2012-05-31 12:27:46 +00:00
|
|
|
#include "decompressor.cpp"
|
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
auto SPC7110::dcuLoadAddress() -> void {
|
2015-11-14 00:52:51 +00:00
|
|
|
uint table = r4801 | r4802 << 8 | r4803 << 16;
|
|
|
|
uint index = r4804 << 2;
|
2012-05-19 06:28:54 +00:00
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
uint address = table + index;
|
|
|
|
dcuMode = dataromRead(address + 0);
|
|
|
|
dcuAddress = dataromRead(address + 1) << 16;
|
|
|
|
dcuAddress |= dataromRead(address + 2) << 8;
|
|
|
|
dcuAddress |= dataromRead(address + 3) << 0;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
auto SPC7110::dcuBeginTransfer() -> void {
|
|
|
|
if(dcuMode == 3) return; //invalid mode
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
addClocks(20);
|
|
|
|
decompressor->initialize(dcuMode, dcuAddress);
|
2012-06-06 09:57:53 +00:00
|
|
|
decompressor->decode();
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
uint seek = r480b & 2 ? r4805 | r4806 << 8 : 0;
|
2012-06-06 09:57:53 +00:00
|
|
|
while(seek--) decompressor->decode();
|
2012-05-31 12:27:46 +00:00
|
|
|
|
|
|
|
r480c |= 0x80;
|
2016-06-17 13:03:54 +00:00
|
|
|
dcuOffset = 0;
|
2012-05-19 06:28:54 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
auto SPC7110::dcuRead() -> uint8 {
|
2012-05-31 12:27:46 +00:00
|
|
|
if((r480c & 0x80) == 0) return 0x00;
|
2012-05-19 06:28:54 +00:00
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
if(dcuOffset == 0) {
|
2015-11-14 00:52:51 +00:00
|
|
|
for(auto row : range(8)) {
|
2012-06-06 09:57:53 +00:00
|
|
|
switch(decompressor->bpp) {
|
|
|
|
case 1:
|
2016-06-17 13:03:54 +00:00
|
|
|
dcuTile[row] = decompressor->result;
|
2012-06-06 09:57:53 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-06-17 13:03:54 +00:00
|
|
|
dcuTile[row * 2 + 0] = decompressor->result >> 0;
|
|
|
|
dcuTile[row * 2 + 1] = decompressor->result >> 8;
|
2012-06-06 09:57:53 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2016-06-17 13:03:54 +00:00
|
|
|
dcuTile[row * 2 + 0] = decompressor->result >> 0;
|
|
|
|
dcuTile[row * 2 + 1] = decompressor->result >> 8;
|
|
|
|
dcuTile[row * 2 + 16] = decompressor->result >> 16;
|
|
|
|
dcuTile[row * 2 + 17] = decompressor->result >> 24;
|
2012-06-06 09:57:53 +00:00
|
|
|
break;
|
2012-05-19 06:28:54 +00:00
|
|
|
}
|
2012-06-06 09:57:53 +00:00
|
|
|
|
2016-02-16 09:27:55 +00:00
|
|
|
uint seek = r480b & 1 ? r4807 : (uint8)1;
|
2012-06-06 09:57:53 +00:00
|
|
|
while(seek--) decompressor->decode();
|
2012-05-19 06:28:54 +00:00
|
|
|
}
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
uint8 data = dcuTile[dcuOffset++];
|
|
|
|
dcuOffset &= 8 * decompressor->bpp - 1;
|
2012-05-19 06:28:54 +00:00
|
|
|
return data;
|
|
|
|
}
|