TweetFollow Us on Twitter

Icon Converter
Volume Number:2
Issue Number:1
Column Tag:Assembly Lab

Icon Converter Shows Disk I/O

By Chris Yerga, School of Engineering, UC California at Berkely, MacTutor Contributing Editor

Chris Yerga wins $50 for the outstanding program of the month with this feature article. Congratulations!

In the second issue of MacTutor, David Smith presented a program that I valued as one of my most useful utilities -- the Icon Converter. This program would take an icon generated by Apple's Icon Editor and convert it to an MDS compatable text file, making it far easier to create icon resources for assembly programs. However, the Icon Converter didn't give a catalog of files , didn't display the icons on the screen, and worse of all, was written in MS Basic. This most likely presented little trouble to the majority of users, but due to the chaotic organization of my disks, I found it frustrating.

This month's column covers the design of an assembly language Icon Converter application that includes these features. As well as developing a valuable utility, the column will explain some of the programming techniques involved in disk I/O using SFGetFile in such an application. The reader is invited to review my "Micro-Finder" utility in MacTutor, Vol. 1 No. 7 which covered an introduction to the standard file package from assembly. Remember, programs which follow the strict Apple guidelines will work with the new standard file package under Finder 5.0. So as not to be redundant, I will assume that the reader understands the basic concepts of assembly language programming covered in previous issues.

Nature of Bit Maps

First, we must recognize that an icon fits into the general category of BitMap. A BitMap is a QuickDraw data structure that represents a rectangular arrangement of bits. The bits themselves define an image simply by representing whether the corresponding pixel is on or off. The structure of a BitMap is that of a record with three fields. The PASCAL TYPE definition is as follows:

 baseAddr : QDPtr;
 rowBytes : INTEGER;
 bounds : Rect

The first field is baseAddr, a pointer to the actual bit image in memory. The next field is rowBytes, an integer that tells how wide (in bytes) each row of the image is. The last field is bounds; it is a rectangle describing the usable area of the bit image. This allows the programmer to define BitMaps which have widths that do not lie on byte boundaries. A sample BitMap is shown in Figure #1; however, realize that this is not an Icon BitMap. Whereas an Icon BitMap is 32 by 32 pixels, the sample BitMap is only 8 by 8 pixels.

Now, given the information that an icon is always 32 by 32 bits in size, we can see that the rowBytes and bounds fields of all icon BitMaps are the same. To calculate rowBytes, we take the number of bits, or pixels, horizontally and divide by 8 to determine how many bytes are needed to hold them. 8 divides evenly into 32 to give us a rowBytes value of 4. The bounds rectangle needed to enclose the 32 by 32 bits of the icon is simply 0,0,32,32. So the only data in an icon's BitMap that changes is the actual bit image of the icon.

It follows that in order to store an icon on a disk, the bit image is the only data that needs to be written. Examining files produced by Apple's old icon editor clearly shows that this is the scheme they used. The net result is that it is extremely easy to make use of files saved in this format.

File Manager Reviewed

In order for a program to access data stored in a file on disk, it must use the File Manager. The File Manager employs a register based calling scheme to pass parameters between itself and the calling program. As has been mentioned in previous installments, address register A0 points to a data structure in memory upon entry to a register based routine - IOParamBlock is used in this case. The proper fields of the IOParamBlock are filled with data, A0 is loaded, and then the desired trap is called. A digram showing which IOParamBlock fields are appropriate for the various File Manager calls is included in figure #2.

Before any data can be read from or written to a file, the file must be opened. This allows the File Manager to locate the file and create an access path to the file. In order for the file to be opened, the program must allocate 522 bytes of memory for the access path buffer and pass it to the _Open routine. After the file is opened, a path reference number, not to be confused with a volume reference number, is returned. This reference number is then used to refer to the file in following File Manager calls.

