Mail Archives: djgpp/1997/03/19/07:37:25
On Sun, 16 Mar 1997 22:36:24 GMT, enigma AT erols DOT com (enigma) wrote:
>ok.. this has been bugging me for a little why...
>i'm trying to copy memory from a real pointer to a protected mode
>pointer. well, i got the copying of bytes to work, but my func for
>copying unsigned words isn't working. i could use a little help here
>folks
>
>code:
>
>#define RM_TO_LINEAR(addr) (((addr & 0xFFFF0000) >> 12) + (addr &
>0xFFFF))
>
>UWORD *PMcopyWordtoLocal(UWORD *RMptr) {
>
> UWORD buffer[256], *p;
> UWORD count = 0;
> ULONG addr;
>
> addr = RM_TO_LINEAR((ULONG)RMptr);
> _farsetsel(_dos_ds);
> while (_farnspeekw(addr) != 0xFFFF) {
> buffer[count++] = _farnspeekw(addr++);
> addr++;
> }
> buffer[count] = 0xFFFF;
> p = (UWORD *)malloc(count);
> memcpy(p,buffer,count);
> return p;
>
>}
>
>feel free to criticize my code as much as necessary. style,
>bugs,etc..
>just gimme my mistake ;)
oops ok.. i guess i was a bit cryptic..
ok this basically is used to grab an array that the vesa bios returns
after a function call. what it should be doing is copying UWORD's
(defined as unsigned int) <-- is this wrong? should they be defined as
unsigned short's? the array is terminated by a word filled with
0xFFFF. what the code above does is give me back is just worthless
numbers (should be video mode numbers).
i am looking into Eli's suggestions, but with the added info, can
anyone see an obivous error?
mint
enigma AT erols DOT com
djgpp is an obsession
- Raw text -