60

Mega Shocked (./59):
Hi Hine62,

Thanks for sharing your method for Sprite Scaling! In my case I am trying to Scale Sprite Pools.
I have modeled my projects around Sprite Pools but the missing link is scaling.

Hi HPMAN!

My hope is you will see although very wrong I did do my best to put elbow grease into this problem.
Again very much for the record appreciate what you have done for the community with this library!
I apologize in advance.

Mame files are here: https://www.dropbox.com/s/7zqkdo5vz4599ww/DDsprdmoMAME.zip?dl=0

Driver I used is in a .txt it needs to be patched into your hash folder via neogeo.xml

Source files are here: https://www.dropbox.com/s/f029ztwuxu7xxek/DDSpritePoolDemoSOURCE.zip?dl=0

General Notes

I used banking so the syntax on functions is different than usual also NeoDev environment will need the bank stuff in place to compile the source .

*Syntax could be useful for people looking to incorporate banking into their projects.
*My projects use similar structs hoping it might be useful for someone to see how I group and declare variables.

Instructions for this broken demo

Joystick Instructions are plainly stated on the screen. Player 2 must be mapped.

Movement: Any character can be moved.
Y Sort: Function can be uncommented in "RenderSpritePool" (Compiled version has no Y sort)
Scale: Most interesting part of the demo
Hide/Show: Hide and Show Sprites and attempt to track their "way up" and "way down" sprite index. (Debug Info can commented to see what I was thinking)

All these things are kinda good if you only do one of the things mentioned above.

My suggestion is to do 1 thing listed below and reset the demo and try another thing.
When you combine things the demo starts to break.

1. Attempt to only SCALE sprites on your first run on the demo.
You will see jank sprite scaling (Probably the best part of this demo)

Looking closely strips have small gaps at times.
The anchoring is garbage.
I wish I could get insight on how to adjust the anchor point of the scale.
EX: How to scale a sprite from its direct center.
EX: How to scale a sprite anchoring the scale to the position of the sprites feet.
EX: Burnov is interesting because he has a frame that expands and contracts which will reveal Abobo's toe how can that be avoided.

2. On the second run Hide/Show Sprites....This was always supported by DATLib but in my case I am trying to re-index my variables to determine where sprites are on the list.

EX: Uncomment the Debug Statement in main to see the way I thought the list was working behind the scenes.
EX: I am a liar I swear I had scaling working with hide and show but you will find this is broken.
EX: Hide/Show Billy then Scale Billy and Abobo scales I am ashamed that I suck

Any insight on better techniques, how sprite pools work, anchoring scaling would be greatly appreciated.

What do you think about idea to recode this demo to racing game engine?
avatar

61

Hi VasiliyFamiliya,

The demo is very broken. Feel free to do what you want with the code. The purpose was to attempt to handle the problem of scaling sprite pools. I don't recommend reusing the scaling portion as I'm sure it is not handled properly and a number of functions were an attempt to manage the pool. I'm sure several functions are dead weight.

62

Why not just write your custom renderer if you need scaling?
That would be simpler than trying to track sprites and fixing tons of data.

By the way you can't do this:
scroll initializeScrollToZero() { scroll s; memset(&s, 0, sizeof(scroll)); return s; }s will cease to exist when function returns. Returned value will point to a memory location on the stack that might be used by something else.

63

Hi HPMAN!

The way you built the Sprite Pool feature is good on so many levels. I wouldn't know where to begin to write a custom renderer. I was hoping to use what you had and build in a solution for scaling as an interim solution. Are you planning on incorperating scaling to sprite pools at a later time?

The s variable is only in place so that every variable within the scroll struct initializes to zero when it is first declared in main. "Glinkie Games" hooked me up with this technique when I inquired about initializing several variables to 0 as a start point. I use this frequently and haven't encountered any issues.

Do you have any insight on how to better anchor the scale in the demo? When anchoring a standard picture or sprite to its center the math in the scale function seems to work.

64

Even if the compiler makes it work for you it's going to be allocated on the stack, it will grow on each call, and that memory will never be released.
This can only degenerate into issues.

I'll try out a scale enabled version someday, need to work out a path that doesn't tank performance.

To adjust shift from anchor point most games have a scale factor of 0-ff and do: scaledShift=(baseShift*(scale+1))>>8

65

HPMAN (./62) :
s will cease to exist when function returns. Returned value will point to a memory location on the stack that might be used by something else.
It's OK because the function returns a struct (return by value), not a pointer to a local struct (return by reference):
https://stackoverflow.com/a/9653083

HPMAN (./64) :
Even if the compiler makes it work for you it's going to be allocated on the stack, it will grow on each call, and that memory will never be released.
Returning a pointer to a local struct is a bad idea, but not because of this. Stack allocations are always released when exiting a function.
avatar
Zeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo

66

What size of playfield Neo-Geo has (for example, Sega MegaDrive\Genesis has 512x512 playfield size)? Maybe, this is a think I need take into account for newest bug fixing in Shaman King.
avatar

67

I have been obsessing lately mainly because the results of the code I posted were so poor.

In this go round I have an official demo.

*Scaling members of Sprite Pools anchored to the players feet
*Hiding and Showing Scaled members of Sprite Pools
*Y-Sorting Scaled members of Sprite Pools



I have updated the previous links....

https://www.dropbox.com/s/7zqkdo5vz4599ww/DDsprdmoMAME.zip?dl=0

https://www.dropbox.com/s/f029ztwuxu7xxek/DDSpritePoolDemoSOURCE.zip?dl=0

I need help to get the finishing touches in place.
Hoping I could get some insight on this. I would love to get the two last issues squared away.

I believe the caveat mentioned in the wiki is the primary culprit.

https://wiki.neogeodev.org/index.php?title=Sprite_shrinking&t=20181013065251

- Abobo is taller than the rest of the other members you can clearly see his feet are appending themselves to the other players. Weird..Caveat?
I tried to make a 5th member that is transparent to make the last member in the pool transparent but that didn't seem to work....

-Idol frames for Burnov and Walk frames for Abobo are different sizes this causes a jitter when scaled....thoughts on fixing this would be awesome.

I am stumped...I realize the "for" loops I am using "Tank Performance" but I am hoping you could humor me on this one.
Maybe the loops could be optimized to only execute on triggers to make the performance hit less apparent in the future.

Hi VasiliyFamiliya,

512x512 is the canvas size. This is useful to have sprites positioned outside of the screen's visible window area of 320x224.
If you move your sprite vertical in X,Y once it exceeds 512 in any direction it will loop to the next side of the screen.
EX: Increment X to the right x++; you will notice the sprite will eventually pop into the left side of the frame.

68

I've read that caveat several times in my neogeo notes and pdfs. I remember fixing some graphics because of this problem. You could try fixing one of the actors by moving them up a pixel or erasing the bottom row of pixels to see if the garage goes away.
avatar

69

Mega Shocked (./67):
Hi VasiliyFamiliya,

512x512 is the canvas size. This is useful to have sprites positioned outside of the screen's visible window area of 320x224.
If you move your sprite vertical in X,Y once it exceeds 512 in any direction it will loop to the next side of the screen.
EX: Increment X to the right x++; you will notice the sprite will eventually pop into the left side of the frame.

Thank you very much.
avatar

70

Now it's time for good news - I finally have been able to fix my bug!
avatar

71

Thanks very much for your suggestion hine62.

I padded all my GFX to have an additional transparent 16x16 tile at the bottom of the frame.
At first glance it does reduce the issue but also creates more issues.

1. Now all scale anchoring is off because of the additional invisible tile each frame has.
2. Abobo is 2 tiles higher than the Billy and Amon sprites so bottoms of his stinky feet are still displaying.
If I padded Abobo's frames to have an additional 32x32 tile at the bottom of them then this issue would appear to go away.

Unfortunately this would get crazy as you would always be concerned with you highest sprite in relation to your smallest sprite and your frames would get weird as the padding would be all over the map.

I am now on quest to determine if anybody knows the secret technique of clearing a tile? I know we can clear sprites but in my case I want to issue a command that only clears specific tiles.

EX: Billy is 5 tiles high Abobo is 7 tiles high the difference between the heights is two tiles. I want to clear the bottom two tiles of Billy's sprite so the garbage data goes away....

72

I don't think you need a whole transparent tile on the bottom. The image just needs the bottom line of pixels to be transparent. I'll try to set up your project and see what I can do.
avatar

73

Now, how to realize the damage number smooth per-pixel up movement(i. e. showing a messages not throught the fix layer) from hit point after attack?
avatar

74

Does anybody know, how to build a CD-version of game using DATlib?
avatar