mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-12-25 20:30:31 +00:00
xmas2019: autodetect mockingboard slot
This commit is contained in:
parent
8e5bf611a9
commit
07b09eed08
@ -54,7 +54,8 @@ XMAS2019: xmas2019.o
|
||||
|
||||
xmas2019.o: xmas2019.s \
|
||||
delay_a.s vapor_lock.s message.inc gr_unrle.s sines.inc \
|
||||
move_letters.s letters.s
|
||||
move_letters.s letters.s \
|
||||
pt3_lib_mockingboard_setup.s pt3_lib_core.s pt3_lib_init.s
|
||||
ca65 -o xmas2019.o xmas2019.s -l xmas2019.lst
|
||||
|
||||
####
|
||||
|
@ -1,5 +1,5 @@
|
||||
5 HOME
|
||||
10 PRINT " LOADING XMAS-2019 FOR APPLE ]["
|
||||
10 PRINT " LOADING XMAS-2019 V1.1 FOR APPLE ]["
|
||||
20 PRINT
|
||||
30 PRINT " WILL RUN ON ANY APPLE ][ WITH 48K"
|
||||
40 PRINT
|
||||
|
@ -406,9 +406,9 @@ L7:
|
||||
|
||||
; should automate this somehow
|
||||
|
||||
lda #<($2000+6279+11-8)
|
||||
lda #<($2000+6296+11-8)
|
||||
sta LZ4_END
|
||||
lda #>($2000+6279+11-8)
|
||||
lda #>($2000+6296+11-8)
|
||||
sta LZ4_END+1
|
||||
|
||||
lda #$40 ; load to $4000
|
||||
|
@ -91,7 +91,7 @@ NOTE_TONE_SLIDE_TO_STEP =39
|
||||
|
||||
NOTE_STRUCT_SIZE=40
|
||||
|
||||
.ifdef USE_ZERO_PAGE
|
||||
.ifdef PT3_USE_ZERO_PAGE
|
||||
note_a = $80
|
||||
note_b = $80+(NOTE_STRUCT_SIZE*1)
|
||||
note_c = $80+(NOTE_STRUCT_SIZE*2)
|
||||
@ -100,7 +100,7 @@ begin_vars=$80
|
||||
end_vars=$80+(NOTE_STRUCT_SIZE*3)
|
||||
|
||||
|
||||
.else ; !USE_ZERO_PAGE
|
||||
.else ; !PT3_USE_ZERO_PAGE
|
||||
begin_vars:
|
||||
|
||||
note_a: ; reset?
|
||||
@ -829,7 +829,7 @@ do_onoff:
|
||||
do_offon:
|
||||
ldy note_a+NOTE_OFFON_DELAY,X ; else a->onoff=a->offon_delay;
|
||||
put_offon:
|
||||
.ifdef USE_ZERO_PAGE
|
||||
.ifdef PT3_USE_ZERO_PAGE
|
||||
sty note_a+NOTE_ONOFF,X
|
||||
.else
|
||||
lda note_a+NOTE_ONOFF,X
|
||||
@ -1519,24 +1519,7 @@ reset_note:
|
||||
; in the player note length code
|
||||
|
||||
is_done:
|
||||
lda LOOP ; see if looping
|
||||
beq really_done
|
||||
|
||||
sp_pt3_loop_smc:
|
||||
lda #$d1 ; looping, move to loop location
|
||||
; non-zero to avoid the temptation
|
||||
; to merge with following lda #$0
|
||||
sta current_pattern_smc+1
|
||||
lda #$0
|
||||
sta current_line_smc+1
|
||||
sta current_subframe_smc+1
|
||||
sta DONE_SONG ; undo the next song
|
||||
|
||||
jmp pt3_set_pattern
|
||||
|
||||
really_done:
|
||||
; done with song, set it to non-zero
|
||||
lda #1
|
||||
sta DONE_SONG ; 3
|
||||
rts ; 6
|
||||
|
||||
@ -1710,7 +1693,7 @@ do_frame:
|
||||
jsr calculate_note ; 6+?
|
||||
|
||||
convert_177_smc1:
|
||||
clc ; 2
|
||||
sec ; 2
|
||||
|
||||
; Load up the Frequency Registers
|
||||
|
||||
@ -1756,7 +1739,7 @@ convert_177_smc1:
|
||||
no_scale_a:
|
||||
|
||||
convert_177_smc2:
|
||||
clc ; 2
|
||||
sec ; 2
|
||||
|
||||
lda note_b+NOTE_TONE_L ; Note B Period L ; 4
|
||||
sta AY_REGISTERS+2 ; into R2 ; 3
|
||||
@ -1798,7 +1781,7 @@ convert_177_smc2:
|
||||
no_scale_b:
|
||||
|
||||
convert_177_smc3:
|
||||
clc ; 2
|
||||
sec ; 2
|
||||
|
||||
lda note_c+NOTE_TONE_L ; Note C Period L ; 4
|
||||
sta AY_REGISTERS+4 ; into R4 ; 3
|
||||
@ -1850,7 +1833,7 @@ pt3_noise_add_smc:
|
||||
sta AY_REGISTERS+6 ; 3
|
||||
|
||||
convert_177_smc4:
|
||||
clc ; 2
|
||||
sec ; 2
|
||||
bcc no_scale_n ; 2/3
|
||||
|
||||
; Convert from 1.77MHz to 1MHz by multiplying by 9/16
|
||||
@ -1913,7 +1896,7 @@ pt3_envelope_slide_h_smc:
|
||||
sta AY_REGISTERS+12 ; 3
|
||||
|
||||
convert_177_smc5:
|
||||
clc
|
||||
sec
|
||||
bcc no_scale_e ; 2/3
|
||||
|
||||
; Convert from 1.77MHz to 1MHz by multiplying by 9/16
|
||||
|
@ -30,7 +30,7 @@ zero_song_structs_loop:
|
||||
sta pt3_envelope_slide_add_h_smc+1 ; 4
|
||||
sta pt3_envelope_add_smc+1 ; 4
|
||||
sta pt3_envelope_type_smc+1 ; 4
|
||||
sta pt3_envelope_type_old_smc+1 ; ok as set_env always ; 4
|
||||
sta pt3_envelope_type_old_smc+1 ; 4
|
||||
sta pt3_envelope_delay_smc+1 ; 4
|
||||
sta pt3_envelope_delay_orig_smc+1 ; 4
|
||||
|
||||
@ -45,8 +45,6 @@ zero_song_structs_loop:
|
||||
sta note_b+NOTE_VOLUME ; 4
|
||||
sta note_c+NOTE_VOLUME ; 4
|
||||
|
||||
|
||||
|
||||
; default ornament/sample in A
|
||||
; X is zero coming in here
|
||||
;ldx #(NOTE_STRUCT_SIZE*0) ; 2
|
||||
@ -69,9 +67,9 @@ zero_song_structs_loop:
|
||||
;=======================
|
||||
; load loop
|
||||
|
||||
lda PT3_LOC+PT3_LOOP ; 4
|
||||
; lda PT3_LOC+PT3_LOOP ; 4
|
||||
; sta pt3_loop_smc+1 ; 4
|
||||
sta sp_pt3_loop_smc+1
|
||||
|
||||
|
||||
;========================
|
||||
;========================
|
||||
|
191
xmas_2019/pt3_lib_mockingboard_detect.s
Normal file
191
xmas_2019/pt3_lib_mockingboard_detect.s
Normal file
@ -0,0 +1,191 @@
|
||||
;===================================================================
|
||||
; code to detect mockingboard
|
||||
;===================================================================
|
||||
; this isn't always easy
|
||||
; my inclination is to just assume slot #4 but that isn't always realistic
|
||||
|
||||
; code below based on "hw.mockingboard.a" from "Total Replay"
|
||||
|
||||
;license:MIT
|
||||
; By Andrew Roughan
|
||||
; in the style of 4am for Total Replay
|
||||
;
|
||||
; Mockingboard support functions
|
||||
;
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; HasMockingboard
|
||||
; detect Mockingboard card by searching for 6522 timers across all slots
|
||||
; access 6522 timers with deterministic cycle counts
|
||||
;
|
||||
; based on prior art in Mockingboard Developers Toolkit
|
||||
; with optimisation from deater/french touch
|
||||
; also takes into account FastChip //e clock difference
|
||||
;
|
||||
; in: none
|
||||
; accelerators should be off
|
||||
; out: C set if Mockingboard found in any slot
|
||||
; if card was found, X = #$Cn where n is the slot number of the card
|
||||
; C clear if no Mockingboard found
|
||||
; other flags clobbered
|
||||
; zp $65-$67 clobbered
|
||||
; A/Y clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
mockingboard_detect:
|
||||
lda #$00
|
||||
sta MB_ADDR_L
|
||||
ldx #$C7 ; start at slot #7
|
||||
mb_slot_loop:
|
||||
stx MB_ADDR_H
|
||||
ldy #$04 ; 6522 #1 $Cx04
|
||||
jsr mb_timer_check
|
||||
bne mb_next_slot
|
||||
ldy #$84 ; 6522 #2 $Cx84
|
||||
jsr mb_timer_check
|
||||
bne mb_next_slot
|
||||
mb_found:
|
||||
sec ; found
|
||||
rts
|
||||
|
||||
mb_next_slot:
|
||||
dex
|
||||
cpx #$C0
|
||||
bne mb_slot_loop
|
||||
|
||||
clc ; not found
|
||||
rts
|
||||
|
||||
mb_timer_check:
|
||||
lda (MB_ADDR_L),Y ; read 6522 timer low byte
|
||||
sta MB_VALUE
|
||||
lda (MB_ADDR_L),Y ; second time
|
||||
sec
|
||||
sbc MB_VALUE
|
||||
cmp #$F8 ; looking for (-)8 cycles between reads
|
||||
beq mb_timer_check_done
|
||||
cmp #$F7 ; FastChip //e clock is different
|
||||
mb_timer_check_done:
|
||||
rts
|
||||
|
||||
|
||||
|
||||
;===================================================================
|
||||
; code to patch mockingboard if not in slot#4
|
||||
;===================================================================
|
||||
; this is the brute force version, we have to patch 39 locations
|
||||
; see further below if you want to try a smaller, more dangerous, patch
|
||||
|
||||
.if 0
|
||||
mockingboard_patch:
|
||||
|
||||
lda MB_ADDR_H
|
||||
|
||||
sta pt3_irq_smc1+2 ; 1
|
||||
|
||||
sta pt3_irq_smc2+2 ; 2
|
||||
sta pt3_irq_smc2+5 ; 3
|
||||
|
||||
sta pt3_irq_smc3+2 ; 4
|
||||
sta pt3_irq_smc3+5 ; 5
|
||||
|
||||
sta pt3_irq_smc4+2 ; 6
|
||||
sta pt3_irq_smc4+5 ; 7
|
||||
|
||||
sta pt3_irq_smc5+2 ; 8
|
||||
sta pt3_irq_smc5+5 ; 9
|
||||
|
||||
sta pt3_irq_smc6+2 ; 10
|
||||
sta pt3_irq_smc6+5 ; 11
|
||||
|
||||
sta pt3_irq_smc7+2 ; 12
|
||||
sta pt3_irq_smc7+5 ; 13
|
||||
|
||||
sta mock_init_smc1+2 ; 14
|
||||
sta mock_init_smc1+5 ; 15
|
||||
|
||||
sta mock_init_smc2+2 ; 16
|
||||
sta mock_init_smc2+5 ; 17
|
||||
|
||||
sta reset_ay_smc1+2 ; 18
|
||||
sta reset_ay_smc2+2 ; 19
|
||||
sta reset_ay_smc3+2 ; 20
|
||||
sta reset_ay_smc4+2 ; 21
|
||||
|
||||
sta write_ay_smc1+2 ; 22
|
||||
sta write_ay_smc1+5 ; 23
|
||||
|
||||
sta write_ay_smc2+2 ; 24
|
||||
sta write_ay_smc2+5 ; 25
|
||||
|
||||
sta write_ay_smc3+2 ; 26
|
||||
sta write_ay_smc3+5 ; 27
|
||||
|
||||
sta write_ay_smc4+2 ; 28
|
||||
sta write_ay_smc4+5 ; 29
|
||||
|
||||
sta write_ay_smc5+2 ; 30
|
||||
sta write_ay_smc5+5 ; 31
|
||||
|
||||
sta write_ay_smc6+2 ; 32
|
||||
sta write_ay_smc6+5 ; 33
|
||||
|
||||
sta setup_irq_smc1+2 ; 34
|
||||
sta setup_irq_smc2+2 ; 35
|
||||
sta setup_irq_smc3+2 ; 36
|
||||
sta setup_irq_smc4+2 ; 37
|
||||
sta setup_irq_smc5+2 ; 38
|
||||
sta setup_irq_smc6+2 ; 39
|
||||
|
||||
rts
|
||||
.endif
|
||||
|
||||
;===================================================================
|
||||
; dangerous code to patch mockingboard if not in slot#4
|
||||
;===================================================================
|
||||
; this code patches any $C4 value to the proper slot# if not slot4
|
||||
; this can be dangerous, it might over-write other important values
|
||||
; that should be $C4
|
||||
|
||||
; safer ways to do this:
|
||||
; only do this if 2 bytes after a LDA/STA/LDX/STX
|
||||
; count total and if not 39 then print error message
|
||||
|
||||
mockingboard_patch:
|
||||
; from mockingboard_init $1BBF
|
||||
; to done_pt3_irq_handler $1D85
|
||||
|
||||
ldx MB_ADDR_H
|
||||
ldy #0
|
||||
|
||||
lda #<mockingboard_init
|
||||
sta MB_ADDR_L
|
||||
lda #>mockingboard_init
|
||||
sta MB_ADDR_H
|
||||
|
||||
mb_patch_loop:
|
||||
lda (MB_ADDR_L),Y
|
||||
cmp #$C4
|
||||
bne mb_patch_nomatch
|
||||
|
||||
txa
|
||||
sta (MB_ADDR_L),Y
|
||||
mb_patch_nomatch:
|
||||
|
||||
inc MB_ADDR_L
|
||||
lda MB_ADDR_L
|
||||
bne mb_patch_oflo
|
||||
inc MB_ADDR_H
|
||||
|
||||
mb_patch_oflo:
|
||||
lda MB_ADDR_H
|
||||
cmp #>update_pt3_play
|
||||
bne mb_patch_loop
|
||||
lda MB_ADDR_L
|
||||
cmp #<update_pt3_play
|
||||
bne mb_patch_loop
|
||||
|
||||
mb_patch_done:
|
||||
rts
|
||||
|
||||
|
@ -23,6 +23,19 @@ MOCK_6522_ORB1 = $C400 ; 6522 #1 port b data
|
||||
MOCK_6522_ORA1 = $C401 ; 6522 #1 port a data
|
||||
MOCK_6522_DDRB1 = $C402 ; 6522 #1 data direction port B
|
||||
MOCK_6522_DDRA1 = $C403 ; 6522 #1 data direction port A
|
||||
MOCK_6522_T1CL = $C404 ; 6522 #1 t1 low order latches
|
||||
MOCK_6522_T1CH = $C405 ; 6522 #1 t1 high order counter
|
||||
MOCK_6522_T1LL = $C406 ; 6522 #1 t1 low order latches
|
||||
MOCK_6522_T1LH = $C407 ; 6522 #1 t1 high order latches
|
||||
MOCK_6522_T2CL = $C408 ; 6522 #1 t2 low order latches
|
||||
MOCK_6522_T2CH = $C409 ; 6522 #1 t2 high order counters
|
||||
MOCK_6522_SR = $C40A ; 6522 #1 shift register
|
||||
MOCK_6522_ACR = $C40B ; 6522 #1 auxilliary control register
|
||||
MOCK_6522_PCR = $C40C ; 6522 #1 peripheral control register
|
||||
MOCK_6522_IFR = $C40D ; 6522 #1 interrupt flag register
|
||||
MOCK_6522_IER = $C40E ; 6522 #1 interrupt enable register
|
||||
MOCK_6522_ORANH = $C40F ; 6522 #1 port a data no handshake
|
||||
|
||||
|
||||
; right speaker
|
||||
MOCK_6522_ORB2 = $C480 ; 6522 #2 port b data
|
||||
@ -47,19 +60,30 @@ MOCK_AY_LATCH_ADDR = $7 ; 1 1 1
|
||||
|
||||
mockingboard_init:
|
||||
lda #$ff ; all output (1)
|
||||
|
||||
mock_init_smc1:
|
||||
sta MOCK_6522_DDRB1
|
||||
sta MOCK_6522_DDRA1
|
||||
mock_init_smc2:
|
||||
sta MOCK_6522_DDRB2
|
||||
sta MOCK_6522_DDRA2
|
||||
rts
|
||||
|
||||
;===================================
|
||||
;===================================
|
||||
; Reset Both AY-3-8910s
|
||||
;===================================
|
||||
;===================================
|
||||
|
||||
;======================
|
||||
; Reset Left AY-3-8910
|
||||
;======================
|
||||
reset_ay_both:
|
||||
lda #MOCK_AY_RESET
|
||||
reset_ay_smc1:
|
||||
sta MOCK_6522_ORB1
|
||||
lda #MOCK_AY_INACTIVE
|
||||
reset_ay_smc2:
|
||||
sta MOCK_6522_ORB1
|
||||
|
||||
;======================
|
||||
@ -68,8 +92,10 @@ reset_ay_both:
|
||||
;reset_ay_right:
|
||||
;could be merged with both
|
||||
lda #MOCK_AY_RESET
|
||||
reset_ay_smc3:
|
||||
sta MOCK_6522_ORB2
|
||||
lda #MOCK_AY_INACTIVE
|
||||
reset_ay_smc4:
|
||||
sta MOCK_6522_ORB2
|
||||
rts
|
||||
|
||||
@ -85,23 +111,30 @@ reset_ay_both:
|
||||
|
||||
write_ay_both:
|
||||
; address
|
||||
|
||||
write_ay_smc1:
|
||||
stx MOCK_6522_ORA1 ; put address on PA1 ; 4
|
||||
stx MOCK_6522_ORA2 ; put address on PA2 ; 4
|
||||
lda #MOCK_AY_LATCH_ADDR ; latch_address on PB1 ; 2
|
||||
write_ay_smc2:
|
||||
sta MOCK_6522_ORB1 ; latch_address on PB1 ; 4
|
||||
sta MOCK_6522_ORB2 ; latch_address on PB2 ; 4
|
||||
ldy #MOCK_AY_INACTIVE ; go inactive ; 2
|
||||
write_ay_smc3:
|
||||
sty MOCK_6522_ORB1 ; 4
|
||||
sty MOCK_6522_ORB2 ; 4
|
||||
;===========
|
||||
; 28
|
||||
; value
|
||||
lda MB_VALUE ; 3
|
||||
write_ay_smc4:
|
||||
sta MOCK_6522_ORA1 ; put value on PA1 ; 4
|
||||
sta MOCK_6522_ORA2 ; put value on PA2 ; 4
|
||||
lda #MOCK_AY_WRITE ; ; 2
|
||||
write_ay_smc5:
|
||||
sta MOCK_6522_ORB1 ; write on PB1 ; 4
|
||||
sta MOCK_6522_ORB2 ; write on PB2 ; 4
|
||||
write_ay_smc6:
|
||||
sty MOCK_6522_ORB1 ; 4
|
||||
sty MOCK_6522_ORB2 ; 4
|
||||
;===========
|
||||
@ -132,132 +165,13 @@ clear_ay_left_loop:
|
||||
|
||||
clear_ay_end:
|
||||
|
||||
.assert >clear_ay_both = >clear_ay_end, error, "clea_ay_both crosses page"
|
||||
|
||||
;=======================================
|
||||
; Detect a Mockingboard card
|
||||
;=======================================
|
||||
; Based on code from the French Touch "Pure Noise" Demo
|
||||
; Attempts to time an instruction sequence with a 6522
|
||||
;
|
||||
; If found, puts in bMB
|
||||
; MB_ADDRL:MB_ADDRH has address of Mockingboard
|
||||
; returns X=0 if not found, X=1 if found
|
||||
|
||||
mockingboard_detect:
|
||||
lda #0
|
||||
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 MB_ADDRH
|
||||
ldy #04 ; $CX04
|
||||
ldx #02 ; 2 tries?
|
||||
mb_check_cycle_loop:
|
||||
lda (MB_ADDRL),Y ; timer 6522 (Low Order Counter)
|
||||
; count down
|
||||
sta PT3_TEMP ; 3 cycles
|
||||
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
|
||||
; between the two accesses to the timer
|
||||
sec
|
||||
sbc PT3_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
|
||||
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
|
||||
ldx #00
|
||||
beq done_mb_detect
|
||||
|
||||
;alternative MB detection from Nox Archaist
|
||||
; lda #$04
|
||||
; sta MB_ADDRL
|
||||
; ldx #$c7
|
||||
;
|
||||
;find_mb:
|
||||
; stx MB_ADDRH
|
||||
;
|
||||
; ;detect sound I
|
||||
;
|
||||
; sec
|
||||
; ldy #$00
|
||||
; lda (MB_ADDRL), y
|
||||
; sbc (MB_ADDRL), y
|
||||
; cmp #$05
|
||||
; beq found_mb
|
||||
; dex
|
||||
; cpx #$c0
|
||||
; bne find_mb
|
||||
; ldx #$00 ;no mockingboard found
|
||||
; rts
|
||||
;
|
||||
;found_mb:
|
||||
; ldx #$01 ;mockingboard found
|
||||
; rts
|
||||
;
|
||||
; ;optionally detect sound II
|
||||
;
|
||||
; sec
|
||||
; ldy #$80
|
||||
; lda (MB_ADDRL), y
|
||||
; sbc (MB_ADDRL), y
|
||||
; cmp #$05
|
||||
; beq found_mb
|
||||
|
||||
|
||||
;=======================================
|
||||
; 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 PT3_TEMP ; 3 cycles
|
||||
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
|
||||
; between the two accesses to the timer
|
||||
sec
|
||||
sbc PT3_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
|
||||
|
||||
.assert >clear_ay_both = >clear_ay_end, error, "clear_ay_both crosses page"
|
||||
|
||||
;=============================
|
||||
; Setup
|
||||
;=============================
|
||||
.if 0
|
||||
pt3_setup_interrupt:
|
||||
mockingboard_setup_interrupt:
|
||||
|
||||
;===========================
|
||||
; Check for Apple IIc
|
||||
@ -278,14 +192,15 @@ apple_iic:
|
||||
; I get the impression the Mockingboard 4c activates
|
||||
; when you access any of the 6522 ports in Slot 4
|
||||
lda #$ff
|
||||
sta $C403
|
||||
sta $C404
|
||||
|
||||
; don't bother patching these, IIc mockingboard always slot 4?
|
||||
|
||||
sta MOCK_6522_DDRA1
|
||||
sta MOCK_6522_T1CL
|
||||
|
||||
; bypass the firmware interrupt handler
|
||||
; should we do this on IIe too? probably faster
|
||||
|
||||
done_apple_detect:
|
||||
|
||||
sei ; disable interrupts
|
||||
lda $c08b ; disable ROM (enable language card)
|
||||
lda $c08b
|
||||
@ -298,7 +213,7 @@ done_apple_detect:
|
||||
sta interrupt_smc
|
||||
sta interrupt_smc+1
|
||||
|
||||
|
||||
done_apple_detect:
|
||||
|
||||
|
||||
;=========================
|
||||
@ -313,91 +228,38 @@ done_apple_detect:
|
||||
sta $03ff
|
||||
|
||||
;============================
|
||||
; Enable 60Hz clock on 6522
|
||||
; Enable 50Hz clock on 6522
|
||||
;============================
|
||||
; yes this is horrible for PT3 files
|
||||
; but in our case we are matching the screen refresh
|
||||
|
||||
; 4fe7 / 1e6 = .020s, 50Hz
|
||||
|
||||
; 9c40 / 1e6 = .040s, 25Hz
|
||||
; 411a / 1e6 = .016s, 60Hz
|
||||
|
||||
sei ; disable interrupts just in case
|
||||
|
||||
lda #$40 ; Continuous interrupts, don't touch PB7
|
||||
sta $C40B ; ACR register
|
||||
setup_irq_smc1:
|
||||
sta MOCK_6522_ACR ; ACR register
|
||||
lda #$7F ; clear all interrupt flags
|
||||
sta $C40E ; IER register (interrupt enable)
|
||||
setup_irq_smc2:
|
||||
sta MOCK_6522_IER ; IER register (interrupt enable)
|
||||
|
||||
lda #$C0
|
||||
sta $C40D ; IFR: 1100, enable interrupt on timer one oflow
|
||||
sta $C40E ; IER: 1100, enable timer one interrupt
|
||||
setup_irq_smc3:
|
||||
sta MOCK_6522_IFR ; IFR: 1100, enable interrupt on timer one oflow
|
||||
setup_irq_smc4:
|
||||
sta MOCK_6522_IER ; IER: 1100, enable timer one interrupt
|
||||
|
||||
lda #$1A
|
||||
sta $C404 ; write into low-order latch
|
||||
lda #$41
|
||||
sta $C405 ; write into high-order latch,
|
||||
lda #$E7
|
||||
setup_irq_smc5:
|
||||
sta MOCK_6522_T1CL ; write into low-order latch
|
||||
lda #$4f
|
||||
setup_irq_smc6:
|
||||
sta MOCK_6522_T1CH ; write into high-order latch,
|
||||
; load both values into counter
|
||||
; clear interrupt and start counting
|
||||
|
||||
|
||||
; 9c40 / 1e6 = .040s, 25Hz
|
||||
; 4fe7 / 1e6 = .020s, 50Hz
|
||||
; 411a / 1e6 = .016s, 60Hz
|
||||
|
||||
rts
|
||||
|
||||
.endif
|
||||
|
||||
|
||||
;==================================
|
||||
; Print mockingboard detect message
|
||||
;==================================
|
||||
; note: on IIc must do this before enabling interrupt
|
||||
; as we disable ROM (COUT won't work?)
|
||||
|
||||
print_mockingboard_detect:
|
||||
|
||||
; print detection message
|
||||
; ldy #0
|
||||
;print_mocking_message:
|
||||
; lda mocking_message,Y ; load loading message
|
||||
; beq done_mocking_message
|
||||
; ora #$80
|
||||
; jsr COUT
|
||||
; iny
|
||||
; jmp print_mocking_message
|
||||
;done_mocking_message:
|
||||
; jsr CROUT1
|
||||
|
||||
rts
|
||||
|
||||
print_mocking_notfound:
|
||||
|
||||
; ldy #0
|
||||
;print_not_message:
|
||||
; lda not_message,Y ; load loading message
|
||||
; beq print_not_message_done
|
||||
; ora #$80
|
||||
; jsr COUT
|
||||
; iny
|
||||
; jmp print_not_message
|
||||
;print_not_message_done:
|
||||
rts
|
||||
|
||||
print_mocking_found:
|
||||
; ldy #0
|
||||
;print_found_message:
|
||||
; lda found_message,Y ; load loading message
|
||||
; beq done_found_message
|
||||
; ora #$80
|
||||
; jsr COUT
|
||||
; iny
|
||||
; jmp print_found_message
|
||||
done_found_message:
|
||||
|
||||
rts
|
||||
|
||||
;=========
|
||||
; strings
|
||||
;=========
|
||||
;mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4"
|
||||
;not_message: .byte "NOT "
|
||||
;found_message: .asciiz "FOUND"
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -53,16 +53,16 @@ ORNAMENT_L = $80
|
||||
ORNAMENT_H = $81
|
||||
SAMPLE_L = $82
|
||||
SAMPLE_H = $83
|
||||
LOOP = $84
|
||||
MB_VALUE = $85
|
||||
MB_ADDRL = $86
|
||||
MB_ADDRH = $87
|
||||
DONE_PLAYING = $88
|
||||
DONE_SONG = $89
|
||||
PT3_TEMP = $8A
|
||||
ENV_SHAPE_TEMP = $8B
|
||||
C_COARSE_TEMP = $8C
|
||||
A_VOL_TEMP = $8D
|
||||
LOOP = $84
|
||||
MB_VALUE = $85
|
||||
MB_ADDR_L = $86
|
||||
MB_ADDR_H = $87
|
||||
DONE_PLAYING = $88
|
||||
DONE_SONG = $89
|
||||
PT3_TEMP = $8A
|
||||
ENV_SHAPE_TEMP = $8B
|
||||
C_COARSE_TEMP = $8C
|
||||
A_VOL_TEMP = $8D
|
||||
|
||||
WASTE_CYCLES = $C6
|
||||
FOREVER_OFFSET = $C7
|
||||
@ -140,6 +140,9 @@ apple_ii_regular:
|
||||
jsr update_pt3_play
|
||||
jsr pt3_set_pages
|
||||
|
||||
jsr mockingboard_detect
|
||||
jsr mockingboard_patch
|
||||
|
||||
jsr mockingboard_init
|
||||
jsr reset_ay_both
|
||||
jsr clear_ay_both
|
||||
@ -964,10 +967,12 @@ pixel_lookup:
|
||||
; Music player
|
||||
.include "pt3_lib_core.s"
|
||||
.include "pt3_lib_init.s"
|
||||
.include "pt3_lib_mockingboard.s"
|
||||
.include "pt3_lib_mockingboard_setup.s"
|
||||
.align $100
|
||||
.include "pt3_lib_play_frame.s"
|
||||
.include "pt3_lib_write_frame.s"
|
||||
.include "pt3_lib_write_lc.s"
|
||||
.include "pt3_lib_mockingboard_detect.s"
|
||||
|
||||
.align $100
|
||||
.include "move_letters.s"
|
||||
|
Loading…
Reference in New Issue
Block a user