extracted OSS code to sndout_oss_*, BTN->PBTN, refactoring

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@599 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-10-17 15:29:37 +00:00
parent 7b3f44c6b6
commit e5ab6fafac
25 changed files with 497 additions and 589 deletions

View file

@ -3,17 +3,17 @@
#ifdef __GP2X__ #ifdef __GP2X__
#include "../gp2x/gp2x.h" #include "../gp2x/gp2x.h"
#define BTN_UP GP2X_UP #define PBTN_UP GP2X_UP
#define BTN_DOWN GP2X_DOWN #define PBTN_DOWN GP2X_DOWN
#define BTN_LEFT GP2X_LEFT #define PBTN_LEFT GP2X_LEFT
#define BTN_RIGHT GP2X_RIGHT #define PBTN_RIGHT GP2X_RIGHT
#define BTN_NORTH GP2X_Y #define PBTN_NORTH GP2X_Y
#define BTN_SOUTH GP2X_X #define PBTN_SOUTH GP2X_X
#define BTN_WEST GP2X_A #define PBTN_WEST GP2X_A
#define BTN_EAST GP2X_B #define PBTN_EAST GP2X_B
#define BTN_L GP2X_L #define PBTN_L GP2X_L
#define BTN_R GP2X_R #define PBTN_R GP2X_R
unsigned long wait_for_input(unsigned long interesting); unsigned long wait_for_input(unsigned long interesting);
void gp2x_pd_clone_buffer2(void); void gp2x_pd_clone_buffer2(void);
@ -43,10 +43,10 @@ void menu_flip(void);
#include "../gizmondo/giz.h" #include "../gizmondo/giz.h"
#define BTN_NORTH BTN_STOP #define PBTN_NORTH PBTN_STOP
#define BTN_SOUTH BTN_PLAY #define PBTN_SOUTH PBTN_PLAY
#define BTN_WEST BTN_REW #define PBTN_WEST PBTN_REW
#define BTN_EAST BTN_FWD #define PBTN_EAST PBTN_FWD
unsigned long wait_for_input(unsigned int interesting); unsigned long wait_for_input(unsigned int interesting);
void menu_draw_begin(int use_bgbuff); void menu_draw_begin(int use_bgbuff);
@ -75,10 +75,10 @@ extern void *giz_screen;
#include "../psp/psp.h" #include "../psp/psp.h"
#define BTN_NORTH BTN_TRIANGLE #define PBTN_NORTH PBTN_TRIANGLE
#define BTN_SOUTH BTN_X #define PBTN_SOUTH PBTN_X
#define BTN_WEST BTN_SQUARE #define PBTN_WEST PBTN_SQUARE
#define BTN_EAST BTN_CIRCLE #define PBTN_EAST PBTN_CIRCLE
unsigned long wait_for_input(unsigned int interesting, int is_key_config); unsigned long wait_for_input(unsigned int interesting, int is_key_config);
void menu_draw_begin(void); void menu_draw_begin(void);
@ -106,17 +106,17 @@ void menu_draw_end(void);
#include "../gp2x/gp2x.h" #include "../gp2x/gp2x.h"
#define BTN_UP 0 #define PBTN_UP 0
#define BTN_DOWN 0 #define PBTN_DOWN 0
#define BTN_LEFT 0 #define PBTN_LEFT 0
#define BTN_RIGHT 0 #define PBTN_RIGHT 0
#define BTN_NORTH 0 #define PBTN_NORTH 0
#define BTN_SOUTH 0 #define PBTN_SOUTH 0
#define BTN_WEST 0 #define PBTN_WEST 0
#define BTN_EAST 0 #define PBTN_EAST 0
#define BTN_L 0 #define PBTN_L 0
#define BTN_R 0 #define PBTN_R 0
unsigned long wait_for_input(unsigned long interesting); unsigned long wait_for_input(unsigned long interesting);
void gp2x_pd_clone_buffer2(void); void gp2x_pd_clone_buffer2(void);

View file

@ -350,7 +350,7 @@ static void mplayer_loop(void)
while (1) while (1)
{ {
PDebugZ80Frame(); PDebugZ80Frame();
if (read_buttons_async(BTN_NORTH)) break; if (read_buttons_async(PBTN_NORTH)) break;
emu_waitSound(); emu_waitSound();
} }
@ -429,41 +429,41 @@ void debug_menu_loop(void)
} }
menu_draw_end(); menu_draw_end();
inp = read_buttons(BTN_EAST|BTN_SOUTH|BTN_WEST|BTN_NORTH|BTN_L|BTN_R|BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT); inp = read_buttons(PBTN_EAST|PBTN_SOUTH|PBTN_WEST|PBTN_NORTH|PBTN_L|PBTN_R|PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT);
if (inp & BTN_SOUTH) return; if (inp & PBTN_SOUTH) return;
if (inp & BTN_L) { mode--; if (mode < 0) mode = 3; } if (inp & PBTN_L) { mode--; if (mode < 0) mode = 3; }
if (inp & BTN_R) { mode++; if (mode > 3) mode = 0; } if (inp & PBTN_R) { mode++; if (mode > 3) mode = 0; }
switch (mode) switch (mode)
{ {
case 0: case 0:
if (inp & BTN_EAST) SekStepM68k(); if (inp & PBTN_EAST) SekStepM68k();
if (inp & BTN_NORTH) { if (inp & PBTN_NORTH) {
while (inp & BTN_NORTH) inp = read_buttons_async(BTN_NORTH); while (inp & PBTN_NORTH) inp = read_buttons_async(PBTN_NORTH);
mplayer_loop(); mplayer_loop();
} }
if ((inp & (BTN_WEST|BTN_LEFT)) == (BTN_WEST|BTN_LEFT)) { if ((inp & (PBTN_WEST|PBTN_LEFT)) == (PBTN_WEST|PBTN_LEFT)) {
mkdir("dumps", 0777); mkdir("dumps", 0777);
PDebugDumpMem(); PDebugDumpMem();
while (inp & BTN_WEST) inp = read_buttons_async(BTN_WEST); while (inp & PBTN_WEST) inp = read_buttons_async(PBTN_WEST);
dumped = 1; dumped = 1;
} }
break; break;
case 1: case 1:
if (inp & BTN_LEFT) PicoDrawMask ^= PDRAW_LAYERB_ON; if (inp & PBTN_LEFT) PicoDrawMask ^= PDRAW_LAYERB_ON;
if (inp & BTN_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON; if (inp & PBTN_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON;
if (inp & BTN_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON; if (inp & PBTN_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON;
if (inp & BTN_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON; if (inp & PBTN_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON;
if (inp & BTN_EAST) { if (inp & PBTN_EAST) {
PsndOut = NULL; // just in case PsndOut = NULL; // just in case
PicoSkipFrame = 1; PicoSkipFrame = 1;
PicoFrame(); PicoFrame();
PicoSkipFrame = 0; PicoSkipFrame = 0;
while (inp & BTN_EAST) inp = read_buttons_async(BTN_EAST); while (inp & PBTN_EAST) inp = read_buttons_async(PBTN_EAST);
} }
break; break;
case 3: case 3:
if (inp & BTN_DOWN) spr_offs++; if (inp & PBTN_DOWN) spr_offs++;
if (inp & BTN_UP) spr_offs--; if (inp & PBTN_UP) spr_offs--;
if (spr_offs < 0) spr_offs = 0; if (spr_offs < 0) spr_offs = 0;
break; break;
} }

View file

@ -390,10 +390,10 @@ static void RunEvents(unsigned int which)
{ {
int keys; int keys;
blit("", (which & 0x1000) ? "LOAD STATE? (PLAY=yes, STOP=no)" : "OVERWRITE SAVE? (PLAY=yes, STOP=no)"); blit("", (which & 0x1000) ? "LOAD STATE? (PLAY=yes, STOP=no)" : "OVERWRITE SAVE? (PLAY=yes, STOP=no)");
while( !((keys = Framework_PollGetButtons()) & (BTN_PLAY|BTN_STOP)) ) while( !((keys = Framework_PollGetButtons()) & (PBTN_PLAY|PBTN_STOP)) )
Sleep(50); Sleep(50);
if (keys & BTN_STOP) do_it = 0; if (keys & PBTN_STOP) do_it = 0;
while( ((keys = Framework_PollGetButtons()) & (BTN_PLAY|BTN_STOP)) ) // wait for release while( ((keys = Framework_PollGetButtons()) & (PBTN_PLAY|PBTN_STOP)) ) // wait for release
Sleep(50); Sleep(50);
clearArea(0); clearArea(0);
} }
@ -449,7 +449,7 @@ static void updateKeys(void)
int i; int i;
keys = Framework_PollGetButtons(); keys = Framework_PollGetButtons();
if (keys & BTN_HOME) if (keys & PBTN_HOME)
engineState = PGS_Menu; engineState = PGS_Menu;
keys &= CONFIGURABLE_KEYS; keys &= CONFIGURABLE_KEYS;

View file

@ -43,20 +43,20 @@ enum FRAMEWORK_BUTTONTYPES
}; };
#endif #endif
#define BTN_LEFT (1 << FRAMEWORK_BUTTON_DPAD_LEFT) #define PBTN_LEFT (1 << FRAMEWORK_BUTTON_DPAD_LEFT)
#define BTN_RIGHT (1 << FRAMEWORK_BUTTON_DPAD_RIGHT) #define PBTN_RIGHT (1 << FRAMEWORK_BUTTON_DPAD_RIGHT)
#define BTN_UP (1 << FRAMEWORK_BUTTON_DPAD_UP) #define PBTN_UP (1 << FRAMEWORK_BUTTON_DPAD_UP)
#define BTN_DOWN (1 << FRAMEWORK_BUTTON_DPAD_DOWN) #define PBTN_DOWN (1 << FRAMEWORK_BUTTON_DPAD_DOWN)
#define BTN_STOP (1 << FRAMEWORK_BUTTON_STOP) #define PBTN_STOP (1 << FRAMEWORK_BUTTON_STOP)
#define BTN_PLAY (1 << FRAMEWORK_BUTTON_PLAY) #define PBTN_PLAY (1 << FRAMEWORK_BUTTON_PLAY)
#define BTN_FWD (1 << FRAMEWORK_BUTTON_FORWARD) #define PBTN_FWD (1 << FRAMEWORK_BUTTON_FORWARD)
#define BTN_REW (1 << FRAMEWORK_BUTTON_REWIND) #define PBTN_REW (1 << FRAMEWORK_BUTTON_REWIND)
#define BTN_L (1 << FRAMEWORK_BUTTON_LEFT_SHOULDER) #define PBTN_L (1 << FRAMEWORK_BUTTON_LEFT_SHOULDER)
#define BTN_R (1 << FRAMEWORK_BUTTON_RIGHT_SHOULDER) #define PBTN_R (1 << FRAMEWORK_BUTTON_RIGHT_SHOULDER)
#define BTN_HOME (1 << FRAMEWORK_BUTTON_HOME) #define PBTN_HOME (1 << FRAMEWORK_BUTTON_HOME)
#define BTN_VOLUME (1 << FRAMEWORK_BUTTON_VOLUME) #define PBTN_VOLUME (1 << FRAMEWORK_BUTTON_VOLUME)
#define BTN_BRIGHTNESS (1 << FRAMEWORK_BUTTON_BRIGHTNESS) #define PBTN_BRIGHTNESS (1 << FRAMEWORK_BUTTON_BRIGHTNESS)
#define BTN_ALARM (1 << FRAMEWORK_BUTTON_ALARM) #define PBTN_ALARM (1 << FRAMEWORK_BUTTON_ALARM)
#define BTN_POWER (1 << FRAMEWORK_BUTTON_POWER) #define PBTN_POWER (1 << FRAMEWORK_BUTTON_POWER)

View file

@ -71,15 +71,15 @@ unsigned long wait_for_input(unsigned int interesting)
repeats = 0; repeats = 0;
wait = 20; wait = 20;
} }
if (wait > 6 && (ret&(BTN_UP|BTN_LEFT|BTN_DOWN|BTN_RIGHT|BTN_L|BTN_R))) if (wait > 6 && (ret&(PBTN_UP|PBTN_LEFT|PBTN_DOWN|PBTN_RIGHT|PBTN_L|PBTN_R)))
wait = 6; wait = 6;
inp_prev = ret; inp_prev = ret;
// we don't need diagonals in menus // we don't need diagonals in menus
if ((ret&BTN_UP) && (ret&BTN_LEFT)) ret &= ~BTN_LEFT; if ((ret&PBTN_UP) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret&BTN_UP) && (ret&BTN_RIGHT)) ret &= ~BTN_RIGHT; if ((ret&PBTN_UP) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
if ((ret&BTN_DOWN) && (ret&BTN_LEFT)) ret &= ~BTN_LEFT; if ((ret&PBTN_DOWN) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret&BTN_DOWN) && (ret&BTN_RIGHT)) ret &= ~BTN_RIGHT; if ((ret&PBTN_DOWN) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
return ret; return ret;
} }
@ -386,14 +386,14 @@ static char *romsel_loop(char *curr_path)
for (;;) for (;;)
{ {
draw_dirlist(curr_path, namelist, n, sel); draw_dirlist(curr_path, namelist, n, sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_L|BTN_R|BTN_PLAY|BTN_STOP); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);
if(inp & BTN_UP ) { sel--; if (sel < 0) sel = n-2; } if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }
if(inp & BTN_DOWN) { sel++; if (sel > n-2) sel = 0; } if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }
if(inp & BTN_LEFT) { sel-=10; if (sel < 0) sel = 0; } if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }
if(inp & BTN_L) { sel-=24; if (sel < 0) sel = 0; } if(inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; }
if(inp & BTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } if(inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }
if(inp & BTN_R) { sel+=24; if (sel > n-2) sel = n-2; } if(inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; }
if(inp & BTN_PLAY) { // enter dir/select if(inp & PBTN_PLAY) { // enter dir/select
if (namelist[sel+1]->d_type == DT_REG) { if (namelist[sel+1]->d_type == DT_REG) {
strcpy(romFileName, curr_path); strcpy(romFileName, curr_path);
strcat(romFileName, "/"); strcat(romFileName, "/");
@ -422,7 +422,7 @@ static char *romsel_loop(char *curr_path)
break; break;
} }
} }
if(inp & BTN_STOP) break; // cancel if(inp & PBTN_STOP) break; // cancel
} }
if (n > 0) { if (n > 0) {
@ -473,17 +473,17 @@ static void patches_menu_loop(void)
for(;;) for(;;)
{ {
draw_patchlist(menu_sel); draw_patchlist(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_L|BTN_R|BTN_PLAY|BTN_STOP); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);
if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }
if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }
if(inp &(BTN_LEFT|BTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }
if(inp &(BTN_RIGHT|BTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; } if(inp &(PBTN_RIGHT|PBTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; }
if(inp & BTN_PLAY) { // action if(inp & PBTN_PLAY) { // action
if (menu_sel < PicoPatchCount) if (menu_sel < PicoPatchCount)
PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active; PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active;
else return; else return;
} }
if(inp & BTN_STOP) return; if(inp & PBTN_STOP) return;
} }
} }
@ -593,18 +593,18 @@ static int savestate_menu_loop(int is_loading)
for(;;) for(;;)
{ {
draw_savestate_menu(menu_sel, is_loading); draw_savestate_menu(menu_sel, is_loading);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY|BTN_STOP); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);
if(inp & BTN_UP ) { if(inp & PBTN_UP ) {
do { do {
menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max;
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);
} }
if(inp & BTN_DOWN) { if(inp & PBTN_DOWN) {
do { do {
menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0;
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);
} }
if(inp & BTN_PLAY) { // save/load if(inp & PBTN_PLAY) { // save/load
if (menu_sel < 10) { if (menu_sel < 10) {
state_slot = menu_sel; state_slot = menu_sel;
PicoStateProgressCB = emu_stateCb; /* also suitable for menu */ PicoStateProgressCB = emu_stateCb; /* also suitable for menu */
@ -615,7 +615,7 @@ static int savestate_menu_loop(int is_loading)
return 0; return 0;
} else return 1; } else return 1;
} }
if(inp & BTN_STOP) return 1; if(inp & PBTN_STOP) return 1;
} }
} }
@ -703,22 +703,22 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
for (;;) for (;;)
{ {
draw_key_config(opts, opt_cnt, player_idx, sel); draw_key_config(opts, opt_cnt, player_idx, sel);
inp = wait_for_input(CONFIGURABLE_KEYS|BTN_HOME); inp = wait_for_input(CONFIGURABLE_KEYS|PBTN_HOME);
if (!(inp & BTN_HOME)) { if (!(inp & PBTN_HOME)) {
prev_select = 0; prev_select = 0;
if(inp & BTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; } if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }
if(inp & BTN_DOWN) { sel++; if (sel > menu_sel_max) sel = 0; continue; } if(inp & PBTN_DOWN) { sel++; if (sel > menu_sel_max) sel = 0; continue; }
} }
if (sel >= opt_cnt) { if (sel >= opt_cnt) {
if (inp & (BTN_PLAY|BTN_STOP)) break; if (inp & (PBTN_PLAY|PBTN_STOP)) break;
else continue; else continue;
} }
// if we are here, we want to bind/unbind something // if we are here, we want to bind/unbind something
if ((inp & BTN_HOME) && !prev_select) if ((inp & PBTN_HOME) && !prev_select)
unbind_action(opts[sel].mask); unbind_action(opts[sel].mask);
prev_select = inp & BTN_HOME; prev_select = inp & PBTN_HOME;
inp &= CONFIGURABLE_KEYS; inp &= CONFIGURABLE_KEYS;
inp &= ~BTN_HOME; inp &= ~PBTN_HOME;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
if (inp & (1 << i)) { if (inp & (1 << i)) {
if (count_bound_keys(opts[sel].mask, player_idx) >= 2) if (count_bound_keys(opts[sel].mask, player_idx) >= 2)
@ -783,13 +783,13 @@ static void kc_sel_loop(void)
while (1) while (1)
{ {
draw_kc_sel(menu_sel); draw_kc_sel(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY|BTN_STOP); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);
selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel);
if (inp & (BTN_LEFT|BTN_RIGHT)) // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise
me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0); me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if (inp & BTN_PLAY) { if (inp & PBTN_PLAY) {
int is_6button = PicoOpt & 0x020; int is_6button = PicoOpt & 0x020;
switch (selected_id) { switch (selected_id) {
case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return; case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return;
@ -800,7 +800,7 @@ static void kc_sel_loop(void)
default: return; default: return;
} }
} }
if (inp & BTN_STOP) return; if (inp & PBTN_STOP) return;
} }
} }
@ -904,14 +904,14 @@ static void cd_menu_loop_options(void)
for(;;) for(;;)
{ {
draw_cd_menu_options(menu_sel, &bios_names); draw_cd_menu_options(menu_sel, &bios_names);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_PLAY|BTN_STOP|BTN_REW); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel);
if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise
if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) && if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) &&
selected_id == MA_CDOPT_READAHEAD) { selected_id == MA_CDOPT_READAHEAD) {
if (inp & BTN_LEFT) { if (inp & PBTN_LEFT) {
PicoCDBuffers >>= 1; PicoCDBuffers >>= 1;
if (PicoCDBuffers < 2) PicoCDBuffers = 0; if (PicoCDBuffers < 2) PicoCDBuffers = 0;
} else { } else {
@ -921,7 +921,7 @@ static void cd_menu_loop_options(void)
} }
} }
} }
if (inp & BTN_PLAY) { // toggleable options if (inp & PBTN_PLAY) { // toggleable options
if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, 1) && if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, 1) &&
selected_id == MA_CDOPT_DONE) { selected_id == MA_CDOPT_DONE) {
return; return;
@ -952,7 +952,7 @@ static void cd_menu_loop_options(void)
break; break;
} }
} }
if (inp & (BTN_STOP|BTN_REW)) return; if (inp & (PBTN_STOP|PBTN_REW)) return;
} }
} }
@ -1003,15 +1003,15 @@ static void amenu_loop_options(void)
for(;;) for(;;)
{ {
draw_amenu_options(menu_sel); draw_amenu_options(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_PLAY|BTN_STOP|BTN_REW); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel);
if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise
if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) && if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) &&
selected_id == MA_OPT2_GAMMA) { selected_id == MA_OPT2_GAMMA) {
while ((inp = Framework_PollGetButtons()) & (BTN_LEFT|BTN_RIGHT)) { while ((inp = Framework_PollGetButtons()) & (PBTN_LEFT|PBTN_RIGHT)) {
currentConfig.gamma += (inp & BTN_LEFT) ? -1 : 1; currentConfig.gamma += (inp & PBTN_LEFT) ? -1 : 1;
if (currentConfig.gamma < 1) currentConfig.gamma = 1; if (currentConfig.gamma < 1) currentConfig.gamma = 1;
if (currentConfig.gamma > 300) currentConfig.gamma = 300; if (currentConfig.gamma > 300) currentConfig.gamma = 300;
draw_amenu_options(menu_sel); draw_amenu_options(menu_sel);
@ -1019,13 +1019,13 @@ static void amenu_loop_options(void)
} }
} }
} }
if (inp & BTN_PLAY) { // toggleable options if (inp & PBTN_PLAY) { // toggleable options
if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, 1) && if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, 1) &&
selected_id == MA_OPT2_DONE) { selected_id == MA_OPT2_DONE) {
return; return;
} }
} }
if (inp & (BTN_STOP|BTN_REW)) return; if (inp & (PBTN_STOP|PBTN_REW)) return;
} }
} }
@ -1187,15 +1187,15 @@ static int menu_loop_options(void)
while (1) while (1)
{ {
draw_menu_options(menu_sel); draw_menu_options(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_PLAY|BTN_STOP|BTN_REW); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);
if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise
if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0)) { if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0)) {
switch (selected_id) { switch (selected_id) {
case MA_OPT_RENDERER: case MA_OPT_RENDERER:
if (inp & BTN_LEFT) { if (inp & PBTN_LEFT) {
if ((PicoOpt&0x10) || !(currentConfig.EmuOpt &0x80)) { if ((PicoOpt&0x10) || !(currentConfig.EmuOpt &0x80)) {
PicoOpt&= ~0x10; PicoOpt&= ~0x10;
currentConfig.EmuOpt |= 0x80; currentConfig.EmuOpt |= 0x80;
@ -1208,25 +1208,25 @@ static int menu_loop_options(void)
} }
break; break;
case MA_OPT_SOUND_QUALITY: case MA_OPT_SOUND_QUALITY:
if ((inp & BTN_RIGHT) && PsndRate == 44100 && if ((inp & PBTN_RIGHT) && PsndRate == 44100 &&
!(PicoOpt&0x08)) !(PicoOpt&0x08))
{ {
PsndRate = 11025; PsndRate = 11025;
PicoOpt |= 8; PicoOpt |= 8;
} else if ((inp & BTN_LEFT) && PsndRate == 11025 && } else if ((inp & PBTN_LEFT) && PsndRate == 11025 &&
(PicoOpt&0x08) && !(PicoAHW&1)) (PicoOpt&0x08) && !(PicoAHW&1))
{ {
PsndRate = 44100; PsndRate = 44100;
PicoOpt &= ~8; PicoOpt &= ~8;
} else } else
PsndRate = sndrate_prevnext(PsndRate, inp & BTN_RIGHT); PsndRate = sndrate_prevnext(PsndRate, inp & PBTN_RIGHT);
break; break;
case MA_OPT_REGION: case MA_OPT_REGION:
region_prevnext(inp & BTN_RIGHT); region_prevnext(inp & PBTN_RIGHT);
break; break;
case MA_OPT_CONFIRM_STATES: { case MA_OPT_CONFIRM_STATES: {
int n = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2); int n = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2);
n += (inp & BTN_LEFT) ? -1 : 1; n += (inp & PBTN_LEFT) ? -1 : 1;
if (n < 0) n = 0; else if (n > 3) n = 3; if (n < 0) n = 0; else if (n > 3) n = 3;
n |= n << 1; n &= ~2; n |= n << 1; n &= ~2;
currentConfig.EmuOpt &= ~0xa00; currentConfig.EmuOpt &= ~0xa00;
@ -1234,7 +1234,7 @@ static int menu_loop_options(void)
break; break;
} }
case MA_OPT_SAVE_SLOT: case MA_OPT_SAVE_SLOT:
if (inp & BTN_RIGHT) { if (inp & PBTN_RIGHT) {
state_slot++; if (state_slot > 9) state_slot = 0; state_slot++; if (state_slot > 9) state_slot = 0;
} else {state_slot--; if (state_slot < 0) state_slot = 9; } else {state_slot--; if (state_slot < 0) state_slot = 9;
} }
@ -1242,7 +1242,7 @@ static int menu_loop_options(void)
case MA_OPT_SAVECFG: case MA_OPT_SAVECFG:
case MA_OPT_SAVECFG_GAME: case MA_OPT_SAVECFG_GAME:
case MA_OPT_LOADCFG: case MA_OPT_LOADCFG:
config_slot += (inp&BTN_RIGHT) ? 1 : -1; config_slot += (inp&PBTN_RIGHT) ? 1 : -1;
if (config_slot > 9) config_slot = 0; if (config_slot > 9) config_slot = 0;
if (config_slot < 0) config_slot = 9; if (config_slot < 0) config_slot = 9;
me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current); me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);
@ -1255,7 +1255,7 @@ static int menu_loop_options(void)
} }
} }
} }
if (inp & BTN_PLAY) { if (inp & PBTN_PLAY) {
if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, 1)) if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, 1))
{ {
switch (selected_id) switch (selected_id)
@ -1290,7 +1290,7 @@ static int menu_loop_options(void)
} }
} }
} }
if(inp & (BTN_STOP|BTN_REW)) { if(inp & (PBTN_STOP|PBTN_REW)) {
menu_options_save(); menu_options_save();
return 0; // done (update, no write) return 0; // done (update, no write)
} }
@ -1383,28 +1383,28 @@ static void menu_loop_root(void)
/* make sure action buttons are not pressed on entering menu */ /* make sure action buttons are not pressed on entering menu */
draw_menu_root(menu_sel); draw_menu_root(menu_sel);
while (Framework_PollGetButtons() & (BTN_PLAY|BTN_STOP|BTN_HOME)) Sleep(50); while (Framework_PollGetButtons() & (PBTN_PLAY|PBTN_STOP|PBTN_HOME)) Sleep(50);
for (;;) for (;;)
{ {
draw_menu_root(menu_sel); draw_menu_root(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY|BTN_STOP|BTN_HOME|BTN_L|BTN_R); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP|PBTN_HOME|PBTN_L|PBTN_R);
if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if((inp & (BTN_L|BTN_R)) == (BTN_L|BTN_R)) debug_menu_loop(); if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop();
if( inp & (BTN_HOME|BTN_STOP)) { if( inp & (PBTN_HOME|PBTN_STOP)) {
if (rom_loaded) { if (rom_loaded) {
while (Framework_PollGetButtons() & (BTN_HOME|BTN_STOP)) Sleep(50); // wait until released while (Framework_PollGetButtons() & (PBTN_HOME|PBTN_STOP)) Sleep(50); // wait until released
engineState = PGS_Running; engineState = PGS_Running;
break; break;
} }
} }
if(inp & BTN_PLAY) { if(inp & PBTN_PLAY) {
switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel)) switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel))
{ {
case MA_MAIN_RESUME_GAME: case MA_MAIN_RESUME_GAME:
if (rom_loaded) { if (rom_loaded) {
while (Framework_PollGetButtons() & BTN_PLAY) Sleep(50); while (Framework_PollGetButtons() & PBTN_PLAY) Sleep(50);
engineState = PGS_Running; engineState = PGS_Running;
return; return;
} }
@ -1421,7 +1421,7 @@ static void menu_loop_root(void)
if (rom_loaded) { if (rom_loaded) {
if(savestate_menu_loop(1)) if(savestate_menu_loop(1))
continue; continue;
while (Framework_PollGetButtons() & BTN_PLAY) Sleep(50); while (Framework_PollGetButtons() & PBTN_PLAY) Sleep(50);
engineState = PGS_Running; engineState = PGS_Running;
return; return;
} }
@ -1429,7 +1429,7 @@ static void menu_loop_root(void)
case MA_MAIN_RESET_GAME: case MA_MAIN_RESET_GAME:
if (rom_loaded) { if (rom_loaded) {
emu_ResetGame(); emu_ResetGame();
while (Framework_PollGetButtons() & BTN_PLAY) Sleep(50); while (Framework_PollGetButtons() & PBTN_PLAY) Sleep(50);
engineState = PGS_Running; engineState = PGS_Running;
return; return;
} }
@ -1465,7 +1465,7 @@ static void menu_loop_root(void)
case MA_MAIN_CREDITS: case MA_MAIN_CREDITS:
draw_menu_credits(); draw_menu_credits();
Sleep(500); Sleep(500);
inp = wait_for_input(BTN_PLAY|BTN_STOP); inp = wait_for_input(PBTN_PLAY|PBTN_STOP);
break; break;
case MA_MAIN_EXIT: case MA_MAIN_EXIT:
engineState = PGS_Quit; engineState = PGS_Quit;
@ -1598,15 +1598,15 @@ int menu_loop_tray(void)
/* make sure action buttons are not pressed on entering menu */ /* make sure action buttons are not pressed on entering menu */
draw_menu_tray(menu_sel); draw_menu_tray(menu_sel);
while (Framework_PollGetButtons() & BTN_PLAY) Sleep(50); while (Framework_PollGetButtons() & PBTN_PLAY) Sleep(50);
for (;;) for (;;)
{ {
draw_menu_tray(menu_sel); draw_menu_tray(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY);
if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if(inp & BTN_PLAY ) { if(inp & PBTN_PLAY) {
switch (menu_sel) { switch (menu_sel) {
case 0: // select image case 0: // select image
selfname = romsel_loop(curr_path); selfname = romsel_loop(curr_path);

View file

@ -10,6 +10,6 @@ void menu_romload_end(void);
#define CONFIGURABLE_KEYS \ #define CONFIGURABLE_KEYS \
(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_STOP|BTN_PLAY|BTN_FWD|BTN_REW| \ (PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_STOP|PBTN_PLAY|PBTN_FWD|PBTN_REW| \
BTN_L|BTN_R|BTN_VOLUME|BTN_BRIGHTNESS|BTN_ALARM) PBTN_L|PBTN_R|PBTN_VOLUME|PBTN_BRIGHTNESS|PBTN_ALARM)

View file

@ -54,14 +54,14 @@ LD = $(CROSS)ld
OBJCOPY = $(CROSS)objcopy OBJCOPY = $(CROSS)objcopy
# frontend # frontend
OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o cpuctrl.o OBJS += main.o menu.o gp2x.o emu.o squidgehack.o cpuctrl.o
# 940 core control # 940 core control
OBJS += 940ctl.o OBJS += 940ctl.o
# common # common
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \ OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \
platform/common/arm_utils.o platform/common/arm_linux.o platform/common/readpng.o \ platform/common/arm_utils.o platform/common/arm_linux.o platform/common/readpng.o \
platform/common/mp3_helix.o platform/common/mp3_helix.o platform/linux/usbjoy.o platform/linux/sndout_oss.o
# Pico # Pico
ifeq "$(amalgamate)" "1" ifeq "$(amalgamate)" "1"
@ -116,8 +116,8 @@ endif
vpath %.c = ../.. vpath %.c = ../..
vpath %.s = ../.. vpath %.s = ../..
vpath %.S = ../.. vpath %.S = ../..
DIRS = platform platform/gp2x platform/common pico pico/cd pico/pico pico/sound pico/carthw/svp \ DIRS = platform platform/gp2x platform/linux platform/common pico pico/cd pico/pico pico/sound \
zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80 pico/carthw/svp zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80
all: mkdirs PicoDrive.gpe all: mkdirs PicoDrive.gpe

View file

@ -16,12 +16,13 @@
#include "emu.h" #include "emu.h"
#include "gp2x.h" #include "gp2x.h"
#include "usbjoy.h"
#include "menu.h" #include "menu.h"
#include "../linux/usbjoy.h"
#include "../common/arm_utils.h" #include "../common/arm_utils.h"
#include "../common/fonts.h" #include "../common/fonts.h"
#include "../common/emu.h" #include "../common/emu.h"
#include "../common/config.h" #include "../common/config.h"
#include "../linux/sndout_oss.h"
#include "cpuctrl.h" #include "cpuctrl.h"
#include <pico/pico_int.h> #include <pico/pico_int.h>
@ -487,7 +488,7 @@ static void update_volume(int has_changed, int is_up)
if (vol > 0) vol--; if (vol > 0) vol--;
} }
wait_frames = 0; wait_frames = 0;
gp2x_sound_volume(vol, vol); sndout_oss_setvol(vol, vol);
currentConfig.volume = vol; currentConfig.volume = vol;
} }
sprintf(noticeMsg, "VOL: %02i", vol); sprintf(noticeMsg, "VOL: %02i", vol);
@ -614,9 +615,9 @@ static void updateKeys(void)
// add joy inputs // add joy inputs
if (num_of_joys > 0) if (num_of_joys > 0)
{ {
gp2x_usbjoy_update(); usbjoy_update();
for (joy = 0; joy < num_of_joys; joy++) { for (joy = 0; joy < num_of_joys; joy++) {
int btns = gp2x_usbjoy_check2(joy); int btns = usbjoy_check2(joy);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if (btns & (1 << i)) { if (btns & (1 << i)) {
int acts = currentConfig.JoyBinds[joy][i]; int acts = currentConfig.JoyBinds[joy][i];
@ -662,7 +663,7 @@ static void updateSound(int len)
/* avoid writing audio when lagging behind to prevent audio lag */ /* avoid writing audio when lagging behind to prevent audio lag */
if (PicoSkipFrame != 2) if (PicoSkipFrame != 2)
gp2x_sound_write(PsndOut, len<<1); sndout_oss_write(PsndOut, len<<1);
} }
void emu_startSound(void) void emu_startSound(void)
@ -683,8 +684,8 @@ void emu_startSound(void)
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps; snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n", printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal); PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);
gp2x_start_sound(PsndRate, 16, (PicoOpt&8)>>3); sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);
gp2x_sound_volume(currentConfig.volume, currentConfig.volume); sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
PicoWriteSound = updateSound; PicoWriteSound = updateSound;
update_volume(0, 0); update_volume(0, 0);
memset(sndBuffer, 0, sizeof(sndBuffer)); memset(sndBuffer, 0, sizeof(sndBuffer));

View file

@ -28,13 +28,12 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include "gp2x.h" #include "gp2x.h"
#include "usbjoy.h" #include "../linux/usbjoy.h"
#include "../linux/sndout_oss.h"
#include "../common/arm_utils.h" #include "../common/arm_utils.h"
#include "../common/arm_linux.h" #include "../common/arm_linux.h"
@ -45,7 +44,7 @@ static void *gp2x_screens[4];
static int screensel = 0; static int screensel = 0;
//static //static
int memdev = 0; int memdev = 0;
static int sounddev = -1, mixerdev = -1, touchdev = -1; static int touchdev = -1;
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 }; static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
void *gp2x_screen; void *gp2x_screen;
@ -210,9 +209,9 @@ unsigned long gp2x_joystick_read(int allow_usb_joy)
if (allow_usb_joy && num_of_joys > 0) { if (allow_usb_joy && num_of_joys > 0) {
// check the usb joy as well.. // check the usb joy as well..
gp2x_usbjoy_update(); usbjoy_update();
for (i = 0; i < num_of_joys; i++) for (i = 0; i < num_of_joys; i++)
value |= gp2x_usbjoy_check(i); value |= usbjoy_check(i);
} }
return value; return value;
@ -251,57 +250,6 @@ int gp2x_touchpad_read(int *x, int *y)
} }
static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0;
void gp2x_start_sound(int rate, int bits, int stereo)
{
int frag = 0, bsize, buffers;
// if no settings change, we don't need to do anything
if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) return;
if (sounddev > 0) close(sounddev);
sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC);
if (sounddev == -1)
printf("open(\"/dev/dsp\") failed with %i\n", errno);
ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits);
ioctl(sounddev, SNDCTL_DSP_SPEED, &rate);
ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo);
// calculate buffer size
buffers = 16;
bsize = rate / 32;
if (rate > 22050) { bsize*=4; buffers*=2; } // 44k mode seems to be very demanding
while ((bsize>>=1)) frag++;
frag |= buffers<<16; // 16 buffers
ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag);
usleep(192*1024);
printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n",
rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff));
s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo;
}
void gp2x_sound_write(void *buff, int len)
{
write(sounddev, buff, len);
}
void gp2x_sound_sync(void)
{
ioctl(sounddev, SOUND_PCM_SYNC, 0);
}
void gp2x_sound_volume(int l, int r)
{
l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r;
l<<=8; l|=r;
ioctl(mixerdev, SOUND_MIXER_WRITE_PCM, &l); /*SOUND_MIXER_WRITE_VOLUME*/
}
/* 940 */ /* 940 */
void Pause940(int yes) void Pause940(int yes)
{ {
@ -352,7 +300,7 @@ void gp2x_init(void)
memdev = open("/dev/mem", O_RDWR); memdev = open("/dev/mem", O_RDWR);
if (memdev == -1) if (memdev == -1)
{ {
printf("open(\"/dev/mem\") failed with %i\n", errno); perror("open(\"/dev/mem\")");
exit(1); exit(1);
} }
@ -360,7 +308,7 @@ void gp2x_init(void)
printf("memregs are @ %p\n", gp2x_memregs); printf("memregs are @ %p\n", gp2x_memregs);
if(gp2x_memregs == MAP_FAILED) if(gp2x_memregs == MAP_FAILED)
{ {
printf("mmap(memregs) failed with %i\n", errno); perror("mmap(memregs)");
exit(1); exit(1);
} }
gp2x_memregl = (unsigned long *) gp2x_memregs; gp2x_memregl = (unsigned long *) gp2x_memregs;
@ -370,7 +318,7 @@ void gp2x_init(void)
gp2x_screens[0] = mmap(0, FRAMEBUFF_WHOLESIZE, PROT_WRITE, MAP_SHARED, memdev, FRAMEBUFF_ADDR0); gp2x_screens[0] = mmap(0, FRAMEBUFF_WHOLESIZE, PROT_WRITE, MAP_SHARED, memdev, FRAMEBUFF_ADDR0);
if(gp2x_screens[0] == MAP_FAILED) if(gp2x_screens[0] == MAP_FAILED)
{ {
printf("mmap(gp2x_screen) failed with %i\n", errno); perror("mmap(gp2x_screen)");
exit(1); exit(1);
} }
printf("framebuffers point to %p\n", gp2x_screens[0]); printf("framebuffers point to %p\n", gp2x_screens[0]);
@ -390,12 +338,10 @@ void gp2x_init(void)
gp2x_memset_all_buffers(0, 0, 320*240*2); gp2x_memset_all_buffers(0, 0, 320*240*2);
// snd // snd
mixerdev = open("/dev/mixer", O_RDWR); sndout_oss_init();
if (mixerdev == -1)
printf("open(\"/dev/mixer\") failed with %i\n", errno);
/* init usb joys -GnoStiC */ /* init usb joys -GnoStiC */
gp2x_usbjoy_init(); usbjoy_init();
// touchscreen // touchscreen
touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY); touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY);
@ -432,11 +378,10 @@ void gp2x_deinit(void)
munmap(gp2x_screens[0], FRAMEBUFF_WHOLESIZE); munmap(gp2x_screens[0], FRAMEBUFF_WHOLESIZE);
munmap((void *)gp2x_memregs, 0x10000); munmap((void *)gp2x_memregs, 0x10000);
close(memdev); close(memdev);
close(mixerdev);
if (sounddev >= 0) close(sounddev);
if (touchdev >= 0) close(touchdev); if (touchdev >= 0) close(touchdev);
gp2x_usbjoy_deinit(); sndout_oss_exit();
usbjoy_deinit();
printf("all done, running "); printf("all done, running ");

View file

@ -20,12 +20,6 @@ void gp2x_memcpy_all_buffers(void *data, int offset, int len);
void gp2x_memset_all_buffers(int offset, int byte, int len); void gp2x_memset_all_buffers(int offset, int byte, int len);
void gp2x_pd_clone_buffer2(void); void gp2x_pd_clone_buffer2(void);
/* sound */
void gp2x_start_sound(int rate, int bits, int stereo);
void gp2x_sound_write(void *buff, int len);
void gp2x_sound_volume(int l, int r);
void gp2x_sound_sync(void);
/* input */ /* input */
unsigned long gp2x_joystick_read(int allow_usb_joy); unsigned long gp2x_joystick_read(int allow_usb_joy);
int gp2x_touchpad_read(int *x, int *y); int gp2x_touchpad_read(int *x, int *y);

View file

@ -13,7 +13,7 @@
#include "gp2x.h" #include "gp2x.h"
#include "emu.h" #include "emu.h"
#include "menu.h" #include "menu.h"
#include "usbjoy.h" #include "../linux/usbjoy.h"
#include "../common/emu.h" #include "../common/emu.h"
#include "../common/menu.h" #include "../common/menu.h"
#include "../common/arm_utils.h" #include "../common/arm_utils.h"
@ -90,9 +90,9 @@ static unsigned long input2_read(unsigned long interesting, int *joy)
{ {
*joy = 0; *joy = 0;
if ((ret = gp2x_joystick_read(0) & interesting)) break; if ((ret = gp2x_joystick_read(0) & interesting)) break;
gp2x_usbjoy_update(); usbjoy_update();
for (i = 0; i < num_of_joys; i++) { for (i = 0; i < num_of_joys; i++) {
ret = gp2x_usbjoy_check2(i); ret = usbjoy_check2(i);
if (ret) { *joy = i + 1; break; } if (ret) { *joy = i + 1; break; }
} }
if (ret) break; if (ret) break;

View file

@ -27,8 +27,8 @@ COPT += `pkg-config --cflags gthread-2.0`
LDFLAGS += `pkg-config --libs gthread-2.0` LDFLAGS += `pkg-config --libs gthread-2.0`
# frontend # frontend
OBJS += platform/gp2x/main.o platform/gp2x/menu.o platform/gp2x/emu.o platform/gp2x/usbjoy.o blit.o \ OBJS += platform/gp2x/main.o platform/gp2x/menu.o platform/gp2x/emu.o usbjoy.o blit.o \
gp2x.o 940ctl_ym2612.o log_io.o sndout_oss.o gp2x.o 940ctl_ym2612.o log_io.o
# common # common
OBJS += platform/common/emu.o platform/common/menu.o platform/common/config.o platform/common/fonts.o \ OBJS += platform/common/emu.o platform/common/menu.o platform/common/config.o platform/common/fonts.o \

View file

@ -9,15 +9,14 @@
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include "../gp2x/emu.h" #include "../gp2x/emu.h"
#include "../gp2x/gp2x.h" #include "../gp2x/gp2x.h"
#include "../gp2x/usbjoy.h"
#include "../gp2x/version.h" #include "../gp2x/version.h"
#include "sndout_oss.h"
#include "usbjoy.h"
#include "log_io.h" #include "log_io.h"
@ -25,7 +24,6 @@ void *gp2x_screen;
static int current_bpp = 8; static int current_bpp = 8;
static int current_pal[256]; static int current_pal[256];
static unsigned long current_keys = 0; static unsigned long current_keys = 0;
static int sounddev = 0, mixerdev = 0;
static const char *verstring = "PicoDrive " VERSION; static const char *verstring = "PicoDrive " VERSION;
// dummies // dummies
@ -184,13 +182,11 @@ void gp2x_init(void)
memset(gp2x_screen, 0, 320*240*2 + 320*2); memset(gp2x_screen, 0, 320*240*2 + 320*2);
// snd // snd
mixerdev = open("/dev/mixer", O_RDWR); sndout_oss_init();
if (mixerdev == -1)
printf("open(\"/dev/mixer\") failed with %i\n", errno);
gtk_initf(); gtk_initf();
gp2x_usbjoy_init(); usbjoy_init();
printf("exitting init()\n"); fflush(stdout); printf("exitting init()\n"); fflush(stdout);
} }
@ -198,9 +194,8 @@ void gp2x_init(void)
void gp2x_deinit(void) void gp2x_deinit(void)
{ {
free(gp2x_screen); free(gp2x_screen);
if (sounddev > 0) close(sounddev); sndout_oss_exit();
close(mixerdev); usbjoy_deinit();
gp2x_usbjoy_deinit();
} }
/* video */ /* video */
@ -304,54 +299,6 @@ void gp2x_pd_clone_buffer2(void)
memset(gp2x_screen, 0, 320*240*2); memset(gp2x_screen, 0, 320*240*2);
} }
/* sound */
static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0;
void gp2x_start_sound(int rate, int bits, int stereo)
{
int frag = 0, bsize, buffers;
// if no settings change, we don't need to do anything
if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) return;
if (sounddev > 0) close(sounddev);
sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC);
if (sounddev == -1)
printf("open(\"/dev/dsp\") failed with %i\n", errno);
ioctl(sounddev, SNDCTL_DSP_SPEED, &rate);
ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits);
ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo);
// calculate buffer size
buffers = 16;
bsize = rate / 32;
if (rate > 22050) { bsize*=4; buffers*=2; } // 44k mode seems to be very demanding
while ((bsize>>=1)) frag++;
frag |= buffers<<16; // 16 buffers
ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag);
printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n",
rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff));
s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo;
}
void gp2x_sound_write(void *buff, int len)
{
write(sounddev, buff, len);
}
void gp2x_sound_sync(void)
{
ioctl(sounddev, SOUND_PCM_SYNC, 0);
}
void gp2x_sound_volume(int l, int r)
{
l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r;
l<<=8; l|=r;
ioctl(mixerdev, SOUND_MIXER_WRITE_PCM, &l); /*SOUND_MIXER_WRITE_VOLUME*/
}
/* joy */ /* joy */
unsigned long gp2x_joystick_read(int allow_usb_joy) unsigned long gp2x_joystick_read(int allow_usb_joy)
{ {
@ -360,9 +307,9 @@ unsigned long gp2x_joystick_read(int allow_usb_joy)
if (allow_usb_joy && num_of_joys > 0) { if (allow_usb_joy && num_of_joys > 0) {
// check the usb joy as well.. // check the usb joy as well..
gp2x_usbjoy_update(); usbjoy_update();
for (i = 0; i < num_of_joys; i++) for (i = 0; i < num_of_joys; i++)
value |= gp2x_usbjoy_check(i); value |= usbjoy_check(i);
} }
return value; return value;

View file

@ -0,0 +1,96 @@
/* sound output via OSS */
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <unistd.h>
#include "sndout_oss.h"
static int sounddev = -1, mixerdev = -1;
int sndout_oss_init(void)
{
if (mixerdev >= 0) close(mixerdev);
mixerdev = open("/dev/mixer", O_RDWR);
if (mixerdev == -1)
{
perror("open(\"/dev/mixer\")");
}
return 0;
}
int sndout_oss_start(int rate, int bits, int stereo)
{
static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0;
int frag = 0, bsize, buffers, ret;
// if no settings change, we don't need to do anything,
// since audio is never stopped
if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo)
return 0;
if (sounddev >= 0) close(sounddev);
sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC);
if (sounddev == -1)
{
perror("open(\"/dev/dsp\")");
return -1;
}
// calculate buffer size
// this is tuned for GP2X
buffers = 16;
bsize = rate / 32;
if (rate > 22050) { bsize*=4; buffers*=2; }
while ((bsize>>=1)) frag++;
frag |= buffers<<16; // 16 buffers
ret = ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag);
if (ret) perror("SNDCTL_DSP_SETFRAGMENT failed");
ret = ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo);
ret |= ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits);
ret |= ioctl(sounddev, SNDCTL_DSP_SPEED, &rate);
if (ret) printf("failed to set audio format\n");
usleep(192*1024);
printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n",
rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff));
s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo;
return 0;
}
int sndout_oss_write(const void *buff, int len)
{
return write(sounddev, buff, len);
}
void sndout_oss_sync(void)
{
ioctl(sounddev, SOUND_PCM_SYNC, 0);
}
void sndout_oss_setvol(int l, int r)
{
if (mixerdev < 0) return;
l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r;
l<<=8; l|=r;
ioctl(mixerdev, SOUND_MIXER_WRITE_PCM, &l); /*SOUND_MIXER_WRITE_VOLUME*/
}
void sndout_oss_exit(void)
{
if (sounddev >= 0) close(sounddev); sounddev = -1;
if (mixerdev >= 0) close(mixerdev); mixerdev = -1;
}

View file

@ -0,0 +1,6 @@
int sndout_oss_init(void);
int sndout_oss_start(int rate, int bits, int stereo);
int sndout_oss_write(const void *buff, int len);
void sndout_oss_sync(void);
void sndout_oss_setvol(int l, int r);
void sndout_oss_exit(void);

View file

@ -321,16 +321,15 @@ int joy_close (struct usbjoy * joy) {
} }
/*********************************************************************/
/* GP2X USB Joystick Handling -GnoStiC */
/*********************************************************************/ /*********************************************************************/
#include "gp2x.h" #include "../common/common.h"
int num_of_joys = 0; int num_of_joys = 0;
struct usbjoy *joys[4]; struct usbjoy *joys[4];
void gp2x_usbjoy_init (void) { void usbjoy_init (void)
{
/* Open available joysticks -GnoStiC */ /* Open available joysticks -GnoStiC */
int i, n = 0; int i, n = 0;
@ -347,7 +346,8 @@ void gp2x_usbjoy_init (void) {
printf("Found %d Joystick(s)\n",num_of_joys); printf("Found %d Joystick(s)\n",num_of_joys);
} }
void gp2x_usbjoy_update (void) { void usbjoy_update (void)
{
/* Update Joystick Event Cache */ /* Update Joystick Event Cache */
int q, foo; int q, foo;
for (q=0; q < num_of_joys; q++) { for (q=0; q < num_of_joys; q++) {
@ -355,45 +355,48 @@ void gp2x_usbjoy_update (void) {
} }
} }
int gp2x_usbjoy_check (int joyno) { int usbjoy_check (int joyno)
{
/* Check Joystick */ /* Check Joystick */
int q, joyExKey = 0; int q, joyExKey = 0;
struct usbjoy *joy = joys[joyno]; struct usbjoy *joy = joys[joyno];
if (joy != NULL) { if (joy != NULL) {
if (joy_getaxe(JOYUP, joy)) { joyExKey |= GP2X_UP; } if (joy_getaxe(JOYUP, joy)) { joyExKey |= PBTN_UP; }
if (joy_getaxe(JOYDOWN, joy)) { joyExKey |= GP2X_DOWN; } if (joy_getaxe(JOYDOWN, joy)) { joyExKey |= PBTN_DOWN; }
if (joy_getaxe(JOYLEFT, joy)) { joyExKey |= GP2X_LEFT; } if (joy_getaxe(JOYLEFT, joy)) { joyExKey |= PBTN_LEFT; }
if (joy_getaxe(JOYRIGHT, joy)) { joyExKey |= GP2X_RIGHT; } if (joy_getaxe(JOYRIGHT, joy)) { joyExKey |= PBTN_RIGHT; }
/* loop through joy buttons to check if they are pushed */ /* loop through joy buttons to check if they are pushed */
for (q=0; q<joy_buttons (joy); q++) { for (q=0; q<joy_buttons (joy); q++) {
if (joy_getbutton (q, joy)) { if (joy_getbutton (q, joy)) {
if (joy->type == JOY_TYPE_LOGITECH) { if (joy->type == JOY_TYPE_LOGITECH) {
switch (q) { switch (q) {
case 0: joyExKey |= GP2X_A; break; case 0: joyExKey |= PBTN_WEST; break;
case 1: joyExKey |= GP2X_X; break; case 1: joyExKey |= PBTN_SOUTH; break;
case 2: joyExKey |= GP2X_B; break; case 2: joyExKey |= PBTN_EAST; break;
case 3: joyExKey |= GP2X_Y; break; case 3: joyExKey |= PBTN_NORTH; break;
} }
} else { } else {
switch (q) { switch (q) {
case 0: joyExKey |= GP2X_Y; break; case 0: joyExKey |= PBTN_NORTH; break;
case 1: joyExKey |= GP2X_B; break; case 1: joyExKey |= PBTN_EAST; break;
case 2: joyExKey |= GP2X_X; break; case 2: joyExKey |= PBTN_SOUTH; break;
case 3: joyExKey |= GP2X_A; break; case 3: joyExKey |= PBTN_WEST; break;
} }
} }
switch (q) { switch (q) {
case 4: joyExKey |= GP2X_L; break; case 4: joyExKey |= PBTN_L; break;
case 5: joyExKey |= GP2X_R; break; case 5: joyExKey |= PBTN_R; break;
case 6: joyExKey |= GP2X_L; break; /* left shoulder button 2 */ case 6: joyExKey |= PBTN_L; break; /* left shoulder button 2 */
case 7: joyExKey |= GP2X_R; break; /* right shoulder button 2 */ case 7: joyExKey |= PBTN_R; break; /* right shoulder button 2 */
/*
case 8: joyExKey |= GP2X_SELECT;break; case 8: joyExKey |= GP2X_SELECT;break;
case 9: joyExKey |= GP2X_START; break; case 9: joyExKey |= GP2X_START; break;
case 10: joyExKey |= GP2X_PUSH; break; case 10: joyExKey |= GP2X_PUSH; break;
case 11: joyExKey |= GP2X_PUSH; break; case 11: joyExKey |= GP2X_PUSH; break;
*/
} }
} }
} }
@ -401,7 +404,8 @@ int gp2x_usbjoy_check (int joyno) {
return joyExKey; return joyExKey;
} }
int gp2x_usbjoy_check2 (int joyno) { int usbjoy_check2 (int joyno)
{
/* Check Joystick, don't map to gp2x joy */ /* Check Joystick, don't map to gp2x joy */
int q, to, joyExKey = 0; int q, to, joyExKey = 0;
struct usbjoy *joy = joys[joyno]; struct usbjoy *joy = joys[joyno];
@ -423,7 +427,8 @@ int gp2x_usbjoy_check2 (int joyno) {
void gp2x_usbjoy_deinit (void) { void usbjoy_deinit (void)
{
int i; int i;
for (i=0; i<num_of_joys; i++) { for (i=0; i<num_of_joys; i++) {
joy_close (joys[i]); joy_close (joys[i]);

View file

@ -228,15 +228,15 @@ int joy_close (struct usbjoy * joy);
/* gp2x stuff */ /* more stuff */
extern int num_of_joys; extern int num_of_joys;
extern struct usbjoy *joys[4]; extern struct usbjoy *joys[4];
void gp2x_usbjoy_update(void); void usbjoy_update(void);
void gp2x_usbjoy_init(void); void usbjoy_init(void);
int gp2x_usbjoy_check(int joyno); int usbjoy_check(int joyno);
int gp2x_usbjoy_check2(int joyno); int usbjoy_check2(int joyno);
void gp2x_usbjoy_deinit(void); void usbjoy_deinit(void);
#endif // USBJOY_H #endif // USBJOY_H

View file

@ -1,4 +1,5 @@
export CROSS = arm-none-linux-gnueabi- #export CROSS = arm-none-linux-gnueabi-
LIBROOT = /home/notaz/dev/pnd/libroot
# settings # settings
#mz80 = 1 #mz80 = 1
@ -29,7 +30,7 @@ use_cyclone = 1
endif endif
DEFINC = -I../.. -I. -DARM -DPANDORA DEFINC = -I../.. -I. -DARM -DPANDORA
COPT_COMMON = -Wall -Winline -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a COPT_COMMON = -Wall -Winline -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a -I$(LIBROOT)/include
ifeq ($(DEBUG),) ifeq ($(DEBUG),)
COPT_COMMON += -O2 # -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math COPT_COMMON += -O2 # -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math
else else
@ -51,12 +52,12 @@ LD = $(CROSS)ld
OBJCOPY = $(CROSS)objcopy OBJCOPY = $(CROSS)objcopy
# frontend # frontend
OBJS += pandora.o main.o emu.o asm_utils.o platform/gp2x/menu.o platform/gp2x/usbjoy.o OBJS += pandora.o main.o emu.o asm_utils.o platform/gp2x/menu.o
# common # common
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \ OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \
platform/common/arm_utils.o platform/common/mp3_helix.o platform/common/arm_linux.o platform/common/arm_utils.o platform/common/mp3_helix.o platform/common/arm_linux.o \
# platform/common/readpng.o platform/common/readpng.o platform/linux/usbjoy.o platform/linux/sndout_oss.o
# Pico # Pico
ifeq "$(amalgamate)" "1" ifeq "$(amalgamate)" "1"
@ -120,7 +121,7 @@ endif
vpath %.c = ../.. vpath %.c = ../..
vpath %.s = ../.. vpath %.s = ../..
vpath %.S = ../.. vpath %.S = ../..
DIRS = platform platform/gp2x platform/common pico pico/cd pico/pico pico/sound pico/carthw/svp \ DIRS = platform platform/gp2x platform/linux platform/common pico pico/cd pico/pico pico/sound pico/carthw/svp \
zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80 zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80
@ -130,7 +131,7 @@ include ../common/common_arm.mak
PicoDrive : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a PicoDrive : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a
@echo ">>>" $@ @echo ">>>" $@
$(CC) -o $@ $(CFLAGS) $^ -lm -Wl,-Map=PicoDrive.map # -lpng $(CC) -o $@ $(CFLAGS) $^ -lm -Wl,-Map=PicoDrive.map -lpng -L$(LIBROOT)/lib
ifeq ($(DEBUG),) ifeq ($(DEBUG),)
$(STRIP) $@ $(STRIP) $@
endif endif

View file

@ -15,13 +15,14 @@
#include <stdarg.h> #include <stdarg.h>
#include "../gp2x/emu.h" #include "../gp2x/emu.h"
#include "../gp2x/usbjoy.h"
#include "../gp2x/menu.h" #include "../gp2x/menu.h"
#include "../common/arm_utils.h" #include "../common/arm_utils.h"
#include "../common/fonts.h" #include "../common/fonts.h"
#include "../common/emu.h" #include "../common/emu.h"
#include "../common/config.h" #include "../common/config.h"
#include "../common/common.h" #include "../common/common.h"
#include "../linux/usbjoy.h"
#include "../linux/sndout_oss.h"
#include "asm_utils.h" #include "asm_utils.h"
#include <pico/pico_int.h> #include <pico/pico_int.h>
@ -554,7 +555,7 @@ static void update_volume(int has_changed, int is_up)
if (vol > 0) vol--; if (vol > 0) vol--;
} }
wait_frames = 0; wait_frames = 0;
gp2x_sound_volume(vol, vol); sndout_oss_setvol(vol, vol);
currentConfig.volume = vol; currentConfig.volume = vol;
} }
sprintf(noticeMsg, "VOL: %02i", vol); sprintf(noticeMsg, "VOL: %02i", vol);
@ -681,9 +682,9 @@ static void updateKeys(void)
// add joy inputs // add joy inputs
if (num_of_joys > 0) if (num_of_joys > 0)
{ {
gp2x_usbjoy_update(); usbjoy_update();
for (joy = 0; joy < num_of_joys; joy++) { for (joy = 0; joy < num_of_joys; joy++) {
int btns = gp2x_usbjoy_check2(joy); int btns = usbjoy_check2(joy);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if (btns & (1 << i)) { if (btns & (1 << i)) {
int acts = currentConfig.JoyBinds[joy][i]; int acts = currentConfig.JoyBinds[joy][i];
@ -729,7 +730,7 @@ static void updateSound(int len)
/* avoid writing audio when lagging behind to prevent audio lag */ /* avoid writing audio when lagging behind to prevent audio lag */
if (PicoSkipFrame != 2) if (PicoSkipFrame != 2)
gp2x_sound_write(PsndOut, len<<1); sndout_oss_write(PsndOut, len<<1);
} }
@ -833,8 +834,8 @@ void emu_Loop(void)
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps; snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n", printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal); PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);
gp2x_start_sound(PsndRate, 16, (PicoOpt&8)>>3); sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);
gp2x_sound_volume(currentConfig.volume, currentConfig.volume); sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
PicoWriteSound = updateSound; PicoWriteSound = updateSound;
update_volume(0, 0); update_volume(0, 0);
memset(sndBuffer, 0, sizeof(sndBuffer)); memset(sndBuffer, 0, sizeof(sndBuffer));

View file

@ -7,23 +7,20 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include "../gp2x/gp2x.h" #include "../gp2x/gp2x.h"
#include "../gp2x/usbjoy.h" #include "../linux/usbjoy.h"
#include "../linux/sndout_oss.h"
#include "../common/arm_linux.h" #include "../common/arm_linux.h"
static volatile unsigned int *memregs = MAP_FAILED; static volatile unsigned int *memregs = MAP_FAILED;
//static //static
int memdev = 0; int memdev = 0;
static int fbdev = -1, sounddev = -1, mixerdev = -1, touchdev = -1; static int fbdev = -1;
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
//#define SCREEN_MAP_SIZE (((800*(480+11)*2)+0xfff)&~0xfff)
#define SCREEN_MAP_SIZE (800*480*2) #define SCREEN_MAP_SIZE (800*480*2)
static void *screen = MAP_FAILED; static void *screen = MAP_FAILED;
void *gp2x_screen; void *gp2x_screen;
@ -98,14 +95,18 @@ unsigned long gp2x_joystick_read(int allow_usb_joy)
if (allow_usb_joy && num_of_joys > 0) { if (allow_usb_joy && num_of_joys > 0) {
// check the usb joy as well.. // check the usb joy as well..
gp2x_usbjoy_update(); usbjoy_update();
for (i = 0; i < num_of_joys; i++) for (i = 0; i < num_of_joys; i++)
value |= gp2x_usbjoy_check(i); value |= usbjoy_check(i);
} }
return value; return value;
} }
// FIXME
#if 0
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
typedef struct ucb1x00_ts_event typedef struct ucb1x00_ts_event
{ {
unsigned short pressure; unsigned short pressure;
@ -137,73 +138,19 @@ int gp2x_touchpad_read(int *x, int *y)
return zero_seen ? event.pressure : 0; return zero_seen ? event.pressure : 0;
} }
#else
int gp2x_touchpad_read(int *x, int *y) { return -1; }
static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0;
void gp2x_start_sound(int rate, int bits, int stereo)
{
int frag = 0, bsize, buffers;
// if no settings change, we don't need to do anything
if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) return;
if (sounddev > 0) close(sounddev);
sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC);
if (sounddev == -1)
printf("open(\"/dev/dsp\") failed with %i\n", errno);
ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits);
ioctl(sounddev, SNDCTL_DSP_SPEED, &rate);
ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo);
// calculate buffer size
buffers = 16;
bsize = rate / 32;
if (rate > 22050) { bsize*=4; buffers*=2; } // 44k mode seems to be very demanding
while ((bsize>>=1)) frag++;
frag |= buffers<<16; // 16 buffers
ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag);
usleep(192*1024);
printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n",
rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff));
s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo;
}
void gp2x_sound_write(void *buff, int len)
{
write(sounddev, buff, len);
}
void gp2x_sound_sync(void)
{
// ioctl(sounddev, SOUND_PCM_SYNC, 0);
}
void gp2x_sound_volume(int l, int r)
{
#if 0
l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r;
l<<=8; l|=r;
ioctl(mixerdev, SOUND_MIXER_WRITE_PCM, &l); /*SOUND_MIXER_WRITE_VOLUME*/
#endif #endif
}
/* common */ /* common */
void gp2x_init(void) void gp2x_init(void)
{ {
struct fb_fix_screeninfo fbfix;
int ret;
printf("entering init()\n"); fflush(stdout); printf("entering init()\n"); fflush(stdout);
memdev = open("/dev/mem", O_RDWR); memdev = open("/dev/mem", O_RDWR);
if (memdev == -1) if (memdev == -1)
{ {
printf("open(\"/dev/mem\") failed with %i\n", errno); perror("open(\"/dev/mem\")");
exit(1); exit(1);
} }
/* /*
@ -217,73 +164,39 @@ void gp2x_init(void)
fbdev = open("/dev/fb0", O_RDWR); fbdev = open("/dev/fb0", O_RDWR);
if (fbdev == -1) if (fbdev == -1)
{ {
printf("open(\"/dev/fb0\") failed with %i\n", errno); perror("open(\"/dev/fb0\")");
exit(1); exit(1);
} }
ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix);
if (ret == -1)
{
printf("ioctl(fbdev) failed with %i\n", errno);
exit(1);
}
// squidge hack
if (fbfix.line_length != 800*2)
{
gp2x_screen = malloc(800*640*2);
return;
}
screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0); screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
if (screen == MAP_FAILED) if (screen == MAP_FAILED)
{ {
printf("mmap(fbptr) failed with %i\n", errno); perror("mmap(fbptr)");
exit(1); exit(1);
} }
printf("fbptr %p\n", screen); printf("fbptr %p\n", screen);
// gp2x_screen = (char *)screen + 800*10*2-64;
gp2x_screen = screen; gp2x_screen = screen;
// snd // snd
mixerdev = open("/dev/mixer", O_RDWR); sndout_oss_init();
if (mixerdev == -1)
printf("open(\"/dev/mixer\") failed with %i\n", errno);
/* init usb joys -GnoStiC */ /* init usb joys -GnoStiC */
gp2x_usbjoy_init(); usbjoy_init();
// touchscreen
touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY);
if (touchdev >= 0) {
FILE *pcf = fopen("/etc/pointercal", "r");
if (pcf) {
fscanf(pcf, "%d %d %d %d %d %d %d", &touchcal[0], &touchcal[1],
&touchcal[2], &touchcal[3], &touchcal[4], &touchcal[5], &touchcal[6]);
fclose(pcf);
}
printf("found touchscreen/wm97xx\n");
}
printf("exitting init()\n"); fflush(stdout); printf("exitting init()\n"); fflush(stdout);
} }
void gp2x_deinit(void) void gp2x_deinit(void)
{ {
//gp2x_video_changemode(15);
if (screen != MAP_FAILED) if (screen != MAP_FAILED)
munmap(screen, SCREEN_MAP_SIZE); munmap(screen, SCREEN_MAP_SIZE);
if (memregs != MAP_FAILED) if (memregs != MAP_FAILED)
munmap((void *)memregs, 0x10000); munmap((void *)memregs, 0x10000);
close(memdev); close(memdev);
if (fbdev >= 0) close(fbdev); if (fbdev >= 0) close(fbdev);
if (mixerdev >= 0) close(mixerdev);
if (sounddev >= 0) close(sounddev);
if (touchdev >= 0) close(touchdev);
gp2x_usbjoy_deinit(); sndout_oss_exit();
usbjoy_deinit();
printf("all done"); printf("all done");
} }
@ -302,7 +215,6 @@ void lprintf(const char *fmt, ...)
/* fake GP2X */ /* fake GP2X */
int crashed_940 = 0; int crashed_940 = 0;
int readpng(void *dest, const char *fname, int what) { return -1; }
void set_gamma(int g100, int A_SNs_curve) {} void set_gamma(int g100, int A_SNs_curve) {}
void set_FCLK(unsigned MHZ) {} void set_FCLK(unsigned MHZ) {}
void set_LCD_custom_rate(int rate) {} void set_LCD_custom_rate(int rate) {}

View file

@ -750,10 +750,10 @@ static void RunEventsPico(unsigned int events, unsigned int keys)
if (pico_inp_mode != 0) if (pico_inp_mode != 0)
{ {
PicoPad[0] &= ~0x0f; // release UDLR PicoPad[0] &= ~0x0f; // release UDLR
if (keys & BTN_UP) { pico_pen_y--; if (pico_pen_y < 8) pico_pen_y = 8; } if (keys & PBTN_UP) { pico_pen_y--; if (pico_pen_y < 8) pico_pen_y = 8; }
if (keys & BTN_DOWN) { pico_pen_y++; if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y; } if (keys & PBTN_DOWN) { pico_pen_y++; if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y; }
if (keys & BTN_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; } if (keys & PBTN_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; }
if (keys & BTN_RIGHT) { if (keys & PBTN_RIGHT) {
int lim = (Pico.video.reg[12]&1) ? 319 : 255; int lim = (Pico.video.reg[12]&1) ? 319 : 255;
pico_pen_x++; pico_pen_x++;
if (pico_pen_x > lim-PICO_PEN_ADJUST_X) if (pico_pen_x > lim-PICO_PEN_ADJUST_X)
@ -779,10 +779,10 @@ static void RunEvents(unsigned int which)
int keys; int keys;
sceGuSync(0,0); sceGuSync(0,0);
blit2("", (which & 0x1000) ? "LOAD STATE? (X=yes, O=no)" : "OVERWRITE SAVE? (X=yes, O=no)", 0); blit2("", (which & 0x1000) ? "LOAD STATE? (X=yes, O=no)" : "OVERWRITE SAVE? (X=yes, O=no)", 0);
while( !((keys = psp_pad_read(1)) & (BTN_X|BTN_CIRCLE)) ) while( !((keys = psp_pad_read(1)) & (PBTN_X|PBTN_CIRCLE)) )
psp_msleep(50); psp_msleep(50);
if (keys & BTN_CIRCLE) do_it = 0; if (keys & PBTN_CIRCLE) do_it = 0;
while( ((keys = psp_pad_read(1)) & (BTN_X|BTN_CIRCLE)) ) // wait for release while( ((keys = psp_pad_read(1)) & (PBTN_X|PBTN_CIRCLE)) ) // wait for release
psp_msleep(50); psp_msleep(50);
clearArea(0); clearArea(0);
} }
@ -836,7 +836,7 @@ static void updateKeys(void)
if (keys & PSP_CTRL_HOME) if (keys & PSP_CTRL_HOME)
sceDisplayWaitVblankStart(); sceDisplayWaitVblankStart();
if (keys & BTN_SELECT) if (keys & PBTN_SELECT)
engineState = PGS_Menu; engineState = PGS_Menu;
keys &= CONFIGURABLE_KEYS; keys &= CONFIGURABLE_KEYS;

View file

@ -80,14 +80,14 @@ unsigned long wait_for_input(unsigned int interesting, int is_key_config)
if (!is_key_config) if (!is_key_config)
ret |= (ret & 0xf0000000) >> 24; // use analog as d-pad ret |= (ret & 0xf0000000) >> 24; // use analog as d-pad
if (wait > 6 && (ret&(BTN_UP|BTN_LEFT|BTN_DOWN|BTN_RIGHT|BTN_L|BTN_R))) if (wait > 6 && (ret&(PBTN_UP|PBTN_LEFT|PBTN_DOWN|PBTN_RIGHT|PBTN_L|PBTN_R)))
wait = 6; wait = 6;
// we don't need diagonals in menus // we don't need diagonals in menus
if ((ret&BTN_UP) && (ret&BTN_LEFT)) ret &= ~BTN_LEFT; if ((ret&PBTN_UP) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret&BTN_UP) && (ret&BTN_RIGHT)) ret &= ~BTN_RIGHT; if ((ret&PBTN_UP) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
if ((ret&BTN_DOWN) && (ret&BTN_LEFT)) ret &= ~BTN_LEFT; if ((ret&PBTN_DOWN) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret&BTN_DOWN) && (ret&BTN_RIGHT)) ret &= ~BTN_RIGHT; if ((ret&PBTN_DOWN) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
return ret; return ret;
} }
@ -384,14 +384,14 @@ static char *romsel_loop(char *curr_path)
for (;;) for (;;)
{ {
draw_dirlist(curr_path, namelist, n, sel); draw_dirlist(curr_path, namelist, n, sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_L|BTN_R|BTN_X|BTN_CIRCLE, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_X|PBTN_CIRCLE, 0);
if(inp & BTN_UP ) { sel--; if (sel < 0) sel = n-2; } if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }
if(inp & BTN_DOWN) { sel++; if (sel > n-2) sel = 0; } if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }
if(inp & BTN_LEFT) { sel-=10; if (sel < 0) sel = 0; } if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }
if(inp & BTN_L) { sel-=24; if (sel < 0) sel = 0; } if(inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; }
if(inp & BTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } if(inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }
if(inp & BTN_R) { sel+=24; if (sel > n-2) sel = n-2; } if(inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; }
if(inp & BTN_CIRCLE) // enter dir/select if(inp & PBTN_CIRCLE) // enter dir/select
{ {
if (namelist[sel+1]->d_type & FIO_S_IFDIR) if (namelist[sel+1]->d_type & FIO_S_IFDIR)
{ {
@ -424,7 +424,7 @@ static char *romsel_loop(char *curr_path)
break; break;
} }
} }
if(inp & BTN_X) break; // cancel if(inp & PBTN_X) break; // cancel
} }
if (n > 0) { if (n > 0) {
@ -469,17 +469,17 @@ static void patches_menu_loop(void)
for(;;) for(;;)
{ {
draw_patchlist(menu_sel); draw_patchlist(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_L|BTN_R|BTN_X|BTN_CIRCLE, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_X|PBTN_CIRCLE, 0);
if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }
if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }
if(inp &(BTN_LEFT|BTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }
if(inp &(BTN_RIGHT|BTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; } if(inp &(PBTN_RIGHT|PBTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; }
if(inp & BTN_CIRCLE) { // action if(inp & PBTN_CIRCLE) { // action
if (menu_sel < PicoPatchCount) if (menu_sel < PicoPatchCount)
PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active; PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active;
else return; else return;
} }
if(inp & BTN_X) return; if(inp & PBTN_X) return;
} }
} }
@ -599,18 +599,18 @@ static int savestate_menu_loop(int is_loading)
for(;;) for(;;)
{ {
draw_savestate_menu(menu_sel, is_loading); draw_savestate_menu(menu_sel, is_loading);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_X|BTN_CIRCLE, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_X|PBTN_CIRCLE, 0);
if(inp & BTN_UP ) { if(inp & PBTN_UP ) {
do { do {
menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max;
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);
} }
if(inp & BTN_DOWN) { if(inp & PBTN_DOWN) {
do { do {
menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0;
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);
} }
if(inp & BTN_CIRCLE) { // save/load if(inp & PBTN_CIRCLE) { // save/load
if (menu_sel < 10) { if (menu_sel < 10) {
state_slot = menu_sel; state_slot = menu_sel;
PicoStateProgressCB = emu_msg_cb; /* also suitable for menu */ PicoStateProgressCB = emu_msg_cb; /* also suitable for menu */
@ -621,7 +621,7 @@ static int savestate_menu_loop(int is_loading)
return 0; return 0;
} else return 1; } else return 1;
} }
if(inp & BTN_X) return 1; if(inp & PBTN_X) return 1;
} }
} }
@ -713,22 +713,22 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
for (;;) for (;;)
{ {
draw_key_config(opts, opt_cnt, player_idx, sel); draw_key_config(opts, opt_cnt, player_idx, sel);
inp = wait_for_input(CONFIGURABLE_KEYS|BTN_SELECT, 1); inp = wait_for_input(CONFIGURABLE_KEYS|PBTN_SELECT, 1);
if (!(inp & BTN_SELECT)) { if (!(inp & PBTN_SELECT)) {
prev_select = 0; prev_select = 0;
if(inp & BTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; } if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }
if(inp & BTN_DOWN) { sel++; if (sel > menu_sel_max) sel = 0; continue; } if(inp & PBTN_DOWN) { sel++; if (sel > menu_sel_max) sel = 0; continue; }
} }
if (sel >= opt_cnt) { if (sel >= opt_cnt) {
if (inp & (BTN_X|BTN_CIRCLE)) break; if (inp & (PBTN_X|PBTN_CIRCLE)) break;
else continue; else continue;
} }
// if we are here, we want to bind/unbind something // if we are here, we want to bind/unbind something
if ((inp & BTN_SELECT) && !prev_select) if ((inp & PBTN_SELECT) && !prev_select)
unbind_action(opts[sel].mask); unbind_action(opts[sel].mask);
prev_select = inp & BTN_SELECT; prev_select = inp & PBTN_SELECT;
inp &= CONFIGURABLE_KEYS; inp &= CONFIGURABLE_KEYS;
inp &= ~BTN_SELECT; inp &= ~PBTN_SELECT;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
if (inp & (1 << i)) { if (inp & (1 << i)) {
if (count_bound_keys(opts[sel].mask, player_idx) >= 2) if (count_bound_keys(opts[sel].mask, player_idx) >= 2)
@ -795,13 +795,13 @@ static void kc_sel_loop(void)
while (1) while (1)
{ {
draw_kc_sel(menu_sel); draw_kc_sel(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0);
selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel);
if (inp & (BTN_LEFT|BTN_RIGHT)) // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise
me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0); me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if (inp & BTN_CIRCLE) { if (inp & PBTN_CIRCLE) {
int is_6button = PicoOpt & POPT_6BTN_PAD; int is_6button = PicoOpt & POPT_6BTN_PAD;
switch (selected_id) { switch (selected_id) {
case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return; case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return;
@ -812,7 +812,7 @@ static void kc_sel_loop(void)
default: return; default: return;
} }
} }
if (inp & BTN_X) return; if (inp & PBTN_X) return;
} }
} }
@ -918,14 +918,14 @@ static void cd_menu_loop_options(void)
for (;;) for (;;)
{ {
draw_cd_menu_options(menu_sel, &bios_names); draw_cd_menu_options(menu_sel, &bios_names);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE|BTN_START, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE|PBTN_START, 0);
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel);
if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise
if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) && if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) &&
selected_id == MA_CDOPT_READAHEAD) { selected_id == MA_CDOPT_READAHEAD) {
if (inp & BTN_LEFT) { if (inp & PBTN_LEFT) {
PicoCDBuffers >>= 1; PicoCDBuffers >>= 1;
if (PicoCDBuffers < 2) PicoCDBuffers = 0; if (PicoCDBuffers < 2) PicoCDBuffers = 0;
} else { } else {
@ -935,12 +935,12 @@ static void cd_menu_loop_options(void)
} }
} }
} }
if (inp & BTN_CIRCLE) // toggleable options if (inp & PBTN_CIRCLE) // toggleable options
if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, 1) && if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, 1) &&
selected_id == MA_CDOPT_DONE) { selected_id == MA_CDOPT_DONE) {
return; return;
} }
if (inp & BTN_START) { if (inp & PBTN_START) {
switch (selected_id) { // BIOS testers switch (selected_id) { // BIOS testers
case MA_CDOPT_TESTBIOS_USA: case MA_CDOPT_TESTBIOS_USA:
if (emu_findBios(4, &bios)) { // test US if (emu_findBios(4, &bios)) { // test US
@ -967,7 +967,7 @@ static void cd_menu_loop_options(void)
break; break;
} }
} }
if (inp & BTN_X) return; if (inp & PBTN_X) return;
} }
} }
@ -1081,18 +1081,18 @@ static void dispmenu_loop_options(void)
for (;;) for (;;)
{ {
draw_dispmenu_options(menu_sel); draw_dispmenu_options(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0);
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt3_entries, OPT3_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt3_entries, OPT3_ENTRY_COUNT, menu_sel);
if (selected_id == MA_OPT3_HSCALE40 && is_32col) { is_32col = 0; menu_opt3_preview(is_32col); } if (selected_id == MA_OPT3_HSCALE40 && is_32col) { is_32col = 0; menu_opt3_preview(is_32col); }
if (selected_id == MA_OPT3_HSCALE32 && !is_32col) { is_32col = 1; menu_opt3_preview(is_32col); } if (selected_id == MA_OPT3_HSCALE32 && !is_32col) { is_32col = 1; menu_opt3_preview(is_32col); }
if (inp & (BTN_LEFT|BTN_RIGHT)) // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise
{ {
float *setting = NULL; float *setting = NULL;
int tmp; int tmp;
me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0); me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);
switch (selected_id) { switch (selected_id) {
case MA_OPT3_SCALE: setting = &currentConfig.scale; break; case MA_OPT3_SCALE: setting = &currentConfig.scale; break;
case MA_OPT3_HSCALE40: setting = &currentConfig.hscale40; is_32col = 0; break; case MA_OPT3_HSCALE40: setting = &currentConfig.hscale40; is_32col = 0; break;
@ -1102,7 +1102,7 @@ static void dispmenu_loop_options(void)
case MA_OPT3_BLACKLVL: menu_opt3_preview(is_32col); break; case MA_OPT3_BLACKLVL: menu_opt3_preview(is_32col); break;
case MA_OPT3_VSYNC: case MA_OPT3_VSYNC:
tmp = ((currentConfig.EmuOpt>>13)&1) | ((currentConfig.EmuOpt>>15)&2); tmp = ((currentConfig.EmuOpt>>13)&1) | ((currentConfig.EmuOpt>>15)&2);
tmp = (inp & BTN_LEFT) ? (tmp>>1) : ((tmp<<1)|1); tmp = (inp & PBTN_LEFT) ? (tmp>>1) : ((tmp<<1)|1);
if (tmp > 3) tmp = 3; if (tmp > 3) tmp = 3;
currentConfig.EmuOpt &= ~0x12000; currentConfig.EmuOpt &= ~0x12000;
currentConfig.EmuOpt |= ((tmp&2)<<15) | ((tmp&1)<<13); currentConfig.EmuOpt |= ((tmp&2)<<15) | ((tmp&1)<<13);
@ -1110,15 +1110,15 @@ static void dispmenu_loop_options(void)
default: break; default: break;
} }
if (setting != NULL) { if (setting != NULL) {
while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) { while ((inp = psp_pad_read(0)) & (PBTN_LEFT|PBTN_RIGHT)) {
*setting += (inp & BTN_LEFT) ? -0.01 : 0.01; *setting += (inp & PBTN_LEFT) ? -0.01 : 0.01;
if (*setting <= 0) *setting = 0.01; if (*setting <= 0) *setting = 0.01;
menu_opt3_preview(is_32col); menu_opt3_preview(is_32col);
draw_dispmenu_options(menu_sel); // will wait vsync draw_dispmenu_options(menu_sel); // will wait vsync
} }
} }
} }
if (inp & BTN_CIRCLE) { // toggleable options if (inp & PBTN_CIRCLE) { // toggleable options
me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, 1); me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, 1);
switch (selected_id) { switch (selected_id) {
case MA_OPT3_DONE: case MA_OPT3_DONE:
@ -1145,7 +1145,7 @@ static void dispmenu_loop_options(void)
default: break; default: break;
} }
} }
if (inp & BTN_X) return; if (inp & PBTN_X) return;
} }
} }
@ -1195,23 +1195,23 @@ static void amenu_loop_options(void)
for(;;) for(;;)
{ {
draw_amenu_options(menu_sel); draw_amenu_options(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0);
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel);
if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise
if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) && if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) &&
selected_id == MA_OPT2_GAMMA) { selected_id == MA_OPT2_GAMMA) {
// TODO? // TODO?
} }
} }
if (inp & BTN_CIRCLE) { // toggleable options if (inp & PBTN_CIRCLE) { // toggleable options
if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, 1) && if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, 1) &&
selected_id == MA_OPT2_DONE) { selected_id == MA_OPT2_DONE) {
return; return;
} }
} }
if (inp & BTN_X) return; if (inp & PBTN_X) return;
} }
} }
@ -1375,12 +1375,12 @@ static int menu_loop_options(void)
while (1) while (1)
{ {
draw_menu_options(menu_sel); draw_menu_options(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0);
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);
if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise
if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0)) { if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0)) {
switch (selected_id) { switch (selected_id) {
case MA_OPT_RENDERER: case MA_OPT_RENDERER:
if ((PicoOpt & 0x10) || !(currentConfig.EmuOpt & 0x80)) { if ((PicoOpt & 0x10) || !(currentConfig.EmuOpt & 0x80)) {
@ -1392,14 +1392,14 @@ static int menu_loop_options(void)
} }
break; break;
case MA_OPT_SOUND_QUALITY: case MA_OPT_SOUND_QUALITY:
PsndRate = sndrate_prevnext(PsndRate, inp & BTN_RIGHT); PsndRate = sndrate_prevnext(PsndRate, inp & PBTN_RIGHT);
break; break;
case MA_OPT_REGION: case MA_OPT_REGION:
region_prevnext(inp & BTN_RIGHT); region_prevnext(inp & PBTN_RIGHT);
break; break;
case MA_OPT_CONFIRM_STATES: { case MA_OPT_CONFIRM_STATES: {
int n = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2); int n = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2);
n += (inp & BTN_LEFT) ? -1 : 1; n += (inp & PBTN_LEFT) ? -1 : 1;
if (n < 0) n = 0; else if (n > 3) n = 3; if (n < 0) n = 0; else if (n > 3) n = 3;
n |= n << 1; n &= ~2; n |= n << 1; n &= ~2;
currentConfig.EmuOpt &= ~0xa00; currentConfig.EmuOpt &= ~0xa00;
@ -1407,14 +1407,14 @@ static int menu_loop_options(void)
break; break;
} }
case MA_OPT_SAVE_SLOT: case MA_OPT_SAVE_SLOT:
if (inp & BTN_RIGHT) { if (inp & PBTN_RIGHT) {
state_slot++; if (state_slot > 9) state_slot = 0; state_slot++; if (state_slot > 9) state_slot = 0;
} else {state_slot--; if (state_slot < 0) state_slot = 9; } else {state_slot--; if (state_slot < 0) state_slot = 9;
} }
break; break;
case MA_OPT_CPU_CLOCKS: case MA_OPT_CPU_CLOCKS:
while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) { while ((inp = psp_pad_read(0)) & (PBTN_LEFT|PBTN_RIGHT)) {
currentConfig.CPUclock += (inp & BTN_LEFT) ? -1 : 1; currentConfig.CPUclock += (inp & PBTN_LEFT) ? -1 : 1;
if (currentConfig.CPUclock < 19) currentConfig.CPUclock = 19; if (currentConfig.CPUclock < 19) currentConfig.CPUclock = 19;
if (currentConfig.CPUclock > 333) currentConfig.CPUclock = 333; if (currentConfig.CPUclock > 333) currentConfig.CPUclock = 333;
draw_menu_options(menu_sel); // will wait vsync draw_menu_options(menu_sel); // will wait vsync
@ -1423,7 +1423,7 @@ static int menu_loop_options(void)
case MA_OPT_SAVECFG: case MA_OPT_SAVECFG:
case MA_OPT_SAVECFG_GAME: case MA_OPT_SAVECFG_GAME:
case MA_OPT_LOADCFG: case MA_OPT_LOADCFG:
config_slot += (inp&BTN_RIGHT) ? 1 : -1; config_slot += (inp&PBTN_RIGHT) ? 1 : -1;
if (config_slot > 9) config_slot = 0; if (config_slot > 9) config_slot = 0;
if (config_slot < 0) config_slot = 9; if (config_slot < 0) config_slot = 9;
me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current); me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);
@ -1436,7 +1436,7 @@ static int menu_loop_options(void)
} }
} }
} }
if (inp & BTN_CIRCLE) { if (inp & PBTN_CIRCLE) {
if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, 1)) if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, 1))
{ {
switch (selected_id) switch (selected_id)
@ -1474,7 +1474,7 @@ static int menu_loop_options(void)
} }
} }
} }
if(inp & BTN_X) { if(inp & PBTN_X) {
menu_options_save(); menu_options_save();
return 0; // done (update, no write) return 0; // done (update, no write)
} }
@ -1576,29 +1576,29 @@ static void menu_loop_root(void)
/* make sure action buttons are not pressed on entering menu */ /* make sure action buttons are not pressed on entering menu */
draw_menu_root(menu_sel); draw_menu_root(menu_sel);
while (psp_pad_read(1) & (BTN_X|BTN_CIRCLE|BTN_SELECT)) psp_msleep(50); while (psp_pad_read(1) & (PBTN_X|PBTN_CIRCLE|PBTN_SELECT)) psp_msleep(50);
for (;;) for (;;)
{ {
draw_menu_root(menu_sel); draw_menu_root(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_X|BTN_CIRCLE|BTN_SELECT|BTN_L|BTN_R, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_X|PBTN_CIRCLE|PBTN_SELECT|PBTN_L|PBTN_R, 0);
if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if((inp & (BTN_L|BTN_R)) == (BTN_L|BTN_R)) debug_menu_loop(); if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop();
if( inp & (BTN_SELECT|BTN_X)) { if( inp & (PBTN_SELECT|PBTN_X)) {
if (rom_loaded) { if (rom_loaded) {
while (psp_pad_read(1) & (BTN_SELECT|BTN_X)) psp_msleep(50); // wait until released while (psp_pad_read(1) & (PBTN_SELECT|PBTN_X)) psp_msleep(50); // wait until released
engineState = PGS_Running; engineState = PGS_Running;
break; break;
} }
} }
if(inp & BTN_CIRCLE) { if(inp & PBTN_CIRCLE) {
menuErrorMsg[0] = 0; // clear error msg menuErrorMsg[0] = 0; // clear error msg
switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel)) switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel))
{ {
case MA_MAIN_RESUME_GAME: case MA_MAIN_RESUME_GAME:
if (rom_loaded) { if (rom_loaded) {
while (psp_pad_read(1) & BTN_CIRCLE) psp_msleep(50); while (psp_pad_read(1) & PBTN_CIRCLE) psp_msleep(50);
engineState = PGS_Running; engineState = PGS_Running;
return; return;
} }
@ -1615,7 +1615,7 @@ static void menu_loop_root(void)
if (rom_loaded) { if (rom_loaded) {
if(savestate_menu_loop(1)) if(savestate_menu_loop(1))
continue; continue;
while (psp_pad_read(1) & BTN_CIRCLE) psp_msleep(50); while (psp_pad_read(1) & PBTN_CIRCLE) psp_msleep(50);
engineState = PGS_Running; engineState = PGS_Running;
return; return;
} }
@ -1623,7 +1623,7 @@ static void menu_loop_root(void)
case MA_MAIN_RESET_GAME: case MA_MAIN_RESET_GAME:
if (rom_loaded) { if (rom_loaded) {
emu_ResetGame(); emu_ResetGame();
while (psp_pad_read(1) & BTN_CIRCLE) psp_msleep(50); while (psp_pad_read(1) & PBTN_CIRCLE) psp_msleep(50);
engineState = PGS_Running; engineState = PGS_Running;
return; return;
} }
@ -1660,8 +1660,8 @@ static void menu_loop_root(void)
draw_menu_credits(); draw_menu_credits();
psp_msleep(500); psp_msleep(500);
inp = 0; inp = 0;
while (!(inp & (BTN_X|BTN_CIRCLE))) while (!(inp & (PBTN_X|PBTN_CIRCLE)))
inp = wait_for_input(BTN_X|BTN_CIRCLE, 0); inp = wait_for_input(PBTN_X|PBTN_CIRCLE, 0);
break; break;
case MA_MAIN_EXIT: case MA_MAIN_EXIT:
engineState = PGS_Quit; engineState = PGS_Quit;
@ -1789,15 +1789,15 @@ int menu_loop_tray(void)
/* make sure action buttons are not pressed on entering menu */ /* make sure action buttons are not pressed on entering menu */
draw_menu_tray(menu_sel); draw_menu_tray(menu_sel);
while (psp_pad_read(1) & BTN_CIRCLE) psp_msleep(50); while (psp_pad_read(1) & PBTN_CIRCLE) psp_msleep(50);
for (;;) for (;;)
{ {
draw_menu_tray(menu_sel); draw_menu_tray(menu_sel);
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_CIRCLE, 0); inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_CIRCLE, 0);
if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if(inp & BTN_CIRCLE) { if(inp & PBTN_CIRCLE) {
switch (menu_sel) { switch (menu_sel) {
case 0: // select image case 0: // select image
selfname = romsel_loop(curr_path); selfname = romsel_loop(curr_path);

View file

@ -9,6 +9,6 @@ void menu_romload_prepare(const char *rom_name);
void menu_romload_end(void); void menu_romload_end(void);
#define CONFIGURABLE_KEYS (BTN_UP|BTN_LEFT|BTN_RIGHT|BTN_DOWN|BTN_L|BTN_R|BTN_TRIANGLE|BTN_CIRCLE|BTN_X|BTN_SQUARE|BTN_START| \ #define CONFIGURABLE_KEYS (PBTN_UP|PBTN_LEFT|PBTN_RIGHT|PBTN_DOWN|PBTN_L|PBTN_R|PBTN_TRIANGLE|PBTN_CIRCLE|PBTN_X|PBTN_SQUARE|PBTN_START| \
BTN_NUB_UP|BTN_NUB_RIGHT|BTN_NUB_DOWN|BTN_NUB_LEFT|BTN_NOTE) PBTN_NUB_UP|PBTN_NUB_RIGHT|PBTN_NUB_DOWN|PBTN_NUB_LEFT|PBTN_NOTE)

View file

@ -224,11 +224,11 @@ unsigned int psp_pad_read(int blocking)
buttons = pad.Buttons; buttons = pad.Buttons;
// analog.. // analog..
buttons &= ~(BTN_NUB_UP|BTN_NUB_DOWN|BTN_NUB_LEFT|BTN_NUB_RIGHT); buttons &= ~(PBTN_NUB_UP|PBTN_NUB_DOWN|PBTN_NUB_LEFT|PBTN_NUB_RIGHT);
if (pad.Lx < 128 - ANALOG_DEADZONE) buttons |= BTN_NUB_LEFT; if (pad.Lx < 128 - ANALOG_DEADZONE) buttons |= PBTN_NUB_LEFT;
if (pad.Lx > 128 + ANALOG_DEADZONE) buttons |= BTN_NUB_RIGHT; if (pad.Lx > 128 + ANALOG_DEADZONE) buttons |= PBTN_NUB_RIGHT;
if (pad.Ly < 128 - ANALOG_DEADZONE) buttons |= BTN_NUB_UP; if (pad.Ly < 128 - ANALOG_DEADZONE) buttons |= PBTN_NUB_UP;
if (pad.Ly > 128 + ANALOG_DEADZONE) buttons |= BTN_NUB_DOWN; if (pad.Ly > 128 + ANALOG_DEADZONE) buttons |= PBTN_NUB_DOWN;
return buttons; return buttons;
} }

View file

@ -48,23 +48,23 @@ void psp_wait_suspend(void);
void psp_resume_suspend(void); void psp_resume_suspend(void);
/* shorter btn names */ /* shorter btn names */
#define BTN_UP PSP_CTRL_UP #define PBTN_UP PSP_CTRL_UP
#define BTN_LEFT PSP_CTRL_LEFT #define PBTN_LEFT PSP_CTRL_LEFT
#define BTN_RIGHT PSP_CTRL_RIGHT #define PBTN_RIGHT PSP_CTRL_RIGHT
#define BTN_DOWN PSP_CTRL_DOWN #define PBTN_DOWN PSP_CTRL_DOWN
#define BTN_L PSP_CTRL_LTRIGGER #define PBTN_L PSP_CTRL_LTRIGGER
#define BTN_R PSP_CTRL_RTRIGGER #define PBTN_R PSP_CTRL_RTRIGGER
#define BTN_TRIANGLE PSP_CTRL_TRIANGLE #define PBTN_TRIANGLE PSP_CTRL_TRIANGLE
#define BTN_CIRCLE PSP_CTRL_CIRCLE #define PBTN_CIRCLE PSP_CTRL_CIRCLE
#define BTN_X PSP_CTRL_CROSS #define PBTN_X PSP_CTRL_CROSS
#define BTN_SQUARE PSP_CTRL_SQUARE #define PBTN_SQUARE PSP_CTRL_SQUARE
#define BTN_SELECT PSP_CTRL_SELECT #define PBTN_SELECT PSP_CTRL_SELECT
#define BTN_START PSP_CTRL_START #define PBTN_START PSP_CTRL_START
#define BTN_NOTE PSP_CTRL_NOTE // doesn't seem to work? #define PBTN_NOTE PSP_CTRL_NOTE // doesn't seem to work?
/* fake 'nub' btns */ /* fake 'nub' btns */
#define BTN_NUB_UP (1 << 28) #define PBTN_NUB_UP (1 << 28)
#define BTN_NUB_RIGHT (1 << 29) #define PBTN_NUB_RIGHT (1 << 29)
#define BTN_NUB_DOWN (1 << 30) #define PBTN_NUB_DOWN (1 << 30)
#define BTN_NUB_LEFT (1 << 31) #define PBTN_NUB_LEFT (1 << 31)