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

k out rogue io module

This commit is contained in:
David Schmenk 2014-12-26 19:13:22 -08:00
parent 69b5666afc
commit c3101171a1
7 changed files with 577 additions and 361 deletions

62
src/CATACOMB.TXT Normal file
View File

@ -0,0 +1,62 @@
..........................[-].................................
.........................*...*................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..............................................................
..*...*.......................................................
..#[=]#.......................................................

View File

@ -10,6 +10,7 @@ SB = SB\#FF2000
ROD = ROD\#FE1000
SIEVE = SIEVE\#FE1000
ROGUE = ROGUE\#FE1000
ROGUEIO = ROGUEIO\#FE1000
ROGUEMAP= ROGUEMAP\#FE1000
ROGUECOMBAT= ROGUECOMBAT\#FE1000
HELLO = HELLO\#FE1000
@ -37,7 +38,7 @@ TXTTYPE = .TXT
#SYSTYPE = \#FF2000
#TXTTYPE = \#040000
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(PROFILE) $(ED) $(SB) $(ROD) $(SIEVE) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(HGR1)
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(PROFILE) $(ED) $(SB) $(ROD) $(SIEVE) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1)
clean:
-rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03)
@ -106,6 +107,10 @@ $(ROGUE): samplesrc/rogue.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < samplesrc/rogue.pla > samplesrc/rogue.a
acme --setpc 4094 -o $(ROGUE) samplesrc/rogue.a
$(ROGUEIO): samplesrc/rogue.io.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < samplesrc/rogue.io.pla > samplesrc/rogue.io.a
acme --setpc 4094 -o $(ROGUEIO) samplesrc/rogue.io.a
$(ROGUECOMBAT): samplesrc/rogue.combat.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < samplesrc/rogue.combat.pla > samplesrc/rogue.combat.a
acme --setpc 4094 -o $(ROGUECOMBAT) samplesrc/rogue.combat.a

View File

@ -1,7 +1,7 @@
import STDLIB
predef syscall, call, memset, getc, putc, puts, putln
predef memset, memcpy
predef heapmark, heapallocallign, heapalloc, heaprelease, heapavail
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
@ -152,6 +152,8 @@ export def fight(player, enemy)
gotoxy(21, 3)
puts(@lifestr); puti(enemy->life)
for e_atck = 0 to 9
gotoxy(0, 10 + e_atck)
puts(@ascii_rogue + e_atck * 11)
gotoxy(20, 10 + e_atck)
puts(ascii_entity[enemy->kind] + e_atck * 11)
next

262
src/samplesrc/rogue.io.pla Normal file
View File

@ -0,0 +1,262 @@
import STDLIB
predef syscall, call, getc, putc, puts, putln
predef memset, memcpy, modaddr
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
const modkeep = $2000
const modinitkeep = $4000
byte stdlib = "STDLIB"
byte[] initstr
byte = " ( )\n"
byte = " )\\ ) ( /( (\n"
byte = "(()/( )\\()) )\\ ) ( (\n"
byte = " /(_))((_)\\ (()/( )\\ )\\\n"
byte = "(_)) ((_) /(_))_ _ ((_)((_)\n"
byte = "| _ \\ / _ \\(_)) __|| | | || __|\n"
byte = "| / | (_) | | (_ || |_| || _|\n"
byte = "|_|_\\ \\___/ \\___| \\___/ |___|\n"
byte = "\n"
byte = " By Resman\n"
byte = " Artwork by Seth Sternberg\n"
byte = ""
word titlestr = @initstr
//
// Machine specific routines
//
export word rnd, getkb, home, gotoxy, tone
export word open, read, close
byte noapple1 = "APPLE 1 NOT SUPPORTED."
const ENV_REG = $FFDF
const SPEAKER = $C030
const a2rndnum = $4E // ZP location of RND
const a2rndl = $4E
const a2rndh = $4F
word iobuff
word a3rndnum = 12345
byte devcons
def a3rnd
a3rndnum = (a3rndnum << 1) + a3rndnum + 123
return *a3rndnum & $7FFF
end
def a2rnd
*a2rndnum = (*a2rndnum << 1) + *a2rndnum + 123
return *a2rndnum & $7FFF
end
def a2getkb
return getc()
end
def a2tone(duration, delay)
byte i
while duration
^SPEAKER
for i = 0 to delay
next
duration = duration - 1
loop
end
def a3tone(duration, pitch)
byte env
env = ^ENV_REG
^ENV_REG = env | $C0
a2tone(duration, pitch)
^ENV_REG = env
end
//
// ProDOS file routines
//
def a2open(path, access)
byte params[6]
params.0 = 3
params:1 = path
params:3 = heapallocalign($0400, 8, @iobuff)
params.5 = 0
syscall($C8, @params)
return params.5
end
def a2close(refnum)
byte params[2]
if iobuff
heaprelease(iobuff)
iobuff = 0
fin
params.0 = 1
params.1 = refnum
return syscall($CC, @params)
end
def a2read(refnum, buff, len)
byte params[8]
params.0 = 4
params.1 = refnum
params:2 = buff
params:4 = len
params:6 = 0
syscall($CA, @params)
return params:6
end
//
// SOS file routines
//
def a3open(path, access)
byte params[7]
params.0 = 4
params:1 = path
params.3 = 0
params:4 = @access
params.6 = 1
syscall($C8, @params)
return params.3
end
def a3close(refnum)
byte params[2]
params.0 = 1
params.1 = refnum
return syscall($CC, @params)
end
def a3read(refnum, buff, len)
byte params[8]
params.0 = 4
params.1 = refnum
params:2 = buff
params:4 = len
params:6 = 0
syscall($CA, @params)
return params:6
end
//
// Apple /// console routines
//
def dev_status(devnum, code, list)
byte params[5]
params.0 = 3
params.1 = devnum
params.2 = code
params:3 = list
return syscall($82, @params)
end
def a3keypressed
byte count
dev_status(devcons, 5, @count)
return count
end
def a3getkb
while not a3keypressed
a3rndnum = a3rndnum + 123
loop
return getc()
end
def a3home
return putc(28)
end
def a3gotoxy(ch, cv)
putc(24)
putc(ch)
putc(25)
return putc(cv)
end
//
// Apple ][ console routines
//
def a2home
return call($FC58, 0, 0, 0, 0) // home()
end
def a2gotoxy(x, y)
^$24 = x + ^$20
return call($FB5B, y + ^$22, 0, 0, 0)
end
export def puti(i)
if i < 0; putc('-'); i = -i; fin
if i < 10
putc(i + '0')
else
puti(i / 10)
putc(i % 10 + '0')
fin
end
export def toupper(c)
if c >= 'a' and c <= 'z'
c = c - $20
fin
return c
end
//
// Set machine specific routines
//
when MACHID & $C8
is $08 // Apple 1
puts(@noapple1)
return -1
is $C0 // Apple ///
rnd = @a3rnd
getkb = @a3getkb
home = @a3home
gotoxy = @a3gotoxy
tone = @a3tone
devcons = modaddr(@stdlib).5 // devcons variable from STDLIB
open = @a3open
read = @a3read
close = @a3close
break
otherwise // Apple ][
rnd = @a2rnd
getkb = @a2getkb
home = @a2home
gotoxy = @a2gotoxy
tone = @a2tone
open = @a2open
read = @a2read
close = @a2close
wend
//
// Print title page
//
home()
while ^titlestr
puts(titlestr)
titlestr = titlestr + ^titlestr + 1
loop
done

View File

