mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-06-01 18:41:13 -07:00
WIP: preparing to setup metaprogramming codegen for PS1 processors.
This commit is contained in:
+26
-22
@@ -17,21 +17,21 @@ enum {
|
||||
};
|
||||
|
||||
typedef U4 OrderingTable_Buffer[OrderingTbl_Len];
|
||||
typedef def_farray(OrderingTable_Buffer, 2);
|
||||
typedef Array_(OrderingTable_Buffer, 2);
|
||||
|
||||
typedef B1 PrimitiveBuffer[PrimitiveBuff_Len];
|
||||
typedef def_farray(PrimitiveBuffer, 2);
|
||||
typedef def_struct(PrimitiveArena) {
|
||||
typedef Array_(PrimitiveBuffer, 2);
|
||||
typedef Struct_(PrimitiveArena) {
|
||||
A2_PrimitiveBuffer buf;
|
||||
U4 used;
|
||||
};
|
||||
|
||||
#define Cube_num_verts 8
|
||||
typedef def_farray(V3_S2, Cube_num_verts);
|
||||
typedef Array_(V3_S2, Cube_num_verts);
|
||||
#define Cube_num_faces 6
|
||||
typedef def_farray(V4_S2, Cube_num_faces);
|
||||
void ent_cube128_init(A8_V3_S2* verts, A6_V4_S2* faces) {
|
||||
memory_copy(verts, & (A8_V3_S2) {
|
||||
typedef Array_(V4_S2, Cube_num_faces);
|
||||
I_ void ent_cube128_init(A8_V3_S2* verts, A6_V4_S2* faces) {
|
||||
LP_ A8_V3_S2 baked_verts = (A8_V3_S2) {
|
||||
{ -128, -128, -128 },
|
||||
{ 128, -128, -128 },
|
||||
{ 128, -128, 128 },
|
||||
@@ -40,18 +40,20 @@ void ent_cube128_init(A8_V3_S2* verts, A6_V4_S2* faces) {
|
||||
{ 128, 128, -128 },
|
||||
{ 128, 128, 128 },
|
||||
{ -128, 128, 128 }
|
||||
}, size_of(A8_V3_S2) );
|
||||
memory_copy(faces, & (A6_V4_S2) {
|
||||
};
|
||||
LP_ A6_V4_S2 baked_faces = (A6_V4_S2) {
|
||||
{ 3, 2, 0, 1 },
|
||||
{ 0, 1, 4, 5 },
|
||||
{ 4, 5, 7, 6 },
|
||||
{ 1, 2, 5, 6 },
|
||||
{ 2, 3, 6, 7 },
|
||||
{ 3, 0, 7, 4 },
|
||||
}, size_of(A6_V4_S2) );
|
||||
};
|
||||
mem_copy(u4_(verts), u4_(& baked_verts), S_(A8_V3_S2) );
|
||||
mem_copy(u4_(faces), u4_(& baked_faces), S_(A6_V4_S2) );
|
||||
return;
|
||||
}
|
||||
typedef def_struct(Ent_Cube) {
|
||||
typedef Struct_(Ent_Cube) {
|
||||
V3_S4 accel;
|
||||
V3_S4 vel;
|
||||
V3_S4 pos;
|
||||
@@ -62,22 +64,24 @@ typedef def_struct(Ent_Cube) {
|
||||
};
|
||||
|
||||
#define Floor_num_verts 4
|
||||
typedef def_farray(V3_S2, Floor_num_verts);
|
||||
typedef Array_(V3_S2, Floor_num_verts);
|
||||
#define Floor_num_faces 2
|
||||
typedef def_farray(V3_S2, Floor_num_faces);
|
||||
void ent_floor_init(A4_V3_S2* verts, A2_V3_S2* faces) {
|
||||
memory_copy(verts, &(A4_V3_S2) {
|
||||
typedef Array_(V3_S2, Floor_num_faces);
|
||||
I_ void ent_floor_init(A4_V3_S2* verts, A2_V3_S2* faces) {
|
||||
LP_ A4_V3_S2 baked_verts = (A4_V3_S2) {
|
||||
{ -900, 0, -900 },
|
||||
{ -900, 0, 900 },
|
||||
{ 900, 0, -900 },
|
||||
{ 900, 0, 900 },
|
||||
}, size_of(A8_V3_S2));
|
||||
memory_copy(faces, & (A2_V3_S2) {
|
||||
};
|
||||
LP_ A2_V3_S2 baked_faces = (A2_V3_S2) {
|
||||
{ 0, 1, 2 },
|
||||
{ 1, 3, 2 },
|
||||
}, size_of(A2_V3_S2));
|
||||
};
|
||||
mem_copy(u4_(verts), u4_(& baked_verts), S_(A4_V3_S2));
|
||||
mem_copy(u4_(faces), u4_(& baked_faces), S_(A2_V3_S2));
|
||||
};
|
||||
typedef def_struct(Ent_Floor) {
|
||||
typedef Struct_(Ent_Floor) {
|
||||
V3_S4 accel;
|
||||
V3_S4 pos;
|
||||
V3_S4 scale;
|
||||
@@ -86,7 +90,7 @@ typedef def_struct(Ent_Floor) {
|
||||
A2_V3_S2 faces;
|
||||
};
|
||||
|
||||
typedef def_struct(SMemory) {
|
||||
typedef Struct_(SMemory) {
|
||||
DoubleBuffer screen_buf;
|
||||
A2_OrderingTable_Buffer ordering_tbl;
|
||||
PrimitiveArena primitives;
|
||||
@@ -100,7 +104,7 @@ typedef def_struct(SMemory) {
|
||||
global SMemory static_mem;
|
||||
extern SMemory static_mem;
|
||||
|
||||
B1* prim__alloc(U4 type_width, Str8 type_name) {
|
||||
I_ B1* prim__alloc(U4 type_width, Str8 type_name) {
|
||||
gknown PrimitiveArena* pa = & static_mem.primitives;
|
||||
gknown B1* buf = (B1*) r_(static_mem.primitives.buf)[static_mem.active_buf_id];
|
||||
assert(pa->used + type_width < PrimitiveBuff_Len);
|
||||
@@ -108,7 +112,7 @@ B1* prim__alloc(U4 type_width, Str8 type_name) {
|
||||
pa->used += type_width;
|
||||
return next;
|
||||
}
|
||||
#define prim_alloc(type) (type*)prim__alloc(size_of(type), txt( stringify(type)))
|
||||
#define prim_alloc(type) (type*)prim__alloc(S_(type), txt( stringify(type)))
|
||||
|
||||
void gp_screen_init_c11(DoubleBuffer* screen_buf, S2* active_buf_id)
|
||||
{
|
||||
|
||||
+17
-17
@@ -5,8 +5,8 @@
|
||||
# include "duffle/gp.h"
|
||||
#endif
|
||||
|
||||
typedef def_struct(DrawEnv_Packed) { U4 tag; U4 code[15]; };
|
||||
typedef def_struct(DrawEnv) {
|
||||
typedef Struct_(DrawEnv_Packed) { U4 tag; U4 code[15]; };
|
||||
typedef Struct_(DrawEnv) {
|
||||
Rect_S2 clip_area;
|
||||
A2_S2 drawing_offset;
|
||||
Rect_S2 texture_window;
|
||||
@@ -17,7 +17,7 @@ typedef def_struct(DrawEnv) {
|
||||
RGB8 initial_bg_color;
|
||||
DrawEnv_Packed dr_env; // reserved
|
||||
};
|
||||
typedef def_struct(DisplayEnv) {
|
||||
typedef Struct_(DisplayEnv) {
|
||||
Rect_S2 display_area;
|
||||
Rect_S2 screen;
|
||||
B1 vinterlace;
|
||||
@@ -25,9 +25,9 @@ typedef def_struct(DisplayEnv) {
|
||||
B1 pad0;
|
||||
B1 pad1;
|
||||
};
|
||||
typedef def_farray(DrawEnv, 2);
|
||||
typedef def_farray(DisplayEnv, 2);
|
||||
typedef def_struct(DoubleBuffer) {
|
||||
typedef Array_(DrawEnv, 2);
|
||||
typedef Array_(DisplayEnv, 2);
|
||||
typedef Struct_(DoubleBuffer) {
|
||||
A2_DrawEnv draw;
|
||||
A2_DisplayEnv display;
|
||||
};
|
||||
@@ -58,7 +58,7 @@ U4 vsync(U4 mode) __asm__("VSync");
|
||||
|
||||
void draw_orderingtbl(U4* buf) __asm__("DrawOTag");
|
||||
|
||||
typedef def_struct(PolyTag) {
|
||||
typedef Struct_(PolyTag) {
|
||||
U4 addr: 24;
|
||||
U4 len: 8;
|
||||
RGB8 color;
|
||||
@@ -106,7 +106,7 @@ typedef def_struct(PolyTag) {
|
||||
// #define setLineF4(p) set_len(p, 6), set_code(p, 0x4c),(p)->pad = 0x55555555
|
||||
// #define setLineG4(p) set_len(p, 9), set_code(p, 0x5c),(p)->pad = 0x55555555, (p)->p2 = 0, (p)->p3 = 0
|
||||
|
||||
typedef def_struct(Poly_F3) {
|
||||
typedef Struct_(Poly_F3) {
|
||||
U4 tag;
|
||||
RGB8 color;
|
||||
B1 code;
|
||||
@@ -120,14 +120,14 @@ typedef def_struct(Poly_F3) {
|
||||
};
|
||||
};
|
||||
|
||||
typedef def_struct(Poly_G3) {
|
||||
typedef Struct_(Poly_G3) {
|
||||
U4 tag; RGB8 c0; B1 code;
|
||||
V2_S2 p0; RGB8 c1; B1 pad1;
|
||||
V2_S2 p1; RGB8 c2; B1 pad2;
|
||||
V2_S2 p2;
|
||||
};
|
||||
|
||||
typedef def_struct(Poly_F4) {
|
||||
typedef Struct_(Poly_F4) {
|
||||
U4 tag;
|
||||
RGB8 color;
|
||||
B1 code;
|
||||
@@ -142,7 +142,7 @@ typedef def_struct(Poly_F4) {
|
||||
};
|
||||
};
|
||||
|
||||
typedef def_struct(Poly_G4) {
|
||||
typedef Struct_(Poly_G4) {
|
||||
U4 tag; RGB8 c0; B1 code;
|
||||
V2_S2 p0; RGB8 c1; B1 pad1;
|
||||
V2_S2 p1; RGB8 c2; B1 pad2;
|
||||
@@ -150,7 +150,7 @@ typedef def_struct(Poly_G4) {
|
||||
V2_S2 p3;
|
||||
};
|
||||
|
||||
typedef def_struct(Tile) {
|
||||
typedef Struct_(Tile) {
|
||||
U4 tag;
|
||||
RGB8 color;
|
||||
B1 code;
|
||||
@@ -169,7 +169,7 @@ M3_S2* m3s2_scale (M3_S2* mat, V3_S4* vec) __asm__("ScaleMatrix");
|
||||
// Rotation, Translation, Perspective
|
||||
|
||||
S4 rtp_v3s2_raw(V3_S2* vec, S4* xy, S4* pp, S4* flag) __asm__("RotTransPers");
|
||||
FI_ S4 rtp_v3s2(V3_S2* vec, V2_S2* xy, A2_S2* pp, S4* flag) { return rtp_v3s2_raw(vec, cast(S4*R_, & xy->x), cast(S4*R_, pp), r_(flag)); }
|
||||
FI_ S4 rtp_v3s2(V3_S2* vec, V2_S2* xy, A2_S2* pp, S4* flag) { return rtp_v3s2_raw(vec, C_(S4*R_, & xy->x), C_(S4*R_, pp), r_(flag)); }
|
||||
|
||||
S4 rtp_avg_nclip_a3_v3s2_raw(V3_S2* v0, V3_S2* v1, V3_S2* v2, S4* xy1, S4* xy2, S4* xy3, S4* pp, S4* otz, S4* flag) __asm__("RotAverageNclip3");
|
||||
FI_ S4 rtp_avg_nclip_a3_v3s2(
|
||||
@@ -179,8 +179,8 @@ FI_ S4 rtp_avg_nclip_a3_v3s2(
|
||||
){
|
||||
return rtp_avg_nclip_a3_v3s2_raw(
|
||||
v0, v1, v2,
|
||||
cast(S4*R_, xy0), cast(S4*R_, xy1), cast(S4*R_, xy2),
|
||||
cast(S4*R_, pp), cast(S4*R_, otz), cast(S4*R_, flag)
|
||||
C_(S4*R_, xy0), C_(S4*R_, xy1), C_(S4*R_, xy2),
|
||||
C_(S4*R_, pp), C_(S4*R_, otz), C_(S4*R_, flag)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ FI_ S4 rtp_avg_nclip_a4_v3s2(
|
||||
){
|
||||
return rtp_avg_nclip_a4_v3s2_raw(
|
||||
v0, v1, v2, v3,
|
||||
cast(S4*R_, xy0), cast(S4*R_, xy1), cast(S4*R_, xy2), cast(S4*R_, xy3),
|
||||
cast(S4*R_, pp), cast(S4*R_, otz), cast(S4*R_, flag)
|
||||
C_(S4*R_, xy0), C_(S4*R_, xy1), C_(S4*R_, xy2), C_(S4*R_, xy3),
|
||||
C_(S4*R_, pp), C_(S4*R_, otz), C_(S4*R_, flag)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user