TweetFollow Us on Twitter

Color, DragRgn
Volume Number:4
Issue Number:1
Column Tag:Basic School

Color & DragGrayRgn Explored

By Dave Kelly, MacTutor Editorial Board

MAC II takes on BASIC

Yes, I know that it has been about a year since the Macintosh II was released and not a word from me on how the Basic works on the Mac II. The Mac II really is a wonderful machine, although there are still a few incompatibilities and inconveniences. But all in all I still give the Mac II an A+.

The curiosity lies in figuring out what works (or doesn’t work) on the Mac II. The Mac II has features that did not even exist when most of the versions of Basic were written. Some things like color and screen size aren’t supported properly, or at all, even though the software was capable before the Mac II came.

It’s fast. For example, just take a look at what it did for the Byte Magazine January 1983 Prime number benchmark program, known as the Sieve. ZBasic™ comes up with a 2 second time, MS Basic Binary interpreter with 129 second time (about the same as True Basic on the Mac Plus), and 15 seconds for the MS Basic compiler. Of course, everything is faster so it is all relative. Since we already know that the Mac II is faster and have a good idea about which versions of Basic are faster, there is no need to go into that here. For more information comparing the various versions of Basic, see MacTutor, Aug 1986, Feb. 1987 and Mar. 1987.

Screen Size: With the advent of the larger screen (also available for Mac Plus and SE) we see the need to be fully compatible with all size monitors. MS Basic opens its default windows to 512 X 342, the size of the SE and MacPlus screens. That works out alright since it still isn’t known what kind of Mac might be running the program. Double-clicking the title bar causes MS Basic windows to zoom to full screen size. The LIST windows won’t expand horizontally beyond the 512 limit, but will expand vertically to the bottom of the screen. The most annoying thing is that none of the windows can be moved below a certain point on the screen which is very close to the place where the bottom of the 9" screen would be (342). This means that you can never move the command window out of the way; you have to close it just like on a Mac Plus.

True Basic v. 1.1, which I haven’t looked at for awhile, opens the default window to full screen size. Of course, True Basic still has all the HFS problems and other limitations which I have discussed in past issues of MacTutor (Best of MacTutor Vol 2, pg 379 or August 1986). (Version 1.1 is the latest that I have).

ZBasic Ver. 4.1 windows also open to full screen size. There doesn’t appear to be any compatibility problems here at all. As I write this, the ZBasic promised editor has still not been completed.

Color support: This is only a big deal to those of you with a Mac II with a color monitor ( I wouldn’t have one any other way!!). As you know, the original Quickdraw supports 8 colors already. I feel that it shows short-sightedness to not at least support that much. But both MS Basic and True Basic have NO color support even though both languages include means to change color from black to white. Other versions (on other computers whose names we won’t say) of True Basic support a small set of colors. MS Basic uses color as a parameter in the syntax for the CIRCLE statement, yet you can’t get any colors except black and white.

ZBasic, however, does support the 8 colors in Quickdraw. That’s only 8 colors for now, but I would expect that they will make improvements to this in some later version (who knows when?). So meanwhile, if you want color you will have to settle with the 8 basic colors. There are a few differences between ZBasic color statements and Quickdraw color statements. In order to standardize ZBasic, Zedcor has numbered the colors from 0 to 7. Quickdraw, however, has its own designation for each color as the following chart shows:

The color codes in ZBasic and QuickDraw CANNOT be substituted for each other. You will have to either use Quickdraw graphics or ZBasic graphics or be careful not to mix the code with the wrong call. Sure, setting the color is easy, but be sure to use the right code with the right statement.

This month’s program demonstrates the colors available in ZBasic and gives you an example of its use. All you have to do is set the color before issuing a graphics drawing statement and either Quickdraw or ZBasic (which probably uses Quickdraw anyway) will use the color you selected.

What’s missing? Color QuickDraw™ that’s what. Fortunately, Zedcor has been very responsive to updating ZBasic. I’m sure that it isn’t easy for them to keep updating everyone so often. Let’s hope that the next version of ZBasic will include the long awaited editor, Color QuickDraw and other major improvements. Read on!

