Skip to content

Commit

Permalink
added semi-transparency test
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed Sep 24, 2019
1 parent 058d664 commit da6b472
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 9 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ TOPTARGETS = build clean
IMAGES = gpu/bandwidth \
gpu/benchmark \
gpu/quad \
gpu/transparency \
gte-fuzz \
spu/test \
spu/stereo \
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

## Tests

Name | Description
--------------|------------
gpu/bandwidth | Measure GPU/VRAM bandwidth
gpu/benchmark | Simple GPU test to benchmark rasteriser
gpu/quad | Semi-transparent polygon commands - for testing fill rules and transparency handling
gte-fuzz | Executes GTE opcodes with random parameters, can be used to verify agains real console
spu/test | Check SPU behaviour (data is lost randomly on 32bit access, ok on 16bit)
spu/stereo | Play samples on first two voices
timers | Run Timer0,1,2 using various clock sources and sync modes and time them using busy loops and vblank interrupt
Name | Description
----------------|------------
gpu/bandwidth | Measure GPU/VRAM bandwidth
gpu/benchmark | Simple GPU test to benchmark rasteriser
gpu/quad | Semi-transparent polygon commands - for testing fill rules and transparency handling
gpu/transparency| Draws rectangles with 4 semi-transparent blending modes
gte-fuzz | Executes GTE opcodes with random parameters, can be used to verify agains real console
spu/test | Check SPU behaviour (data is lost randomly on 32bit access, ok on 16bit)
spu/stereo | Play samples on first two voices
timers | Run Timer0,1,2 using various clock sources and sync modes and time them using busy loops and vblank interrupt

Note: Make sure your PS-EXE loaded does set default value for Stack Pointer - these .exes has SP set to 0.

Expand Down
3 changes: 3 additions & 0 deletions gpu/transparency/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include $(PSN00BSDK)/sdk-common.mk

TARGET = transparency.elf
94 changes: 94 additions & 0 deletions gpu/transparency/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include <stdio.h>
#include <stdlib.h>
#include <psxgpu.h>
#include <psxetc.h>

DISPENV disp;
DRAWENV draw;

#define SCR_W 320
#define SCR_H 240

void setResolution(int w, int h) {
SetDefDispEnv(&disp, 0, 0, w, h);
SetDefDrawEnv(&draw, 0, 0, w, h);

PutDispEnv(&disp);
PutDrawEnv(&draw);
}

void initVideo()
{
ResetGraph(0);
setResolution(SCR_W, SCR_H);
SetDispMask(1);
}

void fillRect(int x, int y, int w, int h, int r, int g, int b) {
FILL f;
setFill(&f);
setRGB0(&f, r, g, b);
setXY0(&f, x, y);
setWH(&f, w, h);

DrawPrim(&f);
}

void clearScreen() {
fillRect(0, 0, 512, 256, 0xff, 0xff, 0xff);
fillRect(512, 0, 512, 256, 0xff, 0xff, 0xff);
fillRect(0, 256, 512, 256, 0xff, 0xff, 0xff);
fillRect(512, 256, 0x3f1, 256, 0xff, 0xff, 0xff);
}

void setSemiTransparencyMode(int mode) {
DR_TPAGE e;
unsigned short texpage = getTPage(/* bitcount - do not card */0, /* semi-transparency mode */ mode, /*x*/0, /*y*/0);
setDrawTPage(&e, /* Drawing to display area */ 1, /* dithering */ 0, texpage);
DrawPrim(&e);
}

const unsigned char bgColors[4] = {
0, 64, 128, 255,
};

int main() {
initVideo();
printf("\ngpu/transparency\n");

clearScreen();

for (;;) {
// Fill screen with 4 strips of different shade
for (int i = 0; i<4; i++) {
fillRect(SCR_W/4 * i, 0, SCR_W/4, SCR_H, bgColors[i], bgColors[i], bgColors[i]);
}

// For every semi-transparency (blending) mode
for (int mode = 0; mode <= 3; mode++) {
setSemiTransparencyMode(mode);

// Draw semi transparent rectangles with different colors
for (int x = 0; x < 8 * 4; x++) {
const int S = 8;

int r = 128 * ((x>>0)&1);
int g = 128 * ((x>>1)&1);
int b = 128 * ((x>>2)&1);
int y = mode;

TILE t;
setTile(&t);
setSemiTrans(&t, 1);
setRGB0(&t, r, g, b);
setXY0(&t, 1 + (S+2) * x, 64 + (S+16) * y);
setWH(&t, S, S);

DrawPrim(&t);
}
}

VSync(0);
}
return 0;
}
Binary file added gpu/transparency/vram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit da6b472

Please sign in to comment.