GIF: Actually use the register classes and bugfixes

other fixes:
- fixed GIF control flow
- improved GIF error messages (includes transfer mode now)
- Fix bitfield alignment detection
This commit is contained in:
hch12907 2018-10-21 15:12:07 +08:00
parent 1452185156
commit 33ee436db0
4 changed files with 36 additions and 22 deletions

View file

@ -70,10 +70,18 @@ struct Bitfield
template <typename To>
constexpr To extract_from(const uqword value) const
{
// Most (all?) bitfields within uqword types are aligned to 64 bit
// boundaries... But this should be easy to implement if needed.
if ((start < 64) && ((length + start) >= 64))
throw std::logic_error("Cannot extract bitfield over 64 bit boundary from a uqword [not implemented]");
// Special case for bitfields within uqword types that are not aligned to
// 64 bit boundaries
if ((start < 64) && ((length + start) > 64))
{
To a = Bitfield(start, 64 - start).extract_from<To, udword>(value.lo);
To b = Bitfield(64, start + length - 64).extract_from<To, udword>(value.hi);
return a | (b << (64 - start));
// Not sure if it works, so...
throw std::runtime_error("Non 64-bit aligned bitfields found!");
}
if (start < 64)
return Bitfield(start, length).extract_from<To, udword>(value.lo);

View file

@ -29,7 +29,7 @@ public:
{
for (auto& branch : pending_branches)
{
if (branch.first == 0)
if (branch.first == -1)
{
branch.first = slots + 1;
branch.second = address;

View file

@ -94,6 +94,8 @@ int CGif::time_step(const int ticks_available)
fifo->read(reinterpret_cast<ubyte*>(&data), NUMBER_BYTES_IN_QWORD);
cycles_consumed = handle_data_packed(data);
break;
}
case Giftag::DataFormat::Reglist:
{
@ -108,6 +110,8 @@ int CGif::time_step(const int ticks_available)
fifo->read(reinterpret_cast<ubyte*>(&data), NUMBER_BYTES_IN_QWORD);
cycles_consumed = handle_data_reglist(data);
break;
}
case Giftag::DataFormat::Image:
case Giftag::DataFormat::Disabled:
@ -119,6 +123,8 @@ int CGif::time_step(const int ticks_available)
fifo->read(reinterpret_cast<ubyte*>(&data), NUMBER_BYTES_IN_QWORD);
cycles_consumed = handle_data_image(data);
break;
}
default:
{
@ -149,10 +155,10 @@ int CGif::handle_tag(const Giftag tag)
ctrl.tag = tag;
// The tag is split into 4 parts and copied to the respective registers
r.ee.gif.tag0 = tag.tag.uw[0];
r.ee.gif.tag1 = tag.tag.uw[1];
r.ee.gif.tag2 = tag.tag.uw[2];
r.ee.gif.tag3 = tag.tag.uw[3];
r.ee.gif.tag0.write_uword(tag.tag.uw[0]);
r.ee.gif.tag1.write_uword(tag.tag.uw[1]);
r.ee.gif.tag2.write_uword(tag.tag.uw[2]);
r.ee.gif.tag3.write_uword(tag.tag.uw[3]);
// Initialise the RGBAQ.Q value on every tag read.
// See EE Users manual page 153.
@ -349,7 +355,7 @@ int CGif::handle_data_packed(const uqword data)
case 0xB:
{
// Reserved
throw std::runtime_error("Reserved register descriptor read from GIFtag");
throw std::runtime_error("GIF: Packed - Reserved register descriptor read from GIFtag");
}
case 0xC:
{
@ -383,7 +389,7 @@ int CGif::handle_data_packed(const uqword data)
}
default:
{
throw std::runtime_error("Unknown register descriptor given");
throw std::runtime_error("GIF: Packed - Unknown register descriptor given");
}
}
@ -505,7 +511,7 @@ int CGif::handle_data_reglist(const uqword data)
case 0xB:
{
// Reserved
throw std::runtime_error("Reserved register descriptor read from GIFtag");
throw std::runtime_error("GIF: Reglist - Reserved register descriptor read from GIFtag");
}
case 0xC:
{
@ -534,7 +540,7 @@ int CGif::handle_data_reglist(const uqword data)
}
default:
{
throw std::runtime_error("Unknown register descriptor given");
throw std::runtime_error("GIF: Reglist - Unknown register descriptor given");
}
}

View file

@ -13,16 +13,16 @@ public:
/// GIF memory mapped registers. See page 21 of EE Users Manual.
GifRegister_Ctrl ctrl;
SizedWordRegister mode;
SizedWordRegister stat;
GifRegister_Mode mode;
GifRegister_Stat stat;
ArrayByteMemory memory_3030;
SizedWordRegister tag0;
SizedWordRegister tag1;
SizedWordRegister tag2;
SizedWordRegister tag3;
SizedWordRegister cnt;
SizedWordRegister p3cnt;
SizedWordRegister p3tag;
GifRegister_Tag0 tag0;
GifRegister_Tag1 tag1;
GifRegister_Tag2 tag2;
GifRegister_Tag3 tag3;
GifRegister_Cnt cnt;
GifRegister_P3cnt p3cnt;
GifRegister_P3tag p3tag;
ArrayByteMemory memory_30b0;
public: