marioballano / emudore

emudore, a Commodore 64 emulator
Apache License 2.0
303 stars 21 forks source link

Double height sprites #8

Closed xlar54 closed 6 years ago

xlar54 commented 6 years ago

This one was a bit of a brain teaser until it just kind of hit me. Your code is soooooo close to having it. Here's the updated function to provide it. I havent tested multicolor (although should work) or collisions yet though.

(Also sorry Im not sending pull requests. I working from my codebase which is obviously modified for the operating system)

void Vic::draw_raster_sprites() { if(spriteenabled != 0) { int rstr = raster_counter(); int y = rstr - kFirstVisibleLine; int sp_y = rstr - kSpritesFirstLine; / loop over sprites reverse order / for(int n=7; n >= 0 ; n--) { int height = is_double_height_sprite(n) ? kSpriteHeight 2 : kSpriteHeight; / check if the sprite is visible */ if(is_sprite_enabled(n) && spy >= my[n] && spy < my[n] + height) { int row = 0; //spy - my[n];

if(is_double_height_sprite(n))
  row = (int)(sp_y-my_[n]) / 2;
else
  row = sp_y - my_[n];

    int x = kSpritesFirstCol + sprite_x(n);
    if(is_multicolor_sprite(n))
    {
      draw_mcsprite(x,y,n,row);
    }
    else
    {
  draw_sprite(x,y,n,row);
    }
  }
}

} }

xlar54 commented 6 years ago

capture

marioballano commented 6 years ago

multicolor should work, if my memory serves me right I did test it, sprite collisions are not implemented yet but that shouldn't be too hard to do, I kind of left the project on hold for some time but let's see if we can keep fixing/adding some of these features :)

btw, do you have the prg you used to test double height sprites handy?, I may actually add some of these tests to the repo if that's okay with you.

marioballano commented 6 years ago

btw, don't worry about the pull requests!

xlar54 commented 6 years ago

Below is the test program. Two versions - one is the raw binary to load to $0801, the other is a header file that put directly into memory. If you use the header, i think you have to do a CLR and then poke to locations 45/46 for the beginning of string RAM.

sprite.zip

marioballano commented 6 years ago

thanks Scott, uhm.. I think this should be fixed now in commit caa1bc5abb425fc2710188b86955da704042bb37, I didn't get it to work with your prg though, perhaps the sprite is not set to double height?

xlar54 commented 6 years ago

I dont think the program sets it to double height. That POKE (on the screenshot) should enable double height for all the sprites (the one that sets it to 255). also a separate fix i sent for double width as well.

Again, sorry to flood you - Im bouncing around from task to task, but I wanted to give back to your code as I make changes. Your core is very readable and easy to work with so it really has been great working with it.

And my repo is up to date if you think I may have missed sending you some vital code, you can check there also if needed. I had a few folks telling me that the new build doesnt work on their machines so Im thinking the multiboot 800x600 res is the issue. Work continues.. but its quite fun.

marioballano commented 6 years ago

ouch!, the problem is that I'm launching the PRGs from command line and I can't enter any manual POKEs before loading it, anyhow.. I should be able to work around this with the r2 debugging interface..

btw, don't worry about the flood, it's actually cool that the code came in handy to someone else, I'm more than happy to fix these bugs here, sounds like you're having a lot of fun :)

btw, I've also checked your repo, and will be keeping an eye, but feel free to keep posting issues here, it pushes me to fix them haha :)

marioballano commented 6 years ago

fixed and tested with debugger