Skip to content

Commit 6aad6d8

Browse files
committed
Merge branch 'master' into stable
2 parents 10ddf94 + 0de8eb4 commit 6aad6d8

File tree

14 files changed

+135
-47
lines changed

14 files changed

+135
-47
lines changed

bin/assets/tic.js.dat

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

build/android/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
-->
55
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
66
package="com.nesbox.tic"
7-
android:versionCode="5000"
8-
android:versionName="0.50.0"
7+
android:versionCode="5001"
8+
android:versionName="0.50.1"
99
android:installLocation="auto">
1010

1111
<!-- Android 2.3.3 -->

build/macosx/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
<key>CFBundlePackageType</key>
2020
<string>APPL</string>
2121
<key>CFBundleShortVersionString</key>
22-
<string>0.50.0</string>
22+
<string>0.50.1</string>
2323
<key>CFBundleVersion</key>
24-
<string>0.50.0</string>
24+
<string>0.50.1</string>
2525
<key>NSHumanReadableCopyright</key>
2626
<string>http://tic.computer © 2017</string>
2727
<key>NSHighResolutionCapable</key>

build/windows/tic80/tic80.aps

0 Bytes
Binary file not shown.

build/windows/tic80/tic80.rc

0 Bytes
Binary file not shown.

lib/windows/tic.rc

0 Bytes
Binary file not shown.

src/console.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,12 @@ static void* getDemoCart(Console* console, tic_script_lang script, s32* size)
464464
return data;
465465
}
466466

