Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!oliveb!pyramid!uccba!hal!cwruecmp!bammi From: bammi@cwruecmp.UUCP Newsgroups: comp.sys.atari.st Subject: Re: String.c (really fontload.tos) Message-ID: <2150@cwruecmp.UUCP> Date: Fri, 12-Jun-87 02:02:33 EDT Article-I.D.: cwruecmp.2150 Posted: Fri Jun 12 02:02:33 1987 Date-Received: Sat, 13-Jun-87 19:48:30 EDT References: <8705271729.AA20883@ucbvax.Berkeley.EDU> <1102@viper.Lynx.MN.ORG> Reply-To: bammi@cwruecmp.UUCP (Jwahar R. Bammi) Distribution: world Organization: Case Western Reserve University Lines: 672 In article <1102@viper.Lynx.MN.ORG> john@viper.UUCP (John Stanley) writes: >In <8705271729.AA20883@ucbvax.Berkeley.EDU> >RDROYA01@ULKYVX.BITNET (Robert Royar) asks: > > > >2. Does anyone have a TOS-based font loader? I'd like something that will > >reset the default font and will allow the new font to be used by TOS-based > >programs. Is this impossible? It seems all that would be needed would be > >to load a new font, reset the old pointers (via linea), and Ptrmres(). > > Here is one that i did (in three parts). It lets you load and use a Gdos font with Bconout()/Putchar etc. The Gdos font has to be mono-spaced and 8 wide. It can be any height. A sample Gdos font is included. BTW - in case anyone is interested, i wrote a little vfont (see man 5 vfont) to Gdos font converter (handles fixed width fonts only at present time), and will be glad to mail it to anyone interested. Using this, and another PD Mac utility that goes Mac->vfont, you can get all the nice PD Mac fonts in Gdos format. It handles Sun's fixed width fonts too. usenet: {decvax,cbosgd,sun}!cwruecmp!bammi jwahar r. bammi csnet: bammi@cwru.edu <---------Please note change of address arpa: bammi@cwru.edu <---------Please note change of address compuServe: 71515,155 -- ------------------cut here ------- TOS font switcher part 1 of 3 ---------- #!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # afona.uue # alglobal.c # compiler.h # init.c # makefile # makefile.alc # switchf.c # This archive created: Fri Jun 12 01:44:15 1987 # By: Jwahar R. Bammi(Case Western Reserve University) # Uucp: {decvax,sun,cbosgd}!cwruecmp!bammi # Csnet: bammi@cwru.edu # Arpa: bammi@cwru.edu # export PATH; PATH=/bin:$PATH echo shar: extracting "'afona.uue'" '(2646 characters)' if test -f 'afona.uue' then echo shar: over-writing existing file "'afona.uue'" fi sed 's/^X//' << \SHAR_EOF > 'afona.uue' Xtable X !"#$%&'()*+,-./0123456789:;<=>? X@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ Xbegin 644 afont.fnt XM6@ 0 $%&3TY44RXQ- ( !^ ! #0 *a XM ( ( @ 0 ! $ 0!55555 !8 6 !@! !@ ! a XM" 0 !@ ( H # . ! $@ 4 !8 & : !P '@ @ "( ) F "@ *@ L "Xa XM , R #0 -@ X #H / ^ 0@!$ $8 2 !* $P 3@!0 %( 5 !6 %@ 6@!a XM< %X 8 !B &0 9@!H &H ; !N ' <@!T '8 > !Z 'P ?@! (( A "& (@a XM B@", (X D "2 )0 E@"8 )H G "> * H@"D *8 J "J *P K@"P +( M "a XMV +@ N@"\ +X @ a XM a XM ( !" $ a XM /$ \ a XM ."' ()"0(,!@$"! (<"#P<##X,a XM?CP\ " $ \& (" $ 0 & a XM!@ . & (!& X ! 0" @ ()"0^2"0$$ @( (Ba XM&$(B%" P0D)& $ "!B)#A\&GQ_?QIW/C]S<(.'''X!QW/CAS?^?B.'@X a XM a X1 H a X a Xend SHAR_EOF if test 2646 -ne "`wc -c 'afona.uue'`" then echo shar: error transmitting "'afona.uue'" '(should have been 2646 characters)' fi echo shar: extracting "'alglobal.c'" '(920 characters)' if test -f 'alglobal.c' then echo shar: over-writing existing file "'alglobal.c'" fi sed 's/^X//' << \SHAR_EOF > 'alglobal.c' X X /***********************************************\ X * * X * alglobal.c * X * Global variables for C interface * X * declared here. Extern eveywhere else. * X * * X * J.R. Bammi * X * decvax!cwruecmp!bammi * X * bammi%cwru.edu.ARPA * X * bammi@cwru.edi.CSNET * X * CIS: 71515,155 * X * * X \***********************************************/ X X X#define ALGLOBAL X X#include "aline.h" X X XLINEA *aline; /* Pointer to line a parameter block returned by init */ X XNLINEA *naline; /* Pointer to line a parameters at negative offsets */ X XFONT **fonts; /* Array of pointers to the three system font headers */ X /* returned by init (in register A1) */ X XWORD (**funcs)(); /* Array of pointers to the 15 line a functions */ X /* returned by init (in register A2) */ X /* only valid in ROM'ed TOS */ SHAR_EOF if test 920 -ne "`wc -c 'alglobal.c'`" then echo shar: error transmitting "'alglobal.c'" '(should have been 920 characters)' fi echo shar: extracting "'compiler.h'" '(1647 characters)' if test -f 'compiler.h' then echo shar: over-writing existing file "'compiler.h'" fi sed 's/^X//' << \SHAR_EOF > 'compiler.h' X X /***********************************************\ X * * X * compiler.h * X * Compiler dependent defines * X * * X * J.R. Bammi * X * decvax!cwruecmp!bammi * X * bammi@cwru.edu.ARPA * X * bammi@cwru.edu.CSNET * X * CIS: 71515,155 * X * * X \***********************************************/ X X /* X * Assumptions: X * Type 'long' == 32 bit integer X * Type 'char' == 8 bit integer X * X * Compiler Dependant defines: X * Type 'WORD' == 16 bit signed int X * Type 'UWORD' == 16 bit unsigned int X * Type 'VOID' == nothing X */ X X/* X * Define one of the following X */ X/* #define ALCYON */ X/* #define MEGAMAX */ X/* #define LATTICE */ X/* #define MWC */ X X X/************************** The rest 'should' be ok **************************/ X X X/* X * Alcyon C X */ X#ifdef ALCYON X Xtypedef int WORD; Xtypedef unsigned int UWORD; X#define VOID void /* can't typedef void in alcyon (bug) */ X X#endif /* ALCYON */ X X X/* X * Megamax C X */ X#ifdef MEGAMAX X Xtypedef int WORD; Xtypedef unsigned UWORD; /* Check this */ Xtypedef int VOID; /* yech !! */ X X#endif /* MEGAMAX */ X X/* X * Lattice C X * I don't have a copy so ...... X */ X#ifdef LATTICE X Xtypedef short WORD; Xtypedef unsigned short UWORD; /* Is'nt lattice braindamaged like Megamax, X * in that it defines unsigned as a type X * instead of a type modifier ?? if so X * unsigned short is incorrect, and i X * don't know what it should be! X */ Xtypedef void VOID; /* what should this be ?? */ X X#endif /* LATTICE */ X X/* X * Mark Williams C X */ X#ifdef MWC X Xtypedef int WORD; Xtypedef unsigned int UWORD; Xtypedef void VOID; X X#endif /* MWC */ SHAR_EOF if test 1647 -ne "`wc -c 'compiler.h'`" then echo shar: error transmitting "'compiler.h'" '(should have been 1647 characters)' fi echo shar: extracting "'init.c'" '(1352 characters)' if test -f 'init.c' then echo shar: over-writing existing file "'init.c'" fi sed 's/^X//' << \SHAR_EOF > 'init.c' X /***********************************************\ X * * X * init.h * X * Common file for C interface * X * to low level Line A calls * X * * X * J.R. Bammi * X * decvax!cwruecmp!bammi * X * bammi%cwru.edu.CSNET * X * bammi@cwru.edu.ARPA * X * CIS: 71515,155 * X * * X \***********************************************/ X X#include "aline.h" X X /* A L C Y O N */ X#ifdef ALCYON XVOID init_aline() X{ X asm(".dc.w $a000"); /* Line A Init */ X asm("move.l a0, _aline"); /* Address of param block */ X asm("move.l a1, _fonts"); /* Array of system font headers */ X asm("move.l a2, _funcs"); /* Pointers to line a functions */ X X naline = ((NLINEA *)aline) - 1; /* Pointer to negative offset parms */ X X} X#endif /* ALCYON */ X X /* M A R K W I L L I A M S */ X#ifdef MWC X#include X XVOID init_aline() X{ X linea0(); X aline = (LINEA *)(la_init.li_a0); X fonts = (FONT **)(la_init.li_a1); X funcs = la_init.li_a2; X naline = ((NLINEA *)aline) - 1; X} X X#endif /* MWC */ X X X /* M E G A M A X */ X /* CAUTION --- NOT TESTED */ X#ifdef MEGAMAX Xinit_aline() X{ X asm X { X dc.w 0XA000 X movea.l A0,aline X movea.l A1,fonts X movea.l A2,funcs X } X naline = ((NLINEA *)aline) - 1; X} X#endif /* MEGAMAX */ X X#ifdef LATTICE X /* Someone fill this in */ X#endif /* LATTICE */ X X/** EOF **/ SHAR_EOF if test 1352 -ne "`wc -c 'init.c'`" then echo shar: error transmitting "'init.c'" '(should have been 1352 characters)' fi echo shar: extracting "'makefile'" '(244 characters)' if test -f 'makefile' then echo shar: over-writing existing file "'makefile'" fi sed 's/^X//' << \SHAR_EOF > 'makefile' X# X# Test out switchf.c X# MWC version X# XCFLAGS = -O -V -DMWC -DTEST X Xswitchf.prg : switchf.o alglobal.o init.o X cc -o switchf.prg switchf.o init.o alglobal.o -s -V -x X Xswitchf.o alglobal.o init.o : aline.h compiler.h X Xclean: X rm *.o switchf.prg SHAR_EOF if test 244 -ne "`wc -c 'makefile'`" then echo shar: error transmitting "'makefile'" '(should have been 244 characters)' fi echo shar: extracting "'makefile.alc'" '(495 characters)' if test -f 'makefile.alc' then echo shar: over-writing existing file "'makefile.alc'" fi sed 's/^X//' << \SHAR_EOF > 'makefile.alc' X# X# Test out switchf.c X# Alcyon version (V2.14 required) X# for 'make' as distributed to this net. X# X# Include directory XINCLUDE = c:\include X# Library XLIB = c:\lib X# LINKER XLINKER = c:\bin\lo68.prg X XCPFLAGS = -i $(INCLUDE)\ -DALCYON -DTEST X Xswitchf.prg : switchf.o alglobal.o init.o X $(LINKER) -r -s -o switchf.68k $(LIB)\gemstart.o switchf.o \ Xalglobal.o init.o $(LIB)\gemlib $(LIB)\libf X $(RELMOD) switchf X Xswitchf.o alglobal.o init.o : aline.h compiler.h X Xclean: X $(RM) *.o *.68k switchf.prg SHAR_EOF if test 495 -ne "`wc -c 'makefile.alc'`" then echo shar: error transmitting "'makefile.alc'" '(should have been 495 characters)' fi echo shar: extracting "'switchf.c'" '(5497 characters)' if test -f 'switchf.c' then echo shar: over-writing existing file "'switchf.c'" fi sed 's/^X//' << \SHAR_EOF > 'switchf.c' X X /***************************************\ X * * X * switchf.c * X * Gdos-less Gdos font switcher * X * soon to appear in Gulam, Xmdm * X * and Zmdm * X * * X * Jwahar R. Bammi * X * {decvax,cbosgd,sun}!cwruecmp!bammi * X * CSnet,Arpa: bammi@cwru.edu * X * CIS: 71515,155 * X * * X \***************************************/ X X X#include X#include "aline.h" X X#define SCREENFONT 2 /* index of 8x16 monochrome system default font */ X X /* Possible Errors */ X#define ENO_ERROR 0 /* No error */ X#define EOPEN_FAIL 1 /* Error opening font file */ X#define EHEAD_READ 2 /* Error reading font header */ X#define EFORM_READ 3 /* Error reading font form */ X#define EOFF_READ 4 /* Error reading offset table */ X#define EMEMORY 5 /* Outa memory */ X X /* Globals */ XFONT *system_font; /* pointer to default system font */ Xint ferr; /* error # if any */ X X X/* X * Init aline & get system font pointer X */ Xinit() X{ X init_aline(); X system_font = fonts[SCREENFONT]; /* save it */ X} X X/* X * Switch to given Gdos font (pointer) X * Acknowledgements to X * Martin Minow X * minow%thundr.dec@decwrl.dec.com X * decvax!minow X * for discovering the info in the routine below. thanks! X */ Xswitch_font(fp) XFONT *fp; X{ X /* See aline.h for description of fields */ X X naline->V_CEL_HT = fp->form_height; X naline->V_CEL_WR = aline->VWRAP * fp->form_height; X naline->V_CEL_MY = (naline->V_Y_MAX / fp->form_height) - 1; X naline->V_CEL_MX = (naline->V_X_MAX / fp->max_cell_width) - 1; X naline->V_FNT_WR = fp->form_width; X naline->V_FNT_ST = fp->first_ade; X naline->V_FNT_ND = fp->last_ade; X naline->V_OFF_AD = fp->off_table; X naline->V_FNT_AD = fp->dat_table; X} X X/* X * Swap bytes of a word X */ Xstatic VOID Swap(p) Xunsigned char p[]; X{ X register unsigned char t; X X t = p[0]; X p[0] = p[1]; X p[1] = t; X X} X X X/* X * Swap all entries in Intel format to MC68K format WORDs X * X */ Xstatic VOID fix_font(font) Xregister FONT *font; X{ X X Swap(&font->font_id); X Swap(&font->size); X Swap(&font->first_ade); X Swap(&font->last_ade); X Swap(&font->top); X Swap(&font->ascent); X Swap(&font->half); X Swap(&font->descent); X Swap(&font->bottom); X Swap(&font->max_char_width); X Swap(&font->max_cell_width); X Swap(&font->left_offset); X Swap(&font->right_offset); X Swap(&font->thicken); X Swap(&font->ul_size); X Swap(&font->lighten); X Swap(&font->skew); X Swap(&font->flags); X Swap(&font->form_width); X Swap(&font->form_height); X X /* init only */ X font->h_table = (char *)NULL; X font->next_font = (FONT *)NULL; X} X X X X/* X * Load a font, return font pointer X * On error: ferr contains error # and pointer returned is NULL X */ XFONT *load_font(name) Xchar *name; X{ X register WORD i,j; X register FONT *font; X WORD *otable; X WORD ndata, nchar; X FILE *fp; X extern char *malloc(); X#ifdef ALCYON X extern FILE *fopenb(); X#else X extern FILE *fopen(); X#endif X X ferr = ENO_ERROR; X X /* open it up */ X#ifdef ALCYON X if((fp = fopenb(name, "r")) == (FILE *)NULL) X#else X if((fp = fopen(name, "rb")) == (FILE *)NULL) X#endif X { X ferr = EOPEN_FAIL; X return (FONT *)NULL; X } X X /* alloc font header */ X if((font = (FONT *)malloc(sizeof(FONT))) == (FONT *)NULL) X { X ferr = EMEMORY; X return (FONT *)NULL; X } X X if(fread(font, sizeof(FONT), 1, fp) != 1) X { X ferr = EHEAD_READ; X return (FONT *)NULL; X } X X /* Fix WORD fields and init */ X fix_font(font); X X /* alloc offset table */ X nchar = font->last_ade - font->first_ade + 1; /* # of chars in font */ X /* all we are doing here is if first_ade is > 30, we are makeing X * first_ade = 0, by adding 30 entries before first_ade and X * moving first_ade to 0, otherwise Bconout([2,5],X) will not X * work (they bomb) - Yet Another Undocumented 'Feature' :-) X */ X X /* add one for the last offset */ X i = (((nchar+30) < 256)? nchar+30 : nchar + (256 - nchar)) + 1; X if((font->off_table = (WORD *)malloc(i*2)) == (WORD *)NULL) X { X ferr = EMEMORY; X return (FONT *)NULL; X } X /* init it */ X for(j = 0; j < i; j++) X font->off_table[j] = 0; X X otable = ((nchar+30) < 256)? &font->off_table[30] : X &font->off_table[(256-nchar)]; X font->first_ade = 0; X X /* alloc font form table */ X ndata = font->form_width * font->form_height; /* bytes in font form */ X if((font->dat_table = malloc(ndata)) == (char *)NULL) X { X ferr = EMEMORY; X return (FONT *)NULL; X } X X /* read in offset table */ X if(fread(otable, 2, nchar, fp) != nchar) X { X ferr = EOFF_READ; X return (FONT *)NULL; X } X /* swap WORDs */ X for(i = 0; i <= nchar; i++) X Swap(&otable[i]); X X /* read in font form */ X if(fread(font->dat_table, 1, ndata, fp) != ndata) X { X ferr = EFORM_READ; X return (FONT *)NULL; X } X fclose(fp); X X /* and finally return the pointer to font header */ X return font; X} X X/* X * free up a loaded font X */ XVOID free_font(font) XFONT *font; X{ X free(font->dat_table); X free(font->off_table); X free(font); X} X X#ifdef TEST X/* X * load and show fonts X * X */ Xmain(argc, argv) XWORD argc; Xchar **argv; X{ X register WORD i, j; X register FONT *font_ptr; X extern FONT *load_font(); X X if(argc < 2) X { X fprintf(stderr,"Usage: switchf fontfiles ....\n"); X exit(1); X } X X init(); X while(--argc > 0) X { X if((font_ptr = load_font(*++argv)) == (FONT *)NULL) X fprintf(stderr,"Trouble Loading %s\n", *argv); X else X { X fprintf(stderr,"\n%s:\n", *argv); X switch_font(font_ptr); X for(j = 0, i = ' '; i < font_ptr->last_ade; i++) X { X putchar(i); X if((++j%8) == 0) X putchar('\n'); X else X putchar('\t'); X } X putchar('\n'); X free(font_ptr); X switch_font(system_font); X } X } X exit(0); X} X X#endif SHAR_EOF if test 5497 -ne "`wc -c 'switchf.c'`" then echo shar: error transmitting "'switchf.c'" '(should have been 5497 characters)' fi # End of shell archive exit 0 -- usenet: {decvax,cbosgd,sun}!cwruecmp!bammi jwahar r. bammi csnet: bammi@cwru.edu <---------Please note change of address arpa: bammi@cwru.edu <---------Please note change of address compuServe: 71515,155