|
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 |
---|---|
|
The asset workflow for creating graphics for SG-1000
Posted: Tue Jul 07, 2020 8:15 pm
|
Hello folks,
I'm playing with SGlib and bmp2tile 0.44 for writing a simple console application. I see no compression support for tiles and tilemap in SGlib API so I have to create uncompressed tile data with bmp2tile. When i use an older bmp2tile version which support raw uncompressed tile data output I don't see my tiles on the screen. The number of tiles and color is correct but it looks more like atari graphics. #include "SGlib.h" // we're including the library with the functions we will use
#include "assets.h" // we're including the assets we created before void loadAssets(void) { SG_loadTilePatterns(font__tiles__bin, 0, font__tiles__bin_size); SG_loadTileColours(font__palette__bin, 0, font__palette__bin_size); } void main(void) { loadAssets(); SG_loadTileMap (0, 0, font__tilemap__bin, font__tilemap__bin_size); SG_displayOn(); for (;;) ; } My build script @echo off
echo Build assets.c and assets.h from assets folder folder2c assets assets rem assets2banks assets sdcc -c -mz80 assets.c if %errorlevel% NEQ 0 goto :EOF echo Build Main sdcc -c -mz80 main.c if %errorlevel% NEQ 0 goto :EOF echo Linking sdcc -o output.ihx -mz80 --no-std-crt0 --data-loc 0xC000 crt0_sg.rel main.rel SGlib.rel assets.rel if %errorlevel% NEQ 0 goto :EOF ihx2sms output.ihx output.sms What is the problem with the code? |
|
|
Posted: Tue Jul 07, 2020 10:50 pm |
BMP2Tile tilemaps aren’t compatible here, and I suspect tiles will need to be 1bpp. | |
|
Posted: Wed Jul 08, 2020 10:00 am |
you can try saving the tiles as 1bpp from BMP2Tile as Maxim suggested and display the characters on screen using either
void SG_setTileatXY (unsigned char x, unsigned char y, unsigned char tile);
or void SG_setNextTileatXY (unsigned char x, unsigned char y);
void SG_setTile (unsigned char tile); in a loop, to workaround the fact that we're missing a tool to save tilemaps (well, na_th_an might have it...) |
|
|
Posted: Wed Jul 08, 2020 10:11 am |
Actually I don’t know how SG tilemaps work, if someone can explain to me I might be able to add support. | |
|
Posted: Wed Jul 08, 2020 10:49 am |
probably it's a simple array of bytes so actually BMP2Tile 'LSB only' tilemaps might work out of the box... it's worth a try! | |
|
Posted: Wed Jul 08, 2020 3:50 pm |
Probably it sits at some place here: https://github.com/mojontwins/loves_the_sg1000/tree/master/examples/01_cheril_perils_classic/ |
|
|
Posted: Wed Jul 08, 2020 6:44 pm |
The TMS9928A supports 4 different graphic modes:
https://segaretro.org/TMS9918#Screen_modes Which modes can be used in SGlib? |
|
|
Posted: Wed Jul 08, 2020 8:49 pm |
At least Mode 2, that it was mainly used in the MSX1 machines... | |
|
Posted: Thu Jul 09, 2020 2:54 pm |
SGlib is Mode 2 only
so this means tiles are 1bpp, likely planar also, maps won't support tile mirroring/flipping, and will be 'LSB' (one single byte per entry) should work... |
|
|
Posted: Sat Feb 24, 2024 8:06 pm |
After days of struggling maybe useful for someone other. At least it works for me.
|
|
|
Posted: Sun Feb 25, 2024 1:30 pm |
Would you mind explaining how this program does and how to use it? This way it's likely more to be useful to someone else :) |
|
|
Posted: Sun Feb 25, 2024 2:02 pm |
It’s Python so it is self-documenting pseudo code :)
I still haven’t used the legacy modes much (apart from text mode for Zexall), but it seems to me this is targeting graphic 2 mode and will emit the tiles and other tables. |
|
|
Posted: Sun Feb 25, 2024 2:17 pm |
can't BMP2Tile save 1bpp graphics (tiles) and 8-bit maps already?
so what this tool do differently? |
|
|
Posted: Sun Feb 25, 2024 2:25 pm |
Tile deduplication has to not cross 256 tile boundaries, plus you need to bump the tile index to the next 256 after each third of a screen. The colour table isn’t emitted by bmp2tile at all. | |
|
Posted: Sun Feb 25, 2024 2:39 pm |
First step is converting the image data by using pillow library into rgb space, necessary because palette formats exist.
Next step calculate a table for the given color to color which matches best to color palette of SG/SC system. Then split image into 8x8 tiles and go through each line. In the loop I create two files, one is a pattern file(tiles) and the other one for assigning the corresponding colors. One nibble is for the background the other is the foreground color. You can use pyinstaller to make a bundle executable or call the script like python gfx2sg.py GRAPHIC.JPG |
|