fireworks: one last try at exact vapor lock

is one full line off on II+ for some reason?
This commit is contained in:
Vince Weaver 2018-09-18 23:53:58 -04:00
parent 4e527d56b6
commit fad3c48c34
5 changed files with 296 additions and 58 deletions

View File

@ -16,7 +16,7 @@ fireworks.dsk: FIREWORKS.BAS FIREWORKS
FIREWORKS: fireworks.o FIREWORKS: fireworks.o
ld65 -o FIREWORKS fireworks.o -C ../linker_scripts/apple2_1000.inc ld65 -o FIREWORKS fireworks.o -C ../linker_scripts/apple2_1000.inc
fireworks.o: fireworks.s gr_copy.s random16.s fw.s hgr.s \ fireworks.o: fireworks.s gr_copy.s random16.s fw.s hgr.s delay_a.s \
vapor_lock.s gr_hline.s state_machine.s move_letters.s \ vapor_lock.s gr_hline.s state_machine.s move_letters.s \
background_final.inc background_final.inc
ca65 -o fireworks.o fireworks.s -l fireworks.lst ca65 -o fireworks.o fireworks.s -l fireworks.lst

25
fireworks/delay_a.s Normal file
View File

@ -0,0 +1,25 @@
; From http://6502org.wikidot.com/software-delay
; 25+A cycles (including JSR), 19 bytes (excluding JSR)
;
; The branches must not cross page boundaries!
;
; Cycles Accumulator Carry flag
; 0 1 2 3 4 5 6 (hex) 0 1 2 3 4 5 6
; jsr delay_a ; 6 6 6 6 6 6 6 00 01 02 03 04 05 06
dly0: sbc #7
delay_a:cmp #7 ; 2 2 2 2 2 2 2 00 01 02 03 04 05 06 0 0 0 0 0 0 0
bcs dly0 ; 2 2 2 2 2 2 2 00 01 02 03 04 05 06 0 0 0 0 0 0 0
lsr ; 2 2 2 2 2 2 2 00 00 01 01 02 02 03 0 1 0 1 0 1 0
bcs dly1 ; 2 3 2 3 2 3 2 00 00 01 01 02 02 03 0 1 0 1 0 1 0
dly1: beq dly2 ; 3 3 2 2 2 2 2 00 00 01 01 02 02 03 0 1 0 1 0 1 0
lsr ; 2 2 2 2 2 00 00 01 01 01 1 1 0 0 1
beq dly3 ; 3 3 2 2 2 00 00 01 01 01 1 1 0 0 1
bcc dly3 ; 3 3 2 01 01 01 0 0 1
dly2: bne dly3 ; 2 2 3 00 00 01 0 1 0
dly3: rts ; 6 6 6 6 6 6 6 00 00 00 00 01 01 01 0 1 1 1 0 0 1
;
; Total cycles: 25 26 27 28 29 30 31

View File

@ -89,7 +89,7 @@ init_letters:
sta LETTERX sta LETTERX
lda #22 lda #22
sta LETTERY sta LETTERY
lda #28 lda #25
sta LETTERD sta LETTERD
@ -150,27 +150,31 @@ init_letters:
; setup graphics for vapor lock ; setup graphics for vapor lock
;============================== ;==============================
jsr vapor_lock ; 6 for rts? jsr vapor_lock ; 6
; found first line of black after green, at up to line 26 on screen ; vapor lock returns with us at beginning of hsync in line
; so we want roughly 22 lines * 4 = 88*65 = 5720 + 4550 = 10270 ; 114 (7410 cycles), so with 5070 lines to go
; - 65 (for the scanline we missed) = 10205 - 12 = 10193
; so we have 5070 + 4550 = 9620 to kill
jsr gr_copy_to_current ; 6+ 9292 jsr gr_copy_to_current ; 6+ 9292
; 10193 - 9298 - 6 = 889
; Fudge factor (unknown) -24 = 865 ; now we have 322 left
; GR part ; GR part
bit LORES ; 4 bit LORES ; 4
bit SET_GR ; 4 bit SET_GR ; 4
bit FULLGR ; 4 bit FULLGR ; 4
; Try X=88 Y=2 cycles=893 R2 ; 322 - 12 = 310
; - 3 for jmp
; 307
nop ; Try X=9 Y=6 cycles=307
ldy #2 ; 2
ldy #6 ; 2
loopA: loopA:
ldx #88 ; 2 ldx #9 ; 2
loopB: loopB:
dex ; 2 dex ; 2
bne loopB ; 2nt/3 bne loopB ; 2nt/3
@ -178,7 +182,7 @@ loopB:
dey ; 2 dey ; 2
bne loopA ; 2nt/3 bne loopA ; 2nt/3
jmp display_loop jmp display_loop ; 3
.align $100 .align $100
@ -284,13 +288,13 @@ cpage0_loop:
bne cpage0_loop ; 2/3 bne cpage0_loop ; 2/3
;============= ;=============
; 10+(5*5)-1=34 ; 10+(5*5)-1=34
bit $1000 ; 4
bit $1000 ; 4
bit TEXTGR ; 4 bit TEXTGR ; 4
bit $1000 ; 4 bit $1000 ; 4
bit $1000 ; 4 bit $1000 ; 4
bit $1000 ; 4 bit $1000 ; 4
bit $1000 ; 4 bit $1000 ; 4
bit $1000 ; 4
bit $1000 ; 4
lda DRAW_PAGE ; 3 lda DRAW_PAGE ; 3
; we set PAGE1 (4) as well as dey (2) and bne (3) then nop (55) ; we set PAGE1 (4) as well as dey (2) and bne (3) then nop (55)
@ -305,9 +309,10 @@ cpage1_loop:
;============= ;=============
; 10+(5*5)-1=34 ; 10+(5*5)-1=34
bit $1000 ; 4
bit $1000 ; 4
bit TEXTGR ; 4 bit TEXTGR ; 4
bit $1000 ; 4
bit $1000 ; 4
bit $1000 ; 4 bit $1000 ; 4
lda DRAW_PAGE ; 3 lda DRAW_PAGE ; 3
nop ; 2 nop ; 2
@ -421,6 +426,7 @@ jump_table:
.include "hgr.s" .include "hgr.s"
.include "vapor_lock.s" .include "vapor_lock.s"
.include "move_letters.s" .include "move_letters.s"
.include "delay_a.s"
background: background:

View File

@ -185,39 +185,39 @@ waste_28:
letters: letters:
; .byte 22,28, ; .byte 22,28,
.byte " ",128 .byte " ",128
.byte 22+128,28," ",128 .byte 22+128,25," ",128
.byte 23,28, " ",128 .byte 23,25, " ",128
.byte 23+128,28," ",128 .byte 23+128,25," ",128
.byte 22,28, "CODE BY",128 .byte 22,26, "CODE BY",128
.byte 22+128,28,"CODE BY",128 .byte 22+128,26,"CODE BY",128
.byte 23,28, "DEATER",128 .byte 23,26, "DEATER",128
.byte 23+128,28,"DEATER",198 .byte 23+128,26,"DEATER",198
.byte 22,28, " ",128 .byte 22,26, " ",128
.byte 22+128,28," ",128 .byte 22+128,26," ",128
.byte 23,28, " ",128 .byte 23,26, " ",128
.byte 23+128,28," ",128 .byte 23+128,26," ",128
.byte 22,28, "FIREWORKS",128 .byte 22,26, "FIREWORKS",128
.byte 22+128,28,"FIREWORKS",128 .byte 22+128,26,"FIREWORKS",128
.byte 23,28, "FOZZTEXX",128 .byte 23,26, "FOZZTEXX",128
.byte 23+128,28,"FOZZTEXX",198 .byte 23+128,26,"FOZZTEXX",198
.byte 22,28, " ",128 .byte 22,26, " ",128
.byte 22+128,28," ",128 .byte 22+128,26," ",128
.byte 23,28, " ",128 .byte 23,26, " ",128
.byte 23+128,28," ",128 .byte 23+128,26," ",128
.byte 22,28,"A VMW",128 .byte 22,26,"A VMW",128
.byte 22+128,28,"A VMW",128 .byte 22+128,26,"A VMW",128
.byte 23,28,"PRODUCTION",128 .byte 23,26,"PRODUCTION",128
.byte 23+128,28,"PRODUCTION" .byte 23+128,26,"PRODUCTION"
.byte 255 .byte 255

