Mail Archives: djgpp/2000/09/18/13:09:34
Here's a code compiled and linked with DJGPP. I'm working under WINDOWS
98 and, after a double click on the EXE file, I get this error message
: "LOAD ERROR: NO DPMI MEMORY"
This program should set video mode in 320X200 (13h graphic mode),then
show a PCX image file.
Running GO32-V2 I get:
DPMI memory available 68844 Kb
DPMI swap space available 58828 Kb
What's the problem ?
Thanks a lot,
Ivan
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
#include <math.h>
#include <dpmi.h>
#define PALETTE_MASK 0x3c6
#define PALETTE_REGISTER_WR 0x3c8
#define PALETTE_REGISTER_RD 0x3c7
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 200
#define PALETTE_DATA 0X3C9
FILE *dati;
unsigned char far *video_buffer = (char far *)0xA0000000L; // vram byte
ptr
unsigned char far doppio_buffer[64000];
unsigned char *var; // Array usato da Read_PCX //
unsigned char *tmp;
void Palette_Load(void);
void Read_PCX(void);
void Show_PCX(void);
void Delete_PCX(void);
void Set_Mode(void);
void Doppio_Buffering(void);
void Set_Text (void);
void Palette_Load()
{
unsigned index;
unsigned char *rosso,*verde,*blu;
fseek(dati,-768L,SEEK_END);
rosso=calloc(256,sizeof(unsigned char));
verde=calloc(256,sizeof(unsigned char));
blu=calloc(256,sizeof(unsigned char));
for(index=0;index<256;index++)
{
rosso[index]=(getc(dati)>>2);
verde[index]=(getc(dati)>>2);
blu[index]=(getc(dati)>>2);
} // ciclo for carica i valori negli array
for(index=0;index<256;index++){
outp(PALETTE_MASK,0xff);
outp(PALETTE_REGISTER_WR,index);
outp(PALETTE_DATA,rosso[index]);
outp(PALETTE_DATA,verde[index]);
outp(PALETTE_DATA,blu[index]);
} //ciclo for scrive nel registro valori estratti
free(rosso);
free(verde);
free(blu);
}
void Read_PCX()
{
unsigned count;
unsigned char num_bytes;
unsigned char data;
var=calloc(64000,sizeof(unsigned char)); // definirla variabile globale
//
fseek(dati,128L,SEEK_SET);
count=0;
while(count<=64000)
{
// get the first piece of data
data = getc(dati);
// is this a rle?
if (data>=192)
{
// how many bytes in run?
num_bytes = data-192;
// get the actual data for the run
data = getc(dati);
// replicate data in buffer num_bytes times
while(num_bytes-->0)
{
var[count++] = data;
} // end while
} // end if rle
else
{
// actual data, just copy it into buffer at next location
var[count++]= data;
} // end else not rle
} // end while
}
void Show_PCX()
{
unsigned i,z=0; // definire var variabile globale //
for(i=0;i<64000;i++){
doppio_buffer[z++]=var[i];
};
}
void Delete_PCX()
{
free(var);
}
void Set_Mode ()
{
__dpmi_regs r;
r.x.ax=0x13;
__dpmi_int(0x10, &r);
}
void Set_Text ()
{
__dpmi_regs r;
r.x.ax=0x03;
__dpmi_int(0x10, &r);
}
void Doppio_Buffering()
{
unsigned i;
for(i=0;i<64000;i++){
video_buffer[i]=doppio_buffer[i];
}
}
void main()
{
while(!kbhit())
{
Set_Mode();
dati=fopen("name.pcx","rb");
Palette_Load();
Read_PCX();
Show_PCX();
Doppio_Buffering();
Delete_PCX();
fclose(dati);
}
Set_Text();
}
- Raw text -