More silly fun: I always loved the different fonts and wanted to use the Beagle Bros fonts from Apple Mechanic which are shape tables. So I wrote a shape table interpreter. It's not fully complete in that it doesn't do scale and rot, but it can write the text to the screen.


function iif(a,b,c) if a then return b else return c end end 
function bool10(a) return iif(a,1,0) end

function bin(x,numbits,gap) if x==nil then return nil end gap=gap or "_" numbits=numbits or 8 str="" for i=numbits-1,0,-1 do str=str..iif((x&(2^i))~=0,"1","0")..iif((i%8==0) and (i>0),gap,"") end return str end

function hex(a,digits,prefix) digits=digits or 2 prefix=prefix or "" if a==nil then return nil end return string.format(prefix.."%0"..digits.."x",a) end
function hexx(a,digits,prefix) prefix=prefix or "0x" return hex(a,digits,"0x") end
function hexpair(a,b) return "("..hex(a)..","..hex(b)..")" end

function max(a,b) if a>b then return a else return b end end 
function min(a,b) if a<b then return a else return b end end
function round(x) if x<0 then return math.floor(x-0.5) else return math.floor (x+0.5) end end

function calc(line,page) if line<0 then line = 0 end if line > 191 then line=191 end page=page or 0 return line % 8 * 1024 + math.floor(line / 64) * 40 + math.floor((line%64) / 8) * 128 + 8192* (page + 1) end

function calcyaddr(line,page) return calc(line,page) end

function plot(x,y,page) page=page or 0 x = max(0,x) x = min(x,279) y = max(0,y) y = min(y,191) mem=applemem() mem:write_u8(calcyaddr(y,page)+math.floor(x/7),mem:read_u8(calcyaddr(y,page)+math.floor(x/7))|(1<<(x%7))) end

function applemem() return manager:machine().devices[":maincpu"].spaces["program"] end

function getbits(a,lobit,hibit) local retval=0 for bit=lobit,hibit do retval=retval|((1<<bit)&a) end return retval end

function getbitsshift(a,lobit,hibit) return getbits(a,lobit,hibit)>>lobit end


function stuckcheck(stucklimit)
if stuck==nil then stuck =0 end
stucklimit=stucklimit or stuckmax
if stuck > stucklimit then print("STUCK hit loop "..stucklimit.."times") stuck=nil gonnamakeanerror() end

function getdrawcmd(a,cmdindex) return getbitsshift(a,cmdindex*3,cmdindex*3+2) end

function drawshapetable(a,shapenum,xpos,ypos)
local bytepos=2*shapenum+1
if printdebugshapetable then print("drawshapetable shapenum="..shapenum) end
if a:byte(1) < shapenum then 
   if  printdebugshapetable then print ("only have "..a:byte(1).." shapes!  shapenum="..shapenum) end 
   return xpos,ypos end
if printdebugshapetable then print(string.rep("-",80)) end
while true do
stuckcheck()  -- stop those pesky infinite loops while debugging things, an infinite loop will hang mame
local b=a:byte(bytepos)
local drawcmd={}
for i=0,2 do
  if b==0 or b==nil then return xpos,ypos end
for i=0,2 do
  local dirbits=getbitsshift(drawcmd[i+1],0,1)
  local plotbit=getbitsshift(drawcmd[i+1],2,2)
  local skip=false
  if i==1 and drawcmd[2]==0 and drawcmd[3]==0 then skip=true end -- if second and third are zero, ignore
  if i==2 and dirbits==0 then skip=true end -- 00 in last command (can't go up in final command)
  if printdebugshapetable then  print("bytepos="..hex(bytepos),"byte="..hex(b),"binary="..bin(b),i+1,bin(drawcmd[i+1],3),"PLOT="..plotbit,"DIR="..dirbits.."  "..dir.." "..iif(skip,"<SKIP>","")..iif(plotbit==1," plot","")) end
  if skip then break end
  if plotbit == 1 then plot(xpos,ypos) end --plot before moving
if printdebugshapetable then print(string.rep("=",80)) end
end -- while
end -- drawshapetable

-- we can just draw the character and ignore the return ypos if we don't want to draw shape #99 between characters

function drawshapetext(a,thisstr,x,y,spacing,xclip,height) for i=1,#thisstr do if thisstr:byte(i)==string.byte("\n") then if x~=0 then x,y=0,y+height end else x=drawshapetable(a,thisstr:byte(i)-32+1,x,y) x=x+spacing if x>xclip then x,y=0,y+height end end end return x,y end

-- Beagle Bros shape table fonts, draw shape #99 between characters to return to baseline and add space

function drawshapetext99(a,thisstr,x,y,spacing,xclip,height) for i=1,#thisstr do if thisstr:byte(i)==string.byte("\n") then if x ~= 0 then x,y=0,y+height end else x,y=drawshapetable(a,thisstr:byte(i)-32+1,x,y) x,y=drawshapetable(a,99,x,y) if x>xclip then x,y=0,y+height end end end return x,y end

printdebugshapetable = true

It's kinda neat to see how the shapes were put together:
drawshapetable shapenum=99
bytepos=10a5	byte=40	binary=01000000	1	000	PLOT=0	DIR=0  up 
bytepos=10a5	byte=40	binary=01000000	2	000	PLOT=0	DIR=0  up 
bytepos=10a5	byte=40	binary=01000000	3	001	PLOT=0	DIR=1  right 
bytepos=10ac	byte=08	binary=00001000	1	000	PLOT=0	DIR=0  up 
bytepos=10ac	byte=08	binary=00001000	2	001	PLOT=0	DIR=1  right 
bytepos=10ac	byte=08	binary=00001000	3	000	PLOT=0	DIR=0  up <SKIP>

[Linked Image]

loaddisk("../../apple_mechanic_typefaces.dsk") hgr() hgrfull() hgrclr() a=getfile("]COMPUTE") drawshapetext99(a,"I'm gonna download and compile mame! ...and compile mame!\nI'm going to live like modern hardware doesn't exist! it doesn't exist!\nI'm gonna fly like a 6502 in the night!\nFeel the artifacts on my eyes",0,0,0,260,18)

[Linked Image]