home *** CD-ROM | disk | FTP | other *** search
-
- Æ;ô ><BasicV$Lib>.CreateDraw Create Draw files. v0.07
- Ðô
- ÚHô Routines to help create a Draw file that resides totally inside a
- äIô heap block. Can print text as path objects, handles text objects,
- îDô handles sprite objects, handles group objects, handles tagged
- øGô objects, font table objects. Does NOT handle text area objects.
- ô
- ô MACHINE: Archimedes
- #ô LANGUAGE: BBC BASIC V, v1.04
- ô AUTHOR: Cy Booker,
- *Gô 86 Church View, Main Road, Crockenhill, Swanley, Kent.
- 4ô BR8 8JW
- >ô FUNCTIONS:
- Hô Char_Width( C% )
- R%ô Char_Draw_Width( C%, width% )
- \ ô Draw_Font_Name( Style% )
- f ô Draw_Font_Style( name$ )
- pô :
- z!ô Inches_To_Draw_Units( i )
- ☓ô :
- ‰&ô Claim_Draw_Sub_Buffer( need% )
- —ô :
- ¢ô PROCEDURES:
- ¬(ô Open_DrawFile( min_mem%, name$ )
- ¶+ô Close_DrawFile( file_name$, keep% )
- À?ô Open_Draw_Path_Object( fill%, colour%, width%, flags% )
- Ê/ô Bezier( x0%, y0%, x1%, y1%, x2%, y2% )
- Ôô Draw( x%, y% )
- Þô Move( x%, y% )
- è#ô Line( x0%, y0%, x1%, y1% )
- òô Close_Path()
- üô Close_SubPath()
- ô Close_Draw_Path_Object
- #ô Open_Draw_Font_Table_Object
- *ô Draw_Font_Table( number%, font$ )
- $%ô Draw_Font_Table_Add( font$ )
- .$ô Close_Draw_Font_Table_Object
- 87ô Open_Draw_Text_Object( X%, Y%, W%, H%, Style% )
- B"ô Draw_Text_Object( text$ )
- L ô Close_Draw_Text_Object()
- VFô Draw_Sprite_Object( name$, base%, xmin%, ymin%, xmax%, ymax% )
- `(ô Open_Draw_Group_Object( group$ )
- j!ô Close_Draw_Group_Object()
- t.ô Open_Draw_Tagged_Object( identifier% )
- ~.ô Draw_Tagged_Object( start%, length% )
- ⇦)ô Draw_Tagged_Object_Byte( byte% )
- ‹)ô Draw_Tagged_Object_Word( word% )
- †)ô Draw_Tagged_Object_Text( text$ )
- ¦"ô Close_Draw_Tagged_Object()
- °'ô Open_Draw_Font( font$, cache% )
- º-ô Draw_Character( C%, X%, Y%, W%, H% )
- Ä ô Close_Draw_Font( font$ )
- Îô :
- ØFô Draw_Check( n_bytes% ) Ensure bytes free in buffer.
- â1ô Draw_Path_Bounding_Box( h%, fill_style% )
- ìô :
- öGô Draw_Rotate_Path( in%, out%, xo%, yo%, radians ) ---> Untested
- =ô Draw_Translate_Path( in%, out%, dx%, dy% ) /
- <ô Init_Draw_Out_Path( size% ) /
- ;ô Draw_Scale_Path( in%, out%, dx, dy ) /
- ô :
- (!ô Release_Draw_Sub_Buffer()
- 2:
- <ô EXTERNALS:
- Fô Wimp heap.
- Pô :
- Zô UPDATES:
- d.ô 14.04.1991 CJB Wrote (from crossword).
- nGô 30.04.1991 CJB Sub-buffers written, transformations documented.
- x1ô 02.05.1991 CJB Characters now functional.
- ŵ,ô 03.05.1991 CJB Close font now works!
- …Jô 18.05.1991 CJB When open file, sets ..Cache$, so error handled OK.
- „@ô 23.05.1991 CJB Close_Path_Object() badly set Draw_xmax%.
- Kô 25.10.1991 CJB Draw_Font_Style() added, error message in .._Name().
- ªIô 03.11.1991 CJB So proper error if attempt text before font table.
- ´:
- ¾$Ý ¤_CreateDraw_version : = 007
- È:
- Ò"Ý ¤_hard_initialise_CreateDraw
- Üê Ŷ
- æCî Ŷ ê ÷ Ŷ : ò_e( "%.CreateDraw: hard_initialise_CreateDraw" )
- ð0 ò_load_library( "<BasicV$Lib>.Heap", 011 )
- ú3 ò_load_library( "<BasicV$Lib>.IntMath", 004 )
- 0 ò_load_library( "<BasicV$Lib>.Wimp", 015 )
- , ò_Claim_Heap_Block( TransMatrix%, 24 )
- = 0
- ":
- ,Kô *********************************************************************
- 6Lô * Start creating a draw file inside a Heap block. This gets extend as
- @<ô * and when. If an error is generated, you should call
- JKô * PROC_Handle_DrawFile_Error, before processing the errors as normal.
- TJô * The following "globals" will be used - to save passing six million
- ^!ô * parameters to everything:
- h:
- rGê Draw_Buffer%, D%, E%, Draw_Group%, Draw_Group_Buffer%, Draw_xmin%
- |Jê Draw_Group_Max%, Draw_Group%, Draw_Object%, O%, M%, Draw_Font_Cache%
- ŷHê Draw_Font_Cache_X%, Draw_Font_Cache_Y%, Draw_Font_Cache_W%, O%, M%
- ‘Jê Draw_Font_Cache_H%, Draw_Design_Size%, Draw_ymax%, Draw_Font_Colour%
- Œ?ê Draw_ymin%, Draw_xmax%, Draw_Font_Fill%, Draw_Font_Width%
- ¤=ê Draw_Chars_Defined%, Draw_Font_Table%, Draw_Font_Cache$
- ®;ê Draw_Text_Colour%, Draw_Text_Hint%, Draw_Text_Object%
- ¸ê Draw_Font_Table_Style%
- Â:
- Ì9: ô Draw_Buffer% == Draw file memory buffer.
- ÖE: ô D% == Rove inside draw file memory buffer.
- à@: ô E% == End of draw file memory buffer.
- êI: ô Draw_xmin% == Local to groups, but extend to "globals"
- ôL: ô Draw_ymin% == for calculation of groups and, indeed, the
- þG: ô Draw_xmax% == the whole file. min's are inclusive,
- J: ô Draw_ymax% == max's are exclusive draw internal units.
- F: ô Draw_Group_Buffer%[] == Start of group header in draw buffer.
- 8: ô Draw_Group% == Index into it [0, max).
- &7: ô Draw_Group_Max% == Maximum group nesting.
- G: ô Draw_Object% == Start of object header in draw buffer.
- :I: ô Draw_Font_Cache%[] == Used when caching fonts (6Kbytes total).
- DK: ô Draw_Font_Cache_D%[] == Offset in draw file of previously rendered
- NL: ô Draw_Font_Cache_X%[] == character. This points to the header. The
- XK: ô Draw_Font_Cache_Y%[] == other arrays detail the original rendering
- bK: ô Draw_Font_Cache_W%[] == parameters. Thus could lose resolution if
- lF: ô Draw_Font_Cache_H%[] == first one is very small. Not likely.
- v?: ô Draw_Font_Cache$ == Name of font currently "open".
- €B: ô O% == File handle of outline font file.
- ⇩B: ô M% == File handle of metrics font file.
- “4: ô Draw_Design_Size% == Set when open font.
- fi4: ô Draw_Chars_Defined% == Set when open font.
- ¨F: ô Draw_Font_Colour% == Must be explicitly set before calling
- ²C: ô Draw_Font_Fill% == PROC_Draw_Character. Colours are
- ¼G: ô Draw_Font_Width% == standard, as is the width definition.
- ÆC: ô Draw_Font_Table% == Used internally to ensure created.
- ÐE: ô Draw_Font_Table_Style%= Used internally while making object.
- Ú9: ô Draw_Text_Colour% == Text object font colour.
- äD: ô Draw_Text_Hint% == Text object background hint colour.
- îA: ô Draw_Text_Object% == Offset into draw file of header.
- øE: ô Draw_Sub_Buffer% == Offset into draw file of sub-buffer.
- : ô /.
- :
- (Ý ò_Open_DrawFile( min_mem%, name$ )
- ê Ŷ
- *6î Ŷ ê ÷ Ŷ : ò_e( "%.CreateDraw: Open_DrawFile" )
- 4 Draw_Buffer% = 0
- > Draw_Group_Buffer% = 0
- H Draw_Group% = 0
- R Draw_Group_Max% = 12
- \ Draw_Font_Cache% = 0
- f Draw_Font_Cache$ = ""
- p Draw_Font_Table% = 0
- z O% = 0
- ☓ M% = 0
- ‰6 min_mem% = ¤_max_int( min_mem%, 1024 )
- —I ò_Claim_Heap_Block( Draw_Group_Buffer%, (Draw_Group_Max% * 5 * 4) )
- ¢2 ò_Claim_Heap_Block( Draw_Buffer%, min_mem% )
- ¬ D% = Draw_Buffer%
- ¶" E% = Draw_Buffer% + min_mem%
- À :
- Ê $D% = "Draw"
- Ô D%!4 = 201
- Þ D%!8 = 0
- è( $(D%+12) = Àname$+ Ä12, " "), 12 )
- ò D% += 40
- ü :
- Draw_xmin% = &7FFFFFFF
- Draw_ymin% = &7FFFFFFF
- Draw_xmax% = &80000000
- $ Draw_ymax% = &80000000
- .á
- 8:
- BKô *********************************************************************
- LKô * IN file_name$ == Full name to save as (time-stamped/typed), or ""
- VFô * keep% == Boolean, TRUE if keep drawfile in heap block, at
- `*ô * Draw_Buffer% ... D%.
- j2ô * OUT File may be created (error-generated)
- tKô * All ancillary heap blocks released, and draw file if not keep.
- ~:
- ⇦+Ý ò_Close_DrawFile( file_name$, keep% )
- ‹ ç Draw_Group%<>0 …
- †+ Ŷ 1, "Group's not closed properly."
- ¦ Í
- °D Draw_Buffer%!24 = Draw_xmin% : ô Bound low.
- º" Draw_Buffer%!28 = Draw_ymin%
- ÄE Draw_Buffer%!32 = Draw_xmax% : ô Bound high.
- Î" Draw_Buffer%!36 = Draw_ymax%
- Ø ç file_name$<>"" …
- â= È− "OS_File", 10, file_name$, &AFF,, Draw_Buffer%, D%
- ì Í
- ö0 ò_Release_Heap_Block( Draw_Group_Buffer% )
- ò_Close_Draw_Font( "" )
- ç keep% …
- D% -= Draw_Buffer%
- E% -= Draw_Buffer%
- (6 ò_Extend_Heap_Block( Draw_Buffer%, (D% - E%) )
- 2 D% += Draw_Buffer%
- < E% = D%
- F Ì
- P, ò_Release_Heap_Block( Draw_Buffer% )
- Z Í
- dá
- n:
- xÝ ò_Handle_DrawFile_Error
- ŵ ò_Close_DrawFile( "", £ )
- …á
- „:
- Kô *********************************************************************
- ª8ô * fill%/colour% == &BBGGRR00 or -1. Usually -1/0.
- ´Kô * width% == 0 for thinnest, else output dependent pixels. Usually 0.
- ¾Jô * flags% == Bit significant, defininig join style/caps/winding rule/
- ÈIô * dash included/triangle caps. Usually just 1 << 6 = 64.
- Ò:
- Ü?Ý ò_Open_Draw_Path_Object( fill%, colour%, width%, flags% )
- æ ò_Draw_Check( 40 )
- ð& Draw_Object% = D% - Draw_Buffer%
- ú D%!0 = 2
- D%!24 = fill%
- D%!28 = colour%
- D%!32 = width%
- " D%!36 = flags%
- , ç (flags% € &80)<>0 …
- 6E Ŷ 1, "Bad Open Draw Path Object - dashes not supported, yet."
- @ Í
- J D% += 40
- Tá
- ^:
- hÝ ò_Close_Draw_Path_Object
- rê o%
- |T o%=D%!-4:ç (o%<>0) € (o%<>5) … Ŷ 1, "Close Draw Path object: path not closed."
- ŷ& o% = Draw_Buffer% + Draw_Object%
- ‘ o%!4 = D% - o%
- ŒJ È− "Draw_ProcessPath", o%+40, &7000003A, 0, 0, 0, 0, 0, o%+&80000008
- ¤0 Draw_xmin% = ¤_min_int( Draw_xmin%, o%!8 )
- ®1 Draw_ymin% = ¤_min_int( Draw_ymin%, o%!12 )
- ¸1 Draw_xmax% = ¤_max_int( Draw_xmax%, o%!16 )
- Â1 Draw_ymax% = ¤_max_int( Draw_ymax%, o%!20 )
- Ìá
- Ö:
- à"Ý ò_Line( x0%, y0%, x1%, y1% )
- ê ò_Move( x0%, y0% )
- ô ò_Draw( x1%, y1% )
- þá
- :
- Ý ò_Move( x%, y% )
- ò_Draw_Check( 12 )
- &
- !D% = 2
- 0 D%!4 = x%
- : D%!8 = y%
- D D% += 12
- Ná
- X:
- bÝ ò_Draw( x%, y% )
- l ò_Draw_Check( 12 )
- v
- !D% = 8
- € D%!4 = x%
- ⇩ D%!8 = y%
- “ D% += 12
- fiá
- ¨:
- ².Ý ò_Bezier( x0%, y0%, x1%, y1%, x2%, y2% )
- ¼ ò_Draw_Check( 28 )
- Æ
- !D% = 6
- Ð D%!4 = x0%
- Ú D%!8 = y0%
- ä D%!12 = x1%
- î D%!16 = y1%
- ø D%!20 = x2%
- ! D%!24 = y2%
- ! D% += 28
- !á
- ! :
- !*Ý ò_Close_Path
- !4 ò_Draw_Check( 4 )
- !>
- !D% = 0
- !H
- D% += 4
- !Rá
- !\:
- !fÝ ò_Close_SubPath
- !p ò_Draw_Check( 4 )
- !z
- !D% = 5
- !☓
- D% += 4
- !‰á
- !—:
- !¢Kô *********************************************************************
- !¬Jô * Font table object. Only used to map font numbers to actual fonts.
- !¶:
- !À#Ý ò_Open_Draw_Font_Table_Object
- !Ê ò_Draw_Check( 8 )
- !Ô* Draw_Font_Table% = D% - Draw_Buffer%
- !Þ Draw_Font_Table_Style% = 1
- !è
- !D% = 0
- !ò
- D% += 8
- !üá
- ":
- ")Ý ò_Draw_Font_Table( number%, font$ )
- "ê l%
- "$! ç number%<1 ☓ number%>255 …
- ".? Ŷ 1, "Bad font table index, while adding to font table"
- "8 Í
- "B l% = ©(font$) + 2
- "L ò_Draw_Check( l%+1 )
- "V ?D% = number%
- "` $(D%+1) = font$+ ½(0)
- "j D% += l%
- "tá
- "~:
- "⇦-: ô Only adds it if not already in there
- "‹:
- "†$Ý ò_Draw_Font_Table_Add( font$ )
- "¦ê l%, F%, found%
- "°. F% = Draw_Buffer% + Draw_Font_Table% + 8
- "º found% = £
- "Ä È” F%<D% € ¬(found%)
- "Î% found% = ¤getname(F%+1)=font$
- "Ø ç ¬(found%) …
- "â F%+=1
- "ì È” ?F%:F%+=1:Î
- "ö Í
- # Î
- #
- ç ¬(found%) …
- #' ç Draw_Font_Table_Style%>=256 …
- #. Ŷ 1, "Too many fonts for font table"
- #( Í
- #2 l% = ©(font$) + 2
- #< ò_Draw_Check( l%+1 )
- #F$ ?D% = Draw_Font_Table_Style%
- #P# Draw_Font_Table_Style% += 1
- #Z $(D%+1) = font$+ ½(0)
- #d D% += l%
- #n Í
- #xá
- #ŵ:
- #…$Ý ò_Close_Draw_Font_Table_Object
- #„ê F%
- # ò_Draw_Check( 4 )
- #ª È” (D% € 3)<>0
- #´ ?D% = 0
- #¾ D% += 1
- #È Î
- #Ò* F% = Draw_Buffer% + Draw_Font_Table%
- #Ü F%!4 = D% - F%
- #æá
- #ð:
- #ú Ý ¤_Draw_Font_Name( Style% )
- $ê F%, n$, G%, found%
- $ ê Ŷ
- $5 î Ŷ ê ÷ Ŷ : ò_e("%.CreateDraw: Draw_Font_Name")
- $" ê Ŷ
- $,M î Ŷ ê ÷ Ŷ : Ŷ 1, "Can't create text object before a font table object."
- $6$ ç Draw_Font_Table%=0 … Ŷ 1, ""
- $@ ÷ Ŷ
- $J* F% = Draw_Buffer% + Draw_Font_Table%
- $T G% = F% + (F%!4)
- $^
- F% += 8
- $h found% = £
- $r È” F%<G% € ¬(found%)
- $| ç (?F%)=Style% …
- $ŷ n$ = ¤getname( F%+1 )
- $‘ found% = ¹
- $Œ Ì
- $¤ F%+=1
- $® È” ?F%<>0:F%+=1:Î
- $¸ F%+=1
- $Â Í
- $Ì Î
- $ÖY ç ¬(found%) … Ŷ 1, "Can't find a font style of #"+ Ã(Style%)+ " in the font table."
- $à= n$
- $ê:
- $ô Ý ¤_Draw_Font_Style( name$ )
- $þê F%, G%, found%
- % ê Ŷ
- %6 î Ŷ ê ÷ Ŷ : ò_e("%.CreateDraw: Draw_Font_Style")
- % ê Ŷ
- %&M î Ŷ ê ÷ Ŷ : Ŷ 1, "Can't create text object before a font table object."
- %0$ ç Draw_Font_Table%=0 … Ŷ 1, ""
- %: ÷ Ŷ
- %D* F% = Draw_Buffer% + Draw_Font_Table%
- %N G% = F% + (F%!4)
- %X
- F% += 8
- %b found% = £
- %l È” F%<G% € ¬(found%)
- %v% found% = ¤getname(F%+1)=name$
- %€ ç ¬ found% …
- %⇩ F%+=1
- %“ È” ?F%:F%+=1:Î
- %fi F%+=1
- %¨ Í
- %² Î
- %¼K ç ¬(found%) … Ŷ 1, "Can't find font `"+ name$+ "' in the font table."
- %Æ = ?F%
- %Ð:
- %ÚKô *********************************************************************
- %ä/ô * Uses Draw_Text_Colour%, Draw_Text_Hint%
- %îLô * Place text$ in font Style% at base line X%, Y%. Font starts of with
- %ø+ô * a size of W% by H% 1/640'ths point.
- &:
- &7Ý ò_Open_Draw_Text_Object( X%, Y%, W%, H%, Style% )
- & ò_Draw_Check( 53 )
- & + Draw_Text_Object% = D% - Draw_Buffer%
- &*
- !D% = 1
- &4 D%!24 = Draw_Text_Colour%
- &> D%!28 = Draw_Text_Hint%
- &H D%!32 = Style%
- &R D%!36 = W%
- &\ D%!40 = H%
- &f D%!44 = X%
- &p D%!48 = Y%
- &z D% += 52
- &☓á
- &‰:
- &—G: ô Gets concatonated onto end of current text. Thus getting over
- &¢$: ô BASIC 256 charactert limit.
- &¬:
- &¶!Ý ò_Draw_Text_Object( text$ )
- &À" ò_Draw_Check( ©(text$) + 1 )
- &Ê $D% = text$
- &Ô D% += ©(text$)
- &Þá
- &è:
- &òÝ ò_Close_Draw_Text_Object
- &üê T%, h%
- ' õ
- ' ?D% = 0
- ' D% += 1
- '$ ý (D% € 3)=0
- '.+ T% = Draw_Buffer% + Draw_Text_Object%
- '8 T%!4 = D% - T%
- 'BQ È− "Font_FindFont",, ¤_Draw_Font_Name( T%!32 ), (T%!36)*40, (T%!40)*40 ¸ h%
- 'LI È− "Font_StringBBox", h%, text$+ ½(0) ¸ , T%!8, T%!12, T%!16, T%!20
- 'V0 Draw_xmin% = ¤_min_int( Draw_xmin%, T%!8 )
- '`1 Draw_ymin% = ¤_min_int( Draw_ymin%, T%!12 )
- 'j1 Draw_xmax% = ¤_max_int( Draw_xmax%, T%!16 )
- 't1 Draw_ymax% = ¤_max_int( Draw_ymax%, T%!20 )
- '~á
- '⇦:
- '‹Kô *********************************************************************
- '†1ô * Define a sprite, inside the bounding box.
- '¦Hô * base% = +1 for Wimp, 0 for system, else pointer to sprites base.
- '°1ô * A side affect, this sprite is "selected".
- 'º:
- 'ÄFÝ ò_Draw_Sprite_Object( name$, base%, xmin%, ymin%, xmax%, ymax% )
- 'Î
- ê sp%, i%
- 'Ø È‰ base% Ê
- 'â2 É 0 : È− "OS_SpriteOp", &18,, name$ ¸ ,, sp%
- 'ì5 É +1 : È− "Wimp_SpriteOp", &18,, name$ ¸ ,, sp%
- 'ö7 : È− "OS_SpriteOp", &118, base%, name$ ¸ ,, sp%
- ( Ë
- (
- ! ò_Draw_Check( (!sp%) + 24 )
- (
- !D% = 5
- ( D%!4 = (!sp%) + 24
- (( D%!8 = xmin%
- (2 D%!12 = ymin%
- (< D%!16 = xmax%
- (F D%!20 = ymax%
- (P D% += 24
- (Z ã i%= 0 ¸ (!sp%) - 1 ⇦ 4
- (d D%!i% = sp%!i%
- (n
- í i%
- (x D% += !sp%
- (ŵá
- (…:
- („Kô *********************************************************************
- ( @ô * Grouped objects can be nested as deep as memory permits.
- (ª:
- (´(Ý ò_Open_Draw_Group_Object( group$ )
- (¾ê G%
- (È ò_Draw_Check( 37 )
- (Ò) ç Draw_Group%=(Draw_Group_Max%-1) …
- (Ü? ò_Extend_Heap_Block( Draw_Group_Buffer%, (16 * 5 * 4) )
- (æ Draw_Group_Max% += 16
- (ð Í
- (ú5 G% = Draw_Group_Buffer% + (Draw_Group% * 5 * 4)
- ) G%!0 = D% - Draw_Buffer%
- ) G%!4 = Draw_xmin%
- ) G%!8 = Draw_ymin%
- )" G%!12 = Draw_xmax%
- ), G%!16 = Draw_ymax%
- )6
- !D% = 6
- )@( $(D%+24) = Àgroup$+ Ä12, " "), 12)
- )J D% += 36
- )T Draw_Group% += 1
- )^ Draw_xmin% = &7FFFFFFF
- )h Draw_ymin% = &7FFFFFFF
- )r Draw_xmax% = &80000000
- )| Draw_ymax% = &80000000
- )ŷá
- )‘:
- )ŒÝ ò_Close_Draw_Group_Object
- )¤ê G%, H%
- )® ç Draw_Group%=0 …
- )¸' Ŷ 1, "Bad Draw Group Close!!!!"
- )Â Í
- )Ì Draw_Group% -= 1
- )Ö8 G% = Draw_Group_Buffer% + (Draw_Group% * 5 * 4)
- )à# H% = ¤_Draw_Address( !G% )
- )ê H%!4 = D% - H%
- )ô H%!8 = Draw_xmin%
- )þ H%!12 = Draw_ymin%
- * H%!16 = Draw_xmax%
- * H%!20 = Draw_ymax%
- *0 Draw_xmin% = ¤_min_int( Draw_xmin%, G%!4 )
- *&0 Draw_ymin% = ¤_min_int( Draw_ymin%, G%!8 )
- *01 Draw_xmax% = ¤_max_int( Draw_xmax%, G%!12 )
- *:1 Draw_ymax% = ¤_max_int( Draw_ymax%, G%!16 )
- *Dá
- *N:
- *XKô *********************************************************************
- *b@ô * A tagged object can be nested as deep as memory permits.
- *l>ô * This uses the Group "stack" to store the bounding box.
- *vLô * Just open it, define an object, then write to D%, and finally close.
- *€:
- *⇩.Ý ò_Open_Draw_Tagged_Object( identifier% )
- *“ê G%
- *fi ò_Draw_Check( 28 )
- *¨) ç Draw_Group%=(Draw_Group_Max%-1) …
- *²? ò_Extend_Heap_Block( Draw_Group_Buffer%, (16 * 5 * 4) )
- *¼ Draw_Group_Max% += 16
- *Æ Í
- *Ð5 G% = Draw_Group_Buffer% + (Draw_Group% * 5 * 4)
- *Ú G%!0 = D% - Draw_Buffer%
- *ä G%!4 = Draw_xmin%
- *î G%!8 = Draw_ymin%
- *ø G%!12 = Draw_xmax%
- + G%!16 = Draw_ymax%
- +
- !D% = 7
- + D%!24 = identifier%
- + D% += 28
- +* Draw_Group% += 1
- +4 Draw_xmin% = &7FFFFFFF
- +> Draw_ymin% = &7FFFFFFF
- +H Draw_xmax% = &80000000
- +R Draw_ymax% = &80000000
- +\á
- +f:
- +pK: ô If prepared tag information externally, can use this to copy it to
- +z: ô the output buffer.
- +☓:
- +‰-Ý ò_Draw_Tagged_Object( start%, length% )
- +—ê i%
- +¢ ò_Draw_Check( length% )
- +¬ ã i%= 0 ¸ length% - 1
- +¶ D%?i% = start%?i%
- +À
- í i%
- +Ê D% += length%
- +Ôá
- +Þ:
- +èB: ô These can be used if creating tag information on the fly.
- +ò:
- +ü(Ý ò_Draw_Tagged_Object_Byte( byte% )
- , ò_Draw_Check( 1 )
- , ?D% = byte%
- ,
- D% += 1
- ,$á
- ,.:
- ,8(Ý ò_Draw_Tagged_Object_Word( word% )
- ,B ò_Draw_Check( 4 )
- ,L !D% = word%
- ,V
- D% += 4
- ,`á
- ,j:
- ,t(Ý ò_Draw_Tagged_Object_Text( text$ )
- ,~" ò_Draw_Check( ©(text$) + 2 )
- ,⇦ $D% = text$+ ½(0)
- ,‹ D% += ©(text$) + 1
- ,†á
- ,¦:
- ,°<: ô Stop writing tag information, word align, then end.
- ,º:
- ,Ä Ý ò_Close_Draw_Tagged_Object
- ,Î ò_Draw_Check( 4 )
- ,Ø È” (D% € 3)<>0
- ,â ?D% = 0
- ,ì D% += 1
- ,ö Î
- - ò_Close_Draw_Group_Object
- -
- á
- -:
- -Kô *********************************************************************
- -(=ô * IN X%,Y% == Draw units of bottom left of character.
- -23ô * W%,H% == Draw units size of character.
- -<.ô * C% == ASCII code of character.
- -F-ô * OUT [D%++] <-- Draw file path object
- -P:
- -Z,Ý ò_Draw_Character( C%, X%, Y%, W%, H% )
- -dê o%, i%
- -n C% = C% << 2
- -x o% = 0
- -ŵ ç Draw_Font_Cache%<>0 …
- -…" o% = Draw_Font_Cache_D%!C%
- -„ Í
- - ç o%=0 …
- -ª ç Draw_Font_Cache%<>0 …
- -´I Draw_Font_Cache_D%!C% = D% - Draw_Buffer% : ô Offset!
- -¾$ Draw_Font_Cache_X%!C% = X%
- -È$ Draw_Font_Cache_Y%!C% = Y%
- -Ò$ Draw_Font_Cache_W%!C% = W%
- -Ü$ Draw_Font_Cache_H%!C% = H%
- -æ Í
- -ð_ ò_Open_Draw_Path_Object( Draw_Font_Fill%, Draw_Font_Colour%, Draw_Font_Width%, 1 << 6 )
- -ú; ò_Draw_Define_Character( C% >>> 2, X%, Y%, W%, H% )
- . ò_Close_Draw_Path_Object
- . Ì
- ., ò_Draw_Check( !(o%+Draw_Buffer%+4) )
- ." o% += Draw_Buffer%
- ., D%!0 = 2
- .6 D%!4 = o%!4
- .@ D%!24 = Draw_Font_Fill%
- .J! D%!28 = Draw_Font_Colour%
- .T D%!32 = Draw_Font_Width%
- .^! ã i%= 36 ¸ (o%!4) - 1 ⇦ 4
- .h D%!i% = o%!i%
- .r í i%
- .|D TransMatrix%!0 = (W% / (Draw_Font_Cache_W%!C%)) * (1 << 16)
- .ŷ TransMatrix%!4 = 0
- .‘ TransMatrix%!8 = 0
- .ŒD TransMatrix%!12 = (H% / (Draw_Font_Cache_H%!C%)) * (1 << 16)
- .¤6 TransMatrix%!16 = X% - (Draw_Font_Cache_X%!C%)
- .®6 TransMatrix%!20 = Y% - (Draw_Font_Cache_Y%!C%)
- .¸: È− "Draw_TransformPath", D%+40, 0, TransMatrix%, 0
- .Â1 ò_Draw_Path_Bounding_Box( D%, &7000003A )
- .Ì D% += (D%!4)
- .Ö Í
- .àá
- .ê:
- .ôH: ô Recursive routine to define character, ie insert sub-paths into
- .þE: ô buffer until character drawn. Recursive because of accents.
- /:
- /3Ý ò_Draw_Define_Character( C%, X%, Y%, W%, H% )
- /#ê Char%, x%, y%, Include%, Ptr%
- /&!ê Chunk%, Chunk_Alpha%, Char%
- /0"ê W, H, J%, K%, Flag%, Ignore%
- /:* Chunk% = 16 + ((C% Ŵ 32) << 2)
- /D& Chunk_Alpha% = ¤getofw( Chunk% )
- /NK Char% = ¤getofw( Chunk_Alpha%+((C% ◰ 32) << 2) )+ Chunk_Alpha%
- /X ç Char%=0 …
- /b1 Ŷ 1, "Character "+ Ã(C%)+ " not defined."
- /l Í
- /v :
- /€ Ï#O% = Char%
- /⇩C Flag% = Œ#O% : ô Bit 0 set if 12-bit co-ords.
- /“ ç (Flag% € 8)=0 …
- /fi5 Ŷ 1, "Character "+Ã(C%)+" is not an outline."
- /¨ Í
- /² ç (Flag% € 1)<>0 …
- /¼ x% = Œ#O%
- /Æ y% = Œ#O%
- /Ð x% += (y% € &F) << 8
- /Ú' y% = (y% >>> 4) + ((Œ#O%) << 4)
- /ä( ç x%>=&800 … x% = x% ☓ &FFFFF000
- /î( ç y%>=&800 … y% = y% ☓ &FFFFF000
- /ø J% = Œ#O% + Œ#O% + Œ#O%
- 0 Ì
- 0 x% = Œ #O%
- 0 y% = Œ #O%
- 0 ' ç x%>=&80 … x% = x% ☓ &FFFFFF00
- 0*' ç y%>=&80 … y% = y% ☓ &FFFFFF00
- 04 J% = Œ#O% + Œ#O%
- 0> Í
- 0H W = W% / Draw_Design_Size%
- 0R H = H% / Draw_Design_Size%
- 0\ J% = X% + (x% * W)
- 0f K% = Y% + (y% * H)
- 0p :
- 0z Ignore% = £
- 0☓ õ
- 0‰ Seg% = Œ#O%
- 0— ȉ (Seg% € 3) Ê
- 0¢ É 0
- 0¬" ç (Seg% € (1 << 3))<>0 …
- 0¶? Include% = Œ#O% : ô Sub-character(s) follow.
- 0À
- õ
- 0Ê Ptr% = •#O%
- 0ÔA ò_Draw_Define_Character( Include%, X%, Y%, W%, H% )
- 0Þ Ï#O% = Ptr%
- 0è Include% = Œ#O%
- 0ò ý (Include%=0)
- 0ü Seg% = 0
- 1 Í
- 1" ç (Seg% € (1 << 2))<>0 …
- 1; Ignore% = ¹ : ô Stroke path follows.
- 1$ Í
- 1. ç Seg%=0 …
- 18 ò_Draw_Check( 4 )
- 1B5 !D% = 0 : ô Close path.
- 1L D% += 4
- 1V Í
- 1`3 É 1 : ô Move to X, Y
- 1j ç ¬(Ignore%) …
- 1t ò_Draw_Check( 12 )
- 1~ !D% = 2
- 1⇦ D% += 4
- 1‹ Í
- 1†% ò_Get_Draw_Font_Coordinates
- 1¦3 É 2 : ô Line to X, Y
- 1° ç ¬(Ignore%) …
- 1º ò_Draw_Check( 12 )
- 1Ä !D% = 8
- 1Î D% += 4
- 1Ø Í
- 1â% ò_Get_Draw_Font_Coordinates
- 1ìD É 3 : ô Curve to x1,y1, x2,y2, x3,y3.
- 1ö ç ¬(Ignore%) …
- 2 ò_Draw_Check( 28 )
- 2
- !D% = 6
- 2 D% += 4
- 2 Í
- 2(% ò_Get_Draw_Font_Coordinates
- 22% ò_Get_Draw_Font_Coordinates
- 2<% ò_Get_Draw_Font_Coordinates
- 2F Ë
- 2P ý Seg%=0
- 2Zá
- 2d:
- 2nKô *********************************************************************
- 2xEô * If cache%>0 then cache every new letter drawn with this font.
- 2ŵ7ô * [If cache%>1 then read in definitions into RAM]
- 2…8ô * Sets up O%, M% for outline/metrics file handles.
- 2„4ô * Also Draw_Design_Size%, Draw_Chars_Defined%.
- 2 =ô * Also Draw_Font_Cache%[], index is ASCII code [0..255]
- 2ªJô * Draw_Font_Cache% Draw buffer offset to path object for character
- 2´.ô * Draw_Font_Cache_X% Left, in draw units
- 2¾0ô * Draw_Font_Cache_Y% Bottom, in draw units
- 2È/ô * Draw_Font_Cache_W% Width, in draw units
- 2Ò0ô * Draw_Font_Cache_H% Height, in draw units
- 2Ü:
- 2æ'Ý ò_Open_Draw_Font( font$, cache% )
- 2ðê i%
- 2ú! ç Draw_Font_Cache$<>font$ …
- 35 O% = ¤_OpenIn_Font_File( font$+ ".Outlines" )
- 3 ç O%=0 …
- 3; Ŷ 1, "Outlines not found for font '"+ font$+ "'."
- 3" Í
- 3,7 M% = ¤_OpenIn_Font_File( font$+ ".IntMetrics" )
- 36 ç M%=0 …
- 3@ Ù#O%
- 3J: Ŷ 1, "Metrics not found for font '"+ font$+ "'."
- 3T Í
- 3^ Ï#M% = 48
- 3h" Draw_Chars_Defined% = Œ#M%
- 3r Ï#O% = 6
- 3|/ Draw_Design_Size% = Œ#O% + (256 * Œ#O%)
- 3ŷ ç cache%>0 …
- 3‘2 ò_Release_Heap_Block( Draw_Font_Cache% )
- 3Œ@ ò_Claim_Heap_Block( Draw_Font_Cache%, (256 << 2) * 6 )
- 3¤/ Draw_Font_Cache_D% = Draw_Font_Cache%
- 3®8 Draw_Font_Cache_X% = Draw_Font_Cache_D% + 1024
- 3¸8 Draw_Font_Cache_Y% = Draw_Font_Cache_X% + 1024
- 3Â8 Draw_Font_Cache_W% = Draw_Font_Cache_Y% + 1024
- 3Ì8 Draw_Font_Cache_H% = Draw_Font_Cache_W% + 1024
- 3Ö' ã i%= 0 ¸ ((256 - 1) * 4) ⇦ 4
- 3à% Draw_Font_Cache_D%!i% = 0
- 3ê í i%
- 3ô Í
- 3þ Draw_Font_Cache$ = font$
- 4 Í
- 4á
- 4:
- 4&J: ô Automatically called when close DrawFile, so only needed if using
- 40+: ô more than one font in a draw file.
- 4::
- 4D Ý ò_Close_Draw_Font( font$ )
- 4N ç Draw_Font_Cache$=font$ …
- 4X ç O%>0 …
- 4b Ù#O%
- 4l O% = 0
- 4v Í
- 4€ ç M%>0 …
- 4⇩ Ù#M%
- 4“ M% = 0
- 4fi Í
- 4¨0 ò_Release_Heap_Block( Draw_Font_Cache% )
- 4² Draw_Font_Cache_D% = 0
- 4¼ Draw_Font_Cache_X% = 0
- 4Æ Draw_Font_Cache_Y% = 0
- 4Ð Draw_Font_Cache_W% = 0
- 4Ú Draw_Font_Cache_H% = 0
- 4ä Draw_Font_Cache$ = ""
- 4î Í
- 4øá
- 5:
- 5!Ý ¤_OpenIn_Font_File( file$ )
- 5ê h%
- 5 0 È− "OS_Find", &42, file$, "Font$Path" ¸ h%
- 5*= h%
- 54:
- 5>: ô
- 5H7: ô Returns width in terms of Design co-ordinates.
- 5R:
- 5\Ý ¤_Char_Width( C% )
- 5fê Map_Byte%, Width%
- 5p> ç M%=0 … Ŷ 1, "Bad call to FN_Char_Width, no font open."
- 5z Ï#M% = 52 + C%
- 5☓ Map_Byte% = Œ#M%
- 5‰C Ï#M% = 52 + 256 + (8 * Draw_Chars_Defined%) + (2 * Map_Byte%)
- 5—" Width% = Œ#M% + (256 * Œ#M%)
- 5¢9 ç (Width% € &8000)<>0 … Width% = Width% ☓ &FFFF0000
- 5¬= Width%
- 5¶:
- 5ÀJ: ô Given a character, and a nominal width of font, return Draw Units
- 5Ê: ô width of character.
- 5Ô:
- 5Þ%Ý ¤_Char_Draw_Width( C%, width% )
- 5è7= (¤_Char_Width( C% ) * width%) / Draw_Design_Size%
- 5ò:
- 5ü: ô
- 6;: ô Read a 32-bit word from outline font at offset O%.
- 6:
- 6Ý ¤getofw( A% )
- 6$ Ï#O% = A%
- 6./= Œ#O% + 256*(Œ#O% + 256*(Œ#O% + 256*Œ#O%))
- 68:
- 6BB: ô Read two 8/12-bit co-ordinates from roving outlines file.
- 6L: ô Stores in D%++.
- 6V!: ô USES Flag%, J%, K%, W, H
- 6`:
- 6j!Ý ò_Get_Draw_Font_Coordinates
- 6tê x%, y%
- 6~ ç (Flag% € 1)<>0 …
- 6⇦ x% = Œ#O%
- 6‹ y% = Œ#O%
- 6† x% += (y% € &F) << 8
- 6¦' y% = (y% >>> 4) + ((Œ#O%) << 4)
- 6°( ç x%>=&800 … x% = x% ☓ &FFFFF000
- 6º( ç y%>=&800 … y% = y% ☓ &FFFFF000
- 6Ä Ì
- 6Î x% = Œ#O%
- 6Ø y% = Œ#O%
- 6â' ç x%>=&80 … x% = x% ☓ &FFFFFF00
- 6ì' ç y%>=&80 … y% = y% ☓ &FFFFFF00
- 6ö Í
- 7 ç ¬(Ignore%) …
- 7
- !D% = J% + (x% * W)
- 7 D%!4 = K% + (y% * H)
- 7 D% += 8
- 7( Í
- 72á
- 7<:
- 7FKô *********************************************************************
- 7PKô * These calls can be used to claim temporary workspace while creating
- 7ZHô * the draw file. They should really only be called when "outside"
- 7dJô * any structure - in case future implementations can't handle memory
- 7nô * moving about.
- 7xKô * Because force callee to remember offset, can be called recursively.
- 7ŵGô * Returns an OFFSET, that can be dereferenced by FN_Draw_Address.
- 7…0ô * This has to be done over any Draw calls.
- 7„:
- 7 Jô * Store length of sub-buffr (privately) so know how far to download.
- 7ª:
- 7´&Ý ¤_Claim_Draw_Sub_Buffer( need% )
- 7¾) need% = (((need% + 3) Ŵ 4) * 4) + 4
- 7È ò_Draw_Check( need% )
- 7ÒH !D% = need% : ô Store so can download.
- 7Ü D% += need%
- 7æ'= (D% - (need% - 4)) - Draw_Buffer%
- 7ð:
- 7úÝ ¤_Draw_Address( offset% )
- 8= offset% + Draw_Buffer%
- 8:
- 8*Ý ò_Release_Draw_Sub_Buffer( Offset% )
- 8"ê i%, e%, d%, s%
- 8,( d% = ¤_Draw_Address( Offset% ) - 4
- 86 e% = d% + (!d%)
- 8@ s% = D% - e%
- 8J ç s%>0 …
- 8T ã i%= 0 ¸ (s% - 1) ⇦ 4
- 8^ d%!i%= e%!i%
- 8h í i%
- 8r Í
- 8| D% = d% + s%
- 8ŷá
- 8‘:
- 8ŒKô *********************************************************************
- 8¤:
- 8®!Ý ¤_Inches_To_Draw_Units( i )
- 8¸= i * 256 * 180
- 8Â:
- 8ÌÝ ò_Draw_Check( n_bytes% )
- 8Ö ç (D%+n_bytes%)>E% …
- 8à D% -= Draw_Buffer%
- 8ê E% -= Draw_Buffer%
- 8ôC n_bytes% = ¤_max_int( ((n_bytes% + 111) € -4), (4 * 1024) )
- 8þ5 ò_Extend_Heap_Block( Draw_Buffer%, n_bytes% )
- 9 D% += Draw_Buffer%
- 9% E% += Draw_Buffer% + n_bytes%
- 9 Í
- 9&á
- 90:
- 9:Kô *********************************************************************
- 9DDô * The following routines transform PATHS - these are the paths
- 9NJô * themselves, less the header. in% *MUST* be valid. out%=0 if want
- 9XFô * to overwrite input, otherwise points to a buffer that contains
- 9b$ô * zero, then length of buffer.
- 9l:
- 9vC: ô This is used to rotate an input path about a given origin.
- 9€:
- 9⇩8Ý ò_Draw_Rotate_Path( in%, out%, xo%, yo%, radians )
- 9“ ç (xo%<>0) ☓ (yo%<>0) …
- 9fi! !TransMatrix% = &00010000
- 9¨ TransMatrix%!4 = 0
- 9² TransMatrix%!8 = 0
- 9¼# TransMatrix%!12 = &00010000
- 9Æ TransMatrix%!16 = -xo%
- 9Ð TransMatrix%!20 = -yo%
- 9Ú9 È− "Draw_ProcessPath", in%, out%, TransMatrix%, 0
- 9ä ç out%<>0 …
- 9î in% = out%
- 9ø out% = 0
- : Í
- : Í
- :, !TransMatrix% = œ(radians) * (1 << 16)
- : - TransMatrix%!4 = µ(radians) * (1 << 16)
- :*( TransMatrix%!8 = -(TransMatrix%!4)
- :4( TransMatrix%!12 = -(!TransMatrix%)
- :> TransMatrix%!16 = xo%
- :H TransMatrix%!20 = yo%
- :R7 È− "Draw_ProcessPath", in%, out%, TransMatrix%, 0
- :\á
- :f:
- :p1: ô Shift the whole object around the plane.
- :z:
- :☓2Ý ò_Draw_Translate_Path( in%, out%, dx%, dy% )
- :‰ !TransMatrix% = &00010000
- :— TransMatrix%!4 = 0
- :¢ TransMatrix%!8 = 0
- :¬! TransMatrix%!12 = &00010000
- :¶ TransMatrix%!16 = dx%
- :À TransMatrix%!20 = dy%
- :Ê7 È− "Draw_ProcessPath", in%, out%, TransMatrix%, 0
- :Ôá
- :Þ:
- :è : ô Scale the whole object.
- :ò:
- :ü,Ý ò_Draw_Scale_Path( in%, out%, dx, dy )
- ;$ !TransMatrix% = dx * &00010000
- ; TransMatrix%!4 = 0
- ; TransMatrix%!8 = 0
- ;$& TransMatrix%!12 = dy * &00010000
- ;. TransMatrix%!16 = 0
- ;8 TransMatrix%!20 = 0
- ;B7 È− "Draw_ProcessPath", in%, out%, TransMatrix%, 0
- ;Lá
- ;V:
- ;`,: ô [D%] <-- output path of size% (>8).
- ;j:
- ;t#Ý ò_Init_Draw_Out_Path( size% )
- ;~ ò_Check( size% )
- ;⇦
- !D% = 0
- ;‹ D%!4 = size%
- ;†á
- ;¦:
- ;°Kô *********************************************************************
- ;º=ô * Given a path Object header, fill in the bounding box.
- ;Ä:
- ;Î1Ý ò_Draw_Path_Bounding_Box( h%, fill_style% )
- ;Ø. ç fill_style%=-1 … fill_style%=&7000003A
- ;âL È− "Draw_ProcessPath", h%+40, fill_style%, 0, 0, 0, 0, 0, h%+&80000008
- ;ìá
- ;ö:
- <