Patch:Music

From KeenWiki
Jump to: navigation, search

This page covers music related patches. As such, it relates mostly to Keen Galaxy. At present, about the only patches available are those that will change what song plays in a level.

There is a patch and program created by User:Lemm to allow IMF files of up to 32 KB in Keen Vorticons.


Keen Vorticons music

The TSR TSMusic created by User:Lemm allows a modder to include as many IMF music files as they wish, one per level. To be used TSMusic requires the Keen engine to coomunicate with it, and thus a patch. The patches for Keen 1–3 (v1.31) are as follows:

Patch: Keen 1
#Play music with TSMusic:
%patch $BE97 $65 %patch $BEE2 $65

Patch: Keen 2
#Play music with TSMusic:
%patch $B5AF $65 %patch $B5FA $65

Patch: Keen 3
#Play music with TSMusic:
%patch $C90D $65 %patch $C958 $65


Keen Galaxy Level songs

These patches change what song is played in a given level. You are limited only to songs in the AUDIO.CKx file. For other music, the values used are not the song number, but the level number that plays the song you want, with some complications. (It is best to experiment with these later values, to see how things work.)

Additional songs can be added to the game by using a chunk designated for sound to hold an extra songs. In the executable, the audio chunk pointers are ordered so that the music chunk pointers are immediately after the sound chunk pointers. Thus, if you shift the boundary between sound and music backwards, you create more space for music chunk pointers at the expense of sound chunk pointers. This also shifts the existing song numbers correspondingly (e.g. if you shift by two chunks, a song that was originally song 3 becomes song 5, since the first music chunk is now two chunks earlier). To use the extra songs patch, lower the existing start index of the song chunks by however many new songs you are adding. Then lower the corresponding start of audio segment pointer by 2x however many songs you imported. For example, in keen 5, if you were to add two songs, %patch $8C61 $00C0W would be lowered to $00BE, and %patch $8BF1 $BF45W would be lowered to $BF41W (along with the two subsequent patches). Finally, you would have to change the total number of songs from 14 to 16.

In Keen 4 it is also possible to play music in the Patch:Main menu or computer wrist, see the pages for details.

Patch: Keen 4
#Where music list is read from:
%patch $8CCD $0396W
#$2F206
%patch $8CA4 $14
#Total number of level entries
#Song values:
#0: Shadowlands 1: Eat your Veggies
#2: Too hot 3: Slug village
#4: Kick in the pants 5: Ancients
#This is the music played in each level:
# VALUE LEVEL MUSIC PLAYED LEVEL No
%patch $2F206 $0000W
#Map (Shadowlands) 0
$0004W
#Border Village (Kick in the Pants) 1
$0003W
#Slug Village (Slug Village) 2
$0003W
#Perilous Pit (Slug Village) 3
$0002W
#Cave of Descendants (Too Hot) 4
$0002W
#Chasm of Chills (Too Hot) 5
$0004W
#Crystalus (Kick in the Pants) 6
$0003W
#Hillville (Slug Village) 7
$0001W
#Sand Yego (Eat your Veggies) 8
$0001W
#Miragia (Eat your Veggies) 9
$0001W
#Lifewater Oasis (Eat your Veggies) 10
$0002W
#Pyramid of Moons (Too Hot) 11
$0002W
#Pyramid of Shadows (Too Hot) 12
$0002W
#Pyramid of Ancients (Too Hot) 13
$0002W
#Pyramid of Forbidden (Too Hot) 14
$0002W
#Isle of Tar (Too Hot) 15
$0002W
#Isle of Fire (Too Hot) 16
$0001W
#Well of Wishes (Eat your Veggies) 17
$0003W
#Bwb Megarocket (Slug Village) 18
$FFFFW
#High scores (No music, "Fanfare") 19
#Other music played: (Values here is number of LEVELS whose music is used)
%patch $5836 $000CW
#Story demo (Too hot)
%patch $9CD7 $0007W
#Ending Sequence (Slug Village)
%patch $F107 $FFFFW
#Talking to Lindsey (Ancient)
%patch $F4CA $FFFFW
#Talking to Ancient (Ancient)
#Add new music
#Index of first music chunk within audio chunks:
%patch $8CEF $009CW
#Start address of music chunks
#reduce start address by 2x that of "First Audio Entry"
%patch $8C75 $C895W
#Clear_music()
%patch $8C83 $C895W
#Clear_music()
%patch $8D83 $C895W
#StartMusic()
%patch $8C91 $06
#Total Number of Songs


