mirror of
https://github.com/jeremysrand/BuGS.git
synced 2025-01-01 01:30:27 +00:00
Add the code to draw the body and head segments in the game loop. Still need to add code to create, update and shoot segments.
This commit is contained in:
parent
67e2b56dc2
commit
d8e9c6863b
@ -13,23 +13,111 @@
|
||||
gameSegments start
|
||||
using globalData
|
||||
|
||||
|
||||
SEGMENT_MAX_NUM equ 12
|
||||
SEGMENT_MAX_OFFSET equ SEGMENT_MAX_NUM*2-2
|
||||
|
||||
SEGMENT_STATE_NONE equ 0
|
||||
SEGMENT_STATE_HEAD equ 1
|
||||
SEGMENT_STATE_BODY equ 2
|
||||
|
||||
SEGMENT_DIR_LEFT equ 0
|
||||
SEGMENT_DIR_DOWN_LEFT equ 1
|
||||
SEGMENT_DIR_DOWN equ 2
|
||||
SEGMENT_DIR_DOWN_RIGHT equ 3
|
||||
SEGMENT_DIR_RIGHT equ 4
|
||||
SEGMENT_DIR_LEFT equ 0
|
||||
SEGMENT_DIR_RIGHT equ 1
|
||||
|
||||
SEGMENT_FACING_LEFT equ 0
|
||||
SEGMENT_FACING_DOWN_LEFT equ 32
|
||||
SEGMENT_FACING_DOWN equ 64
|
||||
SEGMENT_FACING_DOWN_RIGHT equ 96
|
||||
SEGMENT_FACING_RIGHT equ 128
|
||||
|
||||
|
||||
drawSegments entry
|
||||
; Write this code...
|
||||
ldx #SEGMENT_MAX_OFFSET
|
||||
drawSegments_nextSegment anop
|
||||
lda segmentStates,x
|
||||
beq drawSegments_skipSegment
|
||||
|
||||
lda segmentFacing,x
|
||||
clc
|
||||
adc segmentSpriteOffset
|
||||
tay
|
||||
|
||||
lda segmentStates,x
|
||||
cmp #SEGMENT_STATE_HEAD
|
||||
beq drawSegments_head
|
||||
jsl segmentBodyJump
|
||||
bra drawSegments_skipSegment
|
||||
|
||||
drawSegments_head anop
|
||||
jsl segmentHeadJump
|
||||
|
||||
drawSegments_skipSegment anop
|
||||
dex
|
||||
dex
|
||||
bpl drawSegments_nextSegment
|
||||
rtl
|
||||
|
||||
|
||||
segmentHeadJump entry
|
||||
lda segmentScreenShifts,x
|
||||
beq segmentHeadJump_noShift
|
||||
|
||||
lda headShiftJumpTable,y
|
||||
sta segmentHeadJump_jumpInst+1
|
||||
lda headShiftJumpTable+2,y
|
||||
sta segmentHeadJump_jumpInst+3
|
||||
|
||||
ldy segmentScreenOffsets,x
|
||||
bra segmentHeadJump_jumpInst
|
||||
|
||||
segmentHeadJump_noShift anop
|
||||
lda headJumpTable,y
|
||||
sta segmentHeadJump_jumpInst+1
|
||||
lda headJumpTable+2,y
|
||||
sta segmentHeadJump_jumpInst+3
|
||||
|
||||
ldy segmentScreenOffsets,x
|
||||
|
||||
segmentHeadJump_jumpInst anop
|
||||
jmp >leftHead1
|
||||
|
||||
|
||||
segmentBodyJump entry
|
||||
lda segmentScreenShifts,x
|
||||
beq segmentBodyJump_noShift
|
||||
|
||||
lda bodyShiftJumpTable,y
|
||||
sta segmentBodyJump_jumpInst+1
|
||||
lda bodyShiftJumpTable+2,y
|
||||
sta segmentBodyJump_jumpInst+3
|
||||
|
||||
ldy segmentScreenOffsets,x
|
||||
bra segmentBodyJump_jumpInst
|
||||
|
||||
segmentBodyJump_noShift anop
|
||||
lda bodyJumpTable,y
|
||||
sta segmentBodyJump_jumpInst+1
|
||||
lda bodyJumpTable+2,y
|
||||
sta segmentBodyJump_jumpInst+3
|
||||
|
||||
ldy segmentScreenOffsets,x
|
||||
|
||||
segmentBodyJump_jumpInst anop
|
||||
jmp >leftHead1
|
||||
|
||||
|
||||
updateSegments entry
|
||||
lda segmentSpriteOffset
|
||||
beq updateSegments_resetSpriteOffset
|
||||
sec
|
||||
sbc #$4
|
||||
bra updateSegments_spriteOffsetCont
|
||||
|
||||
updateSegments_resetSpriteOffset anop
|
||||
lda #SEGMENT_SPRITE_LAST_OFFSET
|
||||
updateSegments_spriteOffsetCont anop
|
||||
sta segmentSpriteOffset
|
||||
|
||||
; Write this code...
|
||||
rtl
|
||||
|
||||
@ -47,9 +135,23 @@ addHeadSegment entry
|
||||
shootSegment entry
|
||||
; Write this code...
|
||||
rtl
|
||||
|
||||
|
||||
|
||||
numSegments dc i2'0'
|
||||
|
||||
segmentStates dc 12i2'SEGMENT_STATE_NONE'
|
||||
segmentDirections dc 12i2'SEGMENT_DIR_RIGHT'
|
||||
segmentFacing dc 12i2'SEGMENT_FACING_DOWN'
|
||||
segmentScreenOffsets dc 12i2'0'
|
||||
segmentScreenShifts dc 12i2'0'
|
||||
|
||||
SEGMENT_SPRITE_LAST_OFFSET gequ 7*4
|
||||
leftHeadJumpTable dc i4'leftHead5'
|
||||
segmentSpriteOffset dc i2'SEGMENT_SPRITE_LAST_OFFSET'
|
||||
|
||||
|
||||
headJumpTable anop
|
||||
; leftHeadJumpTable
|
||||
dc i4'leftHead5'
|
||||
dc i4'leftHead4'
|
||||
dc i4'leftHead1'
|
||||
dc i4'leftHead2'
|
||||
@ -57,79 +159,20 @@ leftHeadJumpTable dc i4'leftHead5'
|
||||
dc i4'leftHead2'
|
||||
dc i4'leftHead1'
|
||||
dc i4'leftHead4'
|
||||
|
||||
|
||||
leftHeadShiftJumpTable dc i4'leftHead5s'
|
||||
dc i4'leftHead4s'
|
||||
dc i4'leftHead1s'
|
||||
dc i4'leftHead2s'
|
||||
dc i4'leftHead3s'
|
||||
dc i4'leftHead2s'
|
||||
dc i4'leftHead1s'
|
||||
dc i4'leftHead4s'
|
||||
|
||||
|
||||
rightHeadJumpTable dc i4'rightHead5'
|
||||
dc i4'rightHead4'
|
||||
dc i4'rightHead1'
|
||||
dc i4'rightHead2'
|
||||
dc i4'rightHead3'
|
||||
dc i4'rightHead2'
|
||||
dc i4'rightHead1'
|
||||
dc i4'rightHead4'
|
||||
|
||||
|
||||
rightHeadShiftJumpTable dc i4'rightHead5s'
|
||||
dc i4'rightHead4s'
|
||||
dc i4'rightHead1s'
|
||||
dc i4'rightHead2s'
|
||||
dc i4'rightHead3s'
|
||||
dc i4'rightHead2s'
|
||||
dc i4'rightHead1s'
|
||||
dc i4'rightHead4s'
|
||||
; leftDownHeadJumpTable
|
||||
dc i4'leftDownHead1'
|
||||
dc i4'leftDownHead2'
|
||||
dc i4'leftDownHead1'
|
||||
dc i4'leftDownHead2'
|
||||
dc i4'leftDownHead1'
|
||||
dc i4'leftDownHead2'
|
||||
dc i4'leftDownHead1'
|
||||
dc i4'leftDownHead2'
|
||||
|
||||
|
||||
leftDownHeadJumpTable dc i4'leftDownHead1'
|
||||
dc i4'leftDownHead2'
|
||||
dc i4'leftDownHead1'
|
||||
dc i4'leftDownHead2'
|
||||
dc i4'leftDownHead1'
|
||||
dc i4'leftDownHead2'
|
||||
dc i4'leftDownHead1'
|
||||
dc i4'leftDownHead2'
|
||||
|
||||
|
||||
leftDownShiftHeadJumpTable dc i4'leftDownHead1s'
|
||||
dc i4'leftDownHead2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownHead1s'
|
||||
dc i4'leftDownHead2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownHead1s'
|
||||
dc i4'leftDownHead2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownHead1s'
|
||||
dc i4'leftDownHead2s' ; Problem, spills into next tile...
|
||||
|
||||
|
||||
rightDownHeadJumpTable dc i4'rightDownHead1'
|
||||
dc i4'rightDownHead2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownHead1'
|
||||
dc i4'rightDownHead2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownHead1'
|
||||
dc i4'rightDownHead2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownHead1'
|
||||
dc i4'rightDownHead2' ; Problem, spills into next tile...
|
||||
|
||||
|
||||
rightDownShiftHeadJumpTable dc i4'rightDownHead1s'
|
||||
dc i4'rightDownHead2s'
|
||||
dc i4'rightDownHead1s'
|
||||
dc i4'rightDownHead2s'
|
||||
dc i4'rightDownHead1s'
|
||||
dc i4'rightDownHead2s'
|
||||
dc i4'rightDownHead1s'
|
||||
dc i4'rightDownHead2s'
|
||||
|
||||
|
||||
downHeadJumpTable dc i4'downHead3'
|
||||
; downHeadJumpTable
|
||||
dc i4'downHead3'
|
||||
dc i4'downHead3'
|
||||
dc i4'downHead1'
|
||||
dc i4'downHead1'
|
||||
@ -139,7 +182,87 @@ downHeadJumpTable dc i4'downHead3'
|
||||
dc i4'downHead1'
|
||||
|
||||
|
||||
leftBodyJumpTable dc i4'leftBody5'
|
||||
; rightDownHeadJumpTable
|
||||
dc i4'rightDownHead1'
|
||||
dc i4'rightDownHead2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownHead1'
|
||||
dc i4'rightDownHead2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownHead1'
|
||||
dc i4'rightDownHead2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownHead1'
|
||||
dc i4'rightDownHead2' ; Problem, spills into next tile...
|
||||
|
||||
|
||||
; rightHeadJumpTable
|
||||
dc i4'rightHead5'
|
||||
dc i4'rightHead4'
|
||||
dc i4'rightHead1'
|
||||
dc i4'rightHead2'
|
||||
dc i4'rightHead3'
|
||||
dc i4'rightHead2'
|
||||
dc i4'rightHead1'
|
||||
dc i4'rightHead4'
|
||||
|
||||
|
||||
headShiftJumpTable anop
|
||||
; leftHeadShiftJumpTable
|
||||
dc i4'leftHead5s'
|
||||
dc i4'leftHead4s'
|
||||
dc i4'leftHead1s'
|
||||
dc i4'leftHead2s'
|
||||
dc i4'leftHead3s'
|
||||
dc i4'leftHead2s'
|
||||
dc i4'leftHead1s'
|
||||
dc i4'leftHead4s'
|
||||
|
||||
|
||||
; leftDownShiftHeadJumpTable
|
||||
dc i4'leftDownHead1s'
|
||||
dc i4'leftDownHead2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownHead1s'
|
||||
dc i4'leftDownHead2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownHead1s'
|
||||
dc i4'leftDownHead2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownHead1s'
|
||||
dc i4'leftDownHead2s' ; Problem, spills into next tile...
|
||||
|
||||
|
||||
; downHeadJumpTable
|
||||
dc i4'downHead3'
|
||||
dc i4'downHead3'
|
||||
dc i4'downHead1'
|
||||
dc i4'downHead1'
|
||||
dc i4'downHead2'
|
||||
dc i4'downHead2'
|
||||
dc i4'downHead1'
|
||||
dc i4'downHead1'
|
||||
|
||||
|
||||
; rightDownShiftHeadJumpTable
|
||||
dc i4'rightDownHead1s'
|
||||
dc i4'rightDownHead2s'
|
||||
dc i4'rightDownHead1s'
|
||||
dc i4'rightDownHead2s'
|
||||
dc i4'rightDownHead1s'
|
||||
dc i4'rightDownHead2s'
|
||||
dc i4'rightDownHead1s'
|
||||
dc i4'rightDownHead2s'
|
||||
|
||||
|
||||
; rightHeadShiftJumpTable
|
||||
dc i4'rightHead5s'
|
||||
dc i4'rightHead4s'
|
||||
dc i4'rightHead1s'
|
||||
dc i4'rightHead2s'
|
||||
dc i4'rightHead3s'
|
||||
dc i4'rightHead2s'
|
||||
dc i4'rightHead1s'
|
||||
dc i4'rightHead4s'
|
||||
|
||||
|
||||
bodyJumpTable anop
|
||||
; leftBodyJumpTable
|
||||
dc i4'leftBody5'
|
||||
dc i4'leftBody4'
|
||||
dc i4'leftBody1'
|
||||
dc i4'leftBody2'
|
||||
@ -147,19 +270,43 @@ leftBodyJumpTable dc i4'leftBody5'
|
||||
dc i4'leftBody2'
|
||||
dc i4'leftBody1'
|
||||
dc i4'leftBody4'
|
||||
|
||||
|
||||
leftBodyShiftJumpTable dc i4'leftBody5s'
|
||||
dc i4'leftBody4s'
|
||||
dc i4'leftBody1s'
|
||||
dc i4'leftBody2s'
|
||||
dc i4'leftBody3s'
|
||||
dc i4'leftBody2s'
|
||||
dc i4'leftBody1s'
|
||||
dc i4'leftBody4s'
|
||||
|
||||
|
||||
rightBodyJumpTable dc i4'rightBody5'
|
||||
; leftDownBodyJumpTable
|
||||
dc i4'leftDownBody1'
|
||||
dc i4'leftDownBody2'
|
||||
dc i4'leftDownBody1'
|
||||
dc i4'leftDownBody2'
|
||||
dc i4'leftDownBody1'
|
||||
dc i4'leftDownBody2'
|
||||
dc i4'leftDownBody1'
|
||||
dc i4'leftDownBody2'
|
||||
|
||||
|
||||
; downBodyJumpTable
|
||||
dc i4'downBody3'
|
||||
dc i4'downBody3'
|
||||
dc i4'downBody1'
|
||||
dc i4'downBody1'
|
||||
dc i4'downBody2'
|
||||
dc i4'downBody2'
|
||||
dc i4'downBody1'
|
||||
dc i4'downBody1'
|
||||
|
||||
|
||||
; rightDownBodyJumpTable
|
||||
dc i4'rightDownBody1'
|
||||
dc i4'rightDownBody2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownBody1'
|
||||
dc i4'rightDownBody2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownBody1'
|
||||
dc i4'rightDownBody2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownBody1'
|
||||
dc i4'rightDownBody2' ; Problem, spills into next tile...
|
||||
|
||||
|
||||
; rightBodyJumpTable
|
||||
dc i4'rightBody5'
|
||||
dc i4'rightBody4'
|
||||
dc i4'rightBody1'
|
||||
dc i4'rightBody2'
|
||||
@ -168,58 +315,32 @@ rightBodyJumpTable dc i4'rightBody5'
|
||||
dc i4'rightBody1'
|
||||
dc i4'rightBody4'
|
||||
|
||||
|
||||
rightBodyShiftJumpTable dc i4'rightBody5s'
|
||||
dc i4'rightBody4s'
|
||||
dc i4'rightBody1s'
|
||||
dc i4'rightBody2s'
|
||||
dc i4'rightBody3s'
|
||||
dc i4'rightBody2s'
|
||||
dc i4'rightBody1s'
|
||||
dc i4'rightBody4s'
|
||||
|
||||
bodyShiftJumpTable anop
|
||||
; leftBodyShiftJumpTable
|
||||
dc i4'leftBody5s'
|
||||
dc i4'leftBody4s'
|
||||
dc i4'leftBody1s'
|
||||
dc i4'leftBody2s'
|
||||
dc i4'leftBody3s'
|
||||
dc i4'leftBody2s'
|
||||
dc i4'leftBody1s'
|
||||
dc i4'leftBody4s'
|
||||
|
||||
|
||||
leftDownBodyJumpTable dc i4'leftDownBody1'
|
||||
dc i4'leftDownBody2'
|
||||
dc i4'leftDownBody1'
|
||||
dc i4'leftDownBody2'
|
||||
dc i4'leftDownBody1'
|
||||
dc i4'leftDownBody2'
|
||||
dc i4'leftDownBody1'
|
||||
dc i4'leftDownBody2'
|
||||
|
||||
|
||||
leftDownShiftBodyJumpTable dc i4'leftDownBody1s'
|
||||
dc i4'leftDownBody2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownBody1s'
|
||||
dc i4'leftDownBody2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownBody1s'
|
||||
dc i4'leftDownBody2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownBody1s'
|
||||
dc i4'leftDownBody2s' ; Problem, spills into next tile...
|
||||
|
||||
|
||||
rightDownBodyJumpTable dc i4'rightDownBody1'
|
||||
dc i4'rightDownBody2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownBody1'
|
||||
dc i4'rightDownBody2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownBody1'
|
||||
dc i4'rightDownBody2' ; Problem, spills into next tile...
|
||||
dc i4'rightDownBody1'
|
||||
dc i4'rightDownBody2' ; Problem, spills into next tile...
|
||||
|
||||
|
||||
rightDownShiftBodyJumpTable dc i4'rightDownBody1s'
|
||||
dc i4'rightDownBody2s'
|
||||
dc i4'rightDownBody1s'
|
||||
dc i4'rightDownBody2s'
|
||||
dc i4'rightDownBody1s'
|
||||
dc i4'rightDownBody2s'
|
||||
dc i4'rightDownBody1s'
|
||||
dc i4'rightDownBody2s'
|
||||
|
||||
|
||||
downBodyJumpTable dc i4'downBody3'
|
||||
; leftDownShiftBodyJumpTable
|
||||
dc i4'leftDownBody1s'
|
||||
dc i4'leftDownBody2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownBody1s'
|
||||
dc i4'leftDownBody2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownBody1s'
|
||||
dc i4'leftDownBody2s' ; Problem, spills into next tile...
|
||||
dc i4'leftDownBody1s'
|
||||
dc i4'leftDownBody2s' ; Problem, spills into next tile...
|
||||
|
||||
|
||||
; downBodyJumpTable
|
||||
dc i4'downBody3'
|
||||
dc i4'downBody3'
|
||||
dc i4'downBody1'
|
||||
dc i4'downBody1'
|
||||
@ -227,5 +348,28 @@ downBodyJumpTable dc i4'downBody3'
|
||||
dc i4'downBody2'
|
||||
dc i4'downBody1'
|
||||
dc i4'downBody1'
|
||||
|
||||
|
||||
; rightDownShiftBodyJumpTable
|
||||
dc i4'rightDownBody1s'
|
||||
dc i4'rightDownBody2s'
|
||||
dc i4'rightDownBody1s'
|
||||
dc i4'rightDownBody2s'
|
||||
dc i4'rightDownBody1s'
|
||||
dc i4'rightDownBody2s'
|
||||
dc i4'rightDownBody1s'
|
||||
dc i4'rightDownBody2s'
|
||||
|
||||
|
||||
; rightBodyShiftJumpTable
|
||||
dc i4'rightBody5s'
|
||||
dc i4'rightBody4s'
|
||||
dc i4'rightBody1s'
|
||||
dc i4'rightBody2s'
|
||||
dc i4'rightBody3s'
|
||||
dc i4'rightBody2s'
|
||||
dc i4'rightBody1s'
|
||||
dc i4'rightBody4s'
|
||||
|
||||
|
||||
end
|
||||
|
@ -13,6 +13,11 @@
|
||||
segments start
|
||||
using globalData
|
||||
|
||||
; IMPORTANT!!!! - It is critical that the X register is preserved in all of these
|
||||
; draw routines. The caller to this uses the X register to hold the head/segment
|
||||
; number that is being drawn. If the X register is changed in any way, the draw
|
||||
; routine will fail.
|
||||
|
||||
leftHead1 entry
|
||||
_spriteHeader
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user