@ -1,18 +1,22 @@
//
// Module don't free memory
// Map module
//
import STDLIB
predef syscall, call, getc, putc, puts, putln
predef memset, memcpy, modaddr
predef heapmark, heapallocallign, heapalloc, heaprelease, heapavail
byte MACHID
predef syscall, call, getc, putc, puts, putln
predef memset, memcpy, modaddr
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
const modkeep = $2000
const modinitkeep = $4000
import ROGUEIO
const O_READ = 1
const O_WRITE = 2
const O_READ_WRITE = 3
byte stdlib[] = "STDLIB"
predef puti, toupper
word rnd, getkb, home, gotoxy, tone, open, read, close
end
const FALSE = 0
const TRUE = not FALSE
@ -106,9 +110,10 @@ byte = 204,185,205,187,206,189,208,191,210,194,212,213,214,215,216,217,218,219,2
byte[beampts] vispix = 1
const maprows = 21
const mapcols = 32
const mapsize = maprows*mapcols
const rowshift = 6
const maprows = 64
const mapcols = 64
const mapsize = maprows*mapcols
const FLOOR_TILE = '.'
const TORCH_TILE = '*'
@ -128,30 +133,31 @@ 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 = "###############################"
//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
byte catacomb = "CATACOMB"
word map, viewmap
const xcentr = 20
const ycentr = 12
@ -175,144 +181,34 @@ word = $450, $4D0, $550, $5D0, $650, $6D0, $750, @linebuffer // $7D0
word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer
word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer
//
// Machine specific routines
//
export word rnd
export word getkb
export word tone
export word home
export word gotoxy
byte noapple1 = "APPLE 1 NOT SUPPORTED."
byte apple2 = "Apple II "
byte apple3 = "Apple /// "
const ENV_REG = $FFDF
const SPEAKER = $C030
const a2rndnum = $4E // ZP location of RND
const a2rndl = $4E
const a2rndh = $4F
word a3rndnum = 12345
byte devcons
def a3rnd
a3rndnum = (a3rndnum << 1) + a3rndnum + 123
return *a3rndnum & $7FFF
end
def a2rnd
*a2rndnum = (*a2rndnum << 1) + *a2rndnum + 123
return *a2rndnum & $7FFF
end
def a2getkb
return getc()
end
def a2tone(duration, delay)
byte i
while duration
^SPEAKER
for i = 0 to delay
next
duration = duration - 1
loop
end
def a3tone(duration, pitch)
byte env
env = ^ENV_REG
^ENV_REG = env | $C0
a2tone(duration, pitch)
^ENV_REG = env
end
//
// Apple /// console routines
//
def dev_status(devnum, code, list)
byte params[5]
params.0 = 3
params.1 = devnum
params.2 = code
params:3 = list
return syscall($82, @params)
end
def a3keypressed
byte count
dev_status(devcons, 5, @count)
return count
end
def a3getkb
while not a3keypressed
a3rndnum = a3rndnum + 123
loop
return getc()
end
def a3home
return putc(28)
end
def a3gotoxy(ch, cv)
putc(24)
putc(ch)
putc(25)
return putc(cv)
end
//
// Apple ][ console routines
//
def a2home
return call($FC58, 0, 0, 0, 0) // home()
end
def a2gotoxy(x, y)
^$24 = x + ^$20
return call($FB5B, y + ^$22, 0, 0, 0)
end
export def puti(i)
if i < 0; putc('-'); i = -i; fin
if i < 10
putc(i + '0')
else
puti(i / 10)
putc(i % 10 + '0')
fin
end
export def toupper(c)
if c >= 'a' and c <= 'z'
c = c - $20
fin
return c
end
//
// Load map
//
export def loadmap
byte mapref, row
//
// Init the view map
//
if not viewmap
viewmap = heapalloc(maprows * mapcols)
viewmap = heapalloc(mapsize)
fin
memset(viewmap, mapsize, $A0A0)
//
// Load catacomb map from file
//
if not map
map = heapalloc(mapsize)
fin
memset(viewmap, mapsize, $A3A3) // Solid walls
mapref = open(@catacomb, O_READ)
if mapref
for row = 1 to maprows - 2
read(mapref, map + (row << 6) + 1, mapcols - 2)
next
close(mapref)
fin
memset(viewmap, maprows * mapcols, $A0A0)
end
//
@ -320,14 +216,14 @@ end
//
export def getmaptile(xmap, ymap)
return map[(ymap << 5) + xmap + 1]
return map + (ymap << rowshift) + xmap
end
export def setmaptile(xmap, ymap, tile)
word imap
imap = (ymap << 5) + xmap + 1
map[imap] = tile
imap = (ymap << rowshift) + xmap
^(map + imap) = tile
if ^(viewmap + imap) <> $A0
^(viewmap + imap) = tile | VIEWED_TILE
fin
@ -336,12 +232,13 @@ end
export def updtmaptile(xmap, ymap, tile)
word imap
imap = (ymap << 5) + xmap + 1
map[imap] = (map[imap] & LIT_TILE) | tile
imap = (ymap << rowshift) + xmap
^(map + imap) = (^(map + imap) & LIT_TILE) | tile
if ^(viewmap + imap) <> $A0
^(viewmap + imap) = tile | VIEWED_TILE
fin
end
//
// Light torches in map
//
@ -351,15 +248,15 @@ export def lighttorches
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 xmap = 1 to mapcols - 2
imap = (ymap << rowshift) + 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
for xt = xmap - 1 to xmap + 1
tmap = (yt << rowshift) + xt
^(map + tmap) = ^(map + tmap) | LIT_TILE
next
next
fin
next
next
@ -388,12 +285,12 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
// Draw background map if in light
//
darkness = 1
imap = (yorg << 5) + xorg + 1
if map[imap] & LIT_TILE or lightdist
imap = (yorg << rowshift) + xorg
if ^(map + imap) & LIT_TILE or lightdist
//
// Update current spot in viewmap
//
^(viewmap + imap) = map[imap] | VIEWED_TILE
^(viewmap + imap) = ^(map + imap) | VIEWED_TILE
//
// Draw the viewmap
//
@ -407,12 +304,12 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
xscr = 0
fin
if xscr + l > scrnwidth
l = scrnwidth - xscr
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)
memcpy(screen[yscr] + xscr, viewmap + (ymap << rowshift) + xmap, l)
fin
next
darkness = 0
@ -433,8 +330,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
// Check parent visiblity
//
if vispix[vbeam[l]]
imap = ((yorg - ybeam[l]) << 5) + xorg + xbeam[l] + 1
tile = map[imap]
imap = ((yorg - ybeam[l]) << rowshift) + xorg + xbeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
//
// The view stops here
@ -471,8 +368,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
// Check parent visiblity
//
if vispix[vbeam[l]]
imap = ((yorg - ybeam[l]) << 5) + xorg + xbeam[l] + 1
tile = map[imap]
imap = ((yorg - ybeam[l]) << rowshift) + xorg + xbeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
//
// The view stops here
@ -517,8 +414,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
is 1
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg - xbeam[l]) << 5) + xorg + ybeam[l] + 1
tile = map[imap]
imap = ((yorg - xbeam[l]) << rowshift) + xorg + ybeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -537,8 +434,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg - xbeam[l]) << 5) + xorg + ybeam[l] + 1
tile = map[imap]
imap = ((yorg - xbeam[l]) << rowshift) + xorg + ybeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -565,8 +462,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
is 2
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg + xbeam[l]) << 5) + xorg + ybeam[l] + 1
tile = map[imap]
imap = ((yorg + xbeam[l]) << rowshift) + xorg + ybeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -585,8 +482,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg + xbeam[l]) << 5) + xorg + ybeam[l] + 1
tile = map[imap]
imap = ((yorg + xbeam[l]) << rowshift) + xorg + ybeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -613,8 +510,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
is 3
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg + ybeam[l]) << 5) + xorg + xbeam[l] + 1
tile = map[imap]
imap = ((yorg + ybeam[l]) << rowshift) + xorg + xbeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -633,8 +530,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg + ybeam[l]) << 5) + xorg + xbeam[l] + 1
tile = map[imap]
imap = ((yorg + ybeam[l]) << rowshift) + xorg + xbeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -661,8 +558,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
is 4
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg + ybeam[l]) << 5) + xorg - xbeam[l] + 1
tile = map[imap]
imap = ((yorg + ybeam[l]) << rowshift) + xorg - xbeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -681,8 +578,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg + ybeam[l]) << 5) + xorg - xbeam[l] + 1
tile = map[imap]
imap = ((yorg + ybeam[l]) << rowshift) + xorg - xbeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -709,8 +606,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
is 5
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg + xbeam[l]) << 5) + xorg - ybeam[l] + 1
tile = map[imap]
imap = ((yorg + xbeam[l]) << rowshift) + xorg - ybeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -729,8 +626,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg + xbeam[l]) << 5) + xorg - ybeam[l] + 1
tile = map[imap]
imap = ((yorg + xbeam[l]) << rowshift) + xorg - ybeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -757,8 +654,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
is 6
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg - xbeam[l]) << 5) + xorg - ybeam[l] + 1
tile = map[imap]
imap = ((yorg - xbeam[l]) << rowshift) + xorg - ybeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -777,8 +674,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
next
for l = l to dbeam[viewdist]
if vispix[vbeam[l]]
imap = ((yorg - xbeam[l]) << 5) + xorg - ybeam[l] + 1
tile = map[imap]
imap = ((yorg - xbeam[l]) << rowshift) + xorg - ybeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -805,8 +702,8 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
is 7
for l = 1 to dbeam[lightdist]
if vispix[vbeam[l]]
imap = ((yorg - ybeam[l]) << 5) + xorg - xbeam[l] + 1
tile = map[imap]
imap = ((yorg - ybeam[l]) << rowshift) + xorg - xbeam[l]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -824,9 +721,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
fin
next
for l = l to dbeam[viewdist]
imap = ((yorg - ybeam[l]) << 5) + xorg - xbeam[l] + 1
imap = ((yorg - ybeam[l]) << rowshift) + xorg - xbeam[l]
if vispix[vbeam[l]]
tile = map[imap]
tile = ^(map + imap)
if tile & OPAQUE_TILE
vispix[l] = 0
else
@ -865,30 +762,4 @@ export def drawvisentity(xofst, yofst, tile)
fin
end
//
// Set machine specific routines
//
when MACHID & $C8
is $08 // Apple 1
puts(@noapple1)
return -1
is $C0 // Apple ///
puts(@apple3)
rnd = @a3rnd
getkb = @a3getkb
home = @a3home
gotoxy = @a3gotoxy
tone = @a3tone
devcons = modaddr(@stdlib).5 // devcons variable from STDLIB
break
otherwise // Apple ][
puts(@apple2)
rnd = @a2rnd
getkb = @a2getkb
home = @a2home
gotoxy = @a2gotoxy
tone = @a2tone
wend
done