Patch: Keen 5
#Where music list is read from:
%patch $8C3F $033AW
#$3067A
%patch $8C20 $14
#Total number of level entries
#Song values:
#00 = Came In 01 = Armageddon Machine
#02 = High Scores 03 = Snooping
#04 = Bagpipes 05 = Wednesday on the Beach
#06 = Unknown 07 = Security Center
#08 = Help 09 = Be Sphereful With My Diamonds
#0A = Make it Tighter 0B = Omegamatic
#0C = Fanfare 0D = Quantum Explosion Dynamo
#This is the music played in each level:
# VALUE LEVEL MUSIC PLAYED LEVEL No
%patch $3067A $000BW
#Map (Omegamatic) 0
$0005W
#Ion Ventilation System (Wednesday on the Beach) 1
$0007W
#Security Center (Security Center) 2
$0009W
#Defense Tunnel Vlook (Be Sphereful) 3
$000AW
#Energy Flow Systems (Make it Tighter) 4
$0009W
#Defense Tunnel Burrh (Be Sphereful) 5
$000AW
#Regulation Control Center (Make it Tighter) 6
$0009W
#Defense Tunnel Sorra (Be Sphereful) 7
$000AW
#Neutrino Burst Injector (Make it Tighter) 8
$0009W
#Defense Tunnel Teln (Be Sphereful) 9
$000AW
#Brownian Motion Inducer (Make it Tighter) 10
$0003W
#Gravitational Damping Hub (Snooping) 11
$000DW
#Quantum Explosion Dynamo (QED) 12
$0004W
#Korath III Base (Bagpipes) 13
$000CW
#Ending (Fanfare)
$0002W
#High Scores (High Scores) 15
%patch $3069C $0001W
#Scrolling Story (Armageddon Machine)
$0000W
#Game Over (Came In)
$0008W
#Help (Help)
#Other music played: (Values here is number of LEVELS whose music is used)
%patch $5830 $0011W
#Star Wars story
%patch $EABD $0013W
#Help
%patch $EC67 $000EW
#Ending sequence
%patch $F808 $0012W
#Game over
#Add new music
#Index of first music chunk within audio chunks:
%patch $8C61 $00C0W
#Start address of music chunks
#reduce start address by 2x that of "First Audio Entry"
%patch $8BF1 $BF45W
#Clear_music()
%patch $8BFF $BF45W
#Clear_music()
%patch $8CF5 $BF45W
#StartMusic()
%patch $8C0D $0E
#Total Number of Songs


Patch: Keen 6
#Where music list is read from:
%patch $8AA7 $030EW
#$3103E
%patch $8A88 $14
#Total number of level entries
#Song values:
#00 = A World of Wonderment 01 = Brer Tar
#02 = To the Future 03 = Faster
#04 = Space Funk 05 = Aliens Ate My Babysitter
#06 = Ominous 07 = Metal
#08 = Mamba Snake
#This is the music played in each level:
# VALUE LEVEL MUSIC PLAYED LEVEL No
%patch $3103E $0005W
#Map (Aliens Ate My Babysitter) 0
$0003W
#Bloogwaters Crossing (Faster) 1
$0001W
#Guard Post One (Brer Tar) 2
$0008W
#First Dome of Darkness (Mamba Snake) 3
$0008W
#Second Dome of Darkness (Mamba Snake) 4
$0008W
#Bloogdome (Mamba Snake) 5
$0007W
#Bloogton Manufacturing (Metal) 6
$0002W
#Bloogton Tower (To the Future) 7
$0007W
#Bloogfoods, Inc. (Metal) 8
$0001W
#Guard Post 2 (Brer Tar) 9
$0003W
#Bloogville (Faster) 10
$0002W
#BASA (To the Future) 11
$0001W
#Guard Post 3 (Brer Tar) 12
$0004W
#Bloogbase Recreational District(Space Funk) 13
$0004W
#Bloogbase Management District (Space Funk) 14
$0006W
#Bloog Control Center (Ominous) 15
$0002W
#Blooglab Space Station (To the Future) 16
$0000W
#Bean-with-Bacon Megarocket (A World of Wonderment) 17
$0000W
#High Scores (A World of Wonderment) 18
#Other music played: (Values here is number of LEVELS whose music is used)
%patch $563F $000DW
#Star wars text (Space funk)
%patch $E33C $0001W
#Molly ending (Faster)
#Index of first music chunk within audio chunks:
%patch $8AC9 $00B4W
#Add new music
#Start address of music chunks
#reduce start address by 2x that of "First Audio Entry"
%patch $8A59 $CA53W
#Clear_music()
%patch $8A67 $CA53W
#Clear_music()
%patch $8B5D $CA53W
#StartMusic()
%patch $8A75 $09
#Total number of songs

Music and extra levels

It is possible to have extra levels in Keen Vorticons and Galaxy. For Vorticons there is no issue, the TSR program will provide music for any level. With Keen Galaxy the music list must be extended, this is done by simply adding new entries to the end of it. (This will overwrite some of the Patch:F10 M Cheat text.) The extra level patch also has an entry for the number of level song entries in the list. This should match the number of levels.


Create a secondary song list

This patch creates a secondary music subroutine that uses an alternate song list/ What this means is that when used it will play the song from this list instead of the main level list. This is useful if music\level space is tight, or the modder wishes to play a song that does not appear in any possible level. It relies on using the EGAGRAPH check skip and so is incompatible with any other patches that use this.

Following the main part of the patch is a series of optional patches that make various situations in the game use this alternate song list. Any or all of them can be used or removed as desired. Note that the song to be played in these uses is highlighted in blue.

Patch: New song list
#Disable EGAGRAPH check (Frees 389 bytes at $3CF6)
%patch $3CE5 $90 $90
#New music setting code = $037D0526RL
%patch $3CF6 $55 $8B $EC $83 $EC $02 $56 $57 $8B $76 $06 $83 $FE $14 $72 $11 $83 $FE $FF $74 $0C $B8 $06CCW $50 $9A $037D022FRL $83 $C4 $02 $9A $18740B15RL $83 $FE $FF $75 $05 $BF $05 $00 $EB $08 $8B $DE $D1 $E3 $8B $BF $018EW $E9 $4F9EW
#New music list (Max length 20 entries)
%patch $2EFFE $0000W $0001W $0002W $0003W $0004W $0005W $0006W $0007W $0008W $0009W $000AW $000BW $000CW $000DW $000EW $000FW

Patch: Optional uses of new Keen 4 song list
#Use new list in story demo
%patch $5835 $B8 $0001W $50 $9A $037D0526RL
#Use new list in ending sequence
%patch $9CD6 $B8 $0001W $50 $9A $037D0526RL
#Use new list talking to Lindsey
%patch $F106 $B8 $0001W $50 $9A $037D0526RL
#Use new list when talking to Oracle Member
%patch $F4C9 $B8 $0001W $50 $9A $037D0526RL
#Play music in the main menu
#SIDE EFEFECT: Keen menu background color black, not cyan
%patch $1CC6A $B8 $0015W $50 $9A $06BD20C7RL
#Play music whenever help loaded (Overwrite cache graphic sub, thus can cause graphic glitch)
%patch $9924 $B8 $0001W $50 $9A $037D0526RL $83 $C4 $02


Insufficient Memory to play music error

This error occurs when after all the level and graphics have been loaded, there does not remain enough free memory to load the IMF music file selected for that level. The solution is to either use a smaller music file for the level or free up memory.

This error is both easy to diagnose and remedy. The first step is to load the level with the error. Using the memory test cheat (F10 + M) the amount of free memory without the music can be found. This can then be compared with the size of the IMF file needing to be played to give a good estimate of how much extra memory needs to be freed up. If a smaller music file is not desirable or cannot be found then more memory will have to be freed up. This can be constantly checked with the memory cheat.

There are three main ways to free up memory. The first is to physically shrink the level's size; each tile removed will free up six bytes of memory, so trimming a large level can save a lot. This however is often not preferable.

The second method is to lessen the number of different tiles in the level (This is why TED5 has a function to tell you how many there are.) each background tile will save 128 bytes and each foreground tile 140 bytes of memory. Again this may not be preferable, but a large level often contains many tiles that do not really add anything to it.

Finally certain sprites may be removed. Each sprite caches all its graphics into memory so it can display them A sprite can easily take up tens of kilobytes of space, the larger and showier it is, the more memory it needs. To remove a sprite cache, all instances of the sprite must be removed from the level, not one can remain.

A related solution is to edit the graphics, either making them smaller, or changing how many copies are placed into memory. (In theory this will make the sprite move less smoothy, but this is often hard to see.) This can halve or even quarter the amount of memory the sprite needs to run.

Other errors can be found at Patch:Game errors.

Patch: Insufficient memory to play music
#Keen 4 :
#Insufficient memory to play music window
%patch $8D30 $06ECW
#Text called from
%patch $2F55C "Insufficient memory" $0A "for background music!" $00
#Keen 5 :
#Insufficient memory to play music window
%patch $8CA2 $065EW
#Text called from
%patch $3099E "Insufficient memory" $0A "for background music!" $00
#Keen 6 :
#Insufficient memory to play music window
%patch $8B0A $0656W
#Text called from
%patch $31386 "Insufficient memory" $0A "for background music!" $00


Don't play music

These patches remove music from playing or changing in given situations. For disabling music in a level the best option is to create an 'empty' song with no sound and use that as the level music.

Patch: Keen 5
#No GAME OVER music
%patch $F807 $EB $0A
#No music in help menu:
%patch $EABC $EB $0A
#No music during Star Wars story:
%patch $5830 $EB $0A
#No music during ending sequence:
%patch $EC66 $EB $0A