mode7_demo: initial scriptable flying

This commit is contained in:
Vince Weaver 2017-12-21 15:14:46 -05:00
parent 85a296347d
commit 31a4e2b107
5 changed files with 91 additions and 12 deletions

Binary file not shown.

View File

@ -0,0 +1,21 @@
;====================
; lookup_map
;====================
; finds value in space_x.i,space_y.i
; returns color in A
; CLOBBERS: A,Y
lda SPACEX_I ; 3
sta spacex_label+1 ; self modifying code, LAST_SPACEX_I ; 4
lda SPACEY_I ; 3
sta spacey_label+1 ; self modifying code, LAST_SPACEY_I ; 4
lda SPACEY_I
eor SPACEX_I
and #$1
beq @black
@white:
lda #$ff
@black:
sta map_color_label+1 ; self-modifying

View File

@ -0,0 +1,63 @@
;====================================
; do a full lookup, takes much longer
; used to be a separate function but we inlined it here
;====================
; lookup_map
;====================
; finds value in space_x.i,space_y.i
; returns color in A
; CLOBBERS: A,Y
lda SPACEX_I ; 3
sta spacex_label+1 ; self modifying code, LAST_SPACEX_I ; 4
and #CONST_MAP_MASK_X ; wrap at 64 ; 2
sta SPACEX_I ; store i patch out ; 3
tay ; copy to Y for later ; 2
lda SPACEY_I ; 3
sta spacey_label+1 ; self modifying code, LAST_SPACEY_I ; 4
and #CONST_MAP_MASK_Y ; wrap to 64x64 grid ; 2
sta SPACEY_I ; 3
asl ; 2
asl ; 2
asl ; multiply by 8 ; 2
clc ; 2
adc SPACEX_I ; add in X value ; 3
; only valid if x<8 and y<8
; SPACEX_I is also in y
cpy #$8 ; 2
;============
; 39
bcs @ocean_color ; bgt 8 ; 2nt/3
ldy SPACEY_I ; 3
cpy #$8 ; 2
;=============
; 7
bcs @ocean_color ; bgt 8 ; 2nt/3
tay ; 2
lda flying_map,Y ; load from array ; 4
bcc @update_cache ; 3
;============
; 11
@ocean_color:
and #$1f ; 2
tay ; 2
lda water_map,Y ; the color of the sea ; 4
;===========
; 8
@update_cache:
sta map_color_label+1 ; self-modifying ; 4
;===========
; 4
; rts ; 6

View File

@ -303,7 +303,7 @@ check_over_water:
lda CY_I ; 3
sta SPACEY_I ; 3
jsr lookup_map ; 6
jsr lookup_island_map ; 6
sec ; 2
sbc #COLOR_BOTH_DARKBLUE ; 2
@ -914,11 +914,8 @@ screenx_loop:
nomatch:
; Get color to draw in A
.if .def(ISLAND_MAP)
.include "island_lookup.s"
.elseif .def(CHECKERBOARD_MAP)
.include "checkerboard_lookup.s"
.endif
; .include "checkerboard_lookup.s"
match:
@ -1009,15 +1006,13 @@ done_screeny:
; CLOBBERS: A,Y
; this is used to check if above water or grass
; the high-performance per-pixel version has been inlined
lookup_map:
.if .def(ISLAND_MAP)
lookup_island_map:
.include "island_lookup.s"
.elseif .def(CHECKERBOARD_MAP)
rts ; 6
lookup_checkerboard_map:
.include "checkerboard_lookup.s"
.elseif .def(RAINBOW_MAP)
.include "rainbow_lookup.s"
.endif
rts ; 6

Binary file not shown.