Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
19a6546
Delete screens directory
bzz11g Sep 8, 2026
1e1124b
App ICON0 and PIC1 for PSP build
bzz11g Sep 8, 2026
5b55ed3
Configure CMake and source code for PSP EBOOT.PBP compilation
google-labs-jules[bot] Sep 8, 2026
5aef138
Fix CI to output only PSP artifacts using pspdev container
google-labs-jules[bot] Sep 8, 2026
c943396
Fix CI to output only PSP artifacts using pspdev container
google-labs-jules[bot] Sep 8, 2026
2919f4e
Merge pull request #1 from bzz11g/psp-build-config-9940141254180594472
bzz11g Sep 8, 2026
1135e20
Update README.md
bzz11g Sep 8, 2026
11b9d79
Update README.md
bzz11g Sep 8, 2026
699ea87
Update README.md
bzz11g Sep 8, 2026
0c07854
Fix PSP resolution and eliminate screen tearing
google-labs-jules[bot] Sep 8, 2026
baeac03
Update build.yml
bzz11g Sep 8, 2026
b07eded
Fix PSP rendering performance and visual artifacts
google-labs-jules[bot] Sep 8, 2026
c86d867
Implement bounded glyph texture cache to fix memory leak
google-labs-jules[bot] Sep 8, 2026
cae0141
Fix missing font stems and rasterization artifacts on PSP display
google-labs-jules[bot] Sep 8, 2026
2b72de1
Fix visual stacking, menu FPS, and PSP gamepad input
google-labs-jules[bot] Sep 8, 2026
fd94afe
Merge pull request #2 from bzz11g/fix/psp-resolution-1120198453320561…
bzz11g Sep 8, 2026
8b27db2
Implement PSP controller mappings for UI navigation and in-game controls
google-labs-jules[bot] Sep 8, 2026
0772e87
Merge pull request #3 from bzz11g/implement-psp-controller-mappings-1…
bzz11g Sep 8, 2026
fb3f0a4
Update README.md
bzz11g Sep 8, 2026
477a381
Add dynamic custom level pack loader (.mrg files) and UI integration
google-labs-jules[bot] Sep 8, 2026
8d7d040
Update README.md
bzz11g Sep 8, 2026
1da0f14
Add info img
bzz11g Sep 8, 2026
7272d45
Add dynamic custom level pack loader (.mrg files) with UI selection a…
google-labs-jules[bot] Sep 8, 2026
80eb063
Merge pull request #4 from bzz11g/feature/dynamic-level-loader-817554…
bzz11g Sep 8, 2026
2781c2a
Remove obsolete J2ME keyset settings from Options menu
google-labs-jules[bot] Sep 8, 2026
2c963af
Merge pull request #5 from bzz11g/remove-keyset-settings-959854671610…
bzz11g Sep 8, 2026
67878fb
Delete winres directory
bzz11g Sep 8, 2026
b65a8c5
Delete cmake directory
bzz11g Sep 8, 2026
ec2caf6
Add PIC0.png to the PSP EBOOT packaging pipeline
google-labs-jules[bot] Sep 8, 2026
1392751
Create CMakeRC.cmake
bzz11g Sep 9, 2026
335ae4b
Create mingw-sdl2.cmake
bzz11g Sep 9, 2026
9bbed1e
Create mingw-toolchain.cmake
bzz11g Sep 9, 2026
b0eb12f
Fix PSP EBOOT PIC0 packaging and restore Windows build assets
google-labs-jules[bot] Sep 9, 2026
a85534f
Merge pull request #6 from bzz11g/add-pic0-to-eboot-9555305311659279205
bzz11g Sep 9, 2026
2c48cf4
Add basic PARAM.SFO for save states
bzz11g Sep 9, 2026
ca7588b
Highquility replace
bzz11g Sep 9, 2026
e5b8ab6
Move save data to a local save folder next to executable
google-labs-jules[bot] Sep 10, 2026
b7fc068
Fix hardware path resolution and save file flush in RecordStore
google-labs-jules[bot] Sep 10, 2026
1de4029
Organize save files per level pack in local save folder
google-labs-jules[bot] Sep 21, 2026
2b14fb7
Fix PSP step-by-step directory creation and record ID tracking in Rec…
google-labs-jules[bot] Sep 21, 2026
6e56937
Merge pull request #10 from bzz11g/move-save-data-to-local-save-folde…
bzz11g Sep 21, 2026
79c0137
Fix track line clipping, start flag flickering, and unlock 60 FPS.
google-labs-jules[bot] Sep 21, 2026
71ef54a
Fix track clipping, flag flickering, and decouple fixed physics times…
google-labs-jules[bot] Sep 21, 2026
385557a
Fix track clipping, flag flickering, hardware boot crash, and frame p…
google-labs-jules[bot] Sep 21, 2026
7ab8cb6
Fix clipping, flag flickering, frame pacing, and real PSP boot compat…
google-labs-jules[bot] Sep 21, 2026
457106c
Fix track clipping and Start flag flickering; restore stable loop tim…
google-labs-jules[bot] Sep 21, 2026
3baecdf
Fix track clipping, Start flag flickering, hardware boot, and memory …
google-labs-jules[bot] Sep 21, 2026
0fdb3a0
Fix PSP heap allocation (-1024KB), font cache sizing (128), and track…
google-labs-jules[bot] Sep 21, 2026
1ef0167
Merge pull request #11 from bzz11g/jules-fix-clipping-and-60fps-13086…
bzz11g Sep 21, 2026
4dfc339
Create intraFont.c
bzz11g Sep 22, 2026
0206d7e
Create intraFont.h
bzz11g Sep 22, 2026
9863f07
Create libccc.c
bzz11g Sep 22, 2026
e5c012a
Create libccc.h
bzz11g Sep 22, 2026
d47a994
Create glib2d.c
bzz11g Sep 22, 2026
ccd276a
Create glib2d.h
bzz11g Sep 22, 2026
634c13b
Migrate PSP graphics and lifecycle from SDL2 to gLib2D and intraFont
google-labs-jules[bot] Sep 22, 2026
8040208
Fix freetype include path in CMakeLists.txt for PSPDEV CI environment
google-labs-jules[bot] Sep 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
name: Build
on: [pull_request, push]

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
build:
runs-on: ubuntu-24.04
container:
image: pspdev/pspdev:latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev g++-mingw-w64-i686

