Archive for September, 2008

Status on the Math Library (Part 1)

I just recently discovered that some of my Math Library macros only use two variables, and that my python script only works with macros that have three variables. I’m blaming my previous bount of annoyingly mindless assignments for not realizing this small problem.

I’ve currently rewritten the WLA-DX macro generator section of the python script to compensate. All that is left to do is update the parser to acept this change and to work on completing the Index Register handler.

I’ve also decided to add some more math macros to the math library, the new list is as thus:

  • Addition
  • Subtraction
  • Multiplication
  • Division
  • Sine
  • Cosine
  • Square Root
  • Square
  • Absolute value of a variable
  • Loading a fixed value into a variable.
  • Converting one variable type to another.

If anyone has any suggestions as to what other kind of math macros I should add to the list, please let me know.

I believe that I will have this math library completed and fully tested in a week. From there I’ll start thinking about working on a Variable Width Font Library or something.

Comments

Creation of a SNES Mathematics library

I’ve finally found some free time to once again work on my SNES Developments.

This week I am working on a simple SNES Mathematics library. This relies heavily on WLA-DX macros and .IF statements to allow me (and others who use it) to accurately preform the following operations:

  • Addition
  • Subtraction
  • Multiplication
  • Division
  • Sine
  • Cosine
  • Square Root

This in itself is not interesting at all. The most interesting thing about this library is it not only simple to use, it also allows us to mix and match the following variables types in our expressions:

  • byte (8 bit unsigned integer)
  • sbyte (8 bit signed integer)
  • word (16 bit unsigned integer)
  • sword (16 bit signed integer)
  • long (32 bit unsigned integer)
  • slong (32 bit signed integer)
  • frac (fx8.16 unsigned fixed point integer)
  • sfrac (fx8.16 signed fixed point integer)
  • longfrac (fx16.32 unsigned fixed point integer)
  • slongfrac (fx16.32 signed fixed point integer)

In my attempts to make the syntax of this library as simple as possible, I played about with WLA-DX and it’s macro parsing. This is what I have come up with:

multiply sword a, byte b, sword c

This code would take the signed word a and multiply it by the unsigned byte b, storing it in the signed word c.

I’ve also begun to add support for the X/Y index registers. Allowing such code as:

divide word a, X, word b,X, word c

Because there are so many different ways to arrange the mathematical expressions, I will be using python to simplify the task for me. At the moment, I have a simple python script that reads a formatted page of 65816 assembly and generates the necessary WLA-DX macro expressions. I’m slowly adding in support for this script to automatically handle the X/Y index registers for me, so I do not have to type all that code 27 different types (that’s for every combination of X, Y and no Index offset for each of the three variables used).

Even with the help of python, there is still a quite a bit of code to write. Once I’ve got the logistics of the math library done, the rest should be simple.

Comments (3)