Link to home
Start Free TrialLog in
Avatar of _Katka_
_Katka_Flag for Czechia

asked on

URGENT! Is there a possibility to use classic 80x25 (or alternative 80x30) in Delphi 8 for .NET ?

Hi,

How to emulate textmode in Delphi 8 for .NET ? I'm not talking about console here, but about classic direct memory access to 0xB800.
I'm aware that it's not possible to achieve directly, but what about some windows APIs, DirectX maybe ?
What I need is true textmode, not just graphical emulation thru sprites (like 640x400) ?

I don't know, so any thought will be appreciated..

regards,
Kate
Avatar of Wim ten Brink
Wim ten Brink
Flag of Netherlands image

Sorry, but in the 32-bits memory model you don't have direct access to the video memory. It doesn't exist. Use a console instead, which is technically speaking a true textmode environment.

And, btw... The old DOS textmode screen never really existed. These were still graphics and it was even possible to draw things in the textmode! I've seen sprite animations and a "graphical" game in textmode. This was just a matter of redefining the sprites that were used for the characters... And at 0xB000 you just said in which order the sprites should be.

It's even worse in your situation. You're using Delphi 8 which will provide you even less access to sensitive memory areas.

But what are you trying to do anyway?
Avatar of _Katka_

ASKER

Thanks, for quick answer..but:

1) I'm the gal who was writing such graphical demos for textmode.. And yeah, it's done thru reserving some characters to fontset change..
2) I'm aware that text-mode is in fact special graphical mode for CGA,EGA internal..
3) Console lacks the ability to manipulate blocks of text and anyway is practically useless unless you just want to writeln the text forward..
4) I'm also aware that there's no possibility to access text/graphical memory directly thru interrupts or mem[] like in good old times..
5) I know that there's possibility to use alternate compilers like (Free Pascal, which is in my current use) which supports the direct memory access even when in LMA..

What I'm trying to do:

1) To get access to true text-mode (to be precise, the one your bios is using) withing Delphi 8..
2) Alternately access any kind of text-mode (I'll be happy even with 640x400) with possibility to directly emulate text-mode (fontset generated as sprites)
3) These conditions for any of those modes must be satisfied:

 3a) have direct access (doesn't mean direct access to memory, but direct access to what I see)
 3b) It have to be able to manipulate blocks of pixels or characters
 3c) Manipulation with single pixel, character
 3d) support color palettes (truecolor doesn't mind) for single element

Practically I want to be able perform the way the FAR Manager did: http://farmanager.com/screens.asp

I'm not working on file manager, but this is the closest example of abilities I need (text-mode related)
Be aware the FAR Manager is written in 32-bit language. I need to know the way he get the access to such textmode (it's not console definitelly).

Kate :)

ASKER CERTIFIED SOLUTION
Avatar of Wim ten Brink
Wim ten Brink
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _Katka_

ASKER

I'm prepared to write any wrapper to whatever that gives me described abilities with text-mode.. Now in consideration (sorted by elegance):

1) DirectX - DirectDraw wrapper for emulation of text-mode (I'm not much into DirectX and it'll require much of work + I can't find any API for Delphi 8)
2) Your opinion about console - (I'm still not sure if it supports simple GetChar(X,Y):Char, SetChar(X,Y,Char), SetScreen(Buffer) like commands)
3) In case the of emergency (if nothing will work) there's always a standart TCanvas :))
4) EGA/VGA is still inside, so there is always a way to get thru any system to it (I'm not sure how and moreover it causes an instability)

But I'm convinced there's GDI-based textmode, across all versions of Windows.. It's true textmode enough for me ;)

What about that console, is there any proof that is it at least capable of (as mentioned) GetChar,SetChar,SetScreen,GetScreen,SetColor,GetColor,SetBKColor,GetBKColor,ChangeCharacterSet meta-code commands (I figured out that those are all I practically need) ?

Kate :)
Avatar of BJThomsen
BJThomsen

Write the functions in a non .net dll and use as unmanaged code in Delphi 8?

Don't know much about it, just something I've heard.
Goto http://www.overbyte.be/frame_index.html

Download the ICS package, install it, and you will notice that there is a Terminal Emulator component installed. Check out the source code (emulvt.pas) to see how a component is derived from TCustomControl and is even set to handle ANSI emulation (coloring, blinking, etc).



DragonSlayer.
Avatar of _Katka_

ASKER

Hi,

to BJThomsen: Sounds promising have you got some further info ?

to DragonSlayer:

1) ICS package for Delphi 8 .NET doesn't contain TEmulVT component
2) It's not capable of almost none of needed abilities

any other suggestions ?

btw: I downloaded DirectX 9 SDK and MDX is working under Delphi 8 :) but I'm total newbie here and it's not definitely text-mode :(

Kate
Using consoles mentioned above will do everything you need to do.  I am also unclear as to whether Delphi 8 allows access to win32 functions at all, but if it does, then you can do all those functions you mentioned pretty easily.  

Just scanning over it quickly.  All the "Set" functions you need can be done with WriteConsoleOutput() and all the "Get" functions can be done with ReadConsoleOutput().

I would suggest trying that first, as it'll probably do everything you need, before trying to emulate a console mode completely.  
Avatar of _Katka_

ASKER

to Tyris:

That's for sure.. but I downloaded mentioned components and the package for Delphi 8 .NET doesn't contains TEmulVT component.. So I was unable to test it properly,
I determined it has no functionality for me just from sources.. that's (I admit) not sufficient, but anyway it simply doesn't compile under D8..

Kate
Oops, I was talking about Workshop_Alex's response.  Using the Console functionality he lists given in Win32 will allow you to do all the functions you listed.  I don't believe .NET has sufficient support for the Console, so you may have to use unmanaged code to accomplish this.  
Avatar of _Katka_

ASKER

Well I've found some more information about that console and it seems you both were right, but what is needed to be downloaded in order to get it functional ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _Katka_

ASKER

Ok.. this sounds really promising I linked GetStdHandle function externally

function GetStdHandle(nStdHandle:Longword):Longint; external 'Kernel32.dll';

and called:

begin
  inHandle:=GetStdHandle(Longword(-10));
  outHandle:=GetStdHandle(Longword(-11));
end;

Is it possible that handles are equal to 0 ?
Do I have to initialize console first somehow (actually it's just common {$APPTYPE CONSOLE} console) ?

Kate
Yes, you should use $APPTYPE CONSOLE.  After you get the handles, they should be different values, though very low values.  Once you successfully get the handles, you should be able to use any of the Console functions that are listed on the MSDN site above.  

Tyrsis
Avatar of _Katka_

ASKER

Both values are zero, but anyway I was able to SetConsoleCursorPosition and WriteConsole using these handles ;) that's positive..
In the end, Windows unit is able to treat those console functions as managed code so there's no need to manually link the Kernel32.dll.

My last question is how to get use of WriteConsoleOutput (I'm not able to setup data buffer properly it's IntPtr [equivalent of managed pointer]) ?

Kate
Avatar of _Katka_

ASKER

Now I noticed, is there a way to change fontset ?
It's probably easier if you used the following functions:

WriteConsoleOutputCharacter()
GetConsoleScreenBufferInfo()
SetConsoleCursorPosition()

These will allow you to move the cursor around the screen and output characters without having to worry about RECTs.  Experiment with these functions, but I think you'll find everything you need to do in the console can be done with them.  

Tyrsis
Avatar of _Katka_

ASKER

The point about WriteConsoleOutput is that I want to generate a buffer (in memory) and then just paste it to the whole console screen..It's faster and in fact single writing of elements is not needed.

What about that fonset change, it'll be also possible to create my user truetype font, but I don't see any SetCurrentConsoleFont function (this is the most important element without it, it has no meaning to me) ?

Kate
Sadly you can't change the fontset in console.  It is a user selectable option when running a console app, but you can't set it pragmatically.  

Basically, if you want a full screen console app, with the ability to change fonts, you'll have to use DirectX, which I can see being a nightmare.  If you don't need it to be full screen, then you can just emulate it by directly drawing the characters onto a canvas, which would be a lot easier.

Sorry I could not be of more assistance.

Tyrsis



Avatar of _Katka_

ASKER

Well, never mind, I'll split up points 160 Tyrsis/75 Workshop_Alex even I'll use managed DirectX 9 in the end, it's pretty easy to use and moreover it'll bring me on the edge of programming (which is cool :), almost no examples provided on net, yet ,:-/). Somehow MDX is much friendlier than its predecessors thus I'm able to grasp it. Actually full library for emulation of textmode works pretty well and HW accelerated. It is NOT an old text-mode but (my gosh) I have to move forward ;).

Thank you all very much for your opinions..

regards,
Kate