mirror of
https://github.com/hch12907/orbum.git
synced 2024-06-02 19:38:16 -04:00
Add in GIF registers
This commit is contained in:
parent
3e87790f06
commit
0bfb350a34
|
@ -159,6 +159,8 @@ set(COMMON_SRC_FILES
|
|||
"${CMAKE_SOURCE_DIR}/liborbum/src/Resources/Ee/Gif/RGif.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/liborbum/src/Resources/Ee/Gif/RGif.hpp"
|
||||
"${CMAKE_SOURCE_DIR}/liborbum/src/Resources/Ee/Gif/Giftag.hpp"
|
||||
"${CMAKE_SOURCE_DIR}/liborbum/src/Resources/Ee/Gif/GifRegisters.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/liborbum/src/Resources/Ee/Gif/GifRegisters.hpp"
|
||||
"${CMAKE_SOURCE_DIR}/liborbum/src/Resources/Ee/Intc/EeIntcConstants.hpp"
|
||||
"${CMAKE_SOURCE_DIR}/liborbum/src/Resources/Ee/Intc/EeIntcRegisters.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/liborbum/src/Resources/Ee/Intc/EeIntcRegisters.hpp"
|
||||
|
|
|
@ -28,7 +28,6 @@ void CGif::handle_event(const ControllerEvent& event)
|
|||
|
||||
int CGif::time_to_ticks(const double time_us)
|
||||
{
|
||||
// TODO: find out for sure.
|
||||
int ticks = static_cast<int>(time_us / 1.0e6 * Constants::EE::EEBUS_CLK_SPEED * core->get_options().system_bias_gif);
|
||||
|
||||
if (ticks < 10)
|
||||
|
@ -47,23 +46,56 @@ int CGif::time_to_ticks(const double time_us)
|
|||
int CGif::time_step(const int ticks_available)
|
||||
{
|
||||
auto& r = core->get_resources();
|
||||
auto& ctrl = r.ee.gif.ctrl;
|
||||
auto& fifo_gif_path1 = r.fifo_gif_path1;
|
||||
auto& fifo_gif_path2 = r.fifo_gif_path2;
|
||||
auto& fifo_gif_path3 = r.fifo_gif_path3;
|
||||
|
||||
// Prioritise paths by 1 -> 2 -> 3.
|
||||
// TODO: GIF code does not do path arbitration currently.
|
||||
// See EE Users Manual page 149.
|
||||
DmaFifoQueue<>* paths[3] = {&fifo_gif_path1, &fifo_gif_path2, &fifo_gif_path3};
|
||||
|
||||
uqword tag;
|
||||
for (auto& fifo : paths)
|
||||
{
|
||||
if (fifo->has_read_available(NUMBER_BYTES_IN_QWORD))
|
||||
fifo->read(reinterpret_cast<ubyte*>(&tag), NUMBER_BYTES_IN_QWORD);
|
||||
if (!fifo->has_read_available(NUMBER_BYTES_IN_QWORD))
|
||||
continue;
|
||||
|
||||
uqword data;
|
||||
fifo->read(reinterpret_cast<ubyte*>(&data), NUMBER_BYTES_IN_QWORD);
|
||||
|
||||
if (!ctrl.transfer_started)
|
||||
{
|
||||
ctrl.transfer_started = true;
|
||||
handle_tag(Giftag(data));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fifo->has_read_available(1))
|
||||
BOOST_LOG(Core::get_logger()) << "Still data for the GIF waiting...";
|
||||
handle_data(data);
|
||||
}
|
||||
|
||||
if (ctrl.transfer_end_of_packet)
|
||||
{
|
||||
if (ctrl.transfer_data_count == ctrl.transfer_data_target)
|
||||
ctrl.transfer_started = false;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void CGif::handle_tag(const Giftag tag)
|
||||
{
|
||||
auto& r = core->get_resources();
|
||||
auto& ctrl = r.ee.gif.ctrl;
|
||||
|
||||
ctrl.transfer_data_count = 0;
|
||||
}
|
||||
|
||||
void CGif::handle_data(const uqword data)
|
||||
{
|
||||
auto& r = core->get_resources();
|
||||
auto& ctrl = r.ee.gif.ctrl;
|
||||
|
||||
ctrl.transfer_data_count += 1;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "Common/Types/Primitive.hpp"
|
||||
#include "Controller/CController.hpp"
|
||||
#include "Resources/Ee/Gif/Giftag.hpp"
|
||||
|
||||
/// GIF interface, controls data between the EE (EE Core, VPU1) to the GS.
|
||||
class CGif : public CController
|
||||
|
@ -14,4 +16,8 @@ public:
|
|||
int time_to_ticks(const double time_us);
|
||||
|
||||
int time_step(const int ticks_available);
|
||||
|
||||
void handle_tag(const Giftag tag);
|
||||
|
||||
void handle_data(const uqword data);
|
||||
};
|
||||
|
|
9
liborbum/src/Resources/Ee/Gif/GifRegisters.cpp
Normal file
9
liborbum/src/Resources/Ee/Gif/GifRegisters.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "Resources/Ee/Gif/GifRegisters.hpp"
|
||||
|
||||
GifRegister_Ctrl::GifRegister_Ctrl() :
|
||||
transfer_started(false),
|
||||
transfer_data_target(0),
|
||||
transfer_data_count(0),
|
||||
transfer_end_of_packet(false)
|
||||
{
|
||||
}
|
108
liborbum/src/Resources/Ee/Gif/GifRegisters.hpp
Normal file
108
liborbum/src/Resources/Ee/Gif/GifRegisters.hpp
Normal file
|
@ -0,0 +1,108 @@
|
|||
#pragma once
|
||||
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/types/polymorphic.hpp>
|
||||
|
||||
#include "Common/Types/Bitfield.hpp"
|
||||
#include "Common/Types/Register/SizedWordRegister.hpp"
|
||||
|
||||
class GifRegister_Ctrl : public SizedWordRegister
|
||||
{
|
||||
public:
|
||||
static constexpr Bitfield RST = Bitfield(0, 1);
|
||||
static constexpr Bitfield PSE = Bitfield(3, 1);
|
||||
|
||||
GifRegister_Ctrl();
|
||||
|
||||
/// Indicates whether the GIF is currently processing a GS primitive
|
||||
/// (excluding the tag). Reset upon finishing a GS primitive.
|
||||
bool transfer_started;
|
||||
|
||||
/// Number of qwords total/left for the current GS primitive.
|
||||
/// Set by the tag read.
|
||||
size_t transfer_data_target;
|
||||
size_t transfer_data_count;
|
||||
|
||||
/// End of GS packet indicator. Set by the tag read.
|
||||
bool transfer_end_of_packet;
|
||||
|
||||
public:
|
||||
template<class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(
|
||||
cereal::base_class<SizedWordRegister>(this),
|
||||
CEREAL_NVP(transfer_started),
|
||||
CEREAL_NVP(transfer_data_target),
|
||||
CEREAL_NVP(transfer_data_count),
|
||||
CEREAL_NVP(transfer_end_of_packet)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
class GifRegister_Mode : public SizedWordRegister
|
||||
{
|
||||
public:
|
||||
static constexpr Bitfield M3R = Bitfield(0, 1);
|
||||
static constexpr Bitfield IMT = Bitfield(2, 1);
|
||||
};
|
||||
|
||||
class GifRegister_Stat : public SizedWordRegister
|
||||
{
|
||||
public:
|
||||
static constexpr Bitfield M3R = Bitfield(0, 1);
|
||||
static constexpr Bitfield M3P = Bitfield(1, 1);
|
||||
static constexpr Bitfield IMT = Bitfield(2, 1);
|
||||
static constexpr Bitfield PSE = Bitfield(3, 1);
|
||||
static constexpr Bitfield IP3 = Bitfield(5, 1);
|
||||
static constexpr Bitfield P3Q = Bitfield(6, 1);
|
||||
static constexpr Bitfield P2Q = Bitfield(7, 1);
|
||||
static constexpr Bitfield P1Q = Bitfield(8, 1);
|
||||
static constexpr Bitfield OPH = Bitfield(9, 1);
|
||||
static constexpr Bitfield APATH = Bitfield(10, 2);
|
||||
static constexpr Bitfield DIR = Bitfield(12, 1);
|
||||
static constexpr Bitfield FQC = Bitfield(24, 5);
|
||||
};
|
||||
|
||||
class GifRegister_Tag0 : public SizedWordRegister
|
||||
{
|
||||
public:
|
||||
static constexpr Bitfield NLOOP = Bitfield(0, 15);
|
||||
static constexpr Bitfield EOP = Bitfield(15, 1);
|
||||
static constexpr Bitfield TAG = Bitfield(16, 16);
|
||||
};
|
||||
|
||||
class GifRegister_Tag1 : public SizedWordRegister
|
||||
{
|
||||
public:
|
||||
static constexpr Bitfield TAG = Bitfield(0, 14);
|
||||
static constexpr Bitfield PRE = Bitfield(14, 1);
|
||||
static constexpr Bitfield PRIM = Bitfield(15, 11);
|
||||
static constexpr Bitfield FLG = Bitfield(26, 2);
|
||||
static constexpr Bitfield NREG = Bitfield(28, 4);
|
||||
};
|
||||
|
||||
class GifRegister_Tag2 : public SizedWordRegister
|
||||
{
|
||||
public:
|
||||
static constexpr Bitfield TAG = Bitfield(0, 32);
|
||||
};
|
||||
|
||||
class GifRegister_Tag3 : public SizedWordRegister
|
||||
{
|
||||
public:
|
||||
static constexpr Bitfield TAG = Bitfield(0, 32);
|
||||
};
|
||||
|
||||
class GifRegister_Cnt : public SizedWordRegister
|
||||
{
|
||||
public:
|
||||
static constexpr Bitfield P3CNT = Bitfield(0, 15);
|
||||
};
|
||||
|
||||
class GifRegister_P3tag : public SizedWordRegister
|
||||
{
|
||||
public:
|
||||
static constexpr Bitfield LOOPCNT = Bitfield(0, 15);
|
||||
static constexpr Bitfield EOP = Bitfield(15, 1);
|
||||
};
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "Common/Types/Memory/ArrayByteMemory.hpp"
|
||||
#include "Common/Types/Register/SizedWordRegister.hpp"
|
||||
#include "Resources/Ee/Gif/GifRegisters.hpp"
|
||||
|
||||
class RGif
|
||||
{
|
||||
|
@ -11,7 +12,7 @@ public:
|
|||
RGif();
|
||||
|
||||
/// GIF memory mapped registers. See page 21 of EE Users Manual.
|
||||
SizedWordRegister ctrl;
|
||||
GifRegister_Ctrl ctrl;
|
||||
SizedWordRegister mode;
|
||||
SizedWordRegister stat;
|
||||
ArrayByteMemory memory_3030;
|
||||
|
|
Loading…
Reference in a new issue