Solved

How to change the visual Page in Vesa Grafik Mode

Posted on 2000-03-14
4
324 Views
Last Modified: 2010-04-16
Im in Vesa Grafik Mode Nr. $101 ( 640x480x256), my GrafikCard has 2MB RAM, so I've got more than 1 Page. When I change it with the two Ports ( Port to set StartOffSet ), The Screen is only shifted away by ca. 80 %, cause one Page is bigger than 64k.
0
Comment
Question by:DennisWood
4 Comments
 
LVL 1

Expert Comment

by:ntdragon
ID: 2616263
are you using:
activepage(...)
visualpage(...)

or give us some code
0
 
LVL 3

Expert Comment

by:Alisher_N
ID: 2616776
you may need to switch banks on your card because system doesn't allow you to access more than 64K
or you may use Linear Frame Buffering mode which gives you all video memory access
0
 
LVL 12

Accepted Solution

by:
Hypo earned 300 total points
ID: 2617925
Hi,
Take a look at my example... I've used pageflipping in several vesamodes before so I recognize your problem. Check out the pascalcode in the SetVesaMode procedure to see the calculations I use... it works fine to me.

Anyway, I'm not using ports to set the visual page in vesa modes, I'm using the vesa function $4F07 to do that.

Let me know if you want me to explain it better. (this is the second time I write this thing to you since the first answer i tried to submit got lost in a server error)

Program Flipping;

uses crt;

Type modeinfo = record
   ModeAttributes   : word;
   WinAAttributes   : byte;
   WinBAttributes   : byte;
   WinGranularity   : word;
   WinSize          : word;
   WinASegment      : word;
   WinBSegment      : word;
   WinFunc          : pointer;
   BytesPerScanLine : word;
   XResolution      : word;
   YResolution      : word;
   XCharSize        : byte;
   YCharSize        : byte;
   NumberOfPlanes   : byte;
   BitsPerPixel     : byte;
   NumberOfBanks    : byte;
   MemoryModel      : byte;
   BankSize         : byte;
   NumberOfImgPages : byte;
   OtherData        : array[0..225] of byte;
   CurBank          : byte;
   AddPage          : byte;
end;

var _VMode    : ModeInfo;

    _FlipPages,
    _FlipYc,
    _FlipXc,
    _FlipPage  : integer;

    loop,a,b   : integer;

Procedure SetVesaMode(Mode : word);
begin
 asm
  MOV AX,4F01h        { regs.AX := $4F01;      }
  MOV CX,mode         { regs.CX := Mode;       }
  MOV BX,DS           { regs.BX := regs.DS;    }
  MOV ES,BX           { regs.ES := regs.BX;    }
  LEA DI,_VMode       { regs.DI := ofs(Vmode); }
  INT $10;            { intr($10,regs);        }

  MOV AX,4F02h        { regs.AX := $4F02;      }
  MOV BX,CX           { regs.BX := regs.CX;    }
  INT $10             { intr($10,regs);        }

  MOV AX,4F06h
  MOV BL,0
  MOV CX,_VMode.XResolution;
  INT $10
 end;
 _FlipPages := (longint(_VMode.Yresolution)*longint(_VMode.BytesPerScanLine)) shr 16 +1;
 _FlipYc := longint(_FlipPages) shl 16 div (_VMode.BytesPerScanLine);
 _FlipXc := ((longint(_FlipPages) shl 16) mod (_VMode.BytesPerScanLine)) div 2;
 _VMode.CurBank := 0;
 _VMode.AddPage := 0;
end;

Procedure _SetVisualPage(scrn : byte); assembler;
asm
  MOV AX,$4F07
  XOR BX,BX
  XOR DX,DX
  MOV CL,SCRN
  AND CX,1
  JZ  @FirstPage
  MOV CX,_FlipXc;
  MOV DX,_FlipYc;
  @FirstPage:
  INT $10
end;

Procedure _SetActivePage(Page : byte); assembler;
asm
  MOV AL,Page
  AND AX,1
  JZ  @ActivateFirstPage
  MOV AH,byte ptr _FlipPages
  @ActivateFirstPage:
  MOV _VMode.AddPage,AH
end;

Procedure Retrace; assembler;
asm
  MOV DX, $3DA
  @NotVert:
  IN  AL, DX
  AND AL, 8
  JNZ @NotVert
  @IsVert:
  IN  AL, DX
  AND AL, 8
  JZ @IsVert
end;

Procedure SetBank(num : byte); assembler;
asm
  XOR  DX,DX
  XOR  BX,BX
  MOV  DL,num
  ADD  DL,_VMode.AddPage
  CALL _Vmode.WinFunc
  SUB  DL,_VMode.AddPage
  MOV  _VMode.CurBank,DL
end;

Procedure _Flip;
begin
  _FlipPage := not _FlipPage and 1;
  _SetVisualPage(_FlipPage);
  _SetActivePage((_FlipPage+1) and 1);
end;

Procedure _Putpixel(X,Y,C : word);
var VidMem : longint;
begin
 VidMem := longint(longint(Y)*longint(_VMode.XResolution)+X)*longint(_VMode.BitsPerPixel shr 3);
 if (VidMem shr 16) <> _VMode.CurBank then
  SetBank(VidMem shr 16);
 if _VMode.BitsPerPixel > 8 then
  memw[$A000:VidMem] := C else
   mem[$A000:VidMem] := C;
end;

Procedure TextMode; assembler;
asm
 MOV AX,3
 INT $10;
end;

Procedure MakeScreen;
var A,B,C : integer;
begin
 _SetActivePage(0);
 for A := 0 to _VMode.YResolution do begin
  for B := 0 to (A shr 4) do _PutPixel(Random(A),A,random(255));
 _PutPixel(A,A,15);
 end;
 _SetActivePage(1);
 for A := 0 to _VMode.YResolution do begin
  for B := 0 to (A shr 4) do _PutPixel(_VMode.YResolution-Random(A),A,random(255));
  _PutPixel(_VMode.YResolution-A,A,15);
 end;
end;

begin
 SetVesaMode($101);
 MakeScreen;
 repeat
 delay(250);
 retrace;
 _Flip;
 until keypressed;
 TextMode;
end.
0
 

Author Comment

by:DennisWood
ID: 2639669
Thanks, this makes what i wanted. But on my second Computer, with a Cirrus Logic ??22 - ??28 with 1 MB the second screenpage is always black, whats up there ? 640*480 is ca 300kByte two Pages are only around 600 kB.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now