Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIRROR_VERTICAL only works if y < 8 #3

Open
city41 opened this issue Aug 26, 2018 · 0 comments
Open

MIRROR_VERTICAL only works if y < 8 #3

city41 opened this issue Aug 26, 2018 · 0 comments

Comments

@city41
Copy link

city41 commented Aug 26, 2018

Using ArdBitmap 2.0.3

I find if y goes to 8 or above, then the vertically mirrored sprite gets corrupted. In this program pressing up/down changes y, and the number printed on the screen is the current y:

aty7

y=7, no problem

aty8

at y=8, the sprite gets halfway corrupted.

aty16

at y=16 and above, the sprite gets fully corrupted. The corruption changes with every multiple of 8 on y.

The corruption occurs in the ProjectABE emulator and also on a real ArduBoy.

Here is the program:
https://gist.github.com/city41/14f5eb8c15a131f128b62ebddde950c5

Fix to the problem

I found in ArdBitmap.h, if I remove the else statement here, then the problem goes away. So change this:

  if (mirror & MIRROR_VERTICAL) {
    bofs += (loop_h - 1) * w;
    if (y < 0){
      bofs -=  (start_h * w);
    } else {
      bofs +=  (sRow  * w);
    }
  }

to this:

  if (mirror & MIRROR_VERTICAL) {
    bofs += (loop_h - 1) * w;
    if (y < 0){
      bofs -=  (start_h * w);
    }
  }

I have tested this change with sprites of various sizes and all values for y and have not found a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant