timing interrupt routine
timing interrupt routine
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
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
Re: timing interrupt routine
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
Michel
Re: timing interrupt routine
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!
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!
Re: timing interrupt routine
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
Re: timing interrupt routine
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?
Re: timing interrupt routine
You could also do this:
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.
Code: Select all
LD HL,FRAMES
LD A,(HL)
WAIT CP (HL)
JR Z,WAIT
If you want to code MC only I would suggest using a default set up for the program which will generate the REM already.
Re: timing interrupt routine
I think this is not correct.dr beep wrote: This will wait until 1/50 sec has passed.
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.
Re: timing interrupt routine
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.
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.
Re: timing interrupt routine
What is the physical address of "FRAMES"?
Re: timing interrupt routine
#4034zx81user wrote:What is the physical address of "FRAMES"?