• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Tool: PKSV - Pokémon Script Editor + GUI

Status
Not open for further replies.

IIMarckus

J946@5488AA97464
402
Posts
16
Years
    • Seen Feb 21, 2024
    score_under, do you plan on releasing PKSV (the command‐line version, at least) for Linux and similar operating systems? I hear it works with Wine, but that option isn't available for all platforms, including mine.
     

    score_under

    Inactive; Former ROM hack tool author, ❤️
    526
    Posts
    18
    Years
  • score_under, do you plan on releasing PKSV (the command‐line version, at least) for Linux and similar operating systems? I hear it works with Wine, but that option isn't available for all platforms, including mine.
    PKSV has a SVN repository - if you get the source code from there, you should be able to compile it with little problem.

    If you do run into a problem, tell me.

    I've also now compiled a new version of PKSV, look at the decompile dialog ;) So much improvement it's not even funny, haha... also, the AssociateShell.bat bug has been fixed.

    Chinese version is lagging behind in resources (seriously!), so moved that into "mlpksvui.exe" instead of the main "pksvui.exe".
     
    Last edited:

    IIMarckus

    J946@5488AA97464
    402
    Posts
    16
    Years
    • Seen Feb 21, 2024
    If you do run into a problem, tell me.
    Code:
    …
    #include <stdio.h>
    [b]#include <windows.h>[/b]
    HANDLE LogFile;
    #include "pokedef.h"
    #include "golddef.h"
    #include "textproc.h"
    …
    A lot of code uses it as well.
     

    score_under

    Inactive; Former ROM hack tool author, ❤️
    526
    Posts
    18
    Years
  • Code:
    …
    #include <stdio.h>
    [B]#include <windows.h>[/B]
    HANDLE LogFile;
    #include "pokedef.h"
    #include "golddef.h"
    #include "textproc.h"
    …
    A lot of code uses it as well.
    Hehe, I could have sworn I removed that...

    Ah yes, you have to compile pksv2.c, not pksv.c... sorry.
     

    IIMarckus

    J946@5488AA97464
    402
    Posts
    16
    Years
    • Seen Feb 21, 2024
    Turns out I was using an old version anyway. Just checked out version 2.0.4 from the SVN, and got these results:
    Code:
    $ gcc -o pksv.out pksv2.c
    In file included from pksv2.c:26:
    /usr/include/malloc.h:4:2: warning: #warning "<malloc.h> is obsolete, use <stdlib.h>"
    In file included from sulib.h:4,
                     from pksv2.c:34:
    /usr/include/malloc.h:4:2: warning: #warning "<malloc.h> is obsolete, use <stdlib.h>"
    In file included from pksv2.c:55:
    codeproc.h:370:21: gba_asm.h: No such file or directory
    In file included from codeproc.h:371,
                     from pksv2.c:55:
    decompiler.h: In function `DecodeProcLevel':
    decompiler.h:3985: error: `VersionOverride' undeclared (first use in this function)
    decompiler.h:3985: error: (Each undeclared identifier is reported only once
    decompiler.h:3985: error: for each function it appears in.)
    decompiler.h:4106: error: `asm_buf' undeclared (first use in this function)
    decompiler.h: In function `DecodeProc':
    decompiler.h:4135: error: `VersionOverride' undeclared (first use in this function)
    decompiler.h:4221: error: `asm_buf' undeclared (first use in this function)
    decompiler.h: In function `DecodeProcASM':
    decompiler.h:4248: error: `VersionOverride' undeclared (first use in this function)
    decompiler.h:4285: error: `asm_buf' undeclared (first use in this function)
    $ gcc -v
    Reading specs from /usr/lib/gcc-lib/i386-unknown-openbsd4.5/3.3.5/specs
    Configured with: 
    Thread model: single
    gcc version 3.3.5 (propolice)
    $
    Platform: OpenBSD i386
     

    score_under

    Inactive; Former ROM hack tool author, ❤️
    526
    Posts
    18
    Years
  • Okay, NOT my lucky day :P I forgot to add one of the files to the SVN - will do that now.

    EDIT-Done. Tell me if I missed yet more XD
     

    score_under

    Inactive; Former ROM hack tool author, ❤️
    526
    Posts
    18
    Years
  • They're pretty much strictly fixed, but here they are:
    Code:
    pksv -e ScriptFile.txt RomFile.gba        -- Debug compile
    pksv -r ScriptFile.txt RomFile.gba        -- Compile
    pksv RomFile.gba HexOffset OutputFile.txt -- Decompile
    Yes, this means that before I used a DLL, PKSVUI would just read the file, "_d_.pks.tmp"... :P

    Even though you compiled it as command-line, I've done as much as I can to make it work just as well as PKSV in Windows (dynamic offsets, THUMB, pokemarts ...)

    EDIT: - Slightly unrelated ;) This script will work in the soon-to-come v2.0.5, it's a slightly modified version of the "move-to-place" script I mentioned earlier:
    Code:
    [COLOR=#000000][FONT=Lucida Console][COLOR=#ff8000]#dyn 0x800000
    #define safe-val 0x100[/COLOR]
    [COLOR=#008000]'Safe-val is a value definitely larger than the X and Y coords on the map, which is to avoid unsigned integer overflow.[/COLOR]
    [COLOR=#ff8000]#org @start[/COLOR]
    [B][COLOR=#0000c0]lockall[/COLOR][/B]
    getplayerxy [COLOR=#ff0000]0x8000 0x8001[/COLOR]
    addvar [COLOR=#ff0000]0x8000 safe-val[/COLOR]
    addvar [COLOR=#ff0000]0x8001 safe-val[/COLOR]
    subtractvar [COLOR=#ff0000]0x8000 0xA [/COLOR][COLOR=#008000]' Position X to move to[/COLOR]
    subtractvar [COLOR=#ff0000]0x8001 0x9 [/COLOR][COLOR=#008000]' Position Y to move to - try this one in Pallet Town.[/COLOR]
    compare [COLOR=#ff0000]0x8000 safe-val[/COLOR]
    [COLOR=#0000c0][B]if[/B][/COLOR] [COLOR=#ff0000]< jump :loop2[/COLOR]
    [B]:loop[/B]
    [COLOR=#0000c0][B]if[/B][/COLOR] [COLOR=#ff0000]== jump :loop3_s[/COLOR]
    applymovement [COLOR=#ff0000]PLAYER @run-left[/COLOR]
    pauseevent [COLOR=#ff0000]0x0[/COLOR]
    subtractvar [COLOR=#ff0000]0x8000 1[/COLOR]
    compare [COLOR=#ff0000]0x8000 safe-val[/COLOR]
    [COLOR=#0000c0][B]jump[/B][/COLOR] [COLOR=#ff0000]:loop[/COLOR]
    [B]:loop2[/B]
    compare [COLOR=#ff0000]0x8000 safe-val[/COLOR]
    [COLOR=#0000c0][B]if[/B][/COLOR] [COLOR=#ff0000]== jump :loop3_s[/COLOR]
    applymovement [COLOR=#ff0000]PLAYER @run-right[/COLOR]
    pauseevent [COLOR=#ff0000]0x0[/COLOR]
    addvar [COLOR=#ff0000]0x8000 1[/COLOR]
    [COLOR=#0000c0][B]jump[/B][/COLOR] [COLOR=#ff0000]:loop2[/COLOR]
    [B]:loop3_s[/B]
    compare [COLOR=#ff0000]0x8001 safe-val[/COLOR]
    [COLOR=#0000c0][B]if[/B][/COLOR] [COLOR=#ff0000]< jump :loop4[/COLOR]
    [B]:loop3[/B]
    [COLOR=#0000c0][B]if[/B][/COLOR] [COLOR=#ff0000]== jump :endloops[/COLOR]
    applymovement [COLOR=#ff0000]PLAYER @run-up[/COLOR]
    pauseevent [COLOR=#ff0000]0x0[/COLOR]
    subtractvar [COLOR=#ff0000]0x8001 1[/COLOR]
    compare [COLOR=#ff0000]0x8001 safe-val[/COLOR]
    [COLOR=#0000c0][B]jump[/B][/COLOR] [COLOR=#ff0000]:loop3[/COLOR]
    [B]:loop4[/B]
    compare [COLOR=#ff0000]0x8001 safe-val[/COLOR]
    if [COLOR=#ff0000]== jump :endloops[/COLOR]
    applymovement [COLOR=#ff0000]PLAYER @run-down[/COLOR]
    pauseevent [COLOR=#ff0000]0x0[/COLOR]
    addvar [COLOR=#ff0000]0x8001 1[/COLOR]
    jump [COLOR=#ff0000]:loop4[/COLOR]
    [B]:endloops[COLOR=#0000c0]
    releaseall
    end[/COLOR][/B]
    
    [COLOR=#ff8000]#org @run-left[/COLOR]
    [COLOR=#ff0000]m[/COLOR][COLOR=#008000] run_left end[/COLOR]
    [COLOR=#ff8000]#org @run-right[/COLOR]
    [COLOR=#ff0000]m[/COLOR][COLOR=#008000] run_right end[/COLOR]
    [COLOR=#ff8000]#org @run-up[/COLOR]
    [COLOR=#ff0000]m[/COLOR][COLOR=#008000] run_up end[/COLOR]
    [COLOR=#ff8000]#org @run-down[/COLOR]
    [COLOR=#ff0000]m[/COLOR][COLOR=#008000] run_down end[/COLOR][/FONT][/COLOR]
    Edit - "Soon to come"? What the hell was I talking about? :P
     
    Last edited:
    5
    Posts
    14
    Years
    • Seen Sep 4, 2010
    MY code messed up please help

    i put in this code
    Code:
    #org 0x8800638
    '-----------------------------------
    checkflag 0x9999
    if 0x1 jump 0x88006F6 ' Equal To
    msgbox 0x8800657 ' I found this helples...
    callstd MSG_NORMAL ' Normal message
    addpokemon 0x4 0xB 0x0 0x0 0xF000000 0xC300C300
    setflag 0x9999
    
    #org 0x88006F6
    '-----------------------------------
    msgbox 0x88006FF ' Please take it away.
    callstd MSG_NORMAL ' Normal message
    end
    
    
    #org 0x8800657
    = take this Charmander.
    
    #org 0x88006FF
    = Please take it away.
    Then it turned into this after i compiled it
    Code:
    #org 0x8800638
    '-----------------------------------
    checkflag 0x9999
    if 0x1 jump 0x88006F6 ' Equal To
    msgbox 0x8800657 ' I found this helples...
    callstd MSG_NORMAL ' Normal message
    addpokemon 0x4 0xB 0x0 0x0 0xF000000 0xC300C300
    nop0 ' #raw 0x0
    #raw 0xDA
    #raw 0xE3
    #raw 0xE9
    #raw 0xE2
    #raw 0xD8
    nop0 ' #raw 0x0
    #raw 0xE8
    #raw 0xDC
    #raw 0xDD
    #raw 0xE7
    nop0 ' #raw 0x0
    #raw 0xDC
    #raw 0xD9
    #raw 0xE0
    #raw 0xE4
    #raw 0xE0
    #raw 0xD9
    #raw 0xE7
    #raw 0xE7
    CMD_FE 0x0
    #raw 0xBD
    updatecoins 0xBB 0xCC
    textcolor 0xBB 'Sets text color (Fire Red).
    #raw 0xC8
    #raw 0xBE
    #raw 0xBF
    checkobedience 0x0 0xE0D5
    #raw 0xE3
    #raw 0xE2
    #raw 0xD9
    CMD_FB 0xE2DD00
    #raw 0xE9
    #raw 0xE4
    nop0 ' #raw 0x0
    #raw 0xDC
    #raw 0xD9
    #raw 0xE6
    #raw 0xD9
    setdoorclosed 0xC300 0xE800
    #raw 0xDC
    #raw 0xDD
    #raw 0xE2
    #raw 0xDF
    CMD_FE 0x0
    #raw 0xDD
    #raw 0xE8
    nop0 ' #raw 0x0
    #raw 0xDA
    #raw 0xD9
    #raw 0xE0
    #raw 0xE0
    nop0 ' #raw 0x0
    #raw 0xDA
    #raw 0xE6
    #raw 0xE3
    #raw 0xE1
    nop0 ' #raw 0x0
    #raw 0xE9
    #raw 0xE4
    nop0 ' #raw 0x0
    #raw 0xDC
    #raw 0xD9
    #raw 0xE6
    #raw 0xD9
    setdoorclosed 0xC3FB 0xE7E8
    nop0 ' #raw 0x0
    #raw 0xDC
    #raw 0xD9
    #raw 0xD5
    #raw 0xE0
    #raw 0xE8
    #raw 0xDC
    #raw 0xED
    nop0 ' #raw 0x0
    #raw 0xE4
    #raw 0xE0
    #raw 0xD9
    #raw 0xD5
    #raw 0xE7
    #raw 0xD9
    nop0 ' #raw 0x0
    #raw 0xE8
    #raw 0xD5
    #raw 0xDF
    #raw 0xD9
    nop0 ' #raw 0x0
    #raw 0xDD
    #raw 0xE8
    CMD_FE 0x0
    #raw 0xEB
    #raw 0xDD
    #raw 0xE8
    #raw 0xDC
    nop0 ' #raw 0x0
    #raw 0xED
    #raw 0xE3
    #raw 0xE9
    setdoorclosed 0xCAFF 0xD9E0
    #raw 0xD5
    #raw 0xE7
    #raw 0xD9
    nop0 ' #raw 0x0
    #raw 0xDB
    #raw 0xDD
    #raw 0xEA
    #raw 0xD9
    nop0 ' #raw 0x0
    #raw 0xBD
    updatecoins 0xBB 0xCC
    textcolor 0xBB 'Sets text color (Fire Red).
    #raw 0xC8
    #raw 0xBE
    #raw 0xBF
    checkobedience 0x0 0xD5FE
    nop0 ' #raw 0x0
    #raw 0xDB
    #raw 0xE3
    #raw 0xE3
    #raw 0xD8
    nop0 ' #raw 0x0
    #raw 0xDC
    #raw 0xE3
    #raw 0xE1
    #raw 0xD9
    setdoorclosed 0xFFF 0xFF00
    if 0x80 jump 0x2060908 ' Unknown IF condition
              'Jump not in ROM area
    msgboxsign
    #raw 0xE0
    #raw 0xD9
    #raw 0xD5
    #raw 0xE7
    #raw 0xD9
    nop0 ' #raw 0x0
    #raw 0xE8
    #raw 0xD5
    #raw 0xDF
    #raw 0xD9
    nop0 ' #raw 0x0
    #raw 0xDD
    #raw 0xE8
    nop0 ' #raw 0x0
    #raw 0xD5
    #raw 0xEB
    #raw 0xD5
    #raw 0xED
    setdoorclosed 0xFFFF 0xFFFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    #raw 0xFF
    'Decompiler stopped due to failsafe mechanism (too many #RAW 0xFF commands)
    
    #org 0x88006F6
    '-----------------------------------
    msgbox 0x88006FF ' Please take it away.
    callstd MSG_NORMAL ' Normal message
    end
    
    
    #org 0x8800657
    = I found this helpless\n CHARMANDER alone\p in up here. I think\n it fell from up here.\pIts healthy please take it\n with you.
    
    #org 0x88006FF
    = Please take it away.
     

    score_under

    Inactive; Former ROM hack tool author, ❤️
    526
    Posts
    18
    Years
  • MY code messed up please help

    i put in this code
    Code:
    #org 0x8800638
    '-----------------------------------
    checkflag 0x9999
    if 0x1 jump 0x88006F6 ' Equal To
    msgbox 0x8800657 ' I found this helples...
    callstd MSG_NORMAL ' Normal message
    addpokemon 0x4 0xB 0x0 0x0 0xF000000 0xC300C300
    setflag 0x9999
    
    #org 0x88006F6
    '-----------------------------------
    msgbox 0x88006FF ' Please take it away.
    callstd MSG_NORMAL ' Normal message
    end
    
    
    #org 0x8800657
    = take this Charmander.
    
    #org 0x88006FF
    = Please take it away.
    Then it turned into this after i compiled it

    5 problems with that code:

    • 0x9999 is not a valid flag, if I recall correctly. Try 0x200, 0x500, 0x250, or something similar.
    • Your #orgs are too close together - first erase the script by replacing all #org with #eorg and compiling the original script, then replace all #eorg with #org again and use dynamic offsets instead.
    • You're missing an "end" after the setflag
    • He says "Please take it away" if you talk to him *after* you take it away.
    • No Lock/Faceplayer/Release


    The script to erase your current script:
    Code:
    #[B]eorg [/B]0x8800638
    '-----------------------------------
    checkflag 0x9999
    if 0x1 jump 0x88006F6 ' Equal To
    msgbox 0x8800657 ' I found this helples...
    callstd MSG_NORMAL ' Normal message
    addpokemon 0x4 0xB 0x0 0x0 0xF000000 0xC300C300
    setflag 0x9999
    
    #[B]eorg [/B]0x88006F6
    '-----------------------------------
    msgbox 0x88006FF ' Please take it away.
    callstd MSG_NORMAL ' Normal message
    end
    
    
    #[B]eorg [/B]0x8800657
    = take this Charmander.
    
    #[B]eorg [/B]0x88006FF
    = Please take it away.
    The script with dynamic offsets:
    Code:
    [B]#dynamic 0x800000[/B]
    #org [B]@start[/B]
    '-----------------------------------
    [B]lock
    faceplayer[/B]
    checkflag 0x251
    if true jump [B]@already-have[/B]
    msgbox [B]@take-this[/B]
    callstd MSG_NORMAL
    addpokemon CHARMANDER 0xB 0x0 0x0 [B]0x0000000 0x00000000[/B]
    setflag 0x251
    [B]release[/B]
    [B]end[/B]
    
    #org [B]@already-have[/B]
    '-----------------------------------
    msgbox [B]@take-it-away[/B]
    callstd MSG_NORMAL
    [B]release[/B]
    end
    
    
    #org [B]@take-this[/B]
    = take this Charmander.
    
    #org [B]@take-it-away[/B]
    = Please take it away.
    Notice that you can also use "CHARMANDER" in "addpokemon".

    It would be better if you checked if you had enough party space first, and changed the "Please take it away" message to "How's my CHARMANDER doing?" or something.
    If this is the first pokémon you get in the game, you have to add another setflag, "setflag FR_POKEMON" (if you're hacking fire red) or "setflag RS_POKEMON" (if you're hacking R/S). This tells the game that you are allowed to access the "Pokémon" item on the pause menu.
     
    Last edited:

    IIMarckus

    J946@5488AA97464
    402
    Posts
    16
    Years
    • Seen Feb 21, 2024
    They're pretty much strictly fixed, but here they are:
    Code:
    pksv -e ScriptFile.txt RomFile.gba        -- Debug compile
    pksv -r ScriptFile.txt RomFile.gba        -- Compile
    pksv RomFile.gba HexOffset OutputFile.txt -- Decompile
    It might be a good idea to make these display when run with no arguments (or --help). Also, the program segfaults when called with any fewer arguments—you might want to fix that. A -v flag for checking the version would be nice too.

    I do prefer the command‐line version, because I already have a text editor. :P

    You mentioned THUMB—are you planning support for GB‐Z80 in the future?
     

    score_under

    Inactive; Former ROM hack tool author, ❤️
    526
    Posts
    18
    Years
  • It might be a good idea to make these display when run with no arguments (or --help). Also, the program segfaults when called with any fewer arguments—you might want to fix that. A -v flag for checking the version would be nice too.

    I do prefer the command‐line version, because I already have a text editor. :P

    You mentioned THUMB—are you planning support for GB‐Z80 in the future?
    No, I was only planning to implement THUMB and ARM. Would it be desirable to implement GB-Z80?
    Oh, and the SVN source supports the ":label" syntax already ;)
     

    ProClifo

    The Village Pirate Cat
    86
    Posts
    15
    Years
  • I am a beginner to scripting but I just don't get it! Can someone make a video about everything about how to get the scrpit in the game? Please?
     
    2
    Posts
    14
    Years
    • Seen Aug 8, 2009
    Ive made a new script with this prog. and how can i give this script now in the pokemon game?
    Its the first time ive done any script :D
     

    score_under

    Inactive; Former ROM hack tool author, ❤️
    526
    Posts
    18
    Years
  • Ive made a new script with this prog. and how can i give this script now in the pokemon game?
    Its the first time ive done any script :D
    Make sure that it's either using a clean offset or a #dynamic offset, and then load it and the ROM into the script editor (you can do both via drag'n'drop) then press F9 inside PKSV.
     
    2
    Posts
    14
    Years
    • Seen Aug 8, 2009
    Thx
    How can i figure the flag number of my pokemon out?

    When i press F9 it shows this text:

    Opened file.
    #ORG
    -> 0x0
    CHECKFLAG
    -> 0x800
    IF
    Unknown value in IF (Value must be integer)

    Whats wrong with my script?
    I copied a script from this forum to check if my script is wrong and it also shows this text
     
    Last edited:
    Status
    Not open for further replies.
    Back
    Top