Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 1.0.4 (12/11/2026)

- GP 2: the brake goes back through this play's menu screens to change a class, character, kart, cup, course or round. **Brake goes back** is on by default in the Game tab and can be turned off.
- Going back skips the photo screen and stops working once the gas confirms a choice on the current screen. Menu history resets when a race starts. This feature is disabled in linked play and does not apply to GP 1.

- Added a live Performance page and an optional overlay (F7, rebindable in Controls): frame times, drops, hitches, computer CPU usage, GPU textures, sound queue and scene information. No profile recording or stack sampling is included.

### Known issues

- Graphics fixes remain outstanding: reported Yoshi Park 2 Trick House flicker, widescreen HUD/banner and screen-effect distortions, and the macOS GP 2 rainbow fade. Solid-white highlights still need confirmation against the existing texture fix.
- Brake-back is GP 2 only and disabled in linked play. Return to title and Restart race are not included.

## 1.0.3 (7/11/2026)

- Fixed the periodic freezes in linked races: the cabinets now keep in step (a cabinet runs a fraction of a percent faster or slower to follow the one that leads the race), and one that falls a frame behind catches up without freezing the race
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(OpenGP VERSION 1.0.3 LANGUAGES C CXX)
project(OpenGP VERSION 1.0.4 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
2 changes: 1 addition & 1 deletion cmake/game_sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# game's own patches.cpp and status.cpp: one list for the source build
# (games/CMakeLists.txt) and the installer package (cmake/package.cmake, which
# writes it into package.toml for the installer). Names in games/common/.
set(OPENGP_GAME_COMMON_SOURCES main.cpp arcade.cpp cabinet.cpp camera_use.cpp game_log.cpp link_pace.cpp sdk_hle.cpp)
set(OPENGP_GAME_COMMON_SOURCES main.cpp arcade.cpp cabinet.cpp camera_use.cpp game_log.cpp link_pace.cpp menu_back.cpp sdk_hle.cpp)
set(OPENGP_GAME_OWN_SOURCES patches.cpp status.cpp)
16 changes: 16 additions & 0 deletions docs/playing.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ ask first.
| Controls | The keys, buttons and axes for each control; steering speed, dead zones, force feedback |
| Camera | The webcam (or the test pattern) the game takes your photo with |
| Linked cabinets | This cabinet's number and the link over the local network |
| Performance | Live frame times, drops, CPU and GPU usage, audio queue; optional F7 overlay |

The [performance display](profiling.md) keeps its measurements in memory and does not record a profile.

The settings are the launcher's: the launcher's Settings edit the same file. The camera and the
link settings take effect when the game next starts; the page says so while a change waits.
Expand Down Expand Up @@ -247,6 +250,19 @@ it as well.
Every connected device works at once. Keys and d-pad steer gradually (a keyboard cannot hold the
wheel half-way); sticks and wheels steer directly.

### Going back in the menus

On a cabinet, a choice can't be undone: once the class or the character is chosen, the game goes
on to the next screen. In OpenGP, the **brake** goes back a screen, from character select on: to
the class from the character, to the character (or the kart, with a Mario Card) from the cup or
course, to the cup from the round, to the round from the items. The photo screen is skipped on
the way back. Once you have pressed the gas on a screen, it goes on as usual.

It doesn't work in a linked game, where the cabinets' menus keep in step, and it doesn't change the
class screen (hold the VS cancel button there for Time Attack, as on a cabinet). Turn it off with
**Brake goes back** (Game tab) or `brake_goes_back = false` in `settings.toml`. Only in Mario
Kart Arcade GP 2 for now.

### Changing them

In the menu's Settings, on the **Controls** page, choose the keyboard, gamepads or wheels and other
Expand Down
22 changes: 22 additions & 0 deletions docs/profiling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Performance information

Open the in-game settings and choose **Performance** to see live frame times,
frame drops and hitches, computer CPU usage, GPU texture usage, audio queue
health and the current scene. The graph holds the last 120 active frames.

Press **F7** to show or hide the performance overlay while playing, or use the
**Performance overlay** switch on that page. The shortcut can be rebound to a
keyboard key, gamepad button or pedal axis in **Controls > Performance**
(`profile_overlay` in `user/controls.toml`). Controllers have no default binding.
Use `--profile-overlay` to show it from startup.

These are live measurements held in memory. This release does not include
profile recording, stack sampling, event logs, marks or profiler frame captures.
The private development profiler retains those tools. Ordinary screenshots and
crash reports are unchanged.

Frame times are wall-clock measurements. Busy time subtracts idle and renderer
waits and is an estimate. GPU texture memory is estimated from game texture
dimensions and mip levels, not total GPU memory. Hitches and dropped retraces
exclude paused/menu intervals and the first frame after resuming. CPU use is
for the whole computer and may be unavailable on some systems.
2 changes: 2 additions & 0 deletions games/common/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "cabinet.h"
#include "camera_use.h"
#include "game_log.h"
#include "menu_back.h"
#include "status.h"
#include "ppc_recomp_shared.h"

Expand All @@ -28,5 +29,6 @@ int main(int argc, char** argv) {
game.set_cabinet = cabinet::set;
game.status = game_status::read;
game.link_error = game_status::link_error;
game.set_menu_back = menu_back::set;
return app::run(game, argc, argv);
}
80 changes: 80 additions & 0 deletions games/common/menu_back.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "menu_back.h"

#include <algorithm>
#include <mutex>
#include <vector>

#include "ppc/memory.h"

namespace menu_back {

namespace {

std::mutex g_mutex;
std::function<bool()> g_back, g_decide;

// Only the game's thread runs the menus.
struct State {
gekko::u32 screen = ~0u; // the screen of the last update
std::vector<gekko::u32> stops; // this play's screens that going back returns to
bool armed = false; // the brake was up since the screen started
bool decided = false; // the gas was pressed on this screen
} g_state;

constexpr gekko::u32 kStay = ~0u; // an update's -1

bool has(std::span<const gekko::u32> list, gekko::u32 v) { return std::find(list.begin(), list.end(), v) != list.end(); }

} // namespace

void set(std::function<bool()> back, std::function<bool()> decide) {
std::lock_guard lock(g_mutex);
g_back = std::move(back);
g_decide = std::move(decide);
}

void forget() {
g_state.stops.clear();
g_state.screen = ~0u;
}

gekko::u32 after_update(const gekko::u8* base, const Menus& menus, gekko::u32 next) {
State& s = g_state;
const gekko::u32 screen = ppc::load_be<gekko::u32>(base + menus.scene);
if (screen != s.screen) {
s.screen = screen;
s.armed = s.decided = false;
if (has(menus.starts, screen)) s.stops.clear();
if (has(menus.stops, screen)) {
// Back to a screen already in this play (going back): forget the ones after it.
if (auto it = std::find(s.stops.begin(), s.stops.end(), screen); it != s.stops.end())
s.stops.erase(it + 1, s.stops.end());
else
s.stops.push_back(screen);
}
}
if (!has(menus.back, screen)) return next;

bool back = false, decide = false;
{
std::lock_guard lock(g_mutex);
back = g_back && g_back();
decide = g_decide && g_decide();
}
// A screen that has been decided is on its way to the next one.
if (decide) s.decided = true;
// A brake held from the last screen doesn't go back again.
if (!back) s.armed = true;
if (next != kStay || s.decided || !s.armed || !back) return next;

// The screen before this one (this one is the last stop, unless it isn't
// a stop itself).
const std::size_t last = s.stops.size() - (!s.stops.empty() && s.stops.back() == screen ? 1 : 0);
if (last == 0) return next;
s.armed = false;
return s.stops[last - 1];
}

} // namespace menu_back
48 changes: 48 additions & 0 deletions games/common/menu_back.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
// Going back through the menus. On a cabinet a play can't go back: once the
// class or the character is chosen it stays chosen. OpenGP lets the brake
// pedal (the "Cancel" of the games' own name entry) go back a screen, from
// the character on: the character, the kart, the cup, the course or round,
// the items.
//
// The games' menus are one dispatcher (GP 2's MenuScene_Dispatch) that calls
// the current screen's update each frame. The update returns the next
// screen's number, or -1 to stay; the dispatcher then deletes the screen and
// makes the one with that number, which sets the scene number
// (g_currentSceneState) as it starts. Going back is the update returning the
// previous screen's number.
//
// Not in a linked game: the cabinets' menus keep in step with each other.
#pragma once

#include <functional>
#include <span>

#include "gekko/types.h"
#include "ppc/context.h"

namespace menu_back {

// What the launcher tells the games, while they run (any thread may call).
// `back` is whether going back is wanted now (the brake pressed, the setting
// on, the game not linked); `decide` whether the gas (the games' "Decide") is.
void set(std::function<bool()> back, std::function<bool()> decide);

struct Menus {
gekko::u32 scene; // g_currentSceneState
std::span<const gekko::u32> starts; // the screens a play starts from (going back forgets the last play's)
std::span<const gekko::u32> stops; // the screens going back returns to, in order
std::span<const gekko::u32> back; // the screens that go back
};

// Whether a screen update that returned `next` should go back instead, and
// to where: call it after the update of each screen in `menus`. Returns the
// screen to go to, or `next`.
gekko::u32 after_update(const gekko::u8* base, const Menus& menus, gekko::u32 next);

// A race starts: the menus after it (the next round's, after "Continue?")
// don't go back to this play's.
void forget();

} // namespace menu_back
35 changes: 35 additions & 0 deletions games/mkgp2/patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "cabinet.h"
#include "camera_use.h"
#include "link_pace.h"
#include "menu_back.h"
#include "ppc_recomp_shared.h"
#include "sdk_hle.h"
#include "widescreen.h"
Expand Down Expand Up @@ -122,4 +123,38 @@ PPC_FUNC(fn_80138184) {
__imp__fn_80138184(ctx, base);
}

// A race starts: going back in the menus after it stays in its play.
PPC_FUNC(RaceScene_Init) {
menu_back::forget();
__imp__RaceScene_Init(ctx, base);
}

// Going back through the menus (menu_back.h). The screens' numbers: 0x09 the
// Mario Card, 0x0B the class, 0x0D the character, 0x0F the kart (with a
// card), 0x13 the photo, 0x15 the cup, 0x17 and 0x19 the course, 0x1B the
// round, 0x21 and 0x22 the items (with a card).
namespace {
constexpr gekko::u32 kStarts[] = {0x09};
constexpr gekko::u32 kStops[] = {0x0B, 0x0D, 0x0F, 0x15, 0x17, 0x19, 0x1B, 0x21, 0x22};
constexpr gekko::u32 kBack[] = {0x0D, 0x0F, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x21, 0x22};
constexpr menu_back::Menus kMenus{0x806CED74, kStarts, kStops, kBack};
} // namespace

#define MENU_SCREEN_UPDATE(name) \
PPC_FUNC(name) { \
__imp__##name(ctx, base); \
ctx.gpr[3] = menu_back::after_update(base, kMenus, ctx.gpr[3]); \
}
MENU_SCREEN_UPDATE(fn_801BA498) // the Mario Card
MENU_SCREEN_UPDATE(clFlowClass_Update)
MENU_SCREEN_UPDATE(clFlowChara_Update)
MENU_SCREEN_UPDATE(clFlowKart_Update)
MENU_SCREEN_UPDATE(FrameSelection_Update) // the photo
MENU_SCREEN_UPDATE(clFlowCup_Update)
MENU_SCREEN_UPDATE(clFlowCourse_Update)
MENU_SCREEN_UPDATE(clFlowRound_Update)
MENU_SCREEN_UPDATE(clFlowItem_Update)
MENU_SCREEN_UPDATE(clFlowItemSelect_Update)
#undef MENU_SCREEN_UPDATE

} // namespace guest
3 changes: 1 addition & 2 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ add_library(opengp_machine STATIC
os/crash.cpp
os/notice.cpp
os/printf.cpp
os/profiler.cpp
os/reboot.cpp
os/thread_priority.cpp
os/threads.cpp
Expand Down Expand Up @@ -167,7 +166,7 @@ target_link_libraries(opengp_app
PRIVATE opengp_warnings)
target_compile_definitions(opengp_app PRIVATE OPENGP_VERSION="${PROJECT_VERSION}")
if(OPENGP_BUILD_VIDEO)
target_sources(opengp_app PRIVATE app/menu.cpp app/menu_theme.cpp app/menu_widgets.cpp)
target_sources(opengp_app PRIVATE app/menu.cpp app/menu_theme.cpp app/menu_widgets.cpp app/profiler.cpp)
target_link_libraries(opengp_app PUBLIC opengp_video opengp_input opengp_audio opengp_webcam imgui)
target_compile_definitions(opengp_app PRIVATE OPENGP_VIDEO)
# The menu's typeface (thirdparty/fonts/mplus-rounded-1c), embedded.
Expand Down
Loading
Loading