The <IMG Paradox?

May 14, 2020 at 5:34 AM
War criminal
"Life begins and ends with Nu."
Join Date: Jun 27, 2013
Location: Phoenix
Posts: 2758
Age: 29
So, the <IMG command, the bastard TSC command that appeared really good to use, until it comes to the point where it can fuck up your mod hard, and it's a bit difficult to fix that all up if you have no backup files. It's not even compatible with the Widescreen mod used in Mod Loader. But that's not the subject with <IMG that's been bothering me that will be discussed in this thread. It's the other subject with <IMG that's been bothering me that will be discussed in this thread.

So how does <IMG work? Use <IMGXXXX, the XXXX corresponds to the 4 characters used in timgXXXX.bmp. Can be used to display images with that filename within your data folder in your mod. I think people don't realize though, is that despite being able to give the files names in place of XXXX, this command isn't reading a string. It's actually reading a set of numbers, in a very clever way.

You might be familiar with this within the Booster's Lab Guide, the Negative Arguments lesson.
p373096-0-zl9xp3.png

Every known command for Cave Story, can read ASCII values all the way up to the ~ symbol (see the Character Map image below for reference), and in the case for almost every custom TSC command, barring commands like <NAM, <CIN, or <HEX, every argument consists up of a 4-digit value.
p373096-1-klh2vr.png


So what does this have to do with <IMG? It does the exact same thing, so what? My issue is, it may not behave the same, especially if one is either trying to do a sneaky with the ASCII values or if for some reason, they decide to store the number for the file name in <VAR and try reading it off that. So I will test these two possible scenarios and see if it still works as intended, regardless of the filename or not. If it doesn't, then this does only confirm the <IMG Paradox's existence, but also serve as a guide of what not to do when using <IMG. If it's smart enough to tell the difference, then good on Noxid for making sure it doesn't break.
p373096-2-ve8oah.png
p373096-3-rgf44y.png


Note, I'll be using the MaGCSL devkit to test this theory with, as it's the only mod I have with me that has both <IMG and <VAR in the same executable.
First case, <IMG0069 vs <IMG000u, does the command know the difference?
YES.
p373096-4-vaf2uoy.gif
p373096-5-nuv5qrw.gif

It can indeed tell the difference between the two images, not breaking the mod at all!
p373096-6-u5ajsag.png
And now, second case, <IMGTest vs <IMGV008.
So, there's a reason why I included the other TSC events, it's to show that through normal means, without <VAR being in use, this is completely normal, but what about with <VAR in use?
p373096-7-utffswx.gif


Through this event, it'll store the value "Test" (or if you translate it from ASCII, the value would actually be 42038) to Variable 008, or V008, for short. The real question is, would <IMG still recognize it?
Code:
#0400
<KEY<VAR0008:Test<IMGV008<NOD
<IMG0000<END
Will this work?
No.
p373096-8-9s1oqdh.gif

It does read timgV008.bmp instead, and it can tell the difference between the two values.
p373096-9-nfrjpwy.png

Could this have all been intentional? Maybe. I applaud you, Noxid, for dummy-proofing the <IMG command for the case of using ASCII in place of numbers or for the case of storing the file's name in a variable. The least we all know now that this has been tested and recorded, and there won't need to be any special rules on how to name the files without potentially breaking something (<IMG is still a very unstable command however, and is prone to break some stuff (the title screen, the Quote cursor, and the Widescreen mod, but that's a different subject for the Modding Q&A thread)).

Hope this thread helps for those who are curious about any of this!
 
May 14, 2020 at 5:38 AM
Senior Member
"Huzzah!"
Join Date: Jul 6, 2019
Location: United States
Posts: 213
I kinda forgot this command existed, its so useful as well! What the hell was I doing!
 
May 14, 2020 at 5:40 AM
War criminal
"Life begins and ends with Nu."
Join Date: Jun 27, 2013
Location: Phoenix
Posts: 2758
Age: 29
I kinda forgot this command existed, its so useful as well! What the hell was I doing!
It breaks too much shit though, and is very unstable, so it's really a "be careful what you wish for" situation.
 
May 14, 2020 at 5:43 AM
Senior Member
"Huzzah!"
Join Date: Jul 6, 2019
Location: United States
Posts: 213
It breaks too much shit though, and is very unstable, so it's really a "be careful what you wish for" situation.
yes, that is correct, thats kinda why I forgot it even existed, because honestly if I want a detailed map system I can just make backgrounds for that sole purpose (but honestly I'll probably just stick with the map system)
 
Last edited:
Top