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:

TYPE BitMap = RECORD
 baseAddr : QDPtr;
 rowBytes : INTEGER;
 bounds : Rect
                      END;

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:

PROCEDURE CopyBits
 (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
;
INCLUDE MacTraps.D

;  Declare external labels

XDEF    START

.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
@2:
 |

MACRO   Center String,MidPT,Y  =

 CLR.W  -(SP)    ;Save room for INTEGER                        
 ;width of string
 PEA  '{String}'
 _StringWidth
 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}'
 _DrawString
 | ;End of Macro
 
;  Local Constants  

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

;  Start of Main Program  

BadPtr: 
_Debugger ;Should never get here.  Is called
 ;when there is a problem with the
 ;memory manager.
IOErr:  
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...
_GetNewDialog
LEAErrDHandle,A2 ;Save handle, but keep it
MOVE.L  (SP),(A2);on the stack
_DrawDialog ;Draw the dialog..
LEAErrDHandle,A2
MOVE.L  (A2),-(SP) ;Set the Dialog to the current _SetPort     
  ;GrafPort
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
BSRAwaitOK
MOVE.L  ErrDHandle,-(SP)  ;Get rid of the dialog
_DisposDialog
MOVE.L  MainPort,-(SP)  ;restore the main port
_SetPort;as the active port
BRAMain ;abort to the main menu

START:  
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 what...you 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
_FlushEvents;events
_InitCursor ;Get the standard arrow
 
PEAGrayPat
_BackPat
PEAScreen ;Clear the screen
_EraseRect
PEAWhitePat
_BackPat
 
;  Allocate some Memory  

MOVE.L  #80,D0 ;Get 80 Bytes for IOParamBlock
_NewPtr
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
_NewPtr
IsError ;Do the error thing...
LEAIconBitMap,A1 ;Save the Ptr
MOVE.L  A0,(A1)
MOVE.L  #128,D0  ;Get 128 Bytes for Mask Data
_NewPtr
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
IsError
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...
_GetNewDialog
LEAMainDHandle,A2;Save handle, but keep it
MOVE.L  (SP),(A2);on the stack
_DrawDialog ;Draw the dialog..
 
LEAMainDHandle,A2
MOVE.L  (A2),-(SP) ;Set the Dialog to the _SetPort             
 ;current GrafPort
PEAIconFrame;Outline the ICON box
_FrameRect
PEAMaskFrame;Ditto for the MASK
_FrameRect
MOVE.W  #7,-(SP) ;Athens
_TextFont
MOVE.W  #18,-(SP);18 Pt
_TextSize
Center  Icon Converter 3.0,200,30
MOVE.W  #2,-(SP) ;Geneva
_TextFont
MOVE.W  #12,-(SP);12 Pt
_TextSize
Center  ©1985 by Chris Yerga for   MacTutor,200,45
CLR.W -(SP) ;Chicago
_TextFont
PEAMainPort ;Save the GrafPtr for the Main port
_GetPort
 
;  Main Event Loop  

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

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

StdMask:
MOVE.L  MaskBitMap,A0;Get Ptr to Bitmap data
MOVE.L  #31,D0   ;loop 32 times
FillMask:
MOVE.L  #$FFFFFFFF,(A0)+       ;fill the mask with black
DBRA    D0,FillMask;loop until we're done
BSRPlotMask
BRAMain
 
Convert:
MOVE.L  ConvertBuf,A2;Fill the file buffer with
MOVE.L  IconBitMap,A3;the icon definition
BSRIconToMDS
MOVE.W  #$0D0D,(A2)+ ;stick in a few cr's for                  
 ;spacing
MOVE.L  MaskBitMap,A3; & the mask definition
BSRIconToMDS
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 
MOVE.L  A2,A0
_MakeFile ;generate the file
IsError
 
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
IsError
 
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
MOVE.L  A2,A0
_Write  ;write the buffer
IsError
 
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
_SetFileInfo
 
MOVE.L  A2,A0    ;Close out the file
_Close
IsError
MOVE.L  A2,A0    ;& flush the volume
_FlushVol
IsError
BRAMain

IconToMDS:
MOVE.L  #15,D2   ;loop 16 times (16 lines of code)
NextRow:
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
@3:
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

HexToAscii:
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
RTS

ByteTable:
DC.B    '0123456789ABCDEF'
 
Help:
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...
_GetNewDialog
LEAHelpDHandle,A2  ;Save handle, but keep it
MOVE.L  (SP),(A2)    ;on the stack
_DrawDialog    ;Draw the dialog..
LEAHelpDHandle,A2
MOVE.L  (A2),-(SP) ;Set the Dialog to the current _SetPort     
   ;GrafPort
 
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 
and,224,44
Center  converts it to an MDS format TEXT type           file to save 
the,224,56
Center  programmer from the tedious task of        typing in the HEX 
data,224,68
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
_EraseRect
MOVE.L  HelpDHandle,-(SP)           ;Redraw the dialog
_DrawDialog 
 
Center  Clicking in either of the Open buttons           allows the user 
to,224,20
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 
icon,224,90
Center  and mask to an MDS compatable  file.,224,102
BSRAwaitOK;wait for the user to click OK
PEAScreen ;clear the dialog box
_EraseRect
MOVE.L  HelpDHandle,-(SP)  ;Redraw the dialog
_DrawDialog 
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
BSR AwaitOK
MOVE.L  HelpDHandle,-(SP) ;Get rid of the dialog
_DisposDialog
MOVE.L  MainPort,-(SP)   ;restore the main port
_SetPort;as the active port
BRAMain

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

ReadIcon:
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
_Close
IsError
RTS
 
GetFile:
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                  
 ;SFGetFile
 
LEASFReply,A0    ;check for successful call
CMP.B #0,(A0)
RTS
 
PutFile:
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
_Pack3
 
LEASFReply,A0    ;check for successful call
CMP.B #0,(A0)
RTS
 
PlotIcon:
PEACurPort;get the GrafPtr in CurPort
_GetPort
MOVE.L  CurPort,A0 ;put it in A0
PEAIconBitMap    ;source
PEA2(A0);dest
PEASourceRect    ;source rect
PEAIconRect ;dest rect
CLR.W -(SP) ;SrcCopy mode
CLR.L -(SP) ;no mask region
_CopyBits
RTS
 
PlotMask:
PEACurPort;get the GrafPtr in CurPort
_GetPort
 MOVE.L CurPort,A0 ;put it in A0
PEAMaskBitMap    ;source
PEA2(A0);dest
PEASourceRect    ;source rect
PEAMaskRect ;dest rect
CLR.W -(SP) ;SrcCopy mode
CLR.L -(SP) ;no mask region
_CopyBits
RTS
 
;  Program Variables  

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

;   That's all....Enjoy!  


!START

/Output IconVert
/Bundle

]
IconVert

/Resources
ResIcon

/TYPE 'APPL' 'BDOG'

$


;  IconVert 3.0  
;  by Chris Yerga for MacTutor
;
;          RESOURCES
; 

RESOURCE 'BDOG' 0

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

.ALIGN 2
RESOURCE 'BNDL' 128
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

.ALIGN 2
RESOURCE 'FREF' 128
DC.B  'APPL',0,0,0

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

.ALIGN 2
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)
.ALIGN 2
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)
.ALIGN 2
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
.ALIGN 2
RESOURCE 'DITL' 128
STRING_FORMAT 2
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
.ALIGN 2
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
.ALIGN 2
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

Latest Forum Discussions

See All

Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »
Explore some of BBCs' most iconic s...
Despite your personal opinion on the BBC at a managerial level, it is undeniable that it has overseen some fantastic British shows in the past, and now thanks to a partnership with Roblox, players will be able to interact with some of these... | Read more »

Price Scanner via MacPrices.net

You can save $300-$480 on a 14-inch M3 Pro/Ma...
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
24-inch M1 iMacs available at Apple starting...
Apple has clearance M1 iMacs available in their Certified Refurbished store starting at $1049 and ranging up to $300 off original MSRP. Each iMac is in like-new condition and comes with Apple’s... Read more
Walmart continues to offer $699 13-inch M1 Ma...
Walmart continues to offer 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 MacBook for sale by... Read more
B&H has 13-inch M2 MacBook Airs with 16GB...
B&H Photo has 13″ MacBook Airs with M2 CPUs, 16GB of memory, and 256GB of storage in stock and on sale for $1099, $100 off Apple’s MSRP for this configuration. Free 1-2 day delivery is available... Read more
14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more
Roundup of Verizon’s April Apple iPhone Promo...
Verizon is offering a number of iPhone deals for the month of April. Switch, and open a new of service, and you can qualify for a free iPhone 15 or heavy monthly discounts on other models: – 128GB... Read more

Jobs Board

IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: Apr 9, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Medical Assistant - Orthopedics *Apple* Hil...
Medical Assistant - Orthopedics Apple Hill York Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now 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
Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
Top Secret *Apple* System Admin - Insight G...
Job Description Day to Day: * Configure and maintain the client's Apple Device Management (ADM) solution. The current solution is JAMF supporting 250-500 end points, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.