| ... | ... |
@@ -31,7 +31,7 @@ Program p; |
| 31 | 31 |
/* clang-format off */ |
| 32 | 32 |
|
| 33 | 33 |
char ops[][4] = {
|
| 34 |
- "BRK", "LIT", "---", "---", "IOR", "IOW", "LDR", "STR", |
|
| 34 |
+ "BRK", "---", "LI1", "LIX", "IOR", "IOW", "LDR", "STR", |
|
| 35 | 35 |
"JMP", "JSR", "RTI", "RTS", "---", "---", "---", "---", |
| 36 | 36 |
"POP", "DUP", "SWP", "OVR", "ROT", "AND", "ORA", "ROL", |
| 37 | 37 |
"ADD", "SUB", "MUL", "DIV", "EQU", "NEQ", "GTH", "LTH" |
| ... | ... |
@@ -53,10 +53,8 @@ char *scpy(char *src, char *dst, int len) { int i = 0; while((dst[i] = src[i]) &
|
| 53 | 53 |
void |
| 54 | 54 |
pushbyte(Uint8 b, int lit) |
| 55 | 55 |
{
|
| 56 |
- if(lit) {
|
|
| 57 |
- pushbyte(0x01, 0); |
|
| 58 |
- pushbyte(0x01, 0); |
|
| 59 |
- } |
|
| 56 |
+ if(lit) |
|
| 57 |
+ pushbyte(0x02, 0); |
|
| 60 | 58 |
p.data[p.ptr++] = b; |
| 61 | 59 |
} |
| 62 | 60 |
|
| ... | ... |
@@ -64,7 +62,7 @@ void |
| 64 | 62 |
pushshort(Uint16 s, int lit) |
| 65 | 63 |
{
|
| 66 | 64 |
if(lit) {
|
| 67 |
- pushbyte(0x01, 0); |
|
| 65 |
+ pushbyte(0x03, 0); |
|
| 68 | 66 |
pushbyte(0x02, 0); |
| 69 | 67 |
} |
| 70 | 68 |
pushbyte((s >> 8) & 0xff, 0); |
| ... | ... |
@@ -75,7 +73,7 @@ void |
| 75 | 73 |
pushtext(char *w) |
| 76 | 74 |
{
|
| 77 | 75 |
int i = slen(w); |
| 78 |
- pushbyte(0x01, 0); |
|
| 76 |
+ pushbyte(0x03, 0); |
|
| 79 | 77 |
pushbyte(slen(w), 0); |
| 80 | 78 |
while(i > 0) |
| 81 | 79 |
pushbyte(w[--i], 0); |
| ... | ... |
@@ -167,10 +165,13 @@ pass1(FILE *f) |
| 167 | 165 |
case '|': addr = shex(w + 1); break; |
| 168 | 166 |
case '@': |
| 169 | 167 |
case ';': break; |
| 170 |
- case '.': addr += 2; break; |
|
| 171 |
- case '#': addr += 4; break; |
|
| 172 | 168 |
case '"': addr += slen(w + 1) + 2; break; |
| 173 |
- case ',': addr += 2 + (sihx(w + 1) && slen(w + 1) == 2 ? 1 : 2); break; |
|
| 169 |
+ case '#': addr += 4; break; |
|
| 170 |
+ case '.': addr += 2; break; |
|
| 171 |
+ case ',': |
|
| 172 |
+ addr += (slen(w + 1) == 2 ? 1 : 2); |
|
| 173 |
+ addr += (sihx(w + 1) ? slen(w + 1) / 2 : 2); |
|
| 174 |
+ break; |
|
| 174 | 175 |
default: return error("Unknown label", w);
|
| 175 | 176 |
} |
| 176 | 177 |
} |
| ... | ... |
@@ -21,7 +21,7 @@ error(char *msg, const char *err) |
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 | 23 |
Uint8 |
| 24 |
-console_onread(Device *d, Uint8 b) |
|
| 24 |
+consoler(Device *d, Uint8 b) |
|
| 25 | 25 |
{
|
| 26 | 26 |
(void)d; |
| 27 | 27 |
(void)b; |
| ... | ... |
@@ -29,7 +29,7 @@ console_onread(Device *d, Uint8 b) |
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 | 31 |
Uint8 |
| 32 |
-console_onwrite(Device *d, Uint8 b) |
|
| 32 |
+consolew(Device *d, Uint8 b) |
|
| 33 | 33 |
{
|
| 34 | 34 |
(void)d; |
| 35 | 35 |
if(b) |
| ... | ... |
@@ -84,14 +84,13 @@ main(int argc, char **argv) |
| 84 | 84 |
return error("Boot", "Failed");
|
| 85 | 85 |
if(!loaduxn(&u, argv[1])) |
| 86 | 86 |
return error("Load", "Failed");
|
| 87 |
- portuxn(&u, "console", console_onread, console_onwrite); |
|
| 87 |
+ portuxn(&u, "console", consoler, consolew); |
|
| 88 | 88 |
evaluxn(&u, u.vreset); |
| 89 | 89 |
evaluxn(&u, u.vframe); |
| 90 | 90 |
|
| 91 |
- /* |
|
| 92 | 91 |
echos(&u.wst, 0x40, "stack"); |
| 93 | 92 |
echom(&u.ram, 0x40, "ram"); |
| 94 |
-*/ |
|
| 93 |
+ |
|
| 95 | 94 |
echof(&u); |
| 96 | 95 |
return 0; |
| 97 | 96 |
} |
| ... | ... |
@@ -145,11 +145,8 @@ echof(Uxn *c) |
| 145 | 145 |
void |
| 146 | 146 |
domouse(SDL_Event *event) |
| 147 | 147 |
{
|
| 148 |
- int x = event->motion.x / ZOOM - PAD * 8; |
|
| 149 |
- int y = event->motion.y / ZOOM - PAD * 8; |
|
| 150 |
- |
|
| 151 |
- devmouse->mem[0] = x; |
|
| 152 |
- devmouse->mem[1] = y; |
|
| 148 |
+ devmouse->mem[0] = event->motion.x / ZOOM - PAD * 8; |
|
| 149 |
+ devmouse->mem[1] = event->motion.y / ZOOM - PAD * 8; |
|
| 153 | 150 |
switch(event->type) {
|
| 154 | 151 |
case SDL_MOUSEBUTTONUP: |
| 155 | 152 |
devmouse->mem[2] = 0; |
| ... | ... |
@@ -219,18 +216,24 @@ mouser(Device *d, Uint8 b) |
| 219 | 216 |
Uint8 |
| 220 | 217 |
mousew(Device *d, Uint8 b) |
| 221 | 218 |
{
|
| 219 |
+ (void)d; |
|
| 220 |
+ (void)b; |
|
| 222 | 221 |
return 0; |
| 223 | 222 |
} |
| 224 | 223 |
|
| 225 | 224 |
Uint8 |
| 226 | 225 |
keyr(Device *d, Uint8 b) |
| 227 | 226 |
{
|
| 227 |
+ (void)d; |
|
| 228 |
+ (void)b; |
|
| 228 | 229 |
return 0; |
| 229 | 230 |
} |
| 230 | 231 |
|
| 231 | 232 |
Uint8 |
| 232 | 233 |
keyw(Device *d, Uint8 b) |
| 233 | 234 |
{
|
| 235 |
+ (void)d; |
|
| 236 |
+ (void)b; |
|
| 234 | 237 |
return 0; |
| 235 | 238 |
} |
| 236 | 239 |
|
| ... | ... |
@@ -31,7 +31,8 @@ Uint16 mempeek16(Uxn *u, Uint16 s) { return (u->ram.dat[s] << 8) + (u->ram.dat[s
|
| 31 | 31 |
|
| 32 | 32 |
/* I/O */ |
| 33 | 33 |
void op_brk(Uxn *u) { setflag(&u->status,FLAG_HALT, 1); }
|
| 34 |
-void op_lit(Uxn *u) { u->literal += u->ram.dat[u->ram.ptr++]; }
|
|
| 34 |
+void op_li1(Uxn *u) { u->literal += 1; }
|
|
| 35 |
+void op_lix(Uxn *u) { u->literal += u->ram.dat[u->ram.ptr++]; }
|
|
| 35 | 36 |
void op_nop(Uxn *u) { printf("NOP"); (void)u; }
|
| 36 | 37 |
void op_ior(Uxn *u) { Uint8 devid = wspop8(u); Uint16 devop = wspop8(u); Device *dev = &u->dev[devid]; if(devid < u->devices) wspush8(u, dev->rfn(dev,devop)); }
|
| 37 | 38 |
void op_iow(Uxn *u) { Uint8 devid = wspop8(u); Uint16 devop = wspop8(u); Device *dev = &u->dev[devid]; if(devid < u->devices) dev->wfn(dev,devop); }
|
| ... | ... |
@@ -79,7 +80,7 @@ void op_gth16(Uxn *u) { Uint16 a = wspop16(u), b = wspop16(u); wspush8(u, b > a)
|
| 79 | 80 |
void op_lth16(Uxn *u) { Uint16 a = wspop16(u), b = wspop16(u); wspush8(u, b < a); }
|
| 80 | 81 |
|
| 81 | 82 |
void (*ops[])(Uxn *u) = {
|
| 82 |
- op_brk, op_lit, op_nop, op_nop, op_ior, op_iow, op_ldr, op_str, |
|
| 83 |
+ op_brk, op_nop, op_li1, op_lix, op_ior, op_iow, op_ldr, op_str, |
|
| 83 | 84 |
op_jmp, op_jsr, op_nop, op_rts, op_nop, op_nop, op_nop, op_nop, |
| 84 | 85 |
op_pop, op_dup, op_swp, op_ovr, op_rot, op_and, op_ora, op_rol, |
| 85 | 86 |
op_add, op_sub, op_mul, op_div, op_equ, op_neq, op_gth, op_lth, |