Writing PASM quest scripts in a text editor.

Discussion in 'Guides' started by Cookie, Feb 3, 2018.

  1. Cookie

    Cookie Gotta eat 'em all! Event Team

    Writing scripts in qedit can be annoying in 2018 (imo), so I wanted to make that a bit easier for me and hopefully for some of you guys, too.

    What I did:
    1. Syntax highlighting in Notepad++.
    2. Parser and syntax checker in python, that will "convert" scripts into an import friendly format for qedit.
    Both needed files can be found here (quickly hacked together html):

    #1 Syntax highlighting in Notepad++:
    The result for me looks something like this.

    What you need to do:
    1. open Notepad++
    2. click language > define your language
    3. click on the import button and select the pasm.xml file from pasm_notepadpp.zip
    Note that I can't set colors depending on your current Notepad++ style. So if the colors don't look right for you, you have to change them manually. If you look at the user defined language dialog, click on the Keywords List tab. You'll see 4 groups, 1st group are version1 opcodes, 2nd group are version2 opcodes, 3rd group are version3 (GC) opcodes and 4th group are version4 (BB) opcodes. If you want to define your own colors, click on the Styler button. Select a color you like. If you don't want a background color (this gets reset to white), you have to RIGHT click on the background color to make it transparent.
    If you want to change the color of comments, click on the Comment & Number tab. If you want to change the color of strings, click on the Operators & Delimiter tab. Delimiter 1 style are single quote strings, Delimiter 2 style are double quote strings.

    One important note regarding strings. To have propper syntax highlighting for strings, you need to escape the character that is used for limiting the string.
    'You've earned 1000 Meseta.'
    This will break the syntax highlighting because of the single quote character after "You". Change it to...
    'You\'ve earned 1000 Meseta.'
    Don't worry, if you use my python syntax checker, the escape backslash will be removed.

    #2 Parsing and syntax checking in Python:
    You need to have Python installed on your system. To use the script, simply type in command line:
    python pasm.py [options] <pasm_file>

    -q This will remove all the comments, take care of the correct formatting for qedit and create a new pasm file with a 'qe_' prefix.
    -f This will add any missing function labels with a simple ret statement. (Like: 800: ret)

    Note: Only single line comments starting with '//' are supported for now. (// my comment...)

    Some syntax errors that get detected:
    • misspelled opcodes (if you use syntax highlighting, you'll already see when there's something wrong)
    • invalid opcode arguments
    • registers that don't exist (R256...)
    • warns about missing function labels in any jump statement (this includes switch cases like 2:100:101)
    • invalid switch case definitions like 3:100:101 (needs 3 elements, not just 2)
    • some more...

    As I'm still new to qedit and pasm, it's possible that some stuff isn't working properly. Please let me know if you discover any bugs or anything qedit can't handle after the import.
    Last edited: Feb 3, 2018
    Matt, MagicLuthee, Mad and 3 others like this.
  2. Lemon

    Lemon Quest Creator and Tool Developer

    Guildcard 2:
    This looks very useful, I'll have to check it out. Thanks for your hard work.
    Harborer of Hope likes this.
  3. Lemon

    Lemon Quest Creator and Tool Developer

    Guildcard 2:
    Here's a syntax file for Sublime Text. I'm not on my home computer, so this is a few versions old. I'll update with my most recent tomorrow.

    Attached Files:

  4. Raohmaru

    Raohmaru Spaceship Engineer

    Great work @Cookie! I'm a huge fan of Notepad++ and your Syntax highlighting and the parsed are very handy.

    I have done some small improvemets like code folding, different color for registers, created an autocompletion file with the exisiting OP codes, and also I have cloned the pasm.py file to support Python 2.7.

    As you can see I have created a git repository to keep track of the changes. I stated in the readme that you have the full credit for the original version of the code. If you disagree with it or have a different opinion on how to handle the code, please tell me.
    MagicLuthee likes this.
  5. Raohmaru

    Raohmaru Spaceship Engineer

    MagicLuthee likes this.
  6. Raohmaru

    Raohmaru Spaceship Engineer

    New Update! v.1.2.0
    While working on my first quest, I found that the parser could be enhanced by adding new features that I was missing to the PSO ASM language. (This features are seamessly "transpiled" by the parser into the format that accepts QEdit.)

    New features of the Python parser and PASM v2:
    • Added new value type float (needed for OP codes particle2, fleti, faddi, fsubi, fmuli, fdivi, scroll_text).
    • Hexadecimal values can be prefixed with 0x (unless the values of HEX: OP code).
    • Negative integers are transformed into hexadecimal values.
    • Variables.
    • Include PASM source code from another file into the current source file.
    • Macros (sequence of OP codes referenced by a name that work like functions on programming languages).
    Now it is possible to write reusable code and to split your code into several files!

    $R_wait R70
    $L_wait 200
    %macro  wait(frames)
            leti $R_wait, frames
            call $L_wait
    0:      set_episode 0x0
            BB_Map_Designate 00, 0000, 00, 00
            jmp 300
            subi $R_wait, 1
            jmpi_> $R_wait, 0, $L_wait
    300:    wait(60)  // Wait 2s
    0:      set_episode 00000000
            BB_Map_Designate 00, 0000, 00, 00
            jmp 300
    200:    sync
            subi R70, 00000001
            jmpi_> R70, 00000000, 200
    300:    leti R70, 0000003C
            call 200

    Download link:


    Feel free to add any comment or issue here or in the GitHub repository:
    Last edited: May 28, 2019

Share This Page