diff --git a/src/samplesrc/LEVEL0#040000 b/src/samplesrc/LEVEL0#040000 new file mode 100644 index 0000000..31d8452 --- /dev/null +++ b/src/samplesrc/LEVEL0#040000 @@ -0,0 +1 @@ +## .#[-]#.......#&......&..* # ..*...*...###T#.....####.. # ...###.....##.#...&...##.. # ....###.&....#.#.......##.. .............#.+.......##.. .............#.#.T.....##.. ......&#.....&.#.:.......##.. ......###....###.:.......##.. ##.....#.....###.#......&##.. #&.....*...#####.##:#:#:###.. ######......####.#&.........* ###.T......#####.##*....##### #..........#####.##.....##[=] ##....&#....&###.##.....#..O. #.....###...####.###....#$... ##&....#.....###.#&#....###%# ,##....*....####.##.>>.##*..* .######+########.##<<<..##... ...............&.##>>>>>....& \ No newline at end of file diff --git a/src/samplesrc/CATACOMB#040000 b/src/samplesrc/LEVEL1#040000 similarity index 54% rename from src/samplesrc/CATACOMB#040000 rename to src/samplesrc/LEVEL1#040000 index 13007fd..1f98308 100644 --- a/src/samplesrc/CATACOMB#040000 +++ b/src/samplesrc/LEVEL1#040000 @@ -1 +1 @@ -##....&$&#####.......##..#[-]#..#...........................T. #.....#######. .&##..*...*..#.##########......*...*......& .....###..... .###.........#.#.......###...##.....##....# #........ .####.........#...#####.##&...##.T...##....# ##. ..###.........#.#.#.....####....*...*......& #### ....######+#####.#.#.##########.........<<<<< ######### ........###.#&#.#.#.#..........#####....>>>>>> ###....&##......T........##.#..#..#.#.########....##...<<<<<<< &#.## ##############*....#.#####.#.#.#...#.&####..:...>>>>>>> ...... ############.....T#.......#.#...#T...#.##*.:....<<<<<< ###.........#####........##########.########:#.##..#...>>>>>>$ ##.....................*##.....................##..#..<<<<<<.. ..&###*..##..............#+##################.###*.#.>>>>>.... ..#####..##......#&........#..................##...#.<<<<....# ..&##O...#.....####....*####.###################*..#.>>>>...## ...............T##*....##.....................#....#.<<<....## #...........&..........#########.*.*.########.#O...#.>>>...O.# ####..................##.........#.#.....###..#.##.#........&# ..$.########........###..#########.####+####.##.##.#.......### #####......##########.&.##....O$&#.#..&.##*..#.....##....##... ......*###............###..#######.#.T..##..##.....##########+ .####....##############...*#...&O#.#...*&#O.#...##.....O##&... .&..####.....................#####.#..T..##.#...##............ ###T#&.#######################.....##.....#.#...*...##....*##. ..####.........................###..##....#.#.......##*....##. &....###########+###############.....###.&#.#..&##......##.... .#.O.#...#...&.......#&###.......###...##.#.#.T....*##....*... ...#...#...#...#...#.....####.####Z###..#.#.#.......##........ .#...#.&O#.*.#...#...#*.#Z#.#+#.......*.#.#.#&.........T....&. ..,#...#...#...#...#......#.............#O#+####...&......#### .#.&.#...#...#...#....&..##...#.........#+#.########.....####& ...#..Z#...#&..#..*...####.O..:.&.......#.:.#......O.......... .#...#...#...#.......##..#....:.........*.:.*Z................ &.......*.......######...##&..#::::::#....:.................## ####........#####.........###.............:.&.#::::::::::::::# ...##########...............#......O......:............&...... ............................#.............#......Z............ ............................##.............................##. .............................########%######################## ...open space............###########..:....................... ........................##............:..Z.................... ....fill it in!!.......##..############....................... .......................#..##.................................. ......................##...:.................................. ......................#....:........open space................ ......................#.####.................................. ......................#.#............fill it in!.............. ......................#.#..................................... #######################+#..................................... ###...&##...#...###.#...##.................................... &#.Z....#....Z...#.......#.................................... ........*........*.......#.................................... ......................*###.................................... . ...............#.................................... . ............#.................................... ......... ...........##.................................... .......... .......Z..&#.................................... .R.......... ..&.......#.................................... ........R.... ........*##.................................... ..*...*.....<<<<........##.................................... .&#[=]#&....$>>>>.......&#.................................... \ No newline at end of file +##....&@&#####.......##..#[-]#..#...........................T. #.....#######. .&##..*...*..#.##########......*...*......& .....###..... .###.........#.#.......###...##.....##....# #........ .####.........#...#####.##&...##.T...##....# ##. ..###.........#.#.#.....####....*...*......& #### ....######+#####.#.#.##########.........<<<<< ######### ........###.#&#.#.#.#..........#####....>>>>>> ###....&##......T........##.#..#..#.#.########....##...<<<<<<< &#.## ##############*....#.#####.#.#.#...#.&####..:...>>>>>>> ...... ############.....T#.......#.#...#T...#.##*.:....<<<<<< ###.........#####........##########.########:#.##..#...>>>>>>$ ##.....................*##.....................##..#..<<<<<<.. ..&###*..##..............#+##################.###*.#.>>>>>.... ..#####..##......#&........#..................##...#.<<<<....# ..&##O...#.....####....*####.###################*..#.>>>>...## ...............T##*....##.....................#....#.<<<....## #...........&..........#########.*.*.########.#O...#.>>>...O.# ####..................##.........#.#.....###..#.##.#........&# ..$.########........###..#########.####+####.##.##.#.......### #####......##########.&.##....O$&#.#..&.##*..#.....##....##... ......*###............###..#######.#.T..##..##.....##########+ .####....##############...*#...&O#.#...*&#O.#...##.....O##&... .&..####.....................#####.#..T..##.#...##............ ###T#&.#######################.....##.....#.#...*...##....*##. ..####.........................###..##....#.#.......##*....##. &....###########+###############.....###.&#.#..&##......##.... .#.O.#...#...&.......#&###.......###...##.#.#.T....*##....*... ...#...#...#...#...#.....####.####Z###..#.#.#.......##........ .#...#.&O#.*.#...#...#*.#Z#.#+#.......*.#.#.#&.........T....&. ..,#...#...#...#...#......#.............#O#+####...&......#### .#.&.#...#...#...#....&..##...#.........#+#.########.....####& ...#..Z#...#&..#..*...####.O..:.&.......#.:.#......O.......... .#...#...#...#.......##..#....:.........*.:.*Z................ &.......*.......######...##&..#::::::#....:.................## ####........#####.........###.............:.&.#::::::::::::::# #####################.......#......O......:............&...... #...................##......#.............#......Z............ ........*...$$...*...#......##.............................##. .........#......#....#.......########%######################## .........:.Z...Z:....#...############.#>>>>>>>>>>>>>>.....&.&Z .........:......:....#..##............#<<<<<<<<<<<<<<..Z....$$ .........:Z..Z..:....#.##..############>>>>>>>>>>>>>>......... .........:......:....#.#..##......<<<<<<<<<<<<<<<<<<<....Z.Z.. .........:..R.Z.:....###...:......>>>>>>>>>>>>>>>>>>>>.......& .........:......:....##....:.O....<<<<<<<<<<<<<<<<<<<<<....... .........#::::::#....##.##+#.....>>>>>>>>>>>>>>>>>>>>>>>>>>... ..&.....*........*...##.#.......<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #...................###.#...&.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ################..#####+#...<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ###...&##...#...###.#...##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> &#.Z....#....Z...#.......####<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ........*........*.......#..#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ......................*###..#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< . ...............#.&###>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> . ............#....#####<<<<<<<<<<<<<<<<<<<<<<<<<<< ......... ...........##........######>>>>>>>>>>>>>>>>>>>>>> .......... .......Z..&#..Z.$........#####<<<<<<<<<<<<<<<<## .R.......... ..&.......#..#######################+#########. ........R.... ........*##...................Z#.......##...... ..*...*.....<<<<........## .............+.*....*##...... .&#[=]#&....$>>>>.......&# ..Z.###.&..$.+....Z$ \ No newline at end of file diff --git a/src/samplesrc/rogue.combat.pla b/src/samplesrc/rogue.combat.pla index e6580be..359390e 100644 --- a/src/samplesrc/rogue.combat.pla +++ b/src/samplesrc/rogue.combat.pla @@ -30,9 +30,26 @@ struc t_player word oil byte gold byte key + byte raft byte[32] name[32] end +// +// ASCII Warrior +// + +byte[] ascii_warrior +byte = " | " +byte = " T " +byte = " \\ () " +byte = " \\^ " +byte = " #\\_] " +byte = " # ] " +byte = " /\\ " +byte = " / \\ " +byte = " / / " +byte = " = = " + // // Other monsters // @@ -87,16 +104,16 @@ byte = "|%%//%%%/|" byte = "<===|@___/" byte[] ascii_rogue -byte = " | " -byte = " T " -byte = " \\ () " -byte = " \\^ " -byte = " #\\_] " -byte = " # ] " -byte = " /\\ " -byte = " / \\ " -byte = " / / " -byte = " = = " +byte = " " +byte = " \\ / " +byte = " < - - > " +byte = " ( \" ) " +byte = " \\VVV/ " +byte = " \\M/ " +byte = " ^^^^^^ " +byte = " / \\ " +byte = "( ) ^^>--=" +byte = "( ) WW>--//" word ascii_entity = @ascii_thief, @ascii_ogre, @ascii_zombie, @ascii_rogue // @@ -104,9 +121,9 @@ word ascii_entity = @ascii_thief, @ascii_ogre, @ascii_zombie, @ascii_rogue // byte thief = "Thief", 5 -byte ogre = "Ogre", 15 -byte zombie = "Zombie", 25 -byte rogue = "Rogue", 50 +byte ogre = "Ogre", 20 +byte zombie = "Zombie", 40 +byte rogue = "Rogue", 80 export word entity = @thief, @ogre, @zombie, @rogue export word entities = 0 @@ -153,7 +170,7 @@ export def fight(player, enemy) puts(@lifestr); puti(enemy->life) for e_atck = 0 to 9 gotoxy(0, 10 + e_atck) - puts(@ascii_rogue + e_atck * 11) + puts(@ascii_warrior + e_atck * 11) gotoxy(20, 10 + e_atck) puts(ascii_entity[enemy->kind] + e_atck * 11) next diff --git a/src/samplesrc/rogue.map.pla b/src/samplesrc/rogue.map.pla index 47aace8..c2ee9a7 100644 --- a/src/samplesrc/rogue.map.pla +++ b/src/samplesrc/rogue.map.pla @@ -19,7 +19,7 @@ import ROGUEIO end const FALSE = 0 -const TRUE = not FALSE +const TRUE = 1 // // Octant beam parameters @@ -124,6 +124,7 @@ const LOCKED_TILE = '%' const WATER1_TILE = '>' const WATER2_TILE = '<' const KEY_TILE = ',' +const RAFT_TILE = '@' const GOLD_TILE = '$' const FOOD_TILE = '&' const ENTER_TILE = '-' @@ -134,30 +135,7 @@ 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 catacomb = "CATACOMB" +byte catacomb = "LEVEL0" word map, viewmap const xcentr = 20 @@ -183,10 +161,10 @@ word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer // -// Load map +// Load map - levels 0 to 9 // -export def loadmap +export def loadmap(level) byte mapref, row, l // @@ -203,6 +181,10 @@ export def loadmap map = heapalloc(mapsize) fin memset(map, mapsize, $2323) // Solid walls + // + // Set level map and read it + // + catacomb[catacomb] = '0' + level mapref = open(@catacomb, O_READ) if mapref newline(mapref, $7F, $0D) @@ -211,7 +193,9 @@ export def loadmap ^(map + (row << 6) + l) = WALL_TILE next close(mapref) + return TRUE fin + return FALSE end // @@ -262,6 +246,9 @@ export def lighttorches next fin next + if not (ymap & 7) + putc('.') + fin next end @@ -358,7 +345,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist) // Update view // ^(viewmap + imap) = tile | VIEWED_TILE - screen.[ycentr-ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE + if tile <> PIT_TILE + screen.[ycentr-ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE + fin else vispix[l] = 0 fin @@ -430,7 +419,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist) fin fin ^(viewmap + imap) = tile | VIEWED_TILE - screen.[ycentr-xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE + if tile <> PIT_TILE + screen.[ycentr-xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE + fin else vispix[l] = 0 fin @@ -478,7 +469,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist) fin fin ^(viewmap + imap) = tile | VIEWED_TILE - screen.[ycentr+xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE + if tile <> PIT_TILE + screen.[ycentr+xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE + fin else vispix[l] = 0 fin @@ -526,7 +519,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist) fin fin ^(viewmap + imap) = tile | VIEWED_TILE - screen.[ycentr+ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE + if tile <> PIT_TILE + screen.[ycentr+ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE + fin else vispix[l] = 0 fin @@ -574,7 +569,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist) fin fin ^(viewmap + imap) = tile | VIEWED_TILE - screen.[ycentr+ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE + if tile <> PIT_TILE + screen.[ycentr+ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE + fin else vispix[l] = 0 fin @@ -622,7 +619,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist) fin fin ^(viewmap + imap) = tile | VIEWED_TILE - screen.[ycentr+xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE + if tile <> PIT_TILE + screen.[ycentr+xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE + fin else vispix[l] = 0 fin @@ -670,7 +669,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist) fin fin ^(viewmap + imap) = tile | VIEWED_TILE - screen.[ycentr-xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE + if tile <> PIT_TILE + screen.[ycentr-xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE + fin else vispix[l] = 0 fin @@ -718,7 +719,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist) fin fin ^(viewmap + imap) = tile | VIEWED_TILE - screen.[ycentr-ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE + if tile <> PIT_TILE + screen.[ycentr-ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE + fin else vispix[l] = 0 fin diff --git a/src/samplesrc/rogue.pla b/src/samplesrc/rogue.pla index fe9db46..44b21db 100755 --- a/src/samplesrc/rogue.pla +++ b/src/samplesrc/rogue.pla @@ -15,6 +15,7 @@ import ROGUEMAP const mapsize = maprows*mapcols const FLOOR_TILE = '.' + const WALL_TILE = '#' const TORCH_TILE = '*' const PIT_TILE = ' ' const DOOR_TILE = '+' @@ -22,6 +23,7 @@ import ROGUEMAP const WATER1_TILE = '>' const WATER2_TILE = '<' const KEY_TILE = ',' + const RAFT_TILE = '@' const GOLD_TILE = '$' const FOOD_TILE = '&' const ENTER_TILE = '-' @@ -55,7 +57,8 @@ word xdir = 0, 1, 1, 1, 0, -1, -1, -1 word ydir = -1, -1, 0, 1, 1, 1, 0, -1 byte vplayer = '^', '\\', '>', '/', 'v', '\\', '<', '/' byte totaldarkness = 0 - +byte level = 0 +word free_entities // // Power-ups // @@ -84,6 +87,7 @@ struc t_player word oil byte gold byte key + byte raft byte[16] name end @@ -98,6 +102,7 @@ byte = 100 // energy word = 500 // oil byte = 0 // gold byte = 0 // key +byte = 0 // raft byte[16] = "Player" predef moveplayer @@ -122,11 +127,12 @@ end const statusline = 23 -byte helthstr = "Helth:" -byte enrgystr = "Enrgy:" +byte helthstr = "Hlth:" +byte enrgystr = "NRG:" byte oilstr = "Oil:" -byte goldstr = "Gold:" +byte goldstr = "Gld:" byte keystr = "Key" +byte raftstr = "Flt" // // Messages @@ -134,11 +140,12 @@ byte keystr = "Key" word instr byte namestr = "\nGreetings Warrior,\n what is your name" -byte prepstr = "\nPrepare" +byte prepstr = "\nPrepare." byte quitstr = "Are you sure you want to quit?" byte youmadeitstr = "You made it out alive with $" byte youdiedstr = "You perished inside the catacombs :-(" byte againstr = "\n\nPlay again by typing: +rogue\n" + // // Utility functions // @@ -171,6 +178,21 @@ def fall next end +def drown + word i + + tone(10,20) + tone(10,1) + for i = 0 to 1000 + next + tone(10,25) + tone(10,2) + for i = 0 to 1000 + next + tone(10,30) + tone(10,3) +end + def groan byte i @@ -187,15 +209,19 @@ def status gotoxy(0, statusline) puts(@helthstr) puti(player.health) - gotoxy(10, statusline) + gotoxy(9, statusline) puts(@enrgystr) puti(player.energy) - gotoxy(20, statusline) + gotoxy(17, statusline) puts(@oilstr) puti(player:oil/10) - gotoxy(28, statusline) + gotoxy(25, statusline) puts(@goldstr) puti(player.gold) + if player.raft + gotoxy(32, statusline) + puts(@raftstr) + fin if player.key gotoxy(36, statusline) puts(@keystr) @@ -211,16 +237,28 @@ end // def moveplayer(dir) - player.xpos = player.xpos + dir * xdir[player.angle] - player.ypos = player.ypos + dir * ydir[player.angle] - when getmaptile(player.xpos, player.ypos) & MAP_TILE + byte xmove, ymove + + xmove = player.xpos + dir * xdir[player.angle] + ymove = player.ypos + dir * ydir[player.angle] + when getmaptile(xmove, ymove) & MAP_TILE is PIT_TILE fall player.energy = 0 player.health = 0 + break + is WATER1_TILE + is WATER2_TILE + if not player.raft + drown + player.energy = 0 + player.health = 0 + break + fin is FLOOR_TILE is TORCH_TILE is KEY_TILE + is RAFT_TILE is GOLD_TILE is FOOD_TILE if player.energy < 10 @@ -229,10 +267,10 @@ def moveplayer(dir) if player.energy player.energy = player.energy - 1 fin + player.xpos = xmove + player.ypos = ymove break otherwise - player.xpos = player.xpos - dir * xdir[player.angle] - player.ypos = player.ypos - dir * ydir[player.angle] ouch wend end @@ -258,33 +296,33 @@ def findentities player.angle = 4 fin break - is 'R' // Rogue - what = what + 1 - is 'Z' // Zombie - what = what + 1 + 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 if not (ymap & 7) @@ -507,36 +545,45 @@ def play updtmaptile(player.xpos, player.ypos, FLOOR_TILE) gotit break + is RAFT_TILE + player.raft = 1 + updtmaptile(player.xpos, player.ypos, FLOOR_TILE) + gotit + break is GOLD_TILE player.gold = player.gold + 1 updtmaptile(player.xpos, player.ypos, FLOOR_TILE) gotit break is TORCH_TILE - player:oil = player:oil + TORCH_OIL - if player:oil > 1000 - player:oil = 1000 - fin - setmaptile(player.xpos, player.ypos, FLOOR_TILE) - for yt = player.ypos - 1 to player.ypos + 1 - for xt = player.xpos - 1 to player.xpos + 1 - setmaptile(xt, yt, getmaptile(xt, yt) & MAP_TILE) + if player.oil < 1000 + player:oil = player:oil + TORCH_OIL + if player:oil > 1000 + player:oil = 1000 + fin + setmaptile(player.xpos, player.ypos, FLOOR_TILE) + for yt = player.ypos - 1 to player.ypos + 1 + for xt = player.xpos - 1 to player.xpos + 1 + setmaptile(xt, yt, getmaptile(xt, yt) & MAP_TILE) + next next - next - gotit + gotit + fin break is FOOD_TILE - player.health = player.health + MANA/2 - if player.health > 100 - player.health = 100 + if player.health < 100 or player.energy < 100 + player.health = player.health + MANA/2 + if player.health > 100 + player.health = 100 + fin + player.energy = player.energy + MANA + if player.energy > 100 + player.energy = 100 + fin + updtmaptile(player.xpos, player.ypos, FLOOR_TILE) + player.fov = 1 + gotit fin - player.energy = player.energy + MANA - if player.energy > 100 - player.energy = 100 - fin - updtmaptile(player.xpos, player.ypos, FLOOR_TILE) - player.fov = 1 - gotit break wend break @@ -573,35 +620,44 @@ def play player:oil = 0 player.lamp = 0 fin - return TRUE + return player.health end // // Main loop // -loadmap puts(@namestr) instr = gets($BA) if ^instr > 15 ^instr = 15 fin memcpy(@player.name, instr, ^instr + 1) -puts(@prepstr) -findentities -lighttorches -repeat - moveentities(player.lamp or getmaptile(player.xpos, player.ypos) & LIT_TILE)) - totaldarkness = drawmap(player.xpos, player.ypos, player.fov, player.angle, player.lamp, maxview) - if not totaldarkness - drawentities - gotoxy(xcentr, ycentr) - putc(vplayer[player.angle]) +while loadmap(level) + puts(@prepstr) + free_entities = heapmark() + findentities + lighttorches + repeat + moveentities(player.lamp or getmaptile(player.xpos, player.ypos) & LIT_TILE)) + totaldarkness = drawmap(player.xpos, player.ypos, player.fov, player.angle, player.lamp, maxview) + if not totaldarkness + drawentities + gotoxy(xcentr, ycentr) + putc(vplayer[player.angle]) + fin + status + until not play + heaprelease(free_entities) + entities = 0 + player.key = 0 + level = level + 1 + clearstatus + gotoxy(0, statusline) + if player.health == 0 + break fin - status -until not play or player.health == 0 -clearstatus -gotoxy(0, statusline) +loop if player.health > 0 puts(@youmadeitstr) puti(player.gold) diff --git a/src/toolsrc/sb.pla b/src/toolsrc/sb.pla index a0af425..683a6e0 100644 --- a/src/toolsrc/sb.pla +++ b/src/toolsrc/sb.pla @@ -1758,9 +1758,11 @@ def editmode if flags & insmode splitline else - openline(cursrow + 1) cursdown - redraw + curscol = 0 + cursx = 0 + scrnleft = 0 + redraw fin break is keyctrlt diff --git a/src/vmsrc/cmd.pla b/src/vmsrc/cmd.pla index 70f47e6..e0994d2 100644 --- a/src/vmsrc/cmd.pla +++ b/src/vmsrc/cmd.pla @@ -774,11 +774,11 @@ def allocalignheap(size, pow2, freeaddr) return addr end def markheap - return heap// + return heap end def releaseheap(newheap) - heap = newheap// - return @newheap - heap// + heap = newheap + return @newheap - heap end def allocxheap(size) word xaddr @@ -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 // - // 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 + // 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 - else - modend = init - defofst + defaddr - fin + if fixup < modinitkeep + // + // Free init routine unless initkeep + // + if defbank + xheap = init - defofst + defaddr else - fixup = fixup & ~modinitkeep + modend = init - defofst + defaddr fin + else + fixup = fixup & ~modinitkeep + fin fin // // Free up the end-of-module in main memory.