The program will go about reading an icon file in the following manner. First, the SFGetFile package will be called to get the filename of the file to be loaded. Ironically, Apple's Icon Editor breaks with their own standards in that it doesn't assign a filetype or creator to the files it creates. It leaves these fields cleared! Our program tells the SFGetFile package to list all files with NIL values for filetype and creator. As it turns out, Icon Editor files are usually the only ones that fit this criterion, but occasionally some strange file will find its way into the SFGetFile list. (Anyone unfamiliar with the workings of the SFGetFile package should read MacTutor Vol 1 #7, where I covered the Standard FIle package in more detail than is appropriate here.)

Once the desired file is known, it must be opened. Figure 2 shows us which parameters must be passed. IOCompletion will be NIL, because we don't want the File Manager to call a routine after it is done; rather, we want it to return control to us. The filename, refnum, and version number are given to us by the SFGetFile call, and are passed unchanged. The value 1 is stored in the IOPermission field to specify read-only access to the file. Finally, a pointer to the access path buffer is passed. The _Open trap is called and assuming no errors were flagged, the file is now ready to be read.

Reading Disk Files

Once the file is opened, the program is free to read the data from it. The File Manager stores the data it reads in the memory block pointed to by the ioBuffer field of the ioParamBlock. Since the BasAddr field of an icon's BitMap points to its bit image, which is what we want to load, we set ioBuffer equal to BasAddr. ReqCount tells the File Manager how many bytes to read from the file. Multiplying the BitMap's rowBytes value (4) by its number of rows vertically (32) gives the value 128 for this field. The ioPosMode and ioPosOffset fields are both cleared, because the special positioning features of the File Manager are not needed in this case. The _Read trap is then invoked. The input operation is now finished, and the _Close trap is called.

Icon Displayed via CopyBits

It is helpful to see the icons on the screen after they have been loaded. This is achieved through the CopyBits procedure, which can be used to transfer a BitMap to the screen. Its PASCAL interface follows:

 (srcBits,dstBis: BitMap; srcRect,
 dstRect: Rect;  mode: INTEGER;
  maskRgn: RgnHandle);

The first parameter passed to CopyBits is a pointer to the source BitMap, which is our icon BitMap. This is followed by a pointer to the destination BitMap. The destination BitMap will be that of the current GrafPort, which is stored beginning at 2 bytes past the beginning of the GrafPort data. After this is pushed, we push srcRect, which describes the rectangular region of the source BitMap to be copied. The entire BitMap is to be copied, of course, so 0,0,32,32 is sent. dstRect is next, and for it we pass a 32 by 32 rectangle describing where on the screen we want the icon displayed. The next word of data determines which transfer mode is used. Zero is used to set the standard copy mode. The last parameter is a handle to a region to which the BitMap should be masked, and is useless in this instance. NIL is passed. _CopyBits is then called and the icon is displayed inside DestRect.

Now that the icon is loaded and displayed, it's binary bit image must be converted to ASCII data for the MDS file. The program allocates 2K of memory to house the ASCII data before it is written to the destination file. The conversion process is a simple loop that stores "DC.B" at the beginning of each line, converts 8 bytes of hex data to ASCII, stores this ASCII data, stores a carriage return for the end of the line, and loops. The main part of the this loop is the hex to decimal conversion routine, HexToAscii, which takes a hex byte in D0 and converts it to an ASCII word which is returned in D1. It's code is straightforward and commented, and I recommend examining it, as the functional value of the program is based on it.

The final step of the conversion process is writing the MDS file out to disk. First, we must call the SFPutFile trap to get the desired filename from the user. Next, the file must be created on the volume, a task handled by the File Manager's _Create trap (appropriately enough...). As usual, ioCompletion is NIL. The file name and volume reference number, which specifies the volume that will contain the new file, are given to us by the SFPutFile. Finally, we must specify a 1 byte version number for the file. As we are unconcerned with version numbers, this field will contain NIL. After this is done, we call the _Create trap and continue with the next step.

As in reading, we must first open the destination file before we can perform any I/O. Since we have just set the ioCompletion, ioNamePtr, ioVRefNum, and ioVersNum fields, we do not need to do so again. The value 1 is stored in the IOPermission field to specify read-only access to the file. A pointer to the 522 byte access path buffer is passed, and the file is _Opened.

Writing to Disk Files

Now we are ready to do the actual writing. The first step is to calculate the length of the ASCII data in our 2K buffer. This is necessary because the actual data will not fill the entire buffer. After this value has been found, it is stored in the ioReqCount field, informing the File Manager of how much data needs to be written. Next, the base address of the buffer is stored in ioBuffer. Finally, ioPosMode and ioPosOffset are cleared to disable these features of the File Manager, and the _Write trap is called.

Setting Type and Creator Bytes

We now have an file of ASCII data on the disk, but we need to give it filetype and creator tags in order for MDS to recognize it. The filetype will be TEXT, and the creator will be EDIT. The trap that allows us to set these stamps is _SetFileInfo. Unfortunately, however, _SetFileInfo also sets about a dozen other pieces of file information, and requires that they be specified as well. The solution is to first call _GetFileInfo, which reads the current information fields from the file and stores them in the ioParamBlock. In essence, we are letting _GetFileInfo do the tedious business of passing the other parameters to _SetFileInfo. So we call _GetFileInfo, set the filetype and creator, and then call _SetFileInfo.

We are now finished writing the file, so we _Close it. The final step is to call _FlushVol to insure that everything gets updated on the volume.

It is quite possible that an I/O error will occur during one of the above operations. In such an event, the File Manager returns an error code in ioResult. A copy of this error code is also placed in D0. After every I/O operation, the program invokes a macro which checks D0 for an error code. If one is found, it displays a dialog box alerting the user of an error and aborts to the main menu.

Dialog Box Makes it User Friendly

The above steps are the heart of the conversion section of the program. The external features, such as the appearance of the program and so on are fairly simple, involving a single dialog box to support the features described above. Menus have been omitted not to save us from writing extra code, but rather to create a more efficient interface. It is my belief that menus are useful only in applications involving several possible categories of actions that the user may take (ie: Filing commands, Editing commands, Font commands, etc). In such an application, menus serve to organize the possible choices and thus make them more manageable to the user. Whereas in our case, the application serves but one purpose, and consequently, all the possible actions the user may take fall under one category.

I hope that this article and the source code will help explain the basic workings of the File Manager. If not, perhaps the program itself will be useful. If even that is of no use to you, then perhaps you shouldn't have read this far. [But if you did, you've learned a lot! Thanks Chris for a great column. -Ed.]

;    Icon Converter 3.0
; © Copyright 1985 by Chris Yerga
;for MacTutor

;  Declare external labels


.TRAP _MakeFile  $A008  ;The _Create trap
     ;which is not in
     ;the MDS trap file

;   Define Macros  

MACRO IsError  =
 CMP.W  #0,D0    ;Check for nonzero D0
 BEQ    @2
 BRA    ioErr    ;pop up the error dialog

MACRO   Center String,MidPT,Y  =

 CLR.W  -(SP)    ;Save room for INTEGER                        
 ;width of string
 PEA  '{String}'
 CLR.L  D3;Clear the high word of D3 ;so the DIVU works
 MOVE.W (SP)+,D3 ;Get the width (in pixels)                    
 ;in D3
 DIVU #2,D3 ;Divide by 2
 MOVE.L #{MidPT},D4
 SUB.W  D3,D4  ;Subtract (Width/2) from                        
 ;103 to center text
 MOVE.W D4,-(SP) ;Push the X coordinate
 MOVE.W #{Y},-(SP) ;Push the Y coordinate
 _MoveTo;Position the pen
 PEA  '{String}'
 | ;End of Macro
;  Local Constants  

AllEvents EQU  $0000FFFF ; Mask for FlushEvents
MaxEvents EQU  12
DWindLenEQU $AA  ; The size of a Dialog                        

;  Start of Main Program  

_Debugger ;Should never get here.  Is called
 ;when there is a problem with the
 ;memory manager.
CLR.L -(SP)     ;Save room for DIalogPtr
MOVE.W  #150,-(SP) ;The ResID of the error dialog
PEAErrDialog(A5) ;Where to put the DialogRec
MOVE.L  #-1,-(SP);Put it in front, please...
LEAErrDHandle,A2 ;Save handle, but keep it
MOVE.L  (SP),(A2);on the stack
_DrawDialog ;Draw the dialog..
MOVE.L  (A2),-(SP) ;Set the Dialog to the current _SetPort     
Center  Sorry!  That operation was interrupted,150,20
Center  by an I/O error. Check the disk            and,150,32
Center  try again.,150,44
MOVE.L  ErrDHandle,-(SP)  ;Get rid of the dialog
MOVE.L  MainPort,-(SP)  ;restore the main port
_SetPort;as the active port
BRAMain ;abort to the main menu

MOVEM.L D0-D7/A0-A6,-(SP)
 ;The standard-issue routine
LEASAVEREGS,A0   ;which saves the registers
MOVE.L  A6,(A0)  
MOVE.L  A7,4(A0)
;  Initialize the ROM routines  

PEA-4(A5) ;QD Global ptr
_InitGraf ;Init QD global
_InitFonts;Init font manager
_InitWindows;Init Window Manager
_InitMenus;Guess got it!
CLR.L -(SP) ;Standard SysErr/DS dialog
_InitDialogs;Init Dialog Manger
_TEInit ;Init ROM Text edit
MOVE.L  #AllEvents,D0;And flush ALL previous
_InitCursor ;Get the standard arrow
PEAScreen ;Clear the screen
;  Allocate some Memory  

MOVE.L  #80,D0 ;Get 80 Bytes for IOParamBlock
IsError ;Handle any error
LEAIOParamBlock,A1 ;Save the Ptr
MOVE.L  A0,(A1)
MOVE.L  #522,D0  ;Get 522 Bytes for access _NewPtr             
 ;path buffer
IsError ;Handle any error
LEAAPBuffer,A1   ;Save the Ptr
MOVE.L  A0,(A1)
MOVE.L  #128,D0  ;Get 128 Bytes for Icon Data
IsError ;Do the error thing...
LEAIconBitMap,A1 ;Save the Ptr
MOVE.L  A0,(A1)
MOVE.L  #128,D0  ;Get 128 Bytes for Mask Data
IsError ;Do the error thing...
LEAMaskBitMap,A1 ;Save the Ptr
MOVE.L  A0,(A1)
MOVE.L  #2048,D0 ;Get 2K bytes for Target _NewPtr              
 ;file buffer
