FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DISK I/O

Implement PGDTGetIcon call


I am trying to call the Desktop Manager function PBDTGetIcon whose synopsis (from IM More Toolbox) is

FUNCTION PBDTGetIcon(paramBlock: DTPBPtr; asynch: Boolean): OSErr

Charlie Dickman

1. Nothing should be pushed onto nor pulled off of the stack. This looks like a register-based routine which expects the block pointer to be in A0 and the selector in D0. Finally, it returns the result into D0.

2. You have to call one of two different traps, depending on whether the async parameter is set or not. You should use $A660 if async is true, or $A260 if it's false

3. The selector is #$0023, not #$0020.

Try this:
LOCAL FN PBDTGetIcon(@DTPBlock&, asynch%)
  DIM osErr%
  LONG IF asynch%
    `  MOVE.L    ^DTPBlock&,A0
    `  MOVE.W    #$0023,D0
    `  DC.W      $A660
    `  MOVE.W    D0,^osErr%
  XELSE
    `  MOVE.L    ^DTPBlock&,A0
    `  MOVE.W    #$0023,D0
    `  DC.W      $A260
    `  MOVE.W    D0,^osErr%
  END IF
END FN = osErr%
Rick

I call it with
  DEF BLOCKFILL(@DTPBRec, _DTPBRecSize, 0)
  DTPBRec.DTPBioDTBuffer& = @DTPBioDTBuffer
  DTPBRec.DTPBioDTReqCount% = _kLarge8BitIconSize
  DTPBRec.DTPBioIconType% = _kLarge8BitIcon
  DTPBRec.DTPBioFileType& = _"APPL"

  OSErr = FN PBDTGetIcon(DTPBRec, _false)
where DTPBRec and DTPBioDTBuffer are defined with
  DIM DTPBRec.DTPBRecSize, DTPBioDTBuffer.kLarge8BitIconSize
using the following record and constant definitions...
DIM RECORD DTPBRec
  DIM DTPBqLink&                                  ' next queue entry
  DIM DTPBqType%                                  ' queue type
  DIM DTPBioTrap%                                 ' routine trap
  DIM DTPBioCompletion&                           ' completion address
  DIM DTPBioResult%                               ' result code
  DIM DTPBioNamePtr&                              ' file, directory
  ' or volume name
  DIM DTPBioVRefNum%                              ' volume reference number
  DIM DTPBioDTRefNum%                             ' desktop database
  ' reference number
  DIM DTPBioIndex%                                ' index into icon list
  DIM DTPBioTagInfo&                              ' tag information
  DIM DTPBioDTBuffer&                             ' data buffer
  DIM DTPBioDTReqCount&                           ' requested length of data
  DIM DTPBioDTActCount&                           ' actual length of data
  DIM DTPBfiller1%                                ' unused
  DIM DTPBioIconType%                             ' icon type
  DIM DTPBfiller2%                                ' unused
  DIM DTPBioDirId&                                ' parent directory id
  DIM DTPBioFileCreator&                          ' file creator
  DIM DTPBioFileType&                             ' file type
  DIM DTPBfiller3%                                ' unused
  DIM DTPBioDTLgLen&                              ' logical length of
  ' desktop database
  DIM DTPBioDTPyLen&                              ' physical length of
  ' desktop database
  DIM DTPBfiller4%                                ' unused
  DIM DTPBioAPPLParID&                            ' parent directory id
  ' of application
DIM END RECORD.DTPBRecSize

_kLargeIcon = 1                                   'ICN#' large black-and-white
'      icon with mask
_kLarge4BitIcon = 2                               'icl4' large 4-bit color icon
_kLarge8BitIcon = 3                               'icl8' large 8-bit color icon
_kSmallIcon     = 4                               'ics#' small black-and-white
'      icon with mask
_kSmall4BitIcon = 5                               'ics4' small 4-bit color icon
_kSmall8BitIcon = 6                               'ics8' small 8-bit color icon

_kLargeIconSize = 256                             'ICN#' large black-and-white
'      icon with mask
_kLarge4BitIconSize = 512                         'icl4' large 4-bit color icon
_kLarge8BitIconSize = 1024                        'icl8' large 8-bit color icon
_kSmallIconSize     = 64                          'ics#' small black-and-white
'      icon with mask
_kSmall4BitIconSize = 128                         'ics4' small 4-bit color icon
_kSmall8BitIconSize = 256                         'ics8' small 8-bit color icon
Charlie Dickman