Qbasicnews.com

Full Version: Bottom row in text modes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
The last row, where you can't print anything, where the QB message "Press any key" is displayed.

Is there a way to use it? As in, can I display text there, and how do I do it?
Simple, add a semi-colon to the PRINT.

Like this:
Code:
LOCATE 25, 1
PRINT "Hello";
What Neo wrote is true, however you might want to make sure that, if you're using a VIEW PRINT statement, row 25 is included. Otherwise, you can add all the semi- colons you want, and it won't help at all. Big Grin Semi-colons are used to keep what's on the screen at row 25 from scrolling up.(Unless of course, you program it to.)
This is the best solution, it's faster then PRINT and more easily used, for textmode only tho.

Code:
DEFINT A-Z
SUB TextPrint (St$, X, Y, C, Bg)

DEF SEG = &HB800
Offset = (X * 2) + (Y * 160)

FOR I = 1 TO LEN(St$)
     Pntr = Pntr + 2
     POKE Offset + Pntr, ASC(MID$(St$, I, 1))
     POKE Offset + Pntr + 1, Bg * 16 + C
NEXT

END SUB
Quote:Simple, add a semi-colon to the PRINT.

Like this:
Code:
LOCATE 25, 1
PRINT "Hello";
Neo's solution is the simplest.
As dadsherm said the semicolon prevents the normal scroll-up which occurs after a Print command. If you didn't use the semicolon, the "Hello" would end up on line 24 after the scroll-up.

Dadsherm, you're probably right about the View Print, but I don't think he will be using that right now.

BinaryShock, even though your solution probably works, it goes right over the head of most of us. You might a well have posted a solution in assembly language.
*****
I've added some comments to Binary's code (I hope that's okay).
Code:
DEFINT A-Z
SUB TextPrint (St$, X, Y, C, Bg)
'Input: St$: the text to be displayed
'       X  : The column of the first character
'       Y  : The row of the first character
'       C  : The color of the text
'       Bg : The background color

DEF SEG = &HB800                                  ' Set segment address for text mode
Offset = (X * 2) + (Y * 160)                      ' Address of the first character - 2 bytes

FOR I = 1 TO LEN(St$)
     Pntr = Pntr + 2                              ' Bytes from Offset to address of current character
     POKE Offset + Pntr, ASC(MID$(St$, I, 1))     ' POKE the current character
     POKE Offset + Pntr + 1, Bg * 16 + C          ' POKE the color for the character
NEXT

END SUB
If I've made any mistakes, please let me know.

[suggestion] It seems to me that this could be a little more efficient using just Offset (or Pntr) rather than both Offset and Pntr.
Code:
Offset = (X * 2) + (Y * 160)

FOR I = 1 TO LEN(St$)
     Offset = Offset + 2
     POKE Offset, ASC(MID$(St$, I, 1))
     POKE Offset + 1, Bg * 16 + C
NEXT
[/suggestion]
Binary's code works, and it is quite faster than PRINT :lol:

I fixed the offset to

But this isn't quite what I wanted, I want to disable the "Press any key to continue" message. If possible.
Code:
' Simple hack to disable the "Press Any Key" message
' (works with QBasic 1.x, QB 4.5, PDS 7.1, and VBDOS)
'
' by Plasma

DEFINT A-Z
DECLARE SUB PressAnyKey (Enabled)

CONST DISABLE = 0
CONST ENABLE = NOT DISABLE

' disable the "Press Any Key" message.
PressAnyKey DISABLE

' or, if you want to enable it:
' PressAnyKey ENABLE

CLS
LOCATE 25, 25
PRINT "Is this what you want to do?";

k$ = INPUT$(1)  'if you don't pause the program
                'it will return immediately to the IDE

SUB PressAnyKey (Enabled)

  DefSeg& = VARSEG(DefSeg$)
  FOR Segment& = DefSeg& TO 0 STEP -&H400
    DEF SEG = Segment&
    FOR i = 1 TO &H3FFF - 20
      IF PEEK(i) = &H6 AND PEEK(i + 3) = &H3 AND PEEK(i + 4) = &H75 THEN
      IF PEEK(i + 5) = &H40 AND PEEK(i + 6) = &H8B AND PEEK(i + 7) = &H16 THEN
      IF PEEK(i + 10) = &H52 AND PEEK(i + 11) = &HA1 AND PEEK(i + 14) = &H50 THEN
      IF PEEK(i + 15) = &H3A AND PEEK(i + 16) = &HE0 AND PEEK(i + 17) = &H74 THEN
      IF PEEK(i + 18) = &H7 AND PEEK(i + 19) = &H88 AND PEEK(i + 20) = &H26 THEN
        IF NOT Enabled THEN
          POKE (i - 1), &HCB
        ELSE
          POKE (i - 1), &HF6
        END IF
        EXIT SUB
      END IF
      END IF
      END IF
      END IF
      END IF
    NEXT
  NEXT

END SUB
Yup, exactly what i wanted :lol:

Thanx a lot, and btw, you can add QB 7.1 to the working list.

Plasma do you want your names in the Credits section of Novix? Novix dev. page

And Binary, did you write the text poke thing? If so, do you want to be in the credits?

Novix=Fake OS built in QB, dev. time spent: 1.5yrs+
PDS 7.1 = QB 7.1

Sure, my name in lights would be cool Smile
Pages: 1 2