Re: [stella] AOTM AFOS problems

Subject: Re: [stella] AOTM AFOS problems
From: Erik Mooney <erik@xxxxxxxxxx>
Date: Thu, 01 Jul 2004 00:19:43 -0400
On Thu, 1 Jul 2004 01:57:30 +0200, you wrote:

>I attach the code, and the place where all trouble began is commented "HERE BEGINS THE PROBLEM".

When in doubt, don't guess at the cycles.  Count them.  Here's your code
with cycle counts added.  You can see it's running a total of 92 cycles
per loop iteration, which is of course over the limit of 76.  You can also
see that the version without the UFO ran right up to 71 cycles, so adding
anything to that would make it spill over.


Line                ;here the actual line begins
    STA WSYNC

    LDA Game_On         ;+3  3
    BNE No_Position     ;+2  5
    STA RESP0           ;+3  8
    INC Game_On         ;+5 13

No_Position

    LDA Ufo_Buffer      ;+3 16
    STA GRP1            ;+3 19
    LDA Player_Missile_Buffer ;+3 22
    STA ENAM0           ;+3 25


UFoActive               ;check if the ufo is active in this line

    
    SEC                 ;+2 27
    TXA                 ;+2 29
    SBC Ufo_Y           ;+3 32  
    ADC #12             ;+2 34  
    BCC EndOfDrawingUfo ;+2 36
   
    CLC                 ;+2 38
    ADC Ufo_Frame_Offset;+3 41

    TAY                 ;+2 43
    LDA (Ufo_Sprite_Ad),Y;+5 48
    STA Ufo_Buffer      ;+3 51

EndOfDrawingUfo 

MissileActive

    LDY #0              ;+2 53

    SEC                 ;+2 55
    TXA                 ;+2 57
    SBC Player_Missile_Y;+3 60
    ADC #6              ;+2 62
    BCC No_Missile      ;+2 64
    LDY #2              ;+2 66

No_Missile
    STY Player_Missile_Buffer;+2 69
                        ;When I made similar buffer for ufo missile
                        ;the ufo began to act strangely (it jumped
                        ;to another h-pos from time to time)
    ;DEX                    ;don't know what's wrong with this code?
    ;STA WSYNC              ;in the first version of the game
                        ;it was much longer


UfoMissileActive
    LDY #0              ;+2 71
    SEC                 ;+2 73
    TXA                 ;+2 75
    SBC Ufo_Missile_Y   ;+3 78
    ADC #6              ;+2 80
    BCC SkipUfoMissileActive ;+2 82
    LDY #2              ;+2 84

SkipUfoMissileActive
    
    STY ENAM1           ;+3 87
    DEX                 ;+2 89
    
    BNE Line            ;+3 92 (when branch taken)
    RTS



Current Thread