From 3e76213c96184d28b0f5dd36509ba153f863d4e7 Mon Sep 17 00:00:00 2001 From: dborth Date: Sat, 27 Jun 2009 20:06:26 +0000 Subject: [PATCH] add DI_Close, don't wait for net init before entering game, add filename text scrolling, improved efficiency on text wrapping, add reset button for mappings, change video callbacks to avoid over-reading pads --- readme.txt | 2 + source/ngc/FreeTypeGX.cpp | 2 + source/ngc/dvd.cpp | 6 +- source/ngc/filebrowser.cpp | 2 +- source/ngc/filebrowser.h | 3 +- source/ngc/filelist.h | 6 + source/ngc/fileop.cpp | 11 +- source/ngc/gcunzip.cpp | 10 +- source/ngc/gui/gui.h | 18 ++- source/ngc/gui/gui_filebrowser.cpp | 6 + source/ngc/gui/gui_text.cpp | 204 ++++++++++++++++++------ source/ngc/images/button_short.png | Bin 0 -> 1690 bytes source/ngc/images/button_short_over.png | Bin 0 -> 1775 bytes source/ngc/input.cpp | 169 +++++++++++++------- source/ngc/input.h | 3 +- source/ngc/memcardop.cpp | 4 +- source/ngc/menu.cpp | 93 ++++++++--- source/ngc/networkop.cpp | 2 +- source/ngc/networkop.h | 1 + source/ngc/vba.cpp | 1 + source/ngc/video.cpp | 46 +----- source/ngc/video.h | 1 + 22 files changed, 397 insertions(+), 193 deletions(-) create mode 100644 source/ngc/images/button_short.png create mode 100644 source/ngc/images/button_short_over.png diff --git a/readme.txt b/readme.txt index 4dee656..2213c28 100644 --- a/readme.txt +++ b/readme.txt @@ -31,6 +31,8 @@ With it you can play GBA/Game Boy Color/Game Boy games on your Wii/GameCube. [2.0.4] * Increase file browser listing to 10 entries, decrease font size +* Added text scrolling on file browser +* Added reset button for controller mappings * Settings are now loaded from USB when loading the app from USB on HBC * Fixed menu crashes caused by ogg player bugs * Fixed memory card saving verification bug diff --git a/source/ngc/FreeTypeGX.cpp b/source/ngc/FreeTypeGX.cpp index 0cbab38..32110be 100644 --- a/source/ngc/FreeTypeGX.cpp +++ b/source/ngc/FreeTypeGX.cpp @@ -680,6 +680,7 @@ void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 te GX_Color4u8(color.r, color.g, color.b, color.a); GX_TexCoord2f32(0.0f, 1.0f); GX_End(); + GX_DrawDone(); this->setDefaultMode(); } @@ -713,6 +714,7 @@ void FreeTypeGX::copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, i GX_Position2s16(screenX, featureHeight + screenY); GX_Color4u8(color.r, color.g, color.b, color.a); GX_End(); + GX_DrawDone(); this->setDefaultMode(); } diff --git a/source/ngc/dvd.cpp b/source/ngc/dvd.cpp index 3d009f5..18a2587 100644 --- a/source/ngc/dvd.cpp +++ b/source/ngc/dvd.cpp @@ -16,9 +16,7 @@ #include #ifdef HW_RVL -extern "C" { #include -} #endif #include "vba.h" @@ -364,7 +362,6 @@ static int getentry (int entrycount, unsigned char dvdbuffer[]) { char fname[512]; /* Huge, but experience has determined this */ - char tmpname[512]; char *ptr; char *filename; char *filenamelength; @@ -466,8 +463,7 @@ getentry (int entrycount, unsigned char dvdbuffer[]) } else { - StripExt(tmpname, fname); // hide file extension - strncpy (browserList[entrycount].displayname, tmpname, MAXDISPLAY); + StripExt(browserList[entrycount].displayname, browserList[entrycount].filename); // hide file extension } memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4); diff --git a/source/ngc/filebrowser.cpp b/source/ngc/filebrowser.cpp index 5f6ff76..de3bc38 100644 --- a/source/ngc/filebrowser.cpp +++ b/source/ngc/filebrowser.cpp @@ -352,7 +352,7 @@ void StripExt(char* returnstring, char * inputstring) { char* loc_dot; - strncpy (returnstring, inputstring, 255); + strncpy (returnstring, inputstring, MAXJOLIET); if(inputstring == NULL || strlen(inputstring) < 4) return; diff --git a/source/ngc/filebrowser.h b/source/ngc/filebrowser.h index d800661..7653540 100644 --- a/source/ngc/filebrowser.h +++ b/source/ngc/filebrowser.h @@ -15,7 +15,6 @@ #include #define MAXJOLIET 255 -#define MAXDISPLAY 37 typedef struct { @@ -32,7 +31,7 @@ typedef struct time_t mtime; // file modified time char isdir; // 0 - file, 1 - directory char filename[MAXJOLIET + 1]; // full filename - char displayname[MAXDISPLAY + 1]; // name for browser display + char displayname[MAXJOLIET + 1]; // name for browser display } BROWSERENTRY; extern BROWSERINFO browser; diff --git a/source/ngc/filelist.h b/source/ngc/filelist.h index 2571350..95f51a3 100644 --- a/source/ngc/filelist.h +++ b/source/ngc/filelist.h @@ -89,6 +89,12 @@ extern const u32 button_png_size; extern const u8 button_over_png[]; extern const u32 button_over_png_size; +extern const u8 button_short_png[]; +extern const u32 button_short_png_size; + +extern const u8 button_short_over_png[]; +extern const u32 button_short_over_png_size; + extern const u8 button_small_png[]; extern const u32 button_small_png_size; diff --git a/source/ngc/fileop.cpp b/source/ngc/fileop.cpp index 50eb973..0845f30 100644 --- a/source/ngc/fileop.cpp +++ b/source/ngc/fileop.cpp @@ -75,6 +75,11 @@ HaltDeviceThread() { deviceHalt = true; + #ifdef HW_RVL + if(inNetworkInit) // don't wait for network to initialize + return; + #endif + // wait for thread to finish while(!LWP_ThreadIsSuspended(devicethread)) usleep(100); @@ -120,8 +125,8 @@ devicecallback (void *arg) } } - InitializeNetwork(SILENT); UpdateCheck(); + InitializeNetwork(SILENT); #else if(isMounted[METHOD_SD_SLOTA]) { @@ -318,7 +323,6 @@ ParseDirectory(int method) DIR_ITER *dir = NULL; char fulldir[MAXPATHLEN]; char filename[MAXPATHLEN]; - char tmpname[MAXPATHLEN]; struct stat filestat; char msg[128]; int retry = 1; @@ -390,8 +394,7 @@ ParseDirectory(int method) } else { - ShortenFilename(tmpname, filename); // hide file extension - strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display + StripExt(browserList[entryNum].displayname, browserList[entryNum].filename); // hide file extension } browserList[entryNum].length = filestat.st_size; diff --git a/source/ngc/gcunzip.cpp b/source/ngc/gcunzip.cpp index 3d5972d..d1aa198 100644 --- a/source/ngc/gcunzip.cpp +++ b/source/ngc/gcunzip.cpp @@ -3,7 +3,7 @@ * * Tantric September 2008 * - * unzip.cpp + * gcunzip.cpp * * File unzip routines ***************************************************************************/ @@ -482,11 +482,9 @@ int SzParse(char * filepath, int method) } memset(&(browserList[SzJ]), 0, sizeof(BROWSERENTRY)); // clear the new entry - // parse information about this file to the dvd file list structure - strncpy(browserList[SzJ].filename, SzF->Name, MAXJOLIET); // copy joliet name (useless...) - char tmpname[MAXJOLIET+1] = ""; - ShortenFilename(tmpname, browserList[SzJ].filename); - strncpy(browserList[SzJ].displayname, tmpname, MAXDISPLAY); // crop name for display + // parse information about this file to the file list structure + strncpy(browserList[SzJ].filename, SzF->Name, MAXJOLIET); + StripExt(browserList[SzJ].displayname, browserList[SzJ].filename); browserList[SzJ].length = SzF->Size; // filesize browserList[SzJ].offset = SzI; // the extraction function identifies the file with this number browserList[SzJ].isdir = 0; // only files will be displayed (-> no flags) diff --git a/source/ngc/gui/gui.h b/source/ngc/gui/gui.h index e62b133..89d5ca1 100644 --- a/source/ngc/gui/gui.h +++ b/source/ngc/gui/gui.h @@ -102,6 +102,12 @@ enum TRIGGER_BUTTON_ONLY_IN_FOCUS }; +enum +{ + SCROLL_NONE, + SCROLL_HORIZONTAL +}; + typedef struct _paddata { u16 btns_d; u16 btns_u; @@ -613,7 +619,9 @@ class GuiText : public GuiElement //!Sets the maximum width of the drawn texture image //!If the text exceeds this, it is wrapped to the next line //!\param w Maximum width - void SetMaxWidth(int w); + void SetMaxWidth(int width); + void SetScroll(int s); + void SetWrap(bool w, int width = 0); //!Sets the font color //!\param c Font color void SetColor(GXColor c); @@ -627,9 +635,16 @@ class GuiText : public GuiElement //!Constantly called to draw the text void Draw(); protected: + char * origText; wchar_t* text; //!< Unicode text value int size; //!< Font size int maxWidth; //!< Maximum width of the generated text object (for text wrapping) + bool wrap; + wchar_t* textDyn; + int textScroll; + int textScrollPos; + int textScrollInitialDelay; + int textScrollDelay; u16 style; //!< FreeTypeGX style attributes GXColor color; //!< Font color }; @@ -930,4 +945,3 @@ class GuiFileBrowser : public GuiElement }; #endif - diff --git a/source/ngc/gui/gui_filebrowser.cpp b/source/ngc/gui/gui_filebrowser.cpp index 0e28e67..44c08c9 100644 --- a/source/ngc/gui/gui_filebrowser.cpp +++ b/source/ngc/gui/gui_filebrowser.cpp @@ -103,6 +103,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h) fileListText[i] = new GuiText(NULL, 20, (GXColor){0, 0, 0, 0xff}); fileListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); fileListText[i]->SetPosition(5,0); + fileListText[i]->SetMaxWidth(380); fileListBg[i] = new GuiImage(bgGameSelectionEntry); fileListFolder[i] = new GuiImage(gameFolder); @@ -375,6 +376,11 @@ void GuiFileBrowser::Update(GuiTrigger * t) selectedItem = i; browser.selIndex = browser.pageIndex + i; } + + if(selectedItem == i) + fileListText[i]->SetScroll(SCROLL_HORIZONTAL); + else + fileListText[i]->SetScroll(SCROLL_NONE); } // update the location of the scroll box based on the position in the file list diff --git a/source/ngc/gui/gui_text.cpp b/source/ngc/gui/gui_text.cpp index f3254a3..c432403 100644 --- a/source/ngc/gui/gui_text.cpp +++ b/source/ngc/gui/gui_text.cpp @@ -18,23 +18,36 @@ static int presetAlignmentVert = 0; static u16 presetStyle = 0; static GXColor presetColor = (GXColor){255, 255, 255, 255}; +#define TEXT_SCROLL_DELAY 8 +#define TEXT_SCROLL_INITIAL_DELAY 6 + /** * Constructor for the GuiText class. */ GuiText::GuiText(const char * t, int s, GXColor c) { + origText = NULL; text = NULL; size = s; color = c; alpha = c.a; style = FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE; maxWidth = 0; + wrap = false; + textDyn = NULL; + textScroll = SCROLL_NONE; + textScrollPos = 0; + textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; + textScrollDelay = TEXT_SCROLL_DELAY; alignmentHor = ALIGN_CENTRE; alignmentVert = ALIGN_MIDDLE; if(t) + { + origText = strdup(t); text = fontSystem->charToWideChar((char *)t); + } } /** @@ -42,18 +55,28 @@ GuiText::GuiText(const char * t, int s, GXColor c) */ GuiText::GuiText(const char * t) { + origText = NULL; text = NULL; size = presetSize; color = presetColor; alpha = presetColor.a; style = presetStyle; maxWidth = presetMaxWidth; + wrap = false; + textDyn = NULL; + textScroll = SCROLL_NONE; + textScrollPos = 0; + textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; + textScrollDelay = TEXT_SCROLL_DELAY; alignmentHor = presetAlignmentHor; alignmentVert = presetAlignmentVert; if(t) + { + origText = strdup(t); text = fontSystem->charToWideChar((char *)t); + } } /** @@ -61,22 +84,34 @@ GuiText::GuiText(const char * t) */ GuiText::~GuiText() { + if(origText) + free(origText); if(text) - { delete text; - text = NULL; - } + if(textDyn) + delete textDyn; } void GuiText::SetText(const char * t) { + if(origText) + free(origText); if(text) delete text; + if(textDyn) + delete textDyn; + origText = NULL; text = NULL; + textDyn = NULL; + textScrollPos = 0; + textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; if(t) + { + origText = strdup(t); text = fontSystem->charToWideChar((char *)t); + } } void GuiText::SetPresets(int sz, GXColor c, int w, u16 s, int h, int v) @@ -94,9 +129,31 @@ void GuiText::SetFontSize(int s) size = s; } -void GuiText::SetMaxWidth(int w) +void GuiText::SetMaxWidth(int width) { - maxWidth = w; + maxWidth = width; +} + +void GuiText::SetWrap(bool w, int width) +{ + wrap = w; + maxWidth = width; +} + +void GuiText::SetScroll(int s) +{ + if(textScroll == s) + return; + + if(textDyn) + { + delete(textDyn); + textDyn = NULL; + } + textScroll = s; + textScrollPos = 0; + textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; + textScrollDelay = TEXT_SCROLL_DELAY; } void GuiText::SetColor(GXColor c) @@ -170,61 +227,116 @@ void GuiText::Draw() if(alignmentVert == ALIGN_MIDDLE) voffset = -newSize/2 + 2; - if(maxWidth > 0) // text wrapping + if(maxWidth > 0) { - int lineheight = newSize + 6; - int strlen = wcslen(text); - int i = 0; - int ch = 0; - int linenum = 0; - int lastSpace = -1; - int lastSpaceIndex = -1; - wchar_t * tmptext[20]; + char * tmpText = strdup(origText); + u8 maxChar = (maxWidth*2.0) / newSize; - while(ch < strlen) + if(!textDyn) { - if(i == 0) - tmptext[linenum] = new wchar_t[strlen + 1]; + if(strlen(tmpText) > maxChar) + tmpText[maxChar] = 0; + textDyn = fontSystem->charToWideChar(tmpText); + } - tmptext[linenum][i] = text[ch]; - tmptext[linenum][i+1] = 0; + if(textScroll == SCROLL_HORIZONTAL) + { + int textlen = strlen(origText); - if(text[ch] == ' ' || ch == strlen-1) + if(textlen > maxChar && (FrameTimer % textScrollDelay == 0)) { - if(fontSystem->getWidth(tmptext[linenum]) >= maxWidth) + if(textScrollInitialDelay) { - if(lastSpace >= 0) + textScrollInitialDelay--; + } + else + { + textScrollPos++; + if(textScrollPos > textlen-1) { - tmptext[linenum][lastSpaceIndex] = 0; // discard space, and everything after - ch = lastSpace; // go backwards to the last space - lastSpace = -1; // we have used this space - lastSpaceIndex = -1; + textScrollPos = 0; + textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; } - linenum++; - i = -1; - } - else if(ch == strlen-1) - { - linenum++; + + strncpy(tmpText, &origText[textScrollPos], maxChar-1); + tmpText[maxChar-1] = 0; + + int dynlen = strlen(tmpText); + + if(dynlen+2 < maxChar) + { + tmpText[dynlen] = ' '; + tmpText[dynlen+1] = ' '; + strncat(&tmpText[dynlen+2], origText, maxChar - dynlen - 2); + } + if(textDyn) delete textDyn; + textDyn = fontSystem->charToWideChar(tmpText); } } - if(text[ch] == ' ' && i >= 0) - { - lastSpace = ch; - lastSpaceIndex = i; - } - ch++; - i++; + if(textDyn) + fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset, textDyn, c, style); } - - if(alignmentVert == ALIGN_MIDDLE) - voffset = voffset - (lineheight*linenum)/2 + lineheight/2; - - for(i=0; i < linenum; i++) + else if(wrap) { - fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, tmptext[i], c, style); - delete tmptext[i]; + int lineheight = newSize + 6; + int txtlen = wcslen(text); + int i = 0; + int ch = 0; + int linenum = 0; + int lastSpace = -1; + int lastSpaceIndex = -1; + wchar_t * textrow[20]; + + while(ch < txtlen) + { + if(i == 0) + textrow[linenum] = new wchar_t[txtlen + 1]; + + textrow[linenum][i] = text[ch]; + textrow[linenum][i+1] = 0; + + if(text[ch] == ' ' || ch == txtlen-1) + { + if(wcslen(textrow[linenum]) >= maxChar) + { + if(lastSpace >= 0) + { + textrow[linenum][lastSpaceIndex] = 0; // discard space, and everything after + ch = lastSpace; // go backwards to the last space + lastSpace = -1; // we have used this space + lastSpaceIndex = -1; + } + linenum++; + i = -1; + } + else if(ch == txtlen-1) + { + linenum++; + } + } + if(text[ch] == ' ' && i >= 0) + { + lastSpace = ch; + lastSpaceIndex = i; + } + ch++; + i++; + } + + if(alignmentVert == ALIGN_MIDDLE) + voffset = voffset - (lineheight*linenum)/2 + lineheight/2; + + for(i=0; i < linenum; i++) + { + fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, textrow[i], c, style); + delete textrow[i]; + } } + else + { + fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset, textDyn, c, style); + } + free(tmpText); } else { diff --git a/source/ngc/images/button_short.png b/source/ngc/images/button_short.png new file mode 100644 index 0000000000000000000000000000000000000000..73d289379f6e90b3ce7d9c2af9d6ca7d82cd2707 GIT binary patch literal 1690 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 RxW@nh002ovPDHLkV1j5$NgDtF literal 0 HcmV?d00001 diff --git a/source/ngc/input.cpp b/source/ngc/input.cpp index 9e66936..55ad26a 100644 --- a/source/ngc/input.cpp +++ b/source/ngc/input.cpp @@ -43,10 +43,8 @@ int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0; unsigned int vbapadmap[10]; // VBA controller buttons u32 btnmap[5][10]; // button mapping -void ResetControls() +void ResetControls(int wiiCtrl) { - memset(btnmap, 0, sizeof(btnmap)); - int i; // VBA controller buttons @@ -64,69 +62,116 @@ void ResetControls() vbapadmap[i++] = VBA_BUTTON_R; /*** Gamecube controller Padmap ***/ - i=0; - btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_B; - btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_A; - btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_Z; - btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_START; - btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_UP; - btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_DOWN; - btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_LEFT; - btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_RIGHT; - btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_L; - btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_R; + if(wiiCtrl == CTRLR_GCPAD || wiiCtrl == 0) + { + i=0; + btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_B; + btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_A; + btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_Z; + btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_START; + btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_UP; + btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_DOWN; + btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_LEFT; + btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_RIGHT; + btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_L; + btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_R; + } /*** Wiimote Padmap ***/ - i=0; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_1; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_2; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_MINUS; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_PLUS; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_RIGHT; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_LEFT; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_UP; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_DOWN; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_B; - btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_A; + if(wiiCtrl == CTRLR_WIIMOTE || wiiCtrl == 0) + { + i=0; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_1; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_2; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_MINUS; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_PLUS; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_RIGHT; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_LEFT; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_UP; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_DOWN; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_B; + btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_A; + } /*** Classic Controller Padmap ***/ - i=0; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_Y; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_B; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_MINUS; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_PLUS; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_UP; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_DOWN; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_LEFT; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_RIGHT; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L; - btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_R; + if(wiiCtrl == CTRLR_CLASSIC || wiiCtrl == 0) + { + i=0; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_Y; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_B; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_MINUS; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_PLUS; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_UP; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_DOWN; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_LEFT; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_RIGHT; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L; + btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_R; + } /*** Nunchuk + wiimote Padmap ***/ - i=0; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_C; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_Z; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_MINUS; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_PLUS; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_UP; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_DOWN; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_LEFT; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_RIGHT; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_2; - btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_1; + if(wiiCtrl == CTRLR_NUNCHUK || wiiCtrl == 0) + { + i=0; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_C; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_Z; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_MINUS; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_PLUS; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_UP; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_DOWN; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_LEFT; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_RIGHT; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_2; + btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_1; + } /*** Keyboard map ***/ - i=0; - btnmap[CTRLR_KEYBOARD][i++] = KB_X; // VBA stupidly has B on the right instead of left - btnmap[CTRLR_KEYBOARD][i++] = KB_Z; - btnmap[CTRLR_KEYBOARD][i++] = KB_BKSP; - btnmap[CTRLR_KEYBOARD][i++] = KB_ENTER; - btnmap[CTRLR_KEYBOARD][i++] = KB_UP; - btnmap[CTRLR_KEYBOARD][i++] = KB_DOWN; - btnmap[CTRLR_KEYBOARD][i++] = KB_LEFT; - btnmap[CTRLR_KEYBOARD][i++] = KB_RIGHT; - btnmap[CTRLR_KEYBOARD][i++] = KB_A; - btnmap[CTRLR_KEYBOARD][i++] = KB_S; + if(wiiCtrl == CTRLR_KEYBOARD || wiiCtrl == 0) + { + i=0; + btnmap[CTRLR_KEYBOARD][i++] = KB_X; // VBA stupidly has B on the right instead of left + btnmap[CTRLR_KEYBOARD][i++] = KB_Z; + btnmap[CTRLR_KEYBOARD][i++] = KB_BKSP; + btnmap[CTRLR_KEYBOARD][i++] = KB_ENTER; + btnmap[CTRLR_KEYBOARD][i++] = KB_UP; + btnmap[CTRLR_KEYBOARD][i++] = KB_DOWN; + btnmap[CTRLR_KEYBOARD][i++] = KB_LEFT; + btnmap[CTRLR_KEYBOARD][i++] = KB_RIGHT; + btnmap[CTRLR_KEYBOARD][i++] = KB_A; + btnmap[CTRLR_KEYBOARD][i++] = KB_S; + } +} + +/**************************************************************************** + * UpdatePads + * + * called by PostRetraceCallback in InitGCVideo - scans pad and wpad + ***************************************************************************/ +void +UpdatePads() +{ + #ifdef HW_RVL + WPAD_ScanPads(); + #endif + PAD_ScanPads(); + + for(int i=3; i >= 0; i--) + { + #ifdef HW_RVL + memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData)); + #endif + + userInput[i].chan = i; + userInput[i].pad.btns_d = PAD_ButtonsDown(i); + userInput[i].pad.btns_u = PAD_ButtonsUp(i); + userInput[i].pad.btns_h = PAD_ButtonsHeld(i); + userInput[i].pad.stickX = PAD_StickX(i); + userInput[i].pad.stickY = PAD_StickY(i); + userInput[i].pad.substickX = PAD_SubStickX(i); + userInput[i].pad.substickY = PAD_SubStickY(i); + userInput[i].pad.triggerL = PAD_TriggerL(i); + userInput[i].pad.triggerR = PAD_TriggerR(i); + } } #ifdef HW_RVL @@ -180,7 +225,7 @@ static void updateRumble() bool r = false; if (ConfigRequested) r = (menuRumbleCount > 0); else r = cartridgeRumble || possibleCartridgeRumble || (gameRumbleCount > 0) || (menuRumbleCount > 0); - + if (SilenceNeeded>0) { if (r) SilenceNeeded = 5; else SilenceNeeded--; @@ -888,7 +933,7 @@ static u32 DecodeJoy(unsigned short pad) // One Piece case ONEPIECE: return OnePieceInput(pad); - + // Lord of the Rings case HOBBIT: return HobbitInput(pad); @@ -897,7 +942,7 @@ static u32 DecodeJoy(unsigned short pad) case LOTR2: case LOTR3: return ReturnOfTheKingInput(pad); - + // Castlevania case CVADVENTURE: return CastlevaniaAdventureInput(pad); @@ -959,6 +1004,8 @@ bool MenuRequested() u32 GetJoy(int pad) { + UpdatePads(); + // request to go back to menu if (MenuRequested()) { diff --git a/source/ngc/input.h b/source/ngc/input.h index 8115dcc..1df17ad 100644 --- a/source/ngc/input.h +++ b/source/ngc/input.h @@ -34,7 +34,7 @@ extern int rumbleRequest[4]; extern u32 btnmap[5][10]; -void ResetControls(); +void ResetControls(int wc = 0); void ShutoffRumble(); void DoRumble(int i); void systemGameRumble(int RumbleForFrames); @@ -43,5 +43,6 @@ void updateRumbleFrame(); s8 WPAD_Stick(u8 chan,u8 right, int axis); u32 GetJoy(int which); bool MenuRequested(); +void UpdatePads(); #endif diff --git a/source/ngc/memcardop.cpp b/source/ngc/memcardop.cpp index 99c3407..303d69c 100644 --- a/source/ngc/memcardop.cpp +++ b/source/ngc/memcardop.cpp @@ -99,7 +99,6 @@ ParseMCDirectory (int slot) card_dir CardDir; int CardError; int entryNum = 0; - char tmpname[MAXPATHLEN]; // Try to mount the card CardError = MountMC(slot, NOTSILENT); @@ -125,8 +124,7 @@ ParseMCDirectory (int slot) memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry strncpy(browserList[entryNum].filename, (char *)CardDir.filename, MAXJOLIET); - ShortenFilename(tmpname, (char *)CardDir.filename); // hide file extension - strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display + StripExt(browserList[entryNum].displayname, browserList[entryNum].filename); // hide file extension browserList[entryNum].length = CardDir.filelen; entryNum++; diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index c0b2bde..3b8d27e 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -141,7 +141,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, const ch GuiText msgTxt(msg, 26, (GXColor){0, 0, 0, 255}); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msgTxt.SetPosition(0,-20); - msgTxt.SetMaxWidth(430); + msgTxt.SetWrap(true, 430); GuiText btn1Txt(btn1Label, 24, (GXColor){0, 0, 0, 255}); GuiImage btn1Img(&btnOutline); @@ -1087,7 +1087,7 @@ static int MenuGame() sprintf(s, "Weather: Night Time"); } else sprintf(s, "Weather: %d%% sun", SunBars*10); sunBtnTxt = new GuiText(s, 24, (GXColor){0, 0, 0, 255}); - sunBtnTxt->SetMaxWidth(btnLargeOutline.GetWidth()-30); + sunBtnTxt->SetWrap(true, btnLargeOutline.GetWidth()-30); sunBtnImg = new GuiImage(&btnLargeOutline); sunBtnImgOver = new GuiImage(&btnLargeOutlineOver); sunBtn = new GuiButton(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); @@ -1119,7 +1119,7 @@ static int MenuGame() resetBtn.SetEffectGrow(); GuiText gameSettingsBtnTxt("Game Settings", 24, (GXColor){0, 0, 0, 255}); - gameSettingsBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); + gameSettingsBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage gameSettingsBtnImg(&btnLargeOutline); GuiImage gameSettingsBtnImgOver(&btnLargeOutlineOver); GuiImage gameSettingsBtnIcon(&iconGameSettings); @@ -1466,7 +1466,7 @@ static int MenuGameSaves(int action) GuiImage backBtnImgOver(&btnOutlineOver); GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - backBtn.SetPosition(100, -35); + backBtn.SetPosition(50, -35); backBtn.SetLabel(&backBtnTxt); backBtn.SetImage(&backBtnImg); backBtn.SetImageOver(&backBtnImgOver); @@ -1736,7 +1736,7 @@ static int MenuGameSettings() trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); GuiText mappingBtnTxt("Button Mappings", 24, (GXColor){0, 0, 0, 255}); - mappingBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); + mappingBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage mappingBtnImg(&btnLargeOutline); GuiImage mappingBtnImgOver(&btnLargeOutlineOver); GuiImage mappingBtnIcon(&iconMappings); @@ -1753,7 +1753,7 @@ static int MenuGameSettings() mappingBtn.SetEffectGrow(); GuiText videoBtnTxt("Video", 24, (GXColor){0, 0, 0, 255}); - videoBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); + videoBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage videoBtnImg(&btnLargeOutline); GuiImage videoBtnImgOver(&btnLargeOutlineOver); GuiImage videoBtnIcon(&iconVideo); @@ -1834,7 +1834,7 @@ static int MenuGameSettings() GuiImage backBtnImgOver(&btnOutlineOver); GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - backBtn.SetPosition(100, -35); + backBtn.SetPosition(50, -35); backBtn.SetLabel(&backBtnTxt); backBtn.SetImage(&backBtnImg); backBtn.SetImageOver(&backBtnImgOver); @@ -1957,7 +1957,7 @@ static int MenuGameSettings() GuiImage backBtnImgOver(&btnOutlineOver); GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - backBtn.SetPosition(100, -35); + backBtn.SetPosition(50, -35); backBtn.SetLabel(&backBtnTxt); backBtn.SetImage(&backBtnImg); backBtn.SetImageOver(&backBtnImgOver); @@ -2034,7 +2034,7 @@ static int MenuSettingsMappings() trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiText gamecubeBtnTxt("GameCube Controller", 24, (GXColor){0, 0, 0, 255}); - gamecubeBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); + gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage gamecubeBtnImg(&btnLargeOutline); GuiImage gamecubeBtnImgOver(&btnLargeOutlineOver); GuiImage gamecubeBtnIcon(&iconGamecube); @@ -2067,7 +2067,7 @@ static int MenuSettingsMappings() wiimoteBtn.SetEffectGrow(); GuiText classicBtnTxt("Classic Controller", 24, (GXColor){0, 0, 0, 255}); - classicBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); + classicBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage classicBtnImg(&btnLargeOutline); GuiImage classicBtnImgOver(&btnLargeOutlineOver); GuiImage classicBtnIcon(&iconClassic); @@ -2132,7 +2132,7 @@ static int MenuSettingsMappings() GuiImage backBtnImgOver(&btnOutlineOver); GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - backBtn.SetPosition(100, -35); + backBtn.SetPosition(50, -35); backBtn.SetLabel(&backBtnTxt); backBtn.SetImage(&backBtnImg); backBtn.SetImageOver(&backBtnImgOver); @@ -2248,7 +2248,7 @@ ButtonMappingWindow() GuiText msgTxt(msg, 26, (GXColor){0, 0, 0, 255}); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msgTxt.SetPosition(0,-20); - msgTxt.SetMaxWidth(430); + msgTxt.SetWrap(true, 430); promptWindow.Append(&dialogBoxImg); promptWindow.Append(&titleTxt); @@ -2359,6 +2359,8 @@ static int MenuSettingsMappingsMap() GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM); GuiImageData btnOutline(button_png); GuiImageData btnOutlineOver(button_over_png); + GuiImageData btnShortOutline(button_short_png); + GuiImageData btnShortOutlineOver(button_short_over_png); GuiTrigger trigA; if(GCSettings.WiimoteOrientation) @@ -2371,7 +2373,7 @@ static int MenuSettingsMappingsMap() GuiImage backBtnImgOver(&btnOutlineOver); GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - backBtn.SetPosition(100, -35); + backBtn.SetPosition(50, -35); backBtn.SetLabel(&backBtnTxt); backBtn.SetImage(&backBtnImg); backBtn.SetImageOver(&backBtnImgOver); @@ -2380,6 +2382,20 @@ static int MenuSettingsMappingsMap() backBtn.SetTrigger(&trigA); backBtn.SetEffectGrow(); + GuiText resetBtnTxt("Reset", 24, (GXColor){0, 0, 0, 255}); + GuiImage resetBtnImg(&btnShortOutline); + GuiImage resetBtnImgOver(&btnShortOutlineOver); + GuiButton resetBtn(btnShortOutline.GetWidth(), btnShortOutline.GetHeight()); + resetBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); + resetBtn.SetPosition(260, -35); + resetBtn.SetLabel(&resetBtnTxt); + resetBtn.SetImage(&resetBtnImg); + resetBtn.SetImageOver(&resetBtnImgOver); + resetBtn.SetSoundOver(&btnSoundOver); + resetBtn.SetSoundClick(&btnSoundClick); + resetBtn.SetTrigger(&trigA); + resetBtn.SetEffectGrow(); + i=0; sprintf(options.name[i++], "B"); sprintf(options.name[i++], "A"); @@ -2393,6 +2409,9 @@ static int MenuSettingsMappingsMap() sprintf(options.name[i++], "R"); options.length = i; + for(i=0; i < options.length; i++) + options.value[i][0] = 0; + GuiOptionBrowser optionBrowser(552, 248, &options); optionBrowser.SetPosition(0, 108); optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); @@ -2401,6 +2420,7 @@ static int MenuSettingsMappingsMap() HaltGui(); GuiWindow w(screenwidth, screenheight); w.Append(&backBtn); + w.Append(&resetBtn); mainWindow->Append(&optionBrowser); mainWindow->Append(&w); mainWindow->Append(&titleTxt); @@ -2413,14 +2433,17 @@ static int MenuSettingsMappingsMap() for(i=0; i < options.length; i++) { - options.value[i][0] = 0; - for(j=0; j < ctrlr_def[mapMenuCtrl].num_btns; j++) { - if(btnmap[mapMenuCtrl][i] == + if(btnmap[mapMenuCtrl][i] == 0) + { + options.value[i][0] = 0; + } + else if(btnmap[mapMenuCtrl][i] == ctrlr_def[mapMenuCtrl].map[j].btn) { - sprintf(options.value[i], ctrlr_def[mapMenuCtrl].map[j].name); + if(strcmp(options.value[i], ctrlr_def[mapMenuCtrl].map[j].name) != 0) + sprintf(options.value[i], ctrlr_def[mapMenuCtrl].map[j].name); break; } } @@ -2430,13 +2453,27 @@ static int MenuSettingsMappingsMap() if(ret >= 0) { - btnmap[mapMenuCtrl][ret] = ButtonMappingWindow(); // get a button selection from user + // get a button selection from user + btnmap[mapMenuCtrl][ret] = ButtonMappingWindow(); } if(backBtn.GetState() == STATE_CLICKED) { menu = MENU_GAMESETTINGS_MAPPINGS; } + else if(resetBtn.GetState() == STATE_CLICKED) + { + resetBtn.ResetState(); + + int choice = WindowPrompt( + "Reset Mappings", + "Are you sure that you want to reset your mappings?", + "Yes", + "No"); + + if(choice == 1) + ResetControls(mapMenuCtrl); + } } HaltGui(); mainWindow->Remove(&optionBrowser); @@ -2669,6 +2706,9 @@ static int MenuSettingsVideo() sprintf(options.name[i++], "GB Palette"); options.length = i; + for(i=0; i < options.length; i++) + options.value[i][0] = 0; + if(!IsGameboyGame()) options.name[6][0] = 0; // disable palette option for GBA/GBC @@ -2692,7 +2732,7 @@ static int MenuSettingsVideo() GuiImage backBtnImgOver(&btnOutlineOver); GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - backBtn.SetPosition(100, -35); + backBtn.SetPosition(50, -35); backBtn.SetLabel(&backBtnTxt); backBtn.SetImage(&backBtnImg); backBtn.SetImageOver(&backBtnImgOver); @@ -2868,7 +2908,7 @@ static int MenuSettings() savingBtn.SetEffectGrow(); GuiText menuBtnTxt("Menu", 24, (GXColor){0, 0, 0, 255}); - menuBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); + menuBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage menuBtnImg(&btnLargeOutline); GuiImage menuBtnImgOver(&btnLargeOutlineOver); GuiImage menuBtnIcon(&iconMenu); @@ -2885,7 +2925,7 @@ static int MenuSettings() menuBtn.SetEffectGrow(); GuiText networkBtnTxt("Network", 24, (GXColor){0, 0, 0, 255}); - networkBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); + networkBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage networkBtnImg(&btnLargeOutline); GuiImage networkBtnImgOver(&btnLargeOutlineOver); GuiImage networkBtnIcon(&iconNetwork); @@ -3010,6 +3050,9 @@ static int MenuSettingsFile() options.length = i; options.name[4][0] = 0; // hide cheats folder (not implemented) + for(i=0; i < options.length; i++) + options.value[i][0] = 0; + GuiText titleTxt("Settings - Saving & Loading", 28, (GXColor){255, 255, 255, 255}); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetPosition(50,50); @@ -3198,6 +3241,9 @@ static int MenuSettingsMenu() sprintf(options.name[i++], "Rumble"); options.length = i; + for(i=0; i < options.length; i++) + options.value[i][0] = 0; + GuiText titleTxt("Settings - Menu", 28, (GXColor){255, 255, 255, 255}); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetPosition(50,50); @@ -3342,6 +3388,9 @@ static int MenuSettingsNetwork() sprintf(options.name[i++], "SMB Share Password"); options.length = i; + for(i=0; i < options.length; i++) + options.value[i][0] = 0; + GuiText titleTxt("Settings - Network", 28, (GXColor){255, 255, 255, 255}); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetPosition(50,50); @@ -3863,7 +3912,7 @@ static int MenuPalette() spr2Btn.SetEffectGrow(); GuiText importBtnTxt("Load / Save", 24, (GXColor){0, 0, 0, 255}); - importBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); + importBtnTxt.SetWrap(true, btnOutline.GetWidth()-30); GuiImage importBtnImg(&btnOutline); GuiImage importBtnImgOver(&btnOutlineOver); GuiButton importBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); diff --git a/source/ngc/networkop.cpp b/source/ngc/networkop.cpp index 9246d1c..5f517a7 100644 --- a/source/ngc/networkop.cpp +++ b/source/ngc/networkop.cpp @@ -22,7 +22,7 @@ #include "http.h" #include "filebrowser.h" -static bool inNetworkInit = false; +bool inNetworkInit = false; static bool networkInit = false; static bool autoNetworkInit = true; static bool networkShareInit = false; diff --git a/source/ngc/networkop.h b/source/ngc/networkop.h index 9513140..e692bee 100644 --- a/source/ngc/networkop.h +++ b/source/ngc/networkop.h @@ -18,5 +18,6 @@ bool ConnectShare (bool silent); void CloseShare(); extern bool updateFound; +extern bool inNetworkInit; #endif diff --git a/source/ngc/vba.cpp b/source/ngc/vba.cpp index 770edad..99264d9 100644 --- a/source/ngc/vba.cpp +++ b/source/ngc/vba.cpp @@ -211,6 +211,7 @@ int main(int argc, char *argv[]) #endif #ifdef HW_RVL + DI_Close(); // fixes some black screen issues DI_Init(); // first #endif diff --git a/source/ngc/video.cpp b/source/ngc/video.cpp index 176d6e6..982a788 100644 --- a/source/ngc/video.cpp +++ b/source/ngc/video.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include "vba.h" #include "menu.h" @@ -300,39 +299,6 @@ void StopGX() VIDEO_Flush(); } -/**************************************************************************** - * UpdatePadsCB - * - * called by postRetraceCallback in InitGCVideo - scans gcpad and wpad - ***************************************************************************/ -static void -UpdatePadsCB () -{ - #ifdef HW_RVL - WPAD_ScanPads(); - #endif - PAD_ScanPads(); - - for(int i=3; i >= 0; i--) - { - #ifdef HW_RVL - memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData)); - #endif - - userInput[i].chan = i; - userInput[i].pad.btns_d = PAD_ButtonsDown(i); - userInput[i].pad.btns_u = PAD_ButtonsUp(i); - userInput[i].pad.btns_h = PAD_ButtonsHeld(i); - userInput[i].pad.stickX = PAD_StickX(i); - userInput[i].pad.stickY = PAD_StickY(i); - userInput[i].pad.substickX = PAD_SubStickX(i); - userInput[i].pad.substickY = PAD_SubStickY(i); - userInput[i].pad.triggerL = PAD_TriggerL(i); - userInput[i].pad.triggerR = PAD_TriggerR(i); - } -} - - /**************************************************************************** * SetupVideoMode * @@ -437,9 +403,7 @@ InitializeVideo () VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK); VIDEO_SetNextFramebuffer (xfb[0]); - // video callbacks - VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB); - VIDEO_SetPreRetraceCallback ((VIRetraceCallback)copy_to_xfb); + VIDEO_SetPostRetraceCallback ((VIRetraceCallback)copy_to_xfb); VIDEO_SetBlack (FALSE); @@ -556,6 +520,8 @@ ResetVideo_Emu () while (VIDEO_GetNextField()) VIDEO_WaitVSync(); + VIDEO_SetPreRetraceCallback(NULL); + // reconfigure GX GX_SetViewport (0, 0, rmode->fbWidth, rmode->efbHeight, 0, 1); GX_SetDispCopyYScale ((f32) rmode->xfbHeight / (f32) rmode->efbHeight); @@ -770,6 +736,8 @@ ResetVideo_Menu () while (VIDEO_GetNextField()) VIDEO_WaitVSync(); + VIDEO_SetPreRetraceCallback((VIRetraceCallback)UpdatePads); + // clears the bg to color and clears the z buffer GXColor background = {0, 0, 0, 255}; GX_SetCopyClear (background, 0x00ffffff); @@ -827,8 +795,6 @@ ResetVideo_Menu () ***************************************************************************/ void Menu_Render() { - GX_DrawDone (); - whichfb ^= 1; // flip framebuffer GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetColorUpdate(GX_TRUE); @@ -888,6 +854,7 @@ void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], GX_Color4u8(0xFF,0xFF,0xFF,alpha); GX_TexCoord2f32(0, 1); GX_End(); + GX_DrawDone(); GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0); GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); @@ -926,4 +893,5 @@ void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 f GX_Color4u8(color.r, color.g, color.b, color.a); } GX_End(); + GX_DrawDone(); } diff --git a/source/ngc/video.h b/source/ngc/video.h index 27b40d5..a5bc8b4 100644 --- a/source/ngc/video.h +++ b/source/ngc/video.h @@ -37,5 +37,6 @@ extern bool TiltScreen; extern float TiltAngle; extern u8 * gameScreenTex; extern u8 * gameScreenTex2; +extern u32 FrameTimer; #endif