Add support for loading charset and remove dirt.{h,s}

This commit is contained in:
2017-04-14 04:08:13 -05:00
parent 552838c323
commit 63f7daa810
9 changed files with 51 additions and 223 deletions

View File

@ -6,7 +6,6 @@ if(WOMBAT_BUILD_TYPE STREQUAL "GBA")
CPP
gba/gfx.cpp
gba/media.cpp
gba/dirt.s
)
elseif(WOMBAT_BUILD_TYPE STREQUAL "Native")
set(
@ -25,6 +24,7 @@ install(
FILES
core.hpp
gfx.hpp
gba/gba.hpp
DESTINATION
include/nostalgia/core
)

View File

@ -39,8 +39,8 @@
/////////////////////////////////////////////////////////////////
// Memory Addresses
#define MEM_PALLETE_BG *((unsigned short*) 0x05000000)
#define MEM_PALLETE_SPRITE *((unsigned short*) 0x05000200)
#define MEM_PALLETE_BG ((uint16_t*) 0x05000000)
#define MEM_PALLETE_SPRITE ((uint16_t*) 0x05000200)
typedef uint16_t BgMapTile[1024];
#define MEM_BG_MAP ((BgMapTile*) 0x06000000)

View File

@ -1,35 +0,0 @@
/*
* 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
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
//{{BLOCK(dirt)
//======================================================================
//
// dirt, 80x72@4,
// + palette 256 entries, not compressed
// + 90 tiles not compressed
// Total size: 512 + 2880 = 3392
//
// Time-stamp: 2016-07-06, 22:51:35
// Exported by Cearn's GBA Image Transmogrifier, v0.8.12
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
#ifndef GRIT_DIRT_H
#define GRIT_DIRT_H
#define dirtTilesLen 2880
extern const unsigned int dirtTiles[720];
#define dirtPalLen 512
extern const unsigned short dirtPal[256];
#endif // GRIT_DIRT_H
//}}BLOCK(dirt)

View File

@ -1,165 +0,0 @@
@{{BLOCK(dirt)
@=======================================================================
@
@ dirt, 80x72@4,
@ + palette 256 entries, not compressed
@ + 90 tiles not compressed
@ Total size: 512 + 2880 = 3392
@
@ Time-stamp: 2016-07-06, 22:51:35
@ Exported by Cearn's GBA Image Transmogrifier, v0.8.12
@ ( http://www.coranac.com/projects/#grit )
@
@=======================================================================
.section .rodata
.align 2
.global dirtTiles @ 2880 unsigned chars
.hidden dirtTiles
dirtTiles:
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x23324444,0x31134444,0x31134444,0x23324444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x24444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444233
.word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444
.word 0x44444444,0x32444444,0x13444444,0x13444444,0x32444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444423,0x44444431,0x44444431,0x44444423,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x34444444,0x34444444,0x24444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444311,0x44444311,0x44444233,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x32444444,0x13444444,0x13444444,0x32444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444423,0x44444431,0x44444431,0x44444423,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x33244444,0x11344444,0x11344444,0x33244444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444442,0x44444443,0x44444443,0x44444442,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44233244,0x44311344
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x42332444,0x43113444,0x43113444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44311344,0x44233244,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x42332444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44442332,0x44443113,0x44443113,0x44442332,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x33244444,0x11344444,0x11344444,0x33244444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444442,0x44444443,0x44444443,0x44444442,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x42332444,0x43113444,0x43113444,0x42332444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x23324444,0x31134444,0x31134444,0x23324444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x42332444,0x43113444,0x43113444,0x42332444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444
.word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000
.word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000
.word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000000,0x00000000
.section .rodata
.align 2
.global dirtPal @ 512 unsigned chars
.hidden dirtPal
dirtPal:
.hword 0x0000,0x5EF7,0x7BDE,0x739C,0x7FFF,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
@}}BLOCK(dirt)

View File

@ -8,6 +8,8 @@
#pragma once
#include <ox/std/types.hpp>
namespace nostalgia {
namespace core {
@ -15,7 +17,7 @@ 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 unsigned short Pallete[256];
typedef uint16_t Pallete[256];
typedef Tile CharBlock[512];
typedef Tile8 CharBlock8[256];

View File

@ -11,7 +11,6 @@
#include "addresses.hpp"
#include "media.hpp"
#include "gba.hpp"
#include "dirt.h"
namespace nostalgia {
namespace core {
@ -29,25 +28,17 @@ ox::Error initGfx() {
/* |||| */
REG_DISPCNT = 0x1100;
TILE_ADDR[0][1] = *(Tile*) dirtTiles;
for (auto i = 0; i < (dirtPalLen / 2); i++) {
(&MEM_PALLETE_BG)[i] = dirtPal[i];
}
auto fs = (FileStore32*) findMedia();
REG_BG0CNT = (28 << 8) | 1;
REG_BG0CNT |= (1 << 7); // set to use 8 bits per pixel
if (fs) {
FileStore32::FsSize_t readSize = 0;
fs->read(1, 511, 8 * 64 * 36, &TILE8_ADDR[0][1], nullptr);
fs->read(1, 0, 512, &MEM_PALLETE_BG[0], &readSize);
}
MEM_BG_MAP[28][106] = 1;
MEM_BG_MAP[28][107] = 1;
if (fs) {
char out[6];
FileStore32::FsSize_t outSize = 0;
fs->read(3, out, &outSize);
if (outSize == 5) {
MEM_BG_MAP[28][138] = 1;
MEM_BG_MAP[28][139] = 1;
}
}
return 0;
}

View File

@ -59,6 +59,7 @@ int pointToIdx(int w, int x, int y) {
int run(ClArgs args) {
Error err = 0;
int argInode = args.getInt("inode");
QString argInPath = args.getString("img").c_str();
QString argFsPath = args.getString("fs").c_str();
auto argCompact = args.getBool("c");
@ -100,7 +101,7 @@ int run(ClArgs args) {
if (fs) {
fs = expandCopyCleanup(fs, fs->size() + fs->spaceNeeded(imgDataBuffSize));
fsBuff = fs->buff(); // update fsBuff pointer in case there is a new buff
err |= fs->write(1, imgDataBuff, imgDataBuffSize);
err |= fs->write(argInode, imgDataBuff, imgDataBuffSize);
if (argCompact) {
fs->resize();