1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-06-01 19:41:36 +00:00

Fix pointers to pointers. Add 'continue'. Killer new ROGUE.

This commit is contained in:
David Schmenk 2014-12-17 21:55:54 -08:00
parent 8a2dfba024
commit 2384d6f965
13 changed files with 1505 additions and 434 deletions

Binary file not shown.

View File

@ -20,6 +20,6 @@ import stdlib
//
// Module don't free memory
//
const modkeep = $1000
const modinitkeep = $2000
const modkeep = $2000
const modinitkeep = $4000
end

View File

@ -10,6 +10,7 @@ SB = SB\#FF2000
ROD = ROD\#FE1000
SIEVE = SIEVE\#FE1000
ROGUE = ROGUE\#FE1000
ROGUEMAP= ROGUEMAP\#FE1000
HELLO = HELLO\#FE1000
HGR1 = HGR1\#FE1000
HGR1TEST= HGR1TEST\#FE1000
@ -35,7 +36,7 @@ TXTTYPE = .TXT
#SYSTYPE = \#FF2000
#TXTTYPE = \#040000
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(PROFILE) $(ED) $(SB) $(ROD) $(SIEVE) $(ROGUE) $(HGR1)
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(PROFILE) $(ED) $(SB) $(ROD) $(SIEVE) $(ROGUE) $(ROGUEMAP) $(HGR1)
clean:
-rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03)
@ -104,6 +105,10 @@ $(ROGUE): samplesrc/rogue.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < samplesrc/rogue.pla > samplesrc/rogue.a
acme --setpc 4094 -o $(ROGUE) samplesrc/rogue.a
$(ROGUEMAP): samplesrc/rogue.map.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < samplesrc/rogue.map.pla > samplesrc/rogue.map.a
acme --setpc 4094 -o $(ROGUEMAP) samplesrc/rogue.map.a
$(PROFILE): samplesrc/profile.pla $(PLVM02) $(PLASM)
m4 -I inc < samplesrc/profile.pla | ./$(PLASM) -AM > samplesrc/profile.a
acme --setpc 4094 -o $(PROFILE) samplesrc/profile.a

View File

@ -1,9 +1,9 @@
NEW
10 GR: COLOR=15: PLOT 0, 0
20 RI = 24: P = 1: DIM DB(RI): DIM XB(500): DIM YB(500):DIM VB(500)
20 RI = 23: P = 1: DIM DB(RI): DIM XB(500): DIM YB(500):DIM VB(500)
30 PRINT "const beamdepth = "; RI: PRINT: PRINT "byte dbeam = 0";: FOR R = 1 TO RI
50 X = R * .7071: Y = R * .7071
60 SX = INT(X): SY = INT(Y + .25): IF SCRN(SX,SY) <> 0 THEN 80
60 SX = INT(X + .5): SY = INT(Y + .5): IF SCRN(SX,SY) <> 0 THEN 80
70 PLOT SX,SY: XB(P) = SX: YB(P) = SY: P = P + 1
80 X = X - .25
90 Y = SQR(R * R - X * X)

740
src/samplesrc/rogue.map.pla Normal file
View File

