Waiting some time!

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Waiting some time!

Post by PokeMon »

Yes - that should be right. Anyway the 5.5 million calculation was completely wrong.
This brings me to following approach with more easy calculation:

Code: Select all

            ld      c, N
    loop   djnz loop
            dec c
            jr nz, loop
Which is only 7 bytes long, runs approx. C * 1ms and avoids stack usage (which should better avoided when calculating every byte).
Only the first iteration of B is undefined - giving a tolerance of about +/- 500us and a granularity in ms steps.
In SLOW mode you have to multiply with about factor 4, so it is C * 4ms +/- 2ms, giving an all in all running time of maximum 1 second with C=0.
antoniovillena
Posts: 23
Joined: Fri Aug 15, 2014 5:48 pm

Re: Waiting some time!

Post by antoniovillena »

Wow. It's awesome. Good optimization. You can eliminate the unknowed B by changing the first instruction with "defb 1, N" and with A!=13. That loads B with $10 (opcode of djnz).
Post Reply