Merge branch '#345' into tic_0.47.0

This commit is contained in:
BADIM-PC\Vadim 2017-10-20 12:25:13 +03:00
commit 5bb9e8e05d
20 changed files with 322 additions and 333 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -46,7 +46,7 @@ static void history(Code* code)
static void drawStatus(Code* code) 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, systemColor(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);
} }
@ -1408,12 +1408,14 @@ static void textEditTick(Code* code)
static void drawPopupBar(Code* code, const char* title) static void drawPopupBar(Code* code, const char* title)
{ {
code->tic->api.rect(code->tic, 0, TOOLBAR_SIZE-1, TIC80_WIDTH, TIC_FONT_HEIGHT + 1, systemColor(tic_color_blue)); enum {TextY = TOOLBAR_SIZE + 1};
code->tic->api.fixed_text(code->tic, title, 0, TOOLBAR_SIZE, systemColor(tic_color_white));
code->tic->api.fixed_text(code->tic, code->popup.text, (s32)strlen(title)*TIC_FONT_WIDTH, TOOLBAR_SIZE, systemColor(tic_color_white)); 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));
drawCursor(code, (s32)(strlen(title) + strlen(code->popup.text)) * TIC_FONT_WIDTH, TOOLBAR_SIZE, ' '); code->tic->api.fixed_text(code->tic, code->popup.text, (s32)strlen(title)*TIC_FONT_WIDTH, TextY, (tic_color_white));
drawCursor(code, (s32)(strlen(title) + strlen(code->popup.text)) * TIC_FONT_WIDTH, TextY, ' ');
} }
static void updateFindCode(Code* code, char* pos) static void updateFindCode(Code* code, char* pos)
@ -1574,7 +1576,7 @@ static void textGoToTick(Code* code)
code->tic->api.clear(code->tic, getConfig()->theme.code.bg); code->tic->api.clear(code->tic, getConfig()->theme.code.bg);
if(code->jump.line >= 0) if(code->jump.line >= 0)
code->tic->api.rect(code->tic, 0, (code->jump.line - code->scroll.y) * TIC_FONT_HEIGHT + TOOLBAR_SIZE-1, code->tic->api.rect(code->tic, 0, (code->jump.line - code->scroll.y) * TIC_FONT_HEIGHT + TOOLBAR_SIZE + 1,
TIC80_WIDTH, TIC_FONT_HEIGHT+1, getConfig()->theme.code.select); TIC80_WIDTH, TIC_FONT_HEIGHT+1, getConfig()->theme.code.select);
drawCode(code, false); drawCode(code, false);
@ -1607,7 +1609,7 @@ static void drawOutlineBar(Code* code, s32 x, s32 y)
} }
} }
code->tic->api.rect(code->tic, rect.x-1, rect.y, rect.w+1, rect.h, systemColor(tic_color_blue)); code->tic->api.rect(code->tic, rect.x-1, rect.y, rect.w+1, rect.h, (tic_color_blue));
OutlineItem* ptr = code->outline.items; OutlineItem* ptr = code->outline.items;
@ -1616,15 +1618,15 @@ static void drawOutlineBar(Code* code, s32 x, s32 y)
if(ptr->pos) if(ptr->pos)
{ {
code->tic->api.rect(code->tic, rect.x - 1, rect.y + code->outline.index*STUDIO_TEXT_HEIGHT, code->tic->api.rect(code->tic, rect.x - 1, rect.y + code->outline.index*STUDIO_TEXT_HEIGHT,
rect.w + 1, TIC_FONT_HEIGHT + 1, systemColor(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, systemColor(tic_color_white)); code->tic->api.fixed_text(code->tic, ptr->name, x, y, (tic_color_white));
ptr++; ptr++;
y += STUDIO_TEXT_HEIGHT; y += STUDIO_TEXT_HEIGHT;
} }
} }
else code->tic->api.fixed_text(code->tic, "(empty)", x, y, systemColor(tic_color_white)); else code->tic->api.fixed_text(code->tic, "(empty)", x, y, (tic_color_white));
} }
static void textOutlineTick(Code* code) static void textOutlineTick(Code* code)
@ -1689,7 +1691,7 @@ static void textOutlineTick(Code* code)
static void drawCodeToolbar(Code* code) static void drawCodeToolbar(Code* code)
{ {
code->tic->api.rect(code->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE-1, systemColor(tic_color_white)); code->tic->api.rect(code->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, (tic_color_white));
static const u8 Icons[] = static const u8 Icons[] =
{ {
@ -1766,9 +1768,9 @@ static void drawCodeToolbar(Code* code)
bool active = i == code->mode - TEXT_EDIT_MODE && i != 0; bool active = i == code->mode - TEXT_EDIT_MODE && i != 0;
if(active) if(active)
code->tic->api.rect(code->tic, rect.x, rect.y, Size, Size, systemColor(tic_color_blue)); code->tic->api.rect(code->tic, rect.x, rect.y, Size, Size, (tic_color_blue));
drawBitIcon(rect.x, rect.y, Icons + i*BITS_IN_BYTE, active ? systemColor(tic_color_white) : (over ? systemColor(tic_color_dark_gray) : systemColor(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)));
} }
drawToolbar(code->tic, getConfig()->theme.code.bg, false); drawToolbar(code->tic, getConfig()->theme.code.bg, false);
@ -1836,7 +1838,7 @@ void initCode(Code* code, tic_mem* tic)
.tick = tick, .tick = tick,
.escape = escape, .escape = escape,
.cursor = {{tic->cart.code.data, NULL, 0, 0}, NULL, 0}, .cursor = {{tic->cart.code.data, NULL, 0, 0}, NULL, 0},
.rect = {0, TOOLBAR_SIZE, TIC80_WIDTH, TIC80_HEIGHT - TOOLBAR_SIZE - TIC_FONT_HEIGHT - 1}, .rect = {0, TOOLBAR_SIZE + 1, TIC80_WIDTH, TIC80_HEIGHT - TOOLBAR_SIZE - TIC_FONT_HEIGHT - 1},
.scroll = {0, 0, {0, 0}, false}, .scroll = {0, 0, {0, 0}, false},
.tickCounter = 0, .tickCounter = 0,
.history = NULL, .history = NULL,

View File

@ -85,23 +85,6 @@ static void readCursorTheme(Config* config, lua_State* lua)
lua_pop(lua, 1); lua_pop(lua, 1);
} }
static void readPaletteMapTheme(Config* config, lua_State* lua)
{
lua_getfield(lua, -1, "PALMAP");
if(lua_isstring(lua, -1))
{
const char* val = lua_tostring(lua, -1);
s32 size = (s32)strlen(val);
if(size == TIC_PALETTE_SIZE)
for(s32 i = 0; i < size; i++)
config->data.theme.palmap.data[i] = val[i] - (val[i] >= '0' && val[i] <= '9' ? '0' : 'a' - 10);
}
lua_pop(lua, 1);
}
static void readCodeTheme(Config* config, lua_State* lua) static void readCodeTheme(Config* config, lua_State* lua)
{ {
lua_getfield(lua, -1, "CODE"); lua_getfield(lua, -1, "CODE");
@ -154,7 +137,6 @@ static void readTheme(Config* config, lua_State* lua)
if(lua_type(lua, -1) == LUA_TTABLE) if(lua_type(lua, -1) == LUA_TTABLE)
{ {
readPaletteMapTheme(config, lua);
readCursorTheme(config, lua); readCursorTheme(config, lua);
readCodeTheme(config, lua); readCodeTheme(config, lua);
readGamepadTheme(config, lua); readGamepadTheme(config, lua);

View File

@ -29,10 +29,10 @@
#include <zlib.h> #include <zlib.h>
#define CONSOLE_CURSOR_COLOR (systemColor(tic_color_red)) #define CONSOLE_CURSOR_COLOR ((tic_color_red))
#define CONSOLE_BACK_TEXT_COLOR (systemColor(tic_color_dark_gray)) #define CONSOLE_BACK_TEXT_COLOR ((tic_color_dark_gray))
#define CONSOLE_FRONT_TEXT_COLOR (systemColor(tic_color_white)) #define CONSOLE_FRONT_TEXT_COLOR ((tic_color_white))
#define CONSOLE_ERROR_TEXT_COLOR (systemColor(tic_color_red)) #define CONSOLE_ERROR_TEXT_COLOR ((tic_color_red))
#define CONSOLE_CURSOR_BLINK_PERIOD (TIC_FRAMERATE) #define CONSOLE_CURSOR_BLINK_PERIOD (TIC_FRAMERATE)
#define CONSOLE_CURSOR_DELAY (TIC_FRAMERATE / 2) #define CONSOLE_CURSOR_DELAY (TIC_FRAMERATE / 2)
#define CONSOLE_BUFFER_WIDTH (STUDIO_TEXT_BUFFER_WIDTH) #define CONSOLE_BUFFER_WIDTH (STUDIO_TEXT_BUFFER_WIDTH)
@ -963,9 +963,6 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v
{ {
Console* console = (Console*)data; Console* console = (Console*)data;
tic_palette pal;
memcpy(&pal, console->tic->ram.vram.palette.data, sizeof(tic_palette));
if(name) if(name)
{ {
static const char GifExt[] = ".gif"; static const char GifExt[] = ".gif";
@ -993,7 +990,7 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v
u8 src = image->buffer[x + y * image->width]; u8 src = image->buffer[x + y * image->width];
const gif_color* c = &image->palette[src]; const gif_color* c = &image->palette[src];
tic_rgb rgb = {c->r, c->g, c->b}; tic_rgb rgb = {c->r, c->g, c->b};
u8 color = tic_tool_find_closest_color(console->tic->ram.vram.palette.colors, &rgb); u8 color = tic_tool_find_closest_color(console->tic->cart.palette.colors, &rgb);
setSpritePixel(console->tic->cart.gfx.tiles, x, y, color); setSpritePixel(console->tic->cart.gfx.tiles, x, y, color);
} }
@ -1010,8 +1007,6 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v
} }
else printBack(console, "\nfile not imported :|"); else printBack(console, "\nfile not imported :|");
memcpy(console->tic->ram.vram.palette.data, &pal, sizeof(tic_palette));
commandDone(console); commandDone(console);
} }
@ -1729,10 +1724,10 @@ static void printTable(Console* console, const char* text)
case '+': case '+':
case '|': case '|':
case '-': case '-':
color = systemColor(tic_color_gray); color = (tic_color_gray);
break; break;
default: default:
color = systemColor(tic_color_white); color = (tic_color_white);
} }
*(console->colorBuffer + offset) = color; *(console->colorBuffer + offset) = color;
@ -2070,7 +2065,7 @@ static void processConsoleCommand(Console* console)
static void error(Console* console, const char* info) static void error(Console* console, const char* info)
{ {
consolePrint(console, info ? info : "unknown error", systemColor(tic_color_red)); consolePrint(console, info ? info : "unknown error", (tic_color_red));
commandDone(console); commandDone(console);
} }
@ -2123,7 +2118,7 @@ static void checkNewVersion(Console* console)
{ {
char msg[FILENAME_MAX] = {0}; char msg[FILENAME_MAX] = {0};
sprintf(msg, "\n A new version %i.%i.%i is available.\n", version.major, version.minor, version.patch); sprintf(msg, "\n A new version %i.%i.%i is available.\n", version.major, version.minor, version.patch);
consolePrint(console, msg, systemColor(tic_color_light_green)); consolePrint(console, msg, (tic_color_light_green));
} }
} }
} }
@ -2320,7 +2315,7 @@ static void cmdInjectCode(Console* console, const char* param, const char* name)
bool watch = strcmp(param, "-code-watch") == 0; bool watch = strcmp(param, "-code-watch") == 0;
if(watch || strcmp(param, "-code") == 0) if(watch || strcmp(param, "-code") == 0)
{ {
bool loaded = loadFileIntoBuffer(console, &embed.file.code.data, name); bool loaded = loadFileIntoBuffer(console, embed.file.code.data, name);
if(loaded) if(loaded)
{ {

View File

@ -49,12 +49,12 @@ static void drawButton(Dialog* dlg, const char* label, s32 x, s32 y, u8 color, u
if(down) if(down)
{ {
tic->api.rect(tic, rect.x, rect.y+1, rect.w, rect.h, systemColor(tic_color_white)); tic->api.rect(tic, rect.x, rect.y+1, rect.w, rect.h, (tic_color_white));
} }
else else
{ {
tic->api.rect(tic, rect.x, rect.y+1, rect.w, rect.h, systemColor(tic_color_black)); tic->api.rect(tic, rect.x, rect.y+1, rect.w, rect.h, (tic_color_black));
tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, systemColor(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);
@ -74,8 +74,8 @@ static void drawButton(Dialog* dlg, const char* label, s32 x, s32 y, u8 color, u
0b00000000, 0b00000000,
}; };
drawBitIcon(rect.x-5, rect.y+3, Icon, systemColor(tic_color_black)); drawBitIcon(rect.x-5, rect.y+3, Icon, (tic_color_black));
drawBitIcon(rect.x-5, rect.y+2, Icon, systemColor(tic_color_white)); drawBitIcon(rect.x-5, rect.y+2, Icon, (tic_color_white));
} }
} }
@ -117,7 +117,7 @@ static void processKeydown(Dialog* dlg, SDL_Keysym* keysum)
static void drawDialog(Dialog* dlg) static void drawDialog(Dialog* dlg)
{ {
enum {Width = TIC80_WIDTH/2, Height = TIC80_HEIGHT/2-TOOLBAR_SIZE-1}; enum {Width = TIC80_WIDTH/2, Height = TIC80_HEIGHT/2-TOOLBAR_SIZE};
tic_mem* tic = dlg->tic; tic_mem* tic = dlg->tic;
@ -126,7 +126,7 @@ static void drawDialog(Dialog* dlg)
rect.x -= dlg->pos.x; rect.x -= dlg->pos.x;
rect.y -= dlg->pos.y; rect.y -= dlg->pos.y;
SDL_Rect header = {rect.x, rect.y-(TOOLBAR_SIZE-2), rect.w, TOOLBAR_SIZE-1}; SDL_Rect header = {rect.x, rect.y-(TOOLBAR_SIZE-1), rect.w, TOOLBAR_SIZE};
if(checkMousePos(&header)) if(checkMousePos(&header))
{ {
@ -156,16 +156,16 @@ static void drawDialog(Dialog* dlg)
dlg->drag.active = false; dlg->drag.active = false;
} }
tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_blue)); tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, (tic_color_blue));
tic->api.rect_border(tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_white)); tic->api.rect_border(tic, rect.x, rect.y, rect.w, rect.h, (tic_color_white));
tic->api.line(tic, rect.x, rect.y+Height, rect.x+Width-1, rect.y+Height, systemColor(tic_color_black)); tic->api.line(tic, rect.x, rect.y+Height, rect.x+Width-1, rect.y+Height, (tic_color_black));
tic->api.rect(tic, rect.x, rect.y-(TOOLBAR_SIZE-3), rect.w, TOOLBAR_SIZE-3, systemColor(tic_color_white)); tic->api.rect(tic, rect.x, rect.y-(TOOLBAR_SIZE-2), rect.w, TOOLBAR_SIZE-2, (tic_color_white));
tic->api.line(tic, rect.x+1, rect.y-(TOOLBAR_SIZE-2), rect.x+Width-2, rect.y-(TOOLBAR_SIZE-2), systemColor(tic_color_white)); tic->api.line(tic, rect.x+1, rect.y-(TOOLBAR_SIZE-1), rect.x+Width-2, rect.y-(TOOLBAR_SIZE-1), (tic_color_white));
{ {
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);
tic->api.text(tic, Label, rect.x + (Width - size)/2, rect.y-(TOOLBAR_SIZE-3), systemColor(tic_color_gray)); tic->api.text(tic, Label, rect.x + (Width - size)/2, rect.y-(TOOLBAR_SIZE-2), (tic_color_gray));
} }
{ {
@ -180,13 +180,13 @@ static void drawDialog(Dialog* dlg)
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, systemColor(tic_color_black)); tic->api.text(tic, dlg->text[i], x, y+1, (tic_color_black));
tic->api.text(tic, dlg->text[i], x, y, systemColor(tic_color_white)); tic->api.text(tic, dlg->text[i], x, y, (tic_color_white));
} }
} }
drawButton(dlg, "YES", rect.x + (Width/2 - 26), rect.y + 45, systemColor(tic_color_dark_red), systemColor(tic_color_red), onYes, 0); drawButton(dlg, "YES", rect.x + (Width/2 - 26), rect.y + 45, (tic_color_dark_red), (tic_color_red), onYes, 0);
drawButton(dlg, "NO", rect.x + (Width/2 + 6), rect.y + 45, systemColor(tic_color_green), systemColor(tic_color_light_green), onNo, 1); drawButton(dlg, "NO", rect.x + (Width/2 + 6), rect.y + 45, (tic_color_green), (tic_color_light_green), onNo, 1);
} }
static void tick(Dialog* dlg) static void tick(Dialog* dlg)

