Announcement

Collapse
No announcement yet.

PB3.1/3.5 screen output: Direct to video card or through BIOS?

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

  • PB3.1/3.5 screen output: Direct to video card or through BIOS?

    When a compiled PB 3.1/3.5 program generates screen content (either text or graphics), does it write directly to the video (VGA) card memory, or does it use only the bios routines?

  • #2
    If that's not in your help file or manual you should probably address that question directly to PB support.

    "Unofficially" (AFAIK) when the output is text, the compiler writes directly to video memory.
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      THere's a good write up on this somewhere, may still be archived on this board - and I've got some source at home that will allow you tochange the interrupt, allow direct access to the video card etc.

      But I believe it goes through the interrupt/bios and then on to the video card, and the reason I believe this is that I had somecode to write direct TO the video card...

      See if I can dig that up tonight.....
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        Did you mean this?
        Code:
        DEF SEG = &HB800
        POKE 0,65 'Put an A in the top left corner
        POKE 1,1 'Colour it blue
        DEF SEG
        LATER:

        How to use it, for instance?
        Assume there is a user input routine on line 25, at the first character position. So you locate the caret there: "LOCATE 25, 1". But what the user is typing should re-appear on line 4, 20th character position. It's not recommended to use "LOCATE 4, 20" now, because it will cause the caret moving away from the input routine. Better write it directly to the screen, using DEF SEG.

        Note that each line counts 160 offsets. The even offsets (0 through 158 - step 2) for the character, the odd offsets (1 through 159 - step 2) for the color attribute. Also note that the first offset pair for line 2 is 160/161, for line 3: 320/321, for line 4: 480/481 et cetera. So the correct offset for line 4, 20th character can be set as follows:
        Code:
        POKE (4-1)*160 + (20-1)*2, ASCII code
        POKE (4-1)*160 + (20-1)*2 + 1, color attribute
        I remember I wrote such a routine in 1996, but cannot find it. So, I'ved tried to make myself clear without that source. Hope it helps.
        Last edited by Egbert Zijlema; 5 Nov 2008, 04:42 PM.

        Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
        http://zijlema.basicguru.eu
        *** Opinions expressed here are not necessarily untrue ***

        Comment


        • #5
          Yep that's it - I will dig out my code when time permits, HOPEFULLY tonight - I don't keep PB Dos code at work....

          I think I have your library - if so I will post it back for you
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment


          • #6
            Originally posted by Scott Turchin View Post
            (...)
            I think I have your library - if so I will post it back for you
            That would be very nice! I'm looking forward. Once my DOS collection has been re-completed (how shall I ever know?) I will make the files available on my website. I just re-installed PBDOS 3.5 to be able to test my old code.
            Last edited by Egbert Zijlema; 13 Nov 2008, 04:40 AM.

            Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
            http://zijlema.basicguru.eu
            *** Opinions expressed here are not necessarily untrue ***

            Comment


            • #7
              Just extracted some old PBDOS direct screen write routines from DOS project circa 2000

              These are not compilable as is, but they may be of interest as you can have 10 virtual screens.

              Use them as you like.




              Code:
              PB3.5
              
              
                      'Text Screen Constants
                   %Sc_lines=50
                   %Sc_size=%Sc_lines * 160
                   %Sc_Max=10 
              
                DIM VIRTUAL SaveScreen(1:%Sc_Max) AS SHARED STRING*%Sc_size
              
                      %Mgray=8
                      %Dblue=1
                      %Dgreen=2
                      %Dturq=3
                      %Dred=4
                      %Dviolet=5
                      %Gold=6
                      %Black=7
                      %Dgray=8
                      %Pblue=9
                      %Lgreen=10
                      %Pyellow=11
                      %Lred=12
                      %Magneta=13
                      %Yellow=14
                      %White=15
              
                      %Normhue=%Dgray
                      %Tithue =%Dgreen
                      %Hothue =%Dred
                      %Curhue =%Yellow+16*%Dgray
                      %Dimhue =%White
                      %Edhue  =%Lred
                      %Texthue=%Dviolet
                      %Goldhue=%Gold
              
              
                      ' ************** SCREEN FUNCTIONS
              
                      DECLARE FUNCTION SETONEXIT%(BYVAL DWORD )
                      SETONEXIT CODEPTR32(Resetscreen)
                      Setscreen
              
                      SUB Blink(BYVAL Q??)
                          IF Q?? THEN Q??=1
                          ! mov ax,&h1003
                          ! mov bx,Q??
                          ! int &h10
                      END SUB
              
                      FUNCTION Getpalette$
                          LOCAL Q$,Sseg??,Sptr??
                          Q$=SPACE$(17)
                          Sseg??=STRSEG(Q$)
                          Sptr??=STRPTR(Q$)
                          ! PUSH DS
                          ! MOV AX,&H1009
                          ! MOV ES,Sseg??
                          ! MOV DX,Sptr??
                          ! INT &H10
                          ! POP DS
                          FUNCTION=Q$
                      END FUNCTION
              
                      SUB Setpalette(BYVAL Q$)
                          LOCAL Sseg??,Sptr??
                          Sseg??=STRSEG(Q$)
                          Sptr??=STRPTR(Q$)
                          ! PUSH DS
                          ! MOV AX,&H1002
                          ! MOV ES,Sseg??
                          ! MOV DX,Sptr??
                          ! INT &H10
                          ! POP DS
                      END SUB
              
                      SUB Readdac(BYVAL Q?,R?,G?,B?)
                          ! PUSH DS
                          ! PUSH SI
                          ! MOV AX,&H1015
                          ! MOV BX,Q?
                          ! INT &H10
                          ! LDS SI,R?
                          ! MOV DS:[SI],DH
                          ! LDS SI,G?
                          ! MOV DS:[SI],CH
                          ! LDS SI,B?
                          ! MOV DS:[SI],CL
                          ! POP SI
                          ! POP DS
                      END SUB
              
                      SUB Setdac(BYVAL Q?,BYVAL R?,BYVAL G?,BYVAL B?)
                          ! PUSH DS
                          ! MOV BX,Q?
                          ! MOV DH,R?
                          ! MOV CH,G?
                          ! MOV CL,B?
                          ! MOV AX,&H1010
                          ! INT &H10
                          ! POP DS
                      END SUB
              
                      SUB Setscreen
                          WIDTH ,%Sc_lines
                          Dopalette 1
                          Blink 0
                      END SUB
              
                      SUB Resetscreen
                          Dopalette 0
                          WIDTH ,25
                          Blink 1
                      END SUB
              
                      SUB Dopalette(BYVAL Q?)
                          STATIC Dospal$
                          SELECT CASE Q?
                          CASE 0
                            Setpalette Dospal$
              
                          CASE 1
                            Dospal$=Getpalette$
                            
                            Setpalette CHR$(7,1,16,3,4,40,20,0, _
                                            56,57,58,55,39,32,62,63,8)
              
                          CASE 2
                            Setpalette CHR$(7,1,16,3,4,40,20,0, _
                                            56,57,58,55,39,32,62,63,8)
                          END SELECT
              
                      END SUB
              
              
              '   Screen functions
              
              
                 FUNCTION Doscreen(BYVAL Mode?,BYVAL Page?)
                     SHARED SaveScreen(),Screenstat$,Screenaddress???
                     IF Screenstat$="" THEN  Screenstat$=STRING$(%Sc_Max,0)
                     IF Screenaddress???=0 THEN
                        Screenaddress???=PBVSCRNBUFF
                        SHIFT RIGHT Screenaddress???,16
                     END IF
                     DEF SEG = Screenaddress???
                     SELECT CASE Mode?
                     CASE 0   ' Clearscreen
                        IF Page?>0 THEN
                           SaveScreen(Page?)=REPEAT$(%Sc_size/2,CHR$(32,0))
                        ELSE
                           Screenstat$=STRING$(%Sc_Max,0)
                        END IF
                     CASE 1   ' Store screen Page?
                        IF Page?=0 THEN Page?=INSTR(Screenstat$,CHR$(0))
                        IF Page?>0 THEN
                           ASC(Screenstat$,Page?)=1
                           SaveScreen(Page?)=PEEK$(0,%Sc_size)
                        END IF
                     CASE 2   '
                         IF Page?=0 THEN
                            Page?=INSTR(Screenstat$+CHR$(0),CHR$(0))-1
                            IF Page?>0 THEN
                               Poke$ 0,SaveScreen(Page?)
                               ASC(Screenstat$,Page?)=0
                            END IF
                         ELSE
                            Poke$ 0,SaveScreen(Page?)
                         END IF
                     END SELECT
                     DEF SEG
                     FUNCTION=Page?
                 END FUNCTION
              
                 FUNCTION Pushscreen
                     FUNCTION=Doscreen(1,0)
                 END FUNCTION
              
                 FUNCTION Popscreen
                     FUNCTION=Doscreen(2,0)
                 END FUNCTION
              
                 SUB Screensave(BYVAL Q?)
                     Doscreen 1,Q?
                 END SUB
              
                 SUB Screenrestore(BYVAL Q?)
                     Doscreen 2,Q?
                 END SUB
              
                 SUB Screenclear(BYVAL Q?)
                     Doscreen 0,Q?
                 END SUB
              
                 SUB Initscreen
                     Doscreen 0,0
                 END SUB
              
                 SUB Xprint(BYVAL Row?,BYVAL Col?,BYVAL Text$,BYVAL Tint?)
                     ' 4uS + 0.3uS per char
                     DIM Sc AS LOCAL BYTE PTR
                     DIM Tp AS LOCAL BYTE PTR
                     DIM Tl AS LOCAL DWORD
                     Sc=PBVSCRNBUFF + 160*(Row?-1)+ 2*(Col?-1)
                     Tp=STRPTR32(Text$)
                     Tl=Tp+LEN(Text$)
                     DO UNTIL Tp=Tl
                        @[email protected]
                        INCR Sc
                        @Sc=Tint?
                        INCR Sc
                        INCR Tp
                     LOOP
                 END SUB
              
                 SUB Recolour(BYVAL Row?,BYVAL Col?,BYVAL Length??,BYVAL Tint?)
                     DIM Sc AS LOCAL BYTE PTR
                     DIM Sl AS LOCAL DWORD
                     Sc=PBVSCRNBUFF + 160*(Row?-1)+ 2*(Col?-1)
                     Sl=Sc+2*Length??
                     DO UNTIL Sc=Sl
                        INCR Sc
                        @Sc=Tint?
                        INCR Sc
                     LOOP
                 END SUB
              
                   SUB Showbox(Trow?,Lcol?,Brow?,Rcol?,Hue1?,Hue2?)
                       LOCAL H?,W?,Q?,Q$
                       H?=Brow?-Trow?
                       W?=Rcol?-Lcol?
                       Q$=CHR$(218)+STRING$(W?,196)+CHR$(191)
                       Xprint Trow?,Lcol?,Q$,Hue1?
                       Q$=CHR$(191)
                       Xprint Trow?,Lcol?+W?+1,Q$,Hue2?
                       Q$=CHR$(192)+STRING$(W?,196)+CHR$(217)
                       Xprint Brow?,Lcol?,Q$,Hue2?
                       Q$=CHR$(192)
                       Xprint Brow?,Lcol?,Q$,Hue1?
                       FOR Q?=Trow?+1 TO Brow?-1
                           Q$=CHR$(179)+STRING$(W?,0)+CHR$(179)
                           Xprint Q?,Lcol?,Q$,Hue2?
                           Q$=CHR$(179)
                           Xprint Q?,Lcol?,Q$,Hue1?
                       NEXT Q?
                   END SUB
              
                   SUB Setcursor(BYVAL R?,BYVAL C?,BYVAL Flag?)
                       LOCAL Curmin?
                       SELECT CASE Flag?
                       CASE 0
                         LOCATE R?,C?,0
                         EXIT SUB
                       CASE 1
                         Curmin?=6
                       CASE 2
                         Curmin?=0
                       END SELECT
                       DECR R?
                       DECR C?
                       !       PUSH    DI
                       !       PUSH    SI
                       !       MOV     AX,&H0200
                       !       MOV     BX,00
                       !       MOV     DH,R?
                       !       MOV     DL,C?
                       !       INT     &H10
                       !       MOV     AX,&H0100
                       !       MOV     CH,Curmin?
                       !       MOV     CL,7
                       !       INT     &H10
                       !       POP     SI
                       !       POP     DI
                   END SUB
              Dave.

              You're never too old to learn something stupid.

              Comment


              • #8
                Writing to screen without PEEK/POKE

                Usually, PB writes to video RAM when displaying output. I don't know about VGA, but if you want to manipulate screen memory directly and you don't want to use PEEK or POKE, try this: (for CGA-compatible 80x25 text):

                TYPE ScreenLineType
                ScreenLine AS STRING * 160 ' 80 characters, 2 bytes per character
                END TYPE

                TYPE ScreenCharacterType
                ASCIICharacter AS BYTE
                Attribute AS BYTE
                END TYPE

                DIM ScreenCharacter AS ScreenCharacteType

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

                DesiredColumn? = (((ColumnNumber? - 1?) * 2?) + 1?)

                DesiredCharacter$ = MID$(ScreenPage0(LineNumber), DesiredColumn, 2)
                ScreenCharacter.ASCIICharacter = ASC(LEFT$(DesiredCharacter$, 1)
                ScreenCharacter.Attribute = ASC(RIGHT$(DesiredCharacter$, 1)

                "&HB800 is CGA screen page 0 (CGA has 4 pages of 4K each)
                &HBC00 is page 1
                &HC000 is page 2
                &HC400 is page 3

                I hope this helps.
                Last edited by Paul G. Penn; 26 Nov 2008, 03:04 AM. Reason: Punctuation

                Comment

                Working...
                X