Skip to content

Commit

Permalink
raspberry pi port
Browse files Browse the repository at this point in the history
  • Loading branch information
DPRCZ authored and notaz committed Mar 7, 2013
1 parent 6a298de commit ffa573f
Show file tree
Hide file tree
Showing 15 changed files with 1,216 additions and 30 deletions.
4 changes: 4 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,8 @@ typedef u32 fixed8_24;
#include "pandora/pnd.h"
#endif

#ifdef RPI_BUILD
#include "raspberrypi/rpi.h"
#endif

#endif
35 changes: 26 additions & 9 deletions gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ typedef enum
NUMBER_SELECTION_OPTION = 0x01,
STRING_SELECTION_OPTION = 0x02,
SUBMENU_OPTION = 0x04,
ACTION_OPTION = 0x08
ACTION_OPTION = 0x08,
} menu_option_type_enum;

struct _menu_type
Expand Down Expand Up @@ -746,6 +746,13 @@ u32 gamepad_config_line_to_button[] =

#endif

#ifdef RPI_BUILD

u32 gamepad_config_line_to_button[] =
{ 0, 2, 1, 3, 8, 9, 10, 11, 6, 7, 4, 5, 12, 13, 14, 15 };

#endif

static const char *scale_options[] =
{
#ifdef PSP_BUILD
Expand All @@ -759,6 +766,8 @@ static const char *scale_options[] =
"unscaled", "2x", "3x", "fullscreen"
#elif defined(GP2X_BUILD)
"unscaled 3:2", "scaled 3:2", "fullscreen", "scaled 3:2 (software)"
#elif defined(RPI_BUILD)
"fullscreen"
#else
"unscaled 3:2"
#endif
Expand Down Expand Up @@ -843,10 +852,15 @@ s32 load_game_config_file()
if(file_loaded)
return 0;

#ifdef RPI_BUILD
current_frameskip_type = manual_frameskip;
frameskip_value = 1;
#else
current_frameskip_type = auto_frameskip;
frameskip_value = 4;
#ifdef POLLUX_BUILD
frameskip_value = 1;
#endif
#endif
random_skip = 0;
clock_speed = default_clock_speed;
Expand Down Expand Up @@ -1213,10 +1227,6 @@ u32 menu(u16 *original_screen)
reg[CHANGED_PC_STATUS] = 1;
menu_update_clock();
}
else
{
choose_menu(current_menu);
}
}

void menu_restart()
Expand Down Expand Up @@ -1329,8 +1339,9 @@ u32 menu(u16 *original_screen)
static const char *update_backup_options[] = { "Exit only", "Automatic" };

// Marker for help information, don't go past this mark (except \n)------*
menu_option_type graphics_sound_options[] =
{
menu_option_type graphics_sound_options[] =
{
#ifndef RPI_BUILD
string_selection_option(NULL, "Display scaling", scale_options,
(u32 *)(&screen_scale),
sizeof(scale_options) / sizeof(scale_options[0]),
Expand All @@ -1344,6 +1355,8 @@ u32 menu(u16 *original_screen)
#endif
#endif
"", 2),
#endif

#ifndef GP2X_BUILD
string_selection_option(NULL, "Screen filtering", yes_no_options,
(u32 *)(&screen_filter), 2,
Expand All @@ -1352,7 +1365,7 @@ u32 menu(u16 *original_screen)
"smooth image, at the cost of being blurry and having less vibrant\n"
"colors.", 3),
#endif
#ifdef PND_BUILD
#if defined (PND_BUILD)
string_selection_option(NULL, "Scaling filter", filter2_options,
(u32 *)(&screen_filter2),
sizeof(filter2_options) / sizeof(filter2_options[0]),
Expand Down Expand Up @@ -1572,7 +1585,7 @@ u32 menu(u16 *original_screen)

#endif

#ifdef PC_BUILD
#if defined(PC_BUILD) || defined(RPI_BUILD)

menu_option_type gamepad_config_options[] =
{
Expand Down Expand Up @@ -1801,6 +1814,10 @@ u32 menu(u16 *original_screen)

if(current_option->option_type & SUBMENU_OPTION)
choose_menu(current_option->sub_menu);

if(current_menu == &main_menu)
choose_menu(&main_menu);

break;

default:
Expand Down
122 changes: 109 additions & 13 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,49 @@ void init_input()
#endif


#if defined(RPI_BUILD)

#ifdef PC_BUILD
u32 key_map(SDLKey key_sym)
{
switch(key_sym)
{
case SDLK_a:
return BUTTON_L;

case SDLK_s:
return BUTTON_R;

case SDLK_DOWN:
return BUTTON_DOWN;

case SDLK_UP:
return BUTTON_UP;

case SDLK_LEFT:
return BUTTON_LEFT;

case SDLK_RIGHT:
return BUTTON_RIGHT;

case SDLK_RETURN:
return BUTTON_START;

case SDLK_BACKSPACE:
return BUTTON_SELECT;

case SDLK_x:
return BUTTON_B;

case SDLK_z:
return BUTTON_A;

default:
return BUTTON_NONE;
}
}
#endif

#if defined(PC_BUILD)

u32 key_map(SDLKey key_sym)
{
Expand Down Expand Up @@ -596,6 +637,8 @@ u32 key_map(SDLKey key_sym)
return BUTTON_NONE;
}
}
#endif
#if defined(PC_BUILD) || defined(RPI_BUILD)

u32 joy_map(u32 button)
{
Expand All @@ -607,16 +650,16 @@ u32 joy_map(u32 button)
case 5:
return BUTTON_R;

case 9:
case 2:
return BUTTON_START;

case 8:
case 3:
return BUTTON_SELECT;

case 0:
case 1:
return BUTTON_B;

case 1:
case 0:
return BUTTON_A;

default:
Expand All @@ -632,7 +675,7 @@ gui_action_type get_gui_input()
delay_us(30000);

while(SDL_PollEvent(&event))
{
{
switch(event.type)
{
case SDL_QUIT:
Expand Down Expand Up @@ -669,15 +712,49 @@ gui_action_type get_gui_input()
case SDLK_BACKSPACE:
gui_action = CURSOR_BACK;
break;
default:
break;
}
}
break;
#ifdef RPI_BUILD
case SDL_JOYBUTTONDOWN:
{
switch (event.jbutton.button)
{
case 2:
gui_action = CURSOR_BACK;
break;

default:
case 1:
gui_action = CURSOR_EXIT;
break;
}

case 0:
gui_action = CURSOR_SELECT;
break;
}
}
break;

case SDL_JOYAXISMOTION:
{
if (event.jaxis.axis==0) { //Left-Right
if (event.jaxis.value < -3200) gui_action = CURSOR_LEFT;
else if (event.jaxis.value > 3200) gui_action = CURSOR_RIGHT;
}
if (event.jaxis.axis==1) { //Up-Down
if (event.jaxis.value < -3200) gui_action = CURSOR_UP;
else if (event.jaxis.value > 3200) gui_action = CURSOR_DOWN;
}
}
break;

#endif
default:
break;
}
}
}

return gui_action;
}

Expand All @@ -698,8 +775,11 @@ u32 update_input()
{
quit();
}

#ifdef PC_BUILD
if(event.key.keysym.sym == SDLK_BACKSPACE)
#else
if(event.key.keysym.sym == SDLK_F10)
#endif
{
u16 *screen_copy = copy_screen();
u32 ret_val = menu(screen_copy);
Expand All @@ -708,7 +788,7 @@ u32 update_input()
return ret_val;
}
else

#ifdef PC_BUILD
if(event.key.keysym.sym == SDLK_F1)
{
debug_on();
Expand Down Expand Up @@ -741,7 +821,7 @@ u32 update_input()
dump_translation_cache();
}
else

