Announcement

Collapse
No announcement yet.

Question about SCREEN 12

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

  • Tom Hanlin
    replied
    The 'flip' routine of Andrew confuses me once again, it start like this:
    ! PUSH DS
    ! MOV AX, source??
    ! MOV DS, AX
    ! MOV AX, dest??
    ! MOV ES, AX

    Am I correct in saying that it's a matter of luck whether this will work or not?
    Because the variable dest?? is accessed after DS has been altered. And am I also
    correct that Powerbasic allows direct modification of DS and ES unlike plain
    assembler? So IMO the routine would be better if it started like this:
    ! PUSH DS
    ! MOV ES, dest??
    ! MOV DS, source??
    Good point. Yes, ES does need to be loaded first. Loading segment registers from
    memory should be possible with any assembler, not just PowerBASIC.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    several points.

    Mr Hanlin is correct the code I posted will only save the color white(15)
    I only tested it on white so there's egg on my face.

    Second I tested the get and put code by dividing the 640X480 screen
    into 4 sections and it still didn't work. It would get the first section
    but would crash on getting the other ones.So I don't know if it is a bug in the compiler
    or something else.

    Anyway I apologize for my oversight.

    Andrew




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

    Leave a comment:


  • Sebastian Groeneveld
    replied
    The 'flip' routine of Andrew confuses me once again, it start like this:
    ! PUSH DS
    ! MOV AX, source??
    ! MOV DS, AX
    ! MOV AX, dest??
    ! MOV ES, AX

    Am I correct in saying that it's a matter of luck whether this will work or not?
    Because the variable dest?? is accessed after DS has been altered. And am I also
    correct that Powerbasic allows direct modification of DS and ES unlike plain
    assembler? So IMO the routine would be better if it started like this:
    ! PUSH DS
    ! MOV ES, dest??
    ! MOV DS, source??

    The program below is just a merge of Andrew's code and Dave's code...

    Code:
    $LIB VGA ON, GRAPH ON
    DEFINT A-Z
    
    %vga = &HA000
    
      'Reserve 64000 bytes for each plane
    DIM Plane1(0 TO 32000) AS WORD
    DIM Plane2(0 TO 32000) AS WORD
    DIM Plane3(0 TO 32000) AS WORD
    DIM Plane4(0 TO 32000) AS WORD
    
    DIM PlaneAddress(0 TO 3) AS SHARED WORD
    
      'Store the segment of each reserved block
    PlaneAddress(0) = VARSEG( Plane1(0) )
    PlaneAddress(1) = VARSEG( Plane2(0) )
    PlaneAddress(2) = VARSEG( Plane3(0) )
    PlaneAddress(3) = VARSEG( Plane4(0) )
    
    SCREEN 12
    
      'Fill the screen with colored boxes
    FOR i = 0 TO 100
        LINE (i * 2, i * 2)-(639 - i * 2, 479 - i * 2), i MOD 16, B
    NEXT i
    LOCATE 15, 31
    PRINT "Screen 12 save/restore"
    
    WHILE INKEY$ = "": WEND
    
    SaveVGA
    
    CLS
    PRINT "Press any key to restore"
    
    WHILE INKEY$ = "": WEND
    
    LoadVGA
    
    WHILE INKEY$ = "": WEND
    
    SCREEN 0,0,0
    
    SUB SaveVGA
    
        FOR planenr?? = 0 TO 3
              'Select plane to read from
            OUT &H3CE, 4
            OUT &H3CF, planenr??
    
              'And save video memory
            CopySegment %vga, PlaneAddress(planenr??)
    
        NEXT planenr??
    
         'Reset read plane select
       OUT &H3CE, 4
       OUT &H3CF, 0
    
    END SUB
    
    
    SUB LoadVGA
    
        DIM PlaneMask AS LOCAL BYTE
    
          'We need a bit mask to select the planes we want to write to
          'This allows us to write to multiple planes at once (default)
        PlaneMask = &B0001
    
        FOR planenr?? = 0 TO 3
    
              'Select plane to write to
            OUT &H3C4, 2
            OUT &H3C5, PlaneMask
    
              'Load video memory
            CopySegment PlaneAddress(planenr??), %vga
    
              'Move to next plane
            SHIFT LEFT PlaneMask, 1
    
        NEXT planenr??
    
          'Reset write plane select (all)
        OUT &H3C4, 2
        OUT &H3C5, &B1111
    
    END SUB
    
    
    SUB CopySegment (BYVAL source??, BYVAL dest??) PUBLIC
    
       ! push  ds
       ! mov   es, dest??
       ! mov   ds, source??
       ! xor   si, si
       ! xor   di, di
       ! cld
       ! mov   cx, 32000
       ! rep   movsw
       ! pop   ds
    
    END SUB
    Kind regards

    ------------------
    Sebastian Groeneveld
    mailto:[email protected][email protected]</A>

    [This message has been edited by Sebastian Groeneveld (edited May 30, 2001).]

    Leave a comment:


  • Dave Stanton
    replied
    I've used these routines for the last few years without problems.

    Here they are with a demo front end.

    You have to keep the size of any dimention in the virtual
    array <16k, or you get corruption.
    I think it's due to frame size.
    Thats why the each colour plane is split into 3 parts.

    Hope it helps.

    Dave.

    Code:
            %Scrnmax=10
            %Scrnsize=12800
    
            DIM VIRTUAL G12Scr(1:%Scrnmax,1:12) AS STRING*%Scrnsize
    
            SCREEN 12
            CLS
            FOR Scrn?=1 TO %Scrnmax
                CLS SCREEN
                FOR Q?=1 TO 24
                    LINE (RND(1,639),RND(1,479))-(RND(1,639),RND(1,479)),Q?,BF
                NEXT Q?
                LOCATE 30,30
                PRINT USING "Screen  ##";Scrn?;
                G12Scrarc Scrn?,0
            NEXT Scrn?
    
            FOR Scrn?=1 TO %Scrnmax
                IF INPUT$(1)=CHR$(27) THEN EXIT FOR
                MTIMER
                G12Scrdearc Scrn?,0
                T???=MTIMER
                LOCATE 30,1
                PRINT USING " ###### msec";T???/1000;
            NEXT Scrn?
    
            END
    
            SUB G12Scrarc(BYVAL Q?,BYVAL Page?)
                DIM G12Scr(MIN,2) AS SHARED STRING*%Scrnsize
                IF Page? THEN
                   DEF SEG=&HA800
                ELSE
                   DEF SEG=&HA000
                END IF
                OUT &H3CE, 4: OUT &H3CF,0
                G12Scr(Q?,1)=PEEK$(0,%Scrnsize)          'Blue
                G12Scr(Q?,2)=PEEK$(%Scrnsize,%Scrnsize)  'Blue
                G12Scr(Q?,3)=PEEK$(2*%Scrnsize,%Scrnsize)  'Blue
                OUT &H3CE, 4: OUT &H3CF,1
                G12Scr(Q?,4)=PEEK$(0,%Scrnsize)          'Green
                G12Scr(Q?,5)=PEEK$(%Scrnsize,%Scrnsize)  'Green
                G12Scr(Q?,6)=PEEK$(2*%Scrnsize,%Scrnsize)  'Green
                OUT &H3CE, 4: OUT &H3CF,2
                G12Scr(Q?,7)=PEEK$(0,%Scrnsize)          'Red
                G12Scr(Q?,8)=PEEK$(%Scrnsize,%Scrnsize)  'Red
                G12Scr(Q?,9)=PEEK$(2*%Scrnsize,%Scrnsize)  'Red
                OUT &H3CE, 4: OUT &H3CF,3
                G12Scr(Q?,10)=PEEK$(0,%Scrnsize)          'Intensity
                G12Scr(Q?,11)=PEEK$(%Scrnsize,%Scrnsize)  'Intensity
                G12Scr(Q?,12)=PEEK$(2*%Scrnsize,%Scrnsize)  'Intensity
    
    
                OUT &H3CE, 4: OUT &H3C5,&H0
                DEF SEG
            END SUB
    
            SUB G12Scrdearc(BYVAL Q?,BYVAL Page?)
                DIM G12Scr(MIN,2) AS SHARED STRING*%Scrnsize
                IF Page? THEN
                   DEF SEG=&HA800
                ELSE
                   DEF SEG=&HA000
                END IF
                OUT &H3C4, 2: OUT &H3C5, 1
                POKE$ 0,G12Scr(Q?,1)                 'Blue
                POKE$ %Scrnsize,G12Scr(Q?,2)         'Blue
                POKE$ 2*%Scrnsize,G12Scr(Q?,3)         'Blue
                OUT &H3C4, 2: OUT &H3C5, 2
                POKE$ 0,G12Scr(Q?,4)                 'Green
                POKE$ %Scrnsize,G12Scr(Q?,5)         'Green
                POKE$ 2*%Scrnsize,G12Scr(Q?,6)         'Green
                OUT &H3C4, 2: OUT &H3C5, 4
                POKE$ 0,G12Scr(Q?,7)                 'Red
                POKE$ %Scrnsize,G12Scr(Q?,8)         'Red
                POKE$ 2*%Scrnsize,G12Scr(Q?,9)         'Red
                OUT &H3C4, 2: OUT &H3C5, 8
                POKE$ 0,G12Scr(Q?,10)                 'Intensity
                POKE$ %Scrnsize,G12Scr(Q?,11)         'Intensity
                POKE$ 2*%Scrnsize,G12Scr(Q?,12)         'Intensity
                OUT &H3C4, 2: OUT &H3C5,&HF
                DEF SEG
            END SUB
    ------------------

    Leave a comment:


  • Tom Hanlin
    replied
    There's a key problem with the posted save/restore function in that it doesn't
    save colors. The deal here is, SCREEN 12 is stored in a number of separate
    planes (red, green, and blue, if I recall correctly). As far as the computer
    is concerned, these planes occupy the same area of memory, so you can only read
    or write all of them by swapping to each plane in succession. This is done with
    OUT commands to the display controller. In the default mode, apparently, all you
    get is a blend of on/off settings, so all of your colors turn white or black.

    I don't have the details for plane manipulation at my fingertips, but this used
    to be fairly common code. I'd start by looking in the Downloads section here and,
    if that turns up no leads, try searching the old ABC records (All BASIC Code): try
    PowerBASIC Archives


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

    Leave a comment:


  • Guest's Avatar
    Guest replied
    The example at the Source Code is this:

    '*******************************************************

    %vga = &hA000

    DIM screen1(-32000 TO 31999) AS BYTE

    CopyBuffer = VARSEG(screen1(-32000))

    SCREEN 12

    LINE (0,0)-(639,479),15,b

    flip %vga,CopyBuffer

    CLS

    Print "Press any key to restore": sleep 100

    CLS

    flip CopyBuffer,%vga

    SUB flip (BYVAL source??, BYVAL dest??) PUBLIC ' Copy the entire screen at source to destination

    ! PUSH DS
    ! MOV AX, source??
    ! MOV DS, AX
    ! MOV AX, dest??
    ! MOV ES, AX
    ! XOR SI, SI
    ! XOR DI, DI
    ! CLD
    ! MOV CX, 32000
    ! REP MOVSW
    ! POP DS

    END SUB

    '*********************************************************

    It seems be right, but when I draw shapes with other colors
    the code not works.




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

    Leave a comment:


  • Lance Edmonds
    replied
    It looks like someone has kindly posted some code in the Source Code forum that may be of some use...

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

    Leave a comment:


  • Davide Vecchi
    replied
    AFAIK the size of the needed array can' t exceed 64K; this should be the reason why your example doesn' t work.
    I dthink it' s not possible to normally GET the whole screen 12.

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

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Originally posted by Jose Antonio Esteva R:
    How can I GET and PUT all the screen using 640x480x16colors?


    How you would normally do it is....

    DEFINT a-z
    DIM huge image(76802)
    SCREEN 12
    LINE (0,0)-(639,479),15,b
    GET (0,0)-(639,479),image
    CLS
    PUT (0,0),image
    'below is to determine the size of the array needed
    ? (4+CEIL(640/8)*4*480)/2 '153604/2=76802

    But it doesn't work with my version of PBDOS(3.5).
    So in the source code section you will find a way to do it with ASM
    It will only copy the entire screen.



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

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Question about SCREEN 12

    Question about SCREEN 12

    How can I GET and PUT all the screen using 640x480x16colors?



    ------------------
Working...
X