Re: [stella] My code is broked!

Subject: Re: [stella] My code is broked!
From: "Chris Larkin" <clarkin@xxxxxxxxxxxxx>
Date: Wed, 8 Oct 2003 16:13:48 -0700
There are four players in the game.  So in order for a trade hands
subroutine to work the current player's hand RAM location, and the chosen
players hand RAM location should be stored into pointers.

The LDA #PlayerHand/#Player3 code is not really there in the main code, it
is simply how I could demonstrate in the email what I was trying to do
without including the code that determines wihch player's hands to use.

In the real code tmpVar3 and tmpVar4 could point to any one of the four
player hand locations, thus the need for pointers.

Sorry for not making that clear in the original email :-)

Thanks for the help!

--Chris


----- Original Message -----
From: "Christopher Tumber" <christophertumber@xxxxxxxxxx>
To: <stella@xxxxxxxxxxx>
Sent: Tuesday, October 07, 2003 10:31 PM
Subject: Re: [stella] My code is broked!


>
> >I know this loop does not replace the first byte in either location, but
it should "swap" the others... However
> >my results are not very good :-) What am I doing wrong?
>
> As Jason said, pointers are two bytes and you're only initialising the
lower byte.
>
> But, am I missing something here, you're just swapping two 7 byte long
buffers, right? These buffers are permanently anchored in RAM, right? So why
are you using indirection? (just for the sake of using indirect addressing?)
You don't need the flexibility of being able to select between several
buffers or allocate buffers dynamically, do you?
>
> Why not just do something like:
>
>  ldx #7
> next_switch:
>  ldy PlayerHand,x
>  lda Player3,x
>  sta PlayerHand,x
>  sty Player3,x
>  dex
>  bpl next_switch
>
> Unless you've only got one X/Y register avalable, in which case you can
just sub in a temporary variable:
>
>  ldx #7
> next_switch:
>  lda PlayerHand,x
>  sta Temp
>  lda Player3,x
>  sta PlayerHand,x
>  lda Temp
>  sta Player3,x
>  dex
>  bpl next_switch
>
>
> Chris...
>
> --------------------------------------------------------------------------
--------------------
> Archives (includes files) at http://www.biglist.com/lists/stella/archives/
> Unsub & more at http://www.biglist.com/lists/stella/
>

----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread