Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
8407a85
Clear create attr 12 in Zork1
MarcCote Sep 27, 2021
40d11fb
If PC is different from last PC, then assume state has changed.
MarcCote Sep 27, 2021
dcfeda5
Add unrecognized template (from acorncourt). Add ILLEGAL action.
MarcCote Sep 27, 2021
07e2bb5
Add test file to bench_valid_action
MarcCote Sep 27, 2021
cc96475
Set object count according to the output of Infodump.
MarcCote Sep 27, 2021
48df322
Making sure commands in walkthrough causes world_changed.
MarcCote Oct 8, 2021
8402e62
Add script to help finding special ram.
MarcCote Nov 10, 2021
d42e6ab
Testing more games
MarcCote Nov 11, 2021
b3688bc
Testing more games + better handle leading newlines/whitespaces
MarcCote Nov 11, 2021
489220f
Add missing md5.h file
MarcCote Nov 12, 2021
15bf5e6
Improve testing tools + planetfall
MarcCote Nov 17, 2021
483c7b6
Disable status line for z3 or lower.
MarcCote Nov 17, 2021
3fd2229
Fix getRetPC
MarcCote Nov 17, 2021
b538903
Refactor find_special_ram
MarcCote Nov 17, 2021
9d79eb2
Add get_calls_stack as a more precise alternative to getRetPC
MarcCote Nov 17, 2021
52c3336
Planetfall and plundered
MarcCote Nov 17, 2021
64d1c28
Reverb
MarcCote Nov 17, 2021
59c0a72
seastalker
MarcCote Nov 17, 2021
bf64560
ENH: separate buffer for upper (status line) and lower screen
MarcCote Nov 23, 2021
95be1a2
Tweak find_special_ram.py
MarcCote Nov 24, 2021
16c0a9e
Sherlock
MarcCote Nov 24, 2021
c2bd1de
Snacktime
MarcCote Nov 24, 2021
3b4a2b1
Sorcerer
MarcCote Nov 24, 2021
0571736
Spellbrkr
MarcCote Nov 24, 2021
e2d7cf7
temple
MarcCote Nov 24, 2021
49e81e2
theatre
MarcCote Nov 25, 2021
0f5ba62
trinity
MarcCote Nov 25, 2021
d950360
tryst205
MarcCote Nov 25, 2021
114ab23
weapon
MarcCote Nov 25, 2021
0643307
wishbringer
MarcCote Nov 25, 2021
20904dc
yomomma
MarcCote Nov 25, 2021
e3b3271
zenon
MarcCote Nov 25, 2021
e708fb0
Zork1
MarcCote Nov 25, 2021
3a62063
Zork2
MarcCote Nov 25, 2021
0fa2b4a
Zork3
MarcCote Nov 25, 2021
ef6306f
spirit
MarcCote Nov 25, 2021
c1aba4f
FIX: step -> jericho_step to avoid name clashing with regexp.c:step f…
MarcCote Nov 26, 2021
89d5fc3
Tidy up the PR
MarcCote Dec 16, 2021
9d2af0e
Add Matthew's script to test walkthrough.
MarcCote Dec 16, 2021
b9fc0a0
Fix memory issue.
MarcCote Dec 16, 2021
5143731
FIX: wrong memcmp size for special_ram.
MarcCote Jan 11, 2022
5508cf5
Noop checks for curses.z5
MarcCote Jan 12, 2022
732b0f2
Noop check: advent.z5
MarcCote Jan 17, 2022
a04c289
Noop check: afflicted.z8
MarcCote Jan 17, 2022
5870a2f
Improve test_games.py script to display better diff between objects a…
MarcCote Jan 18, 2022
dcf757e
Noop check: anchor.z8
MarcCote Jan 18, 2022
a956daa
Noop check: balances.z5
MarcCote Jan 18, 2022
bb3b6e9
Util function to clear_attr of a zobject
MarcCote Jan 19, 2022
de131ae
Noop check: ballyhoo.z3
MarcCote Jan 19, 2022
7cfe88e
Flush buffer before getting screen. Trim leading/trailing whitespace …
MarcCote Jan 20, 2022
bfa92a3
Noop check: cutthroat
MarcCote Jan 21, 2022
815754d
Noop check: deephome
MarcCote Jan 21, 2022
da86a5b
Noop check: detective
MarcCote Jan 21, 2022
6f66fec
Noop check: dragon
MarcCote Jan 21, 2022
de7c43e
Util function to clear a property of a zobject
MarcCote Jan 21, 2022
fce1a87
Noop check: enchanter
MarcCote Jan 21, 2022
0b6fbab
Noop check: enter
MarcCote Jan 21, 2022
c20f5ea
Noop check: gold
MarcCote Jan 21, 2022
b2d277f
Noop check: hhgg
MarcCote Jan 28, 2022
5245fba
Noop check: hollywood
MarcCote Feb 2, 2022
b6a440d
Noop check: huntdark
MarcCote Feb 2, 2022
0c87558
Noop check: infidel
MarcCote Feb 2, 2022
4fb314f
Sort interactable objects.
MarcCote Feb 2, 2022
61c3af9
Noop check: inhumane
MarcCote Feb 2, 2022
a5e492f
Noop check: jewel
MarcCote Feb 2, 2022
ce3388d
Noop check: karn
MarcCote Feb 2, 2022
60b36ff
Noop check: library
MarcCote Feb 2, 2022
b946067
Noop check: loose
MarcCote Feb 2, 2022
68242f0
Noop check: loose.z5
MarcCote Feb 4, 2022
9aa45ef
Tweak test_games.py to detect unused special ram addresses.
MarcCote Feb 9, 2022
869a950
Noop check: lostpig
MarcCote Feb 9, 2022
8baa787
Noop check: ludicorp
MarcCote Feb 9, 2022
87ed928
Improve debugging tools
MarcCote Feb 11, 2022
87eb5fc
Noop check: lurking
MarcCote Feb 11, 2022
bd99c9e
Noop check: moonlit
MarcCote Feb 12, 2022
e4e4ce8
Halt emulator on z_quit
MarcCote Feb 19, 2022
25fbed5
FIX: do not assume RAM size is even.
MarcCote Feb 19, 2022
dfbf697
Noop check: murdac
MarcCote Feb 21, 2022
39b6f8d
Noop check: night
MarcCote Feb 21, 2022
93cff3f
Noop check: omniquest
MarcCote Feb 21, 2022
9c4f9fa
Noop check: partyfoul + add option to skip z_read_char
MarcCote Feb 21, 2022
88f15eb
Noop check: pentari
MarcCote Feb 22, 2022
9348e2d
Fix md5 import
MarcCote Jan 6, 2025
8bea90c
Improve find_special_ram printing
MarcCote Jan 6, 2025
2634772
Improve checks for anchor.c
MarcCote Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion frotz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CC ?= gcc