LEAConvertBuf,A1 ;save the ptr
MOVE.L  A0,(A1)
;  Set up the Dialog Box  

CLR.L -(SP) ;Save room for DIalogPtr
MOVE.W  #128,-(SP) ;The ResID of the dialog
PEAMainDialog(A5);Where to put the DialogRec
MOVE.L  #-1,-(SP);Put it in front, please...
LEAMainDHandle,A2;Save handle, but keep it
MOVE.L  (SP),(A2);on the stack
_DrawDialog ;Draw the dialog..
MOVE.L  (A2),-(SP) ;Set the Dialog to the _SetPort             
 ;current GrafPort
PEAIconFrame;Outline the ICON box
PEAMaskFrame;Ditto for the MASK
MOVE.W  #7,-(SP) ;Athens
MOVE.W  #18,-(SP);18 Pt
Center  Icon Converter 3.0,200,30
MOVE.W  #2,-(SP) ;Geneva
MOVE.W  #12,-(SP);12 Pt
Center  ©1985 by Chris Yerga for   MacTutor,200,45
CLR.W -(SP) ;Chicago
PEAMainPort ;Save the GrafPtr for the Main port
;  Main Event Loop  

CLR.L -(SP) ;NIL for FilterProc
PEAItemHit;VAR ItemHit
MOVE  ItemHit,D0 ;Get the Item #
CMP.B #1,D0 ;Open an Icon?
CMP.B #2,D0 ;Open a Mask?
CMP.B #3,D0 ;Standard Mask?
CMP.B #4,D0 ;Do the conversion?
CMP.B #5,D0 ;Help?
CMP.B #6,D0 ;Quit?
BRAMain ;loop til we get a good event
MOVE.L  (A0),A6
MOVE.L  4(A0),A7
MOVEM.L (SP)+,D0-D7/A0-A6

BSRGetFile;Get filename
BEQMain ;user hit <Cancel>
LEAIconBitMap,A3 ;set up params for read
BSRReadIcon ;read the file
BSRPlotIcon ;draw the icon
BSRGetFile;Get filename
BEQMain ;user hit cancel
LEAMaskBitMap,A3 ;set up for read...
BSRReadIcon ;read the file
BSRPlotMask ;display the mask

MOVE.L  MaskBitMap,A0;Get Ptr to Bitmap data
MOVE.L  #31,D0   ;loop 32 times
MOVE.L  #$FFFFFFFF,(A0)+       ;fill the mask with black
DBRA    D0,FillMask;loop until we're done
MOVE.L  ConvertBuf,A2;Fill the file buffer with
MOVE.L  IconBitMap,A3;the icon definition
MOVE.W  #$0D0D,(A2)+ ;stick in a few cr's for                  
MOVE.L  MaskBitMap,A3; & the mask definition
BSRPutFile;Get the filename for save
BEQMain ;user cancelled out
MOVE.L  A2,D2    ;Save the buffer Ptr
MOVE.L  IOParamBlock,A2     ;Get Ptr in A2
CLR.L 12(A2);No completion routine
LEAGFileName,A0  ;ioNamePtr
MOVE.L  A0,18(A2);save it in IOPB
MOVE.W  GetVRef,22(A2)  ;volume ref #
CLR.B 26(A2);version # = 0 
_MakeFile ;generate the file
MOVE.B  #2,27(A2);write-only permission
MOVE.L  APBuffer,28(A2) ;pointer to our access MOVE.L    A2,A0 
 ;path buffer
_Open   ;open the data fork of the file
MOVE.L  ConvertBuf,D1;Get the Base address of                  
 ;the buffer
SUB.L D1,D2 ;use it to calculate the ;length of buffer
MOVE.L  ConvertBuf,32(A2);Buffer ptr
MOVE.L  D2,36(A2);write the whole buffer
CLR.W 44(A2);standard positioning
CLR.L 46(A2);with no offset
_Write  ;write the buffer
CLR.W 28(A2);no directory index
MOVE.L  A2,A0    ;Get the current file info
_GetFileInfo;so we don't have to set ;everything
MOVE.L  #'TEXT',32(A2)  ;file type = TEXT
MOVE.L  #'EDIT',36(A2)  ;creator   = EDIT
MOVE.L  A2,A0    ;write the info
MOVE.L  A2,A0    ;Close out the file
MOVE.L  A2,A0    ;& flush the volume

MOVE.L  #15,D2   ;loop 16 times (16 lines of code)
MOVE.L  #7,D3    ;put 8 bytes of data in each line
MOVE.L  LineStart,(A2)+ ;Put the 'DC.B  ' at the 
MOVE.B  LineStart+4,(A2)+ ;beginning of each line
MOVE.B  (A3)+,D0 ;Get next byte of data
BSRHexToAscii    ;get ascii word in D1
MOVE.B  #'$',(A2)+ ;precede digit with $ for hex
MOVE.W  D1,(A2)+ ;store ascii equivalent of byte
MOVE.B  #',',(A2)+ ;store comma separator
DBRA  D3,@3 ;loop till we've done 8 bytes
SUBA  #1,A2 ;replace the last comma w/ cr
MOVE.W  #$200D,(A2)+
DBRA  D2,NextRow  ;loop till we've done 16 lines RTS           
      ;of code
;  HexToAscii routine -> converts a hex byte to an  
;ASCII word
;on entry:
;D0 = Hex byte to be converted
;on return:
;D1 = ASCII word result
;uses D0,D1,D4,A0

MOVE.B  D0,D4  ;save copy of byte
LSR#4,D0;Get the high nibble
ANDI  #$0F,D0    ;mask out all extraneous bits
LEAByteTable,A0  ;Get base address of table
MOVE.B  (A0,D0),D1 ;Move 1st ascii byte into D1
ASL#8,D1;move the byte to the proper position
ANDI  #$0F,D4    ;get the low nibble
MOVE.B  (A0,D4),D0 ;Get 2nd ascii byte
OR.W  D0,D1 ;store 2nd byte in word

DC.B    '0123456789ABCDEF'
CLR.L -(SP)      ;Save room for DIalogPtr
MOVE.W  #129,-(SP) ;The ResID of the help dialog
PEAHelpDialog(A5)  ;Where to put the DialogRec
MOVE.L  #-1,-(SP)  ;Put it in front, please...
LEAHelpDHandle,A2  ;Save handle, but keep it
MOVE.L  (SP),(A2)    ;on the stack
_DrawDialog    ;Draw the dialog..
MOVE.L  (A2),-(SP) ;Set the Dialog to the current _SetPort     
Center  The Icon Converter is based on an          MS-Basic Program,224,20
Center  written by David Smith and presented in          MacTutor Vol. 
1 #2,224,32
Center  that takes a file generated by the Apple         Icon Editor 
Center  converts it to an MDS format TEXT type           file to save 
Center  programmer from the tedious task of        typing in the HEX 
Center  by hand.,224,80
Center  This program is an adaptation of the             original,224,97
Center  Icon Converter in assembly language.,224,109
BSRAwaitOK;wait for the user to click OK
PEAScreen ;clear the dialog box
MOVE.L  HelpDHandle,-(SP)           ;Redraw the dialog
Center  Clicking in either of the Open buttons           allows the user 
Center  open a file generated by the old icon editor           for either,224,32
Center  the icon or mask respectively.,224,44
Center  Clicking in the None button tells the Icon             Editor/Converter,224,61
Center  to generate a standard mask for the icon         (all black).,224,73
Center  Clicking in the Convert button converts the            displayed 
Center  and mask to an MDS compatable  file.,224,102
BSRAwaitOK;wait for the user to click OK
PEAScreen ;clear the dialog box
MOVE.L  HelpDHandle,-(SP)  ;Redraw the dialog
Center  Subscribe to MacTutor - the no fluff             Macintosh programming,224,20
Center  journal - to learn how to write programs         like this in,224,32
Center  Assembly Language on the Mac.,224,44
Center  $24 per year will keep you on top of             Macintosh programming,224,61
Center  in Assembly  Language/Basic/C/Forth/Pascal and         many,224,73
Center  other languages!,224,85
Center  MacTutor  P.O. Box 846  Placentia Ca             92670,224,102
Center  or call (714) 993-9939,224,119
MOVE.L  HelpDHandle,-(SP) ;Get rid of the dialog
MOVE.L  MainPort,-(SP)   ;restore the main port
_SetPort;as the active port

CLR.L -(SP) ;NIL for FilterProc
PEAItemHit;VAR ItemHit
MOVE  ItemHit,D0 ;Get the Item #
CMP.B #1,D0 ;was it OK?
; ReadIcon routine:
;on entry A3 contains a ptr to the bitmap which
;will receive the data.

MOVE.L  IOParamBlock,A2 ;Get Ptr in A2
CLR.L 12(A2);No completion routine
LEAGFileName,A0  ;ioNamePtr
MOVE.L  A0,18(A2);save it in IOPB
MOVE  GetVRef,22(A2) ;the volume refNum
MOVE.B  GetVers,26(A2)  ;the file version #
MOVE.B  #1,27(A2);read-only permission
MOVE.L  APBuffer,28(A2)   ;the access path buffer
MOVE.L  A2,A0    ;Ptr to IOPB
_Open   ;Open the file
IsError ;handle any error
MOVE.L  (A3),32(A2);data buffer
MOVE.L  #128,36(A2);# of bytes to read
CLR.W 44(A2);standard positioning
CLR.L 46(A2);no offset
_Read   ;read the data
IsError ;hope for no errors
MOVE.L  A2,A0    ;close the file
MOVE.W  #82,-(SP);x Coordinate
MOVE.W  #187,-(SP) ;y Coordinate
PEA'PROMPT' ;Prompt (Unused)
MOVE.L  #0,-(SP) ;NIL for ProcPtr
MOVE.W  #1,-(SP)  ;We only want 1 file type listed
PEATypeList ;The TypeList
MOVE.L  #0,-(SP) ;NIL for dlgHook
PEASFReply;The Reply Record
MOVE.W  #2,-(SP) ;Routine Selector for _Pack3                  
LEASFReply,A0    ;check for successful call
CMP.B #0,(A0)
MOVE.W  #104,-(SP) ;x coordinate
MOVE.W  #190,-(SP) ;y coordinate
PEA'Save MDS file as:'  ;Prompt
PEA'Untitled.ICON' ;Default name
CLR.L -(SP) ;standard dialog box
PEASFReply;the reply record
MOVE.W  #1,-(SP) ;Routine selector for SFPutFile
LEASFReply,A0    ;check for successful call
CMP.B #0,(A0)
PEACurPort;get the GrafPtr in CurPort
MOVE.L  CurPort,A0 ;put it in A0
PEAIconBitMap    ;source
PEASourceRect    ;source rect
PEAIconRect ;dest rect
CLR.W -(SP) ;SrcCopy mode
CLR.L -(SP) ;no mask region
PEACurPort;get the GrafPtr in CurPort
 MOVE.L CurPort,A0 ;put it in A0
PEAMaskBitMap    ;source
PEASourceRect    ;source rect
PEAMaskRect ;dest rect
CLR.W -(SP) ;SrcCopy mode
CLR.L -(SP) ;no mask region
;  Program Variables  

SaveRegs: DCB.L 2,0;For saving the SP etc..
MainDHandle:DC.L 0 ;For the main dialog                        
HelpDHandle:DC.L 0 ;For the Help dialog Handle
ErrDHandle: DC.L 0 ;For the ioErr dialog                       
ItemHit:DC.W0  ;For _ModalDialog
IOParamBlock:  DC.L0
APBuffer: DC.L 0

;   That's all....Enjoy!  


/Output IconVert





;  IconVert 3.0  
;  by Chris Yerga for MacTutor
;          RESOURCES


DC.B  'IconVert 3.0 - Chris Yerga 8/4/85'

DC.L  'BDOG';Name of Signature
DC.W  0,1
DC.L  'FREF';FREF mappings
DC.W  0 ;1 mapping (1-1 = 0)
DC.W  0,128
DC.L  'ICN#';ICN# mappings
DC.W  0 ;1 mapping (1-1 = 0)
DC.W  0,128

DC.B  'APPL',0,0,0

RESOURCE 'ICN#' 128'Application Icon'
INCLUDE Martini.ICON ;put your icon here

RESOURCE 'DLOG' 128  'Appl Dialog'
DC.W  29,56,170,456;BoundsRect
DC.W  1 ;Dialog Box w/ Outline
DC.B  1,1 ;Visible
DC.B  0,0 ;NoGoAway
DC.L  0 ;Refcon...
DC.W  128 ;DITL ResID
DC.B  'BOX' ;Title (Unused)
RESOURCE 'DLOG' 129 'Help Dialog'
DC.W  175,32,330,480 ;BoundsRect
DC.W  1 ;Dialog box w/ outline
DC.B  1,1 ;Visible
DC.B  0,0 ;NoGoAway
DC.L  0 ;Refcon...
DC.W  129 ;DITL ResID
DC.B  'HELP';Title (not used)
RESOURCE 'DLOG' 150 'ioErr Dialog'
DC.W  135,106,205,406;BoundsRect
DC.W  1 ;Dialog box w/ outline
DC.B  1,1 ;Visible
DC.B  0,0 ;NoGoAway
DC.L  0 ;RefCon
DC.W  150 ;DITL ResID
DC.B  'ERR' ;Title
DC.W  7 ;8 Items (8-1=7)

* Item #1 *
DC.L  0 ;Handle Holder
DC.W  60,94,77,144 ;Bounds
DC.B  4 ;Button
DC.B  'Open';Text w/ length byte

* Item #2 *
DC.L  0 ;Handle Holder
DC.W  60,256,77,306;Bounds
DC.B  4 ;Button
DC.B  'Open';Text w/ length byte

* Item #3 *
DC.L  0 ;Handle Holder
DC.W  79,256,96,306;Bounds
DC.B  4 ;Button
DC.B  'None';Text w/ length byte

* Item #4 *
DC.L  0 ;Handle Holder
DC.W  118,40,137,140 ;Bounds
DC.B  4 ;Button
DC.B  'Convert ' ;Text w/ length byte

