;
*****************************************
*                                       *
*  file fontequates                     *
*  started 2/24/86                      *
*  Bennet Marks x6245                   *
*                                       *
*****************************************
;
;NOTE - documentation out of date; better will follow
;BHM, 4/23/86
;
*******************************************************************************
*                                                                             *
*  This equates file defines all the constants and 0-page locations that are  *
*  used by the QD II text-drawing, text-measuring, and related routines, but  *
*  which do not have to be maintained between calls to those routines.        *
*                                                                             *
*  some comments:  of all the text-related routines, the only ones to make    *
*  use of any region-clipping functions are BlowItUp and the various sub-     *
*  routines it calls (BlowItUp is the routine which takes the text image from *
*  the text buffer and moves it into the destination pixelmap, using the      *
*  current foreground and background colors and the current transfer mode).   *
*  Therefore any 0-page locations in FONTEQUATES which are not used by        *
*  BlowItUp and its kin, and whose values do not need to be maintained across *
*  calls to BlowItUp, can be shared with locations in REGION.EQUS (the 0-page *
*  locations used by region-clipping and similar calls).  These locations     *
*  be referred to as the font1Vars.                                           *
*                                                                             *
*  The remaining 0-page locations in FONTEQUATES, which are used by BlowItUp  *
*  or at least must be maintained through BlowItUp, will be called the        *
*  font2Vars.  They must come after both the font1Vars and the region         *
*  equates.                                                                   *
*                                                                             *
*  LATE NOTE:  actually, some of the region stuff must be left alone.  We     *
*  have added an END1REGIONS for the dividing point.  More information to     *
*  follow - BHM, 3/13/86                                                      *
*                                                                             *
*  Also, the global QD II 0-page variables called temp and temp2 (4 bytes     *
*  each) are used frequently, and often assigned new, temprary names to       *
*  reflect their functions in a given routine.  temp and temp2 cannot be      *
*  expected to maintain their values during a call to another routine which   *
*  may also use them.  When modifying this code, attention must be paid to    *
*  "dynamic range" of these named locations, so that information won't be     *
*  trashed by inconsistent or overlapping use.  Documentation will be         *
*  in the particular routines to help with this bookkeeping.                  *
*                                                                             *
*  0-page usage in this file has not been handled particularly cleverly or    *
*  efficiently.  There may be some improvements to follow.                    *
*                                                                             *
*  CAVEAT HACKER!                                                             *
*                                                                             *
*******************************************************************************
;
************************************************************
*                                                          *
*  V.0.0.0 - 3/4/86                                        *
*    Some constants should probably be moved into a more   *
*    general equates file.  Used in ROM 3/5/86 - BHM       *
*  V.0.0.1 - 3/9/86                                        *
*    theWidth added.  leftExtent and rightExtent merged    *
*    with leftExtWord and rightExtWord - CAUTION.          *
*    pretty much out of 0-page resources.  Put into 3/10   *
*    ROM. - BHM                                            *
*  V.0.0.2 - 3/11/86                                       *
*    modified to take advantage of the newly-discovered    *
*    "safe" 0-page space of REGION.EQUS - BHM              *
*                                                          *
************************************************************
;
*****************************************
*                                       *
*  Current date and time:               *
*    3:00 PM, 4/23/86                   *
*                                       *
*****************************************
;
;constants:
;
CortFont       equ 1
;0 for Mac font, 1 for Cortland font (the difference is in integer byte order;
;more differences may be implemented later)
;
;point, rectangle, and grafport constants
;(here for now, but possibly best put elsewhere)
O_V            equ 0                   ;vertical coordinate of point
O_H            equ 2                   ;horizontal
O_V1           equ 0                   ;rectangle upper left vertical coord.
O_H1           equ 2                   ;rect. UL horizontal
O_V2           equ 4                   ;rect. lower right vertical coord.
O_H2           equ 6                   ;rect. LR horizontal
O_portInfo     equ 0                   ;portInfo in grafPort

;
;word breakdown constants
;(ditto)
bitsInWord     equ 16
allBitsOff     equ %0000000000000000
allBitsOn      equ %1111111111111111
firstBit       equ %1000000000000000
first2Bits     equ %1100000000000000 
firstBitXBAed  equ %0000000010000000
lastBit        equ %0000000000000001
lastBitXBAed   equ %0000000100000000
first12Bits    equ %1111111111110000
last4Bits      equ %0000000000001111
first13Bits    equ %1111111111111000
first14Bits    equ %1111111111111100
first15Bits    equ %1111111111111110
lowByte        equ $00FF
highByte       equ $FF00


;
;constants for text drawing routines


O_fontStyle    equ 4
asciiSpace     equ $0020
asciiZero      equ $0030
FxdWdthBit     equ %0000000000000001
half           equ $8000

;
boldBit        equ %0000000000000001
italBit        equ %0000000000000010
ulineBit       equ %0000000000000100
olineBit       equ %0000000000001000
shadowBit      equ %0000000000010000
;



