diff --git a/TODO b/TODO index ee2bab3..47e0637 100644 --- a/TODO +++ b/TODO @@ -14,11 +14,14 @@ Things to do before 1.0: Things to do later: - bopti: Implement blending modes for monochrome bitmaps +- clock: Only measure if requires as option, otherwise trust {FTune} - clock: Handle overclock (relaunch clocks when overclocking) +- clock: Split code into several files, change clock_config_t type - core: Change interrupt priority using the gint API - core: Register more interrupts (and understand their parameters) - core: Remove redundant code linked to environment saves - core: Review interrupt system (again) - this one is too slow +- display: Try to make this module lighter (lots of code in text section) - errno: Introduce errno and use it more or less everywhere - esper: Cleaner playback, synthesizing - events: Allow customization of keyboard event system (option to return @@ -26,10 +29,12 @@ Things to do later: - events: Generate keyboard events on-the-fly by reading state arrays, | allowing both a faster interrupt and avoiding supressing other | events inside getkey() and multigetkey() +- gray: Same as display, it's quite heavy - serial: Implement a driver -- stdio: More serious formatted printing functions +- stdio: More serious formatted printing functions and headers - string: Use cmp/str to implement memchr() (assembler examples) - string: Do some tests for memcmp() and memcpy() +- string: Lighter functions? - usb: Implement a driver Things to investigate: diff --git a/configure b/configure index 83c842f..bb6ae65 100755 --- a/configure +++ b/configure @@ -52,11 +52,11 @@ Options that affect the behavior of the library: use this option when using both the gray engine and --no-syscalls. Options that customize size limits: - $Cr--atexit-max$C0=$Cy$Cg [default:$Cp 16$Cg]$C0 + $Cr--atexit-max=$Cy$Cg [default:$Cp 16$Cg]$C0 Number of exit handlers that can be registered by atexit(). - $Cr--timer-slots$C0=$Cy$Cg [default:$Cp 16$Cg]$C0 + $Cr--timer-slots=$Cy$Cg [default:$Cp 16$Cg]$C0 Number of virtual timers that may be registered at the same time. - $Cr--events-queue-size$C0=$Cy$Cg [default:$Cp 64$Cg]$C0 + $Cr--events-queue-size=$Cy$Cg [default:$Cp 64$Cg]$C0 Number of events simultaneously stored in the event queue. EOF diff --git a/demo/asm_syscalls.s b/demo/asm_syscalls.s deleted file mode 100644 index 69b4f10..0000000 --- a/demo/asm_syscalls.s +++ /dev/null @@ -1,56 +0,0 @@ - - # int BFile_Remove(const uint16_t *file) - .global _BFile_Remove - -_BFile_Remove: - mov.l 1f, r0 - mov.l 2f, r1 - jmp @r1 - mov #0, r5 -1: .long 0x0439 - - # int BFile_Create(const uint16_t *file, enum { file = 1, folder = 5 }, - # int *size) - .global _BFile_Create - -_BFile_Create: - mov.l 1f, r0 - mov.l 2f, r1 - jmp @r1 - nop -1: .long 0x0434 - - # int BFile_Open(const uint16_t *file, int mode) - .global _BFile_Open - -_BFile_Open: - mov.l 1f, r0 - mov.l 2f, r1 - jmp @r1 - mov #0, r6 -1: .long 0x042c - - # int BFile_Close(int handle) - .global _BFile_Close - -_BFile_Close: - mov.l 1f, r0 - mov.l 2f, r1 - jmp @r1 - nop -1: .long 0x042d - - # int BFile_Write(int handle, void *ram_buffer, int even_size) - .global _BFile_Write - -_BFile_Write: - mov.l 1f, r0 - mov.l 2f, r1 - jmp @r1 - nop -1: .long 0x0435 - - .align 4 - -# Syscall branch address -2: .long 0x80010070 diff --git a/demo/gintdemo.c b/demo/gintdemo.c index 4655bf6..16ffaf5 100644 --- a/demo/gintdemo.c +++ b/demo/gintdemo.c @@ -54,154 +54,6 @@ void printf_test(void) } */ -/* -static const unsigned char screen[1024] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 7, 159, 0, 0, 1, 192, 0, 0, 0, 0, 0, 121, 240, 0, 0, 0, -31, 191, 192, 0, 3, 224, 27, 216, 0, 0, 1, 251, 252, 0, 0, 0, 57, 247, 222, -30, 7, 240, 36, 36, 62, 25, 131, 159, 24, 255, 129, 224, 0, 227, 142, 126, 1, -192, 45, 172, 127, 127, 192, 14, 1, 255, 199, 224, 0, 227, 140, 240, 1, 192, -26, 88, 115, 127, 224, 14, 57, 221, 207, 0, 0, 227, 13, 192, 1, 192, 34, 68, -120, 30, 0, 14, 25, 156, 220, 0, 0, 227, 253, 252, 1, 192, 36, 36, 126, 28, -0, 14, 219, 156, 223, 192, 0, 227, 253, 252, 1, 192, 36, 36, 31, 12, 0, 46, -27, 140, 223, 192, 0, 227, 141, 193, 193, 192, 40, 20, 7, 140, 0, 206, 25, 140, -220, 28, 0, 227, 140, 225, 129, 199, 24, 24, 99, 156, 1, 14, 25, 204, 206, 24, -0, 227, 142, 127, 1, 195, 39, 228, 255, 156, 2, 14, 24, 237, 199, 240, 1, 247, -222, 62, 1, 198, 44, 44, 223, 30, 2, 31, 28, 237, 131, 224, 1, 224, 0, 0, 3, -254, 27, 216, 0, 0, 4, 30, 0, 0, 0, 0, 3, 192, 0, 0, 7, 252, 0, 0, 0, 0, 4, -60, 1, 249, 240, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 4, 0, 97, 240, 56, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 224, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 47, 192, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 32, 255, 128, 63, 128, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 32, 255, 0, 48, 78, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 15, 176, 255, 0, 112, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 8, 56, 255, 0, -96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 8, 60, 255, 0, 224, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 130, 56, 126, 255, 3, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 192, -62, 255, 15, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 14, 191, 255, 192, 0, -0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 6, 129, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 6, 0, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 7, 128, 63, 192, -0, 0, 96, 1, 224, 1, 0, 0, 0, 2, 0, 0, 7, 0, 31, 192, 0, 0, 95, 1, 11, 68, 88, -0, 0, 4, 0, 0, 7, 128, 31, 192, 0, 1, 192, 129, 204, 85, 100, 0, 0, 8, 0, 0, -15, 128, 63, 224, 0, 0, 95, 1, 8, 85, 68, 0, 1, 144, 0, 0, 31, 128, 143, 224, -64, 0, 96, 1, 232, 41, 68, 0, 2, 96, 0, 31, 255, 129, 7, 248, 96, 0, 0, 0, 0, -0, 0, 0, 4, 0, 0, 96, 254, 129, 7, 254, 96, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 128, -254, 131, 135, 255, 224, 0, 0, 1, 192, 64, 16, 0, 8, 0, 7, 0, 254, 131, 255, -63, 224, 0, 0, 1, 38, 113, 208, 0, 8, 0, 13, 0, 222, 147, 254, 31, 224, 0, 0, -1, 41, 74, 80, 0, 8, 0, 25, 0, 222, 67, 254, 31, 160, 0, 0, 1, 41, 74, 80, 0, -12, 0, 49, 0, 222, 19, 254, 62, 48, 0, 0, 1, 198, 113, 208, 0, 2, 0, 32, 128, -222, 195, 255, 252, 56, 0, 0, 0, 0, 0, 0, 0, 2, 0, 124, 64, 220, 151, 135, 248, -127, 0, 0, 0, 0, 0, 0, 0, 2, 0, 66, 32, 221, 223, 7, 240, 255, 0, 0, 0, 0, 0, -0, 0, 2, 0, 129, 23, 93, 159, 15, 241, 131, 0, 0, 0, 0, 0, 0, 0, 4, 0, 128, -136, 217, 95, 3, 226, 9, 0, 0, 1, 240, 0, 0, 0, 4, 0, 128, 72, 89, 95, 129, -228, 18, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 72, 73, 127, 128, 224, 36, 0, 0, 0, 0, -0, 0, 0, 28, 1, 0, 76, 129, 127, 192, 96, 8, 0, 0, 0, 0, 0, 0, 0, 16, 1, 0, -231, 203, 124, 96, 64, 0, 0, 0, 0, 0, 0, 0, 0, 16, 1, 1, 28, 123, 240, 12, 64, -1, 0, 0, 0, 0, 0, 0, 0, 16, 1, 2, 28, 143, 128, 15, 192, 7, 0, 0, 0, 0, 0, 0, -0, 16, 1, 4, 17, 143, 24, 15, 192, 14, 0, 0, 0, 0, 0, 0, 0, 28, 1, 4, 1, 135, -24, 31, 192, 24, 0, 0, 0, 0, 0, 0, 0, 18, 1, 62, 1, 135, 248, 63, 224, 192, -0, 0, 0, 0, 0, 0, 0, 35, 1, 195, 1, 135, 128, 254, 126, 1, 0, 0, 0, 0, 0, 0, -0, 35, 193, 131, 195, 135, 255, 248, 112, 1, 0, 0, 0, 0, 0, 0, 0, 67, 241, 131, -14, 207, 255, 192, 224, 3, 0, 0, 0, 0, 0, 0, 3, 67, 15, 143, 56, 255, 7, 1, -224, 7, 0, 0, 0, 0, 0, 0, 28, 130, 7, 255, 112, 204, 7, 131, 224, 31, 0, 0, -0, 0, 0, 0, 32, 134, 30, 29, 120, 156, 7, 255, 224, 127, 0, 0, 0, 0, 0, 63, -197, 206, 60, 56, 192, 248, 15, 255, 248, 255, 0, 0, 0, 0, 0, 120, 5, 227, 248, -56, 195, 248, 127, 191, 254, 63, 0, 0, 0, 0, 7, 254, 255, 193, 255, 15, 193, -255, 15, 31, 252, 31 }; - -void ML_bmp_or_cl(const unsigned char *bmp, int x, int y, int width, int height) -{ - unsigned short line; - char shift, *screen, *p; - int i, j, real_width, begin_x, end_x, begin_y, end_y; - char bool1=1, bool2=1, bool3; - if(!bmp || x<1-width || x>127 || y<1-height || y>63 || height<1 || width<1) return; - p = (char*)&line; - real_width = (width-1>>3<<3)+8; - if(y < 0) begin_y = -y; - else begin_y = 0; - if(y+height > 64) end_y = 64-y; - else end_y = height; - shift = 8-(x&7); - if(x<0) - { - begin_x = -x>>3; - if(shift != 8) bool1 = 0; - } else begin_x = 0; - if(x+real_width > 128) end_x = 15-(x>>3), bool2 = 0; - else end_x = real_width-1>>3; - bool3 = (end_x == real_width-1>>3); - screen = display_getCurrentVRAM()+(y+begin_y<<4)+(x>>3); - - for(i=begin_y ; i>3)+begin_x] << shift; - if(bool1) screen[begin_x] |= *p; - if(shift!=8) screen[begin_x+1] |= *(p+1); - for(j=begin_x+1 ; j>3)+j] << shift; - screen[j] |= *p; - if(shift!=8) screen[j+1] |= *(p+1); - } - } - line = bmp[i*(real_width>>3)+end_x]; - if(bool3) line &= -1< -void debug(void) -{ - extern Image res_screen_start; - struct mod_tmu *timer; - int time1, time2; - int i; - - timer_get(TIMER_USER, &timer, NULL); - - dclear(); - ML_bmp_or_cl(screen, 1, 1, 128, 64); - dupdate(); - getkey(); - - dclear(); - dimage(&res_screen_start, 1, 1); - dupdate(); - getkey(); - - dclear(); - dtext("ML...", 2, 2); - dupdate(); - - timer_start2(TIMER_USER, 0x0fffffff, TIMER_Po_4, NULL, 0); - for(i = 0; i < 1000; i++) ML_bmp_or_cl(screen, 1, 1, 128, 64); - time1 = timer->TCNT; - timer_stop(TIMER_USER); - time1 = 0x0fffffff - time1; - - dclear(); - dtext("gint...", 2, 2); - dupdate(); - - timer_start2(TIMER_USER, 0x0fffffff, TIMER_Po_4, NULL, 0); - for(i = 0; i < 1000; i++) dimage(&res_screen_start, 1, 1); - time2 = timer->TCNT; - timer_stop(TIMER_USER); - time2 = 0x0fffffff - time2; - - dclear(); - print_hex(time1, 2, 2); - print_hex(time2, 2, 9); - dupdate(); - while(getkey() != KEY_EXIT); -} -*/ - /* tlb_debug() Displays the TLB contents and some information. Only available for @@ -311,15 +163,13 @@ void main_menu(int *category, int *app) "Clocks and timers", NULL }; +/* const char *list_perfs[] = { "Image rendering", "Text rendering", NULL }; - const char *list_debug[] = { - "View TLB (SH3 only)", - NULL - }; +*/ const char **list = NULL; int list_len = 0; @@ -367,22 +217,17 @@ void main_menu(int *category, int *app) locate(1, 1, "Test list"); list = list_tests; break; - +/* case 2: locate(1, 1, "Performance"); list = list_perfs; break; - - case 3: - locate(1, 1, "Debug"); - list = list_debug; - break; - +*/ default: print(1, 1, "Tab %d", tab); break; } - dimage(0, 56, &res_opt_menu); + dimage_part(0, 56, &res_opt_menu, 0, 0, 42, 8); if(list) { @@ -422,22 +267,17 @@ void main_menu(int *category, int *app) index = 0; scroll = 0; break; - case KEY_F3: +/* case KEY_F3: + *category = 2; + *app = 1; + return; +*/ +/* case KEY_F3: if(tab == 2) break; tab = 2; index = 0; scroll = 0; break; - case KEY_F4: - if(tab == 3) break; - tab = 3; - index = 0; - scroll = 0; - break; -/* case KEY_F6:; - void screen(void); - screen(); - break; */ case KEY_UP: if(list && list_len > 1) @@ -514,36 +354,18 @@ int main(void) case 0x0105: test_rtc(); break; case 0x0106: test_timer(); break; - case 0x0201: /* perf_bopti(); */ break; + case 0x0201: perf_bopti(); break; case 0x0202: /* perf_tales(); */ break; - - case 0x0301: /* if(isSH3()) debug_tlb(); */ break; } } return 0; } -static void crash(void) +/* +#include +void screen(void) { - __asm__( - "mov #0, r0 \n\t" - "ldc r0, vbr \n\t" - "trapa #1 " - ); -} - -static void screen(void) -{ - enum { File = 1, Folder = 5 }; - enum { Read = 0x01, Write = 0x02, ReadWrite = Read | Write }; - - int BFile_Remove(const uint16_t *file); - int BFile_Create(const uint16_t *file, int type, int *size); - int BFile_Open(const uint16_t *file, int mode); - int BFile_Close(int handle); - int BFile_Write(int handle, const void *ram_buffer, int even_size); - const uint8_t bmp_header[0x7e] = { 0x42, 0x4d, 0x7e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x6c, 0x00, @@ -567,8 +389,8 @@ static void screen(void) int size = 0x7e + 1024; BFile_Remove(file); - BFile_Create(file, File, &size); - int handle = BFile_Open(file, Write); + BFile_Create(file, BFile_File, &size); + int handle = BFile_Open(file, BFile_WriteOnly); BFile_Write(handle, bmp_header, 0x7e); void *vram = (void *)display_getCurrentVRAM() + 1024; for(int i = 1; i <= 64; i++) @@ -577,3 +399,58 @@ static void screen(void) } BFile_Close(handle); } +void screengray(void) +{ + const uint8_t bmp_header[0x7e] = { + 0x42, 0x4d, 0x7e, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x6c, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x13, 0x0b, + 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x42, 0x47, + 0x52, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, + }; + uint16_t file[] = { '\\', '\\', 'f', 'l', 's', '0', '\\', 'g', 's', + 'c', 'r', 'e', 'e', 'n', '#', '.', 'b', 'm', 'p', 0x00 }; + int size = 0x7e + 1024; + void *vram; + int handle; + + gupdate(); + + file[14] = 'l'; + BFile_Remove(file); + BFile_Create(file, BFile_File, &size); + handle = BFile_Open(file, BFile_WriteOnly); + BFile_Write(handle, bmp_header, 0x7e); + vram = (void *)gray_lightVRAM() + 1024; + for(int i = 1; i <= 64; i++) + { + BFile_Write(handle, vram - 16 * i, 16); + } + BFile_Close(handle); + + file[14] = 'd'; + BFile_Remove(file); + BFile_Create(file, BFile_File, &size); + handle = BFile_Open(file, BFile_WriteOnly); + BFile_Write(handle, bmp_header, 0x7e); + vram = (void *)gray_darkVRAM() + 1024; + for(int i = 1; i <= 64; i++) + { + BFile_Write(handle, vram - 16 * i, 16); + } + BFile_Close(handle); + + gupdate(); +} +*/ diff --git a/demo/perf_bopti.c b/demo/perf_bopti.c new file mode 100644 index 0000000..94a9907 --- /dev/null +++ b/demo/perf_bopti.c @@ -0,0 +1,179 @@ +#include +#include +#include +#include +#include + +/* +static const uint8_t screen[1024] = { +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 7, 159, 0, 0, 1, 192, 0, 0, 0, 0, 0, 121, 240, 0, 0, 0, +31, 191, 192, 0, 3, 224, 27, 216, 0, 0, 1, 251, 252, 0, 0, 0, 57, 247, 222, +30, 7, 240, 36, 36, 62, 25, 131, 159, 24, 255, 129, 224, 0, 227, 142, 126, 1, +192, 45, 172, 127, 127, 192, 14, 1, 255, 199, 224, 0, 227, 140, 240, 1, 192, +26, 88, 115, 127, 224, 14, 57, 221, 207, 0, 0, 227, 13, 192, 1, 192, 34, 68, +120, 30, 0, 14, 25, 156, 220, 0, 0, 227, 253, 252, 1, 192, 36, 36, 126, 28, +0, 14, 219, 156, 223, 192, 0, 227, 253, 252, 1, 192, 36, 36, 31, 12, 0, 46, +27, 140, 223, 192, 0, 227, 141, 193, 193, 192, 40, 20, 7, 140, 0, 206, 25, 140, +220, 28, 0, 227, 140, 225, 129, 199, 24, 24, 99, 156, 1, 14, 25, 204, 206, 24, +0, 227, 142, 127, 1, 195, 39, 228, 255, 156, 2, 14, 24, 237, 199, 240, 1, 247, +222, 62, 1, 198, 44, 44, 223, 30, 2, 31, 28, 237, 131, 224, 1, 224, 0, 0, 3, +254, 27, 216, 0, 0, 4, 30, 0, 0, 0, 0, 3, 192, 0, 0, 7, 252, 0, 0, 0, 0, 4, +60, 1, 249, 240, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 4, 0, 97, 240, 56, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 224, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +4, 0, 47, 192, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 32, 255, 128, 63, 128, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 32, 255, 0, 48, 78, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 15, 176, 255, 0, 112, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 8, 56, 255, 0, +96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 8, 60, 255, 0, 224, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 130, 56, 126, 255, 3, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 192, +62, 255, 15, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 14, 191, 255, 192, 0, +0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 6, 129, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, +1, 0, 0, 6, 0, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 7, 128, 63, 192, +0, 0, 96, 1, 224, 1, 0, 0, 0, 2, 0, 0, 7, 0, 31, 192, 0, 0, 95, 1, 11, 68, 88, +0, 0, 4, 0, 0, 7, 128, 31, 192, 0, 1, 192, 129, 204, 85, 100, 0, 0, 8, 0, 0, +15, 128, 63, 224, 0, 0, 95, 1, 8, 85, 68, 0, 1, 144, 0, 0, 31, 128, 143, 224, +64, 0, 96, 1, 232, 41, 68, 0, 2, 96, 0, 31, 255, 129, 7, 248, 96, 0, 0, 0, 0, +0, 0, 0, 4, 0, 0, 96, 254, 129, 7, 254, 96, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 128, +254, 131, 135, 255, 224, 0, 0, 1, 192, 64, 16, 0, 8, 0, 7, 0, 254, 131, 255, +63, 224, 0, 0, 1, 38, 113, 208, 0, 8, 0, 13, 0, 222, 147, 254, 31, 224, 0, 0, +1, 41, 74, 80, 0, 8, 0, 25, 0, 222, 67, 254, 31, 160, 0, 0, 1, 41, 74, 80, 0, +12, 0, 49, 0, 222, 19, 254, 62, 48, 0, 0, 1, 198, 113, 208, 0, 2, 0, 32, 128, +222, 195, 255, 252, 56, 0, 0, 0, 0, 0, 0, 0, 2, 0, 124, 64, 220, 151, 135, 248, +127, 0, 0, 0, 0, 0, 0, 0, 2, 0, 66, 32, 221, 223, 7, 240, 255, 0, 0, 0, 0, 0, +0, 0, 2, 0, 129, 23, 93, 159, 15, 241, 131, 0, 0, 0, 0, 0, 0, 0, 4, 0, 128, +136, 217, 95, 3, 226, 9, 0, 0, 1, 240, 0, 0, 0, 4, 0, 128, 72, 89, 95, 129, +228, 18, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 72, 73, 127, 128, 224, 36, 0, 0, 0, 0, +0, 0, 0, 28, 1, 0, 76, 129, 127, 192, 96, 8, 0, 0, 0, 0, 0, 0, 0, 16, 1, 0, +231, 203, 124, 96, 64, 0, 0, 0, 0, 0, 0, 0, 0, 16, 1, 1, 28, 123, 240, 12, 64, +1, 0, 0, 0, 0, 0, 0, 0, 16, 1, 2, 28, 143, 128, 15, 192, 7, 0, 0, 0, 0, 0, 0, +0, 16, 1, 4, 17, 143, 24, 15, 192, 14, 0, 0, 0, 0, 0, 0, 0, 28, 1, 4, 1, 135, +24, 31, 192, 24, 0, 0, 0, 0, 0, 0, 0, 18, 1, 62, 1, 135, 248, 63, 224, 192, +0, 0, 0, 0, 0, 0, 0, 35, 1, 195, 1, 135, 128, 254, 126, 1, 0, 0, 0, 0, 0, 0, +0, 35, 193, 131, 195, 135, 255, 248, 112, 1, 0, 0, 0, 0, 0, 0, 0, 67, 241, 131, +14, 207, 255, 192, 224, 3, 0, 0, 0, 0, 0, 0, 3, 67, 15, 143, 56, 255, 7, 1, +224, 7, 0, 0, 0, 0, 0, 0, 28, 130, 7, 255, 112, 204, 7, 131, 224, 31, 0, 0, +0, 0, 0, 0, 32, 134, 30, 29, 120, 156, 7, 255, 224, 127, 0, 0, 0, 0, 0, 63, +197, 206, 60, 56, 192, 248, 15, 255, 248, 255, 0, 0, 0, 0, 0, 120, 5, 227, 248, +56, 195, 248, 127, 191, 254, 63, 0, 0, 0, 0, 7, 254, 255, 193, 255, 15, 193, +255, 15, 31, 252, 31 }; +*/ + +static const uint8_t town[4464] = { 4, 0, 0, 16, 2, 115, 130, 6, 243, 130, 6, 243, 130, 6, 243, 130, 4, 0, 0, 16, 2, 115, 130, 6, 243, 130, 6, 243, 130, 6, 243, 130, 4, 0, 0, 16, 255, 255, 255, 240, 3, 255, 198, 15, 127, 198, 15, 127, 198, 15, 127, 198, 255, 255, 255, 240, 3, 255, 198, 15, 127, 198, 15, 127, 198, 15, 127, 198, 255, 255, 255, 240, 0, 144, 3, 192, 0, 112, 255, 30, 112, 255, 30, 112, 255, 30, 112, 255, 0, 144, 3, 192, 0, 112, 255, 30, 112, 255, 30, 112, 255, 30, 112, 255, 0, 144, 3, 192, 0, 144, 2, 192, 15, 240, 195, 255, 240, 195, 255, 240, 195, 255, 240, 195, 0, 144, 2, 192, 15, 240, 195, 255, 240, 195, 255, 240, 195, 255, 240, 195, 0, 144, 2, 192, 0, 144, 2, 64, 112, 15, 129, 240, 15, 129, 240, 15, 129, 240, 15, 129, 0, 144, 2, 64, 112, 15, 129, 240, 15, 129, 240, 15, 129, 240, 15, 129, 0, 144, 2, 64, 0, 208, 3, 64, 128, 1, 193, 128, 1, 193, 128, 1, 193, 128, 1, 193, 0, 208, 3, 64, 128, 1, 193, 128, 1, 193, 128, 1, 193, 128, 1, 193, 0, 208, 3, 64, 255, 223, 255, 67, 0, 0, 227, 0, 0, 227, 0, 0, 227, 0, 0, 227, 255, 223, 255, 67, 0, 0, 227, 0, 0, 227, 0, 0, 227, 0, 0, 227, 255, 223, 255, 64, 112, 195, 129, 194, 0, 0, 126, 0, 0, 126, 0, 0, 126, 0, 0, 126, 112, 195, 129, 194, 0, 0, 126, 0, 0, 126, 0, 0, 126, 0, 0, 126, 112, 195, 129, 192, 247, 255, 254, 195, 128, 0, 195, 128, 0, 195, 128, 0, 195, 128, 0, 195, 247, 255, 254, 195, 128, 0, 195, 128, 0, 195, 128, 0, 195, 128, 0, 195, 247, 255, 254, 192, 72, 0, 2, 98, 240, 113, 202, 240, 113, 202, 240, 113, 202, 240, 113, 202, 72, 0, 2, 98, 240, 113, 202, 240, 113, 202, 240, 113, 202, 240, 113, 202, 72, 0, 2, 96, 240, 0, 2, 70, 25, 255, 46, 25, 255, 46, 25, 255, 46, 25, 255, 46, 240, 0, 2, 70, 25, 255, 46, 25, 255, 46, 25, 255, 46, 25, 255, 46, 240, 0, 2, 64, 96, 1, 226, 198, 30, 48, 110, 30, 48, 110, 30, 48, 110, 30, 48, 110, 96, 1, 226, 198, 30, 48, 110, 30, 48, 110, 30, 48, 110, 30, 48, 110, 96, 1, 226, 192, 64, 2, 19, 199, 56, 32, 111, 56, 32, 111, 56, 32, 111, 56, 32, 111, 64, 2, 19, 199, 56, 32, 111, 56, 32, 111, 56, 32, 111, 56, 32, 111, 64, 2, 19, 192, 128, 2, 19, 71, 252, 96, 247, 252, 96, 247, 252, 96, 247, 252, 96, 247, 128, 2, 19, 71, 252, 96, 247, 252, 96, 247, 252, 96, 247, 252, 96, 247, 128, 2, 19, 64, 0, 2, 19, 71, 15, 241, 231, 15, 241, 231, 15, 241, 231, 15, 241, 231, 0, 2, 19, 71, 15, 241, 231, 15, 241, 231, 15, 241, 231, 15, 241, 231, 0, 2, 19, 64, 3, 194, 18, 71, 12, 63, 255, 12, 63, 231, 12, 63, 231, 12, 63, 255, 3, 194, 18, 71, 12, 63, +255, 12, 63, 231, 12, 63, 231, 12, 63, 255, 3, 194, 18, 64, 6, 99, 242, 195, 152, 31, 0, 248, 31, 195, 152, 31, 195, 152, 31, 0, 6, 99, 242, 195, 152, 31, 0, 248, 31, 195, 152, 31, 195, 152, 31, 0, 6, 99, 242, 192, 10, 84, 10, 193, 252, 24, 0, 28, 31, 129, 252, 31, 129, 252, 24, 0, 10, 84, 10, 193, 252, 24, 0, 28, 31, 129, 252, 31, 129, 252, 24, 0, 10, 84, 10, 192, 10, 87, 251, 192, 126, 48, 0, 14, 62, 0, 126, 62, 0, 126, 48, 0, 10, 87, 251, 192, 126, 48, 0, 14, 62, 0, 126, 62, 0, 126, 48, 0, 10, 87, 251, 192, 10, 80, 3, 192, 31, 224, 0, 7, 252, 3, 255, 255, 255, 255, 224, 0, 10, 80, 3, 192, 31, 224, 0, 7, 252, 3, 255, 255, 255, 255, 224, 0, 10, 80, 3, 192, 10, 208, 3, 64, 12, 56, 0, 12, 32, 6, 16, 64, 0, 2, 56, 0, 10, 208, 3, 64, 12, 56, 0, 12, 32, 6, 16, 64, 0, 2, 56, 0, 10, 208, 3, 64, 250, 95, 254, 64, 56, 175, 7, 28, 144, 7, 255, 252, 0, 2, 175, 7, 250, 95, 254, 64, 56, 175, 7, 28, 144, 7, 255, 252, 0, 2, 175, 7, 250, 95, 254, 64, 106, 86, 219, 64, 34, 225, 159, 242, 200, 4, 130, 8, 0, 2, 225, 159, 106, 86, 219, 64, 34, 225, 159, 242, 200, 4, 130, 8, 0, 2, 225, 159, 106, 86, 219, 64, 10, 80, 3, 64, 62, 225, 227, 6, 228, 15, 255, 240, 0, 1, 225, 227, 10, 80, 3, 64, 62, 225, 227, 6, 228, 15, 255, 240, 0, 1, 225, 227, 10, 80, 3, 64, 255, 255, 255, 192, 4, 243, 130, 6, 156, 10, 16, 64, 0, 1, 243, 130, 255, 255, 255, 192, 4, 243, 130, 6, 156, 10, 16, 64, 0, 1, 243, 130, 255, 255, 255, 192, 0, 0, 3, 192, 7, 127, 198, 15, 0, 15, 255, 255, 255, 255, 127, 198, 0, 0, 3, 192, 7, 127, 198, 15, 0, 15, 255, 255, 255, 255, 127, 198, 0, 0, 3, 192, 0, 0, 0, 0, 0, 112, 255, 30, 0, 3, 192, 0, 0, 60, 112, 255, 0, 0, 0, 0, 0, 112, 255, 30, 0, 3, 192, 0, 0, 60, 112, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 195, 254, 0, 2, 198, 0, 220, 44, 112, 195, 0, 0, 0, 0, 0, 112, 195, 254, 0, 2, 198, 0, 220, 44, 112, 195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 129, 252, 0, 2, 69, 0, 168, 36, 57, 129, 0, 0, 0, 0, 0, 57, 129, 252, 0, 2, 69, 0, 168, 36, 57, 129, 0, 0, 0, 0, 0, 0, 0, 0, 128, 31, 193, 248, 0, 3, 117, 62, 87, 244, 31, 193, 0, 0, 0, 0, 128, 31, 193, 248, 0, 3, 117, 62, 87, 244, 31, 193, 0, 0, 0, 0, 0, 0, 0, 2, 160, 7, 227, 224, 0, 3, 72, 128, 168, 52, 7, 227, 0, 0, 0, 2, 160, 7, 227, 224, 0, 3, 72, 128, 168, 52, 7, 227, 0, 0, 0, 0, 0, 0, 0, 1, 64, 1, 255, 192, 0, 3, 232, 246, 245, 252, 1, 254, 0, 0, 0, 1, 64, 1, 255, 192, 0, 3, 232, 246, 245, 252, 1, 254, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 194, 0, 16, 2, 199, 40, 138, 44, 0, 195, 0, 0, 0, 128, 0, 0, 194, 0, 16, 2, 199, 40, 138, 44, 0, 195, 0, 0, 0, 128, 0, 0, 2, 160, 0, 3, 137, 0, 40, 2, 64, 24, 6, 36, 3, 138, 0, 0, 2, 160, 0, 3, 137, 0, 40, 2, 64, 24, 6, 36, 3, 138, 0, 0, 2, 160, 0, 0, 1, 64, 0, 2, 44, 128, 40, 2, 64, 0, 0, 36, 2, 46, 0, 0, 1, 64, 0, 2, 44, 128, 40, 2, 64, 0, 0, 36, 2, 46, 0, 0, 1, 64, 0, 0, 0, 0, 0, 3, 238, 64, 68, 2, 192, 0, 0, 44, 3, 238, 0, 0, 0, 0, 0, 3, 238, 64, 68, 2, 192, 0, 0, 44, 3, 238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 192, 68, 3, 192, 63, 192, 60, 0, 79, 0, 0, 0, 0, 0, 0, 73, 192, 68, 3, 192, 63, 192, 60, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 0, 56, 3, 64, 124, 32, 52, 0, 119, 0, 0, 0, 0, 0, 0, 112, 0, 56, 3, 64, 124, 32, 52, 0, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 3, 64, 80, 32, 52, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 16, 3, 64, 80, 32, 52, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 2, 64, 248, 16, 36, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 16, 2, 64, 248, 16, 36, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 2, 192, 192, 16, 44, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 2, 192, 192, 16, 44, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 2, 192, 255, 240, 44, 8, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 2, 192, 255, 240, 44, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 3, 192, 41, 64, 60, 48, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 3, 192, 41, 64, 60, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 3, 192, 41, 64, 60, 32, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 3, 192, 41, 64, 60, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 8, 16, 3, 64, 47, 64, 52, 56, 0, 0, 0, 0, 0, 8, 0, 0, 8, 16, 3, 64, 47, 64, 52, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 42, 40, 2, 127, 224, 127, 230, 47, 7, 0, 0, 0, 0, 42, 0, 0, 42, 40, 2, 127, 224, 127, 230, 47, 7, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 20, 40, 3, 118, 227, 109, 180, 97, 159, 0, 0, 0, 0, 20, 0, 0, 20, 40, 3, 118, 227, 109, 180, 97, 159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 3, 64, 32, 64, 52, 97, 227, 0, 0, 0, 0, 0, 0, 0, 0, 68, 3, 64, 32, 64, 52, 97, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, 3, 255, 255, 255, 252, 115, 130, 0, 0, 0, 0, 0, 0, 0, 0, 124, 3, 255, 255, 255, 252, 115, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 192, 0, 0, 60, 127, 198, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 192, 0, 0, 60, 127, 198, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 0, 0, 112, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 0, 0, 112, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 132, 0, 0, 112, 195, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 132, 0, 0, 112, 195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 126, 0, 0, 120, 0, 0, 57, 129, 0, 0, 0, 0, 0, 0, 0, 40, 126, 0, 0, 120, 0, 0, 57, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 252, 0, 0, 3, 240, 0, 31, 193, 0, 0, 0, 0, 0, 0, 0, 43, 252, 0, 0, 3, 240, 0, 31, 193, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 134, 0, 0, 2, 16, 0, 7, 227, 0, 0, 0, 0, 0, 0, 0, 21, 134, 0, 0, 2, 16, 0, 7, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 6, 0, 0, 1, 224, 0, 1, 254, 0, 0, 0, 0, 0, 0, 0, 23, 6, 0, 0, 1, 224, 0, 1, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 62, 0, 0, 252, 0, 0, 0, 195, 0, 0, 0, 0, 0, 0, 0, 15, 62, 0, 0, 252, 0, 0, 0, 195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 250, 0, 0, 132, 0, 0, 3, 138, 0, 0, 0, 0, 0, 0, 0, 14, 250, 0, 0, 132, 0, 0, 3, 138, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 190, 0, 0, 120, 0, 0, 2, 46, 0, 0, 0, 0, 0, 0, 0, 6, 190, 0, 0, 120, 0, 0, 2, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 156, 0, 0, 3, 240, 0, 3, 238, 0, 0, 0, 0, 0, 0, 0, 3, 156, 0, 0, 3, 240, 0, 3, 238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 36, 0, 0, 2, 16, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 1, 36, 0, 0, 2, 16, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216, 0, 0, 1, 224, 0, 0, 119, 0, 0, 0, 0, 0, 0, 0, 0, 216, 0, 0, 1, 224, 0, 0, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 4, 0, 0, 16, 2, 115, 130, 6, 243, 130, 6, 243, 130, 6, 243, 130, 4, 0, 0, 16, 2, 115, 130, 6, 243, 130, 6, 243, 130, 6, 243, 130, 4, 0, 0, 16, 255, 255, 255, 240, 3, 255, 198, 15, 127, 198, 15, 127, 198, 15, 127, 198, 255, 255, 255, 240, 3, 255, 198, 15, 127, 198, 15, 127, 198, 15, 127, 198, 255, 255, 255, 240, 0, 144, 3, 192, 0, 112, 255, 30, 112, 255, 30, 112, 255, 30, 112, 255, 0, 144, 3, 192, 0, 112, 255, 30, 112, 255, 30, 112, 255, 30, 112, 255, 0, 144, 3, 192, 0, 144, 2, 192, 15, 240, 195, 255, 240, 195, 255, 240, 195, 255, 240, 195, 0, 144, 2, 192, 15, 240, 195, 255, 240, 195, 255, 240, 195, 255, 240, 195, 0, 144, 2, 192, 0, 144, 2, 64, 112, 15, 129, 240, 15, 129, 240, 15, 129, 240, 15, 129, 0, 144, 2, 64, 112, 15, 129, 240, 15, 129, 240, 15, 129, 240, 15, 129, 0, 144, 2, 64, 0, 208, 3, 64, 128, 1, 193, 128, 1, 193, 128, 1, 193, 128, 1, 193, 0, 208, 3, 64, 128, 1, 193, 128, 1, 193, 128, 1, 193, 128, 1, 193, 0, 208, 3, 64, 255, 223, 255, 67, 0, 0, 227, 0, 0, 227, 0, 0, 227, 0, 0, 227, 255, 223, 255, 67, 0, 0, 227, 0, 0, 227, 0, 0, 227, 0, 0, 227, 255, 223, 255, 64, 112, 195, 129, 194, 0, 0, 126, 0, 0, 126, 0, 0, 126, 0, 0, 126, 112, 195, 129, 194, 0, 0, 126, 0, 0, 126, 0, 0, 126, 0, 0, 126, 112, 195, 129, 192, 247, 255, 254, 195, 128, 0, 195, 128, 0, 195, 128, 0, 195, 128, 0, 195, 247, 255, 254, 195, 128, 0, 195, 128, 0, 195, 128, 0, 195, 128, 0, 195, 247, 255, 254, 192, 72, 0, 2, 98, 240, 113, 202, 240, 113, 202, 240, 113, 202, 240, 113, 202, 72, 0, 2, 98, 240, 113, 202, 240, 113, 202, 240, 113, 202, 240, 113, 202, 72, 0, 2, 96, 240, 0, 2, 70, 25, 255, 46, 25, 255, 46, 25, 255, 46, 25, 255, 46, 240, 0, 2, 70, 25, 255, 46, 25, 255, 46, 25, 255, 46, 25, 255, 46, 240, 0, 2, 64, 96, 1, 226, 198, 30, 48, 110, 30, 48, 110, 30, 48, 110, 30, 48, 110, 96, 1, 226, 198, 30, 48, 110, 30, 48, 110, 30, 48, 110, 30, 48, 110, 96, 1, 226, 192, 64, 2, 19, 199, 56, 32, 111, 56, 32, 111, 56, 32, 111, 56, 32, 111, 64, 2, 19, 199, 56, 32, 111, 56, 32, 111, 56, 32, 111, 56, 32, 111, 64, 2, 19, 192, 128, 2, 19, 71, 252, 96, 247, 252, 96, 247, 252, 96, 247, 252, 96, 247, 128, 2, 19, 71, 252, 96, 247, 252, 96, 247, 252, 96, 247, 252, 96, 247, 128, 2, 19, 64, 0, 2, 19, 71, 15, 241, 231, 15, 241, 231, 15, 241, 231, 15, 241, 231, 0, 2, 19, 71, 15, 241, 231, 15, 241, 231, 15, 241, 231, 15, 241, 231, 0, 2, 19, 64, 3, 194, 18, 71, 12, 63, 255, 12, 63, 231, 12, 63, 231, 12, 63, 255, 3, 194, 18, 71, 12, 63, 255, 12, 63, 231, 12, 63, 231, 12, 63, 255, 3, 194, 18, 64, 6, 99, 242, 195, 152, 31, 0, 248, 31, 195, 152, 31, 195, 152, 31, 0, 6, 99, 242, 195, 152, 31, 0, 248, 31, 195, 152, 31, 195, 152, 31, 0, 6, 99, 242, 192, 10, 84, 10, 193, 252, 24, 0, 28, 31, 129, 252, 31, 129, 252, 24, 0, 10, 84, 10, 193, 252, 24, 0, 28, 31, 129, 252, 31, 129, 252, 24, 0, 10, 84, 10, 192, 10, 87, 251, 192, 126, 48, 0, 14, 62, 0, 126, 62, 0, 126, 48, 0, 10, 87, 251, 192, 126, 48, 0, 14, 62, 0, 126, 62, 0, 126, 48, 0, 10, 87, 251, 192, 10, 80, 3, 192, 31, 224, 0, 7, 252, 3, 255, 255, 255, 255, 224, 0, 10, 80, 3, 192, 31, 224, 0, 7, 252, 3, 255, 255, 255, 255, 224, 0, 10, 80, 3, 192, 10, 208, 3, 64, 12, 56, 0, 12, 32, 6, 16, 64, 0, 2, 56, 0, 10, 208, 3, 64, 12, 56, 0, 12, 32, 6, 16, 64, 0, 2, 56, 0, 10, 208, 3, 64, 250, 95, 254, 64, 56, 175, 7, 28, 144, 7, 255, 252, 0, 2, 175, 7, 250, 95, 254, 64, 56, 175, 7, 28, 144, 7, 255, 252, 0, 2, 175, 7, 250, 95, 254, 64, 106, 86, 219, 64, 34, 225, 159, 242, 200, 4, 130, 8, 0, 2, 225, 159, 106, 86, 219, 64, 34, 225, 159, 242, 200, 4, 130, 8, 0, 2, 225, 159, 106, 86, 219, 64, 10, 80, 3, 64, 62, 225, 227, 6, 228, 15, 255, 240, 0, 1, 225, 227, 10, 80, 3, 64, 62, 225, 227, 6, 228, 15, 255, 240, 0, 1, 225, 227, 10, 80, 3, 64, 255, 255, 255, 192, 4, 243, 130, 6, 156, 10, 16, 64, 0, 1, 243, 130, 255, 255, 255, 192, 4, 243, 130, 6, 156, 10, 16, 64, 0, 1, 243, 130, 255, 255, 255, 192, 0, 0, 3, 192, 7, 127, 198, 15, 0, 15, 255, 255, 255, 255, 127, 198, 0, 0, 3, 192, 7, 127, 198, 15, 0, 15, 255, 255, 255, 255, 127, 198, 0, 0, 3, 192, 0, 0, 0, 0, 0, 112, 255, 30, 0, 3, 192, 0, 0, 60, 112, 255, 0, 0, 0, 0, 0, 112, 255, 30, 0, 3, 192, 0, 0, 60, 112, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 195, 254, 0, 2, 198, 0, 220, 44, 112, 195, 0, 0, 0, 0, 0, 112, 195, 254, 0, 2, 198, 0, 220, 44, 112, 195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 129, 252, 0, 2, 69, 0, 168, 36, 57, 129, 0, 0, 0, 0, 0, 57, 129, 252, 0, 2, 69, 0, 168, 36, 57, 129, 0, 0, 0, 0, 0, 0, 0, 0, 128, 31, 193, 248, 0, 3, 117, 62, 87, 244, 31, 193, 0, 0, 0, 0, 128, 31, 193, 248, 0, 3, 117, 62, 87, 244, 31, 193, 0, 0, 0, 0, 0, 0, 0, 2, 160, 7, 227, 224, 0, 3, 72, 128, 168, 52, 7, 227, 0, 0, 0, 2, 160, 7, 227, 224, 0, 3, 72, 128, 168, 52, 7, 227, 0, 0, 0, 0, 0, 0, 0, 1, 64, 1, 255, 192, 0, 3, 232, 246, 245, 252, 1, 254, 0, 0, 0, 1, 64, 1, 255, 192, 0, 3, 232, 246, 245, 252, 1, 254, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 194, 0, 16, 2, 199, 40, 138, 44, 0, 195, 0, 0, 0, 128, 0, 0, 194, 0, 16, 2, 199, 40, 138, 44, 0, 195, 0, 0, 0, 128, 0, 0, 2, 160, 0, 3, 137, 0, 40, 2, 64, 24, 6, 36, 3, 138, 0, 0, 2, 160, 0, 3, 137, 0, 40, 2, 64, 24, 6, 36, 3, 138, 0, 0, 2, 160, 0, 0, 1, 64, 0, 2, 44, 128, 40, 2, 64, 0, 0, 36, 2, 46, 0, 0, 1, 64, 0, 2, 44, 128, 40, 2, 64, 0, 0, 36, 2, 46, 0, 0, 1, 64, 0, 0, 0, 0, 0, 3, 238, 64, 68, 2, 192, 0, 0, 44, 3, 238, 0, 0, 0, 0, 0, 3, 238, 64, 68, 2, 192, 0, 0, 44, 3, 238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 192, 68, 3, 192, 63, 192, 60, 0, 79, 0, 0, 0, 0, 0, 0, 73, 192, 68, 3, 192, 63, 192, 60, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 0, 56, 3, 64, 124, 32, 52, 0, 119, 0, 0, 0, 0, 0, 0, 112, 0, 56, 3, 64, 124, 32, 52, 0, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 3, 64, 80, 32, 52, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 16, 3, 64, 80, 32, 52, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 2, 64, 248, 16, 36, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 16, 2, 64, 248, 16, 36, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 2, 192, 192, 16, 44, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 2, 192, 192, 16, 44, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 2, 192, 255, 240, 44, 8, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 2, 192, 255, 240, 44, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 3, 192, 41, 64, 60, 48, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 3, 192, 41, 64, 60, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 3, 192, 41, 64, 60, 32, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 3, 192, 41, 64, 60, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 8, 16, 3, 64, 47, 64, 52, 56, 0, 0, 0, 0, 0, 8, 0, 0, 8, 16, 3, 64, 47, 64, 52, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 42, 40, 2, 127, 224, 127, 230, 47, 7, 0, 0, 0, 0, 42, 0, 0, 42, 40, 2, 127, 224, 127, 230, 47, 7, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 20, 40, 3, 118, 227, 109, 180, 97, 159, 0, 0, 0, 0, 20, 0, 0, 20, 40, 3, 118, 227, 109, 180, 97, 159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 3, 64, 32, 64, 52, 97, 227, 0, 0, 0, 0, 0, 0, 0, 0, 68, 3, 64, 32, 64, 52, 97, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, 3, 255, 255, 255, 252, 115, 130, 0, 0, 0, 0, 0, 0, 0, 0, 124, 3, 255, 255, 255, 252, 115, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 192, 0, 0, 60, 127, 198, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 192, 0, 0, 60, 127, 198, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 0, 0, 112, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 0, 0, 112, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 132, 0, 0, 112, 195, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 132, 0, 0, 112, 195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 126, 0, 0, 120, 0, 0, 57, 129, 0, 0, 0, 0, 0, 0, 0, 40, 126, 0, 0, 120, 0, 0, 57, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 252, 0, 0, 3, 240, 0, 31, 193, 0, 0, 0, 0, 0, 0, 0, 43, 252, 0, 0, 3, 240, 0, 31, 193, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 134, 0, 0, 2, 16, 0, 7, 227, 0, 0, 0, 0, 0, 0, 0, 21, 134, 0, 0, 2, 16, 0, 7, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 6, 0, 0, 1, 224, 0, 1, 254, 0, 0, 0, 0, 0, 0, 0, 23, 6, 0, 0, 1, 224, 0, 1, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 62, 0, 0, 252, 0, 0, 0, 195, 0, 0, 0, 0, 0, 0, 0, 15, 62, 0, 0, 252, 0, 0, 0, 195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 250, 0, 0, 132, 0, 0, 3, 138, 0, 0, 0, 0, 0, 0, 0, 14, 250, 0, 0, 132, 0, 0, 3, 138, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 190, 0, 0, 120, 0, 0, 2, 46, 0, 0, 0, 0, 0, 0, 0, 6, 190, 0, 0, 120, 0, 0, 2, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 156, 0, 0, 3, 240, 0, 3, 238, 0, 0, 0, 0, 0, 0, 0, 3, 156, 0, 0, 3, 240, 0, 3, 238, 0, 0, 0, 0 }; + +static const uint8_t screen[460] = { 0, 0, 0, 2, 0, 23, 224, 15, 0, 0, 0, 0, 0, 2, 16, 127, 192, 31, 192, 0, 0, 0, 0, 1, 144, 127, 128, 24, 39, 0, 0, 0, 0, 7, 216, 127, 128, 56, 24, 128, 0, 0, 14, 4, 28, 127, 128, 48, 0, 0, 0, 0, 49, 4, 30, 127, 128, 112, 0, 0, 0, 0, 65, 28, 63, 127, 129, 240, 0, 0, 0, 0, 128, 224, 31, 127, 135, 240, 0, 0, 0, 1, 0, 0, 7, 95, 255, 224, 0, 0, 0, 1, 0, 0, 3, 64, 255, 224, 0, 0, 0, 0, 128, 0, 3, 0, 127, 224, 0, 0, 0, 0, 128, 0, 3, 192, 31, 224, 0, 0, 0, 1, 0, 0, 3, 128, 15, 224, 0, 0, 0, 2, 0, 0, 3, 192, 15, 224, 0, 0, 0, 4, 0, 0, 7, 192, 31, 240, 0, 0, 0, 200, 0, 0, 15, 192, 71, 240, 32, 0, 1, 48, 0, 15, 255, 192, 131, 252, 48, 0, 2, 0, 0, 48, 127, 64, 131, 255, 48, 0, 2, 0, 0, 192, 127, 65, 195, 255, 240, 0, 4, 0, 3, 128, 127, 65, 255, 159, 240, 0, 4, 0, 6, 128, 111, 73, 255, 15, 240, 0, 4, 0, 12, 128, 111, 33, 255, 15, 208, 0, 6, 0, 24, 128, 111, 9, 255, 31, 24, 0, 1, 0, 16, 64, 111, 97, 255, 254, 28, 0, 1, 0, 62, 32, 110, 75, 195, 252, 63, 128, 1, 0, 33, 16, 110, 239, 131, 248, 127, 128, 1, 0, 64, 139, 174, 207, 135, 248, 193, 128, 2, 0, 64, 68, 108, 175, 129, 241, 4, 128, 2, 0, 64, 36, 44, 175, 192, 242, 9, 0, 2, 0, 128, 36, 36, 191, 192, 112, 18, 0, 14, 0, 128, 38, 64, 191, 224, 48, 4, 0, 8, 0, 128, 115, 229, 190, 48, 32, 0, 0, 8, 0, 128, 142, 61, 248, 6, 32, 0, 128, 8, 0, 129, 14, 71, 192, 7, 224, 3, 128, 8, 0, 130, 8, 199, 140, 7, 224, 7, 0, 14, 0, 130, 0, 195, 140, 15, 224, 12, 0, 9, 0, 159, 0, 195, 252, 31, 240, 96, 0, 17, 128, 225, 128, 195, 192, 127, 63, 0, 128, 17, 224, 193, 225, 195, 255, 252, 56, 0, 128, 33, 248, 193, 135, 103, 255, 224, 112, 1, 128, 161, 135, 199, 156, 127, 131, 128, 240, 3, 128, 65, 3, 255, 184, 102, 3, 193, 240, 15, 128, 67, 15, 14, 188, 78, 3, 255, 240, 63, 128, 231, 30, 28, 96, 124, 7, 255, 252, 127, 128, 241, 252, 28, 97, 252, 63, 223, 255, 31, 128, 224, 255, 135, 224, 255, 135, 143, 254, 15, 128 }; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wparentheses" +#pragma GCC diagnostic ignored "-Wshift-negative-value" +#pragma GCC push_options +#pragma GCC optimize 0 + +#define ML_vram_adress display_getCurrentVRAM +__attribute__((optimize("0"))) +void ML_bmp_or_cl(const unsigned char *bmp, int x, int y, int width, int height) +{ + uint16_t line; + char shift, *screen; + uint8_t *p; + int i, j, real_width, begin_x, end_x, begin_y, end_y; + int bool1=1, bool2=1, bool3; + if(!bmp || x<1-width || x>127 || y<1-height || y>63 || height<1 + || width<1) return; + p = (uint8_t *)&line; + real_width = (width-1>>3<<3)+8; + if(y < 0) begin_y = -y; + else begin_y = 0; + if(y+height > 64) end_y = 64-y; + else end_y = height; + shift = 8-(x&7); + if(x<0) + { + begin_x = -x>>3; + if(shift != 8) bool1 = 0; + } else begin_x = 0; + if(x+real_width > 128) end_x = 15-(x>>3), bool2 = 0; + else end_x = real_width-1>>3; + bool3 = (end_x == real_width-1>>3); + screen = (char *)ML_vram_adress()+(y+begin_y<<4)+(x>>3); + + for(i=begin_y ; i>3)+begin_x] << shift; + if(bool1) screen[begin_x] |= *p; + if(shift!=8) screen[begin_x+1] |= *(p+1); + for(j=begin_x+1 ; j>3)+j] << shift; + screen[j] |= *p; + if(shift!=8) screen[j+1] |= *(p+1); + } + } + line = bmp[i*(real_width>>3)+end_x]; + if(bool3) line &= -1<TCNT; + timer_stop(t); + time1 = 0xffffffff - time1; + + dclear(); + dtext(2, 2, "gint..."); + dupdate(); + + t = htimer_setup(timer_user, 0xffffffff, timer_Po_4, 1); + timer_start(t); + for(i = 0; i < 1000; i++) dimage(x, y, img); + time2 = TMU.timers[timer_user]->TCNT; + timer_stop(t); + time2 = 0xffffffff - time2; + + dclear(); + print(1, 1, " ML: %08x", time1); + print(1, 2, "gint: %08x", time2); + print(1, 3, ">> \x04%d", time1 / time2); + dupdate(); + getkey(); +} diff --git a/demo/resources/opt_bitmap.bmp b/demo/resources/opt_bitmap.bmp index c776021..d810717 100644 Binary files a/demo/resources/opt_bitmap.bmp and b/demo/resources/opt_bitmap.bmp differ diff --git a/demo/resources/opt_gray.bmp b/demo/resources/opt_gray.bmp index 6d60c62..80e5c36 100644 Binary files a/demo/resources/opt_gray.bmp and b/demo/resources/opt_gray.bmp differ diff --git a/demo/resources/opt_menu.bmp b/demo/resources/opt_menu.bmp index 4d682e4..09fd37d 100644 Binary files a/demo/resources/opt_menu.bmp and b/demo/resources/opt_menu.bmp differ diff --git a/demo/resources/screen.bmp b/demo/resources/screen.bmp index 050825a..c6fb2c3 100644 Binary files a/demo/resources/screen.bmp and b/demo/resources/screen.bmp differ diff --git a/demo/resources/town.bmp b/demo/resources/town.bmp new file mode 100644 index 0000000..6a2e6ff Binary files /dev/null and b/demo/resources/town.bmp differ diff --git a/demo/test_bopti.c b/demo/test_bopti.c index 9b137c8..de1c083 100644 --- a/demo/test_bopti.c +++ b/demo/test_bopti.c @@ -19,7 +19,7 @@ --------------------------------------------------------- zelda.bmp 86 * 280 Mono - isometric.bmp 37 * 27 Mono Full - Mono Greater + - - Mono Greater --------------------------------------------------------- */ @@ -60,6 +60,7 @@ static image_t *select(image_t *current) res_swords, res_zelda, res_isometric; + extern image_t res_screen; struct { image_t *img; @@ -71,6 +72,7 @@ static image_t *select(image_t *current) { &res_swords, "Swords", "Gray Alpha" }, { &res_zelda, "Zelda", "Mono" }, { &res_isometric, "Isometric", "Mono Alpha" }, + { &res_screen, "TLT", "Mono" }, { NULL, NULL, NULL } }; @@ -81,6 +83,7 @@ static image_t *select(image_t *current) while(images[items].img) items++; + keyboard_setRepeatRate(625, 125); gray_start(); while(1) @@ -141,8 +144,10 @@ void test_bopti(void) int black_bg = 0; int x = 0, y = 0; + while(1) { + keyboard_setRepeatRate(25, 25); if(img && (img->format & channel_light)) { gray_start(); @@ -152,8 +157,7 @@ void test_bopti(void) if(img) gimage(x, y, img); grect(0, 55, 127, 63, color_white); - gimage(0, 56, &res_opt_bitmap); - gupdate(); + gimage_part(0, 56, &res_opt_bitmap, 0, 0, 96, 8); } else if(img) { @@ -164,8 +168,7 @@ void test_bopti(void) if(img) dimage(x, y, img); drect(0, 55, 127, 63, color_white); - dimage(0, 56, &res_opt_bitmap); - dupdate(); + dimage_part(0, 56, &res_opt_bitmap, 0, 0, 96, 8); } else { @@ -174,10 +177,36 @@ void test_bopti(void) dclear(); locate(3, 3, "No image selected"); - dimage(0, 56, &res_opt_bitmap); + dimage_part(0, 56, &res_opt_bitmap, 0, 0, 96, 8); dupdate(); } + if(img) + { + int width, height; + getwh(img, &width, &height); + + if(x < 0) print(1, 4, "\x01"); + if(x + width > 128) print(21, 4, "\x02"); + + if(img->format & channel_light) + { + if(y < 0) gimage_part(61, 0, &res_opt_bitmap, + 122, 0, 6, 8); + if(y + height > 64) gimage_part(61, 48, + &res_opt_bitmap, 116, 0, 6, 8); + gupdate(); + } + else + { + if(y < 0) dimage_part(61, 0, &res_opt_bitmap, + 122, 0, 6, 8); + if(y + height > 64) dimage_part(61, 48, + &res_opt_bitmap, 116, 0, 6, 8); + dupdate(); + } + } + do { leave = 1; @@ -185,6 +214,7 @@ void test_bopti(void) switch(getkey()) { case KEY_EXIT: + keyboard_setRepeatRate(625, 125); gray_stop(); return; @@ -192,22 +222,14 @@ void test_bopti(void) img = select(img); getxy(img, &x, &y); break; - case KEY_F5: + case KEY_F2: black_bg = !black_bg; break; - case KEY_UP: - y--; - break; - case KEY_DOWN: - y++; - break; - case KEY_LEFT: - x--; - break; - case KEY_RIGHT: - x++; - break; + case KEY_UP: y++; break; + case KEY_DOWN: y--; break; + case KEY_LEFT: x++; break; + case KEY_RIGHT: x--; break; default: leave = 0; @@ -216,6 +238,7 @@ void test_bopti(void) while(!leave); } + keyboard_setRepeatRate(625, 125); gray_stop(); return; } diff --git a/demo/test_gray.c b/demo/test_gray.c index 894aa93..86d7f35 100644 --- a/demo/test_gray.c +++ b/demo/test_gray.c @@ -8,10 +8,9 @@ Lets the user set the gray delays and see the results. */ -static void draw(int delay1, int delay2, int selected) +static void draw(int delay1, int delay2, int selected, int gran) { extern image_t res_opt_gray; - extern font_t res_font_modern; uint32_t *vl = gray_lightVRAM(); uint32_t *vd = gray_darkVRAM(); @@ -25,15 +24,16 @@ static void draw(int delay1, int delay2, int selected) vd[offset] = -(i < 32); } - text_configure(&res_font_modern, color_black); - gtext(13, 17, "light"); - gtext(13, 31, "dark"); + print(2, 3, "light %d", delay1); + print(2, 4, " dark %d", delay2); + print(2, 6, "Mode: \x04%d", gran); - text_configure(NULL, color_black); - print(4, 4, "%d", delay1); - print(4, 6, "%d", delay2); - - locate(3, selected ? 6 : 4, "\x02"); + int lengths[2] = { + 4 - (delay1 < 1000), + 4 - (delay2 < 1000) + }; + print(8, 3 + selected, "\x01"); + print(9 + lengths[selected], 3 + selected, "\x02"); gimage(0, 56, &res_opt_gray); gupdate(); @@ -44,6 +44,7 @@ void test_gray(void) int delays[2]; // { light, dark } int key, changed = 1; int selected = 0; + int gran = 1; gray_getDelays(delays, delays + 1); gray_start(); @@ -53,11 +54,11 @@ void test_gray(void) if(changed) { gray_setDelays(delays[0], delays[1]); - draw(delays[0], delays[1], selected); + draw(delays[0], delays[1], selected, gran); } changed = 0; - key = getkey_opt(getkey_repeat_arrow_keys, 25); + key = getkey_opt(getkey_default, 25); if(key == KEY_EXIT) break; changed = 1; @@ -65,31 +66,33 @@ void test_gray(void) switch(key) { case KEY_F1: - selected = !selected; - break; - case KEY_F2: delays[0] = 912; delays[1] = 1343; break; - case KEY_F3: + case KEY_F2: delays[0] = 993; delays[1] = 1609; break; - case KEY_F4: + case KEY_F3: delays[0] = 860; delays[1] = 1298; break; + case KEY_F5: + if(gran >= 100) gran = 1; + else gran *= 10; case KEY_UP: - delays[selected] += 10; + selected = 0; break; case KEY_DOWN: - if(delays[selected] >= 110) delays[selected] -= 10; - break; - case KEY_RIGHT: - delays[selected]++; + selected = 1; break; case KEY_LEFT: - if(delays[selected] >= 101) delays[selected]--; + if(delays[selected] - gran >= 100) + delays[selected] -= gran; + break; + case KEY_RIGHT: + if(delays[selected] + gran < 10000) + delays[selected] += gran; break; default: changed = 0; diff --git a/gscreen.bmp b/gscreen.bmp new file mode 100644 index 0000000..4665fe5 Binary files /dev/null and b/gscreen.bmp differ diff --git a/gscreend.bmp b/gscreend.bmp new file mode 100644 index 0000000..2a4f7c9 Binary files /dev/null and b/gscreend.bmp differ diff --git a/gscreenl.bmp b/gscreenl.bmp new file mode 100644 index 0000000..e10ea7c Binary files /dev/null and b/gscreenl.bmp differ diff --git a/include/bfile.h b/include/bfile.h new file mode 100644 index 0000000..81c0599 --- /dev/null +++ b/include/bfile.h @@ -0,0 +1,74 @@ +//--- +// +// gint core module: BFile interface +// +// Syscall-based interface to the BFile driver (which I would never dare +// to re-write considering how much the storage memory filesystem is an +// awful mess). +// +//--- + +#ifndef _BFILE_H +#define _BFILE_H + +/* + BFile_Remove() + Remove a file from the filesystem. The path must be encoded as two-byte + fontcharacters! +*/ +int BFile_Remove(const uint16_t *file); + +/* + BFile_Create() + Creates an entry in the filesystem (two-byte fontcharacter path) of the + given type. The size pointer must point to the file size for files, and + may be NULL for folders. +*/ +enum BFile_EntryType +{ + BFile_File = 1, + BFile_Folder = 5, +}; +int BFile_Create(const uint16_t *file, enum BFile_EntryType type, int *size); + +/* + BFile_Open() + Opens an existing file (two-byte fontcharacter path) with the required + mode, and returns a handle (positive integer) on success, or an + negative integer on error. +*/ +enum BFile_OpenMode +{ + BFile_ReadOnly = 0x01, + BFile_WriteOnly = 0x02, + BFile_ReadWrite = BFile_ReadOnly | BFile_WriteOnly, +}; +int BFile_Open(const uint16_t *file, enum BFile_OpenMode mode); + +/* + BFile_Close() + Closes an open file. +*/ +int BFile_Close(int handle); + +/* + BFile_Write() + Writes data to a file. The data is taken from the second-argument + buffer. The size to write is given as third argument. + WARNING: Always write an even number of bytes or you're in for trouble! +*/ +int BFile_Write(int handle, const void *ram_buffer, int even_size); + +/* + BFile_Read() + Reads from an open file. The second and third arguments indicate where + to store data and how much to read. The location from where the data is + read depends on the value of `whence`: + - If `whence` >= 0, it is considered as the absolute location (in + bytes) of the requested data in the file; + - If `whence` == -1, BFile_Read() reads from the current virtual + position in the file. +*/ +int BFile_Read(int handle, void *ram_buffer, int size, int whence); + +#endif // _BFILE_H diff --git a/include/internals/syscalls.h b/include/internals/syscalls.h index ae05b78..594c50b 100644 --- a/include/internals/syscalls.h +++ b/include/internals/syscalls.h @@ -1,6 +1,9 @@ //--- +// // gint core module: syscalls +// // Some of the functionality still requires interacting with the system. +// //--- #ifndef _INTERNALS_SYSCALLS_H diff --git a/include/keyboard.h b/include/keyboard.h index ea5cd7f..4acb419 100644 --- a/include/keyboard.h +++ b/include/keyboard.h @@ -177,6 +177,9 @@ typedef enum // Shorthand for the four previous properties. getkey_repeat_all_keys = 0xf0, + // Default combination of getkey(). + getkey_default = 0x1f, + } getkey_option_t; /* diff --git a/include/modules/interrupts.h b/include/modules/interrupts.h index 54b172e..3ffd9d1 100644 --- a/include/modules/interrupts.h +++ b/include/modules/interrupts.h @@ -1,5 +1,5 @@ -#ifndef _MODULES_INTERRUPTS -#define _MODULES_INTERRUPTS +#ifndef _MODULES_INTERRUPTS_H +#define _MODULES_INTERRUPTS_H #include #include @@ -685,4 +685,4 @@ typedef union // Here's what you'll need to use. extern mod_intc_t INTC; -#endif // _MODULE_INTERRUPTS +#endif // _MODULE_INTERRUPTS_H diff --git a/src/core/syscalls.s b/src/core/syscalls.s index ad7f984..0ebf0d2 100644 --- a/src/core/syscalls.s +++ b/src/core/syscalls.s @@ -22,8 +22,18 @@ /* Return to menu */ .global ___system_menu + /* Storage memory filesystem */ + .global _BFile_Remove + .global _BFile_Create + .global _BFile_Open + .global _BFile_Close + .global _BFile_Write + .global _BFile_Read + +/* Dynamic memory allocation */ + ___malloc: mov.l syscall_table, r2 mov.l 1f, r0 @@ -45,6 +55,8 @@ ___realloc: nop 1: .long 0xe6d +/* OS version access */ + ___get_os_version: mov.l syscall_table, r2 mov.l 1f, r0 @@ -126,6 +138,58 @@ ___system_menu: .memcpy: .long _memcpy +/* BFile driver */ + + +# int BFile_Remove(const uint16_t *file) +_BFile_Remove: + mov.l 1f, r0 + mov.l syscall_table, r1 + jmp @r1 + mov #0, r5 +1: .long 0x0439 + +# int BFile_Create(const uint16_t *file, enum { file = 1, folder = 5 }, +# int *size) +_BFile_Create: + mov.l 1f, r0 + mov.l syscall_table, r1 + jmp @r1 + nop +1: .long 0x0434 + +# int BFile_Open(const uint16_t *file, int mode) +_BFile_Open: + mov.l 1f, r0 + mov.l syscall_table, r1 + jmp @r1 + mov #0, r6 +1: .long 0x042c + +# int BFile_Close(int handle) +_BFile_Close: + mov.l 1f, r0 + mov.l syscall_table, r1 + jmp @r1 + nop +1: .long 0x042d + +# int BFile_Write(int handle, const void *ram_buffer, int even_size) +_BFile_Write: + mov.l 1f, r0 + mov.l syscall_table, r1 + jmp @r1 + nop +1: .long 0x0435 + +# int BFile_Read(int handle, void *ram_buffer, int size, int whence) +_BFile_Read: + mov.l 1f, r0 + mov.l syscall_table, r1 + jmp @r1 + nop +1: .long 0x0432 + .align 4 diff --git a/src/gray/grect.c b/src/gray/grect.c index 0edfb1d..a123d94 100644 --- a/src/gray/grect.c +++ b/src/gray/grect.c @@ -20,7 +20,7 @@ void grect(int x1, int y1, int x2, int y2, color_t operator) // Doing things in this order will be slower, but man, I can't stand // writing that many lines of code for such a simple task. It will be // terribly heavy in the binary file... - while(lvideo > lbase) for(int i = 0; i < 4; i++) switch(operator) + while(lvideo > lbase) for(int i = 3; i >= 0; i--) switch(operator) { case color_white: *--lvideo &= ~masks[i]; diff --git a/src/init/crt0.c b/src/init/crt0.c index 92ccc69..712fd3c 100644 --- a/src/init/crt0.c +++ b/src/init/crt0.c @@ -8,6 +8,7 @@ #include #include #include +#include /* We need some more functionality to generate these */ #ifdef GINT_STARTUP_LOG @@ -15,7 +16,6 @@ #include #include #include - #include #ifndef GINT_NO_SYSCALLS #include @@ -226,7 +226,7 @@ __attribute__((section(".pretext.entry"))) int start(void) init(); #ifdef GINT_STARTUP_LOG - /* Keep this visible for a second or so */ + /* Keep this visible if a key is kept pressed */ keyboard_interrupt(); if(pollevent().type != event_none) getkey(); #endif diff --git a/src/keyboard/getkey.c b/src/keyboard/getkey.c index f75d086..9b1f38b 100644 --- a/src/keyboard/getkey.c +++ b/src/keyboard/getkey.c @@ -12,17 +12,7 @@ */ int getkey(void) { - return getkey_opt( - getkey_shift_modifier | - getkey_alpha_modifier | - getkey_manage_backlight | -#ifndef GINT_NO_SYSCALLS - getkey_task_switch | -#endif - getkey_repeat_arrow_keys, - - 0 - ); + return getkey_opt(getkey_default, 0); } /* diff --git a/version b/version index 8cc1a27..6b8dc6a 100644 --- a/version +++ b/version @@ -1 +1 @@ -beta-0.9-581 +beta-0.9-584