2012-05-31 12:27:46 +00:00
|
|
|
#include "decompressor.cpp"
|
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto SPC7110::dcu_load_address() -> void {
|
|
|
|
uint table = r4801 | r4802 << 8 | r4803 << 16;
|
|
|
|
uint index = r4804 << 2;
|
2012-05-19 06:28:54 +00:00
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
uint addr = table + index;
|
2012-05-19 06:28:54 +00:00
|
|
|
dcu_mode = datarom_read(addr + 0);
|
|
|
|
dcu_addr = datarom_read(addr + 1) << 16;
|
|
|
|
dcu_addr |= datarom_read(addr + 2) << 8;
|
|
|
|
dcu_addr |= datarom_read(addr + 3) << 0;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto SPC7110::dcu_begin_transfer() -> void {
|
2012-05-31 12:27:46 +00:00
|
|
|
if(dcu_mode == 3) return; //invalid mode
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2012-05-31 12:27:46 +00:00
|
|
|
add_clocks(20);
|
|
|
|
decompressor->initialize(dcu_mode, dcu_addr);
|
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;
|
2012-06-06 09:57:53 +00:00
|
|
|
dcu_offset = 0;
|
2012-05-19 06:28:54 +00:00
|
|
|
}
|
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto SPC7110::dcu_read() -> uint8 {
|
2012-05-31 12:27:46 +00:00
|
|
|
if((r480c & 0x80) == 0) return 0x00;
|
2012-05-19 06:28:54 +00:00
|
|
|
|
2012-06-06 09:57:53 +00:00
|
|
|
if(dcu_offset == 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:
|
|
|
|
dcu_tile[row] = decompressor->result;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
dcu_tile[row * 2 + 0] = decompressor->result >> 0;
|
|
|
|
dcu_tile[row * 2 + 1] = decompressor->result >> 8;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
dcu_tile[row * 2 + 0] = decompressor->result >> 0;
|
|
|
|
dcu_tile[row * 2 + 1] = decompressor->result >> 8;
|
|
|
|
dcu_tile[row * 2 + 16] = decompressor->result >> 16;
|
|
|
|
dcu_tile[row * 2 + 17] = decompressor->result >> 24;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-06-06 09:57:53 +00:00
|
|
|
uint8 data = dcu_tile[dcu_offset++];
|
|
|
|
dcu_offset &= 8 * decompressor->bpp - 1;
|
2012-05-19 06:28:54 +00:00
|
|
|
return data;
|
|
|
|
}
|