tfv: collision detect on worldmap works (mostly)

This commit is contained in:
Vince Weaver 2018-06-18 15:03:02 -04:00
parent f7092abe2c
commit 5059b4a805
7 changed files with 62 additions and 21 deletions

View File

@ -236,6 +236,30 @@ int scrn(unsigned char xcoord, unsigned char ycoord) {
return 0; return 0;
} }
int scrn_page(unsigned char xcoord, unsigned char ycoord, int page) {
unsigned char a,y,c;
a=ycoord;
y=xcoord;
c=a&1;
a=a>>1;
gbascalc(a);
ram[GBASH]+=page;
a=ram[y_indirect(GBASL,y)];
if (c) {
return a>>4;
}
else {
return a&0xf;
}
return 0;
}
static short gr_addr_lookup[24]={ static short gr_addr_lookup[24]={
0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780, 0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780,
0x428,0x4a8,0x528,0x5a8,0x628,0x6a8,0x728,0x7a8, 0x428,0x4a8,0x528,0x5a8,0x628,0x6a8,0x728,0x7a8,

View File

@ -11,6 +11,7 @@ int basic_vlin(int y1, int y2, int at);
int gr(void); int gr(void);
int bload(char *filename, int address); int bload(char *filename, int address);
int scrn(unsigned char xcoord, unsigned char ycoord); int scrn(unsigned char xcoord, unsigned char ycoord);
int scrn_page(unsigned char xcoord, unsigned char ycoord, int page);
int grsim_unrle(unsigned char *rle_data, int address); int grsim_unrle(unsigned char *rle_data, int address);
int home(void); int home(void);
int grsim_put_sprite_page(int page,unsigned char *sprite_data, int xpos, int ypos); int grsim_put_sprite_page(int page,unsigned char *sprite_data, int xpos, int ypos);

View File

@ -20,11 +20,15 @@ int main(int argc, char **argv) {
} }
color_equals(15); color_equals(15);
basic_vlin(0,40,20); basic_vlin(0,39,20);
color_equals(0); color_equals(0);
basic_hlin(0,40,20); basic_hlin(0,39,20);
printf("0: %d, 1: %d, 2: %d, 3: %d\n",
scrn(0,0),scrn(1,1),scrn(2,2),scrn(3,3));
printf("0: %d, 1: %d, 2: %d, 3: %d\n",
scrn_page(0,0,0),scrn_page(1,1,0),scrn_page(2,2,0),scrn_page(3,3,0));
while(1) { while(1) {
grsim_update(); grsim_update();

View File

@ -21,7 +21,7 @@ unsigned char steps=0;
/* location */ /* location */
//unsigned char map_x=5; //unsigned char map_x=5;
char tfv_x=15,tfv_y=19; char tfv_x=15,tfv_y=20; // tfv_y should always be even
unsigned char ground_color; unsigned char ground_color;
char nameo[9]; char nameo[9];

View File

@ -83,8 +83,17 @@ void show_map(void) {
//gr_copy(0x800,0x400); //gr_copy(0x800,0x400);
color_equals(COLOR_RED); color_equals(COLOR_RED);
printf("plot(%d,%d)\n",
8+((map_location&0x3)*6)+(tfv_x/6),
8+(((map_location&0xc)>>2)*6)+(tfv_y/6));
basic_plot(8+((map_location&0x3)*6)+(tfv_x/6),8+(((map_location&0xc)>>2)*6)+(tfv_y/6)); basic_plot(8+((map_location&0x3)*6)+(tfv_x/6),8+(((map_location&0xc)>>2)*6)+(tfv_y/6));
// basic_plot(8+((map_location&0x3)*6)+(tfv_x/6),8+(((map_location&0xc)>>2)*6)+(tfv_y/6));
ram[CH]=20; ram[CH]=20;
ram[CV]=20; move_and_print(map_info[map_location].name); ram[CV]=20; move_and_print(map_info[map_location].name);

View File

@ -61,7 +61,7 @@ struct map_info_type map_info[16] = {
.e_exit=NOEXIT, .e_exit=NOEXIT,
.w_exit=ARCTIC_MOUNTAINS, .w_exit=ARCTIC_MOUNTAINS,
.miny=4, .miny=4,
.ground_color=(COLOR_WHITE|(COLOR_WHITE<<4)), .ground_color=(COLOR_LIGHTBLUE|(COLOR_LIGHTBLUE<<4)),
.land_type=LAND_LIGHTNING, .land_type=LAND_LIGHTNING,
.scatter=SCATTER_NONE, .scatter=SCATTER_NONE,
.background_image=harfco_rle, .background_image=harfco_rle,

View File

@ -15,10 +15,6 @@
unsigned char map_location=LANDING_SITE; unsigned char map_location=LANDING_SITE;
/* In Town */
/* Puzzle Room */ /* Puzzle Room */
/* Get through office */ /* Get through office */
/* Have to run away? What happens if die? No save game? Code? */ /* Have to run away? What happens if die? No save game? Code? */
@ -31,8 +27,6 @@ unsigned char map_location=LANDING_SITE;
/* Play music, lightning effects? */ /* Play music, lightning effects? */
/* TFV only hit for one damage, susie for 100 */ /* TFV only hit for one damage, susie for 100 */
/* Walk through bushes, beach water */
/* Make landing a sprite? Stand behind things? */
/* Load background to 0xc00 */ /* Load background to 0xc00 */
static int load_map_bg(void) { static int load_map_bg(void) {
@ -143,14 +137,6 @@ int world_map(void) {
/* Landed */ /* Landed */
/************************************************/ /************************************************/
// TODO:
// 4x4 grid of island?
// proceduraly generated?
// can only walk if feet on green/yellow
// should features be sprites?
// rotate when attacked
gr(); gr();
color_equals(COLOR_BLACK); color_equals(COLOR_BLACK);
@ -169,6 +155,11 @@ int world_map(void) {
if ((ch=='q') || (ch==27)) break; if ((ch=='q') || (ch==27)) break;
if ((ch=='t')) {
for(i=0;i<12;i++) printf("scrn(%d,%d)=%d\n",
tfv_x+1,tfv_y+i,scrn_page(tfv_x+1,tfv_y+i,8));
}
if ((ch=='w') || (ch==APPLE_UP)) { if ((ch=='w') || (ch==APPLE_UP)) {
newy=tfv_y-2; newy=tfv_y-2;
moved=1; moved=1;
@ -223,7 +214,7 @@ int world_map(void) {
if (newx>36) { if (newx>36) {
if (map_info[map_location].e_exit!=NOEXIT) { if (map_info[map_location].e_exit!=NOEXIT) {
map_location=map_info[map_location].e_exit; map_location=map_info[map_location].e_exit;
tfv_x=0; tfv_x=1;
refresh=1; refresh=1;
} }
} }
@ -237,7 +228,7 @@ int world_map(void) {
else if (newy<map_info[map_location].miny) { else if (newy<map_info[map_location].miny) {
if (map_info[map_location].n_exit!=NOEXIT) { if (map_info[map_location].n_exit!=NOEXIT) {
map_location=map_info[map_location].n_exit; map_location=map_info[map_location].n_exit;
tfv_y=28; tfv_y=26;
refresh=1; refresh=1;
} }
} }
@ -248,10 +239,22 @@ int world_map(void) {
refresh=1; refresh=1;
} }
} }
else { else if ((scrn_page(newx+1,newy+11,8)==
(map_info[map_location].ground_color&
0xf)) &&
(scrn_page(newx+1,newy+11,8)==
(map_info[map_location].ground_color&
0xf))) {
tfv_x=newx; tfv_x=newx;
tfv_y=newy; tfv_y=newy;
} }
else {
printf("scrn(%d,%d)==%d,scrn(%d,%d)==%d\n",
newx+1,newy+11,scrn_page(newx+1,newy+11,8),
newx+2,newy+11,scrn_page(newx+2,newy+11,8));
// make sad noise
}
} }