Cool, Thanx, I'll see if I can somehow stash that in there somehow.
The game's coming along okay by the way, already got the weapon
implemented... Still working fast by the way. Well, at least I think
so... I have no idea how it would run on a VMU, but hey... How do you
test your stuff btw?
Tobias
--- In vmu-dev@egroups.com, Soeren Gust <sgust@i...> wrote:
> On Wed, Nov 01, 2000 at 06:09:07PM -0000, Tobias_Keizer@y... wrote:
> > Well, I kind of decided to continue in 300kHz mode to see how
fast or
> > slow it is in 32kHz mode... I doubt it'll run tho, but no harm in
> > trying... By the way, how would one go about making a calibration
> > routine? ;)
>
> Here is my calibration routine, I hope I have not forgotten
anything, I took
> it out of my current project.
>
> ;*** first some interrupts I need
> ; timer/counter 0 low 8 bit mode overflow
> .org $13
> jmpf framesync_irq
> ; count clock
> .org $1b
> jmp clockint
>
> ;*** the handlers for the interrupts
> .org $130
> clockint
> push ie
> clr1 ie,mastie
> not1 ext,0
> jmpf clockint
> pop ie
> callf myclockint
> reti
> ; this is the interrupt which wakes us while in HALT mode
in .framesync
> framesync_irq
> bp t0con,t0lovf,.clearie
> reti
> .clearie
> clr1 t0con,t0lie ; disable interrupt
> reti
> ; just set a flag to indicate interrupt
> myclockint
> set1 intflag,0
> ret
>
> ;*** the calibration routine
> ; calibrate the timing, assuming clock between approx. 8KHz and 2MHz
> ; this relies on clk/6/4/170/bogomips/2 = clk/6/bogomips/136/10
> ; explanation of numbers in first term:
> ; 6 builtin division of clock frequency
> ; 4 t0prr in calibration
> ; 170 t0lr in calibration
> ; bogomips result of calibration (74 for 600KHz)
> ; 2 the base timer runs at 2Hz
> ; explanation of additional numbers in second term:
> ; 136 t0lr value for 10fps
> ; 10 10 frames per second
> calibrate
> clr1 ocr,subclk ; use rc osc.
> mov #$fc,t0prr ; prescaler to / 4
> mov #$56,t0lr ; timer0 low to / 170
> clr1 intflag,0
> .loop1 bn intflag,0,.loop1 ; wait for next 0.5s
tick
> clr1 intflag,0
> mov #0,c ; start with 0
> set1 t0con,t0lrun
> .loop2 clr1 t0con,t0lovf
> .loop3 bn t0con,t0lovf,.loop3 ; count timer 0 low
ticks
> inc c
> bn intflag,0,.loop2 ; stop after 0.5s
> clr1 t0con,t0lrun
> set1 ocr,subclk ; use sub clk
> mov #$78,t0lr ; timer0 low to / 136
> xor acc ; t0prr is an incrementing
counter
> sub c ; so negate value
> st bogomips ; store calibration value
> ret
>
> ;*** how to use it
> callf calibrate
> ; switch to rc clock
> ld bogomips
> st t0prr
> clr1 ocr,subclk ; use rc osc.
> ; set frame timer to match fps value
> ld fps
> st b
> mov #$05,acc
> mov #$50,c
> div ; 1360/fps
> xor acc
> sub c
> st t0lr ; 256-1360/fps
>
> ;*** the main frame drawing loop
> frameloop
> ; start frame timer timer
> clr1 t0con,t0lrun ; stop frame timer
> clr1 t0con,t0lovf ; clear overflow
> set1 t0con,t0lie ; enable interrupt to wake up
framesync
> set1 t0con,t0lrun ; start frame timer
>
> [... do drawing here ...]
>
> .framesync
> bp t0con,t0lovf,.synced ; frametime already reached?
> set1 pcon,halt ; sleep till interrupt
> br .framesync ; wait more
> .synced jmp frameloop
>
> Soeren