TweetFollow Us on Twitter

Apr 89 Letters
Volume Number:5
Issue Number:4
Column Tag:Letters


By David E. Smith, Editor & Publisher, MacTutor

Aztec C

Rich Heady

San Diego, CA

Aztec C is all I was told it would be, and I’m already pleased with the results. It is particularly gratifying to have access to “intermediate code” again after being locked inside Lightspeed C’s projects for the past 18 months, and more gratifying still to find the assembly code already optimized to the point where I may not need to go through cleaning up the little stupidities. There is nothing wrong with Lightspeed C; in fact, it remains a superior prototyping environment. But at the point where I began to look beyond the prototype to a shippable product, it was a relief to find Aztec C ready to finish the job. Aztec C might carve a bigger niche in the Macintosh world by appealing to the “1 Meg programmer” who wants to produce polished code without larding on RAM and without wading into the complexity of MPW.

Typos upon Typos

Ajay Nath

Oakland Gardens, NY

I’ve been writing a driver for my plotter, and I’ve been looking at the code you presented in MacTutor, Volume 3, Number 11 and 12. I’ve caught some errors in the code you presented on page 57 (#12). The code in the procedure DrvrStorage():


asm {
 MOVEQ  #8, D0
 MOVE.L UTableBase, A0
 MOVE.L (A0), OutDctlEntry

I wrote to you about this error before, but you printed my correction incorrectly! (You did print my explanation of why the author’s code was wrong correctly.) [Sorry, we will double our efforts. -ed]

On page 59 in the procedure MyPrDlgMain() at the end of this proc a pointer is freed and then accessed as follows:

/* 2 */

free(+p); /*ptr is being freed by a subroutine */
if (tp->fDolt) (void) MyPrValidate(hPrint);
 /*we accessed the ptr we freed */
return (tp->fDolt); /* you did it again! */

if (tp->fDolt) is true the subroutine “MyPrValidate” will be called, and it calls traps like GetResource and LoadResource which will move memory so that doing a subsequent “return(tp->fDolt)” may be pointing to garbage.

One way to fix this is to do the following:

/* 3 */

{ Boolean theResult; 
 /* a local variable to hold function result */
theResult = tp->fDolt; /*save the value of fDolt */
free (tp);
if (theResult) (void) MyPrValidate(hPrint);
return (theResult);

on page 58 in the procedure “MyPrintDefault(hPrint)” one of the lines:

**hPrint = **theDefault;

the same line appears on page 59 near the end of the procedure MyPrValidate(hPrint)

What the author is trying to do is to fill in the fields of the data structure that hPrint points to, what he actually does is mess up the hPrint handle. What he should do is something like this:

/* 4 */
BlockMove(*theDefault, *hPrint, sizeof(TPrint));

and probably:

/* 5 */

 /* unload resource now that we’re done */

It is a good article which provides information on how to write printer drivers, but some of the code is incorrect.

In MacTutor, Vol. 4, #11, the code presented by Donald Koscheka to do a string comparison uses the “DBRA” instruction incorrectly. When you loop using “DBRA” you use the word (16 bits) in the register you use as a loop counter; Mr. Koscheka uses register D1 as his loop counter and sets its value by doing:

 MOVE.B (A))+, D1; get length of string 1

This sets the lower 8 bits of D1, NOT the lower word. The correct way to load the value of the loop counter in this case is to:


            MoveQ #0, D0; set D0 = 0;
            Move.B(A0)+, D0      ; D0 = string length

Also when using the “DBRA” instruction, the register must actually have the loop count -1 in it, i.e. if you want to loop 10 times, put 9 in the register. Mr. Koscheka doesn’t do this. I realize that he was showing a code fragment, but the purpose of his article was to show how to use assembly language and allowing such errors to slip in does readers a disservice.

FORTRAN Math Libraries

Michael M. J. Tracy

Pittstown, NJ

I am writing in response to Tatsuhito Koya’s request (Feb 1989, Vol. 5 No. 2) for information on FORTRAN math libraries that will run on the Mac. There is an excellent book out called ‘Numerical Recipes: The Art of Scientific Computing’ by William H. Press, Brian P. Flannery, Saul A. Teukolsky & William T. Vetterling (Cambridge University Press, ISBN 0 521 30811 9). I refer to this book infinitely more often than ‘Inside Macintosh’ when writing scientific applications on the Mac (and it’s cheaper too, about $35 hard cover). The book provides the source code for over 200 subroutines. Its real value to the user, however, is in the eloquent and intelligent discussion of the principles underlying each algorithm, explaining the strengths and weaknesses, and usually providing alternative algorithms so that the cautious user can cross check results. I have learned a lot from this book. Listing from the contents page, the book covers; solution of linear algebraic equations; interpolation and extrapolation; integration of functions; evaluation of functions; special functions; random numbers; sorting; root finding and non-linear sets of equations; minimization and maximization of functions; eigensystems; fourier transform spectral methods; statistical description of data; modeling of data; integration of ordinary differential equations; two point boundary value problems; partial differential equations. There are two versions of the book. The original edition gave the subroutine listings in both FORTRAN and Pascal. By popular demand, a second version was released which presents the C source code listings (written somewhat from the perspective of a FORTRAN programmer who wishes to convert to C, and provides structures and functions for handling complex numbers). Macintosh compatible disks containing the source code are also available from the publishers.

All FORTRAN subroutines that I have used work well, and have compiled without any problems under both MacFortran and Language Systems Fortran. Some subroutines, however, need to have the ‘SAVE’ statement added at the beginning (as required by the ANSI 77 FORTRAN standard) if local variables need to be preserved between subroutine calls, such as in the random number generators.

Further Optimizations

John F. Reiser

Beaverton, OR

The code for optimized string comparisons (Letters, Jan. ’89, p. 106) is on the right track, but the listing contains a bug and the inner loop can be improved further. If the length of the first string is 128 or more, then the iteration count in register D1 gets an incorrect value via sign extension using EXT.W. The loop can be shortened by combining the break-out test with the iteration count control:


A0 -> Pascal string 1
A1 -> Pascal string 2
D0 <- 0 if not equal, 1 if equal

CompareString  Moveq #0,D0; clear high bits
 Move.B (A0), D0 ; length of first string
@10Cmp.B(A0)+, (A1)+ ; mismatch?
 Dbne D0, @10  ; stop when .ne., or at end
 Sne  D0; D0.B = -1 if .ne.; 0 if .eq.
 Addq.B #1, D0 ; D0.B = 0 if .ne.; 1 if .eq.
 Ext.W  D0; Dbne can set bits 7-15

VBL Animation Problems

David Oster

Berkeley, CA

I am appalled by Dick Chandler’s article, “VBL Task Animation” in the February 1989 issue of MacTutor. Yes, his program works, but only because it is a top. Any real program that tries the technique he describes will fail miserably.

Look, his VBL task calls GetIcon and PlotIcon at VBL interrupt time. In his application, the main loop just busy waits for the user to press the Button. A real application would be calling GetNextEvent(), or doing something. For example, each time the user looks at a menu. When the menu goes away, it slams those bits back and deallocates the handle.

GetIcon calls GetResource(). What if the VBL task calls it while the Memory Manager is shuffling the heap to allocate memory for the main loop. Crash city. PlotIcon calls CopyBits(), which clips against the clipRgn and visRgn of the underlying grafPort. What if the VBL task calls it while the Memory Manager is shuffling the heap to allocate memory for the main loop? Crash city.

Even if your program is clean, you do not know what trap patches the user has installed: Maybe he is using an INIT that overrides some trap your program needs, and the override will do memory allocation. For example, Dick’s program calls Button() from its main loop, and many INITs override button, so they will get called while the mouse is down.

So, you can only do animation at interrupt time if you can guarantee that no user or system task will allocate memory in the main loop.

Dick’s program doesn’t guarantee this, since it calls Button() from its main loop, and Button() may have been overriden by an INIT. Since there is so little the main loop can safely do, you might as well give up on VBL Task animation, and just do animation in your main loop, busy waiting until TickCount changes to pause between animation frames.

TWindow Manager Update

Thomas Fruin

Las Condes, Santiago, Chile

After a four month trek through the Latin American country of Peru (that left me penniless), I was delighted upon arrival at my fathers place in Santiago de Chile to find last December’s copy of MacTutor with my Tool Window Manager article. And the generous cheque that was included couldn’t have come at a better time!

Since the article was sent off to you, several programs have been written making use of TWindow. This caused a few small bugs to surface. I would like to take this opportunity to correct them.

The TWindow Manager incorrectly assumes that the calling application will always process every activate or deactivate event by calling TGetNextEvent. However, when multiple dialog boxes are put up, or dialogs following other dialogs without a call to TGetNextEvent in between, some activate or deactivate events may “linger”. This may cause the wrong (de)activation to occur when TGetNextEvent finally is called.

My solution is a utility function FlushActivateEvents(), with the following code:

/* 8 */

static void FlushActivateEvents()

 toBeActivated = toBeDeactivated = nil;
 result = GetNextEvent(activMask, &theEvent);
 result = GetNextEvent(activMask, &theEvent);

When called, this function effectively flushes (removes) every activate and deactivate event from the system: both official events and TWindow Manager internal events.

A call to FlushActivateEvents needs to be inserted in THideWindow and another call in TShowWindow. Both these calls should be made right after the very first if statement, where is checked if the window is still visible or invisible. That is all.

A minor oversight is that the WindowExists function is not defined static. It should be because it is internal to the TWindow Manager.

Finally, I can announce that I have written an MPW Pascal INTERFACE unit, that allows you to call the TWindow Manager from MPW pascal programs. This required more small modifications to the TWindow Manager source. As soon as I get someone to send me my disks from Holland, I will send the new versions of the software to MacTutor. By the way, this version of software also includes a TWaitNextEvent (although this is a trivial addition).

Publication of my article has definitely encouraged me to write more, so expect to see other stuff from me!

Absoft MacFortran to LS Fortran

Bert Waggoner

Riverside, CA

After over a year of reading your journal and programming the Macintosh things are beginning to make a little sense. Now I’d like to give a little back. Here are some notes on the new Language Systems Fortran compiler for MPW that you may wish to pass on to other readers:

I just received the Language Systems (LS) Fortran compiler v1.2 for MPW, and it looks very good. Now, using MPW, I can code in C and have access to the vast array of scientific subroutines written in Fortran (including those of my boss, who is reluctant to learn another language. We are developing chemical transport models for the Macintosh, and, until now, I have been translating his Fortran code to Think C. Microsoft C and Fortran for the IBM PC’s have been on speaking terms for some time - it’s about time the Mac caught up).

Here are some changes I had to make to get an Absoft MacFortran program to compile with LS Fortran:

- the preconnected file units for screen and printer I/O are reversed!

- any WHILE ( )/REPEAT loops must be replaced by DO WHILE ( )/END DO,

- LS Fortran doesn’t have a SELECT CASE statement (sigh),

- IF statements must have enclosing parentheses, i.e. use IF (X .EQ. Y) THEN, not IF X .EQ. Y Then,

- the ACCEPT statement must specify a format,

- there were several differences in filing handling, such as no POSITION or ACCESS key words for the OPEN statement IN LS Fortran.

There are, undoubtably, many other differences. As for toolbox access, LS Fortran’s implementation is different and cleaner, and the language allows for structures. Last, but not least, LS Fortran has a decent manual with lots of examples. Now my problem is converting my Think C code to MPW C. Would any readers like to share their experiences with this?

SysEnvirons From MacFortran

James Wishart

Long Island, NY

In the course of developing an instrument control and data acquisition application in Absoft MacFortran/020, I needed to call SysEnvirons to check for the 68881 floating point processor. Unfortunately, Absoft did not include the trap dispatch parameter for the call in their include files. With the help of additional documentation on the Toolbx.sub routine provided by Lee Rimar of Absoft, I found the correct parameter to be z’09014010'. The following program demonstrates how to call SysEnvirons in Absoft MacFortran.

c 9

program TestSysEnvirons
implicit none

integer*4 toolbx
integer*2 oserr, i
integer*4 version

integer*1 SysEnvRec(16)

integer*2 environsVersion
integer*2 machineType
integer*1 systemVersion(2)
integer*2 processor
logical*1 hasFPU
logical*1 hasColorQD
integer*2 keyBoardType
integer*2 atDrvrVersNum
integer*2 sysVRefNum

equivalence (SysEnvRec(1), environsVersion)
equivalence (SysEnvRec(3), machineType)
equivalence (SysEnvRec(5), systemVersion(1))
equivalence (SysEnvRec(7), processor)
equivalence (SysEnvRec(9), hasFPU)
equivalence (SysEnvRec(10), hasColorQD)
equivalence (SysEnvRec(11), keyBoardType)
equivalence (SysEnvRec(13), atDrvrVersNum)
equivalence (SysEnvRec(15), sysVRefNum)

Parameter (SYSENVIRONS = Z’09014010')
oserr = 0
version = 2
do (i=1,16)
 SysEnvRec(i) = 0

oserr=toolbx(SYENVIRONS, version, SysEnvRec)

if (oserr .ne. -5501) then
 write(9,*) ‘environsVersion = ‘, environsVersion
 write(9,*) ‘machineType = ‘, machineType
 write(9,1) systemVersion(1), systemVersion(2)
1format(‘systemVersion = ‘, z2, “.”, z2)
 write(9,*) ‘processor = ‘, processor
 write(9,*) ‘hasFPU = “, hasFPU
 write(9,*) ‘hasColorQD = ‘, hasColorQD
 write(9,*) ‘keyBoardType = ‘, keyBoardType
 write(9,*) ‘atDrvrVersNum = ‘, atDrvrVersNum
 write(9,*) ‘sysVRefNum = ‘,sysVRefNum
select case (oserr)
 case (0)
 case (-5500)
 write(9,*) ‘System version is less than 4.2’
 case (-5501)
 write(9,*) ‘Bad version selector - no data returned’
 case (-5502)
 write(9,*) ‘Version ‘, version,’ requested, version ‘,
+environsVersion, ‘ returned.’
 case default
 write(9,*) ‘Unspecified error #’, oserr
end select

write(9,*) ‘Hit RETURN to exit program’

A Usenet message from David Phillip Oster brought my attention to the fact that programs should watch for disk insertion events in their main loops and call DIBadMount if the inserted disk cannot be mounted. Implementing this feature requires two more undocumented trap dispatch parameter, DIBadMount (z’9E952200', routine #0) and DIUnload (z’9E908000', routine #4) from Pack2, Disk Initialization. The following code fragment uses the event manager variables defined in the example in the MacFortran manual. (Notice that the Pack2 routine selector must be added to the end of the argument list.) See Inside Macintosh Vol. 2 for the result codes returned in the two byte variable err.

c 10

select case (what)
 case(7)! 7 = Disk insertion
 if (shift(message, -16) .ne. 0) then
 call toolbx(INITCURSOR)
 err = toolbx(DIBADMOUNT, z’00640064', message, 0)
 call toolbx(DIUNLOAD, 4)

The remaining Pack2 parameters should be as follows, but I have not tested these: DILoad: z’9E908000', routine #2; DIFormat: z’9E949000', routine #6; DIVerify: z’9E949000', routine #8; DIZero: z’9E94E200' or z’9E94C200', routine #10.

I want to thank Jay Lieske for his “Fortran Printing Interface” article in August, 1988 issue as well as all of the people who contributed information about Classic Mac analog board failures. Every month I pace in front of my mailbox until MacTutor arrives.

Author Incentive Program Correction

Kirk Chase

Anaheim, CA

In the December ’89 MacTutor, we made a correction on the Author Incentive Program initiated by Apple. Additional reimbursement is ONLY FOR APPLE EMPLOYEES. Those not employed by Apple DO NOT QUALIFY. We are sorry for any confusion that may have resulted over this and hope this clears up any mistaken notions. If you are with Apple, and if you want more information, please contact Stacey Farmer in public relations, who is now in charge of the program, for more information.


Community Search:
MacTech Search:

Software Updates via MacUpdate

Minecraft 1.20.2 - Popular sandbox build...
Minecraft allows players to build constructions out of textured cubes in a 3D procedurally generated world. Other activities in the game include exploration, gathering resources, crafting, and combat... Read more
HoudahSpot 6.4.1 - Advanced file-search...
HoudahSpot is a versatile desktop search tool. Use HoudahSpot to locate hard-to-find files and keep frequently used files within reach. HoudahSpot is a productivity tool. It is the hub where all the... Read more
coconutBattery 3.9.14 - Displays info ab...
With coconutBattery you're always aware of your current battery health. It shows you live information about your battery such as how often it was charged and how is the current maximum capacity in... Read more
Keynote 13.2 - Apple's presentation...
Easily create gorgeous presentations with the all-new Keynote, featuring powerful yet easy-to-use tools and dazzling effects that will make you a very hard act to follow. The Theme Chooser lets you... Read more
Apple Pages 13.2 - Apple's word pro...
Apple Pages is a powerful word processor that gives you everything you need to create documents that look beautiful. And read beautifully. It lets you work seamlessly between Mac and iOS devices, and... Read more
Numbers 13.2 - Apple's spreadsheet...
With Apple Numbers, sophisticated spreadsheets are just the start. The whole sheet is your canvas. Just add dramatic interactive charts, tables, and images that paint a revealing picture of your data... Read more
Ableton Live 11.3.11 - Record music usin...
Ableton Live lets you create and record music on your Mac. Use digital instruments, pre-recorded sounds, and sampled loops to arrange, produce, and perform your music like never before. Ableton Live... Read more
Affinity Photo 2.2.0 - Digital editing f...
Affinity Photo - redefines the boundaries for professional photo editing software for the Mac. With a meticulous focus on workflow it offers sophisticated tools for enhancing, editing and retouching... Read more
SpamSieve 3.0 - Robust spam filter for m...
SpamSieve is a robust spam filter for major email clients that uses powerful Bayesian spam filtering. SpamSieve understands what your spam looks like in order to block it all, but also learns what... Read more
WhatsApp 2.2338.12 - Desktop client for...
WhatsApp is the desktop client for WhatsApp Messenger, a cross-platform mobile messaging app which allows you to exchange messages without having to pay for SMS. WhatsApp Messenger is available for... Read more

Latest Forum Discussions

See All

‘Resident Evil 4’ Remake Pre-Orders Are...
Over the weekend, Capcom revealed the Japanese price points for both upcoming iOS and iPadOS ports of Resident Evil Village and Resident Evil 4 Remake , in addition to confirming the release date for Resident Evil Village. Since then, pre-orders... | Read more »
Square Enix commemorates one of its grea...
One of the most criminally underused properties in the Square Enix roster is undoubtedly Parasite Eve, a fantastic fusion of Resident Evil and Final Fantasy that deserved far more than two PlayStation One Games and a PSP follow-up. Now, however,... | Read more »
Resident Evil Village for iPhone 15 Pro...
During its TGS 2023 stream, Capcom showcased the Following upcoming ports revealed during the Apple iPhone 15 event. Capcom also announced pricing for the mobile (and macOS in the case of the former) ports of Resident Evil 4 Remake and Resident Evil... | Read more »
The iPhone 15 Episode – The TouchArcade...
After a 3 week hiatus The TouchArcade Show returns with another action-packed episode! Well, maybe not so much “action-packed" as it is “packed with talk about the iPhone 15 Pro". Eli, being in a time zone 3 hours ahead of me, as well as being smart... | Read more »
TouchArcade Game of the Week: ‘DERE Veng...
Developer Appsir Games have been putting out genre-defying titles on mobile (and other platforms) for a number of years now, and this week marks the release of their magnum opus DERE Vengeance which has been many years in the making. In fact, if the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for September 22nd, 2023. I’ve had a good night’s sleep, and though my body aches down to the last bit of sinew and meat, I’m at least thinking straight again. We’ve got a lot to look at... | Read more »
TGS 2023: Level-5 Celebrates 25 Years Wi...
Back when I first started covering the Tokyo Game Show for TouchArcade, prolific RPG producer Level-5 could always be counted on for a fairly big booth with a blend of mobile and console games on offer. At recent shows, the company’s presence has... | Read more »
TGS 2023: ‘Final Fantasy’ & ‘Dragon...
Square Enix usually has one of the bigger, more attention-grabbing booths at the Tokyo Game Show, and this year was no different in that sense. The line-ups to play pretty much anything there were among the lengthiest of the show, and there were... | Read more »
Valve Says To Not Expect a Faster Steam...
With the big 20% off discount for the Steam Deck available to celebrate Steam’s 20th anniversary, Valve had a good presence at TGS 2023 with interviews and more. | Read more »
‘Honkai Impact 3rd Part 2’ Revealed at T...
At TGS 2023, HoYoverse had a big presence with new trailers for the usual suspects, but I didn’t expect a big announcement for Honkai Impact 3rd (Free). | Read more »

Price Scanner via

New low price: 13″ M2 MacBook Pro for $1049,...
Amazon has the Space Gray 13″ MacBook Pro with an Apple M2 CPU and 256GB of storage in stock and on sale today for $250 off MSRP. Their price is the lowest we’ve seen for this configuration from any... Read more
Apple AirPods 2 with USB-C now in stock and o...
Amazon has Apple’s 2023 AirPods Pro with USB-C now in stock and on sale for $199.99 including free shipping. Their price is $50 off MSRP, and it’s currently the lowest price available for new AirPods... Read more
New low prices: Apple’s 15″ M2 MacBook Airs w...
Amazon has 15″ MacBook Airs with M2 CPUs and 512GB of storage in stock and on sale for $1249 shipped. That’s $250 off Apple’s MSRP, and it’s the lowest price available for these M2-powered MacBook... Read more
New low price: Clearance 16″ Apple MacBook Pr...
B&H Photo has clearance 16″ M1 Max MacBook Pros, 10-core CPU/32-core GPU/1TB SSD/Space Gray or Silver, in stock today for $2399 including free 1-2 day delivery to most US addresses. Their price... Read more
Switch to Red Pocket Mobile and get a new iPh...
Red Pocket Mobile has new Apple iPhone 15 and 15 Pro models on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide service using all the major... Read more
Apple continues to offer a $350 discount on 2...
Apple has Studio Display models available in their Certified Refurbished store for up to $350 off MSRP. Each display comes with Apple’s one-year warranty, with new glass and a case, and ships free.... Read more
Apple’s 16-inch MacBook Pros with M2 Pro CPUs...
Amazon is offering a $250 discount on new Apple 16-inch M2 Pro MacBook Pros for a limited time. Their prices are currently the lowest available for these models from any Apple retailer: – 16″ MacBook... Read more
Closeout Sale: Apple Watch Ultra with Green A...
Adorama haș the Apple Watch Ultra with a Green Alpine Loop on clearance sale for $699 including free shipping. Their price is $100 off original MSRP, and it’s the lowest price we’ve seen for an Apple... Read more
Use this promo code at Verizon to take $150 o...
Verizon is offering a $150 discount on cellular-capable Apple Watch Series 9 and Ultra 2 models for a limited time. Use code WATCH150 at checkout to take advantage of this offer. The fine print: “Up... Read more
New low price: Apple’s 10th generation iPads...
B&H Photo has the 10th generation 64GB WiFi iPad (Blue and Silver colors) in stock and on sale for $379 for a limited time. B&H’s price is $70 off Apple’s MSRP, and it’s the lowest price... Read more

Jobs Board

Housekeeper, *Apple* Valley Villa - Cassia...
Apple Valley Villa, part of a 4-star senior living community, is hiring entry-level Full-Time Housekeepers to join our team! We will train you for this position and Read more
Housekeeper, *Apple* Valley Village - Cassi...
Apple Valley Village Health Care Center, a 4-star rated senior care campus, is hiring a Part-Time Housekeeper to join our team! We will train you for this position! Read more
Optometrist- *Apple* Valley, CA- Target Opt...
Optometrist- Apple Valley, CA- Target Optical Date: Sep 23, 2023 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 796045 At Target Read more
Senior *Apple* iOS CNO Developer (Onsite) -...
…Offense and Defense Experts (CODEX) is in need of smart, motivated and self-driven Apple iOS CNO Developers to join our team to solve real-time cyber challenges. Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.