GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Feb-2004, 11:08
ambeco ambeco is offline
New Member
 
Join Date: Feb 2004
Posts: 23
ambeco is on a distinguished road
Question

dot on colored screen


I'm teaching myself C++, and I am having trouble making the screen all one color. I've tried every combination of pointers that I could think of to no use. What is the correct code? Heres my problem:
CPP / C++ / C Code:
memset(0xa000, color, 0xffff);
Anyone know how to point memset at the screen?

[EDIT]
These are the exact errors:
Error E2034 pixel.cpp 32: Cannot convert 'int' to 'void *' in function cls(unsigned char)
Error E2342 pixel.cpp 32: Type mismatch in parameter '__s' (wanted 'void *', got 'int') in function cls(unsigned char)

[/EDIT]
  #2  
Old 10-Feb-2004, 11:24
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Hi ambeco.

I can help you with your error codes, but not your application.

Basically in C/C++ you may need to use typecasting at times to tell the function what it is you are passing. The memset function is defined as:
CPP / C++ / C Code:
void *memset(void *s, int c, size_t n);
So when you pass a literal, ie: 0xa000 it thinks that it is an integer. There is nothing that tells it that it is not. So if you try:

CPP / C++ / C Code:
memset((void*) 0xa000, color, (size_t)0xffff);

This will tell the compiler that this is actually an address and not just an integer.

Now, on to your application. Have you considered looking at conio.h or a similar library. I am impressed by your agressiveness and thought process in doing this. But unless you are extremely sure of what you are doing, I think memset could be a little dangerous.
  #3  
Old 11-Feb-2004, 10:07
ambeco ambeco is offline
New Member
 
Join Date: Feb 2004
Posts: 23
ambeco is on a distinguished road
Talking

Thanks!


Thanks for the code dsmith! You gave me what I needed, I'm doing fine with the rest of the coding, so far. If I have more problems, I will post them, but I think that was the last thing. Thanks so much!
  #4  
Old 11-Feb-2004, 10:32
ambeco ambeco is offline
New Member
 
Join Date: Feb 2004
Posts: 23
ambeco is on a distinguished road
I'm not sure what happened, but my program crashed. I was still working on how to alter the value of the location, so I had turned that part into notes, but it still crashed after compiling correctly. I'm sorry to ask this, but I cant find any errors. My only guess is something is wrong with te way I'm using geninterrupt. Heres the entire coding:
CPP / C++ / C Code:
#include <dos.h>;
#include <string.h>;

void setmcga();	
void settext();
void cls(unsigned char color);
//void pset(int x, int y, unsigned char color);
void geninterrupt(int intr_num); 

int main()
{
	setmcga();
	cls(1);
//	pset(2,2,2);
	return 0;
}

void setmcga()			//puts screen in color mode (320x200x256)
{						//base address is a000h, next 64000 bytes are screen
    _AX = 0x0013;
    geninterrupt (0x10);
}

void settext() //puts screen into text mode
{
    _AX = 0x0003;
    geninterrupt (0x10);
}

void cls(unsigned char color)
{
	memset((void *) 0xa000, color, (size_t)0xffff);  //clears screen in color
}

//void pset(int x, int y, unsigned char color)
//{
//	memset((void *) 0xa000 + x + (y * 320),color,1);
//}
I would really be greatful if someone could help me locate my error.
  #5  
Old 11-Feb-2004, 10:56
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Ambeco,
I may not be able to help much. I haven't screwed around with dos interrupts since the early 90's. You should let us know what compiler/OS you are using as well.

Is geninterrupt a function that you have written? Is it linked from an external source? Obviosly the linker isn't complaining so the function is somewhere.

Once again, I am all for writing your own low-level libraries, but have you had a chance to look at the conio library and whether your compiler includes it?
  #6  
Old 12-Feb-2004, 02:20
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
What OS are you using? If you are using DOS, the address of the screen is 0xB000 for mono, 0xB800 for graphics.

If Windows Xp/NT/2K, I don't believe you have direct access to the screen. From a console window though the mono screen is available. I don't know if you can get to the graphics screen or not.
  #7  
Old 12-Feb-2004, 10:05
ambeco ambeco is offline
New Member
 
Join Date: Feb 2004
Posts: 23
ambeco is on a distinguished road
Post

I'm using the Borland Compiler in WinXP Pro, and I got the code from http://www.cprogramming.com/tutorial/tut1.html by Denthor of ASPHYXIA. This is beginning to seem overly complicated, as well as not working. So, how do I learn how to use a header file (say... conio) I looked through it, and it doesnt not make sense to me. Is there a place on the net that has usages of common C++ commands that you know of? Or how do I learn? Because that way I could learn how to use other ones that came with the compiler as well. Thanks!
  #8  
Old 12-Feb-2004, 10:24
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Hi ambeco.

I followed the link that you gave and it contains some really good code, but it is really geared towards the DOS environment. Like WaltP says, you don't have direct access to the screen in XP and your program is probably being prohibited from writing to that memory address.

conio.h does alot of this type of screen processing for you and is written specifically to work with your OS. For your application it is going to work with XP in a console window. As far as learning more about it there are several things you can do.
  • Google for conio.h. I found this link quite quickly which seems to be pretty good.
  • Look at this thread. It is long, but this guy is using basic conio functions in his galaga-type game.
  • Usually your compiler should ship with pretty good documentation. Alot of the time I will scan through a header file to find a function that does something like I think I need and then look in the documentation for that function.

I hope this gets you going...
  #9  
Old 12-Feb-2004, 18:47
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by dsmith
[*]Google for conio.h. I found this link quite quickly which seems to be pretty good.
This link is for cc65, a C compiler for 6502 based systems. No guarantee the documentation is accurate for Borland.

Which compiler version are you using? If it's not 5.5 you probably have a help file that describes the functions in conio.h.

The following functions are in conio.h (from bcb5rtl.toc)
3 Conio.h
4 clrscr=clrscr
4 delline=delline
4 getch=getch
4 getche=getche
4 getpass=getpass
4 gettext=gettext
4 gettextinfo=gettextinfo
4 gotoxy=gotoxy
4 highvideo=highvideo
4 insline=insline
4 kbhit=kbhit
4 lowvideo=lowvideo
4 movetext=movetext
4 normvideo=normvideo
4 putch=putch
4 puttext=puttext
4 _setcursortype=_setcursortype
4 textattr=textattr
4 textbackground=textbackground
4 textcolor=textcolor
4 textmode=textmode
4 wherex=wherex
4 wherey=wherey
4 window=window

The help file bcb5rtl.hlp documents the functions. I found the help file hidden on the Borland site. If I can find the link I'll post it.
  #10  
Old 12-Feb-2004, 19:02
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Link to documentation for Borland 5.02 and 5.5
http://info.borland.com/techpubs/borlandcpp/
 
 

Recent GIDBlogObservations of Iraq by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
nvidia fx5200 128mb black screen!! cpu-loser Computer Hardware Forum 32 21-Jul-2004 18:28
Operation Flashpoint blank screen after mods pcxgamer Computer Software Forum - Games 0 15-Jan-2004 10:50
screen saver rickdragon C++ Forum 0 18-Nov-2003 02:48
screen resolution zuzupus Web Design Forum 0 29-Jul-2003 02:50

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:45.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.