I wrote a small program, and it appears (offset is 1) that GetModuleHandle is causing this error. I'm just calling it to recieve my hInstance on the first lone of code...
Posted on 2006-06-28 15:49:01 by Bobbias
Please attach the exe.
Posted on 2006-06-28 16:13:36 by ti_mo_n
Alright, I'll pack everything into a rar so you can check out what I got.
Attachments:
Posted on 2006-06-28 16:46:17 by Bobbias
The problem is not related to GetModuleHandle. You are using arguments in WndProc incorrectly.

	WndProc	proc	hWnd:HWND, uMsg:DWORD, wParam:WPARAM,lParam:LPARAM
LOCAL ps:PAINTSTRUCT
LOCAL rect:RECT
LOCAL hdc:HDC

.IF uMsg==WM_DESTROY ;if the user closes our window
invoke PostQuitMessage,NULL ;quit our application
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd,addr ps
mov hdc,eax
invoke GetClientRect,hWnd,addr rect
invoke CreateCompatibleDC,hdc
mov BackBuf,eax
invoke SelectObject,BackBuf,Bitmap
invoke BitBlt,hdc,BMP_X,BMP_Y,16,128,BackBuf,0,0,SRCCOPY ;Flip
invoke EndPaint,hWnd,addr ps
invoke DeleteObject,Bitmap
.ELSEIF uMsg==WM_KEYDOWN
.IF wParam==VK_ESCAPE
invoke PostQuitMessage,0
.ELSEIF wParam==VK_UP
invoke MoveBitmapUp
.ELSEIF wParam==VK_DOWN
invoke MoveBitmapDown
.ELSEIF wParam==VK_LEFT
invoke MoveBitmapLeft
.ELSEIF wParam==VK_RIGHT
invoke MoveBitmapRight
.ENDIF
.ELSE

invoke DefWindowProc,hWnd,uMsg,wParam,lParam ;Default message processing
ret
.ENDIF

xor eax,eax
ret
WndProc endp
Posted on 2006-06-28 18:31:54 by arafel
:/ now I feel stupid. In any case, I got that working after you popinted that out, and for some reason my nice little MoveBitmap procs don't seem to do anything (and I did add in the mov BMP_Y(orX),eax instructions I forgot)
Posted on 2006-06-28 18:45:00 by Bobbias
Your MoveBitmap procs aren't doing anything because of the following:

(I added comments to explain what you're doing)

MoveBitmapUp proc
.IF BMP_Y>0
mov eax,BMP_Y ;mov BMP_Y into EAX
sub eax,1 ;Decrease EAX by 1
.ELSEIF BMP_Y<0
mov BMP_Y,0
.ENDIF
xor eax,eax ;Throw away EAX (Zero it) EAX = 0
RET
MoveBitmapUp endp


You throw away the value after modifying it. Upper proc could be written as follows:

MoveBitmapUp proc
.IF BMP_Y>0
dec BMP_Y ;Decrease BMP_Y by 1
.ELSE
mov BMP_Y,0
.ENDIF
RET
MoveBitmapUp endp


The same applies to MoveBitmapLeft - You can replace most of it with one DEC BMP_X

Now for MoveWindowDown:

MoveBitmapDown proc
mov eax,BMP_Y
mov ebx,SCR_Y
cmp eax,ebx
jnb BMP_ABOV_Y ;jump if BMP_Y is greater than SCR_Y
add eax,1
jmp Y_END ;jump past this code
BMP_ABOV_Y:
mov eax,BMP_Y
mov ebx,SCR_Y
mov eax,ebx
Y_END:
xor eax,eax ;Throw away any value calculated and return
xor ebx,ebx
RET
MoveBitmapDown endp


You have to save the value back into your BMP_Y or you can modify BMP_Y directly using ADD, SUB, etc...
Posted on 2006-06-28 19:44:44 by JimmyClif
Thanks, I'm still getting the hang of certain nuances of ASM programming. I'm forever forgetting how much I can do to a value directly and such, lol. Plus, doing it your way is faster (if only marginally), and more compact (not that it matters, with something this small).
Posted on 2006-06-28 21:27:07 by Bobbias