News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Psuedo interrupts

Started by Neil, May 16, 2010, 04:27:25 PM

Previous topic - Next topic

Neil

This comes from another post about text adventure games, something I haven't written for almost 25 years & I've hit a snag converting my 16 bit library to 32 bit. My question - Is it possible to write a callback function using the timer in such a way that it can emulate interrupts i.e. execute a piece of code every N (approx) seconds no matter what the main program is doing. This is completely unknown territory for me & any advice would be would be very useful.

jj2007

Have a look at the last parameter of SetTimer.

Neil


Neil

Hmm, pointer to a function when timer value elapses, this looks interesting & could be what I'm looking for. Thanks jj  :U I'll do some testing with it & see what happens.

jj2007

I can assure you it works - my callback is 263 lines long and covers 20 different events :bg

dedndave

have to have the dwarves pop out, eh ?
oh - and let's not forget the pirate, too   :P

you could probably just use time of day and check it round-robin style for that
the time being precise isn't that critical

Neil

Yep! I used it (Timer_Tick) to control other characters & events, worked quite well I seem to remember although there wern't any Pirates or Dwarves in my world more like Gypsys & other vagrants  :toothy

dedndave

Quote... although there wern't any Pirates or Dwarves in my world more like Gypsys & other vagrants

lol - sounds great
you could even have bogdan pop out as one of the gypsies and steal your code   :lol

i need to devise a game where he is the bad guy
maybe i'll make it a shoot-em-up

Neil

You would need a mighty big gun for that, maybe like the one in 'QUAKE' - BFG  :cheekygreen:

hutch--

Dave,

> i need to devise a game where he is the bad guy

I did not make Bogdan that Vlad Tepes icon for nothing, if you started that game he would come out with a nuclear disintegrator and melt your screen.  :bdg
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

i was thinking of a Forum Maze game
he moves and locks threads, while you shoot at him
if he locks or moves 10 threads before you get 10 caps in his ass, you lose   :bdg

jj2007

Quote from: dedndave on May 17, 2010, 02:28:29 AM
i was thinking of a Forum Maze game
he moves and locks threads, while you shoot at him
if he locks or moves 10 threads before you get 10 caps in his ass, you lose   :bdg
And losing means you have to attend his course "basic concepts of assembler". If you lose twice, you will have to digitally sign an obligation to ban ML.EXE from your harddisk :green2

hutch--

 :bg

Its all in the style, Bogdan is far more gracious than I am, he will lock the thread and tell them why, if I catch anyone posting virus/trojan/hacking etc ... I assist them in finding another venue that is better suited to their interest.  :bdg
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

i am a pretty good shot
plus, being the guy that writes the game, i'd probably have a back-door to unlimited ammo or something - lol
the guys he works with would enjoy it more than anyone

Neil

I've re-opened this thread as I have hit a minor snag, as jj says the function works perfectly, but, I need it to repeat every 15 to 20 seconds (accuracy not important). The method I've come up with is to re-invoke the SetTimer function just before my own function exits. My question, is this the way to do it or is there a better way?