{"id":28520236,"url":"https://github.com/gyrovorbis/sh4zam","last_synced_at":"2025-09-02T04:32:03.149Z","repository":{"id":292608583,"uuid":"981311142","full_name":"gyrovorbis/sh4zam","owner":"gyrovorbis","description":"Linear Algebra and math library for the Hitachi SuperH4 Processor (used by the Sega Dreamcast).","archived":false,"fork":false,"pushed_at":"2025-08-30T15:25:03.000Z","size":311,"stargazers_count":86,"open_issues_count":0,"forks_count":11,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-08-30T17:29:52.041Z","etag":null,"topics":["assembly","dreamcast","hitachi","linear-algebra","matrices","memcpy","naomi","optimization","quaternion","renesas","sega","sega-dreamcast","sh4","simd","simd-intrinsics","superh","vectorization","vectors"],"latest_commit_sha":null,"homepage":"http://sh4zam.elysianshadows.com","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gyrovorbis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-10T20:16:21.000Z","updated_at":"2025-08-30T15:25:06.000Z","dependencies_parsed_at":"2025-05-26T02:26:35.523Z","dependency_job_id":"10bdbb6a-0c0a-4ab4-8a99-7862ed6f8d33","html_url":"https://github.com/gyrovorbis/sh4zam","commit_stats":null,"previous_names":["gyrovorbis/libsh4","gyrovorbis/sh4zam"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gyrovorbis/sh4zam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gyrovorbis%2Fsh4zam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gyrovorbis%2Fsh4zam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gyrovorbis%2Fsh4zam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gyrovorbis%2Fsh4zam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gyrovorbis","download_url":"https://codeload.github.com/gyrovorbis/sh4zam/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gyrovorbis%2Fsh4zam/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273233232,"owners_count":25068725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","dreamcast","hitachi","linear-algebra","matrices","memcpy","naomi","optimization","quaternion","renesas","sega","sega-dreamcast","sh4","simd","simd-intrinsics","superh","vectorization","vectors"],"created_at":"2025-06-09T07:00:59.767Z","updated_at":"2025-09-02T04:32:03.142Z","avatar_url":"https://github.com/gyrovorbis.png","language":"C","funding_links":[],"categories":["Math"],"sub_categories":[],"readme":"\u003c!-- PROJECT LOGO --\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/gyrovorbis/sh4zam\"\u003e\n    \u003cimg src=\"http://sh4zam.elysianshadows.com/logo.png\" alt=\"SH4ZAM\"\u003e\n  \u003c/a\u003e\n  \u003ch3 align=\"center\"\u003e\u003cstrong\u003eSH4ZAM!\u003c/strong\u003e\u003c/h3\u003e\n  \u003cp align=\"center\"\u003e\n    Fast math library for the Sega Dreamcast's SH4 CPU\n    \u003cbr /\u003e\n    \u003ca href=\"http://sh4zam.elysianshadows.com\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\u003chr\u003e\n\n# Overview\n`Sh4zam` is a hand-optimized, general-purpose math and linear algebra library for harnessing the floating-point power of the SH4 processor in the Sega Dreamcast. It originally began as a collection of inline assembly routines developed specifically to accelerate the math in the Grand Theft Auto 3 and Vice City DC ports. These routines, along with many others from various contributors, have been separated and combined into a single standalone library, which can be leveraged to bring gainz to the Dreamcast and SuperH communities at large.\n\nNOTE: \u003ci\u003eThis repo is still undergoing rapid changes as we pull in these routines from various places, get them exposed via both C and C++ APIs, and get them unit tested. The majority of the content has now been tested and verified in shipping games; however, not everything has been fully tested, as we are not yet to version 1.0.\u003c/i\u003e\n\n# Features\n- Dual modern C23 and modern C++23 APIs\n- No external dependencies (can be used with KallistiOS, SH Linux, etc)\n- Meticulously optimized for latest SH-GCC version 15.x\n- Rigorously unit tested and validated on physical HW\n\n# APIs\n- **Preprocessor** directives controlling optimizations\n- **Intrinsics** for SH4 instructions not emitted by GCC\n- **Memory** routines (memcpy(), memset(), memmove(), etc)\n- **Floating-point Environment** control\n- **Scalar** math operations\n- **Trigonomety** functions\n- **Vector** types: 2D, 3D, 4D\n- **Matrix** types: 2x2, 3x2, 3x3, 3x4, 4x3, and 4x4\n- **Quaternion** math operations\n- **XMTRX** API for manipulating 4x4 back-bank of FP registers\n- **Miscellaneous** optimized routines such as IPv4 checksum\n\n# Examples\n\n## C23\nFor C code, include the header files with the `.h` extensions or `sh4zam/shz_sh4zam.h` to include everything.\n\n    #include \u003csh4zam/shz_sh4zam.h\u003e\n\n    int main(int argc, const char *argv[]) {\n        shz_vec4_t vec1 = shz_vec4_init(2.0f, 3.0f, 4.0f, 1.0f);\n        shz_vec4_t vec2 = shz_vec4_normalize(shz_vec4_scale(vec1, shz_sinf(SHZ_F_PI));\n        shz_matrix_4x4_t mat = {};\n\n        shz_xmtrx_init_diagonal(vec2.x, vec2.y, vec2.z, vec2.w);\n        shz_xmtrx_apply_rotation_x(shz_vec4_dot(vec1, vec2));\n        shz_xmtrx_apply_translation(vec1.x, vec1.y, vec1.z);\n        shz_xmtrx_store_4x4(\u0026mat);\n\n        shz_vec4_t vec3 = shz_xmtrx_trans_vec4(vec2);\n\n        return 0;\n    }\n\nNOTE: \u003ci\u003eWhere applicable, the C API also includes a variety of type-generic routines which will automatically resolve to calling the proper functions based on argument type. for example, `shz_vec_dot()` will automatically forward to the proper routine based on the type of vectors passed to it.\u003c/i\u003e\n\n## C++23\nFor C++ code, include the header files with the `.hpp` extensions or `sh4zam/shz_sh4zam.hpp` to include everything.\n\n    #include \u003csh4zam/shz_sh4zam.hpp\u003e\n\n    int main(int argc, const char* argv[]) {\n        shz::vec4 vec1(2.0f, 3.0f, 4.0f, 1.0f);\n        shz::vec4 vec2 = shz::vec4(vec1 * shz::sinf(shz::f_pi)).normalize();\n        shz::matrix_4x4 mat {};\n\n        shz::xmtrx::init_diagonal(vec2.x,vec2.y, vec2.z, vec2.w);\n        shz::xmtrx::apply_rotation_x(vec1.dot(vec2));\n        shz::xmtrx::apply_translation(vec1.x, vec2.y, vec2.z);\n        shz::xmtrx::store(\u0026mat);\n\n        shz::vec4 vec3 = shz::xmtrx::trans(vec2);\n    }\n\nNOTE: \u003ci\u003eC++ can still use the C API by design, and every C++ type is also compatible with its corresponding C types and C API, so you can mix and match.\u003c/i\u003e\n\n# Installation\n\n## CMake\nTo quickly build the project with CMake in any environment, run the following from the repo root:\n```\nmkdir build\ncd build\ncmake ..\nmake\nmake install\n```\nThis will build and install the statically linked library as well as the public headers.\n\nIf you would like to also build and run the unit tests, include `-DSHZ_ENABLE_TESTS=on` within the `cmake` command. Now a separate binary for the unit test executable should be built as well.\n\nNOTE: \u003ci\u003eFor KOS users, use `kos-cmake` instead of your system `cmake` command!\u003c/i\u003e\n\n## Make (KallistiOS)\n`Makefile.kos` has been included to provide a convenient way to install and use SH4ZAM within the standard [KallistiOS environment](https://github.com/KallistiOS/KallistiOS). See [The Wiki](https://dreamcast.wiki/Getting_Started_with_Dreamcast_development) for a guide on how to set up KallistiOS.\n\nSimply run `make -f Makefile.kos \u003ctarget\u003e` from the root of the repo, optionally passing in one of the following targets:\n\nTarget      | Description\n------------|------------\n`all`       | Builds everything\n`clean`     | Cleans everything\n`lib`       | Builds just libsh4zam.a\n`tests`     | Builds unit test ELF\n`run`       | Builds and runs unit tests\n`install`   | Installs library as a KOS addon\n`uninstall` | Uninstalls library from KOS addons\n`docs`      | Builds Doxygen documentation\n`update`    | Updates git repo to latest\n\n# Contributors\n\nSpecial thanks to the following individuals who have either directly or indirectly contributed to SH4ZAM:\n- Falco Girgis\n- Paul Cercueil\n- Oleg Endo\n- jnmartin64\n- Stefanos Kornilios Mitsis Poiitidis\n- MoopTheHedgehog\n- Mikael Kalms\n- Twada\n- TapamN\n- UnknownShadow\n- yomboprime\n- David Reichelt\n- Luke Benstead\n- Ian Michael\n- HailToDodongo\n- Jesse Stojan\n- Jamie Hyland\n- Aleios\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgyrovorbis%2Fsh4zam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgyrovorbis%2Fsh4zam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgyrovorbis%2Fsh4zam/lists"}