1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-24 05:33:50 +00:00

A little re-org and assembly-izing

This commit is contained in:
David Schmenk 2019-12-28 12:03:59 -08:00
parent 4a4468cc22
commit c09b15f377
8 changed files with 228 additions and 54 deletions

View File

@ -1,4 +1,4 @@
import sprite
import hgrsprite
predef spriteCompile(w, h, xcenter, ycenter, srcptr)#1
predef spriteDup(sprtsrc)#1
predef spriteRead(filestr)#1

View File

@ -2,9 +2,10 @@ include "inc/cmdsys.plh"
predef nopLin(a, b, c)#0
predef nopPix(a, b)#0
var hspan = @nopLin
var vspan = @nopLin
var plot = @nopPix
byte jmpplot = $4C // Sneaky!
var plot = @nopPix
var hspan = @nopLin
var vspan = @nopLin
var err, shorterr, shortlen, longerr, longlen
//def nopLin(a, b, c)#0
@ -82,7 +83,7 @@ asm _majorlineA
STA ESTKH+5,X ; MAJORSTARTH
end
asm _majorlineB
LDA $1001 ; ERRH
LDY $1001 ; ERRH
BMI +
end
asm _majorlineC
@ -90,7 +91,7 @@ asm _majorlineC
CLC
ADC $2000 ; SHORTERRL
STA $1000 ; ERRL
LDA $1001 ; ERRH
TYA ; ERRH
ADC $2001 ; SHORTERRH
STA $1001 ; ERRH
LDA ESTKL+4,X ; MAJORL
@ -108,7 +109,7 @@ asm _majorlineD
CLC
ADC $4000 ; LONGERRL
STA $1000 ; ERRL
LDA $1001 ; ERRH
TYA ; ERRH
ADC $4001 ; LONGERRL
STA $1001 ; ERRH
LDA ESTKL+4,X ; MAJORL
@ -143,9 +144,11 @@ asm _majorlineE
LDA ESTKH+5,X ; MINORH
STA ESTKH+0,X
JSR $B000
INX
INX
INX
TXA
CLC
ADC #$06
TAX
RTS
end
asm nopLin(a, b, c)#0
INX
@ -155,6 +158,179 @@ asm nopPix(a, b)#0
INX
RTS
end
//def hline(x1, x2, dx2, y, dy2, sy)#0
// var dyx2, x
//
// err = dy2 - dx2 / 2
// dyx2 = dy2 - dx2
// for x = x1 to x2
// plot(x, y)#0
// if err >= 0
// y = y + sy
// err = err + dyx2
// else
// err = err + dy2
// fin
// next
//end
asm hline(x1, x2, dx2, y, dy2, sy)#0
LDA ESTKH+3,X ; DX2H
LSR
STA TMPH
LDA ESTKL+3,X ; DX2L
ROR
STA TMPL
LDA ESTKL+1,X ; DY2L
SEC
SBC TMPL
STA $1000 ; ERRL
LDA ESTKH+1,X ; DY2H
SBC TMPH
STA $1001 ; ERRH
LDA ESTKL+1,X ; DY2L
SEC
SBC ESTKL+3,X ; DX2L
STA ESTKL+3,X ; DYX2L
LDA ESTKH+1,X ; DY2H
SBC ESTKH+3,X ; DX2H
STA ESTKH+3,X ; DYX2H
- DEX
DEX
LDA ESTKL+7,X ; XL
STA ESTKL+1,X
LDA ESTKH+7,X ; XH
STA ESTKH+1,X
LDA ESTKL+4,X ; YL
STA ESTKL+0,X
LDA ESTKH+4,X ; YH
STA ESTKH+0,X
end
asm _hlineA
JSR $2000 ; PLOT
LDA $1001 ; ERRH
BMI +
LDA ESTKL+2,X ; YL
CLC
ADC ESTKL+0,X ; SYL
STA ESTKL+2,X
LDA ESTKH+2,X ; YH
ADC ESTKH+0,X ; SYH
STA ESTKH+2,X
LDA ESTKL+3,X ; DYX2L
LDY ESTKH+3,X ; DYX2H
BEQ ++
BNE ++
end
asm _hlineB
+ LDA ESTKL+1,X ; DY2L
LDY ESTKH+1,X ; DY2H
++ CLC
ADC $1000 ; ERRL
STA $1000 ; ERRL
TYA
ADC $1001 ; ERRH
STA $1001 ; ERRH
LDA ESTKL+5,X ; X1L
CMP ESTKL+4,X ; X2L
LDA ESTKH+5,X
SBC ESTKH+4,X
BCS +
INC ESTKL+5,X ; XL
BNE -
INC ESTKH+5,X ; XH
BCC -
+ TXA
ADC #$05
TAX
RTS
end
//def vline(y1, y2, dy2, x, dx2, sx)#0
// var dxy2, y
//
// err = dx2 - dy2 / 2
// dxy2 = dx2 - dy2
// for y = y1 to y2
// plot(x, y)#0
// if err >= 0
// x = x + sx
// err = err + dxy2
// else
// err = err + dx2
// fin
// next
//end
asm vline(y1, y2, dy2, x, dx2, sx)#0
LDA ESTKH+3,X ; DY2H
LSR
STA TMPH
LDA ESTKL+3,X ; DY2L
ROR
STA TMPL
LDA ESTKL+1,X ; DX2L
SEC
SBC TMPL
STA $1000 ; ERRL
LDA ESTKH+1,X ; DX2H
SBC TMPH
STA $1001 ; ERRH
LDA ESTKL+1,X ; DX2L
SEC
SBC ESTKL+3,X ; DX2L
STA ESTKL+3,X ; DXY2L
LDA ESTKH+1,X ; DX2H
SBC ESTKH+3,X ; DY2H
STA ESTKH+3,X ; DXY2H
- DEX
DEX
LDA ESTKL+4,X ; XL
STA ESTKL+1,X
LDA ESTKH+4,X ; XH
STA ESTKH+1,X
LDA ESTKL+7,X ; YL
STA ESTKL+0,X
LDA ESTKH+7,X ; YH
STA ESTKH+0,X
end
asm _vlineA
JSR $2000 ; PLOT
LDA $1001 ; ERRH
BMI +
LDA ESTKL+2,X ; XL
CLC
ADC ESTKL+0,X ; SXL
STA ESTKL+2,X
LDA ESTKH+2,X ; XH
ADC ESTKH+0,X ; SXH
STA ESTKH+2,X
LDA ESTKL+3,X ; DXY2L
LDY ESTKH+3,X ; DXY2H
BEQ ++
BNE ++
end
asm _vlineB
+ LDA ESTKL+1,X ; DX2L
LDY ESTKH+1,X ; DX2H
++ CLC
ADC $1000 ; ERRL
STA $1000 ; ERRL
TYA
ADC $1001 ; ERRH
STA $1001 ; ERRH
LDA ESTKL+5,X ; Y1L
CMP ESTKL+4,X ; Y2L
LDA ESTKH+5,X
SBC ESTKH+4,X
BCS +
INC ESTKL+5,X ; YL
BNE -
INC ESTKH+5,X ; YH
BCC -
+ TXA
ADC #$05
TAX
RTS
end
export def setlinespans(h, v)#0
hspan = h
vspan = v
@ -241,17 +417,17 @@ export def setlineplot(p)#0
plot = p
end
export def line(x1, y1, x2, y2)#0
var sx, sy, dx2, dy2, x, y
var sx, sy, dx2, dy2
sx = 1
sy = 1
dx2 = (x2 - x1) * 2
if dx2 < 0
sx = -1; dx2 = -dx2
sx = -1; dx2 = -dx2
fin
dy2 = (y2 - y1) * 2
if dy2 < 0
sy = -1; dy2 = -dy2
sy = -1; dy2 = -dy2
fin
if dx2 >= dy2
if sx < 0
@ -259,30 +435,14 @@ export def line(x1, y1, x2, y2)#0
y1, y2 = y2, y1
sy = -sy
fin
err = dy2 - dx2 / 2
for x = x1 to x2
plot(x, y1)#0
if err >= 0
err = err - dx2
y1 = y1 + sy
fin
err = err + dy2
next
hline(x1, x2, dx2, y1, dy2, sy)
else
if sy < 0
y1, y2 = y2, y1
x1, x2 = x2, x1
sx = -sx
fin
err = dx2 - dy2 / 2
for y = y1 to y2
plot(x1, y)#0
if err >= 0
err = err - dy2
x1 = x1 + sx
fin
err = err + dx2
next
vline(y1, y2, dy2, x1, dx2, sx)
fin
end
@ -303,18 +463,32 @@ _majorlineB:1 = @err.1
_majorlineC:1 = @err
_majorlineC:5 = @shorterr
_majorlineC:8 = @err
_majorlineC:11 = @err.1
_majorlineC:14 = @shorterr.1
_majorlineC:17 = @err.1
_majorlineC:23 = @shortlen
_majorlineC:30 = @shortlen.1
_majorlineC:12 = @shorterr.1
_majorlineC:15 = @err.1
_majorlineC:21 = @shortlen
_majorlineC:28 = @shortlen.1
_majorlineD:1 = @err
_majorlineD:5 = @longerr
_majorlineD:8 = @err
_majorlineD:11 = @err.1
_majorlineD:14 = @longerr.1
_majorlineD:17 = @err.1
_majorlineD:23 = @longlen
_majorlineD:30 = @longlen.1
_majorlineD:12 = @longerr.1
_majorlineD:15 = @err.1
_majorlineD:21 = @longlen
_majorlineD:28 = @longlen.1
_majorlineE:1 = @_majorlineA
hline:16 = @err
hline:23 = @err.1
_hlineA:1 = @jmpplot
_hlineA:4 = @err.1
_hlineB:6 = @err
_hlineB:9 = @err
_hlineB:13 = @err.1
_hlineB:16 = @err.1
vline:16 = @err
vline:23 = @err.1
_vlineA:1 = @jmpplot
_vlineA:4 = @err.1
_vlineB:6 = @err
_vlineB:9 = @err
_vlineB:13 = @err.1
_vlineB:16 = @err.1
done

View File

@ -58,8 +58,8 @@ TFTPD = rel/TFTPD\#FE1000
HGRLIB = rel/apple/HGRLIB\#FE1000
GRLIB = rel/apple/GRLIB\#FE1000
DGRLIB = rel/apple/DGRLIB\#FE1000
SPRITE = rel/apple/SPRITE\#FE1000
LINES = rel/apple/LINES\#FE1000
HGRSPRITE = rel/apple/HGRSPRITE\#FE1000
LINES = rel/LINES\#FE1000
GRAFIX = rel/apple/GRAFIX\#FE1000
GFXDEMO = rel/apple/GFXDEMO\#FE1000
JOYBUZZ = rel/apple/JOYBUZZ\#FE1000
@ -100,7 +100,7 @@ TXTTYPE = .TXT
#SYSTYPE = \#FF2000
#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) $(LINES) $(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)
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) $(LINES) $(HGRSPRITE) $(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
@ -417,9 +417,9 @@ $(DGRLIB): libsrc/apple/dgrlib.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/dgrlib.pla > 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
$(HGRSPRITE): libsrc/apple/hgrsprite.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/hgrsprite.pla > libsrc/apple/hgrsprite.a
acme --setpc 4094 -o $(HGRSPRITE) libsrc/apple/hgrsprite.a
$(HGRTEST): samplesrc/hgrtest.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/hgrtest.pla > samplesrc/hgrtest.a

View File

@ -9,8 +9,8 @@ rm -rf prodos/sys
mkdir prodos/sys
cp rel/apple/FILEIO#FE1000 prodos/sys/FILEIO.REL
cp rel/apple/CONIO#FE1000 prodos/sys/CONIO.REL
cp rel/apple/LINES#FE1000 prodos/sys/LINES.REL
cp rel/apple/SPRITE#FE1000 prodos/sys/SPRITE.REL
cp rel/LINES#FE1000 prodos/sys/LINES.REL
cp rel/apple/HGRSPRITE#FE1000 prodos/sys/HGRSPRITE.REL
cp rel/apple/HGRLIB#FE1000 prodos/sys/HGRLIB.REL
cp rel/apple/GRLIB#FE1000 prodos/sys/GRLIB.REL
cp rel/apple/DGRLIB#FE1000 prodos/sys/DGRLIB.REL
@ -151,7 +151,7 @@ cp inc/args.plh prodos/bld/inc/ARGS.PLH.TXT
cp inc/cmdsys.plh prodos/bld/inc/CMDSYS.PLH.TXT
cp inc/conio.plh prodos/bld/inc/CONIO.PLH.TXT
cp inc/lines.plh prodos/bld/inc/LINES.PLH.TXT
cp inc/sprite.plh prodos/bld/inc/SPRITE.PLH.TXT
cp inc/hgrsprite.plh prodos/bld/inc/HGRSPRITE.PLH.TXT
cp inc/hgrlib.plh prodos/bld/inc/HGRLIB.PLH.TXT
cp inc/grlib.plh prodos/bld/inc/GRLIB.PLH.TXT
cp inc/dgrlib.plh prodos/bld/inc/DGRLIB.PLH.TXT

View File

@ -1,6 +1,6 @@
include "inc/cmdsys.plh"
include "inc/hgrlib.plh"
include "inc/sprite.plh"
include "inc/hgrsprite.plh"
include "inc/lines.plh"
sysflags reshgr1|reshgr2 // Reserve HGR page 1 and 2

View File

@ -9,7 +9,7 @@ echo "BLD/INC/ARGS.PLH"; atftp $1 --put -l inc/args.plh -r $2/BLD/INC/ARG
echo "BLD/INC/CMDSYS.PLH"; atftp $1 --put -l inc/cmdsys.plh -r $2/BLD/INC/CMDSYS.PLH#040000
echo "BLD/INC/CONIO.PLH"; atftp $1 --put -l inc/conio.plh -r $2/BLD/INC/CONIO.PLH#040000
echo "BLD/INC/LINES.PLH"; atftp $1 --put -l inc/lines.plh -r $2/BLD/INC/LINES.PLH#040000
echo "BLD/INC/SPRITE.PLH"; atftp $1 --put -l inc/sprite.plh -r $2/BLD/INC/SPRITE.PLH#040000
echo "BLD/INC/HGRSPRITE.PLH";atftp $1 --put -l inc/hgrsprite.plh -r $2/BLD/INC/HGRSPRITE.PLH#040000
echo "BLD/INC/HGRLIB.PLH"; atftp $1 --put -l inc/hgrlib.plh -r $2/BLD/INC/HGRLIB.PLH#040000
echo "BLD/INC/GRLIB.PLH"; atftp $1 --put -l inc/grlib.plh -r $2/BLD/INC/GRLIB.PLH#040000
echo "BLD/INC/DGRLIB.PLH"; atftp $1 --put -l inc/dgrlib.plh -r $2/BLD/INC/DGRLIB.PLH#040000

View File

@ -22,8 +22,8 @@ echo "SYS/LONGJUMP"; atftp $1 --put -l rel/LONGJMP#FE1000 -r $2/SYS/LONGJMP#FE10
echo "SYS/MEMMGR"; atftp $1 --put -l rel/MEMMGR#FE1000 -r $2/SYS/MEMMGR#FE1000
echo "SYS/LZ4"; atftp $1 --put -l rel/LZ4#FE1000 -r $2/SYS/LZ4#FE1000
echo "SYS/CONIO"; atftp $1 --put -l rel/apple/CONIO#FE1000 -r $2/SYS/CONIO#FE1000
echo "SYS/SPRITE"; atftp $1 --put -l rel/apple/SPRITE#FE1000 -r $2/SYS/SPRITE#FE1000
echo "SYS/LINES"; atftp $1 --put -l rel/apple/LINES#FE1000 -r $2/SYS/LINES#FE1000
echo "SYS/HGRSPRITE"; atftp $1 --put -l rel/apple/HGRSPRITE#FE1000 -r $2/SYS/HGRSPRITE#FE1000
echo "SYS/LINES"; atftp $1 --put -l rel/LINES#FE1000 -r $2/SYS/LINES#FE1000
echo "SYS/HGRLIB"; atftp $1 --put -l rel/apple/HGRLIB#FE1000 -r $2/SYS/HGRLIB#FE1000
echo "SYS/GRLIB"; atftp $1 --put -l rel/apple/GRLIB#FE1000 -r $2/SYS/GRLIB#FE1000
echo "SYS/DGRLIB"; atftp $1 --put -l rel/apple/DGRLIB#FE1000 -r $2/SYS/DGRLIB#FE1000