ekeeke / Genesis-Plus-GX

An enhanced port of Genesis Plus - accurate & portable Sega 8/16 bit emulator
Other
673 stars 193 forks source link

[Core/CD] Fix various MCD registers, based on the hardware manual and mcd-verificator (#408) #464

Closed DevsArchive closed 1 year ago

DevsArchive commented 1 year ago

Fixes a number of errors reported by mcd-verificator (#408). Half is just simple bit masks to prevent unused bits from being written/read.

The other has to do with how the CDC register select and read/write actually functions. According to mcd-verificator, bit 4 in the CDC register select register is the "RS" flag, which you can read up on Sanyo LC8950/LC8951 manual. Interestingly, it seems that when the CDC register ID wraps back to 0 from 0xF, it'll actually switch the RS flag, effectively making it act as sort of a 5th bit? From the tests done in mcd-verificator, it seems to just act as an access enable flag of sorts? The LC8950 manual says that the RS flag is for dictating how registers are accessed (low ="direct addressing"/"AR", high = "indirect addressing"/"the register pointed to by AR", which I guess is for setups where you would switch between setting the register ID and register data within the same address, which isn't applicable to the MCD, since the 2 are split). The current implementation is based on what mcd-verificator has perceived it. Also, even if the register select is set to 0, it'll still increment on a register read/write if the RS flag is set. It'll only not increment if it's clear.

Minus the timing test errors, register X002 and the CDC register select/register data registers are reported as working correctly in mcd-verificator.

DevsArchive commented 1 year ago

Closing this as further hardware testing has shown some complications.

ekeeke commented 1 year ago

Thank you but I already studied most of the register errors reported by mcd verificator test program (and have most of these fixed in private repository, just need some time for polishing... as usual). The 5-bit CDC register address is indeed only applicable to some specific LC8951x version (the one used in CDX/MultiMega i think) and need to be configurable (best way is to detect used bios)

ekeeke commented 1 year ago

If there are any additional mistakes (not reported by mcd verificator), please rather open a specific issue report (with test program to check on real hardware if possible)

DevsArchive commented 1 year ago

Noted