mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-07 00:29:34 +00:00
Add RLE encoding
This commit is contained in:
parent
50a4fbc230
commit
730360b786
Binary file not shown.
@ -7,6 +7,7 @@ import dcgrutils
|
||||
predef dcgrFont(font)#0
|
||||
predef dcgrRect(x, y, w, h)#0
|
||||
predef dcgrGetPixMap(x, y, w, h)#1
|
||||
predef dcgrEncPixMap(w, h, pixmap, rlemap)#1
|
||||
predef dhgrSet(dhx, y)#0
|
||||
predef dhgrUnset(dhx, y)#0
|
||||
predef spriteRead(filestr)#5
|
||||
|
@ -141,6 +141,34 @@ export def dcgrGetPixMap(x, y, w, h)#1
|
||||
next
|
||||
return pixmap
|
||||
end
|
||||
export def dcgrEncPixMap(w, h, pixmap, rlemap)#1
|
||||
var rleptr
|
||||
byte i, j, run, pixrun
|
||||
|
||||
rleptr = rlemap
|
||||
w--; h--
|
||||
for j = 0 to h
|
||||
run = 0
|
||||
for i = 0 to w step 2
|
||||
if run and ^pixmap == pixrun
|
||||
run++
|
||||
else
|
||||
if run
|
||||
*rleptr = run*2 | (pixrun << 8)
|
||||
//puth(*rleptr); putc(',')
|
||||
rleptr = rleptr + 2
|
||||
fin
|
||||
run = 1
|
||||
pixrun = ^pixmap
|
||||
fin
|
||||
pixmap++
|
||||
next
|
||||
*rleptr = run*2 | (pixrun << 8)
|
||||
//puth(*rleptr); putln
|
||||
rleptr = rleptr + 2
|
||||
next
|
||||
return rleptr - rlemap
|
||||
end
|
||||
export def dhgrSet(dhx, y)#0
|
||||
dcgrColor(dhgrPix[dhx & $03])
|
||||
dcgrOp(OP_OR)
|
||||
|
@ -42,6 +42,7 @@ byte[] = 2, $55, 4, $00, 4, $AA, 4, $00, 2, $55
|
||||
byte[] = 4, $55, 8, $00, 4, $55
|
||||
byte[] = 7, $55, 2, $00, 7, $55
|
||||
|
||||
word rlesprptr
|
||||
word sprite7msk[7]
|
||||
word sprite7[7]
|
||||
word sprite7span, sprite7w
|
||||
@ -99,7 +100,8 @@ def dcgrCompSprite(offset)#0
|
||||
dcgrColor(CLR_BLACK)
|
||||
dcgrClearBl7(0, 0, sprite7w, SPR_H)
|
||||
//dcgrPixMap(i + offset, 0, SPR_W, SPR_H, @sprite)
|
||||
dcgrRleMap(i + offset, 0, SPR_W, SPR_H, @rlesprt)
|
||||
//dcgrRleMap(i + offset, 0, SPR_W, SPR_H, @rlesprt)
|
||||
dcgrRleMap(i + offset, 0, SPR_W, SPR_H, rlesprptr)
|
||||
dcgrSurfScr(OP_SRC)
|
||||
dcgrMemBl7(0, i * SPR_H, sprite7w, SPR_H, sprite7[i], sprite7span)
|
||||
next
|
||||
@ -330,23 +332,23 @@ def dcgrTest#0
|
||||
dcgrOp(OP_XOR)
|
||||
k = 0
|
||||
i = @ncc1701
|
||||
dcgrPixMap(70-i=>spr_xorg, 96-i=>spr_yorg, i=>spr_width, i=>spr_height, i=>spr_pixmap)
|
||||
dcgrPixMap(73-i=>spr_xorg, 96-i=>spr_yorg, i=>spr_width, i=>spr_height, i=>spr_pixmap)
|
||||
while ^$C000 < 128
|
||||
dcgrPixMap(70-i=>spr_xorg, 96-i=>spr_yorg, i=>spr_width, i=>spr_height, i=>spr_pixmap)
|
||||
dcgrPixMap(73-i=>spr_xorg, 96-i=>spr_yorg, i=>spr_width, i=>spr_height, i=>spr_pixmap)
|
||||
i = i + t_sprite
|
||||
k++
|
||||
if k > 7
|
||||
k = 0
|
||||
i = @ncc1701
|
||||
fin
|
||||
dcgrPixMap(70-i=>spr_xorg, 96-i=>spr_yorg, i=>spr_width, i=>spr_height, i=>spr_pixmap)
|
||||
dcgrPixMap(73-i=>spr_xorg, 96-i=>spr_yorg, i=>spr_width, i=>spr_height, i=>spr_pixmap)
|
||||
loop
|
||||
getc
|
||||
dcgrOp(OP_SRC)
|
||||
while ^$C000 < 128
|
||||
dcgrColor(CLR_BLACK)
|
||||
dcgrClearBl7(60/7, 75, 5, 43)
|
||||
dcgrPixMap(70-i=>spr_xorg, 96-i=>spr_yorg, i=>spr_width, i=>spr_height, i=>spr_pixmap)
|
||||
dcgrPixMap(73-i=>spr_xorg, 96-i=>spr_yorg, i=>spr_width, i=>spr_height, i=>spr_pixmap)
|
||||
i = i + t_sprite
|
||||
k++
|
||||
if k > 7
|
||||
@ -433,6 +435,9 @@ def dcgrTest#0
|
||||
next
|
||||
getc
|
||||
end
|
||||
|
||||
rlesprptr = heapmark
|
||||
heapalloc(dcgrEncPixMap(SPR_W, SPR_H, @sprite, rlesprptr))
|
||||
dcgrMode(0)
|
||||
dhgrTest
|
||||
screenRead("monarch")
|
||||
|
Loading…
Reference in New Issue
Block a user