Skip to content

Commit ae7e0f2

Browse files
FORCED: Overwriting Tuna with local state
1 parent 80d2f08 commit ae7e0f2

3 files changed

Lines changed: 43 additions & 51 deletions

File tree

installer/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ EE_GPVAL = -G8192
6161

6262
# CFLAGS for EE compilation
6363
# -Os for size optimization, -mgpopt for GP optimization
64-
# Added -Wall for all warnings, -Wno-string-plus-int to suppress a common GCCism warning
65-
EE_CFLAGS += -Os -mgpopt $(EE_GPVAL) -Wall -Wno-string-plus-int
64+
# Removed -Wno-string-plus-int as it's not recognized by the ps2dev ee-gcc
65+
EE_CFLAGS += -Os -mgpopt $(EE_GPVAL) -Wall
6666

6767
# Conditional compilation for exFAT support
6868
ifeq ($(EXFAT), 1)

installer/main.c

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,61 @@
11
#include <iopheap.h>
22
#include <kernel.h>
3-
#include <libcdvd.h> // For sceCd* functions if used (e.g. in system.c)
4-
#include <libmc.h> // For mc* functions (e.g. in system.c)
5-
#include <fileXio_rpc.h>// For fileXioDevctl, etc. (used in system.c)
6-
#include <hdd-ioctl.h> // For HDDCTL_DEV9_SHUTDOWN (used here)
7-
#include <loadfile.h> // For LoadExecPS2, SifLoadModule (if used directly, often in iop.c)
8-
#include <malloc.h> // For memalign (used in system.c)
9-
#include <sbv_patches.h>// For sbv_patch* (used in iop.c)
10-
#include <sifcmd.h> // For SifInitRpc, SifExitRpc, etc.
3+
#include <libcdvd.h>
4+
#include <libmc.h>
5+
#include <fileXio_rpc.h>
6+
#include <hdd-ioctl.h>
7+
#include <loadfile.h>
8+
#include <malloc.h>
9+
#include <sbv_patches.h>
10+
#include <sifcmd.h>
1111
#include <sifrpc.h>
12-
#include <stdio.h> // For sprintf, printf (if DEBUG_PRINTF uses sio_printf, this might not be strictly needed for that)
13-
#include <string.h> // For strcpy, strcmp, etc.
14-
#include <wchar.h> // If any wide char functions were used by UI/Font (not directly in main.c usually)
12+
#include <stdio.h> // For general C functions like sprintf, if not for sio_printf
13+
#include <string.h>
14+
#include <wchar.h>
1515

16-
#include <libgs.h> // For GS_BGCOLOUR and graphics init/deinit if used directly here
16+
#include <libgs.h>
17+
#include <sio.h> // <<< ADDED: For sio_init, even if DEBUG_TTY_FEEDBACK is off in main.h for DEBUG_PRINTF
1718

1819
// FMCB Project Specific Includes
19-
#include "main.h" // Contains MainMenuEvents enum, extern g_Port/g_Slot, FMCB_INSTALLER_VERSION etc.
20-
#include "iop.h" // For IopInitStart, IopDeinit, IOP_MOD_SET_MAIN
21-
#include "pad.h" // For PadInitPads, PadDeinitPads (if not handled in UI)
22-
#include "graphics.h" // For graphics functions (RedrawLoadingScreen, etc.)
23-
#include "font.h" // For font handling (if used directly here)
24-
25-
// #include "libsecr.h" // libsecr functions are usually wrapped in system.c
26-
// #include "mctools_rpc.h"// MCTools RPC functions are usually wrapped in system.c
27-
#include "system.h" // For GetBootDeviceID, GetPs2Type, HDDCheckStatus, UpdateRegionalPaths, StartWorkerThread, StopWorkerThread, IsHDDBootingEnabled etc.
28-
// #include "ReqSpaceCalc.h"// If used directly here
29-
#include "UI.h" // For InitializeUI, DeinitializeUI, DisplayErrorMessage, etc.
30-
#include "menu.h" // For MainMenu() and menu_opentuna_install() declarations
20+
#include "main.h"
21+
#include "iop.h"
22+
#include "pad.h"
23+
#include "graphics.h"
24+
#include "font.h"
25+
26+
#include "system.h"
27+
#include "UI.h"
28+
#include "menu.h"
3129

3230
// --- Global Variable Definitions ---
33-
// These are declared extern in main.h and used by other modules like menu_opentuna.c
34-
int g_Port = 0; // Default MC port (mc0)
35-
int g_Slot = 0; // Default MC slot (slot 0) - PS2 only has one slot per port controller
36-
int IsHDDUnitConnected = 0; // Tracks HDD status
31+
int g_Port = 0;
32+
int g_Slot = 0;
33+
int IsHDDUnitConnected = 0;
3734

38-
// Semaphores (defined here as they are fundamental to main's operation)
35+
// Semaphores
3936
int VBlankStartSema;
4037
int InstallLockSema;
4138

4239
// --- Static Function Implementations ---
4340

44-
// VBlank Handler (from original main.c)
4541
static int VBlankStartHandler(int cause)
4642
{
4743
ee_sema_t sema_status;
4844
iReferSemaStatus(VBlankStartSema, &sema_status);
4945
if (sema_status.count < sema_status.max_count) {
5046
iSignalSema(VBlankStartSema);
5147
}
52-
ExitHandler(); // From PS2SDK kernel.h
48+
ExitHandler();
5349
return 0;
5450
}
5551

