[fpc-pascal] Pointers
Skybuck@home.nl
skybuck at home.nl
Thu Jul 28 03:23:12 CEST 2005
Maybe free pascal supports the "absolute" directive ;)
something like:
var
SomeAddress : pointer absolute $a000;
----- Original Message -----
From: "Daniel Franzini" <daniel.franzini at gmail.com>
To: <fpc-pascal at lists.freepascal.org>
Sent: Thursday, July 28, 2005 1:55 AM
Subject: [fpc-pascal] Pointers
Hi everyone
I'm just trying to compile and execute a simple example from a
graphics programming tutorial under FPC. Here is the code
<code>
PROGRAM PixelExample;
{$MODE TP} <----i used tp mode because i couldn't figure out how to
do inline asm in fpc mode
USES CRT; { Include the "KeyPressed" function }
TYPE
ScreenBufferType = ARRAY[0..63999] OF BYTE;
ScreenBufferPtr = ^ScreenBufferType;
VAR
Screen : ScreenBufferPtr;
PROCEDURE InitGraph; Assembler;
Asm
mov ax, 0013h { Function 0, mode 13h }
int 10h
end;
PROCEDURE CloseGraph; Assembler;
Asm
mov AX, 0003h { Function 0, Mode 3}
int 10h
end;
PROCEDURE SetPixel(X, Y : INTEGER; Color : BYTE);
VAR
Address : WORD;
BEGIN
Address := Y*320+X;
Screen^[Address] := Color;
END;
BEGIN
InitGraph;
Screen := MEM[$A000]; { Set up the screen buffer pointer }
<-----------here is the error
WHILE NOT KeyPressed DO
SetPixel(
RANDOM(320), { Random X (Range 0-319) }
RANDOM(200), { Random Y (Range 0-199) }
RANDOM(256)); { Random Color (Range 0-255) }
CloseGraph;
END.
</code>
the fact is that i want Screen to point to an specific memory area
(0xA000) for writing to the display directly...but i can't figure out
how to make this
i've tried the following options
@Screen := $A000; -> mode13h.pas(34,5) Error: Can't assign values to an
address
Screen := MEM[$A000]; -> mode13h.pas(34,15) Error: Identifier not found
"MEM"
the last onde didn't worked and i think that's because of the win32
target...so i tried to change the target to go32v2 but there's no
system unit for this target
is there any way that i can compile and execute this simple and basic
example under win32, but without touching the video unit, just using
assembly??? (windows 2000, fpc 2.0.0)
--
Daniel
"(...) one learns how to write code by reading code. One doesn't learn how
to
ride a bike by reading a book, either." (Theo de Raadt)
_______________________________________________
fpc-pascal maillist - fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list