Author Topic: SPC limit broken!  (Read 1943 times)

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
SPC limit broken!
« on: December 10, 2006, 02:18:47 am »
I managed to go beyond the limit of 83 songs by hacking the SPC routines. However, I had to move the instrument table over to make sure I'd have enough room for another song's instruments, so we wouldn't be able to use Temporal Flux to edit the instrument table anymore if we did this.

Geiger's FF6offsets lists a place where it stores the number of songs in the game. Chrono Trigger has one too, and it's at 70AE9. Change that, and it'll change what number the last music track is. I also tweaked stuff within the SPC routines to move the SPC pointers and instrument table over.

« Last Edit: December 10, 2006, 04:23:13 am by Vehek »

ZeaLitY

  • Entity
  • End of Timer (+10000)
  • *
  • Posts: 10797
  • Spring Breeze Dancin'
    • View Profile
    • My Compendium Staff Profile
Re: SPC limit broken!
« Reply #1 on: December 10, 2006, 02:46:19 am »
I guess we'd still have the problem of selecting the songs to be used in Temporal Flux (unless Geiger issued a TF allowing a simple numerical query for music track instead of a drop-down list).

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: SPC limit broken!
« Reply #2 on: December 25, 2006, 07:52:29 pm »
Here's the parts of the SPC routines I modified. I labeled them to make it easier to remember what they did.
Code: [Select]
$C7/01EA BF 11 0E C7 LDA $C70E11,x[$C7:0E11] Loads the instrument table
$C7/0304 BF 0F 0E C7 LDA $C70E0F,x[$C7:0E0F] Loads the middle of the last SPC pointer
$C7/050F BF 18 0D C7 LDA $C70D18,x[$C7:0D18] Loads the SPC pointer table
$C7/0515 BF 19 0D C7 LDA $C70D19,x[$C7:0D19] Loads the second byte in the SPC pointer table
$C7/051B BF 1A 0D C7 LDA $C70D1A,x[$C7:0D1A] Loads the third byte in the pointer table

2008 Edit-Currently, I think I may have been wrong about C70304. I haven't seen it it executed. So it might not need to be changed.
« Last Edit: October 07, 2008, 06:07:40 pm by Vehek »

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: SPC limit broken!
« Reply #3 on: November 25, 2007, 08:08:20 pm »
Annoyingly, over the past one or two months I've discovered that many of the new SPC slots have low volume for some reason.

JLukas

  • Fan Project Leader
  • Squaretable Knight (+400)
  • *
  • Posts: 426
    • View Profile
Re: SPC limit broken!
« Reply #4 on: November 25, 2007, 09:01:23 pm »
07241D to 0724C2 is unknown volume related data.  2 bytes per song, $53 total.

My guess is the added SPCs are fetching data beyond the above range.  Relocate the above to a bigger free space area and update the pointer (do a trace)  Then experiment with the values used to see if you can adjust the volume.

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: SPC limit broken!
« Reply #5 on: November 25, 2007, 09:29:53 pm »
I don't know how to "trace" but I found the code location by searching 1D24C7. And another part of the code for that came before it. I messed up at first and entered in the wrong location, but I fixed it.
Sticking some copies of the bytes for another song after the repointed data fixed the volume problems.
Thanks!
« Last Edit: November 25, 2007, 09:43:17 pm by Vehek »

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: SPC limit broken!
« Reply #6 on: May 14, 2008, 11:45:41 pm »
I'm thinking of changing to a method a Japanese RS3 hack uses: add code to check if the song's over a certain number, and load from a different location if it is. This lets us still use Temporal Flux to change the instruments of the original songs in the game.

Of course, we still wouldn't be able to select the extra songs with Temporal Flux (except for memory assignments).
« Last Edit: May 15, 2008, 12:08:25 am by Vehek »

Shinrin

  • Chrono Trigger Threads of Time
  • Squaretable Knight (+400)
  • *
  • Posts: 487
  • Chrono Trigger Fan # 100
    • View Profile
    • Shinrin Cole
Re: SPC limit broken!
« Reply #7 on: August 23, 2008, 01:42:52 am »
Any New information on this?

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: SPC limit broken!
« Reply #8 on: August 23, 2008, 01:49:21 am »
Well, I finished a patch based on the Japanese RS3 hack's method not long after my last post in this topic. It takes up space at 450000. Additional song pointers are at 450070, additional song instrument table data at 4500D0, and volume-related data at 4506E0. This gives space for 32 (decimal) more songs.
Modified code:
Quote from: Song Instrument table
$C7/01EA 22 35 00 45 JSL $450035[$45:0035]

$45/0035 A5 0E       LDA $0E    [$00:000E]
$45/0037 C9 80       CMP #$80
$45/0039 0A          ASL A
$45/003A B0 06       BCS $06    [$0042]
$45/003C BF 11 0E C7 LDA $C70E11,x
$45/0040 80 04       BRA $04    [$0046]$45/0042 BF 70 F6 44 LDA $44F670,x[$44:F670] //New location; add $A60 to get the location of the first new song's instrument data]
$45/0046 6B          RTL

Quote from: SPC Pointers
$C7/050D 5C 00 00 45 JMP $450000[$45:0000]

