www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/18/02:02:58

From: brin AT star DOT net (Brin)
Newsgroups: comp.os.msdos.djgpp,comp.os.msdos.djgpp
Subject: Graphics in Pascal
Date: Sat, 18 Jan 1997 01:28:48 GMT
Organization: StarNet
Lines: 100
Message-ID: <5bp9er$k73@acs1.star.net>
NNTP-Posting-Host: bev227p.star.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hey All, 
  I wrote the following small program to try out some graphics
routines (I am trying to port my graphics library to protected mode
and just wanna figure out how it works first)  When I run the program,
the computer freezes up until I hit control break, (I get a black
screen without a cursor so I think it does change into graphics mode)
then it will return to rhide.  I tried to step through it and after a
couple of F7, my compter crashed.  Here is the program, any idea to
what I am doing wrong!
Thanks in advance
-Brin

{****************************************************************}
Program Mode13h;
type
  {Define some 'terms'}
  byte  = __byte__ integer;       {8 bit unsigned integer}
  word  = __unsigned__ integer;   {16 bit unsigned integer}
  Long = __longlong__ integer;   {64 bit signed integer}

{routines taken from include/sys/farptr.h}
{Puts a byte}
procedure _farnspokeb(offset: Long ; value: byte);External;C;    
{Gets a byte}               
function _farnspeekb(offset: Long ; value: byte):byte;External;C;
{Gotta call this to set the selector}
procedure _farsetsel(selector : byte);External;C;

{routines taken from include/go32.h}
{Returns _dos_ds flag ie Selector}
function _go32_conventional_mem_selector: byte;External;C;
#define SetSelector _farsetsel(_go32_conventional_mem_selector);

{Port Routines found in include/pc.h}
Function inportb(port : word): byte;External;C;
Procedure outportb(port : word; data :byte);External;C;
{KeyBoard stuff in include/pc.h}
Function kbhit:integer;External;C;  {Tells if a key is pressed}

Procedure InitMode13h;
begin
  asm('movw $0x13, %ax; '                      {Go to Mode13h}
      'int $0x10');
end;

Procedure InitTextMode;
begin
  asm('movw $0x03, %ax; '                        {Go to text Mode}
      'int $0x10');
end;

Procedure PutPixel(x, y : word; c : byte);{Puts a pixel at x, y of
color c}
begin
  _farnspokeb(16#A0000+y shl 8 + y shl 6+x, c); {y shl 8 + y shl 6 = y
* 320}
end;

Procedure SetColor(Col, r, g, b : byte);{Set a color col in the
palette}
  { 0 <= col < 256}
  { 0 <= r < 64}
begin
  outportb($3C8, Col);                {Open the port for input}
  outportb($3C9, r);                  {Assign the color}
  outportb($3C9, g);
  outportb($3C9, b);
end;

var
  i : word;
  j : byte;

begin
  InitMode13h;
  SetSelector; {Set the selector}
  SetColor(100, 30, 30, 30);
  for i := 0 to 255 do
    for j := 0 to 199 do
      PutPixel(i, j, i);
  Repeat until (kbhit > 0);
  InitTextMode;
end.


********************************************************************************
                              Brin's Humor List
SUBSCRIBE!: If you're not on then get signed up!                    
     >>>>>Send an EMail to:  brin AT star DOT net<<<<<                  
     leaving the body with lots of funny comments and
     where you heard about us and Subscribe in the Subject.          
 DISTRIBUTE!: Send this to all your friends, enemies, and        
     to someone very special who you havn't seen in a long time
COME AND SEE:The archives                                              
     http://www.star.net/people/~brin                                        
CONTRIBUTE!: Send me funny stuff.                                    
DISCLAIMER: Please read the disclaimer at: 
  http://www.star.net/people/~Brin/Humor/disclaim.htm
**********************************************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019