Author Topic: Script Dumper  (Read 7482 times)

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Script Dumper
« on: 2006-07-01 21:56:00 »
Ok, I'm in process of writing a script dumper. (I can read the header now)

It sould be the end-all-be-all dumping system. You guys will be able to rip what you need when I'm done. I'm progressing pretty quickly so I should have something basiclly functional soon.

As for right now, I'm being removed from the internet cafe I'm in.  This is due to the holiday. I'll see you guys on monday...




halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Script Dumper
« Reply #1 on: 2006-07-02 20:06:50 »
I know... Double post, but it's an important announcement that's worthy of a bump. I just uploaded the beginnings of a fieldscript dumper into SVN. It can be found under the /utils directory off the main tree.

You can see it here

I started coding at 3 in the afternoon and went until four in the morning, by looking at my comments you sould be able to tell two things.

1) General program flow
2) How punch drunk I get after coding after 2am.

I make no apologies for the code. I haven't touched C in almost 8 years, so it's pretty bad. Oh and it's gonna get worse! ^_^

The output fieldscript is designed so that if a compilier is created, it can parse the output. I have everything but the actual dumper coded.  All that's really missing is the dumpscript(int addr); function that takes an offset in the field file and starts writing out opcodes.

Of course, most likely you are going to need to pass more than just the address, you will probably need the pass the entity names, offset the the dialog strings, and other goodies as I totaly horked up my varible scope. I wish I could of used a struct, but some of the entity data is dynamic.


The field script will look like this when finished...


Quote
# Final Fantasy 7 Field Script
# Original Name: startmap
# Created by: hiroki
#
# Internal filename: startma
#
                                                                               
                                                                               
                                                                               
#################### Entity 0 (dic) ####################
                                                                               
entity dic (script 0)
{
prtyp(0)
ret
ret
}
                                                                               
entity dic (script 1)
{
ret
}
                                                                               
alias dic (script 1 to 31)
                                                                               
#################### Entity 1 (cloud) ####################
                                                                               
entity cloud (script 0)
{
char(0)
pc(0)
ret
xyzi(00,00,00,00,00,00,00,00, 01,00 )
ret
}
                                                                               
entity cloud (script 1)
{
ret
}
                                                                               
alias cloud (script 1 to 31)
                                                                               
#################### Entity 2 (tifa) ####################

entity tifa (script 0)
{
.......


Commands that use conditionals will have blocks of code
Quote
ifubytel(<5>[15] == 12)
{
      special (250)
      ret
      JmpLong lbl_014:
}

Just a heads up...

sfx1999

  • *
  • Posts: 1142
    • View Profile
Re: Script Dumper
« Reply #2 on: 2006-07-02 21:11:21 »
Are you going to use Lex and Yacc?

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: Script Dumper
« Reply #3 on: 2006-07-02 23:49:15 »
Flex and Bison ;)

Prolog though can take horn clauses and emit code rather quickly.
Ehh six of this half dozen of the other.

Cyb

Akari

  • Moderator
  • *
  • Posts: 766
    • View Profile
Re: Script Dumper
« Reply #4 on: 2006-07-04 17:55:50 »
I added basic scripting system to Q-Gears. it's in SVN already.

kini

  • *
  • Posts: 135
    • View Profile
    • open source web
Re: Script Dumper
« Reply #5 on: 2006-07-04 19:43:42 »
i think it'd be sooo cool if this all works with the psx files and jap versions of ffvii, is there any chance of that?

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Script Dumper
« Reply #6 on: 2006-07-04 23:06:21 »
The problem with the Japanese version of FF7 is that I'm colored a bright shade of clueless on how the Japanese text encodeing works. If you look at window.bin, there is a HUGE blank spot under the text that's not used (With the PSX having very little VRAM real estate, such a big blank spot where textures could of gone would of gotten the graphics programmer fired ^_^) I'm guessing that when a field file loads, there was a header that told the window.bin loader which kanji were going to be displayed in that scene. (I'm pretty sure there isn't enough space for all 1,945 Joyo kanji+kana) Then, somewhere in window.bin a bank of kanji glyphs were assembed and placed in the big blank below the text. However I have no access to the Japanese version of the game, so I don't know if this is true.

FF6 had a bank of double-byte refrenced kanji glyphs that was looked up via a pointer, but as FF6 was an SNES cart, the whole table was in memory.

It might explain some of the "unknowns" in the field files.

Also, an update...

