#652: added alt font button to the Code Editor

This commit is contained in:
Vadim Grigoruk 2018-08-04 00:36:53 +03:00
parent 4249516d7e
commit 6be630167a
21 changed files with 181 additions and 125 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -49,7 +49,7 @@ static void drawStatus(Code* code)
{ {
const s32 Height = TIC_FONT_HEIGHT + 1; const s32 Height = TIC_FONT_HEIGHT + 1;
code->tic->api.rect(code->tic, 0, TIC80_HEIGHT - Height, TIC80_WIDTH, Height, (tic_color_white)); code->tic->api.rect(code->tic, 0, TIC80_HEIGHT - Height, TIC80_WIDTH, Height, (tic_color_white));
code->tic->api.fixed_text(code->tic, code->status, 0, TIC80_HEIGHT - TIC_FONT_HEIGHT, getConfig()->theme.code.bg); code->tic->api.fixed_text(code->tic, code->status, 0, TIC80_HEIGHT - TIC_FONT_HEIGHT, getConfig()->theme.code.bg, false);
} }
static void drawCursor(Code* code, s32 x, s32 y, char symbol) static void drawCursor(Code* code, s32 x, s32 y, char symbol)
@ -58,16 +58,16 @@ static void drawCursor(Code* code, s32 x, s32 y, char symbol)
if(inverse) if(inverse)
{ {
code->tic->api.rect(code->tic, x-1, y-1, TIC_FONT_WIDTH+1, TIC_FONT_HEIGHT+1, getConfig()->theme.code.cursor); code->tic->api.rect(code->tic, x-1, y-1, (code->altFont ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH)+1, TIC_FONT_HEIGHT+1, getConfig()->theme.code.cursor);
if(symbol) if(symbol)
code->tic->api.draw_char(code->tic, symbol, x, y, getConfig()->theme.code.bg); code->tic->api.draw_char(code->tic, symbol, x, y, getConfig()->theme.code.bg, code->altFont);
} }
} }
static void drawCode(Code* code, bool withCursor) static void drawCode(Code* code, bool withCursor)
{ {
s32 xStart = code->rect.x - code->scroll.x * STUDIO_TEXT_WIDTH; s32 xStart = code->rect.x - code->scroll.x * (code->altFont ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH);
s32 x = xStart; s32 x = xStart;
s32 y = code->rect.y - code->scroll.y * STUDIO_TEXT_HEIGHT; s32 y = code->rect.y - code->scroll.y * STUDIO_TEXT_HEIGHT;
char* pointer = code->src; char* pointer = code->src;
@ -89,10 +89,10 @@ static void drawCode(Code* code, bool withCursor)
code->tic->api.rect(code->tic, x-1, y-1, TIC_FONT_WIDTH+1, TIC_FONT_HEIGHT+1, getConfig()->theme.code.select); code->tic->api.rect(code->tic, x-1, y-1, TIC_FONT_WIDTH+1, TIC_FONT_HEIGHT+1, getConfig()->theme.code.select);
else if(getConfig()->theme.code.shadow) else if(getConfig()->theme.code.shadow)
{ {
code->tic->api.draw_char(code->tic, symbol, x+1, y+1, 0); code->tic->api.draw_char(code->tic, symbol, x+1, y+1, 0, code->altFont);
} }
code->tic->api.draw_char(code->tic, symbol, x, y, *colorPointer); code->tic->api.draw_char(code->tic, symbol, x, y, *colorPointer, code->altFont);
} }
if(code->cursor.position == pointer) if(code->cursor.position == pointer)
@ -103,7 +103,7 @@ static void drawCode(Code* code, bool withCursor)
x = xStart; x = xStart;
y += STUDIO_TEXT_HEIGHT; y += STUDIO_TEXT_HEIGHT;
} }
else x += STUDIO_TEXT_WIDTH; else x += (code->altFont ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH);
pointer++; pointer++;
colorPointer++; colorPointer++;
@ -966,7 +966,7 @@ static void processMouse(Code* code)
{ {
if(checkMouseDown(&code->rect, tic_mouse_right)) if(checkMouseDown(&code->rect, tic_mouse_right))
{ {
code->scroll.x = (code->scroll.start.x - getMouseX()) / STUDIO_TEXT_WIDTH; code->scroll.x = (code->scroll.start.x - getMouseX()) / (code->altFont ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH);
code->scroll.y = (code->scroll.start.y - getMouseY()) / STUDIO_TEXT_HEIGHT; code->scroll.y = (code->scroll.start.y - getMouseY()) / STUDIO_TEXT_HEIGHT;
normalizeScroll(code); normalizeScroll(code);
@ -980,7 +980,7 @@ static void processMouse(Code* code)
s32 mx = getMouseX(); s32 mx = getMouseX();
s32 my = getMouseY(); s32 my = getMouseY();
s32 x = (mx - code->rect.x) / STUDIO_TEXT_WIDTH; s32 x = (mx - code->rect.x) / (code->altFont ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH);
s32 y = (my - code->rect.y) / STUDIO_TEXT_HEIGHT; s32 y = (my - code->rect.y) / STUDIO_TEXT_HEIGHT;
char* position = code->cursor.position; char* position = code->cursor.position;
@ -1009,7 +1009,7 @@ static void processMouse(Code* code)
{ {
code->scroll.active = true; code->scroll.active = true;
code->scroll.start.x = getMouseX() + code->scroll.x * STUDIO_TEXT_WIDTH; code->scroll.start.x = getMouseX() + code->scroll.x * (code->altFont ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH);
code->scroll.start.y = getMouseY() + code->scroll.y * STUDIO_TEXT_HEIGHT; code->scroll.start.y = getMouseY() + code->scroll.y * STUDIO_TEXT_HEIGHT;
} }
@ -1061,9 +1061,9 @@ static void drawPopupBar(Code* code, const char* title)
enum {TextY = TOOLBAR_SIZE + 1}; enum {TextY = TOOLBAR_SIZE + 1};
code->tic->api.rect(code->tic, 0, TOOLBAR_SIZE, TIC80_WIDTH, TIC_FONT_HEIGHT + 1, (tic_color_blue)); code->tic->api.rect(code->tic, 0, TOOLBAR_SIZE, TIC80_WIDTH, TIC_FONT_HEIGHT + 1, (tic_color_blue));
code->tic->api.fixed_text(code->tic, title, 0, TextY, (tic_color_white)); code->tic->api.fixed_text(code->tic, title, 0, TextY, (tic_color_white), false);
code->tic->api.fixed_text(code->tic, code->popup.text, (s32)strlen(title)*TIC_FONT_WIDTH, TextY, (tic_color_white)); code->tic->api.fixed_text(code->tic, code->popup.text, (s32)strlen(title)*TIC_FONT_WIDTH, TextY, (tic_color_white), false);
drawCursor(code, (s32)(strlen(title) + strlen(code->popup.text)) * TIC_FONT_WIDTH, TextY, ' '); drawCursor(code, (s32)(strlen(title) + strlen(code->popup.text)) * TIC_FONT_WIDTH, TextY, ' ');
} }
@ -1248,12 +1248,12 @@ static void drawOutlineBar(Code* code, s32 x, s32 y)
rect.w + 1, TIC_FONT_HEIGHT + 1, (tic_color_red)); rect.w + 1, TIC_FONT_HEIGHT + 1, (tic_color_red));
while(ptr->pos) while(ptr->pos)
{ {
code->tic->api.fixed_text(code->tic, ptr->name, x, y, (tic_color_white)); code->tic->api.fixed_text(code->tic, ptr->name, x, y, (tic_color_white), false);
ptr++; ptr++;
y += STUDIO_TEXT_HEIGHT; y += STUDIO_TEXT_HEIGHT;
} }
} }
else code->tic->api.fixed_text(code->tic, "(empty)", x, y, (tic_color_white)); else code->tic->api.fixed_text(code->tic, "(empty)", x, y, (tic_color_white), false);
} }
static void textOutlineTick(Code* code) static void textOutlineTick(Code* code)
@ -1308,6 +1308,32 @@ static void textOutlineTick(Code* code)
drawOutlineBar(code, TIC80_WIDTH - 12 * TIC_FONT_WIDTH, 2*(TIC_FONT_HEIGHT+1)); drawOutlineBar(code, TIC80_WIDTH - 12 * TIC_FONT_WIDTH, 2*(TIC_FONT_HEIGHT+1));
} }
static void drawFontButton(Code* code, s32 x, s32 y)
{
tic_mem* tic = code->tic;
enum {Size = TIC_FONT_WIDTH};
tic_rect rect = {x, y, Size, Size};
bool over = false;
if(checkMousePos(&rect))
{
setCursor(tic_cursor_hand);
showTooltip("SWITCH FONT");
over = true;
if(checkMouseClick(&rect, tic_mouse_left))
{
code->altFont = !code->altFont;
}
}
tic->api.draw_char(tic, 'F', x, y, over ? tic_color_dark_gray : tic_color_light_blue, code->altFont);
}
static void drawCodeToolbar(Code* code) static void drawCodeToolbar(Code* code)
{ {
code->tic->api.rect(code->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, (tic_color_white)); code->tic->api.rect(code->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, (tic_color_white));
@ -1392,6 +1418,8 @@ static void drawCodeToolbar(Code* code)
drawBitIcon(rect.x, rect.y, Icons + i*BITS_IN_BYTE, active ? (tic_color_white) : (over ? (tic_color_dark_gray) : (tic_color_light_blue))); drawBitIcon(rect.x, rect.y, Icons + i*BITS_IN_BYTE, active ? (tic_color_white) : (over ? (tic_color_dark_gray) : (tic_color_light_blue)));
} }
drawFontButton(code, TIC80_WIDTH - (Count+2) * Size, 1);
drawToolbar(code->tic, getConfig()->theme.code.bg, false); drawToolbar(code->tic, getConfig()->theme.code.bg, false);
} }
@ -1472,6 +1500,7 @@ void initCode(Code* code, tic_mem* tic, tic_code* src)
.items = code->outline.items, .items = code->outline.items,
.index = 0, .index = 0,
}, },
.altFont = true,
.event = onStudioEvent, .event = onStudioEvent,
.update = update, .update = update,
}; };