View File

@ -6,13 +6,56 @@ vapor_lock:
; Clear Page0 ; Clear Page0
lda #$0 lda #$0
sta DRAW_PAGE sta DRAW_PAGE
lda #$44 lda #$ff ; full screen dark green $44
jsr clear_gr jsr clear_gr
; Make screen half green lda #$aa
lda #$11
ldy #24 ldy #24
jsr clear_page_loop jsr clear_page_loop ; make top half red $11
ldy #00 ; 0
sty $728+20
iny ; 1
sty $728+21
iny ; 2
sty $728+22
iny ; 3
sty $728+23
iny ; 4
sty $728+24
iny ; 5
sty $728+25
iny ; 6
sty $728+26
iny ; 7
sty $728+27
iny ; 8
sty $728+28
iny ; 9
sty $728+29
iny ; a
sty $728+30
iny ; b
sty $728+31
iny ; c
sty $728+32
iny ; d
sty $728+33
iny ; e
sty $728+34
iny ; f
sty $728+35
iny ; 10
sty $728+36
iny
sty $728+37
iny
sty $728+38
iny
sty $728+39
;btt:
; jmp btt
;===================================================== ;=====================================================
@ -33,26 +76,190 @@ vapor_lock:
; to avoid false positive found if the horiz blanking is mirroring ; to avoid false positive found if the horiz blanking is mirroring
; the line (max 3 repeats in that case) ; the line (max 3 repeats in that case)
vapor_lock_loop: ; first make sure we have all zeroes vapor_lock_loop:
LDA #$11
; first make sure we have a full line of red
; we can only read every
lda #$aa ; 2
zxloop: zxloop:
LDX #$04 ldx #$04 ; 2
wiloop: wiloop:
CMP $C051 cmp $C051 ; read the floating bus ; 4
BNE zxloop bne zxloop ; if not red, start from scratch ; 2/3
DEX dex ; we were red, dec ; 2
BNE wiloop bne wiloop ; if not 4 of them, restart ; 3/2
LDA #$44 ; now look for our border color (4 times) ; if we get here we read 4 proper pixels, 11 apart
; X X X X
; X X X X
; X X X X
; X X X X
; X X X X
; X X X X
; X X X X
; 0123456789012345678901234 0123456789012345678901234567890123456789
; 1 2 1 2 3
; hsync pixels
; XXXXXXXXXXXXXXXXXXXXXXXXX 4444444444444444444444444444440123456789
; now look for the color change that
; happens at line 12*8 = 96
lda #$ff ; 2
zloop: zloop:
LDX #$04 ldx #$04 ; 2
qloop: qloop:
CMP $C051 cmp $C051 ; read floating bus ; 4
BNE zloop bne zloop ; 2/3
DEX dex ; 2
BNE qloop bne qloop ; 3/2
;============
; 11
rts ; delay 65 *1
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
; delay 65 *1
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
; delay 65 *1
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
; delay 65 *1
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
; delay 65 *1
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
; delay 65 *1
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
; delay 65 *1
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
; delay 65 *1
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
inc $0
lda $C051
;kbb:
; jmp kbb
; we are in theory on line $728 = 14*8 = 112
; so 112*65 = 7280 cycles from start
; we are actualy 25+20+A pixels in
; 7325+A
; 114 is at 7410 cycles
; 7410 - 7325 = 85
; so kill 85-A cycles
; -6 to do subtraction
; -6 for rts
; -25 for delay_a overhead
eor #$ff ; 2
sec ; 2
adc #48 ; 2
jsr delay_a ; should total 48 cycles
done_vapor_lock:
rts ; 6