Author Topic: Chrono Trigger Sprite Insertion -- Development of a Guide  (Read 28393 times)

FaustWolf

  • Guru of Time Emeritus
  • Arbiter (+8000)
  • *
  • Posts: 8972
  • Fan Power Advocate
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #45 on: November 14, 2008, 10:45:50 pm »
Okay, finally solved my palette dilemma thanks to your guys' help. I was completely unaware all this time that when you insert a graphic via TileMolester, you need to make sure you're viewing the graphic-to-be-inserted with its correct palette even before you do the insertion. Got it now, and it's a user-defined palette to boot, so I didn't have to extract it from a savestate at all:


So that's over and done with. I'm extremely worried about the memory management issue with the Size 1 sprites though, if only for CE's sake. The only thing I can think of to do is comb this thread for clues, but I don't even know what I'm looking for exactly.

EDIT: For what it's worth, I want to point out that there doesn't seem to be any problem with the third character's sprite, only the second's:


The fact that it's Frog and not Lucca being copied here probably clinches the supposition that it's a memory management issue and not a simple "Slash's data is overriding Lucca's" possibility.

Also, if it's any assistance in the diagnosis --

Sometimes it's Slash's tiles that are copied over Lucca, and Lucca disappears. There seems to be a tradeoff between their tiles being displayed, and the problem seems to lie in the "extra tiles beyond four" that are loaded for Slash. Either all four of Lucca's tiles are displayed and copied, or none of Lucca's tiles appear and all four of Slash's "extra" tiles are displayed and copied.

Once again the problem seems to resolve itself in-battle, but Slash's tile assembly seems to fall to pieces in-battle -- probably due to the possibility that Slash does not have a frame for every frame of animation Crono does (Slash has fewer frames than any of the playables IIRC, though he's closer than any other enemy).
« Last Edit: November 14, 2008, 10:50:28 pm by FaustWolf »

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #46 on: November 14, 2008, 10:53:03 pm »
The game doesn't read the PCs' PC sprite data in battle, so it doesn't get the sprite assembly size.

FaustWolf

  • Guru of Time Emeritus
  • Arbiter (+8000)
  • *
  • Posts: 8972
  • Fan Power Advocate
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #47 on: November 14, 2008, 11:17:19 pm »
Whoah, so does sprite assembly size apply only to Field graphics? And by extension, is it even possible for player characters to have Size 1 sprites in battle, or are they "locked" to a total of four tiles (Size 0 assembly) in battle?

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #48 on: November 14, 2008, 11:23:18 pm »
The game seems to load a value from variables starting at 7E967C to determine what sprite assembly size to use in battle. 7E967C seems to represent the sprite assembly size for all three PCs in battle.

FaustWolf

  • Guru of Time Emeritus
  • Arbiter (+8000)
  • *
  • Posts: 8972
  • Fan Power Advocate
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #49 on: November 14, 2008, 11:30:19 pm »
Aha! That should go in the Memory MAP thread too, or at least I didn't see that address in there when I looked. Anything that could possibly help us in Field (outside of Battle)?
« Last Edit: November 15, 2008, 12:49:12 am by FaustWolf »

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1774
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #50 on: November 16, 2008, 11:48:42 am »
7E967C seems to represent the sprite assembly size for all three PCs in battle.
It doesn't. The next two bytes are definitely PCs 2 and 3.

Originally all three bytes were set to 0 along with a larger section with this code:

Code: [Select]
Disassembly:
$CF/FB94 A2 EB 7F LDX #$7FEB A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0008 VC:000 00 FL:00
$CF/FB97 9E 00 2D STZ $2D00,x[$00:2D00] A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0016 VC:000 00 FL:00
$CF/FB9A CA DEX A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0024 VC:000 00 FL:00
$CF/FB9B CA DEX A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0032 VC:000 00 FL:00
$CF/FB9C 10 F9 BPL $F9    [$FB97] A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0040 VC:000 00 FL:00

I moved that code and replaced it with a simple JSR.

