Converting main loop to PLASMA.

This commit is contained in:
Martin Haye
2014-07-06 14:40:35 -07:00
parent 0950b9357e
commit a399d81478
11 changed files with 329 additions and 274 deletions

1
.gitignore vendored
View File

@@ -23,4 +23,5 @@
*.a *.a
/Platform/Apple/tools/PLASMA/src/plasm /Platform/Apple/tools/PLASMA/src/plasm
/Platform/Apple/tools/PLASMA/src/plvm /Platform/Apple/tools/PLASMA/src/plvm
/Platform/Apple/tools/PLASMA/src/PLVM02.SYSTEM.sys
/Platform/Apple/tools/PLASMA/src/*#* /Platform/Apple/tools/PLASMA/src/*#*

View File

@@ -2,7 +2,7 @@
AFLAGS = -o $@ AFLAGS = -o $@
LFLAGS = -C default.cfg LFLAGS = -C default.cfg
PLVM = plvm PLVM = plvm
PLVM02 = PLASMA.SYSTEM\#FF2000 PLVM02 = PLVM02.SYSTEM.sys#2000
CMD = CMD\#FF2000 CMD = CMD\#FF2000
PLASM = plasm PLASM = plasm
INCS = tokens.h symbols.h lex.h parse.h codegen.h INCS = tokens.h symbols.h lex.h parse.h codegen.h

View File

@@ -7,6 +7,7 @@
<property name="build.dir" value="./build"/> <property name="build.dir" value="./build"/>
<property name="a2copy.dir" value="../tools/A2Copy/dist"/> <property name="a2copy.dir" value="../tools/A2Copy/dist"/>
<property name="pack.dir" value="../tools/PackPartitions/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}"/> <property name="IMG_FILE" value="${build.dir}/${projName}.bin#${ORG_ADDR}"/>
@@ -49,7 +50,7 @@
<delete failonerror="false" dir="${build.dir}/root"/> <delete failonerror="false" dir="${build.dir}/root"/>
<mkdir dir="${build.dir}/root"/> <mkdir dir="${build.dir}/root"/>
<copy todir="${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="${src.dir}/core/build" includes="*.sys*"/>
<fileset dir="./build" includes="game.part*.bin"/> <fileset dir="./build" includes="game.part*.bin"/>
</copy> </copy>

View File

@@ -12,6 +12,7 @@
; Global definitions ; Global definitions
!source "../include/global.i" !source "../include/global.i"
!source "../include/mem.i" !source "../include/mem.i"
!source "../include/plasma.i"
; Constants ; Constants
MAX_SEGS = 96 MAX_SEGS = 96
@@ -394,7 +395,7 @@ init: !zone
; 6: main $6000 -> 3, inactive ; 6: main $6000 -> 3, inactive
; 7: main $BF00 -> 0, active + locked ; 7: main $BF00 -> 0, active + locked
; First, the flags ; 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+0
sta tSegType+1 sta tSegType+1
sta tSegType+3 sta tSegType+3
@@ -430,30 +431,40 @@ init: !zone
sta tSegAdrHi+6 sta tSegAdrHi+6
; Finally, form a long list of the remaining unused segments. ; Finally, form a long list of the remaining unused segments.
ldx #8 ldx #8
stx unusedSeg ; that's the first unused seg stx unusedSeg ; that's the first unused seg
ldy #9 ldy #9
.loop: tya .loop: tya
sta tSegLink,x sta tSegLink,x
inx inx
iny iny
cpy #MAX_SEGS ; did all segments yet? cpy #MAX_SEGS ; did all segments yet?
bne .loop ; no, loop again bne .loop ; no, loop again
; Load code resource #1 at $6000 ; 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 ldx #0
lda #START_LOAD lda #START_LOAD
jsr mainLoader jsr mainLoader
ldx #0 ldx #RES_TYPE_MODULE
ldy #$60
lda #SET_MEM_TARGET
jsr mainLoader
ldx #RES_TYPE_CODE
ldy #1 ldy #1
lda #QUEUE_LOAD lda #QUEUE_LOAD
jsr mainLoader 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 lda #FINISH_LOAD
jsr mainLoader 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 { !if DEBUG {
@@ -710,6 +721,26 @@ invalAddr: !zone
jmp fatalError jmp fatalError
+ !text "Invalid addr", 0 + !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 main_lock: !zone
lda #0 ; index for main-mem request lda #0 ; index for main-mem request
@@ -720,7 +751,11 @@ shared_lock:
jsr shared_scan ; scan for exact memory block jsr shared_scan ; scan for exact memory block
ora #$40 ; set the 'locked' flag ora #$40 ; set the 'locked' flag
sta tSegType,x ; store flags back sta tSegType,x ; store flags back
rts ; all done jsr shared_byteCodeAlso
beq +
ora #$40
sta tSegType,x
+ rts ; all done
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
main_unlock: !zone main_unlock: !zone
@@ -732,7 +767,11 @@ shared_unlock:
jsr shared_scan ; scan for exact memory block jsr shared_scan ; scan for exact memory block
and #$BF ; mask off the 'locked' flag and #$BF ; mask off the 'locked' flag
sta tSegType,x ; store flags back sta tSegType,x ; store flags back
rts ; all done jsr shared_byteCodeAlso
beq +
and #$BF
sta tSegType,x
+ rts ; all done
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
main_free: !zone main_free: !zone
@@ -1193,15 +1232,16 @@ disk_finishLoad: !zone
.nFixups: !byte 0 .nFixups: !byte 0
!if DEBUG { !if DEBUG {
.debug1:+prStr : !text "Going to load: type=",0 .debug1:+prStr : !text "Loading: t=",0
+prByte resType +prByte resType
+prStr : !text "num=",0 +prStr : !text "n=",0
+prByte resNum +prByte resNum
+prStr : !text "isAux=",0 +prStr : !text "aux=",0
+prByte isAuxCmd
rts rts
.debug2:+prStr : !text "reqLen=",0 .debug2:+prStr : !text "len=",0
+prWord reqLen +prWord reqLen
+prStr : !text "pDst=",0 +prStr : !text "dst=",0
+prWord pDst : +crout +prWord pDst : +crout
rts rts
} ; end DEBUG } ; end DEBUG
@@ -1260,11 +1300,6 @@ readToBuf: !zone
ldx #0 ldx #0
+ stx readLen + stx readLen
sta readLen+1 ; save number of pages sta readLen+1 ; save number of pages
!if DEBUG {
+prStr : !text "Read to buf, len=",0
+prWord readLen
+crout
}
jsr readToMain ; now read jsr readToMain ; now read
lda reqLen ; decrement reqLen by the amount we read lda reqLen ; decrement reqLen by the amount we read
sec sec

View File

@@ -4,7 +4,7 @@
; (c) 2013, Brutal Deluxe Software ; (c) 2013, Brutal Deluxe Software
; ;
* = $1b00 ; so it ends just before $2000 * = $BA00 ; so it ends just before $BF00
!source "equates.i" !source "equates.i"

View File

@@ -38,7 +38,7 @@ cursv = cursh+1 ; Cursor V-pos 0-23 => 0-191
;--------------------------- ;---------------------------
fontEngine = $1B00 fontEngine = $BA00
printSTR = fontEngine printSTR = fontEngine
printSSTR = printSTR+3 printSSTR = printSTR+3
printCSTR = printSSTR+3 printCSTR = printSSTR+3

View File

@@ -74,23 +74,29 @@ setHires = $C057
opnApple = $C061 opnApple = $C061
clsApple = $C062 clsApple = $C062
; ROM routines setLcRd = $C080
prntax = $F941 setLcWr = $C081
textinit= $FB2F setROM = $C082
home = $FC58 setLcRW = $C083
rdkey = $FD0C lcBank2 = 0
getln1 = $FD6F lcBank1 = 8
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
; 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

View File

@@ -0,0 +1,4 @@
; Zero-page
evalStkL = $C0
evalStkH = $D0
framePtr = $E0

View File

@@ -3,98 +3,246 @@
const FALSE = 0 const FALSE = 0
const TRUE = !FALSE 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. ; Hardware addresses.
const keyboard = $C000 const keyboard = $C000
const keystrobe = $C010 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. ; Strings.
byte hellostr[] = "Hello, world.\n" byte helloStr[] = "Loading Lawless Legends.\n"
byte str2[] = "Second.\n" byte initFontStr[] = "Initting font engine.\n"
byte initRaycastStr[] = "Initting raycaster.\n"
byte renderFrameStr[] = "Rendering frame.\n"
predef func1, func2 ;==================================================================================================
word myclass ; Global variables
word table = @func1, @func2 word mapNum = 1
word pFont
word pMap
;================================================================================================== ;==================================================================================================
; Definitions used by assembly code ; Definitions used by assembly code
asm __defs asm __defs
; Zero-page !source "../../include/global.i"
TMPL = $6 !source "../../include/plasma.i"
TMPH = $7 !source "../../include/mem.i"
ESTKL = $C0 !source "../../include/fontEngine.i"
ESTKH = $D0 tmp = $2
; Memory bank manipulation pTmp = $4
LCRDEN = $C080
LCWTEN = $C081
ROMEN = $C082
LCRWEN = $C083
LCBNK2 = $00
LCBNK1 = $08
; ROM routines
PRBYTE = $FDDA
COUT = $FDED
end end
;================================================================================================== ;==================================================================================================
; Print a string ; Print a string
asm puts asm puts
TXA txa
PHA pha
LDA ESTKL,X lda evalStkL,x
STA TMPL sta pTmp
LDA ESTKH,X lda evalStkH,x
STA TMPH sta pTmp+1
LDY #0 ldy #0
LDA (TMPL),Y lda (pTmp),y
TAX tax
INY iny
BIT ROMEN bit setROM
- LDA (TMPL),Y - lda (pTmp),y
ORA #$80 ora #$80
JSR COUT jsr cout
INY iny
DEX dex
BNE - bne -
BIT LCRDEN+LCBNK2 bit setLcRW+lcBank2
PLA pla
TAX tax
RTS rts
end end
;================================================================================================== ;==================================================================================================
; Print a 16-bit hex value, followed by a space ; Print a 16-bit hex value, followed by a space
asm printHex asm printHex
BIT ROMEN bit setROM
LDA ESTKH,X lda evalStkH,x
JSR PRBYTE jsr prbyte
LDA ESTKL,X lda evalStkL,x
JSR PRBYTE jsr prbyte
LDA #$A0 lda #$A0
JSR COUT jsr cout
BIT LCRDEN+LCBNK2 bit setLcRW+lcBank2
RTS 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 end
;================================================================================================== ;==================================================================================================
; Main loop. ; Main loop.
; ;
def func1() puts(@helloStr)
printHex(1)
end
def func2()
printHex(2)
end
myclass = @table ; Reset memory (our module will stay since memory manager locked it upon load)
table.f2() loader(RESET_MEMORY, MAIN_MEM, 0)
;(myclass).f2()
((myclass):f2)() ; Load the font engine
puts(@hellostr) loader(SET_MEM_TARGET, MAIN_MEM, fontEngine)
func1(@hellostr) 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 done

View File

@@ -89,20 +89,20 @@ expandVec = $800
;--------------------------------- ;---------------------------------
; Main-mem tables and buffers ; Main-mem tables and buffers
tableStart = $A700 tableStart = $A200
decodeTo01 = $A700 decodeTo01 = tableStart+$0000
decodeTo01b = $A800 decodeTo01b = tableStart+$0100
decodeTo23 = $A900 decodeTo23 = tableStart+$0200
decodeTo23b = $AA00 decodeTo23b = tableStart+$0300
decodeTo45 = $AB00 decodeTo45 = tableStart+$0400
decodeTo56 = $AC00 decodeTo56 = tableStart+$0500
decodeTo57 = $AD00 decodeTo57 = tableStart+$0600
clrBlitRollE = $AE00 ; size 3*(128/2) = $C0, plus 2 for tya and rts clrBlitRollE = tableStart+$0700 ; size 3*(128/2) = $C0, plus 2 for tya and rts
clrBlitRollO = $AEC2 ; 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 = $AF84 texAddrLo = tableStart+$0884
texAddrHi = texAddrLo + MAX_TEXTURES texAddrHi = texAddrLo + MAX_TEXTURES
blitRoll = $B000 ; Unrolled blitting code. Size 29*128 = $E80, plus 1 for rts blitRoll = tableStart+$0900 ; Unrolled blitting code. Size 29*128 = $E80, plus 1 for rts
tableEnd = $BE81 tableEnd = tableStart+$01781
; mipmap level offsets ; mipmap level offsets
MIP_OFFSET_0 = 0 MIP_OFFSET_0 = 0

View File

@@ -9,7 +9,8 @@ start:
; This code is written bottom-up. That is, simple routines first, ; This code is written bottom-up. That is, simple routines first,
; then routines that call those to build complexity. The main ; then routines that call those to build complexity. The main
; code is at the very end. We jump to it now. ; code is at the very end. We jump to it now.
jmp main jmp initMap
jmp renderFrame
; Conditional assembly flags ; Conditional assembly flags
DOUBLE_BUFFER = 1 ; whether to double-buffer DOUBLE_BUFFER = 1 ; whether to double-buffer
@@ -1549,111 +1550,6 @@ setBackBuf: !zone
sta clrAuxZP sta clrAuxZP
rts 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: setExpansionCaller:
; Copy the expansion caller to low stack. ; Copy the expansion caller to low stack.
@@ -1905,7 +1801,7 @@ renderFrame: !zone
lda byteNum lda byteNum
cmp #18 cmp #18
bne .oneCol ; go back for another ray bne .oneCol ; go back for another ray
rts jmp flip ; flip it onto the screen
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
; Move the player forward a quarter step ; Move the player forward a quarter step
@@ -2047,19 +1943,6 @@ readKbdColor: !zone
sec sec
rts 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 the window for the top (map name) bar
set_window1: !zone set_window1: !zone
@@ -2107,12 +1990,10 @@ set_window3: !zone
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
; The real action ; The real action
main: !zone initMap: !zone
; Put ourselves high on the stack ; Record the address of the map
ldx #$FF sta mapHeader
txs sty mapHeader+1
; Set up memory
jsr initMem
jsr setPlayerPos jsr setPlayerPos
jsr loadTextures jsr loadTextures
jsr copyScreen jsr copyScreen
@@ -2143,26 +2024,6 @@ main: !zone
ldy mapName ; now display the name itself ldy mapName ; now display the name itself
ldx mapName+1 ldx mapName+1
jsr printCSTR 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 ; play characters in the little window on the bottom right
jsr set_window3 jsr set_window3
jsr clearWINDOW jsr clearWINDOW
@@ -2173,6 +2034,8 @@ main: !zone
!raw "Cliff H. 10/36" !raw "Cliff H. 10/36"
!raw "Prospect 13/24" !raw "Prospect 13/24"
!byte 0 !byte 0
rts
; Render the frame and flip it onto the screen ; Render the frame and flip it onto the screen
.nextFrame: .nextFrame:
jsr renderFrame jsr renderFrame
@@ -2218,9 +2081,6 @@ main: !zone
bne + bne +
jsr setSkyColor jsr setSkyColor
jmp .nextFrame jmp .nextFrame
+ cmp #'M' ; M to switch maps
bne +
jmp nextMap
+ jsr bell ; beep for unrecognized key + jsr bell ; beep for unrecognized key
jmp .pauseLup ; go back and get another one. jmp .pauseLup ; go back and get another one.
.done: ; back to text mode .done: ; back to text mode