Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 1106b89
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/entity/_variables.inc
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions src/entity/allocation.inc
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/entity/counters.inc
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/entity/gameloop.inc
Expand Up @@ -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
//
//
Expand All @@ -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)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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


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

_ProcessTryToActivateAgainList()
_ProcessActivateNextFrameList()

_ProcessActiveWindow()

Expand Down
12 changes: 6 additions & 6 deletions src/entity/spawn.inc
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions unit_tests/src/tests/entity/_common.inc
Expand Up @@ -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
}

Expand Down Expand Up @@ -87,7 +87,7 @@ allocateTmpWord(tmp_count)
}

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


// test all other entities are active
Expand Down
8 changes: 4 additions & 4 deletions unit_tests/src/tests/entity/allocation.inc
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions unit_tests/src/tests/entity/gameloop.inc
Expand Up @@ -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
Expand Down Expand Up @@ -217,7 +217,7 @@ constant tmp = Test.tmp
bcc Loop


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

Expand Down Expand Up @@ -247,7 +247,7 @@ constant tmp = Test.tmp

jsr Entity.ProcessGameLoop

jsr _TryToActivateAgainListLength
jsr _ActivateNextFrameListLength
cmp.w #0
bne Fail

Expand Down

0 comments on commit 1106b89

Please sign in to comment.