Qhimm.com Forums

Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: halkun on 2006-07-12 17:24:23

Title: A thread just for Fieldscript in general...
Post by: halkun on 2006-07-12 17:24:23
As we seem to have about four people (including myself) taking a swing at conqering Fieldscript once and for all, I've decided to make this thread to post all your fieldscript questions/discoveries.

I'll put my quanderies/comments here first...

First, my fieldscript dumper, (Called "Scriptdump") is available via SVN from the q-gears reposotory. I could use some comments/suggestions on it. I have a slightly debugged version at home I'll upload tonight that fixes another "off-by-one" error in the "alias" repeat handeler. Other than that, the only thing left is the adding of curly brackets for if statements, dailog dumping, and the filling out of opcodes.

Now for my theories.

First, it seems that scripts 1-2 and 3-31 occupy different interactivity levels. I haven't played with it yet, the the placement of the files may have something to do with PC interactivity. Just a shot in the dark....

Questions...
from Akari's script dumper he has the listing from startmap here..

Code: [Select]
#D  IFUBL(50 00 01 00 DF 00) // if not - go check other value (#E)
    AKAO(00 00 00 C0 7F 00 00 00 00 00 00 00 00)
    AKAO(00 00 00 A0 7F 00 00 00 00 00 00 00 00)
    AKAO(00 00 00 A1 7F 00 00 00 00 00 00 00 00)
    AKAO(00 00 00 A2 7F 00 00 00 00 00 00 00 00)
    AKAO(00 00 00 A3 7F 00 00 00 00 00 00 00 00)
    AKAO2(00 00 00 C8 FF 7F 00 00 00 00 00 00 00 00)
    AKAO2(00 00 00 E4 00 00 00 00 00 00 00 00 00 00)
    AKAO2(00 00 00 B0 00 00 00 00 00 00 00 00 00 00)
    AKAO2(00 00 00 B1 00 00 00 00 00 00 00 00 00 00)
    AKAO2(00 00 00 B2 00 00 00 00 00 00 00 00 00 00)
    AKAO2(00 00 00 B3 00 00 00 00 00 00 00 00 00 00)
    SPECIAL(00 F2 00 00 00 28 3F 00 00 00 00 00 00 00
            00 F2 00 00 00 29 3F 00 00 00 00 00 00 00
            00 F2 00 00 00 2A 3F 00 00 00 00 00 00 00
            00 F2 00 00 00 2B 3F 00 00 00 00 00 00 00 00
    JMPFL(1E 00) // (#10)

Now, I thought that SPECIAL only used subcodes f5-ff, what's up with the above listing...

Also, what other fieldscript apps are floating out there? Maybe we can pool our resourses.



 
Title: Re: A thread just for Fieldscript in general...
Post by: Synergy Blades on 2006-07-12 17:52:12
Dunno, I get

Code: [Select]
IfUByteL (50,00,01,00,DF,00)
AKAO (00,00,00,C0,7F,00,00,00,00,00,00,00,00)
AKAO (00,00,00,A0,7F,00,00,00,00,00,00,00,00)
AKAO (00,00,00,A1,7F,00,00,00,00,00,00,00,00)
AKAO (00,00,00,A2,7F,00,00,00,00,00,00,00,00)
AKAO (00,00,00,A3,7F,00,00,00,00,00,00,00,00)
AKAO2 (00,00,00,C8,FF,7F,00,00,00,00,00,00,00,00)
AKAO2 (00,00,00,E4,00,00,00,00,00,00,00,00,00,00)
AKAO2 (00,00,00,B0,00,00,00,00,00,00,00,00,00,00)
AKAO2 (00,00,00,B1,00,00,00,00,00,00,00,00,00,00)
AKAO2 (00,00,00,B2,00,00,00,00,00,00,00,00,00,00)
AKAO2 (00,00,00,B3,00,00,00,00,00,00,00,00,00,00)
MUSIC (00)
AKAO (00,00,00,28,3F,00,00,00,00,00,00,00,00)
AKAO (00,00,00,29,3F,00,00,00,00,00,00,00,00)
AKAO (00,00,00,2A,3F,00,00,00,00,00,00,00,00)
AKAO (00,00,00,2B,3F,00,00,00,00,00,00,00,00)
GotoNextLong (1E,00)

I wouldn't mind sending my WIP app to those that specifically wanted it; it's not really ready for public consumption.
Title: Re: A thread just for Fieldscript in general...
Post by: Qhimm on 2006-07-12 18:02:44
Agreeing with Synergy Blades, Akari's dump decodes that part wrong. There is no SPECIAL command there. Here's the output for that area from my old dumper (extra work added, it doesn't actually decode else clauses):
Code: [Select]
  goto label1                 // 13 C9 00
}
else                          // 11 02 01
if ( UByte()[0] == 1 )        // 15 50 00 01 00 DF 00
{
  AKAO                        // F2 00 00 00 C0 7F 00 00 00 00 00 00 00 00
  AKAO                        // F2 00 00 00 A0 7F 00 00 00 00 00 00 00 00
  AKAO                        // F2 00 00 00 A1 7F 00 00 00 00 00 00 00 00
  AKAO                        // F2 00 00 00 A2 7F 00 00 00 00 00 00 00 00
  AKAO                        // F2 00 00 00 A3 7F 00 00 00 00 00 00 00 00
  AKAO2                       // DA 00 00 00 C8 FF 7F 00 00 00 00 00 00 00 00
  AKAO2                       // DA 00 00 00 E4 00 00 00 00 00 00 00 00 00 00
  AKAO2                       // DA 00 00 00 B0 00 00 00 00 00 00 00 00 00 00
  AKAO2                       // DA 00 00 00 B1 00 00 00 00 00 00 00 00 00 00
  AKAO2                       // DA 00 00 00 B2 00 00 00 00 00 00 00 00 00 00
  AKAO2                       // DA 00 00 00 B3 00 00 00 00 00 00 00 00 00 00
  MUSIC(0)                    // F0 00
  AKAO                        // F2 00 00 00 28 3F 00 00 00 00 00 00 00 00
  AKAO                        // F2 00 00 00 29 3F 00 00 00 00 00 00 00 00
  AKAO                        // F2 00 00 00 2A 3F 00 00 00 00 00 00 00 00
  AKAO                        // F2 00 00 00 2B 3F 00 00 00 00 00 00 00 00
}
else                          // 11 1E 00
if ( UByte()[0] == 2)         // 15 50 00 02 00 0B 00
{
  SPECIAL(AddAllMateria)      // 0F F9
  SPECIAL(AddAllMateria)      // 0F F9
  SPECIAL(AddAllMateria)      // 0F F9
}
else                          // 11 0E 00
{
  BATTLE(999)                 // 70 00 E7 03
  MHMMX                       // 3E
}
Title: Re: A thread just for Fieldscript in general...
Post by: halkun on 2006-07-12 22:00:55
Oh, you "Found" your scripting project.... You know, it was because it was missing in the first place I started mine.  Grrrr ^_^

What are you guys trying to make me do? Code?!

Not only that, your output looks better than mine....
Title: Re: A thread just for Fieldscript in general...
Post by: Qhimm on 2006-07-13 07:06:31
Not only that, your output looks better than mine....
As I said, that's not the real output (I've cleaned it up, and added the "else" clauses manually). Also, my script dumper just outputs to a windows listview; it doesn't even have a copy function yet (hence I had to write it down from the screen -- I only have the executable). So I'd wager its only use is reading field scripts, not implementing them.
Title: Re: A thread just for Fieldscript in general...
Post by: Akari on 2006-07-13 15:16:53
Agreeing with Synergy Blades, Akari's dump decodes that part wrong. There is no SPECIAL command there.

