Patch Requests

A general chat area, here you can post anything that doesn't belong in another forum.
Post Reply
User avatar
SodiumtheGlitcher
Vortininja
Posts: 78
Joined: Wed Oct 16, 2024 0:24
Location: Impossible Bulleting out of Keen 6 and Geometry Dashin' both at the same time

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: 8
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.
User avatar
SodiumtheGlitcher
Vortininja
Posts: 78
Joined: Wed Oct 16, 2024 0:24
Location: Impossible Bulleting out of Keen 6 and Geometry Dashin' both at the same time

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: 8
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
User avatar
SodiumtheGlitcher
Vortininja
Posts: 78
Joined: Wed Oct 16, 2024 0:24
Location: Impossible Bulleting out of Keen 6 and Geometry Dashin' both at the same time

Re: Patch Requests

Post by SodiumtheGlitcher »

Can someone give me a patch that allows you to put your own demos into the game without exporting graphics with modkeen or keengraph?
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!!!!!!!!!!!!!
User avatar
Dave216
Vortininja
Posts: 124
Joined: Wed Jun 29, 2022 15:37
Location: Croatia

Re: Patch Requests

Post by Dave216 »

SodiumtheGlitcher wrote: Tue Dec 24, 2024 20:43 Can someone give me a patch that allows you to put your own demos into the game without exporting graphics with modkeen or keengraph?
Why don't you not use modkeen or keengraph? I can't imagine how this could be done any other way.
"I don’t care what model it was! No vacuum cleaner should give a human being a double polaroid!"
weareeletric
Grunt
Posts: 13
Joined: Mon Aug 28, 2023 12:41

Re: Patch Requests

Post by weareeletric »

I think Dave has a point. Modkeen and Keengraph are the best tools for this kind of thing, and trying to bypass them might make things more complicated than necessary.
User avatar
SodiumtheGlitcher
Vortininja
Posts: 78
Joined: Wed Oct 16, 2024 0:24
Location: Impossible Bulleting out of Keen 6 and Geometry Dashin' both at the same time

Re: Patch Requests

Post by SodiumtheGlitcher »

My project that I am using this for is already configured to not be able to modify the graphics, and setting up a new project doesn't work because the old one didn't have the graphics able to be modified. So could I still have the patch?
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!!!!!!!!!!!!!
User avatar
Quillax
Vorticon Elite
Posts: 627
Joined: Sat Mar 14, 2015 14:41
Location: Quillax Ship
Contact:

Re: Patch Requests

Post by Quillax »

Are you using Abiathar? You should be able to make a new project by selecting the game files used in your mod (at least in the advanced setup). The project file (.adeps) is just a configuration of settings for Abiathar to use by default, I believe.
Quillax Ship - Where you can download all of my cool, keen mods and super-marvelous fangames!
User avatar
Dave216
Vortininja
Posts: 124
Joined: Wed Jun 29, 2022 15:37
Location: Croatia

Re: Patch Requests

Post by Dave216 »

If you're referring to your project in Abiathar, you can always change your project settings in Project Wizard in the Edit panel. This mostly serves so that Abiathar knows which files you are using for your graphics so they are properly displayed in the program. All the import/export graphic-wise is done outside Abiathar.


I've been using ModKeen for all my projects, but uGrab has become the standard default. If you downloaded the KeenModdingPackage, it already contains all you need.

In very short summary, all you need is place both ugrab_k4_out.bat and ugrab_k4_in.bat in your project folder, and keen4_ega_apogee_14.def file. They can be found in the uGrab folder in the modding package.

ugrab_k4_in_.bat = imports graphics

ugrab_k4_out.bat = exports graphics( it will make a BMP folder)

Record DEMO in-game by pressing D + F10 and press it once again once you're done. It will make a file in the game folder, and just rename that file as DEMO01.CK4 , DEMO02.CK4, DEMO03.CK4(…) and place it in your BMP folder and import it. I still have trouble remembering which demo is used for highscore, but it's either the first one or the last one, I am unsure.

You will also just need to use a patch for custom graphics.

# Load the modified graphics
%egahead EGAHEAD.CK4
%egadict EGADICT.CK4

And check out the modding tutorial for more information about importing custom graphics or, in your case, demos.

I don't think you'll be getting a patch for this, and I think this is your best option. I hope this helps!
"I don’t care what model it was! No vacuum cleaner should give a human being a double polaroid!"
User avatar
Quillax
Vorticon Elite
Posts: 627
Joined: Sat Mar 14, 2015 14:41
Location: Quillax Ship
Contact:

Re: Patch Requests

Post by Quillax »

Dave216 wrote: Wed Dec 25, 2024 18:26 I still have trouble remembering which demo is used for highscore, but it's either the first one or the last one, I am unsure.
The last demo (DEMO4) is used for high scores. Aside from that, the demos are numbered according to the order they are played. I just think to myself that the high scores demo is in an unusual level so therefore it's numbered after all the standard demos.
Quillax Ship - Where you can download all of my cool, keen mods and super-marvelous fangames!
User avatar
SodiumtheGlitcher
Vortininja
Posts: 78
Joined: Wed Oct 16, 2024 0:24
Location: Impossible Bulleting out of Keen 6 and Geometry Dashin' both at the same time

Re: Patch Requests

Post by SodiumtheGlitcher »

I did what you said, but now if I place any tile, Abiathar instantly crashes. Please help!
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: 8
Joined: Sun Sep 18, 2022 18:29

Re: Patch Requests

Post by nwe74 »

Does Abiathar show some error message before it crashes? That may help to find what the problem is.
Did you manage to create the modified EGAGRAPH and EGAHEAD files with the new demo files in them using uGrab before editing the levels in Abiathar?

However, I have created the patches you asked for. I hope this can help if you still have issues with Abiathar. You did not mention which Keen episode you are modding, I assume Keen 5 based on your previous post, but I have also made a Keen 4 version.

Code: Select all

# --- Keen 5, load demos from files named DEMO?.CK5 ---
# ($5902): This patch modifies the function responsible for loading
# ($5902): demos. The demo will be loaded from a file rather than
# ($5902): a chunk in the EGAGRAPH file.
# ($5929): No stack cleanup needed here, the program will exit
%patch  $5902  $57 $8B $46 $06 $04 $30 $A2 $0195W $9A $05C10067RL $B8 $8001W
    $50 $B8 $0191W $50 $9A $00001D8DRL $83 $C4 $04 $3D $FFFFW $75 $09 $B8
    $018AW $50 $9A $037D022FRL $89 $C6 $BF $0004W $57 $8D $46 $FC $50 $56 $9A
    $00001F10RL $83 $C4 $06 $39 $F8 $75 $E0 $8B $46 $FC $A3 $6F68W $8B $46 $FE
    $A3 $9BA9W $31 $D2 $52 $50 $BF $9BABW $57 $9A $1657071FRL $83 $C4 $06 $B8
    $0001W $50 $57 $9A $16570AE2RL $83 $C4 $04 $31 $C0 $50 $FF $76 $FE $FF $35
    $50 $56 $9A $13A000F1RL $83 $C4 $0A $09 $C0 $74 $A1 $56 $9A $0000026DRL 
    $58 $5F

# ($304CA): The "Demo loop exited???" message should never appear.
# ($304CA): The name of the demo file is placed here.
# ($304CA): Note that the name of the demo file is also part of
# ($304CA): a longer string, the error message.
%patch $304CA  "Error: " 
    "DEMO?.CK5" $00

Code: Select all

# --- Keen 4, load demos from files named DEMO?.CK4 ---
# ($5908): This patch modifies the function responsible for loading
# ($5908): demos. The demo will be loaded from a file rather than
# ($5908): a chunk in the EGAGRAPH file.
# ($592F): No stack cleanup needed here, the program will exit
%patch  $5908  $57 $8B $46 $06 $04 $30 $A2 $01E5W $9A $05C40063RL $B8 $8001W
    $50 $B8 $01E1W $50 $9A $00001D8DRL $83 $C4 $04 $3D $FFFFW $75 $09 $B8
    $01DAW $50 $9A $037D022FRL $89 $C6 $BF $0004W $57 $8D $46 $FC $50 $56 $9A
    $00001F10RL $83 $C4 $06 $39 $F8 $75 $E0 $8B $46 $FC $A3 $7A68W $8B $46 $FE
    $A3 $A541W $31 $D2 $52 $50 $BF $A543W $57 $9A $155E0712RL $83 $C4 $06 $B8
    $0001W $50 $57 $9A $155E0AD5RL $83 $C4 $04 $31 $C0 $50 $FF $76 $FE $FF $35
    $50 $56 $9A $12A600F4RL $83 $C4 $0A $09 $C0 $74 $A1 $56 $9A $0000026DRL 
    $58 $5F

# ($2F04A): The "Demo loop exited???" message should never appear.
# ($2F04A): The name of the demo file is placed here.
# ($2F04A): Note that the name of the demo file is also part of
# ($2F04A): a longer string, the error message.
%patch $2F04A  "Error: "
    "DEMO?.CK4" $00
User avatar
SodiumtheGlitcher
Vortininja
Posts: 78
Joined: Wed Oct 16, 2024 0:24
Location: Impossible Bulleting out of Keen 6 and Geometry Dashin' both at the same time

Re: Patch Requests

Post by SodiumtheGlitcher »

Thanks for the patches! They work like a charm! The only slight annoyance is that the game crashes in the demo every time I get far enough into it because I do not have the files provided, but I'll get there. Thanks again!
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: 8
Joined: Sun Sep 18, 2022 18:29

Re: Patch Requests

Post by nwe74 »

As a temporary solution, you can just copy your DEMO0.CK5 (or CK4) demo and rename it to DEMO1.CK5, DEMO2.CK5, etc. whichever you are missing. For the high scores demo (DEMO4.CK5) you can use the files extracted from the original game using uGrab.
Post Reply