diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /systems/os2/dviware/hp-deskjet/bitmap.h |
Initial commit
Diffstat (limited to 'systems/os2/dviware/hp-deskjet/bitmap.h')
-rw-r--r-- | systems/os2/dviware/hp-deskjet/bitmap.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/systems/os2/dviware/hp-deskjet/bitmap.h b/systems/os2/dviware/hp-deskjet/bitmap.h new file mode 100644 index 0000000000..be0d1bd7fc --- /dev/null +++ b/systems/os2/dviware/hp-deskjet/bitmap.h @@ -0,0 +1,65 @@ +/*********************************************************************** +With non-segmented memory, we just allocate the bitmap as a large 2-D +array. Access to elements is concealed in the macro BITMAP(y,x) which +returns the address of the word at the (y,x) position. On segmented +memory machines (Intel iAPX) this can still be done if the bitmap fits +in one segment, and SEGMEM will have been defined accordingly in +dvixxx.c. + +For segmented memories, not all compilers support pointer addressing of +objects larger than a segment, so we implement the bitmap as a vector of +pointers to raster lines, each of which is allocated dynamically. +Element access is again concealed in BITMAP(y,x), but the code has to +ensure that no pointer is ever advanced outside of a raster line. This +affects functions makechar() and prtbmap(). Bitmap access in +dispchar(), fillrect(), and prxbmap() is already restricted to single +raster lines, so no changes are necessary there. + +getbmap() handles the necessary allocation for either of these, so +devinit() in each dvixxx remains ignorant of the details. +***********************************************************************/ + +#if SEGMEM + +UNSIGN32* bitmap[YBIT] = +{ + (UNSIGN32*)NULL /* only first entry need be initialized */ +}; +#if (IBM_PC_MICROSOFT & !OS_IBMOS2) +#define BITMAP(y,x) ((UNSIGN32*)normaddr(bitmap[y],(x)<<2)) +#define FP_SEG(fp) (*((unsigned *)&(fp) + 1)) +#define FP_OFF(fp) (*((unsigned *)&(fp))) + +char* +normaddr(p,byte_offset) /* return address p+byte_offset */ +char *p; +int byte_offset; /* byte_offset may be positive or negative */ +{ + long address; + char *q; + + /* Reconstruct 32-bit address from SEGMENT*16 + OFFSET + byte_offset */ + + address = (long)FP_SEG(p); /* long <- unsigned by zero extend */ + address <<= 4; /* segment real memory address */ + address += (long)FP_OFF(p); /* *p real memory address */ + address += (long)byte_offset;/* *(p+byte_offset) real memory address */ + + /* Renormalize address to OFFSET in 0..15 */ + + FP_OFF(q) = (unsigned)(address & 0x0f); + FP_SEG(q) = (unsigned)(address >> 4); + + return (q); +} +#else /* NOT IBM_PC_MICROSOFT OR OS_IBMOS2 */ +#define BITMAP(y,x) (bitmap[y] + (UNSIGN16)(x)) +#endif /* IBM_PC_MICROSOFT */ + +#else /* NOT SEGMEM */ + +UNSIGN32* bitmap = (UNSIGN32*)NULL; +#define BITMAP(y,x) (bitmap + ((UNSIGN32)XBIT*(UNSIGN32)(y)) + (UNSIGN32)(x)) + +#endif /* SEGMEM */ + |