Advertisement
Ham62

GetFont.bas

Mar 5th, 2016
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 1.45 KB | None | 0 0
  1. '$INCLUDE: 'QBX.BI'
  2. DIM InRegs AS RegTypeX, OutRegs AS RegTypeX
  3. DIM FontPtr AS LONG, BytePtr AS LONG
  4. DEFINT A-Z
  5. SCREEN 13
  6.  
  7. 'INT 10h function AX=1130h will return a pointer to a font table
  8. 'BH=3 is the table for 8x8 base characters (0-127)
  9. 'BH=4 is the table for 8x8 extended characters (128-255)
  10.  
  11. InRegs.ax = &H1130: InRegs.bx = &H300
  12. CALL InterruptX(&H10, InRegs, OutRegs)
  13.  
  14. 'On Return:
  15. '  CX = bytes per character of on-screen font (not requested font)
  16. '  DL = rows (less 1)
  17. '  ES:BP = pointer to table
  18.  
  19. LOCATE 2
  20. PRINT "Bytes per character: " + HEX$(OutRegs.CX)
  21. PRINT "Rows per character: " + HEX$(OutRegs.DX + 1)
  22. PRINT "Font table at address: " + HEX$(OutRegs.ES) + ":" + HEX$(OutRegs.BP)
  23.  
  24. DEF SEG = OutRegs.ES: FontPtr = OutRegs.BP
  25.  
  26. DIM FontTable(7, 127) AS STRING * 1
  27.  
  28. TestString$ = "AaBbCc1234$"
  29. StrPtr& = SADD(TestString$)
  30.  
  31. FOR CharNum = 0 TO LEN(TestString$) - 1
  32.     DEF SEG = SSEG(TestString$)
  33.     Char = PEEK(StrPtr& + CharNum)
  34.     PRINT CHR$(Char)
  35.     BytePtr = FontPtr + (Char * 127)
  36.     FOR ByteNum = 0 TO 8
  37.         DEF SEG = OutRegs.ES
  38.         Byte = PEEK(BytePtr + ByteNum)
  39.         PSET (X + 0, Y), Byte AND 1
  40.         PSET (X + 1, Y), (Byte AND 2) \ 2 'WHY NO SHR :(
  41.         PSET (X + 2, Y), (Byte AND 4) \ 4
  42.         PSET (X + 3, Y), (Byte AND 8) \ 5
  43.         PSET (X + 4, Y), (Byte AND 16) \ 16
  44.         PSET (X + 5, Y), (Byte AND 32) \ 32
  45.         PSET (X + 6, Y), (Byte AND 64) \ 64
  46.         PSET (X + 7, Y), (Byte AND 128) \ 128
  47.         Y = Y + 1
  48.     NEXT ByteNum
  49.     Y = 0: X = X + 8
  50.     SLEEP
  51. NEXT CharNum
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement