Skip to content

Commit

Permalink
Merge pull request #781 from angstsmurf/scott-update
Browse files Browse the repository at this point in the history
Update ScottFree
  • Loading branch information
cspiegel committed May 11, 2023
2 parents e2f447c + 2ced19e commit c839c00
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 111 deletions.
5 changes: 3 additions & 2 deletions terps/scott/ai_uk/game_specific.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ void SecretAction(int p)
void AdventurelandDarkness(void)
{
if ((Rooms[MyLoc].Image & 128) == 128)
BitFlags |= 1 << DARKBIT;
SetDark();
else
BitFlags &= ~(1 << DARKBIT);
SetLight();
}

void AdventurelandAction(int p)
Expand All @@ -135,6 +135,7 @@ void AdventurelandAction(int p)
DrawImage(image);
Output("\n");
Output(sys[HIT_ENTER]);
showing_closeup = 1;
HitEnter();
return;
}
Expand Down
29 changes: 16 additions & 13 deletions terps/scott/ai_uk/seasofblood.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,16 +617,16 @@ int roll_dice(int strike, int stamina, int boatflag)
their_dice_stopped = 0;
print_sum(our_turn, their_result, strike);
our_turn = 1;
glk_window_clear(Bottom);
glk_cancel_char_event(Top);
glk_request_char_event(Top);
glk_stream_set_current(glk_window_get_stream(Bottom));
glk_put_string("Your throw\n");
glk_put_string("<ENTER> to stop dice");
SOBPrint(Bottom, "\n");
glk_window_clear(Bottom);
glk_put_string("Your throw\n<ENTER> to stop dice");
if (!boatflag)
glk_put_string(" <X> to run");
glk_request_char_event(Top);
} else if (our_turn == 0) {
glk_request_timer_events(delay);
glk_request_timer_events((glui32)delay);
}

rolls++;
Expand All @@ -638,6 +638,7 @@ int roll_dice(int strike, int stamina, int boatflag)

update_dice(our_turn, left_dice, right_dice);
if (our_turn == 0 && rolls == enemy_rolls) {
SOBPrint(Bottom, "\n");
glk_window_clear(Bottom);
their_result = left_dice + right_dice + strike;
SOBPrint(Bottom, "Their result: %d + %d + %d = %d\n", left_dice,
Expand All @@ -652,6 +653,8 @@ int roll_dice(int strike, int stamina, int boatflag)
update_dice(our_turn, left_dice, right_dice);
our_result = left_dice + right_dice + 9;
print_sum(our_turn, our_result, 9);
SOBPrint(Bottom, "\nYour result: %d + %d + %d = %d\n", left_dice,
right_dice, strike, our_result);
if (their_result > our_result) {
return LOSS;
} else if (our_result > their_result) {
Expand Down Expand Up @@ -703,43 +706,42 @@ void battle_loop(int strike, int stamina, int boatflag)
do {
int result = roll_dice(strike, stamina, boatflag);
glk_cancel_char_event(Top);
SOBPrint(Bottom, "\n");
glk_window_clear(Bottom);
clear_stamina();
glk_stream_set_current(glk_window_get_stream(Bottom));
if (result == LOSS) {
Counters[3] -= 2;

if (Counters[3] <= 0) {
SOBPrint(Bottom, "%s\n",
SOBPrint(Bottom, "%s",
boatflag ? "THE BANSHEE HAS BEEN SUNK!"
: "YOU HAVE BEEN KILLED!");
Counters[3] = 0;
BitFlags |= (1 << 6);
SetBitFlag(6);
Counters[7] = 0;
} else {
SOBPrint(Bottom, "%s", battle_messages[1 + rand() % 5 + 16 * boatflag]);
}
} else if (result == VICTORY) {
stamina -= 2;
if (stamina <= 0) {
glk_put_string("YOU HAVE WON!\n");
BitFlags &= ~(1 << 6);
glk_put_string("YOU HAVE WON!");
ClearBitFlag(6);
stamina = 0;
} else {
SOBPrint(Bottom, "%s", battle_messages[6 + rand() % 5 + 16 * boatflag]);
}
} else if (result == FLEE) {
BitFlags |= (1 << 6);
SetBitFlag(6);
MyLoc = SavedRoom;
return;
} else {
SOBPrint(Bottom, "%s", battle_messages[11 + rand() % 5 + 16 * boatflag]);
}

glk_put_string("\n\n");

if (Counters[3] > 0 && stamina > 0) {
glk_put_string("<ENTER> to roll dice");
glk_put_string("\n\n<ENTER> to roll dice");
if (!boatflag)
glk_put_string(" <X> to run");
}
Expand All @@ -748,6 +750,7 @@ void battle_loop(int strike, int stamina, int boatflag)
update_result(1, 9, Counters[3], boatflag);

BattleHitEnter(strike, stamina, boatflag);
SOBPrint(Bottom, "\n\n");
glk_window_clear(Bottom);

} while (stamina > 0 && Counters[3] > 0);
Expand Down
16 changes: 8 additions & 8 deletions terps/scott/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#define MAX_WORDS 128
#define MAX_BUFFER 128

extern strid_t Transcript;
extern struct Command *CurrentCommand;

glui32 **UnicodeWords = NULL;
Expand Down Expand Up @@ -55,6 +54,7 @@ const char *ExtraCommands[NUMBER_OF_EXTRA_COMMANDS] = {
"load",
"#restore",
"transcript",
"#transcript",
"script",
"#script",
"oops",
Expand All @@ -73,6 +73,7 @@ const char *ExtraCommands[NUMBER_OF_EXTRA_COMMANDS] = {
"#qsave",
"except",
"but",
"#flicker",
"", "", "", "", ""
};

Expand All @@ -86,6 +87,7 @@ const char *GermanExtraCommands[NUMBER_OF_EXTRA_COMMANDS] = {
"load",
"#restore",
"transcript",
"#transcript",
"script",
"#script",
"oops",
Expand All @@ -104,6 +106,7 @@ const char *GermanExtraCommands[NUMBER_OF_EXTRA_COMMANDS] = {
"#qsave",
"ausser",
"bis",
"#flicker",
"laden",
"wiederherstellen",
"transkript",
Expand All @@ -121,6 +124,7 @@ const char *SpanishExtraCommands[NUMBER_OF_EXTRA_COMMANDS] = {
"load",
"#restore",
"transcript",
"#transcript",
"script",
"#script",
"oops",
Expand All @@ -139,6 +143,7 @@ const char *SpanishExtraCommands[NUMBER_OF_EXTRA_COMMANDS] = {
"#qsave",
"excepto",
"menos",
"#flicker",
"reanuda",
"cargar",
"transcripcion",
Expand All @@ -148,9 +153,9 @@ const char *SpanishExtraCommands[NUMBER_OF_EXTRA_COMMANDS] = {

extra_command ExtraCommandsKey[NUMBER_OF_EXTRA_COMMANDS] = {
NO_COMMAND, RESTART, RESTART, SAVE, SAVE, RESTORE, RESTORE,
RESTORE, SCRIPT, SCRIPT, SCRIPT, UNDO, UNDO, UNDO, UNDO,
RESTORE, SCRIPT, SCRIPT, SCRIPT, SCRIPT, UNDO, UNDO, UNDO, UNDO,
RAM, RAMLOAD, RAMLOAD, RAMLOAD, RAMLOAD, RAMLOAD, RAMSAVE,
RAMSAVE, RAMSAVE, RAMSAVE, EXCEPT, EXCEPT,
RAMSAVE, RAMSAVE, RAMSAVE, EXCEPT, EXCEPT, FLICKER,
RESTORE, RESTORE, SCRIPT, UNDO, RESTART
};

Expand Down Expand Up @@ -582,11 +587,6 @@ void LineInput(void)

unibuf[ev.val1] = 0;

if (Transcript) {
glk_put_string_stream_uni(Transcript, unibuf);
glk_put_char_stream_uni(Transcript, 10);
}

lastwasnewline = 1;

SplitIntoWords(unibuf, ev.val1);
Expand Down
5 changes: 3 additions & 2 deletions terps/scott/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ typedef enum {
COMMAND,
ALL,
IT,
EXCEPT
EXCEPT,
FLICKER
} extra_command;

int GetInput(int *vb, int *no);
Expand Down Expand Up @@ -70,7 +71,7 @@ extern const char *EnglishDelimiterList[];
extern const char *GermanDelimiterList[];
extern const char *DelimiterList[];

#define NUMBER_OF_EXTRA_COMMANDS 32
#define NUMBER_OF_EXTRA_COMMANDS 34
extern const char *GermanExtraCommands[];
extern const char *SpanishExtraCommands[];
extern const char *ExtraCommands[];
Expand Down
6 changes: 3 additions & 3 deletions terps/scott/saga/woz2nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int rotate_left_with_carry(uint8_t *byte, int last_carry)
}

// This is a translation of $trk =~ s{^0*(1.{7})}{}o;
// Extract first '1' + 7 characters ("bits").
// Extract first set bit + 7 following bits.
static uint8_t extract_nibble(uint8_t *bitstream, int bits, int *pos)
{
int bytes = bits / 8 + (bits % 8 != 0);
Expand Down Expand Up @@ -320,9 +320,9 @@ static SearchResultType find_syncbytes(uint8_t *bitstream, int bitcount, int *po
// or the next byte has the leftmost bit unset
if ((b & 0x01) != 0 && (bitstream[i + 1] & 0x80) != 0) {
for (int j = 1; j < 8; j++) {
// Check if this bit and the next left shifted j places become 0xff
// Check if this bit and the next one left-shifted j places become 0xff
if (((bitstream[i] << j) | (bitstream[i + 1] >> (8 - j))) == 0xff) {
// If so, copy the following 8 bytes to a buffer left shifted j positions,
// If so, copy the following 8 bytes to a buffer left-shifted j positions,
// and compare them to the sync byte sequences.
for (int k = 8; k > 0; k--) {
temp[k] = ((bitstream[i + k] << j) | (bitstream[i + k + 1] >> (8 - j)));
Expand Down
Loading

0 comments on commit c839c00

Please sign in to comment.