Skip to content

Commit

Permalink
gpu/version-detect: GPU version detection based on nocash algorithm (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek authored Mar 30, 2020
1 parent 93568c5 commit 25c7295
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ IMAGES = common \
gpu/transparency \
gpu/triangle \
gpu/vram-to-vram-overlap \
gpu/version-detect \
gte-fuzz \
mdec \
spu/memory-transfer \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ texture-overflow | Draws textured rectangle with UV overflowing VRAM wid
transparency | Draws rectangles with 4 semi-transparent blending modes
triangle | Draws Gouroud shaded equilateral triangle
vram-to-vram-overlap | Test GP0(80) VRAM-VRAM copy behaviour in overlapping rects
version-detect | Uses GP1(0x10) and GP0(0xE1) to detect GPU version

### GTE

Expand Down
3 changes: 3 additions & 0 deletions gpu/version-detect/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TARGET = version-detect.elf

include ../../common-test.mk
37 changes: 37 additions & 0 deletions gpu/version-detect/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <common.h>
#include <stdint.h>

int main() {
initVideo(320, 240);
printf("gpu/version-detect\n");

// GPU version detection based on nocash documentation.
volatile uint32_t* GP0 = (volatile uint32_t*)0x1F801810;
volatile uint32_t* GP1 = (volatile uint32_t*)0x1F801814;
volatile uint32_t* GPUREAD = (volatile uint32_t*)0x1F801810;
volatile uint32_t* GPUSTAT = (volatile uint32_t*)0x1F801814;

*GP1 = 0x10000004;
*GP1 = 0x10000007;

uint32_t res1 = *GPUREAD;
printf("> GPUREAD = 0x%08X\n", res1);

if ((res1 & 0x00FFFFFF) == 2) {
printf("* GPU version 2 [New 208pin GPU (LATE-PU-8 and up)]\n");
} else {
*GP0 = (*GPUSTAT & 0x3FFF) | 0xE1001000;
uint32_t dummy = *GPUREAD;
uint32_t res2 = *GPUSTAT;
printf("> dummy=0x%08X, res2=0x%08X\n", dummy, res2);
if (res2 & 0x00001000)
printf("* GPU version 1 [unknown GPU type, maybe some custom arcade/prototype version ?]\n");
else
printf("* GPU version 0 [Old 160pin GPU (EARLY-PU-8)]\n");
}

for (;;) {
VSync(0);
}
return 0;
}

0 comments on commit 25c7295

Please sign in to comment.