tfv: more work on flying code

This commit is contained in:
Vince Weaver 2017-08-27 00:11:53 -04:00
parent 65b72664ac
commit 36bab516c6
3 changed files with 89 additions and 13 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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