From 3276c0db9c6934adfe305d8d96daff38b99f94db Mon Sep 17 00:00:00 2001 From: TheLastRar Date: Tue, 15 Oct 2024 21:48:25 +0100 Subject: [PATCH] DEV9: Correct implementation of SPD_R_DBUF_STAT reset --- pcsx2/DEV9/DEV9.cpp | 17 ++++++++++------- pcsx2/DEV9/DEV9.h | 3 ++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pcsx2/DEV9/DEV9.cpp b/pcsx2/DEV9/DEV9.cpp index 1b0d3d8faa..070ef2050c 100644 --- a/pcsx2/DEV9/DEV9.cpp +++ b/pcsx2/DEV9/DEV9.cpp @@ -688,16 +688,19 @@ void SpeedWrite(u32 addr, u16 value, int width) case SPD_R_DBUF_STAT: //DevCon.WriteLn("DEV9: SPD_R_DBUF_STAT %dbit write %x", width, value); - if ((value & SPD_DBUF_RESET_FIFO) != 0) + if ((value & SPD_DBUF_RESET_READ_CNT) != 0) { - //DevCon.WriteLn("DEV9: SPD_R_DBUF_STAT Reset FIFO"); - dev9.fifo_bytes_write = 0; + //DevCon.WriteLn("DEV9: SPD_R_DBUF_STAT Reset read counter"); dev9.fifo_bytes_read = 0; - dev9.xfr_ctrl &= ~SPD_XFR_WRITE; //? - dev9.if_ctrl |= SPD_IF_READ; //? - - FIFOIntr(); } + if ((value & SPD_DBUF_RESET_WRITE_CNT) != 0) + { + //DevCon.WriteLn("DEV9: SPD_R_DBUF_STAT Reset write counter"); + dev9.fifo_bytes_write = 0; + } + + if (value != 0) + FIFOIntr(); if (value != 3) Console.Error("DEV9: SPD_R_DBUF_STAT 16bit write %x Which != 3!!!", value); diff --git a/pcsx2/DEV9/DEV9.h b/pcsx2/DEV9/DEV9.h index 261a051af2..7dc96c85d7 100644 --- a/pcsx2/DEV9/DEV9.h +++ b/pcsx2/DEV9/DEV9.h @@ -168,7 +168,8 @@ extern int ThreadRun; #define SPD_DBUF_STAT_FULL (1 << 7) //HDD->SPEED: both SPD_DBUF_STAT_2 and SPD_DBUF_STAT_FULL set to 1 indicates overflow //Write -#define SPD_DBUF_RESET_FIFO (1 << 1) //Set SPD_DBUF_STAT_1 & SPD_DBUF_STAT_2, SPD_DBUF_AVAIL set to 0 +#define SPD_DBUF_RESET_READ_CNT (1 << 0) +#define SPD_DBUF_RESET_WRITE_CNT (1 << 1) #define SPD_R_IF_CTRL (SPD_REGBASE + 0x64) #define SPD_IF_UDMA (1 << 0)