Skip to content

Commit

Permalink
u5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
notaz committed Jun 13, 2009
1 parent 73d1a85 commit 42c8119
Show file tree
Hide file tree
Showing 11 changed files with 281 additions and 67 deletions.
88 changes: 82 additions & 6 deletions gp2x/gp2x.c
Expand Up @@ -46,12 +46,12 @@ static u32 fb_paddr[fb_buf_count];
static void *fb_vaddr[fb_buf_count];
static u32 fb_work_buf;
static int fb_buf_use;
static int fbdev;

static void fb_video_init()
{
struct fb_fix_screeninfo fbfix;
int i, ret;
int fbdev;

fbdev = open("/dev/fb0", O_RDWR);
if (fbdev < 0) {
Expand All @@ -68,7 +68,6 @@ static void fb_video_init()

printf("framebuffer: \"%s\" @ %08lx\n", fbfix.id, fbfix.smem_start);
fb_paddr[0] = fbfix.smem_start;
close(fbdev);

fb_vaddr[0] = mmap(0, 320*240*2*fb_buf_count, PROT_READ|PROT_WRITE,
MAP_SHARED, gpsp_gp2x_dev, fb_paddr[0]);
Expand All @@ -95,7 +94,6 @@ static void fb_video_init()

void pollux_video_flip()
{
warm_cache_op_all(WOP_D_CLEAN);
gpsp_gp2x_memregl[0x406C>>2] = fb_paddr[fb_work_buf];
gpsp_gp2x_memregl[0x4058>>2] |= 0x10;
fb_work_buf++;
Expand All @@ -114,12 +112,90 @@ void fb_use_buffers(int count)
memset(fb_vaddr[0], 0, 320*240*2*count);
}

void wiz_lcd_set_portrait(int y)
{
static int old_y = -1;
int cmd[2] = { 0, 0 };

if (old_y == y)
return;
cmd[0] = y ? 6 : 5;
ioctl(fbdev, _IOW('D', 90, int[2]), cmd);
gpsp_gp2x_memregl[0x4004>>2] = y ? 0x013f00ef : 0x00ef013f;
gpsp_gp2x_memregl[0x4000>>2] |= 1 << 3;
old_y = y;
}

static void fb_video_exit()
{
/* switch to default fb mem */
/* switch to default fb mem, turn portrait off */
gpsp_gp2x_memregl[0x406C>>2] = fb_paddr[0];
gpsp_gp2x_memregl[0x4058>>2] |= 0x10;
wiz_lcd_set_portrait(0);
close(fbdev);
}

static int wiz_gamepak_fd = -1;
static u32 wiz_gamepak_size;

static void wiz_gamepak_cleanup()
{
if (wiz_gamepak_size)
munmap(gamepak_rom, wiz_gamepak_size);
if (wiz_gamepak_fd >= 0)
close(wiz_gamepak_fd);
gamepak_rom = NULL;
wiz_gamepak_size = 0;
wiz_gamepak_fd = -1;
}

u32 wiz_load_gamepak(char *name)
{
char *dot_position = strrchr(name, '.');
u32 ret;

if (!strcasecmp(dot_position, ".zip"))
{
if (wiz_gamepak_fd >= 0)
{
wiz_gamepak_cleanup();
printf("switching to ROM malloc\n");
init_gamepak_buffer();
}
return load_file_zip(name);
}

if (wiz_gamepak_fd < 0)
{
extern void *gamepak_memory_map;
free(gamepak_rom);
free(gamepak_memory_map);
gamepak_memory_map = NULL;
printf("switching to ROM mmap\n");
}
else
wiz_gamepak_cleanup();

wiz_gamepak_fd = open(name, O_RDONLY|O_NOATIME, S_IRUSR);
if (wiz_gamepak_fd < 0)
{
perror("wiz_load_gamepak: open failed");
return -1;
}

ret = lseek(wiz_gamepak_fd, 0, SEEK_END);
wiz_gamepak_size = gamepak_ram_buffer_size = ret;

gamepak_rom = mmap(0, ret, PROT_READ, MAP_SHARED, wiz_gamepak_fd, 0);
if (gamepak_rom == MAP_FAILED)
{
perror("wiz_load_gamepak: mmap failed");
return -1;
}

return ret;
}

#endif

static int get_romdir(char *buff, size_t size)
Expand Down Expand Up @@ -188,15 +264,15 @@ void gp2x_quit()
#ifdef WIZ_BUILD
close(gpsp_gp2x_gpiodev);
fb_video_exit();
wiz_gamepak_cleanup();
#endif
munmap((void *)gpsp_gp2x_memregl, 0x10000);
close(gpsp_gp2x_dev_audio);
close(gpsp_gp2x_dev);

fcloseall();
sync();
chdir("/usr/gp2x");
execl("gp2xmenu", "gp2xmenu", NULL);
exit(0);
}

void gp2x_sound_volume(u32 volume_up)
Expand Down
5 changes: 5 additions & 0 deletions gp2x/gp2x.h
Expand Up @@ -43,5 +43,10 @@ void upscale_aspect(u16 *dst, u16 *src);
extern void *gpsp_gp2x_screen;
void fb_use_buffers(int count);
void pollux_video_flip();
void wiz_lcd_set_portrait(int y);
u32 wiz_load_gamepak(char *name);

void do_rotated_blit(void *dst, void *linesx4, u32 y);
void upscale_aspect_row(void *dst, void *linesx3, u32 row);

#endif
8 changes: 7 additions & 1 deletion gp2x/readme_gp2x.txt
Expand Up @@ -12,6 +12,12 @@ not apply however).

