; Lo-res cycle-counting water transparency hack ; by deater (Vince Weaver) ; Zero Page ;FRAMEBUFFER = $00 ; $00 - $0F ;YPOS = $10 YPOS_SIN = $11 BIRD_STATE = $E0 BIRD_DIR = $E1 OLD_XPOS = $F4 ; location we don't care about DUMMY = $300 waterfall: ;=================== ; init screen jsr TEXT jsr HOME bit PAGE0 ;=================== ; init vars lda #0 sta BIRD_DIR sta BIRD_STATE sta FRAME sta OLD_XPOS lda #4 sta DRAW_PAGE sta XPOS ;============================= ; Load foreground to graphic page1 (apple page2) lda #$0c sta BASH lda #$00 sta BASL ; load image to $c00 lda #waterfall_page1 sta GBASH jsr load_rle_gr jsr gr_copy_to_current ; copy to page1 ;============================= ; Load bg to memory lda #$0c sta BASH lda #$00 sta BASL ; load image to $c00 lda #waterfall_page2 sta GBASH jsr load_rle_gr ;============================== ; 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 jmp wf_display_loop wf_jump_table: .word (display_even-1) .word (display_odd-1) .word (display_three-1) .word (display_four-1) .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 ; jump_table ; 38 + display_odd ; we have 3 (the jmp back) ; = 3 cycles that need to be eaten by the vblank wf_display_loop: inc FRAME ; 5 lda FRAME ; 3 and #$30 ; 2 ; 0011 0000, so more or less div by 16, 3.75Hz lsr ; 2 lsr ; 2 lsr ; 2 tay ; 2 ; 18 lda wf_jump_table+1,y ; 4 pha ; 3 lda wf_jump_table,y ; 4 pha ; 3 rts ; 6 ; 38 wf_display_loop_return: vblank: ;====================================================== ; We have 4550 cycles in the vblank, use them wisely ;====================================================== ; do_nothing should be 4550 ; -3 letfover from HBLANK code ; ** -9 ; -49 check for keypress ; -2252 copy screen ; -2231 draw sprite ; ============= ; 15 cycles ; 15 cycles inc YPOS ; 5 nop ; 2 nop ; 2 lda YPOS ; 3 lda YPOS ; 3 ;========================= ; Clear background ;========================= jsr gr_copy_row22 ; 6+ 2246 ;========= ; 2252 ;========================== ; draw bird sprite ;========================== ; 8 prefix ; bird_walk_right= 14 + 2175 2206 (need 17) ; bird_stand_right= 13 + 2190 2206 (need 3) ; bird_walk_left= 15 + 2175 2206 (need 16) ; bird_stand_left= 14 + 2190 2206 (need 2) ; call to sprite 17 postfix ;==================================================== ; 2231 lda BIRD_STATE ; 3 and #1 ; 2 ldx BIRD_DIR ; 3 bne bird_left bird_right: ; 2 cmp #1 ; 2 beq bird_walk_right ; 2 bird_stand_right: ldx #>bird_rider_stand_right ; 2 ldy #bird_rider_walk_right ; 2 ldy #bird_rider_stand_left ; 2 ldy #bird_rider_walk_left ; 2 ldy #