View File

@ -56,7 +56,7 @@ static void drawPlayer(Keymap* keymap, s32 x, s32 y, s32 id)
{ {
char label[] = "PLAYER #%i"; char label[] = "PLAYER #%i";
sprintf(label, label, id+1); sprintf(label, label, id+1);
keymap->tic->api.text(keymap->tic, label, x, y, systemColor(tic_color_white)); keymap->tic->api.text(keymap->tic, label, x, y, (tic_color_white));
} }
@ -84,14 +84,14 @@ static void drawPlayer(Keymap* keymap, s32 x, s32 y, s32 id)
bool selected = keymap->button == button; bool selected = keymap->button == button;
if(over) if(over)
keymap->tic->api.rect(keymap->tic, rect.x-1, rect.y-1, rect.w, rect.h, systemColor(tic_color_dark_red)); keymap->tic->api.rect(keymap->tic, rect.x-1, rect.y-1, rect.w, rect.h, (tic_color_dark_red));
if(selected) if(selected)
keymap->tic->api.rect(keymap->tic, rect.x-1, rect.y-1, rect.w, rect.h, systemColor(tic_color_white)); keymap->tic->api.rect(keymap->tic, rect.x-1, rect.y-1, rect.w, rect.h, (tic_color_white));
keymap->tic->api.text(keymap->tic, ButtonNames[i], rect.x, rect.y, selected ? systemColor(tic_color_black) : systemColor(tic_color_gray)); keymap->tic->api.text(keymap->tic, ButtonNames[i], rect.x, rect.y, selected ? (tic_color_black) : (tic_color_gray));
keymap->tic->api.text(keymap->tic, SDL_GetKeyName(SDL_GetKeyFromScancode(codes[button])), rect.x + OffsetX, rect.y, selected ? systemColor(tic_color_black) : systemColor(tic_color_white)); keymap->tic->api.text(keymap->tic, SDL_GetKeyName(SDL_GetKeyFromScancode(codes[button])), rect.x + OffsetX, rect.y, selected ? (tic_color_black) : (tic_color_white));
} }
} }
@ -102,11 +102,11 @@ static void drawCenterText(Keymap* keymap, const char* text, s32 y, u8 color)
static void drawKeymap(Keymap* keymap) static void drawKeymap(Keymap* keymap)
{ {
keymap->tic->api.rect(keymap->tic, 0, 0, TIC80_WIDTH, TIC_FONT_HEIGHT * 3, systemColor(tic_color_white)); keymap->tic->api.rect(keymap->tic, 0, 0, TIC80_WIDTH, TIC_FONT_HEIGHT * 3, (tic_color_white));
{ {
static const char Label[] = "CONFIGURE BUTTONS MAPPING"; static const char Label[] = "CONFIGURE BUTTONS MAPPING";
keymap->tic->api.text(keymap->tic, Label, (TIC80_WIDTH - sizeof Label * TIC_FONT_WIDTH)/2, TIC_FONT_HEIGHT, systemColor(tic_color_black)); keymap->tic->api.text(keymap->tic, Label, (TIC80_WIDTH - sizeof Label * TIC_FONT_WIDTH)/2, TIC_FONT_HEIGHT, (tic_color_black));
} }
drawPlayer(keymap, 16, 40, 0); drawPlayer(keymap, 16, 40, 0);
@ -115,14 +115,14 @@ static void drawKeymap(Keymap* keymap)
if(keymap->button < 0) if(keymap->button < 0)
{ {
if(keymap->ticks % TIC_FRAMERATE < TIC_FRAMERATE/2) if(keymap->ticks % TIC_FRAMERATE < TIC_FRAMERATE/2)
drawCenterText(keymap, "SELECT BUTTON", 120, systemColor(tic_color_white)); drawCenterText(keymap, "SELECT BUTTON", 120, (tic_color_white));
} }
else else
{ {
char label[256]; char label[256];
sprintf(label, "PRESS A KEY FOR '%s'", ButtonNames[keymap->button % BUTTONS_COUNT]); sprintf(label, "PRESS A KEY FOR '%s'", ButtonNames[keymap->button % BUTTONS_COUNT]);
drawCenterText(keymap, label, 120, systemColor(tic_color_white)); drawCenterText(keymap, label, 120, (tic_color_white));
drawCenterText(keymap, "ESC TO CANCEL", 126, systemColor(tic_color_white)); drawCenterText(keymap, "ESC TO CANCEL", 126, (tic_color_white));
} }
} }

View File

@ -99,7 +99,7 @@ static s32 drawWorldButton(Map* map, s32 x, s32 y)
setStudioMode(TIC_WORLD_MODE); setStudioMode(TIC_WORLD_MODE);
} }
drawBitIcon(x, y, WorldIcon, over ? systemColor(tic_color_dark_gray) : systemColor(tic_color_light_blue)); drawBitIcon(x, y, WorldIcon, over ? (tic_color_dark_gray) : (tic_color_light_blue));
return x; return x;
@ -137,7 +137,7 @@ static s32 drawGridButton(Map* map, s32 x, s32 y)
map->canvas.grid = !map->canvas.grid; map->canvas.grid = !map->canvas.grid;
} }
drawBitIcon(x, y, GridIcon, map->canvas.grid ? systemColor(tic_color_black) : over ? systemColor(tic_color_dark_gray) : systemColor(tic_color_light_blue)); drawBitIcon(x, y, GridIcon, map->canvas.grid ? (tic_color_black) : over ? (tic_color_dark_gray) : (tic_color_light_blue));
return x; return x;
} }
@ -186,7 +186,7 @@ static s32 drawSheetButton(Map* map, s32 x, s32 y)
} }
} }
drawBitIcon(rect.x, rect.y, map->sheet.show ? UpIcon : DownIcon, over ? systemColor(tic_color_dark_gray) : systemColor(tic_color_light_blue)); drawBitIcon(rect.x, rect.y, map->sheet.show ? UpIcon : DownIcon, over ? (tic_color_dark_gray) : (tic_color_light_blue));
return x; return x;
} }
@ -212,7 +212,7 @@ static s32 drawToolButton(Map* map, s32 x, s32 y, const u8* Icon, s32 width, con
} }
} }
drawBitIcon(rect.x, rect.y, Icon, map->mode == mode ? systemColor(tic_color_black) : over ? systemColor(tic_color_dark_gray) : systemColor(tic_color_light_blue)); drawBitIcon(rect.x, rect.y, Icon, map->mode == mode ? (tic_color_black) : over ? (tic_color_dark_gray) : (tic_color_light_blue));
return x; return x;
} }
@ -293,7 +293,7 @@ static void drawTileIndex(Map* map, s32 x, s32 y)
if(map->sheet.show) if(map->sheet.show)
{ {
SDL_Rect rect = {TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, TOOLBAR_SIZE-1, TIC_SPRITESHEET_SIZE, TIC_SPRITESHEET_SIZE}; SDL_Rect rect = {TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, TOOLBAR_SIZE, TIC_SPRITESHEET_SIZE, TIC_SPRITESHEET_SIZE};
if(checkMousePos(&rect)) if(checkMousePos(&rect))
{ {
@ -322,13 +322,13 @@ 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, systemColor(tic_color_light_blue)); map->tic->api.text(map->tic, buf, x, y, (tic_color_light_blue));
} }
} }
static void drawMapToolbar(Map* map, s32 x, s32 y) static void drawMapToolbar(Map* map, s32 x, s32 y)
{ {
map->tic->api.rect(map->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE-1, systemColor(tic_color_white)); map->tic->api.rect(map->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, (tic_color_white));
drawTileIndex(map, TIC80_WIDTH/2 - TIC_FONT_WIDTH, y); drawTileIndex(map, TIC80_WIDTH/2 - TIC_FONT_WIDTH, y);
@ -348,7 +348,7 @@ static void drawSheet(Map* map, s32 x, s32 y)
SDL_Rect rect = {x, y, TIC_SPRITESHEET_SIZE, TIC_SPRITESHEET_SIZE}; SDL_Rect rect = {x, y, TIC_SPRITESHEET_SIZE, TIC_SPRITESHEET_SIZE};
map->tic->api.rect_border(map->tic, rect.x - 1, rect.y - 1, rect.w + 2, rect.h + 2, systemColor(tic_color_white)); map->tic->api.rect_border(map->tic, rect.x - 1, rect.y - 1, rect.w + 2, rect.h + 2, (tic_color_white));
if(checkMousePos(&rect)) if(checkMousePos(&rect))
{ {
@ -398,7 +398,7 @@ static void drawSheet(Map* map, s32 x, s32 y)
s32 bw = map->sheet.rect.w * TIC_SPRITESIZE + 2; s32 bw = map->sheet.rect.w * TIC_SPRITESIZE + 2;
s32 bh = map->sheet.rect.h * TIC_SPRITESIZE + 2; s32 bh = map->sheet.rect.h * TIC_SPRITESIZE + 2;
map->tic->api.rect_border(map->tic, bx, by, bw, bh, systemColor(tic_color_white)); map->tic->api.rect_border(map->tic, bx, by, bw, bh, (tic_color_white));
} }
} }
@ -411,7 +411,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, systemColor(tic_color_gray)); s32 width = map->tic->api.text(map->tic, pos, TIC80_WIDTH, 0, (tic_color_gray));
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);
@ -419,8 +419,8 @@ static void drawCursorPos(Map* map, s32 x, s32 y)
s32 py = y - (TIC_FONT_HEIGHT + 2); s32 py = y - (TIC_FONT_HEIGHT + 2);
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, systemColor(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, systemColor(tic_color_light_blue)); map->tic->api.text(map->tic, pos, px, py, (tic_color_light_blue));
} }
static void setMapSprite(Map* map, s32 x, s32 y) static void setMapSprite(Map* map, s32 x, s32 y)
@ -455,7 +455,7 @@ static void drawTileCursor(Map* map)
s32 height = map->sheet.rect.h * TIC_SPRITESIZE + 2; s32 height = map->sheet.rect.h * TIC_SPRITESIZE + 2;
map->tic->api.rect_border(map->tic, mx - 1, my - 1, map->tic->api.rect_border(map->tic, mx - 1, my - 1,
width, height, systemColor(tic_color_white)); width, height, (tic_color_white));
{ {
s32 sx = map->sheet.rect.x; s32 sx = map->sheet.rect.x;
@ -556,13 +556,13 @@ static void resetSelection(Map* map)
static void drawSelectionRect(Map* map, s32 x, s32 y, s32 w, s32 h) static void drawSelectionRect(Map* map, s32 x, s32 y, s32 w, s32 h)
{ {
enum{Step = 3}; enum{Step = 3};
u8 color = systemColor(tic_color_white); u8 color = (tic_color_white);
s32 index = map->tickCounter / 10; s32 index = map->tickCounter / 10;
for(s32 i = x; i < (x+w); i++) map->tic->api.pixel(map->tic, i, y, index++ % Step ? color : 0); index++; for(s32 i = x; i < (x+w); i++) {map->tic->api.pixel(map->tic, i, y, index++ % Step ? color : 0);} index++;
for(s32 i = y; i < (y+h); i++) map->tic->api.pixel(map->tic, x + w-1, i, index++ % Step ? color : 0); index++; for(s32 i = y; i < (y+h); i++) {map->tic->api.pixel(map->tic, x + w-1, i, index++ % Step ? color : 0);} index++;
for(s32 i = (x+w-1); i >= x; i--) map->tic->api.pixel(map->tic, i, y + h-1, index++ % Step ? color : 0); index++; for(s32 i = (x+w-1); i >= x; i--) {map->tic->api.pixel(map->tic, i, y + h-1, index++ % Step ? color : 0);} index++;
for(s32 i = (y+h-1); i >= y; i--) map->tic->api.pixel(map->tic, x, i, index++ % Step ? color : 0); for(s32 i = (y+h-1); i >= y; i--) {map->tic->api.pixel(map->tic, x, i, index++ % Step ? color : 0);}
} }
static void drawPasteData(Map* map) static void drawPasteData(Map* map)
@ -867,8 +867,8 @@ static void drawMap(Map* map)
s32 screenScrollX = map->scroll.x % TIC80_WIDTH; s32 screenScrollX = map->scroll.x % TIC80_WIDTH;
s32 screenScrollY = map->scroll.y % TIC80_HEIGHT; s32 screenScrollY = map->scroll.y % TIC80_HEIGHT;
map->tic->api.line(map->tic, 0, TIC80_HEIGHT - screenScrollY, TIC80_WIDTH, TIC80_HEIGHT - screenScrollY, systemColor(tic_color_gray)); map->tic->api.line(map->tic, 0, TIC80_HEIGHT - screenScrollY, TIC80_WIDTH, TIC80_HEIGHT - screenScrollY, (tic_color_gray));
map->tic->api.line(map->tic, TIC80_WIDTH - screenScrollX, 0, TIC80_WIDTH - screenScrollX, TIC80_HEIGHT, systemColor(tic_color_gray)); map->tic->api.line(map->tic, TIC80_WIDTH - screenScrollX, 0, TIC80_WIDTH - screenScrollX, TIC80_HEIGHT, (tic_color_gray));
} }
if(!map->sheet.show && checkMousePos(&rect)) if(!map->sheet.show && checkMousePos(&rect))
@ -1113,7 +1113,7 @@ static void tick(Map* map)
map->tic->api.clear(map->tic, TIC_COLOR_BG); map->tic->api.clear(map->tic, TIC_COLOR_BG);
drawMap(map); drawMap(map);
drawSheet(map, TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, TOOLBAR_SIZE-1); drawSheet(map, TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, TOOLBAR_SIZE);
drawMapToolbar(map, TIC80_WIDTH - 9*TIC_FONT_WIDTH, 1); drawMapToolbar(map, TIC80_WIDTH - 9*TIC_FONT_WIDTH, 1);
drawToolbar(map->tic, TIC_COLOR_BG, false); drawToolbar(map->tic, TIC_COLOR_BG, false);
} }
@ -1131,6 +1131,11 @@ static void onStudioEvent(Map* map, StudioEvent event)
} }
} }
static void scanline(tic_mem* tic, s32 row)
{
memcpy(tic->ram.vram.palette.data, row < TOOLBAR_SIZE ? tic->config.palette.data : tic->cart.palette.data, sizeof(tic_palette));
}
void initMap(Map* map, tic_mem* tic) void initMap(Map* map, tic_mem* tic)
{ {
if(map->history) history_delete(map->history); if(map->history) history_delete(map->history);
@ -1171,6 +1176,7 @@ void initMap(Map* map, tic_mem* tic)
}, },
.history = history_create(&tic->cart.gfx.map, sizeof tic->cart.gfx.map), .history = history_create(&tic->cart.gfx.map, sizeof tic->cart.gfx.map),
.event = onStudioEvent, .event = onStudioEvent,
.scanline = scanline,
}; };
normalizeMap(&map->scroll.x, &map->scroll.y); normalizeMap(&map->scroll.x, &map->scroll.y);

