flat assembler
Message board for the users of flat assembler.

Index > Windows > [WIP] BitBox

Author
Thread Post new topic Reply to topic
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 17 Jun 2010, 13:23
I am making a tool to fondle bits in various ways.
Check it out, leave a reply, share some ideas...

Note:
You must be logged in for attatchment to be visible.


Description: Latest Version
Download
Filename: BitBox.zip
Filesize: 8.28 KB
Downloaded: 388 Time(s)


_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.


Last edited by bitshifter on 04 Nov 2010, 18:40; edited 7 times in total
Post 17 Jun 2010, 13:23
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 17 Jun 2010, 16:14
Cool. Put a button to select/deselect all bits. A option to choose among byte, word and dword would be useful too.
Post 17 Jun 2010, 16:14
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 17 Jun 2010, 16:45
using colored(nice look) list box with 0..32..more items of '0' or '1' symbolizing bit states can remove all the checks, their alignment with 'static' control, their alignment relatively themselves, font independence. Bit offsets can be stored in same items too. Clicking/selecting an item you send a CB_GETITEMDATA message which returns e.g. 0x00 or 0x01 which is to be toggled through XOR 1:
0 xor 1 = 1
1 xor 1 = 0
Post 17 Jun 2010, 16:45
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 17 Jun 2010, 16:49
more readability needed as your program must be useful in computer basic numerology: ignore " " or "'" or anything else in string flow: it provides readability for the end user
Post 17 Jun 2010, 16:49
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 18 Jun 2010, 00:19
Small example, best viewed in fasmw(ouadji), toggle bits with the mouse:

Code:
format pe gui 4.0
include 'win32wx.inc'
rw equ readable writable




section '' code rw executable
items   dd ?
brushes dd ?,?

buf24bytes db 24 dup ?
fmt        du '%d',0
entry $
        mov     ecx,32
        mov     ebx,10
  .init_bits:
        xor     edx,edx
        push    edx
        lea     eax,[ecx-1]
        div     ebx
        shl     edx,16
        lea     eax,[eax+edx+$0030'0030]
        push    eax
        push    $0020'0030
        loop    .init_bits
        mov     [items],esp

        xor     eax,eax
        invoke  DialogBoxParamW,eax,eax,eax,WindowProc,eax

        add     esp,6*2*64
        ret

proc WindowProc wnd:dword, msg:dword, wParam:dword, lParam:dword
        mov     eax,[msg]
        .if     eax=WM_CLOSE
                invoke  EndDialog,[wnd],'cool'
        .elseif eax=WM_INITDIALOG
                mov     ecx,32
          .load_bits:
                push    ecx
                invoke  SendDlgItemMessageW,[wnd],IDC_LSTBITS,LB_ADDSTRING,0,0
                pop     ecx
                loop    .load_bits

                invoke  CreateSolidBrush,$00e0e0e0
                mov     [brushes],eax
                invoke  CreateSolidBrush,$00f0f0f0
                mov     [brushes+4],eax
        .elseif eax=WM_MEASUREITEM
                mov     eax,[wParam]
                .if     eax=IDC_LSTBITS
                        mov     eax,[lParam]
                        mov     dword[eax+16],12
                .endif
        .elseif eax=WM_DRAWITEM
                mov     eax,[wParam]
                .if     eax=IDC_LSTBITS
                        mov     ebx,[lParam]
                        test    byte[ebx+8],1
                        mov     eax,[brushes]
                        mov     ecx,[brushes+4]
                        cmovnz  eax,ecx
                        push    eax
                        lea     eax,[ebx+28]
                        invoke  FillRect,dword[ebx+24],eax

                        invoke  SetBkMode,dword[ebx+24],TRANSPARENT

                        push    /*DT_EXPANDTABS+*/DT_EXTERNALLEADING+DT_LEFT+DT_NOCLIP+DT_NOPREFIX+DT_SINGLELINE+DT_VCENTER
                        lea     eax,[ebx+28]
                        push    eax
                        push    4
                        mov     eax,[ebx+8]
                        lea     eax,[eax*2+eax]
                        shl     eax,2
                        add     eax,[items]
                        push    eax
                        invoke  DrawTextW,dword[ebx+24]
                .endif
        .elseif eax=WM_COMMAND
                mov     eax,[wParam]
                .if     ax=IDC_LSTBITS
                        shr     eax,16
                        .if     eax=LBN_SELCHANGE
                                invoke  SendDlgItemMessageW,[wnd],IDC_LSTBITS,LB_GETCURSEL,0,0
                                mov     ebx,[items]
                                push    0
                                push    eax
                                lea     eax,[eax*2+eax]
                                lea     eax,[ebx+eax*4]
                                xor     byte[eax],$01
                                invoke  SendDlgItemMessageW,[wnd],IDC_LSTBITS,LB_SETCURSEL

                                xor     eax,eax
                                mov     ecx,32
                          .gether_bits:
                                bt      dword[ebx],0
                                rcr     eax,1
                                add     ebx,12
                                loop    .gether_bits
                                invoke  wsprintf,buf24bytes,fmt,eax
                                add     esp,4
                                invoke  SendMessageW,[wnd],WM_SETTEXT,0,buf24bytes
                        .endif
                .endif
        .endif
.ret0:  xor     eax,eax
        ret
endp




section '' import rw
library gdi32,    'gdi32.dll',\
        kernel32, 'kernel32.dll',\
        user32,   'user32.dll'
include 'api\gdi32.inc'
include 'api\kernel32.inc'
include 'api\user32.inc'




section '' resource rw
IDD_MAIN    = 0
IDC_LSTBITS = 1

directory RT_DIALOG,dialogs

resource dialogs,\
         IDD_MAIN,0,idd_main

dialog idd_main,'main',0,0,200,230,/*WS_VISIBLE+*/WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+DS_CENTER,,,'Courier New',8
  dialogitem 'listbox','',IDC_LSTBITS,3,3,20,220,WS_VISIBLE+WS_CHILD+WS_TABSTOP+LBS_NOINTEGRALHEIGHT+LBS_OWNERDRAWFIXED+LBS_NOTIFY
enddialog
    
Post 18 Jun 2010, 00:19
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 21 Jun 2010, 03:26
A little more progress...

New application icon and file version information.
Since we are a tool window the icon is only used for file build.

I hacked into the system menu so we now have a 'Sticky' and 'About' options.
The 'About' option displays a simple message box with version info and such.
The 'Sticky' option toggles the topmost window style (topmost by default)

Also i have subclassed the edit controls and
started to verify valid user input in realtime.

Still much work to do, but this is enough for an alpha version Razz

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.


Last edited by bitshifter on 28 Jun 2010, 13:36; edited 1 time in total
Post 21 Jun 2010, 03:26
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 22 Jun 2010, 04:55
And some more small progress...

Added code to make sure common controls are registered.
Added 3 new operation control buttons [and] [or] [xor]
Subclassed rvalue control to start monitoring input.
Changed application icon color from green to light grey.
Minor size optimizations and naming changes.
Added missing version info (now is complete)
Added manifest resource to enable XP themes.

Its been a while since i played with tool tips so i am on a refresher...
Soon we will have them on all the operational control buttons.

I think this will become a very popular and useful tool Razz

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 22 Jun 2010, 04:55
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 22 Jun 2010, 16:13
Smile


Description:
Filesize: 6.17 KB
Viewed: 9397 Time(s)

heh.PNG



_________________
Sorry if bad english.
Post 22 Jun 2010, 16:13
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 28 Jun 2010, 09:51
New version Razz

New look and feel, including many changes inside and out.
Now validates all user input with more robust conversion routines.
I still have more things to add but this is the next release anyway.

Try it out, leave a reply, share an idea...

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 28 Jun 2010, 09:51
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 28 Jun 2010, 10:09
How about a sar button?
Post 28 Jun 2010, 10:09
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 28 Jun 2010, 10:48
how about "number1 sar number2"
that's difficult a bit
Post 28 Jun 2010, 10:48
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 28 Jun 2010, 13:31
Because of the design, it is very easy to add new operations...
For example, to perform the requested operation only needs very little code...
Code:
        mov     ecx,[_rvalue]
        ...
        cmp     eax,ID_BUTTON_SAR
        jne     .not_sar_clicked
        sar     [_lvalue],cl
        jmp     .refresh_lvalue
    .not_sar_clicked:
        ...
    

Originally i was just going to include the standard C bit operations.
But i guess asm users want the complete set of operations.
Maybe i could do a string box where you type in the instruction name.
Otherwise the box will start to become full of buttons and confusing.
Alternately i could script the buttons so user can choose what they are...

Thanks for the reply's, i will consider any ideas to make this a better tool.

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 28 Jun 2010, 13:31
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 30 Jun 2010, 13:48
Post 30 Jun 2010, 13:48
View user's profile Send private message Reply with quote
KingDemon



Joined: 16 Oct 2006
Posts: 21
Location: Somewhere in Romania
KingDemon 28 Oct 2010, 18:49
I like the idea, but wouldn't it be more useful to have two rows of checkboxes - one for source and one for destination instead of just edit box for destination? Very Happy
Also, you could make it run in the Systray and pop-up/pop-down on a global hotkey. Very HappyVery Happy
Or, more complex it could be made into a Desk Band for the taskbar (with SetFocus on global hotkey).Very HappyVery HappyVery Happy
Post 28 Oct 2010, 18:49
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 28 Oct 2010, 23:14
KingDemon,

Don't sit and wait, you might be first to implement it in such ways! Wink
Post 28 Oct 2010, 23:14
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 29 Oct 2010, 07:59
I think this will be solved with the inclusion of xchg instruction.
Then the box will not have to be cluttered with two bit fields...
As for using the system tray, its something i have thought about.
I have version 0.0.0.4 almost ready, just a few more finishing touches and some test runs...
Post 29 Oct 2010, 07:59
View user's profile Send private message Reply with quote
KingDemon



Joined: 16 Oct 2006
Posts: 21
Location: Somewhere in Romania
KingDemon 29 Oct 2010, 17:08
Well, I started adding the relevant parts from the SysTray example to BitBox, thinking I could do it in less than 10 minutes Cool, but when I realized that I had to go around replacing "DestroyWindow" with "EndDialog"; ".finished" and ".unhandled" with ".processed" and God know what else, I just gave up. I'm simply that lazy. Razz I sure wish I could give these little things more than 10 minutes, but after you've done them a couple of times, it gets boring. And who know, if you try, maybe you'll enjoy it more than I did.
Post 29 Oct 2010, 17:08
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 30 Oct 2010, 09:25
Ok, version 0.0.0.4 snapshot is ready for testing...
It is a bit smaller than v3 to take up less room on the screen.
Also a few more operations have been added.
And more value range checking is being performed.
Still much to do, but so little time...

Edit:
Ok, so i had some time play...
I added a simple taskbar icon which is used to activate window.
Also the window is no longer "sticky" by default.
I guess this bumps it to version 0.0.0.5

Edit:
Version 0.0.0.6
1) Edit controls share same single subclass now with new filtering system.
2) Traded conditional moves for branch statements for increased portability.
3) Enabled edit context menu, cut/copy/paste etc...
Note: Pasted value must not contain any base identifier crap (0x,b,etc)

No known bugs, feel free to find and report one Razz
Thanks for trying it, and thanks for comments/criticism...
Post 30 Oct 2010, 09:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.