Skip to content

Commit

Permalink
Fix #12 and #13
Browse files Browse the repository at this point in the history
Plus clean up code a bit
  • Loading branch information
drdnar committed Jul 2, 2019
1 parent f2d05b6 commit 5df2040
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 29 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NAME ?= ADVENT
COMPRESSED ?= YES
ICON ?= icon.png
VERS := 1.8.0
VERS := 1.8.1
DESCRIPTION ?= "Colossal Cave Adventure $(VERS)"
#----------------------------
# Core C Makefile
Expand All @@ -19,7 +19,6 @@ OPT_MODE ?= -optsize
SRCDIR ?=
OBJDIR ?= obj
BINDIR ?= bin
GFXDIR ?= gfx
#----------------------------

VERSION := 8.5
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ game and has some known deficiencies. Thus you get anomalies like "eat
building" interpreted as a command to move to the building. These should not be
reported as bugs; instead, consider them historical curiosities.

*Nota bene:* YOU **cannot** quit the main game just pressing MODE, DEL, or CLEAR.
*Nota bene:* You **cannot** quit the main game just pressing MODE, DEL, or CLEAR.
You **must** type "quit" or "save" to exit. (Alternatively, press ON, then CLEAR).

==== Installation ====
Expand Down
2 changes: 1 addition & 1 deletion actions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Actions for the duneon-running code.
* Actions for the dungeon-running code.
*
* Zilog's C compiler is a bit . . . special, so this file is broken up into
* smaller units.
Expand Down
11 changes: 11 additions & 0 deletions actions1.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* Actions for the dungeon-running code.
*
* Zilog's C compiler is a bit . . . special, so this file is broken up into
* smaller units.
*
* Copyright (c) 1977, 2005 by Will Crowther and Don Woods
* Copyright (c) 2017 by Eric S. Raymond
* SPDX-License-Identifier: BSD-2-clause
*/

#include "actions.h"

phase_codes_t attack(command_t* command)
Expand Down
11 changes: 11 additions & 0 deletions actions2.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* Actions for the dungeon-running code.
*
* Zilog's C compiler is a bit . . . special, so this file is broken up into
* smaller units.
*
* Copyright (c) 1977, 2005 by Will Crowther and Don Woods
* Copyright (c) 2017 by Eric S. Raymond
* SPDX-License-Identifier: BSD-2-clause
*/

#include "actions.h"

int chain(verb_t verb)
Expand Down
11 changes: 11 additions & 0 deletions actions3.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* Actions for the dungeon-running code.
*
* Zilog's C compiler is a bit . . . special, so this file is broken up into
* smaller units.
*
* Copyright (c) 1977, 2005 by Will Crowther and Don Woods
* Copyright (c) 2017 by Eric S. Raymond
* SPDX-License-Identifier: BSD-2-clause
*/

#include "actions.h"

phase_codes_t fill(verb_t verb, obj_t obj)
Expand Down
11 changes: 11 additions & 0 deletions actions4.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* Actions for the dungeon-running code.
*
* Zilog's C compiler is a bit . . . special, so this file is broken up into
* smaller units.
*
* Copyright (c) 1977, 2005 by Will Crowther and Don Woods
* Copyright (c) 2017 by Eric S. Raymond
* SPDX-License-Identifier: BSD-2-clause
*/

#include "actions.h"

phase_codes_t pour(verb_t verb, obj_t obj)
Expand Down
11 changes: 11 additions & 0 deletions actions5.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* Actions for the dungeon-running code.
*
* Zilog's C compiler is a bit . . . special, so this file is broken up into
* smaller units.
*
* Copyright (c) 1977, 2005 by Will Crowther and Don Woods
* Copyright (c) 2017 by Eric S. Raymond
* SPDX-License-Identifier: BSD-2-clause
*/

#include "actions.h"

phase_codes_t waste(verb_t verb, turn_t turns)
Expand Down
9 changes: 8 additions & 1 deletion calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ static void resume_game(void)
var_name = NULL;
search_pos = NULL;