View File

@ -98,6 +98,8 @@ struct Code
s32 index; s32 index;
} outline; } outline;
bool altFont;
void(*tick)(Code*); void(*tick)(Code*);
void(*escape)(Code*); void(*escape)(Code*);
void(*event)(Code*, StudioEvent); void(*event)(Code*, StudioEvent);

View File

@ -241,7 +241,7 @@ static void drawCursor(Console* console, s32 x, s32 y, u8 symbol)
if(inverse) if(inverse)
console->tic->api.rect(console->tic, x-1, y-1, TIC_FONT_WIDTH+1, TIC_FONT_HEIGHT+1, CONSOLE_CURSOR_COLOR); console->tic->api.rect(console->tic, x-1, y-1, TIC_FONT_WIDTH+1, TIC_FONT_HEIGHT+1, CONSOLE_CURSOR_COLOR);
console->tic->api.draw_char(console->tic, symbol, x, y, inverse ? TIC_COLOR_BG : CONSOLE_FRONT_TEXT_COLOR); console->tic->api.draw_char(console->tic, symbol, x, y, inverse ? TIC_COLOR_BG : CONSOLE_FRONT_TEXT_COLOR, false);
} }
static void drawConsoleText(Console* console) static void drawConsoleText(Console* console)
@ -259,7 +259,7 @@ static void drawConsoleText(Console* console)
u8 color = *colorPointer++; u8 color = *colorPointer++;
if(symbol) if(symbol)
console->tic->api.draw_char(console->tic, symbol, x * STUDIO_TEXT_WIDTH, y * STUDIO_TEXT_HEIGHT, color); console->tic->api.draw_char(console->tic, symbol, x * STUDIO_TEXT_WIDTH, y * STUDIO_TEXT_HEIGHT, color, false);
if(++x == CONSOLE_BUFFER_WIDTH) if(++x == CONSOLE_BUFFER_WIDTH)
{ {
@ -285,7 +285,7 @@ static void drawConsoleInputText(Console* console)
if(console->inputPosition == index) if(console->inputPosition == index)
drawCursor(console, x, y, symbol); drawCursor(console, x, y, symbol);
else else
console->tic->api.draw_char(console->tic, symbol, x, y, CONSOLE_FRONT_TEXT_COLOR); console->tic->api.draw_char(console->tic, symbol, x, y, CONSOLE_FRONT_TEXT_COLOR, false);
index++; index++;

View File

@ -57,8 +57,8 @@ static void drawButton(Dialog* dlg, const char* label, s32 x, s32 y, u8 color, u
tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, (tic_color_white)); tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, (tic_color_white));
} }
s32 size = tic->api.text(tic, label, 0, -TIC_FONT_HEIGHT, 0); s32 size = tic->api.text(tic, label, 0, -TIC_FONT_HEIGHT, 0, false);
tic->api.text(tic, label, rect.x + (BtnWidth - size+1)/2, rect.y + (down?3:2), over ? overColor : color); tic->api.text(tic, label, rect.x + (BtnWidth - size+1)/2, rect.y + (down?3:2), over ? overColor : color, false);
if(dlg->focus == id) if(dlg->focus == id)
{ {
@ -162,8 +162,8 @@ static void drawDialog(Dialog* dlg)
{ {
static const char Label[] = "WARNING!"; static const char Label[] = "WARNING!";
s32 size = tic->api.text(tic, Label, 0, -TIC_FONT_HEIGHT, 0); s32 size = tic->api.text(tic, Label, 0, -TIC_FONT_HEIGHT, 0, false);
tic->api.text(tic, Label, rect.x + (Width - size)/2, rect.y-(TOOLBAR_SIZE-2), (tic_color_gray)); tic->api.text(tic, Label, rect.x + (Width - size)/2, rect.y-(TOOLBAR_SIZE-2), (tic_color_gray), false);
} }
{ {
@ -174,12 +174,12 @@ static void drawDialog(Dialog* dlg)
{ {
for(s32 i = 0; i < dlg->rows; i++) for(s32 i = 0; i < dlg->rows; i++)
{ {
s32 size = tic->api.text(tic, dlg->text[i], 0, -TIC_FONT_HEIGHT, 0); s32 size = tic->api.text(tic, dlg->text[i], 0, -TIC_FONT_HEIGHT, 0, false);
s32 x = rect.x + (Width - size)/2; s32 x = rect.x + (Width - size)/2;
s32 y = rect.y + (TIC_FONT_HEIGHT+1)*(i+1); s32 y = rect.y + (TIC_FONT_HEIGHT+1)*(i+1);
tic->api.text(tic, dlg->text[i], x, y+1, (tic_color_black)); tic->api.text(tic, dlg->text[i], x, y+1, (tic_color_black), false);
tic->api.text(tic, dlg->text[i], x, y, (tic_color_white)); tic->api.text(tic, dlg->text[i], x, y, (tic_color_white), false);
} }
} }

View File

@ -63,8 +63,9 @@ static duk_ret_t duk_print(duk_context* duk)
s32 color = duk_is_null_or_undefined(duk, 3) ? (TIC_PALETTE_SIZE-1) : duk_to_int(duk, 3); s32 color = duk_is_null_or_undefined(duk, 3) ? (TIC_PALETTE_SIZE-1) : duk_to_int(duk, 3);
bool fixed = duk_is_null_or_undefined(duk, 4) ? false : duk_to_boolean(duk, 4); bool fixed = duk_is_null_or_undefined(duk, 4) ? false : duk_to_boolean(duk, 4);
s32 scale = duk_is_null_or_undefined(duk, 5) ? 1 : duk_to_int(duk, 5); s32 scale = duk_is_null_or_undefined(duk, 5) ? 1 : duk_to_int(duk, 5);
bool alt = duk_is_null_or_undefined(duk, 6) ? false : duk_to_boolean(duk, 6);
s32 size = memory->api.text_ex(memory, text ? text : "nil", x, y, color, fixed, scale); s32 size = memory->api.text_ex(memory, text ? text : "nil", x, y, color, fixed, scale, alt);
duk_push_uint(duk, size); duk_push_uint(duk, size);
@ -611,6 +612,7 @@ static duk_ret_t duk_font(duk_context* duk)
s32 height = duk_is_null_or_undefined(duk, 5) ? TIC_SPRITESIZE : duk_to_int(duk, 5); s32 height = duk_is_null_or_undefined(duk, 5) ? TIC_SPRITESIZE : duk_to_int(duk, 5);
bool fixed = duk_is_null_or_undefined(duk, 6) ? false : duk_to_boolean(duk, 6); bool fixed = duk_is_null_or_undefined(duk, 6) ? false : duk_to_boolean(duk, 6);
s32 scale = duk_is_null_or_undefined(duk, 7) ? 1 : duk_to_int(duk, 7); s32 scale = duk_is_null_or_undefined(duk, 7) ? 1 : duk_to_int(duk, 7);
bool alt = duk_is_null_or_undefined(duk, 8) ? false : duk_to_boolean(duk, 8);
if(scale == 0) if(scale == 0)
{ {
@ -618,7 +620,7 @@ static duk_ret_t duk_font(duk_context* duk)
return 1; return 1;
} }
s32 size = drawText(memory, text, x, y, width, height, chromakey, scale, fixed ? drawSpriteFont : drawFixedSpriteFont); s32 size = drawText(memory, text, x, y, width, height, chromakey, scale, fixed ? drawSpriteFont : drawFixedSpriteFont, alt);
duk_push_int(duk, size); duk_push_int(duk, size);

View File

@ -933,6 +933,7 @@ static s32 lua_font(lua_State* lua)
u8 chromakey = 0; u8 chromakey = 0;
bool fixed = false; bool fixed = false;
s32 scale = 1; s32 scale = 1;
bool alt = false;
if(top >= 3) if(top >= 3)
{ {
@ -955,6 +956,11 @@ static s32 lua_font(lua_State* lua)
if(top >= 8) if(top >= 8)
{ {
scale = getLuaNumber(lua, 8); scale = getLuaNumber(lua, 8);
if(top >= 9)
{
alt = lua_toboolean(lua, 9);
}
} }
} }
} }
@ -967,7 +973,7 @@ static s32 lua_font(lua_State* lua)
return 1; return 1;
} }
s32 size = drawText(memory, text, x, y, width, height, chromakey, scale, fixed ? drawSpriteFont : drawFixedSpriteFont); s32 size = drawText(memory, text, x, y, width, height, chromakey, scale, fixed ? drawSpriteFont : drawFixedSpriteFont, alt);
lua_pushinteger(lua, size); lua_pushinteger(lua, size);
@ -991,6 +997,7 @@ static s32 lua_print(lua_State* lua)
s32 color = TIC_PALETTE_SIZE-1; s32 color = TIC_PALETTE_SIZE-1;
bool fixed = false; bool fixed = false;
s32 scale = 1; s32 scale = 1;
bool alt = false;
const char* text = printString(lua, 1); const char* text = printString(lua, 1);
@ -1010,6 +1017,11 @@ static s32 lua_print(lua_State* lua)
if(top >= 6) if(top >= 6)
{ {
scale = getLuaNumber(lua, 6); scale = getLuaNumber(lua, 6);
if(top >= 7)
{
alt = lua_toboolean(lua, 7);
}
} }
} }
} }
@ -1021,7 +1033,7 @@ static s32 lua_print(lua_State* lua)
return 1; return 1;
} }
s32 size = memory->api.text_ex(memory, text ? text : "nil", x, y, color, fixed, scale); s32 size = memory->api.text_ex(memory, text ? text : "nil", x, y, color, fixed, scale, alt);
lua_pushinteger(lua, size); lua_pushinteger(lua, size);

View File

@ -163,10 +163,10 @@ typedef struct
} tic_machine; } tic_machine;
typedef s32(DrawCharFunc)(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale); typedef s32(DrawCharFunc)(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale, bool alt);
s32 drawText(tic_mem* memory, const char* text, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale, DrawCharFunc* func); s32 drawText(tic_mem* memory, const char* text, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale, DrawCharFunc* func, bool alt);
s32 drawSpriteFont(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale); s32 drawSpriteFont(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale, bool alt);
s32 drawFixedSpriteFont(tic_mem* memory, u8 index, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale); s32 drawFixedSpriteFont(tic_mem* memory, u8 index, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale, bool alt);
void parseCode(const tic_script_config* config, const char* start, u8* color, const tic_code_theme* theme); void parseCode(const tic_script_config* config, const char* start, u8* color, const tic_code_theme* theme);
#if defined(TIC_BUILD_WITH_LUA) #if defined(TIC_BUILD_WITH_LUA)

View File

@ -328,7 +328,7 @@ static void drawTileIndex(Map* map, s32 x, s32 y)
{ {
char buf[] = "#999"; char buf[] = "#999";
sprintf(buf, "#%03i", index); sprintf(buf, "#%03i", index);
map->tic->api.text(map->tic, buf, x, y, (tic_color_light_blue)); map->tic->api.text(map->tic, buf, x, y, (tic_color_light_blue), false);
} }
} }
@ -424,7 +424,7 @@ static void drawCursorPos(Map* map, s32 x, s32 y)
sprintf(pos, "%03i:%03i", tx, ty); sprintf(pos, "%03i:%03i", tx, ty);
s32 width = map->tic->api.text(map->tic, pos, TIC80_WIDTH, 0, (tic_color_gray)); s32 width = map->tic->api.text(map->tic, pos, TIC80_WIDTH, 0, (tic_color_gray), false);
s32 px = x + (TIC_SPRITESIZE + 3); s32 px = x + (TIC_SPRITESIZE + 3);
if(px + width >= TIC80_WIDTH) px = x - (width + 2); if(px + width >= TIC80_WIDTH) px = x - (width + 2);
@ -433,7 +433,7 @@ static void drawCursorPos(Map* map, s32 x, s32 y)
if(py <= TOOLBAR_SIZE) py = y + (TIC_SPRITESIZE + 3); if(py <= TOOLBAR_SIZE) py = y + (TIC_SPRITESIZE + 3);
map->tic->api.rect(map->tic, px - 1, py - 1, width + 1, TIC_FONT_HEIGHT + 1, (tic_color_white)); map->tic->api.rect(map->tic, px - 1, py - 1, width + 1, TIC_FONT_HEIGHT + 1, (tic_color_white));
map->tic->api.text(map->tic, pos, px, py, (tic_color_light_blue)); map->tic->api.text(map->tic, pos, px, py, (tic_color_light_blue), false);
} }
static void setMapSprite(Map* map, s32 x, s32 y) static void setMapSprite(Map* map, s32 x, s32 y)

View File

@ -119,8 +119,8 @@ static void drawDialog(Menu* menu)
{ {
static const char Label[] = "GAME MENU"; static const char Label[] = "GAME MENU";
s32 size = tic->api.text(tic, Label, 0, -TIC_FONT_HEIGHT, 0); s32 size = tic->api.text(tic, Label, 0, -TIC_FONT_HEIGHT, 0, false);
tic->api.text(tic, Label, rect.x + (DIALOG_WIDTH - size)/2, rect.y-(TOOLBAR_SIZE-2), (tic_color_gray)); tic->api.text(tic, Label, rect.x + (DIALOG_WIDTH - size)/2, rect.y-(TOOLBAR_SIZE-2), (tic_color_gray), false);
} }
{ {
@ -157,7 +157,7 @@ static void drawTabDisabled(Menu* menu, s32 x, s32 y, s32 id)
{ {
char buf[] = "#1"; char buf[] = "#1";
sprintf(buf, "#%i", id+1); sprintf(buf, "#%i", id+1);
tic->api.fixed_text(tic, buf, x+2, y, (over ? tic_color_light_blue : tic_color_gray)); tic->api.fixed_text(tic, buf, x+2, y, (over ? tic_color_light_blue : tic_color_gray), false);
} }
} }
@ -174,7 +174,7 @@ static void drawTab(Menu* menu, s32 x, s32 y, s32 id)
{ {
char buf[] = "#1"; char buf[] = "#1";
sprintf(buf, "#%i", id+1); sprintf(buf, "#%i", id+1);
tic->api.fixed_text(tic, buf, x+2, y, (tic_color_gray)); tic->api.fixed_text(tic, buf, x+2, y, (tic_color_gray), false);
} }
} }
@ -221,7 +221,7 @@ static void drawPlayerButtons(Menu* menu, s32 x, s32 y)
if(strlen(label) > MaxChars) if(strlen(label) > MaxChars)
label[MaxChars] = '\0'; label[MaxChars] = '\0';
tic->api.text(tic, label, rect.x+10, rect.y+2, (over ? tic_color_gray : tic_color_black)); tic->api.text(tic, label, rect.x+10, rect.y+2, (over ? tic_color_gray : tic_color_black), false);
} }
} }
@ -280,12 +280,12 @@ static void drawGamepadMenu(Menu* menu)
if(down) if(down)
{ {
tic->api.text(tic, Label, rect.x, rect.y+1, (tic_color_light_blue)); tic->api.text(tic, Label, rect.x, rect.y+1, (tic_color_light_blue), false);
} }
else else
{ {
tic->api.text(tic, Label, rect.x, rect.y+1, (tic_color_black)); tic->api.text(tic, Label, rect.x, rect.y+1, (tic_color_black), false);
tic->api.text(tic, Label, rect.x, rect.y, (over ? tic_color_light_blue : tic_color_white)); tic->api.text(tic, Label, rect.x, rect.y, (over ? tic_color_light_blue : tic_color_white), false);
} }
{ {
@ -346,12 +346,12 @@ static void drawMainMenu(Menu* menu)
if(down) if(down)
{ {
tic->api.text(tic, Rows[i], label.x, label.y+1, (tic_color_light_blue)); tic->api.text(tic, Rows[i], label.x, label.y+1, (tic_color_light_blue), false);
} }
else else
{ {
tic->api.text(tic, Rows[i], label.x, label.y+1, (tic_color_black)); tic->api.text(tic, Rows[i], label.x, label.y+1, (tic_color_black), false);
tic->api.text(tic, Rows[i], label.x, label.y, (over ? tic_color_light_blue : tic_color_white)); tic->api.text(tic, Rows[i], label.x, label.y, (over ? tic_color_light_blue : tic_color_white), false);
} }
if(i == menu->main.focus) if(i == menu->main.focus)

View File

@ -139,7 +139,7 @@ static void drawEditbox(Music* music, s32 x, s32 y, s32 value, void(*set)(Music*
char val[] = "99"; char val[] = "99";
sprintf(val, "%02i", value); sprintf(val, "%02i", value);
music->tic->api.fixed_text(music->tic, val, x, y, (tic_color_white)); music->tic->api.fixed_text(music->tic, val, x, y, (tic_color_white), false);
} }
{ {
@ -191,8 +191,8 @@ static void drawSwitch(Music* music, s32 x, s32 y, const char* label, s32 value,
0b00000000, 0b00000000,
}; };
music->tic->api.text(music->tic, label, x, y+1, (tic_color_black)); music->tic->api.text(music->tic, label, x, y+1, (tic_color_black), false);
music->tic->api.text(music->tic, label, x, y, (tic_color_white)); music->tic->api.text(music->tic, label, x, y, (tic_color_white), false);
{ {
x += (s32)strlen(label)*TIC_FONT_WIDTH; x += (s32)strlen(label)*TIC_FONT_WIDTH;
@ -220,8 +220,8 @@ static void drawSwitch(Music* music, s32 x, s32 y, const char* label, s32 value,
{ {
char val[] = "999"; char val[] = "999";
sprintf(val, "%02i", value); sprintf(val, "%02i", value);
music->tic->api.fixed_text(music->tic, val, x + TIC_FONT_WIDTH, y+1, (tic_color_black)); music->tic->api.fixed_text(music->tic, val, x + TIC_FONT_WIDTH, y+1, (tic_color_black), false);
music->tic->api.fixed_text(music->tic, val, x += TIC_FONT_WIDTH, y, (tic_color_white)); music->tic->api.fixed_text(music->tic, val, x += TIC_FONT_WIDTH, y, (tic_color_white), false);
} }
{ {
@ -1166,15 +1166,15 @@ static void drawTrackerFrames(Music* music, s32 x, s32 y)
char buf[] = "99"; char buf[] = "99";
sprintf(buf, "%02i", i); sprintf(buf, "%02i", i);
music->tic->api.fixed_text(music->tic, buf, x, y + i*TIC_FONT_HEIGHT, (tic_color_dark_gray)); music->tic->api.fixed_text(music->tic, buf, x, y + i*TIC_FONT_HEIGHT, (tic_color_dark_gray), false);
} }
if(music->tracker.row >= 0) if(music->tracker.row >= 0)
{ {
char buf[] = "99"; char buf[] = "99";
sprintf(buf, "%02i", music->tracker.row); sprintf(buf, "%02i", music->tracker.row);
music->tic->api.fixed_text(music->tic, buf, x, y - 10, (tic_color_black)); music->tic->api.fixed_text(music->tic, buf, x, y - 10, (tic_color_black), false);
music->tic->api.fixed_text(music->tic, buf, x, y - 11, (tic_color_white)); music->tic->api.fixed_text(music->tic, buf, x, y - 11, (tic_color_white), false);
} }
} }
@ -1306,11 +1306,11 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
char sym = rowStr[c]; char sym = rowStr[c];
const u8* colors = beetRow || sym != '-' ? Colors : DarkColors; const u8* colors = beetRow || sym != '-' ? Colors : DarkColors;
music->tic->api.draw_char(music->tic, sym, colx, rowy, colors[ColorIndexes[c]]); music->tic->api.draw_char(music->tic, sym, colx, rowy, colors[ColorIndexes[c]], false);
} }
} }
} }
else music->tic->api.fixed_text(music->tic, rowStr, x, rowy, (tic_color_dark_gray)); else music->tic->api.fixed_text(music->tic, rowStr, x, rowy, (tic_color_dark_gray), false);
if (i == music->tracker.row) if (i == music->tracker.row)
{ {
@ -1319,7 +1319,7 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
s32 col = music->tracker.col % CHANNEL_COLS; s32 col = music->tracker.col % CHANNEL_COLS;
s32 colx = x - 1 + col * TIC_FONT_WIDTH; s32 colx = x - 1 + col * TIC_FONT_WIDTH;
music->tic->api.rect(music->tic, colx, rowy - 1, TIC_FONT_WIDTH + 1, TIC_FONT_HEIGHT + 1, (tic_color_red)); music->tic->api.rect(music->tic, colx, rowy - 1, TIC_FONT_WIDTH + 1, TIC_FONT_HEIGHT + 1, (tic_color_red));
music->tic->api.draw_char(music->tic, rowStr[col], colx + 1, rowy, (tic_color_black)); music->tic->api.draw_char(music->tic, rowStr[col], colx + 1, rowy, (tic_color_black), false);
} }
} }
@ -1520,7 +1520,7 @@ static void drawPianoLayout(Music* music)
music->tic->api.clear(music->tic, (tic_color_gray)); music->tic->api.clear(music->tic, (tic_color_gray));
static const char Wip[] = "PIANO MODE - WORK IN PROGRESS..."; static const char Wip[] = "PIANO MODE - WORK IN PROGRESS...";
music->tic->api.fixed_text(music->tic, Wip, (TIC80_WIDTH - (sizeof Wip - 1) * TIC_FONT_WIDTH) / 2, TIC80_HEIGHT / 2, (tic_color_white)); music->tic->api.fixed_text(music->tic, Wip, (TIC80_WIDTH - (sizeof Wip - 1) * TIC_FONT_WIDTH) / 2, TIC80_HEIGHT / 2, (tic_color_white), false);
} }
static void scrollNotes(Music* music, s32 delta) static void scrollNotes(Music* music, s32 delta)

View File

@ -63,7 +63,7 @@ static void drawSwitch(Sfx* sfx, s32 x, s32 y, const char* label, s32 value, voi
0b00000000, 0b00000000,
}; };
sfx->tic->api.text(sfx->tic, label, x, y, (tic_color_white)); sfx->tic->api.text(sfx->tic, label, x, y, (tic_color_white), false);
{ {
x += (s32)strlen(label)*TIC_FONT_WIDTH; x += (s32)strlen(label)*TIC_FONT_WIDTH;
@ -84,7 +84,7 @@ static void drawSwitch(Sfx* sfx, s32 x, s32 y, const char* label, s32 value, voi
{ {
char val[] = "99"; char val[] = "99";
sprintf(val, "%02i", value); sprintf(val, "%02i", value);
sfx->tic->api.fixed_text(sfx->tic, val, x += TIC_FONT_WIDTH, y, (tic_color_white)); sfx->tic->api.fixed_text(sfx->tic, val, x += TIC_FONT_WIDTH, y, (tic_color_white), false);
} }
{ {
@ -156,7 +156,7 @@ static void setLoopSize(Sfx* sfx, s32 delta)
static void drawLoopPanel(Sfx* sfx, s32 x, s32 y) static void drawLoopPanel(Sfx* sfx, s32 x, s32 y)
{ {
sfx->tic->api.text(sfx->tic, "LOOP:", x, y, (tic_color_dark_gray)); sfx->tic->api.text(sfx->tic, "LOOP:", x, y, (tic_color_dark_gray), false);
enum {Gap = 2}; enum {Gap = 2};
@ -293,7 +293,7 @@ static void drawCanvasTabs(Sfx* sfx, s32 x, s32 y)
for(s32 i = 0, sy = y; i < COUNT_OF(Labels); sy += Height, i++) for(s32 i = 0, sy = y; i < COUNT_OF(Labels); sy += Height, i++)
{ {
s32 size = sfx->tic->api.text(sfx->tic, Labels[i], 0, -TIC_FONT_HEIGHT, (tic_color_black)); s32 size = sfx->tic->api.text(sfx->tic, Labels[i], 0, -TIC_FONT_HEIGHT, (tic_color_black), false);
tic_rect rect = {x - size, sy, size, TIC_FONT_HEIGHT}; tic_rect rect = {x - size, sy, size, TIC_FONT_HEIGHT};
@ -307,7 +307,7 @@ static void drawCanvasTabs(Sfx* sfx, s32 x, s32 y)
} }
} }
sfx->tic->api.text(sfx->tic, Labels[i], rect.x, rect.y, i == sfx->canvasTab ? (tic_color_white) : (tic_color_dark_gray)); sfx->tic->api.text(sfx->tic, Labels[i], rect.x, rect.y, i == sfx->canvasTab ? (tic_color_white) : (tic_color_dark_gray), false);
} }
tic_sample* effect = getEffect(sfx); tic_sample* effect = getEffect(sfx);
@ -328,7 +328,7 @@ static void drawCanvasTabs(Sfx* sfx, s32 x, s32 y)
effect->pitch16x++; effect->pitch16x++;
} }
sfx->tic->api.fixed_text(sfx->tic, Label, rect.x, rect.y, (effect->pitch16x ? tic_color_white : tic_color_dark_gray)); sfx->tic->api.fixed_text(sfx->tic, Label, rect.x, rect.y, (effect->pitch16x ? tic_color_white : tic_color_dark_gray), false);
} }
break; break;
case SFX_ARPEGGIO_TAB: case SFX_ARPEGGIO_TAB:
@ -345,7 +345,7 @@ static void drawCanvasTabs(Sfx* sfx, s32 x, s32 y)
effect->reverse++; effect->reverse++;
} }
sfx->tic->api.text(sfx->tic, Label, rect.x, rect.y, (effect->reverse ? tic_color_white : tic_color_dark_gray)); sfx->tic->api.text(sfx->tic, Label, rect.x, rect.y, (effect->reverse ? tic_color_white : tic_color_dark_gray), false);
} }
break; break;
default: break; default: break;
@ -517,7 +517,7 @@ static void drawOctavePanel(Sfx* sfx, s32 x, s32 y)
tic_sample* effect = getEffect(sfx); tic_sample* effect = getEffect(sfx);
static const char Label[] = "OCT"; static const char Label[] = "OCT";
sfx->tic->api.text(sfx->tic, Label, x, y, (tic_color_white)); sfx->tic->api.text(sfx->tic, Label, x, y, (tic_color_white), false);
x += sizeof(Label)*TIC_FONT_WIDTH; x += sizeof(Label)*TIC_FONT_WIDTH;
@ -537,7 +537,7 @@ static void drawOctavePanel(Sfx* sfx, s32 x, s32 y)
} }
} }
sfx->tic->api.draw_char(sfx->tic, i + '1', rect.x, rect.y, (i == effect->octave ? tic_color_white : tic_color_dark_gray)); sfx->tic->api.draw_char(sfx->tic, i + '1', rect.x, rect.y, (i == effect->octave ? tic_color_white : tic_color_dark_gray), false);
} }
} }
@ -810,7 +810,7 @@ static void drawSfxToolbar(Sfx* sfx)
char buf[] = "C#4"; char buf[] = "C#4";
sprintf(buf, "%s%i", Notes[effect->note], effect->octave+1); sprintf(buf, "%s%i", Notes[effect->note], effect->octave+1);
sfx->tic->api.fixed_text(sfx->tic, buf, x, y, (over ? tic_color_dark_gray : tic_color_light_blue)); sfx->tic->api.fixed_text(sfx->tic, buf, x, y, (over ? tic_color_dark_gray : tic_color_light_blue), false);
} }
drawModeTabs(sfx); drawModeTabs(sfx);

