aboutsummaryrefslogtreecommitdiff
path: root/src/engine/title_screen.c
blob: 1e9e58681aa0a979822a343d68d425a4f083dc51 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "ppu/ppu.h"
#include "ppu/types.h"
#include "ppu/consts.h"

#include "static/tilemap.h"


#include "engine/draw_screen.h"
#include "engine/entity.h"

void hh_init_title_screen(){

	// hh_clear_screen();

	//send data
	uint8_t idx = 0;
	const uint8_t tilemap_offset = HH_TM_TITLE_SCREEN_ICON_OFFSET;
	int tiles_h = HH_PPU_BG_CANVAS_TILES_H;
	int vp_h = HH_PPU_SCREEN_WIDTH/HH_PPU_SPRITE_WIDTH; //screen_h in tiles
	int vert_offset = tiles_h*3;

	const uint8_t arr[4][4] = {
		{0,1,1,0},
		{2,3,3,2},
		{4,0,0,4},
		{5,6,6,5},
	};
	int val, counter =0;
	hh_ppu_update_color(5, 0, (hh_ppu_rgb_color_t) {0x1, 0x1, 0x1});
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			val = arr[i][j];

			hh_s_ppu_loc_bam_entry temp = {
			.vertical_flip=false, .horizontal_flip = ((j % 4 < 2) ? false : true),
			.palette_index = (counter == 9 || counter == 10? 5:3), .tilemap_index = (val > 0 ? (tilemap_offset + val) : 0)
			};

			int vert_pos = tiles_h*i;
			int x_pos = j;
			idx = vert_offset + vert_pos + x_pos + vp_h/2-2;
			
			hh_ppu_update_background(idx,temp);
			counter++;
		}

	}
	

	const uint8_t letters_offset = HH_TM_TITLE_SCREEN_LETTERES_LARGE_OFFSET;
	const int _size_hooded = 7, _size_v = 2;

	// char* hh = "hooded";
	int hooded_lookup[7][2]={
		{0,1},{0,2},//H
		{3,4},{3,4},//oo
		{5,6},{13,9},//de
		{5,6}//d
	};

	counter = 8;
	for (int i = 0; i < _size_hooded; i++) {
		for (int vert = 1; vert <= _size_v; vert++) {
			//TODO: move 'H' a few pixels to the right for a more cohesive font spacing
			hh_ppu_update_foreground(counter++, (hh_s_ppu_loc_fam_entry) {
				.vertical_flip = false, .horizontal_flip = false,
				.palette_index = 6, .tilemap_index = letters_offset + hooded_lookup[i][vert-1],
				.position_x = (16*i + 64+48), .position_y = (16*(vert > 1 ? 0:1)*-1 + 64+8+16 +(i==2 || i==3 ? 6:0))
			});	
		}
	}


	hh_ppu_update_color(5, 1, (hh_ppu_rgb_color_t) {0xa, 0x3, 0x3});
	hh_ppu_update_color(5, 2, (hh_ppu_rgb_color_t) {0xc, 0x5, 0x3});

	const int _size_havoc = 6;
	int lookup_havoc[6][2]={
		{0,1},{0,2},//H
		{13,10},{7,8},//av
		{13,11},{13,12}//oc
	};

	counter = 8 + (_size_hooded * _size_v);
	for (int i = 0; i < _size_havoc; i++) {
		for (int vert = 1; vert <= _size_v; vert++) {
			//TODO: move 'H' a few pixels to the right for a more cohesive font spacing
			hh_ppu_update_foreground(counter++, (hh_s_ppu_loc_fam_entry) {
				.vertical_flip = false, .horizontal_flip = (i > 4 && vert==0 ? 1:0),
				.palette_index = 5, .tilemap_index = letters_offset + lookup_havoc[i][vert-1],
				.position_x = (16*i +64+32+8), .position_y = (16*(vert > 1 ? 0:1)*-1 + 64+8+48)
			});	
		}
	}
}