Author Topic: Sprite Insertion  (Read 527 times)

Fauntleroy

  • Architect of Kajar
  • Guardian (+100)
  • *
  • Posts: 120
  • Inclinata resurgit
    • View Profile
Sprite Insertion
« on: March 06, 2018, 09:41:43 pm »
This is what I've been dreading.

I've tried reading the old discussions here, as well as Geiger's documents, but I'm not putting this together right in my head.

I want to add three special poses for Schala. Is there "room" to add three poses to Schala's existing sprite, or do I need to make these three poses separate sprites, and then switch between the sprites as needed?

What offsets are available for inserting additional sprite graphics? Once inserted into the ROM, can I manipulate them in Temporal Flux in the normal way?

Does Chrono Trigger compress its sprites? If so, what's the best way to access them?

Thanks.

Mauron

  • Guru of Reason
  • Dimension Crosser (+1000)
  • *
  • Posts: 1209
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Sprite Insertion
« Reply #1 on: March 06, 2018, 11:27:26 pm »
You'll need to edit both Schala's sprites and sprite assembly. Any new tiles will need to be added to her compressed sprite packet, and sprite assembly will need to be modified to put them together.

You'll probably have to move both the compressed sprite packet and the sprite assembly in order to add more.

Compressed packets can be handled through Temporal Flux's compression menu, and reinserted in any free space. Make sure you reserve the free space in Temporal Flux's Custom Data option to protect your new data.

Boo the Gentleman Caller

  • Guru of Life
  • Lavos (+4000)
  • *
  • Posts: 4373
    • View Profile
Re: Sprite Insertion
« Reply #2 on: March 07, 2018, 11:47:42 am »
Dude, sprite insertion is a pain.

TheMage is good at it and may have created some documentation for it two or three years ago.

Mauron

  • Guru of Reason
  • Dimension Crosser (+1000)
  • *
  • Posts: 1209
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Sprite Insertion
« Reply #3 on: March 07, 2018, 03:11:49 pm »
I gave TheMage some notes on overworld backgrounds ages ago. I'll have to update them for sprites.

Boo the Gentleman Caller

  • Guru of Life
  • Lavos (+4000)
  • *
  • Posts: 4373
    • View Profile
Re: Sprite Insertion
« Reply #4 on: March 07, 2018, 05:40:09 pm »
I should have known you created them. :)

Mauron

  • Guru of Reason
  • Dimension Crosser (+1000)
  • *
  • Posts: 1209
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Sprite Insertion
« Reply #5 on: March 07, 2018, 05:47:22 pm »
I might have done some sprite tutorials back then, but the site they'd be on is behaving inconsistently for me right now.

Boo the Gentleman Caller

  • Guru of Life
  • Lavos (+4000)
  • *
  • Posts: 4373
    • View Profile
Re: Sprite Insertion
« Reply #6 on: March 07, 2018, 10:38:40 pm »
If you're referring to the forums we frequent for other stuff, I've had the same issue. It must be a hosting issue. It was down for a week or so recently and I thought for sure someone pulled the site down or something.

Fauntleroy

  • Architect of Kajar
  • Guardian (+100)
  • *
  • Posts: 120
  • Inclinata resurgit
    • View Profile
Re: Sprite Insertion
« Reply #7 on: March 08, 2018, 09:22:50 pm »
Hey, there's the only wrinkle.

I'll just tell you, these additional poses are for the campfire scene. I need one for Schala by the fire and one for her asleep. She won't move at all during the scene. So wouldn't it be easier to create these as new, separate sprites, rather than edit the main Schala sprite? Then I could just add these to empty space without having to move any other stuff.

Or is there a reason this is impractical or just wouldn't work?

Just trying to make this as easy as possible for myself!

Mauron

  • Guru of Reason
  • Dimension Crosser (+1000)
  • *
  • Posts: 1209
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Sprite Insertion
« Reply #8 on: March 09, 2018, 02:12:42 pm »
The process is pretty much the same either way, but there are some unused packets you can use.

1) Locate the graphics packet you want to modify. This is displayed in NPCustom and Fiendcrafter.
2) Find the address of that packet with a hex editor. 0x242000 + graphics packet * 3 will have a 3-byte pointer to the address of the packet. It will be little endian, so the bytes are reversed. 00 56 C4 would be 0xC45600. Subtract 0xC00000 from this, so 0x045600 for this example.
3) Decompress the packet from Temporal Flux's compression menu, using the address from above. Make a note of the compressed size.
4) Add tiles to your decompressed packet using Tile Molester/YY-Char/something along those lines.
5) Attempt to compress the modified packet back into the original space. If the compressed size is less than or equal to the previous compressed size, save it and skip to step 9. If it's larger, you'll need to find free space.
6) Check Geiger's Offsets, NA.txt for space at least equal to the new compressed size. Try adding this to the Custom Data section with Overrride Free Space set to true. If the status bar at the bottom says Warning - Free Space in Use (or something like that), try a different address.
7) Compress the modified packet at the new address and save.
8) Change the pointer from step 2 to the new address. If it's less than 0x400000, add 0xC00000 to it.
9) Locate the sprite assembly you need. The packet can be found in NPCustom or Fiendcrafter. 0x242300 + sprite assembly packet * 3. The same steps are needed. This can be skipped if you're overwriting an empty packet.
10) Check Geiger's Offsets, NA to see where the packet ends. It will be listed as (xx) Sprite Assembly, with xx being the packet number.
11) If adding, you'll need to move the sprite assembly to free space, with 40 bytes (decimal) per additional frame. The same principles for reserving space and adjusting the pointer apply.
12) Put together the frames using a sprite assembly tutorial. There are a couple floating around.
13) If you made a new packet, using NPCustom or Fiendcrafter, put together a sprite using the correct graphics.

That should cover everything. The unused graphics packets are 47, 4A, CC, and E5. The unused assembly packets are 08, 09, 0A, 8C, C5, and D8.

Fauntleroy

  • Architect of Kajar
  • Guardian (+100)
  • *
  • Posts: 120
  • Inclinata resurgit
    • View Profile
Re: Sprite Insertion
« Reply #9 on: March 10, 2018, 01:29:54 am »
This is crazy helpful, Mauron. Thank you!!!

Mauron

  • Guru of Reason
  • Dimension Crosser (+1000)
  • *
  • Posts: 1209
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Sprite Insertion
« Reply #10 on: March 10, 2018, 01:33:44 am »
Let me know if you have any issues.

Fauntleroy

  • Architect of Kajar
  • Guardian (+100)
  • *
  • Posts: 120
  • Inclinata resurgit
    • View Profile
Re: Sprite Insertion
« Reply #11 on: March 11, 2018, 07:16:40 pm »
Finally getting to play with this.  I always get tripped up on hex math.

I want to use graphics packets E0 and E1, as these two enemies are fully deprecated in my hack.

242000 + E0 * 03 brings me to A0626C, which is not a large enough value to subtract C00000 from. What am I missing?

Mauron

  • Guru of Reason
  • Dimension Crosser (+1000)
  • *
  • Posts: 1209
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Sprite Insertion
« Reply #12 on: March 12, 2018, 01:13:57 am »
1) Follow order of operations. Multiplication before addition. The result should be 0x2422A0.
2) Navigate to that address in a hex editor. There you'll find 33 E5 DA, which becomes 0xDAE533

Fauntleroy

  • Architect of Kajar
  • Guardian (+100)
  • *
  • Posts: 120
  • Inclinata resurgit
    • View Profile
Re: Sprite Insertion
« Reply #13 on: March 12, 2018, 08:17:46 pm »
Thank you.  I flunked math repeatedly.

EDITED TO ADD: Worked like a charm! And careful placement of tiles meant no tiresome fuckery with sprite assembly.



And in the wild...





Feels SO GOOD to accomplish this. THANKS AGAIN, MAURON!
« Last Edit: March 12, 2018, 11:58:55 pm by Fauntleroy »

skylark

  • Acacia Deva (+500)
  • *
  • Posts: 552
    • View Profile
Re: Sprite Insertion
« Reply #14 on: March 15, 2018, 04:09:48 pm »
O_O!!!

What project was this?

That Schala, doe... :oops: