Now loading the initial 4 map sections in the tile engine.

This commit is contained in:
Martin Haye 2015-01-10 13:17:56 -08:00
parent 4e4892381f
commit 09583ce1ce
3 changed files with 289 additions and 69 deletions

View File

@ -420,6 +420,7 @@ class PackPartitions
def buf = ByteBuffer.allocate(512) def buf = ByteBuffer.allocate(512)
buffers[vsect][hsect] = buf buffers[vsect][hsect] = buf
def num = maps2D.size() + 1 def num = maps2D.size() + 1
sectionNums[vsect][hsect] = num
def sectName = "$mapName-$hsect-$vsect" def sectName = "$mapName-$hsect-$vsect"
maps2D[sectName] = [num:num, buf:buf] maps2D[sectName] = [num:num, buf:buf]
} }
@ -431,9 +432,9 @@ class PackPartitions
// Header: first come links to other map sections - north, east, south, west // Header: first come links to other map sections - north, east, south, west
def buf = buffers[vsect][hsect] def buf = buffers[vsect][hsect]
buf.put((byte) (vsect > 0) ? sectionNums[vsect-1][hsect] : 0xFF) // north buf.put((byte) (vsect > 0) ? sectionNums[vsect-1][hsect] : 0xFF) // north
buf.put((byte) (hsect > 0) ? sectionNums[vsect][hsect-1] : 0xFF) // east buf.put((byte) (hsect < nHorzSections-1) ? sectionNums[vsect][hsect+1] : 0xFF) // east
buf.put((byte) (vsect < nVertSections-1) ? sectionNums[vsect+1][hsect] : 0xFF) // south buf.put((byte) (vsect < nVertSections-1) ? sectionNums[vsect+1][hsect] : 0xFF) // south
buf.put((byte) (hsect > 0) ? sectionNums[vsect-1][hsect] : 0xFF) // west buf.put((byte) (hsect > 0) ? sectionNums[vsect][hsect-1] : 0xFF) // west
// Then links to the tile set and script library // Then links to the tile set and script library
buf.put((byte) tileSetNum) buf.put((byte) tileSetNum)

View File

