mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-07 22:34:43 -04:00
PS1: Implement 2D coloured polygons, support wider textures, change placeholder texture to grey
This commit is contained in:
parent
8b51e47b19
commit
382d1b2901
@ -25,20 +25,20 @@
|
||||
; -------- Disassembly --------------------
|
||||
00 TEX: ADDR(48) CNT(1) VALID_PIX
|
||||
0 SAMPLE R2, R2.xy0x, t0, s0
|
||||
01 ALU: ADDR(32) CNT(4)
|
||||
1 x: MUL ____, R1.y, R2.y
|
||||
y: MUL ____, R1.x, R2.x
|
||||
z: MUL ____, R1.z, R2.z
|
||||
w: MUL R2.w, R1.w, R2.w
|
||||
t: RCP_sat ____, R0.w
|
||||
2 x: ADD R1.x, PV1.x, -C0.y
|
||||
y: ADD R1.y, PV1.y, -C0.x
|
||||
w: ADD R0.w, PV1.z, -C0.z
|
||||
t: RCP_e ____, PS1
|
||||
3 w: MUL ____, PS2, C1.x
|
||||
4 t: EXP_e ____, PV3.w CLAMP
|
||||
5 x: MULADD R2.x, R1.y, PS4, C0.x
|
||||
y: MULADD R2.y, R1.x, PS4, C0.y
|
||||
z: MULADD R2.z, R0.w, PS4, C0.z
|
||||
01 ALU: ADDR(32) CNT(14)
|
||||
1 x: MUL ____, R1.y, R2.y
|
||||
y: MUL ____, R1.x, R2.x
|
||||
z: MUL ____, R1.z, R2.z
|
||||
w: MUL R2.w, R1.w, R2.w
|
||||
t: RECIP_CLAMPED ____, R0.w
|
||||
2 x: ADD R1.x, PV1.x, -C0.y
|
||||
y: ADD R1.y, PV1.y, -C0.x
|
||||
w: ADD R0.w, PV1.z, -C0.z
|
||||
t: RCP_e ____, PS1
|
||||
3 w: MUL ____, PS2, C1.x
|
||||
4 t: EXP_e ____, PV3.w CLAMP
|
||||
5 x: MULADD R2.x, R1.y, PS4, C0.x
|
||||
y: MULADD R2.y, R1.x, PS4, C0.y
|
||||
z: MULADD R2.z, R0.w, PS4, C0.z
|
||||
02 EXP_DONE: PIX0, R2
|
||||
END_OF_PROGRAM
|
||||
|
@ -25,20 +25,20 @@
|
||||
; -------- Disassembly --------------------
|
||||
00 TEX: ADDR(48) CNT(1) VALID_PIX
|
||||
0 SAMPLE R2, R2.xy0x, t0, s0
|
||||
01 ALU: ADDR(32) CNT(4)
|
||||
1 x: MUL ____, R1.x, R2.x
|
||||
y: MUL ____, R1.z, R2.z
|
||||
z: MUL ____, R1.y, R2.y
|
||||
w: MUL R2.w, R1.w, R2.w
|
||||
t: RCP_sat ____, R0.w
|
||||
2 x: ADD R1.x, PV1.z, -C0.y
|
||||
y: ADD R1.y, PV1.x, -C0.x
|
||||
w: ADD R0.w, PV1.y, -C0.z
|
||||
t: RCP_e ____, PS1
|
||||
3 z: MULADD R127.z, -PS2, C1.y, 1.0f CLAMP
|
||||
4 x: MULADD R2.x, R1.y, PV3.z, C0.x
|
||||
y: MULADD R2.y, R1.x, PV3.z, C0.y
|
||||
z: MULADD R2.z, R0.w, PV3.z, C0.z
|
||||
01 ALU: ADDR(32) CNT(14)
|
||||
1 x: MUL ____, R1.x, R2.x
|
||||
y: MUL ____, R1.z, R2.z
|
||||
z: MUL ____, R1.y, R2.y
|
||||
w: MUL R2.w, R1.w, R2.w
|
||||
t: RECIP_CLAMPED ____, R0.w
|
||||
2 x: ADD R1.x, PV1.z, -C0.y
|
||||
y: ADD R1.y, PV1.x, -C0.x
|
||||
w: ADD R0.w, PV1.y, -C0.z
|
||||
t: RECIP_IEEE ____, PS1
|
||||
3 z: MULADD R127.z, -PS2, C1.y, 1.0f CLAMP
|
||||
4 x: MULADD R2.x, R1.y, PV3.z, C0.x
|
||||
y: MULADD R2.y, R1.x, PV3.z, C0.y
|
||||
z: MULADD R2.z, R0.w, PV3.z, C0.z
|
||||
02 EXP_DONE: PIX0, R2
|
||||
END_OF_PROGRAM
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -158,9 +158,9 @@ static cc_bool cullingEnabled;
|
||||
void Gfx_RestoreState(void) {
|
||||
InitDefaultResources();
|
||||
|
||||
// 2x2 dummy white texture
|
||||
// dummy texture (grey works better in menus than white)
|
||||
struct Bitmap bmp;
|
||||
BitmapCol pixels[4] = { BitmapColor_RGB(255, 0, 0), BITMAPCOLOR_WHITE, BITMAPCOLOR_WHITE, BITMAPCOLOR_WHITE };
|
||||
BitmapCol pixels[4] = { BitmapColor_RGB(130, 130, 130), BitmapColor_RGB(130, 130, 130), BitmapColor_RGB(130, 130, 130), BitmapColor_RGB(130, 130, 130) };
|
||||
Bitmap_Init(bmp, 2, 2, pixels);
|
||||
white_square = Gfx_CreateTexture(&bmp, 0, false);
|
||||
}
|
||||
@ -171,7 +171,7 @@ void Gfx_FreeState(void) {
|
||||
}
|
||||
|
||||
void Gfx_Create(void) {
|
||||
Gfx.MaxTexWidth = 128;
|
||||
Gfx.MaxTexWidth = 256;
|
||||
Gfx.MaxTexHeight = 256;
|
||||
Gfx.Created = true;
|
||||
Gfx.Limitations = GFX_LIMIT_MAX_VERTEX_SIZE;
|
||||
@ -338,7 +338,7 @@ typedef struct GPUTexture {
|
||||
cc_uint16 width, height;
|
||||
cc_uint8 u_shift, v_shift;
|
||||
cc_uint8 xOffset, yOffset;
|
||||
cc_uint16 tpage, line;
|
||||
cc_uint16 tpage, clut, line;
|
||||
} GPUTexture;
|
||||
static GPUTexture textures[TEXTURES_MAX_COUNT];
|
||||
static GPUTexture* curTex;
|
||||
@ -370,6 +370,7 @@ static void* AllocTextureAt(int i, struct Bitmap* bmp, int rowWidth) {
|
||||
int pageX = (page % TPAGES_PER_HALF);
|
||||
int pageY = (page / TPAGES_PER_HALF);
|
||||
tex->tpage = (2 << 7) | (pageY << 4) | pageX;
|
||||
tex->clut = 0;
|
||||
|
||||
VRAM_AllocBlock(line, bmp->width, bmp->height);
|
||||
if (bmp->height > bmp->width) {
|
||||
@ -539,8 +540,8 @@ static void PreprocessTexturedVertices(void) {
|
||||
dst->xx = x >> 8;
|
||||
dst->yy = y >> 8;
|
||||
|
||||
u = src->U * 0.99f;
|
||||
v = src->V == 1.0f ? 0.99f : src->V;
|
||||
u = src->U * 0.999f;
|
||||
v = src->V == 1.0f ? 0.999f : src->V;
|
||||
|
||||
dst->u = UVFixed(u);
|
||||
dst->v = UVFixed(v);
|
||||
@ -733,14 +734,13 @@ static void DrawColouredQuads2D(int verticesCount, int startVertex) {
|
||||
struct PS1VertexColoured* v = (struct PS1VertexColoured*)gfx_vertices + startVertex;
|
||||
struct PSX_POLY_F4* poly = next_packet;
|
||||
cc_uint8* max = next_packet_end - sizeof(*poly);
|
||||
return;
|
||||
|
||||
for (int i = 0; i < verticesCount; i += 4, v += 4)
|
||||
{
|
||||
if ((cc_uint8*)poly > max) break;
|
||||
|
||||
setlen(poly, POLY_LEN_F4);
|
||||
poly->rgbc = v->rgbc;
|
||||
poly->rgbc = v->rgbc | POLY_CMD_SEMITRNS;
|
||||
|
||||
poly->x0 = v[1].xx; poly->y0 = v[1].yy;
|
||||
poly->x1 = v[0].xx; poly->y1 = v[0].yy;
|
||||
@ -762,6 +762,7 @@ static void DrawTexturedQuads2D(int verticesCount, int startVertex) {
|
||||
struct PS1VertexTextured* v = (struct PS1VertexTextured*)gfx_vertices + startVertex;
|
||||
int uOffset = curTex->xOffset, vOffset = curTex->yOffset;
|
||||
int uShift = curTex->u_shift, vShift = curTex->v_shift;
|
||||
int tpage = curTex->tpage, clut = curTex->clut;
|
||||
|
||||
struct PSX_POLY_FT4* poly = next_packet;
|
||||
cc_uint8* max = next_packet_end - sizeof(*poly);
|
||||
@ -772,8 +773,8 @@ static void DrawTexturedQuads2D(int verticesCount, int startVertex) {
|
||||
|
||||
setlen(poly, POLY_LEN_FT4);
|
||||
poly->rgbc = v->rgbc;
|
||||
poly->tpage = curTex->tpage;
|
||||
poly->clut = 0;
|
||||
poly->tpage = tpage;
|
||||
poly->clut = clut;
|
||||
|
||||
poly->x0 = v[1].xx; poly->y0 = v[1].yy;
|
||||
poly->x1 = v[0].xx; poly->y1 = v[0].yy;
|
||||
@ -848,7 +849,7 @@ static void DrawTexturedQuads3D(int verticesCount, int startVertex) {
|
||||
int uShift = curTex->u_shift;
|
||||
int vShift = curTex->v_shift;
|
||||
|
||||
int page = curTex->tpage;
|
||||
int tpage = curTex->tpage, clut = curTex->clut;
|
||||
uint32_t* ot = cur_buffer->ot;
|
||||
|
||||
struct PSX_POLY_FT4* poly = next_packet;
|
||||
@ -895,8 +896,8 @@ static void DrawTexturedQuads3D(int verticesCount, int startVertex) {
|
||||
poly->u3 = (v3->u >> uShift) + uOffset;
|
||||
poly->v3 = (v3->v >> vShift) + vOffset;
|
||||
|
||||
poly->tpage = page;
|
||||
poly->clut = 0;
|
||||
poly->tpage = tpage;
|
||||
poly->clut = clut;
|
||||
addPrim(&ot[p >> 2], poly);
|
||||
poly++;
|
||||
}
|
||||
|
@ -137,6 +137,26 @@ void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
// 1 = Circle, 2 = Cross, 3 = Square, 4 = Triangle
|
||||
static const BindMapping pad_defaults[BIND_COUNT] = {
|
||||
[BIND_FORWARD] = { CCPAD_UP, 0 },
|
||||
[BIND_BACK] = { CCPAD_DOWN, 0 },
|
||||
[BIND_LEFT] = { CCPAD_LEFT, 0 },
|
||||
[BIND_RIGHT] = { CCPAD_RIGHT, 0 },
|
||||
[BIND_JUMP] = { CCPAD_1, 0 },
|
||||
[BIND_SET_SPAWN] = { CCPAD_START, 0 },
|
||||
[BIND_CHAT] = { CCPAD_4, 0 },
|
||||
[BIND_INVENTORY] = { CCPAD_3, 0 },
|
||||
[BIND_SEND_CHAT] = { CCPAD_START, 0 },
|
||||
[BIND_SPEED] = { CCPAD_2, CCPAD_L },
|
||||
[BIND_NOCLIP] = { CCPAD_2, CCPAD_3 },
|
||||
[BIND_FLY] = { CCPAD_2, CCPAD_R },
|
||||
[BIND_FLY_UP] = { CCPAD_2, CCPAD_UP },
|
||||
[BIND_FLY_DOWN] = { CCPAD_2, CCPAD_DOWN },
|
||||
[BIND_PLACE_BLOCK] = { CCPAD_L, 0 },
|
||||
[BIND_DELETE_BLOCK] = { CCPAD_R, 0 },
|
||||
};
|
||||
|
||||
static char pad_buff[2][34];
|
||||
|
||||
void Gamepads_Init(void) {
|
||||
@ -198,7 +218,7 @@ static void ProcessPadInput(int port, PADTYPE* pad, float delta) {
|
||||
|
||||
void Gamepads_Process(float delta) {
|
||||
PADTYPE* pad = (PADTYPE*)&pad_buff[0][0];
|
||||
int port = Gamepad_Connect(0x503E, PadBind_Defaults);
|
||||
int port = Gamepad_Connect(0x503E, pad_defaults);
|
||||
|
||||
if (pad->stat == 0) ProcessPadInput(port, pad, delta);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user