|
ForumsSega Master System / Mark III / Game GearSG-1000 / SC-3000 / SF-7000 / OMV |
Home - Forums - Games - Scans - Maps - Cheats - Credits Music - Videos - Development - Hacks - Translations - Homebrew |
Author | Message |
---|---|
|
Working with sprites and make animation
Posted: Thu Jun 13, 2019 12:19 am
|
Some days ago I started to study DevkitSMS development and I did not understand how I should proceed to leave the sprites with transparent background and how to animate them. I would appreciate the help of the forum members.
Thank you very much in advance. |
|
|
Posted: Thu Jun 13, 2019 6:23 am |
The first color (0) of the sprite palette would be considered transparent on a sprite (automatically). Regarding animation, there's no built in sprite animation system, you have to build it by yourself. | |
|
Posted: Thu Jun 13, 2019 2:31 pm |
as said, any pixel that's using color 0 on a sprite will be transparent.
as for the animations, there are two options which are basically: - animate a sprite by pre-loading the animation tiles in VRAM and using them in different frames: for instance, say you load your animation's 4 frames into tiles 7,8,9 and 10. If you'll use tile 7, later you'll use tile 8 and then 9 and finally 10 (if you change that each frame you'll have your animation running at 50 or 60 fps, according to your system's TV standard, so you probably want to show the same tile more than once...) - animate a sprite by reloading contents in the tile according to the frame you need. So if your sprite is using tile 23, for instance, you can change the contents of tile 23 (during vblank, likely!) when it's time to show the next image |
|
|
Posted: Thu Jun 13, 2019 3:58 pm |
One of the things I'd like to see in homebrew is 60fps sprite (and tile) animation... but that is probably rather onerous for the artist. | |
|
Posted: Thu Jun 13, 2019 4:15 pm |
IMHO everything over 20 fps is totally useless.
But to prove I'm wrong you can code a small 3D spinning wireframe cube rendered into some 16 tiles in screen center and see if updating it at each frame makes any difference to -say- each other frame ;) |
|
|
color 0 em palette
Posted: Thu Jun 13, 2019 6:13 pm
|
What I do not understand, so I understand the color 0 in my palette |
|
|
Posted: Thu Jun 13, 2019 7:45 pm |
the color 0 meaning the first element in your palette, as in my_array[0]
you're likely going to prepare your sprites over a key color background, such as magenta, like this for example: https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTFgzfONPdqgU4ip56oAAXpf7Ko... and then save your image to PNG (or some other format for indexed images) ensuring that your magenta gets color index 0. Then you use Maxim's BMP2Tile to turn your image to tiles. |
|
|
All Right !
Posted: Fri Jun 14, 2019 3:26 pm
|
Thanks !! |
|
|
I can not display background image correctly
Posted: Fri Jun 14, 2019 3:31 pm
|
I do not understand why not trying to put this background image for the scenario I get this result. |
|
|
Posted: Fri Jun 14, 2019 3:51 pm |
Please explain your steps.
Have you got a 256x192 pixel image you converted to tiles, tilemaps and palette in BMP2Tile? Are you sure you're loading them correctly? It seems the tilemap isn't good... |
|
|
Posted: Fri Jun 14, 2019 3:57 pm Last edited by IllusionOfMana on Fri Jun 14, 2019 3:59 pm; edited 1 time in total |
are you loading your tiles into the appropriate vram location and are you loading the sprite table correctly? lastly are you loading your palette information correctly as well. will provide some examples of a bad load and a good load (sorry for camera shots, took these off my IG) |
|
|
Posted: Fri Jun 14, 2019 3:58 pm |
Yes, the map was created using bmp2tile, the size of 256X192 My code: SMS_loadBGPalette(stage_palette__bin); SMS_loadPSGaidencompressedTiles(stage_psgcompr, 0); SMS_loadTileMapArea(0, 0,stage_bin, 32, 24); SMS_displayOn(); |
|
|
Posted: Fri Jun 14, 2019 5:10 pm |
Hello again ! I am grateful for everyone's attention. I was able to display correctly using another map, but when I add my sprites it stays that way as in the image. |
|
|
Posted: Fri Jun 14, 2019 5:17 pm |
Background and sprites are both made of tiles - you're placing your sprites' tiles in video memory (VRAM) somewhere over your background tiles... | |
|
Thanks !!!
Posted: Fri Jun 14, 2019 9:47 pm
|
I undestand ! Thank you very much !! |
|
|
yet error in image
Posted: Sun Jun 16, 2019 2:38 am
|
I thought you understood the cause, but even with just the image alone, if sprites appear that way. I did a test with the Phantasy Star title screen and it is displayed correctly, I use the bmp2tile for the image I want to use, but most present this problem. Using SMS_loadTileMapArea or SMS_loadTileMap. |
|
|
Posted: Sun Jun 16, 2019 3:51 am |
It looks like you ran out of vram. The image youre trying to render uses a lot of similar tiles that are just flipped. try optimizing your tile map and the tile set being loaded in. This may also be causing the odd palette issue as well... (unless those were your intended colors...) | |
|
Posted: Sun Jun 16, 2019 4:11 pm |
A bit of offtopic but, where're this graphics from? I like them! |
|
|
Posted: Mon Jun 17, 2019 8:50 am |
As IllusionOfMana suggested, you're probably using too many tiles. You can expect to be safe as long as your total number of tiles (background and sprites) is at most 448. Try with a simpler background. @kusfo no idea, I just googled 'sprite sheet magenta'. |
|
|
Posted: Mon Jun 17, 2019 10:03 am |
I'll do a reverse searching to find it xD | |
|
Posted: Mon Jun 17, 2019 2:30 pm |
|
|
|
Tiles and Sprites
Posted: Mon Jun 17, 2019 7:10 pm
|
What would be the best way to work with tiles to do the sprites? I've felt a lot of difficulty in this part, maybe I'm wrong or more complicated. |
|
|
Posted: Mon Jun 17, 2019 8:04 pm |
Draw your sprites as an image. Convert to tile data (8x8 tiles). Make your code draw the tiles for each sprite, using the correct tile numbers, at correctly spaced x, y coordinates. How you achieve that depends a lot on how you are animating things and how you need to deal with sprites in your game.
If you have a static set of sprites which stay on screen then you can just set things up once and then just update the coordinates; if it's more complicated then you need something complicated to deal with it, like dynamically generating the sprite table on each frame based on what's visible. |
|
|
Posted: Tue Jun 18, 2019 12:14 pm |
Build a (or a few) sprite sheet(s). If your sprites are 16 pixel tall, use the designated BMP2Tile option ("Treat as 8x16") when saving the tiles. Remember that you can use only tiles in either the first or the second half of VRAM for sprites. Once you've loaded your tiles in VRAM, refer to them by their tile number when adding sprites. I usually have a bunch of #defines for that... |
|
|
Posted: Tue Jun 18, 2019 2:15 pm |
working with tiles and sprites can be complicated.
Tiles I found it was draw 8x8 pixel tiles in any paint program then load them into a map builder called Tiled then export that map as a PNG or BMP image. I then use UGT which is bundled with Psidum's GSLib or ill use bmp2tile. both these programs will allow you to optimize your tile set as well as export a tileset, tile map, and palette. Sprites Similar steps as the first, draw 8x8 pixel tiles for your sprite in your preferred paint program and export it at a PNG or BMP. This time using bmp2tile and turning off any optimization options and exporting both the tileset and palette. Programming Within your program you need to be mindful of your VRAM. I believe you get some 512 entries or 256 enteries per palette. thats 256 8x8 pixel tiles and 256 8x8 pixel sprites (however due to the SAT and Screen Buffer taking up memory, the sprite section doesnt actually have 256 entries available to it but instead around 190 tiles). So be mindful on how many tiles and sprites youre loading into VRAM or you will overflow and cause graphical glitches and other issues. You also only have 64 entries into to Sprite Table despite the sprite section of VRAM allowing more than double that. So to recap, you get: 256 tiles 190 sprites 2 color palettes of 16/64 colors (for sprites, color zero is the cutout mask) 64 max on screen sprites I'll provide some examples below of how some of the things Ive set up look. One of them is a snapshot within an emulator and will show you exactly how your VRAM should look with sprites and tiles separated per section. |
|
|
Posted: Tue Jun 18, 2019 3:13 pm |
More precisely: you safely got 448 tiles (tiles from 0 to 447) to use, but you need to share this space for both sprites tiles and background tiles. As sprite tiles should be either in the first half or in the second half of VRAM, you can have up to 256 tiles for sprites if you use the first half of VRAM but only 192 tiles for sprites if you use the second half (devkitSMS default). For the background you can use all the remaining tiles. So if you're using very few tiles for sprites, you can use more tiles in your background. @IllusionOfMana - that's looking great! :) |
|
|
Posted: Tue Jun 18, 2019 4:12 pm |
Right, I was more or less keeping it simple as thats what I did for mine. I omitted a good 2 or 3 tiles between the last half and the screen buffer since he seems to be having a lot of issues with writing into the screen buffer. He also seems to be overwriting the second half of VRAM a lot too... Also thanks, that project is almost finished! Talked to Psidum earlier, he's reworking GSLib quite a bit so I'm hoping his next update will help fix some of my enemy sprite issues with the on screen check. |
|