Board index » delphi » Screen Resolution in assembly

Screen Resolution in assembly

I am using assembly codes in Turbo Pascal.
Can anyone tell me how I can increase the screen resolution to say
800x600 with assembly codes.
I am currently stuck with 320x200

Thanks

l...@mweb.co.za

 

Re:Screen Resolution in assembly


Quote
"Jaco Joubert" <l...@mweb.co.za> wrote:
>Can anyone tell me how I can increase the screen resolution to say
>800x600 with assembly codes.

You'll have to use VESA modes for higher resolution. There are many good
tutorials on the Internet. One farily good one is at
http://www.monstersoft.com/tutorial1/
I recently finished writing some VESA units, so if you need more information
e-mail me and I'll send you my units.
You might also want to look at the PC Game Programmer's encyclopedia:
http://www.heim2.tu-clausthal.de/PROJEKT/PRG/PCGAMES/index.html

Re:Screen Resolution in assembly


Jaco Joubert skrev i meddelandet <6ja4uh$...@news1.saix.net>...

Quote
>I am using assembly codes in Turbo Pascal.
>Can anyone tell me how I can increase the screen resolution to say
>800x600 with assembly codes.
>I am currently stuck with 320x200

>Thanks

>l...@mweb.co.za

If you don't want to do it the hard way (using the ports at the video card)
you can use VESA as everybody else does in DOS. (Had to write in DOS or some
Windows programmer would flame this post, they just do so, don't blame them,
they can't help it). At the net there are some good text about it, and a lot
which is bad. Try to find some source, it is the easiest way to learn. VESA
is very much like mode 13h infact. BIOS makes the most of the job. It is
even the same interrupt number. The hard thing with VESA is to understand
all variables that it uses. Don't do it, I thought that you had to but you
haven't, learn only those you think are needed. Later of course you should
try to learn the most of them. At first you should make a program that
prints some of the variables like, x resolution, y res, colors, mode number.

Ex.

type Temp =       enter all variables here
           ......
end;

function IsVesaSupported:byte;
var temp:byte;
begin
asm
mov     ax,4f00
mov     ds,seg temp           {I don't know if these are the right registers
                                              but you get the point (Yes you
could not write it that way, I know)}
mov     di,offset temp
int        10h
mov     temp,al
end;

IsVesaSupported:=temp;

end;

When this function gets called your temptype will be filled with plenty of
stuff like, OEMName (Name of your VideoCard), videomemory, Vesa number...

If you don't find any source or don't get it to work, don't hesitate to
write me a mail and I could send you some source or give you some more help.

/David Engstrand

Re:Screen Resolution in assembly


Jaco Joubert heeft geschreven in bericht <6ja4uh$...@news1.saix.net>...

Quote
>I am using assembly codes in Turbo Pascal.
>Can anyone tell me how I can increase the screen resolution to say
>800x600 with assembly codes.
>I am currently stuck with 320x200

You will need to use VESA to initialize the mode.
Then you can use bankswitching or the lineair frame buffer to access the
video memory.

UNIT XBVESA;
INTERFACE
USES XBSTD1;
TYPE
 PXBVESAInfo=^TXBVESAInfo;
 TXBVESAInfo=Record
  Signature:Array[$01..$04] OF Char;
  Version:Word;
  OEMStringPtr:PXBCBlok;
  Capabilities:Array[$00..$03] OF Byte;
  VideoModePtr:PXBWBlok;
  Reserved:Array[$00..$ED] OF Byte;
 END;
 PXBModeInfo=^TXBModeInfo;
 TXBModeInfo=Record
  ModeAttributes:Word;
  WinAAttributes,WinBAttributes:Byte;
  WinGranularity,WinSize,WinASegment,WinBSegment:Word;
  WinFunc:Pointer;
  BytesPerLine,XRes,YRes:Word;
  XCharSize,YCharSize:Byte;
  NumberOfPlanes,BitsPerPixel,NumberOfBanks,MemoryModel,BankSize:Byte;
  NumberOfImagePages,Reserved1:Byte;

RedMaskSize,RedFieldPosition,GreenMaskSize,GreenFieldPosition,BlueMaskSize,B
lueFieldPosition,
  ReservedMaskSize,ReservedFieldPosition,DirectColorModeInfo:Byte;
  Reserved2:Array[$00..$D7] OF Byte;
 END;
VAR
 XBVESACheck:Boolean;
 XBVESAError:Byte;
FUNCTION
XBFindVESAMode(iX2,iY2:Word;iBPP,iMM:Byte;ErrorMessage:Boolean):Word;
FUNCTION XBGetVESAMode:Word;
FUNCTION XBGetVESABank:Byte;
PROCEDURE XBCheckMode(Mode:Word);
PROCEDURE XBGetModeInfo(Mode:Word;ModeInfo:PXBModeInfo);
PROCEDURE XBGetVESAInfo(VESAInfo:PXBVESAInfo);
PROCEDURE XBSetVESABank(Bank:Byte);
PROCEDURE XBSetVESAMode(VesaMode:Word);
{PROCEDURE XBWriteModeInfo(Mode:Word);}
IMPLEMENTATION
FUNCTION
XBFindVESAMode(iX2,iY2:Word;iBPP,iMM:Byte;ErrorMessage:Boolean):Word;
VAR
 I:Word;
 ModeInfo:PXBModeInfo;
 VESAInfo:PXBVESAInfo;
BEGIN
 New(VESAInfo);
 New(ModeInfo);
 XBGetVESAInfo(VESAInfo);
 I:=$0000;
 XBFindVESAMode:=$FFFF;
 WITH ModeInfo^ DO
 WITH VESAInfo^ DO
 BEGIN
  WHILE VideoModePtr^[I]<>$FFFF DO
  BEGIN
   XBGetModeInfo(VideoModePtr^[I],ModeInfo);
   CASE iBPP OF
   $0F:IF GreenMaskSize<>$05 THEN
    XRes:=$0000
    ELSE
    Dec(BitsPerPixel);
   $10:IF GreenMaskSize<>$06 THEN
    XRes:=$0000;
   END;
   IF (iX2=XRes) AND (iY2=YRes) AND ((iBPP=$FF) OR (BitsPerPixel=iBPP)) AND
(MemoryModel=iMM) AND
      (WinGranularity=$0040) AND (WinSize=$0040) THEN
   BEGIN
    XBFindVESAMode:=VideoModePtr^[I];
    Break;
   END;
   Inc(I);
  END;
 END;
 IF ErrorMessage AND (VESAInfo^.VideoModePtr^[I]=$FFFF) THEN
 BEGIN
  WriteLn('No '+XBG(iX2)+'x'+XBG(iY2)+' '+XBG(iBPP)+' bit Color VESA Mode
found.');
  Halt;
 END;
 Dispose(ModeInfo);
 Dispose(VESAInfo);
END;
PROCEDURE ReportVESAError(Functie:Byte;Error:Word);
BEGIN
 IF XBVESACheck THEN
 BEGIN
  ASM
   MOV  AX,$0003
   INT  $10
  END;
  IF Lo(Error)<>$4F THEN
  WriteLn('Error: VESA Function '+XBPriHex(2,Functie)+' not supported.');
  IF Hi(Error)<>$00 THEN
  WriteLn('Error: VESA Function '+XBPriHex(2,Functie)+' failed.');
  Halt;
 END
 ELSE
 XBVESAError:=Hi(Error);
END;
PROCEDURE XBCheckMode(Mode:Word);
VAR
 ModeInfo:PXBModeInfo;
BEGIN
 New(ModeInfo);
 XBGetModeInfo(Mode,ModeInfo);
 WITH ModeInfo^ DO
 IF NOT ((WinGranularity=$0040) AND (WinSize=$0040)) THEN
 BEGIN
  ASM
   MOV  AX,$0003
   INT  $10
  END;
  WriteLn('Error: VESA Mode '+XBPriHex(3,Mode)+' not supported.');
  Halt;
 END;
 Dispose(ModeInfo);
END;
FUNCTION XBGetVESAMode:Word;
ASSEMBLER;
ASM
 MOV  XBVesaError,$00
 MOV  AX,$4F03
 INT  $10
 CMP  AX,$004F
 JZ   @LE
 PUSH $0003
 PUSH AX
 CALL ReportVESAError
@LE:MOV  AX,BX
END;
PROCEDURE XBSetVESAMode(VesaMode:Word);
ASSEMBLER;
ASM
 MOV  XBVesaError,$00
 MOV  AX,$4F02
 MOV  BX,VesaMode
 INT  $10
 CMP  AX,$004F
 JZ   @LE
 PUSH $0002
 PUSH AX
 CALL ReportVESAError
@LE:
END;
FUNCTION XBGetVESABank:Byte;
ASSEMBLER;
ASM
 MOV  XBVesaError,$00
 MOV  AX,$4F05
 MOV  BX,$0100
 INT  $10
 CMP  AX,$004F
 JZ   @LE
 PUSH $0005
 PUSH AX
 CALL ReportVESAError
@LE:MOV  AL,DL
END;
PROCEDURE XBSetVESABank(Bank:Byte);
ASSEMBLER;
ASM
 MOV  XBVesaError,$00
 MOV  AX,$4F05
 XOR  BX,BX
 XOR  DH,DH
 MOV  DL,Bank
 INT  $10
 CMP  AX,$004F
 JZ   @LE
 PUSH $0005
 PUSH AX
 CALL ReportVESAError
@LE:
END;
PROCEDURE XBGetModeInfo(Mode:Word;ModeInfo:PXBModeInfo);
ASSEMBLER;
ASM
 MOV  XBVesaError,$00
 MOV  AX,$4F01
 MOV  CX,Mode
 LES  DI,ModeInfo
 INT  $10
 CMP  AX,$004F
 JZ   @LE
 PUSH $0001
 PUSH AX
 CALL ReportVESAError
@LE:
END;
PROCEDURE XBGetVESAInfo(VESAInfo:PXBVESAInfo);
ASSEMBLER;
ASM
 MOV  XBVesaError,$00
 MOV  AX,$4F00
 LES  DI,VESAInfo
 INT  $10
 CMP  AX,$004F
 JZ   @LE
 PUSH $0000
 PUSH AX
 CALL ReportVESAError
@LE:
END;

BEGIN
 XBVESACheck:=True;
END.

Quote
>Thanks

>l...@mweb.co.za

Other Threads