From fad3c48c3463f8beafe725309c8500c87c15f221 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 18 Sep 2018 23:53:58 -0400 Subject: [PATCH] fireworks: one last try at exact vapor lock is one full line off on II+ for some reason? --- fireworks/Makefile | 2 +- fireworks/delay_a.s | 25 ++++ fireworks/fireworks.s | 38 +++--- fireworks/move_letters.s | 46 ++++---- fireworks/vapor_lock.s | 243 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 296 insertions(+), 58 deletions(-) create mode 100644 fireworks/delay_a.s diff --git a/fireworks/Makefile b/fireworks/Makefile index 99cd9beb..d5f89278 100644 --- a/fireworks/Makefile +++ b/fireworks/Makefile @@ -16,7 +16,7 @@ fireworks.dsk: FIREWORKS.BAS FIREWORKS FIREWORKS: fireworks.o 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 \ background_final.inc ca65 -o fireworks.o fireworks.s -l fireworks.lst diff --git a/fireworks/delay_a.s b/fireworks/delay_a.s new file mode 100644 index 00000000..2d0802da --- /dev/null +++ b/fireworks/delay_a.s @@ -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 diff --git a/fireworks/fireworks.s b/fireworks/fireworks.s index e3f28269..9f021218 100644 --- a/fireworks/fireworks.s +++ b/fireworks/fireworks.s @@ -89,7 +89,7 @@ init_letters: sta LETTERX lda #22 sta LETTERY - lda #28 + lda #25 sta LETTERD @@ -150,27 +150,31 @@ init_letters: ; 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 - ; so we want roughly 22 lines * 4 = 88*65 = 5720 + 4550 = 10270 - ; - 65 (for the scanline we missed) = 10205 - 12 = 10193 + ; vapor lock returns with us at beginning of hsync in line + ; 114 (7410 cycles), so with 5070 lines to go + + ; so we have 5070 + 4550 = 9620 to kill jsr gr_copy_to_current ; 6+ 9292 - ; 10193 - 9298 - 6 = 889 - ; Fudge factor (unknown) -24 = 865 + + ; now we have 322 left ; GR part bit LORES ; 4 bit SET_GR ; 4 bit FULLGR ; 4 - ; Try X=88 Y=2 cycles=893 R2 + ; 322 - 12 = 310 + ; - 3 for jmp + ; 307 - nop - ldy #2 ; 2 + ; Try X=9 Y=6 cycles=307 + + ldy #6 ; 2 loopA: - ldx #88 ; 2 + ldx #9 ; 2 loopB: dex ; 2 bne loopB ; 2nt/3 @@ -178,7 +182,7 @@ loopB: dey ; 2 bne loopA ; 2nt/3 - jmp display_loop + jmp display_loop ; 3 .align $100 @@ -284,13 +288,13 @@ cpage0_loop: bne cpage0_loop ; 2/3 ;============= ; 10+(5*5)-1=34 + bit $1000 ; 4 + bit $1000 ; 4 bit TEXTGR ; 4 bit $1000 ; 4 bit $1000 ; 4 bit $1000 ; 4 bit $1000 ; 4 - bit $1000 ; 4 - bit $1000 ; 4 lda DRAW_PAGE ; 3 ; 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 + bit $1000 ; 4 + bit $1000 ; 4 bit TEXTGR ; 4 - bit $1000 ; 4 - bit $1000 ; 4 + bit $1000 ; 4 lda DRAW_PAGE ; 3 nop ; 2 @@ -421,6 +426,7 @@ jump_table: .include "hgr.s" .include "vapor_lock.s" .include "move_letters.s" +.include "delay_a.s" background: diff --git a/fireworks/move_letters.s b/fireworks/move_letters.s index f456a14f..2e6c2e0c 100644 --- a/fireworks/move_letters.s +++ b/fireworks/move_letters.s @@ -185,39 +185,39 @@ waste_28: letters: ; .byte 22,28, .byte " ",128 - .byte 22+128,28," ",128 + .byte 22+128,25," ",128 - .byte 23,28, " ",128 - .byte 23+128,28," ",128 + .byte 23,25, " ",128 + .byte 23+128,25," ",128 - .byte 22,28, "CODE BY",128 - .byte 22+128,28,"CODE BY",128 + .byte 22,26, "CODE BY",128 + .byte 22+128,26,"CODE BY",128 - .byte 23,28, "DEATER",128 - .byte 23+128,28,"DEATER",198 + .byte 23,26, "DEATER",128 + .byte 23+128,26,"DEATER",198 - .byte 22,28, " ",128 - .byte 22+128,28," ",128 + .byte 22,26, " ",128 + .byte 22+128,26," ",128 - .byte 23,28, " ",128 - .byte 23+128,28," ",128 + .byte 23,26, " ",128 + .byte 23+128,26," ",128 - .byte 22,28, "FIREWORKS",128 - .byte 22+128,28,"FIREWORKS",128 + .byte 22,26, "FIREWORKS",128 + .byte 22+128,26,"FIREWORKS",128 - .byte 23,28, "FOZZTEXX",128 - .byte 23+128,28,"FOZZTEXX",198 + .byte 23,26, "FOZZTEXX",128 + .byte 23+128,26,"FOZZTEXX",198 - .byte 22,28, " ",128 - .byte 22+128,28," ",128 + .byte 22,26, " ",128 + .byte 22+128,26," ",128 - .byte 23,28, " ",128 - .byte 23+128,28," ",128 + .byte 23,26, " ",128 + .byte 23+128,26," ",128 - .byte 22,28,"A VMW",128 - .byte 22+128,28,"A VMW",128 + .byte 22,26,"A VMW",128 + .byte 22+128,26,"A VMW",128 - .byte 23,28,"PRODUCTION",128 - .byte 23+128,28,"PRODUCTION" + .byte 23,26,"PRODUCTION",128 + .byte 23+128,26,"PRODUCTION" .byte 255 diff --git a/fireworks/vapor_lock.s b/fireworks/vapor_lock.s index 6d6d1343..f18b8b7d 100644 --- a/fireworks/vapor_lock.s +++ b/fireworks/vapor_lock.s @@ -6,13 +6,56 @@ vapor_lock: ; Clear Page0 lda #$0 sta DRAW_PAGE - lda #$44 + lda #$ff ; full screen dark green $44 jsr clear_gr - ; Make screen half green - lda #$11 + lda #$aa 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 ; the line (max 3 repeats in that case) -vapor_lock_loop: ; first make sure we have all zeroes - LDA #$11 +vapor_lock_loop: + + ; first make sure we have a full line of red + ; we can only read every + + lda #$aa ; 2 zxloop: - LDX #$04 + ldx #$04 ; 2 wiloop: - CMP $C051 - BNE zxloop - DEX - BNE wiloop + cmp $C051 ; read the floating bus ; 4 + bne zxloop ; if not red, start from scratch ; 2/3 + dex ; we were red, dec ; 2 + 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: - LDX #$04 + ldx #$04 ; 2 qloop: - CMP $C051 - BNE zloop - DEX - BNE qloop + cmp $C051 ; read floating bus ; 4 + bne zloop ; 2/3 + dex ; 2 + 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