|
From: Id K. <dav...@ro...> - 2003-07-09 05:28:43
|
Hi, I'm trying to understand the source code of this version of
StarControl and I'm surprised (perhaps I shouldn't be) by how complex it is.
I'll start with a simple to help me going, if you don't mind.
I don't understand the resource system. You pass into LoadGraphic() an
integer that represents the image you want and you get another integer. In
fact, LoadGraphric() simply turns around and calls GetResource() passing
your integer and returning a handle of some kind.
Where do these resources come from? How does the resource system
translate an integer into a handle? I'm kind of embarrased to ask this next
question but what is this handle? How does this generic handle get turned
into something useful?
Thank you so much for your help. I would very much like to understand
this code...
|
|
From: Alex V. <co...@us...> - 2003-07-09 07:36:41
|
David, I think Serge van den Boom (aka Meep-Eep) is in the process of rewriting that entire code, if he hadn't done so already. I saw some CVS check-ins of the new resource system code. So if you hadn't checked out from CVS recently, you should do so, as all of that code is going to change. As for the old resource code: the integer passed in is an identifier that refers to a package, type and index of an item. There is a resource index file that links these IDs to corresponding files. The returned handle is, in fact, what it is -- a handle ;-). There is a memory manager that deals with them -- legacy of the original code. If I remember correctly, some handles have been changed to actual memory pointers since then. Cannot recall which ones were. Cheers! Alex Volkov. ----- Original Message ----- From: "Id Kong" <dav...@ro...> To: <sc2...@li...> Sent: Wednesday, July 09, 2003 1:42 AM Subject: [Sc2-devel] Where do Star Control images come from? > Hi, I'm trying to understand the source code of this version of > StarControl and I'm surprised (perhaps I shouldn't be) by how complex it is. > I'll start with a simple to help me going, if you don't mind. > I don't understand the resource system. You pass into LoadGraphic() an > integer that represents the image you want and you get another integer. In > fact, LoadGraphric() simply turns around and calls GetResource() passing > your integer and returning a handle of some kind. > Where do these resources come from? How does the resource system > translate an integer into a handle? I'm kind of embarrased to ask this next > question but what is this handle? How does this generic handle get turned > into something useful? > Thank you so much for your help. I would very much like to understand > this code... > > > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Parasoft > Error proof Web apps, automate testing & more. > Download & eval WebKing and get a free book. > www.parasoft.com/bulletproofapps > _______________________________________________ > Sc2-devel mailing list > Sc2...@li... > https://lists.sourceforge.net/lists/listinfo/sc2-devel |
|
From: Michael C. M. <mcm...@st...> - 2003-07-09 08:36:50
|
Alex! Good to see you're still reading the lists. On Wed, 9 Jul 2003, Alex Volkov wrote: > I think Serge van den Boom (aka Meep-Eep) is in the process of rewriting > that entire code, if he hadn't done so already. I saw some CVS check-ins of > the new resource system code. So if you hadn't checked out from CVS > recently, you should do so, as all of that code is going to change. The packaging code has been committed; the reworking of the resource system has not yet been done. This has, indeed, been Serge's main coding project for some months now. All of the old resource and memlib code is, to my knowledge, slated for destruction once it's done. Much of UQM's code complexity comes from the number of layers in the code; TFB had a rather involved framework that they used themselves (some of that has actually been removed so as to use SDL directly, but much still remains), then there's the SDL layer on top of the 3DO layer which is itself presumably on top of the original 386 layer (the PC-specific parts of which would have been removed before the 3DO source release). Most of the grotesque features of the original code (deliberate buffer overruns or undecidably messy pointer arithmetic with deterministic results, for instance, both of which were common in the old graphics code) were cleaned away by the time of 0.2. There have been various proposals for rearchitecting the game; we've been deliberately shelving/ignoring those until all the functionality is present unless it blocks us. (It has, several times, and then we rearchitected just that part.) Most of the code itself worked when we got it, despite being really messy, so we try not to touch it unless we have to (fixing bugs or tieing in new backends, usually). We may pay for this later, but by leaving the original code alone as much as possible, we have a fully playable game at basically all times. Oh, and also, this list is pretty quiet most of the time; the development community is mostly at #sc2 on the Freenode IRC network (irc.freenode.net). --Michael |
|
From: Serge v. d. B. <sv...@st...> - 2003-07-09 15:09:50
|
On Wed, 9 Jul 2003, Id Kong wrote: > Hi, I'm trying to understand the source code of this version of > StarControl and I'm surprised (perhaps I shouldn't be) by how complex it is. > I'll start with a simple to help me going, if you don't mind. > I don't understand the resource system. You pass into LoadGraphic() an > integer that represents the image you want and you get another integer. In > fact, LoadGraphric() simply turns around and calls GetResource() passing > your integer and returning a handle of some kind. > Where do these resources come from? How does the resource system > translate an integer into a handle? I'm kind of embarrased to ask this next > question but what is this handle? How does this generic handle get turned > into something useful? No need to be embarrased. This is very complicated code (possibly the most complicated part), and there was absolutely no documentation. However, since we've got this code, I've documented some things. The integer passed to GetResource() is described in doc/devel/resources. The files to which these resources correspond are listed in starcon.ndx, the *.con, *.shp, and *.sc2 files. If you're interested in how that information is stored in those files, you could check doc/devel/pkgformat. The memory handle (returned by among others, GetResource) gets translated into a memory address by calls to mem_lock. There are various wrappers for various resources, for instance 'LockDrawable', or 'LockStarShip'. Apart from indicating that the resource is in being used, I think part of the original purpose was to deal with the segmented memory model of the 'real mode' Intel architecture. It's probably quite a bit simpler now than it once was, but still, this will all be replaced by a more modern, and a bit more flexible way of managing resources. I'm personally working on this. Greetings, Serge |