Giter Club home page Giter Club logo

zig-psp's Introduction

Zig-PSP

A project to bring Zig to the Sony PlayStation Portable

Why Zig on the PSP?

In the PSP programming community, many libraries, tools, and other features are written in C or C++, which as we know has its problems with writing clean, reusable, and high quality code. Given that the core objectives of Zig as a language are to allow us to create well-designed and reusable software, Zig seems like a perfect fit for integrating older PSP libraries while striving to develop higher quality software!

Special Thanks

Special thanks is given to the Rust-PSP team whose efforts influenced and helped to get this project off the ground. No harm is intended, and it's thanks to you Rustaceans that fellow Ziguanas can program for the PSP.

Usage

Currently, using Zig-PSP is rather straight forward - one must use the psp folder in their project's src folder in order to have the PSP's function definitions, alongside with some custom utilities I have created. One also must include the tools/ folder to use the post-build tools. To build a PSP app, use the included build.zig script to generate a PSP executable! (EBOOT.PBP / app.prx) This script is well commented for explanation and documentation.

For a main.zig file one should include something like:

const psp = @import("psp/utils/psp.zig");

comptime {
    asm(psp.module_info("Zig PSP App", 0, 1, 0));
}

pub fn main() !void {
    psp.utils.enableHBCB();
    psp.debug.screenInit();

    psp.debug.print("Hello from Zig!");
}

A quick call to zig build will build your program and should emit an EBOOT.PBP and app.prx in your root. These are the two PSP executable formats - .prx for debugging, and .PBP for running normally.

One can run a .PBP file on their PSP (assuming CFW is installed) by adding their application to PSP_DRIVE:/PSP/GAME/YourAppName/EBOOT.PBP and it will be available under the Games->Memory Stick list in the PSP's XMB.

EBOOT Customization

In order to customize the EBOOT, one can look into the build.zig file and modify the constant fields to change their application icon, background, and even add animations or sounds to the EBOOT on the XMB screen.

Comparisons To C/C++

When comparing Zig code to C/C++, it would be rather apparent that by default, Zig is much smaller and tightly knit. LLVM is an excellent backend which produces some very small code, and Zig is an example of that. Without the weight of the entire C standard library needing to be imported, a simple naive Hello World, as seen above, generates in 10,195 bytes, compared to the C/C++ size of 68,098 bytes. That's an 85% reduction in size! With a few structural changes, as seen in hello-min.zig sample, that size can get down to 6,674 bytes! That's 90.2% smaller!

Hopefully in the future, one could reference track the functions used in the SDK for imports, and dynamically generate module import information. This way, the PSP applications could go as small as 3,200 bytes for a hello world! This repository is distributed as part of a template, allowing one to customize their module imports, meaning that full release applications built with small tweaks to the toolchain NIDS directory could result in extraordinarily small executables for release applications!

Documentation

Currently Zig-PSP does not include documentation of the PSPSDK in the SDK's .zig files - but rather they are well documented in C. It is planned to add documentation in the future to resolve this

Debugging

If one has an installed copy of the legacy PSPSDK, one can use PSPLink - a USB debugging software, to connect their PSP to their computer and run debugging functions on the application. With legacy PSPSDK, you'll also have access to psp-gdb, a PSP-specific version of GDB to use as well. PSP-GDB with Zig is untested at the moment, but in theory should work.

zig-psp's People

Contributors

iridescentrose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zig-psp's Issues

Release Roadmap

  • PSP PRX Generation
  • All PSP Userland Library Symbols
  • Full build.zig build script
  • Remove all dependencies on PSPSDK headers & Newlib
  • Basic PSP Debug Printing
  • Remove dependency on Rust-PSP installs.
  • Basic PSP Memory & VRAM Allocator
  • Basic Error handling on Main
  • Fixup enums
  • Panic Support
  • Remove C dependencies!
  • Documentation for the custom modules.
  • Benchmarking
  • Include basic examples!
  • Self-hosted packing tools
  • Remove Reliance on Rust libpsp.a
  • Generate function stubs (comptime macros?)
  • Fix ABI issues with >4 arg funcs
  • Add all NIDs
  • New sceGu
  • New sceGum
  • 3D Samples

v1.0

  • Update to latest PSPSDK NIDS
  • Update to latest PSPSDK SDK
  • Update to latest PSPSDK Includes
  • Rewrite Namespace / Modules
  • Generate zig autodocs
  • PRX Generation in Zig
  • Add exports to C for sceGu and sceGum
  • Add steps to generate libzpsp from build script
  • STD Custom OS Support
  • Stack Traces
  • VFPU / Allegrex ASM macro
  • Support building Plugins
  • Add Signing Support

Bug with projection matrix when rendering the cube

I'm aware this project isn't maintained now but I figured I'd track this bug in the project anyway incase someone else wanted to resolve it.

Details here:
hrydgard/ppsspp#17981 (comment)

OK, investigated this in RenderDoc.

The entire cube gets clipped away, I guess we're just very slightly off from what the real PSP is doing.

The reason this is happening is that there's a digit missing in the projection matrix, causing it to squish the cube flat against the Z=0 plane, so this cube will not depth test properly against anything else. The perspective projected texturing still works (if you pass the clipping) since the W coordinate is computed correctly.

289694398-f29450a8-7eb6-4f1a-b7d2-b4a3f32bcb86

Note how the third row (actually column, I believe, but viewed transposed) of the matrix is 0.0f. There should be at least one non-zero number in there.

Pre-Release Cleanup

  • Default EBOOT parameters.
  • PSP Module Info Macro
  • Automagic module_start(); without the block.
  • Clear and concise Readme
  • SFOTool Parsing JSON as an option
  • Update final template

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.