Code: [Select]
Disassembly:
$CF/FB94 20 85 FE JSR $FE85  [$FD:FE85] A:0064 X:151C Y:000E D:0100 DB:7F S:06F7 P:envMxdizc HC:0280 VC:000 00 FL:11
$CF/FB97 80 05 BRA $05    [$FB9E] A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0016 VC:000 00 FL:00
$CF/FB99 EA NOP A:0064 X:151C Y:000E D:0100 DB:7F S:06F7 P:envMxdizc HC:0292 VC:000 00 FL:11
$CF/FB9A EA NOP A:0064 X:151C Y:000E D:0100 DB:7F S:06F7 P:envMxdizc HC:0298 VC:000 00 FL:11
$CF/FB9B EA NOP A:0064 X:151C Y:000E D:0100 DB:7F S:06F7 P:envMxdizc HC:0304 VC:000 00 FL:11
$CF/FB9C EA NOP A:0064 X:151C Y:000E D:0100 DB:7F S:06F7 P:envMxdizc HC:0310 VC:000 00 FL:11
$CF/FB9D EA NOP A:0064 X:151C Y:000E D:0100 DB:7F S:06F7 P:envMxdizc HC:0316 VC:000 00 FL:11

I then added some new code for loading the sprite assembly size in battle. This is the moved and new code:

Code: [Select]
Disassembly:
$CF/FE85 A2 EB 7F LDX #$7FEB A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0504 VC:000 00 FL:00
$CF/FE88 9E 00 2D STZ $2D00,x[$00:2D00] A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0512 VC:000 00 FL:00
$CF/FE8B CA DEX A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0520 VC:000 00 FL:00
$CF/FE8C CA DEX A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0528 VC:000 00 FL:00
$CF/FE8D 10 F9 BPL $F9    [$FE88] A:0000 X:0000 Y:0000 D:0000 DB:00 S:01FF P:EnvmxdIzc HC:0536 VC:000 00 FL:00
$CF/FE8F E2 30 SEP #$30 A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0280 VC:000 00 FL:224
$CF/FE91 A0 02 LDY #$02 A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0286 VC:000 00 FL:224
$CF/FE93 BE 80 29 LDX $2980,y[$7F:29E6] A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0292 VC:000 00 FL:224
$CF/FE96 A9 00 LDA #$00 A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0298 VC:000 00 FL:224
$CF/FE98 18 CLC A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0304 VC:000 00 FL:224
$CF/FE99 69 05 ADC #$05 A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0310 VC:000 00 FL:224
$CF/FE9B CA DEX A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0316 VC:000 00 FL:224
$CF/FE9C 10 FB BPL $FB    [$FE99] A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0322 VC:000 00 FL:224
$CF/FE9E 3A DEC A A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0328 VC:000 00 FL:224
$CF/FE9F AA TAX A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0334 VC:000 00 FL:224
$CF/FEA0 BF 00 F0 E4 LDA $E4F000,x[$E4:051C] A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0340 VC:000 00 FL:224
$CF/FEA4 99 7C 96 STA $967C,y[$7F:96E2] A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0346 VC:000 00 FL:224
$CF/FEA7 88 DEY A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0352 VC:000 00 FL:224
$CF/FEA8 10 E9 BPL $E9    [$FE93] A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0358 VC:000 00 FL:224
$CF/FEAA C2 30 REP #$30 A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envMXdizc HC:0370 VC:000 00 FL:224
$CF/FEAC 60 RTS A:0070 X:151C Y:0066 D:0100 DB:7F S:06F7 P:envmxdizc HC:0376 VC:000 00 FL:224

I've attached an IPS patch with the changes.

[attachment deleted by admin]

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #51 on: November 16, 2008, 12:46:50 pm »
7E967C seems to represent the sprite assembly size for all three PCs in battle.
It doesn't. The next two bytes are definitely PCs 2 and 3.

Originally all three bytes were set to 0 along with a larger section with this code:

Well,  I only did some brief tests and noted that all 3 characters collapsed into junk.

FaustWolf

  • Guru of Time Emeritus
  • Arbiter (+8000)
  • *
  • Posts: 8972
  • Fan Power Advocate
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #52 on: November 16, 2008, 01:47:44 pm »
Oh damn. Mauron, I assume your code changed the PC character sprites in-battle to Size 1 assembly, and they were locked into Size 0 assembly prior? That's bad. So the game engine may have been forcing Size 0 assembly in-battle all this time? That would explain why Slash's sprite collapsed in-battle but didn't overlap Lucca's.

