Page 1 of 1

Interrupt handler

Posted: Mon Jan 11, 2021 12:36 pm
by retrofan8081
Hi all,

I know this comes up from time to time and I've looked through the forum for clues and one post had something promising but I'm stuck.

I'm starting to learn machine code and I'm pretty good now but I want to be able to do something like the 'nova' prgram does and that's put some thing on the screen the whole time. To do this i need to 'hook' the screen routine and call my code after it's drawn.

There's a post that has some code by Dr Beep and I've tried this but it doesn't work. What I think it does is change the ix register to point to the new routine so it is called instead of the ROM code and you do what you need to do in there as well as calling the ROM code that would have run anyways.

I use EO and in the debugger after I've run the code the IX register has recovered it's old value and my code isn't being called. Stepping through the ROM is difficult for me and a bit confusing. I've tried it before asking for help....

Here's the code I'm basing my stuff on:

Code: Select all

       LD   IX,mycode
     ; wait for vsync
     ; do some things
     jp loop

mycode CALL #281	; the normal IX routine
myprog CALL mystuff ;   

end    CALL #292
       CALL #220
       LD   IX,mycode
       JP   #2A4

  do my stuff
if anyone can tell me what's wrong that would be brilliant thank you!!!

Re: Interrupt handler

Posted: Mon Jan 11, 2021 3:54 pm
by dr beep
You must not call 281,
But set BC, HL and A as done in 281, but only do the call to 2b5.

Re: Interrupt handler

Posted: Tue Jan 12, 2021 2:52 pm
by retrofan8081
Thank you!

I have updated my code now and it works like I wanted it to.

Code: Select all

   ld    ix,isr	; make rom call my code instead
   ret		; back to basic

; ------------------------------------------------------------

   ld    a,r
   ld    bc,$1901
   ld    a,$f5
   call  $02b5
   call  $0292
   call  $0220

   ; do whatever you need to here

   ld    ix,isr
   jp    $02a4

Re: Interrupt handler

Posted: Tue Jan 12, 2021 10:43 pm
by dr beep
My game does the same, the intrupt in my games
meassures time passed, 5 sec and 20 sec.

Mainprogram does many calculations but is always cut off after 20sec. a video of the game: ... w&index=15