home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / lib_examples / suits8.asm < prev    next >
Encoding:
Assembly Source File  |  1992-08-21  |  7.4 KB  |  145 lines

  1. * A sparse (but complete) sample font.
  2. *
  3. * 1.  Assemble this file (assumed to have been saved as "suits8.asm"). For
  4. * example, if you have the CAPE 680x0 assembler, and you have assigned
  5. * "include:" to the directory containing your include files, use:
  6. *          CAsm -a "suits8.asm" -o "suits8.o" -i "include:"
  7. *
  8. *     Link "suits8.o".  For example, if you have Lattice, use:
  9. *          BLink from "suits8.o" to "suits8"
  10. *
  11. * 2.  Create the subdirectory "Fonts:suits".  Copy the file "suits8"
  12. *     (created in step 1) to "Fonts:suits/8".
  13. *
  14. * 3.  Create a font contents file for the font.  You can do this by two
  15. *      methods:
  16. *
  17. *   a. Run the program "System/FixFonts" which will create the file
  18. *      "Fonts:suits.font" automatically.
  19. *   b. Use the NewFontContents() call in the diskfont library to create a
  20. *      FontContentsHeader structure, which can be saved in the Fonts:
  21. *      directory as "suits.font".   This is essentially what FixFonts does.
  22. *
  23. * The next word contains the font YSize; in this case, 0x0008.
  24. *
  25. * The next byte contains the font Flags, in this case 0x00.
  26. *
  27. * The last byte contains the font characteristics, in this case 0x60.  This
  28. * says it is a disk-based font (bit 1 set) and the font has been removed
  29. * (bit 7 set), saying that the font is not currently resident.
  30. *
  31. * Summary of suits.font file:
  32. *
  33. * Name: fch_FileID fch_NumEntries fc_FileName    fc_YSize fc_Flags fc_Style
  34. * Size: word       word     MAXFONTPATH bytes word     byte     byte
  35. * Hex:  0f00       0001     73756974732F3800  0008     00       60
  36. * ASCII:            s u i t s / 8 \0
  37. *
  38. * The correct length of a font file may be calculated with this formula:
  39. * length = ((number of font contents entries) * (MAXFONTPATH+4)) + 4. In
  40. * this case (one entry), this becomes (MAXFONTPATH + 8) or 264.
  41. *
  42. * To try out this example font, do the following.  Use the Fonts
  43. * Preferences editor or a program that allows the user to select fonts.
  44. * Choose the "suits" font in size 8.  This example font defines ASCII
  45. * characters 'a' 'b' 'c' and 'd' only. All other characters map to a
  46. * rectangle, meaning "character unknown".
  47.  
  48.     INCLUDE  "exec/types.i"
  49.     INCLUDE  "exec/nodes.i"
  50.     INCLUDE  "libraries/diskfont.i"
  51.  
  52.     MOVEQ  #-1,D0    ; Provide an easy exit in case this file is
  53.     RTS              ; "Run" instead of merely loaded.
  54.  
  55.     DC.L   0         ; ln_Succ   * These five entries comprise a Node
  56.     DC.L   0         ; ln_Pred   * structure, used by the system to link
  57.     DC.B   NT_FONT   ; ln_Type   * disk fonts into a list.  See the
  58.     DC.B   0         ; ln_Pri    * definition of the "DiskFontHeader"
  59.     DC.L   fontName  ; ln_Name   * structure in the "libraries/diskfont.i"
  60.                                  * includefile for more information.
  61.     DC.W   DFH_ID    ; FileID
  62.     DC.W   1         ; Revision
  63.     DC.L   0         ; Segment
  64.  
  65. * The next MAXFONTNAME bytes are a placeholder.  The name of the font
  66. * contents file (e.g. "suits.font") will be copied here after this font
  67. * descriptor is LoadSeg-ed into memory.  The Name field could have been
  68. * left blank, but inserting the font name and size (or style) allows one to
  69. * tell something about the font by using "Type OPT H" on the file.
  70.  
  71. fontName:
  72.     DC.B      "suits8"    ; Name
  73.  
  74. * If your assembler needs an absolute value in place of the "length"
  75. * variable, simply count the number of characters in Name and use that.
  76.  
  77. length  EQU     *-fontName           ; Assembler calculates Name's length.
  78.         DCB.B   MAXFONTNAME-length,0 ; Padding of null characters.
  79.  
  80. font:
  81.     DC.L  0          ; ln_Succ       * The rest of the information is a
  82.     DC.L  0          ; ln_Pred       * TextFont structure.  See the
  83.     DC.B  NT_FONT    ; ln_Type       * "graphics/text.i" include file for
  84.     DC.B  0          ; ln_Pri        * more information.
  85.     DC.L  fontName   ; ln_Name
  86.     DC.L  0          ; mn_ReplyPort
  87.     DC.W  0          ; (Reserved for 1.4 system use.)
  88.     DC.W  8          ; tf_YSize
  89.     DC.B  0          ; tf_Style
  90.     DC.B  FPF_DESIGNED!FPF_PROPORTIONAL!FPF_DISKFONT ; tf_Flags
  91.     DC.W  14         ; tf_XSize
  92.     DC.W  6          ; tf_Baseline  <----* tf_Baseline must be no greater
  93.     DC.W  1          ; tf_BoldSmear      * than tf_YSize-1, otherwise
  94.     DC.W  0          ; tf_Accessors      * algorithmically-generated styles
  95.     DC.B  97         ; tf_LoChar         * (italic in particular) can
  96.     DC.B  100        ; tf_HiChar         *  corrupt system memory.
  97.     DC.L  fontData   ; tf_CharData
  98.     DC.W  8          ; tf_Modulo  <- * add this to the data pointer to go
  99.                      ;               * from one row of a character to the
  100.                                      * next row of it.
  101.     DC.L  fontLoc    ; tf_CharLoc <------* bit position in the font data
  102.     DC.L  fontSpace  ; tf_CharSpace      * at which the character begins.
  103.     DC.L  fontKern   ; tf_CharKern
  104.  
  105. * The four characters of this font define the four playing-card suit
  106. * symbols.  The heart, club, diamond, and spade map to the lower-case ASCII
  107. * characters 'a', 'b', 'c', and 'd' respectively The fifth entry in the
  108. * table is the character to be output when there is no entry defined in the
  109. * character set for the requested ASCII value.  Font data is bit-packed
  110. * edge to edge to save space.
  111.  
  112. fontData:                             ;   97 (a)       98 (b)       99 (c)   100 (d)      255
  113.     DC.W  $071C0,$08040,$070FF,$0F000 ; <        X        X    X        X        >
  114.     DC.W  $0FBE3,$0E0E0,$0F8C0,$03000 ;  .@@@...@@@.  .....@.....  ...@...  ....@@@....  @@@@@@@@@@@@
  115.     DC.W  $07FCF,$0F9F3,$026C0,$03000 ;  @@@@@.@@@@@  ...@@@@@...  ..@@@..  ...@@@@@...  @@........@@
  116.     DC.W  $03F9F,$0FFFF,$0FFC0,$03000 ;  .@@@@@@@@@.  .@@@@@@@@@.  .@@@@@.  .@@..@..@@.  @@........@@
  117.     DC.W  $01F0E,$0B9F3,$026C0,$03000 ;  ..@@@@@@@..  @@@@@@@@@@@  @@@@@@@  @@@@@@@@@@@  @@........@@
  118.     DC.W  $00E00,$080E0,$020C0,$03000 ;  ...@@@@@...  .@@@.@.@@@.  .@@@@@.  .@@..@..@@.  @@........@@
  119.     DC.W  $00403,$0E040,$0F8FF,$0F000 ;  ....@@@....  .....@.....  ..@@@..  .....@.....  @@........@@
  120.     DC.W  $00000,$00000,$00000,$00000 ;  .....@.....  ...@@@@@...  ...@...  ...@@@@@...  @@@@@@@@@@@@
  121.     DC.W  $00000,$00000,$00000,$00000 ;  ...........  ...........  .......  ...........  ............
  122.  
  123. fontLoc:              ; The fontLoc information is used to "unpack" the
  124.     DC.L  $00000000B  ; fontData. Each pair of words specifies how the
  125.     DC.L  $0000B000B  ; characters are bit-packed.  For example, the first
  126.     DC.L  $000160007  ; character starts at bit position 0x0000, and is
  127.     DC.L  $0001D000B  ; 0x000B (11) bits wide.  The second character starts
  128.     DC.L  $00028000C  ; at bit position 0x000B and is 0x000B bits wide, and
  129.                       ; so on.  This tellsthe font handler how to unpack
  130.                       ; the bits from the array.
  131.  
  132. fontSpace:                      ; fontSpace array:  Use a space this wide
  133.     DC.W  000012,000012         ; to contain this character when it is
  134.     DC.W  000008,000012,000013  ; printed.  For reverse-path fonts these
  135.                                 ; values would be small or negative.
  136.  
  137. fontKern:                       ; fontKern array:  Place a space this wide
  138.     DC.W  000001,000001         ; after the corresponding character to
  139.     DC.W  000001,000001,000001  ; separate it from the following character.
  140.                                 ; For reverse-path fonts these values would
  141.                                 ; be large negative numbers, approximately
  142.                                 ; the width of the characters.
  143. fontEnd:
  144.     END
  145.