From db4e07f5b17b13adf1a11b8e238bb6ec6ce645b9 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 2 Feb 2023 09:34:14 -0800 Subject: [PATCH] Ported to last uxn core --- src/devices/system.c | 4 ++-- src/uxn.c | 8 ++++---- src/uxn.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/devices/system.c b/src/devices/system.c index 214a1c7..78050b0 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -62,9 +62,9 @@ system_load(Uxn *u, char *filename) FILE *f = fopen(filename, "rb"); if(!f) return 0; - l = fread(&u->ram[PAGE_PROGRAM], 1, 0x10000 - PAGE_PROGRAM, f); + l = fread(&u->ram[PAGE_PROGRAM], 0x10000 - PAGE_PROGRAM, 1, f); while(l && ++i < RAM_PAGES) - l = fread(u->ram + 0x10000 * i, 1, 0x10000, f); + l = fread(u->ram + 0x10000 * i, 0x10000, 1, f); fclose(f); return 1; } diff --git a/src/uxn.c b/src/uxn.c index a0bca6f..967040d 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -75,7 +75,7 @@ uxn_eval(Uxn *u, Uint16 pc) case 0x0f: /* STH */ POP(a) PUSH(dst, a) break; case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(src, b) break; case 0x11: /* STZ */ POP8(a) POP(b) POKE(a, b) break; - case 0x12: /* LDR */ POP8(a) PEEK(b, pc + (Sint8)a) PUSH(src, b) break; + case 0x12: /* LDR */ POP8(a) b = pc + (Sint8)a; PEEK(c, b) PUSH(src, c) break; case 0x13: /* STR */ POP8(a) POP(b) c = pc + (Sint8)a; POKE(c, b) break; case 0x14: /* LDA */ POP16(a) PEEK(b, a) PUSH(src, b) break; case 0x15: /* STA */ POP16(a) POP(b) POKE(a, b) break; @@ -100,9 +100,9 @@ uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo) char *cptr = (char *)u; for(i = 0; i < sizeof(*u); i++) cptr[i] = 0x00; - u->wst = (Stack *)(ram + 0x10000); - u->rst = (Stack *)(ram + 0x10100); - u->dev = (Uint8 *)(ram + 0x10200); + u->wst = (Stack *)(ram + 0xf0000); + u->rst = (Stack *)(ram + 0xf0100); + u->dev = (Uint8 *)(ram + 0xf0200); u->ram = ram; u->dei = dei; u->deo = deo; diff --git a/src/uxn.h b/src/uxn.h index f217213..e67b746 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -26,7 +26,7 @@ typedef unsigned int Uint32; /* clang-format on */ typedef struct { - Uint8 dat[254], err, ptr; + Uint8 dat[255], ptr; } Stack; typedef struct Uxn {