aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basys3/basys3.srcs/io.xdc6
-rw-r--r--basys3/basys3.srcs/top.vhd105
-rw-r--r--pinout.md33
-rw-r--r--src/.vscode/c_cpp_properties.json16
-rw-r--r--src/.vscode/settings.json6
-rw-r--r--src/demo.c169
-rw-r--r--src/demo.h35
-rw-r--r--src/ds.c15
-rw-r--r--src/ds.mk5
-rw-r--r--src/engine/TODO/hh_combat.h (renamed from src/stm32/TODO/hh_combat.h)0
-rw-r--r--src/engine/TODO/hh_draw_screen.h (renamed from src/stm32/TODO/hh_draw_screen.h)0
-rw-r--r--src/engine/TODO/hh_entity.c (renamed from src/stm32/TODO/hh_entity.c)9
-rw-r--r--src/engine/TODO/hh_entity.h (renamed from src/stm32/TODO/hh_entity.h)0
-rw-r--r--src/engine/TODO/hh_level.h (renamed from src/stm32/TODO/hh_level.h)0
-rw-r--r--src/engine/TODO/hh_rand.h (renamed from src/stm32/TODO/hh_rand.h)0
-rw-r--r--src/engine/TODO/maths.c1
-rw-r--r--src/engine/TODO/maths.h (renamed from src/stm32/TODO/maths.h)4
-rw-r--r--src/engine/TODO/player_controller.h (renamed from src/stm32/TODO/player_controller.h)0
-rw-r--r--src/engine/TODO/sprite_controller.h (renamed from src/stm32/TODO/sprite_controller.h)0
-rw-r--r--src/entity.h15
-rw-r--r--src/input.h22
-rw-r--r--src/main.c20
-rw-r--r--src/makefile4
-rw-r--r--src/ppu/internals.c75
-rw-r--r--src/ppu/ppu.c22
-rw-r--r--src/ppu/ppu.h3
-rw-r--r--src/ppu/stm.c4
-rw-r--r--src/ppusim/input.c15
-rw-r--r--src/ppusim/mem.c4
-rw-r--r--src/ppusim/pixel.c77
-rw-r--r--src/ppusim/sim.c16
-rw-r--r--src/ppusim/work.c35
-rw-r--r--src/stm32.mk31
-rw-r--r--src/stm32/TODO/maths.c10
-rw-r--r--src/stm32/input.c13
-rw-r--r--src/stm32/setup.c197
-rw-r--r--src/stm32/setup.h24
-rw-r--r--src/stm32/stm32f0xx_hal_conf.h16
-rw-r--r--style.md1
-rw-r--r--test/bin/tiles.bs544
40 files changed, 1333 insertions, 219 deletions
diff --git a/basys3/basys3.srcs/io.xdc b/basys3/basys3.srcs/io.xdc
new file mode 100644
index 0000000..f254cdd
--- /dev/null
+++ b/basys3/basys3.srcs/io.xdc
@@ -0,0 +1,6 @@
+set_property PACKAGE_PIN A15 [get_ports clkSPI]
+set_property PACKAGE_PIN C15 [get_ports csSPI]
+set_property PACKAGE_PIN A17 [get_ports dataSPI]
+set_property IOSTANDARD LVCMOS33 [get_ports dataSPI]
+set_property IOSTANDARD LVCMOS33 [get_ports csSPI]
+set_property IOSTANDARD LVCMOS33 [get_ports clkSPI] \ No newline at end of file
diff --git a/basys3/basys3.srcs/top.vhd b/basys3/basys3.srcs/top.vhd
new file mode 100644
index 0000000..7cf3e63
--- /dev/null
+++ b/basys3/basys3.srcs/top.vhd
@@ -0,0 +1,105 @@
+----------------------------------------------------------------------------------
+-- Company:
+-- Engineer:
+--
+-- Create Date: 15.02.2023 21:09:16
+-- Design Name:
+-- Module Name: top - Behavioral
+-- Project Name:
+-- Target Devices:
+-- Tool Versions:
+-- Description:
+--
+-- Dependencies:
+--
+-- Revision:
+-- Revision 0.01 - File Created
+-- Additional Comments:
+--
+----------------------------------------------------------------------------------
+
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+
+-- Uncomment the following library declaration if using
+-- arithmetic functions with Signed or Unsigned values
+use IEEE.NUMERIC_STD.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+-- Uncomment the following library declaration if instantiating
+-- any Xilinx leaf cells in this code.
+--library UNISIM;
+--use UNISIM.VComponents.all;
+
+entity spiSlave is
+ Port ( clkBoard : in std_logic; -- clock basys3 100MHz
+ clkSPI : in std_logic; -- incoming clock of SPI
+ dataSPI : in std_logic; -- incoming data of SPI
+ csSPI : in std_logic; -- incoming select of SPI
+ dataRead : out std_logic_vector(23 downto 0) := (others => '0') -- data read
+
+ );
+end spiSlave;
+
+architecture Behavioral of spiSlave is
+ signal PulseFF0,PulseFF1,PulseFF2,PulseFF3 : std_logic := '0'; -- signal for metastability synchronizer of clk SPI
+ signal dataFF0,dataFF1,dataFF2,dataFF3 : std_logic := '0'; -- signal for metastability synchronizer of data SPI
+ signal ssFF0,ssFF1,ssFF2,ssFF3 : std_logic := '0'; -- signal for metastability synchronizer of slave select SPI
+
+ signal data : std_logic_vector(23 downto 0) := (others => '0'); -- signal to store incomming data of dataSPI (2x 8bit)
+ signal counter : integer := 23; --counter for data position
+ signal enable : std_logic := '0'; -- enable signal if slave is selected
+begin
+
+ process (clkBoard)
+ begin
+
+ if rising_edge(clkBoard) then
+ -- flip flop for clk SPI to synchronise a
+ PulseFF0 <= clkSPI;
+ PulseFF1 <= PulseFF0;
+ PulseFF2 <= PulseFF1;
+ PulseFF3 <= PulseFF2;
+ -- flip flop for data SPI to synchronise
+ dataFF0 <= dataSPI;
+ dataFF1 <= dataFF0;
+ dataFF2 <= dataFF1;
+ dataFF3 <= dataFF2;
+ -- flip flop for slave select SPI to synchronise
+ ssFF0 <= csSPI;
+ ssFF1 <= ssFF0;
+ ssFF2 <= ssFF1;
+ ssFF3 <= ssFF2;
+ -- check if slave select signal has falling edge (slave is selected by master)
+ if(ssFF3 = '1' and ssFF2 = '0') then
+ --reset counter if true
+ counter <= 23;
+ --disable data read if rising edge (slave is not selected)
+ elsif (ssFF3 = '0' and ssFF2 = '1') then
+ enable <= '0';
+ end if;
+ --check if synchronised slave select signal is falling edge or data read is enabled
+ if(ssFF3 = '1' and ssFF2 = '0') or enable = '1' then
+ enable <= '1'; --enable data read
+ if (PulseFF3 = '0' and PulseFF2 = '1') then -- check for rising edge of clk SPI
+ if counter > -1 then
+ counter <= counter - 1;
+ -- data transfer into vector
+ data(counter) <= dataFF3;
+ end if;
+ end if;
+ --check if counter is done
+ if counter = -1 then
+ counter <= 23; --reset counter
+ dataRead <= data;
+ end if;
+ elsif (enable = '0') then
+ --dataRead <= data;
+
+ end if;
+
+ end if;
+
+ end process;
+
+end Behavioral;
diff --git a/pinout.md b/pinout.md
new file mode 100644
index 0000000..f4569d2
--- /dev/null
+++ b/pinout.md
@@ -0,0 +1,33 @@
+Pin layout
+
+| pin STM | function |
+|---------|----------|
+| PA5 / D13 | SPI clock |
+| PA7 / D11 | SPI MOSI |
+| PA9 / D8 | SPI cs |
+| PB4 / D5 | button 1 |
+| PB5 / D4 | button 2 |
+| PB6 / D10 | button 3 |
+| PB8 / D15 | button 4 |
+
+| pin FPGA | function |
+|---------|----------|
+| JB 7 | SPI clock |
+| JB 8 | SPI data |
+| JB 9 | SPI cs |
+
+
+
+constraints:
+
+set_property PACKAGE_PIN A15 [get_ports clkSPI]
+
+set_property PACKAGE_PIN C15 [get_ports csSPI]
+
+set_property PACKAGE_PIN A17 [get_ports dataSPI]
+
+set_property IOSTANDARD LVCMOS33 [get_ports dataSPI]
+
+set_property IOSTANDARD LVCMOS33 [get_ports csSPI]
+
+set_property IOSTANDARD LVCMOS33 [get_ports clkSPI] .
diff --git a/src/.vscode/c_cpp_properties.json b/src/.vscode/c_cpp_properties.json
new file mode 100644
index 0000000..359928d
--- /dev/null
+++ b/src/.vscode/c_cpp_properties.json
@@ -0,0 +1,16 @@
+{
+ "configurations": [
+ {
+ "name": "Linux",
+ "includePath": [
+ "${workspaceFolder}/**"
+ ],
+ "defines": [],
+ "compilerPath": "/usr/bin/gcc",
+ "cStandard": "c17",
+ "cppStandard": "c++14",
+ "intelliSenseMode": "linux-gcc-x64"
+ }
+ ],
+ "version": 4
+} \ No newline at end of file
diff --git a/src/.vscode/settings.json b/src/.vscode/settings.json
new file mode 100644
index 0000000..d485e2c
--- /dev/null
+++ b/src/.vscode/settings.json
@@ -0,0 +1,6 @@
+{
+ "files.associations": {
+ "hh_entity.h": "c",
+ "maths.h": "c"
+ }
+} \ No newline at end of file
diff --git a/src/demo.c b/src/demo.c
index 019750a..b9bba17 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -1,55 +1,178 @@
#include <math.h>
#include "demo.h"
+#include "entity.h"
+#include "input.h"
#include "ppu/ppu.h"
-#define HH_DEMO_BALL_COUNT 5
+#define HH_DEMO_BALL_COUNT 1
hh_s_ppu_loc_fam_entry g_hh_demo_balls[HH_DEMO_BALL_COUNT];
+hh_s_entity_player g_hh_player_1 = {
+ .pos_x = 31000, // 0b0000 0001 0011 0110
+ .pos_y = 21000,
+ .radius = 8,
+ .speed = 1,
+ .direction_x = 1,
+ .rotation = 8,
+ .in_air = false,
+};
+
+void hh_player_movement();
+
+uint16_t g_hh_pos_x; // 0b0000 0001 0011 0110
+uint16_t g_hh_pos_y;
+uint8_t g_hh_left = 0;
+uint8_t g_hh_right = 0;
+uint8_t g_hh_up = 0;
+uint8_t g_hh_down = 0;
+uint8_t g_hh_pos_x_bit[2];
+uint8_t g_hh_pos_y_bit[2];
+uint8_t g_hh_data_send[3];
+int g_hh_tile_x;
+int g_hh_tile_y;
+
void hh_demo_setup() {
// load sprites
hh_ppu_update_sprite(0, HH_DBG_SPRITE_BALL);
hh_ppu_update_sprite(1, HH_DBG_SPRITE_CHECKERBOARD);
// background pattern
- hh_ppu_update_color(0, 1, (hh_ppu_rgb_color_t) {0x4, 0x4, 0x4});
+ hh_ppu_update_color(0, 1, (hh_ppu_rgb_color_t){0x4, 0x4, 0x4});
for (unsigned i = 0; i < HH_PPU_BG_CANVAS_TILES_H * HH_PPU_BG_CANVAS_TILES_V; i++) {
- hh_ppu_update_background(i, (hh_s_ppu_loc_bam_entry) {
- .horizontal_flip = false,
- .vertical_flip = false,
- .palette_index = 0,
- .tilemap_index = 1,
- });
+ hh_ppu_update_background(i, (hh_s_ppu_loc_bam_entry){
+ .horizontal_flip = false,
+ .vertical_flip = false,
+ .palette_index = 0,
+ .tilemap_index = 1,
+ });
}
// cool colors
- hh_ppu_update_color(1, 1, (hh_ppu_rgb_color_t) {0xf, 0x0, 0xf});
- hh_ppu_update_color(2, 1, (hh_ppu_rgb_color_t) {0xf, 0xf, 0xf});
- hh_ppu_update_color(3, 1, (hh_ppu_rgb_color_t) {0xf, 0x0, 0x0});
- hh_ppu_update_color(4, 1, (hh_ppu_rgb_color_t) {0x0, 0xf, 0xf});
- hh_ppu_update_color(5, 1, (hh_ppu_rgb_color_t) {0x0, 0x0, 0xf});
+ hh_ppu_update_color(1, 1, (hh_ppu_rgb_color_t){0xf, 0x0, 0xf});
+ hh_ppu_update_color(2, 1, (hh_ppu_rgb_color_t){0xf, 0xf, 0xf});
+ hh_ppu_update_color(3, 1, (hh_ppu_rgb_color_t){0xf, 0x0, 0x0});
+ hh_ppu_update_color(4, 1, (hh_ppu_rgb_color_t){0x0, 0xf, 0xf});
+ hh_ppu_update_color(5, 1, (hh_ppu_rgb_color_t){0x0, 0x0, 0xf});
// balls
for (unsigned i = 0; i < HH_DEMO_BALL_COUNT; i++) {
g_hh_demo_balls[i].horizontal_flip = false;
- g_hh_demo_balls[i].vertical_flip = false;
- g_hh_demo_balls[i].palette_index = i+1;
- g_hh_demo_balls[i].tilemap_index = 0;
+ g_hh_demo_balls[i].vertical_flip = false;
+ g_hh_demo_balls[i].palette_index = i + 1;
+ g_hh_demo_balls[i].tilemap_index = 0;
}
}
void hh_demo_loop(unsigned long frame) {
+ hh_player_movement();
+
+ // adjust map size
+ g_hh_pos_x = g_hh_player_1.pos_x / 100;
+ g_hh_pos_y = g_hh_player_1.pos_y / 100;
+
+ // input testing (no hitbox stuff)
+ // pos_x += (-1 * g_hh_controller_p1.dpad_left) + (1 * g_hh_controller_p1.dpad_right); // -1 = L || 1 == R
+ // pos_y += (-1 * g_hh_controller_p1.dpad_up) + (1 * g_hh_controller_p1.dpad_down); // -1 = D || 1 == U
+
+ // update player sprite on ppu
+ g_hh_demo_balls[0].position_x = g_hh_pos_x;
+ g_hh_demo_balls[0].position_y = g_hh_pos_y;
+ hh_ppu_update_foreground(0, g_hh_demo_balls[0]);
+
// set background pattern position
- hh_ppu_update_aux((hh_s_ppu_loc_aux) {
+ hh_ppu_update_aux((hh_s_ppu_loc_aux){
.bg_shift_x = (frame / 2) % HH_PPU_SPRITE_WIDTH,
.bg_shift_y = (frame / 8) % HH_PPU_SPRITE_HEIGHT,
- .fg_fetch = 0,
- .sysreset = 0,
+ .fg_fetch = 0,
+ .sysreset = 0,
});
+}
- for (unsigned i = 0; i < HH_DEMO_BALL_COUNT; i++) {
- g_hh_demo_balls[i].position_x = HH_PPU_SCREEN_WIDTH/2 - HH_PPU_SPRITE_WIDTH/2 + (int)(60 * (double)sin((1*(double)frame / 10) + (double)i * 12));
- g_hh_demo_balls[i].position_y = HH_PPU_SCREEN_HEIGHT/2 - HH_PPU_SPRITE_HEIGHT/2 + (int)(30 * (double)sin((2*(double)frame / 10) + (double)i * 12));
- hh_ppu_update_foreground(i, g_hh_demo_balls[i]);
+// void sendData(uint8_t address, uint16_t data) {
+// uint8_t bitData[3];
+// bitData[2] = data & 0xff;
+// bitData[1] = (data >> 8);
+// bitData[0] = address; // first byte is address
+//
+// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET);
+// HAL_SPI_Transmit(&hspi1, bitData, 3, 100); //2*8 bit data
+// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_SET);
+// }
+
+void hh_player_movement() {
+ int8_t directionX = (-1 * g_hh_controller_p1.dpad_left) + (1 * g_hh_controller_p1.dpad_right); // -1 = L || 1 == R
+ int8_t directionY = (-1 * g_hh_controller_p1.dpad_down) + (1 * g_hh_controller_p1.dpad_up); // -1 = D || 1 == U
+
+ uint8_t i, j;
+ uint8_t rotation = 0; // 0-7
+
+ // rotation calc
+ for (i = -1; i < 2; i++) {
+ for (j = -1; j < 2; j++) {
+ if (directionX == i) {
+ if (directionY == j) {
+ if (i != 0 && j != 0) // dont update when player idle
+ {
+ g_hh_player_1.rotation = rotation;
+ }
+ }
+ }
+ rotation++;
+ }
+ }
+ // direction calc
+ if (directionX != 0) // update direction if player is not idle
+ {
+ g_hh_player_1.direction_x = directionX;
+ }
+ // collision map x-axis
+
+ // tile calc including radius and direction for background coliision
+
+ uint16_t tileColX;
+ uint16_t tileColY = (g_hh_player_1.pos_y / 100) / 16;
+ ;
+
+ // remaining space between grid and exact
+ uint8_t modTileX;
+ uint8_t modTileY;
+
+ if (g_hh_player_1.in_air == false && directionX != 0) {
+ if (directionX == 1) {
+ tileColX = ((g_hh_player_1.pos_x / 100) + g_hh_player_1.radius) / 20;
+ modTileX = (g_hh_player_1.pos_x + (100 * g_hh_player_1.radius)) % 2000;
+ } else if (directionX == -1) {
+ tileColX = ((g_hh_player_1.pos_x / 100) - g_hh_player_1.radius) / 20;
+ modTileX = (g_hh_player_1.pos_x - (100 * g_hh_player_1.radius)) % 2000;
+ }
+
+ if (HH_DEMO_HITBOX_TILEMAP[tileColY][tileColX + directionX] != 1) {
+ g_hh_player_1.pos_x = g_hh_player_1.pos_x + (directionX * g_hh_player_1.speed); // NEW x set
+ }
+
+ else if (HH_DEMO_HITBOX_TILEMAP[tileColY][tileColX + directionX] == 1) {
+ if (modTileX < g_hh_player_1.speed) {
+ g_hh_player_1.pos_x = g_hh_player_1.pos_x + (directionX * modTileX); // NEW x set
+ } else {
+ g_hh_player_1.pos_x = g_hh_player_1.pos_x + (directionX * g_hh_player_1.speed); // NEW x set
+ }
+ }
+
+ } else // if in air different all borders have to be checked
+ {
+ }
+
+ // collision map floor (y-axis) (falling)
+ // if falling no jump press (implement)
+ /*
+ tileColY = (( g_hh_player_1.pos_y / 100) + g_hh_player_1.radius) / 16; //bottom of player box
+ modTileY = 1;
+ if(HH_DEMO_HITBOX_TILEMAP[tileColY+1][tileColX] != 1) //rework after jumping
+ {
+ g_hh_player_1.pos_y = g_hh_player_1.pos_y + 5 ;// NEW y set //makew var gravity
+ //playerStat = falling; //for later use of graphics/sound
}
+ */
+ // else if(HH_DEMO_HITBOX_TILEMAP[])
}
diff --git a/src/demo.h b/src/demo.h
index 89436b5..ddf8403 100644
--- a/src/demo.h
+++ b/src/demo.h
@@ -42,3 +42,38 @@ static const hh_s_ppu_loc_sprite HH_DBG_SPRITE_CHECKERBOARD = {
0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0
};
+
+static const uint8_t HH_DEMO_HITBOX_TILEMAP[30][40] =
+ {
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 },
+ {1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,1,1,1,1 }
+ };
+
diff --git a/src/ds.c b/src/ds.c
new file mode 100644
index 0000000..24ef58f
--- /dev/null
+++ b/src/ds.c
@@ -0,0 +1,15 @@
+#include "demo.h"
+#include "main.h"
+#include "ppu/ppu.h"
+
+void hh_setup() {
+ hh_ppu_init();
+
+ hh_demo_setup();
+}
+
+void hh_exit() {
+ g_hh_run = false;
+
+ hh_ppu_deinit();
+}
diff --git a/src/ds.mk b/src/ds.mk
index d4354a2..57d1776 100644
--- a/src/ds.mk
+++ b/src/ds.mk
@@ -10,5 +10,6 @@ endif
DESKTOP_SRCS += ppusim/sim.c \
ppusim/mem.c \
ppusim/pixel.c \
- ppusim/work.c
-
+ ppusim/work.c \
+ ds.c \
+ ppusim/input.c
diff --git a/src/stm32/TODO/hh_combat.h b/src/engine/TODO/hh_combat.h
index 16c41f5..16c41f5 100644
--- a/src/stm32/TODO/hh_combat.h
+++ b/src/engine/TODO/hh_combat.h
diff --git a/src/stm32/TODO/hh_draw_screen.h b/src/engine/TODO/hh_draw_screen.h
index f5d7507..f5d7507 100644
--- a/src/stm32/TODO/hh_draw_screen.h
+++ b/src/engine/TODO/hh_draw_screen.h
diff --git a/src/stm32/TODO/hh_entity.c b/src/engine/TODO/hh_entity.c
index 94aa370..fa550d5 100644
--- a/src/stm32/TODO/hh_entity.c
+++ b/src/engine/TODO/hh_entity.c
@@ -1,11 +1,3 @@
-<<<<<<< HEAD
-#include "maths.h"
-#include "hh_entity.h"
-
-bool hh_collision(const vec2& environment, const vec2& entity){
-
-}
-=======
#include <stdbool.h>
#include "hh_entity.h"
@@ -47,4 +39,3 @@ void hh_solve_collision(vec2* pos_environment, hh_entity* entity){
}
}
->>>>>>> 458d620a4ae17c42e97413a49db6c1c5f53393e5
diff --git a/src/stm32/TODO/hh_entity.h b/src/engine/TODO/hh_entity.h
index fdbeb8a..fdbeb8a 100644
--- a/src/stm32/TODO/hh_entity.h
+++ b/src/engine/TODO/hh_entity.h
diff --git a/src/stm32/TODO/hh_level.h b/src/engine/TODO/hh_level.h
index 43b19a3..43b19a3 100644
--- a/src/stm32/TODO/hh_level.h
+++ b/src/engine/TODO/hh_level.h
diff --git a/src/stm32/TODO/hh_rand.h b/src/engine/TODO/hh_rand.h
index ea7c1d4..ea7c1d4 100644
--- a/src/stm32/TODO/hh_rand.h
+++ b/src/engine/TODO/hh_rand.h
diff --git a/src/engine/TODO/maths.c b/src/engine/TODO/maths.c
new file mode 100644
index 0000000..d1bb089
--- /dev/null
+++ b/src/engine/TODO/maths.c
@@ -0,0 +1 @@
+#include "maths.h"
diff --git a/src/stm32/TODO/maths.h b/src/engine/TODO/maths.h
index 0889c47..032e56d 100644
--- a/src/stm32/TODO/maths.h
+++ b/src/engine/TODO/maths.h
@@ -1,9 +1,9 @@
#pragma once
-
+#include <stdint.h>
// #include <math.h>
typedef struct {
- u_int32_t x,y;
+ uint32_t x,y;
} vec2;
typedef vec2 vec_cen;//centered
diff --git a/src/stm32/TODO/player_controller.h b/src/engine/TODO/player_controller.h
index 1e9b86c..1e9b86c 100644
--- a/src/stm32/TODO/player_controller.h
+++ b/src/engine/TODO/player_controller.h
diff --git a/src/stm32/TODO/sprite_controller.h b/src/engine/TODO/sprite_controller.h
index c1fadff..c1fadff 100644
--- a/src/stm32/TODO/sprite_controller.h
+++ b/src/engine/TODO/sprite_controller.h
diff --git a/src/entity.h b/src/entity.h
new file mode 100644
index 0000000..20cbf42
--- /dev/null
+++ b/src/entity.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef struct {
+ uint16_t pos_x;
+ uint16_t pos_y;
+ uint8_t radius;
+ uint8_t rotation; //45 degrees steps 0 == right 2 == down 4 == left 6 == up
+ uint8_t direction_x; //direction where its looking at in case no input;
+ int8_t speed; //10 default L/R MODifier
+ bool in_air;
+} hh_s_entity_player;
+
diff --git a/src/input.h b/src/input.h
new file mode 100644
index 0000000..adacba2
--- /dev/null
+++ b/src/input.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <stdbool.h>
+
+/** @brief game controller state */
+typedef struct {
+ bool dpad_up;
+ bool dpad_down;
+ bool dpad_left;
+ bool dpad_right;
+ bool button_primary;
+ bool button_secondary;
+} hh_s_gamepad;
+
+/** @brief player 1's controller */
+extern hh_s_gamepad g_hh_controller_p1;
+/** @brief player 2's controller */
+extern hh_s_gamepad g_hh_controller_p2;
+
+/** @brief update g_hh_controller_p1 and 2 by reading buttons */
+void hh_input_read();
+
diff --git a/src/main.c b/src/main.c
index f4de225..191d5d9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,8 +1,8 @@
#include <stdlib.h>
-#include "main.h"
-#include "ppu/ppu.h"
#include "demo.h"
+#include "input.h"
+#include "main.h"
bool g_hh_run = true;
@@ -15,19 +15,7 @@ int main() {
void hh_ppu_vblank_interrupt() {
static unsigned long frame = 0;
- frame++;
-
+ hh_input_read();
hh_demo_loop(frame);
-}
-
-void hh_setup() {
- hh_ppu_init();
-
- hh_demo_setup();
-}
-
-void hh_exit() {
- g_hh_run = false;
-
- hh_ppu_deinit();
+ frame++;
}
diff --git a/src/makefile b/src/makefile
index 1115874..c69bfb5 100644
--- a/src/makefile
+++ b/src/makefile
@@ -81,8 +81,8 @@ compile_commands.json: makefile stm32.mk ds.mk
PHONY += format
format:
- clang-format -i $(LOCAL_SRCS)
- clang-tidy --fix-errors $(LOCAL_SRCS)
+ clang-format -i $(LOCAL_SRCS) $(DESKTOP_SRCS)
+ clang-tidy --fix-errors $(LOCAL_SRCS) $(DESKTOP_SRCS)
PHONY += clean
clean:
diff --git a/src/ppu/internals.c b/src/ppu/internals.c
index 650ba3e..b8d3e27 100644
--- a/src/ppu/internals.c
+++ b/src/ppu/internals.c
@@ -1,8 +1,8 @@
#include <stdlib.h>
-#include "ppu/types.h"
-#include "ppu/internals.h"
#include "ppu/consts.h"
+#include "ppu/internals.h"
+#include "ppu/types.h"
bool hh_ppu_vram_valid_address(hh_ppu_addr_t addr) {
#pragma GCC diagnostic push
@@ -17,88 +17,59 @@ bool hh_ppu_vram_valid_address(hh_ppu_addr_t addr) {
}
void hh_ppu_vram_write(hh_s_ppu_vram_data data) {
- for (unsigned i = 0; i < data.size; i++)
- hh_ppu_vram_dwrite(data.offset + i, data.data[i]);
+ for (unsigned i = 0; i < data.size; i++) hh_ppu_vram_dwrite(data.offset + i, data.data[i]);
}
hh_s_ppu_vram_data hh_ppu_2nat_bam(hh_s_ppu_loc_bam_entry e) {
- hh_ppu_data_t* data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_BAM_ENTRY_SIZE);
+ hh_ppu_data_t *data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_BAM_ENTRY_SIZE);
- data[0] = HH_RESIZE(e.tilemap_index, 9, 0) << 0 |
- HH_RESIZE(e.palette_index, 2, 0) << 10 |
- e.vertical_flip << 13 |
- e.horizontal_flip << 14;
+ data[0] = HH_RESIZE(e.tilemap_index, 9, 0) << 0 | HH_RESIZE(e.palette_index, 2, 0) << 10 | e.vertical_flip << 13 | e.horizontal_flip << 14;
- hh_s_ppu_vram_data out = {
- .data = data,
- .size = HH_PPU_VRAM_FAM_ENTRY_SIZE
- };
+ hh_s_ppu_vram_data out = {.data = data, .size = HH_PPU_VRAM_FAM_ENTRY_SIZE};
return out;
}
hh_s_ppu_vram_data hh_ppu_2nat_fam(hh_s_ppu_loc_fam_entry e) {
- hh_ppu_data_t* data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_FAM_ENTRY_SIZE);
+ hh_ppu_data_t *data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_FAM_ENTRY_SIZE);
e.position_x += 16;
e.position_y += 16;
- data[0] = HH_RESIZE(e.tilemap_index, 9, 0) << 0 |
- HH_RESIZE(e.palette_index, 2, 0) << 10 |
- HH_RESIZE(e.position_y, 2, 0) << 13;
- data[1] = HH_RESIZE(e.position_y, 7, 3) << 0 |
- HH_RESIZE(e.position_x, 8, 0) << 5 |
- e.vertical_flip << 14 |
- e.horizontal_flip << 15;
-
- hh_s_ppu_vram_data out = {
- .data = data,
- .size = HH_PPU_VRAM_FAM_ENTRY_SIZE
- };
+ data[0] = HH_RESIZE(e.tilemap_index, 9, 0) << 0 | HH_RESIZE(e.palette_index, 2, 0) << 10 | HH_RESIZE(e.position_y, 2, 0) << 13;
+ data[1] = HH_RESIZE(e.position_y, 7, 3) << 0 | HH_RESIZE(e.position_x, 8, 0) << 5 | e.vertical_flip << 14 | e.horizontal_flip << 15;
+
+ hh_s_ppu_vram_data out = {.data = data, .size = HH_PPU_VRAM_FAM_ENTRY_SIZE};
return out;
}
hh_s_ppu_vram_data hh_ppu_2nat_aux(hh_s_ppu_loc_aux aux) {
- hh_ppu_data_t* data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_AUX_SIZE);
-
- data[0] = HH_RESIZE(aux.bg_shift_y, 7, 0) << 0 |
- HH_RESIZE(aux.bg_shift_x, 7, 0) << 8;
- data[1] = HH_RESIZE(aux.bg_shift_x, 8, 8) << 0 |
- aux.fg_fetch << 1 |
- aux.sysreset << 2;
-
- hh_s_ppu_vram_data out = {
- .data = data,
- .size = HH_PPU_VRAM_AUX_SIZE
- };
+ hh_ppu_data_t *data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_AUX_SIZE);
+
+ data[0] = HH_RESIZE(aux.bg_shift_y, 7, 0) << 0 | HH_RESIZE(aux.bg_shift_x, 7, 0) << 8;
+ data[1] = HH_RESIZE(aux.bg_shift_x, 8, 8) << 0 | aux.fg_fetch << 1 | aux.sysreset << 2;
+
+ hh_s_ppu_vram_data out = {.data = data, .size = HH_PPU_VRAM_AUX_SIZE};
return out;
}
hh_s_ppu_vram_data hh_ppu_2nat_sprite(const hh_ppu_loc_sprite_data_t sprite_data) {
- hh_ppu_data_t* data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_TMM_SPRITE_SIZE);
+ hh_ppu_data_t *data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_TMM_SPRITE_SIZE);
for (unsigned i = 0; i < HH_PPU_SPRITE_WIDTH * HH_PPU_SPRITE_HEIGHT; i++) {
- unsigned word = i / 5;
+ unsigned word = i / 5;
unsigned pixel = i % 5;
if (pixel == 0) data[word] = 0;
data[word] |= HH_RESIZE(sprite_data[i], 2, 0) << pixel * 3;
}
- hh_s_ppu_vram_data out = {
- .data = data,
- .size = HH_PPU_VRAM_TMM_SPRITE_SIZE
- };
+ hh_s_ppu_vram_data out = {.data = data, .size = HH_PPU_VRAM_TMM_SPRITE_SIZE};
return out;
}
hh_s_ppu_vram_data hh_ppu_2nat_color(hh_ppu_rgb_color_t rgb) {
- hh_ppu_data_t* data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_PAL_ENTRY_SIZE);
+ hh_ppu_data_t *data = malloc(sizeof(hh_ppu_data_t) * HH_PPU_VRAM_PAL_ENTRY_SIZE);
- data[0] = HH_RESIZE(rgb[0], 3, 0) << 8 |
- HH_RESIZE(rgb[1], 3, 0) << 4 |
- HH_RESIZE(rgb[2], 3, 0) << 0;
+ data[0] = HH_RESIZE(rgb[0], 3, 0) << 8 | HH_RESIZE(rgb[1], 3, 0) << 4 | HH_RESIZE(rgb[2], 3, 0) << 0;
- hh_s_ppu_vram_data out = {
- .data = data,
- .size = HH_PPU_VRAM_PAL_ENTRY_SIZE
- };
+ hh_s_ppu_vram_data out = {.data = data, .size = HH_PPU_VRAM_PAL_ENTRY_SIZE};
return out;
}
diff --git a/src/ppu/ppu.c b/src/ppu/ppu.c
index 5f33c55..df14b9f 100644
--- a/src/ppu/ppu.c
+++ b/src/ppu/ppu.c
@@ -1,52 +1,48 @@
#include <stdlib.h>
-#include "ppu/ppu.h"
-#include "ppu/internals.h"
#include "ppu/consts.h"
+#include "ppu/internals.h"
+#include "ppu/ppu.h"
void hh_ppu_update_foreground(unsigned index, hh_s_ppu_loc_fam_entry e) {
hh_s_ppu_vram_data s = hh_ppu_2nat_fam(e);
- s.offset = HH_PPU_VRAM_FAM_OFFSET + HH_PPU_VRAM_FAM_ENTRY_SIZE * index;
+ s.offset = HH_PPU_VRAM_FAM_OFFSET + HH_PPU_VRAM_FAM_ENTRY_SIZE * index;
hh_ppu_vram_write(s);
free(s.data);
}
void hh_ppu_update_background(unsigned index, hh_s_ppu_loc_bam_entry e) {
hh_s_ppu_vram_data s = hh_ppu_2nat_bam(e);
- s.offset = HH_PPU_VRAM_BAM_OFFSET + HH_PPU_VRAM_BAM_ENTRY_SIZE * index;
+ s.offset = HH_PPU_VRAM_BAM_OFFSET + HH_PPU_VRAM_BAM_ENTRY_SIZE * index;
hh_ppu_vram_write(s);
free(s.data);
}
void hh_ppu_update_sprite(unsigned tilemap_index, const hh_s_ppu_loc_sprite sprite) {
hh_s_ppu_vram_data s = hh_ppu_2nat_sprite(sprite);
- s.offset = HH_PPU_VRAM_TMM_OFFSET + HH_PPU_VRAM_TMM_SPRITE_SIZE * tilemap_index;
+ s.offset = HH_PPU_VRAM_TMM_OFFSET + HH_PPU_VRAM_TMM_SPRITE_SIZE * tilemap_index;
hh_ppu_vram_write(s);
free(s.data);
}
void hh_ppu_update_aux(hh_s_ppu_loc_aux aux) {
hh_s_ppu_vram_data a = hh_ppu_2nat_aux(aux);
- a.offset = HH_PPU_VRAM_AUX_OFFSET;
+ a.offset = HH_PPU_VRAM_AUX_OFFSET;
hh_ppu_vram_write(a);
free(a.data);
}
void hh_ppu_update_palette_table(hh_ppu_loc_palette_table_t table) {
- for(unsigned i = 0; i < HH_PPU_PALETTE_COUNT; i++)
- hh_ppu_update_palette(i, table[i]);
+ for (unsigned i = 0; i < HH_PPU_PALETTE_COUNT; i++) hh_ppu_update_palette(i, table[i]);
}
void hh_ppu_update_palette(unsigned palette_index, hh_ppu_loc_palette_data_t palette) {
- for(unsigned i = 0; i < HH_PPU_PALETTE_COLOR_COUNT; i++)
- hh_ppu_update_color(palette_index, i, palette[i]);
+ for (unsigned i = 0; i < HH_PPU_PALETTE_COLOR_COUNT; i++) hh_ppu_update_color(palette_index, i, palette[i]);
}
void hh_ppu_update_color(unsigned palette_index, unsigned color_index, hh_ppu_rgb_color_t color) {
hh_s_ppu_vram_data c = hh_ppu_2nat_color(color);
- c.offset = HH_PPU_VRAM_PAL_OFFSET +
- palette_index * HH_PPU_VRAM_PAL_ENTRY_SIZE * HH_PPU_PALETTE_COLOR_COUNT +
- color_index * HH_PPU_VRAM_PAL_ENTRY_SIZE;
+ c.offset = HH_PPU_VRAM_PAL_OFFSET + palette_index * HH_PPU_VRAM_PAL_ENTRY_SIZE * HH_PPU_PALETTE_COLOR_COUNT + color_index * HH_PPU_VRAM_PAL_ENTRY_SIZE;
hh_ppu_vram_write(c);
free(c.data);
}
diff --git a/src/ppu/ppu.h b/src/ppu/ppu.h
index 75d97c1..18b58a2 100644
--- a/src/ppu/ppu.h
+++ b/src/ppu/ppu.h
@@ -9,6 +9,9 @@ void hh_ppu_init();
/** @brief deinitialize ppu interface */
void hh_ppu_deinit();
+/** @brief */
+void hh_ppu_load_tilemap();
+
/** @brief update single foreground sprite */
void hh_ppu_update_foreground(unsigned index, hh_s_ppu_loc_fam_entry e);
/** @brief update single background sprite */
diff --git a/src/ppu/stm.c b/src/ppu/stm.c
new file mode 100644
index 0000000..fd4a18c
--- /dev/null
+++ b/src/ppu/stm.c
@@ -0,0 +1,4 @@
+#include "ppu/ppu.h"
+
+void hh_ppu_init() {}
+void hh_ppu_deinit() {}
diff --git a/src/ppusim/input.c b/src/ppusim/input.c
new file mode 100644
index 0000000..08bc382
--- /dev/null
+++ b/src/ppusim/input.c
@@ -0,0 +1,15 @@
+#include <SDL2/SDL.h>
+
+#include "input.h"
+
+hh_s_gamepad g_hh_controller_p1 = {0};
+hh_s_gamepad g_hh_controller_p2 = {0};
+
+void hh_input_read() {
+ // SDL_PumpEvents();
+ const Uint8 *kb = SDL_GetKeyboardState(NULL);
+ g_hh_controller_p1.dpad_up = kb[SDL_SCANCODE_W];
+ g_hh_controller_p1.dpad_down = kb[SDL_SCANCODE_S];
+ g_hh_controller_p1.dpad_left = kb[SDL_SCANCODE_A];
+ g_hh_controller_p1.dpad_right = kb[SDL_SCANCODE_D];
+}
diff --git a/src/ppusim/mem.c b/src/ppusim/mem.c
index e3f41f5..bd8606e 100644
--- a/src/ppusim/mem.c
+++ b/src/ppusim/mem.c
@@ -1,8 +1,8 @@
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
-#include "ppusim/mem.h"
#include "ppu/internals.h"
+#include "ppusim/mem.h"
hh_ppu_data_t *g_hh_ppusim_vram = NULL;
diff --git a/src/ppusim/pixel.c b/src/ppusim/pixel.c
index 6e915e6..0457d55 100644
--- a/src/ppusim/pixel.c
+++ b/src/ppusim/pixel.c
@@ -1,10 +1,10 @@
#include <SDL2/SDL.h>
#include <stdbool.h>
-#include "ppusim/work.h"
+#include "ppu/consts.h"
#include "ppu/internals.h"
#include "ppusim/mem.h"
-#include "ppu/consts.h"
+#include "ppusim/work.h"
/* transform xy if tile is flipped */
static uint16_t hh_ppusim_apply_transform(unsigned x, unsigned y, bool fliph, bool flipv) {
@@ -15,25 +15,25 @@ static uint16_t hh_ppusim_apply_transform(unsigned x, unsigned y, bool fliph, bo
/* @brief get current bg pixel cidx */
static uint8_t hh_ppusim_bg_pixel(unsigned x, unsigned y) {
- hh_ppu_data_t* aux = &g_hh_ppusim_vram[HH_PPU_VRAM_AUX_OFFSET];
- unsigned bg_shift_y = HH_RESIZE(aux[0], 7, 0);
- unsigned bg_shift_x = HH_RESIZE(aux[0], 15, 8) | HH_RESIZE(aux[1], 0, 0) << 8;
- unsigned abs_x = bg_shift_x + x;
- unsigned abs_y = bg_shift_y + y;
- unsigned grid_x = abs_x / HH_PPU_SPRITE_WIDTH;
- unsigned grid_y = abs_y / HH_PPU_SPRITE_HEIGHT;
- unsigned loc_x = abs_x - grid_x * HH_PPU_SPRITE_WIDTH;
- unsigned loc_y = abs_y - grid_y * HH_PPU_SPRITE_HEIGHT;
- unsigned bam_offset = grid_y * HH_PPU_BG_CANVAS_TILES_H + grid_x;
- hh_ppu_data_t bam = g_hh_ppusim_vram[HH_PPU_VRAM_BAM_OFFSET + bam_offset];
- uint8_t cidx = 0;
+ hh_ppu_data_t *aux = &g_hh_ppusim_vram[HH_PPU_VRAM_AUX_OFFSET];
+ unsigned bg_shift_y = HH_RESIZE(aux[0], 7, 0);
+ unsigned bg_shift_x = HH_RESIZE(aux[0], 15, 8) | HH_RESIZE(aux[1], 0, 0) << 8;
+ unsigned abs_x = bg_shift_x + x;
+ unsigned abs_y = bg_shift_y + y;
+ unsigned grid_x = abs_x / HH_PPU_SPRITE_WIDTH;
+ unsigned grid_y = abs_y / HH_PPU_SPRITE_HEIGHT;
+ unsigned loc_x = abs_x - grid_x * HH_PPU_SPRITE_WIDTH;
+ unsigned loc_y = abs_y - grid_y * HH_PPU_SPRITE_HEIGHT;
+ unsigned bam_offset = grid_y * HH_PPU_BG_CANVAS_TILES_H + grid_x;
+ hh_ppu_data_t bam = g_hh_ppusim_vram[HH_PPU_VRAM_BAM_OFFSET + bam_offset];
+ uint8_t cidx = 0;
uint16_t tile_pixel_idx = hh_ppusim_apply_transform(loc_x, loc_y, HH_RESIZE(bam, 14, 14), HH_RESIZE(bam, 13, 13));
- uint16_t tile_idx = HH_RESIZE(bam, 9, 0);
- hh_ppu_addr_t ttm_addr = tile_idx * HH_PPU_VRAM_TMM_SPRITE_SIZE + tile_pixel_idx / 5;
- uint8_t word_bit_addr = (tile_pixel_idx % 5) * 3;
- hh_ppu_data_t tmm = g_hh_ppusim_vram[HH_PPU_VRAM_TMM_OFFSET + ttm_addr];
+ uint16_t tile_idx = HH_RESIZE(bam, 9, 0);
+ hh_ppu_addr_t ttm_addr = tile_idx * HH_PPU_VRAM_TMM_SPRITE_SIZE + tile_pixel_idx / 5;
+ uint8_t word_bit_addr = (tile_pixel_idx % 5) * 3;
+ hh_ppu_data_t tmm = g_hh_ppusim_vram[HH_PPU_VRAM_TMM_OFFSET + ttm_addr];
cidx |= HH_RESIZE(bam, 12, 10) << 3;
- cidx |= HH_RESIZE(tmm, word_bit_addr+2, word_bit_addr) << 0;
+ cidx |= HH_RESIZE(tmm, word_bit_addr + 2, word_bit_addr) << 0;
return cidx;
}
@@ -44,42 +44,37 @@ static uint8_t hh_ppusim_fg_pixel(unsigned x, unsigned y) {
uint8_t cidx = 0;
for (unsigned i = 0; i < HH_PPU_FG_SPRITE_COUNT; i++) {
unsigned fam_offset = i * HH_PPU_VRAM_FAM_ENTRY_SIZE;
- hh_ppu_data_t* fam = &g_hh_ppusim_vram[HH_PPU_VRAM_FAM_OFFSET + fam_offset];
- unsigned sprite_y = HH_RESIZE(fam[0], 15, 13) | HH_RESIZE(fam[1], 4, 0) << 3;
- unsigned sprite_x = HH_RESIZE(fam[1], 13, 5);
+ hh_ppu_data_t *fam = &g_hh_ppusim_vram[HH_PPU_VRAM_FAM_OFFSET + fam_offset];
+ unsigned sprite_y = HH_RESIZE(fam[0], 15, 13) | HH_RESIZE(fam[1], 4, 0) << 3;
+ unsigned sprite_x = HH_RESIZE(fam[1], 13, 5);
if (x < sprite_x) continue;
if (x >= sprite_x + HH_PPU_SPRITE_WIDTH) continue;
if (y < sprite_y) continue;
if (y >= sprite_y + HH_PPU_SPRITE_HEIGHT) continue;
- unsigned loc_x = x - sprite_x;
- unsigned loc_y = y - sprite_y;
+ unsigned loc_x = x - sprite_x;
+ unsigned loc_y = y - sprite_y;
uint16_t tile_pixel_idx = hh_ppusim_apply_transform(loc_x, loc_y, HH_RESIZE(fam[1], 15, 15), HH_RESIZE(fam[1], 14, 14));
- uint16_t tile_idx = HH_RESIZE(fam[0], 9, 0);
- hh_ppu_addr_t ttm_addr = tile_idx * HH_PPU_VRAM_TMM_SPRITE_SIZE + tile_pixel_idx / 5;
- uint8_t word_bit_addr = (tile_pixel_idx % 5) * 3;
- hh_ppu_data_t tmm = g_hh_ppusim_vram[HH_PPU_VRAM_TMM_OFFSET + ttm_addr];
- unsigned cidx_col = HH_RESIZE(tmm, word_bit_addr+2, word_bit_addr);
+ uint16_t tile_idx = HH_RESIZE(fam[0], 9, 0);
+ hh_ppu_addr_t ttm_addr = tile_idx * HH_PPU_VRAM_TMM_SPRITE_SIZE + tile_pixel_idx / 5;
+ uint8_t word_bit_addr = (tile_pixel_idx % 5) * 3;
+ hh_ppu_data_t tmm = g_hh_ppusim_vram[HH_PPU_VRAM_TMM_OFFSET + ttm_addr];
+ unsigned cidx_col = HH_RESIZE(tmm, word_bit_addr + 2, word_bit_addr);
if (cidx_col == 0) continue;
unsigned cidx_pal = HH_RESIZE(fam[0], 12, 10);
- cidx = (cidx_col << 0) | (cidx_pal << 3);
+ cidx = (cidx_col << 0) | (cidx_pal << 3);
break;
}
return cidx;
}
-void hh_ppusim_pixel(uint8_t* s, unsigned x, unsigned y) {
- uint8_t bg_cidx = hh_ppusim_bg_pixel(x, y);
- uint8_t fg_cidx = hh_ppusim_fg_pixel(x, y);
- uint8_t cidx = (fg_cidx & HH_MASK(3)) == 0 ? bg_cidx : fg_cidx;
- hh_ppu_data_t pal_rgb = g_hh_ppusim_vram[HH_PPU_VRAM_PAL_OFFSET + cidx];
- hh_ppu_rgb_color_t rgb = {
- HH_RESIZE(pal_rgb, 11, 8),
- HH_RESIZE(pal_rgb, 7, 4),
- HH_RESIZE(pal_rgb, 3, 0)
- };
+void hh_ppusim_pixel(uint8_t *s, unsigned x, unsigned y) {
+ uint8_t bg_cidx = hh_ppusim_bg_pixel(x, y);
+ uint8_t fg_cidx = hh_ppusim_fg_pixel(x, y);
+ uint8_t cidx = (fg_cidx & HH_MASK(3)) == 0 ? bg_cidx : fg_cidx;
+ hh_ppu_data_t pal_rgb = g_hh_ppusim_vram[HH_PPU_VRAM_PAL_OFFSET + cidx];
+ hh_ppu_rgb_color_t rgb = {HH_RESIZE(pal_rgb, 11, 8), HH_RESIZE(pal_rgb, 7, 4), HH_RESIZE(pal_rgb, 3, 0)};
s[0] = rgb[0] << 4;
s[1] = rgb[1] << 4;
s[2] = rgb[2] << 4;
}
-
diff --git a/src/ppusim/sim.c b/src/ppusim/sim.c
index 2816b31..449b78d 100644
--- a/src/ppusim/sim.c
+++ b/src/ppusim/sim.c
@@ -1,6 +1,6 @@
-#include <stdlib.h>
-#include <stdbool.h>
#include <SDL2/SDL.h>
+#include <stdbool.h>
+#include <stdlib.h>
#include "main.h"
#include "ppu/ppu.h"
@@ -8,16 +8,17 @@
#include "ppusim/sim.h"
#include "ppusim/work.h"
-SDL_Window *g_hh_window = NULL;
+SDL_Window *g_hh_window = NULL;
SDL_Renderer *g_hh_renderer = NULL;
void hh_ppu_init() {
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
- g_hh_window = SDL_CreateWindow("ppusim", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, HH_PPU_SCREEN_WIDTH * HH_PPUSIM_UPSCALE_FACTOR, HH_PPU_SCREEN_HEIGHT * HH_PPUSIM_UPSCALE_FACTOR, SDL_WINDOW_SHOWN);
+ g_hh_window = SDL_CreateWindow("ppusim", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, HH_PPU_SCREEN_WIDTH * HH_PPUSIM_UPSCALE_FACTOR,
+ HH_PPU_SCREEN_HEIGHT * HH_PPUSIM_UPSCALE_FACTOR, SDL_WINDOW_SHOWN);
g_hh_renderer = SDL_CreateRenderer(g_hh_window, -1, SDL_RENDERER_ACCELERATED);
g_hh_ppusim_core_count = SDL_GetCPUCount();
- g_hh_ppusim_threads = malloc(sizeof(pthread_t) * g_hh_ppusim_core_count);
+ g_hh_ppusim_threads = malloc(sizeof(pthread_t) * g_hh_ppusim_core_count);
g_hh_ppusim_vram = malloc(sizeof(hh_ppu_data_t) * 0xffff);
memset(g_hh_ppusim_vram, 0x0000, 0xffff);
@@ -36,8 +37,9 @@ void hh_loop() {
SDL_Event e;
while (g_hh_run) {
uint32_t start = SDL_GetTicks();
- while (SDL_PollEvent(&e)) if (e.type == SDL_QUIT) exit(0);
-
+ while (SDL_PollEvent(&e))
+ if (e.type == SDL_QUIT) exit(0);
+
hh_ppu_vblank_interrupt();
SDL_RenderClear(g_hh_renderer);
diff --git a/src/ppusim/work.c b/src/ppusim/work.c
index 3b9cee6..96d15aa 100644
--- a/src/ppusim/work.c
+++ b/src/ppusim/work.c
@@ -2,12 +2,12 @@
#include <pthread.h>
#include <stdio.h>
-#include "ppusim/work.h"
-#include "ppusim/sim.h"
#include "ppu/consts.h"
#include "ppusim/pixel.h"
+#include "ppusim/sim.h"
+#include "ppusim/work.h"
-pthread_t* g_hh_ppusim_threads;
+pthread_t *g_hh_ppusim_threads;
unsigned g_hh_ppusim_core_count;
hh_s_ppusim_screen g_hh_ppusim_screen;
@@ -15,29 +15,26 @@ hh_s_ppusim_screen g_hh_ppusim_screen;
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
-void* hh_ppusim_draw_thread(void* arg) {
- unsigned core = (unsigned long) arg;
+void *hh_ppusim_draw_thread(void *arg) {
+ unsigned core = (unsigned long)arg;
for (unsigned y = core; y < HH_PPU_SCREEN_HEIGHT; y += g_hh_ppusim_core_count)
- for (unsigned x = 0; x < HH_PPU_SCREEN_WIDTH; x++)
- hh_ppusim_pixel(g_hh_ppusim_screen[y][x], x, y);
+ for (unsigned x = 0; x < HH_PPU_SCREEN_WIDTH; x++) hh_ppusim_pixel(g_hh_ppusim_screen[y][x], x, y);
return NULL;
}
-void hh_ppusim_draw_frame(SDL_Renderer* renderer) {
- for (unsigned core = 0; core < g_hh_ppusim_core_count; core++)
- pthread_create(&g_hh_ppusim_threads[core], NULL, hh_ppusim_draw_thread, (void*)(unsigned long)core);
- for (unsigned core = 0; core < g_hh_ppusim_core_count; core++)
- pthread_join(g_hh_ppusim_threads[core], NULL);
-
+void hh_ppusim_draw_frame(SDL_Renderer *renderer) {
+ for (unsigned core = 0; core < g_hh_ppusim_core_count; core++) pthread_create(&g_hh_ppusim_threads[core], NULL, hh_ppusim_draw_thread, (void *)(unsigned long)core);
+ for (unsigned core = 0; core < g_hh_ppusim_core_count; core++) pthread_join(g_hh_ppusim_threads[core], NULL);
+
for (unsigned x = 0; x < HH_PPU_SCREEN_WIDTH; x++) {
for (unsigned y = 0; y < HH_PPU_SCREEN_HEIGHT; y++) {
SDL_SetRenderDrawColor(renderer, g_hh_ppusim_screen[y][x][0], g_hh_ppusim_screen[y][x][1], g_hh_ppusim_screen[y][x][2], 255);
- SDL_RenderFillRect(renderer, &(SDL_Rect) {
- .x = x * HH_PPUSIM_UPSCALE_FACTOR,
- .y = y * HH_PPUSIM_UPSCALE_FACTOR,
- .w = HH_PPUSIM_UPSCALE_FACTOR,
- .h = HH_PPUSIM_UPSCALE_FACTOR,
- });
+ SDL_RenderFillRect(renderer, &(SDL_Rect){
+ .x = x * HH_PPUSIM_UPSCALE_FACTOR,
+ .y = y * HH_PPUSIM_UPSCALE_FACTOR,
+ .w = HH_PPUSIM_UPSCALE_FACTOR,
+ .h = HH_PPUSIM_UPSCALE_FACTOR,
+ });
}
}
}
diff --git a/src/stm32.mk b/src/stm32.mk
index 6926dea..3b5ccb9 100644
--- a/src/stm32.mk
+++ b/src/stm32.mk
@@ -43,22 +43,25 @@ STM_SRCS += lib/FreeRTOS-Kernel/croutine.c \
lib/FreeRTOS-Kernel/timers.c \
lib/FreeRTOS-Kernel/portable/GCC/ARM_CM0/port.c \
lib/FreeRTOS-Kernel/portable/MemMang/heap_4.c
-STM_SRCS += lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_rcc.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_rcc_ex.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_i2c.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_i2c_ex.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_gpio.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_dma.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_cortex.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_pwr.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_pwr_ex.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_flash.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_flash_ex.c \
+STM_SRCS += lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_spi.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_spi_ex.c \
lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_tim.c \
lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_tim_ex.c \
lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_uart.c \
- lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_uart_ex.c
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_uart_ex.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_cortex.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_dma.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_flash.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_flash_ex.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_gpio.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_pwr.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_pwr_ex.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_rcc.c \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_rcc_ex.c
STM_SRCS += stm32/idle_task_static_memory.c \
- stm32/main.c
+ stm32/main.c \
+ stm32/setup.c \
+ ppu/stm.c \
+ stm32/input.c
diff --git a/src/stm32/TODO/maths.c b/src/stm32/TODO/maths.c
deleted file mode 100644
index 2f4444a..0000000
--- a/src/stm32/TODO/maths.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "maths.h"
-
-float clamp( float* x, float *min, float *max ){
- if (*x < *min)
- return *min;
- else if (*x > *max)
- return *max;
- else
- return *x;
-}
diff --git a/src/stm32/input.c b/src/stm32/input.c
new file mode 100644
index 0000000..e2d07cb
--- /dev/null
+++ b/src/stm32/input.c
@@ -0,0 +1,13 @@
+#include <stm32f0xx_hal_gpio.h>
+
+#include "input.h"
+
+hh_s_gamepad g_hh_controller_p1 = { 0 };
+hh_s_gamepad g_hh_controller_p2 = { 0 };
+
+void hh_input_read() {
+ g_hh_controller_p1.dpad_left = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4);
+ g_hh_controller_p1.dpad_right = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_5);
+ g_hh_controller_p1.dpad_down = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6);
+ g_hh_controller_p1.dpad_up = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8);
+}
diff --git a/src/stm32/setup.c b/src/stm32/setup.c
new file mode 100644
index 0000000..2c3552b
--- /dev/null
+++ b/src/stm32/setup.c
@@ -0,0 +1,197 @@
+#include <stm32f0xx_hal.h>
+#include <stm32f0xx_hal_spi.h>
+#include <stm32f0xx_hal_uart.h>
+#include <stm32f0xx_hal_gpio.h>
+#include <FreeRTOS.h>
+#include <task.h>
+
+#include "main.h"
+#include "setup.h"
+#include "ppu/ppu.h"
+
+UART_HandleTypeDef huart2 = {
+ .Instance = USART2,
+ .Init.BaudRate = 115200,
+ .Init.WordLength = UART_WORDLENGTH_8B,
+ .Init.StopBits = UART_STOPBITS_1,
+ .Init.Parity = UART_PARITY_NONE,
+ .Init.Mode = UART_MODE_TX_RX,
+ .Init.HwFlowCtl = UART_HWCONTROL_NONE,
+ .Init.OverSampling = UART_OVERSAMPLING_16,
+ .Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE,
+ .AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT,
+};
+
+GPIO_InitTypeDef spi_gpio = {
+ .Pin = HH_IO_SPI_PINS,
+ .Mode = GPIO_MODE_AF_PP,
+ .Pull = GPIO_NOPULL,
+ .Speed = GPIO_SPEED_FREQ_HIGH,
+ .Alternate = GPIO_AF0_SPI1,
+};
+
+SPI_HandleTypeDef hspi1 = {
+ .Instance = SPI1,
+ .Init.Mode = SPI_MODE_MASTER,
+ .Init.Direction = SPI_DIRECTION_1LINE,
+ .Init.DataSize = SPI_DATASIZE_8BIT,
+ .Init.CLKPolarity = SPI_POLARITY_LOW,
+ .Init.CLKPhase = SPI_PHASE_1EDGE,
+ .Init.NSS = SPI_NSS_SOFT,
+ .Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16,
+ .Init.FirstBit = SPI_FIRSTBIT_MSB,
+ .Init.TIMode = SPI_TIMODE_DISABLE,
+ .Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE,
+ .Init.CRCPolynomial = 7,
+ .Init.CRCLength = SPI_CRC_LENGTH_DATASIZE,
+ .Init.NSSPMode = SPI_NSS_PULSE_DISABLE,
+};
+
+TIM_HandleTypeDef htim3 = {
+ .Instance = TIM3,
+ .Init.Prescaler = 7999,
+ .Init.CounterMode = TIM_COUNTERMODE_UP,
+ .Init.Period = 65535,
+ .Init.ClockDivision = TIM_CLOCKDIVISION_DIV1,
+ .Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE,
+};
+
+static void hh_io_spi_setup();
+static void hh_io_tim_setup();
+static void hh_io_usart2_setup();
+static void hh_io_gpio_setup();
+static void hh_io_clock_setup();
+static void hh_io_setup_error_handler();
+
+void hh_setup() {
+ HAL_Init();
+
+ hh_io_clock_setup();
+ hh_io_usart2_setup();
+ hh_io_gpio_setup();
+ hh_io_spi_setup();
+ hh_io_tim_setup();
+
+ hh_ppu_init();
+}
+
+void hh_exit() {
+ hh_ppu_deinit();
+
+ HAL_DeInit();
+}
+
+void hh_io_clock_setup() {
+ if (HAL_OK != HAL_RCC_OscConfig(&(RCC_OscInitTypeDef){
+ .OscillatorType = RCC_OSCILLATORTYPE_HSI,
+ .HSIState = RCC_HSI_ON,
+ .HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT,
+ .PLL.PLLState = RCC_PLL_ON,
+ })) return hh_io_setup_error_handler();
+
+ // cpu, ahb & apb clocks
+ if (HAL_OK != HAL_RCC_ClockConfig(&(RCC_ClkInitTypeDef){
+ .ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1,
+ .SYSCLKSource = RCC_SYSCLKSOURCE_HSI,
+ .AHBCLKDivider = RCC_SYSCLK_DIV1,
+ .APB1CLKDivider = RCC_HCLK_DIV1,
+ }, FLASH_LATENCY_1)) return hh_io_setup_error_handler();
+
+ // usart2 clock (usb serial)
+ if (HAL_RCCEx_PeriphCLKConfig(&(RCC_PeriphCLKInitTypeDef){
+ .PeriphClockSelection = RCC_PERIPHCLK_USART2,
+ .Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1,
+ .I2c1ClockSelection = RCC_I2C1CLKSOURCE_HSI,
+ }) != HAL_OK) return hh_io_setup_error_handler();
+}
+
+void hh_io_spi_setup() {
+ if (HAL_SPI_Init(&hspi1) != HAL_OK)
+ return hh_io_setup_error_handler();
+}
+
+void hh_io_usart2_setup() {
+ if (HAL_UART_Init(&huart2) != HAL_OK)
+ return hh_io_setup_error_handler();
+}
+
+void hh_io_tim_setup() {
+ if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
+ return hh_io_setup_error_handler();
+
+ if (HAL_TIM_ConfigClockSource(&htim3, &(TIM_ClockConfigTypeDef) {
+ .ClockSource = TIM_CLOCKSOURCE_INTERNAL
+ }) != HAL_OK) return hh_io_setup_error_handler();
+
+ if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &(TIM_MasterConfigTypeDef) {
+ .MasterOutputTrigger = TIM_TRGO_RESET,
+ .MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE,
+ }) != HAL_OK) return hh_io_setup_error_handler();
+}
+
+void hh_io_gpio_setup() {
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+
+ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_SET);
+ HAL_GPIO_Init(GPIOA, &(GPIO_InitTypeDef) {
+ .Pin = GPIO_PIN_9,
+ .Mode = GPIO_MODE_OUTPUT_PP,
+ .Pull = GPIO_NOPULL,
+ .Speed = GPIO_SPEED_FREQ_LOW,
+ });
+ HAL_GPIO_Init(GPIOA, &(GPIO_InitTypeDef) {
+ .Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_8,
+ .Mode = GPIO_MODE_INPUT,
+ .Pull = GPIO_PULLDOWN,
+ });
+}
+
+void HAL_MspInit() {
+ __HAL_RCC_SYSCFG_CLK_ENABLE();
+ __HAL_RCC_PWR_CLK_ENABLE();
+}
+
+void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) {
+ if(hspi->Instance != SPI1) return;
+
+ __HAL_RCC_SPI1_CLK_ENABLE();
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+
+ HAL_GPIO_Init(HH_IO_SPI_PORT, &spi_gpio);
+}
+
+void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) {
+ if(hspi->Instance != SPI1) return;
+
+ __HAL_RCC_SPI1_CLK_DISABLE();
+
+ HAL_GPIO_DeInit(HH_IO_SPI_PORT, HH_IO_SPI_PINS);
+}
+
+void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) {
+ if(htim_base->Instance != TIM3) return;
+
+ __HAL_RCC_TIM3_CLK_ENABLE();
+}
+
+void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) {
+ if(htim_base->Instance != TIM3) return;
+
+ __HAL_RCC_TIM3_CLK_DISABLE();
+}
+
+void SysTick_Handler() {
+ HAL_IncTick();
+ if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)
+ xPortSysTickHandler();
+}
+
+void HardFault_Handler() {
+ for(;;);
+}
+
+void hh_io_setup_error_handler() {
+ __disable_irq();
+ while (1);
+}
diff --git a/src/stm32/setup.h b/src/stm32/setup.h
new file mode 100644
index 0000000..66d5ff3
--- /dev/null
+++ b/src/stm32/setup.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <stm32f0xx_hal_spi.h>
+#include <stm32f0xx_hal_uart.h>
+#include <stm32f0xx_hal_tim.h>
+#include <stm32f0xx_hal_gpio.h>
+
+#define HH_IO_SPI_PINS (GPIO_PIN_5 | GPIO_PIN_7)
+#define HH_IO_SPI_PORT GPIOA
+
+extern UART_HandleTypeDef huart2; // NOLINT
+extern GPIO_InitTypeDef spi_gpio; // NOLINT
+extern SPI_HandleTypeDef hspi1; // NOLINT
+extern TIM_HandleTypeDef htim3; // NOLINT
+
+// required HAL setup functions
+void HAL_MspInit(); // NOLINT
+void HAL_UART_MspInit(UART_HandleTypeDef *huart); // NOLINT
+void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi); // NOLINT
+void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi); // NOLINT
+void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base); // NOLINT
+void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base); // NOLINT
+void HardFault_Handler(); // NOLINT
+void SysTick_Handler(); // NOLINT
diff --git a/src/stm32/stm32f0xx_hal_conf.h b/src/stm32/stm32f0xx_hal_conf.h
index fc27221..84a3b74 100644
--- a/src/stm32/stm32f0xx_hal_conf.h
+++ b/src/stm32/stm32f0xx_hal_conf.h
@@ -19,16 +19,18 @@
#define DATA_CACHE_ENABLE 0U
#define USE_SPI_CRC 0U
-#define HAL_RCC_MODULE_ENABLED
#define HAL_MODULE_ENABLED
-#define HAL_I2C_MODULE_ENABLED
-#define HAL_GPIO_MODULE_ENABLED
-#define HAL_DMA_MODULE_ENABLED
-#define HAL_CORTEX_MODULE_ENABLED
-#define HAL_PWR_MODULE_ENABLED
-#define HAL_FLASH_MODULE_ENABLED
+#define HAL_SPI_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_EXTI_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+// #define HAL_I2C_MODULE_ENABLED
#ifdef HAL_RCC_MODULE_ENABLED
#include <stm32f0xx_hal_rcc.h>
diff --git a/style.md b/style.md
index 3fe912b..db3e1d7 100644
--- a/style.md
+++ b/style.md
@@ -31,6 +31,7 @@ before formatting as a failsafe.
- library hooks that need specific symbol names are exempt from the naming
conventions (e.g. `main` or `HAL_UART_MspInit`)
- names are always in English
+- filenames should not be prefixed by anything.
## others
diff --git a/test/bin/tiles.bs b/test/bin/tiles.bs
new file mode 100644
index 0000000..4452c2a
--- /dev/null
+++ b/test/bin/tiles.bs
@@ -0,0 +1,544 @@
+0000: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0010: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0020: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0030: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0040: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0050: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0060: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0070: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0080: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0090: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+00a0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+00b0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+00c0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+00d0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+00e0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+00f0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+0100: 29 29 29 29 29 28 29 29 29 29 29 28 29 29 29 29
+0110: 29 28 28 28 28 26 28 28 28 28 28 26 28 28 28 28
+0120: 29 28 27 27 27 26 28 28 28 28 28 26 28 28 28 28
+0130: 29 27 27 27 27 25 25 25 25 25 25 25 25 25 25 25
+0140: 29 27 27 27 27 25 25 26 26 26 26 26 26 25 26 26
+0150: 28 27 27 27 27 25 26 26 26 26 26 26 26 25 26 26
+0160: 28 27 27 27 27 25 26 26 26 26 26 26 26 25 26 26
+0170: 26 26 26 26 26 25 25 25 25 25 25 25 25 25 25 25
+0180: 29 29 27 27 27 27 27 25 25 25 26 26 26 26 25 25
+0190: 28 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+01a0: 28 27 27 27 27 27 27 25 25 26 26 26 26 26 26 25
+01b0: 28 26 26 26 26 26 25 25 25 25 25 25 25 25 25 25
+01c0: 01 28 27 27 27 27 27 27 25 25 26 26 26 26 26 26
+01d0: 01 28 27 27 27 27 27 27 25 26 26 26 26 26 26 26
+01e0: 01 28 27 27 27 27 27 27 25 26 26 26 26 26 26 26
+01f0: 29 29 29 28 28 28 25 25 25 25 25 25 25 25 25 25
+0200: 29 29 29 28 29 29 29 29 29 29 29 28 29 29 29 29
+0210: 28 28 28 26 28 28 28 28 28 28 28 26 28 28 28 28
+0220: 28 28 28 26 28 28 28 28 28 28 28 26 28 28 28 28
+0230: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0240: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+0250: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+0260: 26 26 26 26 25 25 26 26 26 26 26 26 26 25 26 26
+0270: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0280: 25 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+0290: 26 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+02a0: 26 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+02b0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+02c0: 26 25 26 26 26 26 26 26 26 25 26 26 26 26 26 26
+02d0: 26 25 26 26 26 26 26 26 26 25 26 26 26 26 26 26
+02e0: 25 25 26 26 26 26 26 26 26 25 26 26 26 26 26 26
+02f0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0300: 29 29 29 28 29 29 29 29 29 29 28 29 29 29 29 29
+0310: 28 28 28 26 28 28 28 28 28 28 26 28 28 28 28 29
+0320: 28 28 28 26 28 28 28 28 28 28 26 27 27 28 28 29
+0330: 25 25 25 25 25 25 25 25 25 25 25 27 27 27 27 29
+0340: 26 26 26 26 26 25 26 26 26 26 25 27 27 27 27 29
+0350: 26 26 26 26 26 25 26 26 26 26 25 27 27 27 27 28
+0360: 26 26 26 26 26 25 26 26 26 26 25 27 27 27 27 28
+0370: 25 25 25 25 25 25 25 25 25 25 25 26 26 26 26 28
+0380: 26 26 26 26 26 26 26 25 27 27 27 27 27 28 28 01
+0390: 26 26 26 26 26 26 26 25 27 27 27 27 27 27 28 01
+03a0: 26 26 26 26 26 26 26 25 27 27 27 27 27 27 28 01
+03b0: 25 25 25 25 25 25 25 25 25 25 25 28 28 29 29 29
+03c0: 26 25 26 26 26 26 26 26 26 25 27 27 27 27 27 29
+03d0: 26 25 26 26 26 26 26 26 26 25 27 27 27 27 27 29
+03e0: 26 25 26 26 26 26 26 26 26 25 27 27 27 27 27 28
+03f0: 25 25 25 25 25 25 25 25 25 25 25 25 26 26 26 28
+0400: 29 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+0410: 28 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+0420: 28 27 27 27 27 27 27 25 25 26 26 26 26 26 25 25
+0430: 28 26 26 26 26 26 25 25 25 25 25 25 25 25 25 25
+0440: 01 28 27 27 27 26 25 26 26 26 26 26 26 25 26 26
+0450: 01 28 27 27 27 25 26 26 26 26 26 26 26 25 26 26
+0460: 01 27 27 27 27 25 26 26 26 26 26 25 25 25 25 26
+0470: 29 29 28 28 25 25 25 25 25 25 25 25 25 25 25 25
+0480: 29 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+0490: 28 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+04a0: 28 27 27 27 27 27 27 25 25 26 26 26 26 26 26 25
+04b0: 28 26 26 26 26 26 25 25 25 25 25 25 25 25 25 25
+04c0: 01 28 28 27 27 27 27 26 25 26 26 26 26 26 26 26
+04d0: 01 28 27 27 27 27 27 27 25 25 26 26 26 26 26 26
+04e0: 01 28 27 27 27 27 27 27 25 25 26 26 26 26 26 26
+04f0: 01 28 26 26 26 26 26 25 25 25 25 25 25 25 25 25
+0500: 26 26 25 25 25 26 26 26 26 26 26 25 25 26 26 26
+0510: 26 26 26 25 26 26 26 26 26 26 26 25 26 26 26 26
+0520: 26 26 26 25 26 26 26 26 26 26 25 25 25 26 26 26
+0530: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0540: 26 26 26 26 25 25 26 26 26 26 26 26 26 25 26 26
+0550: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+0560: 26 26 26 26 26 25 26 26 26 26 26 26 25 25 25 26
+0570: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0580: 25 26 26 26 26 26 26 25 26 26 26 26 26 26 25 25
+0590: 26 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+05a0: 26 26 26 26 26 26 25 25 25 25 26 26 26 26 26 25
+05b0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+05c0: 25 25 25 26 26 26 26 26 26 25 26 26 26 26 26 26
+05d0: 26 25 26 26 26 26 26 26 26 25 26 26 26 26 26 26
+05e0: 26 25 26 26 26 26 26 26 25 25 25 26 26 26 26 26
+05f0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0600: 26 26 26 25 26 26 26 26 26 26 26 25 27 27 28 01
+0610: 26 26 26 25 26 26 26 26 26 26 26 25 27 27 28 01
+0620: 26 26 25 25 26 26 26 26 26 26 26 25 27 27 27 01
+0630: 25 25 25 25 25 25 25 25 25 25 25 25 25 29 29 29
+0640: 26 26 26 26 26 25 26 26 26 25 27 27 27 27 27 29
+0650: 26 26 26 26 26 25 26 26 26 25 27 27 27 27 27 28
+0660: 26 26 26 26 26 25 26 26 26 25 27 27 27 27 27 28
+0670: 25 25 25 25 25 25 25 25 25 25 25 26 26 26 26 28
+0680: 26 26 26 26 26 26 26 25 27 27 27 27 27 28 28 01
+0690: 26 26 26 26 26 26 26 25 27 27 27 27 27 27 28 01
+06a0: 26 26 26 26 26 26 26 25 27 27 27 27 27 27 28 01
+06b0: 25 25 25 25 25 25 25 25 25 25 25 26 26 29 29 29
+06c0: 26 25 26 26 26 26 26 26 26 25 27 27 27 27 27 29
+06d0: 26 25 26 26 26 26 26 26 26 25 27 27 27 27 27 28
+06e0: 26 25 26 26 26 26 26 26 26 25 27 27 27 27 27 28
+06f0: 25 25 25 25 25 25 25 25 25 25 25 25 26 26 26 28
+0700: 29 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+0710: 28 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+0720: 28 27 27 27 27 27 27 25 25 26 26 26 26 26 25 25
+0730: 28 26 26 26 26 26 25 25 25 25 25 25 25 25 25 25
+0740: 01 28 27 27 27 26 25 26 26 26 26 26 26 25 26 26
+0750: 01 28 27 27 27 25 26 26 26 26 26 26 26 25 26 26
+0760: 01 27 27 27 27 25 26 26 26 26 26 25 25 25 25 26
+0770: 29 29 28 28 25 25 25 25 25 25 25 25 25 25 25 25
+0780: 29 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+0790: 28 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+07a0: 28 27 27 27 27 27 27 25 25 26 26 26 26 26 26 25
+07b0: 28 26 26 26 26 26 25 25 25 25 25 25 25 25 25 25
+07c0: 01 28 28 27 27 27 27 27 27 27 27 25 25 25 25 27
+07d0: 01 28 28 27 27 27 27 27 27 27 27 27 25 27 27 27
+07e0: 01 29 28 28 28 27 27 27 27 27 27 27 26 27 27 27
+07f0: 01 29 29 29 28 28 28 28 28 28 28 28 26 28 28 28
+0800: 26 26 25 25 25 26 26 26 26 26 26 25 25 26 26 26
+0810: 26 26 26 25 26 26 26 26 26 26 26 25 26 26 26 26
+0820: 26 26 26 25 26 26 26 26 26 26 25 25 25 26 26 26
+0830: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0840: 26 26 26 26 25 25 26 26 26 26 26 26 26 25 26 26
+0850: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+0860: 26 26 26 26 26 25 26 26 26 26 26 26 25 25 25 26
+0870: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0880: 25 26 26 26 26 26 26 25 26 26 26 26 26 26 25 25
+0890: 26 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+08a0: 26 26 26 26 26 26 25 25 25 25 26 26 26 26 26 25
+08b0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+08c0: 27 27 27 27 27 27 27 27 26 26 26 27 27 27 27 27
+08d0: 27 27 27 27 27 27 27 27 27 26 26 27 27 27 27 27
+08e0: 27 27 27 27 27 27 27 27 27 26 27 27 27 27 27 27
+08f0: 28 28 28 28 28 28 28 28 28 26 28 28 28 28 28 28
+0900: 26 26 26 25 26 26 26 26 26 26 26 25 27 27 28 01
+0910: 26 26 26 25 26 26 26 26 26 26 26 25 27 27 28 01
+0920: 26 26 25 25 26 26 26 26 26 26 26 25 27 27 27 01
+0930: 25 25 25 25 25 25 25 25 25 25 25 25 25 29 29 29
+0940: 26 26 26 26 26 25 26 26 26 25 27 27 27 27 27 29
+0950: 26 26 26 26 26 25 26 26 26 25 27 27 27 27 27 28
+0960: 26 26 26 26 26 25 26 26 26 25 27 27 27 27 27 28
+0970: 25 25 25 25 25 25 25 25 25 25 25 26 26 26 26 28
+0980: 26 26 26 26 26 26 26 25 27 27 27 27 27 28 28 01
+0990: 26 26 26 26 26 26 26 25 27 27 27 27 27 27 28 01
+09a0: 26 26 26 26 26 26 26 25 27 27 27 27 27 27 28 01
+09b0: 25 25 25 25 25 25 26 26 26 26 26 26 26 29 29 29
+09c0: 27 27 26 26 26 27 27 27 27 27 27 27 27 27 28 29
+09d0: 27 27 27 26 26 27 27 27 27 27 27 27 27 28 28 28
+09e0: 27 27 27 26 27 27 27 27 27 27 27 28 28 28 28 29
+09f0: 28 28 28 26 28 28 28 28 28 28 28 28 28 29 29 29
+0a00: 29 29 29 29 29 28 29 29 29 29 29 28 29 29 29 29
+0a10: 29 28 28 28 28 26 28 28 28 28 28 26 28 28 28 28
+0a20: 29 28 27 27 27 26 28 28 28 28 28 26 28 28 28 28
+0a30: 29 27 27 27 27 25 25 25 25 25 25 25 25 25 25 25
+0a40: 29 27 27 27 27 25 25 26 26 26 26 26 26 25 26 26
+0a50: 28 27 27 27 27 25 26 26 26 26 26 26 26 25 26 26
+0a60: 28 27 27 27 27 25 26 26 26 26 26 26 26 25 26 26
+0a70: 26 26 26 26 26 25 25 25 25 25 25 25 25 25 25 25
+0a80: 29 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+0a90: 28 27 27 27 27 27 27 25 26 26 26 26 26 26 26 25
+0aa0: 28 27 27 27 27 27 27 25 25 26 26 26 26 26 26 25
+0ab0: 28 26 26 26 26 26 25 25 25 25 25 25 25 25 25 25
+0ac0: 01 28 28 27 27 27 27 27 27 27 27 25 25 25 25 27
+0ad0: 01 28 28 27 27 27 27 27 27 27 27 27 25 27 27 27
+0ae0: 01 29 28 28 28 27 27 27 27 27 27 27 26 27 27 27
+0af0: 01 29 29 29 28 28 28 28 28 28 28 28 26 28 28 28
+0b00: 29 29 29 28 29 29 29 29 29 29 29 28 29 29 29 29
+0b10: 28 28 28 26 28 28 28 28 28 28 28 26 28 28 28 28
+0b20: 28 28 28 26 28 28 28 28 28 28 28 26 28 28 28 28
+0b30: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0b40: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+0b50: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+0b60: 26 26 26 26 25 25 26 26 26 26 26 26 26 25 26 26
+0b70: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0b80: 25 26 26 26 26 26 26 25 26 26 26 26 26 26 25 25
+0b90: 26 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+0ba0: 26 26 26 26 26 26 25 25 25 25 26 26 26 26 26 25
+0bb0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+0bc0: 27 27 27 27 27 27 27 27 26 26 26 27 27 27 27 27
+0bd0: 27 27 27 27 27 27 27 27 27 26 26 27 27 27 27 27
+0be0: 27 27 27 27 27 27 27 27 27 26 27 27 27 27 27 27
+0bf0: 28 28 28 28 28 28 28 28 28 26 28 28 28 28 28 28
+0c00: 29 29 29 28 29 29 29 29 29 29 28 29 29 29 29 29
+0c10: 28 28 28 26 28 28 28 28 28 28 26 28 28 28 28 29
+0c20: 28 28 28 26 28 28 28 28 28 28 26 27 27 28 28 29
+0c30: 25 25 25 25 25 25 25 25 25 25 25 27 27 27 27 29
+0c40: 26 26 26 26 26 25 26 26 26 26 25 27 27 27 27 29
+0c50: 26 26 26 26 26 25 26 26 26 26 25 27 27 27 27 28
+0c60: 26 26 26 26 26 25 26 26 26 26 25 27 27 27 27 28
+0c70: 25 25 25 25 25 25 25 25 25 25 25 26 26 26 26 28
+0c80: 26 26 26 26 26 26 26 25 27 27 27 27 27 28 28 01
+0c90: 26 26 26 26 26 26 26 25 27 27 27 27 27 27 28 01
+0ca0: 26 26 26 26 26 26 26 25 27 27 27 27 27 27 28 01
+0cb0: 25 25 25 25 25 25 26 26 26 26 26 26 26 29 29 29
+0cc0: 27 27 26 26 26 27 27 27 27 27 27 27 27 27 28 29
+0cd0: 27 27 27 26 26 27 27 27 27 27 27 27 27 28 28 28
+0ce0: 27 27 27 26 27 27 27 27 27 27 27 28 28 28 28 29
+0cf0: 28 28 28 26 28 28 28 28 28 28 28 28 28 29 29 29
+0d00: 29 29 29 29 29 28 29 29 29 29 28 29 29 29 29 29
+0d10: 29 28 28 28 28 26 28 28 28 28 26 28 28 28 28 29
+0d20: 29 28 27 27 27 26 28 28 28 28 26 27 27 28 28 29
+0d30: 29 27 27 27 27 25 25 25 25 25 25 27 27 27 27 29
+0d40: 29 27 27 27 27 25 25 26 26 26 25 27 27 27 27 29
+0d50: 28 27 27 27 27 25 26 26 26 26 25 27 27 27 27 28
+0d60: 28 27 27 27 27 25 26 26 26 26 25 27 27 27 27 28
+0d70: 26 26 26 26 26 25 25 25 25 25 25 26 26 26 26 28
+0d80: 29 29 27 27 27 27 27 25 27 27 27 27 27 28 28 01
+0d90: 28 27 27 27 27 27 27 25 27 27 27 27 27 27 28 01
+0da0: 28 27 27 27 27 27 27 25 27 27 27 27 27 27 28 01
+0db0: 28 26 26 26 26 26 25 25 25 25 25 28 28 29 29 29
+0dc0: 01 28 27 27 27 27 27 27 26 25 27 27 27 27 27 29
+0dd0: 01 28 27 27 27 27 27 27 26 25 27 27 27 27 27 29
+0de0: 01 28 27 27 27 27 27 27 26 25 27 27 27 27 27 28
+0df0: 29 29 29 28 28 28 25 25 25 25 25 25 26 26 26 28
+0e00: 29 27 27 27 27 27 27 25 26 26 26 25 27 27 28 01
+0e10: 28 27 27 27 27 27 27 25 26 26 26 25 27 27 28 01
+0e20: 28 27 27 27 27 27 27 25 26 26 26 25 27 27 27 01
+0e30: 28 26 26 26 26 26 25 25 25 25 25 25 25 29 29 29
+0e40: 01 28 27 27 27 26 25 26 26 25 27 27 27 27 27 29
+0e50: 01 28 27 27 27 25 26 26 26 25 27 27 27 27 27 28
+0e60: 01 27 27 27 27 25 26 26 26 25 26 27 27 27 27 28
+0e70: 29 29 28 28 25 25 25 25 25 25 25 26 26 26 26 28
+0e80: 29 27 27 27 27 27 27 25 27 27 27 27 27 28 28 01
+0e90: 28 27 27 27 27 27 27 25 27 27 27 27 27 27 28 01
+0ea0: 28 27 27 27 27 27 27 25 27 27 27 27 27 27 28 01
+0eb0: 28 26 26 26 26 26 25 25 25 25 25 26 26 29 29 29
+0ec0: 01 28 28 27 27 27 26 26 26 26 26 27 27 27 27 29
+0ed0: 01 28 27 27 27 27 26 26 26 26 27 27 27 27 27 28
+0ee0: 01 28 27 27 27 26 26 26 26 26 27 27 27 27 27 28
+0ef0: 01 28 26 26 26 26 26 25 25 25 25 25 26 26 26 28
+0f00: 29 27 27 27 27 27 27 25 26 26 26 25 27 27 28 01
+0f10: 28 27 27 27 27 27 27 25 26 26 26 25 27 27 28 01
+0f20: 28 27 27 27 27 27 27 25 26 26 26 25 27 27 27 01
+0f30: 28 26 26 26 26 26 25 25 25 25 25 25 25 29 29 29
+0f40: 01 28 27 27 27 26 25 26 26 25 27 27 27 27 27 29
+0f50: 01 28 27 27 27 25 26 26 26 25 27 27 27 27 27 28
+0f60: 01 27 27 27 27 25 26 26 26 25 27 27 27 27 27 28
+0f70: 29 29 28 28 25 25 25 25 25 25 25 26 26 26 26 28
+0f80: 29 27 27 27 27 27 27 25 27 27 27 27 27 28 28 01
+0f90: 28 27 27 27 27 27 27 25 27 27 27 27 27 27 28 01
+0fa0: 28 27 27 27 27 27 27 25 27 27 27 27 27 27 28 01
+0fb0: 28 26 26 26 26 26 25 25 26 26 26 26 26 29 29 29
+0fc0: 01 28 28 27 27 27 27 27 27 27 27 27 27 27 28 29
+0fd0: 01 28 28 27 27 27 27 27 27 27 27 27 27 28 28 28
+0fe0: 01 29 28 28 28 27 27 27 27 27 27 28 28 28 28 29
+0ff0: 01 29 29 29 28 28 28 28 28 28 28 28 28 29 29 29
+1000: 26 26 25 25 25 26 26 26 26 26 26 25 25 26 26 26
+1010: 26 26 26 25 26 26 26 26 26 26 26 25 26 26 26 26
+1020: 26 26 26 25 26 26 26 26 26 26 25 25 25 26 26 26
+1030: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1040: 26 26 26 26 25 25 26 26 26 26 26 26 26 25 26 26
+1050: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+1060: 26 26 26 26 26 25 26 26 26 26 26 26 25 25 25 26
+1070: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1080: 25 26 26 26 26 26 26 25 26 26 26 26 26 26 25 25
+1090: 26 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+10a0: 26 26 26 26 26 26 25 25 25 25 26 26 26 26 26 25
+10b0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+10c0: 25 25 25 26 26 26 26 26 26 25 26 26 26 27 27 27
+10d0: 26 25 26 26 26 26 26 26 26 25 26 26 27 27 27 27
+10e0: 26 25 26 26 26 26 26 26 25 25 25 26 27 27 27 27
+10f0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1100: 26 26 25 25 25 26 26 26 26 26 26 25 25 26 26 26
+1110: 26 26 26 25 26 26 26 26 26 26 26 25 26 26 26 26
+1120: 26 26 26 25 26 26 26 26 26 26 25 25 25 26 26 26
+1130: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1140: 26 26 26 26 25 25 26 26 26 26 26 26 26 25 26 26
+1150: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+1160: 26 26 26 26 26 25 26 26 26 26 26 26 25 25 25 26
+1170: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1180: 25 26 26 26 26 26 26 25 26 26 26 26 26 26 25 25
+1190: 26 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+11a0: 26 26 26 26 26 26 25 25 25 25 26 26 26 26 26 25
+11b0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+11c0: 25 25 25 26 26 26 26 26 26 25 26 26 26 26 26 26
+11d0: 27 25 27 27 26 26 26 26 26 25 26 26 26 26 26 26
+11e0: 27 25 27 27 26 26 26 26 25 25 25 26 26 26 26 26
+11f0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1200: 26 26 25 25 25 26 26 26 26 26 26 25 25 28 28 28
+1210: 26 26 26 25 26 26 26 26 26 26 26 25 26 28 28 28
+1220: 26 26 26 25 26 26 26 26 26 26 25 25 25 26 28 28
+1230: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1240: 26 26 26 26 25 25 26 26 26 26 26 26 26 25 26 26
+1250: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+1260: 26 26 26 26 26 25 26 26 26 26 26 26 25 25 25 26
+1270: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1280: 25 26 26 26 26 26 26 25 26 26 26 26 26 26 25 25
+1290: 26 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+12a0: 26 26 26 26 26 26 25 25 25 25 26 26 26 26 26 25
+12b0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+12c0: 25 25 25 26 26 26 26 26 26 25 26 26 26 26 26 26
+12d0: 26 25 26 26 26 26 26 26 26 25 26 26 26 26 26 26
+12e0: 26 25 26 26 26 26 26 26 25 25 25 26 26 26 26 26
+12f0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1300: 28 28 25 25 25 26 26 26 26 26 26 25 25 26 26 26
+1310: 28 28 28 25 26 26 26 26 26 26 26 25 26 26 26 26
+1320: 28 28 26 25 26 26 26 26 26 26 25 25 25 26 26 26
+1330: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1340: 26 26 26 26 25 25 26 26 26 26 26 26 26 25 26 26
+1350: 26 26 26 26 26 25 26 26 26 26 26 26 26 25 26 26
+1360: 26 26 26 26 26 25 26 26 26 26 26 26 25 25 25 26
+1370: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1380: 25 26 26 26 26 26 26 25 26 26 26 26 26 26 25 25
+1390: 26 26 26 26 26 26 26 25 26 26 26 26 26 26 26 25
+13a0: 26 26 26 26 26 26 25 25 25 25 26 26 26 26 26 25
+13b0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+13c0: 25 25 25 26 26 26 26 26 26 25 26 26 26 26 26 26
+13d0: 26 25 26 26 26 26 26 26 26 25 26 26 26 26 26 26
+13e0: 26 25 26 26 26 26 26 26 25 25 25 26 26 26 26 26
+13f0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1400: 26 26 25 25 24 25 25 25 25 25 24 24 24 24 24 24
+1410: 26 26 26 24 25 25 25 25 25 25 24 24 24 24 24 24
+1420: 26 26 25 24 25 25 25 25 25 25 24 24 24 24 24 24
+1430: 25 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1440: 25 25 25 25 24 24 25 25 25 25 24 24 24 24 24 24
+1450: 25 25 25 25 25 24 25 25 25 25 24 24 24 24 24 24
+1460: 25 25 25 25 25 24 25 25 25 25 24 24 24 24 24 24
+1470: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1480: 24 25 25 25 25 25 25 24 24 24 24 24 24 24 24 24
+1490: 25 25 25 25 25 25 25 24 24 24 24 24 24 24 24 24
+14a0: 25 25 25 25 25 25 24 24 24 24 24 24 24 24 24 24
+14b0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+14c0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+14d0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+14e0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+14f0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1500: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1510: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1520: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1530: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1540: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1550: 24 24 24 24 24 24 24 24 25 25 25 25 25 24 25 25
+1560: 24 24 24 24 24 24 24 25 25 25 25 25 24 24 24 25
+1570: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1580: 24 24 24 24 24 24 24 24 25 25 25 25 25 25 24 24
+1590: 24 24 24 24 24 24 24 24 25 25 25 25 25 25 25 24
+15a0: 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25 24
+15b0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 25 25
+15c0: 24 24 24 24 24 25 25 25 25 24 25 25 25 26 26 26
+15d0: 24 24 24 24 25 25 25 25 25 24 25 25 26 26 26 26
+15e0: 24 24 24 24 25 25 25 25 24 24 24 26 26 26 26 26
+15f0: 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25 25
+1600: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1610: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1620: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1630: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1640: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1650: 25 25 25 25 25 24 25 25 25 25 24 24 24 24 24 24
+1660: 25 25 25 25 25 24 25 25 25 25 25 24 24 24 24 25
+1670: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1680: 24 25 25 25 25 25 25 24 25 25 25 25 25 25 24 24
+1690: 25 25 25 25 25 25 25 24 25 25 25 25 25 25 25 24
+16a0: 25 25 25 25 25 25 24 24 24 24 25 25 25 25 25 24
+16b0: 25 25 25 25 24 24 24 24 24 24 24 24 24 24 24 24
+16c0: 25 25 25 26 26 25 25 25 25 24 25 25 26 26 26 26
+16d0: 26 25 26 26 26 26 26 26 26 25 26 26 26 26 26 26
+16e0: 26 25 26 26 26 26 26 26 25 25 25 26 26 26 26 26
+16f0: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1700: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1710: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1720: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1730: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1740: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1750: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1760: 25 25 25 25 25 24 24 24 24 24 24 24 24 24 24 24
+1770: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1780: 24 25 25 25 25 25 25 24 25 25 24 24 24 24 24 24
+1790: 25 25 25 25 25 25 25 24 25 25 24 24 24 24 24 24
+17a0: 25 25 25 25 25 25 24 24 24 24 24 24 24 24 24 24
+17b0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+17c0: 25 24 24 25 25 25 25 25 25 24 24 24 24 24 24 24
+17d0: 26 25 25 25 25 25 25 25 25 24 24 24 24 24 24 24
+17e0: 26 25 26 25 25 25 25 25 24 24 24 24 24 24 24 24
+17f0: 25 25 25 25 24 24 24 24 24 24 24 24 24 24 24 24
+1800: 24 24 24 24 24 25 25 25 25 25 26 25 25 26 26 26
+1810: 24 24 24 24 25 25 25 25 25 25 26 25 26 26 26 26
+1820: 24 24 24 24 25 25 25 25 25 25 25 25 25 26 26 26
+1830: 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25 25
+1840: 24 24 24 24 24 24 25 25 25 25 26 26 26 25 26 26
+1850: 24 24 24 24 24 24 25 25 25 25 26 26 26 25 26 26
+1860: 24 24 24 24 24 24 25 25 25 25 26 26 25 25 25 26
+1870: 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25 25
+1880: 24 24 24 24 25 25 25 24 25 25 26 26 26 26 25 25
+1890: 24 24 24 25 25 25 25 24 25 25 25 26 26 26 26 25
+18a0: 24 24 24 25 25 25 24 24 24 24 25 25 26 26 26 25
+18b0: 24 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25
+18c0: 24 24 24 25 25 25 25 25 25 24 26 26 26 26 26 26
+18d0: 24 24 24 24 25 25 25 25 25 24 26 26 26 26 26 26
+18e0: 24 24 24 24 25 25 25 25 24 24 25 26 26 26 26 26
+18f0: 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25 25
+1900: 26 26 25 25 25 25 25 25 25 24 24 24 24 24 24 24
+1910: 26 26 26 25 26 25 25 25 25 24 24 24 24 24 24 24
+1920: 26 26 26 25 26 25 25 25 25 24 24 24 24 24 24 24
+1930: 25 25 25 25 25 24 24 24 24 24 24 24 24 24 24 24
+1940: 26 26 26 26 25 24 25 25 25 24 24 24 24 24 24 24
+1950: 26 26 26 26 26 24 25 25 25 24 24 24 24 24 24 24
+1960: 26 26 26 26 26 24 25 25 24 24 24 24 24 24 24 24
+1970: 25 25 25 25 24 24 24 24 24 24 24 24 24 24 24 24
+1980: 25 26 26 26 25 25 25 24 24 24 24 24 24 24 24 24
+1990: 26 26 26 26 25 25 25 24 24 24 24 24 24 24 24 24
+19a0: 26 26 26 26 26 25 24 24 24 24 24 24 24 24 24 24
+19b0: 25 25 25 25 25 24 24 24 24 24 24 24 24 24 24 24
+19c0: 25 25 25 26 26 25 25 25 25 24 24 24 24 24 24 24
+19d0: 26 25 26 26 26 25 25 25 25 24 24 24 24 24 24 24
+19e0: 26 25 26 26 26 25 25 25 24 24 24 24 24 24 24 24
+19f0: 25 25 25 25 25 24 24 24 24 24 24 24 24 24 24 24
+1a00: 24 24 24 24 24 25 25 25 25 25 26 25 25 26 26 26
+1a10: 24 24 24 24 25 25 25 25 25 25 25 25 26 26 26 26
+1a20: 24 24 24 24 25 25 25 25 25 25 24 24 25 26 26 26
+1a30: 24 24 24 24 24 24 24 24 24 24 24 24 24 25 25 25
+1a40: 24 24 24 24 24 24 25 25 25 25 25 25 25 24 26 26
+1a50: 24 24 24 24 24 24 24 25 25 25 25 25 25 24 25 25
+1a60: 24 24 24 24 24 24 24 25 25 25 25 25 24 24 24 25
+1a70: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1a80: 24 24 24 24 24 24 24 24 25 25 25 25 25 25 24 24
+1a90: 24 24 24 24 24 24 24 24 25 25 25 25 25 25 25 24
+1aa0: 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25 24
+1ab0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1ac0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1ad0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1ae0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1af0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1b00: 26 26 25 25 25 26 26 26 26 26 26 25 25 26 26 26
+1b10: 26 26 26 25 26 26 26 26 26 26 26 25 26 26 26 26
+1b20: 26 26 26 25 26 26 26 26 26 26 25 25 25 26 26 26
+1b30: 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
+1b40: 26 26 26 26 25 25 26 26 26 26 26 26 26 25 26 25
+1b50: 25 25 25 25 25 24 25 25 25 25 25 25 25 24 25 25
+1b60: 25 25 25 25 25 24 25 25 25 25 25 25 24 24 24 25
+1b70: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1b80: 24 25 25 25 25 25 25 24 25 25 25 25 25 25 24 24
+1b90: 25 25 25 25 25 25 25 24 25 25 25 25 25 25 25 24
+1ba0: 25 25 25 25 25 25 24 24 24 24 25 25 25 25 25 24
+1bb0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1bc0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1bd0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1be0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1bf0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1c00: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+1c10: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+1c20: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+1c30: 01 01 01 01 01 1b 1b 1b 1b 1b 1b 01 01 01 01 01
+1c40: 01 01 01 01 01 1b 01 01 01 01 1b 01 01 01 01 01
+1c50: 01 01 01 01 01 01 01 01 01 01 1b 01 01 01 01 01
+1c60: 01 01 01 01 01 01 01 01 01 01 1b 01 01 01 01 01
+1c70: 01 01 01 01 01 01 01 01 01 1b 1b 01 01 01 01 01
+1c80: 01 01 01 01 01 01 01 01 1b 1b 01 01 01 01 01 01
+1c90: 01 01 01 01 01 01 01 1b 1b 01 01 01 01 01 01 01
+1ca0: 01 01 01 01 01 01 01 1b 01 01 01 01 01 01 01 01
+1cb0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+1cc0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+1cd0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+1ce0: 01 01 01 01 01 01 01 1b 01 01 01 01 01 01 01 01
+1cf0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+1d00: 01 01 01 01 01 01 01 1b 1b 1b 01 01 01 01 01 01
+1d10: 01 01 01 01 01 01 1b 1b 1b 1b 1b 01 01 01 01 01
+1d20: 01 01 01 01 01 1b 1b 1b 1b 1b 1b 1b 01 01 01 01
+1d30: 01 01 01 01 01 1b 1b 1b 1b 1b 1b 1b 01 01 01 01
+1d40: 01 01 01 01 01 1b 1b 1b 1b 1b 1b 1b 01 01 01 01
+1d50: 01 01 01 01 01 1b 1b 1b 1b 1b 1b 1b 01 01 01 01
+1d60: 01 01 01 01 01 1b 1b 1b 1b 1b 1b 1b 01 01 01 01
+1d70: 01 01 01 01 01 01 1b 1b 1b 1b 1b 01 01 01 01 01
+1d80: 01 01 01 01 01 01 1b 1b 1b 1b 1b 01 01 01 01 01
+1d90: 01 01 01 01 01 01 01 1b 1b 1b 01 01 01 01 01 01
+1da0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+1db0: 01 01 01 01 01 01 01 1b 1b 1b 01 01 01 01 01 01
+1dc0: 01 01 01 01 01 01 1b 1b 1b 1b 1b 01 01 01 01 01
+1dd0: 01 01 01 01 01 01 1b 1b 1b 1b 1b 01 01 01 01 01
+1de0: 01 01 01 01 01 01 1b 1b 1b 1b 1b 01 01 01 01 01
+1df0: 01 01 01 01 01 01 01 1b 1b 1b 01 01 01 01 01 01
+1e00: 09 09 09 08 08 09 09 09 09 09 09 09 08 08 09 09
+1e10: 09 08 08 08 09 09 08 08 07 09 09 08 08 07 07 07
+1e20: 09 08 07 07 09 08 08 07 07 06 09 08 08 07 07 09
+1e30: 08 08 07 06 08 08 08 07 07 06 09 08 07 07 08 09
+1e40: 07 06 06 08 06 06 07 07 07 06 06 08 07 08 08 08
+1e50: 06 08 08 08 08 06 06 07 06 06 08 06 08 08 08 07
+1e60: 08 07 07 08 08 08 06 06 06 08 08 07 06 07 07 07
+1e70: 06 06 07 07 07 08 08 06 08 08 07 07 06 06 06 06
+1e80: 24 24 06 07 07 07 06 07 07 07 07 06 06 24 24 24
+1e90: 24 24 24 06 06 06 06 06 07 06 06 24 24 24 24 24
+1ea0: 24 24 24 24 24 24 24 24 06 24 24 24 24 24 24 24
+1eb0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1ec0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1ed0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1ee0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1ef0: 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
+1f00: 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e
+1f10: 0d 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e 0d
+1f20: 0d 0d 0d 0e 12 12 12 12 12 12 12 12 0e 0d 0d 0d
+1f30: 0d 0d 13 0d 0e 12 12 12 12 12 12 0e 0d 13 0d 0d
+1f40: 0d 0d 12 13 0d 0e 12 12 12 12 0e 0d 13 12 0d 0d
+1f50: 0d 0d 12 12 13 0d 0e 12 12 0e 0d 13 12 12 0d 0d
+1f60: 0d 0d 12 12 12 13 0d 0e 0e 0d 13 12 12 12 0d 0d
+1f70: 0d 0d 12 12 12 12 13 0d 0d 13 12 12 12 12 0d 0d
+1f80: 0d 0d 12 12 12 12 0e 0d 0d 0e 12 12 12 12 0d 0d
+1f90: 0d 0d 12 12 12 0e 0d 13 13 0d 0e 12 12 12 0d 0d
+1fa0: 0d 0d 12 12 0e 0d 13 12 12 13 0d 0e 12 12 0d 0d
+1fb0: 0d 0d 12 0e 0d 13 12 12 12 12 13 0d 0e 12 0d 0d
+1fc0: 0d 0d 0e 0d 13 12 12 12 12 12 12 13 0d 0e 0d 0d
+1fd0: 0d 0d 0d 13 12 12 12 12 12 12 12 12 13 0d 0d 0d
+1fe0: 0d 13 13 13 13 13 13 13 13 13 13 13 13 13 13 0d
+1ff0: 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13
+2000: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+2010: 01 01 2d 2d 2d 2d 2d 01 01 01 2d 2d 2d 01 01 01
+2020: 01 01 01 01 2d 01 01 01 01 2d 01 01 01 2d 01 01
+2030: 01 01 01 01 2d 01 01 01 01 2d 01 01 01 2d 01 01
+2040: 01 01 01 01 2d 01 01 01 01 2d 01 01 01 2d 01 01
+2050: 01 01 01 01 2d 01 01 01 01 2d 01 01 01 2d 01 01
+2060: 01 01 01 01 2d 01 01 01 01 01 2d 2d 2d 01 01 01
+2070: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+2080: 01 01 2d 2d 2d 2d 01 01 01 01 2d 2d 2d 01 01 01
+2090: 01 01 2d 01 01 01 2d 01 01 2d 01 01 01 2d 01 01
+20a0: 01 01 2d 01 01 01 2d 01 01 2d 01 01 01 2d 01 01
+20b0: 01 01 2d 01 01 01 2d 01 01 2d 01 01 01 2d 01 01
+20c0: 01 01 2d 01 01 01 2d 01 01 2d 01 01 01 2d 01 01
+20d0: 01 01 2d 2d 2d 2d 01 01 01 01 2d 2d 2d 01 01 01
+20e0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+20f0: 01 01 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 01
+2100: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+2110: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+2120: 01 01 01 01 01 01 17 17 17 17 01 01 01 01 01 01
+2130: 01 01 01 01 17 17 17 17 17 17 17 17 01 01 01 01
+2140: 01 01 01 17 17 17 16 17 16 17 17 17 17 01 01 01
+2150: 01 01 01 17 17 17 15 15 15 15 17 17 17 01 01 01
+2160: 01 01 17 17 17 15 16 17 16 17 17 17 17 17 01 01
+2170: 01 01 17 17 17 15 16 17 16 17 17 17 17 17 01 01
+2180: 01 01 17 17 17 15 16 17 16 17 17 17 17 17 01 01
+2190: 01 01 17 17 17 15 16 17 16 17 17 17 17 17 01 01
+21a0: 01 01 01 17 17 17 15 15 15 15 17 17 17 01 01 01
+21b0: 01 01 01 17 17 17 16 17 16 17 17 17 17 01 01 01
+21c0: 01 01 01 01 17 17 17 17 17 17 17 17 01 01 01 01
+21d0: 01 01 01 01 01 01 17 17 17 17 01 01 01 01 01 01
+21e0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+21f0: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01