NintendoAge http://nintendoage.com/forum/ -Sqooner Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T16:43:38 -05.00 bunnyboy 99 Originally posted by: Mega Mario Man

Originally posted by: user
Originally posted by: Piputkin3

I will ask another question, can you determine the sprite rate of less than 1?


Yes, using a further byte of RAM.
Example: you store somewhere (e.g. variable FOO) the value HEX00.
then each NMI you add HEX40 to that variable.
each four MNIs the variable will reach "HEX100" (which is HEX FF+1 ) reset to zero and trigger the carry flag.
When the carry flag is triggered, you advance by 1 pixel.
So, you advance by 1/4 of pixel each NMI.
tell me if this helps.
I think this may be better touched in the 16-bit math section further a long in the tutorials. This is only lesson #4.

But yes, that is a shorter way to do this than what I posted if you are wanting to save cycles and RAM space.
 

Indeed.  
What you say makes perfect sense. And nice from you to write a full routine, I was too lazy.  

In the end, I think that providing Piputkin3 two different solutions, won't hurt!   ]]>
Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T16:06:30 -05.00 bunnyboy 99 Originally posted by: user
 
Originally posted by: Piputkin3

I will ask another question, can you determine the sprite rate of less than 1?


Yes, using a further byte of RAM.
Example: you store somewhere (e.g. variable FOO) the value HEX00.
then each NMI you add HEX40 to that variable.
each four MNIs the variable will reach "HEX100" (which is HEX FF+1 ) reset to zero and trigger the carry flag.
When the carry flag is triggered, you advance by 1 pixel.
So, you advance by 1/4 of pixel each NMI.
tell me if this helps.   I think this may be better touched in the 16-bit math section further a long in the tutorials. This is only lesson #4.   

But yes, that is a shorter way to do this than what I posted if you are wanting to save cycles and RAM space.

  ]]>
Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T16:03:12 -05.00 bunnyboy 99 Originally posted by: Piputkin3

I will ask another question, can you determine the sprite rate of less than 1?
Yes. Instead of moving 1 pixel per frame, you move 1 pixel every other frame, every third frame, etc. However slow you want it to go.

The way I would tackle this by using a counter variable to skip frames.

;Variables
MissileSpeedCounter   .rs 1

;Code to Move Missile
INC MissileSpeedCounter      
LDA MissileSpeedCounter
CMP #$02                           ;Adjust this value depending on how many frames you want to skip, here I'm going every other frame. You can use a variable here if you want different speeds
BNE .SkipMoveMissile         ;Skip moving the missile this frame if not equal to #$02
     LDA $0210
     CLC
     ADC #$01
     STA $0210        ;Move Missile 1 pixel
    
     LDA #$00
     STA MissileSpeedCounter         ; Reset counter back to #$00
.SkipMoveMissile :



  ]]>
Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T15:57:47 -05.00 bunnyboy 99 Originally posted by: Piputkin3

I will ask another question, can you determine the sprite rate of less than 1?

Yes, using a further byte of RAM.
Example: you store somewhere (e.g. variable FOO) the value HEX00.
then each NMI you add HEX40 to that variable.
each four MNIs the variable will reach "HEX100" (which is HEX FF+1 ) reset to zero and trigger the carry flag.
When the carry flag is triggered, you advance by 1 pixel.
So, you advance by 1/4 of pixel each NMI.
tell me if this helps.   ]]>
Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T15:40:13 -05.00 bunnyboy 99 Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T15:16:22 -05.00 bunnyboy 99 Originally posted by: Piputkin3

It's slower than ADC #$01? With what I posted, the Missile is 2x faster than the character. I hope that is what you are asking, I'm not sure what "It" is.

  ]]>
Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T14:52:13 -05.00 bunnyboy 99 Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T11:50:14 -05.00 bunnyboy 99 Originally posted by: Mega Mario Man

Just have the sprite move more pixels per frame.

If your character is moving 1 pixel per frame, increment the missile to move 2 pixels per frame.

Example for:
Character
LDA $0200
CLC
ADC #$01
STA $0200

Missile:
LDA $0210
CLC
ADC #$02 ;Twice as fast
STA $0210

To build on this, you can use a variable and change the speed of the missile before moving it x or y pixels per frame.

;In Variables Area
MissileSpeed    .rs 1

;Changing Missile speed in code for whatever reason
LDA #$02          ;You can load this with whatever number you want based on things
STA MissileSpeed

;Adjusting the speed of the missile (assuming $0210 is the direction the missile is moving)
LDA $0210
CLC
ADC MissileSpeed                 ;Move sprite this many pixels
STA $0210


2x Character Speed
If you want the missile to be twice as fast as the character, you can do this.

;In Variables Area
CharacterSpeed    .rs 1
MissileSpeed    .rs 1

;Changing Missile speed in code for whatever reason
LDA CharacterSpeed             ;Current number of pixel per frame the character is moving
CLC
ADC CharacterSpeed 
STA MissileSpeed                 ;CharacterSpeed + CharacterSpeed = MissileSpeed

;Adjusting the speed of the missile (assuming $0210 is the direction the missile is moving)
LDA $0210
CLC
ADC MissileSpeed                 ;Move sprite this many pixels
STA $0210 ]]>
Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T11:33:46 -05.00 bunnyboy 99
If your character is moving 1 pixel per frame, increment the missile to move 2 pixels per frame.

Example for:
Character
LDA $0200
CLC
ADC #$01
STA $0200

Missile:
LDA $0210
CLC
ADC #$02 ;Twice as fast
STA $0210 ]]>
Nerdy Nights week 4 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=6082 2017-04-27T10:40:19 -05.00 bunnyboy 99
Eg. The character is at the speed x, ap the missile fired at a speed of 2x. Is it possible to set it somehow ]]>