-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
The Dispatcher
https://github.com/oisee/antique-toy/blob/main/chapters/ch18-gameloop/draft.md#the-dispatcher
The HL = game_state + A part can be optimized from 45T...
; Dispatch to current state handler (original)
ld a, (game_state) ; 13T load state index
ld l, a ; 4T
ld h, 0 ; 7T
ld de, state_table ; 10T
add hl, de ; 11T HL = state_table + offset...to a slightly faster (42T) and slightly longer (1B):
; Dispatch to current state handler
ld hl, state_table
ld a, (game_state)
add l
ld l, a
jr nc, .else
inc h
.else:Iterating Entities
https://github.com/oisee/antique-toy/blob/main/chapters/ch18-gameloop/draft.md#iterating-entities
; Check if entity is active
ld a, (ix + 9) ; 19T load flags byte (offset +9)
bit 0, a ; 8T test ACTIVE flag
jr z, .skip ; 12/7T skip if inactiveCan be rewritten as:
; Check if entity is active
bit 0, (ix + 9) ; 20T test ACTIVE flag of flags byte (offset +9)
jr z, .skip ; 12/7T skip if inactiveSaving 7T per entity (112T in total for 16 entities).
Update Dispatch by Type
Same optimization for HL = type_handlers + A as the one mentioned for The Dispatcher. Saves 3T per entity (48T in total for 16 entities).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels