From 6265f0a75df1bc3eab1f078323760ceae19c1b88 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 31 Dec 2020 11:43:03 -0500 Subject: [PATCH] tfv: optimize sky drawing glitches a bit and wasn't critical path, but much cleaner --- tfv/Makefile | 3 +- tfv/flying_mode7.s | 99 ++++++++++++++++++++++++++-------------------- tfv/tfv_flying.s | 10 ++--- tfv/zp.inc | 4 +- 4 files changed, 65 insertions(+), 51 deletions(-) diff --git a/tfv/Makefile b/tfv/Makefile index 644b8e2a..be2f7fb8 100644 --- a/tfv/Makefile +++ b/tfv/Makefile @@ -50,7 +50,8 @@ TFV_FLYING: tfv_flying.o ld65 -o TFV_FLYING tfv_flying.o -C ../linker_scripts/apple2_2000.inc tfv_flying.o: tfv_flying.s \ - gr_hlin.s gr_putsprite.s \ + zp.inc \ + gr_putsprite.s \ tfv_help.s \ flying_mode7.s flying_sprites.inc ca65 -o tfv_flying.o tfv_flying.s -l tfv_flying.lst diff --git a/tfv/flying_mode7.s b/tfv/flying_mode7.s index fba66984..7ad59d30 100644 --- a/tfv/flying_mode7.s +++ b/tfv/flying_mode7.s @@ -7,50 +7,22 @@ ; 2da70 cycles (added in 2 cycle cpx) a00 = 2560, yes, 32*40=1280 ; 2aec3 cycles (update inner loop) = 175,811 = 5.7 fps + +; flying_loop -> check_done 2040 - 214f 2E +; +; check_done -> draw_background 214f - 219b 2E +; +; draw_background -> check_over_water 219b - 219e 298ad +; +; check_over_water -> no_splash 219e - 21d0 5b +; +; no_splash -> done_flying_loop 21d0 - 229b aa4 + + + + draw_background_mode7: - ; Only draw sky if necessary - ; (at start, or if we have switched to text, we never overwrite it) - - lda DRAW_SKY ; 3 - beq no_draw_sky ;^2nt/3 - ;============== - ; 6 - ; Draw Sky - ; not performance critical as this happens rarely - - dec DRAW_SKY ; usually 2 as we redraw both pages ; 5 - lda #COLOR_BOTH_MEDIUMBLUE ; MEDIUMBLUE color ; 2 - sta COLOR ; 3 - lda #0 ; 2 - ;=========== - ; 11 - -sky_loop: ; draw line across screen - ldy #39 ; from y=0 to y=6 ; 2 - sty V2 ; 3 - ldy #0 ; 2 - pha ; 3 - jsr hlin_double ; hlin y,V2 at A ; 63+(X*16) - pla ; 4 - clc ; 2 - adc #2 ; 2 - cmp #6 ; 2 - bne sky_loop ; 3/2nt - ;============= - ; (23+63+(X*16))*5 - ; Draw Hazy Horizon - -; lda #COLOR_BOTH_GREY ; Horizon is Grey ; 2 - lda #$56 ; Horizon is Grey ; 2 - sta COLOR ; 3 - lda #6 ; draw single line at 6/7 ; 2 - ldy #39 ; 2 - sty V2 ; hlin Y,V2 at A ; 3 - ldy #0 ; 2 - jsr hlin_double ; hlin 0,40 at 6 ; 63+(X*16) - ;=========== - ; 63+(X*16)+14 no_draw_sky: @@ -413,6 +385,7 @@ nomatch: ; 39 bcs ocean_color ; bge 8 ; 2nt/3 + ldy SPACEY_I ; 3 cpy #$8 ; 2 ;============= @@ -470,6 +443,7 @@ dxf_label: dxi_label: adc #0 ; self modifying, is DX_I ; 2 sta SPACEX_I ; 3 + ;========== ; 18 @@ -567,6 +541,47 @@ ocean_color_outline: update_cache_outline: rts ; 6 + + + ;====================================== + ; draw sky + ;====================================== + ; Only draw sky if necessary + ; (at start, or if we have switched to text, we never overwrite it) +draw_sky: + ; 6 + ; Draw Sky on both pages + ; lines 0..6 + + + lda #COLOR_BOTH_MEDIUMBLUE ; MEDIUMBLUE color ; 2 + ldx #39 + +sky_loop: ; draw line across screen + sta $400,X + sta $480,X + sta $500,X + sta $800,X + sta $880,X + sta $900,X + + dex + bpl sky_loop + + ; Draw Hazy Horizon + + lda #$56 ; Horizon is blue/grey ; 2 + ldx #39 +horizon_loop: ; draw line across screen + sta $580,X + sta $980,X + + dex + bpl horizon_loop + + rts + + ; 8.8 fixed point ; should we store as two arrays, one I one F? fixed_sin: diff --git a/tfv/tfv_flying.s b/tfv/tfv_flying.s index 81fabd2f..c2bee1de 100644 --- a/tfv/tfv_flying.s +++ b/tfv/tfv_flying.s @@ -59,8 +59,7 @@ flying: lda #1 ; slightly off North for better view of island sta ANGLE - lda #2 ; initialize sky both pages - sta DRAW_SKY + jsr draw_sky lda #4 ; starts out at 4.5 altitude sta SPACEZ_I @@ -304,8 +303,7 @@ check_help: jsr print_help - lda #2 - sta DRAW_SKY + jsr draw_sky check_done: @@ -576,7 +574,7 @@ draw_ship: ;================== ; loop forever ;================== - +done_flying_loop: jmp flying_loop ; 3 @@ -653,7 +651,7 @@ grass_string: ;=============================================== .include "gr_offsets.s" -.include "gr_hlin.s" +;.include "gr_hlin.s" .include "gr_pageflip.s" .include "gr_putsprite.s" .include "gr_fast_clear.s" diff --git a/tfv/zp.inc b/tfv/zp.inc index 0793786f..4d410bfb 100644 --- a/tfv/zp.inc +++ b/tfv/zp.inc @@ -63,8 +63,8 @@ NEGATE = $86 ; UNUSED? LAST_SPACEX_I = $87 LAST_SPACEY_I = $88 LAST_MAP_COLOR = $89 -DRAW_SKY = $8A -COLOR_MASK = $8B +COLOR_MASK = $8A + ;; World Map Only ODD = $7B