I'm pretty much hit the end of my programming ability writing the fieldscript dumper. I'm bottoming out using strings and pointers. I'm uploading what I have into SVN, and putting a call out to anyone who wants to pick up where I left off. All that really needs to be done is the dumpscript(); command to change the opcodes onto text strings. I made comments for everyone to follow along.


Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: Script Dumper
« Reply #7 on: 2006-07-05 03:02:17 »
I've never seen anything regarding the encoding for both FF8 and FF7 in Japanese.  Are there 'game shark' style web sites for the japanese versions of these games?

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Script Dumper
« Reply #8 on: 2006-07-08 20:18:05 »
Ok, I've updated the script dumper program. All that's left now is the individual decrypting of opcodes. I have a tiny bug were my opcode arguments seems to be fetched backwards. I'll fix that today.

(EDIT: Oops, I also need to dump the dialog too. I'll get to that ^_^)

Also, as a first, I also support the correct dumping of the Script 0 "init" and "base" scripts (GO ME!)  and also soon, I'll be able to correctly parse memory access.

I can use some comments on how it's looking.

The system will do two passes (I'm working on pass one now), the second pass will give labels to the various jump commands and bracket the conditionals. I don't know if I will be dumping the raw hex data or not. Any ideas on that?

Here's an example dump from the top of "startmap" with my program.

Quote
# Final Fantasy 7 Field Script
# Original Name: startmap
# Created by: hiroki
#
# Internal filename: startma
#
                                                                               
                                                                               
                                                                               
#################### Entity 0 (dic) ####################
                                                                               
ENTITY(0) = dic
                                                                               
dic (script 0)
{
INIT:
    prtyp(0)
    ret
BASE:
    ret
}
                                                                               
dic (script 1)
{
    ret
}
                                                                               
alias dic (script 1 to 31)
                                                                               
#################### Entity 1 (cloud) ####################
                                                                               
ENTITY(1) = cloud
                                                                               
cloud (script 0)
{
INIT:
    char(0)
    pc(0)
    ret
BASE:
    xyzi(0,1,0,0,0,0,0,0,0,0)
    ret
}
                                                                               
cloud (script 1)
{
    ret
}
                                                                               
alias cloud (script 1 to 31)
#################### Entity 2 (tifa) ####################
                                                                               
ENTITY(2) = tifa
                                                                               
tifa (script 0)
{
INIT:
    char(1)
    pc(2)
    ret
BASE:
    ret
}
                                                                               
tifa (script 1)
{
    ret
}
                                                                               
alias tifa (script 1 to 31)
                                                                               
#################### Entity 3 (cid) ####################
                                                                               
ENTITY(3) = cid
                                                                               
cid (script 0)
{
INIT:
    char(2)
    pc(8)
    ret
BASE:
    ret
}
                                                                               
cid (script 1)
{
    ret
}
                                                                               
alias cid (script 1 to 31)
                                                                               
#################### Entity 4 (yufi) ####################
                                                                               
ENTITY(4) = yufi
                                                                               
yufi (script 0)
{
INIT:
    char(3)
    xyzi(0,64,0,0,ff,7e,ff,b6,0,0)
    dir(60,0)
    slidr(1,0)
    ret
BASE:
    ret
}
                                                                               
yufi (script 1)
{
...
}

not bad huh?


Sephrys

  • Guest
Re: Script Dumper
« Reply #9 on: 2007-01-06 08:36:21 »
How is it possible to "decompress" these files
STARTMAP.BSX  STARTMAP.DAT  STARTMAP.MIM

to get it to work?

Sephrys

  • Guest
Re: Script Dumper
« Reply #10 on: 2007-01-06 08:50:43 »
playing in epsxe linux, European Version, interested in Japanese version

anyway in theory something similar to this could work? I have full blown linux setup here, but not sure about the 28 byte header,
maybe edit the 28 bytes out with a hex editor then do this? Help me please, I want the script dump!

$ lha -x STARTMAP.DAT
LHa: Fatal error: Unknown level header

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Script Dumper
« Reply #11 on: 2007-01-06 19:22:57 »
My program only works for uncompressed PC field files. You have to edit the code to have it be able to read uncompressed PSX files.

Sephrys

  • Guest
Re: Script Dumper
« Reply #12 on: 2007-01-06 20:46:25 »
Got the PC copy too, will take a look at the details, the instructions may be different in the PSX version possibly specifically the Japanese version,
so some help would be cool, but otherwise we'll manage for now. Now how is one to uncompress the PC files, is in the gears pdf?

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: Script Dumper
« Reply #13 on: 2007-01-07 00:49:26 »
The PC files are archived you have to extract them from the archive I believe.
The opcodes are likely to be Similiar but not the same for the Japanese version. Especially the dialog information.  If you can please share the Japanese information as it will allow Q-gears to work with the Japanese/International release of FF7.

Cyb

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Script Dumper
« Reply #14 on: 2007-01-07 01:00:03 »
Sephrysは日本人ですか?