Remove all template integer types from fast PPU core.

This commit is contained in:
byuu 2019-08-01 08:49:18 +09:00
parent 216b472418
commit fe81130f54
6 changed files with 87 additions and 139 deletions

View File

@ -8,7 +8,6 @@ using int5 = nall::Integer< 5>;
using int6 = nall::Integer< 6>;
using int7 = nall::Integer< 7>;
using int8 = int8_t;
//using int8 = nall::Integer< 8>;
using int9 = nall::Integer< 9>;
using int10 = nall::Integer<10>;
using int11 = nall::Integer<11>;
@ -17,7 +16,6 @@ using int13 = nall::Integer<13>;
using int14 = nall::Integer<14>;
using int15 = nall::Integer<15>;
using int16 = int16_t;
//using int16 = nall::Integer<16>;
using int17 = nall::Integer<17>;
using int18 = nall::Integer<18>;
using int19 = nall::Integer<19>;
@ -34,40 +32,8 @@ using int29 = nall::Integer<29>;
using int30 = nall::Integer<30>;
using int31 = nall::Integer<31>;
using int32 = int32_t;
//using int32 = nall::Integer<32>;
using int33 = nall::Integer<33>;
using int34 = nall::Integer<34>;
using int35 = nall::Integer<35>;
using int36 = nall::Integer<36>;
using int37 = nall::Integer<37>;
using int38 = nall::Integer<38>;
using int39 = nall::Integer<39>;
using int40 = nall::Integer<40>;
using int41 = nall::Integer<41>;
using int42 = nall::Integer<42>;
using int43 = nall::Integer<43>;
using int44 = nall::Integer<44>;
using int45 = nall::Integer<45>;
using int46 = nall::Integer<46>;
using int47 = nall::Integer<47>;
using int48 = nall::Integer<48>;
using int49 = nall::Integer<49>;
using int50 = nall::Integer<50>;
using int51 = nall::Integer<51>;
using int52 = nall::Integer<52>;
using int53 = nall::Integer<53>;
using int54 = nall::Integer<54>;
using int55 = nall::Integer<55>;
using int56 = nall::Integer<56>;
using int57 = nall::Integer<57>;
using int58 = nall::Integer<58>;
using int59 = nall::Integer<59>;
using int60 = nall::Integer<60>;
using int61 = nall::Integer<61>;
using int62 = nall::Integer<62>;
using int63 = nall::Integer<63>;
using int48 = nall::Integer<48>; //Cx4
using int64 = int64_t;
//using int64 = nall::Integer<64>;
using uint1 = nall::Natural< 1>;
using uint2 = nall::Natural< 2>;
@ -77,7 +43,6 @@ using uint5 = nall::Natural< 5>;
using uint6 = nall::Natural< 6>;
using uint7 = nall::Natural< 7>;
using uint8 = uint8_t;
//using uint8 = nall::Natural< 8>;
using uint9 = nall::Natural< 9>;
using uint10 = nall::Natural<10>;
using uint11 = nall::Natural<11>;
@ -86,7 +51,6 @@ using uint13 = nall::Natural<13>;
using uint14 = nall::Natural<14>;
using uint15 = nall::Natural<15>;
using uint16 = uint16_t;
//using uint16 = nall::Natural<16>;
using uint17 = nall::Natural<17>;
using uint18 = nall::Natural<18>;
using uint19 = nall::Natural<19>;
@ -103,37 +67,6 @@ using uint29 = nall::Natural<29>;
using uint30 = nall::Natural<30>;
using uint31 = nall::Natural<31>;
using uint32 = uint32_t;
//using uint32 = nall::Natural<32>;
using uint33 = nall::Natural<33>;
using uint34 = nall::Natural<34>;
using uint35 = nall::Natural<35>;
using uint36 = nall::Natural<36>;
using uint37 = nall::Natural<37>;
using uint38 = nall::Natural<38>;
using uint39 = nall::Natural<39>;
using uint40 = nall::Natural<40>;
using uint41 = nall::Natural<41>;
using uint42 = nall::Natural<42>;
using uint43 = nall::Natural<43>;
using uint44 = nall::Natural<44>;
using uint45 = nall::Natural<45>;
using uint46 = nall::Natural<46>;
using uint47 = nall::Natural<47>;
using uint48 = nall::Natural<48>;
using uint49 = nall::Natural<49>;
using uint50 = nall::Natural<50>;
using uint51 = nall::Natural<51>;
using uint52 = nall::Natural<52>;
using uint53 = nall::Natural<53>;
using uint54 = nall::Natural<54>;
using uint55 = nall::Natural<55>;
using uint56 = nall::Natural<56>;
using uint57 = nall::Natural<57>;
using uint58 = nall::Natural<58>;
using uint59 = nall::Natural<59>;
using uint60 = nall::Natural<60>;
using uint61 = nall::Natural<61>;
using uint62 = nall::Natural<62>;
using uint63 = nall::Natural<63>;
using uint40 = nall::Natural<40>; //SA1
using uint48 = nall::Natural<48>; //Cx4
using uint64 = uint64_t;
//using uint64 = nall::Natural<64>;

