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

Duet - Use your iPad as an exter...
Duet is the first app that allows you to use your iDevice as an extra display for your Mac using the Lightning or 30-pin cable. Note: This app requires a $14.99 iOS companion app. Version Read more
Apple iTunes 12.5.2 - Play Apple Music a...
Apple iTunes lets you organize and stream Apple Music, download and watch video and listen to Podcasts. It can automatically download new music, app, and book purchases across all your devices and... Read more
Pinegrow Web Designer 2.95 - Mockup and...
Pinegrow Web Designer is desktop app that lets you mockup and design webpages faster with multi-page editing, CSS and LESS styling, and smart components for Bootstrap, Foundation, Angular JS, and... Read more
jAlbum Pro 13.6 - Organize your digital...
jAlbum Pro has all the features you love in jAlbum, but comes with a commercial license. You can create gorgeous custom photo galleries for the Web without writing a line of code! Beginner-friendly... Read more
jAlbum 13.6 - Create custom photo galler...
With jAlbum, you can create gorgeous custom photo galleries for the Web without writing a line of code! Beginner-friendly, with pro results - Simply drag and drop photos into groups, choose a design... Read more
TextMate 2.0-beta.12.26 - Code/markup ed...
TextMate is a versatile plain text editor with a unique and innovative feature set which caused it to win an Apple Design Award for Best Mac OS X Developer Tool in August 2006. A rapidly growing... Read more
VMware Fusion 8.5.1 - Run Windows apps a...
VMware Fusion 8 and Fusion 8 Pro--the latest versions of its virtualization software for running Windows on a Mac without rebooting--include full support for Windows 10, OS X El Capitan, and the... Read more
Apple Final Cut Pro X 10.3 - Professiona...
Apple Final Cut Pro X is a professional video editing solution.Completely redesigned from the ground up, Final Cut Pro adds extraordinary speed, quality, and flexibility to every part of the post-... Read more
Civilization VI 1.0.0 - Next iteration o...
Sid Meier’s Civilization VI is the next entry in the popular Civilization franchise. Originally created by legendary game designer Sid Meier, Civilization is a strategy game in which you attempt to... Read more
Paperless 2.3.7 - $49.95
Paperless is a digital documents manager. Remember when everyone talked about how we would soon be a paperless society? Now it seems like we use paper more than ever. Let's face it - we need and we... Read more

Latest Forum Discussions

See All

Roofbot: Puzzler On The Roof (Games)
Roofbot: Puzzler On The Roof 1.0.2 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0.2 (iTunes) Description: Guide Roofie through gorgeous, meditative rooftops and try to get the right color energy balls into the... | Read more »
The 4 best food delivery apps
As the temperatures continue to drop, so does the motivation to venture outside. Sometimes you still want to eat a nice meal from that sushi place down the road though. Thankfully in these trying times, there are a number of fine food delivery... | Read more »
Toca Life: Farm (Education)
Toca Life: Farm 1.0 Device: iOS Universal Category: Education Price: $2.99, Version: 1.0 (iTunes) Description: Work and play the farmer's way! Milk your cow, gather eggs from your hens and raise your crops. Have a picnic, play the... | Read more »
The Lost Shield (Games)
The Lost Shield 1.0.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.0 (iTunes) Description: The Lost shield is a brick break/adventure game. You play as a hero who must return a powerful but dangerous magic shield... | Read more »
The Forgotten Room (Games)
The Forgotten Room 1.0.1 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.1 (iTunes) Description: Play as paranormal investigator John “Buster of Ghosts” Murr as he explores yet another mysteriously creepy house. This... | Read more »
5 Halloween mobile games for wimps
If you're anything like me, horror games are a great way to have nightly nightmares for the next decade or three. They're off limits, but perhaps you want to get in on the Halloween celebrations in some way. Fortunately not all Halloween themed... | Read more »
The 5 scariest mobile games
It's the most wonderful time of the year for people who enjoy scaring themselves silly with haunted houses, movies, video games, and what have you. Mobile might not be the first platform you'd turn to for quality scares, but rest assured there are... | Read more »
Lifeline: Flatline (Games)
Lifeline: Flatline 1.0.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0.0 (iTunes) Description: The Lifeline series takes a terrifying turn in this interactive horror experience. Every decision you make could help... | Read more »
Game of Dice is now available on Faceboo...
After celebrating its anniversary in style with a brand new update, there’s even more excitement in store for Game of Dice has after just being launched on Facebook Gameroom. A relatively new platform, Facebook Gameroom has been designed for PC... | Read more »
4 addictive clicker games like Best Fien...
Clickers are passive games that take advantage of basic human psychology to suck you in, and they're totally unashamed of that. As long as you're aware that this game has been created to take hold of your brain and leave you perfectly content to... | Read more »

