tfv: have minmal flying going on in 6502 version

This commit is contained in:
Vince Weaver 2017-08-23 15:41:37 -04:00
parent fe0ade564b
commit 5b9ad56cc1
10 changed files with 273 additions and 77 deletions

View File

@ -831,7 +831,7 @@ int grsim_put_sprite_page(int page, unsigned char *sprite_data, int xpos, int yp
while(1) {
address=gr_addr_lookup[ypos/2];
address+=(page*4)<<8;
address+=(page)<<8;
address+=xpos;
for(i=0;i<x;i++) {
a=*ptr;
@ -861,7 +861,7 @@ int grsim_put_sprite_page(int page, unsigned char *sprite_data, int xpos, int yp
int grsim_put_sprite(unsigned char *sprite_data, int xpos, int ypos) {
grsim_put_sprite_page(0,sprite_data,xpos,ypos);
grsim_put_sprite_page(ram[DRAW_PAGE],sprite_data,xpos,ypos);
return 0;
}
@ -1242,7 +1242,7 @@ int hlin(int page, int x1, int x2, int at) {
hlin_addr=gr_addr_lookup[at/2];
hlin_hi=at&1;
hlin_addr+=(page*4)<<8;
hlin_addr+=(page)<<8;
hlin_addr+=x1;
hlin_continue(x2-x1);
@ -1314,7 +1314,7 @@ int hlin_double(int page, int x1, int x2, int at) {
ram[GBASL]=(gr_addr_lookup[y])&0xff;
ram[GBASH]=(gr_addr_lookup[y]>>8);
ram[GBASH]+=(page*4);
ram[GBASH]+=(page);
ram[GBASL]+=x1;
hlin_double_continue(x2-x1);
@ -1331,7 +1331,7 @@ int collision(int xx, int yy, int ground_color) {
hlin_addr=gr_addr_lookup[yy/2];
hlin_addr+=(page*4)<<8;
hlin_addr+=(page)<<8;
hlin_addr+=xx;

View File

@ -95,3 +95,8 @@ void print_inverse(char *string);
#define DHIRES_ON 0xc05e // double-hires on
#define DHIRES_OFF 0xc05f // double-hires off
#define DHIRES_RD 0xc07f // double-hires read
#define PAGE0 0x0
#define PAGE1 0x4
#define PAGE2 0x8

View File

@ -41,13 +41,13 @@ int main(int argc, char **argv) {
/* clear top page0 */
/* clear top page1 */
clear_top(0);
clear_top(1);
clear_top(PAGE0);
clear_top(PAGE1);
/* clear bottom page0 */
/* clear bottom page1 */
clear_bottom(0);
clear_bottom(1);
clear_bottom(PAGE0);
clear_bottom(PAGE1);
/* Do Opening */
opening();

View File

@ -24,9 +24,13 @@ static unsigned char flying_map[64]= {
#define TILE_W 64
#define TILE_H 64
#define MASK_X (TILE_W - 1)
#define MASK_Y (TILE_H - 1)
#define LOWRES_W 40
#define LOWRES_H 40
static int mask_x = (TILE_W - 1);
static int mask_y = (TILE_H - 1);
static int lookup_map(int x, int y) {
@ -34,8 +38,8 @@ static int lookup_map(int x, int y) {
color=2;
x=x&mask_x;
y=y&mask_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;
@ -64,8 +68,7 @@ static int lookup_map(int x, int y) {
static double space_z=4.5; // height of the camera above the plane
static int horizon=-2; // number of pixels line 0 is below the horizon
static double scale_x=20, scale_y=20;
// scale of space coordinates to screen coordinates
static double bmp_w=40, bmp_h=40;
//void mode_7 (BITMAP *bmp, BITMAP *tile, fixed angle, fixed cx, fixed cy, MODE_7_PARAMS params)
@ -81,8 +84,6 @@ void draw_background_mode7(double angle, double cx, double cy) {
// the distance and horizontal scale of the line we are drawing
double distance, horizontal_scale;
// step for points in space between two pixels on a horizontal line
double line_dx, line_dy;
@ -92,23 +93,19 @@ void draw_background_mode7(double angle, double cx, double cy) {
over_water=0;
clear_top(0);
/* Draw Sky */
/* Originally wanted to be fancy and have sun too, but no */
color_equals(COLOR_MEDIUMBLUE);
for(screen_y=0;screen_y<6;screen_y+=2) {
hlin_double(0, 0, 40, screen_y);
hlin_double(ram[DRAW_PAGE], 0, 40, screen_y);
}
/* Draw hazy horizon */
color_equals(COLOR_GREY);
hlin_double(0, 0, 40, 6);
hlin_double(ram[DRAW_PAGE], 0, 40, 6);
// printf("%lf %lf\n",cx,cy);
for (screen_y = 8; screen_y < bmp_h; screen_y++) {
for (screen_y = 8; screen_y < LOWRES_H; screen_y++) {
// first calculate the distance of the line we are drawing
distance = (space_z * scale_y) / (screen_y + horizon);
@ -122,8 +119,8 @@ void draw_background_mode7(double angle, double cx, double cy) {
line_dy = cos(angle) * horizontal_scale;
// calculate the starting position
space_x = cx + (distance * cos(angle)) - bmp_w/2 * line_dx;
space_y = cy + (distance * sin(angle)) - bmp_w/2 * line_dy;
space_x = cx + (distance * cos(angle)) - LOWRES_W/2 * line_dx;
space_y = cy + (distance * sin(angle)) - LOWRES_W/2 * line_dy;
// Move camera back a bit
@ -138,36 +135,39 @@ void draw_background_mode7(double angle, double cx, double cy) {
// go through all points in this screen line
for (screen_x = 0; screen_x < bmp_w; screen_x++) {
for (screen_x = 0; screen_x < LOWRES_W-1; screen_x++) {
// get a pixel from the tile and put it on the screen
map_color=lookup_map((int)space_x,(int)space_y);
//(flying_map[(int)space_x & mask_x]
//[(int)space_y&mask_y]);
color_equals(map_color);
ram[COLOR]=map_color;
ram[COLOR]|=map_color<<4;
if (screen_x==20) {
if (map_color==COLOR_DARKBLUE) over_water=1;
else over_water=0;
}
basic_plot(screen_x,screen_y);
hlin_double(ram[DRAW_PAGE], screen_x, screen_x+1,
screen_y);
//basic_plot(screen_x,screen_y);
// advance to the next position in space
space_x += line_dx;
space_y += line_dy;
}
}
}
#define SHIPX 15
int flying(void) {
unsigned char ch;
int xx,yy;
int shipy;
int turning=0;
double flyx=0,flyy=0;
double our_angle=0.0;
@ -179,7 +179,7 @@ int flying(void) {
/************************************************/
gr();
xx=15; yy=20;
shipy=20;
while(1) {
if (draw_splash>0) draw_splash--;
@ -206,16 +206,16 @@ int flying(void) {
#endif
if ((ch=='w') || (ch==APPLE_UP)) {
if (yy>16) {
yy-=2;
if (shipy>16) {
shipy-=2;
space_z+=1;
}
printf("Z=%lf\n",space_z);
}
if ((ch=='s') || (ch==APPLE_DOWN)) {
if (yy<28) {
yy+=2;
if (shipy<28) {
shipy+=2;
space_z-=1;
}
else {
@ -273,39 +273,39 @@ int flying(void) {
if (turning==0) {
if ((speed>0.0) && (over_water)&&(draw_splash)) {
grsim_put_sprite_page(0,splash_forward,
xx+1,yy+9);
grsim_put_sprite(splash_forward,
SHIPX+1,shipy+9);
}
grsim_put_sprite_page(0,shadow_forward,xx+3,31+space_z);
grsim_put_sprite_page(0,ship_forward,xx,yy);
grsim_put_sprite(shadow_forward,SHIPX+3,31+space_z);
grsim_put_sprite(ship_forward,SHIPX,shipy);
}
if (turning<0) {
if ((yy>25) && (speed>0.0)) draw_splash=1;
if ((shipy>25) && (speed>0.0)) draw_splash=1;
if (over_water&&draw_splash) {
grsim_put_sprite_page(0,splash_left,
xx+1,36);
grsim_put_sprite(splash_left,
SHIPX+1,36);
}
grsim_put_sprite_page(0,shadow_left,xx+3,31+space_z);
grsim_put_sprite_page(0,ship_left,xx,yy);
grsim_put_sprite(shadow_left,SHIPX+3,31+space_z);
grsim_put_sprite(ship_left,SHIPX,shipy);
turning++;
}
if (turning>0) {
if ((yy>25) && (speed>0.0)) draw_splash=1;
if ((shipy>25) && (speed>0.0)) draw_splash=1;
if (over_water&&draw_splash) {
grsim_put_sprite_page(0,splash_right,
xx+1,36);
grsim_put_sprite(splash_right,
SHIPX+1,36);
}
grsim_put_sprite_page(0,shadow_right,xx+3,31+space_z);
grsim_put_sprite_page(0,ship_right,xx,yy);
grsim_put_sprite(shadow_right,SHIPX+3,31+space_z);
grsim_put_sprite(ship_right,SHIPX,shipy);
turning--;
}
grsim_update();
page_flip();
usleep(20000);

View File

@ -75,7 +75,7 @@ static int load_map_bg(void) {
/* Sky */
color_equals(COLOR_MEDIUMBLUE);
for(i=0;i<10;i+=2) {
hlin_double(1,0,40,i);
hlin_double(4,0,40,i);
}
if (map_x<4) ground_color=(COLOR_WHITE|(COLOR_WHITE<<4));
@ -87,7 +87,7 @@ static int load_map_bg(void) {
for(i=10;i<40;i++) {
temp=4+(40-i)/8;
color_equals(COLOR_DARKBLUE);
hlin(1,0,temp,i);
hlin(4,0,temp,i);
color_equals(COLOR_LIGHTBLUE);
hlin_continue(2);
color_equals(COLOR_YELLOW);
@ -101,7 +101,7 @@ static int load_map_bg(void) {
if ((map_x&3)==1) {
for(i=10;i<40;i+=2) {
color_equals(ground_color);
hlin_double(1,0,40,i);
hlin_double(4,0,40,i);
}
}
@ -109,7 +109,7 @@ static int load_map_bg(void) {
if ((map_x&3)==2) {
for(i=10;i<40;i+=2) {
color_equals(ground_color);
hlin_double(1,0,40,i);
hlin_double(4,0,40,i);
}
}
@ -119,7 +119,7 @@ static int load_map_bg(void) {
temp=24+(i/4);
/* 32 ... 40 */
color_equals(ground_color);
hlin(1,0,temp,i);
hlin(4,0,temp,i);
color_equals(COLOR_YELLOW);
hlin_continue(2);
color_equals(COLOR_LIGHTBLUE);
@ -133,22 +133,22 @@ static int load_map_bg(void) {
/* Draw north shore */
if (map_x<4) {
color_equals(COLOR_DARKBLUE);
hlin_double(1,0,40,10);
hlin_double(4,0,40,10);
}
/* Draw south shore */
if (map_x>=12) {
start=0; end=40;
color_equals(COLOR_DARKBLUE);
hlin_double(1,0,40,38);
hlin_double(4,0,40,38);
color_equals(COLOR_LIGHTBLUE);
if (map_x==12) start=6;
if (map_x==15) end=35;
hlin_double(1,start,end,36);
hlin_double(4,start,end,36);
if (map_x==12) start=8;
if (map_x==15) end=32;
color_equals(COLOR_YELLOW);
hlin_double(1,start,end,34);
hlin_double(4,start,end,34);
}
if ((map_x&3)==2) {

View File

@ -15,6 +15,31 @@
#define OUTL 0xfe
#define OUTH 0xff
/* Zero page addresses */
#define WNDLFT 0x20
#define WNDWDTH 0x21
#define WNDTOP 0x22
#define WNDBTM 0x23
#define CH 0x24
#define CV 0x25
#define GBASL 0x26
#define GBASH 0x27
#define BASL 0x28
#define BASH 0x29
#define BAS2L 0x2A
#define BAS2H 0x2B
#define H2 0x2C
#define V2 0x2D
#define MASK 0x2E
#define COLOR 0x30
#define INVFLG 0x32
#define YSAV 0x34
#define YSAV1 0x35
#define CSWL 0x36
#define CSWH 0x37
/* stats */
extern unsigned char level;
extern unsigned char hp,max_hp;

Binary file not shown.

View File

@ -1,12 +1,25 @@
SHIPY EQU $E4
; FIXME, sort out available ZP page space
TURNING EQU $40
SHIPX EQU 15
flying_start:
; Clear screen/pages
jsr set_gr_page0
flying_loop:
jsr gr_copy_to_current
; Init Variables
lda #20
sta SHIPY
lda #0
sta TURNING
flying_loop:
jsr put_sprite
jsr wait_until_keypressed
@ -19,27 +32,153 @@ skipskip:
cmp #('I')
bne check_down
dec YPOS
dec YPOS
lda SHIPY
cmp #16
bcc check_down ; bgt
dec SHIPY
dec SHIPY
check_down:
cmp #('M')
bne check_left
inc YPOS
inc YPOS
lda SHIPY
cmp #28
bcs check_left ; ble
inc SHIPY
inc SHIPY
check_left:
cmp #('J')
bne check_right
dec XPOS
inc TURNING
check_right:
cmp #('K')
bne check_done
inc XPOS
dec TURNING
check_done:
;====================
; Draw the background
;====================
jsr draw_background_mode7
;==============
; Draw the ship
;==============
clv
lda TURNING
bmi draw_ship_right
bne draw_ship_left
draw_ship_forward:
lda #>ship_forward
sta INH
lda #<ship_forward
sta INL
bvc draw_ship
draw_ship_right:
lda #>ship_right
sta INH
lda #<ship_right
sta INL
bvc draw_ship
draw_ship_left:
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
;==================
jmp flying_loop
;===========================
; Draw the Mode7 Background
;===========================
draw_background_mode7:
; Draw Sky
lda #COLOR_BOTH_MEDIUMBLUE
sta COLOR
lda #0
sky_loop:
ldy #40
sty V2
ldy #0
pha
jsr hlin_double
pla
clc
adc #2
cmp #6
bne sky_loop
; Draw Horizon
lda #COLOR_BOTH_GREY
sta COLOR
lda #6
ldy #40
sty V2
jsr hlin_double
; Temporarily Draw Ocean Everywhere
lda #COLOR_BOTH_DARKBLUE
sta COLOR
lda #6
sea_loop:
ldy #40
sty V2
ldy #0
pha
jsr hlin_double
pla
clc
adc #2
cmp #40
bne sea_loop
rts
flying_map:
.byte 2,15,15,15, 15,15,15, 2
.byte 13,12,12, 8, 4, 4, 0,13
.byte 13,12,12,12, 8, 4, 4,13
.byte 13,12,12, 8, 4, 4, 4,13
.byte 13,12, 9, 9, 8, 4, 4,13
.byte 13,12, 9, 8, 4, 4, 4,13
.byte 13,12, 9, 9, 1, 4, 4,13
.byte 2,13,13,13, 13,13,13, 2

View File

@ -318,12 +318,15 @@ save_key:
;=============================================
; put_sprite
;=============================================
; Sprite to display in INH,INL
; Location is XPOS,YPOS
put_sprite:
lda #>tb1_sprite ; hardcoded for tb1 for now
sta INH
lda #<tb1_sprite
sta INL
; lda #>tb1_sprite ; hardcoded for tb1 for now
; sta INH
; lda #<tb1_sprite
; sta INL
ldy #0 ; byte 0 is xsize
lda (INL),Y
@ -346,6 +349,7 @@ put_sprite_loop:
adc XPOS ; add in xpos
sta OUTL ; store out low byte of addy ; 3
lda gr_offsets+1,Y ; look up high byte ; 5
adc DRAW_PAGE ;
sta OUTH ; and store it out ; 3
ldy TEMP ; restore sprite pointer ; 3
@ -482,6 +486,7 @@ vlin_too_slow:
; hlin_double:
;================================
; VLIN Y, V2 AT A
; Y, X, A trashed
hlin_double:
;int hlin_double(int page, int x1, int x2, int at) {

View File

@ -89,3 +89,25 @@ INH EQU $FD
OUTL EQU $FE
OUTH EQU $FF
COLOR_BLACK EQU 0
COLOR_RED EQU 1
COLOR_DARKBLUE EQU 2
COLOR_PURPLE EQU 3
COLOR_DARKGREEN EQU 4
COLOR_GREY EQU 5
COLOR_MEDIUMBLUE EQU 6
COLOR_LIGHTBLUE EQU 7
COLOR_BROWN EQU 8
COLOR_ORANGE EQU 9
COLOR_GREY2 EQU 10
COLOR_PINK EQU 11
COLOR_LIGHTGREEN EQU 12
COLOR_YELLOW EQU 13
COLOR_AQUA EQU 14
COLOR_WHITE EQU 15
COLOR_BOTH_DARKBLUE EQU $22
COLOR_BOTH_GREY EQU $55
COLOR_BOTH_MEDIUMBLUE EQU $66