diff --git a/src/bme/bme_win.cpp b/src/bme/bme_win.cpp index 4ebaad1..aec7739 100644 --- a/src/bme/bme_win.cpp +++ b/src/bme/bme_win.cpp @@ -266,7 +266,33 @@ void win_checkmessages() break; case SDL_EVENT_TEXT_INPUT: - win_asciikey = event.text.text[0]; + { + const char *in = event.text.text; + // convert to ISO-8859-1 + unsigned int codepoint; + while (*in != 0) + { + unsigned char ch = static_cast(*in); + if (ch <= 0x7f) + codepoint = ch; + else if (ch <= 0xbf) + codepoint = (codepoint << 6) | (ch & 0x3f); + else if (ch <= 0xdf) + codepoint = ch & 0x1f; + else if (ch <= 0xef) + codepoint = ch & 0x0f; + else + codepoint = ch & 0x07; + ++in; + if (((*in & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) + { + if (codepoint <= 255) + { + win_asciikey = static_cast(codepoint); + } + } + } + } break; case SDL_EVENT_KEY_DOWN: @@ -477,6 +503,50 @@ void gfx_freecursor() } } +bool gfx_loadcharset(const char *name, unsigned char *chardata) +{ + int handle = io_open(name); + if (handle == -1) return false; + + int size = io_lseek(handle, 0, SEEK_END); + char *charbuffer = new (std::nothrow) char[size]; + if (!charbuffer) + { + io_close(handle); + return false; + } + io_lseek(handle, 0, SEEK_SET); + io_read(handle, charbuffer, size); + io_close(handle); + + SDL_IOStream *rw = SDL_IOFromMem(charbuffer, size); + SDL_Surface *gfx_chars = SDL_LoadPNG_IO(rw, true); + if (!gfx_chars) + return false; + + if ((gfx_chars->w != 8) || (gfx_chars->h != 4096)) + return false; + + if (gfx_chars->format != SDL_PIXELFORMAT_INDEX8) + return false; + + int i = 0, j = 0; + for (int y=0; y<4096; y++) + { + chardata[j] = 0; + for (int x=7; x>=0; x--) + { + if (((unsigned char*)gfx_chars->pixels)[i]) + chardata[j] |= (1u << x); + i++; + } + j++; + } + SDL_DestroySurface(gfx_chars); + + return true; +} + void gfx_drawcursor(int x, int y) { if (!gfx_initted) return; diff --git a/src/bme/bme_win.h b/src/bme/bme_win.h index b009810..edb243c 100644 --- a/src/bme/bme_win.h +++ b/src/bme/bme_win.h @@ -27,6 +27,8 @@ bool gfx_loadcursor(const char *name); void gfx_drawcursor(int x, int y); void gfx_freecursor(); +bool gfx_loadcharset(const char *name, unsigned char *chardata); + void mou_getpos(unsigned *x, unsigned *y); unsigned mou_getbuttons(); diff --git a/src/console.cpp b/src/console.cpp index 12f4bd9..d49910f 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -115,10 +115,7 @@ bool initscreen() std::memset(region, 0, sizeof region); chardata = new unsigned char[4096]; - int handle = io_open("chargen.bin"); - if (handle == -1) return false; - io_read(handle, &chardata[0], 4096); - io_close(handle); + gfx_loadcharset("font.png", chardata); loadexternalpalette(); gfx_setpalette(); @@ -298,8 +295,8 @@ void drawbox(int x, int y, int color, int sx, int sy) while (counter--) { - setcharcolor(dptr, '|', color); - setcharcolor(dptr2, '|', color); + setcharcolor(dptr, '\x95', color); + setcharcolor(dptr2, '\x95', color); dptr += MAX_COLUMNS; dptr2 += MAX_COLUMNS; } @@ -310,23 +307,23 @@ void drawbox(int x, int y, int color, int sx, int sy) while (counter--) { - setcharcolor(dptr, '-', color); - setcharcolor(dptr2, '-', color); + setcharcolor(dptr, '\x94', color); + setcharcolor(dptr2, '\x94', color); dptr++; dptr2++; } dptr = scrbuffer + (x + y * MAX_COLUMNS); - setcharcolor(dptr, '+', color); + setcharcolor(dptr, '\x90', color); dptr = scrbuffer + ((x+sx-1) + y * MAX_COLUMNS); - setcharcolor(dptr, '+', color); + setcharcolor(dptr, '\x91', color); dptr = scrbuffer + (x + (y+sy-1) * MAX_COLUMNS); - setcharcolor(dptr, '+', color); + setcharcolor(dptr, '\x92', color); dptr = scrbuffer + ((x+sx-1) + (y+sy-1) * MAX_COLUMNS); - setcharcolor(dptr, '+', color); + setcharcolor(dptr, '\x93', color); } void printbg(int x, int y, int color, int length) diff --git a/src/data/chargen.bin b/src/data/chargen.bin deleted file mode 100644 index b937329..0000000 Binary files a/src/data/chargen.bin and /dev/null differ diff --git a/src/data/font.png b/src/data/font.png index b386dbd..f1a8f67 100644 Binary files a/src/data/font.png and b/src/data/font.png differ diff --git a/src/data/loadtrk.seq b/src/data/loadtrk.seq index 338d7e4..9382a68 100644 --- a/src/data/loadtrk.seq +++ b/src/data/loadtrk.seq @@ -2,6 +2,6 @@ player.s altplayer.s player_s.s altplayer_s.s -chargen.bin +font.png cursor.png loadtrk.bmp diff --git a/src/display.cpp b/src/display.cpp index e812ce2..e26999d 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -590,7 +590,7 @@ void printstatus() color = isplaying() ? colors.CEDIT : colors.CMUTE; printtext(dpos.octaveX+10, dpos.octaveY+1, color, textbuffer); - const char *cmds = isplaying() ? " [] Stop " : " [> Play "; + const char *cmds = isplaying() ? " \x80 " : " \x81 "; printtext(dpos.octaveX+20, dpos.octaveY, colors.CTITLE|(colors.CHDRBG<<4), cmds); const char *chnls = (numsids == 1) ? " CHN1 CHN2 CHN3 " : " CHN1 CHN2 CHN3 CHN4 CHN5 CHN6 "; diff --git a/src/loadtrk.cpp b/src/loadtrk.cpp index 166131a..1c42a55 100644 --- a/src/loadtrk.cpp +++ b/src/loadtrk.cpp @@ -764,7 +764,7 @@ void mousecommands() if ((!prevmouseb) && (mousey == dpos.octaveY)) { if ((mousex >= dpos.octaveX+20) && - (mousex <= dpos.octaveX+28)) + (mousex <= dpos.octaveX+23)) { if (isplaying()) {