- name: Build for Ubuntu
run: |
cmake -B build-ubuntu
cmake --build build-ubuntu

- name: Upload for Ubuntu
uses: actions/upload-artifact@v4
with:
name: GravityDefied
path: build-ubuntu/GravityDefied
- name: Workaround Git Permissions
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Build for Windows
- name: Build for PSP
run: |
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/mingw-toolchain.cmake -B build-win32
cmake --build build-win32
export PATH=/usr/local/pspdev/bin:$PATH
psp-cmake -B build-psp
make -C build-psp

- name: Upload for Windows
- name: Upload for PSP
uses: actions/upload-artifact@v4
with:
name: GravityDefied.exe
path: build-win32/GravityDefied.exe
name: GravityDefied-PSP
path: build-psp/EBOOT.PBP
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
.cache
.vscode
build-psp/
52 changes: 52 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Gravity Defied (PSP Port) Agent Guidelines

## PSP Build Instructions

This project targets the PlayStation Portable (PSP) hardware. It requires the PSPDEV toolchain to build the target artifact (`EBOOT.PBP`).

### Toolchain Prerequisites
- A working PSPDEV toolchain installation.
- Ensure the `psp-cmake` and `psp-g++` binaries are available in your `$PATH`.
- Typically, the toolchain is located at `/usr/local/pspdev`.

Before building, set up the environment:
```bash
export PATH=/usr/local/pspdev/bin:$PATH
```

### Build Commands
To compile and produce `EBOOT.PBP` from scratch:
```bash
# 1. Generate build files with psp-cmake
psp-cmake -B build-psp

# 2. Compile and package the binary
make -C build-psp
```

The resulting PSP executable will be generated at `build-psp/EBOOT.PBP`.

### Project Structure & PSP Hardware Dependencies
- **C++ Source Files**: Located in `src/`.
- **Game Assets**: Located in `assets/`.
- **PSP Specific Macros**: Located in `src/main.cpp` (using `PSP_MODULE_INFO` and `<pspkernel.h>`).
- **Dependencies**: The project requires `SDL2`, `SDL2_ttf`, and `SDL2_image` ports for PSP, linked automatically via standard CMake `pkg-config` and `target_link_libraries`.
- **CMake config**: The primary configuration is in `CMakeLists.txt`. For PSP builds, the toolchain provides a `create_pbp_file` macro to package the EBOOT.PBP.

### Asset Packing Rules
When the `EBOOT.PBP` is generated, it bundles the executable along with the following UI assets from the `assets/` directory:
- **Title (SFO metadata)**: `Gravity Defied: Trial Racing`
- **XMB Icon**: `assets/ICON0.png`
- **XMB Background**: `assets/PIC1.png`

These are defined inside `CMakeLists.txt` using the `create_pbp_file` command. The PSP DEV script `pack-pbp` uses these arguments to assemble the `EBOOT.PBP` output.

