Skip to content

Commit

Permalink
Load strings from STRINGS.CKx file
Browse files Browse the repository at this point in the history
In order to better support mods/translations/etc down the line, this
patch makes many (but not all strings) dynamic: loaded as variables from
the STRINGS.CKx file on startup.

The syntax of the file is:
%string [string-name] "[string-contents]"

The string names are handcoded for each episode: some are common, others
are per-episode. They all should start "ck_str_" or "ck[456]_str_", to
distinguish episode-specific strings from strings shared between
episodes.

The string contents can contain escaped characters (currently just \n
for newlines and \\ and \" to escape the backslash and quotes), and may
be split up into multiple quote-enclosed strings (which are
concatenated), so that large strings may be split across several lines.

Note that not all strings are dynamic yet: those which are stored
directly in structures in the code (most notably the menu and the
highscores) are not converted, and there are a few others here and
there. This is largely because (a) we have to start somewhere, and (b)
the file isn't loaded when such static structures are initialised. The
current plan is to store the string names in these structures, and load
them on use.

If a string cannot be found, it will probably be replaced by its name.
This will crash if the string name is longer than the string, and the
string is US_CPrint()ed into a small area. This basically means the
[Enter] status screen crashes without the STRINGS file. This, hopefully,
will end up fixed.

Finally, there are a few other minor fixes and hacks:
- A small bugfix for the Star Wars scroller when the last line doesn't
  have a newline.
- Increases to the maximum token size.
- Got rid of some arena resets in the parser which conflicted with
  PeekToken(). Clearly we need a better way to handle that.
  • Loading branch information
sulix committed Jun 13, 2021
1 parent cdd4d00 commit a5d8a79
Show file tree
Hide file tree
Showing 23 changed files with 1,041 additions and 547 deletions.
2 changes: 2 additions & 0 deletions data/keen4/ACTION.CK4
Expand Up @@ -2,6 +2,8 @@
# Action database for Keen 4 (Apogee v1.4)
#

%include "STRINGS.CK4"

#ck_phys.c
%action CK_ACT_NULL 0x089C 0 0 Frame 0 0 0 0 0 NULL NULL NULL NULL

Expand Down
305 changes: 305 additions & 0 deletions data/keen4/STRINGS.CK4
@@ -0,0 +1,305 @@
#
# Strings for Keen 4 (v1.4)
#

# Common strings

%string ck_str_gameOver "Game Over!"

# Loading box for demos
%string ck_str_demo "DEMO"

%string ck_str_tryAgainIntro "You didn't make it past"
%string ck_str_tryAgainTryAgain "Try Again"


#ck_play.c

%string ck_str_itemCheat "Cheat Option!\n\nYou just got all\nthe keys, 99 shots,\nand an extra keen!"

%string ck_str_godModeOn "God Mode ON"
%string ck_str_godModeOff "God Mode OFF"

%string ck_str_freeItems "Free Items!"

%string ck_str_jumpCheatOn "\nJump cheat ON"
%string ck_str_jumpCheatOff "\nJump cheat OFF"

%string ck_str_noClippingOn "No clipping ON"
%string ck_str_noClippingOff "No clipping OFF"

%string ck_str_slowMotionOn "Slow motion ON"
%string ck_str_slowMotionOff "Slow motion OFF"

#TODO: Warp and some other debug cheats

%string ck_str_debugKeysActive "Debug keys active"


%string ck_str_paused "PAUSED"

#NOTE: QuickSave feature
%string ck_str_gameQuickSaved "GAME SAVED"

# Status window
%string ck_str_statusLocation "LOCATION"
%string ck_str_statusScore "SCORE"
%string ck_str_statusExtra "EXTRA"
%string ck_str_statusLevel "LEVEL" # Difficulty level
%string ck_str_statusEasy "Easy"
%string ck_str_statusNormal "Normal"
%string ck_str_statusHard "Hard"
%string ck_str_statusKeys "KEYS"
%string ck_str_statusAmmo "AMMO"
%string ck_str_statusLives "KEENS"
#NOTE: Centilives are in the per-episode STRINGS file


%string ck_str_gameOver "Game Over!"

# Loading box for demos
%string ck_str_demo "DEMO"

%string ck_str_tryAgainIntro "You didn't make it past"
%string ck_str_tryAgainTryAgain "Try Again"


#ck_play.c

%string ck_str_itemCheat "Cheat Option!\n\nYou just got all\nthe keys, 99 shots,\nand an extra keen!"

%string ck_str_godModeOn "God Mode ON"
%string ck_str_godModeOff "God Mode OFF"

%string ck_str_freeItems "Free Items!"

%string ck_str_jumpCheatOn "\nJump cheat ON"
%string ck_str_jumpCheatOff "\nJump cheat OFF"

%string ck_str_noClippingOn "No clipping ON"
%string ck_str_noClippingOff "No clipping OFF"

%string ck_str_slowMotionOn "Slow motion ON"
%string ck_str_slowMotionOff "Slow motion OFF"

#TODO: Warp and some other debug cheats

%string ck_str_debugKeysActive "Debug keys active"


%string ck_str_paused "PAUSED"

#NOTE: QuickSave feature
%string ck_str_gameQuickSaved "GAME SAVED"

# Status window
%string ck_str_statusLocation "LOCATION"
%string ck_str_statusScore "SCORE"
%string ck_str_statusExtra "EXTRA"
%string ck_str_statusLevel "LEVEL" # Difficulty level
%string ck_str_statusEasy "Easy"
%string ck_str_statusNormal "Normal"
%string ck_str_statusHard "Hard"
%string ck_str_statusKeys "KEYS"
%string ck_str_statusAmmo "AMMO"
%string ck_str_statusLives "KEENS"

# Keen 4
%string ck_str_exitToMap "Exit to Shadowlands"

%string ck_str_statusCentilives "DROPS"
%string ck4_str_statusRescued "RESCUED"
%string ck4_str_statusWetsuit "Wetsuit"
%string ck4_str_statusNoWetsuit "???"

%string ck_str_levelName0 "Shadowlands"
%string ck_str_levelName1 "Border Village"
%string ck_str_levelName2 "Slug Village"
%string ck_str_levelName3 "The Perilous Pit"
%string ck_str_levelName4 "Cave of the Descendents"
%string ck_str_levelName5 "Chasm of Chills"
%string ck_str_levelName6 "Crystalus"
%string ck_str_levelName7 "Hilville"
%string ck_str_levelName8 "Sand Yego"
%string ck_str_levelName9 "Miragia"
%string ck_str_levelName10 "Lifewater Oasis"
%string ck_str_levelName11 "Pyramid of the Moons"
%string ck_str_levelName12 "Pyramid of Shadows"
%string ck_str_levelName13 "Pyramid of the\nGnosticene Ancients"
%string ck_str_levelName14 "Pyramid of the Forbidden"
%string ck_str_levelName15 "Isle of Tar"
%string ck_str_levelName16 "Isle of Fire"
%string ck_str_levelName17 "Well of Wishes"
%string ck_str_levelName18 "Bean-with-Bacon\nMegarocket"




%string ck_str_levelEntryText0 "Keen enters the\nShadowlands\n"

%string ck_str_levelEntryText1 "Keen makes a run for\nthe Border Village"

%string ck_str_levelEntryText2 "Keen slips into\nSlug Village"

%string ck_str_levelEntryText3 "Keen plummets into\nthe The Perilous Pit"

%string ck_str_levelEntryText4 "Keen plods down into\nthe Cave of the\nDescendents"

%string ck_str_levelEntryText5 "Keen shivers along\n"
"the Chasm of Chills"

%string ck_str_levelEntryText6 "Keen reflects upon\n"
"entering Crystalus"

%string ck_str_levelEntryText7 "Keen stumbles upon\n"
"Hillville"

%string ck_str_levelEntryText8 "Keen grits his teeth\n"
"and enters Sand Yego"

%string ck_str_levelEntryText9 "Keen disappears into\n"
"Miragia"

%string ck_str_levelEntryText10 "Keen crawls into\n"
"Lifewater Oasis"

%string ck_str_levelEntryText11 "Keen backs into the\n"
"Pyramid of the Moons"

%string ck_str_levelEntryText12 "Keen move silently in\n"
"the Pyramid of Shadows"

%string ck_str_levelEntryText13 "Keen reverently enters\n"
"the Pyramid of the\n"
"Gnosticene Ancients"

%string ck_str_levelEntryText14 "Keen hesitantly crosses\n"
"into the Pyramid of the\n"
"Forbidden"

%string ck_str_levelEntryText15 "Keen mucks along the\n"
"Isle of Tar"

%string ck_str_levelEntryText16 "Keen blazes across the\n"
"Isle of Fire"

%string ck_str_levelEntryText17 "Keen hopefully enters\n"
"the Well of Wishes"

%string ck_str_levelEntryText18 "Keen launches into the\n"
"Bean-with-Bacon\n"
"Megarocket"

%string ck_str_storyText
"Episode Four\n"
"\n"
"Secret of the Oracle\n"
"\n"
"After delivering a\n"
"crippling blow to the\n"
"plans of Mortimer\n"
"McMire and receiving\n"
"the praise of the\n"
"Vorticon race,\n"
"Commander Keen\n"
"returned to his home in\n"
"the suburbs.\n"
"\n"
"Here he was forced to\n"
"go to bed at an early\n"
"hour, and to eat mashed\n"
"potatoes.\n"
"\n"
"Months later, Billy\n"
"tinkered around with\n"
"his latest invention,\n"
"the Photachyon\n"
"Transceiver, or faster-\n"
"than-light radio. After\n"
"picking up a lot of bad\n"
"alien sitcoms, he\n"
"stumbled upon a strange\n"
"message of terrible\n"
"importance....\n"


# Princess Lindsay:

%string ck4_str_lindsaySays "Princess Lindsey says:\n"
%string ck4_str_lindsayMessage1 "There's gear to help\n"
"you swim in Three-Tooth\n"
"Lake. It is hidden in\n"
"Miragia.\n"

%string ck4_str_lindsayMessage2 "The way to the Pyramid\n"
"of the Forbidden lines\n"
"under the Pyramid of\n"
"Moons.\n"

%string ck4_str_lindsayThanks1 "Thanks, your Highness!"
%string ck4_str_lindsayThanks2 "Thanks for the\n"
"mysterious clue,\n"
"Princess!\n"

# Oracle Janitor:

%string ck4_str_janitor1 "Thanks for going to all\n"
"that trouble, but I'm\n"
"just the janitor for the\n"
"High Council."

%string ck4_str_janitor2 "I tried to tell the\n"
"Shikadi that but they\n"
"just wouldn't listen..."

%string ck4_str_janitor3 "This had better\n"
"be a joke."

%string ck4_str_janitor4 "Sorry. You aren't\n"
"mad, are you?"

# Wetsuit:

%string ck4_str_cantSwim "I can't swim!"
%string ck4_str_gotWetsuit "Cool! I can breathe\n"
"under water now!"

# Council members:

%string ck4_str_councilMessage0 "No sweat, oh guardian\n"
"of wisdom!"

%string ck4_str_councilMessage1 "Sounds like a plan,\n"
"bearded one!"

%string ck4_str_councilMessage2 "No problemo."

%string ck4_str_councilMessage3 "Great. You known, you\n"
"look a lot like the\n"
"last guy I rescued..."

%string ck4_str_councilMessage4 "Good idea, Gramps."

%string ck4_str_councilMessage5 "May the road rise\n"
"to meet your feet,\n"
"Mr. Member."

%string ck4_str_councilMessage6 "Wise plan of action,\n"
"your ancientness."

%string ck4_str_councilMessage7 "You're the last one,\n"
"fella. Let's both\n"
"get back to the\n"
"Oracle chamber!"

%string ck4_str_councilThanks "Oh thank you so much\n"
"for rescuing me!\n"
"I'll return to the\n"
"Oracle chamber\n"
"immediately."

%string ck4_str_councilThanks2 "Ggoh thig you sogh mg\n"
"fgor regscuing mgge!\n"
"I'gll regur tgo the\n"
"Goracle chagber\n"
"igmediatggely. Blub."
2 changes: 2 additions & 0 deletions data/keen5/ACTION.CK5
Expand Up @@ -2,6 +2,8 @@
# Action database for Keen 5 (v1.4)
#

%include "STRINGS.CK5"

# ck_phys.c
%action CK_ACT_NULL 0x0788 0 0 Frame 0 0 0 0 0 NULL NULL NULL NULL

Expand Down

0 comments on commit a5d8a79

Please sign in to comment.