Pointers

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Pointers

Daniel Franzini
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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pointers

Steve Williams-3
Daniel Franzini wrote:

> 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"
Have you tried

   Screen := ScreenBufferPtr($a000);


--
Sly


This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Pointers

Daniel Franzini
no, i didn't...but it worked and the program did compiled...now, it
shows the following message

Runtime error 216 at $00401034
  $00401034

but i think that this is some windows (2000) issue not FPC one...so i
ask: is there any way of running these simple examples or i will just
have to set up some 16bit env or start touching those graphics units
that come with freepascal??

On 7/27/05, Steve Williams <[hidden email]> wrote:
> Have you tried
>
>    Screen := ScreenBufferPtr($a000);
>
>
> --
> Sly
>

--
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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pointers

Skybuck@home.nl
In reply to this post by Daniel Franzini
Maybe free pascal supports the "absolute" directive ;)

something like:

var
    SomeAddress : pointer absolute $a000;

----- Original Message -----
From: "Daniel Franzini" <[hidden email]>
To: <[hidden email]>
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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pointers

Steve Williams-3
In reply to this post by Daniel Franzini
Daniel Franzini wrote:

> no, i didn't...but it worked and the program did compiled...now, it
> shows the following message
>
> Runtime error 216 at $00401034
>   $00401034
>
> but i think that this is some windows (2000) issue not FPC one...so i
> ask: is there any way of running these simple examples or i will just
> have to set up some 16bit env or start touching those graphics units
> that come with freepascal??
I believe you do not have direct access to that memory in Windows 2000
or higher.  You have to go through the proper channels, ie. GDI or DirectX.

--
Sly


This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pointers

Bugzilla from elio@mixtk.com
In reply to this post by Daniel Franzini
El Mié 27 Jul 2005 20:14, Daniel Franzini escribió:
> no, i didn't...but it worked and the program did compiled...now, it
> shows the following message
>
> Runtime error 216 at $00401034
>   $00401034
>
> but i think that this is some windows (2000) issue not FPC one...
New versions of WinNT (Incl. win2k) use a DOS emulator to which allows the
kind of instructions you want to use, but if you compile in full Win32 mode
it won't let you have access to the graphic hardware, not even use these
DOS/BIOS interruptions.

> so i ask: is there any way of running these simple examples or i will just
> have to set up some 16bit env or start touching those graphics units
> that come with freepascal??
>
Well, either that or you might want to try OpenGL, that way you'll get fully
acelerated 2D graphics plus free alpha blending and even 3D if you need that.
In my experience the FPC graph unit is not that good, not that is bad, it's
very fun to use but not really useful for fast graphical applications.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pointers

John Coppens
In reply to this post by Daniel Franzini
On Wed, 27 Jul 2005 20:55:34 -0300
Daniel Franzini <[hidden email]> wrote:

> Hi everyone
>
> I'm just trying to compile and execute a simple example from a
> graphics programming tutorial under FPC. Here is the code
>

Note that those addresses (like $a000) are all things from the 16-bit
world. I'm not sure how far these are emulated correctly if you are
running in a 32-bit world. Addresses for graphics cards are way different
there, easier to use, but different from card to card.

John

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pointers

Leonhard Holz
Hello,

> Note that those addresses (like $a000) are all things from the 16-bit
> world. I'm not sure how far these are emulated correctly if you are
> running in a 32-bit world. Addresses for graphics cards are way different
> there, easier to use, but different from card to card.

If you compile a win32-program you will have a total virtual memory,
that means that your pointer values don't have anything to do with the
physical ram. A pointer associated to $a0000 actually points to nowhere.

If you really want mode $13 you need to compile for dos, cause then
windows sets up an old-style 8086 environment. Unfortunately the
download page says:

"Sorry, no Dos release yet. The Dos platform is missing a maintainer and
is not of acceptable quality for 2.0."

Leo

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pointers

Daniel Franzini
On 7/28/05, Leonhard Holz <[hidden email]> wrote:
> Hello,
>
> If you compile a win32-program you will have a total virtual memory,
> that means that your pointer values don't have anything to do with the
> physical ram. A pointer associated to $a0000 actually points to nowhere.
>

ok...thanks

