How to get out cleanly of an interrupt routine ?

페이지 2/2
1 |

By ro

Scribe (4902)

ro의 아바타

11-02-2011, 08:55

nobody said assembly was easy Tongue

By bore

Master (161)

bore의 아바타

11-02-2011, 09:04

nobody said assembly was easy Tongue
Assembly is easy!

By konamiman

Paragon (1190)

konamiman의 아바타

11-02-2011, 13:13

Just for your information... do you know what you will found if you disassemble the startup routine of any Konami game?

Something like this:

...(some initialization)...
di
ld a,#c3
ld (#fd9f),a
ld hl,int_routine
ld (#fda0),hl
ei
X: jr X

So... EVERYTHING is in the interrupt. There is no "main loop". Isn't that funny? Smile

By Metalion

Paragon (1622)

Metalion의 아바타

11-02-2011, 14:36

EVERYTHING is in the interrupt. There is no "main loop". Isn't that funny? Smile
Yeah, I knew about that already ...

It is indeed strange, but it makes sense when you think about it. In effect, the game loop is re-initialized at each frame, which gives you the opportunity to divide each action into fragments processed in the main game loop, within each frame at the same moment.

However, when you're out of the game loop (ie. an level intro ...) it makes much less sense to manage that thru the ISR.

By nikodr

Paladin (748)

nikodr의 아바타

11-02-2011, 14:48

Just for your information... do you know what you will found if you disassemble the startup routine of any Konami game?

Something like this:

...(some initialization)...
di
ld a,#c3
ld (#fd9f),a
ld hl,int_routine
ld (#fda0),hl
ei
X: jr X

So... EVERYTHING is in the interrupt. There is no "main loop". Isn't that funny? Smile
Very clever trick,however i think it would be better and have more power management for our poor z80 (make them last a little longer in that cruel world) by having something like

X:Halt
Jr X

Now everything happens in the interrupts and z80 consumes less electricity ?

By konamiman

Paragon (1190)

konamiman의 아바타

11-02-2011, 15:17

X:Halt
Jr X

Now everything happens in the interrupts and z80 consumes less electricity ?
Not exactly. Z80 does not "shut down" itself, nor enters any type of power saving mode, when HALT is executed; instead, it enters a loop in which it continously exectues NOP instructions. I read somewhere that this is necesssary for the memory refresh mechanism to continue working.

By RetroTechie

Paragon (1563)

RetroTechie의 아바타

11-02-2011, 18:16

Just for your information... do you know what you will found if you disassemble the startup routine of any Konami game?

Something like this:

...(some initialization)...
di
ld a,#c3
ld (#fd9f),a
ld hl,int_routine
ld (#fda0),hl
ei
X: jr X

So... EVERYTHING is in the interrupt. There is no "main loop". Isn't that funny? Smile
I've seen that often but disadvantage is that all work is done inside an interrupt routine. This may have some disadvantages that don't apply to regular code. Of course the point is timing of game events, I'd rather use something like:

... (some initialization) ...
main:
   (process keys/joystick etc)
   (process sound)
   (process video)
   halt
   jp main

As long as you take care that everything between "main" and "halt" executes in less than 1 interrupt timeslice, you have proper timing but your code runs outside interrupt routine. Less tricky that way... Wink

Or do only repetitive, time-sensitive tasks like movement & background music in interrupt routine, and [things that may take very long to execute] in main program.

페이지 2/2
1 |