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):
    http://koalacuddleparty.com/pso/

    #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.
    Example:
    '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>

    Options:
    -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:
    42000530
    Guildcard 2:
    42024306
    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:
    42000530
    Guildcard 2:
    42024306
    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

    Location:
    Spain
    Guildcard:
    42043089
    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.
    https://github.com/raohmaru/psoasm-npp-udl.

    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

    Location:
    Spain
    Guildcard:
    42043089
    MagicLuthee likes this.

Share This Page