Difference between revisions of "FF8/Field/Script/Opcodes"
Jump to navigation
Jump to search
my_wiki>Shard |
my_wiki>Myst6re |
||
Line 8: | Line 8: | ||
PSHN_L 6 # push number 6 onto the stack (stack = [6 ; var1024]) | PSHN_L 6 # push number 6 onto the stack (stack = [6 ; var1024]) | ||
CAL EQ # compare the two numbers at the top of the stack, pop this numbers, and push the result (1 or 0) into the stack (stack = [1 or 0]) | CAL EQ # compare the two numbers at the top of the stack, pop this numbers, and push the result (1 or 0) into the stack (stack = [1 or 0]) | ||
− | JPF LABEL1 # if the popped top of the stack is 0, jump to LABEL1 | + | JPF LABEL1 # if the popped top of the stack is 0, jump to LABEL1 (stack = []) |
PSHN_L 0 # push 0 at the top of the stack (stack = [0]) | PSHN_L 0 # push 0 at the top of the stack (stack = [0]) | ||
POPM_W 1024 # pop the top of the stack into var1024 (stack = []) | POPM_W 1024 # pop the top of the stack into var1024 (stack = []) |
Revision as of 01:51, 11 May 2014
The language
The field script language in ff8 is a simple assembly language with a stack. Here is an example:
stack = []
PSHM_W 1024 # push var1024 onto the stack (stack = [var1024]) PSHN_L 6 # push number 6 onto the stack (stack = [6 ; var1024]) CAL EQ # compare the two numbers at the top of the stack, pop this numbers, and push the result (1 or 0) into the stack (stack = [1 or 0]) JPF LABEL1 # if the popped top of the stack is 0, jump to LABEL1 (stack = []) PSHN_L 0 # push 0 at the top of the stack (stack = [0]) POPM_W 1024 # pop the top of the stack into var1024 (stack = []) JMP LABEL2 # goto LABEL2 LABEL1 PSHN_L 1 # push 1 at the top of the stack (stack = [1]) POPM_W 1024 # pop the top of the stack into var1024 (stack = []) LABEL2 ...
In standard code, it's equivalent to:
if(var1024 == 6) { var1024 = 0; } else { var1024 = 1; }
Reading Documentation
Each Opcode's page lists all the parameters for that function in the order you would put them on the stack before the function call. The inline argument is listed separately, if the function requires one. For example, on the page for SET3, the parameters are listed like this:
- XCoord
- YCoord
- ZCoord
- SET3
Which means when you call SET3, the ZCoord is the top item on the stack, YCoord is under it, and XCoord is under that, for example
PSHN_L 402 (XCoord) PSHN_L -381 (YCoord) PSHN_L 20 (ZCoord) SET3 17 (walkmesh triangle ID)
Opcode list
000 NOP (Unused) 001 CAL 002 JMP 003 JPF 004 GJMP (Unused) 005 LBL 006 RET 007 PSHN_L 008 PSHI_L 009 POPI_L 00A PSHM_B 00B POPM_B 00C PSHM_W 00D POPM_W 00E PSHM_L 00F POPM_L 010 PSHSM_B 011 PSHSM_W 012 PSHSM_L 013 PSHAC 014 REQ 015 REQSW 016 REQEW 017 PREQ 018 PREQSW 019 PREQEW 01A UNUSE 01B DEBUG (Unused) 01C HALT 01D SET 01E SET3 01F IDLOCK 020 IDUNLOCK 021 EFFECTPLAY2 022 FOOTSTEP 023 JUMP 024 JUMP3 025 LADDERUP 026 LADDERDOWN 027 LADDERUP2 028 LADDERDOWN2 029 MAPJUMP 02A MAPJUMP3 02B SETMODEL 02C BASEANIME 02D ANIME 02E ANIMEKEEP 02F CANIME 030 CANIMEKEEP 031 RANIME 032 RANIMEKEEP 033 RCANIME 034 RCANIMEKEEP 035 RANIMELOOP 036 RCANIMELOOP 037 LADDERANIME 038 DISCJUMP 039 SETLINE 03A LINEON 03B LINEOFF 03C WAIT 03D MSPEED 03E MOVE 03F MOVEA 040 PMOVEA 041 CMOVE 042 FMOVE 043 PJUMPA 044 ANIMESYNC 045 ANIMESTOP 046 MESW (Unused) 047 MES 048 MESSYNC 049 MESVAR 04A ASK 04B WINSIZE 04C WINCLOSE 04D UCON 04E UCOFF 04F MOVIE 050 MOVIESYNC 051 SETPC 052 DIR 053 DIRP 054 DIRA 055 PDIRA 056 SPUREADY 057 TALKON 058 TALKOFF 059 PUSHON 05A PUSHOFF 05B ISTOUCH 05C MAPJUMPO 05D MAPJUMPON 05E MAPJUMPOFF 05F SETMESSPEED 060 SHOW 061 HIDE 062 TALKRADIUS 063 PUSHRADIUS 064 AMESW 065 AMES 066 GETINFO 067 THROUGHON 068 THROUGHOFF 069 BATTLE 06A BATTLERESULT 06B BATTLEON 06C BATTLEOFF 06D KEYSCAN 06E KEYON 06F AASK 070 PGETINFO 071 DSCROLL 072 LSCROLL 073 CSCROLL 074 DSCROLLA 075 LSCROLLA 076 CSCROLLA 077 SCROLLSYNC 078 RMOVE 079 RMOVEA 07A RPMOVEA 07B RCMOVE 07C RFMOVE 07D MOVESYNC 07E CLEAR 07F DSCROLLP 080 LSCROLLP 081 CSCROLLP 082 LTURNR 083 LTURNL 084 CTURNR 085 CTURNL 086 ADDPARTY 087 SUBPARTY 088 CHANGEPARTY 089 REFRESHPARTY 08A SETPARTY 08B ISPARTY 08C ADDMEMBER 08D SUBMEMBER 08E ISMEMBER (Unused) 08F LTURN 090 CTURN 091 PLTURN 092 PCTURN 093 JOIN 094 MESFORCUS (Unused) 095 BGANIME 096 RBGANIME 097 RBGANIMELOOP 098 BGANIMESYNC 099 BGDRAW 09A BGOFF 09B BGANIMESPEED 09C SETTIMER 09D DISPTIMER 09E SHADETIMER (Unused) 09F SETGETA 0A0 SETROOTTRANS 0A1 SETVIBRATE 0A2 STOPVIBRATE (Unused) 0A3 MOVIEREADY 0A4 GETTIMER 0A5 FADEIN 0A6 FADEOUT 0A7 FADESYNC 0A8 SHAKE 0A9 SHAKEOFF 0AA FADEBLACK 0AB FOLLOWOFF 0AC FOLLOWON 0AD GAMEOVER 0AE ENDING (Unused) 0AF SHADELEVEL 0B0 SHADEFORM 0B1 FMOVEA 0B2 FMOVEP 0B3 SHADESET 0B4 MUSICCHANGE 0B5 MUSICLOAD 0B6 FADENONE 0B7 POLYCOLOR 0B8 POLYCOLORALL 0B9 KILLTIMER 0BA CROSSMUSIC 0BB DUALMUSIC 0BC EFFECTPLAY 0BD EFFECTLOAD 0BE LOADSYNC 0BF MUSICSTOP 0C0 MUSICVOL 0C1 MUSICVOLTRANS 0C2 MUSICVOLFADE 0C3 ALLSEVOL 0C4 ALLSEVOLTRANS 0C5 ALLSEPOS (Unused) 0C6 ALLSEPOSTRANS 0C7 SEVOL 0C8 SEVOLTRANS 0C9 SEPOS 0CA SEPOSTRANS 0CB SETBATTLEMUSIC 0CC BATTLEMODE 0CD SESTOP 0CE BGANIMEFLAG (Unused) 0CF INITSOUND 0D0 BGSHADE 0D1 BGSHADESTOP 0D2 RBGSHADELOOP 0D3 DSCROLL2 0D4 LSCROLL2 0D5 CSCROLL2 0D6 DSCROLLA2 0D7 LSCROLLA2 (Unused) 0D8 CSCROLLA2 0D9 DSCROLLP2 (Unused) 0DA LSCROLLP2 (Unused) 0DB CSCROLLP2 (Unused) 0DC SCROLLSYNC2 0DD SCROLLMODE2 0DE MENUENABLE 0DF MENUDISABLE 0E0 FOOTSTEPON 0E1 FOOTSTEPOFF 0E2 FOOTSTEPOFFALL 0E3 FOOTSTEPCUT 0E4 PREMAPJUMP 0E5 USE 0E6 SPLIT 0E7 ANIMESPEED 0E8 RND 0E9 DCOLADD 0EA DCOLSUB 0EB TCOLADD 0EC TCOLSUB 0ED FCOLADD 0EE FCOLSUB 0EF COLSYNC 0F0 DOFFSET 0F1 LOFFSETS 0F2 COFFSETS 0F3 LOFFSET 0F4 COFFSET 0F5 OFFSETSYNC 0F6 RUNENABLE 0F7 RUNDISABLE 0F8 MAPFADEOFF 0F9 MAPFADEON 0FA INITTRACE 0FB SETDRESS 0FC GETDRESS (Unused) 0FD FACEDIR 0FE FACEDIRA 0FF FACEDIRP 100 FACEDIRLIMIT 101 FACEDIROFF 102 SARALYOFF 103 SARALYON 104 SARALYDISPOFF 105 SARALYDISPON 106 MESMODE 107 FACEDIRINIT 108 FACEDIRI 109 JUNCTION 10A SETCAMERA 10B BATTLECUT 10C FOOTSTEPCOPY 10D WORLDMAPJUMP 10E RFACEDIRI (Unused) 10F RFACEDIR 110 RFACEDIRA 111 RFACEDIRP 112 RFACEDIROFF 113 FACEDIRSYNC 114 COPYINFO 115 PCOPYINFO (Unused) 116 RAMESW 117 BGSHADEOFF 118 AXIS 119 AXISSYNC (Unused) 11A MENUNORMAL 11B MENUPHS 11C BGCLEAR 11D GETPARTY 11E MENUSHOP 11F DISC 120 DSCROLL3 (Unused) 121 LSCROLL3 122 CSCROLL3 123 MACCEL 124 MLIMIT 125 ADDITEM 126 SETWITCH 127 SETODIN 128 RESETGF 129 MENUNAME 12A REST 12B MOVECANCEL 12C PMOVECANCEL (Unused) 12D ACTORMODE 12E MENUSAVE 12F SAVEENABLE 130 PHSENABLE 131 HOLD 132 MOVIECUT 133 SETPLACE 134 SETDCAMERA 135 CHOICEMUSIC 136 GETCARD 137 DRAWPOINT 138 PHSPOWER 139 KEY 13A CARDGAME 13B SETBAR 13C DISPBAR 13D KILLBAR 13E SCROLLRATIO2 13F WHOAMI 140 MUSICSTATUS 141 MUSICREPLAY 142 DOORLINEOFF 143 DOORLINEON 144 MUSICSKIP 145 DYING 146 SETHP 147 GETHP (Unused) 148 MOVEFLUSH 149 MUSICVOLSYNC 14A PUSHANIME 14B POPANIME 14C KEYSCAN2 14D KEYON2 (Unused) 14E PARTICLEON 14F PARTICLEOFF 150 KEYSIGHNCHANGE 151 ADDGIL 152 ADDPASTGIL 153 ADDSEEDLEVEL 154 PARTICLESET 155 SETDRAWPOINT 156 MENUTIPS 157 LASTIN 158 LASTOUT 159 SEALEDOFF 15A MENUTUTO 15B OPENEYES (Unused) 15C CLOSEEYES 15D BLINKEYES (Unused) 15E SETCARD 15F HOWMANYCARD 160 WHERECARD 161 ADDMAGIC 162 SWAP 163 SETPARTY2 (Unused) 164 SPUSYNC 165 BROKEN