Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 21st, 2006, 4:00 PM   #1
matko
Newbie
 
Join Date: Sep 2005
Posts: 28
Rep Power: 0 matko is on a distinguished road
Smile EGA mode

Can anyone tell me wha next code doesn't compile:
#include <stdio.h>
#include <dos.h>

union REGS regs;

main(argc, argv)
int argc;
char *argv[];
{
	if (argc == 2)
		modeset(atoi(argv[1]));

	if (argc != 2)
		printf("EGA Mode is %d", modeget());
}

modeset(mode)
int mode;
{
	regs.h.a1 = mode;
	regs.h.ah = 0;
	int86(0x10, &regs, &regs);
}

modeget(){
regs.h.a1 = 0;
regs.h.ah = 0x0f;
int86(0x10, &regs, &regs);
return(regs.h.a1);
}

matko is offline   Reply With Quote
Old Jan 21st, 2006, 4:15 PM   #2
Kaja Fumei
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 134
Rep Power: 3 Kaja Fumei is on a distinguished road
The list of compiler errors would help so I don't have to go looking through dos.h
Kaja Fumei is offline   Reply With Quote
Old Jan 21st, 2006, 4:29 PM   #3
matko
Newbie
 
Join Date: Sep 2005
Posts: 28
Rep Power: 0 matko is on a distinguished road
--------------------Configuration: MODEGA - Win32 Debug--------------------
Compiling...
MODEGA.C
D:\zabavni_projekti\MODEGA.C(4) : error C2079: 'regs' uses undefined union 'REGS'
D:\zabavni_projekti\MODEGA.C(11) : warning C4013: 'modeset' undefined; assuming extern returning int
D:\zabavni_projekti\MODEGA.C(11) : warning C4013: 'atoi' undefined; assuming extern returning int
D:\zabavni_projekti\MODEGA.C(14) : warning C4013: 'modeget' undefined; assuming extern returning int
D:\zabavni_projekti\MODEGA.C(20) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(21) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(22) : warning C4013: 'int86' undefined; assuming extern returning int
D:\zabavni_projekti\MODEGA.C(26) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(27) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(29) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(29) : warning C4033: 'modeget' must return a value
Error executing cl.exe.

MODEGA.OBJ - 6 error(s), 5 warning(s)
matko is offline   Reply With Quote
Old Jan 21st, 2006, 7:22 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Looks like Visual C++ to me. No one's supported DOS.H for absolutely ages - it's ancient. Now, why would you want to check for EGA mode when you're running Windows?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 21st, 2006, 10:40 PM   #5
Kaja Fumei
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 134
Rep Power: 3 Kaja Fumei is on a distinguished road
1. Try "union _REGS" instead of "union REGS"
2. Try "_int86" instead of "int86".
3. You need to include stdlib.h to use atoi()
4. You either need to declare prototypes for modeget and modeset before they are used (or you could just move main to the bottom of the file).
5. modeget is declared to return a int. If you forgot to return the value, put it in. If there is nothing to return, the return type should be "void".
Kaja Fumei is offline   Reply With Quote
Old Jan 22nd, 2006, 1:04 AM   #6
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,198
Rep Power: 5 grumpy is on a distinguished road
Close Kaja. modeset() can be declared void with modern compilers. modeget() is returning a value.

The basic problem, as Ooble has said, is that this is code that worked with an ancient compiler not working with a modern compiler. The form of function definitions;
main(argc, argv)
int argc;
char *argv[];
were deprecated (a formal way of declaring them obsolete to discourage their use) in the 1989 C standard, in favour of;
int main(int argc, char *argv[])
style. This suggests the original code is at least 15 years old. One reason that the functions haven't been declared void is that compilers of that vintage did not support the void keyword.
grumpy is offline   Reply With Quote
Old Jan 22nd, 2006, 5:51 AM   #7
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 3 ivan is on a distinguished road
Quote:
Originally Posted by matko
--------------------Configuration: MODEGA - Win32 Debug--------------------
Compiling...
MODEGA.C
D:\zabavni_projekti\MODEGA.C(4) : error C2079: 'regs' uses undefined union 'REGS'
D:\zabavni_projekti\MODEGA.C(11) : warning C4013: 'modeset' undefined; assuming extern returning int
D:\zabavni_projekti\MODEGA.C(11) : warning C4013: 'atoi' undefined; assuming extern returning int
D:\zabavni_projekti\MODEGA.C(14) : warning C4013: 'modeget' undefined; assuming extern returning int
D:\zabavni_projekti\MODEGA.C(20) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(21) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(22) : warning C4013: 'int86' undefined; assuming extern returning int
D:\zabavni_projekti\MODEGA.C(26) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(27) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(29) : error C2224: left of '.h' must have struct/union type
D:\zabavni_projekti\MODEGA.C(29) : warning C4033: 'modeget' must return a value
Error executing cl.exe.

MODEGA.OBJ - 6 error(s), 5 warning(s)
We speak the same language
ivan is offline   Reply With Quote
Old Jan 22nd, 2006, 8:58 AM   #8
matko
Newbie
 
Join Date: Sep 2005
Posts: 28
Rep Power: 0 matko is on a distinguished road
Which is that ancient compiler? Where can I get(download) it?
Is Turbo C sufficient?
matko is offline   Reply With Quote
Old Jan 22nd, 2006, 2:07 PM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Why would you want to run this program within Windows anyway? EGA is a buzzword for a 640x350 resolution with 4-bit colour. It's been obsolete since 1990 at the very latest.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 24th, 2006, 8:05 AM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
An ancient compiler isn't necessarily good enough. The code emitted would in many cases be regurgitated at runtime by today's more protective OSes.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:57 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC