Macros v. Python
SkoolKit 8.5 has been released. To get a copy, please head over to the download page, the Python Package Index, the Ubuntu PPA, or the Fedora copr repo.
As if the #PLOT
macro (new in 8.3) weren’t enough, this release introduces
the second and third new image macros to the 8.x series: #COPY
and #OVER
.
The first of these (#COPY
) enables you to copy all or part of an existing
frame into a new frame, and change the scale, mask type and cropping
specification (if desired) in the process. The second (#OVER
) enables you to
superimpose one frame (let’s call it the foreground) over another (the
background, if you will), using the foreground’s mask or some other custom
scheme for combining the graphic bytes and attributes of each frame.
So what do #COPY
and #OVER
make possible that was either very difficult or
impossible before? One example is composing complex gameplay images consisting
of sprites drawn on a background without having to write a SkoolKit extension
module first. (Not that I’d want to discourage anyone from writing Python,
but I understand that it’s not everyone’s bag.) Construct one big frame of the
entire gameplay background, and one frame for each sprite in the game. Then use
#COPY
to copy the desired portion of that background to a new frame, and
#OVER
to sprinkle sprites onto that new frame. Finally, use the good old
#UDGARRAY*
macro to create an image file from the result. Bingo, as the
saying goes.
Now, while you’re doing that, you might consider using the new #DEF
macro to
define custom macros that will simplify some of the repeated #COPYing
and
#OVERing
. Why the new #DEF
instead of the old #DEFINE
? Well, #DEF
has a
more natural syntax and can create macros with optional integer and string
parameters. And you can name the parameters to boot. In short, #DEF
is what
#DEFINE
should have been from the start. For example, whereas you might
define a #MAX
macro using #DEFINE
like this:
#DEFINE2(MAX,#IF({0}>{1})({0},{1}))
the same can be accomplished using #DEF
like this:
#DEF(#MAX(a,b) #IF($a>$b)($a,$b))
If you’re not sold on #DEF
yet by this particular example, think about how
you’d define a new macro that has 10 arguments instead of just two. Then
perhaps you’ll find that keeping track of them all by name instead of their
position in a list is quite a bit easier and makes the macro definition much
more readable.
At this point you’re probably sick of hearing about macros, so let’s talk about
sna2skool.py
instead. This workhorse of the SkoolKit suite now has the
ability to disassemble an instruction that crosses the 64K boundary (i.e. has
one of its bytes at address 65535 and the next one at address 0). Just set the
new Wrap
configuration parameter to 1
, and off you go. Should be a boon to
those of you who particularly enjoy disassembling custom interrupt routines.
While all that is perhaps the most interesting new stuff in 8.5, it is by no means everything. For details on the rest, I recommend consulting the changelog. There you will find details on such things as how to change the default snapshot disassembly start address (traditionally 16384), and how to add to the list of instructions that SkoolKit regards as identifying entry points (traditionally just calls, jumps and RSTs). After that, grab a copy of 8.5 and see just how complex an image you can compose without resorting to Python.