From 2154a1a7e37ecd7165a058147011a525812ab7d6 Mon Sep 17 00:00:00 2001 From: Sean Date: Sun, 19 Aug 2018 17:24:54 -0700 Subject: [PATCH] initial import --- .gitignore | 7 + 2mg.c | 312 ++++++++++ 65816.h | 374 ++++++++++++ LICENSE | 24 + Makefile | 19 + README.md | 175 ++++++ addresses.h | 412 +++++++++++++ disasm.c | 358 +++++++++++ disasm.h | 10 + handle.h | 41 ++ map.c | 142 +++++ map.h | 33 + omf.c | 568 ++++++++++++++++++ parser.c | 66 ++ parser.h | 22 + pascal/ace.p | 42 ++ pascal/adb.p | 102 ++++ pascal/applesharefst.p | 166 ++++++ pascal/controls.p | 274 +++++++++ pascal/ctiutils.p | 38 ++ pascal/desk.p | 67 +++ pascal/dialogs.p | 205 +++++++ pascal/events.p | 133 +++++ pascal/fonts.p | 103 ++++ pascal/fst.p | 138 +++++ pascal/gsos.p | 498 ++++++++++++++++ pascal/intmath.p | 111 ++++ pascal/lineedit.p | 95 +++ pascal/lists.p | 106 ++++ pascal/loader.p | 87 +++ pascal/locator.p | 87 +++ pascal/memory.p | 80 +++ pascal/menus.p | 142 +++++ pascal/midi.p | 119 ++++ pascal/misctool.p | 367 ++++++++++++ pascal/noteseq.p | 95 +++ pascal/notesyn.p | 87 +++ pascal/print.p | 165 +++++ pascal/prodos16.p | 211 +++++++ pascal/qdaux.p | 119 ++++ pascal/quickdraw.p | 510 ++++++++++++++++ pascal/resources.p | 184 ++++++ pascal/sane.p | 222 +++++++ pascal/scheduler.p | 22 + pascal/scrap.p | 40 ++ pascal/sound.p | 115 ++++ pascal/stdfile.p | 154 +++++ pascal/textedit.p | 343 +++++++++++ pascal/types.p | 104 ++++ pascal/video.p | 119 ++++ pascal/windows.p | 301 ++++++++++ prodos16.h | 144 +++++ prodos8.h | 56 ++ regs.c | 120 ++++ scan.c | 185 ++++++ scan.h | 11 + smartport.h | 47 ++ tools.h | 1290 ++++++++++++++++++++++++++++++++++++++++ 58 files changed, 10167 insertions(+) create mode 100644 .gitignore create mode 100644 2mg.c create mode 100644 65816.h create mode 100644 LICENSE create mode 100644 Makefile create mode 100755 README.md create mode 100644 addresses.h create mode 100644 disasm.c create mode 100644 disasm.h create mode 100644 handle.h create mode 100644 map.c create mode 100644 map.h create mode 100644 omf.c create mode 100644 parser.c create mode 100644 parser.h create mode 100755 pascal/ace.p create mode 100755 pascal/adb.p create mode 100755 pascal/applesharefst.p create mode 100755 pascal/controls.p create mode 100755 pascal/ctiutils.p create mode 100755 pascal/desk.p create mode 100755 pascal/dialogs.p create mode 100755 pascal/events.p create mode 100755 pascal/fonts.p create mode 100755 pascal/fst.p create mode 100755 pascal/gsos.p create mode 100755 pascal/intmath.p create mode 100755 pascal/lineedit.p create mode 100755 pascal/lists.p create mode 100755 pascal/loader.p create mode 100755 pascal/locator.p create mode 100755 pascal/memory.p create mode 100755 pascal/menus.p create mode 100755 pascal/midi.p create mode 100755 pascal/misctool.p create mode 100755 pascal/noteseq.p create mode 100755 pascal/notesyn.p create mode 100755 pascal/print.p create mode 100644 pascal/prodos16.p create mode 100755 pascal/qdaux.p create mode 100755 pascal/quickdraw.p create mode 100755 pascal/resources.p create mode 100755 pascal/sane.p create mode 100755 pascal/scheduler.p create mode 100755 pascal/scrap.p create mode 100755 pascal/sound.p create mode 100755 pascal/stdfile.p create mode 100755 pascal/textedit.p create mode 100755 pascal/types.p create mode 100755 pascal/video.p create mode 100755 pascal/windows.p create mode 100644 prodos16.h create mode 100644 prodos8.h create mode 100644 regs.c create mode 100644 scan.c create mode 100644 scan.h create mode 100644 smartport.h create mode 100644 tools.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d650c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.o +*.swp +*.map +seg* +2mg +omf +regs diff --git a/2mg.c b/2mg.c new file mode 100644 index 0000000..3938d01 --- /dev/null +++ b/2mg.c @@ -0,0 +1,312 @@ +/** + * @copyright 2018 Sean Kasun + * Extracts 2mg and other prodos disk images into a directory structure + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "handle.h" + +static void doDirectory(uint16_t key, uint8_t *disk, uint32_t disklen, + int depth); +static void doEntry(uint8_t *entry, uint8_t *disk, uint32_t disklen, + int depth); +static void doFile(uint16_t key, uint32_t len, char *name, uint8_t *disk, + uint32_t disklen, int type); +static void doGSOS(uint16_t key, char *name, uint8_t *disk, uint32_t disklen, + int depth); + +const char *argp_program_version = "2mg 0.2"; +const char *argp_program_bug_address = "sean@seancode.com"; +static char doc[] = "Extract ProDOS disk images"; +static char args_doc[] = "DISKIMAGE"; +static struct argp_option options[] = { + {"list", 'l', 0, 0, "List files"}, + { 0 } +}; + +struct arguments { + char *diskimage; + bool list; +}; + +static error_t parse_opt(int key, char *arg, struct argp_state *state) { + struct arguments *arguments = state->input; + switch (key) { + case 'l': + arguments->list = true; + break; + case ARGP_KEY_ARG: + if (state->arg_num >= 1) { + argp_usage(state); + } + arguments->diskimage = arg; + break; + case ARGP_KEY_END: + if (state->arg_num < 1) { + argp_usage(state); + } + break; + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + +static struct argp argp = { options, parse_opt, args_doc, doc }; + +int main(int argc, char **argv) { + struct arguments arguments; + arguments.list = false; + + argp_parse(&argp, argc, argv, 0, 0, &arguments); + + FILE *f = fopen(arguments.diskimage, "rb"); + if (!f) { + fprintf(stderr, "Failed to open '%s'\n", arguments.diskimage); + return -1; + } + fseek(f, 0, SEEK_END); + size_t len = ftell(f); + fseek(f, 0, SEEK_SET); + if (len < 64) { + fprintf(stderr, "%s is not a valid disk image\n", argv[1]); + fclose(f); + return -1; + } + + uint8_t *header = malloc(64); + fread(header, 64, 1, f); + + uint32_t disklen = len; + uint32_t diskofs = 0; + + if (r4(header) == fourcc("2IMG")) { + if (r32(header + 0xc) != 1) { + fprintf(stderr, "Not a ProDOS disk image\n"); + fclose(f); + return -1; + } + disklen = r32(header + 0x14) * 512; + diskofs = r32(header + 0x18); + } + free(header); + + fseek(f, diskofs, SEEK_SET); + uint8_t *disk = malloc(disklen); + fread(disk, disklen, 1, f); + fclose(f); + + doDirectory(2, disk, disklen, arguments.list ? 0 : -1); + free(disk); + return 0; +} + +static void readFilename(uint8_t *filename, uint8_t length, char *outname) { + for (int i = 0; i < length; i++) { + char ch = filename[i]; + if (isalnum(ch) || ch == '_' || ch == '.' || ch == ' ') { + *outname++ = ch; + } else { + *outname++ = 'x'; + char hi = ch >> 4; + char lo = ch & 0xf; + if (hi > 9) { + *outname++ = 'a' + (hi - 10); + } else { + *outname++ = '0' + hi; + } + if (lo > 9) { + *outname++ = '0' + (lo - 10); + } else { + *outname++ = '0' + lo; + } + } + } + *outname = 0; +} + +static void indent(int depth) { + for (int i = 0; i < depth; i++) { + printf(" "); + } +} + +static void doDirectory(uint16_t key, uint8_t *disk, uint32_t disklen, + int depth) { + uint8_t *block = disk + key * 512; + if ((block[4] & 0xf0) != 0xf0 && (block[4] & 0xf0) != 0xe0) { + fprintf(stderr, "Invalid ProDOS disk\n"); + return; + } + + char dirname[50]; + readFilename(block + 5, block[4] & 0xf, dirname); + + if (depth < 0) { + mkdir(dirname, 0777); + chdir(dirname); + } else { + indent(depth); + printf("%s \n", dirname); + } + + uint8_t entryLength = block[0x23]; + uint8_t entriesPerBlock = block[0x24]; + uint16_t fileCount = r16(block + 0x25); + uint8_t *entry = block + entryLength + 4; + uint8_t curEntry = 1; + uint16_t curFile = 0; + + while (curFile < fileCount) { + if (entry[0] != 0) { + doEntry(entry, disk, disklen, depth < 0 ? -1 : depth + 1); + curFile++; + } + curEntry++; + entry += entryLength; + if (curEntry == entriesPerBlock) { + curEntry = 0; + block = disk + r16(block + 2) * 512; + entry = block + 4; + } + } + + if (depth < 0) { + chdir(".."); + } +} + +static void doEntry(uint8_t *entry, uint8_t *disk, uint32_t disklen, + int depth) { + uint16_t key = r16(entry + 0x11); + uint32_t eof = r24(entry + 0x15); + + char filename[50]; + readFilename(entry + 1, entry[0] & 0xf, filename); + + switch (entry[0] & 0xf0) { + case 0x10: // seedling + case 0x20: // sapling + case 0x30: // tree + if (depth < 0) { + doFile(key, eof, filename, disk, disklen, entry[0] >> 4); + } else { + indent(depth); + printf("%s %d bytes\n", filename, eof); + } + break; + case 0x50: + doGSOS(key, filename, disk, disklen, depth); + break; + case 0xd0: + doDirectory(key, disk, disklen, depth < 0 ? -1 : depth + 1); + break; + default: + fprintf(stderr, "Unknown file type: %x\n", entry[0] & 0xf0); + return; + } +} + +static void dumpSeedling(uint8_t *block, uint32_t len, FILE *f) { + if (block == NULL) { + fseek(f, len, SEEK_CUR); + } else { + fwrite(block, len, 1, f); + } +} + +static void dumpSapling(uint8_t *index, uint32_t len, FILE *f, uint8_t *disk, + uint32_t disklen) { + if (index == NULL) { + fseek(f, len, SEEK_CUR); + return; + } + + while (len > 0) { + uint16_t blockid = index[0] | (index[256] << 8); + uint8_t *block = NULL; + if (blockid && (blockid + 1) * 512 <= disklen) { + block = disk + blockid * 512; + } + uint32_t blen = len > 512 ? 512 : len; + dumpSeedling(block, blen, f); + len -= blen; + index++; + } +} + +static void dumpTree(uint8_t *index, uint32_t len, FILE *f, uint8_t *disk, + uint32_t disklen) { + if (index == NULL) { + fseek(f, len, SEEK_CUR); + return; + } + + while (len > 0) { + uint16_t blockid = index[0] | (index[256] << 8); + uint8_t *block = NULL; + if (blockid && (blockid + 1) * 512 <= disklen) { + block = disk + blockid * 512; + } + uint32_t blen = len > 256 * 512 ? 256 * 512 : len; + dumpSapling(block, blen, f, disk, disklen); + len -= blen; + index++; + } +} + +static void doGSOS(uint16_t key, char *name, uint8_t *disk, + uint32_t disklen, int depth) { + uint8_t *block = disk + key * 512; + int type = *block; + uint16_t subkey = r16(block + 1); + uint32_t eof = r24(block + 5); + if (depth < 0) { + doFile(subkey, eof, name, disk, disklen, type); + } + + char resname[50]; + strncpy(resname, name, 50); + strncat(resname, ".res", 50); + block = disk + key * 512 + 0x100; + type = *block; + subkey = r16(block + 1); + uint32_t reof = r24(block + 5); + if (depth < 0) { + doFile(subkey, reof, resname, disk, disklen, type); + } else { + indent(depth); + printf("%s %d bytes resource: %d bytes\n", name, eof, reof); + } +} + +static void doFile(uint16_t key, uint32_t len, char *name, uint8_t *disk, + uint32_t disklen, int type) { + uint8_t *block = disk + key * 512; + FILE *f = fopen(name, "wb"); + if (!f) { + fprintf(stderr, "Failed to create '%s'\n", name); + return; + } + + switch (type) { + case 1: + dumpSeedling(block, len, f); + break; + case 2: + dumpSapling(block, len, f, disk, disklen); + break; + case 3: + dumpTree(block, len, f, disk, disklen); + break; + } + fclose(f); +} diff --git a/65816.h b/65816.h new file mode 100644 index 0000000..1cd492d --- /dev/null +++ b/65816.h @@ -0,0 +1,374 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * Defines the 65816 opcodes, their addressing modes, and sizes + */ + +/** + Addressing modes: + imp implied + imm #$const (l) + immm #$const (l | h) if m16 + immx #$const (l | h) if x16 + imms #$const (l | h) + abs $addr (addrl | addrh) + abl $addr (addrl | addrh | bank) + abx $addr,x (addrl | addrh) + aby $addr,y (addrl | addrh) + ablx $addr,x (addrl | addrh | bank) + aix ($addr,x) (addrl | addrh) + zp $zp (offset) + zpx $zp,x (offset) + zpy $zp,y (offset) + zps $zp,s (offset) + ind ($addr) (addrl | addrh) + inz ($zp) (offset) + inl [$zp] (offset) + inx ($zp,x) (offset) + iny ($zp),y (offset) + inly [$zp],y (offset) + ins ($zp,s),y (offset) + rel $r (signed byte + pc) + rell $r (offsetl | offseth) + pc + bank $sb,$db (dstbnk | srcbnk) + db $op + dw $op + dd $op + */ + +typedef enum { + IMP = 0, + IMM, + IMMM, + IMMX, + IMMS, + ABS, + ABL, + ABX, + ABY, + ABLX, + AIX, + ZP, + ZPX, + ZPY, + ZPS, + IND, + INZ, + INL, + INX, + INY, + INLY, + INS, + REL, + RELL, + BANK, + DB, + DW, + DD +} Address; + +typedef enum { + BREAK = 0, + NORMAL = 1, + BRANCH = 2, + CALL = 3, + RETURN = 4, + JUMP = 5 +} OpType; + +typedef struct { + const char *inst; + Address address; + OpType type; +} Opcode; + +static Opcode opcodes[] = { + {"brk", IMP, BREAK}, // 00 + {"ora", INX, NORMAL}, // 01 + {"cop", IMP, NORMAL}, // 02 + {"ora", ZPS, NORMAL}, // 03 + {"tsb", ZP, NORMAL}, // 04 + {"ora", ZP, NORMAL}, // 05 + {"asl", ZP, NORMAL}, // 06 + {"ora", INL, NORMAL}, // 07 + {"php", IMP, NORMAL}, // 08 + {"ora", IMMM, NORMAL}, // 09 + {"asl", IMP, NORMAL}, // 0a + {"phd", IMP, NORMAL}, // 0b + {"tsb", ABS, NORMAL}, // 0c + {"ora", ABS, NORMAL}, // 0d + {"asl", ABS, NORMAL}, // 0e + {"ora", ABL, NORMAL}, // 0f + {"bpl", REL, BRANCH}, // 10 + {"ora", INY, NORMAL}, // 11 + {"ora", INZ, NORMAL}, // 12 + {"ora", INS, NORMAL}, // 13 + {"trb", ZP, NORMAL}, // 14 + {"ora", ZPX, NORMAL}, // 15 + {"asl", ZPX, NORMAL}, // 16 + {"ora", INLY, NORMAL}, // 17 + {"clc", IMP, NORMAL}, // 18 + {"ora", ABY, NORMAL}, // 19 + {"inc", IMP, NORMAL}, // 1a + {"tcs", IMP, NORMAL}, // 1b + {"trb", ABS, NORMAL}, // 1c + {"ora", ABX, NORMAL}, // 1d + {"asl", ABX, NORMAL}, // 1e + {"ora", ABLX, NORMAL}, // 1f + {"jsr", ABS, CALL}, // 20 + {"and", INX, NORMAL}, // 21 + {"jsl", ABL, CALL}, // 22 + {"and", ZPS, NORMAL}, // 23 + {"bit", ZP, NORMAL}, // 24 + {"and", ZP, NORMAL}, // 25 + {"rol", ZP, NORMAL}, // 26 + {"and", INL, NORMAL}, // 27 + {"plp", IMP, NORMAL}, // 28 + {"and", IMMM, NORMAL}, // 29 + {"rol", IMP, NORMAL}, // 2a + {"pld", IMP, NORMAL}, // 2b + {"bit", ABS, NORMAL}, // 2c + {"and", ABS, NORMAL}, // 2d + {"rol", ABS, NORMAL}, // 2e + {"and", ABL, NORMAL}, // 2f + {"bmi", REL, BRANCH}, // 30 + {"and", INY, NORMAL}, // 31 + {"and", INZ, NORMAL}, // 32 + {"and", INS, NORMAL}, // 33 + {"bit", ZPX, NORMAL}, // 34 + {"and", ZPX, NORMAL}, // 35 + {"rol", ZPX, NORMAL}, // 36 + {"and", INLY, NORMAL}, // 37 + {"sec", IMP, NORMAL}, // 38 + {"and", ABY, NORMAL}, // 39 + {"dec", IMP, NORMAL}, // 3a + {"tsc", IMP, NORMAL}, // 3b + {"bit", ABX, NORMAL}, // 3c + {"and", ABX, NORMAL}, // 3d + {"rol", ABX, NORMAL}, // 3e + {"and", ABLX, NORMAL}, // 3f + {"rti", IMP, RETURN}, // 40 + {"eor", INX, NORMAL}, // 41 + {"db", DB, BREAK}, // 42 + {"eor", ZPS, NORMAL}, // 43 + {"mvp", BANK, NORMAL}, // 44 + {"eor", ZP, NORMAL}, // 45 + {"lsr", ZP, NORMAL}, // 46 + {"eor", INL, NORMAL}, // 47 + {"pha", IMP, NORMAL}, // 48 + {"eor", IMMM, NORMAL}, // 49 + {"lsr", IMP, NORMAL}, // 4a + {"phk", IMP, NORMAL}, // 4b + {"jmp", ABS, JUMP}, // 4c + {"eor", ABS, NORMAL}, // 4d + {"lsr", ABS, NORMAL}, // 4e + {"eor", ABL, NORMAL}, // 4f + {"bvc", REL, BRANCH}, // 50 + {"eor", INY, NORMAL}, // 51 + {"eor", INZ, NORMAL}, // 52 + {"eor", INS, NORMAL}, // 53 + {"mvn", BANK, NORMAL}, // 54 + {"eor", ZPX, NORMAL}, // 55 + {"lsr", ZPX, NORMAL}, // 56 + {"eor", INLY, NORMAL}, // 57 + {"cli", IMP, NORMAL}, // 58 + {"eor", ABY, NORMAL}, // 59 + {"phy", IMP, NORMAL}, // 5a + {"tcd", IMP, NORMAL}, // 5b + {"jmp", ABL, JUMP}, // 5c + {"eor", ABX, NORMAL}, // 5d + {"lsr", ABX, NORMAL}, // 5e + {"eor", ABLX, NORMAL}, // 5f + {"rts", IMP, RETURN}, // 60 + {"adc", INX, NORMAL}, // 61 + {"per", IMP, NORMAL}, // 62 + {"adc", ZPS, NORMAL}, // 63 + {"stz", ZP, NORMAL}, // 64 + {"adc", ZP, NORMAL}, // 65 + {"ror", ZP, NORMAL}, // 66 + {"adc", INL, NORMAL}, // 67 + {"pla", IMP, NORMAL}, // 68 + {"adc", IMMM, NORMAL}, // 69 + {"ror", IMP, NORMAL}, // 6a + {"rtl", IMP, RETURN}, // 6b + {"jmp", IND, JUMP}, // 6c + {"adc", ABS, NORMAL}, // 6d + {"ror", ABS, NORMAL}, // 6e + {"adc", ABL, NORMAL}, // 6f + {"bvs", REL, BRANCH}, // 70 + {"adc", INY, NORMAL}, // 71 + {"adc", INZ, NORMAL}, // 72 + {"adc", INS, NORMAL}, // 73 + {"stz", ZPX, NORMAL}, // 74 + {"adc", ZPX, NORMAL}, // 75 + {"ror", ZPX, NORMAL}, // 76 + {"adc", INLY, NORMAL}, // 77 + {"sei", IMP, NORMAL}, // 78 + {"adc", ABY, NORMAL}, // 79 + {"ply", IMP, NORMAL}, // 7a + {"tdc", IMP, NORMAL}, // 7b + {"jmp", AIX, JUMP}, // 7c + {"adc", ABX, NORMAL}, // 7d + {"ror", ABX, NORMAL}, // 7e + {"adc", ABLX, NORMAL}, // 7f + {"bra", REL, JUMP}, // 80 + {"sta", INX, NORMAL}, // 81 + {"brl", RELL, JUMP}, // 82 + {"sta", ZPS, NORMAL}, // 83 + {"sty", ZP, NORMAL}, // 84 + {"sta", ZP, NORMAL}, // 85 + {"stx", ZP, NORMAL}, // 86 + {"sta", INL, NORMAL}, // 87 + {"dey", IMP, NORMAL}, // 88 + {"bit", IMMM, NORMAL}, // 89 + {"txa", IMP, NORMAL}, // 8a + {"phb", IMP, NORMAL}, // 8b + {"sty", ABS, NORMAL}, // 8c + {"sta", ABS, NORMAL}, // 8d + {"stx", ABS, NORMAL}, // 8e + {"sta", ABL, NORMAL}, // 8f + {"bcc", REL, BRANCH}, // 90 + {"sta", INY, NORMAL}, // 91 + {"sta", INZ, NORMAL}, // 92 + {"sta", INS, NORMAL}, // 93 + {"sty", ZPX, NORMAL}, // 94 + {"sta", ZPX, NORMAL}, // 95 + {"stx", ZPY, NORMAL}, // 96 + {"sta", INLY, NORMAL}, // 97 + {"tya", IMP, NORMAL}, // 98 + {"sta", ABY, NORMAL}, // 99 + {"txs", IMP, NORMAL}, // 9a + {"txy", IMP, NORMAL}, // 9b + {"stz", ABS, NORMAL}, // 9c + {"sta", ABX, NORMAL}, // 9d + {"stz", ABX, NORMAL}, // 9e + {"sta", ABLX, NORMAL}, // 9f + {"ldy", IMMX, NORMAL}, // a0 + {"lda", INX, NORMAL}, // a1 + {"ldx", IMMX, NORMAL}, // a2 + {"lda", ZPS, NORMAL}, // a3 + {"ldy", ZP, NORMAL}, // a4 + {"lda", ZP, NORMAL}, // a5 + {"ldx", ZP, NORMAL}, // a6 + {"lda", INL, NORMAL}, // a7 + {"tay", IMP, NORMAL}, // a8 + {"lda", IMMM, NORMAL}, // a9 + {"tax", IMP, NORMAL}, // aa + {"plb", IMP, NORMAL}, // ab + {"ldy", ABS, NORMAL}, // ac + {"lda", ABS, NORMAL}, // ad + {"ldx", ABS, NORMAL}, // ae + {"lda", ABL, NORMAL}, // af + {"bcs", REL, BRANCH}, // b0 + {"lda", INY, NORMAL}, // b1 + {"lda", INZ, NORMAL}, // b2 + {"lda", INS, NORMAL}, // b3 + {"ldy", ZPX, NORMAL}, // b4 + {"lda", ZPX, NORMAL}, // b5 + {"ldx", ZPY, NORMAL}, // b6 + {"lda", INLY, NORMAL}, // b7 + {"clv", IMP, NORMAL}, // b8 + {"lda", ABY, NORMAL}, // b9 + {"tsx", IMP, NORMAL}, // ba + {"tyx", IMP, NORMAL}, // bb + {"ldy", ABX, NORMAL}, // bc + {"lda", ABX, NORMAL}, // bd + {"ldx", ABY, NORMAL}, // be + {"lda", ABLX, NORMAL}, // bf + {"cpy", IMMX, NORMAL}, // c0 + {"cmp", INX, NORMAL}, // c1 + {"rep", IMM, NORMAL}, // c2 + {"cmp", ZPS, NORMAL}, // c3 + {"cpy", ZP, NORMAL}, // c4 + {"cmp", ZP, NORMAL}, // c5 + {"dec", ZP, NORMAL}, // c6 + {"cmp", INL, NORMAL}, // c7 + {"iny", IMP, NORMAL}, // c8 + {"cmp", IMMM, NORMAL}, // c9 + {"dex", IMP, NORMAL}, // ca + {"wai", IMP, NORMAL}, // cb + {"cpy", ABS, NORMAL}, // cc + {"cmp", ABS, NORMAL}, // cd + {"dec", ABS, NORMAL}, // ce + {"cmp", ABL, NORMAL}, // cf + {"bne", REL, BRANCH}, // d0 + {"cmp", INY, NORMAL}, // d1 + {"cmp", INZ, NORMAL}, // d2 + {"cmp", INS, NORMAL}, // d3 + {"pei", ZP, NORMAL}, // d4 + {"cmp", ZPX, NORMAL}, // d5 + {"dec", ZPX, NORMAL}, // d6 + {"cmp", INLY, NORMAL}, // d7 + {"cld", IMP, NORMAL}, // d8 + {"cmp", ABY, NORMAL}, // d9 + {"phx", IMP, NORMAL}, // da + {"stp", IMP, BREAK}, // db + {"jmp", IND, JUMP}, // dc + {"cmp", ABX, NORMAL}, // dd + {"dec", ABX, NORMAL}, // de + {"cmp", ABLX, NORMAL}, // df + {"cpx", IMMX, NORMAL}, // e0 + {"sbc", INX, NORMAL}, // e1 + {"sep", IMM, NORMAL}, // e2 + {"sbc", ZPS, NORMAL}, // e3 + {"cpx", ZP, NORMAL}, // e4 + {"sbc", ZP, NORMAL}, // e5 + {"inc", ZP, NORMAL}, // e6 + {"sbc", INL, NORMAL}, // e7 + {"inx", IMP, NORMAL}, // e8 + {"sbc", IMMM, NORMAL}, // e9 + {"nop", IMP, NORMAL}, // ea + {"xba", IMP, NORMAL}, // eb + {"cpx", ABS, NORMAL}, // ec + {"sbc", ABS, NORMAL}, // ed + {"inc", ABS, NORMAL}, // ee + {"sbc", ABL, NORMAL}, // ef + {"beq", REL, BRANCH}, // f0 + {"sbc", INY, NORMAL}, // f1 + {"sbc", INZ, NORMAL}, // f2 + {"sbc", INS, NORMAL}, // f3 + {"pea", IMMS, NORMAL}, // f4 + {"sbc", ZPX, NORMAL}, // f5 + {"inc", ZPX, NORMAL}, // f6 + {"sbc", INLY, NORMAL}, // f7 + {"sed", IMP, NORMAL}, // f8 + {"sbc", ABY, NORMAL}, // f9 + {"plx", IMP, NORMAL}, // fa + {"xce", IMP, NORMAL}, // fb + {"jsr", AIX, CALL}, // fc + {"sbc", ABX, NORMAL}, // fd + {"inc", ABX, NORMAL}, // fe + {"sbc", ABLX, NORMAL} // ff +}; + +static uint8_t addressSizes[] = { + 1, // IMP + 2, // IMM + 3, // IMMM + 3, // IMMX + 3, // IMMS + 3, // ABS + 4, // ABL + 3, // ABX + 3, // ABY + 4, // ABLX + 3, // AIX + 2, // ZP + 2, // ZPX + 2, // ZPY + 2, // ZPS + 3, // IND + 2, // INZ + 2, // INL + 2, // INX + 2, // INY + 2, // INLY + 2, // INS + 2, // REL + 3, // RELL + 3, // BANK + 1, // DB + 2, // DW + 4 // DD +}; diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fca8893 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ + Copyright (c) 2018, Sean Kasun + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1ee38be --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +CC=clang +CFLAGS=-Wall + +all: 2mg omf regs + +2mg: 2mg.o + $(CC) $(CFLAGS) -o $@ $^ + +omf: omf.o parser.o + $(CC) $(CFLAGS) -o $@ $^ + +regs: regs.o map.o scan.o parser.o disasm.o + $(CC) $(CFLAGS) -o $@ $^ + +%.o: %.c + $(CC) -c $(CFLAGS) -o $@ $< + +clean: + rm -f *.o 2mg omg regs diff --git a/README.md b/README.md new file mode 100755 index 0000000..35656f1 --- /dev/null +++ b/README.md @@ -0,0 +1,175 @@ +# What is this? + +This is a set of command-line tools designed specifically to reverse engineer Apple IIgs software. It is comprised of 3 separate tools; `2mg`, `omf`, and `regs`. + + + +## 2mg + +`2mg` extracts .2mg and .po prodos disk images. You can also just list the contents of the disk image with the `-l` or `--list` command line argument. Otherwise, it will create a folder with the name of the disk and extract all the files into that folder. + + + +## omf + +`omf` is a rather complicated tool which is designed to extract relocatable segments from OMF files. Apple IIgs executables (.sys16 files) and system tools (ex. SYSTEM/TOOLS/TOOL025) are in OMF format. + +You first run this tool and pass it an OMF file and it will generate a .map file. This map file is a simple text file that you may edit. Each line is in the format: + +`segment:memory location` + +The `segment`is the segment number from the OMF file, and `memory location` is where in memory to relocate that segment. + +`omf` does its best to automatically pack all the relocatable segments into the smallest memory possible, starting at `$2/0000`. You can change the starting memory address with the `-o` or `--org` argument. If you wish to manually specify where each segment should go in memory, feel free to edit the .map file however you wish. + +The next step is to run `omf` again, this time specifying the map file with `-m` or `--map`. This will apply the .map to the OMF and output each segment along with a corresponding .map file. `omf` will throw an error if the segments cannot be mapped as the .map file dictates (for example, you modified the map file so that the segments accidentally overlap). + +`omf` will modify each segment, applying the proper relocations before outputting the segment. If you wish to change where a segment is in memory, you should modify the original .map file and re-run `omf`. The resulting output files will be hardcoded for those specific memory locations. + +The segment outputs will be named `segX` and `segX.map`, where `X` is the segment number, in hex. If you wish to change the prefix from `seg` use the `-p` or `--prefix` argument. + +At this point, you can use the resulting segment files and map files as input to the `regs` tool. + + + +## regs + +`regs`is my 65816 tracing disassembler. It can be used in conjunction with the .map files created by `omf` or on its own. Since it is a tracing disassembler, it will start disassembly at a given location, and keep disassembling, following all possible paths. Everything not disassembled will be assumed to be data and shown in a hex view. + + + +#### regs by itself + +You can call `regs` and simply pass it a binary file and it will attempt to disassemble it. You can specify where in memory it should load the file before disassembly with the `-o` or `--org` argument. You can also control whether or not the disassembler is in emulation mode or 16-bit mode with various command-line arguments. Emulation mode is also useful for disassembling 8-bit Apple II software. Use `-e` to start in emulation mode (default native mode), `-m` to start with an 8-bit accumulator (default 16-bit), and `-x` to start with 8-bit index registers (default 16-bit). + + + +#### regs with .map files + +`regs` with .map files is where the disassembler really shines. You can call `regs` and pass it a .map file generated by `omf` and have real control over the disassembly. The .map file is designed to be edited by hand. The format is as follows: + +``` +gMAP "seg1" +sORG $30000 +$30000: +$30053:mx +$31066:e +``` + +The first line specifies the segment file that this map applies to. The filename in the quotes should be relative to the current directory. + +The next line specifies where the segment belongs in memory. **Do not edit this** if the segment was created by `omf`, since it has also been hardcoded in the binary. + +The next lines are a list of entry points to begin disassembly at. If, when analyzing the disassembly you find a switch case encoded as an indirect jump, you can take that list of jumps and add them to the map file and re-run `regs` to disassemble the previously un-disassembled data. As you work through a disassembly, you may end up with a map file with hundreds of entry points, that's normal. + +The flags after the colon are optional, and specify whether emulation mode should be enabled, or 16-bit or 8-bit accumulator and index registers should be used. It defaults to native mode with 16-bit registers. + +You can also use bank-separators if you wish. `$3/1066` is the same as `$31066`. + + + +## Pascal folder + +You'll notice a pascal folder in this repository. These are the original GS/OS pascal header files. This is to make it easier for you to look up the arguments and structures of various tool calls you'll come across when disassembling. + + + +# Examples + +The flexibility of these tools makes their use a little complicated. So here are some examples of how to go about disassembling various things. + +### Disassembling an S16 + +I'll be using the S16 from Dream Zone as an example. + +Generate a basic map of your S16: + +`$ omf dream.s16` + +This will create a file called `dream.s16.map`, which we could edit if we choose. We'll leave it as it is. Extract the segments of the OMF with: + +`$ omf --map=dream.s16.map dream.s16 --prefix=dream` + +This will create files `dream1`to `dream5` as well as `dream1.map` to `dream5.map`. + +The program's entry point is always the beginning of the first segment, so we'll start there. + +`$ regs dream1.map > dream1.s` + +This will disassemble the entry point. We can then modify the map to further refine the disassembly if we wish. + + + +### Disassembling a Tool + +This works the same as disassembling an S16, but with an important difference. + +We'll start the same, generating a map and extracting it. + +``` +$ omf TOOL025 +$ omf --map=TOOL025.map TOOL025 +``` + +Now, we'll remove all disassembly instructions from the map. You'll see why in a second. So we edit the map file to look like the following: + +``` +gMAP "seg1" +sORG $20000 +``` + +That's it.. no disassembly instructions. Now we run the disassembler: + +`$ regs seg1.map > seg1.s` + +This will just give us a hex dump of the segment. That's actually what we want. All tools start with a tool table. The first dword specifies the number of tools in this toolset. The next dwords all contain addresses (minus 1) of the various tool entry points. + +Let's say I want to disassemble NoteOn. We check the pascal folder and discover that it's tool $0b inside the $19 toolset. Which is the TOOL025 file we're working on (the tool numbers in the filenames are in decimal). So we calculate the offset to that entry point. + +`$0b * 4 + $20000 = $2:002c` + +If we look at the hex dump at that location we'll discover the entry point of NoteOn: `$2:02dd`. Well that's minus one, so we add the real entry point to the .map file: + +``` +gMAP "seg1" +sORG $20000 +$2/02de: +``` + +And rerun the disassembler. + +`$ regs seg1.map > seg1.s` + +We have just disassembled the NoteOn function. + + + +### Disassembling a Specific Tool Call in ROM + +Let's say I want to disassemble WriteRamBlock. We discover it's in the sound toolset $08. If you search, you'll discover that there isn't a TOOL008 anywhere, so we'll have to pull it from ROM. I'll be using an older 128k ROM just because it's convenient. + +First thing I do, is actually hand make a `rom.map` file for the ROM. + +``` +gMAP "APPLE2GS.ROM" +sORG $fe0000 +$fe/0000: +``` + +and disassemble it. + +`$ regs rom.map > rom.s` + +This is actually the bootstrap that initializes the `$e1/0000` tool call entrypoint. I notice it copies over a block of memory from `$fe/0051` into `$e1/0000`. So we add `$fe/0051` to the disassembly list of the map file, and disassemble it again. + +Following along with the disassembly, we discover that there's a toolset list starting at `$fe/012f`. It starts with a dword with the number of toolsets in the ROM, followed by a list of offsets to the various toolsets. We want toolset 8 for the sound toolset. + +`$8 * 4 + $fe012f = $fe014f` + +Look up the dword in that location and I find that the toolset is located at `$ff/3e00`. If you then jump to that location, you'll find this is in the exact same format as a tool on disk. It starts with a tool table. WriteRamBlock is tool 9. + +`$9 * 4 + $ff3e00 = $ff3e24` + +At that location, we discover the offset to the tool entry point is `$ff/41a4` so we'll add `$ff/41a5`to the map file and rerun the disassembly. + +Boom, we have just disassembled a specific tool call from ram. \ No newline at end of file diff --git a/addresses.h b/addresses.h new file mode 100644 index 0000000..0708ea9 --- /dev/null +++ b/addresses.h @@ -0,0 +1,412 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * Defines important IIgs memory addresses. + */ + +typedef struct { + uint32_t address; + const char *comment; +} MemAddress; + +static MemAddress addresses[] = { + {0x03d0, "Enter BASIC"}, + {0x03d2, "Reconnect DOS"}, + {0x03d9, "Cow Sound"}, + {0x03ea, "Reconnect IO"}, + {0x03f2, "Control-Reset Vector"}, + {0x03f5, "Ampersand Vector"}, + {0x03f8, "Control-Y Vector"}, + {0x0400, "Text Screen"}, + {0x0800, "Text Screen 2"}, + {0x0803, "Enter assembler"}, + {0x2000, "Hires screen"}, + {0x4000, "Hires screen 2"}, + {0x9dbf, "Reconnect DOS 3.3"}, + {0xa56e, "CATALOG"}, + {0xc000, "KBD / 80STOREOFF"}, + {0xc001, "80STOREON"}, + {0xc002, "RDMAINRAM"}, + {0xc003, "RDCARDRAM"}, + {0xc004, "WRMAINRAM"}, + {0xc005, "WRCARDRAM"}, + {0xc006, "SETSLOTCXROM"}, + {0xc007, "SETINTCXROM"}, + {0xc008, "SETSTDZP"}, + {0xc009, "SETALTZP"}, + {0xc00a, "SETINTC3ROM"}, + {0xc00b, "SETSLOTC3ROM"}, + {0xc00c, "CLR80VID"}, + {0xc00d, "SET80VID"}, + {0xc00e, "CLRALTCHAR"}, + {0xc00f, "SETALTCHAR"}, + {0xc010, "KBDSTRB"}, + {0xc011, "RDLCBNK2"}, + {0xc012, "RDLCRAM"}, + {0xc013, "RDRAMRD"}, + {0xc014, "RDRAMWRT"}, + {0xc015, "RDCXROM"}, + {0xc016, "RDALTZP"}, + {0xc017, "RDC3ROM"}, + {0xc018, "RD80STORE"}, + {0xc019, "RDVBL"}, + {0xc01a, "RDTEXT"}, + {0xc01b, "RDMIXED"}, + {0xc01c, "RDPAGE2"}, + {0xc01d, "RDHIRES"}, + {0xc01e, "RDALTCHAR"}, + {0xc01f, "RD80VID"}, + {0xc020, "TAPEOUT"}, + {0xc021, "MONOCOLOR"}, + {0xc022, "TBCOLOR"}, + {0xc023, "VGCINT"}, + {0xc024, "MOUSEDATA"}, + {0xc025, "KEYMODREG"}, + {0xc026, "DATAREG"}, + {0xc027, "KMSTATUS"}, + {0xc028, "ROMBANK"}, + {0xc029, "NEWVIDEO"}, + {0xc02b, "LANGSEL"}, + {0xc02c, "CHARROM"}, + {0xc02d, "SLTROMSEL"}, + {0xc02e, "VERTCNT"}, + {0xc02f, "HORIZCNT"}, + {0xc030, "SPKR"}, + {0xc031, "DISKREG"}, + {0xc032, "SCANINT"}, + {0xc033, "CLOCKDATA"}, + {0xc034, "CLOCKCTL"}, + {0xc035, "SHADOW"}, + {0xc036, "CYAREG"}, + {0xc037, "DMAREG"}, + {0xc038, "SCCBREG"}, + {0xc039, "SCCAREG"}, + {0xc03a, "SCCBDATA"}, + {0xc03b, "SCCADATA"}, + {0xc03c, "SOUNDCTL"}, + {0xc03d, "SOUNDDATA"}, + {0xc03e, "SOUNDADRL"}, + {0xc03f, "SOUNDADRH"}, + {0xc040, "STROBE"}, + {0xc041, "INTEN"}, + {0xc044, "MMDELTAX"}, + {0xc045, "MMDELTAY"}, + {0xc046, "DIAGTYPE"}, + {0xc047, "CLRVBLINT"}, + {0xc048, "CLRXYINT"}, + {0xc050, "TXTCLR"}, + {0xc051, "TXTSET"}, + {0xc052, "MIXCLR"}, + {0xc053, "MIXSET"}, + {0xc054, "TXTPAGE1"}, + {0xc055, "TXTPAGE2"}, + {0xc056, "LORES"}, + {0xc057, "HIRES"}, + {0xc058, "CLRAN0"}, + {0xc059, "SETAN0"}, + {0xc05a, "CLRAN1"}, + {0xc05b, "SETAN1"}, + {0xc05c, "CLRAN2"}, + {0xc05d, "SETAN2"}, + {0xc05e, "DHIRESON"}, + {0xc05f, "DHIRESOFF"}, + {0xc060, "TAPEIN"}, + {0xc061, "RDBTN0"}, + {0xc062, "RDBTN1"}, + {0xc063, "RDBTN2"}, + {0xc064, "PADDL0"}, + {0xc065, "PADDL1"}, + {0xc066, "PADDL2"}, + {0xc067, "PADDL3"}, + {0xc068, "STATEREG"}, + {0xc06d, "TESTREG"}, + {0xc06e, "CLTRM"}, + {0xc06f, "ENTM"}, + {0xc070, "PTRIG"}, + {0xc073, "BANKSEL"}, + {0xc07e, "IOUDISON"}, + {0xc07f, "IOUDISOFF"}, + {0xc081, "ROMIN"}, + {0xc083, "LCBANK2"}, + {0xc08b, "LCBANK1"}, + {0xc0e0, "PH0 off"}, + {0xc0e1, "PH0 on"}, + {0xc0e2, "PH1 off"}, + {0xc0e3, "PH1 on"}, + {0xc0e4, "PH2 off"}, + {0xc0e5, "PH2 on"}, + {0xc0e6, "PH3 off"}, + {0xc0e7, "PH3 on"}, + {0xc0e8, "motor off"}, + {0xc0e9, "motor on"}, + {0xc0ea, "drive 1"}, + {0xc0eb, "drive 2"}, + {0xc0ec, "q6 off"}, + {0xc0ed, "q6 on"}, + {0xc0ee, "q7 off"}, + {0xc0ef, "q7 on"}, + {0xc311, "AUXMOVE"}, + {0xc314, "XFER"}, + {0xc50d, "Smartport"}, + {0xc70d, "Smartport"}, + {0xcfff," CLRROM"}, + {0xd1fc, "Hires Find"}, + {0xd2c9, "Hires bg"}, + {0xd331, "Hires graphics bg"}, + {0xd33a, "Hires DRAW1"}, + {0xd3b9, "Hires SHLOAD"}, + {0xd683, "Clear FOR"}, + {0xdafb, "Carriage Return"}, + {0xe000, "Reset Int Basic"}, + {0xe04b, "IntBASIC LIST"}, + {0xe5ad, "NEW"}, + {0xe5b7, "PLOT"}, + {0xe836, "IntBASIC CHAIN"}, + {0xefec, "IntBASIC RUN"}, + {0xf07c, "IntBASIC LOAD"}, + {0xf0e0, "Leave monitor"}, + {0xf123, "DRAW shape"}, + {0xf14f, "Plot point"}, + {0xf171, "IntBASIC TRACE ON"}, + {0xf176, "IntBASIC TRACE OFF"}, + {0xf30a, "IntBASIC CON"}, + {0xf317, "RESUME"}, + {0xf328, "Clear error"}, + {0xf3de, "HGR"}, + {0xf3e4, "Show hires"}, + {0xf3f2, "Clear hires"}, + {0xf3f6, "Clear hires color"}, + {0xf666, "Enter assembler"}, + {0xf800, "PLOT"}, + {0xf80e, "PLOT1"}, + {0xf819, "HLINE"}, + {0xf828, "VLINE"}, + {0xf832, "CLRSCR"}, + {0xf836, "CLRTOP"}, + {0xf838, "Clear lores y"}, + {0xf83c, "Clear rect"}, + {0xf847, "GBASCALC"}, + {0xf85e, "Add 3 COLOR"}, + {0xf85f, "NXTCOL"}, + {0xf864, "SETCOL"}, + {0xf871, "SCRN"}, + {0xf88c, "INSDS1.2"}, + {0xf88e, "INSDS2"}, + {0xf890, "GET816LEN"}, + {0xf8d0, "INSTDSP"}, + {0xf940, "PRNTYX"}, + {0xf941, "PRNTAX"}, + {0xf944, "PRNTX"}, + {0xf948, "PRBLNK"}, + {0xf94a, "PRBL2"}, + {0xf94c, "Print X blank"}, + {0xf953, "PCADJ"}, + {0xf962, "TEXT2COPY"}, + {0xfa40, "OLDIRQ"}, + {0xfa4c, "BREAK"}, + {0xfa59, "OLDBRK"}, + {0xfa62, "RESET"}, + {0xfaa6, "PWRUP"}, + {0xfaba, "SLOOP"}, + {0xfad7, "REGDSP"}, + {0xfb19, "RTBL"}, + {0xfb1e, "PREAD"}, + {0xfb21, "PREAD4"}, + {0xfb2f, "INIT"}, + {0xfb39, "SETTXT"}, + {0xfb40, "SETGR"}, + {0xfb4b, "SETWND"}, + {0xfb51, "SETWND2"}, + {0xfb5b, "TABV"}, + {0xfb60, "APPLEII"}, + {0xfb6f, "SETPWRC"}, + {0xfb78, "VIDWAIT"}, + {0xfb88, "KBDWAIT"}, + {0xfbb3, "VERSION"}, + {0xfbbf, "ZIDBYTE2"}, + {0xfbc0, "ZIDBYTE"}, + {0xfbc1, "BASCALC"}, + {0xfbdd, "BELL1"}, + {0xfbe2, "BELL1.2"}, + {0xfbe4, "BELL2"}, + {0xfbf0, "STORADV"}, + {0xfbf4, "ADVANCE"}, + {0xfbfd, "VIDOUT"}, + {0xfc10, "BS"}, + {0xfc1a, "UP"}, + {0xfc22, "VTAB"}, + {0xfc24, "VTABZ"}, + {0xfc2c, "ESC"}, + {0xfc42, "CLREOP"}, + {0xfc58, "HOME"}, + {0xfc62, "CR"}, + {0xfc66, "LF"}, + {0xfc70, "SCROLL"}, + {0xfc9c, "CLREOL"}, + {0xfc9e, "CLREOLZ"}, + {0xfca8, "WAIT"}, + {0xfcb4, "NXTA4"}, + {0xfcba, "NXTA1"}, + {0xfcc9, "HEADR"}, + {0xfd0c, "RDKEY"}, + {0xfd10, "FD10"}, + {0xfd18, "RDKEY1"}, + {0xfd1b, "KEYIN"}, + {0xfd35, "RDCHAR"}, + {0xfd5a, "Wait return"}, + {0xfd5c, "Ring bell wait"}, + {0xfd67, "GETLNZ"}, + {0xfd6a, "GETLN"}, + {0xfd6c, "GETLN0"}, + {0xfd6f, "GETLN1"}, + {0xfd75, "Wait line"}, + {0xfd8b, "CROUT1"}, + {0xfd8e, "CROUT"}, + {0xfd92, "PRA1"}, + {0xfda3, "Print memory"}, + {0xfdda, "PRBYTE"}, + {0xfde3, "PRHEX"}, + {0xfded, "COUT"}, + {0xfdf0, "COUT1"}, + {0xfdf6, "COUTZ"}, + {0xfe1f, "IDROUTINE"}, + {0xfe2c, "MOVE"}, + {0xfe5e, "LIST"}, + {0xfe61, "Disassembler"}, + {0xfe80, "INVERSE"}, + {0xfe84, "NORMAL"}, + {0xfe86, "Set I"}, + {0xfe89, "SETKBD"}, + {0xfe8b, "INPORT"}, + {0xfe93, "SETVID"}, + {0xfe95, "OUTPORT"}, + {0xfeb0, "Jump BASIC"}, + {0xfeb6, "GO"}, + {0xfebf, "Display regs"}, + {0xfec2, "Perform trace"}, + {0xfecd, "WRITE"}, + {0xfefd, "READ"}, + {0xff2d, "PRERR"}, + {0xff3a, "BELL"}, + {0xff3f, "RESTORE"}, + {0xff44, "RSTR1"}, + {0xff4a, "SAVE"}, + {0xff4c, "SAV1"}, + {0xff58, "IORTS"}, + {0xff59, "OLDRST"}, + {0xff65, "MON"}, + {0xff69, "MONZ"}, + {0xff6c, "MONZ2"}, + {0xff70, "MONZ4"}, + {0xff8a, "DIG"}, + {0xffa7, "GETNUM"}, + {0xffad, "NXTCHR"}, + {0xffbe, "TOSUB"}, + {0xffc7, "ZMODE"}, + {0xe01e04, "StdText"}, + {0xe01e08, "StdLine"}, + {0xe01e0c, "StdRect"}, + {0xe01e10, "StdRRect"}, + {0xe01e14, "StdOval"}, + {0xe01e18, "StdArc"}, + {0xe01e1c, "StdPoly"}, + {0xe01e20, "StdRgn"}, + {0xe01e24, "StdPixels"}, + {0xe01e28, "StdComment"}, + {0xe01e2c, "StdTxMeas"}, + {0xe01e30, "StdTxBnds"}, + {0xe01e34, "StdGetPic"}, + {0xe01e38, "StdPutPic"}, + {0xe01e98, "ShieldCursor"}, + {0xe01e9c, "UnshieldCursor"}, + {0xe10000, "System Tool dispatch"}, + {0xe10004, "System Tool dispatch"}, + {0xe10008, "User Tool dispatch"}, + {0xe1000c, "User Tool dispatch"}, + {0xe10010, "Interrupt manager"}, + {0xe10014, "COP manager"}, + {0xe10018, "Abort manager"}, + {0xe1001c, "System death manager"}, + {0xe10020, "AppleTalk interrupt"}, + {0xe10024, "Serial interrupt"}, + {0xe10028, "Scanline interrupt"}, + {0xe1002c, "Sound interrupt"}, + {0xe10030, "VBlank interrupt"}, + {0xe10034, "Mouse interrupt"}, + {0xe10038, "250ms interrupt"}, + {0xe1003c, "Keyboard interrupt"}, + {0xe10040, "ADB Response"}, + {0xe10044, "ADB SRQ"}, + {0xe10048, "DA manager"}, + {0xe1004c, "Flush Buffer"}, + {0xe10050, "KbdMicro interrupt"}, + {0xe10054, "1s interrupt"}, + {0xe10058, "External VGC interrupt"}, + {0xe1005c, "Ohter interrupt"}, + {0xe10060, "Cursor update"}, + {0xe10064, "IncBusy"}, + {0xe10068, "DecBusy"}, + {0xe1006c, "Bell vector"}, + {0xe10070, "Break vector"}, + {0xe10074, "Trace vector"}, + {0xe10078, "Step vector"}, + {0xe1007c, "ROM disk"}, + {0xe10080, "ToWriteBram"}, + {0xe10084, "ToReadBram"}, + {0xe10088, "ToWriteTime"}, + {0xe1008c, "ToReadTime"}, + {0xe10090, "ToCtrlPanel"}, + {0xe10094, "ToBramSetup"}, + {0xe10098, "ToPrintMsg8"}, + {0xe1009c, "ToPrintMsg16"}, + {0xe100a0, "Native Ctl-Y"}, + {0xe100a4, "ToAltDispCDA"}, + {0xe100a8, "Prodos 16"}, + {0xe100ac, "OS vector"}, + {0xe100b0, "GS/OS"}, + {0xe100b4, "P8 Switch"}, + {0xe100b8, "Public Flags"}, + {0xe100bc, "OS Kind"}, + {0xe100bd, "OS Boot"}, + {0xe100be, "OS Busy"}, + {0xe100c0, "MsgPtr"}, + {0xe10180, "ToBusyStrip"}, + {0xe10184, "ToStrip"}, + {0xe101b2, "MidiInputPoll"}, + {0xe10200, "Memory manager"}, + {0xe10204, "Set System Speed"}, + {0xe10208, "Slot Arbiter"}, + {0xe10220, "Hypercard callback"}, + {0xe10224, "WordForRTL"}, + {0xe11004, "ATLK Basic"}, + {0xe11008, "ATLK Pascal"}, + {0xe1100c, "ATLK RamGoComp"}, + {0xe11010, "ATLK SoftReset"}, + {0xe11014, "ATLK RamDispatch"}, + {0xe11018, "ATLK RamForbid"}, + {0xe1101c, "ATLK RamPermit"}, + {0xe11020, "ATLK ProEntry"}, + {0xe11022, "ATLK ProDOS"}, + {0xe11026, "ATLK SerStatus"}, + {0xe1102a, "ATLK SerWrite"}, + {0xe1102e, "ATLK SerRead"}, + {0xe1103e, "ATLK PFI"}, + {0xe1d600, "ATLK CmdTable"}, + {0xe1da00, "ATLK TickCount"} +}; + +#define numAddresses (sizeof(addresses) / sizeof(addresses[0])) + +static const char *addressLookup(uint32_t addr) { + for (int i = 0; i < numAddresses; i++) { + if (addresses[i].address >= addr) { + if (addresses[i].address == addr) + return addresses[i].comment; + break; + } + } + if (addr & ~0xffff) + return addressLookup(addr & 0xffff); // try pageless + return NULL; +} diff --git a/disasm.c b/disasm.c new file mode 100644 index 0000000..a7badc1 --- /dev/null +++ b/disasm.c @@ -0,0 +1,358 @@ +/** + * @copyright 2018 Sean Kasun + * The main disassembler. + */ + +#include +#include +#include +#include +#include "disasm.h" +#include "65816.h" +#include "handle.h" +#include "addresses.h" +#include "prodos8.h" +#include "prodos16.h" +#include "smartport.h" +#include "tools.h" + +static void dumphex(uint8_t *ptr, uint32_t addr, uint32_t len) { + uint8_t *eof = ptr + len; + for (int line = 0; ptr < eof; line++) { + printf("%02x/%04x: ", addr >> 16, addr & 0xffff); + uint8_t *p = ptr; + int skip = addr & 0xf; + int i = 0; + for (; i < skip; i++) { + if (i == 8) { + printf(" "); + } + printf(" "); + } + for (; i < 16 && p < eof; i++) { + if (i == 8) { + printf(" "); + } + printf("%02x ", *p++); + } + for (; i < 16; i++) { + if (i == 8) { + printf(" "); + } + printf(" "); + } + printf("| "); + i = 0; + for (; i < skip; i++) { + if (i == 8) { + printf(" "); + } + printf(" "); + } + for (; i < 16 && ptr < eof; i++) { + if (i == 8) { + printf(" "); + } + uint8_t c = *ptr++; + addr++; + printf("%c", (c >= ' ' && c <= '~') ? c : '.'); + } + printf("\n"); + } +} + +void disassemble(uint8_t *data, size_t len, Map *map) { + uint8_t *ptr = data; + uint8_t *end = data + len; + + uint16_t x = 0; + uint32_t val; + int8_t delta; + int16_t delta16; + uint32_t d6; + bool smart = false, dos8 = false, dos16 = false; + + uint32_t addr = map->minMemory; + + while (ptr < end) { + MapFlags flags = map->mem[addr - map->minMemory]; + if ((flags & IsOpcode) || smart || dos8 || dos16) { + printf("%02x/%04x:", addr >> 16, addr & 0xffff); + uint8_t *start = ptr; + uint8_t opcode = *ptr++; + + const char *inst = opcodes[opcode].inst; + Address mode = opcodes[opcode].address; + + if (smart || dos8) { + mode = DB; + inst = "db"; + } + if (dos16) { + mode = DW; + inst = "dw"; + } + + uint16_t width = addressSizes[mode]; + if (mode == IMMM && (flags & (IsEmu | IsM8))) { + width--; + } + if (mode == IMMX && (flags & (IsEmu | IsX8))) { + width--; + } + addr += width; + + for (int i = 0; i < width; i++) { + printf(" %02x", start[i]); + } + for (int i = 0; i < 4 - width; i++) { + printf(" "); + } + printf(" %s", inst); + for (int i = strlen(inst); i < 8; i++) { + printf(" "); + } + + const char *comments = NULL; + uint8_t oprlen = 0; + + switch (mode) { + case IMP: + break; + case IMM: + printf("#$%02x", *ptr++); + oprlen = 4; + break; + case IMMM: + if (flags & (IsEmu | IsM8)) { + printf("#$%02x", *ptr++); + oprlen = 4; + } else { + printf("#$%04x", r16(ptr)); ptr += 2; + oprlen = 6; + } + break; + case IMMX: + if (flags & (IsEmu | IsX8)) { + x = *ptr++; + printf("#$%02x", x); + oprlen = 4; + } else { + x = r16(ptr); ptr += 2; + printf("#$%04x", x); + oprlen = 6; + } + break; + case IMMS: + printf("#$%04x", r16(ptr)); ptr += 2; + oprlen = 6; + break; + case ABS: + val = r16(ptr); ptr += 2; + printf("$%04x", val); + oprlen = 5; + comments = addressLookup(val); + break; + case ABL: + val = r24(ptr); ptr += 3; + printf("$%02x/%04x", val >> 16, val & 0xffff); + oprlen = 8; + comments = addressLookup(val); + break; + case ABX: + printf("$%04x, x", r16(ptr)); ptr += 2; + oprlen = 8; + break; + case ABY: + printf("$%04x, y", r16(ptr)); ptr += 2; + oprlen = 8; + break; + case ABLX: + val = r24(ptr); ptr += 3; + printf("$%02x/%04x, x", val >> 16, val & 0xffff); + oprlen = 11; + break; + case AIX: + printf("($%04x, x)", r16(ptr)); ptr += 2; + oprlen = 10; + break; + case ZP: + printf("$%02x", *ptr++); + oprlen = 3; + break; + case ZPX: + printf("$%02x, x", *ptr++); + oprlen = 6; + break; + case ZPY: + printf("$%02x, y", *ptr++); + oprlen = 6; + break; + case ZPS: + printf("$%02x, s", *ptr++); + oprlen = 6; + break; + case IND: + printf("($%04x)", r16(ptr)); ptr += 2; + oprlen = 7; + break; + case INZ: + printf("($%02x)", *ptr++); + oprlen = 5; + break; + case INL: + printf("[$%02x]", *ptr++); + oprlen = 5; + break; + case INX: + printf("($%02x, x)", *ptr++); + oprlen = 8; + break; + case INY: + printf("($%02x), y", *ptr++); + oprlen = 8; + break; + case INLY: + printf("[$%02x], y", *ptr++); + oprlen = 8; + break; + case INS: + printf("($%02x, s), y", *ptr++); + oprlen = 11; + break; + case REL: + delta = *ptr++; + d6 = delta + addr; + printf("$%02x/%04x", d6 >> 16, d6 & 0xffff); + oprlen = 8; + break; + case RELL: + delta16 = r16(ptr); ptr += 2; + d6 = delta16 + addr; + printf("$%02x/%04x", d6 >> 16, d6 & 0xffff); + oprlen = 8; + break; + case BANK: + val = *ptr++; + printf("$%02x, $%02x", *ptr++, val); + oprlen = 8; + break; + case DB: + printf("$%02x", opcode); + oprlen = 3; + break; + case DW: + val = opcode | (*ptr++ << 8); + printf("$%04x", val); + oprlen = 5; + break; + case DD: + printf("$%08x", opcode | r24(ptr) << 8); ptr += 3; + oprlen = 9; + break; + } + + if (smart) { + comments = smartportLookup(opcode); + smart = false; + } + if (dos8) { + comments = prodos8Lookup(opcode); + dos8 = false; + } + if (dos16) { + comments = prodos16Lookup(val); + dos16 = false; + } + + if (opcode == 0xa2) { // ldx + if (*ptr == 0x22) { // jsl + if (r24(ptr + 1) == 0xe10000) { // jsl el/0000 + comments = toolLookup(x); + } + } + } + if (opcode == 0x20) { // jsr + if (val == 0xc50d || val == 0xc70d) { + smart = true; + } + if (val == 0xbf00) { + dos8 = true; + } + } + if (opcode == 0x22) { // jsl + if (val == 0xe100a8) { + dos16 = true; + } + } + + if (comments != NULL) { + for (int i = oprlen; i < 16; i++) { + printf(" "); + } + printf("; %s", comments); + } + + uint16_t nextFlags = map->mem[addr - map->minMemory]; + if (((flags ^ nextFlags) & (IsEmu | IsM8 | IsX8)) && comments == NULL && + (nextFlags & IsOpcode)) { + for (int i = oprlen; i < 16; i++) { + printf(" "); + } + printf(";"); + if ((flags ^ nextFlags) & IsEmu) { + if (nextFlags & IsEmu) { + printf(" 8-bit mode"); + } else { + printf(" 16-bit mode"); + } + } + if ((flags ^ nextFlags) & IsM8) { + if (nextFlags & IsM8) { + printf(" a.b"); + } else { + printf(" a.w"); + } + } + if ((flags ^ nextFlags) & IsX8) { + if (nextFlags & IsX8) { + printf(" x.b"); + } else { + printf(" x.w"); + } + } + } + printf("\n"); + } else { + uint32_t dlen = 0; + uint8_t *p = ptr; + while (p < end && !(map->mem[addr + dlen - map->minMemory] & IsOpcode)) { + p++; + dlen++; + } + uint32_t val; + switch (dlen) { + case 4: + printf("%02x/%04x:", addr >> 16, addr & 0xffff); + val = r32(ptr); + printf(" %02x %02x %02x %02x dd $%08x\n", val & 0xff, + (val >> 8) & 0xff, (val >> 16) & 0xff, val >> 24, val); + break; + case 2: + printf("%02x/%04x:", addr >> 16, addr & 0xffff); + val = r16(ptr); + printf(" %02x %02x dw $%04x\n", val & 0xff, val >> 8, val); + break; + case 1: + printf("%02x/%04x:", addr >> 16, addr & 0xffff); + printf(" %02x db $%04x\n", *ptr, *ptr); + break; + default: + dumphex(ptr, addr, dlen); + break; + } + ptr += dlen; + addr += dlen; + } + } +} diff --git a/disasm.h b/disasm.h new file mode 100644 index 0000000..50d05e3 --- /dev/null +++ b/disasm.h @@ -0,0 +1,10 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * The main disassembler. + */ + +#include "map.h" + +extern void disassemble(uint8_t *data, size_t len, Map *map); diff --git a/handle.h b/handle.h new file mode 100644 index 0000000..e4e467e --- /dev/null +++ b/handle.h @@ -0,0 +1,41 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * Routines for reading multi-byte numbers from a stream + */ + +#include + +static inline uint32_t fourcc(const char *p) { + return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; +} + +static inline uint16_t r16(uint8_t *p) { + uint16_t r = *p++; + r |= *p << 8; + return r; +} + +static inline uint32_t r24(uint8_t *p) { + uint32_t r = *p++; + r |= *p++ << 8; + r |= *p << 16; + return r; +} + +static inline uint32_t r32(uint8_t *p) { + uint32_t r = *p++; + r |= *p++ << 8; + r |= *p++ << 16; + r |= *p << 24; + return r; +} + +static inline uint32_t r4(uint8_t *p) { + uint32_t r = *p++ << 24; + r |= *p++ << 16; + r |= *p++ << 8; + r |= *p; + return r; +} diff --git a/map.c b/map.c new file mode 100644 index 0000000..d0289fd --- /dev/null +++ b/map.c @@ -0,0 +1,142 @@ +/** + * @copyright 2018 Sean Kasun + * Handles the memory map, for the tracing disassembler. + */ + +#include +#include +#include +#include +#include +#include +#include "map.h" +#include "parser.h" +#include "handle.h" + +static Rule *parseRule(ConfigFile *f) { + Rule *rule = malloc(sizeof(Rule)); + rule->next = NULL; + if (!token(f, '$')) { + fail(f, "Address must be a hex value above 0 \n" + "starting with '$', i.e. $c20"); + } + rule->address = hex(f); + if (token(f, '/')) { + rule->address <<= 16; + rule->address |= hex(f); + } + if (rule->address == 0) { + fail(f, "Address must be a hex value above 0 \n" + "starting with '$', i.e. $c20"); + } + if (!token(f, ':')) { + fail(f, "Expected ':'"); + } + rule->flags = IsOpcode; + bool foundFlag = false; + do { + foundFlag = false; + if (token(f, 'e')) { + rule->flags |= IsEmu; + foundFlag = true; + } + if (token(f, 'm')) { + rule->flags |= IsM8; + foundFlag = true; + } + if (token(f, 'x')) { + rule->flags |= IsX8; + foundFlag = true; + } + } while (foundFlag); + return rule; +} + +Map *loadMap(const char *filename, uint32_t org, MapFlags flags) { + Map *map = malloc(sizeof(Map)); + map->rules = NULL; + map->minMemory = org; + map->maxMemory = 0; + map->mem = NULL; + + FILE *f = fopen(filename, "rb"); + if (!f) { + fprintf(stderr, "Failed to open '%s'\n", filename); + exit(-1); + } + fseek(f, 0, SEEK_END); + size_t len = ftell(f); + fseek(f, 0, SEEK_SET); + uint8_t *data = malloc(len); + fread(data, len, 1, f); + fclose(f); + + if (r4(data) != fourcc("gMAP")) { + // not a map file, use org as the only entry point + map->rules = malloc(sizeof(Rule)); + map->rules->address = org; + map->rules->flags = flags; + map->rules->next = NULL; + map->filename = filename; + free(data); + return map; + } + ConfigFile c; + c.start = data; + c.p = c.start; + c.end = c.start + len; + c.filename = filename; + + // set filename + c.p += 4; + eatSpaces(&c); + if (!token(&c, '"')) { + fail(&c, "Expected '\"' around the filename."); + } + uint8_t *fnp = c.p; + while (fnp < c.end && *fnp != '"') { + fnp++; + } + if (fnp == c.end) { + fail(&c, "Filename has no closing '\"'."); + } + int flen = fnp - c.p; + char *fname = malloc(flen); + memcpy(fname, c.p, flen); + fname[flen] = 0; + map->filename = fname; + c.p = fnp + 1; + + eatSpaces(&c); + if (r4(c.p) != fourcc("sORG")) { + fail(&c, "Expected 'sORG' tag"); + } + c.p += 4; + eatSpaces(&c); + if (!token(&c, '$')) { + fail(&c, "ORG must be a hex value above 0\n" + "starting with '$', i.e. $c20"); + } + map->minMemory = hex(&c); + if (map->minMemory == 0) { + fail(&c, "ORG must be a hex value above 0\n" + "starting with '$', i.e. $c20"); + } + eatSpaces(&c); + + // load rules + Rule *lastRule = NULL; + while (c.p < c.end) { + Rule *rule = parseRule(&c); + if (lastRule == NULL) { + map->rules = rule; + } else { + lastRule->next = rule; + } + lastRule = rule; + eatSpaces(&c); + } + free(c.start); + + return map; +} diff --git a/map.h b/map.h new file mode 100644 index 0000000..c8841df --- /dev/null +++ b/map.h @@ -0,0 +1,33 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * The memory map for the tracing disassembler + */ + +#include + +typedef enum { + IsData = 0x01, + IsOpcode = 0x02, + IsOperand = 0x04, + IsX8 = 0x10, + IsM8 = 0x20, + IsEmu = 0x100 +} MapFlags; + +typedef struct Rule { + uint32_t address; + uint16_t flags; + struct Rule *next; +} Rule; + +typedef struct { + Rule *rules; + uint32_t minMemory; + uint32_t maxMemory; + MapFlags *mem; + const char *filename; +} Map; + +extern Map *loadMap(const char *filename, uint32_t org, MapFlags flags); diff --git a/omf.c b/omf.c new file mode 100644 index 0000000..8667211 --- /dev/null +++ b/omf.c @@ -0,0 +1,568 @@ +/** + * @copyright 2018 Sean Kasun + * Handles parsing and relocating an OMF (s16, tool, etc) + */ + +#include "handle.h" +#include "parser.h" +#include +#include +#include + +const char *argp_program_version = "omf 0.5"; +const char *argp_program_bug_address = "sean@seancode.com"; +static char doc[] = "Relocate and extract OMF segments" + "\vThis should be run twice. The first time to generate the map." + "The second time, to use that map to relocate and extract the segments"; +static char args_doc[] = "FILE"; +static struct argp_option options[] = { + {"org", 'o', "ADDRESS", OPTION_ARG_OPTIONAL, + "Start mapping the segments at this address, default 20000"}, + {"map", 'm', "FILE", OPTION_ARG_OPTIONAL, + "Use this map to extract the segments"}, + {"prefix", 'p', "PREFIX", OPTION_ARG_OPTIONAL, + "Prefix segment files with this. Default \"seg\""}, + { 0 } +}; + +struct arguments { + char *filename; + char *map; + char *prefix; + uint32_t org; +}; + +static inline uint32_t parseNum(const char *s) { + uint32_t res = 0; + while (isspace(*s)) { + s++; + } + while (isxdigit(*s)) { + res <<= 4; + if (*s >= '0' && *s <= '9') { + res |= *s - '0'; + } else if (*s >= 'a' && *s <= 'f') { + res |= *s - 'a' + 10; + } else if (*s >= 'A' && *s <= 'F') { + res |= *s - 'A' + 10; + } + s++; + } + return res; +} + +static error_t parse_opt(int key, char *arg, struct argp_state *state) { + struct arguments *arguments = state->input; + switch (key) { + case 'm': + arguments->map = arg; + break; + case 'p': + arguments->prefix = arg; + break; + case 'o': + if (arg) { + arguments->org = parseNum(arg); + } + break; + case ARGP_KEY_ARG: + if (state->arg_num >= 1) { + argp_usage(state); + } + arguments->filename = arg; + break; + case ARGP_KEY_END: + if (state->arg_num < 1) { + argp_usage(state); + } + break; + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + +static struct argp argp = { options, parse_opt, args_doc, doc }; + + +typedef struct Segment { + uint32_t bytecnt; + uint32_t resspc; + uint32_t length; + uint8_t lablen; + uint8_t numlen; + uint32_t banksize; + uint16_t kind; + uint32_t org; + uint32_t align; + uint16_t segnum; + uint32_t entry; + char name[256]; + uint8_t *offset; + uint8_t *data; + uint32_t mapped; + struct Segment *next; +} Segment; + +static Segment *loadOMF(uint8_t *data, size_t len); +static void mapSegments(Segment *segments, uint32_t min); +static void relocSegments(Segment *segments, char *prefix); + +int main(int argc, char **argv) { + struct arguments arguments; + arguments.filename = ""; + arguments.map = NULL; + arguments.prefix = "seg"; + arguments.org = 0x20000; + argp_parse(&argp, argc, argv, 0, 0, &arguments); + + // open omf + FILE *f = fopen(arguments.filename, "rb"); + if (!f) { + fprintf(stderr, "Failed to open '%s'\n", arguments.filename); + return -1; + } + fseek(f, 0, SEEK_END); + size_t len = ftell(f); + fseek(f, 0, SEEK_SET); + uint8_t *data = malloc(len); + fread(data, len, 1, f); + fclose(f); + + Segment *segments = loadOMF(data, len); + if (arguments.map != NULL) { + // load the map! + f = fopen(arguments.map, "rb"); + if (!f) { + fprintf(stderr, "Failed to open '%s'\n", arguments.map); + return -1; + } + ConfigFile c; + fseek(f, 0, SEEK_END); + len = ftell(f); + fseek(f, 0, SEEK_SET); + c.start = malloc(len); + fread(c.start, len, 1, f); + fclose(f); + c.p = c.start; + c.end = c.start + len; + + while (c.p < c.end) { + uint32_t segnum = hex(&c); + if (!token(&c, ':')) { + fprintf(stderr, "Error: expected ':' in map.\n"); + exit(-1); + } + uint32_t mapped = hex(&c); + + for (Segment *seg = segments; seg != NULL; seg = seg->next) { + if (seg->segnum == segnum) { + seg->mapped = mapped; + } + } + eatSpaces(&c); + } + free(c.start); + } + + // map any unmapped segments + mapSegments(segments, arguments.org); + + if (arguments.map != NULL) { + relocSegments(segments, arguments.prefix); + } else { + int mlen = strlen(arguments.filename); + char *mapname = malloc(mlen + 5); + memcpy(mapname, arguments.filename, mlen); + memcpy(mapname + mlen, ".map\0", 5); + f = fopen(mapname, "wb"); + if (!f) { + fprintf(stderr, "Failed to create '%s'\n", mapname); + return -1; + } + for (Segment *seg = segments; seg != NULL; seg = seg->next) { + fprintf(f, "%x:%x\n", seg->segnum, seg->mapped); + } + fclose(f); + fprintf(stdout, "Created '%s'. Edit it, and extract with: \n" + " %s --map=%s %s\n", mapname, argv[0], mapname, arguments.filename); + } + + free(data); +} + +static Segment *loadOMF(uint8_t *data, size_t len) { + Segment *last = NULL; + Segment *segments = NULL; + + size_t ofs = 0; + while (ofs < len) { + Segment *seg = malloc(sizeof(Segment)); + seg->next = NULL; + + uint8_t *p = data + ofs; + seg->bytecnt = r32(p); p += 4; + seg->resspc = r32(p); p += 4; + seg->length = r32(p); p += 4; + uint8_t kind = *p++; + seg->lablen = *p++; + seg->numlen = *p++; + uint8_t version = *p++; + seg->banksize = r32(p); p += 4; + seg->kind = r16(p); p += 2; + p += 2; // undefined + seg->org = r32(p); p += 4; + seg->align = r32(p); p += 4; + p += 2; // byte order + seg->segnum = r16(p); p += 2; + seg->entry = r32(p); p += 4; + uint16_t dispname = r16(p); p += 2; + uint16_t dispdata = r16(p); p += 2; + p = data + ofs + dispname + 0xa; + uint8_t strlen = seg->lablen; + if (strlen == 0) { + strlen = *p++; + } + memcpy(seg->name, p, strlen); + seg->name[strlen] = 0; + seg->offset = data + ofs + dispdata; + if (version == 1) { // convert to v2 + seg->bytecnt *= 512; + seg->kind = (kind & 0x1f) | ((kind & 0xe0) << 8); + } + seg->mapped = 0; + seg->data = NULL; + + ofs += seg->bytecnt; + if (last == NULL) { + segments = seg; + } else { + last->next = seg; + } + last = seg; + } + return segments; +} + +static int cmpmemory(const void *p1, const void *p2) { + const uint32_t *a = p1, *b = p2; + return *a - *b; +} + +static void mapSegments(Segment *segments, uint32_t min) { + // we use a memory map that denotes runes of available memory. + // Each segment has a start and end, so we need an array of twice the + // number of segments (+2 for the absolute start and end of memory) + + // count segments + uint32_t numSegs = 0; + for (Segment *seg = segments; seg != NULL; seg = seg->next) { + numSegs++; + } + + uint32_t *memory = malloc(sizeof(uint32_t) * (numSegs * 2 + 2)); + int numNodes = 0; + memory[numNodes++] = min; // minimum + memory[numNodes++] = 0x1000000; // maximum possible memory for the IIgs. + + // step one, map hardcoded or overridden targets + for (Segment *seg = segments; seg != NULL; seg = seg->next) { + if (seg->org != 0 || seg->mapped != 0) { + if (seg->mapped == 0) { + if ((seg->kind & 0x1f) == 0x11) { // absolute bank + seg->mapped = seg->org << 16; + } else { + seg->mapped = seg->org; + } + } + bool collision = false; + // verify we aren't overlapping.. that would be tremendously bad. + for (int node = 0; node < numNodes; node += 2) { + if (seg->mapped < memory[node] && + seg->mapped + seg->length > memory[node]) { // crosses! + collision = true; + } + if (seg->mapped < memory[node + 1] && + seg->mapped + seg->length > memory[node + 1]) { // crosses! + collision = true; + } + } + if (collision) { + fprintf(stderr, "Segment #$%x collides with another segment!\n", + seg->segnum); + exit(-1); + } + memory[numNodes++] = seg->mapped; + memory[numNodes++] = seg->mapped + seg->length; + if (seg->mapped < memory[0]) { // below the minimum! + memory[0] = seg->mapped; // recalibrate the minimum + } + // resort memory map + qsort(memory, numNodes, sizeof(uint32_t), cmpmemory); + } + } + + // finally, map everything else by first fit. + for (Segment *seg = segments; seg != NULL; seg = seg->next) { + if (seg->mapped == 0) { + for (int node = 0; node < numNodes; node += 2) { + uint32_t base = memory[node]; + if (seg->align && (base & (seg->align - 1))) { // snap to alignment + base += seg->align; + base &= ~(seg->align - 1); + } + if (seg->banksize &&(((base & (seg->banksize - 1)) + seg->length) & + ~(seg->banksize - 1))) { // crosses bank + base += seg->banksize; + base &= ~(seg->banksize - 1); + } + // does it fit? + if (base < memory[node + 1] && memory[node + 1] - base >= seg->length) { + seg->mapped = base; + memory[numNodes++] = seg->mapped; + memory[numNodes++] = seg->mapped + seg->length; + qsort(memory, numNodes, sizeof(uint32_t), cmpmemory); + break; + } + } + if (seg->mapped == 0) { + fprintf(stderr, "Failed to map Segment #$%x, not enough free memory\n", + seg->segnum); + exit(-1); + } + } + } + free(memory); +} + +typedef enum { + DONE = 0x00, + RELOC = 0xe2, + INTERSEG = 0xe3, + DS = 0xf1, + LCONST = 0xf2, + cRELOC = 0xf5, + cINTERSEG = 0xf6, + SUPER = 0xf7 +} SegOp; + +static void patch(uint8_t *data, uint8_t numBytes, uint32_t value) { + for (int i = 0; i < numBytes; i++, value >>= 8) { + data[i] = value & 0xff; + } +} + +static void hexout(char *p, uint32_t val, int len) { + p += len; + while (len-- > 0) { + char ch = val & 0xf; + val >>= 4; + if (ch < 10) { + *--p = '0' + ch; + } else { + *--p = 'a' + (ch - 10); + } + } +} + +static void relocSegments(Segment *segments, char *prefix) { + int prefixLen = strlen(prefix); + char *filename = malloc(prefixLen + 4); + char *mapname = malloc(prefixLen + 9); + + for (Segment *seg = segments; seg != NULL; seg = seg->next) { + bool done = false; + uint32_t pc = seg->mapped; + uint8_t *p = seg->offset; + seg->data = calloc(seg->length, 1); + + while (!done) { + uint8_t opcode = *p++; + switch (opcode) { + case DONE: + done = true; + break; + case RELOC: + { + uint8_t numBytes = *p++; + int8_t bitShift = *p++; + uint32_t offset = r32(p); p += 4; + uint32_t subOffset = r32(p) + seg->mapped; p += 4; + + if (bitShift < 0) { + subOffset >>= -bitShift; + } else { + subOffset <<= bitShift; + } + patch(seg->data + offset, numBytes, subOffset); + } + break; + case INTERSEG: + { + uint8_t numBytes = *p++; + int8_t bitShift = *p++; + uint32_t offset = r32(p); p += 4; + p += 2; // filenum + uint16_t segnum = r16(p); p += 2; + uint32_t subOffset = r32(p); p += 4; + for (Segment *sub = segments; sub != NULL; sub = sub->next) { + if (sub->segnum == segnum) { + subOffset += sub->mapped; + break; + } + } + if (bitShift < 0) { + subOffset >>= -bitShift; + } else { + subOffset <<= bitShift; + } + patch(seg->data + offset, numBytes, subOffset); + } + break; + case DS: + pc += r32(p); p += 4; // filled with zeros + break; + case LCONST: + { + uint32_t count = r32(p); p += 4; + memcpy(seg->data + pc - seg->mapped, p, count); p += count; + pc += count; + } + break; + case cRELOC: + { + uint8_t numBytes = *p++; + int8_t bitShift = *p++; + uint16_t offset = r16(p); p += 2; + uint32_t subOffset = r16(p) + seg->mapped; p += 2; + if (bitShift < 0) { + subOffset >>= -bitShift; + } else { + subOffset <<= bitShift; + } + patch(seg->data + offset, numBytes, subOffset); + } + break; + case cINTERSEG: + { + uint8_t numBytes = *p++; + int8_t bitShift = *p++; + uint16_t offset = r16(p); p += 2; + uint8_t segnum = *p++; + uint32_t subOffset = r16(p); p += 2; + for (Segment *sub = segments; sub != NULL; sub = sub->next) { + if (sub->segnum == segnum) { + subOffset += sub->mapped; + break; + } + } + if (bitShift < 0) { + subOffset >>= -bitShift; + } else { + subOffset <<= bitShift; + } + patch(seg->data + offset, numBytes, subOffset); + } + break; + case SUPER: + { + uint32_t superLen = r32(p); p += 4; + uint8_t *superEnd = p + superLen; + uint8_t superType = *p++; + uint32_t superPage = 0; + while (p < superEnd) { + uint8_t numOfs = *p++; + if (numOfs & 0x80) { + superPage += 256 * (numOfs & 0x7f); + continue; + } + for (int o = 0; o <= numOfs; o++) { + uint32_t offset = superPage | *p++; + uint8_t numBytes = 0; + uint32_t subOffset = r16(seg->data + offset); + if (superType == 0 || superType == 1) { // RELOC2 | RELOC3 + subOffset += seg->mapped; + numBytes = 2 + superType; + } else if (superType < 14) { // INTERSEG1--12 + uint8_t segnum = seg->data[offset + 2]; + for (Segment *sub = segments; sub != NULL; sub = sub->next) { + if (sub->segnum == segnum) { + subOffset += sub->mapped; + break; + } + } + numBytes = 3; + } else if (superType < 26) { // INTERSEG13--24 + uint8_t segnum = superType - 13; + for (Segment *sub = segments; sub != NULL; sub = sub->next) { + if (sub->segnum == segnum) { + subOffset += sub->mapped; + break; + } + } + numBytes = 2; + } else { // INTERSEG25--36 + uint8_t segnum = superType - 25; + for (Segment *sub = segments; sub != NULL; sub = sub->next) { + if (sub->segnum == segnum) { + subOffset += sub->mapped; + break; + } + } + subOffset >>= 16; + numBytes = 2; + } + patch(seg->data + offset, numBytes, subOffset); + } + superPage += 256; + } + } + break; + default: + if (opcode < 0xe0) { + memcpy(seg->data + pc - seg->mapped, p, opcode); p += opcode; + pc += opcode; + } else { + fprintf(stderr, "Unknown segment code: %x\n", opcode); + exit(-1); + } + break; + } + } + + memcpy(filename, prefix, prefixLen); + int numLen = 3; + if (seg->segnum < 0x10) { + numLen = 1; + } else if (seg->segnum < 0x100) { + numLen = 2; + } + hexout(filename + prefixLen, seg->segnum, numLen); + filename[prefixLen + numLen] = 0; + memcpy(mapname, filename, prefixLen + numLen); + memcpy(mapname + prefixLen + numLen, ".map\0", 5); + + FILE *f = fopen(filename, "wb"); + if (!f) { + fprintf(stderr, "Failed to create '%s'\n", filename); + exit(-1); + } + fwrite(seg->data, 1, seg->length, f); + fclose(f); + f = fopen(mapname, "wb"); + if (!f) { + fprintf(stderr, "Failed to create '%s'\n", mapname); + exit(-1); + } + fprintf(f, "gMAP \"%s\"\n", filename); + fprintf(f, "sORG $%x\n", seg->mapped); + if ((seg->kind & 0x1f) == 0) { // code + fprintf(f, "$%x:\n", seg->mapped + seg->entry); + } + fclose(f); + fprintf(stdout, "Extracted Segment #$%x %s into %s\n", seg->segnum, + seg->name, filename); + fprintf(stdout, "Created map %s\n", mapname); + } + free(filename); +} diff --git a/parser.c b/parser.c new file mode 100644 index 0000000..7c5e460 --- /dev/null +++ b/parser.c @@ -0,0 +1,66 @@ +/** + * @copyright 2018 Sean Kasun + * Routines for parsing a simple config file + */ + +#include "parser.h" +#include +#include +#include + +void fail(ConfigFile *f, char *format, ...) { + // calculate line and column + int line = 1; + int col = 1; + bool done = false; + while (f->p > f->start) { + if (*f->p == '\n') { + done = true; + line++; + } + if (!done) { + col++; + } + f->p--; + } + va_list args; + va_start(args, format); + fprintf(stderr, "%s[%d,%d] Error: ", f->filename, line, col); + vfprintf(stderr, format, args); + fprintf(stderr, "\n"); + va_end(args); + exit(-1); +} + +void eatSpaces(ConfigFile *f) { + while (f->p < f->end && isspace(*f->p)) { + f->p++; + } +} + +bool token(ConfigFile *f, char ch) { + eatSpaces(f); + if (f->p < f->end && *f->p == ch) { // found it, consume + f->p++; + return true; + } + // not found, don't consume anything + return false; +} + +uint32_t hex(ConfigFile *f) { + eatSpaces(f); + uint32_t res = 0; + while (f->p < f->end && isxdigit(*f->p)) { + res <<= 4; + if (*f->p >= '0' && *f->p <= '9') { + res |= *f->p - '0'; + } else if (*f->p >= 'a' && *f->p <= 'f') { + res |= *f->p - 'a' + 10; + } else if (*f->p >= 'A' && *f->p <= 'F') { + res |= *f->p - 'A' + 10; + } + f->p++; + } + return res; +} diff --git a/parser.h b/parser.h new file mode 100644 index 0000000..5b8782f --- /dev/null +++ b/parser.h @@ -0,0 +1,22 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * Routines for parsing simple config files + */ + +#include +#include +#include + +typedef struct { + uint8_t *start; + uint8_t *p; + uint8_t *end; + const char *filename; +} ConfigFile; + +extern void fail(ConfigFile *f, char *format, ...); +extern void eatSpaces(ConfigFile *f); +extern bool token(ConfigFile *f, char ch); +extern uint32_t hex(ConfigFile *f); diff --git a/pascal/ace.p b/pascal/ace.p new file mode 100755 index 0000000..fb258f1 --- /dev/null +++ b/pascal/ace.p @@ -0,0 +1,42 @@ +{******************************************** +; File: ACE.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT ACE; +INTERFACE +USES TYPES; + +(* *** Toolset Errors *** +CONST +aceNoError = $0; {Error - } +aceIsActive = $1D01; {Error - } +aceBadDP = $1D02; {Error - } +aceNotActive = $1D03; {Error - } +aceNoSuchParam = $1D04; {Error - } +aceBadMethod = $1D05; {Error - } +aceBadSrc = $1D06; {Error - } +aceBadDest = $1D07; {Error - } +aceDataOverlap = $1D08; {Error - } +aceNotImplemented = $1DFF; {Error - } + *** Toolset Errors *** *) + +PROCEDURE ACEBootInit ; Tool $1D,$01; +PROCEDURE ACEStartUp ( dPageAddr:Integer) ; Tool $1D,$02; +PROCEDURE ACEShutDown ; Tool $1D,$03; +FUNCTION ACEVersion : Integer ; Tool $1D,$04; +PROCEDURE ACEReset ; Tool $1D,$05; +FUNCTION ACEStatus : Boolean ; Tool $1D,$06; +FUNCTION ACEInfo ( infoItemCode:Integer) : Longint ; Tool $1D,$07; +PROCEDURE ACECompBegin ; Tool $1D,$0B; +PROCEDURE ACECompress ( src:Handle; srcOffset:Longint; dest:Handle; +destOffset:Longint; nBlks:Integer; method:Integer) ; Tool $1D,$09; +PROCEDURE ACEExpand ( src:Handle; srcOffset:Longint; dest:Handle; +destOffset:Longint; nBlks:Integer; method:Integer) ; Tool $1D,$0A; +PROCEDURE ACEExpBegin ; Tool $1D,$0C; +IMPLEMENTATION +END. diff --git a/pascal/adb.p b/pascal/adb.p new file mode 100755 index 0000000..697d940 --- /dev/null +++ b/pascal/adb.p @@ -0,0 +1,102 @@ +{******************************************** +; File: ADB.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT ADB; +INTERFACE +USES TYPES; +CONST + +(* *** Toolset Errors *** +cmndIncomplete = $0910; {error - Command not completed. } +cantSync = $0911; {error - Can't synchronize } +adbBusy = $0982; {error - Busy (command pending) } +devNotAtAddr = $0983; {error - Device not present at address } +srqListFull = $0984; {error - List full } + *** Toolset Errors *** *) + +readModes = $000A; {ReadKeyMicroData - } +readConfig = $000B; {ReadKeyMicroData - } +readADBError = $000C; {ReadKeyMicroData - } +readVersionNum = $000D; {ReadKeyMicroData - } +readAvailCharSet = $000E; {ReadKeyMicroData - } +readAvailLayout = $000F; {ReadKeyMicroData - } +readMicroMem = $0009; {ReadKeyMicroMem - } +abort = $0001; {SendInfo - command } +resetKbd = $0002; {SendInfo - command } +flushKbd = $0003; {SendInfo - command } +setModes = $0004; {SendInfo - 2nd param is pointer to mode byte } +clearModes = $0005; {SendInfo - 2nd param is pointer to mode Byte } +setConfig = $0006; {SendInfo - 2nd param is pointer to SetConfigRec } +synch = $0007; {SendInfo - 2nd param is pointer to SynchRec } +writeMicroMem = $0008; {SendInfo - 2nd param is pointer to MicroControlMemRec } +resetSys = $0010; {SendInfo - command } +keyCode = $0011; {SendInfo - 2nd param is pointer to key code byte. } +resetADB = $0040; {SendInfo - command } +transmitADBBytes = $0047; {SendInfo - add number of bytes to this } +enableSRQ = $0050; {SendInfo - command - ADB address in low nibble } +flushADBDevBuf = $0060; {SendInfo - command - ADB address in low nibble } +disableSRQ = $0070; {SendInfo - command - ADB address in low nibble } +transmit2ADBBytes = $0080; {SendInfo - add ADB address to this } +listen = $0080; {SendInfo - adbCommand = listen + ( 16 * reg) + (adb address) } +talk = $00C0; {SendInfo - adbCommand = talk + ( 16 * reg) + (adb address) } + +TYPE +ReadConfigRecPtr = ^ReadConfigRec; +ReadConfigRec = PACKED RECORD + rcRepeatDelay : Byte; { Output Byte: Repeat / Delay } + rcLayoutOrLang : Byte; { Output Byte: Layout / Language } + rcADBAddr : Byte; { Output Byte: ADB address - keyboard and mouse } +END; +SetConfigRecPtr = ^SetConfigRec; +SetConfigRec = PACKED RECORD + scADBAddr : Byte; { keyboard and mouse } + scLayoutOrLang : Byte; + scRepeatDelay : Byte; +END; +SynchRecPtr = ^SynchRec; +SynchRec = PACKED RECORD + synchMode : Byte; + synchKybdMouseAddr : Byte; + synchLayoutOrLang : Byte; + synchRepeatDelay : Byte; +END; +ScaleRecPtr = ^ScaleRec; +ScaleRec = RECORD + xDivide : Integer; + yDivide : Integer; + xOffset : Integer; + yOffset : Integer; + xMultiply : Integer; + yMultiply : Integer; +END; +PROCEDURE ADBBootInit ; Tool $09,$01; +PROCEDURE ADBStartUp ; Tool $09,$02; +PROCEDURE ADBShutDown ; Tool $09,$03; +FUNCTION ADBVersion : Integer ; Tool $09,$04; +PROCEDURE ADBReset ; Tool $09,$05; +FUNCTION ADBStatus : Boolean ; Tool $09,$06; +PROCEDURE AbsOff ; Tool $09,$10; +PROCEDURE AbsOn ; Tool $09,$0F; +PROCEDURE AsyncADBReceive ( compPtr:Ptr) ; Tool $09,$0D; +PROCEDURE ClearSRQTable ; Tool $09,$16; +PROCEDURE GetAbsScale (VAR dataInPtr:ScaleRec) ; Tool $09,$13; +FUNCTION ReadAbs : Integer ; Tool $09,$11; +PROCEDURE ReadKeyMicroData ( dataLength:Integer; dataPtr:Ptr; +adbCommand:Integer) ; Tool $09,$0A; +PROCEDURE ReadKeyMicroMem ( dataLength:Integer; dataPtr:Ptr; +adbCommand:Integer) ; Tool $09,$0B; +PROCEDURE SendInfo ( dataLength:Integer; dataPtr:Ptr; adbCommand:Integer) ; +Tool $09,$09; +PROCEDURE SetAbsScale ( dataOutPtr:ScaleRec) ; Tool $09,$12; +PROCEDURE SRQPoll ( compPtr:Ptr; adbRegAddr:Integer) ; Tool $09,$14; +PROCEDURE SRQRemove ( adbRegAddr:Integer) ; Tool $09,$15; +PROCEDURE SyncADBReceive ( inputWord:Integer; compPtr:Ptr; adbCommand:Integer) +; Tool $09,$0E; +IMPLEMENTATION +END. diff --git a/pascal/applesharefst.p b/pascal/applesharefst.p new file mode 100755 index 0000000..f2df121 --- /dev/null +++ b/pascal/applesharefst.p @@ -0,0 +1,166 @@ +{******************************************** +; File: AppleShareFST.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT APPLESHAREFST; +INTERFACE +USES TYPES,GSOS; +CONST + +ASBufferControl = $0001; {Command Number - } +ASByteRangeLock = $0002; {Command Number - } +ASSpecialOpenFork = $0003; {Command Number - } +ASGetPrivileges = $0004; {Command Number - } +ASSetPrivileges = $0005; {Command Number - } +ASUserInfo = $0006; {Command Number - } +ASCopyFile = $0007; {Command Number - } +ASGetUserPath = $0008; {Command Number - } +ASOpenDesktop = $0009; {Command Number - } +ASCloseDesktop = $000A; {Command Number - } +ASGetComment = $000B; {Command Number - } +ASSetComment = $000C; {Command Number - } +ASGetServerName = $000D; {Command Number - } +appleShareNetError = $0088; {Error - AppleShare Network Error } +unknownUser = $007E; {Error - specified user name not registered } +unknownGroup = $007F; {Error - specified group name not the name of a group } +lockRange = $8000; {Mask - } +relativeToEOF = $4000; {Mask - } +seeFolders = $00; {Mask - } +seeFiles = $02; {Mask - } +makeChanges = $0004; {Mask - } +folderOwner = $80; {Mask - } +onDesktop = $0001; {File Info Mask - } +bFOwnAppl = $0002; {File Info Mask - used internally } +bFNever = $0010; {File Info Mask - never SwitchLaunch } +bFAlways = $0020; {File Info Mask - always SwitchLaunch } +shareApplication = $0040; {File Info Mask - set if file is a shareable +application } +fileIsInited = $0100; {File Info Mask - seen by Finder } +fileHasChanged = $0200; {File Info Mask - used internally by Finder } +fileIsBusy = $0400; {File Info Mask - copied from File System busy bit } +fileNoCopy = $0800; {File Info Mask - not used in 5.0 and later, formally BOZO +} +fileIsSystem = $1000; {File Info Mask - set if file is a system file } +fileHasBundle = $2000; {File Info Mask - } +fileIsInvisible = $4000; {File Info Mask - } +fileIsLocked = $8000; {File Info Mask - } +inTrashWindow = $FFFD; {Window Info Mask - } +inDesktopWindow = $FFFE; {Window Info Mask - } +inDiskWindow = $0000; {Window Info Mask - } +requestReadAccess = $0000; {accessWord Mask - } +requestWriteAccess = $0002; {accessWord Mask - } +denyReadAccess = $0010; {accessWord Mask - } +denyWriteAccess = $0020; {accessWord Mask - } +dataForkNum = $0000; {forkNum Mask - } +resourceForkNum = $0001; {forkNum Mask - } + +TYPE +CommandBlock = RECORD + pCount : Integer; + fstNum : Integer; + commandNum : Integer; +END; +BufferControlRecPtr = ^BufferControlRec; +BufferControlRec = RECORD + pBlock : CommandBlock; + refNum : Integer; + flags : Integer; +END; +SpecialOpenForkRecPtr = ^SpecialOpenForkRec; +SpecialOpenForkRec = RECORD + pBlock : CommandBlock; + pathname : GSString255Ptr; + accessMode : Integer; + forkNum : Integer; +END; +ByteRangeLockRecPtr = ^ByteRangeLockRec; +ByteRangeLockRec = RECORD + pBlock : CommandBlock; + referenceNum : Integer; + lockFlag : Integer; + fileOffset : Longint; + rangeLength : Longint; + rangeStart : Longint; +END; +GetAccessRightsRecPtr = ^GetAccessRightsRec; +GetAccessRightsRec = PACKED RECORD + reserved : Byte; + world : Byte; + group : Byte; + owner : Byte; +END; +GetPrivilegesRecPtr = ^GetPrivilegesRec; +GetPrivilegesRec = RECORD + pBlock : CommandBlock; + pathname : GSString255Ptr; + accessRights : GetAccessRightsRec; + ownerName : ResultBuf255Ptr; + groupName : ResultBuf255Ptr; +END; +SetAccessRightsRecPtr = ^SetAccessRightsRec; +SetAccessRightsRec = PACKED RECORD + userSummary : Byte; + world : Byte; + group : Byte; + owner : Byte; +END; +SetPrivilegesRecPtr = ^SetPrivilegesRec; +SetPrivilegesRec = RECORD + pBlock : CommandBlock; + pathname : GSString255Ptr; + accessRights : SetAccessRightsRec; + ownerName : ResultBuf255Ptr; + groupName : ResultBuf255Ptr; +END; +UserInfoRecPtr = ^UserInfoRec; +UserInfoRec = RECORD + pBlock : CommandBlock; + deviceNum : Integer; + userName : ResultBuf255Ptr; + primaryGroupName : ResultBuf255Ptr; +END; +CopyFileRecPtr = ^CopyFileRec; +CopyFileRec = RECORD + pBlock : CommandBlock; + sourcePathname : GSString255Ptr; + destPathname : GSString255Ptr; +END; +GetUserPathRecPtr = ^GetUserPathRec; +GetUserPathRec = RECORD + pBlock : CommandBlock; + prefix : ResultBuf255Ptr; +END; +DesktopRecPtr = ^DesktopRec; +DesktopRec = RECORD + pBlock : CommandBlock; + desktopRefNum : Integer; + pathname : GSString255Ptr; +END; +GetCommentRecPtr = ^GetCommentRec; +GetCommentRec = RECORD + pBlock : CommandBlock; + desktopRefNum : Integer; + pathname : GSString255Ptr; + comment : ResultBuf255Ptr; +END; +SetCommentRecPtr = ^SetCommentRec; +SetCommentRec = RECORD + pBlock : CommandBlock; + desktopRefNum : Integer; + pathname : GSString255Ptr; + comment : GSString255Ptr; +END; +GetServerNameRecPtr = ^GetServerNameRec; +GetServerNameRec = RECORD + pBlock : CommandBlock; + pathname : GSString255Ptr; + serverName : ResultBuf255Ptr; + zoneName : ResultBuf255Ptr; +END; +IMPLEMENTATION +END. diff --git a/pascal/controls.p b/pascal/controls.p new file mode 100755 index 0000000..ce909c4 --- /dev/null +++ b/pascal/controls.p @@ -0,0 +1,274 @@ +{******************************************** +; File: Controls.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT CONTROLS; +INTERFACE +USES TYPES,QUICKDRAW,EVENTS; +CONST + +wmNotStartedUp = $1001; {error - Window manager was not started first. } +noConstraint = $0000; {Axis Parameter - No constraint on movement. } +hAxisOnly = $0001; {Axis Parameter - Horizontal axis only. } +vAxisOnly = $0002; {Axis Parameter - Vertical axis only. } +simpRound = $0000; {CtlFlag - Simple button flag } +upFlag = $0001; {CtlFlag - Scroll bar flag. } +boldButton = $0001; {CtlFlag - Bold round cornered outlined button. } +simpBRound = $0001; {CtlFlag - Simple button flag } +downFlag = $0002; {CtlFlag - Scroll bar flag. } +simpSquare = $0002; {CtlFlag - Simple button flag } +simpDropSquare = $0003; {CtlFlag - Simple button flag } +leftFlag = $0004; {CtlFlag - Scroll bar flag. } +rightFlag = $0008; {CtlFlag - Scroll bar flag. } +dirScroll = $0010; {CtlFlag - Scroll bar flag. } +horScroll = $0010; {CtlFlag - Scroll bar flag. } +family = $007F; {CtlFlag - Mask for radio button family number } +ctlInVis = $0080; {CtlFlag - invisible mask for any type of control } +inListBox = $88; {CtlFlag - } +simpleProc = $00000000; {CtlProc - } +checkProc = $02000000; {CtlProc - } +radioProc = $04000000; {CtlProc - } +scrollProc = $06000000; {CtlProc - } +growProc = $08000000; {CtlProc - } +drawCtl = $0000; {DefProc - Draw control command. } +calcCRect = $0001; {DefProc - Compute drag RECT command. } +testCtl = $0002; {DefProc - Hit test command. } +initCtl = $0003; {DefProc - Initialize command. } +dispCtl = $0004; {DefProc - Dispose command. } +posCtl = $0005; {DefProc - Move indicator command. } +thumbCtl = $0006; {DefProc - Compute drag parameters command. } +dragCtl = $0007; {DefProc - Drag command. } +autoTrack = $0008; {DefProc - Action command. } +newValue = $0009; {DefProc - Set new value command. } +setParams = $000A; {DefProc - Set new parameters command. } +moveCtl = $000B; {DefProc - Move command. } +recSize = $000C; {DefProc - Return record size command. } +noHilite = $0000; {hiliteState - Param to HiliteControl } +inactiveHilite = $00FF; {hiliteState - Param to HiliteControl } +noPart = $0000; {PartCode - } +simpleButton = $0002; {PartCode - } +checkBox = $0003; {PartCode - } +radioButton = $0004; {PartCode - } +upArrow = $0005; {PartCode - } +downArrow = $0006; {PartCode - } +pageUp = $0007; {PartCode - } +pageDown = $0008; {PartCode - } +growBox = $000A; {PartCode - } +thumb = $0081; {PartCode - } +fCtlTarget = $8000; {CtlRec.ctlMoreFlags - is current target of typing commands +} +fCtlCanBeTarget = $4000; {CtlRec.ctlMoreFlags - can be made the target control +} +fCtlWantEvents = $2000; {CtlRec.ctlMoreFlags - control can be called view +SendEventToCtl } +fCtlProcRefNotPtr = $1000; {CtlRec.ctlMoreFlags - set = ID of defproc, clear = +pointer to defproc } +fCtlTellAboutSize = $0800; {CtlRec.ctlMoreFlags - set if ctl needs notification +when size of owning window changes } +fCtlIsMultiPar = $0400; {CtlRec.ctlMoreFlags - set if ctl needs notification to +be hidden } +titleIsPtr = $00; {Ctl Verb - } +titleIsHandle = $01; {Ctl Verb - } +titleIsResource = $02; {Ctl Verb - } +colorTableIsPtr = $00; {Ctl Verb - } +colorTableIsHandle = $04; {Ctl Verb - } +colorTableIsResource = $08; {Ctl Verb - } +ctlHandleEvent = $0D; {DefProc message - } +ctlChangeTarget = $0E; {DefProc message - } +ctlChangeBounds = $0F; {DefProc message - } +ctlWindChangeSize = $10; {DefProc message - } +ctlHandleTab = $11; {DefProc message - } +ctlHideCtl = $12; {DefProc message - } +singlePtr = $0000; {InputVerb - } +singleHandle = $0001; {InputVerb - } +singleResource = $0002; {InputVerb - } +ptrToPtr = $0003; {InputVerb - } +ptrToHandle = $0004; {InputVerb - } +ptrToResource = $0005; {InputVerb - } +handleToPtr = $0006; {InputVerb - } +handleToHandle = $0007; {InputVerb - } +handleToResource = $0008; {InputVerb - } +resourceToResource = $0009; {InputVerb - } +simpleButtonControl = $80000000; {ProcRefs - } +checkControl = $82000000; {ProcRefs - } +radioControl = $84000000; {ProcRefs - } +scrollBarControl = $86000000; {ProcRefs - } +growControl = $88000000; {ProcRefs - } +statTextControl = $81000000; {ProcRefs - } +editLineControl = $83000000; {ProcRefs - } +editTextControl = $85000000; {ProcRefs - } +popUpControl = $87000000; {ProcRefs - } +listControl = $89000000; {ProcRefs - } +iconButtonControl = $07FF0001; {ProcRefs - } +pictureControl = $8D000000; {ProcRefs - } + +(* *** Toolset Errors *** +noCtlError = $1004; {Error - no controls in window } +noSuperCtlError = $1005; {Error - no super controls in window } +noCtlTargetError = $1006; {Error - no target super control } +notSuperCtlError = $1007; {Error - action can only be done on super control } +canNotBeTargetError = $1008; {Error - conrol cannot be made target } +noSuchIDError = $1009; {Error - specified ID cannot be found } +tooFewParmsError = $100A; {Error - not enough params specified } +noCtlToBeTargetError = $100B; {Error - NextCtl call, no ctl could be target } +noWind_Err = $100C; {Error - there is no front window } + *** Toolset Errors *** *) + +TYPE +WindowPtr = GrafPortPtr ; + + +BarColorsHndl = ^BarColorsPtr; +BarColorsPtr = ^BarColors; +BarColors = RECORD + barOutline : Integer; { color for outlining bar, arrows, and thumb } + barNorArrow : Integer; { color of arrows when not highlighted } + barSelArrow : Integer; { color of arrows when highlighted } + barArrowBack : Integer; { color of arrow box's background } + barNorThumb : Integer; { color of thumb's background when not highlighted } + barSelThumb : Integer; { color of thumb's background when highlighted } + barPageRgn : Integer; { color and pattern page region: high byte - 1= +dither, 0 = solid } + barInactive : Integer; { color of scroll bar's interior when inactive } +END; +BoxColorsHndl = ^BoxColorsPtr; +BoxColorsPtr = ^BoxColors; +BoxColors = RECORD + boxReserved : Integer; { reserved } + boxNor : Integer; { color of box when not checked } + boxSel : Integer; { color of box when checked } + boxTitle : Integer; { color of check box's title } +END; +BttnColorsHndl = ^BttnColorsPtr; +BttnColorsPtr = ^BttnColors; +BttnColors = RECORD + bttnOutline : Integer; { color of outline } + bttnNorBack : Integer; { color of background when not selected } + bttnSelBack : Integer; { color of background when selected } + bttnNorText : Integer; { color of title's text when not selected } + bttnSelText : Integer; { color of title's text when selected } +END; +CtlRecHndlPtr = ^CtlRecHndl; +CtlRecHndl = ^CtlRecPtr; +CtlRecPtr = ^CtlRec; +CtlRec = PACKED RECORD + ctlNext : CtlRecHndl; { Handle of next control. } + ctlOwner : WindowPtr; { Pointer to control's window. } + ctlRect : Rect; { Enclosing rectangle. } + ctlFlag : Byte; { Bit flags. } + ctlHilite : Byte; { Highlighted part. } + ctlValue : Integer; { Control's value. } + ctlProc : LongProcPtr; { Control's definition procedure. } + ctlAction : LongProcPtr; { Control's action procedure. } + ctlData : Longint; { Reserved for CtrlProc's use. } + ctlRefCon : Longint; { Reserved for application's use. } + ctlColor : Ptr; { Pointer to appropriate color table. } + ctlReserved : PACKED ARRAY[1..16] OF Byte; { Reserved for future expansion +} + ctlID : Longint; + ctlMoreFlags : Integer; + ctlVersion : Integer; +END; +LimitBlkHndl = ^LimitBlkPtr; +LimitBlkPtr = ^LimitBlk; +LimitBlk = RECORD + boundRect : Rect; { Drag bounds. } + slopRect : Rect; { Cursor bounds. } + axisParam : Integer; { Movement constrains. } + dragPatt : Ptr; { Pointer to 32 byte Pattern for drag outline. } +END; +RadioColorsHndl = ^RadioColorsPtr; +RadioColorsPtr = ^RadioColors; +RadioColors = RECORD + radReserved : Integer; { reserved } + radNor : Integer; { color of radio button when off } + radSel : Integer; { color of radio button when on } + radTitle : Integer; { color of radio button's title text } +END; +PROCEDURE CtlBootInit ; Tool $10,$01; +PROCEDURE CtlStartUp ( userID:Integer; dPageAddr:Integer) ; Tool $10,$02; +PROCEDURE CtlShutDown ; Tool $10,$03; +FUNCTION CtlVersion : Integer ; Tool $10,$04; +PROCEDURE CtlReset ; Tool $10,$05; +FUNCTION CtlStatus : Boolean ; Tool $10,$06; +PROCEDURE CtlNewRes ; Tool $10,$12; +PROCEDURE DisposeControl ( theControlHandle:CtlRecHndl) ; Tool $10,$0A; +PROCEDURE DragControl ( startX:Integer; startY:Integer; limitRectPtr:Rect; +slopRectPtr:Rect; dragFlag:Integer; theControlHandle:CtlRecHndl) ; Tool +$10,$17; +FUNCTION DragRect ( actionProcPtr:VoidProcPtr; dragPatternPtr:Pattern; +startX:Integer; startY:Integer; dragRectPtr:Rect; limitRectPtr:Rect; +slopRectPtr:Rect; dragFlag:Integer) : Longint ; Tool $10,$1D; +PROCEDURE DrawControls ( theWindowPtr:WindowPtr) ; Tool $10,$10; +PROCEDURE DrawOneCtl ( theControlHandle:CtlRecHndl) ; Tool $10,$25; +PROCEDURE EraseControl ( theControlHandle:CtlRecHndl) ; Tool $10,$24; +FUNCTION FindControl (VAR foundCtl:CtlRecHndl; pointX:Integer; pointY:Integer; +theWindowPtr:WindowPtr) : Integer ; Tool $10,$13; +FUNCTION GetCtlAction ( theControlHandle:CtlRecHndl) : LongProcPtr ; Tool +$10,$21; +FUNCTION GetCtlDPage : Integer ; Tool $10,$1F; +FUNCTION GetCtlParams ( theControlHandle:CtlRecHndl) : Longint ; Tool $10,$1C; +FUNCTION GetCtlRefCon ( theControlHandle:CtlRecHndl) : Longint ; Tool $10,$23; +FUNCTION GetCtlTitle ( theControlHandle:CtlRecHndl) : Ptr ; Tool $10,$0D; +FUNCTION GetCtlValue ( theControlHandle:CtlRecHndl) : Integer ; Tool $10,$1A; +FUNCTION GrowSize : Longint ; Tool $10,$1E; +PROCEDURE HideControl ( theControlHandle:CtlRecHndl) ; Tool $10,$0E; +PROCEDURE HiliteControl ( hiliteState:Integer; theControlHandle:CtlRecHndl) ; +Tool $10,$11; +PROCEDURE KillControls ( theWindowPtr:WindowPtr) ; Tool $10,$0B; +PROCEDURE MoveControl ( newX:Integer; newY:Integer; +theControlHandle:CtlRecHndl) ; Tool $10,$16; +FUNCTION NewControl ( theWindowPtr:WindowPtr; boundsRectPtr:Rect; titlePtr:Ptr; +flag:Integer; value :Integer; param1:Integer; param2:Integer; +defProcPtr:LongProcPtr; refCon:Longint; U__colorTablePtr:Ptr) : CtlRecHndl ; +Tool $10,$09; +PROCEDURE SetCtlAction ( newActionPtr:LongProcPtr; theControlHandle:CtlRecHndl) +; Tool $10,$20; +FUNCTION SetCtlIcons ( newFontHandle:FontHndl) : FontHndl ; Tool $10,$18; +PROCEDURE SetCtlParams ( param2:Integer; param1:Integer; +theControlHandle:CtlRecHndl) ; Tool $10,$1B; +PROCEDURE SetCtlRefCon ( newRefCon:Longint; theControlHandle:CtlRecHndl) ; +Tool $10,$22; +PROCEDURE SetCtlTitle ( title:Str255; theControlHandle:CtlRecHndl) ; Tool +$10,$0C; +PROCEDURE SetCtlValue ( curValue:Integer; theControlHandle:CtlRecHndl) ; Tool +$10,$19; +PROCEDURE ShowControl ( theControlHandle:CtlRecHndl) ; Tool $10,$0F; +FUNCTION TestControl ( pointX:Integer; pointY:Integer; +theControlHandle:CtlRecHndl) : Integer ; Tool $10,$14; +FUNCTION TrackControl ( startX:Integer; startY:Integer; +actionProcPtr:LongProcPtr; theControlHndl:CtlRecHndl) : Integer ; Tool $10,$15; +FUNCTION NewControl2 ( ownerPtr:WindowPtr; inputDesc:RefDescriptor; +inputRef:Ref) : CtlRecHndl ; Tool $10,$31; +FUNCTION FindTargetCtl : CtlRecHndl ; Tool $10,$26; +FUNCTION MakeNextCtlTarget : CtlRecHndl ; Tool $10,$27; +PROCEDURE MakeThisCtlTarget ( targetCtlRecHndl:CtlRecHndl) ; Tool $10,$28; +PROCEDURE CallCtlDefProc ( U__ctlRecHndl:CtlRecHndl; defProcMessage:Integer; +U__param:Longint) ; Tool $10,$2C; +PROCEDURE NotifyControls ( U__mask:Integer; message:Integer; U__param:Longint; +window:WindowPtr) ; Tool $10,$2D; +FUNCTION SendEventToCtl ( targetOnlyFlag:Integer; U__WindowPtr:WindowPtr; +extendedTaskRecPtr:Ptr) : Boolean ; Tool $10,$29; +FUNCTION GetCtlID ( theCtlHandle:CtlRecHndl) : Longint ; Tool $10,$2A; +PROCEDURE SetCtlID ( newID:Longint; theCtlHandle:CtlRecHndl) ; Tool $10,$2B; +FUNCTION GetCtlMoreFlags ( theCtlHandle:CtlRecHndl) : Longint ; Tool $10,$2E; +FUNCTION SetCtlMoreFlags ( newID:Longint; theCtlHandle:CtlRecHndl) : Longint ; +Tool $10,$2F; +FUNCTION GetCtlHandleFromID ( U__WindowPtr:WindowPtr; ControlID:Longint) : +CtlRecHndl ; Tool $10,$30; +PROCEDURE SetCtlParamPtr ( SubArrayPtr:Ptr) ; Tool $10,$34; +FUNCTION GetCtlParamPtr : Ptr ; Tool $10,$35; +FUNCTION CMLoadResource ( U__ResType:Integer; U__ResID:Longint) : Handle ; Tool +$10,$32; +PROCEDURE CMReleaseResource ( U__ResType:Integer; U__ResID:Longint) ; Tool +$10,$33; +PROCEDURE InvalCtls ( U__WindowPtr:Longint) ; Tool $10,$37; +PROCEDURE NotifyCtls ( moreFlagsMask:Integer; message:Integer; param:Longint; +theGrafPortPtr:GrafPort) ; Tool $10,$2D; +IMPLEMENTATION +END. diff --git a/pascal/ctiutils.p b/pascal/ctiutils.p new file mode 100755 index 0000000..1c62def --- /dev/null +++ b/pascal/ctiutils.p @@ -0,0 +1,38 @@ +UNIT CTIUtils; + +INTERFACE + +USES + +FUNCTION Int2String + +FUNCTION LongInt2String + +FUNCTION Real2String + + +FUNCTION String2Int + +FUNCTION String2LongInt + +FUNCTION String2Real + + +procedure P2GSstring + + +procedure GS2Pstring + + + +PROCEDURE StuffHex + + +PROCEDURE CallCode + + nBytesIn: integer; BytesIn: univ ptr; + nBytesOut: integer; BytesOut: univ ptr ); + +IMPLEMENTATION + +END. diff --git a/pascal/desk.p b/pascal/desk.p new file mode 100755 index 0000000..076c514 --- /dev/null +++ b/pascal/desk.p @@ -0,0 +1,67 @@ +{******************************************** +; File: Desk.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT DESK; +INTERFACE +USES TYPES,QUICKDRAW,EVENTS; +CONST + +(* *** Toolset Errors *** +daNotFound = $0510; {error - desk accessory not found } +notSysWindow = $0511; {error - not the system window } + *** Toolset Errors *** *) + +eventAction = $0001; {NDA action code - } +runAction = $0002; {NDA action code - } +undoAction = $0005; {NDA action code - } +cutAction = $0006; {NDA action code - } +copyAction = $0007; {NDA action code - } +pasteAction = $0008; {NDA action code - } +clearAction = $0009; {NDA action code - } +cursorAction = $0003; {NDAaction code - } +kUndo = $0001; {System Edit - edit type } +kCut = $0002; {System Edit - edit type } +kCopy = $0003; {System Edit - edit type } +kPaste = $0004; {System Edit - edit type } +kClear = $0005; {System Edit - edit type } +PROCEDURE DeskBootInit ; Tool $05,$01; +PROCEDURE DeskStartUp ; Tool $05,$02; +PROCEDURE DeskShutDown ; Tool $05,$03; +FUNCTION DeskVersion : Integer ; Tool $05,$04; +PROCEDURE DeskReset ; Tool $05,$05; +FUNCTION DeskStatus : Boolean ; Tool $05,$06; +PROCEDURE ChooseCDA ; Tool $05,$11; +PROCEDURE CloseAllNDAs ; Tool $05,$1D; +PROCEDURE CloseNDA ( refNum:Integer) ; Tool $05,$16; +PROCEDURE CloseNDAByWinPtr ( theWindowPtr:GrafPortPtr) ; Tool $05,$1C; +PROCEDURE FixAppleMenu ( startingID:Integer) ; Tool $05,$1E; +FUNCTION GetDAStrPtr : Ptr ; Tool $05,$14; +FUNCTION GetNumNDAs : Integer ; Tool $05,$1B; +PROCEDURE InstallCDA ( idHandle:Handle) ; Tool $05,$0F; +PROCEDURE InstallNDA ( idHandle:Handle) ; Tool $05,$0E; +FUNCTION OpenNDA ( idNum:Integer) : Integer ; Tool $05,$15; +PROCEDURE RestAll ; Tool $05,$0C; +PROCEDURE RestScrn ; Tool $05,$0A; +PROCEDURE SaveAll ; Tool $05,$0B; +PROCEDURE SaveScrn ; Tool $05,$09; +PROCEDURE SetDAStrPtr ( altDispHandle:Handle; stringTablePtr:Ptr) ; Tool +$05,$13; +PROCEDURE SystemClick ( eventRecPtr:EventRecord; theWindowPtr:GrafPortPtr; +findWndwResult:Integer) ; Tool $05,$17; +FUNCTION SystemEdit ( editType:Integer) : Boolean ; Tool $05,$18; +FUNCTION SystemEvent ( eventWhat:Integer; eventMessage:Longint; +eventWhen:Longint; eventWhere:Point; eventMods:Integer) : Boolean ; Tool +$05,$1A; +PROCEDURE SystemTask ; Tool $05,$19; +PROCEDURE AddToRunQ ( headerPtr:Ptr) ; Tool $05,$1F; +PROCEDURE RemoveFromRunQ ( headerPtr:Ptr) ; Tool $05,$20; +PROCEDURE RemoveCDA ( idHandle:Handle) ; Tool $05,$21; +PROCEDURE RemoveNDA ( idHandle:Handle) ; Tool $05,$22; +IMPLEMENTATION +END. diff --git a/pascal/dialogs.p b/pascal/dialogs.p new file mode 100755 index 0000000..6f05fa2 --- /dev/null +++ b/pascal/dialogs.p @@ -0,0 +1,205 @@ +{******************************************** +; File: Dialogs.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT DIALOGS; +INTERFACE +USES TYPES,QUICKDRAW,EVENTS,CONTROLS,WINDOWS,LINEEDIT; +CONST + +(* *** Toolset Errors *** +badItemType = $150A; {error - } +newItemFailed = $150B; {error - } +itemNotFound = $150C; {error - } +notModalDialog = $150D; {error - } + *** Toolset Errors *** *) + +getInitView = $0001; {Command - } +getInitTotal = $0002; {Command - } +getInitValue = $0003; {Command - } +scrollLineUp = $0004; {Command - } +scrollLineDown = $0005; {Command - } +scrollPageUp = $0006; {Command - } +scrollPageDown = $0007; {Command - } +scrollThumb = $0008; {Command - } +buttonItem = $000A; {Item Type - } +checkItem = $000B; {Item Type - } +radioItem = $000C; {Item Type - } +scrollBarItem = $000D; {Item Type - } +userCtlItem = $000E; {Item Type - } +statText = $000F; {Item Type - } +longStatText = $0010; {Item Type - } +editLine = $0011; {Item Type - } +iconItem = $0012; {Item Type - } +picItem = $0013; {Item Type - } +userItem = $0014; {Item Type - } +userCtlItem2 = $0015; {Item Type - } +longStatText2 = $0016; {Item Type - } +itemDisable = $8000; {Item Type - } +minItemType = $000A; {Item Type Range - } +maxItemType = $0016; {Item Type Range - } +ok = $0001; {ItemID - } +cancel = $0002; {ItemID - } +inButton = $0002; {ModalDialog2 - Part code } +inCheckBox = $0003; {ModalDialog2 - Part code } +inRadioButton = $0004; {ModalDialog2 - Part code } +inUpArrow = $0005; {ModalDialog2 - Part code } +inDownArrow = $0006; {ModalDialog2 - Part code } +inPageUp = $0007; {ModalDialog2 - Part code } +inPageDown = $0008; {ModalDialog2 - Part code } +inStatText = $0009; {ModalDialog2 - Part code } +inGrow = $000A; {ModalDialog2 - Part code } +inEditLine = $000B; {ModalDialog2 - Part code } +inUserItem = $000C; {ModalDialog2 - Part code } +inLongStatText = $000D; {ModalDialog2 - Part code } +inIconItem = $000E; {ModalDialog2 - Part code } +inLongStatText2 = $000F; {ModalDialog2 - } +inThumb = $0081; {ModalDialog2 - Part code } +okDefault = $0000; {Stage Bit Vector - } +cancelDefault = $0040; {Stage Bit Vector - } +alertDrawn = $0080; {Stage Bit Vector - } + +atItemListLength = $0005; + +dtItemListLength = $0008; + +TYPE +DialogPtr = WindowPtr ; +ItemTempHndl = ^ItemTempPtr; +ItemTempPtr = ^ItemTemplate; +ItemTemplate = RECORD + itemID : Integer; + itemRect : Rect; + itemType : Integer; + itemDescr : Ptr; + itemValue : Integer; + itemFlag : Integer; + itemColor : Ptr; { pointer to appropriate type of color table } +END; +AlertTempHndl = ^AlertTempPtr; +AlertTempPtr = ^AlertTemplate; +AlertTemplate = RECORD + atBoundsRect : Rect; + atAlertID : Integer; + atStage1 : Byte; + atStage2 : Byte; + atStage3 : Byte; + atStage4 : Byte; + atItemList : ARRAY[1..atItemListLength] OF ItemTempPtr; { Null terminated +array } +END; +DlgTempHndl = ^DlgTempPtr; +DlgTempPtr = ^DialogTemplate; +DialogTemplate = RECORD + dtBoundsRect : Rect; + dtVisible : Boolean; + dtRefCon : Longint; + dtItemList : ARRAY[1..dtItemListLength] OF ItemTempPtr; { Null terminated +array } +END; +IconRecordHndl = ^IconRecordPtr; +IconRecordPtr = ^IconRecord; +IconRecord = RECORD + iconRect : Rect; + iconImage : PACKED ARRAY[1..1] OF Byte; +END; +UserCtlItemPBHndl = ^UserCtlItemPBPtr; +UserCtlItemPBPtr = ^UserCtlItemPB; +UserCtlItemPB = RECORD + defProcParm : Longint; { ? should this be a LongProcPtr? } + titleParm : Ptr; + param2 : Integer; + param1 : Integer; +END; +PROCEDURE DialogBootInit ; Tool $15,$01; +PROCEDURE DialogStartUp ( userID:Integer) ; Tool $15,$02; +PROCEDURE DialogShutDown ; Tool $15,$03; +FUNCTION DialogVersion : Integer ; Tool $15,$04; +PROCEDURE DialogReset ; Tool $15,$05; +FUNCTION DialogStatus : Boolean ; Tool $15,$06; +FUNCTION Alert ( alertTemplatePtr:AlertTemplate; filterProcPtr:WordProcPtr) : +Integer ; Tool $15,$17; +FUNCTION CautionAlert ( alertTemplatePtr:AlertTemplate; +filterProcPtr:WordProcPtr) : Integer ; Tool $15,$1A; +PROCEDURE CloseDialog ( theDialogPtr:DialogPtr) ; Tool $15,$0C; +FUNCTION DefaultFilter ( theDialogPtr:DialogPtr; theEventPtr:EventRecord; +itemHitPtr:IntPtr) : Boolean ; Tool $15,$36; +FUNCTION DialogSelect ( theEventPtr:EventRecord;VAR resultPtr:WindowPtr;VAR +itemHitPtr:Integer) : Boolean ; Tool $15,$11; +PROCEDURE DisableDItem ( theDialogPtr:DialogPtr; itemID:Integer) ; Tool +$15,$39; +PROCEDURE DlgCopy ( theDialogPtr:DialogPtr) ; Tool $15,$13; +PROCEDURE DlgCut ( theDialogPtr:DialogPtr) ; Tool $15,$12; +PROCEDURE DlgDelete ( theDialogPtr:DialogPtr) ; Tool $15,$15; +PROCEDURE DlgPaste ( theDialogPtr:DialogPtr) ; Tool $15,$14; +PROCEDURE DrawDialog ( theDialogPtr:DialogPtr) ; Tool $15,$16; +PROCEDURE EnableDItem ( theDialogPtr:DialogPtr; itemID:Integer) ; Tool +$15,$3A; +PROCEDURE ErrorSound ( soundProcPtr:VoidProcPtr) ; Tool $15,$09; +FUNCTION FindDItem ( theDialogPtr:DialogPtr; thePoint:Point) : Integer ; Tool +$15,$24; +FUNCTION GetAlertStage : Integer ; Tool $15,$34; +FUNCTION GetControlDItem ( theDialogPtr:DialogPtr; itemID:Integer) : CtlRecHndl +; Tool $15,$1E; +FUNCTION GetDefButton ( theDialogPtr:DialogPtr) : Integer ; Tool $15,$37; +PROCEDURE GetDItemBox ( theDialogPtr:DialogPtr; itemID:Integer; +itemBoxPtr:Rect) ; Tool $15,$28; +FUNCTION GetDItemType ( theDialogPtr:DialogPtr; itemID:Integer) : Integer ; +Tool $15,$26; +FUNCTION GetDItemValue ( theDialogPtr:DialogPtr; itemID:Integer) : Integer ; +Tool $15,$2E; +FUNCTION GetFirstDItem ( theDialogPtr:DialogPtr) : Integer ; Tool $15,$2A; +PROCEDURE GetIText ( theDialogPtr:DialogPtr; itemID:Integer;VAR text:Str255) ; +Tool $15,$1F; +PROCEDURE GetNewDItem ( theDialogPtr:DialogPtr; itemTemplatePtr:ItemTemplate) +; Tool $15,$33; +FUNCTION GetNewModalDialog ( dialogTemplatePtr:DlgTempPtr) : DialogPtr ; Tool +$15,$32; +FUNCTION GetNextDItem ( theDialogPtr:DialogPtr; itemID:Integer) : Integer ; +Tool $15,$2B; +PROCEDURE HideDItem ( theDialogPtr:DialogPtr; itemID:Integer) ; Tool $15,$22; +FUNCTION IsDialogEvent ( theEventPtr:EventRecord) : Boolean ; Tool $15,$10; +FUNCTION ModalDialog ( filterProcPtr:WordProcPtr) : Integer ; Tool $15,$0F; +FUNCTION ModalDialog2 ( filterProcPtr:WordProcPtr) : Longint ; Tool $15,$2C; +PROCEDURE NewDItem ( theDialogPtr:DialogPtr; itemID:Integer; itemRectPtr:Rect; +itemType:Integer; itemDescr:Ptr; itemValue:Integer; itemFlag:Integer; +itemColorPtr:Ptr) ; Tool $15,$0D; +FUNCTION NewModalDialog ( dBoundsRectPtr:Rect; dVisibleFlag:Boolean; +dRefCon:Longint) : DialogPtr ; Tool $15,$0A; +FUNCTION NewModelessDialog ( dBoundsRectPtr:Rect; dTitle:Str255; +dBehindPtr:DialogPtr; dFlag:Integer; dRefCon:Longint; dFullSizePtr:Rect) : +DialogPtr ; Tool $15,$0B; +FUNCTION NoteAlert ( alertTemplatePtr:AlertTempPtr; filterProcPtr:WordProcPtr) +: Integer ; Tool $15,$19; +PROCEDURE ParamText ( param0:Str255; param1:Str255; param2:Str255; +param3:Str255) ; Tool $15,$1B; +PROCEDURE RemoveDItem ( theDialogPtr:DialogPtr; itemID:Integer) ; Tool +$15,$0E; +PROCEDURE ResetAlertStage ; Tool $15,$35; +PROCEDURE SelIText ( theDialogPtr:DialogPtr; itemID:Integer; startSel:Integer; +endSel:Integer) ; Tool $15,$21; +PROCEDURE SelectIText ( theDialogPtr:DialogPtr; itemID:Integer; +startSel:Integer; endSel:Integer) ; Tool $15,$21; +PROCEDURE SetDAFont ( fontHandle:FontHndl) ; Tool $15,$1C; +PROCEDURE SetDefButton ( defButtonID:Integer; theDialogPtr:DialogPtr) ; Tool +$15,$38; +PROCEDURE SetDItemBox ( theDialogPtr:DialogPtr; itemID:Integer; +itemBoxPtr:Rect) ; Tool $15,$29; +PROCEDURE SetDItemType ( itemType:Integer; theDialogPtr:DialogPtr; +itemID:Integer) ; Tool $15,$27; +PROCEDURE SetDItemValue ( itemValue:Integer; theDialogPtr:DialogPtr; +itemID:Integer) ; Tool $15,$2F; +PROCEDURE SetIText ( theDialogPtr:DialogPtr; itemID:Integer; theString:Str255) +; Tool $15,$20; +PROCEDURE ShowDItem ( theDialogPtr:DialogPtr; itemID:Integer) ; Tool $15,$23; +FUNCTION StopAlert ( alertTemplatePtr:AlertTempPtr; filterProcPtr:WordProcPtr) +: Integer ; Tool $15,$18; +PROCEDURE UpdateDialog ( theDialogPtr:DialogPtr; updateRgnHandle:RgnHandle) ; +Tool $15,$25; +IMPLEMENTATION +END. diff --git a/pascal/events.p b/pascal/events.p new file mode 100755 index 0000000..dda0479 --- /dev/null +++ b/pascal/events.p @@ -0,0 +1,133 @@ +{******************************************** +; File: Events.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT EVENTS; +INTERFACE +USES TYPES; +CONST + +(* *** Toolset Errors *** +emDupStrtUpErr = $0601; {error - duplicate EMStartup Call } +emResetErr = $0602; {error - can't reset error the Event Manager } +emNotActErr = $0603; {error - event manager not active } +emBadEvtCodeErr = $0604; {error - illegal event code } +emBadBttnNoErr = $0605; {error - illegal button number } +emQSiz2LrgErr = $0606; {error - queue size too large } +emNoMemQueueErr = $0607; {error - not enough memory for queue } +emBadEvtQErr = $0681; {error - fatal sys error - event queue damaged } +emBadQHndlErr = $0682; {error - fatal sys error - queue handle damaged } + *** Toolset Errors *** *) + +nullEvt = $0000; {Event Code - } +mouseDownEvt = $0001; {Event Code - } +mouseUpEvt = $0002; {Event Code - } +keyDownEvt = $0003; {Event Code - } +autoKeyEvt = $0005; {Event Code - } +updateEvt = $0006; {Event Code - } +activateEvt = $0008; {Event Code - } +switchEvt = $0009; {Event Code - } +deskAccEvt = $000A; {Event Code - } +driverEvt = $000B; {Event Code - } +app1Evt = $000C; {Event Code - } +app2Evt = $000D; {Event Code - } +app3Evt = $000E; {Event Code - } +app4Evt = $000F; {Event Code - } +mDownMask = $0002; {Event Masks - } +mUpMask = $0004; {Event Masks - } +keyDownMask = $0008; {Event Masks - } +autoKeyMask = $0020; {Event Masks - } +updateMask = $0040; {Event Masks - } +activeMask = $0100; {Event Masks - } +switchMask = $0200; {Event Masks - } +deskAccMask = $0400; {Event Masks - } +driverMask = $0800; {Event Masks - } +app1Mask = $1000; {Event Masks - } +app2Mask = $2000; {Event Masks - } +app3Mask = $4000; {Event Masks - } +app4Mask = $8000; {Event Masks - } +everyEvent = $FFFF; {Event Masks - } +jcTickCount = $00; {Journal Code - TickCount call } +jcGetMouse = $01; {Journal Code - GetMouse call } +jcButton = $02; {Journal Code - Button call } +jcEvent = $04; {Journal Code - GetNextEvent and EventAvail calls } +activeFlag = $0001; {Modifier Flags - set if window being activated } +changeFlag = $0002; {Modifier Flags - set if active wind. changed state } +btn1State = $0040; {Modifier Flags - set if button 1 up } +btn0State = $0080; {Modifier Flags - set if button 0 up } +appleKey = $0100; {Modifier Flags - set if Apple key down } +shiftKey = $0200; {Modifier Flags - set if shift key down } +capsLock = $0400; {Modifier Flags - set if caps lock key down } +optionKey = $0800; {Modifier Flags - set if option key down } +controlKey = $1000; {Modifier Flags - set if Control key down } +keyPad = $2000; {Modifier Flags - set if keypress from key pad } + +TYPE +EventRecordHndl = ^EventRecordPtr; +EventRecordPtr = ^EventRecord; +EventRecord = RECORD CASE INTEGER OF + 0: ( + what : Integer; { event code } + message : Longint; { event message } + when : Longint; { ticks since startup } + where : Point; { mouse location } + modifiers : Integer; { modifier flags } + ); + 1: ( + wmWhat : Integer; + wmMessage : Longint; + wmWhen : Longint; + wmWhere : Point; + wmModifiers : Integer; + wmTaskData : Longint; { TaskMaster return value. } + wmTaskMask : Longint; { TaskMaster feature mask. } + wmLastClickTick : Longint; + wmClickCount : Integer; + wmTaskData2 : Longint; + wmTaskData3 : Longint; + wmTaskData4 : Longint; + wmLastClickPt : Point; + ); +END; +PROCEDURE EMBootInit ; Tool $06,$01; +PROCEDURE EMStartUp ( dPageAddr:Integer; queueSize:Integer; xMinClamp:Integer; +xMaxClamp:Integer; yMinClamp:Integer; yMaxClamp:Integer; userID:Integer) ; +Tool $06,$02; +PROCEDURE EMShutDown ; Tool $06,$03; +FUNCTION EMVersion : Integer ; Tool $06,$04; +PROCEDURE EMReset ; Tool $06,$05; +FUNCTION EMStatus : Boolean ; Tool $06,$06; +FUNCTION Button ( buttonNum:Integer) : Boolean ; Tool $06,$0D; +FUNCTION DoWindows : Integer ; Tool $06,$09; +FUNCTION EventAvail ( eventMask:Integer;VAR eventPtr:EventRecord) : Boolean ; +Tool $06,$0B; +PROCEDURE FakeMouse ( changedFlag:Integer; modLatch:Integer; xPos:Integer; +yPos:Integer; ButtonStatus:Integer) ; Tool $06,$19; +FUNCTION FlushEvents ( eventMask:Integer; stopMask:Integer) : Integer ; Tool +$06,$15; +FUNCTION GetCaretTime : Longint ; Tool $06,$12; +FUNCTION GetDblTime : Longint ; Tool $06,$11; +PROCEDURE GetMouse (VAR mouseLocPtr:Point) ; Tool $06,$0C; +FUNCTION GetNextEvent ( eventMask:Integer;VAR eventPtr:EventRecord) : Boolean ; +Tool $06,$0A; +FUNCTION GetOSEvent ( eventMask:Integer;VAR eventPtr:EventRecord) : Boolean ; +Tool $06,$16; +FUNCTION OSEventAvail ( eventMask:Integer;VAR eventPtr:EventRecord) : Boolean ; +Tool $06,$17; +FUNCTION PostEvent ( eventCode:Integer; eventMsg:Longint) : Integer ; Tool +$06,$14; +PROCEDURE SetEventMask ( sysEventMask:Integer) ; Tool $06,$18; +PROCEDURE SetSwitch ; Tool $06,$13; +FUNCTION StillDown ( buttonNum:Integer) : Boolean ; Tool $06,$0E; +FUNCTION WaitMouseUp ( buttonNum:Integer) : Boolean ; Tool $06,$0F; +FUNCTION TickCount : Longint ; Tool $06,$10; +FUNCTION GetKeyTranslation : Integer ; Tool $06,$1B; +PROCEDURE SetKeyTranslation ( kTransID:Integer) ; Tool $06,$1C; +PROCEDURE SetAutoKeyLimit ( newLimit:Integer) ; Tool $06,$1A; +IMPLEMENTATION +END. diff --git a/pascal/fonts.p b/pascal/fonts.p new file mode 100755 index 0000000..c5a9d1a --- /dev/null +++ b/pascal/fonts.p @@ -0,0 +1,103 @@ +{******************************************** +; File: Fonts.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT FONTS; +INTERFACE +USES TYPES,QUICKDRAW; +CONST + +(* *** Toolset Errors *** +fmDupStartUpErr = $1B01; {error - duplicate FMStartUp call } +fmResetErr = $1B02; {error - can't reset the Font Manager } +fmNotActiveErr = $1B03; {error - Font Manager not active } +fmFamNotFndErr = $1B04; {error - family not found } +fmFontNtFndErr = $1B05; {error - font not found } +fmFontMemErr = $1B06; {error - font not in memory } +fmSysFontErr = $1B07; {error - system font cannot be purgeable } +fmBadFamNumErr = $1B08; {error - illegal family number } +fmBadSizeErr = $1B09; {error - illegal size } +fmBadNameErr = $1B0A; {error - illegal name length } +fmMenuErr = $1B0B; {error - fix font menu never called } +fmScaleSizeErr = $1B0C; {error - scaled size of font exeeds limits } + *** Toolset Errors *** *) + +newYork = $0002; {Family Number - } +geneva = $0003; {Family Number - } +monaco = $0004; {Family Number - } +venice = $0005; {Family Number - } +london = $0006; {Family Number - } +athens = $0007; {Family Number - } +sanFran = $0008; {Family Number - } +toronto = $0009; {Family Number - } +cairo = $000B; {Family Number - } +losAngeles = $000C; {Family Number - } +times = $0014; {Family Number - } +helvetica = $0015; {Family Number - } +courier = $0016; {Family Number - } +symbol = $0017; {Family Number - } +taliesin = $0018; {Family Number - } +shaston = $FFFE; {Family Number - } +baseOnlyBit = $0020; {FamSpecBits - } +notBaseBit = $0020; {FamStatBits - } +memOnlyBit = $0001; {FontSpecBits - } +realOnlyBit = $0002; {FontSpecBits - } +anyFamBit = $0004; {FontSpecBits - } +anyStyleBit = $0008; {FontSpecBits - } +anySizeBit = $0010; {FontSpecBits - } +memBit = $0001; {FontStatBits - } +unrealBit = $0002; {FontStatBits - } +apFamBit = $0004; {FontStatBits - } +apVarBit = $0008; {FontStatBits - } +purgeBit = $0010; {FontStatBits - } +notDiskBit = $0020; {FontStatBits - } +notFoundBit = $8000; {FontStatBits - } +dontScaleBit = $0001; {Scale Word - } + +TYPE +FontStatRecHndl = ^FontStatRecPtr; +FontStatRecPtr = ^FontStatRec; +FontStatRec = RECORD + resultID : FontID; + resultStats : Integer; +END; +PROCEDURE FMBootInit ; Tool $1B,$01; +PROCEDURE FMStartUp ( userID:Integer; dPageAddr:Integer) ; Tool $1B,$02; +PROCEDURE FMShutDown ; Tool $1B,$03; +FUNCTION FMVersion : Integer ; Tool $1B,$04; +PROCEDURE FMReset ; Tool $1B,$05; +FUNCTION FMStatus : Boolean ; Tool $1B,$06; +PROCEDURE AddFamily ( famNum:Integer; famName:Str255) ; Tool $1B,$0D; +PROCEDURE AddFontVar ( fontHandle:FontHndl; newSpecs:Integer) ; Tool $1B,$14; +FUNCTION ChooseFont ( currentID:FontID; famSpecs:Integer) : FontID ; Tool +$1B,$16; +FUNCTION CountFamilies ( famSpecs:Integer) : Integer ; Tool $1B,$09; +FUNCTION CountFonts ( desiredID:FontId; fontSpecs:Integer) : Integer ; Tool +$1B,$10; +FUNCTION FamNum2ItemID ( famNum:Integer) : Integer ; Tool $1B,$1B; +FUNCTION FindFamily ( famSpecs:Integer; positionNum:Integer; famName:Str255) : +Integer ; Tool $1B,$0A; +PROCEDURE FindFontStats ( desiredID:FontId; fontSpecs:Integer; +positionNum:Integer;VAR resultPtr:FontStatRec) ; Tool $1B,$11; +PROCEDURE FixFontMenu ( menuID:Integer; startingID:Integer; famSpecs:Integer) +; Tool $1B,$15; +FUNCTION FMGetCurFID : FontID ; Tool $1B,$1A; +FUNCTION FMGetSysFID : FontID ; Tool $1B,$19; +PROCEDURE FMSetSysFont ( newFontID:FontID) ; Tool $1B,$18; +FUNCTION GetFamInfo ( famNum:Integer; famName:Str255) : Integer ; Tool $1B,$0B; +FUNCTION GetFamNum ( famName:Str255) : Integer ; Tool $1B,$0C; +PROCEDURE InstallFont ( desiredID:FontID; scaleWord:Integer) ; Tool $1B,$0E; +PROCEDURE InstallWithStats ( desiredID:FontID; scaleWord:Integer; +resultPtr:Ptr) ; Tool $1B,$1C; +FUNCTION ItemID2FamNum ( itemID:Integer) : Integer ; Tool $1B,$17; +PROCEDURE LoadFont ( desiredID:FontID; fontSpecs:Integer; +positionNum:Integer;VAR resultPtr:FontStatRec) ; Tool $1B,$12; +PROCEDURE LoadSysFont ; Tool $1B,$13; +PROCEDURE SetPurgeStat ( theFontID:FontID; purgeStat:Integer) ; Tool $1B,$0F; +IMPLEMENTATION +END. diff --git a/pascal/fst.p b/pascal/fst.p new file mode 100755 index 0000000..dd5c00f --- /dev/null +++ b/pascal/fst.p @@ -0,0 +1,138 @@ +{******************************************** +; File: FST.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT FST; +INTERFACE +USES Types,GSOS; + +TYPE +BufferControlRecPtr = ^BufferControlRec; +BufferControlRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + refNum : Integer; + flags : Integer; +END; +SpecialOpenForkRecPtr = ^SpecialOpenForkRec; +SpecialOpenForkRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + referenceNum : Integer; + pathname : GSString255Ptr; + accessMode : Integer; + resourceNum : Integer; +END; +ByteRangeLockRecPtr = ^ByteRangeLockRec; +ByteRangeLockRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + referenceNum : Integer; + lockFlag : Integer; + fileOffset : Longint; + rangeLength : Longint; + rangeStart : Longint; +END; +GetAccessRightsRecPtr = ^GetAccessRightsRec; +GetAccessRightsRec = PACKED RECORD + reserved : Byte; + world : Byte; + group : Byte; + owner : Byte; +END; +GetPrivilegesRecPtr = ^GetPrivilegesRec; +GetPrivilegesRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + pathname : GSString255Ptr; + accessRights : GetAccessRightsRec; + ownerName : ResultBuf255Ptr; + groupName : ResultBuf255Ptr; +END; +SetAccessRightsRecPtr = ^SetAccessRightsRec; +SetAccessRightsRec = PACKED RECORD + userSummary : Byte; + world : Byte; + group : Byte; + owner : Byte; +END; +SetPrivilegesRecPtr = ^SetPrivilegesRec; +SetPrivilegesRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + pathname : GSString255Ptr; + accessRights : SetAccessRightsRec; + ownerName : ResultBuf255Ptr; + groupName : ResultBuf255Ptr; +END; +UserInfoRecPtr = ^UserInfoRec; +UserInfoRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + deviceNum : Integer; + userName : ResultBuf255Ptr; + primaryGroupName : ResultBuf255Ptr; +END; +CopyFileRecPtr = ^CopyFileRec; +CopyFileRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + sourcePathname : GSString255Ptr; + destPathname : GSString255Ptr; +END; +GetUserPathRecPtr = ^GetUserPathRec; +GetUserPathRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + prefix : ResultBuf255Ptr; +END; +DesktopRecPtr = ^DesktopRec; +DesktopRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + desktopRefNum : Integer; + pathname : GSString255Ptr; +END; +GetCommentRecPtr = ^GetCommentRec; +GetCommentRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + desktopRefNum : Integer; + pathname : GSString255Ptr; + comment : ResultBuf255Ptr; +END; +SetCommentRecPtr = ^SetCommentRec; +SetCommentRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + desktopRefNum : Integer; + pathname : GSString255Ptr; + comment : GSString255Ptr; +END; +GetServerNameRecPtr = ^GetServerNameRec; +GetServerNameRec = RECORD + pCount : Integer; + fstNum : Integer; + command : Integer; + pathname : GSString255Ptr; + serverName : ResultBuf255Ptr; + zoneName : ResultBuf255Ptr; +END; +IMPLEMENTATION +END. diff --git a/pascal/gsos.p b/pascal/gsos.p new file mode 100755 index 0000000..71af6a8 --- /dev/null +++ b/pascal/gsos.p @@ -0,0 +1,498 @@ +{******************************************** +; File: GSOS.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT GSOS; +INTERFACE +USES TYPES; +CONST + +readEnable = $0001; {access - read enable bit: CreateRec, OpenRec access and +requestAccess fields } +writeEnable = $0002; {access - write enable bit: CreateRec, OpenRec access and +requestAccess fields } +fileInvisible = $0004; {access - Invisible bit } +backupNeeded = $0020; {access - backup needed bit: CreateRec, OpenRec access +field. (Must be 0 in requestAccess field ) } +renameEnable = $0040; {access - rename enable bit: CreateRec, OpenRec access +and requestAccess fields } +destroyEnable = $0080; {access - destroy enable bit: CreateRec, OpenRec access +and requestAccess fields } +startPlus = $0000; {base - > setMark = displacement } +eofMinus = $0001; {base - > setMark = eof - displacement } +markPlus = $0002; {base - > setMark = mark + displacement } +markMinus = $0003; {base - > setMark = mark - displacement } +cacheOff = $0000; {cachePriority - do not cache blocks invloved in this read } +cacheOn = $0001; {cachePriority - cache blocks invloved in this read if +possible } + +(* *** Toolset Errors *** +badSystemCall = $0001; {error - bad system call number } +invalidPcount = $0004; {error - invalid parameter count } +gsosActive = $07; {error - GS/OS already active } +devNotFound = $10; {error - device not found } +invalidDevNum = $11; {error - invalid device number } +drvrBadReq = $20; {error - bad request or command } +drvrBadCode = $0021; {error - bad control or status code } +drvrBadParm = $0022; {error - bad call parameter } +drvrNotOpen = $0023; {error - character device not open } +drvrPriorOpen = $0024; {error - character device already open } +irqTableFull = $0025; {error - interrupt table full } +drvrNoResrc = $0026; {error - resources not available } +drvrIOError = $0027; {error - I/O error } +drvrNoDevice = $0028; {error - device not connected } +drvrBusy = $0029; {error - call aborted, driver is busy } +drvrWrtProt = $002B; {error - device is write protected } +drvrBadCount = $002C; {error - invalid byte count } +drvrBadBlock = $002D; {error - invalid block address } +drvrDiskSwitch = $002E; {error - disk has been switched } +drvrOffLine = $002F; {error - device off line/ no media present } +badPathSyntax = $0040; {error - invalid pathname syntax } +invalidRefNum = $0043; {error - invalid reference number } +pathNotFound = $44; {error - subdirectory does not exist } +volNotFound = $0045; {error - volume not found } +fileNotFound = $0046; {error - file not found } +dupPathname = $0047; {error - create or rename with existing name } +volumeFull = $0048; {error - volume full error } +volDirFull = $0049; {error - volume directory full } +badFileFormat = $004A; {error - version error (incompatible file format) } +badStoreType = $004B; {error - unsupported (or incorrect) storage type } +eofEncountered = $004C; {error - end-of-file encountered } +outOfRange = $004D; {error - position out of range } +invalidAccess = $004E; {error - access not allowed } +buffTooSmall = $004F; {error - buffer too small } +fileBusy = $0050; {error - file is already open } +dirError = $0051; {error - directory error } +unknownVol = $0052; {error - unknown volume type } +paramRangeErr = $0053; {error - parameter out of range } +outOfMem = $0054; {error - out of memory } +dupVolume = $0057; {error - duplicate volume name } +notBlockDev = $0058; {error - not a block device } +invalidLevel = $0059; {error - specifield level outside legal range } +damagedBitMap = $005A; {error - block number too large } +badPathNames = $005B; {error - invalid pathnames for ChangePath } +notSystemFile = $005C; {error - not an executable file } +osUnsupported = $005D; {error - Operating System not supported } +stackOverflow = $005F; {error - too many applications on stack } +dataUnavail = $0060; {error - Data unavailable } +endOfDir = $0061; {error - end of directory has been reached } +invalidClass = $0062; {error - invalid FST call class } +resForkNotFound = $0063; {error - file does not contain required resource } +invalidFSTID = $0064; {error - error - FST ID is invalid } + *** Toolset Errors *** *) + +(* *** File System IDs *** +proDOSFSID = $0001; {fileSysID - ProDOS/SOS } +dos33FSID = $0002; {fileSysID - DOS 3.3 } +dos32FSID = $0003; {fileSysID - DOS 3.2 } +dos31FSID = $0003; {fileSysID - DOS 3.1 } +appleIIPascalFSID = $0004; {fileSysID - Apple II Pascal } +mfsFSID = $0005; {fileSysID - Macintosh (flat file system) } +hfsFSID = $0006; {fileSysID - Macintosh (hierarchical file system) } +lisaFSID = $0007; {fileSysID - Lisa file system } +appleCPMFSID = $0008; {fileSysID - Apple CP/M } +charFSTFSID = $0009; {fileSysID - Character FST } +msDOSFSID = $000A; {fileSysID - MS/DOS } +highSierraFSID = $000B; {fileSysID - High Sierra } +iso9660FSID = $000C; {fileSysID - ISO 9660 } +appleShareFSID = $000D; {fileSysID - ISO 9660 } + *** File System IDs *** *) + +characterFST = $4000; {FSTInfo.attributes - character FST } +ucFST = $8000; {FSTInfo.attributes - SCM should upper case pathnames before +passing them to the FST } +onStack = $8000; {QuitRec.flags - place state information about quitting +program on the quit return stack } +restartable = $4000; {QuitRec.flags - the quitting program is capable of being +restarted from its dormant memory } +seedling = $0001; {storageType - standard file with seedling structure } +standardFile = $0001; {storageType - standard file type (no resource fork) } +sapling = $0002; {storageType - standard file with sapling structure } +tree = $0003; {storageType - standard file with tree structure } +pascalRegion = $0004; {storageType - UCSD Pascal region on a partitioned disk } +extendedFile = $0005; {storageType - extended file type (with resource fork) } +directoryFile = $000D; {storageType - volume directory or subdirectory file } +minorRelNumMask = $00FF; {version - minor release number } +majorRelNumMask = $7F00; {version - major release number } +finalRelNumMask = $8000; {version - final release number } +isFileExtended = $8000; {GetDirEntryGS - } + +TYPE +GSString255Hndl = ^GSString255Ptr; +GSString255Ptr = ^GSString255; +GSString255 = RECORD + length : Integer; { Number of Chars in text field } + text : PACKED ARRAY[1..255] OF CHAR; +END; +GSString255HndlPtr = ^GSString255Hndl; + +GSString32Hndl = ^GSString32Ptr; +GSString32Ptr = ^GSString32; +GSString32 = RECORD + length : Integer; { Number of characters in text field } + text : PACKED ARRAY[1..32] OF CHAR; +END; +ResultBuf255Hndl = ^ResultBuf255Ptr; +ResultBuf255Ptr = ^ResultBuf255; +ResultBuf255 = RECORD + bufSize : Integer; + bufString : GSString255; +END; +ResultBuf255HndlPtr = ^ResultBuf255Hndl; + +ResultBuf32Hndl = ^ResultBuf32Ptr; +ResultBuf32Ptr = ^ResultBuf32; +ResultBuf32 = RECORD + bufSize : Integer; + bufString : GSString32; +END; +ChangePathRecPtrGS = ^ChangePathRecGS; +ChangePathRecGS = RECORD + pCount : Integer; + pathname : GSString255Ptr; + newPathname : GSString255Ptr; +END; +CreateRecPtrGS = ^CreateRecGS; +CreateRecGS = RECORD + pCount : Integer; + pathname : GSString255Ptr; + access : Integer; + fileType : Integer; + auxType : Longint; + storageType : Integer; + eof : Longint; + resourceEOF : Longint; +END; +DAccessRecPtrGS = ^DAccessRecGS; +DAccessRecGS = RECORD + pCount : Integer; + devNum : Integer; + code : Integer; + list : Ptr; + requestCount : Longint; + transferCount : Longint; +END; +DevNumRecPtrGS = ^DevNumRecGS; +DevNumRecGS = RECORD + pCount : Integer; + devName : GSString255Ptr; + devNum : Integer; +END; +DInfoRecPtrGS = ^DInfoRecGS; +DInfoRecGS = RECORD + pCount : Integer; { minimum = 2 } + devNum : Integer; + devName : GSString32Ptr; + characteristics : Integer; + totalBlocks : Longint; + slotNum : Integer; + unitNum : Integer; + version : Integer; + deviceID : Integer; + headLink : Integer; + forwardLink : Integer; + extendedDIBptr : Longint; +END; +DIORecPtrGS = ^DIORecGS; +DIORecGS = RECORD + pCount : Integer; + devNum : Integer; + buffer : Ptr; + requestCount : Longint; + startingBlock : Longint; + blockSize : Integer; + transferCount : Longint; +END; +DirEntryRecPtrGS = ^DirEntryRecGS; +DirEntryRecGS = RECORD + pCount : Integer; + refNum : Integer; + flags : Integer; + base : Integer; + displacement : Integer; + name : Ptr; + entryNum : Integer; + fileType : Integer; + eof : Longint; + blockCount : Longint; + createDateTime : TimeRec; + modDateTime : TimeRec; + access : Integer; + auxType : Longint; + fileSysID : Integer; + optionList : ResultBuf255Ptr; + resourceEOF : Longint; + resourceBlocks : Longint; +END; +ExpandPathRecPtrGS = ^ExpandPathRecGS; +ExpandPathRecGS = RECORD + pCount : Integer; + inputPath : GSString255Ptr; + outputPath : ResultBuf255Ptr; + flags : Integer; +END; +FileInfoRecPtrGS = ^FileInfoRecGS; +FileInfoRecGS = RECORD + pCount : Integer; + pathname : GSString255Ptr; + access : Integer; + fileType : Integer; + auxType : Longint; + storageType : Integer; { must be 0 for SetFileInfo } + createDateTime : TimeRec; + modDateTime : TimeRec; + optionList : Longint; + eof : Longint; + blocksUsed : Longint; { must be 0 for SetFileInfo } + resourceEOF : Longint; { must be 0 for SetFileInfo } + resourceBlocks : Longint; { must be 0 for SetFileInfo } +END; +FormatRecPtrGS = ^FormatRecGS; +FormatRecGS = RECORD + pCount : Integer; + devName : GSString32Ptr; { device name pointer } + volName : GSString32Ptr; { volume name pointer } + fileSysID : Integer; { file system ID } + reqFileSysID : Integer; { in; } +END; +FSTInfoRecPtrGS = ^FSTInfoRecGS; +FSTInfoRecGS = RECORD + pCount : Integer; + fstNum : Integer; + fileSysID : Integer; + fstName : ResultBuf255Ptr; + version : Integer; + attributes : Integer; + blockSize : Integer; + maxVolSize : Longint; + maxFileSize : Longint; +END; +InterruptRecPtrGS = ^InterruptRecGS; +InterruptRecGS = RECORD + pCount : Integer; + intNum : Integer; + vrn : Integer; { used only by BindInt } + intCode : Longint; { used only by BindInt } +END; +IORecPtrGS = ^IORecGS; +IORecGS = RECORD + pCount : Integer; + refNum : Integer; + dataBuffer : Ptr; + requestCount : Longint; + transferCount : Longint; + cachePriority : Integer; +END; +LevelRecPtrGS = ^LevelRecGS; +LevelRecGS = RECORD + pCount : Integer; + level : Integer; +END; +NameRecPtrGS = ^NameRecGS; +NameRecGS = RECORD + pCount : Integer; + pathname : GSString255Ptr; { full pathname or a filename depending on call +} +END; +GetNameRecPtrGS = ^GetNameRecGS; +GetNameRecGS = RECORD + pCount : Integer; + dataBuffer : ResultBuf255Ptr; { full pathname or a filename depending on +call } +END; +NewlineRecPtrGS = ^NewlineRecGS; +NewlineRecGS = RECORD + pCount : Integer; + refNum : Integer; + enableMask : Integer; + numChars : Integer; + newlineTable : Ptr; +END; +OpenRecPtrGS = ^OpenRecGS; +OpenRecGS = RECORD + pCount : Integer; + refNum : Integer; + pathname : GSString255Ptr; + requestAccess : Integer; + resourceNumber : Integer; { For extended files: dataFork/resourceFork } + access : Integer; { Value of file's access attribute } + fileType : Integer; { Value of file's fileType attribute } + auxType : Longint; + storageType : Integer; + createDateTime : TimeRec; + modDateTime : TimeRec; + optionList : IntPtr; + eof : Longint; + blocksUsed : Longint; + resourceEOF : Longint; + resourceBlocks : Longint; +END; +OSShutdownRecPtrGS = ^OSShutdownRecGS; +OSShutdownRecGS = RECORD + pCount : Integer; { in } + shutdownFlag : Integer; { in } +END; +PositionRecPtrGS = ^PositionRecGS; +PositionRecGS = RECORD + pCount : Integer; + refNum : Integer; + position : Longint; +END; +EOFRecPtrGS = ^EOFRecGS; +EOFRecGS = RECORD + pCount : Integer; + refNum : Integer; + eof : Longint; +END; +PrefixRecPtrGS = ^PrefixRecGS; +PrefixRecGS = RECORD + pCount : Integer; + prefixNum : Integer; + CASE INTEGER OF + 0: (getPrefix : ResultBuf255Ptr;); + 1: (setPrefix : GSString255Ptr;); +END; +QuitRecPtrGS = ^QuitRecGS; +QuitRecGS = RECORD + pCount : Integer; + pathname : GSString255Ptr; { pathname of next app to run } + flags : Integer; +END; +RefnumRecPtrGS = ^RefNumRecGS; +RefNumRecGS = RECORD + pCount : Integer; + refNum : Integer; +END; +SessionStatusRecPtrGS = ^SessionStatusRecGS; +SessionStatusRecGS = RECORD + pCount : Integer; { in: min = 1 } + status : Integer; { out: } +END; +SetPositionRecPtrGS = ^SetPositionRecGS; +SetPositionRecGS = RECORD + pCount : Integer; + refNum : Integer; + base : Integer; + displacement : Longint; +END; +SysPrefsRecPtrGS = ^SysPrefsRecGS; +SysPrefsRecGS = RECORD + pCount : Integer; + preferences : Integer; +END; +VersionRecPtrGS = ^VersionRecGS; +VersionRecGS = RECORD + pCount : Integer; + version : Integer; +END; +VolumeRecPtrGS = ^VolumeRecGS; +VolumeRecGS = RECORD + pCount : Integer; + devName : GSString32Ptr; + volName : ResultBuf255Ptr; + totalBlocks : Longint; + freeBlocks : Longint; + fileSysID : Integer; + blockSize : Integer; +END; +PROCEDURE BeginSessionGS (VAR pblockPtr: SessionStatusRecGS); GSOS $201D ; + +PROCEDURE BindIntGS (VAR pblockPtr: InterruptRecGS); GSOS $2031 ; + +PROCEDURE ChangePathGS (VAR pblockPtr: ChangePathRecGS); GSOS $2004 ; + +PROCEDURE ClearBackupBitGS (VAR pblockPtr: NameRecGS); GSOS $200B ; + +PROCEDURE CloseGS (VAR pblockPtr: RefNumRecGS); GSOS $2014 ; + +PROCEDURE CreateGS (VAR pblockPtr: CreateRecGS); GSOS $2001 ; + +PROCEDURE DControlGS (VAR pblockPtr: DAccessRecGS); GSOS $202E ; + +PROCEDURE DestroyGS (VAR pblockPtr: NameRecGS); GSOS $2002 ; + +PROCEDURE DInfoGS (VAR pblockPtr: DInfoRecGS); GSOS $202C ; + +PROCEDURE DReadGS (VAR pblockPtr: DIORecGS); GSOS $202F ; + +PROCEDURE DStatusGS (VAR pblockPtr: DAccessRecGS); GSOS $202D ; + +PROCEDURE DWriteGS (VAR pblockPtr: DIORecGS); GSOS $2030 ; + +PROCEDURE EndSessionGS (VAR pblockPtr: SessionStatusRecGS); GSOS $201E ; + +PROCEDURE EraseDiskGS (VAR pblockPtr: FormatRecGS); GSOS $2025 ; + +PROCEDURE ExpandPathGS (VAR pblockPtr: ExpandPathRecGS); GSOS $200E ; + +PROCEDURE FlushGS (VAR pblockPtr: RefNumRecGS); GSOS $2015 ; + +PROCEDURE FormatGS (VAR pblockPtr: FormatRecGS); GSOS $2024 ; + +PROCEDURE GetBootVolGS (VAR pblockPtr: NameRecGS); GSOS $2028 ; + +PROCEDURE GetDevNumberGS (VAR pblockPtr: DevNumRecGS); GSOS $2020 ; + +PROCEDURE GetDirEntryGS (VAR pblockPtr: DirEntryRecGS); GSOS $201C ; + +PROCEDURE GetEOFGS (VAR pblockPtr: EOFRecGS); GSOS $2019 ; + +PROCEDURE GetFileInfoGS (VAR pblockPtr: FileInfoRecGS); GSOS $2006 ; + +PROCEDURE GetFSTInfoGS (VAR pblockPtr: FSTInfoRecGS); GSOS $202B ; + +PROCEDURE GetLevelGS (VAR pblockPtr: LevelRecGS); GSOS $201B ; + +PROCEDURE GetMarkGS (VAR pblockPtr: PositionRecGS); GSOS $2017 ; + +PROCEDURE GetNameGS (VAR pblockPtr: GetNameRecGS); GSOS $2027 ; + +PROCEDURE GetPrefixGS (VAR pblockPtr: PrefixRecGS); GSOS $200A ; + +PROCEDURE GetVersionGS (VAR pblockPtr: VersionRecGS); GSOS $202A ; + +PROCEDURE GetSysPrefsGS (VAR pblockPtr: SysPrefsRecGS); GSOS $200F ; + +PROCEDURE NewlineGS (VAR pblockPtr: NewlineRecGS); GSOS $2011 ; + +PROCEDURE NullGS (VAR pblockPtr: IntPtr); GSOS $200D ; + +PROCEDURE OpenGS (VAR pblockPtr: OpenRecGS); GSOS $2010 ; + +PROCEDURE QuitGS (VAR pblockPtr: QuitRecGS); GSOS $2029 ; + +PROCEDURE ReadGS (VAR pblockPtr: IORecGS); GSOS $2012 ; + +PROCEDURE ResetCacheGS (VAR pblockPtr: IntPtr); GSOS $2026 ; + +PROCEDURE SessionStatusGS (VAR pblockPtr: SessionStatusRecGS); GSOS $201F ; + +PROCEDURE SetEOFGS (VAR pblockPtr: SetPositionRecGS); GSOS $2018 ; + +PROCEDURE SetFileInfoGS (VAR pblockPtr: FileInfoRecGS); GSOS $2005 ; + +PROCEDURE SetLevelGS (VAR pblockPtr: LevelRecGS); GSOS $201A ; + +PROCEDURE SetMarkGS (VAR pblockPtr: SetPositionRecGS); GSOS $2016 ; + +PROCEDURE SetPrefixGS (VAR pblockPtr: PrefixRecGS); GSOS $2009 ; + +PROCEDURE SetSysPrefsGS (VAR pblockPtr: SysPrefsRecGS); GSOS $200C ; + +PROCEDURE UnbindIntGS (VAR pblockPtr: InterruptRecGS); GSOS $2032 ; + +PROCEDURE VolumeGS (VAR pblockPtr: VolumeRecGS); GSOS $2008 ; + +PROCEDURE WriteGS (VAR pblockPtr: IORecGS); GSOS $2013 ; + +PROCEDURE OSShutdownGS (VAR pblockPtr: OSShutdownRecGS); GSOS $2003 ; + +PROCEDURE FSTSpecific (VAR pBlockPtr: Ptr); GSOS $2033 ; + +IMPLEMENTATION +END. diff --git a/pascal/intmath.p b/pascal/intmath.p new file mode 100755 index 0000000..1b88f62 --- /dev/null +++ b/pascal/intmath.p @@ -0,0 +1,111 @@ +{******************************************** +; File: IntMath.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT INTMATH; +INTERFACE +USES TYPES; +CONST + +(* *** Toolset Errors *** +imBadInptParam = $0B01; {error - bad input parameter } +imIllegalChar = $0B02; {error - Illegal character in string } +imOverflow = $0B03; {error - integer or long integer overflow } +imStrOverflow = $0B04; {error - string overflow } + *** Toolset Errors *** *) + +minLongint = $80000000; {Limit - minimum negative signed long integer } +minFrac = $80000000; {Limit - pinned value for negative Frac overflow } +minFixed = $80000000; {Limit - pinned value for negative Fixed overflow } +minInt = $8000; {Limit - Minimum negative signed integer } +maxInt = $7FFF; {Limit - Maximum positive signed integer } +maxUInt = $FFFF; {Limit - Maximum positive unsigned integer } +maxLongint = $7FFFFFFF; {Limit - maximum positive signed Longint } +maxFrac = $7FFFFFFF; {Limit - pinned value for positive Frac overflow } +maxFixed = $7FFFFFFF; {Limit - pinned value for positive Fixed overflow } +maxULong = $FFFFFFFF; {Limit - maximum unsigned Long } +unsignedFlag = $0000; {SignedFlag - } +signedFlag = $0001; {SignedFlag - } + +TYPE +IntDivRecPtr = ^IntDivRec; +IntDivRec = RECORD + quotient : Integer; { quotient from SDivide } + remainder : Integer; { remainder from SDivide } +END; +LongDivRecPtr = ^LongDivRec; +LongDivRec = RECORD + quotient : Longint; { Quotient from LongDiv } + remainder : Longint; { remainder from LongDiv } +END; +DivRecPtr = ^DivRec; (* for backward compatability *) +DivRec = LongDivRec; +LongMulRecPtr = ^LongMulRec; +LongMulRec = RECORD + lsResult : Longint; { low 2 words of product } + msResult : Longint; { High 2 words of product } +END; +WordDivRecPtr = ^WordDivRec; +WordDivRec = RECORD + quotient : Integer; { Quotient from UDivide } + remainder : Integer; { remainder from UDivide } +END; +PROCEDURE IMBootInit ; Tool $0B,$01; +PROCEDURE IMStartUp ; Tool $0B,$02; +PROCEDURE IMShutDown ; Tool $0B,$03; +FUNCTION IMVersion : Integer ; Tool $0B,$04; +PROCEDURE IMReset ; Tool $0B,$05; +FUNCTION IMStatus : Boolean ; Tool $0B,$06; +FUNCTION Dec2Int ( strPtr:Ptr; strLength:Integer; signedFlag:Boolean) : Integer +; Tool $0B,$28; +FUNCTION Dec2Long ( strPtr:Ptr; strLength:Integer; signedFlag:Boolean) : +Longint ; Tool $0B,$29; +FUNCTION Fix2Frac ( fixedValue:Fixed) : Frac ; Tool $0B,$1C; +FUNCTION Fix2Long ( fixedValue:Fixed) : Longint ; Tool $0B,$1B; +PROCEDURE Fix2X ( fixedValue:Fixed;VAR extendPtr:Extended) ; Tool $0B,$1E; +FUNCTION FixATan2 ( input1:Longint; input2:Longint) : Fixed ; Tool $0B,$17; +FUNCTION FixDiv ( dividend:Longint; divisor:Longint) : Fixed ; Tool $0B,$11; +FUNCTION FixMul ( multiplicand:Fixed; multiplier:Fixed) : Fixed ; Tool $0B,$0F; +FUNCTION FixRatio ( numerator:Integer; denominator:Integer) : Fixed ; Tool +$0B,$0E; +FUNCTION FixRound ( fixedValue:Fixed) : Integer ; Tool $0B,$13; +FUNCTION Frac2Fix ( fracValue:Frac) : Fixed ; Tool $0B,$1D; +PROCEDURE Frac2X ( fracValue:Frac;VAR extendPtr:Extended) ; Tool $0B,$1F; +FUNCTION FracCos ( angle:Fixed) : Frac ; Tool $0B,$15; +FUNCTION FracDiv ( dividend:Longint; divisor:Longint) : Frac ; Tool $0B,$12; +FUNCTION FracMul ( multiplicand:Frac; multiplier:Frac) : Frac ; Tool $0B,$10; +FUNCTION FracSin ( angle:Fixed) : Frac ; Tool $0B,$16; +FUNCTION FracSqrt ( fracValue:Frac) : Frac ; Tool $0B,$14; +FUNCTION Hex2Int ( strPtr:Ptr; strLength:Integer) : Integer ; Tool $0B,$24; +FUNCTION Hex2Long ( strPtr:Ptr; strLength:Integer) : Longint ; Tool $0B,$25; +FUNCTION HexIt ( intValue:Integer) : Longint ; Tool $0B,$2A; +FUNCTION HiWord ( longValue:Longint) : Integer ; Tool $0B,$18; +PROCEDURE Int2Dec ( wordValue:Integer; strPtr:Ptr; strLength:Integer; +signedFlag:Boolean) ; Tool $0B,$26; +PROCEDURE Int2Hex ( intValue:Integer; strPtr:Ptr; strLength:Integer) ; Tool +$0B,$22; +PROCEDURE Long2Dec ( longValue:Longint; strPtr:Ptr; strLength:Integer; +signedFlag:Boolean) ; Tool $0B,$27; +FUNCTION Long2Fix ( longValue:Longint) : Fixed ; Tool $0B,$1A; +PROCEDURE Long2Hex ( longValue:Longint; strPtr:Ptr; strLength:Integer) ; Tool +$0B,$23; +FUNCTION LongDivide ( dividend:Longint; divisor:Longint) : LongDivRec ; +EXTERNAL ; +FUNCTION LongMul ( multiplicand:Longint; multiplier:Longint) : LongMulRec ; +EXTERNAL ; +FUNCTION LoWord ( longValue:Longint) : Integer ; Tool $0B,$19; +FUNCTION Multiply ( multiplicand:Integer; multiplier:Integer) : Longint ; Tool +$0B,$09; +FUNCTION SDivide ( dividend:Integer; divisor:Integer) : IntDivRec ; Tool +$0B,$0A; +FUNCTION UDivide ( dividend:Integer; divisor:Integer) : WordDivRec ; Tool +$0B,$0B; +FUNCTION X2Fix ( extendPtr:ExtendedPtr) : Longint ; Tool $0B,$20; +FUNCTION X2Frac ( extendPtr:ExtendedPtr) : Longint ; Tool $0B,$21; +IMPLEMENTATION +END. diff --git a/pascal/lineedit.p b/pascal/lineedit.p new file mode 100755 index 0000000..5197a15 --- /dev/null +++ b/pascal/lineedit.p @@ -0,0 +1,95 @@ +{******************************************** +; File: LineEdit.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT LINEEDIT; +INTERFACE +USES TYPES,QUICKDRAW,EVENTS; +CONST + +(* *** Toolset Errors *** +leDupStrtUpErr = $1401; {error - duplicate LEStartup call } +leResetErr = $1402; {error - can't reset Line Edit } +leNotActiveErr = $1403; {error - Line Edit not active } +leScrapErr = $1404; {error - desk scrap too big to copy } + *** Toolset Errors *** *) + +leJustLeft = $0000; {Justification - } +leJustCenter = $0001; {Justification - } +leJustFill = $0002; {Justification - } +leJustRight = $FFFF; {Justification - } + +TYPE +LERecHndl = ^LERecPtr; +LERecPtr = ^LERec; +LERec = RECORD + leLineHandle : Handle; + leLength : Integer; + leMaxLength : Integer; + leDestRect : Rect; + leViewRect : Rect; + lePort : GrafPortPtr; + leLineHite : Integer; + leBaseHite : Integer; + leSelStart : Integer; + leSelEnd : Integer; + leActFlg : Integer; + leCarAct : Integer; + leCarOn : Integer; + leCarTime : Longint; + leHiliteHook : VoidProcPtr; + leCaretHook : VoidProcPtr; + leJust : Integer; + lePWChar : Integer; +END; +PROCEDURE LEBootInit ; Tool $14,$01; +PROCEDURE LEStartUp ( userID:Integer; dPageAddr:Integer) ; Tool $14,$02; +PROCEDURE LEShutDown ; Tool $14,$03; +FUNCTION LEVersion : Integer ; Tool $14,$04; +PROCEDURE LEReset ; Tool $14,$05; +FUNCTION LEStatus : Boolean ; Tool $14,$06; +PROCEDURE LEActivate ( leRecHandle:LERecHndl) ; Tool $14,$0F; +PROCEDURE LEClick ( eventPtr:EventRecord; leRecHandle:LERecHndl) ; Tool +$14,$0D; +PROCEDURE LECopy ( leRecHandle:LERecHndl) ; Tool $14,$13; +PROCEDURE LECut ( leRecHandle:LERecHndl) ; Tool $14,$12; +PROCEDURE LEDeactivate ( leRecHandle:LERecHndl) ; Tool $14,$10; +PROCEDURE LEDelete ( leRecHandle:LERecHndl) ; Tool $14,$15; +PROCEDURE LEDispose ( leRecHandle:LERecHndl) ; Tool $14,$0A; +PROCEDURE LEFromScrap ; Tool $14,$19; +FUNCTION LEGetScrapLen : Integer ; Tool $14,$1C; +FUNCTION LEGetTextHand ( leRecHandle:LERecHndl) : Handle ; Tool $14,$22; +FUNCTION LEGetTextLen ( leRecHandle:LERecHndl) : Integer ; Tool $14,$23; +PROCEDURE LEIdle ( leRecHandle:LERecHndl) ; Tool $14,$0C; +PROCEDURE LEInsert ( textPtr:Ptr; textLength:Integer; leRecHandle:LERecHndl) ; +Tool $14,$16; +PROCEDURE LEKey ( theKey:CHAR; modifiers:Integer; leRecHandle:LERecHndl) ; +Tool $14,$11; +FUNCTION LENew ( destRectPtr:Rect; viewRectPtr:Rect; maxTextLen:Integer) : +LERecHndl ; Tool $14,$09; +PROCEDURE LEPaste ( leRecHandle:LERecHndl) ; Tool $14,$14; +FUNCTION LEScrapHandle : Handle ; Tool $14,$1B; +PROCEDURE LESetCaret ( caretProcPtr:VoidProcPtr; leRecHandle:LERecHndl) ; Tool +$14,$1F; +PROCEDURE LESetHilite ( hiliteProcPtr:VoidProcPtr; leRecHandle:LERecHndl) ; +Tool $14,$1E; +PROCEDURE LESetJust ( just:Integer; leRecHandle:LERecHndl) ; Tool $14,$21; +PROCEDURE LESetScrapLen ( newLength:Integer) ; Tool $14,$1D; +PROCEDURE LESetSelect ( selStart:Integer; selEnd:Integer; +leRecHandle:LERecHndl) ; Tool $14,$0E; +PROCEDURE LESetText ( textPtr:Ptr; textLength:Integer; leRecHandle:LERecHndl) +; Tool $14,$0B; +PROCEDURE LETextBox ( textPtr:Ptr; textLength:Integer; rectPtr:Rect; +just:Integer) ; Tool $14,$18; +PROCEDURE LETextBox2 ( textPtr:Ptr; textLength:Integer; rectPtr:Rect; +just:Integer) ; Tool $14,$20; +PROCEDURE LEToScrap ; Tool $14,$1A; +PROCEDURE LEUpdate ( leRecHandle:LERecHndl) ; Tool $14,$17; +FUNCTION GetLEDefProc : Ptr ; Tool $14,$24; +IMPLEMENTATION +END. diff --git a/pascal/lists.p b/pascal/lists.p new file mode 100755 index 0000000..86ab962 --- /dev/null +++ b/pascal/lists.p @@ -0,0 +1,106 @@ +{******************************************** +; File: Lists.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT LISTS; +INTERFACE +USES TYPES,QUICKDRAW,EVENTS,CONTROLS; +CONST + +cString = $0001; {ListType bit mask - null terminated string type } +LIST_STRG = $0001; {ListType bit mask - null terminated string type } +selectOnlyOne = $0002; {ListType bit mask - only one selection allowed } +LIST_SELECT = $0002; {ListType bit mask - single selection only } +memDisabled = $40; {memFlag - Sets member flag to disabled } +memSelected = $80; {memFlag - Sets member flag to selected } + +TYPE +LColorTableHndl = ^LColorTablePtr; +LColorTablePtr = ^LColorTable; +LColorTable = RECORD + listFrameClr : Integer; { Frame color } + listNorTextClr : Integer; { Unhighlighted text color } + listSelTextClr : Integer; { Highlighted text color } + listNorBackClr : Integer; { Unhighlighted background color } + listSelBackClr : Integer; { Highlighted backgraound color } +END; +MemRecHndl = ^MemRecPtr; +MemRecPtr = ^MemRec; +MemRec = PACKED RECORD + memPtr : Ptr; { Pointer to string, or custom } + memFlag : Byte; { Bit Flag } +END; +ListCtlRecHndl = ^ListCtlRecPtr; +ListCtlRecPtr = ^ListCtlRec; +ListCtlRec = PACKED RECORD + ctlNext : CtlRecHndl; { Handle of Next Control } + ctlOwner : GrafPortPtr; { Window owner } + ctlRect : Rect; { Enclosing Rect } + ctlFlag : Byte; { Bit 7 visible, Bit 0 string type, Bit 1 multiple } + ctlHilite : Byte; { (not used) } + ctlValue : Integer; { First member in display } + ctlProc : LongProcPtr; { Address of list definition procedure } + ctlAction : LongProcPtr; { Address of list action procedure } + ctlData : Longint; { Low = view size, High = total members } + ctlRefCon : Longint; { Not used } + ctlColor : LColorTablePtr; { Null for default colors } + ctlMemDraw : VoidProcPtr; { Address of routine to draw members } + ctlMemHeight : Integer; { Member's Height in Pixels } + ctlMemSize : Integer; { Bytes in member record } + ctlList : MemRecPtr; { Adress of first member record in array } + ctlListBar : CtlRecHndl; { Handle of list contrlo's scroll bar control } +END; +ListRecHndl = ^ListRecPtr; +ListRecPtr = ^ListRec; +ListRec = RECORD + listRect : Rect; { Enclosing Rectangle } + listSize : Integer; { Number of List Members } + listView : Integer; { Max Viewable members } + listType : Integer; { Bit Flag } + listStart : Integer; { First member in view } + listCtl : CtlRecHndl; { List control's handle } + listDraw : VoidProcPtr; { Address of Custom drawing routine } + listMemHeight : Integer; { Height of list members } + listMemSize : Integer; { Size of Member Records } + listPointer : MemRecPtr; { Pointer to first element in MemRec array } + listRefCon : Longint; { becomes Control's refCon } + listScrollClr : BarColorsPtr; { Color table for list's scroll bar } +END; +PROCEDURE ListBootInit ; Tool $1C,$01; +PROCEDURE ListStartup ; Tool $1C,$02; +PROCEDURE ListShutDown ; Tool $1C,$03; +FUNCTION ListVersion : Integer ; Tool $1C,$04; +PROCEDURE ListReset ; Tool $1C,$05; +FUNCTION ListStatus : Boolean ; Tool $1C,$06; +FUNCTION CreateList ( theWindowPtr:WindowPtr; U__listRecPtr:ListRecPtr) : +ListCtlRecHndl ; Tool $1C,$09; +PROCEDURE DrawMember ( memberPtr:MemRecPtr; U__listRecPtr:ListRecPtr) ; Tool +$1C,$0C; +FUNCTION GetListDefProc : LongProcPtr ; Tool $1C,$0E; +PROCEDURE NewList ( memberPtr:MemRecPtr; U__listRecPtr:ListRecPtr) ; Tool +$1C,$10; +FUNCTION NextMember ( memberPtr:MemRecPtr; U__listRecPtr:ListRecPtr) : +MemRecPtr ; Tool $1C,$0B; +FUNCTION ResetMember ( U__listRecPtr:ListRecPtr) : MemRecPtr ; Tool $1C,$0F; +PROCEDURE SelectMember ( memberPtr:MemRecPtr; U__listRecPtr:ListRecPtr) ; Tool +$1C,$0D; +PROCEDURE SortList ( comparePtr:VoidProcPtr; U__listRecPtr:ListRecPtr) ; Tool +$1C,$0A; +PROCEDURE DrawMember2 ( itemNumber:Integer; ctlHandle:CtlRecHndl) ; Tool +$1C,$11; +FUNCTION NextMember2 ( itemNumber:Integer; ctlHandle:CtlRecHndl) : Integer ; +Tool $1C,$12; +FUNCTION ResetMember2 ( ctlHandle:CtlRecHndl) : Integer ; Tool $1C,$13; +PROCEDURE SelectMember2 ( itemNumber:Integer; ctlHandle:CtlRecHndl) ; Tool +$1C,$14; +PROCEDURE SortList2 ( comparePtr:Ptr; ctlHandle:CtlRecHndl) ; Tool $1C,$15; +PROCEDURE NewList2 ( drawProcPtr:ProcPtr; listStart:Integer; listRef:Ref; +listRefDesc:RefDescriptor; listSize:Integer; ctlHandle:CtlRecHndl) ; Tool +$1C,$16; +IMPLEMENTATION +END. diff --git a/pascal/loader.p b/pascal/loader.p new file mode 100755 index 0000000..11501e8 --- /dev/null +++ b/pascal/loader.p @@ -0,0 +1,87 @@ +{******************************************** +; File: Loader.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT LOADER; +INTERFACE +USES TYPES; + +(* *** Toolset Errors *** +CONST +idNotFound = $1101; {error - segment/application/entry not found } +idNotLoadFile = $1104; {error - file is not a load file } +idBusyErr = $1105; {error - system loader is busy } +idFilVersErr = $1107; {error - file version error } +idUserIDErr = $1108; {error - user ID error } +idSequenceErr = $1109; {error - segnum out of sequence } +idBadRecordErr = $110A; {error - illegal load record found } +idForeignSegErr = $110B; {error - segment is foreign } + *** Toolset Errors *** *) + +TYPE +InitialLoadOutputRecPtr = ^InitialLoadOutputRec; +InitialLoadOutputRec = RECORD + userID : Integer; + startAddr : Ptr; + dPageAddr : Integer; + buffSize : Integer; +END; +RestartOutRecPtr = ^RestartOutRec; +RestartOutRec = RECORD + userID : Integer; + startAddr : Ptr; + dPageAddr : Integer; + buffSize : Integer; +END; +LoadSegNameOutPtr = ^LoadSegNameOut; +LoadSegNameOut = RECORD + segAddr : Ptr; + fileNum : Integer; + segNum : Integer; +END; +UnloadSegOutRecPtr = ^UnloadSegOutRec; +UnloadSegOutRec = RECORD + userID : Integer; + fileNum : Integer; + segNum : Integer; +END; +PROCEDURE LoaderInitialization ; Tool $11,$01; +PROCEDURE LoaderStartUp ; Tool $11,$02; +PROCEDURE LoaderShutDown ; Tool $11,$03; +FUNCTION LoaderVersion : Integer ; Tool $11,$04; +PROCEDURE LoaderReset ; Tool $11,$05; +FUNCTION LoaderStatus : Boolean ; Tool $11,$06; +PROCEDURE GetLoadSegInfo ( userID:Integer; loadFileNum:Integer; +loadSegNum:Integer; bufferPtr:Ptr) ; Tool $11,$0F; +FUNCTION GetUserID ( pathNamePtr:Ptr) : Integer ; Tool $11,$10; +FUNCTION GetUserID2 ( pathNamePtr:Ptr) : Integer ; Tool $11,$21; +FUNCTION InitialLoad ( userID:Integer; loadFileNamePtr:Ptr; spMemFlag:Boolean) +: InitialLoadOutputRec ; EXTERNAL ; +FUNCTION InitialLoad2 ( userID:Integer; loadFileNamePtr:Ptr; spMemFlag:Boolean; +inputType:Integer) : InitialLoadOutputRec ; EXTERNAL ; +FUNCTION LGetPathname ( userID:Integer; fileNumber:Integer) : Ptr ; Tool +$11,$11; +FUNCTION LGetPathname2 ( userID:Integer; fileNumber:Integer) : Ptr ; Tool +$11,$22; +FUNCTION GetPathname ( userID:Integer; fileNumber:Integer) : Ptr ; Tool +$11,$11; +FUNCTION GetPathname2 ( userID:Integer; fileNumber:Integer) : Ptr ; Tool +$11,$22; +PROCEDURE RenamePathname ( oldPathname:Ptr; newPathname:Ptr) ; Tool $11,$13; +FUNCTION LoadSegName ( userID:Integer; loadFileNamePtr:Ptr; loadSegNamePtr:Ptr) +: LoadSegNameOut ; EXTERNAL ; +FUNCTION LoadSegNum ( userID:Integer; loadFileNum:Integer; loadSegNum:Integer) +: Ptr ; Tool $11,$0B; +FUNCTION Restart ( userID:Integer) : RestartOutRec ; EXTERNAL ; +FUNCTION UnloadSeg ( segmentPtr:Ptr) : UnloadSegOutRec ; EXTERNAL ; +PROCEDURE UnloadSegNum ( userID:Integer; loadFileNum:Integer; +loadSegNum:Integer) ; Tool $11,$0C; +FUNCTION UserShutDown ( userID:Integer; restartFlag:Integer) : Integer ; Tool +$11,$12; +IMPLEMENTATION +END. diff --git a/pascal/locator.p b/pascal/locator.p new file mode 100755 index 0000000..7f91b39 --- /dev/null +++ b/pascal/locator.p @@ -0,0 +1,87 @@ +{******************************************** +; File: Locator.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT LOCATOR; +INTERFACE +USES TYPES; +CONST + +(* *** Toolset Errors *** +toolNotFoundErr = $0001; {error - } +funcNotFoundErr = $0002; {error - } +toolVersionErr = $0110; {error - } +sysStrtMtErr = $0100; {error - can't mount system startup volume } +messNotFoundErr = $0111; {error - } + *** Toolset Errors *** *) + +fileInfoType = $0001; {MessageCenter - Message type parameter } +addMessage = $0001; {MessageCenter - action parameter } +getMessage = $0002; {MessageCenter - action parameter } +deleteMessage = $0003; {MessageCenter - action parameter } +mvReturn = $0001; {TLMountVolume - like ok for dialogs } +mvEscape = $0002; {TLMountVolume - like cancel for dialogs } +sysTool = $0000; {Tool Set Spec - } +userTool = $8000; {Tool Set Spec - } + +TYPE +MessageRecHndl = ^MessageRecPtr; +MessageRecPtr = ^MessageRec; +MessageRec = RECORD + messageNext : MessageRecHndl; + messageType : Integer; + messageData : Integer; + fileNames : PACKED ARRAY[1..1] OF Str255; +END; +ToolSpec = RECORD + toolNumber : Integer; + minVersion : Integer; +END; +StartStopRecordPtr = ^StartStopRecord; +StartStopRecord = RECORD + flags : Integer; + videoMode : Integer; + resFileID : Integer; + dPageHandle : Handle; + numTools : Integer; +END; +PROCEDURE TLBootInit ; Tool $01,$01; +PROCEDURE TLStartUp ; Tool $01,$02; +PROCEDURE TLShutDown ; Tool $01,$03; +FUNCTION TLVersion : Integer ; Tool $01,$04; +PROCEDURE TLReset ; Tool $01,$05; +FUNCTION TLStatus : Boolean ; Tool $01,$06; +FUNCTION GetFuncPtr ( userOrSystem:Integer; funcTSNum:Integer) : Ptr ; Tool +$01,$0B; +FUNCTION GetTSPtr ( userOrSystem:Integer; tSNum:Integer) : Ptr ; Tool $01,$09; +FUNCTION GetWAP ( userOrSystem:Integer; tSNum:Integer) : Ptr ; Tool $01,$0C; +PROCEDURE LoadOneTool ( toolNumber:Integer; minVersion:Integer) ; Tool +$01,$0F; +PROCEDURE LoadTools ( toolTablePtr:Ptr) ; Tool $01,$0E; +PROCEDURE MessageCenter ( action:Integer; messagetype:Integer; +messageHandle:MessageRecHndl) ; Tool $01,$15; +PROCEDURE RestoreTextState ( stateHandle:Handle) ; Tool $01,$14; +FUNCTION SaveTextState : Handle ; Tool $01,$13; +PROCEDURE SetDefaultTPT ; Tool $01,$16; +PROCEDURE SetTSPtr ( userOrSystem:Integer; tsNum:Integer; fptablePtr:FPTPtr) ; +Tool $01,$0A; +PROCEDURE SetWAP ( userOrSystem:Integer; tSNum:Integer; waptPtr:Ptr) ; Tool +$01,$0D; +FUNCTION TLMountVolume ( whereX:Integer; whereY:Integer; line1:Str255; +line2:Str255; but1:Str255; but2:Str255) : Integer ; Tool $01,$11; +FUNCTION TLTextMountVolume ( line1:Str255; line2:Str255; but1:Str255; +but2:Str255) : Integer ; Tool $01,$12; +PROCEDURE UnloadOneTool ( toolNumber:Integer) ; Tool $01,$10; +FUNCTION StartUpTools ( userID:Integer; startStopRefDesc:RefDescriptor; +startStopRef:Ref) : Ref ; Tool $01,$18; +PROCEDURE ShutDownTools ( startStopDesc:RefDescriptor; startStopRef:Ref) ; +Tool $01,$19; +FUNCTION MessageByName ( createItFlag:Boolean; recordPtr:Ptr) : Longint ; Tool +$01,$17; +IMPLEMENTATION +END. diff --git a/pascal/memory.p b/pascal/memory.p new file mode 100755 index 0000000..0da8ff2 --- /dev/null +++ b/pascal/memory.p @@ -0,0 +1,80 @@ +{******************************************** +; File: Memory.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT MEMORY; +INTERFACE +USES TYPES; +CONST + +(* *** Toolset Errors *** +memErr = $0201; {error - unable to allocate block } +emptyErr = $0202; {error - illegal operation, empty handle } +notEmptyErr = $0203; {error - an empty handle was expected for this operation } +lockErr = $0204; {error - illegal operation on a locked block } +purgeErr = $0205; {error - attempt to purge an unpurgable block } +handleErr = $0206; {error - an invalid handle was given } +idErr = $0207; {error - an invalid owner ID was given } +attrErr = $0208; {error - operation illegal on block with given attributes } + *** Toolset Errors *** *) + +attrNoPurge = $0000; {Handle Attribute Bits - Not purgeable } +attrBank = $0001; {Handle Attribute Bits - fixed bank } +attrAddr = $0002; {Handle Attribute Bits - fixed address } +attrPage = $0004; {Handle Attribute Bits - page aligned } +attrNoSpec = $0008; {Handle Attribute Bits - may not use special memory } +attrNoCross = $0010; {Handle Attribute Bits - may not cross banks } +attrPurge1 = $0100; {Handle Attribute Bits - Purge level 1 } +attrPurge2 = $0200; {Handle Attribute Bits - Purge level 2 } +attrPurge3 = $0300; {Handle Attribute Bits - Purge level 3 } +attrPurge = $0300; {Handle Attribute Bits - test or set both purge bits } +attrHandle = $1000; {Handle Attribute Bits - block of master pointers } +attrSystem = $2000; {Handle Attribute Bits - system handle } +attrFixed = $4000; {Handle Attribute Bits - not movable } +attrLocked = $8000; {Handle Attribute Bits - locked } +PROCEDURE MMBootInit ; Tool $02,$01; +FUNCTION MMStartUp : Integer ; Tool $02,$02; +PROCEDURE MMShutDown ( userID:Integer) ; Tool $02,$03; +FUNCTION MMVersion : Integer ; Tool $02,$04; +PROCEDURE MMReset ; Tool $02,$05; +FUNCTION MMStatus : Boolean ; Tool $02,$06; +PROCEDURE BlockMove ( srcPtr:Ptr; dstPtr:Ptr; count:Longint) ; Tool $02,$2B; +PROCEDURE CheckHandle ( theHandle:Handle) ; Tool $02,$1E; +PROCEDURE CompactMem ; Tool $02,$1F; +PROCEDURE DisposeAll ( userID:Integer) ; Tool $02,$11; +PROCEDURE DisposeHandle ( theHandle:Handle) ; Tool $02,$10; +FUNCTION FindHandle ( locationPtr:Ptr) : Handle ; Tool $02,$1A; +FUNCTION FreeMem : Longint ; Tool $02,$1B; +FUNCTION GetHandleSize ( theHandle:Handle) : Longint ; Tool $02,$18; +PROCEDURE HandToHand ( sourceHandle:Handle; destHandle:Handle; count:Longint) +; Tool $02,$2A; +PROCEDURE HandToPtr ( sourceHandle:Handle; destPtr:Ptr; count:Longint) ; Tool +$02,$29; +PROCEDURE HLock ( theHandle:Handle) ; Tool $02,$20; +PROCEDURE HLockAll ( userID:Integer) ; Tool $02,$21; +PROCEDURE HUnlock ( theHandle:Handle) ; Tool $02,$22; +PROCEDURE HUnlockAll ( userID:Integer) ; Tool $02,$23; +FUNCTION MaxBlock : Longint ; Tool $02,$1C; +FUNCTION NewHandle ( blockSize:Longint; userID:Integer; attributes:Integer; +locationPtr:Ptr) : Handle ; Tool $02,$09; +PROCEDURE PtrToHand ( sourcePtr:Ptr; destHandle:Handle; count:Longint) ; Tool +$02,$28; +PROCEDURE PurgeAll ( userID:Integer) ; Tool $02,$13; +PROCEDURE PurgeHandle ( theHandle:Handle) ; Tool $02,$12; +FUNCTION RealFreeMem : Longint ; Tool $02,$2F; +PROCEDURE ReallocHandle ( blockSize:Longint; userID:Integer; +attributes:Integer; locationPtr:Ptr; theHandle:Handle) ; Tool $02,$0A; +PROCEDURE RestoreHandle ( theHandle:Handle) ; Tool $02,$0B; +PROCEDURE SetHandleSize ( newSize:Longint; theHandle:Handle) ; Tool $02,$19; +PROCEDURE SetPurge ( newPurgeLevel:Integer; theHandle:Handle) ; Tool $02,$24; +PROCEDURE SetPurgeAll ( newPurgeLevel:Integer; userID:Integer) ; Tool $02,$25; +FUNCTION TotalMem : Longint ; Tool $02,$1D; +PROCEDURE AddToOOMQueue ( headerPtr:Ptr) ; Tool $02,$0C; +PROCEDURE DeleteFromOOMQueue ( headerPtr:Ptr) ; Tool $02,$0D; +IMPLEMENTATION +END. diff --git a/pascal/menus.p b/pascal/menus.p new file mode 100755 index 0000000..1ea6887 --- /dev/null +++ b/pascal/menus.p @@ -0,0 +1,142 @@ +{******************************************** +; File: Menus.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT MENUS; +INTERFACE +USES TYPES,QUICKDRAW,EVENTS,CONTROLS,WINDOWS; +CONST + +mDrawMsg = $0000; {MenuDefProcCodes - } +mChooseMsg = $0001; {MenuDefProcCodes - } +mSizeMsg = $0002; {MenuDefProcCodes - } +mDrawTitle = $0003; {MenuDefProcCodes - } +mDrawMItem = $0004; {MenuDefProcCodes - } +mGetMItemID = $0005; {MenuDefProcCodes - } +mInvis = $0004; {MenuFlag - } +mCustom = $0010; {MenuFlag - } +mXor = $0020; {MenuFlag - } +mSelected = $0040; {MenuFlag - } +mDisabled = $0080; {MenuFlag - } +customMenu = $0010; {MenuFlagMasks - } +xorMItemHilite = $0020; {MenuFlagMasks - } +xorTitleHilite = $0020; {MenuFlagMasks - } +underMItem = $0040; {MenuFlagMasks - } +disableItem = $0080; {MenuFlagMasks - } +disableMenu = $0080; {MenuFlagMasks - } +enableItem = $FF7F; {MenuFlagMasks - } +enableMenu = $FF7F; {MenuFlagMasks - } +noUnderMItem = $FFBF; {MenuFlagMasks - } +colorMItemHilite = $FFDF; {MenuFlagMasks - } +colorTitleHilite = $FFDF; {MenuFlagMasks - } +colorReplace = $FFDF; {MenuFlagMasks - } +standardMenu = $FFEF; {MenuFlagMasks - } + +TYPE +MenuBarRecHndl = ^MenuBarRecPtr; +MenuBarRecPtr = ^MenuBarRec; +MenuBarRec = CtlRec ; +MenuRecHndl = ^MenuRecPtr; +MenuRecPtr = ^MenuRec; +MenuRec = PACKED RECORD + menuID : Integer; { Menu's ID number } + menuWidth : Integer; { Width of menu } + menuHeight : Integer; { Height of menu } + menuProc : WordProcPtr; { Menu's definition procedure } + menuFlag : Integer; { Bit flags } + firstItem : Byte; + numOfItems : Byte; + titleWidth : Integer; { Width of menu's title } + titleName : Ptr; +END; +PROCEDURE MenuBootInit ; Tool $0F,$01; +PROCEDURE MenuStartUp ( userID:Integer; dPageAddr:Integer) ; Tool $0F,$02; +PROCEDURE MenuShutDown ; Tool $0F,$03; +FUNCTION MenuVersion : Integer ; Tool $0F,$04; +PROCEDURE MenuReset ; Tool $0F,$05; +FUNCTION MenuStatus : Boolean ; Tool $0F,$06; +PROCEDURE CalcMenuSize ( newWidth:Integer; newHeight:Integer; menuNum:Integer) +; Tool $0F,$1C; +PROCEDURE CheckMItem ( checkedFlag:Boolean; itemNum:Integer) ; Tool $0F,$32; +FUNCTION CountMItems ( menuNum:Integer) : Integer ; Tool $0F,$14; +PROCEDURE DeleteMenu ( menuNum:Integer) ; Tool $0F,$0E; +PROCEDURE DeleteMItem ( itemNum:Integer) ; Tool $0F,$10; +PROCEDURE DisableMItem ( itemNum:Integer) ; Tool $0F,$31; +PROCEDURE DisposeMenu ( menuHandle:MenuRecHndl) ; Tool $0F,$2E; +PROCEDURE DrawMenuBar ; Tool $0F,$2A; +PROCEDURE EnableMItem ( itemNum:Integer) ; Tool $0F,$30; +FUNCTION FixMenuBar : Integer ; Tool $0F,$13; +PROCEDURE FlashMenuBar ; Tool $0F,$0C; +FUNCTION GetBarColors : Longint ; Tool $0F,$18; +FUNCTION GetMenuBar : MenuBarRecHndl ; Tool $0F,$0A; +FUNCTION GetMenuFlag ( menuNum:Integer) : Integer ; Tool $0F,$20; +FUNCTION GetMenuMgrPort : GrafPortPtr ; Tool $0F,$1B; +FUNCTION GetMenuTitle ( menuNum:Integer) : Ptr ; Tool $0F,$22; +FUNCTION GetMHandle ( menuNum:Integer) : MenuRecHndl ; Tool $0F,$16; +FUNCTION GetMItem ( itemNum:Integer) : StringPtr ; Tool $0F,$25; +FUNCTION GetMItemFlag ( itemNum:Integer) : Integer ; Tool $0F,$27; +FUNCTION GetMItemMark ( itemNum:Integer) : Integer ; Tool $0F,$34; +FUNCTION GetMItemStyle ( itemNum:Integer) : TextStyle ; Tool $0F,$36; +FUNCTION GetMTitleStart : Integer ; Tool $0F,$1A; +FUNCTION GetMTitleWidth ( menuNum:Integer) : Integer ; Tool $0F,$1E; +FUNCTION GetSysBar : MenuBarRecHndl ; Tool $0F,$11; +PROCEDURE HiliteMenu ( hiliteFlag:Boolean; menuNum:Integer) ; Tool $0F,$2C; +PROCEDURE InitPalette ; Tool $0F,$2F; +PROCEDURE InsertMenu ( addMenuHandle:MenuRecHndl; insertAfter:Integer) ; Tool +$0F,$0D; +PROCEDURE InsertMItem ( addItemPtr:Ptr; insertAfter:Integer; menuNum:Integer) +; Tool $0F,$0F; +FUNCTION MenuGlobal ( menuGlobalMask:Integer) : Integer ; Tool $0F,$23; +PROCEDURE MenuKey ( taskRecPtr:WmTaskRec; barHandle:MenuBarRecHndl) ; Tool +$0F,$09; +PROCEDURE MenuNewRes ; Tool $0F,$29; +PROCEDURE MenuRefresh ( redrawRoutinePtr:VoidProcPtr) ; Tool $0F,$0B; +PROCEDURE MenuSelect ( taskRecPtr:WmTaskRec; barHandle:MenuBarRecHndl) ; Tool +$0F,$2B; +FUNCTION NewMenu ( menuStringPtr:Ptr) : MenuRecHndl ; Tool $0F,$2D; +FUNCTION NewMenuBar ( theWindowPtr:WindowPtr) : MenuBarRecHndl ; Tool $0F,$15; +PROCEDURE SetBarColors ( newBarColor:Integer; newInvertColor:Integer; +newOutColor:Integer) ; Tool $0F,$17; +PROCEDURE SetMenuBar ( barHandle:MenuBarRecHndl) ; Tool $0F,$39; +PROCEDURE SetMenuFlag ( newValue:Integer; menuNum:Integer) ; Tool $0F,$1F; +PROCEDURE SetMenuID ( newMenuNum:Integer; curMenuNum:Integer) ; Tool $0F,$37; +PROCEDURE SetMenuTitle ( newStr:Str255; menuNum:Integer) ; Tool $0F,$21; +PROCEDURE SetMItem ( newItemLine:Str255; itemNum:Integer) ; Tool $0F,$24; +PROCEDURE SetMItemBlink ( count:Integer) ; Tool $0F,$28; +PROCEDURE SetMItemFlag ( newValue:Integer; itemNum:Integer) ; Tool $0F,$26; +PROCEDURE SetMItemID ( newItemNum:Integer; curItemNum:Integer) ; Tool $0F,$38; +PROCEDURE SetMItemMark ( mark:Integer; itemNum:Integer) ; Tool $0F,$33; +PROCEDURE SetMItemName ( str:Str255; itemNum:Integer) ; Tool $0F,$3A; +PROCEDURE SetMItemStyle ( theTextStyle:TextStyle; itemNum:Integer) ; Tool +$0F,$35; +PROCEDURE SetMTitleStart ( xStart:Integer) ; Tool $0F,$19; +PROCEDURE SetMTitleWidth ( newWidth:Integer; menuNum:Integer) ; Tool $0F,$1D; +PROCEDURE SetSysBar ( barHandle:MenuBarRecHndl) ; Tool $0F,$12; +FUNCTION PopUpMenuSelect ( selection:Integer; currentLeft:Integer; +currentTop:Integer; flag:Integer; menuHandle:MenuRecHndl) : Integer ; Tool +$0F,$3C; +FUNCTION GetPopUpDefProc : Ptr ; Tool $0F,$3B; +PROCEDURE DrawPopUp ( selection:Integer; flag:Integer; right:Integer; +bottom:Integer; left:Integer; top:Integer; menuHandle:MenuRecHndl) ; Tool +$0F,$3D; +FUNCTION NewMenuBar2 ( refDesc:RefDescriptor; menuBarTemplateRef:Ref; +windowPortPtr:GrafPortPtr) : MenuBarRecHndl ; Tool $0F,$43; +FUNCTION NewMenu2 ( refDesc:RefDescriptor; menuTemplateRef:Ref) : MenuRecHndl ; +Tool $0F,$3E; +PROCEDURE InsertMItem2 ( refDesc:RefDescriptor; menuTemplateRef:Ref; +insertAfter:Integer; menuNum:Integer) ; Tool $0F,$3F; +PROCEDURE SetMenuTitle2 ( refDesc:RefDescriptor; titleRef:Ref; menuNum:Integer) +; Tool $0F,$40; +PROCEDURE SetMItem2 ( refDesc:RefDescriptor; menuItemTempRef:Ref; +menuItemID:Integer) ; Tool $0F,$41; +PROCEDURE SetMItemName2 ( refDesc:RefDescriptor; titleRef:Ref; +menuItemID:Integer) ; Tool $0F,$42; +PROCEDURE HideMenuBar ; Tool $0F,$45; +PROCEDURE ShowMenuBar ; Tool $0F,$46; +IMPLEMENTATION +END. diff --git a/pascal/midi.p b/pascal/midi.p new file mode 100755 index 0000000..8bf3587 --- /dev/null +++ b/pascal/midi.p @@ -0,0 +1,119 @@ +{******************************************** +; File: MIDI.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT MIDI; +INTERFACE +USES TYPES; +CONST + +miToolNum = $0020; {Midi - the tool number of the MIDI Tool Set } +miDrvrFileType = $00BB; {Midi - filetype of MIDI device driver } +miNSVer = $0102; {Midi - minimum version of Note Synthesizer required by MIDI +Tool Set } +miSTVer = $0203; {Midi - minimum version of Sound Tools needed by MIDI Tool Set +} +miDrvrAuxType = $0300; {Midi - aux type of MIDI device driver } + +(* *** Toolset Errors *** +miStartUpErr = $2000; {Midi - MIDI Tool Set is not started } +miPacketErr = $2001; {Midi - incorrect length for a received MIDI command } +miArrayErr = $2002; {Midi - a designated array had an insufficient or illegal +size } +miFullBufErr = $2003; {Midi - input buffer overflow } +miToolsErr = $2004; {Midi - the required tools were not started up or had +insufficient versions } +miOutOffErr = $2005; {Midi - MIDI output must first be enabled } +miNoBufErr = $2007; {Midi - no buffer is currently allocated } +miDriverErr = $2008; {Midi - the designated file is not a legal MIDI device +driver } +miBadFreqErr = $2009; {Midi - the MIDI clock cannot attain the requested +frequency } +miClockErr = $200A; {Midi - the MIDI clock value wrapped to zero } +miConflictErr = $200B; {Midi - conflicting processes for MIDI input } +miNoDevErr = $200C; {Midi - no MIDI device driver loaded } +miDevNotAvail = $2080; {Midi - the requested device is not available } +miDevSlotBusy = $2081; {Midi - requested slot is already in use } +miDevBusy = $2082; {Midi - the requested device is already in use } +miDevOverrun = $2083; {Midi - device overrun by incoming MIDI data } +miDevNoConnect = $2084; {Midi - no connection to MIDI } +miDevReadErr = $2085; {Midi - framing error in received MIDI data } +miDevVersion = $2086; {Midi - ROM version is incompatible with device driver } +miDevIntHndlr = $2087; {Midi - conflicting interrupt handler is installed } + *** Toolset Errors *** *) + +miSetClock = $0000; {MidiClock - set time stamp clock } +miStartClock = $0001; {MidiClock - start time stamp clock } +miStopClock = $0002; {MidiClock - stop time stamp clock } +miSetFreq = $0003; {MidiClock - set clock frequency } +miRawMode = $00000000; {MidiControl - raw mode for MIDI input and output } +miSetRTVec = $0000; {MidiControl - set real-time message vector } +miPacketMode = $00000001; {MidiControl - packet mode for MIDI input and output +} +miSetErrVec = $0001; {MidiControl - set real-time error vector } +miStandardMode = $00000002; {MidiControl - standard mode for MIDI input and +output } +miSetInBuf = $0002; {MidiControl - set input buffer information } +miSetOutBuf = $0003; {MidiControl - set output buffer information } +miStartInput = $0004; {MidiControl - start MIDI input } +miStartOutput = $0005; {MidiControl - start MIDI output } +miStopInput = $0006; {MidiControl - stop MIDI input } +miStopOutput = $0007; {MidiControl - stop MIDI output } +miFlushInput = $0008; {MidiControl - discard contents of input buffer } +miFlushOutput = $0009; {MidiControl - discard contents of output buffer } +miFlushPacket = $000A; {MidiControl - discard next input packet } +miWaitOutput = $000B; {MidiControl - wait for output buffer to empty } +miSetInMode = $000C; {MidiControl - set input mode } +miSetOutMode = $000D; {MidiControl - set output mode } +miClrNotePad = $000E; {MidiControl - clear all notes marked on in the note pad +} +miSetDelay = $000F; {MidiControl - set minimum delay between output packets } +miOutputStat = $0010; {MidiControl - enable/disable output of running-status } +miIgnoreSysEx = $0011; {MidiControl - ignore system exclusive input } +miSelectDrvr = $0000; {MidiDevice - display device driver selection dialog } +miLoadDrvr = $0001; {MidiDevice - load and initialize device driver } +miUnloadDrvr = $0002; {MidiDevice - shutdown MIDI device, unload driver } +miNextPktLen = $0; {MidiInfo - return length of next packet } +miInputChars = $0001; {MidiInfo - return number of characters in input buffer } +miOutputChars = $0002; {MidiInfo - return number of characters in output buffer +} +miMaxInChars = $0003; {MidiInfo - return maximum number of characters in input +buffer } +miMaxOutChars = $0004; {MidiInfo - return maximum number of characters in +output buffer } +miRecordAddr = $0005; {MidiInfo - return current MidiRecordSeq address } +miPlayAddr = $0006; {MidiInfo - return current MidiPlaySeq address } +miClockValue = $0007; {MidiInfo - return current time stamp clock value } +miClockFreq = $0008; {MidiInfo - return number of clock ticks per second } + +TYPE +MiBufInfo = RECORD + bufSize : Integer; { size of buffer (0 for default) } + address : Ptr; { address of buffer (0 for auto-allocation) } +END; +MiDriverInfo = RECORD + slot : Integer; { device slot } + external : Integer; { slot internal (=0) / external (=1) } + pathname : PACKED ARRAY[1..65] OF Byte; { device driver pathname } +END; +PROCEDURE MidiBootInit ; Tool $20,$01; +PROCEDURE MidiStartUp ( userID:Integer; directPages:Integer) ; Tool $20,$02; +PROCEDURE MidiShutDown ; Tool $20,$03; +FUNCTION MidiVersion : Integer ; Tool $20,$04; +PROCEDURE MidiReset ; Tool $20,$05; +FUNCTION MidiStatus : Boolean ; Tool $20,$06; +PROCEDURE MidiClock ( funcNum:Integer; arg:Longint) ; Tool $20,$0B; +PROCEDURE MidiControl ( controlCode:Integer) ; Tool $20,$09; +PROCEDURE MidiDevice ( funcNum:Integer; driverInfo:Ptr) ; Tool $20,$0A; +FUNCTION MidiInfo ( funcNum:Integer) : Longint ; Tool $20,$0C; +PROCEDURE MidiInputPoll ; EXTERNAL ; +FUNCTION MidiReadPacket ( arrayAddr:Ptr; arraySize:Integer) : Integer ; Tool +$20,$0D; +FUNCTION MidiWritePacket ( arrayAddr:Ptr) : Integer ; Tool $20,$0E; +IMPLEMENTATION +END. diff --git a/pascal/misctool.p b/pascal/misctool.p new file mode 100755 index 0000000..bd49668 --- /dev/null +++ b/pascal/misctool.p @@ -0,0 +1,367 @@ +{******************************************** +; File: MiscTool.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT MISCTOOL; +INTERFACE +USES TYPES; + +(* *** Toolset Errors *** +CONST +badInputErr = $0301; {error - bad input parameter } +noDevParamErr = $0302; {error - no device for input parameter } +taskInstlErr = $0303; {error - task already installed error } +noSigTaskErr = $0304; {error - no signature in task header } +queueDmgdErr = $0305; {error - queue has been damaged error } +taskNtFdErr = $0306; {error - task was not found error } +firmTaskErr = $0307; {error - firmware task was unsuccessful } +hbQueueBadErr = $0308; {error - heartbeat queue damaged } +unCnctdDevErr = $0309; {error - attempted to dispatch to unconnected device } +idTagNtAvlErr = $030B; {error - ID tag not available } +pdosUnClmdIntErr = $0001; {System Fail - ProDOS unclaimed interrupt error } +divByZeroErr = $0004; {System Fail - divide by zero error } +pdosVCBErr = $000A; {System Fail - ProDOS VCB unusable } +pdosFCBErr = $000B; {System Fail - ProDOS FCB unusable } +pdosBlk0Err = $000C; {System Fail - ProDOS block zero allocated illegally } +pdosIntShdwErr = $000D; {System Fail - ProDOS interrupt w/ shadowing off } +segLoader1Err = $0015; {System Fail - segment loader error } +sPackage0Err = $0017; {System Fail - can't load a package } +package1Err = $0018; {System Fail - can't load a package } +package2Err = $0019; {System Fail - can't load a package } +package3Err = $001A; {System Fail - can't load a package } +package4Err = $001B; {System Fail - can't load a package } +package5Err = $001C; {System Fail - can't load a package } +package6Err = $001D; {System Fail - can't load a package } +package7Err = $001E; {System Fail - can't load a package } +package8Err = $0020; {System Fail - can't load a package } +package9Err = $0021; {System Fail - can't load a package } +package10Err = $0022; {System Fail - can't load a package } +package11Err = $0023; {System Fail - can't load a package } +package12Err = $0024; {System Fail - can't load a package } +outOfMemErr = $0025; {System Fail - out of memory error } +segLoader2Err = $0026; {System Fail - segment loader error } +fMapTrshdErr = $0027; {System Fail - file map trashed } +stkOvrFlwErr = $0028; {System Fail - stack overflow error } +psInstDiskErr = $0030; {System Fail - Please Insert Disk (file manager alert) } +memMgr1Err = $0032; {System Fail - memory manager error } +memMgr2Err = $0033; {System Fail - memory manager error } +memMgr3Err = $0034; {System Fail - memory manager error } +memMgr4Err = $0035; {System Fail - memory manager error } +memMgr5Err = $0036; {System Fail - memory manager error } +memMgr6Err = $0037; {System Fail - memory manager error } +memMgr7Err = $0038; {System Fail - memory manager error } +memMgr8Err = $0039; {System Fail - memory manager error } +memMgr9Err = $003A; {System Fail - memory manager error } +memMgr10Err = $003B; {System Fail - memory manager error } +memMgr11Err = $003C; {System Fail - memory manager error } +memMgr12Err = $003D; {System Fail - memory manager error } +memMgr13Err = $003E; {System Fail - memory manager error } +memMgr14Err = $003F; {System Fail - memory manager error } +memMgr15Err = $0040; {System Fail - memory manager error } +memMgr16Err = $0041; {System Fail - memory manager error } +memMgr17Err = $0042; {System Fail - memory manager error } +memMgr18Err = $0043; {System Fail - memory manager error } +memMgr19Err = $0044; {System Fail - memory manager error } +memMgr20Err = $0045; {System Fail - memory manager error } +memMgr21Err = $0046; {System Fail - memory manager error } +memMgr22Err = $0047; {System Fail - memory manager error } +memMgr23Err = $0048; {System Fail - memory manager error } +memMgr24Err = $0049; {System Fail - memory manager error } +memMgr25Err = $004A; {System Fail - memory manager error } +memMgr26Err = $004B; {System Fail - memory manager error } +memMgr27Err = $004C; {System Fail - memory manager error } +memMgr28Err = $004D; {System Fail - memory manager error } +memMgr29Err = $004E; {System Fail - memory manager error } +memMgr30Err = $004F; {System Fail - memory manager error } +memMgr31Err = $0050; {System Fail - memory manager error } +memMgr32Err = $0051; {System Fail - memory manager error } +memMgr33Err = $0052; {System Fail - memory manager error } +memMgr34Err = $0053; {System Fail - memory manager error } +stupVolMntErr = $0100; {System Fail - can't mount system startup volume } + *** Toolset Errors *** *) + +(* *** Reference Numbers *** +p1PrntModem = $0000; {Battery Ram Parameter Ref Number - } +p1LineLnth = $0001; {Battery Ram Parameter Ref Number - } +p1DelLine = $0002; {Battery Ram Parameter Ref Number - } +p1AddLine = $0003; {Battery Ram Parameter Ref Number - } +p1Echo = $0004; {Battery Ram Parameter Ref Number - } +p1Buffer = $0005; {Battery Ram Parameter Ref Number - } +p1Baud = $0006; {Battery Ram Parameter Ref Number - } +p1DtStpBits = $0007; {Battery Ram Parameter Ref Number - } +p1Parity = $0008; {Battery Ram Parameter Ref Number - } +p1DCDHndShk = $0009; {Battery Ram Parameter Ref Number - } +p1DSRHndShk = $000A; {Battery Ram Parameter Ref Number - } +p1XnfHndShk = $000B; {Battery Ram Parameter Ref Number - } +p2PrntModem = $000C; {Battery Ram Parameter Ref Number - } +p2LineLnth = $000D; {Battery Ram Parameter Ref Number - } +p2DelLine = $000E; {Battery Ram Parameter Ref Number - } +p2AddLine = $000F; {Battery Ram Parameter Ref Number - } +p2Echo = $0010; {Battery Ram Parameter Ref Number - } +p2Buffer = $0011; {Battery Ram Parameter Ref Number - } +p2Baud = $0012; {Battery Ram Parameter Ref Number - } +p2DtStpBits = $0013; {Battery Ram Parameter Ref Number - } +p2Parity = $0014; {Battery Ram Parameter Ref Number - } +p2DCDHndShk = $0015; {Battery Ram Parameter Ref Number - } +p2DSRHndShk = $0016; {Battery Ram Parameter Ref Number - } +p2XnfHndShk = $0017; {Battery Ram Parameter Ref Number - } +dspColMono = $0018; {Battery Ram Parameter Ref Number - } +dsp40or80 = $0019; {Battery Ram Parameter Ref Number - } +dspTxtColor = $001A; {Battery Ram Parameter Ref Number - } +dspBckColor = $001B; {Battery Ram Parameter Ref Number - } +dspBrdColor = $001C; {Battery Ram Parameter Ref Number - } +hrtz50or60 = $001D; {Battery Ram Parameter Ref Number - } +userVolume = $001E; {Battery Ram Parameter Ref Number - } +bellVolume = $001F; {Battery Ram Parameter Ref Number - } +sysSpeed = $0020; {Battery Ram Parameter Ref Number - } +slt1intExt = $0021; {Battery Ram Parameter Ref Number - } +slt2intExt = $0022; {Battery Ram Parameter Ref Number - } +slt3intExt = $0023; {Battery Ram Parameter Ref Number - } +slt4intExt = $0024; {Battery Ram Parameter Ref Number - } +slt5intExt = $0025; {Battery Ram Parameter Ref Number - } +slt6intExt = $0026; {Battery Ram Parameter Ref Number - } +slt7intExt = $0027; {Battery Ram Parameter Ref Number - } +startupSlt = $0028; {Battery Ram Parameter Ref Number - } +txtDspLang = $0029; {Battery Ram Parameter Ref Number - } +kybdLang = $002A; {Battery Ram Parameter Ref Number - } +kyBdBuffer = $002B; {Battery Ram Parameter Ref Number - } +kyBdRepSpd = $002C; {Battery Ram Parameter Ref Number - } +kyBdRepDel = $002D; {Battery Ram Parameter Ref Number - } +dblClkTime = $002E; {Battery Ram Parameter Ref Number - } +flashRate = $002F; {Battery Ram Parameter Ref Number - } +shftCpsLCas = $0030; {Battery Ram Parameter Ref Number - } +fstSpDelKey = $0031; {Battery Ram Parameter Ref Number - } +dualSpeed = $0032; {Battery Ram Parameter Ref Number - } +hiMouseRes = $0033; {Battery Ram Parameter Ref Number - } +dateFormat = $0034; {Battery Ram Parameter Ref Number - } +clockFormat = $0035; {Battery Ram Parameter Ref Number - } +rdMinRam = $0036; {Battery Ram Parameter Ref Number - } +rdMaxRam = $0037; {Battery Ram Parameter Ref Number - } +langCount = $0038; {Battery Ram Parameter Ref Number - } +lang1 = $0039; {Battery Ram Parameter Ref Number - } +lang2 = $003A; {Battery Ram Parameter Ref Number - } +lang3 = $003B; {Battery Ram Parameter Ref Number - } +lang4 = $003C; {Battery Ram Parameter Ref Number - } +lang5 = $003D; {Battery Ram Parameter Ref Number - } +lang6 = $003E; {Battery Ram Parameter Ref Number - } +lang7 = $003F; {Battery Ram Parameter Ref Number - } +lang8 = $0040; {Battery Ram Parameter Ref Number - } +layoutCount = $0041; {Battery Ram Parameter Ref Number - } +layout1 = $0042; {Battery Ram Parameter Ref Number - } +layout2 = $0043; {Battery Ram Parameter Ref Number - } +layout3 = $0044; {Battery Ram Parameter Ref Number - } +layout4 = $0045; {Battery Ram Parameter Ref Number - } +layout5 = $0046; {Battery Ram Parameter Ref Number - } +layout6 = $0047; {Battery Ram Parameter Ref Number - } +layout7 = $0048; {Battery Ram Parameter Ref Number - } +layout8 = $0049; {Battery Ram Parameter Ref Number - } +layout9 = $004A; {Battery Ram Parameter Ref Number - } +layout10 = $004B; {Battery Ram Parameter Ref Number - } +layout11 = $004C; {Battery Ram Parameter Ref Number - } +layout12 = $004D; {Battery Ram Parameter Ref Number - } +layout13 = $004E; {Battery Ram Parameter Ref Number - } +layout14 = $004F; {Battery Ram Parameter Ref Number - } +layout15 = $0050; {Battery Ram Parameter Ref Number - } +layout16 = $0051; {Battery Ram Parameter Ref Number - } +aTalkNodeNo = $0080; {Battery Ram Parameter Ref Number - } + +irqIntFlag = $0000; {GetAddr Param Ref No - } +irqDataReg = $0001; {GetAddr Param Ref No - } +irqSerial1 = $0002; {GetAddr Param Ref No - } +irqSerial2 = $0003; {GetAddr Param Ref No - } +irqAplTlkHi = $0004; {GetAddr Param Ref No - } +tickCnt = $0005; {GetAddr Param Ref No - } +irqVolume = $0006; {GetAddr Param Ref No - } +irqActive = $0007; {GetAddr Param Ref No - } +irqSndData = $0008; {GetAddr Param Ref No - } +brkVar = $0009; {GetAddr Param Ref No - } +evMgrData = $000A; {GetAddr Param Ref No - } +mouseSlot = $000B; {GetAddr Param Ref No - } +mouseClamps = $000C; {GetAddr Param Ref No - } +absClamps = $000D; {GetAddr Param Ref No - } +sccIntFlag = $000E; {GetAddr Param Ref No - } + +extVGCInt = $01; {Hardware Interrupt Status - Returned by GetIRQEnable } +scanLineInt = $02; {Hardware Interrupt Status - Returned by GetIRQEnable } +adbDataInt = $04; {Hardware Interrupt Status - Returned by GetIRQEnable } +ADTBDataInt = $04; {Hardware Interrupt Status - maintained for compatiblity +with old interfaces } +oneSecInt = $10; {Hardware Interrupt Status - Returned by GetIRQEnable } +quartSecInt = $20; {Hardware Interrupt Status - Returned by GetIRQEnable } +vbInt = $40; {Hardware Interrupt Status - Returned by GetIRQEnable } +kbdInt = $80; {Hardware Interrupt Status - Returned by GetIRQEnable } + +kybdEnable = $0000; {Interrupt Ref Number - Parameter to IntSource } +kybdDisable = $0001; {Interrupt Ref Number - Parameter to IntSource } +vblEnable = $0002; {Interrupt Ref Number - Parameter to IntSource } +vblDisable = $0003; {Interrupt Ref Number - Parameter to IntSource } +qSecEnable = $0004; {Interrupt Ref Number - Parameter to IntSource } +qSecDisable = $0005; {Interrupt Ref Number - Parameter to IntSource } +oSecEnable = $0006; {Interrupt Ref Number - Parameter to IntSource } +oSecDisable = $0007; {Interrupt Ref Number - Parameter to IntSource } +adbEnable = $000A; {Interrupt Ref Number - Parameter to IntSource } +adbDisable = $000B; {Interrupt Ref Number - Parameter to IntSource } +scLnEnable = $000C; {Interrupt Ref Number - Parameter to IntSource } +scLnDisable = $000D; {Interrupt Ref Number - Parameter to IntSource } +exVCGEnable = $000E; {Interrupt Ref Number - Parameter to IntSource } +exVCGDisable = $000F; {Interrupt Ref Number - Parameter to IntSource } + +mouseOff = $0000; {Mouse Mode Value - } +transparent = $0001; {Mouse Mode Value - } +transParnt = $0001; {Mouse Mode Value - (old name) } +moveIntrpt = $0003; {Mouse Mode Value - } +bttnIntrpt = $0005; {Mouse Mode Value - } +bttnOrMove = $0007; {Mouse Mode Value - } +mouseOffVI = $0008; {Mouse Mode Value - } +transParntVI = $0009; {Mouse Mode Value - (old name) } +transparentVI = $0009; {Mouse Mode Value - } +moveIntrptVI = $000B; {Mouse Mode Value - } +bttnIntrptVI = $000D; {Mouse Mode Value - } +bttnOrMoveVI = $000F; {Mouse Mode Value - } + +toolLoc1 = $0000; {Vector Ref Number - } +toolLoc2 = $0001; {Vector Ref Number - } +usrTLoc1 = $0002; {Vector Ref Number - } +usrTLoc2 = $0003; {Vector Ref Number - } +intrptMgr = $0004; {Vector Ref Number - } +copMgr = $0005; {Vector Ref Number - } +abortMgr = $0006; {Vector Ref Number - } +U_sysFailMgr = $0007; {Vector Ref Number - } +aTalkIntHnd = $0008; {Vector Ref Number - } +sccIntHnd = $0009; {Vector Ref Number - } +scLnIntHnd = $000A; {Vector Ref Number - } +sndIntHnd = $000B; {Vector Ref Number - } +vblIntHnd = $000C; {Vector Ref Number - } +mouseIntHnd = $000D; {Vector Ref Number - } +qSecIntHnd = $000E; {Vector Ref Number - } +kybdIntHnd = $000F; {Vector Ref Number - } +adbRBIHnd = $0010; {Vector Ref Number - } +adbSRQHnd = $0011; {Vector Ref Number - } +deskAccHnd = $0012; {Vector Ref Number - } +flshBufHnd = $0013; {Vector Ref Number - } +kybdMicHnd = $0014; {Vector Ref Number - } +oneSecHnd = $0015; {Vector Ref Number - } +extVCGHnd = $0016; {Vector Ref Number - } +otherIntHnd = $0017; {Vector Ref Number - } +crsrUpdtHnd = $0018; {Vector Ref Number - } +incBsyFlag = $0019; {Vector Ref Number - } +decBsyFlag = $001A; {Vector Ref Number - } +bellVector = $001B; {Vector Ref Number - } +breakVector = $001C; {Vector Ref Number - } +traceVector = $001D; {Vector Ref Number - } +stepVector = $001E; {Vector Ref Number - } +ctlYVector = $0028; {Vector Ref Number - } +proDOSVctr = $002A; {Vector Ref Number - } +osVector = $002B; {Vector Ref Number - } +msgPtrVctr = $002C; {Vector Ref Number - } + *** Reference Numbers *** *) + + +TYPE +ClampRecHndl = ^ClampRecPtr; +ClampRecPtr = ^ClampRec; +ClampRec = RECORD + yMaxClamp : Integer; + yMinClamp : Integer; + xMaxClamp : Integer; + xMinClamp : Integer; +END; +FWRecHndl = ^FWRecPtr; +FWRecPtr = ^FWRec; +FWRec = RECORD + yRegExit : Integer; + xRegExit : Integer; + aRegExit : Integer; + status : Integer; +END; +MouseRecHndl = ^MouseRecPtr; +MouseRecPtr = ^MouseRec; +MouseRec = PACKED RECORD + mouseMode : Byte; + mouseStatus : Byte; + yPos : Integer; + xPos : Integer; +END; +InterruptStateRecHndl = ^InterruptStateRecPtr; +InterruptStateRecPtr = ^InterruptStateRec; +InterruptStateRec = PACKED RECORD + irq_A : Integer; + irq_X : Integer; + irq_Y : Integer; + irq_S : Integer; + irq_D : Integer; + irq_P : Byte; + irq_DB : Byte; + irq_e : Byte; + irq_K : Byte; + irq_PC : Integer; + irq_state : Byte; + irq_shadow : Integer; + irq_mslot : Byte; +END; +PROCEDURE MTBootInit ; Tool $03,$01; +PROCEDURE MTStartUp ; Tool $03,$02; +PROCEDURE MTShutDown ; Tool $03,$03; +FUNCTION MTVersion : Integer ; Tool $03,$04; +PROCEDURE MTReset ; Tool $03,$05; +FUNCTION MTStatus : Boolean ; Tool $03,$06; +PROCEDURE ClampMouse ( xMinClamp:Integer; xMaxClamp:Integer; yMinClamp:Integer; +yMaxClamp:Integer) ; Tool $03,$1C; +PROCEDURE ClearMouse ; Tool $03,$1B; +PROCEDURE ClrHeartBeat ; Tool $03,$14; +PROCEDURE DeleteID ( idTag:Integer) ; Tool $03,$21; +PROCEDURE DelHeartBeat ( taskPtr:Ptr) ; Tool $03,$13; +FUNCTION FWEntry ( aRegValue:Integer; xRegValue:Integer; yRegValue:Integer; +eModeEntryPt:Integer) : FWRec ; EXTERNAL ; +FUNCTION GetAbsClamp : ClampRec ; EXTERNAL ; +FUNCTION GetAddr ( refNum:Integer) : Ptr ; Tool $03,$16; +FUNCTION GetIRQEnable : Integer ; Tool $03,$29; +FUNCTION GetMouseClamp : ClampRec ; EXTERNAL ; +FUNCTION GetNewID ( idTag:Integer) : Integer ; Tool $03,$20; +FUNCTION GetTick : Longint ; Tool $03,$25; +FUNCTION GetVector ( vectorRefNum:Integer) : Ptr ; Tool $03,$11; +PROCEDURE HomeMouse ; Tool $03,$1A; +PROCEDURE InitMouse ( mouseSlot:Integer) ; Tool $03,$18; +PROCEDURE IntSource ( srcRefNum:Integer) ; Tool $03,$23; +FUNCTION Munger ( destPtr:Ptr; destLenPtr:IntPtr; targPtr:Ptr; targLen:Integer; +replPtr:Ptr; replLen:Integer; padPtr:Ptr) : Integer ; Tool $03,$28; +FUNCTION PackBytes (VAR srcBuffer:Ptr;VAR srcSize:Integer; dstBuffer:Ptr; +dstSize:Integer) : Integer ; Tool $03,$26; +PROCEDURE PosMouse ( xPos:Integer; yPos:Integer) ; Tool $03,$1E; +PROCEDURE ReadAsciiTime ( bufferPtr:Ptr) ; Tool $03,$0F; +FUNCTION ReadBParam ( paramRefNum:Integer) : Integer ; Tool $03,$0C; +PROCEDURE ReadBRam ( bufferPtr:Ptr) ; Tool $03,$0A; +FUNCTION ReadMouse : MouseRec ; EXTERNAL ; +FUNCTION ReadTimeHex : TimeRec ; EXTERNAL ; +FUNCTION ServeMouse : Integer ; Tool $03,$1F; +PROCEDURE SetAbsClamp ( xMinClamp:Integer; xMaxClamp:Integer; +yMinClamp:Integer; yMaxClamp:Integer) ; EXTERNAL ; +PROCEDURE SetHeartBeat ( taskPtr:Ptr) ; Tool $03,$12; +PROCEDURE SetMouse ( mouseMode:Integer) ; Tool $03,$19; +PROCEDURE SetVector ( vectorRefNum:Integer; vectorPtr:Ptr) ; Tool $03,$10; +PROCEDURE StatusID ( idTag:Integer) ; Tool $03,$22; +PROCEDURE SysBeep ; Tool $03,$2C; +PROCEDURE SysFailMgr ( errorCode:Integer; str:Str255) ; Tool $03,$15; +FUNCTION UnPackBytes ( srcBuffer:Ptr; srcSize:Integer;VAR dstBuffer:Ptr;VAR +dstSize:Integer) : Integer ; Tool $03,$27; +PROCEDURE WriteBParam ( theData:Integer; paramRefNum:Integer) ; Tool $03,$0B; +PROCEDURE WriteBRam ( bufferPtr:Ptr) ; Tool $03,$09; +PROCEDURE WriteTimeHex ( month:Byte; day:Byte; curYear:Byte; hour:Byte; +minute:Byte; second:Byte) ; EXTERNAL ; +PROCEDURE AddToQueue ( newEntryPtr:Ptr; headerPtr:Ptr) ; Tool $03,$2E; +PROCEDURE DeleteFromQueue ( entryPtr:Ptr; headerPtr:Ptr) ; Tool $03,$2F; +PROCEDURE SetInterruptState ( iStateRec:InterruptStateRec; +bytesDesired:Integer) ; Tool $03,$30; +PROCEDURE GetInterruptState (VAR iStateRec:InterruptStateRec; +bytesDesired:Integer) ; Tool $03,$31; +FUNCTION GetIntStateRecSize : Integer ; Tool $03,$32; +FUNCTION ReadMouse2 : MouseRec ; EXTERNAL ; +FUNCTION GetCodeResConverter : ProcPtr ; Tool $03,$34; +FUNCTION GetRomResource : Ptr ; Tool $03,$35; +IMPLEMENTATION +END. diff --git a/pascal/noteseq.p b/pascal/noteseq.p new file mode 100755 index 0000000..598c659 --- /dev/null +++ b/pascal/noteseq.p @@ -0,0 +1,95 @@ +{******************************************** +; File: NoteSeq.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT NOTESEQ; +INTERFACE +USES TYPES; +CONST + +pitchBend = $0; {Command - } +tempo = $00000001; {Command - } +turnNotesOff = $00000002; {Command - } +jump = $00000003; {Command - } +setVibratoDepth = $00000004; {Command - } +programChange = $00000005; {Command - } +setRegister = $00000006; {Command - } +ifGo = $00000007; {Command - } +incRegister = $00000008; {Command - } +decRegister = $00000009; {Command - } +midiNoteOff = $0000000A; {Command - } +midiNoteOn = $0000000B; {Command - } +midiPolyKey = $0000000C; {Command - } +midiCtlChange = $0000000D; {Command - } +midiProgChange = $0000000E; {Command - } +midiChnlPress = $0000000F; {Command - } +midiPitchBend = $00000010; {Command - } +midiSelChnlMode = $00000011; {Command - } +midiSysExclusive = $00000012; {Command - } +midiSysCommon = $00000013; {Command - } +midiSysRealTime = $00000014; {Command - } +midiSetSysExl = $00000015; {Command - } +commandMask = $0000007F; {Command - } +volumeMask = $0000007F; {Command - } +chord = $00000080; {Command - } +val1Mask = $00007F00; {Command - } +toneMask = $00007F00; {Command - } +noteMask = $00008000; {Command - } +lByte = $00FF0000; {Command - meaning depends on midi command } +durationMask = $07FF0000; {Command - } +trackMask = $78000000; {Command - } +delayMask = $80000000; {Command - } +hByte = $FF000000; {Command - } + +(* *** Toolset Errors *** +noRoomMidiErr = $1A00; {error - } +noCommandErr = $1A01; {error - can't understand the current SeqItem } +noRoomErr = $1A02; {error - sequence is more than twelve levels deep } +startedErr = $1A03; {error - Note Sequencer is already started } +noNoteErr = $1A04; {error - can't find the note to be turned off by the current +SeqItem } +noStartErr = $1A05; {error - Note Sequencer not started yet } +instBndsErr = $1A06; {error - Instrument number out of Instrument boundary +range } +nsWrongVer = $1A07; {error - incompatible versions of NoteSequencer and +NoteSynthesizer } + *** Toolset Errors *** *) + +TYPE +LocRecHndl = ^LocRecPtr; +LocRecPtr = ^LocRec; +LocRec = RECORD + curPhraseItem : Integer; + curPattItem : Integer; + curLevel : Integer; +END; +PROCEDURE SeqBootInit ; Tool $1A,$01; +PROCEDURE SeqStartUp ( dPageAddr:Integer; mode:Integer; updateRate:Integer; +increment:Integer) ; Tool $1A,$02; +PROCEDURE SeqShutDown ; Tool $1A,$03; +FUNCTION SeqVersion : Integer ; Tool $1A,$04; +PROCEDURE SeqReset ; Tool $1A,$05; +FUNCTION SeqStatus : Boolean ; Tool $1A,$06; +PROCEDURE SeqAllNotesOff ; Tool $1A,$0D; +FUNCTION ClearIncr : Integer ; Tool $1A,$0A; +FUNCTION GetLoc : LocRec ; EXTERNAL ; +FUNCTION GetTimer : Integer ; Tool $1A,$0B; +PROCEDURE SetIncr ( increment:Integer) ; Tool $1A,$09; +PROCEDURE SetInstTable ( instTable:Handle) ; Tool $1A,$12; +PROCEDURE SetTrkInfo ( priority:Integer; instIndex:Integer; trackNum:Integer) +; Tool $1A,$0E; +PROCEDURE StartInts ; Tool $1A,$13; +PROCEDURE StartSeq ( errHndlrRoutine:VoidProcPtr; compRoutine:VoidProcPtr; +sequence:Handle) ; Tool $1A,$0F; +PROCEDURE StepSeq ; Tool $1A,$10; +PROCEDURE StopInts ; Tool $1A,$14; +PROCEDURE StopSeq ( next:Integer) ; Tool $1A,$11; +PROCEDURE StartSeqRel ( errHandlerPtr:ProcPtr; compRoutine:ProcPtr; +sequence:Handle) ; Tool $1A,$15; +IMPLEMENTATION +END. diff --git a/pascal/notesyn.p b/pascal/notesyn.p new file mode 100755 index 0000000..2434c46 --- /dev/null +++ b/pascal/notesyn.p @@ -0,0 +1,87 @@ +{******************************************** +; File: NoteSyn.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT NOTESYN; +INTERFACE +USES TYPES; + +(* *** Toolset Errors *** +CONST +nsAlreadyInit = $1901; {error - Note Syn already initialized } +nsSndNotInit = $1902; {error - Sound Tools not initialized } +nsNotAvail = $1921; {error - generator not available } +nsBadGenNum = $1922; {error - bad generator number } +nsNotInit = $1923; {error - Note Syn not initialized } +nsGenAlreadyOn = $1924; {error - generator already on } +soundWrongVer = $1925; {error - incompatible versions of Sound and NoteSyn } + *** Toolset Errors *** *) + +TYPE +EnvelopeHndl = ^EnvelopePtr; +EnvelopePtr = ^Envelope; +Envelope = PACKED RECORD + st1BkPt : Byte; + st1Increment : Integer; + st2BkPt : Byte; + st2Increment : Integer; + st3BkPt : Byte; + st3Increment : Integer; + st4BkPt : Byte; + st4Increment : Integer; + st5BkPt : Byte; + st5Increment : Integer; + st6BkPt : Byte; + st6Increment : Integer; + st7BkPt : Byte; + st7Increment : Integer; + st8BkPt : Byte; + st8Increment : Integer; +END; +WaveFormHndl = ^WaveFormPtr; +WaveFormPtr = ^WaveForm; +WaveForm = PACKED RECORD + wfTopKey : Byte; + wfWaveAddress : Byte; + wfWaveSize : Byte; + wfDocMode : Byte; + wfRelPitch : Integer; +END; +InstrumentHndl = ^InstrumentPtr; +InstrumentPtr = ^Instrument; +Instrument = PACKED RECORD + theEnvelope : Envelope; + releaseSegment : Byte; + priorityIncrement : Byte; + pitchBendRange : Byte; + vibratoDepth : Byte; + vibratoSpeed : Byte; + inSpare : Byte; + aWaveCount : Byte; + bWaveCount : Byte; + aWaveList : ARRAY[1..1] OF WaveForm; + bWaveList : ARRAY[1..1] OF WaveForm; +END; +PROCEDURE NSBootInit ; Tool $19,$01; +PROCEDURE NSStartUp ( updateRate:Integer; userUpdateRtnPtr:Ptr) ; Tool +$19,$02; +PROCEDURE NSShutDown ; Tool $19,$03; +FUNCTION NSVersion : Integer ; Tool $19,$04; +PROCEDURE NSReset ; Tool $19,$05; +FUNCTION NSStatus : Boolean ; Tool $19,$06; +PROCEDURE AllNotesOff ; Tool $19,$0D; +FUNCTION AllocGen ( requestPriority:Integer) : Integer ; Tool $19,$09; +PROCEDURE DeallocGen ( genNumber:Integer) ; Tool $19,$0A; +PROCEDURE NoteOff ( genNumber:Integer; semitone:Integer) ; Tool $19,$0C; +PROCEDURE NoteOn ( genNumber:Integer; semitone:Integer; volume:Integer; +instrumentPtr:Ptr) ; Tool $19,$0B; +PROCEDURE NSSetUpdateRate ( updateRate:Integer) ; Tool $19,$0E; +FUNCTION NSSetUserUpdateRtn ( updateRtn:VoidProcPtr) : VoidProcPtr ; Tool +$19,$0F; +IMPLEMENTATION +END. diff --git a/pascal/print.p b/pascal/print.p new file mode 100755 index 0000000..12bdd47 --- /dev/null +++ b/pascal/print.p @@ -0,0 +1,165 @@ +{******************************************** +; File: Print.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT PRINT; +INTERFACE +USES TYPES,QUICKDRAW,EVENTS,CONTROLS,WINDOWS,LINEEDIT,DIALOGS; +CONST + +(* *** Toolset Errors *** +pntrConFailed = $1308; {error - connection to the printer failed } +memFullErr = $FF80; {errors - } +ioAbort = $FFE5; {errors - } +prAbort = $0080; {errors - } +missingDriver = $1301; {errors - specified driver not in system/drivers } +portNotOn = $1302; {errors - specified port not selected in ctl panel } +noPrintRecord = $1303; {errors - no print record was given } +badLaserPrep = $1304; {errors - laser prep in laser writer incompatible } +badLPFile = $1305; {errors - laser prep in system/drivers incompatible } +papConnNotOpen = $1306; {errors - cannot connect to laser writer } +papReadWriteErr = $1307; {errors - apple talk PAPRead or PAPWrite error } +ptrConnFailed = $1308; {errors - cannot establish connection with imagewriter } +badLoadParam = $1309; {errors - parameter for load/unload is invalid } +callNotSupported = $130A; {errors - toolcall made is not supported by this +version } +startUpAlreadyMade = $1321; {errors - low level startup already made } +invalidCtlVal = $1322; {errors - invalid control value had been spec'd } + *** Toolset Errors *** *) + +kReset = $0001; {LLDControl - Printer control value - reset printer } +kFormFeed = $0002; {LLDControl - Printer control value - form feed } +kLineFeed = $0003; {LLDControl - Printer control value - line feed } +bothDrivers = $0; {whichDriver - input to PMLoadDriver and PMUnloadDriver } +printerDriver = $0001; {whichDriver - input to PMLoadDriver and PMUnloadDriver +} +portDriver = $0002; {whichDriver - input to PMLoadDriver and PMUnloadDriver } +prPortrait = $0000; { - } +prLandscape = $0001; { - } +prImageWriter = $0001; { - } +prImageWriterLQ = $0002; { - } +prLaserWriter = $0003; { - } +prEpson = $0004; { - } +prBlackWhite = $0001; { - } +prColor = $0002; { - } +bDraftLoop = $0000; { - } +bSpoolLoop = $0080; { - } + +TYPE +PrPrinterSpecRec = RECORD + prPrinterType : Integer; + prCharacteristics : Integer; +END; +PrInfoRecHndl = ^PrInfoRecPtr; +PrInfoRecPtr = ^PrInfoRec; +PrInfoRec = RECORD + iDev : Integer; { reserved for internal use } + iVRes : Integer; { vertical resolution of printer } + iHRes : Integer; { horizontal resolution of printer } + rPage : Rect; { defining page rectangle } +END; +PrJobRecPtr = ^PrJobRec; +PrJobRec = PACKED RECORD + iFstPage : Integer; { first page to print } + iLstPage : Integer; { last page to print } + iCopies : Integer; { number of copies } + bJDocLoop : Byte; { printing method } + fFromUser : Byte; { used internally } + pIdleProc : WordProcPtr; { background procedure } + pFileName : Ptr; { spool file name } + iFileVol : Integer; { spool file volume reference number } + bFileVers : Byte; { spool file version number } + bJobX : Byte; { used internally } +END; +PrStyleRecHndl = ^PrStyleRecPtr; +PrStyleRecPtr = ^PrStyleRec; +PrStyleRec = RECORD + wDev : Integer; { output quality information } + internA : ARRAY[1..3] OF Integer; { for internal use } + feed : Integer; { paper feed type } + paperType : Integer; { paper type } + crWidth : Integer; { carriage Width for image writer or vertical sizing for +lazer writer } + reduction : Integer; { % reduction, laser writer only } + internB : Integer; { for internal use } +END; +PrRecHndl = ^PrRecPtr; +PrRecPtr = ^PrRec; +PrRec = RECORD + prVersion : Integer; { print manager version } + prInfo : PrInfoRec; { printer infomation subrecord } + rPaper : Rect; { Defining paper rectangle } + prStl : PrStyleRec; { style subrecord } + prInfoPT : PACKED ARRAY[1..14] OF Byte; { reserved for internal use } + prXInfo : PACKED ARRAY[1..24] OF Byte; { reserved for internal use } + prJob : PrJobRec; { job subrecord } + printX : PACKED ARRAY[1..38] OF Byte; { reserved for future use } + iReserved : Integer; { reserved for internal use } +END; +PrStatusRecHndl = ^PrStatusRecPtr; +PrStatusRecPtr = ^PrStatusRec; +PrStatusRec = RECORD + iTotPages : Integer; { number of pages in spool file } + iCurPage : Integer; { page being printed } + iTotCopies : Integer; { number of copies requested } + iCurCopy : Integer; { copy being printed } + iTotBands : Integer; { reserved for internal use } + iCurBand : Integer; { reserved for internal use } + fPgDirty : Integer; { TRUE if started printing page } + fImaging : Integer; { reserved for internal use } + hPrint : PrRecHndl; { handle of print record } + pPrPort : GrafPortPtr; { pointer to grafport being use for printing } + hPic : Longint; { reserved for internal use } +END; +PROCEDURE PMBootInit ; Tool $13,$01; +PROCEDURE PMStartUp ( userID:Integer; dPageAddr:Integer) ; Tool $13,$02; +PROCEDURE PMShutDown ; Tool $13,$03; +FUNCTION PMVersion : Integer ; Tool $13,$04; +PROCEDURE PMReset ; Tool $13,$05; +FUNCTION PMStatus : Boolean ; Tool $13,$06; +PROCEDURE LLDBitMap ( bitMapPtr:Ptr; rectPtr:Rect; userID:Integer) ; Tool +$13,$1C; +PROCEDURE LLDControl ( printerControlValue:Integer) ; Tool $13,$1B; +PROCEDURE LLDShutDown ( userID:Integer) ; Tool $13,$1A; +PROCEDURE LLDStartUp ( dPageAddr:Integer; userID:Integer) ; Tool $13,$19; +PROCEDURE LLDText ( textPtr:Ptr; textLength:Integer; userID:Integer) ; Tool +$13,$1D; +PROCEDURE PMLoadDriver ( whichDriver:Integer) ; Tool $13,$35; +PROCEDURE PMUnloadDriver ( whichDriver:Integer) ; Tool $13,$34; +FUNCTION PrChoosePrinter : Boolean ; Tool $13,$16; +FUNCTION PrChooser : Boolean ; Tool $13,$16; +PROCEDURE PrCloseDoc ( printGrafPortPtr:GrafPortPtr) ; Tool $13,$0F; +PROCEDURE PrClosePage ( printGrafPortPtr:GrafPortPtr) ; Tool $13,$11; +PROCEDURE PrDefault ( printRecordHandle:PrRecHndl) ; Tool $13,$09; +FUNCTION PrDriverVer : Integer ; Tool $13,$23; +FUNCTION PrError : Integer ; Tool $13,$14; +FUNCTION PrJobDialog ( printRecordHandle:PrRecHndl) : Boolean ; Tool $13,$0C; +FUNCTION PrOpenDoc ( printRecordHandle:PrRecHndl; printGrafPortPtr:GrafPortPtr) +: GrafPortPtr ; Tool $13,$0E; +PROCEDURE PrOpenPage ( printGrafPortPtr:GrafPortPtr; pageFramePtr:RectPtr) ; +Tool $13,$10; +PROCEDURE PrPicFile ( printRecordHandle:PrRecHndl; +printGrafPortPtr:GrafPortPtr; statusRecPtr:PrStatusRecPtr) ; Tool $13,$12; +PROCEDURE PrPixelMap ( srcLocPtr:LocInfoPtr; srcRectPtr:Rect; +colorFlag:Integer) ; Tool $13,$0D; +FUNCTION PrPortVer : Integer ; Tool $13,$24; +PROCEDURE PrSetError ( errorNumber:Integer) ; Tool $13,$15; +FUNCTION PrStlDialog ( printRecordHandle:PrRecHndl) : Boolean ; Tool $13,$0B; +FUNCTION PrValidate ( printRecordHandle:PrRecHndl) : Boolean ; Tool $13,$0A; +PROCEDURE PrSetDocName ( DocNamePtr:StringPtr) ; Tool $13,$37; +FUNCTION PrGetDocName : StringPtr ; Tool $13,$36; +FUNCTION PrGetPgOrientation ( prRecordHandle:PrRecHndl) : Integer ; Tool +$13,$38; +FUNCTION PrGetPrinterSpecs : PrPrinterSpecRec ; Tool $13,$18; +PROCEDURE PrGetZoneName (VAR ZoneNamePtr:Str255) ; Tool $13,$25; +PROCEDURE PrGetPrinterDvrName (VAR DvrNamePtr:Str255) ; Tool $13,$28; +PROCEDURE PrGetPortDvrName (VAR DvrNamePtr:Str255) ; Tool $13,$29; +PROCEDURE PrGetUserName (VAR UserNamePtr:Str255) ; Tool $13,$2A; +PROCEDURE PrGetNetworkName (VAR NetworkNamePtr:Str255) ; Tool $13,$2B; +IMPLEMENTATION +END. diff --git a/pascal/prodos16.p b/pascal/prodos16.p new file mode 100644 index 0000000..0518cff --- /dev/null +++ b/pascal/prodos16.p @@ -0,0 +1,211 @@ +FileAccess: mask Word { + 7: destroyEnable + 6: renameEnable + 5: backupNeeded + 1: writeEnable + 0: readEnable +} + +FileDate: mask Word { + 15-9: year + 8-5: month + 4-0: day +} + +FileTime: mask Word { + 12-8: hour + 5-0: minute +} + +StorageType: enum Word { + inactive: $0 + seedling: $1 + sapling: $2 + tree: $3 + pascal: $4 + directory: $d +} + +CREATE_PB: record { + pathname: ^String // 00 + access: FileAccess // 04 + file_type: Word // 06 + aux_type: Long // 08 + storage_type: StorageType // 0c + create_date: FileDate // 0e + create_time: FileTime // 10 +} + +DESTROY_PB: record { + pathname: ^String // 00 +} + +CHANGE_PATH_PB: record { + pathname: ^String // 00 + new_pathname: ^String // 04 +} + +SET_FILE_INFO_PB: record { + pathname: ^String // 00 + access: FileAccess // 04 + file_type: Word // 06 + aux_type: Long // 08 + unused: Word // 0c + create_date: FileDate // 0e + create_time: FileTime // 10 + mod_date: FileDate // 12 + mod_time: FileTime // 14 +} + +GET_FILE_INFO_PB: record { + pathname: ^String // 00 + access: FileAccess // 04 + file_type: Word // 06 + aux_type: Long // 08 + storage_type: StorageType // 0c + create_date: FileDate // 0e + create_time: FileTime // 10 + mod_date: FileDate // 12 + mod_time: FileTime // 14 + blocks_used: Long // 16 +} + +VOLUME_PB: record { + dev_name: ^String // 00 + vol_name: ^String // 04 + total_blocks: Long // 08 + free_blocks: Long // 0c + file_sys_id: Word // 10 +} + +SET_PREFIX_PB: record { + prefix_num: Word // 00 + prefix: ^String // 02 +} + +GET_PREFIX_PB: record { + prefix_num: Word // 00 + prefix: ^String // 02 +} + +CLEAR_BACKUP_BIT_PB: record { + pathname: ^String // 00 +} + +OPEN_PB: record { + ref_num: Word // 00 + pathname: ^String // 02 + io_buffer: Ptr // 06 +} + +NEWLINE_PB: record { + ref_num: Word // 00 + enable_Mask: Word // 02 + newline_char: Word // 04 +} + +READ_PB: record { + ref_num: Word // 00 + data_buffer: Ptr // 02 + request_count: Long // 06 + transfer_count: Long // 0a +} + +WRITE_PB: record { + ref_num: Word // 00 + data_buffer: Ptr // 02 + request_count: Long // 06 + transfer_count: Long // 0a +} + +CLOSE_PB: record { + ref_num: Word // 00 +} + +FLUSH_PB: record { + ref_num: Word // 00 +} + +SET_MARK_PB: record { + ref_num: Word // 00 + position: Long // 02 +} + +GET_MARK_PB: record { + ref_num: Word // 00 + position: Long // 02 +} + +SET_EOF_PB: record { + ref_num: Word // 00 + eof: Long // 02 +} + +GET_EOF_PB: record { + ref_num: Word // 00 + eof: Long // 02 +} + +SET_LEVEL_PB: record { + level: Word // 00 +} + +GET_LEVEL_PB: record { + level: Word // 00 +} + +GET_DEV_NUM_PB: record { + dev_name: ^String // 00 + dev_num: Word // 04 +} + +GET_LAST_DEV_PB: record { + dev_num: Word // 00 +} + +READ_BLOCK_PB: record { + dev_num: Word // 00 + data_buffer: Ptr // 02 + block_num: Long // 06 +} + +WRITE_BLOCK_PB: record { + dev_num: Word // 00 + data_buffer: Ptr // 02 + block_num: Long // 06 +} + +FORMAT_PB: record { + dev_name: ^String // 00 + vol_name: ^String // 04 + file_sys_id: Word // 08 +} + +GET_NAME_PB: record { + data_buffer: ^String // 00 +} + +GET_BOOT_VOL_PB: record { + data_buffer: ^String // 00 +} + +QUIT_PB: record { + pathname: ^String // 00 + flags: mask Word { // 04 + 15: returnUserID + 14: restartable + } +} + +GET_VERSION_PB: record { + version: Word // 00 +} + +ALLOC_INTERRUPT_PB: record { + int_num: Word // 00 + int_code: Ptr // 02 +} + +DEALLOC_INTERRUPT_PB: record { + int_num: Word // 00 +} diff --git a/pascal/qdaux.p b/pascal/qdaux.p new file mode 100755 index 0000000..664b463 --- /dev/null +++ b/pascal/qdaux.p @@ -0,0 +1,119 @@ +{******************************************** +; File: QDAux.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT QDAUX; +INTERFACE +USES TYPES,QUICKDRAW; +CONST + +(* *** Private Constants *** +frameVerb = $00; {PicInfo - PRIVATE - for reference only } +picNop = $00; {PicInfo - PRIVATE - for reference only } +drawCharVerb = $00; {PicInfo - PRIVATE - for reference only } +paintVerb = $01; {PicInfo - PRIVATE - for reference only } +picClipRgn = $01; {PicInfo - PRIVATE - for reference only } +drawTextVerb = $01; {PicInfo - PRIVATE - for reference only } +eraseVerb = $02; {PicInfo - PRIVATE - for reference only } +picBkPat = $02; {PicInfo - PRIVATE - for reference only } +drawCStrVerb = $02; {PicInfo - PRIVATE - for reference only } +invertVerb = $03; {PicInfo - PRIVATE - for reference only } +picTxFont = $03; {PicInfo - PRIVATE - for reference only } +fillVerb = $04; {PicInfo - PRIVATE - for reference only } +picTxFace = $04; {PicInfo - PRIVATE - for reference only } +picTxMode = $05; {PicInfo - PRIVATE - for reference only } +picSpExtra = $06; {PicInfo - PRIVATE - for reference only } +picPnSize = $07; {PicInfo - PRIVATE - for reference only } +picPnMode = $08; {PicInfo - PRIVATE - for reference only } +picPnPat = $09; {PicInfo - PRIVATE - for reference only } +picThePat = $0A; {PicInfo - PRIVATE - for reference only } +picOvSize = $0B; {PicInfo - PRIVATE - for reference only } +picOrigin = $0C; {PicInfo - PRIVATE - for reference only } +picTxSize = $0D; {PicInfo - PRIVATE - for reference only } +picFGColor = $0E; {PicInfo - PRIVATE - for reference only } +picBGColor = $0F; {PicInfo - PRIVATE - for reference only } +picTxRatio = $10; {PicInfo - PRIVATE - for reference only } +picVersion = $11; {PicInfo - PRIVATE - for reference only } +lineNoun = $20; {PicInfo - PRIVATE - for reference only } +picLine = $20; {PicInfo - PRIVATE - for reference only } +picLineFrom = $21; {PicInfo - PRIVATE - for reference only } +picShortL = $22; {PicInfo - PRIVATE - for reference only } +picShortLFrom = $23; {PicInfo - PRIVATE - for reference only } +picLongText = $28; {PicInfo - PRIVATE - for reference only } +picDHText = $29; {PicInfo - PRIVATE - for reference only } +picDVText = $2A; {PicInfo - PRIVATE - for reference only } +picDVDHText = $2B; {PicInfo - PRIVATE - for reference only } +rectNoun = $30; {PicInfo - PRIVATE - for reference only } +rRectNoun = $40; {PicInfo - PRIVATE - for reference only } +ovalNoun = $50; {PicInfo - PRIVATE - for reference only } +arcNoun = $60; {PicInfo - PRIVATE - for reference only } +polyNoun = $70; {PicInfo - PRIVATE - for reference only } +rgnNoun = $80; {PicInfo - PRIVATE - for reference only } +mapNoun = $90; {PicInfo - PRIVATE - for reference only } +picBitsRect = $90; {PicInfo - PRIVATE - for reference only } +picBitsRgn = $91; {PicInfo - PRIVATE - for reference only } +picPBitsRect = $98; {PicInfo - PRIVATE - for reference only } +picPBitsRgn = $99; {PicInfo - PRIVATE - for reference only } +picShortComment = $A0; {PicInfo - PRIVATE - for reference only } +picLongComment = $A1; {PicInfo - PRIVATE - for reference only } +picEnd = $FF; {PicInfo - PRIVATE - for reference only } + *** Private Constants *** *) + +resMode640PMask = $00; {SeedFill/CalcMask - } +resMode640DMask = $01; {SeedFill/CalcMask - } +resMode320Mask = $02; {SeedFill/CalcMask - } +destModeCopyMask = $0000; {SeedFill/CalcMask - } +destModeLeaveMask = $1000; {SeedFill/CalcMask - } +destModeOnesMask = $2000; {SeedFill/CalcMask - } +destModeZerosMask = $3000; {SeedFill/CalcMask - } +destModeError = $1212; {Error - } + +TYPE +QDIconRecordHndl = ^QDIconRecordPtr; +QDIconRecordPtr = ^QDIconRecord; +QDIconRecord = RECORD + iconType : Integer; + iconSize : Integer; + iconHeight : Integer; + iconWidth : Integer; + iconImage : PACKED ARRAY[1..1] OF Byte; + iconMask : PACKED ARRAY[1..1] OF Byte; +END; +PicHndl = ^PicPtr; +PicPtr = ^Picture; +Picture = RECORD + picSCB : Integer; + picFrame : Rect; { Followed by picture opcodes } +END; +PROCEDURE QDAuxBootInit ; Tool $12,$01; +PROCEDURE QDAuxStartUp ; Tool $12,$02; +PROCEDURE QDAuxShutDown ; Tool $12,$03; +FUNCTION QDAuxVersion : Integer ; Tool $12,$04; +PROCEDURE QDAuxReset ; Tool $12,$05; +FUNCTION QDAuxStatus : Boolean ; Tool $12,$06; +PROCEDURE CopyPixels ( srcLocPtr:LocInfo; destLocPtr:LocInfo; srcRect:Rect; +destRect:Rect; xferMode:Integer; makeRgn:RgnHandle) ; Tool $12,$09; +PROCEDURE DrawIcon ( iconPtr:QDIconRecord; displayMode:Integer; xPos:Integer; +yPos:Integer) ; Tool $12,$0B; +PROCEDURE SpecialRect ( rectPtr:Rect; frameColor:Integer; fillColor:Integer) ; +Tool $12,$0C; +PROCEDURE WaitCursor ; Tool $12,$0A; +PROCEDURE SeedFill ( srcLocInfoPtr:LocInfo; srcRect:Rect; +dstLocInfoPtr:LocInfo; dstRect:Rect; seedH:Integer; seedV:Integer; +resMode:Integer; U__patternPtr:PatternPtr; leakTblPtr:Ptr) ; Tool $12,$0D; +PROCEDURE CalcMask ( srcLocInfoPtr:LocInfo; srcRect:Rect; +dstLocInfoPtr:LocInfo; dstRect:Rect; resMode:Integer; U__patternPtr:PatternPtr; +leakTblPtr:Ptr) ; Tool $12,$0E; +PROCEDURE PicComment ( kind:Integer; dataSize:Integer; dataHandle:Handle) ; +Tool $04,$B8; +PROCEDURE ClosePicture ; Tool $04,$B9; +PROCEDURE DrawPicture ( picHandle:PicHndl; destRect:Rect) ; Tool $04,$BA; +PROCEDURE KillPicture ( pichandle:PicHndl) ; Tool $04,$BB; +FUNCTION OpenPicture ( picFrame:Rect) : PicHndl ; Tool $04,$B7; +IMPLEMENTATION +END. diff --git a/pascal/quickdraw.p b/pascal/quickdraw.p new file mode 100755 index 0000000..3395246 --- /dev/null +++ b/pascal/quickdraw.p @@ -0,0 +1,510 @@ +{******************************************** +; File: Quickdraw.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT QUICKDRAW; +INTERFACE +USES TYPES; +CONST + +(* *** Toolset Errors *** +alreadyInitialized = $0401; {error - Quickdraw already initialized } +cannotReset = $0402; {error - never used } +notInitialized = $0403; {error - Quickdraw not initialized } +screenReserved = $0410; {error - screen reserved } +badRect = $0411; {error - bad rectangle } +notEqualChunkiness = $0420; {error - Chunkiness is not equal } +rgnAlreadyOpen = $0430; {error - region is already open } +rgnNotOpen = $0431; {error - region is not open } +rgnScanOverflow = $0432; {error - region scan overflow } +rgnFull = $0433; {error - region is full } +polyAlreadyOpen = $0440; {error - poly is already open } +polyNotOpen = $0441; {error - poly is not open } +polyTooBig = $0442; {error - poly is too big } +badTableNum = $0450; {error - bad table number } +badColorNum = $0451; {error - bad color number } +badScanLine = $0452; {error - bad scan line } +notImplemented = $04FF; {error - not implemented } + *** Toolset Errors *** *) + +tsNumber = $04; { - } +U_colorTable = $0F; {AnSCBByte - Mask for SCB color table } +scbReserved = $10; {AnSCBByte - Mask for SCB reserved bit } +scbFill = $20; {AnSCBByte - Mask for SCB fill bit } +scbInterrupt = $40; {AnSCBByte - Mask for SCB interrupt bit } +scbColorMode = $80; {AnSCBByte - Mask for SCB color mode bit } +table320 = $32; {ColorData - (val=size) } +table640 = $32; {ColorData - (val=size) } +blueMask = $000F; {ColorValue - Mask for Blue nibble } +greenMask = $00F0; {ColorValue - Mask for green nibble } +redMask = $0F00; {ColorValue - Mask for red nibble } +widMaxSize = $0001; {FontFlags - } +zeroSize = $0002; {FontFlags - } +maskSize = $08; {GrafPort - Mask Size (val=size) } +locSize = $10; {GrafPort - Loc Size (val=size) } +patsize = $20; {GrafPort - Pattern Size (val=size) } +pnStateSize = $32; {GrafPort - Pen State Size (Val=size) } +portSize = $AA; {GrafPort - Size of GrafPort } +black = $000; {MasterColors - These work in 320 and 640 mode } +blue = $00F; {MasterColors - These work in 320 and 640 mode } +darkGreen320 = $080; {MasterColors - These work in 320 mode } +green320 = $0E0; {MasterColors - These work in 320 mode } +green640 = $0F0; {MasterColors - These work in 640 mode } +lightBlue320 = $4DF; {MasterColors - These work in 320 mode } +purple320 = $72C; {MasterColors - These work in 320 mode } +darkGray320 = $777; {MasterColors - These work in 320 mode } +periwinkleBlue320 = $78F; {MasterColors - These work in 320 mode } +brown320 = $841; {MasterColors - These work in 320 mode } +lightGray320 = $0CCC; {MasterColors - These work in 320 mode } +red320 = $0D00; {MasterColors - These work in 320 mode } +lilac320 = $0DAF; {MasterColors - These work in 320 mode } +red640 = $0F00; {MasterColors - These work in 640 mode } +orange320 = $0F70; {MasterColors - These work in 320 mode } +flesh320 = $0FA9; {MasterColors - These work in 320 mode } +yellow = $0FF0; {MasterColors - These work in 320 and 640 mode } +white = $0FFF; {MasterColors - These work in 320 and 640 mode } +modeCopy = $0000; {PenModeDATA - } +modeOR = $0001; {PenModeDATA - } +modeXOR = $0002; {PenModeDATA - } +modeBIC = $0003; {PenModeDATA - } +modeForeCopy = $0004; {PenModeDATA - } +modeForeOR = $0005; {PenModeDATA - } +modeForeXOR = $0006; {PenModeDATA - } +modeForeBIC = $0007; {PenModeDATA - } +modeNOT = $8000; {PenModeDATA - } +notCopy = $8000; {PenModeDATA - } +notOR = $8001; {PenModeDATA - } +notXOR = $8002; {PenModeDATA - } +notBIC = $8003; {PenModeDATA - } +notForeCOPY = $8004; {PenModeDATA - } +notForeOR = $8005; {PenModeDATA - } +notForeXOR = $8006; {PenModeDATA - } +notForeBIC = $8007; {PenModeDATA - } +mode320 = $0000; {QDStartup - Argument to QDStartup } +mode640 = $0080; {QDStartup - Argument to QDStartup } +plainMask = $0000; {TextStyle - Mask for plain text bit } +boldMask = $0001; {TextStyle - Mask for bold bit } +italicMask = $0002; {TextStyle - Mask for italic bit } +underlineMask = $0004; {TextStyle - Mask for underline bit } +outlineMask = $0008; {TextStyle - Mask for outline bit } +shadowMask = $0010; {TextStyle - Mask for shadow bit } + +TYPE +TextStyle = Integer ; +ColorValue = Integer ; +AnSCBByte = Byte ; +PatternPtr = ^Pattern; +Pattern = PACKED ARRAY[1..32] of Byte ; +Mask = PACKED ARRAY[1..8] OF Byte; +CursorHndl = ^CursorPtr; +CursorPtr = ^Cursor; +Cursor = RECORD + cursorHeight : Integer; { size in bytes } + cursorWidth : Integer; { enclosing rectangle } + cursorData : ARRAY[1..1,1..1] OF Integer; + cursorMask : ARRAY[1..1,1..1] OF Integer; + cursorHotSpot : Point; +END; +RgnHandle = ^RgnPtr; +RgnPtr = ^Region; +Region = RECORD + rgnSize : Integer; { size in bytes } + rgnBBox : Rect; { enclosing rectangle } +END; +BufDimRecHndl = ^BufDimRecPtr; +BufDimRecPtr = ^BufDimRec; +BufDimRec = RECORD + maxWidth : Integer; + textBufHeight : Integer; + textBufferWords : Integer; + fontWidth : Integer; +END; +FontHndl = ^FontPtr; +FontPtr = ^Font; +Font = RECORD + offseToMF : Integer; { fully defined front of the Font record. } + family : Integer; + style : TextStyle; + size : Integer; + version : Integer; + fbrExtent : Integer; +END; +FontGlobalsRecHndl = ^FontGlobalsRecPtr; +FontGlobalsRecPtr = ^FontGlobalsRecord; +FontGlobalsRecord = RECORD + fgFontID : Integer; { currently 12 bytes long, but may be expanded } + fgStyle : TextStyle; + fgSize : Integer; + fgVersion : Integer; + fgWidMax : Integer; + fgFBRExtent : Integer; +END; +FontIDHndl = ^FontIDPtr; +FontIDPtr = ^FontID; +FontID = PACKED RECORD + famNum : Integer; + fontStyle : Byte; + fontSize : Byte; +END; +FontInfoRecHndl = ^FontInfoRecPtr; +FontInfoRecPtr = ^FontInfoRecord; +FontInfoRecord = RECORD + ascent : Integer; + descent : Integer; + widMax : Integer; + leading : Integer; +END; +LocInfoHndl = ^LocInfoPtr; +LocInfoPtr = ^LocInfo; +LocInfo = RECORD + portSCB : Integer; { SCBByte in low byte } + ptrToPixImage : Ptr; { ImageRef } + width : Integer; { Width } + boundsRect : Rect; { BoundsRect } +END; +QDProcsHndl = ^QDProcsPtr; +QDProcsPtr = ^QDProcs; +QDProcs = RECORD + stdText : VoidProcPtr; + stdLine : VoidProcPtr; + stdRect : VoidProcPtr; + stdRRect : VoidProcPtr; + stdOval : VoidProcPtr; + stdArc : VoidProcPtr; + stdPoly : VoidProcPtr; + stdRgn : VoidProcPtr; + stdPixels : VoidProcPtr; + stdComment : VoidProcPtr; + stdTxMeas : VoidProcPtr; + stdTxBnds : VoidProcPtr; + stdGetPic : VoidProcPtr; + stdPutPic : VoidProcPtr; +END; +GrafPortHndl = ^GrafPortPtr; +GrafPortPtr = ^GrafPort; +GrafPort = RECORD + portInfo : LocInfo; + portRect : Rect; { PortRect } + clipRgn : RgnHandle; { Clip Rgn. Pointer } + visRgn : RgnHandle; { Vis. Rgn. Pointer } + bkPat : Pattern; { BackGround Pattern } + pnLoc : Point; { Pen Location } + pnSize : Point; { Pen Size } + pnMode : Integer; { Pen Mode } + pnPat : Pattern; { Pen Pattern } + pnMask : Mask; { Pen Mask } + pnVis : Integer; { Pen Visable } + fontHandle : FontHndl; + gfontID : FontID; { Font ID } + fontFlags : Integer; { FontFlags } + txSize : Integer; { Text Size } + txFace : TextStyle; { Text Face } + txMode : Integer; { Text Mode } + spExtra : Fixed; { Fixed Point Value } + chExtra : Fixed; { Fixed Point Value } + fgColor : Integer; { ForeGround Color } + bgColor : Integer; { BackGround Color } + picSave : Handle; { PicSave } + rgnSave : Handle; { RgnSave } + polySave : Handle; { PolySave } + grafProcs : QDProcsPtr; + arcRot : Integer; { ArcRot } + userField : Longint; { UserField } + sysField : Longint; { SysField } +END; +PaintParamHndl = ^PaintParamPtr; +PaintParamPtr = ^PaintParam; +PaintParam = RECORD + ptrToSourceLocInfo : LocInfoPtr; + ptrToDestLocInfo : LocInfoPtr; + ptrToSourceRect : RectPtr; + ptrToDestPoint : PointPtr; + mode : Integer; + maskHandle : Handle; { clip region } +END; +PenStateHndl = ^PenStatePtr; +PenStatePtr = ^PenState; +PenState = RECORD + psPnSize : Point; + psPnMode : Integer; + psPnPat : Pattern; + psPnMask : Mask; +END; +RomFontRecHndl = ^RomFontRecPtr; +RomFontRecPtr = ^RomFontRec; +RomFontRec = RECORD + rfFamNum : Integer; + rfFamStyle : Integer; + rfSize : Integer; + rfFontHandle : FontHndl; + rfNamePtr : Ptr; + rfFBRExtent : Integer; +END; +ColorTableHndl = ^ColorTablePtr; +ColorTablePtr = ^ColorTable; +ColorTable = RECORD + entries : ARRAY[1..16] OF Integer; +END; +PROCEDURE QDBootInit ; Tool $04,$01; +PROCEDURE QDStartUp ( dPageAddr:Integer; masterSCB:Integer; maxWidth:Integer; +userID:Integer) ; Tool $04,$02; +PROCEDURE QDShutDown ; Tool $04,$03; +FUNCTION QDVersion : Integer ; Tool $04,$04; +PROCEDURE QDReset ; Tool $04,$05; +FUNCTION QDStatus : Boolean ; Tool $04,$06; +PROCEDURE AddPt (VAR srcPtPtr:Point;VAR destPtPtr:Point) ; Tool $04,$80; +PROCEDURE CharBounds ( theChar:CHAR;VAR resultPtr:Rect) ; Tool $04,$AC; +FUNCTION CharWidth ( theChar:CHAR) : Integer ; Tool $04,$A8; +PROCEDURE ClearScreen ( colorWord:Integer) ; Tool $04,$15; +PROCEDURE ClipRect ( rectPtr:Rect) ; Tool $04,$26; +PROCEDURE ClosePoly ; Tool $04,$C2; +PROCEDURE ClosePort ( portPtr:GrafPortPtr) ; Tool $04,$1A; +PROCEDURE CloseRgn ( aRgnHandle:RgnHandle) ; Tool $04,$6E; +PROCEDURE CopyRgn ( srcRgnHandle:RgnHandle; destRgnHandle:RgnHandle) ; Tool +$04,$69; +PROCEDURE CStringBounds ( cStringPtr:Ptr;VAR resultRect:Rect) ; Tool $04,$AE; +FUNCTION CStringWidth ( cStringPtr:Ptr) : Integer ; Tool $04,$AA; +PROCEDURE DiffRgn ( rgn1Handle:RgnHandle; rgn2Handle:RgnHandle; +diffRgnHandle:RgnHandle) ; Tool $04,$73; +PROCEDURE DisposeRgn ( aRgnHandle:RgnHandle) ; Tool $04,$68; +PROCEDURE DrawChar ( theChar:CHAR) ; Tool $04,$A4; +PROCEDURE DrawCString ( cStrPtr:CStringPtr) ; Tool $04,$A6; +PROCEDURE DrawString ( str:Str255) ; Tool $04,$A5; +PROCEDURE DrawText ( textPtr:Ptr; textLength:Integer) ; Tool $04,$A7; +FUNCTION NotEmptyRect ( rectPtr:Rect) : Boolean ; Tool $04,$52; +FUNCTION EmptyRgn ( aRgnHandle:RgnHandle) : Boolean ; Tool $04,$78; +FUNCTION EqualPt (VAR point1Ptr:Point;VAR point2Ptr:Point) : Boolean ; Tool +$04,$83; +FUNCTION EqualRect ( rect1Ptr:Rect; rect2Ptr:Rect) : Boolean ; Tool $04,$51; +FUNCTION EqualRgn ( rgn1Handle:RgnHandle; rgn2Handle:RgnHandle) : Boolean ; +Tool $04,$77; +PROCEDURE EraseArc ( rectPtr:Rect; startAngle:Integer; arcAngle:Integer) ; +Tool $04,$64; +PROCEDURE EraseOval ( rectPtr:Rect) ; Tool $04,$5A; +PROCEDURE ErasePoly ( polyHandle:Handle) ; Tool $04,$BE; +PROCEDURE EraseRect ( rectPtr:Rect) ; Tool $04,$55; +PROCEDURE EraseRgn ( aRgnHandle:RgnHandle) ; Tool $04,$7B; +PROCEDURE EraseRRect ( rectPtr:Rect; ovalWidth:Integer; ovalHeight:Integer) ; +Tool $04,$5F; +PROCEDURE FillArc ( rectPtr:Rect; startAngle:Integer; arcAngle:Integer; +patternPtr:Pattern) ; Tool $04,$66; +PROCEDURE FillOval ( rectPtr:Rect; patternPtr:Pattern) ; Tool $04,$5C; +PROCEDURE FillPoly ( polyHandle:Handle; patternPtr:Pattern) ; Tool $04,$C0; +PROCEDURE FillRect ( rectPtr:Rect; patternPtr:Pattern) ; Tool $04,$57; +PROCEDURE FillRgn ( aRgnHandle:RgnHandle; patternPtr:Pattern) ; Tool $04,$7D; +PROCEDURE FillRRect ( rectPtr:Rect; ovalWidth:Integer; ovalHeight:Integer; +patternPtr:Pattern) ; Tool $04,$61; +PROCEDURE ForceBufDims ( maxWidth:Integer; maxFontHeight:Integer; +maxFBRExtent:Integer) ; Tool $04,$CC; +PROCEDURE FrameArc ( rectPtr:Rect; startAngle:Integer; arcAngle:Integer) ; +Tool $04,$62; +PROCEDURE FrameOval ( rectPtr:Rect) ; Tool $04,$58; +PROCEDURE FramePoly ( polyHandle:Handle) ; Tool $04,$BC; +PROCEDURE FrameRect ( rectPtr:Rect) ; Tool $04,$53; +PROCEDURE FrameRgn ( aRgnHandle:RgnHandle) ; Tool $04,$79; +PROCEDURE FrameRRect ( rectPtr:Rect; ovalWidth:Integer; ovalHeight:Integer) ; +Tool $04,$5D; +FUNCTION GetAddress ( tableID:Integer) : Ptr ; Tool $04,$09; +FUNCTION GetArcRot : Integer ; Tool $04,$B1; +FUNCTION GetBackColor : Integer ; Tool $04,$A3; +PROCEDURE GetBackPat (VAR patternPtr:Pattern) ; Tool $04,$35; +FUNCTION GetCharExtra : Fixed ; Tool $04,$D5; +PROCEDURE GetClip ( aRgnHandle:RgnHandle) ; Tool $04,$25; +FUNCTION GetClipHandle : RgnHandle ; Tool $04,$C7; +FUNCTION GetColorEntry ( tableNumber:Integer; entryNumber:Integer) : Integer ; +Tool $04,$11; +PROCEDURE GetColorTable ( tableNumber:Integer;VAR destTablePtr:ColorTable) ; +Tool $04,$0F; +FUNCTION GetCursorAdr : CursorPtr ; Tool $04,$8F; +FUNCTION GetFGSize : Integer ; Tool $04,$CF; +FUNCTION GetFont : FontHndl ; Tool $04,$95; +FUNCTION GetFontFlags : Integer ; Tool $04,$99; +PROCEDURE GetFontGlobals (VAR fgRecPtr:FontGlobalsRecord) ; Tool $04,$97; +FUNCTION GetFontID : FontID ; Tool $04,$D1; +PROCEDURE GetFontInfo (VAR fontInfoRecPtr:FontInfoRecord) ; Tool $04,$96; +FUNCTION GetFontLore (VAR recordPtr:FontGlobalsRecord; recordSize:Integer) : +Integer ; Tool $04,$D9; +FUNCTION GetForeColor : Integer ; Tool $04,$A1; +FUNCTION GetGrafProcs : QDProcsPtr ; Tool $04,$45; +FUNCTION GetMasterSCB : Integer ; Tool $04,$17; +PROCEDURE GetPen (VAR pointPtr:Point) ; Tool $04,$29; +PROCEDURE GetPenMask (VAR maskPtr:Mask) ; Tool $04,$33; +FUNCTION GetPenMode : Integer ; Tool $04,$2F; +PROCEDURE GetPenPat (VAR patternPtr:Pattern) ; Tool $04,$31; +PROCEDURE GetPenSize (VAR pointPtr:Point) ; Tool $04,$2D; +PROCEDURE GetPenState (VAR U__penStatePtr:PenState) ; Tool $04,$2B; +FUNCTION GetPicSave : Longint ; Tool $04,$3F; +FUNCTION GetPixel ( h:Integer; v:Integer) : Integer ; Tool $04,$88; +FUNCTION GetPolySave : Longint ; Tool $04,$43; +FUNCTION GetPort : GrafPortPtr ; Tool $04,$1C; +PROCEDURE GetPortLoc (VAR locInfoPtr:LocInfo) ; Tool $04,$1E; +PROCEDURE GetPortRect (VAR U__rectPtr:Rect) ; Tool $04,$20; +FUNCTION GetRgnSave : Longint ; Tool $04,$41; +PROCEDURE GetROMFont (VAR recordPtr:RomFontRec) ; Tool $04,$D8; +FUNCTION GetSCB ( scanLine:Integer) : Integer ; Tool $04,$13; +FUNCTION GetSpaceExtra : Fixed ; Tool $04,$9F; +FUNCTION GetStandardSCB : Integer ; Tool $04,$0C; +FUNCTION GetSysField : Longint ; Tool $04,$49; +FUNCTION GetSysFont : FontHndl ; Tool $04,$B3; +FUNCTION GetTextFace : TextStyle ; Tool $04,$9B; +FUNCTION GetTextMode : Integer ; Tool $04,$9D; +FUNCTION GetTextSize : Integer ; Tool $04,$D3; +FUNCTION GetUserField : Longint ; Tool $04,$47; +FUNCTION GetVisHandle : RgnHandle ; Tool $04,$C9; +PROCEDURE GetVisRgn ( aRgnHandle:RgnHandle) ; Tool $04,$B5; +PROCEDURE GlobalToLocal (VAR pointPtr:Point) ; Tool $04,$85; +PROCEDURE GrafOff ; Tool $04,$0B; +PROCEDURE GrafOn ; Tool $04,$0A; +PROCEDURE HideCursor ; Tool $04,$90; +PROCEDURE HidePen ; Tool $04,$27; +PROCEDURE InflateTextBuffer ( newWidth:Integer; newHeight:Integer) ; Tool +$04,$D7; +PROCEDURE InitColorTable (VAR tablePtr:ColorTable) ; Tool $04,$0D; +PROCEDURE InitCursor ; Tool $04,$CA; +PROCEDURE InitPort ( portPtr:GrafPortPtr) ; Tool $04,$19; +PROCEDURE InsetRect (VAR U__rectPtr:Rect; deltaH:Integer; deltaV:Integer) ; +Tool $04,$4C; +PROCEDURE InsetRgn ( aRgnHandle:RgnHandle; dH:Integer; dV:Integer) ; Tool +$04,$70; +PROCEDURE InvertArc ( rectPtr:Rect; startAngle:Integer; arcAngle:Integer) ; +Tool $04,$65; +PROCEDURE InvertOval ( rectPtr:Rect) ; Tool $04,$5B; +PROCEDURE InvertPoly ( polyHandle:Handle) ; Tool $04,$BF; +PROCEDURE InvertRect ( rectPtr:Rect) ; Tool $04,$56; +PROCEDURE InvertRgn ( aRgnHandle:RgnHandle) ; Tool $04,$7C; +PROCEDURE InvertRRect ( rectPtr:Rect; ovalWidth:Integer; ovalHeight:Integer) ; +Tool $04,$60; +PROCEDURE KillPoly ( polyHandle:Handle) ; Tool $04,$C3; +PROCEDURE Line ( dH:Integer; dV:Integer) ; Tool $04,$3D; +PROCEDURE LineTo ( h:Integer; v:Integer) ; Tool $04,$3C; +PROCEDURE LocalToGlobal (VAR pointPtr:Point) ; Tool $04,$84; +PROCEDURE MapPoly ( polyHandle:Handle; srcRectPtr:Rect; destRectPtr:Rect) ; +Tool $04,$C5; +PROCEDURE MapPt (VAR pointPtr:Point; srcRectPtr:Rect; destRectPtr:Rect) ; Tool +$04,$8A; +PROCEDURE MapRect (VAR rectPtr:Rect; srcRectPtr:Rect; destRectPtr:Rect) ; Tool +$04,$8B; +PROCEDURE MapRgn ( aRgnHandle:RgnHandle; srcRectPtr:Rect; destdRectPtr:Rect) ; +Tool $04,$8C; +PROCEDURE Move ( dH:Integer; dV:Integer) ; Tool $04,$3B; +PROCEDURE MovePortTo ( h:Integer; v:Integer) ; Tool $04,$22; +PROCEDURE MoveTo ( h:Integer; v:Integer) ; Tool $04,$3A; +FUNCTION NewRgn : RgnHandle ; Tool $04,$67; +PROCEDURE ObscureCursor ; Tool $04,$92; +PROCEDURE OffsetPoly ( polyHandle:Handle; dH:Integer; dV:Integer) ; Tool +$04,$C4; +PROCEDURE OffsetRect (VAR U__rectPtr:Rect; deltaH:Integer; deltaV:Integer) ; +Tool $04,$4B; +PROCEDURE OffsetRgn ( aRgnHandle:RgnHandle; dH:Integer; dV:Integer) ; Tool +$04,$6F; +FUNCTION OpenPoly : handle ; Tool $04,$C1; +PROCEDURE OpenPort ( portPtr:GrafPortPtr) ; Tool $04,$18; +PROCEDURE OpenRgn ; Tool $04,$6D; +PROCEDURE PaintArc ( rectPtr:Rect; startAngle:Integer; arcAngle:Integer) ; +Tool $04,$63; +PROCEDURE PaintOval ( rectPtr:Rect) ; Tool $04,$59; +PROCEDURE PaintPixels ( U__paintParamPtr:PaintParam) ; Tool $04,$7F; +PROCEDURE PaintPoly ( polyHandle:Handle) ; Tool $04,$BD; +PROCEDURE PaintRect ( rectPtr:Rect) ; Tool $04,$54; +PROCEDURE PaintRgn ( aRgnHandle:RgnHandle) ; Tool $04,$7A; +PROCEDURE PaintRRect ( rectPtr:Rect; ovalWidth:Integer; ovalHeight:Integer) ; +Tool $04,$5E; +PROCEDURE PenNormal ; Tool $04,$36; +PROCEDURE PPToPort ( srcLocPtr:LocInfoPtr; srcRectPtr:Rect; destX:Integer; +destY:Integer; transferMode:Integer) ; Tool $04,$D6; +PROCEDURE Pt2Rect (VAR point1Ptr:Point;VAR point2Ptr:Point;VAR U__rectPtr:Rect) +; Tool $04,$50; +FUNCTION PtInRect (VAR pointPtr:Point; rectPtr:Rect) : Boolean ; Tool $04,$4F; +FUNCTION PtInRgn (VAR pointPtr:Point; aRgnHandle:RgnHandle) : Boolean ; Tool +$04,$75; +FUNCTION Random : Integer ; Tool $04,$86; +FUNCTION RectInRgn ( rectPtr:Rect; aRgnHandle:RgnHandle) : Boolean ; Tool +$04,$76; +PROCEDURE RectRgn ( aRgnHandle:RgnHandle; rectPtr:Rect) ; Tool $04,$6C; +PROCEDURE RestoreBufDims ( sizeInfoPtr:BufDimRecPtr) ; Tool $04,$CE; +PROCEDURE SaveBufDims (VAR sizeInfoPtr:BufDimRec) ; Tool $04,$CD; +PROCEDURE ScalePt (VAR pointPtr:Point; srcRectPtr:Rect; destRectPtr:Rect) ; +Tool $04,$89; +PROCEDURE ScrollRect ( rectPtr:Rect; dH:Integer; dV:Integer; +aRgnHandle:RgnHandle) ; Tool $04,$7E; +FUNCTION SectRect ( rect1Ptr:Rect; rect2Ptr:Rect;VAR intersectRectPtr:Rect) : +Boolean ; Tool $04,$4D; +PROCEDURE SectRgn ( rgn1Handle:RgnHandle; rgn2Handle:RgnHandle; +destRgnHandle:RgnHandle) ; Tool $04,$71; +PROCEDURE SetAllSCBs ( newSCB:Integer) ; Tool $04,$14; +PROCEDURE SetArcRot ; Tool $04,$B0; +PROCEDURE SetBackColor ( backColor:Integer) ; Tool $04,$A2; +PROCEDURE SetBackPat ( patternPtr:Pattern) ; Tool $04,$34; +PROCEDURE SetBufDims ( maxWidth:Integer; maxFontHeight:Integer; +maxFBRExtent:Integer) ; Tool $04,$CB; +PROCEDURE SetCharExtra ( charExtra:Fixed) ; Tool $04,$D4; +PROCEDURE SetClip ( aRgnHandle:RgnHandle) ; Tool $04,$24; +PROCEDURE SetClipHandle ( aRgnHandle:RgnHandle) ; Tool $04,$C6; +PROCEDURE SetColorEntry ( tableNumber:Integer; entryNumber:Integer; +newColor:ColorValue) ; Tool $04,$10; +PROCEDURE SetColorTable ( tableNumber:Integer; srcTablePtr:ColorTable) ; Tool +$04,$0E; +PROCEDURE SetCursor ( theCursorPtr:Cursor) ; Tool $04,$8E; +PROCEDURE SetEmptyRgn ( aRgnHandle:RgnHandle) ; Tool $04,$6A; +PROCEDURE SetFont ( newFontHandle:FontHndl) ; Tool $04,$94; +PROCEDURE SetFontFlags ( fontFlags:Integer) ; Tool $04,$98; +PROCEDURE SetFontID (VAR U__fontID:FontID) ; Tool $04,$D0; +PROCEDURE SetForeColor ( foreColor:Integer) ; Tool $04,$A0; +PROCEDURE SetGrafProcs ( grafProcsPtr:QDProcsPtr) ; Tool $04,$44; +PROCEDURE SetIntUse ( useInt:Integer) ; Tool $04,$B6; +PROCEDURE SetMasterSCB ( masterSCB:Integer) ; Tool $04,$16; +PROCEDURE SetOrigin ( h:Integer; v:Integer) ; Tool $04,$23; +PROCEDURE SetPenMask ( maskPtr:Mask) ; Tool $04,$32; +PROCEDURE SetPenMode ( penMode:Integer) ; Tool $04,$2E; +PROCEDURE SetPenPat ( patternPtr:Pattern) ; Tool $04,$30; +PROCEDURE SetPenSize ( penWidth:Integer; penHeight:Integer) ; Tool $04,$2C; +PROCEDURE SetPenState (VAR U__penStatePtr:PenState) ; Tool $04,$2A; +PROCEDURE SetPicSave ( picSaveValue:Longint) ; Tool $04,$3E; +PROCEDURE SetPolySave ( polySaveValue:Longint) ; Tool $04,$42; +PROCEDURE SetPort ( portPtr:GrafPortPtr) ; Tool $04,$1B; +PROCEDURE SetPortLoc ( U__locInfoPtr:LocInfo) ; Tool $04,$1D; +PROCEDURE SetPortRect ( rectPtr:Rect) ; Tool $04,$1F; +PROCEDURE SetPortSize ( portWidth:Integer; portHeight:Integer) ; Tool $04,$21; +PROCEDURE SetPt (VAR srcPtPtr:Point; h:Integer; v:Integer) ; Tool $04,$82; +PROCEDURE SetRandSeed ( randomSeed:Longint) ; Tool $04,$87; +PROCEDURE SetRect (VAR aRectPtr:Rect; left:Integer; top:Integer; right:Integer; +bottom:Integer) ; Tool $04,$4A; +PROCEDURE SetRectRgn ( aRgnHandle:RgnHandle; left:Integer; top:Integer; +right:Integer; bottom:Integer) ; Tool $04,$6B; +PROCEDURE SetRgnSave ( rgnSaveValue:Longint) ; Tool $04,$40; +PROCEDURE SetSCB ( scanLine:Integer; newSCB:Integer) ; Tool $04,$12; +PROCEDURE SetSolidBackPat ( colorNum:Integer) ; Tool $04,$38; +PROCEDURE SetSolidPenPat ( colorNum:Integer) ; Tool $04,$37; +PROCEDURE SetSpaceExtra ( spaceExtra:Fixed) ; Tool $04,$9E; +PROCEDURE SetStdProcs ( stdProcRecPtr:QDProcsPtr) ; Tool $04,$8D; +PROCEDURE SetSysField ( sysFieldValue:Longint) ; Tool $04,$48; +PROCEDURE SetSysFont ( fontHandle:FontHndl) ; Tool $04,$B2; +PROCEDURE SetTextFace ( textFace:TextStyle) ; Tool $04,$9A; +PROCEDURE SetTextMode ( textMode:Integer) ; Tool $04,$9C; +PROCEDURE SetTextSize ( textSize:Integer) ; Tool $04,$D2; +PROCEDURE SetUserField ( userFieldValue:Longint) ; Tool $04,$46; +PROCEDURE SetVisHandle ( aRgnHandle:RgnHandle) ; Tool $04,$C8; +PROCEDURE SetVisRgn ( aRgnHandle:RgnHandle) ; Tool $04,$B4; +PROCEDURE ShowCursor ; Tool $04,$91; +PROCEDURE ShowPen ; Tool $04,$28; +PROCEDURE SolidPattern ( colorNum:Integer;VAR patternPtr:Pattern) ; Tool +$04,$39; +PROCEDURE StringBounds ( str:Str255;VAR resultPtr:Rect) ; Tool $04,$AD; +FUNCTION StringWidth ( str:Str255) : Integer ; Tool $04,$A9; +PROCEDURE SubPt (VAR srcPtPtr:Point;VAR destPtPtr:Point) ; Tool $04,$81; +PROCEDURE TextBounds ( textPtr:Ptr; textLength:Integer;VAR resultPtr:Rect) ; +Tool $04,$AF; +FUNCTION TextWidth ( textPtr:Ptr; textLength:Integer) : Integer ; Tool $04,$AB; +PROCEDURE UnionRect ( rect1Ptr:Rect; rect2Ptr:Rect;VAR unionRectPtr:Rect) ; +Tool $04,$4E; +PROCEDURE UnionRgn ( rgn1Handle:RgnHandle; rgn2Handle:RgnHandle; +unionRgnHandle:RgnHandle) ; Tool $04,$72; +PROCEDURE XorRgn ( rgn1Handle:RgnHandle; rgn2Handle:RgnHandle; +xorRgnHandle:RgnHandle) ; Tool $04,$74; +IMPLEMENTATION +END. diff --git a/pascal/resources.p b/pascal/resources.p new file mode 100755 index 0000000..4d37455 --- /dev/null +++ b/pascal/resources.p @@ -0,0 +1,184 @@ +{******************************************** +; File: Resources.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT RESOURCES; +INTERFACE +USES TYPES,MEMORY,GSOS; +CONST + +resLogOut = $0; {ResourceConverter - } +resLogIn = $1; {ResourceConverter - } +resLogApp = $0; {ResourceConverter - } +resLogSys = $2; {ResourceConverter - } + +(* *** Toolset Errors *** +resForkUsed = $1E01; {Error - Resource fork not empty } +resBadFormat = $1E02; {Error - Format of resource fork is unknown } +resForkEmpty = $1E03; {Error - Resource fork is empty } +resNoCurFile = $1E04; {Error - there are no current open resource files } +resDupID = $1E05; {Error - ID is already used } +resNotFound = $1E06; {Error - resource was not found } +resFileNotFound = $1E07; {Error - resource file not found } +resBadAppID = $1E08; {Error - User ID not found, please call ResourceStartup } +resNoUniqueID = $1E09; {Error - a unique ID was not found } +resBadAttr = $1E0A; {Error - reseved bits in attributes word are not zero } +resHashGone = $1E0B; {Error - the hash count table is no longer valid } +resIndexRange = $1E0D; {Error - index is out of range } +resNoCurApp = $1E0E; {Error - no current application, please call +ResourceStartup } + *** Toolset Errors *** *) + +resChanged = $0020; {Resources - } +resPreLoad = $0040; {Resources - } +resProtected = $0080; {Resources - } +resAbsLoad = $0400; {Resources - } +resConverter = $0800; {Resources - } +resMemAttr = $C3F1; {Resources - } +systemMap = $0001; {Resources - } +mapChanged = $0002; {Resources - } +romMap = $0004; {Resources - } +resNameOffset = $10000; {Resources - type holding names } +resNameVersion = $0001; {Resources - } +rIcon = $8001; {Resources - resource type holding names } +rPicture = $8002; {Resources - resource type holding names } +rControlList = $8003; {Resources - resource type holding names } +rControlTemplate = $8004; {Resources - resource type holding names } +rWindow = $8005; {Resources - resource type holding names } +rString = $8006; {Resources - resource type holding names } +rStringList = $8007; {Resources - resource type holding names } +rMenuBar = $8008; {Resources - resource type holding names } +rMenu = $8009; {Resources - resource type holding names } +rMenuItem = $800A; {Resources - resource type holding names } +rTextForLETextBox2 = $800B; {Resources - resource type holding names } +rCtlDefProc = $800C; {Resources - resource type holding names } +rCtlColorTbl = $800D; {Resources - resource type holding names } +rWindParam1 = $800E; {Resources - resource type holding names } +rWindParam2 = $800F; {Resources - resource type holding names } +rWindColor = $8010; {Resources - resource type holding names } +rResName = $8014; {Resources - resource type holding names } + +TYPE +ResID = Longint ; +ResType = Integer ; +ResAttr = Integer ; + + +ResHeaderRec = RECORD + rFileVersion : Longint; { Format version of resource fork } + rFileToMap : Longint; { Offset from start to resource map record } + rFileMapSize : Longint; { Number of bytes map occupies in file } + rFileMemo : PACKED ARRAY[1..128] OF Byte; { Reserved space for application +} + rFileRecSize : Longint; { Size of ResHeaderRec Record } +END; +FreeBlockRec = RECORD + blkOffset : Longint; + blkSize : Longint; +END; +ResMapHandle = ^ResMapPtr; +ResMapPtr = ^ResMap; +ResMap = RECORD + mapNext : ResMapHandle; { Handle to next resource map } + mapFlag : Integer; { Bit Flags } + mapOffset : Longint; { Map's file position } + mapSize : Longint; { Number of bytes map occupies in file } + mapToIndex : Integer; + mapFileNum : Integer; + mapID : Integer; + mapIndexSize : Longint; + mapIndexUsed : Longint; + mapFreeListSize : Integer; + mapFreeListUsed : Integer; + mapFreeList : ARRAY[1..1] OF FreeBlockRec; { n bytes (array of free block +records) } +END; +ResRefRecPtr = ^ResRefRec; +ResRefRec = RECORD + fResType : ResType; + fResID : ResID; + fResOffset : Longint; + fResAttr : ResAttr; + fResSize : Longint; + fResHandle : Handle; +END; +ResourceSpec = RECORD + resourceType : ResType; + resourceID : ResID; +END; +ResNameEntryPtr = ^ResNameEntry; +ResNameEntry = RECORD + namedResID : ResID; + resName : Str255; +END; +ResNameRecordHandle = ^ResNameRecordPtr; +ResNameRecordPtr = ^ResNameRecord; +ResNameRecord = RECORD + version : Integer; + nameCount : Longint; + resNameEntries : ARRAY[1..1] OF ResNameEntry; +END; +PROCEDURE ResourceBootInit ; Tool $1E,$01; +PROCEDURE ResourceStartup ( userID:Integer) ; Tool $1E,$02; +PROCEDURE ResourceShutdown ; Tool $1E,$03; +FUNCTION ResourceVersion : Integer ; Tool $1E,$04; +PROCEDURE ResourceReset ; Tool $1E,$05; +FUNCTION ResourceStatus : Boolean ; Tool $1E,$06; +PROCEDURE AddResource ( resourceHandle:Handle; resourceAttr:ResAttr; +resourceType:ResType; resourceID:ResID) ; Tool $1E,$0C; +PROCEDURE CloseResourceFile ( fileID:Integer) ; Tool $1E,$0B; +FUNCTION CountResources ( resourceType:ResType) : Longint ; Tool $1E,$22; +FUNCTION CountTypes : Integer ; Tool $1E,$20; +PROCEDURE CreateResourceFile ( auxType:Longint; fileType:Integer; +fileAccess:Integer; fileName:GSString255Ptr) ; Tool $1E,$09; +PROCEDURE DetachResource ( resourceType:ResType; resourceID:ResID) ; Tool +$1E,$18; +FUNCTION GetCurResourceApp : Integer ; Tool $1E,$14; +FUNCTION GetCurResourceFile : Integer ; Tool $1E,$12; +FUNCTION GetIndResource ( resourceType:ResType; resourceIndex:Longint) : ResID +; Tool $1E,$23; +FUNCTION GetIndType ( typeIndex:Integer) : ResType ; Tool $1E,$21; +FUNCTION GetMapHandle ( fileID:Integer) : ResMapHandle ; Tool $1E,$26; +FUNCTION GetOpenFileRefNum ( fileID:Integer) : Integer ; Tool $1E,$1F; +FUNCTION GetResourceAttr ( resourceType:ResType; resourceID:ResID) : ResAttr ; +Tool $1E,$1B; +FUNCTION GetResourceSize ( resourceType:ResType; currentID:ResID) : Longint ; +Tool $1E,$1D; +FUNCTION HomeResourceFile ( resourceType:ResType; resourceID:ResID) : Integer ; +Tool $1E,$15; +FUNCTION LoadAbsResource ( loadAddress:Longint; maxSize:Longint; +resourceType:ResType; resourceID:ResID) : Handle ; Tool $1E,$27; +FUNCTION LoadResource ( resourceType:ResType; resourceID:ResID) : Handle ; Tool +$1E,$0E; +PROCEDURE MarkResourceChange ( U__changeFlag:Boolean; resourceType:ResType; +resourceID:ResID) ; Tool $1E,$10; +PROCEDURE MatchResourceHandle ( foundRec:Ptr; resourceHandle:Handle) ; Tool +$1E,$1E; +FUNCTION OpenResourceFile ( openAccess:Integer; resourceMapPtr:ResMapPtr; +fileName:GSString255Ptr) : Integer ; Tool $1E,$0A; +PROCEDURE ReleaseResource ( purgeLevel:Integer; resourceType:ResType; +resourceID:ResID) ; Tool $1E,$17; +PROCEDURE RemoveResource ( resourceType:ResType; resourceID:ResID) ; Tool +$1E,$0F; +PROCEDURE ResourceConverter ( converterProc:ProcPtr; resourceType:ResType; +logFlags:Integer) ; Tool $1E,$28; +PROCEDURE SetCurResourceApp ( userID:Integer) ; Tool $1E,$13; +PROCEDURE SetCurResourceFile ( fileID:Integer) ; Tool $1E,$11; +PROCEDURE SetResourceAttr ( resourceAttr:ResAttr; resourceType:ResType; +currentID:ResID) ; Tool $1E,$1C; +FUNCTION SetResourceFileDepth ( searchDepth:Integer) : Integer ; Tool $1E,$25; +PROCEDURE SetResourceID ( newID:ResID; resourceType:ResType; currentID:ResID) +; Tool $1E,$1A; +FUNCTION SetResourceLoad ( readFlag:Integer) : Integer ; Tool $1E,$24; +FUNCTION UniqueResourceID ( IDrange:Integer; resourceType:ResType) : ResID ; +Tool $1E,$19; +PROCEDURE UpdateResourceFile ( fileID:Integer) ; Tool $1E,$0D; +PROCEDURE WriteResource ( resourceType:ResType; resourceID:ResID) ; Tool +$1E,$16; +IMPLEMENTATION +END. diff --git a/pascal/sane.p b/pascal/sane.p new file mode 100755 index 0000000..c313e23 --- /dev/null +++ b/pascal/sane.p @@ -0,0 +1,222 @@ +UNIT SANE; + +{ Apple IIGS SANE Interfaces + + See the Apple Numerics Manual for complete documentation + + + Copyright (c) 1986-1988 by TML Systems, Inc. All Rights Reserved. +} + + +{ The SANE environment word (Integer) is defined as follows: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +INTERFACE + +CONST DecStrLen = 255; + + + + + + + + + + + + + + + + + + + +TYPE + + + + + + + + + + + + + + + + + + + + + + +{ Standard housekeeping routines } + +PROCEDURE SANEStartUp + +PROCEDURE SANEShutDown; +FUNCTION SANEVersion: Integer; +PROCEDURE SANEReset; +FUNCTION SANEStatus: Integer; + +{ Conversions between numeric binary types } + +FUNCTION Num2Integer + +FUNCTION Num2Longint + +FUNCTION Num2Real + +FUNCTION Num2Double + +FUNCTION Num2Extended + +FUNCTION Num2Comp + + +{ Conversions between binary and decimal } + +PROCEDURE Num2Dec + + + +FUNCTION Dec2Num + + +{ Conversions between decimal formats } + +PROCEDURE Str2Dec + + + + +PROCEDURE CStr2Dec + + + +PROCEDURE Dec2Str + + + + +{ Arithmetic, auxiliary and elementary functions } + +FUNCTION Remainder + + +FUNCTION Rint + +FUNCTION Scalb + + +FUNCTION Logb + +FUNCTION Log2 + +FUNCTION Ln1 + +FUNCTION Exp2 + +FUNCTION Exp1 + +FUNCTION Tan + + +FUNCTION CopySign + +FUNCTION NextExtended + +FUNCTION XpwrI + + +FUNCTION XpwrY + +FUNCTION Compound + +FUNCTION Annuity + +FUNCTION RandomX + + +{ Inquirty routines } + +FUNCTION ClassReal + +FUNCTION ClassDouble + +FUNCTION ClassComp + +FUNCTION ClassExtended + +FUNCTION SignNum + + +{ NaN function } + +FUNCTION NAN + + +{ Environment control routines } + +FUNCTION GetHaltVector: Integer; +PROCEDURE SetHaltVector + + +{ Environment access routines } +PROCEDURE SetEnvironment + +PROCEDURE GetEnvironment + +PROCEDURE ProcEntry + +PROCEDURE ProcExit + + +{ Comparison routine } + +FUNCTION Relation + + +IMPLEMENTATION + +END. diff --git a/pascal/scheduler.p b/pascal/scheduler.p new file mode 100755 index 0000000..4f681bc --- /dev/null +++ b/pascal/scheduler.p @@ -0,0 +1,22 @@ +{******************************************** +; File: Scheduler.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT SCHEDULER; +INTERFACE +USES TYPES; +PROCEDURE SchBootInit ; Tool $07,$01; +PROCEDURE SchStartUp ; Tool $07,$02; +PROCEDURE SchShutDown ; Tool $07,$03; +FUNCTION SchVersion : Integer ; Tool $07,$04; +PROCEDURE SchReset ; Tool $07,$05; +FUNCTION SchStatus : Boolean ; Tool $07,$06; +FUNCTION SchAddTask ( taskPtr:VoidProcPtr) : Boolean ; Tool $07,$09; +PROCEDURE SchFlush ; Tool $07,$0A; +IMPLEMENTATION +END. diff --git a/pascal/scrap.p b/pascal/scrap.p new file mode 100755 index 0000000..5a743f1 --- /dev/null +++ b/pascal/scrap.p @@ -0,0 +1,40 @@ +{******************************************** +; File: Scrap.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT SCRAP; +INTERFACE +USES TYPES; +CONST + +(* *** Toolset Errors *** +badScrapType = $1610; {error - No scrap of this type. } + *** Toolset Errors *** *) + +textScrap = $0000; {scrapType - } +picScrap = $0001; {scrapType - } +PROCEDURE ScrapBootInit ; Tool $16,$01; +PROCEDURE ScrapStartUp ; Tool $16,$02; +PROCEDURE ScrapShutDown ; Tool $16,$03; +FUNCTION ScrapVersion : Integer ; Tool $16,$04; +PROCEDURE ScrapReset ; Tool $16,$05; +FUNCTION ScrapStatus : Boolean ; Tool $16,$06; +PROCEDURE GetScrap ( destHandle:Handle; scrapType:Integer) ; Tool $16,$0D; +FUNCTION GetScrapCount : Integer ; Tool $16,$12; +FUNCTION GetScrapHandle ( scrapType:Integer) : handle ; Tool $16,$0E; +FUNCTION GetScrapPath : Ptr ; Tool $16,$10; +FUNCTION GetScrapSize ( scrapType:Integer) : Longint ; Tool $16,$0F; +FUNCTION GetScrapState : Integer ; Tool $16,$13; +PROCEDURE LoadScrap ; Tool $16,$0A; +PROCEDURE PutScrap ( numBytes:Longint; scrapType:Integer; srcPtr:Ptr) ; Tool +$16,$0C; +PROCEDURE SetScrapPath ( path:Str255) ; Tool $16,$11; +PROCEDURE UnloadScrap ; Tool $16,$09; +PROCEDURE ZeroScrap ; Tool $16,$0B; +IMPLEMENTATION +END. diff --git a/pascal/sound.p b/pascal/sound.p new file mode 100755 index 0000000..713747f --- /dev/null +++ b/pascal/sound.p @@ -0,0 +1,115 @@ +{******************************************** +; File: Sound.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT SOUND; +INTERFACE +USES TYPES; +CONST + +(* *** Toolset Errors *** +noDOCFndErr = $0810; {error - no DOC chip found } +docAddrRngErr = $0811; {error - DOC address range error } +noSAppInitErr = $0812; {error - no SAppInit call made } +invalGenNumErr = $0813; {error - invalid generator number } +synthModeErr = $0814; {error - synthesizer mode error } +genBusyErr = $0815; {error - generator busy error } +mstrIRQNotAssgnErr = $0817; {error - master IRQ not assigned } +sndAlreadyStrtErr = $0818; {error - sound tools already started } +unclaimedSndIntErr = $08FF; {error - sound tools already started } + *** Toolset Errors *** *) + +ffSynthMode = $0001; {channelGenMode - Free form synthesizer mode } +noteSynthMode = $0002; {channelGenMode - Note synthesizer mode. } +gen0off = $0001; {genMask - param to FFStopSound } +gen1off = $0002; {genMask - param to FFStopSound } +gen2off = $0004; {genMask - param to FFStopSound } +gen3off = $0008; {genMask - param to FFStopSound } +gen4off = $0010; {genMask - param to FFStopSound } +gen5off = $0020; {genMask - param to FFStopSound } +gen6off = $0040; {genMask - param to FFStopSound } +gen7off = $0080; {genMask - param to FFStopSound } +gen8off = $0100; {genMask - param to FFStopSound } +gen9off = $0200; {genMask - param to FFStopSound } +gen10off = $0400; {genMask - param to FFStopSound } +gen11off = $0800; {genMask - param to FFStopSound } +gen12off = $1000; {genMask - param to FFStopSound } +gen13off = $2000; {genMask - param to FFStopSound } +gen14off = $4000; {genMask - param to FFStopSound } +genAvail = $0000; {genStatus - Generator available status } +ffSynth = $0100; {genStatus - Free Form Synthesizer status } +noteSynth = $0200; {genStatus - Note Synthesizer status } +lastBlock = $8000; {genStatus - Last block of wave } +smReadRegister = $00; {Jump Table Offset - Read Register routine } +smWriteRegister = $04; {Jump Table Offset - Write Register routine } +smReadRam = $08; {Jump Table Offset - Read Ram routine } +smWriteRam = $0C; {Jump Table Offset - Write Ram routine } +smReadNext = $10; {Jump Table Offset - Read Next routine } +smWriteNext = $14; {Jump Table Offset - Write Next routine } +smOscTable = $18; {Jump Table Offset - Pointer to Oscillator table } +smGenTable = $1C; {Jump Table Offset - Pointer to generator table } +smGcbAddrTable = $20; {Jump Table Offset - Pointer to GCB address table } +smDisableInc = $24; {Jump Table Offset - Disable Increment routine } + +TYPE +SoundPBHndl = ^SoundPBPtr; +SoundPBPtr = ^SoundParamBlock; +SoundParamBlock = RECORD + waveStart : Ptr; { starting address of wave } + waveSize : Integer; { waveform size in pages } + freqOffset : Integer; { ? formula to be provided } + docBuffer : Integer; { DOC buffer start address, low byte = 0 } + bufferSize : Integer; { DOC buffer start address, low byte = 0 } + nextWavePtr : SoundPBPtr; { Pointer to start of next wave's parameter block +} + volSetting : Integer; { DOC volume setting. High byte = 0 } +END; +DocRegParamBlkPtr = ^DocRegParamBlk; +DocRegParamBlk = PACKED RECORD + oscGenType : Integer; + freqLow1 : Byte; + freqHigh1 : Byte; + vol1 : Byte; + tablePtr1 : Byte; + control1 : Byte; + tableSize1 : Byte; + freqLow2 : Byte; + freqHigh2 : Byte; + vol2 : Byte; + tablePtr2 : Byte; + control2 : Byte; + tableSize2 : Byte; +END; +PROCEDURE SoundBootInit ; Tool $08,$01; +PROCEDURE SoundStartUp ( dPageAddr:Integer) ; Tool $08,$02; +PROCEDURE SoundShutDown ; Tool $08,$03; +FUNCTION SoundVersion : Integer ; Tool $08,$04; +PROCEDURE SoundReset ; Tool $08,$05; +FUNCTION SoundToolStatus : Boolean ; Tool $08,$06; +FUNCTION FFGeneratorStatus ( genNumber:Integer) : Integer ; Tool $08,$11; +FUNCTION FFSoundDoneStatus ( genNumber:Integer) : Boolean ; Tool $08,$14; +FUNCTION FFSoundStatus : Integer ; Tool $08,$10; +PROCEDURE FFStartSound ( genNumFFSynth:Integer; pBlockPtr:SoundPBPtr) ; Tool +$08,$0E; +PROCEDURE FFStopSound ( genMask:Integer) ; Tool $08,$0F; +FUNCTION GetSoundVolume ( genNumber:Integer) : Integer ; Tool $08,$0C; +FUNCTION GetTableAddress : Ptr ; Tool $08,$0B; +PROCEDURE ReadRamBlock ( destPtr:Ptr; docStart:Integer; byteCount:Integer) ; +Tool $08,$0A; +PROCEDURE SetSoundMIRQV ( sMasterIRQ:Longint) ; Tool $08,$12; +PROCEDURE SetSoundVolume ( volume:Integer; genNumber:Integer) ; Tool $08,$0D; +FUNCTION SetUserSoundIRQV ( userIRQVector:Longint) : Ptr ; Tool $08,$13; +PROCEDURE WriteRamBlock ( srcPtr:Ptr; docStart:Integer; byteCount:Integer) ; +Tool $08,$09; +PROCEDURE FFSetUpSound ( channelGen:Integer; paramBlockPtr:SoundPBPtr) ; Tool +$08,$15; +PROCEDURE FFStartPlaying ( genWord:Integer) ; Tool $08,$16; +PROCEDURE SetDOCReg ( pBlockPtr:DocRegParamBlk) ; Tool $08,$17; +PROCEDURE ReadDOCReg (VAR pBlockPtr:DocRegParamBlk) ; Tool $08,$18; +IMPLEMENTATION +END. diff --git a/pascal/stdfile.p b/pascal/stdfile.p new file mode 100755 index 0000000..4d35144 --- /dev/null +++ b/pascal/stdfile.p @@ -0,0 +1,154 @@ +{******************************************** +; File: StdFile.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT STDFILE; +INTERFACE +USES Types, QuickDraw, Events, Controls, Windows, LineEdit, Dialogs; +CONST + +noDisplay = $0000; {filterProc result - file not to be displayed } +noSelect = $0001; {filterProc result - file displayed, but not selectable } +displaySelect = $0002; {filterProc result - file displayed and selectable } +sfMatchFileType = $8000; { - } +sfMatchAuxType = $4000; { - } +sfDisplayGrey = $2000; { - } + +TYPE +SFReplyRecPtr = ^SFReplyRec; +SFReplyRec = RECORD + good : Boolean; + fileType : Integer; + auxFileType : Integer; + filename : String[15]; + fullPathname : String[128]; +END; +SFReplyRec2Hndl = ^SFReplyRec2Ptr; +SFReplyRec2Ptr = ^SFReplyRec2; +SFReplyRec2 = RECORD + good : Boolean; + filetype : Integer; + auxType : Longint; + nameDesc : RefDescriptor; + nameRef : Ref; + pathDesc : RefDescriptor; + pathRef : Ref; +END; +multiReplyRecord = RECORD + good : Integer; + namesHandle : Handle; +END; +SFTypeListHandle = ^SFTypeListPtr; +SFTypeListPtr = ^SFTypeList; +SFTypeList = PACKED RECORD + numEntries : Byte; + fileTypeEntries : PACKED ARRAY[1..5] OF Byte; +END; +TypeSelector2 = RECORD + flags : Integer; + fileType : Integer; + auxType : Longint; +END; +SFTypeList2Ptr = ^SFTypeList2; +SFTypeList2 = RECORD + numEntries : Integer; + fileTypeEntries : ARRAY[1..5] OF TypeSelector2; +END; +PROCEDURE SFBootInit ; Tool $17,$01; +PROCEDURE SFStartUp ( userID:Integer; dPageAddr:Integer) ; Tool $17,$02; +PROCEDURE SFShutDown ; Tool $17,$03; +FUNCTION SFVersion : Integer ; Tool $17,$04; +PROCEDURE SFReset ; Tool $17,$05; +FUNCTION SFStatus : Boolean ; Tool $17,$06; +PROCEDURE SFAllCaps ( allCapsFlag:Boolean) ; Tool $17,$0D; +PROCEDURE SFGetFile + + + + + + +PROCEDURE SFGetFile2 + + + + + + + +PROCEDURE SFMultiGet2 ( whereX:Integer; + + + + + + +PROCEDURE SFPGetFile ( whereX:Integer; + + + + + + +PROCEDURE SFPGetFile2 ( whereX:Integer; + + + + + + + + + +PROCEDURE SFPMultiGet2 ( whereX:Integer; + + + + + + + + + +PROCEDURE SFPPutFile ( whereX:Integer; + + + + + + + +PROCEDURE SFPPutFile2 + + + + + + + + + + +PROCEDURE SFPutFile ( whereX:Integer; + + + + + +PROCEDURE SFPutFile2 ( whereX:Integer; + + + + + + +FUNCTION SFShowInvisible ( invisibleState:Boolean) : Boolean ; Tool $17,$12; +PROCEDURE SFReScan ( filterProcPtr:ProcPtr; typeListPtr:SFTypeList2Ptr) ; Tool +$17,$13; +IMPLEMENTATION +END. diff --git a/pascal/textedit.p b/pascal/textedit.p new file mode 100755 index 0000000..c0ca530 --- /dev/null +++ b/pascal/textedit.p @@ -0,0 +1,343 @@ +{******************************************** +; File: TextEdit.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT TEXTEDIT; +INTERFACE +USES TYPES,MEMORY,QUICKDRAW,EVENTS,CONTROLS,FONTS,GSOS,RESOURCES; +CONST + +(* *** Toolset Errors *** +teAlreadyStarted = $2201; {error - } +teNotStarted = $2202; {error - } +teInvalidHandle = $2203; {error - } +teInvalidVerb = $2204; {error - } +teInvalidFlag = $2205; {error - } +teInvalidPCount = $2206; {error - } +teInvalidRect = $2207; {error - } +teBufferOverflow = $2208; {error - } +teInvalidLine = $2209; { - } +teInvalidCall = $220A; { - } + *** Toolset Errors *** *) + +NullVerb = $0; {TE - } +PStringVerb = $0001; {TE - } +CStringVerb = $0002; {TE - } +C1InputVerb = $0003; {TE - } +C1OutputVerb = $0004; {TE - } +HandleVerb = $0005; {TE - } +PointerVerb = $0006; {TE - } +NewPStringVerb = $0007; {TE - } +fEqualLineSpacing = $8000; {TE - } +fShowInvisibles = $4000; {TE - } +teInvalidDescriptor = $2204; { - } +teInvalidParameter = $220B; { - } +teInvalidTextBox2 = $220C; { - } +teEqualLineSpacing = $8000; { - } +teShowInvisibles = $4000; { - } +teJustLeft = $0; { - } +teJustRight = $1; { - } +teJustCenter = $2; { - } +teJustFull = $3; { - } +teNoTabs = $0; { - } +teColumnTabs = $1; { - } +teAbsoluteTabs = $2; { - } +teLeftTab = $0; { - } +teCenterTab = $1; { - } +teRightTab = $2; { - } +teDecimalTab = $3; { - } +teInvis = $4000; { - } +teCtlColorIsPtr = $0000; { - } +teCtlColorIsHandle = $0004; { - } +teCtlColorIsResource = $0008; { - } +teCtlStyleIsPtr = $0000; { - } +teCtlStyleIsHandle = $0001; { - } +teCtlStyleIsResource = $0002; { - } +teNotControl = $80000000; { - } +teSingleFormat = $40000000; { - } +teSingleStyle = $20000000; { - } +teNoWordWrap = $10000000; { - } +teNoScroll = $08000000; { - } +teReadOnly = $04000000; { - } +teSmartCutPaste = $02000000; { - } +teTabSwitch = $01000000; { - } +teDrawBounds = $00800000; { - } +teColorHilite = $00400000; { - } +teRefIsPtr = $0000; { - } +teRefIsHandle = $0001; { - } +teRefIsResource = $0002; { - } +teRefIsNewHandle = $0003; { - } +teDataIsPString = $0000; { - } +teDataIsCString = $0001; { - } +teDataIsC1Input = $0002; { - } +teDataIsC1Output = $0003; { - } +teDataIsTextBox2 = $0004; { - } +teDataIsTextBlock = $0005; { - } +teTextIsPtr = $0000; { - } +teTextIsHandle = $0008; { - } +teTextIsResource = $0010; { - } +teTextIsNewHandle = $0018; { - } +tePartialLines = $8000; { - } +teDontDraw = $4000; { - } +teUseFont = $0020; { - } +teUseSize = $0010; { - } +teUseForeColor = $0008; { - } +teUseBackColor = $0004; { - } +teUseUserData = $0002; { - } +teUseAttributes = $0001; { - } +teReplaceFont = $0040; { - } +teReplaceSize = $0020; { - } +teReplaceForeColor = $0010; { - } +teReplaceBackColor = $0008; { - } +teReplaceUserField = $0004; { - } +teReplaceAttributes = $0002; { - } +teSwitchAttributes = $0001; { - } +teEraseRect = $0001; { - } +teEraseBuffer = $0002; { - } +teRectChanged = $0003; { - } +doEraseRect = $0001; { - } +doEraseBuffer = $0002; { - } +doRectChanged = $0003; { - } +doKeyStroke = $0004; { - } + +TYPE +TEColorTablePtr = ^TEColorTable; +TEColorTable = RECORD + contentColor : Integer; + outlineColor : Integer; + pageBoundaryColor : Integer; + hiliteForeColor : Integer; + hiliteBackColor : Integer; + vertColorDescriptor : Integer; + vertColorRef : Longint; + horzColorDescriptor : Integer; + horzColorRef : Longint; + growColorDescriptor : Integer; + growColorRef : Longint; +END; +TEBlockEntry = RECORD + text : Handle; + length : Handle; + flags : Integer; +END; +TEBlocksHndl = ^TEBlocksPtr; +TEBlocksPtr = ^TEBlocksRecord; +TEBlocksRecord = RECORD + start : Longint; + index : Integer; + blocks : ARRAY[1..1] OF TEBlockEntry; +END; +TEHandle = ^TERecordPtr; +TERecordPtr = ^TERecord; +TERecord = PACKED RECORD + ctlNext : CtlRecHndl; + ctlOwner : WindowPtr; + ctlRect : Rect; + ctlFlag : Byte; + ctlHilite : Byte; + ctlValue : Integer; + ctlProc : ProcPtr; + ctlAction : ProcPtr; + ctlData : Longint; + ctlRefCon : Longint; + ctlColorRef : TEColorTablePtr; + + ctlID : Longint; + ctlMoreFlags : Integer; + ctlVersion : Integer; + theChar : Integer; + theModifiers : Integer; + extendFlag : Integer; + moveByWord : Integer; + inputPtr : Ptr; + inputLength : Longint; + theRect : Rect; +END; +TETabItem = RECORD + tabKind : Integer; + tabData : Integer; +END; +TERuler = RECORD + leftMargin : Integer; + leftIndent : Integer; + rightMargin : Integer; + just : Integer; + extraLS : Integer; + flags : Integer; + userData : Integer; + tabType : Integer; + tabs : ARRAY[1..1] OF TETabItem; + tabTerminator : Integer; +END; +TEStyle = RECORD + teFont : FontID; + foreColor : Integer; + backColor : Integer; + reserved : Longint; +END; +TEStyleGroupHndl = ^TEStyleGroupPtr; +TEStyleGroupPtr = ^TEStyleGroup; +TEStyleGroup = RECORD + count : Integer; + styles : ARRAY[1..1] OF TEStyle; +END; +TEStyleItem = RECORD + length : Longint; + offset : Longint; +END; +TEFormatHndl = ^TEFormatPtr; +TEFormatPtr = ^TEFormat; +TEFormat = RECORD + version : Integer; + rulerListLength : Longint; + theRulerList : ARRAY[1..1] OF TERuler; + styleListLength : Longint; + theStyleList : ARRAY[1..1] OF TEStyle; + numberOfStyles : Longint; + theStyles : ARRAY[1..1] OF TEStyleItem; +END; +TETextRef = RECORD CASE INTEGER OF + $0000:(textIsPStringPtr:StringPtr); + $0001:(textIsCStringPtr:CStringPtr); + $0002:(textIsC1InputPtr:GSString255Ptr); + $0003:(textIsC1OutputPtr:ResultBuf255Ptr); + $0004:(textIsTB2Ptr:Ptr); + $0005:(textIsRawPtr:Ptr); + + $0008:(textIsPStringHandle:String255Hndl); + $0009:(textIsCStringHandle:CStringHndl); + $000A:(textIsC1InputHandle:GSString255Hndl); + $000B:(textIsC1OutputHandle:ResultBuf255Hndl); + $000C:(textIsTB2Handle:Handle); + $000D:(textIsRawHandle:Handle); + + $0010:(textIsPStringResource: ResID); + $0011:(textIsCStringResource: ResID); + $0012:(textIsC1InputResource: ResID); + $0013:(textIsC1OutputResource: ResID); + $0014:(textIsTB2Resource: ResID); + $0015:(textIsRawResource: ResID); + + $0018:(textIsPStringNewH:String255HndlPtr); + $0019:(textIsCStringNewH:CStringHndlPtr); + $001A:(textIsC1InputNewH:GSString255HndlPtr); + $001B:(textIsC1OutputNewH:ResultBuf255HndlPtr); + $001C:(textIsTB2NewH:HandlePtr); + $001D:(textIsRawNewH:HandlePtr); +END; + +TEStyleRef = RECORD CASE INTEGER OF + $0000:(styleIsPtr:TEFormatPtr); + $0001:(styleIsHandle:TEFormatHndl); + $0002:(styleIsResource:ResID); + $0003:(styleIsNewH:^TEFormatHndl); +END; + +TEParamBlockHndl = ^TEParamBlockPtr; +TEParamBlockPtr = ^TEParamBlock; +TEParamBlock = RECORD + pCount : Integer; + controlID : Longint; + boundsRect : Rect; + procRef : Longint; + flags : Integer; + moreflags : Integer; + refCon : Longint; + textFlags : Longint; + indentRect : Rect; + vertBar : CtlRecHndl; + vertScroll : Integer; + horzBar : CtlRecHndl; + horzScroll : Integer; + styleRef : TEStyleRef; + textDescriptor : Integer; + textRef : TETextRef; + textLength : Longint; + maxChars : Longint; + maxLines : Longint; + maxHeight : Integer; + pageHeight : Integer; + headerHeight : Integer; + footerHeight : Integer; + pageBoundary : Integer; + colorRef : Longint; + drawMode : Integer; + filterProcPtr : ProcPtr; +END; +TEInfoRec = RECORD + charCount : Longint; + lineCount : Longint; + formatMemory : Longint; + totalMemory : Longint; + styleCount : Longint; + rulerCount : Longint; +END; +TEHooks = RECORD + charFilter : ProcPtr; + wordWrap : ProcPtr; + wordBreak : ProcPtr; + drawText : ProcPtr; + eraseText : ProcPtr; +END; +PROCEDURE TEBootInit ; Tool $22,$01; +PROCEDURE TEStartup ( userId:Integer; directPage:Integer) ; Tool $22,$02; +PROCEDURE TEShutdown ; Tool $22,$03; +FUNCTION TEVersion : Integer ; Tool $22,$04; +PROCEDURE TEReset ; Tool $22,$05; +FUNCTION TEStatus : Integer ; Tool $22,$06; +PROCEDURE TEActivate ( teH:TEHandle) ; Tool $22,$0F; +PROCEDURE TEClear ( teH:TEHandle) ; Tool $22,$19; +PROCEDURE TEClick (VAR theEventPtr:EventRecord; teH:TEHandle) ; Tool $22,$11; +PROCEDURE TECut ( teH:TEHandle) ; Tool $22,$16; +PROCEDURE TECopy ( teH:TEHandle) ; Tool $22,$17; +PROCEDURE TEDeactivate ( teH:TEHandle) ; Tool $22,$10; +FUNCTION TEGetDefProc : ProcPtr ; Tool $22,$22; +PROCEDURE TEGetHooks (VAR hooks:TEHooks; count:Integer; teH:TEHandle) ; Tool +$22,$20; +PROCEDURE TEGetSelection (VAR selStart:Longint;VAR selEnd:Longint; +teH:TEHandle) ; Tool $22,$1C; +FUNCTION TEGetSelectionStyle (VAR commonStyle:TEStyle; +styleHandle:TEStyleGroupHndl; teH:TEHandle) : Integer ; Tool $22,$1E; +FUNCTION TEGetText ( bufferDesc:Integer; bufferRef:TETextRef; +bufferLength:Longint; styleDesc:Integer; styleRef:TEStyleRef; teH:TEHandle) : +Longint ; Tool $22,$0C; +PROCEDURE TEGetTextInfo (VAR infoRec:TEInfoRec; pCount:Integer; teH:TEHandle) +; Tool $22,$0D; +PROCEDURE TEIdle ( teH:TEHandle) ; Tool $22,$0E; +PROCEDURE TEInsert ( textDesc:Integer; textRef:TETextRef; textLength:Longint; +styleDesc:Integer; styleRef:TEStyleRef; teH:TEHandle) ; Tool $22,$1A; +PROCEDURE TEInsertPageBreak ( teH:TEHandle) ; Tool $22,$15; +PROCEDURE TEKey ( theEventPtr:EventRecord; teH:TEHandle) ; Tool $22,$14; +PROCEDURE TEKill ( teH:TEHandle) ; Tool $22,$0A; +FUNCTION TENew ( theParms:TEParamBlock) : TEHandle ; Tool $22,$09; +FUNCTION TEPaintText ( thePort:GrafPortPtr; start:Longint; destRect:rect; +paintFlags:Integer; teH:TEHandle) : Longint ; Tool $22,$13; +PROCEDURE TEPaste ( teH:TEHandle) ; Tool $22,$18; +PROCEDURE TEReplace ( textDesc:Integer; textRef:TETextRef; textLength:Longint; +styleDesc:Integer; styleRef:TEStyleRef; teH:TEHandle) ; Tool $22,$1B; +PROCEDURE TESetHooks ( hooks:TEHooks; count:Integer; teH:TEHandle) ; Tool +$22,$21; +PROCEDURE TESetSelection ( selStart:Longint; selEnd:Longint; teH:TEHandle) ; +Tool $22,$1D; +PROCEDURE TESetText ( textDesc:Integer; textRef:TETextRef; textLength:Longint; +styleDesc:Integer; styleRef:TEStyleRef; teH:TEHandle) ; Tool $22,$0B; +PROCEDURE TEStyleChange ( flags:Integer; newStyle:TEStyle; teH:TEHandle) ; +Tool $22,$1F; +PROCEDURE TEUpdate ( teH:TEHandle) ; Tool $22,$12; +PROCEDURE TEGetRuler ( rulerDescriptor:Integer; rulerRef:Ref; teH:TEHandle) ; +Tool $22,$23; +PROCEDURE TEOffsetToPoint ( textOffset:Longint; vertPosPtr:Ptr; horzPosPtr:Ptr; +teH:TEHandle) ; Tool $22,$20; +FUNCTION TEPointToOffset ( vertPosPtr:Ptr; horzPosPtr:Ptr; teH:TEHandle) : +Longint ; Tool $22,$21; +FUNCTION TEScroll ( scrollDescriptor:Integer; vertAmount:Longint; +horzAmount:Longint; teH:TEHandle) : Longint ; Tool $22,$25; +PROCEDURE TESetRuler ( rulerDescriptor:Integer; rulerRef:Ref; teH:TEHandle); +Tool $22,$24; +IMPLEMENTATION +END. diff --git a/pascal/types.p b/pascal/types.p new file mode 100755 index 0000000..b27a8ec --- /dev/null +++ b/pascal/types.p @@ -0,0 +1,104 @@ +{******************************************** +; File: Types.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT TYPES; +INTERFACE + +CONST +noError = $0000; + +refIsPointer = $0000; {RefDescriptor - } +refIsHandle = $0001; {RefDescriptor - } +refIsResource = $0002; {RefDescriptor - } +refIsNewHandle = $0003; {RefDescriptor - } + +TYPE +Byte = 0..255; +Fixed = Longint ; +Frac = Longint ; +ExtendedPtr = ^Extended; + +SignedByte = -128..127; +PackedByte = PACKED ARRAY [1..1] of SignedByte; +Ptr = ^PackedByte; +PointerPtr = ^Ptr; +Handle = ^Ptr; + +HandlePtr = ^Handle; + +CStringPtr = Ptr; +CStringHndl = ^CStringPtr; +CStringHndlPtr = ^CStringHndl; +ProcPtr = Ptr; +VoidProcPtr = ProcPtr; +WordProcPtr = ProcPtr; +LongProcPtr = ProcPtr; + +IntPtr = ^Integer; +FPTPtr = Ptr ; +String255 = STRING[255]; +String255Ptr = ^String255; +String255Hndl = ^String255Ptr; +String255HndlPtr = ^String255Hndl; +Str255 = String255; +StringPtr = String255Ptr; +StringHandle = ^StringPtr; +String32 = STRING[32]; +String32Ptr = ^String32; +String32Handle = ^String32Ptr; +Str32 = String32; + +PointPtr = ^Point; +Point = RECORD + v : Integer; + h : Integer; +END; +RectHndl = ^RectPtr; +RectPtr = ^Rect; +Rect = RECORD +CASE INTEGER OF +1: + (top: Integer; + left: Integer; + bottom: Integer; + right: Integer); +2: + (topLeft: Point; + botRight: Point); +3: ( +v1 : Integer; +h1 : Integer; +v2 : Integer; +h2 : Integer); +END; + +TimeRecHndl = ^TimeRecPtr; +TimeRecPtr = ^TimeRec; +TimeRec = PACKED RECORD + second : Byte; + minute : Byte; + hour : Byte; + year : Byte; + day : Byte; + month : Byte; + extra : Byte; + weekDay : Byte; +END; + +RefDescriptor = Integer; +Ref = RECORD + CASE Integer OF + refIsPointer : ( refIsPointer : Ptr ) ; + refIsHandle : ( refIsHandle : Handle ) ; + refIsResource : ( refIsResource : Longint ) ; + refIsNewHandle : ( refIsNewHandle : Handle ) ; +END; + +IMPLEMENTATION +END. diff --git a/pascal/video.p b/pascal/video.p new file mode 100755 index 0000000..80c5509 --- /dev/null +++ b/pascal/video.p @@ -0,0 +1,119 @@ +{******************************************** +; File: Video.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT VIDEO; +INTERFACE +USES TYPES; +CONST + +vdVideoOverlay = $01; { - } +vdFrameGrabber = $02; { - } +vdInVStandards = $03; { - } +vdOutVStandards = $04; { - } +vdKeyDissLevels = $05; { - } +vdNKeyDissLevels = $06; { - } +vdAdjSideEffect = $07; { - } +vdKeyColorBits = $08; { - } +vdInHueAdj = $09; { - } +vdInSatAdj = $0A; { - } +vdInContrastAdj = $0B; { - } +vdInBrightAdj = $0C; { - } +vdOutSetup = $0D; { - } +vdOutChromaFilter = $0E; { - } +vdOutExtBlank = $0F; { - } +vdKeyEnhDiss = $10; { - } +vdLineInterrupt = $11; { - } +vdGGBus = $12; { - } +vdDualOut = $13; { - } +vdTextMonoOver = $14; { - } +vdGenlock = $32; { - } +vdVideoDetect = $33; { - } +vdGenlocked = $34; { - } +vdAdjInc = $50; { - } +vdAdjDec = $51; { - } +vdAdjSave = $52; { - } +vdAvail = $01; { - } +vdNotAvail = $00; { - } +vdYes = $01; { - } +vdNo = $00; { - } +vdOn = $01; { - } +vdOff = $00; { - } +vdKColorEnable = $64; { - } +vdVerticalBlank = $82; { - } +vdMainPageLin = $C8; { - } +vdRAMPageSel = $C9; { - } +vdVBLInterrupt = $CA; { - } +vdInterlaceMode = $CB; { - } +vdClearVBLInt = $CC; { - } +vdClearLineInt = $CD; { - } +vdDisplayField = $CE; { - } +vdVBLIntRequest = $CF; { - } +vdLineIntRequest = $D0; { - } +vdNone = $00; { - } +vdNTSC = $01; { - } +vdPAL = $02; { - } +vdSECAM = $04; { - } +vdSNTSC = $08; { - } +vdSPAL = $10; { - } +vdSSECAM = $20; { - } +vdRGB60 = $40; { - } +vdRGB50 = $80; { - } +vdAux = $00; { - } +vdMain = $10; { - } +vdInterlace = $30; { - } +vdField1 = $01; { - } +vdField0 = $00; { - } +vdEnable = $01; { - } +vdDisable = $00; { - } +vdExternal = $00; { - } +vdGraphics = $01; { - } +vdVBlank = $01; { - } +vdActiveVideo = $00; { - } +vdNoVideoDevice = $2110; {Error - no video device was found } +vdAlreadyStarted = $2111; {Error - Video tool set already started } +vdInvalidSelector = $2112; {Error - an invalid selector was specified } +vdInvalidParam = $2113; {Error - an invalid parameter was specified } +vdUnImplemented = $21FF; {Error - an unimplemented tool set routine was called +} +PROCEDURE VDBootInit ; Tool $21,$01; +PROCEDURE VDStartUp ; Tool $21,$02; +PROCEDURE VDShutdown ; Tool $21,$03; +FUNCTION VDVersion : Integer ; Tool $21,$04; +PROCEDURE VDReset ; Tool $21,$05; +FUNCTION VDStatus : Boolean ; Tool $21,$06; +FUNCTION VDGetFeatures ( videoSelector:Integer) : Integer ; Tool $21,$1B; +PROCEDURE VDInControl ( videoSelector:Integer; inputCtlValue:Integer) ; Tool +$21,$1C; +FUNCTION VDInStatus ( videoSelector:Integer) : Integer ; Tool $21,$09; +PROCEDURE VDInSetStd ( inputStandard:Integer) ; Tool $21,$0A; +FUNCTION VDInGetStd : Integer ; Tool $21,$0B; +PROCEDURE VDInConvAdj ( videoSelector:Integer; adjustFunction:Integer) ; Tool +$21,$0C; +PROCEDURE VDKeyControl ( videoSelector:Integer; keyerCtlValue:Integer) ; Tool +$21,$0D; +FUNCTION VDKeyStatus ( videoSelector:Integer) : Integer ; Tool $21,$0E; +PROCEDURE VDKeySetKCol ( redValue:Integer; greenValue:Integer; +blueValue:Integer) ; Tool $21,$0F; +FUNCTION VDKeyGetRCol : Integer ; Tool $21,$10; +FUNCTION VDKeyGetGCol : Integer ; Tool $21,$11; +FUNCTION VDKeyGetBCol : Integer ; Tool $21,$12; +PROCEDURE VDKeySetKDiss ( kDissolve:Integer) ; Tool $21,$13; +FUNCTION VDKeyGetKDiss : Integer ; Tool $21,$14; +PROCEDURE VDKeySetNKDiss ( nonKeyDissolve:Integer) ; Tool $21,$15; +FUNCTION VDKeyGetNKDiss : Integer ; Tool $21,$16; +PROCEDURE VDOutSetStd ( outStandard:Integer) ; Tool $21,$17; +FUNCTION VDOutGetStd : Integer ; Tool $21,$18; +PROCEDURE VDOutControl ( videoSelector:Integer; outCtlValue:Integer) ; Tool +$21,$19; +FUNCTION VDOutStatus ( videoSelector:Integer) : Integer ; Tool $21,$1A; +PROCEDURE VDGGControl ( videoSelector:Integer; gGCtlValue:Integer) ; Tool +$21,$1D; +FUNCTION VDGGStatus ( videoSelector:Integer) : Integer ; Tool $21,$1E; +IMPLEMENTATION +END. diff --git a/pascal/windows.p b/pascal/windows.p new file mode 100755 index 0000000..db311c6 --- /dev/null +++ b/pascal/windows.p @@ -0,0 +1,301 @@ +{******************************************** +; File: Windows.p +; +; +; Copyright Apple Computer, Inc. 1986-89 +; All Rights Reserved +; +********************************************} + +UNIT WINDOWS; +INTERFACE +USES TYPES,QUICKDRAW,EVENTS,CONTROLS; +CONST + +(* *** Toolset Errors *** +paramLenErr = $0E01; {error - first word of parameter list is the wrong size } +allocateErr = $0E02; {error - unable to allocate window record } +taskMaskErr = $0E03; {error - bits 12-15 are not clear in WmTaskMask field of +EventRecord } + *** Toolset Errors *** *) + +wNoConstraint = $0000; {Axis parameter - No constraint on movement. } +wHAxisOnly = $0001; {Axis parameter - Horizontal axis only. } +wVAxisOnly = $0002; {Axis parameter - Vertical axis only. } +FromDesk = $00; {Desktop Command - Subtract region from desktop } +ToDesk = $1; {Desktop Command - Add region to desktop } +GetDesktop = $2; {Desktop Command - Get Handle of Desktop region } +SetDesktop = $3; {Desktop Command - Set Handle of Desktop region } +GetDeskPat = $4; {Desktop command - Address of pattern or drawing routine } +SetDeskPat = $5; {Desktop command - Change Address of pattern or drawing +routine } +GetVisDesktop = $6; {Desktop command - Get destop region less visible windows. +} +BackGroundRgn = $7; {Desktop command - For drawing directly on desktop. } +toBottom = $FFFFFFFE; {SendBehind value - To send window to bottom. } +topMost = $FFFFFFFF; {SendBehind value - To make window top. } +bottomMost = $0000; {SendBehind value - To make window bottom. } +tmMenuKey = $0001; {Task Mask - } +tmUpdate = $0002; {Task Mask - } +tmFindW = $0004; {Task Mask - } +tmMenuSel = $0008; {Task Mask - } +tmOpenNDA = $0010; {Task Mask - } +tmSysClick = $0020; {Task Mask - } +tmDragW = $0040; {Task Mask - } +tmContent = $0080; {Task Mask - } +tmClose = $0100; {Task Mask - } +tmZoom = $0200; {Task Mask - } +tmGrow = $0400; {Task Mask - } +tmScroll = $0800; {Task Mask - } +tmSpecial = $1000; {Task Mask - } +tmCRedraw = $2000; {Task Mask - } +tmInactive = $4000; {Task Mask - } +tmInfo = $8000; {Task Mask - } +wNoHit = $0000; {TaskMaster codes - retained for back compatibility. } +inNull = $0000; {TaskMaster codes - retained for back compatibility } +inKey = $0003; {TaskMaster codes - retained for back compatibility } +inButtDwn = $0001; {TaskMaster codes - retained for back compatibility } +inUpdate = $0006; {TaskMaster codes - retained for back compatibility } +wInDesk = $0010; {TaskMaster codes - On Desktop } +wInMenuBar = $0011; {TaskMaster codes - On system menu bar } +wClickCalled = $0012; {TaskMaster codes - system click called } +wInContent = $0013; {TaskMaster codes - In content region } +wInDrag = $0014; {TaskMaster codes - In drag region } +wInGrow = $0015; {TaskMaster codes - In grow region, active window only } +wInGoAway = $0016; {TaskMaster codes - In go-away region, active window only } +wInZoom = $0017; {TaskMaster codes - In zoom region, active window only } +wInInfo = $0018; {TaskMaster codes - In information bar } +wInSpecial = $0019; {TaskMaster codes - Item ID selected was 250 - 255 } +wInDeskItem = $001A; {TaskMaster codes - Item ID selected was 1 - 249 } +wInFrame = $1B; {TaskMaster codes - in Frame, but not on anything else } +wInactMenu = $1C; {TaskMaster codes - "selection" of inactive menu item } +wClosedNDA = $001D; {TaskMaster codes - desk accessory closed } +wCalledSysEdit = $001E; {TaskMaster codes - inactive menu item selected } +wInSysWindow = $8000; {TaskMaster codes - hi bit set for system windows } +wDraw = $00; {VarCode - Draw window frame command. } +wHit = $01; {VarCode - Hit test command. } +wCalcRgns = $02; {VarCode - Compute regions command. } +wNew = $03; {VarCode - Initialization command. } +wDispose = $04; {VarCode - Dispose command. } +fHilited = $0001; {WFrame - Window is highlighted. } +fZoomed = $0002; {WFrame - Window is zoomed. } +fAllocated = $0004; {WFrame - Window record was allocated. } +fCtlTie = $0008; {WFrame - Window state tied to controls. } +fInfo = $0010; {WFrame - Window has an information bar. } +fVis = $0020; {WFrame - Window is visible. } +fQContent = $0040; {WFrame - } +fMove = $0080; {WFrame - Window is movable. } +fZoom = $0100; {WFrame - Window is zoomable. } +fFlex = $0200; {WFrame - } +fGrow = $0400; {WFrame - Window has grow box. } +fBScroll = $0800; {WFrame - Window has horizontal scroll bar. } +fRScroll = $1000; {WFrame - Window has vertical scroll bar. } +fAlert = $2000; {WFrame - } +fClose = $4000; {WFrame - Window has a close box. } +fTitle = $8000; {WFrame - Window has a title bar. } +windSize = $145; {WindRec - Size of WindRec. } +wmTaskRecSize = $0046; {WmTaskRec - Size of WmTaskRec. } +wTrackZoom = $001F; { - } +wHitFrame = $0020; { - } +wInControl = $0021; { - } + +TYPE +WmTaskRec = EventRecord ; + + +WmTaskRecPtr = EventRecordPtr ; + +WindColorHndl = ^WindColorPtr; +WindColorPtr = ^WindColor; +WindColor = RECORD + frameColor : Integer; { Color of window frame. } + titleColor : Integer; { Color of title and bar. } + tBarColor : Integer; { Color/pattern of title bar. } + growColor : Integer; { Color of grow box. } + infoColor : Integer; { Color of information bar. } +END; +WindRecPtr = ^WindRec; +WindRec = RECORD + port : GrafPort; { Window's port } + wDefProc : ProcPtr; + wRefCon : Longint; + wContDraw : ProcPtr; + wReserved : Longint; { Space for future expansion } + wStrucRgn : RgnHandle; { Region of frame plus content. } + wContRgn : RgnHandle; { Content region. } + wUpdateRgn : RgnHandle; { Update region. } + wControls : CtlRecHndl; { Window's control list. } + wFrameCtrls : CtlRecHndl; { Window frame's control list. } + wFrame : Integer; +END; +WindowChainPtr = ^WindowChain; +WindowChain = RECORD + wNext : WindowChainPtr; + theWindow : WindRec; +END; +ParamListHndl = ^ParamListPtr; +ParamListPtr = ^ParamList; +ParamList = RECORD + paramLength : Integer; { Parameter to NewWindow. } + wFrameBits : Integer; { Parameter to NewWindow. } + wTitle : Ptr; { Parameter to NewWindow. } + wRefCon : Longint; { Parameter to NewWindow. } + wZoom : Rect; { Parameter to NewWindow. } + wColor : WindColorPtr; { Parameter to NewWindow. } + wYOrigin : Integer; { Parameter to NewWindow. } + wXOrigin : Integer; { Parameter to NewWindow. } + wDataH : Integer; { Parameter to NewWindow. } + wDataW : Integer; { Parameter to NewWindow. } + wMaxH : Integer; { Parameter to NewWindow. } + wMaxW : Integer; { Parameter to NewWindow. } + wScrollVer : Integer; { Parameter to NewWindow. } + wScrollHor : Integer; { Parameter to NewWindow. } + wPageVer : Integer; { Parameter to NewWindow. } + wPageHor : Integer; { Parameter to NewWindow. } + wInfoRefCon : Longint; { Parameter to NewWindow. } + wInfoHeight : Integer; { height of information bar } + wFrameDefProc : LongProcPtr; { Parameter to NewWindow. } + wInfoDefProc : VoidProcPtr; { Parameter to NewWindow. } + wContDefProc : VoidProcPtr; { Parameter to NewWindow. } + wPosition : Rect; { Parameter to NewWindow. } + wPlane : WindowPtr; { Parameter to NewWindow. } + wStorage : WindowChainPtr; { Parameter to NewWindow. } +END; +DeskMessageRecordPtr = ^DeskMessageRecord; +DeskMessageRecord = RECORD + reserved : Longint; + messageType : Integer; + drawType : Integer; +END; +FUNCTION AlertWindow ( alertFlags:Integer; subStrPtr:Ptr; alertStrPtr:Ref) : +Integer ; Tool $0E,$59; +PROCEDURE DrawInfoBar ( theWindowPtr:WindowPtr) ; Tool $0E,$55; +PROCEDURE EndFrameDrawing ; Tool $0E,$5B; +FUNCTION GetWindowMgrGlobals : Longint ; Tool $0E,$58; +PROCEDURE ResizeWindow ( hiddenFlag:Integer; U__rectPtr:Rect; +theWindowPtr:WindowPtr) ; Tool $0E,$5C; +PROCEDURE StartFrameDrawing ( windowPtr:Longint) ; Tool $0E,$5A; +PROCEDURE WindBootInit ; Tool $0E,$01; +PROCEDURE WindStartUp ( userID:Integer) ; Tool $0E,$02; +PROCEDURE WindShutDown ; Tool $0E,$03; +FUNCTION WindVersion : Integer ; Tool $0E,$04; +PROCEDURE WindReset ; Tool $0E,$05; +FUNCTION WindStatus : Boolean ; Tool $0E,$06; +PROCEDURE BeginUpdate ( theWindowPtr:WindowPtr) ; Tool $0E,$1E; +PROCEDURE BringToFront ( theWindowPtr:WindowPtr) ; Tool $0E,$24; +FUNCTION CheckUpdate ( theEventPtr:EventRecordPtr) : Boolean ; Tool $0E,$0A; +PROCEDURE CloseWindow ( theWindowPtr:WindowPtr) ; Tool $0E,$0B; +FUNCTION Desktop ( deskTopOP:Integer; dtParam:Longint) : Ptr ; Tool $0E,$0C; +PROCEDURE DragWindow ( grid:Integer; startX:Integer; startY:Integer; +grace:Integer; boundsRectPtr:RectPtr; theWindowPtr:WindowPtr) ; Tool $0E,$1A; +PROCEDURE EndInfoDrawing ; Tool $0E,$51; +PROCEDURE EndUpdate ( theWindowPtr:WindowPtr) ; Tool $0E,$1F; +FUNCTION FindWindow (VAR theWindowPtr:WindowPtr; pointX:Integer; +pointY:Integer) : Integer ; Tool $0E,$17; +FUNCTION FrontWindow : WindowPtr ; Tool $0E,$15; +FUNCTION GetContentDraw ( theWindowPtr:WindowPtr) : VoidProcPtr ; Tool $0E,$48; +FUNCTION GetContentOrigin ( theWindowPtr:WindowPtr) : Point ; Tool $0E,$3E; +FUNCTION GetContentRgn ( theWindowPtr:WindowPtr) : RgnHandle ; Tool $0E,$2F; +FUNCTION GetDataSize ( theWindowPtr:WindowPtr) : Longint ; Tool $0E,$40; +FUNCTION GetDefProc ( theWindowPtr:WindowPtr) : LongProcPtr ; Tool $0E,$31; +FUNCTION GetFirstWindow : WindowPtr ; Tool $0E,$52; +PROCEDURE GetFrameColor (VAR colorPtr:WindColorPtr; theWindowPtr:WindowPtr) ; +Tool $0E,$10; +FUNCTION GetInfoDraw ( theWindowPtr:WindowPtr) : VoidProcPtr ; Tool $0E,$4A; +FUNCTION GetInfoRefCon ( theWindowPtr:WindowPtr) : Longint ; Tool $0E,$35; +FUNCTION GetMaxGrow ( theWindowPtr:WindowPtr) : Longint ; Tool $0E,$42; +FUNCTION GetNextWindow ( theWindowPtr:WindowPtr) : WindowPtr ; Tool $0E,$2A; +FUNCTION GetPage ( theWindowPtr:WindowPtr) : Longint ; Tool $0E,$46; +PROCEDURE GetRectInfo (VAR infoRectPtr:Rect; theWindowPtr:WindowPtr) ; Tool +$0E,$4F; +FUNCTION GetScroll ( theWindowPtr:WindowPtr) : Longint ; Tool $0E,$44; +FUNCTION GetStructRgn ( theWindowPtr:WindowPtr) : RgnHandle ; Tool $0E,$2E; +FUNCTION GetSysWFlag ( theWindowPtr:WindowPtr) : Boolean ; Tool $0E,$4C; +FUNCTION GetUpdateRgn ( theWindowPtr:WindowPtr) : RgnHandle ; Tool $0E,$30; +FUNCTION GetWControls ( theWindowPtr:WindowPtr) : CtlRecHndl ; Tool $0E,$33; +FUNCTION GetWFrame ( theWindowPtr:WindowPtr) : Integer ; Tool $0E,$2C; +FUNCTION GetWKind ( theWindowPtr:WindowPtr) : Integer ; Tool $0E,$2B; +FUNCTION GetWMgrPort : WindowPtr ; Tool $0E,$20; +FUNCTION GetWRefCon ( theWindowPtr:WindowPtr) : Longint ; Tool $0E,$29; +FUNCTION GetWTitle ( theWindowPtr:WindowPtr) : Ptr ; Tool $0E,$0E; +FUNCTION GetZoomRect ( theWindowPtr:WindowPtr) : RectPtr ; Tool $0E,$37; +FUNCTION GrowWindow ( minWidth:Integer; minHeight:Integer; startX:Integer; +startY:Integer; theWindowPtr:WindowPtr) : Longint ; Tool $0E,$1B; +PROCEDURE HideWindow ( theWindowPtr:WindowPtr) ; Tool $0E,$12; +PROCEDURE HiliteWindow ( fHiliteFlag:Boolean; theWindowPtr:WindowPtr) ; Tool +$0E,$22; +PROCEDURE InvalRect ( badRectPtr:Rect) ; Tool $0E,$3A; +PROCEDURE InvalRgn ( badRgnHandle:RgnHandle) ; Tool $0E,$3B; +PROCEDURE MoveWindow ( newX:Integer; newY:Integer; theWindowPtr:WindowPtr) ; +Tool $0E,$19; +FUNCTION NewWindow ( theParamListPtr:ParamList) : WindowPtr ; Tool $0E,$09; +FUNCTION PinRect ( theXPt:Integer; theYPt:Integer; theRectPtr:Rect) : Point ; +Tool $0E,$21; +PROCEDURE RefreshDesktop ( redrawRect:RectPtr) ; Tool $0E,$39; +PROCEDURE SelectWindow ( theWindowPtr:WindowPtr) ; Tool $0E,$11; +PROCEDURE SendBehind ( behindWindowPtr:WindowPtr; theWindowPtr:WindowPtr) ; +Tool $0E,$14; +PROCEDURE SetContentDraw ( contentDrawPtr:VoidProcPtr; theWindowPtr:WindowPtr) +; Tool $0E,$49; +PROCEDURE SetContentOrigin ( xOrigin:Integer; yOrigin:Integer; +theWindowPtr:WindowPtr) ; Tool $0E,$3F; +PROCEDURE SetContentOrigin2 ( scrollFlag:Integer; xOrigin:Integer; +yOrigin:Integer; theWindowPtr:WindowPtr) ; Tool $0E,$57; +PROCEDURE SetDataSize ( dataWidth:Integer; dataHeight:Integer; +theWindowPtr:WindowPtr) ; Tool $0E,$41; +PROCEDURE SetDefProc ( wDefProcPtr:LongProcPtr; theWindowPtr:WindowPtr) ; Tool +$0E,$32; +PROCEDURE SetFrameColor ( newColorPtr:WindColorPtr; theWindowPtr:WindowPtr) ; +Tool $0E,$0F; +PROCEDURE SetInfoDraw ( infoRecCon:VoidProcPtr; theWindowPtr:WindowPtr) ; Tool +$0E,$16; +PROCEDURE SetInfoRefCon ( infoRefCon:Longint; theWindowPtr:WindowPtr) ; Tool +$0E,$36; +PROCEDURE SetMaxGrow ( maxWidth:Integer; maxHeight:Integer; +theWindowPtr:WindowPtr) ; Tool $0E,$43; +PROCEDURE SetOriginMask ( originMask:Integer; theWindowPtr:WindowPtr) ; Tool +$0E,$34; +PROCEDURE SetPage ( hPage:Integer; vPage:Integer; theWindowPtr:WindowPtr) ; +Tool $0E,$47; +PROCEDURE SetScroll ( hScroll:Integer; vScroll:Integer; theWindowPtr:WindowPtr) +; Tool $0E,$45; +PROCEDURE SetSysWindow ( theWindowPtr:WindowPtr) ; Tool $0E,$4B; +PROCEDURE SetWFrame ( wFrame:Integer; theWindowPtr:WindowPtr) ; Tool $0E,$2D; +FUNCTION SetWindowIcons ( newFontHandle:FontHndl) : FontHndl ; Tool $0E,$4E; +PROCEDURE SetWRefCon ( wRefCon:Longint; theWindowPtr:WindowPtr) ; Tool +$0E,$28; +PROCEDURE SetWTitle ( title:Str255; theWindowPtr:WindowPtr) ; Tool $0E,$0D; +PROCEDURE SetZoomRect ( wZoomSizePtr:Rect; theWindowPtr:WindowPtr) ; Tool +$0E,$38; +PROCEDURE ShowHide ( showFlag:Boolean; theWindowPtr:WindowPtr) ; Tool $0E,$23; +PROCEDURE ShowWindow ( theWindowPtr:WindowPtr) ; Tool $0E,$13; +PROCEDURE SizeWindow ( newWidth:Integer; newHeight:Integer; +theWindowPtr:WindowPtr) ; Tool $0E,$1C; +PROCEDURE StartDrawing ( theWindowPtr:WindowPtr) ; Tool $0E,$4D; +PROCEDURE StartInfoDrawing (VAR infoRectPtr:Rect; theWindowPtr:WindowPtr) ; +Tool $0E,$50; +FUNCTION TaskMaster ( taskMask:Integer; taskRecPtr:WmTaskRec) : Integer ; Tool +$0E,$1D; +FUNCTION TrackGoAway ( startX:Integer; startY:Integer; theWindowPtr:WindowPtr) +: Boolean ; Tool $0E,$18; +FUNCTION TrackZoom ( startX:Integer; startY:Integer; theWindowPtr:WindowPtr) : +Boolean ; Tool $0E,$26; +PROCEDURE ValidRect ( goodRectPtr:Rect) ; Tool $0E,$3C; +PROCEDURE ValidRgn ( goodRgnHandle:RgnHandle) ; Tool $0E,$3D; +FUNCTION WindDragRect ( actionProcPtr:VoidProcPtr; dragPatternPtr:Pattern; +startX:Integer; startY:Integer; dragRectPtr:Rect; limitRectPtr:Rect; +slopRectPtr:Rect; dragFlag:Integer) : Longint ; Tool $0E,$53; +PROCEDURE WindNewRes ; Tool $0E,$25; +FUNCTION WindowGlobal ( WindowGlobalMask:Integer) : Integer ; Tool $0E,$56; +PROCEDURE ZoomWindow ( theWindowPtr:WindowPtr) ; Tool $0E,$27; +FUNCTION TaskMasterDA ( eventMask:Integer; taskRecPtr:Ptr) : Integer ; Tool +$0E,$5F; +FUNCTION CompileText ( subType:Integer; subStringsPtr:Ptr; srcStringPtr:Ptr; +srcSize:Integer) : Handle ; Tool $0E,$60; +FUNCTION NewWindow2 ( titlePtr:StringPtr; refCon:Longint; +contentDrawPtr:ProcPtr; defProcPtr:ProcPtr; paramTableDesc:RefDescriptor; +paramTableRef:Ref; resourceType:Integer) : WindowPtr ; Tool $0E,$61; +FUNCTION ErrorWindow ( subType:Integer; subStringPtr:Ptr; errNum:Integer) : +Integer ; Tool $0E,$62; +IMPLEMENTATION +END. diff --git a/prodos16.h b/prodos16.h new file mode 100644 index 0000000..a5857e5 --- /dev/null +++ b/prodos16.h @@ -0,0 +1,144 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * The ProDOS 16 tool calls + */ + +typedef struct { + uint16_t call; + const char *name; +} Prodos16; + +static Prodos16 prodos16[] = { + {0x0001, "CREATE"}, + {0x0002, "DESTROY"}, + {0x0004, "CHANGE_PATH"}, + {0x0005, "SET_FILE_INFO"}, + {0x0006, "GET_FILE_INFO"}, + {0x0008, "VOLUME"}, + {0x0009, "SET_PREFIX"}, + {0x000a, "GET_PREFIX"}, + {0x000b, "CLEAR_BACKUP_BIT"}, + {0x0010, "OPEN"}, + {0x0011, "NEWLINE"}, + {0x0012, "READ"}, + {0x0013, "WRITE"}, + {0x0014, "CLOSE"}, + {0x0015, "FLUSH"}, + {0x0016, "SET_MARK"}, + {0x0017, "GET_MARK"}, + {0x0018, "SET_EOF"}, + {0x0019, "GET_EOF"}, + {0x001a, "SET_LEVEL"}, + {0x001b, "GET_LEVEL"}, + {0x001c, "GET_DIR_ENTRY"}, + {0x0020, "GET_DEV_NUM"}, + {0x0021, "GET_LAST_DEV"}, + {0x0022, "READ_BLOCK"}, + {0x0023, "WRITE_BLOCK"}, + {0x0024, "FORMAT"}, + {0x0025, "ERASE_DISK"}, + {0x0027, "GET_NAME"}, + {0x0028, "GET_BOOT_VOL"}, + {0x0029, "QUIT"}, + {0x002a, "GET_VERSION"}, + {0x002c, "D_INFO"}, + {0x0031, "ALLOC_INTERRUPT"}, + {0x0032, "DEALLOCATE_INTERRUPT"}, + {0x0101, "Get_LInfo"}, + {0x0102, "Set_LInfo"}, + {0x0103, "Get_Lang"}, + {0x0104, "Set_Lang"}, + {0x0105, "Error"}, + {0x0106, "Set_Variable"}, + {0x0107, "Version"}, + {0x0108, "Read_Indexed"}, + {0x0109, "Init_Wildcard"}, + {0x010a, "Next_Wildcard"}, + {0x010b, "Read_Variable"}, + {0x010c, "ChangeVector"}, + {0x010d, "Execute"}, + {0x010e, "FastFile"}, + {0x010f, "Direction"}, + {0x0110, "Redirect"}, + {0x0113, "Stop"}, + {0x0114, "ExpandDevices"}, + {0x0115, "UnsetVariable"}, + {0x0116, "Export"}, + {0x0117, "PopVariables"}, + {0x0118, "PushVariables"}, + {0x0119, "SetStopFlag"}, + {0x011a, "ConsoleOut"}, + {0x011b, "SetIODevices"}, + {0x011c, "GetIODevices"}, + {0x011d, "GetCommand"}, + {0x2001, "Create"}, + {0x2002, "Destroy"}, + {0x2003, "OSShutdown"}, + {0x2004, "ChangePath"}, + {0x2005, "SetFileInfo"}, + {0x2006, "GetFileInfo"}, + {0x2007, "JudgeName"}, + {0x2008, "Volume"}, + {0x2009, "SetPrefix"}, + {0x200a, "GetPrefix"}, + {0x200b, "ClearBackup"}, + {0x200c, "SetSysPrefs"}, + {0x200d, "Null"}, + {0x200e, "ExpandPath"}, + {0x200f, "GetSysPrefs"}, + {0x2010, "Open"}, + {0x2011, "NewLine"}, + {0x2012, "Read"}, + {0x2013, "Write"}, + {0x2014, "Close"}, + {0x2015, "Flush"}, + {0x2016, "SetMark"}, + {0x2017, "GetMark"}, + {0x2018, "SetEOF"}, + {0x2019, "GetEOF"}, + {0x201a, "SetLevel"}, + {0x201b, "GetLevel"}, + {0x201c, "GetDirEntry"}, + {0x201d, "BeginSession"}, + {0x201e, "EndSession"}, + {0x201f, "SessionStatus"}, + {0x2020, "GetDevNumber"}, + {0x2024, "Format"}, + {0x2025, "EraseDisk"}, + {0x2026, "ResetCache"}, + {0x2027, "GetName"}, + {0x2028, "GetBoolVol"}, + {0x2029, "Quit"}, + {0x202a, "GetVersion"}, + {0x202b, "GetFSTInfo"}, + {0x202c, "DInfo"}, + {0x202d, "DStatus"}, + {0x202e, "DControl"}, + {0x202f, "DRead"}, + {0x2030, "DWrite"}, + {0x2031, "BindInt"}, + {0x2032, "UnbindInt"}, + {0x2033, "FSTSpecific"}, + {0x2034, "AddNotifyProc"}, + {0x2035, "DelNotifyProc"}, + {0x2036, "DRename"}, + {0x2037, "GetStdRefNum"}, + {0x2038, "GetRefNum"}, + {0x2039, "GetRefInfo"}, + {0x203a, "SetStdRefNum"} +}; + +#define numProdos16 (sizeof(prodos16) / sizeof(prodos16[0])) + +static const char *prodos16Lookup(uint16_t call) { + for (int i = 0; i < numProdos16; i++) { + if (prodos16[i].call >= call) { + if (prodos16[i].call == call) + return prodos16[i].name; + break; + } + } + return NULL; +} diff --git a/prodos8.h b/prodos8.h new file mode 100644 index 0000000..09d5514 --- /dev/null +++ b/prodos8.h @@ -0,0 +1,56 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * Defines the ProDOS 8 tool calls + */ + +typedef struct { + uint16_t call; + const char *name; +} Prodos8; + +static Prodos8 prodos8[] = { + {0x0040, "ALLOC_INTERRUPT"}, + {0x0041, "DEALLOC_INTERRUPT"}, + {0x0042, "AppleTalk"}, + {0x0043, "SpecialOpenFork"}, + {0x0044, "ByteRangeLock"}, + {0x0065, "QUIT"}, + {0x0080, "READ_BLOCK"}, + {0x0081, "WRITE_BLOCK"}, + {0x0082, "GET_TIME"}, + {0x00c0, "CREATE"}, + {0x00c1, "DESTROY"}, + {0x00c2, "RENAME"}, + {0x00c3, "SetFileInfo"}, + {0x00c4, "GetFileInfo"}, + {0x00c5, "ONLINE"}, + {0x00c6, "SET_PREFIX"}, + {0x00c7, "GET_PREFIX"}, + {0x00c8, "OPEN"}, + {0x00c9, "NEWLINE"}, + {0x00ca, "READ"}, + {0x00cb, "WRITE"}, + {0x00cc, "CLOSE"}, + {0x00cd, "FLUSH"}, + {0x00ce, "SET_MARK"}, + {0x00cf, "GET_MARK"}, + {0x00d0, "SET_EOF"}, + {0x00d1, "GET_EOF"}, + {0x00d2, "SET_BUF"}, + {0x00d3, "GET_BUF"} +}; + +#define numProdos8 (sizeof(prodos8) / sizeof(prodos8[0])) + +static const char *prodos8Lookup(uint16_t call) { + for (int i = 0; i < numProdos8; i++) { + if (prodos8[i].call >= call) { + if (prodos8[i].call == call) + return prodos8[i].name; + break; + } + } + return NULL; +} diff --git a/regs.c b/regs.c new file mode 100644 index 0000000..48e8309 --- /dev/null +++ b/regs.c @@ -0,0 +1,120 @@ +/** + * @copyright 2018 Sean Kasun + * The main disassembler + */ + +#include +#include "handle.h" +#include "scan.h" +#include "disasm.h" + +const char *argp_program_version = "regs 0.1"; +const char *argp_program_bug_address = "sean@seancode.com"; +static char doc[] = "Disassemble Apple IIgs software"; +static char args_doc[] = "FILE or MAP"; +static struct argp_option options[] = { + {"org", 'o', "ADDRESS", 0, + "Starting address of the binary file, in hex"}, + {"m", 'm', 0, OPTION_ARG_OPTIONAL, + "Start with 8-bit accumulator"}, + {"x", 'x', 0, OPTION_ARG_OPTIONAL, + "Start with 8-bit indices"}, + {"e", 'e', 0, OPTION_ARG_OPTIONAL, + "Start in emulation mode"}, + { 0 } +}; + +struct arguments { + char *filename; + uint32_t org; + MapFlags flags; +}; + +static inline uint32_t parseNum(const char *s) { + uint32_t res = 0; + while (isspace(*s)) { + s++; + } + while (isxdigit(*s)) { + res <<= 4; + if (*s >= '0' && *s <= '9') { + res |= *s - '0'; + } else if (*s >= 'a' && *s <= 'f') { + res |= *s - 'a' + 10; + } else if (*s >= 'A' && *s <= 'F') { + res |= *s - 'A' + 10; + } + s++; + } + return res; +} + +static error_t parse_opt(int key, char *arg, struct argp_state *state) { + struct arguments *arguments = state->input; + switch (key) { + case 'o': + if (arg) { + arguments->org = parseNum(arg); + } + break; + case 'm': + if (arg) { + arguments->flags |= IsM8; + } + break; + case 'x': + if (arg) { + arguments->flags |= IsX8; + } + break; + case 'e': + if (arg) { + arguments->flags |= IsEmu; + } + break; + case ARGP_KEY_ARG: + if (state->arg_num >= 1) { + argp_usage(state); + } + arguments->filename = arg; + break; + case ARGP_KEY_END: + if (state->arg_num < 1) { + argp_usage(state); + } + break; + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + +static struct argp argp = { options, parse_opt, args_doc, doc }; + +int main(int argc, char **argv) { + struct arguments arguments; + arguments.filename = ""; + arguments.org = 0x300; + arguments.flags = IsOpcode; + argp_parse(&argp, argc, argv, 0, 0, &arguments); + + // load the map, if it exists + Map *map = loadMap(arguments.filename, arguments.org, arguments.flags); + + // load the file + FILE *f = fopen(map->filename, "rb"); + if (!f) { + fprintf(stderr, "Failed to open '%s'\n", map->filename); + return -1; + } + fseek(f, 0, SEEK_END); + size_t len = ftell(f); + fseek(f, 0, SEEK_SET); + uint8_t *data = malloc(len); + fread(data, len, 1, f); + fclose(f); + + scan(data, len, map); + disassemble(data, len, map); + free(data); +} diff --git a/scan.c b/scan.c new file mode 100644 index 0000000..77c44eb --- /dev/null +++ b/scan.c @@ -0,0 +1,185 @@ +/** + * @copyright 2018 Sean Kasun + * The tracing scanner. + */ +#include "scan.h" +#include "65816.h" +#include "handle.h" + +typedef struct { + uint32_t address; + MapFlags flags; +} Scan; + +typedef struct { + uint32_t max; + uint32_t num; + Scan *values; +} List; + +static void initList(List *list) { + list->max = 1024; + list->num = 0; + list->values = malloc(sizeof(Scan) * list->max); +} + +static void freeList(List *list) { + free(list->values); +} + +static void appendList(List *list, uint32_t address, MapFlags flags) { + list->values[list->num].address = address; + list->values[list->num].flags = flags; + list->num++; + if (list->num == list->max) { + list->max *= 1.6; + list->values = realloc(list->values, sizeof(Scan) * list->max); + } +} + +static uint32_t fillMem(uint32_t address, int len, MapFlags flags, Map *map) { + for (int i = 0; i < len; i++) { + map->mem[address++ - map->minMemory] = flags; + } + return address; +} + +void scan(uint8_t *data, size_t len, Map *map) { + List toScan; + initList(&toScan); + map->maxMemory = map->minMemory + len; + + map->mem = calloc(len, sizeof(MapFlags)); + + for (Rule *rule = map->rules; rule != NULL; rule = rule->next) { + appendList(&toScan, rule->address, rule->flags); + } + + while (toScan.num > 0) { + toScan.num--; + MapFlags flags = toScan.values[toScan.num].flags; + uint32_t address = toScan.values[toScan.num].address; + + while (address < map->maxMemory) { + uint8_t *ptr = data + address - map->minMemory; + + uint8_t opcode = *ptr++; + if (map->mem[address - map->minMemory] & IsOperand) { + // we jumped into the middle of an opcode.. go backward to clear it + uint32_t offset = (address - map->minMemory) - 1; + while (offset > 0 && (map->mem[offset] & IsOperand)) { + map->mem[offset--] = IsData; + } + map->mem[offset] = IsData; // overwrite the opcode too. + } + + Address mode = opcodes[opcode].address; + OpType type = opcodes[opcode].type; + if (address + addressSizes[mode] > map->maxMemory) { + mode = DB; + } + + uint16_t width = addressSizes[mode]; + if (mode == IMMM && (flags & (IsEmu | IsM8))) { + width--; + } + if (mode == IMMX && (flags & (IsEmu | IsX8))) { + width--; + } + + if (mode == DB) { + map->mem[address++ - map->minMemory] = IsData; + } else { + map->mem[address++ - map->minMemory] = IsOpcode | + (flags & (IsEmu | IsX8 | IsM8)); + address = fillMem(address, width - 1, IsOperand, map); + } + + uint32_t val = 0; + int8_t delta; + int16_t delta16; + + switch (mode) { + case IMM: + val = *ptr++; + if (opcode == 0xe2) { + flags |= val; + } else if (opcode == 0xc2) { + flags &= ~val; + } + break; + case IMMM: + if (flags & (IsEmu | IsM8)) { + val = *ptr++; + } else { + val = r16(ptr); ptr += 2; + } + break; + case IMMX: + if (flags & (IsEmu | IsX8)) { + val = *ptr++; + } else { + val = r16(ptr); ptr += 2; + } + break; + case IMMS: + val = r16(ptr); ptr += 2; + break; + case ABS: + val = r16(ptr); ptr += 2; + val |= address & 0xff0000; + break; + case ABL: + val = r24(ptr); ptr += 3; + break; + case REL: + delta = *ptr++; + val = delta + address; + break; + case RELL: + delta16 = r16(ptr); ptr += 2; + val = delta16 + address; + break; + default: + break; + } + + if (opcode == 0x18 && *ptr == 0xfb) { // clc xce + flags &= ~IsEmu; // 16-bit + } + if (opcode == 0x38 && *ptr == 0xfb) { // sec xce + flags |= IsEmu; // 8-bit + } + + if (opcode == 0x20) { // jsr + if ((val & 0xffff) == 0xc50d || (val & 0xffff) == 0xc70d) { // disk + address = fillMem(address, 3, IsData, map); // db, dw + if (*ptr++ >= 0x40) { + address = fillMem(address, 2, IsData, map); // dw + } + } + if ((val & 0xffff) == 0xbf00) { // prodos8 + address = fillMem(address, 3, IsData, map); // db, dw + } + } + if (opcode == 0x22) { // jsl + if (val == 0xe100a8) { + address = fillMem(address, 6, IsData, map); // dw, dd + } + } + + if (type == BRANCH || (type == CALL && mode != AIX) || + (type == JUMP && mode != IND && mode != AIX)) { + if (val >= map->minMemory && val < map->maxMemory && + !(map->mem[val - map->minMemory] & IsOpcode)) { + appendList(&toScan, val, flags); + } + } + if (type == BREAK || type == RETURN || type == JUMP) { + break; + } + } + } + + freeList(&toScan); +} diff --git a/scan.h b/scan.h new file mode 100644 index 0000000..8d1d92b --- /dev/null +++ b/scan.h @@ -0,0 +1,11 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * The tracing scanner. + */ + +#include "map.h" +#include + +extern void scan(uint8_t *data, size_t len, Map *map); diff --git a/smartport.h b/smartport.h new file mode 100644 index 0000000..49ed455 --- /dev/null +++ b/smartport.h @@ -0,0 +1,47 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * Defines the SmartPort tool calls + */ + +typedef struct { + uint8_t call; + const char *name; +} SmartPort; + +static SmartPort smartport[] = { + {0x00, "Status"}, + {0x01, "Read"}, + {0x02, "Write"}, + {0x03, "Format"}, + {0x04, "Control"}, + {0x05, "Init"}, + {0x06, "Open"}, + {0x07, "Close"}, + {0x08, "Read"}, + {0x09, "Write"}, + {0x40, "Status"}, + {0x41, "Read"}, + {0x42, "Write"}, + {0x43, "Format"}, + {0x44, "Control"}, + {0x45, "Init"}, + {0x46, "Open"}, + {0x47, "Close"}, + {0x48, "Read"}, + {0x49, "Write"} +}; + +#define numSmartPort (sizeof(smartport) / sizeof(smartport[0])) + +static const char *smartportLookup(uint8_t call) { + for (int i = 0; i < numSmartPort; i++) { + if (smartport[i].call >= call) { + if (smartport[i].call == call) + return smartport[i].name; + break; + } + } + return NULL; +} diff --git a/tools.h b/tools.h new file mode 100644 index 0000000..7395d76 --- /dev/null +++ b/tools.h @@ -0,0 +1,1290 @@ +#pragma once + +/** + * @copyright 2018 Sean Kasun + * Defines the IIgs Tool calls + */ + +typedef struct { + uint16_t id; + const char *name; +} Tool; + +static Tool tools[] = { + {0x0101, "TLBootInit"}, + {0x0102, "MMBootInit"}, + {0x0103, "MTBootInit"}, + {0x0104, "QDBootInit"}, + {0x0105, "DeskBootInit"}, + {0x0106, "EMBootInit"}, + {0x0107, "SchBootInit"}, + {0x0108, "SoundBootInit"}, + {0x0109, "ADBBootInit"}, + {0x010a, "SANEBootInit"}, + {0x010b, "IMBootInit"}, + {0x010c, "TextBootInit"}, + {0x010e, "WindBootInit"}, + {0x010f, "MenuBootInit"}, + {0x0110, "CtlBootInit"}, + {0x0111, "LoaderBootInit"}, + {0x0112, "QDAuxBootInit"}, + {0x0113, "PMBootInit"}, + {0x0114, "LEBootInit"}, + {0x0115, "DialogBootInit"}, + {0x0116, "ScrapBootInit"}, + {0x0117, "SFBootInit"}, + {0x0118, "DUBootInit"}, + {0x0119, "NSBootInit"}, + {0x011a, "SeqBootInit"}, + {0x011b, "FMBootInit"}, + {0x011c, "ListBootInit"}, + {0x011d, "ACEBootInit"}, + {0x011e, "ResourceBootInit"}, + {0x0120, "MIDIBootInit"}, + {0x0121, "VDBootInit"}, + {0x0122, "TEBootInit"}, + {0x0123, "MSBootInit"}, + {0x0125, "AnimBootInit"}, + {0x0201, "TLStartUp"}, + {0x0202, "MMStartUp"}, + {0x0203, "MTStartUp"}, + {0x0204, "QDStartUp"}, + {0x0205, "DeskStartUp"}, + {0x0206, "EMStartUp"}, + {0x0207, "SchStartUp"}, + {0x0208, "SoundStartUp"}, + {0x0209, "ADBStartUp"}, + {0x020a, "SANEStartUp"}, + {0x020b, "IMStartUp"}, + {0x020c, "TextStartUp"}, + {0x020e, "WindStartUp"}, + {0x020f, "MenuStartUp"}, + {0x0210, "CtlStartUp"}, + {0x0211, "LoaderStartUp"}, + {0x0212, "QDAuxStartUp"}, + {0x0213, "PMStartUp"}, + {0x0214, "LEStartUp"}, + {0x0215, "DialogStartUp"}, + {0x0216, "ScrapStartUp"}, + {0x0217, "SFStartUp"}, + {0x0218, "DUStartUp"}, + {0x0219, "NSStartUp"}, + {0x021a, "SeqStartUp"}, + {0x021b, "FMStartUp"}, + {0x021c, "ListStartUp"}, + {0x021d, "ACEStartUp"}, + {0x021e, "ResourceStartUp"}, + {0x0220, "MIDIStartUp"}, + {0x0221, "VDStartUp"}, + {0x0222, "TEStartUp"}, + {0x0223, "MSStartUp"}, + {0x0225, "AnimStartUp"}, + {0x0301, "TLShutDown"}, + {0x0302, "MMShutDown"}, + {0x0303, "MTShutDown"}, + {0x0304, "QDShutDown"}, + {0x0305, "DeskShutDown"}, + {0x0306, "EMShutDown"}, + {0x0307, "SchShutDown"}, + {0x0308, "SoundShutDown"}, + {0x0309, "ADBShutDown"}, + {0x030a, "SANEShutDown"}, + {0x030b, "IMShutDown"}, + {0x030c, "TextShutDown"}, + {0x030e, "WindShutDown"}, + {0x030f, "MenuShutDown"}, + {0x0310, "CtlShutDown"}, + {0x0311, "LoaderShutDown"}, + {0x0312, "QDAuxShutDown"}, + {0x0313, "PMShutDown"}, + {0x0314, "LEShutDown"}, + {0x0315, "DialogShutDown"}, + {0x0316, "ScrapShutDown"}, + {0x0317, "SFShutDown"}, + {0x0318, "DUShutDown"}, + {0x0319, "NSShutDown"}, + {0x031a, "SeqShutDown"}, + {0x031b, "FMShutDown"}, + {0x031c, "ListShutDown"}, + {0x031d, "ACEShutDown"}, + {0x031e, "ResourceShutDown"}, + {0x0320, "MIDIShutDown"}, + {0x0321, "VDShutDown"}, + {0x0322, "TEShutDown"}, + {0x0323, "MSShutDown"}, + {0x0325, "AnimShutDown"}, + {0x0401, "TLVersion"}, + {0x0402, "MMVersion"}, + {0x0403, "MTVersion"}, + {0x0404, "QDVersion"}, + {0x0405, "DeskVersion"}, + {0x0406, "EMVersion"}, + {0x0407, "SchVersion"}, + {0x0408, "SoundVersion"}, + {0x0409, "ADBVersion"}, + {0x040a, "SANEVersion"}, + {0x040b, "IMVersion"}, + {0x040c, "TextVersion"}, + {0x040e, "WindVersion"}, + {0x040f, "MenuVersion"}, + {0x0410, "CtlVersion"}, + {0x0411, "LoaderVersion"}, + {0x0412, "QDAuxVersion"}, + {0x0413, "PMVersion"}, + {0x0414, "LEVersion"}, + {0x0415, "DialogVersion"}, + {0x0416, "ScrapVersion"}, + {0x0417, "SFVersion"}, + {0x0418, "DUVersion"}, + {0x0419, "NSVersion"}, + {0x041a, "SeqVersion"}, + {0x041b, "FMVersion"}, + {0x041c, "ListVersion"}, + {0x041d, "ACEVersion"}, + {0x041e, "ResourceVersion"}, + {0x0420, "MIDIVersion"}, + {0x0421, "VDVersion"}, + {0x0422, "TEVersion"}, + {0x0423, "MSVersion"}, + {0x0425, "AnimVersion"}, + {0x0501, "TLReset"}, + {0x0502, "MMReset"}, + {0x0503, "MTReset"}, + {0x0504, "QDReset"}, + {0x0505, "DeskReset"}, + {0x0506, "EMReset"}, + {0x0507, "SchReset"}, + {0x0508, "SoundReset"}, + {0x0509, "ADBReset"}, + {0x050a, "SANEReset"}, + {0x050b, "IMReset"}, + {0x050c, "TextReset"}, + {0x050e, "WindReset"}, + {0x050f, "MenuReset"}, + {0x0510, "CtlReset"}, + {0x0511, "LoaderReset"}, + {0x0512, "QDAuxReset"}, + {0x0513, "PMReset"}, + {0x0514, "LEReset"}, + {0x0515, "DialogReset"}, + {0x0516, "ScrapReset"}, + {0x0517, "SFReset"}, + {0x0518, "DUReset"}, + {0x0519, "NSReset"}, + {0x051a, "SeqReset"}, + {0x051b, "FMReset"}, + {0x051c, "ListReset"}, + {0x051d, "ACEReset"}, + {0x051e, "ResourceReset"}, + {0x0520, "MIDIReset"}, + {0x0521, "VDReset"}, + {0x0522, "TEReset"}, + {0x0523, "MSReset"}, + {0x0525, "AnimReset"}, + {0x0601, "TLStatus"}, + {0x0602, "MMStatus"}, + {0x0603, "MTStatus"}, + {0x0604, "QDStatus"}, + {0x0605, "DeskStatus"}, + {0x0606, "EMStatus"}, + {0x0607, "SchStatus"}, + {0x0608, "SoundStatus"}, + {0x0609, "ADBStatus"}, + {0x060a, "SANEStatus"}, + {0x060b, "IMStatus"}, + {0x060c, "TextStatus"}, + {0x060e, "WindStatus"}, + {0x060f, "MenuStatus"}, + {0x0610, "CtlStatus"}, + {0x0611, "LoaderStatus"}, + {0x0612, "QDAuxStatus"}, + {0x0613, "PMStatus"}, + {0x0614, "LEStatus"}, + {0x0615, "DialogStatus"}, + {0x0616, "ScrapStatus"}, + {0x0617, "SFStatus"}, + {0x0618, "DUStatus"}, + {0x0619, "NSStatus"}, + {0x061a, "SeqStatus"}, + {0x061b, "FMStatus"}, + {0x061c, "ListStatus"}, + {0x061d, "ACEStatus"}, + {0x061e, "ResourceStatus"}, + {0x0620, "MIDIStatus"}, + {0x0621, "VDStatus"}, + {0x0622, "TEStatus"}, + {0x0623, "MSStatus"}, + {0x0625, "AnimStatus"}, + {0x071d, "ACEInfo"}, + {0x0804, "AddPt"}, + {0x0825, "AnimIdleDebug"}, + {0x0901, "GetTSPtr"}, + {0x0902, "NewHandle"}, + {0x0903, "WriteBRam"}, + {0x0904, "GetAddress"}, + {0x0905, "SaveScrn"}, + {0x0906, "DoWindows"}, + {0x0907, "SchAddTask"}, + {0x0908, "WriteRamBlock"}, + {0x0909, "SendInfo"}, + {0x090a, "SANEFP816"}, + {0x090b, "Multiply"}, + {0x090c, "SetInGlobals"}, + {0x090e, "NewWindow"}, + {0x090f, "MenuKey"}, + {0x0910, "NewControl"}, + {0x0911, "InitialLoad"}, + {0x0912, "CopyPixels"}, + {0x0913, "PrDefault"}, + {0x0914, "LENew"}, + {0x0915, "ErrorSound"}, + {0x0916, "UnloadScrap"}, + {0x0917, "SFGetFile"}, + {0x0919, "AllocGen"}, + {0x091a, "SetIncr"}, + {0x091b, "CountFamilies"}, + {0x091c, "CreateList"}, + {0x091d, "ACECompress"}, + {0x091e, "CreateResourceFile"}, + {0x0920, "MIDIControl"}, + {0x0921, "VDInStatus"}, + {0x0922, "TENew"}, + {0x0923, "SetBasicChan"}, + {0x0925, "StartScene"}, + {0x0a01, "SetTSPtr"}, + {0x0a02, "ReAllocHandle"}, + {0x0a03, "ReadBRam"}, + {0x0a04, "GrafOn"}, + {0x0a05, "RestScrn"}, + {0x0a06, "GetNextEvent"}, + {0x0a07, "SchFlush"}, + {0x0a08, "ReadRamBlock"}, + {0x0a09, "ReadKeyMicroData"}, + {0x0a0a, "SANEDecStr816"}, + {0x0a0b, "SDivide"}, + {0x0a0c, "SetOutGlobals"}, + {0x0a0e, "CheckUpdate"}, + {0x0a0f, "GetMenuBar"}, + {0x0a10, "DisposeControl"}, + {0x0a11, "Restart"}, + {0x0a12, "WaitCursor"}, + {0x0a13, "PrValidate"}, + {0x0a14, "LEDispose"}, + {0x0a15, "NewModalDialog"}, + {0x0a16, "LoadScrap"}, + {0x0a17, "SFPutFile"}, + {0x0a19, "DeAlocGen"}, + {0x0a1a, "ClearIncr"}, + {0x0a1b, "FindFamily"}, + {0x0a1c, "SortList"}, + {0x0a1d, "ACEExpand"}, + {0x0a1e, "OpenResourceFile"}, + {0x0a20, "MIDIDevice"}, + {0x0a21, "VDInSetStd"}, + {0x0a22, "TEKill"}, + {0x0a23, "SetMIDIMode"}, + {0x0a25, "StopScene"}, + {0x0b01, "GetFuncPtr"}, + {0x0b02, "RestoreHandle"}, + {0x0b03, "WriteBParam"}, + {0x0b04, "GrafOff"}, + {0x0b05, "SaveAll"}, + {0x0b06, "EventAvail"}, + {0x0b08, "GetTableAddress"}, + {0x0b09, "ReadKeyMicroMemory"}, + {0x0b0a, "SANEElems816"}, + {0x0b0b, "UDivide"}, + {0x0b0c, "SetErrGlobals"}, + {0x0b0e, "CloseWindow"}, + {0x0b0f, "MenuRefresh"}, + {0x0b10, "KillControls"}, + {0x0b11, "LoadSegNum"}, + {0x0b12, "DrawIcon"}, + {0x0b13, "PrStlDialog"}, + {0x0b14, "LESetText"}, + {0x0b15, "NewModelessDialog"}, + {0x0b16, "ZeroScrap"}, + {0x0b17, "SFPGetFile"}, + {0x0b19, "NoteOn"}, + {0x0b1a, "GetTimer"}, + {0x0b1b, "GetFamInfo"}, + {0x0b1c, "NextMember"}, + {0x0b1d, "ACECompBegin"}, + {0x0b1e, "CloseResourceFile"}, + {0x0b20, "MIDIClock"}, + {0x0b21, "VDInGetStd"}, + {0x0b22, "TESetText"}, + {0x0b23, "PlayNote"}, + {0x0b25, "StartFrameTimer"}, + {0x0c01, "GetWAP"}, + {0x0c02, "AddToOOMQueue"}, + {0x0c03, "ReadBParam"}, + {0x0c04, "GetStandardSCB"}, + {0x0c05, "RestAll"}, + {0x0c06, "GetMouse"}, + {0x0c08, "GetSoundVolume"}, + {0x0c09, "Resync"}, + {0x0c0b, "LongMul"}, + {0x0c0c, "GetInGlobals"}, + {0x0c0e, "Destkop"}, + {0x0c0f, "FlashMenuBar"}, + {0x0c10, "SetCtlTitle"}, + {0x0c11, "UnloadSegNum"}, + {0x0c12, "SpecialRect"}, + {0x0c13, "PrJobDialog"}, + {0x0c14, "LEIdle"}, + {0x0c15, "CloseDialog"}, + {0x0c16, "PutScrap"}, + {0x0c17, "SFPPutFile"}, + {0x0c19, "NoteOff"}, + {0x0c1a, "GetLoc"}, + {0x0c1b, "GetFamNum"}, + {0x0c1c, "DrawMember"}, + {0x0c1d, "ACEExpBegin"}, + {0x0c1e, "AddResource"}, + {0x0c20, "MIDIInfo"}, + {0x0c21, "VDInConvAdj"}, + {0x0c22, "TEGetText"}, + {0x0c23, "StopNote"}, + {0x0c25, "StopFrameTimer"}, + {0x0d01, "SetWAP"}, + {0x0d02, "RemoveFromOOMQueue"}, + {0x0d03, "ReadTimeHex"}, + {0x0d04, "InitColorTable"}, + {0x0d06, "Button"}, + {0x0d08, "SetSoundVolume"}, + {0x0d09, "AsyncADBReceive"}, + {0x0d0b, "LongDivide"}, + {0x0d0c, "GetOutGlobals"}, + {0x0d0e, "SetWTitle"}, + {0x0d0f, "InsertMenu"}, + {0x0d10, "GetCtlTitle"}, + {0x0d11, "LoadSegNum"}, + {0x0d12, "SeedFill"}, + {0x0d13, "PrPixelMap"}, + {0x0d14, "LEClick"}, + {0x0d15, "NewDItem"}, + {0x0d16, "GetScrap"}, + {0x0d17, "SFAllCaps"}, + {0x0d19, "AllNotesOff"}, + {0x0d1a, "SeqAllNotesOff"}, + {0x0d1b, "AddFamily"}, + {0x0d1c, "SelectMember"}, + {0x0d1d, "GetACEExpState"}, + {0x0d1e, "UpdateResourceFile"}, + {0x0d20, "MIDIReadPacket"}, + {0x0d21, "VDKeyControl"}, + {0x0d22, "TEGetTextInfo"}, + {0x0d23, "KillAllNotes"}, + {0x0d25, "SetBackgndPort"}, + {0x0e01, "LoadTools"}, + {0x0e03, "WriteTimeHex"}, + {0x0e04, "SetColorTable"}, + {0x0e05, "InstallNDA"}, + {0x0e06, "StillDown"}, + {0x0e08, "FFStartSound"}, + {0x0e09, "SyncADBReceive"}, + {0x0e0b, "FixRatio"}, + {0x0e0c, "GetErrGlobals"}, + {0x0e0e, "GetWTitle"}, + {0x0e0f, "DeleteMenu"}, + {0x0e10, "HideControl"}, + {0x0e11, "UnloadSeg"}, + {0x0e12, "CalcMask"}, + {0x0e13, "PrOpenDoc"}, + {0x0e14, "LESetSelect"}, + {0x0e15, "RemoveDItem"}, + {0x0e16, "GetScrapHandle"}, + {0x0e17, "SFGetFile2"}, + {0x0e19, "NSSetUpdateRate"}, + {0x0e1a, "SetTrkInfo"}, + {0x0e1b, "InstallFont"}, + {0x0e1c, "GetListDefProc"}, + {0x0e1d, "SetACEExpState"}, + {0x0e1e, "LoadResource"}, + {0x0e20, "MIDIWritePacket"}, + {0x0e21, "VDKeyStatus"}, + {0x0e22, "TEIdle"}, + {0x0e23, "SetRecTrack"}, + {0x0e25, "RefreshBack"}, + {0x0f01, "LoadOneTool"}, + {0x0f03, "ReadAsciiTime"}, + {0x0f04, "GetColorTable"}, + {0x0f05, "InstallCDA"}, + {0x0f06, "WaitMouseUp"}, + {0x0f08, "FFStopSound"}, + {0x0f09, "AbsOn"}, + {0x0f0b, "FixMul"}, + {0x0f0c, "SetInputDevice"}, + {0x0f0e, "SetFrameColor"}, + {0x0f0f, "InsertMItem"}, + {0x0f10, "ShowControl"}, + {0x0f11, "GetLoadSegInfo"}, + {0x0f12, "GetSysIcon"}, + {0x0f13, "PrCloseDoc"}, + {0x0f14, "LEActivate"}, + {0x0f15, "ModalDialog"}, + {0x0f16, "GetScrapSize"}, + {0x0f17, "SFPutFile2"}, + {0x0f19, "NSSetUserUpdateRtn"}, + {0x0f1a, "StartSeq"}, + {0x0f1b, "SetPurgeStart"}, + {0x0f1c, "ResetMember"}, + {0x0f1e, "RemoveResource"}, + {0x0f20, "MIDIRecordSeq"}, + {0x0f21, "VDKeySetKCol"}, + {0x0f22, "TEActivate"}, + {0x0f23, "SetPlayTrack"}, + {0x0f25, "StartChar"}, + {0x1001, "UnloadOneTool"}, + {0x1002, "DisposeHandle"}, + {0x1003, "SetVector"}, + {0x1004, "SetColorEntry"}, + {0x1006, "TickCount"}, + {0x1008, "FFSoundStatus"}, + {0x1009, "AbsOff"}, + {0x100b, "FracMul"}, + {0x100c, "SetOutputDevice"}, + {0x100e, "GetFrameColor"}, + {0x100f, "DeleteMItem"}, + {0x1010, "DrawControls"}, + {0x1011, "GetUserID"}, + {0x1012, "PixelMap2Rgn"}, + {0x1013, "PrOpenPage"}, + {0x1014, "LEDeactivate"}, + {0x1015, "IsDialogEvent"}, + {0x1016, "GetScrapPath"}, + {0x1017, "SFPGetFile2"}, + {0x101a, "StepSeq"}, + {0x101b, "CountFonts"}, + {0x101c, "NewList"}, + {0x101e, "MarkResourceChange"}, + {0x1020, "MIDIStopRecord"}, + {0x1021, "VDKeyGetKRCol"}, + {0x1022, "TEDeactivate"}, + {0x1023, "TrackToChan"}, + {0x1025, "MoveChar"}, + {0x1101, "TLMountVolume"}, + {0x1102, "DisposeAll"}, + {0x1103, "GetVector"}, + {0x1104, "GetColorEntry"}, + {0x1105, "ChooseCDA"}, + {0x1106, "GetDBLTime"}, + {0x1108, "FFGeneratorStatus"}, + {0x1109, "ReadAbs"}, + {0x110b, "FixDiv"}, + {0x110c, "SetErrorDevice"}, + {0x110e, "SelectWindow"}, + {0x110f, "GetSysBar"}, + {0x1110, "HiliteControls"}, + {0x1111, "LGetPathname"}, + {0x1113, "PrClosePage"}, + {0x1114, "LEKey"}, + {0x1115, "DialogSelect"}, + {0x1116, "SetScrapPath"}, + {0x1117, "SFPPutFile2"}, + {0x111a, "StopSeq"}, + {0x111b, "FindFontStats"}, + {0x111c, "DrawMember2"}, + {0x111e, "SetCurResourceFile"}, + {0x1120, "MIDIPlaySeq"}, + {0x1121, "VDKeyGetKGCol"}, + {0x1122, "TEClick"}, + {0x1123, "Locate"}, + {0x1125, "GetCharRecPtr"}, + {0x1201, "TLTextMountVolume"}, + {0x1202, "PurgeHandle"}, + {0x1203, "SetHeartBeat"}, + {0x1204, "SetSCB"}, + {0x1206, "GetCaretTime"}, + {0x1208, "SetSoundMIRQV"}, + {0x1209, "SetAbsScale"}, + {0x120b, "FracDiv"}, + {0x120c, "GetInputDevice"}, + {0x120e, "HideWindow"}, + {0x120f, "SetSysBar"}, + {0x1210, "CtlNewRes"}, + {0x1211, "UserShutdown"}, + {0x1213, "PrPicFile"}, + {0x1214, "LECut"}, + {0x1215, "DlgCut"}, + {0x1216, "GetScrapCount"}, + {0x1217, "SFShowInvisible"}, + {0x121a, "SetInstTable"}, + {0x121b, "LoadFont"}, + {0x121c, "NextMember2"}, + {0x121e, "GetCurResourceFile"}, + {0x1220, "MIDIStopPlay"}, + {0x1221, "VDKeyGetKBCol"}, + {0x1222, "TEUpdate"}, + {0x1223, "SetVelComp"}, + {0x1225, "KillChar"}, + {0x1301, "SaveTextState"}, + {0x1302, "PurgeAll"}, + {0x1303, "DelHeartBeat"}, + {0x1304, "GetSCB"}, + {0x1305, "SetDAStrPtr"}, + {0x1306, "SetSwitch"}, + {0x1308, "SetUserSoundIRQV"}, + {0x1309, "GetAbsScale"}, + {0x130b, "FixRound"}, + {0x130c, "GetOutputDevice"}, + {0x130e, "ShowWindow"}, + {0x130f, "FixMenuBar"}, + {0x1310, "FindControl"}, + {0x1311, "RenamePathname"}, + {0x1312, "IBeamCursor"}, + {0x1313, "PrControl"}, + {0x1314, "LECopy"}, + {0x1315, "DlgCopy"}, + {0x1316, "GetScrapState"}, + {0x1317, "SFReScan"}, + {0x131a, "StartInts"}, + {0x131b, "LoadSysFont"}, + {0x131c, "ResetMember2"}, + {0x131e, "SetCurResourceApp"}, + {0x1320, "MIDIConvert"}, + {0x1321, "VDKeySetKDiss"}, + {0x1322, "TEPaintText"}, + {0x1323, "SetMIDIPort"}, + {0x1325, "LoadActor"}, + {0x1401, "RestoreTextState"}, + {0x1403, "ClrHeartBeat"}, + {0x1404, "SetAllSCBs"}, + {0x1405, "GetDAStrPtr"}, + {0x1406, "PostEvent"}, + {0x1408, "FFSoundDoneStatus"}, + {0x1409, "SRQPoll"}, + {0x140b, "FracSqrt"}, + {0x140c, "GetErrorDevice"}, + {0x140e, "SendBehind"}, + {0x140f, "CountMItems"}, + {0x1410, "TestControl"}, + {0x1412, "WhooshRect"}, + {0x1413, "PrError"}, + {0x1414, "LEPaste"}, + {0x1415, "DlgPaste"}, + {0x1417, "SFMultiGet2"}, + {0x141a, "StopInts"}, + {0x141b, "AddFontVar"}, + {0x141c, "SelectMember2"}, + {0x141e, "GetCurResourceApp"}, + {0x1421, "VDKeyGetKDiss"}, + {0x1422, "TEKey"}, + {0x1423, "SetInstrument"}, + {0x1425, "SetCharScript"}, + {0x1501, "MessageCenter"}, + {0x1503, "SysFailMgr"}, + {0x1504, "ClearScreen"}, + {0x1505, "OpenNDA"}, + {0x1506, "FlushEvents"}, + {0x1508, "FFSetUpSound"}, + {0x1509, "SRQRemove"}, + {0x150b, "FracCos"}, + {0x150c, "InitTextDev"}, + {0x150e, "FrontWindow"}, + {0x150f, "NewMenuBar"}, + {0x1510, "TrackControl"}, + {0x1513, "PrSetError"}, + {0x1514, "LEDelete"}, + {0x1515, "DlgDelete"}, + {0x1517, "SFPMultiGet2"}, + {0x151a, "StartSeqRel"}, + {0x151b, "FixFontMenu"}, + {0x151c, "SortList2"}, + {0x151e, "HomeResourceFile"}, + {0x1521, "VDKeySetNKD"}, + {0x1522, "TEUnsupported"}, + {0x1523, "SeqPlayer"}, + {0x1525, "RunAnimScripts"}, + {0x1601, "SetDefaultTPT"}, + {0x1603, "GetAddr"}, + {0x1604, "SetMasterSCB"}, + {0x1605, "CloseNDA"}, + {0x1606, "GetOSEvent"}, + {0x1608, "FFStartPlaying"}, + {0x1609, "ClearSRQTable"}, + {0x160b, "FracSin"}, + {0x160c, "CtlTextDev"}, + {0x160e, "SetInfoDraw"}, + {0x160f, "GetMHandle"}, + {0x1610, "MoveControl"}, + {0x1613, "PrChoosePrinter"}, + {0x1614, "LEInsert"}, + {0x1615, "DrawDialog"}, + {0x161b, "ChooseFont"}, + {0x161c, "NewList2"}, + {0x161e, "WriteResource"}, + {0x1621, "VDKeyGetNKD"}, + {0x1622, "TECut"}, + {0x1623, "SetTempo"}, + {0x1625, "FillAddrTable"}, + {0x1701, "MessageByName"}, + {0x1703, "ReadMouse"}, + {0x1704, "GetMasterSCB"}, + {0x1705, "SystemClick"}, + {0x1706, "OSEventAvail"}, + {0x1708, "SetDOCReg"}, + {0x170b, "FixATan2"}, + {0x170c, "StatusTextDev"}, + {0x170e, "FindWindow"}, + {0x170f, "SetBarColors"}, + {0x1710, "DragControl"}, + {0x1713, "GetDeviceName"}, + {0x1714, "LEUpdate"}, + {0x1715, "Alert"}, + {0x171b, "ItemID2FamNum"}, + {0x171c, "ListKey"}, + {0x171e, "ReleaseResource"}, + {0x1721, "VDOutSetStd"}, + {0x1722, "TECopy"}, + {0x1723, "SetCallBack"}, + {0x1725, "CompileRect"}, + {0x1801, "StartUpTools"}, + {0x1802, "GetHandleSize"}, + {0x1803, "InitMouse"}, + {0x1804, "OpenPort"}, + {0x1805, "SystemEdit"}, + {0x1806, "SetEventMask"}, + {0x1808, "ReadDOCReg"}, + {0x180b, "HiWord"}, + {0x180c, "WriteChar"}, + {0x180e, "TrackGoAway"}, + {0x180f, "GetBarColors"}, + {0x1810, "SetCtlIcons"}, + {0x1813, "PrGetPrinterSpecs"}, + {0x1814, "LETextBox"}, + {0x1815, "StopAlert"}, + {0x181b, "FMSetSysFont"}, + {0x181c, "CompareStrings"}, + {0x181e, "DetachResource"}, + {0x1821, "VDOutGetStd"}, + {0x1822, "TEPaste"}, + {0x1823, "SysExOut"}, + {0x1825, "StartTockTask"}, + {0x1901, "ShutDownTools"}, + {0x1902, "SetHandleSize"}, + {0x1903, "SetMouse"}, + {0x1904, "InitPort"}, + {0x1905, "SystemTask"}, + {0x1906, "FakeMouse"}, + {0x190b, "LoWord"}, + {0x190c, "ErrWriteChar"}, + {0x190e, "MoveWindow"}, + {0x190f, "SetMTitleStart"}, + {0x1910, "SetCtlValue"}, + {0x1913, "PrDevPrChanged"}, + {0x1914, "LEFromScrap"}, + {0x1915, "NoteAlert"}, + {0x191b, "FMGetSysFID"}, + {0x191e, "UniqueResourceID"}, + {0x1921, "VDOutControl"}, + {0x1922, "TEClear"}, + {0x1923, "SetBeat"}, + {0x1925, "FireTockTask"}, + {0x1a01, "GetMsgHandle"}, + {0x1a02, "FindHandle"}, + {0x1a03, "HomeMouse"}, + {0x1a04, "ClosePort"}, + {0x1a05, "SystemEvent"}, + {0x1a06, "SetAutokeyLimit"}, + {0x1a0b, "Long2Fix"}, + {0x1a0c, "WriteLine"}, + {0x1a0e, "DragWindow"}, + {0x1a0f, "GetMTitleStart"}, + {0x1a10, "GetCtlValue"}, + {0x1a13, "PrDevstartup"}, + {0x1a14, "LEToScrap"}, + {0x1a15, "CautionAlert"}, + {0x1a1b, "FMGetCurFID"}, + {0x1a1e, "SetResourceID"}, + {0x1a21, "VDOutStatus"}, + {0x1a22, "TEInsert"}, + {0x1a23, "MIDIMessage"}, + {0x1a25, "SetForegndPort"}, + {0x1b01, "AcceptRequests"}, + {0x1b02, "FreeMem"}, + {0x1b03, "ClearMouse"}, + {0x1b04, "SetPort"}, + {0x1b05, "GetNumNDAs"}, + {0x1b06, "GetKeyTranslation"}, + {0x1b0b, "Fix2Long"}, + {0x1b0c, "ErrWriteLine"}, + {0x1b0e, "GrowWindow"}, + {0x1b0f, "GetMenuMgrPort"}, + {0x1b10, "SetCtlParams"}, + {0x1b13, "PrDevShutdown"}, + {0x1b14, "LEScrapHandle"}, + {0x1b15, "ParamText"}, + {0x1b1b, "FamNum2ItemID"}, + {0x1b1e, "GetResourceAttr"}, + {0x1b21, "VDGetFeatures"}, + {0x1b22, "TEReplace"}, + {0x1b23, "LocateEnd"}, + {0x1b25, "SetAnimWindow"}, + {0x1c01, "SendRequests"}, + {0x1c02, "MaxBlock"}, + {0x1c03, "ClampMouse"}, + {0x1c04, "GetPort"}, + {0x1c05, "CloseNDAbyWinPtr"}, + {0x1c06, "SetKeyTranslation"}, + {0x1c0b, "Fix2Frac"}, + {0x1c0c, "WriteString"}, + {0x1c0e, "SizeWindow"}, + {0x1c0f, "CalcMenuSize"}, + {0x1c10, "GetCtlParams"}, + {0x1c13, "PrDevOpen"}, + {0x1c14, "LEGetScrapLen"}, + {0x1c15, "SetDAFont"}, + {0x1c1b, "InstallWithStats"}, + {0x1c1e, "SetResourceAttr"}, + {0x1c21, "VDInControl"}, + {0x1c22, "TEGetSelection"}, + {0x1c23, "Merge"}, + {0x1d02, "TotalMem"}, + {0x1d03, "GetMouseClamp"}, + {0x1d04, "SetPortLoc"}, + {0x1d05, "CloseAllNDAs"}, + {0x1d0b, "Frac2Fix"}, + {0x1d0c, "ErrWriteString"}, + {0x1d0e, "TaskMaster"}, + {0x1d0f, "SetMTitleWidth"}, + {0x1d10, "DragRect"}, + {0x1d13, "PrDevRead"}, + {0x1d14, "LESetScrapLen"}, + {0x1d1e, "GetResourceSize"}, + {0x1d21, "VDGGControl"}, + {0x1d22, "TESsetSelection"}, + {0x1d23, "DeleteTrack"}, + {0x1e02, "CheckHandle"}, + {0x1e03, "PosMouse"}, + {0x1e04, "GetPortLoc"}, + {0x1e05, "FixAppleMenu"}, + {0x1e0b, "Fix2X"}, + {0x1e0c, "TextWriteBlock"}, + {0x1e0e, "BeginUpdate"}, + {0x1e0f, "GetMTitleWidth"}, + {0x1e10, "GrowSize"}, + {0x1e13, "PrDevWrite"}, + {0x1e14, "LESetHilite"}, + {0x1e15, "GetControlDItem"}, + {0x1e1e, "MatchResourceHandle"}, + {0x1e21, "VDGGStatus"}, + {0x1e22, "TEGetSelectionStyle"}, + {0x1e23, "SetMetro"}, + {0x1f02, "CompactMem"}, + {0x1f03, "ServeMouse"}, + {0x1f04, "SetPortRect"}, + {0x1f05, "AddToRunQ"}, + {0x1f0b, "Frac2X"}, + {0x1f0c, "ErrWriteBlock"}, + {0x1f0e, "EndUpdate"}, + {0x1f0f, "SetMenuFlag"}, + {0x1f10, "GetCtlDPage"}, + {0x1f13, "PrDevClose"}, + {0x1f14, "LESetCaret"}, + {0x1f15, "GetIText"}, + {0x1f1e, "GetOpenFileRefNum"}, + {0x1f22, "TEStyleChange"}, + {0x1f23, "GetMSData"}, + {0x2002, "HLock"}, + {0x2003, "GetNewID"}, + {0x2004, "GetPortRect"}, + {0x2005, "RemoveFromRunQ"}, + {0x200b, "X2FIx"}, + {0x200c, "WriteCString"}, + {0x200e, "GetWMgrPort"}, + {0x200f, "GetMenuFlag"}, + {0x2010, "SetCtlAction"}, + {0x2011, "InitialLoad2"}, + {0x2013, "PrDevStatus"}, + {0x2014, "LETextBox2"}, + {0x2015, "SetIText"}, + {0x201e, "CountTypes"}, + {0x2022, "TEOffsetToPoint"}, + {0x2023, "ConvertToTime"}, + {0x2102, "HLockAll"}, + {0x2103, "DeleteID"}, + {0x2104, "SetPortSize"}, + {0x2105, "RemoveCDA"}, + {0x210b, "X2Frac"}, + {0x210c, "ErrWriteCString"}, + {0x210e, "PinRect"}, + {0x210f, "SetMenuTitle"}, + {0x2110, "GetCtlAction"}, + {0x2111, "GetUserID2"}, + {0x2113, "PrDevAsyncRead"}, + {0x2114, "LESetJust"}, + {0x2115, "SelectIText"}, + {0x211e, "GetIndType"}, + {0x2122, "TEPointToOffset"}, + {0x2123, "ConvertToMeasure"}, + {0x2202, "HUnlock"}, + {0x2203, "StatusID"}, + {0x2204, "MovePortTo"}, + {0x2205, "RemoveNDA"}, + {0x220b, "Int2Hex"}, + {0x220c, "ReadChar"}, + {0x220e, "HiliteWindow"}, + {0x220f, "GetMenuTitle"}, + {0x2210, "SetCtlRefCon"}, + {0x2211, "LGetPathname2"}, + {0x2213, "PrDevWriteBackground"}, + {0x2214, "LEGetTextHand"}, + {0x2215, "HideDItem"}, + {0x221e, "CountResources"}, + {0x2222, "TEGetDefProc"}, + {0x2223, "MSSuspend"}, + {0x2302, "HUnlockAll"}, + {0x2303, "IntSource"}, + {0x2304, "SetOrigin"}, + {0x2305, "GetIndDAInfo"}, + {0x230b, "Long2Hex"}, + {0x230c, "TextReadBlock"}, + {0x230e, "ShowHide"}, + {0x230f, "MenuGlobal"}, + {0x2310, "GetCtlRefCon"}, + {0x2313, "PrDriverVer"}, + {0x2314, "LEGetTextLen"}, + {0x2315, "ShowDItem"}, + {0x231e, "GetIndResource"}, + {0x2322, "TEGetRuler"}, + {0x2323, "MSResume"}, + {0x2402, "SetPurge"}, + {0x2403, "FWEntry"}, + {0x2404, "SetClip"}, + {0x2405, "CallDeskAcc"}, + {0x240b, "Hex2Int"}, + {0x240c, "ReadLine"}, + {0x240e, "BringToFront"}, + {0x240f, "SetMItem"}, + {0x2410, "EraseControl"}, + {0x2413, "PrPortVer"}, + {0x2414, "GetLEDefProc"}, + {0x2415, "FindDItem"}, + {0x241e, "SetResourceLoad"}, + {0x2422, "TESetRuler"}, + {0x2423, "SetTuningTable"}, + {0x2502, "SetPurgeAll"}, + {0x2503, "GetTick"}, + {0x2504, "GetClip"}, + {0x2505, "GetDeskGlobal"}, + {0x250b, "Hex2Long"}, + {0x250e, "WindNewRes"}, + {0x250f, "GetMItem"}, + {0x2510, "DrawOneCtl"}, + {0x2513, "PrGetZoneName"}, + {0x2515, "UpdateDialog"}, + {0x251e, "SetResourceFileDepth"}, + {0x2522, "TEScroll"}, + {0x2523, "GetTuningTable"}, + {0x2603, "PackBytes"}, + {0x2604, "ClipRect"}, + {0x260b, "Int2Dec"}, + {0x260e, "TrackZoom"}, + {0x260f, "SetMItemFlag"}, + {0x2610, "FindTargetCtl"}, + {0x2615, "GetDItemType"}, + {0x261e, "GetMapHandle"}, + {0x2622, "TEGetInternalProc"}, + {0x2623, "SetTrackOut"}, + {0x2703, "UnPackBytes"}, + {0x2704, "HidePen"}, + {0x270b, "Long2Dec"}, + {0x270e, "ZoomWindow"}, + {0x270f, "GetMItemFlag"}, + {0x2710, "MakeNextCtlTarget"}, + {0x2715, "SetDItemType"}, + {0x271e, "LoadAbsResource"}, + {0x2722, "TEGetLastError"}, + {0x2723, "StartMIDIDriver"}, + {0x2802, "PtrToHand"}, + {0x2803, "Munger"}, + {0x2804, "ShowPen"}, + {0x280b, "Dec2Int"}, + {0x280e, "SetWRefCon"}, + {0x280f, "SetMItemBlink"}, + {0x2810, "MakeThisCtlTarget"}, + {0x2813, "PrGetPrinterDrvName"}, + {0x2815, "GetDItemBox"}, + {0x281e, "ResourceConverter"}, + {0x2822, "TECompactRecord"}, + {0x2823, "StopMIDIDriver"}, + {0x2902, "HandToPtr"}, + {0x2903, "GetIRQEnable"}, + {0x2904, "GetPen"}, + {0x290b, "Dec2Long"}, + {0x290e, "GetWRefCon"}, + {0x290f, "MenuNewRes"}, + {0x2910, "SendEventToCtl"}, + {0x2913, "PrGetPortDvrName"}, + {0x2915, "SetDItemBox"}, + {0x2a02, "HandToHand"}, + {0x2a03, "SetAbsClamp"}, + {0x2a04, "SetPenState"}, + {0x2a0b, "HexIt"}, + {0x2a0e, "GetNextWindow"}, + {0x2a0f, "DrawMenuBar"}, + {0x2a10, "GetCtlID"}, + {0x2a13, "PrGetUserName"}, + {0x2a15, "GetFirstDItem"}, + {0x2a1e, "RMFindNamedResource"}, + {0x2b02, "BlockMove"}, + {0x2b03, "GetAbsClamp"}, + {0x2b04, "GetPenState"}, + {0x2b0e, "GetWKind"}, + {0x2b0f, "MenuSelect"}, + {0x2b10, "SetCtlID"}, + {0x2b13, "PrGetNetworkName"}, + {0x2b15, "GetNextDItem"}, + {0x2b1e, "RMGetResourceName"}, + {0x2c03, "SysBeep"}, + {0x2c04, "SetPenSize"}, + {0x2c0e, "GetWFrame"}, + {0x2c0f, "HiliteMenu"}, + {0x2c10, "CallCtlDefProc"}, + {0x2c15, "ModalDialog2"}, + {0x2c1e, "RMLoadNamedResource"}, + {0x2d04, "GetPenSize"}, + {0x2d0e, "SetWFrame"}, + {0x2d0f, "NewMenu"}, + {0x2d10, "NotifyCtls"}, + {0x2d1e, "RMSetResourceName"}, + {0x2e03, "AddToQueue"}, + {0x2e04, "SetPenMode"}, + {0x2e0e, "GetStructRgn"}, + {0x2e0f, "DisposeMenu"}, + {0x2e10, "GetCtlMoreFlags"}, + {0x2e15, "GetDItemValue"}, + {0x2f02, "RealFreeMem"}, + {0x2f03, "DeleteFromQueue"}, + {0x2f04, "GetPenMode"}, + {0x2f0e, "GetContentRgn"}, + {0x2f0f, "InitPalette"}, + {0x2f10, "SetCtlMoreFlags"}, + {0x2f15, "SetDItemValue"}, + {0x3002, "SetHandleID"}, + {0x3004, "SetPenPat"}, + {0x300e, "GetUpdateRgn"}, + {0x300f, "EnableMItem"}, + {0x3010, "GetCtlHandleFromID"}, + {0x3013, "PrDevIsItSafe"}, + {0x3103, "GetInterruptState"}, + {0x3104, "GetPenPat"}, + {0x310e, "GetDefProc"}, + {0x310f, "DisableMItem"}, + {0x3110, "NewControl2"}, + {0x3113, "GetZoneList"}, + {0x3203, "GetIntStateRecSize"}, + {0x3204, "SetPenMask"}, + {0x320e, "SetDefProc"}, + {0x320f, "CheckMItem"}, + {0x3210, "CMLoadResource"}, + {0x3213, "GetMyZone"}, + {0x3215, "GetNewModalDialog"}, + {0x3303, "ReadMouse2"}, + {0x3304, "GetPenMask"}, + {0x330e, "GetWControls"}, + {0x330f, "SetMItemMark"}, + {0x3310, "CMReleaseResource"}, + {0x3313, "GetPrinterList"}, + {0x3315, "GetNewDItem"}, + {0x3403, "GetCodeResConverter"}, + {0x3404, "SetBackPat"}, + {0x340e, "SetOriginMask"}, + {0x340f, "GetMItemMark"}, + {0x3410, "SetCtlParamPtr"}, + {0x3413, "PMUnloadDriver"}, + {0x3415, "GetAlertStage"}, + {0x3503, "GetROMResource"}, + {0x3504, "GetBackPat"}, + {0x350e, "GetInfoRefCon"}, + {0x350f, "SetMItemStyle"}, + {0x3510, "GetCtlParamPtr"}, + {0x3513, "PMLoadDriver"}, + {0x3515, "ResetAlertStage"}, + {0x3603, "ReleaseROMResource"}, + {0x3604, "PenNormal"}, + {0x360e, "SetInfoRefCon"}, + {0x360f, "GetMItemStyle"}, + {0x3613, "PrGetDocName"}, + {0x3615, "DefaultFilter"}, + {0x3703, "ConvSeconds"}, + {0x3704, "SetSolidPenPat"}, + {0x370e, "GetZoomRect"}, + {0x370f, "SetMenuID"}, + {0x3710, "InvalCtls"}, + {0x3713, "PrSetDocName"}, + {0x3715, "GetDefButton"}, + {0x3803, "SysBeep2"}, + {0x3804, "SetSolidBackPat"}, + {0x380e, "SetZoomRect"}, + {0x380f, "SetMItemID"}, + {0x3810, "CtlReserved"}, + {0x3813, "PrGetPgOrientation"}, + {0x3815, "SetDefButton"}, + {0x3903, "VersionString"}, + {0x3904, "SolidPattern"}, + {0x390e, "RefreshDesktop"}, + {0x390f, "SetMenuBar"}, + {0x3910, "FindRadioButton"}, + {0x3915, "DisableDItem"}, + {0x3a03, "WaitUntil"}, + {0x3a04, "MoveTo"}, + {0x3a0e, "InvalRect"}, + {0x3a0f, "SetMItemName"}, + {0x3a10, "SetLETextByID"}, + {0x3a15, "EnableDItem"}, + {0x3b03, "StringToText"}, + {0x3b04, "Move"}, + {0x3b0e, "InvalRgn"}, + {0x3b0f, "GetPopUpDefProc"}, + {0x3b10, "GetLETextByID"}, + {0x3c03, "ShowBootInfo"}, + {0x3c04, "LineTo"}, + {0x3c0e, "ValidRect"}, + {0x3c0f, "PopUpMenuSelect"}, + {0x3d03, "ScanDevices"}, + {0x3d04, "Line"}, + {0x3d0e, "ValidRgn"}, + {0x3d0f, "DrawPopUp"}, + {0x3e04, "SetPicSave"}, + {0x3e0e, "GetContentOrigin"}, + {0x3e0f, "NewMenu2"}, + {0x3f04, "GetPicSave"}, + {0x3f0e, "SetContentOrigin"}, + {0x3f0f, "InsertMItem2"}, + {0x4004, "SetRgnSave"}, + {0x400e, "GetDataSize"}, + {0x400f, "SetMenuTitle2"}, + {0x4104, "GetRgnSave"}, + {0x410e, "SetDataSize"}, + {0x410f, "SetMItem2"}, + {0x4204, "SetPolySave"}, + {0x420e, "GetMaxGrow"}, + {0x420f, "SetMItemName2"}, + {0x4304, "GetPolySave"}, + {0x430e, "SetMaxGrow"}, + {0x430f, "NewMenuBar2"}, + {0x4404, "SetGrafProcs"}, + {0x440e, "GetScroll"}, + {0x4504, "GetGrafProcs"}, + {0x450e, "SetScroll"}, + {0x450f, "HideMenuBar"}, + {0x4604, "SetUserField"}, + {0x460e, "GetPage"}, + {0x460f, "ShowMenuBar"}, + {0x4704, "GetUserField"}, + {0x470e, "SetPage"}, + {0x470f, "SetMItemIcon"}, + {0x4804, "SetSysField"}, + {0x480e, "GetContentDraw"}, + {0x480f, "GetMItemIcon"}, + {0x4904, "GetSysField"}, + {0x490e, "SetContentDraw"}, + {0x490f, "SetMItemStruct"}, + {0x4a04, "SetRect"}, + {0x4a0e, "GetInfoDraw"}, + {0x4a0f, "GetMItemStruct"}, + {0x4b04, "OffsetRect"}, + {0x4b0e, "SetSysWindow"}, + {0x4b0f, "RemoveMItemStruct"}, + {0x4c04, "InsetRect"}, + {0x4c0e, "GetSysWFlag"}, + {0x4c0f, "GetMItemFlag2"}, + {0x4d04, "SectRect"}, + {0x4d0e, "StartDrawing"}, + {0x4d0f, "SetMItemFlag2"}, + {0x4e04, "UnionRect"}, + {0x4e0e, "SetWindowIcons"}, + {0x4e0f, "GetMItemWidth"}, + {0x4f04, "PtInRect"}, + {0x4f0e, "GetRectInfo"}, + {0x4f0f, "GetMItemBlink"}, + {0x5004, "Pt2Rect"}, + {0x500e, "StartInfoDrawing"}, + {0x500f, "InsertPathMItems"}, + {0x5104, "EqualRect"}, + {0x510e, "EndInfoDrawing"}, + {0x5204, "NotEmptyRect"}, + {0x520e, "GetFirstWindow"}, + {0x5304, "FrameRect"}, + {0x530e, "WindDragRect"}, + {0x5404, "PaintRect"}, + {0x540e, "Private01"}, + {0x5504, "EraseRect"}, + {0x550e, "DrawInfoBar"}, + {0x5604, "InvertRect"}, + {0x560e, "WindowGlobal"}, + {0x5704, "FillRect"}, + {0x570e, "SetContentOrigin2"}, + {0x5804, "FrameOval"}, + {0x580e, "GetWindowMgrGlobals"}, + {0x5904, "PaintOval"}, + {0x590e, "AlertWindow"}, + {0x5a04, "EraseOval"}, + {0x5a0e, "StartFrameDrawing"}, + {0x5b04, "InvertOval"}, + {0x5b0e, "EndFrameDrawing"}, + {0x5c04, "FillOVal"}, + {0x5c0e, "ResizeWindow"}, + {0x5d04, "FrameRRect"}, + {0x5d0e, "TaskMasterContent"}, + {0x5e04, "PaintRRect"}, + {0x5e0e, "TaskMasterKey"}, + {0x5f04, "EraseRRect"}, + {0x5f0e, "TaskMasterDA"}, + {0x6004, "InvertRRect"}, + {0x600e, "CompileText"}, + {0x6104, "FillRRect"}, + {0x610e, "NewWindow2"}, + {0x6204, "FrameArc"}, + {0x620e, "ErrorWindow"}, + {0x6304, "PaintArc"}, + {0x630e, "GetAuxWindInfo"}, + {0x6404, "EraseArc"}, + {0x640e, "DoModalWindow"}, + {0x6504, "InvertArc"}, + {0x650e, "MWGetCtlPart"}, + {0x6604, "FillArc"}, + {0x660e, "MWSetMenuProc"}, + {0x6704, "NewRgn"}, + {0x670e, "MWStdDrawProc"}, + {0x6804, "DisposeRgn"}, + {0x680e, "MWSetUpEditMenu"}, + {0x6904, "CopyRgn"}, + {0x690e, "FindCursorCtl"}, + {0x6a04, "SetEmptyRgn"}, + {0x6a0e, "ResizeInfoBar"}, + {0x6b04, "SetRectRgn"}, + {0x6b0e, "HandleDiskInsert"}, + {0x6c04, "RectRgn"}, + {0x6d04, "OpenRgn"}, + {0x6e04, "CloseRgn"}, + {0x6f04, "OffsetRgn"}, + {0x7004, "InsetRgn"}, + {0x7104, "SectRgn"}, + {0x7204, "UnionRgn"}, + {0x7304, "DiffRgn"}, + {0x7404, "XorRgn"}, + {0x7504, "PtInRgn"}, + {0x7604, "RectInRgn"}, + {0x7704, "EqualRgn"}, + {0x7804, "EmptyRgn"}, + {0x7904, "FrameRgn"}, + {0x7a04, "PaintRgn"}, + {0x7b04, "EraseRgn"}, + {0x7c04, "InvertRgn"}, + {0x7d04, "FillRgn"}, + {0x7e04, "ScrollRect"}, + {0x7f04, "PaintPixels"}, + {0x8004, "AddPt"}, + {0x8104, "SubPt"}, + {0x8204, "SetPt"}, + {0x8304, "EqualPt"}, + {0x8404, "LocalToGlobal"}, + {0x8504, "GlobalToLocal"}, + {0x8604, "Random"}, + {0x8704, "SetRandSeed"}, + {0x8804, "GetPixel"}, + {0x8904, "ScalePt"}, + {0x8a04, "MapPt"}, + {0x8b04, "MapRect"}, + {0x8c04, "MapRgn"}, + {0x8d04, "SetStdProcs"}, + {0x8e04, "SetCursor"}, + {0x8f04, "GetCursorAdr"}, + {0x9004, "HideCursor"}, + {0x9104, "ShowCursor"}, + {0x9204, "ObscureCursor"}, + {0x9304, "SetMouseLoc"}, + {0x9404, "SetFont"}, + {0x9504, "GetFont"}, + {0x9604, "GetFontInfo"}, + {0x9704, "GetFontGlobals"}, + {0x9804, "SetFontFlags"}, + {0x9904, "GetFontFlags"}, + {0x9a04, "SetTextFace"}, + {0x9b04, "GetTextFace"}, + {0x9c04, "SetTextMode"}, + {0x9d04, "GetTextMode"}, + {0x9e04, "SetSpaceExtra"}, + {0x9f04, "GetSpaceExtra"}, + {0xa004, "SetForeColor"}, + {0xa104, "GetForeColor"}, + {0xa204, "SetBackColor"}, + {0xa304, "GetBackColor"}, + {0xa404, "DrawChar"}, + {0xa504, "DrawString"}, + {0xa604, "DrawCString"}, + {0xa704, "DrawText"}, + {0xa804, "CharWidth"}, + {0xa904, "StringWidth"}, + {0xaa04, "CStringWidth"}, + {0xab04, "TextWidth"}, + {0xac04, "CharBounds"}, + {0xad04, "StringBounds"}, + {0xae04, "CStringBounds"}, + {0xaf04, "TextBounds"}, + {0xb004, "SetArcRot"}, + {0xb104, "GetArcRot"}, + {0xb204, "SetSysFont"}, + {0xb304, "GetSysFont"}, + {0xb404, "SetVisRgn"}, + {0xb504, "GetVisRgn"}, + {0xb604, "SetIntUse"}, + {0xb704, "OpenPicture"}, + {0xb712, "OpenPicture"}, + {0xb804, "PicComment"}, + {0xb812, "PicComment"}, + {0xb904, "ClosePicture"}, + {0xba04, "DrawPicture"}, + {0xba12, "DrawPicture"}, + {0xbb04, "KillPicture"}, + {0xbb12, "KillPicture"}, + {0xbc04, "FramePoly"}, + {0xbd04, "PaintPoly"}, + {0xbe04, "ErasePoly"}, + {0xbf04, "InvertPoly"}, + {0xc004, "FillPoly"}, + {0xc104, "OpenPoly"}, + {0xc204, "ClosePoly"}, + {0xc304, "KillPoly"}, + {0xc404, "OffsetPoly"}, + {0xc504, "MapPoly"}, + {0xc604, "SetClipHandle"}, + {0xc704, "GetClipHandle"}, + {0xc804, "SetVisHandle"}, + {0xc904, "GetVisHandle"}, + {0xca04, "InitCursor"}, + {0xcb04, "SetBufDims"}, + {0xcc04, "ForceBufDims"}, + {0xcd04, "SaveBufDims"}, + {0xce04, "RestoreBufDims"}, + {0xcf04, "GetFGSize"}, + {0xd004, "SetFontID"}, + {0xd104, "GetFontID"}, + {0xd204, "SetTextSize"}, + {0xd304, "GetTextSize"}, + {0xd404, "SetCharExtra"}, + {0xd504, "GetCharExtra"}, + {0xd604, "PPToPort"}, + {0xd704, "InflateTextBuffer"}, + {0xd804, "GetRomFont"}, + {0xd904, "GetFontLore"}, + {0xda04, "Get640Color"}, + {0xdb04, "Set640Color"} +}; + +#define numTools (sizeof(tools) / sizeof(tools[0])) + +static const char *toolLookup(uint16_t tool) { + for (int i = 0; i < numTools; i++) { + if (tools[i].id >= tool) { + if (tools[i].id == tool) + return tools[i].name; + break; + } + } + return NULL; +}