Merge branch 'master' (early part) into medusa

This commit is contained in:
Vicki Pfau 2019-06-28 15:52:41 -07:00
commit 7a67ed4ff9
13 changed files with 4902 additions and 16 deletions

View File

@ -118,7 +118,7 @@ if (BUILD_OPENEMU)
endif()
set(CMAKE_INSTALL_RPATH "${LIBDIR}")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
if (NOT DEFINED MANDIR)
set(MANDIR ${CMAKE_INSTALL_MANDIR})

View File

@ -154,11 +154,11 @@ To build on Windows for development, using MSYS2 is recommended. Follow the inst
For x86 (32 bit) builds:
pacman -Sy mingw-w64-i686-{cmake,ffmpeg,gcc,gdb,imagemagick,libelf,libepoxy,libzip,pkg-config,qt5,SDL2,ntldd-git}
pacman -Sy base-devel git mingw-w64-i686-{cmake,ffmpeg,gcc,gdb,imagemagick,libelf,libepoxy,libzip,pkg-config,qt5,SDL2,ntldd-git}
For x86_64 (64 bit) builds:
pacman -Sy mingw-w64-x86_64-{cmake,ffmpeg,gcc,gdb,imagemagick,libelf,libepoxy,libzip,pkg-config,qt5,SDL2,ntldd-git}
pacman -Sy base-devel git mingw-w64-x86_64-{cmake,ffmpeg,gcc,gdb,imagemagick,libelf,libepoxy,libzip,pkg-config,qt5,SDL2,ntldd-git}
Check out the source code by running this command:

View File

@ -136,11 +136,11 @@ Um mGBA auf Windows zu kompilieren, wird MSYS2 empfohlen. Befolge die Installati
Für x86 (32 Bit):
pacman -Sy mingw-w64-i686-{cmake,ffmpeg,gcc,gdb,imagemagick,libelf,libepoxy,libzip,pkg-config,qt5,SDL2,ntldd-git}
pacman -Sy base-devel git mingw-w64-i686-{cmake,ffmpeg,gcc,gdb,imagemagick,libelf,libepoxy,libzip,pkg-config,qt5,SDL2,ntldd-git}
Für x86_64 (64 Bit):
pacman -Sy mingw-w64-x86_64-{cmake,ffmpeg,gcc,gdb,imagemagick,libelf,libepoxy,libzip,pkg-config,qt5,SDL2,ntldd-git}
pacman -Sy base-devel git mingw-w64-x86_64-{cmake,ffmpeg,gcc,gdb,imagemagick,libelf,libepoxy,libzip,pkg-config,qt5,SDL2,ntldd-git}
Lade den aktuellen mGBA-Quellcode mithilfe des folgenden Kommandos herunter:

View File

@ -244,7 +244,7 @@ is used.
.Bl -tag -width Ds -compact
.It Pa $XDG_CONFIG_HOME/medusa-emu/config.ini
Default
.Xr medusa-emu 6
.Nm medusa-emu
configuration file.
.It Pa portable.ini
If this file exists in the current directory,

View File

