mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-26 19:29:27 +00:00
Implemented blocker sprites the right way.
This commit is contained in:
parent
61e568f38d
commit
3af48520a1
@ -431,18 +431,15 @@ class PackPartitions
|
|||||||
if (name == null || name.toLowerCase() =~ /street|blank|null/)
|
if (name == null || name.toLowerCase() =~ /street|blank|null/)
|
||||||
texMap[id] = 0
|
texMap[id] = 0
|
||||||
else if (stripName(name) in textures) {
|
else if (stripName(name) in textures) {
|
||||||
def flags = 0
|
def flags = 1
|
||||||
if (tile?.@obstruction == 'true')
|
if (tile?.@obstruction == 'true')
|
||||||
flags |= 1
|
|
||||||
if (tile?.@sprite == 'true')
|
|
||||||
flags |= 2
|
flags |= 2
|
||||||
if (tile?.@blocker == 'true')
|
if (tile?.@blocker == 'true')
|
||||||
flags |= 4
|
flags |= 4
|
||||||
texList.add(textures[stripName(name)].num)
|
texList.add(textures[stripName(name)].num)
|
||||||
texFlags.add(flags)
|
texFlags.add(flags)
|
||||||
texMap[id] = texList.size()
|
texMap[id] = texList.size()
|
||||||
println "tex #${texList.size()}: name=$name flags=$flags"
|
if (tile?.@sprite == 'true')
|
||||||
if (tile?.@obstruction != 'true')
|
|
||||||
texMap[id] |= 0x80; // hi-bit flag to mark sprite cells
|
texMap[id] |= 0x80; // hi-bit flag to mark sprite cells
|
||||||
}
|
}
|
||||||
else if (id) {
|
else if (id) {
|
||||||
@ -464,6 +461,10 @@ class PackPartitions
|
|||||||
texList.each { buf.put((byte)it) }
|
texList.each { buf.put((byte)it) }
|
||||||
buf.put((byte)0)
|
buf.put((byte)0)
|
||||||
|
|
||||||
|
// Followed by the corresponding list of texture flags
|
||||||
|
texFlags.each { buf.put((byte)it) }
|
||||||
|
buf.put((byte)0)
|
||||||
|
|
||||||
// Sentinel row of $FF at start of map
|
// Sentinel row of $FF at start of map
|
||||||
(0..<width).each { buf.put((byte)0xFF) }
|
(0..<width).each { buf.put((byte)0xFF) }
|
||||||
|
|
||||||
|
@ -132,8 +132,8 @@ byte = $22 ; blue
|
|||||||
byte = $28 ; orange
|
byte = $28 ; orange
|
||||||
byte = $2A ; hi-bit white
|
byte = $2A ; hi-bit white
|
||||||
|
|
||||||
word skyNum = 0
|
word skyNum = 9
|
||||||
word groundNum = 0
|
word groundNum = 10
|
||||||
|
|
||||||
;==================================================================================================
|
;==================================================================================================
|
||||||
; Definitions used by assembly code
|
; Definitions used by assembly code
|
||||||
@ -367,9 +367,11 @@ def initCmd(key, func)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def moveForward()
|
def moveForward()
|
||||||
|
word wasBlocked
|
||||||
|
wasBlocked = isBlocked()
|
||||||
*playerX = *playerX + walkDirs[^playerDir * 2]
|
*playerX = *playerX + walkDirs[^playerDir * 2]
|
||||||
*playerY = *playerY + walkDirs[^playerDir * 2 + 1]
|
*playerY = *playerY + walkDirs[^playerDir * 2 + 1]
|
||||||
if isBlocked()
|
if !wasBlocked and isBlocked()
|
||||||
moveBackward()
|
moveBackward()
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
@ -379,10 +381,12 @@ def adjustDir(n)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def moveBackward()
|
def moveBackward()
|
||||||
|
word wasBlocked
|
||||||
|
wasBlocked = isBlocked()
|
||||||
adjustDir(8)
|
adjustDir(8)
|
||||||
moveForward()
|
moveForward()
|
||||||
adjustDir(8)
|
adjustDir(8)
|
||||||
if isBlocked()
|
if !wasBlocked and isBlocked()
|
||||||
moveForward()
|
moveForward()
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ start:
|
|||||||
; code is at the very end. We jump to it now.
|
; code is at the very end. We jump to it now.
|
||||||
jmp initMap
|
jmp initMap
|
||||||
jmp renderFrame
|
jmp renderFrame
|
||||||
jmp getMapCell
|
jmp isBlocked
|
||||||
jmp setColor
|
jmp setColor
|
||||||
|
|
||||||
; Conditional assembly flags
|
; Conditional assembly flags
|
||||||
@ -19,9 +19,6 @@ DOUBLE_BUFFER = 1 ; whether to double-buffer
|
|||||||
DEBUG = 0 ; 1=some logging, 2=lots of logging
|
DEBUG = 0 ; 1=some logging, 2=lots of logging
|
||||||
DEBUG_COLUMN = -1
|
DEBUG_COLUMN = -1
|
||||||
|
|
||||||
; temporary hack to try blocker sprites
|
|
||||||
BLOCKER_FOO = 0
|
|
||||||
|
|
||||||
; Shared constants, zero page, buffer locations, etc.
|
; Shared constants, zero page, buffer locations, etc.
|
||||||
!source "render.i"
|
!source "render.i"
|
||||||
; Debug macros and support functions
|
; Debug macros and support functions
|
||||||
@ -390,14 +387,19 @@ castRay: !zone
|
|||||||
.hitSprite:
|
.hitSprite:
|
||||||
cmp #$FF ; check for special mark at edges of map
|
cmp #$FF ; check for special mark at edges of map
|
||||||
beq .hitEdge
|
beq .hitEdge
|
||||||
!if BLOCKER_FOO {
|
|
||||||
cmp #$c1
|
|
||||||
beq .hitEdge
|
|
||||||
}
|
|
||||||
; We found a sprite cell on the map. We only want to process this sprite once,
|
; We found a sprite cell on the map. We only want to process this sprite once,
|
||||||
; so check if we've already done it.
|
; so check if we've already done it.
|
||||||
|
tax
|
||||||
and #$40
|
and #$40
|
||||||
bne .spriteDone ; already done, don't do again
|
beq .notDone ; already done, don't do again
|
||||||
|
txa
|
||||||
|
and #$3F
|
||||||
|
tax
|
||||||
|
jsr getTileFlags
|
||||||
|
and #4 ; blocker sprite?
|
||||||
|
bne .hitEdge ; if yes, stop tracing here
|
||||||
|
jmp .spriteDone ; if not, keep tracing
|
||||||
|
.notDone:
|
||||||
; Haven't seen this one yet. Mark it, and also record the address of the flag
|
; Haven't seen this one yet. Mark it, and also record the address of the flag
|
||||||
; so we can clear it later after tracing all rays.
|
; so we can clear it later after tracing all rays.
|
||||||
lda (pMap),y ; get back the original byte
|
lda (pMap),y ; get back the original byte
|
||||||
@ -434,11 +436,10 @@ castRay: !zone
|
|||||||
jsr drawSprite ; put it on screen
|
jsr drawSprite ; put it on screen
|
||||||
+ pla
|
+ pla
|
||||||
tay ; restore map position index
|
tay ; restore map position index
|
||||||
!if BLOCKER_FOO {
|
ldx txNum
|
||||||
lda txNum
|
jsr getTileFlags
|
||||||
cmp #1
|
and #4 ; blocker sprite?
|
||||||
beq .hitEdge
|
bne .hitEdge ; if yes, stop tracing rays
|
||||||
}
|
|
||||||
.spriteDone:
|
.spriteDone:
|
||||||
jmp .DDA_step ; trace this ray some more
|
jmp .DDA_step ; trace this ray some more
|
||||||
|
|
||||||
@ -1553,6 +1554,12 @@ setPlayerPos: !zone
|
|||||||
sta playerDir
|
sta playerDir
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
;-------------------------------------------------------------------------------
|
||||||
|
getTileFlags: !zone
|
||||||
|
dex ; because tile numbers start at 1 but list at 0
|
||||||
|
lda $1111,x
|
||||||
|
rts
|
||||||
|
|
||||||
;-------------------------------------------------------------------------------
|
;-------------------------------------------------------------------------------
|
||||||
; Load the texture expansion code, copy it to aux mem
|
; Load the texture expansion code, copy it to aux mem
|
||||||
loadTextures: !zone
|
loadTextures: !zone
|
||||||
@ -1607,7 +1614,15 @@ loadTextures: !zone
|
|||||||
brk ; barf out if too many textures
|
brk ; barf out if too many textures
|
||||||
+ stx txNum
|
+ stx txNum
|
||||||
jmp .lup
|
jmp .lup
|
||||||
.done: ; end of the texture numbers is the base of the map data - record it
|
.done: ; end of texture numbers is the list of tile flags
|
||||||
|
lda .get+1
|
||||||
|
sta getTileFlags+2
|
||||||
|
lda .get+2
|
||||||
|
sta getTileFlags+3
|
||||||
|
- jsr .get ; skip over the flags now
|
||||||
|
tay
|
||||||
|
bne -
|
||||||
|
; end of the texture flags is the base of the map data - record it
|
||||||
lda .get+1
|
lda .get+1
|
||||||
sta mapBase
|
sta mapBase
|
||||||
lda .get+2
|
lda .get+2
|
||||||
@ -1668,13 +1683,18 @@ calcMapOrigin: !zone
|
|||||||
|
|
||||||
;-------------------------------------------------------------------------------
|
;-------------------------------------------------------------------------------
|
||||||
; Retrieve the map data where the player currently is
|
; Retrieve the map data where the player currently is
|
||||||
getMapCell: !zone
|
isBlocked: !zone
|
||||||
jsr calcMapOrigin
|
jsr calcMapOrigin
|
||||||
sta pMap
|
sta pMap
|
||||||
sty pMap+1
|
sty pMap+1
|
||||||
ldy playerX+1
|
ldy playerX+1
|
||||||
lda (pMap),y
|
lda (pMap),y
|
||||||
rts
|
beq +
|
||||||
|
and #$3F
|
||||||
|
tax
|
||||||
|
jsr getTileFlags
|
||||||
|
and #2 ; flag 2 is for obstructions
|
||||||
|
+ rts
|
||||||
|
|
||||||
;-------------------------------------------------------------------------------
|
;-------------------------------------------------------------------------------
|
||||||
; Cast all the rays from the current player coord
|
; Cast all the rays from the current player coord
|
||||||
|
Loading…
Reference in New Issue
Block a user