Lots of fixes.

This commit is contained in:
Martin Haye 2014-07-06 16:45:27 -07:00
parent 89d8721afd
commit 655fe7946f
4 changed files with 98 additions and 49 deletions

View File

@ -448,6 +448,10 @@ init: !zone
iny ; twice for 2 pages: initial pointer at top of new space
iny
sty framePtr+1
dey
dey
lda #LOCK_MEMORY ; lock it in place forever
jsr mainLoader
; Load PLASMA module #1
ldx #0
lda #START_LOAD
@ -862,7 +866,7 @@ shared_queueLoad:
beq .noChkTarg ; if not, skip target check
cpx targetAddr ; verify addr lo
bne .redo
cpy targetAddr ; verify addr hi
cpy targetAddr+1 ; verify addr hi
bne .redo
.noChkTarg:
lda #0

View File

@ -63,6 +63,8 @@ word zp = 0
const playerDir = $5D
const playerX = $5E
const playerY = $60
const backBuf = $6A
const frontBuf = $6B
;==================================================================================================
; Strings.
@ -255,6 +257,57 @@ asm goMon
jmp $FF69
end
;==================================================================================================
; General methods
def initMap()
; 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
; Start up the font engine
puts(@initFontStr)
initFontEngine(pFont)
; Start up the raycaster
puts(@initRaycastStr)
initRaycaster(pMap)
; Set initial player position
^playerDir = 1
*playerX = $280
*playerY = $380
; Draw the first frame
renderFrame()
end
;==================================================================================================
; Actions
def initCmd(key, func)
@ -305,6 +358,21 @@ def strafeLeft()
adjustDir(4)
end
def flipToFirstPage
if ^frontBuf == 1
renderFrame()
fin
end
def nextMap()
flipToFirstPage()
mapNum = mapNum + 1
if mapNum > 5
mapNum = 1
fin
initMap()
end
def kbdLoop()
word key, func
while TRUE
@ -327,51 +395,10 @@ def kbdLoop()
end
;==================================================================================================
; Main loop.
; Main code.
;
puts(@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)
; Set initial player position
^playerDir = 1
*playerX = $280
*playerY = $380
; Init the command table
initCmd('W', @moveForward)
initCmd('A', @rotateLeft)
@ -389,8 +416,9 @@ initCmd(',', @moveBackward)
initCmd('M', @strafeLeft)
initCmd('.', @strafeRight)
; Draw the first frame
renderFrame()
initCmd('N', @nextMap)
initMap()
; Main keyboard loop
puts(@loopStr)

View File

@ -57,6 +57,8 @@ mapHeight = $63 ; len 1
spriteX = $64 ; len 2
spriteY = $66 ; len 2
plasmaFrames = $68 ; len 2
backBuf = $6A ; len 1
frontBuf = $6B ; len 1
; Sprite calculations zero page
bSgnSinT = $90

View File

@ -35,6 +35,7 @@ MAX_SPRITES = 64 ; max # sprites visible at once
NUM_COLS = 63
SPRITE_DIST_LIMIT = 8
SPRITE_CT_LIMIT = 4
MAX_NAME_LEN = 14
; Starting position and dir. Eventually this will come from the map
PLAYER_START_X = $280 ; 1.5
@ -51,8 +52,6 @@ W_LOG_65536 = $1000
W_LOG_VIEW_DIST = $0E3F
; Variables
backBuf: !byte 0 ; (value 0 or 1)
frontBuf: !byte 0 ; (value 0 or 1)
mapHeader: !word 0 ; map with header first
mapBase: !word 0 ; first byte after the header
mapRayOrigin: !word 0
@ -1610,7 +1609,18 @@ loadTextures: !zone
inc mapNameLen
cmp #0
bne .skip ; until end-of-string is reached (zero byte)
lda #0 ; now comes the list of textures.
lda mapNameLen ; clamp length of map name
cmp #MAX_NAME_LEN
bcc +
lda mapName
sta .trunc+1
lda mapName+1
sta .trunc+2
ldx #MAX_NAME_LEN
lda #0
.trunc sta mapName,x
stx mapNameLen
+ lda #0 ; now comes the list of textures.
sta txNum
.lup: jsr .get ; get texture resource number
tay ; to Y for mem manager
@ -1640,11 +1650,16 @@ loadTextures: !zone
lda #FINISH_LOAD
ldx #0
jmp mainLoader
.get: lda $1111
.get: lda $1111
inc .get+1
bne +
inc .get+2
+ rts
.set lda .get+2
sta .set2+2
ldy .get+1
.set2 sta $1100,y
rts
;-------------------------------------------------------------------------------
; Set up front and back buffers, go to hires mode, and clear for first blit.