View File

@ -80,6 +80,7 @@ struct Map
void(*tick)(Map*); void(*tick)(Map*);
void(*event)(Map*, StudioEvent); void(*event)(Map*, StudioEvent);
void(*scanline)(tic_mem* tic, s32 row);
}; };
void initMap(Map*, tic_mem*); void initMap(Map*, tic_mem*);

View File

@ -24,7 +24,7 @@
#include "fs.h" #include "fs.h"
#define DIALOG_WIDTH (TIC80_WIDTH/2) #define DIALOG_WIDTH (TIC80_WIDTH/2)
#define DIALOG_HEIGHT (TIC80_HEIGHT/2-TOOLBAR_SIZE-1) #define DIALOG_HEIGHT (TIC80_HEIGHT/2-TOOLBAR_SIZE)
static const char* Rows[] = static const char* Rows[] =
{ {
@ -78,7 +78,7 @@ static void drawDialog(Menu* menu)
tic_mem* tic = menu->tic; tic_mem* tic = menu->tic;
SDL_Rect header = {rect.x, rect.y-(TOOLBAR_SIZE-2), rect.w, TOOLBAR_SIZE-1}; SDL_Rect header = {rect.x, rect.y-(TOOLBAR_SIZE-1), rect.w, TOOLBAR_SIZE};
if(checkMousePos(&header)) if(checkMousePos(&header))
{ {
@ -110,16 +110,16 @@ static void drawDialog(Menu* menu)
rect = getRect(menu); rect = getRect(menu);
tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_blue)); tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, (tic_color_blue));
tic->api.rect_border(tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_white)); tic->api.rect_border(tic, rect.x, rect.y, rect.w, rect.h, (tic_color_white));
tic->api.line(tic, rect.x, rect.y+DIALOG_HEIGHT, rect.x+DIALOG_WIDTH-1, rect.y+DIALOG_HEIGHT, systemColor(tic_color_black)); tic->api.line(tic, rect.x, rect.y+DIALOG_HEIGHT, rect.x+DIALOG_WIDTH-1, rect.y+DIALOG_HEIGHT, (tic_color_black));
tic->api.rect(tic, rect.x, rect.y-(TOOLBAR_SIZE-3), rect.w, TOOLBAR_SIZE-3, systemColor(tic_color_white)); tic->api.rect(tic, rect.x, rect.y-(TOOLBAR_SIZE-2), rect.w, TOOLBAR_SIZE-2, (tic_color_white));
tic->api.line(tic, rect.x+1, rect.y-(TOOLBAR_SIZE-2), rect.x+DIALOG_WIDTH-2, rect.y-(TOOLBAR_SIZE-2), systemColor(tic_color_white)); tic->api.line(tic, rect.x+1, rect.y-(TOOLBAR_SIZE-1), rect.x+DIALOG_WIDTH-2, rect.y-(TOOLBAR_SIZE-1), (tic_color_white));
{ {
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);
tic->api.text(tic, Label, rect.x + (DIALOG_WIDTH - size)/2, rect.y-(TOOLBAR_SIZE-3), systemColor(tic_color_gray)); tic->api.text(tic, Label, rect.x + (DIALOG_WIDTH - size)/2, rect.y-(TOOLBAR_SIZE-2), (tic_color_gray));
} }
{ {
@ -149,14 +149,14 @@ static void drawTabDisabled(Menu* menu, s32 x, s32 y, s32 id)
} }
} }
tic->api.rect(tic, x, y-1, Width, Height+1, systemColor(tic_color_dark_gray)); tic->api.rect(tic, x, y-1, Width, Height+1, (tic_color_dark_gray));
tic->api.pixel(tic, x, y+Height-1, systemColor(tic_color_blue)); tic->api.pixel(tic, x, y+Height-1, (tic_color_blue));
tic->api.pixel(tic, x+Width-1, y+Height-1, systemColor(tic_color_blue)); tic->api.pixel(tic, x+Width-1, y+Height-1, (tic_color_blue));
{ {
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, systemColor(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));
} }
} }
@ -165,15 +165,15 @@ static void drawTab(Menu* menu, s32 x, s32 y, s32 id)
enum{Width = 15, Height = 7}; enum{Width = 15, Height = 7};
tic_mem* tic = menu->tic; tic_mem* tic = menu->tic;
tic->api.rect(tic, x, y-2, Width, Height+2, systemColor(tic_color_white)); tic->api.rect(tic, x, y-2, Width, Height+2, (tic_color_white));
tic->api.pixel(tic, x, y+Height-1, systemColor(tic_color_black)); tic->api.pixel(tic, x, y+Height-1, (tic_color_black));
tic->api.pixel(tic, x+Width-1, y+Height-1, systemColor(tic_color_black)); tic->api.pixel(tic, x+Width-1, y+Height-1, (tic_color_black));
tic->api.rect(tic, x+1, y+Height, Width-2 , 1, systemColor(tic_color_black)); tic->api.rect(tic, x+1, y+Height, Width-2 , 1, (tic_color_black));
{ {
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, systemColor(tic_color_gray)); tic->api.fixed_text(tic, buf, x+2, y, (tic_color_gray));
} }
} }
@ -218,7 +218,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, systemColor(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));
} }
} }
@ -228,12 +228,12 @@ static void drawGamepadSetupTabs(Menu* menu, s32 x, s32 y)
tic_mem* tic = menu->tic; tic_mem* tic = menu->tic;
tic->api.rect(tic, x, y, Width, Height, systemColor(tic_color_white)); tic->api.rect(tic, x, y, Width, Height, (tic_color_white));
tic->api.pixel(tic, x, y, systemColor(tic_color_blue)); tic->api.pixel(tic, x, y, (tic_color_blue));
tic->api.pixel(tic, x+Width-1, y, systemColor(tic_color_blue)); tic->api.pixel(tic, x+Width-1, y, (tic_color_blue));
tic->api.pixel(tic, x, y+Height-1, systemColor(tic_color_black)); tic->api.pixel(tic, x, y+Height-1, (tic_color_black));
tic->api.pixel(tic, x+Width-1, y+Height-1, systemColor(tic_color_black)); tic->api.pixel(tic, x+Width-1, y+Height-1, (tic_color_black));
tic->api.rect(tic, x+1, y+Height, Width-2 , 1, systemColor(tic_color_black)); tic->api.rect(tic, x+1, y+Height, Width-2 , 1, (tic_color_black));
for(s32 i = 0; i < Tabs; i++) for(s32 i = 0; i < Tabs; i++)
{ {
@ -283,12 +283,12 @@ static void drawGamepadMenu(Menu* menu)
if(down) if(down)
{ {
tic->api.text(tic, Label, rect.x, rect.y+1, systemColor(tic_color_light_blue)); tic->api.text(tic, Label, rect.x, rect.y+1, (tic_color_light_blue));
} }
else else
{ {
tic->api.text(tic, Label, rect.x, rect.y+1, systemColor(tic_color_black)); tic->api.text(tic, Label, rect.x, rect.y+1, (tic_color_black));
tic->api.text(tic, Label, rect.x, rect.y, systemColor(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));
} }
{ {
@ -304,8 +304,8 @@ static void drawGamepadMenu(Menu* menu)
0b00000000, 0b00000000,
}; };
drawBitIcon(rect.x-7, rect.y+1, Icon, systemColor(tic_color_black)); drawBitIcon(rect.x-7, rect.y+1, Icon, (tic_color_black));
drawBitIcon(rect.x-7, rect.y, Icon, systemColor(tic_color_white)); drawBitIcon(rect.x-7, rect.y, Icon, (tic_color_white));
} }
drawGamepadSetupTabs(menu, dlgRect.x+25, dlgRect.y+4); drawGamepadSetupTabs(menu, dlgRect.x+25, dlgRect.y+4);
@ -349,12 +349,12 @@ static void drawMainMenu(Menu* menu)
if(down) if(down)
{ {
tic->api.text(tic, Rows[i], label.x, label.y+1, systemColor(tic_color_light_blue)); tic->api.text(tic, Rows[i], label.x, label.y+1, (tic_color_light_blue));
} }
else else
{ {
tic->api.text(tic, Rows[i], label.x, label.y+1, systemColor(tic_color_black)); tic->api.text(tic, Rows[i], label.x, label.y+1, (tic_color_black));
tic->api.text(tic, Rows[i], label.x, label.y, systemColor(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));
} }
if(i == menu->main.focus) if(i == menu->main.focus)
@ -371,8 +371,8 @@ static void drawMainMenu(Menu* menu)
0b00000000, 0b00000000,
}; };
drawBitIcon(label.x-7, label.y+1, Icon, systemColor(tic_color_black)); drawBitIcon(label.x-7, label.y+1, Icon, (tic_color_black));
drawBitIcon(label.x-7, label.y, Icon, systemColor(tic_color_white)); drawBitIcon(label.x-7, label.y, Icon, (tic_color_white));
} }
} }
} }

View File

