America Online APPLE II DEVELOPMENT FORUM CONFERENCE LOG Tuesday, January 5, 1993 10:00 p.m. Eastern Time Topic: Assembly & General Questions Forum Leader: Gary Jacobson (AFL GaryJ) AFL GaryJ Welcome to the Apple II Development Forum! AFL GaryJ Tonight, our topic (should we decide to accept it) is Assembly AFL GaryJ Language Programming. AFL GaryJ See how much assembly code you can squeeze into 5 megs of memory!! AFL GaryJ (probably about 5 megs worth, eh? :) AFA Jay too much :) LL AndyW A ton of it! Barnabas Wow! That's a lot of NOP's, eh? :) AFL GaryJ Yeah, lots of development time :) LL AndyW How about BRA +0!! AFC SteveB or BRL +0? :) LL AndyW or.. JML *+4! AFL GaryJ How many mili-seconds would it take for a program with nothing but NOPs (and a JML AFL GaryJ at the end of the bank) to execute in 1 meg of memory? :) Barnabas Better yet, a long stream of JSL *+4's (make sure you got lots of stack space) AFA Jay what's a nop, 1 cycle? Barnabas NOP=2 cycles. AFA Jay oh, yah :) LL AndyW I know an even wierder one... AFL GaryJ What, Andy? LL AndyW PEA *+whatever it is, PHK RTL Barnabas The answer is: .081854 sec.! AFA Jay at what speed? Barnabas (On a stock GS at fast mode) LL AndyW Whoops. That's PHK, PEA *+2, RTL AFA Jay what'd you use, 2.7? DanP18 does the gs have the long cycle at 2.7 mhz? AFL GaryJ That's a good trivia question :) AFL GaryJ (We should use that kind of thing the next time we do one of our games) AFA Jay What IS the fast mode speed :) AFC SteveB Or you could do some self-modifying code, Andy :) Barnabas 2.562000, which is my best calculation of GS speed (in RAM) AFL Marty (The question about slowing down the IIc+ would be a good trivia question :) AFL GaryJ Yes, it would, Marty :) AFL Marty We might get lucky and actually get an answer :D AFC SteveB Hey, I got a Font Manager-type question... AFL GaryJ Go for it, Steve AFC SteveB How can I install a font ($C8 standard font) and make the Font Manager AFC SteveB treat it as it's own? AFL GaryJ Define "as it's own", Steve. AFC SteveB Hmmm... so the font manager think it's one that has been installed AFC SteveB at startup time, and appear in all the Font Manager's internal tables. LL AndyW Might want to wait and see if Matt shows up for that one.. Sheppy How are you installing this font? I don't quite follow you. JWankerl You could patch all the relevant tool calls..... ;-) AFC SteveB I'm not... I'm asking how, Eric. :) Joe: Ack! Sheppy That's always good for some cheap thrills, Joe. :) Sheppy Er... in your question, you ask how to get the font mgr. to recognize a font Sheppy once it's installed. Are you talking about "installed"="loaded" or "installed" Sheppy ="placed in */system/fonts" ? Barnabas Why not just use AddFamily and AddFontVar? AFL GaryJ Why don't you repeat your question so Matt can hear it, Steve :) Sheppy Do you want to insert it into "Font.Lists"? Is that your question? AFC SteveB Here's the question. AFC SteveB I want the use to be able to choose a font file... AFC SteveB ...and have my program load it in and throw it into the font manager's AFC SteveB internal tables so it treats it like the font manager itself loaded it AFC SteveB in at startup time. Font/DA installer does this. How do I? :) Sheppy Ah! I see what you're getting at. LL AndyW You mean so that when your program exits, it's still there.. Barnabas Well, AddFamily then AddFontVar is nearly what you're asking for... Barnabas ...unless you don't want the bit set that says "application installed font". AFC SteveB My program really isn't a program... it's a patch to a toolbox call... AFC SteveB so I'd like it to be system-wide. Matt DTS If you want it to stick around after FMShutDown, you have to patch FMStartUp or hook in at some Matt DTS point after it's called. That's your only choice. JWankerl See - I told you to patch... ;-) AFC SteveB Ok... fun. :) Thanks :) AFL GaryJ Good question, Steve :) AFA Jay This is funny...I have a question about... AFA Jay MoveTo :) Sheppy MoveTo? :) AFA Jay MoveTo :) AFA Jay This is really strange, and it's been REALLY bothering me. AFL GaryJ That's what I thought he said :) AFA Jay I have an offscreen grafport. AFA Jay It's painted into a window. AFA Jay I draw some text to the grafport in a big font, say like Geneva 48. AFA Jay Then I switch to Shaston 8 to draw some more text. AFA Jay After moving to the place I want, and drawing in Shaston 8, it ends up drawing AFA Jay it somewhere different, if within the grafport at all. Sheppy Oh, good. It's more complicated than just MoveTo. If it was just MoveTo, I'd Sheppy have started worrying about you, Jay. :) AFA Jay It's predicable, if I keep moving to the same place... AFA Jay it draws in the same place... Barnabas Are you using local coordinates for your MoveTo? Matt DTS "it" ends up drawing. Where is the pen when you start drawing in Shaston, and how did it get there? AFA Jay Yah... AFA Jay I do a series of MoveTo/DrawChar in the big font... AFA Jay then another loop of MoveTo/DrawChar in Shaston. AFA Jay It's strange, I do a MoveTo(10,10) and draw something, then move back there AFA Jay change the font and draw again, and it goes elsewhere. AFA Jay I did the same thing in NiftyList, it's nothing in my program. Matt DTS You're aware that different fonts have different baselines, right? Or are you talking _radically_ Matt DTS different places where the two letters show up? AFA Jay Ok, one shows up at 10,10... AFA Jay the second one shows up about 500,2000 :) Barnabas Sounds radically different... AFC SteveB Hell of a baseline ;) AFA Jay Sometimes, it'll work correctly, like near the top of the grafport... AFA Jay but beyond 50 it really loses it :) AFA Jay y=50 I mean Barnabas What is the size of your offscreen bitmap?: AFA Jay Usually like 2000-3000 pixels wide by about 500 high AFA Jay Now, the strange thing... AFC SteveB Offscreen bitmaps are so cool... and they reallt aren't that hard to set up :) AFA Jay If I use something like Geneva 12 and then Shaston 8, it works fine. AFA Jay But a BIG font, and Shaston 8 it gets funny. Barnabas What do you mean "like 2000-3000 pixels wide"? AFA Jay Ok, say 500 bytes wide, you asked how big it was. AFA Jay I use SetFont(GetSysFont()) to set to Shaston 8, is that bad? Barnabas Is this width a variable thing, something that you maybe set on the fly? AFA Jay Yes, I calculate the size of the grafport, then draw into it. Barnabas You aren't using the Font Manager, Jay? AFA Jay Nope AFA Jay I could, though. AFL GaryJ QuickDraw, right? Barnabas Which GrafPort's size are you calculating? AFA Jay what do you mean? Barnabas You said that the offscreen bitmap is variable width, you calculate the size Barnabas of the GrafPort, then draw into it... which GrafPort's size are you calculatin? AFA Jay it's variable width and height. AFA Jay I calculate how many pixels I need vertically and horizontally... AFA Jay I take the horizontal value and divide by 4 and make sure that's divisible by AFA Jay 8...like the rule says. AFC SteveB for the offscreen bitmap :) Barnabas Ah, OK. Barnabas Which font causes the problem again? AFA Jay From what I can tell, anything larger than 48 points. AFL GaryJ And, all fonts smaller than 48 points work fine? AFA Jay all I've tried. Barnabas Hmmm...and you're not using the Font Manager...how are you getting these fonts? AFA Jay Loading them from disk. Barnabas Manually? Sheppy That's how it's done, Greg. :) Spottysoft :) AFA Jay I don't do it MANUALLY, the computer does it :) Barnabas Never seen anyone loading them manually, Eric! AFL GaryJ LOL! Barnabas So, you are using the Font Manager? AFA Jay Open, Read, Close... AFA Jay strip off the title string... AFC SteveB He's using QuickDraw II to use it :) AFA Jay bingo, a font :) AFA Jay Use SetFont to that handle and you can draw with it. AFA Jay (with the correct SetBufDims, of course) :) Barnabas Well, after all the work I did testing the Font Manager, and he bypasses it! :) AFC SteveB (And I'm patching it :) Barnabas Oh, is there no decency, no piety, no justice left on the earth? :) AFL GaryJ Looks like another mystery, Jay :) Barnabas Jay: Only thing I can think of is that your fonts my be overflowing QD's Barnabas buffers... AFL GaryJ That's what I was wondering, Barnabas. (I've never used anything larger than AFL GaryJ 24 with Quickdraw, so I don't know how it behaves) AFA Jay I did SetBufDims. Barnabas Yes, and with memory too, Eric! :) Sheppy Well, yeah, okay, that... :) AFC SteveB I have a MenuHandle hanging around that's not attached to AFC SteveB any menu bar... (I use it for making my own menu with PopUpMenuSelect)... AFC SteveB What's the best way to modify this menu (add check marks to the items, etc) AFC SteveB ...Perhaps create a hidden pop up menu, and double with it, eg... AFC SteveB Do SetMenuBar(hiddenPopUpsControl) and modify it (while the pop up AFC SteveB is modifyhing my MenuHandle)? I know that last sentence didn't make AFC SteveB any sense, but I'm tired :) AFL Marty It made sense to me. (NOW you can worry :) AFC SteveB ;) AFC SteveB Ok, I think what I'm thinking about will work. I'll try it. Barnabas So, Jay, what sizes did you pass to SetBufDims? AFA Jay let me check :) AFA Jay Ok, SetBufDims... AFA Jay ok, maxWidth I put in the width of my offscreen grafport in bytes AFA Jay maxFontHeight I use the height of the font or Shaston 8, which ever is greater AFA Jay then maxFBRExtent I use the FBRExtent of the font or Shaston 8, whichever is AFA Jay greater. AFA Jay I don't think it's a problem with that... AFA Jay cause the big font draws just fine... AFA Jay the little one doesn't. :/ Barnabas I was thinking, what does QD do if it overflows the buffer? (Answer: Probably Barnabas does what it always does when it runs out of room... barfs on somebody's mem.:) LL AndyW die a horrible death! Matt DTS Jay, is there a good reason _why_ you're not using the Font Manager? AFL GaryJ We need a Dave Lyons here to answer that :) AFA Jay Because I want to be able to load any $C8 font, anywhere. Matt DTS That's not an answer. AFA Jay enlighten me. Matt DTS The Font Manager does that. Why aren't you using the Font Manager? AFA Jay I guess I don't have the correct answer. Matt DTS You need to play around with InflateTextBuffer, SetBufDims, ForceBufDims, etc. Matt DTS It's a pain in the butt and mostly unnecessary because the Font Manager does it for you. I haven't Matt DTS heard a good reason why you're not using it (you may think there's a limitation it doesn't have), Matt DTS so until I do my answer is "use the Font Manager." AFA Jay how? Matt DTS QuickDraw chapter. Barnabas I wholeheartedly agree! Matt DTS (I probably shouldn't even be here tonight because I'm in a bad mood. Don't take it personally, Jay.) AFA Jay Ok, can someone clue me in, there are 278 pages of QuickDraw. Matt DTS Jay: Matt DTS The Font Manager _exists_ because trying to do it yourself is hard. Matt DTS There aren't any pre-prepared articles or methods to follow because the Font Manager works for most Matt DTS folks. If I wanted to do it myself, I'd have to read up on all the calls and play around with it Matt DTS until I understood it -- and that's what you'll have to do, and it still might not work in all Matt DTS cases unless you want to test every font there is. That's why the Font Manager is there -- so folks Matt DTS like Barnabas could test it and you could use it. If you insist on not using it, this is about as far Matt DTS as I can go with advice -- I've never done it and I don't intend to and I wouldn't recommend you do it Matt DTS either. AFA Jay ok, I'm done. Barnabas If it still has problems with the Font Manager, Jay, I'd be glad to help out... AFL GaryJ I was just checking to see what kind of sample source code we AFL GaryJ had in the library dealing with font handling... AFL GaryJ The only thing I noticed was a "change the menu bar font", Pascal AFL GaryJ source code. AFL GaryJ (The source code I mentioned DOES use the Font Manager) AFL GaryJ (or so it says) GNO Jawaid Okay. I've got these serial drivers, see, and they're slow, see, you GNO Jawaid dirty rat.. GNO Jawaid Well anyway, to make a long story short, to write a char to the serial GNO Jawaid port I currently have to make two FWEntry calls: GNO Jawaid Status, to see if the firmware has room for the char, and then of course GNO Jawaid a write. LL AndyW check the DCD line too.. GNO Jawaid Using FWEntry to call this Status routine costs a LOT of overhead. GNO Jawaid I can cut my (rather large, thus slow drivers) in half by extending my GNO Jawaid "let the firmware do interrupt processing and move data manipulation to GNO Jawaid native code" paradigm that I used to get serial reads up to speed. GNO Jawaid So, I sends a letter to DevSupport asking what the Status routine checks GNO Jawaid and get the Classic(tm) answer: "Apple does not discuss internal structures GNO Jawaid or implementation of operating system functions". GNO Jawaid Unfortunately, that's not what I asked, so I'll try here. Anyone ever Matt DTS Jawaid: "Tell me exactly how the firmware works so I can duplicate it." GNO Jawaid taken the serial firmware Status routine apart? Matt DTS DevSupport: "Go away." Matt DTS :) GNO Jawaid Well, yah, ya got it in a nut shell there Matt. :) AFL GaryJ :) AFL GaryJ FWEntry probably adds a bit of slowness to your calls. You could avoid it (but I'm AFL GaryJ not sure if rolling your own bank 0 code is faster than FWEntry or not) Matt DTS If Apple had wanted such details published, they'd have published the firmware source. GNO Jawaid I tried my own bank 0 code, but it doesn't work and nobody can figure GNO Jawaid out why. Matt DTS Did you take DEVSUPPORT's other advice and use GetFuncPtr to avoid the overhead of the tool dispatcher Matt DTS ? AFL GaryJ That's right, you asked about it here. GNO Jawaid Yes, Matt, I did. I got about a 25% raw improvement just through that. GNO Jawaid But that's still not enough; it maxes out at around 1100 cps on a 9MHz IIgs. LL AndyW Jawaid, see Apple IIgs technote #18.. Matt DTS Your routine isn't going to get much faster than FWEntry, except if you remove a few checks just Matt DTS for video mode checking (looks for slot 3 addresses). Otherwise it's pretty darn tight. AFL GaryJ I have some bank zero code that I know works. I could send you a sample, if you'd like. GNO Jawaid Gary- please do, I'd love to see it. LL AndyW Next, see the SCC header file in the BW library for registers of the SCC Matt DTS But you still have the basic problem that you're not willing to deal with. GNO Jawaid Matt- my routine will be orders of magnitude faster if I look at the GNO Jawaid firmware's data structures directly like I do for serial reads. AFL GaryJ But, as Matt says, I guess it wouldn't improve your speed all that much. AFL GaryJ (But I will send it) Matt DTS Uh-huh. And that's the problem. Matt DTS You have two choices: "Use the firmware" or "Don't use the firmware." GNO Jawaid Okay, so Apple should do it. And that's the other problem. GNO Jawaid :) Matt DTS You _want_ "Use the hard parts of the firmware and do the easy parts myself." That's not a choice. Matt DTS You can't use half the firmware at this point. You can use it all, or you can use none of it. LL AndyW Only problem with not using the firmware is dealing with AppleTalk.. AFL GaryJ I'd like to write some of my own code to access the serial hardware directly too, but I've AFL GaryJ YET to find the correct address or phone number to get the Zilog data sheets. AFL GaryJ (Only have the Advanced Micro Devices info) Matt DTS He can find out the AppleTalk channel number from GS/OS without too many problems. GNO Jawaid See, my point is that the firmware has already done everything that needs GNO Jawaid to be done. Apple never created a fast, native-mode entry to the firmware GNO Jawaid though; and that's what I'm trying to do. Matt DTS So it doesn't do everything that needs to be done. Matt DTS And it depends on bank zero and some other stuff. It wasn't designed for your needs, and, as usual, Matt DTS you won't admit it. GNO Jawaid Of course not. GNO Jawaid :) LL AndyW We use the firmware for everything but setting the baud rate.. GNO Jawaid Are you in emulation mode, Andy? LL AndyW Can't get 57.??? baud that way.. (yes Jawaid).. LL AndyW This is from P8.. GNO Jawaid Then you don't have to deal with FWEntry... it may not seem like a lot of GNO Jawaid overhead, but per-character it is. Matt DTS Anyway, I've said my piece. I won't be listened to, but I've said it. LL AndyW No, but if the buffer is large enough, you should do ok.. GNO Jawaid Matt- when your 'piece' not only doesn't include a solution but doesn't GNO Jawaid even point towards one, then that's to be expected. LL AndyW One problem is making sure the handshake is right for the modem and cable LL AndyW you're using. If it isn't, it won't work. LL AndyW And, if you have the bad buffer chip, you got more problems.. GNO Jawaid Actually, the buffer chip isn't flawed- Proterm's driver set up the SCC GNO Jawaid incorrectly. GNO Jawaid There's a fix driver available. LL AndyW Really? I thought the 'fix' was a multiple check of the CTS line to be sure LL AndyW of it's state.. GNO Jawaid Everyone- I understand Matt's points, but I'm trying to come up with a GNO Jawaid solution for the many, many people who want to program the IIgs serial ports GNO Jawaid and either have to use FWEntry (2400 baud maximum) or TextTools (even worse) GNO Jawaid or bank 0 assembly emulation mode routines ("I don't know assembly") GNO Jawaid or even worse hacks, like Modem Manager. GNO Jawaid Andy- they did some more research (and an Apple engineer suggested this) GNO Jawaid and found out that Proterm was setting up the line as an output instead GNO Jawaid of an input. Some buffer chips just happened to work like this. GNO Jawaid Anyway, I guess I'll just do it the hard way and plow through the firmware GNO Jawaid with ORCA/Disassembler. :) LL AndyW Good luck! LL AndyW (I just love disassembling ROM.. No relocation records to help out!!) LL AndyW You know one problem Jawaid? Try to get an unmodified banks E0 and E1!! GNO Jawaid Hmm..