├── .clang-format ├── .dockerignore ├── .gitattributes ├── .github └── workflows │ ├── master-build.yml │ ├── pr-build-check.yml │ └── pr-format-check.yml ├── .gitignore ├── .vscode ├── .gitignore ├── configurations │ └── windows-docker │ │ ├── c_cpp_properties.json │ │ ├── settings.json │ │ └── tasks.json └── extensions.json ├── Dockerfile ├── Makefile.base ├── README.MD ├── assets ├── github-splash.png ├── github-splash2.png ├── showcase.gif ├── tyra_code.gif └── vcl ├── demo ├── Makefile ├── bin │ └── .gitignore ├── inc │ ├── demo_game.hpp │ ├── game_settings.hpp │ ├── state │ │ ├── global_state_type.hpp │ │ ├── state.hpp │ │ └── state_manager.hpp │ └── states │ │ ├── game │ │ ├── enemy │ │ │ ├── enemy.hpp │ │ │ ├── enemy_info.hpp │ │ │ └── enemy_manager.hpp │ │ ├── game_state.hpp │ │ ├── hud │ │ │ └── hud.hpp │ │ ├── player │ │ │ ├── camera.hpp │ │ │ ├── player.hpp │ │ │ ├── player_shoot_action.hpp │ │ │ └── weapon.hpp │ │ ├── renderer │ │ │ ├── game_renderer.hpp │ │ │ ├── renderer_dynamic_pair.hpp │ │ │ └── renderer_static_pair.hpp │ │ ├── ship │ │ │ └── ship.hpp │ │ ├── skybox │ │ │ └── skybox.hpp │ │ └── terrain │ │ │ ├── heightmap.hpp │ │ │ └── terrain.hpp │ │ ├── intro │ │ ├── intro_state.hpp │ │ ├── intro_state_type.hpp │ │ └── states │ │ │ ├── intro_press_key_state.hpp │ │ │ ├── intro_ps2dev_state.hpp │ │ │ └── intro_tyra_state.hpp │ │ └── loading │ │ └── loading_state.hpp ├── res │ └── .gitignore ├── run.ps1 └── src │ ├── demo_game.cpp │ ├── main.cpp │ └── states │ ├── game │ ├── enemy │ │ ├── enemy.cpp │ │ └── enemy_manager.cpp │ ├── game_state.cpp │ ├── hud │ │ └── hud.cpp │ ├── player │ │ ├── camera.cpp │ │ ├── player.cpp │ │ └── weapon.cpp │ ├── renderer │ │ └── game_renderer.cpp │ ├── ship │ │ └── ship.cpp │ ├── skybox │ │ └── skybox.cpp │ └── terrain │ │ ├── heightmap.cpp │ │ └── terrain.cpp │ ├── intro │ ├── intro_state.cpp │ └── states │ │ ├── intro_press_key_state.cpp │ │ ├── intro_ps2dev_state.cpp │ │ └── intro_tyra_state.cpp │ └── loading │ └── loading_state.cpp ├── docker-compose.yml ├── docs └── install │ ├── README.MD │ └── pcsx2.md ├── engine ├── Makefile ├── bin │ └── .gitignore ├── inc │ ├── audio │ │ ├── adpcm_result.hpp │ │ ├── audio.hpp │ │ ├── audio_adpcm.hpp │ │ ├── audio_listener.hpp │ │ ├── audio_listener_ref.hpp │ │ └── audio_song.hpp │ ├── debug │ │ └── debug.hpp │ ├── engine.hpp │ ├── file │ │ └── file_utils.hpp │ ├── game.hpp │ ├── info │ │ ├── banner.hpp │ │ ├── info.hpp │ │ └── version.hpp │ ├── irx │ │ └── irx_loader.hpp │ ├── loaders │ │ ├── 3d │ │ │ ├── builder │ │ │ │ ├── mesh_builder_data.hpp │ │ │ │ ├── mesh_builder_material_data.hpp │ │ │ │ └── mesh_builder_material_frame_data.hpp │ │ │ ├── md2_loader │ │ │ │ ├── anorms.hpp │ │ │ │ └── md2_loader.hpp │ │ │ └── obj_loader │ │ │ │ ├── mapbox │ │ │ │ └── earcut.hpp │ │ │ │ ├── obj_loader.hpp │ │ │ │ └── tiny_obj_loader.hpp │ │ └── texture │ │ │ ├── base │ │ │ ├── texture_loader.hpp │ │ │ └── texture_loader_selector.hpp │ │ │ ├── builder │ │ │ └── texture_builder_data.hpp │ │ │ └── png_loader.hpp │ ├── math │ │ ├── m4x4.hpp │ │ ├── math.hpp │ │ ├── plane.hpp │ │ ├── vec2.hpp │ │ └── vec4.hpp │ ├── packet2 │ │ └── packet2_tyra_utils.hpp │ ├── pad │ │ └── pad.hpp │ ├── physics │ │ └── ray.hpp │ ├── renderer │ │ ├── 2d │ │ │ └── renderer_2d.hpp │ │ ├── 3d │ │ │ ├── bbox │ │ │ │ ├── bbox.hpp │ │ │ │ └── bbox_face.hpp │ │ │ ├── mesh │ │ │ │ ├── dynamic │ │ │ │ │ ├── animation_sequence_callback.hpp │ │ │ │ │ ├── dynamic_mesh.hpp │ │ │ │ │ ├── dynamic_mesh_anim_state.hpp │ │ │ │ │ └── dynamic_mesh_animation.hpp │ │ │ │ ├── mesh.hpp │ │ │ │ ├── mesh_frame.hpp │ │ │ │ ├── mesh_material.hpp │ │ │ │ ├── mesh_material_frame.hpp │ │ │ │ └── static │ │ │ │ │ └── static_mesh.hpp │ │ │ ├── pipeline │ │ │ │ ├── dynamic │ │ │ │ │ ├── core │ │ │ │ │ │ ├── bag │ │ │ │ │ │ │ ├── dynpip_bag.hpp │ │ │ │ │ │ │ ├── dynpip_color_bag.hpp │ │ │ │ │ │ │ ├── dynpip_info_bag.hpp │ │ │ │ │ │ │ ├── dynpip_lighting_bag.hpp │ │ │ │ │ │ │ └── dynpip_texture_bag.hpp │ │ │ │ │ │ ├── dynpip_core.hpp │ │ │ │ │ │ ├── dynpip_program_name.hpp │ │ │ │ │ │ ├── dynpip_programs_repository.hpp │ │ │ │ │ │ ├── dynpip_renderer.hpp │ │ │ │ │ │ ├── dynpip_vu1_program.hpp │ │ │ │ │ │ └── programs │ │ │ │ │ │ │ ├── dynpip_c_vu1_program.hpp │ │ │ │ │ │ │ ├── dynpip_d_vu1_program.hpp │ │ │ │ │ │ │ ├── dynpip_tc_vu1_program.hpp │ │ │ │ │ │ │ ├── dynpip_td_vu1_program.hpp │ │ │ │ │ │ │ └── dynpip_vu1_shared_defines.h │ │ │ │ │ ├── dynamic_pipeline.hpp │ │ │ │ │ └── dynpip_options.hpp │ │ │ │ ├── minecraft │ │ │ │ │ ├── data │ │ │ │ │ │ ├── mcpip_block_data.hpp │ │ │ │ │ │ ├── mcpip_multi_tex_block_data.hpp │ │ │ │ │ │ └── mcpip_single_tex_block_data.hpp │ │ │ │ │ ├── mcpip_block.hpp │ │ │ │ │ ├── minecraft_pipeline.hpp │ │ │ │ │ └── programs │ │ │ │ │ │ ├── as_is │ │ │ │ │ │ ├── mcpip_as_is_vu1_program.hpp │ │ │ │ │ │ ├── mcpip_clip.hpp │ │ │ │ │ │ └── mcpip_vu1_as_is_shared_defines.h │ │ │ │ │ │ ├── cull │ │ │ │ │ │ ├── mcpip_cull.hpp │ │ │ │ │ │ ├── mcpip_cull_vu1_program.hpp │ │ │ │ │ │ └── mcpip_vu1_cull_shared_defines.h │ │ │ │ │ │ ├── mcpip_program.hpp │ │ │ │ │ │ ├── mcpip_program_name.hpp │ │ │ │ │ │ ├── mcpip_programs_manager.hpp │ │ │ │ │ │ └── mcpip_programs_repository.hpp │ │ │ │ ├── renderer_3d_pipeline.hpp │ │ │ │ ├── shared │ │ │ │ │ ├── bag │ │ │ │ │ │ ├── pipeline_dir_lights_bag.hpp │ │ │ │ │ │ ├── pipeline_info_bag.hpp │ │ │ │ │ │ └── pipeline_info_bag_frustum_culling.hpp │ │ │ │ │ ├── pipeline_frustum_culling.hpp │ │ │ │ │ ├── pipeline_lighting_options.hpp │ │ │ │ │ ├── pipeline_options.hpp │ │ │ │ │ ├── pipeline_shading_type.hpp │ │ │ │ │ ├── pipeline_texture_mapping_type.hpp │ │ │ │ │ ├── pipeline_transformation_type.hpp │ │ │ │ │ └── pipeline_z_test.hpp │ │ │ │ └── static │ │ │ │ │ ├── core │ │ │ │ │ ├── bag │ │ │ │ │ │ ├── packaging │ │ │ │ │ │ │ ├── stapip_bag_package.hpp │ │ │ │ │ │ │ ├── stapip_bag_packager.hpp │ │ │ │ │ │ │ └── stapip_bag_packages_bbox.hpp │ │ │ │ │ │ ├── stapip_bag.hpp │ │ │ │ │ │ ├── stapip_color_bag.hpp │ │ │ │ │ │ ├── stapip_info_bag.hpp │ │ │ │ │ │ ├── stapip_lighting_bag.hpp │ │ │ │ │ │ └── stapip_texture_bag.hpp │ │ │ │ │ ├── programs │ │ │ │ │ │ ├── as_is │ │ │ │ │ │ │ ├── stapip_as_is_c_vu1_program.hpp │ │ │ │ │ │ │ ├── stapip_as_is_d_vu1_program.hpp │ │ │ │ │ │ │ ├── stapip_as_is_tc_vu1_program.hpp │ │ │ │ │ │ │ └── stapip_as_is_td_vu1_program.hpp │ │ │ │ │ │ ├── cull │ │ │ │ │ │ │ ├── stapip_cull_c_vu1_program.hpp │ │ │ │ │ │ │ ├── stapip_cull_d_vu1_program.hpp │ │ │ │ │ │ │ ├── stapip_cull_tc_vu1_program.hpp │ │ │ │ │ │ │ └── stapip_cull_td_vu1_program.hpp │ │ │ │ │ │ └── stapip_vu1_shared_defines.h │ │ │ │ │ ├── stapip_bag_bboxes_cacher.hpp │ │ │ │ │ ├── stapip_clipper.hpp │ │ │ │ │ ├── stapip_core.hpp │ │ │ │ │ ├── stapip_program_name.hpp │ │ │ │ │ ├── stapip_program_type.hpp │ │ │ │ │ ├── stapip_programs_repository.hpp │ │ │ │ │ ├── stapip_qbuffer.hpp │ │ │ │ │ ├── stapip_qbuffer_renderer.hpp │ │ │ │ │ └── stapip_vu1_program.hpp │ │ │ │ │ ├── stapip_options.hpp │ │ │ │ │ └── static_pipeline.hpp │ │ │ ├── renderer_3d.hpp │ │ │ └── renderer_3d_utility.hpp │ │ ├── core │ │ │ ├── 2d │ │ │ │ ├── renderer_core_2d.hpp │ │ │ │ └── sprite │ │ │ │ │ ├── sprite.hpp │ │ │ │ │ └── sprite_mode.hpp │ │ │ ├── 3d │ │ │ │ ├── bbox │ │ │ │ │ ├── core_bbox.hpp │ │ │ │ │ ├── core_bbox_frustum.hpp │ │ │ │ │ └── render_bbox.hpp │ │ │ │ ├── camera_info_3d.hpp │ │ │ │ ├── clipper │ │ │ │ │ ├── planes_clip_algorithm.hpp │ │ │ │ │ └── planes_clip_vertex.hpp │ │ │ │ ├── renderer_3d_frustum_planes.hpp │ │ │ │ └── renderer_core_3d.hpp │ │ │ ├── gs │ │ │ │ ├── renderer_core_gs.hpp │ │ │ │ └── renderer_core_gs_vram.hpp │ │ │ ├── paths │ │ │ │ ├── path1 │ │ │ │ │ ├── path1.hpp │ │ │ │ │ └── vu1_program.hpp │ │ │ │ └── path3 │ │ │ │ │ └── path3.hpp │ │ │ ├── renderer_core.hpp │ │ │ ├── renderer_core_sync.hpp │ │ │ └── texture │ │ │ │ ├── models │ │ │ │ ├── texture.hpp │ │ │ │ ├── texture_bpp.hpp │ │ │ │ ├── texture_link.hpp │ │ │ │ └── texture_wrap.hpp │ │ │ │ ├── renderer_core_texture.hpp │ │ │ │ ├── renderer_core_texture_buffers.hpp │ │ │ │ ├── renderer_core_texture_sender.hpp │ │ │ │ ├── texture_data.hpp │ │ │ │ └── texture_repository.hpp │ │ ├── models │ │ │ └── color.hpp │ │ ├── renderer.hpp │ │ └── renderer_settings.hpp │ ├── thread │ │ └── threading.hpp │ ├── time │ │ └── timer.hpp │ └── tyra ├── obj │ └── .gitignore └── src │ ├── audio │ ├── audio.cpp │ ├── audio_adpcm.cpp │ └── audio_song.cpp │ ├── debug │ └── debug.cpp │ ├── engine.cpp │ ├── file │ └── file_utils.cpp │ ├── info │ ├── banner.cpp │ ├── banner_data.cpp │ └── info.cpp │ ├── irx │ ├── audsrv.irx-em │ ├── bdm.irx-em │ ├── bdmfs_fatfs.irx-em │ ├── fileXio.irx-em │ ├── iomanX.irx-em │ ├── irx_loader.cpp │ ├── libsd.irx-em │ ├── padman.irx-em │ ├── sio2man.irx-em │ ├── usbd.irx-em │ └── usbmass_bd.irx-em │ ├── loaders │ ├── 3d │ │ ├── builder │ │ │ ├── mesh_builder_data.cpp │ │ │ ├── mesh_builder_material_data.cpp │ │ │ └── mesh_builder_material_frame_data.cpp │ │ ├── md2_loader │ │ │ └── md2_loader.cpp │ │ └── obj_loader │ │ │ └── obj_loader.cpp │ └── texture │ │ ├── base │ │ ├── texture_builder_data.cpp │ │ ├── texture_loader.cpp │ │ └── texture_loader_selector.cpp │ │ └── png_loader.cpp │ ├── math │ ├── m4x4.cpp │ ├── math.cpp │ ├── plane.cpp │ ├── vec2.cpp │ └── vec4.cpp │ ├── pad │ └── pad.cpp │ ├── physics │ └── ray.cpp │ ├── renderer │ ├── 2d │ │ └── renderer_2d.cpp │ ├── 3d │ │ ├── bbox │ │ │ └── bbox.cpp │ │ ├── mesh │ │ │ ├── dynamic │ │ │ │ ├── dynamic_mesh.cpp │ │ │ │ └── dynamic_mesh_animation.cpp │ │ │ ├── mesh.cpp │ │ │ ├── mesh_frame.cpp │ │ │ ├── mesh_material.cpp │ │ │ ├── mesh_material_frame.cpp │ │ │ └── static │ │ │ │ └── static_mesh.cpp │ │ ├── pipeline │ │ │ ├── dynamic │ │ │ │ ├── core │ │ │ │ │ ├── bag │ │ │ │ │ │ ├── dynpip_bag.cpp │ │ │ │ │ │ ├── dynpip_color_bag.cpp │ │ │ │ │ │ ├── dynpip_lighting_bag.cpp │ │ │ │ │ │ └── dynpip_texture_bag.cpp │ │ │ │ │ ├── dynpip_core.cpp │ │ │ │ │ ├── dynpip_programs_repository.cpp │ │ │ │ │ ├── dynpip_renderer.cpp │ │ │ │ │ ├── dynpip_vu1_program.cpp │ │ │ │ │ └── programs │ │ │ │ │ │ ├── dynpip_c_vu1.vclpp │ │ │ │ │ │ ├── dynpip_c_vu1_program.cpp │ │ │ │ │ │ ├── dynpip_d_vu1.vclpp │ │ │ │ │ │ ├── dynpip_d_vu1_program.cpp │ │ │ │ │ │ ├── dynpip_tc_vu1.vclpp │ │ │ │ │ │ ├── dynpip_tc_vu1_program.cpp │ │ │ │ │ │ ├── dynpip_td_vu1.vclpp │ │ │ │ │ │ └── dynpip_td_vu1_program.cpp │ │ │ │ └── dynamic_pipeline.cpp │ │ │ ├── minecraft │ │ │ │ ├── data │ │ │ │ │ ├── mcpip_block_data.cpp │ │ │ │ │ ├── mcpip_multi_tex_block_data.cpp │ │ │ │ │ └── mcpip_single_tex_block_data.cpp │ │ │ │ ├── minecraft_pipeline.cpp │ │ │ │ └── programs │ │ │ │ │ ├── as_is │ │ │ │ │ ├── macros.i │ │ │ │ │ ├── mcpip_as_is_vu1.vclpp │ │ │ │ │ ├── mcpip_as_is_vu1_program.cpp │ │ │ │ │ └── mcpip_clip.cpp │ │ │ │ │ ├── cull │ │ │ │ │ ├── macros.i │ │ │ │ │ ├── mcpip_cull.cpp │ │ │ │ │ ├── mcpip_cull_vu1.vclpp │ │ │ │ │ └── mcpip_cull_vu1_program.cpp │ │ │ │ │ ├── mcpip_program.cpp │ │ │ │ │ ├── mcpip_programs_manager.cpp │ │ │ │ │ └── mcpip_programs_repository.cpp │ │ │ ├── shared │ │ │ │ ├── bag │ │ │ │ │ └── pipeline_dir_lights_bag.cpp │ │ │ │ ├── tyra_macros.i │ │ │ │ └── vcl_sml.i │ │ │ └── static │ │ │ │ ├── core │ │ │ │ ├── bag │ │ │ │ │ ├── packaging │ │ │ │ │ │ ├── stapip_bag_package.cpp │ │ │ │ │ │ ├── stapip_bag_packager.cpp │ │ │ │ │ │ └── stapip_bag_packages_bbox.cpp │ │ │ │ │ ├── stapip_bag.cpp │ │ │ │ │ ├── stapip_color_bag.cpp │ │ │ │ │ ├── stapip_lighting_bag.cpp │ │ │ │ │ └── stapip_texture_bag.cpp │ │ │ │ ├── programs │ │ │ │ │ ├── as_is │ │ │ │ │ │ ├── stapip_as_is_c_vu1.vclpp │ │ │ │ │ │ ├── stapip_as_is_c_vu1_program.cpp │ │ │ │ │ │ ├── stapip_as_is_d_vu1.vclpp │ │ │ │ │ │ ├── stapip_as_is_d_vu1_program.cpp │ │ │ │ │ │ ├── stapip_as_is_tc_vu1.vclpp │ │ │ │ │ │ ├── stapip_as_is_tc_vu1_program.cpp │ │ │ │ │ │ ├── stapip_as_is_td_vu1.vclpp │ │ │ │ │ │ └── stapip_as_is_td_vu1_program.cpp │ │ │ │ │ └── cull │ │ │ │ │ │ ├── stapip_cull_c_vu1.vclpp │ │ │ │ │ │ ├── stapip_cull_c_vu1_program.cpp │ │ │ │ │ │ ├── stapip_cull_d_vu1.vclpp │ │ │ │ │ │ ├── stapip_cull_d_vu1_program.cpp │ │ │ │ │ │ ├── stapip_cull_tc_vu1.vclpp │ │ │ │ │ │ ├── stapip_cull_tc_vu1_program.cpp │ │ │ │ │ │ ├── stapip_cull_td_vu1.vclpp │ │ │ │ │ │ └── stapip_cull_td_vu1_program.cpp │ │ │ │ ├── stapip_bag_bboxes_cacher.cpp │ │ │ │ ├── stapip_clipper.cpp │ │ │ │ ├── stapip_core.cpp │ │ │ │ ├── stapip_programs_repository.cpp │ │ │ │ ├── stapip_qbuffer.cpp │ │ │ │ ├── stapip_qbuffer_renderer.cpp │ │ │ │ └── stapip_vu1_program.cpp │ │ │ │ └── static_pipeline.cpp │ │ ├── renderer_3d.cpp │ │ └── renderer_3d_utility.cpp │ ├── core │ │ ├── 2d │ │ │ ├── renderer_core_2d.cpp │ │ │ └── sprite │ │ │ │ └── sprite.cpp │ │ ├── 3d │ │ │ ├── bbox │ │ │ │ ├── core_bbox.cpp │ │ │ │ └── render_bbox.cpp │ │ │ ├── camera_info_3d.cpp │ │ │ ├── clipper │ │ │ │ └── planes_clip_algorithm.cpp │ │ │ ├── renderer_3d_frustum_planes.cpp │ │ │ └── renderer_core_3d.cpp │ │ ├── gs │ │ │ ├── renderer_core_gs.cpp │ │ │ └── renderer_core_gs_vram.cpp │ │ ├── paths │ │ │ ├── path1 │ │ │ │ ├── draw_finish.vclpp │ │ │ │ ├── path1.cpp │ │ │ │ └── vu1_program.cpp │ │ │ └── path3 │ │ │ │ └── path3.cpp │ │ ├── renderer_core.cpp │ │ ├── renderer_core_sync.cpp │ │ └── texture │ │ │ ├── models │ │ │ └── texture.cpp │ │ │ ├── renderer_core_texture.cpp │ │ │ ├── renderer_core_texture_sender.cpp │ │ │ ├── texture_data.cpp │ │ │ └── texture_repository.cpp │ ├── models │ │ └── color.cpp │ ├── renderer.cpp │ └── renderer_settings.cpp │ ├── thread │ └── threading.cpp │ └── time │ └── timer.cpp ├── template ├── .clang-format ├── .dockerignore ├── .gitattributes ├── .gitignore ├── .vscode │ ├── .gitignore │ ├── configurations │ │ └── windows-docker │ │ │ ├── c_cpp_properties.json │ │ │ ├── settings.json │ │ │ └── tasks.json │ └── extensions.json ├── Dockerfile ├── Makefile ├── bin │ └── .gitignore ├── docker-compose.yml ├── inc │ └── racer_game.hpp ├── obj │ └── .gitignore ├── res │ └── .gitignore ├── run.ps1 ├── src │ ├── main.cpp │ └── racer_game.cpp └── windows-pcsx2.ps1 ├── tutorials ├── 01-hello │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ └── tutorial_01.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── main.cpp │ │ └── tutorial_01.cpp ├── 02-sprite │ ├── Makefile │ ├── bin │ │ ├── .gitignore │ │ └── tyra.png │ ├── inc │ │ └── tutorial_02.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── main.cpp │ │ └── tutorial_02.cpp ├── 03-minecraft │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ ├── tutorial_03.hpp │ │ └── tutorial_block.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── main.cpp │ │ ├── tutorial_03.cpp │ │ └── tutorial_block.cpp ├── 04-de_dust2 │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ ├── camera.hpp │ │ └── tutorial_04.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── camera.cpp │ │ ├── main.cpp │ │ └── tutorial_04.cpp ├── 05-animation │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ └── tutorial_05.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── main.cpp │ │ └── tutorial_05.cpp ├── 06-audio │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ └── tutorial_06.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── main.cpp │ │ └── tutorial_06.cpp ├── 07-lighting │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ └── tutorial_07.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── main.cpp │ │ └── tutorial_07.cpp ├── 08-skybox-debug │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ └── tutorial_08.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── main.cpp │ │ └── tutorial_08.cpp ├── 09-manual-mode │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ └── tutorial_09.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── main.cpp │ │ └── tutorial_09.cpp ├── 10-sprite-sheet │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ ├── font_sprite.hpp │ │ └── tutorial_10.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── font_sprite.cpp │ │ ├── main.cpp │ │ └── tutorial_10.cpp ├── 11-texture-region-repeat │ ├── Makefile │ ├── bin │ │ └── .gitignore │ ├── inc │ │ └── tutorial_11.hpp │ ├── obj │ │ └── .gitignore │ ├── res │ │ └── .gitignore │ ├── run.ps1 │ └── src │ │ ├── main.cpp │ │ └── tutorial_11.cpp └── Makefile.tutorials-base └── windows-pcsx2.ps1 /.clang-format: -------------------------------------------------------------------------------- 1 | # Use the Google style in this project. 2 | BasedOnStyle: Google 3 | 4 | # Some folks prefer to write "int& foo" while others prefer "int &foo". The 5 | # Google Style Guide only asks for consistency within a project, we chose 6 | # "int& foo" for this project: 7 | DerivePointerAlignment: false 8 | PointerAlignment: Left 9 | 10 | SortIncludes: false 11 | 12 | IncludeBlocks: Merge 13 | IncludeCategories: 14 | # Matches common headers first, but sorts them after project includes 15 | - Regex: '^\"google/cloud/internal/disable_deprecation_warnings.inc\"$' 16 | Priority: -1 17 | - Regex: '^\"google/cloud/(internal/|grpc_utils/|testing_util/|[^/]+\.h)' 18 | Priority: 1000 19 | - Regex: '^\"google/cloud/' # project includes should sort first 20 | Priority: 500 21 | - Regex: '^\"' 22 | Priority: 1500 23 | - Regex: '^' 30 | Priority: 5000 31 | 32 | # Format raw string literals with a `pb` or `proto` tag as proto. 33 | RawStringFormats: 34 | - Language: TextProto 35 | Delimiters: 36 | - 'pb' 37 | - 'proto' 38 | BasedOnStyle: Google 39 | 40 | CommentPragmas: '(@copydoc)' -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | *.elf 2 | .git/ 3 | .vscode/ 4 | docs/ 5 | tools/ -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Ignore all differences in line endings 2 | * -crlf -------------------------------------------------------------------------------- /.github/workflows/pr-format-check.yml: -------------------------------------------------------------------------------- 1 | #This is a modified version of the clang format check used on Open-PS2-Loader 2 | name: PR C++ format check 3 | 4 | on: 5 | push: 6 | paths: 7 | - '**.hpp' 8 | - '**.cpp' 9 | - '**.' 10 | - '**.h' 11 | - './engine/inc/tyra' 12 | - '.github/workflows/check-format.yml' 13 | - '.clang-format' 14 | pull_request: 15 | paths: 16 | - '**.hpp' 17 | - '**.cpp' 18 | - '**.' 19 | - '**.h' 20 | - './engine/inc/tyra' 21 | - '.github/workflows/check-format.yml' 22 | - '.clang-format' 23 | 24 | jobs: 25 | check-format: 26 | name: Check clang format 27 | runs-on: ubuntu-latest 28 | 29 | steps: 30 | - uses: actions/checkout@v2 31 | - uses: DoozyX/clang-format-lint-action@v0.12 32 | with: 33 | source: '.' 34 | extensions: 'hpp, cpp, h' 35 | clangFormatVersion: 12 36 | inplace: False 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # --- 2 | 3 | # Prerequisites 4 | *.d 5 | 6 | # Compiled Object files 7 | *.slo 8 | *.lo 9 | *.o 10 | *.vsm 11 | 12 | # Precompiled Headers 13 | *.gch 14 | *.pch 15 | 16 | # Compiled Dynamic libraries 17 | *.so 18 | *.dylib 19 | *.dll 20 | 21 | # Compiled Static libraries 22 | *.lai 23 | *.la 24 | *.a 25 | *.lib 26 | 27 | # Executables 28 | *.exe 29 | *.out 30 | *.app 31 | *.erl 32 | *.elf 33 | *.irx 34 | -------------------------------------------------------------------------------- /.vscode/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | 3 | # Configuration files 4 | /c_cpp_properties.json 5 | /tasks.json 6 | /settings.json 7 | /ps2dev-intellisense -------------------------------------------------------------------------------- /.vscode/configurations/windows-docker/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "buildDirectory": "demo", 3 | "C_Cpp.default.intelliSenseMode": "gcc-x86", 4 | "files.associations": { 5 | "*.vcl": "asm-collection", 6 | "*.i": "asm-collection", 7 | "*.vsm": "asm-collection", 8 | "*.vclpp": "asm-collection", 9 | "*.hpp": "cpp", 10 | "*.cpp": "cpp", 11 | "*.h": "c", 12 | "*.c": "c" 13 | } 14 | } -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-vscode.cpptools-extension-pack", 4 | "ryzngard.vscode-header-source", 5 | "maziac.asm-code-lens", 6 | "dmnsgn.vscode-wavefront", 7 | "spmeesseman.vscode-taskexplorer" 8 | ] 9 | } -------------------------------------------------------------------------------- /assets/github-splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h4570/tyra/b7bc5f2f0aafd5048c9cbf6dc497ef10f8ac2b28/assets/github-splash.png -------------------------------------------------------------------------------- /assets/github-splash2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h4570/tyra/b7bc5f2f0aafd5048c9cbf6dc497ef10f8ac2b28/assets/github-splash2.png -------------------------------------------------------------------------------- /assets/showcase.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h4570/tyra/b7bc5f2f0aafd5048c9cbf6dc497ef10f8ac2b28/assets/showcase.gif -------------------------------------------------------------------------------- /assets/tyra_code.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h4570/tyra/b7bc5f2f0aafd5048c9cbf6dc497ef10f8ac2b28/assets/tyra_code.gif -------------------------------------------------------------------------------- /assets/vcl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h4570/tyra/b7bc5f2f0aafd5048c9cbf6dc497ef10f8ac2b28/assets/vcl -------------------------------------------------------------------------------- /demo/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := demo.elf 2 | ENGINEDIR := ../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := -ltyra 20 | LIBDIRS := -L$(ENGINEDIR)/bin 21 | INC := -I$(INCDIR) -I$(ENGINEDIR)/inc 22 | INCDEP := -I$(INCDIR) -I$(ENGINEDIR)/inc 23 | 24 | include ../Makefile.base 25 | 26 | clean-engine: 27 | cd $(ENGINEDIR) && $(MAKE) cleaner 28 | 29 | build-engine: 30 | cd $(ENGINEDIR) && $(MAKE) 31 | 32 | build-release-engine: 33 | cd $(ENGINEDIR) && $(MAKE) release 34 | -------------------------------------------------------------------------------- /demo/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /demo/inc/demo_game.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "state/state_manager.hpp" 15 | 16 | using Tyra::Engine; 17 | using Tyra::Game; 18 | 19 | namespace Demo { 20 | 21 | class DemoGame : public Game { 22 | public: 23 | DemoGame(Engine* engine); 24 | ~DemoGame(); 25 | 26 | void init(); 27 | void loop(); 28 | 29 | private: 30 | Engine* engine; 31 | StateManager stateManager; 32 | }; 33 | 34 | } // namespace Demo 35 | -------------------------------------------------------------------------------- /demo/inc/game_settings.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Demo { 14 | 15 | const bool IS_REAL_PS2_VIA_USB = false; 16 | 17 | } // namespace Demo 18 | -------------------------------------------------------------------------------- /demo/inc/state/global_state_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Demo { 14 | 15 | enum GlobalStateType { STATE_INTRO, STATE_LOADING, STATE_GAME, STATE_EXIT }; 16 | 17 | } // namespace Demo 18 | -------------------------------------------------------------------------------- /demo/inc/state/state.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | using Tyra::Engine; 16 | 17 | namespace Demo { 18 | 19 | template 20 | class State { 21 | public: 22 | State(Engine* t_engine) : engine(t_engine) {} 23 | virtual ~State() {} 24 | 25 | virtual const StateTypeT& getState() const = 0; 26 | 27 | virtual const bool& wantFinish() const = 0; 28 | 29 | virtual void onStart() = 0; 30 | 31 | virtual void update() = 0; 32 | 33 | /** @return Next game state */ 34 | virtual StateTypeT onFinish() = 0; 35 | 36 | protected: 37 | Engine* engine; 38 | }; 39 | 40 | } // namespace Demo 41 | -------------------------------------------------------------------------------- /demo/inc/states/game/enemy/enemy_info.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | using Tyra::DynamicMesh; 17 | using Tyra::Texture; 18 | using Tyra::Vec4; 19 | 20 | namespace Demo { 21 | 22 | struct EnemyInfo { 23 | u8 adpcmChannel; 24 | audsrv_adpcm_t* adpcmPunch; 25 | audsrv_adpcm_t* adpcmDeath; 26 | DynamicMesh* motherMesh; 27 | Texture* bodyTexture; 28 | Texture* clothTexture; 29 | Vec4 terrainLeftUp; 30 | Vec4 terrainRightDown; 31 | }; 32 | 33 | } // namespace Demo 34 | -------------------------------------------------------------------------------- /demo/inc/states/game/enemy/enemy_manager.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "states/game/terrain/heightmap.hpp" 16 | #include "states/game/player/player_shoot_action.hpp" 17 | #include "./enemy.hpp" 18 | 19 | using Tyra::DynamicMesh; 20 | using Tyra::Engine; 21 | using Tyra::Texture; 22 | using Tyra::TextureRepository; 23 | using Tyra::Vec4; 24 | 25 | namespace Demo { 26 | 27 | class EnemyManager { 28 | public: 29 | EnemyManager(Engine* engine, const Heightmap& heightmap); 30 | ~EnemyManager(); 31 | 32 | void update(const Heightmap& heightmap, const Vec4& playerPosition, 33 | const PlayerShootAction& shootAction); 34 | 35 | std::vector getPairs() const; 36 | 37 | private: 38 | TextureRepository* textureRepo; 39 | std::vector enemies; 40 | DynamicMesh* motherMesh; 41 | Texture* bodyTexture; 42 | Texture* clothTexture; 43 | }; 44 | 45 | } // namespace Demo 46 | -------------------------------------------------------------------------------- /demo/inc/states/game/hud/hud.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | using std::unique_ptr; 17 | using Tyra::Sprite; 18 | using Tyra::Texture; 19 | using Tyra::TextureRepository; 20 | 21 | namespace Demo { 22 | 23 | class Hud { 24 | public: 25 | Hud(TextureRepository* repo); 26 | ~Hud(); 27 | 28 | TextureRepository* repo; 29 | 30 | unique_ptr hpSprite; 31 | unique_ptr crosshairSprite; 32 | unique_ptr soldierSprite; 33 | 34 | Texture* hpTexture; 35 | Texture* crosshairTexture; 36 | Texture* soldierTexture; 37 | }; 38 | 39 | } // namespace Demo 40 | -------------------------------------------------------------------------------- /demo/inc/states/game/player/camera.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | using Tyra::CameraInfo3D; 16 | using Tyra::Pad; 17 | using Tyra::Vec4; 18 | 19 | namespace Demo { 20 | 21 | class Camera { 22 | public: 23 | Camera(Pad* pad); 24 | ~Camera(); 25 | 26 | Vec4 lookAt; 27 | Vec4 position; 28 | Vec4 unitCircle; 29 | 30 | CameraInfo3D getCameraInfo() { return CameraInfo3D(&position, &lookAt); } 31 | 32 | void update(const Vec4& playerPosition, const float& terrainHeight); 33 | 34 | private: 35 | float circleRotation, lengthFromOrigin, height; 36 | 37 | Pad* pad; 38 | }; 39 | 40 | } // namespace Demo 41 | -------------------------------------------------------------------------------- /demo/inc/states/game/player/player_shoot_action.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | using Tyra::Ray; 17 | 18 | namespace Demo { 19 | 20 | struct PlayerShootAction { 21 | bool isShooting = false; 22 | std::optional ray; 23 | }; 24 | 25 | } // namespace Demo 26 | -------------------------------------------------------------------------------- /demo/inc/states/game/player/weapon.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | using Tyra::Audio; 16 | using Tyra::Engine; 17 | using Tyra::Pad; 18 | using Tyra::Renderer; 19 | using Tyra::StaPipOptions; 20 | using Tyra::StaticMesh; 21 | using Tyra::TextureRepository; 22 | using Tyra::Timer; 23 | using Tyra::Vec4; 24 | 25 | namespace Demo { 26 | 27 | class Weapon { 28 | public: 29 | Weapon(Engine* engine); 30 | ~Weapon(); 31 | 32 | StaticMesh* mesh; 33 | StaPipOptions* options; 34 | bool isShooting = false; 35 | 36 | void update(); 37 | 38 | private: 39 | bool isShootAnimation1, isShootAnimation2; 40 | Pad* pad; 41 | Audio* audio; 42 | Timer shootTimer; 43 | Vec4 initialPosition; 44 | u8 adpcmCurrentChannel; 45 | u8 adpcmChannelsCount; 46 | 47 | audsrv_adpcm_t* shootAdpcm; 48 | 49 | void shoot(); 50 | void allocateOptions(); 51 | u8 getShootChannel(); 52 | }; 53 | 54 | } // namespace Demo 55 | -------------------------------------------------------------------------------- /demo/inc/states/game/renderer/renderer_dynamic_pair.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | using Tyra::DynamicMesh; 16 | using Tyra::DynPipOptions; 17 | 18 | namespace Demo { 19 | 20 | struct RendererDynamicPair { 21 | DynamicMesh* mesh; 22 | DynPipOptions* options; 23 | }; 24 | 25 | } // namespace Demo 26 | -------------------------------------------------------------------------------- /demo/inc/states/game/renderer/renderer_static_pair.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | using Tyra::StaPipOptions; 16 | using Tyra::StaticMesh; 17 | 18 | namespace Demo { 19 | 20 | struct RendererStaticPair { 21 | StaticMesh* mesh; 22 | StaPipOptions* options; 23 | }; 24 | 25 | } // namespace Demo 26 | -------------------------------------------------------------------------------- /demo/inc/states/game/ship/ship.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "states/game/renderer/renderer_static_pair.hpp" 15 | 16 | using Tyra::Renderer; 17 | using Tyra::StaPipOptions; 18 | using Tyra::StaticMesh; 19 | using Tyra::TextureRepository; 20 | using Tyra::Vec4; 21 | 22 | namespace Demo { 23 | 24 | class Ship { 25 | public: 26 | Ship(TextureRepository* repo); 27 | ~Ship(); 28 | 29 | StaticMesh* mesh; 30 | StaPipOptions* options; 31 | RendererStaticPair* pair; 32 | 33 | private: 34 | void allocateOptions(); 35 | }; 36 | 37 | } // namespace Demo 38 | -------------------------------------------------------------------------------- /demo/inc/states/game/skybox/skybox.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "states/game/renderer/renderer_static_pair.hpp" 15 | 16 | using Tyra::Renderer; 17 | using Tyra::StaPipOptions; 18 | using Tyra::StaticMesh; 19 | using Tyra::TextureRepository; 20 | using Tyra::Vec4; 21 | 22 | namespace Demo { 23 | 24 | class Skybox { 25 | public: 26 | Skybox(TextureRepository* repo); 27 | ~Skybox(); 28 | 29 | StaticMesh* mesh; 30 | StaPipOptions* options; 31 | RendererStaticPair* pair; 32 | 33 | void update(const Vec4& playerPosition); 34 | 35 | private: 36 | void allocateOptions(); 37 | }; 38 | 39 | } // namespace Demo 40 | -------------------------------------------------------------------------------- /demo/inc/states/game/terrain/heightmap.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | using Tyra::Vec4; 16 | 17 | namespace Demo { 18 | 19 | class Heightmap { 20 | public: 21 | Heightmap(const float& minHeight, const float& maxHeight, const Vec4& leftUp, 22 | const Vec4& rightDown); 23 | ~Heightmap(); 24 | 25 | const float& getHeightOffset(const Vec4& playerPosition) const; 26 | 27 | bool isOutside(const Vec4& position) const; 28 | 29 | float** map; 30 | s16 mapWidth, mapHeight; 31 | float minHeight, maxHeight; 32 | Vec4 leftUp, rightDown; 33 | 34 | private: 35 | float getWidthPercentage(const Vec4& playerPosition) const; 36 | float getHeightPercentage(const Vec4& playerPosition) const; 37 | void allocateMap(const unsigned char* data, const int& width, 38 | const int& height); 39 | float getGameHeight(const u8& inputColor, const u8& minColor, 40 | const u8& maxColor) const; 41 | }; 42 | 43 | } // namespace Demo 44 | -------------------------------------------------------------------------------- /demo/inc/states/game/terrain/terrain.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "states/game/renderer/renderer_static_pair.hpp" 15 | #include "./heightmap.hpp" 16 | 17 | using Tyra::StaPipOptions; 18 | using Tyra::StaticMesh; 19 | using Tyra::TextureRepository; 20 | using Tyra::Vec4; 21 | 22 | namespace Demo { 23 | 24 | class Terrain { 25 | public: 26 | Terrain(TextureRepository* repo); 27 | ~Terrain(); 28 | 29 | Heightmap heightmap; 30 | StaticMesh* mesh; 31 | StaPipOptions* options; 32 | RendererStaticPair* pair; 33 | 34 | float getHeightOffset(const Vec4& playerPosition); 35 | 36 | private: 37 | void allocateOptions(); 38 | }; 39 | 40 | } // namespace Demo 41 | -------------------------------------------------------------------------------- /demo/inc/states/intro/intro_state.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "state/state.hpp" 14 | #include "state/global_state_type.hpp" 15 | #include "state/state_manager.hpp" 16 | #include "./intro_state_type.hpp" 17 | 18 | namespace Demo { 19 | 20 | class IntroState : public State { 21 | public: 22 | IntroState(Engine* t_engine); 23 | ~IntroState(); 24 | 25 | const GlobalStateType& getState() const { return state; } 26 | 27 | const bool& wantFinish() const { return _wantFinish; }; 28 | 29 | void onStart(); 30 | 31 | void update(); 32 | 33 | /** @return Next game state */ 34 | GlobalStateType onFinish(); 35 | 36 | private: 37 | GlobalStateType state; 38 | bool _wantFinish; 39 | bool initialized; 40 | 41 | StateManager stateManager; 42 | }; 43 | 44 | } // namespace Demo 45 | -------------------------------------------------------------------------------- /demo/inc/states/intro/intro_state_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Demo { 14 | 15 | enum IntroStateType { 16 | STATE_PS2DEV, 17 | STATE_TYRA, 18 | STATE_PRESS_KEY, 19 | STATE_INTRO_END 20 | }; 21 | 22 | } // namespace Demo 23 | -------------------------------------------------------------------------------- /demo/inc/states/intro/states/intro_ps2dev_state.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "state/state.hpp" 14 | #include "../intro_state_type.hpp" 15 | #include 16 | 17 | using Tyra::Sprite; 18 | using Tyra::Texture; 19 | using Tyra::Timer; 20 | 21 | namespace Demo { 22 | 23 | class IntroPs2DevState : public State { 24 | public: 25 | IntroPs2DevState(Engine* t_engine); 26 | ~IntroPs2DevState(); 27 | 28 | const IntroStateType& getState() const { return state; } 29 | 30 | const bool& wantFinish() const { return _wantFinish; }; 31 | 32 | void onStart(); 33 | 34 | void update(); 35 | 36 | /** @return Next game state */ 37 | IntroStateType onFinish(); 38 | 39 | private: 40 | IntroStateType state; 41 | bool _wantFinish; 42 | 43 | Texture* texture; 44 | Timer initialDelayTimer; 45 | bool initialized; 46 | bool initialDelayElapsed; 47 | bool fadeinActivated; 48 | bool fadeoutActivated; 49 | u8 frameSkipper; 50 | 51 | Sprite* sprite; 52 | }; 53 | 54 | } // namespace Demo 55 | -------------------------------------------------------------------------------- /demo/inc/states/loading/loading_state.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "state/state.hpp" 14 | #include "state/global_state_type.hpp" 15 | #include "state/state_manager.hpp" 16 | 17 | namespace Demo { 18 | 19 | class LoadingState : public State { 20 | public: 21 | LoadingState(Engine* t_engine); 22 | ~LoadingState(); 23 | 24 | const GlobalStateType& getState() const { return state; } 25 | 26 | const bool& wantFinish() const { return _wantFinish; }; 27 | 28 | void onStart(); 29 | 30 | void update(); 31 | 32 | /** @return Next game state */ 33 | GlobalStateType onFinish(); 34 | 35 | private: 36 | GlobalStateType state; 37 | bool _wantFinish; 38 | bool initialized; 39 | }; 40 | 41 | } // namespace Demo 42 | -------------------------------------------------------------------------------- /demo/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /demo/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /demo/src/demo_game.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "demo_game.hpp" 12 | #include "states/intro/intro_state.hpp" 13 | #include "states/loading/loading_state.hpp" 14 | #include "states/game/game_state.hpp" 15 | 16 | namespace Demo { 17 | 18 | DemoGame::DemoGame(Engine* t_engine) 19 | : engine(t_engine), stateManager(STATE_INTRO, STATE_EXIT) {} 20 | DemoGame::~DemoGame() {} 21 | 22 | void DemoGame::init() { 23 | stateManager.add(new IntroState(engine)); 24 | stateManager.add(new LoadingState(engine)); 25 | stateManager.add(new GameState(engine)); 26 | } 27 | void DemoGame::loop() { 28 | stateManager.update(); 29 | 30 | if (stateManager.finished()) { 31 | exit(0); 32 | } 33 | } 34 | 35 | } // namespace Demo 36 | -------------------------------------------------------------------------------- /demo/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include 12 | #include "demo_game.hpp" 13 | #include "game_settings.hpp" 14 | 15 | int main() { 16 | Tyra::EngineOptions options; 17 | 18 | if (Demo::IS_REAL_PS2_VIA_USB) { 19 | options.writeLogsToFile = true; 20 | options.loadUsbDriver = true; 21 | } 22 | 23 | Tyra::Engine engine(options); 24 | 25 | Demo::DemoGame game(&engine); 26 | engine.run(&game); 27 | SleepThread(); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /demo/src/states/game/ship/ship.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "states/game/ship/ship.hpp" 12 | 13 | using Tyra::FileUtils; 14 | using Tyra::ObjLoader; 15 | using Tyra::ObjLoaderOptions; 16 | 17 | namespace Demo { 18 | 19 | Ship::Ship(TextureRepository* repo) { 20 | ObjLoader loader; 21 | 22 | ObjLoaderOptions objOptions; 23 | objOptions.flipUVs = true; 24 | objOptions.scale = 200.0F; 25 | 26 | auto data = 27 | loader.load(FileUtils::fromCwd("game/models/ship/ship.obj"), objOptions); 28 | mesh = new StaticMesh(data.get()); 29 | 30 | for (std::size_t i = 0; i < mesh->materials.size(); i++) { 31 | mesh->materials[i]->ambient /= 2.0F; 32 | mesh->materials[i]->ambient.a = 128.0F; 33 | } 34 | 35 | mesh->setPosition(Vec4(-800.0F, 10.0F, -2500.0F)); 36 | 37 | allocateOptions(); 38 | 39 | pair = new RendererStaticPair{mesh, options}; 40 | } 41 | 42 | Ship::~Ship() { 43 | delete mesh; 44 | delete options; 45 | delete pair; 46 | } 47 | 48 | void Ship::allocateOptions() { options = new StaPipOptions(); } 49 | 50 | } // namespace Demo 51 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | volumes: 3 | tyra-volume: 4 | services: 5 | compiler: 6 | environment: 7 | TERM: xterm-256color 8 | network_mode: host 9 | image: "h4570/tyra" 10 | tty: true 11 | container_name: tyra-compiler 12 | volumes: 13 | - tyra-volume:/src 14 | - ./:/host 15 | -------------------------------------------------------------------------------- /docs/install/README.MD: -------------------------------------------------------------------------------- 1 | # Installing Tyra 2 | 3 | [![](https://img.shields.io/badge/Install%20time-5%20minutes-brightgreen)](#) 4 | 5 | ## Prerequisites: 6 | 1. Git 7 | 2. VSCode 8 | 3. Docker with PowerShell as a default terminal 9 | 4. [Configured PCSX2](https://github.com/h4570/tyra/blob/master/docs/install/pcsx2.md#) 10 | 11 | --- 12 | 13 | ## Steps: 14 | 1. Download [intellisense package](https://github.com/h4570/tyra/releases) and unzip it somewhere in your computer. 15 | 2. Open terminal in your favourite repositories directory and execute: 16 | ``` 17 | docker pull h4570/tyra 18 | git clone https://github.com/h4570/tyra.git 19 | ``` 20 | 3. Download the [assets.zip](https://github.com/h4570/tyra/releases) file and unzip it into the tyra directory 21 | 4. Open `VSCode` and open previously cloned directory. 22 | 5. In `VSCode` open `.vscode/configurations/windows-docker` and copy configuration files into `.vscode/` 23 | 6. In `c_cpp_properties.json` fix all `YOUR-INTELLISENSE-PATH` with path from point 2. 24 | 7. Click `CTRL+SHIFT+P`, type `Tasks: Run task` and run `Start docker container` - Repeat this step every time you want to start working with Tyra (every reboot) 25 | 8. Click `CTRL+SHIFT+P`, type `Tasks: Run build task` 26 | 9. Tyra should automatically compile engine, `demo` game and run `PCSX2`. If you want to compile & run tutorials, please change `buildDirectory` in `settings.json` to example `tutorials/01-hello` 27 | -------------------------------------------------------------------------------- /docs/install/pcsx2.md: -------------------------------------------------------------------------------- 1 | ## PCSX2 preparation 2 | 3 | - Download PCSX2 from https://pcsx2.net/ 4 | - Install 5 | - Extract bios files from https://romsmania.cc/bios/pcsx2-playstation-2-bios-3 to `%UserProfile%\Documents\PCSX2\bios` 6 | - Map pad to your keyboard, for example: 7 | 8 | ``` 9 | WASD = Left joy 10 | Arrows = Right joy 11 | Space = X 12 | Circle = C 13 | ``` 14 | 15 | ### For PCSX2 1.6.X 16 | - Close `PCSX2` if you have opened! 17 | - Open `%UserProfile%\Documents\PCSX2\inis\PCSX2_vm.ini` in notepad and change HostFs option: 18 | 19 | ``` 20 | HostFs=enabled 21 | ``` 22 | 23 | ### For PCSX2 1.7.X 24 | - Open `PCSX2` 25 | - Go to Settings -> Emulation -> Enable `Host file system` -------------------------------------------------------------------------------- /engine/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := libtyra.a 2 | 3 | #The Directories, Source, Includes, Objects, Binary and Resources 4 | SRCDIR := src 5 | INCDIR := inc 6 | BUILDDIR := obj 7 | TARGETDIR := bin 8 | RESDIR := res 9 | SRCEXT := cpp 10 | VSMEXT := vsm 11 | VCLEXT := vcl 12 | VCLPPEXT := vclpp 13 | DEPEXT := d 14 | OBJEXT := o 15 | 16 | #Flags, Libraries and Includes 17 | CFLAGS := 18 | LIB := 19 | LIBDIRS := 20 | INC := -I$(INCDIR) 21 | INCDEP := -I$(INCDIR) 22 | 23 | include ../Makefile.base 24 | 25 | $(TARGET): $(OBJECTS) $(VCL_OBJECTS) $(VU_OBJECTS_VCL) $(VU_OBJECTS_VSM) $(IRXEM_OBJECTS) 26 | $(AR) rcs $(TARGETDIR)/$(TARGET) $(OBJECTS) $(VCL_OBJECTS) $(VU_OBJECTS_VCL) $(VU_OBJECTS_VSM) $(IRXEM_OBJECTS) 27 | -------------------------------------------------------------------------------- /engine/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /engine/inc/audio/adpcm_result.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022-2022, Tyra - https://github.com/h4570/tyrav2 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | # Wellinator Carvalho 10 | */ 11 | 12 | #pragma once 13 | 14 | namespace Tyra { 15 | 16 | enum AdpcmResult { 17 | ADPCM_OK, 18 | 19 | /** When provided channel by user is currently in use */ 20 | ADPCM_CHANNEL_USED, 21 | 22 | /** When user did not provided channel and all are in use */ 23 | ADPCM_NO_FREE_CHANNELS, 24 | 25 | ADPCM_ERROR 26 | }; 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/inc/audio/audio.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022-2022, Tyra - https://github.com/h4570/tyrav2 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | # Wellinator Carvalho 10 | */ 11 | 12 | #pragma once 13 | 14 | #include "./audio_adpcm.hpp" 15 | #include "./audio_song.hpp" 16 | 17 | namespace Tyra { 18 | 19 | /** Class responsible for audio. */ 20 | class Audio { 21 | public: 22 | Audio(); 23 | ~Audio(); 24 | 25 | void init(); 26 | 27 | AudioSong song; 28 | AudioAdpcm adpcm; 29 | 30 | void work(); 31 | 32 | private: 33 | ee_thread_t thread; 34 | int threadId; 35 | static const u16 threadStackSize; 36 | u8* threadStack; 37 | 38 | void initAUDSRV(); 39 | void initThread(); 40 | }; 41 | 42 | } // namespace Tyra 43 | -------------------------------------------------------------------------------- /engine/inc/audio/audio_listener.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022-2022, Tyra - https://github.com/h4570/tyrav2 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | # Wellinator Carvalho 10 | */ 11 | 12 | #pragma once 13 | 14 | namespace Tyra { 15 | 16 | class AudioListener { 17 | public: 18 | virtual ~AudioListener(){}; 19 | virtual void onAudioTick() = 0; 20 | virtual void onAudioFinish() = 0; 21 | 22 | private: 23 | }; 24 | 25 | } // namespace Tyra 26 | -------------------------------------------------------------------------------- /engine/inc/audio/audio_listener_ref.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022-2022, Tyra - https://github.com/h4570/tyrav2 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | # Wellinator Carvalho 10 | */ 11 | 12 | #pragma once 13 | 14 | #include "./audio_listener.hpp" 15 | #include 16 | 17 | namespace Tyra { 18 | 19 | struct AudioListenerRef { 20 | AudioListener* listener; 21 | u32 id; 22 | }; 23 | 24 | } // namespace Tyra 25 | -------------------------------------------------------------------------------- /engine/inc/engine.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "./renderer/renderer.hpp" 14 | #include "./pad/pad.hpp" 15 | #include "./audio/audio.hpp" 16 | #include "./irx/irx_loader.hpp" 17 | #include "./info/info.hpp" 18 | #include "./info/banner.hpp" 19 | #include "./game.hpp" 20 | 21 | namespace Tyra { 22 | 23 | struct EngineOptions { 24 | /** 25 | * True -> logs will be written to file. 26 | * False -> logs will be displayed in console 27 | */ 28 | bool writeLogsToFile = false; 29 | 30 | bool loadUsbDriver = false; 31 | }; 32 | 33 | class Engine { 34 | public: 35 | Engine(); 36 | Engine(const EngineOptions& options); 37 | ~Engine(); 38 | 39 | Renderer renderer; 40 | Pad pad; 41 | Audio audio; 42 | Info info; 43 | 44 | void run(Game* t_game); 45 | 46 | private: 47 | IrxLoader irx; 48 | 49 | Game* game; 50 | Banner banner; 51 | 52 | void realLoop(); 53 | void initAll(const bool& loadUsbDriver); 54 | }; 55 | 56 | } // namespace Tyra 57 | -------------------------------------------------------------------------------- /engine/inc/game.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | class Game { 16 | public: 17 | virtual void init() = 0; 18 | virtual void loop() = 0; 19 | }; 20 | 21 | } // namespace Tyra 22 | -------------------------------------------------------------------------------- /engine/inc/info/banner.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Wellington Carvalho 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/renderer.hpp" 14 | 15 | namespace Tyra { 16 | 17 | class Banner { 18 | public: 19 | Banner(); 20 | ~Banner(); 21 | 22 | void show(Renderer* renderer); 23 | }; 24 | 25 | } // namespace Tyra 26 | -------------------------------------------------------------------------------- /engine/inc/info/info.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Wellington Carvalho 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "time/timer.hpp" 16 | #include "./version.hpp" 17 | 18 | namespace Tyra { 19 | 20 | class Info { 21 | public: 22 | Info(); 23 | ~Info(); 24 | 25 | Version version; 26 | 27 | static bool writeLogsToFile; 28 | 29 | /** Called by engine */ 30 | void update(); 31 | 32 | const u32& getFps() const { return fps; }; 33 | 34 | /** @return Available RAM in MB */ 35 | float getAvailableRAM(); 36 | 37 | private: 38 | float calcFps(); 39 | void* allocateLargestFreeRAMBlock(size_t* size); 40 | size_t getFreeRAMSize(); 41 | 42 | u8 fpsDelayer; 43 | u32 fps; 44 | Timer timer; 45 | }; 46 | 47 | } // namespace Tyra 48 | -------------------------------------------------------------------------------- /engine/inc/info/version.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # André Guilherme 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | namespace Tyra { 17 | 18 | class Version { 19 | public: 20 | Version() {} 21 | ~Version() {} 22 | 23 | static const u8 major = 2; 24 | static const u8 minor = 2; 25 | static const u8 patch = 0; 26 | 27 | static std::string toString() { 28 | return std::to_string(major) + "." + std::to_string(minor) + "." + 29 | std::to_string(patch); 30 | } 31 | }; 32 | 33 | } // namespace Tyra 34 | -------------------------------------------------------------------------------- /engine/inc/irx/irx_loader.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Wellington Carvalho 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace Tyra { 16 | 17 | class IrxLoader { 18 | public: 19 | IrxLoader(); 20 | ~IrxLoader(); 21 | 22 | void loadAll(const bool& withUsb, const bool& isLoggingToFile); 23 | 24 | private: 25 | static bool isLoaded; 26 | 27 | void loadSio2man(const bool& verbose); 28 | void loadPadman(const bool& verbose); 29 | void loadLibsd(const bool& verbose); 30 | void loadIO(const bool& verbose); 31 | void loadUsbModules(const bool& verbose); 32 | void loadAudsrv(const bool& verbose); 33 | 34 | int applyRpcPatches(); 35 | void waitUntilUsbDeviceIsReady(); 36 | void delay(int count); 37 | }; 38 | 39 | } // namespace Tyra 40 | -------------------------------------------------------------------------------- /engine/inc/loaders/3d/builder/mesh_builder_data.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #pragma once 13 | 14 | #include 15 | #include "./mesh_builder_material_data.hpp" 16 | 17 | namespace Tyra { 18 | 19 | /** 20 | * Data needed for constructing mesh class. 21 | * All dynamic data ownership is moved to mesh class, so 22 | * verts, coords.. are not deallocated! 23 | */ 24 | class MeshBuilderData { 25 | public: 26 | MeshBuilderData(); 27 | ~MeshBuilderData(); 28 | 29 | std::vector materials; 30 | 31 | bool loadNormals, loadLightmap; 32 | }; 33 | 34 | } // namespace Tyra 35 | -------------------------------------------------------------------------------- /engine/inc/loaders/3d/builder/mesh_builder_material_data.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #pragma once 13 | 14 | #include 15 | #include 16 | #include 17 | #include "./mesh_builder_material_frame_data.hpp" 18 | #include "renderer/models/color.hpp" 19 | 20 | namespace Tyra { 21 | 22 | class MeshBuilderMaterialData { 23 | public: 24 | MeshBuilderMaterialData(); 25 | ~MeshBuilderMaterialData(); 26 | 27 | std::vector frames; 28 | std::string name; 29 | std::optional texturePath; 30 | Color ambient; 31 | }; 32 | 33 | } // namespace Tyra 34 | -------------------------------------------------------------------------------- /engine/inc/loaders/3d/builder/mesh_builder_material_frame_data.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #pragma once 13 | 14 | #include 15 | #include "math/vec4.hpp" 16 | #include "renderer/models/color.hpp" 17 | 18 | namespace Tyra { 19 | 20 | class MeshBuilderMaterialFrameData { 21 | public: 22 | MeshBuilderMaterialFrameData(); 23 | ~MeshBuilderMaterialFrameData(); 24 | 25 | u32 count; 26 | Vec4 *vertices, *textureCoords, *normals; 27 | Color* colors; 28 | }; 29 | 30 | } // namespace Tyra 31 | -------------------------------------------------------------------------------- /engine/inc/loaders/3d/md2_loader/md2_loader.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "../builder/mesh_builder_data.hpp" 14 | #include 15 | #include 16 | 17 | namespace Tyra { 18 | 19 | struct MD2LoaderOptions { 20 | bool flipUVs = false; 21 | float scale = 1.0F; 22 | }; 23 | 24 | /** Class responsible for loading & parsing Quake's II ".md2" 3D files */ 25 | class MD2Loader { 26 | public: 27 | static std::unique_ptr load(const char* fullpath); 28 | static std::unique_ptr load(const char* fullpath, 29 | MD2LoaderOptions options); 30 | static std::unique_ptr load(const std::string& fullpath); 31 | static std::unique_ptr load(const std::string& fullpath, 32 | MD2LoaderOptions options); 33 | }; 34 | 35 | } // namespace Tyra 36 | -------------------------------------------------------------------------------- /engine/inc/loaders/texture/base/texture_loader.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "loaders/texture/builder/texture_builder_data.hpp" 14 | #include "renderer/core/texture/models/texture_bpp.hpp" 15 | #include 16 | 17 | namespace Tyra { 18 | class TextureLoader { 19 | public: 20 | /** 21 | * @brief Loads texture data from file. 22 | * Sets size, name and data. 23 | * @param fullpath Full path to texture file. Example: "host:texture.png" 24 | */ 25 | virtual TextureBuilderData* load(const char* fullpath) = 0; 26 | 27 | inline TextureBuilderData* load(const std::string& fullpath) { 28 | return load(fullpath.c_str()); 29 | } 30 | 31 | u32 getTextureSize(const u32& width, const u32& height, 32 | const TextureBpp& bpp); 33 | }; 34 | } // namespace Tyra 35 | -------------------------------------------------------------------------------- /engine/inc/loaders/texture/base/texture_loader_selector.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "loaders/texture/base/texture_loader.hpp" 14 | #include "loaders/texture/png_loader.hpp" 15 | #include 16 | 17 | namespace Tyra { 18 | class TextureLoaderSelector { 19 | public: 20 | TextureLoaderSelector(); 21 | ~TextureLoaderSelector(); 22 | 23 | TextureLoader& getLoaderByFileName(const char* fullpath); 24 | 25 | inline TextureLoader& getLoaderByFileName(const std::string& fullpath) { 26 | return getLoaderByFileName(fullpath.c_str()); 27 | } 28 | 29 | TextureLoader& getLoaderByExtension(const std::string& extension); 30 | 31 | private: 32 | PngLoader pngLoader; 33 | }; 34 | } // namespace Tyra 35 | -------------------------------------------------------------------------------- /engine/inc/loaders/texture/builder/texture_builder_data.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "renderer/core/texture/models/texture_bpp.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class TextureBuilderData { 20 | public: 21 | TextureBuilderData(); 22 | ~TextureBuilderData(); 23 | 24 | std::string name; 25 | 26 | int width, height; 27 | unsigned char* data; 28 | TextureBpp bpp; 29 | unsigned char gsComponents; 30 | 31 | int clutWidth, clutHeight; 32 | unsigned char* clut; 33 | TextureBpp clutBpp; 34 | unsigned char clutGsComponents; 35 | }; 36 | 37 | } // namespace Tyra 38 | -------------------------------------------------------------------------------- /engine/inc/math/math.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | extern "C" { 14 | #include 15 | } 16 | 17 | #include 18 | 19 | namespace Tyra { 20 | 21 | class Math { 22 | public: 23 | constexpr static float HALF_ANG2RAD = 3.14159265358979323846F / 360.0F; 24 | constexpr static float ANG2RAD = 3.14159265358979323846F / 180.0F; 25 | constexpr static float PI = 3.1415926535897932384626433832795F; 26 | constexpr static float HALF_PI = 1.5707963267948966192313216916398F; 27 | static float cos(float x); 28 | static float asin(float x); 29 | static float atan2(float y, float x); 30 | static float mod(const float& x, const float& y); 31 | static float acos(const float& x); 32 | static float sin(const float& x); 33 | static float tan(const float& x); 34 | static float invSqrt(const float& x); 35 | static float randomf(const float& min, const float& max); 36 | static int randomi(const int& min, const int& max); 37 | static bool equalf(const float& a, const float& b, 38 | const float& epsilon = 0.00001F); 39 | }; 40 | 41 | } // namespace Tyra 42 | -------------------------------------------------------------------------------- /engine/inc/math/plane.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "./vec4.hpp" 14 | #include 15 | 16 | namespace Tyra { 17 | 18 | class Plane { 19 | public: 20 | Vec4 normal; 21 | float distance; 22 | 23 | Plane(); 24 | Plane(const Vec4& a, const Vec4& b, const Vec4& c); 25 | ~Plane(); 26 | 27 | void update(const Vec4& a, const Vec4& b, const Vec4& c); 28 | 29 | float distanceTo(const Vec4& t_vec) const; 30 | 31 | void print() const; 32 | void print(const char* name) const; 33 | void print(const std::string& name) const { print(name.c_str()); } 34 | std::string getPrint(const char* name = nullptr) const; 35 | }; 36 | 37 | } // namespace Tyra 38 | -------------------------------------------------------------------------------- /engine/inc/renderer/2d/renderer_2d.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/core/2d/sprite/sprite.hpp" 14 | #include "renderer/core/renderer_core.hpp" 15 | 16 | namespace Tyra { 17 | 18 | class Renderer2D { 19 | public: 20 | Renderer2D(); 21 | ~Renderer2D(); 22 | 23 | void init(RendererCore* rendererCore); 24 | void render(const Sprite* sprite); 25 | void render(const Sprite& sprite); 26 | 27 | private: 28 | RendererCore* core; 29 | }; 30 | 31 | } // namespace Tyra 32 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/bbox/bbox_face.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/vec4.hpp" 14 | 15 | namespace Tyra { 16 | 17 | /** BBox face */ 18 | class BBoxFace { 19 | public: 20 | BBoxFace() {} 21 | BBoxFace(const Vec4& t_minCorner, const Vec4& t_maxCorner, float t_axisPos) { 22 | minCorner = t_minCorner; 23 | maxCorner = t_maxCorner; 24 | axisPosition = t_axisPos; 25 | } 26 | 27 | /** Position of the face on it's respective axis. */ 28 | float axisPosition; 29 | /** Corner of the face with lower coordinates */ 30 | Vec4 minCorner; 31 | /** Corner of the face with higher coordinates */ 32 | Vec4 maxCorner; 33 | }; 34 | 35 | } // namespace Tyra 36 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/mesh/dynamic/animation_sequence_callback.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #pragma once 13 | 14 | namespace Tyra { 15 | 16 | enum AnimationSequenceCallback { 17 | /** On frame change */ 18 | AnimationSequenceCallback_NextFrame, 19 | /** When animation in loop = false will end */ 20 | AnimationSequenceCallback_End, 21 | /** When animation in loop = true will start from beginning */ 22 | AnimationSequenceCallback_Loop 23 | }; 24 | 25 | } // namespace Tyra 26 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/mesh/dynamic/dynamic_mesh.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "../mesh_frame.hpp" 14 | #include "./dynamic_mesh_animation.hpp" 15 | #include "../mesh.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class DynamicMesh : public Mesh { 20 | public: 21 | explicit DynamicMesh(const MeshBuilderData* data); 22 | DynamicMesh(const DynamicMesh& mesh); 23 | ~DynamicMesh(); 24 | 25 | std::vector frames; 26 | 27 | DynamicMeshAnimation animation; 28 | 29 | /** @returns bounding box object of current frame. */ 30 | const BBox& getCurrentBoundingBox() const { 31 | return *frames[animation.getState().currentFrame]->bbox; 32 | } 33 | 34 | /** Update animation */ 35 | inline void update() { animation.update(); } 36 | }; 37 | 38 | } // namespace Tyra 39 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/mesh/dynamic/dynamic_mesh_anim_state.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #pragma once 13 | 14 | #include 15 | 16 | namespace Tyra { 17 | 18 | struct DynamicMeshAnimState { 19 | float interpolation; 20 | u32 currentFrame; 21 | u32 nextFrame; 22 | }; 23 | 24 | } // namespace Tyra 25 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/mesh/mesh.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/m4x4.hpp" 14 | #include "./mesh_material.hpp" 15 | #include 16 | #include "debug/debug.hpp" 17 | 18 | namespace Tyra { 19 | 20 | class Mesh { 21 | public: 22 | explicit Mesh(const MeshBuilderData* data); 23 | Mesh(const Mesh& mesh); 24 | ~Mesh(); 25 | 26 | u8 isMother; 27 | 28 | u32 id; 29 | 30 | M4x4 translation, rotation, scale; 31 | 32 | /** nullptr if not found */ 33 | MeshMaterial* getMaterialByName(const std::string& name); 34 | 35 | std::vector materials; 36 | 37 | M4x4 getModelMatrix() const; 38 | 39 | /** Get position from translation matrix */ 40 | inline Vec4* getPosition() { 41 | return reinterpret_cast(&translation.data[3 * 4]); 42 | } 43 | 44 | void setPosition(const Vec4& v); 45 | 46 | protected: 47 | void init(); 48 | }; 49 | 50 | } // namespace Tyra 51 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/mesh/mesh_frame.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "./mesh_material.hpp" 14 | #include "loaders/3d/builder/mesh_builder_data.hpp" 15 | #include "renderer/3d/bbox/bbox.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class MeshFrame { 20 | public: 21 | explicit MeshFrame(const MeshBuilderData& data, const u32& index); 22 | explicit MeshFrame(const MeshFrame& frame); 23 | ~MeshFrame(); 24 | 25 | u8 isMother; 26 | 27 | u32 id; 28 | 29 | BBox* bbox; 30 | 31 | void print() const; 32 | void print(const char* name) const; 33 | void print(const std::string& name) const { print(name.c_str()); } 34 | std::string getPrint(const char* name = nullptr) const; 35 | }; 36 | 37 | } // namespace Tyra 38 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/mesh/mesh_material.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "debug/debug.hpp" 14 | #include "./mesh_material_frame.hpp" 15 | #include "loaders/3d/builder/mesh_builder_data.hpp" 16 | #include 17 | 18 | namespace Tyra { 19 | 20 | class MeshMaterial { 21 | public: 22 | explicit MeshMaterial(const MeshBuilderData& data, const u32& materialIndex); 23 | explicit MeshMaterial(const MeshMaterial& material); 24 | ~MeshMaterial(); 25 | 26 | bool isMother, lightmapFlag; 27 | u32 id; 28 | std::string name; 29 | std::optional textureName; 30 | Color ambient; 31 | 32 | std::vector frames; 33 | 34 | const BBox& getBBox(const u32& frame) const; 35 | 36 | void print() const; 37 | void print(const char* name) const; 38 | void print(const std::string& name) const { print(name.c_str()); } 39 | std::string getPrint(const char* name = nullptr) const; 40 | }; 41 | 42 | } // namespace Tyra 43 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/mesh/mesh_material_frame.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "loaders/3d/builder/mesh_builder_data.hpp" 14 | #include "./renderer/3d/bbox/bbox.hpp" 15 | 16 | namespace Tyra { 17 | 18 | class MeshMaterialFrame { 19 | public: 20 | explicit MeshMaterialFrame(const MeshBuilderData& data, const u32& frameIndex, 21 | const u32& materialIndex); 22 | explicit MeshMaterialFrame(const MeshMaterialFrame& frame); 23 | ~MeshMaterialFrame(); 24 | 25 | u8 isMother; 26 | 27 | u32 id, count; 28 | 29 | Vec4 *vertices, *textureCoords, *normals; 30 | 31 | Color* colors; 32 | 33 | BBox* bbox; 34 | 35 | void print() const; 36 | void print(const char* name) const; 37 | void print(const std::string& name) const { print(name.c_str()); } 38 | std::string getPrint(const char* name = nullptr) const; 39 | }; 40 | 41 | } // namespace Tyra 42 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/mesh/static/static_mesh.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "../mesh.hpp" 14 | #include "../mesh_frame.hpp" 15 | #include "../mesh_material.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class StaticMesh : public Mesh { 20 | public: 21 | explicit StaticMesh(const MeshBuilderData* data); 22 | StaticMesh(const StaticMesh& mesh); 23 | ~StaticMesh(); 24 | 25 | MeshFrame* frame; 26 | }; 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/bag/dynpip_color_bag.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/models/color.hpp" 14 | 15 | namespace Tyra { 16 | 17 | /** 18 | * @brief Color data. At least one color data is required (single/many). 19 | */ 20 | class DynPipColorBag { 21 | public: 22 | DynPipColorBag(); 23 | ~DynPipColorBag(); 24 | 25 | /** Mandatory */ 26 | const Color* single; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/bag/dynpip_info_bag.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp" 14 | 15 | namespace Tyra { 16 | 17 | class DynPipInfoBag : public PipelineInfoBag { 18 | public: 19 | DynPipInfoBag() {} 20 | ~DynPipInfoBag() {} 21 | }; 22 | 23 | } // namespace Tyra 24 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/bag/dynpip_lighting_bag.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/vec4.hpp" 14 | #include "renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp" 15 | 16 | namespace Tyra { 17 | 18 | class DynPipLightingBag { 19 | public: 20 | DynPipLightingBag(); 21 | ~DynPipLightingBag(); 22 | 23 | /** Mandatory. Model matrix for lights. */ 24 | M4x4* lightMatrix; 25 | 26 | /** Mandatory. Lighting normals per vertex. */ 27 | Vec4* normalsFrom; 28 | Vec4* normalsTo; 29 | 30 | /** Mandatory. Directional lights */ 31 | PipelineDirLightsBag* dirLights; 32 | 33 | void freeNormals(); 34 | }; 35 | 36 | } // namespace Tyra 37 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/bag/dynpip_texture_bag.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/vec4.hpp" 14 | #include "renderer/core/texture/models/texture.hpp" 15 | 16 | namespace Tyra { 17 | 18 | class DynPipTextureBag { 19 | public: 20 | DynPipTextureBag(); 21 | ~DynPipTextureBag(); 22 | 23 | /** Mandatory. Texture coordinates per vertex. */ 24 | Vec4* coordinatesFrom; 25 | Vec4* coordinatesTo; 26 | 27 | /** Mandatory. Texture image. */ 28 | Texture* texture; 29 | 30 | void freeCoords(); 31 | }; 32 | 33 | } // namespace Tyra 34 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/dynpip_program_name.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum DynPipProgramName { 16 | DynPipUndefinedProgram, 17 | 18 | DynPipColor, 19 | DynPipDirLights, 20 | DynPipTextureDirLights, 21 | DynPipTextureColor, 22 | }; 23 | 24 | } // namespace Tyra 25 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/dynpip_programs_repository.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "debug/debug.hpp" 14 | #include "renderer/core/paths/path1/vu1_program.hpp" 15 | #include "./bag/dynpip_bag.hpp" 16 | 17 | #include "./programs/dynpip_c_vu1_program.hpp" 18 | #include "./programs/dynpip_d_vu1_program.hpp" 19 | #include "./programs/dynpip_td_vu1_program.hpp" 20 | #include "./programs/dynpip_tc_vu1_program.hpp" 21 | 22 | namespace Tyra { 23 | 24 | class DynPipProgramsRepository { 25 | public: 26 | DynPipProgramsRepository(); 27 | ~DynPipProgramsRepository(); 28 | 29 | DynPipVU1Program* getProgram(const DynPipProgramName& name); 30 | DynPipVU1Program* getProgramByParams(const bool& isLightingEnabled, 31 | const bool& isTextureEnabled); 32 | DynPipVU1Program* getProgramByBag(const DynPipBag* bag); 33 | 34 | private: 35 | DynPipCVU1Program color; 36 | DynPipDVU1Program dirLights; 37 | DynPipTDVU1Program textureDirLights; 38 | DynPipTCVU1Program textureColor; 39 | }; 40 | 41 | } // namespace Tyra 42 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/programs/dynpip_c_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../dynpip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class DynPipCVU1Program : public DynPipVU1Program { 20 | public: 21 | DynPipCVU1Program(); 22 | ~DynPipCVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, DynPipBag* bag) const; 26 | }; 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/programs/dynpip_d_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../dynpip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class DynPipDVU1Program : public DynPipVU1Program { 20 | public: 21 | DynPipDVU1Program(); 22 | ~DynPipDVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, DynPipBag* bag) const; 26 | }; 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/programs/dynpip_tc_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../dynpip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class DynPipTCVU1Program : public DynPipVU1Program { 20 | public: 21 | DynPipTCVU1Program(); 22 | ~DynPipTCVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, DynPipBag* bag) const; 26 | }; 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/programs/dynpip_td_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../dynpip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class DynPipTDVU1Program : public DynPipVU1Program { 20 | public: 21 | DynPipTDVU1Program(); 22 | ~DynPipTDVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, DynPipBag* bag) const; 26 | }; 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/core/programs/dynpip_vu1_shared_defines.h: -------------------------------------------------------------------------------- 1 | // 2 | // ______ ____ ___ 3 | // | \/ ____| |___| 4 | // | | | \ | | 5 | //----------------------------------------------------------------------- 6 | // Copyright 2022, tyra - https://github.com/h4570/tyra 7 | // Licensed under Apache License 2.0 8 | // Sandro Sobczyński 9 | // 10 | 11 | // Updated once per mesh 12 | #define VU1_MVP_MATRIX_ADDR 0 13 | #define VU1_LIGHTS_MATRIX_ADDR 4 14 | #define VU1_SINGLE_COLOR_ADDR 7 15 | #define VU1_OPTIONS_ADDR 8 16 | #define VU1_LOD_ADDR 9 17 | #define VU1_Z_TESTS_ADDR 10 18 | #define VU1_CLUT_ADDR 11 19 | #define VU1_LIGHTS_DIRS_ADDR 12 20 | #define VU1_LIGHTS_COLORS_ADDR 15 21 | #define VU1_SET_GIFTAG_ADDR 19 22 | #define VU1_DYNPIP_LAST_ITEM_ADDR 19 23 | 24 | // Buffer data (xtop) 25 | #define VU1_DYNPIP_VERT_DATA_ADDR 2 26 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/dynamic/dynpip_options.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/3d/pipeline/shared/pipeline_options.hpp" 14 | 15 | namespace Tyra { 16 | 17 | class DynPipOptions : public PipelineOptions { 18 | public: 19 | DynPipOptions() {} 20 | ~DynPipOptions() {} 21 | }; 22 | 23 | } // namespace Tyra 24 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/data/mcpip_block_data.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/vec4.hpp" 14 | 15 | namespace Tyra { 16 | 17 | class McpipBlockData { 18 | public: 19 | McpipBlockData(); 20 | ~McpipBlockData(); 21 | 22 | u32 count; 23 | float offset; 24 | u32 getComboCount() const { return count * 2; } 25 | 26 | Tyra::Vec4* comboData; 27 | Tyra::Vec4* vertices; 28 | Tyra::Vec4* textureCoords; 29 | }; 30 | 31 | } // namespace Tyra 32 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/data/mcpip_multi_tex_block_data.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "debug/debug.hpp" 14 | #include "./mcpip_block_data.hpp" 15 | #include "string" 16 | 17 | namespace Tyra { 18 | 19 | class McpipMultiTexBlockData : public McpipBlockData { 20 | public: 21 | McpipMultiTexBlockData(); 22 | ~McpipMultiTexBlockData(); 23 | 24 | private: 25 | Vec4* tempVerts; 26 | Vec4* tempTexCoords; 27 | u32* tempVertFaces; 28 | u32* tempTexCoordsFaces; 29 | 30 | void allocateTempData(); 31 | void unroll(); 32 | void dellocateTempData(); 33 | }; 34 | 35 | } // namespace Tyra 36 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/data/mcpip_single_tex_block_data.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "debug/debug.hpp" 14 | #include "./mcpip_block_data.hpp" 15 | #include "string" 16 | 17 | namespace Tyra { 18 | 19 | class McpipSingleTexBlockData : public McpipBlockData { 20 | public: 21 | McpipSingleTexBlockData(); 22 | ~McpipSingleTexBlockData(); 23 | 24 | private: 25 | Vec4* tempVerts; 26 | Vec4* tempTexCoords; 27 | u32* tempVertFaces; 28 | u32* tempTexCoordsFaces; 29 | 30 | void allocateTempData(); 31 | void unroll(); 32 | void dellocateTempData(); 33 | }; 34 | 35 | } // namespace Tyra 36 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/mcpip_block.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "math/m4x4.hpp" 15 | #include "math/vec4.hpp" 16 | #include "renderer/models/color.hpp" 17 | 18 | namespace Tyra { 19 | 20 | class McpipBlock { 21 | public: 22 | McpipBlock() { 23 | model = nullptr; 24 | color = nullptr; 25 | textureOffset = nullptr; 26 | } 27 | ~McpipBlock() {} 28 | 29 | M4x4* model; 30 | Color* color; 31 | Vec4* textureOffset; 32 | }; 33 | 34 | } // namespace Tyra 35 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_as_is_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "debug/debug.hpp" 16 | #include "renderer/3d/pipeline/minecraft/programs/mcpip_program.hpp" 17 | 18 | namespace Tyra { 19 | 20 | class McpipAsIsVU1Program : public McpipProgram { 21 | public: 22 | McpipAsIsVU1Program(); 23 | ~McpipAsIsVU1Program(); 24 | 25 | std::string getStringName() const; 26 | }; 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_vu1_as_is_shared_defines.h: -------------------------------------------------------------------------------- 1 | // 2 | // ______ ____ ___ 3 | // | \/ ____| |___| 4 | // | | | \ | | 5 | //----------------------------------------------------------------------- 6 | // Copyright 2022, tyra - https://github.com/h4570/tyra 7 | // Licensed under Apache License 2.0 8 | // Sandro Sobczyński 9 | // 10 | 11 | // Static data for blockizer program 12 | 13 | #define VU1_MCPIP_AS_IS_STATIC_LOD 0 14 | #define VU1_MCPIP_AS_IS_STATIC_SET_TAG 1 15 | #define VU1_MCPIP_AS_IS_STATIC_LAST_DATA_ADDR 1 16 | 17 | // Dynamic data (unpack per VU1 call) 18 | #define VU1_MCPIP_AS_IS_DYNAMIC_SCALE 0 19 | #define VU1_MCPIP_AS_IS_DYNAMIC_PRIM 1 20 | #define VU1_MCPIP_AS_IS_DYNAMIC_CLUT 2 21 | #define VU1_MCPIP_AS_IS_DYNAMIC_COLOR 3 22 | #define VU1_MCPIP_AS_IS_DYNAMIC_VERTEX_DATA_ADDR 4 23 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/programs/cull/mcpip_cull_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "debug/debug.hpp" 16 | #include "renderer/3d/pipeline/minecraft/programs/mcpip_program.hpp" 17 | 18 | namespace Tyra { 19 | 20 | class McpipCullVU1Program : public McpipProgram { 21 | public: 22 | McpipCullVU1Program(); 23 | ~McpipCullVU1Program(); 24 | 25 | std::string getStringName() const; 26 | }; 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/programs/cull/mcpip_vu1_cull_shared_defines.h: -------------------------------------------------------------------------------- 1 | // 2 | // ______ ____ ___ 3 | // | \/ ____| |___| 4 | // | | | \ | | 5 | //----------------------------------------------------------------------- 6 | // Copyright 2022, tyra - https://github.com/h4570/tyra 7 | // Licensed under Apache License 2.0 8 | // Sandro Sobczyński 9 | // 10 | 11 | // Static data for blockizer program 12 | 13 | #define VU1_MCPIP_CULL_VERTEX_COUNT 36 14 | #define VU1_MCPIP_CULL_QWORDS_PER_BLOCK 6 15 | 16 | #define VU1_MCPIP_CULL_STATIC_LOD 0 17 | #define VU1_MCPIP_CULL_STATIC_PRIM 1 18 | #define VU1_MCPIP_CULL_STATIC_SET_TAG 2 19 | #define VU1_MCPIP_CULL_STATIC_VU1_OPTIONS 3 20 | #define VU1_MCPIP_CULL_STATIC_VERTEX_DATA 4 21 | #define VU1_MCPIP_CULL_STATIC_TEX_COORD_DATA 4 + 36 22 | #define VU1_MCPIP_CULL_STATIC_LAST_DATA_ADDR \ 23 | VU1_MCPIP_CULL_STATIC_TEX_COORD_DATA + 36 24 | 25 | // Dynamic data (unpack per VU1 call) 26 | #define VU1_MCPIP_CULL_DYNAMIC_SCALE_AND_BLOCKS_COUNT_ADDR 0 27 | #define VU1_MCPIP_CULL_DYNAMIC_CLUT_TEX 1 28 | #define VU1_MCPIP_CULL_DYNAMIC_VIEW_PROJ_MATRIX_ADDR 2 29 | #define VU1_MCPIP_CULL_DYNAMIC_BLOCKS_DATA 6 30 | 31 | // Output mini double buffer inside VU1 mem 32 | #define VU1_MCPIP_CULL_DYNAMIC_OUTPUT_DOUBLE_BUFF1_ADDR 774 33 | #define VU1_MCPIP_CULL_DYNAMIC_OUTPUT_DOUBLE_BUFF2_ADDR 887 34 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/programs/mcpip_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "./mcpip_program_name.hpp" 14 | #include "renderer/core/paths/path1/vu1_program.hpp" 15 | 16 | namespace Tyra { 17 | 18 | class McpipProgram : public VU1Program { 19 | public: 20 | McpipProgram(const McpipProgramName& name, u32* start, u32* end); 21 | ~McpipProgram(); 22 | 23 | const McpipProgramName& getName() const; 24 | 25 | protected: 26 | McpipProgramName name; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/programs/mcpip_program_name.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum McpipProgramName { 16 | UndefinedMcpipProgram, 17 | McPipCull, 18 | McPipAsIs, 19 | }; 20 | 21 | } // namespace Tyra 22 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/minecraft/programs/mcpip_programs_repository.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "debug/debug.hpp" 14 | #include "./mcpip_program.hpp" 15 | #include "cull/mcpip_cull_vu1_program.hpp" 16 | #include "as_is/mcpip_as_is_vu1_program.hpp" 17 | 18 | namespace Tyra { 19 | 20 | class McpipProgramsRepository { 21 | public: 22 | McpipProgramsRepository(); 23 | ~McpipProgramsRepository(); 24 | 25 | McpipProgram* getProgram(const McpipProgramName& name); 26 | 27 | private: 28 | McpipCullVU1Program cull; 29 | McpipAsIsVU1Program asIs; 30 | }; 31 | 32 | } // namespace Tyra 33 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/renderer_3d_pipeline.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/core/renderer_core.hpp" 14 | 15 | namespace Tyra { 16 | 17 | class Renderer3DPipeline { 18 | public: 19 | Renderer3DPipeline() { onDestroy = nullptr; } 20 | ~Renderer3DPipeline() {} 21 | 22 | virtual void setRenderer(RendererCore* core) = 0; 23 | virtual void onUse() = 0; 24 | virtual void onFrameEnd() = 0; 25 | virtual void onUseEnd() = 0; 26 | std::function onDestroy; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/shared/bag/pipeline_info_bag_frustum_culling.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum PipelineInfoBagFrustumCulling { 16 | /** No frustum culling */ 17 | PipelineInfoBagFrustumCulling_None = 0, 18 | /** Frustum culling of parts of an object */ 19 | PipelineInfoBagFrustumCulling_Precise = 2, 20 | }; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/shared/pipeline_frustum_culling.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum PipelineFrustumCulling { 16 | /** No frustum culling */ 17 | PipelineFrustumCulling_None = 0, 18 | /** Frustum culling of whole object */ 19 | PipelineFrustumCulling_Simple = 1, 20 | /** Frustum culling of parts of an object */ 21 | PipelineFrustumCulling_Precise = 2, 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/shared/pipeline_lighting_options.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/vec4.hpp" 14 | #include "renderer/models/color.hpp" 15 | 16 | namespace Tyra { 17 | 18 | class PipelineLightingOptions { 19 | public: 20 | PipelineLightingOptions() {} 21 | ~PipelineLightingOptions() {} 22 | 23 | /** 24 | * Mandatory. 25 | * Default 128.0F, 128.0F, 128.0F, 128.0F 26 | */ 27 | Color* ambientColor; 28 | 29 | /** 30 | * Mandatory. 31 | * Min/max length - 3. 32 | * Example color value: 64.0F, 0.0F, 0.0F, 1.0F 33 | */ 34 | Color* directionalColors; 35 | 36 | /** 37 | * Mandatory. 38 | * Min/max length - 3. 39 | * Example dir value: 1.0F, 0.0F, 0.0F, 1.0F 40 | */ 41 | Vec4* directionalDirections; 42 | }; 43 | 44 | } // namespace Tyra 45 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/shared/pipeline_shading_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum PipelineShadingType { 16 | TyraShadingFlat, 17 | TyraShadingGouraud, 18 | }; 19 | 20 | } // namespace Tyra 21 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/shared/pipeline_texture_mapping_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum PipelineTextureMappingType { 16 | TyraNearest, 17 | TyraLinear, 18 | }; 19 | 20 | } // namespace Tyra 21 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/shared/pipeline_transformation_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum PipelineTransformationType { 16 | /** Multiplies model by view and projection matrix */ 17 | TyraMVP, 18 | /** Multiplies model by only projection matrix */ 19 | TyraMP, 20 | }; 21 | 22 | } // namespace Tyra 23 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/shared/pipeline_z_test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum PipelineZTest { 16 | PipelineZTest_Standard = 0, 17 | PipelineZTest_AllPass = 1, 18 | }; 19 | 20 | } // namespace Tyra 21 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/bag/stapip_color_bag.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/models/color.hpp" 14 | 15 | namespace Tyra { 16 | 17 | /** 18 | * @brief Color data. At least one color data is required (single/many). 19 | */ 20 | class StaPipColorBag { 21 | public: 22 | StaPipColorBag(); 23 | ~StaPipColorBag(); 24 | 25 | /** Optional. Single color for all vertices. */ 26 | const Color* single; 27 | 28 | /** Optional. Color per vertex. */ 29 | const Color* many; 30 | }; 31 | 32 | } // namespace Tyra 33 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/bag/stapip_info_bag.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp" 14 | 15 | namespace Tyra { 16 | 17 | class StaPipInfoBag : public PipelineInfoBag { 18 | public: 19 | StaPipInfoBag() { fullClipChecks = false; } 20 | ~StaPipInfoBag() {} 21 | 22 | /** 23 | * @brief Experimental! False -> disables "clip against each plane" algorithm. 24 | * Default: True. 25 | * 26 | * Full clip checks are slow, but they are 27 | * preventing visual artifacts, which can happen 28 | * for big 3D objects (or objects near camera eyes) 29 | * Force enabled in dynamic pipe, because of efficiency. 30 | */ 31 | bool fullClipChecks; 32 | }; 33 | 34 | } // namespace Tyra 35 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/vec4.hpp" 14 | #include "renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp" 15 | 16 | namespace Tyra { 17 | 18 | class StaPipLightingBag { 19 | public: 20 | StaPipLightingBag(); 21 | ~StaPipLightingBag(); 22 | 23 | /** Mandatory. Model matrix for lights. */ 24 | M4x4* lightMatrix; 25 | 26 | /** Mandatory. Lighting normals per vertex. */ 27 | Vec4* normals; 28 | 29 | /** Mandatory. Directional lights */ 30 | PipelineDirLightsBag* dirLights; 31 | }; 32 | 33 | } // namespace Tyra 34 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/bag/stapip_texture_bag.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/vec4.hpp" 14 | #include "renderer/core/texture/models/texture.hpp" 15 | 16 | namespace Tyra { 17 | 18 | class StaPipTextureBag { 19 | public: 20 | StaPipTextureBag(); 21 | ~StaPipTextureBag(); 22 | 23 | /** Mandatory. Texture coordinates per vertex. */ 24 | Vec4* coordinates; 25 | 26 | /** Mandatory. Texture image. */ 27 | Texture* texture; 28 | }; 29 | 30 | } // namespace Tyra 31 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_c_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../../stapip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class StaPipAsIsCVU1Program : public StaPipVU1Program { 20 | public: 21 | StaPipAsIsCVU1Program(); 22 | ~StaPipAsIsCVU1Program(); 23 | 24 | std::string getStringName() const; 25 | 26 | void addProgramQBufferDataToPacket(packet2_t* packet, 27 | StaPipQBuffer* qbuffer) const; 28 | }; 29 | 30 | } // namespace Tyra 31 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_d_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../../stapip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class StaPipAsIsDVU1Program : public StaPipVU1Program { 20 | public: 21 | StaPipAsIsDVU1Program(); 22 | ~StaPipAsIsDVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, 26 | StaPipQBuffer* qbuffer) const; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_tc_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../../stapip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class StaPipAsIsTCVU1Program : public StaPipVU1Program { 20 | public: 21 | StaPipAsIsTCVU1Program(); 22 | ~StaPipAsIsTCVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, 26 | StaPipQBuffer* qbuffer) const; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_td_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../../stapip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class StaPipAsIsTDVU1Program : public StaPipVU1Program { 20 | public: 21 | StaPipAsIsTDVU1Program(); 22 | ~StaPipAsIsTDVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, 26 | StaPipQBuffer* qbuffer) const; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/programs/cull/stapip_cull_c_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../../stapip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class StaPipCullCVU1Program : public StaPipVU1Program { 20 | public: 21 | StaPipCullCVU1Program(); 22 | ~StaPipCullCVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, 26 | StaPipQBuffer* qbuffer) const; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/programs/cull/stapip_cull_d_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../../stapip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class StaPipCullDVU1Program : public StaPipVU1Program { 20 | public: 21 | StaPipCullDVU1Program(); 22 | ~StaPipCullDVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, 26 | StaPipQBuffer* qbuffer) const; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/programs/cull/stapip_cull_tc_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../../stapip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class StaPipCullTCVU1Program : public StaPipVU1Program { 20 | public: 21 | StaPipCullTCVU1Program(); 22 | ~StaPipCullTCVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, 26 | StaPipQBuffer* qbuffer) const; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/programs/cull/stapip_cull_td_vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "../../stapip_vu1_program.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class StaPipCullTDVU1Program : public StaPipVU1Program { 20 | public: 21 | StaPipCullTDVU1Program(); 22 | ~StaPipCullTDVU1Program(); 23 | 24 | std::string getStringName() const; 25 | void addProgramQBufferDataToPacket(packet2_t* packet, 26 | StaPipQBuffer* qbuffer) const; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h: -------------------------------------------------------------------------------- 1 | // 2 | // ______ ____ ___ 3 | // | \/ ____| |___| 4 | // | | | \ | | 5 | //----------------------------------------------------------------------- 6 | // Copyright 2022, tyra - https://github.com/h4570/tyra 7 | // Licensed under Apache License 2.0 8 | // Sandro Sobczyński 9 | // 10 | 11 | // Updated once per mesh 12 | #define VU1_MVP_MATRIX_ADDR 0 13 | #define VU1_LIGHTS_MATRIX_ADDR 4 14 | #define VU1_SINGLE_COLOR_ADDR 7 15 | #define VU1_OPTIONS_ADDR 8 16 | #define VU1_LOD_ADDR 9 17 | #define VU1_Z_TESTS_ADDR 10 18 | #define VU1_CLUT_ADDR 11 19 | #define VU1_LIGHTS_DIRS_ADDR 12 20 | #define VU1_LIGHTS_COLORS_ADDR 15 21 | #define VU1_SET_GIFTAG_ADDR 19 22 | #define VU1_STAPIP_LAST_ITEM_ADDR 19 23 | 24 | // Buffer data (xtop) 25 | #define VU1_STAPIP_VERT_DATA_ADDR 2 26 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/stapip_bag_bboxes_cacher.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "./bag/packaging/stapip_bag_packages_bbox.hpp" 15 | #include "renderer/3d/mesh/mesh.hpp" 16 | #include 17 | #include 18 | 19 | namespace Tyra { 20 | 21 | struct StapipBagBBoxesCacheItem { 22 | u32 vu1MaxVertCount; 23 | u32 id; 24 | std::unique_ptr bboxes; 25 | int framesLeftToDestroy; 26 | }; 27 | 28 | class StapipBagBBoxesCacher { 29 | public: 30 | StapipBagBBoxesCacher(); 31 | ~StapipBagBBoxesCacher(); 32 | 33 | const int cacheFramesCount = 50; 34 | const int cacheSecondsCount = 5; 35 | 36 | void onFrameEnd(); 37 | 38 | StaPipBagPackagesBBox* getBBoxes(const Vec4* vertices, const u32& count, 39 | const u32& id, const u32& maxVertCount); 40 | 41 | private: 42 | StapipBagBBoxesCacheItem* getCache(const u32& maxVertCount, const u32& id); 43 | 44 | std::vector storage; 45 | }; 46 | 47 | } // namespace Tyra 48 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/stapip_program_name.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum StaPipProgramName { 16 | StaPipUndefinedProgram, 17 | 18 | StaPipCullColor, 19 | StaPipAsIsColor, 20 | 21 | StaPipCullDirLights, 22 | StaPipAsIsDirLights, 23 | 24 | StaPipCullTextureDirLights, 25 | StaPipAsIsTextureDirLights, 26 | 27 | StaPipCullTextureColor, 28 | StaPipAsIsTextureColor, 29 | }; 30 | 31 | } // namespace Tyra 32 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/core/stapip_program_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum StaPipProgramType { 16 | StaPipVU1Color, 17 | StaPipVU1DirLights, 18 | StaPipVU1TextureDirLights, 19 | StaPipVU1TextureColor, 20 | }; 21 | 22 | } // namespace Tyra 23 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/pipeline/static/stapip_options.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/3d/pipeline/shared/pipeline_options.hpp" 14 | 15 | namespace Tyra { 16 | 17 | class StaPipOptions : public PipelineOptions { 18 | public: 19 | StaPipOptions() { fullClipChecks = false; } 20 | ~StaPipOptions() {} 21 | 22 | /** 23 | * @brief Experimental! True -> enables "clip against each plane" algorithm. 24 | * Mandatory, default: False. 25 | * 26 | * Full clip checks are slow, but they are 27 | * preventing visual artifacts, which can happen 28 | * for big 3D objects (or objects near camera eyes). 29 | * 30 | * There is other way to prevent these glitches. Just convert your triangles 31 | * to smaller triangles (for example 1 big triangle to 10 smaller). It will 32 | * be way faster than enabling this option... 33 | */ 34 | bool fullClipChecks; 35 | }; 36 | 37 | } // namespace Tyra 38 | -------------------------------------------------------------------------------- /engine/inc/renderer/3d/renderer_3d.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "./pipeline/renderer_3d_pipeline.hpp" 14 | #include "./renderer_3d_utility.hpp" 15 | #include "../core/renderer_core.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class Renderer3D { 20 | public: 21 | Renderer3D(); 22 | ~Renderer3D(); 23 | 24 | Renderer3DUtility utility; 25 | 26 | /** Deinitialize previous pipeline and initialize new pipeline */ 27 | void usePipeline(Renderer3DPipeline* pipeline); 28 | void usePipeline(Renderer3DPipeline& pipeline); 29 | 30 | /** Called by engine */ 31 | void init(RendererCore* core); 32 | 33 | /** Called by engine */ 34 | void onFrameEnd(); 35 | 36 | private: 37 | Renderer3DPipeline* currentPipeline; 38 | void onDestroy(Renderer3DPipeline* pipeline); 39 | }; 40 | 41 | } // namespace Tyra 42 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/2d/sprite/sprite.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "./sprite_mode.hpp" 16 | #include "math/vec2.hpp" 17 | #include "renderer/models/color.hpp" 18 | 19 | namespace Tyra { 20 | 21 | class Sprite { 22 | public: 23 | Sprite(); 24 | ~Sprite(); 25 | 26 | u32 id; 27 | Vec2 position, size, offset; 28 | float scale; 29 | Color color; 30 | SpriteMode mode; 31 | bool flipHorizontal, flipVertical; 32 | 33 | private: 34 | void setDefaultColor(); 35 | }; 36 | 37 | } // namespace Tyra 38 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/2d/sprite/sprite_mode.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum SpriteMode { MODE_STRETCH, MODE_REPEAT }; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/3d/bbox/core_bbox_frustum.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum CoreBBoxFrustum { IN_FRUSTUM, OUTSIDE_FRUSTUM, PARTIALLY_IN_FRUSTUM }; 16 | 17 | } // namespace Tyra 18 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/3d/bbox/render_bbox.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "./core_bbox.hpp" 15 | 16 | namespace Tyra { 17 | 18 | /** Bounding box */ 19 | class RenderBBox : public CoreBBox { 20 | public: 21 | explicit RenderBBox(const Vec4* t_vertices, const u32* faces, 22 | const u32& t_count); 23 | explicit RenderBBox(const Vec4* t_vertices, const u32& t_count); 24 | explicit RenderBBox(const Vec4* t_vertices); 25 | explicit RenderBBox(CoreBBox** t_bboxes, const u32& count); 26 | explicit RenderBBox(const std::vector& t_bboxes, 27 | const u32& startIndex, const u32& stopIndex); 28 | explicit RenderBBox(const RenderBBox& t_bbox, const M4x4& t_matrix); 29 | 30 | CoreBBoxFrustum clipFrustumCheck(const Plane* frustumPlanes, 31 | const M4x4& model) const; 32 | 33 | /** Get new transformed BBox by model matrix */ 34 | RenderBBox getTransformed(const M4x4& t_matrix) const; 35 | }; 36 | 37 | } // namespace Tyra 38 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/3d/camera_info_3d.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/vec4.hpp" 14 | 15 | namespace Tyra { 16 | 17 | class CameraInfo3D { 18 | public: 19 | CameraInfo3D(const Vec4* cameraPosition, const Vec4* cameraLooksAt, 20 | const Vec4* cameraUp = nullptr); 21 | ~CameraInfo3D(); 22 | 23 | const Vec4 *position, *looksAt, *up; 24 | 25 | private: 26 | static Vec4 defaultCameraUp; 27 | }; 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/3d/clipper/planes_clip_vertex.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "math/vec4.hpp" 14 | 15 | namespace Tyra { 16 | 17 | struct PlanesClipVertex { 18 | Vec4 position, normal, st, color; 19 | }; 20 | 21 | struct PlanesClipVertexPtrs { 22 | Vec4 *position, *normal, *st, *color; 23 | }; 24 | 25 | } // namespace Tyra 26 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/gs/renderer_core_gs.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "renderer/renderer_settings.hpp" 14 | #include "./renderer_core_gs_vram.hpp" 15 | #include "../renderer_core_sync.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class RendererCoreGS { 20 | public: 21 | RendererCoreGS(); 22 | ~RendererCoreGS(); 23 | 24 | zbuffer_t zBuffer; 25 | RendererCoreGSVRam vram; 26 | 27 | void init(RendererSettings* settings); 28 | 29 | void flipBuffers(); 30 | 31 | void enableZTests(); 32 | 33 | private: 34 | constexpr static float gsCenter = 4096.0F; 35 | constexpr static float screenCenter = gsCenter / 2.0F; 36 | 37 | RendererSettings* settings; 38 | framebuffer_t frameBuffers[2]; 39 | packet2_t* flipPacket; 40 | packet2_t* zTestPacket; 41 | u8 context; 42 | u8 currentField; 43 | 44 | void allocateBuffers(); 45 | void initDrawingEnvironment(); 46 | void initChannels(); 47 | void updateCurrentField(); 48 | qword_t* setXYOffset(qword_t* q, const int& drawContext, const float& x, 49 | const float& y); 50 | }; 51 | 52 | } // namespace Tyra 53 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/paths/path1/path1.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "debug/debug.hpp" 16 | #include "./vu1_program.hpp" 17 | 18 | namespace Tyra { 19 | 20 | class Path1 { 21 | public: 22 | Path1(); 23 | ~Path1(); 24 | 25 | u32 uploadProgram(VU1Program* program, const u32& address); 26 | 27 | void sendDrawFinishTag(); 28 | 29 | void addDrawFinishTag(packet2_t* packet); 30 | 31 | packet2_t* createProgramsCache(VU1Program** programs, const u32& count, 32 | const u32& address); 33 | 34 | void setDoubleBuffer(const u16& startingAddress, const u16& bufferSize); 35 | 36 | private: 37 | void uploadDrawFinishProgram(); 38 | void prepareDrawFinishPacket(); 39 | 40 | packet2_t* doubleBufferPacket; 41 | packet2_t* drawFinishPacket; 42 | u32 drawFinishAddr; 43 | }; 44 | 45 | } // namespace Tyra 46 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/paths/path1/vu1_program.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace Tyra { 18 | 19 | class VU1Program { 20 | public: 21 | VU1Program(u32* start, u32* end); 22 | ~VU1Program(); 23 | 24 | const u32& getPacketSize() const; 25 | const u32& getProgramSize() const; 26 | const u32& getDestinationAddress() const; 27 | 28 | u32* getStart() const; 29 | u32* getEnd() const; 30 | 31 | virtual std::string getStringName() const = 0; 32 | 33 | void setDestinationAddress(const u32& addr); 34 | 35 | protected: 36 | u32 packetSize, destinationAddress, programSize; 37 | u32 *start, *end; 38 | u32 calculateProgramSize() const; 39 | }; 40 | 41 | } // namespace Tyra 42 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/paths/path3/path3.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include 16 | #include "renderer/core/texture/models/texture.hpp" 17 | #include "renderer/renderer_settings.hpp" 18 | #include "renderer/models/color.hpp" 19 | #include "renderer/core/texture/renderer_core_texture_buffers.hpp" 20 | 21 | namespace Tyra { 22 | 23 | class Path3 { 24 | public: 25 | Path3(); 26 | ~Path3(); 27 | 28 | void init(RendererSettings* settings); 29 | 30 | void sendDrawFinishTag(); 31 | void clearScreen(zbuffer_t* z, const Color& color); 32 | void sendTexture(const Texture* texture, 33 | const RendererCoreTextureBuffers& texBuffers); 34 | 35 | private: 36 | packet2_t* drawFinishPacket; 37 | packet2_t* clearScreenPacket; 38 | packet2_t* texturePacket; 39 | RendererSettings* settings; 40 | }; 41 | 42 | } // namespace Tyra 43 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/texture/models/texture_bpp.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | 15 | enum TextureBpp { 16 | 17 | /** 18 | * @brief 32-bit RGBA - Slowest 19 | */ 20 | bpp32 = 32, 21 | 22 | /** 23 | * @brief 24-bit RGB - Slow 24 | */ 25 | bpp24 = 24, 26 | 27 | /** 28 | * @brief 8-bit palletized (indexed) - Super fast 29 | */ 30 | bpp8 = 8, 31 | 32 | /** 33 | * @brief 4-bit palletized (indexed) - Super, super fast 34 | */ 35 | bpp4 = 4, 36 | }; 37 | 38 | } // namespace Tyra 39 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/texture/models/texture_link.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace Tyra { 16 | struct TextureLink { 17 | /** 18 | * For 3D: MeshMaterial material id. 19 | * For 2D: Sprite id. 20 | */ 21 | u32 id; 22 | }; 23 | } // namespace Tyra 24 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/texture/models/texture_wrap.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | namespace Tyra { 14 | enum TextureWrap { Repeat = 0, Clamp = 1, RegionClamp = 2, RegionRepeat = 3 }; 15 | } 16 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/texture/renderer_core_texture_buffers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | namespace Tyra { 17 | 18 | struct RendererCoreTextureBuffers { 19 | /** Texture id */ 20 | u32 id; 21 | 22 | /** 23 | * Texture data. 24 | * Used in: 4bpp, 8bpp, 24bpp, 32bpp. 25 | */ 26 | texbuffer_t* core; 27 | 28 | /** 29 | * Texture pallete data. 30 | * Used in: 4bpp, 8bpp (otherwise nullptr). 31 | */ 32 | texbuffer_t* clut; 33 | }; 34 | 35 | } // namespace Tyra -------------------------------------------------------------------------------- /engine/inc/renderer/core/texture/renderer_core_texture_sender.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include 16 | #include "./models/texture.hpp" 17 | #include "renderer/core/paths/path3/path3.hpp" 18 | #include "renderer/core/gs/renderer_core_gs.hpp" 19 | #include "./renderer_core_texture_buffers.hpp" 20 | 21 | namespace Tyra { 22 | 23 | class RendererCoreTextureSender { 24 | public: 25 | RendererCoreTextureSender(); 26 | ~RendererCoreTextureSender(); 27 | 28 | void init(Path3* path3, RendererCoreGS* gs); 29 | 30 | RendererCoreTextureBuffers allocate(const Texture* t_texture); 31 | 32 | void deallocate(const RendererCoreTextureBuffers& texBuffers); 33 | 34 | float getSizeInMB(texbuffer_t* texBuffer); 35 | 36 | private: 37 | RendererCoreGS* gs; 38 | Path3* path3; 39 | TextureBpp getBppByPsm(const u32& psm); 40 | texbuffer_t* allocateTextureCore(const Texture* t_texture); 41 | texbuffer_t* allocateTextureClut(const Texture* t_texture); 42 | }; 43 | 44 | } // namespace Tyra 45 | -------------------------------------------------------------------------------- /engine/inc/renderer/core/texture/texture_data.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "renderer/core/texture/models/texture_bpp.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class TextureData { 20 | public: 21 | TextureData(unsigned char* data, const TextureBpp& bpp, 22 | const unsigned char& gsComponents, const int& width, 23 | const int& height); 24 | ~TextureData(); 25 | 26 | int width, height; 27 | u32 psm; 28 | unsigned char* data; 29 | TextureBpp bpp; 30 | unsigned char components; 31 | 32 | void print() const; 33 | void print(const unsigned char* name) const; 34 | void print(const std::string& name) const { print(name.c_str()); } 35 | std::string getPrint(const unsigned char* name = nullptr) const; 36 | 37 | private: 38 | u32 getPsmByBpp(const TextureBpp& bpp); 39 | }; 40 | } // namespace Tyra 41 | -------------------------------------------------------------------------------- /engine/inc/thread/threading.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | namespace Tyra { 17 | 18 | class Threading { 19 | public: 20 | Threading(); 21 | ~Threading(); 22 | 23 | static void sleep(const u32& ms); 24 | static void sleep(const timespec& tv); 25 | 26 | static void switchThread(); 27 | 28 | private: 29 | static timespec tv; 30 | }; 31 | 32 | } // namespace Tyra 33 | -------------------------------------------------------------------------------- /engine/inc/time/timer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | namespace Tyra { 17 | 18 | class Timer { 19 | public: 20 | Timer(); 21 | ~Timer(); 22 | 23 | u32 getTimeDelta(); 24 | inline void prime() { lastTime = *T3_COUNT; } 25 | 26 | private: 27 | u32 lastTime, time, change; 28 | }; 29 | 30 | } // namespace Tyra 31 | -------------------------------------------------------------------------------- /engine/inc/tyra: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "./engine.hpp" 14 | #include "./debug/debug.hpp" 15 | #include "./file/file_utils.hpp" 16 | #include "./loaders/3d/md2_loader/md2_loader.hpp" 17 | #include "./loaders/3d/obj_loader/obj_loader.hpp" 18 | #include "./loaders/texture/png_loader.hpp" 19 | #include "./packet2/packet2_tyra_utils.hpp" 20 | #include "./physics/ray.hpp" 21 | #include "./renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp" 22 | #include "./renderer/3d/pipeline/static/static_pipeline.hpp" 23 | #include "./renderer/3d/pipeline/minecraft/minecraft_pipeline.hpp" 24 | #include "./renderer/3d/mesh/dynamic/dynamic_mesh.hpp" 25 | #include "./renderer/3d/mesh/static/static_mesh.hpp" 26 | #include "./thread/threading.hpp" 27 | #include "./time/timer.hpp" 28 | -------------------------------------------------------------------------------- /engine/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /engine/src/debug/debug.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Wellington Carvalho 9 | */ 10 | 11 | #include "debug/debug.hpp" 12 | 13 | void TyraDebug::writeInLogFile(std::stringstream* ss) { 14 | std::ofstream logFile; 15 | logFile.open(Tyra::FileUtils::fromCwd("log.txt"), 16 | std::ofstream::out | std::ofstream::app); 17 | logFile << ss->str(); 18 | logFile.flush(); 19 | // logFile.close(); 20 | } 21 | -------------------------------------------------------------------------------- /engine/src/engine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | 13 | namespace Tyra { 14 | 15 | Engine::Engine() { initAll(false); } 16 | 17 | Engine::Engine(const EngineOptions& options) { 18 | info.writeLogsToFile = options.writeLogsToFile; 19 | initAll(options.loadUsbDriver); 20 | } 21 | 22 | Engine::~Engine() {} 23 | 24 | void Engine::run(Game* t_game) { 25 | game = t_game; 26 | game->init(); 27 | while (true) { 28 | realLoop(); 29 | } 30 | } 31 | 32 | void Engine::realLoop() { 33 | pad.update(); 34 | game->loop(); 35 | info.update(); 36 | } 37 | 38 | void Engine::initAll(const bool& loadUsbDriver) { 39 | srand(time(nullptr)); 40 | irx.loadAll(loadUsbDriver, info.writeLogsToFile); 41 | renderer.init(); 42 | banner.show(&renderer); 43 | audio.init(); 44 | pad.init(); 45 | } 46 | 47 | } // namespace Tyra 48 | -------------------------------------------------------------------------------- /engine/src/irx/audsrv.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/audsrv.irx 2 | audsrv_irx 3 | -------------------------------------------------------------------------------- /engine/src/irx/bdm.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/bdm.irx 2 | bdm_irx 3 | -------------------------------------------------------------------------------- /engine/src/irx/bdmfs_fatfs.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/bdmfs_fatfs.irx 2 | bdmfs_fatfs_irx 3 | -------------------------------------------------------------------------------- /engine/src/irx/fileXio.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/fileXio.irx 2 | fileXio_irx 3 | -------------------------------------------------------------------------------- /engine/src/irx/iomanX.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/iomanX.irx 2 | iomanX_irx 3 | -------------------------------------------------------------------------------- /engine/src/irx/libsd.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/libsd.irx 2 | libsd_irx 3 | -------------------------------------------------------------------------------- /engine/src/irx/padman.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/padman.irx 2 | padman_irx 3 | -------------------------------------------------------------------------------- /engine/src/irx/sio2man.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/sio2man.irx 2 | sio2man_irx 3 | -------------------------------------------------------------------------------- /engine/src/irx/usbd.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/usbd.irx 2 | usbd_irx 3 | -------------------------------------------------------------------------------- /engine/src/irx/usbmass_bd.irx-em: -------------------------------------------------------------------------------- 1 | $PS2SDK/iop/irx/usbmass_bd.irx 2 | usbmass_bd_irx 3 | -------------------------------------------------------------------------------- /engine/src/loaders/3d/builder/mesh_builder_data.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #include "loaders/3d/builder/mesh_builder_data.hpp" 13 | 14 | namespace Tyra { 15 | 16 | MeshBuilderData::MeshBuilderData() { 17 | loadNormals = false; 18 | loadLightmap = false; 19 | } 20 | 21 | MeshBuilderData::~MeshBuilderData() { 22 | for (auto& material : materials) { 23 | delete material; 24 | } 25 | } 26 | 27 | } // namespace Tyra 28 | -------------------------------------------------------------------------------- /engine/src/loaders/3d/builder/mesh_builder_material_data.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #include "loaders/3d/builder/mesh_builder_material_data.hpp" 13 | 14 | namespace Tyra { 15 | 16 | MeshBuilderMaterialData::MeshBuilderMaterialData() { 17 | ambient.set(128.0F, 128.0F, 128.0F, 128.0F); 18 | } 19 | MeshBuilderMaterialData::~MeshBuilderMaterialData() { 20 | for (auto& frame : frames) { 21 | delete frame; 22 | } 23 | } 24 | 25 | } // namespace Tyra 26 | -------------------------------------------------------------------------------- /engine/src/loaders/3d/builder/mesh_builder_material_frame_data.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #include "loaders/3d/builder/mesh_builder_material_frame_data.hpp" 13 | 14 | namespace Tyra { 15 | 16 | MeshBuilderMaterialFrameData::MeshBuilderMaterialFrameData() { 17 | vertices = nullptr; 18 | textureCoords = nullptr; 19 | normals = nullptr; 20 | colors = nullptr; 21 | } 22 | MeshBuilderMaterialFrameData::~MeshBuilderMaterialFrameData() {} 23 | 24 | } // namespace Tyra 25 | -------------------------------------------------------------------------------- /engine/src/loaders/texture/base/texture_builder_data.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "loaders/texture/builder/texture_builder_data.hpp" 12 | #include 13 | 14 | namespace Tyra { 15 | 16 | TextureBuilderData::TextureBuilderData() { 17 | width = 0; 18 | height = 0; 19 | data = nullptr; 20 | bpp = bpp32; 21 | gsComponents = TEXTURE_COMPONENTS_RGBA; 22 | 23 | clut = nullptr; 24 | clutWidth = 0; 25 | clutHeight = 0; 26 | clutBpp = bpp32; 27 | clutGsComponents = TEXTURE_COMPONENTS_RGBA; 28 | } 29 | 30 | TextureBuilderData::~TextureBuilderData() {} 31 | 32 | } // namespace Tyra 33 | -------------------------------------------------------------------------------- /engine/src/loaders/texture/base/texture_loader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include 12 | #include "debug/debug.hpp" 13 | #include "loaders/texture/base/texture_loader.hpp" 14 | 15 | namespace Tyra { 16 | 17 | u32 TextureLoader::getTextureSize(const u32& width, const u32& height, 18 | const TextureBpp& bpp) { 19 | switch (bpp) { 20 | case bpp32: 21 | return (width * height * 4); 22 | case bpp24: 23 | return (width * height * 3); 24 | case bpp8: 25 | return (width * height); 26 | case bpp4: 27 | return (width * height / 2); 28 | default: 29 | TYRA_TRAP("Unknown texture bpp"); 30 | } 31 | 32 | return -1; 33 | } 34 | 35 | } // namespace Tyra 36 | -------------------------------------------------------------------------------- /engine/src/renderer/2d/renderer_2d.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/2d/renderer_2d.hpp" 12 | 13 | namespace Tyra { 14 | 15 | Renderer2D::Renderer2D() {} 16 | Renderer2D::~Renderer2D() {} 17 | 18 | void Renderer2D::init(RendererCore* t_rendererCore) { core = t_rendererCore; } 19 | 20 | void Renderer2D::render(const Sprite* sprite) { render(*sprite); } 21 | 22 | void Renderer2D::render(const Sprite& sprite) { 23 | auto* texture = core->texture.repository.getBySpriteId(sprite.id); 24 | 25 | TYRA_ASSERT( 26 | texture, "Texture for sprite with id: ", sprite.id, 27 | "Was not found in texture repository! Did you forget to add texture?"); 28 | 29 | auto texBuffers = core->texture.useTexture(texture); 30 | core->texture.updateClutBuffer(texBuffers.clut); 31 | core->renderer2D.render(sprite, texBuffers, texture); 32 | } 33 | 34 | } // namespace Tyra 35 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/mesh/dynamic/dynamic_mesh.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #include 13 | #include "math/m4x4.hpp" 14 | #include "renderer/3d/mesh/dynamic/dynamic_mesh.hpp" 15 | 16 | namespace Tyra { 17 | 18 | DynamicMesh::DynamicMesh(const MeshBuilderData* data) : Mesh(data) { 19 | if (data->materials[0]->frames.size() == 1) { 20 | TYRA_WARN( 21 | "Frames count should be greater than 1 for DynamicMesh! Maybe you " 22 | "should use StaticMesh?"); 23 | } 24 | 25 | for (u32 i = 0; i < data->materials[0]->frames.size(); i++) { 26 | frames.push_back(new MeshFrame(*data, i)); 27 | } 28 | 29 | animation.resetAll(frames); 30 | } 31 | 32 | DynamicMesh::DynamicMesh(const DynamicMesh& mesh) : Mesh(mesh) { 33 | for (u32 i = 0; i < mesh.frames.size(); i++) { 34 | frames.push_back(new MeshFrame(*mesh.frames[i])); 35 | } 36 | 37 | animation.resetAll(frames); 38 | } 39 | 40 | DynamicMesh::~DynamicMesh() { 41 | for (u32 i = 0; i < frames.size(); i++) { 42 | delete frames[i]; 43 | } 44 | } 45 | 46 | } // namespace Tyra 47 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/mesh/static/static_mesh.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #include "renderer/3d/mesh/static/static_mesh.hpp" 13 | 14 | namespace Tyra { 15 | 16 | StaticMesh::StaticMesh(const MeshBuilderData* data) : Mesh(data) { 17 | if (data->materials[0]->frames.size() > 1) 18 | TYRA_WARN("Static meshes should have only one frame, but ", 19 | data->materials[0]->frames.size(), " frames were found"); 20 | 21 | frame = new MeshFrame(*data, 0); 22 | } 23 | 24 | StaticMesh::StaticMesh(const StaticMesh& mesh) : Mesh(mesh) { 25 | frame = new MeshFrame(*mesh.frame); 26 | } 27 | 28 | StaticMesh::~StaticMesh() { delete frame; } 29 | 30 | } // namespace Tyra 31 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/dynamic/core/bag/dynpip_color_bag.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/dynamic/core/bag/dynpip_color_bag.hpp" 12 | 13 | namespace Tyra { 14 | 15 | DynPipColorBag::DynPipColorBag() { single = nullptr; } 16 | 17 | DynPipColorBag::~DynPipColorBag() {} 18 | 19 | } // namespace Tyra 20 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/dynamic/core/bag/dynpip_lighting_bag.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/dynamic/core/bag/dynpip_lighting_bag.hpp" 12 | 13 | namespace Tyra { 14 | 15 | DynPipLightingBag::DynPipLightingBag() { 16 | lightMatrix = nullptr; 17 | normalsFrom = nullptr; 18 | normalsTo = nullptr; 19 | dirLights = nullptr; 20 | } 21 | 22 | DynPipLightingBag::~DynPipLightingBag() {} 23 | 24 | void DynPipLightingBag::freeNormals() { 25 | if (normalsFrom) delete[] normalsFrom; 26 | if (normalsTo) delete[] normalsTo; 27 | } 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/dynamic/core/bag/dynpip_texture_bag.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/dynamic/core/bag/dynpip_texture_bag.hpp" 12 | 13 | namespace Tyra { 14 | 15 | DynPipTextureBag::DynPipTextureBag() { 16 | coordinatesFrom = nullptr; 17 | coordinatesTo = nullptr; 18 | texture = nullptr; 19 | } 20 | 21 | DynPipTextureBag::~DynPipTextureBag() {} 22 | 23 | void DynPipTextureBag::freeCoords() { 24 | if (coordinatesFrom) delete[] coordinatesFrom; 25 | if (coordinatesTo) delete[] coordinatesTo; 26 | } 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/minecraft/data/mcpip_block_data.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/minecraft/data/mcpip_block_data.hpp" 12 | 13 | namespace Tyra { 14 | 15 | McpipBlockData::McpipBlockData() { 16 | vertices = nullptr; 17 | textureCoords = nullptr; 18 | comboData = nullptr; 19 | offset = 0.0F; 20 | count = 0; 21 | } 22 | 23 | McpipBlockData::~McpipBlockData() {} 24 | 25 | } // namespace Tyra 26 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_as_is_vu1_program.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/minecraft/programs/as_is/mcpip_as_is_vu1_program.hpp" 12 | 13 | extern u32 VU1BlocksAsIs_CodeStart __attribute__((section(".vudata"))); 14 | extern u32 VU1BlocksAsIs_CodeEnd __attribute__((section(".vudata"))); 15 | 16 | namespace Tyra { 17 | 18 | McpipAsIsVU1Program::McpipAsIsVU1Program() 19 | : McpipProgram(McpipProgramName::McPipAsIs, &VU1BlocksAsIs_CodeStart, 20 | &VU1BlocksAsIs_CodeEnd) {} 21 | 22 | McpipAsIsVU1Program::~McpipAsIsVU1Program() {} 23 | 24 | std::string McpipAsIsVU1Program::getStringName() const { 25 | return std::string("McPip - As is"); 26 | } 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/minecraft/programs/cull/mcpip_cull_vu1_program.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/minecraft/programs/cull/mcpip_cull_vu1_program.hpp" 12 | 13 | extern u32 VU1BlocksCull_CodeStart __attribute__((section(".vudata"))); 14 | extern u32 VU1BlocksCull_CodeEnd __attribute__((section(".vudata"))); 15 | 16 | namespace Tyra { 17 | 18 | McpipCullVU1Program::McpipCullVU1Program() 19 | : McpipProgram(McpipProgramName::McPipCull, &VU1BlocksCull_CodeStart, 20 | &VU1BlocksCull_CodeEnd) {} 21 | 22 | McpipCullVU1Program::~McpipCullVU1Program() {} 23 | 24 | std::string McpipCullVU1Program::getStringName() const { 25 | return std::string("McPip - Cull"); 26 | } 27 | 28 | } // namespace Tyra 29 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/minecraft/programs/mcpip_program.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/minecraft/programs/mcpip_program.hpp" 12 | 13 | namespace Tyra { 14 | 15 | McpipProgram::McpipProgram(const McpipProgramName& t_name, u32* t_start, 16 | u32* t_end) 17 | : VU1Program(t_start, t_end), name(t_name) {} 18 | 19 | McpipProgram::~McpipProgram() {} 20 | 21 | const McpipProgramName& McpipProgram::getName() const { return name; } 22 | 23 | } // namespace Tyra 24 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/minecraft/programs/mcpip_programs_repository.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/minecraft/programs/mcpip_programs_repository.hpp" 12 | 13 | namespace Tyra { 14 | 15 | McpipProgramsRepository::McpipProgramsRepository() {} 16 | 17 | McpipProgramsRepository::~McpipProgramsRepository() {} 18 | 19 | McpipProgram* McpipProgramsRepository::getProgram( 20 | const McpipProgramName& name) { 21 | switch (name) { 22 | case McpipProgramName::McPipCull: 23 | return &cull; 24 | case McpipProgramName::McPipAsIs: 25 | return &asIs; 26 | 27 | default: 28 | TYRA_TRAP("Unknown VU1 program name"); 29 | return &cull; 30 | } 31 | } 32 | 33 | } // namespace Tyra 34 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/static/core/bag/stapip_color_bag.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/static/core/bag/stapip_color_bag.hpp" 12 | 13 | namespace Tyra { 14 | 15 | StaPipColorBag::StaPipColorBag() { 16 | single = nullptr; 17 | many = nullptr; 18 | } 19 | 20 | StaPipColorBag::~StaPipColorBag() {} 21 | 22 | } // namespace Tyra 23 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.hpp" 12 | 13 | namespace Tyra { 14 | 15 | StaPipLightingBag::StaPipLightingBag() { 16 | lightMatrix = nullptr; 17 | normals = nullptr; 18 | dirLights = nullptr; 19 | } 20 | 21 | StaPipLightingBag::~StaPipLightingBag() {} 22 | 23 | } // namespace Tyra 24 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/pipeline/static/core/bag/stapip_texture_bag.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/3d/pipeline/static/core/bag/stapip_texture_bag.hpp" 12 | 13 | namespace Tyra { 14 | 15 | StaPipTextureBag::StaPipTextureBag() { 16 | coordinates = nullptr; 17 | texture = nullptr; 18 | } 19 | 20 | StaPipTextureBag::~StaPipTextureBag() {} 21 | 22 | } // namespace Tyra 23 | -------------------------------------------------------------------------------- /engine/src/renderer/3d/renderer_3d.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | # _____ ____ ___ 4 | # | \/ ____| |___| 5 | # | | | \ | | 6 | #----------------------------------------------------------------------- 7 | # Copyright 2022, tyra - https://github.com/h4570/tyra 8 | # Licensed under Apache License 2.0 9 | # Sandro Sobczyński 10 | */ 11 | 12 | #include "renderer/3d/renderer_3d.hpp" 13 | 14 | namespace Tyra { 15 | 16 | Renderer3D::Renderer3D() { currentPipeline = nullptr; } 17 | 18 | Renderer3D::~Renderer3D() {} 19 | 20 | void Renderer3D::init(RendererCore* core) { utility.init(core); } 21 | 22 | void Renderer3D::onFrameEnd() { 23 | if (currentPipeline != nullptr) { 24 | currentPipeline->onFrameEnd(); 25 | } 26 | } 27 | 28 | void Renderer3D::usePipeline(Renderer3DPipeline& pipeline) { 29 | usePipeline(&pipeline); 30 | } 31 | 32 | void Renderer3D::usePipeline(Renderer3DPipeline* pipeline) { 33 | if (currentPipeline != pipeline) { 34 | if (currentPipeline) currentPipeline->onUseEnd(); 35 | currentPipeline = pipeline; 36 | currentPipeline->onDestroy = 37 | std::bind(&Renderer3D::onDestroy, this, std::placeholders::_1); 38 | currentPipeline->onUse(); 39 | } 40 | } 41 | 42 | void Renderer3D::onDestroy(Renderer3DPipeline* pipeline) { 43 | if (currentPipeline == pipeline) { 44 | currentPipeline->onUseEnd(); 45 | currentPipeline = nullptr; 46 | } 47 | } 48 | 49 | } // namespace Tyra 50 | -------------------------------------------------------------------------------- /engine/src/renderer/core/2d/sprite/sprite.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/core/2d/sprite/sprite.hpp" 12 | 13 | namespace Tyra { 14 | 15 | Sprite::Sprite() { 16 | id = rand() % 1000000; 17 | flipHorizontal = false; 18 | flipVertical = false; 19 | size.set(32.0F, 32.0F); 20 | position.set(100.0F, 100.0F); 21 | offset.set(0.0F, 0.0F); 22 | scale = 1.0F; 23 | mode = MODE_REPEAT; 24 | setDefaultColor(); 25 | } 26 | 27 | Sprite::~Sprite() {} 28 | 29 | // ---- 30 | // Methods 31 | // ---- 32 | 33 | void Sprite::setDefaultColor() { 34 | color.r = 128; 35 | color.g = 128; 36 | color.b = 128; 37 | color.a = 128; 38 | } 39 | 40 | } // namespace Tyra -------------------------------------------------------------------------------- /engine/src/renderer/core/3d/camera_info_3d.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/core/3d/camera_info_3d.hpp" 12 | 13 | namespace Tyra { 14 | 15 | Vec4 CameraInfo3D::defaultCameraUp = Vec4(0.0F, 1.0F, 0.0F); 16 | 17 | CameraInfo3D::CameraInfo3D(const Vec4* t_cameraPosition, 18 | const Vec4* t_cameraLooksAt, 19 | const Vec4* t_cameraUp) { 20 | position = t_cameraPosition; 21 | looksAt = t_cameraLooksAt; 22 | 23 | if (t_cameraUp == nullptr) { 24 | up = &defaultCameraUp; 25 | } else { 26 | up = t_cameraUp; 27 | } 28 | } 29 | 30 | CameraInfo3D::~CameraInfo3D() {} 31 | 32 | } // namespace Tyra 33 | -------------------------------------------------------------------------------- /engine/src/renderer/core/paths/path1/draw_finish.vclpp: -------------------------------------------------------------------------------- 1 | 2 | ; _____ ____ ___ 3 | ; | \/ ____| |___| 4 | ; | | | \ | | 5 | ;--------------------------------------------------------------- 6 | ; Copyright 2022, tyra - https://github.com/h4570/tyra 7 | ; Licensed under Apache License 2.0 8 | ; Sandro Sobczyński 9 | ; 10 | ;--------------------------------------------------------------- 11 | ; Needed for synchronization with draw_wait_finish() 12 | ;--------------------------------------------------------------- 13 | 14 | .syntax new 15 | .name VU1DrawFinish 16 | .vu 17 | .init_vf_all 18 | .init_vi_all 19 | 20 | --enter 21 | --endenter 22 | 23 | #vuprog VU1DrawFinish 24 | xtop buffer 25 | iaddiu kickAddress, buffer, 10 26 | xgkick kickAddress 27 | #endvuprog 28 | 29 | --exit 30 | --endexit -------------------------------------------------------------------------------- /engine/src/renderer/core/paths/path1/vu1_program.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/core/paths/path1/vu1_program.hpp" 12 | 13 | namespace Tyra { 14 | 15 | VU1Program::VU1Program(u32* t_start, u32* t_end) : start(t_start), end(t_end) { 16 | packetSize = packet2_utils_get_packet_size_for_program(start, end); 17 | programSize = calculateProgramSize(); 18 | } 19 | 20 | VU1Program::~VU1Program() {} 21 | 22 | const u32& VU1Program::getPacketSize() const { return packetSize; } 23 | const u32& VU1Program::getProgramSize() const { return programSize; } 24 | const u32& VU1Program::getDestinationAddress() const { 25 | return destinationAddress; 26 | } 27 | void VU1Program::setDestinationAddress(const u32& addr) { 28 | destinationAddress = addr; 29 | } 30 | u32* VU1Program::getStart() const { return start; } 31 | u32* VU1Program::getEnd() const { return end; } 32 | 33 | u32 VU1Program::calculateProgramSize() const { 34 | u32 count = (getEnd() - getStart()) / 2; 35 | if (count & 1) count++; 36 | 37 | return count; 38 | } 39 | 40 | } // namespace Tyra 41 | -------------------------------------------------------------------------------- /engine/src/renderer/core/renderer_core_sync.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/core/renderer_core_sync.hpp" 12 | 13 | namespace Tyra { 14 | 15 | RendererCoreSync::RendererCoreSync() {} 16 | RendererCoreSync::~RendererCoreSync() {} 17 | 18 | void RendererCoreSync::init(Path3* t_path3, Path1* t_path1) { 19 | path3 = t_path3; 20 | path1 = t_path1; 21 | } 22 | 23 | void RendererCoreSync::align3D() { 24 | clear(); 25 | sendPath1Req(); 26 | waitAndClear(); 27 | } 28 | 29 | void RendererCoreSync::align2D() { 30 | clear(); 31 | sendPath3Req(); 32 | waitAndClear(); 33 | } 34 | 35 | void RendererCoreSync::sendPath1Req() { path1->sendDrawFinishTag(); } 36 | 37 | void RendererCoreSync::sendPath3Req() { path3->sendDrawFinishTag(); } 38 | 39 | void RendererCoreSync::addPath1Req(packet2_t* packet) { 40 | path1->addDrawFinishTag(packet); 41 | } 42 | 43 | u8 RendererCoreSync::check() { return *GS_REG_CSR & 2; } 44 | 45 | void RendererCoreSync::clear() { *GS_REG_CSR |= 2; } 46 | 47 | void RendererCoreSync::waitAndClear() { 48 | while (!check()) { 49 | } 50 | clear(); 51 | } 52 | 53 | } // namespace Tyra 54 | -------------------------------------------------------------------------------- /engine/src/renderer/renderer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "renderer/renderer.hpp" 12 | 13 | namespace Tyra { 14 | 15 | Renderer::Renderer() {} 16 | Renderer::~Renderer() {} 17 | 18 | void Renderer::init() { 19 | core.init(); 20 | renderer2D.init(&core); 21 | renderer3D.init(&core); 22 | } 23 | 24 | void Renderer::beginFrame() { core.beginFrame(); } 25 | 26 | void Renderer::beginFrame(const CameraInfo3D& cameraInfo) { 27 | core.beginFrame(cameraInfo); 28 | } 29 | 30 | void Renderer::endFrame() { 31 | core.endFrame(); 32 | renderer3D.onFrameEnd(); 33 | } 34 | 35 | } // namespace Tyra 36 | -------------------------------------------------------------------------------- /engine/src/thread/threading.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022-2022, tyra - https://github.com/h4570/tyrav2 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "thread/threading.hpp" 12 | #include 13 | 14 | namespace Tyra { 15 | 16 | timespec Threading::tv = {0, 0}; 17 | 18 | void Threading::sleep(const u32& ms) { 19 | tv.tv_sec = ms / 1000; 20 | tv.tv_nsec = (ms % 1000) * 1000000; 21 | nanosleep(&tv, nullptr); 22 | } 23 | 24 | void Threading::sleep(const timespec& t_tv) { nanosleep(&t_tv, nullptr); } 25 | 26 | void Threading::switchThread() { 27 | tv.tv_sec = 0; 28 | tv.tv_nsec = 500000; // 1/2ms 29 | nanosleep(&tv, nullptr); 30 | } 31 | 32 | } // Namespace Tyra -------------------------------------------------------------------------------- /engine/src/time/timer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "time/timer.hpp" 12 | 13 | namespace Tyra { 14 | 15 | Timer::Timer() { prime(); } 16 | 17 | Timer::~Timer() {} 18 | 19 | u32 Timer::getTimeDelta() { 20 | time = *T3_COUNT; 21 | 22 | if (time < lastTime) // The counter has wrapped 23 | change = time + (65536 - lastTime); 24 | else 25 | change = time - lastTime; 26 | return change; 27 | } 28 | 29 | } // namespace Tyra 30 | -------------------------------------------------------------------------------- /template/.clang-format: -------------------------------------------------------------------------------- 1 | # Use the Google style in this project. 2 | BasedOnStyle: Google 3 | 4 | # Some folks prefer to write "int& foo" while others prefer "int &foo". The 5 | # Google Style Guide only asks for consistency within a project, we chose 6 | # "int& foo" for this project: 7 | DerivePointerAlignment: false 8 | PointerAlignment: Left 9 | 10 | SortIncludes: false 11 | 12 | IncludeBlocks: Merge 13 | IncludeCategories: 14 | # Matches common headers first, but sorts them after project includes 15 | - Regex: '^\"google/cloud/internal/disable_deprecation_warnings.inc\"$' 16 | Priority: -1 17 | - Regex: '^\"google/cloud/(internal/|grpc_utils/|testing_util/|[^/]+\.h)' 18 | Priority: 1000 19 | - Regex: '^\"google/cloud/' # project includes should sort first 20 | Priority: 500 21 | - Regex: '^\"' 22 | Priority: 1500 23 | - Regex: '^' 30 | Priority: 5000 31 | 32 | # Format raw string literals with a `pb` or `proto` tag as proto. 33 | RawStringFormats: 34 | - Language: TextProto 35 | Delimiters: 36 | - 'pb' 37 | - 'proto' 38 | BasedOnStyle: Google 39 | 40 | CommentPragmas: '(@copydoc)' -------------------------------------------------------------------------------- /template/.dockerignore: -------------------------------------------------------------------------------- 1 | *.elf 2 | .git/ 3 | .vscode/ 4 | docs/ 5 | tools/ -------------------------------------------------------------------------------- /template/.gitattributes: -------------------------------------------------------------------------------- 1 | # Ignore all differences in line endings 2 | * -crlf -------------------------------------------------------------------------------- /template/.gitignore: -------------------------------------------------------------------------------- 1 | # --- 2 | 3 | # Prerequisites 4 | *.d 5 | 6 | # Compiled Object files 7 | *.slo 8 | *.lo 9 | *.o 10 | *.vsm 11 | 12 | # Precompiled Headers 13 | *.gch 14 | *.pch 15 | 16 | # Compiled Dynamic libraries 17 | *.so 18 | *.dylib 19 | *.dll 20 | 21 | # Compiled Static libraries 22 | *.lai 23 | *.la 24 | *.a 25 | *.lib 26 | 27 | # Executables 28 | *.exe 29 | *.out 30 | *.app 31 | *.erl 32 | *.elf 33 | -------------------------------------------------------------------------------- /template/.vscode/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | 3 | # Configuration files 4 | /c_cpp_properties.json 5 | /tasks.json 6 | /settings.json 7 | -------------------------------------------------------------------------------- /template/.vscode/configurations/windows-docker/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "buildDirectory": "./", 3 | "C_Cpp.default.intelliSenseMode": "gcc-x86", 4 | "files.associations": { 5 | "*.vcl": "asm-collection", 6 | "*.i": "asm-collection", 7 | "*.vsm": "asm-collection", 8 | "*.vclpp": "asm-collection", 9 | "*.hpp": "cpp", 10 | "*.cpp": "cpp", 11 | "*.h": "c", 12 | "*.c": "c" 13 | } 14 | } -------------------------------------------------------------------------------- /template/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-vscode.cpptools-extension-pack", 4 | "ryzngard.vscode-header-source", 5 | "maziac.asm-code-lens", 6 | "dmnsgn.vscode-wavefront", 7 | "spmeesseman.vscode-taskexplorer" 8 | ] 9 | } -------------------------------------------------------------------------------- /template/Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1 2 | FROM h4570/tyra 3 | 4 | RUN apt-get update 5 | RUN apt-get install git -y 6 | 7 | WORKDIR /src 8 | CMD ["/bin/bash"] -------------------------------------------------------------------------------- /template/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := racer.elf 2 | ENGINEDIR := /tyra/engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := -ltyra 20 | LIBDIRS := -L$(ENGINEDIR)/bin 21 | INC := -I$(INCDIR) -I$(ENGINEDIR)/inc 22 | INCDEP := -I$(INCDIR) -I$(ENGINEDIR)/inc 23 | 24 | include /tyra/Makefile.base 25 | 26 | clean-engine: 27 | cd $(ENGINEDIR) && $(MAKE) cleaner 28 | 29 | build-engine: 30 | cd $(ENGINEDIR) && $(MAKE) 31 | 32 | build-release-engine: 33 | cd $(ENGINEDIR) && $(MAKE) release -------------------------------------------------------------------------------- /template/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /template/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | volumes: 3 | tyra-game-volume: 4 | services: 5 | compiler: 6 | environment: 7 | TERM: xterm-256color 8 | network_mode: host 9 | build: 10 | context: ./ 11 | dockerfile: Dockerfile 12 | tty: true 13 | container_name: tyra-game-compiler 14 | volumes: 15 | - tyra-game-volume:/src 16 | - ./:/host 17 | -------------------------------------------------------------------------------- /template/inc/racer_game.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Racer { 6 | 7 | class RacerGame : public Tyra::Game { 8 | public: 9 | RacerGame(Tyra::Engine* engine); 10 | ~RacerGame(); 11 | 12 | void init(); 13 | void loop(); 14 | 15 | private: 16 | Tyra::Engine* engine; 17 | }; 18 | 19 | } // namespace Racer 20 | -------------------------------------------------------------------------------- /template/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /template/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /template/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot './windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /template/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "racer_game.hpp" 3 | 4 | int main() { 5 | Tyra::Engine engine; 6 | Racer::RacerGame game(&engine); 7 | engine.run(&game); 8 | SleepThread(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /template/src/racer_game.cpp: -------------------------------------------------------------------------------- 1 | #include "racer_game.hpp" 2 | 3 | namespace Racer { 4 | 5 | using namespace Tyra; 6 | 7 | RacerGame::RacerGame(Engine* t_engine) { engine = t_engine; } 8 | RacerGame::~RacerGame() {} 9 | 10 | void RacerGame::init() { TYRA_LOG("Hello!"); } 11 | 12 | void RacerGame::loop() { TYRA_LOG("Loop!"); } 13 | 14 | } // namespace Racer 15 | -------------------------------------------------------------------------------- /tutorials/01-hello/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_01.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/01-hello/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/01-hello/inc/tutorial_01.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | /** We can include all of Tyra classes via this single line: */ 14 | #include 15 | 16 | namespace Tyra { 17 | 18 | /** Tutorial01 is a name of our game class */ 19 | class Tutorial01 : public Game { 20 | public: 21 | Tutorial01(Engine* engine); 22 | ~Tutorial01(); 23 | 24 | /** 25 | * This function will be called once, 26 | * immediatly after initializing Tyra features 27 | */ 28 | void init(); 29 | 30 | /** 31 | * This function will be called every frame 32 | */ 33 | void loop(); 34 | 35 | private: 36 | Engine* engine; 37 | }; 38 | 39 | } // namespace Tyra 40 | -------------------------------------------------------------------------------- /tutorials/01-hello/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/01-hello/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/01-hello/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/01-hello/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_01.hpp" 13 | 14 | /** 15 | * Hello, thank you for choosing Tyra engine! 16 | * 17 | * In this tutorial we will learn how to: 18 | * - Initialize engine and game class 19 | * - Use debug functions 20 | * - Print "Hello world" to the screen 21 | */ 22 | 23 | int main() { 24 | /** 25 | * This is a class which contains 26 | * all features of Tyra. 27 | */ 28 | Tyra::Engine engine; 29 | 30 | /** 31 | * This is a class with our game code. 32 | */ 33 | Tyra::Tutorial01 game(&engine); 34 | 35 | /** 36 | * We need to insert our game class into engine. 37 | */ 38 | engine.run(&game); 39 | 40 | /** Continuation in file tutorial_01.hpp */ 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /tutorials/02-sprite/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_02.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/02-sprite/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/02-sprite/bin/tyra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h4570/tyra/b7bc5f2f0aafd5048c9cbf6dc497ef10f8ac2b28/tutorials/02-sprite/bin/tyra.png -------------------------------------------------------------------------------- /tutorials/02-sprite/inc/tutorial_02.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace Tyra { 16 | 17 | class Tutorial02 : public Game { 18 | public: 19 | Tutorial02(Engine* engine); 20 | ~Tutorial02(); 21 | 22 | void init(); 23 | void loop(); 24 | 25 | private: 26 | void loadTexture(); 27 | void loadSprite(); 28 | 29 | Engine* engine; 30 | 31 | Sprite sprite; 32 | }; 33 | 34 | } // namespace Tyra 35 | -------------------------------------------------------------------------------- /tutorials/02-sprite/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/02-sprite/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/02-sprite/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/02-sprite/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_02.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn how to: 16 | * - Load png file and create texture from it 17 | * - Create sprite class 18 | * - Clear screen and render sprite 19 | */ 20 | 21 | int main() { 22 | Tyra::Engine engine; 23 | Tyra::Tutorial02 game(&engine); 24 | engine.run(&game); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tutorials/03-minecraft/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_03.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/03-minecraft/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/03-minecraft/inc/tutorial_block.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace Tyra { 16 | 17 | class TutorialBlock { 18 | public: 19 | TutorialBlock(); 20 | TutorialBlock(const TutorialBlock& v); 21 | ~TutorialBlock(); 22 | 23 | void updateModelMatrix(); 24 | 25 | M4x4 translation, rotation, scale; 26 | 27 | /** Result matrix with translation, rotation and scale */ 28 | M4x4 model; 29 | 30 | /** Color */ 31 | Color color; 32 | 33 | /** Texture atlas offset */ 34 | Vec4 atlasOffset; 35 | 36 | McpipBlock renderData; 37 | 38 | private: 39 | void setRenderData(); 40 | }; 41 | 42 | } // namespace Tyra 43 | -------------------------------------------------------------------------------- /tutorials/03-minecraft/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/03-minecraft/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/03-minecraft/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/03-minecraft/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_03.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn: 16 | * - What are the VU1 pipelines 17 | * - How to create a 3D camera 18 | * - What is the translation, rotation scale and model matrix 19 | * - How to render 3D minecraft cubes 20 | */ 21 | 22 | int main() { 23 | Tyra::Engine engine; 24 | Tyra::Tutorial03 game(&engine); 25 | engine.run(&game); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /tutorials/03-minecraft/src/tutorial_block.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include 12 | #include "tutorial_block.hpp" 13 | 14 | namespace Tyra { 15 | 16 | TutorialBlock::TutorialBlock() { 17 | /** Set identity value for matrices (instead of random numbers) */ 18 | translation = M4x4::Identity; 19 | rotation = M4x4::Identity; 20 | scale = M4x4::Identity; 21 | 22 | setRenderData(); 23 | } 24 | 25 | /** Copy constructor */ 26 | TutorialBlock::TutorialBlock(const TutorialBlock& v) { 27 | translation = v.translation; 28 | rotation = v.rotation; 29 | scale = v.scale; 30 | model = v.model; 31 | color = v.color; 32 | atlasOffset = v.atlasOffset; 33 | 34 | setRenderData(); 35 | } 36 | 37 | TutorialBlock::~TutorialBlock() {} 38 | 39 | /** Fill block's render data object */ 40 | void TutorialBlock::setRenderData() { 41 | renderData.color = &color; 42 | renderData.model = &model; 43 | renderData.textureOffset = &atlasOffset; 44 | } 45 | 46 | void TutorialBlock::updateModelMatrix() { 47 | model = translation * rotation * scale; 48 | } 49 | 50 | } // namespace Tyra 51 | -------------------------------------------------------------------------------- /tutorials/04-de_dust2/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_04.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/04-de_dust2/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/04-de_dust2/inc/camera.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace Tyra { 16 | 17 | class Camera { 18 | public: 19 | Camera(Pad* pad); 20 | ~Camera(); 21 | 22 | Vec4 lookAt; 23 | Vec4 position; 24 | 25 | /** 26 | * Result variable of unit circle calculation 27 | * This is needed for rotation about the camera lookAt 28 | * https://www.geogebra.org/m/cNEtsbvC 29 | */ 30 | Vec4 unitCircle; 31 | 32 | CameraInfo3D getCameraInfo() { return CameraInfo3D(&position, &lookAt); } 33 | 34 | void update(); 35 | 36 | private: 37 | void updatePosition(); 38 | void updateLookAt(); 39 | 40 | Pad* pad; 41 | float circleRotation, circleLength, speed, lookAtHeight; 42 | }; 43 | 44 | } // namespace Tyra 45 | -------------------------------------------------------------------------------- /tutorials/04-de_dust2/inc/tutorial_04.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include "./camera.hpp" 16 | 17 | namespace Tyra { 18 | 19 | class Tutorial04 : public Game { 20 | public: 21 | Tutorial04(Engine* engine); 22 | ~Tutorial04(); 23 | 24 | void init(); 25 | void loop(); 26 | 27 | private: 28 | void loadMesh(); 29 | 30 | Engine* engine; 31 | 32 | Camera camera; 33 | 34 | /** 3D pipeline used for rendering static meshes */ 35 | StaticPipeline stapip; 36 | 37 | /** Options for static pipeline */ 38 | StaPipOptions renderOptions; 39 | 40 | /** Mesh with de_dust2 */ 41 | std::unique_ptr mesh; 42 | }; 43 | 44 | } // namespace Tyra 45 | -------------------------------------------------------------------------------- /tutorials/04-de_dust2/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/04-de_dust2/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/04-de_dust2/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/04-de_dust2/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_04.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn: 16 | * - How to get pad input and move the camera 17 | * - What is static pipeline and how to use it 18 | * - What is mesh (StaticMesh) and how to load it from .obj file 19 | */ 20 | 21 | int main() { 22 | Tyra::Engine engine; 23 | Tyra::Tutorial04 game(&engine); 24 | engine.run(&game); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tutorials/05-animation/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_05.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/05-animation/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/05-animation/inc/tutorial_05.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace Tyra { 16 | 17 | class Tutorial05 : public Game { 18 | public: 19 | Tutorial05(Engine* engine); 20 | ~Tutorial05(); 21 | 22 | void init(); 23 | void loop(); 24 | 25 | private: 26 | void loadZombieMesh(); 27 | void loadWarriorMesh(); 28 | void warriorAnimationCallback(const AnimationSequenceCallback& callback); 29 | 30 | Engine* engine; 31 | 32 | Vec4 cameraPosition, cameraLookAt; 33 | 34 | std::unique_ptr warriorMesh; 35 | std::unique_ptr zombieMesh; 36 | DynamicPipeline dynpip; 37 | DynPipOptions renderOptions; 38 | }; 39 | 40 | } // namespace Tyra 41 | -------------------------------------------------------------------------------- /tutorials/05-animation/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/05-animation/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/05-animation/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/05-animation/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_05.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn: 16 | * - What is a DynamicMesh and DynamicPipeline 17 | * - How to load animated model from .obj and .md2 format 18 | * - How to arrange animation keyframes 19 | */ 20 | 21 | int main() { 22 | Tyra::Engine engine; 23 | Tyra::Tutorial05 game(&engine); 24 | engine.run(&game); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tutorials/06-audio/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_06.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/06-audio/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/06-audio/inc/tutorial_06.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace Tyra { 16 | 17 | class Tutorial06 : public Game { 18 | public: 19 | Tutorial06(Engine* engine); 20 | ~Tutorial06(); 21 | 22 | void init(); 23 | void loop(); 24 | 25 | private: 26 | Engine* engine; 27 | 28 | audsrv_adpcm_t* sample; 29 | }; 30 | 31 | } // namespace Tyra 32 | -------------------------------------------------------------------------------- /tutorials/06-audio/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/06-audio/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/06-audio/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/06-audio/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_06.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn: 16 | * - How to play background music 17 | * - How to play sound effects (ADPCM samples) 18 | */ 19 | 20 | int main() { 21 | Tyra::Engine engine; 22 | Tyra::Tutorial06 game(&engine); 23 | engine.run(&game); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tutorials/07-lighting/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_07.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/07-lighting/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/07-lighting/inc/tutorial_07.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace Tyra { 16 | 17 | class Tutorial07 : public Game { 18 | public: 19 | Tutorial07(Engine* engine); 20 | ~Tutorial07(); 21 | 22 | void init(); 23 | void loop(); 24 | 25 | private: 26 | void loadMeshWithLightmap(); 27 | void setDirectionalLightsOptions(); 28 | void setLightmap(MeshBuilderData* data); 29 | void switchBetweenLightmapAndDirectional(); 30 | 31 | int counter, switcher; 32 | 33 | Engine* engine; 34 | 35 | Vec4 cameraPosition, cameraLookAt; 36 | 37 | StaticPipeline stapip; 38 | StaPipOptions renderOptions; 39 | std::unique_ptr mesh; 40 | 41 | PipelineLightingOptions renderLightingOptions; 42 | Color directionalAmbientColor; 43 | std::array directionalColors; 44 | std::array directionalDirections; 45 | }; 46 | 47 | } // namespace Tyra 48 | -------------------------------------------------------------------------------- /tutorials/07-lighting/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/07-lighting/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/07-lighting/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/07-lighting/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_07.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn: 16 | * - How to add directional lights to mesh 17 | * - How to add lightmap to mesh 18 | */ 19 | 20 | int main() { 21 | Tyra::Engine engine; 22 | Tyra::Tutorial07 game(&engine); 23 | engine.run(&game); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tutorials/08-skybox-debug/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_08.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/08-skybox-debug/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/08-skybox-debug/inc/tutorial_08.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace Tyra { 16 | 17 | class Tutorial08 : public Game { 18 | public: 19 | Tutorial08(Engine* engine); 20 | ~Tutorial08(); 21 | 22 | void init(); 23 | void loop(); 24 | 25 | private: 26 | void loadCupMesh(); 27 | void loadSkyboxMesh(); 28 | 29 | Vec4 cameraPosition; 30 | Vec4 cameraLookAt; 31 | 32 | Engine* engine; 33 | u8 fpsCounter; 34 | 35 | StaticPipeline stapip; 36 | StaPipOptions skyboxRenderOptions; 37 | StaPipOptions cupRenderOptions; 38 | std::unique_ptr skyboxMesh; 39 | std::unique_ptr cupMesh; 40 | }; 41 | 42 | } // namespace Tyra 43 | -------------------------------------------------------------------------------- /tutorials/08-skybox-debug/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/08-skybox-debug/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/08-skybox-debug/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/08-skybox-debug/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_08.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn: 16 | * - How to render skybox and what is "ALLPASS" rendering method 17 | * - How to render debug lines and bboxes 18 | * - How to get available RAM and FPS count 19 | */ 20 | 21 | int main() { 22 | Tyra::Engine engine; 23 | Tyra::Tutorial08 game(&engine); 24 | engine.run(&game); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tutorials/09-manual-mode/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_09.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/09-manual-mode/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/09-manual-mode/inc/tutorial_09.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | namespace Tyra { 17 | 18 | class Tutorial09 : public Game { 19 | public: 20 | Tutorial09(Engine* engine); 21 | ~Tutorial09(); 22 | 23 | void init(); 24 | void loop(); 25 | 26 | private: 27 | void setDrawData(); 28 | void loadBags(); 29 | 30 | Engine* engine; 31 | 32 | StaticPipeline stapip; 33 | 34 | Vec4 cameraPosition, cameraLookAt; 35 | M4x4 translation, rotation, scale, model; 36 | 37 | std::array vertices; 38 | std::array colors; 39 | 40 | std::unique_ptr bag; 41 | std::unique_ptr infoBag; 42 | std::unique_ptr colorBag; 43 | }; 44 | 45 | } // namespace Tyra 46 | -------------------------------------------------------------------------------- /tutorials/09-manual-mode/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/09-manual-mode/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/09-manual-mode/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/09-manual-mode/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Sandro Sobczyński 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_09.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn: 16 | * - What is StaticPipeline/DynamicPipeline core class 17 | * - How to render data manually (without Mesh class) 18 | * - What are the "3D bags" 19 | */ 20 | 21 | int main() { 22 | Tyra::Engine engine; 23 | Tyra::Tutorial09 game(&engine); 24 | engine.run(&game); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tutorials/10-sprite-sheet/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_10.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/10-sprite-sheet/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/10-sprite-sheet/inc/font_sprite.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022-2023, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Guido Diego Quispe Robles 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #define FONT_CHAR_SIZE 96 16 | 17 | namespace Tyra { 18 | 19 | class Font { 20 | public: 21 | Font(); 22 | void load(TextureRepository& repository, Renderer2D* renderer); 23 | void free(TextureRepository& repository); 24 | void drawText(const char* text, const int& x, const int& y, Color color); 25 | void drawText(const std::string& text, const int& x, const int& y, 26 | Color color); 27 | 28 | private: 29 | const static int chars[FONT_CHAR_SIZE]; 30 | const static int charWidths[FONT_CHAR_SIZE]; 31 | 32 | Renderer2D* renderer2D; 33 | Sprite allFont; 34 | std::array font; 35 | }; 36 | 37 | } // namespace Tyra -------------------------------------------------------------------------------- /tutorials/10-sprite-sheet/inc/tutorial_10.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022-2023, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Guido Diego Quispe Robles 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "font_sprite.hpp" 15 | 16 | namespace Tyra { 17 | 18 | class Tutorial10 : public Game { 19 | public: 20 | explicit Tutorial10(Engine* engine); 21 | ~Tutorial10(); 22 | 23 | void init(); 24 | void loop(); 25 | 26 | private: 27 | void loadTexture(); 28 | void loadSprite(); 29 | void handlePad(); 30 | 31 | int padTimer; 32 | Engine* engine; 33 | Pad* pad; 34 | Font font; 35 | 36 | Sprite sprite; 37 | Sprite spriteFlip; 38 | Sprite spriteScale; 39 | Sprite spriteStretch; 40 | std::string strFilter; 41 | 42 | PipelineTextureMappingType textureFilter; 43 | }; 44 | 45 | } // namespace Tyra 46 | -------------------------------------------------------------------------------- /tutorials/10-sprite-sheet/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/10-sprite-sheet/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/10-sprite-sheet/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/10-sprite-sheet/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2022-2023, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Guido Diego Quispe Robles 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_10.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn: 16 | * - How works the offset of the sprite 17 | * - How works the texture mapping 18 | * - How to write text (font) 19 | */ 20 | 21 | int main() { 22 | Tyra::Engine engine; 23 | Tyra::Tutorial10 game(&engine); 24 | engine.run(&game); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tutorials/11-texture-region-repeat/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := tutorial_11.elf 2 | ENGINEDIR := ../../engine 3 | 4 | #The Directories, Source, Includes, Objects, Binary and Resources 5 | SRCDIR := src 6 | INCDIR := inc 7 | BUILDDIR := obj 8 | TARGETDIR := bin 9 | RESDIR := res 10 | SRCEXT := cpp 11 | VSMEXT := vsm 12 | VCLEXT := vcl 13 | VCLPPEXT := vclpp 14 | DEPEXT := d 15 | OBJEXT := o 16 | 17 | #Flags, Libraries and Includes 18 | CFLAGS := 19 | LIB := 20 | LIBDIRS := 21 | INC := -I$(INCDIR) 22 | INCDEP := -I$(INCDIR) 23 | 24 | include ../Makefile.tutorials-base -------------------------------------------------------------------------------- /tutorials/11-texture-region-repeat/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/11-texture-region-repeat/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/11-texture-region-repeat/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /tutorials/11-texture-region-repeat/run.ps1: -------------------------------------------------------------------------------- 1 | $ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' 2 | . $ConfigFile 3 | 4 | RunPCSX2 5 | -------------------------------------------------------------------------------- /tutorials/11-texture-region-repeat/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ____ ___ 3 | # | \/ ____| |___| 4 | # | | | \ | | 5 | #----------------------------------------------------------------------- 6 | # Copyright 2024, tyra - https://github.com/h4570/tyra 7 | # Licensed under Apache License 2.0 8 | # Wellington Carvalho 9 | */ 10 | 11 | #include "engine.hpp" 12 | #include "tutorial_11.hpp" 13 | 14 | /** 15 | * In this tutorial we will learn: 16 | * - How to use texture in repeate mode of GS 17 | */ 18 | 19 | int main() { 20 | Tyra::Engine engine; 21 | Tyra::Tutorial11 game(&engine); 22 | engine.run(&game); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /tutorials/Makefile.tutorials-base: -------------------------------------------------------------------------------- 1 | LIB += -ltyra 2 | LIBDIRS += -L$(ENGINEDIR)/bin 3 | INC += -I$(ENGINEDIR)/inc 4 | INCDEP += -I$(ENGINEDIR)/inc 5 | 6 | include ../../Makefile.base 7 | 8 | clean-engine: 9 | cd $(ENGINEDIR) && $(MAKE) cleaner 10 | 11 | build-engine: 12 | cd $(ENGINEDIR) && $(MAKE) 13 | 14 | build-release-engine: 15 | cd $(ENGINEDIR) && $(MAKE) release 16 | --------------------------------------------------------------------------------