fix some errors
[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_GAME
11 //#define VG_STATIC static
12 #define VG_STATIC
13 #define VG_FRAMEBUFFER_RESIZE 1
14 #include "vg/vg.h"
15 #include "submodules/anyascii/impl/c/anyascii.c"
16
17 #define RESET_MAX_TIME 45.0
18
19 enum menu_controller_type
20 {
21 k_menu_controller_type_keyboard,
22 k_menu_controller_type_xbox,
23 k_menu_controller_type_playstation,
24 k_menu_controller_type_steam,
25 k_menu_controller_type_steam_deck
26 };
27
28 VG_STATIC enum menu_controller_type menu_display_controller;
29
30 typedef struct ray_hit ray_hit;
31 struct ray_hit
32 {
33 float dist;
34 u32 *tri;
35 v3f pos, normal;
36 };
37
38 VG_STATIC int network_scores_updated = 0;
39
40 VG_STATIC u32 utf8_byte0_byte_count( u8 char0 )
41 {
42 for( u32 k=2; k<4; k++ )
43 {
44 if( !(char0 & (0x80 >> k)) )
45 return k;
46 }
47
48 return 0;
49 }
50
51 VG_STATIC void str_utf8_collapse( const char *str, char *buf, u32 length )
52 {
53 u8 *ustr = (u8 *)str;
54 u32 utf32_code = 0x00000000;
55 u32 i=0, j=0, utf32_byte_ct=0;
56
57 for(;i < length-1;)
58 {
59 if( ustr[i] == 0x00 )
60 break;
61
62 if( ustr[i] & 0x80 )
63 {
64 if( utf32_byte_ct )
65 {
66 utf32_byte_ct --;
67 utf32_code |= (ustr[i] & 0x3F) << (utf32_byte_ct*6);
68
69 if( !utf32_byte_ct )
70 {
71 const char *match;
72 size_t chars = anyascii( utf32_code, &match );
73
74 for( u32 k=0; k<VG_MIN(chars, length-1-j); k++ )
75 {
76 buf[ j++ ] = (u8)match[k];
77 }
78 }
79 }
80 else
81 {
82 utf32_byte_ct = utf8_byte0_byte_count( ustr[i] )-1;
83 utf32_code = ustr[i] & (0x3F >> utf32_byte_ct);
84 utf32_code <<= utf32_byte_ct*6;
85 }
86 }
87 else
88 {
89 utf32_byte_ct = 0x00;
90 buf[j ++] = str[i];
91 }
92
93 i++;
94 }
95
96 buf[j] = 0x00;
97 }
98
99 VG_STATIC float
100 k_runspeed = 20.0f, /* depr */
101 k_board_radius = 0.3f,
102 k_board_length = 0.45f,
103 k_board_allowance = 0.04f,
104 k_friction_lat = 12.0f,
105 k_friction_resistance = 0.01f,
106 k_max_push_speed = 16.0f,
107 k_push_accel = 10.0f,
108 k_push_cycle_rate = 8.0f,
109 k_steer_ground = 2.5f,
110 k_steer_air = 3.6f,
111 k_steer_air_lerp = 0.3f,
112 k_pump_force = 0.0f,
113 k_downforce = 5.0f,
114 k_walk_downforce = 8.0f,
115 k_jump_charge_speed = (1.0f/1.0f),
116 k_jump_force = 5.0f,
117 k_pitch_limit = 1.5f,
118 k_look_speed = 2.0f,
119
120 k_spin_boost = 2.2f,
121
122 k_cog_spring = 0.2f,
123 k_cog_damp = 0.02f,
124 k_cog_mass_ratio = 0.9f,
125
126 k_mmthrow_scale = 6.0f,
127 k_mmcollect_lat = 2.0f,
128 k_mmcollect_vert = 0.0f,
129 k_mmdecay = 12.0f,
130 k_spring_angular = 1.0f,
131
132 k_spring_force = 15.0f,
133 k_spring_dampener = 5.0f;
134
135
136 #endif /* COMMON_H */