For what its worth the Oric on bootup at the ready prompt is running a rather heafty IRQ routine that does the following stuff..
1) Read the keyboard (scans each individual key for its state, nothing optimised)
2) Updates three page 2 software timers (Flashing cursor delay, WAIT count, etc.)
One trick i remember years ago to speed up your basic program was to slow down the speed of the IRQ (usually runs at 100hz or 100 times a second).
Will half the speed of the IRQ routine but effectively increase (not double tho) the speed of the BASIC program running). It will also double the duration of a WAIT statement.
Bugger, pressed the wrong key and lost my response to an answer to your problem. I was getting on so well. oh well start again we shall..
Ok, it just so happens that CB1 can be trapped using another interrupt.
Turn to page 43 to see that the IFR and IER hold flags for CB1. Also note that the 6522 can trigger the irq flag on the negative or positive active edge and this is set in the PCR on page 38.
The setup routine for this new interrupt routine will need to be done in machine code so that we can disable interrupts whilst setting it all up.
First we need to add CB1 as an interrupt source...
Code: Select all
SEI
LDA #0
STA $030E
LDA #%11010000
STA $030E
Then set the type of active edge in the PCR (page 38)...
Code: Select all
LDA $030C
AND #%11101111
ORA #%00010000
STA $030C
Remove the ORA if you want to detect negative active edge.
We intercept the IRQ at EE22 by redirecting its vector in page 2...
Code: Select all
LDA #<$BFE0
STA $0245
LDA #>$BFE0
STA $0246
Then we write our interrupt routine in $BFE0 (not used by BASIC or HIRES).
Note we use BIT for two reasons. First it doesn't corrupt the main registers and second its fast in detecting the interrupts we need to detect
If the CB1 interrupt did not occur it will jump to the standard BASIC EE22 IRQ routine
Code: Select all
*=$BFE0
BIT $030D
BVC ProcessCB1Event
JMP $EE22
ProcessCB1Event
'Reset CB1 Interrupt
BIT $0300
'Detect Signal using timer2 as counter between pulses
I'm not sure what you want to achieve at this point onwards. It is possible to use Timer2 (not used under BASIC AFAIK) to count the period (duty cycle) between pulses on CB1 and therefore calculate the frequency of the warning signal.