#endif
if(event.key.keysym.sym == SDLK_F5)
{
char current_savestate_filename[512];
Expand Down Expand Up @@ -795,6 +875,22 @@ u32 update_input()
key &= ~(joy_map(event.jbutton.button));
break;
}
#ifdef RPI_BUILD
case SDL_JOYAXISMOTION:
{
if (event.jaxis.axis==0) { //Left-Right
key &= ~(BUTTON_LEFT|BUTTON_RIGHT);
if (event.jaxis.value < -3200) key |= BUTTON_LEFT;
else if (event.jaxis.value > 3200) key |= BUTTON_RIGHT;
}
if (event.jaxis.axis==1) { //Up-Down
key &= ~(BUTTON_UP|BUTTON_DOWN);
if (event.jaxis.value < -3200) key |= BUTTON_UP;
else if (event.jaxis.value > 3200) key |= BUTTON_DOWN;
}
break;
#endif
}
}
}

Expand Down
10 changes: 8 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ debug_state current_debug_state = RUN;

//u32 breakpoint_value = 0;

#ifdef RPI_BUILD
frameskip_type current_frameskip_type = manual_frameskip; //manual; //auto_frameskip;
u32 global_cycles_per_instruction = 1;
#else
frameskip_type current_frameskip_type = auto_frameskip;
u32 global_cycles_per_instruction = 1;
#endif

u32 random_skip = 0;
u32 fps_debug = 0;

Expand Down Expand Up @@ -821,7 +827,7 @@ void synchronize()
}
else if (synchronize_flag)
{
#if defined(PND_BUILD)
#if defined(PND_BUILD) || defined(RPI_BUILD)
fb_wait_vsync();
#elif !defined(GP2X_BUILD) // sleeping on GP2X is a bad idea
delay_us((u64)virtual_frame_count * 50000 / 3 - new_ticks + 2);
Expand Down Expand Up @@ -867,7 +873,7 @@ void synchronize()

interval_skipped_frames += skip_next_frame;

#if !defined(GP2X_BUILD) && !defined(PND_BUILD)
#if !defined(GP2X_BUILD) && !defined(PND_BUILD) && !defined(RPI_BUILD)
char char_buffer[64];
sprintf(char_buffer, "gpSP: %2d (%2d) fps", fps, frames_drawn);
SDL_WM_SetCaption(char_buffer, "gpSP");
Expand Down
44 changes: 44 additions & 0 deletions raspberrypi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# gpSP makefile
# Gilead Kutnick - Exophase
# pandora port - notaz
# respberry pi - DPR

# Global definitions

CC = gcc

OBJS = rpi.o 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\
gles_video.o video_blend.o

BIN = gpsp

# Platform specific definitions

VPATH += .. ../arm
CFLAGS += -DARM_ARCH -DRPI_BUILD -Wall
CFLAGS += -O3 -mfpu=vfp
CFLAGS += `sdl-config --cflags`
CFLAGS += -I$(SDKSTAGE)/opt/vc/include -I$(SDKSTAGE)/opt/vc/include/interface/vcos/pthreads

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

LIBS += `sdl-config --libs`
LIBS += -ldl -lpthread -lz
LIBS += -L$(SDKSTAGE)/opt/vc/lib/ -lGLESv2 -lEGL -lopenmaxil -lbcm_host -lvcos -lvchiq_arm -lrt

# Compilation:

all: $(BIN)

%.o: %.S
$(CC) $(CFLAGS) -c -o $@ $<


cpu.o cpu_threaded.o: CFLAGS += -Wno-unused-variable -Wno-unused-label

$(BIN): $(OBJS)
$(CC) $(OBJS) $(LIBS) -o $(BIN)

clean:
rm -f *.o $(BIN)
Loading

0 comments on commit ffa573f

Please sign in to comment.