2020-12-30 06:41:14 +00:00
|
|
|
; Mode-7 Flying code
|
|
|
|
|
|
|
|
.include "zp.inc"
|
|
|
|
.include "hardware.inc"
|
|
|
|
.include "common_defines.inc"
|
|
|
|
|
|
|
|
|
2017-08-27 04:11:53 +00:00
|
|
|
;===========
|
|
|
|
; CONSTANTS
|
|
|
|
;===========
|
2020-09-28 02:03:01 +00:00
|
|
|
CONST_SHIPX = 15
|
|
|
|
CONST_TILE_W = 64
|
|
|
|
CONST_TILE_H = 64
|
|
|
|
CONST_MAP_MASK_X = (CONST_TILE_W - 1)
|
|
|
|
CONST_MAP_MASK_Y = (CONST_TILE_H - 1)
|
|
|
|
CONST_LOWRES_W = 40
|
|
|
|
CONST_LOWRES_H = 40
|
|
|
|
CONST_BETA_I = $ff
|
|
|
|
CONST_BETA_F = $80
|
|
|
|
CONST_SCALE_I = $14
|
|
|
|
CONST_SCALE_F = $00
|
|
|
|
CONST_LOWRES_HALF_I = $ec ; -(LOWRES_W/2)
|
|
|
|
CONST_LOWRES_HALF_F = $00
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2020-12-30 06:41:14 +00:00
|
|
|
flying:
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
;===================
|
2017-08-23 19:41:37 +00:00
|
|
|
; Clear screen/pages
|
2017-09-11 19:09:51 +00:00
|
|
|
;===================
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2020-12-30 06:41:14 +00:00
|
|
|
bit PAGE0
|
2021-01-14 06:28:18 +00:00
|
|
|
bit LORES ; Lo-res graphics
|
|
|
|
bit TEXTGR ; mixed gr/text mode
|
|
|
|
bit SET_GR ; set graphics
|
|
|
|
|
|
|
|
|
|
|
|
jsr clear_screens
|
2020-12-30 06:41:14 +00:00
|
|
|
lda #0
|
|
|
|
sta DISP_PAGE
|
|
|
|
lda #4
|
|
|
|
sta DRAW_PAGE
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2017-12-14 17:44:27 +00:00
|
|
|
; Initialize the 2kB of multiply lookup tables
|
2017-11-26 00:37:02 +00:00
|
|
|
jsr init_multiply_tables
|
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
;===============
|
2017-08-23 19:41:37 +00:00
|
|
|
; Init Variables
|
2017-09-11 19:09:51 +00:00
|
|
|
;===============
|
2017-08-23 19:41:37 +00:00
|
|
|
lda #20
|
|
|
|
sta SHIPY
|
|
|
|
lda #0
|
|
|
|
sta TURNING
|
2017-09-07 05:32:31 +00:00
|
|
|
sta ANGLE
|
2017-08-27 04:11:53 +00:00
|
|
|
sta SPACEX_I
|
|
|
|
sta SPACEY_I
|
2017-09-11 03:42:47 +00:00
|
|
|
sta CX_I
|
|
|
|
sta CX_F
|
|
|
|
sta CY_I
|
|
|
|
sta CY_F
|
2017-09-11 19:09:51 +00:00
|
|
|
sta DRAW_SPLASH
|
|
|
|
sta SPEED
|
2017-10-09 19:36:25 +00:00
|
|
|
sta SPLASH_COUNT
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-12-14 17:44:27 +00:00
|
|
|
lda #1 ; slightly off North for better view of island
|
2017-09-11 20:15:13 +00:00
|
|
|
sta ANGLE
|
|
|
|
|
2020-12-31 16:43:03 +00:00
|
|
|
jsr draw_sky
|
2017-11-26 05:10:58 +00:00
|
|
|
|
2017-12-14 17:44:27 +00:00
|
|
|
lda #4 ; starts out at 4.5 altitude
|
2017-09-07 03:17:39 +00:00
|
|
|
sta SPACEZ_I
|
|
|
|
lda #$80
|
|
|
|
sta SPACEZ_F
|
|
|
|
|
2017-11-30 05:13:23 +00:00
|
|
|
jsr update_z_factor
|
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
flying_loop:
|
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda SPLASH_COUNT ; 3
|
|
|
|
beq flying_keyboard ; 2nt/3
|
|
|
|
dec SPLASH_COUNT ; decrement splash count ; 5
|
2017-09-11 19:09:51 +00:00
|
|
|
|
|
|
|
flying_keyboard:
|
|
|
|
|
2020-12-30 06:41:14 +00:00
|
|
|
jsr get_keypress ; get keypress ; 6
|
2020-12-30 23:47:00 +00:00
|
|
|
cmp #0
|
2020-12-30 07:12:17 +00:00
|
|
|
bne key_was_pressed
|
2017-09-11 19:09:51 +00:00
|
|
|
|
2020-12-30 07:12:17 +00:00
|
|
|
jmp check_done
|
|
|
|
|
|
|
|
key_was_pressed:
|
|
|
|
|
|
|
|
; lda LASTKEY ; 3
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2017-11-17 21:54:29 +00:00
|
|
|
; cmp #('Q') ; if quit, then return
|
|
|
|
; bne skipskip
|
|
|
|
; rts
|
2017-09-11 19:09:51 +00:00
|
|
|
|
2017-11-17 21:54:29 +00:00
|
|
|
;skipskip:
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2020-12-30 23:47:00 +00:00
|
|
|
cmp #'W' ; 2
|
2020-12-30 06:41:14 +00:00
|
|
|
bne flying_check_down ; 3/2nt
|
2017-09-11 18:48:35 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
;===========
|
2017-09-11 18:48:35 +00:00
|
|
|
; UP PRESSED
|
2017-09-11 19:09:51 +00:00
|
|
|
;===========
|
2017-09-11 18:48:35 +00:00
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
lda SHIPY
|
2017-09-11 18:48:35 +00:00
|
|
|
cmp #17
|
2020-12-30 06:41:14 +00:00
|
|
|
bcc flying_check_down ; bgt, if shipy>16
|
2017-08-23 19:41:37 +00:00
|
|
|
dec SHIPY
|
2017-09-11 19:09:51 +00:00
|
|
|
dec SHIPY ; move ship up
|
|
|
|
inc SPACEZ_I ; incement height
|
2017-11-30 05:13:23 +00:00
|
|
|
jsr update_z_factor
|
2017-10-09 19:36:25 +00:00
|
|
|
lda #0
|
|
|
|
sta SPLASH_COUNT
|
2020-12-30 07:12:17 +00:00
|
|
|
jmp check_done
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2020-12-30 06:41:14 +00:00
|
|
|
flying_check_down:
|
2020-12-30 23:47:00 +00:00
|
|
|
cmp #'S'
|
2020-12-30 06:41:14 +00:00
|
|
|
bne flying_check_left
|
2017-09-11 18:48:35 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
;=============
|
2017-09-11 18:48:35 +00:00
|
|
|
; DOWN PRESSED
|
2017-09-11 19:09:51 +00:00
|
|
|
;=============
|
2017-09-11 18:48:35 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
lda SHIPY
|
2017-08-23 19:41:37 +00:00
|
|
|
cmp #28
|
2017-10-09 19:36:25 +00:00
|
|
|
bcs splashy ; ble, if shipy < 28
|
2017-08-23 19:41:37 +00:00
|
|
|
inc SHIPY
|
2017-09-11 19:09:51 +00:00
|
|
|
inc SHIPY ; move ship down
|
|
|
|
dec SPACEZ_I ; decrement height
|
2017-11-30 05:13:23 +00:00
|
|
|
jsr update_z_factor
|
2020-12-30 07:12:17 +00:00
|
|
|
bcc done_flying_down
|
2017-10-09 19:36:25 +00:00
|
|
|
|
|
|
|
splashy:
|
|
|
|
lda #10
|
|
|
|
sta SPLASH_COUNT
|
2020-12-30 07:12:17 +00:00
|
|
|
done_flying_down:
|
|
|
|
jmp check_done
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2020-12-30 06:41:14 +00:00
|
|
|
flying_check_left:
|
2020-12-30 23:47:00 +00:00
|
|
|
cmp #'A'
|
2020-12-30 06:41:14 +00:00
|
|
|
bne flying_check_right
|
2017-09-11 18:48:35 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
;=============
|
2017-09-11 18:48:35 +00:00
|
|
|
; LEFT PRESSED
|
2017-09-11 19:09:51 +00:00
|
|
|
;=============
|
2017-09-11 18:48:35 +00:00
|
|
|
|
2017-09-11 19:58:23 +00:00
|
|
|
lda TURNING
|
|
|
|
bmi turn_left
|
|
|
|
beq turn_left
|
|
|
|
|
|
|
|
lda #$0
|
|
|
|
sta TURNING
|
2020-12-30 07:12:17 +00:00
|
|
|
jmp check_done
|
2017-09-11 19:58:23 +00:00
|
|
|
|
|
|
|
turn_left:
|
|
|
|
lda #253 ; -3
|
|
|
|
sta TURNING
|
|
|
|
|
2017-09-11 03:42:47 +00:00
|
|
|
dec ANGLE
|
2020-12-30 07:12:17 +00:00
|
|
|
jmp check_done
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2020-12-30 06:41:14 +00:00
|
|
|
flying_check_right:
|
2020-12-30 23:47:00 +00:00
|
|
|
cmp #'D'
|
2017-09-11 19:09:51 +00:00
|
|
|
bne check_speedup
|
2017-09-11 18:48:35 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
;==============
|
2017-09-11 18:48:35 +00:00
|
|
|
; RIGHT PRESSED
|
2017-09-11 19:09:51 +00:00
|
|
|
;==============
|
2017-09-11 18:48:35 +00:00
|
|
|
|
2017-09-11 19:58:23 +00:00
|
|
|
lda TURNING ;; FIXME: optimize me
|
|
|
|
bpl turn_right
|
|
|
|
lda #0
|
|
|
|
sta TURNING
|
2020-12-30 07:12:17 +00:00
|
|
|
jmp check_done
|
2017-09-11 19:58:23 +00:00
|
|
|
|
|
|
|
turn_right:
|
|
|
|
lda #3
|
|
|
|
sta TURNING
|
|
|
|
|
2017-09-11 03:42:47 +00:00
|
|
|
inc ANGLE
|
2020-12-30 07:12:17 +00:00
|
|
|
jmp check_done
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
check_speedup:
|
2020-12-30 23:47:00 +00:00
|
|
|
cmp #'Z'
|
2017-09-11 19:09:51 +00:00
|
|
|
bne check_speeddown
|
|
|
|
|
|
|
|
;=========
|
|
|
|
; SPEED UP
|
|
|
|
;=========
|
2017-11-26 23:27:58 +00:00
|
|
|
lda #$8
|
2017-09-11 19:09:51 +00:00
|
|
|
cmp SPEED
|
2020-12-30 07:12:17 +00:00
|
|
|
beq skip_speedup
|
2017-09-11 19:09:51 +00:00
|
|
|
inc SPEED
|
2020-12-30 07:12:17 +00:00
|
|
|
skip_speedup:
|
|
|
|
jmp check_done
|
2017-09-11 19:09:51 +00:00
|
|
|
|
|
|
|
check_speeddown:
|
2020-12-30 23:47:00 +00:00
|
|
|
cmp #'X'
|
2017-09-11 19:28:56 +00:00
|
|
|
bne check_brake
|
2017-09-11 19:09:51 +00:00
|
|
|
|
|
|
|
;===========
|
|
|
|
; SPEED DOWN
|
|
|
|
;===========
|
|
|
|
|
|
|
|
lda SPEED
|
2020-12-30 07:12:17 +00:00
|
|
|
beq skip_speeddown
|
2017-09-11 19:09:51 +00:00
|
|
|
dec SPEED
|
2020-12-30 07:12:17 +00:00
|
|
|
skip_speeddown:
|
|
|
|
jmp check_done
|
2017-09-11 19:09:51 +00:00
|
|
|
|
2017-09-11 19:28:56 +00:00
|
|
|
check_brake:
|
2020-12-30 23:47:00 +00:00
|
|
|
cmp #' '
|
2017-09-11 19:09:51 +00:00
|
|
|
bne check_land
|
|
|
|
|
|
|
|
;============
|
2017-09-11 19:28:56 +00:00
|
|
|
; BRAKE
|
2017-09-11 19:09:51 +00:00
|
|
|
;============
|
|
|
|
lda #$0
|
|
|
|
sta SPEED
|
2020-12-30 07:12:17 +00:00
|
|
|
jmp check_done
|
2017-09-11 19:09:51 +00:00
|
|
|
|
|
|
|
check_land:
|
|
|
|
cmp #13
|
|
|
|
bne check_help
|
|
|
|
|
|
|
|
;=====
|
|
|
|
; LAND
|
|
|
|
;=====
|
|
|
|
|
2017-11-17 21:54:29 +00:00
|
|
|
; finds value in space_x.i,space_y.i
|
|
|
|
; returns color in A
|
|
|
|
lda CX_I
|
|
|
|
sta SPACEX_I
|
|
|
|
lda CY_I
|
|
|
|
sta SPACEY_I
|
|
|
|
|
|
|
|
jsr lookup_map
|
|
|
|
|
|
|
|
cmp #COLOR_BOTH_LIGHTGREEN
|
2017-11-18 19:31:03 +00:00
|
|
|
bne must_land_on_grass
|
2017-11-17 21:54:29 +00:00
|
|
|
|
|
|
|
landing_loop:
|
|
|
|
|
|
|
|
jsr draw_background_mode7
|
|
|
|
|
|
|
|
; Draw Shadow
|
|
|
|
lda #>shadow_forward
|
|
|
|
sta INH
|
|
|
|
lda #<shadow_forward
|
|
|
|
sta INL
|
2017-11-24 19:01:47 +00:00
|
|
|
lda #(CONST_SHIPX+3)
|
2017-11-17 21:54:29 +00:00
|
|
|
sta XPOS
|
|
|
|
clc
|
|
|
|
lda SPACEZ_I
|
|
|
|
adc #31
|
|
|
|
and #$fe ; make sure it's even
|
|
|
|
sta YPOS
|
|
|
|
jsr put_sprite
|
|
|
|
|
|
|
|
lda #>ship_forward
|
|
|
|
sta INH
|
|
|
|
lda #<ship_forward
|
|
|
|
sta INL
|
|
|
|
|
2017-11-24 19:01:47 +00:00
|
|
|
lda #CONST_SHIPX
|
2017-11-17 21:54:29 +00:00
|
|
|
sta XPOS
|
|
|
|
lda SHIPY
|
|
|
|
sta YPOS
|
|
|
|
jsr put_sprite
|
|
|
|
|
|
|
|
jsr page_flip
|
|
|
|
|
|
|
|
dec SPACEZ_I
|
2017-11-30 05:13:23 +00:00
|
|
|
jsr update_z_factor
|
|
|
|
lda SPACEZ_I
|
|
|
|
|
2017-11-17 21:54:29 +00:00
|
|
|
bpl landing_loop
|
|
|
|
|
2020-12-30 07:12:17 +00:00
|
|
|
done_flying:
|
|
|
|
lda #LOAD_WORLD
|
|
|
|
sta WHICH_LOAD
|
2017-11-17 21:54:29 +00:00
|
|
|
|
|
|
|
rts ; finish flying
|
|
|
|
|
2017-11-18 19:31:03 +00:00
|
|
|
must_land_on_grass:
|
2017-11-27 03:05:52 +00:00
|
|
|
lda #<(grass_string)
|
|
|
|
sta OUTL
|
2020-12-31 17:41:46 +00:00
|
|
|
lda #>(grass_string)
|
|
|
|
sta OUTH
|
|
|
|
|
2017-11-18 19:31:03 +00:00
|
|
|
|
2017-11-27 03:05:52 +00:00
|
|
|
jsr print_both_pages ; "NEED TO LAND ON GRASS!"
|
2017-09-11 19:09:51 +00:00
|
|
|
|
|
|
|
check_help:
|
|
|
|
cmp #('H')
|
|
|
|
bne check_done
|
|
|
|
|
|
|
|
;=====
|
|
|
|
; HELP
|
|
|
|
;=====
|
|
|
|
|
2017-11-18 20:17:28 +00:00
|
|
|
jsr print_help
|
|
|
|
|
2020-12-31 16:43:03 +00:00
|
|
|
jsr draw_sky
|
2017-11-26 22:59:27 +00:00
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
check_done:
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
;================
|
|
|
|
; Wrap the Angle
|
|
|
|
;================
|
2017-11-24 04:57:30 +00:00
|
|
|
; FIXME: only do this in right/left routine?
|
|
|
|
lda ANGLE ; 3
|
|
|
|
and #$f ; 2
|
|
|
|
sta ANGLE ; 3
|
2017-09-07 05:32:31 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
;================
|
|
|
|
; Handle Movement
|
|
|
|
;================
|
|
|
|
|
2017-09-11 19:28:56 +00:00
|
|
|
speed_move:
|
2017-11-24 04:57:30 +00:00
|
|
|
ldx SPEED ; 3
|
|
|
|
beq draw_background ; 2nt/3
|
|
|
|
;=============
|
|
|
|
lda ANGLE ; dx.i=fixed_sin[(angle+4)&0xf].i; // cos() ; 3
|
|
|
|
clc ; 2
|
|
|
|
adc #4 ; 2
|
|
|
|
and #$f ; 2
|
|
|
|
asl ; 2
|
|
|
|
tay ; 2
|
|
|
|
lda fixed_sin_scale,Y ; 4
|
|
|
|
sta DX_I ; 3
|
|
|
|
iny ; dx.f=fixed_sin[(angle+4)&0xf].f; // cos() ; 2
|
|
|
|
lda fixed_sin_scale,Y ; 4
|
|
|
|
sta DX_F ; 3
|
2017-09-11 19:28:56 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda ANGLE ; dy.i=fixed_sin[angle&0xf].i; // sin() ; 3
|
|
|
|
and #$f ; 2
|
|
|
|
asl ; 2
|
|
|
|
tay ; 2
|
|
|
|
lda fixed_sin_scale,Y ; 4
|
|
|
|
sta DY_I ; 3
|
|
|
|
iny ; dx.f=fixed_sin[angle&0xf].f; // sin() ; 2
|
|
|
|
lda fixed_sin_scale,Y ; 4
|
|
|
|
sta DY_F ; 3
|
|
|
|
;============
|
|
|
|
; 54
|
2017-09-11 19:28:56 +00:00
|
|
|
speed_loop:
|
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
clc ; fixed_add(&cx,&dx,&cx); ; 2
|
|
|
|
lda CX_F ; 3
|
|
|
|
adc DX_F ; 3
|
|
|
|
sta CX_F ; 3
|
|
|
|
lda CX_I ; 3
|
|
|
|
adc DX_I ; 3
|
|
|
|
sta CX_I ; 3
|
2017-09-11 19:09:51 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
clc ; fixed_add(&cy,&dy,&cy); ; 2
|
|
|
|
lda CY_F ; 3
|
|
|
|
adc DY_F ; 3
|
|
|
|
sta CY_F ; 3
|
|
|
|
lda CY_I ; 3
|
|
|
|
adc DY_I ; 3
|
|
|
|
sta CY_I ; 3
|
2017-09-11 19:09:51 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
dex ; 2
|
|
|
|
bne speed_loop ; 2nt/3
|
|
|
|
;============
|
|
|
|
; 45
|
2017-09-11 19:09:51 +00:00
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
;====================
|
|
|
|
; Draw the background
|
|
|
|
;====================
|
2017-09-11 19:09:51 +00:00
|
|
|
draw_background:
|
2017-11-24 04:57:30 +00:00
|
|
|
jsr draw_background_mode7 ; 6
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-11-26 06:02:02 +00:00
|
|
|
check_over_water:
|
|
|
|
; See if we are over water
|
|
|
|
lda CX_I ; 3
|
|
|
|
sta SPACEX_I ; 3
|
|
|
|
lda CY_I ; 3
|
|
|
|
sta SPACEY_I ; 3
|
|
|
|
|
|
|
|
jsr lookup_map ; 6
|
|
|
|
|
|
|
|
sec ; 2
|
|
|
|
sbc #COLOR_BOTH_DARKBLUE ; 2
|
|
|
|
sta OVER_LAND ; 3
|
|
|
|
;===========
|
|
|
|
; 31
|
|
|
|
|
2017-10-09 19:36:25 +00:00
|
|
|
; Calculate whether to draw the splash
|
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #0 ; set splash drawing to 0 ; 2
|
|
|
|
sta DRAW_SPLASH ; 3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda SPEED ; if speed==0, no splash ; 3
|
|
|
|
beq no_splash ; 2nt/3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda TURNING ; 3
|
|
|
|
beq no_turning_splash ; 2nt/3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda SHIPY ; 3
|
|
|
|
cmp #27 ; 2
|
|
|
|
bcc no_turning_splash ; blt if shipy<25 skip ; 2nt/3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #1 ; 2
|
|
|
|
sta SPLASH_COUNT ; 3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
|
|
|
no_turning_splash:
|
2017-11-26 06:02:02 +00:00
|
|
|
lda OVER_LAND ; no splash if over land ; 3
|
|
|
|
bne no_splash ; 2nt/3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda SPLASH_COUNT ; no splash if splash_count expired ; 3
|
|
|
|
beq no_splash ; 2nt/3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #1 ; 2
|
|
|
|
sta DRAW_SPLASH ; 3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
|
|
|
no_splash:
|
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
;==============
|
|
|
|
; Draw the ship
|
|
|
|
;==============
|
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
clv ; 2
|
|
|
|
lda TURNING ; 3
|
|
|
|
beq draw_ship_forward ; 2nt/3
|
|
|
|
bpl draw_ship_right ; 2nt/3
|
|
|
|
bmi draw_ship_left ;; FIXME: optimize order ; 2nt/3
|
2017-08-23 19:41:37 +00:00
|
|
|
|
|
|
|
draw_ship_forward:
|
2017-11-24 04:57:30 +00:00
|
|
|
lda DRAW_SPLASH ; 2
|
|
|
|
beq no_forward_splash ; 2nt/3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
|
|
|
; Draw Splash
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #>splash_forward ; 2
|
|
|
|
sta INH ; 3
|
|
|
|
lda #<splash_forward ; 2
|
|
|
|
sta INL ; 3
|
2017-11-24 19:01:47 +00:00
|
|
|
lda #(CONST_SHIPX+1) ; 2
|
2017-11-24 04:57:30 +00:00
|
|
|
sta XPOS ; 3
|
|
|
|
clc ; 2
|
|
|
|
lda SHIPY ; 3
|
|
|
|
adc #9 ; 2
|
|
|
|
and #$fe ; make sure it's even ; 2
|
|
|
|
sta YPOS ; 3
|
|
|
|
jsr put_sprite ; 6
|
|
|
|
;==========
|
|
|
|
; 33
|
2017-10-09 19:36:25 +00:00
|
|
|
no_forward_splash:
|
2017-09-11 19:58:23 +00:00
|
|
|
; Draw Shadow
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #>shadow_forward ; 2
|
|
|
|
sta INH ; 3
|
|
|
|
lda #<shadow_forward ; 2
|
|
|
|
sta INL ; 3
|
2017-11-24 19:01:47 +00:00
|
|
|
lda #(CONST_SHIPX+3) ; 2
|
2017-11-24 04:57:30 +00:00
|
|
|
sta XPOS ; 3
|
|
|
|
clc ; 2
|
|
|
|
lda SPACEZ_I ; 3
|
|
|
|
adc #31 ; 2
|
|
|
|
and #$fe ; make sure it's even ; 2
|
|
|
|
sta YPOS ; 3
|
|
|
|
jsr put_sprite ; 6
|
|
|
|
|
|
|
|
lda #>ship_forward ; 2
|
|
|
|
sta INH ; 3
|
|
|
|
lda #<ship_forward ; 2
|
|
|
|
sta INL ; 3
|
|
|
|
bvc draw_ship ; 3
|
|
|
|
;===========
|
|
|
|
; 46
|
2017-08-23 19:41:37 +00:00
|
|
|
draw_ship_right:
|
2017-11-24 04:57:30 +00:00
|
|
|
lda DRAW_SPLASH ; 3
|
|
|
|
beq no_right_splash ; 2nt/3
|
2017-09-11 19:58:23 +00:00
|
|
|
|
2017-10-09 19:36:25 +00:00
|
|
|
; Draw Splash
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #>splash_right ; 2
|
|
|
|
sta INH ; 3
|
|
|
|
lda #<splash_right ; 2
|
|
|
|
sta INL ; 3
|
2017-11-24 19:01:47 +00:00
|
|
|
lda #(CONST_SHIPX+1) ; 2
|
2017-11-24 04:57:30 +00:00
|
|
|
sta XPOS ; 3
|
|
|
|
clc ; 2
|
|
|
|
lda #36 ; 2
|
|
|
|
sta YPOS ; 3
|
|
|
|
jsr put_sprite ; 6
|
|
|
|
;===========
|
|
|
|
; 28
|
2017-10-09 19:36:25 +00:00
|
|
|
no_right_splash:
|
2017-09-11 19:58:23 +00:00
|
|
|
|
|
|
|
; Draw Shadow
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #>shadow_right ; 2
|
|
|
|
sta INH ; 3
|
|
|
|
lda #<shadow_right ; 2
|
|
|
|
sta INL ; 3
|
2017-11-24 19:01:47 +00:00
|
|
|
lda #(CONST_SHIPX+3) ; 2
|
2017-11-24 04:57:30 +00:00
|
|
|
sta XPOS ; 3
|
|
|
|
clc ; 2
|
|
|
|
lda SPACEZ_I ; 3
|
|
|
|
adc #31 ; 2
|
|
|
|
and #$fe ; make sure it's even ; 2
|
|
|
|
sta YPOS ; 3
|
|
|
|
jsr put_sprite ; 6
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #>ship_right ; 2
|
|
|
|
sta INH ; 3
|
|
|
|
lda #<ship_right ; 2
|
|
|
|
sta INL ; 3
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
dec TURNING ; 5
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
bvc draw_ship ; 3
|
|
|
|
;==========
|
|
|
|
; 51
|
2017-08-23 19:41:37 +00:00
|
|
|
draw_ship_left:
|
2017-11-24 04:57:30 +00:00
|
|
|
lda DRAW_SPLASH ; 3
|
|
|
|
beq no_left_splash ; 2nt/3
|
2017-09-11 19:58:23 +00:00
|
|
|
|
2017-10-09 19:36:25 +00:00
|
|
|
; Draw Splash
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #>splash_left ; 2
|
|
|
|
sta INH ; 3
|
|
|
|
lda #<splash_left ; 2
|
|
|
|
sta INL ; 3
|
2017-11-24 19:01:47 +00:00
|
|
|
lda #(CONST_SHIPX+1) ; 2
|
2017-11-24 04:57:30 +00:00
|
|
|
sta XPOS ; 3
|
|
|
|
clc ; 2
|
|
|
|
lda #36 ; 2
|
|
|
|
sta YPOS ; 3
|
|
|
|
jsr put_sprite ; 6
|
|
|
|
;===========
|
2017-11-27 00:20:58 +00:00
|
|
|
; 28
|
2017-10-09 19:36:25 +00:00
|
|
|
no_left_splash:
|
2017-09-11 19:58:23 +00:00
|
|
|
|
|
|
|
; Draw Shadow
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #>shadow_left ; 2
|
|
|
|
sta INH ; 3
|
|
|
|
lda #<shadow_left ; 2
|
|
|
|
sta INL ; 3
|
2017-11-24 19:01:47 +00:00
|
|
|
lda #(CONST_SHIPX+3) ; 2
|
2017-11-24 04:57:30 +00:00
|
|
|
sta XPOS ; 3
|
|
|
|
clc ; 2
|
|
|
|
lda SPACEZ_I ; 3
|
|
|
|
adc #31 ; 2
|
|
|
|
and #$fe ; make sure it's even ; 2
|
|
|
|
sta YPOS ; 3
|
|
|
|
jsr put_sprite ; 6
|
2017-09-11 19:58:23 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
lda #>ship_left ; 2
|
|
|
|
sta INH ; 3
|
|
|
|
lda #<ship_left ; 2
|
|
|
|
sta INL ; 3
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
inc TURNING ; 5
|
|
|
|
;==========
|
|
|
|
; 48
|
2017-10-09 19:36:25 +00:00
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
draw_ship:
|
2017-11-24 19:01:47 +00:00
|
|
|
lda #CONST_SHIPX ; 2
|
2017-11-24 04:57:30 +00:00
|
|
|
sta XPOS ; 3
|
|
|
|
lda SHIPY ; 3
|
|
|
|
sta YPOS ; 3
|
|
|
|
jsr put_sprite ; 6
|
|
|
|
;===========
|
|
|
|
; 17
|
2017-08-23 19:41:37 +00:00
|
|
|
|
|
|
|
;==================
|
|
|
|
; flip pages
|
|
|
|
;==================
|
|
|
|
|
2017-11-24 04:57:30 +00:00
|
|
|
jsr page_flip ; 6
|
2017-08-23 19:41:37 +00:00
|
|
|
|
|
|
|
;==================
|
|
|
|
; loop forever
|
|
|
|
;==================
|
2020-12-31 16:43:03 +00:00
|
|
|
done_flying_loop:
|
2017-11-24 04:57:30 +00:00
|
|
|
jmp flying_loop ; 3
|
2017-08-17 03:18:59 +00:00
|
|
|
|
|
|
|
|
2017-11-30 05:13:23 +00:00
|
|
|
update_z_factor:
|
|
|
|
|
|
|
|
; we only do the following if Z changes
|
|
|
|
|
|
|
|
; fixed_mul(&space_z,&BETA,&factor);
|
|
|
|
;mul1
|
|
|
|
lda SPACEZ_I ; 3
|
|
|
|
sta NUM1H ; 3
|
|
|
|
|
|
|
|
; interlude, update SPACEZ_SHIFTED
|
|
|
|
asl ; 2
|
|
|
|
asl ; 2
|
|
|
|
asl ; 2
|
|
|
|
asl ; 2
|
|
|
|
asl ; 2
|
|
|
|
sec ; 2
|
|
|
|
sbc #8 ; 2
|
|
|
|
sta spacez_shifted+1 ; 4
|
|
|
|
|
|
|
|
|
|
|
|
lda SPACEZ_F ; 3
|
|
|
|
sta NUM1L ; 3
|
|
|
|
|
|
|
|
lda #CONST_BETA_I ; BETA_I ; 2
|
|
|
|
sta NUM2H ; 3
|
|
|
|
lda #CONST_BETA_F ; BETA_F ; 2
|
|
|
|
sta NUM2L ; 3
|
|
|
|
|
|
|
|
sec ; don't reuse old values ; 2
|
|
|
|
jsr multiply ; 6
|
|
|
|
|
2017-11-30 05:18:14 +00:00
|
|
|
stx FACTOR_I ; 3
|
|
|
|
sta FACTOR_F ; 3
|
2017-11-30 05:13:23 +00:00
|
|
|
|
|
|
|
rts ; 6
|
|
|
|
;===========
|
|
|
|
; 60
|
|
|
|
|
|
|
|
|
2017-12-01 05:01:34 +00:00
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-12-01 05:01:34 +00:00
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
flying_map:
|
2017-08-25 05:34:14 +00:00
|
|
|
.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
|
|
|
|
|
|
|
|
|
2017-08-27 04:11:53 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2017-11-26 20:12:21 +00:00
|
|
|
|
|
|
|
|
2017-11-18 19:31:03 +00:00
|
|
|
|
|
|
|
grass_string:
|
2020-12-31 17:41:46 +00:00
|
|
|
.byte 10,22,"NEED TO LAND ON GRASS!",0
|
2020-12-30 06:41:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
;===============================================
|
|
|
|
; External modules
|
|
|
|
;===============================================
|
|
|
|
|
|
|
|
.include "gr_offsets.s"
|
2020-12-31 16:43:03 +00:00
|
|
|
;.include "gr_hlin.s"
|
2020-12-30 06:41:14 +00:00
|
|
|
.include "gr_pageflip.s"
|
|
|
|
.include "gr_putsprite.s"
|
|
|
|
.include "gr_fast_clear.s"
|
|
|
|
|
|
|
|
.include "keyboard.s"
|
|
|
|
.include "joystick.s"
|
|
|
|
|
|
|
|
.include "wait_keypressed.s"
|
|
|
|
.include "text_print.s"
|
|
|
|
|
2020-12-31 20:01:44 +00:00
|
|
|
.include "help_flying.s"
|
2020-12-30 06:41:14 +00:00
|
|
|
|
2020-12-30 23:25:43 +00:00
|
|
|
.include "flying_mode7.s"
|
|
|
|
.include "flying_sprites.inc"
|
|
|
|
.include "multiply_fast.s"
|