TriOS-alt/demo/graphics/gra-emu.spin

239 lines
14 KiB
Plaintext
Raw Normal View History

2010-11-26 23:58:06 +01:00
<EFBFBD><EFBFBD>
PUB start : okay
'' Start graphics driver - starts a cog
'' returns false if no cog available
PUB stop
'' Stop graphics driver - frees a cog
PUB setup(x_tiles, y_tiles, x_origin, y_origin, base_ptr) | bases_ptr, slices_ptr
'' Set bitmap parameters
''
'' x_tiles - number of x tiles (tiles are 16x16 pixels each)
'' y_tiles - number of y tiles
'' x_origin - relative-x center pixel
'' y_origin - relative-y center pixel
'' base_ptr - base address of bitmap
PUB clear
'' Clear bitmap
PUB copy(dest_ptr)
'' Copy bitmap
'' use for double-buffered display (flicker-free)
''
'' dest_ptr - base address of destination bitmap
PUB color(c)|_arg1,_arg2
'' Set pixel color to two-bit pattern
''
'' c - color code in bits[1..0]
PUB width(w) | pixel_passes,_arg2,_arg3,_arg4, r, i, p
'' Set pixel width
'' actual width is w[3..0] + 1
''
'' w - 0..15 for round pixels, 16..31 for square pixels
PUB colorwidth(c, w)
'' Set pixel color and width
PUB plot(x, y)
'' Plot point
''
'' x,y - point
PUB line(x, y)
'' Draw a line to point
''
'' x,y - endpoint
PUB arc(x, y, xr, yr, angle, anglestep, steps, arcmode)
'' Draw an arc
''
'' x,y - center of arc
'' xr,yr - radii of arc
'' angle - initial angle in bits[12..0] (0..$1FFF = 0<00>..359.956<00>)
'' anglestep - angle step in bits[12..0]
'' steps - number of steps (0 just leaves (x,y) at initial arc position)
'' arcmode - 0: plot point(s)
'' 1: line to point(s)
'' 2: line between points
'' 3: line from point(s) to center
PUB vec(x, y, vecscale, vecangle, vecdef_ptr)
'' Draw a vector sprite
''
'' x,y - center of vector sprite
'' vecscale - scale of vector sprite ($100 = 1x)
'' vecangle - rotation angle of vector sprite in bits[12..0]
'' vecdef_ptr - address of vector sprite definition
''
''
'' Vector sprite definition:
''
'' word $8000|$4000+angle 'vector mode + 13-bit angle (mode: $4000=plot, $8000=line)
'' word length 'vector length
'' ... 'more vectors
'' ...
'' word 0 'end of definition
PUB vecarc(x, y, xr, yr, angle, vecscale, vecangle, vecdef_ptr)
'' Draw a vector sprite at an arc position
''
'' x,y - center of arc
'' xr,yr - radii of arc
'' angle - angle in bits[12..0] (0..$1FFF = 0<00>..359.956<00>)
'' vecscale - scale of vector sprite ($100 = 1x)
'' vecangle - rotation angle of vector sprite in bits[12..0]
'' vecdef_ptr - address of vector sprite definition
PUB pix(x, y, pixrot, pixdef_ptr)
'' Draw a pixel sprite
''
'' x,y - center of vector sprite
'' pixrot - 0: 0<00>, 1: 90<00>, 2: 180<00>, 3: 270<00>, +4: mirror
'' pixdef_ptr - address of pixel sprite definition
''
''
'' Pixel sprite definition:
''
'' word 'word align, express dimensions and center, define pixels
'' byte xwords, ywords, xorigin, yorigin
'' word %%xxxxxxxx,%%xxxxxxxx
'' word %%xxxxxxxx,%%xxxxxxxx
'' word %%xxxxxxxx,%%xxxxxxxx
'' ...
PUB pixarc(x, y, xr, yr, angle, pixrot, pixdef_ptr)
'' Draw a pixel sprite at an arc position
''
'' x,y - center of arc
'' xr,yr - radii of arc
'' angle - angle in bits[12..0] (0..$1FFF = 0<00>..359.956<00>)
'' pixrot - 0: 0<00>, 1: 90<00>, 2: 180<00>, 3: 270<00>, +4: mirror
'' pixdef_ptr - address of pixel sprite definition
PUB text(x, y, string_ptr) | justx, justy
'' Draw text
''
'' x,y - text position (see textmode for sizing and justification)
'' string_ptr - address of zero-terminated string (it may be necessary to call .finish
'' immediately afterwards to prevent subsequent code from clobbering the
'' string as it is being drawn
PUB textarc(x, y, xr, yr, angle, string_ptr) | justx, justy
'' Draw text at an arc position
''
'' x,y - center of arc
'' xr,yr - radii of arc
'' angle - angle in bits[12..0] (0..$1FFF = 0<00>..359.956<00>)
'' string_ptr - address of zero-terminated string (it may be necessary to call .finish
'' immediately afterwards to prevent subsequent code from clobbering the
'' string as it is being drawn
PUB textmode(x_scale, y_scale, spacing, justification)|_arg4,_arg5,_arg6,_arg7
'' Set text size and justification
''
'' x_scale - x character scale, should be 1+
'' y_scale - y character scale, should be 1+
'' spacing - character spacing, 6 is normal
'' justification - bits[1..0]: 0..3 = left, center, right, left
'' bits[3..2]: 0..3 = bottom, center, top, bottom
PUB setFont(fontType)
''Sets font type
''
'' fontType - Vector - Uses the orignal vector font - doesn't work well at the moment in XOR mode
'' ROM - Uses the ROM font - You should set spacing to 16
'' Clemens - Uses a variant Clemens 16x8 font - You should set spacint to 8
PUB box(x, y, box_width, box_height) | x2, y2, pmin, pmax
'' Draw a box with round/square corners, according to pixel width
''
'' x,y - box left, box bottom
PUB boxXOR(x, y, box_width, box_height) | x2, y2, pmin, pmax
'' Draw a box with square corners
''
'' x,y - box left, box bottom
PUB quad(x1, y1, x2, y2, x3, y3, x4, y4)|tx3,ty3,tx1,ty1
'' Draw a solid quadrilateral
'' vertices must be ordered clockwise or counter-clockwise
PUB tri(x1, y1, x2, y2, x3, y3) | xy[2]
'' Draw a solid triangle
PUB finish
'' Wait for any current graphics command to finish
'' use this to insure that it is safe to manually manipulate the bitmap
PUB setXOR
'' Sets XOR mode. In this mode the pixel to be written is read from the bitmap and than
'' XORed with the color value.
''
'' This mode looks bad when using a width other than 0, and the quad and box methods do
'' not work well. The boxXOR method can be used for drawing boxes.
PUB setOverWrite
'' Sets OverWrite or normal mode. In this mode the color is written directly to the bitmap
'' in the desired location.
PUB setFontPtr(fontBase)|_arg1,_arg2
'' Sets the pointer to the base of the Vector font. This could be useful if you wanted to have
'' more than one Vector font. Not tested.
''
'' The data should start with "!". The data can be either lines or curves. See the Vector font
'' below for info.
PUB drawGlyph(x,y,xr,yr,angle,pixrot,pixdef_ptr,glyph)
'' Draws a Glyph using the ROM font.
''
'' x,y - position to draw glyph
'' xr - x radius if you want to do an arc
'' yr - y radius if you want to do an arc (MUST be non-zero), otherwise MUST be 0
'' pixrot - see pix
'' pixdef_ptr - pointer to a buffer for the glyph
'' glyph - the character you want to draw
PUB pixelColor(x,y): temp' | sad
'' Returns the color of a pixel at x,y
PRI fill(x, y, da, db, db2, linechange, lines_minus_1)
PRI justify(string_ptr, justptr)