Announcement

Collapse
No announcement yet.

Values for POKE?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Values for POKE?

    What values do I give poke for:

    Poking a letter to the screen (a through z)?
    Saving variables to disk using poke? (poking memory areas to disk)

    Thanks.

    Paul


    ------------------
    Few cats act their age, while
    most just cough up furballs.
    Few cats act their age, while
    most just cough up furballs.

  • #2
    You poke the ASCII values to the screen page. The page is located at segment &H0B800 for VGA and &H0B000 for mono, so using the internal variable pbvscrnbuff pointer value simplies the task of working out what the address should be.

    The text-mode screen (SCREEN 0) is arranged thus:
    Byte 0: Ascii code of the letter to display at column 1, row 1
    Byte 1: color attribute of the character at column 1, row 1
    Byte 2: Ascii code of the letter to display at column 2, row 1
    Byte 3: color attribute of the character at column 2, row 1
    ...etc.

    Here is a quick example:
    Code:
    cls
    def seg = pbvscrnbuff \ &H10000
    for x% = 1 to 26
      poke x% * 2 - 2, 64 + x%
    next x%
    def seg
    Finally, I'm not sure what you mean about "poking to disk" - I guess you mean save variables to disk by peeking at their location in memory?

    That would be done something like this (using both 32-bit pointers and seg/offet methods):
    Code:
    ' pseudocode
    DIM ps AS LONG PTR, x AS LONG
    x  = 999
    ps = VARPTR32(x)
    OPEN "file.dat" FOR OUTPUT AS #1
    ' Write it as a "text" value, ie "999"
    PRINT #1, @ps ' use the pointer target
     
    ' Or we could write it as 4 byte binary value (same as MKL$):
    DEF SEG = VARSEG(x)
    PRINT #1, PEEK$(VARPTR(x), LEN(x)) 
    DEF SEG
    CLOSE #1
    Is that what you mean? If not, can you please rephrase the question a little. Thanks!

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment

    Working...
    X