Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-07

Pointers

12 messages · 9 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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)
Steve Williams
to Daniel Franzini
Daniel Franzini wrote 22 lines
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.
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??

Steve Williams wrote 8 lines
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)
Unknown author
to Daniel Franzini: Hi everyone I'm just trying to compile and execute a simple example from a graphics…

Maybe free pascal supports the "absolute" directive ;)

something like:

var
    SomeAddress : pointer absolute $a000;
Earlier message 87 lines
----- Original Message ----- From: "Daniel Franzini" To: 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)
Steve Williams
to Daniel Franzini: no, i didn't...but it worked and the program did compiled...now, it shows the following…
Daniel Franzini wrote 10 lines
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.
Elio Cuevas Gómez
to Daniel Franzini: no, i didn't...but it worked and the program did compiled...now, it shows the following…
Daniel Franzini wrote 7 lines
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.

John Coppens
to Daniel Franzini: Hi everyone I'm just trying to compile and execute a simple example from a graphics…
Show quoted text 5 lines
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

Leonhard Holz
to John Coppens

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

Daniel Franzini
to Leonhard Holz
Leonhard Holz wrote 6 lines
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

Show quoted text 6 lines
Leo _______________________________________________ fpc-pascal maillist - 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)
Vinzent Hoefler
to Leonhard Holz: If you compile a win32-program you will have a total virtual memory, that means that your…
Leonhard Holz wrote 6 lines
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.

Tomas Hajny
to Vinzent Hoefler
Show quoted text 24 lines
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

Lee, John

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

Earlier message 42 lines
-----Original Message----- From: 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.