timing interrupt routine

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
zx81user
Posts: 54
Joined: Mon Mar 25, 2013 3:14 am

timing interrupt routine

Post by zx81user »

Hi All,
I cleaned out the garage last weekend and bumped into my good old ZX81! I couldn't dare to throw it out so I thought maybe I can use it for "something", not sure yet what to use it for though!

The problem I ran into long time ago is that I couldn't figure out how to get an interrupt at constant intervals. The interval itself doesn't really matter, could be 1, 10, 100 or even 1000ms, for as long as it is constant. Is there anyway this can be achieved? There is now so much knowledge available through internet that my chances of finding a solution is about a million times higher than back in the good old 80's.....

Any help is highly appreciated!
Michel
zx81user
Posts: 54
Joined: Mon Mar 25, 2013 3:14 am

Re: timing interrupt routine

Post by zx81user »

I think I found the answer already. If I understand correctly, the IX register contains an interrupt vector that will be called 50 or 60 times per second. By changing this vector to my own routine and ending with a jump to the original vector that should then exactly do what I want. Is it that simple hey!?!?!

Michel
dr beep
Posts: 2076
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: timing interrupt routine

Post by dr beep »

Almost!

Since IX is changed twice during screen you need to do your routine, call the screen and then set some registers right before returning to the mainprogram. Must go now, will add right settings later!
dr beep
Posts: 2076
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: timing interrupt routine

Post by dr beep »

This should work!

Code: Select all

in your mainprogram

       LD   IX,mycode

mycode CALL #281	; the normal IX routine
       
myprog NOP

end    CALL #292
       CALL #220
       LD   IX,mycode
       JP   #2A4
zx81user
Posts: 54
Joined: Mon Mar 25, 2013 3:14 am

Re: timing interrupt routine

Post by zx81user »

ok, that is a lot more than I initially thought :-). I found a clock program, I think it will use the same trick so I will disassemble that and see what is exactly there. Is there any way to do a smart kind of disassembling of some machine code in a REM statement?
dr beep
Posts: 2076
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: timing interrupt routine

Post by dr beep »

You could also do this:

Code: Select all

     LD HL,FRAMES
     LD A,(HL)
WAIT CP (HL)
     JR Z,WAIT
This will wait until 1/50 sec has passed.

If you want to code MC only I would suggest using a default set up for the program which will generate the REM already.
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: timing interrupt routine

Post by PokeMon »

dr beep wrote: This will wait until 1/50 sec has passed.
I think this is not correct.
Your example waits for the next frame but only at the beginning of a frame it is 1/50 second.
Could be called short before the end of a frame and it will be much shorter. :shock:
dr beep
Posts: 2076
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: timing interrupt routine

Post by dr beep »

True, but it will synchronize the game.

When in 1 loop the game comes here faster it will wait until the intrupt has occured where in another loop it will wait a shorter time to finally continue at the same time.

To me it is a simple routine I use combined with a DJNZ loop to wait a certain time.
zx81user
Posts: 54
Joined: Mon Mar 25, 2013 3:14 am

Re: timing interrupt routine

Post by zx81user »

What is the physical address of "FRAMES"?
dr beep
Posts: 2076
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: timing interrupt routine

Post by dr beep »

zx81user wrote:What is the physical address of "FRAMES"?
#4034
Post Reply