Patch:Music

From KeenWiki
Jump to navigation Jump to 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:

Keen 1

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

Keen 2

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

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.

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


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


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 called it will play a 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.

As a note the Keen 6 patch overwrites two 'Not enough memory to load levels' error texts and disables the VBL cheat.

New song list -Keen 4

#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

#OPTIONAL USES OF NEW MUSIC 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 EFFECT: 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

New song list -Keen 5

#Disable EGAGRAPH check (Frees 389 bytes at $3CF0)
%patch $3CDF $90 $90

#New music setting code = $037D0520RL
%patch $3CF0 $55 $8B $EC $83 $EC $02 $56 $57 $8B $76 $06 $83 $FE $14 $72 $11
             $83 $FE $FF $74 $0C $B8 $063EW  $50 $9A $037D022FRL     $83 $C4
             $02 $9A $196E0B13RL     $8B $DE $D1 $E3 $8B $BF $0147W  $E9 $4F20W

#New music list (Max length 20 entries)
%patch $30487 $0000W
              $0001W
              $0002W
              $0003W
              $0004W
              $0005W
              $0006W
              $0007W
              $0008W
              $0009W
              $000AW
              $000BW
              $000CW
              $000DW
              $000EW
              $000FW

#OPTIONAL USES OF NEW MUSIC LIST:
#Use new list in GAME OVER music
%patch $F807 $B8 [$0001W] $50 $9A $037D0520RL

#Use new list in music in help menu
%patch $EABC $B8 [$0001W] $50 $9A $037D0520RL

#Use new list in story demo
%patch $5830 $B8 [$0001W] $50 $9A $037D0520RL

#Use new list in ending sequence
%patch $EC66 $B8 [$0001W] $50 $9A $037D0520RL

New song list -Keen 6

#Disable Add VBLs (Free $74B0-$7535)
%patch $74AD $E9 $0086W

#New music setting code = $069A0B10RL
%patch $74B0 $55 $8B $EC $83 $EC $02 $56 $57 $8B $76 $06 $83 $FE $14 $72 $11
             $83 $FE $FF $74 $0C $B8 $0636W  $50 $9A $037B0230RL     $83 $C4
             $02 $9A $183B0B15RL     $8B $DE $D1 $E3 $8B $BF  $027BW  $E9 $15C8W

#New music list (Max length 24 entries)
%patch $30FAB $0000W
              $0001W
              $0002W
              $0003W
              $0004W
              $0005W
              $0006W
              $0007W
              $0008W
              $0009W
              $000AW
              $000BW
              $000CW
              $000DW
              $000EW
              $000FW

#Use new list in story demo
%patch $563E $B8 [$0001W] $50 $9A $069A0B10RL

#Use new list in ending sequence
%patch $E33B $B8 [$0001W] $50 $9A $069A0B10RL


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.

Insufficient memory to play music

#Insufficient memory to play music window -Keen 4:
%patch $8D18  $EB    #Never show (Free 8D1A-8D7F)
%patch $8D1B  [$0008W] #Height
%patch $8D1F  [$0014W] #Width
%patch $8D30  [$06ECW] #Text called from
%patch $2F55C "Insufficient memory" $0A
              "for background music!" $00

#Insufficient memory to play music window -Keen 5:
%patch $8C8A  $EB    #Never show (Free 8C8C-8CEE)
%patch $8C8D  [$0008W] #Height
%patch $8C91  [$0014W] #Width
%patch $8CA2  [$065EW] #Text called from
%patch $3099E "Insufficient memory" $0A
              "for background music!" $00

#Insufficient memory to play music window -Keen 6:
%patch $8AF2  $EB    #Never show (Free 8AF4-8B69)
%patch $8AF5  [$0008W] #Height
%patch $8AF9  [$0014W] #Width
%patch $8B0A  [$0656W] #Text called from
%patch $31386 "Insufficient memory" $0A
              "for background music!" $00


Disable music

These patches disable music entirely. Even if the player attempts to enable music this will fail. The first patch simply disables music. (Changing the $0000W to $0001W will force the game to always play music.) The second forces 'PC mode' where there is no music and PC sounds only will play.


Keen 4

