diff --git a/src/gint/bopti.c b/src/gint/bopti.c index c8370c3..760c600 100644 --- a/src/gint/bopti.c +++ b/src/gint/bopti.c @@ -11,7 +11,7 @@ void gintctl_gint_bopti(void) #ifdef FXCG50 extern bopti_image_t img_swift; extern bopti_image_t img_swords; - extern bopti_image_t img_potion_17x22, img_potion_18x22, img_potion_21x22; + extern bopti_image_t img_potion_17x22, img_potion_18x22; extern bopti_image_t img_applejack_31x27, img_applejack_36x25; int key = 0, x, y; @@ -21,34 +21,34 @@ void gintctl_gint_bopti(void) row_title("Image rendering"); x=51, y=25; - dtext(x, y, "E.E", C_BLACK, C_NONE); - dtext(x+35, y, "E.O", C_BLACK, C_NONE); - dtext(x+70, y, "O.E", C_BLACK, C_NONE); - dtext(x+105, y, "O.O", C_BLACK, C_NONE); + dtext(x, y, C_BLACK, "E.E"); + dtext(x+35, y, C_BLACK, "E.O"); + dtext(x+70, y, C_BLACK, "O.E"); + dtext(x+105, y, C_BLACK, "O.O"); x=52, y=40; - dtext(10, y+6, "OxE", C_BLACK, C_NONE); + dtext(10, y+6, C_BLACK, "OxE"); dimage(x, y, &img_potion_17x22); dimage(x+35, y+1, &img_potion_17x22); dimage(x+71, y, &img_potion_17x22); dimage(x+106, y+1, &img_potion_17x22); x=52, y=67; - dtext(10, y+6, "ExE", C_BLACK, C_NONE); + dtext(10, y+6, C_BLACK, "ExE"); dimage(x, y, &img_potion_18x22); dimage(x+35, y+1, &img_potion_18x22); dimage(x+71, y, &img_potion_18x22); dimage(x+106, y+1, &img_potion_18x22); x=44, y=95; - dtext(10, y+9, "OxO", C_BLACK, C_NONE); + dtext(10, y+9, C_BLACK, "OxO"); dimage(x, y, &img_applejack_31x27); dimage(x+35, y+1, &img_applejack_31x27); dimage(x+71, y, &img_applejack_31x27); dimage(x+106, y+1, &img_applejack_31x27); x=40, y=127; - dtext(10, y+9, "ExO", C_BLACK, C_NONE); + dtext(10, y+9, C_BLACK, "ExO"); dimage(x, y, &img_applejack_36x25); dimage(x+35, y+1, &img_applejack_36x25); dimage(x+71, y, &img_applejack_36x25); @@ -56,8 +56,8 @@ void gintctl_gint_bopti(void) dimage(190, 35, &img_swords); - dtext(67, 210, "Some images by Pix3M (deviantart.com/pix3m)", - C_BLACK, C_NONE); + dtext(67, 210, C_BLACK, + "Some images by Pix3M (deviantart.com/pix3m)"); dupdate(); key = getkey().key; diff --git a/src/gint/dma.c b/src/gint/dma.c index c2a8a5c..7d6f2b4 100644 --- a/src/gint/dma.c +++ b/src/gint/dma.c @@ -10,7 +10,7 @@ #ifdef FXCG50 #define DMA SH7305_DMA -#define dprint(x, y, ...) dprint(x, y, C_BLACK, C_NONE, __VA_ARGS__) +#define dprint(x, y, ...) dprint(x, y, C_BLACK, __VA_ARGS__) void show_dma(int x, int y, int channel, sh7305_dma_channel_t *dma) { diff --git a/src/gint/dump.c b/src/gint/dump.c index 6f98abb..297c2c9 100644 --- a/src/gint/dump.c +++ b/src/gint/dump.c @@ -108,8 +108,8 @@ void gintctl_gint_dump(void) extern bopti_image_t img_opt_dump; dimage(0, 56, &img_opt_dump); - if(retcode == 1) dprint(77, 56, C_BLACK,C_NONE, "Done!"); - if(retcode < 0) dprint(77, 56, C_BLACK,C_NONE, "E%d",retcode); + if(retcode == 1) dprint(77, 56, C_BLACK, "Done!"); + if(retcode < 0) dprint(77, 56, C_BLACK, "E%d",retcode); #endif #ifdef FXCG50 @@ -124,6 +124,9 @@ void gintctl_gint_dump(void) regs[region].segment_count); row_print(3, 10, "%s", filename); + if(retcode == 1) row_print(5, 1, "Done!"); + if(retcode < 0) row_print(5, 1, "Error %d", retcode); + fkey_button(1, "ROM"); fkey_button(2, "RAM"); fkey_button(3, "RS"); diff --git a/src/gint/keyboard.c b/src/gint/keyboard.c index f2f4ab0..f29dbff 100644 --- a/src/gint/keyboard.c +++ b/src/gint/keyboard.c @@ -1,5 +1,6 @@ #include #include +#include #include @@ -103,9 +104,9 @@ static void render(key_event_t *last_events, int counter) char const *name = key_names[6*row + col]; if(ev.type == KEYEV_UP) - dprint(x2, y, C_BLACK, C_NONE, "Up %s", name); + dprint(x2, y, C_BLACK, "Up %s", name); if(ev.type == KEYEV_DOWN) - dprint(x1, y, C_BLACK,C_NONE,"Down %s", name); + dprint(x1, y, C_BLACK, "Down %s", name); } render_keyboard(); diff --git a/src/gint/switch.c b/src/gint/switch.c index 2dd7031..5c58ada 100644 --- a/src/gint/switch.c +++ b/src/gint/switch.c @@ -139,9 +139,8 @@ static void ctx_dma() show_dma(138, 104, 4, ch+4); show_dma(270, 104, 5, ch+5); - dprint(6, 184, C_BLACK, C_WHITE, "DMAOR: %08X", *OR); - dprint(198, 184, C_BLACK, C_WHITE, "Clock enabled: %s", - (*clock ? "No" : "Yes")); + dprint(6, 184, C_BLACK, "DMAOR: %08X", *OR); + dprint(198, 184, C_BLACK, "Clock enabled: %s",(*clock ? "No" : "Yes")); } #endif /* FXCG50 */ diff --git a/src/gint/timer.c b/src/gint/timer.c index 08bf7e2..fe0c8bb 100644 --- a/src/gint/timer.c +++ b/src/gint/timer.c @@ -13,17 +13,17 @@ void timer_print(int x, int y, char const *name, uint32_t TCOR, uint32_t TCNT, int UNIE, int UNF, int STR) { int dy = _(8,14); - print(x, y, "%s:", name); + dprint(x, y, C_BLACK, "%s:", name); #ifdef FXCG50 - print(x, y+dy, "TCOR"); - print(x, y+2*dy, "TCNT"); + dprint(x, y+dy, C_BLACK, "TCOR"); + dprint(x, y+2*dy, C_BLACK, "TCNT"); #endif - print(_(x+6, x+45), y+dy, "%08X", TCOR); - print(_(x+60, x+45), _(y+dy, y+2*dy), "%08X", TCNT); + dprint(_(x+6, x+45), y+dy, C_BLACK, "%08X", TCOR); + dprint(_(x+60, x+45), _(y+dy, y+2*dy), C_BLACK, "%08X", TCNT); - print(_(x+36, x), _(y, y+3*dy), "%s%s%s", + dprint(_(x+36, x), _(y, y+3*dy), C_BLACK, "%s%s%s", UNIE ? "UNIE " : "", UNF ? "UNF " : "", STR ? "STR " : "" @@ -96,8 +96,8 @@ void gintctl_gint_timer(void) hence ask getkey() to never wait. (The processor is still sleeping during the DMA transfer to the screen on fxcg50, limiting the program to ~90 FPS.) */ - int key=0, timeout=1; - int tid=0; + int key=0, tid=0; + GUNUSED int timeout=1; #ifdef FX9860G int tab = 1; @@ -115,8 +115,8 @@ void gintctl_gint_timer(void) extern bopti_image_t img_opt_gint_timers; dimage(0, 56, &img_opt_gint_timers); - if(tid < 3) dprint(23, 56, C_BLACK, C_NONE, "TMU%d", tid); - else dprint(23, 56, C_BLACK, C_NONE, "ETMU%d", tid-3); + if(tid < 3) dprint(23, 56, C_BLACK, "TMU%d", tid); + else dprint(23, 56, C_BLACK, "ETMU%d", tid-3); #endif #ifdef FXCG50 @@ -128,8 +128,8 @@ void gintctl_gint_timer(void) fkey_action(1, "SLEEP"); - if(tid < 3) dprint(72, 210, C_BLACK, C_NONE, "TMU%d", tid); - else dprint(72, 210, C_BLACK, C_NONE, "ETMU%d", tid-3); + if(tid < 3) dprint(72, 210, C_BLACK, "TMU%d", tid); + else dprint(72, 210, C_BLACK, "ETMU%d", tid-3); #endif dupdate(); diff --git a/src/gint/timer_callbacks.c b/src/gint/timer_callbacks.c index ff713b9..4f0cc0d 100644 --- a/src/gint/timer_callbacks.c +++ b/src/gint/timer_callbacks.c @@ -49,7 +49,7 @@ void gintctl_gint_timer_callbacks(void) extern bopti_image_t img_opt_gint_timer_callbacks; dimage(0, 56, &img_opt_gint_timer_callbacks); - dprint(69, 56, C_BLACK, C_NONE, "Done:%d", done); + dprint(69, 56, C_BLACK, "Done:%d", done); #endif #ifdef FXCG50 diff --git a/src/gint/tlb.c b/src/gint/tlb.c index 61ac757..012c166 100644 --- a/src/gint/tlb.c +++ b/src/gint/tlb.c @@ -8,7 +8,6 @@ #define PAGE_USED 0x01 #define PAGE_MAPPED 0x02 -#define C_ C_BLACK, C_NONE #define TLB_VIEW_MAX (64 - TLB_VIEW) #ifdef FXCG50 @@ -31,13 +30,8 @@ static void draw_rom_cell(int x, int y, int status) status == -2 ? C_RGB(31,0,0) : C_BLACK; - if(status >= 0 && status < 4) - drect(x, y, x+SQUARE_WIDTH, y+SQUARE_HEIGHT, colors[status]); - - dline(x, y, x+SQUARE_WIDTH, y, border); - dline(x, y, x, y+SQUARE_HEIGHT, border); - dline(x+SQUARE_WIDTH, y, x+SQUARE_WIDTH, y+SQUARE_HEIGHT, border); - dline(x, y+SQUARE_HEIGHT, x+SQUARE_WIDTH, y+SQUARE_HEIGHT, border); + uint16_t fill = (status >= 0 && status < 4) ? colors[status] : C_NONE; + drect_border(x, y, x+SQUARE_WIDTH, y+SQUARE_HEIGHT, fill, 1, border); } #endif @@ -193,11 +187,11 @@ void show_utlb(int row, int E) if(E == -1) { - dprint( 1, y, C_, "ID"); - dprint(12, y, C_, "Virtual"); - dprint(47, y, C_, "Physical"); - dprint(82, y, C_, "Len"); - dprint(98, y, C_, "Mode"); + dprint( 1, y, C_BLACK, "ID"); + dprint(12, y, C_BLACK, "Virtual"); + dprint(47, y, C_BLACK, "Physical"); + dprint(82, y, C_BLACK, "Len"); + dprint(98, y, C_BLACK, "Mode"); dfont(old_font); return; @@ -214,14 +208,14 @@ void show_utlb(int row, int E) char const *size_str[] = { "1k", "4k", "64k", "1M" }; char const *access_str[] = { "K:r", "K:rw", "U:r", "U:rw" }; - dprint( 1, y, C_, "%d", E); + dprint( 1, y, C_BLACK, "%d", E); if(valid) { - dprint(12, y, C_, "%08X", src); - dprint(47, y, C_, "%08X", dst); - dprint(82, y, C_, "%s", size_str[size]); - dprint(98, y, C_, "%s", access_str[data.PR]); + dprint(12, y, C_BLACK, "%08X", src); + dprint(47, y, C_BLACK, "%08X", dst); + dprint(82, y, C_BLACK, "%s", size_str[size]); + dprint(98, y, C_BLACK, "%s", access_str[data.PR]); } dfont(old_font); @@ -247,7 +241,7 @@ static void draw(int tab, uint8_t *pages, uint32_t next_miss, int tlb_scroll) for(uint p=0, y=_(19,36); p < PAGE_COUNT; p += 2*LINE_SIZE) { - dprint(_(4,18), y, C_, _("%06x","%08X"), + dprint(_(4,18), y, C_BLACK, _("%06x","%08X"), 0x00300000 + (p << 12)); y += 2*SQUARE_HEIGHT; } @@ -281,18 +275,18 @@ static void draw(int tab, uint8_t *pages, uint32_t next_miss, int tlb_scroll) draw_rom_cell(_(8,18), _(25,50), 2); draw_rom_cell(_(64,200), _(25,50), 3); - dprint(_(16,30), _(16,36), C_, + dprint(_(16,30), _(16,36), C_BLACK, _("Unused", "Unused in add-in")); - dprint(_(72,212), _(16,36), C_, + dprint(_(72,212), _(16,36), C_BLACK, _("Unmapped", "Currently unmapped")); - dprint(_(16,30), _(24,50), C_, + dprint(_(16,30), _(24,50), C_BLACK, _("Mapped?", "Strangely mapped?!")); - dprint(_(72,212), _(24,50), C_, + dprint(_(72,212), _(24,50), C_BLACK, _("Mapped", "Currently mapped")); #ifdef FXCG50 draw_rom_cell(18, 64, -1); - dprint(30, 64, C_, "Next page to load"); + dprint(30, 64, C_BLACK, "Next page to load"); row_print(6, 1, "The MISS key will load an unmapped page to TLB by"); diff --git a/src/gintctl.c b/src/gintctl.c index 05d3b61..5502f0d 100644 --- a/src/gintctl.c +++ b/src/gintctl.c @@ -106,14 +106,6 @@ void gintctl_main(void) row_print(7,1, "This add-in is running a unikernel called gint by"); row_print(8,1, "Lephe'. Information about the project is available"); row_print(9,1, "on planet-casio.com."); - - #ifdef GINT_BOOTLOG - extern char gint_bootlog[22 * 8]; - extern font_t *gint_default_font; - - for(int i = 1; i < 8; i++) dtext(8, 85 + 13 * i, gint_bootlog + 22 * i, - C_BLACK, C_NONE); - #endif /* GINT_BOOTLOG */ #endif /* FXCG50 */ } diff --git a/src/libs/printf.c b/src/libs/printf.c index eebba06..174c4a6 100644 --- a/src/libs/printf.c +++ b/src/libs/printf.c @@ -109,21 +109,21 @@ static void draw(struct printf_test const *tests, int offset) #ifdef FX9860G extern font_t font_hexa; - font_t *old_font = dfont(&font_hexa); + font_t const *old_font = dfont(&font_hexa); - dprint( 1, 0, C_BLACK, C_NONE, "ID"); - dprint(13, 0, C_BLACK, C_NONE, "Format"); - dprint(43, 0, C_BLACK, C_NONE, "Output"); - dprint(91, 0, C_BLACK, C_NONE, "Valid"); + dprint( 1, 0, C_BLACK, "ID"); + dprint(13, 0, C_BLACK, "Format"); + dprint(43, 0, C_BLACK, "Output"); + dprint(91, 0, C_BLACK, "Valid"); for(int i = 0; i < SCROLL_HEIGHT; i++) { struct printf_test const *t = &tests[offset+i]; int y = (i+1) * 6; - dprint( 1, y, C_BLACK, C_NONE, "%d", offset+i+1); - dprint(13, y, C_BLACK, C_NONE, "%s", t->format); - dprint(43, y, C_BLACK, C_NONE, "%s", t->answer); - dprint(91, y, C_BLACK, C_NONE, "%s", t->passed?"Ok":"Err"); + dprint( 1, y, C_BLACK, "%d", offset+i+1); + dprint(13, y, C_BLACK, "%s", t->format); + dprint(43, y, C_BLACK, "%s", t->answer); + dprint(91, y, C_BLACK, "%s", t->passed?"Ok":"Err"); } dfont(old_font); diff --git a/src/mem/mem.c b/src/mem/mem.c index 7a482b7..8ba332c 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -95,21 +95,18 @@ void gintctl_mem(void) GUNUSED int status = line(mem,header,bytes,ascii,size); #ifdef FX9860G - dtext( 5, 6*i + 1, view_ascii ? ascii : header, - C_BLACK, C_NONE); - dtext(45, 6*i + 1, bytes, C_BLACK, C_NONE); + dtext( 5, 6*i + 1, C_BLACK, view_ascii?ascii:header); + dtext(45, 6*i + 1, C_BLACK, bytes); #endif #ifdef FXCG50 - dtext(25, 26 + 12*i, header, C_BLACK, C_NONE); - dtext(110, 26 + 12*i, bytes, status ? C_RED : C_BLACK, - C_NONE); + dtext(25, 26 + 12*i, C_BLACK, header); + dtext(110, 26 + 12*i, status ? C_RED : C_BLACK, bytes); for(int k = size - 1; k >= 0; k--) { ascii[k+1] = 0; - dtext(275 + 9*k, 26 + 12*i, ascii + k, C_BLACK, - C_NONE); + dtext(275 + 9*k, 26 + 12*i, C_BLACK, ascii+k); } #endif diff --git a/src/util.c b/src/util.c index a7257d5..9bd98f3 100644 --- a/src/util.c +++ b/src/util.c @@ -40,11 +40,11 @@ void row_title(char const *format, ...) shortprint(str, format); #ifdef FX9860G - dtext(1, 0, str, C_BLACK, C_NONE); + dtext(1, 0, C_BLACK, str); #endif #ifdef FXCG50 - dtext(ROW_X, 3, str, C_BLACK, C_NONE); + dtext(ROW_X, 3, C_BLACK, str); uint32_t *long_vram = (void *)gint_vram; for(int i = 0; i < 198 * 16; i++) long_vram[i] = ~long_vram[i]; #endif @@ -59,7 +59,7 @@ void row_print(int row, int x, char const *format, ...) shortprint(str, format); dtext(ROW_X + ROW_W * (x - 1), ROW_Y + ROW_H * (row - 1) + ROW_YPAD, - str, C_BLACK, C_NONE); + C_BLACK, str); } /* row_print_color(): Formatted printing... with custom colors! */ @@ -70,8 +70,8 @@ void row_print_color(int row, int x, int fg, int bg, char const *format, ...) char str[80]; shortprint(str, format); - dtext(ROW_X + ROW_W * (x - 1), ROW_Y + ROW_H * (row - 1) + ROW_YPAD, - str, fg, bg); + dtext_opt(ROW_X + ROW_W * (x-1), ROW_Y + ROW_H * (row-1) + ROW_YPAD, + fg, bg, DTEXT_LEFT, DTEXT_TOP, str); } /* row_highlight(): Invert a row's pixels to highlight it */ @@ -98,8 +98,7 @@ void row_right(int row, char const *character) #endif #ifdef FXCG50 - dtext(370, ROW_Y + ROW_H * (row - 1) + ROW_YPAD, character, - C_BLACK, C_NONE); + dtext(370, ROW_Y + ROW_H * (row - 1) + ROW_YPAD, C_BLACK, character); #endif } @@ -125,33 +124,11 @@ int row_count(void) } //--- -// General (x,y) printing +// Other drawing utilities //--- -/* print(): Formatted printing shorthand */ -void print(int x, int y, char const *format, ...) -{ - char str[80]; - shortprint(str, format); - dtext(x, y, str, C_BLACK, C_NONE); -} - - #ifdef FXCG50 -/* printw(): Print in white */ -void printw(int x, int y, char const *format, ...) -{ - char str[80]; - va_list args; - va_start(args, format); - vsprintf(str, format, args); - - dtext(x, y, str, C_WHITE, C_NONE); - - va_end(args); -} - /* fkey_action(): A black-on-white F-key */ void fkey_action(int position, char const *text) { @@ -167,7 +144,7 @@ void fkey_action(int position, char const *text) drect(x, y + 1, x + 1, y + 13, C_BLACK); drect(x + w - 2, y + 1, x + w - 1, y + 13, C_BLACK); - dtext(x + ((w - width) >> 1), y + 3, text, C_BLACK, C_NONE); + dtext(x + ((w - width) >> 1), y + 3, C_BLACK, text); } /* fkey_button(): A rectangular F-key */ @@ -184,7 +161,7 @@ void fkey_button(int position, char const *text) dline(x + 1, y + 14, x + w - 2, y + 14, C_BLACK); drect(x, y + 1, x + w - 1, y + 13, C_BLACK); - dtext(x + ((w - width) >> 1), y + 3, text, C_WHITE, C_NONE); + dtext(x + ((w - width) >> 1), y + 3, C_WHITE, text); } /* fkey_menu(): A rectangular F-key with the bottom right corner removed */