View File

@ -366,8 +366,8 @@ static void drawCanvas(Sprite* sprite, s32 x, s32 y)
s32 ix = x + (CANVAS_SIZE - 4*TIC_FONT_WIDTH)/2; s32 ix = x + (CANVAS_SIZE - 4*TIC_FONT_WIDTH)/2;
s32 iy = TIC_SPRITESIZE + 2; s32 iy = TIC_SPRITESIZE + 2;
sprite->tic->api.text(sprite->tic, buf, ix, iy+1, (tic_color_black)); sprite->tic->api.text(sprite->tic, buf, ix, iy+1, (tic_color_black), false);
sprite->tic->api.text(sprite->tic, buf, ix, iy, (tic_color_white)); sprite->tic->api.text(sprite->tic, buf, ix, iy, (tic_color_white), false);
} }
sprite->tic->api.rect_border(sprite->tic, x-1, y-1, CANVAS_SIZE+2, CANVAS_SIZE+2, (tic_color_white)); sprite->tic->api.rect_border(sprite->tic, x-1, y-1, CANVAS_SIZE+2, CANVAS_SIZE+2, (tic_color_white));
@ -692,7 +692,7 @@ static void drawRGBSlider(Sprite* sprite, s32 x, s32 y, u8* value)
{ {
char buf[] = "FF"; char buf[] = "FF";
sprintf(buf, "%02X", *value); sprintf(buf, "%02X", *value);
sprite->tic->api.text(sprite->tic, buf, x - 18, y - 2, (tic_color_dark_gray)); sprite->tic->api.text(sprite->tic, buf, x - 18, y - 2, (tic_color_dark_gray), false);
} }
} }
@ -1535,7 +1535,7 @@ static void drawSpriteToolbar(Sprite* sprite)
static const char Label[] = "BG"; static const char Label[] = "BG";
tic_rect rect = {TIC80_WIDTH - 2 * TIC_FONT_WIDTH - 2, 0, 2 * TIC_FONT_WIDTH + 1, TIC_SPRITESIZE-1}; tic_rect rect = {TIC80_WIDTH - 2 * TIC_FONT_WIDTH - 2, 0, 2 * TIC_FONT_WIDTH + 1, TIC_SPRITESIZE-1};
sprite->tic->api.rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, bg ? (tic_color_black) : (tic_color_gray)); sprite->tic->api.rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, bg ? (tic_color_black) : (tic_color_gray));
sprite->tic->api.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, (tic_color_white)); sprite->tic->api.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, (tic_color_white), false);
if(checkMousePos(&rect)) if(checkMousePos(&rect))
{ {
@ -1555,7 +1555,7 @@ static void drawSpriteToolbar(Sprite* sprite)
static const char Label[] = "FG"; static const char Label[] = "FG";
tic_rect rect = {TIC80_WIDTH - 4 * TIC_FONT_WIDTH - 4, 0, 2 * TIC_FONT_WIDTH + 1, TIC_SPRITESIZE-1}; tic_rect rect = {TIC80_WIDTH - 4 * TIC_FONT_WIDTH - 4, 0, 2 * TIC_FONT_WIDTH + 1, TIC_SPRITESIZE-1};
sprite->tic->api.rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, bg ? (tic_color_gray) : (tic_color_black)); sprite->tic->api.rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, bg ? (tic_color_gray) : (tic_color_black));
sprite->tic->api.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, (tic_color_white)); sprite->tic->api.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, (tic_color_white), false);
if(checkMousePos(&rect)) if(checkMousePos(&rect))
{ {

View File

@ -38,9 +38,9 @@ static void reset(Start* start)
static void drawHeader(Start* start) static void drawHeader(Start* start)
{ {
start->tic->api.fixed_text(start->tic, TIC_NAME_FULL, STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT, (tic_color_white)); start->tic->api.fixed_text(start->tic, TIC_NAME_FULL, STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT, (tic_color_white), false);
start->tic->api.fixed_text(start->tic, TIC_VERSION_LABEL, (sizeof(TIC_NAME_FULL) + 1) * STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT, (tic_color_dark_gray)); start->tic->api.fixed_text(start->tic, TIC_VERSION_LABEL, (sizeof(TIC_NAME_FULL) + 1) * STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT, (tic_color_dark_gray), false);
start->tic->api.fixed_text(start->tic, TIC_COPYRIGHT, STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT*2, (tic_color_dark_gray)); start->tic->api.fixed_text(start->tic, TIC_COPYRIGHT, STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT*2, (tic_color_dark_gray), false);
} }
static void header(Start* start) static void header(Start* start)

View File

@ -595,7 +595,7 @@ static void drawBankIcon(s32 x, s32 y)
if(i == impl.bank.indexes[mode]) if(i == impl.bank.indexes[mode])
tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, tic_color_red); tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, tic_color_red);
tic->api.draw_char(tic, '0' + i, rect.x+1, rect.y+1, i == impl.bank.indexes[mode] ? tic_color_white : over ? tic_color_red : tic_color_peach); tic->api.draw_char(tic, '0' + i, rect.x+1, rect.y+1, i == impl.bank.indexes[mode] ? tic_color_white : over ? tic_color_red : tic_color_peach, false);
} }
@ -764,11 +764,11 @@ void drawToolbar(tic_mem* tic, u8 color, bool bg)
{ {
if(strlen(impl.tooltip.text)) if(strlen(impl.tooltip.text))
{ {
impl.studio.tic->api.text(tic, impl.tooltip.text, TextOffset, 1, (tic_color_black)); impl.studio.tic->api.text(tic, impl.tooltip.text, TextOffset, 1, (tic_color_black), false);
} }
else else
{ {
impl.studio.tic->api.text(tic, Names[mode], TextOffset, 1, (tic_color_dark_gray)); impl.studio.tic->api.text(tic, Names[mode], TextOffset, 1, (tic_color_dark_gray), false);
} }
} }
} }
@ -1538,7 +1538,7 @@ static void drawPopup()
impl.studio.tic->api.rect(impl.studio.tic, 0, anim, TIC80_WIDTH, TIC_FONT_HEIGHT+1, (tic_color_red)); impl.studio.tic->api.rect(impl.studio.tic, 0, anim, TIC80_WIDTH, TIC_FONT_HEIGHT+1, (tic_color_red));
impl.studio.tic->api.text(impl.studio.tic, impl.popup.message, impl.studio.tic->api.text(impl.studio.tic, impl.popup.message,
(s32)(TIC80_WIDTH - strlen(impl.popup.message)*TIC_FONT_WIDTH)/2, (s32)(TIC80_WIDTH - strlen(impl.popup.message)*TIC_FONT_WIDTH)/2,
anim + 1, (tic_color_white)); anim + 1, (tic_color_white), false);
} }
} }

View File

