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 - Tiles not displaying properly - Z88DK

Reply to topic
Author Message
  • Joined: 16 Jan 2007
  • Posts: 16
  • Location: Pennsylvania, USA
Reply with quote
Tiles not displaying properly - Z88DK
Post Posted: Mon Aug 14, 2023 10:47 pm
Hey all, I've been experimenting with SMS development using the examples provided in the z88dk package. I used the tool BMP2TILE to create the tile data (tiles, map, and palette). When I compile and run my code it displays the tiles as garbled messes but you can see the tile layout correctly. The image I used to make the tiles is definitely 4bpp so I'm not sure if its the source image or how I put the data into my code. The examples I saw had the tile bytes in a single array.
The left is what it should like, the right is what I see in MEKA and Fusion364. Anything that can point me in the right direction would much appreciated.


My code
#include <sms.h>

const int screen_width = 32; // in tiles
const int screen_height = 28; // in tiles

const unsigned char bg_tiles[] = { 0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x11 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x11 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x11 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x11 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x11 ,0x31 ,0x13 ,0x33 ,0x13 ,0x13 ,0x13 ,0x33 ,0x13 ,0x13 ,0x13 ,0x33 ,0x13 ,0x13 ,0x13 ,0x33 ,0x13 ,0x13 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x11 ,0x33 ,0x13 ,0x33 ,0x13 ,0x13 ,0x13 ,0x33 ,0x13 ,0x31 ,0x13 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x11 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x31 ,0x33 ,0x33 ,0x31 ,0x31 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x13 ,0x13 ,0x13 ,0x33 ,0x13 ,0x13 ,0x13 ,0x33 ,0x13 ,0x13 ,0x13 ,0x33 ,0x11 ,0x31 ,0x13 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x31 ,0x31 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x31 ,0x31 ,0x33 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x13 ,0x33 ,0x31 ,0x31 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x31 ,0x33 ,0x33 ,0x13 ,0x11 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x31 ,0x11 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x11 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x13 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x11 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x13 ,0x31 ,0x33 ,0x33 ,0x33 ,0x31 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x11 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x33 ,0x11 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x31 ,0x11 ,0x11 ,0x31 ,0x11 ,0x11 ,0x11 ,0xB1 ,0x11 ,0x11 ,0x11 ,0x3B ,0x11 ,0xBB ,0xBB ,0x33 ,0xBB ,0x33 ,0x33,
                                   0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x1B ,0xB1 ,0x11 ,0xBB ,0xB3 ,0x3B ,0xBB ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x31 ,0x13 ,0x33 ,0x31 ,0x11 ,0x11 ,0x33 ,0x11 ,0x11 ,0x11 ,0x31 ,0x11 ,0x11 ,0x11,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x33 ,0x33 ,0x11 ,0x11 ,0x13 ,0x31 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x33 ,0x33 ,0x33 ,0x11 ,0x13 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x11 ,0x11 ,0x11 ,0x33,
                                   0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0xBB ,0xBB ,0xBB ,0xBB,
                                   0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0xB1 ,0x11 ,0x11 ,0x11,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x11 ,0x33 ,0x33 ,0x33 ,0x11 ,0x11 ,0x33 ,0x33 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11,
                                   0xB1 ,0x11 ,0x11 ,0x11 ,0x3B ,0x11 ,0x11 ,0x11 ,0x33 ,0xBB ,0x11 ,0x11 ,0x33 ,0x33 ,0xB1 ,0x11 ,0x33 ,0x3B ,0x11 ,0x1B ,0x33 ,0xB1 ,0x11 ,0xB3 ,0x33 ,0x3B ,0xBB ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0xB1 ,0x11 ,0x11 ,0x1B ,0x3B ,0x11 ,0x11 ,0xB3 ,0x33 ,0xB1 ,0x1B ,0x33 ,0x33 ,0x3B ,0xB3 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x11 ,0x11 ,0xBB ,0xBB ,0x1B ,0xBB ,0x33 ,0x33 ,0xB3 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33,
                                   0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11 ,0x11,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x35 ,0x33 ,0x33 ,0x53 ,0x53 ,0x35 ,0x35 ,0x35 ,0x43 ,0x53 ,0x34 ,0x35 ,0x43 ,0x43,
                                   0x33 ,0x33 ,0x32 ,0x33 ,0x33 ,0x32 ,0x21 ,0x22 ,0x33 ,0x33 ,0x27 ,0x13 ,0x33 ,0x32 ,0x22 ,0x22 ,0x35 ,0x33 ,0x32 ,0x35 ,0x33 ,0x53 ,0x34 ,0x53 ,0x33 ,0x35 ,0x45 ,0x33 ,0x33 ,0x35 ,0x43 ,0x33,
                                   0x55 ,0x55 ,0x55 ,0x55 ,0x55 ,0x55 ,0x55 ,0x55 ,0x56 ,0x56 ,0x66 ,0x65 ,0x44 ,0x44 ,0x44 ,0x44 ,0x99 ,0x44 ,0x94 ,0x44 ,0x98 ,0x99 ,0xA9 ,0xA9 ,0x89 ,0xAA ,0x9A ,0xA9 ,0x88 ,0x89 ,0x89 ,0x88,
                                   0x55 ,0x55 ,0x55 ,0x53 ,0x55 ,0x55 ,0x55 ,0x55 ,0x56 ,0x56 ,0x65 ,0x55 ,0x44 ,0x54 ,0x46 ,0x65 ,0x99 ,0x49 ,0x94 ,0x43 ,0x98 ,0x99 ,0xA9 ,0xA3 ,0x89 ,0xAA ,0x9A ,0xA3 ,0x98 ,0xA9 ,0xA9 ,0xA3,
                                   0x8A ,0x9A ,0x8A ,0x9A ,0x98 ,0x88 ,0x88 ,0x88 ,0x88 ,0xA9 ,0x88 ,0xA8 ,0x88 ,0x88 ,0x88 ,0x88 ,0x8A ,0x88 ,0xA9 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88,
                                   0x99 ,0xA8 ,0x98 ,0xA8 ,0x8A ,0x8A ,0x89 ,0x8A ,0x98 ,0x98 ,0x9A ,0x89 ,0x88 ,0x88 ,0xA9 ,0x8A ,0x8A ,0x8A ,0x88 ,0x98 ,0x88 ,0x89 ,0x89 ,0x8A ,0x88 ,0x88 ,0x8A ,0x89 ,0x88 ,0x88 ,0x88 ,0x8A,
                                   0x8A ,0xAA ,0x99 ,0xA3 ,0x98 ,0x9A ,0x9A ,0xA3 ,0x89 ,0xA9 ,0xA9 ,0xA3 ,0x98 ,0xA9 ,0x99 ,0xA3 ,0x8A ,0xAA ,0x9A ,0xA3 ,0x98 ,0x99 ,0xA9 ,0xA3 ,0x89 ,0xAA ,0x9A ,0xA3 ,0x98 ,0xA9 ,0xA9 ,0xA3,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0xCC ,0x33 ,0x33 ,0x3C ,0xCB ,0x33 ,0x33 ,0xCB ,0xBC ,0x33 ,0x3C ,0xCB ,0xBB ,0x33 ,0x3C ,0xCC ,0xCC ,0x33 ,0x3C ,0xCC ,0xCC,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0xCC ,0xCC ,0xCC ,0x33 ,0xB1 ,0x11 ,0xBC ,0xC3 ,0xBB ,0xBB ,0xBB ,0xCC ,0xCB ,0xBB ,0xBC ,0xCC ,0xCC ,0xCC ,0xCC ,0xB1 ,0xCC ,0xCC ,0xCC ,0xCC,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0x33 ,0xC3 ,0x33 ,0x33 ,0x33 ,0xCC ,0x33 ,0x33 ,0x33 ,0xCC ,0xC3 ,0x33 ,0x33,
                                   0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88 ,0x88,
                                   0x88 ,0x88 ,0x88 ,0x98 ,0x88 ,0x8A ,0x88 ,0x8A ,0x88 ,0x88 ,0x8A ,0x89 ,0x88 ,0x88 ,0x89 ,0x8A ,0x88 ,0x8A ,0x88 ,0x88 ,0x88 ,0x89 ,0x88 ,0x8A ,0x88 ,0x88 ,0x8A ,0x89 ,0x88 ,0x88 ,0x88 ,0x8A,
                                   0x33 ,0x33 ,0x33 ,0x33 ,0x3C ,0xCC ,0xCC ,0xCC ,0xCC ,0xCC ,0xCC ,0xCC ,0xB1 ,0x11 ,0xB1 ,0x11 ,0xBB ,0xBB ,0xBC ,0xBB ,0xCB ,0xBB ,0xBB ,0xCB ,0xCC ,0xBB ,0xCC ,0xBB ,0xCC ,0xCC ,0xCC ,0xCC,
                                   0x8A ,0x9A ,0x8A ,0x9A ,0xA8 ,0x88 ,0x98 ,0x88 ,0x89 ,0xA9 ,0x89 ,0xA8 ,0x98 ,0x9A ,0x88 ,0x88 ,0x8A ,0x88 ,0xA9 ,0x88 ,0xA8 ,0x98 ,0x88 ,0x88 ,0x9A ,0x88 ,0xA8 ,0x88 ,0x98 ,0x98 ,0x88 ,0x88};