@ -21,6 +21,7 @@ void GBMBCSwitchBank(struct GB* gb, int bank);
void GBMBCSwitchBank0(struct GB* gb, int bank);
void GBMBCSwitchHalfBank(struct GB* gb, int half, int bank);
void GBMBCSwitchSramBank(struct GB* gb, int bank);
void GBMBCSwitchSramHalfBank(struct GB* gb, int half, int bank);
enum GBCam {
GBCAM_WIDTH = 128,

View File

@ -26,6 +26,8 @@ enum {
GB_BASE_CART_HALFBANK2 = 0x6000,
GB_BASE_VRAM = 0x8000,
GB_BASE_EXTERNAL_RAM = 0xA000,
GB_BASE_EXTERNAL_RAM_HALFBANK0 = 0xA000,
GB_BASE_EXTERNAL_RAM_HALFBANK1 = 0xB000,
GB_BASE_WORKING_RAM_BANK0 = 0xC000,
GB_BASE_WORKING_RAM_BANK1 = 0xD000,
GB_BASE_OAM = 0xFE00,
@ -53,6 +55,7 @@ enum {
GB_SIZE_VRAM = 0x4000,
GB_SIZE_VRAM_BANK0 = 0x2000,
GB_SIZE_EXTERNAL_RAM = 0x2000,
GB_SIZE_EXTERNAL_RAM_HALFBANK = 0x1000,
GB_SIZE_WORKING_RAM = 0x8000,
GB_SIZE_WORKING_RAM_BANK0 = 0x1000,
GB_SIZE_OAM = 0xA0,
@ -110,6 +113,9 @@ struct GBMBC1State {
struct GBMBC6State {
int currentBank1;
uint8_t* romBank1;
bool sramAccess;
int currentSramBank1;
uint8_t* sramBank1;
};
struct GBMBC7State {

View File

@ -32,7 +32,7 @@
#define REG_DEBUG_FLAGS (vu16*) 0x4FFF700
#define REG_DEBUG_STRING (char*) 0x4FFF600
ssize_t mgba_stdout_write(struct _reent* r __attribute__((unused)), int fd __attribute__((unused)), const char* ptr, size_t len) {
ssize_t mgba_stdout_write(struct _reent* r __attribute__((unused)), void* fd __attribute__((unused)), const char* ptr, size_t len) {
if (len > 0x100) {
len = 0x100;
}
@ -41,7 +41,7 @@ ssize_t mgba_stdout_write(struct _reent* r __attribute__((unused)), int fd __att
return len;
}
ssize_t mgba_stderr_write(struct _reent* r __attribute__((unused)), int fd __attribute__((unused)), const char* ptr, size_t len) {
ssize_t mgba_stderr_write(struct _reent* r __attribute__((unused)), void* fd __attribute__((unused)), const char* ptr, size_t len) {
if (len > 0x100) {
len = 0x100;
}

View File

@ -32,6 +32,7 @@ static void _GBPocketCam(struct GB* gb, uint16_t address, uint8_t value);
static void _GBTAMA5(struct GB* gb, uint16_t address, uint8_t value);
static uint8_t _GBMBC2Read(struct GBMemory*, uint16_t address);
static uint8_t _GBMBC6Read(struct GBMemory*, uint16_t address);
static uint8_t _GBMBC7Read(struct GBMemory*, uint16_t address);
static void _GBMBC7Write(struct GBMemory* memory, uint16_t address, uint8_t value);
@ -114,6 +115,22 @@ void GBMBCSwitchSramBank(struct GB* gb, int bank) {
gb->memory.sramCurrentBank = bank;
}
void GBMBCSwitchSramHalfBank(struct GB* gb, int half, int bank) {
size_t bankStart = bank * GB_SIZE_EXTERNAL_RAM_HALFBANK;
if (bankStart + GB_SIZE_EXTERNAL_RAM_HALFBANK > gb->sramSize) {
mLOG(GB_MBC, GAME_ERROR, "Attempting to switch to an invalid RAM bank: %0X", bank);
bankStart &= (gb->sramSize - 1);
bank = bankStart / GB_SIZE_EXTERNAL_RAM_HALFBANK;
}
if (!half) {
gb->memory.sramBank = &gb->memory.sram[bankStart];
gb->memory.sramCurrentBank = bank;
} else {
gb->memory.mbcState.mbc6.sramBank1 = &gb->memory.sram[bankStart];
gb->memory.mbcState.mbc6.currentSramBank1 = bank;
}
}
void GBMBCInit(struct GB* gb) {
const struct GBCartridge* cart = (const struct GBCartridge*) &gb->memory.rom[0x100];
if (gb->memory.rom) {
@ -230,6 +247,7 @@ void GBMBCInit(struct GB* gb) {
case GB_MBC6:
mLOG(GB_MBC, WARN, "unimplemented MBC: MBC6");
gb->memory.mbcWrite = _GBMBC6;
gb->memory.mbcRead = _GBMBC6Read;
break;
case GB_MBC7:
gb->memory.mbcWrite = _GBMBC7;
@ -531,16 +549,15 @@ void _GBMBC5(struct GB* gb, uint16_t address, uint8_t value) {
void _GBMBC6(struct GB* gb, uint16_t address, uint8_t value) {
struct GBMemory* memory = &gb->memory;
int bank = value & 0x7F;
int bank = value;
switch (address >> 10) {
case 0:
switch (value) {
case 0:
memory->sramAccess = false;
memory->mbcState.mbc6.sramAccess = false;
break;
case 0xA:
memory->sramAccess = true;
GBMBCSwitchSramBank(gb, memory->sramCurrentBank);
memory->mbcState.mbc6.sramAccess = true;
break;
default:
// TODO
@ -548,18 +565,55 @@ void _GBMBC6(struct GB* gb, uint16_t address, uint8_t value) {
break;
}
break;
case 0x1:
GBMBCSwitchSramHalfBank(gb, 0, bank);
break;
case 0x2:
GBMBCSwitchSramHalfBank(gb, 1, bank);
break;
case 0x8:
case 0x9:
GBMBCSwitchHalfBank(gb, 0, bank);
break;
case 0xC:
case 0xD:
GBMBCSwitchHalfBank(gb, 1, bank);
break;
case 0x28:
case 0x29:
case 0x2A:
case 0x2B:
if (memory->mbcState.mbc6.sramAccess) {
memory->sramBank[address & (GB_SIZE_EXTERNAL_RAM_HALFBANK - 1)] = value;
}
break;
case 0x2C:
case 0x2D:
case 0x2E:
case 0x2F:
if (memory->mbcState.mbc6.sramAccess) {
memory->mbcState.mbc6.sramBank1[address & (GB_SIZE_EXTERNAL_RAM_HALFBANK - 1)] = value;
}
break;
default:
mLOG(GB_MBC, STUB, "MBC6 unknown address: %04X:%02X", address, value);
break;
}
}
uint8_t _GBMBC6Read(struct GBMemory* memory, uint16_t address) {
if (!memory->mbcState.mbc6.sramAccess) {
return 0xFF;
}
switch (address >> 12) {
case 0xA:
return memory->sramBank[address & (GB_SIZE_EXTERNAL_RAM_HALFBANK - 1)];
case 0xB:
return memory->mbcState.mbc6.sramBank1[address & (GB_SIZE_EXTERNAL_RAM_HALFBANK - 1)];
}
return 0xFF;
}
void _GBMBC7(struct GB* gb, uint16_t address, uint8_t value) {
int bank = value & 0x7F;
switch (address >> 13) {

View File

@ -73,9 +73,20 @@ static void GBSetActiveRegion(struct LR35902Core* cpu, uint16_t address) {
case GB_REGION_CART_BANK1 + 2:
case GB_REGION_CART_BANK1 + 3:
cpu->memory.cpuLoad8 = GBFastLoad8;
cpu->memory.activeRegion = memory->romBank;
cpu->memory.activeRegionEnd = GB_BASE_VRAM;
cpu->memory.activeMask = GB_SIZE_CART_BANK0 - 1;
if (gb->memory.mbcType != GB_MBC6) {
cpu->memory.activeRegion = memory->romBank;
cpu->memory.activeRegionEnd = GB_BASE_VRAM;
cpu->memory.activeMask = GB_SIZE_CART_BANK0 - 1;
} else {
cpu->memory.activeMask = GB_SIZE_CART_HALFBANK - 1;
if (address & 0x2000) {
cpu->memory.activeRegion = memory->mbcState.mbc6.romBank1;
cpu->memory.activeRegionEnd = GB_BASE_VRAM;
} else {
cpu->memory.activeRegion = memory->romBank;
cpu->memory.activeRegionEnd = GB_BASE_CART_BANK1 + 0x2000;
}
}
break;
default:
cpu->memory.cpuLoad8 = GBLoad8;
@ -169,6 +180,13 @@ void GBMemoryReset(struct GB* gb) {
case GB_MBC1:
gb->memory.mbcState.mbc1.mode = 0;
break;
case GB_MBC6:
GBMBCSwitchHalfBank(gb, 0, 2);
GBMBCSwitchHalfBank(gb, 1, 3);
gb->memory.mbcState.mbc6.sramAccess = false;
GBMBCSwitchSramHalfBank(gb, 0, 0);
GBMBCSwitchSramHalfBank(gb, 0, 1);
break;
default:
memset(&gb->memory.mbcState, 0, sizeof(gb->memory.mbcState));
}

View File

@ -648,7 +648,7 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render
}
if (softwareRenderer->target1Obj && (softwareRenderer->blendEffect == BLEND_DARKEN || softwareRenderer->blendEffect == BLEND_BRIGHTEN)) {
int x = 0;
uint32_t mask = 0xFF000000 & ~FLAG_OBJWIN;
uint32_t mask = FLAG_REBLEND | FLAG_TARGET_1 | FLAG_IS_BACKGROUND;
uint32_t match = FLAG_REBLEND;
if (GBARegisterDISPCNTIsObjwinEnable(softwareRenderer->dispcnt)) {
mask |= FLAG_OBJWIN;

View File

@ -9,6 +9,7 @@ pydir = os.path.dirname(os.path.abspath(__file__))
srcdir = os.path.join(pydir, "..", "..")
incdir = os.path.join(pydir, "..", "..", "..", "include")
bindir = os.environ.get("BINDIR", os.path.join(os.getcwd(), ".."))
libdir = os.environ.get("LIBDIR")
cpp = shlex.split(os.environ.get("CPP", "cc -E"))
cppflags = shlex.split(os.environ.get("CPPFLAGS", ""))
@ -54,6 +55,7 @@ ffi.set_source("mgba._pylib", """
extra_compile_args=cppflags,
libraries=["medusa-emu"],
library_dirs=[bindir],
runtime_library_dirs=[libdir],
sources=[os.path.join(pydir, path) for path in ["vfs-py.c", "core.c", "log.c", "sio.c"]])
preprocessed = subprocess.check_output(cpp + ["-fno-inline", "-P"] + cppflags + [os.path.join(pydir, "_builder.h")], universal_newlines=True)

View File

@ -4,6 +4,7 @@ import os
import sys
os.environ["BINDIR"] = "${CMAKE_BINARY_DIR}"
os.environ["LIBDIR"] = "${CMAKE_INSTALL_PREFIX}/${LIBDIR}"
os.environ["CPPFLAGS"] = " ".join([d for d in "${INCLUDE_FLAGS}".split(";") if d])
classifiers = [

File diff suppressed because it is too large Load Diff