Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect maximum ROM size #1103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/device/cart/cart_rom.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

#define CART_ROM_ADDR_MASK UINT32_C(0x03ffffff);
#define CART_ROM_ADDR_MASK UINT32_C(0xefffffff);


void init_cart_rom(struct cart_rom* cart_rom,
Expand Down
2 changes: 1 addition & 1 deletion src/device/cart/cart_rom.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct cart_rom

static osal_inline uint32_t rom_address(uint32_t address)
{
return (address & 0x03fffffc);
return (address & 0x0ffffffc);
}

void init_cart_rom(struct cart_rom* cart_rom,
Expand Down
5 changes: 3 additions & 2 deletions src/device/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "device.h"

#include "main/util.h"
#include "memory/memory.h"
#include "pif/pif.h"
#include "r4300/r4300_core.h"
Expand Down Expand Up @@ -57,7 +58,7 @@ static void get_pi_dma_handler(struct cart* cart, struct dd_controller* dd, uint

if (address >= MM_CART_ROM) {
if (address >= MM_CART_DOM3) {
/* 0x1fd00000 - 0x7fffffff : dom3 addr2, cart rom (Paper Mario (U)) ??? */
/* 0x1fd00000 - 0xffffffff : dom3 addr2, cart rom */
RW(cart, cart_dom3);
}
else {
Expand Down Expand Up @@ -155,7 +156,7 @@ void init_device(struct device* dev,
{ A(MM_DD_ROM, 0x1ffffff), M64P_MEM_NOTHING, { NULL, RW(open_bus) } },
{ A(MM_DOM2_ADDR2, 0x1ffff), M64P_MEM_FLASHRAMSTAT, { &dev->cart, RW(cart_dom2) } },
{ A(MM_IS_VIEWER, 0xfff), M64P_MEM_NOTHING, { &dev->is, RW(is_viewer) } },
{ A(MM_CART_ROM, rom_size-1), M64P_MEM_ROM, { &dev->cart.cart_rom, RW(cart_rom) } },
{ A(MM_CART_ROM, min(rom_size-1, 0xfbfffff)), M64P_MEM_ROM, { &dev->cart.cart_rom, RW(cart_rom) } },
{ A(MM_PIF_MEM, 0xffff), M64P_MEM_PIF, { &dev->pif, RW(pif_mem) } }
};

Expand Down
4 changes: 1 addition & 3 deletions src/device/gb/m64282fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
*/

#include "m64282fp.h"
#include "main/util.h"

#include <string.h>

int min(int a, int b) { return (a < b) ? a : b; }
int max(int a, int b) { return (a < b) ? b : a; }

int clamp(int v, int low, int high)
{
return min(high, max(low, v));
Expand Down
2 changes: 1 addition & 1 deletion src/device/memory/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ enum {
MB_DD_ROM = MB_RSP_MEM + SP_MEM_SIZE,
MB_PIF_MEM = MB_DD_ROM + DD_ROM_MAX_SIZE,
MB_MAX_SIZE = MB_PIF_MEM + PIF_ROM_SIZE + PIF_RAM_SIZE,
MB_MAX_SIZE_FULL = 0x20000000
MB_MAX_SIZE_FULL = 0x120000000,
};

/* Use LSB of mem_base pointer to encode mem_base mode
Expand Down
2 changes: 1 addition & 1 deletion src/device/memory/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "osal/preproc.h"

enum { RDRAM_MAX_SIZE = 0x800000 };
enum { CART_ROM_MAX_SIZE = 0x4000000 };
enum { CART_ROM_MAX_SIZE = 0x100000000 };
enum { DD_ROM_MAX_SIZE = 0x400000 };

typedef void (*read32fn)(void*,uint32_t,uint32_t*);
Expand Down
3 changes: 3 additions & 0 deletions src/main/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ struct xoshiro256pp_state xoshiro256pp_seed(uint64_t seed);

uint64_t xoshiro256pp_next(struct xoshiro256pp_state* s);

#define min(a, b) ((a < b) ? a : b)
#define max(a, b) ((a < b) ? b : a)

/**********************
GUI utilities
**********************/
Expand Down