Announcement

Collapse
No announcement yet.

Save Screen Contents

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

    Save Screen Contents

    This is how I save the entire screen to disk for a 40x80 display

    OldX% = pos(0) : OldY% = csrlin : OldColor% = pbvscrntxtattr
    DEF SEG = &hB800 : BSAVE "SCREEN.TMP", 0, 4000 : DEF SEG

    Then to restore the screen

    CT% = OldColor% and 15 : cb% = OldColor% \ 16
    color CT%, cb% : locate OldY%, OldX%
    DEF SEG = &hB800 : BLOAD "SCREEN.TMP" : DEF SEG


    What would be the values if the screen mode was 43 or 50 lines.

    How is the screen data structured ?

    I need to save a portion of the screen and I know that within the 4000 bytes, the character and the colour is stored.


    #2
    Check out Qsave() and Qrest() in ScrnUnit.bas that comes
    with PB 3.5. Routines allow any portion of the screen to
    be saved/restored.

    SUB QSAVE(BYVAL Row AS INTEGER, BYVAL Col AS INTEGER, _
    BYVAL Rows AS INTEGER, BYVAL Cols AS INTEGER, _
    Where AS INTEGER) PUBLIC

    For example, to save 25,80:
    dim n(2000) as integer
    call qsave(1,1,25,80,n(1))
    To restore full screen:
    call qrest(1,1,25,80,n(1))

    To save/rest rows 2-4, cols 11-15
    call qsave(2,11,3,5,n(1))
    call qrest(2,11,3,5,n(1))

    As to how the screen data is structured, it's been awhile
    since I got into this, but if I remember correctly, the lower
    8 bits contain the ascii character, the upper 8 bits contain
    the color.

    Dennis


    ------------------

    Comment


      #3
      Steve,
      Sorry for first response. I missed the opening sentence
      referring to disk write.
      Denny


      ------------------

      Comment


        #4
        BSAVE stores data with no translation. There's a brief header which contains information such as a BSAVE "signature" and the original data segment. After that, it's just the actual data bytes. In the case of a text screen, this would be sequential bytes starting from the upper left corner of the screen and going column by column, wrapping for each row, until the end of the screen. Screen data is stored as character/color combinations, where the first byte is the ASCII character and the second byte is the color/attribute of that character on the screen. If you need information about color/attribute encoding, I can dig that up.

        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment


          #5
          Saving screen contents to disk

          Have you considered DIM ABSOLUTE? I don't know what "40x80" is, but for an 80x25 screen (SCREEN 0) on a CGA, try:

          TYPE ScreenLineType
          ScreenLine AS STRING * 160 ' 80-character line x 2 bytes per character
          END TYPE

          DIM ABSOLUTE ScreenPage0(1:25) AS ScreenLineType AT &HB800

          OPEN "SCRNPIC.DAT" FOR RANDOM AS #1, LEN = 160

          FOR I? = 1? TO 25?
          PUT #1, I?, ScreenPage0(I?)
          NEXT I?

          This will write the line exactly as it is stored in the video buffer. You could write a SUB if all you want are the ASCII characters in the line. For a 43- or 50-line display, you just have to change the 25 and &HB800 to whatever you need.

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