Price Scanner via

Apple Unveils Redesigned MacBook Pro With Tou...
October 27, 2016 – Apple today introduced the thinnest and lightest MacBook Pro yet, along with a new interface innovation that replaces the traditional row of function keys with a Retina-quality... Read more
Apple Unveils New TV App for Apple TV, iPhone...
October 27, 2016 – Apple today introduced a new TV app, offering a unified experience for discovering and accessing TV shows and movies from multiple apps on Apple TV, iPhone and iPad. The TV app... Read more
Price drops on select refurbished 2015 13″ Re...
Apple dropped prices on select Certified Refurbished 2015 13″ Retina MacBook Pros by as much as $90. An Apple one-year warranty is included with each model, and shipping is free: - 13″ 2.7GHz/256GB... Read more
Apple reveals new next-generation 15″ and 13″...
Apple today revealed their next-generation 15″ and 13″ MacBook Pros. The new models are thinner and lighter than before with a new aluminum design featuring an enhanced keyboard with retina, multi-... Read more
Worldwide Smartphone Shipments Up 1.0% Year o...
According to preliminary results from the International Data Corporation (IDC) Worldwide Quarterly Mobile Phone Tracker, vendors shipped a total of 362.9 million smartphones worldwide in the third... Read more
TuneBand Arm Band For iPhone 7 and 7 Plus Rel...
Grantwood Technology has added the TuneBand for iPhone 7 and 7 Plus to its smartphone armband series. The TuneBand provides a lightweight and comfortable way to wear the iPhone while running,... Read more
1.4GHz Mac mini on sale for $449, save $50
Adorama has the 1.4GHz Mac mini on sale for $50 off MSRP including free shipping plus NY & NJ sales tax only: - 1.4GHz Mac mini (Apple sku# MGEM2LL/A): $449 $50 off MSRP To purchase a mini at... Read more
21-inch 1.6GHz iMac on sale for $999, save $1...
B&H has the 21″ 1.6GHz Apple iMac on sale for $999 including free shipping plus NY sales tax only. Their price is $100 off MSRP. Read more
Macs’ Superior Enterprise Deployment Cost Eco...
IBM’s debunking of conventional wisdom and popular mythology about the relative cost of using Apple Mac computers as opposed to PCs running Microsoft Windows at the sixth annual Jamf Nation User... Read more
12-inch WiFi Apple iPad Pros on sale for $50-...
B&H Photo has 12″ WiFi Apple iPad Pros on sale for $50-$70 off MSRP, each including free shipping. B&H charges sales tax in NY only: - 12″ Space Gray 32GB WiFi iPad Pro: $749 $50 off MSRP -... Read more

Jobs Board

*Apple* Retail - Multiple Positions - Apple,...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
Software Engineering Intern: UI Applications...
Job Summary Apple is currently seeking enthusiastic interns who can work full-time for a minimum of 12-weeks between Fall 2015 and Summer 2016. Our software Read more
Security Data Analyst - *Apple* Information...
…data sources need to be collected to allow Information Security to better protect Apple employees and customers from a wide range of threats.Act as the subject Read more
*Apple* Retail - Multiple Positions - Apple,...
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* Solutions Consultant - Apple (United...
# Apple Solutions Consultant Job Number: 52812872 Houston, Texas, United States Posted: Oct. 18, 2016 Weekly Hours: 40.00 **Job Summary** As an Apple Solutions Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.