commit c866b0938a906c877626656d6215acf1e2ce0892
parent 8fdb039926b9371a48765e44ab697561503483c3
Author: neauoire <aliceffekt@gmail.com>
Date: Fri, 7 Jan 2022 16:51:43 -0800
Use proper memory size
Diffstat:
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/uxncli.c b/src/uxncli.c
@@ -103,7 +103,7 @@ load(Uxn *u, char *filepath)
FILE *f;
int r;
if(!(f = fopen(filepath, "rb"))) return 0;
- r = fread(u->ram + PAGE_PROGRAM, 1, 0xffff - PAGE_PROGRAM, f);
+ r = fread(u->ram + PAGE_PROGRAM, 1, 0x10000 - PAGE_PROGRAM, f);
fclose(f);
if(r < 1) return 0;
fprintf(stderr, "Loaded %s\n", filepath);
@@ -118,8 +118,8 @@ main(int argc, char **argv)
Uxn u;
int i, loaded = 0;
- shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8));
- memory = (Uint8 *)calloc(0xffff, sizeof(Uint8));
+ shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8));
+ memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
if(!uxn_boot(&u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST)))
return error("Boot", "Failed");
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -238,7 +238,7 @@ load(Uxn *u, char *rom)
SDL_RWops *f;
int r;
if(!(f = SDL_RWFromFile(rom, "rb"))) return 0;
- r = f->read(f, u->ram + PAGE_PROGRAM, 1, 0xffff - PAGE_PROGRAM);
+ r = f->read(f, u->ram + PAGE_PROGRAM, 1, 0x10000 - PAGE_PROGRAM);
f->close(f);
if(r < 1) return 0;
fprintf(stderr, "Loaded %s\n", rom);
@@ -251,8 +251,8 @@ static Uint8 *shadow, *memory;
static int
start(Uxn *u, char *rom)
{
- memory = (Uint8 *)calloc(0xffff, sizeof(Uint8));
- shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8));
+ memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
+ shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8));
if(!uxn_boot(&supervisor, shadow, shadow + VISOR_DEV, (Stack *)(shadow + VISOR_WST), (Stack *)(shadow + VISOR_RST)))
return error("Boot", "Failed to start uxn.");