@ -194,8 +194,8 @@ static void drawTopToolbar(Surf* surf, s32 x, s32 y)
s32 xl = x + MAIN_OFFSET; s32 xl = x + MAIN_OFFSET;
s32 yl = y + (Height - TIC_FONT_HEIGHT)/2; s32 yl = y + (Height - TIC_FONT_HEIGHT)/2;
tic->api.text(tic, label, xl, yl+1, tic_color_black); tic->api.text(tic, label, xl, yl+1, tic_color_black, false);
tic->api.text(tic, label, xl, yl, tic_color_white); tic->api.text(tic, label, xl, yl, tic_color_white, false);
} }
enum{Gap = 10, TipX = 150, SelectWidth = 54}; enum{Gap = 10, TipX = 150, SelectWidth = 54};
@ -204,15 +204,15 @@ static void drawTopToolbar(Surf* surf, s32 x, s32 y)
tic->api.sprite_ex(tic, &getConfig()->cart->bank0.tiles, 12, TipX, y+1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); tic->api.sprite_ex(tic, &getConfig()->cart->bank0.tiles, 12, TipX, y+1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate);
{ {
static const char Label[] = "SELECT"; static const char Label[] = "SELECT";
tic->api.text(tic, Label, TipX + Gap, y+3, tic_color_black); tic->api.text(tic, Label, TipX + Gap, y+3, tic_color_black, false);
tic->api.text(tic, Label, TipX + Gap, y+2, tic_color_white); tic->api.text(tic, Label, TipX + Gap, y+2, tic_color_white, false);
} }
tic->api.sprite_ex(tic, &getConfig()->cart->bank0.tiles, 13, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); tic->api.sprite_ex(tic, &getConfig()->cart->bank0.tiles, 13, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate);
{ {
static const char Label[] = "BACK"; static const char Label[] = "BACK";
tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black); tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black, false);
tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +2, tic_color_white); tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +2, tic_color_white, false);
} }
} }
@ -232,8 +232,8 @@ static void drawBottomToolbar(Surf* surf, s32 x, s32 y)
sprintf(label, "/%s", dir); sprintf(label, "/%s", dir);
s32 xl = x + MAIN_OFFSET; s32 xl = x + MAIN_OFFSET;
s32 yl = y + (Height - TIC_FONT_HEIGHT)/2; s32 yl = y + (Height - TIC_FONT_HEIGHT)/2;
tic->api.text(tic, label, xl, yl+1, tic_color_black); tic->api.text(tic, label, xl, yl+1, tic_color_black, false);
tic->api.text(tic, label, xl, yl, tic_color_white); tic->api.text(tic, label, xl, yl, tic_color_white, false);
} }
#ifdef CAN_OPEN_URL #ifdef CAN_OPEN_URL
@ -247,8 +247,8 @@ static void drawBottomToolbar(Surf* surf, s32 x, s32 y)
tic->api.sprite_ex(tic, &getConfig()->cart->bank0.tiles, 15, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); tic->api.sprite_ex(tic, &getConfig()->cart->bank0.tiles, 15, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate);
{ {
static const char Label[] = "WEBSITE"; static const char Label[] = "WEBSITE";
tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black); tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black, false);
tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +2, tic_color_white); tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +2, tic_color_white, false);
} }
} }
#endif #endif
@ -331,14 +331,14 @@ static void drawMenu(Surf* surf, s32 x, s32 y, bool bg)
if(bg) if(bg)
{ {
s32 size = tic->api.text(tic, name, 0, -TIC_FONT_HEIGHT, 0); s32 size = tic->api.text(tic, name, 0, -TIC_FONT_HEIGHT, 0, false);
drawInverseRect(tic, x + MAIN_OFFSET - 1, ym-1, size+1, TIC_FONT_HEIGHT+2); drawInverseRect(tic, x + MAIN_OFFSET - 1, ym-1, size+1, TIC_FONT_HEIGHT+2);
} }
else else
{ {
tic->api.text(tic, name, x + MAIN_OFFSET, ym + 1, tic_color_black); tic->api.text(tic, name, x + MAIN_OFFSET, ym + 1, tic_color_black, false);
tic->api.text(tic, name, x + MAIN_OFFSET, ym, tic_color_white); tic->api.text(tic, name, x + MAIN_OFFSET, ym, tic_color_white, false);
} }
} }
} }
@ -837,8 +837,8 @@ static void tick(Surf* surf)
else else
{ {
static const char Label[] = "You don't have any files..."; static const char Label[] = "You don't have any files...";
s32 size = tic->api.text(tic, Label, 0, -TIC_FONT_HEIGHT, tic_color_white); s32 size = tic->api.text(tic, Label, 0, -TIC_FONT_HEIGHT, tic_color_white, false);
tic->api.text(tic, Label, (TIC80_WIDTH - size) / 2, (TIC80_HEIGHT - TIC_FONT_HEIGHT)/2, tic_color_white); tic->api.text(tic, Label, (TIC80_WIDTH - size) / 2, (TIC80_HEIGHT - TIC_FONT_HEIGHT)/2, tic_color_white, false);
} }
} }

View File

