Skip to content

Commit

Permalink
TAYLOR: Update
Browse files Browse the repository at this point in the history
Update docs a bit, adding some minimal documentation of the added
commands.

Improved formatting of gameinfo.c

Extra commands like TRANSCRIPT OFF was broken in games that defined OFF
in their internal dictionary (and TRANSCRIPT ON if they defined ON,
and so on.)

Fix some problems with undo.

Rename buffer[] array to not shadow local libspectrum variables.

One animation in Kayleth (the firing android) would not show.
The assembly line in room 2 is now smoother.

Energy display in Rebel Planet said 0 where it should say 00.

Multiple waiting now matches original. It actually waits one extra
turn, but won't print a message for the last one.
  • Loading branch information
angstsmurf committed May 8, 2023
1 parent 37e70f5 commit 2c3ac77
Show file tree
Hide file tree
Showing 13 changed files with 325 additions and 211 deletions.
30 changes: 16 additions & 14 deletions terps/taylor/FORMAT
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,30 @@ rules.
Drawing Codes:

0xFF End
0xFE 733C
0xFD 6FF5 arg 0-7, arg 0-7
0xFC 76D4 arg1 arg2 arg3 arg4
0xFE 733C mirror area x0 y0 width y1
0xFD 6FF5 arg 0-7, arg 0-7 replace colour arg1 with arg2
0xFC 76D4 arg1 arg2 arg3 arg4 draw color, args y, x, height, colour, width
(in early games x, y, colour, length)
Seems to be
setattributes (arg1,arg2, height, attribute, width)
set attributes (arg1, arg2, height, attribute, width)
where arg1=y arg2=x in chars 0,0 top left
0xFB 700D
Make picture attribute area bright
0xFA 7512
0xFA 7512 Flip image horizontally
0xF9 DrawPicture n (following byte)
0xF8 729D
0xF7 743A arg1 }
0xF8 729D Skip rest of picture if object arg1 is not present
Early games: Draw picture arg1 at x y
0xF7 743A arg1 } Rebel Planet: Stop drawing if alcove is unlocked
0xF6 744E arg1 } set A to 0 4 or 8 and call same method
0xF5 7444 arg1 }
0xF4 7458 arg1
End of object arg1 is not present
0xF3 7409
0xF2 7331 arg1 arg2 arg3 arg4
0xF1 73FE
0xEE 7507
0xED 7654
0xEC 7649
End if object arg1 is not present
0xF3 7409 Mirror top half vertically
0xF2 7331 arg1 arg2 arg3 arg4 Mirror area horizontally
0xF1 73FE Mirror area vertically
0xEE 7507 Flip area horizontally
0xED 7654 Flip image vertically
0xEC 7649 Flip area vertically
0xEB CRASH
0xEA CRASH
0xE9 7678 arg1 arg2 ..
Expand Down
18 changes: 18 additions & 0 deletions terps/taylor/README
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
Forker's note

This is a fork of the original TaylorMade interpreter by Alan Cox. I've
ported it to the Glk api and added support for "Questprobe featuring The
Human Torch and The Thing", graphics and animations, and a couple of beeps
in "Rebel Planet".

The following "extra commands" are added to all games, though some games
already had some of them:

#RESTART, #RESTORE, #TRANSCRIPT ON, #TRANSCRIPT OFF, #QUICKSAVE, #QUICKLOAD,
and UNDO.

-- Petter Sjölund, May 2023


Original README:


TaylorMade v0.4 (c) 2004 - 2016 Alan Cox
All Rights Reserved
Expand Down
66 changes: 42 additions & 24 deletions terps/taylor/animations.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static int KaylethAnimationIndex = 0;
static int AnimationStage = 0;
static int ClickShelfStage = 0;

extern uint8_t buffer[384][9];
extern uint8_t screenbuf[768][9];
extern Image *images;
extern int draw_to_buffer;

Expand All @@ -53,35 +53,35 @@ static void AnimateStars(void)
/* because the bytes are flipped in our implementation */
/* for some reason */
for (int col = 15; col > 5; col--) {
uint8_t attribute = buffer[col + line * 32][8];
uint8_t attribute = screenbuf[col + line * 32][8];
glui32 ink = attribute & 7;
ink += 8 * ((attribute & 64) == 64);
ink = Remap(ink);
for (int bit = 0; bit < 8; bit++) {
if ((buffer[col + line * 32][pixrow] & (1 << bit)) != 0) {
if ((screenbuf[col + line * 32][pixrow] & (1 << bit)) != 0) {
PutPixel(col * 8 + bit, line * 8 + pixrow, ink);
}
}
carry = rotate_right_with_carry(&(buffer[col + line * 32][pixrow]), carry);
carry = rotate_right_with_carry(&(screenbuf[col + line * 32][pixrow]), carry);
}
if (carry) {
buffer[line * 32 + 15][pixrow] = buffer[line * 32 + 15][pixrow] | 128;
screenbuf[line * 32 + 15][pixrow] = screenbuf[line * 32 + 15][pixrow] | 128;
}
carry = 0;
/* Then the right half */
for (int col = 16; col < 26; col++) {
uint8_t attribute = buffer[col + line * 32][8];
uint8_t attribute = screenbuf[col + line * 32][8];
glui32 ink = attribute & 7;
ink += 8 * ((attribute & 64) == 64);
ink = Remap(ink);
for (int pix = 0; pix < 8; pix++) {
if ((buffer[col + line * 32][pixrow] & (1 << pix)) != 0) {
if ((screenbuf[col + line * 32][pixrow] & (1 << pix)) != 0) {
PutPixel(col * 8 + pix, line * 8 + pixrow, ink);
}
}
carry = rotate_left_with_carry(&(buffer[col + line * 32][pixrow]), carry);
carry = rotate_left_with_carry(&(screenbuf[col + line * 32][pixrow]), carry);
}
buffer[line * 32 + 16][pixrow] = buffer[line * 32 + 16][pixrow] | carry;
screenbuf[line * 32 + 16][pixrow] = screenbuf[line * 32 + 16][pixrow] | carry;
}
}
}
Expand All @@ -93,25 +93,25 @@ static void AnimateForcefield(void)
RectFill(104, 16, 48, 39, 0, 0);
/* We go line by line and pixel row by pixel row */

uint8_t colour = buffer[2 * 32 + 13][8];
uint8_t colour = screenbuf[2 * 32 + 13][8];
glui32 ink = Remap(colour & 0x7);

for (int line = 2; line < 7; line++) {
for (int pixrow = 0; pixrow < 8; pixrow++) {
carry = 0;
for (int col = 13; col < 19; col++) {
for (int pix = 0; pix < 8; pix++) {
if ((buffer[col + line * 32][pixrow] & (1 << pix)) != 0) {
if ((screenbuf[col + line * 32][pixrow] & (1 << pix)) != 0) {
PutPixel(col * 8 + pix, line * 8 + pixrow, ink);
}
}
/* The force field is rotated one pixel to the right, */
/* byte by byte, but we actually rotate to the left */
/* because the bytes are flipped in our implementation */
/* for some reason */
carry = rotate_left_with_carry(&(buffer[col + line * 32][pixrow]), carry);
carry = rotate_left_with_carry(&(screenbuf[col + line * 32][pixrow]), carry);
}
buffer[line * 32 + 13][pixrow] = buffer[line * 32 + 13][pixrow] | carry;
screenbuf[line * 32 + 13][pixrow] = screenbuf[line * 32 + 13][pixrow] | carry;
}
}
}
Expand All @@ -122,7 +122,7 @@ static void FillCell(int cell, glui32 ink)
int starty = (cell / 32) * 8;
for (int pixrow = 0; pixrow < 8; pixrow++) {
for (int pix = 0; pix < 8; pix++) {
if ((buffer[cell][pixrow] & (1 << pix)) == 0) {
if ((screenbuf[cell][pixrow] & (1 << pix)) == 0) {
PutPixel(startx + pix, starty + pixrow, ink);
}
}
Expand Down Expand Up @@ -178,21 +178,21 @@ static void AnimateKaylethClickShelves(int stage)
int ypos = line * 8 + i + stage;
if (ypos > 79)
ypos = ypos - 80;
uint8_t attribute = buffer[col + (ypos / 8) * 32][8];
uint8_t attribute = screenbuf[col + (ypos / 8) * 32][8];
glui32 ink = attribute & 7;
ink += 8 * ((attribute & 64) == 64);
attribute = buffer[col + ((79 - ypos) / 8) * 32][8];
attribute = screenbuf[col + ((79 - ypos) / 8) * 32][8];
glui32 ink2 = attribute & 7;
ink2 += 8 * ((attribute & 64) == 64);
ink = Remap(ink);
ink2 = Remap(ink2);
for (int j = 0; j < 8; j++)
if (col > 15) {
if ((buffer[col + line * 32][i] & (1 << j)) != 0) {
if ((screenbuf[col + line * 32][i] & (1 << j)) != 0) {
PutPixel(col * 8 + j, ypos, ink);
}
} else {
if ((buffer[col + (9 - line) * 32][7 - i] & (1 << j)) != 0) {
if ((screenbuf[col + (9 - line) * 32][7 - i] & (1 << j)) != 0) {
PutPixel(col * 8 + j, 79 - ypos, ink2);
}
}
Expand Down Expand Up @@ -224,9 +224,17 @@ static int UpdateKaylethAnimationFrames(void) // Draw animation frame
int Stage = *ptr;
ptr++;
uint8_t *LastInstruction = ptr;
if (ObjectLoc[*ptr] != MyLoc && *ptr != 0 && *ptr != 122) {

int obj0loc = ObjectLoc[0];
ObjectLoc[0] = MyLoc;
if (Flag[10] > 1)
ObjectLoc[122] = MyLoc;

if (ObjectLoc[*ptr] != MyLoc) {
//Returning because location of object *ptr is not current location
return 0;
ObjectLoc[0] = obj0loc;
ObjectLoc[122] = DESTROYED;
return 1;
}
ptr++;
// Reset animation if we are in a new room
Expand All @@ -240,13 +248,21 @@ static int UpdateKaylethAnimationFrames(void) // Draw animation frame

// This is needed to make conveyor belt animation 2 smooth
// (the one you see after getting up)
// No idea why, this code is still largely a mystery
if (KaylethAnimationIndex == 2 && AnimationRate == 50)
AnimationRate = 10;
if (KaylethAnimationIndex == 2 && AnimationRate == 50) {
int counter = *(ptr + 1) + 1;
if (counter == 20) {
DrawTaylor(114);
DrawSagaPictureFromBuffer();
} else if (counter == 40) {
DrawTaylor(109);
DrawSagaPictureFromBuffer();
}
}

if (AnimationRate != 0xff) {
ptr++;
(*ptr)++;
int result = 1;
if (AnimationRate == *ptr) {
*ptr = 0;
// Draw "room image" *(ptr + 1) (Actually an animation frame)
Expand All @@ -257,7 +273,9 @@ static int UpdateKaylethAnimationFrames(void) // Draw animation frame
(*ptr) += 3;
return result;
}
return 1;
ObjectLoc[0] = obj0loc;
ObjectLoc[122] = DESTROYED;
return result;
} else {
ptr = LastInstruction + 1;
*ptr = Stage;
Expand Down
24 changes: 18 additions & 6 deletions terps/taylor/extracommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ typedef enum {
RAMLOAD_EXTR,
UNDO,
RAM,
SCRIPT,
GAME,
COMMAND,
ALL,
IT,
SCRIPT,
ON,
OFF
} extra_command;
Expand Down Expand Up @@ -108,6 +108,8 @@ extern int ShouldRestart;
extern int StopTime;
extern int Redraw;
extern int WordsInInput;
extern int PrintedOK;
extern uint8_t Word[];

extern winid_t Bottom;

Expand Down Expand Up @@ -141,6 +143,7 @@ static void TranscriptOn(void)
glk_put_string_stream(Transcript, start_of_transcript);
glk_put_string_stream(glk_window_get_stream(Bottom),
"Transcript is now on.\n");
glk_window_set_echo_stream(Bottom, Transcript);
}

static void TranscriptOff(void)
Expand All @@ -154,12 +157,13 @@ static void TranscriptOff(void)
glk_put_string_stream(Transcript, end_of_transcript);

glk_stream_close(Transcript, NULL);
glk_window_set_echo_stream(Bottom, NULL);
Transcript = NULL;
glk_put_string_stream(glk_window_get_stream(Bottom),
"Transcript is now off.\n");
}

static int ParseExtraCommand(char *p)
int ParseExtraCommand(char *p)
{
if (p == NULL)
return NO_COMMAND;
Expand Down Expand Up @@ -188,18 +192,26 @@ static int ParseExtraCommand(char *p)
return NO_COMMAND;
}

extern uint8_t Word[];
extern int FoundExtraCommand;

int TryExtraCommand(void)
{
int verb = ParseExtraCommand(InputWordStrings[WordPositions[0]]);
FoundExtraCommand = 0;
int verb_position = WordPositions[0];
int verb = ParseExtraCommand(InputWordStrings[verb_position]);
int noun = NO_COMMAND;
if (WordPositions[0] + 1 < WordsInInput)
noun = ParseExtraCommand(InputWordStrings[WordPositions[0] + 1]);

if (verb > SCRIPT && verb_position > 0) {
verb_position--;
verb = ParseExtraCommand(InputWordStrings[verb_position]);
}
if (verb_position + 1 < WordsInInput)
noun = ParseExtraCommand(InputWordStrings[verb_position + 1]);
if (noun == NO_COMMAND)
noun = Word[1];

StopTime = 1;
PrintedOK = 1;
Redraw = 1;
switch (verb) {
case RESTORE:
Expand Down
3 changes: 3 additions & 0 deletions terps/taylor/extracommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
#include <stdio.h>

int TryExtraCommand(void);
int ParseExtraCommand(char *p);

#define EXTRA_COMMAND 0xffff

#endif /* extracommands_h */
Loading

0 comments on commit 2c3ac77

Please sign in to comment.