Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

How Do You Enter a 640x480x256 Mode?

Ok, most of us know about mode x, and it's relations. And we all can use 640x480x16, but how do you get into 640x480x256? I would like it if it didn't use any .bgi drivers, but anything will help.  Send any drivers or units to Ozzy_98@msn.com.  Or, just e-mail and nice source codes you got laying around, I just love free source.
One last note: right now, I'm using 5.5, so it my not be compatiable with any thing you send.  If it has to use asm, send it anyways.  I'm planning on getting 7.0, or maybe Delphi.  
0
Ozzy_98
Asked:
Ozzy_98
  • 4
  • 3
  • 2
1 Solution
 
MathiasCommented:
I have some code for that question. Give me some hours and I will post it.

Bye, TDS.
0
 
MathiasCommented:
Here is the code.

First you must extract the code, the main program and
the vesa unit. Save the vesa unit as "vesa.pas".
The main program can have a name like "test.pas" or so.

You can set the modes given with the
"Vesa_" prefix.

Have fun with this, TDS.

{ - - - - - cut - - - - - }

{main program}

uses crt, vesa;
const
  Vesa_640x480x256   = $101;
  Vesa_800x600x256   = $103;
  Vesa_1024x768x256  = $105;
  Vesa_1280x1024x256 = $107;

begin
  SetVESA(VESA_640x480x256);
  delay(1500); {We want to see the first pixel!
                Let the graphic card a little delay}
  while not keypressed do
  begin
    PutPixel(Random(640), Random(480), Random(256));
    delay(5);
  end;
  SetText;
end.


{ - - - - - cut - - - - - }

{VESA unit}

{$G+}
Unit vesa;

INTERFACE

PROCEDURE setvesa(blabla:word);            {Set VGA-Mode}
PROCEDURE Settext;                         {Set Textmode}

PROCEDURE Wait;                            {vertical retrace}

PROCEDURE Outtextxy    (x, y:word;texte:string;color:byte);{Write text}

procedure Putpixel(X, Y : Word; C : word);                 {Set a point}
FUNCTION  GetPixel     (x, y : Word)           : Byte;     {Get color at x, y}
PROCEDURE Line         (x1, y1, x2, y2, color  : INTEGER); {Line}
PROCEDURE Rectangle    (x, y, x2, y2, color    : INTEGER); {Rectangle}

PROCEDURE SetPalette(index, r, g, b : Byte); {Change palette}

IMPLEMENTATION

VAR xstart, ystart, xend, yend: WORD;
    mode,co,n,m,xmax,ymax,mxmax:word;
    buf:array[0..255] of byte;
    sos,ooo:word;
    bank:byte;
    oldbank:word;

PrOcedure setvesa(blabla:word);
begin
 mode:=blabla;
 sos:=seg(buf);
 ooo:=ofs(buf[0]);
 oldbank:=0;
 asm
  mov ax,$4f02
  mov bx,mode
  int $10
 end;
 asm
  mov ax,$4f01
  mov cx,mode
  mov es,sos
  mov di,ooo
  int $10
 end;

 if memw[sos:ooo+4]=0 then memw[sos:ooo+4]:=1;
 bank:=memw[sos:ooo+6] div memw[sos:ooo+4];

 xmax:=memw[sos:ooo+$12];
 ymax:=memw[sos:ooo+$14];
 if xmax=0 then begin xmax:=320;ymax:=200;bank:=0;end;

end;

PROCEDURE settext;
  BEGIN;
    Asm MOV  AX,3; INT $10; END;
  END;

procedure Putpixel(X, Y : Word; C : word);  { VESA putpixel }
var b,z1,z2,z3,q,w:longint;
    bnk:word;

begin
 if c<=255 then
  begin      
   z1:=y;z2:=xmax;
   q:=z1*z2+x;
   z3:=memw[sos:ooo+6];
   z3:=z3*1024;
   if z3=0 then z3:=1;
   b:=q div z3;
   bnk:=b*bank;        
   if oldbank<>b then
    begin
     asm
      mov ax,$4f05
      mov bx,0
      mov dx,bnk
      int $10
     end;  
     oldbank:=b;
    end;
   if ((x<xmax) and (y<ymax)) then mem[$a000:q]:=c;
 end;
end;

procedure wait;
 BEGIN;
  asm
   mov dx,3dah
   @x: in al,dx
   test al,08h
   jnz @x
   @y: in al,dx
   test al,08h
   jz @y
  END;
 END;

