mirror of
https://github.com/par274/sharpemu.git
synced 2026-08-01 15:39:47 +08:00
[AGC] Quake rendering progress: WAIT_REG_MEM, draw fixes, VideoOut, and HLE improvements (#68)
* [agc] WAIT_REG_MEM suspend/resume, draw packet fixes, new HLE exports, debug cleanup
Rebased onto upstream 79a7437 (par274/sharpemu, rewritten history).
- GpuWaitRegistry: DCBs suspended on unsatisfied WAIT_REG_MEM are re-polled
against guest memory on every submit; fixed 64-bit and standard packet parse
offsets, apply the mask, treat PM4 compare function 0 as "always".
- TryReadSubmittedDrawCount: accept the 5-dword ItDrawIndex2 form emitted by
DcbDrawIndex (count at +4); menu draws were silently discarded before.
- sceAgcDriverSubmitMultiDcbs: reversed ABI (rdi=address array, rsi=dword
sizes, rdx=count).
- VideoOut: vblank events, sceVideoOutGetFlipStatus, buffers registered via
sceVideoOutRegisterBuffers are valid flip targets.
- New HLE: libc stdio (fopen/fread/fseek/ftell/fclose/fgets), Dinkumware
_Getpctype ctype table, NpTrophy2 stubs, AMPR PAK sequential-read tracker,
MsgDialog lifecycle, NGS2 alt NIDs + dummy vtable for handle objects,
guarded memset intrinsic, abort()/strcasecmp null-arg recovery.
- Removed investigation-only code (INT3 breakpoints, qfont/mcpp dumps,
error-candidate printf traces, unconditional debug logs).
First rendered frame: Quake (PPSA01880) presents a 1920x1080 guest frame.
* Implemented a guarded native intrinsic (rep movsb) in DirectExecutionBackend to bypass HLE dispatch overhead, while preserving memory safety checks.
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
using SharpEmu.HLE;
|
||||
using System.Buffers.Binary;
|
||||
|
||||
namespace SharpEmu.Libs.Np;
|
||||
|
||||
public static class NpTrophy2Exports
|
||||
{
|
||||
private static int _nextContext = 1;
|
||||
private static int _nextHandle = 1;
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "Bagshr7OQ6Q",
|
||||
ExportName = "sceNpTrophy2CreateContext",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceNpTrophy2")]
|
||||
public static int NpTrophy2CreateContext(CpuContext ctx)
|
||||
{
|
||||
return WriteIdAndReturn(ctx, ctx[CpuRegister.Rdi], ref _nextContext);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "Gz1rmUZpROM",
|
||||
ExportName = "sceNpTrophy2CreateHandle",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceNpTrophy2")]
|
||||
public static int NpTrophy2CreateHandle(CpuContext ctx)
|
||||
{
|
||||
return WriteIdAndReturn(ctx, ctx[CpuRegister.Rdi], ref _nextHandle);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "sysY2FHYff4",
|
||||
ExportName = "sceNpTrophy2DestroyContext",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceNpTrophy2")]
|
||||
public static int NpTrophy2DestroyContext(CpuContext ctx) => ReturnOk(ctx);
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "d8P11CI40KE",
|
||||
ExportName = "sceNpTrophy2DestroyHandle",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceNpTrophy2")]
|
||||
public static int NpTrophy2DestroyHandle(CpuContext ctx) => ReturnOk(ctx);
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "fYapWA9xVmA",
|
||||
ExportName = "sceNpTrophy2AbortHandle",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceNpTrophy2")]
|
||||
public static int NpTrophy2AbortHandle(CpuContext ctx) => ReturnOk(ctx);
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "bIDov3wBu5Q",
|
||||
ExportName = "sceNpTrophy2RegisterContext",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceNpTrophy2")]
|
||||
public static int NpTrophy2RegisterContext(CpuContext ctx) => ReturnOk(ctx);
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "sUXGfNMalIo",
|
||||
ExportName = "sceNpTrophy2RegisterUnlockCallback",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceNpTrophy2")]
|
||||
public static int NpTrophy2RegisterUnlockCallback(CpuContext ctx) => ReturnOk(ctx);
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "wVqxM58sIKs",
|
||||
ExportName = "sceNpTrophy2UnregisterUnlockCallback",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceNpTrophy2")]
|
||||
public static int NpTrophy2UnregisterUnlockCallback(CpuContext ctx) => ReturnOk(ctx);
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "EHQEDVXZ0TI",
|
||||
ExportName = "sceNpTrophy2ShowTrophyList",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceNpTrophy2")]
|
||||
public static int NpTrophy2ShowTrophyList(CpuContext ctx) => ReturnOk(ctx);
|
||||
|
||||
private static int WriteIdAndReturn(CpuContext ctx, ulong outAddress, ref int nextId)
|
||||
{
|
||||
if (outAddress == 0)
|
||||
{
|
||||
return SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
Span<byte> idBytes = stackalloc byte[sizeof(int)];
|
||||
BinaryPrimitives.WriteInt32LittleEndian(idBytes, nextId);
|
||||
if (!ctx.Memory.TryWrite(outAddress, idBytes))
|
||||
{
|
||||
return SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
}
|
||||
|
||||
nextId++;
|
||||
return SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
private static int ReturnOk(CpuContext ctx) => SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
|
||||
private static int SetReturn(CpuContext ctx, OrbisGen2Result result)
|
||||
{
|
||||
ctx[CpuRegister.Rax] = unchecked((ulong)(int)result);
|
||||
return (int)result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user