Use proper memory size

This commit is contained in:
neauoire 2022-01-07 16:51:43 -08:00
parent 8fdb039926
commit c866b0938a
2 changed files with 6 additions and 6 deletions

View File

@ -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");

View File

@ -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.");