mednapce - lag flag, some more memory domains, some ppu view work
This commit is contained in:
parent
c467023dac
commit
0891e448d7
Binary file not shown.
|
@ -12,7 +12,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
public partial class PceBgViewer : ToolFormBase, IToolFormAutoConfig
|
||||
{
|
||||
[RequiredService]
|
||||
private PCEngine PCE { get; set; }
|
||||
public IPceGpuView Viewer { get; private set; }
|
||||
[RequiredService]
|
||||
public IEmulator Emulator { get; private set; }
|
||||
|
||||
[ConfigPersist]
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
|
@ -32,48 +34,52 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public unsafe void Generate()
|
||||
{
|
||||
if (PCE.Frame % RefreshRate.Value != 0)
|
||||
if (Emulator.Frame % RefreshRate.Value != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var vdc = _vdcType == 0 ? PCE.VDC1 : PCE.VDC2;
|
||||
|
||||
var width = 8 * vdc.BatWidth;
|
||||
var height = 8 * vdc.BatHeight;
|
||||
var buf = canvas.Bat.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, canvas.Bat.PixelFormat);
|
||||
var pitch = buf.Stride / 4;
|
||||
var begin = (int*)buf.Scan0.ToPointer();
|
||||
|
||||
int* p = begin;
|
||||
for (int y = 0; y < height; ++y)
|
||||
Viewer.GetGpuData(_vdcType, view =>
|
||||
{
|
||||
int yTile = y / 8;
|
||||
int yOfs = y % 8;
|
||||
for (int x = 0; x < width; ++x, ++p)
|
||||
{
|
||||
int xTile = x / 8;
|
||||
int xOfs = x % 8;
|
||||
int tileNo = vdc.VRAM[(ushort)(((yTile * vdc.BatWidth) + xTile))] & 0x07FF;
|
||||
int paletteNo = vdc.VRAM[(ushort)(((yTile * vdc.BatWidth) + xTile))] >> 12;
|
||||
int paletteBase = paletteNo * 16;
|
||||
var width = 8 * view.BatWidth;
|
||||
var height = 8 * view.BatHeight;
|
||||
var buf = canvas.Bat.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, canvas.Bat.PixelFormat);
|
||||
var pitch = buf.Stride / 4;
|
||||
var begin = (int*)buf.Scan0.ToPointer();
|
||||
var vram = (ushort*)view.Vram;
|
||||
var patternBuffer = (byte*)view.BackgroundCache;
|
||||
var palette = (int*)view.PaletteCache;
|
||||
|
||||
byte c = vdc.PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs];
|
||||
if (c == 0)
|
||||
int* p = begin;
|
||||
for (int y = 0; y < height; ++y)
|
||||
{
|
||||
int yTile = y / 8;
|
||||
int yOfs = y % 8;
|
||||
for (int x = 0; x < width; ++x, ++p)
|
||||
{
|
||||
*p = PCE.VCE.Palette[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
*p = PCE.VCE.Palette[paletteBase + c];
|
||||
int xTile = x / 8;
|
||||
int xOfs = x % 8;
|
||||
int tileNo = vram[(ushort)(((yTile * view.BatWidth) + xTile))] & 0x07FF;
|
||||
int paletteNo = vram[(ushort)(((yTile * view.BatWidth) + xTile))] >> 12;
|
||||
int paletteBase = paletteNo * 16;
|
||||
|
||||
byte c = patternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs];
|
||||
if (c == 0)
|
||||
{
|
||||
*p = palette[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
*p = palette[paletteBase + c];
|
||||
}
|
||||
}
|
||||
|
||||
p += pitch - width;
|
||||
}
|
||||
|
||||
p += pitch - width;
|
||||
}
|
||||
|
||||
canvas.Bat.UnlockBits(buf);
|
||||
canvas.Refresh();
|
||||
canvas.Bat.UnlockBits(buf);
|
||||
canvas.Refresh();
|
||||
});
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
|
@ -85,7 +91,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
VDC2MenuItem.Enabled = PCE.SystemId == "SGX";
|
||||
VDC2MenuItem.Enabled = Viewer.IsSgx;
|
||||
|
||||
VDC1MenuItem.Checked = _vdcType == 0;
|
||||
VDC2MenuItem.Checked = _vdcType == 1;
|
||||
|
@ -106,16 +112,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
Close();
|
||||
}
|
||||
|
||||
private void Canvas_MouseMove(object sender, MouseEventArgs e)
|
||||
private unsafe void Canvas_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
var vdc = _vdcType == 0 ? PCE.VDC1 : PCE.VDC2;
|
||||
int xTile = e.X / 8;
|
||||
int yTile = e.Y / 8;
|
||||
int tileNo = vdc.VRAM[(ushort)((yTile * vdc.BatWidth) + xTile)] & 0x07FF;
|
||||
int paletteNo = vdc.VRAM[(ushort)((yTile * vdc.BatWidth) + xTile)] >> 12;
|
||||
TileIDLabel.Text = tileNo.ToString();
|
||||
XYLabel.Text = $"{xTile}:{yTile}";
|
||||
PaletteLabel.Text = paletteNo.ToString();
|
||||
Viewer.GetGpuData(_vdcType, view =>
|
||||
{
|
||||
var vram = (ushort*)view.Vram;
|
||||
int xTile = e.X / 8;
|
||||
int yTile = e.Y / 8;
|
||||
int tileNo = vram[(ushort)((yTile * view.BatWidth) + xTile)] & 0x07FF;
|
||||
int paletteNo = vram[(ushort)((yTile * view.BatWidth) + xTile)] >> 12;
|
||||
TileIDLabel.Text = tileNo.ToString();
|
||||
XYLabel.Text = $"{xTile}:{yTile}";
|
||||
PaletteLabel.Text = paletteNo.ToString();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public partial class PceTileViewer : ToolFormBase, IToolFormAutoConfig
|
||||
{
|
||||
[RequiredService]
|
||||
public PCEngine Emu { get; private set; }
|
||||
|
||||
private VDC _vdc;
|
||||
private VCE _vce;
|
||||
public IPceGpuView Viewer { get; private set; }
|
||||
|
||||
private int _bgPalNum;
|
||||
private int _spPalNum;
|
||||
|
@ -67,13 +64,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
unsafe void DrawSprites()
|
||||
{
|
||||
var lockData = bmpViewSP.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
|
||||
int* dest = (int*)lockData.Scan0;
|
||||
int pitch = lockData.Stride / sizeof(int);
|
||||
fixed (byte* src = _vdc.SpriteBuffer)
|
||||
fixed (int* pal = &_vce.Palette[256 + _spPalNum * 16])
|
||||
Viewer.GetGpuData(checkBoxVDC2.Checked ? 1 : 0, view =>
|
||||
{
|
||||
var lockData = bmpViewSP.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
|
||||
int* dest = (int*)lockData.Scan0;
|
||||
int pitch = lockData.Stride / sizeof(int);
|
||||
byte* src = (byte*)view.SpriteCache;
|
||||
int* pal = (int*)view.PaletteCache + 256 + _spPalNum * 16;
|
||||
for (int tile = 0; tile < 512; tile++)
|
||||
{
|
||||
int srcAddr = tile * 256;
|
||||
|
@ -82,20 +80,20 @@ namespace BizHawk.Client.EmuHawk
|
|||
int destAddr = ty * 16 * pitch + tx * 16;
|
||||
Draw16x16(src + srcAddr, dest + destAddr, pitch, pal);
|
||||
}
|
||||
}
|
||||
|
||||
bmpViewSP.BMP.UnlockBits(lockData);
|
||||
bmpViewSP.BMP.UnlockBits(lockData);
|
||||
});
|
||||
}
|
||||
|
||||
unsafe void DrawBacks()
|
||||
{
|
||||
var lockData = bmpViewBG.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
|
||||
int* dest = (int*)lockData.Scan0;
|
||||
int pitch = lockData.Stride / sizeof(int);
|
||||
fixed (byte* src = _vdc.PatternBuffer)
|
||||
fixed (int* pal = &_vce.Palette[0 + _bgPalNum * 16])
|
||||
Viewer.GetGpuData(checkBoxVDC2.Checked ? 1 : 0, view =>
|
||||
{
|
||||
var lockData = bmpViewBG.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
|
||||
int* dest = (int*)lockData.Scan0;
|
||||
int pitch = lockData.Stride / sizeof(int);
|
||||
byte* src = (byte*)view.BackgroundCache;
|
||||
int* pal = (int*)view.PaletteCache + _bgPalNum * 16;
|
||||
for (int tile = 0; tile < 2048; tile++)
|
||||
{
|
||||
int srcAddr = tile * 64;
|
||||
|
@ -104,17 +102,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
int destAddr = ty * 8 * pitch + tx * 8;
|
||||
Draw8x8(src + srcAddr, dest + destAddr, pitch, pal);
|
||||
}
|
||||
}
|
||||
bmpViewBG.BMP.UnlockBits(lockData);
|
||||
bmpViewBG.BMP.UnlockBits(lockData);
|
||||
});
|
||||
}
|
||||
|
||||
unsafe void DrawPalettes()
|
||||
{
|
||||
fixed (int* pal = _vce.Palette)
|
||||
Viewer.GetGpuData(checkBoxVDC2.Checked ? 1 : 0, view =>
|
||||
{
|
||||
int* pal = (int*)view.PaletteCache;
|
||||
DrawPalette(bmpViewBGPal.BMP, pal);
|
||||
DrawPalette(bmpViewSPPal.BMP, pal + 256);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static unsafe void DrawPalette(Bitmap bmp, int* pal)
|
||||
|
@ -140,9 +139,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void Restart()
|
||||
{
|
||||
_vce = Emu.VCE;
|
||||
|
||||
if (Emu.SystemId == "SGX")
|
||||
if (Viewer.IsSgx)
|
||||
{
|
||||
checkBoxVDC2.Enabled = true;
|
||||
}
|
||||
|
@ -157,7 +154,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void CheckBoxVDC2_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
_vdc = checkBoxVDC2.Checked ? Emu.VDC2 : Emu.VDC1;
|
||||
GeneralUpdate();
|
||||
}
|
||||
|
||||
|
@ -215,7 +211,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void PceTileViewer_Load(object sender, EventArgs e)
|
||||
{
|
||||
_vce = Emu.VCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using BizHawk.BizInvoke;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.PCEngine;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
using BizHawk.Emulation.DiscSystem;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
|
||||
{
|
||||
[Core(CoreNames.TurboNyma, "Mednafen Team", true, false, "1.24.3", "", false)]
|
||||
public class TerboGrafix : NymaCore, IRegionable
|
||||
public class TerboGrafix : NymaCore, IRegionable, IPceGpuView
|
||||
{
|
||||
private readonly LibTerboGrafix _terboGrafix;
|
||||
|
||||
[CoreConstructor(new[] { "PCE", "SGX" })]
|
||||
public TerboGrafix(GameInfo game, byte[] rom, CoreComm comm, string extension,
|
||||
NymaSettings settings, NymaSyncSettings syncSettings)
|
||||
: base(comm, "PCE", "PC Engine Controller", settings, syncSettings)
|
||||
{
|
||||
DoInit<LibNymaCore>(game, rom, null, "pce.wbx", extension);
|
||||
_terboGrafix = DoInit<LibTerboGrafix>(game, rom, null, "pce.wbx", extension);
|
||||
}
|
||||
public TerboGrafix(GameInfo game, Disc[] discs, CoreComm comm,
|
||||
NymaSettings settings, NymaSyncSettings syncSettings)
|
||||
|
@ -27,11 +34,10 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
|
|||
firmwares.Add("FIRMWARE:syscard3.pce", comm.CoreFileProvider.GetFirmware("PCECD", "Bios", true));
|
||||
if (types.Contains(DiscType.TurboGECD))
|
||||
firmwares.Add("FIRMWARE:gecard.pce", comm.CoreFileProvider.GetFirmware("PCECD", "GE-Bios", true));
|
||||
DoInit<LibNymaCore>(game, null, discs, "pce.wbx", null, firmwares);
|
||||
_terboGrafix = DoInit<LibTerboGrafix>(game, null, discs, "pce.wbx", null, firmwares);
|
||||
}
|
||||
|
||||
// pce always has two layers, sgx always has 4, and mednafen knows this
|
||||
public override string SystemId => SettingsInfo.LayerNames.Count == 4 ? "SGX" : "PCE";
|
||||
public override string SystemId => IsSgx ? "SGX" : "PCE";
|
||||
|
||||
protected override ICollection<string> HiddenSettings { get; } = new[]
|
||||
{
|
||||
|
@ -42,5 +48,32 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
|
|||
"pce.resamp_rate_error",
|
||||
"pce.vramsize",
|
||||
};
|
||||
|
||||
// pce always has two layers, sgx always has 4, and mednafen knows this
|
||||
public bool IsSgx => SettingsInfo.LayerNames.Count == 4;
|
||||
|
||||
public unsafe void GetGpuData(int vdc, Action<PceGpuData> callback)
|
||||
{
|
||||
using(_exe.EnterExit())
|
||||
{
|
||||
var palScratch = new int[512];
|
||||
var v = new PceGpuData();
|
||||
_terboGrafix.GetVramInfo(v, vdc);
|
||||
fixed(int* p = palScratch)
|
||||
{
|
||||
for (var i = 0; i < 512; i++)
|
||||
p[i] = v.PaletteCache[i] | unchecked((int)0xff000000);
|
||||
v.PaletteCache = p;
|
||||
callback(v);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class LibTerboGrafix : LibNymaCore
|
||||
{
|
||||
[BizImport(CallingConvention.Cdecl, Compatibility = true)]
|
||||
public abstract void GetVramInfo([Out]PceGpuData v, int vdcIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.PCEngine
|
||||
{
|
||||
public interface IPceGpuView : IEmulatorService
|
||||
{
|
||||
bool IsSgx { get; }
|
||||
void GetGpuData(int vdc, Action<PceGpuData> callback);
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe class PceGpuData
|
||||
{
|
||||
public int BatWidth;
|
||||
public int BatHeight;
|
||||
public int* PaletteCache;
|
||||
public byte* BackgroundCache;
|
||||
public byte* SpriteCache;
|
||||
public ushort* Vram;
|
||||
}
|
||||
}
|
|
@ -17,7 +17,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
isPorted: false,
|
||||
isReleased: true)]
|
||||
public sealed partial class PCEngine : IEmulator, ISaveRam, IInputPollable, IVideoLogicalOffsets, IRomInfo,
|
||||
IDebuggable, ISettable<PCEngine.PCESettings, PCEngine.PCESyncSettings>, IDriveLight, ICodeDataLogger
|
||||
IDebuggable, ISettable<PCEngine.PCESettings, PCEngine.PCESyncSettings>, IDriveLight, ICodeDataLogger,
|
||||
IPceGpuView
|
||||
{
|
||||
[CoreConstructor(new[] { "PCE", "SGX" })]
|
||||
public PCEngine(GameInfo game, byte[] rom, object settings, object syncSettings)
|
||||
|
@ -357,8 +358,30 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private ISoundProvider _soundProvider;
|
||||
|
||||
private string Region { get; set; }
|
||||
|
||||
public bool IsSgx => Type == NecSystemType.SuperGrafx;
|
||||
public unsafe void GetGpuData(int vdcIndex, Action<PceGpuData> callback)
|
||||
{
|
||||
var vdc = vdcIndex == 0 ? VDC1 : VDC2;
|
||||
fixed(int* pal = VCE.Palette)
|
||||
fixed(byte* bg = vdc.PatternBuffer)
|
||||
fixed(byte* spr = vdc.SpriteBuffer)
|
||||
fixed(ushort* vram = vdc.VRAM)
|
||||
{
|
||||
callback(new PceGpuData
|
||||
{
|
||||
BatWidth = vdc.BatWidth,
|
||||
BatHeight = vdc.BatHeight,
|
||||
PaletteCache = pal,
|
||||
BackgroundCache = bg,
|
||||
SpriteCache = spr,
|
||||
Vram = vram
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,19 +46,19 @@ DOBJS := $(patsubst $(ROOT_DIR)%,$(DOBJ_DIR)%,$(_OBJS))
|
|||
$(OBJ_DIR)/%.c.o: %.c
|
||||
@echo cc $<
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) -c -o $@ $< $(CCFLAGS) $(CCFLAGS_RELEASE)
|
||||
@$(CC) -c -o $@ $< $(CCFLAGS) $(CCFLAGS_RELEASE) $(PER_FILE_FLAGS_$<)
|
||||
$(OBJ_DIR)/%.cpp.o: %.cpp
|
||||
@echo cxx $<
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) -c -o $@ $< $(CXXFLAGS) $(CXXFLAGS_RELEASE)
|
||||
@$(CC) -c -o $@ $< $(CXXFLAGS) $(CXXFLAGS_RELEASE) $(PER_FILE_FLAGS_$<)
|
||||
$(DOBJ_DIR)/%.c.o: %.c
|
||||
@echo cc $<
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) -c -o $@ $< $(CCFLAGS) $(CCFLAGS_DEBUG)
|
||||
@$(CC) -c -o $@ $< $(CCFLAGS) $(CCFLAGS_DEBUG) $(PER_FILE_FLAGS_$<)
|
||||
$(DOBJ_DIR)/%.cpp.o: %.cpp
|
||||
@echo cxx $<
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) -c -o $@ $< $(CXXFLAGS) $(CXXFLAGS_DEBUG)
|
||||
@$(CC) -c -o $@ $< $(CXXFLAGS) $(CXXFLAGS_DEBUG) $(PER_FILE_FLAGS_$<)
|
||||
|
||||
ifndef NO_WBX_TARGETS
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <emulibc.h>
|
||||
#include "nyma.h"
|
||||
#include <unordered_map>
|
||||
|
||||
enum { SETTING_VALUE_MAX_LENGTH = 256 };
|
||||
|
||||
|
@ -18,6 +20,21 @@ ECL_EXPORT void SetFrontendSettingQuery(void (*q)(const char* setting, char* des
|
|||
FrontendSettingQuery = q;
|
||||
}
|
||||
|
||||
static std::unordered_map<uint32_t, CheatArea> CheatAreas;
|
||||
|
||||
CheatArea* FindCheatArea(uint32_t address)
|
||||
{
|
||||
auto kvp = CheatAreas.find(address);
|
||||
if (kvp != CheatAreas.end())
|
||||
{
|
||||
return &kvp->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Mednafen
|
||||
{
|
||||
MDFNGI *MDFNGameInfo = NULL;
|
||||
|
@ -152,7 +169,9 @@ namespace Mednafen
|
|||
void MDFNMP_Init(uint32 ps, uint32 numpages)
|
||||
{}
|
||||
void MDFNMP_AddRAM(uint32 size, uint32 address, uint8 *RAM, bool use_in_search) // Deprecated
|
||||
{}
|
||||
{
|
||||
CheatAreas.insert(std::pair<uint32_t, CheatArea>({ address, CheatArea({ (void*)RAM, size }) }));
|
||||
}
|
||||
void MDFNMP_RegSearchable(uint32 addr, uint32 size)
|
||||
{}
|
||||
void MDFNMP_Kill(void)
|
||||
|
|
|
@ -26,6 +26,8 @@ enum { MAX_PORTS = 16 };
|
|||
enum { MAX_PORT_DATA = 16 };
|
||||
static uint8_t InputPortData[(MAX_PORTS + 1) * MAX_PORT_DATA];
|
||||
|
||||
bool LagFlag;
|
||||
|
||||
ECL_EXPORT void PreInit()
|
||||
{
|
||||
SetupMDFNGameInfo();
|
||||
|
@ -106,6 +108,7 @@ struct MyFrameInfo: public FrameInfo
|
|||
|
||||
ECL_EXPORT void FrameAdvance(MyFrameInfo& frame)
|
||||
{
|
||||
LagFlag = true;
|
||||
EES->skip = frame.SkipRendering;
|
||||
|
||||
if (frame.Command)
|
||||
|
@ -119,6 +122,7 @@ ECL_EXPORT void FrameAdvance(MyFrameInfo& frame)
|
|||
EES->VideoFormatChanged = false;
|
||||
EES->SoundFormatChanged = false;
|
||||
frame.Cycles = EES->MasterCycles;
|
||||
frame.Lagged = LagFlag;
|
||||
if (!frame.SkipSoundening)
|
||||
{
|
||||
memcpy(frame.SoundBuffer, EES->SoundBuf, EES->SoundBufSize * 4);
|
||||
|
|
|
@ -15,7 +15,8 @@ MEDNAFLAGS := \
|
|||
-mindirect-branch=keep \
|
||||
-mno-indirect-branch-register \
|
||||
-Wall -Wshadow -Wempty-body -Wignored-qualifiers \
|
||||
-Wvla -Wvariadic-macros -Wdisabled-optimization -Werror=write-strings
|
||||
-Wvla -Wvariadic-macros -Wdisabled-optimization -Werror=write-strings \
|
||||
-Dprivate=public # the gods have abandoned us
|
||||
|
||||
CCFLAGS := $(MEDNAFLAGS) -std=gnu99
|
||||
CXXFLAGS := $(MEDNAFLAGS) -std=gnu++11
|
||||
|
@ -28,7 +29,6 @@ MODULENAME := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LI
|
|||
MODULENAME := $(MODULENAME:.mak=)
|
||||
|
||||
TARGET := $(MODULENAME).wbx
|
||||
OUT_DIR := obj/$(MODULENAME)
|
||||
|
||||
SRCS := \
|
||||
mednafen/src/error.cpp \
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// the one linked core should set the MDFNGameInfo global
|
||||
void SetupMDFNGameInfo();
|
||||
|
||||
struct CheatArea
|
||||
{
|
||||
void* data;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
// find a previously registered cheatmem area, or null if it does not exist
|
||||
CheatArea* FindCheatArea(uint32_t address);
|
||||
|
||||
extern bool LagFlag;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <waterboxcore.h>
|
||||
#include "mednafen/src/pce/pcecd.h"
|
||||
#include "mednafen/src/pce/huc.h"
|
||||
#include "mednafen/src/pce/vce.h"
|
||||
#include "mednafen/src/hw_misc/arcade_card/arcade_card.h"
|
||||
|
||||
using namespace MDFN_IEN_PCE;
|
||||
|
@ -16,26 +17,6 @@ void SetupMDFNGameInfo()
|
|||
Mednafen::MDFNGameInfo = &EmulatedPCE;
|
||||
}
|
||||
|
||||
static bool IsSgx()
|
||||
{
|
||||
return strcmp(EmulatedPCE.LayerNames, "BG0") == 0;
|
||||
}
|
||||
|
||||
// template<auto ReadFunc, auto WriteFunc>
|
||||
// static void AccessFunc(uint8_t* buffer, int64_t address, int64_t count, bool write)
|
||||
// {
|
||||
// if (write)
|
||||
// {
|
||||
// while (count--)
|
||||
// WriteFunc(address++, *buffer++);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// while (count--)
|
||||
// *buffer++ = ReadFunc(address++);
|
||||
// }
|
||||
// }
|
||||
|
||||
#define DEFUN(N,R,W)\
|
||||
static void Access##N(uint8_t* buffer, int64_t address, int64_t count, bool write)\
|
||||
{\
|
||||
|
@ -66,38 +47,47 @@ static void Access##N(uint8_t* buffer, int64_t address, int64_t count, bool writ
|
|||
namespace MDFN_IEN_PCE
|
||||
{
|
||||
extern ArcadeCard* arcade_card;
|
||||
extern VCE* vce;
|
||||
uint8 ZZINPUT_Read(int32 timestamp, unsigned int A);
|
||||
uint8 INPUT_Read(int32 timestamp, unsigned int A)
|
||||
{
|
||||
LagFlag = false;
|
||||
return ZZINPUT_Read(timestamp, A);
|
||||
}
|
||||
}
|
||||
|
||||
DEFUN(ShortBus, HuCPU.PeekLogical, HuCPU.PokeLogical);
|
||||
DEFUN(LongBus, HuCPU.PeekPhysical, HuCPU.PokePhysical);
|
||||
DEFUN(MainMemory, PCE_PeekMainRAM, PCE_PokeMainRAM);
|
||||
// DEFUN(ShortBus, HuCPU.PeekLogical, HuCPU.PokeLogical);
|
||||
// DEFUN(LongBus, HuCPU.PeekPhysical, HuCPU.PokePhysical);
|
||||
DEFUN(BRAM, HuC_PeekBRAM, HuC_PokeBRAM);
|
||||
DEFRG(ADPCM, ADPCM_PeekRAM, ADPCM_PokeRAM);
|
||||
DEFRG(Arcade, arcade_card->PeekRAM, arcade_card->PokeRAM);
|
||||
|
||||
ECL_EXPORT void GetMemoryAreas(MemoryArea* m)
|
||||
{
|
||||
CheatArea* c;
|
||||
int i = 0;
|
||||
|
||||
m[i].Data = (void*)(MemoryFunctionHook)AccessLongBus;
|
||||
m[i].Name = "System Bus (21 bit)";
|
||||
m[i].Size = 1 << 21;
|
||||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
|
||||
i++;
|
||||
// TOOD: These two cause the core to assert with a timestamp problem?
|
||||
// m[i].Data = (void*)(MemoryFunctionHook)AccessLongBus;
|
||||
// m[i].Name = "System Bus (21 bit)";
|
||||
// m[i].Size = 1 << 21;
|
||||
// m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
|
||||
// i++;
|
||||
|
||||
m[i].Data = (void*)(MemoryFunctionHook)AccessShortBus;
|
||||
m[i].Name = "System Bus";
|
||||
m[i].Size = 1 << 16;
|
||||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
|
||||
i++;
|
||||
// m[i].Data = (void*)(MemoryFunctionHook)AccessShortBus;
|
||||
// m[i].Name = "System Bus";
|
||||
// m[i].Size = 1 << 16;
|
||||
// m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
|
||||
// i++;
|
||||
|
||||
m[i].Data = (void*)(MemoryFunctionHook)AccessMainMemory;
|
||||
c = FindCheatArea(0xf8 * 8192);
|
||||
m[i].Data = c->data;
|
||||
m[i].Name = "Main Memory";
|
||||
m[i].Size = IsSgx() ? 32768 : 8192;
|
||||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK | MEMORYAREA_FLAGS_PRIMARY;
|
||||
m[i].Size = c->size;
|
||||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_PRIMARY;
|
||||
i++;
|
||||
|
||||
// TODO: "ROM"
|
||||
// not that important because we have ROM file domain in the frontend
|
||||
|
||||
if (HuC_IsBRAMAvailable())
|
||||
{
|
||||
|
@ -110,7 +100,12 @@ ECL_EXPORT void GetMemoryAreas(MemoryArea* m)
|
|||
|
||||
if (PCE_IsCD)
|
||||
{
|
||||
// TODO: "TurboCD RAM" (var CDRAM)
|
||||
c = FindCheatArea(0x80 * 8192);
|
||||
m[i].Data = c->data;
|
||||
m[i].Name = "TurboCD RAM";
|
||||
m[i].Size = c->size;
|
||||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1;
|
||||
i++;
|
||||
|
||||
m[i].Data = (void*)(MemoryFunctionHook)AccessADPCM;
|
||||
m[i].Name = "ADPCM RAM";
|
||||
|
@ -118,21 +113,61 @@ ECL_EXPORT void GetMemoryAreas(MemoryArea* m)
|
|||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
|
||||
i++;
|
||||
|
||||
// TODO: "Super System Card RAM"
|
||||
// if (HuCPU.ReadMap[0x68] == SysCardRAMRead)
|
||||
// {}
|
||||
c = FindCheatArea(0x68 * 8192);
|
||||
if (c)
|
||||
{
|
||||
m[i].Data = c->data;
|
||||
m[i].Name = "Super System Card RAM";
|
||||
m[i].Size = c->size;
|
||||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (arcade_card)
|
||||
{
|
||||
m[i].Data = (void*)(MemoryFunctionHook)AccessArcade;
|
||||
m[i].Data = arcade_card->ACRAM;
|
||||
m[i].Name = "Arcade Card RAM";
|
||||
m[i].Size = 1 << 16;
|
||||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
|
||||
m[i].Size = sizeof(arcade_card->ACRAM);
|
||||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: "Cart Battery RAM"
|
||||
// if (IsPopulous)
|
||||
// {}
|
||||
c = FindCheatArea(0x40 * 8192);
|
||||
if (c)
|
||||
{
|
||||
// populous
|
||||
m[i].Data = c->data;
|
||||
m[i].Name = "Cart Battery RAM";
|
||||
m[i].Size = c->size;
|
||||
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
struct VramInfo
|
||||
{
|
||||
int32_t BatWidth;
|
||||
int32_t BatHeight;
|
||||
const uint32_t* PaletteCache;
|
||||
const uint8_t* BackgroundCache;
|
||||
const uint8_t* SpriteCache;
|
||||
const uint16_t* Vram;
|
||||
};
|
||||
|
||||
static uint8_t* SpriteCache;
|
||||
|
||||
static const int bat_width_tab[4] = { 32, 64, 128, 128 };
|
||||
static const int bat_height_tab[2] = { 32, 64 };
|
||||
ECL_EXPORT void GetVramInfo(VramInfo& v, int vdcIndex)
|
||||
{
|
||||
if (!SpriteCache)
|
||||
SpriteCache = (uint8_t*)alloc_invisible(0x20000);
|
||||
auto& vdc = vce->vdc[vdcIndex];
|
||||
v.BatWidth = bat_width_tab[(vdc.MWR >> 4) & 3];
|
||||
v.BatHeight = bat_height_tab[(vdc.MWR >> 6) & 1];
|
||||
v.PaletteCache = vce->color_table_cache;
|
||||
v.BackgroundCache = (uint8_t*)vdc.bg_tile_cache;
|
||||
v.SpriteCache = SpriteCache;
|
||||
v.Vram = vdc.VRAM;
|
||||
}
|
||||
|
|
|
@ -21,4 +21,6 @@ SRCS += \
|
|||
cdrom.cpp \
|
||||
pce.cpp
|
||||
|
||||
PER_FILE_FLAGS_mednafen/src/pce/input.cpp := -DINPUT_Read=ZZINPUT_Read
|
||||
|
||||
include ../common.mak
|
||||
|
|
Loading…
Reference in New Issue