* Item #5 *
DC.L  0 ;Handle Holder
DC.W  118,150,137,250;Bounds
DC.B  4 ;Button
DC.B  'Help';Text w/ length byte

* Item #6 *
DC.L  0 ;Handle Holder
DC.W  118,260,137,360;Bounds
DC.B  4 ;Button
DC.B  'Quit';Text w/ length byte

* Item #7 *
DC.L  0 ;Handle Holder
DC.W  98,154,113,190 ;Bounds
DC.B  136 ;Button
DC.B  'Icon';Text w/ length byte

* Item #8 *
DC.L  0 ;Handle Holder
DC.W  98,210,113,246 ;Bounds
DC.B  136 ;static text
DC.B  'Mask';Text w/ length byte
RESOURCE 'DITL' 129 'Help Items'
DC.W  0 ;1 Item (1-1=0)
* Item #1 *
DC.L  0 ;handle holder
DC.W  135,199,152,249;BoundsRect
DC.B  4 ;Button
DC.B  'OK';title
RESOURCE 'DITL' 150 'Err Items'
DC.W  0 ;1 Item (1-1=0)
* Item #1 *
DC.L  0 ;handle holder
DC.W  51,120,68,180;BoundsRect
DC.B  4 ;Button
DC.B  'Oh no!'   ;title
STRING_FORMAT 0  ;set things back to normal

Community Search:
MacTech Search:

Software Updates via MacUpdate

VOX 2.8.24 - Music player that supports...
VOX just sounds better! The beauty is in its simplicity, yet behind the minimal exterior lies a powerful music player with a ton of features and support for all audio formats you should ever need.... Read more
Dropbox 24.4.17 - Cloud backup and synch...
Dropbox is an application that creates a special Finder folder that automatically syncs online and between your computers. It allows you to both backup files and keep them up-to-date between systems... Read more
OmniPlan Pro 3.7.1 - Professional-grade...
With OmniPlan Pro, you can create logical, manageable project plans with Gantt charts, schedules, summaries, milestones, and critical paths. Break down the tasks needed to make your project a success... Read more
OmniPlan 3.7.1 - Robust project manageme...
With OmniPlan, you can create logical, manageable project plans with Gantt charts, schedules, summaries, milestones, and critical paths. Break down the tasks needed to make your project a success,... Read more
Adium - Popular instant messagi...
Adium is a fast and free instant messaging client which supports AIM, ICQ, Jabber, MSN, Yahoo!, Google Talk, Yahoo! Japan, Bonjour, Gadu-Gadu, Novell Groupwise, SIP/SIMPLE (Text), and Lotus Sametime... Read more
SteerMouse 5.1 - Powerful third-party mo...
SteerMouse is an advanced driver for USB and Bluetooth mice. It also supports Apple Mighty Mouse very well. SteerMouse can assign various functions to buttons that Apple's software does not allow,... Read more
File Juicer 4.57 - $18.00
File Juicer is a drag-and-drop can opener and data archaeologist. Its specialty is to find and extract images, video, audio, or text from files which are hard to open in other ways. In computer... Read more
1Password 6.7 - Powerful password manage...
1Password is a password manager that uniquely brings you both security and convenience. It is the only program that provides anti-phishing protection and goes beyond password management by adding Web... Read more
CleanMyMac 3.8.1 - $39.95
CleanMyMac makes space for the things you love. Sporting a range of ingenious new features, CleanMyMac lets you safely and intelligently scan and clean your entire system, delete large, unused files... Read more
Monolingual 1.7.8 - Remove unwanted OS X...
Monolingual is a program for removing unnecesary language resources from OS X, in order to reclaim several hundred megabytes of disk space. If you use your computer in only one (human) language, you... Read more

Latest Forum Discussions

See All

