megademo: re-use some infrastructure from fireworks demo

This commit is contained in:
Vince Weaver 2018-09-17 13:51:53 -04:00
parent f95b5e697e
commit 8feda43b13
6 changed files with 100 additions and 93 deletions

View File

@ -21,7 +21,7 @@ MEGADEMO: megademo.o
megademo.o: megademo.s \
zp.inc hardware.inc \
gr_offsets.s \
gr_hline.s gr_offsets.s vapor_lock.s \
c64_opener.s c64.img.lz4 \
falling_apple.s apple_40_96.inc
ca65 -o megademo.o megademo.s -l megademo.lst

View File

@ -73,62 +73,11 @@ falling_apple:
; setup graphics for vapor lock
;==============================
; Clear Page0
lda #$0
sta DRAW_PAGE
lda #$44
jsr clear_gr
; Make screen half green
lda #$11
ldy #24
jsr clear_page_loop
;=====================================================
; attempt vapor lock
; by reading the "floating bus" we can see most recently
; written value of the display
; we look for $55 (which is the grey line)
;=====================================================
; See:
; Have an Apple Split by Bob Bishop
; Softalk, October 1982
; Challenges: each scan line scans 40 bytes.
; The blanking happens at the *beginning*
; So 65 bytes are scanned, starting at adress of the line - 25
; the scan takes 8 cycles, look for 4 repeats of the value
; to avoid false positive found if the horiz blanking is mirroring
; the line (max 3 repeats in that case)
vapor_lock_loop: ; first make sure we have all zeroes
LDA #$11
zxloop:
LDX #$04
wiloop:
CMP $C051
BNE zxloop
DEX
BNE wiloop
LDA #$44 ; now look for our border color (4 times)
zloop:
LDX #$04
qloop:
CMP $C051
BNE zloop
DEX
BNE qloop
; found first line of black after green, at up to line 26 on screen
; so we want roughly 22 lines * 4 = 88*65 = 5720 + 4550 = 10270
; - 65 (for the scanline we missed) = 10205 - 12 = 10193
jsr vapor_lock ; 6?
jsr gr_copy_to_current ; 6+ 9292
; 10193 - 9298 = 895
; Fudge factor (unknown) -30 = 865
; 10193 - 9298 = 889
; Fudge factor (unknown) -24 = 865
; GR part
bit LORES ; 4
@ -237,43 +186,6 @@ loop2:
rts ; 6
;==================================
; HLINE
;==================================
; Color in A
; Y has which line
hline:
pha ; 3
ldx gr_offsets,y ; 4+
stx hline_loop+1 ; 4
lda gr_offsets+1,y ; 4+
clc ; 2
adc DRAW_PAGE ; 3
sta hline_loop+2 ; 4
pla ; 4
ldx #39 ; 2
hline_loop:
sta $5d0,X ; 38 ; 5
dex ; 2
bpl hline_loop ; 2nt/3
rts ; 6
;==========================
; Clear gr screen
;==========================
; Color in A
clear_gr:
ldy #46
clear_page_loop:
jsr hline
dey
dey
bpl clear_page_loop
rts
.include "../asm_routines/gr_unrle.s"
.include "gr_copy.s"

View File

@ -4,7 +4,7 @@
; copy 0xc00 to DRAW_PAGE
;
; 45 + 2 + 120*(8*9 + 5) -1 + 6 = 9292
.align $100
gr_copy_to_current:
lda DRAW_PAGE ; 3

34
megademo/gr_hline.s Normal file
View File

@ -0,0 +1,34 @@
;==================================
; HLINE
;==================================
; Color in A
; Y has which line
hline:
pha ; 3
ldx gr_offsets,y ; 4+
stx hline_loop+1 ; 4
lda gr_offsets+1,y ; 4+
clc ; 2
adc DRAW_PAGE ; 3
sta hline_loop+2 ; 4
pla ; 4
ldx #39 ; 2
hline_loop:
sta $5d0,X ; 38 ; 5
dex ; 2
bpl hline_loop ; 2nt/3
rts ; 6
;==========================
; Clear gr screen
;==========================
; Color in A
clear_gr:
ldy #46
clear_page_loop:
jsr hline
dey
dey
bpl clear_page_loop
rts

View File

@ -36,3 +36,6 @@ loop_forever:
.include "c64_opener.s"
.include "falling_apple.s"
.include "gr_offsets.s"
.include "gr_hline.s"
.include "vapor_lock.s"

58
megademo/vapor_lock.s Normal file
View File

@ -0,0 +1,58 @@
;==============================
; setup graphics for vapor lock
;==============================
vapor_lock:
; Clear Page0
lda #$0
sta DRAW_PAGE
lda #$44
jsr clear_gr
; Make screen half green
lda #$11
ldy #24
jsr clear_page_loop
;=====================================================
; attempt vapor lock
; by reading the "floating bus" we can see most recently
; written value of the display
; we look for $55 (which is the grey line)
;=====================================================
; See:
; Have an Apple Split by Bob Bishop
; Softalk, October 1982
; Challenges: each scan line scans 40 bytes.
; The blanking happens at the *beginning*
; So 65 bytes are scanned, starting at adress of the line - 25
; the scan takes 8 cycles, look for 4 repeats of the value
; to avoid false positive found if the horiz blanking is mirroring
; the line (max 3 repeats in that case)
vapor_lock_loop: ; first make sure we have all zeroes
LDA #$11
zxloop:
LDX #$04
wiloop:
CMP $C051
BNE zxloop
DEX
BNE wiloop
LDA #$44 ; now look for our border color (4 times)
zloop:
LDX #$04
qloop:
CMP $C051
BNE zloop
DEX
BNE qloop
rts