kion-dgl / Miku-Legends-2

Source Code for Writing files to the Megaman Legends 2 format to replace Megaman with Miku
GNU General Public License v3.0
2 stars 0 forks source link

Miku's face during cut scenes. #26

Closed kion-dgl closed 6 days ago

kion-dgl commented 1 month ago

I had planned for this in version 0.4 Testing confirmed that the face looks terrible during cutscenes.

image

kion-dgl commented 1 month ago

After the forbidden islands

image

kion-dgl commented 3 weeks ago

Textures are complete. Thanks to Xinus22 for these.

image

kion-dgl commented 1 week ago

So it looks like we have about 22 textures to replace. I think the place it make most sense is to start with tests. The first tests that we need to write are finding the offsets to the files that we want to replace. And then the second test is going to involve looking at the palettes in terms of what colors the game expects to be there to see if we need to, or should apply the same palette across all of the faces. Or at least have as many colors as we can have a consistent index.

kion-dgl commented 1 week ago
const CUT_SCENES = [
  {
    name: "cut-ST1CT.BIN",
    offset: 0x02d000,
    compressed: true
  },
  {
    name: "cut-ST1FT.BIN",
    offset: 0x053000,
    compressed: true
  },
  {
    name: "cut-ST03T.BIN",
    offset: 0x046000,
    compressed: true
  },
  {
    name: "cut-ST3A02.BIN",
    offset: 0x03d800,
    compressed: false
  },
  {
    name: "cut-ST4B01.BIN",
    offset: 0x023000,
    compressed: false
  },
  {
    name: "cut-ST4B01.BIN",
    offset: 0x027800,
    compressed: false
  },
  {
    name: "cut-ST4BT.BIN",
    offset: 0x03e800,
    compressed: true
  },
  {
    name: "cut-ST4CT.BIN",
    offset: 0x047800,
    compressed: true
  },
  {
    name: "cut-ST5C01.BIN",
    offset: 0x014800,
    compressed: false
  },
  {
    name: "cut-ST15T.BIN",
    offset: 0x03a800,
    compressed: true
  },
  {
    name: "cut-ST17T.BIN",
    offset: 0x052000,
    compressed: true
  },
  {
    name: "cut-ST1700.BIN",
    offset: 0x011000,
    compressed: false
  },
  {
    name: "cut-ST1701.BIN",
    offset: 0x00e800,
    compressed: false
  },
  {
    name: "cut-ST1702.BIN",
    offset: 0x00b000,
    compressed: false
  },
  {
    name: "cut-ST25T.BIN",
    offset: 0x049000,
    compressed: true
  },
  {
    name: "cut-ST27T.BIN",
    offset: 0x067000,
    compressed: true
  },
  {
    name: "cut-ST28T.BIN",
    offset: 0x06d000,
    compressed: true
  },
  {
    name: "cut-ST30T.BIN",
    offset: 0x04a000,
    compressed: true
  },
  {
    name: "cut-ST3001T.BIN",
    offset: 0x04a000,
    compressed: true
  },
  {
    name: "cut-ST39T.BIN",
    offset: 0x01e000,
    compressed: true
  },
  {
    name: "cut-ST46T.BIN",
    offset: 0x032000,
    compressed: true
  },
  {
    name: "cut-ST52T.BIN",
    offset: 0x030000,
    compressed: true
  },
  {
    name: "cut-ST0305.BIN",
    offset: 0x041000,
    compressed: false
  },
  {
    name: "cut-ST1802T.BIN",
    offset: 0x052800,
    compressed: true
  },
  {
    name: "cut-ST1803.BIN",
    offset: 0x018000,
    compressed: false
  },
  {
    name: "cut-ST2501.BIN",
    offset: 0x00a000,
    compressed: false
  }
]
kion-dgl commented 1 week ago

Now that we've managed to track down all of the offsets for the cutscene faces, the next step is to update EncodeTexture.ts to encode all of the images and replace them.

  1. We're probably going to want to keep the palettes as consistent as possible. I would hope the game would load and update the correct palette as needed, but we can't guarantee anything. Which means that we're probably going to want to find the largest number of consistent colors and use that across all of the textures.
  2. We're going to need to undo the ST3A02.BIN hack we previously did
  3. For compressed textures, we're going to need to make sure the length fits the expected length in the file.
  4. Once all of that is done, we're going to need to update EncodeRom.ts.
kion-dgl commented 1 week ago

Right now I'm going through and implementing replacing the textures for each one of the cut scenes. There is a small chance that things work out, but also things could go pretty badly.

I think we're going to be paranoid and make sure we go through each one of the textures to make sure they look correct in the file and then go from there.

In terms of uncompressed textures, it's a pretty simple search and replace. In the case of compressed textures we need to try and make sure we're getting the right length.

kion-dgl commented 6 days ago

Well.... nuts. It looks like we have a problem.

image

I finally managed to go through and get all of the textures to compress to the the right length. But it looks like things aren't quite working correctly.

image

I think the follow up is to write tests so that we can run the script to export the textures, which we can then test to render the textures and see if we get the image we expect.

Right now on a first pass of this, it looks like we have an empty texture so we'll need to look into the file to see what's wrong.

kion-dgl commented 6 days ago

I got textures working and then i broke something. Seems to be working as of a77a821. So I'll need to compare what's different from the current branch and compare.

kion-dgl commented 6 days ago

I'm not exactly sure what the problem is, but it looks like it has something to do with ST3A02.BIN. This file effectively has three textures that need to be replaced.

Body

The body is at offset 0x2c800 (not compressed)

cut-ST3A02 BIN-02c800-false

Cut Scene Face

Cut Scene face is at 0x3d800 (not compressed)

cut-ST3A02 BIN-03d800-false

Gameplay Face

Gameplay face is at 0x35000

cut-ST3A02 BIN-035000-false

kion-dgl commented 6 days ago

To trace through it, the game goes (start new game)

so the weirdness is scene 3A2 has three textures, it has the gameplay face and body that the game patches in after the cut scene and it has megaman's face that it uses for about a second if i don't change megaman's face in 3A2, the intro scene looks fine, but megaman is glitched out for two seconds when the flutter touches down but if i update megaman's face in scene 3a2, the whole intro cutscene is glitched and i've been trying to debug things by setting them red to see what triggers it, and i can't seem to find it

right now my best guess is one of the faces is a texture where the palette isn't included directly and that's why the reference is getting mixed up or something. framebuffer

Looking at the framebuffer, it looks like the cut scene and the default face are getting loaded in.

kion-dgl commented 6 days ago

Merged. This can be closed.