HLA v2.x and / or LASM suggestion: Win32 Resources

From: Beth (BethStone21_at_hotmail.NOSPICEDHAM.com)
Date: 01/05/04


Date: Mon, 5 Jan 2004 12:14:26 -0000

Hi,

    Here's an interesting suggestion for an addition to either HLA
v.2x or LASM or, basically, _any_ 32-bit assembler tool (RosAsm is
excluded but only because it deals with this sort of thing already and
in a completely different way :)...

With Microsoft's RC compiler, I've just noticed that it's less capable
than Borland's version...with Borland, there are two versions of
resource statements like "ICON", where one version is "compatible"
with Microsoft's statement and simply names the ".ico" file with the
_binary_ icon resource (e.g. 'MY_ICON ICON "MyIcon.ico"' :)...then
there's a second "source" version where rather than the filename, it
actually dumps out a whole bunch of hex codes that are, basically, the
binary resource converted into readable, editable ASCII form...

Anyway, Microsoft's "lesser" functionality is a pain from the
perspective of, say, posting up code here that includes an icon...this
ain't a binary group so I shouldn't be attaching any binary
files...and, most importantly, some newservers would automatically
remove the binary attachments so that some people wouldn't be able to
see them (my ISP is okay with this but I know some have different
policies)...plus, it's just general netiquette, which I tend to agree
with, that _source_ not binary is posted (i.e. virus worries, source
_should_ be visible as usually the whole point is to _show_ how things
are achieved and be "educational" that just posting up a binary ".exe"
file for everything wouldn't be particularly useful here and this
problem would be the resource equivalent to just posting up closed
source ".exe" files for every problem, etc. :)...

So, whilst pondering how to get around this (for example, it is
possible to create an icon or bitmap on-the-fly in the actual program
for use...but the problem with that is that the icon would not be
picked up by Explorer to make the ".exe" file look pretty there, which
is what people would expect and what having an "icon" would primiarily
be all about in most cases ;), I started thinking even more generally
about this...beyond the immediate problem of getting an icon onto a
posted-up Win32 code example (although, in the end, this _isn't_
essential or crucial...I just thought that it would be nice if I could
think up a way of doing it that's totally source-based...possible with
Borland tools but lots of people only have Microsoft's RC compiler or
are using that RC compiler via HLA or whatever ;)...

I just thought a simple thought: "if RC is a _compiler_, then why
isn't this stuff part of the assembler or C++ compiler,
anyway?"...well, one reason is, of course, that Microsoft produce MASM
and MSVC++ and so forth, which could all make use of a resource
compiler...hence, make a separate tool and then all of them can share
the same compiler...I can see why _Microsoft_ have gone in this
direction (and why they - unlike Borland - only think of "binary"
files and not any "source" equivalents...this is Microsoft who happily
throw ten 48MB DLL files at implementing "strlen"! Of course
_Microsoft_ would do things this way...it's their modus operandi
:)...they produce lots of different tools and languages and so forth,
so they are just "sharing" the common bits between them (like LINK.EXE
is the same for all these tools too :), as there's no sense them
"re-inventing the wheel" every time :)...

But why do other packages - like HLA, (the upcoming) LASM, GoAsm,
etc. - actually need to separate out the resource compiler from the
"source compiler", so to speak?

Now, before anyone jumps on this with the usual Microsoft quotations:
"putting resources into a separate file eases internationalisation"
and so forth...I perfectly realise this and what I'm suggesting can
work either way...if you want resources in a separate file then create
a separate ".asm" file with just the resources...if you'd rather an
"all in one" affair (the most suitable for posting up :) then you can
stick these statements into the one and only main source code file
instead...you "separate" your resources into a separate file
_manually_, is all...it's hardly rocket-science...you don't need to be
calling it special names like "resources" and having special compilers
to _force_ them separate...we're ASM coders, right? We don't need
"data typing" tricks to force us to keep data in order, we do it all
manually! :)...

The idea being something along these lines...resources are just
another (special) type of "section" inside a PE file...thus, just like
".data" and ".code", we simply add ".resource" (or something
similar..."[section resource]" for NASM, one supposes ;)...then the
actual resource data can follow in that section...it's, of course, up
to the tool author to decide how best to define the syntax...I'd
imagine, for example, that HLA would go for actual "ICON" and "BITMAP"
data type statements and look comparable to RC (but also allowing,
perhaps, that "DB" works in this section too, so that "hand-made"
resources and resource tables are an option as well ;)...NASM (though,
would NASM be appropriate for this idea when it's not only Win32 and
only Win32 has this "resource" concept? Maybe not but I'll pretend it
is for the moment to make the example :) going for something more like
"DB" statements, insisting on a "low-level" syntax...certain resources
like "RCDATA" and "STRINGTABLE" and so forth are almost automatically
appropriate for a "DB" statement straight away, anyway...

[ RosAsm has its own "editors" for interactively adding resources to a
file...it could be possible to add some "source code equivalent" so
that, for example, I could actually post up an icon _in ASCII_ that
can be put onto a RosAsm program via _source_ rather than the
editor...but that may violate Rene's "principles" here (this actually
makes a good way to demonstrate the weirdness of Rene's "no library"
principles, in a sense...for example, I've drawn up a bunch of
cool-looking icons...but I _can't_ give them to any RosAsm programmer
because that would be using a "library"...indeed, not a code library
but it's still a "library" of icons that _I_ drew rather than they
drew...I mean, to echo Rene, if I provide pre-drawn icons, then users
of these "library" icons wouldn't know _how_ I went about drawing
them...did I start by drawing the circle or was that actually added
later? You can't tell the order something was drawn by simply looking
at it...thus, this is "black box", this is "hidden", this is "library"
and no RosAsm programmer should ever use any icon, bitmap, wave file
or anything else that they themselves did not create...otherwise,
you'll be using a "black box"...so, Rene, care to explain how it's
"wrong" to do so with code but you "overlook" it when dealing with
other resources? Out of interest, does this extend to _data_ of any
kind? In my "adventure game" - sorry, "interactive fiction" - example
I posted up a while ago, I had a simple "engine" that accepted
different _data_ for different "adventures"...hence, would someone
using my game map elsewhere count as "black box" too? Are DOOM, Quake,
Half-life and the others with their similar "game engine (plug in your
data on-the-fly)" schemes also "out of bounds" because, yes, those
people making their own Counter-strike maps _are_ using Half-life in a
"black box" way? Where does this end, Rene? Can I no longer use my DVD
player or washing machine because I don't understand what every
transistor inside them does? Blah-blah-blah...no, I _understand_ what
you mean about "black box" being "dangerous", "leading to bloat",
etc., etc....but I think you've got it all wrong to introduce what is
actually a very right-wing, fascist "ThoughtPolice" in _forcing_
people never to ever use them..._even when_ they were the ones who
potentially built these "black boxes" for their own purpose...for a
"leftist" and "opensource" kind of guy, it's amazing just how quickly
you've jumped to a _fascist_ solution...no, really, when you call
others "fascist", it's a bit of a joke really...not because they
aren't being so at all but because of the massive, massive irony that
you've probably created the _only_ "fascist ThoughtPolice" programming
tool ever to have existed on this planet...a tool that delibrately
makes sure that "code libraries" can't be used in any shape or form,
forcing them through this "clip file" stuff instead...in trying to
defeat your "fascist" enemies, Rene, you have _become_ the greatest
fascist of them all)... ]

Actually, this is probably mostly a LASM suggestion because
"resources" are a Win32-specific kind of deal, thinking about it...but
the possibility is there for others to allow such statements for their
Win32 "mode of operation" or something (like NASM has different
"sections" according to the format :)...although, I was also kind of
thinking it might be cool for HLA v2.x as well in that Randy could
more easily write examples and so forth for "Windows Programming in
Assembly" or whatever that supplies icons, bitmaps and stuff directly
in the source code without the complexity of makefiles, running RC
compilers and so forth...that, as was the case with simple console
applications, you can simply put "HLA MyCode.hla" onto a command line
and the whole thing is done automatically...one possibility for
"compatibility" is that any "resource" section could be simply
considered "extra data" in any target other than Win32, which doesn't
specially support these "resource" concepts...it could still make
sense and be useful to have a renamed "data" section called "resource"
that simply already understands how to load and format ".GIF" or
".JPG" or ".MP3" into the data section for use...

Anyway, this idea has _only just_ come to mind so I admit I've not had
time to completely think it through (could be some major "dumb" thing
about it I've missed :)...but, as it struck me now, I thought I'd
better post it up or I _would_ simply forget about it, I'm sure ;)...

Basically, though I'm not completely convinced by Randy's "DOS is
dead", as I still think it can be useful and demonstrate things (but,
sure, if someone has limited time - because they are only doing it for
a "course" - then "getting straight to the point" might be the best
way...I wouldn't say "taking the scenic route" is "dead" or "wrong"
but if you've got to get to a destination within a certain time, I can
certainly understand it being "impractical" that, if someone intends
to do only Windows / Linux stuff, then messing around with DOS might,
indeed, be "educational" but if you don't have the time, then you
don't have the time...and it's as simple as that: "impractical"...I'll
still be posting up DOS-based examples, anyway, as they are the
easiest and usually smallest and the OS that almost everyone can
access that the examples "stretch" the furthest :)...but, along these
same lines, if these "old ways" are "dead" then shouldn't Windows
32-bit tools stop thinking in a "DOS - with an extra compiler added
for the non-DOS stuff - way"? And, on that point, I have to 100%
support and congratulate Rene for basically thinking this and then
_doing it_ with his tool...I'm not sure if he's really a "technique
pioneer" - that's open to debate - but maybe he's certainly an
"attitude" pioneer...

That is, lest someone be offended as per usual, I'm perfectly happy
with DOS, CP/M and so forth...please, carry on...I'll be posting up
DOS stuff from time to time too...BUT, for those who've made the
decision to be "Win32", then shouldn't they make that decision
_firmly_ and _be_ "Win32"? Oh, and as I seem to have caused offence to
Linux in an earlier post, I'll make up for it by pointing out that
non-X Linux stuff can often be _easier_ and _less complicated_ than
DOS for examples (totally so, if you've no problems with "borrowing"
the odd C standard library function here and there ;)...and this can't
be faulted in Linux's direction because Linux itself _has_ made the
decision implicitly, so to speak...it's not part of this argument
because it already has "its own way of doing things" :)...

Okay, I'm just ranting wildly now so I'll stop...just thought I'd
shake the tree and watch the coconuts fall down once more...I mean, I
have to be careful or - perish the thought - I may start "conforming"
if I don't give the "alien brain" its regular exercise ;)

Beth :)


Loading