diff --git a/fire/Makefile b/fire/Makefile new file mode 100644 index 00000000..e145876b --- /dev/null +++ b/fire/Makefile @@ -0,0 +1,34 @@ +include ../Makefile.inc + +DOS33 = ../dos33fs-utils/dos33 +PNG_TO_RLE = ../gr-utils/png2rle + + +all: fire.dsk + +fire.dsk: FIRE HELLO + $(DOS33) -y fire.dsk SAVE A HELLO + $(DOS33) -y fire.dsk BSAVE -a 0x1000 FIRE + +#### + +FIRE: fire.o + ld65 -o FIRE fire.o -C ../linker_scripts/apple2_1000.inc + +fire.o: fire.s gr_copy.s gr_unrolled_copy.s vapor_lock.s \ + delay_a.s + ca65 -o fire.o fire.s -l fire.lst + + +#### + +HELLO: hello.bas + ../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO + + +##### + +clean: + rm -f *~ *.o *.lst FIRE HELLO + + diff --git a/fire/delay_a.s b/fire/delay_a.s new file mode 100644 index 00000000..2d0802da --- /dev/null +++ b/fire/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/fire/fire.dsk b/fire/fire.dsk new file mode 100644 index 00000000..524cee5d Binary files /dev/null and b/fire/fire.dsk differ diff --git a/fire/fire.s b/fire/fire.s new file mode 100644 index 00000000..70c229b7 --- /dev/null +++ b/fire/fire.s @@ -0,0 +1,128 @@ +; Lo-res fire animation + +; by deater (Vince Weaver) + +; based on code described here http://fabiensanglard.net/doom_fire_psx/ + +; Zero Page +FRAMEBUFFER = $00 ; $00 - $0F +YPOS = $10 +YPOS_SIN = $11 +CH = $24 +CV = $25 +GBASL = $26 +GBASH = $27 +BASL = $28 +BASH = $29 +MASK = $2E +COLOR = $30 +FRAME = $60 +MB_VALUE = $91 +BIRD_STATE = $E0 +BIRD_DIR = $E1 +DRAW_PAGE = $EE +LASTKEY = $F1 +PADDLE_STATUS = $F2 +XPOS = $F3 +OLD_XPOS = $F4 +TEMP = $FA +TEMPY = $FB +INL = $FC +INH = $FD +OUTL = $FE +OUTH = $FF + +; Soft Switches +KEYPRESS= $C000 +KEYRESET= $C010 +SET_GR = $C050 ; Enable graphics +FULLGR = $C052 ; Full screen, no text +PAGE0 = $C054 ; Page0 +PAGE1 = $C055 ; Page1 +LORES = $C056 ; Enable LORES graphics +PADDLE_BUTTON0 = $C061 +PADDL0 = $C064 +PTRIG = $C070 + +; ROM routines + +TEXT = $FB36 ;; Set text mode +HOME = $FC58 ;; Clear the text screen +WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us + + +fire_demo: + + ;=================== + ; init screen + jsr TEXT + jsr HOME + bit PAGE0 + + ;=================== + ; init vars + lda #0 + + ;============================== + ; 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 +;wfloopA:ldx #9 ; 2 +;wfloopB:dex ; 2 +; bne wfloopB ; 2nt/3 +; dey ; 2 +; bne wfloopA ; 2nt/3 + + +fire_loop: + ;====================================================== + ; We have 4550 cycles in the vblank, use them wisely + ;====================================================== + ; do_nothing should be 4550 + ; ============= + ; 15 cycles + + + ;==================== + ; Handle keypresses + ; if no keypress, 9 + ; if keypress, 6+43 = 49 + + lda KEYPRESS ; 4 + bmi keypress + ; 2 +no_keypress: + jmp fire_loop + +keypress: + jmp keypress + + +.include "gr_hline.s" +;.include "../asm_routines/keypress.s" +.include "gr_copy.s" +.include "gr_unrolled_copy.s" +.include "vapor_lock.s" +.include "delay_a.s" + diff --git a/fire/gr_copy.s b/fire/gr_copy.s new file mode 100644 index 00000000..acd83f6f --- /dev/null +++ b/fire/gr_copy.s @@ -0,0 +1,58 @@ + ;========================================================= + ; gr_copy_to_current, 40x48 version + ;========================================================= + ; copy 0xc00 to DRAW_PAGE + ; + ; 45 + 2 + 120*(8*9 + 5) -1 + 6 = 9292 + +gr_copy_to_current: + + lda DRAW_PAGE ; 3 + clc ; 2 + adc #$4 ; 2 + sta gr_copy_line+5 ; 4 + sta gr_copy_line+11 ; 4 + adc #$1 ; 2 + sta gr_copy_line+17 ; 4 + sta gr_copy_line+23 ; 4 + adc #$1 ; 2 + sta gr_copy_line+29 ; 4 + sta gr_copy_line+35 ; 4 + adc #$1 ; 2 + sta gr_copy_line+41 ; 4 + sta gr_copy_line+47 ; 4 + ;=========== + ; 45 + + ldy #119 ; for early ones, copy 120 bytes ; 2 + +gr_copy_line: + lda $C00,Y ; load a byte (self modified) ; 4 + sta $400,Y ; store a byte (self modified) ; 5 + + lda $C80,Y ; load a byte (self modified) ; 4 + sta $480,Y ; store a byte (self modified) ; 5 + + lda $D00,Y ; load a byte (self modified) ; 4 + sta $500,Y ; store a byte (self modified) ; 5 + + lda $D80,Y ; load a byte (self modified) ; 4 + sta $580,Y ; store a byte (self modified) ; 5 + + lda $E00,Y ; load a byte (self modified) ; 4 + sta $600,Y ; store a byte (self modified) ; 5 + + lda $E80,Y ; load a byte (self modified) ; 4 + sta $680,Y ; store a byte (self modified) ; 5 + + lda $F00,Y ; load a byte (self modified) ; 4 + sta $700,Y ; store a byte (self modified) ; 5 + + lda $F80,Y ; load a byte (self modified) ; 4 + sta $780,Y ; store a byte (self modified) ; 5 + + dey ; decrement pointer ; 2 + bpl gr_copy_line ; ; 2nt/3 + + rts ; 6 + diff --git a/fire/gr_hline.s b/fire/gr_hline.s new file mode 100644 index 00000000..9c77b4a4 --- /dev/null +++ b/fire/gr_hline.s @@ -0,0 +1,40 @@ + ;================================== + ; 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 + +gr_offsets: + .word $400,$480,$500,$580,$600,$680,$700,$780 + .word $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8 + .word $450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0 + diff --git a/fire/gr_unrolled_copy.s b/fire/gr_unrolled_copy.s new file mode 100644 index 00000000..4c89fc95 --- /dev/null +++ b/fire/gr_unrolled_copy.s @@ -0,0 +1,648 @@ + ;========================================================= + ; fast copy rows 22-36 from $C00 to $400 + ;========================================================= + ; + ; 6 + 7*8*40 = 2246 cycles + ; 6*7*40 = 1680 bytes of code? + +gr_copy_row22: + +;= y = 22 $5a8 $da8/$9a8 ========================= + ; x=0,y=22 + lda $da8 + sta $5a8 + lda $da9 + sta $5a9 + lda $daa + sta $5aa + lda $dab + sta $5ab + lda $dac + sta $5ac + lda $dad + sta $5ad + lda $dae + sta $5ae + lda $daf + sta $5af + + ; x=8,y=22 + lda $db0 + sta $5b0 + lda $db1 + sta $5b1 + lda $db2 + sta $5b2 + lda $db3 + sta $5b3 + lda $db4 + sta $5b4 + lda $db5 + sta $5b5 + lda $db6 + sta $5b6 + lda $db7 + sta $5b7 + + ; x=16,y=22 + lda $db8 + sta $5b8 + lda $db9 + sta $5b9 + lda $dba + sta $5ba + lda $dbb + sta $5bb + lda $dbc + sta $5bc + lda $dbd + sta $5bd + lda $dbe + sta $5be + lda $dbf + sta $5bf + + ; x=24,y=22 + lda $dc0 + sta $5c0 + lda $dc1 + sta $5c1 + lda $dc2 + sta $5c2 + lda $dc3 + sta $5c3 + lda $dc4 + sta $5c4 + lda $dc5 + sta $5c5 + lda $dc6 + sta $5c6 + lda $dc7 + sta $5c7 + + ; x=32,y=22 + lda $dc8 + sta $5c8 + lda $dc9 + sta $5c9 + lda $dca + sta $5ca + lda $dcb + sta $5cb + lda $dcc + sta $5cc + lda $dcd + sta $5cd + lda $dce + sta $5ce + lda $dcf + sta $5cf + +;= y = 24 $628 $e28/$a28 ========================= + ; x=0,y=24 + lda $e28 + sta $628 + lda $e29 + sta $629 + lda $e2a + sta $62a + lda $e2b + sta $62b + lda $e2c + sta $62c + lda $e2d + sta $62d + lda $e2e + sta $62e + lda $e2f + sta $62f + + ; x=8,y=24 + lda $e30 + sta $630 + lda $e31 + sta $631 + lda $e32 + sta $632 + lda $e33 + sta $633 + lda $e34 + sta $634 + lda $e35 + sta $635 + lda $e36 + sta $636 + lda $e37 + sta $637 + + ; x=16,y=24 + lda $e38 + sta $638 + lda $e39 + sta $639 + lda $e3a + sta $63a + lda $e3b + sta $63b + lda $e3c + sta $63c + lda $e3d + sta $63d + lda $e3e + sta $63e + lda $e3f + sta $63f + + ; x=24,y=24 + lda $e40 + sta $640 + lda $e41 + sta $641 + lda $e42 + sta $642 + lda $e43 + sta $643 + lda $e44 + sta $644 + lda $e45 + sta $645 + lda $e46 + sta $646 + lda $e47 + sta $647 + + ; x=32,y=24 + lda $e48 + sta $648 + lda $e49 + sta $649 + lda $e4a + sta $64a + lda $e4b + sta $64b + lda $e4c + sta $64c + lda $e4d + sta $64d + lda $e4e + sta $64e + lda $e4f + sta $64f + +;= y = 26 $6a8 $ea8/$aa8 ========================= + ; x=0,y=26 + lda $ea8 + sta $6a8 + lda $ea9 + sta $6a9 + lda $eaa + sta $6aa + lda $eab + sta $6ab + lda $eac + sta $6ac + lda $ead + sta $6ad + lda $eae + sta $6ae + lda $eaf + sta $6af + + ; x=8,y=26 + lda $eb0 + sta $6b0 + lda $eb1 + sta $6b1 + lda $eb2 + sta $6b2 + lda $eb3 + sta $6b3 + lda $eb4 + sta $6b4 + lda $eb5 + sta $6b5 + lda $eb6 + sta $6b6 + lda $eb7 + sta $6b7 + + ; x=16,y=26 + lda $eb8 + sta $6b8 + lda $eb9 + sta $6b9 + lda $eba + sta $6ba + lda $ebb + sta $6bb + lda $ebc + sta $6bc + lda $ebd + sta $6bd + lda $ebe + sta $6be + lda $ebf + sta $6bf + + ; x=24,y=26 + lda $ec0 + sta $6c0 + lda $ec1 + sta $6c1 + lda $ec2 + sta $6c2 + lda $ec3 + sta $6c3 + lda $ec4 + sta $6c4 + lda $ec5 + sta $6c5 + lda $ec6 + sta $6c6 + lda $ec7 + sta $6c7 + + ; x=32,y=26 + lda $ec8 + sta $6c8 + lda $ec9 + sta $6c9 + lda $eca + sta $6ca + lda $ecb + sta $6cb + lda $ecc + sta $6cc + lda $ecd + sta $6cd + lda $ece + sta $6ce + lda $ecf + sta $6cf + +;= y = 28 $728 $f28/$b28 ========================= + ; x=0,y=28 + lda $f28 + sta $728 + lda $f29 + sta $729 + lda $f2a + sta $72a + lda $f2b + sta $72b + lda $f2c + sta $72c + lda $f2d + sta $72d + lda $f2e + sta $72e + lda $f2f + sta $72f + + ; x=8,y=28 + lda $f30 + sta $730 + lda $f31 + sta $731 + lda $f32 + sta $732 + lda $f33 + sta $733 + lda $f34 + sta $734 + lda $f35 + sta $735 + lda $f36 + sta $736 + lda $f37 + sta $737 + + ; x=16,y=28 + lda $f38 + sta $738 + lda $f39 + sta $739 + lda $f3a + sta $73a + lda $f3b + sta $73b + lda $f3c + sta $73c + lda $f3d + sta $73d + lda $f3e + sta $73e + lda $f3f + sta $73f + + ; x=24,y=28 + lda $f40 + sta $740 + lda $f41 + sta $741 + lda $f42 + sta $742 + lda $f43 + sta $743 + lda $f44 + sta $744 + lda $f45 + sta $745 + lda $f46 + sta $746 + lda $f47 + sta $747 + + ; x=32,y=28 + lda $f48 + sta $748 + lda $f49 + sta $749 + lda $f4a + sta $74a + lda $f4b + sta $74b + lda $f4c + sta $74c + lda $f4d + sta $74d + lda $f4e + sta $74e + lda $f4f + sta $74f + +;= y = 30 $7a8 $fa8/$ba8 ========================= + ; x=0,y=30 + lda $fa8 + sta $7a8 + lda $fa9 + sta $7a9 + lda $faa + sta $7aa + lda $fab + sta $7ab + lda $fac + sta $7ac + lda $fad + sta $7ad + lda $fae + sta $7ae + lda $faf + sta $7af + + ; x=8,y=30 + lda $fb0 + sta $7b0 + lda $fb1 + sta $7b1 + lda $fb2 + sta $7b2 + lda $fb3 + sta $7b3 + lda $fb4 + sta $7b4 + lda $fb5 + sta $7b5 + lda $fb6 + sta $7b6 + lda $fb7 + sta $7b7 + + ; x=16,y=30 + lda $fb8 + sta $7b8 + lda $fb9 + sta $7b9 + lda $fba + sta $7ba + lda $fbb + sta $7bb + lda $fbc + sta $7bc + lda $fbd + sta $7bd + lda $fbe + sta $7be + lda $fbf + sta $7bf + + ; x=24,y=30 + lda $fc0 + sta $7c0 + lda $fc1 + sta $7c1 + lda $fc2 + sta $7c2 + lda $fc3 + sta $7c3 + lda $fc4 + sta $7c4 + lda $fc5 + sta $7c5 + lda $fc6 + sta $7c6 + lda $fc7 + sta $7c7 + + ; x=32,y=30 + lda $fc8 + sta $7c8 + lda $fc9 + sta $7c9 + lda $fca + sta $7ca + lda $fcb + sta $7cb + lda $fcc + sta $7cc + lda $fcd + sta $7cd + lda $fce + sta $7ce + lda $fcf + sta $7cf + +;= y = 32 $450 $c50/$850 ========================= + ; x=0,y=32 + lda $c50 + sta $450 + lda $c51 + sta $451 + lda $c52 + sta $452 + lda $c53 + sta $453 + lda $c54 + sta $454 + lda $c55 + sta $455 + lda $c56 + sta $456 + lda $c57 + sta $457 + + ; x=8,y=32 + lda $c58 + sta $458 + lda $c59 + sta $459 + lda $c5a + sta $45a + lda $c5b + sta $45b + lda $c5c + sta $45c + lda $c5d + sta $45d + lda $c5e + sta $45e + lda $c5f + sta $45f + + ; x=16,y=32 + lda $c60 + sta $460 + lda $c61 + sta $461 + lda $c62 + sta $462 + lda $c63 + sta $463 + lda $c64 + sta $464 + lda $c65 + sta $465 + lda $c66 + sta $466 + lda $c67 + sta $467 + + ; x=24,y=32 + lda $c68 + sta $468 + lda $c69 + sta $469 + lda $c6a + sta $46a + lda $c6b + sta $46b + lda $c6c + sta $46c + lda $c6d + sta $46d + lda $c6e + sta $46e + lda $c6f + sta $46f + + ; x=32,y=32 + lda $c70 + sta $470 + lda $c71 + sta $471 + lda $c72 + sta $472 + lda $c73 + sta $473 + lda $c74 + sta $474 + lda $c75 + sta $475 + lda $c76 + sta $476 + lda $c77 + sta $477 + +;= y = 34 $4d0 $cd0/$8d0 ========================= + ; x=0,y=34 + lda $cd0 + sta $4d0 + lda $cd1 + sta $4d1 + lda $cd2 + sta $4d2 + lda $cd3 + sta $4d3 + lda $cd4 + sta $4d4 + lda $cd5 + sta $4d5 + lda $cd6 + sta $4d6 + lda $cd7 + sta $4d7 + + ; x=8,y=34 + lda $cd8 + sta $4d8 + lda $cd9 + sta $4d9 + lda $cda + sta $4da + lda $cdb + sta $4db + lda $cdc + sta $4dc + lda $cdd + sta $4dd + lda $cde + sta $4de + lda $cdf + sta $4df + + ; x=16,y=34 + lda $ce0 + sta $4e0 + lda $ce1 + sta $4e1 + lda $ce2 + sta $4e2 + lda $ce3 + sta $4e3 + lda $ce4 + sta $4e4 + lda $ce5 + sta $4e5 + lda $ce6 + sta $4e6 + lda $ce7 + sta $4e7 + + ; x=24,y=34 + lda $ce8 + sta $4e8 + lda $ce9 + sta $4e9 + lda $cea + sta $4ea + lda $ceb + sta $4eb + lda $cec + sta $4ec + lda $ced + sta $4ed + lda $cee + sta $4ee + lda $cef + sta $4ef + + ; x=32,y=34 + lda $cf0 + sta $4f0 + lda $cf1 + sta $4f1 + lda $cf2 + sta $4f2 + lda $cf3 + sta $4f3 + lda $cf4 + sta $4f4 + lda $cf5 + sta $4f5 + lda $cf6 + sta $4f6 + lda $cf7 + sta $4f7 + + rts ; 6 + diff --git a/fire/hello.bas b/fire/hello.bas new file mode 100644 index 00000000..77c3fc3d --- /dev/null +++ b/fire/hello.bas @@ -0,0 +1,4 @@ + 5 HOME + 10 PRINT "FIRE DEMO V1.0" + 40 PRINT:PRINT + 105 PRINT CHR$ (4)"BRUN FIRE" diff --git a/fire/vapor_lock.s b/fire/vapor_lock.s new file mode 100644 index 00000000..dfaf8247 --- /dev/null +++ b/fire/vapor_lock.s @@ -0,0 +1,238 @@ +; This took a while to track down +; On Apple II/II+ the horiz blanking addr are $1000 higher than on IIe +; So on II+ were outside video area, so unlikely to be our set value +; (unless I foolishly use $ff which some uninitialized mem is set to) +; Lots of this color fiddling is to make sure you don't accidentally +; get runs of colors on IIe due to the horiz blank + +; 0-5 aqua 6-12 = grey, 13 - 20 = yellow, 21-23 = aqua rainbow 14 +; +; +;16 0 YA +;17 1 YA +;18 2 YA +;19 3 YA +;20 4 YA +;21 5 AA +;22 6 AG +;23 7 AG +;0 8 AG +;1 9 AG +;2 10 AG +;3 11 AG +;4 12 AG +;5 13 AY **** +;6 14 GY RAINBOW +;7 15 GY +;8 16 GY +;9 17 GY +;10 18 GY +;11 19 GY +;12 20 GY +;13 21 YA +;14 22 YA +;15 23 YA + + + + ;============================== + ; setup graphics for vapor lock + ;============================== +vapor_lock: + + ; Clear Page0 + lda #$0 + sta DRAW_PAGE + lda #$ee ; full screen white $ff + jsr clear_gr + + lda #$dd + ldy #40 + jsr clear_page_loop ; make bottom half yellow $dd + + lda #$aa + ldy #24 + jsr clear_page_loop ; make middle grey2 $aa + + lda #$ee + ldy #10 + jsr clear_page_loop ; make top half aqua $ee + + ; set up a rainbow to aid in exact lock + + ldy #00 +rainbow_loop: + tya + sta $728+20,Y + iny + cpy #20 + bne rainbow_loop + +;btt: +; jmp btt + + + ;===================================================== + ; attempt vapor lock + ; by reading the "floating bus" we can see most recently + ; written value of the display + ;===================================================== + ; 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 a full line of $aa + + lda #$aa ; 2 +zxloop: + ldx #$04 ; 2 +wiloop: + cmp $C051 ; read the floating bus ; 4 + bne zxloop ; if not, start from scratch ; 2/3 + dex ; we were, dec ; 2 + bne wiloop ; if not 4 of them, restart ; 3/2 + + ; if we get here we read 4 proper pixels, 11 apart (2+4+2+2+3) + ; 0 11 22 33, clock at 34 + ; 1 12 23 34, clock at 35 + ; 2 13 24 35, clock at 36 + ; 3 14 25 36, clock at 37 + ; 4 15 26 37, clock at 38 + ; 5 16 27 38, clock at 39 + ; 6 17 28 39, clock at 40 + + +; 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 13*8 = 104 + + lda #$dd ; 2 +zloop: + ldx #$04 ; 2 +qloop: + cmp $C051 ; read floating bus ; 4 + bne zloop ; 2/3 + dex ; 2 + bne qloop ; 3/2 + ;============ + ; 11 + + ; Found it! + ; if we get here we read 4 proper pixels, 11 apart (2+4+2+2+3) + ; 0 11 22 33, clock at 34 + ; 1 12 23 34, clock at 35 + ; 2 13 24 35, clock at 36 + ; 3 14 25 36, clock at 37 + ; 4 15 26 37, clock at 38 + ; 5 16 27 38, clock at 39 + ; 6 17 28 39, clock at 40 + + + + +;btt: +; jmp btt + + ; In theory near end of line 104 + + ; now skip ahead 8 lines and read from the rainbow pattern we set + ; up to find our exact location + + ; delay 65 * 8 = 520 + ; we back off a few to make sure we're not in the horiz blank + ; try to delay 510 + + ; *NOTE* sometimes we end up going one (or rarely, two??) lines too far + ; so instead try going 7 lines ahead, and if still dd then one more + + ; so single step until we get a rainbow color + + ; go to next line, -10 + lda #28 ; 2 + jsr delay_a ; delay 25+28 = 53 + ; total delay = 55 + +vl_try_again: + lda #29 ; 2 + jsr delay_a ; delay 25+29 = 54 + ; total delay = 56 + + + + lda $C051 ; 4 + cmp #$dd ; 2 + beq vl_try_again ; 3 + ; -1 + + + ; now near end of line 112 + ;lda $0 ; nop to match old code ; 3 +; nop ; nop to match old code ; 2 + + lda $C051 ; 4 +;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 + + ; Our goal is line 114 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 + + + + + ; Some random related work + ; Docs: + ; Lancaster + ; Bishop + ; Sather + + ; Vaguely relevant but no help with the Apple II+ issue + ; + ; Eamon: Screen display and timing synchronization + ; on the Apple IIe and Apple IIgs + ; + ; Adams: Visually presented verbal stimuli by assembly + ; language on the Apple II computer. + ; Cavanagh and Anstis: Visual psychophysics on the + ; Apple II: Getting started