Browse code

Use proper memory size

neauoire authored on 08/01/2022 00:51:43
Showing 2 changed files
... ...
@@ -103,7 +103,7 @@ load(Uxn *u, char *filepath)
103 103
 	FILE *f;
104 104
 	int r;
105 105
 	if(!(f = fopen(filepath, "rb"))) return 0;
106
-	r = fread(u->ram + PAGE_PROGRAM, 1, 0xffff - PAGE_PROGRAM, f);
106
+	r = fread(u->ram + PAGE_PROGRAM, 1, 0x10000 - PAGE_PROGRAM, f);
107 107
 	fclose(f);
108 108
 	if(r < 1) return 0;
109 109
 	fprintf(stderr, "Loaded %s\n", filepath);
... ...
@@ -118,8 +118,8 @@ main(int argc, char **argv)
118 118
 	Uxn u;
119 119
 	int i, loaded = 0;
120 120
 
121
-	shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8));
122
-	memory = (Uint8 *)calloc(0xffff, sizeof(Uint8));
121
+	shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8));
122
+	memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
123 123
 	if(!uxn_boot(&u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST)))
124 124
 		return error("Boot", "Failed");
125 125
 
... ...
@@ -238,7 +238,7 @@ load(Uxn *u, char *rom)
238 238
 	SDL_RWops *f;
239 239
 	int r;
240 240
 	if(!(f = SDL_RWFromFile(rom, "rb"))) return 0;
241
-	r = f->read(f, u->ram + PAGE_PROGRAM, 1, 0xffff - PAGE_PROGRAM);
241
+	r = f->read(f, u->ram + PAGE_PROGRAM, 1, 0x10000 - PAGE_PROGRAM);
242 242
 	f->close(f);
243 243
 	if(r < 1) return 0;
244 244
 	fprintf(stderr, "Loaded %s\n", rom);
... ...
@@ -251,8 +251,8 @@ static Uint8 *shadow, *memory;
251 251
 static int
252 252
 start(Uxn *u, char *rom)
253 253
 {
254
-	memory = (Uint8 *)calloc(0xffff, sizeof(Uint8));
255
-	shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8));
254
+	memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
255
+	shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8));
256 256
 
257 257
 	if(!uxn_boot(&supervisor, shadow, shadow + VISOR_DEV, (Stack *)(shadow + VISOR_WST), (Stack *)(shadow + VISOR_RST)))
258 258
 		return error("Boot", "Failed to start uxn.");