Basic CD image loading

This commit is contained in:
Connor McLaughlin
2019-09-20 20:14:00 +10:00
parent 53e755aa68
commit ad652c47ed
12 changed files with 260 additions and 8 deletions

View File

@ -1,5 +1,6 @@
#include "cdrom.h"
#include "YBaseLib/Log.h"
#include "common/cd_image.h"
#include "common/state_wrapper.h"
#include "interrupt_controller.h"
Log_SetChannel(CDROM);
@ -43,6 +44,34 @@ bool CDROM::DoState(StateWrapper& sw)
return !sw.HasError();
}
bool CDROM::InsertMedia(const char* filename)
{
auto media = std::make_unique<CDImage>();
if (!media->Open(filename))
{
Log_ErrorPrintf("Failed to open media at '%s'", filename);
return false;
}
if (HasMedia())
RemoveMedia();
m_media = std::move(media);
m_secondary_status.shell_open = false;
return true;
}
void CDROM::RemoveMedia()
{
if (!m_media)
return;
// TODO: Error while reading?
Log_InfoPrintf("Removing CD...");
m_media.reset();
m_secondary_status.shell_open = true;
}
u8 CDROM::ReadRegister(u32 offset)
{
switch (offset)