How does RND() and TIMER work?
Posted: Sun Jul 13, 2014 3:04 pm
Does anyone know how RND() and the TIMER work on the Dragon? How are they generated?
The Dragon Archive Forums
http://archive.worldofdragon.org/phpBB3/
http://archive.worldofdragon.org/phpBB3/viewtopic.php?f=8&t=4894
Code: Select all
?TIMER
0
?TIMER
0
TIMER=3
?TIMER
3
Code: Select all
b7ce| write $80 RND() seed to: $0115
b7ce| write $4f RND() seed to: $0116
b7ce| write $c7 RND() seed to: $0117
b7ce| write $52 RND() seed to: $0118
b7ce| write $59 RND() seed to: $0119
Code: Select all
978e| read $4f RND() seed from: $0116
978e| read $c7 RND() seed from: $0117
9793| read $52 RND() seed from: $0118
9793| read $59 RND() seed from: $0119
97aa| write $2b RND() seed to: $0118
97aa| write $fe RND() seed to: $0119
97b5| write $7f RND() seed to: $0116
97b5| write $8f RND() seed to: $0117
Code: Select all
a59c| write $80 RND() seed to: $0115
a59c| write $4f RND() seed to: $0116
a59c| write $c7 RND() seed to: $0117
a59c| write $52 RND() seed to: $0118
a59c| write $59 RND() seed to: $0119
and on page 197:The Dragon does not use all the M6809's interrupts but
only makes use of the IRQ and FIRQ interrupts.
So i will be concentrate on the normal IRQ first. I looked into XRoar sources.The normal interrupt (IRQ) is derived from the video
circuitry which provides an interrupt request every 20
milliseconds, that is, in correspondence with every
cycle of the mains frequency. This will be slightly
different in countries where the mains frequency is
60Hz rather than 50Hz. The role played by this
interrupt is to update the system clock which is used
by the BASIC function TIMER as well as the functions
SOUND and PLAY.
Code: Select all
event_queue(&MACHINE_EVENT_LIST, &vdg->hs_rise_event);
event_queue(&MACHINE_EVENT_LIST, &vdg->hs_fall_event);
The latest Dragon's use a 14.218 MHz crystal to give a CPU frequency (/16) of 0.888625 MHz, a cycle time of 1.125334 us whereas the CoCo and original Dragon's use the NTSC standard frequency of 14.31818 MHz to give a CPU frequency of 0.894886 MHz or 1.117460 us per cycle. This was to reduce the harmonic interaction between the CPU frequency and that of the PAL crystal ( 4.433619 MHz ) used to generate the TV output, giving a 'cleaner' video signal. The later Dragon's therefore run approx 6261 CPU cycles per second slower than the CoCo and earlier Dragon's.
Code: Select all
...
MainProcess/MainThread $a7d5 *** IRQ, set PC to $010c E.......
MainProcess/MainThread 8955| read byte $00 TIMER value from: $0112
MainProcess/MainThread 8955| read byte $61 TIMER value from: $0113
MainProcess/MainThread 895a| write word $0062 TIMER value to: $0112
MainProcess/MainThread 895a| write byte $00 TIMER value to: $0112
MainProcess/MainThread 895a| write byte $62 TIMER value to: $0113
MainProcess/MainThread $a7d3 *** IRQ, set PC to $010c E.......
MainProcess/MainThread 8955| read byte $00 TIMER value from: $0112
MainProcess/MainThread 8955| read byte $62 TIMER value from: $0113
MainProcess/MainThread 895a| write word $0063 TIMER value to: $0112
MainProcess/MainThread 895a| write byte $00 TIMER value to: $0112
MainProcess/MainThread 895a| write byte $63 TIMER value to: $0113
MainProcess/MainThread $a7d3 *** IRQ, set PC to $010c E.......
MainProcess/MainThread 8955| read byte $00 TIMER value from: $0112
MainProcess/MainThread 8955| read byte $63 TIMER value from: $0113
MainProcess/MainThread 895a| write word $0064 TIMER value to: $0112
MainProcess/MainThread 895a| write byte $00 TIMER value to: $0112
MainProcess/MainThread 895a| write byte $64 TIMER value to: $0113
...
Code: Select all
1123 8955 BE 01 12 L8955 LDX TIMVAL GET REAL TIME CLOCK
1124 8958 30 01 LEAX $01,X INCREMENT IT
1125 895A BF 01 12 STX TIMVAL SAVE IT
Code: Select all
MainProcess/MainThread $bbc8 *** IRQ, set PC to $010c E.H.....
MainProcess/MainThread $bbca *** IRQ, set PC to $010c E.H.....
MainProcess/MainThread $bbc8 *** IRQ, set PC to $010c E.H.....
MainProcess/MainThread $bbc8 *** IRQ, set PC to $010c E.H.....
MainProcess/MainThread $bbca *** IRQ, set PC to $010c E.H.....
MainProcess/MainThread $bbc8 *** IRQ, set PC to $010c E.H.....
MainProcess/MainThread $bbca *** IRQ, set PC to $010c E.H.....
Code: Select all
...
MainProcess/MainThread $bbc8 *** IRQ, set PC to $010c E.......
MainProcess/MainThread $bbc8 *** IRQ, set PC to $010c E.......
MainProcess/MainThread 9d59| read byte $00 TIMER value from: $0112
MainProcess/MainThread 9d59| read byte $02 TIMER value from: $0113
MainProcess/MainThread $bbca *** IRQ, set PC to $010c E.H.....
MainProcess/MainThread $bbca *** IRQ, set PC to $010c E.H.....
...
MainProcess/MainThread $bbca *** IRQ, set PC to $010c E.......
MainProcess/MainThread $bbca *** IRQ, set PC to $010c E.......
MainProcess/MainThread 9d55| write word $0002 TIMER value to: $0112
MainProcess/MainThread 9d55| write byte $00 TIMER value to: $0112
MainProcess/MainThread 9d55| write byte $02 TIMER value to: $0113
MainProcess/MainThread $bbc8 *** IRQ, set PC to $010c E.H.....
MainProcess/MainThread $bbc8 *** IRQ, set PC to $010c E.H.....
...