America Online APPLE II DEVELOPMENT FORUM CONFERENCE LOG Tuesday, June 23, 1992 10:00 p.m. Eastern Time Topic: Graphics and Animation Programming Forum Leader: Gary Jacobson (AFL GaryJ) AFL GaryJ Welcome to the Apple II Development Forum! Tonight our topic is... AFL GaryJ Graphics and Animation Programming! AFL GaryJ (Just happens to be the "topic" of the main article in July's A2-Central" too) AFL GaryJ Does anyone have anything they'd like to start off with this evening? WinkieJim I reacently whiped up a routine to read $C0/$0002 graphic files. It works WinkieJim fine on Platinum paint files, but chokes on Deluxe paint files. anyone have any WinkieJim idea what might be happening AFL GaryJ I have experienced other programs which could not handle Deluxe Paint AFL GaryJ files, as well. I'm not sure if that would be the fault of the Deluxe Paint file AFL GaryJ structure, or the programmer :) Sheppy Not really an answer, but... I've noticed that there are a couple of programs Sheppy that don't handle APF files very well. I know that Paintworks Gold, for one, Sheppy doesn't really deal with other programs' APF files at all. It's possible Sheppy that some programmers didn't implement it correctly. I don't really know. Sheppy Just a thought... AFL GaryJ GA, Hurlant HURLANT Some programs use the packbytes routine just for the data, some for all of HURLANT the file. Palettes, etc. So you you have to know what to unpack. Sheppy Yeah, but as far as I can tell, the FTN says only the MAIN and MASK blocks Sheppy have packed data. WinkieJim okay, that's pretty much what I thought... HURLANT Also, DP used only a 4 pure color palette for 640 mode. Sheppy Okay. This is an off-topic question. What I need to know is this... Sheppy is there any way for an application to figure out, on the fly, if there is Sheppy a _fully_implemented_ version of the Slot Arbiter running at the time? GA. Sheppy If so, what would that way be? GA. Matt DTS (Sorry, Andy was calling me on the phone.) Just ask for both an internal and an external slot. Matt DTS (Like ask for both slot 1 and slot 9 in two successive requests.) Until a slot arbiter is Matt DTS implemented, that will always fail. It _might_ fail in a working situation, but it might not. Dave Lyons My answer is "no", since I don't think "fully-implemented" is a well-defined term when it Dave Lyons comes to a slot arbiter. Even an implemented slot arbiter may *not* be able to give you the slot Dave Lyons you want, for practical reasons (if the thing you'd be swapping out needs *fast* access to its screen Dave Lyons holes at interrupt time, for example, a real S.A. could refuse your request). -- I assume the Dave Lyons purpose behind this question is to decide what to tell the user to do?? Or what? Matt DTS By far the easiest thing to do is just ask for it, and if you can't get the slot ask the user to... Matt DTS ...change his/her control panel settings. Sheppy Basically yes, Dave & Matt, that's the main purpose here. I want to be Sheppy able to get the slot if it's available, and tell the user what the deal is Sheppy if it is not. Dave Lyons Well, if your request is not granted, all you can tell them is to change the control panel. Dave Lyons That's just as good as "Change your control panel slot setting or wait for future system software", Dave Lyons isn't it? :-) ga Sheppy Sigh. So basically you're telling me not to bother trying to use the Slot Sheppy Arbiter? Dave Lyons No no no! Definitely call it! If it says "NO" then you haven't gained Dave Lyons anything, but if it says Yes, you're set. ga Sheppy Oh, okay. That's what I figured. Thanks. That's it. GA. HURLANT I am trying to understand precompiled shapes and their advantages. HURLANT How is the data in the data area accessed with the using directive? AFL GaryJ The main advantage is speed, of course. AFL Marty I'd like to know what a precompiled shape is. AFL Marty Maybe you could start with a definition. AFL GaryJ Is that part of your question too, Hurlant? HURLANT Yes. AFL GaryJ I'm not sure if I know the exact definition to that particular terminology. But, AFL GaryJ a shape can be defined as a matrix of data (basically, a clip from the AFL GaryJ graphics screen). One method of getting that data to the screen as fast as possible AFL GaryJ is to pre-define all the addressing, so that looping and INCrementing is AFL GaryJ put to a minimum. AFL GaryJ (or DECrementing) Matt DTS OK, you're asking two separate questions: 1) What about precompiled shapes, and 2) What about USING? Matt DTS Let me start with #2, then offer a thought on #1 and let others comment. Matt DTS In the ORCA/APW assembler, you divide all your code and data into segments. It's typical practice... Matt DTS ...to put a lot of data in one big DATA segment. The USING directive lets you access labels in that Matt DTS DATA segment from within a code segment. If you don't include a USING statement and you reference Matt DTS a label that's in the DATA segement, the Linker will complain that it doesn't know where to find Matt DTS the address you're trying to reference. You can use USING to reference as many DATA segments as you Matt DTS like, but no two labels in any of them can be identical or the Linker won't know which one you Matt DTS wanted. HURLANT Ahh, but what if your data is in another bank? HURLANT Would that be long addressing? AFL GaryJ Long addressing (or change the data bank register) Matt DTS That's your doing if it is. Matt DTS Y'see.. Matt DTS When you link, you tell the linker where to put your DATA segments. If you link all your segments... Matt DTS into one big load segment, they'll always be within 16-bit addressing range. If you link your DATA Matt DTS segment to be a separate segment, the Loader could put it in a separate bank. It's up to _you_ to Matt DTS know which way you do it, and to take appropriate precautions (like using long addressing or setting Matt DTS the "B" register appropriately, always) if the data could be in a different bank. Matt DTS Now for #1: Matt DTS "Precompiled shapes" normally refer to a technique used to optimize shape drawing. Matt DTS Often, you'll have just a few shapes to draw (maybe a man in various positions of running), and you Matt DTS want to draw them very quickly. Some game programmers have created their own shape compilers, Matt DTS which basically take a graphics shape and output 65816 assembly source code for a routine that Matt DTS draws the shape as quickly as possible. The exact details of the routine depend on the shape compiler Matt DTS -- some of them make routines that can draw the shape anywhere, some require you to say exactly Matt DTS _where_ the shape will be drawn at (address) so the compiler can output the fastest possible 65816 Matt DTS code. You take the finished code and put it in your program to draw the shapes. FredW GS For very large shapes and full screen animations... FredW GS Movie Viewer will be out in a short while (shorter if anyone wants to write FredW GS the GSOS shell) ...ga. AFL GaryJ Ah... we have to get our public broadcasting "plugs" in for the evening :) WinkieJim ok, not graphics related (my first one was though :) but here goes... WinkieJim Okay, I've got an NDA that opens up additional system windows everythign works WinkieJim fine except when I want to use _InvalRect to force an update to one of the WinkieJim other windows. When I use InvalRect it draws the other windows requardless of WinkieJim the clipping regions...so all the drawin is done up front. WinkieJim it works ok if I call _Refresh desktop, but that's so drastic :) WinkieJim ga, any ideas? WinkieJim BTW I use a _StartDrawing WindowHand Erase Rect InvalRect sequence Matt DTS What draws what to what other windows? Be more specific, Jim. WinkieJim Basicaly everything draws on the front window which was the window that got the WinkieJim event action code. WinkieJim (a keypress to be specific) Dave Lyons Jim, does anything ever draw in the *wrong* window? WinkieJim Yes. Dave Lyons Or does your InvalRect just cause the wrong window to get updated (but with its own contents)? Dave Lyons Okay, are you calling TaskMasterDA in response to getting update events, allowing TaskMaster to Dave Lyons call your wContDraw routines, or are you handling update events directly? WinkieJim If ttwo windows are overlapping the contents of the window behind the front WinkieJim window will get drawn in the front window (over the scroll bars and everything) Dave Lyons Aha! Dave Lyons Okay, I think I've got it (there's a version of Memory Bar that had a similar problem). Dave Lyons Are you ever calling InvalRect between BeginUpdate and EndUpdate? (This includes during your Dave Lyons wContDraw routine, since the system called Begin/EndUpdate around calling your wContDraw.) Dave Lyons That's B A D, because your update region is temporarily holding your real visRgn during Dave Lyons that time (see technotes for gory details) [IIGS #75] Dave Lyons That explains it so well it's almost gotta be the problem.... WinkieJim I don't believe so, I'm calling InvalRect after getting a key event which WinkieJim in turn checks the keypress in a menu bar in the info bar of the main window WinkieJim which if it's a particular key press needs to fource all the windows to WinkieJim update so I do a loop using _StartDrawing handle InvalRect SetOrigin 0,0 WinkieJim to force the updates Dave Lyons Well...I suggest triple-checking the code to make sure you never accidentally get to any operations Dave Lyons (such as InvalRect or NewWindow or SelectWindow or CloseWindow) that mess with regions, during an Dave Lyons update. Matt DTS Can you invalidate things after _StartDrawing? Dave Lyons Yes, StartDrawing is fine (since it is just like a SetPort and a SetOrigin). Dave Lyons (Jim, the damage to the visRgn was probably done before the keypress makes it obvious.) WinkieJim Sounds plausible...so many windows to keep track of...something might be WinkieJim happening that I didn't forsee when it was just a single window. Matt DTS You might try setting toolbreaks on SetVis[Rgn/Handle] and see if you break, too. WinkieJim So it should be okay to use StartDrawing on another window from within an NDa's WinkieJim action routine? Dave Lyons Yes. WinkieJim Well I know I'm not useing SetVis in my code.... Matt DTS But whoever's trashing your VisRgn probably is... Dave Lyons Matt, maybe or maybe not. Dave Lyons (Many region operations just modify the data in the existing handle.) Matt DTS That's not very fastPort-friendly of them, is it? Dave Lyons Matt, what? Yes, it's fine. FastPort only means you can cram new values into the port, not that Dave Lyons you can't do any operations on the port's regions. WinkieJim Um...I do do a StartInfoDrawing before doing this...any thing it there that WinkieJim may cause this? Dave Lyons Jim, before doing what? You need to be pretty careful what you do between StartInfoDrawing Dave Lyons and EndInfoDrawing--like don't make *any* Window Manager calls, I think! (It's documented.) WinkieJim I've already done a EndInfo by this time... Matt DTS (InvalXXX, by the way, is a Window Manager call.) WinkieJim just a call to SetMenuBar and MenuKey WinkieJim between the StartInfo and EndInfo Matt DTS Are you invalidating anything between StartInfoDrawing and EndInfoDrawing? WinkieJim nope WinkieJim well ga I've got enough to fool with it a bit... Matt DTS Well, OK. Post in the BB if you need more help. Toleth #1 Where do I go for more information on animation ? AFL GaryJ What *kind* of information are you looking for? AFL GaryJ There are a number of areas online where you can get some information. Toleth I would like to study animation like in the king quest series games.. Toleth I have studied DYA tech #3 and mvn mvp (block moves) AFL GaryJ There are some excellent "tech notes" and sample programs in our software library. AFL GaryJ Also, we've had some good discussions on this in our message boards. AFL GaryJ There have been a number of articles written in times past, for magazines AFL GaryJ like Call A.P.P.L.E. (RIP) and 8/16 (RIP) Toleth I am downloading them as well, but I would like more information on complex Toleth animation as in the games . AFL GaryJ You are always welcome to ask specific questions here or in our message boards. AFL GaryJ It is difficult to always find exactly what you are looking for in learning AFL GaryJ to do animation programming. Just about EVERY programmer does it AFL GaryJ differently, and in reality, for the game to have good performance, they pretty much AFL GaryJ need to each be custom designed, unless a "series" of games is planned which AFL GaryJ uses the same basic graphics engines (like the "Space Quest" series, for example) AFL GaryJ Do you have a specific question we can address here? (Or you can ask question AFL GaryJ number 2) Toleth hmm, then how does one accomplish a animated man moving around a tree Toleth in front of it and then behind it Clipping regions??? AFL GaryJ In front and in back of the tree? Toleth yes AFL GaryJ Ok. The basic principle would be to set up some sort of hidden "mask" (that represents the AFL GaryJ shape of the tree for the man to "walk" behind). A "mask" may be AFL GaryJ a bitmap, stored in memory, and may be the same size as the graphic screen itself. AFL GaryJ You could determine if the guy has to be drawn with out using the mask at all (i.e. in front of the AFL GaryJ tree), or by using the mask to block out parts of the shape of the man (i.e. in back of the tree) AFL GaryJ by his relative vertical position on the screen. Dave Lyons A different appraoch, sometimes-slow but useful sometimes, is to figure out what area of the screen Dave Lyons will be affected, make an *off screen* area that you fill with your background, then draw all the Dave Lyons shapes in that area from back to front. Once they're all drawn, copy that area to the real Dave Lyons screen as fast as you can (synchronized with VBL if needed to avoid flicker). ga AFL GaryJ As you can see, there are many ways to skin a cat :) Sheppy Programmers love to argue about animation techniques... :) Toleth ok, something to think on and Q#2 Toleth Dealing with SYNTHLAB song formats, how is the Time stamp high,mid,low Toleth used ? AFL GaryJ Hmm.... I think you just jumped the knowledge barrier here (maybe :) AFL GaryJ Anyone do anything with synthLAB songs? AFA Jay This is in the sequence format? Toleth yes AFL Marty Post a question on the message boards. Mike Nuzzi visits here a lot... AFL Marty he knows quite a bit about synthLAB songs. AFL GaryJ Thanks, Marty. Good suggestion. Elmo Dorf What ever happened to the 'Animation Tools'? Will they ever be released? AFL GaryJ Last I heard, they were put on hold, and no definite plans of release. Matt DTS There's no word on the Animation Tools.