View File

@ -1,7 +1,7 @@
import STDLIB
predef syscall, call, memset, getc, putc, puts, putln
predef memset, memcpy
predef heapmark, heapallocallign, heapalloc, heaprelease, heapavail
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
@ -10,8 +10,8 @@ import ROGUEMAP
const ycentr = 12
const scrnwidth = 40
const scrnheight = 22
const maprows = 21
const mapcols = 32
const maprows = 64
const mapcols = 64
const mapsize = maprows*mapcols
const FLOOR_TILE = '.'
@ -32,9 +32,7 @@ import ROGUEMAP
const INV_TILE = $3F
const MAP_TILE = $7F
predef puti, toupper
predef loadmap, getmaptile, setmaptile, updtmaptile, lighttorches, drawmap, drawvisentity
word rnd, getkb, home, gotoxy, tone
end
import ROGUECOMBAT
@ -42,6 +40,11 @@ import ROGUECOMBAT
word entity, entities
end
import ROGUEIO
predef puti, toupper
word rnd, getkb, home, gotoxy, tone
end
const FALSE = 0
const TRUE = not FALSE
@ -84,8 +87,8 @@ struc t_player
byte[32] name[32]
end
byte player = 8 // xpos
byte = 2 // ypos
byte player = 0 // xpos
byte = 0 // ypos
byte = 4 // angle
byte = 4 // lamp
byte = 1 // fov
@ -129,7 +132,6 @@ byte keystr = "Key"
// Messages
//
byte initstr = "Initializing..."
byte quitstr = "Are you sure you want to quit?"
byte youmadeitstr = "You made it out alive with $"
byte youdiedstr = "You perished inside the catacombs :-("
@ -145,6 +147,10 @@ def abs(i)
return i
end
//
// Sound functions
//
def ouch
tone(128,5)
end
@ -240,33 +246,42 @@ def findentities
for xmap = 2 to mapcols - 2
what = 0
when getmaptile(xmap, ymap) & MAP_TILE
is 'R' // Rogue
what = what + 1
is 'Z' // Zombie
what = what + 1
is ENTER_TILE
player.xpos = xmap
player.ypos = ymap
if getmaptile(xmap, ymap - 1) & MAP_TILE == FLOOR_TILE
player.angle = 0
else
player.angle = 4
fin
break
is 'R' // Rogue
what = what + 1
is 'Z' // Zombie
what = what + 1
is 'O' // Ogre
what = what + 1
is 'T' // Thief
newother = heapalloc(t_other)
newother->xpos = xmap
newother->ypos = ymap
newother->kind = what
newother->tileid = ^(entity[what] + 1) // First character of name string
newother->power = ^(entity[what] + ^entity[what] + 1)
newother->life = 100
//
// Insert into head of entities list
//
newother=>prev_other = 0
newother=>next_other = entities
if entities
entities=>prev_other = newother
fin
entities = newother
//
// Clear entity from map, replace with floor
//
setmaptile(xmap, ymap, FLOOR_TILE)
what = what + 1
is 'T' // Thief
newother = heapalloc(t_other)
newother->xpos = xmap
newother->ypos = ymap
newother->kind = what
newother->tileid = ^(entity[what] + 1) // First character of name string
newother->power = ^(entity[what] + ^entity[what] + 1)
newother->life = 100
//
// Insert into head of entities list
//
newother=>prev_other = 0
newother=>next_other = entities
if entities
entities=>prev_other = newother
fin
entities = newother
//
// Clear entity from map, replace with floor
//
setmaptile(xmap, ymap, FLOOR_TILE)
wend
next
next
@ -559,7 +574,6 @@ end
// Main loop
//
puts(@initstr)
loadmap
findentities
lighttorches

