mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 14:15:11 +00:00
hot fix
This commit is contained in:
@@ -39,8 +39,12 @@ namespace ComSquare::PPU
|
|||||||
this->_oamadd.oamaddh = data;
|
this->_oamadd.oamaddh = data;
|
||||||
break;
|
break;
|
||||||
case ppuRegisters::oamdata:
|
case ppuRegisters::oamdata:
|
||||||
//! @brief not implemented yet.
|
|
||||||
this->_oamdata = data;
|
this->_oamdata = data;
|
||||||
|
throw InvalidAddress("oamdata", addr);
|
||||||
|
std::cout << "oamdata" << std::endl;
|
||||||
|
// the oamAddress have to be calculated if fblank or not (not implemented)
|
||||||
|
_oamram.write(this->_oamadd.oamAddress, this->_oamdata);
|
||||||
|
this->_oamadd.oamAddress++;
|
||||||
break;
|
break;
|
||||||
case ppuRegisters::bgmode:
|
case ppuRegisters::bgmode:
|
||||||
this->_bgmode.raw = data;
|
this->_bgmode.raw = data;
|
||||||
@@ -73,7 +77,17 @@ namespace ComSquare::PPU
|
|||||||
break;
|
break;
|
||||||
case ppuRegisters::vmain:
|
case ppuRegisters::vmain:
|
||||||
this->_vmain.raw = data;
|
this->_vmain.raw = data;
|
||||||
break;
|
switch (this->_vmain.incrementAmount) {
|
||||||
|
case 0b00:
|
||||||
|
this->_incrementAmount = 1;
|
||||||
|
break;
|
||||||
|
case 0b01:
|
||||||
|
this->_incrementAmount = 32;
|
||||||
|
break;
|
||||||
|
case 0b10:
|
||||||
|
case 0b11:
|
||||||
|
this->_incrementAmount = 128;
|
||||||
|
}
|
||||||
case ppuRegisters::vmaddl:
|
case ppuRegisters::vmaddl:
|
||||||
this->_vmadd.vmaddl = data;
|
this->_vmadd.vmaddl = data;
|
||||||
break;
|
break;
|
||||||
@@ -81,20 +95,23 @@ namespace ComSquare::PPU
|
|||||||
this->_vmadd.vmaddh = data;
|
this->_vmadd.vmaddh = data;
|
||||||
break;
|
break;
|
||||||
case ppuRegisters::vmdatal:
|
case ppuRegisters::vmdatal:
|
||||||
|
throw InvalidAddress("vmdata", addr);
|
||||||
|
std::cout << "vmdatal" << std::endl;
|
||||||
if (!this->_inidisp.fblank) {
|
if (!this->_inidisp.fblank) {
|
||||||
this->_vmdata.vmdatal = data;
|
this->_vmdata.vmdatal = data;
|
||||||
//this->_vram[getVramAddress()] = this->_vmdata.vmdata;
|
this->_vram.write(getVramAddress(), this->_vmdata.vmdata);
|
||||||
}
|
}
|
||||||
if (!this->_vmain.incrementMode)
|
if (!this->_vmain.incrementMode)
|
||||||
this->_vmadd.vmadd += this->_vmain.incrementAmount;
|
this->_vmadd.vmadd += this->_incrementAmount;
|
||||||
break;
|
break;
|
||||||
case ppuRegisters::vmdatah:
|
case ppuRegisters::vmdatah:
|
||||||
|
std::cout << "vmdatah" << std::endl;
|
||||||
if (!this->_inidisp.fblank) {
|
if (!this->_inidisp.fblank) {
|
||||||
this->_vmdata.vmdatah = data;
|
this->_vmdata.vmdatah = data;
|
||||||
//this->_vram[getVramAddress()] = this->_vmdata.vmdata;
|
this->_vram.write(getVramAddress(), this->_vmdata.vmdata);
|
||||||
}
|
}
|
||||||
if (this->_vmain.incrementMode)
|
if (this->_vmain.incrementMode)
|
||||||
this->_vmadd.vmadd += this->_vmain.incrementAmount;
|
this->_vmadd.vmadd += this->_incrementAmount;
|
||||||
break;
|
break;
|
||||||
case ppuRegisters::m7sel:
|
case ppuRegisters::m7sel:
|
||||||
this->_m7sel.raw = data;
|
this->_m7sel.raw = data;
|
||||||
@@ -104,11 +121,14 @@ namespace ComSquare::PPU
|
|||||||
this->_isLowByte = true;
|
this->_isLowByte = true;
|
||||||
break;
|
break;
|
||||||
case ppuRegisters::cgdata:
|
case ppuRegisters::cgdata:
|
||||||
|
throw InvalidAddress("cgdata", addr);
|
||||||
if (this->_isLowByte) {
|
if (this->_isLowByte) {
|
||||||
|
std::cout << "cgadatal" << std::endl;
|
||||||
this->_cgdata.cgdatal = data;
|
this->_cgdata.cgdatal = data;
|
||||||
this->_cgram.write(this->_cgadd, this->_cgdata.raw);
|
this->_cgram.write(this->_cgadd, this->_cgdata.raw);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
std::cout << "cgadatah" << std::endl;
|
||||||
this->_cgdata.cgdatah = data;
|
this->_cgdata.cgdatah = data;
|
||||||
this->_cgram.write(this->_cgadd, this->_cgdata.raw);
|
this->_cgram.write(this->_cgadd, this->_cgdata.raw);
|
||||||
}
|
}
|
||||||
@@ -186,14 +206,18 @@ namespace ComSquare::PPU
|
|||||||
int inc = 0;
|
int inc = 0;
|
||||||
//uint32_t pixelTmp = 0xFFFFFFFF;
|
//uint32_t pixelTmp = 0xFFFFFFFF;
|
||||||
//pixelTmp |= this->_inidisp.brightness;
|
//pixelTmp |= this->_inidisp.brightness;
|
||||||
|
std::cout << "update" << std::endl;
|
||||||
if (!this->_inidisp.fblank) {
|
if (!this->_inidisp.fblank) {
|
||||||
for (int x = 0; x < 448; x++) {
|
for (int x = 0; x < 448; x++) {
|
||||||
for (int y = 0; y < 512; y++) {
|
for (int y = 0; y < 512; y++) {
|
||||||
//this->_renderer.putPixel(x, y, ((uint32_t)_vram[inc++] << 8U) + 0xFFU);
|
if (inc == 0xFA00)
|
||||||
|
inc = 0;
|
||||||
|
//std::cout << "holy" << std::endl;
|
||||||
this->_renderer.putPixel(x, y, (uint32_t)this->_vram.read(inc++));
|
this->_renderer.putPixel(x, y, (uint32_t)this->_vram.read(inc++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::cout << "cgadata2" << std::endl;
|
||||||
this->_renderer.drawScreen();
|
this->_renderer.drawScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,6 +229,5 @@ namespace ComSquare::PPU
|
|||||||
_cgram(512)
|
_cgram(512)
|
||||||
{
|
{
|
||||||
this->_isLowByte = true;
|
this->_isLowByte = true;
|
||||||
//_vram = new uint16_t[32000];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,75 +217,100 @@ namespace ComSquare::PPU
|
|||||||
//! @brief INIDISP Register (F-blank and Brightness)
|
//! @brief INIDISP Register (F-blank and Brightness)
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
//! @brief Store the brightness value (F = max, 0 = off)
|
||||||
uint8_t brightness: 4;
|
uint8_t brightness: 4;
|
||||||
bool _: 3;
|
bool _: 3;
|
||||||
|
//! @brief Store the FBlank status
|
||||||
bool fblank: 1;
|
bool fblank: 1;
|
||||||
};
|
};
|
||||||
uint8_t raw;
|
uint8_t raw = 0;
|
||||||
} _inidisp;
|
} _inidisp;
|
||||||
//! @brief OBSEL Register (Object Size and Character Address)
|
//! @brief OBSEL Register (Object Size and Character Address)
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
uint8_t baseSelect: 3;
|
//! @brief Stores the location of the first sprite table
|
||||||
bool nameSelect: 2;
|
uint8_t nameBaseSelect: 3;
|
||||||
|
//! @brief Stores the offset of the second sprite table
|
||||||
|
uint8_t nameSelect: 2;
|
||||||
|
//! @brief Stores the resolution preset of the sprites
|
||||||
uint8_t objectSize: 3;
|
uint8_t objectSize: 3;
|
||||||
};
|
};
|
||||||
uint8_t raw;
|
uint8_t raw = 0;
|
||||||
} _obsel;
|
} _obsel;
|
||||||
//! @brief OAMADD Register (OAM Address and Obj Priority)
|
//! @brief OAMADD Register (OAM Address and Obj Priority)
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
//! @brief Stores the address to write with OAMDATA register
|
||||||
uint32_t oamAddress: 9;
|
uint32_t oamAddress: 9;
|
||||||
uint8_t _: 6;
|
uint8_t _: 6;
|
||||||
|
//! @brief When Obj Priority activation bit is set, an Obj other than Sprite 0 may be given priority
|
||||||
bool objPriorityActivationBit: 1;
|
bool objPriorityActivationBit: 1;
|
||||||
};
|
};
|
||||||
struct {
|
struct {
|
||||||
|
//! @brief Stores the data written on the OAMADDL register
|
||||||
uint8_t oamaddl;
|
uint8_t oamaddl;
|
||||||
|
//! @brief Stores the data written on the OAMADDH register
|
||||||
uint8_t oamaddh;
|
uint8_t oamaddh;
|
||||||
};
|
};
|
||||||
uint32_t raw;
|
uint32_t raw = 0;
|
||||||
} _oamadd;
|
} _oamadd;
|
||||||
//! @brief OAMDATA Register (Data for OAM write)
|
//! @brief OAMDATA Register (Data for OAM write)
|
||||||
uint8_t _oamdata;
|
uint8_t _oamdata;
|
||||||
//! @brief BGMODE Register (OAM Address and Obj Priority)
|
//! @brief BGMODE Register (OAM Address and Obj Priority)
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
//! @brief Stores the current BG Mode (0 - 7)
|
||||||
uint8_t bgMode: 3;
|
uint8_t bgMode: 3;
|
||||||
|
//! @brief When Mode 1 BG3 priority bit is set the BG3 is draw
|
||||||
bool mode1Bg3PriorityBit: 1;
|
bool mode1Bg3PriorityBit: 1;
|
||||||
|
//! @brief When The bit is set character size will 16x16 otherwise it is 8x8
|
||||||
bool characterSizeBg1: 1;
|
bool characterSizeBg1: 1;
|
||||||
|
//! @brief When The bit is set character size will 16x16 otherwise it is 8x8
|
||||||
bool characterSizeBg2: 1;
|
bool characterSizeBg2: 1;
|
||||||
|
//! @brief When The bit is set character size will 16x16 otherwise it is 8x8
|
||||||
bool characterSizeBg3: 1;
|
bool characterSizeBg3: 1;
|
||||||
|
//! @brief When The bit is set character size will 16x16 otherwise it is 8x8
|
||||||
bool characterSizeBg4: 1;
|
bool characterSizeBg4: 1;
|
||||||
};
|
};
|
||||||
uint8_t raw;
|
uint8_t raw = 0;
|
||||||
} _bgmode;
|
} _bgmode;
|
||||||
//! @brief MOSAIC Register (Screen Pixelation)
|
//! @brief MOSAIC Register (Screen Pixelation)
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
//! @brief Apply mosaic to the BG1
|
||||||
bool affectBg1: 1;
|
bool affectBg1: 1;
|
||||||
|
//! @brief Apply mosaic to the BG2
|
||||||
bool affectBg2: 1;
|
bool affectBg2: 1;
|
||||||
|
//! @brief Apply mosaic to the BG3
|
||||||
bool affectBg3: 1;
|
bool affectBg3: 1;
|
||||||
|
//! @brief Apply mosaic to the BG4
|
||||||
bool affectBg4: 1;
|
bool affectBg4: 1;
|
||||||
|
//! @brief Stores the pixel size (0 = 1x1, F = 16x16)
|
||||||
uint8_t pixelSize: 4;
|
uint8_t pixelSize: 4;
|
||||||
};
|
};
|
||||||
uint8_t raw;
|
uint8_t raw = 0;
|
||||||
} _mosaic;
|
} _mosaic;
|
||||||
//! @brief BGSC Registers (BG Tilemap Address and Size)
|
//! @brief BGSC Registers (BG Tilemap Address and Size)
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
//! @brief When tilemap horizontal mirroring bit is set the tilemap is mirrored horizontally
|
||||||
bool tilemapHorizontalMirroring: 1;
|
bool tilemapHorizontalMirroring: 1;
|
||||||
|
//! @brief When tilemap vertically mirroring bit is set the tilemap is mirrored vertically
|
||||||
bool tilemapVerticalMirroring: 1;
|
bool tilemapVerticalMirroring: 1;
|
||||||
|
//! @brief Address of the tilemap Address (0, 0)
|
||||||
uint8_t tilemapAddress: 6;
|
uint8_t tilemapAddress: 6;
|
||||||
};
|
};
|
||||||
uint8_t raw;
|
uint8_t raw = 0;
|
||||||
} _bgsc[4];
|
} _bgsc[4];
|
||||||
//! @brief BGNBA Registers (BG1/2/3/4 Chr Address)
|
//! @brief BGNBA Registers (BG1/2/3/4 Chr Address)
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
//! @brief The address let us know where to search for BG1/3 characters
|
||||||
uint8_t baseAddressBg1a3: 4;
|
uint8_t baseAddressBg1a3: 4;
|
||||||
|
//! @brief The address let us know where to search for BG2/4 characters
|
||||||
uint8_t baseAddressBg2a4: 4;
|
uint8_t baseAddressBg2a4: 4;
|
||||||
};
|
};
|
||||||
uint8_t raw;
|
uint8_t raw = 0;
|
||||||
} _bgnba[2];
|
} _bgnba[2];
|
||||||
//! @brief BGXXOFS Register (BG1/2/3/4 Horizontal and Vertical Scrolls)
|
//! @brief BGXXOFS Register (BG1/2/3/4 Horizontal and Vertical Scrolls)
|
||||||
union {
|
union {
|
||||||
@@ -314,6 +339,8 @@ namespace ComSquare::PPU
|
|||||||
};
|
};
|
||||||
uint8_t raw;
|
uint8_t raw;
|
||||||
} _vmain;
|
} _vmain;
|
||||||
|
//! @brief Store the real value of the increment Amount (1, 32, 128) instead of 0,1 or 2
|
||||||
|
uint8_t _incrementAmount;
|
||||||
//! @brief VMADD Register (VRAM Address)
|
//! @brief VMADD Register (VRAM Address)
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace ComSquare::Ram
|
|||||||
uint16_t ExtendedRam::read(uint24_t addr)
|
uint16_t ExtendedRam::read(uint24_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= this->_size)
|
if (addr >= this->_size)
|
||||||
throw InvalidAddress("ExtendedRam Write", addr);
|
throw InvalidAddress("ExtendedRam Read", addr);
|
||||||
return this->_data[addr];
|
return this->_data[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user