[coding] console screen memory

G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

How under WIN 2000 get pointer to memory (or something that simulates
it, something like 0xb800 in DOS) that stores data displayed in console?

(I'm new at the newsgroup; I'm propably going to write whole rg engine;
I don't know if it's proper newsgroup to ask about rg coding but I
haven't found anything better)
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Kolczuga wrote:

> How under WIN 2000 get pointer to memory (or something that simulates
> it, something like 0xb800 in DOS) that stores data displayed in console?

Didn't use it, by have a look at "CreateConsoleScreenBuffer"
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

If so, maybe you know if how to make the scrollbar not to show? Or maybe
just you have some parts of code?
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

And some other problems that occured just minutes ago:
- why when I'm switching screen buffers number of wisible lines on the
screen is changing?

- how to make cursor to dissapear and letters not to show when I'm
writing something?

I know that those are basics, but I haven't worked with damn WIN2K text
mode that way yet.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Kolczuga wrote:
> How under WIN 2000 get pointer to memory (or something that simulates
> it, something like 0xb800 in DOS) that stores data displayed in console?

Don't. Use Curses instead. What language 'r you using?

> (I'm new at the newsgroup; I'm propably going to write whole rg engine;
> I don't know if it's proper newsgroup to ask about rg coding but I
> haven't found anything better)

"roguelike.development" -- how much more specific would have the
newsgroup be... "rec.games.roguelike.development.coding.console"? ;-P

Aaah, another Pole from out secret goverment project to take over the
wo.... uh. Nevermind ;-P

--
At your service,
Kornel Kisielewicz (charonATmagma-net.pl) [http://chaos.magma-net.pl]
"Oh come on. We both know the truth about this game --
vapourware." -- Anathiel about GenRogue
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Dear few remaining non-Polish readers of r.g.d.r, this revealing piece
of conversation has just come to my attention:

Kornel Kisielewicz wrote:
> Aaah, another Pole from out secret goverment project to take over the
> wo.... uh. Nevermind ;-P

I understand that their plan involves creating really good roguelikes.
Games that are so compelling that people will refuse to leave their
computer for long enough to do any useful work. As we all know,
computer gamers form a major part of the world's IT workforce. With
this population practically eliminated, software updates will not get
installed, backups will not be made, users will be as clueless as ever,
servers will crash, satellites will leave their orbit, delivery trucks
will not find their destinations and the world economy will collapse. A
diabolic plan indeed.

Ladies and gentlemen, there's only one way to stop the Polish elite
programmers from world domination. We need to create these
"super-roguelikes" first and release them to the internet. The choice
among so many great roguelikes will confuse players and render them
incapable of deciding on any single one of them. Coders of the world,
if you believe in gameplay, tonight you must warm up your compiler or
script interpreter. Boot up your terminal and/or GUI interface and
launch vi (or even emacs). Use whatever programming language creates
the most flamewars on Usenet, like C#, C, C++, C--, !C or C:\. But for
the sake of Anhur, start hacking! Long live the @!!

..
..
..

..
..
..

(For the benefit of the dumb among us, I would like to point out that
this entire post is an attempt at a joke. Maybe I should hide a smiley
somewhere to make this clear.)
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On Sat, 30 Jul 2005 22:48:55 +0200, Kolczuga <burakozol@wp.pl> wrote:

>If so, maybe you know if how to make the scrollbar not to show?

By setting the appropriate size for the buffer using
SetConsoleScreenBufferSize().

>Or maybe just you have some parts of code?

Generally, it's better to write your own display wrapper containing the
most commonly used functions. As you may discover, it is not always
possible to set the display size to whatever you want, and you'll have to
make due with whatever's available.

At the worst case, you would be able to wrap one display library withtn a
week. (e.g. have a curses wrappep for a 7DRL project.)
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On Sat, 30 Jul 2005 23:05:05 +0200, Kolczuga <burakozol@wp.pl> wrote:

>And some other problems that occured just minutes ago:
>- why when I'm switching screen buffers number of wisible lines on the
>screen is changing?

There's no visible reason on why it should. The only reason the number of
visible lines should change is if there is a change in the window size, or
if the program requested an explicit change.

Unless if you mean pressing ALT-ENTER - in that case, you have to use call
system("mode con: lines=25") or system("mode con: lines=50") to force the
number of lines you want.

>- how to make cursor to dissapear and letters not to show when I'm
>writing something?

Windows has a getch() function that does not echo input text to the screen.

You can also use SetConsoleCursorInfo() to change the cursor.

>
>I know that those are basics, but I haven't worked with damn WIN2K text
>mode that way yet.

You should try to get the copy of the Windows KP SDK documentation if you
don't already. As msot of the related functions are together, you should
have no problem finding out what you want.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

HA HHHA HHHAAAAH! TOO LATE!! TOO LATE!!
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

I have actually used the windows console functions myself. They work
fairly well if you can work out which functions to use. So for anyone
interested, here are a few of the functions I wrote...



#include <windows.h>
#include <iostream>
#include <string>

using namespace std;

typedef unsigned char uchar;

HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
COORD cZero = {0, 0};

string next;

void initText()
{
AllocConsole();
SetConsoleMode(hStdIn, ENABLE_PROCESSED_INPUT);
}

void cls()
{
DWORD count;

CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hStdOut, &csbi);

FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X *
csbi.dwSize.Y, cZero, &count);

SetConsoleCursorPosition(hStdOut, cZero);
}

void setPos(uchar xpos, uchar ypos)
{
COORD c = {xpos, ypos};
SetConsoleCursorPosition(hStdOut, c);
}

void resetPos()
{
SetConsoleCursorPosition(hStdOut, cZero);
}

void putStr(string s, uchar xpos, uchar ypos)
{
COORD c = {xpos, ypos};
SetConsoleCursorPosition(hStdOut, c);
cout << s;
}

void putStr(string s, uchar xpos, uchar ypos, uchar col)
{
COORD c = {xpos, ypos};
SetConsoleTextAttribute(hStdOut, col);
SetConsoleCursorPosition(hStdOut, c);
cout << s;
}

void putChar(char ch, uchar xpos, uchar ypos)
{
COORD c = {xpos, ypos};
SetConsoleCursorPosition(hStdOut, c);
cout << ch;
}

void putChar(char ch, uchar xpos, uchar ypos, uchar col)
{
COORD c = {xpos, ypos};
SetConsoleTextAttribute(hStdOut, col);
SetConsoleCursorPosition(hStdOut, c);
cout << ch;
}

void putStr(string s, uchar col)
{
SetConsoleTextAttribute(hStdOut, col);
cout << s;
}

INPUT_RECORD readKeyboard()
{
INPUT_RECORD input;
DWORD count;

ReadConsoleInput(hStdIn, &input, 1, &count);
FlushConsoleInputBuffer(hStdIn);

return input;
}

uchar readKey()
{
INPUT_RECORD input;
DWORD count;

ReadConsoleInput(hStdIn, &input, 1, &count);
FlushConsoleInputBuffer(hStdIn);

if(input.Event.KeyEvent.bKeyDown)
return input.Event.KeyEvent.uChar.AsciiChar;
else
return 0;
}

void setTextColor(uchar col)
{
SetConsoleTextAttribute(hStdOut, col);
}