@ -7,6 +7,7 @@ const NULL = 0
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Fixed memory locations // Fixed memory locations
const raycaster = $6000 // main mem const raycaster = $6000 // main mem
const tileEngine = $6000 // main mem
const expandVec = $2000 // aux mem const expandVec = $2000 // aux mem
const fontEngine = $BA00 // main mem const fontEngine = $BA00 // main mem
@ -15,6 +16,7 @@ const fontEngine = $BA00 // main mem
const RES_NUM_RAYCASTER = 1 const RES_NUM_RAYCASTER = 1
const RES_NUM_EXPAND_VEC = 2 const RES_NUM_EXPAND_VEC = 2
const RES_NUM_FONT_ENGINE = 3 const RES_NUM_FONT_ENGINE = 3
const RES_NUM_TILE_ENGINE = 4
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Hardware addresses. // Hardware addresses.
@ -58,14 +60,18 @@ const FATAL_ERROR = $1F
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Other constants // Other constants
const callbacks = $300 const callbacks = $300
const MAP_FLAG_3D = $4000
const OVERMAP_NUM = 11
const OVERMAP_IS_3D = 1
const MAX_LOC_TRIG = 128 const MAX_LOC_TRIG = 128
// 3D mode
//const OVERMAP_NUM = 11
//const OVERMAP_IS_3D = 1
// 2D mode
const OVERMAP_NUM = 1
const OVERMAP_IS_3D = 0
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Predefined functions, for circular calls // Predefined functions, for circular calls or out-of-order calls
predef moveBackward, setWindow2 predef moveBackward, setWindow2, initCmds2D, initCmds3D
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Raycaster variables // Raycaster variables
@ -219,6 +225,8 @@ asm printHex
rts rts
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Print a carriage return
asm crout asm crout
bit setROM bit setROM
jsr crout jsr crout
@ -227,6 +235,8 @@ asm crout
rts rts
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Ring the bell
asm beep asm beep
bit setROM bit setROM
jsr bell jsr bell
@ -236,7 +246,7 @@ asm beep
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Work with the memory manager // Send a command to the memory manager
// Params: cmd, mainOrAux, amount // Params: cmd, mainOrAux, amount
asm loader asm loader
txa txa
@ -307,10 +317,25 @@ asm initRaycaster
rts rts
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set up the tile engine
// Params: mapNum
asm initTileEngine
txa
pha
bit setROM
lda evalStkL,x
jsr $6000
pla
tax
bit setLcRW+lcBank2
rts
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Render one frame using the ray caster. // Render one frame using the ray caster.
// Params: none // Params: none
asm renderFrame asm renderFrame3D
txa txa
pha pha
bit setROM bit setROM
@ -475,10 +500,14 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// General methods // General methods
///////////////////////////////////////////////////////////////////////////////////////////////////
// Fatal error: print message and stop the system.
def fatal(msg) def fatal(msg)
loader(FATAL_ERROR, MAIN_MEM, msg) loader(FATAL_ERROR, MAIN_MEM, msg)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Get a keystroke and convert it to upper case
def getUpperKey() def getUpperKey()
byte key byte key
while ^keyboard < 128 while ^keyboard < 128
@ -491,26 +520,46 @@ def getUpperKey()
return key return key
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set the sky color (relevant to 3D display only)
def setSky(num) def setSky(num)
skyNum = num skyNum = num
setColor(0<<8 | skyGndTbl1[skyNum]) setColor(0<<8 | skyGndTbl1[skyNum])
setColor(1<<8 | skyGndTbl2[skyNum]) setColor(1<<8 | skyGndTbl2[skyNum])
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Switch to the next sky color (3D only)
def nextSky() def nextSky()
setSky((skyNum + 1) & $F) setSky((skyNum + 1) & $F)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set the ground color (relevant to 3D display only)
def setGround(num) def setGround(num)
groundNum = num groundNum = num
setColor(2<<8 | skyGndTbl1[groundNum]) setColor(2<<8 | skyGndTbl1[groundNum])
setColor(3<<8 | skyGndTbl2[groundNum]) setColor(3<<8 | skyGndTbl2[groundNum])
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Switch to the next ground color
def nextGround() def nextGround()
setGround((groundNum + 1) & $F) setGround((groundNum + 1) & $F)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Render a graphics frame
def renderFrame()
if mapIs3D
renderFrame3D()
else
// TODO: 2D render
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Switch to text mode and display mem manager debug printout, get a key, switch back to graphics.
def debugMem(bank, code) def debugMem(bank, code)
^$c051 ^$c051
^$c054 ^$c054
@ -520,9 +569,45 @@ def debugMem(bank, code)
^$c050 ^$c050
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Clear the command table
def resetCmds()
byte i
for i = 0 to 63
cmdTbl[i] = 0
next
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.
def loadFrameImg()
if titleLoaded
loader(UNLOCK_MEMORY,MAIN_MEM, $2000)
loader(FREE_MEMORY, MAIN_MEM, $2000)
titleLoaded = FALSE
fin
loader(SET_MEM_TARGET, MAIN_MEM, $2000)
loader(QUEUE_LOAD, MAIN_MEM, 1<<8 | RES_TYPE_SCREEN)
loader(LOCK_MEMORY, MAIN_MEM, $2000)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Load code and data, set up everything to display a 3D map
def initMap3D() def initMap3D()
word scriptModule word scriptModule
// Set up the command table
initCmds3D()
// Reset memory (our module will stay since memory manager locked it upon load) // Reset memory (our module will stay since memory manager locked it upon load)
loader(RESET_MEMORY, MAIN_MEM, 0) loader(RESET_MEMORY, MAIN_MEM, 0)
@ -549,14 +634,7 @@ def initMap3D()
loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open
// Load the frame image (and lock it there) // Load the frame image (and lock it there)
if titleLoaded loadFrameImg()
loader(UNLOCK_MEMORY,MAIN_MEM, $2000)
loader(FREE_MEMORY, MAIN_MEM, $2000)
titleLoaded = FALSE
fin
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 scripts for this map, if it has any. // 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 scriptModule = pMap->2 // first 2 bytes are width and height, third byte is script module num
@ -607,6 +685,65 @@ def initMap3D()
redraw = FALSE redraw = FALSE
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Load code and data, set up everything to display a 2D map
def initMap2D()
word scriptModule
// Set up the command table
printHex($1001)
initCmds2D()
// Reset memory (our module will stay since memory manager locked it upon load)
printHex($1002)
loader(RESET_MEMORY, MAIN_MEM, 0)
// Load the font engine
printHex($1003)
loader(SET_MEM_TARGET, MAIN_MEM, fontEngine)
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_FONT_ENGINE<<8 | RES_TYPE_CODE)
// Load the font for the font engine
printHex($1004)
loader(SET_MEM_TARGET, MAIN_MEM, $9000)
pFont = loader(QUEUE_LOAD, MAIN_MEM, 1<<8 | RES_TYPE_FONT)
// Load the tile engine
printHex($1005)
loader(SET_MEM_TARGET, MAIN_MEM, tileEngine)
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_TILE_ENGINE<<8 | RES_TYPE_CODE)
// Load everything that we just queued
printHex($1006)
loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open
// Load the frame image (and lock it there)
printHex($1007)
loadFrameImg()
// Start up the font engine
printHex($1008)
initFontEngine(pFont)
// Start up the tile engine
printHex($1009)
initTileEngine(mapNum)
// TODO
printHex($1010)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set up mapNum (2D or 3D depending on state of is3DMap)
def initMap()
if mapIs3D
initMap3D()
else
initMap2D()
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Window for the map name bar // Window for the map name bar
def setWindow1() def setWindow1()
^wndtop = 1 ^wndtop = 1
@ -617,6 +754,7 @@ def setWindow1()
^cursh = ^wndleft ^cursh = ^wndleft
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Window for the large upper right bar // Window for the large upper right bar
def setWindow2() def setWindow2()
^wndtop = 3 ^wndtop = 3
@ -627,6 +765,7 @@ def setWindow2()
^cursh = ^wndleft ^cursh = ^wndleft
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Window for the mid-size lower right bar // Window for the mid-size lower right bar
def setWindow3() def setWindow3()
^wndtop = 18 ^wndtop = 18
@ -638,21 +777,8 @@ def setWindow3()
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Actions // Make sure page 1 of hi-res is displayed. Do this before doing memory manager operations, since
def resetCmds() // they overwrite page 2.
byte i
for i = 0 to 63
cmdTbl[i] = 0
next
end
def initCmd(key, func)
if key >= $60
key = key - $20
fin
cmdTbl[key-$20] = func
end
def flipToFirstPage def flipToFirstPage
if ^frontBuf == 1 if ^frontBuf == 1
renderFrame() renderFrame()
@ -660,6 +786,8 @@ def flipToFirstPage
fin fin
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Check for script(s) attached to the current location, and call them if there are any.
def checkScript() def checkScript()
word x word x
word y word y
@ -685,10 +813,12 @@ def checkScript()
fin fin
if (mapNum <> prevMapNum) or (mapIs3D <> prevMapIs3D) if (mapNum <> prevMapNum) or (mapIs3D <> prevMapIs3D)
flipToFirstPage() flipToFirstPage()
initMap3D() initMap()
fin fin
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Advance one step forward (3D maps only)
def moveForward() def moveForward()
word wasBlocked word wasBlocked
word func word func
@ -700,36 +830,50 @@ def moveForward()
fin fin
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Adjust player's direction plus or minus n increments (3D mode)
def adjustDir(n) def adjustDir(n)
^playerDir = (^playerDir + n) & $F ^playerDir = (^playerDir + n) & $F
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Move backward one step (3D mode)
def moveBackward() def moveBackward()
adjustDir(8) adjustDir(8)
moveForward() moveForward()
adjustDir(8) adjustDir(8)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Turn left (3D mode)
def rotateLeft() def rotateLeft()
adjustDir(-1) adjustDir(-1)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Rotate to the right (3D mode)
def rotateRight() def rotateRight()
adjustDir(1) adjustDir(1)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Sidestep to the right (3D mode)
def strafeRight() def strafeRight()
adjustDir(4) adjustDir(4)
moveForward() moveForward()
adjustDir(-4) adjustDir(-4)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Sidestep to the left (3D mode)
def strafeLeft() def strafeLeft()
adjustDir(-4) adjustDir(-4)
moveForward() moveForward()
adjustDir(4) adjustDir(4)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Switch to a new map (2D or 3D)
def setMap(is3D, num) def setMap(is3D, num)
// save player state if we're coming *from* the over-map // save player state if we're coming *from* the over-map
if mapNum == OVERMAP_NUM and mapIs3D == OVERMAP_IS_3D if mapNum == OVERMAP_NUM and mapIs3D == OVERMAP_IS_3D
@ -745,6 +889,8 @@ def setMap(is3D, num)
mapNum = num mapNum = num
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Switch to next map in the current 2D or 3D mode.
def nextMap() def nextMap()
mapNum = mapNum + 1 mapNum = mapNum + 1
if mapNum > 20 if mapNum > 20
@ -753,6 +899,8 @@ def nextMap()
setMap(mapIs3D, mapNum) setMap(mapIs3D, mapNum)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Jump to a new map location (and in 3D mode, point in the given direction)
def teleport(x, y, dir) def teleport(x, y, dir)
*playerX = ((x+1)<<8) | $80 *playerX = ((x+1)<<8) | $80
*playerY = ((y+1)<<8) | $80 *playerY = ((y+1)<<8) | $80
@ -764,6 +912,8 @@ def teleport(x, y, dir)
redraw = TRUE redraw = TRUE
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Get a key and dispatch it to a command. Then do it again, forever.
def kbdLoop() def kbdLoop()
word key, func word key, func
while TRUE while TRUE
@ -785,6 +935,8 @@ def kbdLoop()
loop loop
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Associate a location with a trigger function (i.e. a script)
def setLocationTrigger(x, y, func) def setLocationTrigger(x, y, func)
if nLocTrig == MAX_LOC_TRIG if nLocTrig == MAX_LOC_TRIG
fatal(@tooManyTriggers) fatal(@tooManyTriggers)
@ -795,6 +947,8 @@ def setLocationTrigger(x, y, func)
nLocTrig = nLocTrig + 1 nLocTrig = nLocTrig + 1
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Get a key, and don't return until it's Y or N (or lower-case of those). Returns 1 for Y.
def getYN() def getYN()
byte key byte key
while TRUE while TRUE
@ -809,25 +963,8 @@ def getYN()
loop loop
end end
def loadTitle() ///////////////////////////////////////////////////////////////////////////////////////////////////
puts(@helloStr) // Set up the command table for 3D mode
// Load the title screen
loader(SET_MEM_TARGET, MAIN_MEM, $2000)
loader(QUEUE_LOAD, MAIN_MEM, 2<<8 | RES_TYPE_SCREEN)
loader(LOCK_MEMORY, MAIN_MEM, $2000)
loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open
titleLoaded = TRUE
^$c050
^$c057
^$c054
^$c052
// Hack for real (not emulated) IIc: sometimes displays only lo-bit graphics
// unless we do this. *HUGE* thanks to Brendan Robert for the fix!
^$C07E=0 // disable double-hi-res
^$C05F // disable double-hi-res
end
def initCmds3D() def initCmds3D()
resetCmds() resetCmds()
@ -881,16 +1018,40 @@ def initCmds3D()
callbacks:19 = @teleport callbacks:19 = @teleport
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set up the command table for 2D mode
def initCmds2D()
resetCmds()
//initCmd('W', @moveForward)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Load and display the title screen.
def loadTitle()
puts(@helloStr)
// Load the title screen
loader(SET_MEM_TARGET, MAIN_MEM, $2000)
loader(QUEUE_LOAD, MAIN_MEM, 2<<8 | RES_TYPE_SCREEN)
loader(LOCK_MEMORY, MAIN_MEM, $2000)
loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open
titleLoaded = TRUE
^$c050
^$c057
^$c054
^$c052
// Hack for real (not emulated) IIc: sometimes displays only lo-bit graphics
// unless we do this. *HUGE* thanks to Brendan Robert for the fix!
^$C07E=0 // disable double-hi-res
^$C05F // disable double-hi-res
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Main code. // Main code.
// //
loadTitle() loadTitle()
if mapIs3D initMap()
initCmds3D()
initMap3D()
else
// 2D todo
fin
setWindow2() setWindow2()
kbdLoop() kbdLoop()

View File

@ -3,11 +3,17 @@
; ------------------ ; ------------------
; ;
* = $6000 * = $6000
; Use hi-bit ASCII for Apple II
!convtab "../include/hiBitAscii.ct"
; Global definitions ; Global definitions
!source "../include/global.i" !source "../include/global.i"
!source "../include/mem.i" !source "../include/mem.i"
!source "../include/plasma.i" !source "../include/plasma.i"
DEBUG = 1 ; 1=some logging, 2=lots of logging
HEADER_LENGTH=6 HEADER_LENGTH=6
SECTION_WIDTH=22 SECTION_WIDTH=22
SECTION_HEIGHT=23 SECTION_HEIGHT=23
@ -69,17 +75,13 @@ Y_COUNTER = $67 ; Loop counter used during drawing
Y_LOC = $68 ; Current row being drawn (between 0 and VIEWPORT_WIDTH) Y_LOC = $68 ; Current row being drawn (between 0 and VIEWPORT_WIDTH)
ROW_LOCATION = $69 ; Used for pointing at row offset in map data ROW_LOCATION = $69 ; Used for pointing at row offset in map data
TILE_SOURCE = $6D ; Location of tile data TILE_SOURCE = $6D ; Location of tile data
; >> INIT (reset map drawing vars)
INIT ;----------------------------------------------------------------------
LDA #NOT_LOADED ; Vectors used to call in from the outside.
STA NW_MAP_ID jmp INIT
STA NE_MAP_ID
STA SW_MAP_ID ; Debug support -- must come after jump vectors, since it's not just macros.
STA SE_MAP_ID !source "../include/debug.i"
LDX VIEWPORT_HORIZ_PAD
LDY VIEWPORT_VERT_PAD
JSR SET_XY
RTS
;---------------------------------------------------------------------- ;----------------------------------------------------------------------
; >> START LOADING MAP SECTIONS ; >> START LOADING MAP SECTIONS
@ -109,6 +111,11 @@ LOAD_SECTION
LDY #00 LDY #00
RTS RTS
.doLoad TAY ; resource # in Y .doLoad TAY ; resource # in Y
!if DEBUG >= 1 {
+prStr : !text "load section: mapNum=",0
+prY
+crout
} ; end DEBUG
LDX #RES_TYPE_2D_MAP LDX #RES_TYPE_2D_MAP
LDA #QUEUE_LOAD LDA #QUEUE_LOAD
JMP mainLoader JMP mainLoader
@ -142,6 +149,11 @@ FINISH_MAP_LOAD
; Load tile resource (A = Resource ID) ; Load tile resource (A = Resource ID)
LOAD_TILESET LOAD_TILESET
TAY TAY
!if DEBUG >= 1 {
+prStr : !text "load tileset=",0
+prY
+crout
} ; end DEBUG
LDX #RES_TYPE_TILESET LDX #RES_TYPE_TILESET
LDA #QUEUE_LOAD LDA #QUEUE_LOAD
JMP mainLoader JMP mainLoader
@ -578,6 +590,52 @@ ROW_OFFSET = 3
JMP .rowLoop JMP .rowLoop
; Draw player ; Draw player
;----------------------------------------------------------------------
; >> INIT (reset map drawing vars, load initial map in A)
INIT
!if DEBUG >= 1 {
+prStr : !text "Init tile engine.",0
+prA
+crout
} ; end DEBUG
; load the NW map section first
STA NW_MAP_ID
+startLoad
LDA NW_MAP_ID
+loadSection NW_MAP_LOC
+finishLoad
+startLoad
; from the NW section we can get the ID of the NE section
LDY #EAST
LDA (NW_MAP_LOC),Y
STA NE_MAP_ID
+loadSection NE_MAP_LOC
; from the NW section we can get the ID of the SW section
LDY #SOUTH
LDA (NW_MAP_LOC),Y
STA SW_MAP_ID
+loadSection SW_MAP_LOC
+finishLoad
+startLoad
; if there's no SW section, there's also no SE section
LDA #$FF
STA SE_MAP_ID
CMP SW_MAP_ID
BEQ +
; get the SE section from the SW section
LDY #EAST
LDA (SW_MAP_LOC),Y
STA SE_MAP_ID
+loadSection SE_MAP_LOC
+ +loadAllTiles
+finishLoad
; set up the X and Y coordinates
LDX VIEWPORT_HORIZ_PAD
LDY VIEWPORT_VERT_PAD
JSR SET_XY
RTS
tblHGRl tblHGRl
!byte $00,$80,$00,$80,$00,$80,$00,$80 !byte $00,$80,$00,$80,$00,$80,$00,$80
!byte $28,$A8,$28,$A8,$28,$A8,$28,$A8 !byte $28,$A8,$28,$A8,$28,$A8,$28,$A8