User:Blaziken257/T1 Music research

From Wikifang, a definitive guide to Telefang, Dino Device and Bugsite
Revision as of 11:52, 13 December 2012 by Blaziken257 (talk | contribs) (Wow, I screwed up my math here...)
Jump to navigation Jump to search

Some research on Telefang's music.

Reading music values

On overworld map

  • Code is at 0x2E384.
  • Music is based on the Denjuu's origin in any given acre, and the game maps the value of the origin to the value of the music:

Note: Check this more thoroughly.

Origin Music
0x5 0x6
0x6 0x5
0x3 0x7
0xB 0x8
0xE 0x2A if you're in bottom-left quadrant in overworld, while in an antenna tree (i.e. 0xC904 in RAM == 0x06);
0x3 otherwise.
Everything else 0x3

In Denjuu battles

0x14620: Controls music in normal wild Denjuu battle.
0x14624: Appears to control music in T-Fanger battle. (Check this!)
0x14630: Appears to control music in boss battle. (Check this!)
0x14634: Appears to control music in Doomsday battle. (Check this!)

Finding music data in ROM

Since the music data is split up into multiple banks (each bank = 0x4000 bytes or 16 KB), a function exists at 0x15F5 to determine the bank and relative song ID.

If music ID < 0x10:
Don't change music ID, set bank to 0x20

Else if music ID < 0x20:
Subtract 0xF from music ID, set bank to 0x21

Else if music ID < 0x30:
Subtract 0x1F from music ID, set bank to 0x22

Else:
Subtract 0x2F from music ID, set bank to 0x23

New music ID is output to 0xFFA0 in RAM, bank (minus 0x20) is output to 0xCFF8 in RAM.

Sound Test

A mapping from external music IDs (i.e. visible IDs on the screen) to internal IDs are found starting at 0x12D3B in ROM.

Music table

This is in the same order as the sound test, but is sometimes split apart for some reason. (Maybe more songs were planned?)

Internal ID ROM Bank Relative ID Sound test Song Pointer
0x03 0x20 0x03 00 Overworld 0x82018
0x04 0x04 01 Cactos Ruins 0x82022
0x05 0x05 02 Ion Island 0x8202C
0x06 0x06 03 Barran 0x82036
0x07 0x07 04 Palm Sea 0x82040
0x08 0x08 05 Pepperi Mts. 0x8204A
0x09 0x09 06 Toronko Spring 0x82054
0x0A 0x0A 07 Craft Research Center 0x8205E
0x0B 0x0B 08 Burion Ruins 0x82068
0x12 0x21 0x03 09 Wild Denjuu screen 0x8601A
0x13 0x04 10 Before link battle 0x86024
0x14 0x05 11 Wild Denjuu battle 0x8602E
0x15 0x06 12 T-Fanger battle 0x86038
0x16 0x07 13 Boss/Mini-boss battle 0x86042
0x17 0x08 14 Doomsday battle 0x8604C
0x18 0x09 15 Battle win 0x86056
0x19 0x0A 16 Battle lose 0x86060
0x1A 0x0B 17 Level up 0x8606A
0x1B 0x0C 18 Game Over 0x86074
0x22 0x22 0x03 19 Kai 0x8E01A
0x23 0x04 20 Miyo 0x8E024
0x24 0x05 21 Shop 0x8E02E
0x25 0x06 22 Before battle 0x8E038
0x26 0x07 23 Nerikara 0x8E042
0x27 0x08 24 Multiplayer 0x8E04C
0x28 0x09 25 Got number 0x8E056
0x29 0x0A 26 To Denjuu World 0x8E060
0x2A 0x0B 27 Yarrow 0x8E06A
0x2B 0x0C 28 Natural evolution 0x8E074
0x2C 0x0D 29 Test evolution 0x8E07E
0x2D 0x0E 30 Experimental evolution 0x8E088
0x2E 0x0F 31 Lost phone number 0x8E09C
0x32 0x23 0x03 32 D-Shot menu 0x8E00E
0x33 0x04 33 Human World 0x8E018
0x34 0x05 34 Switch 0x8E022
0x35 0x06 35 Warp 0x8E02C
0x36 0x07 36 Title screen 0x8E040
0x37 0x08 37 Intro 0x8E036
0x38 0x09 38 Credits 0x8E04A
0x39 0x0A 39 Sanaeba 0x8E054
0x3B+ ID-0x2F -- Glitchy sound 0x8E0FC (0x3B),
0x8E0FE (some others), etc.

Anything less than 0x3B that is not listed is silent. IT IS UNLIKELY THAT THERE IS UNUSED MUSIC IN THIS GAME (much to my dismay). Unless there are songs that have no pointers, which is possible but very unlikely (hey, I've seen it elsewhere).

There appears to be some code in the game that branches whether the relative music ID is 0x00 or 0x01, but it is not known what this does.

Each bank from 0x20 to 0x23 contains code to produce the music, and contains a pointer table. A bank 0x24 also exists and seems to contain the same code as the other four banks; however, this bank is never accessed from playing anything (music or sound effects) on the sound test. What could be in here?

For banks 0x20-0x23, the pointer table starts at 0x5FE2 in RAM (therefore, the ROM offsets for these pointer tables are 0x81FE2, 0x85FE2, 0x89FE2, and 0x8DFE2). For mystery bank 0x24, the pointer table starts at 0x7D2D in RAM (so the ROM offset for this table is 0x93D2D, which is just a string of 0x00's). The pointer table offsets can be changed at 0x4C1A in RAM (which corresponds to ROM offsets 0x80C1A, 0x84C1A, 0x88C1A, 0x8CC1A, and 0x90C1A). (Don't forget that in this game, like 99% of Game Boy games, the pointers are little endian!)

Unfortunately, even when changing the pointer table offset for bank 0x24, it still has glitchy music likely derived from garbage data.