Author Topic: [Release] Final Fantasy VII Script Code Assembler!  (Read 4904 times)

titeguy3

  • *
  • Posts: 1283
  • A jack of all trades
    • View Profile
I got sick and tired of having to manually edit all of the Jump points in an AI Script after modifying something and having to frequently look up the hex values for stuff, so I decided to write myself a little Assembler so that I can code directly in assembly and use labels and quantifiers instead of having to put in raw hex values.

It's nothing flashy, but it works pretty well. I've tested it against Sephiroth's Pre-Battle script and it matched perfectly.

Here's what the input file looked like:

Code: [Select]
; Sepher Sephiroth's Pre-Battle AI Script
;Label Opcode Argument
PUSH12 Self ;This is a quantifier, There's a total of 124 of them built in. Typing "self" is the same as 2060
PUSH10 402C
MASK
PUSH01 01
STRA
PUSH 00
PUSH02 0268
GLOB
PUSH13 0020
PSHA01 GlobalAddress ;This is another one, this one stands for x2010
STRA
PUSH01 00
PUSH01 5B
GLOB
PUSH13 0040
PSHA01 GlobalAddress
STRA
PUSH01 00
PUSH02 026C
GLOB
PSHA01 GlobalAddress
PUSH01 01
EQU
JMP0 jump1 ;This is a Label, it stores the address of any other instruction, so long as it's labeled with an identical label
PUSH13 0060
PUSH03 013880 ;Note: when dealing with PUSH and PSHA, specifying a type (e.g. PUSH03) is optional--PSHA defaults to PSHA00, and PUSH defaults to opcodes 60, 61, or 62 depending on the argument size.
STRA
JUMP jump2
jump1 PUSH13 0060
PUSH 00 ;See? not necessary
STRA
jump2 PUSH13 0000
PUSH 4E200 ;Trailing zeros are also not necessary
STRA
PUSH13 0000
PSHA03 0000
PUSH01 08
PSHA03 0020
SUB
PUSH02 7530
MUL
SUB
STRA
push12 SELF ;Case insensitivity ftw
PUSH13 mhp
MASK
PSHA03 0000
PSHA03 0060
ADD
STRA
PUSH12 SELF
PUSH13 HP
MASK
PSHA02 SELF
PSHA03 MHP
MASK
PSHA03 0040
PUSH01 #100 ;you can also enter decimal values like this
MUL
SUB
STRA
PSHA02 SELF
PSHA03 MHP
MASK
PSHA02 SELF
PSHA03 HP
MASK
DEBUG 02 HP = %d / %d
PUSH13 0000
PSHA02 SELF
PSHA01 ATTACKPOWER
MASK
PSHA03 0020
PUSH01 02
MUL
ADD
STRA
PUSH12 SELF
PUSH11 ATTACKPOWER
MASK
PSHA03 0000
STRA
PUSH13 0000
PSHA02 SELF
PSHA02 PHYSDEFENSE
MASK
PSHA03 0020
PUSH01 14
MUL
ADD
STRA
PUSH12 SELF
PUSH12 ATTACKPOWER
MASK
PSHA03 0000
STRA
PUSH13 0000
PSHA02 SELF
PSHA01 MAGICPOWER
MASK
PSHA03 0020
PUSH01 05
MUL
ADD
STRA
PUSH12 SELF
PUSH11 MAGICPOWER
MASK
PSHA03 0000
STRA
PUSH13 0000
PSHA02 SELF
PSHA02 MAGDEFENSE
MASK
PSHA03 0020
PUSH01 10
MUL
ADD
STRA
PUSH12 SELF
PUSH12 MAGDEFENSE
MASK
PSHA03 0000
STRA
PSHA02 SELF
PSHA02 MAGDEFENSE
MASK
PSHA02 SELF
PSHA01 MAGICPOWER
MASK
PSHA02 SELF
PSHA02 PHYSDEFENSE
MASK
PSHA02 SELF
PSHA01 ATTACKPOWER
MASK
DEBUG 04 AT %d DF %d ATM %d DFM %d
PUSH12 TARGETMASK
PUSH02 SELF
STRA
PUSH01 20
PUSH02 0368 ;"x" attack
ATTK
PUSH01 20
PUSH02 014F ;"Appear" attack
ATTK
END

And this was the output file:

Code: [Select]
12 2060
10 402C
80
60 01
90
60 00
61 0268
95
13 0020
01 2010
90
60 00
60 5B
95
13 0040
01 2010
90
60 00
61 026C
95
01 2010
60 01
40
70 003D
13 0060
62 013880
90
72 0043
13 0060
60 00
90
13 0000
62 04E200
90
13 0000
03 0000
60 08
03 0020
31
61 7530
32
31
90
12 2060
13 4180
80
03 0000
03 0060
30
90
12 2060
13 4160
80
02 2060
03 4180
80
03 0040
60 64
32
31
90
02 2060
03 4180
80
02 2060
03 4160
80
A0 02 HP = %d / %d
13 0000
02 2060
01 4068
80
03 0020
60 02
32
30
90
12 2060
11 4068
80
03 0000
90
13 0000
02 2060
02 4100
80
03 0020
60 14
32
30
90
12 2060
12 4068
80
03 0000
90
13 0000
02 2060
01 4070
80
03 0020
60 05
32
30
90
12 2060
11 4070
80
03 0000
90
13 0000
02 2060
02 4110
80
03 0020
60 10
32
30
90
12 2060
12 4110
80
03 0000
90
02 2060
02 4110
80
02 2060
01 4070
80
02 2060
02 4100
80
02 2060
01 4068
80
A0 04 AT %d DF %d ATM %d DFM %d
12 2070
61 2060
90
60 20
61 0368
92
60 20
61 014F
92
73

You can see a screenshot of it in action here:


Told ya, the interface isn't exactly flashy but it gets the job done.

You can download it and try it out here

If you find any bugs, be sure to tell me, send me a screenshot or a copy of the error message and the input file and I'll try to fix it and get another version up.

Edit: FF7 Script Code Assembler is now v1.1! The max number of labels allowed is now 50 (from 10) and it no longer crashes when you exceed that. Note also that the max label size is 15 characters. The TBIT opcode has also been fixed.
« Last Edit: 2009-08-03 15:42:04 by titeguy3 »

gamefac

  • *
  • Posts: 22
    • View Profile
Re: [Release] Final Fantasy VII Script Code Assembler!
« Reply #1 on: 2009-07-17 23:35:02 »
Is this for script for PC version? i'm hoping for a psx enemy script

Kudistos Megistos

  • Banned
  • *
  • Posts: 3929
    • View Profile
Re: [Release] Final Fantasy VII Script Code Assembler!
« Reply #2 on: 2009-07-17 23:59:59 »
I haven't tried it, but since the scene.bin is the same in both versions of the game maybe this will work with both?
« Last Edit: 2009-08-13 01:03:56 by Kudistos Megistos »

titeguy3

  • *
  • Posts: 1283
  • A jack of all trades
    • View Profile
Re: [Release] Final Fantasy VII Script Code Assembler!
« Reply #3 on: 2009-07-18 00:42:22 »
It just spits out a .txt file with the hex values for the script, which are gonna be the same between pc and psx.

I admit that this would be a ton more useful if you could just copy and paste tabbed entries into proudclod.
« Last Edit: 2009-07-18 00:49:50 by titeguy3 »