View File

@ -92,7 +92,7 @@ word = @modadrstr, @lookupstrmod
word = @machidstr, MACHID
word = @argstr, @cmdln
word = 0
word stdlibsym = @exports
word stdlibsym = @exports
//
// String pool.
//
@ -282,7 +282,7 @@ REVCPY ;CLC
DEC SRCH
LDY #$FF
LDA ESTKL-2,X
BEQ REVCPYLP
BEQ REVCPYLP
INC ESTKH-2,X
REVCPYLP LDA (SRC),Y
STA (DST),Y
@ -491,7 +491,7 @@ asm uword_islt
end
//
// Utility routines.
//
//
// A DCI string is one that has the high bit set for every character except the last.
// More efficient than C or Pascal strings.
//
@ -903,71 +903,71 @@ def loadmod(mod)
refnum = open(@filename, iobuffer)
if refnum > 0
rdlen = read(refnum, @header, 128)
modsize = header:0
moddep = @header.1
defofst = modsize
modsize = header:0
moddep = @header.1
defofst = modsize
init = 0
if rdlen > 4 and header:2 == $DA7E // DAVE = magic number :-)
//
// This is an EXTended RELocatable (data+bytecode) module.
//
systemflags = header:4 | systemflags
systemflags = header:4 | systemflags
defofst = header:6
defcnt = header:8
init = header:10
moddep = @header.12
//
// Load module dependencies.
//
//
// Load module dependencies.
//
while ^moddep
if !lookupmod(moddep)
close(refnum)
refnum = 0
close(refnum)
refnum = 0
if loadmod(moddep) < 0
return -perr
fin
return -perr
fin
fin
moddep = moddep + dcitos(moddep, @str)
loop
//
// Init def table.
//
deftbl = allocheap(defcnt * 5 + 1)
deflast = deftbl
^deflast = 0
if !refnum
//
// Reset read pointer.
//
refnum = open(@filename, iobuffer)
rdlen = read(refnum, @header, 128)
fin
// Init def table.
//
deftbl = allocheap(defcnt * 5 + 1)
deflast = deftbl
^deflast = 0
if !refnum
//
// Reset read pointer.
//
refnum = open(@filename, iobuffer)
rdlen = read(refnum, @header, 128)
fin
fin
//
// Alloc heap space for relocated module (data + bytecode).
//
moddep = moddep + 1
modfix = moddep - @header.2 // Adjust to skip header
modsize = modsize - modfix
rdlen = rdlen - modfix - 2
modaddr = allocheap(modsize)
memcpy(modaddr, moddep, rdlen)
//
// Read in remainder of module into memory for fixups.
//
addr = modaddr//
//
// Alloc heap space for relocated module (data + bytecode).
//
moddep = moddep + 1
modfix = moddep - @header.2 // Adjust to skip header
modsize = modsize - modfix
rdlen = rdlen - modfix - 2
modaddr = allocheap(modsize)
memcpy(modaddr, moddep, rdlen)
//
// Read in remainder of module into memory for fixups.
//
addr = modaddr//
repeat
addr = addr + rdlen
rdlen = read(refnum, addr, 4096)
until rdlen <= 0
close(refnum)
//
// Add module to symbol table.
//
addmod(mod, modaddr)
//
// Apply all fixups and symbol import/export.
//
//
// Add module to symbol table.
//
addmod(mod, modaddr)
//
// Apply all fixups and symbol import/export.
//
modfix = modaddr - modfix
bytecode = defofst + modfix - MODADDR
modend = modaddr + modsize
@ -975,28 +975,28 @@ def loadmod(mod)
esd = rld // Extern+Entry Symbol Directory
while ^esd // Scan to end of ESD
esd = esd + 4
loop
loop
esd = esd + 1
//
// Locate bytecode defs in appropriate bank.
//
if ^MACHID & $30 == $30
defbank = 1
defaddr = allocxheap(rld - bytecode)
modend = bytecode
else
defbank = 0
defaddr = bytecode
fin
//
// Locate bytecode defs in appropriate bank.
//
if ^MACHID & $30 == $30
defbank = 1
defaddr = allocxheap(rld - bytecode)
modend = bytecode
else
defbank = 0
defaddr = bytecode
fin
//
// Run through the Re-Location Dictionary.
//
while ^rld
if ^rld == $02
//
// This is a bytcode def entry - add it to the def directory.
//
adddef(defbank, rld=>1 - defofst + defaddr, @deflast)
//
// This is a bytcode def entry - add it to the def directory.
//
adddef(defbank, rld=>1 - defofst + defaddr, @deflast)
else
addr = rld=>1 + modfix
if uword_isge(addr, modaddr) // Skip fixups to header
@ -1025,32 +1025,32 @@ def loadmod(mod)
fin
rld = rld + 4
loop
//
//
// Run through the External/Entry Symbol Directory.
//
//
while ^esd
sym = esd
esd = esd + dcitos(esd, @str)
if ^esd & $08
//
//
// EXPORT symbol - add it to the global symbol table.
//
//
addr = esd=>1 + modfix - MODADDR
if uword_isge(addr, bytecode)
//
// Use the def directory address for bytecode.
//
//
// Use the def directory address for bytecode.
//
addr = lookupdef(addr - bytecode + defaddr, deftbl)
fin
addsym(sym, addr)
fin
esd = esd + 3
loop
if defbank
//
// Move bytecode to AUX bank.
//
memxcpy(defaddr, bytecode, modsize - (bytecode - modaddr))
if defbank
//
// Move bytecode to AUX bank.
//
memxcpy(defaddr, bytecode, modsize - (bytecode - modaddr))
fin
fin
if perr
@ -1062,18 +1062,18 @@ def loadmod(mod)
fixup = 0 // This is repurposed for the return code
if init
fixup = adddef(defbank, init - defofst + defaddr, @deflast)()
if fixup < modinitkeep
//
// Free init routine unless initkeep
//
if defbank
xheap = init - defofst + defaddr
if fixup < modinitkeep
//
// Free init routine unless initkeep
//
if defbank
xheap = init - defofst + defaddr
else
modend = init - defofst + defaddr
modend = init - defofst + defaddr
fin
else
fixup = fixup & ~modinitkeep
fin
else
fixup = fixup & ~modinitkeep
fin
fin
//
// Free up the end-of-module in main memory.
@ -1245,7 +1245,7 @@ end
def execmod(modfile)
byte moddci[17]
word saveheap, savexheap, savesym, saveflags
if stodci(modfile, @moddci)
saveheap = heap
savexheap = xheap
@ -1320,7 +1320,7 @@ while 1
execmod(@cmdln)
break
otherwise
prstr(@huhstr)
prstr(@huhstr)
wend
if perr
prstr(@errorstr)