diff --git a/code/asmdd/dsl.s b/code/asmdd/dsl.s index 2e7cb82..838e0f1 100644 --- a/code/asmdd/dsl.s +++ b/code/asmdd/dsl.s @@ -162,18 +162,20 @@ .set byte, 1 .set word, 4 -.equ U8, 1 -.equ S8, 1 -.equ U16, 2 -.equ S16, 2 -.equ U32, 4 -.equ S32, 4 -.equ SSIZE, 4 -.equ USIZE, 4 -.equ B8, S8 -.equ B16, S16 -.equ B32, S32 +.equ U1, 1 +.equ U2, 2 +.equ U4, 4 +.equ S1, 1 +.equ S2, 2 +.equ S4, 4 +.equ B1, 1 +.equ B2, 2 +.equ B3, 3 .equ false, 0 .equ true, 1 .equ true_overflow, 3 + +.macro struct_field name type_width, prev_offset +\name \prev_offset +.endm diff --git a/code/asmdd/math.s b/code/asmdd/math.s index 2bd6ec5..11506e1 100644 --- a/code/asmdd/math.s +++ b/code/asmdd/math.s @@ -1,46 +1,46 @@ -.equ A2_S16, (S16 * 2) -.equ A2_S32, (S32 * 2) -# Extent_2S16 { S16 width; S16 height; } -.equ Extent_2S16_width, (S16 * 0) -.equ Extent_2S16_height, (S16 * 1) -.equ Extent_2S16, (S16 * 2) -# Extent_2S32 { S32 width; S32 height; } -.equ Extent_2S32_width, (S32 * 0) -.equ Extent_2S32_height, (S32 * 1) -.equ Extent_2S32, (S32 * 2) -# Vec_2S16 { S16 x; S16 y; } -.equ Vec_2S16_x, (S16 * 0) -.equ Vec_2S16_y, (S16 * 1) -.equ Vec_2S16, (S16 * 2) -# Vec_2S32 { S32 x; S32 y; } -.equ Vec_2S32_x, (S32 * 0) -.equ Vec_2S32_y, (S32 * 1) -.equ Vec_2S32, (S32 * 2) -# Range_2S16 { Vec_2S16 p0; Vec_2S16 p1; } -.equ Range_2S16_p0, (Vec_2S16 * 0) -.equ Range_2S16_p1, (Vec_2S16 * 1) -.equ Range_2S16_p0_x, (S16 * 0) -.equ Range_2S16_p0_y, (S16 * 1) -.equ Range_2S16_p1_x, (S16 * 2) -.equ Range_2S16_p1_y, (S16 * 3) -.equ Range_2S16, (S16 * 4) -# Range_2S32 { Vec_2S32 p0; Vec_2S32 p1; } -.equ Range_2S32_p0, (Vec_2S32 * 0) -.equ Range_2S32_p1, (Vec_2S32 * 1) -.equ Range_2S32_p0_x, (S32 * 0) -.equ Range_2S32_p0_y, (S32 * 1) -.equ Range_2S32_p1_x, (S32 * 2) -.equ Range_2S32_p1_y, (S32 * 3) -.equ Range_2S32, (S32 * 4) -# Rect_S16 { S16 x; S16 y; S16 width; S16 height; } -.equ Rect_S16_x, (S16 * 0) -.equ Rect_S16_y, (S16 * 1) -.equ Rect_S16_width, (S16 * 2) -.equ Rect_S16_height, (S16 * 3) -.equ Rect_S16, (S16 * 4) -# Rect_S32 { S32 x; S32 y; S32 width; S32 height; } -.equ Rect_S32_x, (S32 * 0) -.equ Rect_S32_y, (S32 * 1) -.equ Rect_S32_width, (S32 * 2) -.equ Rect_S32_height, (S32 * 3) -.equ Rect_S32, (S32 * 4) +.equ A2_S2, (S2 * 2) +.equ A2_S4, (S4 * 2) +# Extent2_S2 { S2 width; S2 height; } +.equ Extent2_S2_width, (S2 * 0) +.equ Extent2_S2_height, (S2 * 1) +.equ Extent2_S2, (S2 * 2) +# Extent2_S4 { S4 width; S4 height; } +.equ Extent2_S4_width, (S2 * 0) +.equ Extent2_S4_height, (S2 * 1) +.equ Extent2_S4, (S2 * 2) +# V2_S2 { S2 x; S2 y; } +.equ V2_S2_x, (S2 * 0) +.equ V2_S2_y, (S2 * 1) +.equ V2_S2, (S2 * 2) +# V2_S4 { S4 x; S4 y; } +.equ V2_S4_x, (S4 * 0) +.equ V2_S4_y, (S4 * 1) +.equ V2_S4, (S4 * 2) +# Range2_S16 { Vec_2S16 p0; Vec_2S16 p1; } +.equ Range2_S2_p0, (V2_S2 * 0) +.equ Range2_S2_p1, (V2_S2 * 1) +.equ Range2_S2_p0_x, (S2 * 0) +.equ Range2_S2_p0_y, (S2 * 1) +.equ Range2_S2_p1_x, (S2 * 2) +.equ Range2_S2_p1_y, (S2 * 3) +.equ Range2_S2, (S2 * 4) +# Range2_S4 { V2_S4 p0; V2_S4 p1; } +.equ Range2_S4_p0, (V2_S4 * 0) +.equ Range2_S4_p1, (V2_S4 * 1) +.equ Range2_S4_p0_x, (S4 * 0) +.equ Range2_S4_p0_y, (S4 * 1) +.equ Range2_S4_p1_x, (S4 * 2) +.equ Range2_S4_p1_y, (S4 * 3) +.equ Range2_S4, (S4 * 4) +# Rect_S2 { S2 x; S2 y; S2 width; S2 height; } +.equ Rect_S2_x, (S2 * 0) +.equ Rect_S2_y, (S2 * 1) +.equ Rect_S2_width, (S2 * 2) +.equ Rect_S2_height, (S2 * 3) +.equ Rect_S2, (S2 * 4) +# Rect_S4 { S4 x; S4 y; S4 width; S4 height; } +.equ Rect_S4_x, (S2 * 0) +.equ Rect_S4_y, (S2 * 1) +.equ Rect_S4_width, (S2 * 2) +.equ Rect_S4_height, (S2 * 3) +.equ Rect_S4, (S2 * 4) diff --git a/code/graphics_hello_psyq/hello_gpu.c b/code/graphics_hello_psyq/hello_gpu.c index c0bb680..e8e5538 100644 --- a/code/graphics_hello_psyq/hello_gpu.c +++ b/code/graphics_hello_psyq/hello_gpu.c @@ -277,7 +277,7 @@ int main(void) cube128_init(& static_mem.cube_verts, & static_mem.cube_faces); static_mem.rotation = v3s2(0, 0, 0); static_mem.translation = v3s4(0, 0, 900); - static_mem.scale = v3s4(m3s2_one, m3s2_one, m3s2_one); + static_mem.scale = v3s4(fp_one, fp_one, fp_one); gknown gp_screen_init(); // gp_screen_init_c11(& static_mem.screen_buf, & static_mem.active_screen_buf); while (1) diff --git a/code/graphics_hello_psyq/hello_gpu.h b/code/graphics_hello_psyq/hello_gpu.h index df3d997..b3f33af 100644 --- a/code/graphics_hello_psyq/hello_gpu.h +++ b/code/graphics_hello_psyq/hello_gpu.h @@ -81,14 +81,15 @@ typedef def_struct(PolyTag) { #define orderingtbl_add_primitives(ot, p0, p1) set_addr(p1, get_addr(ot)), set_addr(ot, p0) /* Primitive Length Code */ -#define set_poly_f3(p) set_len(p, 4), set_code(p, 0x20) -// #define setPolyFT3(p) set_len(p, 7), set_code(p, 0x24) -#define set_poly_g3(p) set_len(p, 6), set_code(p, 0x30) -// #define setPolyGT3(p) set_len(p, 9), set_code(p, 0x34) -#define set_poly_f4(p) set_len(p, 5), set_code(p, 0x28) -// #define setPolyFT4(p) set_len(p, 9), set_code(p, 0x2c) -#define set_poly_g4(p) set_len(p, 8), set_code(p, 0x38) -// #define setPolyGT4(p) set_len(p, 12), set_code(p, 0x3c) + +#define set_poly_f3(p) set_len(p, 4), set_code(p, 0x20) +#define set_poly_ft3(p) set_len(p, 7), set_code(p, 0x24) +#define set_poly_g3(p) set_len(p, 6), set_code(p, 0x30) +#define set_poly_gt3(p) set_len(p, 9), set_code(p, 0x34) +#define set_poly_f4(p) set_len(p, 5), set_code(p, 0x28) +#define set_poly_ft4(p) set_len(p, 9), set_code(p, 0x2c) +#define set_poly_g4(p) set_len(p, 8), set_code(p, 0x38) +#define set_poly_gt4(p) set_len(p, 12), set_code(p, 0x3c) // #define setSprt8(p) setlen(p, 3), setcode(p, 0x74) // #define setSprt16(p) setlen(p, 3), setcode(p, 0x7c) @@ -113,14 +114,17 @@ M3_S2* m3s2_rotation (V3_S2* vec, M3_S2* mat) __asm__("RotMatrix"); M3_S2* m3s2_translation(M3_S2* mat, V3_S4* vec) __asm__("TransMatrix"); M3_S2* m3s2_scale (M3_S2* mat, V3_S4* vec) __asm__("ScaleMatrix"); -S4 rtp_v3s2_raw(V3_S2* vec, S4* xy, S4* pp, S4* flag) __asm__("RotTransPers"); // Rotation, Translate, Perspective +// Rotation, Translation, Perspective + +S4 rtp_v3s2_raw(V3_S2* vec, S4* xy, S4* pp, S4* flag) __asm__("RotTransPers"); finline 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)); } 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"); finline S4 rtp_avg_nclip_a3_v3s2( V3_S2* v0, V3_S2* v1, V3_S2* v2, V2_S2* xy0, V2_S2* xy1, V2_S2* xy2, - A2_S2* pp, S4* otz, S4* flag) { + A2_S2* pp, S4* otz, S4* flag +){ return rtp_avg_nclip_a3_v3s2_raw( v0, v1, v2, cast(S4*R_, xy0), cast(S4*R_, xy1), cast(S4*R_, xy2), @@ -131,4 +135,4 @@ finline S4 rtp_avg_nclip_a3_v3s2( void gte_matrix_set_rotation (M3_S2* mat) __asm__("SetRotMatrix"); void gte_matrix_set_translation(M3_S2* mat) __asm__("SetTransMatrix"); -#define m3s2_one (1 << 12) +#define fp_one (1 << 12) diff --git a/code/graphics_hello_psyq/hello_gpu.s b/code/graphics_hello_psyq/hello_gpu.s index 56f2c67..dd9aff5 100644 --- a/code/graphics_hello_psyq/hello_gpu.s +++ b/code/graphics_hello_psyq/hello_gpu.s @@ -5,29 +5,29 @@ .include "./asmdd/io.s" .include "./asmdd/gp.s" -# DrawEnv_Packed { U32 tag; U32 code[15]; } +# DrawEnv_Packed { U4 tag; U4 code[15]; } .equ DrawEnv_Packed_tag, 0 -.equ DrawEnv_Packed_code, DrawEnv_Packed_tag + U32 +.equ DrawEnv_Packed_code, DrawEnv_Packed_tag + U4 .equ DrawEnv_Packed, 64 # DrawEnv { Rect_S16 clip; Vec_2S16 ofs; Rect_S16 tw; U16 tpage; U8 dtd; U8 dfe; U8 tme; U8 r0,g0,b0; DR_ENV dr_env; } -.equ DrawEnv_clip_area, /* 0 */ Rect_S16 * 0 -.equ DrawEnv_drawing_offset, /* 8 */ A2_S16 * 0 + Rect_S16 -.equ DrawEnv_texture_window, /* 12 */ Rect_S16 * 0 + A2_S16 + DrawEnv_drawing_offset -.equ DrawEnv_texture_page, /* 20 */ S16 * 0 + Rect_S16 + DrawEnv_texture_window -.equ DrawEnv_flag_dither, /* 22 */ byte * 0 + S16 + DrawEnv_texture_page -.equ DrawEnv_flag_draw_on_display, /* 23 */ byte * 0 + byte + DrawEnv_flag_dither -.equ DrawEnv_enable_auto_clear, /* 24 */ byte * 0 + byte + DrawEnv_flag_draw_on_display -.equ DrawEnv_initial_bg_color, /* 25 */ RGB8 * 0 + byte + DrawEnv_enable_auto_clear +.equ DrawEnv_clip_area, /* 0 */ Rect_S2 * 0 +.equ DrawEnv_drawing_offset, /* 8 */ A2_S2 * 0 + Rect_S2 +.equ DrawEnv_texture_window, /* 12 */ Rect_S2 * 0 + A2_S2 + DrawEnv_drawing_offset +.equ DrawEnv_texture_page, /* 20 */ S1 * 0 + Rect_S2 + DrawEnv_texture_window +.equ DrawEnv_flag_dither, /* 22 */ B1 * 0 + S2 + DrawEnv_texture_page +.equ DrawEnv_flag_draw_on_display, /* 23 */ B1 * 0 + B1 + DrawEnv_flag_dither +.equ DrawEnv_enable_auto_clear, /* 24 */ B1 * 0 + B1 + DrawEnv_flag_draw_on_display +.equ DrawEnv_initial_bg_color, /* 25 */ RGB8 * 0 + B1 + DrawEnv_enable_auto_clear .equ DrawEnv_dr_env, /* 28 */ DrawEnv_Packed * 0 + RGB8 + DrawEnv_initial_bg_color .equ DrawEnv, /* 92 */ DrawEnv_dr_env + DrawEnv_Packed # DisplayEnv { Rect_S16 disp; Rect_S16 screen; U8 isinter; U8 isrgb24; U8 pad[2]; } -.equ DisplayEnv_display_area, Rect_S16 * 0 -.equ DisplayEnv_screen, Rect_S16 * 0 + Rect_S16 + DisplayEnv_display_area -.equ DisplayEnv_vinterlace, byte * 0 + Rect_S16 + DisplayEnv_screen -.equ DisplayEnv_color24, byte * 0 + byte + DisplayEnv_vinterlace -.equ DisplayEnv_pad0, byte * 0 + byte + DisplayEnv_color24 -.equ DisplayEnv_pad1, byte * 0 + byte + DisplayEnv_pad0 -.equ DisplayEnv, DisplayEnv_pad1 + byte +.equ DisplayEnv_display_area, Rect_S2 * 0 +.equ DisplayEnv_screen, Rect_S2 * 0 + Rect_S2 + DisplayEnv_display_area +.equ DisplayEnv_vinterlace, B1 * 0 + Rect_S2 + DisplayEnv_screen +.equ DisplayEnv_color24, B1 * 0 + B1 + DisplayEnv_vinterlace +.equ DisplayEnv_pad0, B1 * 0 + B1 + DisplayEnv_color24 +.equ DisplayEnv_pad1, B1 * 0 + B1 + DisplayEnv_pad0 +.equ DisplayEnv, DisplayEnv_pad1 + B1 # DoubleBuffer { DrawEnv draw[2]; DisplayEnv display[2]; } .equ DoubleBuffer_draw, 0 .equ DoubleBuffer_draw_0, (DrawEnv * 0) @@ -43,7 +43,7 @@ .equ ScreenRes_CenterY, (ScreenRes_Y >> 1) .equ SMemory_screen_buf, DoubleBuffer * 0 -.equ SMemory_active_screen_buf, S16 * 0 + DoubleBuffer +.equ SMemory_active_screen_buf, S2 * 0 + DoubleBuffer .equ CF_Shadow, 16 @@ -64,7 +64,7 @@ .equ SetDefDispEnv_y, rarg_2 .equ SetDefDispEnv_w, rarg_3 .equ SetDefDispEnv_h, CF_Shadow -.set SetDefDispEnv_sp_size, CF_Shadow + S32 +.set SetDefDispEnv_sp_size, CF_Shadow + S4 .extern SetDefDrawEnv .equ SetDefDrawEnv_env, rarg_0 @@ -72,7 +72,7 @@ .equ SetDefDrawEnv_y, rarg_2 .equ SetDefDrawEnv_w, rarg_3 .equ SetDefDrawEnv_h, CF_Shadow -.set SetDefDrawEnv_sp_size, CF_Shadow + S32 +.set SetDefDrawEnv_sp_size, CF_Shadow + S4 .extern SetGeomOffset .equ SetGeomOffset_x, rarg_0