hi all,

as some of you could remember, i'm doing a little game. I've tought to do it for compatibiliti in W95,98, without DX or other library needed.

The game (not yet complete) is attached.

As you could see, I need again some suggestion about followings improvements:

Keys: when i press the Space (shot) starship stops to move...
Mouse: when i move the mouse everithing pause down...

Maybe someone uf us has already solved this issues..

Thanks All Again, Angelo
Posted on 2001-10-21 14:07:06 by Bit7
I'm not a good programmer :( (not in Win32 asm), but where do you put the procedure for shooting?

Mouse: ???
I move the mouse, I even click but nothing happend.

Any way, nice job for begining. I wish I have the time to write something like this.
Posted on 2001-10-22 07:27:24 by scarpelius
Please study the classics :alright: will you?

again from Chris Hobbs SpaceTris... source code here is its main loop:

; (some init code cut here......)
; Loop until PostQuitMessage is sent
invoke PeekMessage, ADDR msg, NULL, 0, 0, PM_REMOVE
.if (eax != 0)
; Break if it was the quit messge
mov eax, msg.message
.IF eax == WM_QUIT
; Break out
jmp shutdown

; Translate and Dispatch the message
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg


; Call our Main Game Loop
; NOTE: This is done every loop
; iteration no matter what
invoke Game_Main

; Do they want to leave
.if GameState == GS_EXIT
jmp shutdown



; Shutdown the Game
invoke Game_Shutdown

; Show the Cursor
invoke ShowCursor, TRUE

; We are through
return msg.wParam

WinMain endp

if this dosent help you...well then you need THREADS and/or DirectX (esp DirectInput)
Posted on 2001-10-22 13:27:38 by BogdanOntanu
Game loads up fine and I see the credits, but then when I press a button I get an exception.

laptop PIII 850
128MB ram
Posted on 2001-10-22 14:39:35 by Kenny
Same here kenny, it's the privileged instruction exception caused by the in ax, 60h.
Angelo: using ports to get keyboard input is not the right way to do it. In win9x it will work but it's still not correct, and in win2k it won't work because it won't allow you INs and OUTs...

Posted on 2001-10-22 14:44:45 by Thomas
scarpelius, Kenny, Thomas,

first i've put the keys inside WM_KEYDOWN message, but it was incerdibly slow. So someone indicate me to use this in that's much more fast than using Windproc messaging. This is why i'm using IN. Sorry for NT/2K, seems there is not better way without using DX.

many thx for the code skeleton ! I'm studying it very well !

This evening i've done the starship explosion. Now i would do an end level monster .... But first i try to optimize for maximum speed (i've seen that in a P1 133 the gamo is too much slow...)

I will send again game and code when level1 will be finished.

THX all again for your support.
Bye A
Posted on 2001-10-22 16:00:36 by Bit7

for WinNT/2k you could possibly install a "low level keyboard hook" with SetWindowsHookEx. This may be faster and whats more you will be able to prevent the system from sending WM_KEYxxx messages to your window proc. For mouse input there exists a similar hook as well.

Posted on 2001-10-23 07:04:23 by japheth
thanks japhet, i eill try !
Posted on 2001-10-23 13:32:37 by Bit7
Hi Angelo!

On my AMD 1,3 gHz the game is MUCH too fast! I can barely see what I'm shooting at before it's gone again, and the arrow keys are VERY sensitive (moves the ship about 2 inches when tapped for a millisecond or so :) )
My only hope of getting a high score now is just to keep shooting :(
Posted on 2001-10-24 13:02:03 by Qweerdy
On my AMD 1,3 gHz the game is MUCH too fast

Mine is even faster (1.4Ghz) :grin:. Angelo: maybe you can use some kind of timer that has a known rate to time your game...

Posted on 2001-10-24 13:44:44 by Thomas
Qweerdy, thomas,

thanks for your feedback.

The speed factor u see after start message box will chose the sleep pause factor in every game loop.

It's not reliable becouse, as you can see, at every start the speed factor change. This becouse i read system time before and after a cycle of 3 mov repated for many times...
Probably system time is affected by windows ring0 priority, or something like this.

But for noe i'm taking this factor to define the pauses. Now it is not still active... i've done the speed calculation but i've leaved the pause fixed to 1 ms. For your pc's it will be set higher.

I get it work on my next posting ...

Thanks bye.
Posted on 2001-10-24 17:03:37 by Bit7
really not my area... so the only thing that I noticed was that i couldn't replicate the mouse move problem as for the other (interrupt race conflict trapping space vs move ?) well i'm no help there w/o the source. btw: on a 350MHz win98 machine the game runs just right... Nice start.
Posted on 2001-10-24 20:42:34 by rafe
Angelo, varying speed problems are easy to solve. At the start of every frame get the TickCount and use it to calculate the number of ticks the previous frame took. The method I use is:

invoke GetTickCount
push eax
sub eax,preTickVal
pop preTickVal
mov ticksPassed,eax

You then used the ticksPassed as a modifer for all speed values. For example, if you have a variable, shipSpeed = 30 which maybe means that the ship moves 30 pixels per frame, well from now on multiply shipSpeed by ticksPassed before its used so that instead of meaning "per frame" it will mean "per tick".

I usually divide ticksPassed by 1000 so that it will mean "per second" instead which is easier to follow.
Posted on 2001-10-25 05:13:21 by Eóin