Mail Archives: djgpp/1996/10/01/19:49:30
Eric Rudd wrote:
>
<SNIP>
> int _crt0_startup_flags = _CRT0_FLAG_NEARPTR | _CRT0_FLAG_NONMOVE_SBRK;
> .
> .
> .
> info.size = width*height*BytesPerPixel;
> info.address = (int) PhysBasePtr;
> if (__dpmi_physical_address_mapping(&info) == -1) {
> return 2; /* Physical mapping of address PhysBasePtr failed. */
> }
> VideoBase = (void *) info.address; /* Updated by above call */
> (char *) VideoBase += __djgpp_conventional_base;
>
> I then access video memory by references like
>
> ((char *) VideoBase)[offset] = GrayValue;
>
> -Eric Rudd
<SNIP>
Hello
If I do it your way, I get a protection fault.
I can erase that problem by setting the ds segment limit by hand.
__dpmi_set_segment_limit(_my_ds(),info.address+Video_card_memory);
and then accessing the memory your way.
Or do the following.
I allocate as much memory as the Video card supports
my_video=malloc(Video_card_memory+Alignment_buffer);
then aligning the pointer, mapping the PhysBasePtr, like you did it.
info.size = Video_card_memory;
info.address = (int) PhysBasePtr;
if (__dpmi_physical_address_mapping(&info) == -1) {
return 2; /* Physical mapping of address PhysBasePtr failed.
after that my program changes a little (maybe this is stupid, but it
works)
I do a physical mapping with
__djgpp_map_physical_memory(my_video,Video_card_memory,info.address);
after that it is no problem to access my_video like this:
*(my_video+offset)=pixel_value;
I think the advance of my routine is, that it doesn't have to
disable protection (by setting the ds segment limit to 4GB).
If I am wrong and there is any problem with doing it that way (I know
that this will only work with dmpi 1.0) please post it here or mail me.
Greetings
Mirko
- Raw text -