Subject: Re: [stella] Sprites source code From: Nick S Bensema <nickb@xxxxxxxxxxxx> Date: Thu, 6 Mar 1997 13:53:35 -0700 (MST) |
>- Do you think that a different way of storing X coordinates might lead to >a more efficient code during screen drawing? For example: > >7 6 5 4 3 2 1 0 >f f f f c c c c > >bits 0-3 = course position, to be used in a DEY-BPL loop for course positioning > > LDA XPOS > AND #$0F > TAY >loop: > DEY > BPL loop > >bits 4-7 = fine motion value, to be stored to HMPx > > LDA XPOS > STA HMP0 The real X-value, according to you, would be 15*fine + coarse. Considering the nature of the horizontal motion registers, where bit 3 equals -8, it would be far from linear in nature without a few adjustments. Unmodified, 0 stays 0, and 1 stays 1, but 15 becomes -1 and 14 becomes -2 and so forth. The values would go like this. 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 <-XPOS 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 15 15 15 <-coarse +0 +1 +2 +3 +4 +5 +6 +7 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 <-fine 0 1 2 3 4 5 6 7 -8 -7 -6 -5 -4 -3 -2 -1 15 16 17 18 19 20 <-Position Though it could be as simple as this: LDA XPOS LSR LSR ;You forgot to shift the bits LSR ;to where Hmove will see it! LSR EOR #8 ;Toggle bit 3 STA HMP0 00 01 02 03 04 05 06 07 08 09...0D 0E 0F 10 11 12...1E 1F 20 21 <-XPOS 08 09 0A 0B 0C 0D 0E 0F 00 01...05 06 07 18 19 1A...16 17 28 29 <-EOR 8 0 0 0 0 0 0 0 0 0 0... 0 0 0 15 15 15...15 15 30 30 <-coarse -8 -7 -6 -5 -4 -3 -2 -1 +0 +1...+5 +6 +7 -8 -7 -6...+6 +7 -8 -7 <-fine -8 -7 -6 -5 -4 -3 -2 -1 0 1... 5 6 7 7 8 9...21 22 22 23 <-Position Brilliant! It works.... sort of. It still sort of "trips over" that 15 there, but it's accurate enough for most purposes. There certainly isn't much danger of erratic jerking around, it'll just snag on every 15 pixels. In real life, the left side of the screen is 0 and the right side of the screen is 152 (160-8). Here, the left side of the screen is 8 (eight), and the right side of the screen... uh, I'll figure it out later. -- To unsubscribe, send the word UNSUBSCRIBE in the body of a message to stella-request@xxxxxxxxxxx
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] Sprites source code, Piero Cavina | Thread | Re: [stella] Sprites source code, Bob Colbert |
[stella] Special VCS emulator, Dan Boris | Date | Re: [stella] discovering the tricks, Bob Colbert |
Month |