Qbasicnews.com
April 09, 2020, 05:19:52 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Making new text.  (Read 1313 times)
prof_flex
Member
*
Posts: 37


« on: June 03, 2003, 03:21:07 PM »

Ive seen the code for it, but i still dont understand how it works, anyone up for suggestions? I wanna make a game with my own text
Logged

LA BLA BLA
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #1 on: June 03, 2003, 03:45:43 PM »

Well, if you mean to do it in a graphics mode, see if this helps.



'
'  This program demonstrates how to change the font in a QB graphics
' video mode.  (It changes a character of your choosing to a box.)
'
'$INCLUDE: 'QB.BI'
DIM CHAR(1 TO 1024) AS LONG, SM AS INTEGER, OS AS INTEGER, I AS INTEGER
DIM BYTE AS INTEGER, VS AS INTEGER, INREGS AS REGTYPEX, OUTREGS AS REGTYPEX
DIM MODE AS INTEGER, NBYTES AS INTEGER, SMORG AS INTEGER, OSORG AS INTEGER
DIM SMORG1 AS INTEGER, OSORG1 AS INTEGER
'
'  Get location in memory of where font data is to go.
'
SM = VARSEG(CHAR(1)): OS = VARPTR(CHAR(1))
'
'  Get video mode to use.
'
MODE = 0
WHILE MODE < 1 OR (MODE > 2 AND MODE < 7) OR MODE > 13
INPUT "WHAT QB GRAPHICS MODE DO YOU WANT"; MODE
WEND
SCREEN MODE
'
'  Get character size.
'
DEF SEG = 0
VS = PEEK(&H485)
'
'  If this routine doesn't work for you, print out the value of VS just
' obtained.  If it's 14, uncomment the following line of code and see if
' that helps.  (Some video boards require it.)
'
'IF VS = 14 THEN VS = 16
'
'  Find out where font data is.
'
INREGS.AX = &H3543
CALL INTERRUPTX(&H21, INREGS, OUTREGS)
'
'  Save IVT data.
'
SMORG = OUTREGS.ES: OSORG = OUTREGS.BX
'
'  Read font data from video area and write it to array.
'
NBYTES = VS * 256
IF MODE < 7 THEN NBYTES = NBYTES / 2
FOR I = 0 TO NBYTES - 1
DEF SEG = OUTREGS.ES
BYTE = PEEK(I + OUTREGS.BX)
DEF SEG = SM
POKE I + OS, BYTE
NEXT I
'
'  If MODE < 7, font data for ascii values > 127 are located elsewhere.
'
IF MODE < 7 THEN
INREGS.AX = &H351F
CALL INTERRUPTX(&H21, INREGS, OUTREGS)
SMORG1 = OUTREGS.ES: OSORG1 = OUTREGS.BX
FOR I = NBYTES TO 2 * NBYTES - 1
DEF SEG = OUTREGS.ES
BYTE = PEEK(I - NBYTES + OUTREGS.BX)
DEF SEG = SM
POKE I + OS, BYTE
NEXT I
END IF
'
'  Ask for what character is to be changed to box and get its ascii
' value.
'
LINE INPUT "WHAT CHARACTER DO YOU WANT TO CHANGE TO BOX?"; UCHAR$
ASCII = ASC(UCHAR$)
'
'  Change UCHAR$ font to box.  Note that (255 decimal = 11111111 binary
' and 129 decimal = 10000001 binary.)
'
OS = ASCII * VS + OS
'
'  Write top byte.
'
POKE OS, 255
OS = OS + 1
'
'  Write side bytes.
'
FOR I = 1 TO VS - 2
POKE OS, 129
OS = OS + 1
NEXT I
'
'  Write bottom byte.
'
POKE OS, 255
DEF SEG
'
'  Clear screen and write original character.
'
CLS
PRINT UCHAR$
'
'  Change interrupt vector to memory location of array.
'
INREGS.DX = VARPTR(CHAR(1))
IF MODE > 6 THEN
INREGS.AX = &H2543
ELSE
INREGS.AX = &H251F
INREGS.DX = INREGS.DX + NBYTES
END IF
INREGS.DS = SM
CALL INTERRUPTX(&H21, INREGS, OUTREGS)
'
'  Display UCHAR$ again and see how it's changed.
'
PRINT UCHAR$
'
'  Pause program.
'
WHILE INKEY$ = "": WEND
'
'  Restore original interrupt vectors.
'
INREGS.AX = &H2543
INREGS.DS = SMORG
INREGS.DX = OSORG
CALL INTERRUPTX(&H21, INREGS, OUTREGS)
IF MODE < 7 THEN
INREGS.AX = &H251F
INREGS.DS = SMORG1
INREGS.DX = OSORG1
CALL INTERRUPTX(&H21, INREGS, OUTREGS)
END IF
END
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!