Last active
August 29, 2015 14:23
-
-
Save MatthewScholefield/726de13c133e54d93878 to your computer and use it in GitHub Desktop.
Font and imageTiles problem with libnds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <nds.h> | |
#include "font.h" //GRIT generated header | |
#include "image.h" //GRIT generated header | |
ConsoleFont font; | |
void setupFont() | |
{ | |
const int tile_base = 1; | |
const int map_base = 0; | |
PrintConsole *console = consoleInit(0, 0, BgType_Text8bpp, BgSize_T_256x256, map_base, tile_base, false, false); | |
font.gfx = (u16*) fontTiles; | |
font.pal = (u16*) fontPal; | |
font.numChars = 256; | |
font.numColors = fontPalLen / 2; | |
font.bpp = 8; | |
font.asciiOffset = 0; | |
font.convertSingleColor = false; | |
consoleSetFont(console, &font); | |
} | |
void refreshFont() | |
{ | |
consoleSetFont(NULL, &font); //The NULL parameter is understood as the current console | |
} | |
int main () | |
{ | |
//Graphics initialization, palette copying, etc. | |
dmaCopy(&imageTiles, bgGetGfxPtr(6), imageTilesLen); //6 is the hardcoded id that is correct in my case | |
setupFont(); | |
//Font works at this point | |
dmaCopy(&imageTiles, bgGetGfxPtr(6), imageTilesLen); //In actual code, this would copy new tiles | |
//Now fonts are invisible D: | |
refreshFont(); | |
//Now fonts work again :D, and it shouldn't cause a memory leak | |
/* | |
Soo... Why does the dmaCopy cause the fonts to disappear? | |
Any help is appreciated. Please reply either here or in the irc. I can increase my verbosity if requested. | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment