Skip to content

Commit

Permalink
gp0_e1 test
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed Dec 2, 2019
1 parent 79dfb13 commit a5dec9e
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ IMAGES = common \
gpu/rectangles \
gpu/texture-overflow \
gpu/mask-bit \
gpu/gp0-e1 \
gte-fuzz \
spu/test \
spu/stereo \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions gpu/gp0-e1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include ../../common-test.mk

TARGET = gp0-e1.elf
108 changes: 108 additions & 0 deletions gpu/gp0-e1/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#include <common.h>
#include <test.h>

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;
}
8 changes: 8 additions & 0 deletions gpu/gp0-e1/psx.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
gpu/gp0-e1
pass - testWriteZerosToE1
pass - testWriteOnesToE1
pass - testWriteOnesToE1WithTextureDisable
pass - testTexturedPolygons
pass - testTexturedPolygonsTextureDisable
pass - testTexturedPolygonsDoesNotChangeOtherBits
Done.

0 comments on commit a5dec9e

Please sign in to comment.