swi #0x18

The runtime debugging library is accessed via a special opcode sequence which is very unlikely to occur in normal code, and will run on hardware with no side-effects.

There are a number of different functions.


ConsolePrint (r0 = 0x00)

Prototypes:

void dprint(char * string); void dprintf(char * string, params...);

0x00: Write to the console

0x01: Beep

0x02: Pause CPU

0x03: Associate profile ID

0x04: Entering profile ID

0x05: Exiting profile ID

0x08: Open file

0x09: Close file

0x0A: Seek in file

0x0B: Write to file (not currently supported)

0x0C: Read from file

0x0D: Blinkenlights


SoftReset (swi #0x00)


RegisterRamReset (swi #0x01)


Halt (swi #0x02)


Stop (swi #0x03)


IntrWait (swi #0x04)

Enters low power mode until a specified interrupt occurs.


VBlankIntrWait (swi #0x05)

Enters low power mode until VBlank occurs.


Div (swi #0x06)

Parameters:

Results:


DivArm (swi #0x07)


Sqrt (swi #0x08)

Prototype:

uint32 Sqrt(uint32 value)

Parameters:

Result:


ArcTan (swi #0x09)

Prototype:

uint32 ArcTan(uint32 value)

Parameters:

Result:


ArcTan2 (swi #0x0A)


CPUSet (swi #0x0B)

Prototype:

void CPUSet(void * source, void * dest, uint32 control)

Parameters:

bit26 = 32 or 16 bit transfer bits 15 - 0 = number of transfers


CPUFastSet (swi #0x0C)

Prototype:

void CPUFastSet(void * source, void * dest, uint32 control)

Parameters:


BgAffineSet (swi #0x0E)

Prototype

void BgAffineSet(PBgAffineParams params, PBgAffineResults result, int32 count)

Parameters

Structures

struct {
  int32 cx;         // 20.8 x center of rotation on the texture
  int32 cy;         // 20.8 y center of rotation on the texture
  int16 screen_cx;  // center of rotation on the display
  int16 screen_cy;  // center of rotation on the display
  int16 scale_x;    // 8.8 x scale factor
  int16 scale_y;    // 8.8 y scale factor
  uint16 theta;     // rotation value (0-255)
} *PBgAffineParams, TBgAffineParams;


struct {
  int16 hdx;  // 8.8 horizontal textel per horizontal pixel delta
  int16 vdx;  // 8.8 vertical textel per horizontal pixel delta
  int16 hdy;  // 8.8 horizontal textel per vertical pixel delta
  int16 vdy;  // 8.8 vertical textel per vertical pixel delta
  int32 x;    // 20.8 x initial texture position
  int32 y;    // 20.8 y initial texture position
} *PBgAffineResults, TBgAffineResults;


ObjAffineSet (swi #0x0F)


BitUnPack (swi #0x10)


DecompressLZSStoWRAM (swi #0x11)

Input: r0 = source address r1 = dest address


DecompressLZSStoVRAM (swi #0x12)

Input: r0 = source address r1 = dest address

The window is 4096 bytes, the minimum entry length is 3 bytes and the maximum entry length is 18 bytes.


DecompressHuffman (swi #0x13)

Prototype:

void DecompressHuffman(void * source, void * dest)

Parameters:


DecompressRLEtoWRAM (swi #0x14)

Prototype:

void DecompressRLEtoWRAM(void * source, void * dest)

Parameters:


DecompressRLEtoVRAM (swi #0x15)

Prototype:

void DecompressRLEtovRAM(void * source, void * dest)

Parameters:

Notes: This version buffers decompressed bytes and writes them in halfwords since VRAM is not single-byte addressable.


Diff8bitUnFilterWRAM (swi #0x16)


Diff8bitUnFilterVRAM (swi #0x17)


Diff16bitUnFilter (swi #0x18)

These are not currently implemented in Mappy VM

SoundBiasChange (swi #0x19)

SoundDriverInit (swi #0x1A)

SoundDriverMode (swi #0x1B)

SoundDriverMain (swi #0x1C)

SoundDriverVSync (swi #0x1D)

SoundChannelClear (swi #0x1E)

MIDIKey2Freq (swi #0x1F)

MusicPlayerOpen (swi #0x20)

MusicPlayerStart (swi #0x21)

MusicPlayerStop (swi #0x22)

MusicPlayerContinue (swi #0x23)

MusicPlayerFadeOut (swi #0x24)

MultiBoot (swi #0x25)

SoundDriverVSyncOff (swi #0x28)

SoundDriverVSyncOn (swi #0x29)

VBADPrint (swi #0xFF) Warning: Will not work on hardware.