> If you really want mode $13 you need to compile for dos, cause then
> windows sets up an old-style 8086 environment. Unfortunately the
> download page says:
>

yeah, i'll try compiling for go32-v2 target to see what happens

> "Sorry, no Dos release yet. The Dos platform is missing a maintainer and
> is not of acceptable quality for 2.0."
>

i'm aware of that...so i'm going to download the lastest go32-v2
sources, build it and see what happens...thanks

> Leo
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


--
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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pointers

Vinzent Höfler
In reply to this post by Leonhard Holz
On Thursday 28 July 2005 06:11, Leonhard Holz wrote:

> If you really want mode $13 you need to compile for dos, cause then
> windows sets up an old-style 8086 environment. Unfortunately the
> download page says:
>
> "Sorry, no Dos release yet. The Dos platform is missing a maintainer
> and is not of acceptable quality for 2.0."

Ok. My turn. :) This statement on the webpage is "not entirely
accurate".

There is a DOS maintainer, but unfortunately I haven't had much spare
time to work on that further. My latest tests were quite successful,
the "only" problem still is that you can't debug inside the IDE, it
still crashes due to - well, let me put it this way - interesting
reasons.

Demo programs and that stuff compiled and ran fine as far (there were
some problems with the DOS specific mouse support, though, but the
portable units worked).

I hope, once things are a little bit settled at work, I will have more
time to work on a real release quality version.


Vinzent.

--
public key: http://www.t-domaingrabbing.ch/publickey.asc

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Pointers

Tomas Hajny
> On Thursday 28 July 2005 06:11, Leonhard Holz wrote:
>
>> If you really want mode $13 you need to compile for dos, cause then
>> windows sets up an old-style 8086 environment. Unfortunately the
>> download page says:
>>
>> "Sorry, no Dos release yet. The Dos platform is missing a maintainer
>> and is not of acceptable quality for 2.0."
>
> Ok. My turn. :) This statement on the webpage is "not entirely
> accurate".
>
> There is a DOS maintainer, but unfortunately I haven't had much spare
> time to work on that further. My latest tests were quite successful,
> the "only" problem still is that you can't debug inside the IDE, it
> still crashes due to - well, let me put it this way - interesting
> reasons.
>
> Demo programs and that stuff compiled and ran fine as far (there were
> some problems with the DOS specific mouse support, though, but the
> portable units worked).
>
> I hope, once things are a little bit settled at work, I will have more
> time to work on a real release quality version.

...daily generated snapshots available on our FTP can be used instead in
the meantime (saving John from some typing ;-) ).

Tomas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Pointers

Lee, John
In reply to this post by Daniel Franzini
As Vinzent says there are some problems with the dos (go32v2) - not sure that these are bad enough to prevent us doing a v2.0.x release shortly - the compiler & rtl seem to be fine. Anyway in the meantime the _daily_ dos v2.0.1 snapshot which has release + fixes functionality and the v2.1.1 snapshot which has the latest development functionality are working, can be downloaded from ftp.freepascal.org/ snapshot/ v20 or v21 respectively.

Regards John    
-----Original Message-----
From: [hidden email]
[mailto:[hidden email]]On Behalf Of Vinzent
Hoefler
Sent: 28 July 2005 14:48
To: FPC-Pascal users discussions
Subject: Re: [fpc-pascal] Pointers


On Thursday 28 July 2005 06:11, Leonhard Holz wrote:

> If you really want mode $13 you need to compile for dos, cause then
> windows sets up an old-style 8086 environment. Unfortunately the
> download page says:
>
> "Sorry, no Dos release yet. The Dos platform is missing a maintainer
> and is not of acceptable quality for 2.0."

Ok. My turn. :) This statement on the webpage is "not entirely
accurate".

There is a DOS maintainer, but unfortunately I haven't had much spare
time to work on that further. My latest tests were quite successful,
the "only" problem still is that you can't debug inside the IDE, it
still crashes due to - well, let me put it this way - interesting
reasons.

Demo programs and that stuff compiled and ran fine as far (there were
some problems with the DOS specific mouse support, though, but the
portable units worked).

I hope, once things are a little bit settled at work, I will have more
time to work on a real release quality version.


Vinzent.

--
public key: http://www.t-domaingrabbing.ch/publickey.asc


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal