mirror of
https://github.com/libretro/Genesis-Plus-GX.git
synced 2024-11-23 00:09:43 +00:00
Merge branch 'ekeeke:master' into master
This commit is contained in:
commit
cbacea7236
@ -58,9 +58,10 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke)
|
||||
* fixed byte access to font data registers
|
||||
* fixed memory mode register bits masking when read from MAIN-CPU and SUB-CPU (verified on real hardware, cf. Krikzz's mcd-verificator)
|
||||
* fixed pending level 1 interrupts when GFX interrupt is disabled (fixes random freezes when exiting "Batman Returns" option menu)
|
||||
* fixed CDD seek command again (Final Fight CD freeze with model 2 BIOS)
|
||||
* fixed CDD seek command again (fixes Final Fight CD freeze with model 2 BIOS)
|
||||
* fixed CDD status reported during seek/access time (fixes sound effect synchronization issue in Bari Arm)
|
||||
* fixed CDD position reset when disc is stopped (fixes random freezes in Spiderman vs Kingpin when switching between audio tracks)
|
||||
* fixed CDD seeking start delay (fixes Radical Rex incorrect PRG-RAM & Word-RAM initialization, causing missing sprites during intro) */
|
||||
* fixed word access to CDD control register (fixes spurious audio track playback on startup with Mode 1 patched games using MSU-MD driver)
|
||||
* fixed CD communication registers state on peripheral reset (fixes SUB-CPU side initialization in MSU-MD sample demo and some Mode 1 patched games using MSU-MD driver)
|
||||
* fixed 32x32 pixels stamp index masking during GFX operation (fixes graphics rotation/scaling effects in "Chuck Rock II - Son of Chuck")
|
||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 3.8 MiB After Width: | Height: | Size: 3.8 MiB |
Binary file not shown.
Before Width: | Height: | Size: 4.0 MiB After Width: | Height: | Size: 4.0 MiB |
@ -2,7 +2,7 @@
|
||||
* Genesis Plus
|
||||
* Mega Drive cartridge hardware support
|
||||
*
|
||||
* Copyright (C) 2007-2023 Eke-Eke (Genesis Plus GX)
|
||||
* Copyright (C) 2007-2024 Eke-Eke (Genesis Plus GX)
|
||||
*
|
||||
* Many cartridge protections were initially documented by Haze
|
||||
* (http://haze.mameworld.info/)
|
||||
@ -465,7 +465,10 @@ void md_cart_init(void)
|
||||
memset(&cart.hw, 0, sizeof(cart.hw));
|
||||
|
||||
/* initialize default $200000-$20ffff mapping (for games using SRAM & ROM bankswitching) */
|
||||
cart.hw.regs[0] = (0x200000 & cart.mask) >> 16;
|
||||
if (m68k.memory_map[0x20].base == sram.sram)
|
||||
{
|
||||
cart.hw.regs[0] = (0x200000 & cart.mask) >> 16;
|
||||
}
|
||||
|
||||
/* search for game into database */
|
||||
for (i=0; i<(sizeof(rom_database)/sizeof(md_entry_t)); i++)
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Genesis Plus
|
||||
* Mega Drive cartridge hardware support
|
||||
*
|
||||
* Copyright (C) 2007-2023 Eke-Eke (Genesis Plus GX)
|
||||
* Copyright (C) 2007-2024 Eke-Eke (Genesis Plus GX)
|
||||
*
|
||||
* Most cartridge protections were initially documented by Haze
|
||||
* (http://haze.mameworld.info/)
|
||||
|
196
core/cd_hw/cdd.c
196
core/cd_hw/cdd.c
@ -1936,6 +1936,79 @@ void cdd_update(void)
|
||||
/* udpate current track index */
|
||||
cdd.index = index;
|
||||
}
|
||||
|
||||
/* seeking should start with at least one interrupt delay (fixes Radical Rex incorrect PRG-RAM & Word-RAM initialization, causing missing sprites during intro) */
|
||||
if (scd.regs[0x38>>1].byte.h == CD_SEEK)
|
||||
{
|
||||
/* reset track index */
|
||||
int index = 0;
|
||||
|
||||
/* new LBA position */
|
||||
int lba = ((scd.regs[0x44>>1].byte.h * 10 + scd.regs[0x44>>1].byte.l) * 60 +
|
||||
(scd.regs[0x46>>1].byte.h * 10 + scd.regs[0x46>>1].byte.l)) * 75 +
|
||||
(scd.regs[0x48>>1].byte.h * 10 + scd.regs[0x48>>1].byte.l) - 150;
|
||||
|
||||
/* CD drive latency */
|
||||
if (!cdd.latency)
|
||||
{
|
||||
/* Fixes a few games hanging because they expect data to be read with some delay */
|
||||
/* Wolf Team games (Annet Futatabi, Aisle Lord, Cobra Command, Earnest Evans, Road Avenger & Time Gal) need at least 11 interrupts delay */
|
||||
/* Space Adventure Cobra (2nd morgue scene) needs at least 13 interrupts delay (incl. seek time, so 11 is OK) */
|
||||
/* By default, at least two interrupts latency is required by current emulation model (BIOS hangs otherwise) */
|
||||
cdd.latency = 2 + 9*config.cd_latency;
|
||||
}
|
||||
|
||||
/* CD drive seek time */
|
||||
/* max. seek time = 1.5 s = 1.5 x 75 = 112.5 CDD interrupts (rounded to 120) for 270000 sectors max on disc. */
|
||||
/* Note: This is only a rough approximation since, on real hardware, seek time is much likely not linear and */
|
||||
/* latency much larger than above value, but this model works fine for Sonic CD (track 26 playback needs to */
|
||||
/* be enough delayed to start in sync with intro sequence, as compared with real hardware recording). */
|
||||
/* It also works fine for Switch/Panic! intro (at least 30 interrupts are needed while seeking from 00:05:63 */
|
||||
/* to 24:03:19 in Switch or when seeking from 00:05:60 to 24:06:07 in Panic!). */
|
||||
if (lba > cdd.lba)
|
||||
{
|
||||
cdd.latency += (((lba - cdd.lba) * 120 * config.cd_latency) / 270000);
|
||||
}
|
||||
else
|
||||
{
|
||||
cdd.latency += (((cdd.lba - lba) * 120 * config.cd_latency) / 270000);
|
||||
}
|
||||
|
||||
/* update current LBA */
|
||||
cdd.lba = lba;
|
||||
|
||||
/* get track index */
|
||||
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last))
|
||||
index++;
|
||||
|
||||
/* audio track ? */
|
||||
if (cdd.toc.tracks[index].type == TYPE_AUDIO)
|
||||
{
|
||||
/* stay within track limits when seeking files */
|
||||
if (lba < cdd.toc.tracks[index].start)
|
||||
{
|
||||
lba = cdd.toc.tracks[index].start;
|
||||
}
|
||||
|
||||
/* seek to current track sector */
|
||||
cdd_seek_audio(index, lba);
|
||||
}
|
||||
|
||||
/* update current track index */
|
||||
cdd.index = index;
|
||||
|
||||
/* seek to current subcode position */
|
||||
if (cdd.toc.sub)
|
||||
{
|
||||
cdStreamSeek(cdd.toc.sub, lba * 96, SEEK_SET);
|
||||
}
|
||||
|
||||
/* no audio track playing (yet) */
|
||||
scd.regs[0x36>>1].byte.h = 0x01;
|
||||
|
||||
/* update CDD status to either PLAY or PAUSE depending on host command (will be reported to host once seeking has ended) */
|
||||
cdd.status = scd.regs[0x42>>1].byte.h & 0x05;
|
||||
}
|
||||
}
|
||||
|
||||
void cdd_process(void)
|
||||
@ -2112,73 +2185,7 @@ void cdd_process(void)
|
||||
|
||||
case 0x03: /* Play */
|
||||
{
|
||||
/* reset track index */
|
||||
int index = 0;
|
||||
|
||||
/* new LBA position */
|
||||
int lba = ((scd.regs[0x44>>1].byte.h * 10 + scd.regs[0x44>>1].byte.l) * 60 +
|
||||
(scd.regs[0x46>>1].byte.h * 10 + scd.regs[0x46>>1].byte.l)) * 75 +
|
||||
(scd.regs[0x48>>1].byte.h * 10 + scd.regs[0x48>>1].byte.l) - 150;
|
||||
|
||||
/* CD drive latency */
|
||||
if (!cdd.latency)
|
||||
{
|
||||
/* Fixes a few games hanging because they expect data to be read with some delay */
|
||||
/* Wolf Team games (Annet Futatabi, Aisle Lord, Cobra Command, Earnest Evans, Road Avenger & Time Gal) need at least 11 interrupts delay */
|
||||
/* Space Adventure Cobra (2nd morgue scene) needs at least 13 interrupts delay (incl. seek time, so 11 is OK) */
|
||||
/* By default, at least two interrupts latency is required by current emulation model (BIOS hangs otherwise) */
|
||||
cdd.latency = 2 + 9*config.cd_latency;
|
||||
}
|
||||
|
||||
/* CD drive seek time */
|
||||
/* max. seek time = 1.5 s = 1.5 x 75 = 112.5 CDD interrupts (rounded to 120) for 270000 sectors max on disc. */
|
||||
/* Note: This is only a rough approximation since, on real hardware, seek time is much likely not linear and */
|
||||
/* latency much larger than above value, but this model works fine for Sonic CD (track 26 playback needs to */
|
||||
/* be enough delayed to start in sync with intro sequence, as compared with real hardware recording). */
|
||||
if (lba > cdd.lba)
|
||||
{
|
||||
cdd.latency += (((lba - cdd.lba) * 120 * config.cd_latency) / 270000);
|
||||
}
|
||||
else
|
||||
{
|
||||
cdd.latency += (((cdd.lba - lba) * 120 * config.cd_latency) / 270000);
|
||||
}
|
||||
|
||||
/* update current LBA */
|
||||
cdd.lba = lba;
|
||||
|
||||
/* get track index */
|
||||
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
||||
|
||||
/* audio track ? */
|
||||
if (cdd.toc.tracks[index].type == TYPE_AUDIO)
|
||||
{
|
||||
/* stay within track limits when seeking files */
|
||||
if (lba < cdd.toc.tracks[index].start)
|
||||
{
|
||||
lba = cdd.toc.tracks[index].start;
|
||||
}
|
||||
|
||||
/* seek to current track sector */
|
||||
cdd_seek_audio(index, lba);
|
||||
}
|
||||
|
||||
/* update current track index */
|
||||
cdd.index = index;
|
||||
|
||||
/* seek to current subcode position */
|
||||
if (cdd.toc.sub)
|
||||
{
|
||||
cdStreamSeek(cdd.toc.sub, lba * 96, SEEK_SET);
|
||||
}
|
||||
|
||||
/* no audio track playing (yet) */
|
||||
scd.regs[0x36>>1].byte.h = 0x01;
|
||||
|
||||
/* update status (reported to host once seeking has ended) */
|
||||
cdd.status = CD_PLAY;
|
||||
|
||||
/* RS0 should indicates seeking until drive is ready (fixes audio delay in Bari Arm) */
|
||||
/* RS0 should indicate seeking until drive is ready (fixes audio delay in Bari Arm) */
|
||||
/* RS1=0xf to invalidate track infos in RS2-RS8 until drive is ready (fixes Snatcher Act 2 start cutscene) */
|
||||
scd.regs[0x38>>1].w = (CD_SEEK << 8) | 0x0f;
|
||||
scd.regs[0x3a>>1].w = 0x0000;
|
||||
@ -2190,61 +2197,6 @@ void cdd_process(void)
|
||||
|
||||
case 0x04: /* Seek */
|
||||
{
|
||||
/* reset track index */
|
||||
int index = 0;
|
||||
|
||||
/* new LBA position */
|
||||
int lba = ((scd.regs[0x44>>1].byte.h * 10 + scd.regs[0x44>>1].byte.l) * 60 +
|
||||
(scd.regs[0x46>>1].byte.h * 10 + scd.regs[0x46>>1].byte.l)) * 75 +
|
||||
(scd.regs[0x48>>1].byte.h * 10 + scd.regs[0x48>>1].byte.l) - 150;
|
||||
|
||||
/* CD drive seek time */
|
||||
/* We are using similar linear model as above, although still not exactly accurate, */
|
||||
/* it works fine for Switch/Panic! intro (Switch needs at least 30 interrupts while */
|
||||
/* seeking from 00:05:63 to 24:03:19, Panic! when seeking from 00:05:60 to 24:06:07) */
|
||||
if (lba > cdd.lba)
|
||||
{
|
||||
cdd.latency = ((lba - cdd.lba) * 120 * config.cd_latency) / 270000;
|
||||
}
|
||||
else
|
||||
{
|
||||
cdd.latency = ((cdd.lba - lba) * 120 * config.cd_latency) / 270000;
|
||||
}
|
||||
|
||||
/* update current LBA */
|
||||
cdd.lba = lba;
|
||||
|
||||
/* get current track index */
|
||||
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
||||
|
||||
/* audio track ? */
|
||||
if (cdd.toc.tracks[index].type == TYPE_AUDIO)
|
||||
{
|
||||
/* stay within track limits when seeking files */
|
||||
if (lba < cdd.toc.tracks[index].start)
|
||||
{
|
||||
lba = cdd.toc.tracks[index].start;
|
||||
}
|
||||
|
||||
/* seek to current track sector */
|
||||
cdd_seek_audio(index, lba);
|
||||
}
|
||||
|
||||
/* update current track index */
|
||||
cdd.index = index;
|
||||
|
||||
/* seek to current subcode position */
|
||||
if (cdd.toc.sub)
|
||||
{
|
||||
cdStreamSeek(cdd.toc.sub, lba * 96, SEEK_SET);
|
||||
}
|
||||
|
||||
/* no audio track playing */
|
||||
scd.regs[0x36>>1].byte.h = 0x01;
|
||||
|
||||
/* update status (reported to host once seeking has ended) */
|
||||
cdd.status = CD_PAUSE;
|
||||
|
||||
/* RS1=0xf to invalidate track infos in RS2-RS8 while seeking (fixes Final Fight CD intro when seek time is emulated) */
|
||||
scd.regs[0x38>>1].w = (CD_SEEK << 8) | 0x0f;
|
||||
scd.regs[0x3a>>1].w = 0x0000;
|
||||
|
@ -480,4 +480,4 @@ void input_end_frame(unsigned int cycles)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ void m68k_run(unsigned int cycles)
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
/* Trigger execution hook */
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_M68K_E, 0, REG_PC, 0);
|
||||
#endif
|
||||
|
||||
|
@ -859,7 +859,7 @@ INLINE uint m68ki_read_8(uint address)
|
||||
else val = READ_BYTE(temp->base, (address) & 0xffff);
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_M68K_R, 1, address, val);
|
||||
#endif
|
||||
|
||||
@ -879,7 +879,7 @@ INLINE uint m68ki_read_16(uint address)
|
||||
else val = *(uint16 *)(temp->base + ((address) & 0xffff));
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_M68K_R, 2, address, val);
|
||||
#endif
|
||||
|
||||
@ -899,7 +899,7 @@ INLINE uint m68ki_read_32(uint address)
|
||||
else val = m68k_read_immediate_32(address);
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_M68K_R, 4, address, val);
|
||||
#endif
|
||||
|
||||
@ -913,7 +913,7 @@ INLINE void m68ki_write_8(uint address, uint value)
|
||||
m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_DATA) /* auto-disable (see m68kcpu.h) */
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_M68K_W, 1, address, value);
|
||||
#endif
|
||||
|
||||
@ -930,7 +930,7 @@ INLINE void m68ki_write_16(uint address, uint value)
|
||||
m68ki_check_address_error(address, MODE_WRITE, FLAG_S | FUNCTION_CODE_USER_DATA); /* auto-disable (see m68kcpu.h) */
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_M68K_W, 2, address, value);
|
||||
#endif
|
||||
|
||||
@ -947,7 +947,7 @@ INLINE void m68ki_write_32(uint address, uint value)
|
||||
m68ki_check_address_error(address, MODE_WRITE, FLAG_S | FUNCTION_CODE_USER_DATA) /* auto-disable (see m68kcpu.h) */
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_M68K_W, 4, address, value);
|
||||
#endif
|
||||
|
||||
|
@ -53,6 +53,15 @@
|
||||
#define ALIGNED_(x) __attribute__ ((aligned(x)))
|
||||
#endif
|
||||
|
||||
/* Provide the compiler with branch prediction information */
|
||||
#if defined(__GNUC__)
|
||||
#define LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define LIKELY(x) x
|
||||
#define UNLIKELY(x) x
|
||||
#endif
|
||||
|
||||
/* Default CD image file access (read-only) functions */
|
||||
/* If you need to override default stdio.h functions with custom filesystem API,
|
||||
redefine following macros in platform specific include file (osd.h) or Makefile
|
||||
|
@ -2197,7 +2197,7 @@ static void vdp_bus_w(unsigned int data)
|
||||
}
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_VRAM_W, 2, addr, data);
|
||||
#endif
|
||||
|
||||
@ -2246,7 +2246,7 @@ static void vdp_bus_w(unsigned int data)
|
||||
}
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_CRAM_W, 2, addr, data);
|
||||
#endif
|
||||
|
||||
@ -2272,7 +2272,7 @@ static void vdp_bus_w(unsigned int data)
|
||||
}
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_VSRAM_W, 2, addr, data);
|
||||
#endif
|
||||
|
||||
@ -2483,7 +2483,7 @@ static unsigned int vdp_68k_data_r_m5(void)
|
||||
data = *(uint16 *)&vram[addr & 0xFFFE];
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_VRAM_R, 2, addr, data);
|
||||
#endif
|
||||
|
||||
@ -2512,7 +2512,7 @@ static unsigned int vdp_68k_data_r_m5(void)
|
||||
data |= (fifo[fifo_idx] & ~0x7FF);
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_VSRAM_R, 2, addr, data);
|
||||
#endif
|
||||
|
||||
@ -2534,7 +2534,7 @@ static unsigned int vdp_68k_data_r_m5(void)
|
||||
data |= (fifo[fifo_idx] & ~0xEEE);
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_CRAM_R, 2, addr, data);
|
||||
#endif
|
||||
|
||||
@ -2553,7 +2553,7 @@ static unsigned int vdp_68k_data_r_m5(void)
|
||||
data |= (fifo[fifo_idx] & ~0xFF);
|
||||
|
||||
#ifdef HOOK_CPU
|
||||
if (cpu_hook)
|
||||
if (UNLIKELY(cpu_hook))
|
||||
cpu_hook(HOOK_VRAM_R, 2, addr, data);
|
||||
#endif
|
||||
|
||||
|
@ -41,6 +41,14 @@ ifneq ($(OS),Windows_NT)
|
||||
DEFINES += -DHAVE_ALLOCA_H
|
||||
endif
|
||||
|
||||
ifneq ($(findstring Darwin,$(shell uname -a)),)
|
||||
platform = osx
|
||||
endif
|
||||
|
||||
ifeq ($(platform), osx)
|
||||
CFLAGS += -Winvalid-utf8 -Wstrict-prototypes
|
||||
endif
|
||||
|
||||
SRCDIR = ../core
|
||||
INCLUDES = -I$(SRCDIR) -I$(SRCDIR)/z80 -I$(SRCDIR)/m68k -I$(SRCDIR)/sound -I$(SRCDIR)/input_hw -I$(SRCDIR)/cart_hw -I$(SRCDIR)/cart_hw/svp -I$(SRCDIR)/cd_hw -I$(SRCDIR)/ntsc -I$(SRCDIR)/tremor -I$(SRCDIR)/../sdl -I$(SRCDIR)/../sdl/sdl2
|
||||
LIBS = `sdl2-config --libs` -lz -lm
|
||||
|
@ -2,7 +2,7 @@
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
||||
#include "shared.h"
|
||||
#include "types.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Config Option
|
||||
|
Loading…
Reference in New Issue
Block a user