From dc194d44f78821c1e83f8d30d69d32d0fb1e7151 Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Sun, 18 Jan 2015 08:59:56 -0800 Subject: [PATCH] Simplified section math. --- .../Apple/virtual/src/plasma/gameloop.pla | 49 ++++++++++++++++++- Platform/Apple/virtual/src/tile/tile.s | 22 +++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index e5314540..d590b506 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -81,6 +81,11 @@ const playerY = $60 const backBuf = $6A const frontBuf = $6B +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Tile engine variables +const relX = $50 +const relY = $51 + /////////////////////////////////////////////////////////////////////////////////////////////////// // Font engine variables const wndleft = $70 // left edge of the window @@ -333,6 +338,21 @@ asm renderFrame rts end +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Deal with crossing into a new map section +// Params: none +asm checkCrossing + txa + pha + bit setROM + jsr $6006 + pla + tax + dex ; don't-care return value + bit setLcRW+lcBank2 + rts +end + /////////////////////////////////////////////////////////////////////////////////////////////////// // Is the player's current position a physical obstruction? // Params: none @@ -847,6 +867,29 @@ def strafeLeft() adjustDir(4) end +/////////////////////////////////////////////////////////////////////////////////////////////////// +def move2D(ox, oy) + *relX = ox + *relX + *relY = oy + *relY + checkCrossing() +end + +def moveNorth() + move2D(0, -1) +end + +def moveEast() + move2D(1, 0) +end + +def moveSouth() + move2D(0, 1) +end + +def moveWest() + move2D(-1, 0) +end + /////////////////////////////////////////////////////////////////////////////////////////////////// // Switch to a new map (2D or 3D) def setMap(is3D, num) @@ -998,7 +1041,11 @@ end def initCmds2D() resetCmds() - //initCmd('W', @moveForward) + initCmd('W', @moveNorth) + initCmd('D', @moveEast) + initCmd('S', @moveSouth) + initCmd('X', @moveSouth) + initCmd('A', @moveWest) end /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Platform/Apple/virtual/src/tile/tile.s b/Platform/Apple/virtual/src/tile/tile.s index 8edfa466..303ac6f2 100644 --- a/Platform/Apple/virtual/src/tile/tile.s +++ b/Platform/Apple/virtual/src/tile/tile.s @@ -80,6 +80,7 @@ TILE_SOURCE = $6D ; Location of tile data ; Vectors used to call in from the outside. jmp INIT jmp DRAW + jmp CROSS ; Debug support -- must come after jump vectors, since it's not just macros. !source "../include/debug.i" @@ -221,6 +222,27 @@ LOAD_ALL_TILES JSR LOAD_ALL_TILES } +; >> CHECK CROSSINGS +!zone +CROSS + LDA REL_Y + CMP #VIEWPORT_VERT_PAD-1 + BPL .10 + JSR CROSS_NORTH +.10 LDA REL_Y + CMP #VIEWPORT_VERT_PAD+SECTION_HEIGHT + BMI .20 + JSR CROSS_SOUTH +.20 LDA REL_X + CMP #VIEWPORT_HORZ_PAD-1 + BPL .30 + JSR CROSS_WEST +.30 LDA REL_X + CMP #VIEWPORT_HORZ_PAD+SECTION_WIDTH + BMI .40 + JSR CROSS_EAST +.40 RTS + ; >> CROSS NORTH BOUNDARY (Load next section to the north) !zone CROSS_NORTH