467+
static void setCartName(Console* console, const char* name)
468+
{
469+
if(name != console->romName)
470+
strcpy(console->romName, name);
471+
}
472+
467473
static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* param)
468474
{
469475
void* data = NULL;
@@ -480,7 +486,7 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para
480486

481487
const char* name = getCartName(param);
482488

483-
strcpy(console->romName, name);
489+
setCartName(console, name);
484490

485491
loadRom(console->tic, data, size, true);
486492

@@ -495,7 +501,7 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para
495501

496502
static void onCartLoaded(Console* console, const char* name)
497503
{
498-
strcpy(console->romName, name);
504+
setCartName(console, name);
499505

500506
studioRomLoaded();
501507

@@ -1343,15 +1349,21 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v
13431349
commandDone(console);
13441350
}
13451351

1352+
static void injectMap(Console* console, const void* buffer, s32 size)
1353+
{
1354+
enum {Size = sizeof(tic_map)};
1355+
1356+
SDL_memset(&console->tic->cart.gfx.map, 0, Size);
1357+
SDL_memcpy(&console->tic->cart.gfx.map, buffer, SDL_min(size, Size));
1358+
}
1359+
13461360
static void onImportMap(const char* name, const void* buffer, size_t size, void* data)
13471361
{
13481362
Console* console = (Console*)data;
13491363

1350-
enum {Size = sizeof(tic_map)};
1351-
1352-
if(name && buffer && size == Size)
1364+
if(name && buffer && size <= sizeof(tic_map))
13531365
{
1354-
memcpy(&console->tic->cart.gfx.map, buffer, size);
1366+
injectMap(console, buffer, size);
13551367

13561368
printLine(console);
13571369
printBack(console, "map successfully imported");
@@ -1889,7 +1901,7 @@ static CartSaveResult saveCartName(Console* console, const char* name)
18891901

18901902
if(size && fsSaveFile(console->fs, name, buffer, size, true))
18911903
{
1892-
strcpy(console->romName, name);
1904+
setCartName(console, name);
18931905
success = true;
18941906
studioRomSaved();
18951907
}
@@ -2627,7 +2639,7 @@ static void cmdLoadCart(Console* console, const char* name)
26272639
if(hasProjectExt(name))
26282640
{
26292641
loadProject(console, name, data, size, &embed.file);
2630-
strcpy(console->romName, fsFilename(name));
2642+
setCartName(console, fsFilename(name));
26312643
embed.yes = true;
26322644
embed.fast = true;
26332645
}
@@ -2637,7 +2649,7 @@ static void cmdLoadCart(Console* console, const char* name)
26372649
if(hasExt(name, CART_EXT))
26382650
{
26392651
loadCart(console->tic, &embed.file, data, size, true);
2640-
strcpy(console->romName, fsFilename(name));
2652+
setCartName(console, fsFilename(name));
26412653
embed.yes = true;
26422654
}
26432655

@@ -2755,9 +2767,9 @@ static void cmdInjectMap(Console* console, const char* param, const char* name)
27552767

27562768
if(map)
27572769
{
2758-
if(size == sizeof(tic_map))
2770+
if(size <= sizeof(tic_map))
27592771
{
2760-
SDL_memcpy(embed.file.gfx.map.data, map, size);
2772+
injectMap(console, map, size);
27612773

27622774
embed.yes = true;
27632775
embed.fast = true;
@@ -2862,6 +2874,8 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config,
28622874
config->data.noSound = true;
28632875
else if(strcmp(argv[i], "-surf") == 0)
28642876
console->startSurf = true;
2877+
else if(strcmp(argv[i], "-fullscreen") == 0)
2878+
goFullscreen();
28652879
}
28662880
}
28672881

src/run.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,57 @@ static void tick(Run* run)
115115
setStudioMode(TIC_CONSOLE_MODE);
116116
}
117117

118+
static void processDoFile(void* data, char* dst)
119+
{
120+
Run* run = (Run*)data;
121+
tic_mem* tic = run->tic;
122+
123+
static const char DoFileTag[] = "dofile(";
124+
enum {Size = sizeof DoFileTag - 1};
125+
126+
if (memcmp(tic->cart.code.data, DoFileTag, Size) == 0)
127+
{
128+
const char* start = tic->cart.code.data + Size;
129+
const char* end = strchr(start, ')');
130+
131+
if(end && *start == *(end-1) && (*start == '"' || *start == '\''))
132+
{
133+
char filename[FILENAME_MAX] = {0};
134+
memcpy(filename, start + 1, end - start - 2);
135+
memset(dst, 0, sizeof(tic_code));
136+
137+
s32 size = 0;
138+
void* buffer = fsReadFile(filename, &size);
139+
140+
if(buffer)
141+
{
142+
if(size > 0)
143+
{
144+
if(size > TIC_CODE_SIZE)
145+
{
146+
char buffer[256];
147+
sprintf(buffer, "code is larger than %i symbols", TIC_CODE_SIZE);
148+
onError(run, buffer);
149+
150+
return;
151+
}
152+
else SDL_memcpy(dst, buffer, size);
153+
}
154+
}
155+
else
156+
{
157+
char buffer[256];
158+
sprintf(buffer, "dofile: file '%s' not found", filename);
159+
onError(run, buffer);
160+
161+
return;
162+
}
163+
}
164+
}
165+
166+
return;
167+
}
168+
118169
void initRun(Run* run, Console* console, tic_mem* tic)
119170
{
120171
*run = (Run)
@@ -133,6 +184,7 @@ void initRun(Run* run, Console* console, tic_mem* tic)
133184
.start = 0,
134185
.data = run,
135186
.exit = onExit,
187+
.preprocessor = processDoFile,
136188
},
137189
};
138190

src/sprite.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,8 @@ static void drawSpriteToolbar(Sprite* sprite)
13521352
{
13531353
setCursor(SDL_SYSTEM_CURSOR_HAND);
13541354

1355+
showTooltip("CANVAS ZOOM");
1356+
13551357
if(checkMouseDown(&rect, SDL_BUTTON_LEFT))
13561358
{
13571359
s32 mx = getMouseX() - rect.x;

src/studio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ static void processMouse()
13711371
}
13721372
}
13731373

1374-
static void onFullscreen()
1374+
void goFullscreen()
13751375
{
13761376
studio.fullscreen = !studio.fullscreen;
13771377
SDL_SetWindowFullscreen(studio.window, studio.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
@@ -1555,12 +1555,12 @@ static bool processShortcuts(SDL_KeyboardEvent* event)
15551555
studio.gamepad.backProcessed = true;
15561556
return true;
15571557
case SDLK_F11:
1558-
onFullscreen();
1558+
goFullscreen();
15591559
return true;
15601560
case SDLK_RETURN:
15611561
if(mod & KMOD_RALT)
15621562
{
1563-
onFullscreen();
1563+
goFullscreen();
15641564
return true;
15651565
}
15661566
break;
@@ -1627,11 +1627,11 @@ static bool processShortcuts(SDL_KeyboardEvent* event)
16271627
return true;
16281628
}
16291629
break;
1630-
case SDLK_F11: onFullscreen(); return true;
1630+
case SDLK_F11: goFullscreen(); return true;
16311631
case SDLK_RETURN:
16321632
if(mod & KMOD_RALT)
16331633
{
1634-
onFullscreen();
1634+
goFullscreen();
16351635
return true;
16361636
}
16371637
else if(mod & TIC_MOD_CTRL)

0 commit comments

Comments
 (0)