This repository has been archived by the owner on Apr 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefine.hpp
44 lines (38 loc) · 1.44 KB
/
define.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include <cstdint>
#include <SDL.h>
#include <string>
#include <vector>
using color = uint8_t; /* color: 4bit */
using rect = struct {
uint8_t x, y, w, h;
};
using bank = struct {
std::string title;
// todo: sprite, map, sfx, music...
};
using cartridge = struct {
std::string code;
};
static SDL_Color to_sdl_color(const color c) {
const uint8_t col = c & 0xf;
switch (col) {
case 0x1: return SDL_Color{0xff, 0xff, 0xff, 0xff}; // white
case 0x2: return SDL_Color{0xff, 0x00, 0x00, 0xff}; // red
case 0x3: return SDL_Color{0x00, 0xff, 0x00, 0xff}; // lime
case 0x4: return SDL_Color{0x00, 0x00, 0xff, 0xff}; // blue
case 0x5: return SDL_Color{0xff, 0xff, 0x00, 0xff}; // yellow
case 0x6: return SDL_Color{0xff, 0x00, 0xff, 0xff}; // fuchsia
case 0x7: return SDL_Color{0x00, 0xff, 0xff, 0xff}; // aqua
case 0x8: return SDL_Color{0x80, 0x00, 0x00, 0xff}; // maroon
case 0x9: return SDL_Color{0x00, 0x80, 0x00, 0xff}; // green
case 0xa: return SDL_Color{0x00, 0x00, 0x80, 0xff}; // navy
case 0xb: return SDL_Color{0x80, 0x80, 0x00, 0xff}; // olive
case 0xc: return SDL_Color{0x80, 0x00, 0x80, 0xff}; // purple
case 0xd: return SDL_Color{0x00, 0x80, 0x80, 0xff}; // teal
case 0xe: return SDL_Color{0xc0, 0xc0, 0xc0, 0xff}; // sliver
case 0xf: return SDL_Color{0x80, 0x80, 0x80, 0xff}; // gray
case 0x0:
default : return SDL_Color{0x00, 0x00, 0x00, 0x00}; // empty
}
}