Looks like what we would need, theoretically, is a way of changing where the game loads player character sprite tiles into VRAM. Not even sure if it's possible though. My guess is we're looking at heavy ASM hacking.

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1774
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #53 on: November 16, 2008, 05:52:32 pm »
Oh damn. Mauron, I assume your code changed the PC character sprites in-battle to Size 1 assembly, and they were locked into Size 0 assembly prior? That's bad. So the game engine may have been forcing Size 0 assembly in-battle all this time? That would explain why Slash's sprite collapsed in-battle but didn't overlap Lucca's.
The new code should be loading the proper size for PC sprites in battle, based on what's stored in the sprite data. It seemed to be working properly in my testing.

Well,  I only did some brief tests and noted that all 3 characters collapsed into junk.
7E967C-7E967E seem to spill over into the next sprite(s) when set to higher values.

FaustWolf

  • Guru of Time Emeritus
  • Arbiter (+8000)
  • *
  • Posts: 8972
  • Fan Power Advocate
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #54 on: November 21, 2008, 08:12:53 pm »
Yeah, the new code seems to have no effect when all player characters are Size 0, so it's working correctly as far as I can tell (just checked on a fresh unheadered ROM).

This is an encouraging development though -- we would essentially have to use Mauron's patch if we ever did solve the Size 1 sprite dilemma, since the game engine normally forces Size 0 in battle from what I understand. Thanks!

EDIT:
Latest version of the sprite offsets list is attached. It's structured much more in line with what Chrono Tweaker had, taking sprite headers into account. With this document complete, I can move on to examine sprite animations. But first, I'm going to see if I can develop the skill necessary to find out how the game loads sprite tiles in VRAM.

[attachment deleted by admin]

Chrono'99

  • Guru of Reason Emeritus
  • God of War (+3000)
  • *
  • Posts: 3605
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #55 on: December 29, 2008, 08:12:38 am »
I noticed that some palette indexes don't seem to be used by any sprite according to this document (Sprite Palette Index 7 for instance). Does this mean they can safely be used as custom palettes for sprite graphic hacking? Or are they used somewhere else in the game, like weapons or battle effects perhaps?
« Last Edit: December 29, 2008, 08:21:17 am by Chrono'99 »

justin3009

  • Fan Project Leader
  • God of War (+3000)
  • *
  • Posts: 3296
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #56 on: December 29, 2008, 10:32:55 am »
I think the ones that are just one solid color can be used for what you want.  I think it was 7 8 9 that was solid gray.  I believe if they're something like that, then they're nothing important.

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #57 on: December 29, 2008, 02:32:59 pm »
There are a good 30 palettes referenced by neither NPCs or enemies. Unfortunately, I don't know if their data is used by other things. Is there a good way to check?

FaustWolf

  • Guru of Time Emeritus
  • Arbiter (+8000)
  • *
  • Posts: 8972
  • Fan Power Advocate
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #58 on: December 29, 2008, 03:24:45 pm »
D'oh! I never uploaded the much more readable version of this document. It's attached in the first post now, and I'll get it on the Compendium modification page too, sorry about that.

I've made lists of palettes used for sprites and backgrounds, but haven't for weapons and overworld sprites yet. I guess the overworld backgrounds would need a palette list as well. So I know the following objects have palettes applied to them:

Sprites (done)
Overworld Sprites
Field Backgrounds (done)
Overworld Backgrounds
Weapons
Layer 1 Effects Graphics

Am I missing anything?

justin3009

  • Fan Project Leader
  • God of War (+3000)
  • *
  • Posts: 3296
    • View Profile
Re: Chrono Trigger Sprite Insertion -- Development of a Guide
« Reply #59 on: December 29, 2008, 04:51:36 pm »
I think that's all of them.  I think the next big step we'll have to take is label all animations of characters so we have an easy list to go through.  Maybe Geiger can implement the "Scroll Down Animation" when you want to change it if we get them labeled.

On another note, I've been going through some of my Hex notes.  Should I go through and put the exact values of where each text thing is?  Then post it here for easier organization.