# Enable compiler warnings. This is an absolute minimum.
CFLAGS += -Wall -Wextra -std=gnu99 -fPIC -Werror=implicit-function-declaration
CFLAGS = -w

# Define your optimization flags.
#
Expand All @@ -20,7 +21,8 @@ CFLAGS += -Wall -Wextra -std=gnu99 -fPIC -Werror=implicit-function-declaration
# OPTS = -O3 -fomit-frame-pointer -falign-functions=2 -falign-loops=2 -falign-jumps=2 -fPIC
OPTS = -O3 -fPIC
# These are handy for debugging.
# OPTS = $(CFLAGS) -g -fPIC
# OPTS = $(CFLAGS) -O3 -g -fPIC # With optimization (faster code)
# OPTS = $(CFLAGS) -g -fPIC # Without optimization (slower code)
# These are handy for profiling
# OPTS = $(CFLAGS) -pg -fPIC

Expand Down
15 changes: 0 additions & 15 deletions frotz/src/common/frotz.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,21 +550,6 @@ extern char *option_zcode_path; /* dg */

extern long reserve_mem;

// Keep track of the last n=16 changes to object tree
extern int move_diff_cnt;
extern zword move_diff_objs[16];
extern zword move_diff_dest[16];

// Keep track of the last n=16 changes to obj attributes
extern int attr_diff_cnt;
extern zword attr_diff_objs[16];
extern zword attr_diff_nb[16];

// Keep track of the last n=16 clears of obj attributes
extern int attr_clr_cnt;
extern zword attr_clr_objs[16];
extern zword attr_clr_nb[16];

