Jump to content
IGNORED

Sprite scaling


Ecernosoft

Recommended Posts

By the way, is there a way to get around the "Jumping"?

 

 

 

Main reason is because in my future games, I want to have "ECERNOSOFT" appear using vertical sprite scaling, thought it'd be cool.

 

 

Some more tests.....

Sprite_scaling (4).a26; Seizure warning!!!

Sprite_scaling (2).dasm; A little better? This is source code though.

Sprite_scaling (3).dasm

Sprite_scaling (5).a26; This and the above are both the same but this is much better

Sprite_scaling (2).dasm

Edited by Ecernosoft
Link to comment
Share on other sites

What kind of effect are you trying to create? I looked through the code, but couldn't really understand what's intended.

 

Are you hoping to smoothly scale the text in the vertical dimension to any arbitrary height? I might suggest keeping a vertical coordinate in 8.8 fixed point. On every scan line, use the integer part to index into your logo data, then add a fractional delta value. That should enable you to get smooth scaling without jumpiness. Here's some untested code:

 

        lda #42 ; change this value for different scaling
        sta Vpos_scale
        lda #0
        sta Vpos_lo
        sta Vpos_hi
        ldy #192

Count	
        ldx Vpos_hi
        lda Logo,x
        sta PF1
        sta PF2

        lda Vpos_lo
        clc
        adc Vpos_scale
        sta Vpos_lo
        lda Vpos_hi
        adc #0
        sta Vpos_hi

        dey
        sta WSYNC
        bne Count

 

  • Like 3
Link to comment
Share on other sites

3 hours ago, bigmessowires said:

What kind of effect are you trying to create? I looked through the code, but couldn't really understand what's intended.

 

Are you hoping to smoothly scale the text in the vertical dimension to any arbitrary height? I might suggest keeping a vertical coordinate in 8.8 fixed point. On every scan line, use the integer part to index into your logo data, then add a fractional delta value. That should enable you to get smooth scaling without jumpiness. Here's some untested code:

 

        lda #42 ; change this value for different scaling
        sta Vpos_scale
        lda #0
        sta Vpos_lo
        sta Vpos_hi
        ldy #192

Count	
        ldx Vpos_hi
        lda Logo,x
        sta PF1
        sta PF2

        lda Vpos_lo
        clc
        adc Vpos_scale
        sta Vpos_lo
        lda Vpos_hi
        adc #0
        sta Vpos_hi

        dey
        sta WSYNC
        bne Count

 

Yes!!
That is what I'm trying to do.

 

 

Like, in NEO GEO how the logo for it sort of "Stretches into existance".

That's what I'm trying to do. 

 

Edit: *tests code*

Thanks! 

 

(Part of this is because as a fun little thing, I thought I'd design my own video chip, and one of the things I'd like would be vertical scaling, and possibly horizontal too.)

Edited by Ecernosoft
Link to comment
Share on other sites

Honestly I might be able to have a kernal with scaling for the background thanks to this!

 

 

Big thanks to @splendidnut!

 

Though how exactly does this work?

 

Edit: and will this work on the 5200/8bit using the vertical scroll register?

Edited by Ecernosoft
Link to comment
Share on other sites

3 hours ago, splendidnut said:

Not sure what I did... It was @bigmessowires who provided something for you to try.  I was in the process of writing a response when he beat me to it.

Lol oops!

 

 

 

Big thanks to @bigmessowires! Lol oops.

 

Edit: I added the full logo........ unfortunately since the different sections of the logo are stored sequentially it looks sort of garbled.

Sprite_scaling (4).dasm; Source code

Sprite_scaling (6).a26; hmmm... I wonder what this does. :D 

 

 

Edit 2: I'm also going to port it to the 5200 and hopefully the 7800. 5200 won't be that hard as I can just use the 4 players to act "like" PF1, PF2, PF1', and PF2'.

7800 unfortunately doesn't use players or the playfeild so I'll have to use CHARBASE and that might require completely new code.

Edited by Ecernosoft
Link to comment
Share on other sites

The example code I posted works, but the final height of the logo is inversely proportional to Vpos_scale. So if you change Vpos_scale linearly like in my example, the logo height changes non-linearly, and it looks a little strange. Here's some code that corrects for this by changing the logo height linearly, and using a look-up table to determine the right Vpos_scale value needed to get the desired height. The logo doesn't scale quite as smoothly at large logo heights though. I think you'd need to go to 8.16 fixed point format to get totally smooth scaling using this technique.

 

vscale.dasm

  • Like 1
Link to comment
Share on other sites

3 hours ago, bigmessowires said:

The example code I posted works, but the final height of the logo is inversely proportional to Vpos_scale. So if you change Vpos_scale linearly like in my example, the logo height changes non-linearly, and it looks a little strange. Here's some code that corrects for this by changing the logo height linearly, and using a look-up table to determine the right Vpos_scale value needed to get the desired height. The logo doesn't scale quite as smoothly at large logo heights though. I think you'd need to go to 8.16 fixed point format to get totally smooth scaling using this technique.

 

vscale.dasm 3.58 kB · 0 downloads

Honestly all I do is decrement the scale variable and it looks mostly fine. sure there's still a bounce but it's nowhere near as bad as my version which is full of bouning.

Link to comment
Share on other sites

47 minutes ago, Ecernosoft said:

Though how exactly does this work?

Are you familiar with fixed point numbers? This method is using a two-byte fixed point counter (Vpos_hi and Vpos_lo) to step through the lines of the logo. As you've found, you can't use an integer step size, or else the final logo height will always be some multiple of the number of lines in your logo, and you can't get smooth scaling.

 

You could extend this technique to a three-byte fixed point counter with one integer byte and two fractional bytes, and a two-byte lookup table to match, and it should be 100 percent smooth. If you have enough CPU time, you could also replace the lookup table with a software division subroutine.

  • Like 1
Link to comment
Share on other sites

3 hours ago, bigmessowires said:

Are you familiar with fixed point numbers? This method is using a two-byte fixed point counter (Vpos_hi and Vpos_lo) to step through the lines of the logo. As you've found, you can't use an integer step size, or else the final logo height will always be some multiple of the number of lines in your logo, and you can't get smooth scaling.

 

You could extend this technique to a three-byte fixed point counter with one integer byte and two fractional bytes, and a two-byte lookup table to match, and it should be 100 percent smooth. If you have enough CPU time, you could also replace the lookup table with a software division subroutine.

Well..... kinda.

I'm not the best with it though.

 

Though seriously. I'm amazed. Keep up the good work. :) 

 

(I'm also going to port it to the 5200 and 7800!)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...