mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-26 15:53:01 +00:00
Added li1/lix
This commit is contained in:
parent
a1267aea4e
commit
8b407af780
5 changed files with 27 additions and 27 deletions
21
assembler.c
21
assembler.c
|
@ -31,7 +31,7 @@ Program p;
|
|||
/* clang-format off */
|
||||
|
||||
char ops[][4] = {
|
||||
"BRK", "LIT", "---", "---", "IOR", "IOW", "LDR", "STR",
|
||||
"BRK", "---", "LI1", "LIX", "IOR", "IOW", "LDR", "STR",
|
||||
"JMP", "JSR", "RTI", "RTS", "---", "---", "---", "---",
|
||||
"POP", "DUP", "SWP", "OVR", "ROT", "AND", "ORA", "ROL",
|
||||
"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]) &
|
|||
void
|
||||
pushbyte(Uint8 b, int lit)
|
||||
{
|
||||
if(lit) {
|
||||
pushbyte(0x01, 0);
|
||||
pushbyte(0x01, 0);
|
||||
}
|
||||
if(lit)
|
||||
pushbyte(0x02, 0);
|
||||
p.data[p.ptr++] = b;
|
||||
}
|
||||
|
||||
|
@ -64,7 +62,7 @@ void
|
|||
pushshort(Uint16 s, int lit)
|
||||
{
|
||||
if(lit) {
|
||||
pushbyte(0x01, 0);
|
||||
pushbyte(0x03, 0);
|
||||
pushbyte(0x02, 0);
|
||||
}
|
||||
pushbyte((s >> 8) & 0xff, 0);
|
||||
|
@ -75,7 +73,7 @@ void
|
|||
pushtext(char *w)
|
||||
{
|
||||
int i = slen(w);
|
||||
pushbyte(0x01, 0);
|
||||
pushbyte(0x03, 0);
|
||||
pushbyte(slen(w), 0);
|
||||
while(i > 0)
|
||||
pushbyte(w[--i], 0);
|
||||
|
@ -167,10 +165,13 @@ pass1(FILE *f)
|
|||
case '|': addr = shex(w + 1); break;
|
||||
case '@':
|
||||
case ';': break;
|
||||
case '.': addr += 2; break;
|
||||
case '#': addr += 4; break;
|
||||
case '"': addr += slen(w + 1) + 2; break;
|
||||
case ',': addr += 2 + (sihx(w + 1) && slen(w + 1) == 2 ? 1 : 2); break;
|
||||
case '#': addr += 4; break;
|
||||
case '.': addr += 2; break;
|
||||
case ',':
|
||||
addr += (slen(w + 1) == 2 ? 1 : 2);
|
||||
addr += (sihx(w + 1) ? slen(w + 1) / 2 : 2);
|
||||
break;
|
||||
default: return error("Unknown label", w);
|
||||
}
|
||||
}
|
||||
|
|
9
cli.c
9
cli.c
|
@ -21,7 +21,7 @@ error(char *msg, const char *err)
|
|||
}
|
||||
|
||||
Uint8
|
||||
console_onread(Device *d, Uint8 b)
|
||||
consoler(Device *d, Uint8 b)
|
||||
{
|
||||
(void)d;
|
||||
(void)b;
|
||||
|
@ -29,7 +29,7 @@ console_onread(Device *d, Uint8 b)
|
|||
}
|
||||
|
||||
Uint8
|
||||
console_onwrite(Device *d, Uint8 b)
|
||||
consolew(Device *d, Uint8 b)
|
||||
{
|
||||
(void)d;
|
||||
if(b)
|
||||
|
@ -84,14 +84,13 @@ main(int argc, char **argv)
|
|||
return error("Boot", "Failed");
|
||||
if(!loaduxn(&u, argv[1]))
|
||||
return error("Load", "Failed");
|
||||
portuxn(&u, "console", console_onread, console_onwrite);
|
||||
portuxn(&u, "console", consoler, consolew);
|
||||
evaluxn(&u, u.vreset);
|
||||
evaluxn(&u, u.vframe);
|
||||
|
||||
/*
|
||||
echos(&u.wst, 0x40, "stack");
|
||||
echom(&u.ram, 0x40, "ram");
|
||||
*/
|
||||
|
||||
echof(&u);
|
||||
return 0;
|
||||
}
|
||||
|
|
13
emulator.c
13
emulator.c
|
@ -145,11 +145,8 @@ echof(Uxn *c)
|
|||
void
|
||||
domouse(SDL_Event *event)
|
||||
{
|
||||
int x = event->motion.x / ZOOM - PAD * 8;
|
||||
int y = event->motion.y / ZOOM - PAD * 8;
|
||||
|
||||
devmouse->mem[0] = x;
|
||||
devmouse->mem[1] = y;
|
||||
devmouse->mem[0] = event->motion.x / ZOOM - PAD * 8;
|
||||
devmouse->mem[1] = event->motion.y / ZOOM - PAD * 8;
|
||||
switch(event->type) {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
devmouse->mem[2] = 0;
|
||||
|
@ -219,18 +216,24 @@ mouser(Device *d, Uint8 b)
|
|||
Uint8
|
||||
mousew(Device *d, Uint8 b)
|
||||
{
|
||||
(void)d;
|
||||
(void)b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Uint8
|
||||
keyr(Device *d, Uint8 b)
|
||||
{
|
||||
(void)d;
|
||||
(void)b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Uint8
|
||||
keyw(Device *d, Uint8 b)
|
||||
{
|
||||
(void)d;
|
||||
(void)b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
|
||||
|0100 @RESET
|
||||
|
||||
,01 ,00 IOW
|
||||
,02 ,00 IOW
|
||||
,03 ,00 IOW
|
||||
,04 ,00 IOW
|
||||
,05 ,00 IOW
|
||||
,1234
|
||||
|
||||
BRK
|
||||
|
||||
|
|
5
uxn.c
5
uxn.c
|
@ -31,7 +31,8 @@ Uint16 mempeek16(Uxn *u, Uint16 s) { return (u->ram.dat[s] << 8) + (u->ram.dat[s
|
|||
|
||||
/* I/O */
|
||||
void op_brk(Uxn *u) { setflag(&u->status,FLAG_HALT, 1); }
|
||||
void op_lit(Uxn *u) { u->literal += u->ram.dat[u->ram.ptr++]; }
|
||||
void op_li1(Uxn *u) { u->literal += 1; }
|
||||
void op_lix(Uxn *u) { u->literal += u->ram.dat[u->ram.ptr++]; }
|
||||
void op_nop(Uxn *u) { printf("NOP"); (void)u; }
|
||||
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)); }
|
||||
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)
|
|||
void op_lth16(Uxn *u) { Uint16 a = wspop16(u), b = wspop16(u); wspush8(u, b < a); }
|
||||
|
||||
void (*ops[])(Uxn *u) = {
|
||||
op_brk, op_lit, op_nop, op_nop, op_ior, op_iow, op_ldr, op_str,
|
||||
op_brk, op_nop, op_li1, op_lix, op_ior, op_iow, op_ldr, op_str,
|
||||
op_jmp, op_jsr, op_nop, op_rts, op_nop, op_nop, op_nop, op_nop,
|
||||
op_pop, op_dup, op_swp, op_ovr, op_rot, op_and, op_ora, op_rol,
|
||||
op_add, op_sub, op_mul, op_div, op_equ, op_neq, op_gth, op_lth,
|
||||
|
|
Loading…
Reference in a new issue