// Keep track of up to n=16 changes to special ram locations defined by the game
extern int ram_diff_cnt;
extern zword ram_diff_addr[16];
Expand Down
35 changes: 0 additions & 35 deletions frotz/src/common/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@
#define O4_PROPERTY_OFFSET 12
#define O4_SIZE 14

int move_diff_cnt;
zword move_diff_objs[16];
zword move_diff_dest[16];
int attr_diff_cnt;
zword attr_diff_objs[16];
zword attr_diff_nb[16];
int attr_clr_cnt;
zword attr_clr_objs[16];
zword attr_clr_nb[16];

/*
* object_address
*
Expand Down Expand Up @@ -451,14 +441,6 @@ void z_clear_attr (void)
if (zargs[1] > ((h_version <= V3) ? 31 : 47))
runtime_error (ERR_ILL_ATTR);

/* If we are monitoring attribute assignment display a short note */

if (attr_clr_cnt < 16) {
attr_clr_objs[attr_clr_cnt] = zargs[0];
attr_clr_nb[attr_clr_cnt] = zargs[1];
attr_clr_cnt++;
}

if (f_setup.attribute_assignment) {
stream_mssg_on ();
print_string ("@clear_attr ");
Expand Down Expand Up @@ -1063,14 +1045,6 @@ void z_insert_obj (void)
zword obj1_addr;
zword obj2_addr;

/* If we are monitoring object movements display a short note */

if (move_diff_cnt < 16) {
move_diff_objs[move_diff_cnt] = obj1;
move_diff_dest[move_diff_cnt] = obj2;
move_diff_cnt++;
}

if (f_setup.object_movement) {
stream_mssg_on ();
print_string ("@move_obj ");
Expand Down Expand Up @@ -1194,7 +1168,6 @@ void z_put_prop (void)
*/
void z_remove_obj (void)
{
/* If we are monitoring object movements display a short note */

if (f_setup.object_movement) {
stream_mssg_on ();
Expand Down Expand Up @@ -1229,14 +1202,6 @@ void z_set_attr (void)
if (zargs[1] > ((h_version <= V3) ? 31 : 47))
runtime_error (ERR_ILL_ATTR);

/* If we are monitoring attribute assignment display a short note */

if (attr_diff_cnt < 16) {
attr_diff_objs[attr_diff_cnt] = zargs[0];
attr_diff_nb[attr_diff_cnt] = zargs[1];
attr_diff_cnt++;
}

if (f_setup.attribute_assignment) {
stream_mssg_on ();
print_string ("@set_attr ");
Expand Down
1 change: 1 addition & 0 deletions frotz/src/common/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ void z_nop (void)
void z_quit (void)
{
finished = 9999;
emulator_halted = 2;

}/* z_quit */

Expand Down
2 changes: 1 addition & 1 deletion frotz/src/common/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ void z_show_status (void)
/* One V5 game (Wishbringer Solid Gold) contains this opcode by
accident, so just return if the version number does not fit */

if (h_version >= V4)
if (h_version >= V4 || h_config & CONFIG_NOSTATUSLINE)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip printing the status line when the corresponding option is set. This simplifies the clean_observation_... functions.

return;

/* Read all relevant global variables from the memory of the
Expand Down
1 change: 1 addition & 0 deletions frotz/src/dumb/dumb_frotz.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void dumb_set_picture_cell(int row, int col, char c);
void dumb_row_to_str(char *s);
void dumb_clear_output(void);
char* dumb_get_screen(void);
char* dumb_get_lower_screen(void);
void dumb_clear_screen(void);

/* dumb-pic.c */
Expand Down
63 changes: 54 additions & 9 deletions frotz/src/dumb/dumb_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ static cell make_cell(int style, char c) {return (style << 8) | (0xff & c);}
static char cell_char(cell c) {return c & 0xff;}
static int cell_style(cell c) {return c >> 8;}

#define UPPER_SCREEN_BUFF_SIZE 256
#define SCREEN_BUFF_SIZE 8192
static char screen_buffer[SCREEN_BUFF_SIZE];
static char screen_buffer[SCREEN_BUFF_SIZE]; // aka window 0 (lower screen)
static char upper_screen_buffer[UPPER_SCREEN_BUFF_SIZE]; // aka window 1 (upper screen)

char* screen_buffer_ptr = screen_buffer;
char* upper_screen_buffer_ptr = upper_screen_buffer;

/* A cell's style is REVERSE_STYLE, normal (0), or PICTURE_STYLE.
* PICTURE_STYLE means the character is part of an ascii image outline
Expand Down Expand Up @@ -114,7 +118,12 @@ int os_string_width (const zchar *s)

void os_set_cursor(int row, int col)
{
cursor_row = row - 1; cursor_col = col - 1;
//printf("\n--> win:%d\trow:%d\tcol:%d MAX_COLS:%d<--\n", cwin, row, col, h_screen_cols);
if (cwin == 1 && row == 1) {
upper_screen_buffer_ptr = upper_screen_buffer + (col-1);
}

cursor_row = row - 1; cursor_col = col - 1; // 0-index
if (cursor_row >= h_screen_rows)
cursor_row = h_screen_rows - 1;
}
Expand Down Expand Up @@ -148,9 +157,16 @@ void os_set_text_style(int x)
/* put a character in the cell at the cursor and advance the cursor. */
static void dumb_display_char(char c)
{
if ((screen_buffer_ptr - screen_buffer) < (SCREEN_BUFF_SIZE - 1)) {
*screen_buffer_ptr++ = c;
}
if (cwin == 1 && cursor_row == 0) {
if ((upper_screen_buffer_ptr - upper_screen_buffer) < (UPPER_SCREEN_BUFF_SIZE - 1)) {
*upper_screen_buffer_ptr++ = c;
}
}
else {
if ((screen_buffer_ptr - screen_buffer) < (SCREEN_BUFF_SIZE - 1)) {
*screen_buffer_ptr++ = c;
}
}
}

void dumb_display_user_input(char *s)
Expand Down Expand Up @@ -210,7 +226,7 @@ void os_display_string (const zchar *s)
}
}

void os_erase_area (int top, int left, int bottom, int right, int UNUSED (win))
void os_erase_area (int top, int left, int bottom, int right, int win)
{
int row, col;
top--; left--; bottom--; right--;
Expand All @@ -222,9 +238,16 @@ void os_erase_area (int top, int left, int bottom, int right, int UNUSED (win))

void os_scroll_area (int top, int left, int bottom, int right, int units)
{
if ((screen_buffer_ptr - screen_buffer) < (SCREEN_BUFF_SIZE - 1)) {
*screen_buffer_ptr++ = '\n';
}
if (cwin == 1) {
if ((upper_screen_buffer_ptr - upper_screen_buffer) < (UPPER_SCREEN_BUFF_SIZE - 1)) {
*upper_screen_buffer_ptr++ = '\n';
}
}
else {
if ((screen_buffer_ptr - screen_buffer) < (SCREEN_BUFF_SIZE - 1)) {
*screen_buffer_ptr++ = '\n';
}
}
}

int os_font_data(int font, int *height, int *width)
Expand Down Expand Up @@ -522,6 +545,7 @@ void dumb_init_output(void)
{
if (h_version == V3) {
h_config |= CONFIG_SPLITSCREEN;
h_config |= CONFIG_NOSTATUSLINE;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the option to disable status line for V3 games. This simplifies the clean_observation_... functions.

h_flags &= ~OLD_SOUND_FLAG;
}

Expand All @@ -548,6 +572,7 @@ void dumb_init_output(void)
}

char* dumb_get_screen(void) {
flush_buffer();
*screen_buffer_ptr = '\0';
return screen_buffer;
}
Expand All @@ -556,6 +581,26 @@ void dumb_clear_screen(void) {
screen_buffer_ptr = screen_buffer;
}


char* dumb_get_lower_screen(void) {
flush_buffer();
*screen_buffer_ptr = '\0';
return screen_buffer;
}

void dumb_clear_lower_screen(void) {
screen_buffer_ptr = screen_buffer;
}

char* dumb_get_upper_screen(void) {
upper_screen_buffer[UPPER_SCREEN_BUFF_SIZE-1] = '\0';
return upper_screen_buffer;
}

void dumb_clear_upper_screen(void) {
upper_screen_buffer_ptr = upper_screen_buffer;
}

void dumb_free(void) {
if (screen_data) {
free(screen_data);
Expand Down
16 changes: 8 additions & 8 deletions frotz/src/games/acorncourt.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
Copyright (C) 2018 Microsoft Corporation

This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -103,11 +103,11 @@ int acorn_ignore_attr_clr(zword obj_num, zword attr_idx) {
}

void acorn_clean_world_objs(zobject* objs) {
int i;
char mask;
mask = ~(1 << 6);
// Clear attr 25
for (i=1; i<=acorn_get_num_world_objs(); ++i) {
objs[i].attr[3] &= mask;
}
// Zero out attribute 25 for all objects.
// attr[0] attr[1] attr[2] attr[3]
// 11111111 11111111 11111111 10111111
char mask3 = 0b10111111; // Attr 25.
for (int i=1; i<=acorn_get_num_world_objs(); ++i) {
objs[i].attr[3] &= mask3;
}
}
19 changes: 13 additions & 6 deletions frotz/src/games/advent.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
Copyright (C) 2018 Microsoft Corporation

This program is free software; you can redistribute it and/or
Expand All @@ -24,16 +24,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

// Adventure: http://ifdb.tads.org/viewgame?id=fft6pu91j85y4acv

const zword advent_special_ram_addrs[5] = {
const zword advent_special_ram_addrs[3] = {
15198, // Kill dragon
15191, // Pour water on plant
15287, // Give food to bear
// 15191, // Pour water on plant
//15287, // Give food to bear
15282, // Bear following you
15642, // FEE/FIE/FOE/FOO
};

zword* advent_ram_addrs(int *n) {
*n = 5;
*n = 3;
return advent_special_ram_addrs;
}

Expand Down Expand Up @@ -84,7 +84,7 @@ int advent_max_score() {
}

int advent_get_num_world_objs() {
return 255;
return 276;
}

int advent_ignore_moved_obj(zword obj_num, zword dest_num) {
Expand All @@ -104,4 +104,11 @@ int advent_ignore_attr_clr(zword obj_num, zword attr_idx) {
}

void advent_clean_world_objs(zobject* objs) {
// Zero out attribute 25 for all objects.
// attr[0] attr[1] attr[2] attr[3]
// 11111111 11111111 11111111 10111111
char mask = 0b10111111; // Attr 25.
for (int i=1; i<=advent_get_num_world_objs(); ++i) {
objs[i].attr[3] &= mask;
}
}
28 changes: 14 additions & 14 deletions frotz/src/games/adventureland.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

// Adventureland: http://ifdb.tads.org/viewgame?id=dy4ok8sdlut6ddj7

const zword adventureland_special_ram_addrs[1] = {
1231 // Activated take/drink water
const zword adventureland_special_ram_addrs[0] = {
// 1231 // Activated take/drink water
};

zword* adventureland_ram_addrs(int *n) {
*n = 1;
*n = 0;
return adventureland_special_ram_addrs;
}

Expand Down Expand Up @@ -88,23 +88,23 @@ int adventureland_ignore_moved_obj(zword obj_num, zword dest_num) {
}

int adventureland_ignore_attr_diff(zword obj_num, zword attr_idx) {
if (attr_idx == 2 || attr_idx == 25)
return 1;
// if (attr_idx == 2 || attr_idx == 25)
// return 1;
return 0;
}

int adventureland_ignore_attr_clr(zword obj_num, zword attr_idx) {
if (attr_idx == 2 || attr_idx == 25)
return 1;
// if (attr_idx == 2 || attr_idx == 25)
// return 1;
return 0;
}

void adventureland_clean_world_objs(zobject* objs) {
int i;
char mask;
mask = ~(1 << 6) & ~(1 << 7);
// Clear attr 24 & 25
for (i=1; i<=adventureland_get_num_world_objs(); ++i) {
objs[i].attr[3] &= mask;
}
// Zero out attribute 25 for all objects.
// attr[0] attr[1] attr[2] attr[3]
// 11111111 11111111 11111111 10111111
// char mask3 = 0b10111111; // Attr 25.
// for (int i=1; i<=adventureland_get_num_world_objs(); ++i) {
// objs[i].attr[3] &= mask3;
// }
}
Loading
Loading