Solved

How to change the visual Page in Vesa Grafik Mode

Posted on 2000-03-14
4
323 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
A Short Story about the Best File Recovery Software – Acronis True Image 2017
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

20 Experts available now in Live!

Get 1:1 Help Now