diff --git a/arm9/data/font.nftr b/arm9/data/font.nftr index de8d045..76c1315 100644 Binary files a/arm9/data/font.nftr and b/arm9/data/font.nftr differ diff --git a/arm9/source/gui/fileBrowse.cpp b/arm9/source/gui/fileBrowse.cpp index cb6030f..661f602 100644 --- a/arm9/source/gui/fileBrowse.cpp +++ b/arm9/source/gui/fileBrowse.cpp @@ -126,7 +126,7 @@ void showDirectoryContents(const std::vector& dirContents, const std:: // Print path drawImageSection(0, 0, 256, 17, fileBrowseBgBitmap, 256, 0, 0, 16); - printTextMaxW(path, 250, 1, 0, 3, 0); + printTextMaxW(path, 250, 1, 0, 3, 1); // Print directory listing for(int i=0;i < ENTRIES_PER_SCREEN; i++) { @@ -155,15 +155,13 @@ void showDirectoryContents(const std::vector& dirContents, const std:: } } - printText(name, 1, 1, !(startRow+i == selection) + (watched*2), 3, i*16+16); + printText(name, 1, 1, !(startRow+i == selection) + (watched*2), 3, i * 16 + 17); } } } std::string browseForFile(const std::vector& extensionList) { - videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); vramSetBankC(VRAM_C_SUB_BG); - bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0); int pressed = 0, held = 0, screenOffset = 0, fileOffset = 0; touchPosition touch; @@ -238,7 +236,7 @@ std::string browseForFile(const std::vector& extensionList) { touchRead(&touch); for(int i=0;i (i+1)*16 && touch.py < (i+2)*16) { - fileOffset = i; + fileOffset = screenOffset + i; goto selection; } } diff --git a/arm9/source/gui/graphics.cpp b/arm9/source/gui/graphics.cpp index ebc2bd8..0afa23f 100644 --- a/arm9/source/gui/graphics.cpp +++ b/arm9/source/gui/graphics.cpp @@ -6,32 +6,37 @@ #include "font_nftr.h" #include "fileBrowseBg.h" -std::vector fontTiles; -std::vector fontWidths; +u8 *fontTiles; +const u8 *fontWidths; std::vector fontMap; u16 tileSize, tileWidth, tileHeight; void loadPalettes(void) { - u16 palette[] = {0, 0xFBDE, 0xBDEF, // Light - 0, 0xD294, 0xA529, // Darker - 0, (u16)(palettes[PersonalData->theme][0] & 0xFBDE), (u16)(palettes[PersonalData->theme][0] & 0xBDEF), // Light colored - 0, (u16)(palettes[PersonalData->theme][0] & 0xD294), (u16)(palettes[PersonalData->theme][0] & 0xA529)}; // Darker colored + u16 palette[] = {0x0000, 0xFFFF, 0xD6B5, 0xB9CE, // White + 0x0000, 0xDEF7, 0xC631, 0xA94A, // Black + 0x0000, (u16)(palettes[PersonalData->theme][1] & 0xFFFF), (u16)(palettes[PersonalData->theme][1] & 0xDEF7), (u16)(palettes[PersonalData->theme][1] & 0xCE73), // Light colored + 0x0000, (u16)(palettes[PersonalData->theme][1] & 0xD6B5), (u16)(palettes[PersonalData->theme][1] & 0xCA52), (u16)(palettes[PersonalData->theme][1] & 0xC210)}; // Darker colored tonccpy(BG_PALETTE_SUB, &palette, sizeof(palette)); tonccpy(BG_PALETTE_SUB+0x10, &fileBrowseBgPal, fileBrowseBgPalLen/2); tonccpy(BG_PALETTE_SUB+0x13, &palettes[PersonalData->theme], sizeof(palettes[PersonalData->theme])); } void loadFont(void) { - // Load font info - u32 chunkSize = *(u32*)(font_nftr+0x30); - tileWidth = *(font_nftr+0x34); - tileHeight = *(font_nftr+0x35); - tileSize = *(u16*)(font_nftr+0x36); + // consoleDemoInit(); + // Get glyph start + u8 glyphOfs = font_nftr[0x14] + 0x14; + + // Load glyph info + u32 chunkSize = *(u32*)(font_nftr+glyphOfs); + tileWidth = font_nftr[glyphOfs+4]; + tileHeight = font_nftr[glyphOfs+5]; + tileSize = *(u16*)(font_nftr+glyphOfs+6); + // printf("%d\n%d\n%d\n", tileWidth, tileHeight, tileSize); + // while(1)swiWaitForVBlank(); // Load character glyphs int tileAmount = ((chunkSize-0x10)/tileSize); - fontTiles = std::vector(tileSize*tileAmount); - memcpy(fontTiles.data(), font_nftr+0x3C, tileSize*tileAmount); + fontTiles = (u8*)font_nftr+glyphOfs+0xC; // Fix top rows for(int i=0;i(3*tileAmount); - memcpy(fontWidths.data(), font_nftr+locHDWC+8, 3*tileAmount); + fontWidths = font_nftr+locHDWC+8; // Load character maps fontMap = std::vector(tileAmount); @@ -193,7 +197,7 @@ void printText(std::string text, double scaleX, double scaleY, int palette, int void printText(std::u16string text, double scaleX, double scaleY, int palette, int xPos, int yPos) { int x=xPos; for(unsigned c=0;c>6 & 3)); - image[(i*4)+1] = (palette*3 + (fontTiles[i+(t*tileSize)]>>4 & 3)); - image[(i*4)+2] = (palette*3 + (fontTiles[i+(t*tileSize)]>>2 & 3)); - image[(i*4)+3] = (palette*3 + (fontTiles[i+(t*tileSize)] & 3)); + image[(i*4)] = (palette*4 + (fontTiles[i+(t*tileSize)]>>6 & 3)); + image[(i*4)+1] = (palette*4 + (fontTiles[i+(t*tileSize)]>>4 & 3)); + image[(i*4)+2] = (palette*4 + (fontTiles[i+(t*tileSize)]>>2 & 3)); + image[(i*4)+3] = (palette*4 + (fontTiles[i+(t*tileSize)] & 3)); } x += fontWidths[t*3]; diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index 09f7ac2..0d2470f 100644 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -156,7 +156,7 @@ static void aac_initQueue() DC_FlushRange(&sAACQueue, (sizeof(sAACQueue) + 31) & ~31); } -ITCM_CODE void PlayVideo() +ITCM_CODE void PlayVideo(const char *fileName) { printf("PlayVideo\n"); stopVideo = FALSE; @@ -185,15 +185,14 @@ ITCM_CODE void PlayVideo() mVideoHeader = (uint8_t*)malloc(SWAP_CONSTANT_32(header_size)); mRingBufferHttpStream->Read(mVideoHeader + 4, SWAP_CONSTANT_32(header_size) - 4); #else - std::string fileName = browseForFile({"mp4"}); - FILE* video = fopen(fileName.c_str(), "rb"); + FILE* video = fopen(fileName, "rb"); // Clear the screen printf("\x1b[2J"); drawRectangle(0, 0, 256, 192, 0); // Draw progress bar background - drawRectangle(35, 6, 185, 7, 5); + drawRectangle(36, 5, 184, 7, 7); printf("Opened file: %p\n", video); //find the moov atom @@ -414,7 +413,7 @@ ITCM_CODE void PlayVideo() skip = 0; continue; } - + if(pauseVideo) continue; if(frame < nrframes) { @@ -649,10 +648,10 @@ ITCM_CODE void VBlankProc() nrFramesInQueue--; } else { // Update time & progress if not copying a frame - drawRectangle(36, 7, (int)(((float)frame/nrframes)*184), 5, 4); + drawRectangle(37, 6, (int)(((float)frame/nrframes)*183), 5, 5); char time[14]; snprintf(time, sizeof(time), "%.02d:%.02d", frame/(mTimeScale/1000)/60, (frame/(mTimeScale/1000))-((frame/(mTimeScale/1000)/60)*60)); - drawRectangle(3, 1, 30, 16, 0); + drawRectangle(3, 1, 32, 16, 0); printText(time, 1, 1, 1, 3, 1); } } @@ -674,15 +673,15 @@ ITCM_CODE void VBlankProc() } else if(held & KEY_LEFT) { skip = -24*5; drawBar: - drawRectangle(35, 6, 185, 7, 5); - drawRectangle(36, 7, (int)(((float)frame/nrframes)*184), 5, 4); + drawRectangle(36, 5, 184, 7, 7); + drawRectangle(37, 6, (int)(((float)frame/nrframes)*183), 5, 5); } else if(held & KEY_TOUCH) { touchPosition touch; touchRead(&touch); - if(touch.py < 16 && touch.px > 35 && touch.px < 220) { - int newpos = nrframes*((float)(touch.px-35)/183); + if(touch.py < 16 && touch.px > 36 && touch.px < 220) { + int newpos = nrframes*((float)(touch.px-37)/182); skip = newpos-frame; - goto drawBar; // overflowed itcm with it copied + goto drawBar; // overflowed itcm with it copied } } } @@ -690,7 +689,7 @@ ITCM_CODE void VBlankProc() mKeyTimer = 0; } -int main() +int main(int argc, char *argv[]) { mpu_enableVramCache(); defaultExceptionHandler(); @@ -699,12 +698,13 @@ int main() mUpscalingEnabled = FALSE; if(!fatInitDefault()) nitroFSInit(NULL); - //defaultExceptionHandler(); - //consoleDemoInit(); + videoSetMode(MODE_0_2D); - videoSetModeSub(MODE_0_2D); + videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); vramSetBankH(VRAM_H_SUB_BG); + bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0); + loadFont(); loadPalettes(); @@ -837,7 +837,6 @@ int main() setBrightness(2, (bright + 1) / 2); swiWaitForVBlank(); }*/ -idle_loop: #ifdef USE_WIFI while(1) { @@ -863,7 +862,17 @@ int main() mRingBufferHttpStream = new RingBufferHttpStream(url); free(url); #endif*/ - PlayVideo(); - goto idle_loop; + + if(argc > 1) { + PlayVideo(argv[1]); + } else { + while(1) { + PlayVideo(browseForFile({"mp4"}).c_str()); + } + } + + printTextCentered("Please turn off your DS.", 1, 1, 0, 0, 32); + printTextCentered("(This will hopefully be fixed soon)", 1, 1, 0, 0, 48); + return 0; } \ No newline at end of file