From e1e48294f05f4d78c08665c591881ddcc070c771 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sun, 26 Jan 2020 08:47:28 +0800 Subject: [PATCH] Remove unused variables --- src/cart.c | 5 ----- src/cart.h | 3 --- src/unif.c | 25 ++++++++++++------------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/cart.c b/src/cart.c index d0b7cd1..911cb0c 100644 --- a/src/cart.c +++ b/src/cart.c @@ -53,9 +53,6 @@ static int PRGram[32]; uint8 *PRGptr[32]; uint8 *CHRptr[32]; -uint32 PRGchip_max; -uint32 CHRchip_max; - uint32 PRGsize[32]; uint32 CHRsize[32]; @@ -107,8 +104,6 @@ void ResetCartMapping(void) { for (x = 0; x < 8; x++) { MMC5SPRVPage[x] = MMC5BGVPage[x] = VPageR[x] = nothing - 0x400 * x; } - PRGchip_max = 0; - CHRchip_max = 0; } void SetupCartPRGMapping(int chip, uint8 *p, uint32 size, int ram) { diff --git a/src/cart.h b/src/cart.h index 56875da..08de902 100644 --- a/src/cart.h +++ b/src/cart.h @@ -49,9 +49,6 @@ DECLFW(CartBW); extern uint8 *PRGptr[32]; extern uint8 *CHRptr[32]; -extern uint32 PRGchip_max; -extern uint32 CHRchip_max; - extern uint32 PRGsize[32]; extern uint32 CHRsize[32]; diff --git a/src/unif.c b/src/unif.c index 5702fa0..2c11ca7 100644 --- a/src/unif.c +++ b/src/unif.c @@ -687,9 +687,6 @@ static int InitializeBoard(void) { mirrortodo = 4; MooMirroring(); - PRGchip_max = prg_chip_count - 1; - if (chr_chip_count) - CHRchip_max = chr_chip_count - 1; UNIFCart.submapper = submapper; GameInfo->cspecial = cspecial; @@ -756,18 +753,20 @@ int UNIFLoad(const char *name, FCEUFILE *fp) { VROM = (uint8*)malloc(VROM_size); for (x = 0; x < 16; x++) { - if (malloced[prg_idx[x]]) { - memcpy(ROM + PRGptr, malloced[(prg_idx[x])], mallocedsizes[(prg_idx[x])]); - PRGptr += mallocedsizes[(prg_idx[x])]; - free(malloced[(prg_idx[x])]); - malloced[(prg_idx[x])] = 0; + unsigned p = prg_idx[x]; + unsigned c = 16 + chr_idx[x]; + if (malloced[p]) { + memcpy(ROM + PRGptr, malloced[p], mallocedsizes[p]); + PRGptr += mallocedsizes[p]; + free(malloced[p]); + malloced[p] = 0; } - if (malloced[16 + (chr_idx[x])]) { - memcpy(VROM + CHRptr, malloced[16 + (chr_idx[x])], mallocedsizes[16 + (chr_idx[x])]); - CHRptr += mallocedsizes[16 + (chr_idx[x])]; - free(malloced[16 + (chr_idx[x])]); - malloced[16 + (chr_idx[x])] = 0; + if (malloced[c]) { + memcpy(VROM + CHRptr, malloced[c], mallocedsizes[c]); + CHRptr += mallocedsizes[c]; + free(malloced[c]); + malloced[c] = 0; } }