|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
Data Structures | |
| struct | droplist |
| struct | killlist |
| struct | snowfield |
| struct | randomtable |
| struct | side |
Macros | |
| #define | END 0xabcd /* the end of a list */ |
| #define | ASLW(d, n) |
| #define | FULL(entries, size) |
| #define | DROP(a) |
| #define | KILL(a) |
| #define | PLANE(bm, n) |
Functions | |
| void | _AsmDoSnow (void) |
| LDoSnow listnum,randomtable: one step of the snow. | |
| void | _InitSnowDrop (void) |
| void | _KillPoint (void) |
| void | _DoKillList (void) |
| void | risnowlib_libinit (void) |
| void | risnowlib_libfinit (void) |
| void | initchk (void) |
| void | fieldchk (void) |
| void | killchk (void) |
| static struct snowfield * | entry (ULONG n) |
| static int | btst (const UBYTE *p, UWORD idx, UWORD bit) |
| static void | bclr (UBYTE *p, UWORD idx, UWORD bit) |
| static void | bset (UBYTE *p, UWORD idx, UWORD bit) |
| static void | libinit_c (void) |
| init: clears the list table, as at the first load. | |
| static void | nothing_c (void) |
| finit: RTS (nothing to do). | |
| static UBYTE * | drophead (UBYTE *p, ULONG size, ULONG bm, ULONG bpsize) |
| static UBYTE * | killhead (UBYTE *p, ULONG size) |
| static ULONG | initsnowdrop_c (ULONG n, ULONG num, ULONG bpsize, ULONG bm) |
| InitSnowDrop(listnum,numpoints,bitmap,bp_size): the four lists of a snow field. | |
| static int | unpause (UBYTE *plane1, const UBYTE *plane2, UWORD at, UWORD bit, UWORD **drop, const UWORD *full) |
| static ULONG | dokilllist_c (ULONG n) |
| LDoSnowActivate(listnum): stopped snow next to removed pixels falls again. | |
| static BB_BOOL | killpoint_c (ULONG n, ULONG x, ULONG y) |
| KillPoint(listnum,x,y): removes a "blue" pixel (plane 2). | |
| static void | listchk (ULONG n) |
| static void | initdonechk (ULONG n) |
| static void | initchk_c (ULONG n) |
| The error check of InitSnowDrop (debugger only). | |
| static void | fieldchk_c (ULONG n) |
| The error check of LDoSnow and LDoSnowActivate (debugger only). | |
| static void | killchk_c (ULONG n, ULONG x, ULONG y) |
| The error check of KillPoint (debugger only). | |
Variables | |
| static struct snowfield | lp [4] |
| static const struct side | lookup [2][8][2] |
| #define FULL | ( | entries, | |
| size ) |
| void _AsmDoSnow | ( | void | ) |
LDoSnow listnum,randomtable: one step of the snow.
Reads the newer drop list and writes the other (they swap): a flake moves one row down if the pixel there is clear, else to the side (left or right first, alternating) where the pixel and the one below are clear, else it stays; one that cannot move with plane 1 set below it stops (set in plane 1, dropped). A flake below bp_size (compared as a signed word) is removed. Then a new flake from the random table (the index steps by 2 modulo 1024). COLOR00 is red while it runs ($F00, then 0: a debug flash).
An assembler entry, the original's loop (registers as there: a1 plane 0, a4 plane 1, a0 the list read, a2 the list written, a5 the random table, d7 bp_size, d6 left or right first, a3 the side table): as C (even with the bit operations as inline assembler) it took 4.2 and 1.7 times the original's cycles per call (perf bsnow). Keeps d1/a0/a1 and a4-a6 (the original a4-a6, the C thunk d1/a0/a1); changes d0, d2-d7, a2, a3.
The list number: fieldchk (fixed #913). Fixed (#914): no new flake when the list written is full (a6: its FULL place; the original had no bound). Fixed (#910): the bit of a new flake is taken modulo 8 (a bit above 7 read behind the side tables).
| void _DoKillList | ( | void | ) |
| void _InitSnowDrop | ( | void | ) |
| void _KillPoint | ( | void | ) |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
LDoSnowActivate(listnum): stopped snow next to removed pixels falls again.
For each pixel of the kill list (the two kill lists swap): stopped snow (plane 1 set, plane 2 clear) at the two sides below and at the pixel is cleared in plane 1 and added to the newer drop list; the pixel above goes into the other kill list. Checking plane 2 at the killed pixel again is redundant (no defect). The bits of the entries are 0-7 (fixed #910: LDoSnow masks the random table's). The list number: fieldchk (fixed #913). Fixed (#909): the drop list's last is updated (the original's stayed, so the next call overwrote the entries). Fixed (#914): stopped snow stays when the drop list is full (the original had no bound). Fixed (#908): before the first LDoSnow the drop list's last is its first entry (InitSnowDrop sets it; the original's 0 wrote at address 0).
| n | d0: the list number |
|
static |
|
static |
| void fieldchk | ( | void | ) |
|
static |
The error check of LDoSnow and LDoSnowActivate (debugger only).
Fixed (#913), not in the original: the list number was not checked (lists and bitmap read behind the table); with it a list number without InitSnowDrop, whose entry is 0 (the lists and the bitmap read at address 0). The release code is unchanged (D-005).
Errors: "Snow list number must be 0 to 3", "Snow list needs InitSnowDrop".
| n | d0: the list number |
| void initchk | ( | void | ) |
|
static |
The error check of InitSnowDrop (debugger only).
Fixed (#913), not in the original (risnowlib had no error check area): the list number indexes the table of 4 numbers with ASL.w #4 without a check, so 4 and up (and negative numbers, a non-zero upper word) wrote the four list pointers behind or before the table. The release code is unchanged (an invalid argument, D-005).
Errors: "Snow list number must be 0 to 3".
| n | d0: the list number |
|
static |
|
static |
InitSnowDrop(listnum,numpoints,bitmap,bp_size): the four lists of a snow field.
One block (memlib globalloc, MEMF_CLEAR; not checked: memlib raises Out of Memory) for drop lists A and B and kill lists 1 and 2, each numpoints*16 bytes, all empty. Fixed (#911): the block the number had is freed first (memlib globfree; the original lost it). Fixed (#912): the size is a long (the original's ASL.w #2 made the block too small from numpoints 1024 on). Fixed (#908): the drop lists' last is set (the original left it 0).
| n | d0: the list number (0-3) |
| num | d1: the number of points |
| bpsize | d3: the end offset in the plane (bp_size) |
| bm | a3: the bitmap object (!libs bitmaplib,ia3|pd2) |
| void killchk | ( | void | ) |
|
static |
The error check of KillPoint (debugger only).
Fixed (#913), not in the original: as fieldchk_c, and the pixel: x outside the 320 pixels of a row (the library assumes 40 bytes per row) or y outside the rows of the field's bitmap cleared bits and appended kill entries outside the planes. The release code is unchanged (D-005).
Errors: "Snow list number must be 0 to 3", "Snow list needs InitSnowDrop", "KillPoint outside the bitmap".
|
static |
|
static |
KillPoint(listnum,x,y): removes a "blue" pixel (plane 2).
The pixel is cleared in all three planes and the pixel above it added to the kill list. The list number and the pixel: killchk (fixed #913).
|
static |
init: clears the list table, as at the first load.
Fixed (#1135): the original's init was an RTS; in a second run of a program from the editor (the library stays loaded, memlib has freed the blocks) the table still pointed to the first run's lists.
|
static |
|
static |
finit: RTS (nothing to do).
| void risnowlib_libfinit | ( | void | ) |
| void risnowlib_libinit | ( | void | ) |
|
static |
|
static |
|
static |