Mail Archives: djgpp/1999/01/10/12:40:35.1
> I am trying to port some code, for reading the fonts in ROM for DOS.
> Anyway, what I need to do is to get the memory location of this... I
> have 2 pointers... segment and offset...
>
> And I want to have the pointers added, for example if the segement is
> 0xAA and the offset is 0x03 then I can make a pointer to 0xAD...
>
> The code I am trying to port looks like this:
>
> char *offset=regs.x.bp;
> char *segment=regs.x.es;
>
> char *font=*MK_FP(segment, offset);
>
> That is the code... the last line is the one I am having trouble with...
> Thanks for the info, I hoped I described this well enough.
>
> -- Alex
I've already done that, here's the code (ripped off my add-on library
AllegroPlus):
First thing are the macros:
#define FAKE_FP_OFF ( (__tb) & 0x0f )
#define FAKE_FP_SEG ( ((__tb) >> 4) & 0xffff )
#define __fp_put(buf,len) dosmemput((buf),(len),(__tb))
#define __fp_get(buf,len) dosmemget((__tb),(len),(buf))
(don't think about the names ;)
Second thing is the load routine for a 8x16 font
//11:30 15.08.1998 fix
//loads a 8x16 dos font (4096 bytes).
#include <dpmi.h>
#include <go32.h>
#include "allplus.h"
void set_8x16_font( uchar *_dat)
{
__dpmi_regs r;
if( _dat == NULL) return;
r.x.ax = 0x1110;
r.x.bx = 0x1000; //points
r.x.cx = 256; //bytes per char
r.x.dx = 0;
r.d.ebp = FAKE_FP_OFF; //offset macro
r.x.es = FAKE_FP_SEG; //segment macro
__fp_put( _dat, 4096); //dosmemput macro
__dpmi_int( 0x10, &r);
}
And last thing is the load routine for a 8x8 font
//11:30 15.08.1998 fix
//loads a 8x8 dos font (2048 bytes).
#include <dpmi.h>
#include <go32.h>
#include "allplus.h"
void set_8x8_font( uchar *_dat)
{
__dpmi_regs r;
if( _dat == NULL) return;
r.x.ax = 0x1110;
r.x.bx = 0x0800; //points
r.x.cx = 256; //bytes per char
r.x.dx = 0;
r.d.ebp = FAKE_FP_OFF; //offset macro
r.x.es = FAKE_FP_SEG; //segment macro
__fp_put( _dat, 2048); //dosmemput macro
__dpmi_int( 0x10, &r);
}
I hope this helps you.
----------
Thomas Wolf (seawolf AT net4you DOT co DOT at)
"Hardware is fast enough to do interesting things, but not fast enough to do
what we
really want." -- Michael Abrash / id Software
- Raw text -