#Disable music
%patch $18F54 $C7 $06 $C633W $0000W $90 $90

#Force PC-mode
%patch $19022 $EB

Keen 5

#Disable music
%patch $19EF2 $C7 $06 $BC9BW $0000W $90 $90

#Force PC-mode
%patch $19FC0 $EB

Keen 6

#Disable music
%patch $18BC4 $C7 $06 $C7C1W $0000W $90 $90

#Force PC-mode
%patch $18C92 $EB


Don't play music in certain situations

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. (Though Keen 4 has the option of setting a song to -1 ($FFFFW) for silence.)

Keen 4

#No music during Star Wars story:
%patch $5835 $EB $0A

#No music during ending sequence:
%patch $9CD6 $EB $0A

#No music during Lindsey talk
%patch $F106 $EB $0A

#No music during Oracle Member talk
%patch $F4C9 $EB $0A

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

Keen 6

#No music during Star Wars story:
%patch $563E $EB $0A

#No music during ending sequence:
%patch $E33B $EB $0A


Play a certain song while an item is got

This patch causes a certain level's song to be played in any normal level while some condition is met. Here the map (level 0's) music is played while Keen has the V card. Loading a saved game or going to the help\menu will result in the 'default' music restarting. By changing the $0000W a different level's music can be selected.

Keen 5

#Play a certain song while an item is got
%patch $C551 $E9 $FEFDW
%patch $C53B $E9 $FF19W
%patch $C3FC $55 $8B $EC $83 $EC $0C $56 $57 $8B $76 $06 $83 $3E {$6F5AW}  [$01]
             {$75} $0C $B8 [$0000W]  $50 $9A $06B92083RL     $83 $C4 $02 $8B $5C $2E $D1 $E3 $8B $87 $87
             $BF $D1 $E8 $E0D1W  $8B $16 $51 $9E $8B $5C $2C $D1 $E3 $03 $C3
             $89 $56 $FC $89 $46 $FA $8B $44 $30 $2B $44 $2C $40 $8B $16 $4C
             $9E $2B $D0 $89 $56 $F8 $8B $44 $2E $89 $46 $FE $E9 $00FBW  $8B
             $7C $2C $E9 $00E2W  $C4 $5E $FA $26 $8B $1F $8E $06 $61 $BF $26
             $8A $87 $0A $47 $B4 $00 $25 $7F $00 $89 $46 $F6 $0B $C0 $74 $16
             $8B $5E $F6 $83 $EB $03 $83 $FB $19 $77 $0B
%patch $8C7D $75 $08 $C7 $06 {$6F5AW}  [$0000W]  $EB $68 $FF $06 {$6F5AW}  $83 $3E
             {$6F5AW}  [$01] {$76} $06 $C7 $06 {$6F5AW}  [$0000W]  $EB $18
%patch $8CC3 $5F $5E $8B $E5 $5D $CB


Play music in Galaxy menu

This allows you to play music in the main menu. As a side effect the menu background color is black, not cyan. This only matters if your menu image is smaller than 320x200. The value used here is the level whose music is used. (For example a value of 0 will play the map level's music.) See Patch:Music.

Keen 4

#Play music in the menu
%patch $1CC6F $06BD20C7RL
%patch $1CC6B [$0003W]      #Play this level's song

Keen 5

#Play music in the menu
%patch $1DC0C $06B92083RL
%patch $1DC08 [$0003W]      #Play this level's song

Keen 6

#Play music in the menu
%patch $1C8DE $069A20DBRL
%patch $1C8DA [$0003W]      #Play this level's song


Galaxy menu doesn't stop game music

This patch lets the game music keep playing when the menu is called. This means the music playing in the level or demo the player plays before calling the menu. When the game initially starts the menu will be silent.

Keen 4

#Don't interrupt music when Main menu is called
%patch $7994 $90 $90 $90 $90
%patch $79A2 $EB $0A

Keen 5

#Don't interrupt music when Main menu is called
%patch $794F $90 $90 $90 $90
%patch $795D $EB $0A

Keen 6

#Don't interrupt music when Main menu is called
%patch $7728 $90 $90 $90 $90
%patch $7736 $EB $0A