1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2026-01-22 18:15:59 +00:00

Move and increase symbol table

This commit is contained in:
David Schmenk
2025-12-01 16:53:04 -08:00
parent 77b94b0339
commit 4172c2c5e4
8 changed files with 80 additions and 69 deletions

View File

@@ -1,10 +1,14 @@
import turtle
predef initTurtle(width, height)#0
predef clipLine(x1, y1, x2, y2)#0
predef clipRect(left, top, right, bottom)#0
predef fillRect(left, top, right, bottom)#0
predef turnTo(angle)#0
predef turnLeft(angle)#0
predef turnRight(angle)#0
predef turnTo(angle)#0
predef moveForward(dist)#0
predef moveTo(x, y)#0
predef moveForward(dist)#0
predef moveBackward(dist)#0
predef penUp#0
predef penDown#0
end

View File

@@ -13,24 +13,23 @@ byte pen
var clipLeft, clipRight, clipTop, clipBottom
def clipCode(x, y)#1
byte code
byte xcode, ycode
code = 0
if x < clipLeft
code = CLIP_LEFT
xcode = CLIP_LEFT
elsif x > clipRight
code = CLIP_RIGHT
xcode = CLIP_RIGHT
else
xcode = 0
fin
if y < clipTop
code = code | CLIP_TOP
ycode = CLIP_TOP
elsif y > clipBottom
code = code | CLIP_BOTTOM
ycode = CLIP_BOTTOM
else
ycode = 0
fin
return code
end
def abs(val)#1
return val < 0 ?? -val :: val
return xcode | ycode
end
def lerp(a1, b1, a2, b2, n)#1
@@ -45,7 +44,7 @@ def lerp(a1, b1, a2, b2, n)#1
return i32[0] + b1
end
def clipLine(x1, y1, x2, y2)#0
export def clipLine(x1, y1, x2, y2)#0
byte outcode1, outcode2
outcode1 = clipCode(x1, y1)
@@ -80,54 +79,46 @@ def clipLine(x1, y1, x2, y2)#0
x2 = lerp(y1, x1, y2, x2, clipBottom)
y2 = clipBottom
fin
outcode1 = clipCode(x1, y1)
outcode2 = clipCode(x2, y2)
if outcode1 & outcode2; return; fin // Clipped away
if clipCode(x1, y1) | clipCode(x2, y2); return; fin // Clipped away
fin
linespans(x1, y1, x2, y2)
end
export def clipRect(left, top, right, bottom)#0
clipLeft = left
clipTop = top
clipLeft = left
clipLeft = left
clipTop = top
clipRight = right
clipBottom = bottom
end
export def fillRect(left, top, right, bottom)#0
var y
for y = top to bottom
clipLine(left, y, right, y)
next
end
export def initTurtle(width, height)#0
cliprect(0, 0, width - 1, height - 1)
clipRect(0, 0, width - 1, height - 1)
turtleX = width / 2
turtleY = height / 2
turtleAngle = 0
pen = 1
end
export def turnLeft(angle)#0
turtleAngle = turtleAngle - angle
while turtleAngle < 0; turtleAngle = turtleAngle + 360; loop
end
export def turnRight(angle)#0
turtleAngle = turtleAngle + angle
while turtleAngle >= 360; turtleAngle = turtleAngle - 360; loop
end
export def turnTo(angle)#0
turtleAngle = angle
while turtleAngle >= 360; turtleAngle = turtleAngle - 360; loop
while turtleAngle < 0; turtleAngle = turtleAngle + 360; loop
end
export def moveForward(dist)#0
var x, y
export def turnLeft(angle)#0
turnTo(turtleAngle - angle)
end
x = turtleX + mulcos(dist, turtleAngle)
y = turtleY + mulsin(dist, turtleAngle)
if pen
clipLine(turtleX, turtleY, x, y)
fin
turtleX = x
turtleY = y
export def turnRight(angle)#0
turnTo(turtleAngle + angle)
end
export def moveTo(x, y)#0
@@ -138,6 +129,14 @@ export def moveTo(x, y)#0
turtleY = y
end
export def moveForward(dist)#0
moveTo(turtleX + mulcos(dist, turtleAngle), turtleY + mulsin(dist, turtleAngle))
end
export def moveBackward(dist)#0
moveTo(turtleX - mulcos(dist, turtleAngle), turtleY - mulsin(dist, turtleAngle))
end
export def penUp#0
pen = 0
end

View File

@@ -181,6 +181,7 @@ cp scripts/dbounce.4th prodos/bld/scripts/DBOUNCE.4TH.TXT
cp scripts/hrbounce.4th prodos/bld/scripts/HRBOUNCE.4TH.TXT
cp scripts/plot.4th prodos/bld/scripts/PLOT.4TH.TXT
cp scripts/hrplot.4th prodos/bld/scripts/HRPLOT.4TH.TXT
cp scripts/hrturtle.4th prodos/bld/scripts/HRTURTLE.4TH.TXT
cp scripts/gfxplot.4th prodos/bld/scripts/GFXPLOT.4TH.TXT
cp scripts/hdinstall.4th prodos/bld/scripts/HDINSTALL.4TH.TXT
cp scripts/hdinstall1.4th prodos/bld/scripts/HDINSTALL1.4TH.TXT

View File

