2014-07-03 23:56:26 +00:00
|
|
|
;==================================================================================================
|
2014-06-25 15:47:28 +00:00
|
|
|
; Handy constants.
|
|
|
|
const FALSE = 0
|
|
|
|
const TRUE = !FALSE
|
2014-07-03 23:56:26 +00:00
|
|
|
|
2014-07-06 21:40:35 +00:00
|
|
|
;==================================================================================================
|
|
|
|
; Fixed memory locations
|
|
|
|
const raycaster = $6000 ; main mem
|
|
|
|
const expandVec = $800 ; aux mem
|
|
|
|
const fontEngine = $BA00 ; main mem
|
|
|
|
|
|
|
|
;==================================================================================================
|
|
|
|
; Resource numbers
|
|
|
|
const RES_NUM_RAYCASTER = 1
|
|
|
|
const RES_NUM_EXPAND_VEC = 2
|
|
|
|
const RES_NUM_FONT_ENGINE = 3
|
|
|
|
|
2014-07-03 23:56:26 +00:00
|
|
|
;==================================================================================================
|
2014-06-25 15:47:28 +00:00
|
|
|
; Hardware addresses.
|
|
|
|
const keyboard = $C000
|
|
|
|
const keystrobe = $C010
|
2014-07-06 21:40:35 +00:00
|
|
|
|
|
|
|
;==================================================================================================
|
|
|
|
; Memory manager definitions
|
|
|
|
|
|
|
|
; Resource types
|
|
|
|
const RES_TYPE_CODE = 1
|
|
|
|
const RES_TYPE_2D_MAP = 2
|
|
|
|
const RES_TYPE_3D_MAP = 3
|
|
|
|
const RES_TYPE_TILE = 4
|
|
|
|
const RES_TYPE_TEXTURE = 5
|
|
|
|
const RES_TYPE_SCREEN = 6
|
|
|
|
const RES_TYPE_FONT = 7
|
|
|
|
const RES_TYPE_MODULE = 8
|
|
|
|
const RES_TYPE_BYTECODE = 9
|
|
|
|
const RES_TYPE_FIXUP = 10
|
|
|
|
|
|
|
|
; Memory banks
|
|
|
|
const MAIN_MEM = 0
|
|
|
|
const AUX_MEM = 1
|
|
|
|
|
|
|
|
; Command codes
|
|
|
|
const RESET_MEMORY = $10
|
|
|
|
const REQUEST_MEMORY = $11
|
|
|
|
const LOCK_MEMORY = $12
|
|
|
|
const UNLOCK_MEMORY = $13
|
|
|
|
const SET_MEM_TARGET = $14
|
|
|
|
const START_LOAD = $15
|
|
|
|
const QUEUE_LOAD = $16
|
|
|
|
const FINISH_LOAD = $17
|
|
|
|
const FREE_MEMORY = $18
|
|
|
|
const CALC_FREE = $19
|
|
|
|
const CHAIN_LOADER = $1E
|
|
|
|
const FATAL_ERROR = $1F
|
2014-07-03 23:56:26 +00:00
|
|
|
|
2014-07-09 02:11:03 +00:00
|
|
|
const callbacks = $300
|
2014-07-08 16:39:31 +00:00
|
|
|
|
2014-07-06 23:13:44 +00:00
|
|
|
;==================================================================================================
|
|
|
|
; Predefined functions, for circular calls
|
2014-07-09 02:11:03 +00:00
|
|
|
predef moveBackward, setWindow2
|
2014-07-06 23:13:44 +00:00
|
|
|
|
2014-07-06 23:02:52 +00:00
|
|
|
;==================================================================================================
|
|
|
|
; Raycaster variables
|
|
|
|
word zp = 0
|
|
|
|
const playerDir = $5D
|
|
|
|
const playerX = $5E
|
|
|
|
const playerY = $60
|
2014-07-06 23:45:27 +00:00
|
|
|
const backBuf = $6A
|
|
|
|
const frontBuf = $6B
|
2014-07-06 23:02:52 +00:00
|
|
|
|
2014-07-08 16:39:31 +00:00
|
|
|
;==================================================================================================
|
|
|
|
; Font engine variables
|
|
|
|
const wndleft = $70 ; left edge of the window
|
|
|
|
const wndwdth = $71 ; right edge (NOT width) of text window
|
|
|
|
const wndtop = $72 ; top of text window
|
|
|
|
const wndbtm = $73 ; bottom+1 of text window
|
|
|
|
|
|
|
|
const cursh = $74 ; Cursor H-pos 0-39
|
|
|
|
const cursv = $75 ; Cursor V-pos 0-23
|
|
|
|
|
2014-07-19 20:54:41 +00:00
|
|
|
const MAX_LOC_TRIG = 80
|
|
|
|
|
2014-07-03 23:56:26 +00:00
|
|
|
;==================================================================================================
|
|
|
|
; Strings.
|
2014-07-06 21:40:35 +00:00
|
|
|
byte helloStr[] = "Loading Lawless Legends.\n"
|
2014-07-06 23:02:52 +00:00
|
|
|
byte loopStr[] = "Entering keyboard loop.\n"
|
2014-07-06 14:40:57 +00:00
|
|
|
|
2014-07-06 21:40:35 +00:00
|
|
|
;==================================================================================================
|
|
|
|
; Global variables
|
|
|
|
word mapNum = 1
|
|
|
|
word pFont
|
|
|
|
word pMap
|
2014-07-08 23:02:10 +00:00
|
|
|
word pScripts
|
2014-07-06 23:02:52 +00:00
|
|
|
word cmdTbl[64]
|
2014-07-09 02:11:03 +00:00
|
|
|
word nLocTrig = 0
|
2014-07-19 20:54:41 +00:00
|
|
|
word locTrig_x[MAX_LOC_TRIG]
|
|
|
|
word locTrig_y[MAX_LOC_TRIG]
|
|
|
|
word locTrig_func[MAX_LOC_TRIG]
|
2014-07-09 02:11:03 +00:00
|
|
|
word prevX
|
|
|
|
word prevY
|
2014-07-06 23:02:52 +00:00
|
|
|
|
|
|
|
; Movement amounts when walking at each angle
|
|
|
|
; Each entry consists of an X bump and a Y bump, in 8.8 fixed point
|
|
|
|
word walkDirs[] = $0040, $0000
|
|
|
|
word = $003B, $0018
|
|
|
|
word = $002D, $002D
|
|
|
|
word = $0018, $003B
|
|
|
|
word = $0000, $0040
|
|
|
|
word = $FFE8, $003B
|
|
|
|
word = $FFD3, $002D
|
|
|
|
word = $FFC5, $0018
|
|
|
|
word = $FFC0, $0000
|
|
|
|
word = $FFC5, $FFE8
|
|
|
|
word = $FFD3, $FFD3
|
|
|
|
word = $FFE8, $FFC5
|
|
|
|
word = $0000, $FFC0
|
|
|
|
word = $0018, $FFC5
|
|
|
|
word = $002D, $FFD3
|
|
|
|
word = $003B, $FFE8
|
2014-07-03 23:56:26 +00:00
|
|
|
|
2014-07-07 00:04:26 +00:00
|
|
|
byte skyGndTbl1[] = $00 ; lo-bit black
|
|
|
|
byte = $00 ; lo-bit black
|
|
|
|
byte = $00 ; lo-bit black
|
|
|
|
byte = $02 ; violet
|
|
|
|
byte = $08 ; green
|
|
|
|
byte = $0A ; lo-bit white
|
|
|
|
byte = $0A ; lo-bit white
|
|
|
|
byte = $0A ; lo-bit white
|
|
|
|
byte = $20 ; hi-bit black
|
|
|
|
byte = $20 ; hi-bit black
|
|
|
|
byte = $20 ; hi-bit black
|
|
|
|
byte = $22 ; blue
|
|
|
|
byte = $28 ; orange
|
|
|
|
byte = $2A ; hi-bit white
|
|
|
|
byte = $2A ; hi-bit white
|
|
|
|
byte = $2A ; hi-bit white
|
|
|
|
byte skyGndTbl2[] = $00 ; lo-bit black
|
|
|
|
byte = $02 ; violet
|
|
|
|
byte = $08 ; green
|
|
|
|
byte = $02 ; violet
|
|
|
|
byte = $08 ; green
|
|
|
|
byte = $02 ; violet
|
|
|
|
byte = $08 ; green
|
|
|
|
byte = $0A ; lo-bit white
|
|
|
|
byte = $20 ; hi-bit black
|
|
|
|
byte = $22 ; blue
|
|
|
|
byte = $28 ; orange
|
|
|
|
byte = $22 ; blue
|
|
|
|
byte = $28 ; orange
|
|
|
|
byte = $22 ; blue
|
|
|
|
byte = $28 ; orange
|
|
|
|
byte = $2A ; hi-bit white
|
|
|
|
|
2014-07-07 01:22:31 +00:00
|
|
|
word skyNum = 9
|
|
|
|
word groundNum = 10
|
2014-07-07 00:04:26 +00:00
|
|
|
|
2014-07-03 23:56:26 +00:00
|
|
|
;==================================================================================================
|
|
|
|
; Definitions used by assembly code
|
|
|
|
asm __defs
|
2014-07-06 21:40:35 +00:00
|
|
|
!source "../../include/global.i"
|
|
|
|
!source "../../include/plasma.i"
|
|
|
|
!source "../../include/mem.i"
|
|
|
|
!source "../../include/fontEngine.i"
|
|
|
|
tmp = $2
|
|
|
|
pTmp = $4
|
2014-07-03 23:56:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
;==================================================================================================
|
|
|
|
; Print a string
|
|
|
|
asm puts
|
2014-07-06 21:40:35 +00:00
|
|
|
txa
|
|
|
|
pha
|
2014-07-06 23:02:52 +00:00
|
|
|
bit setROM
|
2014-07-06 21:40:35 +00:00
|
|
|
lda evalStkL,x
|
|
|
|
sta pTmp
|
|
|
|
lda evalStkH,x
|
|
|
|
sta pTmp+1
|
|
|
|
ldy #0
|
|
|
|
lda (pTmp),y
|
|
|
|
tax
|
|
|
|
iny
|
|
|
|
- lda (pTmp),y
|
|
|
|
ora #$80
|
|
|
|
jsr cout
|
|
|
|
iny
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
bit setLcRW+lcBank2
|
|
|
|
pla
|
|
|
|
tax
|
|
|
|
rts
|
2014-07-06 14:40:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
;==================================================================================================
|
|
|
|
; Print a 16-bit hex value, followed by a space
|
|
|
|
asm printHex
|
2014-07-06 21:40:35 +00:00
|
|
|
bit setROM
|
|
|
|
lda evalStkH,x
|
|
|
|
jsr prbyte
|
|
|
|
lda evalStkL,x
|
|
|
|
jsr prbyte
|
|
|
|
lda #$A0
|
|
|
|
jsr cout
|
|
|
|
bit setLcRW+lcBank2
|
|
|
|
rts
|
2014-06-25 15:47:28 +00:00
|
|
|
end
|
2014-07-03 23:56:26 +00:00
|
|
|
|
2014-07-06 23:02:52 +00:00
|
|
|
asm crout
|
|
|
|
bit setROM
|
|
|
|
jsr crout
|
2014-07-09 02:11:03 +00:00
|
|
|
dex ; don't-care return value
|
2014-07-06 23:02:52 +00:00
|
|
|
bit setLcRW+lcBank2
|
|
|
|
rts
|
|
|
|
end
|
|
|
|
|
2014-07-03 23:56:26 +00:00
|
|
|
;==================================================================================================
|
2014-07-06 21:40:35 +00:00
|
|
|
; Allocate memory
|
|
|
|
asm loader ; (cmd, mainOrAux, amount)
|
|
|
|
txa
|
|
|
|
pha
|
|
|
|
bit setROM
|
|
|
|
lda evalStkL+2,x ; command code
|
|
|
|
pha
|
|
|
|
lda evalStkL+1,x ; main or aux
|
|
|
|
lsr
|
|
|
|
ldy evalStkH,x ; address (or other param)
|
|
|
|
lda evalStkL,x
|
|
|
|
tax
|
|
|
|
pla
|
|
|
|
bcs +
|
|
|
|
jsr mainLoader
|
|
|
|
clc
|
|
|
|
bcc ++
|
|
|
|
+ jsr auxLoader
|
|
|
|
++ stx tmp
|
|
|
|
pla
|
|
|
|
tax
|
2014-07-06 23:02:52 +00:00
|
|
|
inx ; drop second and third parameters
|
|
|
|
inx
|
2014-07-06 21:40:35 +00:00
|
|
|
lda tmp
|
|
|
|
sta evalStkL,x
|
|
|
|
tya
|
|
|
|
sta evalStkH,x
|
|
|
|
bit setLcRW+lcBank2
|
|
|
|
rts
|
|
|
|
end
|
|
|
|
|
2014-07-06 23:02:52 +00:00
|
|
|
asm initFontEngine ; (pFont)
|
2014-07-06 21:40:35 +00:00
|
|
|
txa
|
|
|
|
pha
|
|
|
|
bit setROM
|
|
|
|
ldy evalStkL,x ; font engine likes *lo* byte in Y
|
|
|
|
lda evalStkH,x ; hi byte in X
|
|
|
|
tax
|
|
|
|
jsr setFONT
|
|
|
|
; Set to write text on both hi-res pages at the same time
|
|
|
|
lda #pHGR3
|
|
|
|
jsr displayMODE
|
|
|
|
; Set to normal (non-inverse) text
|
|
|
|
lda #pNORMAL
|
|
|
|
jsr drawMODE
|
|
|
|
pla
|
|
|
|
tax
|
|
|
|
bit setLcRW+lcBank2
|
|
|
|
rts
|
|
|
|
end
|
|
|
|
|
2014-07-06 23:02:52 +00:00
|
|
|
asm initRaycaster ; (pMap)
|
2014-07-06 21:40:35 +00:00
|
|
|
txa
|
|
|
|
pha
|
|
|
|
bit setROM
|
|
|
|
lda evalStkL,x
|
|
|
|
ldy evalStkH,x
|
|
|
|
jsr $6000
|
|
|
|
pla
|
|
|
|
tax
|
|
|
|
bit setLcRW+lcBank2
|
|
|
|
rts
|
|
|
|
end
|
|
|
|
|
|
|
|
asm renderFrame
|
|
|
|
txa
|
|
|
|
pha
|
|
|
|
bit setROM
|
|
|
|
jsr $6003
|
|
|
|
pla
|
|
|
|
tax
|
2014-07-06 23:02:52 +00:00
|
|
|
dex ; don't-care return value
|
2014-07-06 21:40:35 +00:00
|
|
|
bit setLcRW+lcBank2
|
|
|
|
rts
|
2014-07-06 14:40:57 +00:00
|
|
|
end
|
2014-07-06 21:40:35 +00:00
|
|
|
|
2014-07-06 23:09:10 +00:00
|
|
|
asm isBlocked
|
|
|
|
txa
|
|
|
|
pha
|
|
|
|
bit setROM
|
|
|
|
jsr $6006
|
|
|
|
tay
|
|
|
|
pla
|
|
|
|
tax
|
|
|
|
dex
|
|
|
|
tya
|
|
|
|
sta evalStkL,x
|
|
|
|
lda #0
|
|
|
|
sta evalStkH,x
|
|
|
|
bit setLcRW+lcBank2
|
|
|
|
rts
|
|
|
|
end
|
|
|
|
|
2014-07-07 00:04:26 +00:00
|
|
|
asm setColor
|
|
|
|
txa
|
|
|
|
pha
|
|
|
|
bit setROM
|
|
|
|
lda evalStkL,x
|
|
|
|
ldy evalStkH,x
|
|
|
|
jsr $6009
|
|
|
|
bit setLcRW+lcBank2
|
|
|
|
pla
|
|
|
|
tax
|
|
|
|
rts
|
|
|
|
end
|
|
|
|
|
2014-07-06 21:40:35 +00:00
|
|
|
asm goMon
|
|
|
|
bit setROM
|
|
|
|
jmp $FF69
|
2014-07-03 23:56:26 +00:00
|
|
|
end
|
|
|
|
|
2014-07-19 20:54:41 +00:00
|
|
|
asm fatal
|
|
|
|
bit setROM
|
|
|
|
lda #'F'+$80
|
|
|
|
jsr cout
|
|
|
|
lda #'#'+$80
|
|
|
|
jsr cout
|
|
|
|
lda evalStkH,x
|
|
|
|
jsr prbyte
|
|
|
|
lda evalStkL,x
|
|
|
|
jsr prbyte
|
|
|
|
jsr crout
|
|
|
|
jmp $FF65
|
|
|
|
end
|
|
|
|
|
2014-07-09 02:11:03 +00:00
|
|
|
asm clearWindow
|
|
|
|
bit setROM
|
|
|
|
txa
|
|
|
|
pha
|
|
|
|
jsr clearWINDOW
|
|
|
|
bit setLcRW+lcBank2
|
|
|
|
pla
|
|
|
|
tax
|
|
|
|
dex ; don't-care return value
|
|
|
|
rts
|
|
|
|
end
|
|
|
|
|
2014-07-08 16:39:31 +00:00
|
|
|
; Display a string using the font engine
|
2014-07-09 02:11:03 +00:00
|
|
|
asm displayStr ; (str)
|
2014-07-08 16:39:31 +00:00
|
|
|
txa
|
|
|
|
pha
|
|
|
|
bit setROM
|
2014-07-09 02:11:03 +00:00
|
|
|
txa
|
2014-07-08 16:39:31 +00:00
|
|
|
ldy evalStkL,x
|
|
|
|
lda evalStkH,x
|
|
|
|
tax
|
|
|
|
jsr printSTR
|
|
|
|
bit setLcRW+lcBank2
|
|
|
|
pla
|
|
|
|
tax
|
|
|
|
rts
|
|
|
|
end
|
|
|
|
|
2014-07-06 23:45:27 +00:00
|
|
|
;==================================================================================================
|
|
|
|
; General methods
|
|
|
|
|
|
|
|
def initMap()
|
2014-07-15 16:52:58 +00:00
|
|
|
word scriptModule
|
2014-07-06 23:45:27 +00:00
|
|
|
|
|
|
|
; Reset memory (our module will stay since memory manager locked it upon load)
|
|
|
|
loader(RESET_MEMORY, MAIN_MEM, 0)
|
|
|
|
|
|
|
|
; Load the font engine
|
|
|
|
loader(SET_MEM_TARGET, MAIN_MEM, fontEngine)
|
|
|
|
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_FONT_ENGINE<<8 | RES_TYPE_CODE)
|
|
|
|
|
|
|
|
; Load the raycaster
|
|
|
|
loader(SET_MEM_TARGET, MAIN_MEM, raycaster)
|
|
|
|
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_RAYCASTER<<8 | RES_TYPE_CODE)
|
|
|
|
|
|
|
|
; Load the texture expansion code
|
|
|
|
loader(SET_MEM_TARGET, AUX_MEM, expandVec)
|
|
|
|
loader(QUEUE_LOAD, AUX_MEM, RES_NUM_EXPAND_VEC<<8 | RES_TYPE_CODE)
|
|
|
|
|
|
|
|
; Load the frame image (and lock it there)
|
|
|
|
loader(SET_MEM_TARGET, MAIN_MEM, $2000)
|
|
|
|
loader(QUEUE_LOAD, MAIN_MEM, 1<<8 | RES_TYPE_SCREEN)
|
|
|
|
loader(LOCK_MEMORY, MAIN_MEM, $2000)
|
|
|
|
|
|
|
|
; Load the font for the font engine
|
|
|
|
pFont = loader(QUEUE_LOAD, MAIN_MEM, 1<<8 | RES_TYPE_FONT)
|
|
|
|
|
|
|
|
; Load the map
|
|
|
|
pMap = loader(QUEUE_LOAD, MAIN_MEM, mapNum<<8 | RES_TYPE_3D_MAP)
|
|
|
|
|
|
|
|
; Load everything that we just queued
|
|
|
|
loader(FINISH_LOAD, MAIN_MEM, 1) ; 1 = keep open
|
|
|
|
|
2014-07-15 16:52:58 +00:00
|
|
|
; Load the scripts for this map, if it has any.
|
|
|
|
scriptModule = pMap->2 ; first 2 bytes are width and height, third byte is script module num
|
|
|
|
if scriptModule
|
|
|
|
pScripts = loader(QUEUE_LOAD, MAIN_MEM, (scriptModule << 8) | RES_TYPE_MODULE)
|
|
|
|
loader(FINISH_LOAD, MAIN_MEM, 1) ; 1 = keep open
|
2014-07-19 20:54:41 +00:00
|
|
|
nLocTrig = 0
|
2014-07-15 16:52:58 +00:00
|
|
|
*pScripts()
|
|
|
|
fin
|
2014-07-09 02:11:03 +00:00
|
|
|
|
2014-07-06 23:45:27 +00:00
|
|
|
; Start up the font engine
|
|
|
|
initFontEngine(pFont)
|
|
|
|
|
|
|
|
; Start up the raycaster
|
|
|
|
initRaycaster(pMap)
|
|
|
|
|
|
|
|
; Set initial player position
|
|
|
|
^playerDir = 1
|
|
|
|
*playerX = $280
|
|
|
|
*playerY = $380
|
|
|
|
|
2014-07-09 02:11:03 +00:00
|
|
|
; Initialize the map scripts
|
|
|
|
setWindow2()
|
|
|
|
prevX = -1
|
|
|
|
prevY = -1
|
|
|
|
|
2014-07-06 23:45:27 +00:00
|
|
|
; Draw the first frame
|
|
|
|
renderFrame()
|
|
|
|
end
|
|
|
|
|
2014-07-08 16:39:31 +00:00
|
|
|
; Window for the map name bar
|
|
|
|
def setWindow1()
|
|
|
|
^wndtop = 1
|
|
|
|
^wndbtm = 2
|
|
|
|
^wndleft = 4
|
|
|
|
^wndwdth = 18
|
|
|
|
^cursv = ^wndtop
|
|
|
|
^cursh = ^wndleft
|
|
|
|
end
|
|
|
|
|
|
|
|
; Window for the large upper right bar
|
|
|
|
def setWindow2()
|
|
|
|
^wndtop = 3
|
|
|
|
^wndbtm = 17
|
|
|
|
^wndleft = 23
|
|
|
|
^wndwdth = 37
|
|
|
|
^cursv = ^wndtop
|
|
|
|
^cursh = ^wndleft
|
|
|
|
end
|
|
|
|
|
|
|
|
; Window for the mid-size lower right bar
|
|
|
|
def setWindow3()
|
|
|
|
^wndtop = 18
|
|
|
|
^wndbtm = 23
|
|
|
|
^wndleft = 23
|
|
|
|
^wndwdth = 37
|
|
|
|
^cursv = ^wndtop
|
|
|
|
^cursh = ^wndleft
|
|
|
|
end
|
|
|
|
|
2014-07-06 23:02:52 +00:00
|
|
|
;==================================================================================================
|
|
|
|
; Actions
|
|
|
|
def initCmd(key, func)
|
|
|
|
if key >= $60
|
|
|
|
key = key - $20
|
|
|
|
fin
|
|
|
|
cmdTbl[key-$20] = func
|
|
|
|
end
|
|
|
|
|
2014-07-09 02:11:03 +00:00
|
|
|
def checkScript()
|
|
|
|
word x
|
|
|
|
word y
|
|
|
|
word i
|
|
|
|
word func
|
|
|
|
x = playerX.1 - 1
|
|
|
|
y = playerY.1 - 1
|
|
|
|
if x <> prevX or y <> prevY
|
|
|
|
prevX = x
|
|
|
|
prevY = y
|
|
|
|
clearWindow()
|
|
|
|
for i = 0 to nLocTrig-1
|
|
|
|
if x == locTrig_x[i] and y == locTrig_y[i]
|
|
|
|
func = locTrig_func[i]
|
|
|
|
*func()
|
|
|
|
fin
|
|
|
|
next
|
|
|
|
fin
|
|
|
|
end
|
|
|
|
|
2014-07-06 23:02:52 +00:00
|
|
|
def moveForward()
|
2014-07-07 01:22:31 +00:00
|
|
|
word wasBlocked
|
2014-07-09 02:11:03 +00:00
|
|
|
word func
|
2014-07-07 01:22:31 +00:00
|
|
|
wasBlocked = isBlocked()
|
2014-07-06 23:02:52 +00:00
|
|
|
*playerX = *playerX + walkDirs[^playerDir * 2]
|
|
|
|
*playerY = *playerY + walkDirs[^playerDir * 2 + 1]
|
2014-07-07 01:22:31 +00:00
|
|
|
if !wasBlocked and isBlocked()
|
2014-07-06 23:09:10 +00:00
|
|
|
moveBackward()
|
2014-07-09 02:11:03 +00:00
|
|
|
else
|
|
|
|
checkScript()
|
2014-07-06 23:09:10 +00:00
|
|
|
fin
|
|
|
|
end
|
|
|
|
|
|
|
|
def adjustDir(n)
|
|
|
|
^playerDir = (^playerDir + n) & $F
|
2014-07-06 23:02:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def moveBackward()
|
2014-07-07 01:22:31 +00:00
|
|
|
word wasBlocked
|
|
|
|
wasBlocked = isBlocked()
|
2014-07-06 23:09:10 +00:00
|
|
|
adjustDir(8)
|
2014-07-06 23:02:52 +00:00
|
|
|
moveForward()
|
2014-07-06 23:09:10 +00:00
|
|
|
adjustDir(8)
|
2014-07-07 01:22:31 +00:00
|
|
|
if !wasBlocked and isBlocked()
|
2014-07-06 23:09:10 +00:00
|
|
|
moveForward()
|
|
|
|
fin
|
2014-07-06 23:02:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def rotateLeft()
|
2014-07-06 23:09:10 +00:00
|
|
|
adjustDir(-1)
|
2014-07-06 23:02:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def rotateRight()
|
2014-07-06 23:09:10 +00:00
|
|
|
adjustDir(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
def strafeRight()
|
|
|
|
adjustDir(4)
|
|
|
|
moveForward()
|
|
|
|
adjustDir(-4)
|
|
|
|
end
|
|
|
|
|
|
|
|
def strafeLeft()
|
|
|
|
adjustDir(-4)
|
|
|
|
moveForward()
|
|
|
|
adjustDir(4)
|
2014-07-06 23:02:52 +00:00
|
|
|
end
|
|
|
|
|
2014-07-06 23:45:27 +00:00
|
|
|
def flipToFirstPage
|
|
|
|
if ^frontBuf == 1
|
|
|
|
renderFrame()
|
|
|
|
fin
|
|
|
|
end
|
|
|
|
|
|
|
|
def nextMap()
|
|
|
|
flipToFirstPage()
|
|
|
|
mapNum = mapNum + 1
|
2014-07-19 20:54:41 +00:00
|
|
|
if mapNum > 8
|
2014-07-06 23:45:27 +00:00
|
|
|
mapNum = 1
|
|
|
|
fin
|
|
|
|
initMap()
|
|
|
|
end
|
|
|
|
|
2014-07-07 00:04:26 +00:00
|
|
|
def nextSky()
|
|
|
|
skyNum = (skyNum + 1) & $F
|
|
|
|
setColor(0<<8 | skyGndTbl1[skyNum])
|
|
|
|
setColor(1<<8 | skyGndTbl2[skyNum])
|
|
|
|
end
|
|
|
|
|
|
|
|
def nextGround()
|
|
|
|
groundNum = (groundNum + 1) & $F
|
|
|
|
setColor(2<<8 | skyGndTbl1[groundNum])
|
|
|
|
setColor(3<<8 | skyGndTbl2[groundNum])
|
|
|
|
end
|
|
|
|
|
2014-07-06 23:02:52 +00:00
|
|
|
def kbdLoop()
|
|
|
|
word key, func
|
|
|
|
while TRUE
|
|
|
|
if ^keyboard >= 128
|
|
|
|
key = ^keyboard & $7F
|
|
|
|
^keystrobe
|
|
|
|
key = key - $20
|
|
|
|
if key >= $40
|
|
|
|
key = key - $20
|
|
|
|
fin
|
|
|
|
if key >= 0 and key < $40
|
|
|
|
func = cmdTbl[key]
|
|
|
|
if func
|
|
|
|
func()
|
|
|
|
renderFrame()
|
|
|
|
fin
|
|
|
|
fin
|
|
|
|
fin
|
|
|
|
loop
|
|
|
|
end
|
|
|
|
|
2014-07-09 02:11:03 +00:00
|
|
|
def setLocationTrigger(x, y, func)
|
2014-07-19 20:54:41 +00:00
|
|
|
if nLocTrig == MAX_LOC_TRIG
|
|
|
|
fatal($101)
|
|
|
|
fin
|
2014-07-09 02:11:03 +00:00
|
|
|
locTrig_x[nLocTrig] = x
|
|
|
|
locTrig_y[nLocTrig] = y
|
|
|
|
locTrig_func[nLocTrig] = func
|
|
|
|
nLocTrig = nLocTrig + 1
|
2014-07-08 23:02:10 +00:00
|
|
|
end
|
|
|
|
|
2014-07-06 21:40:35 +00:00
|
|
|
;==================================================================================================
|
2014-07-06 23:45:27 +00:00
|
|
|
; Main code.
|
2014-07-06 21:40:35 +00:00
|
|
|
;
|
|
|
|
puts(@helloStr)
|
|
|
|
|
2014-07-06 23:02:52 +00:00
|
|
|
; Init the command table
|
|
|
|
initCmd('W', @moveForward)
|
|
|
|
initCmd('A', @rotateLeft)
|
|
|
|
initCmd('D', @rotateRight)
|
|
|
|
initCmd('S', @moveBackward)
|
2014-07-06 23:09:10 +00:00
|
|
|
initCmd('X', @moveBackward)
|
|
|
|
initCmd('Z', @strafeLeft)
|
|
|
|
initCmd('C', @strafeRight)
|
2014-07-06 23:02:52 +00:00
|
|
|
|
|
|
|
initCmd('I', @moveForward)
|
|
|
|
initCmd('J', @rotateLeft)
|
|
|
|
initCmd('L', @rotateRight)
|
|
|
|
initCmd('K', @moveBackward)
|
2014-07-06 23:09:10 +00:00
|
|
|
initCmd(',', @moveBackward)
|
|
|
|
initCmd('M', @strafeLeft)
|
|
|
|
initCmd('.', @strafeRight)
|
2014-07-06 23:02:52 +00:00
|
|
|
|
2014-07-06 23:45:27 +00:00
|
|
|
initCmd('N', @nextMap)
|
|
|
|
|
2014-07-07 00:04:26 +00:00
|
|
|
initCmd('Y', @nextSky)
|
|
|
|
initCmd('G', @nextGround)
|
|
|
|
|
2014-07-09 02:11:03 +00:00
|
|
|
callbacks.0 = $4c
|
|
|
|
callbacks:1 = @setLocationTrigger
|
|
|
|
callbacks.3 = $4c
|
|
|
|
callbacks:4 = @displayStr
|
|
|
|
|
2014-07-06 23:45:27 +00:00
|
|
|
initMap()
|
2014-07-06 21:40:35 +00:00
|
|
|
|
2014-07-08 16:39:31 +00:00
|
|
|
setWindow2()
|
|
|
|
|
2014-07-06 23:02:52 +00:00
|
|
|
; Main keyboard loop
|
|
|
|
puts(@loopStr)
|
|
|
|
kbdLoop()
|
|
|
|
|
2014-06-25 15:47:28 +00:00
|
|
|
done
|