1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-07-05 04:28:57 +00:00

Loadable map

This commit is contained in:
David Schmenk 2014-12-27 20:33:36 -08:00
parent 963046d4f6
commit ac6faf4e96
2 changed files with 34 additions and 13 deletions

View File

@ -30,7 +30,7 @@ word titlestr = @initstr
//
export word rnd, getkb, home, gotoxy, tone
export word open, read, close
export word open, read, close, newline
byte noapple1 = "APPLE 1 NOT SUPPORTED."
@ -117,6 +117,15 @@ def a2read(refnum, buff, len)
syscall($CA, @params)
return params:6
end
def a2newline(refnum, emask, nlchar)
byte params[4]
params.0 = 3
params.1 = refnum
params.2 = emask
params.3 = nlchar
return syscall($C9, @params)
end
//
// SOS file routines
@ -151,6 +160,15 @@ def a3read(refnum, buff, len)
syscall($CA, @params)
return params:6
end
def a3newline(refnum, emask, nlchar)
byte params[4]
params.0 = 3
params.1 = refnum
params.2 = emask
params.3 = nlchar
return syscall($C9, @params)
end
//
// Apple /// console routines
@ -237,6 +255,7 @@ when MACHID & $C8
open = @a3open
read = @a3read
close = @a3close
newline = @a3newline
break
otherwise // Apple ][
rnd = @a2rnd
@ -247,6 +266,7 @@ when MACHID & $C8
open = @a2open
read = @a2read
close = @a2close
newline = @a2newline
wend
//

View File

@ -15,7 +15,7 @@ import ROGUEIO
const O_READ_WRITE = 3
predef puti, toupper
word rnd, getkb, home, gotoxy, tone, open, read, close
word rnd, getkb, home, gotoxy, tone, open, read, close, newline
end
const FALSE = 0
@ -201,11 +201,12 @@ export def loadmap
if not map
map = heapalloc(mapsize)
fin
memset(viewmap, mapsize, $A3A3) // Solid walls
memset(map, mapsize, $2323) // Solid walls
mapref = open(@catacomb, O_READ)
if mapref
newline(mapref, $7F, $0D)
for row = 1 to maprows - 2
read(mapref, map + (row << 6) + 1, mapcols - 2)
read(mapref, map + (row << 6) + 1, mapcols)
next
close(mapref)
fin
@ -216,7 +217,7 @@ end
//
export def getmaptile(xmap, ymap)
return map + (ymap << rowshift) + xmap
return ^(map + (ymap << rowshift) + xmap)
end
export def setmaptile(xmap, ymap, tile)
@ -345,7 +346,7 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
//
// Check adjacent tile for opaqueness - improves wall display
//
adjtile = map[imap + 1] & INV_TILE
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
@ -420,7 +421,7 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap - mapcols] & INV_TILE
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
@ -468,7 +469,7 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap + mapcols] & INV_TILE
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
@ -516,7 +517,7 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap + 1] & INV_TILE
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
@ -564,7 +565,7 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap - 1] & INV_TILE
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
@ -612,7 +613,7 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap + mapcols] & INV_TILE
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
@ -660,7 +661,7 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap - mapcols] & INV_TILE
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
@ -708,7 +709,7 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
vispix[l] = 0
else
vispix[l] = 1
adjtile = map[imap - 1] & INV_TILE
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