2017-08-16 18:46:45 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gr-sim.h"
|
|
|
|
#include "tfv_utils.h"
|
|
|
|
#include "tfv_zp.h"
|
2018-06-13 04:32:46 +00:00
|
|
|
#include "tfv_defines.h"
|
2018-07-07 19:18:08 +00:00
|
|
|
#include "tfv_definitions.h"
|
2017-08-16 18:46:45 +00:00
|
|
|
|
|
|
|
#include "tfv_sprites.h"
|
|
|
|
#include "tfv_backgrounds.h"
|
|
|
|
|
2018-06-25 20:21:43 +00:00
|
|
|
#include "tfv_items.h"
|
|
|
|
#include "tfv_dialog.h"
|
|
|
|
|
2018-06-12 04:44:34 +00:00
|
|
|
#include "tfv_mapinfo.h"
|
|
|
|
|
2018-07-16 02:26:23 +00:00
|
|
|
// debug
|
2018-07-16 00:19:56 +00:00
|
|
|
static int random_encounters=1;
|
2018-06-25 19:59:53 +00:00
|
|
|
|
2018-06-13 04:32:46 +00:00
|
|
|
unsigned char map_location=LANDING_SITE;
|
|
|
|
|
2017-08-16 18:46:45 +00:00
|
|
|
/* Puzzle Room */
|
|
|
|
/* Get through office */
|
|
|
|
/* Have to run away? What happens if die? No save game? Code? */
|
|
|
|
|
|
|
|
/* Construct the LED circuit */
|
|
|
|
/* Zaps through cloud */
|
|
|
|
/* Susie joins your party */
|
|
|
|
|
|
|
|
/* Final Battle */
|
|
|
|
/* Play music, lightning effects? */
|
|
|
|
/* TFV only hit for one damage, susie for 100 */
|
|
|
|
|
|
|
|
|
2017-09-13 03:24:44 +00:00
|
|
|
/* Load background to 0xc00 */
|
2017-08-16 18:46:45 +00:00
|
|
|
static int load_map_bg(void) {
|
|
|
|
|
|
|
|
int i,temp;
|
|
|
|
int start,end;
|
|
|
|
|
2018-06-13 04:32:46 +00:00
|
|
|
ground_color=map_info[map_location].ground_color;
|
2017-08-16 18:46:45 +00:00
|
|
|
|
2018-06-15 04:08:15 +00:00
|
|
|
/* Load background image, if applicable */
|
|
|
|
if (map_info[map_location].background_image) {
|
|
|
|
grsim_unrle(map_info[map_location].background_image,0xc00);
|
2017-08-16 18:46:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sky */
|
|
|
|
color_equals(COLOR_MEDIUMBLUE);
|
|
|
|
for(i=0;i<10;i+=2) {
|
2017-09-13 18:32:08 +00:00
|
|
|
hlin_double(PAGE2,0,39,i);
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* grassland/sloped left beach */
|
2018-06-15 04:08:15 +00:00
|
|
|
if (map_info[map_location].land_type&LAND_LEFT_BEACH) {
|
2017-11-19 03:52:25 +00:00
|
|
|
for(i=10;i<40;i+=2) {
|
|
|
|
temp=4+(39-i)/8;
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_DARKBLUE);
|
2017-11-19 03:52:25 +00:00
|
|
|
hlin_double(PAGE2,0,temp,i);
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_LIGHTBLUE);
|
2017-11-19 03:52:25 +00:00
|
|
|
hlin_double_continue(2);
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_YELLOW);
|
2017-11-19 03:52:25 +00:00
|
|
|
hlin_double_continue(2);
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(ground_color);
|
2017-11-19 03:52:25 +00:00
|
|
|
hlin_double_continue(35-temp);
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Grassland */
|
2018-06-15 04:08:15 +00:00
|
|
|
if (map_info[map_location].land_type&LAND_GRASSLAND) {
|
2017-08-16 18:46:45 +00:00
|
|
|
for(i=10;i<40;i+=2) {
|
|
|
|
color_equals(ground_color);
|
2017-09-13 18:32:08 +00:00
|
|
|
hlin_double(PAGE2,0,39,i);
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mountain */
|
2018-06-15 04:08:15 +00:00
|
|
|
if (map_info[map_location].land_type&LAND_MOUNTAIN) {
|
2017-08-16 18:46:45 +00:00
|
|
|
for(i=10;i<40;i+=2) {
|
|
|
|
color_equals(ground_color);
|
2017-09-13 18:32:08 +00:00
|
|
|
hlin_double(PAGE2,0,39,i);
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-19 03:52:25 +00:00
|
|
|
/* Right Beach */
|
2018-06-15 04:08:15 +00:00
|
|
|
if (map_info[map_location].land_type&LAND_RIGHT_BEACH) {
|
2017-11-19 03:52:25 +00:00
|
|
|
for(i=10;i<40;i+=2) {
|
|
|
|
temp=24+(i/4); /* 26 ... 33 */
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(ground_color);
|
2017-11-19 03:52:25 +00:00
|
|
|
hlin_double(PAGE2,0,temp,i);
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_YELLOW);
|
2017-11-19 03:52:25 +00:00
|
|
|
hlin_double_continue(2); /* 28 ... 35 */
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_LIGHTBLUE);
|
2017-11-19 03:52:25 +00:00
|
|
|
hlin_double_continue(2); /* 30 ... 37 */
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_DARKBLUE);
|
2017-11-19 03:52:25 +00:00
|
|
|
hlin_double_continue(35-temp);
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw north shore */
|
2018-06-15 04:08:15 +00:00
|
|
|
if (map_info[map_location].land_type&LAND_NORTHSHORE) {
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_DARKBLUE);
|
2017-09-13 18:32:08 +00:00
|
|
|
hlin_double(PAGE2,0,39,10);
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw south shore */
|
2018-06-15 04:08:15 +00:00
|
|
|
if (map_info[map_location].land_type&LAND_SOUTHSHORE) {
|
2017-09-13 18:32:08 +00:00
|
|
|
start=0; end=39;
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_DARKBLUE);
|
2017-09-13 18:32:08 +00:00
|
|
|
hlin_double(PAGE2,0,39,38);
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_LIGHTBLUE);
|
2018-06-13 04:32:46 +00:00
|
|
|
if (map_location==12) start=6;
|
|
|
|
if (map_location==15) end=35;
|
2017-09-13 03:24:44 +00:00
|
|
|
hlin_double(PAGE2,start,end,36);
|
2018-06-13 04:32:46 +00:00
|
|
|
if (map_location==12) start=8;
|
|
|
|
if (map_location==15) end=32;
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_YELLOW);
|
2017-09-13 03:24:44 +00:00
|
|
|
hlin_double(PAGE2,start,end,34);
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
|
2017-11-19 03:52:25 +00:00
|
|
|
/* Mountains */
|
2018-06-15 04:08:15 +00:00
|
|
|
if (map_info[map_location].land_type&LAND_MOUNTAIN) {
|
2017-08-16 18:46:45 +00:00
|
|
|
for(i=0;i<4;i++) {
|
2017-09-13 03:24:44 +00:00
|
|
|
grsim_put_sprite_page(PAGE2,mountain,10+(i%2)*5,(i*8)+2);
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int world_map(void) {
|
|
|
|
|
|
|
|
int ch;
|
|
|
|
int direction=1;
|
2018-07-03 04:37:15 +00:00
|
|
|
int i,tree_limit;
|
2017-08-16 18:46:45 +00:00
|
|
|
int newx=0,newy=0,moved;
|
2018-06-24 05:01:44 +00:00
|
|
|
int special_destination=NOEXIT,destination_type=LOCATION_PLACE;
|
2018-07-16 02:26:23 +00:00
|
|
|
int next_encounter=32;
|
2018-07-16 00:19:56 +00:00
|
|
|
int odd=0;
|
|
|
|
int refresh=1;
|
|
|
|
int entry=0;
|
|
|
|
int on_bird=0;
|
|
|
|
int conversation_started=0;
|
|
|
|
int conversation_person=0;
|
2018-07-16 03:05:42 +00:00
|
|
|
int conversation_count=0;
|
2018-07-16 17:59:04 +00:00
|
|
|
int item_received=-1,health_restored=0,buy_smartpass=0;
|
2018-07-16 05:29:57 +00:00
|
|
|
int in_query=0;
|
2017-08-16 18:46:45 +00:00
|
|
|
|
|
|
|
/************************************************/
|
|
|
|
/* Landed */
|
|
|
|
/************************************************/
|
|
|
|
|
|
|
|
gr();
|
|
|
|
|
|
|
|
color_equals(COLOR_BLACK);
|
|
|
|
|
|
|
|
direction=1;
|
2018-07-16 00:19:56 +00:00
|
|
|
|
2017-08-16 18:46:45 +00:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
moved=0;
|
|
|
|
newx=tfv_x;
|
|
|
|
newy=tfv_y;
|
|
|
|
|
|
|
|
ch=grsim_input();
|
|
|
|
|
2018-07-14 03:36:01 +00:00
|
|
|
if (hp==0) break;
|
|
|
|
|
2017-08-16 18:46:45 +00:00
|
|
|
if ((ch=='q') || (ch==27)) break;
|
|
|
|
|
2018-06-18 19:03:02 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2017-08-16 18:46:45 +00:00
|
|
|
if ((ch=='w') || (ch==APPLE_UP)) {
|
|
|
|
newy=tfv_y-2;
|
|
|
|
moved=1;
|
|
|
|
}
|
|
|
|
if ((ch=='s') || (ch==APPLE_DOWN)) {
|
|
|
|
newy=tfv_y+2;
|
|
|
|
moved=1;
|
|
|
|
}
|
|
|
|
if ((ch=='a') || (ch==APPLE_LEFT)) {
|
|
|
|
if (direction>0) {
|
|
|
|
direction=-1;
|
|
|
|
odd=0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newx=tfv_x-1;
|
|
|
|
moved=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((ch=='d') || (ch==APPLE_RIGHT)) {
|
2018-07-16 00:19:56 +00:00
|
|
|
/* Update random seed */
|
|
|
|
random_8();
|
|
|
|
|
2017-08-16 18:46:45 +00:00
|
|
|
if (direction<0) {
|
|
|
|
direction=1;
|
|
|
|
odd=0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newx=tfv_x+1;
|
|
|
|
moved=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-14 04:21:21 +00:00
|
|
|
if (moved) conversation_started=0;
|
|
|
|
|
2017-09-14 19:12:38 +00:00
|
|
|
if (ch==13) {
|
2018-07-16 17:41:04 +00:00
|
|
|
|
|
|
|
health_restored=0;
|
|
|
|
|
2018-06-24 05:01:44 +00:00
|
|
|
if (destination_type==LOCATION_CONVERSATION) {
|
2018-07-03 17:47:42 +00:00
|
|
|
conversation_started=1;
|
|
|
|
conversation_person=special_destination;
|
2018-07-16 03:05:42 +00:00
|
|
|
|
2018-07-16 16:20:33 +00:00
|
|
|
/* HACK */
|
2018-07-16 17:41:04 +00:00
|
|
|
|
|
|
|
/* Action Done */
|
2018-07-16 16:20:33 +00:00
|
|
|
conversation_count=dialog[conversation_person].count;
|
|
|
|
if (dialog[conversation_person].statement[conversation_count].action==ACTION_DONE) {
|
|
|
|
conversation_started=0;
|
|
|
|
dialog[conversation_person].count=-1;
|
|
|
|
goto skip_all_this;
|
|
|
|
}
|
|
|
|
|
2018-07-16 17:41:04 +00:00
|
|
|
/* Get on Large Bird */
|
|
|
|
if (dialog[conversation_person].statement[conversation_count].action==ACTION_BIRD) {
|
|
|
|
printf("BIRD BIRD BIRD BIRD!\n");
|
|
|
|
on_bird=1;
|
|
|
|
conversation_started=0;
|
|
|
|
dialog[conversation_person].count=-1;
|
|
|
|
map_location=COLLEGE_PARK;
|
2018-07-16 17:59:04 +00:00
|
|
|
tfv_x=32;
|
2018-07-16 17:41:04 +00:00
|
|
|
tfv_y=5;
|
|
|
|
refresh=1;
|
|
|
|
goto skip_all_this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Action Time */
|
2018-07-16 16:20:33 +00:00
|
|
|
if (dialog[conversation_person].statement[conversation_count].action==ACTION_TIME) {
|
|
|
|
conversation_started=0;
|
|
|
|
dialog[conversation_person].count=-1;
|
|
|
|
if (time_hours<95) time_hours+=4;
|
|
|
|
goto skip_all_this;
|
|
|
|
}
|
|
|
|
|
2018-07-16 17:59:04 +00:00
|
|
|
/* Move to next conversation */
|
2018-07-14 04:21:21 +00:00
|
|
|
if (dialog[conversation_person].count==-1) {
|
|
|
|
dialog[conversation_person].count=0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dialog[conversation_person].count=
|
|
|
|
dialog[conversation_person].statement[dialog[conversation_person].count].next;
|
|
|
|
}
|
2018-07-16 03:05:42 +00:00
|
|
|
conversation_count=dialog[conversation_person].count;
|
2018-07-16 16:20:33 +00:00
|
|
|
|
|
|
|
|
2018-07-16 17:59:04 +00:00
|
|
|
/* Check for items */
|
2018-07-16 17:41:04 +00:00
|
|
|
if (dialog[conversation_person].statement[conversation_count].action==ACTION_ITEM) {
|
2018-07-16 16:20:33 +00:00
|
|
|
|
2018-07-16 17:41:04 +00:00
|
|
|
item_received=dialog[conversation_person].statement[conversation_count].item;
|
|
|
|
printf("ACTION ITEM %d\n",item_received);
|
|
|
|
|
|
|
|
/* Action Smartpass */
|
|
|
|
/* FIXME: make generic item buy? */
|
|
|
|
if (item_received==ITEM_SMARTPASS) {
|
2018-07-16 17:59:04 +00:00
|
|
|
if (buy_smartpass) {
|
|
|
|
|
|
|
|
printf("Trying to get smartpass!\n");
|
|
|
|
if (money<5) {
|
|
|
|
item_received=-1;
|
|
|
|
goto no_smartpass;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
money-=5;
|
|
|
|
}
|
2018-07-16 17:41:04 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-07-16 17:59:04 +00:00
|
|
|
item_received=-1;
|
|
|
|
goto no_smartpass;
|
2018-07-16 17:41:04 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-16 16:20:33 +00:00
|
|
|
|
|
|
|
|
2018-07-16 03:05:42 +00:00
|
|
|
if (item_received<8) {
|
|
|
|
items1|=(1<<item_received);
|
|
|
|
}
|
|
|
|
else if (item_received<16) {
|
|
|
|
items2|=(1<<(item_received&0x7));
|
|
|
|
}
|
|
|
|
else if (item_received<24) {
|
|
|
|
items3|=(1<<(item_received&0x7));
|
|
|
|
}
|
|
|
|
dialog[conversation_person].statement[conversation_count].action=ACTION_NONE;
|
2018-07-16 17:41:04 +00:00
|
|
|
no_smartpass:;
|
2018-07-16 03:05:42 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
item_received=-1;
|
|
|
|
}
|
2018-07-16 05:29:57 +00:00
|
|
|
if (dialog[conversation_person].statement[conversation_count].action==ACTION_QUERY) {
|
|
|
|
in_query=1;
|
|
|
|
}
|
2018-06-24 05:01:44 +00:00
|
|
|
}
|
|
|
|
else if (destination_type==LOCATION_SPACESHIP) {
|
|
|
|
return LOCATION_SPACESHIP;
|
|
|
|
}
|
2018-07-17 04:16:09 +00:00
|
|
|
else if (destination_type==LOCATION_PUZZLE) {
|
|
|
|
do_ending();
|
|
|
|
}
|
2018-06-24 05:01:44 +00:00
|
|
|
else if (special_destination!=NOEXIT) {
|
2018-06-22 19:22:05 +00:00
|
|
|
map_info[map_location].saved_x=tfv_x;
|
|
|
|
map_info[map_location].saved_y=tfv_y;
|
|
|
|
|
2018-06-18 21:02:13 +00:00
|
|
|
map_location=special_destination;
|
2018-06-22 19:22:05 +00:00
|
|
|
entry=1;
|
|
|
|
refresh=1;
|
2018-06-18 21:02:13 +00:00
|
|
|
}
|
2018-07-16 16:20:33 +00:00
|
|
|
skip_all_this: ;
|
2017-09-14 19:12:38 +00:00
|
|
|
}
|
|
|
|
|
2018-07-14 18:57:19 +00:00
|
|
|
if (ch=='h') {
|
|
|
|
print_help();
|
|
|
|
}
|
|
|
|
if (ch=='i') {
|
|
|
|
print_info();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch=='m') {
|
|
|
|
show_map();
|
|
|
|
refresh=1;
|
|
|
|
}
|
|
|
|
|
2018-07-16 03:10:38 +00:00
|
|
|
/* Only have encounters on world map */
|
|
|
|
if ((moved) && (map_location<16)) {
|
2018-07-16 00:19:56 +00:00
|
|
|
if (random_encounters) next_encounter--;
|
|
|
|
if (next_encounter==0) {
|
|
|
|
do_battle(map_info[map_location].ground_color);
|
|
|
|
refresh=1;
|
2018-07-16 02:26:23 +00:00
|
|
|
next_encounter=32+(random_8()%32);
|
2018-07-16 00:19:56 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-14 18:57:19 +00:00
|
|
|
|
|
|
|
/* debugging routines */
|
2017-09-19 04:43:17 +00:00
|
|
|
if (ch=='b') {
|
2018-07-09 20:47:59 +00:00
|
|
|
do_battle(map_info[map_location].ground_color);
|
2017-09-19 04:43:17 +00:00
|
|
|
refresh=1;
|
|
|
|
}
|
2018-07-14 18:57:19 +00:00
|
|
|
|
|
|
|
if (ch=='e') {
|
|
|
|
do_ending();
|
2017-08-16 18:46:45 +00:00
|
|
|
refresh=1;
|
|
|
|
}
|
|
|
|
|
2018-07-14 18:57:19 +00:00
|
|
|
|
|
|
|
|
2018-06-22 18:16:50 +00:00
|
|
|
/* Handle entry to a new area */
|
|
|
|
if (entry) {
|
|
|
|
printf("Entering!\n");
|
2018-06-22 19:22:05 +00:00
|
|
|
|
|
|
|
/* Y can never be 0 by accident */
|
|
|
|
if (map_info[map_location].saved_y) {
|
|
|
|
newx=map_info[map_location].saved_x;
|
|
|
|
newy=map_info[map_location].saved_y;
|
|
|
|
map_info[map_location].saved_x=0;
|
|
|
|
map_info[map_location].saved_y=0;
|
|
|
|
goto done_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-22 18:16:50 +00:00
|
|
|
if (map_info[map_location].entry_type&ENTRY_R_OR_L) {
|
|
|
|
if (tfv_x<20) newx=10;
|
|
|
|
else newx=30;
|
|
|
|
newy=26;
|
|
|
|
}
|
|
|
|
if (map_info[map_location].entry_type&ENTRY_EXPLICIT) {
|
|
|
|
newx=map_info[map_location].entry_x;
|
|
|
|
newy=map_info[map_location].entry_y;
|
|
|
|
}
|
|
|
|
if (map_info[map_location].entry_type&ENTRY_CENTER) {
|
|
|
|
newx=19;
|
|
|
|
newy=26;
|
|
|
|
}
|
2018-06-22 19:22:05 +00:00
|
|
|
if (map_info[map_location].entry_type&ENTRY_MINX) {
|
|
|
|
if (newx<map_info[map_location].entry_x) {
|
|
|
|
newx=map_info[map_location].entry_x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (map_info[map_location].entry_type&ENTRY_MAXX) {
|
|
|
|
if (newx>map_info[map_location].entry_x) {
|
|
|
|
newx=map_info[map_location].entry_x;
|
|
|
|
}
|
|
|
|
}
|
2018-06-22 18:16:50 +00:00
|
|
|
if (map_info[map_location].entry_type&ENTRY_MAXY) {
|
|
|
|
if (newy>map_info[map_location].entry_y) {
|
|
|
|
newy=map_info[map_location].entry_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-22 19:22:05 +00:00
|
|
|
done_entry:
|
|
|
|
|
2018-06-22 18:16:50 +00:00
|
|
|
entry=0;
|
|
|
|
//moved=1;
|
|
|
|
printf("Newx=%d,Newy=%d\n",newx,newy);
|
|
|
|
tfv_x=newx; tfv_y=newy;
|
|
|
|
}
|
|
|
|
|
2017-08-16 18:46:45 +00:00
|
|
|
|
|
|
|
/* Collision detection + Movement */
|
|
|
|
if (moved) {
|
|
|
|
odd=!odd;
|
|
|
|
steps++;
|
|
|
|
|
2018-06-18 15:58:36 +00:00
|
|
|
if (newx>36) {
|
|
|
|
if (map_info[map_location].e_exit!=NOEXIT) {
|
|
|
|
map_location=map_info[map_location].e_exit;
|
2018-06-18 19:03:02 +00:00
|
|
|
tfv_x=1;
|
2018-06-18 15:58:36 +00:00
|
|
|
refresh=1;
|
2018-06-22 18:16:50 +00:00
|
|
|
entry=1;
|
2018-06-18 15:58:36 +00:00
|
|
|
}
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
2018-06-18 15:58:36 +00:00
|
|
|
else if (newx<=0) {
|
|
|
|
if (map_info[map_location].w_exit!=NOEXIT) {
|
|
|
|
map_location=map_info[map_location].w_exit;
|
|
|
|
tfv_x=35;
|
|
|
|
refresh=1;
|
2018-06-22 18:16:50 +00:00
|
|
|
entry=1;
|
2018-06-18 15:58:36 +00:00
|
|
|
}
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
2018-06-18 15:59:47 +00:00
|
|
|
else if (newy<map_info[map_location].miny) {
|
2018-06-18 15:58:36 +00:00
|
|
|
if (map_info[map_location].n_exit!=NOEXIT) {
|
|
|
|
map_location=map_info[map_location].n_exit;
|
2018-06-18 19:03:02 +00:00
|
|
|
tfv_y=26;
|
2018-06-18 15:58:36 +00:00
|
|
|
refresh=1;
|
2018-06-22 18:16:50 +00:00
|
|
|
entry=1;
|
2018-06-18 15:58:36 +00:00
|
|
|
}
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
2018-06-18 15:58:36 +00:00
|
|
|
else if (newy>=28) {
|
|
|
|
if (map_info[map_location].s_exit!=NOEXIT) {
|
|
|
|
map_location=map_info[map_location].s_exit;
|
|
|
|
tfv_y=4;
|
|
|
|
refresh=1;
|
2018-06-22 18:16:50 +00:00
|
|
|
entry=1;
|
2018-06-18 15:58:36 +00:00
|
|
|
}
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
2018-06-18 19:03:02 +00:00
|
|
|
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))) {
|
|
|
|
|
2018-06-18 15:58:36 +00:00
|
|
|
tfv_x=newx;
|
|
|
|
tfv_y=newy;
|
|
|
|
}
|
2018-06-18 19:03:02 +00:00
|
|
|
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
|
|
|
|
}
|
2018-06-18 15:58:36 +00:00
|
|
|
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 18:32:08 +00:00
|
|
|
if (refresh) {
|
2018-01-08 19:01:19 +00:00
|
|
|
int s;
|
|
|
|
s=ram[DRAW_PAGE];
|
|
|
|
ram[DRAW_PAGE]=PAGE2;
|
|
|
|
clear_bottom();
|
|
|
|
ram[DRAW_PAGE]=s;
|
2017-09-13 18:32:08 +00:00
|
|
|
load_map_bg();
|
|
|
|
refresh=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gr_copy_to_current(0xc00);
|
|
|
|
|
2017-11-19 03:52:25 +00:00
|
|
|
/* Draw Background Ground Scatter */
|
2018-06-18 16:48:41 +00:00
|
|
|
if ((map_info[map_location].scatter) &&
|
|
|
|
(tfv_y>=map_info[map_location].scatter_cutoff)) {
|
2017-09-13 18:32:08 +00:00
|
|
|
|
2018-06-18 16:48:41 +00:00
|
|
|
if (map_info[map_location].scatter&SCATTER_SNOWYPINE) {
|
|
|
|
grsim_put_sprite(snowy_tree,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map_info[map_location].scatter&SCATTER_PINE) {
|
|
|
|
grsim_put_sprite(pine_tree,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (map_info[map_location].scatter&SCATTER_PALM) {
|
|
|
|
grsim_put_sprite(palm_tree,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
2017-09-13 18:32:08 +00:00
|
|
|
|
2018-06-18 16:48:41 +00:00
|
|
|
if (map_info[map_location].scatter&SCATTER_CACTUS) {
|
|
|
|
grsim_put_sprite(cactus,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
2018-06-20 19:35:05 +00:00
|
|
|
if (map_info[map_location].scatter&SCATTER_SPOOL) {
|
|
|
|
grsim_put_sprite(spool,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
2018-07-10 04:34:22 +00:00
|
|
|
if (map_info[map_location].scatter&SCATTER_JEN_LIZ) {
|
|
|
|
grsim_put_sprite(jen_liz,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
2018-06-18 16:48:41 +00:00
|
|
|
|
|
|
|
}
|
2017-09-13 18:32:08 +00:00
|
|
|
|
|
|
|
/* Draw Background Trees */
|
2018-06-18 16:48:41 +00:00
|
|
|
if (map_info[map_location].land_type&LAND_FOREST) {
|
2017-09-13 18:32:08 +00:00
|
|
|
for(i=10;i<tfv_y+8;i+=2) {
|
2018-07-03 04:37:15 +00:00
|
|
|
tree_limit=22+(i/4);
|
2017-09-13 18:32:08 +00:00
|
|
|
color_equals(COLOR_DARKGREEN);
|
2018-07-03 04:37:15 +00:00
|
|
|
hlin_double(ram[DRAW_PAGE],0,tree_limit,i);
|
2017-09-13 18:32:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-22 03:48:21 +00:00
|
|
|
if (on_bird) {
|
|
|
|
if (direction==-1) {
|
|
|
|
if (odd) grsim_put_sprite(bird_rider_walk_left,tfv_x,tfv_y);
|
|
|
|
else grsim_put_sprite(bird_rider_stand_left,tfv_x,tfv_y);
|
|
|
|
}
|
|
|
|
if (direction==1) {
|
|
|
|
if (odd) grsim_put_sprite(bird_rider_walk_right,tfv_x,tfv_y);
|
|
|
|
else grsim_put_sprite(bird_rider_stand_right,tfv_x,tfv_y);
|
|
|
|
}
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
2017-10-22 03:48:21 +00:00
|
|
|
else {
|
|
|
|
if (direction==-1) {
|
|
|
|
if (odd) grsim_put_sprite(tfv_walk_left,tfv_x,tfv_y);
|
|
|
|
else grsim_put_sprite(tfv_stand_left,tfv_x,tfv_y);
|
|
|
|
}
|
|
|
|
if (direction==1) {
|
|
|
|
if (odd) grsim_put_sprite(tfv_walk_right,tfv_x,tfv_y);
|
|
|
|
else grsim_put_sprite(tfv_stand_right,tfv_x,tfv_y);
|
|
|
|
}
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 18:32:08 +00:00
|
|
|
/* Draw Below Ground Scatter */
|
2018-06-18 16:48:41 +00:00
|
|
|
if ((map_info[map_location].scatter) &&
|
|
|
|
(tfv_y<map_info[map_location].scatter_cutoff)) {
|
|
|
|
|
|
|
|
if (map_info[map_location].scatter&SCATTER_SNOWYPINE) {
|
|
|
|
grsim_put_sprite(snowy_tree,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
2017-08-16 18:46:45 +00:00
|
|
|
|
2018-06-18 16:48:41 +00:00
|
|
|
if (map_info[map_location].scatter&SCATTER_PINE) {
|
|
|
|
grsim_put_sprite(pine_tree,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (map_info[map_location].scatter&SCATTER_PALM) {
|
|
|
|
grsim_put_sprite(palm_tree,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map_info[map_location].scatter&SCATTER_CACTUS) {
|
|
|
|
grsim_put_sprite(cactus,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
2018-06-20 19:35:05 +00:00
|
|
|
if (map_info[map_location].scatter&SCATTER_SPOOL) {
|
|
|
|
grsim_put_sprite(spool,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
2018-07-10 04:34:22 +00:00
|
|
|
if (map_info[map_location].scatter&SCATTER_JEN_LIZ) {
|
|
|
|
grsim_put_sprite(jen_liz,
|
|
|
|
map_info[map_location].scatter_x,
|
|
|
|
map_info[map_location].scatter_y);
|
|
|
|
}
|
|
|
|
|
2018-06-18 16:48:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map_info[map_location].land_type&LAND_FOREST) {
|
2017-11-19 03:52:25 +00:00
|
|
|
|
2017-09-13 18:32:08 +00:00
|
|
|
/* Draw Below Forest */
|
2017-08-16 18:46:45 +00:00
|
|
|
for(i=tfv_y+8;i<36;i+=2) {
|
2018-07-03 04:37:15 +00:00
|
|
|
tree_limit=22+(i/4);
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_DARKGREEN);
|
2018-07-03 04:37:15 +00:00
|
|
|
hlin_double(ram[DRAW_PAGE],0,tree_limit,i);
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
|
2017-11-19 03:52:25 +00:00
|
|
|
int f;
|
2017-09-13 18:32:08 +00:00
|
|
|
/* Draw tree trunks */
|
2017-11-19 03:52:25 +00:00
|
|
|
for(f=36;f<40;f+=2) {
|
2017-09-13 18:32:08 +00:00
|
|
|
|
2017-08-16 18:46:45 +00:00
|
|
|
color_equals(COLOR_BROWN);
|
2017-11-19 03:52:25 +00:00
|
|
|
hlin_double(ram[DRAW_PAGE],0,0,f);
|
|
|
|
|
|
|
|
for(i=0;i<13;i++) {
|
|
|
|
color_equals(COLOR_GREY);
|
|
|
|
hlin_double_continue(1);
|
|
|
|
color_equals(COLOR_BROWN);
|
|
|
|
hlin_double_continue(1);
|
|
|
|
}
|
2017-08-16 18:46:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-18 16:48:41 +00:00
|
|
|
if (map_info[map_location].land_type&LAND_LIGHTNING) {
|
2017-08-16 18:46:45 +00:00
|
|
|
if ((steps&0xf)==0) {
|
2017-09-13 03:24:44 +00:00
|
|
|
grsim_put_sprite(lightning,25,4);
|
2017-08-16 18:46:45 +00:00
|
|
|
/* Hurt hit points if in range? */
|
|
|
|
if ((tfv_x>25) && (tfv_x<30) && (tfv_y<12)) {
|
|
|
|
printf("HIT! %d %d\n\n",steps,hp);
|
|
|
|
if (hp>11) {
|
|
|
|
hp=10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-18 21:02:13 +00:00
|
|
|
special_destination=NOEXIT;
|
2018-06-26 03:34:57 +00:00
|
|
|
destination_type=LOCATION_PLACE;
|
2018-06-18 21:02:13 +00:00
|
|
|
for(i=0;i<map_info[map_location].num_locations;i++) {
|
2018-06-13 04:32:46 +00:00
|
|
|
|
2018-06-19 04:08:50 +00:00
|
|
|
if ( (tfv_x>=map_info[map_location].location[i].x0) &&
|
|
|
|
(tfv_x<=map_info[map_location].location[i].x1) &&
|
|
|
|
(tfv_y+11>=map_info[map_location].location[i].y0) &&
|
|
|
|
(tfv_y+11<=map_info[map_location].location[i].y1)) {
|
2018-06-13 04:32:46 +00:00
|
|
|
|
2018-06-19 04:08:50 +00:00
|
|
|
ram[CH]=(40-strlen(map_info[map_location].location[i].name))/2;
|
2018-06-18 21:02:13 +00:00
|
|
|
ram[CV]=20;
|
2018-06-19 04:08:50 +00:00
|
|
|
move_and_print(map_info[map_location].location[i].name);
|
2018-06-13 04:32:46 +00:00
|
|
|
|
2018-06-18 21:02:13 +00:00
|
|
|
special_destination=map_info[map_location].location[i].destination;
|
2018-06-24 05:01:44 +00:00
|
|
|
destination_type=map_info[map_location].location[i].type;
|
2018-06-22 19:22:05 +00:00
|
|
|
|
2018-06-18 21:02:13 +00:00
|
|
|
break;
|
2018-06-13 04:32:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-03 17:47:42 +00:00
|
|
|
if (conversation_started) {
|
2018-07-16 03:05:42 +00:00
|
|
|
char *item_name;
|
2018-07-03 17:47:42 +00:00
|
|
|
ram[CH]=1;
|
|
|
|
ram[CV]=21;
|
2018-07-14 04:21:21 +00:00
|
|
|
move_and_print(
|
|
|
|
dialog[conversation_person].statement[dialog[conversation_person].count].words);
|
2018-07-03 17:47:42 +00:00
|
|
|
// printf("%s\n",dialog[conversation_person].statement[0].words);
|
2018-07-16 03:05:42 +00:00
|
|
|
if (item_received!=-1) {
|
|
|
|
item_name=item_names[item_received>>3][item_received%8];
|
|
|
|
ram[CH]=(40-(15+strlen(item_name)))/2;
|
|
|
|
ram[CV]=23;
|
|
|
|
move_and_print("RECEIVED ITEM: ");
|
|
|
|
ram[CH]+=15;
|
|
|
|
move_and_print(item_name);
|
|
|
|
}
|
|
|
|
|
2018-07-16 17:41:04 +00:00
|
|
|
if (health_restored) {
|
|
|
|
ram[CH]=10;
|
|
|
|
ram[CV]=23;
|
|
|
|
move_and_print("HEALTH/MP RESTORED");
|
|
|
|
}
|
|
|
|
|
2018-07-03 17:47:42 +00:00
|
|
|
}
|
2018-06-13 04:32:46 +00:00
|
|
|
|
|
|
|
page_flip();
|
|
|
|
|
2018-07-16 05:29:57 +00:00
|
|
|
/* Take over keyboard if in query */
|
|
|
|
if (in_query) {
|
|
|
|
int saved_draw;
|
|
|
|
int which_line=0;
|
|
|
|
|
|
|
|
saved_draw=ram[DRAW_PAGE];
|
|
|
|
|
2018-07-16 17:41:04 +00:00
|
|
|
ram[DRAW_PAGE]=ram[DISP_PAGE]*4;
|
2018-07-16 05:29:57 +00:00
|
|
|
|
|
|
|
ram[CH]=5;
|
|
|
|
ram[CV]=22;
|
|
|
|
move_and_print(
|
|
|
|
dialog[conversation_person].statement[dialog[conversation_person].count+1].words);
|
2018-07-16 17:41:04 +00:00
|
|
|
|
|
|
|
printf("Printing %s at %d,%d page %d\n",
|
|
|
|
dialog[conversation_person].statement[dialog[conversation_person].count+1].words,
|
|
|
|
ram[CH],ram[CV],ram[DRAW_PAGE]);
|
|
|
|
|
2018-07-16 05:29:57 +00:00
|
|
|
ram[CH]=5;
|
|
|
|
ram[CV]=23;
|
|
|
|
move_and_print(
|
|
|
|
dialog[conversation_person].statement[dialog[conversation_person].count+2].words);
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
if (which_line==0) {
|
|
|
|
ram[CH]=0;
|
|
|
|
ram[CV]=22;
|
|
|
|
move_and_print("--> ");
|
|
|
|
ram[CH]=0;
|
|
|
|
ram[CV]=23;
|
|
|
|
move_and_print(" ");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ram[CH]=0;
|
|
|
|
ram[CV]=22;
|
|
|
|
move_and_print(" ");
|
|
|
|
ram[CH]=0;
|
|
|
|
ram[CV]=23;
|
|
|
|
move_and_print("--> ");
|
|
|
|
}
|
|
|
|
grsim_update();
|
|
|
|
// printf("Waiting\n");
|
|
|
|
ch=grsim_input();
|
|
|
|
// printf("OOGAH %d\n",ch);
|
|
|
|
if ((ch==APPLE_UP) || (ch==APPLE_DOWN)) {
|
|
|
|
which_line=!which_line;
|
|
|
|
}
|
|
|
|
if (ch==13) break;
|
|
|
|
usleep(100000);
|
|
|
|
}
|
|
|
|
dialog[conversation_person].count=
|
2018-07-16 17:41:04 +00:00
|
|
|
dialog[conversation_person].count+1+which_line;
|
|
|
|
// dialog[conversation_person].statement[dialog[conversation_person].count]+1+which_line;
|
2018-07-16 05:29:57 +00:00
|
|
|
ram[DRAW_PAGE]=saved_draw;
|
|
|
|
in_query=0;
|
2018-07-16 17:41:04 +00:00
|
|
|
|
2018-07-16 17:59:04 +00:00
|
|
|
/* Handle health restore */
|
2018-07-16 17:41:04 +00:00
|
|
|
conversation_count=dialog[conversation_person].count;
|
|
|
|
if (dialog[conversation_person].statement[conversation_count].action==ACTION_RESTORE) {
|
|
|
|
printf("RESTORE RESTORE RESTORE!\n");
|
|
|
|
hp=max_hp;
|
|
|
|
mp=max_mp;
|
|
|
|
health_restored=1;
|
|
|
|
}
|
|
|
|
|
2018-07-16 17:59:04 +00:00
|
|
|
if (dialog[conversation_person].statement[conversation_count].action==ACTION_SMARTPASS) {
|
|
|
|
printf("Attempt to buy!\n");
|
|
|
|
buy_smartpass=1;
|
|
|
|
}
|
|
|
|
|
2018-07-16 17:41:04 +00:00
|
|
|
dialog[conversation_person].count=
|
|
|
|
dialog[conversation_person].statement[dialog[conversation_person].count].next;
|
|
|
|
|
|
|
|
|
2018-07-16 05:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-13 04:32:46 +00:00
|
|
|
if (steps>=60) {
|
|
|
|
steps=0;
|
|
|
|
time_minutes++;
|
|
|
|
if (time_minutes>=60) {
|
|
|
|
time_hours++;
|
|
|
|
time_minutes=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
usleep(10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-06-18 21:02:13 +00:00
|
|
|
|
|
|
|
|