Re: [stella] Unending VDEL hell

Subject: Re: [stella] Unending VDEL hell
From: Thomas Jentzsch <tjentzsch@xxxxxx>
Date: Mon, 29 Apr 2002 20:41:14 +0200
At 29.04.2002, 09:49, Glenn Saunders wrote:
> Well, I give up.

> I tried to take Thomas' suggestions from a while back and implement them as 
> literally as I could, and no matter what I do I either get 1-scanline 
> precision with the 2nd car down a line or both cars offset by 2 scanlines 
> or on the same scanline but animating in 2-scanline jumps.

There are multiple errors in that VDEL code, so by try and error it is
nearly impossible to solve them.

Here is your code:
    LDA P0_YFullres         ;of player position
    EOR #1
    ; IF ODD,THEN VDEL
    BNE .SetVDELP0
    LDA 1
    JMP .ClearVDELP0
.SetVDELP0
    LDA 0
.ClearVDELP0
    STA VDELP0

    LDA P1_YFullres         ;of player position
    EOR #1
    BNE .SetVDELP1
    LDA 0
    JMP .ClearVDELP1
.SetVDELP1
    LDA 1
.ClearVDELP1
    STA VDELP1

Here are the bugs:
1. you must add AND #1 before or after both EORs, or the branches won't
work 
2. instead of LDA 0 or LDA 1, you must write LDA #0 or LDA #1, else you
will read the first two collision registers. I can't count, how often I
made the very same error too :-)
3. the values for P0 are swapped

That how it should look like:
    LDA P0_YFullres         ;of player position
    EOR #1
    AND #1
    ; IF ODD,THEN VDEL
    BNE .SetVDELP0
    LDA #0
    JMP .ClearVDELP0
.SetVDELP0
    LDA #1
.ClearVDELP0
    STA VDELP0

    LDA P1_YFullres         ;of player position
    EOR #1
    AND #1
    BNE .SetVDELP1
    LDA #0
    JMP .ClearVDELP1
.SetVDELP1
    LDA #1
.ClearVDELP1
    STA VDELP1

Then I have cleared the code a "bit", especially by removing the branches.
They are unnecessary, the EOR #1 does the job alone. And when you don't
need the branches anymore, you can remove the now missing ANDs too. Here
is the stunning simple result:

    LDA P0_YFullres     ;of player position
    EOR #1
    STA VDELP0          ;don't care for the bits 1..7, VDEL ignores them

    LDA P1_YFullres     ;of player position
    EOR #1
    STA VDELP1

I hope that helps.

Have fun!
Thomas                            
_______________________________________________________
Thomas Jentzsch         | *** Every bit is sacred ! ***
tjentzsch at web dot de |

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


Current Thread