megamusic: trying to get things to fit

This commit is contained in:
Vince Weaver 2018-10-27 22:28:54 -04:00
parent 63f7e7e7fd
commit 80ddbea278
7 changed files with 710 additions and 12 deletions

View File

@ -7,8 +7,9 @@ PNG_TO_RLE = ../gr-utils/png2rle
all: megamusic.dsk
megamusic.dsk: MEGAMUSIC MEGALOAD
megamusic.dsk: MEGAMUSIC MEGALOAD HALFMUSIC
$(DOS33) -y megamusic.dsk BSAVE -a 0x4000 MEGAMUSIC
$(DOS33) -y megamusic.dsk BSAVE -a 0x4000 HALFMUSIC
$(DOS33) -y megamusic.dsk BSAVE -a 0x800 MEGALOAD
####
@ -20,6 +21,15 @@ megamusic.o: megamusic.s \
play_music.s falling_apple.s
ca65 -o megamusic.o megamusic.s -l megamusic.lst
####
HALFMUSIC: halfmusic.o
ld65 -o HALFMUSIC halfmusic.o -C ../linker_scripts/apple2_4000.inc
halfmusic.o: halfmusic.s \
play_half.s falling_half.s
ca65 -o halfmusic.o halfmusic.s -l halfmusic.lst
####
@ -32,4 +42,4 @@ megaload.o: megaload.s
####
clean:
rm -f *~ *.o *.lst MEGAMUSIC MEGALOAD
rm -f *~ *.o *.lst MEGAMUSIC MEGALOAD HALFMUSIC

View File

@ -161,6 +161,8 @@ page1_loop: ; delay 115+(7 loop)+4 (bit)+4(extra)
; Try X=231 Y=3 cycles=3484
ldy #3 ; 2
faloop1:ldx #231 ; 2
faloop2:dex ; 2

228
megamusic/falling_half.s Normal file
View File

@ -0,0 +1,228 @@
; Display Falling Apple II and message
falling_half:
;===================
; init screen
jsr TEXT
jsr HOME
bit KEYRESET
;===================
; init vars
lda #0
sta DRAW_PAGE
sta FRAME
sta FRAMEH
;=============================
; Load graphic page0
lda #$0c
sta BASH
lda #$00
sta BASL ; load image to $c00
lda #<apple_low
sta GBASL
lda #>apple_low
sta GBASH
jsr load_rle_gr
lda #4
sta DRAW_PAGE
jsr gr_copy_to_current ; copy to page1
; GR part
bit PAGE1
bit LORES ; 4
bit SET_GR ; 4
bit FULLGR ; 4
;=============================
; Load graphic page1
lda #$0c
sta BASH
lda #$00
sta BASL ; load image to $c00
lda #<apple_high
sta GBASL
lda #>apple_high
sta GBASH
jsr load_rle_gr
lda #0
sta DRAW_PAGE
jsr gr_copy_to_current
; GR part
bit PAGE0
;==============================
; setup graphics for vapor lock
;==============================
jsr vapor_lock ; 6
; vapor lock returns with us at beginning of hsync in line
; 114 (7410 cycles), so with 5070 lines to go
jsr gr_copy_to_current ; 6+ 9292
; now we have 322 left
; GR part
bit LORES ; 4
bit SET_GR ; 4
bit FULLGR ; 4
; 322 - 12 = 310
; - 3 for jmp
; 307
; Try X=9 Y=6 cycles=307
ldy #6 ; 2
faloopA:ldx #9 ; 2
faloopB:dex ; 2
bne faloopB ; 2nt/3
dey ; 2
bne faloopA ; 2nt/3
jmp fa_display_loop ; 3
.align $100
;================================================
; Display Loop
;================================================
; each scan line 65 cycles
; 1 cycle each byte (40cycles) + 25 for horizontal
; Total of 12480 cycles to draw screen
; Vertical blank = 4550 cycles (70 scan lines)
; Total of 17030 cycles to get back to where was
; in the end, scrolling in was deemed to complex
; what we do is load both to PAGE1/PAGE2 and then
; slowly shift from all PAGE1 to PAGE1/PAGE every two scanlines
fa_display_loop:
ldy #48 ; 2
outer_loop:
bit PAGE0 ; 4
ldx #25 ; 130 cycles with PAGE0 ; 2
page0_loop: ; delay 126+bit
dex ; 2
bne page0_loop ; 2/3
bit PAGE1 ; 4
ldx #23 ; 130 cycles with PAGE1 ; 2
page1_loop: ; delay 115+(7 loop)+4 (bit)+4(extra)
dex ; 2
bne page1_loop ; 2/3
nop ; 2
lda DRAW_PAGE ; 3
dey ; 2
bne outer_loop ; 2/3
;======================================================
; We have 4550 cycles in the vblank, use them wisely
;======================================================
; 4550 cycles
; -1 (+1-2) from above
; -25 inc framecount
; -7 see if timeout
;-1023 play_music
; -10 keypress
;================
; 3484
jsr play_music ; 6+1017
; Try X=231 Y=3 cycles=3484
ldy #3 ; 2
faloop1:ldx #231 ; 2
faloop2:dex ; 2
bne faloop2 ; 2nt/3
dey ; 2
bne faloop1 ; 2nt/3
;========================
; Increment Frame at 20Hz
;========================
; noinc: 13+12=25
; inc: 13+12=25
inc FRAME ; 5
lda FRAME ; 3
cmp #4 ; 2
bne fa_noinc ; 3
; -1
lda #0 ; 2
sta FRAME ; 3
inc FRAMEH ; 5
jmp fa_doneinc ; 3
fa_noinc:
lda $0 ; 3
lda $0 ; 3
lda $0 ; 3
lda $0 ; 3
fa_doneinc:
;====================
; exit after 5s or so
;====================
; 7 cycles
lda FRAMEH ; 3
cmp #100 ; 2
nop
;beq fa_done ; 3
; -1
;=====================
; check for keypress
; 10 cycles
lda KEYPRESS ; 4
bpl fa_no_keypress ; 3
jmp fa_done
fa_no_keypress:
jmp fa_display_loop ; 3
fa_done:
bit KEYRESET ; clear keypress ; 4
rts ; 6
;.include "../asm_routines/gr_unrle.s"
;.include "gr_copy.s"
;.include "apple_40_96.inc"

56
megamusic/halfmusic.s Normal file
View File

@ -0,0 +1,56 @@
; Apple II Megademo
; by deater (Vince Weaver) <vince@deater.net>
.include "zp.inc"
.include "hardware.inc"
megamusic_start: ; this should end up at $4000
lda #0
sta MB_FRAME
sta MB_PATTERN
;===================
; Init mockingboard
;===================
jsr mockingboard_init
;===================
; set graphics mode
;===================
jsr HOME
; apple
jsr falling_half
;==================
; Game over
;==================
; we never get here
game_over_man:
jmp game_over_man
.include "falling_half.s"
.include "gr_unrle.s"
.include "gr_copy.s"
.align $100
.include "gr_offsets.s"
.include "gr_hline.s"
.include "vapor_lock.s"
.include "delay_a.s"
.align $100
.include "mockingboard.s"
.include "play_half.s"
;============================
; Include Lores Graphics
; No Alignment Needed
;============================
; falling_apple
.include "apple_40_96.inc"

View File

