home *** CD-ROM | disk | FTP | other *** search
/ Old Hackers Atari User Group Newsletter / Old_Hackers_Atari_User_Group_Newsletter_OHJF92B.atr / ffontma.txt < prev    next >
Text File  |  2023-02-26  |  7KB  |  1 lines

  1.            *************¢¢    FANCY FONT DISPLAY ROUTINES¢    ---------------------------¢¢    For so long now people have been ¢after text display routines for ¢graphic modes 7 & 15. These routines ¢have been provided, but they always ¢use a block copy technique which uses ¢a standard 8 by 8 bit character set.¢¢    My routines throw away these ¢principles and allow the programmer ¢to define the individual characters ¢in terms of their image, width, ¢height and drop.¢¢Example: The word 'Tie' might be ¢displayed as follows¢¢+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+¢|X|X|X|X|X|X| |X| | | | | | | |¢+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+¢| | |X| | | | | | | | | | | | |¢+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+¢| | |X| | | | |X| | |X|X|X| | |¢+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+¢| | |X| | | | |X| |X| | | |X| |¢+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+¢| | |X| | | | |X| |X|X|X|X|X| |¢+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+¢| | |X| | | | |X| |X| | | | | |¢+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+¢| | |X| | | | |X| | |X|X|X|X| |¢+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+¢¢The accompanying data¢to go along with the¢image for the 'e' would¢be as follows:¢¢Height = 5¢Width = 6¢Drop = 2¢¢Note that the gap should¢be included in the width¢¢    This produces output which is ¢more pleasing to look at. It's ¢difficult to do justice to this with ¢words, so run the program ¢"D:EGFFDR.BAS" to see what is ¢possible.¢¢HOW TO USE THE ROUTINES FROM BASIC¢----------------------------------¢¢    For ease of use, the routines are ¢loaded upon booting the disk, the ¢program being in an AUTORUN.SYS file. ¢(Note: on the news-disk the program ¢has been called FFDR.COM. It should ¢be copied to a fresh disk and renamed ¢AUTORUN.SYS). The code is loaded ¢above DOS, then it protects itself ¢from SYSTEM RESET by altering MEMLO ¢and DOSINI addresses. The routines ¢and example font (Taken from the ST ¢game 'Paradroid 90' which inspired ¢these routines) take up ^7.5K but ¢this still leaves you with ^30K ¢available for your BASIC program.¢¢    There are 4 routines that you can ¢use. In order to do this it is best ¢that you set up the following ¢variables within your program.¢¢e.g. 10 MESSAGE=7459:REM Address¢        of Display routine vector.¢        20 SETXY=MESSAGE+3¢        30 COLOUR=SETXY+3¢        40 DRWLET=COLOUR+3¢¢    Definitions for each of these ¢routines now follow:¢¢SETXY¢-----¢¢Format : A=USR(SETXY,xpos,ypos)¢Limits : xpos between 0 and 159¢         ypos between 0 and 191¢         (for graphics mode 15)¢         ypos between 0 and 95¢         (for graphics mode 7)¢¢Desc. : this moves the current¢         printing position to the¢         coordinates (xpos,ypos).¢         Important note - a SETXY¢         must be executed before¢         any printing is done (i.e.¢         a MESSAGE or DRWLET).¢¢COLOUR¢------¢¢Format : A=USR(COLOUR,col)¢Limits : col between 0 and 3¢         (Although MC routine will¢         force any value of col to¢         be between 0 <-> 3 )¢¢Desc. : Sets the output colour as¢         follows -¢¢         0 = COLOR4 (location 712)¢             (Background)¢         1 = COLOR0 (location 708)¢         2 = COLOR1 (location 709)¢         3 = COLOR2 (location 710)¢¢DRWLET¢------¢¢Format : A=USR(DRWLET,ASC("A"))¢         A=USR(DRWLET,char)¢Limits : char between 0 and 127¢¢Desc. : Outputs the character at¢         the current screen¢         position (which is¢         updated accordingly).¢         Spaces are always drawn¢         in COLOR4, leaving the¢         background intact.¢¢MESSAGE¢-------¢¢Format : A=USR(MESSAGE,ADR(M$))¢         A=USR(MESSAGE,ADR("An¢           Example!"))¢Limits : Last character of string¢         must be inverse.¢¢Desc. : Displays the string on the¢         screen at the current x,y¢         position. The last¢         character of the string¢         must be inverse (in the¢         example the '!' is¢         inverse) in order to¢         denote the end of string¢         within the display¢         routine.¢¢ROUTINES FOR USE BY THE ASSEMBLY ¢PROGRAMMER ¢--------------------------------------¢-----¢¢    Calling protocols are different ¢within assembly language:¢¢    SETXY -> LDX xpos¢               LDY ypos¢               JSR POSITION¢¢    COLOUR -> LDA col¢               JSR SETCOL¢¢    DRWLET -> LDA char¢               JSR ONELET¢¢    MESSAGE -> LDX # >string¢               LDY # <string¢               JSR DOMSG¢               JMP skip¢              msg¢               .BYTE "An Example!"¢(Remember '!' is inverse!)¢              skip¢               ... your code ¢continues here¢¢    Assembler/Editor users must ¢remember to replace all '>' and '<' ¢symbols as follows:¢¢    # >name becomes #name/256¢    # <name becomes #name&255¢¢    If your including these routines ¢in your own program then you can ¢delete all the MEMLO initialisation ¢code (lines 1014 to 1078), otherwise ¢assemble it to an AUTORUN.SYS file ¢using the command:¢¢    ASM#D:FFDR.SRC,,#D:AUTORUN.SYS¢      - Ass/Ed¢¢    ASM#D:FFDR.M65,#-,#D:AUTORUN.SYS¢    - MAC/65¢¢N.B. MAC/65 users should first load ¢the source file using¢¢    ENTER#D:FFDR.SRC¢¢then save it in MAC/65 format using¢¢    SAVE#D:FFDR.M65¢¢The file "D:FFDR.SRC" can then be ¢deleted, saving disk space.¢¢DESIGNING YOUR OWN FONTS¢------------------------¢¢    Designing your own font is just ¢as easy as designing your own 8*8 ¢character sets. Let's go through an ¢example - a lower case 'g'¢¢        |¢+-+-+-+-+-+-+-+-+¢| | | | | | | | | ^ Drop = 2¢+-+-+-+-+-+-+-+-+ |¢| | | | | | | | | v¢+-+-+-+-+-+-+-+-+¢| |X|X|X| | | | | = $3F00 ^¢+-+-+-+-+-+-+-+-+ |¢|X| | | |X| | | | = $C0C0 |¢+-+-+-+-+-+-+-+-+ |¢|X| | | |X| | | | = $C0C0 |¢+-+-+-+-+-+-+-+-+ |¢| |X|X|X|X| | | | = $3FC0 |*¢+-+-+-+-+-+-+-+-+ |¢| | | | |X| | | | = $00C0 |¢+-+-+-+-+-+-+-+-+ |¢|X| | | |X| | | | = $C0C0 |¢+-+-+-+-+-+-+-+-+ |¢| |X|X|X| | | | | = $3F00 v¢+-+-+-+-+-+-+-+-+¢        |¢¢                    (*Height=7)¢¢<---------> Width = 6 (Remember¢               to include gap!)¢¢    Remember too that in mode 7 & 15, ¢each pixel is two bits wide, giving ¢four possible colours. So define the ¢character for colour 3, i.e. both ¢bits set per pixel, as the ¢draw_letter routine simply AND'S it ¢with the current colour mask to ¢produce the right colour. This is ¢also why the image is two bytes wide, ¢to allow for characters with widths ¢up to 8 pixels wide.¢    The data image is stored in the ¢source listing as follows:¢¢1000 LG¢1002 .DBYTE ¢$3F00,$C0C0,$C0C0,$3FC0,$00C0,$C0C0,$3¢F00¢¢    All the characters are referenced ¢in the character table (see CHRTAB - ¢line 1574). This is best left alone, ¢and you should use the same labels ¢for your images.¢    All that's left to do is to store ¢the height, width and drop ¢information in the correct positions ¢in the relevant tables. So for our ¢example:¢¢ Height = 7, Width = 6, Drop = 2¢¢    These are stored in position 4 of ¢lines 1656, 1686 and 1716 ¢respectively, corresponding to the LG ¢entry in CHRTAB.¢¢    Hope that's enough for you to be ¢able to do your own thing, if you ¢have any queries, or just want to ¢discuss programming on the 8-bit ¢Atari, then write to:¢¢ Mark Keates,¢ 24 Hayes Mead,¢ Meadowcroft,¢ Holbury,¢ Southampton,¢ Hampshire,¢ S04 1JZ,¢ England.¢¢Enjoy!¢¢(This article was re-formatted and ¢edited by Dean Garraghty.), and¢reprinted by THE OL' HACKERS ATARI¢USERS GROUP, INC., WITH THANKS TO BOTH!¢¢       +-+-+-+-+- END -+-+-+-+-+¢