Author Topic: Opcodes - Final Stretch  (Read 14290 times)

Synergy Blades

  • Guest
Opcodes - Final Stretch
« on: 2006-09-13 00:40:28 »
A call to those with opcode knowledge (halkun, Qhimm, whoever else...)

I've done well over 100 opcodes on the Wiki, and with halkun's maths/assignment write-up and Qhimm's RET/REQs I reckon we've got about 90 opcodes left to nail down. I'm not putting anything up with any "unknown" in, and in my view the remainder range from "I'm not 100% sure what this argument does" to "what on Earth is this supposed to do?" I've also done my best to categorise them, though there's still a few left to do.

With a bit of concerted effort I think we can get the unknowns down to below the 20 mark. If you know any that haven't been done then feel free to put them in. I'll write up a few musings I've had with some opcodes I can't 100% document and post it here to see if anyone has any ideas.

Good idea/bad idea?

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #1 on: 2006-09-13 01:00:35 »
21 TUTOR: Opens the menu and should play a tutorial, but on fields without tutorials, lets you control the menu; quit the menu, and it comes straight back up again. The field file contains the PSX version of the tutorial ("insert a memory card into either slot..."), whereas the flevel LGP contains the PC version. So how are these accessed/referenced?
22 BTMD2: Battle mode: no victory celebration, celebration without music, etc.
28 KAWAI: Why after each KAWAI is there often a WAIT(1) followed by KAWAI(subop, 1)?
31 IFKEYON/32 IFKEYOFF: How do these differ from IFKEY if IFKEY lets you check whether a key is down or up?
3C HMPMAX1/3D HMPMAX2: How do these differ from HMPMAX3? [EDIT] They may not be - HMPMAX1 and HMPMAX2 are not used in the game
5C DMTRA/5D CMTRA: Can't figure out argument usage for DMTRA (only used in blackbg4 anyway); CMTRA not used in the game which doesn't help figuring out args
5E SHAKE: (bank, bank, ?, ?, y-direction?, force, regularity): shakes the screen, but direction specification seems hit and miss
5F NOP: Can we assume this is as per a CPU NOP? Just a no-op command?
6D IDLCK: In some fields, come under an entity called "IDlock"; what IDs are they locking?
6E LSTMP: Often used before accessing a 16-bit value from the temporary bank, such as; LSTMP(6,20) followed by if(<6>[20] == 100)...
7E TLKON: Talk on? Doesn't seem to stop dialogs
7F RDMSD: Random seed?
9D SETX/9E GETX/9F SEARCHX: All unused in the game, and a hefty argument list
B2 MSPED: Second argument is..?
B4 TURNGEN: Generate turn? Differs from other turn opcodes how?
C6 SLIDR: Seems to combine with LADER
D4 SIN/D5 COS: kuro_4 > mover > Script 0 only. (Bank[4]/Bank[4],Bank[4]/Bank[4],?S16,?S16,?S16,?U8)
DA AKAO2/F2 AKAO: Even though they're seperate opcodes do they have different functions within each? Does one/either play sound and if so how does it differ to SOUND?

So those are a few that have been bugging me the most, as for the remainder I might stick up the understood arguments for each remaining opcode on its talk page if there's any demand for them. If you want to take a look at each you might find this little tool helpful as it dumps the locations of each opcode for the entire field set.

