From 712c249e8c2b614555a6492b520244fe12cd1910 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Thu, 20 Dec 2012 23:52:09 -0500 Subject: Simplify the GUI code. * gui.c: Simplify row and column checks when handling touch events. * draw.c, err_msg: Use ConsoleInit instead of a custom drawstring function when an initialisation error that is NOT related to DS2 I/O occurs. This allows \r\n to work. * gui.c, initialisation: Remove the Engrish in the "initial error" messages. Make them appear in English and French. Unfortunately, the console doesn't support Chinese characters, and I don't know Chinese. --- source/nds/draw.c | 54 +++--------------------------------------------------- 1 file changed, 3 insertions(+), 51 deletions(-) (limited to 'source/nds/draw.c') diff --git a/source/nds/draw.c b/source/nds/draw.c index 6223c6e..b6c3f9b 100644 --- a/source/nds/draw.c +++ b/source/nds/draw.c @@ -1273,57 +1273,11 @@ void show_log(void* screen_addr) } /*************************************************************/ -extern const unsigned char font_map[128][8]; - -//font size 8*8 -static inline void drawfont(unsigned short *addr, unsigned short f_color, unsigned short b_color, unsigned char ch) -{ - unsigned char *dot_map; - unsigned int j, k; - unsigned char dot; - unsigned short *dst; - - dot_map = (unsigned char*)font_map[ch&0x7F]; - - for(j= 0; j < 8; j++) - { - dot = *dot_map++; - dst = addr + j*SCREEN_WIDTH; - for(k = 0; k < 8; k++) - *dst++ = (dot & (0x80>>k)) ? f_color : b_color; - } -} - -static void drawstring(unsigned int x, unsigned int y, enum SCREEN_ID screen, char *string, - unsigned short f_color, unsigned short b_color) -{ - unsigned short *scr_addr, *dst; - - if(screen & UP_MASK) - scr_addr = up_screen_addr; - else - scr_addr = down_screen_addr; - - if(x>= 32 || y>= 24) return; - - while(*string) - { - dst = scr_addr + (y*8)*SCREEN_WIDTH + x*8; - drawfont(dst, f_color, b_color, *string++); - - x += 1; - if(x>= 32) - { - x = 0; - y+= 1; - if(y >= 24) break; - } - } -} - void err_msg(enum SCREEN_ID screen, char *msg) { - drawstring(0, 0, screen, msg, COLOR16(16, 16, 16), COLOR16(0, 0, 0)); + // A wild console appeared! + ConsoleInit(RGB15(31, 31, 31), RGB15(0, 0, 0), UP_SCREEN, 512); + printf(msg); } /* @@ -1372,5 +1326,3 @@ void blit_to_screen(void* screen_addr, u16 *src, u32 w, u32 h, u32 dest_x, u32 d *dst++ = *src++; } } - - -- cgit v1.2.3