From f1f75c2ae292d4e7b4415e4570e07fbbf7675883 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 6 Jul 2018 10:56:50 -0400 Subject: [PATCH] split: adding sound support --- split_screen/Makefile | 2 +- split_screen/credits.s | 29 +++--- split_screen/mockingboard.s | 185 ++++++++++++++++++++++++++++++++++++ split_screen/music.tfv | Bin 0 -> 7042 bytes 4 files changed, 203 insertions(+), 13 deletions(-) create mode 100644 split_screen/mockingboard.s create mode 100644 split_screen/music.tfv diff --git a/split_screen/Makefile b/split_screen/Makefile index 1618009f..f95c4999 100644 --- a/split_screen/Makefile +++ b/split_screen/Makefile @@ -32,7 +32,7 @@ RAINBOW: rainbow.o RAINBOW.BAS: rainbow.bas $(TOKENIZE) < rainbow.bas > RAINBOW.BAS -credits.o: credits.s tfv_sprites.inc +credits.o: credits.s tfv_sprites.inc mockingboard.s ca65 -o credits.o credits.s -l credits.lst CREDITS: credits.o diff --git a/split_screen/credits.s b/split_screen/credits.s index 0ef761ac..ca3c34c8 100644 --- a/split_screen/credits.s +++ b/split_screen/credits.s @@ -1,26 +1,18 @@ .include "zp.inc" - H2 = $2C -; V2 = $2D -; TEMPY = $FB FRAME = $60 TREE1X = $61 TREE2X = $62 - HGR = $F3E2 - HPLOT0 = $F457 - HCOLOR = $F6EC -; HLINE = $F819 -; VLINE = $F828 -; COLOR = $F864 -; TEXT = $FB36 -; HOME = $FC58 + ;=================== + ; init screen jsr TEXT jsr HOME - + ;================== ; Init vars + lda #28 sta TREE1X lda #37 @@ -32,6 +24,14 @@ lda #0 sta DRAW_PAGE + ;========================== + ; setup mockingboard + + jsr mockingboard_detect_slot4 + + ;========================== + ; setup text screen + lda #0 sta CH sta CV @@ -642,6 +642,7 @@ line5:.asciiz " . . . " line6:.asciiz " . " .include "../asm_routines/text_print.s" +.include "mockingboard.s" .align $100 .include "../asm_routines/gr_offsets.s" @@ -649,4 +650,8 @@ line6:.asciiz " . " .align $1000 +graphics: .incbin "KATC.BIN" + +music: +.incbin "music.tfv" diff --git a/split_screen/mockingboard.s b/split_screen/mockingboard.s new file mode 100644 index 00000000..3cd54737 --- /dev/null +++ b/split_screen/mockingboard.s @@ -0,0 +1,185 @@ +; ZP addresses + +; left channel +MOCK_6522_1_ORB = $C400 ; 6522 #1 port b data +MOCK_6522_1_ORA = $C401 ; 6522 #1 port a data +MOCK_6522_1_DDRB = $C402 ; 6522 #1 data direction port B +MOCK_6522_1_DDRA = $C403 ; 6522 #1 data direction port A +MOCK_6522_1_T1C_L = $C404 ; 6522 #1 Low-order counter +MOCK_6522_1_T1C_H = $C405 ; 6522 #1 High-order counter +MOCK_6522_1_T1L_L = $C406 ; 6522 #1 Low-order latch +MOCK_6522_1_T1L_H = $C407 ; 6522 #1 High-order latch +MOCK_6522_1_T2C_L = $C408 ; 6522 #1 Timer2 Low-order Latch/Counter +MOCK_6522_1_T2C_H = $C409 ; 6522 #1 Timer2 High-order Latch/Counter +MOCK_6522_1_SR = $C40A ; 6522 #1 Shift Register +MOCK_6522_1_ACR = $C40B ; 6522 #1 Auxiliary Control Register +MOCK_6522_1_PCR = $C40C ; 6522 #1 Peripheral Control Register +MOCK_6522_1_IFR = $C40D ; 6522 #1 Interrupt Flag Register +MOCK_6522_1_IER = $C40E ; 6522 #1 Interrupt Enable Register +MOCK_6522_1_ORAN = $C40F ; 6522 #1 port a data, no handshake + +; right channel +MOCK_6522_2_ORB = $C480 ; 6522 #2 port b data +MOCK_6522_2_ORA = $C481 ; 6522 #2 port a data +MOCK_6522_2_DDRB = $C482 ; 6522 #2 data direction port B +MOCK_6522_2_DDRA = $C483 ; 6522 #2 data direction port A +MOCK_6522_2_T1C_L = $C484 ; 6522 #2 Low-order counter +MOCK_6522_2_T1C_H = $C485 ; 6522 #2 High-order counter +MOCK_6522_2_T1L_L = $C486 ; 6522 #2 Low-order latch +MOCK_6522_2_T1L_H = $C487 ; 6522 #2 High-order latch +MOCK_6522_2_T2C_L = $C488 ; 6522 #2 Timer2 Low-order Latch/Counter +MOCK_6522_2_T2C_H = $C489 ; 6522 #2 Timer2 High-order Latch/Counter +MOCK_6522_2_SR = $C48A ; 6522 #2 Shift Register +MOCK_6522_2_ACR = $C48B ; 6522 #2 Auxiliary Control Register +MOCK_6522_2_PCR = $C48C ; 6522 #2 Peripheral Control Register +MOCK_6522_2_IFR = $C48D ; 6522 #2 Interrupt Flag Register +MOCK_6522_2_IER = $C48E ; 6522 #2 Interrupt Enable Register +MOCK_6522_2_ORAN = $C48F ; 6522 #2 port a data, no handshake + + +; AY-3-8910 commands on port B +; RESET BDIR BC1 +MOCK_AY_RESET = $0 ; 0 0 0 +MOCK_AY_INACTIVE = $4 ; 1 0 0 +MOCK_AY_READ = $5 ; 1 0 1 +MOCK_AY_WRITE = $6 ; 1 1 0 +MOCK_AY_LATCH_ADDR = $7 ; 1 1 1 + + + ;======================== + ; Mockingboard Init + ;======================== + ; Initialize the 6522s + ; set the data direction for all pins of PortA/PortB to be output + +mockingboard_init: + lda #$ff ; all 8 pins output (1), portA + + sta MOCK_6522_1_DDRA + sta MOCK_6522_2_DDRA + ; only 3 pins output (1), port B + lda #$7 + sta MOCK_6522_1_DDRB + + sta MOCK_6522_2_DDRB + + +reset_ay_both: + ;====================== + ; Reset Left AY-3-8910 + ;====================== +reset_ay_left: + lda #MOCK_AY_RESET + sta MOCK_6522_1_ORB + lda #MOCK_AY_INACTIVE + sta MOCK_6522_1_ORB + + ; AY-3-8913: Wait 5 us + nop + nop + nop + nop + nop + + ;====================== + ; Reset Right AY-3-8910 + ;====================== +reset_ay_right: + lda #MOCK_AY_RESET + sta MOCK_6522_2_ORB + lda #MOCK_AY_INACTIVE + sta MOCK_6522_2_ORB + + ; AY-3-8913: Wait 5 us + nop + nop + nop + nop + nop + + ;========================= + ; Setup initial conditions + ;========================= + + + ; 7: ENABLE + ldx #7 + lda #$38 ; noise disabled, ABC enabled + sta MB_VALUE + jsr write_ay_both + + rts + + + + ;========================================= + ; Write Right/Left to save value AY-3-8910 + ;========================================= + ; register in X + ; value in MB_VALUE + +write_ay_both: + ; address + stx MOCK_6522_1_ORA ; put address on PA1 ; 3 + stx MOCK_6522_2_ORA ; put address on PA2 ; 3 + lda #MOCK_AY_LATCH_ADDR ; latch_address on PB1 ; 2 + sta MOCK_6522_1_ORB ; latch_address on PB1 ; 3 + sta MOCK_6522_2_ORB ; latch_address on PB2 ; 3 + lda #MOCK_AY_INACTIVE ; go inactive ; 2 + sta MOCK_6522_1_ORB ; 3 + sta MOCK_6522_2_ORB ; 3 + + ; value + lda MB_VALUE ; 3 + sta MOCK_6522_1_ORA ; put value on PA1 ; 3 + sta MOCK_6522_2_ORA ; put value on PA2 ; 3 + lda #MOCK_AY_WRITE ; ; 2 + sta MOCK_6522_1_ORB ; write on PB1 ; 3 + sta MOCK_6522_2_ORB ; write on PB2 ; 3 + lda #MOCK_AY_INACTIVE ; go inactive ; 2 + sta MOCK_6522_1_ORB ; 3 + sta MOCK_6522_2_ORB ; 3 + + rts ; 6 + ;=========== + ; 53 + + ;======================================= + ; 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 + diff --git a/split_screen/music.tfv b/split_screen/music.tfv new file mode 100644 index 0000000000000000000000000000000000000000..ad6ed1fe33e5dc7298cb9c310522beadb355cab9 GIT binary patch literal 7042 zcmeI0F>1p=5JeT21|=8B5pn=Sz$sIx2!S+iQsn^YQW)nBK7%V?!^biNC)uy!iD8x< zkc9;L#W4Jxo&EE7ZH$}d9~JPP0HXR%AoG?W<~c!mYSw5~eaa*Im*+Z>^?CiC9(DLg zP>rUrQI($#)WJq7WFFP8y;7xo_McZ_ofkvTnS1YnygKAxg+3!T>VET4x2YQ4rXuIE zdZ>!4HfN=M&tj}{F?r=$rT!=23!thOfb%kcbWoy)HQu})ueWg-4BH^~K^%iP1+fZZ z6T~5ia}YuMw?X^&LHmzE`%gjpS3&zXLHiFu`_I&W5A?-z-Uqb)(j>uri4pdT-+r4=vty(dy1KMk%>N`5UJ|6GQqO-Uf zWmvD=L_05;&RkSdlJj)c=b5z1(_3%3*U{h6>Gkn=Zx*MX3fps`imR=Dr;qm9dNN*r z?k&mLleyR5){s%obL}c?cnbOQoc+CXJ)V1+hwJrD2K)Qrf_Fo$b6);#X0N91m2Pm3 Ovjgq#u;IRctLhgls#*a6 literal 0 HcmV?d00001