Interrupt handler

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
retrofan8081
Posts: 2
Joined: Thu Aug 06, 2020 11:29 am

Interrupt handler

Post 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


programmestart:
       LD   IX,mycode
loop:
     ; 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

mystuff:
  do my stuff
  ret
if anyone can tell me what's wrong that would be brilliant thank you!!!
dr beep
Posts: 1348
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Interrupt handler

Post 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.
8E974BA1-FCF0-4CCF-B6F6-8F1CD1695368.jpeg
retrofan8081
Posts: 2
Joined: Thu Aug 06, 2020 11:29 am

Re: Interrupt handler

Post by retrofan8081 »

Thank you!

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

Code: Select all

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

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

isr:
   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
dr beep
Posts: 1348
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Interrupt handler

Post 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:


https://m.youtube.com/watch?v=lmWkLrS9A ... w&index=15
Post Reply