Patch Requests

A general chat area, here you can post anything that doesn't belong in another forum.
Post Reply
SodiumtheGlitcher
Vortininja
Posts: 40
Joined: Wed Oct 16, 2024 0:24
Location: Impossible Bulleting out of Keen 6

Patch Requests

Post by SodiumtheGlitcher »

Keen:Modding has gone inactive for the most part, so I'm starting a patch request topic over here. Put your patch requests here!

To the admins: I would appreciate if you would at least think twice before deleting this. Keen:Modding has almost no one on it anymore, but you may delete this topic if you think necessary.

So here's my patch request (copied from K:M): Could someone give me a patch to allow 32 levels and allow entry texts for 32 levels for Keen 5? I have a levelpack project I want to finish with 32 levels in it...
Put me in a room full of chlorine. Results: I die and turn into a pillar of salt and a very buggy Keen 6.

IMPOSSIBLE BULLET FOR LIFE!!!!!!!!!!!!!
nwe74
Grunt
Posts: 6
Joined: Sun Sep 18, 2022 18:29

Re: Patch Requests

Post by nwe74 »

I attached the patches for increasing the level number limit to 32 in a Keen 5 mod. In a patch-based mod, everything needs to fit in the available space in the original executable, so this makes finding the position for the new level names and texts somewhat tricky. In the solution I used, the following changes were necessary: 1. the space for level names and entry texts in the executable is now used for the level entry texts only. 2. The level names were moved into the "cache manager" segment, and they replace unused code for a "Keen Dreams style" loading window (see https://keenwiki.shikadi.net/wiki/Keen_4_Easter_eggs) - and other unnecessary code. Other modifications were also needed. The music numbers for each level now use only one byte instead of a 16-bit word. Some arrays (gamestate.leveldone, levelnames) have space for only 25 levels, so I have also changed the format of the data in them (see comments in patches)

Code: Select all

# ($60B1): Largest number for level that is accessible from worldmap
%patch  $60B3  $1F

# ($60B6): Use one byte format for gamestate.leveldone
# ($60B6): (This is the check for completed levels in PatchWorldMap)
%patch  $60B6  $80 $BD $6F1CW $00 $90 $90 $90 $90

# ($6211): Level entry text code.
# ($6211): Note that all entry texts must start with "Keen "
# ($6211): and these 5 chars are copied from the
# ($6211): "Keen steps out onto Korath III" text
%patch  $6208  $0D
%patch  $6211  $B8 $0223W $77 $2B $1E $07 $57 $56 $BE $0223W $BF $6F88W $FC
    $A4 $A5 $A5 $5E $8B $1E $9E55W $D1 $E3 $B8 $2004RW $50 $FF $B7 $17D8W $1E
    $57 $9A $000037B3RL $83 $C4 $08 $8D $45 $FB $5F

# ($65FB): Level name segment (ID_CA) for "Keen dead" window
%patch  $65FB  $B8 $13A0RW $50 $90 $90

# ($6A8F): One byte format for gamestate.leveldone
%patch  $6A8F  $C6 $87 $6F1CW $0E $90 $90 $90
%patch  $6AF1  $C6 $87 $6F1CW $01 $90 $90 $90

# ($7797): Maximum level number for F10+W cheat
%patch  $7799  $1F

# ($7CEB): Level name segment (ID_CA) for status window
# ($7CEF): Level number for secret level must be added to
# ($7CEF): this number! (status window for worldmap)
# ($7CEF): The original number (start of array) is $1774W
# ($1781W is level $0D = 13)
%patch  $7CEB  $B8 $13A0RW $50 $FF $36 $1781W
# Level name segment (ID_CA) for status window
%patch  $7D08  $B8 $13A0RW $50 $90 $90

# ($8C1E): The number of levels (for music)
# ($8C1E): (Abiathar may generate a patch for this, please check)
%patch  $8C20  $20

# ($8C39): Use one byte format for the "music for levels" array
# ($8C39): Note that the format must be different from that
# ($8C39): generated by Abiathar
%patch  $8C39  $8A $84 $033AW $30 $E4 $89 $C7

# ($D2BF): Maximum infoplane value on worldmap for level entry
# ($D2BF): (contains level number - 1)
%patch  $D2C2  $C01FW

# ($EC2F): Level number for alternative ending must be added to this number
# ($EC2F): The original number (start of array) is $6F1CW
# ($6F29W is level $0D = 13)
%patch  $EC2F  $80 $BF $6F29W

# ($ED0C): Level number for alternative ending must be added to this number
# ($ED0C): The original number (start of array) is $6F1CW
%patch  $ED0C  $80 $BF $6F29W

# ($14360): Eliminate usages for overwritten "Keen Dreams style"
# ($14360): loading window functions

%patch $14360  $B8 $0001W $A2 $6FECW $88 $26 $9E4EW $F7 $D8 $A3 $9E55W $5D $CB
    

# ($14C75): "debughandle" and "profilehandle" are the variables preceding
# ($14C75): "mapheaderseg" in the DATA segment, and both are unused.
# ($14C75): Therefore, it is possible to increase the size of "mapheaderseg"
# ($14C75): from 30 to 32 by moving its start offset backwards by 4 bytes.
%patch $14C77  $C2DBW
%patch $14C86  $C2DBW
%patch $14CC0  $C2DBW
%patch $14D03  $C2DBW
%patch $14D30  $C2DBW
%patch $14D48  $C2DBW
%patch $14D59  $C2DBW
%patch $14D78  $C2DBW
%patch $14FA7  $C2DBW
%patch $14FB5  $C2DBW
%patch $176AF  $C2DBW

# --- Level names ---

# The level names are stored in the ID_CA segment
# They overwrite the unused "Keen Dreams loading screen"
# functions plus two additional functions.

# Note: The level names and entry texts are stored in a format
# that is not compatible with the available tools for editing
# them such as Startext.

%patch $1504D "Omegamatic" $00
%patch $15058 "Ion Ventilation System" $00
%patch $1506F "Security Center" $00
%patch $1507F "Defense Tunnel Vlook" $00
%patch $15094 "Energy Flow Systems" $00
%patch $150A8 "Defense Tunnel Burrh" $00
%patch $150BD "Regulation" $0A "Control Center" $00
%patch $150D7 "Defense Tunnel Sorra" $00
%patch $150EC "Neutrino" $0A "Burst Injector" $00
%patch $15104 "Defense Tunnel Teln" $00
%patch $15118 "Brownian" $0A "Motion Inducer" $00
%patch $15130 "Gravitational" $0A "Damping Hub" $00
%patch $1514A "Quantum" $0A "Explosion Dynamo" $00
%patch $15163 "Korath III Base" $00
%patch $15173 "BWBMegarocket" $00
%patch $15181 "High Scores" $00
%patch $1518D "Unknown level 16" $00
%patch $1519E "Unknown level 17" $00
%patch $151AF "Unknown level 18" $00
%patch $151C0 "Unknown level 19" $00
%patch $151D1 "Unknown level 20" $00
%patch $151E2 "Unknown level 21" $00
%patch $151F3 "Unknown level 22" $00
%patch $15204 "Unknown level 23" $00
%patch $15215 "Unknown level 24" $00
%patch $15226 "Unknown level 25" $00
%patch $15237 "Unknown level 26" $00

%patch $13A5C "Unknown level 27" $00 
%patch $13A6D "Unknown level 28" $00
%patch $13A7E "Unknown level 29" $00

%patch $14371 "Unknown level 30" $00 
%patch $14382 "Unknown level 31" $00

# The level name array contains offsets only, the segments are coded
# into patches for functions that use the level name strings.

%patch $31AB4
    $164DW $1658W $166FW $167FW
    $1694W $16A8W $16BDW $16D7W
    $16ECW $1704W $1718W $1730W
    $174AW $1763W $1773W $1781W
    $178DW $179EW $17AFW $17C0W
    $17D1W $17E2W $17F3W $1804W
    $1815W $1826W $1837W $005CW
    $006DW $007EW $0971W $0982W
    
# Level entry texts with the common "Keen " start removed.
# The space for level names AND entry texts in KEEN5 executable
# are used for the entry texts only.

%patch $20040 "purposefully" $0A "wanders about the" $0A "Omegamatic" $00
%patch $2006A "investigates the" $0A "Ion Ventilation System" $00
%patch $20092 "struts through" $0A "the Security Center" $00
%patch $200B5 "invades" $0A "Defense Tunnel Vlook" $00
%patch $200D2 "engages" $0A "Energy Flow Systems" $00
%patch $200EE "barrels into" $0A "Defense Tunnel Burrh" $00
%patch $20110 "goes nuts in" $0A "the Regulation" $0A "Control Center" $00
%patch $2013B "regrets entering" $0A "Defense Tunnel Sorra" $00
%patch $20161 "blows through" $0A "the Neutrino" $0A "Burst Injector" $00
%patch $2018B "trots through" $0A "Defense Tunnel Teln" $00
%patch $201AD "breaks into" $0A "the Brownian" $0A "Motion Inducer" $00
%patch $201D5 "hurries through" $0A "the Gravitational" $0A "Damping Hub" $00
%patch $20203 "explodes into" $0A "the Quantum" $0A "Explosion Dynamo" $00
%patch $2022E "faces danger" $0A "in the secret" $0A "Korath III Base" $00
%patch $20259 "will not be" $0A "in the BWBMegarocket" $00
%patch $2027A "unexplainedly" $0A "finds himself by" $0A "theHigh Scores" $00
%patch $202A8 "enters unknown" $0A "placeholder level 16" $00
%patch $202CC "enters unknown" $0A "placeholder level 17" $00
%patch $202F0 "enters unknown" $0A "placeholder level 18" $00
%patch $20314 "enters unknown" $0A "placeholder level 19" $00
%patch $20338 "enters unknown" $0A "placeholder level 20" $00
%patch $2035C "enters unknown" $0A "placeholder level 21" $00
%patch $20380 "enters unknown" $0A "placeholder level 22" $00
%patch $203A4 "enters unknown" $0A "placeholder level 23" $00
%patch $203C8 "enters unknown" $0A "placeholder level 24" $00
%patch $203EC "enters unknown" $0A "placeholder level 25" $00
%patch $20410 "enters unknown" $0A "placeholder level 26" $00
%patch $20434 "enters unknown" $0A "placeholder level 27" $00
%patch $20458 "enters unknown" $0A "placeholder level 28" $00
%patch $2047C "enters unknown" $0A "placeholder level 29" $00
%patch $204A0 "enters unknown" $0A "placeholder level 30" $00
%patch $204C4 "enters unknown" $0A "placeholder level 31" $00

%patch $31B18
    $0000W $002AW $0052W $0075W
    $0092W $00AEW $00D0W $00FBW
    $0121W $014BW $016DW $0195W
    $01C3W $01EEW $0219W $023AW
    $0268W $028CW $02B0W $02D4W
    $02F8W $031CW $0340W $0364W
    $0388W $03ACW $03D0W $03F4W
    $0418W $043CW $0460W $0484W
    
# New music data format, one byte for each level
# Note that the format is different from that generated by Abiathar

%patch $3067A
    $0b $05 $07 $09 $0a $09 $0a $09 $0a
    $09 $0a $03 $0d $04 $0c $02 $06 $01
    $00 $08
    $0b $05 $07 $09 $0a $09 $0a $09 $0a
    $09 $0a $03 $0d $04 $0c $02 
You might consider creating a source code mod instead of a patch-based mod as it provides more flexibility compared to patching.
(Edit - fixed an error in one of the patches)
Last edited by nwe74 on Sat Nov 30, 2024 19:53, edited 1 time in total.
SodiumtheGlitcher
Vortininja
Posts: 40
Joined: Wed Oct 16, 2024 0:24
Location: Impossible Bulleting out of Keen 6

Re: Patch Requests

Post by SodiumtheGlitcher »

Thanks for the patches! I'm new to modding, and the KeenWiki source modding tutorial is not finished, so I don't know how to make a source mod. But these patches are still helpful.

The levels without music could be a problem, so could someone tell me how to add music to levels past level 16?
Put me in a room full of chlorine. Results: I die and turn into a pillar of salt and a very buggy Keen 6.

IMPOSSIBLE BULLET FOR LIFE!!!!!!!!!!!!!
nwe74
Grunt
Posts: 6
Joined: Sun Sep 18, 2022 18:29

Re: Patch Requests

Post by nwe74 »

Music numbers for levels can be edited using Abiathar.
By default, it will generate patches for the music numbers which will look something like this (but with different numbers):

Code: Select all

%patch $3067A $0000W
              $0001W
              $0002W
              $0003W
              $0004W
              (and so on)
              

It must be changed to the following format:

Code: Select all

%patch $3067A 
              $00
              $01
              $02
              $03
              $04
Post Reply