### Guidelines for Testing
- The output `EBOOT.PBP` can be tested using the **PPSSPP** emulator or executed on **real PSP hardware** running Custom Firmware (CFW).
- For real hardware, copy the output `EBOOT.PBP` to `ms0:/PSP/GAME/GravityDefied/EBOOT.PBP`.
- Automated testing (`ctest`) is currently unconfigured for this target. Verification must be done either manually (via emulator/hardware).

### File Boundaries
- Do not modify or commit files in the `build-psp/` directory (these are generated outputs, such as intermediate `.o` / `.obj` files, and raw ELF binaries).
- Do not manually construct or commit `PARAM.SFO`. It is generated automatically during the build process via `mksfo` or `mksfoex`.
- Do not add Windows or other platform-specific metadata files (e.g., MSVC projects) as this build focuses on PSP hardware.
75 changes: 29 additions & 46 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
cmake_minimum_required(VERSION 3.24)
project(gravity_defied_cpp C CXX)

unset(ENV{PKG_CONFIG_PATH})

if(WIN32)
include(cmake/mingw-sdl2.cmake)
download_mingw_sdl2(
"2.26.1" # SDL2
"2.20.1" # SDL2_ttf
"2.6.2" # SDL2_image
)
endif()

find_package(PkgConfig REQUIRED)

