Thread View: comp.os.msdos.programmer
11 messages
11 total messages
Started by William White
Tue, 03 Oct 1995 18:33
Writing to screen, no cursor movement
Author: William White
Date: Tue, 03 Oct 1995 18:33
Date: Tue, 03 Oct 1995 18:33
20 lines
1521 bytes
1521 bytes
I'm programming in text mode, and would like to know how to write characters to the screen without moving the cursor. Just backing up the cursor one column after a character is written is not good enough. Here is what I need this for: I'm trying to write a program that does all screen I/O without the screen borders scrolling. I need to be able to write in column 80 on line 25 without the cursor going to the next line, thus making line 1 disappear off the screen. I would be eternally gratefull for any help anyone could give me. ---Will +----------------------------------------------------------------------+ | William White ®¯ Yakima, WA. ®¯ Hi-Country Foods Corporation | | Quality Assurance Lab Technician ®¯ Computer Analyst/Programmer | | ** We make it, you drink it, you love it ** | |Check out our new web page at http://www.wolfe.net/~hcfoods/index.html| | For my Public PGP key, please finger me at wcw@wolfe.net | +----------------------------------------------------------------------+
Re: Writing to screen, no cursor movement
Author: Solution Technology
Date: Tue, 03 Oct 1995 19:54
Date: Tue, 03 Oct 1995 19:54
22 lines
1180 bytes
1180 bytes
William White (wcw@wolfenet.com) wrote: : I'm trying to write a program that does all screen I/O without the screen : borders scrolling. I need to be able to write in column 80 on line 25 : without the cursor going to the next line, thus making line 1 disappear off : the screen. How about: Read the character in column 79. Delete column 79 twice. Insert the last character at 79. Insert the read character at 79 pushing the other character into 80. This should leave the cursor in column 80. Ugly isn't it? Of cource if you can get to the character mode memory directly. You can just store the byte at the proper address. Some systems have an API to get the buffer address. Ken Walter
Re: Writing to screen, no cursor movement
Author: Derick J.R. Qua-Gonzalez
Date: Wed, 04 Oct 1995 04:48
Date: Wed, 04 Oct 1995 04:48
25 lines
1522 bytes
1522 bytes
wcw@wolfenet.com (William White) writes: > I'm programming in text mode, and would like to know how to >write characters to the screen without moving the cursor. Just >backing up the cursor one column after a character is written is not >good enough. Here is what I need this for: > Since you posted it to comp.os.msdos.programmer as well, where this is topical (it is not in c.l.c and c.l.c++), I'll answer . . . /* M$-DOG SPECIFICS FOLLOW : SNIPPED FOR NEWSGROUP, EMAILED TO POSTER */ The quickest way is to directly access the video buffer. ... Best regards, Derick. -- +------------------------------------------------------------------------+ | Derick R. Qua-Gonzalez | ________ | | Department of Physics, California State University | \ / | | dqua@EarthLink.Net | \ / | | ``It is better to be hated for what one is, | \ / | | than loved for what one is not.'' (A. Gide) | 32 \/ USA| +-------------------------------------------------------------+----------+
Re: Writing to screen, no cursor movement
Author: Ed Schwartz
Date: Wed, 04 Oct 1995 16:47
Date: Wed, 04 Oct 1995 16:47
39 lines
1948 bytes
1948 bytes
In article <44rvl0$3pq@news1.wolfe.net>, from 3 Oct 1995 18:33:04 GMT William
White at wcw@wolfenet.com says...
>
> I'm programming in text mode, and would like to know how to write
characters
>to the screen without moving the cursor. Just backing up the cursor one
>column after a character is written is not good enough.
> Here is what I need this for:
>
> I'm trying to write a program that does all screen I/O without the
screen
>borders scrolling. I need to be able to write in column 80 on line 25
>without the cursor going to the next line, thus making line 1 disappear off
>the screen.
Write the caracter directly to the screen buffer, i.e. in your
case (line 25 column 80) write to B800:0F9E
I don't know, how to do that in C
>
> I would be eternally gratefull for any help anyone could give me.
^^^^^^^^^
two weeks should do !
Please note that there's a group alt.msdos.batch. If you don't receive it,
contact your news administrator.
--
Ed Schwartz
+------- e-mail --------------+--- s-mail ----+---- Phone/Fax ---------+
| schwartz@sunco.co.kp.dlr.de | DLR/RM-CTC | Tel.: (0)2203-601 2648 |
| Edwin.Schwartz@dlr.de | Linder Hoehe | Fax : (0)2203-601 2701 |
| | D-51147 Koeln | |
| http://www.dlr.de | Germany | |
+-----------------------------+---------------+------------------------+
Re: Writing to screen, no cursor movement
Author: Rich Grisier
Date: Wed, 04 Oct 1995 21:21
Date: Wed, 04 Oct 1995 21:21
11 lines
925 bytes
925 bytes
Hi Will--
There are a couple of things you could do here.
You could:
1. Set up view ports.
- This will allow you to printf to a section of the screen without
disrupting the area outside the viewport.
2. Use gotoxy command.
- This will position the cursor wherever you need it.
Hope this helps,
Rich
Re: Writing to screen, no cursor movement
Author: Yuval Koren
Date: Sat, 07 Oct 1995 21:44
Date: Sat, 07 Oct 1995 21:44
18 lines
876 bytes
876 bytes
all you should do is write directly to the screen buffer starting from adress b800:0000 . if you are programming in pascal that will really help you : var screen : array [1..25,1..80,1..2] of char absolute $b800:0000; now all you have to do if you want to put a character is : screen[y,x,1]:=' '; <-- character goes into the ' '. the last variable is to decide if you want to put there color or a char. (i thing 1 is for char, if not try 2) this is the fastest way! Yuval Koren shani@yuvalk.co.il
Re: Writing to screen, no cursor movement
Author: Anton Maurovic
Date: Sun, 08 Oct 1995 12:55
Date: Sun, 08 Oct 1995 12:55
53 lines
2259 bytes
2259 bytes
wcw@wolfenet.com (William White) wrote:
> I'm programming in text mode, and would like to know how to write characters
>to the screen without moving the cursor. Just backing up the cursor one
>column after a character is written is not good enough.
> Here is what I need this for:
>
> I'm trying to write a program that does all screen I/O without the screen
>borders scrolling. I need to be able to write in column 80 on line 25
>without the cursor going to the next line, thus making line 1 disappear off
>the screen.
>
Hi Will.
If you could let me know what language you're programming in, I could probably provide
you with more help. Otherwise I'll assume you're programming in C. In C/C++, you can
use the gotoxy() function to specify where you wish to relocate the cursor to, and
this allows you to put it on line 25 without scrolling the screen. Here is an example:
<- Cut here ->
/*
* A *VERY* simple program for placing text at the top and bottom of the screen.
* By Anton Maurovic, SYSLYNC Computing.
* syslync@dove.mtx.net.au
*
* Of couse, this code is NOT copywrite.
*
*/
#include <stdio.h>
void main(void)
{
gotoxy(1,25); //Relocate cursor on bottom of screen (line 25), against
//the left-hand side of the screen.
printf("This should be at the bottom of the screen");
gotoxy(1,1); //Relocate cursor in the top corner of the screen.
printf("This should be at the top of the screen");
}
<- Cut here ->
I hope this is what you wanted to know. If not, please e-mail me.
Yours sincerely,
Anton Maurovic.
syslync@dove.mtx.net.au
Re: Writing to screen, no cursor movement
Author: Antonio Perez Ayala
Date: Wed, 11 Oct 1995 00:05
Date: Wed, 11 Oct 1995 00:05
37 lines
2203 bytes
2203 bytes
wcw@wolfenet.com (William White) wrote: > I'm programming in text mode, and would like to know how to write characters >to the screen without moving the cursor. Just backing up the cursor one >column after a character is written is not good enough. > Here is what I need this for: > > I'm trying to write a program that does all screen I/O without the screen >borders scrolling. I need to be able to write in column 80 on line 25 >without the cursor going to the next line, thus making line 1 disappear off >the screen. > I would be eternally gratefull for any help anyone could give me. > ---Will >+----------------------------------------------------------------------+ >| William White ®¯ Yakima, WA. ®¯ Hi-Country Foods Corporation | >| Quality Assurance Lab Technician ®¯ Computer Analyst/Programmer | >| ** We make it, you drink it, you love it ** | >|Check out our new web page at http://www.wolfe.net/~hcfoods/index.html| >| For my Public PGP key, please finger me at wcw@wolfe.net | >+----------------------------------------------------------------------+ Here is how to do it in Turbo-C; if you are using anoter compiler, must be an equivalent. Output the last char in the line throught BIOS INT 10H function 10 using the Turbo-C function int86: #include <dos.h> #define VIDEO 0x10 /* BIOS interrupt number = Video */ union REGS cpu_reg; cpu_reg.h.ah = 10; /* function = Write Character at Cursor */ cpu_reg.h.bh = 0; /* video page number, usually zero */ cpu_reg.x.cx = 1; /* num of SAME char. to output, usually 1 */ cpu_reg.h.al = 'X'; /* char. to output */ int86(VIDEO,&cpu_reg,&cpu_reg);
Re: Writing to screen, no cursor movement
Author: Christopher Field
Date: Fri, 13 Oct 1995 09:11
Date: Fri, 13 Oct 1995 09:11
6 lines
996 bytes
996 bytes
To carry on with the writing to screen with pointers method, text memory begins at B800:0000 (in hex, of course). It's then either character followed by colour or the other way around. Sorry, but I forget at the moment. Anyway, this will do the job without moving the cursor. - Chris Field (se1cf@dmu.ac.uk)
Re: Writing to screen, no cursor movement
Author: Rotbart
Date: Sun, 15 Oct 1995 03:17
Date: Sun, 15 Oct 1995 03:17
47 lines
1951 bytes
1951 bytes
wcw@wolfenet.com (William White) wrote:
> I'm programming in text mode, and would like to know how to write characters
>to the screen without moving the cursor. Just backing up the cursor one
>column after a character is written is not good enough.
> Here is what I need this for:
>
> I'm trying to write a program that does all screen I/O without the screen
>borders scrolling. I need to be able to write in column 80 on line 25
>without the cursor going to the next line, thus making line 1 disappear off
>the screen.
>
Hi,
The best and fastest way to write to the screen without scrolling or beeping
is by writing directly to the screen's memory.
This allows you to display control characters on the screen such as ^G which
beeps when using terminal writes.
In Turbo Pascal this is very easy:
(This is in Turbo Pascal because I have this snippet already programmed only in
TP, This can be done in any language)
Type
Cell = Record
Ch : Char; { Character }
Attr : Byte; { Attribute }
End;
ScreenType = Array [1..25, 1..80] of Cell;
Var
Screen : ScreenType Absolute $B800:$0000;
Procedure WriteFast(x,y : Integer;
str : String);
Var
i : Integer;
Begin
For i := 1 To Length(str) Do Begin
Screen[y,x+i-1].char := str[i];
Screen[y,x+i-1].attr := TextAttr;
End;
End; { WriteFast. }
Begin
Screen[25, 80].Ch := #14;
WriteFast(1, 78, '!!');
End.
Re: Writing to screen, no cursor movement
Author: Jonathan Darren Nix
Date: Fri, 20 Oct 1995 18:51
Date: Fri, 20 Oct 1995 18:51
46 lines
2435 bytes
2435 bytes
Antonio Perez Ayala (apa@mail.internet.com.mx) wrote:
: wcw@wolfenet.com (William White) wrote:
: > I'm programming in text mode, and would like to know how to write characters
: >to the screen without moving the cursor. Just backing up the cursor one
: >column after a character is written is not good enough.
: > Here is what I need this for:
: >
: > I'm trying to write a program that does all screen I/O without the screen
: >borders scrolling. I need to be able to write in column 80 on line 25
: >without the cursor going to the next line, thus making line 1 disappear off
: >the screen.
: > I would be eternally gratefull for any help anyone could give me.
: > ---Will
Perhaps your compiler is MSVC++ V1 compatible, in that case, you
could do somthing like this;
(char far *)TextMem = (char far *)0xB8000000L;
/* Declared as char far * to write/read character attribute pairs
seperately */
Then you could convert an X, Y screen position into a linear address
by doing the following;
TextMem[(y<<7+y<<5)+x] = desired_char;
TextMem[((y<<7+y<<5)+x)+1] = desired_attrib;
The preceding formula is used because there are 160 bytes that make up
the width of the screen in linear memory. This is because the video
memory is organized in character/attribute pairs. (2 bytes) and 2*80 is
160. (y<<7+y<<5)+x == (y*128+y*64)+x == (y*160)+x {Shifting is faster}
Using the above formula, you can read/write any character or attribute
on screen. You can use a similar formula, to read/write any pixel in
other video modes, such as _320x200_[(y<<8+y<<6)+x]=color;
Hope this helps.
Jonathan Nix
jonathin@teleport.com
--
jonathin@teleport.COM Public Access User -- Not affiliated with Teleport
Public Access UNIX and Internet at (503) 220-1016 (2400-28800, N81)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads