Author Topic: Changing the BIOS font.  (Read 3398 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Changing the BIOS font.
« on: August 12, 2020, 09:43:30 pm »
Many moons ago Galleon set me up with a way to change the BIOS font to a custom one.
With the loss of .NET this is a copy I have been using in the game I was cloning at the time "Reaping the Dungeon"
The font was created with "FONT by Davey W Taylor" from WAY BACK! (I think it can be found in the A.B.C. archive).

Charset.h  must be placed in the QB64 folder
 
Code: QB64: [Select]
  1. DECLARE LIBRARY "charset"
  2.  SUB Charset_8x8 (BYVAL o AS _OFFSET)
  3.  SUB Charset_8x16 (BYVAL o AS _OFFSET)
  4. DIM SHARED c16(7, 15, 255) AS _UNSIGNED _BYTE, charload AS _UNSIGNED _BYTE
  5.  
  6. 'Usage:
  7. Load_BIOS_Font "yourfontfile.fnt"
  8. Charset_8x16 _OFFSET(c16(0, 0, 0))
  9.  
  10.  
  11. SUB Load_BIOS_Font (Font$)
  12.  OPEN Font$ FOR BINARY AS #1
  13.  FOR c% = 0 TO 255
  14.   FOR y% = 0 TO 15
  15.    GET #1, , charload
  16.    FOR x% = 0 TO 7
  17.     IF _READBIT(charload, x%) THEN c16(7 - x%, y%, c%) = 1 'any non-0 value should work
  18.    NEXT
  19.   NEXT
  20.  CLOSE #1
  21.  
  22.  

Font Edit V1.0 (c. 1995?) By Davey W. Taylor
Code: QB64: [Select]
  1. DECLARE SUB char (ch%, sx%, sy%)
  2. DECLARE FUNCTION getXY! (c%, x%, y%)
  3. DIM SHARED fot(255) AS STRING * 16
  4. xp% = 1: yp% = 1
  5. cb$ = STRING$(16, 0)
  6. Show:
  7. SCREEN 7, , 1, 1
  8. COLOR 4, 0
  9. PRINT "FONT EDIT v1.0 by Davey W Taylor"
  10. LOCATE 25, 1: PRINT "Press 'H' for help";
  11. LINE ((xp% - 1) * 10, (yp% * 20))-(9 + (xp% - 1) * 10, 17 + (yp% * 20)), 15, B
  12. ch% = 0
  13. FOR y% = 1 TO 8
  14.  FOR x% = 1 TO 32
  15.   sx% = (x% - 1) * 10
  16.   sy% = y% * 20
  17.   ch% = ch% + 1
  18.   char ch%, sx%, sy%
  19.  NEXT x%
  20. NEXT y%
  21. ml:
  22.  in$ = INKEY$
  23.  SELECT CASE in$
  24.   CASE "h", "H"
  25.    SCREEN 7, , 0, 0
  26.    CLS
  27.    COLOR 15, 0
  28.    PRINT "Keys:"
  29.    PRINT " Left/Right/Up/Down - Change character"
  30.    PRINT " ENTER - Edit character"
  31.    PRINT " L - Load font"
  32.    PRINT " S - Save font"
  33.    PRINT " ESC - Quit"
  34.    PRINT
  35.    PRINT "Press any key"
  36.    DO: LOOP UNTIL INKEY$ <> ""
  37.    SCREEN 7, , 1, 1
  38.   CASE CHR$(0) + "K" 'Lt
  39.    LINE ((xp% - 1) * 10, (yp% * 20))-(9 + (xp% - 1) * 10, 17 + (yp% * 20)), 0, B
  40.    IF xp% > 1 THEN xp% = xp% - 1
  41.    LINE ((xp% - 1) * 10, (yp% * 20))-(9 + (xp% - 1) * 10, 17 + (yp% * 20)), 15, B
  42.   CASE CHR$(0) + "M" 'Rt
  43.    LINE ((xp% - 1) * 10, (yp% * 20))-(9 + (xp% - 1) * 10, 17 + (yp% * 20)), 0, B
  44.    IF xp% < 32 THEN xp% = xp% + 1
  45.    LINE ((xp% - 1) * 10, (yp% * 20))-(9 + (xp% - 1) * 10, 17 + (yp% * 20)), 15, B
  46.   CASE CHR$(0) + "H" 'Up
  47.    LINE ((xp% - 1) * 10, (yp% * 20))-(9 + (xp% - 1) * 10, 17 + (yp% * 20)), 0, B
  48.    IF yp% > 1 THEN yp% = yp% - 1
  49.    LINE ((xp% - 1) * 10, (yp% * 20))-(9 + (xp% - 1) * 10, 17 + (yp% * 20)), 15, B
  50.   CASE CHR$(0) + "P" 'Dn
  51.    LINE ((xp% - 1) * 10, (yp% * 20))-(9 + (xp% - 1) * 10, 17 + (yp% * 20)), 0, B
  52.    IF yp% < 8 THEN yp% = yp% + 1
  53.    LINE ((xp% - 1) * 10, (yp% * 20))-(9 + (xp% - 1) * 10, 17 + (yp% * 20)), 15, B
  54.   CASE "l", "L"
  55.    SCREEN 7, , 0, 0
  56.    CLS
  57.    COLOR 15, 0
  58.    PRINT "Load font-file: ";
  59.    LINE INPUT "", f$
  60.    ON ERROR GOTO nofile
  61.    OPEN f$ FOR INPUT AS #1
  62.    IF LOF(1) = 256 * 16 THEN er% = 0 ELSE er% = 1
  63.    CLOSE #1
  64.    ON ERROR GOTO 0
  65.    IF er% THEN
  66.     PRINT "A font-file must be exactly 256 * 16 bytes long!"
  67.     DO: LOOP UNTIL INKEY$ <> ""
  68.     SCREEN 7, , 1, 1
  69.     GOTO ml
  70.    END IF
  71.     FOR ch% = 0 TO 255
  72.      GET #1, , fot(ch%)
  73.     NEXT ch%
  74.    CLOSE #1
  75.    GOTO Show
  76.   CASE "s", "S"
  77.    SCREEN 7, , 0, 0
  78.    CLS
  79.    COLOR 15, 0
  80.    PRINT "Save font-file: ";
  81.    LINE INPUT "", f$
  82.    chf% = 0
  83.    ON ERROR GOTO fc
  84.    OPEN f$ FOR INPUT AS #1
  85.    CLOSE #1
  86.    ON ERROR GOTO 0
  87.    IF chf% = 0 THEN
  88.     PRINT "File exists, overwrite? ";
  89.     DO: in$ = UCASE$(INKEY$): LOOP UNTIL in$ = "Y" OR in$ = "N"
  90.     IF in$ = "N" THEN
  91.      SCREEN 7, , 1, 1
  92.      GOTO ml
  93.     END IF
  94.    END IF
  95.    ON ERROR GOTO diskfull
  96.    OPEN f$ FOR OUTPUT AS #1
  97.    CLOSE #1
  98.     FOR n% = 0 TO 255
  99.      PUT #1, , fot(n%)
  100.     NEXT n%
  101.    CLOSE #1
  102.    ON ERROR GOTO 0
  103.    SCREEN 7, , 1, 1
  104.   CASE CHR$(13)
  105.    SCREEN 7, , 0, 0
  106.    CLS
  107.    ch% = (xp% - 1) + (32 * (yp% - 1))
  108.    xe% = 1: ye% = 1
  109. upd:
  110.    FOR y% = 1 TO 16
  111.     FOR x% = 1 TO 8
  112.      xs% = 1 + (x% - 1) * 10
  113.      ys% = 1 + (y% - 1) * 10
  114.      IF getXY(ch%, x%, y%) THEN
  115.       LINE (xs%, ys%)-(xs% + 8, ys% + 8), 14, BF
  116.      ELSE
  117.       LINE (xs%, ys%)-(xs% + 8, ys% + 8), 1, BF
  118.      END IF
  119.     NEXT x%
  120.    NEXT y%
  121.    LOCATE 1, 15: PRINT "up/dn/lt/rt - move cursor"
  122.    LOCATE 2, 15: PRINT "space - toggle pixel"
  123.    LOCATE 3, 15: PRINT "enter - when done"
  124.    LOCATE 4, 15: PRINT "H - flip horizontal"
  125.    LOCATE 5, 15: PRINT "V - flip vertical"
  126.    LOCATE 6, 15: PRINT "I - invert"
  127.    LOCATE 7, 15: PRINT "C - copy"
  128.    LOCATE 8, 15: PRINT "P - paste"
  129.    LOCATE 9, 15: PRINT "X - clear"
  130.    LINE ((xe% - 1) * 10, (ye% - 1) * 10)-(10 + (xe% - 1) * 10, 10 + (ye% - 1) * 10), 12, B
  131.    DO
  132.     in$ = INKEY$
  133.     SELECT CASE in$
  134.      CASE CHR$(0) + "K" 'Lt
  135.       LINE ((xe% - 1) * 10, (ye% - 1) * 10)-(10 + (xe% - 1) * 10, 10 + (ye% - 1) * 10), 0, B
  136.       IF xe% > 1 THEN xe% = xe% - 1
  137.       LINE ((xe% - 1) * 10, (ye% - 1) * 10)-(10 + (xe% - 1) * 10, 10 + (ye% - 1) * 10), 12, B
  138.      CASE CHR$(0) + "M" 'Rt                                
  139.       LINE ((xe% - 1) * 10, (ye% - 1) * 10)-(10 + (xe% - 1) * 10, 10 + (ye% - 1) * 10), 0, B
  140.       IF xe% < 8 THEN xe% = xe% + 1
  141.       LINE ((xe% - 1) * 10, (ye% - 1) * 10)-(10 + (xe% - 1) * 10, 10 + (ye% - 1) * 10), 12, B
  142.      CASE CHR$(0) + "H" 'Up
  143.       LINE ((xe% - 1) * 10, (ye% - 1) * 10)-(10 + (xe% - 1) * 10, 10 + (ye% - 1) * 10), 0, B
  144.       IF ye% > 1 THEN ye% = ye% - 1
  145.       LINE ((xe% - 1) * 10, (ye% - 1) * 10)-(10 + (xe% - 1) * 10, 10 + (ye% - 1) * 10), 12, B
  146.      CASE CHR$(0) + "P" 'Dn
  147.       LINE ((xe% - 1) * 10, (ye% - 1) * 10)-(10 + (xe% - 1) * 10, 10 + (ye% - 1) * 10), 0, B
  148.       IF ye% < 16 THEN ye% = ye% + 1
  149.       LINE ((xe% - 1) * 10, (ye% - 1) * 10)-(10 + (xe% - 1) * 10, 10 + (ye% - 1) * 10), 12, B
  150.      CASE " "
  151.       xv% = 2 ^ (8 - xe%)
  152.       IF getXY(ch%, xe%, ye%) THEN
  153.        MID$(fot(ch%), ye%, 1) = CHR$(ASC(MID$(fot(ch%), ye%, 1)) - xv%)
  154.       ELSE
  155.        MID$(fot(ch%), ye%, 1) = CHR$(ASC(MID$(fot(ch%), ye%, 1)) + xv%)
  156.       END IF
  157.       xs% = 1 + (xe% - 1) * 10
  158.       ys% = 1 + (ye% - 1) * 10
  159.       IF getXY(ch%, xe%, ye%) THEN
  160.        LINE (xs%, ys%)-(xs% + 8, ys% + 8), 14, BF
  161.       ELSE
  162.        LINE (xs%, ys%)-(xs% + 8, ys% + 8), 1, BF
  163.       END IF
  164.      CASE "v", "V"
  165.       v$ = fot(ch%)
  166.       FOR n% = 1 TO 16
  167.        MID$(fot(ch%), n%, 1) = MID$(v$, 17 - n%, 1)
  168.       NEXT n%
  169.       GOTO upd
  170.      CASE "h", "H"
  171.       v$ = STRING$(16, 0)
  172.       FOR y% = 1 TO 16
  173.        FOR x% = 1 TO 8
  174.         xv% = 2 ^ (x% - 1)
  175.         IF getXY(ch%, x%, y%) THEN
  176.          MID$(v$, y%, 1) = CHR$(ASC(MID$(v$, y%, 1)) + xv%)
  177.         END IF
  178.        NEXT x%
  179.       NEXT y%
  180.       fot(ch%) = v$
  181.       GOTO upd
  182.      CASE "i", "I"
  183.       v$ = fot(ch%)
  184.       FOR n% = 1 TO 16
  185.        MID$(fot(ch%), n%, 1) = CHR$(255 - ASC(MID$(v$, n%, 1)))
  186.       NEXT n%
  187.       GOTO upd
  188.      CASE "c", "C"
  189.       cb$ = fot(ch%)
  190.      CASE "p", "P"
  191.       fot(ch%) = cb$
  192.       GOTO upd
  193.      CASE "x", "X"
  194.       fot(ch%) = STRING$(16, 0)
  195.       GOTO upd
  196.     END SELECT
  197.    LOOP UNTIL in$ = CHR$(13)
  198.    SCREEN 7, , 1, 1
  199.    sx% = (xp% - 1) * 10
  200.    sy% = yp% * 20
  201.    char ch% + 1, sx%, sy%
  202.   CASE CHR$(27)
  203.    SCREEN 7, , 0, 0
  204.    CLS
  205.    COLOR 15, 0
  206.    PRINT "Save your work first? ";
  207.    DO: in$ = UCASE$(INKEY$): LOOP UNTIL in$ = "N" OR in$ = "Y"
  208.    IF in$ = "Y" THEN
  209.     PRINT "Y"
  210.     PRINT "Save font-file: ";
  211.     LINE INPUT "", f$
  212.     chf% = 0
  213.     ON ERROR GOTO fc
  214.     OPEN f$ FOR INPUT AS #1
  215.     CLOSE #1
  216.     ON ERROR GOTO 0
  217.     IF chf% = 0 THEN
  218.      PRINT "File exists, overwrite? ";
  219.      DO: in$ = UCASE$(INKEY$): LOOP UNTIL in$ = "Y" OR in$ = "N"
  220.      IF in$ = "N" THEN
  221.       SCREEN 7, , 1, 1
  222.       GOTO ml
  223.      END IF
  224.     END IF
  225.     ON ERROR GOTO diskfull
  226.     OPEN f$ FOR OUTPUT AS #1
  227.     CLOSE #1
  228.      FOR n% = 0 TO 255
  229.       PUT #1, , fot(n%)
  230.      NEXT n%
  231.     CLOSE #1
  232.     ON ERROR GOTO 0
  233.    END IF
  234.    END
  235. nofile:
  236.  CLOSE #1
  237.  PRINT "Can't find file!"
  238.  DO: LOOP UNTIL INKEY$ <> ""
  239.  SCREEN 7, , 1, 1
  240.  RESUME ml
  241. fc:
  242.  hm% = ERR
  243.   CASE 76, 75, 64, 52
  244.    PRINT "Invalid filename!"
  245.    DO: LOOP UNTIL INKEY$ <> ""
  246.    SCREEN 7, , 1, 1
  247.    RESUME ml
  248.    chf% = 1
  249. diskfull:
  250.  CLOSE #1
  251.  PRINT "The disk is full!"
  252.  DO: LOOP UNTIL INKEY$ <> ""
  253.  SCREEN 7, , 1, 1
  254.  RESUME ml
  255.  
  256. SUB char (ch%, sx%, sy%)
  257.  FOR uy% = 1 TO 16
  258.   x% = ASC(MID$(fot(ch% - 1), uy%, 1))
  259.   x% = 256 * (x% + (256 * (x% > 127)))
  260.   LINE (sx% + 1, sy% + uy%)-(sx% + 8, sy% + uy%), 1
  261.   LINE (sx% + 1, sy% + uy%)-(sx% + 8, sy% + uy%), 14, , x%
  262.  NEXT uy%
  263.  
  264. FUNCTION getXY (c%, x%, y%)
  265. xv% = 2 ^ (8 - x%)
  266. B% = ASC(MID$(fot(c%), y%, 1))
  267. getXY = SGN(B% AND xv%)
  268.  
  269.  
* charset.h (Filesize: 0.26 KB, Downloads: 170)
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Changing the BIOS font.
« Reply #1 on: August 12, 2020, 09:53:44 pm »
Thanks for sharing, Cobalt.