From 382d1b2901dc286596af8ed62439ce8c1977e79a Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 14 Mar 2025 20:04:12 +1100 Subject: [PATCH] PS1: Implement 2D coloured polygons, support wider textures, change placeholder texture to grey --- misc/wiiu/ps_textured_exp.psh | 30 +++++++++++++++--------------- misc/wiiu/ps_textured_lin.psh | 28 ++++++++++++++-------------- misc/wiiu/textured_exp.gsh | Bin 1788 -> 1788 bytes misc/wiiu/textured_lin.gsh | Bin 1788 -> 1788 bytes src/Graphics_PS1.c | 27 ++++++++++++++------------- src/Window_PS1.c | 22 +++++++++++++++++++++- 6 files changed, 64 insertions(+), 43 deletions(-) diff --git a/misc/wiiu/ps_textured_exp.psh b/misc/wiiu/ps_textured_exp.psh index 0cb393020..6ac5cd167 100644 --- a/misc/wiiu/ps_textured_exp.psh +++ b/misc/wiiu/ps_textured_exp.psh @@ -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 diff --git a/misc/wiiu/ps_textured_lin.psh b/misc/wiiu/ps_textured_lin.psh index 7f8c28d1b..7b656ec82 100644 --- a/misc/wiiu/ps_textured_lin.psh +++ b/misc/wiiu/ps_textured_lin.psh @@ -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 diff --git a/misc/wiiu/textured_exp.gsh b/misc/wiiu/textured_exp.gsh index 4d31c65c5016e6e37fca42946720e29c3304686f..6ef52e1e38ddfdcf4d07db3834c38969138099d3 100644 GIT binary patch delta 104 zcmeyv`-gW!6f2|2=4e(P#!$uy3=RnlJPZvCMhp!97#1)IFeotmV^ILn3ja71m<1RZ z68ZHK%M!u1O)5&4-9ySL6 DJRBK` delta 28 kcmeyv`-gW!6e}ao=4e(PM%Km&3=RpC6PXewpJ6iq0EkWq@Bjb+ diff --git a/misc/wiiu/textured_lin.gsh b/misc/wiiu/textured_lin.gsh index f9ce2bc555fc766893eebee013db283499211120..a5d231e65e632b2ce91117c18ed1ed239055f91e 100644 GIT binary patch delta 104 zcmeyv`-gW!6f2|2=4e(P#!$uy3=RnlJPZvCMhp!9I2JGoFeotmV^9Fm3jbIXm<1RZ z68tpage = (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++; } diff --git a/src/Window_PS1.c b/src/Window_PS1.c index 23be62785..8fee2008d 100644 --- a/src/Window_PS1.c +++ b/src/Window_PS1.c @@ -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); }