unsigned char bg_pal[] = { 0x00, 0x3F, 0x03, 0x3E, 0x04, 0x09, 0x0E, 0x1F,
                           0x05, 0x06, 0x1B, 0x2A, 0x15, 0x00, 0x00, 0x00 };
unsigned int bg[] = { 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,                     
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x2D, 0x2E, 0x2F, 0x1A, 0x1A, 0x2D, 0x2E, 0x2E, 0x2D, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x2B, 0x30, 0x2C, 0x31, 0x32, 0x32, 0x30, 0x2C, 0x30, 0x30, 0x2B, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x33, 0x34, 0x35, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x2D, 0x2E, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x2D, 0x2E, 0x2D, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x2B, 0x31, 0x36, 0x32, 0x2B,
                      0x1A, 0x1A, 0x2B, 0x31, 0x36, 0x36, 0x30, 0x30, 0x2B, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x33, 0x34, 0x35, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x33, 0x34, 0x35, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x1A, 0x37, 0x38, 0x1A, 0x1A, 0x37, 0x37, 0x1A, 0x37, 0x1A, 0x38, 0x1A, 0x37, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x3A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3C, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x37, 0x3E, 0x3F, 0x40, 0x38, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A, 0x23, 0x39, 0x39, 0x39, 0x39, 0x3A, 0x3E, 0x43, 0x3F, 0x40, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A, 0x3D, 0x44, 0x3B, 0x3B, 0x3B, 0x3C, 0x39, 0x39, 0x39, 0x3A, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A, 0x3D, 0x42, 0x41, 0x41, 0x41, 0x41, 0x3B, 0x3B, 0x3C, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A, 0x3D, 0x42, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A, 0x3D, 0x42, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A, 0x3D, 0x42, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A, 0x3D, 0x42, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A,
                      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A, 0x3D, 0x42, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x3D, 0x1A, 0x1A, 0x1A, 0x1A };
                   
unsigned int bg_grid[32][28];
unsigned char spr_pal[] = { 0x00, 0x03, 0x08, 0x28, 0x02, 0x22, 0x0A, 0x2A,
                        0x15, 0x35, 0x1D, 0x3D, 0x17, 0x37, 0x1F, 0x3F };

void UpdateBackgroundTiles(unsigned int * background)
{
    set_bkg_map(background, 0, 0, screen_width, screen_height);
}

void PopulateGridArray()
{
    int total = 0;
    int i = 0;
    int k = 0;
    for(i; i < 28; i++)
    {
        for(k;k < 32;k++)
        {
            bg_grid[k][i] = total;
            total++;
        }
    }
}



void Initialize()
{
    clear_vram();
    //PopulateGridArray();
    UpdateBackgroundTiles(bg);
    load_palette(bg_pal, 0, 16);
    load_palette(spr_pal, 16, 16);
    load_tiles(bg_tiles,0,69,4);
    //set_vdp_reg(VDP_REG_HINT_COUNTER, 0xFF);
    set_vdp_reg(VDP_REG_FLAGS1, VDP_REG_FLAGS1_BIT7 | VDP_REG_FLAGS1_SCREEN | VDP_REG_FLAGS1_VINT);
   
}

void SetTile(int index, int tile)
{
    bg[index] = tile;
}

void DrawText(unsigned char * text, int x, int y)
{
    int start = bg_grid[y][x];
    int i = 0;
    for(i = 0; i < strlen(text); i++ )
    {
        if(text[i] == 'A' || text[i] == 'a')
        {
            SetTile(start + i,0x00);
        }
        else if(text[i] == 'B' || text[i] == 'b')
        {
            SetTile(start + i,0x01);
        }
        else if(text[i] == 'C' || text[i] == 'c')
        {
            SetTile(start + i,0x02);
        }
        else if(text[i] == 'D' || text[i] == 'd')
        {
            SetTile(start + i,0x03);
        }
        else if(text[i] == 'E' || text[i] == 'e')
        {
            SetTile(start + i,0x04);
        }
        else if(text[i] == 'F' || text[i] == 'f')
        {
            SetTile(start + i,0x05);
        }
        else if(text[i] == 'G' || text[i] == 'g')
        {
            SetTile(start + i,0x06);
            //set_sprite(i,x + (i * 8),y,0x47);
        }
        else if(text[i] == 'H' || text[i] == 'h')
        {
            SetTile(start + i,0x07);
        }
        else if(text[i] == 'I' || text[i] == 'i')
        {
            SetTile(start + i,0x08);
        }
        else if(text[i] == 'J' || text[i] == 'j')
        {
            SetTile(start + i,0x09);
        }
        else if(text[i] == 'K' || text[i] == 'k')
        {
            SetTile(start + i,0x0A);
        }
        else if(text[i] == 'L' || text[i] == 'l')
        {
            SetTile(start + i,0x0B);
        }
        else if(text[i] == 'M' || text[i] == 'm')
        {
            SetTile(start + i,0x0C);       
        }
        else if(text[i] == 'N' || text[i] == 'n')
        {
            SetTile(start + i,0x0D);
        }
        else if(text[i] == 'O' || text[i] == 'o')
        {
            SetTile(start + i,0x0E);
        }
        else if(text[i] == 'P' || text[i] == 'p')
        {
            SetTile(start + i,0x0F);
        }
        else if(text[i] == 'Q' || text[i] == 'q')
        {
            SetTile(start + i,0x10);
        }
        else if(text[i] == 'R' || text[i] == 'r')
        {
            SetTile(start + i,0x11);
        }
        else if(text[i] == 'S' || text[i] == 's')
        {
            SetTile(start + i,0x12);
        }
        else if(text[i] == 'T' || text[i] == 't')
        {
            SetTile(start + i,0x13);
        }
        else if(text[i] == 'U' || text[i] == 'u')
        {
            SetTile(start + i,0x14);
        }
        else if(text[i] == 'V' || text[i] == 'v')
        {
            SetTile(start + i,0x15);
        }
        else if(text[i] == 'W' || text[i] == 'w')
        {
            SetTile(start + i,0x16);
        }
        else if(text[i] == 'X' || text[i] == 'x')
        {
            SetTile(start + i,0x17);
        }
        else if(text[i] == 'Y' || text[i] == 'y')
        {
            SetTile(start + i,0x18);
        }
        else if(text[i] == 'Z' || text[i] == 'z')
        {
            SetTile(start + i,0x19);
        }
        else if(text[i] == '!')
        {
            SetTile(start + i,0x27);
        }
        else if(text[i] == '?')
        {
            SetTile(start + i,0x28);
        }
        else if(text[i] == '.')
        {
            SetTile(start + i,0x25);
        }
        else if(text[i] == ',')
        {
            SetTile(start + i,0x29);
        }
        else if(text[i] == ':')
        {
            SetTile(start + i,0x26);
        }
        else if(text[i] == ';')
        {
            SetTile(start + i,0x2A);
        }
        else if(text[i] == '&')
        {
            SetTile(start + i,0x2A);
        }
        else if(text[i] == '=')
        {
            SetTile(start + i,0x1A);
        }
        else if(text[i] == '$')
        {
            SetTile(start + i,0x1A);
        }
        else if(text[i] == '%')
        {
            SetTile(start + i,0x1A);
        }
        else if(text[i] == '0')
        {
            SetTile(start + i,0x1B);
        }
        else if(text[i] == '1')
        {
            SetTile(start + i,0x1C);
        }
        else if(text[i] == '2')
        {
            SetTile(start + i,0x1D);
        }
        else if(text[i] == '3')
        {
            SetTile(start + i,0x1E);
        }
        else if(text[i] == '4')
        {
            SetTile(start + i,0x1F);
        }
        else if(text[i] == '5')
        {
            SetTile(start + i,0x20);
        }
        else if(text[i] == '6')
        {
            SetTile(start + i,0x21);
        }
        else if(text[i] == '7')
        {
            SetTile(start + i,0x22);
        }
        else if(text[i] == '8')
        {
            SetTile(start + i,0x23);
        }
        else if(text[i] == '9')
        {
            SetTile(start + i,0x24);
        }
        else if(text[i] == '-')
        {
            SetTile(start + i,0x2D);
        }
        else
        {
            SetTile(start + i,0x1A);
        }
    }
    UpdateBackgroundTiles(bg);
}