@ -39,9 +39,9 @@ start:
jsr opendir ; open and read entire file into memory
; open and read a file
; lda #<c64_filename
; lda #<half_filename
; sta namlo
; lda #>c64_filename
; lda #>half_filename
; sta namhi
; jsr opendir ; open and read entire file into memory
@ -55,9 +55,9 @@ megademo_filename: ;.byte "MEGAMUSIC "
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
.byte $A0,$A0,$A0,$A0,$A0,$A0
c64_filename: ;.byte "C64.IMG "
.byte 'C'|$80,'6'|$80,'4'|$80,'.'|$80,'I'|$80,'M'|$80,'G'|$80,$A0
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
half_filename: ;.byte "HALFMUSIC "
.byte 'H'|$80,'A'|$80,'L'|$80,'F'|$80,'M'|$80,'U'|$80,'S'|$80,'I'|$80
.byte 'C'|$80,$A0,$A0,$A0,$A0,$A0,$A0,$A0
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
.byte $A0,$A0,$A0,$A0,$A0,$A0

394
megamusic/play_half.s Normal file
View File

@ -0,0 +1,394 @@
; takes
; 3 + 83 +
; 80 + 82 + 88 +
; 80 + 82 + 88 +
; 80 + 82 + 88 +
; 80 + 80 +
; 26 = 1022 + 8 = 1030
play_music:
lda FRAME ; 3
and #1 ; 2
beq play_half ; 3
; -1
play_nothing:
; need to delay 1022-6= 1016
; Try X=201 Y=1 cycles=1012 R4
nop
nop
ldy #1 ; 2
hmloopA:ldx #201 ; 2
hmloopB:dex ; 2
bne hmloopB ; 2nt/3
dey ; 2
bne hmloopA ; 2nt/3
rts ; 6
play_half:
; self-modify the code
lda MB_PATTERN ; 3
and #$1f ; 2
tay ; 2
lda mal_pattern,Y ; 4
sta mb_smc1+2 ; 4
lda mah_pattern,Y ; 4
sta mb_smc2+2 ; 4
sta mb_smc3+2 ; 4
lda mbl_pattern,Y ; 4
sta mb_smc4+2 ; 4
lda mbh_pattern,Y ; 4
sta mb_smc5+2 ; 4
sta mb_smc6+2 ; 4
lda mcl_pattern,Y ; 4
sta mb_smc7+2 ; 4
lda mch_pattern,Y ; 4
sta mb_smc8+2 ; 4
sta mb_smc9+2 ; 4
lda mnl_pattern,Y ; 4
sta mb_smc10+2 ; 4
lda mnh_pattern,Y ; 4
sta mb_smc11+2 ; 4
;=======
; 83
; play the code
ldy MB_FRAME ; 3
;=======
; mal
mb_smc1:
lda mal00,Y ; 4
sta MB_VALUE ; 3
ldx #0 ; 2
jsr write_ay_both ; 6+65
;=========
; 80
; mah
mb_smc2:
lda mal00,Y ; 4
and #$f ; 2
sta MB_VALUE ; 3
ldx #1 ; 2
jsr write_ay_both ; 6+65
;========
; 82
mb_smc3:
lda mal00,Y ; 4
lsr ; 2
lsr ; 2
lsr ; 2
lsr ; 2
sta MB_VALUE ; 3
ldx #8 ; 2
jsr write_ay_both ; 6+65
;=======
; 88
; mbl
mb_smc4:
lda mbl00,Y ; 4
sta MB_VALUE ; 3
ldx #2 ; 2
jsr write_ay_both ; 6+65
;=======
; 80
; mbh
mb_smc5:
lda mbh00,Y ; 4
and #$f ; 2
sta MB_VALUE ; 3
ldx #3 ; 2
jsr write_ay_both ; 6+65
;=======
; 82
mb_smc6:
lda mbh00,Y ; 4
lsr ; 2
lsr ; 2
lsr ; 2
lsr ; 2
sta MB_VALUE ; 3
ldx #9 ; 2
jsr write_ay_both ; 6+65
;======
; 88
; mcl
mb_smc7:
lda mal00,Y ; 4
sta MB_VALUE ; 3
ldx #4 ; 2
jsr write_ay_both ; 6+65
;======
; 80
; mch
mb_smc8:
lda mal00,Y ; 4
and #$f ; 2
sta MB_VALUE ; 3
ldx #5 ; 2
jsr write_ay_both ; 6+65
;=======
; 82
mb_smc9:
lda mal00,Y ; 4
lsr ; 2
lsr ; 2
lsr ; 2
lsr ; 2
sta MB_VALUE ; 3
ldx #10 ; 2
jsr write_ay_both ; 6+65
;========
; 88
; mnl
mb_smc10:
lda mal00,Y ; 4
sta MB_VALUE ; 3
ldx #6 ; 2
jsr write_ay_both ; 6+65
;=======
; 80
; mnh
mb_smc11:
lda mnh00,Y ; 4
sta MB_VALUE ; 3
ldx #7 ; 2
jsr write_ay_both ; 6+65
;=======
; 80
inc MB_FRAME ; 5
inc MB_FRAME ; 5
bne mb_no_change ; 3
; -1
inc MB_PATTERN ; 5
jmp mb_done_change ; 3
mb_no_change:
lda $0 ; 3
nop ; 2
nop ; 2
mb_done_change:
rts ; 6
;=======
; 26
.align $100
; patterns 31 long
mal_pattern:
.byte >mal00,>mal00,>mal02,>mal02,>mal02,>mal02,>mal02,>mal02
.byte >mal02,>mal02,>mal02,>mal02,>mal02,>mal02,>mal02,>mal02
.byte >mal02,>mal02,>mal02,>mal02,>mal02,>mal02,>mal02,>mal02
.byte >mal02,>mal02,>mal02,>mal02,>mal02,>mal02,>mal02,>mal00
mah_pattern:
.byte >mal00,>mal00,>mah02,>mah03,>mah04,>mah05,>mah04,>mah07
.byte >mah04,>mah05,>mah10,>mah11,>mah04,>mah05,>mah04,>mah07
.byte >mah04,>mah05,>mah10,>mah11,>mah04,>mah05,>mah04,>mah07
.byte >mah04,>mah05,>mah10,>mah11,>mah10,>mah11,>mah30,>mal00
mbl_pattern:
.byte >mbl00,>mbl01,>mbl02,>mbl01,>mbl00,>mbl01,>mbl00,>mbl07
.byte >mbl00,>mbl01,>mbl10,>mbl11,>mbl00,>mbl01,>mbl00,>mbl07
.byte >mbl00,>mbl01,>mbl10,>mbl11,>mbl00,>mbl01,>mbl22,>mbl23
.byte >mbl00,>mbl01,>mbl10,>mbl11,>mbl10,>mbl11,>mbl01,>mbl00
mbh_pattern:
.byte >mbh00,>mbh01,>mbh00,>mbh01,>mbh04,>mbh05,>mbh04,>mbh07
.byte >mbh08,>mbh05,>mbh10,>mbh11,>mbh04,>mbh05,>mbh04,>mbh07
.byte >mbh08,>mbh05,>mbh10,>mbh11,>mbh04,>mbh05,>mbh22,>mbh23
.byte >mbh08,>mbh05,>mbh10,>mbh11,>mbh10,>mbh11,>mbh30,>mal00
mcl_pattern:
.byte >mal00,>mal00,>mal00,>mcl03,>mcl04,>mcl05,>mcl04,>mcl07
.byte >mcl08,>mcl09,>mcl10,>mcl11,>mcl04,>mcl05,>mcl04,>mcl07
.byte >mcl08,>mcl09,>mcl10,>mcl11,>mcl04,>mcl05,>mcl22,>mcl23
.byte >mcl08,>mcl09,>mcl10,>mcl11,>mcl10,>mcl11,>mcl30,>mal00
mch_pattern:
.byte >mal00,>mal00,>mal00,>mch03,>mch04,>mch05,>mch04,>mch07
.byte >mch08,>mch09,>mch10,>mch11,>mch04,>mch05,>mch04,>mch07
.byte >mch08,>mch09,>mch10,>mch11,>mch04,>mch05,>mch22,>mch23
.byte >mch08,>mch09,>mch10,>mch11,>mch10,>mch11,>mch30,>mal00
mnl_pattern:
.byte >mal00,>mal00,>mal00,>mnl03,>mnl04,>mnl05,>mnl04,>mnl07
.byte >mnl04,>mnl05,>mnl10,>mnl11,>mnl04,>mnl05,>mnl04,>mnl07
.byte >mnl04,>mnl05,>mnl10,>mnl11,>mnl04,>mnl05,>mnl04,>mnl07
.byte >mnl04,>mnl05,>mnl10,>mnl11,>mnl10,>mnl11,>mnl30,>mal00
mnh_pattern:
.byte >mnh00,>mnh01,>mnh02,>mnh03,>mnh04,>mnh05,>mnh04,>mnh07
.byte >mnh08,>mnh09,>mnh10,>mnh11,>mnh04,>mnh05,>mnh04,>mnh07
.byte >mnh08,>mnh09,>mnh10,>mnh11,>mnh04,>mnh05,>mnh04,>mnh23
.byte >mnh08,>mnh09,>mnh10,>mnh11,>mnh10,>mnh11,>mnh30,>mal00
.align $100
mal00:
.incbin "music/mock.al.00"
mal02:
.incbin "music/mock.al.02"
mah02:
.incbin "music/mock.ah.02"
mah03:
.incbin "music/mock.ah.03"
mah04:
.incbin "music/mock.ah.04"
mah05:
.incbin "music/mock.ah.05"
mah07:
.incbin "music/mock.ah.07"
mah10:
.incbin "music/mock.ah.10"
mah11:
.incbin "music/mock.ah.11"
mah30:
.incbin "music/mock.ah.30"
mbl00:
.incbin "music/mock.bl.00"
mbl01:
.incbin "music/mock.bl.01"
mbl02:
.incbin "music/mock.bl.02"
mbl07:
.incbin "music/mock.bl.07"
mbl10:
.incbin "music/mock.bl.10"
mbl11:
.incbin "music/mock.bl.11"
mbl22:
.incbin "music/mock.bl.22"
mbl23:
.incbin "music/mock.bl.23"
mbh00:
.incbin "music/mock.bh.00"
mbh01:
.incbin "music/mock.bh.01"
mbh04:
.incbin "music/mock.bh.04"
mbh05:
.incbin "music/mock.bh.05"
mbh07:
.incbin "music/mock.bh.07"
mbh08:
.incbin "music/mock.bh.08"
mbh10:
.incbin "music/mock.bh.10"
mbh11:
.incbin "music/mock.bh.11"
mbh22:
.incbin "music/mock.bh.22"
mbh23:
.incbin "music/mock.bh.23"
mbh30:
.incbin "music/mock.bh.30"
mcl03:
.incbin "music/mock.cl.03"
mcl04:
.incbin "music/mock.cl.04"
mcl05:
.incbin "music/mock.cl.05"
mcl07:
.incbin "music/mock.cl.07"
mcl08:
.incbin "music/mock.cl.08"
mcl09:
.incbin "music/mock.cl.09"
mcl10:
.incbin "music/mock.cl.10"
mcl11:
.incbin "music/mock.cl.11"
mcl22:
.incbin "music/mock.cl.22"
mcl23:
.incbin "music/mock.cl.23"
mcl30:
.incbin "music/mock.cl.30"
mch03:
.incbin "music/mock.ch.03"
mch04:
.incbin "music/mock.ch.04"
mch05:
.incbin "music/mock.ch.05"
mch07:
.incbin "music/mock.ch.07"
mch08:
.incbin "music/mock.ch.08"
mch09:
.incbin "music/mock.ch.09"
mch10:
.incbin "music/mock.ch.10"
mch11:
.incbin "music/mock.ch.11"
mch22:
.incbin "music/mock.ch.22"
mch23:
.incbin "music/mock.ch.23"
mch30:
.incbin "music/mock.ch.30"
mnl03:
.incbin "music/mock.nl.03"
mnl04:
.incbin "music/mock.nl.04"
mnl05:
.incbin "music/mock.nl.05"
mnl07:
.incbin "music/mock.nl.07"
mnl10:
.incbin "music/mock.nl.10"
mnl11:
.incbin "music/mock.nl.11"
mnl30:
.incbin "music/mock.nl.30"
mnh00:
.incbin "music/mock.nh.00"
mnh01:
.incbin "music/mock.nh.01"
mnh02:
.incbin "music/mock.nh.02"
mnh03:
.incbin "music/mock.nh.03"
mnh04:
.incbin "music/mock.nh.04"
mnh05:
.incbin "music/mock.nh.05"
mnh07:
.incbin "music/mock.nh.07"
mnh08:
.incbin "music/mock.nh.08"
mnh09:
.incbin "music/mock.nh.09"
mnh10:
.incbin "music/mock.nh.10"
mnh11:
.incbin "music/mock.nh.11"
mnh23:
.incbin "music/mock.nh.23"
mnh30:
.incbin "music/mock.nh.30"

View File

@ -1,6 +1,6 @@
; takes
; 3 + 83 +
; 3 + 79 +
; 80 + 82 + 88 +
; 80 + 82 + 88 +
; 80 + 82 + 88 +
@ -25,6 +25,7 @@ play_music:
sta mb_smc5+2 ; 4
sta mb_smc6+2 ; 4
; mcl and mch patterns are the same
lda mcl_pattern,Y ; 4
sta mb_smc7+2 ; 4
lda mch_pattern,Y ; 4
@ -36,7 +37,7 @@ play_music:
lda mnh_pattern,Y ; 4
sta mb_smc11+2 ; 4
;=======
; 83
; 79
@ -196,6 +197,7 @@ mcl_pattern:
.byte >mcl08,>mcl09,>mcl10,>mcl11,>mcl04,>mcl05,>mcl04,>mcl07
.byte >mcl08,>mcl09,>mcl10,>mcl11,>mcl04,>mcl05,>mcl22,>mcl23
.byte >mcl08,>mcl09,>mcl10,>mcl11,>mcl10,>mcl11,>mcl30,>mal00
mch_pattern:
.byte >mal00,>mal00,>mal00,>mch03,>mch04,>mch05,>mch04,>mch07
.byte >mch08,>mch09,>mch10,>mch11,>mch04,>mch05,>mch04,>mch07
@ -213,13 +215,15 @@ mnh_pattern:
.byte >mnh08,>mnh09,>mnh10,>mnh11,>mnh10,>mnh11,>mnh30,>mal00
.align $100
; total = 2+8+8+11+11+11+7+13=71
; 2
mal00:
.incbin "music/mock.al.00"
mal02:
.incbin "music/mock.al.02"
; 8
mah02:
.incbin "music/mock.ah.02"
mah03:
@ -237,6 +241,7 @@ mah11:
mah30:
.incbin "music/mock.ah.30"
; 8
mbl00:
.incbin "music/mock.bl.00"
mbl01:
@ -254,6 +259,7 @@ mbl22:
mbl23:
.incbin "music/mock.bl.23"
; 11
mbh00:
.incbin "music/mock.bh.00"
mbh01:
@ -277,7 +283,7 @@ mbh23:
mbh30:
.incbin "music/mock.bh.30"
; 11
mcl03:
.incbin "music/mock.cl.03"
mcl04:
@ -301,6 +307,7 @@ mcl23:
mcl30:
.incbin "music/mock.cl.30"
; 11
mch03:
.incbin "music/mock.ch.03"
mch04:
@ -324,6 +331,7 @@ mch23:
mch30:
.incbin "music/mock.ch.30"
;7
mnl03:
.incbin "music/mock.nl.03"
mnl04:
@ -339,7 +347,7 @@ mnl11:
mnl30:
.incbin "music/mock.nl.30"
; 13
mnh00:
.incbin "music/mock.nh.00"
mnh01: