mirror of
https://github.com/libretro/FBNeo.git
synced 2024-12-02 14:56:50 +00:00
Merge branch 'finalburnneo-master'
This commit is contained in:
commit
ef3316e9c7
@ -34,6 +34,10 @@ struct threadystruct
|
||||
HANDLE our_thread;
|
||||
HANDLE our_event;
|
||||
HANDLE wait_event;
|
||||
|
||||
HANDLE startup_timer;
|
||||
LARGE_INTEGER startup_timer_i;
|
||||
|
||||
DWORD our_threadid;
|
||||
void (*our_callback)();
|
||||
|
||||
@ -54,9 +58,12 @@ struct threadystruct
|
||||
end_thread = 0; // good to go!
|
||||
|
||||
our_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
wait_event = CreateEvent(NULL, FALSE, TRUE, NULL);
|
||||
wait_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
our_thread = CreateThread(NULL, 0, ThreadyProc, NULL, 0, &our_threadid);
|
||||
|
||||
startup_timer = CreateWaitableTimer(NULL, TRUE, NULL);
|
||||
startup_timer_i.QuadPart = -1000; // 100usec, negative = "relative to current time"
|
||||
|
||||
SetThreadIdealProcessor(our_thread, thready_proc);
|
||||
|
||||
if (our_event && wait_event && our_thread) {
|
||||
@ -78,6 +85,7 @@ struct threadystruct
|
||||
CloseHandle(our_event);
|
||||
CloseHandle(our_thread);
|
||||
CloseHandle(wait_event);
|
||||
CloseHandle(startup_timer);
|
||||
thready_ok = 0;
|
||||
}
|
||||
}
|
||||
@ -89,6 +97,11 @@ struct threadystruct
|
||||
void notify() {
|
||||
if (thready_ok && ok_to_thread) {
|
||||
SetEvent(our_event);
|
||||
|
||||
// allow thread to get started (1/10 ms) (bug: mushisam doesn't like threaded blitter)
|
||||
SetWaitableTimer(startup_timer, &startup_timer_i, 0, NULL, NULL, 0);
|
||||
WaitForSingleObject(startup_timer, INFINITE);
|
||||
|
||||
ok_to_wait = 1;
|
||||
} else {
|
||||
// fallback to single-threaded mode
|
||||
@ -185,6 +198,7 @@ struct threadystruct
|
||||
void notify() {
|
||||
if (thready_ok && ok_to_thread) {
|
||||
sem_post(&our_event);
|
||||
usleep(100);
|
||||
ok_to_wait = 1;
|
||||
} else {
|
||||
// fallback to single-threaded mode
|
||||
@ -203,13 +217,13 @@ static threadystruct thready;
|
||||
|
||||
static void *ThreadyProc(void*) {
|
||||
do {
|
||||
sem_post(&thready.wait_event);
|
||||
sem_wait(&thready.our_event);
|
||||
|
||||
if (thready.end_thread == 0) {
|
||||
thready.is_running = 1;
|
||||
thready.our_callback();
|
||||
thready.is_running = 0;
|
||||
sem_post(&thready.wait_event);
|
||||
} else {
|
||||
sem_post(&thready.wait_event);
|
||||
thready.end_thread |= 0x100;
|
||||
|
@ -342,6 +342,16 @@ static INT32 nff0002 = 0;
|
||||
static INT32 nff0004 = 0;
|
||||
|
||||
|
||||
static inline INT32 NeoCurrentScanline()
|
||||
{
|
||||
return (SekCurrentScanline() + 248) % 264;
|
||||
}
|
||||
|
||||
static inline INT32 NeoCurrentScanlineOffset()
|
||||
{
|
||||
return SekTotalCycles() - SekCurrentScanline() * nSekCyclesScanline;
|
||||
}
|
||||
|
||||
bool IsNeoGeoCD() {
|
||||
//return (nNeoSystemType & NEO_SYS_CD);
|
||||
return ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_NEOCD);
|
||||
@ -1811,7 +1821,7 @@ static inline void NeoIRQUpdate(UINT16 wordValue)
|
||||
{
|
||||
nIRQAcknowledge |= (wordValue & 7);
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T(" - IRQ Ack -> %02X (at line %3i).\n"), nIRQAcknowledge, SekCurrentScanline());
|
||||
// bprintf(PRINT_NORMAL, _T(" - IRQ Ack -> %02X (at line %3i).\n"), nIRQAcknowledge, NeoCurrentScanline());
|
||||
|
||||
if ((nIRQAcknowledge & 7) == 7) {
|
||||
SekSetIRQLine(7, CPU_IRQSTATUS_NONE);
|
||||
@ -1832,7 +1842,7 @@ static inline void NeoCDIRQUpdate(UINT8 byteValue)
|
||||
{
|
||||
nIRQAcknowledge |= (byteValue & 0x38);
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T(" - IRQ Ack -> %02X (CD, at line %3i).\n"), nIRQAcknowledge, SekCurrentScanline());
|
||||
// bprintf(PRINT_NORMAL, _T(" - IRQ Ack -> %02X (CD, at line %3i).\n"), nIRQAcknowledge, NeoCurrentScanline());
|
||||
|
||||
if ((nIRQAcknowledge & 0x3F) == 0x3F) {
|
||||
SekSetIRQLine(7, CPU_IRQSTATUS_NONE);
|
||||
@ -2114,7 +2124,7 @@ static void WriteIO2(INT32 nOffset, UINT8 byteValue)
|
||||
if (nNeoSystemType & NEO_SYS_CART) {
|
||||
NeoRecalcPalette = 1;
|
||||
bNeoDarkenPalette = (nOffset == 0x11) ? 1 : 0;
|
||||
//bprintf(PRINT_NORMAL, _T(" - Darken Palette %X (0x%02X, at scanline %i).\n"), bNeoDarkenPalette, byteValue, SekCurrentScanline());
|
||||
//bprintf(PRINT_NORMAL, _T(" - Darken Palette %X (0x%02X, at scanline %i).\n"), bNeoDarkenPalette, byteValue, NeoCurrentScanline());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2203,7 +2213,7 @@ static void __fastcall neogeoWriteByte(UINT32 sekAddress, UINT8 byteValue)
|
||||
switch (sekAddress & 0xFF0000) {
|
||||
case 0x300000:
|
||||
if ((sekAddress & 1) == 1) {
|
||||
// bprintf(PRINT_NORMAL, " - Watchdog timer reset (%02X, at scanline %i)\n", byteValue, SekCurrentScanline());
|
||||
// bprintf(PRINT_NORMAL, " - Watchdog timer reset (%02X, at scanline %i)\n", byteValue, NeoCurrentScanline());
|
||||
|
||||
#if defined EMULATE_WATCHDOG
|
||||
nNeoWatchdog = -SekTotalCycles();
|
||||
@ -2257,13 +2267,13 @@ static UINT16 __fastcall neogeoReadWordVideo(UINT32 sekAddress)
|
||||
return (UINT16)(nNeoGraphicsModulo >> 1);
|
||||
|
||||
case 0x06: // Display status
|
||||
// bprintf(PRINT_NORMAL, " - Display status read, line: %3i, anim: %i\n", SekCurrentScanline(), nNeoSpriteFrame);
|
||||
// bprintf(PRINT_NORMAL, " - Display status read, line: %3i, anim: %i\n", NeoCurrentScanline(), nNeoSpriteFrame);
|
||||
|
||||
#if 1 && !defined USE_SPEEDHACKS
|
||||
bForcePartialRender |= bForceUpdateOnStatusRead;
|
||||
#endif
|
||||
|
||||
return ((SekCurrentScanline() + nScanlineOffset) << 7) | 0 | (nNeoSpriteFrame & 7);
|
||||
return ((NeoCurrentScanline() + nScanlineOffset) << 7) | 0 | (nNeoSpriteFrame & 7);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -2322,7 +2332,7 @@ static void __fastcall neogeoWriteWordVideo(UINT32 sekAddress, UINT16 wordValue)
|
||||
if ((nIRQControl & 0x10) == 0 && wordValue & 0x10) {
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ enabled (at line %3i, IRQControl: 0x%02X).\n"), SekCurrentScanline(), wordValue & 0xFF);
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ enabled (at line %3i, IRQControl: 0x%02X).\n"), NeoCurrentScanline(), wordValue & 0xFF);
|
||||
#endif
|
||||
|
||||
if (nIRQCycles < nCyclesSegment) {
|
||||
@ -2332,13 +2342,13 @@ static void __fastcall neogeoWriteWordVideo(UINT32 sekAddress, UINT16 wordValue)
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
if (nIRQControl & 0x10 && (wordValue & 0x10) == 0) {
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ disabled (at line %3i, IRQControl: 0x%02X).\n"), SekCurrentScanline(), wordValue & 0xFF);
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ disabled (at line %3i, IRQControl: 0x%02X).\n"), NeoCurrentScanline(), wordValue & 0xFF);
|
||||
}
|
||||
#endif
|
||||
|
||||
nIRQControl = wordValue;
|
||||
// bprintf(PRINT_NORMAL, _T(" - Autoanim speed -> 0x%02X\n"), wordValue >> 8);
|
||||
// bprintf(PRINT_NORMAL, _T(" - IRQ control register -> 0x%02X (at line %3i)\n"), wordValue & 0xFF, SekCurrentScanline());
|
||||
// bprintf(PRINT_NORMAL, _T(" - IRQ control register -> 0x%02X (at line %3i)\n"), wordValue & 0xFF, NeoCurrentScanline());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2353,7 +2363,7 @@ static void __fastcall neogeoWriteWordVideo(UINT32 sekAddress, UINT16 wordValue)
|
||||
nIRQOffset = (nIRQOffset & 0xFFFF0000) | wordValue;
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ offs -> 0x%08X (at line %3i, IRQControl: 0x%02X).\n"), nIRQOffset, SekCurrentScanline(), nIRQControl);
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ offs -> 0x%08X (at line %3i, IRQControl: 0x%02X).\n"), nIRQOffset, NeoCurrentScanline(), nIRQControl);
|
||||
#endif
|
||||
|
||||
if (nIRQControl & 0x20) {
|
||||
@ -2366,7 +2376,7 @@ static void __fastcall neogeoWriteWordVideo(UINT32 sekAddress, UINT16 wordValue)
|
||||
nIRQCycles = SekTotalCycles() + NeoConvertIRQPosition(nIRQOffset + 8);
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" IRQ Line -> %3i (at line %3i, relative).\n"), nIRQCycles / nSekCyclesScanline, SekCurrentScanline());
|
||||
bprintf(PRINT_NORMAL, _T(" IRQ Line -> %3i (at line %3i, relative).\n"), nIRQCycles / nSekCyclesScanline, NeoCurrentScanline());
|
||||
#endif
|
||||
|
||||
if (nIRQCycles < 0) {
|
||||
@ -4811,7 +4821,11 @@ INT32 NeoFrame()
|
||||
nuPD4990ATicks = nCyclesExtra[0];
|
||||
|
||||
// Run 68000
|
||||
nCyclesSegment = nSekCyclesScanline * 24;
|
||||
//nCyclesSegment = nSekCyclesScanline * 24;
|
||||
/* Do scanlines: [248, 263] followed by [0, 23] ==
|
||||
* [248, 264) followed by [0, 24)
|
||||
*/
|
||||
nCyclesSegment = nSekCyclesScanline * (16 + 24);
|
||||
while (SekTotalCycles() < nCyclesSegment) {
|
||||
|
||||
if ((nIRQControl & 0x10) && (nIRQCycles < NO_IRQ_PENDING) && (SekTotalCycles() >= nIRQCycles)) {
|
||||
@ -4820,14 +4834,14 @@ INT32 NeoFrame()
|
||||
SekSetIRQLine(nScanlineIRQ, CPU_IRQSTATUS_ACK);
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ triggered (line %3i + %3i cycles).\n"), SekCurrentScanline(), SekTotalCycles() - SekCurrentScanline() * nSekCyclesScanline);
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ triggered (line %3i + %3i cycles).\n"), NeoCurrentScanline(), NeoCurrentScanlineOffset());
|
||||
#endif
|
||||
|
||||
if (nIRQControl & 0x80) {
|
||||
nIRQCycles += NeoConvertIRQPosition(nIRQOffset + 1);
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ Line -> %3i (at line %3i, autoload).\n"), nIRQCycles / nSekCyclesScanline, SekCurrentScanline());
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ Line -> %3i (at line %3i, autoload).\n"), nIRQCycles / nSekCyclesScanline, NeoCurrentScanline());
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -4859,7 +4873,7 @@ INT32 NeoFrame()
|
||||
|
||||
// Display starts here
|
||||
|
||||
nCyclesVBlank = nSekCyclesScanline * 248;
|
||||
nCyclesVBlank = nCyclesTotal[0]; //nSekCyclesScanline * 248;
|
||||
if (bRenderLineByLine) {
|
||||
INT32 nLastIRQ = nIRQCycles - 1;
|
||||
while (SekTotalCycles() < nCyclesVBlank) {
|
||||
@ -4869,13 +4883,13 @@ INT32 NeoFrame()
|
||||
nIRQAcknowledge &= ~2;
|
||||
SekSetIRQLine(nScanlineIRQ, CPU_IRQSTATUS_ACK);
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ triggered (line %3i + %3i cycles).\n"), SekCurrentScanline(), SekTotalCycles() - SekCurrentScanline() * nSekCyclesScanline);
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ triggered (line %3i + %3i cycles).\n"), NeoCurrentScanline(), NeoCurrentScanlineOffset());
|
||||
#endif
|
||||
|
||||
if (nIRQControl & 0x80) {
|
||||
nIRQCycles += NeoConvertIRQPosition(nIRQOffset + 1);
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ Line -> %3i (at line %3i, autoload).\n"), nIRQCycles / nSekCyclesScanline, SekCurrentScanline());
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ Line -> %3i (at line %3i, autoload).\n"), nIRQCycles / nSekCyclesScanline, NeoCurrentScanline());
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -4883,12 +4897,12 @@ INT32 NeoFrame()
|
||||
bForcePartialRender = bRenderImage;
|
||||
if (bForcePartialRender) {
|
||||
nSliceStart = nSliceEnd;
|
||||
nSliceEnd = SekCurrentScanline() - 5 + NEO_RASTER_IRQ_TWEAK;
|
||||
nSliceEnd = NeoCurrentScanline() - 5 + NEO_RASTER_IRQ_TWEAK;
|
||||
}
|
||||
} else {
|
||||
if (bForcePartialRender) {
|
||||
nSliceStart = nSliceEnd;
|
||||
nSliceEnd = SekCurrentScanline() - 6 + NEO_RASTER_IRQ_TWEAK;
|
||||
nSliceEnd = NeoCurrentScanline() - 6 + NEO_RASTER_IRQ_TWEAK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4928,14 +4942,14 @@ INT32 NeoFrame()
|
||||
SekSetIRQLine(nScanlineIRQ, CPU_IRQSTATUS_ACK);
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ triggered (line %3i + %3i cycles).\n"), SekCurrentScanline(), SekTotalCycles() - SekCurrentScanline() * nSekCyclesScanline);
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ triggered (line %3i + %3i cycles).\n"), NeoCurrentScanline(), NeoCurrentScanlineOffset());
|
||||
#endif
|
||||
|
||||
if (nIRQControl & 0x80) {
|
||||
nIRQCycles += NeoConvertIRQPosition(nIRQOffset + 1);
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ Line -> %3i (at line %3i, autoload).\n"), nIRQCycles / nSekCyclesScanline, SekCurrentScanline());
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ Line -> %3i (at line %3i, autoload).\n"), nIRQCycles / nSekCyclesScanline, NeoCurrentScanline());
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -4949,7 +4963,7 @@ INT32 NeoFrame()
|
||||
if (bForcePartialRender) {
|
||||
|
||||
nSliceStart = nSliceEnd;
|
||||
nSliceEnd = SekCurrentScanline() - 5 + NEO_RASTER_IRQ_TWEAK;
|
||||
nSliceEnd = NeoCurrentScanline() - 5 + NEO_RASTER_IRQ_TWEAK;
|
||||
|
||||
if (nSliceEnd > 240) {
|
||||
nSliceEnd = 240;
|
||||
@ -5009,39 +5023,11 @@ INT32 NeoFrame()
|
||||
}
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ Line -> %3i (at line %3i, VBlank).\n"), nIRQCycles / nSekCyclesScanline, SekCurrentScanline());
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ Line -> %3i (at line %3i, VBlank).\n"), nIRQCycles / nSekCyclesScanline, NeoCurrentScanline());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
nCyclesSegment = nCyclesTotal[0];
|
||||
while (SekTotalCycles() < nCyclesSegment) {
|
||||
|
||||
if ((nIRQControl & 0x10) && (nIRQCycles < NO_IRQ_PENDING) && (SekTotalCycles() >= nIRQCycles)) {
|
||||
nIRQAcknowledge &= ~2;
|
||||
SekSetIRQLine(nScanlineIRQ, CPU_IRQSTATUS_ACK);
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ triggered (line %3i + %3i cycles).\n"), SekCurrentScanline(), SekTotalCycles() - SekCurrentScanline() * nSekCyclesScanline);
|
||||
#endif
|
||||
|
||||
if (nIRQControl & 0x80) {
|
||||
nIRQCycles += NeoConvertIRQPosition(nIRQOffset + 1);
|
||||
|
||||
#if 0 || defined LOG_IRQ
|
||||
bprintf(PRINT_NORMAL, _T(" - IRQ Line -> %3i (at line %3i, autoload).\n"), nIRQCycles / nSekCyclesScanline, SekCurrentScanline());
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (nCyclesSegment < nIRQCycles || SekTotalCycles() >= nIRQCycles) {
|
||||
NeoSekRun(nCyclesSegment - SekTotalCycles());
|
||||
} else {
|
||||
NeoSekRun(nIRQCycles - SekTotalCycles());
|
||||
}
|
||||
}
|
||||
|
||||
if (nIRQCycles < NO_IRQ_PENDING) {
|
||||
nIRQCycles -= nCyclesTotal[0];
|
||||
if (nIRQCycles < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user