Unused opcodes (assuming the two fields my script analyser falls over on don't contain these):

3C HMPMAX1
3D HMPMAX2
55 WROW
56 GWCOL (but 57 SWCOL *is* used)
5D CMTRA
5F NOP
61 SCRLO (on/off? but doesn't seem to stop scrolls)
94 XOR2
9D SETX
9E GETX
9F SEARCHX
D7 SLDR2
D9 PMJMP2
EB STPLS
EC LDPLS
EE RTPAL2
F4 MUSVM
F7 CHMPH


While I'm at it: check "yougan" (or whichever one it is where Yuffie steals your materia). I absolutely cannot find any script that removes the party's materia, and changing a gateway to replay that field and going through the field again removes only a certain subset of materia. Any ideas?

+++EDIT: Halkun+++

CRAP! I edited and accidently deleted this post. I lost the links. Sorry. I'm lame ;_;

EDIT: You are lame. Good thing I'm around. :P /Q
« Last Edit: 2006-09-14 13:04:03 by Qhimm »

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Opcodes - Final Stretch
« Reply #2 on: 2006-09-13 02:57:15 »
Quote

31 IFKEYON/32 IFKEYOFF: How do these differ from IFKEY if IFKEY lets you check whether a key is down or up?

Umm, sorry, IFKEY might be wrong, the center argument was always zero. I made the assumption that as buttins only have two states, the center argument has to be what you are checking for.

It might just be "0"

RW_66

  • *
  • Posts: 74
    • View Profile
Re: Opcodes - Final Stretch
« Reply #3 on: 2006-09-13 05:58:10 »
A few suggestions/observations to investigate:

BTMD2 - Battle Mode 2; used in the Nibelheim memory sequence with Sephiroth and Cloud. No item or XP after battle.
LSTMP- List Map; Used to find values in Temporary Memory?
IDLCK- ID lock; Used to temporarily "seal" commands out of operation; for instance, bad spins in Battle Arena, 'Berzerk' status, 'toad' status, etc. Operations identified with the ID lock become disabled. (?)
RDMSD- I think your correct that this is Random Seed. Probably used early in the program to generate semi-random numbers. Usually uses the format of RNDSD nnnn with the value being applied to a specific randomising algorithim.
MSPED- Message Speed?
TURNGEN- Used to RET to the top of the Turn OP? Or to start Turn?
SLIDR- Slider; Combined with LADER, provides x,y coordinates for some function (?)

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Opcodes - Final Stretch
« Reply #4 on: 2006-09-13 12:08:59 »
Hmm...

Code: [Select]
0x5F - NOPIt just increases the IP by 1, it's one byte in size, no arguments - so it's equivalent to CPU NOP :P

Cloned opcodes:
Code: [Select]
0x3C - HMPMAX1
0x3D - HMPMAX2
0x3F - HMPMAX3
Are the same

Code: [Select]
0xA3 - ANIME1
0xAE - ANIME2
Are the same

Code: [Select]
0xAF - ANIM!1
0xBA - ANIM!2
Are the same

Code: [Select]
0xB0 - CANIM1
0xBB - CANIM2
Are the same

Code: [Select]
0xB1 - CANM!1
0xBC - CANM!2
Are the same

Code: [Select]
0xD4 - SIN
0xD5 - COS

OP SID1 SID2 ANGLE MUL BASE RES

OP - byte 0xD4 / 0xD5
SID1 - source/dest byte for ANGLE and MUL
SID2 - source/dest byte for BASE and RES
ANGLE - WORD
MUL - WORD
BASE - WORD
RES - WORD
size - 0x0A

res = (trunc(sin(angle*2*pi/4096)*4096)*mul+base)/4096
Angle is 4096 based because it's not precise enough to store it in radians. Edit: Oh, and it is probably used to calculate the position of clock's hand in Ancient's Temple :)

Rest will come here as I check them :P

Edit:

Code: [Select]
0x7F - RDMSD

OP SEED
OP - byte 0x7F
SEED - BYTE
seed = (byte)(seed<<0x04 + 1)
Which is then used when picking the value from an array or "random" numbers.

position = (byte)(position+seed)
random = random_numbers[position]

When changing the seed, you change the leap which is done before each pick up.
« Last Edit: 2006-09-13 12:36:04 by dziugo »

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #5 on: 2006-09-13 12:23:45 »
No, the ANIM opcodes aren't the same, they're as I've documented them. The ones with 1 after them *do* pause script execution; the ones with 2 after them *do not* pause script execution. In addition, the ANIM! ones leave the object in the last frame of animation; the ANIME ones return the object to its initial pose.

RW_66:

BTMD2: Yep, but it's figuring out the arguments and combinations that's the difficult part.
LSTMP: Is it possible to do an if on the 16-bit temp bank without using LSTMP?
MSPED: Yep, not sure what the second arg is though.
SLIDR: I edited one SLIDR that is present on the *up* portion of the ladder. Saw no changes, except when I tried to come back down the ladder, Cloud got stuck at the top.
« Last Edit: 2006-09-13 12:29:18 by Synergy Blades »

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Opcodes - Final Stretch
« Reply #6 on: 2006-09-13 12:37:48 »
No, the ANIM opcodes aren't the same
Didn't say that.

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #7 on: 2006-09-13 12:44:15 »
You said:
Quote
0xA3 - ANIME1
0xAE - ANIME2
Are the same

0xAF - ANIM!1
0xBA - ANIM!2
Are the same
..they're not  :-P

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Opcodes - Final Stretch
« Reply #8 on: 2006-09-13 12:48:59 »
They may work different, but they share the same .text area.

Edit:
I take that back. Now I see that they fork inside the function.
« Last Edit: 2006-09-13 13:05:43 by dziugo »

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: Opcodes - Final Stretch
« Reply #9 on: 2006-09-13 14:22:05 »
SLIDR I think is used in the entrance to Gaia's cave where you have to fall to certain locations. I believe the minigame on the tracks between Costa Del Sol and North Coral <sp> it's used as well (falling minigame?)

Anyhow SLIDR is used where an uncontroled movement happens to the PC.
If for example you change the 'leap onto a ladder' function where I think SLIDR is used you'll end up possibly not being able to move.

of course this is shear speculation .. but you could check those areas for meaningful information on the SLIDR opcode.

if someone could would they insert the information for PMVIE?  I'm curious how movies are setup to run from the script as I had a sudden suspicion the other day :D

Cyb
« Last Edit: 2006-09-13 14:45:48 by Cyberman »

Qhimm

  • Founder
  • *
  • Posts: 1996
    • View Profile
    • Qhimm.com
Re: Opcodes - Final Stretch
« Reply #10 on: 2006-09-13 14:56:17 »
Yuffie's materia theft is carried out by a dedicated game "mode" (accessed through MENU, I believe). Looks like a lot of specific can't-quite-do-in-script actions were hard-coded in this manner.

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #11 on: 2006-09-13 15:01:39 »
Ah, I mistook that for MENU E (save game menu). I did notice several MENUs in the debug rooms with values >0xF that didn't seem to do anything in other fields so I guess they'll all need to be looked at.

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Opcodes - Final Stretch
« Reply #12 on: 2006-09-13 15:15:03 »
DMTRA and CMTRA don't work as someone might think they should. Can't find Qhimm's post about it so:
DMTRA was supposed to Delete Materia. The thing is, it doesn't :)

Arguments:
Code: [Select]
OP SID1 SID2 B1 B2 B3 B4 UNKNOWN

OP - 0x5C
SID1 - source/dest byte for B1 and B2
SID2 - source/dest byte for B3 and B4
B1 - BYTE
B2 - BYTE
B3 - BYTE
B4 - BYTE
UNKNOWN - BYTE
B4*16777216 + B3*65536 + B2*256 + B1 is probably a materia with a certain amount of AP (an unknown byte might be a mode, like 1-delete every single materia that matches, 2-ignore APs etc.)

CMTRA was supposed to Check if Materia is in party's possesion (maybe even count them). The checking function isn't implemented (PC version).

Arguments:
Code: [Select]
OP SID1 SID2 SID3 B1 B2 B3 B4 UNKNOWN RES

OP - 0x5D
SID1 - source/dest byte for B1 and B2
SID2 - source/dest byte for B3 and B4
SID3 - source/dest byte for RES
B1 - BYTE
B2 - BYTE
B3 - BYTE
B4 - BYTE
UNKNOWN - BYTE
RES - BYTE
Result is always 0.

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #13 on: 2006-09-13 15:19:59 »
Could the arguments be similar to adding materia? So

DMTRA (00,00,14,FF,FF,FF,63)

Would be deleting all materia with a materia type of 14, and AP 63FFFFFF?

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Opcodes - Final Stretch
« Reply #14 on: 2006-09-13 15:23:35 »
Yes, that would be the most logic way :P There is also that unknown byte... You said that it uses it in blackbg4. What are the arguments there? Is it accessible?

Edit:
AP is 24bit, that unknown byte isn't used (I might be wrong again).
« Last Edit: 2006-09-13 15:25:46 by dziugo »

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #15 on: 2006-09-13 15:28:52 »
[EDIT] Oops - wrong, forgot AP was a three-byte value in SMTRA

Well if that is the way it works, then there's no unknown byte, as it'd be:

DMTRA(B/B,B/B,Type,AP,AP,AP,AP)

Then CMTRA would be the same, just with the address to store the result on the end.

Here's the call from blackbg4 > gss > Script 2:

DLITM(0,8F,0,63)
DMTRA(0,0,14,FF,FF,FF,63)
DMTRA(0,0,14,0,0,0,63)

I did test it on another field where it didn't delete anything but forgot that it'd probably need the required AP to be deleted, so I might test it again later. Not entirely sure how to Wiki this pair, I'll probably just add a note on the page about it not being implemented on the PC version.


[EDIT2] Could it be quantity to delete, as per the ITM opcodes? 0x63 = 99.
« Last Edit: 2006-09-13 15:30:58 by Synergy Blades »

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Opcodes - Final Stretch
« Reply #16 on: 2006-09-13 15:36:10 »
[EDIT2] Could it be quantity to delete, as per the ITM opcodes? 0x63 = 99.
Most likely.

AP == 0 for newborn materia and FFFFFF for mastered one, 14 is W-Summon Materia, 8F is Ultima Weapon. Sounds fishy :P
« Last Edit: 2006-09-13 15:38:14 by dziugo »

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #17 on: 2006-09-13 15:51:26 »
It's the debug room, it does all sorts of odd things.  :-D From there it goes on to change fields with JUMPMAP so I think it's just a check for the field programmers.

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Opcodes - Final Stretch
« Reply #18 on: 2006-09-13 16:17:39 »
It's the debug room, it does all sorts of odd things.  :-D
:roll:

Another update:
IFKEY
IFKEYON
IFKEYOFF

Usage is similar:
Code: [Select]
OP KEY JUMP

OP - 0x30/0x31/0x32
KEY - WORD
JUMP - BYTE
KEY is a key to check for (surprise!), JUMP is a number of bytes to skip if the condition isn't true (IP+3+JUMP).

IFKEY is used to check if the button is being pressed.
IFKEYON is used to check if the button has been pressed (was OFF, became ON)
IFKEYOFF is used to check if the button has been released (was ON, became OFF)

What I don't understand is:
KEY & 0x0200
It's a condition which determines which key status to use (2 statuses for each mode - being pressed/was pressed/was released - they are always the same :/). 0x0200 is probably not a valid key... Help?

Qhimm

  • Founder
  • *
  • Posts: 1996
    • View Profile
    • Qhimm.com
Re: Opcodes - Final Stretch
« Reply #19 on: 2006-09-14 13:30:36 »
Here are some extra pointers (can't post details because I'm at work):

MPPAL, STPAL, LDPAL, CPPAL, RTPAL, ADPAL, MPPAL2, STPLS, LDPLS, CPPAL2, RTPAL2 and ADPAL2 involve the manipulation of field palettes. Palettes are manipulated in the script, then uploaded to and downloaded from VRAM as needed (palettes are only "active" when in VRAM, of course). MultiPlyPALette, CoPyPALette, STorePALette, LoaDPALette, RoTatePALette, ADdPALette etc., with the "duplicate" commands working on either the entire palette or a subset of it. Arguments to the various commands are a bit inconsistent, but the last argument typically denotes the size of the palette (0x0F or 0xFF, signifying 16- or 256-sized palettes). The MPPAL opcodes use fixed-point values for the R, G and B coefficients.

BGROL, BGROL2: Compound BGON/BGOFF commands. "Rolls" the set of visible blocks for a certain background, e.g. "if block i is visible, make block i+1 visible next frame". Useful when a number of blocks work together as an animation.

GWCOL and SWCOL: GetWindowCOLors and SetWindowCOLors, respectively. Does exactly what you'd think, setting the colors of the four corners of your regular gradient-adorned message window.

Oh, and RDMSD is very correctly RanDoMSeeD. The lower 4 bits of the argument is used as a seed for the internal 8-bit random number generator.

That's all I can remember off the top of my head, you did a mighty good job at filling out the wiki page for most of the opcodes I know already. Might fill in more details later if there are questions.

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #20 on: 2006-09-14 15:01:33 »
Could someone with the reverse-engineered opcodes confirm/disprove that SWCOL doesn't work (at least on the PC version)? The args seem straight-forward but my windows still come out the standard blue colour even after setting every corner to black.

[EDIT] Nor does it work in blackbg2, the only place it's used.
« Last Edit: 2006-09-14 15:16:59 by Synergy Blades »

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Opcodes - Final Stretch
« Reply #21 on: 2006-09-14 20:22:38 »
It changes wrong variables for it to work as described.

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #22 on: 2006-09-14 22:05:11 »
GWCOL works just fine, mind. RDMSD has two arguments; is this so it can operate as (Bank,Add) as well as just specifying (0,VAL)? (Something I can't check by observation  :-))

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Opcodes - Final Stretch
« Reply #23 on: 2006-09-14 22:43:26 »
Yeah, RDMSD has a standard source/dest byte, so you can feed it with byte from anywhere. GWCOL works fine, because it reads the mirrored (kind of) variables. Writing to mirrored variables doesn't change much.

Synergy Blades

  • Guest
Re: Opcodes - Final Stretch
« Reply #24 on: 2006-09-15 00:38:33 »
if someone could would they insert the information for PMVIE?  I'm curious how movies are setup to run from the script as I had a sudden suspicion the other day :D

Done a partial list for that opcode.