@ -615,25 +615,25 @@ static void api_clear(tic_mem* memory, u8 color)
} }
} }
static s32 drawChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale) static s32 drawChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale, bool alt)
{ {
const u8* ptr = memory->font.data + symbol*BITS_IN_BYTE; const u8* ptr = memory->font.data + (symbol + (alt ? TIC_FONT_CHARS / 2 : 0))*BITS_IN_BYTE;
x += (BITS_IN_BYTE - 1)*scale; x += (BITS_IN_BYTE - 1)*scale;
for(s32 i = 0, ys = y; i < TIC_FONT_HEIGHT; i++, ptr++, ys += scale) for(s32 i = 0, ys = y; i < TIC_FONT_HEIGHT; i++, ptr++, ys += scale)
for(s32 col = BITS_IN_BYTE - TIC_FONT_WIDTH, xs = x - col; col < BITS_IN_BYTE; col++, xs -= scale) for(s32 col = BITS_IN_BYTE - (alt ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH), xs = x - col; col < BITS_IN_BYTE; col++, xs -= scale)
if(*ptr & 1 << col) if(*ptr & 1 << col)
api_rect(memory, xs, ys, scale, scale, color); api_rect(memory, xs, ys, scale, scale, color);
return TIC_FONT_WIDTH*scale; return (alt ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH)*scale;
} }
static s32 api_draw_char(tic_mem* memory, u8 symbol, s32 x, s32 y, u8 color) static s32 api_draw_char(tic_mem* memory, u8 symbol, s32 x, s32 y, u8 color, bool alt)
{ {
return drawChar(memory, symbol, x, y, TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, 1); return drawChar(memory, symbol, x, y, alt ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, 1, alt);
} }
s32 drawText(tic_mem* memory, const char* text, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale, DrawCharFunc* func) s32 drawText(tic_mem* memory, const char* text, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale, DrawCharFunc* func, bool alt)
{ {
s32 pos = x; s32 pos = x;
s32 max = x; s32 max = x;
@ -649,26 +649,28 @@ s32 drawText(tic_mem* memory, const char* text, s32 x, s32 y, s32 width, s32 hei
pos = x; pos = x;
y += height * scale; y += height * scale;
} }
else pos += func(memory, sym, pos, y, width, height, color, scale); else pos += func(memory, sym, pos, y, width, height, color, scale, alt);
} }
return pos > max ? pos - x : max - x; return pos > max ? pos - x : max - x;
} }
static s32 api_fixed_text(tic_mem* memory, const char* text, s32 x, s32 y, u8 color) static s32 api_fixed_text(tic_mem* memory, const char* text, s32 x, s32 y, u8 color, bool alt)
{ {
return drawText(memory, text, x, y, TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, 1, drawChar); return drawText(memory, text, x, y, alt ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, 1, drawChar, alt);
} }
static s32 drawNonFixedChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale) static s32 drawNonFixedChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale, bool alt)
{ {
const u8* ptr = memory->font.data + (symbol)*BITS_IN_BYTE; const u8* ptr = memory->font.data + (symbol)*BITS_IN_BYTE + (alt ? TIC_FONT_CHARS / 2 : 0);
const s32 FontWidth = alt ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH;
s32 start = 0; s32 start = 0;
s32 end = TIC_FONT_WIDTH; s32 end = FontWidth;
s32 i = 0; s32 i = 0;
for(s32 col = 0; col < TIC_FONT_WIDTH; col++) for(s32 col = 0; col < FontWidth; col++)
{ {
for(i = 0; i < TIC_FONT_HEIGHT; i++) for(i = 0; i < TIC_FONT_HEIGHT; i++)
if(*(ptr + i) & 0b10000000 >> col) break; if(*(ptr + i) & 0b10000000 >> col) break;
@ -678,7 +680,7 @@ static s32 drawNonFixedChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width,
x -= start * scale; x -= start * scale;
for(s32 col = TIC_FONT_WIDTH - 1; col >= start; col--) for(s32 col = FontWidth - 1; col >= start; col--)
{ {
for(i = 0; i < TIC_FONT_HEIGHT; i++) for(i = 0; i < TIC_FONT_HEIGHT; i++)
if(*(ptr + i) & 0b10000000 >> col) break; if(*(ptr + i) & 0b10000000 >> col) break;
@ -692,17 +694,17 @@ static s32 drawNonFixedChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width,
api_rect(memory, xs, ys, scale, scale, color); api_rect(memory, xs, ys, scale, scale, color);
s32 size = end - start; s32 size = end - start;
return (size ? size + 1 : TIC_FONT_WIDTH - 2) * scale; return (size ? size + 1 : FontWidth - 2) * scale;
} }
static s32 api_text(tic_mem* memory, const char* text, s32 x, s32 y, u8 color) static s32 api_text(tic_mem* memory, const char* text, s32 x, s32 y, u8 color, bool alt)
{ {
return drawText(memory, text, x, y, TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, 1, drawNonFixedChar); return drawText(memory, text, x, y, alt ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, 1, drawNonFixedChar, alt);
} }
static s32 api_text_ex(tic_mem* memory, const char* text, s32 x, s32 y, u8 color, bool fixed, s32 scale) static s32 api_text_ex(tic_mem* memory, const char* text, s32 x, s32 y, u8 color, bool fixed, s32 scale, bool alt)
{ {
return drawText(memory, text, x, y, TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, scale, fixed ? drawChar : drawNonFixedChar); return drawText(memory, text, x, y, alt ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, scale, fixed ? drawChar : drawNonFixedChar, alt);
} }
static void drawSprite(tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, u8* colors, s32 count, s32 scale, tic_flip flip, tic_rotate rotate) static void drawSprite(tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, u8* colors, s32 count, s32 scale, tic_flip flip, tic_rotate rotate)
@ -753,14 +755,14 @@ static void api_sprite_ex(tic_mem* memory, const tic_tiles* src, s32 index, s32
} }
} }
s32 drawSpriteFont(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale) s32 drawSpriteFont(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale, bool alt)
{ {
api_sprite_ex(memory, &memory->ram.sprites, symbol, x, y, 1, 1, &chromakey, 1, scale, tic_no_flip, tic_no_rotate); api_sprite_ex(memory, &memory->ram.sprites, symbol, x, y, 1, 1, &chromakey, 1, scale, tic_no_flip, tic_no_rotate);
return width * scale; return width * scale;
} }
s32 drawFixedSpriteFont(tic_mem* memory, u8 index, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale) s32 drawFixedSpriteFont(tic_mem* memory, u8 index, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale, bool alt)
{ {
const u8* ptr = memory->ram.sprites.data[index].data; const u8* ptr = memory->ram.sprites.data[index].data;

View File

@ -55,6 +55,7 @@
#define TIC_RAM_SIZE (80*1024) //80K #define TIC_RAM_SIZE (80*1024) //80K
#define TIC_FONT_WIDTH 6 #define TIC_FONT_WIDTH 6
#define TIC_FONT_HEIGHT 6 #define TIC_FONT_HEIGHT 6
#define TIC_ALTFONT_WIDTH 4
#define TIC_PALETTE_BPP 4 #define TIC_PALETTE_BPP 4
#define TIC_PALETTE_SIZE (1 << TIC_PALETTE_BPP) #define TIC_PALETTE_SIZE (1 << TIC_PALETTE_BPP)
#define TIC_FRAMERATE 60 #define TIC_FRAMERATE 60
@ -111,7 +112,7 @@
#define TIC_GAMEPADS (sizeof(tic80_gamepads) / sizeof(tic80_gamepad)) #define TIC_GAMEPADS (sizeof(tic80_gamepads) / sizeof(tic80_gamepad))
#define SFX_NOTES {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"} #define SFX_NOTES {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"}
#define TIC_FONT_CHARS 128 #define TIC_FONT_CHARS 256
enum enum
{ {

View File

@ -121,10 +121,10 @@ struct tic_script_config
typedef struct typedef struct
{ {
s32 (*draw_char) (tic_mem* memory, u8 symbol, s32 x, s32 y, u8 color); s32 (*draw_char) (tic_mem* memory, u8 symbol, s32 x, s32 y, u8 color, bool alt);
s32 (*text) (tic_mem* memory, const char* text, s32 x, s32 y, u8 color); s32 (*text) (tic_mem* memory, const char* text, s32 x, s32 y, u8 color, bool alt);
s32 (*fixed_text) (tic_mem* memory, const char* text, s32 x, s32 y, u8 color); s32 (*fixed_text) (tic_mem* memory, const char* text, s32 x, s32 y, u8 color, bool alt);
s32 (*text_ex) (tic_mem* memory, const char* text, s32 x, s32 y, u8 color, bool fixed, s32 scale); s32 (*text_ex) (tic_mem* memory, const char* text, s32 x, s32 y, u8 color, bool fixed, s32 scale, bool alt);
void (*clear) (tic_mem* memory, u8 color); void (*clear) (tic_mem* memory, u8 color);
void (*pixel) (tic_mem* memory, s32 x, s32 y, u8 color); void (*pixel) (tic_mem* memory, s32 x, s32 y, u8 color);
u8 (*get_pixel) (tic_mem* memory, s32 x, s32 y); u8 (*get_pixel) (tic_mem* memory, s32 x, s32 y);

View File

@ -397,7 +397,9 @@ static void wren_print(WrenVM* vm)
return; return;
} }
s32 size = memory->api.text_ex(memory, text, x, y, color, fixed, scale); bool alt = wrenGetSlotBool(vm, 7);
s32 size = memory->api.text_ex(memory, text, x, y, color, fixed, scale, alt);
wrenSetSlotDouble(vm, 0, size); wrenSetSlotDouble(vm, 0, size);
} }
@ -422,6 +424,7 @@ static void wren_font(WrenVM* vm)
u8 chromakey = 0; u8 chromakey = 0;
bool fixed = false; bool fixed = false;
s32 scale = 1; s32 scale = 1;
bool alt = false;
if(top > 3) if(top > 3)
{ {
@ -444,6 +447,11 @@ static void wren_font(WrenVM* vm)
if(top > 8) if(top > 8)
{ {
scale = getWrenNumber(vm, 8); scale = getWrenNumber(vm, 8);
if(top > 9)
{
alt = wrenGetSlotBool(vm, 9);
}
} }
} }
} }
@ -456,7 +464,7 @@ static void wren_font(WrenVM* vm)
return; return;
} }
s32 size = drawText(memory, text ? text : "null", x, y, width, height, chromakey, scale, fixed ? drawSpriteFont : drawFixedSpriteFont); s32 size = drawText(memory, text ? text : "null", x, y, width, height, chromakey, scale, fixed ? drawSpriteFont : drawFixedSpriteFont, alt);
wrenSetSlotDouble(vm, 0, size); wrenSetSlotDouble(vm, 0, size);
} }
} }