ps2sdk
1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
|
#include <kernel.h>
#include <malloc.h>
#include <tamtypes.h>
#include <gs_psm.h>
#include <dma.h>
#include <packet2.h>
#include <packet2_utils.h>
#include <graph.h>
#include <draw.h>
#include "zbyszek.c"
#include "mesh_data.c"
Go to the source code of this file.
Functions | |
void | calculate_cube (texbuffer_t *t_texbuff) |
void | draw_cube (VECTOR t_object_position, texbuffer_t *t_texbuff) |
void | init_gs (framebuffer_t *t_frame, zbuffer_t *t_z, texbuffer_t *t_texbuff) |
void | init_drawing_environment (framebuffer_t *t_frame, zbuffer_t *t_z) |
void | send_texture (texbuffer_t *texbuf) |
void | clear_screen (framebuffer_t *frame, zbuffer_t *z) |
void | set_lod_clut_prim_tex_buff (texbuffer_t *t_texbuff) |
void | render (framebuffer_t *t_frame, zbuffer_t *t_z, texbuffer_t *t_texbuff) |
void | vu1_set_double_buffer_settings () |
void | vu1_upload_micro_program () |
int | main (int argc, char **argv) |
Variables | |
unsigned char | zbyszek [] |
u32 | VU1Draw3D_CodeStart |
u32 | VU1Draw3D_CodeEnd |
VECTOR | object_rotation = {0.00f, 0.00f, 0.00f, 1.00f} |
VECTOR | camera_position = {140.00f, 140.00f, 40.00f, 1.00f} |
VECTOR | camera_rotation = {0.00f, 0.00f, 0.00f, 1.00f} |
MATRIX | local_world |
MATRIX | world_view |
MATRIX | view_screen |
MATRIX | local_screen |
packet2_t * | vif_packets [2] |
packet2_t * | curr_vif_packet |
packet2_t * | zbyszek_packet |
u8 | context = 0 |
prim_t | prim |
clutbuffer_t | clut |
lod_t | lod |
VECTOR * | c_verts |
VECTOR * | c_sts |
void calculate_cube | ( | texbuffer_t * | t_texbuff | ) |
Calculate packet for cube data
Definition at line 95 of file main.c.
References clut, DRAW_STQ2_REGLIST, faces_count, lod, packet2_add_float(), packet2_add_s32(), packet2_add_u32(), packet2_utils_gif_add_set(), packet2_utils_gs_add_lod(), packet2_utils_gs_add_prim_giftag(), packet2_utils_gs_add_texbuff_clut(), prim, and zbyszek_packet.
Referenced by render().
void clear_screen | ( | framebuffer_t * | frame, |
zbuffer_t * | z | ||
) |
Send packet which will clear our screen.
Definition at line 206 of file main.c.
References DMA_CHANNEL_GIF, dma_channel_send_packet2(), dma_wait_fast(), draw_clear(), draw_disable_tests(), draw_enable_tests(), draw_finish(), draw_wait_finish(), framebuffer_t::height, packet2_t::next, P2_MODE_NORMAL, P2_TYPE_NORMAL, packet2_create(), packet2_free(), packet2_update(), and framebuffer_t::width.
Referenced by render().
void draw_cube | ( | VECTOR | t_object_position, |
texbuffer_t * | t_texbuff | ||
) |
Calculate cube position and add packet with cube data
Definition at line 111 of file main.c.
References packet2_t::base, c_sts, c_verts, camera_position, camera_rotation, context, create_local_screen(), create_local_world(), create_world_view(), curr_vif_packet, dma_channel_send_packet2(), DMA_CHANNEL_VIF1, dma_channel_wait(), faces_count, local_screen, local_world, object_rotation, packet2_get_qw_count(), packet2_reset(), packet2_utils_vu_add_end_tag(), packet2_utils_vu_add_start_program(), packet2_utils_vu_add_unpack_data(), view_screen, vif_packets, world_view, and zbyszek_packet.
Referenced by render().
void init_drawing_environment | ( | framebuffer_t * | t_frame, |
zbuffer_t * | t_z | ||
) |
Some initialization of GS 2
Definition at line 174 of file main.c.
References DMA_CHANNEL_GIF, dma_channel_send_packet2(), dma_wait_fast(), draw_finish(), draw_primitive_xyoffset(), draw_setup_environment(), packet2_t::next, P2_MODE_NORMAL, P2_TYPE_NORMAL, packet2_create(), packet2_free(), and packet2_update().
Referenced by main().
void init_gs | ( | framebuffer_t * | t_frame, |
zbuffer_t * | t_z, | ||
texbuffer_t * | t_texbuff | ||
) |
Some initialization of GS and VRAM allocation
Definition at line 148 of file main.c.
References framebuffer_t::address, zbuffer_t::address, texbuffer_t::address, DRAW_ENABLE, zbuffer_t::enable, GRAPH_ALIGN_BLOCK, GRAPH_ALIGN_PAGE, graph_initialize(), graph_vram_allocate(), GS_PSM_24, GS_PSM_32, GS_ZBUF_32, framebuffer_t::height, framebuffer_t::mask, zbuffer_t::mask, zbuffer_t::method, framebuffer_t::psm, texbuffer_t::psm, framebuffer_t::width, texbuffer_t::width, zbuffer_t::zsm, and ZTEST_METHOD_GREATER_EQUAL.
Referenced by main().
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 350 of file main.c.
References dma_channel_fast_waits(), DMA_CHANNEL_GIF, dma_channel_initialize(), DMA_CHANNEL_VIF1, init_drawing_environment(), init_gs(), NULL, P2_MODE_CHAIN, P2_TYPE_NORMAL, packet2_create(), packet2_free(), render(), send_texture(), SleepThread(), vif_packets, vu1_set_double_buffer_settings(), vu1_upload_micro_program(), and zbyszek_packet.
void render | ( | framebuffer_t * | t_frame, |
zbuffer_t * | t_z, | ||
texbuffer_t * | t_texbuff | ||
) |
Allocate some space for object position calculating. c_ prefix = calc_
Definition at line 257 of file main.c.
References c_sts, c_verts, calculate_cube(), camera_position, camera_rotation, clear_screen(), create_view_screen(), draw_cube(), faces, faces_count, graph_aspect_ratio(), graph_wait_vsync(), object_rotation, set_lod_clut_prim_tex_buff(), sts, vertices, and view_screen.
Referenced by main().
void send_texture | ( | texbuffer_t * | texbuf | ) |
Send texture data to GS.
Definition at line 195 of file main.c.
References texbuffer_t::address, DMA_CHANNEL_GIF, dma_channel_send_packet2(), dma_wait_fast(), draw_texture_flush(), draw_texture_transfer(), GS_PSM_24, packet2_t::next, P2_MODE_CHAIN, P2_TYPE_NORMAL, packet2_create(), packet2_free(), packet2_update(), texbuffer_t::width, and zbyszek.
Referenced by main().
void set_lod_clut_prim_tex_buff | ( | texbuffer_t * | t_texbuff | ) |
Definition at line 226 of file main.c.
References clutbuffer_t::address, prim_t::antialiasing, prim_t::blending, lod_t::calculation, clut, CLUT_NO_LOAD, CLUT_STORAGE_MODE1, prim_t::colorfix, texinfo_t::components, DRAW_DISABLE, DRAW_ENABLE, draw_log2(), prim_t::fogging, texinfo_t::function, texinfo_t::height, texbuffer_t::info, lod_t::k, lod_t::l, clutbuffer_t::load_method, lod, LOD_MAG_NEAREST, LOD_MIN_NEAREST, LOD_USE_K, lod_t::mag_filter, prim_t::mapping, prim_t::mapping_type, lod_t::max_level, lod_t::min_filter, prim, PRIM_MAP_ST, PRIM_SHADE_GOURAUD, PRIM_TRIANGLE, PRIM_UNFIXED, clutbuffer_t::psm, prim_t::shading, clutbuffer_t::start, clutbuffer_t::storage_mode, TEXTURE_COMPONENTS_RGB, TEXTURE_FUNCTION_DECAL, prim_t::type, and texinfo_t::width.
Referenced by render().
void vu1_set_double_buffer_settings | ( | ) |
Definition at line 328 of file main.c.
References dma_channel_send_packet2(), DMA_CHANNEL_VIF1, dma_channel_wait(), P2_MODE_CHAIN, P2_TYPE_NORMAL, packet2_create(), packet2_free(), packet2_utils_vu_add_double_buffer(), and packet2_utils_vu_add_end_tag().
Referenced by main().
void vu1_upload_micro_program | ( | ) |
Definition at line 338 of file main.c.
References dma_channel_send_packet2(), DMA_CHANNEL_VIF1, dma_channel_wait(), P2_MODE_CHAIN, P2_TYPE_NORMAL, packet2_create(), packet2_free(), packet2_utils_get_packet_size_for_program(), packet2_utils_vu_add_end_tag(), packet2_vif_add_micro_program(), VU1Draw3D_CodeEnd, and VU1Draw3D_CodeStart.
Referenced by main().
VECTOR * c_sts |
Definition at line 92 of file main.c.
Referenced by draw_cube(), and render().
VECTOR* c_verts |
Helper arrays. Needed for calculations.
Definition at line 92 of file main.c.
Referenced by draw_cube(), and render().
VECTOR camera_position = {140.00f, 140.00f, 40.00f, 1.00f} |
Definition at line 55 of file main.c.
Referenced by draw_cube(), and render().
VECTOR camera_rotation = {0.00f, 0.00f, 0.00f, 1.00f} |
Definition at line 56 of file main.c.
Referenced by draw_cube(), and render().
clutbuffer_t clut |
Color look up table. Needed for texture.
Definition at line 80 of file main.c.
Referenced by calculate_cube(), draw_clutbuffer(), draw_texturebuffer(), packet2_utils_gs_add_texbuff_clut(), run_demo(), set_lod_clut_prim_tex_buff(), and setup_texture().
u8 context = 0 |
Definition at line 71 of file main.c.
Referenced by draw_alpha_blending(), draw_alpha_correction(), draw_arc_filled(), draw_arc_outline(), draw_clear(), draw_clutbuffer(), draw_cube(), draw_disable_tests(), draw_enable_tests(), draw_framebuffer(), draw_line(), draw_mipmap1(), draw_mipmap2(), draw_pixel_test(), draw_point(), draw_prim_start(), draw_primitive_override_setting(), draw_primitive_xyoffset(), draw_rect_filled(), draw_rect_filled_strips(), draw_rect_outline(), draw_rect_textured(), draw_rect_textured_strips(), draw_round_rect_filled(), draw_round_rect_outline(), draw_scissor_area(), draw_setup_environment(), draw_texture_sampling(), draw_texture_wrapping(), draw_texturebuffer(), draw_triangle_filled(), draw_triangle_outline(), draw_zbuffer(), fontstudio_print_string(), fontx_print_ascii(), fontx_print_sjis(), graph_set_framebuffer(), GsClearDrawEnv1(), GsClearDrawEnv2(), packet2_utils_gs_add_prim_giftag(), render(), and run_demo().
packet2_t* curr_vif_packet |
Definition at line 66 of file main.c.
Referenced by draw_cube().
MATRIX local_screen |
Definition at line 57 of file main.c.
Referenced by calculate_vertices(), create_local_screen(), draw_cube(), render(), and render_teapot().
MATRIX local_world |
Definition at line 57 of file main.c.
Referenced by create_local_screen(), create_local_world(), draw_cube(), render(), and render_teapot().
lod_t lod |
Level of details. Needed for texture.
Definition at line 86 of file main.c.
Referenced by calculate_cube(), draw_texture_sampling(), packet2_utils_gs_add_lod(), run_demo(), set_lod_clut_prim_tex_buff(), and setup_texture().
VECTOR object_rotation = {0.00f, 0.00f, 0.00f, 1.00f} |
Definition at line 54 of file main.c.
Referenced by draw_cube(), and render().
prim_t prim |
Set GS primitive type of drawing.
Definition at line 74 of file main.c.
Referenced by calculate_cube(), draw_prim_start(), draw_primitive_override_setting(), packet2_utils_gs_add_prim_giftag(), render(), render_teapot(), and set_lod_clut_prim_tex_buff().
MATRIX view_screen |
Definition at line 57 of file main.c.
Referenced by create_local_screen(), create_view_screen(), draw_cube(), render(), and render_teapot().
packet2_t* vif_packets[2] |
Packets for sending VU data Each packet will have: a) View/Projection matrix (calculated every frame) b) Cube data (prim,lod,vertices,sts,...) added from zbyszek_packet.
Definition at line 65 of file main.c.
Referenced by draw_cube(), and main().
|
extern |
Referenced by vu1_upload_micro_program().
|
extern |
Data of VU1 micro program (draw_3D.vcl/vsm). How we can use it:
Referenced by vu1_upload_micro_program().
MATRIX world_view |
Definition at line 57 of file main.c.
Referenced by create_local_screen(), create_world_view(), draw_cube(), render(), and render_teapot().
|
extern |
Data of our texture (24bit, RGB8)
Referenced by send_texture().
packet2_t* zbyszek_packet |
Cube data
Definition at line 69 of file main.c.
Referenced by calculate_cube(), draw_cube(), and main().