[nostalgia/core] Move puts function out of core implementations to core
This commit is contained in:
parent
758907ab5a
commit
628b4d656b
@ -1,6 +1,7 @@
|
|||||||
add_library(
|
add_library(
|
||||||
NostalgiaCore
|
NostalgiaCore
|
||||||
core.cpp
|
core.cpp
|
||||||
|
gfx.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
|
@ -10,17 +10,16 @@
|
|||||||
#include <ox/mc/mc.hpp>
|
#include <ox/mc/mc.hpp>
|
||||||
#include <ox/std/std.hpp>
|
#include <ox/std/std.hpp>
|
||||||
|
|
||||||
#include "../media.hpp"
|
#include <nostalgia/core/media.hpp>
|
||||||
|
#include <nostalgia/core/gfx.hpp>
|
||||||
|
|
||||||
#include "addresses.hpp"
|
#include "addresses.hpp"
|
||||||
#include "gba.hpp"
|
#include "gba.hpp"
|
||||||
#include "panic.hpp"
|
#include "panic.hpp"
|
||||||
|
|
||||||
#include "../gfx.hpp"
|
|
||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
using namespace ox;
|
extern char charMap[128];
|
||||||
|
|
||||||
#define TILE_ADDR ((CharBlock*) 0x06000000)
|
#define TILE_ADDR ((CharBlock*) 0x06000000)
|
||||||
#define TILE8_ADDR ((CharBlock8*) 0x06000000)
|
#define TILE8_ADDR ((CharBlock8*) 0x06000000)
|
||||||
@ -28,137 +27,6 @@ using namespace ox;
|
|||||||
constexpr auto GBA_TILE_COLUMNS = 32;
|
constexpr auto GBA_TILE_COLUMNS = 32;
|
||||||
constexpr auto GBA_TILE_ROWS = 32;
|
constexpr auto GBA_TILE_ROWS = 32;
|
||||||
|
|
||||||
// map ASCII values to the nostalgia charset
|
|
||||||
static char charMap[128] = {
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0, // space
|
|
||||||
38, // !
|
|
||||||
0, // "
|
|
||||||
0, // #
|
|
||||||
0, // $
|
|
||||||
0, // %
|
|
||||||
0, // &
|
|
||||||
0, // '
|
|
||||||
42, // (
|
|
||||||
43, // )
|
|
||||||
0, // *
|
|
||||||
0, // +
|
|
||||||
37, // ,
|
|
||||||
0, // -
|
|
||||||
39, // .
|
|
||||||
0, // /
|
|
||||||
27, // 0
|
|
||||||
28, // 1
|
|
||||||
29, // 2
|
|
||||||
30, // 3
|
|
||||||
31, // 4
|
|
||||||
32, // 5
|
|
||||||
33, // 6
|
|
||||||
34, // 7
|
|
||||||
35, // 8
|
|
||||||
36, // 9
|
|
||||||
40, // :
|
|
||||||
0, // ;
|
|
||||||
0, // <
|
|
||||||
41, // =
|
|
||||||
0, // >
|
|
||||||
0, // ?
|
|
||||||
0, // @
|
|
||||||
1, // A
|
|
||||||
2, // B
|
|
||||||
3, // C
|
|
||||||
4, // D
|
|
||||||
5, // E
|
|
||||||
6, // F
|
|
||||||
7, // G
|
|
||||||
8, // H
|
|
||||||
9, // I
|
|
||||||
10, // J
|
|
||||||
11, // K
|
|
||||||
12, // L
|
|
||||||
13, // M
|
|
||||||
14, // N
|
|
||||||
15, // O
|
|
||||||
16, // P
|
|
||||||
17, // Q
|
|
||||||
18, // R
|
|
||||||
19, // S
|
|
||||||
20, // T
|
|
||||||
21, // U
|
|
||||||
22, // V
|
|
||||||
23, // W
|
|
||||||
24, // X
|
|
||||||
25, // Y
|
|
||||||
26, // Z
|
|
||||||
44, // [
|
|
||||||
0, // backslash
|
|
||||||
45, // ]
|
|
||||||
0, // ^
|
|
||||||
0, // _
|
|
||||||
0, // `
|
|
||||||
1, // a
|
|
||||||
2, // b
|
|
||||||
3, // c
|
|
||||||
4, // d
|
|
||||||
5, // e
|
|
||||||
6, // f
|
|
||||||
7, // g
|
|
||||||
8, // h
|
|
||||||
9, // i
|
|
||||||
10, // j
|
|
||||||
11, // k
|
|
||||||
12, // l
|
|
||||||
13, // m
|
|
||||||
14, // n
|
|
||||||
15, // o
|
|
||||||
16, // p
|
|
||||||
17, // q
|
|
||||||
18, // r
|
|
||||||
19, // s
|
|
||||||
20, // t
|
|
||||||
21, // u
|
|
||||||
22, // v
|
|
||||||
23, // w
|
|
||||||
24, // x
|
|
||||||
25, // y
|
|
||||||
26, // z
|
|
||||||
46, // {
|
|
||||||
0, // |
|
|
||||||
48, // }
|
|
||||||
0, // ~
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GbaPaletteTarget {
|
struct GbaPaletteTarget {
|
||||||
volatile uint16_t *palette = nullptr;
|
volatile uint16_t *palette = nullptr;
|
||||||
};
|
};
|
||||||
@ -277,16 +145,8 @@ ox::Error loadTileSheet(Context *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do NOT use Context in the GBA version of this function.
|
// Do NOT use Context in the GBA version of this function.
|
||||||
void puts(Context*, int loc, const char *str) {
|
|
||||||
for (int i = 0; str[i]; i++) {
|
|
||||||
MEM_BG_MAP[28][loc + i] = charMap[(int) str[i]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTile(Context*, int layer, int column, int row, uint8_t tile) {
|
void setTile(Context*, int layer, int column, int row, uint8_t tile) {
|
||||||
if (column < GBA_TILE_COLUMNS && row < GBA_TILE_ROWS) {
|
MEM_BG_MAP[28 + layer][row * GBA_TILE_COLUMNS + column] = tile;
|
||||||
MEM_BG_MAP[28 + layer][row * GBA_TILE_COLUMNS + column] = tile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
150
src/nostalgia/core/gfx.cpp
Normal file
150
src/nostalgia/core/gfx.cpp
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 - 2019 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/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gfx.hpp"
|
||||||
|
|
||||||
|
namespace nostalgia::core {
|
||||||
|
|
||||||
|
// map ASCII values to the nostalgia charset
|
||||||
|
char charMap[128] = {
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0, // space
|
||||||
|
38, // !
|
||||||
|
0, // "
|
||||||
|
0, // #
|
||||||
|
0, // $
|
||||||
|
0, // %
|
||||||
|
0, // &
|
||||||
|
0, // '
|
||||||
|
42, // (
|
||||||
|
43, // )
|
||||||
|
0, // *
|
||||||
|
0, // +
|
||||||
|
37, // ,
|
||||||
|
0, // -
|
||||||
|
39, // .
|
||||||
|
0, // /
|
||||||
|
27, // 0
|
||||||
|
28, // 1
|
||||||
|
29, // 2
|
||||||
|
30, // 3
|
||||||
|
31, // 4
|
||||||
|
32, // 5
|
||||||
|
33, // 6
|
||||||
|
34, // 7
|
||||||
|
35, // 8
|
||||||
|
36, // 9
|
||||||
|
40, // :
|
||||||
|
0, // ;
|
||||||
|
0, // <
|
||||||
|
41, // =
|
||||||
|
0, // >
|
||||||
|
0, // ?
|
||||||
|
0, // @
|
||||||
|
1, // A
|
||||||
|
2, // B
|
||||||
|
3, // C
|
||||||
|
4, // D
|
||||||
|
5, // E
|
||||||
|
6, // F
|
||||||
|
7, // G
|
||||||
|
8, // H
|
||||||
|
9, // I
|
||||||
|
10, // J
|
||||||
|
11, // K
|
||||||
|
12, // L
|
||||||
|
13, // M
|
||||||
|
14, // N
|
||||||
|
15, // O
|
||||||
|
16, // P
|
||||||
|
17, // Q
|
||||||
|
18, // R
|
||||||
|
19, // S
|
||||||
|
20, // T
|
||||||
|
21, // U
|
||||||
|
22, // V
|
||||||
|
23, // W
|
||||||
|
24, // X
|
||||||
|
25, // Y
|
||||||
|
26, // Z
|
||||||
|
44, // [
|
||||||
|
0, // backslash
|
||||||
|
45, // ]
|
||||||
|
0, // ^
|
||||||
|
0, // _
|
||||||
|
0, // `
|
||||||
|
1, // a
|
||||||
|
2, // b
|
||||||
|
3, // c
|
||||||
|
4, // d
|
||||||
|
5, // e
|
||||||
|
6, // f
|
||||||
|
7, // g
|
||||||
|
8, // h
|
||||||
|
9, // i
|
||||||
|
10, // j
|
||||||
|
11, // k
|
||||||
|
12, // l
|
||||||
|
13, // m
|
||||||
|
14, // n
|
||||||
|
15, // o
|
||||||
|
16, // p
|
||||||
|
17, // q
|
||||||
|
18, // r
|
||||||
|
19, // s
|
||||||
|
20, // t
|
||||||
|
21, // u
|
||||||
|
22, // v
|
||||||
|
23, // w
|
||||||
|
24, // x
|
||||||
|
25, // y
|
||||||
|
26, // z
|
||||||
|
46, // {
|
||||||
|
0, // |
|
||||||
|
48, // }
|
||||||
|
0, // ~
|
||||||
|
};
|
||||||
|
|
||||||
|
void puts(Context *ctx, int loc, const char *str) {
|
||||||
|
for (int i = 0; str[i]; i++) {
|
||||||
|
setTile(ctx, 0, loc + i, 0, charMap[static_cast<int>(str[i])]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -55,8 +55,10 @@ ox::Error shutdownGfx() {
|
|||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error initConsole(Context*) {
|
ox::Error initConsole(Context *ctx) {
|
||||||
return OxError(1);
|
constexpr auto TilesheetAddr = "/TileSheets/Charset.ng";
|
||||||
|
constexpr auto PaletteAddr = "/Palettes/Charset.npal";
|
||||||
|
return loadTileSheet(ctx, TileSheetSpace::Background, 0, TilesheetAddr, PaletteAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Color createSDL_Color(Color nc) {
|
SDL_Color createSDL_Color(Color nc) {
|
||||||
@ -154,9 +156,6 @@ void draw() {
|
|||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void puts(Context*, int, const char*) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTile(Context*, int, int, int, uint8_t) {
|
void setTile(Context*, int, int, int, uint8_t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user