From 36bab516c65976c606ba00ec24cce49de084e20f Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 27 Aug 2017 00:11:53 -0400 Subject: [PATCH] tfv: more work on flying code --- gr-sim/tfv_flying.c | 23 +++++++++----- tfv/tfv_flying.s | 77 ++++++++++++++++++++++++++++++++++++++++++--- tfv/tfv_utils.s | 2 +- 3 files changed, 89 insertions(+), 13 deletions(-) diff --git a/gr-sim/tfv_flying.c b/gr-sim/tfv_flying.c index fa082341..2b874d83 100644 --- a/gr-sim/tfv_flying.c +++ b/gr-sim/tfv_flying.c @@ -24,6 +24,13 @@ static unsigned char flying_map[64]= { 13,12, 9, 9, 1, 4, 4,13, 2,13,13,13, 13,13,13, 2}; +static unsigned char water_map[32]={ + 2,2,2,2, 2,2,2,2, + 14,2,2,2, 2,2,2,2, + 2, 2,2,2, 2,2,2,2, + 2,2,2,2, 14,2,2,2, +}; + #define TILE_W 64 #define TILE_H 64 #define MASK_X (TILE_W - 1) @@ -43,19 +50,21 @@ static int lookup_map(int x, int y) { x=x&MASK_X; y=y&MASK_Y; - if ( ((y&0x3)==1) && ((x&7)==0) ) color=14; - if ( ((y&0x3)==3) && ((x&7)==4) ) color=14; +// if ( ((y&0x3)==1) && ((x&7)==0) ) color=14; +// if ( ((y&0x3)==3) && ((x&7)==4) ) color=14; + color=water_map[((y*8)+x)&0x1f]; + + + /* 2 2 2 2 2 2 2 2 */ + /* e 2 2 2 2 2 2 2 */ + /* 2 2 2 2 2 2 2 2 */ + /* 2 2 2 2 e 2 2 2 */ if ((y<8) && (x<8)) { color=flying_map[(y*8)+x]; } - /* 2 2 2 2 2 2 2 2 */ - /* 14 14 2 2 2 2 2 2 */ - /* 2 2 2 2 14 14 2 2 */ - /* 2 2 2 2 2 2 2 2 */ - return color; } diff --git a/tfv/tfv_flying.s b/tfv/tfv_flying.s index a38da58e..d71ce23c 100644 --- a/tfv/tfv_flying.s +++ b/tfv/tfv_flying.s @@ -1,12 +1,45 @@ SHIPY EQU $E4 ; FIXME, sort out available ZP page space -TURNING EQU $40 -SCREEN_X EQU $41 -SCREEN_Y EQU $42 +TURNING EQU $60 +SCREEN_X EQU $61 +SCREEN_Y EQU $62 +ANGLE EQU $63 +HORIZ_SCALE_I EQU $64 +HORIZ_SCALE_F EQU $65 +FACTOR_I EQU $66 +FACTOR_F EQU $67 +DX_I EQU $68 +DX_F EQU $69 +SPACEX_I EQU $6A +SPACEX_F EQU $6B +CX_I EQU $6C +CX_F EQU $6D +DY_I EQU $6E +DY_F EQU $6F +SPACEY_I EQU $70 +SPACEY_F EQU $71 +CY_I EQU $72 +CY_F EQU $73 +TEMP_I EQU $74 +TEMP_F EQU $75 +DISTANCE_I EQU $76 +DISTANCE_F EQU $77 +SPACEZ_I EQU $78 +SPACEZ_F EQU $79 +;=========== +; CONSTANTS +;=========== SHIPX EQU 15 +TILE_W EQU 64 +TILE_H EQU 64 +MAP_MASK EQU (TILE_W - 1) +LOWRES_W EQU 40 +LOWRES_H EQU 40 + + flying_start: @@ -19,6 +52,8 @@ flying_start: sta SHIPY lda #0 sta TURNING + sta SPACEX_I + sta SPACEY_I flying_loop: @@ -191,9 +226,34 @@ screenx_loop: ; finds value in space_x.i,space_y.i ; returns color in A lookup_map: - lda #COLOR_BOTH_DARKBLUE ; the color of the sea + lda SPACEX_I + and #MAP_MASK + sta TEMPY - + lda SPACEY_I + and #MAP_MASK + lsr + lsr + lsr ; multiply by 8 + clc + adc TEMPY ; add in X value + + ldy SPACEX_I + cpy #$8 + bcc ocean_color ; bgt + ldy SPACEY_I + cpy #$8 + bcc ocean_color ; bgt + + tay + lda flying_map,Y ; load from array + + rts + +ocean_color: + and #$1f + tay + lda water_map,Y ; the color of the sea rts @@ -208,6 +268,13 @@ flying_map: .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 + + ; http://www.llx.com/~nparker/a2/mult.html ; MULTIPLY NUM1H:NUM1L * NUM2H:NUM2L diff --git a/tfv/tfv_utils.s b/tfv/tfv_utils.s index deaaa59f..f32ebe62 100644 --- a/tfv/tfv_utils.s +++ b/tfv/tfv_utils.s @@ -481,7 +481,7 @@ vlin_too_slow: ; hlin_setup ;================================ ; put address in GBASL/GBASH - ; Ycoord in A, X coord inY + ; Ycoord in A, Xcoord in Y hlin_setup: sty TEMPY tay ; y=A