Git Product home page Git Product logo

vclpp's Introduction

VCLPP

VCLPP, a minimal preprocessor for the PS2 Vector Command Line (VCL) tool, written in C++11.

VCL uses GNU GASP by default for source file preprocessing before running its instruction scheduler. Unfortunately, GASP has become deprecated and is increasingly harder to find a good build for it, specially on OSX, plus, its preprocessor syntax is peculiar and not familiar to C programmers.

Due to these issues, I wrote this tiny and very ad hoc preprocessor for Vector Unit assembly code that is compatible with the input expected by the VCL. I use it in my PS2 port of Quake II.

The supported syntax is:

Define constants

#define ANSWER 42
#define FOO "bar"

NOTE: Only one level of substitution is performed, so the "value" of a #define must not reference other defines!

Function-like macros

#macro MatrixMultiplyVertex: vertex_result, matrix, vertex
    mul  acc,           matrix[0], vertex[x]
    madd acc,           matrix[1], vertex[y]
    madd acc,           matrix[2], vertex[z]
    madd vertex_result, matrix[3], vertex[w]
#endmacro

And in the invocation, the expected syntax is:

MatrixMultiplyVertex{ Vert, fTransform, Vert }

Include files

You can include other files containing defines and macros anywhere inside a source file. There's also no limit for the number of #includes in a source file.

#include "my_definitions.i"

NOTE: Recursive includes are not supported, so files that you #include in a source file cannot themselves include other files!

VCLPP Usage

Usage:
 $ vclpp input-file [output-file] [options]
 Applies custom preprocessing to a source file prior to running VCL.
 This preprocessor supports C-style #define constants and custom #macro directives.
 If no output filename is provided the input name is used but the extension is replaced with '.vsm'
 Options are:
  -h, --help     Prints this message and exits.
  -j, --vcljunk  Adds the standard VCL prologue/epilogue junk to the output.
  -x, --fixcexpr Tries to resolve constant expressions involving literals, like 1+2.

Providing the -j or --vcljunk flag will cause the tool to add the frequently used VCL prologue/epilogue boilerplate for enter/exit sections, so you don't have to repeat that in every source file. Output example:

.init_vf_all
.init_vi_all
.syntax new
.vu

--enter
--endenter

    ; Your VU program here

--exit
--endexit

License

This project's source code is released under the MIT License.

vclpp's People

Contributors

glampert avatar zennoe avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.