|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
Macros | |
| #define | __NOLIBBASE__ |
| #define | BUFSIZE 2048 |
| #define | DOSBase dosbase /* for proto/dos.h */ |
| #define | ID_BODY 0x424f4459 /* "BODY" */ |
Functions | |
| void | iffopen (void) |
| void | iffclose (void) |
| void | iffbyte (void) |
| void | iffword (void) |
| void | ifflong (void) |
| void | ifffind (void) |
| void | iffskip (void) |
| void | iffread (void) |
| static ULONG | codeinit (struct DosLibrary *dos) |
| The library's init: remember dos.library, allocate the buffer. | |
| static void | readbuff (void) |
| static ULONG | iffopen_c (ULONG value, const char *name) |
| iffopen (+1): open a file for reading and fill the buffer. | |
| static void | iffclose_c (void) |
| iffclose (+2): close the file. | |
| static LONG | getbyte (void) |
| static ULONG | byte_ (ULONG value) |
| static ULONG | word_ (ULONG value) |
| static ULONG | long_ (ULONG value) |
| static ULONG | iffbyte_c (ULONG value) |
| iffbyte (+3): the next byte of the file. | |
| static ULONG | iffword_c (ULONG value) |
| iffword (+4): the next word (big endian), two iffbytes. | |
| static ULONG | ifflong_c (ULONG value) |
| ifflong (+5): the next long (big endian), two iffwords. | |
| static ULONG | ifffind_c (ULONG id) |
| ifffind (+6): find a chunk. | |
| static ULONG | iffskip_c (ULONG n) |
| iffskip (+7): skip bytes (the source says "long words"). | |
| static ULONG | iffread_c (ULONG n, UBYTE *dst) |
| iffread (+8): copy bytes of the file to memory. | |
Variables | |
| static UBYTE * | iffbuff |
| static UWORD | charat |
| static UWORD | charsleft |
| static BPTR | filehand |
| static struct DosLibrary * | dosbase |
| UWORD | iff_fail |
| UBYTE * | iff_a0 |
| #define __NOLIBBASE__ |
| #define BUFSIZE 2048 |
| #define ID_BODY 0x424f4459 /* "BODY" */ |
|
static |
|
static |
The library's init: remember dos.library, allocate the buffer.
The 2048 byte buffer comes from memlib's globalloc (MEMF_PUBLIC).
| dos | a0: dos.library (!libs doslib,la0) |
|
static |
| void iffbyte | ( | void | ) |
|
static |
iffbyte (+3): the next byte of the file.
Refills the buffer when it is used up. CCR: Z = ok. Fixed (#177): a read error is the end of the data (the original took the buffer as 65535 bytes long).
| value | d0: the caller's d0, only its low byte is replaced |
| void iffclose | ( | void | ) |
|
static |
iffclose (+2): close the file.
Fixed (#186): only a file that is open (the handle is not 0), and the handle is cleared; the original called dos Close also with 0 (after a failed iffopen, e.g. ILBMInfo of a missing file).
| void ifffind | ( | void | ) |
|
static |
ifffind (+6): find a chunk.
Reads up to and including the id, then the chunk length (ifflong). CCR: Z = found. BUG(orig) (#178), won't fix (a limit, see the head comment): it gives up at a "BODY" id (unless it is looking for BODY) and reads ahead byte by byte (the ids need not be aligned).
| id | d0: the chunk id |
| void ifflong | ( | void | ) |
|
static |
ifflong (+5): the next long (big endian), two iffwords.
CCR: Z = ok.
| value | d0: the caller's d0 |
| void iffopen | ( | void | ) |
|
static |
| void iffread | ( | void | ) |
|
static |
iffread (+8): copy bytes of the file to memory.
From the buffer; when the buffer position reaches 2048 the rest is read with one dos Read directly to a0 (a0 not advanced; the buffer is refilled by the next iffbyte). When the data ends inside the buffer, d0 = the bytes still wanted and a0 = the end. Not a bug: all callers ignore d0/a0 afterwards. Fixed (#179): d0 = 0 copies nothing (d0 = 0, a0 unchanged); the original counted down from 2^32.
| n | d0: the number of bytes |
| dst | a0: the destination; a0 afterwards: see above |
| void iffskip | ( | void | ) |
|
static |
iffskip (+7): skip bytes (the source says "long words").
CCR: Z when all bytes were skipped, not Z at the end of the data. Fixed (#179): d0 = 0 skips nothing (Z, d0 = 0); the original counted down from 2^32.
| n | d0: the number of bytes |
| void iffword | ( | void | ) |
|
static |
iffword (+4): the next word (big endian), two iffbytes.
CCR: Z = ok.
| value | d0: the caller's d0, only its low word is replaced |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| UBYTE* iff_a0 |
| UWORD iff_fail |
|
static |