Skip to content
Permalink
Browse files

Rename tryToActivateAgain entity list to activateNextFrame

`activateNextFrame` is more descriptive of what the list does than
`tryToActivateAgain`.
  • Loading branch information
undisbeliever committed Oct 23, 2018
1 parent 3056d75 commit 1106b89858b2826eb52b39d17542abc008ace585
@@ -131,8 +131,8 @@ namespace Entity {
// A) Entities that could not be activated in the previous
// frame, and
// B) Newly spawned active entities.
allocate(tryToActivateAgain, wram7e, 2)
constant _TRY_TO_ACTIVATE_AGAIN_INDEX = tryToActivateAgain - FIRST
allocate(activateNextFrame, wram7e, 2)
constant _ACTIVATE_NEXT_FRAME_INDEX = activateNextFrame - FIRST

// Unallocated Entities
allocate(free, wram7e, 2)
@@ -58,7 +58,7 @@ function Init {

// Ensure free list is the last one
assert(lists.deactivated < lists.free)
assert(lists.tryToActivateAgain < lists.free)
assert(lists.activateNextFrame < lists.free)
assert(lists.LAST < lists.free)

lda.w lists.free
@@ -74,16 +74,16 @@ function Init {



// Clear the TryToActivateAgain entity list
// Clear the activateNextFrame entity list
//
// Should be called at the start of each level
//
// REQUIRES: 16 bit A, 16 bit Index, DB = 0x7e, DP = 0
a16()
i16()
code()
function ClearTryToActivateAgainList {
lda.w lists.tryToActivateAgain
function ClearActivateNextFrameList {
lda.w lists.activateNextFrame
beq Return

Loop:
@@ -98,15 +98,15 @@ function ClearTryToActivateAgainList {
bne Loop


// Move the tryToActivateAgain list into the free list
// Move the activateNextFrame list into the free list

lda.w lists.free
sta.b BaseEntity.next

lda.w lists.tryToActivateAgain
lda.w lists.activateNextFrame
sta.w lists.free

stz.w lists.tryToActivateAgain
stz.w lists.activateNextFrame


lda.w #0
@@ -13,7 +13,7 @@ namespace Entity {

// Counts the number of enemies of a specific Id
//
// This routine will also search the deactivated and tryToActivateAgain entity
// This routine will also search the deactivated and activateNextFrame entity
// lists.
//
// This routine SHOULD ONLY be called on entities that will not change its
@@ -39,7 +39,7 @@ allocateTmpWord(tmp_count)
jsr _TestList
ldx.w Entity.lists.deactivated
jsr _TestList
ldx.w Entity.lists.tryToActivateAgain
ldx.w Entity.lists.activateNextFrame
jsr _TestList

lda.w tmp_count
@@ -7,8 +7,8 @@
// * Process all active entities' Process routine
// * Entity Collision detection
// * Animate all active entities
// * Activate entities in the `Entity.activateNextFrame` list
// * Activate entities that enter the active window
// * Activate entities in the `Entity.tryToActivateAgain` list
// * Delete all entities in the `Entity.toDelete` list
//
//
@@ -32,7 +32,7 @@ namespace Entity {


// Previous entity being processed
// Used in TryToActivateAgain, ProcessActiveWindow and the entity loop.
// Used in _ProcessActivateNextFrameList, _ProcessActiveWindow and the entity loop.
// (word address)
allocateTmpWord(_previousEntity)

@@ -135,26 +135,26 @@ macro __ChangeEntityList_Y() {
}


// Processes the tryToActivateAgain entity list
// Processes the activateNextFrame entity list
//
// For each entity in the list it will try to reactivate the entity and
// if it succeeds move it into its designated entity list.
//
// REQUIRES: 16 bit A, 16 bit Index, DB = 0x7e
//
// MODIFIES: DP
inline _ProcessTryToActivateAgainList() {
inline _ProcessActivateNextFrameList() {
assert16a()
assert16i()

function ProcessTryToActivateAgainList {
lda.w lists.tryToActivateAgain
function ProcessActivateNextFrameList {
lda.w lists.activateNextFrame
beq EndLoop

// this allows _previousEntity variable to work on first item
assert(BaseEntity.next == 0)

ldy.w #lists.tryToActivateAgain
ldy.w #lists.activateNextFrame
sty.w _previousEntity

Loop:
@@ -194,7 +194,7 @@ inline _ProcessTryToActivateAgainList() {
__ChangeEntityList_Y()
// A = next entity address
// z set if there are no more entities in the current list
// MUST NOT CHANGE _previousEntity as the entity is no longer in the tryToActivateAgain list
// MUST NOT CHANGE _previousEntity as the entity is no longer in the activateNextFrame list

bne Loop

@@ -254,7 +254,7 @@ inline _ProcessActiveWindow() {

// Could not activate the entity.
// Try again in the next frame.
ldy.w #lists._TRY_TO_ACTIVATE_AGAIN_INDEX
ldy.w #lists._ACTIVATE_NEXT_FRAME_INDEX
bra _ChangeEntityList_Y


@@ -418,7 +418,7 @@ code()
function ProcessGameLoop {
jsr _UpdateActiveWindows

_ProcessTryToActivateAgainList()
_ProcessActivateNextFrameList()

_ProcessActiveWindow()

@@ -136,14 +136,14 @@ allocateTmpWord(yPos)
SkipActiveWindowTest:
// We cannot move the entity into its entity list while
// the entity-loop is running.
// Instead we move it to the `tryToActivateAgain` list,
// Instead we move it to the `activateNextFrame` list,
// where it will be activated and moved to the correct
// entity list at the start of the next frame.

lda.w lists.tryToActivateAgain
lda.w lists.activateNextFrame
sta.b BaseEntity.next
tdc
sta.w lists.tryToActivateAgain
sta.w lists.activateNextFrame

bra EndIf

@@ -490,14 +490,14 @@ SpawnProjectile:

// We cannot move the entity into its entity list while the
// entity-loop is running.
// Instead we move it to the `tryToActivateAgain` list, where it
// Instead we move it to the `activateNextFrame` list, where it
// will be activated and moved to the correct entity list at the
// start of the next frame.

lda.w lists.tryToActivateAgain
lda.w lists.activateNextFrame
sta.b BaseEntity.next
tdc
sta.w lists.tryToActivateAgain
sta.w lists.activateNextFrame

ldx.w MetaSprite.ActionPoint.address

@@ -25,12 +25,12 @@ function _DeactivatedListLength {
}

// REQUIRES: 16 bit A, 16 bit Index, DB = 0x7e
// OUT: A = number of entities in the tryToActivateAgain list
// OUT: A = number of entities in the activateNextFrame list
a16()
i16()
code()
function _TryToActivateAgainListLength {
ldx.w #Entity.lists._TRY_TO_ACTIVATE_AGAIN_INDEX
function _ActivateNextFrameListLength {
ldx.w #Entity.lists._ACTIVATE_NEXT_FRAME_INDEX
jmp Entity._CountEntitiesInListIndexX
}

@@ -87,7 +87,7 @@ allocateTmpWord(tmp_count)
}

_TestDeactivated(deactivated)
_TestDeactivated(tryToActivateAgain)
_TestDeactivated(activateNextFrame)


// test all other entities are active
@@ -28,8 +28,8 @@ Fail:
a16()
i16()
code()
Test.add("Entities.ClearTryToActivateAgainList")
function ClearTryToActivateAgainList {
Test.add("Entities.ClearActivateNextFrameList")
function ClearActivateNextFrameList {
constant tmp = Test.tmp

jsr Entity.Init
@@ -59,12 +59,12 @@ constant tmp = Test.tmp
bcc Loop


jsr _TryToActivateAgainListLength
jsr _ActivateNextFrameListLength
cmp.w #Entity.lists.N_LISTS
bne Fail


jsr Entity.ClearTryToActivateAgainList
jsr Entity.ClearActivateNextFrameList


jsr _FreeListLength
@@ -186,8 +186,8 @@ Fail:
a16()
i16()
code()
Test.add("Entity.GameLoop.TryToActivateAgain")
function GameLoop_TryToActivateAgain {
Test.add("Entity.GameLoop.ActivateNextFrame")
function GameLoop_ActivateNextFrame {
constant tmp = Test.tmp

jsr Entity.Init
@@ -217,7 +217,7 @@ constant tmp = Test.tmp
bcc Loop


jsr _TryToActivateAgainListLength
jsr _ActivateNextFrameListLength
cmp.w #Entity.lists.N_LISTS
bne Fail

@@ -247,7 +247,7 @@ constant tmp = Test.tmp

jsr Entity.ProcessGameLoop

jsr _TryToActivateAgainListLength
jsr _ActivateNextFrameListLength
cmp.w #0
bne Fail

0 comments on commit 1106b89

Please sign in to comment.
You can’t perform that action at this time.