@ -0,0 +1,740 @@
//
// Module don't free memory
//
import STDLIB
predef syscall, call, memset, getc, putc, puts, putln
predef memset, memcpy
predef heapmark, heapallocallign, heapalloc, heaprelease, heapavail
byte MACHID
end
const modkeep = $2000
const modinitkeep = $4000
const FALSE = 0
const TRUE = not FALSE
//
// Octant beam parameters
//
const beamdepth = 23
byte dbeam = 0,2,4,8,12,17,22,28,37,44,53,63,72,83,96,109,123,137,151,166,183,202,220,239
const beampts = 240
byte[] xbeam
byte = 0
byte = 1,0
byte = 1,0
byte = 2,2,1,0
byte = 3,2,1,0
byte = 4,3,2,1,0
byte = 4,3,2,1,0
byte = 5,4,3,2,1,0
byte = 6,5,5,4,3,3,2,1,0
byte = 6,5,4,3,2,1,0
byte = 7,7,6,5,4,3,2,1,0
byte = 8,7,6,6,5,4,3,2,1,0
byte = 8,7,6,5,4,3,2,1,0
byte = 9,9,8,7,6,5,4,3,2,1,0
byte = 10,9,8,8,7,6,5,4,4,3,2,1,0
byte = 11,10,10,9,8,7,6,5,4,3,2,1,0
byte = 11,10,9,9,8,7,7,6,5,4,3,2,1,0
byte = 12,12,11,10,9,8,7,6,5,4,3,2,1,0
byte = 13,12,11,10,9,8,7,6,5,4,3,2,1,0
byte = 13,12,11,11,10,9,8,7,6,5,4,3,2,1,0
byte = 14,14,13,12,11,10,10,9,8,7,6,5,4,3,2,1,0
byte = 15,14,13,13,12,12,11,10,9,8,8,7,6,5,4,3,2,1,0
byte = 16,15,14,13,12,11,10,9,8,7,6,5,5,4,3,2,1,0
byte = 16,15,15,14,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
byte[] ybeam
byte = 0
byte = 1,1
byte = 2,2
byte = 2,3,3,3
byte = 3,4,4,4
byte = 4,4,5,5,5
byte = 5,5,6,6,6
byte = 5,6,6,7,7,7
byte = 6,6,7,7,7,8,8,8,8
byte = 7,8,8,9,9,9,9
byte = 7,8,8,9,9,10,10,10,10
byte = 8,9,9,10,10,10,11,11,11,11
byte = 9,10,11,11,11,12,12,12,12
byte = 9,10,10,11,12,12,12,13,13,13,13
byte = 10,11,11,12,12,13,13,13,14,14,14,14,14
byte = 11,11,12,12,13,13,14,14,15,15,15,15,15
byte = 12,13,13,14,14,14,15,15,15,16,16,16,16,16
byte = 12,13,13,14,15,15,16,16,16,17,17,17,17,17
byte = 13,14,14,15,16,16,17,17,17,18,18,18,18,18
byte = 14,15,15,16,16,17,17,18,18,18,19,19,19,19,19
byte = 14,15,15,16,17,17,18,18,18,19,19,19,20,20,20,20,20
byte = 15,16,16,17,17,18,18,19,19,19,20,20,20,20,21,21,21,21,21
byte = 16,16,17,18,19,19,20,20,21,21,21,21,22,22,22,22,22,22
byte = 17,17,18,18,19,19,20,20,21,21,22,22,22,23,23,23,23,23,23
byte[] vbeam
byte = 0
byte = 0,0
byte = 2,2
byte = 1,3,4,4
byte = 5,7,7,8
byte = 9,6,11,11,12
byte = 14,10,16,16,17
byte = 13,19,15,21,21,22
byte = 23,18,24,25,20,26,26,27,28
byte = 30,32,33,35,35,36,37
byte = 29,38,31,40,34,42,42,43,44
byte = 45,47,39,48,49,41,51,51,52,53
byte = 46,56,58,59,50,60,61,62,63
byte = 54,64,55,57,67,68,60,69,70,71,72
byte = 73,75,65,76,66,78,79,69,80,80,81,82,83
byte = 84,74,85,86,88,77,90,91,93,93,94,95,96
byte = 98,100,87,101,102,89,103,104,92,105,106,107,108,109
byte = 97,110,99,112,114,115,117,118,105,119,120,121,122,123
byte = 124,126,111,113,129,116,131,132,119,133,134,135,136,137
byte = 125,140,127,141,128,143,130,145,146,133,147,148,149,150,151
byte = 138,152,139,154,156,142,157,158,144,160,161,147,162,163,164,165,166
byte = 167,169,153,170,155,171,172,174,175,159,176,177,178,178,179,180,181,182,183
byte = 184,168,186,188,190,173,192,193,195,196,197,197,214,198,199,200,201,202
byte = 204,185,205,187,206,189,208,191,210,194,212,213,214,215,216,217,218,219,220
byte[beampts] vispix = 1
const maprows = 21
const mapcols = 32
const mapsize = maprows*mapcols
const FLOOR_TILE = '.'
const TORCH_TILE = '*'
const PIT_TILE = ' '
const DOOR_TILE = '+'
const LOCKED_TILE = '%'
const WATER1_TILE = '>'
const WATER2_TILE = '<'
const KEY_TILE = ','
const GOLD_TILE = '$'
const FOOD_TILE = '&'
const ENTER_TILE = '-'
const EXIT_TILE = '='
const OPAQUE_TILE = $01
const VIEWED_TILE = $80
const LIT_TILE = $80
const INV_TILE = $3F
const MAP_TILE = $7F
byte[] map
byte = "###############################"
byte = "### .#[-]#.......#&.....O&..*#"
byte = "## ..*...*...###T#.....####..#"
byte = "## ...###.T...##.#...&...##..#"
byte = "## ....###.&....#.#.......##..#"
byte = "# .............#.+.......##..#"
byte = "# T.....T.......#.#.T.....##..#"
byte = "#......&#.....&.#.:.......##..#"
byte = "#......###....###.:.......##..#"
byte = "###.....#.....###.#......&##..#"
byte = "##&.....*...#####.##:#:#:###..#"
byte = "#######......####.#&........Z*#"
byte = "####.O......#####.##*....######"
byte = "##..........#####.##.....##[=]#"
byte = "###....&#....&###.##.....#..R.#"
byte = "##.....###...####.###....#$...#"
byte = "###&...T#.....###.#&#....###%##"
byte = "#,##....*....####.##.>>.##*..*#"
byte = "#.######+########.##<<<..##...#"
byte = "#...............&.##>>>>>..Z.&#"
byte = "###############################"
word viewmap = 0
const xcentr = 20
const ycentr = 12
const scrnwidth = 40
const scrnheight = 22
//
// Buffer to void checks in octant caster
//
byte[scrnwidth] linebuffer
word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer
word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer
word[] screen
word = $400, $480, $500, $580, $600, $680, $700, $780
word = $428, $4A8, $528, $5A8, $628, $6A8, $728, $7A8
word = $450, $4D0, $550, $5D0, $650, $6D0, $750, @linebuffer // $7D0
word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer
word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer
//
// Load map
//
export def loadmap
//
// Init the view map
//
if not viewmap
viewmap = heapalloc(maprows * mapcols)
fin
memset(viewmap, maprows * mapcols, $A0A0)
end
//
// Tile access to map
//
export def getmaptile(xmap, ymap)
return map[(ymap << 5) + xmap + 1]
end
export def setmaptile(xmap, ymap, tile)
word imap
imap = (ymap << 5) + xmap + 1
map[imap] = tile
if ^(viewmap + imap) <> $A0
^(viewmap + imap) = tile | VIEWED_TILE
fin
end
export def updtmaptile(xmap, ymap, tile)
word imap
imap = (ymap << 5) + xmap + 1
map[imap] = (map[imap] & LIT_TILE) | tile
if ^(viewmap + imap) <> $A0
^(viewmap + imap) = tile | VIEWED_TILE
fin
end
//
// Light torches in map
//
export def lighttorches
word imap, tmap
byte xmap, ymap, xt, yt
for ymap = 1 to maprows - 2
for xmap = 2 to mapcols - 2
imap = (ymap << 5) + xmap
if map[imap] & MAP_TILE == TORCH_TILE
for yt = ymap - 1 to ymap + 1
for xt = xmap - 1 to xmap + 1
tmap = (yt << 5) + xt
map[tmap] = map[tmap] | LIT_TILE
next
next
fin
next
next
end
//
// Draw the map. Return 0 if any light visible, 1 if in complete darkness
//
export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
byte o, l, dist, tile, adjtile, occluded, darkness
word ymap, xmap, imap
byte yscr, xscr
if viewdist > beamdepth
viewdist = beamdepth
fin
if lightdist > viewdist
lightdist = viewdist
fin
//
// Clear screen
//
call($FC58, 0, 0, 0, 0)
//
// Draw background map if in light
//
darkness = 1
imap = (yorg << 5) + xorg + 1
if map[imap] & LIT_TILE or lightdist
//
// Update current spot in viewmap
//
^(viewmap + imap) = map[imap] | VIEWED_TILE
//
// Draw the viewmap
//
xmap = xorg - xcentr
if xmap < 0
l = mapcols - 1
xscr = -xmap
xmap = 0
else
l = mapcols - xmap - 1
xscr = 0
fin
if xscr + l > scrnwidth
l = scrnwidth - xscr
fin
for yscr = 0 to scrnheight
ymap = yscr - ycentr + yorg
if ymap >= 0 and ymap < maprows
memcpy(screen[yscr] + xscr, viewmap + (ymap << 5) + xmap + 1, l)
fin
next
darkness = 0
fin
//
// Draw visible octants
//
for o = viewdir - viewfield - 1 to viewdir + viewfield
dist = lightdist + 1
occluded = 1
when o & 7
is 0
//
// Run through lit octant beam points
//
for l = 1 to dbeam[lightdist]
//
// Check parent visiblity
//
if vispix[vbeam[l]]
imap = ((yorg - ybeam[l]) << 5) + xorg + xbeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
//
// The view stops here
//
vispix[l] = 0
else
//
// This tile is transparent
//
vispix[l] = 1
//
// Check adjacent tile for opaqueness - improves wall display
//
adjtile = map[imap + 1] & INV_TILE
if adjtile & OPAQUE_TILE
^(viewmap + imap + 1) = adjtile | VIEWED_TILE
screen.[ycentr-ybeam[l], xcentr+xbeam[l]+1] = adjtile
fin
fin
//
// Update view
//
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr-ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE
else
vispix[l] = 0
fin
next
//
// Run through visible octant beam points
//
for l = l to dbeam[viewdist]
//
// Check parent visiblity
//
if vispix[vbeam[l]]
imap = ((yorg - ybeam[l]) << 5) + xorg + xbeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
//
// The view stops here
//
vispix[l] = 0
else
//
// This tile is transparent
//
vispix[l] = 1
occluded = 0
fin
//
// If the tile is in light, update view
//
if tile & LIT_TILE
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr-ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE
darkness = 0
fin
else
vispix[l] = 0
fin
//
// Advance beam distance
//
if l == dbeam[dist]
if occluded
//
// Beam fully occluded
//
break
fin
//
// Update distance
//
occluded = 1
dist = dist + 1
fin
next
break
is 1
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg - xbeam[l]) << 5) + xorg + ybeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap - mapcols] & INV_TILE
if adjtile & OPAQUE_TILE
^(viewmap + imap - mapcols) = adjtile | VIEWED_TILE
screen.[ycentr-xbeam[l]-1, xcentr+ybeam[l]] = adjtile
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr-xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE
else
vispix[l] = 0
fin
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg - xbeam[l]) << 5) + xorg + ybeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
occluded = 0
fin
if tile & LIT_TILE
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr-xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE
darkness = 0
fin
else
vispix[l] = 0
fin
if l == dbeam[dist]
if occluded
break
fin
occluded = 1
dist = dist + 1
fin
next
break
is 2
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg + xbeam[l]) << 5) + xorg + ybeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap + mapcols] & INV_TILE
if adjtile & OPAQUE_TILE
^(viewmap + imap + mapcols) = adjtile | VIEWED_TILE
screen.[ycentr+xbeam[l]+1, xcentr+ybeam[l]] = adjtile
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr+xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE
else
vispix[l] = 0
fin
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg + xbeam[l]) << 5) + xorg + ybeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
occluded = 0
fin
if tile & LIT_TILE
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr+xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE
darkness = 0
fin
else
vispix[l] = 0
fin
if l == dbeam[dist]
if occluded
break
fin
occluded = 1
dist = dist + 1
fin
next
break
is 3
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg + ybeam[l]) << 5) + xorg + xbeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap + 1] & INV_TILE
if adjtile & OPAQUE_TILE
^(viewmap + imap + 1) = adjtile | VIEWED_TILE
screen.[ycentr+ybeam[l], xcentr+xbeam[l]+1] = adjtile
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr+ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE
else
vispix[l] = 0
fin
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg + ybeam[l]) << 5) + xorg + xbeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
occluded = 0
fin
if tile & LIT_TILE
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr+ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE
darkness = 0
fin
else
vispix[l] = 0
fin
if l == dbeam[dist]
if occluded
break
fin
occluded = 1
dist = dist + 1
fin
next
break
is 4
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg + ybeam[l]) << 5) + xorg - xbeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap - 1] & INV_TILE
if adjtile & OPAQUE_TILE
^(viewmap + imap - 1) = adjtile | VIEWED_TILE
screen.[ycentr+ybeam[l], xcentr-xbeam[l]-1] = adjtile
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr+ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE
else
vispix[l] = 0
fin
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg + ybeam[l]) << 5) + xorg - xbeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
occluded = 0
fin
if tile & LIT_TILE
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr+ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE
darkness = 0
fin
else
vispix[l] = 0
fin
if l == dbeam[dist]
if occluded
break
fin
occluded = 1
dist = dist + 1
fin
next
break
is 5
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg + xbeam[l]) << 5) + xorg - ybeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap + mapcols] & INV_TILE
if adjtile & OPAQUE_TILE
^(viewmap + imap + mapcols) = adjtile | VIEWED_TILE
screen.[ycentr+xbeam[l]+1, xcentr-ybeam[l]] = adjtile
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr+xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE
else
vispix[l] = 0
fin
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg + xbeam[l]) << 5) + xorg - ybeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
occluded = 0
fin
if tile & LIT_TILE
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr+xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE
darkness = 0
fin
else
vispix[l] = 0
fin
if l == dbeam[dist]
if occluded
break
fin
occluded = 1
dist = dist + 1
fin
next
break
is 6
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg - xbeam[l]) << 5) + xorg - ybeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap - mapcols] & INV_TILE
if adjtile & OPAQUE_TILE
^(viewmap + imap - mapcols) = adjtile | VIEWED_TILE
screen.[ycentr-xbeam[l]-1, xcentr-ybeam[l]] = adjtile
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr-xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE
else
vispix[l] = 0
fin
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg - xbeam[l]) << 5) + xorg - ybeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
occluded = 0
fin
if tile & LIT_TILE
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr-xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE
darkness = 0
fin
else
vispix[l] = 0
fin
if l == dbeam[dist]
if occluded
break
fin
occluded = 1
dist = dist + 1
fin
next
break
is 7
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg - ybeam[l]) << 5) + xorg - xbeam[l] + 1
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap - 1] & INV_TILE
if adjtile & OPAQUE_TILE
^(viewmap + imap - 1) = adjtile | VIEWED_TILE
screen.[ycentr-ybeam[l], xcentr-xbeam[l]-1] = adjtile
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr-ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE
else
vispix[l] = 0
fin
next
for l = l to dbeam[viewdist]
imap = ((yorg - ybeam[l]) << 5) + xorg - xbeam[l] + 1
if vispix[vbeam[l]]
tile = map[imap]
if tile & OPAQUE_TILE
vispix[l] = 0
else
vispix[l] = 1
occluded = 0
fin
if tile & LIT_TILE
^(viewmap + imap) = tile | VIEWED_TILE
screen.[ycentr-ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE
darkness = 0
fin
else
vispix[l] = 0
fin
if l == dbeam[dist]
if occluded
break
fin
occluded = 1
dist = dist + 1
fin
next
break
wend
next
return darkness
end
//
// Draw other entities
//
export def drawvisentity(xofst, yofst, tile)
if screen.[ycentr+yofst, xcentr+xofst] < $80
screen.[ycentr+yofst, xcentr+xofst] = tile
fin
end
done

File diff suppressed because it is too large Load Diff

View File

@ -94,7 +94,17 @@ int idlocal_add(char *name, int len, int type, int size)
{
printf("Local variable size overflow\n");
return (0);
}
}
if (idconst_lookup(name, len) > 0)
{
parse_error("const/local name conflict\n");
return (0);
}
if (idlocal_lookup(name, len) > 0)
{
parse_error("local label already defined\n");
return (0);
}
name[len] = '\0';
emit_idlocal(name, localsize);
name[len] = c;
@ -116,6 +126,16 @@ int idglobal_add(char *name, int len, int type, int size)
printf("Global variable count overflow\n");
return (0);
}
if (idconst_lookup(name, len) > 0)
{
parse_error("const/global name conflict\n");
return (0);
}
if (idglobal_lookup(name, len) > 0)
{
parse_error("global label already defined\n");
return (0);
}
name[len] = '\0';
name[len] = c;
idglobal_name[globals][0] = len;

View File

@ -825,7 +825,7 @@ def drawrow(row, ofst, strptr)
end
def drawscrn(toprow, ofst)
byte row, numchars
word numchars, strptr, scrnptr
word strptr, scrnptr
if ofst
for row = 0 to 23

View File

@ -22,28 +22,29 @@ t_token keywords[] = {
ENDCASE_TOKEN, 'W', 'E', 'N', 'D',
FOR_TOKEN, 'F', 'O', 'R',
TO_TOKEN, 'T', 'O',
DOWNTO_TOKEN, 'D', 'O', 'W', 'N', 'T', 'O',
DOWNTO_TOKEN, 'D', 'O', 'W', 'N', 'T', 'O',
STEP_TOKEN, 'S', 'T', 'E', 'P',
NEXT_TOKEN, 'N', 'E', 'X', 'T',
REPEAT_TOKEN, 'R', 'E', 'P', 'E', 'A', 'T',
UNTIL_TOKEN, 'U', 'N', 'T', 'I', 'L',
BREAK_TOKEN, 'B', 'R', 'E', 'A', 'K',
UNTIL_TOKEN, 'U', 'N', 'T', 'I', 'L',
BREAK_TOKEN, 'B', 'R', 'E', 'A', 'K',
CONTINUE_TOKEN, 'C', 'O', 'N', 'T', 'I', 'N', 'U', 'E',
ASM_TOKEN, 'A', 'S', 'M',
DEF_TOKEN, 'D', 'E', 'F',
EXPORT_TOKEN, 'E', 'X', 'P', 'O', 'R', 'T',
IMPORT_TOKEN, 'I', 'M', 'P', 'O', 'R', 'T',
EXPORT_TOKEN, 'E', 'X', 'P', 'O', 'R', 'T',
IMPORT_TOKEN, 'I', 'M', 'P', 'O', 'R', 'T',
RETURN_TOKEN, 'R', 'E', 'T', 'U', 'R', 'N',
END_TOKEN, 'E', 'N', 'D',
DONE_TOKEN, 'D', 'O', 'N', 'E',
LOGIC_NOT_TOKEN, 'N', 'O', 'T',
LOGIC_AND_TOKEN, 'A', 'N', 'D',
LOGIC_OR_TOKEN, 'O', 'R',
LOGIC_OR_TOKEN, 'O', 'R',
BYTE_TOKEN, 'B', 'Y', 'T', 'E',
WORD_TOKEN, 'W', 'O', 'R', 'D',
CONST_TOKEN, 'C', 'O', 'N', 'S', 'T',
STRUC_TOKEN, 'S', 'T', 'R', 'U', 'C',
PREDEF_TOKEN, 'P', 'R', 'E', 'D', 'E', 'F',
SYSFLAGS_TOKEN, 'S', 'Y', 'S', 'F', 'L', 'A', 'G', 'S',
SYSFLAGS_TOKEN, 'S', 'Y', 'S', 'F', 'L', 'A', 'G', 'S',
EOL_TOKEN
};

View File

@ -5,7 +5,7 @@
#include "codegen.h"
#include "parse.h"
int infunc = 0, break_tag = 0, stack_loop = 0;
int infunc = 0, break_tag = 0, cont_tag = 0, stack_loop = 0;
t_token prevstmnt;
t_token binary_ops_table[] = {
@ -357,6 +357,8 @@ int parse_value(int rvalue)
(type & BPTR_TYPE) ? emit_lb() : emit_lw();
emit_value = 1;
}
else
(type & BPTR_TYPE) ? emit_lb() : emit_lw();
type &= ~(VAR_TYPE | ADDR_TYPE);
type |= WORD_TYPE;
scantoken = scantoken == PTRB_TOKEN ? DOT_TOKEN : COLON_TOKEN;
@ -636,7 +638,7 @@ int parse_expr()
}
int parse_stmnt(void)
{
int tag_prevbrk, tag_else, tag_endif, tag_while, tag_wend, tag_repeat, tag_for, tag_choice, tag_of;
int tag_prevbrk, tag_prevcnt, tag_else, tag_endif, tag_while, tag_wend, tag_repeat, tag_for, tag_choice, tag_of;
int type, addr, step;
char *idptr;
@ -694,6 +696,8 @@ int parse_stmnt(void)
case WHILE_TOKEN:
tag_while = tag_new(BRANCH_TYPE);
tag_wend = tag_new(BRANCH_TYPE);
tag_prevcnt = cont_tag;
cont_tag = tag_while;
tag_prevbrk = break_tag;
break_tag = tag_wend;
emit_codetag(tag_while);
@ -712,11 +716,14 @@ int parse_stmnt(void)
emit_brnch(tag_while);
emit_codetag(tag_wend);
break_tag = tag_prevbrk;
cont_tag = tag_prevcnt;
break;
case REPEAT_TOKEN:
tag_prevbrk = break_tag;
break_tag = tag_new(BRANCH_TYPE);
tag_repeat = tag_new(BRANCH_TYPE);
tag_prevcnt = cont_tag;
cont_tag = tag_new(BRANCH_TYPE);
emit_codetag(tag_repeat);
scan();
while (parse_stmnt()) next_line();
@ -725,6 +732,8 @@ int parse_stmnt(void)
parse_error("Missing REPEAT/UNTIL");
return (0);
}
emit_codetag(cont_tag);
cont_tag = tag_prevcnt;
if (!parse_expr())
{
parse_error("Bad expression");
@ -739,6 +748,8 @@ int parse_stmnt(void)
tag_prevbrk = break_tag;
break_tag = tag_new(BRANCH_TYPE);
tag_for = tag_new(BRANCH_TYPE);
tag_prevcnt = cont_tag;
cont_tag = tag_for;
if (scan() != ID_TOKEN)
{
parse_error("Missing FOR variable");
@ -794,6 +805,7 @@ int parse_stmnt(void)
return (0);
}
emit_brnch(tag_for);
cont_tag = tag_prevcnt;
emit_codetag(break_tag);
emit_drop();
break_tag = tag_prevbrk;
@ -854,6 +866,15 @@ int parse_stmnt(void)
break_tag = tag_prevbrk;
stack_loop--;
break;
case CONTINUE_TOKEN:
if (cont_tag)
emit_brnch(cont_tag);
else
{
parse_error("CONTINUE without loop");
return (0);
}
break;
case BREAK_TOKEN:
if (break_tag)
emit_brnch(break_tag);

View File

@ -199,7 +199,7 @@ const STRUC_TKN = $96
const DONE_TKN = $98
const RETURN_TKN = $99
const BREAK_TKN = $9A
const START_TKN = $9B
const CONT_TKN = $9B
const EXIT_TKN = $9C
const EVAL_TKN = $9D
const PREDEF_TKN = $9E
@ -253,6 +253,7 @@ byte = "DOWNTO", DOWNTO_TKN
byte = "REPEAT", REPEAT_TKN
byte = "RETURN", RETURN_TKN
byte = "PREDEF", PREDEF_TKN
byte = "CONTINUE", CONT_TKN
byte = "OTHERWISE",DEFAULT_TKN
byte = $FF
//
@ -387,6 +388,7 @@ byte stack_loop = 0
byte prevstmnt = 0
word retfunc_tag = 0
word break_tag = 0
word cont_tag = 0
predef parse_expr, parse_module
//
// ASM utility functions
@ -3107,6 +3109,12 @@ def parse_value(rvalue)
fin
fin
emit_val = 1;
else
if type & BYTE_TYPE
emit_lab(value, elem_offset)
else
emit_law(value, elem_offset)
fin
fin
type = type & ~(VAR_TYPE | ADDR_TYPE)
type = type | WORD_TYPE
@ -3380,7 +3388,7 @@ def parse_expr
end
def parse_stmnt
byte type, elem_type, elem_size, i
word elem_offset, tag_prevbrk, tag_else, tag_endif, tag_while, tag_wend
word elem_offset, tag_prevbrk, tag_prevcnt, tag_else, tag_endif, tag_while, tag_wend
word tag_repeat, tag_for, tag_choice, tag_of, idptr, saveptr, addr, stepdir
if token <> END_TKN and token <> DONE_TKN and token <> OF_TKN and token <> DEFAULT_TKN
@ -3423,6 +3431,8 @@ def parse_stmnt
is WHILE_TKN
tag_while = ctag_new
tag_wend = ctag_new
tag_prevcnt = cont_tag
cont_tag = tag_while
tag_prevbrk = break_tag
break_tag = tag_wend
ctag_resolve(tag_while)
@ -3435,17 +3445,22 @@ def parse_stmnt
emit_branch(tag_while)
ctag_resolve(tag_wend)
break_tag = tag_prevbrk
cont_tag = tag_prevcnt
break
is REPEAT_TKN
tag_repeat = ctag_new
tag_prevbrk = break_tag
break_tag = ctag_new
tag_prevcnt = cont_tag
cont_tag = ctag_new
ctag_resolve(tag_repeat)
scan
while parse_stmnt
nextln
loop
if token <> UNTIL_TKN; return parse_err(@no_until); fin
ctag_resolve(cont_tag)
cont_tag = tag_prevcnt
if !parse_expr; return FALSE; fin
emit_brfls(tag_repeat)
ctag_resolve(break_tag)
@ -3454,6 +3469,8 @@ def parse_stmnt
is FOR_TKN
stack_loop = stack_loop + 1
tag_for = ctag_new
tag_prevcnt = cont_tag
cont_tag = tag_for
tag_prevbrk = break_tag
break_tag = ctag_new
if scan <> ID_TKN; return parse_err(@bad_stmnt); fin
@ -3512,6 +3529,7 @@ def parse_stmnt
loop
if token <> NEXT_TKN; return parse_err(@bad_stmnt); fin
emit_branch(tag_for)
cont_tag = tag_prevcnt
ctag_resolve(break_tag)
emit_drop
break_tag = tag_prevbrk
@ -3566,6 +3584,13 @@ def parse_stmnt
return parse_err(@bad_stmnt)
fin
break
is CONT_TKN
if cont_tag
emit_branch(cont_tag)
else
return parse_err(@bad_stmnt)
fin
break
is RETURN_TKN
if infunc
for i = 1 to stack_loop

View File

@ -43,7 +43,8 @@
#define BREAK_TOKEN TOKEN(29)
#define SYSFLAGS_TOKEN TOKEN(30)
#define STRUC_TOKEN TOKEN(31)
#define EVAL_TOKEN TOKEN(32)
#define CONTINUE_TOKEN TOKEN(32)
//#define EVAL_TOKEN TOKEN(32)
/*
* Double operand operators.
*/

View File

@ -18,8 +18,8 @@ const resxhgr2 = $0080
//
// Module don't free memory
//
const modkeep = $1000
const modinitkeep = $2000
const modkeep = $2000
const modinitkeep = $4000
//
// Pedefined functions.
//
@ -1058,7 +1058,7 @@ def loadmod(mod)
fixup = 0 // This is repurposed for the return code
if init
fixup = adddef(defbank, init - defofst + defaddr, @deflast)()
if !(systemflags & modinitkeep)
if fixup < modinitkeep
//
// Free init routine unless initkeep
//
@ -1067,13 +1067,15 @@ def loadmod(mod)
else
modend = init - defofst + defaddr
fin
else
fixup = fixup & ~modinitkeep
fin
fin
//
// Free up the end-of-module in main memory.
//
releaseheap(modend)
return fixup | (systemflags & modkeep)
return fixup
end
//
// Command mode
@ -1247,12 +1249,12 @@ def execmod(modfile)
saveflags = systemflags
^lastsym = 0
perr = loadmod(@moddci)
if perr >= modkeep
perr = perr & ~modkeep
else
if perr < modkeep
lastsym = savesym
xheap = savexheap
heap = saveheap
else
perr = perr & ~modkeep
fin
systemflags = saveflags
fin