nice_group

Hi

I am trying to read the VGA palette color table using the following code in c:

#include <limits.h>

#include <stdlib.h>

#include <string.h>

#include <conio.h>

#include <ctype.h>

#include <stdio.h>

#include <dos.h>

#ifdef __cplusplus

extern "C" {

#endif

//#include <iostream>

//using namespace std;

typedef struct RGB_t{

unsigned char r;

unsigned char g;

unsigned char b;

unsigned char a;

}RGB_t;

typedef RGB_t Palette[256];

/*void SetMode13h(void)

{

union REGS regs;

regs.w.ax = 0x0013;

int386(0x10, &regs, &regs);

}*/

void GetPalette(Palette pal, int startColor, int endColor)

{

int index;

/* Set the palette data */

for (index = startColor; index <= endColor; index++) {

outp(0x3C7, index);

pal[index].r = inp(0x3C9);

pal[index].g = inp(0x3C9);

pal[index].b = inp(0x3C9);

}

}

int main()

{

int i;

int n;

Palette pal;

GetPalette(pal,0,256);

printf("Data display \n");

printf("Rea Green Blue\n");

for (i=0;i<256;i++)

{

printf("%u %u %u\n",pal[ i ].r,pal[ i ].g,pal[ i ].b);

}

getchar();

return 0;

}

#ifdef __cplusplus

};

#endif

and i have this error when i compile it in VC++ 8

1>Linking...

1>P_test1.obj : error LNK2019: unresolved external symbol _inp referenced in function _GetPalette

1>P_test1.obj : error LNK2019: unresolved external symbol _outp referenced in function _GetPalette

1>C:\Documents and Settings\User\Desktop\Reem\Thesis\Videocrd\palette1\Debug\palette1.exe : fatal error LNK1120: 2 unresolved externals

any suggestions please



Re: Visual C++ General Read VGA Palette

Peter Ritchie

try using "_outp"/"_inp" rather than "outp"/"inp".




Re: Visual C++ General Read VGA Palette

nice_group

Thanx Peter for quick replying

thats fix my error.. but when i run the program i have this error now:

Unhandled exception at 0x102708ab (msvcr80d.dll) in palette1.exe: 0xC0000096: Privileged instruction.

'palette1.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.

First-chance exception at 0x102708ab (msvcr80d.dll) in palette1.exe: 0xC0000096: Privileged instruction.

Unhandled exception at 0x102708ab (msvcr80d.dll) in palette1.exe: 0xC0000096: Privileged instruction.

and its stop in (outp.asm):

_outp proc

xor eax,eax

mov dx,word ptr [esp + 4]

mov al,byte ptr [esp + 8]

out dx,al

ret

any idea!!..

note: my os is windows xp





Re: Visual C++ General Read VGA Palette

Peter Ritchie

The other problem, as documented at http://msdn2.microsoft.com/en-us/library/y7ae61bc(VS.80).aspx is these commands cannot be used from user code in Windows NT or better. It wasn't clear what type of code you were trying to run.

You will probably need to use a library that provides equivalent functionality to user mode code, like http://www.zealsoftstudio.com/ntport/






Re: Visual C++ General Read VGA Palette

nice_group

Thanx Peter for your help again..

i figure out what is the problem now and will see if this library will help me





Re: Visual C++ General Read VGA Palette

AZEH


hello friends,
i do hve this problem and i need help. So if you will help me i will be glad. When my computer boot it brings this message ( the exception privileged instruction) . (0xc0000096) occured in the application location 0x100141F7.
please do help me .

Thanks
sincerely