PDA

View Full Version : Screen Output



AbsolutelyWhite
10-02-2006, 04:57 PM
I've been working on Turbo Pascal, I recently started working on Delphi,
and I'm currently trying to understand it..... So i was wandering If there
is an easy way, to create a Window i.e 320x240, and then let me draw
in it, pixel per pixel? I want to make a 2D game, so i need this drawing
to be fast enough for some basic animation.

Oh, also can i do this from a console application? (I'm still used to turbo.. :P)


Thank you in advance.

LP
10-02-2006, 05:38 PM
Turbo Pascal generates DOS only executables (and you will need a fix for run-time error bug on fast machines). Indeed, you can try using interrupts to change video mode to 13h (320x200) and then accessing video memory directly (at A000:0000, if my memory is correct), but you may want to explore other options first. ;)

In order to create Win32 console executables (if that's what you are after), you can use either FreePascal or Delphi. Using either OpenGL and Direct3D you can draw images and stuff, but it's no longer made on pixel-by-pixel basis (though it's still possible), though it needs video hardware to do this. There is another option - using DirectDraw. It's rather outdated but if you really need only to manipulate pixels, this option may be worth exploring.

Nitrogen
10-02-2006, 06:06 PM
Those are good solutions but maybe not the easiest to get into especially straight from TP.

I would highly recommend you start with the good old windows GDI.
So yes you need a window, put down a TImage or similar and initalise it with a picture, then you can draw on it on a per pixel basis or copy another TImage onto it fairly fast if you keep the drawing area small...

Here are a few places to start:
- Look up the TBitmap.Scanline function in the Delphi help. It allows you to get the raw pixels of that picture.
- Google Delphi GDI or Delphi Canvas...

LP
10-02-2006, 06:09 PM
As an addition to Nitrogen's answer, check efg's Computer Lab (http://www.efg2.com/Lab/index.html) which contains many useful tutorials and information (including about Scanline properly).

AbsolutelyWhite
10-02-2006, 07:05 PM
Thank you, i now at least know where to start from! :)

AbsolutelyWhite
14-02-2006, 04:37 PM
I decided to do this the hard way, basically because I'm a fan of old dos modes :P So i'm going to use Pascal and some interrupts :)

Any idea how i can make this work in Free pascal ?


Procedure SetMCGA; { This procedure gets you into 320x200x256 mode. }
BEGIN
asm
mov ax,0013h
int 10h
end;
END;

It doesn't look like it works in FP :/

EugenioEnko
14-02-2006, 08:29 PM
this code will only work on 16-bit applications (only DOS).
I don't remember if Free Pascal compiles for DOS, or Windows 32bit Console application:?

I'm shure this stuff must work on Turbo Pascal

AbsolutelyWhite
15-02-2006, 12:42 PM
It works on Turbo Pascal, but I unfortunately can't run 16bit version applications. I work on a 64bit system :/ So i was looking for a way to do the same in Freepascal which compiles for DOS. (and uses 32bit)