PROCEDURE line(x1,y1,x2,y2,color:INTEGER);
 function sign(x:INTEGER):INTEGER;
  BEGIN if x<0 then sign:=-1 else if x>0 then sign:=1 else sign:=0 END;
  var
    x,y,count,xs,ys,xm,ym:INTEGER;
  BEGIN
    x:=x1;y:=y1;

    xs:=x2-x1;    ys:=y2-y1;

    xm:=sign(xs); ym:=sign(ys);
    xs:=abs(xs);  ys:=abs(ys);

    putpixel(x,y,color);

  if xs > ys
    then BEGIN {flat line <45 deg}
      count:=-(xs div 2);
      while (x <> x2 ) do BEGIN
        count:=count+ys;
        x:=x+xm;
        if count>0 then BEGIN
          y:=y+ym;
          count:=count-xs;
          END;
        putpixel(x,y,color);
        END;
      END
    else BEGIN {steep line >=45 deg}
      count:=-(ys div 2);
      while (y <> y2 ) do BEGIN
        count:=count+xs;
        y:=y+ym;
        if count>0 then BEGIN
          x:=x+xm;
          count:=count-ys;
          END;
        putpixel(x,y,color);
        END;
      END;
  END;

PROCEDURE SetPalette(index, r, g, b : Byte);
 BEGIN
  Port[$3C8] := index;
  Port[$3C9] := r;
  Port[$3C9] := g;
  Port[$3C9] := b;
 END;

PROCEDURE rectangle(x,y,x2,y2,color:INTEGER);
 BEGIN;
  line(x,    y   , x+x2, y   , color);
  line(x,    y   , x   , y+y2, color);
  line(x+x2, y+y2, x+x2, y   , color);
  line(x+x2, y+y2, x   , y+y2, color);
 END;

function GetPixel(X, Y : Word):byte;
var z1,z2,q,w:longint;
    b:word;
begin
 z1:=y;z2:=xmax;
 q:=z1*z2+x;
 b:=q div 65536;
 b:=b*bank;
 if oldbank<>b then
  begin
   asm
    mov ax,$4f05
    mov bx,0
    mov dx,b
    int $10
   end;
   oldbank:=b;
  end;
 getpixel:=mem[$a000:q];
end;

{Write text to x,y with color}
PROCEDURE outtextxy(x,y:word;texte:string;color:byte);

PROCEDURE GetFontPointer (var p : pointer; font : byte);
BEGIN
 asm
  push ds
  push bp
  mov  ax, 1130h
  mov  bh, font
  int  10h
  mov  ax, bp
  pop  bp
  lds  si, p
  mov  ds:[si], ax
  mov  ds:[si+02], es
  pop  ds
 END;
END;

VAR point:pointer;
    d,d2,x2,y2,d3,num:word;
    st:string;
    d21,len:byte;

BEGIN
  getfontpointer(point,6);

  x2:=0;
  y2:=0;

  for len:=0 to length(texte)-1 do
  BEGIN
    y2:=0;
    x2:=x+8*len;
    num:=ord(texte[len+1]);
    for d3:=0 to 15 do
     BEGIN
       d21:=mem[seg(point^):ofs(point^)+num*16+d3];
       for d:=7 downto 0 do
           if (d21 shr d) mod 2 = 1 then putpixel(x+x2+7-d,y+y2,color);
       inc(y2);
     END;
    END;
 END;

END.
0
 
HypoCommented:
This is how you do it...
 in pascal
 
 uses Crt,Dos;
 var Regs : Registers;
 begin
 Regs.AX := $4F02; { $4F02 = use VBE command 4F02 (set VESA mode) }
 Regs.BX := $101;  { $101 = which mode to set, ($101 = 640x480x256) }
 intr($10,Regs); { Call interrupt $10, Video interrupt }
 { voilla, 640x480x256 }
 
 
 


 end;
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
MathiasCommented:
Hypo, take a look at my code. What you wrote here is already written in the given routines.
0
 
HypoCommented:
TDS,

I write my own graphic units... I don't need to take the code from others.

When wrote my comment, you hadn't posted your answer yet... So I couldn't know about your answer when I posted my comment, 'cuz it wasn't there when I started typing it!
0
 
MathiasCommented:
Sorry, Hypo, but I saw the time difference too late.

Sorry, Sorry...
0
 
Ozzy_98Author Commented:
Adjusted points from 25 to 30
0
 
Ozzy_98Author Commented:
Thanks, Guys. Looks like you two try to help out all us pascal programers.  Most answers seem to be from you two, or a few others. :) I can't realy use the asm stuff yet, but most can be used by the intr command. But, my mode-x unit I made looks alot like yours, TDS.  Makes me feel good knowing someone else writes code like me.  Too many people are comment happy.  Takes toooo loooong to figure some things out.
0
 
HypoCommented:
TDS: it's ok... ;)

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now