;
; Offsets in font
;
o_FontIDinFont       equ 2
O_style        equ 4
O_size         equ 6
O_version      equ 8
fgSize         equ 14					;Font Globals size (SMD - 26 Oct 88)
;
;font record offsets (names stolen from Mac)
FFormat        equ 0                   ;fontType
FMinChar       equ 2                   ;firstChar
FMaxChar       equ 4                   ;lastChar
FMaxWd         equ 6                   ;widMax
FBBOX          equ 8                   ;kernMax
FBBOY          equ 10                  ;nDescent
FBBDX          equ 12                  ;fRectMax
FBBDY          equ 14                  ;chHeight
FLength        equ 16                  ;owTLoc
FAscent        equ 18                  ;ascent
FDescent       equ 20                  ;descent
FLeading       equ 22                  ;leading
FRaster        equ 24                  ;rowWords
;and some of our own devising
FStrike        equ 26                  ;font strike
;offset/width table entry indicating an in-range missing symbol:
owMSVal        equ -1
***************************************
*
*  Feb. 5, 1987  4:45 pm
*
*  Bennet Marks  x6245
*
***************************************
;
;the following constants should be added to the text routines' repetoire:
;
numWdthBit     equ %0000000000000010
;
;for the GetFontInfo record:
o_FoInDescent  equ 2
o_FoInWidMax   equ 4
o_FoInLeading  equ 6
;
;
;0-page locations:
;
font1Vars      equ end1Regions         ;these can co-exist with REGION.EQUS
;                                       ;(some of them . . . .)
;pointers
;
fontHeadPtr    equ font1Vars           ;pointer to start of Cort font
fontRecPtr     equ fontHeadPtr+4       ;to start of Mac-style font part
strikePtr      equ fontRecPtr+4        ;pointer to beginning of font strike
locTPtr        equ strikePtr+4         ;to beginning of font location table
owTPtr         equ locTPtr+4           ;beginning of font offset/width table
endOfPtrs      equ owTptr+4
;
;font information (from font record)
;
ascent         equ endOfPtrs           ;font ascent
rowBytes       equ ascent+2            ;width of font strike in bytes
firstChar      equ rowBytes+2          ;first defined character in font
lastChar       equ firstChar+2         ;last defined character in font
kernMax        equ lastChar+2          ;font's max left kern, as a negative
msCodeT2       equ kernMax+2           ;code for font "missing symbol", offset
;                                       ;and *2 for array access
endFontInfo    equ msCodeT2+2
;
;buffer information
;
bufPen         equ endFontInfo         ;pen position within buffer, measured
;                                       ;in pixels
startBufPen    equ bufPen+2
bucket         equ startBufPen+2       ;holds low-order word for fixed-point
bufRightLimit  equ bucket+2

endBufInfo     equ bufRightLimit+2
;
imagePen       equ endBufInfo          ;position in buffer where character
;                                       ;image starts, in pixels (= bufPen,
;                                       ;adjusted for kerning)
strikeWord     equ imagePen+2
startByte      equ strikeWord+2        ;(startWord)*2, so we can use it as an
;                                       ;index
fRectMax       equ startByte+2
hBufToLoc      equ fRectMax+2
vBufToLoc      equ hBufToLoc+2
maskLeft       equ vBufToLoc+2
maskRight      equ maskLeft+2
leftLimit      equ maskRight+2
rightLimit     equ leftLimit+2
currPen        equ rightLimit+2
;
endFont1Vars   equ currPen+2
zzEndFont1Vars equ endFont1Vars
;
;the following locations cannot overlap with the font1Vars or the REGION.EQUS.
;We use conditional assembly to make sure:
;
               IF endOfRegions>endFont1Vars GOTO .RegBigger
startFont2Vars equ endFont1Vars
               GOTO .GotSF2V
.RegBigger
startFont2Vars equ endOfRegions
.GotSF2V
zzfont2start   equ startFont2Vars
;
;
bufPtr         equ startFont2Vars
tbRowPtr       equ bufPtr+4
pmRowPtr       equ tbRowPtr+4
;
tbStartByte    equ pmRowPtr+4
pmStartByte    equ tbStartByte+2
BG             equ pmStartByte+2
tempFG         equ BG+2
notMaskAndDest equ tempFG+2
bufRowBytes    equ notMaskAndDest+2
numOfWords     equ bufRowBytes+2
rowCounter     equ numOfWords+2
chHeight       equ rowCounter+2
wordCounter    equ chHeight+2
leftExtent     equ wordCounter+2
rightExtent    equ leftExtent+2
fontTemp       equ rightExtent+2
charToDraw     equ fontTemp+4          ;ASCII code of character to be displayed
;
textLength     equ charToDraw+2        ;# of characters remaining to be drawn
;
textPtr        equ textLength+2        ;pointer to start of text char.'s
theWidth       equ textPtr+4
widMax         equ theWidth+2
descent        equ widMax+2
leading        equ descent+2
txFace         equ leading+2
justExtents    equ txFace+2
numOfBytes     equ justExtents+2
spExtra        equ numOfBytes+2
chExtra        equ spExtra+4
extra          equ chExtra+4
fontFlags      equ extra+2
;the following variables must be added to the text routines' 0-page
;
digitWidth     equ fontFlags+2         ;character width of digit 0
;
;
Version102	   equ digitWidth+2		; added 30 Oct 88 by SEG to make Sue's code work in ROM.
;
endFont2Vars   equ Version102+2
;
zzEndFont2Vars equ endFont2Vars
;



