🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #7851

Re: Writing to screen, no cursor movement

#7851
From: Jonathan Darren Nix
Date: Fri, 20 Oct 1995 18:51
46 lines
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)
Technical Details
Message-ID: <468r45$9gc@linda.teleport.com>
Path: arc1-ca.pugleaf.net!nntp.teleport.com!not-for-mail
References: <44rvl0$3pq@news1.wolfe.net> <45f80j$o5d@news.internet.com.mx>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nntp.teleport.com!not-for-mail
From: jonathin@teleport.com (Jonathan Darren Nix)
Newsgroups: comp.os.msdos.programmer,comp.lang.c,comp.lang.c++
Subject: Re: Writing to screen, no cursor movement
Followup-To: comp.os.msdos.programmer,comp.lang.c,comp.lang.c++
Date: 20 Oct 1995 11:51:49 -0700
Organization: Teleport - Portland's Public Access (503) 220-1016
Message-ID: <468r45$9gc@linda.teleport.com>
References: <44rvl0$3pq@news1.wolfe.net> <45f80j$o5d@news.internet.com.mx>
NNTP-Posting-Host: linda.teleport.com
X-Newsreader: TIN [version 1.2 PL2]