/* vml.c - GENERATED by build-ml.ps1 from vml.s and vmlwrap.c. Do not edit. * * The machine code helpers as a byte array. mlinit() copies them to $C000. */ #define MLBMOVE 0xc161 #define MLKPOP 0xc237 #define MLLADJ 0xc1e3 #define MLROW 0xc102 #define MLSCRN 0xc000 #define MLSIZE 660 char mlcode[660] = { 32, 86, 194, 162, 15, 189, 0, 196, 149, 75, 202, 16, 248, 24, 165, 81, 101, 89, 133, 91, 165, 82, 105, 0, 133, 92, 165, 91, 10, 133, 93, 165, 92, 42, 133, 94, 24, 165, 93, 101, 77, 133, 93, 165, 94, 101, 78, 133, 94, 169, 0, 133, 37, 169, 4, 133, 38, 166, 89, 240, 14, 24, 165, 37, 105, 40, 133, 37, 144, 2, 230, 38, 202, 208, 242, 165, 89, 133, 95, 169, 0, 133, 40, 133, 36, 169, 255, 133, 39, 165, 91, 197, 79, 165, 92, 229, 80, 176, 114, 160, 0, 177, 93, 133, 251, 200, 177, 93, 133, 252, 24, 165, 91, 105, 1, 170, 165, 92, 105, 0, 228, 79, 208, 15, 197, 80, 208, 11, 165, 83, 133, 41, 165, 84, 133, 42, 76, 155, 192, 160, 2, 177, 93, 56, 233, 1, 133, 41, 200, 177, 93, 233, 0, 133, 42, 24, 165, 251, 101, 85, 133, 251, 165, 252, 101, 86, 133, 252, 56, 165, 41, 229, 251, 170, 165, 42, 229, 252, 144, 10, 208, 4, 224, 41, 144, 2, 162, 40, 134, 36, 24, 165, 75, 101, 251, 133, 34, 165, 76, 101, 252, 133, 35, 165, 95, 197, 87, 208, 4, 165, 88, 133, 39, 32, 21, 193, 165, 95, 197, 90, 176, 33, 230, 95, 230, 91, 208, 2, 230, 92, 24, 165, 93, 105, 2, 133, 93, 144, 2, 230, 94, 24, 165, 37, 105, 40, 133, 37, 144, 2, 230, 38, 76, 79, 192, 76, 117, 194, 32, 86, 194, 162, 6, 189, 0, 196, 149, 34, 202, 16, 248, 32, 21, 193, 76, 117, 194, 165, 40, 9, 32, 160, 39, 145, 37, 136, 16, 251, 160, 0, 196, 36, 240, 45, 177, 34, 201, 32, 176, 2, 169, 32, 201, 192, 144, 4, 233, 128, 176, 22, 201, 160, 144, 4, 233, 64, 176, 14, 201, 96, 144, 4, 233, 32, 176, 6, 201, 64, 144, 2, 233, 64, 5, 40, 145, 37, 200, 208, 207, 165, 39, 201, 40, 176, 7, 168, 177, 37, 73, 128, 145, 37, 96, 32, 86, 194, 173, 0, 196, 133, 34, 173, 1, 196, 133, 35, 173, 2, 196, 133, 37, 173, 3, 196, 133, 38, 173, 4, 196, 133, 75, 173, 5, 196, 133, 76, 165, 37, 197, 34, 165, 38, 229, 35, 144, 52, 24, 165, 35, 101, 76, 133, 35, 24, 165, 38, 101, 76, 133, 38, 164, 75, 240, 9, 136, 177, 34, 145, 37, 192, 0, 208, 247, 166, 76, 240, 18, 198, 35, 198, 38, 160, 0, 136, 177, 34, 145, 37, 192, 0, 208, 247, 202, 208, 238, 76, 117, 194, 160, 0, 166, 76, 240, 14, 177, 34, 145, 37, 200, 208, 249, 230, 35, 230, 38, 202, 208, 242, 166, 75, 240, 229, 177, 34, 145, 37, 200, 202, 208, 248, 76, 117, 194, 32, 86, 194, 162, 5, 189, 0, 196, 149, 75, 202, 16, 248, 165, 75, 133, 34, 165, 76, 133, 35, 165, 77, 133, 75, 165, 78, 133, 76, 165, 79, 133, 77, 165, 80, 133, 78, 165, 75, 5, 76, 240, 38, 160, 0, 24, 177, 34, 101, 77, 145, 34, 200, 177, 34, 101, 78, 145, 34, 24, 165, 34, 105, 2, 133, 34, 144, 2, 230, 35, 165, 75, 208, 2, 198, 76, 198, 75, 76, 8, 194, 76, 117, 194, 120, 165, 198, 240, 22, 162, 0, 173, 119, 2, 72, 189, 120, 2, 157, 119, 2, 232, 224, 9, 208, 245, 198, 198, 104, 88, 96, 88, 169, 0, 96, 162, 8, 181, 34, 157, 16, 196, 202, 16, 248, 162, 21, 181, 75, 157, 25, 196, 202, 16, 248, 165, 251, 141, 47, 196, 165, 252, 141, 48, 196, 96, 162, 8, 189, 16, 196, 149, 34, 202, 16, 248, 162, 21, 189, 25, 196, 149, 75, 202, 16, 248, 173, 47, 196, 133, 251, 173, 48, 196, 133, 252, 96 }; /* vmlwrap.c - the C side of the machine code helpers. build-ml.ps1 appends * this to the generated byte array to make vml.c; edit it here. * * Parameters go through a block at $c400 (not $cf00: the C stack lives just below $d000), then sys() jumps to the entry. * On the c64 sys() takes no bank argument: sys(addr, &a, &x, &y). */ extern char *bfr; extern unsigned blen; extern unsigned lptr[]; extern int nlines, top, leftcol; /* move the code to $c000 and keep power c's heap and stack below it. must run before malloc() */ mlinit() { char *d; int i; highmem(0xc000); d = (char *) 0xc000; for (i = 0; i < MLSIZE; i++) d[i] = mlcode[i]; return 0; } /* call an entry, return what it left in A */ mlgo(addr) unsigned addr; { char a, x, y; a = 0; x = 0; y = 0; sys(addr, &a, &x, &y); return a & 255; } /* The wrappers fill the parameter block through one pointer instead of calling a helper per field: every power c function call costs a lot, and mlscr runs on every key. Words are stored low byte first. */ /* paint one row at screen address dst: len bytes from src, cursor at column cur (255 = none), rev = 128 for an all reverse row */ mlrow(src, len, dst, cur, rev) unsigned src, dst; int len, cur, rev; { char *p; p = (char *) 0xc400; p[0] = src; p[1] = src >> 8; p[2] = len; p[3] = dst; p[4] = dst >> 8; p[5] = cur; p[6] = rev; mlgo(MLROW); return 0; } /* paint screen rows r0..r1 from the buffer; the cursor sits at screen row crow (255 = none), column ccol */ mlscr(r0, r1, crow, ccol) int r0, r1, crow, ccol; { char *p; unsigned v; p = (char *) 0xc400; v = (unsigned) bfr; p[0] = v; p[1] = v >> 8; v = (unsigned) lptr; p[2] = v; p[3] = v >> 8; p[4] = nlines; p[5] = nlines >> 8; p[6] = top; p[7] = top >> 8; p[8] = blen; p[9] = blen >> 8; p[10] = leftcol; p[11] = leftcol >> 8; p[12] = crow; p[13] = ccol; p[14] = r0; p[15] = r1; mlgo(MLSCRN); return 0; } /* memmove: n bytes from 'from' to 'to', overlap safe */ mlmove(from, to, n) unsigned from, to, n; { char *p; if (n == 0) return 0; p = (char *) 0xc400; p[0] = from; p[1] = from >> 8; p[2] = to; p[3] = to >> 8; p[4] = n; p[5] = n >> 8; mlgo(MLBMOVE); return 0; } /* add d to n words starting at address a (line index fix-ups) */ mladj(a, n, d) unsigned a, n, d; { char *p; if (n == 0) return 0; p = (char *) 0xc400; p[0] = a; p[1] = a >> 8; p[2] = n; p[3] = n >> 8; p[4] = d; p[5] = d >> 8; mlgo(MLLADJ); return 0; } /* next key from the kernal buffer, or 0 */ mlkey() { return mlgo(MLKPOP); }