From 611e379c0473fefcb1023d3d9584afa5b0e20de5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Oct 2020 07:45:57 +0200 Subject: [PATCH] Simplify SimpleFIFO --- Makefile.common | 2 +- mednafen/cdrom/SimpleFIFO.h | 34 +++---------------------------- mednafen/pce_fast/pcecd.cpp | 2 +- mednafen/pce_fast/pcecd_drive.cpp | 2 +- 4 files changed, 6 insertions(+), 34 deletions(-) diff --git a/Makefile.common b/Makefile.common index 97093bc..f1f2f30 100644 --- a/Makefile.common +++ b/Makefile.common @@ -172,7 +172,7 @@ ifeq ($(HAVE_CHD), 1) INCFLAGS += $(shell pkg-config --cflags zlib) LIBS += $(shell pkg-config --libs zlib) else - INCFLAGS += $(ZLIB_INCFLAGS) + INCFLAGS += $(ZLIB_INCFLAGS) SOURCES_C += $(ZLIB_SOURCES_C) endif diff --git a/mednafen/cdrom/SimpleFIFO.h b/mednafen/cdrom/SimpleFIFO.h index 192a3b1..0b5f8c5 100644 --- a/mednafen/cdrom/SimpleFIFO.h +++ b/mednafen/cdrom/SimpleFIFO.h @@ -30,24 +30,14 @@ class SimpleFIFO return(size - in_count); } - INLINE uint8_t ReadUnit(bool peek = false) + INLINE uint8_t ReadUnit(void) { uint8_t ret = data[read_pos]; - - if(!peek) - { - read_pos = (read_pos + 1) & (size - 1); - in_count--; - } - + read_pos = (read_pos + 1) & (size - 1); + in_count--; return(ret); } - INLINE uint8_t ReadByte(bool peek = false) - { - return(ReadUnit(peek)); - } - INLINE void Write(const uint8_t *happy_data, uint32 happy_count) { while(happy_count) @@ -61,17 +51,6 @@ class SimpleFIFO } } - INLINE void WriteUnit(const uint8_t& wr_data) - { - Write(&wr_data, 1); - } - - INLINE void WriteByte(const uint8_t& wr_data) - { - Write(&wr_data, 1); - } - - INLINE void Flush(void) { read_pos = 0; @@ -79,13 +58,6 @@ class SimpleFIFO in_count = 0; } - INLINE void SaveStatePostLoad(void) - { - read_pos %= size; - write_pos %= size; - in_count %= (size + 1); - } - uint8_t *data; uint32 size; uint32 read_pos; // Read position diff --git a/mednafen/pce_fast/pcecd.cpp b/mednafen/pce_fast/pcecd.cpp index 58eda84..4432af2 100644 --- a/mednafen/pce_fast/pcecd.cpp +++ b/mednafen/pce_fast/pcecd.cpp @@ -403,7 +403,7 @@ uint8 PCECD_Read(uint32 timestamp, uint32 A) case 0x7: if(SubChannelFIFO.in_count > 0) - ret = SubChannelFIFO.ReadByte(); + ret = SubChannelFIFO.ReadUnit(); else ret = 0x00; // Not sure if it's 0, 0xFF, the last byte read, or something else. diff --git a/mednafen/pce_fast/pcecd_drive.cpp b/mednafen/pce_fast/pcecd_drive.cpp index 82cf61c..de8f850 100644 --- a/mednafen/pce_fast/pcecd_drive.cpp +++ b/mednafen/pce_fast/pcecd_drive.cpp @@ -1142,7 +1142,7 @@ uint32 PCECD_Drive_Run(pcecd_drive_timestamp_t system_timestamp) } else { - cd_bus.DB = din.ReadByte(); + cd_bus.DB = din.ReadUnit(); SetREQ(TRUE); } }