Merge pull request #99 from negativeExponent/libretro_updates

update
This commit is contained in:
Autechre 2021-05-22 05:15:30 +02:00 committed by GitHub
commit 501909c57b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 74 deletions

View File

@ -1065,10 +1065,13 @@ void gbWriteMemory(uint16_t address, uint8_t value)
}
#endif
}
#else
gbMemory[0xff02] = value;
if (gbSerialOn)
gbSerialTicks = GBSERIAL_CLOCK_TICKS;
#endif
gbSerialBits = 0;
return;
#endif
}
case 0x04: {
@ -1893,11 +1896,11 @@ uint8_t gbReadMemory(uint16_t address)
return gbMemory[0xff01];
case 0x02:
return (gbMemory[0xff02]);
case 0x03:
log("Undocumented Memory register read %04x PC=%04x\n",
case 0x03:
log("Undocumented Memory register read %04x PC=%04x\n",
address,
PC.W);
return 0xff;
return 0xff;
case 0x04:
return register_DIV;
case 0x05:
@ -5295,6 +5298,27 @@ void gbEmulate(int ticksToStop)
}
#endif
}
#else
static int SIOctr = 0;
SIOctr++;
if (SIOctr % 5) {
if (gbSerialOn) {
if (gbMemory[0xff02] & 1) {
gbSerialTicks -= clockTicks;
while (gbSerialTicks <= 0) {
gbMemory[0xff01] = (gbMemory[0xff01] << 1) | 1;
gbSerialBits++;
if (gbSerialBits >= 8) {
gbMemory[0xff02] &= 0x7f;
gbMemory[0xff0f] = register_IF |= 8;
gbSerialOn = 0;
gbSerialBits = 0;
} else
gbSerialTicks += GBSERIAL_CLOCK_TICKS;
}
}
}
}
#endif
// TODO: evaluate and fix this
// On VBA-M (gb core running twice as fast?), each vblank is uses 35112 cycles.

View File

@ -3038,11 +3038,27 @@ void CPUUpdateRegister(uint32_t address, uint16_t value)
cpuNextEvent = cpuTotalTicks;
break;
#ifndef NO_LINK
case COMM_SIOCNT:
#ifndef NO_LINK
StartLink(value);
#else
if (!ioMem)
return;
if (value & 0x80) {
value &= 0xff7f;
if (value & 1 && (value & 0x4000)) {
UPDATE_REG(COMM_SIOCNT, 0xFF);
IF |= 0x80;
UPDATE_REG(0x202, IF);
value &= 0x7f7f;
}
}
UPDATE_REG(COMM_SIOCNT, value);
#endif
break;
#ifndef NO_LINK
case COMM_SIODATA8:
UPDATE_REG(COMM_SIODATA8, value);
break;
@ -3057,11 +3073,19 @@ void CPUUpdateRegister(uint32_t address, uint16_t value)
UPDATE_REG(0x132, value & 0xC3FF);
break;
#ifndef NO_LINK
case COMM_RCNT:
#ifndef NO_LINK
StartGPLink(value);
#else
if (!ioMem)
return;
UPDATE_REG(COMM_RCNT, value);
#endif
break;
#ifndef NO_LINK
case COMM_JOYCNT: {
uint16_t cur = READ16LE(&ioMem[COMM_JOYCNT]);

View File

@ -2,7 +2,7 @@ DEBUG=0
TILED_RENDERING=0
STATIC_LINKING=0
FRONTEND_SUPPORTS_RGB565=1
NO_LINK=0
NO_LINK=1
SPACE :=
SPACE := $(SPACE) $(SPACE)

View File

@ -92,72 +92,6 @@ void (*dbgOutput)(const char* s, uint32_t addr);
void (*dbgSignal)(int sig, int number);
#endif
// Dummy vars/funcs for serial io emulation without LINK communication related stuff
#ifndef NO_LINK
#include "../gba/GBALink.h"
uint8_t gbSIO_SC;
bool LinkIsWaiting;
bool LinkFirstTime;
bool EmuReseted;
int winGbPrinterEnabled;
bool gba_joybus_active = false;
#define UPDATE_REG(address, value) WRITE16LE(((uint16_t*)&ioMem[address]), value)
LinkMode GetLinkMode()
{
return LINK_DISCONNECTED;
}
void StartGPLink(uint16_t value)
{
if (!ioMem)
return;
UPDATE_REG(COMM_RCNT, value);
}
void LinkUpdate(int ticks)
{
}
void StartLink(uint16_t siocnt)
{
/* log("'s' siocnt = %04x\n", siocnt); */
if (!ioMem)
return;
if(siocnt & 0x80)
{
siocnt &= 0xff7f;
if(siocnt & 1 && (siocnt & 0x4000))
{
UPDATE_REG(COMM_SIOCNT, 0xFF);
IF |= 0x80;
UPDATE_REG(0x202, IF);
siocnt &= 0x7f7f;
}
}
UPDATE_REG(COMM_SIOCNT, siocnt);
}
void CheckLinkConnection()
{
}
void gbInitLink()
{
LinkIsWaiting = false;
LinkFirstTime = true;
}
uint16_t gbLinkUpdate(uint8_t b, int gbSerialOn) //used on external clock
{
return (b << 8);
}
#endif
#define GS555(x) (x | (x << 5) | (x << 10))
uint16_t systemGbPalette[24] = {
GS555(0x1f), GS555(0x15), GS555(0x0c), 0,