-
Notifications
You must be signed in to change notification settings - Fork 26
Double Hires Graphics
Useful functions to make drawing on the double color hi-res screen much easier.
The DHGR toolkit consists of the library, utility library, and sprite editor. The library is different from the other graphics library in that it uses a single display buffer. The DHGR page #2 is rather difficult to address compared to page #1. It also take up a lot of memory in both AUX and MAIN memory. So the choice was made to create an API that could draw into either the display memory or memory buffers that can then be copied to the display. Bitmaps and pixmaps (packed, 4BPP) are the generic image formats. Zero bits in the bitmap and pixel value 5 (GREY 1) in the pixmap are transparent values. One bits in the bitmap are rendered using the current color. There is a run length encoded version of the pixmap that may be more memory efficient for large pixmaps that have areas of constant color or transparency.
Memory buffers are referred to as Block7 surfaces as they mimic the internal DHGR layout of the display buffer and are rounded up to 7 pixel wide spans, thus Block7. They can be quickly copied to the display and other memory buffers, but the destination has to be on 7 pixel boundaries and multiples of 7 pixels wide. The destination surface can be set to the screen with the dhgrSurfScr() function and to a Block7 memory buffer with the dhgrSurfMem() function. All rendering operations will use that designation until another is set.
Tiles are 7 pixel wide by 8 pixel tall images meant for optimized screen drawing. They are even more restrictive than the Block7 buffers in that they must be rendered on a 7 pixel boundary horizontally and an 8 pixel boundary vertically. Useful for drawing things like maps.
The utility library includes routine to read and write sprite pixmap images created with the DHGR SPRite EDitor, dcgrspred. It includes an origin offset, dimensions, and the pixmap data. Screens created with Dazzle Draw can be loaded into the display buffer, or saved, with a simple call.
Compatibility: 128K //e, //c
Basic operations for drawing into screen and memory buffers
Usage: include "inc/dhgrlib.plh"
Values:
const DST_SCREEN = 0
const DST_MEMORY = 1
const SCR_WIDTH7 = 20
const SCR_WIDTH = 140
const SCR_HEIGHT = 192
const OP_SRC = 0
const OP_XOR = 1
const OP_AND = 2
const OP_OR = 3
const CLR_BLACK = 0
const CLR_MAGENTA = 1
const CLR_DRKBLUE = 2
const CLR_PURPLE = 3
const CLR_DRKGREEN = 4
const CLR_GREY1 = 5
const CLR_XPARENT = 5
const CLR_MEDBLUE = 6
const CLR_LTBLUE = 7
const CLR_BROWN = 8
const CLR_ORANGE = 9
const CLR_GREY2 = 10
const CLR_PINK = 11
const CLR_GREEN = 12
const CLR_YELLOW = 13
const CLR_AQUA = 14
const CLR_WHITE = 15
Functions:
dcgrColor(c)#0
dcgrPixel(x, y)#0
dcgrGetPixel(x, y)#1
dcgrHLin(x1, x2, y)#0
dcgrVLin(y1, y2, x)#0
dcgrBitMap(x, y, bitw, bith, bitptr)#0
dcgrPixMap(x, y, pixw, pixh, pixptr)#0
dcgrRleMap(x, y, pixw, pixh, pixptr)#0
dcgrScrBl7(x7, y, w7, h)#0
dcgrMemBl7(x7, y, w7, h, memptr, memspan)#0
dcgrClearBl7(x7, y, w7, h)#0
dcgrTiles(x7, y8, strptr, strlen, tileset)#0
dcgrMemBl7Tile(x7, y, memptr, memspan, tileptr)#0
dhgrVLB#0
dhgrOp(op)#0
dhgrSurfScr(op)#0
dhgrSurfMem(op, memh, memptr, memspan)#0
dhgrMode(mode)#1
Source Code: dhgrlib.pla
Sample Source: dhgrtest.pla
Handy utility functions for working with DHGR fonts and image files
Usage: include "inc/dhgrutils.plh"
Values:
const FONT_WIDE = 0
const FONT_THIN = 1
Functions:
dcgrAllocBl7Mem(w, h)#2
dcgrStr(x, y, strptr)#0
dcgrBoldStr(clr, x, y, strptr)#0
dcgrFont(font)#0
dcgrRect(x, y, w, h)#0
dcgrGetPixMap(x, y, w, h)#1
dcgrEncPixMap(w, h, pixmap, rlemap)#1
dhgrSet(dhx, y)#0
dhgrUnset(dhx, y)#0
spriteRead(filestr)#5
spriteWrite(filestr, xorg, yorg, width, height, sprptr)#1
screenRead(filestr)#1
screenWrite(filestr)#1
Source Code: dhgrutils.pla
Sample Source: dhgrtest.pla