It is currently Wed Oct 23, 2019 7:36 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Mon Jun 03, 2019 11:31 pm 
Offline
User avatar

Joined: Fri Jan 24, 2014 9:05 am
Posts: 193
Location: Hungary
Yesterday as I was trying to figure out a way to efficiently create multiple "forks" of the same enemies that would behave differently based on their ID, I've come across the need to pass one of multiple sets of arguments to my function that handles sine-wave motion. Since the enemy needs to find its own ID and figure out which of the three possible versions it is, I decided to use a copy of the CPU flags after comparison, because the Z and C flags are conveniently placed in the low two bits.

Code:
lda objIDslot+0,x ; X = current index into the list of active entities
cmp obj_windeagleV2
php
pla
clc
adc #$01 ; correction to 01/00/10, as ZC after the comparison would result in either 00, 11 ,or 01, but not 10
and #$03
tay
;... read the arguments from arrays for each argument


Is there perhaps a more efficient way to do this sort of thing? Most places I've read about this tell you to pass the address of the right array, but one array per argument seems better suited for the 6502.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group