@ -93,7 +93,7 @@ static void drawEditbox(Music* music, s32 x, s32 y, s32 value, void(*set)(Music*
set(music, -1, channel); set(music, -1, channel);
} }
drawBitIcon(rect.x, rect.y, LeftArrow, systemColor(over ? tic_color_light_blue : tic_color_dark_gray)); drawBitIcon(rect.x, rect.y, LeftArrow, (over ? tic_color_light_blue : tic_color_dark_gray));
} }
{ {
@ -115,16 +115,16 @@ static void drawEditbox(Music* music, s32 x, s32 y, s32 value, void(*set)(Music*
} }
} }
music->tic->api.rect(music->tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_black)); music->tic->api.rect(music->tic, rect.x, rect.y, rect.w, rect.h, (tic_color_black));
if(music->tracker.row == -1 && music->tracker.col / CHANNEL_COLS == channel) if(music->tracker.row == -1 && music->tracker.col / CHANNEL_COLS == channel)
{ {
music->tic->api.rect(music->tic, x - 1 + music->tracker.patternCol * TIC_FONT_WIDTH, y - 1, TIC_FONT_WIDTH + 1, TIC_FONT_HEIGHT + 1, systemColor(tic_color_red)); music->tic->api.rect(music->tic, x - 1 + music->tracker.patternCol * TIC_FONT_WIDTH, y - 1, TIC_FONT_WIDTH + 1, TIC_FONT_HEIGHT + 1, (tic_color_red));
} }
char val[] = "99"; char val[] = "99";
sprintf(val, "%02i", value); sprintf(val, "%02i", value);
music->tic->api.fixed_text(music->tic, val, x, y, systemColor(tic_color_white)); music->tic->api.fixed_text(music->tic, val, x, y, (tic_color_white));
} }
{ {
@ -142,7 +142,7 @@ static void drawEditbox(Music* music, s32 x, s32 y, s32 value, void(*set)(Music*
set(music, +1, channel); set(music, +1, channel);
} }
drawBitIcon(rect.x, rect.y, RightArrow, systemColor(over ? tic_color_light_blue : tic_color_dark_gray)); drawBitIcon(rect.x, rect.y, RightArrow, (over ? tic_color_light_blue : tic_color_dark_gray));
} }
} }
@ -172,7 +172,7 @@ 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, systemColor(tic_color_white)); music->tic->api.text(music->tic, label, x, y, (tic_color_white));
{ {
x += (s32)strlen(label)*TIC_FONT_WIDTH; x += (s32)strlen(label)*TIC_FONT_WIDTH;
@ -187,13 +187,13 @@ static void drawSwitch(Music* music, s32 x, s32 y, const char* label, s32 value,
set(music, -1, data); set(music, -1, data);
} }
drawBitIcon(rect.x, rect.y, LeftArrow, systemColor(tic_color_dark_gray)); drawBitIcon(rect.x, rect.y, LeftArrow, (tic_color_dark_gray));
} }
{ {
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, systemColor(tic_color_white)); music->tic->api.fixed_text(music->tic, val, x += TIC_FONT_WIDTH, y, (tic_color_white));
} }
{ {
@ -209,7 +209,7 @@ static void drawSwitch(Music* music, s32 x, s32 y, const char* label, s32 value,
set(music, +1, data); set(music, +1, data);
} }
drawBitIcon(rect.x, rect.y, RightArrow, systemColor(tic_color_dark_gray)); drawBitIcon(rect.x, rect.y, RightArrow, (tic_color_dark_gray));
} }
} }
@ -1112,7 +1112,7 @@ static void drawTrackerFrames(Music* music, s32 x, s32 y)
} }
} }
music->tic->api.rect(music->tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_black)); music->tic->api.rect(music->tic, rect.x, rect.y, rect.w, rect.h, (tic_color_black));
} }
for (s32 i = 0; i < MUSIC_FRAMES; i++) for (s32 i = 0; i < MUSIC_FRAMES; i++)
@ -1131,24 +1131,24 @@ static void drawTrackerFrames(Music* music, s32 x, s32 y)
0b00000000, 0b00000000,
}; };
drawBitIcon(x - TIC_FONT_WIDTH, y - 1 + i*TIC_FONT_HEIGHT, Icon, systemColor(tic_color_white)); drawBitIcon(x - TIC_FONT_WIDTH, y - 1 + i*TIC_FONT_HEIGHT, Icon, (tic_color_white));
} }
if (i == music->tracker.frame) if (i == music->tracker.frame)
{ {
music->tic->api.rect(music->tic, x - 1, y - 1 + i*TIC_FONT_HEIGHT, Width, TIC_FONT_HEIGHT + 1, systemColor(tic_color_white)); music->tic->api.rect(music->tic, x - 1, y - 1 + i*TIC_FONT_HEIGHT, Width, TIC_FONT_HEIGHT + 1, (tic_color_white));
} }
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, systemColor(tic_color_dark_gray)); music->tic->api.fixed_text(music->tic, buf, x, y + i*TIC_FONT_HEIGHT, (tic_color_dark_gray));
} }
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 - 9, systemColor(tic_color_white)); music->tic->api.fixed_text(music->tic, buf, x, y - 9, (tic_color_white));
} }
} }
@ -1215,7 +1215,7 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
} }
} }
music->tic->api.rect(music->tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_black)); music->tic->api.rect(music->tic, rect.x, rect.y, rect.w, rect.h, (tic_color_black));
s32 start = music->tracker.scroll; s32 start = music->tracker.scroll;
s32 end = start + Rows; s32 end = start + Rows;
@ -1229,7 +1229,7 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
if (i == music->tracker.row) if (i == music->tracker.row)
{ {
music->tic->api.rect(music->tic, x - 1, rowy - 1, Width, TIC_FONT_HEIGHT + 1, systemColor(tic_color_dark_red)); music->tic->api.rect(music->tic, x - 1, rowy - 1, Width, TIC_FONT_HEIGHT + 1, (tic_color_dark_red));
} }
// draw selection // draw selection
@ -1239,13 +1239,13 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
if (rect.h > 1 && i >= rect.y && i < rect.y + rect.h) if (rect.h > 1 && i >= rect.y && i < rect.y + rect.h)
{ {
s32 sx = x - 1; s32 sx = x - 1;
tic->api.rect(tic, sx, rowy - 1, CHANNEL_COLS * TIC_FONT_WIDTH + 1, TIC_FONT_HEIGHT + 1, systemColor(tic_color_yellow)); tic->api.rect(tic, sx, rowy - 1, CHANNEL_COLS * TIC_FONT_WIDTH + 1, TIC_FONT_HEIGHT + 1, (tic_color_yellow));
} }
} }
if (checkPlayRow(music, i)) if (checkPlayRow(music, i))
{ {
music->tic->api.rect(music->tic, x - 1, rowy - 1, Width, TIC_FONT_HEIGHT + 1, systemColor(tic_color_white)); music->tic->api.rect(music->tic, x - 1, rowy - 1, Width, TIC_FONT_HEIGHT + 1, (tic_color_white));
} }
char rowStr[] = "--------"; char rowStr[] = "--------";
@ -1268,8 +1268,8 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
if (note >= NoteStart) if (note >= NoteStart)
sprintf(rowStr, "%s%i%02i%01X--", Notes[note - NoteStart], octave + 1, sfx, volume & 0xf); sprintf(rowStr, "%s%i%02i%01X--", Notes[note - NoteStart], octave + 1, sfx, volume & 0xf);
const u8 Colors[] = { systemColor(tic_color_light_green), systemColor(tic_color_orange), systemColor(tic_color_blue), systemColor(tic_color_gray) }; const u8 Colors[] = { (tic_color_light_green), (tic_color_orange), (tic_color_blue), (tic_color_gray) };
const u8 DarkColors[] = { systemColor(tic_color_green), systemColor(tic_color_brown), systemColor(tic_color_dark_blue), systemColor(tic_color_dark_gray) }; const u8 DarkColors[] = { (tic_color_green), (tic_color_brown), (tic_color_dark_blue), (tic_color_dark_gray) };
static u8 ColorIndexes[] = { 0, 0, 0, 1, 1, 2, 3, 3 }; static u8 ColorIndexes[] = { 0, 0, 0, 1, 1, 2, 3, 3 };
bool beetRow = i % NOTES_PER_BEET == 0; bool beetRow = i % NOTES_PER_BEET == 0;
@ -1283,7 +1283,7 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
} }
} }
} }
else music->tic->api.fixed_text(music->tic, rowStr, x, rowy, systemColor(tic_color_dark_gray)); else music->tic->api.fixed_text(music->tic, rowStr, x, rowy, (tic_color_dark_gray));
if (i == music->tracker.row) if (i == music->tracker.row)
{ {
@ -1291,13 +1291,13 @@ 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, systemColor(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, systemColor(tic_color_black)); music->tic->api.draw_char(music->tic, rowStr[col], colx + 1, rowy, (tic_color_black));
} }
} }
if (i % NOTES_PER_BEET == 0) if (i % NOTES_PER_BEET == 0)
music->tic->api.pixel(music->tic, x - 4, y + pos*TIC_FONT_HEIGHT + 2, systemColor(tic_color_dark_gray)); music->tic->api.pixel(music->tic, x - 4, y + pos*TIC_FONT_HEIGHT + 2, (tic_color_dark_gray));
} }
} }
@ -1418,9 +1418,9 @@ static void drawPlayButtons(Music* music)
} }
if(i == 0 && music->tracker.follow) if(i == 0 && music->tracker.follow)
drawBitIcon(rect.x, rect.y, Icons + i*Rows, over ? systemColor(tic_color_peach) : systemColor(tic_color_red)); drawBitIcon(rect.x, rect.y, Icons + i*Rows, over ? (tic_color_peach) : (tic_color_red));
else else
drawBitIcon(rect.x, rect.y, Icons + i*Rows, over ? systemColor(tic_color_dark_gray) : systemColor(tic_color_light_blue)); drawBitIcon(rect.x, rect.y, Icons + i*Rows, over ? (tic_color_dark_gray) : (tic_color_light_blue));
} }
} }
@ -1470,15 +1470,15 @@ static void drawModeTabs(Music* music)
} }
if (music->tab == Tabs[i]) if (music->tab == Tabs[i])
music->tic->api.rect(music->tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_gray)); music->tic->api.rect(music->tic, rect.x, rect.y, rect.w, rect.h, (tic_color_gray));
drawBitIcon(rect.x, rect.y, Icons + i*Rows, music->tab == Tabs[i] ? systemColor(tic_color_white) : over ? systemColor(tic_color_dark_gray) : systemColor(tic_color_light_blue)); drawBitIcon(rect.x, rect.y, Icons + i*Rows, music->tab == Tabs[i] ? (tic_color_white) : over ? (tic_color_dark_gray) : (tic_color_light_blue));
} }
} }
static void drawMusicToolbar(Music* music) static void drawMusicToolbar(Music* music)
{ {
music->tic->api.rect(music->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE - 1, systemColor(tic_color_white)); music->tic->api.rect(music->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, (tic_color_white));
drawPlayButtons(music); drawPlayButtons(music);
drawModeTabs(music); drawModeTabs(music);
@ -1489,10 +1489,10 @@ static void drawPianoLayout(Music* music)
SDL_Event* event = NULL; SDL_Event* event = NULL;
while ((event = pollEvent())){} while ((event = pollEvent())){}
music->tic->api.clear(music->tic, systemColor(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, systemColor(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));
} }
static void scrollNotes(Music* music, s32 delta) static void scrollNotes(Music* music, s32 delta)
@ -1571,9 +1571,9 @@ static void drawTrackerLayout(Music* music)
} }
} }
music->tic->api.clear(music->tic, systemColor(tic_color_gray)); music->tic->api.clear(music->tic, (tic_color_gray));
drawTopPanel(music, 6, TOOLBAR_SIZE + 4); drawTopPanel(music, 6, TOOLBAR_SIZE + 3);
drawTracker(music, 6, 35); drawTracker(music, 6, 35);
} }
@ -1592,7 +1592,7 @@ static void tick(Music* music)
} }
drawMusicToolbar(music); drawMusicToolbar(music);
drawToolbar(music->tic, systemColor(tic_color_gray), false); drawToolbar(music->tic, (tic_color_gray), false);
} }
static void onStudioEvent(Music* music, StudioEvent event) static void onStudioEvent(Music* music, StudioEvent event)

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, systemColor(tic_color_white)); sfx->tic->api.text(sfx->tic, label, x, y, (tic_color_white));
{ {
x += (s32)strlen(label)*TIC_FONT_WIDTH; x += (s32)strlen(label)*TIC_FONT_WIDTH;
@ -78,13 +78,13 @@ static void drawSwitch(Sfx* sfx, s32 x, s32 y, const char* label, s32 value, voi
set(sfx, -1); set(sfx, -1);
} }
drawBitIcon(rect.x, rect.y, LeftArrow, systemColor(tic_color_dark_gray)); drawBitIcon(rect.x, rect.y, LeftArrow, (tic_color_dark_gray));
} }
{ {
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, systemColor(tic_color_white)); sfx->tic->api.fixed_text(sfx->tic, val, x += TIC_FONT_WIDTH, y, (tic_color_white));
} }
{ {
@ -100,7 +100,7 @@ static void drawSwitch(Sfx* sfx, s32 x, s32 y, const char* label, s32 value, voi
set(sfx, +1); set(sfx, +1);
} }
drawBitIcon(rect.x, rect.y, RightArrow, systemColor(tic_color_dark_gray)); drawBitIcon(rect.x, rect.y, RightArrow, (tic_color_dark_gray));
} }
} }
@ -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, systemColor(tic_color_dark_gray)); sfx->tic->api.text(sfx->tic, "LOOP:", x, y, (tic_color_dark_gray));
enum {Gap = 2}; enum {Gap = 2};
@ -234,7 +234,7 @@ static void drawWaveButtons(Sfx* sfx, s32 x, s32 y)
} }
sfx->tic->api.rect(sfx->tic, rect.x, rect.y, rect.w, rect.h, sfx->tic->api.rect(sfx->tic, rect.x, rect.y, rect.w, rect.h,
active ? systemColor(tic_color_red) : over ? systemColor(tic_color_gray) : systemColor(tic_color_dark_gray)); active ? (tic_color_red) : over ? (tic_color_gray) : (tic_color_dark_gray));
{ {
enum{Size = 5}; enum{Size = 5};
@ -254,7 +254,7 @@ static void drawWaveButtons(Sfx* sfx, s32 x, s32 y)
} }
} }
drawBitIcon(iconRect.x, iconRect.y, EmptyIcon, systemColor(over ? tic_color_gray : tic_color_dark_gray)); drawBitIcon(iconRect.x, iconRect.y, EmptyIcon, (over ? tic_color_gray : tic_color_dark_gray));
} }
{ {
@ -263,7 +263,7 @@ static void drawWaveButtons(Sfx* sfx, s32 x, s32 y)
for(s32 i = 0; i < ENVELOPE_VALUES/Scale; i++) for(s32 i = 0; i < ENVELOPE_VALUES/Scale; i++)
{ {
s32 value = tic_tool_peek4(wave->data, i*Scale)/Scale; s32 value = tic_tool_peek4(wave->data, i*Scale)/Scale;
sfx->tic->api.pixel(sfx->tic, rect.x + i+1, rect.y + Height - value - 2, systemColor(tic_color_white)); sfx->tic->api.pixel(sfx->tic, rect.x + i+1, rect.y + Height - value - 2, (tic_color_white));
} }
} }
} }
@ -281,7 +281,7 @@ static void drawWaveButtons(Sfx* sfx, s32 x, s32 y)
} }
if(full) if(full)
drawBitIcon(x+Width+HGap, y + (Count - start - 1)*(Height+Gap), FullIcon, systemColor(tic_color_white)); drawBitIcon(x+Width+HGap, y + (Count - start - 1)*(Height+Gap), FullIcon, (tic_color_white));
} }
} }
@ -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, systemColor(tic_color_black)); s32 size = sfx->tic->api.text(sfx->tic, Labels[i], 0, -TIC_FONT_HEIGHT, (tic_color_black));
SDL_Rect rect = {x - size, sy, size, TIC_FONT_HEIGHT}; SDL_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 ? systemColor(tic_color_white) : systemColor(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));
} }
tic_sound_effect* effect = getEffect(sfx); tic_sound_effect* 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, systemColor(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));
} }
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, systemColor(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));
} }
break; break;
default: break; default: break;
@ -354,7 +354,7 @@ static void drawCanvasTabs(Sfx* sfx, s32 x, s32 y)
static void drawCanvas(Sfx* sfx, s32 x, s32 y) static void drawCanvas(Sfx* sfx, s32 x, s32 y)
{ {
sfx->tic->api.rect(sfx->tic, x, y, CANVAS_WIDTH, CANVAS_HEIGHT, systemColor(tic_color_dark_red)); sfx->tic->api.rect(sfx->tic, x, y, CANVAS_WIDTH, CANVAS_HEIGHT, (tic_color_dark_red));
for(s32 i = 0; i < CANVAS_HEIGHT; i += CANVAS_SIZE) for(s32 i = 0; i < CANVAS_HEIGHT; i += CANVAS_SIZE)
sfx->tic->api.line(sfx->tic, x, y + i, x + CANVAS_WIDTH, y + i, TIC_COLOR_BG); sfx->tic->api.line(sfx->tic, x, y + i, x + CANVAS_WIDTH, y + i, TIC_COLOR_BG);
@ -367,7 +367,7 @@ static void drawCanvas(Sfx* sfx, s32 x, s32 y)
s32 tickIndex = *(pos.data + sfx->canvasTab); s32 tickIndex = *(pos.data + sfx->canvasTab);
if(tickIndex >= 0) if(tickIndex >= 0)
sfx->tic->api.rect(sfx->tic, x + tickIndex * CANVAS_SIZE, y, CANVAS_SIZE + 1, CANVAS_HEIGHT + 1, systemColor(tic_color_white)); sfx->tic->api.rect(sfx->tic, x + tickIndex * CANVAS_SIZE, y, CANVAS_SIZE + 1, CANVAS_HEIGHT + 1, (tic_color_white));
} }
SDL_Rect rect = {x, y, CANVAS_WIDTH, CANVAS_HEIGHT}; SDL_Rect rect = {x, y, CANVAS_WIDTH, CANVAS_HEIGHT};
@ -409,26 +409,26 @@ static void drawCanvas(Sfx* sfx, s32 x, s32 y)
case SFX_VOLUME_TAB: case SFX_VOLUME_TAB:
{ {
for(s32 j = 1, start = CANVAS_HEIGHT - CANVAS_SIZE; j <= CANVAS_ROWS - effect->data[i].volume; j++, start -= CANVAS_SIZE) for(s32 j = 1, start = CANVAS_HEIGHT - CANVAS_SIZE; j <= CANVAS_ROWS - effect->data[i].volume; j++, start -= CANVAS_SIZE)
sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1, y + 1 + start, CANVAS_SIZE-1, CANVAS_SIZE-1, systemColor(tic_color_red)); sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1, y + 1 + start, CANVAS_SIZE-1, CANVAS_SIZE-1, (tic_color_red));
} }
break; break;
case SFX_ARPEGGIO_TAB: case SFX_ARPEGGIO_TAB:
{ {
sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1, sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1,
y + 1 + (CANVAS_HEIGHT - (effect->data[i].arpeggio+1)*CANVAS_SIZE), CANVAS_SIZE-1, CANVAS_SIZE-1, systemColor(tic_color_red)); y + 1 + (CANVAS_HEIGHT - (effect->data[i].arpeggio+1)*CANVAS_SIZE), CANVAS_SIZE-1, CANVAS_SIZE-1, (tic_color_red));
} }
break; break;
case SFX_PITCH_TAB: case SFX_PITCH_TAB:
{ {
for(s32 j = SDL_min(0, effect->data[i].pitch); j <= SDL_max(0, effect->data[i].pitch); j++) for(s32 j = SDL_min(0, effect->data[i].pitch); j <= SDL_max(0, effect->data[i].pitch); j++)
sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1, y + 1 + (CANVAS_HEIGHT/2 - (j+1)*CANVAS_SIZE), sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1, y + 1 + (CANVAS_HEIGHT/2 - (j+1)*CANVAS_SIZE),
CANVAS_SIZE-1, CANVAS_SIZE-1, systemColor(tic_color_red)); CANVAS_SIZE-1, CANVAS_SIZE-1, (tic_color_red));
} }
break; break;
case SFX_WAVE_TAB: case SFX_WAVE_TAB:
{ {
sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1, sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1,
y + 1 + (CANVAS_HEIGHT - (effect->data[i].wave+1)*CANVAS_SIZE), CANVAS_SIZE-1, CANVAS_SIZE-1, systemColor(tic_color_red)); y + 1 + (CANVAS_HEIGHT - (effect->data[i].wave+1)*CANVAS_SIZE), CANVAS_SIZE-1, CANVAS_SIZE-1, (tic_color_red));
} }
break; break;
default: break; default: break;
@ -440,7 +440,7 @@ static void drawCanvas(Sfx* sfx, s32 x, s32 y)
if(loop->start > 0 || loop->size > 0) if(loop->start > 0 || loop->size > 0)
{ {
for(s32 i = 0; i < loop->size; i++) for(s32 i = 0; i < loop->size; i++)
sfx->tic->api.rect(sfx->tic, x + (loop->start+i) * CANVAS_SIZE+1, y + CANVAS_HEIGHT - 2, CANVAS_SIZE-1, 2, systemColor(tic_color_yellow)); sfx->tic->api.rect(sfx->tic, x + (loop->start+i) * CANVAS_SIZE+1, y + CANVAS_HEIGHT - 2, CANVAS_SIZE-1, 2, (tic_color_yellow));
} }
} }
} }
@ -508,7 +508,7 @@ static void drawPiano(Sfx* sfx, s32 x, s32 y)
if(index >= 0) if(index >= 0)
sfx->tic->api.rect(sfx->tic, rect->x, rect->y, rect->w - (white ? 1 : 0), rect->h, sfx->tic->api.rect(sfx->tic, rect->x, rect->y, rect->w - (white ? 1 : 0), rect->h,
systemColor(sfx->play.active && effect->note == index ? tic_color_red : white ? tic_color_white : tic_color_black)); (sfx->play.active && effect->note == index ? tic_color_red : white ? tic_color_white : tic_color_black));
} }
} }
@ -517,7 +517,7 @@ static void drawOctavePanel(Sfx* sfx, s32 x, s32 y)
tic_sound_effect* effect = getEffect(sfx); tic_sound_effect* effect = getEffect(sfx);
static const char Label[] = "OCT"; static const char Label[] = "OCT";
sfx->tic->api.text(sfx->tic, Label, x, y, systemColor(tic_color_white)); sfx->tic->api.text(sfx->tic, Label, x, y, (tic_color_white));
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, systemColor(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));
} }
} }
@ -788,15 +788,15 @@ static void drawModeTabs(Sfx* sfx)
} }
if (sfx->tab == Tabs[i]) if (sfx->tab == Tabs[i])
sfx->tic->api.rect(sfx->tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_black)); sfx->tic->api.rect(sfx->tic, rect.x, rect.y, rect.w, rect.h, (tic_color_black));
drawBitIcon(rect.x, rect.y, Icons + i*Rows, systemColor(sfx->tab == Tabs[i] ? tic_color_white : over ? tic_color_dark_gray : tic_color_light_blue)); drawBitIcon(rect.x, rect.y, Icons + i*Rows, (sfx->tab == Tabs[i] ? tic_color_white : over ? tic_color_dark_gray : tic_color_light_blue));
} }
} }
static void drawSfxToolbar(Sfx* sfx) static void drawSfxToolbar(Sfx* sfx)
{ {
sfx->tic->api.rect(sfx->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE-1, systemColor(tic_color_white)); sfx->tic->api.rect(sfx->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, (tic_color_white));
enum{Width = 3 * TIC_FONT_WIDTH}; enum{Width = 3 * TIC_FONT_WIDTH};
s32 x = TIC80_WIDTH - Width - TIC_SPRITESIZE*3; s32 x = TIC80_WIDTH - Width - TIC_SPRITESIZE*3;
@ -825,7 +825,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, systemColor(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));
} }
drawModeTabs(sfx); drawModeTabs(sfx);
@ -854,13 +854,13 @@ static void envelopesTick(Sfx* sfx)
drawSfxToolbar(sfx); drawSfxToolbar(sfx);
drawToolbar(sfx->tic, TIC_COLOR_BG, false); drawToolbar(sfx->tic, TIC_COLOR_BG, false);
drawTopPanel(sfx, Start, TOOLBAR_SIZE + Gap - 1); drawTopPanel(sfx, Start, TOOLBAR_SIZE + Gap);
drawCanvasTabs(sfx, Start-Gap, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT+1); drawCanvasTabs(sfx, Start-Gap, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT+2);
if(sfx->canvasTab == SFX_WAVE_TAB) if(sfx->canvasTab == SFX_WAVE_TAB)
drawWaveButtons(sfx, Start + CANVAS_WIDTH + Gap-1, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT+1); drawWaveButtons(sfx, Start + CANVAS_WIDTH + Gap-1, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT+2);
drawLoopPanel(sfx, Gap, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT+91); drawLoopPanel(sfx, Gap, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT+92);
drawCanvas(sfx, Start-1, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT); drawCanvas(sfx, Start-1, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT + 1);
drawOctavePanel(sfx, Start + Gap + PIANO_WIDTH + Gap-1, TIC80_HEIGHT - TIC_FONT_HEIGHT - (PIANO_HEIGHT - TIC_FONT_HEIGHT)/2 - Gap); drawOctavePanel(sfx, Start + Gap + PIANO_WIDTH + Gap-1, TIC80_HEIGHT - TIC_FONT_HEIGHT - (PIANO_HEIGHT - TIC_FONT_HEIGHT)/2 - Gap);
} }
@ -898,10 +898,10 @@ static void drawWaveformBar(Sfx* sfx, s32 x, s32 y)
active = true; active = true;
} }
sfx->tic->api.rect(sfx->tic, rect.x, rect.y, rect.w, rect.h, systemColor(active ? tic_color_red : tic_color_white)); sfx->tic->api.rect(sfx->tic, rect.x, rect.y, rect.w, rect.h, (active ? tic_color_red : tic_color_white));
if(sfx->waveform.index == i) if(sfx->waveform.index == i)
sfx->tic->api.rect_border(sfx->tic, rect.x-2, rect.y-2, rect.w+4, rect.h+4, systemColor(tic_color_white)); sfx->tic->api.rect_border(sfx->tic, rect.x-2, rect.y-2, rect.w+4, rect.h+4, (tic_color_white));
{ {
tic_waveform* wave = getWaveformById(sfx, i); tic_waveform* wave = getWaveformById(sfx, i);
@ -909,7 +909,7 @@ static void drawWaveformBar(Sfx* sfx, s32 x, s32 y)
for(s32 i = 0; i < ENVELOPE_VALUES/Scale; i++) for(s32 i = 0; i < ENVELOPE_VALUES/Scale; i++)
{ {
s32 value = tic_tool_peek4(wave->data, i*Scale)/Scale; s32 value = tic_tool_peek4(wave->data, i*Scale)/Scale;
sfx->tic->api.pixel(sfx->tic, rect.x + i+1, rect.y + Height - value - 2, systemColor(tic_color_black)); sfx->tic->api.pixel(sfx->tic, rect.x + i+1, rect.y + Height - value - 2, (tic_color_black));
} }
} }
} }
@ -921,7 +921,7 @@ static void drawWaveformCanvas(Sfx* sfx, s32 x, s32 y)
SDL_Rect rect = {x, y, Width, Height}; SDL_Rect rect = {x, y, Width, Height};
sfx->tic->api.rect(sfx->tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_dark_red)); sfx->tic->api.rect(sfx->tic, rect.x, rect.y, rect.w, rect.h, (tic_color_dark_red));
for(s32 i = 0; i < Height; i += CANVAS_SIZE) for(s32 i = 0; i < Height; i += CANVAS_SIZE)
sfx->tic->api.line(sfx->tic, rect.x, rect.y + i, rect.x + Width, rect.y + i, TIC_COLOR_BG); sfx->tic->api.line(sfx->tic, rect.x, rect.y + i, rect.x + Width, rect.y + i, TIC_COLOR_BG);
@ -958,7 +958,7 @@ static void drawWaveformCanvas(Sfx* sfx, s32 x, s32 y)
{ {
s32 value = tic_tool_peek4(wave->data, i); s32 value = tic_tool_peek4(wave->data, i);
sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1, sfx->tic->api.rect(sfx->tic, x + i * CANVAS_SIZE + 1,
y + 1 + (Height - (value+1)*CANVAS_SIZE), CANVAS_SIZE-1, CANVAS_SIZE-1, systemColor(tic_color_red)); y + 1 + (Height - (value+1)*CANVAS_SIZE), CANVAS_SIZE-1, CANVAS_SIZE-1, (tic_color_red));
} }
} }

View File

@ -56,7 +56,7 @@ static s32 getIndexPosY(Sprite* sprite)
static void drawSelection(Sprite* sprite, s32 x, s32 y, s32 w, s32 h) static void drawSelection(Sprite* sprite, s32 x, s32 y, s32 w, s32 h)
{ {
enum{Step = 3}; enum{Step = 3};
u8 color = systemColor(tic_color_white); u8 color = (tic_color_white);
s32 index = sprite->tickCounter / 10; s32 index = sprite->tickCounter / 10;
for(s32 i = x; i < (x+w); i++) { sprite->tic->api.pixel(sprite->tic, i, y, index++ % Step ? color : 0);} index++; for(s32 i = x; i < (x+w); i++) { sprite->tic->api.pixel(sprite->tic, i, y, index++ % Step ? color : 0);} index++;
@ -75,8 +75,8 @@ static SDL_Rect getSpriteRect(Sprite* sprite)
static void drawCursorBorder(Sprite* sprite, s32 x, s32 y, s32 w, s32 h) static void drawCursorBorder(Sprite* sprite, s32 x, s32 y, s32 w, s32 h)
{ {
sprite->tic->api.rect_border(sprite->tic, x, y, w, h, systemColor(tic_color_black)); sprite->tic->api.rect_border(sprite->tic, x, y, w, h, (tic_color_black));
sprite->tic->api.rect_border(sprite->tic, x-1, y-1, w+2, h+2, systemColor(tic_color_white)); sprite->tic->api.rect_border(sprite->tic, x-1, y-1, w+2, h+2, (tic_color_white));
} }
static void processPickerCanvasMouse(Sprite* sprite, s32 x, s32 y, s32 sx, s32 sy) static void processPickerCanvasMouse(Sprite* sprite, s32 x, s32 y, s32 sx, s32 sy)
@ -336,21 +336,21 @@ static void drawBrushSlider(Sprite* sprite, s32 x, s32 y)
} }
} }
sprite->tic->api.rect(sprite->tic, x+1, y, Size-2, Size*Count, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, x+1, y, Size-2, Size*Count, (tic_color_black));
for(s32 i = 0; i < Count; i++) for(s32 i = 0; i < Count; i++)
{ {
s32 offset = y + i*(Size+1); s32 offset = y + i*(Size+1);
sprite->tic->api.rect(sprite->tic, x, offset, Size, Size, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, x, offset, Size, Size, (tic_color_black));
sprite->tic->api.rect(sprite->tic, x + 6, offset + 2, Count - i, 1, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, x + 6, offset + 2, Count - i, 1, (tic_color_black));
} }
sprite->tic->api.rect(sprite->tic, x+2, y+1, 1, Size*Count+1, systemColor(over ? tic_color_white : tic_color_gray)); sprite->tic->api.rect(sprite->tic, x+2, y+1, 1, Size*Count+1, (over ? tic_color_white : tic_color_gray));
s32 offset = y + (Count - sprite->brushSize)*(Size+1); s32 offset = y + (Count - sprite->brushSize)*(Size+1);
sprite->tic->api.rect(sprite->tic, x, offset, Size, Size, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, x, offset, Size, Size, (tic_color_black));
sprite->tic->api.rect(sprite->tic, x+1, offset+1, Size-2, Size-2, systemColor(over ? tic_color_white : tic_color_gray)); sprite->tic->api.rect(sprite->tic, x+1, offset+1, Size-2, Size-2, (over ? tic_color_white : tic_color_gray));
} }
static void drawCanvas(Sprite* sprite, s32 x, s32 y) static void drawCanvas(Sprite* sprite, s32 x, s32 y)
@ -362,13 +362,13 @@ 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, systemColor(tic_color_black)); sprite->tic->api.text(sprite->tic, buf, ix, iy+1, (tic_color_black));
sprite->tic->api.text(sprite->tic, buf, ix, iy, systemColor(tic_color_white)); sprite->tic->api.text(sprite->tic, buf, ix, iy, (tic_color_white));
} }
sprite->tic->api.rect_border(sprite->tic, x-1, y-1, CANVAS_SIZE+2, CANVAS_SIZE+2, systemColor(tic_color_white)); sprite->tic->api.rect_border(sprite->tic, x-1, y-1, CANVAS_SIZE+2, CANVAS_SIZE+2, (tic_color_white));
sprite->tic->api.rect(sprite->tic, x, y, CANVAS_SIZE, CANVAS_SIZE, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, x, y, CANVAS_SIZE, CANVAS_SIZE, (tic_color_black));
sprite->tic->api.rect(sprite->tic, x-1, y + CANVAS_SIZE+1, CANVAS_SIZE+2, 1, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, x-1, y + CANVAS_SIZE+1, CANVAS_SIZE+2, 1, (tic_color_black));
SDL_Rect rect = getSpriteRect(sprite); SDL_Rect rect = getSpriteRect(sprite);
s32 r = rect.x + rect.w; s32 r = rect.x + rect.w;
@ -506,18 +506,13 @@ static void drawMoveButtons(Sprite* sprite)
Func[i](sprite); Func[i](sprite);
} }
drawBitIcon(Rects[i].x, Rects[i].y+1, Icons + i*8, down ? systemColor(tic_color_white) : systemColor(tic_color_black)); drawBitIcon(Rects[i].x, Rects[i].y+1, Icons + i*8, down ? (tic_color_white) : (tic_color_black));
if(!down) drawBitIcon(Rects[i].x, Rects[i].y, Icons + i*8, systemColor(tic_color_white)); if(!down) drawBitIcon(Rects[i].x, Rects[i].y, Icons + i*8, (tic_color_white));
} }
} }
} }
static void updateCartPalette(Sprite* sprite)
{
SDL_memcpy(sprite->tic->cart.palette.data, sprite->tic->ram.vram.palette.data, sizeof(tic_palette));
}
static void drawRGBSlider(Sprite* sprite, s32 x, s32 y, u8* value) static void drawRGBSlider(Sprite* sprite, s32 x, s32 y, u8* value)
{ {
enum {Size = CANVAS_SIZE, Max = 255}; enum {Size = CANVAS_SIZE, Max = 255};
@ -545,25 +540,23 @@ static void drawRGBSlider(Sprite* sprite, s32 x, s32 y, u8* value)
{ {
s32 mx = getMouseX() - x; s32 mx = getMouseX() - x;
*value = mx * Max / (Size-1); *value = mx * Max / (Size-1);
updateCartPalette(sprite);
} }
} }
sprite->tic->api.rect(sprite->tic, x, y+1, Size, 1, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, x, y+1, Size, 1, (tic_color_black));
sprite->tic->api.rect(sprite->tic, x, y, Size, 1, systemColor(tic_color_white)); sprite->tic->api.rect(sprite->tic, x, y, Size, 1, (tic_color_white));
{ {
s32 offset = x + *value * (Size-1) / Max - 1; s32 offset = x + *value * (Size-1) / Max - 1;
drawBitIcon(offset, y, Icon, systemColor(tic_color_black)); drawBitIcon(offset, y, Icon, (tic_color_black));
drawBitIcon(offset, y-1, Icon, systemColor(tic_color_white)); drawBitIcon(offset, y-1, Icon, (tic_color_white));
sprite->tic->api.pixel(sprite->tic, offset+1, y, sprite->color); sprite->tic->api.pixel(sprite->tic, offset+1, y, sprite->color);
} }
{ {
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, systemColor(tic_color_dark_gray)); sprite->tic->api.text(sprite->tic, buf, x - 18, y - 2, (tic_color_dark_gray));
} }
} }
@ -591,20 +584,17 @@ static void drawRGBSlider(Sprite* sprite, s32 x, s32 y, u8* value)
down = true; down = true;
if(checkMouseClick(&rect, SDL_BUTTON_LEFT)) if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
{
(*value)--; (*value)--;
updateCartPalette(sprite);
}
} }
if(down) if(down)
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_white)); drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_white));
} }
else else
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black)); drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
drawBitIcon(rect.x, rect.y, Icon, systemColor(tic_color_white)); drawBitIcon(rect.x, rect.y, Icon, (tic_color_white));
} }
} }
@ -632,20 +622,17 @@ static void drawRGBSlider(Sprite* sprite, s32 x, s32 y, u8* value)
down = true; down = true;
if(checkMouseClick(&rect, SDL_BUTTON_LEFT)) if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
{
(*value)++; (*value)++;
updateCartPalette(sprite);
}
} }
if(down) if(down)
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_white)); drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_white));
} }
else else
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black)); drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
drawBitIcon(rect.x, rect.y, Icon, systemColor(tic_color_white)); drawBitIcon(rect.x, rect.y, Icon, (tic_color_white));
} }
} }
} }
@ -682,17 +669,17 @@ static void drawRGBTools(Sprite* sprite, s32 x, s32 y)
down = true; down = true;
if(checkMouseClick(&rect, SDL_BUTTON_LEFT)) if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
toClipboard(sprite->tic->ram.vram.palette.data, sizeof(tic_palette), false); toClipboard(sprite->tic->cart.palette.data, sizeof(tic_palette), false);
} }
if(down) if(down)
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_light_blue)); drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_light_blue));
} }
else else
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black)); drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
drawBitIcon(rect.x, rect.y, Icon, systemColor(over ? tic_color_light_blue : tic_color_white)); drawBitIcon(rect.x, rect.y, Icon, (over ? tic_color_light_blue : tic_color_white));
} }
} }
@ -733,12 +720,12 @@ static void drawRGBTools(Sprite* sprite, s32 x, s32 y)
if(down) if(down)
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_light_blue)); drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_light_blue));
} }
else else
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black)); drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
drawBitIcon(rect.x, rect.y, Icon, systemColor(over ? tic_color_light_blue : tic_color_white)); drawBitIcon(rect.x, rect.y, Icon, (over ? tic_color_light_blue : tic_color_white));
} }
} }
} }
@ -747,7 +734,7 @@ static void drawRGBSliders(Sprite* sprite, s32 x, s32 y)
{ {
enum{Gap = 6, Count = sizeof(tic_rgb)}; enum{Gap = 6, Count = sizeof(tic_rgb)};
u8* data = &sprite->tic->ram.vram.palette.data[sprite->color * Count]; u8* data = &sprite->tic->cart.palette.data[sprite->color * Count];
for(s32 i = 0; i < Count; i++) for(s32 i = 0; i < Count; i++)
drawRGBSlider(sprite, x, y + Gap*i, &data[i]); drawRGBSlider(sprite, x, y + Gap*i, &data[i]);
@ -781,23 +768,23 @@ static void drawPalette(Sprite* sprite, s32 x, s32 y)
} }
} }
sprite->tic->api.rect(sprite->tic, rect.x-1, rect.y-1, rect.w+2, rect.h+2, systemColor(tic_color_white)); sprite->tic->api.rect(sprite->tic, rect.x-1, rect.y-1, rect.w+2, rect.h+2, (tic_color_white));
for(s32 row = 0, i = 0; row < PALETTE_ROWS; row++) for(s32 row = 0, i = 0; row < PALETTE_ROWS; row++)
for(s32 col = 0; col < PALETTE_COLS; col++) for(s32 col = 0; col < PALETTE_COLS; col++)
sprite->tic->api.rect(sprite->tic, x + col * PALETTE_CELL_SIZE, y + row * PALETTE_CELL_SIZE, PALETTE_CELL_SIZE-1, PALETTE_CELL_SIZE-1, i++); sprite->tic->api.rect(sprite->tic, x + col * PALETTE_CELL_SIZE, y + row * PALETTE_CELL_SIZE, PALETTE_CELL_SIZE-1, PALETTE_CELL_SIZE-1, i++);
sprite->tic->api.rect(sprite->tic, rect.x-1, rect.y+rect.h+1, PALETTE_WIDTH+1, 1, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, rect.x-1, rect.y+rect.h+1, PALETTE_WIDTH+1, 1, (tic_color_black));
{ {
s32 offsetX = x + (sprite->color % PALETTE_COLS) * PALETTE_CELL_SIZE; s32 offsetX = x + (sprite->color % PALETTE_COLS) * PALETTE_CELL_SIZE;
s32 offsetY = y + (sprite->color / PALETTE_COLS) * PALETTE_CELL_SIZE; s32 offsetY = y + (sprite->color / PALETTE_COLS) * PALETTE_CELL_SIZE;
sprite->tic->api.rect(sprite->tic, offsetX - 1, offsetY - 1, PALETTE_CELL_SIZE + 1, PALETTE_CELL_SIZE + 1, sprite->color); sprite->tic->api.rect(sprite->tic, offsetX - 1, offsetY - 1, PALETTE_CELL_SIZE + 1, PALETTE_CELL_SIZE + 1, sprite->color);
sprite->tic->api.rect_border(sprite->tic, offsetX - 2, offsetY - 2, PALETTE_CELL_SIZE + 3, PALETTE_CELL_SIZE + 3, systemColor(tic_color_white)); sprite->tic->api.rect_border(sprite->tic, offsetX - 2, offsetY - 2, PALETTE_CELL_SIZE + 3, PALETTE_CELL_SIZE + 3, (tic_color_white));
if(offsetY > y) if(offsetY > y)
sprite->tic->api.rect(sprite->tic, offsetX - 2, rect.y + rect.h+2, PALETTE_CELL_SIZE+3, 1, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, offsetX - 2, rect.y + rect.h+2, PALETTE_CELL_SIZE+3, 1, (tic_color_black));
} }
{ {
@ -816,7 +803,7 @@ static void drawPalette(Sprite* sprite, s32 x, s32 y)
s32 offsetX = x + (sprite->color2 % PALETTE_COLS) * PALETTE_CELL_SIZE; s32 offsetX = x + (sprite->color2 % PALETTE_COLS) * PALETTE_CELL_SIZE;
s32 offsetY = y + (sprite->color2 / PALETTE_COLS) * PALETTE_CELL_SIZE; s32 offsetY = y + (sprite->color2 / PALETTE_COLS) * PALETTE_CELL_SIZE;
drawBitIcon(offsetX, offsetY, Icon, sprite->color2 == systemColor(tic_color_white) ? systemColor(tic_color_black) : systemColor(tic_color_white)); drawBitIcon(offsetX, offsetY, Icon, sprite->color2 == (tic_color_white) ? (tic_color_black) : (tic_color_white));
} }
{ {
@ -852,12 +839,12 @@ static void drawPalette(Sprite* sprite, s32 x, s32 y)
if(sprite->editPalette || down) if(sprite->editPalette || down)
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(over ? tic_color_light_blue : tic_color_white)); drawBitIcon(rect.x, rect.y+1, Icon, (over ? tic_color_light_blue : tic_color_white));
} }
else else
{ {
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black)); drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
drawBitIcon(rect.x, rect.y, Icon, systemColor(over ? tic_color_light_blue : tic_color_white)); drawBitIcon(rect.x, rect.y, Icon, (over ? tic_color_light_blue : tic_color_white));
} }
} }
} }
@ -899,8 +886,8 @@ static void drawSheet(Sprite* sprite, s32 x, s32 y)
{ {
SDL_Rect rect = {x, y, TIC_SPRITESHEET_SIZE, TIC_SPRITESHEET_SIZE}; SDL_Rect rect = {x, y, TIC_SPRITESHEET_SIZE, TIC_SPRITESHEET_SIZE};
sprite->tic->api.rect_border(sprite->tic, rect.x - 1, rect.y - 1, rect.w + 2, rect.h + 2, systemColor(tic_color_white)); sprite->tic->api.rect_border(sprite->tic, rect.x - 1, rect.y - 1, rect.w + 2, rect.h + 2, (tic_color_white));
sprite->tic->api.rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, (tic_color_black));
if(checkMousePos(&rect)) if(checkMousePos(&rect))
{ {
@ -920,7 +907,7 @@ static void drawSheet(Sprite* sprite, s32 x, s32 y)
s32 bx = getIndexPosX(sprite) + x - 1; s32 bx = getIndexPosX(sprite) + x - 1;
s32 by = getIndexPosY(sprite) + y - 1; s32 by = getIndexPosY(sprite) + y - 1;
sprite->tic->api.rect_border(sprite->tic, bx, by, sprite->size + 2, sprite->size + 2, systemColor(tic_color_white)); sprite->tic->api.rect_border(sprite->tic, bx, by, sprite->size + 2, sprite->size + 2, (tic_color_white));
} }
} }
@ -1072,12 +1059,12 @@ static void drawSpriteTools(Sprite* sprite, s32 x, s32 y)
if(pushed) if(pushed)
{ {
drawBitIcon(rect.x, y + 1, Icons + i*BITS_IN_BYTE, systemColor(over ? tic_color_light_blue : tic_color_white)); drawBitIcon(rect.x, y + 1, Icons + i*BITS_IN_BYTE, (over ? tic_color_light_blue : tic_color_white));
} }
else else
{ {
drawBitIcon(rect.x, y+1, Icons + i*BITS_IN_BYTE, systemColor(tic_color_black)); drawBitIcon(rect.x, y+1, Icons + i*BITS_IN_BYTE, (tic_color_black));
drawBitIcon(rect.x, y, Icons + i*BITS_IN_BYTE, systemColor(over ? tic_color_light_blue : tic_color_white)); drawBitIcon(rect.x, y, Icons + i*BITS_IN_BYTE, (over ? tic_color_light_blue : tic_color_white));
} }
} }
} }
@ -1163,15 +1150,15 @@ static void drawTools(Sprite* sprite, s32 x, s32 y)
0b00000000, 0b00000000,
}; };
drawBitIcon(rect.x, y - 4, Icon, systemColor(tic_color_black)); drawBitIcon(rect.x, y - 4, Icon, (tic_color_black));
drawBitIcon(rect.x, y - 5, Icon, systemColor(tic_color_white)); drawBitIcon(rect.x, y - 5, Icon, (tic_color_white));
drawBitIcon(rect.x, y + 1, Icons + i*BITS_IN_BYTE, systemColor(over ? tic_color_light_blue : tic_color_white)); drawBitIcon(rect.x, y + 1, Icons + i*BITS_IN_BYTE, (over ? tic_color_light_blue : tic_color_white));
} }
else else
{ {
drawBitIcon(rect.x, y+1, Icons + i*BITS_IN_BYTE, systemColor(tic_color_black)); drawBitIcon(rect.x, y+1, Icons + i*BITS_IN_BYTE, (tic_color_black));
drawBitIcon(rect.x, y, Icons + i*BITS_IN_BYTE, systemColor(over ? tic_color_light_blue : tic_color_white)); drawBitIcon(rect.x, y, Icons + i*BITS_IN_BYTE, (over ? tic_color_light_blue : tic_color_white));
} }
} }
@ -1347,7 +1334,7 @@ static void processKeydown(Sprite* sprite, SDL_Keycode keycode)
static void drawSpriteToolbar(Sprite* sprite) static void drawSpriteToolbar(Sprite* sprite)
{ {
sprite->tic->api.rect(sprite->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE-1, systemColor(tic_color_white)); sprite->tic->api.rect(sprite->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, (tic_color_white));
// draw sprite size control // draw sprite size control
{ {
@ -1370,16 +1357,16 @@ static void drawSpriteToolbar(Sprite* sprite)
} }
for(s32 i = 0; i < 4; i++) for(s32 i = 0; i < 4; i++)
sprite->tic->api.rect(sprite->tic, rect.x + i*6, 1, 5, 5, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, rect.x + i*6, 1, 5, 5, (tic_color_black));
sprite->tic->api.rect(sprite->tic, rect.x, 2, 23, 3, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, rect.x, 2, 23, 3, (tic_color_black));
sprite->tic->api.rect(sprite->tic, rect.x+1, 3, 21, 1, systemColor(tic_color_white)); sprite->tic->api.rect(sprite->tic, rect.x+1, 3, 21, 1, (tic_color_white));
s32 size = sprite->size / TIC_SPRITESIZE, val = 0; s32 size = sprite->size / TIC_SPRITESIZE, val = 0;
while(size >>= 1) val++; while(size >>= 1) val++;
sprite->tic->api.rect(sprite->tic, rect.x + val*6, 1, 5, 5, systemColor(tic_color_black)); sprite->tic->api.rect(sprite->tic, rect.x + val*6, 1, 5, 5, (tic_color_black));
sprite->tic->api.rect(sprite->tic, rect.x+1 + val*6, 2, 3, 3, systemColor(tic_color_white)); sprite->tic->api.rect(sprite->tic, rect.x+1 + val*6, 2, 3, 3, (tic_color_white));
} }
bool bg = sprite->index < TIC_BANK_SPRITES; bool bg = sprite->index < TIC_BANK_SPRITES;
@ -1387,8 +1374,8 @@ static void drawSpriteToolbar(Sprite* sprite)
{ {
static const char Label[] = "BG"; static const char Label[] = "BG";
SDL_Rect rect = {TIC80_WIDTH - 2 * TIC_FONT_WIDTH - 2, 0, 2 * TIC_FONT_WIDTH + 1, TIC_SPRITESIZE-1}; SDL_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 ? systemColor(tic_color_black) : systemColor(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, systemColor(tic_color_white)); sprite->tic->api.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, (tic_color_white));
if(checkMousePos(&rect)) if(checkMousePos(&rect))
{ {
@ -1407,8 +1394,8 @@ static void drawSpriteToolbar(Sprite* sprite)
{ {
static const char Label[] = "FG"; static const char Label[] = "FG";
SDL_Rect rect = {TIC80_WIDTH - 4 * TIC_FONT_WIDTH - 4, 0, 2 * TIC_FONT_WIDTH + 1, TIC_SPRITESIZE-1}; SDL_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 ? systemColor(tic_color_gray) : systemColor(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, systemColor(tic_color_white)); sprite->tic->api.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, (tic_color_white));
if(checkMousePos(&rect)) if(checkMousePos(&rect))
{ {
@ -1453,7 +1440,7 @@ static void tick(Sprite* sprite)
} }
} }
sprite->tic->api.clear(sprite->tic, systemColor(tic_color_gray)); sprite->tic->api.clear(sprite->tic, (tic_color_gray));
drawCanvas(sprite, 24, 20); drawCanvas(sprite, 24, 20);
drawMoveButtons(sprite); drawMoveButtons(sprite);
@ -1466,7 +1453,7 @@ static void tick(Sprite* sprite)
drawSheet(sprite, TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, 7); drawSheet(sprite, TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, 7);
drawSpriteToolbar(sprite); drawSpriteToolbar(sprite);
drawToolbar(sprite->tic, systemColor(tic_color_gray), false); drawToolbar(sprite->tic, (tic_color_gray), false);
sprite->tickCounter++; sprite->tickCounter++;
} }
@ -1483,6 +1470,11 @@ static void onStudioEvent(Sprite* sprite, StudioEvent event)
} }
} }
static void scanline(tic_mem* tic, s32 row)
{
memcpy(tic->ram.vram.palette.data, row < TOOLBAR_SIZE ? tic->config.palette.data : tic->cart.palette.data, sizeof(tic_palette));
}
void initSprite(Sprite* sprite, tic_mem* tic) void initSprite(Sprite* sprite, tic_mem* tic)
{ {
if(sprite->select.back == NULL) sprite->select.back = (u8*)SDL_malloc(CANVAS_SIZE*CANVAS_SIZE); if(sprite->select.back == NULL) sprite->select.back = (u8*)SDL_malloc(CANVAS_SIZE*CANVAS_SIZE);
@ -1511,5 +1503,6 @@ void initSprite(Sprite* sprite, tic_mem* tic)
.mode = SPRITE_DRAW_MODE, .mode = SPRITE_DRAW_MODE,
.history = history_create(tic->cart.gfx.tiles, TIC_SPRITES * sizeof(tic_tile)), .history = history_create(tic->cart.gfx.tiles, TIC_SPRITES * sizeof(tic_tile)),
.event = onStudioEvent, .event = onStudioEvent,
.scanline = scanline,
}; };
} }

View File

@ -61,6 +61,7 @@ struct Sprite
void (*tick)(Sprite*); void (*tick)(Sprite*);
void (*event)(Sprite*, StudioEvent); void (*event)(Sprite*, StudioEvent);
void (*scanline)(tic_mem* tic, s32 row);
}; };
void initSprite(Sprite*, tic_mem*); void initSprite(Sprite*, tic_mem*);

View File

@ -26,7 +26,7 @@ static void reset(Start* start)
{ {
u8* tile = (u8*)start->tic->ram.gfx.tiles; u8* tile = (u8*)start->tic->ram.gfx.tiles;
start->tic->api.clear(start->tic, systemColor(tic_color_black)); start->tic->api.clear(start->tic, (tic_color_black));
static const u8 Reset[] = {0x00, 0x06, 0x96, 0x00}; static const u8 Reset[] = {0x00, 0x06, 0x96, 0x00};
u8 val = Reset[sizeof(Reset) * (start->ticks % TIC_FRAMERATE) / TIC_FRAMERATE]; u8 val = Reset[sizeof(Reset) * (start->ticks % TIC_FRAMERATE) / TIC_FRAMERATE];
@ -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, systemColor(tic_color_white)); 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_VERSION_LABEL, (sizeof(TIC_NAME_FULL) + 1) * STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT, systemColor(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));
start->tic->api.fixed_text(start->tic, TIC_COPYRIGHT, STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT*2, systemColor(tic_color_dark_gray)); start->tic->api.fixed_text(start->tic, TIC_COPYRIGHT, STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT*2, (tic_color_dark_gray));
} }
static void header(Start* start) static void header(Start* start)
@ -100,7 +100,4 @@ void initStart(Start* start, tic_mem* tic)
.tick = tick, .tick = tick,
.play = false, .play = false,
}; };
memcpy(tic->cart.palette.data, tic->config.palette.data, sizeof(tic_palette));
tic->api.reset(tic);
} }

View File

@ -466,8 +466,8 @@ void drawExtrabar(tic_mem* tic)
{ {
SDL_Rect rect = {x + i*Size, y, Size, Size}; SDL_Rect rect = {x + i*Size, y, Size, Size};
u8 bgcolor = systemColor(tic_color_white); u8 bgcolor = (tic_color_white);
u8 color = systemColor(tic_color_light_blue); u8 color = (tic_color_light_blue);
if(checkMousePos(&rect)) if(checkMousePos(&rect))
{ {
@ -479,7 +479,7 @@ void drawExtrabar(tic_mem* tic)
if(checkMouseDown(&rect, SDL_BUTTON_LEFT)) if(checkMouseDown(&rect, SDL_BUTTON_LEFT))
{ {
bgcolor = color; bgcolor = color;
color = systemColor(tic_color_white); color = (tic_color_white);
} }
else if(checkMouseClick(&rect, SDL_BUTTON_LEFT)) else if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
{ {
@ -497,15 +497,10 @@ const StudioConfig* getConfig()
return &studio.config.data; return &studio.config.data;
} }
u8 systemColor(u8 color)
{
return getConfig()->theme.palmap.data[color];
}
void drawToolbar(tic_mem* tic, u8 color, bool bg) void drawToolbar(tic_mem* tic, u8 color, bool bg)
{ {
if(bg) if(bg)
studio.tic->api.rect(tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE-1, systemColor(tic_color_white)); studio.tic->api.rect(tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, (tic_color_white));
static const u8 TabIcon[] = static const u8 TabIcon[] =
{ {
@ -596,7 +591,7 @@ void drawToolbar(tic_mem* tic, u8 color, bool bg)
if(mode == i) if(mode == i)
drawBitIcon(i * Size, 0, TabIcon, color); drawBitIcon(i * Size, 0, TabIcon, color);
drawBitIcon(i * Size, 0, Icons + i * BITS_IN_BYTE, mode == i ? systemColor(tic_color_white) : (over ? systemColor(tic_color_dark_gray) : systemColor(tic_color_light_blue))); drawBitIcon(i * Size, 0, Icons + i * BITS_IN_BYTE, mode == i ? (tic_color_white) : (over ? (tic_color_dark_gray) : (tic_color_light_blue)));
} }
if(mode >= 0) drawExtrabar(tic); if(mode >= 0) drawExtrabar(tic);
@ -614,11 +609,11 @@ void drawToolbar(tic_mem* tic, u8 color, bool bg)
{ {
if(strlen(studio.tooltip.text)) if(strlen(studio.tooltip.text))
{ {
studio.tic->api.text(tic, studio.tooltip.text, (COUNT_OF(Modes) + 1) * Size, 1, systemColor(tic_color_black)); studio.tic->api.text(tic, studio.tooltip.text, (COUNT_OF(Modes) + 1) * Size, 1, (tic_color_black));
} }
else else
{ {
studio.tic->api.text(tic, Names[mode], (COUNT_OF(Modes) + 1) * Size, 1, systemColor(tic_color_dark_gray)); studio.tic->api.text(tic, Names[mode], (COUNT_OF(Modes) + 1) * Size, 1, (tic_color_dark_gray));
} }
} }
} }
@ -771,9 +766,7 @@ void setStudioMode(EditorMode mode)
EditorMode prev = studio.mode; EditorMode prev = studio.mode;
if(prev == TIC_RUN_MODE) if(prev == TIC_RUN_MODE)
{
studio.tic->api.pause(studio.tic); studio.tic->api.pause(studio.tic);
}
if(mode != TIC_RUN_MODE) if(mode != TIC_RUN_MODE)
studio.tic->api.reset(studio.tic); studio.tic->api.reset(studio.tic);
@ -820,9 +813,11 @@ EditorMode getStudioMode()
return studio.mode; return studio.mode;
} }
void showGameMenu() static void showGameMenu()
{ {
studio.tic->api.pause(studio.tic); studio.tic->api.pause(studio.tic);
studio.tic->api.reset(studio.tic);
initMenuMode(); initMenuMode();
studio.mode = TIC_MENU_MODE; studio.mode = TIC_MENU_MODE;
} }
@ -1390,7 +1385,7 @@ static u32* srcPaletteBlit(const u8* src)
memset(pal, 0xff, sizeof pal); memset(pal, 0xff, sizeof pal);
u8* dst = (u8*)pal; u8* dst = (u8*)pal;
const u8* end = src + sizeof studio.tic->ram.vram.palette; const u8* end = src + sizeof(tic_palette);
enum{RGB = sizeof(tic_rgb)}; enum{RGB = sizeof(tic_rgb)};
@ -1411,15 +1406,32 @@ static void blit(u32* out, u32* bgOut, s32 pitch, s32 bgPitch)
const s32 pitchWidth = pitch/sizeof *out; const s32 pitchWidth = pitch/sizeof *out;
const s32 bgPitchWidth = bgPitch/sizeof *bgOut; const s32 bgPitchWidth = bgPitch/sizeof *bgOut;
u32* row = out; u32* row = out;
const u32* pal = srcPaletteBlit(studio.tic->cart.palette.data); const u32* pal = paletteBlit();
void(*scanline)(tic_mem* memory, s32 row) = NULL;
switch(studio.mode)
{
case TIC_RUN_MODE:
scanline = studio.tic->api.scanline;
break;
case TIC_SPRITE_MODE:
scanline = studio.sprite.scanline;
break;
case TIC_MAP_MODE:
scanline = studio.map.scanline;
break;
default:
break;
}
for(s32 r = 0, pos = 0; r < TIC80_HEIGHT; r++, row += pitchWidth) for(s32 r = 0, pos = 0; r < TIC80_HEIGHT; r++, row += pitchWidth)
{ {
if(scanline)
if(studio.mode == TIC_RUN_MODE || studio.mode == TIC_MENU_MODE)
{ {
studio.tic->api.scanline(studio.tic, r); scanline(studio.tic, r);
pal = paletteBlit(); pal = paletteBlit();
}
if(bgOut) if(bgOut)
{ {
@ -1427,7 +1439,6 @@ static void blit(u32* out, u32* bgOut, s32 pitch, s32 bgPitch)
SDL_memset4(bgOut, pal[border], TIC80_WIDTH); SDL_memset4(bgOut, pal[border], TIC80_WIDTH);
bgOut += bgPitchWidth; bgOut += bgPitchWidth;
} }
}
SDL_memset4(row, 0, pitchWidth); SDL_memset4(row, 0, pitchWidth);
@ -1994,6 +2005,11 @@ static void renderCursor()
blitCursor(studio.tic->config.gfx.tiles[getConfig()->theme.cursor.sprite].data); blitCursor(studio.tic->config.gfx.tiles[getConfig()->theme.cursor.sprite].data);
} }
static void useSystemPalette()
{
memcpy(studio.tic->ram.vram.palette.data, studio.tic->config.palette.data, sizeof(tic_palette));
}
static void renderStudio() static void renderStudio()
{ {
showTooltip(""); showTooltip("");
@ -2046,14 +2062,18 @@ static void renderStudio()
{ {
studio.popup.counter--; studio.popup.counter--;
studio.tic->api.rect(studio.tic, 0, TIC80_HEIGHT - TIC_FONT_HEIGHT - 1, TIC80_WIDTH, TIC80_HEIGHT, systemColor(tic_color_red)); studio.tic->api.rect(studio.tic, 0, TIC80_HEIGHT - TIC_FONT_HEIGHT - 1, TIC80_WIDTH, TIC80_HEIGHT, (tic_color_red));
studio.tic->api.text(studio.tic, studio.popup.message, (s32)(TIC80_WIDTH - strlen(studio.popup.message)*TIC_FONT_WIDTH)/2, studio.tic->api.text(studio.tic, studio.popup.message, (s32)(TIC80_WIDTH - strlen(studio.popup.message)*TIC_FONT_WIDTH)/2,
TIC80_HEIGHT - TIC_FONT_HEIGHT, systemColor(tic_color_white)); TIC80_HEIGHT - TIC_FONT_HEIGHT, (tic_color_white));
} }
studio.tic->api.tick_end(studio.tic); studio.tic->api.tick_end(studio.tic);
blitSound(); blitSound();
if(studio.mode != TIC_RUN_MODE)
useSystemPalette();
blitTexture(); blitTexture();
renderCursor(); renderCursor();
@ -2253,7 +2273,7 @@ static void setWindowIcon()
u32* pixels = SDL_malloc(Size * Size * sizeof(u32)); u32* pixels = SDL_malloc(Size * Size * sizeof(u32));
const u32* pal = paletteBlit(); const u32* pal = srcPaletteBlit(studio.tic->config.palette.data);
for(s32 j = 0, index = 0; j < Size; j++) for(s32 j = 0, index = 0; j < Size; j++)
for(s32 i = 0; i < Size; i++, index++) for(s32 i = 0; i < Size; i++, index++)

View File

@ -43,13 +43,13 @@
#define TIC_MOD_CTRL (KMOD_GUI|KMOD_CTRL) #define TIC_MOD_CTRL (KMOD_GUI|KMOD_CTRL)
#define TOOLBAR_SIZE 8 #define TOOLBAR_SIZE 7
#define STUDIO_TEXT_WIDTH (TIC_FONT_WIDTH) #define STUDIO_TEXT_WIDTH (TIC_FONT_WIDTH)
#define STUDIO_TEXT_HEIGHT (TIC_FONT_HEIGHT+1) #define STUDIO_TEXT_HEIGHT (TIC_FONT_HEIGHT+1)
#define STUDIO_TEXT_BUFFER_WIDTH (TIC80_WIDTH / STUDIO_TEXT_WIDTH) #define STUDIO_TEXT_BUFFER_WIDTH (TIC80_WIDTH / STUDIO_TEXT_WIDTH)
#define STUDIO_TEXT_BUFFER_HEIGHT (TIC80_HEIGHT / STUDIO_TEXT_HEIGHT) #define STUDIO_TEXT_BUFFER_HEIGHT (TIC80_HEIGHT / STUDIO_TEXT_HEIGHT)
#define TIC_COLOR_BG systemColor(tic_color_black) #define TIC_COLOR_BG (tic_color_black)
#define DEFAULT_CHMOD 0755 #define DEFAULT_CHMOD 0755
#define CONFIG_TIC "config " TIC_VERSION_LABEL ".tic" #define CONFIG_TIC "config " TIC_VERSION_LABEL ".tic"
@ -64,11 +64,6 @@ typedef struct
{ {
struct struct
{ {
struct
{
u8 data[TIC_PALETTE_SIZE];
} palmap;
struct struct
{ {
s32 sprite; s32 sprite;
@ -179,8 +174,6 @@ void showTooltip(const char* text);
SDL_Scancode* getKeymap(); SDL_Scancode* getKeymap();
u8 systemColor(u8 color);
const StudioConfig* getConfig(); const StudioConfig* getConfig();
void setSpritePixel(tic_tile* tiles, s32 x, s32 y, u8 color); void setSpritePixel(tic_tile* tiles, s32 x, s32 y, u8 color);
@ -190,7 +183,6 @@ typedef void(*DialogCallback)(bool yes, void* data);
void showDialog(const char** text, s32 rows, DialogCallback callback, void* data); void showDialog(const char** text, s32 rows, DialogCallback callback, void* data);
void hideDialog(); void hideDialog();
void showGameMenu();
void hideGameMenu(); void hideGameMenu();
bool studioCartChanged(); bool studioCartChanged();

View File

@ -482,7 +482,7 @@ static void updateMenuItemCover(Surf* surf, const u8* cover, s32 size)
{ {
const gif_color* c = &image->palette[image->buffer[i]]; const gif_color* c = &image->palette[image->buffer[i]];
tic_rgb rgb = { c->r, c->g, c->b }; tic_rgb rgb = { c->r, c->g, c->b };
u8 color = tic_tool_find_closest_color(tic->cart.palette.colors, &rgb); u8 color = tic_tool_find_closest_color(tic->config.palette.colors, &rgb);
tic_tool_poke4(item->cover->data, i, color); tic_tool_poke4(item->cover->data, i, color);
} }
} }

View File

@ -441,8 +441,8 @@ static void api_pause(tic_mem* memory)
memcpy(&machine->pause.music_pos, &memory->ram.music_pos, sizeof memory->ram.music_pos); memcpy(&machine->pause.music_pos, &memory->ram.music_pos, sizeof memory->ram.music_pos);
memcpy(&machine->pause.vram, &memory->ram.vram, sizeof memory->ram.vram); memcpy(&machine->pause.vram, &memory->ram.vram, sizeof memory->ram.vram);
api_reset(memory); // api_reset(memory);
memcpy(memory->ram.vram.palette.data, memory->config.palette.data, sizeof(tic_palette)); // memcpy(memory->ram.vram.palette.data, memory->config.palette.data, sizeof(tic_palette));
} }
static void api_resume(tic_mem* memory) static void api_resume(tic_mem* memory)

View File

@ -28,7 +28,7 @@
static void drawGrid(World* world) static void drawGrid(World* world)
{ {
Map* map = world->map; Map* map = world->map;
u8 color = systemColor(tic_color_light_blue); u8 color = (tic_color_light_blue);
for(s32 c = 0; c < TIC80_WIDTH; c += TIC_MAP_SCREEN_WIDTH) for(s32 c = 0; c < TIC80_WIDTH; c += TIC_MAP_SCREEN_WIDTH)
world->tic->api.line(world->tic, c, 0, c, TIC80_HEIGHT, color); world->tic->api.line(world->tic, c, 0, c, TIC80_HEIGHT, color);
@ -58,7 +58,7 @@ static void drawGrid(World* world)
} }
world->tic->api.rect_border(world->tic, map->scroll.x / TIC_SPRITESIZE, map->scroll.y / TIC_SPRITESIZE, world->tic->api.rect_border(world->tic, map->scroll.x / TIC_SPRITESIZE, map->scroll.y / TIC_SPRITESIZE,
TIC_MAP_SCREEN_WIDTH+1, TIC_MAP_SCREEN_HEIGHT+1, systemColor(tic_color_red)); TIC_MAP_SCREEN_WIDTH+1, TIC_MAP_SCREEN_HEIGHT+1, (tic_color_red));
} }
static void processKeydown(World* world, SDL_Keycode keycode) static void processKeydown(World* world, SDL_Keycode keycode)