$45/0000 C9 F9 00    CMP #$00F9 //Check in within original song limit
$45/0003 B0 14       BCS $14    [$0019]
$45/0005 E2 20       SEP #$20
$45/0007 BF 18 0D C7 LDA $C70D18,x
$45/000B 85 12       STA $12    [$00:0012]
$45/000D BF 19 0D C7 LDA $C70D19,x
$45/0011 85 13       STA $13    [$00:0013]
$45/0013 BF 1A 0D C7 LDA $C70D1A,x
$45/0017 80 16       BRA $16    [$002F]
$45/0019 E9 F9 00    SBC #$00F9
$45/001C AA          TAX
$45/001D E2 20       SEP #$20
$45/001F BF 70 00 45 LDA $450070,x //First byte of new SPC pointers location
$45/0023 85 12       STA $12    [$00:0012]
$45/0025 BF 71 00 45 LDA $450071,x
$45/0029 85 13       STA $13    [$00:0013]
$45/002B BF 72 00 45 LDA $450072,x
$45/002F 5C 1F 05 C7 JMP $C7051F[$C7:051F] //Back to the normal code

Quote from: Volume-related Data
$C7/0A43 5C 48 00 45 JMP $450048[$45:0048]

$45/0048 C9 A6 00    CMP #$00A6 //Check if outside song limit
$45/004B B0 0E       BCS $0E    [$005B]
$45/004D E2 20       SEP #$20         
$45/004F BF 1E 24 C7 LDA $C7241E,x
$45/0053 85 02       STA $02    [$00:0002]
$45/0055 BF 1D 24 C7 LDA $C7241D,x
$45/005B E9 A6 00    SBC #$00A6
$45/005E AA          TAX
$45/005F E2 20       SEP #$20
$45/0061 BF E1 06 45 LDA $4506E1,x[$45:06E1] //Second byte of extra volume-related data.
$45/0065 85 02       STA $02    [$00:0002]
$45/0067 BF E0 06 45 LDA $4506E0,x[$45:06E0] //First byte of extra volume-related data.
$45/006B 5C 4F 0A C7 JMP $C70A4F[$C7:0A4F]


[attachment deleted by admin]
« Last Edit: August 23, 2008, 02:16:40 am by Vehek »

Shinrin

  • Chrono Trigger Threads of Time
  • Squaretable Knight (+400)
  • *
  • Posts: 487
  • Chrono Trigger Fan # 100
    • View Profile
    • Shinrin Cole
Re: SPC limit broken!
« Reply #9 on: August 23, 2008, 03:07:19 am »
I've already moved the SPC pointer table and instrument table. just need the volume table.

also i added singing mountain as song 54, the song sounds right, but it's missing the wind.. of course i'm not gonna leave this hear, i'm planning on moving the battle music to 54+ as you can assign the battlesong in memory.

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: SPC limit broken!
« Reply #10 on: August 23, 2008, 03:13:07 am »
This is the original volume-related data code:
Quote
$C7/0A45 BF 1E 24 C7 LDA $C7241E,x
$C7/0A49 85 02       STA $02
$C7/0A4B BF 1D 24 C7 LDA $C7241D,x
$C7/0A4F 29 0F       AND #$0F
$C7/0A51 85 03       STA $03

Shinrin

  • Chrono Trigger Threads of Time
  • Squaretable Knight (+400)
  • *
  • Posts: 487
  • Chrono Trigger Fan # 100
    • View Profile
    • Shinrin Cole
Re: SPC limit broken!
« Reply #11 on: August 23, 2008, 12:27:48 pm »
I took the patch you made, and copy the information from it, and put it in a different location, you said that you can have normal volume for 33 songs in dec. how would i go to change that, if i added more songs?

I change the 84 song in CT to Battle 2, and it's not playing all the instruments that should be playing.
« Last Edit: August 23, 2008, 01:12:11 pm by Shinrin »

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: SPC limit broken!
« Reply #12 on: August 23, 2008, 08:23:40 pm »
I don't know what the problem is. The extra song slots have never worked as well as the original slots. For me, sometimes  different extra slots behave differently.

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: SPC limit broken!
« Reply #13 on: October 07, 2008, 03:18:39 pm »
Yesterday, I was doing some MML importing tests with RS3Extool2 to see what places it wrote to in the RS3 ROM. I noticed it was writing to a place I didn't expect it to, and I investigated.

The equivalent stuff for CT:

Quote
$C7/05B2 A9 71       LDA #$71                A:0000 X:FFFD Y:0000 P:envMxdIZc
$C7/05B4 85 12       STA $12    [$00:1E12]   A:0071 X:FFFD Y:0000 P:envMxdIzc
$C7/05B6 A9 18       LDA #$18                A:0071 X:FFFD Y:0000 P:envMxdIzc
$C7/05B8 85 13       STA $13    [$00:1E13]   A:0018 X:FFFD Y:0000 P:envMxdIzc
$C7/05BA A9 C7       LDA #$C7                A:0018 X:FFFD Y:0000 P:envMxdIzc
$C7/05BC 85 14       STA $14    [$00:1E14]   A:00C7 X:FFFD Y:0000 P:eNvMxdIzc
...
$C7/05E3 B7 12       LDA [$12],y[$C7:1871]   A:0003 X:000C Y:0000 P:envMxdIzC
I think the y is 0x24 * song #. Hopefully, there's nothing else the SPC routines need.

Edit-The data read in RS3 is labeled "ドラムセット" in a RS3 document. Google translated that as "drum set".
« Last Edit: October 07, 2008, 06:40:08 pm by Vehek »