News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

[SM] Editing the gameplay footage during title.

Started by dewhi100, May 18, 2017, 09:43:21 AM

Previous topic - Next topic

dewhi100

How intensive is it to edit the gameplay clips shown when you ide at the title screen? From what I understand, the game actually loads Samus into a level and pilots her around. Seems like it'd be an ASM rewrite. How much is known about this?

monktroid

Quote from: dewhi100 on May 18, 2017, 09:43:21 AM
How intensive is it to edit the gameplay clips shown when you ide at the title screen? From what I understand, the game actually loads Samus into a level and pilots her around. Seems like it'd be an ASM rewrite. How much is known about this?

I doubt it's something many people have looked at. I remember seeing some registers in the RAM map about the game taking control of Samus. Probably, the place to start would be to load it up with Geiger and watch those registers to see what's happening.  Be cool if you could write cut scenes with it.

PHOSPHOTiDYL

Red_monkey posted some demo pointers on the resource thread a few years back.

Quote from: A_red_monk_called_Key on February 22, 2012, 11:12:41 AM
i don't know if anybody found these yet.

these are the addresses for the pointers to the rooms that each demo is in.

$1896A = LANDING ROOM
$18EAA = BEFORE MISSLE ROOM
$18DC6 = BEFORE SPORE SPAWN
$1970E = SPEED BOOST DEMO
$19792 = GRAPPLE BEAM DEMO
$18E7A = CHARGE BEAM DEMO

$1A36C = ICE BEAM DEMO
$18CCA = GLOW ROOM
$18DEA = BLUE GATE DEMO
$1967E = LAVA SPACEJUMP
$18982 = SCREW DEMO
$18DD2 = SPEED JUMP DEMO

$1A21C = LOWER WRECK SHIP
$1896A = (SAME AS THE FIRST)LANDING ROOM SPEED JUMP
$1919E = ROOM BEFORE KRAID
$190EA = ROOM RIGHT OF POWER BOMB ROOM
$191B6 = KRAID
$191F2 = STATUE ROOM

Quote58

Iirc, many years ago JAM worked through the routines that ran and recorded demos, but the problem is you couldn't currently record any because they were made for a dev kit that could write to ROM during gameplay. That being said, he seemed to be getting somewhere with it, so if anyone would know it would be him.

P.JBoy

Over at $82:876C, there's a list of pointers, one for each set of demos, that points to a list of not-quite door transition entries:


;;; $876C: Demo data ;;;
{
; Pointers to demo data
$82:876C             dw 8774, 87E2, 8850, 88BE

;                        ___________________________________________________ MDB
;                       |      _____________________________________________ DDB
;                       |     |      _______________________________________ door slot
;                       |     |     |      _________________________________ screen X position
;                       |     |     |     |      ___________________________ screen Y position
;                       |     |     |     |     |      _____________________ Samus Y offset from top of screen
;                       |     |     |     |     |     |      _______________ Samus X offset from centre of screen
;                       |     |     |     |     |     |     |      _________ length of demo
;                       |     |     |     |     |     |     |     |      ___ pointer to code
;                       |     |     |     |     |     |     |     |     |
$82:8774             dw 91F8, 896A, 0001, 0400, 0400, 0040, 0001, 04D3, 8925,
                        91F8, 896A, 0001, 0400, 0400, 0040, 0001, 04D3, 8925,
                        9F11, 8EAA, 0001, 0000, 0000, 006B, FFD2, 0151, 8924,
                        9D9C, 8DC6, 0000, 0100, 0000, 00BB, FFE0, 017A, 8924,
                        B106, 970E, 0000, 0700, 0000, 008B, 0048, 01A4, 8924,
                        AFFB, 9792, 0001, 0000, 0000, 008B, FFC2, 01BC, 8924,
                        9D19, 8E7A, 0000, 0200, 0600, 0099, 0027, 0265, 891A,
                        FFFF

$82:87E2             dw A408, A36C, 0000, 0100, 0100, 008B, 0056, 01FD, 8924,
                        9C5E, 8CCA, 0003, 0200, 0000, 008B, 0049, 019A, 8924,
                        9E52, 8DEA, 0003, 0500, 0300, 00AB, FFE2, 0117, 8924,
                        AF14, 967E, 0002, 0300, 0000, 008B, 004B, 03CA, 8924,
                        9879, 8982, 0003, 0000, 0000, 00BB, FFF1, 00D5, 8924,
                        9CB3, 8DD2, 0001, 0400, 0200, 0080, 0005, 0317, 8924,
                        FFFF

$82:8850             dw CC6F, A21C, 0003, 0200, 0000, 0060, 0004, 02EF, 8924,
                        91F8, 896A, 0001, 0300, 0400, 00B0, 0000, 00C7, 8925,
                        A56B, 919E, 0001, 0000, 0100, 008B, FFD2, 02D3, 8924,
                        A322, 90EA, 0000, 0000, 0700, 008B, FFAA, 0164, 8924,
                        A59F, 91B6, 0001, 0000, 0100, 008B, FFBF, 013F, 892B,
                        A66A, 91F2, 0001, 0000, 0000, 008B, FFB1, 0197, 8932,
                        FFFF


$82:88BE             dw 91F8, 890A, 0000, 0600, 0200, 0080, 0030, 0100, 8925,
                        D0B9, A474, 0000, 0200, 0000, 00AB, 0000, 0332, 8924,
                        91F8, 890A, 0000, 0600, 0200, 007B, 0020, 0185, 8925,
                        9AD9, 8D42, 0001, 0000, 0400, 008B, FFB7, 018A, 8924,
                        91F8, 890A, 0000, 0600, 0200, 008B, 0004, 0200, 8925,
                        FFFF
}


