h63241
s 00002/00002/00083
d D 1.3 83/02/03 15:54:35 mjb 3 2
c fixed common name collision
e
s 00030/00017/00055
d D 1.2 83/01/20 21:00:28 tes 2 1
c Added LRU for last character read to increase performance
e
s 00072/00000/00000
d D 1.1 83/01/20 10:46:26 tes 1 0
c date and time created 83/01/20 10:46:26 by tes
e
u
tes
mjb
U
t
T
I 1
D 2
integer function hshrec (font, ichr, out)
E 2
I 2
integer function hshrec (font, ichr)
E 2

#  Access new font table format
# 	hshrec - loads an int array with the graphic record
#       for a particular character in a particular font

D 2
integer font, ichr, out(1)
E 2
I 2
integer font, ichr
E 2

integer i, upe64w, charno, stemp
integer nwords,nwds,temp
integer sector, offset
integer gdseek, gdread

include(`hshcom')

nwords = -1
D 2
if (hfile >= 0) {
   if (font >= 0 & font < nfonts) {
      if (font != cfont) {
E 2
I 2
if (hfile >= 0) {                  # Insure the hershy file is currently open
   if (font >= 0 & font < nfonts) {   # Insure the requested font is in range
D 3
      if (font != cfont) {            # See if font table is already in memory
E 3
I 3
      if (font != chfont) {            # See if font table is already in memory
E 3
E 2

	 # read the font definition
I 2
         #    the font table contains specific font information, such as
	 #    character scale, width, base line offset, and disk file offset
	 #    to each character definition
E 2

         temp = fdpos + font*FONTxDESCRIPTION
         sector = temp/128
         offset = temp - (temp/128)*128
         temp = gdseek (hfile, sector, offset)
         temp = gdread (hfile, fnttbl, FONTxDESCRIPTION)
D 3
	 cfont = font
E 3
I 3
	 chfont = font
E 3
	 i = upe64w (fnttbl(1), cfscal, cfbase)
	 i = upe64w (fnttbl(2), cftop, cfwdth)
I 2

	 # reset last character register
	 lstchr = 0
E 2
	 }
D 2
      charno = fnttbl(ichr+FONTxJUNK)
E 2
I 2
      charno = fnttbl(ichr+FONTxJUNK)   # get disk file offset for character
E 2
      }
   else {
      charno = -font
      }
D 2
   if (charno > 0) {
      temp = cdpos + charno
      sector = temp/128
      offset = temp - (temp/128)*128
      temp = gdseek (hfile, sector, offset)
      temp = gdread (hfile, stemp, 2 )
E 2
I 2
   if (charno > 0) {    # check for legal character offset
      if (lstchr != charno) {   # see if the character definition is already in
         temp = cdpos + charno  #    memory, if not read the character 
         sector = temp/128      #    definition into memory
         offset = temp - (temp/128)*128
         temp = gdseek (hfile, sector, offset)
         temp = gdread (hfile, stemp, 2 )
E 2

D 2
      out(1) = stemp
      nwds = stemp - (stemp/256)*256
      nwords = nwds + 1;
      temp = gdread (hfile, out(2), nwds*2)
E 2
I 2
         chrbuf(1) = stemp
         nwds = stemp - (stemp/256)*256
         temp = gdread (hfile, chrbuf(2), nwds*2)
	 lstchr = charno
	 }
      else {
	 stemp = chrbuf(1)   # get the character definition length from last
	 nwds = stemp - (stemp/256)*256   # buffer and return its value
	 }
      nwords = nwds + 1
E 2
      }
   }

D 2
return (nwords)
E 2
I 2
return (nwords)   # return the number of words in the definition
E 2
end
integer function upe64w (word, top, bottom)
integer word, top, bottom

integer movdrw, w

w = word
if (w < 0) {
   movdrw = 1

   #   obtain the unsigned integer by adding 32768, assuming a 16 bit integer
   w = 16384 + w + 16384
   }
else {
   movdrw = 0
   }
top = ((w/128) - 128) - 64
bottom = (w - (w/128)*128) - 64

return (movdrw)
end
E 1
