Skip to content

Commit 79cf5ea

Browse files
committed
Fix incorrect maximum ROM size
1 parent e170c40 commit 79cf5ea

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

src/device/cart/cart_rom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define __STDC_FORMAT_MACROS
3333
#include <inttypes.h>
3434

35-
#define CART_ROM_ADDR_MASK UINT32_C(0x03ffffff);
35+
#define CART_ROM_ADDR_MASK UINT32_C(0xefffffff);
3636

3737

3838
void init_cart_rom(struct cart_rom* cart_rom,

src/device/device.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "device.h"
2323

24+
#include "main/util.h"
2425
#include "memory/memory.h"
2526
#include "pif/pif.h"
2627
#include "r4300/r4300_core.h"
@@ -57,7 +58,7 @@ static void get_pi_dma_handler(struct cart* cart, struct dd_controller* dd, uint
5758

5859
if (address >= MM_CART_ROM) {
5960
if (address >= MM_CART_DOM3) {
60-
/* 0x1fd00000 - 0x7fffffff : dom3 addr2, cart rom (Paper Mario (U)) ??? */
61+
/* 0x1fd00000 - 0xffffffff : dom3 addr2, cart rom */
6162
RW(cart, cart_dom3);
6263
}
6364
else {
@@ -155,7 +156,7 @@ void init_device(struct device* dev,
155156
{ A(MM_DD_ROM, 0x1ffffff), M64P_MEM_NOTHING, { NULL, RW(open_bus) } },
156157
{ A(MM_DOM2_ADDR2, 0x1ffff), M64P_MEM_FLASHRAMSTAT, { &dev->cart, RW(cart_dom2) } },
157158
{ A(MM_IS_VIEWER, 0xfff), M64P_MEM_NOTHING, { &dev->is, RW(is_viewer) } },
158-
{ A(MM_CART_ROM, rom_size-1), M64P_MEM_ROM, { &dev->cart.cart_rom, RW(cart_rom) } },
159+
{ A(MM_CART_ROM, min(rom_size-1, 0x3ffffff)), M64P_MEM_ROM, { &dev->cart.cart_rom, RW(cart_rom) } },
159160
{ A(MM_PIF_MEM, 0xffff), M64P_MEM_PIF, { &dev->pif, RW(pif_mem) } }
160161
};
161162

src/device/gb/m64282fp.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
*/
2525

2626
#include "m64282fp.h"
27+
#include "main/util.h"
2728

2829
#include <string.h>
2930

30-
int min(int a, int b) { return (a < b) ? a : b; }
31-
int max(int a, int b) { return (a < b) ? b : a; }
32-
3331
int clamp(int v, int low, int high)
3432
{
3533
return min(high, max(low, v));

src/device/memory/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "osal/preproc.h"
2929

3030
enum { RDRAM_MAX_SIZE = 0x800000 };
31-
enum { CART_ROM_MAX_SIZE = 0x4000000 };
31+
enum { CART_ROM_MAX_SIZE = 0x100000000 };
3232
enum { DD_ROM_MAX_SIZE = 0x400000 };
3333

3434
typedef void (*read32fn)(void*,uint32_t,uint32_t*);

src/main/util.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ struct xoshiro256pp_state xoshiro256pp_seed(uint64_t seed);
185185

186186
uint64_t xoshiro256pp_next(struct xoshiro256pp_state* s);
187187

188+
#define min(a, b) ((a < b) ? a : b)
189+
#define max(a, b) ((a < b) ? b : a)
190+
188191
/**********************
189192
GUI utilities
190193
**********************/

0 commit comments

Comments
 (0)