2017-08-23 19:41:37 +00:00
|
|
|
SHIPY EQU $E4
|
|
|
|
|
|
|
|
; FIXME, sort out available ZP page space
|
2017-08-27 04:11:53 +00:00
|
|
|
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
|
2017-09-11 19:09:51 +00:00
|
|
|
DRAW_SPLASH EQU $7A
|
|
|
|
SPEED EQU $7B
|
2017-08-27 04:11:53 +00:00
|
|
|
|
|
|
|
;===========
|
|
|
|
; 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
|
2017-08-23 19:41:37 +00:00
|
|
|
|
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
|
|
|
|
flying_start:
|
|
|
|
|
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
|
|
|
|
2017-09-11 18:52:32 +00:00
|
|
|
jsr clear_screens
|
2017-08-17 03:18:59 +00:00
|
|
|
jsr set_gr_page0
|
|
|
|
|
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-08-23 19:41:37 +00:00
|
|
|
|
2017-09-11 20:15:13 +00:00
|
|
|
lda #1
|
|
|
|
sta ANGLE
|
|
|
|
|
2017-09-07 03:17:39 +00:00
|
|
|
lda #4
|
|
|
|
sta SPACEZ_I
|
|
|
|
lda #$80
|
|
|
|
sta SPACEZ_F
|
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
flying_loop:
|
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
lda DRAW_SPLASH
|
|
|
|
beq flying_keyboard
|
|
|
|
dec DRAW_SPLASH ; decrement splash count
|
|
|
|
|
|
|
|
flying_keyboard:
|
|
|
|
|
|
|
|
|
|
|
|
jsr get_key ; get keypress
|
2017-08-17 03:18:59 +00:00
|
|
|
|
|
|
|
lda LASTKEY
|
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
cmp #('Q') ; if quit, then return
|
2017-08-17 03:18:59 +00:00
|
|
|
bne skipskip
|
|
|
|
rts
|
2017-09-11 19:09:51 +00:00
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
skipskip:
|
|
|
|
|
|
|
|
cmp #('I')
|
|
|
|
bne check_down
|
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
|
2017-09-11 19:09:51 +00:00
|
|
|
bcc 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-08-17 03:18:59 +00:00
|
|
|
|
|
|
|
check_down:
|
|
|
|
cmp #('M')
|
|
|
|
bne 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-09-11 19:09:51 +00:00
|
|
|
bcs check_left ; 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-08-17 03:18:59 +00:00
|
|
|
|
|
|
|
check_left:
|
|
|
|
cmp #('J')
|
|
|
|
bne 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
|
|
|
|
clv
|
|
|
|
bvc check_right
|
|
|
|
|
|
|
|
turn_left:
|
|
|
|
lda #253 ; -3
|
|
|
|
sta TURNING
|
|
|
|
|
2017-09-11 03:42:47 +00:00
|
|
|
dec ANGLE
|
2017-08-17 03:18:59 +00:00
|
|
|
|
|
|
|
check_right:
|
|
|
|
cmp #('K')
|
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
|
|
|
|
clv
|
|
|
|
bvc check_speedup
|
|
|
|
|
|
|
|
turn_right:
|
|
|
|
lda #3
|
|
|
|
sta TURNING
|
|
|
|
|
2017-09-11 03:42:47 +00:00
|
|
|
inc ANGLE
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
check_speedup:
|
|
|
|
cmp #('Z')
|
|
|
|
bne check_speeddown
|
|
|
|
|
|
|
|
;=========
|
|
|
|
; SPEED UP
|
|
|
|
;=========
|
|
|
|
lda #$3
|
|
|
|
cmp SPEED
|
2017-09-11 19:28:56 +00:00
|
|
|
beq check_speeddown
|
2017-09-11 19:09:51 +00:00
|
|
|
inc SPEED
|
|
|
|
|
|
|
|
check_speeddown:
|
|
|
|
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
|
2017-09-11 19:28:56 +00:00
|
|
|
beq check_brake
|
2017-09-11 19:09:51 +00:00
|
|
|
dec SPEED
|
|
|
|
|
2017-09-11 19:28:56 +00:00
|
|
|
check_brake:
|
|
|
|
cmp #(' '+128)
|
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
|
|
|
|
|
|
|
|
check_land:
|
|
|
|
cmp #13
|
|
|
|
bne check_help
|
|
|
|
|
|
|
|
;=====
|
|
|
|
; LAND
|
|
|
|
;=====
|
|
|
|
|
|
|
|
|
|
|
|
check_help:
|
|
|
|
cmp #('H')
|
|
|
|
bne check_done
|
|
|
|
|
|
|
|
;=====
|
|
|
|
; HELP
|
|
|
|
;=====
|
|
|
|
|
|
|
|
|
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-09-07 05:32:31 +00:00
|
|
|
lda ANGLE
|
|
|
|
and #$f
|
|
|
|
sta ANGLE
|
|
|
|
|
2017-09-11 19:09:51 +00:00
|
|
|
;================
|
|
|
|
; Handle Movement
|
|
|
|
;================
|
|
|
|
|
2017-09-11 19:28:56 +00:00
|
|
|
speed_move:
|
2017-09-11 19:09:51 +00:00
|
|
|
ldx SPEED
|
|
|
|
beq draw_background
|
|
|
|
|
2017-09-11 19:28:56 +00:00
|
|
|
lda ANGLE ; dx.i=fixed_sin[(angle+4)&0xf].i; // cos()
|
|
|
|
clc
|
|
|
|
adc #4
|
|
|
|
and #$f
|
|
|
|
asl
|
|
|
|
tay
|
|
|
|
lda fixed_sin_scale,Y
|
|
|
|
sta DX_I
|
|
|
|
iny ; dx.f=fixed_sin[(angle+4)&0xf].f; // cos()
|
|
|
|
lda fixed_sin_scale,Y
|
|
|
|
sta DX_F
|
|
|
|
|
|
|
|
lda ANGLE ; dy.i=fixed_sin[angle&0xf].i; // sin()
|
|
|
|
and #$f
|
|
|
|
asl
|
|
|
|
tay
|
|
|
|
lda fixed_sin_scale,Y
|
|
|
|
sta DY_I
|
|
|
|
iny ; dx.f=fixed_sin[angle&0xf].f; // sin()
|
|
|
|
lda fixed_sin_scale,Y
|
|
|
|
sta DY_F
|
|
|
|
|
|
|
|
speed_loop:
|
|
|
|
|
|
|
|
clc ; fixed_add(&cx,&dx,&cx);
|
|
|
|
lda CX_F
|
|
|
|
adc DX_F
|
|
|
|
sta CX_F
|
|
|
|
lda CX_I
|
|
|
|
adc DX_I
|
|
|
|
sta CX_I
|
2017-09-11 19:09:51 +00:00
|
|
|
|
2017-09-11 19:28:56 +00:00
|
|
|
clc ; fixed_add(&cy,&dy,&cy);
|
|
|
|
lda CY_F
|
|
|
|
adc DY_F
|
|
|
|
sta CY_F
|
|
|
|
lda CY_I
|
|
|
|
adc DY_I
|
|
|
|
sta CY_I
|
2017-09-11 19:09:51 +00:00
|
|
|
|
|
|
|
dex
|
2017-09-11 19:28:56 +00:00
|
|
|
bne speed_loop
|
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-08-23 19:41:37 +00:00
|
|
|
jsr draw_background_mode7
|
|
|
|
|
|
|
|
;==============
|
|
|
|
; Draw the ship
|
|
|
|
;==============
|
|
|
|
|
|
|
|
clv
|
|
|
|
lda TURNING
|
2017-09-11 19:58:23 +00:00
|
|
|
beq draw_ship_forward
|
|
|
|
bpl draw_ship_right
|
|
|
|
bmi draw_ship_left ;; FIXME: optimize order
|
2017-08-23 19:41:37 +00:00
|
|
|
|
|
|
|
draw_ship_forward:
|
2017-09-11 19:58:23 +00:00
|
|
|
; Draw Shadow
|
|
|
|
lda #>shadow_forward
|
|
|
|
sta INH
|
|
|
|
lda #<shadow_forward
|
|
|
|
sta INL
|
|
|
|
lda #(SHIPX+3)
|
|
|
|
sta XPOS
|
|
|
|
clc
|
|
|
|
lda SPACEZ_I
|
|
|
|
adc #31
|
|
|
|
sta YPOS
|
|
|
|
jsr put_sprite
|
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
lda #>ship_forward
|
|
|
|
sta INH
|
|
|
|
lda #<ship_forward
|
|
|
|
sta INL
|
|
|
|
bvc draw_ship
|
|
|
|
|
|
|
|
draw_ship_right:
|
2017-09-11 19:58:23 +00:00
|
|
|
|
|
|
|
dec TURNING
|
|
|
|
|
|
|
|
; Draw Shadow
|
|
|
|
lda #>shadow_right
|
|
|
|
sta INH
|
|
|
|
lda #<shadow_right
|
|
|
|
sta INL
|
|
|
|
lda #(SHIPX+3)
|
|
|
|
sta XPOS
|
|
|
|
clc
|
|
|
|
lda SPACEZ_I
|
|
|
|
adc #31
|
|
|
|
sta YPOS
|
|
|
|
jsr put_sprite
|
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
lda #>ship_right
|
|
|
|
sta INH
|
|
|
|
lda #<ship_right
|
|
|
|
sta INL
|
|
|
|
bvc draw_ship
|
|
|
|
|
|
|
|
draw_ship_left:
|
2017-09-11 19:58:23 +00:00
|
|
|
|
|
|
|
inc TURNING
|
|
|
|
|
|
|
|
; Draw Shadow
|
|
|
|
lda #>shadow_left
|
|
|
|
sta INH
|
|
|
|
lda #<shadow_left
|
|
|
|
sta INL
|
|
|
|
lda #(SHIPX+3)
|
|
|
|
sta XPOS
|
|
|
|
clc
|
|
|
|
lda SPACEZ_I
|
|
|
|
adc #31
|
|
|
|
sta YPOS
|
|
|
|
jsr put_sprite
|
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
lda #>ship_left
|
|
|
|
sta INH
|
|
|
|
lda #<ship_left
|
|
|
|
sta INL
|
|
|
|
|
|
|
|
draw_ship:
|
|
|
|
lda #SHIPX
|
|
|
|
sta XPOS
|
|
|
|
lda SHIPY
|
|
|
|
sta YPOS
|
|
|
|
jsr put_sprite
|
|
|
|
|
|
|
|
;==================
|
|
|
|
; flip pages
|
|
|
|
;==================
|
|
|
|
|
|
|
|
jsr page_flip
|
|
|
|
|
|
|
|
;==================
|
|
|
|
; loop forever
|
|
|
|
;==================
|
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
jmp flying_loop
|
|
|
|
|
|
|
|
|
2017-08-23 19:41:37 +00:00
|
|
|
;===========================
|
|
|
|
; Draw the Mode7 Background
|
|
|
|
;===========================
|
|
|
|
|
|
|
|
draw_background_mode7:
|
|
|
|
|
|
|
|
; Draw Sky
|
|
|
|
|
2017-08-25 05:34:14 +00:00
|
|
|
lda #COLOR_BOTH_MEDIUMBLUE ; MEDIUMBLUE color
|
2017-08-23 19:41:37 +00:00
|
|
|
sta COLOR
|
|
|
|
|
|
|
|
lda #0
|
2017-08-25 05:34:14 +00:00
|
|
|
sky_loop: ; draw line across screen
|
|
|
|
ldy #40 ; from y=0 to y=6
|
2017-08-23 19:41:37 +00:00
|
|
|
sty V2
|
|
|
|
ldy #0
|
|
|
|
pha
|
2017-08-25 05:34:14 +00:00
|
|
|
jsr hlin_double ; hlin y,V2 at A
|
2017-08-23 19:41:37 +00:00
|
|
|
pla
|
|
|
|
clc
|
|
|
|
adc #2
|
|
|
|
cmp #6
|
|
|
|
bne sky_loop
|
|
|
|
|
|
|
|
; Draw Horizon
|
|
|
|
|
2017-08-25 05:34:14 +00:00
|
|
|
lda #COLOR_BOTH_GREY ; Horizon is Grey
|
2017-08-23 19:41:37 +00:00
|
|
|
sta COLOR
|
2017-08-25 05:34:14 +00:00
|
|
|
lda #6 ; draw single line at 6/7
|
2017-08-23 19:41:37 +00:00
|
|
|
ldy #40
|
2017-08-25 05:34:14 +00:00
|
|
|
sty V2 ; hlin Y,V2 at A
|
|
|
|
ldy #0
|
|
|
|
jsr hlin_double ; hlin 0,40 at 6
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
; fixed_mul(&space_z,&BETA,&factor);
|
2017-09-07 05:32:31 +00:00
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
lda SPACEZ_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1H
|
2017-09-07 03:17:39 +00:00
|
|
|
lda SPACEZ_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1L
|
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
lda #$ff ; BETA_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2H
|
2017-09-07 03:17:39 +00:00
|
|
|
lda #$80 ; BETA_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2L
|
|
|
|
|
|
|
|
;; TEST
|
|
|
|
;; lda #$0
|
|
|
|
;; sta NUM1H
|
|
|
|
;; lda #$2
|
|
|
|
;; sta NUM1L
|
|
|
|
|
|
|
|
;; lda #$0
|
|
|
|
;; sta NUM2H
|
|
|
|
;; lda #$3
|
|
|
|
;; sta NUM2L
|
|
|
|
|
|
|
|
|
2017-09-07 03:17:39 +00:00
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
jsr multiply
|
2017-09-07 03:17:39 +00:00
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
lda RESULT+2
|
2017-09-07 05:32:31 +00:00
|
|
|
sta FACTOR_I
|
|
|
|
lda RESULT+1
|
2017-09-02 04:23:38 +00:00
|
|
|
sta FACTOR_F
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-09-07 05:32:31 +00:00
|
|
|
;; SPACEZ=78 * ff80 = FACTOR=66
|
2017-09-07 03:17:39 +00:00
|
|
|
|
|
|
|
;; C
|
|
|
|
;; GOOD 4 80 * ffffffff 80 = fffffffd c0
|
|
|
|
;; BAD 4 80 * ffffffff 80 = 42 40
|
|
|
|
|
2017-08-25 05:34:14 +00:00
|
|
|
lda #8
|
|
|
|
sta SCREEN_Y
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-08-25 05:34:14 +00:00
|
|
|
screeny_loop:
|
2017-08-23 19:41:37 +00:00
|
|
|
ldy #0
|
2017-09-11 03:42:47 +00:00
|
|
|
jsr hlin_setup ; y-coord in a, x-coord in y
|
|
|
|
; sets up GBASL/GBASH
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
lda #0 ; horizontal_scale.i = 0
|
|
|
|
sta HORIZ_SCALE_I
|
|
|
|
|
|
|
|
;horizontal_scale.f=
|
|
|
|
; horizontal_lookup[space_z.i&0xf][(screen_y-8)/2];
|
|
|
|
|
|
|
|
lda SPACEZ_I
|
|
|
|
and #$f
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
sta TEMP_I
|
|
|
|
|
2017-09-11 18:48:35 +00:00
|
|
|
sec
|
2017-09-02 04:23:38 +00:00
|
|
|
lda SCREEN_Y
|
2017-09-11 18:48:35 +00:00
|
|
|
sbc #8
|
2017-09-02 04:23:38 +00:00
|
|
|
lsr
|
|
|
|
clc
|
|
|
|
adc TEMP_I
|
|
|
|
tay
|
|
|
|
lda horizontal_lookup,Y
|
|
|
|
sta HORIZ_SCALE_F
|
|
|
|
|
2017-09-10 20:52:56 +00:00
|
|
|
;; brk ASM, horiz_scale = 00:73
|
2017-09-02 04:23:38 +00:00
|
|
|
|
|
|
|
; calculate the distance of the line we are drawing
|
|
|
|
; fixed_mul(&horizontal_scale,&scale,&distance);
|
|
|
|
lda HORIZ_SCALE_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda HORIZ_SCALE_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1L
|
2017-09-02 04:23:38 +00:00
|
|
|
lda #$14 ; SCALE_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda #$00 ; SCALE_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2L
|
2017-09-02 04:23:38 +00:00
|
|
|
jsr multiply
|
|
|
|
lda RESULT+2
|
2017-09-07 05:32:31 +00:00
|
|
|
sta DISTANCE_I
|
|
|
|
lda RESULT+1
|
2017-09-02 04:23:38 +00:00
|
|
|
sta DISTANCE_F
|
|
|
|
|
2017-09-10 20:52:56 +00:00
|
|
|
;; brk ASM, distance = 08:fc
|
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
; calculate the dx and dy of points in space when we step
|
|
|
|
; through all points on this line
|
|
|
|
|
|
|
|
lda ANGLE ; dx.i=fixed_sin[(angle+8)&0xf].i; // -sin()
|
|
|
|
clc
|
|
|
|
adc #8
|
|
|
|
and #$f
|
2017-09-10 20:52:56 +00:00
|
|
|
asl
|
2017-09-02 04:23:38 +00:00
|
|
|
tay
|
|
|
|
lda fixed_sin,Y
|
|
|
|
sta DX_I
|
|
|
|
iny ; dx.f=fixed_sin[(angle+8)&0xf].f; // -sin()
|
|
|
|
lda fixed_sin,Y
|
|
|
|
sta DX_F
|
|
|
|
|
|
|
|
; fixed_mul(&dx,&horizontal_scale,&dx);
|
|
|
|
lda HORIZ_SCALE_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda HORIZ_SCALE_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1L
|
2017-09-02 04:23:38 +00:00
|
|
|
lda DX_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda DX_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2L
|
2017-09-02 04:23:38 +00:00
|
|
|
jsr multiply
|
|
|
|
lda RESULT+2
|
2017-09-07 05:32:31 +00:00
|
|
|
sta DX_I
|
|
|
|
lda RESULT+1
|
2017-09-02 04:23:38 +00:00
|
|
|
sta DX_F
|
|
|
|
|
2017-09-11 03:42:47 +00:00
|
|
|
;; ANGLE
|
|
|
|
;; brk ASM, dx = 00:00
|
2017-09-02 04:23:38 +00:00
|
|
|
|
|
|
|
lda ANGLE ; dy.i=fixed_sin[(angle+4)&0xf].i; // cos()
|
|
|
|
clc
|
|
|
|
adc #4
|
|
|
|
and #$f
|
2017-09-10 20:52:56 +00:00
|
|
|
asl
|
2017-09-02 04:23:38 +00:00
|
|
|
tay
|
|
|
|
lda fixed_sin,Y
|
|
|
|
sta DY_I
|
|
|
|
iny ; dy.f=fixed_sin[(angle+4)&0xf].f; // cos()
|
|
|
|
lda fixed_sin,Y
|
|
|
|
sta DY_F
|
|
|
|
|
|
|
|
; fixed_mul(&dy,&horizontal_scale,&dy);
|
|
|
|
lda HORIZ_SCALE_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda HORIZ_SCALE_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1L
|
2017-09-02 04:23:38 +00:00
|
|
|
lda DY_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda DY_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2L
|
2017-09-02 04:23:38 +00:00
|
|
|
jsr multiply
|
|
|
|
lda RESULT+2
|
2017-09-07 05:32:31 +00:00
|
|
|
sta DY_I
|
|
|
|
lda RESULT+1
|
2017-09-02 04:23:38 +00:00
|
|
|
sta DY_F
|
|
|
|
|
2017-09-11 03:42:47 +00:00
|
|
|
;; brk ASM, dy = 00:73
|
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
; calculate the starting position
|
|
|
|
|
|
|
|
; fixed_add(&distance,&factor,&space_x);
|
|
|
|
clc ; fixed_add(&distance,&factor,&space_y);
|
|
|
|
lda DISTANCE_F
|
|
|
|
adc FACTOR_F
|
|
|
|
sta SPACEY_F
|
|
|
|
sta SPACEX_F
|
|
|
|
lda DISTANCE_I
|
|
|
|
adc FACTOR_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta SPACEY_I
|
|
|
|
sta SPACEX_I
|
2017-09-02 04:23:38 +00:00
|
|
|
|
2017-09-10 21:05:26 +00:00
|
|
|
;; brk space_x = 06:bc
|
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
lda ANGLE ; fixed_temp.i=fixed_sin[(angle+4)&0xf].i; // cos
|
|
|
|
clc
|
|
|
|
adc #4
|
|
|
|
and #$f
|
2017-09-10 20:52:56 +00:00
|
|
|
asl
|
2017-09-02 04:23:38 +00:00
|
|
|
tay
|
|
|
|
lda fixed_sin,Y
|
|
|
|
sta TEMP_I
|
|
|
|
iny ; fixed_temp.f=fixed_sin[(angle+4)&0xf].f; // cos
|
|
|
|
lda fixed_sin,Y
|
|
|
|
sta TEMP_F
|
|
|
|
|
|
|
|
; fixed_mul(&space_x,&fixed_temp,&space_x);
|
|
|
|
lda SPACEX_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda SPACEX_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1L
|
2017-09-02 04:23:38 +00:00
|
|
|
lda TEMP_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda TEMP_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2L
|
2017-09-02 04:23:38 +00:00
|
|
|
jsr multiply
|
|
|
|
lda RESULT+2
|
2017-09-07 05:32:31 +00:00
|
|
|
sta SPACEX_I
|
|
|
|
lda RESULT+1
|
2017-09-10 21:05:26 +00:00
|
|
|
sta SPACEX_F
|
2017-09-02 04:23:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
clc ; fixed_add(&space_x,&cx,&space_x);
|
|
|
|
lda SPACEX_F
|
|
|
|
adc CX_F
|
|
|
|
sta SPACEX_F
|
|
|
|
lda SPACEX_I
|
|
|
|
adc CX_I
|
|
|
|
sta SPACEX_I
|
|
|
|
|
|
|
|
lda #$ec ; fixed_temp.i=0xec; // -20 (LOWRES_W/2)
|
|
|
|
sta TEMP_I
|
|
|
|
lda #0 ; fixed_temp.f=0;
|
|
|
|
sta TEMP_F
|
|
|
|
|
|
|
|
; fixed_mul(&fixed_temp,&dx,&fixed_temp);
|
|
|
|
lda TEMP_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda TEMP_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1L
|
2017-09-02 04:23:38 +00:00
|
|
|
lda DX_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda DX_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2L
|
2017-09-02 04:23:38 +00:00
|
|
|
jsr multiply
|
|
|
|
lda RESULT+2
|
2017-09-07 05:32:31 +00:00
|
|
|
sta TEMP_I
|
|
|
|
lda RESULT+1
|
2017-09-02 04:23:38 +00:00
|
|
|
sta TEMP_F
|
|
|
|
|
|
|
|
|
|
|
|
clc ; fixed_add(&space_x,&fixed_temp,&space_x);
|
|
|
|
lda SPACEX_F
|
|
|
|
adc TEMP_F
|
|
|
|
sta SPACEX_F
|
2017-09-10 21:05:26 +00:00
|
|
|
lda SPACEX_I
|
2017-09-02 04:23:38 +00:00
|
|
|
adc TEMP_I
|
|
|
|
sta SPACEX_I
|
|
|
|
|
2017-09-11 20:15:13 +00:00
|
|
|
;;brk ;; brk space_x = 06:bc
|
2017-09-11 03:42:47 +00:00
|
|
|
|
2017-09-02 04:23:38 +00:00
|
|
|
lda ANGLE ; fixed_temp.i=fixed_sin[angle&0xf].i;
|
|
|
|
and #$f
|
2017-09-10 20:52:56 +00:00
|
|
|
asl
|
2017-09-02 04:23:38 +00:00
|
|
|
tay
|
|
|
|
lda fixed_sin,Y
|
|
|
|
sta TEMP_I
|
|
|
|
iny ; fixed_temp.f=fixed_sin[angle&0xf].f;
|
|
|
|
lda fixed_sin,Y
|
|
|
|
sta TEMP_F
|
|
|
|
|
|
|
|
|
|
|
|
; fixed_mul(&space_y,&fixed_temp,&space_y);
|
|
|
|
lda SPACEY_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda SPACEY_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1L
|
2017-09-02 04:23:38 +00:00
|
|
|
lda TEMP_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda TEMP_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2L
|
2017-09-02 04:23:38 +00:00
|
|
|
jsr multiply
|
|
|
|
lda RESULT+2
|
2017-09-07 05:32:31 +00:00
|
|
|
sta SPACEY_I
|
|
|
|
lda RESULT+1
|
2017-09-02 04:23:38 +00:00
|
|
|
sta SPACEY_F
|
|
|
|
|
|
|
|
|
|
|
|
clc ; fixed_add(&space_y,&cy,&space_y);
|
|
|
|
lda SPACEY_F
|
|
|
|
adc CY_F
|
|
|
|
sta SPACEY_F
|
|
|
|
lda SPACEY_I
|
|
|
|
adc CY_I
|
|
|
|
sta SPACEY_I
|
|
|
|
|
|
|
|
lda #$ec ; fixed_temp.i=0xec; // -20 (LOWRES_W/2)
|
|
|
|
sta TEMP_I
|
|
|
|
lda #0 ; fixed_temp.f=0;
|
|
|
|
sta TEMP_F
|
|
|
|
|
|
|
|
; fixed_mul(&fixed_temp,&dy,&fixed_temp);
|
|
|
|
lda TEMP_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda TEMP_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM1L
|
2017-09-11 20:15:13 +00:00
|
|
|
lda DY_I
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2H
|
2017-09-02 04:23:38 +00:00
|
|
|
lda DY_F
|
2017-09-07 05:32:31 +00:00
|
|
|
sta NUM2L
|
2017-09-02 04:23:38 +00:00
|
|
|
jsr multiply
|
|
|
|
lda RESULT+2
|
2017-09-07 05:32:31 +00:00
|
|
|
sta TEMP_I
|
|
|
|
lda RESULT+1
|
2017-09-02 04:23:38 +00:00
|
|
|
sta TEMP_F
|
|
|
|
|
|
|
|
|
|
|
|
clc ; fixed_add(&space_y,&fixed_temp,&space_y);
|
|
|
|
lda SPACEY_F
|
|
|
|
adc TEMP_F
|
|
|
|
sta SPACEY_F
|
|
|
|
lda SPACEY_I
|
|
|
|
adc TEMP_I
|
|
|
|
sta SPACEY_I
|
|
|
|
|
2017-09-11 20:15:13 +00:00
|
|
|
;;brk ;; brk space_y = f7:04
|
2017-08-23 19:41:37 +00:00
|
|
|
|
2017-08-25 05:34:14 +00:00
|
|
|
lda #0
|
|
|
|
sta SCREEN_X
|
|
|
|
screenx_loop:
|
|
|
|
|
|
|
|
jsr lookup_map ; get color in A
|
|
|
|
ldy #0
|
2017-09-02 04:23:38 +00:00
|
|
|
sta (GBASL),Y ; plot double height
|
|
|
|
inc GBASL ; point to next pixel
|
|
|
|
|
|
|
|
; advance to the next position in space
|
|
|
|
|
|
|
|
clc ; fixed_add(&space_x,&dx,&space_x);
|
|
|
|
lda SPACEX_F
|
|
|
|
adc DX_F
|
|
|
|
sta SPACEX_F
|
|
|
|
lda SPACEX_I
|
|
|
|
adc DX_I
|
|
|
|
sta SPACEX_I
|
|
|
|
|
|
|
|
clc ; fixed_add(&space_y,&dy,&space_y);
|
|
|
|
lda SPACEY_F
|
|
|
|
adc DY_F
|
|
|
|
sta SPACEY_F
|
|
|
|
lda SPACEY_I
|
|
|
|
adc DY_I
|
|
|
|
sta SPACEY_I
|
|
|
|
|
|
|
|
|
2017-08-25 05:34:14 +00:00
|
|
|
|
|
|
|
inc SCREEN_X
|
|
|
|
lda SCREEN_X
|
|
|
|
cmp #40 ; LOWRES width
|
|
|
|
bne screenx_loop
|
|
|
|
|
|
|
|
|
|
|
|
lda SCREEN_Y
|
2017-08-23 19:41:37 +00:00
|
|
|
clc
|
|
|
|
adc #2
|
2017-08-25 05:34:14 +00:00
|
|
|
sta SCREEN_Y
|
|
|
|
cmp #40 ; LOWRES height
|
2017-09-02 04:23:38 +00:00
|
|
|
beq done_screeny
|
|
|
|
jmp screeny_loop
|
|
|
|
done_screeny:
|
2017-08-25 05:34:14 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;====================
|
|
|
|
; lookup_map
|
|
|
|
;====================
|
|
|
|
; finds value in space_x.i,space_y.i
|
|
|
|
; returns color in A
|
|
|
|
lookup_map:
|
2017-08-27 04:11:53 +00:00
|
|
|
lda SPACEX_I
|
|
|
|
and #MAP_MASK
|
|
|
|
sta TEMPY
|
|
|
|
|
|
|
|
lda SPACEY_I
|
2017-09-11 03:42:47 +00:00
|
|
|
and #MAP_MASK ; wrap to 64x64 grid
|
|
|
|
|
|
|
|
|
2017-09-07 05:32:31 +00:00
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl ; multiply by 8
|
2017-08-27 04:11:53 +00:00
|
|
|
clc
|
|
|
|
adc TEMPY ; add in X value
|
2017-09-07 05:40:00 +00:00
|
|
|
; (use OR instead?)
|
2017-08-25 05:34:14 +00:00
|
|
|
|
2017-08-27 04:11:53 +00:00
|
|
|
ldy SPACEX_I
|
|
|
|
cpy #$8
|
2017-09-11 03:42:47 +00:00
|
|
|
beq ocean_color ; bgt
|
|
|
|
bcs ocean_color
|
2017-08-27 04:11:53 +00:00
|
|
|
ldy SPACEY_I
|
|
|
|
cpy #$8
|
2017-09-11 03:42:47 +00:00
|
|
|
beq ocean_color ; bgt
|
|
|
|
bcs ocean_color
|
2017-08-27 04:11:53 +00:00
|
|
|
|
|
|
|
tay
|
|
|
|
lda flying_map,Y ; load from array
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
ocean_color:
|
|
|
|
and #$1f
|
|
|
|
tay
|
|
|
|
lda water_map,Y ; the color of the sea
|
2017-08-23 19:41:37 +00:00
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
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-09-07 05:32:31 +00:00
|
|
|
.include "tfv_multiply.s"
|
2017-08-27 04:11:53 +00:00
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2017-08-25 05:34:14 +00:00
|
|
|
; 8.8 fixed point
|
2017-09-02 04:23:38 +00:00
|
|
|
; should we store as two arrays, one I one F?
|
2017-08-25 05:34:14 +00:00
|
|
|
fixed_sin:
|
|
|
|
.byte $00,$00 ; 0.000000=00.00
|
|
|
|
.byte $00,$61 ; 0.382683=00.61
|
|
|
|
.byte $00,$b5 ; 0.707107=00.b5
|
|
|
|
.byte $00,$ec ; 0.923880=00.ec
|
|
|
|
.byte $01,$00 ; 1.000000=01.00
|
|
|
|
.byte $00,$ec ; 0.923880=00.ec
|
|
|
|
.byte $00,$b5 ; 0.707107=00.b5
|
|
|
|
.byte $00,$61 ; 0.382683=00.61
|
|
|
|
.byte $00,$00 ; 0.000000=00.00
|
|
|
|
.byte $ff,$9f ; -0.382683=ff.9f
|
|
|
|
.byte $ff,$4b ; -0.707107=ff.4b
|
|
|
|
.byte $ff,$14 ; -0.923880=ff.14
|
|
|
|
.byte $ff,$00 ; -1.000000=ff.00
|
|
|
|
.byte $ff,$14 ; -0.923880=ff.14
|
|
|
|
.byte $ff,$4b ; -0.707107=ff.4b
|
|
|
|
.byte $ff,$9f ; -0.382683=ff.9f
|
|
|
|
|
|
|
|
fixed_sin_scale:
|
|
|
|
.byte $00,$00
|
|
|
|
.byte $00,$0c
|
|
|
|
.byte $00,$16
|
|
|
|
.byte $00,$1d
|
|
|
|
.byte $00,$20
|
|
|
|
.byte $00,$1d
|
|
|
|
.byte $00,$16
|
|
|
|
.byte $00,$0c
|
|
|
|
.byte $00,$00
|
|
|
|
.byte $ff,$f4
|
|
|
|
.byte $ff,$ea
|
|
|
|
.byte $ff,$e3
|
|
|
|
.byte $ff,$e0
|
|
|
|
.byte $ff,$e3
|
|
|
|
.byte $ff,$ea
|
|
|
|
.byte $ff,$f4
|
|
|
|
|
|
|
|
horizontal_lookup:
|
|
|
|
.byte $0C,$0A,$09,$08,$07,$06,$05,$05,$04,$04,$04,$04,$03,$03,$03,$03
|
|
|
|
.byte $26,$20,$1B,$18,$15,$13,$11,$10,$0E,$0D,$0C,$0C,$0B,$0A,$0A,$09
|
|
|
|
.byte $40,$35,$2D,$28,$23,$20,$1D,$1A,$18,$16,$15,$14,$12,$11,$10,$10
|
|
|
|
.byte $59,$4A,$40,$38,$31,$2C,$28,$25,$22,$20,$1D,$1C,$1A,$18,$17,$16
|
|
|
|
.byte $73,$60,$52,$48,$40,$39,$34,$30,$2C,$29,$26,$24,$21,$20,$1E,$1C
|
|
|
|
.byte $8C,$75,$64,$58,$4E,$46,$40,$3A,$36,$32,$2E,$2C,$29,$27,$25,$23
|
|
|
|
.byte $A6,$8A,$76,$68,$5C,$53,$4B,$45,$40,$3B,$37,$34,$30,$2E,$2B,$29
|