Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ikuyubon

Prob with 13h using DJGPP

This topic is 6899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can''t understand why I can''t put a pixel in 13h mode with the following code using DJGPP: #include #include #include #include #include unsigned char *vga = (unsigned char *) 0xA0000; void Init13h() { __dpmi_regs r; r.x.ax = 0x13; __dpmi_int(0x10, &r); } void Close13h() { __dpmi_regs r; r.x.ax = 0x03; __dpmi_int(0x10, &r); } void main() { Init13h(); vga[0] = 15; getche(); Close13h(); } Tell me what''s wrong with my code..... Maybe vga needs to be an (unsigned char far *)??? If yes, tell me how to create far pointers under DJGPP.... (I used to use Turbo C++ and it''s the first time that I use DJGPP) thanx

Share this post


Link to post
Share on other sites
Advertisement
the line that's causing the General Protection Fault is:
vga[0] = 15;
correct me if i'm wrong (i may be) but..
djgpp is a protected mode compiler, so you can't just create [a pointer] to anywhere in memory (like, say, 0xA0000 for video memory) and use it.
here's a site with some djgpp graphics tips:
www.castle.net/~avly/djgfx.html
most of it's assembly for use with djgpp, but there's some C code..
i find it works if you use a double buffer, and copy it to the video pointer with dosmemput().. it's one of the examples on that page..

Edited by - fuzzyai on May 16, 2000 11:34:27 AM

Share this post


Link to post
Share on other sites
Thanx
you''re right... it causes a general protection fault...
I''ll try what you said
(Don''t try! Do it)
ohhhh OK OK
I''ll do it

hehe

Share this post


Link to post
Share on other sites
OK
I''ve tried dosmemput() and it works
but... (yes but)
isn''t dosmemput a little bit slow... compared to memcpy()???
(?)

Share this post


Link to post
Share on other sites
To access video memory in DGJPP like an array, you have to do this.

video = (unsigned char *)0xa0000;
__djgpp_nearptr_enable();
video += __djgpp_conventional_base;

...
some code
...

__djgpp_nearptr_disable();

I may have missed something, because I took this code from an old 3D DJGPP engine that I no longer use. I also don''t use DJGPP anymore, but it is a good compiler.

Domini

Share this post


Link to post
Share on other sites
Try to make a function that search if the __djgpp_nearptr_enable() is on or off, and then if it´s off, turn it on. Make a value to enter in the function to make it on or off whenever you want, then you just have to call the function!

i hope it could be useful! =]

Share this post


Link to post
Share on other sites
It''s been a while since I used DJGPP, but I want to say that __djgpp_conventional_base is a global variable initialized at runtime. You have to look at all the faqs and read the online documentation that comes with rhide. That''s how I learned it. You''ll also have to get an understanding about programming in protected mode. I''ll look at my old stuff and see if I can figure it out again.

Domini

Share this post


Link to post
Share on other sites
I havent been using DJGPP for a while, so please correct me if this is wrong.
DJGPP produces protected mode code, so you cant just access video memory like you are doing it.
dosmemput() is slow and memcpy() isn''t the fastest too.
If you know asm i suggest you create your putpixel function in asm. You just put _dos_ds (a global variabel which contains the video memory''s selector) into the ES register, 0xA0000 into the EDI register and then you add the pixel''s offset on the screen to EDI. The code will be something like this:

movw _dos_ds, %es
movl 0xA0000, %edi
addl pixel_offset, %edi // pixel_offset=y*320+x
movb %al, %es%edi) // dont remember if this is the right syntax to acces memory

That''s it...
If you dont understand my explanatation or dont know asm, i can send you my asm putpixel function...

Share this post


Link to post
Share on other sites
This is how I put it in to Mode 13h

#include

void SetMode13()
{
union REGS in, out;
in.w.ax=0x0013;
int86(0x10,&in,&out);
}

The above works for me. But I forgot how to allocate a pointer to
vga address so that pixels can be written to the screen. To get it back
to ordinary screen mode replace:

in.w.ax=0x0013 with in.w.ax=0x0003

Hope that works for you.

Dark Star.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!