The pointer to code is doing door ASM type work, like setting scroll colours.

Meanwhile, over at $91:8885, there's a list of pointers that point to a list of Samus equipment definitions:


;;; $8885:  ;;;
{
$91:8885             dw 888D, 88ED, 894D, 89AD

;                        ______________________________________ Equipment
;                       |     _________________________________ Missiles
;                       |    |     ____________________________ Super missiles
;                       |    |    |     _______________________ Power bombs
;                       |    |    |    |     __________________ Health
;                       |    |    |    |    |     _____________ Collected beams
;                       |    |    |    |    |    |     ________ Equipped beams
;                       |    |    |    |    |    |    |     ___ Input PLM-esque object
;                       |    |    |    |    |    |    |    |
$91:888D             dw 0000,0000,0000,0000,0063,0000,0000,9E52,
                        0004,0005,0000,0000,0063,0000,0000,9E88,
                        0004,000F,0000,0000,00C7,1000,1000,9EAC,
                        2105,001E,0005,0000,012B,1004,1004,9E5E,
                        6105,001E,0005,0005,018F,1006,1006,9EB2,
                        0004,0014,0000,0000,00C7,1000,1000,9E58

$91:88ED             dw 2105,001E,0005,0000,012B,1006,1006,9EB8,
                        0004,000A,0000,0000,00C7,0000,0000,9E94,
                        0004,0019,0005,0000,00C7,1000,1000,9EA0,
                        E325,004B,000F,000A,0383,1000,1000,9E76,
                        E32D,0055,000F,000A,03E7,0000,0000,9E9A,
                        E105,002D,0005,0005,018F,1000,1000,9E64

$91:894D             dw E105,0037,0005,0005,018F,1000,1000,9E70,
                        F33F,0055,000F,000A,03E7,100F,1000,9E82,
                        0104,0019,0005,0000,012B,1004,1004,9E7C,
                        2105,001E,0005,0000,012B,0000,0000,9E6A,
                        0104,0019,0005,0000,012B,0000,0000,9E8E,
                        2105,001E,0005,0005,012B,1008,1008,9ED6

$91:89AD             dw F32D,0055,000F,000A,03E7,1000,1000,9EBE,
                        F32D,0055,000F,000A,03E7,0000,0000,9EC4,
                        F32D,0055,000F,000A,03E7,0000,0000,9ECA,
                        F32D,0055,000F,000A,03E7,1008,1008,9ED0,
                        F32D,0055,0014,0014,03E7,1000,1000,9EDC
}


That pointer at the end of each entry points to a triple of pointers that define a PLM-esque object that handles the demo input:


;;; $9E52:  ;;;
{
;                        _____________ Initialisation (RTS)
;                       |     ________ Pre-instruction (does basically nothing)
;                       |    |     ___ Pointer to input instruction list
;                       |    |    |
$91:9E52             dw 83BF,8A9B,8ACE
$91:9E58             dw 83BF,8A9B,8C3E
$91:9E5E             dw 83BF,8A9B,8DF0
$91:9E64             dw 83BF,8A9B,8E64
$91:9E6A             dw 83BF,8A9B,8EB4
$91:9E70             dw 83BF,8A9B,8F3A
$91:9E76             dw 83BF,8A9B,8FE4
$91:9E7C             dw 83BF,8A9B,9154
$91:9E82             dw 83BF,8AB0,933C
$91:9E88             dw 83BF,8A9B,93CC
$91:9E8E             dw 83BF,8A9B,9464
$91:9E94             dw 83BF,8A9B,946C
$91:9E9A             dw 83BF,8A9B,950A
$91:9EA0             dw 83BF,8A9B,9560
$91:9EA6             dw 83BF,8A9B,95BC
$91:9EAC             dw 83BF,8A9B,965A
$91:9EB2             dw 83BF,8A9B,973A
$91:9EB8             dw 83BF,8A9B,989E
$91:9EBE             dw 83BF,8A9B,99AE
$91:9EC4             dw 83BF,8A9B,99C8
$91:9ECA             dw 83BF,8A9B,9AF0
$91:9ED0             dw 83BF,8A9B,9CD8
$91:9ED6             dw 83BF,8A9B,9DA6
$91:9EDC             dw 83BF,8A9B,9DAE
}


The first two pointers of each of these aren't very interesting; the last one points to the input data itself, taking the first demo as an example:


;;; $8ACE:  ;;;
{
;                        _____________ Number of frames
;                       |     ________ Current input
;                       |    |     ___ New input
;                       |    |    |
$91:8ACE             dw 0121,0000,0000,
                        0001,0200,0200,
                        0006,0200,0000,
                        0001,0A00,0800,
                        0003,0A00,0000,
                        0013,0200,0000,
                        0001,0280,0080,
                        0028,0280,0000,
                        0032,0200,0000,
                        0024,0000,0000,
                        0001,0100,0100,
                        0005,0100,0000,
                        000F,0000,0000,
                        0001,0200,0200,
                        0005,0200,0000,
                        0022,0000,0000,
                        0001,0200,0200,
                        004A,0200,0000,
                        0005,0000,0000,
                        0001,0100,0100,
                        0005,0100,0000,
                        0045,0000,0000,
                        0001,0200,0200,
                        0003,0200,0000,
                        0001,8200,8000,
                        0049,8200,0000,
                        0001,8A00,0800,
                        0003,8A00,0000,
                        0001,0200,0000,
                        0002,0000,0000,
                        0001,0100,0100,
                        0007,0100,0000,
                        000B,0000,0000,
                        0001,0010,0010,
                        001F,0010,0000,
                        0001,0210,0200,
                        0005,0210,0000,
                        001D,0010,0000,
                        0001,0200,0200,
                        005E,0200,0000,
                        0030,0000,0000,
                        0001,0200,0200,
                        002E,0200,0000,
                        001F,0000,0000,
                        0001,0100,0100,
                        0004,0100,0000,
                        0040,0000,0000,
                        0001,0200,0200,
                        0004,0200,0000,
                        0028,0000,0000,
                        0001,0040,0040,
                        0006,0040,0000,
                        002B,0000,0000,
                        0001,0200,0200,
                        0011,0200,0000,
                        0007,0000,0000,
                        0001,0200,0200,
                        0004,0200,0000,
                        0014,0100,0000,
                        0001,0140,0040,
                        0003,0140,0000,
                        8427
}


You'll notice that wherever there is a 'new input' defined, its associated 'number of frames' is 1, and you'll also probably notice the $8427 at the end, which terminates the demo. You can run an ASM routine at any point during these (the demo handler will differentiate pointers ($8000+) from numbers of frames), that routine will have Y pointing to the next instruction (or arguments to the current instruction, this is just like PLMs).

There're also some pointers at $91:89FD that point to ASM to set up the room


;;; $89FD:  ;;;
{
$91:89FD             dw 8A05, 8A11, 8A1D, 8A29
                       
$91:8A05             dw 8A33, 8A53, 8A53, 8A49, 8A53, 8A3E,
$91:8A11             dw 8A49, 8A49, 8A53, 8A49, 8A53, 8A4E,
$91:8A1D             dw 8A49, 8A68, 8A53, 8A53, 8A53, 8A53,
$91:8A29             dw 8A81, 8A49, 8A49, 8A53, 8A43
}


At a quick glance, I'm pretty sure the different pointers are just setting up Samus in different poses, so you should be alright to reuse whatever one of those works.

Quote58 is right that there is some functionality in the ROM that would have been used to record these demos. It's enabled in debug mode by having the second controller press Y to start the recording, X to pause / end and A to reset, then it writes all of the information I outlined above (except the custom ASM) to the ROM (not possible in emulators / console) in bank B8 (the famously blank bank(!)). The recorder had a limit of 2560 frames (~42 seconds), but I don't think the limitation holds for manually hex editing the data.

I actually don't think it would be very difficult to convert a state-stated SMV into demo recording if someone wanted to code that up
...

Scyzer

I've sorta made a demo editor in RF, though it's not a high priority at the moment. It requires input outside of RF from an emulator which is why I was hesitant to finish it.
It works simple enough. Basically there's a bit of ASM which you apply to a ROM. This ASM runs to record your input into the RAM. When you're done, you copy that section of RAM (meaning you would have to use an emulator with a RAM viewer such as geigers), and paste it into a box in RF which then organises that data into new demos in the ROM.
Before anyone asks: No, it is not available in the current public version of RF. It will definitely (read: probably) be done for a later version though so don't stress too much about editing the demos yet.

dewhi100

Wow, this is a lot of information. Thanks all!

squishy_ichigo

That's neat to hear Scyzer, I had been bugging PJBoy a few years ago for better documentation so I could eventually edit the demos, but this is even better. Hope to use it at some point.