Merge branch 'tic_0.47.0'
This commit is contained in:
commit
5d50811877
|
@ -2,6 +2,8 @@
|
|||
*.ipch
|
||||
*.opendb
|
||||
*.suo
|
||||
sexit
|
||||
.vscode/
|
||||
build/uwp/tic/Debug/
|
||||
build/uwp/tic/Release/
|
||||
build/uwp/tic/x64/
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4,8 +4,8 @@
|
|||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.nesbox.tic"
|
||||
android:versionCode="4600"
|
||||
android:versionName="0.46.0"
|
||||
android:versionCode="4700"
|
||||
android:versionName="0.47.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- Android 2.3.3 -->
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "build.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-12
|
|
@ -19,9 +19,9 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.46.0</string>
|
||||
<string>0.47.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.46.0</string>
|
||||
<string>0.47.0</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>http://tic.computer © 2017</string>
|
||||
</dict>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
|
||||
<Identity Name="50446Nesbox.TICcomputer" Publisher="CN=1040DC4A-04A1-4B33-9107-C1A9D74775D4" Version="0.46.0.0" />
|
||||
<Identity Name="50446Nesbox.TICcomputer" Publisher="CN=1040DC4A-04A1-4B33-9107-C1A9D74775D4" Version="0.47.0.0" />
|
||||
<mp:PhoneIdentity PhoneProductId="93515db0-8ee3-478b-933a-5776b58247b2" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>TIC-80</DisplayName>
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<PackageCertificateKeyFile>tic_StoreKey.pfx</PackageCertificateKeyFile>
|
||||
<PackageCertificateThumbprint>FAF3D8EF7331C1BFD85A8A5CE536BBA943CFEF65</PackageCertificateThumbprint>
|
||||
<PackageCertificateThumbprint>D14111A1389AE6F9821F879C5D6D066D87718B43</PackageCertificateThumbprint>
|
||||
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
|
||||
<AppxBundle>Always</AppxBundle>
|
||||
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
config.tic
BIN
config.tic
Binary file not shown.
Binary file not shown.
181
src/code.c
181
src/code.c
|
@ -46,7 +46,7 @@ static void history(Code* code)
|
|||
static void drawStatus(Code* code)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ static void drawCode(Code* code, bool withCursor)
|
|||
|
||||
u8* colorPointer = code->colorBuffer;
|
||||
|
||||
struct { char* start; char* end; } selection = {SDL_min(code->cursor.selection, code->cursor.position),
|
||||
struct { char* start; char* end; } selection = {SDL_min(code->cursor.selection, code->cursor.position),
|
||||
SDL_max(code->cursor.selection, code->cursor.position)};
|
||||
|
||||
struct { s32 x; s32 y; char symbol; } cursor = {-1, -1, 0};
|
||||
|
@ -155,11 +155,11 @@ static void updateEditor(Code* code)
|
|||
getCursorPosition(code, &column, &line);
|
||||
|
||||
if(column < code->scroll.x) code->scroll.x = column;
|
||||
else if(column >= code->scroll.x + TEXT_BUFFER_WIDTH)
|
||||
else if(column >= code->scroll.x + TEXT_BUFFER_WIDTH)
|
||||
code->scroll.x = column - TEXT_BUFFER_WIDTH + 1;
|
||||
|
||||
if(line < code->scroll.y) code->scroll.y = line;
|
||||
else if(line >= code->scroll.y + TEXT_BUFFER_HEIGHT)
|
||||
else if(line >= code->scroll.y + TEXT_BUFFER_HEIGHT)
|
||||
code->scroll.y = line - TEXT_BUFFER_HEIGHT + 1;
|
||||
|
||||
code->cursor.delay = TEXT_CURSOR_DELAY;
|
||||
|
@ -175,9 +175,9 @@ static void updateEditor(Code* code)
|
|||
|
||||
size_t codeLen = strlen(code->data);
|
||||
sprintf(status, "%i/%i", (u32)codeLen, TIC_CODE_SIZE);
|
||||
|
||||
|
||||
memset(code->data + codeLen, '\0', TIC_CODE_SIZE - codeLen);
|
||||
memcpy(code->status + sizeof code->status - strlen(status) - 1, status, strlen(status));
|
||||
memcpy(code->status + sizeof code->status - strlen(status) - 1, status, strlen(status));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ static void highlightStrings(Code* code, const char* text, u8* color, char separ
|
|||
memset(colorPtr, getConfig()->theme.code.string, end - start);
|
||||
|
||||
highlightStrings(code, end, color + (end - text), separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,13 +265,13 @@ static void highlightMoonKeywords(Code* code, u8* color)
|
|||
{
|
||||
const char* text = code->data;
|
||||
|
||||
static const char* const MoonKeywords [] =
|
||||
static const char* const MoonKeywords [] =
|
||||
{
|
||||
"false", "true", "nil", "return",
|
||||
"break", "continue", "for", "while",
|
||||
"if", "else", "elseif", "unless", "switch",
|
||||
"when", "and", "or", "in", "do",
|
||||
"not", "super", "try", "catch",
|
||||
"false", "true", "nil", "return",
|
||||
"break", "continue", "for", "while",
|
||||
"if", "else", "elseif", "unless", "switch",
|
||||
"when", "and", "or", "in", "do",
|
||||
"not", "super", "try", "catch",
|
||||
"with", "export", "import", "then",
|
||||
"from", "class", "extends", "new"
|
||||
};
|
||||
|
@ -283,7 +283,7 @@ static void highlightLuaKeywords(Code* code, u8* color)
|
|||
{
|
||||
const char* text = code->data;
|
||||
|
||||
static const char* const LuaKeywords [] =
|
||||
static const char* const LuaKeywords [] =
|
||||
{
|
||||
"and", "break", "do", "else", "elseif",
|
||||
"end", "false", "for", "function", "goto", "if",
|
||||
|
@ -298,11 +298,11 @@ static void highlightJsKeywords(Code* code, u8* color)
|
|||
{
|
||||
const char* text = code->data;
|
||||
|
||||
static const char* const JsKeywords [] =
|
||||
static const char* const JsKeywords [] =
|
||||
{
|
||||
"break", "do", "instanceof", "typeof", "case", "else", "new",
|
||||
"var", "catch", "finally", "return", "void", "continue", "for",
|
||||
"switch", "while", "debugger", "function", "this", "with",
|
||||
"break", "do", "instanceof", "typeof", "case", "else", "new",
|
||||
"var", "catch", "finally", "return", "void", "continue", "for",
|
||||
"switch", "while", "debugger", "function", "this", "with",
|
||||
"default", "if", "throw", "delete", "in", "try", "const"
|
||||
};
|
||||
|
||||
|
@ -335,13 +335,13 @@ static void highlightSigns(Code* code, u8* color)
|
|||
{
|
||||
const char* text = code->data;
|
||||
|
||||
static const char* const LuaSigns [] =
|
||||
static const char* const LuaSigns [] =
|
||||
{
|
||||
"+", "-", "*", "/", "%", "^", "#",
|
||||
"&", "~", "|", "<<", ">>", "//",
|
||||
"==", "~=", "<=", ">=", "<", ">", "=",
|
||||
"(", ")", "{", "}", "[", "]", "::",
|
||||
";", ":", ",", ".", "..", "...",
|
||||
"+", "-", "*", "/", "%", "^", "#",
|
||||
"&", "~", "|", "<<", ">>", "//",
|
||||
"==", "~=", "<=", ">=", "<", ">", "=",
|
||||
"(", ")", "{", "}", "[", "]", "::",
|
||||
";", ":", ",", ".", "..", "...",
|
||||
};
|
||||
|
||||
for(s32 i = 0; i < COUNT_OF(LuaSigns); i++)
|
||||
|
@ -521,7 +521,7 @@ static void setCursorPosition(Code* code, s32 cx, s32 cy)
|
|||
if(y == cy && cx > x)
|
||||
{
|
||||
updateCursorPosition(code, pointer);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
|
@ -567,7 +567,7 @@ static void leftColumn(Code* code)
|
|||
static void rightColumn(Code* code)
|
||||
{
|
||||
if(*code->cursor.position)
|
||||
{
|
||||
{
|
||||
code->cursor.position++;
|
||||
updateColumn(code);
|
||||
}
|
||||
|
@ -619,6 +619,20 @@ static void goEnd(Code* code)
|
|||
updateColumn(code);
|
||||
}
|
||||
|
||||
static void goCodeHome(Code *code)
|
||||
{
|
||||
code->cursor.position = code->data;
|
||||
|
||||
updateColumn(code);
|
||||
}
|
||||
|
||||
static void goCodeEnd(Code *code)
|
||||
{
|
||||
code->cursor.position = code->data + strlen(code->data);
|
||||
|
||||
updateColumn(code);
|
||||
}
|
||||
|
||||
static void pageUp(Code* code)
|
||||
{
|
||||
s32 column = 0;
|
||||
|
@ -878,7 +892,7 @@ static void doTab(Code* code, bool shift)
|
|||
history(code);
|
||||
|
||||
parseSyntaxColor(code);
|
||||
|
||||
|
||||
}
|
||||
else inputSymbolBase(code, '\t');
|
||||
}
|
||||
|
@ -890,7 +904,7 @@ static void setFindMode(Code* code)
|
|||
const char* end = SDL_max(code->cursor.position, code->cursor.selection);
|
||||
const char* start = SDL_min(code->cursor.position, code->cursor.selection);
|
||||
size_t len = end - start;
|
||||
|
||||
|
||||
if(len > 0 && len < sizeof code->popup.text - 1)
|
||||
{
|
||||
memset(code->popup.text, 0, sizeof code->popup.text);
|
||||
|
@ -938,7 +952,7 @@ static char* getFuncName(const char* start, char* buffer)
|
|||
memcpy(buffer, start, len);
|
||||
buffer[len] = '\0';
|
||||
|
||||
return buffer;
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +1011,7 @@ static void setMoonscriptOutlineMode(Code* code)
|
|||
char filter[STUDIO_TEXT_BUFFER_WIDTH];
|
||||
strcpy(filter, code->popup.text);
|
||||
SDL_strlwr(filter);
|
||||
|
||||
|
||||
while(ptr)
|
||||
{
|
||||
ptr = strstr(ptr, FuncString);
|
||||
|
@ -1029,7 +1043,7 @@ static void setMoonscriptOutlineMode(Code* code)
|
|||
out++;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
out->pos = start;
|
||||
out++;
|
||||
|
@ -1076,7 +1090,7 @@ static void setLuaOutlineMode(Code* code)
|
|||
out++;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
out->pos = ptr;
|
||||
out++;
|
||||
|
@ -1095,7 +1109,7 @@ static void setOutlineMode(Code* code)
|
|||
memset(code->outline.items, 0, OUTLINE_ITEMS_SIZE);
|
||||
|
||||
code->tic->api.get_script(code->tic) == tic_script_moon
|
||||
? setMoonscriptOutlineMode(code)
|
||||
? setMoonscriptOutlineMode(code)
|
||||
: setLuaOutlineMode(code);
|
||||
|
||||
qsort(code->outline.items, OUTLINE_SIZE, sizeof(OutlineItem), funcCompare);
|
||||
|
@ -1199,7 +1213,7 @@ static void processKeydown(Code* code, SDL_Keycode keycode)
|
|||
if(!(keymod & KMOD_SHIFT)) code->cursor.selection = NULL;
|
||||
else if(code->cursor.selection == NULL) code->cursor.selection = code->cursor.position;
|
||||
}
|
||||
|
||||
|
||||
if(keymod & TIC_MOD_CTRL)
|
||||
{
|
||||
if(keymod & KMOD_CTRL)
|
||||
|
@ -1228,6 +1242,8 @@ static void processKeydown(Code* code, SDL_Keycode keycode)
|
|||
case SDLK_g: setCodeMode(code, TEXT_GOTO_MODE); break;
|
||||
case SDLK_o: setCodeMode(code, TEXT_OUTLINE_MODE); break;
|
||||
case SDLK_SLASH: commentLine(code); break;
|
||||
case SDLK_HOME: goCodeHome(code); break;
|
||||
case SDLK_END: goCodeEnd(code); break;
|
||||
}
|
||||
}
|
||||
else if(keymod & KMOD_ALT)
|
||||
|
@ -1319,7 +1335,7 @@ static void processMouse(Code* code)
|
|||
code->cursor.position = position;
|
||||
}
|
||||
else if(!code->cursor.mouseDownPosition)
|
||||
{
|
||||
{
|
||||
code->cursor.selection = code->cursor.position;
|
||||
code->cursor.mouseDownPosition = code->cursor.position;
|
||||
}
|
||||
|
@ -1352,7 +1368,7 @@ static void textEditTick(Code* code)
|
|||
switch(event->type)
|
||||
{
|
||||
case SDL_MOUSEWHEEL:
|
||||
{
|
||||
{
|
||||
enum{Scroll = 3};
|
||||
s32 delta = event->wheel.y > 0 ? -Scroll : Scroll;
|
||||
|
||||
|
@ -1368,11 +1384,11 @@ static void textEditTick(Code* code)
|
|||
|
||||
#if defined(__LINUX__)
|
||||
if(!(SDL_GetModState() & KMOD_LALT))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if(strlen(event->text.text) == 1)
|
||||
{
|
||||
|
||||
|
||||
|
||||
inputSymbol(code, *event->text.text);
|
||||
updateEditor(code);
|
||||
|
@ -1392,12 +1408,14 @@ static void textEditTick(Code* code)
|
|||
|
||||
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));
|
||||
code->tic->api.fixed_text(code->tic, title, 0, TOOLBAR_SIZE, systemColor(tic_color_white));
|
||||
enum {TextY = TOOLBAR_SIZE + 1};
|
||||
|
||||
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)
|
||||
|
@ -1425,7 +1443,7 @@ static char* upStrStr(const char* start, const char* from, const char* substr)
|
|||
return (char*)ptr;
|
||||
|
||||
ptr--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -1446,9 +1464,9 @@ static void textFindTick(Code* code)
|
|||
case SDL_KEYDOWN:
|
||||
switch(event->key.keysym.sym)
|
||||
{
|
||||
case SDLK_RETURN:
|
||||
case SDLK_RETURN:
|
||||
setCodeMode(code, TEXT_EDIT_MODE);
|
||||
break;
|
||||
break;
|
||||
case SDLK_UP:
|
||||
case SDLK_LEFT:
|
||||
case SDLK_DOWN:
|
||||
|
@ -1474,7 +1492,7 @@ static void textFindTick(Code* code)
|
|||
}
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
if(strlen(event->text.text) == 1)
|
||||
if(strlen(event->text.text) == 1)
|
||||
{
|
||||
if(strlen(code->popup.text) + 1 < sizeof code->popup.text)
|
||||
{
|
||||
|
@ -1523,7 +1541,7 @@ static void textGoToTick(Code* code)
|
|||
case SDL_KEYDOWN:
|
||||
switch(event->key.keysym.sym)
|
||||
{
|
||||
case SDLK_RETURN:
|
||||
case SDLK_RETURN:
|
||||
if(*code->popup.text)
|
||||
updateGotoCode(code);
|
||||
|
||||
|
@ -1540,7 +1558,7 @@ static void textGoToTick(Code* code)
|
|||
}
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
if(strlen(event->text.text) == 1)
|
||||
if(strlen(event->text.text) == 1)
|
||||
{
|
||||
char sym = *event->text.text;
|
||||
|
||||
|
@ -1558,7 +1576,7 @@ static void textGoToTick(Code* code)
|
|||
code->tic->api.clear(code->tic, getConfig()->theme.code.bg);
|
||||
|
||||
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);
|
||||
|
||||
drawCode(code, false);
|
||||
|
@ -1583,7 +1601,7 @@ static void drawOutlineBar(Code* code, s32 x, s32 y)
|
|||
{
|
||||
code->outline.index = mx;
|
||||
updateOutlineCode(code);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
|
||||
|
@ -1591,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;
|
||||
|
||||
|
@ -1599,16 +1617,16 @@ static void drawOutlineBar(Code* code, s32 x, s32 y)
|
|||
|
||||
if(ptr->pos)
|
||||
{
|
||||
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));
|
||||
code->tic->api.rect(code->tic, rect.x - 1, rect.y + code->outline.index*STUDIO_TEXT_HEIGHT,
|
||||
rect.w + 1, TIC_FONT_HEIGHT + 1, (tic_color_red));
|
||||
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++;
|
||||
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)
|
||||
|
@ -1621,21 +1639,21 @@ static void textOutlineTick(Code* code)
|
|||
case SDL_KEYDOWN:
|
||||
switch(event->key.keysym.sym)
|
||||
{
|
||||
case SDLK_UP:
|
||||
case SDLK_UP:
|
||||
if(code->outline.index > 0)
|
||||
{
|
||||
code->outline.index--;
|
||||
updateOutlineCode(code);
|
||||
}
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
case SDLK_DOWN:
|
||||
if(code->outline.index < OUTLINE_SIZE - 1 && code->outline.items[code->outline.index + 1].pos)
|
||||
{
|
||||
code->outline.index++;
|
||||
updateOutlineCode(code);
|
||||
}
|
||||
break;
|
||||
case SDLK_RETURN:
|
||||
case SDLK_RETURN:
|
||||
updateOutlineCode(code);
|
||||
setCodeMode(code, TEXT_EDIT_MODE);
|
||||
break;
|
||||
|
@ -1650,7 +1668,7 @@ static void textOutlineTick(Code* code)
|
|||
}
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
if(strlen(event->text.text) == 1)
|
||||
if(strlen(event->text.text) == 1)
|
||||
{
|
||||
if(strlen(code->popup.text) + 1 < sizeof code->popup.text)
|
||||
{
|
||||
|
@ -1673,10 +1691,19 @@ static void textOutlineTick(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[] =
|
||||
{
|
||||
0b00000000,
|
||||
0b00100000,
|
||||
0b00110000,
|
||||
0b00111000,
|
||||
0b00110000,
|
||||
0b00100000,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
|
||||
0b00000000,
|
||||
0b00111000,
|
||||
0b01000100,
|
||||
|
@ -1708,7 +1735,7 @@ static void drawCodeToolbar(Code* code)
|
|||
enum {Count = sizeof Icons / BITS_IN_BYTE};
|
||||
enum {Size = 7};
|
||||
|
||||
static const char* Tips[] = {"FIND [ctrl+f]", "GOTO [ctrl+g]", "OUTLINE [ctrl+o]"};
|
||||
static const char* Tips[] = {"RUN [ctrl+r]","FIND [ctrl+f]", "GOTO [ctrl+g]", "OUTLINE [ctrl+o]"};
|
||||
|
||||
for(s32 i = 0; i < Count; i++)
|
||||
{
|
||||
|
@ -1725,18 +1752,25 @@ static void drawCodeToolbar(Code* code)
|
|||
|
||||
if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
|
||||
{
|
||||
s32 mode = TEXT_FIND_MODE + i;
|
||||
if (i == TEXT_RUN_CODE)
|
||||
{
|
||||
runProject();
|
||||
}
|
||||
else
|
||||
{
|
||||
s32 mode = TEXT_EDIT_MODE + i;
|
||||
|
||||
if(code->mode == mode) code->escape(code);
|
||||
else setCodeMode(code, mode);
|
||||
if(code->mode == mode) code->escape(code);
|
||||
else setCodeMode(code, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool active = i == code->mode - TEXT_FIND_MODE;
|
||||
bool active = i == code->mode - TEXT_EDIT_MODE && i != 0;
|
||||
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);
|
||||
|
@ -1751,6 +1785,7 @@ static void tick(Code* code)
|
|||
|
||||
switch(code->mode)
|
||||
{
|
||||
case TEXT_RUN_CODE: runProject(); break;
|
||||
case TEXT_EDIT_MODE: textEditTick(code); break;
|
||||
case TEXT_FIND_MODE: textFindTick(code); break;
|
||||
case TEXT_GOTO_MODE: textGoToTick(code); break;
|
||||
|
@ -1803,19 +1838,19 @@ void initCode(Code* code, tic_mem* tic)
|
|||
.tick = tick,
|
||||
.escape = escape,
|
||||
.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},
|
||||
.tickCounter = 0,
|
||||
.history = NULL,
|
||||
.cursorHistory = NULL,
|
||||
.mode = TEXT_EDIT_MODE,
|
||||
.jump = {.line = -1},
|
||||
.popup =
|
||||
.popup =
|
||||
{
|
||||
.prevPos = NULL,
|
||||
.prevSel = NULL,
|
||||
},
|
||||
.outline =
|
||||
.outline =
|
||||
{
|
||||
.items = code->outline.items,
|
||||
.index = 0,
|
||||
|
|
|
@ -72,6 +72,7 @@ struct Code
|
|||
|
||||
enum
|
||||
{
|
||||
TEXT_RUN_CODE,
|
||||
TEXT_EDIT_MODE,
|
||||
TEXT_FIND_MODE,
|
||||
TEXT_GOTO_MODE,
|
||||
|
|
18
src/config.c
18
src/config.c
|
@ -85,23 +85,6 @@ static void readCursorTheme(Config* config, lua_State* lua)
|
|||
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)
|
||||
{
|
||||
lua_getfield(lua, -1, "CODE");
|
||||
|
@ -154,7 +137,6 @@ static void readTheme(Config* config, lua_State* lua)
|
|||
|
||||
if(lua_type(lua, -1) == LUA_TTABLE)
|
||||
{
|
||||
readPaletteMapTheme(config, lua);
|
||||
readCursorTheme(config, lua);
|
||||
readCodeTheme(config, lua);
|
||||
readGamepadTheme(config, lua);
|
||||
|
|
221
src/console.c
221
src/console.c
|
@ -29,10 +29,10 @@
|
|||
|
||||
#include <zlib.h>
|
||||
|
||||
#define CONSOLE_CURSOR_COLOR (systemColor(tic_color_red))
|
||||
#define CONSOLE_BACK_TEXT_COLOR (systemColor(tic_color_dark_gray))
|
||||
#define CONSOLE_FRONT_TEXT_COLOR (systemColor(tic_color_white))
|
||||
#define CONSOLE_ERROR_TEXT_COLOR (systemColor(tic_color_red))
|
||||
#define CONSOLE_CURSOR_COLOR ((tic_color_red))
|
||||
#define CONSOLE_BACK_TEXT_COLOR ((tic_color_dark_gray))
|
||||
#define CONSOLE_FRONT_TEXT_COLOR ((tic_color_white))
|
||||
#define CONSOLE_ERROR_TEXT_COLOR ((tic_color_red))
|
||||
#define CONSOLE_CURSOR_BLINK_PERIOD (TIC_FRAMERATE)
|
||||
#define CONSOLE_CURSOR_DELAY (TIC_FRAMERATE / 2)
|
||||
#define CONSOLE_BUFFER_WIDTH (STUDIO_TEXT_BUFFER_WIDTH)
|
||||
|
@ -122,7 +122,7 @@ static void consolePrint(Console* console, const char* text, u8 color)
|
|||
console->cursor.x = 0;
|
||||
console->cursor.y++;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
s32 offset = console->cursor.x + console->cursor.y * CONSOLE_BUFFER_WIDTH;
|
||||
*(console->buffer + offset) = symbol;
|
||||
|
@ -182,7 +182,7 @@ static void drawCursor(Console* console, s32 x, s32 y, u8 symbol)
|
|||
|
||||
if(inverse)
|
||||
console->tic->api.rect(console->tic, x-1, y-1, TIC_FONT_WIDTH+1, TIC_FONT_HEIGHT+1, CONSOLE_CURSOR_COLOR);
|
||||
|
||||
|
||||
console->tic->api.draw_char(console->tic, symbol, x, y, inverse ? TIC_COLOR_BG : CONSOLE_FRONT_TEXT_COLOR);
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ static void processConsoleDel(Console* console)
|
|||
{
|
||||
char* pos = console->inputBuffer + console->inputPosition;
|
||||
size_t size = strlen(pos);
|
||||
memmove(pos, pos + 1, size);
|
||||
memmove(pos, pos + 1, size);
|
||||
}
|
||||
|
||||
static void processConsoleBackspace(Console* console)
|
||||
|
@ -269,7 +269,7 @@ static void processConsoleBackspace(Console* console)
|
|||
{
|
||||
console->inputPosition--;
|
||||
|
||||
processConsoleDel(console);
|
||||
processConsoleDel(console);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param)
|
|||
|
||||
if(param)
|
||||
{
|
||||
static const char* Sections[] =
|
||||
static const char* Sections[] =
|
||||
{
|
||||
"sprites",
|
||||
"map",
|
||||
|
@ -416,21 +416,21 @@ static void* getDemoCart(Console* console, tic_script_lang script, s32* size)
|
|||
return data;
|
||||
}
|
||||
|
||||
static const u8 LuaDemoRom[] =
|
||||
static const u8 LuaDemoRom[] =
|
||||
{
|
||||
#include "../bin/assets/luademo.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 JsDemoRom[] =
|
||||
static const u8 JsDemoRom[] =
|
||||
{
|
||||
#include "../bin/assets/jsdemo.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 MoonDemoRom[] =
|
||||
static const u8 MoonDemoRom[] =
|
||||
{
|
||||
#include "../bin/assets/moondemo.tic.dat"
|
||||
};
|
||||
|
||||
|
||||
const u8* demo = NULL;
|
||||
s32 romSize = 0;
|
||||
|
||||
|
@ -467,7 +467,7 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para
|
|||
s32 size = 0;
|
||||
|
||||
console->showGameMenu = false;
|
||||
|
||||
|
||||
if(strcmp(param, DefaultLuaTicPath) == 0)
|
||||
data = getDemoCart(console, tic_script_lua, &size);
|
||||
else if(strcmp(param, DefaultMoonTicPath) == 0)
|
||||
|
@ -499,7 +499,7 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param)
|
|||
s32 size = 0;
|
||||
const char* name = getRomName(param);
|
||||
|
||||
void* data = strcmp(name, CONFIG_TIC_PATH) == 0
|
||||
void* data = strcmp(name, CONFIG_TIC_PATH) == 0
|
||||
? fsLoadRootFile(console->fs, name, &size)
|
||||
: fsLoadFile(console->fs, name, &size);
|
||||
|
||||
|
@ -568,7 +568,7 @@ static void onConsoleLoadDemoCommand(Console* console, const char* param)
|
|||
{
|
||||
if(studioCartChanged())
|
||||
{
|
||||
static const char* Rows[] =
|
||||
static const char* Rows[] =
|
||||
{
|
||||
"YOU HAVE",
|
||||
"UNSAVED CHANGES",
|
||||
|
@ -589,7 +589,7 @@ static void onConsoleLoadCommand(Console* console, const char* param)
|
|||
{
|
||||
if(studioCartChanged())
|
||||
{
|
||||
static const char* Rows[] =
|
||||
static const char* Rows[] =
|
||||
{
|
||||
"YOU HAVE",
|
||||
"UNSAVED CHANGES",
|
||||
|
@ -615,7 +615,7 @@ static void loadDemo(Console* console, tic_script_lang script)
|
|||
{
|
||||
loadRom(console->tic, data, size, false);
|
||||
|
||||
SDL_free(data);
|
||||
SDL_free(data);
|
||||
}
|
||||
|
||||
SDL_memset(console->romName, 0, sizeof console->romName);
|
||||
|
@ -651,7 +651,7 @@ static void onConsoleNewCommand(Console* console, const char* param)
|
|||
{
|
||||
if(studioCartChanged())
|
||||
{
|
||||
static const char* Rows[] =
|
||||
static const char* Rows[] =
|
||||
{
|
||||
"YOU HAVE",
|
||||
"UNSAVED CHANGES",
|
||||
|
@ -779,42 +779,42 @@ static void installDemoCart(FileSystem* fs, const char* name, const void* cart,
|
|||
|
||||
static void onConsoleInstallDemosCommand(Console* console, const char* param)
|
||||
{
|
||||
static const u8 DemoFire[] =
|
||||
static const u8 DemoFire[] =
|
||||
{
|
||||
#include "../bin/assets/fire.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 DemoP3D[] =
|
||||
static const u8 DemoP3D[] =
|
||||
{
|
||||
#include "../bin/assets/p3d.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 DemoSFX[] =
|
||||
static const u8 DemoSFX[] =
|
||||
{
|
||||
#include "../bin/assets/sfx.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 DemoPalette[] =
|
||||
static const u8 DemoPalette[] =
|
||||
{
|
||||
#include "../bin/assets/palette.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 DemoFont[] =
|
||||
static const u8 DemoFont[] =
|
||||
{
|
||||
#include "../bin/assets/font.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 DemoMusic[] =
|
||||
static const u8 DemoMusic[] =
|
||||
{
|
||||
#include "../bin/assets/music.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 GameQuest[] =
|
||||
static const u8 GameQuest[] =
|
||||
{
|
||||
#include "../bin/assets/quest.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 GameTetris[] =
|
||||
static const u8 GameTetris[] =
|
||||
{
|
||||
#include "../bin/assets/tetris.tic.dat"
|
||||
};
|
||||
|
@ -942,7 +942,7 @@ static void onImportCover(const char* name, const void* buffer, size_t size, voi
|
|||
|
||||
printLine(console);
|
||||
printBack(console, name);
|
||||
printBack(console, " successfully imported");
|
||||
printBack(console, " successfully imported");
|
||||
}
|
||||
else printError(console, "\ncover image too big :(");
|
||||
}
|
||||
|
@ -950,9 +950,9 @@ static void onImportCover(const char* name, const void* buffer, size_t size, voi
|
|||
|
||||
gif_close(image);
|
||||
}
|
||||
else printError(console, "\nfile importing error :(");
|
||||
else printError(console, "\nfile importing error :(");
|
||||
}
|
||||
else printBack(console, "\nonly .gif files can be imported :|");
|
||||
else printBack(console, "\nonly .gif files can be imported :|");
|
||||
}
|
||||
else printBack(console, "\nfile not imported :|");
|
||||
|
||||
|
@ -963,9 +963,6 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v
|
|||
{
|
||||
Console* console = (Console*)data;
|
||||
|
||||
tic_palette pal;
|
||||
memcpy(&pal, console->tic->ram.vram.palette.data, sizeof(tic_palette));
|
||||
|
||||
if(name)
|
||||
{
|
||||
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];
|
||||
const gif_color* c = &image->palette[src];
|
||||
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);
|
||||
}
|
||||
|
@ -1006,12 +1003,10 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v
|
|||
}
|
||||
else printError(console, "\nfile importing error :(");
|
||||
}
|
||||
else printBack(console, "\nonly .gif files can be imported :|");
|
||||
else printBack(console, "\nonly .gif files can be imported :|");
|
||||
}
|
||||
else printBack(console, "\nfile not imported :|");
|
||||
|
||||
memcpy(console->tic->ram.vram.palette.data, &pal, sizeof(tic_palette));
|
||||
|
||||
commandDone(console);
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1086,7 @@ static void exportCover(Console* console)
|
|||
else
|
||||
{
|
||||
printBack(console, "\ncover image is empty, run game and\npress [F7] to assign cover image");
|
||||
commandDone(console);
|
||||
commandDone(console);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1215,7 +1210,7 @@ typedef struct
|
|||
const char* cartName;
|
||||
} AppFileReadParam;
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
u8* data;
|
||||
size_t size;
|
||||
|
@ -1272,7 +1267,7 @@ static void onConsoleExportHtmlCommand(Console* console, const char* name)
|
|||
writeMemoryString(&output, "<script type='text/javascript'>\n");
|
||||
|
||||
u8* buffer = (u8*)SDL_malloc(sizeof(tic_cartridge));
|
||||
|
||||
|
||||
if(buffer)
|
||||
{
|
||||
writeMemoryString(&output, "var cartridge = [");
|
||||
|
@ -1315,7 +1310,7 @@ static void onConsoleExportHtmlCommand(Console* console, const char* name)
|
|||
|
||||
fsGetFileData(onFileDownloaded, cartName, output.data, output.size, DEFAULT_CHMOD, console);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_free(EmbedIndex);
|
||||
|
@ -1381,7 +1376,7 @@ static bool exportToFolder(Console* console, const char* folder, const char* fil
|
|||
strcpy(dst, folder);
|
||||
strcat(dst, file);
|
||||
|
||||
return fsCopyFile(src, dst);
|
||||
return fsCopyFile(src, dst);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -1390,7 +1385,7 @@ static bool exportToFolder(Console* console, const char* folder, const char* fil
|
|||
static void onConsoleExportNativeCommand(Console* console, const char* cartName)
|
||||
{
|
||||
const char* folder = folder_dialog(console);
|
||||
bool done = false;
|
||||
bool done = false;
|
||||
|
||||
if(folder)
|
||||
{
|
||||
|
@ -1414,7 +1409,7 @@ static void onConsoleExportNativeCommand(Console* console, const char* cartName)
|
|||
}
|
||||
}
|
||||
|
||||
if(done && exportToFolder(console, folder, "\\tic80.dll") &&
|
||||
if(done && exportToFolder(console, folder, "\\tic80.dll") &&
|
||||
exportToFolder(console, folder, "\\SDL2.dll"))
|
||||
printBack(console, "\ngame exported :)");
|
||||
else printBack(console, "\ngame not exported :|");
|
||||
|
@ -1478,7 +1473,7 @@ static void onConsoleExportCommand(Console* console, const char* param)
|
|||
if(strcmp(param, "html") == 0) onConsoleExportHtmlCommand(console, getExportName(console, true));
|
||||
else
|
||||
{
|
||||
if(strcmp(param, "native") == 0)
|
||||
if(strcmp(param, "native") == 0)
|
||||
{
|
||||
#ifdef CAN_EXPORT
|
||||
onConsoleExportNativeCommand(console, getExportName(console, false));
|
||||
|
@ -1529,7 +1524,7 @@ static CartSaveResult saveCartName(Console* console, const char* name)
|
|||
{
|
||||
console->config->save(console->config);
|
||||
studioRomSaved();
|
||||
|
||||
|
||||
return CART_SAVE_OK;
|
||||
}
|
||||
else
|
||||
|
@ -1544,10 +1539,10 @@ static CartSaveResult saveCartName(Console* console, const char* name)
|
|||
success = true;
|
||||
studioRomSaved();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_free(buffer);
|
||||
SDL_free(buffer);
|
||||
}
|
||||
}
|
||||
else if (strlen(console->romName))
|
||||
|
@ -1555,7 +1550,7 @@ static CartSaveResult saveCartName(Console* console, const char* name)
|
|||
return saveCartName(console, console->romName);
|
||||
}
|
||||
else return CART_SAVE_MISSING_NAME;
|
||||
|
||||
|
||||
return success ? CART_SAVE_OK : CART_SAVE_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1574,9 +1569,9 @@ static void onConsoleSaveCommandConfirmed(Console* console, const char* param)
|
|||
printFront(console, console->romName);
|
||||
printBack(console, " saved!\n");
|
||||
}
|
||||
else if(rom == CART_SAVE_MISSING_NAME)
|
||||
else if(rom == CART_SAVE_MISSING_NAME)
|
||||
printBack(console, "\ncart name is missing\n");
|
||||
else
|
||||
else
|
||||
printBack(console, "\ncart saving error");
|
||||
|
||||
commandDone(console);
|
||||
|
@ -1586,7 +1581,7 @@ static void onConsoleSaveCommand(Console* console, const char* param)
|
|||
{
|
||||
if(param && strlen(param) && fsExistsFile(console->fs, getRomName(param)))
|
||||
{
|
||||
static const char* Rows[] =
|
||||
static const char* Rows[] =
|
||||
{
|
||||
"THE CART",
|
||||
"ALREADY EXISTS",
|
||||
|
@ -1672,24 +1667,24 @@ static void onConsoleDelCommandConfirmed(Console* console, const char* param)
|
|||
if(fsIsDir(console->fs, param))
|
||||
{
|
||||
printBack(console, fsDeleteDir(console->fs, param)
|
||||
? "\ndir not deleted"
|
||||
? "\ndir not deleted"
|
||||
: "\ndir successfully deleted");
|
||||
}
|
||||
else
|
||||
{
|
||||
printBack(console, fsDeleteFile(console->fs, param)
|
||||
? "\nfile not deleted"
|
||||
? "\nfile not deleted"
|
||||
: "\nfile successfully deleted");
|
||||
}
|
||||
}
|
||||
else printBack(console, "\nname is missing");
|
||||
else printBack(console, "\nname is missing");
|
||||
|
||||
commandDone(console);
|
||||
}
|
||||
|
||||
static void onConsoleDelCommand(Console* console, const char* param)
|
||||
{
|
||||
static const char* Rows[] =
|
||||
static const char* Rows[] =
|
||||
{
|
||||
"", "",
|
||||
"DO YOU REALLY WANT",
|
||||
|
@ -1717,7 +1712,7 @@ static void printTable(Console* console, const char* text)
|
|||
console->cursor.x = 0;
|
||||
console->cursor.y++;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
s32 offset = console->cursor.x + console->cursor.y * CONSOLE_BUFFER_WIDTH;
|
||||
*(console->buffer + offset) = symbol;
|
||||
|
@ -1729,10 +1724,10 @@ static void printTable(Console* console, const char* text)
|
|||
case '+':
|
||||
case '|':
|
||||
case '-':
|
||||
color = systemColor(tic_color_gray);
|
||||
color = (tic_color_gray);
|
||||
break;
|
||||
default:
|
||||
color = systemColor(tic_color_white);
|
||||
color = (tic_color_white);
|
||||
}
|
||||
|
||||
*(console->colorBuffer + offset) = color;
|
||||
|
@ -1805,7 +1800,7 @@ static void onConsoleRamCommand(Console* console, const char* param)
|
|||
commandDone(console);
|
||||
}
|
||||
|
||||
static const struct
|
||||
static const struct
|
||||
{
|
||||
const char* command;
|
||||
const char* alt;
|
||||
|
@ -1860,7 +1855,7 @@ static void processConsoleTab(Console* console)
|
|||
if(strlen(input))
|
||||
{
|
||||
char* param = SDL_strchr(input, ' ');
|
||||
|
||||
|
||||
if(param && strlen(++param))
|
||||
{
|
||||
fsEnumFiles(console->fs, predictFilename, param);
|
||||
|
@ -1878,8 +1873,8 @@ static void processConsoleTab(Console* console)
|
|||
console->inputPosition = strlen(input);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1980,7 +1975,7 @@ static void processCommand(Console* console, const char* command)
|
|||
if(param && !strlen(param)) param = NULL;
|
||||
|
||||
for(s32 i = 0; i < COUNT_OF(AvailableConsoleCommands); i++)
|
||||
if(tic_strcasecmp(command, AvailableConsoleCommands[i].command) == 0 ||
|
||||
if(tic_strcasecmp(command, AvailableConsoleCommands[i].command) == 0 ||
|
||||
(AvailableConsoleCommands[i].alt && tic_strcasecmp(command, AvailableConsoleCommands[i].alt) == 0))
|
||||
{
|
||||
if(AvailableConsoleCommands[i].handler)
|
||||
|
@ -2070,7 +2065,7 @@ static void processConsoleCommand(Console* console)
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -2087,7 +2082,7 @@ static void setScroll(Console* console, s32 val)
|
|||
console->scroll.pos = val;
|
||||
|
||||
if(console->scroll.pos < 0) console->scroll.pos = 0;
|
||||
if(console->scroll.pos > console->cursor.y) console->scroll.pos = console->cursor.y;
|
||||
if(console->scroll.pos > console->cursor.y) console->scroll.pos = console->cursor.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2117,13 +2112,13 @@ static void checkNewVersion(Console* console)
|
|||
NetVersion version = netVersionRequest(net);
|
||||
SDL_free(net);
|
||||
|
||||
if((version.major > TIC_VERSION_MAJOR) ||
|
||||
if((version.major > TIC_VERSION_MAJOR) ||
|
||||
(version.major == TIC_VERSION_MAJOR && version.minor > TIC_VERSION_MINOR) ||
|
||||
(version.major == TIC_VERSION_MAJOR && version.minor == TIC_VERSION_MINOR && version.patch > TIC_VERSION_PATCH))
|
||||
{
|
||||
char msg[FILENAME_MAX] = {0};
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2177,7 +2172,7 @@ static void tick(Console* console)
|
|||
}
|
||||
|
||||
scrollConsole(console);
|
||||
console->cursor.delay = CONSOLE_CURSOR_DELAY;
|
||||
console->cursor.delay = CONSOLE_CURSOR_DELAY;
|
||||
}
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
|
@ -2260,7 +2255,7 @@ static void tick(Console* console)
|
|||
drawConsoleInputText(console);
|
||||
}
|
||||
|
||||
console->tickCounter++;
|
||||
console->tickCounter++;
|
||||
}
|
||||
|
||||
static void cmdLoadCart(Console* console, const char* name)
|
||||
|
@ -2269,7 +2264,7 @@ static void cmdLoadCart(Console* console, const char* name)
|
|||
void* data = fsReadFile(name, &size);
|
||||
|
||||
if(data)
|
||||
{
|
||||
{
|
||||
loadCart(console->tic, &embed.file, data, size, true);
|
||||
embed.yes = true;
|
||||
|
||||
|
@ -2277,31 +2272,62 @@ static void cmdLoadCart(Console* console, const char* name)
|
|||
}
|
||||
}
|
||||
|
||||
static bool loadFileIntoBuffer(Console* console, char* buffer, const char* fileName)
|
||||
{
|
||||
s32 size = 0;
|
||||
void* contents = fsReadFile(fileName, &size);
|
||||
|
||||
if(contents)
|
||||
{
|
||||
memset(buffer, 0, TIC_CODE_SIZE);
|
||||
|
||||
if(size > TIC_CODE_SIZE)
|
||||
{
|
||||
char messageBuffer[256];
|
||||
sprintf(messageBuffer, "\n code is larger than %i symbols\n", TIC_CODE_SIZE);
|
||||
|
||||
printError(console, messageBuffer);
|
||||
}
|
||||
|
||||
memcpy(buffer, contents, SDL_min(size, TIC_CODE_SIZE-1));
|
||||
SDL_free(contents);
|
||||
|
||||
embed.yes = true;
|
||||
embed.fast = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void tryReloadCode(Console* console, char* codeBuffer)
|
||||
{
|
||||
if(console->codeLiveReload.active)
|
||||
{
|
||||
const char* fileName = console->codeLiveReload.fileName;
|
||||
loadFileIntoBuffer(console, codeBuffer, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
static void cmdInjectCode(Console* console, const char* param, const char* name)
|
||||
{
|
||||
if(strcmp(param, "-code") == 0)
|
||||
bool watch = strcmp(param, "-code-watch") == 0;
|
||||
if(watch || strcmp(param, "-code") == 0)
|
||||
{
|
||||
s32 size = 0;
|
||||
void* code = fsReadFile(name, &size);
|
||||
bool loaded = loadFileIntoBuffer(console, embed.file.code.data, name);
|
||||
|
||||
memset(embed.file.code.data, 0, sizeof(tic_code));
|
||||
|
||||
if(code)
|
||||
if(loaded)
|
||||
{
|
||||
if(size > TIC_CODE_SIZE)
|
||||
{
|
||||
char buffer[256];
|
||||
sprintf(buffer, "\n code is larger than %i symbols\n", TIC_CODE_SIZE);
|
||||
|
||||
printError(console, buffer);
|
||||
}
|
||||
|
||||
memcpy(embed.file.code.data, code, SDL_min(size, TIC_CODE_SIZE-1));
|
||||
SDL_free(code);
|
||||
|
||||
embed.yes = true;
|
||||
embed.fast = true;
|
||||
}
|
||||
|
||||
if(watch)
|
||||
{
|
||||
console->codeLiveReload.active = true;
|
||||
strcpy(console->codeLiveReload.fileName, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2313,7 +2339,7 @@ static void cmdInjectSprites(Console* console, const char* param, const char* na
|
|||
void* sprites = fsReadFile(name, &size);
|
||||
|
||||
if(sprites)
|
||||
{
|
||||
{
|
||||
gif_image* image = gif_read_data(sprites, size);
|
||||
|
||||
if (image)
|
||||
|
@ -2387,12 +2413,17 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config,
|
|||
.tick = tick,
|
||||
.save = saveCart,
|
||||
.cursor = {.x = 0, .y = 0, .delay = 0},
|
||||
.scroll =
|
||||
.scroll =
|
||||
{
|
||||
.pos = 0,
|
||||
.start = 0,
|
||||
.active = false,
|
||||
},
|
||||
.codeLiveReload =
|
||||
{
|
||||
.active = false,
|
||||
.reload = tryReloadCode,
|
||||
},
|
||||
.inputPosition = 0,
|
||||
.history = NULL,
|
||||
.historyHead = NULL,
|
||||
|
@ -2407,6 +2438,8 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config,
|
|||
memset(console->buffer, 0, CONSOLE_BUFFER_SIZE);
|
||||
memset(console->colorBuffer, TIC_COLOR_BG, CONSOLE_BUFFER_SIZE);
|
||||
|
||||
memset(console->codeLiveReload.fileName, 0, FILENAME_MAX);
|
||||
|
||||
if(argc)
|
||||
{
|
||||
strcpy(console->appPath, argv[0]);
|
||||
|
@ -2424,7 +2457,7 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config,
|
|||
if(argc > 1)
|
||||
{
|
||||
memcpy(embed.file.palette.data, tic->config.palette.data, sizeof(tic_palette));
|
||||
|
||||
|
||||
if (argc == 2) cmdLoadCart(console, argv[1]);
|
||||
else if (argc == 3)
|
||||
{
|
||||
|
@ -2475,9 +2508,9 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config,
|
|||
SDL_free(data);
|
||||
|
||||
EM_ASM_({Module._free($0);}, cartPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
console->active = !embed.yes;
|
||||
|
|
|
@ -57,10 +57,18 @@ struct Console
|
|||
{
|
||||
s32 pos;
|
||||
s32 start;
|
||||
|
||||
|
||||
bool active;
|
||||
} scroll;
|
||||
|
||||
struct
|
||||
{
|
||||
char fileName[FILENAME_MAX];
|
||||
bool active;
|
||||
|
||||
void(*reload)(Console*, char*);
|
||||
} codeLiveReload;
|
||||
|
||||
char* buffer;
|
||||
u8* colorBuffer;
|
||||
|
||||
|
|
34
src/dialog.c
34
src/dialog.c
|
@ -49,12 +49,12 @@ static void drawButton(Dialog* dlg, const char* label, s32 x, s32 y, u8 color, u
|
|||
|
||||
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
|
||||
{
|
||||
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, rect.w, rect.h, systemColor(tic_color_white));
|
||||
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, (tic_color_white));
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
drawBitIcon(rect.x-5, rect.y+3, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(rect.x-5, rect.y+2, Icon, systemColor(tic_color_white));
|
||||
drawBitIcon(rect.x-5, rect.y+3, Icon, (tic_color_black));
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -126,7 +126,7 @@ static void drawDialog(Dialog* dlg)
|
|||
rect.x -= dlg->pos.x;
|
||||
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))
|
||||
{
|
||||
|
@ -156,16 +156,16 @@ static void drawDialog(Dialog* dlg)
|
|||
dlg->drag.active = false;
|
||||
}
|
||||
|
||||
tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_blue));
|
||||
tic->api.rect_border(tic, rect.x, rect.y, rect.w, rect.h, systemColor(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.rect(tic, rect.x, rect.y-(TOOLBAR_SIZE-3), rect.w, TOOLBAR_SIZE-3, systemColor(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.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, (tic_color_white));
|
||||
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-2), rect.w, TOOLBAR_SIZE-2, (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!";
|
||||
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 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, systemColor(tic_color_white));
|
||||
tic->api.text(tic, dlg->text[i], x, y+1, (tic_color_black));
|
||||
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, "NO", rect.x + (Width/2 + 6), rect.y + 45, systemColor(tic_color_green), systemColor(tic_color_light_green), onNo, 1);
|
||||
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, (tic_color_green), (tic_color_light_green), onNo, 1);
|
||||
}
|
||||
|
||||
static void tick(Dialog* dlg)
|
||||
|
|
11
src/jsapi.c
11
src/jsapi.c
|
@ -200,7 +200,7 @@ static duk_ret_t duk_btn(duk_context* duk)
|
|||
else
|
||||
{
|
||||
s32 index = duk_to_int(duk, 0) & 0xf;
|
||||
duk_push_uint(duk, machine->memory.ram.vram.input.gamepad.data & (1 << index));
|
||||
duk_push_boolean(duk, machine->memory.ram.vram.input.gamepad.data & (1 << index));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -466,10 +466,9 @@ static duk_ret_t duk_memcpy(duk_context* duk)
|
|||
s32 dest = duk_to_int(duk, 0);
|
||||
s32 src = duk_to_int(duk, 1);
|
||||
s32 size = duk_to_int(duk, 2);
|
||||
s32 dstBound = sizeof(tic_ram) - size;
|
||||
s32 srcBound = sizeof(tic_mem) - size;
|
||||
s32 bound = sizeof(tic_ram) - size;
|
||||
|
||||
if(size > 0 && dest < dstBound && src < srcBound)
|
||||
if(size >= 0 && size <= sizeof(tic_ram) && dest >= 0 && src >= 0 && dest <= bound && src <= bound)
|
||||
{
|
||||
u8* base = (u8*)&getDukMachine(duk)->memory;
|
||||
memcpy(base + dest, base + src, size);
|
||||
|
@ -485,7 +484,7 @@ static duk_ret_t duk_memset(duk_context* duk)
|
|||
s32 size = duk_to_int(duk, 2);
|
||||
s32 bound = sizeof(tic_ram) - size;
|
||||
|
||||
if(size > 0 && dest < bound)
|
||||
if(size >= 0 && size <= sizeof(tic_ram) && dest >= 0 && dest <= bound)
|
||||
{
|
||||
u8* base = (u8*)&getDukMachine(duk)->memory;
|
||||
memset(base + dest, value, size);
|
||||
|
@ -747,7 +746,7 @@ static const struct{duk_c_function func; s32 params;} ApiFunc[] =
|
|||
{duk_circ, 4},
|
||||
{duk_circb, 4},
|
||||
{duk_tri, 7},
|
||||
{duk_textri,12},
|
||||
{duk_textri,14},
|
||||
{duk_clip, 4},
|
||||
{duk_music, 4},
|
||||
{duk_sync, 0},
|
||||
|
|
20
src/keymap.c
20
src/keymap.c
|
@ -56,7 +56,7 @@ static void drawPlayer(Keymap* keymap, s32 x, s32 y, s32 id)
|
|||
{
|
||||
char label[] = "PLAYER #%i";
|
||||
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;
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
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";
|
||||
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);
|
||||
|
@ -115,14 +115,14 @@ static void drawKeymap(Keymap* keymap)
|
|||
if(keymap->button < 0)
|
||||
{
|
||||
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
|
||||
{
|
||||
char label[256];
|
||||
sprintf(label, "PRESS A KEY FOR '%s'", ButtonNames[keymap->button % BUTTONS_COUNT]);
|
||||
drawCenterText(keymap, label, 120, systemColor(tic_color_white));
|
||||
drawCenterText(keymap, "ESC TO CANCEL", 126, systemColor(tic_color_white));
|
||||
drawCenterText(keymap, label, 120, (tic_color_white));
|
||||
drawCenterText(keymap, "ESC TO CANCEL", 126, (tic_color_white));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
11
src/luaapi.c
11
src/luaapi.c
|
@ -759,14 +759,13 @@ static s32 lua_memcpy(lua_State* lua)
|
|||
s32 dest = getLuaNumber(lua, 1);
|
||||
s32 src = getLuaNumber(lua, 2);
|
||||
s32 size = getLuaNumber(lua, 3);
|
||||
s32 dstBound = sizeof(tic_ram) - size;
|
||||
s32 srcBound = sizeof(tic_mem) - size;
|
||||
s32 bound = sizeof(tic_ram) - size;
|
||||
|
||||
if(dest < dstBound && src < srcBound)
|
||||
if(size >= 0 && size <= sizeof(tic_ram) && dest >= 0 && src >= 0 && dest <= bound && src <= bound)
|
||||
{
|
||||
u8* base = (u8*)&getLuaMachine(lua)->memory;
|
||||
memcpy(base + dest, base + src, size);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -786,11 +785,11 @@ static s32 lua_memset(lua_State* lua)
|
|||
s32 size = getLuaNumber(lua, 3);
|
||||
s32 bound = sizeof(tic_ram) - size;
|
||||
|
||||
if(dest < bound)
|
||||
if(size >= 0 && size <= sizeof(tic_ram) && dest >= 0 && dest <= bound)
|
||||
{
|
||||
u8* base = (u8*)&getLuaMachine(lua)->memory;
|
||||
memset(base + dest, value, size);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
56
src/map.c
56
src/map.c
|
@ -99,7 +99,7 @@ static s32 drawWorldButton(Map* map, s32 x, s32 y)
|
|||
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;
|
||||
|
||||
|
@ -137,7 +137,7 @@ static s32 drawGridButton(Map* map, s32 x, s32 y)
|
|||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ static void drawTileIndex(Map* map, s32 x, s32 y)
|
|||
|
||||
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))
|
||||
{
|
||||
|
@ -322,13 +322,13 @@ static void drawTileIndex(Map* map, s32 x, s32 y)
|
|||
{
|
||||
char buf[] = "#999";
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
|
@ -348,7 +348,7 @@ static void drawSheet(Map* map, s32 x, s32 y)
|
|||
|
||||
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))
|
||||
{
|
||||
|
@ -398,7 +398,7 @@ static void drawSheet(Map* map, s32 x, s32 y)
|
|||
s32 bw = map->sheet.rect.w * 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,12 +411,16 @@ static void drawCursorPos(Map* map, s32 x, s32 y)
|
|||
|
||||
sprintf(pos, "%03i:%03i", tx, ty);
|
||||
|
||||
x += (TIC_SPRITESIZE + 3);
|
||||
y -= (TIC_FONT_HEIGHT + 2);
|
||||
s32 width = map->tic->api.text(map->tic, pos, TIC80_WIDTH, 0, (tic_color_gray));
|
||||
|
||||
s32 width = map->tic->api.text(map->tic, pos, x, y, systemColor(tic_color_gray));
|
||||
map->tic->api.rect(map->tic, x - 1, y - 1, width + 1, TIC_FONT_HEIGHT + 1, systemColor(tic_color_white));
|
||||
map->tic->api.text(map->tic, pos, x, y, systemColor(tic_color_light_blue));
|
||||
s32 px = x + (TIC_SPRITESIZE + 3);
|
||||
if(px + width >= TIC80_WIDTH) px = x - (width + 2);
|
||||
|
||||
s32 py = y - (TIC_FONT_HEIGHT + 2);
|
||||
if(py <= TOOLBAR_SIZE) py = y + (TIC_SPRITESIZE + 3);
|
||||
|
||||
map->tic->api.rect(map->tic, px - 1, py - 1, width + 1, TIC_FONT_HEIGHT + 1, (tic_color_white));
|
||||
map->tic->api.text(map->tic, pos, px, py, (tic_color_light_blue));
|
||||
}
|
||||
|
||||
static void setMapSprite(Map* map, s32 x, s32 y)
|
||||
|
@ -451,7 +455,7 @@ static void drawTileCursor(Map* map)
|
|||
s32 height = map->sheet.rect.h * TIC_SPRITESIZE + 2;
|
||||
|
||||
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;
|
||||
|
@ -552,13 +556,13 @@ static void resetSelection(Map* map)
|
|||
static void drawSelectionRect(Map* map, s32 x, s32 y, s32 w, s32 h)
|
||||
{
|
||||
enum{Step = 3};
|
||||
u8 color = systemColor(tic_color_white);
|
||||
u8 color = (tic_color_white);
|
||||
|
||||
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 = 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 = (y+h-1); i >= y; i--) map->tic->api.pixel(map->tic, x, i, index++ % Step ? color : 0);
|
||||
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 = (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);}
|
||||
}
|
||||
|
||||
static void drawPasteData(Map* map)
|
||||
|
@ -863,8 +867,8 @@ static void drawMap(Map* map)
|
|||
s32 screenScrollX = map->scroll.x % TIC80_WIDTH;
|
||||
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, TIC80_WIDTH - screenScrollX, 0, TIC80_WIDTH - screenScrollX, TIC80_HEIGHT, 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, (tic_color_gray));
|
||||
}
|
||||
|
||||
if(!map->sheet.show && checkMousePos(&rect))
|
||||
|
@ -1109,7 +1113,7 @@ static void tick(Map* map)
|
|||
map->tic->api.clear(map->tic, TIC_COLOR_BG);
|
||||
|
||||
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);
|
||||
drawToolbar(map->tic, TIC_COLOR_BG, false);
|
||||
}
|
||||
|
@ -1127,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)
|
||||
{
|
||||
if(map->history) history_delete(map->history);
|
||||
|
@ -1167,6 +1176,7 @@ void initMap(Map* map, tic_mem* tic)
|
|||
},
|
||||
.history = history_create(&tic->cart.gfx.map, sizeof tic->cart.gfx.map),
|
||||
.event = onStudioEvent,
|
||||
.scanline = scanline,
|
||||
};
|
||||
|
||||
normalizeMap(&map->scroll.x, &map->scroll.y);
|
||||
|
|
|
@ -80,6 +80,7 @@ struct Map
|
|||
|
||||
void(*tick)(Map*);
|
||||
void(*event)(Map*, StudioEvent);
|
||||
void(*scanline)(tic_mem* tic, s32 row);
|
||||
};
|
||||
|
||||
void initMap(Map*, tic_mem*);
|
68
src/menu.c
68
src/menu.c
|
@ -24,7 +24,7 @@
|
|||
#include "fs.h"
|
||||
|
||||
#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[] =
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ static void drawDialog(Menu* menu)
|
|||
|
||||
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))
|
||||
{
|
||||
|
@ -110,16 +110,16 @@ static void drawDialog(Menu* menu)
|
|||
|
||||
rect = getRect(menu);
|
||||
|
||||
tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_blue));
|
||||
tic->api.rect_border(tic, rect.x, rect.y, rect.w, rect.h, systemColor(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.rect(tic, rect.x, rect.y-(TOOLBAR_SIZE-3), rect.w, TOOLBAR_SIZE-3, systemColor(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.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, (tic_color_white));
|
||||
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-2), rect.w, TOOLBAR_SIZE-2, (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";
|
||||
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.pixel(tic, x, y+Height-1, systemColor(tic_color_blue));
|
||||
tic->api.pixel(tic, x+Width-1, y+Height-1, systemColor(tic_color_blue));
|
||||
tic->api.rect(tic, x, y-1, Width, Height+1, (tic_color_dark_gray));
|
||||
tic->api.pixel(tic, x, y+Height-1, (tic_color_blue));
|
||||
tic->api.pixel(tic, x+Width-1, y+Height-1, (tic_color_blue));
|
||||
|
||||
{
|
||||
char buf[] = "#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};
|
||||
tic_mem* tic = menu->tic;
|
||||
|
||||
tic->api.rect(tic, x, y-2, Width, Height+2, systemColor(tic_color_white));
|
||||
tic->api.pixel(tic, x, y+Height-1, systemColor(tic_color_black));
|
||||
tic->api.pixel(tic, x+Width-1, y+Height-1, systemColor(tic_color_black));
|
||||
tic->api.rect(tic, x+1, y+Height, Width-2 , 1, systemColor(tic_color_black));
|
||||
tic->api.rect(tic, x, y-2, Width, Height+2, (tic_color_white));
|
||||
tic->api.pixel(tic, x, y+Height-1, (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, (tic_color_black));
|
||||
|
||||
{
|
||||
char buf[] = "#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)
|
||||
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->api.rect(tic, x, y, Width, Height, systemColor(tic_color_white));
|
||||
tic->api.pixel(tic, x, y, systemColor(tic_color_blue));
|
||||
tic->api.pixel(tic, x+Width-1, y, systemColor(tic_color_blue));
|
||||
tic->api.pixel(tic, x, y+Height-1, systemColor(tic_color_black));
|
||||
tic->api.pixel(tic, x+Width-1, y+Height-1, systemColor(tic_color_black));
|
||||
tic->api.rect(tic, x+1, y+Height, Width-2 , 1, systemColor(tic_color_black));
|
||||
tic->api.rect(tic, x, y, Width, Height, (tic_color_white));
|
||||
tic->api.pixel(tic, x, y, (tic_color_blue));
|
||||
tic->api.pixel(tic, x+Width-1, y, (tic_color_blue));
|
||||
tic->api.pixel(tic, x, y+Height-1, (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, (tic_color_black));
|
||||
|
||||
for(s32 i = 0; i < Tabs; i++)
|
||||
{
|
||||
|
@ -283,12 +283,12 @@ static void drawGamepadMenu(Menu* menu)
|
|||
|
||||
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
|
||||
{
|
||||
tic->api.text(tic, Label, rect.x, rect.y+1, systemColor(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+1, (tic_color_black));
|
||||
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,
|
||||
};
|
||||
|
||||
drawBitIcon(rect.x-7, rect.y+1, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(rect.x-7, rect.y, Icon, systemColor(tic_color_white));
|
||||
drawBitIcon(rect.x-7, rect.y+1, Icon, (tic_color_black));
|
||||
drawBitIcon(rect.x-7, rect.y, Icon, (tic_color_white));
|
||||
}
|
||||
|
||||
drawGamepadSetupTabs(menu, dlgRect.x+25, dlgRect.y+4);
|
||||
|
@ -349,12 +349,12 @@ static void drawMainMenu(Menu* menu)
|
|||
|
||||
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
|
||||
{
|
||||
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, systemColor(over ? tic_color_light_blue : tic_color_white));
|
||||
tic->api.text(tic, Rows[i], label.x, label.y+1, (tic_color_black));
|
||||
tic->api.text(tic, Rows[i], label.x, label.y, (over ? tic_color_light_blue : tic_color_white));
|
||||
}
|
||||
|
||||
if(i == menu->main.focus)
|
||||
|
@ -371,8 +371,8 @@ static void drawMainMenu(Menu* menu)
|
|||
0b00000000,
|
||||
};
|
||||
|
||||
drawBitIcon(label.x-7, label.y+1, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(label.x-7, label.y, Icon, systemColor(tic_color_white));
|
||||
drawBitIcon(label.x-7, label.y+1, Icon, (tic_color_black));
|
||||
drawBitIcon(label.x-7, label.y, Icon, (tic_color_white));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
68
src/music.c
68
src/music.c
|
@ -93,7 +93,7 @@ static void drawEditbox(Music* music, s32 x, s32 y, s32 value, void(*set)(Music*
|
|||
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)
|
||||
{
|
||||
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";
|
||||
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);
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
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;
|
||||
|
@ -187,13 +187,13 @@ static void drawSwitch(Music* music, s32 x, s32 y, const char* label, s32 value,
|
|||
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";
|
||||
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);
|
||||
}
|
||||
|
||||
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++)
|
||||
|
@ -1131,24 +1131,24 @@ static void drawTrackerFrames(Music* music, s32 x, s32 y)
|
|||
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)
|
||||
{
|
||||
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";
|
||||
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)
|
||||
{
|
||||
char buf[] = "99";
|
||||
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 end = start + Rows;
|
||||
|
@ -1229,7 +1229,7 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
|
|||
|
||||
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
|
||||
|
@ -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)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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[] = "--------";
|
||||
|
@ -1268,8 +1268,8 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
|
|||
if (note >= NoteStart)
|
||||
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 DarkColors[] = { systemColor(tic_color_green), systemColor(tic_color_brown), systemColor(tic_color_dark_blue), systemColor(tic_color_dark_gray) };
|
||||
const u8 Colors[] = { (tic_color_light_green), (tic_color_orange), (tic_color_blue), (tic_color_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 };
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -1291,13 +1291,13 @@ static void drawTrackerChannel(Music* music, s32 x, s32 y, s32 channel)
|
|||
{
|
||||
s32 col = music->tracker.col % CHANNEL_COLS;
|
||||
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.draw_char(music->tic, rowStr[col], colx + 1, rowy, systemColor(tic_color_black));
|
||||
music->tic->api.rect(music->tic, colx, rowy - 1, TIC_FONT_WIDTH + 1, TIC_FONT_HEIGHT + 1, (tic_color_red));
|
||||
music->tic->api.draw_char(music->tic, rowStr[col], colx + 1, rowy, (tic_color_black));
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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
|
||||
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])
|
||||
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)
|
||||
{
|
||||
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);
|
||||
drawModeTabs(music);
|
||||
|
@ -1489,10 +1489,10 @@ static void drawPianoLayout(Music* music)
|
|||
SDL_Event* event = NULL;
|
||||
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...";
|
||||
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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1592,7 +1592,7 @@ static void tick(Music* 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)
|
||||
|
|
74
src/sfx.c
74
src/sfx.c
|
@ -63,7 +63,7 @@ static void drawSwitch(Sfx* sfx, s32 x, s32 y, const char* label, s32 value, voi
|
|||
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;
|
||||
|
@ -78,13 +78,13 @@ static void drawSwitch(Sfx* sfx, s32 x, s32 y, const char* label, s32 value, voi
|
|||
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";
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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};
|
||||
|
||||
|
@ -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,
|
||||
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};
|
||||
|
@ -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++)
|
||||
{
|
||||
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)
|
||||
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++)
|
||||
{
|
||||
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};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -328,7 +328,7 @@ static void drawCanvasTabs(Sfx* sfx, s32 x, s32 y)
|
|||
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;
|
||||
case SFX_ARPEGGIO_TAB:
|
||||
|
@ -345,7 +345,7 @@ static void drawCanvasTabs(Sfx* sfx, s32 x, s32 y)
|
|||
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;
|
||||
default: break;
|
||||
|
@ -354,7 +354,7 @@ static void drawCanvasTabs(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)
|
||||
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);
|
||||
|
||||
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};
|
||||
|
@ -409,26 +409,26 @@ static void drawCanvas(Sfx* sfx, s32 x, s32 y)
|
|||
case SFX_VOLUME_TAB:
|
||||
{
|
||||
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;
|
||||
case SFX_ARPEGGIO_TAB:
|
||||
{
|
||||
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;
|
||||
case SFX_PITCH_TAB:
|
||||
{
|
||||
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),
|
||||
CANVAS_SIZE-1, CANVAS_SIZE-1, systemColor(tic_color_red));
|
||||
CANVAS_SIZE-1, CANVAS_SIZE-1, (tic_color_red));
|
||||
}
|
||||
break;
|
||||
case SFX_WAVE_TAB:
|
||||
{
|
||||
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;
|
||||
default: break;
|
||||
|
@ -440,7 +440,7 @@ static void drawCanvas(Sfx* sfx, s32 x, s32 y)
|
|||
if(loop->start > 0 || loop->size > 0)
|
||||
{
|
||||
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)
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
|
@ -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])
|
||||
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)
|
||||
{
|
||||
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};
|
||||
s32 x = TIC80_WIDTH - Width - TIC_SPRITESIZE*3;
|
||||
|
@ -825,7 +825,7 @@ static void drawSfxToolbar(Sfx* sfx)
|
|||
char buf[] = "C#4";
|
||||
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);
|
||||
|
@ -854,13 +854,13 @@ static void envelopesTick(Sfx* sfx)
|
|||
drawSfxToolbar(sfx);
|
||||
drawToolbar(sfx->tic, TIC_COLOR_BG, false);
|
||||
|
||||
drawTopPanel(sfx, Start, TOOLBAR_SIZE + Gap - 1);
|
||||
drawCanvasTabs(sfx, Start-Gap, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT+1);
|
||||
drawTopPanel(sfx, Start, TOOLBAR_SIZE + Gap);
|
||||
drawCanvasTabs(sfx, Start-Gap, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT+2);
|
||||
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);
|
||||
drawCanvas(sfx, Start-1, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT);
|
||||
drawLoopPanel(sfx, Gap, TOOLBAR_SIZE + Gap + TIC_FONT_HEIGHT+92);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -898,10 +898,10 @@ static void drawWaveformBar(Sfx* sfx, s32 x, s32 y)
|
|||
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)
|
||||
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);
|
||||
|
@ -909,7 +909,7 @@ static void drawWaveformBar(Sfx* sfx, s32 x, s32 y)
|
|||
for(s32 i = 0; i < ENVELOPE_VALUES/Scale; i++)
|
||||
{
|
||||
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};
|
||||
|
||||
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)
|
||||
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);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
151
src/sprite.c
151
src/sprite.c
|
@ -56,7 +56,7 @@ static s32 getIndexPosY(Sprite* sprite)
|
|||
static void drawSelection(Sprite* sprite, s32 x, s32 y, s32 w, s32 h)
|
||||
{
|
||||
enum{Step = 3};
|
||||
u8 color = systemColor(tic_color_white);
|
||||
u8 color = (tic_color_white);
|
||||
|
||||
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++;
|
||||
|
@ -75,8 +75,8 @@ static SDL_Rect getSpriteRect(Sprite* sprite)
|
|||
|
||||
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-1, y-1, w+2, h+2, systemColor(tic_color_white));
|
||||
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, (tic_color_white));
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
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 + 6, offset + 2, Count - i, 1, 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, (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);
|
||||
sprite->tic->api.rect(sprite->tic, x, offset, Size, Size, systemColor(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, offset, Size, Size, (tic_color_black));
|
||||
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)
|
||||
|
@ -362,13 +362,13 @@ static void drawCanvas(Sprite* sprite, s32 x, s32 y)
|
|||
|
||||
s32 ix = x + (CANVAS_SIZE - 4*TIC_FONT_WIDTH)/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, systemColor(tic_color_white));
|
||||
sprite->tic->api.text(sprite->tic, buf, ix, iy+1, (tic_color_black));
|
||||
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(sprite->tic, x, y, CANVAS_SIZE, CANVAS_SIZE, systemColor(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_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, (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);
|
||||
s32 r = rect.x + rect.w;
|
||||
|
@ -506,18 +506,13 @@ static void drawMoveButtons(Sprite* 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)
|
||||
{
|
||||
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;
|
||||
*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, Size, 1, systemColor(tic_color_white));
|
||||
sprite->tic->api.rect(sprite->tic, x, y+1, Size, 1, (tic_color_black));
|
||||
sprite->tic->api.rect(sprite->tic, x, y, Size, 1, (tic_color_white));
|
||||
|
||||
{
|
||||
s32 offset = x + *value * (Size-1) / Max - 1;
|
||||
drawBitIcon(offset, y, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(offset, y-1, Icon, systemColor(tic_color_white));
|
||||
drawBitIcon(offset, y, Icon, (tic_color_black));
|
||||
drawBitIcon(offset, y-1, Icon, (tic_color_white));
|
||||
sprite->tic->api.pixel(sprite->tic, offset+1, y, sprite->color);
|
||||
}
|
||||
|
||||
{
|
||||
char buf[] = "FF";
|
||||
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;
|
||||
|
||||
if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
|
||||
{
|
||||
(*value)--;
|
||||
updateCartPalette(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
if(down)
|
||||
{
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_white));
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_white));
|
||||
}
|
||||
else
|
||||
{
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(rect.x, rect.y, Icon, systemColor(tic_color_white));
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
|
||||
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;
|
||||
|
||||
if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
|
||||
{
|
||||
(*value)++;
|
||||
updateCartPalette(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
if(down)
|
||||
{
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_white));
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_white));
|
||||
}
|
||||
else
|
||||
{
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(rect.x, rect.y, Icon, systemColor(tic_color_white));
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
|
||||
drawBitIcon(rect.x, rect.y, Icon, (tic_color_white));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -682,17 +669,17 @@ static void drawRGBTools(Sprite* sprite, s32 x, s32 y)
|
|||
down = true;
|
||||
|
||||
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)
|
||||
{
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_light_blue));
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_light_blue));
|
||||
}
|
||||
else
|
||||
{
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(rect.x, rect.y, Icon, systemColor(over ? tic_color_light_blue : tic_color_white));
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
|
||||
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)
|
||||
{
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_light_blue));
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_light_blue));
|
||||
}
|
||||
else
|
||||
{
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(rect.x, rect.y, Icon, systemColor(over ? tic_color_light_blue : tic_color_white));
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
|
||||
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)};
|
||||
|
||||
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++)
|
||||
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 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, 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 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_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)
|
||||
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 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)
|
||||
{
|
||||
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
|
||||
{
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(rect.x, rect.y, Icon, systemColor(over ? tic_color_light_blue : tic_color_white));
|
||||
drawBitIcon(rect.x, rect.y+1, Icon, (tic_color_black));
|
||||
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};
|
||||
|
||||
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(sprite->tic, rect.x, rect.y, rect.w, rect.h, systemColor(tic_color_black));
|
||||
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, (tic_color_black));
|
||||
|
||||
if(checkMousePos(&rect))
|
||||
{
|
||||
|
@ -920,7 +907,7 @@ static void drawSheet(Sprite* sprite, s32 x, s32 y)
|
|||
s32 bx = getIndexPosX(sprite) + x - 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)
|
||||
{
|
||||
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
|
||||
{
|
||||
drawBitIcon(rect.x, y+1, Icons + i*BITS_IN_BYTE, systemColor(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+1, Icons + i*BITS_IN_BYTE, (tic_color_black));
|
||||
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,
|
||||
};
|
||||
|
||||
drawBitIcon(rect.x, y - 4, Icon, systemColor(tic_color_black));
|
||||
drawBitIcon(rect.x, y - 5, Icon, systemColor(tic_color_white));
|
||||
drawBitIcon(rect.x, y - 4, Icon, (tic_color_black));
|
||||
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
|
||||
{
|
||||
drawBitIcon(rect.x, y+1, Icons + i*BITS_IN_BYTE, systemColor(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+1, Icons + i*BITS_IN_BYTE, (tic_color_black));
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -1370,16 +1357,16 @@ static void drawSpriteToolbar(Sprite* sprite)
|
|||
}
|
||||
|
||||
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+1, 3, 21, 1, systemColor(tic_color_white));
|
||||
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, (tic_color_white));
|
||||
|
||||
s32 size = sprite->size / TIC_SPRITESIZE, val = 0;
|
||||
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+1 + val*6, 2, 3, 3, systemColor(tic_color_white));
|
||||
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, (tic_color_white));
|
||||
}
|
||||
|
||||
bool bg = sprite->index < TIC_BANK_SPRITES;
|
||||
|
@ -1387,8 +1374,8 @@ static void drawSpriteToolbar(Sprite* sprite)
|
|||
{
|
||||
static const char Label[] = "BG";
|
||||
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.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, systemColor(tic_color_white));
|
||||
sprite->tic->api.rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, bg ? (tic_color_black) : (tic_color_gray));
|
||||
sprite->tic->api.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, (tic_color_white));
|
||||
|
||||
if(checkMousePos(&rect))
|
||||
{
|
||||
|
@ -1407,8 +1394,8 @@ static void drawSpriteToolbar(Sprite* sprite)
|
|||
{
|
||||
static const char Label[] = "FG";
|
||||
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.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, systemColor(tic_color_white));
|
||||
sprite->tic->api.rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, bg ? (tic_color_gray) : (tic_color_black));
|
||||
sprite->tic->api.fixed_text(sprite->tic, Label, rect.x+1, rect.y+1, (tic_color_white));
|
||||
|
||||
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);
|
||||
drawMoveButtons(sprite);
|
||||
|
@ -1466,7 +1453,7 @@ static void tick(Sprite* sprite)
|
|||
drawSheet(sprite, TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, 7);
|
||||
|
||||
drawSpriteToolbar(sprite);
|
||||
drawToolbar(sprite->tic, systemColor(tic_color_gray), false);
|
||||
drawToolbar(sprite->tic, (tic_color_gray), false);
|
||||
|
||||
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)
|
||||
{
|
||||
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,
|
||||
.history = history_create(tic->cart.gfx.tiles, TIC_SPRITES * sizeof(tic_tile)),
|
||||
.event = onStudioEvent,
|
||||
.scanline = scanline,
|
||||
};
|
||||
}
|
|
@ -60,7 +60,8 @@ struct Sprite
|
|||
struct History* history;
|
||||
|
||||
void (*tick)(Sprite*);
|
||||
void(*event)(Sprite*, StudioEvent);
|
||||
void (*event)(Sprite*, StudioEvent);
|
||||
void (*scanline)(tic_mem* tic, s32 row);
|
||||
};
|
||||
|
||||
void initSprite(Sprite*, tic_mem*);
|
11
src/start.c
11
src/start.c
|
@ -26,7 +26,7 @@ static void reset(Start* start)
|
|||
{
|
||||
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};
|
||||
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)
|
||||
{
|
||||
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_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_COPYRIGHT, STUDIO_TEXT_WIDTH, STUDIO_TEXT_HEIGHT*2, systemColor(tic_color_dark_gray));
|
||||
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, (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)
|
||||
|
@ -100,7 +100,4 @@ void initStart(Start* start, tic_mem* tic)
|
|||
.tick = tick,
|
||||
.play = false,
|
||||
};
|
||||
|
||||
memcpy(tic->cart.palette.data, tic->config.palette.data, sizeof(tic_palette));
|
||||
tic->api.reset(tic);
|
||||
}
|
||||
|
|
241
src/studio.c
241
src/studio.c
|
@ -141,7 +141,7 @@ static struct
|
|||
struct
|
||||
{
|
||||
s32 counter;
|
||||
char message[STUDIO_TEXT_BUFFER_WIDTH];
|
||||
char message[STUDIO_TEXT_BUFFER_WIDTH];
|
||||
} popup;
|
||||
|
||||
struct
|
||||
|
@ -188,11 +188,11 @@ static struct
|
|||
|
||||
float* floatSamples;
|
||||
|
||||
} studio =
|
||||
} studio =
|
||||
{
|
||||
.tic80local = NULL,
|
||||
.tic = NULL,
|
||||
|
||||
|
||||
.window = NULL,
|
||||
.renderer = NULL,
|
||||
.texture = NULL,
|
||||
|
@ -205,7 +205,7 @@ static struct
|
|||
.prevMode = TIC_CODE_MODE,
|
||||
.dialogMode = TIC_CONSOLE_MODE,
|
||||
|
||||
.mouse =
|
||||
.mouse =
|
||||
{
|
||||
.cursor = {-1, -1},
|
||||
.button = 0,
|
||||
|
@ -221,11 +221,11 @@ static struct
|
|||
},
|
||||
|
||||
.keyboard = NULL,
|
||||
.keycodes =
|
||||
.keycodes =
|
||||
{
|
||||
SDL_SCANCODE_UP,
|
||||
SDL_SCANCODE_DOWN,
|
||||
SDL_SCANCODE_LEFT,
|
||||
SDL_SCANCODE_UP,
|
||||
SDL_SCANCODE_DOWN,
|
||||
SDL_SCANCODE_LEFT,
|
||||
SDL_SCANCODE_RIGHT,
|
||||
|
||||
SDL_SCANCODE_Z, // a
|
||||
|
@ -233,26 +233,26 @@ static struct
|
|||
SDL_SCANCODE_A, // x
|
||||
SDL_SCANCODE_S, // y
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
},
|
||||
|
||||
.gamepad =
|
||||
.gamepad =
|
||||
{
|
||||
.show = false,
|
||||
},
|
||||
|
||||
.popup =
|
||||
.popup =
|
||||
{
|
||||
.counter = 0,
|
||||
.message = "\0",
|
||||
},
|
||||
|
||||
.tooltip =
|
||||
.tooltip =
|
||||
{
|
||||
.text = "\0",
|
||||
},
|
||||
|
||||
.video =
|
||||
.video =
|
||||
{
|
||||
.record = false,
|
||||
.buffer = NULL,
|
||||
|
@ -278,10 +278,10 @@ static void md5(const void* voidData, s32 length, u8* digest)
|
|||
|
||||
const u8* data = voidData;
|
||||
|
||||
MD5_CTX c;
|
||||
MD5_CTX c;
|
||||
MD5_Init(&c);
|
||||
|
||||
while (length > 0)
|
||||
while (length > 0)
|
||||
{
|
||||
MD5_Update(&c, data, length > Size ? Size: length);
|
||||
|
||||
|
@ -331,13 +331,13 @@ void toClipboard(const void* data, s32 size, bool flip)
|
|||
{
|
||||
char tmp = ptr[0];
|
||||
ptr[0] = ptr[1];
|
||||
ptr[1] = tmp;
|
||||
ptr[1] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SetClipboardText(clipboard);
|
||||
SDL_free(clipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ void str2buf(const char* str, void* buf, bool flip)
|
|||
}
|
||||
else
|
||||
{
|
||||
val[2] = *ptr++;
|
||||
val[2] = *ptr++;
|
||||
val[3] = *ptr++;
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ bool fromClipboard(void* data, s32 size, bool flip)
|
|||
|
||||
return valid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -394,7 +394,7 @@ void showTooltip(const char* text)
|
|||
strcpy(studio.tooltip.text, text);
|
||||
}
|
||||
|
||||
static const EditorMode Modes[] =
|
||||
static const EditorMode Modes[] =
|
||||
{
|
||||
TIC_CODE_MODE,
|
||||
TIC_SPRITE_MODE,
|
||||
|
@ -466,8 +466,8 @@ void drawExtrabar(tic_mem* tic)
|
|||
{
|
||||
SDL_Rect rect = {x + i*Size, y, Size, Size};
|
||||
|
||||
u8 bgcolor = systemColor(tic_color_white);
|
||||
u8 color = systemColor(tic_color_light_blue);
|
||||
u8 bgcolor = (tic_color_white);
|
||||
u8 color = (tic_color_light_blue);
|
||||
|
||||
if(checkMousePos(&rect))
|
||||
{
|
||||
|
@ -479,7 +479,7 @@ void drawExtrabar(tic_mem* tic)
|
|||
if(checkMouseDown(&rect, SDL_BUTTON_LEFT))
|
||||
{
|
||||
bgcolor = color;
|
||||
color = systemColor(tic_color_white);
|
||||
color = (tic_color_white);
|
||||
}
|
||||
else if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
|
||||
{
|
||||
|
@ -497,15 +497,10 @@ const StudioConfig* getConfig()
|
|||
return &studio.config.data;
|
||||
}
|
||||
|
||||
u8 systemColor(u8 color)
|
||||
{
|
||||
return getConfig()->theme.palmap.data[color];
|
||||
}
|
||||
|
||||
void drawToolbar(tic_mem* tic, u8 color, bool 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[] =
|
||||
{
|
||||
|
@ -596,7 +591,7 @@ void drawToolbar(tic_mem* tic, u8 color, bool bg)
|
|||
if(mode == i)
|
||||
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);
|
||||
|
@ -610,15 +605,15 @@ void drawToolbar(tic_mem* tic, u8 color, bool bg)
|
|||
"MUSIC EDITOR",
|
||||
};
|
||||
|
||||
if(mode >= 0)
|
||||
if(mode >= 0)
|
||||
{
|
||||
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
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -682,7 +677,7 @@ void exitStudio()
|
|||
{
|
||||
if(studio.mode != TIC_START_MODE && studioCartChanged())
|
||||
{
|
||||
static const char* Rows[] =
|
||||
static const char* Rows[] =
|
||||
{
|
||||
"YOU HAVE",
|
||||
"UNSAVED CHANGES",
|
||||
|
@ -771,9 +766,7 @@ void setStudioMode(EditorMode mode)
|
|||
EditorMode prev = studio.mode;
|
||||
|
||||
if(prev == TIC_RUN_MODE)
|
||||
{
|
||||
studio.tic->api.pause(studio.tic);
|
||||
}
|
||||
|
||||
if(mode != TIC_RUN_MODE)
|
||||
studio.tic->api.reset(studio.tic);
|
||||
|
@ -783,7 +776,7 @@ void setStudioMode(EditorMode mode)
|
|||
case TIC_START_MODE:
|
||||
SDL_StartTextInput();
|
||||
case TIC_CONSOLE_MODE:
|
||||
case TIC_RUN_MODE:
|
||||
case TIC_RUN_MODE:
|
||||
case TIC_KEYMAP_MODE:
|
||||
case TIC_DIALOG_MODE:
|
||||
case TIC_MENU_MODE:
|
||||
|
@ -800,8 +793,8 @@ void setStudioMode(EditorMode mode)
|
|||
case TIC_RUN_MODE: initRunMode(); break;
|
||||
case TIC_SURF_MODE: studio.surf.resume(&studio.surf); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
studio.mode = mode;
|
||||
|
||||
if(prev == TIC_RUN_MODE)
|
||||
|
@ -809,7 +802,7 @@ void setStudioMode(EditorMode mode)
|
|||
else if ((prev == TIC_MENU_MODE || prev == TIC_SURF_MODE) && studio.mode != TIC_RUN_MODE)
|
||||
enableScreenTextInput();
|
||||
|
||||
if(SDL_HasScreenKeyboardSupport() &&
|
||||
if(SDL_HasScreenKeyboardSupport() &&
|
||||
(studio.mode == TIC_RUN_MODE || studio.mode == TIC_SURF_MODE || studio.mode == TIC_MENU_MODE))
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
|
@ -820,9 +813,11 @@ EditorMode getStudioMode()
|
|||
return studio.mode;
|
||||
}
|
||||
|
||||
void showGameMenu()
|
||||
static void showGameMenu()
|
||||
{
|
||||
studio.tic->api.pause(studio.tic);
|
||||
studio.tic->api.reset(studio.tic);
|
||||
|
||||
initMenuMode();
|
||||
studio.mode = TIC_MENU_MODE;
|
||||
}
|
||||
|
@ -852,8 +847,8 @@ bool checkMouseClick(const SDL_Rect* rect, s32 button)
|
|||
{
|
||||
MouseState* state = &studio.mouse.state[button - 1];
|
||||
|
||||
bool value = state->click
|
||||
&& SDL_PointInRect(&state->start, rect)
|
||||
bool value = state->click
|
||||
&& SDL_PointInRect(&state->start, rect)
|
||||
&& SDL_PointInRect(&state->end, rect);
|
||||
|
||||
if(value) state->click = false;
|
||||
|
@ -924,7 +919,7 @@ static void updateTitle()
|
|||
if(strlen(studio.console.romName))
|
||||
sprintf(name, "%s [%s]", TIC_TITLE, studio.console.romName);
|
||||
|
||||
SDL_SetWindowTitle(studio.window, name);
|
||||
SDL_SetWindowTitle(studio.window, name);
|
||||
}
|
||||
|
||||
void studioRomSaved()
|
||||
|
@ -1088,7 +1083,7 @@ static void processTouchGamepad()
|
|||
|
||||
{
|
||||
SDL_Rect a = {studio.gamepad.part.a.x, studio.gamepad.part.a.y, size, size};
|
||||
if(checkTouch(&a, &x, &y)) studio.gamepad.touch.first.a = true;
|
||||
if(checkTouch(&a, &x, &y)) studio.gamepad.touch.first.a = true;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1098,7 +1093,7 @@ static void processTouchGamepad()
|
|||
|
||||
{
|
||||
SDL_Rect xb = {studio.gamepad.part.x.x, studio.gamepad.part.x.y, size, size};
|
||||
if(checkTouch(&xb, &x, &y)) studio.gamepad.touch.first.x = true;
|
||||
if(checkTouch(&xb, &x, &y)) studio.gamepad.touch.first.x = true;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1227,7 +1222,7 @@ static void processJoysticks()
|
|||
gamepad->data |= getJoystickHatMask(getAxisMask(joystick));
|
||||
|
||||
for (s32 h = 0; h < SDL_JoystickNumHats(joystick); h++)
|
||||
gamepad->data |= getJoystickHatMask(SDL_JoystickGetHat(joystick, h));
|
||||
gamepad->data |= getJoystickHatMask(SDL_JoystickGetHat(joystick, h));
|
||||
|
||||
s32 numButtons = SDL_JoystickNumButtons(joystick);
|
||||
if(numButtons >= 2)
|
||||
|
@ -1278,11 +1273,11 @@ static void processJoysticks()
|
|||
static void processGamepad()
|
||||
{
|
||||
studio.tic->ram.vram.input.gamepad.data = 0;
|
||||
|
||||
|
||||
studio.tic->ram.vram.input.gamepad.data |= studio.gamepad.keyboard.data;
|
||||
studio.tic->ram.vram.input.gamepad.data |= studio.gamepad.touch.data;
|
||||
studio.tic->ram.vram.input.gamepad.data |= studio.gamepad.joystick.data;
|
||||
studio.tic->ram.vram.input.gamepad.data &= studio.tic->ram.vram.vars.mask.data |
|
||||
studio.tic->ram.vram.input.gamepad.data &= studio.tic->ram.vram.vars.mask.data |
|
||||
(studio.tic->ram.vram.vars.mask.data << (sizeof(tic80_gamepad)*BITS_IN_BYTE));
|
||||
}
|
||||
|
||||
|
@ -1351,10 +1346,10 @@ static void processMouse()
|
|||
static void onFullscreen()
|
||||
{
|
||||
studio.fullscreen = !studio.fullscreen;
|
||||
SDL_SetWindowFullscreen(studio.window, studio.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
SDL_SetWindowFullscreen(studio.window, studio.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
}
|
||||
|
||||
static void runProject()
|
||||
void runProject()
|
||||
{
|
||||
studio.tic->api.reset(studio.tic);
|
||||
|
||||
|
@ -1373,7 +1368,7 @@ static void saveProject()
|
|||
{
|
||||
char buffer[FILENAME_MAX];
|
||||
sprintf(buffer, "%s SAVED :)", studio.console.romName);
|
||||
|
||||
|
||||
for(s32 i = 0; i < (s32)strlen(buffer); i++)
|
||||
buffer[i] = SDL_toupper(buffer[i]);
|
||||
|
||||
|
@ -1390,7 +1385,7 @@ static u32* srcPaletteBlit(const u8* src)
|
|||
memset(pal, 0xff, sizeof 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)};
|
||||
|
||||
|
@ -1411,22 +1406,38 @@ static void blit(u32* out, u32* bgOut, s32 pitch, s32 bgPitch)
|
|||
const s32 pitchWidth = pitch/sizeof *out;
|
||||
const s32 bgPitchWidth = bgPitch/sizeof *bgOut;
|
||||
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)
|
||||
{
|
||||
|
||||
if(studio.mode == TIC_RUN_MODE || studio.mode == TIC_MENU_MODE)
|
||||
if(scanline)
|
||||
{
|
||||
studio.tic->api.scanline(studio.tic, r);
|
||||
scanline(studio.tic, r);
|
||||
pal = paletteBlit();
|
||||
}
|
||||
|
||||
if(bgOut)
|
||||
{
|
||||
u8 border = tic_tool_peek4(studio.tic->ram.vram.mapping, studio.tic->ram.vram.vars.border & 0xf);
|
||||
SDL_memset4(bgOut, pal[border], TIC80_WIDTH);
|
||||
bgOut += bgPitchWidth;
|
||||
}
|
||||
if(bgOut)
|
||||
{
|
||||
u8 border = tic_tool_peek4(studio.tic->ram.vram.mapping, studio.tic->ram.vram.vars.border & 0xf);
|
||||
SDL_memset4(bgOut, pal[border], TIC80_WIDTH);
|
||||
bgOut += bgPitchWidth;
|
||||
}
|
||||
|
||||
SDL_memset4(row, 0, pitchWidth);
|
||||
|
@ -1443,7 +1454,7 @@ static void screen2buffer(u32* buffer, const u8* pixels, s32 pitch)
|
|||
SDL_memcpy(buffer, pixels+MAX_OFFSET * sizeof(u32), TIC80_WIDTH * sizeof(u32));
|
||||
pixels += pitch;
|
||||
buffer += TIC80_WIDTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void setCoverImage()
|
||||
|
@ -1462,8 +1473,8 @@ static void setCoverImage()
|
|||
if(buffer)
|
||||
{
|
||||
screen2buffer(buffer, (const u8*)pixels, Pitch);
|
||||
|
||||
gif_write_animation(studio.tic->cart.cover.data, &studio.tic->cart.cover.size,
|
||||
|
||||
gif_write_animation(studio.tic->cart.cover.data, &studio.tic->cart.cover.size,
|
||||
TIC80_WIDTH, TIC80_HEIGHT, (const u8*)buffer, 1, TIC_FRAMERATE, 1);
|
||||
|
||||
SDL_free(buffer);
|
||||
|
@ -1545,7 +1556,7 @@ static bool processShortcuts(SDL_KeyboardEvent* event)
|
|||
|
||||
if(studio.mode == TIC_START_MODE) return true;
|
||||
if(studio.mode == TIC_CONSOLE_MODE && !studio.console.active) return true;
|
||||
|
||||
|
||||
if(isGameMenu())
|
||||
{
|
||||
switch(event->keysym.sym)
|
||||
|
@ -1555,7 +1566,7 @@ static bool processShortcuts(SDL_KeyboardEvent* event)
|
|||
studio.mode == TIC_MENU_MODE ? hideGameMenu() : showGameMenu();
|
||||
studio.gamepad.backProcessed = true;
|
||||
return true;
|
||||
case SDLK_F11:
|
||||
case SDLK_F11:
|
||||
onFullscreen();
|
||||
return true;
|
||||
case SDLK_RETURN:
|
||||
|
@ -1565,14 +1576,14 @@ static bool processShortcuts(SDL_KeyboardEvent* event)
|
|||
return true;
|
||||
}
|
||||
break;
|
||||
case SDLK_F7:
|
||||
case SDLK_F7:
|
||||
setCoverImage();
|
||||
return true;
|
||||
case SDLK_F8:
|
||||
case SDLK_F8:
|
||||
takeScreenshot();
|
||||
return true;
|
||||
#if !defined(__EMSCRIPTEN__)
|
||||
case SDLK_F9:
|
||||
case SDLK_F9:
|
||||
startVideoRecord();
|
||||
return true;
|
||||
#endif
|
||||
|
@ -1591,7 +1602,7 @@ static bool processShortcuts(SDL_KeyboardEvent* event)
|
|||
case SDLK_3: setStudioMode(TIC_MAP_MODE); return true;
|
||||
case SDLK_4: setStudioMode(TIC_SFX_MODE); return true;
|
||||
case SDLK_5: setStudioMode(TIC_MUSIC_MODE); return true;
|
||||
default: break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1608,8 +1619,8 @@ static bool processShortcuts(SDL_KeyboardEvent* event)
|
|||
#if !defined(__EMSCRIPTEN__)
|
||||
case SDLK_F9: startVideoRecord(); return true;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
switch(event->keysym.sym)
|
||||
|
@ -1686,7 +1697,7 @@ static void processGamepadInput()
|
|||
static void processMouseInput()
|
||||
{
|
||||
processJoysticksWithMouseInput();
|
||||
|
||||
|
||||
s32 x = studio.mouse.cursor.x;
|
||||
s32 y = studio.mouse.cursor.y;
|
||||
|
||||
|
@ -1698,7 +1709,7 @@ static void processMouseInput()
|
|||
studio.tic->ram.vram.input.gamepad.mouse = x + y * TIC80_WIDTH;
|
||||
studio.tic->ram.vram.input.gamepad.pressed = studio.mouse.state->down ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
SDL_Event* pollEvent()
|
||||
{
|
||||
static SDL_Event event;
|
||||
|
@ -1739,6 +1750,13 @@ SDL_Event* pollEvent()
|
|||
switch(event.window.event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_RESIZED: updateGamepadParts(); break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
{
|
||||
studio.console.codeLiveReload.reload(&studio.console,studio.code.data);
|
||||
if(studio.code.update)
|
||||
studio.code.update(&studio.code);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDL_FINGERUP:
|
||||
|
@ -1767,7 +1785,7 @@ SDL_Event* pollEvent()
|
|||
case tic_gamepad_input:
|
||||
processGamepadInput();
|
||||
break;
|
||||
|
||||
|
||||
case tic_mouse_input:
|
||||
processMouseInput();
|
||||
break;
|
||||
|
@ -1804,7 +1822,7 @@ static void transparentBlit(u32* out, s32 pitch)
|
|||
{
|
||||
col = 0;
|
||||
out += Delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1831,7 +1849,7 @@ static void blitSound()
|
|||
|
||||
static void drawRecordLabel(u8* frame, s32 pitch, s32 sx, s32 sy, const u32* color)
|
||||
{
|
||||
static const u16 RecLabel[] =
|
||||
static const u16 RecLabel[] =
|
||||
{
|
||||
0b0111001100110011,
|
||||
0b1111101010100100,
|
||||
|
@ -1839,14 +1857,14 @@ static void drawRecordLabel(u8* frame, s32 pitch, s32 sx, s32 sy, const u32* col
|
|||
0b1111101010100100,
|
||||
0b0111001010110011,
|
||||
};
|
||||
|
||||
|
||||
for(s32 y = 0; y < 5; y++)
|
||||
{
|
||||
for(s32 x = 0; x < sizeof RecLabel[0]*BITS_IN_BYTE; x++)
|
||||
{
|
||||
if(RecLabel[y] & (1 << x))
|
||||
memcpy(&frame[((MAX_OFFSET + sx) + 15 - x + (y+sy)*(pitch/4))*4], color, sizeof *color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1861,11 +1879,11 @@ static void recordFrame(u8* pixels, s32 pitch)
|
|||
if(studio.video.frame % TIC_FRAMERATE < TIC_FRAMERATE / 2)
|
||||
{
|
||||
const u32* pal = srcPaletteBlit(studio.tic->config.palette.data);
|
||||
drawRecordLabel(pixels, pitch, TIC80_WIDTH-24, 8, &pal[tic_color_red]);
|
||||
drawRecordLabel(pixels, pitch, TIC80_WIDTH-24, 8, &pal[tic_color_red]);
|
||||
}
|
||||
|
||||
studio.video.frame++;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1912,7 +1930,7 @@ static void blitTexture()
|
|||
|
||||
{
|
||||
SDL_Rect srcRect = {0, 0, FULL_WIDTH, TIC80_HEIGHT};
|
||||
SDL_RenderCopy(studio.renderer, studio.texture, &srcRect, &rect);
|
||||
SDL_RenderCopy(studio.renderer, studio.texture, &srcRect, &rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1972,7 +1990,7 @@ static void blitCursor(const u8* in)
|
|||
|
||||
static void renderCursor()
|
||||
{
|
||||
if(studio.mode == TIC_RUN_MODE &&
|
||||
if(studio.mode == TIC_RUN_MODE &&
|
||||
studio.tic->input == tic_mouse_input &&
|
||||
studio.tic->ram.vram.vars.cursor)
|
||||
{
|
||||
|
@ -1987,6 +2005,11 @@ static void renderCursor()
|
|||
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()
|
||||
{
|
||||
showTooltip("");
|
||||
|
@ -2014,7 +2037,7 @@ static void renderStudio()
|
|||
src = &studio.tic->cart.sound;
|
||||
}
|
||||
|
||||
studio.tic->api.tick_start(studio.tic, src);
|
||||
studio.tic->api.tick_start(studio.tic, src);
|
||||
}
|
||||
|
||||
switch(studio.mode)
|
||||
|
@ -2039,14 +2062,18 @@ static void renderStudio()
|
|||
{
|
||||
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.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));
|
||||
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,
|
||||
TIC80_HEIGHT - TIC_FONT_HEIGHT, (tic_color_white));
|
||||
}
|
||||
|
||||
studio.tic->api.tick_end(studio.tic);
|
||||
|
||||
blitSound();
|
||||
|
||||
if(studio.mode != TIC_RUN_MODE)
|
||||
useSystemPalette();
|
||||
|
||||
blitTexture();
|
||||
|
||||
renderCursor();
|
||||
|
@ -2087,7 +2114,7 @@ static void renderGamepad()
|
|||
const s32 tileSize = studio.gamepad.part.size;
|
||||
const SDL_Point axis = studio.gamepad.part.axis;
|
||||
typedef struct { bool press; s32 x; s32 y;} Tile;
|
||||
const Tile Tiles[] =
|
||||
const Tile Tiles[] =
|
||||
{
|
||||
{studio.tic->ram.vram.input.gamepad.first.up, axis.x + 1*tileSize, axis.y + 0*tileSize},
|
||||
{studio.tic->ram.vram.input.gamepad.first.down, axis.x + 1*tileSize, axis.y + 2*tileSize},
|
||||
|
@ -2171,7 +2198,7 @@ static void tick()
|
|||
|
||||
static void initSound()
|
||||
{
|
||||
SDL_AudioSpec want =
|
||||
SDL_AudioSpec want =
|
||||
{
|
||||
.freq = 44100,
|
||||
.format = AUDIO_S16,
|
||||
|
@ -2202,7 +2229,7 @@ static void initTouchGamepad()
|
|||
|
||||
if(!studio.gamepad.texture)
|
||||
{
|
||||
studio.gamepad.texture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING,
|
||||
studio.gamepad.texture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING,
|
||||
textureLog2(TIC80_WIDTH), textureLog2(TIC80_HEIGHT));
|
||||
SDL_SetTextureBlendMode(studio.gamepad.texture, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
|
@ -2246,7 +2273,7 @@ static void setWindowIcon()
|
|||
|
||||
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 i = 0; i < Size; i++, index++)
|
||||
|
@ -2255,8 +2282,8 @@ static void setWindowIcon()
|
|||
pixels[index] = color == ColorKey ? 0 : pal[color];
|
||||
}
|
||||
|
||||
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(pixels, Size, Size,
|
||||
sizeof(s32) * BITS_IN_BYTE, Size * sizeof(s32),
|
||||
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(pixels, Size, Size,
|
||||
sizeof(s32) * BITS_IN_BYTE, Size * sizeof(s32),
|
||||
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
||||
|
||||
SDL_SetWindowIcon(studio.window, surface);
|
||||
|
@ -2301,13 +2328,13 @@ static void onFSInitialized(FileSystem* fs)
|
|||
|
||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
|
||||
|
||||
studio.window = SDL_CreateWindow( TIC_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
(TIC80_WIDTH+STUDIO_UI_BORDER) * STUDIO_UI_SCALE,
|
||||
(TIC80_HEIGHT+STUDIO_UI_BORDER) * STUDIO_UI_SCALE,
|
||||
studio.window = SDL_CreateWindow( TIC_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
(TIC80_WIDTH+STUDIO_UI_BORDER) * STUDIO_UI_SCALE,
|
||||
(TIC80_HEIGHT+STUDIO_UI_BORDER) * STUDIO_UI_SCALE,
|
||||
SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE
|
||||
#if defined(__ARM_LINUX__)
|
||||
| SDL_WINDOW_FULLSCREEN_DESKTOP
|
||||
#endif
|
||||
#endif
|
||||
);
|
||||
|
||||
initSound();
|
||||
|
@ -2343,14 +2370,14 @@ static void onFSInitialized(FileSystem* fs)
|
|||
#endif
|
||||
|
||||
studio.renderer = SDL_CreateRenderer(studio.window, -1, renderFlags);
|
||||
studio.texture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING,
|
||||
studio.texture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING,
|
||||
textureLog2(FULL_WIDTH), textureLog2(TIC80_HEIGHT));
|
||||
|
||||
#if !defined(__ARM_LINUX__)
|
||||
#if !defined(__ARM_LINUX__)
|
||||
SDL_SetTextureBlendMode(studio.texture, SDL_BLENDMODE_BLEND);
|
||||
#endif
|
||||
|
||||
studio.borderTexture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING,
|
||||
studio.borderTexture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING,
|
||||
textureLog2(TIC80_WIDTH), textureLog2(TIC80_HEIGHT));
|
||||
|
||||
initTouchGamepad();
|
||||
|
@ -2400,19 +2427,19 @@ s32 main(s32 argc, char **argv)
|
|||
u64 nextTick = SDL_GetPerformanceCounter();
|
||||
const u64 Delta = SDL_GetPerformanceFrequency() / TIC_FRAMERATE;
|
||||
|
||||
while (!studio.quitFlag)
|
||||
while (!studio.quitFlag)
|
||||
{
|
||||
nextTick += Delta;
|
||||
tick();
|
||||
|
||||
s64 delay = nextTick - SDL_GetPerformanceCounter();
|
||||
|
||||
|
||||
if(delay > 0)
|
||||
SDL_Delay((u32)(delay * 1000 / SDL_GetPerformanceFrequency()));
|
||||
else nextTick -= delay;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
if(studio.tic80local)
|
||||
|
@ -2420,7 +2447,7 @@ s32 main(s32 argc, char **argv)
|
|||
|
||||
if(studio.floatSamples)
|
||||
SDL_free(studio.floatSamples);
|
||||
|
||||
|
||||
SDL_DestroyTexture(studio.gamepad.texture);
|
||||
SDL_DestroyTexture(studio.texture);
|
||||
SDL_DestroyTexture(studio.borderTexture);
|
||||
|
@ -2436,7 +2463,7 @@ s32 main(s32 argc, char **argv)
|
|||
SDL_CloseAudioDevice(studio.audioDevice);
|
||||
SDL_Quit();
|
||||
#endif
|
||||
|
||||
|
||||
SDLNet_Quit();
|
||||
exit(0);
|
||||
|
||||
|
|
15
src/studio.h
15
src/studio.h
|
@ -43,13 +43,13 @@
|
|||
|
||||
#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_HEIGHT (TIC_FONT_HEIGHT+1)
|
||||
#define STUDIO_TEXT_BUFFER_WIDTH (TIC80_WIDTH / STUDIO_TEXT_WIDTH)
|
||||
#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 CONFIG_TIC "config " TIC_VERSION_LABEL ".tic"
|
||||
|
@ -64,11 +64,6 @@ typedef struct
|
|||
{
|
||||
struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
u8 data[TIC_PALETTE_SIZE];
|
||||
} palmap;
|
||||
|
||||
struct
|
||||
{
|
||||
s32 sprite;
|
||||
|
@ -179,8 +174,6 @@ void showTooltip(const char* text);
|
|||
|
||||
SDL_Scancode* getKeymap();
|
||||
|
||||
u8 systemColor(u8 color);
|
||||
|
||||
const StudioConfig* getConfig();
|
||||
|
||||
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 hideDialog();
|
||||
|
||||
void showGameMenu();
|
||||
void hideGameMenu();
|
||||
|
||||
bool studioCartChanged();
|
||||
|
@ -198,4 +190,5 @@ void playSystemSfx(s32 id);
|
|||
|
||||
void runGameFromSurf();
|
||||
void gotoSurf();
|
||||
void exitFromGameMenu();
|
||||
void exitFromGameMenu();
|
||||
void runProject();
|
||||
|
|
20
src/surf.c
20
src/surf.c
|
@ -482,7 +482,7 @@ static void updateMenuItemCover(Surf* surf, const u8* cover, s32 size)
|
|||
{
|
||||
const gif_color* c = &image->palette[image->buffer[i]];
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -762,14 +762,16 @@ static void tick(Surf* surf)
|
|||
tic->api.clear(tic, TIC_COLOR_BG);
|
||||
|
||||
drawBG(surf);
|
||||
processAnim(surf);
|
||||
|
||||
if(surf->state == &MenuModeState)
|
||||
if(surf->menu.count > 0)
|
||||
{
|
||||
processGamepad(surf);
|
||||
}
|
||||
processAnim(surf);
|
||||
|
||||
if(surf->state == &MenuModeState)
|
||||
{
|
||||
processGamepad(surf);
|
||||
}
|
||||
|
||||
{
|
||||
loadCover(surf);
|
||||
|
||||
drawCover(surf, surf->menu.pos, 0, 0);
|
||||
|
@ -782,6 +784,12 @@ static void tick(Surf* surf)
|
|||
drawTopToolbar(surf, 0, AnimVar.topBarY - MENU_HEIGHT);
|
||||
drawBottomToolbar(surf, 0, TIC80_HEIGHT - AnimVar.bottomBarY);
|
||||
}
|
||||
else
|
||||
{
|
||||
static const char Label[] = "You don't have any files...";
|
||||
s32 size = tic->api.text(tic, Label, 0, -TIC_FONT_HEIGHT, tic_color_white);
|
||||
tic->api.text(tic, Label, (TIC80_WIDTH - size) / 2, (TIC80_HEIGHT - TIC_FONT_HEIGHT)/2, tic_color_white);
|
||||
}
|
||||
}
|
||||
|
||||
static void resume(Surf* surf)
|
||||
|
|
|
@ -440,9 +440,6 @@ static void api_pause(tic_mem* memory)
|
|||
memcpy(&machine->pause.registers, &memory->ram.registers, sizeof memory->ram.registers);
|
||||
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);
|
||||
|
||||
api_reset(memory);
|
||||
memcpy(memory->ram.vram.palette.data, memory->config.palette.data, sizeof(tic_palette));
|
||||
}
|
||||
|
||||
static void api_resume(tic_mem* memory)
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "defines.h"
|
||||
|
||||
#define TIC_VERSION_MAJOR 0
|
||||
#define TIC_VERSION_MINOR 46
|
||||
#define TIC_VERSION_MINOR 47
|
||||
#define TIC_VERSION_PATCH 0
|
||||
#define TIC_VERSION_STATUS ""
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
static void drawGrid(World* world)
|
||||
{
|
||||
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)
|
||||
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,
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue