Skip to content

Commit

Permalink
Adding option to boot from BIOS. Untested.
Browse files Browse the repository at this point in the history
  • Loading branch information
gameblabla committed Sep 20, 2020
1 parent 3b868b2 commit 58267cb
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
*.u
*.z
*.gcda
*.gba
*.bin
gpsp.gpe
tags
cscope.out
pandora/linux
bittboy/gpsp
x86/*.txt
bittboy/*.txt
x86/*.cfg
x86/gpsp
bittboy/*.cfg
8 changes: 4 additions & 4 deletions bittboy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Global definitions

CC = /opt/bittboy-toolchain/usr/bin/arm-miyoo-linux-musleabi-gcc
CC = /opt/bittboy-toolchain/usr/bin/arm-linux-gcc

OBJS = main.o cpu.o memory.o video.o input.o sound.o gui.o \
cheats.o zip.o arm_stub.o warm.o cpu_threaded.o video_blend.o sha1.o imageio.o
Expand All @@ -16,12 +16,12 @@ BIN = gpsp

VPATH += .. ../arm
CFLAGS += -DARM_ARCH -DPC_BUILD -DBITTBOY -Wall
CFLAGS += -Ofast -fdata-sections -ffunction-sections -flto -fno-PIC -fprofile-use
CFLAGS += `/opt/bittboy-toolchain/arm-miyoo-linux-musleabi/sysroot/usr/bin/sdl-config --cflags`
CFLAGS += -Ofast -fdata-sections -ffunction-sections -fsingle-precision-constant -fno-PIC -flto -march=armv5te -mtune=arm926ej-s -fprofile-generate=./profile
CFLAGS += `/opt/bittboy-toolchain/arm-buildroot-linux-musleabi/sysroot/usr/bin/sdl-config --cflags`

# expecting to have PATH set up to get correct sdl-config first

LIBS = -lc -lgcc -lSDL -lpng -lasound -lz -Wl,--as-needed -Wl,--gc-sections -flto -s
LIBS = -nodefaultlibs -lc -lgcc -lSDL -lpng -lasound -lz -Wl,--as-needed -Wl,--gc-sections -flto -s

# Compilation:

Expand Down
6 changes: 4 additions & 2 deletions cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4429,7 +4429,7 @@ void execute_arm(u32 cycles)
}
}

void init_cpu()
void init_cpu(uint32_t BootFromBIOS)
{
u32 i;

Expand All @@ -4439,7 +4439,9 @@ void init_cpu()
}

reg[REG_SP] = 0x03007F00;
reg[REG_PC] = 0x08000000;
reg[REG_PC] = BootFromBIOS
? 0x00000000
: 0x08000000;
reg[REG_CPSR] = 0x0000001F;
reg[CPU_HALT_STATE] = CPU_ACTIVE;
reg[CPU_MODE] = MODE_USER;
Expand Down
2 changes: 1 addition & 1 deletion cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ extern u32 memory_writes_u8;
extern u32 memory_writes_u16;
extern u32 memory_writes_u32;

void init_cpu();
void init_cpu(uint32_t BootFromBIOS);
void move_reg();

#endif
19 changes: 18 additions & 1 deletion gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "common.h"
#include "font.h"

extern u32 BootBIOS;

#ifndef _WIN32_WCE

#include <sys/stat.h>
Expand Down Expand Up @@ -986,6 +988,8 @@ s32 load_config_file()
gamepad_config_map[PLAT_MENU_BUTTON] = BUTTON_ID_MENU;
}*/
#endif
BootBIOS = file_options[FILE_OPTION_COUNT-1];

file_close(config_file);
}

Expand Down Expand Up @@ -1060,6 +1064,8 @@ s32 save_config_file()
}
#endif

file_options[FILE_OPTION_COUNT-1] = BootBIOS;

file_write_array(config_file, file_options);

file_close(config_file);
Expand Down Expand Up @@ -1259,6 +1265,12 @@ u32 menu(u16 *original_screen)
menu_update_clock();
}
}

void menu_bios()
{
if (BootBIOS == 1) BootBIOS = 0;
else BootBIOS = 1;
}

void menu_restart()
{
Expand Down Expand Up @@ -1682,8 +1694,13 @@ u32 menu(u16 *original_screen)
"loaded.", 9),
action_option(menu_exit, NULL, "Return to game",
"Select to exit this menu and resume gameplay.", 10),

numeric_selection_action_option(menu_bios, NULL,
"Boot to BIOS : ", &BootBIOS, 2,
"0 for no, 1 for YES", 11),

action_option(menu_quit, NULL, "Exit gpSP",
"Select to exit gpSP and return to the menu.", 12)
"Select to exit gpSP and return to the menu.", 13)
};

make_menu(main, submenu_main, NULL);
Expand Down
8 changes: 5 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "common.h"

u32 BootBIOS = 0;

#ifdef PSP_BUILD

//PSP_MODULE_INFO("gpSP", 0x1000, 0, 6);
Expand Down Expand Up @@ -328,7 +330,7 @@ int main(int argc, char *argv[])
set_gba_resolution(screen_scale);
video_resolution_small();

init_cpu();
init_cpu(BootBIOS);
init_memory();
}
else
Expand All @@ -353,7 +355,7 @@ int main(int argc, char *argv[])
set_gba_resolution(screen_scale);
video_resolution_small();

init_cpu();
init_cpu(BootBIOS);
init_memory();
}
}
Expand Down Expand Up @@ -908,7 +910,7 @@ void reset_gba()
{
init_main();
init_memory();
init_cpu();
init_cpu(BootBIOS);
reset_sound();
}

Expand Down
6 changes: 3 additions & 3 deletions x86/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ AS = as

PREFIX = /usr
OBJS = main.o cpu.o memory.o video.o input.o sound.o \
cpu_threaded.o gui.o x86_stub.o cheats.o zip.o sha1.o
cpu_threaded.o gui.o x86_stub.o cheats.o zip.o sha1.o imageio.o
BIN ?= gpsp

# Platform specific definitions

VPATH += ..
CFLAGS += -DPC_BUILD -Wall -m32
CFLAGS += -DPC_BUILD -Wall -m32 -O0 -g
INCLUDES = `sdl-config --cflags`
LIBS = `sdl-config --libs` -lz -m32
LIBS = `sdl-config --libs` -lz -m32 -lpng

# Compilation:

Expand Down

1 comment on commit 58267cb

@gameblabla
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, it does work fine.

Please sign in to comment.