Mario Sprites Problem

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Mario Sprites Problem
by on (#713)
i have problems emulating super mario bros.
Mario sprites itself goes to position x = 0 after scrolling 128 pixels, and after that mario's sprites are animated but i cant move it.

Help please :(

by on (#718)
Sounds like it could be a CPU bug. Do other games work ok?

by on (#720)
Sounds almost like a V flag problem (bad wrapping at 128 could be because the V flag is being set wrong on ADC/SBC)

Double check your ADC/SBC. For ADC... the V flag should be set when:

Positive + Positive = Negative
or
Negative + Negative = Positive

In all other instances of ADC, the V flag should be cleared.


Likewise for SBC... V flag is set when:

Positive - Negative = Negative
or
Negative - Positive = Positive

by on (#721)
You can make SBC always work by implementing SBC in terms of ADC: load the operand from memory as normal, invert it (^ 0xff), and then do your ADC code. Reducing complexity of your emulator's 6502 core is a good thing.
Nestress
by on (#724)
I have tested my cpu with nestress rom and it throw me all "ok"
do i have to trust in that?

Thanks

by on (#725)
Do not trust it; I'm pretty sure there is something wrong with your ADC and SBC code (V flag).
adc implementation
by on (#726)
sure, thanks i will try

by on (#735)
tepples wrote:
You can make SBC always work by implementing SBC in terms of ADC: load the operand from memory as normal, invert it (^ 0xff), and then do your ADC code. Reducing complexity of your emulator's 6502 core is a good thing.


Really? That's pretty good...
Is there any other similar case?

by on (#738)
Fx3 wrote:
Really? That's pretty good...
Is there any other similar case?


Fx3 if you read carefully Mos 6502 manual, it says that the processor is always really adding. It inverts the bytes of the source, add carry and then add. :D

by on (#755)
Anes wrote:
Fx3 wrote:
Really? That's pretty good...
Is there any other similar case?


Fx3 if you read carefully Mos 6502 manual, it says that the processor is always really adding. It inverts the bytes of the source, add carry and then add. :D


Actually, it inverts the BITS of the data (byte)... :roll: