From 29eea6a6279d29598b5495dfb4eaa5e42e8298c1 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 12 Dec 2017 14:29:39 -0500 Subject: [PATCH] mode7: paramaterize the map --- mode7/Makefile | 3 +- mode7/island_lookup.s | 63 ++++++++++++++++++++ mode7/island_map.inc | 16 +++++ mode7/mode7.dsk | Bin 143360 -> 143360 bytes mode7/mode7.s | 134 +++--------------------------------------- 5 files changed, 88 insertions(+), 128 deletions(-) create mode 100644 mode7/island_lookup.s create mode 100644 mode7/island_map.inc diff --git a/mode7/Makefile b/mode7/Makefile index 79ea978a..9917cab7 100644 --- a/mode7/Makefile +++ b/mode7/Makefile @@ -18,8 +18,7 @@ MODE7: mode7.o ld65 -o MODE7 mode7.o -C ./apple2_1000.inc mode7.o: mode7.s \ - flying.s fast_multiply.s \ - utils.s zp.inc sprites.inc + fast_multiply.s utils.s zp.inc sprites.inc ca65 -o mode7.o mode7.s -l mode7.lst clean: diff --git a/mode7/island_lookup.s b/mode7/island_lookup.s new file mode 100644 index 00000000..01d4df67 --- /dev/null +++ b/mode7/island_lookup.s @@ -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 diff --git a/mode7/island_map.inc b/mode7/island_map.inc new file mode 100644 index 00000000..3a42dcf2 --- /dev/null +++ b/mode7/island_map.inc @@ -0,0 +1,16 @@ +flying_map: + .byte $22,$ff,$ff,$ff, $ff,$ff,$ff,$22 + .byte $dd,$cc,$cc,$88, $44,$44,$00,$dd + .byte $dd,$cc,$cc,$cc, $88,$44,$44,$dd + .byte $dd,$cc,$cc,$88, $44,$44,$44,$dd + .byte $dd,$cc,$99,$99, $88,$44,$44,$dd + .byte $dd,$cc,$99,$88, $44,$44,$44,$dd + .byte $dd,$cc,$99,$99, $11,$44,$44,$dd + .byte $22,$dd,$dd,$dd, $dd,$dd,$dd,$22 + + +water_map: + .byte $22,$22,$22,$22, $22,$22,$22,$22 + .byte $ee,$22,$22,$22, $22,$22,$22,$22 + .byte $22,$22,$22,$22, $22,$22,$22,$22 + .byte $22,$22,$22,$22, $ee,$22,$22,$22 diff --git a/mode7/mode7.dsk b/mode7/mode7.dsk index 8e1df707f629b69cb43171a382347b0ae2d2acce..e9ea42bcbbcb3b65d47473913ca73d42e1f3630a 100644 GIT binary patch delta 920 zcmaKpZAep57{~9O^WAdkeK|{Q*IMQkS22=Q2n!+z_F?uRB>Hg64cx3S1GS7c(IZhD z(@wA;0)wu2djTad76?ip%lcpuMISN)H>6;=7n9g#oxA2sV10S+Ilt%sf1c+&*FBfz zp353Z4`s@XFv|$JxU{DPi=kpogu(Sk3-PH?&)yF(t`xuskUJa(aRo*NC#!HUp#%xf zhY@)`iG&x-REN-BfDMq-XgSY76Nu; za+bwX>#htNs~oY|@aZ2rayofnkH8i0RUVJFnl+Ow{$kb_sMH9{3AG2IC<$*_th;2a z@w3UEezpk)rJmTZSJlOmdsc;eBtg$r%O-#9(ZV1l?;j`&lugh4BorTBt|R}&z0A?3 zXP)IQdTS9_xKH)Xd<*UbK?Zn6^XLlKb%6Q+dJ51OIQ|RW1ZV)D5rDivcA>ifJpgDz zP22Pt|!$Ep4Vbq7s@)E#{UDfA8ub*;iTt8ivb_Za|%a!{~489kLI S`aRa=G<0iY&$Tf+e&9D{`jra+ delta 921 zcmaKoT}V@57{||@3ZyaA9WwHiq(5t2DlGB?sRMb)No$;*thMKy0<^joT>7)-sY7ZAnWq z&qfh(F@abwJ=w~(Xs{k>RWZihTS4aM(z(bM@X66G))})ihn4Fc1-O5#lPta;zUmy1 zt58byMSI5n>i_9l-7G#>qZ2cXB;69XH`nX|^XlYzX%wI2t4+IJzv4YFx8865{txqI z6kq25`YvvX6p~f=O;?_Z(_-&AhUD<)h(67sLq!3f1BW7dQx$YIqZY9a?CFW`M*+13 zd~$RFE9Y#=UcjzCAcv_M{e?ZbSdW}y1A15~+rZk08XjA3qx$4h_sQid)t^@hH?p937wLFOjf@h33~WuDm(L*EsAapf zGELs_nZOCWu%45(Nte`)Q>l{2Z0Xx5K5AjOFjcV}7Q@DrwG{JB2J?>NX%~zKAiRemSEZlm-Xi+^M9&uSOqhV=Tlfk|GzCL#JMhB}{J5)|0gwngfjSb=T~bQU QU@Eh=LmeAa$H@5E-?k=}Jpcdz diff --git a/mode7/mode7.s b/mode7/mode7.s index 0beb11e1..e76ce710 100644 --- a/mode7/mode7.s +++ b/mode7/mode7.s @@ -29,6 +29,7 @@ CONST_LOWRES_HALF_F EQU $00 jsr clear_screens ; clear top/bottom of page 0/1 jsr set_gr_page0 + ; Initialize the 2kB of multiply lookup tables jsr init_multiply_tables ;=============== @@ -50,13 +51,13 @@ CONST_LOWRES_HALF_F EQU $00 sta SPLASH_COUNT sta DISP_PAGE - lda #1 + lda #1 ; slightly off North for better view of island sta ANGLE lda #2 ; initialize sky both pages sta DRAW_SKY - lda #4 ; starts out at 4.5 + lda #4 ; starts out at 4.5 altitude sta SPACEZ_I lda #$80 sta SPACEZ_F @@ -961,74 +962,9 @@ screenx_loop: nomatch: - ;==================================== - ; do a full lookup, takes much longer - ; used to be a separate function but we inlined it here + ; Get color to draw in A + .include "island_lookup.s" - ;==================== - ; 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 - - - -; jsr lookup_map ; get color in A ; 6 -; ;============ - ; 6 match: mask_label: @@ -1119,49 +1055,9 @@ done_screeny: ; this is used to check if above water or grass ; the high-performance per-pixel version has been inlined lookup_map: - lda SPACEX_I ; 3 - and #CONST_MAP_MASK_X ; 2 - sta SPACEX_I ; 3 - tay ; 2 - - lda SPACEY_I ; 3 - 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 in y - cpy #$8 ; 2 - ;============ - ; 31 - - bcs ocean_color_outline ; bgt 8 ;^2nt/3 - ldy SPACEY_I ; 3 - cpy #$8 ; 2 - bcs ocean_color_outline ; bgt 8 ; 2nt/3 - - tay ; 2 - lda flying_map,Y ; load from array ; 4 - - bcc update_cache_outline ; 3 - -ocean_color_outline: - and #$1f ; 2 - tay ; 2 - lda water_map,Y ; the color of the sea ; 4 - -update_cache_outline: + .include "island_lookup.s" rts ; 6 - - - - ;===================== ; All finished ;===================== @@ -1178,6 +1074,7 @@ exit: ; Return to BASIC? + ; This most likely won't work, should probably reboot rts @@ -1201,22 +1098,7 @@ gr_offsets: .word $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8 .word $450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0 -flying_map: - .byte $22,$ff,$ff,$ff, $ff,$ff,$ff,$22 - .byte $dd,$cc,$cc,$88, $44,$44,$00,$dd - .byte $dd,$cc,$cc,$cc, $88,$44,$44,$dd - .byte $dd,$cc,$cc,$88, $44,$44,$44,$dd - .byte $dd,$cc,$99,$99, $88,$44,$44,$dd - .byte $dd,$cc,$99,$88, $44,$44,$44,$dd - .byte $dd,$cc,$99,$99, $11,$44,$44,$dd - .byte $22,$dd,$dd,$dd, $dd,$dd,$dd,$22 - - -water_map: - .byte $22,$22,$22,$22, $22,$22,$22,$22 - .byte $ee,$22,$22,$22, $22,$22,$22,$22 - .byte $22,$22,$22,$22, $22,$22,$22,$22 - .byte $22,$22,$22,$22, $ee,$22,$22,$22 +.include "island_map.inc" .include "fast_multiply.s"