56-
// Deinitialization services (from original main.c)
5752
static void DeinitServices(void)
5853
{
5954
DisableIntc(kINTC_VBLANK_START);
6055
RemoveIntcHandler(kINTC_VBLANK_START, 0);
6156
DeleteSema(VBlankStartSema);
6257
DeleteSema(InstallLockSema);
63-
64-
IopDeinit(); // From iop.c
65-
// PadDeinitPads(); // This is called within DeinitializeUI() in UI.c
58+
IopDeinit();
6659
}
6760

6861
// --- Main Application Entry Point ---
@@ -72,10 +65,12 @@ int main(int argc, char *argv[])
7265
int result_generic;
7366
unsigned int FrameNum;
7467
ee_sema_t sema_config;
75-
int current_event = MENU_EVENT_NONE; // Variable to hold event from MainMenu or submenus
68+
int current_event = MENU_EVENT_NONE;
7669

70+
// sio_init is called unconditionally, so <sio.h> must be included.
71+
// The DEBUG_PRINTF macro in main.h will handle whether sio_printf actually outputs.
7772
sio_init(38400, 0, 0, 0, 0);
78-
DEBUG_PRINTF("FMCB Installer v%s starting...\n", FMCB_INSTALLER_VERSION);
73+
DEBUG_PRINTF("FMCB Installer v%s starting...\n", FMCB_INSTALLER_VERSION); // FMCB_INSTALLER_VERSION is now from Makefile
7974

8075
for (result_generic = 0; result_generic < argc; result_generic++) {
8176
DEBUG_PRINTF("argv[%d] = %s\n", result_generic, argv[result_generic]);
@@ -92,12 +87,14 @@ int main(int argc, char *argv[])
9287

9388
sema_config.init_count = 0;
9489
sema_config.max_count = 1;
95-
sema_config.attr = EA_THPRI;
90+
sema_config.attr = 0; // <<< MODIFIED: Changed EA_THPRI to 0 for default attributes
9691
sema_config.option = 0;
9792
VBlankStartSema = CreateSema(&sema_config);
9893

9994
sema_config.init_count = 1;
10095
sema_config.max_count = 1;
96+
// Attribute for InstallLockSema can also be 0, or EA_THPRI if needed and available
97+
sema_config.attr = 0; // Ensuring consistency, was likely 0 in original too.
10198
InstallLockSema = CreateSema(&sema_config);
10299

103100
AddIntcHandler(kINTC_VBLANK_START, VBlankStartHandler, 0);
@@ -133,22 +130,19 @@ int main(int argc, char *argv[])
133130
}
134131
}
135132

136-
// Main application loop
137-
current_event = MENU_EVENT_RETURN_TO_MAIN; // Start by entering the main menu
133+
current_event = MENU_EVENT_RETURN_TO_MAIN;
138134

139135
while(current_event != EVENT_EXIT) {
140136
DEBUG_PRINTF("main.c: Top of event loop, current_event = %d\n", current_event);
141137
switch (current_event) {
142138
case MENU_EVENT_RETURN_TO_MAIN:
143139
DEBUG_PRINTF("main.c: Calling MainMenu()...\n");
144-
current_event = MainMenu(); // MainMenu now returns an int event
140+
current_event = MainMenu();
145141
DEBUG_PRINTF("main.c: MainMenu() returned event: %d\n", current_event);
146142
break;
147143

148144
case MENU_EVENT_GO_TO_OPENTUNA_INSTALL:
149145
DEBUG_PRINTF("main.c: Calling menu_opentuna_install()...\n");
150-
// Parameters for menu_opentuna_install are (int connecting_event, int current_selection)
151-
// We pass the event that led here, and 0 for default selection in the OpenTuna menu.
152146
current_event = menu_opentuna_install(MENU_EVENT_GO_TO_OPENTUNA_INSTALL, 0);
153147
DEBUG_PRINTF("main.c: menu_opentuna_install() returned event: %d\n", current_event);
154148
break;
@@ -160,17 +154,15 @@ int main(int argc, char *argv[])
160154

161155
case EVENT_EXIT:
162156
DEBUG_PRINTF("main.c: EVENT_EXIT received. Loop will terminate.\n");
163-
// The while loop condition (current_event != EVENT_EXIT) will handle actual termination.
164157
break;
165158

166159
default:
167160
DEBUG_PRINTF("main.c: Unhandled event %d received. Defaulting to MainMenu.\n", current_event);
168161
current_event = MENU_EVENT_RETURN_TO_MAIN;
169162
break;
170163
}
171-
} // End of while(current_event != EVENT_EXIT)
164+
}
172165

173-
// Shutdown sequence
174166
DEBUG_PRINTF("Exiting application (final event was %d)...\n", current_event);
175167
StopWorkerThread();
176168

installer/main.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#ifndef __MAIN_H__
22
#define __MAIN_H__
33

4-
// FMCB Installer version. Increment as needed.
5-
#define FMCB_INSTALLER_VERSION "1.001-MOD-OpenTuna" // Example version increment
4+
// FMCB Installer version will be defined by the Makefile via CFLAGS
5+
// #define FMCB_INSTALLER_VERSION "1.001-MOD-OpenTuna" // REMOVED THIS LINE
66

77
/* Debugging TTY output - comment out to disable */
88
// #define DEBUG_TTY_FEEDBACK
99
#ifdef DEBUG_TTY_FEEDBACK
10-
#include <sio.h>
10+
#include <sio.h> // For sio_printf
1111
#define DEBUG_PRINTF(args...) sio_printf(args)
1212
#else
1313
#define DEBUG_PRINTF(args...) (void)0

0 commit comments

Comments
 (0)