Yup... I fix it a long ago. Soon after I post it  :-P

By the way, did someone knew parameters for MAPJUMP(74 00 00 00 00 00 00 00 00) opcode?
The first byte seems to be map ID... but the next ones?
Title: Re: A thread just for Fieldscript in general...
Post by: halkun on 2006-07-13 17:13:39
XYZ and rotation of the PC, I haven't played with it much. Looking at the gears manual in the section about the debug rooms, some mapjumps land poor cloud off the walkmesh. [STUCK] I can play with those and see exactly how it's done.

Rotation is most likely 0-255 with 0 following the Z vector. That's what DIR takes as it's second argument.

The jump to 74 (the train station) resets all entities on the map including the PC so the initial PC loaction/rotation isn't needed

Also, my script program is going for human readability, not so much a dump of hex numbers. (Lasyan's dumper is good for that) each opcode is printed via a big switch/case statement so you can individually tool the output of each opcode in it's own case routine. (I'm quite proud of my work with that).

Human readability == Better understanding of uncoded opcode data.

 
Title: Re: A thread just for Fieldscript in general...
Post by: Synergy Blades on 2006-07-23 20:46:14
Just PMd halkun but figured I might as well posted it here to confirm with anyone working on script who may have already spotted this, and inform those that haven't.

As far as I can tell, the list of opcodes & argument counts is not correct for opcode RETTO (id: 0x07). It's down as 4 arguments in the list but I think it's 2. Having looked at the script offsets for anfrst_1's "cl" entity, script 10, for example, it has a RETTO as its final opcode, but four arguments would mean the last two of the four spill over into the start of the next script. Script 1 and 11 also have this issue but again reducing the arg count to 2 for RETTO fixes this problem.

Can anyone confirm this?
Title: Re: A thread just for Fieldscript in general...
Post by: dziugo on 2006-07-23 20:54:13
It's 2. Higher 3 bits is the priority and lower 5 bits is the number of script to "return" to (in the current "thread").

dziugo
Title: Re: A thread just for Fieldscript in general...
Post by: halkun on 2006-09-03 00:39:40
Added some opcodes to the WIKI.

That is all for now...
Title: Re: A thread just for Fieldscript in general...
Post by: Cyberman on 2006-09-03 04:47:10
Added some opcodes to the WIKI.

That is all for now...
Ooooo more opcodes!
Sigh.. my XML 'stuff' is garbage.  BLEAH!

Ahem I should stop complaining :D

the rest regarding it  I'll put in Q-gears forum.

Thanks for the update halkun :)
Cyb
Title: Re: A thread just for Fieldscript in general...
Post by: Synergy Blades on 2006-09-09 03:24:58
Opcode-o-rama, I've done a boatload more. We're well past the half-way mark now.

Anyway, the purpose of my post, I think FD: CMUSC is wrong; should be 7 arguments, is currently down as 5 arguments. Everywhere there's a CMUSC you get the following sort of structure;

Code: [Select]
   CMUSC(2,0,14,0,0)
   return
   return
   CHMST(5,2)

I don't think two extra returns in the middle of a chunk of code is correct, plus the remainder of the code won't get executed.
Title: Re: A thread just for Fieldscript in general...
Post by: dziugo on 2006-09-09 09:58:18
It's advanced by 6 bytes in a main function and by 2 bytes in a subfunction, which probably wasn't noticed. Structure is something like this:
Code: [Select]
OPC AKAO SID B W1 W2

OPC - 0xFD
AKAO - byte - index of AKAO record
SID - source & destination byte
B - byte - something:P
W1 - word pointed by SID byte
W2 - same as above