From 64c2278395831444b08718a29368ae355c9b6014 Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Tue, 6 Jul 2010 14:03:50 +0000 Subject: [PATCH] .fixed GX_REPEAT texture rendering .added new default menu background --- source/gx/config.c | 6 +- source/gx/config.h | 2 +- source/gx/gui/filesel.c | 33 ++++-- source/gx/gui/gui.h | 1 + source/gx/gui/menu.c | 198 ++++++++++++++-------------------- source/gx/gui/menu.h | 3 +- source/gx/gx_video.c | 2 +- source/gx/images/Bg_layer.png | Bin 0 -> 260 bytes source/gx/main.c | 3 +- source/gx/osd.h | 1 - 10 files changed, 117 insertions(+), 132 deletions(-) create mode 100644 source/gx/images/Bg_layer.png diff --git a/source/gx/config.c b/source/gx/config.c index 542b8e2..c4e18db 100644 --- a/source/gx/config.c +++ b/source/gx/config.c @@ -21,6 +21,7 @@ * ***************************************************************************/ #include "shared.h" +#include "menu.h" void config_save(void) { @@ -123,7 +124,7 @@ void config_default(void) #endif config.s_default = 1; config.s_device = 0; - config.bg_color = 0; + config.bg_type = 0; config.bg_overlay = 0; config.screen_w = 658; config.bgm_volume = 100.0; @@ -140,5 +141,8 @@ void config_default(void) /* restore from config file */ config_load(); io_init(); + + /* default menu settings */ + menu_configure(); } diff --git a/source/gx/config.h b/source/gx/config.h index dc20924..8a883a6 100644 --- a/source/gx/config.h +++ b/source/gx/config.h @@ -76,7 +76,7 @@ typedef struct uint8 s_auto; uint8 s_default; uint8 s_device; - int8 bg_color; + int8 bg_type; int8 bg_overlay; int16 screen_w; float bgm_volume; diff --git a/source/gx/gui/filesel.c b/source/gx/gui/filesel.c index cc27c6f..f337080 100644 --- a/source/gx/gui/filesel.c +++ b/source/gx/gui/filesel.c @@ -93,7 +93,7 @@ static gui_image bg_filesel[10] = {NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255}, {NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255}, {NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255}, - {NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,200}, + {NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,150}, {NULL,Frame_s2_png,0,384,264,248,140,200}, {NULL,Snap_empty_png,IMAGE_VISIBLE,422,114,164,116,255}, {NULL,NULL,0,424,116,160,112,255}, @@ -243,15 +243,30 @@ int FileSelector(unsigned char *buffer, bool useFAT) gui_butn *button; #endif - /* Background Settings */ - if (config.bg_color == 0) - bg_filesel[0].data = Bg_main_2_png; + /* background type */ + if (config.bg_type > 0) + { + bg_filesel[0].state &= ~IMAGE_REPEAT; + if (config.bg_type > 1) bg_filesel[0].data = Bg_main_png; + else bg_filesel[0].data = Bg_main_2_png; + bg_filesel[0].x = 374; + bg_filesel[0].y = 140; + bg_filesel[0].w = 284; + bg_filesel[0].h = 288; + } else - bg_filesel[0].data = Bg_main_png; - if (config.bg_overlay) - bg_filesel[1].state |= IMAGE_VISIBLE; - else - bg_filesel[1].state &= ~IMAGE_VISIBLE; + { + bg_filesel[0].state |= IMAGE_REPEAT; + bg_filesel[0].data = Bg_layer_png; + bg_filesel[0].x = 0; + bg_filesel[0].y = 0; + bg_filesel[0].w = 640; + bg_filesel[0].h = 480; + } + + /* background overlay */ + if (config.bg_overlay) bg_filesel[1].state |= IMAGE_VISIBLE; + else bg_filesel[1].state &= ~IMAGE_VISIBLE; /* Initialize Menu */ gui_menu *m = &menu_browser; diff --git a/source/gx/gui/gui.h b/source/gx/gui/gui.h index 2f32a66..ffe861f 100644 --- a/source/gx/gui/gui.h +++ b/source/gx/gui/gui.h @@ -153,6 +153,7 @@ extern gx_texture *w_pointer; #endif /* Generic backgrounds */ +extern const u8 Bg_layer_png[]; extern const u8 Bg_main_png[]; extern const u8 Bg_main_2_png[]; extern const u8 Bg_overlay_png[]; diff --git a/source/gx/gui/menu.c b/source/gx/gui/menu.c index 81c2ce2..39910d7 100644 --- a/source/gx/gui/menu.c +++ b/source/gx/gui/menu.c @@ -561,26 +561,17 @@ static void prefmenu () gui_item *items = m->items; sprintf (items[0].text, "Load ROM Auto: %s", config.autoload ? "ON":"OFF"); - if (config.s_auto == 3) - sprintf (items[1].text, "Auto Saves: ALL"); - else if (config.s_auto == 2) - sprintf (items[1].text, "Auto Saves: STATE ONLY"); - else if (config.s_auto == 1) - sprintf (items[1].text, "Auto Saves: SRAM ONLY"); - else - sprintf (items[1].text, "Auto Saves: NONE"); - if (config.s_device == 1) - sprintf (items[2].text, "Saves Device: MCARD A"); - else if (config.s_device == 2) - sprintf (items[2].text, "Saves Device: MCARD B"); - else - sprintf (items[2].text, "Saves Device: FAT"); + if (config.s_auto == 3) sprintf (items[1].text, "Auto Saves: ALL"); + else if (config.s_auto == 2) sprintf (items[1].text, "Auto Saves: STATE ONLY"); + else if (config.s_auto == 1) sprintf (items[1].text, "Auto Saves: SRAM ONLY"); + else sprintf (items[1].text, "Auto Saves: NONE"); + if (config.s_device == 1) sprintf (items[2].text, "Saves Device: MCARD A"); + else if (config.s_device == 2) sprintf (items[2].text, "Saves Device: MCARD B"); + else sprintf (items[2].text, "Saves Device: FAT"); sprintf (items[3].text, "SFX Volume: %1.1f", config.sfx_volume); sprintf (items[4].text, "BGM Volume: %1.1f", config.bgm_volume); - if (config.bg_color) - sprintf (items[5].text, "BG Color: TYPE %d", config.bg_color); - else - sprintf (items[5].text, "BG Color: DEFAULT"); + if (config.bg_type) sprintf (items[5].text, "BG Type: COLOR %d", config.bg_type - 1); + else sprintf (items[5].text, "BG Type: DEFAULT"); sprintf (items[6].text, "BG Overlay: %s", config.bg_overlay ? "ON":"OFF"); sprintf (items[7].text, "Screen Width: %d", config.screen_w); @@ -600,24 +591,17 @@ static void prefmenu () case 1: /*** Auto load/save STATE & SRAM files ***/ config.s_auto = (config.s_auto + 1) % 4; - if (config.s_auto == 3) - sprintf (items[ret].text, "Auto Saves: ALL"); - else if (config.s_auto == 2) - sprintf (items[ret].text, "Auto Saves: STATE ONLY"); - else if (config.s_auto == 1) - sprintf (items[ret].text, "Auto Saves: SRAM ONLY"); - else - sprintf (items[ret].text, "Auto Saves: NONE"); + if (config.s_auto == 3) sprintf (items[ret].text, "Auto Saves: ALL"); + else if (config.s_auto == 2) sprintf (items[ret].text, "Auto Saves: STATE ONLY"); + else if (config.s_auto == 1) sprintf (items[ret].text, "Auto Saves: SRAM ONLY"); + else sprintf (items[ret].text, "Auto Saves: NONE"); break; case 2: /*** Default saves device ***/ config.s_device = (config.s_device + 1) % 3; - if (config.s_device == 1) - sprintf (items[ret].text, "Saves Device: MCARD A"); - else if (config.s_device == 2) - sprintf (items[ret].text, "Saves Device: MCARD B"); - else - sprintf (items[ret].text, "Saves Device: FAT"); + if (config.s_device == 1) sprintf (items[ret].text, "Saves Device: MCARD A"); + else if (config.s_device == 2) sprintf (items[ret].text, "Saves Device: MCARD B"); + else sprintf (items[ret].text, "Saves Device: FAT"); break; case 3: /*** Sound effects volume ***/ @@ -630,64 +614,27 @@ static void prefmenu () sprintf (items[ret].text, "BGM Volume: %1.1f", config.bgm_volume); break; - case 5: /*** Background color ***/ - if (ret < 0) - config.bg_color --; - else - config.bg_color ++; - if (config.bg_color < 0) - config.bg_color = BG_COLOR_MAX - 1; - else if (config.bg_color >= BG_COLOR_MAX) - config.bg_color = 0; - if (config.bg_color) - sprintf (items[ret].text, "BG Color: TYPE %d", config.bg_color); - else - sprintf (items[ret].text, "BG Color: DEFAULT"); - GUI_SetBgColor((u8)config.bg_color); + case 5: /*** Background type ***/ + if (ret < 0) config.bg_type --; + else config.bg_type++; + if (config.bg_type < 0) config.bg_type = BG_COLOR_MAX; + else if (config.bg_type > BG_COLOR_MAX) config.bg_type = 0; + if (config.bg_type) sprintf (items[5].text, "BG Type: COLOR %d", config.bg_type - 1); + else sprintf (items[5].text, "BG Type: DEFAULT"); GUI_DeleteMenu(m); - if (config.bg_color == 0) - { - bg_main[0].data = Bg_main_2_png; - bg_misc[0].data = Bg_main_2_png; - bg_ctrls[0].data = Bg_main_2_png; - bg_list[0].data = Bg_main_2_png; - bg_saves[1].data = Bg_main_2_png; - } - else - { - bg_main[0].data = Bg_main_png; - bg_misc[0].data = Bg_main_png; - bg_ctrls[0].data = Bg_main_png; - bg_list[0].data = Bg_main_png; - bg_saves[1].data = Bg_main_png; - } + menu_configure(); GUI_InitMenu(m); break; - case 6: /*** Background items ***/ + case 6: /*** Background overlay ***/ config.bg_overlay ^= 1; - if (config.bg_overlay) - { - bg_main[1].state |= IMAGE_VISIBLE; - bg_misc[1].state |= IMAGE_VISIBLE; - bg_ctrls[1].state |= IMAGE_VISIBLE; - bg_list[1].state |= IMAGE_VISIBLE; - bg_saves[2].state |= IMAGE_VISIBLE; - } - else - { - bg_main[1].state &= ~IMAGE_VISIBLE; - bg_misc[1].state &= ~IMAGE_VISIBLE; - bg_ctrls[1].state &= ~IMAGE_VISIBLE; - bg_list[1].state &= ~IMAGE_VISIBLE; - bg_saves[2].state &= ~IMAGE_VISIBLE; - } - sprintf (items[ret].text, "BG Overlay: %s", config.bg_overlay ? "ON":"OFF"); + sprintf (items[6].text, "BG Overlay: %s", config.bg_overlay ? "ON":"OFF"); + menu_configure(); break; case 7: /*** Screen Width ***/ GUI_OptionBox(m,update_screen_w,"Screen Width",(void *)&config.screen_w,2,640,VI_MAX_WIDTH_NTSC,1); - sprintf (items[ret].text, "Screen Width: %d", config.screen_w); + sprintf (items[7].text, "Screen Width: %d", config.screen_w); break; case -1: @@ -2838,7 +2785,7 @@ static void exitmenu(void) * Main Menu * ****************************************************************************/ -void MainMenu (void) +void menu_execute(void) { char filename[MAXPATHLEN]; int quit = 0; @@ -2885,41 +2832,6 @@ void MainMenu (void) m->buttons[8].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); } - /* Update background */ - GUI_SetBgColor((u8)config.bg_color); - if (config.bg_color == 0) - { - bg_main[0].data = Bg_main_2_png; - bg_misc[0].data = Bg_main_2_png; - bg_ctrls[0].data = Bg_main_2_png; - bg_list[0].data = Bg_main_2_png; - bg_saves[1].data = Bg_main_2_png; - } - else - { - bg_main[0].data = Bg_main_png; - bg_misc[0].data = Bg_main_png; - bg_ctrls[0].data = Bg_main_png; - bg_list[0].data = Bg_main_png; - bg_saves[1].data = Bg_main_png; - } - if (config.bg_overlay) - { - bg_main[1].state |= IMAGE_VISIBLE; - bg_misc[1].state |= IMAGE_VISIBLE; - bg_ctrls[1].state |= IMAGE_VISIBLE; - bg_list[1].state |= IMAGE_VISIBLE; - bg_saves[2].state |= IMAGE_VISIBLE; - } - else - { - bg_main[1].state &= ~IMAGE_VISIBLE; - bg_misc[1].state &= ~IMAGE_VISIBLE; - bg_ctrls[1].state &= ~IMAGE_VISIBLE; - bg_list[1].state &= ~IMAGE_VISIBLE; - bg_saves[2].state &= ~IMAGE_VISIBLE; - } - GUI_InitMenu(m); GUI_DrawMenuFX(m,10,0); @@ -3033,3 +2945,55 @@ void MainMenu (void) uselessinquiry (); #endif } + +void menu_configure(void) +{ + /* background type */ + if (config.bg_type > 0) + { + GUI_SetBgColor((u8)(config.bg_type - 1)); + bg_main[0].state &= ~IMAGE_REPEAT; + bg_misc[0].state &= ~IMAGE_REPEAT; + bg_ctrls[0].state &= ~IMAGE_REPEAT; + bg_list[0].state &= ~IMAGE_REPEAT; + bg_saves[1].state &= ~IMAGE_REPEAT; + if (config.bg_type > 1) bg_main[0].data = bg_misc[0].data = bg_ctrls[0].data = bg_list[0].data = bg_saves[1].data = Bg_main_png; + else bg_main[0].data = bg_misc[0].data = bg_ctrls[0].data = bg_list[0].data = bg_saves[1].data = Bg_main_2_png; + bg_main[0].x = bg_misc[0].x = bg_ctrls[0].x = bg_list[0].x = bg_saves[1].x = 374; + bg_main[0].y = bg_misc[0].y = bg_ctrls[0].y = bg_list[0].y = bg_saves[1].y = 140; + bg_main[0].w = bg_misc[0].w = bg_ctrls[0].w = bg_list[0].w = bg_saves[1].w = 284; + bg_main[0].h = bg_misc[0].h = bg_ctrls[0].h = bg_list[0].h = bg_saves[1].h = 288; + } + else + { + GUI_SetBgColor(0); + bg_main[0].state |= IMAGE_REPEAT; + bg_misc[0].state |= IMAGE_REPEAT; + bg_ctrls[0].state |= IMAGE_REPEAT; + bg_list[0].state |= IMAGE_REPEAT; + bg_saves[1].state |= IMAGE_REPEAT; + bg_main[0].data = bg_misc[0].data = bg_ctrls[0].data = bg_list[0].data = bg_saves[1].data = Bg_layer_png; + bg_main[0].x = bg_misc[0].x = bg_ctrls[0].x = bg_list[0].x = bg_saves[1].x = 0; + bg_main[0].y = bg_misc[0].y = bg_ctrls[0].y = bg_list[0].y = bg_saves[1].y = 0; + bg_main[0].w = bg_misc[0].w = bg_ctrls[0].w = bg_list[0].w = bg_saves[1].w = 640; + bg_main[0].h = bg_misc[0].h = bg_ctrls[0].h = bg_list[0].h = bg_saves[1].h = 480; + } + + /* background overlay */ + if (config.bg_overlay) + { + bg_main[1].state |= IMAGE_VISIBLE; + bg_misc[1].state |= IMAGE_VISIBLE; + bg_ctrls[1].state |= IMAGE_VISIBLE; + bg_list[1].state |= IMAGE_VISIBLE; + bg_saves[2].state |= IMAGE_VISIBLE; + } + else + { + bg_main[1].state &= ~IMAGE_VISIBLE; + bg_misc[1].state &= ~IMAGE_VISIBLE; + bg_ctrls[1].state &= ~IMAGE_VISIBLE; + bg_list[1].state &= ~IMAGE_VISIBLE; + bg_saves[2].state &= ~IMAGE_VISIBLE; + } +} diff --git a/source/gx/gui/menu.h b/source/gx/gui/menu.h index 52fc842..5e9617b 100644 --- a/source/gx/gui/menu.h +++ b/source/gx/gui/menu.h @@ -104,7 +104,8 @@ extern const u8 ctrl_nunchuk_png[]; extern const u8 ctrl_wiimote_png[]; #endif -extern void MainMenu (void); +extern void menu_execute(void); +extern void menu_configure(void); #endif diff --git a/source/gx/gx_video.c b/source/gx/gx_video.c index 0e30577..87862fa 100644 --- a/source/gx/gx_video.c +++ b/source/gx/gx_video.c @@ -747,7 +747,7 @@ void gxDrawTextureRepeat(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alp { /* load texture object */ GXTexObj texObj; - GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_MIRROR, GX_MIRROR, GX_FALSE); + GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_REPEAT, GX_REPEAT, GX_FALSE); GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_InvalidateTexAll(); diff --git a/source/gx/images/Bg_layer.png b/source/gx/images/Bg_layer.png new file mode 100644 index 0000000000000000000000000000000000000000..b37186ea9a65ee64b0b880a538228adb54bd581a GIT binary patch literal 260 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmSQK*5Dp-y;YjHK@;M7UB8wRq zxITa|qthCb86X`ct`Q}{`DrEPiAAXlzKO|2`MIennTZN+nMJAP`9;~q3ceA$Cu*qx z)mC}BIEGZrd3)8HtHFVX`9g}shhmTQ4-W0_UU0dhJ*;5zJK=jZ3v9mmdi1DFII_uS zrUgSn%Z1CC3@R6+v`tvFUiu$nVCFG6&~TqI)=T&Bdj=J6R>6tq`UHOMI=8gx^PT`p umyc|(&VT={ZgK#ku+CmtHtfpwhuqow