************************************************************
*                                                          *
*  Note:  many of the above variables are ripe for         *
*  aliasing.  I only took as many as I needed.             *
*                                                          *
************************************************************
;
widthOfChar    equ temp
imageWidth     equ temp
locTEnt        equ temp+2
startBit       equ temp2
startWord      equ temp2+2
;
curPMByte      equ temp
curTBByte      equ temp+2
FG             equ temp2
textMode       equ temp2+2



;
;these global equates must be made available to the QD II text-drawing
;routines.  They are used by the patches that introduce fbrExtent.
;
last15Bits     equ %0111111111111111
V0100          equ $0100               ;version number V.01.00
O_fbrExtent    equ 10                  ;fbrExtent offset
;
;added 3/10/87 for CalcSlop:
fontSlop       equ 0                   ;lives on third 0-page
;
;added 10/26/88 for Version 1.02.  Introduces highOwTLoc.
;
;
; We use $0105 for the new font version number because a dumb application
; (Graphics Studio) made their own font and used the version number 1.2
; for it.  This font did not work with the new quickdraw so we skip a few
; numbers and try again.
;
V0102			equ $0105				;Version 1.02
O_highOwTLoc	equ 12					;offset for high word of offset to o/w table



;
;these added for outlining:
;third 0-page stuff:
tb1R1Ptr       equ 0                  ;text buffer 1, top row, 1st active
xBufPtr        equ tb1R1Ptr+4         ;ptr to tb1
tb2Ptr         equ xBufPtr+4          ;ptr to tb2
tb2R2Ptr       equ tb2Ptr+4           ;tb2, 2nd row, leftmost active word
xLeftExtent    equ tb2R2Ptr+4
xRightExtent   equ xLeftExtent+2
xFontWidth     equ xRightExtent+2
trueFBRXtnt    equ xFontWidth+2
;
tb2Handle      equ 256-4              ;permanent
tb3Handle      equ tb2Handle-4        ;permanent  
;
oldY           equ fontTemp
newY           equ fontTemp+2
;
bRowPtr        equ spExtra            ;bottom row ptr




;
;
;
*****************************************************************************
* FastDrawing equates														*
* 2/10/89	Mensch
* These equates are used in the fast drawing routines, they go on top of 	*
* other font manager direct page stuff, so be careful when you use the two	*
* together.
*****************************************************************************


fastfontVars      equ end1Regions         ;these can co-exist with REGION.EQUS
;                                       ;(some of them . . . .)
;pointers
;
fastHeadPtr    equ font1Vars           ;pointer to start of Cort font
fontStrike1    equ fontHeadPtr+4       ;offsets to the font strike in our file
fontStrike2    equ fontStrike1+4       ;offsets to the font strike in our file
fontStrike3    equ fontStrike2+4       ;offsets to the font strike in our file
fontStrike4    equ fontStrike3+4       ;offsets to the font strike in our file
endOffastPtrs      equ fontStrike4+4
; fast char locals... can be no larger than 28 bytes...
;
CharRect       	equ endFontInfo       	; 0 rectangle used to locate characters
;                                     	;in pixels
space_bucket    equ CharRect+4       	; 4 Space for the bucket for addextra
destRef		   	equ CharRect+4			; 6 address to draw the character into...
srcRef      	equ destRef+4			; 10
fastMaskLeft	equ srcRef+4			; 14
fastMaskRight	equ fastMaskLeft+2		; 16
mult1			equ fastMaskRight+2		; 18
mult2			equ mult1+2				; 20
shiftinfo		equ mult2+2				; 22 number of pixels to shift *2
StdFontHandle	equ shiftInfo+2			; 24 do I really need this???
fastLineStat	equ StdFontHandle+4		; 28
fastMode		equ textMode
;
fastBucket		equ justExtents			; reuse justExtents for fastfont chextra bucket
;
; Equates for the fastfont record
;
o_FFAscent		equ 0
o_FFDescent		equ o_FFAscent+2
o_FFMaxWidth	equ o_FFDescent+2
o_FFLeading		equ o_FFMaxWidth+2
o_FFrowBytes	equ o_FFLeading+2
o_oldFontHandle	equ o_FFRowBytes+2
o_StrikeSize	equ o_oldFontHandle+4
o_FFSizeofVars	equ o_StrikeSize+4
o_FFWidthTable	equ o_FFSizeofVars
o_FFOffsetTable	equ o_FFWidthTable+256
o_FFEndOfTables	equ o_FFOffsetTable+512
;
