Skip to content
Permalink
Browse files

Merge pull request #69 from retro-wertz/master

Cleanup
  • Loading branch information
twinaphex committed Aug 6, 2019
2 parents 408cab7 + d9f8396 commit 71e4b7b3754571a832aebc68acbc7c2f012fe191
@@ -1,6 +1,11 @@
#ifndef GB_H
#define GB_H

#define gbWidth 160
#define gbHeight 144
#define sgbWidth 256
#define sgbHeight 224

const int GB_C_FLAG = 0x10;
const int GB_H_FLAG = 0x20;
const int GB_N_FLAG = 0x40;
@@ -55,6 +60,8 @@ void setColorizerHack(bool value);
bool allowColorizerHack(void);

extern int gbHardware;
extern int gbRomType; // gets type from header 0x147
extern int gbBattery; // enabled when gbRamSize != 0

extern struct EmulatedSystem GBSystem;

@@ -246,6 +246,7 @@ static char dummy_state[735 * 2];
&name, sizeof(type) \
}

#ifndef __LIBRETRO__
// Old save state support

static variable_desc gbsound_format[] = {
@@ -355,7 +356,6 @@ enum {
nr52
};

#ifndef __LIBRETRO__
static void gbSoundReadGameOld(int version, gzFile gzFile)
{
if (version == 11) {
@@ -27,30 +27,6 @@ int flashDeviceID = 0x1b;
int flashManufacturerID = 0x32;
int flashBank = 0;

static variable_desc flashSaveData[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSaveMemory[0], SIZE_FLASH512 },
{ NULL, 0 }
};

static variable_desc flashSaveData2[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSize, sizeof(int) },
{ &flashSaveMemory[0], SIZE_FLASH1M },
{ NULL, 0 }
};

static variable_desc flashSaveData3[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSize, sizeof(int) },
{ &flashBank, sizeof(int) },
{ &flashSaveMemory[0], SIZE_FLASH1M },
{ NULL, 0 }
};

void flashInit()
{
memset(flashSaveMemory, 0xff, sizeof(flashSaveMemory));
@@ -63,49 +39,6 @@ void flashReset()
flashBank = 0;
}

#ifdef __LIBRETRO__
void flashSaveGame(uint8_t*& data)
{
utilWriteDataMem(data, flashSaveData3);
}

void flashReadGame(const uint8_t*& data, int)
{
utilReadDataMem(data, flashSaveData3);
}

#else // !__LIBRETRO__
void flashSaveGame(gzFile gzFile)
{
utilWriteData(gzFile, flashSaveData3);
}

void flashReadGame(gzFile gzFile, int version)
{
if (version < SAVE_GAME_VERSION_5)
utilReadData(gzFile, flashSaveData);
else if (version < SAVE_GAME_VERSION_7) {
utilReadData(gzFile, flashSaveData2);
flashBank = 0;
flashSetSize(flashSize);
} else {
utilReadData(gzFile, flashSaveData3);
}
}

void flashReadGameSkip(gzFile gzFile, int version)
{
// skip the flash data in a save game
if (version < SAVE_GAME_VERSION_5)
utilReadDataSkip(gzFile, flashSaveData);
else if (version < SAVE_GAME_VERSION_7) {
utilReadDataSkip(gzFile, flashSaveData2);
} else {
utilReadDataSkip(gzFile, flashSaveData3);
}
}
#endif

void flashSetSize(int size)
{
// log("Setting flash size to %d\n", size);
@@ -279,3 +212,70 @@ void flashWrite(uint32_t address, uint8_t byte)
break;
}
}

static variable_desc flashSaveData3[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSize, sizeof(int) },
{ &flashBank, sizeof(int) },
{ &flashSaveMemory[0], SIZE_FLASH1M },
{ NULL, 0 }
};

#ifdef __LIBRETRO__
void flashSaveGame(uint8_t*& data)
{
utilWriteDataMem(data, flashSaveData3);
}

void flashReadGame(const uint8_t*& data, int)
{
utilReadDataMem(data, flashSaveData3);
}

#else // !__LIBRETRO__
static variable_desc flashSaveData[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSaveMemory[0], SIZE_FLASH512 },
{ NULL, 0 }
};

static variable_desc flashSaveData2[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSize, sizeof(int) },
{ &flashSaveMemory[0], SIZE_FLASH1M },
{ NULL, 0 }
};

void flashSaveGame(gzFile gzFile)
{
utilWriteData(gzFile, flashSaveData3);
}

void flashReadGame(gzFile gzFile, int version)
{
if (version < SAVE_GAME_VERSION_5)
utilReadData(gzFile, flashSaveData);
else if (version < SAVE_GAME_VERSION_7) {
utilReadData(gzFile, flashSaveData2);
flashBank = 0;
flashSetSize(flashSize);
} else {
utilReadData(gzFile, flashSaveData3);
}
}

void flashReadGameSkip(gzFile gzFile, int version)
{
// skip the flash data in a save game
if (version < SAVE_GAME_VERSION_5)
utilReadDataSkip(gzFile, flashSaveData);
else if (version < SAVE_GAME_VERSION_7) {
utilReadDataSkip(gzFile, flashSaveData2);
} else {
utilReadDataSkip(gzFile, flashSaveData3);
}
}
#endif
@@ -1235,6 +1235,7 @@ DEFINE_ALU_INSN_C(1F, 3F, MVNS, YES)
int mult = (opcode & 0x0F); \
uint32_t rs = reg[(opcode >> 8) & 0x0F].I; \
int acc = (opcode >> 12) & 0x0F; /* or destLo */ \
maybe_unused(acc); \
int dest = (opcode >> 16) & 0x0F; /* or destHi */ \
OP; \
SETCOND; \
@@ -19,6 +19,9 @@ const uint64_t TICKS_PER_SECOND = 16777216;
#define SAVE_GAME_VERSION_10 10
#define SAVE_GAME_VERSION SAVE_GAME_VERSION_10

#define gbaWidth 240
#define gbaHeight 160

enum {
GBA_SAVE_AUTO = 0,
GBA_SAVE_EEPROM,
@@ -588,6 +588,7 @@ static struct {
int soundDSBValue;
} state;

#ifndef __LIBRETRO__
// Old GBA sound state format
static variable_desc old_gba_state[] = {
SKIP(int, soundPaused),
@@ -673,6 +674,7 @@ variable_desc old_gba_state2[] = {
SKIP(int, sound3ForcedOutput),
{ NULL, 0 }
};
#endif

// New state format
static variable_desc gba_state[] = {
@@ -6,8 +6,7 @@ SOURCES_CXX :=
SOURCES_CXX += \
$(CORE_DIR)/libretro/libretro.cpp \
$(CORE_DIR)/libretro/UtilRetro.cpp \
$(CORE_DIR)/libretro/SoundRetro.cpp \
$(CORE_DIR)/libretro/scrc32.cpp
$(CORE_DIR)/libretro/SoundRetro.cpp

SOURCES_CXX += \
$(CORE_DIR)/apu/Gb_Oscs.cpp \

0 comments on commit 71e4b7b

Please sign in to comment.
You can’t perform that action at this time.