mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-12 00:30:31 +00:00
mockingboard: update detection code
This commit is contained in:
parent
2901c748d7
commit
0faa94473b
@ -158,45 +158,79 @@ clear_ay_right_loop:
|
||||
; Attempts to time an instruction sequence with a 6522
|
||||
;
|
||||
; If found, puts in bMB
|
||||
; OUT2: has address of Mockingboard
|
||||
|
||||
bMB EQU $03
|
||||
OUT2 EQU $22 ; +$21
|
||||
bGood EQU $FE ; 0 : ok / 1 : bad
|
||||
Temp EQU $FF ;
|
||||
|
||||
; MB_ADDRL:MB_ADDRH has address of Mockingboard
|
||||
; returns X=0 if not found, X=1 if found
|
||||
|
||||
mockingboard_detect:
|
||||
lda #0
|
||||
sta OUT2
|
||||
sta MB_ADDRL
|
||||
|
||||
mb_detect_loop: ; self-modifying
|
||||
lda #$07 ; we start in slot 7 ($C7) and go down to 0 ($C0)
|
||||
ora #$C0 ; make it start with C
|
||||
sta OUT2+1
|
||||
sta MB_ADDRH
|
||||
ldy #04 ; $CX04
|
||||
ldx #02 ; 2 tries?
|
||||
mb_check_cycle_loop:
|
||||
lda (OUT2),Y ; timer 6522 (Low Order Counter)
|
||||
lda (MB_ADDRL),Y ; timer 6522 (Low Order Counter)
|
||||
; count down
|
||||
sta Temp ; 3 cycles
|
||||
lda (OUT2),Y ; + 5 cycles = 8 cycles
|
||||
sta TEMP ; 3 cycles
|
||||
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
|
||||
; between the two accesses to the timer
|
||||
sec
|
||||
sbc Temp ; subtract to see if we had 8 cycles
|
||||
sbc TEMP ; subtract to see if we had 8 cycles
|
||||
cmp #$f8 ; -8
|
||||
bne mb_not_in_this_slot
|
||||
dex ; decrement, try one more time
|
||||
bne mb_check_cycle_loop ; loop detection
|
||||
inx ; Mockingboard found (X=1)
|
||||
done_mb_detect:
|
||||
stx bMB ; store result to bMB
|
||||
;stx bMB ; store result to bMB
|
||||
rts ; return
|
||||
|
||||
mb_not_in_this_slot:
|
||||
dec mb_detect_loop+1 ; decrement the "slot" (self_modify)
|
||||
bne mb_detect_loop ; loop down to one
|
||||
inc bGood ; didn't find?
|
||||
ldx #00
|
||||
beq done_mb_detect
|
||||
|
||||
|
||||
;=======================================
|
||||
; Detect a Mockingboard card in Slot4
|
||||
;=======================================
|
||||
; Based on code from the French Touch "Pure Noise" Demo
|
||||
; Attempts to time an instruction sequence with a 6522
|
||||
;
|
||||
; MB_ADDRL:MB_ADDRH has address of Mockingboard
|
||||
; returns X=0 if not found, X=1 if found
|
||||
|
||||
mockingboard_detect_slot4:
|
||||
lda #0
|
||||
sta MB_ADDRL
|
||||
|
||||
mb4_detect_loop: ; self-modifying
|
||||
lda #$04 ; we're only looking in Slot 4
|
||||
ora #$C0 ; make it start with C
|
||||
sta MB_ADDRH
|
||||
ldy #04 ; $CX04
|
||||
ldx #02 ; 2 tries?
|
||||
mb4_check_cycle_loop:
|
||||
lda (MB_ADDRL),Y ; timer 6522 (Low Order Counter)
|
||||
; count down
|
||||
sta TEMP ; 3 cycles
|
||||
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
|
||||
; between the two accesses to the timer
|
||||
sec
|
||||
sbc TEMP ; subtract to see if we had 8 cycles
|
||||
cmp #$f8 ; -8
|
||||
bne mb4_not_in_this_slot
|
||||
dex ; decrement, try one more time
|
||||
bne mb4_check_cycle_loop ; loop detection
|
||||
inx ; Mockingboard found (X=1)
|
||||
done_mb4_detect:
|
||||
rts ; return
|
||||
|
||||
mb4_not_in_this_slot:
|
||||
ldx #00
|
||||
beq done_mb4_detect
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user