void main()
{
    int pad1 = 0;
    int pad2 = 0;
    int color = bg_pal[1];
    int output = 1;
    Initialize();
   
    //Main Loop
    for(;;)
    {
        pad1 = read_joypad1();

        if(pad1 & JOY_UP)
        {
            if(color < 64)
            {
                color++;
                bg_pal[1] = color;
                load_palette(bg_pal, 0, 16);
            }
            else if(color == 64)
            {
                color = 0;
                bg_pal[1] = color;
                load_palette(bg_pal, 0, 16);
            }
        }

        if(pad1 & JOY_DOWN)
        {
            if(color > 0)
            {
                color--;
                bg_pal[1] = color;
                load_palette(bg_pal, 0, 16);
            }
            else if(color == 0)
            {
                color = 63;
                bg_pal[1] = color;
                load_palette(bg_pal, 0, 16);
            }
        }

        if(pad1 & JOY_LEFT)
        {

        }

        if(pad1 & JOY_RIGHT)
        {

        }

        if(pad1 & JOY_FIREA)
        {
            DrawText("HELLO AGAIN",10,50);
        }

        DrawText("Hello World",2,1);

    }
}
  View user's profile Send private message
  • Joined: 06 Mar 2022
  • Posts: 671
  • Location: London, UK
Reply with quote
Post Posted: Mon Aug 14, 2023 11:44 pm
Not quite sure what's happened there, but the data in `bg_tiles` doesn't look right at all to me..
  View user's profile Send private message Visit poster's website
  • Joined: 04 Jul 2010
  • Posts: 542
  • Location: Angers, France
