diff --git a/mockingboard/Makefile b/mockingboard/Makefile index e1fb0d4d..0b952057 100644 --- a/mockingboard/Makefile +++ b/mockingboard/Makefile @@ -3,11 +3,13 @@ include ../Makefile.inc DOS33 = ../dos33fs-utils/dos33 PNG2GR = ../gr-utils/png2gr -all: dump_ed mock.dsk +all: dump_ed mock.dsk lzss_compress -mock.dsk: KSP_THEME_UNCOMPRESSED KSP_THEME_COMPRESSED +mock.dsk: KSP_THEME_UNCOMPRESSED KSP_THEME_COMPRESSED \ + KSP_THEME_INTERRUPT $(DOS33) -y mock_test.dsk BSAVE -a 0x1000 KSP_THEME_UNCOMPRESSED $(DOS33) -y mock_test.dsk BSAVE -a 0x1000 KSP_THEME_COMPRESSED + $(DOS33) -y mock_test.dsk BSAVE -a 0x1000 KSP_THEME_INTERRUPT KSP_THEME_COMPRESSED: ksp_theme_compressed.o ld65 -o KSP_THEME_COMPRESSED ksp_theme_compressed.o -C ./apple2_1000.inc @@ -17,6 +19,15 @@ ksp_theme_compressed.o: ksp_theme_compressed.s \ ksp_theme_compressed.inc ca65 -o ksp_theme_compressed.o ksp_theme_compressed.s -l ksp_theme_compressed.lst +KSP_THEME_INTERRUPT: ksp_theme_interrupt.o + ld65 -o KSP_THEME_INTERRUPT ksp_theme_interrupt.o -C ./apple2_1000.inc + +ksp_theme_interrupt.o: ksp_theme_interrupt.s \ + ../asm_routines/mockingboard.s \ + ksp_title.inc + ca65 -o ksp_theme_interrupt.o ksp_theme_interrupt.s -l ksp_theme_interrupt.lst + + KSP_THEME_UNCOMPRESSED: ksp_theme_uncompressed.o ld65 -o KSP_THEME_UNCOMPRESSED ksp_theme_uncompressed.o -C ./apple2_1000.inc @@ -40,6 +51,12 @@ dump_ed: dump_ed.o notes.o $(CC) $(LFLAGS) -o dump_ed dump_ed.o notes.o +lzss_compress.o: lzss_compress.c + $(CC) $(CFLAGS) -c lzss_compress.c + +lzss_compress: lzss_compress.o + $(CC) $(LFLAGS) -o lzss_compress lzss_compress.o + clean: rm -f *~ TITLE.GR *.o *.lst ED KSP_THEME_UNCOMPRESSED dump_ed diff --git a/mockingboard/ksp_theme_compressed.inc b/mockingboard/ksp_theme_compressed.inc index 27fa1126..a1a744d4 100644 --- a/mockingboard/ksp_theme_compressed.inc +++ b/mockingboard/ksp_theme_compressed.inc @@ -7,7 +7,7 @@ ksptheme: ; Author name: Felipe Falanghe ; Comment: Tracked by Vince Weaver -.byte $00,$80,$38,$00 ; 00000 +.byte $01,$80,$38,$00 ; 00000 .byte $60,$35,$BD,$EE,$DD,$01,$07,$0D,$0D,$0D ; 00096 .byte $01,$00,$07,$0E,$0E,$0E ; 00097 .byte $01,$00,$07,$0F,$0F,$0F ; 00098 @@ -939,5 +939,6 @@ ksptheme: .byte $01,$00,$01,$09 ; 04035 .byte $08,$00,$01,$08 ; 04043 .byte $01,$01,$00,$01,$00 ; 04044 +.byte $ff ; Raw size = 57792 bytes ; Updated size = 4800 bytes diff --git a/mockingboard/ksp_theme_compressed.s b/mockingboard/ksp_theme_compressed.s index 853ba0e2..c040eb66 100644 --- a/mockingboard/ksp_theme_compressed.s +++ b/mockingboard/ksp_theme_compressed.s @@ -20,6 +20,27 @@ sta OUTH jsr move_and_print + jsr mockingboard_detect_slot4 + cpx #$1 + beq mockingboard_found + + lda #not_message + sta OUTH + inc CV + jsr move_and_print + + jmp forever_loop + +mockingboard_found: + lda #found_message + sta OUTH + inc CV + jsr move_and_print + ;============================ ; Init the Mockingboard ;============================ @@ -40,8 +61,8 @@ lda #>ksptheme sta INH - ldy #0 new_frame: + ldy #0 lda (INL),Y ; read in frame delay cmp #$ff ; see if end beq done_play ; if so, done @@ -49,90 +70,96 @@ new_frame: tax old_frame: dex ; decrement the frame diff - bpl delay_a_bit ; if not there yet, delay + beq bottom_regs ; if not there yet, delay + jsr delay_50Hz + jmp old_frame -top_regs: +bottom_regs: iny - lda (INL),Y ; load low reg bitmask - ldx #$ff -top_regs_loop: - inx - cmp #$8 - beq bottom_regs - ror - bcc top_regs_loop + lda (INL),Y ; load low reg bitmask + sta MASK + ldx #$ff ; init to -1 +bottom_regs_loop: + inx ; increment X + cpx #$8 ; if we reach 8, done + beq top_regs ; move on to top - stx XX - sty YY + ror MASK + bcc bottom_regs_loop ; if bit not set in mask, skip reg - iny - lda (INL),Y ; read in value - tax + stx XX ; save X - ldy XX + iny ; get next output value + lda (INL),Y ; read in value + + sty YY ; save Y + + tax ; value in X + ldy XX ; register# in Y ; reg in Y, value in X - jsr write_ay_left ; assume 3 channel (not six) - jsr write_ay_right ; so write same to both left/write + jsr write_ay_left ; assume 3 channel (not six) + jsr write_ay_right ; so write same to both left/write + + ldx XX ; restore X + ldy YY ; restore Y + + jmp bottom_regs_loop ; loop + +top_regs: + iny ; point to next value + lda (INL),Y ; load top reg bitmask + sta MASK + ldx #$7 ; load X as 7 (we increment first) +top_regs_loop: + inx ; increment + cpx #$16 + beq done_with_masks ; exit if done + + ror MASK + bcc top_regs_loop ; loop if not set + + stx XX ; save X value + + iny ; point to value + lda (INL),Y ; read in output value + + sty YY ; save Y value + + tax ; value in X + ldy XX ; register in Y + + ; reg in Y, value in X + jsr write_ay_left ; assume 3 channel (not six) + jsr write_ay_right ; so write same to both left/write ldx XX ldy YY jmp top_regs_loop -bottom_regs: +done_with_masks: iny - lda (INL),Y ; load low reg bitmask - ldx #$ff -bottom_regs_loop: - inx - cmp #$8 - beq delay_a_bit - ror - bcc bottom_regs_loop + clc + tya + adc INL + sta INL + lda #0 + adc INH + sta INH + jsr delay_50Hz - stx XX - sty YY + jmp new_frame - iny - lda (INL),Y ; read in value - tax - - ldy XX - - ; reg in Y, value in X - jsr write_ay_left ; assume 3 channel (not six) - jsr write_ay_right ; so write same to both left/write - - ldx XX - ldy YY - - jmp bottom_regs_loop - - ; reg in Y, value in X - jsr write_ay_left ; assume 3 channel (not six) - jsr write_ay_right ; so write same to both left/write - -delay_a_bit: - - lda #86 - jsr WAIT ; delay 1/2(26+27A+5A^2) us - ; 50Hz = 20ms = 20000us - ; 40000 = 26+27A+5A^2 - ; 5a^2+27a-39974 = 0 - ; A = 86.75 - - jmp old_frame done_play: jsr clear_ay_left jsr clear_ay_right - lda #0 sta CH - lda #2 + lda #3 sta CV lda #mocking_message + sta OUTH + jsr move_and_print + + jsr mockingboard_detect_slot4 + cpx #$1 + beq mockingboard_found + + lda #not_message + sta OUTH + inc CV + jsr move_and_print + + jmp forever_loop + +mockingboard_found: + + lda #found_message + sta OUTH + inc CV + jsr move_and_print + + + ;============================ + ; Init the Mockingboard + ;============================ + + jsr mockingboard_init + jsr reset_ay_left + jsr reset_ay_right + jsr clear_ay_left + jsr clear_ay_right + + + ;=========================== + ; load pointer to the music + ;=========================== + + lda #ksptheme + sta INH + + ldy #0 +new_frame: + lda (INL),Y ; read in frame delay + cmp #$ff ; see if end + beq done_play ; if so, done + + tax +old_frame: + dex ; decrement the frame diff + bpl delay_a_bit ; if not there yet, delay + +top_regs: + iny + lda (INL),Y ; load low reg bitmask + ldx #$ff +top_regs_loop: + inx + cmp #$8 + beq bottom_regs + ror + bcc top_regs_loop + + stx XX + sty YY + + iny + lda (INL),Y ; read in value + tax + + ldy XX + + ; reg in Y, value in X + jsr write_ay_left ; assume 3 channel (not six) + jsr write_ay_right ; so write same to both left/write + + ldx XX + ldy YY + + jmp top_regs_loop + +bottom_regs: + iny + lda (INL),Y ; load low reg bitmask + ldx #$ff +bottom_regs_loop: + inx + cmp #$8 + beq delay_a_bit + ror + bcc bottom_regs_loop + + + stx XX + sty YY + + iny + lda (INL),Y ; read in value + tax + + ldy XX + + ; reg in Y, value in X + jsr write_ay_left ; assume 3 channel (not six) + jsr write_ay_right ; so write same to both left/write + + ldx XX + ldy YY + + jmp bottom_regs_loop + + ; reg in Y, value in X + jsr write_ay_left ; assume 3 channel (not six) + jsr write_ay_right ; so write same to both left/write + +delay_a_bit: + + lda #86 + jsr WAIT ; delay 1/2(26+27A+5A^2) us + ; 50Hz = 20ms = 20000us + ; 40000 = 26+27A+5A^2 + ; 5a^2+27a-39974 = 0 + ; A = 86.75 + + jmp old_frame +done_play: + + jsr clear_ay_left + jsr clear_ay_right + + + lda #0 + sta CH + lda #2 + sta CV + lda #done_message + sta OUTH + jsr move_and_print + + +forever_loop: + jmp forever_loop + +;========= +;routines +;========= +.include "../asm_routines/gr_offsets.s" +.include "../asm_routines/text_print.s" +.include "../asm_routines/mockingboard.s" + +;======= +; music +;======= +.include "ksp_theme_compressed.inc" + +;========= +; strings +;========= +mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4: " +not_message: .byte "NOT " +found_message: .asciiz "FOUND" +done_message: .asciiz "DONE PLAYING" diff --git a/mockingboard/mock_test.dsk b/mockingboard/mock_test.dsk index a9e7e476..6c040492 100644 Binary files a/mockingboard/mock_test.dsk and b/mockingboard/mock_test.dsk differ diff --git a/mockingboard/zp.inc b/mockingboard/zp.inc index 56cf2e1d..3af335f7 100644 --- a/mockingboard/zp.inc +++ b/mockingboard/zp.inc @@ -100,7 +100,8 @@ KEY_OFFSET EQU $8D DRAW_BLUE_SKY EQU $8E RANDOM_POINTER EQU $8F FRAME_COUNT EQU $90 -AY_FRAME EQU $91 +MB_ADDRL EQU $91 +MB_ADDRH EQU $92 SHIPY EQU $E4