Changelog:

0.9-2xb u5
- Added portrait drawing modes. They eliminate tearing but are slightly
slower.
- Added page scrolling in ROM browser with L/R.
- 32MB ROM support fixed.

0.9-2xb u4 (unofficial notaz release, done on Exophase's request)
- Wiz port. No emulation related changes.
- Wiz: dropped SDL for video and hitting hardware directly (GPH SDL can't
Expand All @@ -22,7 +28,7 @@ Changelog:
- gpSP now comes with wARM, new kernel module+lib for ARM cache control
(replaces mmuhack).
- gpSP no longer invalidates whole icache after recompilation, might
case minor speedup.
cause minor speedup.

0.9-2xb u3 (unofficial notaz release, released with permission):
- Removed built-in CPU/LCD/RAM-Tweaker.
Expand Down
81 changes: 67 additions & 14 deletions gui.c
Expand Up @@ -140,11 +140,11 @@ s32 load_file(u8 **wildcards, u8 *result)
u32 chosen_file, chosen_dir;
u32 dialog_result = 1;
s32 return_value = 1;
u32 current_file_selection;
u32 current_file_scroll_value;
s32 current_file_selection;
s32 current_file_scroll_value;
u32 current_dir_selection;
u32 current_dir_scroll_value;
u32 current_file_in_scroll;
s32 current_file_in_scroll;
u32 current_dir_in_scroll;
u32 current_file_number, current_dir_number;
u32 current_column = 0;
Expand Down Expand Up @@ -364,6 +364,13 @@ s32 load_file(u8 **wildcards, u8 *result)
current_file_in_scroll++;
}
}
else
{
clear_screen(COLOR_BG);
current_file_selection = 0;
current_file_scroll_value = 0;
current_file_in_scroll = 0;
}
}
else
{
Expand All @@ -384,6 +391,25 @@ s32 load_file(u8 **wildcards, u8 *result)

break;

case CURSOR_R:
if (current_column != 0)
break;
clear_screen(COLOR_BG);
current_file_selection += FILE_LIST_ROWS;
if (current_file_selection > num_files - 1)
current_file_selection = num_files - 1;
current_file_scroll_value = current_file_selection - FILE_LIST_ROWS / 2;
if (current_file_scroll_value < 0)
{
current_file_scroll_value = 0;
current_file_in_scroll = current_file_selection;
}
else
{
current_file_in_scroll = FILE_LIST_ROWS / 2;
}
break;

case CURSOR_UP:
if(current_column == 0)
{
Expand All @@ -400,6 +426,17 @@ s32 load_file(u8 **wildcards, u8 *result)
current_file_in_scroll--;
}
}
else
{
clear_screen(COLOR_BG);
current_file_selection = num_files - 1;
current_file_in_scroll = FILE_LIST_ROWS - 1;
if (current_file_in_scroll > num_files - 1)
current_file_in_scroll = num_files - 1;
current_file_scroll_value = num_files - FILE_LIST_ROWS;
if (current_file_scroll_value < 0)
current_file_scroll_value = 0;
}
}
else
{
Expand All @@ -419,7 +456,26 @@ s32 load_file(u8 **wildcards, u8 *result)
}
break;

case CURSOR_RIGHT:
case CURSOR_L:
if (current_column != 0)
break;
clear_screen(COLOR_BG);
current_file_selection -= FILE_LIST_ROWS;
if (current_file_selection < 0)
current_file_selection = 0;
current_file_scroll_value = current_file_selection - FILE_LIST_ROWS / 2;
if (current_file_scroll_value < 0)
{
current_file_scroll_value = 0;
current_file_in_scroll = current_file_selection;
}
else
{
current_file_in_scroll = FILE_LIST_ROWS / 2;
}
break;

case CURSOR_RIGHT:
if(current_column == 0)
{
if(num_dirs != 0)
Expand Down Expand Up @@ -951,7 +1007,7 @@ void get_savestate_snapshot(u8 *savestate_filename)
{
memset(snapshot_buffer, 0, 240 * 160 * 2);
print_string_ext("No savestate exists for this slot.",
0xFFFF, 0x0000, 15, 75, snapshot_buffer, 240, 0);
0xFFFF, 0x0000, 15, 75, snapshot_buffer, 240, 0, 0, FONT_HEIGHT);
print_string("---------- --/--/---- --:--:-- ", COLOR_HELP_TEXT,
COLOR_BG, 10, 40);
}
Expand Down Expand Up @@ -1179,7 +1235,8 @@ u32 menu(u16 *original_screen)
u8 *scale_options[] =
{
#ifdef WIZ_BUILD
"unscaled 3:2", "scaled 3:2 (slower)"
"unscaled 3:2", "scaled 3:2 (slower)",
"unscaled 3:2 (anti-tear)", "scaled 3:2 (anti-tear)"
#else
"unscaled 3:2", "scaled 3:2", "fullscreen"
#ifdef PSP_BUILD
Expand Down Expand Up @@ -1263,11 +1320,7 @@ u32 menu(u16 *original_screen)
{
string_selection_option(NULL, "Display scaling", scale_options,
(u32 *)(&screen_scale),
#ifdef WIZ_BUILD
2,
#else
3,
#endif
sizeof(scale_options) / sizeof(scale_options[0]),
#ifndef GP2X_BUILD
"Determines how the GBA screen is resized in relation to the entire\n"
"screen. Select unscaled 3:2 for GBA resolution, scaled 3:2 for GBA\n"
Expand Down Expand Up @@ -1581,7 +1634,7 @@ u32 menu(u16 *original_screen)
first_load = 1;
memset(original_screen, 0x00, 240 * 160 * 2);
print_string_ext("No game loaded yet.", 0xFFFF, 0x0000,
60, 75,original_screen, 240, 0);
60, 75,original_screen, 240, 0, 0, FONT_HEIGHT);
}

choose_menu(&main_menu);
Expand Down Expand Up @@ -1627,12 +1680,12 @@ u32 menu(u16 *original_screen)
if(display_option == current_option)
{
print_string_pad(line_buffer, COLOR_ACTIVE_ITEM, COLOR_BG, 10,
(display_option->line_number * 10) + 40, 36);
(display_option->line_number * 10) + 40, 41);
}
else
{
print_string_pad(line_buffer, COLOR_INACTIVE_ITEM, COLOR_BG, 10,
(display_option->line_number * 10) + 40, 36);
(display_option->line_number * 10) + 40, 41);
}
}

Expand Down
6 changes: 6 additions & 0 deletions input.c
Expand Up @@ -412,6 +412,12 @@ gui_action_type get_gui_input()
if(new_buttons & GP2X_RIGHT)
new_button = CURSOR_RIGHT;

if(new_buttons & GP2X_L)
new_button = CURSOR_L;

if(new_buttons & GP2X_R)
new_button = CURSOR_R;


if(new_button != CURSOR_NONE)
{
Expand Down
2 changes: 2 additions & 0 deletions input.h
Expand Up @@ -70,6 +70,8 @@ typedef enum
CURSOR_SELECT,
CURSOR_BACK,
CURSOR_EXIT,
CURSOR_L,
CURSOR_R,
CURSOR_NONE
} gui_action_type;

Expand Down

0 comments on commit 42c8119

Please sign in to comment.