/* Build a list of up to MAX_SAVES save files.
* The game won't prevent you making more than MAX_SAVES files, but you
* won't be able to scroll to all of them through this menu. */
while ((var_name = ti_Detect(&search_pos, save_file_header)) != NULL)
{
file = ti_Open(var_name, "r");
Expand All @@ -360,6 +363,8 @@ static void resume_game(void)
break;
}

/* If the user has no save games, display an message to that effect instead
* of garbage. */
if (total_saves == 0)
{
restore_splash();
Expand All @@ -378,8 +383,10 @@ static void resume_game(void)
line_height = fontlib_GetCurrentFontHeight();
saves_per_screen = (LCD_HEIGHT - SAVE_LIST_Y) / line_height;

/* Let the user select a file. Implement scrolling if necessary. */
do
{
/* Handle redrawing the screen if necessary. */
if (redraw)
{
redraw = false;
Expand Down Expand Up @@ -433,7 +440,7 @@ static void resume_game(void)
case sk_Del:
redraw = true;
fontlib_SetWindowFullScreen();
gfx_FillScreen(background_color);
restore_splash();
fontlib_SetCursorPosition(0, LCD_HEIGHT / 3 - 16);
print_centered_compressed(CONFIRM_DELETE);
print_centered(current_item->name);
Expand Down
2 changes: 2 additions & 0 deletions calculator.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ but also maps all of its flash memory, too, allowing unchanging data to be read

I wrote all of the code that deals with the dungeon file before ever writing any calculator code.
I wanted to verify that the semicompressed dungeon file worked before any actual porting.
The text is compressed with basic Huffman coding,
though most of the space saving actually comes from string deduplication.

Having a separate dungeon file reduces the program's RAM footprint.
While it would have been possible to keep all the data in the program binary,
Expand Down
20 changes: 1 addition & 19 deletions misc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* I/O and support riutines.
* I/O and support routines.
*
* Copyright (c) 1977, 2005 by Will Crowther and Don Woods
* Copyright (c) 2017 by Eric S. Raymond
Expand Down Expand Up @@ -32,24 +32,6 @@
#include "style.h"
#endif

#ifdef NEVER
/* Hack needed because Mateo decided that strcasecmp was the same as strncasecmp */
#include <ctype.h>
static int strncasecmp(const char *s1, const char *s2, size_t n)
{
if (n && s1 != s2)
{
do {
int d = tolower(*s1) - tolower(*s2);
if (d || *s1 == '\0' || *s2 == '\0') return d;
s1++;
s2++;
} while (--n);
}
return 0;
}
#endif

static void* xcalloc(size_t size)
{
void* ptr = calloc(size, 1);
Expand Down
11 changes: 6 additions & 5 deletions saveresume.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ static bool enough_mem()
static bool is_archived(char* name)
{
bool archived;
ti_var_t file = 0;
if (!ti_Open(name, "r"))
ti_var_t file;
if (!(file = ti_Open(name, "r")))
return false;
archived = ti_IsArchived(file);
ti_Close(file);
Expand All @@ -89,9 +89,9 @@ void save_apd()
fp = fopen(save_file_name, WRITE_MODE);
if (fp == NULL)
return;
/* Only deduct two points---they've either already waited a few minutes, or
* had to leave to do something else. */
game.saved += 2;
/* Only deduct three points---they've either already waited a few minutes,
* or had to leave to do something else. */
game.saved += 3;
savefile(fp, VRSION);
if (archived)
{
Expand Down Expand Up @@ -229,6 +229,7 @@ int suspend(void)
os_PutStrFull(get_arbitrary_message(SAVING_FILE));
ti_SetArchiveStatus(true, fp->slot);
gfx_resume_render_splash();
gfx_FillScreen(background_color);
}
#endif
fclose(fp);
Expand Down

0 comments on commit 5df2040

Please sign in to comment.