mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-04-01 07:33:09 +00:00
Converting main loop to PLASMA.
This commit is contained in:
parent
0950b9357e
commit
a399d81478
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,4 +23,5 @@
|
||||
*.a
|
||||
/Platform/Apple/tools/PLASMA/src/plasm
|
||||
/Platform/Apple/tools/PLASMA/src/plvm
|
||||
/Platform/Apple/tools/PLASMA/src/PLVM02.SYSTEM.sys
|
||||
/Platform/Apple/tools/PLASMA/src/*#*
|
||||
|
@ -2,7 +2,7 @@
|
||||
AFLAGS = -o $@
|
||||
LFLAGS = -C default.cfg
|
||||
PLVM = plvm
|
||||
PLVM02 = PLASMA.SYSTEM\#FF2000
|
||||
PLVM02 = PLVM02.SYSTEM.sys#2000
|
||||
CMD = CMD\#FF2000
|
||||
PLASM = plasm
|
||||
INCS = tokens.h symbols.h lex.h parse.h codegen.h
|
||||
|
@ -7,6 +7,7 @@
|
||||
<property name="build.dir" value="./build"/>
|
||||
<property name="a2copy.dir" value="../tools/A2Copy/dist"/>
|
||||
<property name="pack.dir" value="../tools/PackPartitions/dist"/>
|
||||
<property name="plasma.dir" location="../tools/PLASMA/src"/>
|
||||
|
||||
<property name="IMG_FILE" value="${build.dir}/${projName}.bin#${ORG_ADDR}"/>
|
||||
|
||||
@ -49,7 +50,7 @@
|
||||
<delete failonerror="false" dir="${build.dir}/root"/>
|
||||
<mkdir dir="${build.dir}/root"/>
|
||||
<copy todir="${build.dir}/root">
|
||||
<fileset dir="${src.dir}/plasma/build" includes="*.sys*"/>
|
||||
<fileset dir="${plasma.dir}" includes="PLVM02.SYSTEM*"/>
|
||||
<fileset dir="${src.dir}/core/build" includes="*.sys*"/>
|
||||
<fileset dir="./build" includes="game.part*.bin"/>
|
||||
</copy>
|
||||
|
@ -12,6 +12,7 @@
|
||||
; Global definitions
|
||||
!source "../include/global.i"
|
||||
!source "../include/mem.i"
|
||||
!source "../include/plasma.i"
|
||||
|
||||
; Constants
|
||||
MAX_SEGS = 96
|
||||
@ -394,7 +395,7 @@ init: !zone
|
||||
; 6: main $6000 -> 3, inactive
|
||||
; 7: main $BF00 -> 0, active + locked
|
||||
; First, the flags
|
||||
lda #$C0 ; flags for active + locked (with no resource)
|
||||
lda #$C0 ; flags for active + locked (with no resource)
|
||||
sta tSegType+0
|
||||
sta tSegType+1
|
||||
sta tSegType+3
|
||||
@ -430,30 +431,40 @@ init: !zone
|
||||
sta tSegAdrHi+6
|
||||
; Finally, form a long list of the remaining unused segments.
|
||||
ldx #8
|
||||
stx unusedSeg ; that's the first unused seg
|
||||
stx unusedSeg ; that's the first unused seg
|
||||
ldy #9
|
||||
.loop: tya
|
||||
sta tSegLink,x
|
||||
inx
|
||||
iny
|
||||
cpy #MAX_SEGS ; did all segments yet?
|
||||
bne .loop ; no, loop again
|
||||
; Load code resource #1 at $6000
|
||||
cpy #MAX_SEGS ; did all segments yet?
|
||||
bne .loop ; no, loop again
|
||||
; Allocate space for the PLASMA frame stack
|
||||
ldx #0
|
||||
ldy #2 ; 2 pages
|
||||
lda #REQUEST_MEMORY
|
||||
jsr mainLoader
|
||||
stx framePtr
|
||||
iny ; twice for 2 pages: initial pointer at top of new space
|
||||
iny
|
||||
sty framePtr+1
|
||||
; Load PLASMA module #1
|
||||
ldx #0
|
||||
lda #START_LOAD
|
||||
jsr mainLoader
|
||||
ldx #0
|
||||
ldy #$60
|
||||
lda #SET_MEM_TARGET
|
||||
jsr mainLoader
|
||||
ldx #RES_TYPE_CODE
|
||||
ldx #RES_TYPE_MODULE
|
||||
ldy #1
|
||||
lda #QUEUE_LOAD
|
||||
jsr mainLoader
|
||||
ldx #1 ; keep open for efficiency's sake
|
||||
stx .gomod+1
|
||||
sty .gomod+2
|
||||
lda #LOCK_MEMORY ; lock it in forever
|
||||
jsr mainLoader
|
||||
ldx #1 ; keep open for efficiency's sake
|
||||
lda #FINISH_LOAD
|
||||
jsr mainLoader
|
||||
jmp $6000 ; jump to the loaded code for futher bootstrapping
|
||||
ldx #$10 ; initial eval stack index
|
||||
.gomod: jmp $1111 ; jump to module for further bootstrapping
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
!if DEBUG {
|
||||
@ -710,6 +721,26 @@ invalAddr: !zone
|
||||
jmp fatalError
|
||||
+ !text "Invalid addr", 0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; If the resource is a module, this will locate the corresponding bytecode
|
||||
; in aux mem.
|
||||
; Returns the segment found in X, or 0 if n/a. Sets Z flag appropriately.
|
||||
shared_byteCodeAlso:
|
||||
lda resType
|
||||
cmp #RES_TYPE_MODULE
|
||||
beq +
|
||||
lda #0
|
||||
rts
|
||||
+ lda #RES_TYPE_BYTECODE
|
||||
sta resType
|
||||
lda #1
|
||||
sta isAuxCmd
|
||||
jsr scanForResource
|
||||
bne +
|
||||
brk ; it better be present!
|
||||
+ lda tSegType,x
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
main_lock: !zone
|
||||
lda #0 ; index for main-mem request
|
||||
@ -720,7 +751,11 @@ shared_lock:
|
||||
jsr shared_scan ; scan for exact memory block
|
||||
ora #$40 ; set the 'locked' flag
|
||||
sta tSegType,x ; store flags back
|
||||
rts ; all done
|
||||
jsr shared_byteCodeAlso
|
||||
beq +
|
||||
ora #$40
|
||||
sta tSegType,x
|
||||
+ rts ; all done
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
main_unlock: !zone
|
||||
@ -732,7 +767,11 @@ shared_unlock:
|
||||
jsr shared_scan ; scan for exact memory block
|
||||
and #$BF ; mask off the 'locked' flag
|
||||
sta tSegType,x ; store flags back
|
||||
rts ; all done
|
||||
jsr shared_byteCodeAlso
|
||||
beq +
|
||||
and #$BF
|
||||
sta tSegType,x
|
||||
+ rts ; all done
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
main_free: !zone
|
||||
@ -1193,15 +1232,16 @@ disk_finishLoad: !zone
|
||||
.nFixups: !byte 0
|
||||
|
||||
!if DEBUG {
|
||||
.debug1:+prStr : !text "Going to load: type=",0
|
||||
.debug1:+prStr : !text "Loading: t=",0
|
||||
+prByte resType
|
||||
+prStr : !text "num=",0
|
||||
+prStr : !text "n=",0
|
||||
+prByte resNum
|
||||
+prStr : !text "isAux=",0
|
||||
+prStr : !text "aux=",0
|
||||
+prByte isAuxCmd
|
||||
rts
|
||||
.debug2:+prStr : !text "reqLen=",0
|
||||
.debug2:+prStr : !text "len=",0
|
||||
+prWord reqLen
|
||||
+prStr : !text "pDst=",0
|
||||
+prStr : !text "dst=",0
|
||||
+prWord pDst : +crout
|
||||
rts
|
||||
} ; end DEBUG
|
||||
@ -1260,11 +1300,6 @@ readToBuf: !zone
|
||||
ldx #0
|
||||
+ stx readLen
|
||||
sta readLen+1 ; save number of pages
|
||||
!if DEBUG {
|
||||
+prStr : !text "Read to buf, len=",0
|
||||
+prWord readLen
|
||||
+crout
|
||||
}
|
||||
jsr readToMain ; now read
|
||||
lda reqLen ; decrement reqLen by the amount we read
|
||||
sec
|
||||
|
@ -4,7 +4,7 @@
|
||||
; (c) 2013, Brutal Deluxe Software
|
||||
;
|
||||
|
||||
* = $1b00 ; so it ends just before $2000
|
||||
* = $BA00 ; so it ends just before $BF00
|
||||
|
||||
!source "equates.i"
|
||||
|
||||
|
@ -38,7 +38,7 @@ cursv = cursh+1 ; Cursor V-pos 0-23 => 0-191
|
||||
|
||||
;---------------------------
|
||||
|
||||
fontEngine = $1B00
|
||||
fontEngine = $BA00
|
||||
printSTR = fontEngine
|
||||
printSSTR = printSTR+3
|
||||
printCSTR = printSSTR+3
|
||||
|
@ -74,23 +74,29 @@ setHires = $C057
|
||||
opnApple = $C061
|
||||
clsApple = $C062
|
||||
|
||||
; ROM routines
|
||||
prntax = $F941
|
||||
textinit= $FB2F
|
||||
home = $FC58
|
||||
rdkey = $FD0C
|
||||
getln1 = $FD6F
|
||||
crout = $FD8E
|
||||
prbyte = $FDDA
|
||||
cout = $FDED
|
||||
setnorm = $FE84
|
||||
setkbd = $FE89
|
||||
setvid = $FE93
|
||||
prerr = $FF2D
|
||||
bell = $FF3A
|
||||
iosave = $FF4A
|
||||
iorest = $FF3F
|
||||
monrts = $FF58
|
||||
monitor = $FF69
|
||||
getnum = $FFA7
|
||||
setLcRd = $C080
|
||||
setLcWr = $C081
|
||||
setROM = $C082
|
||||
setLcRW = $C083
|
||||
lcBank2 = 0
|
||||
lcBank1 = 8
|
||||
|
||||
; ROM routines
|
||||
prntax = $F941
|
||||
textinit = $FB2F
|
||||
home = $FC58
|
||||
rdkey = $FD0C
|
||||
getln1 = $FD6F
|
||||
crout = $FD8E
|
||||
prbyte = $FDDA
|
||||
cout = $FDED
|
||||
setnorm = $FE84
|
||||
setkbd = $FE89
|
||||
setvid = $FE93
|
||||
prerr = $FF2D
|
||||
bell = $FF3A
|
||||
iosave = $FF4A
|
||||
iorest = $FF3F
|
||||
monrts = $FF58
|
||||
monitor = $FF69
|
||||
getnum = $FFA7
|
||||
|
4
Platform/Apple/virtual/src/include/plasma.i
Normal file
4
Platform/Apple/virtual/src/include/plasma.i
Normal file
@ -0,0 +1,4 @@
|
||||
; Zero-page
|
||||
evalStkL = $C0
|
||||
evalStkH = $D0
|
||||
framePtr = $E0
|
@ -3,98 +3,246 @@
|
||||
const FALSE = 0
|
||||
const TRUE = !FALSE
|
||||
|
||||
;==================================================================================================
|
||||
; 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
|
||||
|
||||
;==================================================================================================
|
||||
; Hardware addresses.
|
||||
const keyboard = $C000
|
||||
const keystrobe = $C010
|
||||
const ptr = $6000
|
||||
const f1 = 0
|
||||
const f2 = 2
|
||||
|
||||
;==================================================================================================
|
||||
; 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
|
||||
|
||||
;==================================================================================================
|
||||
; Strings.
|
||||
byte hellostr[] = "Hello, world.\n"
|
||||
byte str2[] = "Second.\n"
|
||||
byte helloStr[] = "Loading Lawless Legends.\n"
|
||||
byte initFontStr[] = "Initting font engine.\n"
|
||||
byte initRaycastStr[] = "Initting raycaster.\n"
|
||||
byte renderFrameStr[] = "Rendering frame.\n"
|
||||
|
||||
predef func1, func2
|
||||
word myclass
|
||||
word table = @func1, @func2
|
||||
;==================================================================================================
|
||||
; Global variables
|
||||
word mapNum = 1
|
||||
word pFont
|
||||
word pMap
|
||||
|
||||
;==================================================================================================
|
||||
; Definitions used by assembly code
|
||||
asm __defs
|
||||
; Zero-page
|
||||
TMPL = $6
|
||||
TMPH = $7
|
||||
ESTKL = $C0
|
||||
ESTKH = $D0
|
||||
; Memory bank manipulation
|
||||
LCRDEN = $C080
|
||||
LCWTEN = $C081
|
||||
ROMEN = $C082
|
||||
LCRWEN = $C083
|
||||
LCBNK2 = $00
|
||||
LCBNK1 = $08
|
||||
; ROM routines
|
||||
PRBYTE = $FDDA
|
||||
COUT = $FDED
|
||||
!source "../../include/global.i"
|
||||
!source "../../include/plasma.i"
|
||||
!source "../../include/mem.i"
|
||||
!source "../../include/fontEngine.i"
|
||||
tmp = $2
|
||||
pTmp = $4
|
||||
end
|
||||
|
||||
;==================================================================================================
|
||||
; Print a string
|
||||
asm puts
|
||||
TXA
|
||||
PHA
|
||||
LDA ESTKL,X
|
||||
STA TMPL
|
||||
LDA ESTKH,X
|
||||
STA TMPH
|
||||
LDY #0
|
||||
LDA (TMPL),Y
|
||||
TAX
|
||||
INY
|
||||
BIT ROMEN
|
||||
- LDA (TMPL),Y
|
||||
ORA #$80
|
||||
JSR COUT
|
||||
INY
|
||||
DEX
|
||||
BNE -
|
||||
BIT LCRDEN+LCBNK2
|
||||
PLA
|
||||
TAX
|
||||
RTS
|
||||
txa
|
||||
pha
|
||||
lda evalStkL,x
|
||||
sta pTmp
|
||||
lda evalStkH,x
|
||||
sta pTmp+1
|
||||
ldy #0
|
||||
lda (pTmp),y
|
||||
tax
|
||||
iny
|
||||
bit setROM
|
||||
- lda (pTmp),y
|
||||
ora #$80
|
||||
jsr cout
|
||||
iny
|
||||
dex
|
||||
bne -
|
||||
bit setLcRW+lcBank2
|
||||
pla
|
||||
tax
|
||||
rts
|
||||
end
|
||||
|
||||
;==================================================================================================
|
||||
; Print a 16-bit hex value, followed by a space
|
||||
asm printHex
|
||||
BIT ROMEN
|
||||
LDA ESTKH,X
|
||||
JSR PRBYTE
|
||||
LDA ESTKL,X
|
||||
JSR PRBYTE
|
||||
LDA #$A0
|
||||
JSR COUT
|
||||
BIT LCRDEN+LCBNK2
|
||||
RTS
|
||||
bit setROM
|
||||
lda evalStkH,x
|
||||
jsr prbyte
|
||||
lda evalStkL,x
|
||||
jsr prbyte
|
||||
lda #$A0
|
||||
jsr cout
|
||||
bit setLcRW+lcBank2
|
||||
rts
|
||||
end
|
||||
|
||||
;==================================================================================================
|
||||
; 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
|
||||
inx ; drop second parameter
|
||||
lda tmp
|
||||
sta evalStkL,x
|
||||
tya
|
||||
sta evalStkH,x
|
||||
bit setLcRW+lcBank2
|
||||
rts
|
||||
end
|
||||
|
||||
asm initFontEngine
|
||||
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
|
||||
|
||||
asm initRaycaster
|
||||
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
|
||||
bit setLcRW+lcBank2
|
||||
rts
|
||||
end
|
||||
|
||||
asm goMon
|
||||
bit setROM
|
||||
jmp $FF69
|
||||
end
|
||||
|
||||
;==================================================================================================
|
||||
; Main loop.
|
||||
;
|
||||
def func1()
|
||||
printHex(1)
|
||||
end
|
||||
def func2()
|
||||
printHex(2)
|
||||
end
|
||||
puts(@helloStr)
|
||||
|
||||
myclass = @table
|
||||
table.f2()
|
||||
;(myclass).f2()
|
||||
((myclass):f2)()
|
||||
puts(@hellostr)
|
||||
func1(@hellostr)
|
||||
; 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
|
||||
loader(SET_MEM_TARGET, MAIN_MEM, $2000)
|
||||
loader(QUEUE_LOAD, MAIN_MEM, 1<<8 | RES_TYPE_SCREEN)
|
||||
|
||||
; 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
|
||||
|
||||
; Start up the font engine
|
||||
puts(@initFontStr)
|
||||
initFontEngine(pFont)
|
||||
|
||||
; Start up the raycaster
|
||||
puts(@initRaycastStr)
|
||||
initRaycaster(pMap)
|
||||
|
||||
; And draw the frame
|
||||
puts(@renderFrameStr)
|
||||
renderFrame()
|
||||
|
||||
; For now, just get out
|
||||
goMon()
|
||||
|
||||
done
|
@ -89,20 +89,20 @@ expandVec = $800
|
||||
;---------------------------------
|
||||
|
||||
; Main-mem tables and buffers
|
||||
tableStart = $A700
|
||||
decodeTo01 = $A700
|
||||
decodeTo01b = $A800
|
||||
decodeTo23 = $A900
|
||||
decodeTo23b = $AA00
|
||||
decodeTo45 = $AB00
|
||||
decodeTo56 = $AC00
|
||||
decodeTo57 = $AD00
|
||||
clrBlitRollE = $AE00 ; size 3*(128/2) = $C0, plus 2 for tya and rts
|
||||
clrBlitRollO = $AEC2 ; size 3*(128/2) = $C0, plus 2 for tya and rts
|
||||
texAddrLo = $AF84
|
||||
tableStart = $A200
|
||||
decodeTo01 = tableStart+$0000
|
||||
decodeTo01b = tableStart+$0100
|
||||
decodeTo23 = tableStart+$0200
|
||||
decodeTo23b = tableStart+$0300
|
||||
decodeTo45 = tableStart+$0400
|
||||
decodeTo56 = tableStart+$0500
|
||||
decodeTo57 = tableStart+$0600
|
||||
clrBlitRollE = tableStart+$0700 ; size 3*(128/2) = $C0, plus 2 for tya and rts
|
||||
clrBlitRollO = tableStart+$07C2 ; size 3*(128/2) = $C0, plus 2 for tya and rts
|
||||
texAddrLo = tableStart+$0884
|
||||
texAddrHi = texAddrLo + MAX_TEXTURES
|
||||
blitRoll = $B000 ; Unrolled blitting code. Size 29*128 = $E80, plus 1 for rts
|
||||
tableEnd = $BE81
|
||||
blitRoll = tableStart+$0900 ; Unrolled blitting code. Size 29*128 = $E80, plus 1 for rts
|
||||
tableEnd = tableStart+$01781
|
||||
|
||||
; mipmap level offsets
|
||||
MIP_OFFSET_0 = 0
|
||||
|
@ -9,7 +9,8 @@ start:
|
||||
; This code is written bottom-up. That is, simple routines first,
|
||||
; then routines that call those to build complexity. The main
|
||||
; code is at the very end. We jump to it now.
|
||||
jmp main
|
||||
jmp initMap
|
||||
jmp renderFrame
|
||||
|
||||
; Conditional assembly flags
|
||||
DOUBLE_BUFFER = 1 ; whether to double-buffer
|
||||
@ -1549,111 +1550,6 @@ setBackBuf: !zone
|
||||
sta clrAuxZP
|
||||
rts
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
initMem: !zone
|
||||
!if DEBUG { +prStr : !text "Raycast: setting up memory.",0 }
|
||||
lda #LOCK_MEMORY ; lock ourselves in before reset
|
||||
ldx #<start
|
||||
ldy #>start
|
||||
jsr mainLoader
|
||||
lda #RESET_MEMORY ; clear everything else
|
||||
jsr mainLoader
|
||||
; Reserve memory for our tables
|
||||
lda #SET_MEM_TARGET
|
||||
ldx #<tableStart
|
||||
ldy #>tableStart
|
||||
jsr mainLoader
|
||||
lda #REQUEST_MEMORY
|
||||
ldx #<(tableEnd-tableStart)
|
||||
ldy #>(tableEnd-tableStart)
|
||||
jsr mainLoader
|
||||
; Reserve memory for the PLASMA frame stack
|
||||
lda #REQUEST_MEMORY
|
||||
ldx #0
|
||||
ldy #>PLASMA_FRAME_SIZE
|
||||
jsr mainLoader
|
||||
stx plasmaFrames
|
||||
sty plasmaFrames+1
|
||||
; Load the font engine
|
||||
!if DEBUG { +prStr : !text "Loading font engine.",0 }
|
||||
lda #SET_MEM_TARGET
|
||||
ldx #<fontEngine
|
||||
ldy #>fontEngine
|
||||
jsr mainLoader
|
||||
lda #QUEUE_LOAD
|
||||
ldx #RES_TYPE_CODE
|
||||
ldy #3 ; hard coded for now: code #3 is the font engine
|
||||
jsr mainLoader
|
||||
!if DEBUG { +prStr : !text "Loading expansion code.",0 }
|
||||
; Load the texture expansion code into aux mem.
|
||||
lda #SET_MEM_TARGET
|
||||
ldx #<expandVec
|
||||
ldy #>expandVec
|
||||
jsr mainLoader
|
||||
lda #QUEUE_LOAD ; we assume bootstrapper left the queue open
|
||||
ldx #RES_TYPE_CODE
|
||||
ldy #2 ; hard coded for now: code #2 is texture expander
|
||||
jsr auxLoader
|
||||
!if DEBUG { +prStr : !text "Loading frame.",0 }
|
||||
; Load the UI frame
|
||||
lda #SET_MEM_TARGET
|
||||
ldx #0
|
||||
ldy #$20
|
||||
jsr mainLoader
|
||||
lda #QUEUE_LOAD
|
||||
ldx #RES_TYPE_SCREEN
|
||||
ldy #1
|
||||
jsr mainLoader
|
||||
; Load the game loop module
|
||||
!if DEBUG { +prStr : !text "Loading game loop.",0 }
|
||||
lda #QUEUE_LOAD
|
||||
ldx #RES_TYPE_MODULE
|
||||
ldy #1 ; hard coded for now: module #1 is the game loop
|
||||
jsr mainLoader
|
||||
stx .callGameLoop+1
|
||||
sty .callGameLoop+2
|
||||
; Load the map into main mem
|
||||
!if DEBUG { +prStr : !text "Loading map.",0 }
|
||||
lda #QUEUE_LOAD
|
||||
ldx #RES_TYPE_3D_MAP
|
||||
ldy mapNum ; hard-coded for now
|
||||
jsr mainLoader
|
||||
stx mapHeader
|
||||
sty mapHeader+1
|
||||
; Load the font into main mem
|
||||
lda #QUEUE_LOAD
|
||||
ldx #RES_TYPE_FONT
|
||||
ldy #1 ; we have only one font, for now at least
|
||||
jsr mainLoader
|
||||
tya ; save location for when font engine has been loaded
|
||||
pha
|
||||
txa
|
||||
pha
|
||||
; Force the loads to complete now
|
||||
lda #FINISH_LOAD
|
||||
ldx #1 ; keep queue open
|
||||
jsr mainLoader
|
||||
|
||||
LDA #$00 ; INIT FRAME POINTER
|
||||
STA $E0
|
||||
LDA #$BF
|
||||
STA $E1
|
||||
LDX #$10 ; INIT EVAL STACK INDEX
|
||||
.callGameLoop:
|
||||
jsr $1111 ; self-modified with actual address
|
||||
bit $c081
|
||||
pla ; get back the font location
|
||||
tay ; font engine likes *lo* byte in Y
|
||||
pla
|
||||
tax ; and hi byte in X
|
||||
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
|
||||
jmp drawMODE
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
setExpansionCaller:
|
||||
; Copy the expansion caller to low stack.
|
||||
@ -1905,7 +1801,7 @@ renderFrame: !zone
|
||||
lda byteNum
|
||||
cmp #18
|
||||
bne .oneCol ; go back for another ray
|
||||
rts
|
||||
jmp flip ; flip it onto the screen
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Move the player forward a quarter step
|
||||
@ -2047,19 +1943,6 @@ readKbdColor: !zone
|
||||
sec
|
||||
rts
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
nextMap: !zone
|
||||
ldx mapNum
|
||||
inx
|
||||
cpx #6
|
||||
bne +
|
||||
ldx #1
|
||||
+ stx mapNum
|
||||
bit setText
|
||||
bit page1
|
||||
jmp main ; re-init everything
|
||||
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Set the window for the top (map name) bar
|
||||
set_window1: !zone
|
||||
@ -2107,12 +1990,10 @@ set_window3: !zone
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; The real action
|
||||
main: !zone
|
||||
; Put ourselves high on the stack
|
||||
ldx #$FF
|
||||
txs
|
||||
; Set up memory
|
||||
jsr initMem
|
||||
initMap: !zone
|
||||
; Record the address of the map
|
||||
sta mapHeader
|
||||
sty mapHeader+1
|
||||
jsr setPlayerPos
|
||||
jsr loadTextures
|
||||
jsr copyScreen
|
||||
@ -2143,26 +2024,6 @@ main: !zone
|
||||
ldy mapName ; now display the name itself
|
||||
ldx mapName+1
|
||||
jsr printCSTR
|
||||
; play text in the big window on the top right
|
||||
!if 0 {
|
||||
jsr set_window2
|
||||
jsr clearWINDOW
|
||||
jsr printSCSTR
|
||||
!raw "Loud music",13
|
||||
!raw "brings your at-"
|
||||
!raw "tention to the",13
|
||||
!raw "northwest where"
|
||||
!raw "patrons and",13
|
||||
!raw "'entertainers' "
|
||||
!raw "are enjoying",13
|
||||
!raw "themselves at",13
|
||||
!raw "the town's",13
|
||||
!raw "saloon. One",13
|
||||
!raw "sends you a",13
|
||||
!raw "wink. Perhaps",13
|
||||
!raw "it's your lucky"
|
||||
!raw "day?",0
|
||||
}
|
||||
; play characters in the little window on the bottom right
|
||||
jsr set_window3
|
||||
jsr clearWINDOW
|
||||
@ -2173,6 +2034,8 @@ main: !zone
|
||||
!raw "Cliff H. 10/36"
|
||||
!raw "Prospect 13/24"
|
||||
!byte 0
|
||||
rts
|
||||
|
||||
; Render the frame and flip it onto the screen
|
||||
.nextFrame:
|
||||
jsr renderFrame
|
||||
@ -2218,9 +2081,6 @@ main: !zone
|
||||
bne +
|
||||
jsr setSkyColor
|
||||
jmp .nextFrame
|
||||
+ cmp #'M' ; M to switch maps
|
||||
bne +
|
||||
jmp nextMap
|
||||
+ jsr bell ; beep for unrecognized key
|
||||
jmp .pauseLup ; go back and get another one.
|
||||
.done: ; back to text mode
|
||||
|
Loading…
x
Reference in New Issue
Block a user