@@ -1,11 +1,17 @@
' INITTURTLE ?ENDSRC
" TURTLE" LOADMOD" "
" INT32" LOADMOD" "
" SINCOS" LOADMOD" "
" LINES" LOADMOD" "
" TURTLE" LOADMOD" "
LOOKUP INITTURTLE PLASMA INITTURTLE
LOOKUP CLIPLINE PLASMA CLIPLINE
LOOKUP CLIPRECT PLASMA CLIPRECT
LOOKUP FILLRECT PLASMA FILLRECT
LOOKUP TURNTO PLASMA TURNTO
LOOKUP TURNLEFT PLASMA TURNLEFT
LOOKUP TURNRIGHT PLASMA TURNRIGHT
LOOKUP TURNTO PLASMA TURNTO
LOOKUP MOVEFORWARD PLASMA MOVEFORWARD
LOOKUP MOVETO PLASMA MOVETO
LOOKUP MOVEFORWARD PLASMA MOVEFORWARD
LOOKUP MOVEBACKWARD PLASMA MOVEBACKWARD
LOOKUP PENUP PLASMA PENUP
LOOKUP PENDOWN PLASMA PENDOWN

View File

@@ -2,7 +2,7 @@
const MACHID = $BF98
const iobuffer = $0800
const RELADDR = $1000
const symtbl = $0C00
const symtbl = $B800
const freemem = $0006
const getlnbuf = $01FF
const CSW = $36
@@ -623,7 +623,7 @@ end
asm lookuptbl(dci)#1
LDA #$00 ; SYMBOL TABLE
STA DSTL
LDA #$0C
LDA #$B8
STA DSTH
LDA ESTKL,X
STA SRCL
@@ -1433,7 +1433,7 @@ if ^MACHID & MACHID_80COL
*CSW = $C300
crout; cout(12)
fin
prstr("PLEIADES 64K VM v2.20\n")
prstr("PLEIADES 64K VM v2.30\n")
//
// Init symbol table.
//

View File

@@ -1,7 +1,7 @@
const MACHID = $BF98
const iobuffer = $0800
const RELADDR = $1000
const symtbl = $0C00
const symtbl = $A800
const freemem = $0006
const getlnbuf = $01FF
const CSW = $36
@@ -642,7 +642,7 @@ end
asm lookuptbl(dci)#1
LDA #$00 ; SYMBOL TABLE
STA DSTL
LDA #$0C
LDA #$A8
STA DSTH
LDA ESTKL,X
STA SRCL
@@ -1433,7 +1433,7 @@ def docmds#0
loadmod(jitmod) // Cannot do this in init code - it will overwrite it!
xheap = $0200 // Reset heap to point at low memory
xheaptop = $A000 // Top below JITC
xheaptop = $A000 // Top below JITC ($C000 - 8K)
prefix = pfxop(heap, GET_PFX)
strcpy(getlnbuf, @cmdln)
repeat
@@ -1514,7 +1514,7 @@ if ^MACHID & MACHID_80COL
*CSW = $C300
cout(12)
fin
prstr("PLEIADES 128K VM v2.20\n")
prstr("PLEIADES 128K VM v2.30\n")
//
// Init symbol table.
//

View File

@@ -8,24 +8,18 @@ LCBNK1 = $08
JITCOMP = $03E2
JITCODE = $03E4
!SOURCE "vmsrc/plvmzp.inc"
JMP CMDMOVE
_CMDBEGIN = *
!PSEUDOPC $1000 {
!SOURCE "vmsrc/apple/cmdjit.a"
_CMDEND = *
}
;*
;* MOVE CMD DOWN TO $1000-$2000
;*
CMDMOVE LDA #<_CMDBEGIN
LDA #<_CMDBEGIN
STA SRCL
LDA #>_CMDBEGIN
STA SRCH
LDY #$00
STY DSTL
LDX #$10
LDX #$0C
STX DSTH
INX
LDX #$11
- LDA (SRC),Y
STA (DST),Y
INY
@@ -38,16 +32,22 @@ CMDMOVE LDA #<_CMDBEGIN
; INIT VM ENVIRONMENT STACK POINTERS
;
STY $01FF
STY PPL
STY IFPL ; INIT FRAME POINTER = $AF00 (4K FOR JIT CODE)
STY JITCODE
STY JITCODE ; INIT JIT CODE TO $AF00
STY JITCOMP
STY JITCOMP+1
LDA #$AF
STA JITCODE+1
STY PPL
STY IFPL ; INIT FRAME POINTER = $A800 (4K FOR JIT CODE 768 BYTES SYM)
LDA #$A8 ; FRAME POINTER BELOW JIT CODE AND SYM TABLE
STA PPH
STA IFPH
STA JITCODE+1
LDX #$FE ; INIT STACK POINTER (YES, $FE. SEE GETS)
TXS
LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX
JMP $1000
JMP $0C00
_CMDBEGIN = *
!PSEUDOPC $0C00 {
!SOURCE "vmsrc/apple/cmdjit.a"
_CMDEND = *
}

View File

@@ -7,7 +7,7 @@ LCBNK2 = $00
LCBNK1 = $08
!SOURCE "vmsrc/plvmzp.inc"
;*
;* MOVE CMD DOWN TO $1000-$2000
;* MOVE CMD DOWN TO $0C00-$2000
;*
LDA #<_CMDBEGIN
STA SRCL
@@ -15,8 +15,9 @@ LCBNK1 = $08
STA SRCH
LDY #$00
STY DSTL
LDX #$10
LDX #$0C
STX DSTH
LDX #$10
- LDA (SRC),Y
STA (DST),Y
INY
@@ -30,14 +31,14 @@ LCBNK1 = $08
;
STY $01FF
STY IFPL ; INIT FRAME POINTER = $BF00
LDA #$BF
LDA #$B8
STA IFPH
LDX #$FE ; INIT STACK POINTER (YES, $FE. SEE GETS)
TXS
LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX
JMP $1000
JMP $0C00
_CMDBEGIN = *
!PSEUDOPC $1000 {
!PSEUDOPC $0C00 {
!SOURCE "vmsrc/apple/cmd.a"
_CMDEND = *
}