mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-10-18 07:24:16 +00:00
Break out sprite library
This commit is contained in:
parent
f829682876
commit
4186c5170d
@ -16,6 +16,6 @@ import hgrlib
|
|||||||
predef hgrClear#0
|
predef hgrClear#0
|
||||||
predef hgrShow(page)#1
|
predef hgrShow(page)#1
|
||||||
predef hgrSwap#1
|
predef hgrSwap#1
|
||||||
predef hgrDrawBuf(page)#0
|
predef hgrDrawBuf(page)#1
|
||||||
predef hgrColor(clr)#0
|
predef hgrColor(clr)#0
|
||||||
end
|
end
|
||||||
|
15
src/inc/sprite.plh
Normal file
15
src/inc/sprite.plh
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import sprite
|
||||||
|
predef spriteCompile(w, h, srcptr)#1
|
||||||
|
predef spriteDup(sprtsrc)#1
|
||||||
|
predef spriteDraw(sprtptr)#0
|
||||||
|
predef spriteDrawXor(sprtptr)#0
|
||||||
|
predef spriteUnDraw(sprtptr)#0
|
||||||
|
predef spriteUnDrawXor(sprtptr)#0
|
||||||
|
predef spritePos(x, y, sprtptr)#0
|
||||||
|
predef spritePosIndex(x, y, i)#0
|
||||||
|
predef spriteDrawList#0
|
||||||
|
predef spriteDrawXorList#0
|
||||||
|
predef spriteAdd(i, sprtptr)#1
|
||||||
|
predef spriteDel(i)#1
|
||||||
|
predef spriteDrawBuf(page)#0
|
||||||
|
end
|
@ -112,10 +112,6 @@ byte = $88, $8F, $FF, $F8, $88
|
|||||||
|
|
||||||
asm grInc(buff)
|
asm grInc(buff)
|
||||||
!SOURCE "vmsrc/plvmzp.inc"
|
!SOURCE "vmsrc/plvmzp.inc"
|
||||||
GBASL = $26
|
|
||||||
GBASH = $27
|
|
||||||
GBASE = GBASL
|
|
||||||
GCLR = $30
|
|
||||||
end
|
end
|
||||||
|
|
||||||
export asm divmod7(x)#2
|
export asm divmod7(x)#2
|
||||||
@ -786,9 +782,10 @@ export def hgrSwap#1
|
|||||||
drawbuff = hgrbuff[drawpage]
|
drawbuff = hgrbuff[drawpage]
|
||||||
return drawpage
|
return drawpage
|
||||||
end
|
end
|
||||||
export def hgrDrawBuf(page)#0
|
export def hgrDrawBuf(page)#1
|
||||||
drawpage = page & 1
|
drawpage = page & 1
|
||||||
drawbuff = hgrbuff[drawpage]
|
drawbuff = hgrbuff[drawpage]
|
||||||
|
return drawpage
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
// Assembly fixups
|
// Assembly fixups
|
||||||
|
185
src/libsrc/apple/sprite.pla
Normal file
185
src/libsrc/apple/sprite.pla
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
include "inc/cmdsys.plh"
|
||||||
|
include "inc/hgrlib.plh"
|
||||||
|
|
||||||
|
struc t_sprite
|
||||||
|
var s_xpos
|
||||||
|
var s_ypos
|
||||||
|
byte s_undermap[2]
|
||||||
|
byte s_underofst[2]
|
||||||
|
byte s_undery[2]
|
||||||
|
byte s_pitch
|
||||||
|
// var s_width
|
||||||
|
var s_height
|
||||||
|
var s_size
|
||||||
|
var s_mask[14]
|
||||||
|
var s_map[14]
|
||||||
|
var s_under[14]
|
||||||
|
end
|
||||||
|
|
||||||
|
var spriteList[16]
|
||||||
|
byte drawpage
|
||||||
|
//
|
||||||
|
// Sprite routines
|
||||||
|
//
|
||||||
|
def spriteBLTMask(x, y, w, h, srcptr)#0
|
||||||
|
word i, j
|
||||||
|
byte c
|
||||||
|
|
||||||
|
for j = y to y + h - 1
|
||||||
|
for i = 0 to w - 1
|
||||||
|
c = srcptr->[i >> 1]
|
||||||
|
if i & 1
|
||||||
|
hgrColor(c & $08 ?? 3 :: 0)
|
||||||
|
else
|
||||||
|
hgrColor(c & $80 ?? 3 :: 0)
|
||||||
|
fin
|
||||||
|
hgrPlot(x + i, j)
|
||||||
|
next
|
||||||
|
srcptr = srcptr + (w + 1) / 2
|
||||||
|
next
|
||||||
|
end
|
||||||
|
export def spriteCompile(w, h, srcptr)#1
|
||||||
|
var sprtptr, bytewidth, spritesize, i
|
||||||
|
|
||||||
|
sprtptr = heapalloc(t_sprite)
|
||||||
|
bytewidth = (w + 7) / 7 + 1
|
||||||
|
sprtptr->s_pitch = bytewidth
|
||||||
|
spritesize = bytewidth * h
|
||||||
|
sprtptr=>s_size = spritesize
|
||||||
|
// sprtptr=>s_width = w
|
||||||
|
sprtptr=>s_height = h
|
||||||
|
sprtptr=>s_under[0] = heapalloc(spritesize)
|
||||||
|
sprtptr=>s_under[1] = heapalloc(spritesize)
|
||||||
|
for i = 0 to 13
|
||||||
|
sprtptr=>s_map[i] = heapalloc(spritesize)
|
||||||
|
sprtptr=>s_mask[i] = heapalloc(spritesize)
|
||||||
|
hgrColor(0)
|
||||||
|
hgrRect(0, w + 21, 0, h - 1)
|
||||||
|
hgrBLT(i, 0, w, h, srcptr)
|
||||||
|
hgrCopyDst(i > 6 ?? 1 :: 0, 0, bytewidth, h, sprtptr=>s_map[i])
|
||||||
|
hgrColor(3)
|
||||||
|
hgrRect(0, w + 21, h, h * 2 - 1)
|
||||||
|
spriteBLTMask(i, h, w, h, srcptr)
|
||||||
|
hgrCopyDst(i > 6 ?? 1 :: 0, h, bytewidth, h, sprtptr=>s_mask[i])
|
||||||
|
next
|
||||||
|
sprtptr->s_underofst[0] = 255 // Mark as under not valid
|
||||||
|
sprtptr->s_underofst[1] = 255
|
||||||
|
return sprtptr
|
||||||
|
end
|
||||||
|
export def spriteDup(sprtsrc)#1
|
||||||
|
var sprtdup, spritesize
|
||||||
|
byte i
|
||||||
|
|
||||||
|
sprtdup = heapalloc(t_sprite)
|
||||||
|
spritesize = sprtsrc=>s_size
|
||||||
|
sprtdup=>s_size = spritesize
|
||||||
|
sprtdup->s_pitch = sprtsrc->s_pitch
|
||||||
|
// sprtdup=>s_width = sprtsrc=>s_width
|
||||||
|
sprtdup=>s_height = sprtsrc=>s_height
|
||||||
|
sprtdup=>s_under[0] = heapalloc(spritesize)
|
||||||
|
sprtdup=>s_under[1] = heapalloc(spritesize)
|
||||||
|
for i = 0 to 13
|
||||||
|
sprtdup=>s_map[i] = sprtsrc=>s_map[i]
|
||||||
|
sprtdup=>s_mask[i] = sprtsrc=>s_mask[i]
|
||||||
|
next
|
||||||
|
sprtdup->s_underofst[0] = 255 // Mark as under not valid
|
||||||
|
sprtdup->s_underofst[1] = 255
|
||||||
|
return sprtdup
|
||||||
|
end
|
||||||
|
export def spriteDraw(sprtptr)#0
|
||||||
|
byte ofst, map, y
|
||||||
|
var width, height
|
||||||
|
|
||||||
|
y = sprtptr->s_ypos
|
||||||
|
ofst, map = divmod7(sprtptr=>s_xpos)
|
||||||
|
if ofst & 1
|
||||||
|
map = map + 7
|
||||||
|
fin
|
||||||
|
sprtptr->s_underofst[drawpage] = ofst
|
||||||
|
sprtptr->s_undery[drawpage] = y
|
||||||
|
width = sprtptr->s_pitch
|
||||||
|
height = sprtptr=>s_height
|
||||||
|
hgrCopyDst(ofst, y, width, height, sprtptr=>s_under[drawpage])
|
||||||
|
hgrAndSrc( ofst, y, width, height, sprtptr=>s_mask[map])
|
||||||
|
hgrXorSrc( ofst, y, width, height, sprtptr=>s_map[map])
|
||||||
|
end
|
||||||
|
export def spriteUnDraw(sprtptr)#0
|
||||||
|
if sprtptr->s_underofst[drawpage] < 40
|
||||||
|
hgrCopySrc(sprtptr->s_underofst[drawpage], sprtptr->s_undery[drawpage], sprtptr->s_pitch, sprtptr=>s_height, sprtptr=>s_under[drawpage])
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
export def spriteDrawXor(sprtptr)#0
|
||||||
|
byte ofst, map, y
|
||||||
|
var width, height
|
||||||
|
|
||||||
|
y = sprtptr->s_ypos
|
||||||
|
ofst, map = divmod7(sprtptr=>s_xpos)
|
||||||
|
if ofst & 1
|
||||||
|
map = map + 7
|
||||||
|
fin
|
||||||
|
sprtptr->s_undermap[drawpage] = map
|
||||||
|
sprtptr->s_underofst[drawpage] = ofst
|
||||||
|
sprtptr->s_undery[drawpage] = y
|
||||||
|
width = sprtptr->s_pitch
|
||||||
|
height = sprtptr=>s_height
|
||||||
|
hgrXorSrc( ofst, y, width, height, sprtptr=>s_map[map])
|
||||||
|
end
|
||||||
|
export def spriteUnDrawXor(sprtptr)#0
|
||||||
|
if sprtptr->s_underofst[drawpage] < 40
|
||||||
|
hgrXorSrc(sprtptr->s_underofst[drawpage], sprtptr->s_undery[drawpage], sprtptr->s_pitch, sprtptr=>s_height, sprtptr=>s_map[sprtptr->s_undermap[drawpage]])
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
export def spritePos(x, y, sprtptr)#0
|
||||||
|
sprtptr=>s_ypos = y
|
||||||
|
sprtptr=>s_xpos = x
|
||||||
|
end
|
||||||
|
export def spritePosIndex(x, y, i)#0
|
||||||
|
i = i & 15
|
||||||
|
if spriteList[i]
|
||||||
|
spriteList[i]=>s_ypos = y
|
||||||
|
spriteList[i]=>s_xpos = x
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
export def spriteDrawList#0
|
||||||
|
byte i
|
||||||
|
|
||||||
|
for i = 15 downto 0
|
||||||
|
if spriteList[i]
|
||||||
|
spriteUnDraw(spriteList[i])
|
||||||
|
fin
|
||||||
|
next
|
||||||
|
for i = 0 to 15
|
||||||
|
if spriteList[i]
|
||||||
|
spriteDraw(spriteList[i])
|
||||||
|
fin
|
||||||
|
next
|
||||||
|
end
|
||||||
|
export def spriteDrawXorList#0
|
||||||
|
byte i
|
||||||
|
for i = 0 to 15
|
||||||
|
if spriteList[i]
|
||||||
|
spriteUnDrawXor(spriteList[i])
|
||||||
|
spriteDrawXor(spriteList[i])
|
||||||
|
fin
|
||||||
|
next
|
||||||
|
end
|
||||||
|
export def spriteAdd(i, sprtptr)#1
|
||||||
|
var sprtprev
|
||||||
|
|
||||||
|
i = i & 15
|
||||||
|
sprtprev = spriteList[i]
|
||||||
|
spriteList[i] = sprtptr
|
||||||
|
return sprtprev
|
||||||
|
end
|
||||||
|
export def spriteDel(i)#1
|
||||||
|
var sprtprev
|
||||||
|
|
||||||
|
i = i & 15
|
||||||
|
sprtprev = spriteList[i]
|
||||||
|
spriteList[i] = 0
|
||||||
|
return sprtprev
|
||||||
|
end
|
||||||
|
export def spriteDrawBuf(page)#0
|
||||||
|
drawpage = page & 1
|
||||||
|
end
|
||||||
|
done
|
@ -38,6 +38,12 @@ asm majorline(majorstart, major, majorend, minor, dir, majorspan)#0
|
|||||||
LDA $1001 ; ERRH
|
LDA $1001 ; ERRH
|
||||||
ADC $2001 ; SHORTERRH
|
ADC $2001 ; SHORTERRH
|
||||||
STA $1001 ; ERRH
|
STA $1001 ; ERRH
|
||||||
|
LDA ESTKL+0,X ; MAJORSPANL
|
||||||
|
STA $A000
|
||||||
|
STA $B000
|
||||||
|
LDA ESTKH+0,X ; MAJORSPANH
|
||||||
|
STA $A001
|
||||||
|
STA $B001
|
||||||
end
|
end
|
||||||
asm _majorlineA
|
asm _majorlineA
|
||||||
- DEX
|
- DEX
|
||||||
@ -55,11 +61,7 @@ asm _majorlineA
|
|||||||
STA ESTKL+0,X
|
STA ESTKL+0,X
|
||||||
LDA ESTKH+5,X ; MINORH
|
LDA ESTKH+5,X ; MINORH
|
||||||
STA ESTKH+0,X
|
STA ESTKH+0,X
|
||||||
LDA ESTKL+3,X ; MAJORSPANL
|
JSR $A000
|
||||||
STA TMPL
|
|
||||||
LDA ESTKH+3,X ; MAJORSPANH
|
|
||||||
STA TMPH
|
|
||||||
JSR JMPTMP
|
|
||||||
|
|
||||||
LDA ESTKL+2,X ; MINORL
|
LDA ESTKL+2,X ; MINORL
|
||||||
CLC
|
CLC
|
||||||
@ -138,11 +140,7 @@ asm _majorlineE
|
|||||||
STA ESTKL+0,X
|
STA ESTKL+0,X
|
||||||
LDA ESTKH+5,X ; MINORH
|
LDA ESTKH+5,X ; MINORH
|
||||||
STA ESTKH+0,X
|
STA ESTKH+0,X
|
||||||
LDA ESTKL+3,X ; MAJORSPANL
|
JSR $B000
|
||||||
STA TMPL
|
|
||||||
LDA ESTKH+3,X ; MAJORSPANH
|
|
||||||
STA TMPH
|
|
||||||
JSR JMPTMP
|
|
||||||
INX
|
INX
|
||||||
INX
|
INX
|
||||||
INX
|
INX
|
||||||
@ -240,6 +238,10 @@ majorline:8 = @err
|
|||||||
majorline:11 = @err.1
|
majorline:11 = @err.1
|
||||||
majorline:14 = @shorterr.1
|
majorline:14 = @shorterr.1
|
||||||
majorline:17 = @err.1
|
majorline:17 = @err.1
|
||||||
|
majorline:22 = @_majorlineA.28
|
||||||
|
majorline:25 = @_majorlineE.31
|
||||||
|
majorline:30 = @_majorlineA.29
|
||||||
|
majorline:33 = @_majorlineE.32
|
||||||
_majorlineB:1 = @err.1
|
_majorlineB:1 = @err.1
|
||||||
_majorlineC:1 = @err
|
_majorlineC:1 = @err
|
||||||
_majorlineC:5 = @shorterr
|
_majorlineC:5 = @shorterr
|
||||||
|
@ -58,6 +58,7 @@ TFTPD = rel/TFTPD\#FE1000
|
|||||||
HGRLIB = rel/apple/HGRLIB\#FE1000
|
HGRLIB = rel/apple/HGRLIB\#FE1000
|
||||||
GRLIB = rel/apple/GRLIB\#FE1000
|
GRLIB = rel/apple/GRLIB\#FE1000
|
||||||
DGRLIB = rel/apple/DGRLIB\#FE1000
|
DGRLIB = rel/apple/DGRLIB\#FE1000
|
||||||
|
SPRITE = rel/apple/SPRITE\#FE1000
|
||||||
LINESPANS = rel/apple/LINESPANS\#FE1000
|
LINESPANS = rel/apple/LINESPANS\#FE1000
|
||||||
GRAFIX = rel/apple/GRAFIX\#FE1000
|
GRAFIX = rel/apple/GRAFIX\#FE1000
|
||||||
GFXDEMO = rel/apple/GFXDEMO\#FE1000
|
GFXDEMO = rel/apple/GFXDEMO\#FE1000
|
||||||
@ -99,7 +100,7 @@ TXTTYPE = .TXT
|
|||||||
#SYSTYPE = \#FF2000
|
#SYSTYPE = \#FF2000
|
||||||
#TXTTYPE = \#040000
|
#TXTTYPE = \#040000
|
||||||
|
|
||||||
apple: $(PLVMZP_APL) $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVMJIT) $(PLVM802) $(PLVM03) $(CMD) $(CMDJIT) $(JIT) $(JIT16) $(JITUNE) $(SOSCMD) $(PLASMAPLASM) $(CODEOPT) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(COPY) $(DEL) $(REN) $(CAT) $(NEWDIR) $(TYPE) $(SOS) $(ROD) $(SIEVE) $(PRIMEGAP) $(MOUSE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(TFTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(GRAFIX) $(GFXDEMO) $(LINESPANS) $(HGRLIB) $(HGRTEST) $(GRLIB) $(DGRLIB) $(GRTEST) $(DGRTEST) $(HGRTEST) $(FILEIO_APL) $(CONIO_APL) $(JOYBUZZ) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(INT32) $(INT32TEST) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(LZ4) $(LZ4CAT) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ)
|
apple: $(PLVMZP_APL) $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVMJIT) $(PLVM802) $(PLVM03) $(CMD) $(CMDJIT) $(JIT) $(JIT16) $(JITUNE) $(SOSCMD) $(PLASMAPLASM) $(CODEOPT) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(COPY) $(DEL) $(REN) $(CAT) $(NEWDIR) $(TYPE) $(SOS) $(ROD) $(SIEVE) $(PRIMEGAP) $(MOUSE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(TFTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(GRAFIX) $(GFXDEMO) $(LINESPANS) $(SPRITE) $(HGRLIB) $(HGRTEST) $(GRLIB) $(DGRLIB) $(GRTEST) $(DGRTEST) $(HGRTEST) $(FILEIO_APL) $(CONIO_APL) $(JOYBUZZ) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(INT32) $(INT32TEST) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(LZ4) $(LZ4CAT) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ)
|
||||||
|
|
||||||
-rm vmsrc/plvmzp.inc
|
-rm vmsrc/plvmzp.inc
|
||||||
|
|
||||||
@ -416,6 +417,10 @@ $(DGRLIB): libsrc/apple/dgrlib.pla $(PLVM02) $(PLASM)
|
|||||||
./$(PLASM) -AMOW < libsrc/apple/dgrlib.pla > libsrc/apple/dgrlib.a
|
./$(PLASM) -AMOW < libsrc/apple/dgrlib.pla > libsrc/apple/dgrlib.a
|
||||||
acme --setpc 4094 -o $(DGRLIB) libsrc/apple/dgrlib.a
|
acme --setpc 4094 -o $(DGRLIB) libsrc/apple/dgrlib.a
|
||||||
|
|
||||||
|
$(SPRITE): libsrc/apple/sprite.pla $(PLVM02) $(PLASM)
|
||||||
|
./$(PLASM) -AMOW < libsrc/apple/sprite.pla > libsrc/apple/sprite.a
|
||||||
|
acme --setpc 4094 -o $(SPRITE) libsrc/apple/sprite.a
|
||||||
|
|
||||||
$(HGRTEST): samplesrc/hgrtest.pla $(PLVM02) $(PLASM)
|
$(HGRTEST): samplesrc/hgrtest.pla $(PLVM02) $(PLASM)
|
||||||
./$(PLASM) -AMOW < samplesrc/hgrtest.pla > samplesrc/hgrtest.a
|
./$(PLASM) -AMOW < samplesrc/hgrtest.pla > samplesrc/hgrtest.a
|
||||||
acme --setpc 4094 -o $(HGRTEST) samplesrc/hgrtest.a
|
acme --setpc 4094 -o $(HGRTEST) samplesrc/hgrtest.a
|
||||||
|
@ -10,6 +10,7 @@ mkdir prodos/sys
|
|||||||
cp rel/apple/FILEIO#FE1000 prodos/sys/FILEIO.REL
|
cp rel/apple/FILEIO#FE1000 prodos/sys/FILEIO.REL
|
||||||
cp rel/apple/CONIO#FE1000 prodos/sys/CONIO.REL
|
cp rel/apple/CONIO#FE1000 prodos/sys/CONIO.REL
|
||||||
cp rel/apple/LINESPANS#FE1000 prodos/sys/LINESPANS.REL
|
cp rel/apple/LINESPANS#FE1000 prodos/sys/LINESPANS.REL
|
||||||
|
cp rel/apple/SPRITE#FE1000 prodos/sys/SPRITE.REL
|
||||||
cp rel/apple/HGRLIB#FE1000 prodos/sys/HGRLIB.REL
|
cp rel/apple/HGRLIB#FE1000 prodos/sys/HGRLIB.REL
|
||||||
cp rel/apple/GRLIB#FE1000 prodos/sys/GRLIB.REL
|
cp rel/apple/GRLIB#FE1000 prodos/sys/GRLIB.REL
|
||||||
cp rel/apple/DGRLIB#FE1000 prodos/sys/DGRLIB.REL
|
cp rel/apple/DGRLIB#FE1000 prodos/sys/DGRLIB.REL
|
||||||
@ -150,6 +151,7 @@ cp inc/args.plh prodos/bld/inc/ARGS.PLH.TXT
|
|||||||
cp inc/cmdsys.plh prodos/bld/inc/CMDSYS.PLH.TXT
|
cp inc/cmdsys.plh prodos/bld/inc/CMDSYS.PLH.TXT
|
||||||
cp inc/conio.plh prodos/bld/inc/CONIO.PLH.TXT
|
cp inc/conio.plh prodos/bld/inc/CONIO.PLH.TXT
|
||||||
cp inc/linespans.plh prodos/bld/inc/LINESPANS.PLH.TXT
|
cp inc/linespans.plh prodos/bld/inc/LINESPANS.PLH.TXT
|
||||||
|
cp inc/sprite.plh prodos/bld/inc/SPRITE.PLH.TXT
|
||||||
cp inc/hgrlib.plh prodos/bld/inc/HGRLIB.PLH.TXT
|
cp inc/hgrlib.plh prodos/bld/inc/HGRLIB.PLH.TXT
|
||||||
cp inc/grlib.plh prodos/bld/inc/GRLIB.PLH.TXT
|
cp inc/grlib.plh prodos/bld/inc/GRLIB.PLH.TXT
|
||||||
cp inc/dgrlib.plh prodos/bld/inc/DGRLIB.PLH.TXT
|
cp inc/dgrlib.plh prodos/bld/inc/DGRLIB.PLH.TXT
|
||||||
|
@ -1,23 +1,9 @@
|
|||||||
include "inc/cmdsys.plh"
|
include "inc/cmdsys.plh"
|
||||||
include "inc/hgrlib.plh"
|
include "inc/hgrlib.plh"
|
||||||
|
include "inc/sprite.plh"
|
||||||
include "inc/linespans.plh"
|
include "inc/linespans.plh"
|
||||||
sysflags reshgr1|reshgr2 // Reserve HGR page 1 and 2
|
sysflags reshgr1|reshgr2 // Reserve HGR page 1 and 2
|
||||||
|
|
||||||
struc t_sprite
|
|
||||||
var s_xpos
|
|
||||||
var s_ypos
|
|
||||||
byte s_underofst[2]
|
|
||||||
var s_undery[2]
|
|
||||||
var s_width
|
|
||||||
var s_height
|
|
||||||
var s_pitch
|
|
||||||
var s_size
|
|
||||||
var s_mask[14]
|
|
||||||
var s_map[14]
|
|
||||||
var s_under[14]
|
|
||||||
end
|
|
||||||
|
|
||||||
var spriteList[16]
|
|
||||||
byte ball = $88, $83, $33, $38, $88
|
byte ball = $88, $83, $33, $38, $88
|
||||||
byte = $88, $33, $11, $33, $88
|
byte = $88, $33, $11, $33, $88
|
||||||
byte = $83, $31, $11, $13, $38
|
byte = $83, $31, $11, $13, $38
|
||||||
@ -29,150 +15,16 @@ byte = $83, $31, $11, $13, $38
|
|||||||
byte = $88, $33, $11, $33, $88
|
byte = $88, $33, $11, $33, $88
|
||||||
byte = $88, $83, $33, $38, $88
|
byte = $88, $83, $33, $38, $88
|
||||||
var sprtBall
|
var sprtBall
|
||||||
byte drawpage
|
|
||||||
//
|
|
||||||
// Sprite routines
|
|
||||||
//
|
|
||||||
export def spriteBLTMask(x, y, w, h, srcptr)#0
|
|
||||||
word i, j
|
|
||||||
byte c
|
|
||||||
|
|
||||||
for j = y to y + h - 1
|
|
||||||
for i = 0 to w - 1
|
|
||||||
c = srcptr->[i >> 1]
|
|
||||||
if i & 1
|
|
||||||
hgrColor(c & $08 ?? 3 :: 0)
|
|
||||||
else
|
|
||||||
hgrColor(c & $80 ?? 3 :: 0)
|
|
||||||
fin
|
|
||||||
hgrPlot(x + i, j)
|
|
||||||
next
|
|
||||||
srcptr = srcptr + (w + 1) / 2
|
|
||||||
next
|
|
||||||
end
|
|
||||||
def spriteCompile(w, h, srcptr)
|
|
||||||
var sprtptr, bytewidth, spritesize, i
|
|
||||||
|
|
||||||
sprtptr = heapalloc(t_sprite)
|
|
||||||
bytewidth = (w + 7) / 7 + 1
|
|
||||||
sprtptr=>s_pitch = bytewidth
|
|
||||||
spritesize = bytewidth * h
|
|
||||||
sprtptr=>s_size = spritesize
|
|
||||||
sprtptr=>s_width = w
|
|
||||||
sprtptr=>s_height = h
|
|
||||||
sprtptr=>s_under[0] = heapalloc(spritesize)
|
|
||||||
sprtptr=>s_under[1] = heapalloc(spritesize)
|
|
||||||
for i = 0 to 13
|
|
||||||
sprtptr=>s_map[i] = heapalloc(spritesize)
|
|
||||||
sprtptr=>s_mask[i] = heapalloc(spritesize)
|
|
||||||
hgrColor(0)
|
|
||||||
hgrRect(0, w + 21, 0, h - 1)
|
|
||||||
hgrBLT(i, 0, w, h, srcptr)
|
|
||||||
hgrCopyDst(i > 6 ?? 1 :: 0, 0, bytewidth, h, sprtptr=>s_map[i])
|
|
||||||
hgrColor(3)
|
|
||||||
hgrRect(0, w + 21, h, h * 2 - 1)
|
|
||||||
spriteBLTMask(i, h, w, h, srcptr)
|
|
||||||
hgrCopyDst(i > 6 ?? 1 :: 0, h, bytewidth, h, sprtptr=>s_mask[i])
|
|
||||||
next
|
|
||||||
sprtptr->s_underofst[0] = 255 // Mark as under not valid
|
|
||||||
sprtptr->s_underofst[1] = 255
|
|
||||||
return sprtptr
|
|
||||||
end
|
|
||||||
def spriteDup(sprtsrc)
|
|
||||||
var sprtdup, spritesize
|
|
||||||
byte i
|
|
||||||
|
|
||||||
sprtdup = heapalloc(t_sprite)
|
|
||||||
spritesize = sprtsrc=>s_size
|
|
||||||
sprtdup=>s_size = spritesize
|
|
||||||
sprtdup=>s_pitch = sprtsrc=>s_pitch
|
|
||||||
sprtdup=>s_width = sprtsrc=>s_width
|
|
||||||
sprtdup=>s_height = sprtsrc=>s_height
|
|
||||||
sprtdup=>s_under[0] = heapalloc(spritesize)
|
|
||||||
sprtdup=>s_under[1] = heapalloc(spritesize)
|
|
||||||
for i = 0 to 13
|
|
||||||
sprtdup=>s_map[i] = sprtsrc=>s_map[i]
|
|
||||||
sprtdup=>s_mask[i] = sprtsrc=>s_mask[i]
|
|
||||||
next
|
|
||||||
sprtdup->s_underofst[0] = 255 // Mark as under not valid
|
|
||||||
sprtdup->s_underofst[1] = 255
|
|
||||||
return sprtdup
|
|
||||||
end
|
|
||||||
def spriteDraw(page, sprtptr)#0
|
|
||||||
byte ofst, map, y
|
|
||||||
var width, height
|
|
||||||
|
|
||||||
y = sprtptr->s_ypos
|
|
||||||
ofst, map = divmod7(sprtptr=>s_xpos)
|
|
||||||
if ofst & 1
|
|
||||||
map = map + 7
|
|
||||||
fin
|
|
||||||
sprtptr->s_underofst[page] = ofst
|
|
||||||
sprtptr->s_undery[page] = y
|
|
||||||
width = sprtptr=>s_pitch
|
|
||||||
height = sprtptr=>s_height
|
|
||||||
hgrCopyDst(ofst, y, width, height, sprtptr=>s_under[page])
|
|
||||||
hgrAndSrc( ofst, y, width, height, sprtptr=>s_mask[map])
|
|
||||||
hgrXorSrc( ofst, y, width, height, sprtptr=>s_map[map])
|
|
||||||
end
|
|
||||||
def spritePos(x, y, sprtptr)#0
|
|
||||||
sprtptr=>s_ypos = y
|
|
||||||
sprtptr=>s_xpos = x
|
|
||||||
end
|
|
||||||
def spritePosIndex(x, y, i)#0
|
|
||||||
i = i & 15
|
|
||||||
if spriteList[i]
|
|
||||||
spriteList[i]=>s_ypos = y
|
|
||||||
spriteList[i]=>s_xpos = x
|
|
||||||
fin
|
|
||||||
end
|
|
||||||
def spriteUnDraw(page, sprtptr)#0
|
|
||||||
if sprtptr->s_underofst[page] < 40
|
|
||||||
hgrCopySrc(sprtptr->s_underofst[page], sprtptr->s_undery[page], sprtptr=>s_pitch, sprtptr=>s_height, sprtptr=>s_under[page])
|
|
||||||
fin
|
|
||||||
end
|
|
||||||
def spriteDrawList#0
|
|
||||||
byte i
|
|
||||||
|
|
||||||
for i = 15 downto 0
|
|
||||||
if spriteList[i]
|
|
||||||
spriteUnDraw(drawpage, spriteList[i])
|
|
||||||
fin
|
|
||||||
next
|
|
||||||
for i = 0 to 15
|
|
||||||
if spriteList[i]
|
|
||||||
spriteDraw(drawpage, spriteList[i])
|
|
||||||
fin
|
|
||||||
next
|
|
||||||
end
|
|
||||||
def spriteAdd(i, sprtptr)
|
|
||||||
var sprtprev
|
|
||||||
|
|
||||||
i = i & 15
|
|
||||||
sprtprev = spriteList[i]
|
|
||||||
spriteList[i] = sprtptr
|
|
||||||
return sprtprev
|
|
||||||
end
|
|
||||||
def spriteDel(i)
|
|
||||||
var sprtprev
|
|
||||||
|
|
||||||
i = i & 15
|
|
||||||
sprtprev = spriteList[i]
|
|
||||||
spriteList[i] = 0
|
|
||||||
return sprtprev
|
|
||||||
end
|
|
||||||
def spriteDrawPage(page)#0
|
|
||||||
drawpage = page & 1
|
|
||||||
end
|
|
||||||
def testline#0
|
def testline#0
|
||||||
var i
|
var i
|
||||||
|
|
||||||
setlinespans(@hgrHlin, @hgrVlin)
|
setlinespans(@hgrHlin, @hgrVlin)
|
||||||
hgrColor(7)
|
hgrColor(7)
|
||||||
for i = 0 to 191 step 24
|
for i = 0 to 191 step 8
|
||||||
linetospans(0, 0, 279, i)
|
linetospans(0, 0, 279, i)
|
||||||
next
|
next
|
||||||
for i = 0 to 279 step 24
|
for i = 0 to 279 step 8
|
||||||
linetospans(0, 0, i, 191)
|
linetospans(0, 0, i, 191)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
@ -206,17 +58,17 @@ def testblt(sprtnum)#0
|
|||||||
spritePosIndex(i[k], j[k], k)
|
spritePosIndex(i[k], j[k], k)
|
||||||
next
|
next
|
||||||
spriteDrawList()
|
spriteDrawList()
|
||||||
spriteDrawPage(hgrSwap())
|
spriteDrawBuf(hgrSwap())
|
||||||
loop
|
loop
|
||||||
end
|
end
|
||||||
drawpage = hgrMode
|
hgrMode
|
||||||
hgrDrawBuf(0) // So we can see the compile process
|
spriteDrawBuf(hgrDrawBuf(0)) // So we can see the compile process
|
||||||
sprtBall = spriteCompile(10, 10, @ball)
|
sprtBall = spriteCompile(10, 10, @ball)
|
||||||
hgrColor(0)
|
hgrColor(0)
|
||||||
hgrClear()
|
hgrClear()
|
||||||
testline
|
testline
|
||||||
memcpy($4000, $2000, $2000) // Copy to both buffers
|
memcpy($4000, $2000, $2000) // Copy to both buffers
|
||||||
hgrDrawbuf(drawpage)
|
spriteDrawBuf(hgrDrawBuf(1))
|
||||||
spriteAdd(0, sprtBall)
|
spriteAdd(0, sprtBall)
|
||||||
spriteAdd(1, spriteDup(sprtBall))
|
spriteAdd(1, spriteDup(sprtBall))
|
||||||
spriteAdd(2, spriteDup(sprtBall))
|
spriteAdd(2, spriteDup(sprtBall))
|
||||||
|
Loading…
Reference in New Issue
Block a user