Enable drawing of backgroud tiles.

This commit is contained in:
2017-04-04 19:21:29 -05:00
parent 42d8a3f792
commit f6bf7ede6b
17 changed files with 280 additions and 26 deletions
+32 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2016 gtalent2@gmail.com
* Copyright 2016-2017 gtalent2@gmail.com
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -8,17 +8,46 @@
#include <ox/std/types.hpp>
#include "registers.hpp"
#include "dirt.h"
namespace nostalgia {
namespace core {
using namespace ox::std;
typedef struct { uint32_t data[8]; } Tile, Tile4;
// d-tile: double-sized tile (8bpp)
typedef struct { uint32_t data[16]; } Tile8;
// tile block: 32x16 tiles, 16x16 d-tiles
typedef struct { unsigned short data[256]; } Pallete;
typedef Tile CharBlock[512];
typedef Tile8 CharBlock8[256];
#define TILE_ADDR ((CharBlock*) 0x06000000)
#define TILE8_ADDR ((CharBlock8*) 0x06000000)
#define PALLETE_BG ((unsigned short*) 0x05000000)
#define PALLETE_SPRITE ((unsigned short*) 0x05000200)
typedef uint16_t BgMapTile[1024];
#define BG_MAP ((BgMapTile*) 0x06000000)
ox::std::Error initGfx() {
/* Sprite Mode ----\ */
/* ---\| */
/* Background 2 -\|| */
/* Background 0 -\|| */
/* Objects -----\||| */
/* |||| */
REG_DISPCNT = 0x1400;
REG_DISPCNT = 0x1100;
TILE_ADDR[0][1] = *(Tile*) dirtTiles;
for (auto i = 0; i < (dirtPalLen / 2); i++) {
PALLETE_BG[i] = dirtPal[i];
}
BG_MAP[28][52] = 1;
REG_BG0CNT = (28 << 8) | 1;
return 0;
}