Sign in Join

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

Mailing lists / fpc-pascal / 2003-06

ocrt question

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Alex Dingle

Hello. I'm currently in the process of porting an old DOS game to linux using fpc and the ocrt module. The game makes extensive use of high ascii characters.

Sometimes, if I do : nwriteAC(nscreen, x, y, color, char1); char2 :=
byte((nReadScr(x,y,1))[1]);

char2 will be different from char1, because free pascal or ncurses is remapping the character before displaying it to the screen.

Unfortunately this breaks the program in certain places, as the program frequently relies on data read from the screen in its internal logic.

I am wondering if perhaps there is some method of querying for the "original character value" that was last written to some x,y position of a text window using an output procedure (such as write, writeln, or nwriteAC) and not the remapped value that was actually displayed there via ncurses.

Thanks.

-Alex

Rainer Hantsch
to Alex Dingle

Hi!

In your situation, I would insert a "virtual screen" between your application and execution of ncurses calls. All write opertions should also be stored into an array hereby, and when reading, use this array instead of a real read from ncurses.
This will be the only way to get around the re-mapping of ncurses.

Another way will be some more tricky:
o Write a translation function which works with a dynamic list. This list is initially empty, so there will be no translation. o On program start, write all characters in a loop (always only one character) into position 1/1 on the sreen, then read it back. If the result is different, the original and the read-back value are added to the list of the translation function.
o After that, proceed as usual with your program, but feed every read-back from screen through the translation routine.

This way your program should automatically "learn" the translation of ncurses and can reverse it, as long as there is noextreme conversion. Keep in mind that ncurses is able to translate a graphical character, i.e. a horizontal bar, into a normal minus character. In this case, _every_ minus character from read-back, including true minuses!!!, would be translated back into a graphical horizintal bar!

mfg

Ing. Rainer Hantsch

.---------------------------------------------------------------------. | \\|// Ing. Rainer HANTSCH - Hardware + Software | | (o o) Forget Windoze! -- We focus on L-I-N-U-X... | |--oOOo-(_)-oOOo------------------------------------------------------| | Ing. Rainer HANTSCH | mail: | | Khunngasse 21/20 | www: http://www.hantsch.co.at | | A-1030 Vienna | tel: +43-1-79885380 fax: +43-1-798853818 | | ** A u s t r i a ** | handy: +43-664-9194382 UID-Nr: ATU 11134002 | '---------------------------------------------------------------------'
Marco van de Voort
to Rainer Hantsch
Show quoted text 5 lines
In your situation, I would insert a "virtual screen" between your application and execution of ncurses calls. All write opertions should also be stored into an array hereby, and when reading, use this array instead of a real read from ncurses. This will be the only way to get around the re-mapping of ncurses.

Use unit Video, it also does wrap ncurses with a virtual screen construct.

Michael Van Canneyt
to Marco van de Voort
Marco van de Voort wrote 7 lines
> In your situation, I would insert a "virtual screen" between your application > and execution of ncurses calls. All write opertions should also be stored into > an array hereby, and when reading, use this array instead of a real read from > ncurses. > This will be the only way to get around the re-mapping of ncurses. Use unit Video, it also does wrap ncurses with a virtual screen construct.

It's already the second time I read this, but it is manifestly NOT true. ncurses is *not* used in the video unit, the video unit assumes an VT100 compatible display or uses the linux console device.

One *could* write an ncurses video driver for it, but there is none available at this moment.

Michael.

Alex Dingle
to Rainer Hantsch: Hi! In your situation, I would insert a "virtual screen" between your application and…
Rainer Hantsch wrote 6 lines
Hi! In your situation, I would insert a "virtual screen" between your application and execution of ncurses calls. All write opertions should also be stored into an array hereby, and when reading, use this array instead of a real read from ncurses.

A good idea, this is what I'm already doing, basically, the problem is that I will have to provide reimplimentations for write and writeln which is a moderate pain due to the variable number and type of parameters. (I'm new to pascal -- the only way I can see of doing this is with 'array of const' -- is there a better way?)

...

Show quoted text 19 lines
Another way will be some more tricky: o Write a translation function which works with a dynamic list. This list is initially empty, so there will be no translation. o On program start, write all characters in a loop (always only one character) into position 1/1 on the sreen, then read it back. If the result is different, the original and the read-back value are added to the list of the translation function. o After that, proceed as usual with your program, but feed every read-back from screen through the translation routine. This way your program should automatically "learn" the translation of ncurses and can reverse it, as long as there is noextreme conversion. Keep in mind that ncurses is able to translate a graphical character, i.e. a horizontal bar, into a normal minus character. In this case, _every_ minus character from read-back, including true minuses!!!, would be translated back into a graphical horizintal bar!

This is a cool idea, but I'm a bit scared about the possibility of what you call an "extreme" conversion occuring (this game uses a *lot* of high ASCII :) ) I suppose it probably wouldn't be too hard to try out...

-Alex