fov slider input maps menu stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / common.h
1 /*
2 * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 */
4
5 #ifndef COMMON_H
6 #define COMMON_H
7
8 #define VG_TIMESTEP_FIXED (1.0/60.0)
9 #define VG_3D
10 #define VG_FRAMEBUFFER_RESIZE 1
11 #include "vg/vg.h"
12 #include "anyascii/anyascii.h"
13
14 #define RESET_MAX_TIME 45.0
15
16 enum menu_controller_type
17 {
18 k_menu_controller_type_keyboard,
19 k_menu_controller_type_xbox,
20 k_menu_controller_type_playstation,
21 k_menu_controller_type_steam,
22 k_menu_controller_type_steam_deck
23 };
24
25 VG_STATIC enum menu_controller_type menu_display_controller;
26 VG_STATIC float g_fov_option = 0.86f;
27
28 typedef struct ray_hit ray_hit;
29 struct ray_hit
30 {
31 float dist;
32 u32 *tri;
33 v3f pos, normal;
34 };
35
36 VG_STATIC int network_scores_updated = 0;
37
38 VG_STATIC u32 utf8_byte0_byte_count( u8 char0 )
39 {
40 for( u32 k=2; k<4; k++ )
41 {
42 if( !(char0 & (0x80 >> k)) )
43 return k;
44 }
45
46 return 0;
47 }
48
49 VG_STATIC void str_utf8_collapse( const char *str, char *buf, u32 length )
50 {
51 u8 *ustr = (u8 *)str;
52 u32 utf32_code = 0x00000000;
53 u32 i=0, j=0, utf32_byte_ct=0;
54
55 for(;i < length-1;)
56 {
57 if( ustr[i] == 0x00 )
58 break;
59
60 if( ustr[i] & 0x80 )
61 {
62 if( utf32_byte_ct )
63 {
64 utf32_byte_ct --;
65 utf32_code |= (ustr[i] & 0x3F) << (utf32_byte_ct*6);
66
67 if( !utf32_byte_ct )
68 {
69 const char *match;
70 size_t chars = anyascii( utf32_code, &match );
71
72 for( u32 k=0; k<VG_MIN(chars, length-1-j); k++ )
73 {
74 buf[ j++ ] = (u8)match[k];
75 }
76 }
77 }
78 else
79 {
80 utf32_byte_ct = utf8_byte0_byte_count( ustr[i] )-1;
81 utf32_code = ustr[i] & (0x3F >> utf32_byte_ct);
82 utf32_code <<= utf32_byte_ct*6;
83 }
84 }
85 else
86 {
87 utf32_byte_ct = 0x00;
88 buf[j ++] = str[i];
89 }
90
91 i++;
92 }
93
94 buf[j] = 0x00;
95 }
96
97 #endif /* COMMON_H */