diff --git a/gr-sim/tfv_flying.c b/gr-sim/tfv_flying.c index 01fe5fd2..489d1c32 100644 --- a/gr-sim/tfv_flying.c +++ b/gr-sim/tfv_flying.c @@ -41,6 +41,8 @@ static unsigned char water_map[32]={ static int displayed=0; +static int over_water=0; + static int lookup_map(int xx, int yy) { int color,offset; @@ -83,7 +85,7 @@ static int lookup_map(int xx, int yy) { } -static int over_water; + // current screen position static int screen_x, screen_y; @@ -348,9 +350,8 @@ void draw_background_mode7(void) { ram[COLOR]=map_color; ram[COLOR]|=map_color<<4; - if (screen_x==20) { + if ((screen_x==20) && (screen_y==38)) { if (map_color==COLOR_DARKBLUE) over_water=1; - else over_water=0; } hlin_double(ram[DRAW_PAGE], screen_x, screen_x+1, @@ -420,6 +421,8 @@ double our_cos(unsigned char angle) { // // + + void draw_background_mode7(void) { @@ -476,9 +479,8 @@ void draw_background_mode7(void) { color_equals(map_color); - if (screen_x==20) { + if ((screen_x==20) && (screen_y==38)) { if (map_color==COLOR_DARKBLUE) over_water=1; - else over_water=0; } plot(screen_x,screen_y); @@ -501,9 +503,11 @@ int flying(void) { unsigned char ch; int shipy; int turning=0; - int draw_splash=0; + int draw_splash=0,splash_count=0; int zint; + + /************************************************/ /* Flying */ /************************************************/ @@ -515,7 +519,7 @@ int flying(void) { shipy=20; while(1) { - if (draw_splash>0) draw_splash--; + if (splash_count>0) splash_count--; ch=grsim_input(); @@ -547,6 +551,7 @@ int flying(void) { space_z+=1; #endif } + splash_count=0; // printf("Z=%lf\n",space_z); } @@ -560,7 +565,7 @@ int flying(void) { #endif } else { - draw_splash=10; + splash_count=10; } // printf("Z=%lf\n",space_z); } @@ -665,9 +670,24 @@ int flying(void) { zint=space_z; #endif + draw_splash=0; + + + if (speed>0) { + + if ((shipy>25) && (turning!=0)) { + splash_count=1; + } + + if ((over_water) && (splash_count)) { + draw_splash=1; + } + } + +// printf("VMW: %d %d\n",draw_splash,splash_count); if (turning==0) { - if ((speed>0) && (over_water)&&(draw_splash)) { + if (draw_splash) { grsim_put_sprite(splash_forward, SHIPX+1,shipy+9); } @@ -676,9 +696,7 @@ int flying(void) { } if (turning<0) { - if ((shipy>25) && (speed>0.0)) draw_splash=1; - - if (over_water&&draw_splash) { + if (draw_splash) { grsim_put_sprite(splash_left, SHIPX+1,36); } @@ -688,10 +706,7 @@ int flying(void) { } if (turning>0) { - - if ((shipy>25) && (speed>0.0)) draw_splash=1; - - if (over_water&&draw_splash) { + if (draw_splash) { grsim_put_sprite(splash_right, SHIPX+1,36); } @@ -707,5 +722,3 @@ int flying(void) { } return 0; } - - diff --git a/tfv/tfv.dsk b/tfv/tfv.dsk index eaddac68..6dd3d296 100644 Binary files a/tfv/tfv.dsk and b/tfv/tfv.dsk differ diff --git a/tfv/tfv_flying.s b/tfv/tfv_flying.s index acc91ed4..11ddceb5 100644 --- a/tfv/tfv_flying.s +++ b/tfv/tfv_flying.s @@ -30,6 +30,8 @@ SPACEZ_I EQU $78 SPACEZ_F EQU $79 DRAW_SPLASH EQU $7A SPEED EQU $7B +SPLASH_COUNT EQU $7C +OVER_WATER EQU $7D ;=========== ; CONSTANTS @@ -68,6 +70,8 @@ flying_start: sta CY_F sta DRAW_SPLASH sta SPEED + sta SPLASH_COUNT + sta OVER_WATER lda #1 sta ANGLE @@ -79,9 +83,9 @@ flying_start: flying_loop: - lda DRAW_SPLASH + lda SPLASH_COUNT beq flying_keyboard - dec DRAW_SPLASH ; decrement splash count + dec SPLASH_COUNT ; decrement splash count flying_keyboard: @@ -109,6 +113,8 @@ skipskip: dec SHIPY dec SHIPY ; move ship up inc SPACEZ_I ; incement height + lda #0 + sta SPLASH_COUNT check_down: cmp #('M') @@ -120,10 +126,15 @@ check_down: lda SHIPY cmp #28 - bcs check_left ; ble, if shipy < 28 + bcs splashy ; ble, if shipy < 28 inc SHIPY inc SHIPY ; move ship down dec SPACEZ_I ; decrement height + bcc check_left + +splashy: + lda #10 + sta SPLASH_COUNT check_left: cmp #('J') @@ -289,6 +300,39 @@ speed_loop: draw_background: jsr draw_background_mode7 +; lda #1 +; sta OVER_WATER + + ; Calculate whether to draw the splash + + lda #0 ; set splash drawing to 0 + sta DRAW_SPLASH + + lda SPEED ; if speed==0, no splash + beq no_splash + + lda TURNING + beq no_turning_splash + + lda SHIPY + cmp #27 + bcc no_turning_splash ; blt if shipy<25 skip + + lda #1 + sta SPLASH_COUNT + +no_turning_splash: + lda OVER_WATER ; no splash if over land + beq no_splash + + lda SPLASH_COUNT ; no splash if splash_count expired + beq no_splash + + lda #1 + sta DRAW_SPLASH + +no_splash: + ;============== ; Draw the ship ;============== @@ -300,6 +344,23 @@ draw_background: bmi draw_ship_left ;; FIXME: optimize order draw_ship_forward: + lda DRAW_SPLASH + beq no_forward_splash + + ; Draw Splash + lda #>splash_forward + sta INH + lda #shadow_forward sta INH @@ -310,6 +371,7 @@ draw_ship_forward: clc lda SPACEZ_I adc #31 + and #$fe ; make sure it's even sta YPOS jsr put_sprite @@ -320,8 +382,21 @@ draw_ship_forward: bvc draw_ship draw_ship_right: + lda DRAW_SPLASH + beq no_right_splash - dec TURNING + ; Draw Splash + lda #>splash_right + sta INH + lda #shadow_right @@ -333,6 +408,7 @@ draw_ship_right: clc lda SPACEZ_I adc #31 + and #$fe ; make sure it's even sta YPOS jsr put_sprite @@ -340,11 +416,27 @@ draw_ship_right: sta INH lda #splash_left + sta INH + lda #shadow_left @@ -356,6 +448,7 @@ draw_ship_left: clc lda SPACEZ_I adc #31 + and #$fe ; make sure it's even sta YPOS jsr put_sprite @@ -364,6 +457,8 @@ draw_ship_left: lda #