diff --git a/src/inc/line.plh b/src/inc/line.plh new file mode 100644 index 0000000..c7e63f4 --- /dev/null +++ b/src/inc/line.plh @@ -0,0 +1,6 @@ +import line + predef setlinespans(h, v)#0 + predef linespans(x1, y1, x2, y2)#0 + predef setlineplot(p)#0 + predef line(x1, y1, x2, y2)#0 +end diff --git a/src/inc/linespans.plh b/src/inc/linespans.plh deleted file mode 100644 index 3145d3f..0000000 --- a/src/inc/linespans.plh +++ /dev/null @@ -1,4 +0,0 @@ -import linespans - predef setlinespans(h, v)#0 - predef linetospans(x1, y1, x2, y2)#0 -end diff --git a/src/libsrc/apple/hgrlib.pla b/src/libsrc/apple/hgrlib.pla index 6a85e88..8397da7 100644 --- a/src/libsrc/apple/hgrlib.pla +++ b/src/libsrc/apple/hgrlib.pla @@ -110,49 +110,153 @@ byte = $8F, $FF, $FF, $FF, $F8 byte = $88, $FF, $FF, $FF, $88 byte = $88, $8F, $FF, $F8, $88 -asm grInc(buff) -!SOURCE "vmsrc/plvmzp.inc" -end - export asm divmod7(x)#2 - LDA ESTKL,X ; X COORD LSB - LDY ESTKH,X ; X COORD MSB - BNE + ; MUST BE >= 140 - CMP #140 - BCC ++ -+ SEC +!SOURCE "vmsrc/plvmzp.inc" + LDY ESTKH+0,X ; X COORDH + BPL + + LDA #$00 + SEC + SBC ESTKL+0,X + STA ESTKL+0,X + LDA #$00 + SBC ESTKH+0,X + TAY ++ LDA ESTKL+0,X ; X COORDL + CPY #$01 + BEQ ++ ; MUST BE >= 140 + BCC + + LDY #40 ; > 512 SO CLIP AT MAX + LDA #00 + BEQ +++ ++ CMP #140 + BCC + +++ SEC SBC #140 LDY #20 -++ CMP #70 ++ CMP #70 BCC + SBC #70 - STA ESTKL,X + STA ESTKL+0,X TYA ADC #9 TAY - LDA ESTKL,X + LDA ESTKL+0,X + CMP #35 BCC + SBC #35 - STA ESTKL,X + STA ESTKL+0,X TYA ADC #4 TAY - LDA ESTKL,X + LDA ESTKL+0,X + - CMP #7 - BCC + + BCC +++ SBC #7 INY BNE - -+ DEX - STA ESTKL,X ; REMAINDER - STY ESTKL+1,X ; QUOTIENT ++++ DEX + ASL ESTKH+1,X ; CHECK SIGN OF XCOORD + BCS + + STA ESTKL+0,X ; REMAINDERL LDA #$00 - STA ESTKH,X + STA ESTKH+0,X + STY ESTKL+1,X ; QUOTIENTL STA ESTKH+1,X RTS -end ++ EOR #$07 + STA ESTKL+0,X ; REMAINDERL + LDA #$00 + STA ESTKH+0,X + TYA + EOR #$FF + STA ESTKL+1,X ; QUOTIENTL + LDA #$FF + STA ESTKH+1,X + RTS +end +asm clipsrc(ofst, y, w, h, srcptr)#0 + LDA ESTKL+0,X ; SRC PTR + STA SRCL + LDA ESTKH+0,X + STA SRCH + LDA ESTKL+2,X ; WIDTH (SRC PITCH) + STA TMPH ; WIDTH (DRAW WIDTH) +; CLPTOP + LDY ESTKH+3,X ; Y COORDH + BPL CLPBOTM + INY +; STY ESTKH+3,X ; Y COORDH + BNE CLPPED + LDY ESTKL+3,X ; Y COORDL +- LDA SRCL + CLC + ADC ESTKL+2,X ; PITCH + STA SRCL + BCC + + INC SRCH ++ DEC ESTKL+1,X ; HEIGHT + BEQ CLPPED + INY ; Y COORDL + BNE - + STY ESTKL+3,X ; Y COORDL + BEQ CLPLEFT ; BETTER BE ZERO +CLPBOTM BNE CLPPED + LDA ESTKL+3,X ; YCOORDL + CMP #192 + BCS CLPPED +; CLC + ADC ESTKL+1,X ; HEIGHT + SBC #191 + BCC CLPLEFT + STA TMPL + LDA ESTKL+1,X ; HEIGHT + SBC TMPL + STA ESTKL+1,X ; HEIGHT + BEQ CLPPED +CLPLEFT LDY ESTKH+4,X ; HORIZ OFFSETH + BPL CLPRGHT + INY +; STY ESTKH+4,X + BNE CLPPED + LDY ESTKL+4,X ; HORIZ OFFSETL +- INC SRCL + BNE + + INC SRCH ++ DEC TMPH ; WIDTH + BEQ CLPPED + INY ; HORIZ OFFSETL + BNE - + STY ESTKL+4,X ; HORIZ OFFSETL + BEQ CLPDONE ; BETTER BE ZERO +CLPRGHT BNE CLPPED + LDA ESTKL+4,X ; HORIZ OFFSETL + CMP #40 + BCS CLPPED +; CLC + ADC TMPH ; WIDTH + SBC #39 + BCC CLPDONE + STA TMPL + LDA TMPH ; WIDTH + SBC TMPL + STA TMPH ; WIDTH +CLPDONE LDA TMPH + STA ESTKH+2,X ; WIDTH (DRAW WIDTH) +; LDA SRCL +; STA ESTKL+0,X ; SRC PTR +; LDA SRCH +; STA ESTKH+0,X + RTS +CLPPED INX + INX + INX + INX + INX + PLA + PLA + RTS +end //export def hgrColor(c)#0 // curhclr = hcolor[c & $07] //end @@ -179,14 +283,16 @@ end // next //end export asm hgrCopyDst(ofst, y, w, h, dstptr)#0 - LDA ESTKL+0,X ; DST PTR + JSR $C000 ; CLIPSRC +; LDA ESTKL+0,X ; DST PTR + LDA SRCL STA DSTL - LDA ESTKH+0,X +; LDA ESTKH+0,X + LDA SRCH STA DSTH -- LDY ESTKL+3,X ; Y COORD - CPY #192 - BCS + LDA ESTKL+4,X ; HORIZ OFFSET + CLC end asm _hgrCopyDst ADC $8000,Y ; HGRSCANL @@ -194,15 +300,15 @@ asm _hgrCopyDst LDA $1000 ; DRAWBUFFH ADC $9000,Y ; HGRSCANH STA SRCH - LDY ESTKL+2,X ; WIDTH + LDY ESTKH+2,X ; WIDTH DEY - LDA (SRC),Y STA (DST),Y DEY BPL - -+ LDA DSTL + LDA DSTL CLC - ADC ESTKL+2,X ; WIDTH + ADC ESTKL+2,X ; PITCH STA DSTL BCC + INC DSTH @@ -227,14 +333,14 @@ end // next //end export asm hgrCopySrc(ofst, y, w, h, srcptr)#0 - LDA ESTKL+0,X ; SRC PTR - STA SRCL - LDA ESTKH+0,X - STA SRCH + JSR $C000 ; CLIPSRC +; LDA ESTKL+0,X ; SRC PTR +; STA SRCL +; LDA ESTKH+0,X +; STA SRCH -- LDY ESTKL+3,X ; Y COORD - CPY #192 - BCS + LDA ESTKL+4,X ; HORIZ OFFSET + CLC end asm _hgrCopySrc ADC $8000,Y ; HGRSCANL @@ -242,15 +348,15 @@ asm _hgrCopySrc LDA $1000 ; DRAWBUFFH ADC $9000,Y ; HGRSCANH STA DSTH - LDY ESTKL+2,X ; WIDTH + LDY ESTKH+2,X ; WIDTH DEY - LDA (SRC),Y STA (DST),Y DEY BPL - -+ LDA SRCL + LDA SRCL CLC - ADC ESTKL+2,X ; WIDTH + ADC ESTKL+2,X ; PITCH STA SRCL BCC + INC SRCH @@ -278,14 +384,14 @@ end // next //end export asm hgrAndSrc(ofst, y, w, h, srcptr)#0 - LDA ESTKL+0,X ; SRC PTR - STA SRCL - LDA ESTKH+0,X - STA SRCH + JSR $C000 ; CLIPSRC +; LDA ESTKL+0,X ; SRC PTR +; STA SRCL +; LDA ESTKH+0,X +; STA SRCH -- LDY ESTKL+3,X ; Y COORD - CPY #192 - BCS + LDA ESTKL+4,X ; HORIZ OFFSET + CLC end asm _hgrAndSrc ADC $8000,Y ; HGRSCANL @@ -293,16 +399,16 @@ asm _hgrAndSrc LDA $1000 ; DRAWBUFFH ADC $9000,Y ; HGRSCANH STA DSTH - LDY ESTKL+2,X ; WIDTH + LDY ESTKH+2,X ; WIDTH DEY - LDA (SRC),Y AND (DST),Y STA (DST),Y DEY BPL - -+ LDA SRCL + LDA SRCL CLC - ADC ESTKL+2,X ; WIDTH + ADC ESTKL+2,X ; PITCH STA SRCL BCC + INC SRCH @@ -330,14 +436,14 @@ end // next //end export asm hgrXorSrc(ofst, y, w, h, srcptr)#0 - LDA ESTKL+0,X ; SRC PTR - STA SRCL - LDA ESTKH+0,X - STA SRCH + JSR $C000 ; CLIPSRC +; LDA ESTKL+0,X ; SRC PTR +; STA SRCL +; LDA ESTKH+0,X +; STA SRCH -- LDY ESTKL+3,X ; Y COORD - CPY #192 - BCS + LDA ESTKL+4,X ; HORIZ OFFSET + CLC end asm _hgrXorSrc ADC $8000,Y ; HGRSCANL @@ -345,16 +451,16 @@ asm _hgrXorSrc LDA $1000 ; DRAWBUFFH ADC $9000,Y ; HGRSCANH STA DSTH - LDY ESTKL+2,X ; WIDTH + LDY ESTKH+2,X ; WIDTH DEY - LDA (SRC),Y EOR (DST),Y STA (DST),Y DEY BPL - -+ LDA SRCL + LDA SRCL CLC - ADC ESTKL+2,X ; WIDTH + ADC ESTKL+2,X ; PITCH STA SRCL BCC + INC SRCH @@ -382,14 +488,14 @@ end // next //end export asm hgrOrSrc(ofst, y, w, h, srcptr)#0 - LDA ESTKL+0,X ; SRC PTR - STA SRCL - LDA ESTKH+0,X - STA SRCH + JSR $C000 ; CLIPSRC +; LDA ESTKL+0,X ; SRC PTR +; STA SRCL +; LDA ESTKH+0,X +; STA SRCH -- LDY ESTKL+3,X ; Y COORD - CPY #192 - BCS + LDA ESTKL+4,X ; HORIZ OFFSET + CLC end asm _hgrOrSrc ADC $8000,Y ; HGRSCANL @@ -397,16 +503,16 @@ asm _hgrOrSrc LDA $1000 ; DRAWBUFFH ADC $9000,Y ; HGRSCANH STA DSTH - LDY ESTKL+2,X ; WIDTH + LDY ESTKH+2,X ; WIDTH DEY - LDA (SRC),Y ORA (DST),Y STA (DST),Y DEY BPL - -+ LDA SRCL + LDA SRCL CLC - ADC ESTKL+2,X ; WIDTH + ADC ESTKL+2,X ; PITCH STA SRCL BCC + INC SRCH @@ -711,6 +817,99 @@ asm _hgrVLinC INX RTS end +// +// BLT scanline of pixmap +// +asm scanBLT(x, y, w, srcptr)#0 + LDA ESTKL+0,X ; SRC PTR + STA SRCL + LDA ESTKH+0,X + STA SRCH + LDA #$00 +- PHA + LSR + TAY + LDA (SRC),Y + LSR + LSR + LSR + LSR + PHA + DEX + STA ESTKL+0,X +end +asm _scanBLTA + JSR $C000 ; HCOLOR + DEX + DEX + LDA ESTKL+5,X ; X COORDL + STA ESTKL+1,X + LDA ESTKH+5,X ; X COORDH + STA ESTKH+1,X + LDA ESTKL+4,X ; Y COORDL + STA ESTKL+0,X + LDA ESTKH+4,X ; Y COORDH + STA ESTKH+0,X + PLA + AND #$08 + BEQ + +end +asm _scanBLTB + JSR $D000 ; HPLOT + BEQ ++ + BNE ++ ++ JSR $E000 ; HPLOTX +++ INC ESTKL+3,X ; X COORDL + BNE + + INC ESTKH+3,X ; X COORDH ++ PLA + CLC + ADC #$01 + CMP ESTKL+1,X ; WIDTH + BEQ BLTDONE + PHA + LSR + TAY + LDA (SRC),Y + PHA + DEX + STA ESTKL+0,X +end +asm _scanBLTC + JSR $C000 ; HCOLOR + DEX + DEX + LDA ESTKL+5,X ; X COORDL + STA ESTKL+1,X + LDA ESTKH+5,X ; X COORDH + STA ESTKH+1,X + LDA ESTKL+4,X ; Y COORDL + STA ESTKL+0,X + LDA ESTKH+4,X ; Y COORDH + STA ESTKH+0,X + PLA + AND #$08 + BEQ + +end +asm _scanBLTD + JSR $D000 ; HPLOT + BEQ ++ + BNE ++ ++ JSR $E000 ; HPLOTX +++ INC ESTKL+3,X ; X COORDL + BNE + + INC ESTKH+3,X ; X COORDH ++ PLA + CLC + ADC #$01 + CMP ESTKL+1,X ; WIDTH + BNE - +BLTDONE INX + INX + INX + INX + RTS +end export def hgrRect(x1, x2, y1, y2)#0 word y @@ -729,24 +928,25 @@ export def hgrBLT(x, y, w, h, srcptr)#0 saveclr = curhclr for j = y to y + h - 1 - for i = 0 to w - 1 - c = srcptr->[i >> 1] - if i & 1 - hgrColor(c) - if c & $08 - hgrXorPlot(x + i, j) - else - hgrPlot(x + i, j) - fin - else - hgrColor(c >> 4) - if c & $80 - hgrXorPlot(x + i, j) - else - hgrPlot(x + i, j) - fin - fin - next + scanBLT(x, j, w, srcptr) +// for i = 0 to w - 1 +// c = srcptr->[i >> 1] +// if i & 1 +// hgrColor(c) +// if c & $08 +// hgrXorPlot(x + i, j) +// else +// hgrPlot(x + i, j) +// fin +// else +// hgrColor(c >> 4) +// if c & $80 +// hgrXorPlot(x + i, j) +// else +// hgrPlot(x + i, j) +// fin +// fin +// next srcptr = srcptr + (w + 1) / 2 next curhclr = saveclr @@ -790,18 +990,23 @@ end // // Assembly fixups // +hgrCopyDst:1 = @clipsrc _hgrCopyDst:1 = @hgrscanl _hgrCopyDst:6 = @drawbuff.1 _hgrCopyDst:9 = @hgrscanh +hgrCopySrc:1 = @clipsrc _hgrCopySrc:1 = @hgrscanl _hgrCopySrc:6 = @drawbuff.1 _hgrCopySrc:9 = @hgrscanh +hgrAndSrc:1 = @clipsrc _hgrAndSrc:1 = @hgrscanl _hgrAndSrc:6 = @drawbuff.1 _hgrAndSrc:9 = @hgrscanh +hgrXorSrc:1 = @clipsrc _hgrXorSrc:1 = @hgrscanl _hgrXorSrc:6 = @drawbuff.1 _hgrXorSrc:9 = @hgrscanh +hgrOrSrc:1 = @clipsrc _hgrOrSrc:1 = @hgrscanl _hgrOrSrc:6 = @drawbuff.1 _hgrOrSrc:9 = @hgrscanh @@ -839,4 +1044,10 @@ hgrColor:7 = @hcolor hgrColor:10 = @curhclr hgrColor:13 = @hcolor.1 hgrColor:16 = @curhclr.1 +_scanBLTA:1 = @hgrColor +_scanBLTB:1 = @hgrPlot +_scanBLTB:8 = @hgrXorPlot +_scanBLTC:1 = @hgrColor +_scanBLTD:1 = @hgrPlot +_scanBLTD:8 = @hgrXorPlot done diff --git a/src/libsrc/apple/sprite.pla b/src/libsrc/apple/sprite.pla index 60f61c2..358a94a 100644 --- a/src/libsrc/apple/sprite.pla +++ b/src/libsrc/apple/sprite.pla @@ -5,36 +5,119 @@ include "inc/fileio.plh" struc t_sprite var s_xpos var s_ypos + var s_undery[2] + var s_underofst[2] byte s_undermap[2] - byte s_underofst[2] - byte s_undery[2] byte s_pitch - var s_height + byte s_height var s_size var s_mask[14] var s_map[14] var s_under[14] end -var spriteList[16] +var drawList[16] +var undrawList0[16] +var undrawList1[16] +var undrawList[2] = @undrawList0, @undrawList1 byte drawpage // // Sprite routines // +asm scanMask(x, y, w, srcptr)#0 +!SOURCE "vmsrc/plvmzp.inc" + LDA ESTKL+0,X ; SRC PTR + STA SRCL + LDA ESTKH+0,X + STA SRCH + LDA #$00 +- PHA + LSR + TAY + LDA (SRC),Y + AND #$80 + BEQ + + LDA #$03 ++ DEX + STA ESTKL+0,X +end +asm _scanMaskA + JSR $C000 ; HCOLOR + DEX + DEX + LDA ESTKL+5,X ; X COORDL + STA ESTKL+1,X + LDA ESTKH+5,X ; X COORDH + STA ESTKH+1,X + LDA ESTKL+4,X ; Y COORDL + STA ESTKL+0,X + LDA ESTKH+4,X ; Y COORDH + STA ESTKH+0,X +end +asm _scanMaskB + JSR $D000 ; HPLOT + INC ESTKL+3,X ; X COORDL + BNE + + INC ESTKH+3,X ; X COORDH ++ PLA + CLC + ADC #$01 + CMP ESTKL+1,X ; WIDTH + BEQ BLTDONE + PHA + LSR + TAY + LDA (SRC),Y + AND #$08 + BEQ + + LDA #$03 ++ DEX + STA ESTKL+0,X +end +asm _scanMaskC + JSR $C000 ; HCOLOR + DEX + DEX + LDA ESTKL+5,X ; X COORDL + STA ESTKL+1,X + LDA ESTKH+5,X ; X COORDH + STA ESTKH+1,X + LDA ESTKL+4,X ; Y COORDL + STA ESTKL+0,X + LDA ESTKH+4,X ; Y COORDH + STA ESTKH+0,X +end +asm _scanMaskD + JSR $D000 ; HPLOT + INC ESTKL+3,X ; X COORDL + BNE + + INC ESTKH+3,X ; X COORDH ++ PLA + CLC + ADC #$01 + CMP ESTKL+1,X ; WIDTH + BNE - +BLTDONE INX + INX + INX + INX + RTS +end 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 + scanMask(x, j, w, srcptr) +// 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 @@ -46,7 +129,7 @@ export def spriteCompile(w, h, srcptr)#1 sprtptr->s_pitch = bytewidth spritesize = bytewidth * h sprtptr=>s_size = spritesize - sprtptr=>s_height = h + sprtptr->s_height = h sprtptr=>s_under[0] = heapalloc(spritesize) sprtptr=>s_under[1] = heapalloc(spritesize) for i = 0 to 13 @@ -61,8 +144,6 @@ export def spriteCompile(w, h, srcptr)#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 @@ -73,15 +154,13 @@ export def spriteDup(sprtsrc)#1 spritesize = sprtsrc=>s_size sprtdup=>s_size = spritesize sprtdup->s_pitch = sprtsrc->s_pitch - sprtdup=>s_height = sprtsrc=>s_height + 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 spriteRead(filestr)#1 @@ -91,24 +170,22 @@ export def spriteRead(filestr)#1 sprtptr = 0 refnum = fileio:open(@filestr) if refnum - sprtptr = heapalloc(t_sprite) - if fileio:read(refnum, sprtptr, t_sprite) == t_sprite - spritesize = sprtptr=>s_size - 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) - fileio:read(refnum, sprtptr=>s_map[i], spritesize) - fileio:read(refnum, sprtptr=>s_mask[i], spritesize) - next - sprtptr->s_underofst[0] = 255 // Mark as under not valid - sprtptr->s_underofst[1] = 255 + sprtptr = heapalloc(t_sprite) + if fileio:read(refnum, sprtptr, t_sprite) == t_sprite + spritesize = sprtptr=>s_size + 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) + fileio:read(refnum, sprtptr=>s_map[i], spritesize) + fileio:read(refnum, sprtptr=>s_mask[i], spritesize) + next else - heaprelease(sprtptr) - sprtptr = 0 - fin - fileio:close(refnum) + heaprelease(sprtptr) + sprtptr = 0 + fin + fileio:close(refnum) fin return sprtptr end @@ -120,62 +197,57 @@ export def spriteSave(filestr, sprtptr)#1 if fileio:create(@filestr, $06, $0000) == FILE_ERR_OK refnum = fileio:open(@filestr) if refnum - if fileio:write(refnum, sprtptr, t_sprite) == t_sprite - spritesize = sprtptr=>s_size - for i = 0 to 13 - fileio:write(refnum, sprtptr=>s_map[i], spritesize) - fileio:write(refnum, sprtptr=>s_mask[i], spritesize) - next - fin - fileio:close(refnum) - return 0 - fin + if fileio:write(refnum, sprtptr, t_sprite) == t_sprite + spritesize = sprtptr=>s_size + for i = 0 to 13 + fileio:write(refnum, sprtptr=>s_map[i], spritesize) + fileio:write(refnum, sprtptr=>s_mask[i], spritesize) + next + fin + fileio:close(refnum) + return 0 + fin fin return -1 end - export def spriteDraw(sprtptr)#0 - byte ofst, map, y - var width, height + byte map, pitch, height + var ofst, y - y = sprtptr->s_ypos + 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]) + sprtptr=>s_underofst[drawpage] = ofst + sprtptr=>s_undery[drawpage] = y + pitch = sprtptr->s_pitch + height = sprtptr->s_height + hgrCopyDst(ofst, y, pitch, height, sprtptr=>s_under[drawpage]) + hgrAndSrc( ofst, y, pitch, height, sprtptr=>s_mask[map]) + hgrXorSrc( ofst, y, pitch, 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 + hgrCopySrc(sprtptr=>s_underofst[drawpage], sprtptr=>s_undery[drawpage], sprtptr->s_pitch, sprtptr->s_height, sprtptr=>s_under[drawpage]) end export def spriteDrawXor(sprtptr)#0 - byte ofst, map, y - var width, height + byte map, pitch, height + var ofst, y - y = sprtptr->s_ypos + 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]) + sprtptr=>s_underofst[drawpage] = ofst + sprtptr=>s_undery[drawpage] = y + pitch = sprtptr->s_pitch + height = sprtptr->s_height + hgrXorSrc( ofst, y, pitch, 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 + hgrXorSrc(sprtptr=>s_underofst[drawpage], sprtptr=>s_undery[drawpage], sprtptr->s_pitch, sprtptr->s_height, sprtptr=>s_map[sprtptr->s_undermap[drawpage]]) end export def spritePos(x, y, sprtptr)#0 sprtptr=>s_ypos = y @@ -183,51 +255,67 @@ export def spritePos(x, y, sprtptr)#0 end export def spritePosIndex(x, y, i)#0 i = i & 15 - if spriteList[i] - spriteList[i]=>s_ypos = y - spriteList[i]=>s_xpos = x + if drawList[i] + drawList[i]=>s_ypos = y + drawList[i]=>s_xpos = x fin end export def spriteDrawList#0 byte i + var undrawptr + undrawptr = undrawList[drawpage] for i = 15 downto 0 - if spriteList[i] - spriteUnDraw(spriteList[i]) + if undrawptr=>[i] + spriteUnDraw(undrawptr=>[i]) fin next for i = 0 to 15 - if spriteList[i] - spriteDraw(spriteList[i]) + if drawList[i] + spriteDraw(drawList[i]) fin next + memcpy(undrawptr, @drawList, 16*2) end export def spriteDrawXorList#0 byte i + var undrawptr + + undrawptr = undrawList[drawpage] for i = 0 to 15 - if spriteList[i] - spriteUnDrawXor(spriteList[i]) - spriteDrawXor(spriteList[i]) + if undrawptr=>[i] + spriteUnDrawXor(undrawptr=>[i]) + fin + if drawList[i] + spriteDrawXor(drawList[i]) fin next + memcpy(undrawptr, @drawList, 16*2) end export def spriteAdd(i, sprtptr)#1 var sprtprev i = i & 15 - sprtprev = spriteList[i] - spriteList[i] = sprtptr + sprtprev = drawList[i] + drawList[i] = sprtptr return sprtprev end export def spriteDel(i)#1 var sprtprev i = i & 15 - sprtprev = spriteList[i] - spriteList[i] = 0 + sprtprev = drawList[i] + drawList[i] = 0 return sprtprev end export def spriteDrawBuf(page)#0 drawpage = page & 1 end +// +// Assembly fixups +// +_scanMaskA:1 = @hgrColor +_scanMaskB:1 = @hgrPlot +_scanMaskC:1 = @hgrColor +_scanMaskD:1 = @hgrPlot done diff --git a/src/libsrc/linespans.pla b/src/libsrc/line.pla similarity index 86% rename from src/libsrc/linespans.pla rename to src/libsrc/line.pla index 343c80e..183d2e3 100644 --- a/src/libsrc/linespans.pla +++ b/src/libsrc/line.pla @@ -1,8 +1,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 var err, shorterr, shortlen, longerr, longlen //def nopLin(a, b, c)#0 @@ -147,6 +149,8 @@ asm _majorlineE end asm nopLin(a, b, c)#0 INX +end +asm nopPix(a, b)#0 INX INX RTS @@ -155,7 +159,7 @@ export def setlinespans(h, v)#0 hspan = h vspan = v end -export def linetospans(x1, y1, x2, y2)#0 +export def linespans(x1, y1, x2, y2)#0 var dx, dy, dx2, dy2, halflen, rem, sx, sy sx = 1 @@ -229,6 +233,51 @@ export def linetospans(x1, y1, x2, y2)#0 majorline(y1, y1 + halflen, y2, x1, sx, vspan) fin end +export def setlineplot(p)#0 + plot = p +end +export def line(x1, y1, x2, y2)#0 + var sx, sy, dx2, dy2, x, y + + sx = 1 + sy = 1 + dx2 = (x2 - x1) * 2 + if dx2 < 0 + sx = -1; dx2 = -dx2 + fin + dy2 = (y2 - y1) * 2 + if dy2 < 0 + sy = -1; dy2 = -dy2 + fin + if dx2 >= dy2 + if sx < 0 + sy = -sy; x1, x2 = x2, x1 + fin + err = dy2 - dx2 / 2 + for x = x1 to x2 + plot(x, y) + if err >= 0 + err = err - dx2 + y = y + sy + fin + err = err + dy2 + next + else + if sy < 0 + sx = -sx; y1, y2 = y2, y1 + fin + err = dx2 - dy2 / 2 + for y = y1 to y2 + plot(x, y) + if err >= 0 + err = err - dy2 + x = x + sx + fin + err = err + dx2 + next + fin + end + // // Assembly fixups // diff --git a/src/makefile b/src/makefile index 77724ff..a4b60d6 100755 --- a/src/makefile +++ b/src/makefile @@ -59,7 +59,7 @@ HGRLIB = rel/apple/HGRLIB\#FE1000 GRLIB = rel/apple/GRLIB\#FE1000 DGRLIB = rel/apple/DGRLIB\#FE1000 SPRITE = rel/apple/SPRITE\#FE1000 -LINESPANS = rel/apple/LINESPANS\#FE1000 +LINE = rel/apple/LINE\#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) $(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) +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) $(LINE) $(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 @@ -229,9 +229,9 @@ $(FIBER): libsrc/fiber.pla $(PLVM02) $(PLASM) ./$(PLASM) -AMOW < libsrc/fiber.pla > libsrc/fiber.a acme --setpc 4094 -o $(FIBER) libsrc/fiber.a -$(LINESPANS): libsrc/linespans.pla $(PLVM02) $(PLASM) - ./$(PLASM) -AMOW < libsrc/linespans.pla > libsrc/linespans.a - acme --setpc 4094 -o $(LINESPANS) libsrc/linespans.a +$(LINE): libsrc/line.pla $(PLVM02) $(PLASM) + ./$(PLASM) -AMOW < libsrc/line.pla > libsrc/line.a + acme --setpc 4094 -o $(LINE) libsrc/line.a $(FIBERTEST): samplesrc/fibertest.pla $(PLVM02) $(PLASM) ./$(PLASM) -AMOW < samplesrc/fibertest.pla > samplesrc/fibertest.a diff --git a/src/mkrel b/src/mkrel index f36d594..8ac8a18 100755 --- a/src/mkrel +++ b/src/mkrel @@ -9,7 +9,7 @@ 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/LINESPANS#FE1000 prodos/sys/LINESPANS.REL +cp rel/apple/LINE#FE1000 prodos/sys/LINE.REL cp rel/apple/SPRITE#FE1000 prodos/sys/SPRITE.REL cp rel/apple/HGRLIB#FE1000 prodos/sys/HGRLIB.REL cp rel/apple/GRLIB#FE1000 prodos/sys/GRLIB.REL @@ -150,7 +150,7 @@ mkdir prodos/bld/inc 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/linespans.plh prodos/bld/inc/LINESPANS.PLH.TXT +cp inc/line.plh prodos/bld/inc/LINE.PLH.TXT cp inc/sprite.plh prodos/bld/inc/SPRITE.PLH.TXT cp inc/hgrlib.plh prodos/bld/inc/HGRLIB.PLH.TXT cp inc/grlib.plh prodos/bld/inc/GRLIB.PLH.TXT diff --git a/src/samplesrc/dgrtest.pla b/src/samplesrc/dgrtest.pla index ea20a0f..46910fa 100644 --- a/src/samplesrc/dgrtest.pla +++ b/src/samplesrc/dgrtest.pla @@ -1,6 +1,6 @@ include "inc/cmdsys.plh" include "inc/dgrlib.plh" -include "inc/linespans.plh" +include "inc/line.plh" sysflags restxt1|restxt2|resxtxt1|resxtxt2 // Reserve all text pages byte[] sprite1 = $80,$80,$00,$00,$00,$00,$80,$80 @@ -32,11 +32,11 @@ def dgrTest#0 setlinespans(@dgrHLin, @dgrVLin) for l = 0 to 79 dgrColor(l) - linetospans(0, 0, l, 47) + linespans(0, 0, l, 47) next for l = 47 downto 0 dgrColor(l) - linetospans(0, 0, 79, l) + linespans(0, 0, 79, l) next ii = 2 ij = -1 diff --git a/src/samplesrc/grtest.pla b/src/samplesrc/grtest.pla index e79817b..58569a4 100644 --- a/src/samplesrc/grtest.pla +++ b/src/samplesrc/grtest.pla @@ -1,6 +1,6 @@ include "inc/cmdsys.plh" include "inc/grlib.plh" -include "inc/linespans.plh" +include "inc/line.plh" sysflags restxt1|restxt2 // Reserve all text pages byte[] sprite1 = $80,$80,$00,$00,$00,$00,$80,$80 @@ -32,11 +32,11 @@ def grTest#0 setlinespans(@grHLin, @grVLin) for l = 0 to 39 grColor(l) - linetospans(0, 0, l, 47) + linespans(0, 0, l, 47) next for l = 47 downto 0 grColor(l) - linetospans(0, 0, 39, l) + linespans(0, 0, 39, l) next ii = 2 ij = -1 diff --git a/src/samplesrc/hgrtest.pla b/src/samplesrc/hgrtest.pla index 905bc00..41e6451 100644 --- a/src/samplesrc/hgrtest.pla +++ b/src/samplesrc/hgrtest.pla @@ -1,7 +1,7 @@ include "inc/cmdsys.plh" include "inc/hgrlib.plh" include "inc/sprite.plh" -include "inc/linespans.plh" +include "inc/line.plh" sysflags reshgr1|reshgr2 // Reserve HGR page 1 and 2 byte ball = $88, $83, $33, $38, $88 @@ -22,10 +22,10 @@ def testline#0 setlinespans(@hgrHlin, @hgrVlin) hgrColor(7) for i = 0 to 191 step 8 - linetospans(0, 0, 279, i) + linespans(0, 0, 279, i) next for i = 0 to 279 step 8 - linetospans(0, 0, i, 191) + linespans(0, 0, i, 191) next end def testblt(sprtnum)#0 @@ -48,11 +48,11 @@ def testblt(sprtnum)#0 while ^$C000 < 128 for k = 0 to sprtnum i[k] = i[k] + ii[k] - if i[k] < 1 or i[k] > 269 + if i[k] < -10 or i[k] > 280 ii[k] = -ii[k] fin j[k] = j[k] + jj[k] - if j[k] < 1 or j[k] > 181 + if j[k] < -10 or j[k] > 192 jj[k] = -jj[k] fin spritePosIndex(i[k], j[k], k)