View File

@ -123,7 +123,8 @@ auto PPU::readIO(uint address, uint8 data) -> uint8 {
}
case 0x2138: { //OAMDATAREAD
data = readOAM(io.oamAddress++);
data = readOAM(io.oamAddress);
io.oamAddress = io.oamAddress + 1 & 0x3ff;
oamSetFirstObject();
return latch.ppu1.mdr = data;
}
@ -147,9 +148,11 @@ auto PPU::readIO(uint address, uint8 data) -> uint8 {
}
case 0x213b: { //CGDATAREAD
if(io.cgramAddressLatch++ == 0) {
if(io.cgramAddressLatch == 0) {
io.cgramAddressLatch = 1;
latch.ppu2.mdr = readCGRAM<0>(io.cgramAddress);
} else {
io.cgramAddressLatch = 0;
latch.ppu2.mdr = readCGRAM<1>(io.cgramAddress++) & 0x7f | latch.ppu2.mdr & 0x80;
}
return latch.ppu2.mdr;
@ -214,7 +217,7 @@ auto PPU::writeIO(uint address, uint8 data) -> void {
}
case 0x2101: { //OBSEL
io.obj.tiledataAddress = (data & 7) << 13;
io.obj.tiledataAddress = data << 13 & 0x6000;
io.obj.nameselect = data >> 3 & 3;
io.obj.baseSize = data >> 5 & 7;
return;
@ -235,7 +238,8 @@ auto PPU::writeIO(uint address, uint8 data) -> void {
case 0x2104: { //OAMDATA
bool latchBit = io.oamAddress & 1;
uint address = io.oamAddress++;
uint address = io.oamAddress;
io.oamAddress = io.oamAddress + 1 & 0x3ff;
if(latchBit == 0) latch.oam = data;
if(address & 0x200) {
writeOAM(address, data);
@ -269,37 +273,37 @@ auto PPU::writeIO(uint address, uint8 data) -> void {
case 0x2107: { //BG1SC
io.bg1.screenSize = data >> 0 & 3;
io.bg1.screenAddress = data >> 2 << 10;
io.bg1.screenAddress = data << 8 & 0x7c00;
return;
}
case 0x2108: { //BG2SC
io.bg2.screenSize = data >> 0 & 3;
io.bg2.screenAddress = data >> 2 << 10;
io.bg2.screenAddress = data << 8 & 0x7c00;
return;
}
case 0x2109: { //BG3SC
io.bg3.screenSize = data >> 0 & 3;
io.bg3.screenAddress = data >> 2 << 10;
io.bg3.screenAddress = data << 8 & 0x7c00;
return;
}
case 0x210a: { //BG4SC
io.bg4.screenSize = data >> 0 & 3;
io.bg4.screenAddress = data >> 2 << 10;
io.bg4.screenAddress = data << 8 & 0x7c00;
return;
}
case 0x210b: { //BG12NBA
io.bg1.tiledataAddress = (data & 15) << 12;
io.bg2.tiledataAddress = (data >> 4) << 12;
io.bg1.tiledataAddress = data << 12 & 0x7000;
io.bg2.tiledataAddress = data << 8 & 0x7000;
return;
}
case 0x210c: { //BG34NBA
io.bg3.tiledataAddress = (data & 15) << 12;
io.bg4.tiledataAddress = (data >> 4) << 12;
io.bg3.tiledataAddress = data << 12 & 0x7000;
io.bg4.tiledataAddress = data << 8 & 0x7000;
return;
}
@ -443,9 +447,11 @@ auto PPU::writeIO(uint address, uint8 data) -> void {
}
case 0x2122: { //CGDATA
if(io.cgramAddressLatch++ == 0) {
if(io.cgramAddressLatch == 0) {
io.cgramAddressLatch = 1;
latch.cgram = data;
} else {
io.cgramAddressLatch = 0;
writeCGRAM(io.cgramAddress++, (data & 0x7f) << 8 | latch.cgram);
}
return;

View File

@ -33,7 +33,7 @@ auto PPU::Line::render() -> void {
bool hires = io.pseudoHires || io.bgMode == 5 || io.bgMode == 6;
auto aboveColor = cgram[0];
auto belowColor = hires ? cgram[0] : (uint16_t)io.col.fixedColor;
auto belowColor = hires ? cgram[0] : io.col.fixedColor;
uint xa = (hd || ss) && ppu.interlace() && ppu.field() ? 256 * scale * scale / 2 : 0;
uint xb = !(hd || ss) ? 256 : ppu.interlace() && !ppu.field() ? 256 * scale * scale / 2 : 256 * scale * scale;
for(uint x = xa; x < xb; x++) {

View File

@ -8,11 +8,11 @@ auto PPU::Line::renderObject(PPU::IO::Object& self) -> void {
uint itemCount = 0;
uint tileCount = 0;
for(auto n : range(ppu.ItemLimit)) items[n].valid = false;
for(auto n : range(ppu.TileLimit)) tiles[n].valid = false;
for(uint n : range(ppu.ItemLimit)) items[n].valid = false;
for(uint n : range(ppu.TileLimit)) tiles[n].valid = false;
for(auto n : range(128)) {
ObjectItem item{true, self.first + n};
for(uint n : range(128)) {
ObjectItem item{true, uint8_t(self.first + n)};
const auto& object = ppu.objects[item.index];
if(object.size == 0) {
@ -83,7 +83,7 @@ auto PPU::Line::renderObject(PPU::IO::Object& self) -> void {
uint mirrorX = !object.hflip ? tileX : tileWidth - 1 - tileX;
uint address = tiledataAddress + ((characterY + (characterX + mirrorX & 15)) << 4);
tile.number = address >> 4;
tile.number = address >> 4 & 0x7ff;
if(tileCount++ >= ppu.TileLimit) break;
tiles[tileCount - 1] = tile;
@ -129,7 +129,7 @@ auto PPU::oamAddressReset() -> void {
}
auto PPU::oamSetFirstObject() -> void {
io.obj.first = !io.oamPriority ? 0 : io.oamAddress >> 2;
io.obj.first = !io.oamPriority ? 0 : io.oamAddress >> 2 & 0x7f;
}
auto PPU::readObject(uint10 address) -> uint8 {

View File

@ -31,7 +31,10 @@ auto PPU::hdMosaic() const -> bool { return configuration.hacks.ppu.mode7.mosaic
#define ppu ppufast
PPU::PPU() {
output = new uint16_t[2304 * 2160]();
for(uint l : range(16)) {
lightTable[l] = new uint16_t[32768];
for(uint r : range(32)) {
for(uint g : range(32)) {
for(uint b : range(32)) {
@ -55,6 +58,8 @@ PPU::PPU() {
}
PPU::~PPU() {
delete[] output;
for(uint l : range(16)) delete[] lightTable[l];
delete[] tilecache[TileMode::BPP2];
delete[] tilecache[TileMode::BPP4];
delete[] tilecache[TileMode::BPP8];

View File

@ -50,14 +50,14 @@ public:
bool hd = 0;
bool ss = 0;
uint16_t vram = 0;
uint8_t oam = 0;
uint8_t cgram = 0;
uint16 vram = 0;
uint8 oam = 0;
uint8 cgram = 0;
uint10 oamAddress = 0;
uint8_t cgramAddress = 0;
uint16 oamAddress = 0;
uint8 cgramAddress = 0;
uint8_t mode7 = 0;
uint8 mode7 = 0;
bool counters = 0;
bool hcounter = 0; //hdot
bool vcounter = 0;
@ -66,8 +66,8 @@ public:
//serialization.cpp
auto serialize(serializer&) -> void;
uint8_t mdr = 0;
uint8_t bgofs = 0;
uint8 mdr = 0;
uint8 bgofs = 0;
} ppu1, ppu2;
};
@ -76,21 +76,21 @@ public:
auto serialize(serializer&) -> void;
bool displayDisable = 1;
uint4 displayBrightness = 0;
uint10 oamBaseAddress = 0;
uint10 oamAddress = 0;
uint8 displayBrightness = 0;
uint16 oamBaseAddress = 0;
uint16 oamAddress = 0;
bool oamPriority = 0;
bool bgPriority = 0;
uint3 bgMode = 0;
uint4 mosaicSize = 0;
uint8 bgMode = 0;
uint8 mosaicSize = 0;
bool vramIncrementMode = 0;
uint2 vramMapping = 0;
uint8 vramMapping = 0;
uint8 vramIncrementSize = 0;
uint16 vramAddress = 0;
uint8 cgramAddress = 0;
uint1 cgramAddressLatch = 0;
uint9 hcounter = 0; //hdot
uint9 vcounter = 0;
bool cgramAddressLatch = 0;
uint16 hcounter = 0; //hdot
uint16 vcounter = 0;
bool interlace = 0;
bool overscan = 0;
bool pseudoHires = 0;
@ -117,10 +117,10 @@ public:
//serialization.cpp
auto serialize(serializer&) -> void;
uint8_t oneLeft = 0;
uint8_t oneRight = 0;
uint8_t twoLeft = 0;
uint8_t twoRight = 0;
uint8 oneLeft = 0;
uint8 oneRight = 0;
uint8 twoLeft = 0;
uint8 twoRight = 0;
} window;
struct WindowLayer {
@ -154,17 +154,18 @@ public:
auto serialize(serializer&) -> void;
WindowLayer window;
bool aboveEnable = 0;
bool belowEnable = 0;
bool mosaicEnable = 0;
uint15 tiledataAddress = 0;
uint15 screenAddress = 0;
uint2 screenSize = 0;
uint16 tiledataAddress = 0;
uint16 screenAddress = 0;
uint8 screenSize = 0;
bool tileSize = 0;
uint16 hoffset = 0;
uint16 voffset = 0;
uint3 tileMode = 0;
uint4 priority[2] = {};
uint8 tileMode = 0;
uint8 priority[2] = {};
} bg1, bg2, bg3, bg4;
struct Object {
@ -172,16 +173,17 @@ public:
auto serialize(serializer&) -> void;
WindowLayer window;
bool aboveEnable = 0;
bool belowEnable = 0;
bool interlace = 0;
uint3 baseSize = 0;
uint2 nameselect = 0;
uint15 tiledataAddress = 0;
uint7 first = 0;
uint8 baseSize = 0;
uint8 nameselect = 0;
uint16 tiledataAddress = 0;
uint8 first = 0;
bool rangeOver = 0;
bool timeOver = 0;
uint4 priority[4] = {};
uint8 priority[4] = {};
} obj;
struct Color {
@ -189,12 +191,13 @@ public:
auto serialize(serializer&) -> void;
WindowColor window;
bool enable[7] = {};
bool directColor = 0;
bool blendMode = 0; //0 = fixed; 1 = pixel
bool halve = 0;
bool mathMode = 0; //0 = add; 1 = sub
uint15 fixedColor = 0;
uint16 fixedColor = 0;
} col;
};
@ -202,32 +205,32 @@ public:
//serialization.cpp
auto serialize(serializer&) -> void;
uint9 x = 0;
uint8_t y = 0;
uint8_t character = 0;
uint16 x = 0;
uint8 y = 0;
uint8 character = 0;
bool nameselect = 0;
bool vflip = 0;
bool hflip = 0;
uint2 priority = 0;
uint3 palette = 0;
uint8 priority = 0;
uint8 palette = 0;
bool size = 0;
};
struct ObjectItem {
bool valid = 0;
uint7 index = 0;
uint8_t width = 0;
uint8_t height = 0;
uint8 index = 0;
uint8 width = 0;
uint8 height = 0;
};
struct ObjectTile {
bool valid = 0;
uint9 x = 0;
uint8_t y = 0;
uint2 priority = 0;
uint8_t palette = 0;
uint16 x = 0;
uint8 y = 0;
uint8 priority = 0;
uint8 palette = 0;
bool hflip = 0;
uint11 number = 0;
uint16 number = 0;
};
struct Pixel {
@ -266,9 +269,10 @@ public:
Object objects[128] = {};
//[unserialized]
uint16_t output[2304 * 2160] = {};
uint16_t lightTable[16][32768] = {};
uint16_t* output = {};
uint16_t* lightTable[16] = {};
uint8_t* tilecache[3] = {}; //bitplane -> bitmap tiledata
uint ItemLimit = 0;
uint TileLimit = 0;
@ -302,10 +306,10 @@ public:
auto renderWindow(PPU::IO::WindowColor&, uint mask, bool output[256]) -> void;
//[unserialized]
uint9 y; //constant
uint y; //constant
IO io;
uint16_t cgram[256];
uint16 cgram[256];
ObjectItem items[128]; //32 on real hardware
ObjectTile tiles[128]; //34 on real hardware; 1024 max (128 * 64-width tiles)