Skip to content
Permalink
Browse files
Merge pull request #9959 from Bonta0/gba-qol
Qt: GBA QoL improvements
  • Loading branch information
Tilka committed Jul 25, 2021
2 parents 1119488 + cfd0f46 commit 3e04cb6
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 150 deletions.
@@ -292,6 +292,25 @@ bool Core::IsStarted() const
return m_started;
}

CoreInfo Core::GetCoreInfo() const
{
CoreInfo info{};
info.device_number = m_device_number;
info.width = GBA_VIDEO_HORIZONTAL_PIXELS;
info.height = GBA_VIDEO_VERTICAL_PIXELS;

if (!IsStarted())
return info;

info.is_gba = m_core->platform(m_core) == mPlatform::mPLATFORM_GBA;
info.has_rom = !m_rom_path.empty();
info.has_ereader =
info.is_gba && static_cast<::GBA*>(m_core->board)->memory.hw.devices & HW_EREADER;
m_core->desiredVideoDimensions(m_core, &info.width, &info.height);
info.game_title = m_game_title;
return info;
}

void Core::SetHost(std::weak_ptr<GBAHostInterface> host)
{
m_host = std::move(host);
@@ -305,7 +324,7 @@ void Core::SetForceDisconnect(bool force_disconnect)
void Core::EReaderQueueCard(std::string_view card_path)
{
Flush();
if (!IsStarted() || m_core->platform(m_core) != mPlatform::mPLATFORM_GBA)
if (!GetCoreInfo().has_ereader)
return;

File::IOFile file(std::string(card_path), "rb");
@@ -438,28 +457,6 @@ void Core::SetupEvent()
m_event.priority = 0x80;
}

int Core::GetDeviceNumber() const
{
return m_device_number;
}

void Core::GetVideoDimensions(u32* width, u32* height) const
{
if (!IsStarted())
{
*width = GBA_VIDEO_HORIZONTAL_PIXELS;
*height = GBA_VIDEO_VERTICAL_PIXELS;
return;
}

m_core->desiredVideoDimensions(m_core, width, height);
}

std::string Core::GetGameTitle() const
{
return m_game_title;
}

void Core::SendJoybusCommand(u64 gc_ticks, int transfer_time, u8* buffer, u16 keys)
{
if (!IsStarted())
@@ -36,6 +36,17 @@ struct AVStream : mAVStream
Core* core;
};

struct CoreInfo
{
int device_number;
bool is_gba;
bool has_rom;
bool has_ereader;
u32 width;
u32 height;
std::string game_title;
};

class Core final
{
public:
@@ -46,15 +57,12 @@ class Core final
void Stop();
void Reset();
bool IsStarted() const;
CoreInfo GetCoreInfo() const;

void SetHost(std::weak_ptr<GBAHostInterface> host);
void SetForceDisconnect(bool force_disconnect);
void EReaderQueueCard(std::string_view card_path);

int GetDeviceNumber() const;
void GetVideoDimensions(u32* width, u32* height) const;
std::string GetGameTitle() const;

void SendJoybusCommand(u64 gc_ticks, int transfer_time, u8* buffer, u16 keys);
std::vector<u8> GetJoybusResponse();

@@ -15,16 +15,9 @@ GBAHost::GBAHost(std::weak_ptr<HW::GBA::Core> core)
m_widget_controller->moveToThread(qApp->thread());
m_core = std::move(core);
auto core_ptr = m_core.lock();

int device_number = core_ptr->GetDeviceNumber();
std::string game_title = core_ptr->GetGameTitle();
u32 width, height;
core_ptr->GetVideoDimensions(&width, &height);

HW::GBA::CoreInfo info = core_ptr->GetCoreInfo();
QueueOnObject(m_widget_controller, [widget_controller = m_widget_controller, core = m_core,
device_number, game_title, width, height] {
widget_controller->Create(core, device_number, game_title, width, height);
});
info] { widget_controller->Create(core, info); });
}

GBAHost::~GBAHost()
@@ -37,15 +30,10 @@ void GBAHost::GameChanged()
auto core_ptr = m_core.lock();
if (!core_ptr || !core_ptr->IsStarted())
return;

std::string game_title = core_ptr->GetGameTitle();
u32 width, height;
core_ptr->GetVideoDimensions(&width, &height);

QueueOnObject(m_widget_controller,
[widget_controller = m_widget_controller, game_title, width, height] {
widget_controller->GameChanged(game_title, width, height);
});
HW::GBA::CoreInfo info = core_ptr->GetCoreInfo();
QueueOnObject(m_widget_controller, [widget_controller = m_widget_controller, info] {
widget_controller->GameChanged(info);
});
}

void GBAHost::FrameEnded(const std::vector<u32>& video_buffer)

0 comments on commit 3e04cb6

Please sign in to comment.