From e11c55481f1703298b3e7e213f73cec8a136f974 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 9 Feb 2007 22:09:07 +0000 Subject: [PATCH] menu bg, pc linux build git-svn-id: file:///home/notaz/opt/svn/PicoDrive@34 be3aeb3a-fb24-0410-a615-afba39da0efa --- platform/gp2x/emu.c | 11 +++++- platform/gp2x/gp2x.c | 48 +++++++++++++++++------ platform/gp2x/gp2x.h | 3 ++ platform/gp2x/menu.c | 72 ++++++++++++++++++++++------------ platform/linux/940ctl_ym2612.c | 41 +++++++++++++------ platform/linux/gp2x.c | 14 +++++++ 6 files changed, 141 insertions(+), 48 deletions(-) diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 871d05fd..36408f48 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -634,7 +634,7 @@ static int EmuScan8(unsigned int num, void *sdata) return 0; } -static int localPal[0x100]; +int localPal[0x100]; static void (*vidCpyM2)(void *dest, void *src) = NULL; static void blit(char *fps, char *notice) @@ -1001,6 +1001,7 @@ void emu_Loop(void) // make sure we are in correct mode vidResetMode(); + Pico.m.dirtyPal = 1; oldmodes = ((Pico.video.reg[12]&1)<<2) ^ 0xc; find_combos(); @@ -1227,6 +1228,14 @@ if (Pico.m.frame_count == 31563) { emu_SaveLoadGame(0, 1); SRam.changed = 0; } + + // if in 16bit mode, generate 8it image for menu background + if (!(PicoOpt&0x10) && (currentConfig.EmuOpt&0x80)) { + PicoOpt |= 0x10; + PicoFrameFull(); + blit("", NULL); blit("", NULL); blit("", NULL); blit("", NULL); // be sure buffer3 gets updated + PicoOpt &= ~0x10; + } } diff --git a/platform/gp2x/gp2x.c b/platform/gp2x/gp2x.c index b02a6856..0d0017b4 100644 --- a/platform/gp2x/gp2x.c +++ b/platform/gp2x/gp2x.c @@ -59,27 +59,45 @@ static unsigned short gp2x_screenaddr_old[4]; void gp2x_video_flip(void) { unsigned int address = gp2x_screenaddrs[screensel&3]; + unsigned short msb16 = (unsigned short)(address >> 16); + unsigned short lsb16 = (unsigned short)(address); - /* test */ -/* { - int i; char *p=gp2x_screen; - for (i=0; i < 240; i++) { memset(p+i*320, 0, 32); } - }*/ - - gp2x_memregs[0x290E>>1]=(unsigned short)(address); - gp2x_memregs[0x2910>>1]=(unsigned short)(address >> 16); - gp2x_memregs[0x2912>>1]=(unsigned short)(address); - gp2x_memregs[0x2914>>1]=(unsigned short)(address >> 16); + gp2x_memregs[0x290E>>1] = lsb16; + gp2x_memregs[0x2910>>1] = msb16; + gp2x_memregs[0x2912>>1] = lsb16; + gp2x_memregs[0x2914>>1] = msb16; // jump to other buffer: gp2x_screen = gp2x_screens[++screensel&3]; } +/* doulblebuffered flip */ +void gp2x_video_flip2(void) +{ + unsigned int address = gp2x_screenaddrs[screensel&1]; + unsigned short msb16 = (unsigned short)(address >> 16); + unsigned short lsb16 = (unsigned short)(address); -void gp2x_video_changemode(int bpp) + gp2x_memregs[0x290E>>1] = lsb16; + gp2x_memregs[0x2910>>1] = msb16; + gp2x_memregs[0x2912>>1] = lsb16; + gp2x_memregs[0x2914>>1] = msb16; + + // jump to other buffer: + gp2x_screen = gp2x_screens[++screensel&1]; +} + + +void gp2x_video_changemode2(int bpp) { gp2x_memregs[0x28DA>>1]=(((bpp+1)/8)<<9)|0xAB; /*8/15/16/24bpp...*/ gp2x_memregs[0x290C>>1]=320*((bpp+1)/8); /*line width in bytes*/ +} + + +void gp2x_video_changemode(int bpp) +{ + gp2x_video_changemode2(bpp); gp2x_memset_all_buffers(0, 0, 640*480); gp2x_video_flip(); @@ -148,6 +166,14 @@ void gp2x_memset_all_buffers(int offset, int byte, int len) } +void gp2x_pd_clone_buffer2(void) +{ + memcpy(gp2x_screen, gp2x_screens[2], 320*240); + memset(gp2x_screen, 0xe0, 320*8); + memset(gp2x_screen + 320*232, 0xe0, 320*8); +} + + unsigned long gp2x_joystick_read(int allow_usb_joy) { int i; diff --git a/platform/gp2x/gp2x.h b/platform/gp2x/gp2x.h index f76736d7..bddfc29c 100644 --- a/platform/gp2x/gp2x.h +++ b/platform/gp2x/gp2x.h @@ -8,12 +8,15 @@ void gp2x_deinit(void); /* video */ void gp2x_video_flip(void); +void gp2x_video_flip2(void); void gp2x_video_changemode(int bpp); +void gp2x_video_changemode2(int bpp); void gp2x_video_setpalette(int *pal, int len); void gp2x_video_RGB_setscaling(int W, int H); void gp2x_video_wait_vsync(void); void gp2x_memcpy_all_buffers(void *data, int offset, int len); void gp2x_memset_all_buffers(int offset, int byte, int len); +void gp2x_pd_clone_buffer2(void); /* sound */ void gp2x_start_sound(int rate, int bits, int stereo); diff --git a/platform/gp2x/menu.c b/platform/gp2x/menu.c index 24337421..5d807e80 100644 --- a/platform/gp2x/menu.c +++ b/platform/gp2x/menu.c @@ -164,7 +164,7 @@ void gp2x_text_out8(int x, int y, char *texto, ...) vsprintf(buffer,texto,args); va_end(args); - gp2x_text(gp2x_screen,x,y,buffer,1); + gp2x_text(gp2x_screen,x,y,buffer,0xf0); } @@ -182,7 +182,7 @@ void gp2x_text_out8_lim(int x, int y, char *texto, int max) if (max < 0) max = 0; buffer[max] = 0; - gp2x_text(gp2x_screen,x,y,buffer,1); + gp2x_text(gp2x_screen,x,y,buffer,0xf0); } @@ -279,7 +279,8 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) start = 12 - sel; n--; // exclude current dir (".") - memset(gp2x_screen, 0, 320*240); + //memset(gp2x_screen, 0, 320*240); + gp2x_pd_clone_buffer2(); if(start - 2 >= 0) gp2x_text_out8_lim(14, (start - 2)*10, curdir, 38); @@ -295,7 +296,7 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) } } gp2x_text_out8(5, 120, ">"); - gp2x_video_flip(); + gp2x_video_flip2(); } static int scandir_cmp(const void *p1, const void *p2) @@ -460,7 +461,8 @@ static void draw_key_config(int curr_act, int is_p2) } } - memset(gp2x_screen, 0, 320*240); + //memset(gp2x_screen, 0, 320*240); + gp2x_pd_clone_buffer2(); gp2x_text_out8(60, 40, "Action: %s", actionNames[curr_act]); gp2x_text_out8(60, 60, "Keys: %s", strkeys); @@ -468,7 +470,7 @@ static void draw_key_config(int curr_act, int is_p2) gp2x_text_out8(30, 190, "Press a key to bind/unbind"); gp2x_text_out8(30, 200, "Select \"Done\" action and"); gp2x_text_out8(30, 210, " press any key to finish"); - gp2x_video_flip(); + gp2x_video_flip2(); } static void key_config_loop(int is_p2) @@ -515,7 +517,8 @@ static void draw_kc_sel(int menu_sel) char joyname[36]; y = tl_y; - memset(gp2x_screen, 0, 320*240); + //memset(gp2x_screen, 0, 320*240); + gp2x_pd_clone_buffer2(); gp2x_text_out8(tl_x, y, "Player 1"); gp2x_text_out8(tl_x, (y+=10), "Player 2"); gp2x_text_out8(tl_x, (y+=10), "Done"); @@ -535,7 +538,7 @@ static void draw_kc_sel(int menu_sel) } - gp2x_video_flip(); + gp2x_video_flip2(); } static void kc_sel_loop(void) @@ -569,7 +572,9 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j int tl_x = 25, tl_y = 60, y; y = tl_y; - memset(gp2x_screen, 0, 320*240); + //memset(gp2x_screen, 0, 320*240); + gp2x_pd_clone_buffer2(); + gp2x_text_out8(tl_x, y, "USA BIOS: %s", b_us); // 0 gp2x_text_out8(tl_x, (y+=10), "EUR BIOS: %s", b_eu); // 1 gp2x_text_out8(tl_x, (y+=10), "JAP BIOS: %s", b_jp); // 2 @@ -586,7 +591,7 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j (menu_sel == 2 && strcmp(b_jp, "NOT FOUND"))) gp2x_text_out8(tl_x, 220, "Press start to test selected BIOS"); - gp2x_video_flip(); + gp2x_video_flip2(); } static void cd_menu_loop_options(void) @@ -659,7 +664,9 @@ static void draw_amenu_options(int menu_sel) char *mms = mmuhack_status ? "active) " : "inactive)"; y = tl_y; - memset(gp2x_screen, 0, 320*240); + //memset(gp2x_screen, 0, 320*240); + gp2x_pd_clone_buffer2(); + gp2x_text_out8(tl_x, y, "Scale 32 column mode %s", (currentConfig.PicoOpt&0x100)?"ON":"OFF"); // 0 gp2x_text_out8(tl_x, (y+=10), "Gamma correction %i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); // 1 gp2x_text_out8(tl_x, (y+=10), "Emulate Z80 %s", (currentConfig.PicoOpt&0x004)?"ON":"OFF"); // 2 @@ -675,7 +682,7 @@ static void draw_amenu_options(int menu_sel) // draw cursor gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">"); - gp2x_video_flip(); + gp2x_video_flip2(); } static void amenu_loop_options(void) @@ -761,7 +768,9 @@ static void draw_menu_options(int menu_sel) } y = tl_y; - memset(gp2x_screen, 0, 320*240); + //memset(gp2x_screen, 0, 320*240); + gp2x_pd_clone_buffer2(); + gp2x_text_out8(tl_x, y, "Renderer: %s", strrend); // 0 gp2x_text_out8(tl_x, (y+=10), "Accurate timing (slower) %s", (currentConfig.PicoOpt&0x040)?"ON":"OFF"); // 1 gp2x_text_out8(tl_x, (y+=10), "Accurate sprites (slower) %s", (currentConfig.PicoOpt&0x080)?"ON":"OFF"); // 2 @@ -785,7 +794,7 @@ static void draw_menu_options(int menu_sel) // draw cursor gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">"); - gp2x_video_flip(); + gp2x_video_flip2(); } static int sndrate_prevnext(int rate, int dir) @@ -937,7 +946,8 @@ static int menu_loop_options(void) static void draw_menu_credits(void) { int tl_x = 15, tl_y = 70, y; - memset(gp2x_screen, 0, 320*240); + //memset(gp2x_screen, 0, 320*240); + gp2x_pd_clone_buffer2(); gp2x_text_out8(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007"); y = tl_y; @@ -956,7 +966,7 @@ static void draw_menu_credits(void) gp2x_text_out8(tl_x, (y+=10), "GnoStiC / Puck2099: USB joystick"); gp2x_text_out8(tl_x, (y+=10), "craigix: GP2X hardware"); - gp2x_video_flip(); + gp2x_video_flip2(); } @@ -965,7 +975,8 @@ static void draw_menu_credits(void) static void draw_menu_root(int menu_sel) { int tl_x = 70, tl_y = 70, y; - memset(gp2x_screen, 0, 320*240); + //memset(gp2x_screen, 0, 320*240); + gp2x_pd_clone_buffer2(); gp2x_text_out8(tl_x, 20, "PicoDrive v" VERSION); @@ -988,7 +999,7 @@ static void draw_menu_root(int menu_sel) gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">"); // error if (menuErrorMsg[0]) gp2x_text_out8(5, 226, menuErrorMsg); - gp2x_video_flip(); + gp2x_video_flip2(); } @@ -1087,17 +1098,28 @@ static void menu_loop_root(void) } -void menu_loop(void) +static void menu_gfx_prepare(void) { - int pal[2]; + extern int localPal[0x100]; + int i; + + // don't clear old palette just for fun (but make it dark) + for (i = 0x100-1; i >= 0; i--) + localPal[i] = (localPal[i] >> 2) & 0x003f3f3f; + localPal[0xe0] = 0x00000000; // reserved pixels for OSD + localPal[0xf0] = 0x00ffffff; // switch to 8bpp - gp2x_video_changemode(8); + gp2x_video_changemode2(8); gp2x_video_RGB_setscaling(320, 240); - // set pal - pal[0] = 0; - pal[1] = 0x00ffffff; - gp2x_video_setpalette(pal, 2); + gp2x_video_setpalette(localPal, 0x100); + gp2x_video_flip2(); +} + + +void menu_loop(void) +{ + menu_gfx_prepare(); menu_loop_root(); diff --git a/platform/linux/940ctl_ym2612.c b/platform/linux/940ctl_ym2612.c index 915ac0a5..86435e46 100644 --- a/platform/linux/940ctl_ym2612.c +++ b/platform/linux/940ctl_ym2612.c @@ -24,7 +24,7 @@ YM2612 *ym2612_940 = &ym2612; // static _940_data_t shared_data_; static _940_ctl_t shared_ctl_; // static _940_data_t *shared_data = &shared_data_; -static _940_ctl_t *shared_ctl = &shared_ctl_; +_940_ctl_t *shared_ctl = &shared_ctl_; unsigned char *mp3_mem = 0; @@ -32,15 +32,6 @@ unsigned char *mp3_mem = 0; /***********************************************************/ -#define MAXOUT (+32767) -#define MINOUT (-32768) - -/* limitter */ -#define Limit(val, max,min) { \ - if ( val > max ) val = max; \ - else if ( val < min ) val = min; \ -} - int YM2612Write_940(unsigned int a, unsigned int v) { @@ -80,10 +71,18 @@ void YM2612PicoStateLoad_940(void) } -void YM2612Init_940(int baseclock, int rate) +void sharedmem_init(void) { mp3_mem = malloc(MP3_SIZE_MAX); +} + +void sharedmem_deinit(void) +{ + free(mp3_mem); +} +void YM2612Init_940(int baseclock, int rate) +{ YM2612Init_(baseclock, rate); } @@ -184,6 +183,12 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty) } +void mp3_update(int *buffer, int length, int stereo) +{ + // nothing.. +} + + /***********************************************************/ void mp3_start_play(FILE *f, int pos) // pos is 0-1023 @@ -218,3 +223,17 @@ int mp3_get_offset(void) return 0; } + +/* unimplemented... */ +void mix_16h_to_32(int *dest_buf, short *mp3_buf, int count) +{ +} + +void mix_16h_to_32_s1(int *dest_buf, short *mp3_buf, int count) +{ +} + +void mix_16h_to_32_s2(int *dest_buf, short *mp3_buf, int count) +{ +} + diff --git a/platform/linux/gp2x.c b/platform/linux/gp2x.c index 6e442433..38ab0533 100644 --- a/platform/linux/gp2x.c +++ b/platform/linux/gp2x.c @@ -236,11 +236,21 @@ void gp2x_video_flip(void) gdk_threads_leave(); } +void gp2x_video_flip2(void) +{ + gp2x_video_flip(); +} + void gp2x_video_changemode(int bpp) { current_bpp = bpp; } +void gp2x_video_changemode2(int bpp) +{ + current_bpp = bpp; +} + void gp2x_video_setpalette(int *pal, int len) { memcpy(current_pal, pal, len*4); @@ -261,6 +271,10 @@ void gp2x_memset_all_buffers(int offset, int byte, int len) memset((char *)gp2x_screen + offset, byte, len); } +void gp2x_pd_clone_buffer2(void) +{ + memset(gp2x_screen, 0, 320*240); +} /* sound */ static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0; -- 2.39.5