mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-08-16 14:29:00 +00:00
Allow control chars in command table; basic framework for game load/save established.
This commit is contained in:
parent
dcea57cc7c
commit
87ab8b6031
@ -1523,6 +1523,7 @@ class PackPartitions
|
|||||||
compileModule("gameloop", "src/plasma/")
|
compileModule("gameloop", "src/plasma/")
|
||||||
compileModule("combat", "src/plasma/")
|
compileModule("combat", "src/plasma/")
|
||||||
compileModule("party", "src/plasma/")
|
compileModule("party", "src/plasma/")
|
||||||
|
compileModule("diskops", "src/plasma/")
|
||||||
compileModule("gen_globalScripts", "src/plasma/")
|
compileModule("gen_globalScripts", "src/plasma/")
|
||||||
compileModule("gen_enemies", "src/plasma/")
|
compileModule("gen_enemies", "src/plasma/")
|
||||||
compileModule("gen_items", "src/plasma/")
|
compileModule("gen_items", "src/plasma/")
|
||||||
|
45
Platform/Apple/virtual/src/plasma/diskops.pla
Normal file
45
Platform/Apple/virtual/src/plasma/diskops.pla
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
|
||||||
|
// (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
|
||||||
|
// Unless required by applicable law or agreed to in writing, software distributed under
|
||||||
|
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||||
|
// ANY KIND, either express or implied. See the License for the specific language
|
||||||
|
// governing permissions and limitations under the License.
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Functions we import from the main game loop. If you find there are some over there that aren't
|
||||||
|
// yet exported, modify this header then add the mechanics at the top of gameloop.pla.
|
||||||
|
include "gamelib.plh"
|
||||||
|
|
||||||
|
// Definition of constants for functions exported by this module
|
||||||
|
include "diskops.plh"
|
||||||
|
|
||||||
|
// This pointer is the root of all heap-tracked (and garbage collected) objects.
|
||||||
|
// See playtype.plh for definitions of all the datastructures and how they interconnect.
|
||||||
|
word global
|
||||||
|
|
||||||
|
// Exported functions go here. First a predef for each one, then a table with function pointers
|
||||||
|
// in the same order as the constants are defined in the the header.
|
||||||
|
predef _saveGame, _loadGame
|
||||||
|
word[] funcTbl = @_saveGame, @_loadGame
|
||||||
|
|
||||||
|
// Other global variables here
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def _saveGame()
|
||||||
|
displayStr("Save game\n")
|
||||||
|
getUpperKey()
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def _loadGame()
|
||||||
|
displayStr("Load game\n")
|
||||||
|
getUpperKey()
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Boilerplate module initialization code
|
||||||
|
global = getGlobals()
|
||||||
|
return @funcTbl
|
||||||
|
done
|
13
Platform/Apple/virtual/src/plasma/diskops.plh
Normal file
13
Platform/Apple/virtual/src/plasma/diskops.plh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2016 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
|
||||||
|
// (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
|
||||||
|
// Unless required by applicable law or agreed to in writing, software distributed under
|
||||||
|
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||||
|
// ANY KIND, either express or implied. See the License for the specific language
|
||||||
|
// governing permissions and limitations under the License.
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Each module-exported function needs its own constant, 0..n
|
||||||
|
const diskops_saveGame = 0
|
||||||
|
const diskops_loadGame = 2
|
@ -42,6 +42,7 @@ include "gen_globalScripts.plh"
|
|||||||
include "gen_players.plh"
|
include "gen_players.plh"
|
||||||
include "combat.plh"
|
include "combat.plh"
|
||||||
include "party.plh"
|
include "party.plh"
|
||||||
|
include "diskops.plh"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Data structures
|
// Data structures
|
||||||
@ -73,7 +74,7 @@ byte portraitNum = 0
|
|||||||
word triggerOriginX, triggerOriginY
|
word triggerOriginX, triggerOriginY
|
||||||
word triggerTbl
|
word triggerTbl
|
||||||
|
|
||||||
word cmdTbl[64]
|
word cmdTbl[96] // ASCII $00..$5F
|
||||||
byte frameLoaded = 0
|
byte frameLoaded = 0
|
||||||
|
|
||||||
// Queue setMap / teleport, since otherwise script might be replaced while executing
|
// Queue setMap / teleport, since otherwise script might be replaced while executing
|
||||||
@ -1082,15 +1083,6 @@ def nextGround()
|
|||||||
setGround((groundNum + 1) % 18)
|
setGround((groundNum + 1) % 18)
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Establish a keystroke -> command association in the command table
|
|
||||||
def initCmd(key, func)
|
|
||||||
if key >= $60
|
|
||||||
key = key - $20
|
|
||||||
fin
|
|
||||||
cmdTbl[key-$20] = func
|
|
||||||
end
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Load the Frame Image, and lock it.
|
// Load the Frame Image, and lock it.
|
||||||
def loadFrameImg()
|
def loadFrameImg()
|
||||||
@ -1553,8 +1545,7 @@ def kbdLoop()
|
|||||||
brk()
|
brk()
|
||||||
fin
|
fin
|
||||||
key = getUpperKey()
|
key = getUpperKey()
|
||||||
key = key - $20
|
if key >= 0 and key < $60
|
||||||
if key >= 0 and key < $40
|
|
||||||
func = cmdTbl[key]
|
func = cmdTbl[key]
|
||||||
if func; func(); fin
|
if func; func(); fin
|
||||||
fin
|
fin
|
||||||
@ -1960,58 +1951,72 @@ def testCombat
|
|||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def saveGame
|
||||||
|
loadEngine(MODULE_DISKOPS)=>diskops_saveGame()
|
||||||
|
restoreMapPos()
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def loadGame
|
||||||
|
loadEngine(MODULE_DISKOPS)=>diskops_loadGame()
|
||||||
|
restoreMapPos()
|
||||||
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set up the command table for 3D mode
|
// Set up the command table for 3D mode
|
||||||
def initCmds()
|
def initCmds()
|
||||||
|
|
||||||
// Clear the command table
|
// Clear the command table
|
||||||
byte i
|
byte i
|
||||||
for i = 0 to 63
|
for i = 0 to 95
|
||||||
cmdTbl[i] = 0
|
cmdTbl[i] = 0
|
||||||
next
|
next
|
||||||
|
|
||||||
// Commands common to both 2D and 3D
|
// Commands common to both 2D and 3D
|
||||||
initCmd('T', @kbdTeleport)
|
cmdTbl['T'] = @kbdTeleport
|
||||||
initCmd('P', @showPos)
|
cmdTbl['P'] = @showPos
|
||||||
initCmd('/', @nextPortrait)
|
cmdTbl['/'] = @nextPortrait
|
||||||
initCmd('?', @prevPortrait)
|
cmdTbl['?'] = @prevPortrait
|
||||||
initCmd('!', @testCombat)
|
cmdTbl['!'] = @testCombat
|
||||||
initCmd('1', @showPlayer1)
|
cmdTbl['1'] = @showPlayer1
|
||||||
initCmd('2', @showPlayer2)
|
cmdTbl['2'] = @showPlayer2
|
||||||
initCmd('3', @showPlayer3)
|
cmdTbl['3'] = @showPlayer3
|
||||||
|
cmdTbl[$13] = @saveGame // ctrl-S
|
||||||
|
cmdTbl[$0c] = @loadGame // ctrl-L
|
||||||
|
|
||||||
// Commands handled differently in 3D vs 2D
|
// Commands handled differently in 3D vs 2D
|
||||||
if mapIs3D
|
if mapIs3D
|
||||||
initCmd('W', @moveForward)
|
cmdTbl['W'] = @moveForward
|
||||||
initCmd('A', @rotateLeft)
|
cmdTbl['A'] = @rotateLeft
|
||||||
initCmd('D', @rotateRight)
|
cmdTbl['D'] = @rotateRight
|
||||||
initCmd('S', @moveBackward)
|
cmdTbl['S'] = @moveBackward
|
||||||
initCmd('X', @moveBackward)
|
cmdTbl['X'] = @moveBackward
|
||||||
initCmd('Z', @strafeLeft)
|
cmdTbl['Z'] = @strafeLeft
|
||||||
initCmd('C', @strafeRight)
|
cmdTbl['C'] = @strafeRight
|
||||||
|
|
||||||
initCmd('I', @moveForward)
|
cmdTbl['I'] = @moveForward
|
||||||
initCmd('J', @rotateLeft)
|
cmdTbl['J'] = @rotateLeft
|
||||||
initCmd('L', @rotateRight)
|
cmdTbl['L'] = @rotateRight
|
||||||
initCmd('K', @moveBackward)
|
cmdTbl['K'] = @moveBackward
|
||||||
initCmd(',', @moveBackward)
|
cmdTbl[','] = @moveBackward
|
||||||
initCmd('M', @strafeLeft)
|
cmdTbl['M'] = @strafeLeft
|
||||||
initCmd('.', @strafeRight)
|
cmdTbl['.'] = @strafeRight
|
||||||
|
|
||||||
initCmd('Y', @nextSky)
|
cmdTbl['Y'] = @nextSky
|
||||||
initCmd('G', @nextGround)
|
cmdTbl['G'] = @nextGround
|
||||||
else
|
else
|
||||||
initCmd('W', @moveNorth)
|
cmdTbl['W'] = @moveNorth
|
||||||
initCmd('D', @moveEast)
|
cmdTbl['D'] = @moveEast
|
||||||
initCmd('S', @moveSouth)
|
cmdTbl['S'] = @moveSouth
|
||||||
initCmd('X', @moveSouth)
|
cmdTbl['X'] = @moveSouth
|
||||||
initCmd('A', @moveWest)
|
cmdTbl['A'] = @moveWest
|
||||||
|
|
||||||
initCmd('I', @moveNorth)
|
cmdTbl['I'] = @moveNorth
|
||||||
initCmd('J', @moveWest)
|
cmdTbl['J'] = @moveWest
|
||||||
initCmd('L', @moveEast)
|
cmdTbl['L'] = @moveEast
|
||||||
initCmd('K', @moveSouth)
|
cmdTbl['K'] = @moveSouth
|
||||||
initCmd(',', @moveSouth)
|
cmdTbl[','] = @moveSouth
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user