Author Topic: Question about the Music (SPC)  (Read 867 times)

Squall

  • Dark Dragon
  • *
  • Posts: 486
    • View Profile
Question about the Music (SPC)
« on: October 17, 2016, 03:35:31 AM »
Hey guys, I'm trying to find the master table for SPC Song sequences (a table that by ID of a song you get a pointer to actual data).

According to last post here it starts at 3721D. Well it seems as master table - it contains around 44 enties, each is 3 bytes. By examining the date I found that the 3 bytes doesn't contain exact pointer (relative or absoute). It contain 2 types of data:
- EF 32 01 -> $0132EF - that should mean song with id 0 (Nothing). Actually there are 25 bytes song :)
- xx yy 01 -> $01yyxx - pointer to which we must add $024000 to actually match file offset, or C2:4000 to match ROM address

Again according to last post there is a code that 'translate' the value from master table to actual address ... but doesn't quite fit with my observation. What is the real story?

P.S. I found that in the end of the master there are couple EF 32 01 entries which mean that master table was designed to hold 43 songs but used 37.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Question about the Music (SPC)
« Reply #1 on: October 18, 2016, 12:29:28 PM »
The three bytes from that table are loaded into 1E20-1E22 in RAM, then the upper two bytes only are considered in the following subroutine:
Code: [Select]
$04/864E 08          PHP                     A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0468 VC:080 FC:30 I:00
$04/864F C2 20       REP #$20                A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0492 VC:080 FC:30 I:00
$04/8651 A5 21       LDA $21    [$00:1E21]   A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0508 VC:080 FC:30 I:00
$04/8653 C9 40 00    CMP #$0040              A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0524 VC:080 FC:30 I:00
$04/8656 B0 05       BCS $05    [$865D]      A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0540 VC:080 FC:30 I:00
$04/8658 69 C0 04    ADC #$04C0              A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0556 VC:080 FC:30 I:00
$04/865B 80 22       BRA $22    [$867F]      A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0572 VC:080 FC:30 I:00
$04/865D C9 C0 00    CMP #$00C0              A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0588 VC:080 FC:30 I:00
$04/8660 B0 05       BCS $05    [$8667]      A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0604 VC:080 FC:30 I:00
$04/8662 69 40 05    ADC #$0540              A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0620 VC:080 FC:30 I:00
$04/8665 80 18       BRA $18    [$867F]      A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0636 VC:080 FC:30 I:00
$04/8667 C9 40 01    CMP #$0140              A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0652 VC:080 FC:30 I:00
$04/866A B0 05       BCS $05    [$8671]      A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0668 VC:080 FC:30 I:00
$04/866C 69 C0 05    ADC #$05C0              A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0684 VC:080 FC:30 I:00
$04/866F 80 0E       BRA $0E    [$867F]      A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0700 VC:080 FC:30 I:00
$04/8671 C9 C0 01    CMP #$01C0              A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0716 VC:080 FC:30 I:00
$04/8674 B0 05       BCS $05    [$867B]      A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0732 VC:080 FC:30 I:00
$04/8676 69 40 06    ADC #$0640              A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0748 VC:080 FC:30 I:00
$04/8679 80 04       BRA $04    [$867F]      A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0764 VC:080 FC:30 I:00
$04/867B 18          CLC                     A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0780 VC:080 FC:30 I:00
$04/867C 69 C0 06    ADC #$06C0              A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0796 VC:080 FC:30 I:00
$04/867F 85 21       STA $21    [$00:1E21]   A:06F7 X:1E00 Y:F222 D:1E00 DB:04 S:02DC P:envmxdizc HC:0812 VC:080 FC:30 I:00
So...
Code: [Select]
IF TABLE ENTRY IS IN RANGE THEN ADD EXAMPLE
-------------------------- -------- -------
000000 - 003FFF 04C000 003FFF -> 04FFFF
004000 - 00BFFF 054000 00BFFF -> 05FFFF
00C000 - 013FFF 05C000 013FFF -> 06FFFF
014000 - 01BFFF 064000 01BFFF -> 07FFFF
01C000 AND ABOVE 06C000 0201FF -> 08C1FF
 (likely max 0201FF)

Those offsets are all LoROM, of course, so 04FFFF means 027FFF in ROM without header, or 0281FF in ROM with header.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Question about the Music (SPC)
« Reply #2 on: October 18, 2016, 12:49:09 PM »
As I noted once in this thread, there are some "songs" that are actually constantly running sound effects. looking up one of those song IDs in this table and then translating the table entry does point to what appears to be a short, previously uncharted SPC sequence.
Song 44 (rushing water sound from the Watery Pass Waterfall)'s table entry is 0136D6, which run through that subroutine comes out to 6f6d6, or 376D6 in ROM w/o header, or 378D6 in ROM with header.
I wonder: could this be the same sequence played when a sound effect is played normally, and therefore could any sound effect be set to play as a background "song?" I'm thinking so, but don't really have the time to look into that today.

Squall

  • Dark Dragon
  • *
  • Posts: 486
    • View Profile
Re: Question about the Music (SPC)
« Reply #3 on: October 18, 2016, 01:50:57 PM »
Hehe thank you chillyfeez! In your link I saw confirmation that after listed $37 songs there are 6 zero-songs (nothing) ^^

Quote
I wonder: could this be the same sequence played when a sound effect is played normally, and therefore could any sound effect be set to play as a background "song?" I'm thinking so, but don't really have the time to look into that today.
I'm getting the same feeling - sound effects are actually "songs"  :laugh:

thepatirckinator

  • Tunnel Armor
  • *
  • Posts: 159
  • Gender: Male
  • God bless you all!
    • View Profile
Re: Question about the Music (SPC)
« Reply #4 on: December 31, 2016, 06:21:10 PM »
Maybe we can make the unused songs more usable in Final Fantasy IV romhacks!