Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - The asset workflow for creating graphics for SG-1000

Reply to topic
Author Message
  • Joined: 09 Jan 2012
  • Posts: 60
  • Location: Germany
Reply with quote
The asset workflow for creating graphics for SG-1000
Post 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?
font.png (1.25 KB)
font.png
emu_shot.png (3.57 KB)
emu_shot.png

  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13290
  • Location: London
Reply with quote
Post Posted: Tue Jul 07, 2020 10:50 pm
BMP2Tile tilemaps aren’t compatible here, and I suspect tiles will need to be 1bpp.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 2709
Reply with quote
Post 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...)
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13290
  • Location: London
Reply with quote
Post 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.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 2709
Reply with quote
Post 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!
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 602
  • Location: Spain
Reply with quote
Post Posted: Wed Jul 08, 2020 3:50 pm
sverx wrote


in a loop, to workaround the fact that we're missing a tool to save tilemaps (well, na_th_an might have it...)


Probably it sits at some place here: https://github.com/mojontwins/loves_the_sg1000/tree/master/examples/01_cheril_perils_classic/
  View user's profile Send private message
  • Joined: 09 Jan 2012
  • Posts: 60
  • Location: Germany
Reply with quote
Post Posted: Wed Jul 08, 2020 6:44 pm
The TMS9928A supports 4 different graphic modes:


Quote
Mode 0 (Text): 40×24 characters monochrome. As the display is 256 pixels width, the character set is only 6 pixels wide. This mode doesn't support sprites, nor a separate border color setting.

Mode 1 (Graphic 1): 32×24 characters (256×192 bitmap), where for each 8 characters in the character set the foreground and background color can be set. The chars "0"-"7" for example all have the same attributes.

Mode 2 (Graphic 2): 32×24 characters (256×192 bitmap), with a 2-color limitation for each 8 pixel wide line inside a character.

Mode 3 (Multicolor): 64×48 mode, very blocky and rarely used. Each 'pixel' can have its own color defined though, hence the name. Its sprites still have the same resolution as in screen modes 1 and 2.

The TMS9918 has a fixed 16-color palette (actually 15 colors + transparent).

https://segaretro.org/TMS9918#Screen_modes

Which modes can be used in SGlib?
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 602
  • Location: Spain
Reply with quote
Post Posted: Wed Jul 08, 2020 8:49 pm
At least Mode 2, that it was mainly used in the MSX1 machines...
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2709
Reply with quote
Post Posted: Thu Jul 09, 2020 2:54 pm
dark wrote
Which modes can be used in SGlib?


SGlib is Mode 2 only

Quote
Mode 2 (Graphic 2): 32×24 characters (256×192 bitmap), with a 2-color limitation for each 8 pixel wide line inside a character.


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...
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!