remove unused variable

This commit is contained in:
Hojun-Cho 2024-07-24 16:04:17 +09:00
parent 8c700685ab
commit d82b0a8ccd
4 changed files with 14 additions and 32 deletions

15
gb.c
View File

@ -6,12 +6,10 @@
#include <fcntl.h> #include <fcntl.h>
int savereq, loadreq; int savereq, loadreq;
int cpuhalt;
int backup;
int savefd = -1; int savefd = -1;
int saveframes; int saveframes;
const char *romname; const char *romname;
u8 mbc, feat, mode; u8 mbc, mode;
void void
writeback(void) writeback(void)
@ -68,6 +66,7 @@ loadsave(const char *file)
static void static void
loadrom(const char* file) loadrom(const char* file)
{ {
int feat;
FILE* f; FILE* f;
long sz; long sz;
static u8 mbctab[31] = { 0, 1, 1, 1, -1, 2, 2, -1, 0, 0, -1, 6, 6, 6, -1, 3, static u8 mbctab[31] = { 0, 1, 1, 1, -1, 2, 2, -1, 0, 0, -1, 6, 6, 6, -1, 3,
@ -114,8 +113,8 @@ loadrom(const char* file)
break; break;
default: panic("unsupported mbc %d", mbc); default: panic("unsupported mbc %d", mbc);
} }
if ((rom[0x143] & 0x80) != 0 && (mode & FORCEDMG) == 0) if (rom[0x143] & 0x80 != 0)
mode = CGB | COL; panic("unsupported color");
if((feat & FEATBAT) != 0) if((feat & FEATBAT) != 0)
loadsave(file); loadsave(file);
} }
@ -147,11 +146,7 @@ flush()
static void static void
colinit(void) colinit(void)
{ {
union union {u8 c[4]; u32 l;}c;
{
u8 c[4];
u32 l;
} c;
c.c[3] = 0; c.c[3] = 0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {

5
gb.h
View File

@ -174,15 +174,14 @@ extern u32 pal[64];
extern u8 dma; extern u8 dma;
extern u32 divclock; extern u32 divclock;
extern u64 clock; extern u64 clock;
extern u8 ppuy, ppustate, ppuw; extern u8 ppuy, ppustate;
extern u8 keys; extern u8 keys;
extern int prish; extern int prish;
extern u8 mode; extern u8 mode;
extern u8 mbc, feat; extern u8 mbc;
extern Event* elist; extern Event* elist;
extern Event evhblank, evjoypad; extern Event evhblank, evjoypad;
extern u32 moncols[4]; extern u32 moncols[4];
extern u32 white;
extern u8* pic; extern u8* pic;
extern int (*mapper)(int, int); extern int (*mapper)(int, int);
extern Event *events[NEVENT]; extern Event *events[NEVENT];

11
mem.c
View File

@ -71,7 +71,6 @@ regwrite(u16 a, u8 v)
ppusync(); ppusync();
if ((~v & reg[a] & LCDEN) != 0) { if ((~v & reg[a] & LCDEN) != 0) {
ppuy = 0; ppuy = 0;
ppuw = 0;
ppustate = 0; ppustate = 0;
delevent(&evhblank); delevent(&evhblank);
} }
@ -236,13 +235,9 @@ mbc1(int a, int v)
} }
void void
meminit(void) meminit()
{ {
union union {u8 c[4]; u32 l;}c;
{
u8 c[4];
u32 l;
} c;
c.c[0] = c.c[1] = c.c[2] = 0; c.c[0] = c.c[1] = c.c[2] = 0;
c.c[3] = 1; c.c[3] = 1;
@ -250,14 +245,12 @@ meminit(void)
c.l >>= 1; c.l >>= 1;
c.c[0] = c.c[1] = c.c[2] = 0xff; c.c[0] = c.c[1] = c.c[2] = 0xff;
c.c[3] = 0; c.c[3] = 0;
white = c.l;
romb = rom + 0x4000; romb = rom + 0x4000;
wramb = wram + 0x1000; wramb = wram + 0x1000;
vramb = vram; vramb = vram;
mapper = mappers[mbc]; mapper = mappers[mbc];
mapper(INIT, 0); mapper(INIT, 0);
reg[LCDC] = 0x91; reg[LCDC] = 0x91;
reg[IF] = 0xE0; reg[IF] = 0xE0;
reg[SVBK] = 0xff; reg[SVBK] = 0xff;

11
ppu.c
View File

@ -34,7 +34,7 @@ enum
}; };
jmp_buf mainjmp,renderjmp; jmp_buf mainjmp,renderjmp;
u8 ppustate, ppuy, ppuw; u8 ppustate, ppuy;
u64 hblclock, rendclock; u64 hblclock, rendclock;
static int cyc, ppux, ppux0; static int cyc, ppux, ppux0;
sprite spr[10], *sprm; sprite spr[10], *sprm;
@ -110,8 +110,8 @@ ppurender(void)
} while (m > 8); } while (m > 8);
if (win == -1) { if (win == -1) {
win = 1; win = 1;
ta = 0x1800 | reg[LCDC] << 4 & 0x400 | ppuw - reg[WY] << 2 & 0x3E0; ta = 0x1800 | reg[LCDC] << 4 & 0x400 | ppuy - reg[WY] << 2 & 0x3E0;
y = ppuw - reg[WY] << 1 & 14; y = ppuy - reg[WY] << 1 & 14;
cyc += 12; cyc += 12;
m = 175 - reg[WX]; m = 175 - reg[WX];
goto restart; goto restart;
@ -245,8 +245,6 @@ hblanktick(void* _)
switch (ppustate) { switch (ppustate) {
case 0: case 0:
hblclock = clock + evhblank.time; hblclock = clock + evhblank.time;
if (reg[WX] <= 166 && reg[WY] <= 143)
ppuw++;
if (++ppuy == 144) { if (++ppuy == 144) {
ppustate = 1; ppustate = 1;
if (reg[STAT] & IRQM1) if (reg[STAT] & IRQM1)
@ -265,11 +263,8 @@ hblanktick(void* _)
break; break;
case 1: case 1:
hblclock = clock + evhblank.time; hblclock = clock + evhblank.time;
if (reg[WX] <= 166 && reg[WY] <= 143)
ppuw++;
if (++ppuy == 154) { if (++ppuy == 154) {
ppuy = 0; ppuy = 0;
ppuw = 0;
ppustate = 2; ppustate = 2;
if (reg[STAT] & IRQM2) if (reg[STAT] & IRQM2)
reg[IF] |= IRQLCDS; reg[IF] |= IRQLCDS;