Reply with quote
Post Posted: Tue Aug 15, 2023 11:49 am
As Will say.
in the function background data are pushed into the VDP as int not char ;)

so your data should be like 0x0054, 0x0123, etc.
  View user's profile Send private message
  • Joined: 16 Jan 2007
  • Posts: 16
  • Location: Pennsylvania, USA
Reply with quote
Post Posted: Thu Aug 17, 2023 11:23 pm
ichigobankai wrote
As Will say.
in the function background data are pushed into the VDP as int not char ;)

so your data should be like 0x0054, 0x0123, etc.


I ended up saving my tiles and tilemap as uncompressed raw binaries with BMP2Tiles as entering the data manually into arrays wasn't working even changing the format from 0x00 to 0x0000, that ended up working. Now I just need to figure out how to make the background scroll in its entirely as I extended my tilemap from 32 tiles wide to 64 tiles and it continues to loop at 32. None of the examples included with Z88DK have the background set to wider then 32 tiles.
  View user's profile Send private message
  • Joined: 29 Mar 2012
  • Posts: 886
  • Location: Spain
Reply with quote
Post Posted: Fri Aug 18, 2023 8:26 am
That's because the nametable is only 32 tiles wide (and it loops endlessly )

If you want to scroll backgrounds, you must update the nametable columns by hand (update the next column going to be displayed)
  View user's profile Send private message
  • Joined: 04 Jul 2010
  • Posts: 542
  • Location: Angers, France
Reply with quote
Post Posted: Fri Aug 18, 2023 3:10 pm
scrolling background is part of the fun.

- "standard version", you calc the offset (for each next tiles) to generate the new column of tiles

- if you're only scrolling in 1 dir (vertical or horizontal), better to generate your data accordingly, so will be easier for new/next column/row (ex. for horizontal scrolling, order data by column). Maxim's BMP2Tile only proceed by row, you you must make a little converter in C or Python.

For horizontal scrolling, don't forget to activate the "hide the left most column" in VDP register 0 (bit 5)
  View user's profile Send private message
  • Joined: 16 Jan 2007
  • Posts: 16
  • Location: Pennsylvania, USA
Reply with quote
Post Posted: Thu Aug 31, 2023 3:30 pm
ichigobankai wrote
scrolling background is part of the fun.

- "standard version", you calc the offset (for each next tiles) to generate the new column of tiles

- if you're only scrolling in 1 dir (vertical or horizontal), better to generate your data accordingly, so will be easier for new/next column/row (ex. for horizontal scrolling, order data by column). Maxim's BMP2Tile only proceed by row, you you must make a little converter in C or Python.

For horizontal scrolling, don't forget to activate the "hide the left most column" in VDP register 0 (bit 5)

Would you happen to know where I could find some examples for drawing the next column in C? I haven't had much luck on my own though I understand what your saying I need to do but not quite sure how to implement it without a starting point.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Sep 01, 2023 8:58 am
the point that it's hard to understand at first is that for horizontal scrolling, you need to load the 33th column of data onto the leftmost one (1st col) and scroll right, then load the 34th onto the 2nd leftmost col and so on, so you likely want to have your BG map organized in columns instead of rows.

BMP2Tile can't do that (at the moment?) so you might need to reorganize the data yourself OR create a plugin for BMP2Tile to export the data using the format you need.

Once you pass this hurdle, loading a column is just one function call away, because there's a function to do that.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Fri Sep 01, 2023 9:34 am
My intention with BMP2Tile is that you probably have a meta tile approach anyway so you will be building meta tiles from a tile set and using a non-image source for the map itself.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Sep 01, 2023 1:24 pm
yes, but you might not have any metatile at all - imagine a fighting game background that just needs to scroll left/right and be, say, twice the size of the screen...
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Fri Sep 01, 2023 3:00 pm
Well, indeed it would be easy to make a “compressor” that rotated the data. It would presumably need to be raw data - but two- and one-byte versions could be useful.
  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!