Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion src/bme/bme_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned char>(*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<char>(codepoint);
}
}
}
}
break;

case SDL_EVENT_KEY_DOWN:
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/bme/bme_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
21 changes: 9 additions & 12 deletions src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down
Binary file removed src/data/chargen.bin
Binary file not shown.
Binary file modified src/data/font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/data/loadtrk.seq
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ player.s
altplayer.s
player_s.s
altplayer_s.s
chargen.bin
font.png
cursor.png
loadtrk.bmp
2 changes: 1 addition & 1 deletion src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ";
Expand Down
2 changes: 1 addition & 1 deletion src/loadtrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
Loading