Mail Archives: djgpp/1996/05/04/22:57:03
Xref: | news2.mv.net comp.os.msdos.djgpp:3438
|
From: | edoardo AT smartcom DOT it (Edo)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Memory problem
|
Date: | Fri, 03 May 1996 16:40:54 GMT
|
Organization: | Smartcom S.r.l.
|
Lines: | 98
|
Message-ID: | <4mdcv7$2qgu@venere.inet.it>
|
Reply-To: | edoardo AT smartcom DOT it
|
NNTP-Posting-Host: | pc3.smartcom.it
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hi!
Can anyone help me with this little piece of code? This program put a
pixel into a "virtual" screen and then copy the virtual screen into
the vga...but it doesn't work! I think that it is due to my low skill
with DJGPP programming (I have downloaded DJGPP only 3 days ago and
this is my first DJGPP proggy, but I've coded a mini 3d engine with
BorlandC ). When I run the prog, the following msg appears:
Page fault at eip=000015c2, error=0004
eax=00000039 ebx=0004c0a0 ecx=00003e80 edx=00006400 esi=00000000
edi=000a0000
ebp=00049cb0 esp=00049cae cs=00a7 ds=00af es=00bf fs=008f gs=00bf
ss=00af
Call frame traceback EIPs:
0x000015c2
0x00001658
0x00001bc7
I think that the wrong instruction is:
vr_addr=__dpmi_get_segment_base_address(vr_screen_sel,vr_screen);
because vr_addr is always 0 (but maybe I'm mistaking.....).
I got a 486dx2/80 with 8Mb RAM and I load DOS only with himem.sys.
Please help me!!!
#include <go32.h>
#include <dpmi.h>
#include <dos.h>
#include <malloc.h>
short vga_sel,vr_screen_sel,c;
int x,y;
long vr_addr;
unsigned long *vr_screen;
/****************************************************************************/
void set_vga(short mode){
__dpmi_regs r;
r.x.ax=mode;
__dpmi_int(0x10,&r);
}
/****************************************************************************/
void put_pixel(void){
asm("
movw _vr_screen_sel,%es
movl _vr_addr,%edi
movw _y,%di
movw %di,%dx
shlw $6,%di
shlw $8,%dx
addw %dx,%di
addw _x,%di
movb _c,%al
movb %al,%es:(%edi)
");
}
/****************************************************************************/
void screen_copy(void){
asm("
pushw %ds
movw $16000,%cx
movl $0xA0000,%edi
movl _vr_addr,%esi
movw _vr_screen_sel,%ds
movw _vga_sel,%es
rep; movsl
popw %ds
");
}
/****************************************************************************/
void main()
{
vr_screen=(unsigned long *)malloc(320*200);
set_vga(0x13);
vga_sel=_dos_ds;
vr_screen_sel=_go32_my_ds();
vr_addr=__dpmi_get_segment_base_address(vr_screen_sel,vr_screen);
vr_addr=vr_addr*16;
x=160;
y=100;
c=57;
put_pixel();
screen_copy();
getkey();
set_vga(0x3);
free(vr_screen);
}
_____ ____
| ____|__/ \
____/ | ___| \ || | \____
\ | || ||| | /
\____|| |___/
|____/ edoardo AT smartcom DOT it
VGAi RuLeZ!
- Raw text -