hello,

here you can find a game I'm working on (i disabled the game actually, the menu screen is the only important thing atm): (~500kb)

http://www.uni-koblenz.de/~tenshi/nopsnake.zip

1. a friend of mine has no TFT, that means a s?mple monitor. he says the background (the brown one) is distorted at the left and right border in the middle. i'm not sure if this is a monitor problem or a problem with my application. would be nice if you could report anything weird in the menu screen.

2. hiroshimator pointed me on the mouse running sluggish. it's true, if you move the mouse a bit too fast it jumps and isn't shown fluently. i don't know where the problem is, here's the mouse code:

initialisation:


DIINVOKE CreateDevice, lpdi, ADDR GUID_SysMouse, ADDR lpdimouse, 0
.if eax!=DI_OK
FATAL "DI: Creating mouse device failed!"
.endif
DIDEVINVOKE SetCooperativeLevel, lpdimouse, hWin,DISCL_NONEXCLUSIVE or DISCL_BACKGROUND
.if eax!=DI_OK
FATAL "DI: SetCooperativeLevel (MOUSE) failed!"
.endif
DIDEVINVOKE SetDataFormat, lpdimouse, ADDR c_dfDIMouse
.if eax!=DI_OK
FATAL "DI: SetDataFormat (MOUSE) failed!"
.endif
;-----------------------------------------------------------
;set axis data to relative/absolute
;-------------------------------------------
mov my_DIPROPDWORD.diph.dwSize,sizeof(DIPROPDWORD)
mov my_DIPROPDWORD.diph.dwHeaderSize,sizeof(DIPROPHEADER)
mov my_DIPROPDWORD.diph.dwObj,0
mov my_DIPROPDWORD.diph.dwHow,DIPH_DEVICE
mov my_DIPROPDWORD.dwData,DIPROPAXISMODE_REL
DIDEVINVOKE SetProperty,lpdimouse,DIPROP_AXISMODE,addr my_DIPROPDWORD.diph
.if eax!=DI_OK
FATAL "Property could not be set!"
.endif
DIDEVINVOKE Acquire, lpdimouse
.if eax!=DI_OK
FATAL "DI:Acquire mouse failed!"
.endif


reading mouse data:


ReadMouse proc
.if lpdimouse!= NULL
DIDEVINVOKE GetDeviceState,lpdimouse,sizeof(DIMOUSESTATE),addr mouse_state
.if eax!=DI_OK
FATAL "Could not read mouse!"
.endif
mov eax,mouse_state.lX
add mp.x,eax
mov eax,mouse_state.lY
add mp.y,eax
.else
DIINITSTRUCT ADDR mouse_state,sizeof(DIMOUSESTATE)
.endif
ret
ReadMouse endp


my messageloop:


StartLoop:
cmp app_flag,1
jne _nonactive

invoke PeekMessage, addr msg, NULL, 0, 0, PM_REMOVE
and eax, eax
jz IdleTime
cmp [msg.message], WM_QUIT
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop

IdleTime:
.if gameruns==0
.if gameoverf==1
mov gameovermode,1

invoke CheckForHighscore
mcall [dds_back],IDirectDrawSurface7_GetDC,addr backdc
invoke SelectObject, backdc, fonthandle2
mov oldfont,eax
invoke SetTextColor,backdc,000000h
RGB 0CCh,0CCh,0CCh
invoke SetBkColor,backdc,eax
invoke SetBkMode,backdc,OPAQUE ;TRANSPARENT
invoke DrawMyText,addr gameovermsg,225,190
invoke SetTextColor,backdc,000000h
invoke DrawMyText,addr gameover2,210,215
invoke SelectObject,backdc,oldfont
mcall [dds_back],IDirectDrawSurface7_ReleaseDC,backdc
invoke UpdateScreen
mov gameoverf,0
.endif

invoke ReadKeyboard
.if keyboard_state[DIK_DOWN]
mov key_old,DIK_DOWN
;invoke RepaintScreen
mov app_flag,0
invoke StartNewGame
mov gameruns,1
.endif
;--- actually not needed??!!! -----
.if repainted==0
invoke RepaintScreen
mov repainted,1
.endif
.endif

invoke snakemainproc
jmp StartLoop

_nonactive:

[b]invoke ReadMouse[/b]
.if menuid==MENU_MAIN
invoke RepaintMenu
.elseif menuid==MENU_OPTIONS
invoke RepaintOptions
.elseif menuid == MENU_HIGHSCORE
invoke RepaintHighscore
.elseif menuid == MENU_INSTRUCT
invoke RepaintInstruct
.elseif menuid == MENU_CREDITS
invoke RepaintCredits
.elseif menuid == MENU_NETGAME
invoke RepaintNetgame
.endif



invoke GetMessage,ADDR msg,NULL,0,0
and eax, eax
jz ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:


mouse cursor drawing in the menu loop procedure:


invoke BlitBitmap,mp.x,mp.y,0,0,0,0,offset surface_mycursorsprite,offset bmp_mycursorsprite_info,0FFFFFFh,1
invoke UpdateScreen


i really have no idea where the problem is, perhaps it's the message loop?

thank you!

NOP
Posted on 2003-10-16 15:42:34 by NOP-erator
Your friends monitor sounds like it may have a pin cushion problem, you can usually find an adjustment labelled PCC either in back or on the PCB for the monitor (usually near the flyback) it will allow you to adjust the pin cushioning.
Posted on 2003-10-16 18:10:22 by donkey
Hi

You could try to read the mouse bufferedto avoid losing mouse moves.

Eugen
Posted on 2003-10-16 18:25:11 by Eugen
i already guessed it's a message loop problem!! from the beginning i wondered about the weird structure, i changed it to that now, and it works fine:



StartLoop:


invoke PeekMessage, addr msg, NULL, 0, 0, PM_REMOVE
and eax, eax
jz IdleTime
cmp [msg.message], WM_QUIT
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop

IdleTime:
cmp app_flag,1
jne _nonactive
.if gameruns==0
.if gameoverf==1
mov gameovermode,1

invoke CheckForHighscore
mcall [dds_back],IDirectDrawSurface7_GetDC,addr backdc
invoke SelectObject, backdc, fonthandle2
mov oldfont,eax
invoke SetTextColor,backdc,000000h
RGB 0CCh,0CCh,0CCh
invoke SetBkColor,backdc,eax
invoke SetBkMode,backdc,OPAQUE ;TRANSPARENT
invoke DrawMyText,addr gameovermsg,225,190
invoke SetTextColor,backdc,000000h
invoke DrawMyText,addr gameover2,210,215
invoke SelectObject,backdc,oldfont
mcall [dds_back],IDirectDrawSurface7_ReleaseDC,backdc
invoke UpdateScreen
mov gameoverf,0
.endif

invoke ReadKeyboard
.if keyboard_state[DIK_DOWN]
mov key_old,DIK_DOWN
;invoke RepaintScreen
mov app_flag,0
invoke StartNewGame
mov gameruns,1
.endif
;--- actually not needed??!!! -----
.if repainted==0
invoke RepaintScreen
mov repainted,1
.endif
.endif

invoke snakemainproc
jmp StartLoop

_nonactive:

invoke ReadMouse
.if menuid==MENU_MAIN
invoke RepaintMenu
.elseif menuid==MENU_OPTIONS
invoke RepaintOptions
.elseif menuid == MENU_HIGHSCORE
invoke RepaintHighscore
.elseif menuid == MENU_INSTRUCT
invoke RepaintInstruct
.elseif menuid == MENU_CREDITS
invoke RepaintCredits
.elseif menuid == MENU_NETGAME
invoke RepaintNetgame
.endif
jmp StartLoop

comment ~

invoke GetMessage,ADDR msg,NULL,0,0
and eax, eax
jz ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
~
ExitLoop:

return msg.wParam

Posted on 2003-10-17 01:43:25 by NOP-erator
You could probably lose the secondary MessagePeek, Translate and Dispatch and just jump backwards to the beginning of your MessagePump...
Posted on 2003-10-18 00:10:52 by Homer