pkg_search_module(SDL2 REQUIRED IMPORTED_TARGET sdl2)
pkg_search_module(SDL2_TTF REQUIRED IMPORTED_TARGET SDL2_ttf)
pkg_search_module(SDL2_IMAGE REQUIRED IMPORTED_TARGET SDL2_image)
execute_process(
COMMAND psp-config --psp-prefix
OUTPUT_VARIABLE PSP_PREFIX_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Create a sources variable with a link to all cpp files to compile
set(SOURCES
src/utils/Time.cpp
src/utils/EmbedFileStream.cpp
Expand Down Expand Up @@ -46,6 +34,10 @@ set(SOURCES
src/lcdui/FontStorage.cpp
src/rms/RecordEnumerationImpl.cpp
src/rms/RecordStore.cpp
src/psp/glib2d.c
src/psp/intra/intraFont.c
src/psp/intra/libccc.c
src/psp/pspSetup.cpp
)

include(cmake/CMakeRC.cmake)
Expand All @@ -68,43 +60,34 @@ cmrc_add_resource_library(Assets
assets/FontSansSerif.ttf
)

# Compile resources when building for Windows.
if(WIN32)
enable_language(RC)
list(APPEND SOURCES winres/res.rc)
endif()

add_executable(GravityDefied ${SOURCES})

target_compile_features(GravityDefied PRIVATE cxx_std_17)
target_compile_options(GravityDefied PRIVATE -Wall -Wextra)
target_compile_options(GravityDefied PRIVATE -Wall -Wextra -fno-exceptions -fno-rtti)

target_include_directories(GravityDefied PRIVATE
${SDL2_INCLUDE_DIRS}
${SDL2_TTF_INCLUDE_DIRS}
${SDL2_IMAGE_INCLUDE_DIRS})

target_link_directories(GravityDefied PRIVATE
${SDL2_LIBRARY_DIRS}
${SDL2_TTF_LIBRARY_DIRS}
${SDL2_IMAGE_LIBRARY_DIRS})
src
src/psp
src/psp/intra
${PSP_PREFIX_DIR}/include/freetype2
$ENV{PSPDEV}/psp/include/freetype2)

set_target_properties(GravityDefied PROPERTIES LINK_FLAGS_RELEASE -s)

if(WIN32)
target_link_options(GravityDefied PRIVATE -static -mwindows)
target_link_libraries(GravityDefied
${SDL2_STATIC_LIBRARIES}
${SDL2_TTF_STATIC_LIBRARIES}
${SDL2_IMAGE_STATIC_LIBRARIES}
Assets::Assets)
else()
target_link_libraries(GravityDefied
${SDL2_LIBRARIES}
${SDL2_TTF_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
Assets::Assets)
endif()
target_link_libraries(GravityDefied PRIVATE
png jpeg bz2 pspgu pspgum pspdisplay pspge pspctrl psppower psprtc pspvram
freetype z m stdc++
Assets::Assets)

# Copy assets to the build directory
file(COPY assets/levels.mrg DESTINATION ${CMAKE_BINARY_DIR})

if(PSP OR DEFINED ENV{PSPDEV})
create_pbp_file(
TARGET GravityDefied
TITLE "Gravity Defied: Trial Racing"
ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/assets/ICON0.png"
PREVIEW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/assets/PIC0.png"
BACKGROUND_PATH "${CMAKE_CURRENT_SOURCE_DIR}/assets/PIC1.png"
)
endif()
59 changes: 52 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,62 @@
# Gravity Defied Cpp

![](./screens/demo1.gif)
# Gravity Defied C++ PSP (AI Homebrew Port)

**Gravity Defied** is a legendary mototrial racing mobile game. It was originally developed by Codebrew Software in 2004 for J2ME platform.

This is the C++ & SDL2 port of Gravity Defied, which includes all the features of the original game.
This project is an experimental native PlayStation Portable (PSP) homebrew port based on the C++ / SDL2 codebase, brought to the platform with the assistance of AI development tools (Google Jules). It aims to deliver all features and authentic physics of the original game directly on real PSP hardware and emulators.

***Disclaimer
This project is an unofficial fan homebrew and is not associated with Codebrew Software in any fashion. All rights to the original Gravity Defied, including its name, logotype, brand, assets, and original codebase, belong to Codebrew Software.***

## Custom Level Packs

The release build includes the original track set along with **5 top community level packs from [gdtr.net](https://gdtr.net)** ready to play.

### Adding Your Own Tracks
Put any `.mrg` level pack files into the `levels/` folder inside the game directory:
`ms0:/PSP/GAME/<GravityDefied_Folder>/levels/your_pack.mrg`

Select your pack in **Menu > Play > Level pack:**. Each pack maintains its own independent track progress and saves.

---

## Controls

### Menu Navigation

***This Project is not associated with Codebrew Software in any fashion. All rights to the original Gravity Defied, it's name, logotype, brand and all that stuff belong to Codebrew Software.***
| Button | Action |
| :--- | :--- |
| **D-Pad / Analog Stick** | Navigate menu options |
| **✕ (Cross) / START** | Confirm / Select |
| **○ (Circle)** | Back / Cancel |
| **HOME / PS** | Open standard PSP exit dialog |
| **△, □, SELECT, L, R** | Disabled in menus |

---

### In-Game (Race)

Controls replicate the authentic J2ME mobile phone keypad layout:

| Action | D-Pad / Analog Stick | Face Buttons | J2ME Equivalent |
| :--- | :--- | :--- | :--- |
| **Accelerate (Gas)** | **Up** | **△ (Triangle)** | `KEY_NUM2` / `UP` |
| **Brake / Reverse** | **Down** | **✕ (Cross)** | `KEY_NUM8` / `DOWN` |
| **Lean Backward** | **Left** | **□ (Square)** | `KEY_NUM4` / `LEFT` |
| **Lean Forward** | **Right** | **○ (Circle)** | `KEY_NUM6` / `RIGHT` |

#### Shortcuts & System

* **L Trigger:** Gas + Lean Backward (`KEY_NUM1`)
* **R Trigger:** Gas + Lean Forward (`KEY_NUM3`)
* **START:** Pause / Resume
* **HOME / PS:** Standard PSP firmware exit dialog

# Authors

### PSP Homebrew port
* **[bzz11g](https://github.com/bzz11g)**
* **jules.google.com**

### Gravity Defied Cpp authors
* **[rgimad](https://github.com/rgimad)** - idea & coding
* **[AntonEvmenenko](https://github.com/AntonEvmenenko)** - coding
Expand All @@ -24,5 +71,3 @@ This is the C++ & SDL2 port of Gravity Defied, which includes all the features o
For more information, please visit official site of Codebrew Software: [codebrew.se](http://codebrew.se)

# Contributing

If you want to contribute, feel free to discuss your idea with the rest of the developers in our [Telegram group](https://t.me/+sOfxjrsbkbEwNzc6)
Binary file added assets/ICON0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/PARAM.SFO
Binary file not shown.
Binary file added assets/PIC0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/PIC1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions patch_main.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<<<<<<< SEARCH
#ifdef PSP
#include <pspkernel.h>
PSP_MODULE_INFO("GravityDefied", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
#endif

int main(int argc, char** argv)
{
try {
std::unique_ptr<Micro> micro = std::make_unique<Micro>();
=======
#ifdef PSP
#include <pspkernel.h>
PSP_MODULE_INFO("GravityDefied", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);

int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}

int CallbackThread(SceSize args, void *argp) {
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}

int SetupCallbacks(void) {
int thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
#endif

int main(int argc, char** argv)
{
#ifdef PSP
SetupCallbacks();
#endif

try {
std::unique_ptr<Micro> micro = std::make_unique<Micro>();
>>>>>>> REPLACE
Binary file removed screens/demo1.gif
Binary file not shown.
2 changes: 0 additions & 2 deletions src/GameCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,6 @@ void GameCanvas::renderFender(int x, int y, int angleF16)

void GameCanvas::clearScreenWithWhite()
{
graphics->setColor(255, 255, 255);
graphics->fillRect(0, 0, width, height2);
}

void GameCanvas::setColor(int red, int green, int blue)
Expand Down
Loading