Olli by Tinrocket (Photography)
Olli by Tinrocket 1.0 Device: iOS iPhone Category: Photography Price: $2.99, Version: 1.0 (iTunes) Description: Get drawn in with Olli by TinrocketOlli instantly turns your everyday moments into hand-drawn art and animations. • Watch... | Read more »
Penarium (Games)
Penarium 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: | Read more »
Fire Emblem Heroes is way more profitabl...
Profits for Nintendo's mobile game Fire Emblem Heroes are apparently impressive enough to beat out other Nintendo titles likeSuper Mario Run, despite having 10 times fewer downloads. [Read more] | Read more »
Classic series Robot Unicorn Attack 3 no...
The classic Adult Swim browser game, Robot Unicorn Attack, branched off into a series of popular mobile games. Now, the latest entry into the series, Robot Unicorn Attack 3, is available for iOS and Android mobile devices. [Read more] | Read more »
Sudoku Sweeper (Games)
Sudoku Sweeper 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: A minimalist mashup of Minesweeper and Sudoku. Logic puzzle perfection. Every row, column and zone contains a bomb and one of... | Read more »
Under Leaves (Games)
Under Leaves 1.0.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.0 (iTunes) Description: Journey into the forest, the jungle or the depths of the deep blue sea. Find chestnuts for the pigs, a caterpillar for the... | Read more »
Ninja Pizza Girl (Games)
Ninja Pizza Girl 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: In the not-so-distant future, rampart traffic congestion has resulted in only one way to deliver pizzas across town in thirty... | Read more »
SCRAP (Games)
SCRAP 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: That day, for no apparent reason, SCRAP decided to wake up and run. He had to, because his activation was a mistake the "Factory" could... | Read more »
The Bunker (Games)
The Bunker 1.1 Device: iOS Universal Category: Games Price: $3.99, Version: 1.1 (iTunes) Description: The critically acclaimed console hit "The Bunker" comes to iOS, The groundbreaking live-action thriller adventure set in a real... | Read more »
Die With Glory (Games)
Die With Glory 1.2.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.2.0 (iTunes) Description: Die with Glory is an epic adventure game where your goal is to die in glorious fashion. You must help Sigurd, a brave old... | Read more »

Price Scanner via

New System Clock for macOS by B-Eng Now Avail...
Fehraltorf, Switzerland based B-Eng has announced the release and immediate availability of System Clock, the company’s new system monitor and information app developed exclusively for macOS. System... Read more
DEVONtechnologies Celebrates 15th Anniversary...
DEVONtechnologies celebrates its 15th company anniversary with a 30% discount on all its software products from May 1st through 5th, 2017. In spring 2002, DEVONtechnologies opened its website and... Read more
WaterField Designs Invites Customers to Help...
San Francisco based WaterField Designs invites customers and air travelers to participate in developing the next generation in-flight travel case, the Air Porter. Frustrated with limited legroom,... Read more
Save up to $260 with Apple refurbished 12-inc...
Apple has Certified Refurbished 2016 12″ Retina MacBooks available for $200-$260 off MSRP. Apple will include a standard one-year warranty with each MacBook, and shipping is free. The following... Read more
Digital Paper Tablet Offers Distraction Free...
I typically spend 8-10 hours a day gazing at the screens in my laptops and iPad, as tools of my livelihood, I don’t as a rule use electronic devices for pleasure reading. I subscribe to a daily... Read more
“Today at Apple” Bringing New Educational Ses...
Apple has announced plans to launch dozens of new educational sessions next month in all 495 Apple Stores ranging in topics from photo and video to music, coding, art and design, and more. The hands-... Read more
Smart Finance Free Comprehensive Personal Fin...
Moscow-based indie developer, Alexander Survillo has announced the release and immediate availability of Smart Finance: Personal Finance, Budget & Money 1.1.4, an update to his comprehensive... Read more
12-inch 1.1GHz Retina MacBooks on sale for $1...
B&H has 12″ 1.1GHz Retina MacBooks on sale for $100 off MSRP. Shipping is free, and B&H charges NY & NJ sales tax only: - 12″ 1.1GHz Space Gray Retina MacBook: $1199.99 $100 off MSRP - 12... Read more
13-inch 2.7GHz Retina MacBook Pro on sale for...
B&H Photo has the 13″ 2.7GHz Retina MacBook Pro on sale for $130 off MSRP. Shipping is free, and B&H charges NY & NJ tax only: - 13″ 2.7GHz/128GB Retina MacBook Pro (MF839LL/A): $1169 $... Read more
15-inch 2.2GHz Retina MacBook Pros available...
B&H Photo has the 15″ 2.2GHz Retina MacBook Pro available for $200 off MSRP including free shipping plus NY & NJ sales tax only: - 15″ 2.2GHz Retina MacBook Pro (MJLQ2LL/A): $1799.99 $200 off... Read more

Jobs Board

*Apple* Mac Computer Technician - GeekHampto...
…complex computer issues over the phone and in person? GeekHampton, Long Island's Apple Premium Service Provider, is looking for you! Come work with our crew Read more
*Apple* Retail - Multiple Positions- Chicago...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
*Apple* Systems Engineer - California Polyte...
Cal Poly, San Luis Obispo Apple Systems Engineer Department: ITS - Customer & Tech Support (134900) College/Division: Academic Affairs Salary Range: Position Read more
*Apple* Mobile Master - Best Buy (United Sta...
**501042BR** **Job Title:** Apple Mobile Master **Location Number:** 000416-East Lansing-Store **Job Description:** **What does a Best Buy Apple Mobile Master Read more
Best Buy *Apple* Computing Master - Best Bu...
**501195BR** **Job Title:** Best Buy Apple Computing Master **Location Number:** 000211-Colorado Blvd-Store **Job Description:** **What does a Best Buy Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.