Board index » delphi » Bank Switching for video.

Bank Switching for video.

Can some kind soul show me the interrupt for bank switching so that I
can use the mem[seg:ofs] array to access the whole screen in
1024x768x256 mode please? I know that
the interrupt is 10h, but that's about all. Below was my first and only
attempt at this
based on a message that I read on news:borland.public.turbopascal but it
didn't work. :-)

Thanks in advance.

------------------------------
program pages;
var rg:registers;
begin
 rg:ax:=$4f05;
 rg.bx:=0;
 rg.dx:=1;
 intr($10,rg);
end.
------------------------------

--
Patrick D. Rockwell
mailto:prockw...@thegrid.net
mailto:HNHC...@prodigy.net
mailto:patri48...@aol.com

 

Re:Bank Switching for video.


"Patrick D. Rockwell" schrieb:

Quote

> Can some kind soul show me the interrupt for bank switching so that I
> can use the mem[seg:ofs] array to access the whole screen in
> 1024x768x256 mode please? I know that
> the interrupt is 10h, but that's about all. Below was my first and only
> attempt at this
> based on a message that I read on news:borland.public.turbopascal but it
> didn't work. :-)

> Thanks in advance.

 procedure switchbank64K(bank:word);
 var rg:registers;
 begin
  rg:ax:=$4f05;
  rg.bx:=0;
  rg.dx:=bank;
  intr($10,rg);
 end.

procedure putpixel(x,y:integer;color:byte);
var address:longint;
begin
  address:=longint(y)*640+x;
  switchbank64KB(word(address SHR 16));
  mem[$A000:word(address)]:=color;
end;

Michael

--
+-----------------------------------------------------------------+
| Michael Knapp - Mauerbach - Nieder?sterreich - Austria - Europe |
|   Informatik-Student an der TU-Wien - http://www.tuwien.ac.at   |
| E-Mail: mkn...@gmx.at                             ICQ: 36542787 |
+-----------------------------------------------------------------+
|     G r a p h i X  -  Freeware Graphics-Library for Pascal      |
|           http://programmierer.freepage.de/graphix              |
+-----------------------------------------------------------------+

Re:Bank Switching for video.


Quote
Michael Knapp <mkn...@gmx.at> wrote in message

news:3821DC9A.185353BF@gmx.at...

Quote
> "Patrick D. Rockwell" schrieb:

> > Can some kind soul show me the interrupt for bank switching so that I
> > can use the mem[seg:ofs] array to access the whole screen in
> > 1024x768x256 mode please?

>  procedure switchbank64K(bank:word);
>  var rg:registers;
>  begin
>   rg:ax:=$4f05;
>   rg.bx:=0;
>   rg.dx:=bank;
>   intr($10,rg);
>  end.

> procedure putpixel(x,y:integer;color:byte);
> var address:longint;
> begin
>   address:=longint(y)*640+x;
>   switchbank64KB(word(address SHR 16));
>   mem[$A000:word(address)]:=color;
> end;

To make the above VESA compatible, you should not assume that a bank shifts
the video memory by 64K. Better to derive a vairiable based on the
"WinGranularity" value returned by the VESA "Get Video Mode Information"
function:

VesaShift := Word(1) shl (64 div CardInfo.WinGranularity);

 This, amongst other things tells you by how big each video "bank" is. It is
guaranteed to be a power of 2, so a SHR instruction can be used to convert a
linear address to a bank number plus offset (into $A000):

function SetBank(X, Y: Integer): Word; assember;
asm
  mov   ax,[Y]
  mul   [CardInfo.BytesPerScanLine]  { May not be 640! }
  add   ax,[X]
  adc   dx,0
  cmp  dx,[VesaBank]  { Same bank as is currently set ? }
  je      @@Exit
  push   ax
  shl   dx,[VesaShift] { Convert 64K bank to "WinGranularity" }
  mov    ax:,$4f05
  mov   [VesaBank],dx
  xor     bx,bx
  call    [VesaSetBank] { Use the call, not the Int, 'cos it's faster }
  pop   ax                     { Return value - offset into video window seg
$A000 }
@@Exit:
end;

UNTESTED

A couple of other points to note:

The video window may not be located at $A000
The physical number of bytes per video scanline may exceed the actual
displayed scanline bytes - hence the CardInfo.BytesPerScanLine variable in the
above code.

There may be two video "banks" to set - one for setting the "bank" when
writing to the video memory, another for reading from the video memory. IIRC
set BX to 1 for the 4F05 function for setting the Read bank.

All of these things, and the address of the VesaSetBank function are returned
by VESA VBE function 1, "Get  Video Mode Information".

--
Jay

Jason Burgon - Author of Graphic Vision
New version 2 now available from:
http://www.jayman.demon.co.uk

Other Threads