diff --git a/Makefile b/Makefile index 2fcb3f9..4eda78b 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ IMAGES = common \ gpu/rectangles \ gpu/texture-overflow \ gpu/mask-bit \ + gpu/gp0-e1 \ gte-fuzz \ spu/test \ spu/stereo \ diff --git a/README.md b/README.md index 61f9101..dd7c9dc 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ gpu/lines | Draws lines using different modes - for verifying Bresenh gpu/rectangles | Draws all combinations of Rectangle commands gpu/texture-overflow | Draws textured rectangle with UV overflowing VRAM width gpu/mask-bit | Check Mask bit behavior during VRAM copy operations +gpu/gp0-e1 | Check if GP0_E1, GPUSTAT and polygon render uses the same register internally gte-fuzz | Executes GTE opcodes with random parameters, can be used to verify against real console spu/test | Check SPU behavior (data is lost randomly on 32bit access, ok on 16bit) spu/stereo | Play samples on first two voices diff --git a/gpu/gp0-e1/Makefile b/gpu/gp0-e1/Makefile new file mode 100644 index 0000000..1a1c545 --- /dev/null +++ b/gpu/gp0-e1/Makefile @@ -0,0 +1,3 @@ +include ../../common-test.mk + +TARGET = gp0-e1.elf \ No newline at end of file diff --git a/gpu/gp0-e1/main.cpp b/gpu/gp0-e1/main.cpp new file mode 100644 index 0000000..032cbfc --- /dev/null +++ b/gpu/gp0-e1/main.cpp @@ -0,0 +1,108 @@ +#include +#include + +const uint32_t E1_MASK = 0b10000111'11111111; + +void drawTexturedPolygon(uint16_t texpage) { + POLY_FT4 p = {0}; + setPolyFT4(&p); + setRGB0(&p, 0x80, 0x80, 0x80); + setClut(&p, 0, 0); + setUVWH(&p, 0, 0,255, 255); + setXY4(&p, + 0, 0, + 0, 32, + 32, 0, + 32, 32 + ); + p.tpage = texpage; + + DrawPrim(&p); +} + +// Check if writing zeroes to GP0_E1 == what GPSTAT read +void testWriteZerosToE1() { + writeGP1(0x09, 0); // Disable E1.11 bit + writeGP0(0xe1,0x000); + gpuNop(); + + assertEquals((ReadGPUstat() & E1_MASK), 0b00000000'00000000); +} + +// Check if writing ones to GP0_E1 == what GPSTAT read (no "Texture Disable") +void testWriteOnesToE1() { + writeGP1(0x09, 0); // Disable E1.11 bit + writeGP0(0xe1, 0xfff); + gpuNop(); + + assertEquals((ReadGPUstat() & E1_MASK), 0b00000111'11111111); +} + +// Check if writing ones to GP0_E1 == what GPSTAT read (with "Texture Disable") +void testWriteOnesToE1WithTextureDisable() { + writeGP1(0x09, 1); // Enable E1.11 bit + writeGP0(0xe1,0xfff); + gpuNop(); + + assertEquals((ReadGPUstat() & E1_MASK), 0b10000111'11111111); +} + +// Check which bits in GP0_E1 are changed by Textured Polygon draw commands +// vv - These two bits can be set via GP0_E1, but not via draw command +// 0b10000111'11111111 +void testTexturedPolygons() { + writeGP1(0x09, 0); // Disable E1.11 bit + writeGP0(0xe1,0x000); + + drawTexturedPolygon(0xffff); + gpuNop(); + + assertEquals((ReadGPUstat() & E1_MASK), 0b0000001'11111111); +} + +// Check which bits in GP0_E1 are changed by Textured Polygon draw commands (Texture Disable allowed) +void testTexturedPolygonsTextureDisable() { + writeGP1(0x09, 1); // Enable E1.11 bit + writeGP0(0xe1,0x000); + + drawTexturedPolygon(0xffff); + gpuNop(); + + assertEquals((ReadGPUstat() & E1_MASK), 0b10000001'11111111); +} + +// Check if drawing textured polygons doesn't change other bits in E1 register +void testTexturedPolygonsDoesNotChangeOtherBits() { + writeGP1(0x09, 1); // Enable E1.11 bit + writeGP0(0xe1,0xfff); + + drawTexturedPolygon(0x0000); + gpuNop(); + + assertEquals((ReadGPUstat() & E1_MASK), 0b00000110'00000000); +} + +void runTests() { + testWriteZerosToE1(); + testWriteOnesToE1(); + testWriteOnesToE1WithTextureDisable(); + testTexturedPolygons(); + testTexturedPolygonsTextureDisable(); + testTexturedPolygonsDoesNotChangeOtherBits(); + + printf("Done.\n"); +} + +int main() { + initVideo(320, 240); + printf("\ngpu/gp0-e1\n"); + + clearScreen(); + + runTests(); + + for (;;) { + VSync(0); + } + return 0; +} diff --git a/gpu/gp0-e1/psx.log b/gpu/gp0-e1/psx.log new file mode 100644 index 0000000..b2c591f --- /dev/null +++ b/gpu/gp0-e1/psx.log @@ -0,0 +1,8 @@ +gpu/gp0-e1 +pass - testWriteZerosToE1 +pass - testWriteOnesToE1 +pass - testWriteOnesToE1WithTextureDisable +pass - testTexturedPolygons +pass - testTexturedPolygonsTextureDisable +pass - testTexturedPolygonsDoesNotChangeOtherBits +Done. \ No newline at end of file