[The slow response by the Basic compiler makers to upgrade their products to meet the requirements of Mutifinder, System 4.2 and the Macintosh II, has been really disappointing! There is still a pressing need for a reliable, engineering oriented Basic that provides full access to the Macintosh capabilities and can function in a workstation environment (ie, it can do math correctly and quickly). We encourage both the present Basic compiler makers to address this issue, as well as those we haven't seen in this marketplace, like Borland, to enter it, and hopefully unite a fragmented and frustrated market. -Ed]

{1}
‘ColorBasic
‘MacTutor, 1988
‘By Dave Kelly

WINDOW OFF
COORDINATE WINDOW
‘A color chart for future reference
DIM rect%(3)
MENU 1,0,1,”File”
MENU 1,1,1,”Quit”
EDIT MENU 2
MENU 3,0,1,”Colors”
MENU 3,1,1,”ZBasic™ Commands”
MENU 3,2,1,”ToolBox Commands”
MENU 3,3,1,”Erase window”
theEnd=0:REM theEnd will never come.

‘Make QuickDraw Color Assignments
blackColor&=33
whiteColor&=30
redColor&=205
greenColor&=341
blueColor&=409
cyanColor&=273
magentaColor&=137
yellowColor&=69

‘Make ZBasic Color Assignments
white=0
yellow=1
green=2
cyan=3
blue=4
magenta=5
red=6
black=7
WINDOW 1,”Color Demo Window”,(4,38)-(450,200),4
GOSUB “ZBasic™ Colors”: ‘ Print something to start
ON MENU GOSUB “MenuEvent”
MENU ON
theEnd=0:REM theEnd will never come.
DO
 UNTIL theEnd

MENU OFF

“MenuEvent”
Menunumber%=MENU(0)
Menuitem%=MENU(1)
MENU
IF Menunumber%=1 AND Menuitem%=1 THEN “Quit”
IF Menunumber%=3 AND Menuitem%=1 THEN 
 GOSUB “ZBasic™ Colors”
IF Menunumber%=3 AND Menuitem%=2 THEN 
 GOSUB “QuickDraw™ Colors”
IF Menunumber%=3 AND Menuitem%=3 THEN CLS:PRINT@(1,3)”The Colors are 
now cleared!”
RETURN

“Quit”
END

“ZBasic™ Colors”
CLS
TEXT 2,14,0,0
PRINT%(170,20) “ZBasic™ Colors”
COLOR=white
BOX FILL 5,50 TO 55,100
COLOR=yellow
BOX FILL 60,50 TO 110,100
COLOR=green
BOX FILL 115,50 TO 165,100
COLOR=cyan
BOX FILL 170,50 TO 220,100
COLOR=blue
BOX FILL 225,50 TO 275,100
COLOR=magenta
BOX FILL 280,50 TO 330,100
COLOR=red
BOX FILL 335,50 TO 385,100
COLOR=black
BOX FILL 390,50 TO 440,100
BOX 5,50 TO 55,100
BOX 60,50 TO 110,100
BOX 115,50 TO 165,100
BOX 170,50 TO 220,100
BOX 225,50 TO 275,100
BOX 280,50 TO 330,100
BOX 335,50 TO 385,100
BOX 390,50 TO 440,100
TEXT 2,10
PRINT%(25,48) white
PRINT%(75,48) yellow
PRINT%(130,48) green
PRINT%(190,48) cyan
PRINT%(240,48) blue
PRINT%(300,48) magenta
PRINT%(355,48) red
PRINT%(410,48) black
PRINT%(25,112) whiteColor&
PRINT%(75,112) yellowColor&
PRINT%(130,112) greenColor&
PRINT%(190,112) cyanColor&
PRINT%(240,112) blueColor&
PRINT%(300,112) magentaColor&
PRINT%(350,112) redColor&
PRINT%(410,112) blackColor&
TEXT 2,14
PRINT%(150,140) “QuickDraw™ Colors”
RETURN

“QuickDraw™ Colors”
CLS
CALL MOVETO (170,20)
CALL TEXTFONT(2)
CALL TEXTSIZE(14)
CALL DRAWSTRING (“ZBasic™ Colors”)
CALL SETRECT(rect%(0),5,50,55,100)
CALL FORECOLOR(whiteColor&)
CALL PAINTRECT(rect%(0))
CALL SETRECT(rect%(0),60,50,110,100)
CALL FORECOLOR(yellowColor&)
CALL PAINTRECT(rect%(0))
CALL SETRECT(rect%(0),115,50,165,100)
CALL FORECOLOR(greenColor&)
CALL PAINTRECT(rect%(0))
CALL SETRECT(rect%(0),170,50,220,100)
CALL FORECOLOR(cyanColor&)
CALL PAINTRECT(rect%(0))
CALL SETRECT(rect%(0),225,50,275,100)
CALL FORECOLOR(blueColor&)
CALL PAINTRECT(rect%(0))
CALL SETRECT(rect%(0),280,50,330,100)
CALL FORECOLOR(magentaColor&)
CALL PAINTRECT(rect%(0))
CALL SETRECT(rect%(0),335,50,385,100)
CALL FORECOLOR(redColor&)
CALL PAINTRECT(rect%(0))
CALL SETRECT(rect%(0),390,50,440,100)
CALL FORECOLOR(blackColor&)
CALL PAINTRECT(rect%(0))
CALL SETRECT(rect%(0),5,50,55,100)
CALL FRAMERECT(rect%(0))
CALL SETRECT(rect%(0),60,50,110,100)
CALL FRAMERECT(rect%(0))
CALL SETRECT(rect%(0),115,50,165,100)
CALL FRAMERECT(rect%(0))
CALL SETRECT(rect%(0),170,50,220,100)
CALL FRAMERECT(rect%(0))
CALL SETRECT(rect%(0),225,50,275,100)
CALL FRAMERECT(rect%(0))
CALL SETRECT(rect%(0),280,50,330,100)
CALL FRAMERECT(rect%(0))
CALL SETRECT(rect%(0),335,50,385,100)
CALL FRAMERECT(rect%(0))
CALL SETRECT(rect%(0),390,50,440,100)
CALL FRAMERECT(rect%(0))
CALL TEXTSIZE (10)
CALL MOVETO (25,48)
PRINT white
CALL MOVETO (75,48)
PRINT yellow
CALL MOVETO (130,48)
PRINT green
CALL MOVETO (190,48)
PRINT cyan
CALL MOVETO (240,48)
PRINT blue
CALL MOVETO (300,48)
PRINT magenta
CALL MOVETO (355,48)
PRINT red
CALL MOVETO (410,48)
PRINT black
CALL MOVETO (25,112)
PRINT whiteColor&
CALL MOVETO (75,112)
PRINT yellowColor&
CALL MOVETO (130,112)
PRINT greenColor&
CALL MOVETO (190,112)
PRINT cyanColor&
CALL MOVETO (240,112)
PRINT blueColor&
CALL MOVETO (300,112)
PRINT magentaColor&
CALL MOVETO (350,112)
PRINT redColor&
CALL MOVETO (410,112)
PRINT blackColor&
CALL TEXTSIZE(14)
CALL MOVETO (150,140)
CALL DRAWSTRING (“QuickDraw™ Colors”)
RETURN

Basic Answers to Basic Questions

Concerning the comment in the Nov. 1987 issue of MacTutor where Steve Millman suggested a method of applying an event loop for reading disk events: The main problem here is that a disk event might be inserted while not in the GetNextEvent loop. The disk insert would be missed completely. I have been assured by Zedcor that in a future release of ZBasic they will add the Disk insert event to the DIALOG functions. This is easy for them to do since GETNEXTEVENT returns this to them anyway. For now, just do what Steve Millman suggests or don’t bother checking for disks at all until the new improvements come.

Q. I want to use in my program a DragGrayRect statement (the same as you see in MS Basic), but I want to use it in ZBasic. Is this possible?

A. DragGrayRect is only available as an MS Basic library call (previously known as a Clear Lake Research Library call). The alternative is to use DragGrayRgn where the region is in the shape of a rectangle. DragGrayRgn is a ROM call where as DragGrayRect is a library subroutine derived from ROM calls (probably uses DragGrayRgn). Another alternative that would require more work would be to write your own DragGrayRect function to use in any of your programs. The following program includes an example of this function. The function itself can be saved to the disk with SAVE+ and retrieved later for use in other programs with APPEND. Hope that this helps.

{2}
‘Drag Example
‘By Dave Kelly
‘©MacTutor, 1988

WINDOW OFF
COORDINATE WINDOW
DEF MOUSE=-1
DIM Rect%(3),pt%(1),pin%(3),bnd%(3),dir%,dis&
pt%(0)=mousey%:pt%(1)=mousex%
‘Create DragGrayRect function
LONG FN DragGrayRect&(RL%,RT%,RR%,RB%,  mousey,mousex, PL%,PT%,PR%,PB%,BL%,BT%,BR%, 
 BB%,dir%)
‘Rect%  = the rectangle to be moved
‘pt%    = the point where the mouse was pushed.
‘pin% = the rectangular limits in which outline can be
‘dragged.
‘bnd% = the rectangular boundary for a drag.
‘dir% = the direction to which the drag is constrained
‘0 = no constraint, 1 = horizontal, 2 = vertical
‘dis& = A point array that returns drag displacement.
 CALL SETRECT(Rect%(0),RL,RT,RR,RB)
 CALL SETRECT(pin%(0),PL,PT,PR,PB)
 CALL SETRECT(bnd%(0),BL,BT,BR,BB)
 RgnHand&=FN NEWRGN
 CALL OPENRGN
 CALL FRAMERECT(Rect%(0))
 CALL CLOSERGN(RgnHand&)
 pt%(0)=mousey%:pt%(1)=mousex%:Proc&=0:dis&=0
 dis&=FN DRAGGRAYRGN(RgnHand&, pt%(0), pin%(0), bnd%(0), dir%,Proc&)
 CALL DISPOSERGN(RgnHand&)
END FN=dis&
‘Find out monitor size
CALL GETWMGRPORT(WMgrPort&)
PortTop=PEEK WORD(WMgrPort&+8)
PortLeft=PEEK WORD(WMgrPort&+10)
PortBottom=PEEK WORD(WMgrPort&+12)
PortRight=PEEK WORD(WMgrPort&+14)
WINDOW#1,”DragExample”,(PortLeft+4,PortTop+42)-                
 (PortRight-6, PortBottom-6),5
MENU 1,0,1,”File”
MENU 1,1,1,”Quit”
top=100:left=100
GOSUB “DrawBox”
MOUSE ON:MENU ON:DIALOG ON
ON MOUSE GOSUB “MouseEvent”
ON MENU GOSUB “MenuEvent”
ON DIALOG GOSUB “DialogEvent”
“Loop”
DO
UNTIL Done
MOUSE OFF:MENU OFF:DIALOG OFF

“DialogEvent”
D=DIALOG(0)
IF D=4 THEN END
RETURN

“MenuEvent”
Menunumber=MENU(0)
Menuitem=MENU(1)
IF Menunumber=1 AND Menuitem=1 THEN END
MENU
RETURN

“MouseEvent”
X=MOUSE(0)
mousey=MOUSE(2):mousex=MOUSE(1)
dir%=0
dis&= FN DragGrayRect&(left,top, left+100, top+100, mousey,    
 mousex, PortLeft, PortTop, PortRight, PortBottom,             PortLeft, 
PortTop, PortRight,PortBottom,dir%)
dy=FN HIWORD(dis&)
dx=FN LOWORD(dis&)
LONG IF dx<>0 AND dy<>0
 CALL ERASERECT(Rect%(0))
 top=top+dy:left=left+dx
 GOSUB “DrawBox”
END IF
RETURN

“DrawBox”
CALL SETRECT(Rect%(0),left,top,left+100,top+100)
CALL FORECOLOR(205): ‘ color = red
CALL PAINTRECT(Rect%(0))
RETURN
 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but new, Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.