From 3c2a19b745b6993d82c35736c18a162edd4ff171 Mon Sep 17 00:00:00 2001 From: Sergey Dvodnenko Date: Tue, 3 Dec 2019 21:48:47 +0200 Subject: [PATCH] megacd: reset drive without ejecting a disk * megacd: fix sgets() * megacd: reset drive without ejecting a disk --- menu.cpp | 3 +-- support/megacd/cdd.cpp | 24 ++++++++++++++++++++++-- support/megacd/megacd.cpp | 4 ++++ support/megacd/megacd.h | 4 ++-- user_io.cpp | 2 +- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/menu.cpp b/menu.cpp index d3c95a3..8de4f2d 100644 --- a/menu.cpp +++ b/menu.cpp @@ -760,7 +760,6 @@ static void vga_nag() OsdWrite(n++, " or enable scaler on VGA:"); OsdWrite(n++, " vga_scaler=1"); for (; n < OsdGetSize(); n++) OsdWrite(n); - OsdUpdate(); OsdEnable(0); EnableOsd_on(OSD_HDMI); } @@ -1575,7 +1574,7 @@ void HandleUI(void) } else { - if (mask == 1 && is_megacd_core()) mcd_set_image(0, ""); + if (mask == 1 && is_megacd_core()) mcd_reset(); uint32_t status = user_io_8bit_set_status(0, 0, ex); diff --git a/support/megacd/cdd.cpp b/support/megacd/cdd.cpp index 107905f..3bebc9a 100644 --- a/support/megacd/cdd.cpp +++ b/support/megacd/cdd.cpp @@ -14,9 +14,7 @@ cdd_t cdd; uint32_t frame = 0; cdd_t::cdd_t() { - cycles = 0; latency = 10; - type = 0; loaded = 0; index = 0; lba = 0; @@ -306,6 +304,28 @@ void cdd_t::Unload() this->sectorSize = 0; } +void cdd_t::Reset() { + latency = 10; + index = 0; + lba = 0; + scanOffset = 0; + isData = 1; + status = CD_STAT_STOP; + audioLength = 0; + audioOffset = 0; + + stat[0] = 0x0; + stat[1] = 0x0; + stat[2] = 0x0; + stat[3] = 0x0; + stat[4] = 0x0; + stat[5] = 0x0; + stat[6] = 0x0; + stat[7] = 0x0; + stat[8] = 0x0; + stat[9] = 0xF; +} + void cdd_t::Update() { if (this->status == CD_STAT_STOP || this->status == CD_STAT_TRAY || this->status == CD_STAT_OPEN) { diff --git a/support/megacd/megacd.cpp b/support/megacd/megacd.cpp index 8877795..c695d0f 100644 --- a/support/megacd/megacd.cpp +++ b/support/megacd/megacd.cpp @@ -93,6 +93,10 @@ void mcd_set_image(int num, const char *filename) } } +void mcd_reset() { + cdd.Reset(); +} + int cdd_t::SectorSend(uint8_t* header) { diff --git a/support/megacd/megacd.h b/support/megacd/megacd.h index fca881f..7053172 100644 --- a/support/megacd/megacd.h +++ b/support/megacd/megacd.h @@ -70,6 +70,7 @@ public: cdd_t(); int Load(const char *filename); void Unload(); + void Reset(); void Update(); void CommandExec(); int SectorSend(uint8_t* header); @@ -82,8 +83,6 @@ private: toc_t toc; int index; int lba; - uint32_t cycles; - int type; uint16_t sectorSize; int scanOffset; int audioLength; @@ -116,5 +115,6 @@ extern uint32_t frame; void mcd_poll(); void mcd_set_image(int num, const char *filename); +void mcd_reset(); #endif diff --git a/user_io.cpp b/user_io.cpp index 9dd4131..e6ff2e6 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -1828,7 +1828,7 @@ void user_io_send_buttons(char force) { if (is_archie()) fpga_load_rbf(name[0] ? name : "Archie.rbf"); if (is_minimig()) minimig_reset(); - if (is_megacd_core()) mcd_set_image(0, ""); + if (is_megacd_core()) mcd_reset(); } key_map = map;