Hi Thomas,
I've done a few experiments without much success.
The first idea I had was to simply to wait for the scanline to occur, in a tight loop.
I know you said not to use assembly but this was just to see what effect the interpreter was having and how much it varied when the program was compiled with the STOS Compiler.
To call the routine in STOS:
Code: Select all
S15=start(15)+28
dreg(0)=looplength:call S15
Border removal switch:
Code: Select all
FREQ=$FFFF820A
poke FREQ,2:dreg(0)=dreg(0):poke FREQ,0
The effect of the dreg(0)=dreg(0) should be compiled to a move d0,d0 by STOS having no effect but the required delay.
The results show that the loop length has to be 9063 for a stable border removal effect on an 8MHz ST but when compiled the loop length has to be 10324. You can see a bit of graphics memory in the lower border.
Then I had a good idea:
Use the 200Hz timer to get us near scanline 199. We'd get 4 ticks per frame. If we wait until the 4th tick that leaves 75% CPU time free at the start of the frame for code and graphics updates. Surely we would only have to wait a few hundred clock cycles to get to scanline 199? But this was unstable.
10 hide : key off : mode 0 : curs off : flash off : click off : mouseoff
20 HZ=$FFFF820A
30 KBD=$FFFFFC02
40 THHZ=$4BA
40 S15=start(15)+28
60 rem ** it is crucial to wait for the vbl
70 rem ** and reset the timer as near as possible
80 wait vbl: loke THHZ,1
rem ** main loop
100 doke $FFFF8240,$70
110 gosub 200
120 if peek(KBD)=57 then goto 170
130 wait vbl
140 loke THHZ,1
150 goto 100
200 rem ** wait for the bottom quarter of the screen then the required line
210 while leek(THHZ) mod 4 <> 0 : wend
220 dreg(0)=100:call S15
230 poke HZ,2:dreg(0)=dreg(0):poke HZ,0
240 return
The problem is that the timing in STOS is so vague. This is why you really need to use Timer B interrupts and STOS doesn't have any call back handlers for that sort of thing. Does anyone else have other ideas?
You do not have the required permissions to view the files attached to this post.
Still got, still working: Atari 4Mb STe, 520STFM, 2.5Mb STF.
Hardware: Cumana CSA 354, Ultimate Ripper, Blitz Turbo, Synchro Express II (US and UK Versions).