The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Neil on May 16, 2010, 04:27:25 PM

Title: Psuedo interrupts
Post by: Neil on May 16, 2010, 04:27:25 PM
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.
Title: Re: Psuedo interrupts
Post by: jj2007 on May 16, 2010, 04:54:27 PM
Have a look at the last parameter of SetTimer.
Title: Re: Psuedo interrupts
Post by: Neil on May 16, 2010, 05:25:55 PM
thanks jj will do
Title: Re: Psuedo interrupts
Post by: Neil on May 16, 2010, 05:32:29 PM
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.
Title: Re: Psuedo interrupts
Post by: jj2007 on May 16, 2010, 05:48:46 PM
I can assure you it works - my callback is 263 lines long and covers 20 different events :bg
Title: Re: Psuedo interrupts
Post by: dedndave on May 16, 2010, 05:49:33 PM
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
Title: Re: Psuedo interrupts
Post by: Neil on May 16, 2010, 06:25:46 PM
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
Title: Re: Psuedo interrupts
Post by: dedndave on May 16, 2010, 06:29:58 PM
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
Title: Re: Psuedo interrupts
Post by: Neil on May 16, 2010, 06:38:39 PM
You would need a mighty big gun for that, maybe like the one in 'QUAKE' - BFG  :cheekygreen:
Title: Re: Psuedo interrupts
Post by: hutch-- on May 17, 2010, 01:02:29 AM
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
Title: Re: Psuedo interrupts
Post by: 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
Title: Re: Psuedo interrupts
Post by: jj2007 on May 17, 2010, 06:33:09 AM
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
Title: Re: Psuedo interrupts
Post by: hutch-- on May 17, 2010, 12:58:08 PM
 :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
Title: Re: Psuedo interrupts
Post by: dedndave on May 17, 2010, 01:35:43 PM
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
Title: Re: Psuedo interrupts
Post by: Neil on June 18, 2010, 12:53:04 PM
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?
Title: Re: Psuedo interrupts
Post by: Tedd on June 18, 2010, 02:11:42 PM
The timer will trigger periodically until you specifically kill it, there's no need for you to do anything extra (i.e. it repeats by default, it's not a one-shot.)
Title: Re: Psuedo interrupts
Post by: Neil on June 18, 2010, 02:24:04 PM
Thanks Tedd, I thought it was a One Shot