From: xolatile Date: Tue, 15 Apr 2025 10:02:08 +0000 (+0200) Subject: Using Terry types... X-Git-Url: https://git.xolatile.top/?a=commitdiff_plain;h=36a74400fa04f19e2fe94d367a5c0c5f14e1ac55;p=emil-xolatilization.git Using Terry types... --- diff --git a/test.c b/test.c index b18b2f4..8f5a100 100644 --- a/test.c +++ b/test.c @@ -9,20 +9,20 @@ #include "xhape.h" #include "xision.h" -static void print_shape (shape_node * sh) { +static v0 print_shape (shape_node * sh) { print ("shape data:\n"); print ("v = %i // %i\n", sh->vertex_count, sh->vertex_limit); print ("i = %i // %i\n", sh->index_count, sh->index_limit); } -static void render_shape (vision_structure * vision, shape_node * sh) { - //~uint vc = sh->vertex_count; - //~uint ic = sh->index_count; +static v0 render_shape (vision_structure * vision, shape_node * sh) { + //~u4 vc = sh->vertex_count; + //~u4 ic = sh->index_count; - //~float va [100] = { 0 }; - //~uint ia [100] = { 0 }; + //~f4 va [100] = { 0 }; + //~u4 ia [100] = { 0 }; - //~for (uint i = 0; i < vc; i += 5) { + //~for (u4 i = 0; i < vc; i += 5) { //~va [i+0] = sh->vertex_array [i/5]->x; //~va [i+1] = sh->vertex_array [i/5]->y; //~va [i+2] = sh->vertex_array [i/5]->z; @@ -30,14 +30,14 @@ static void render_shape (vision_structure * vision, shape_node * sh) { //~va [i+4] = sh->unwrap_array [i/5]->y; //~} - //~for (uint i = 0; i < ic; i += 5) { + //~for (u4 i = 0; i < ic; i += 5) { //~ia [i] = sh->index_array [i]; //~} vision_render_base (vision, sh->vertex_count, sh->vertex_array, sh->index_count, sh->index_array, 0, 0xff7733ff); } -int main (void) { +s4 main (v0) { //~vector_3 as = { +2,0,0 }; //~vector_3 bs = { -2,0,0 }; //~vector_3 cs = { 0,+2,0 }; @@ -59,11 +59,11 @@ int main (void) { vision_structure * vision = vision_initialize (60, 60, false, 6000, 3000, 256); particle_structure * particle = particle_initialize (1024); - uint i0 = vision_sprite_import (vision, "xui/goblin/end_turn_button.png"); - uint i1 = vision_sprite_import (vision, "xui/goblin/separator_center.png"); - uint i2 = vision_sprite_import (vision, "xui/goblin/separator_left.png"); - uint i3 = vision_sprite_import (vision, "xui/goblin/separator_middle.png"); - uint i4 = vision_sprite_import (vision, "xui/goblin/separator_right.png"); + u4 i0 = vision_sprite_import (vision, "xui/goblin/end_turn_button.png"); + u4 i1 = vision_sprite_import (vision, "xui/goblin/separator_center.png"); + u4 i2 = vision_sprite_import (vision, "xui/goblin/separator_left.png"); + u4 i3 = vision_sprite_import (vision, "xui/goblin/separator_middle.png"); + u4 i4 = vision_sprite_import (vision, "xui/goblin/separator_right.png"); vision_configure (vision, 800, 600, "Xube"); @@ -107,12 +107,12 @@ int main (void) { render_shape (vision, e); render_shape (vision, f); - //~float t0 [] = {1,0,0,0,0,1,0,1,0}; - //~float t1 [] = {1,0,0,0,0,1,0,1,0}; - //~float t2 [] = {1,0,0,0,0,1,0,1,0}; - //~float t3 [] = {1,0,0,0,0,1,0,1,0}; - //~float t4 [] = {1,0,0,0,0,1,0,1,0}; - //~float t5 [] = {1,0,0,0,0,1,0,1,0}; + //~f4 t0 [] = {1,0,0,0,0,1,0,1,0}; + //~f4 t1 [] = {1,0,0,0,0,1,0,1,0}; + //~f4 t2 [] = {1,0,0,0,0,1,0,1,0}; + //~f4 t3 [] = {1,0,0,0,0,1,0,1,0}; + //~f4 t4 [] = {1,0,0,0,0,1,0,1,0}; + //~f4 t5 [] = {1,0,0,0,0,1,0,1,0}; //~vision_render_triangle (vision, t0, 0xff7733ff); //~vision_render_triangle (vision, t1, 0xff7733ff); @@ -121,7 +121,7 @@ int main (void) { //~vision_render_triangle (vision, t4, 0xff7733ff); //~vision_render_triangle (vision, t5, 0xff7733ff); - //~for (uint i = 0; i < particle->count; ++i) { + //~for (u4 i = 0; i < particle->count; ++i) { //~Vector3 vector = {particle->position [i]->x, particle->position [i]->y, particle->position [i]->z}; //~DrawBillboard (camera, texture, vector, 1, RED); //~} @@ -131,14 +131,14 @@ int main (void) { - //~float va [] = { + //~f4 va [] = { //~-1, -1, 0, 0, 1, 1, 1, 1, 1, //~-1, +1, 0, 0, 0, 1, 1, 1, 1, //~+1, +1, 0, 1, 0, 1, 1, 1, 1, //~+1, -1, 0, 1, 1, 1, 1, 1, 1 //~}; - //~uint ia [] = { 2, 1, 0, 3, 2, 1 }; + //~u4 ia [] = { 2, 1, 0, 3, 2, 1 }; //~vision_render_base (vision, sizeof(va)/4, va, sizeof(ia)/4, ia, 1, 0xff7733ff); diff --git a/xachine.h b/xachine.h index 7f343a2..fcfa5f5 100755 --- a/xachine.h +++ b/xachine.h @@ -45,11 +45,11 @@ typedef enum { #ifdef use_debug_printing -static char * operand_name [operand_count] = { +static c1 * operand_name [operand_count] = { "rel", "reg", "mem", "imm" }; -static char * operation_name [operation_count] = { +static c1 * operation_name [operation_count] = { "asmmem", "asmrel", "asmnum", "asmstr", "add", "or", "adc", "sbb", "and", "sub", "xor", "cmp", "inc", "dec", "not", "neg", "mul", "imul", "div", "idiv", @@ -61,19 +61,19 @@ static char * operation_name [operation_count] = { #endif -static uint main_entry_point = 0; -static uint text_sector_size = 0; -static uchar * text_sector_byte = null; -static uint data_sector_size = 0; // This is unused, and it should be used... -static uchar * data_sector_byte = null; // This is unused, and it should be used... +static u4 main_entry_pos4 = 0; +static u4 text_sector_size = 0; +static u1 * text_sector_byte = null; +static u4 data_sector_size = 0; // This is unused, and it should be used... +static u1 * data_sector_byte = null; // This is unused, and it should be used... -static uint empty_count = 1; -static uint empty_holes = 1; -static uint * empty_array = null; -static uint * empty_imbue = null; -static uint * empty_store = null; +static u4 empty_count = 1; +static u4 empty_holes = 1; +static u4 * empty_array = null; +static u4 * empty_imbue = null; +static u4 * empty_store = null; -static uchar elf_main_header_byte [elf_main_header_size] = { // These should be done properly... +static u1 elf_main_header_byte [elf_main_header_size] = { // These should be done properly... 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x3e, 0x00, 0x01, 0x00, 0x00, 0x00, @@ -84,7 +84,7 @@ static uchar elf_main_header_byte [elf_main_header_size] = { // These should be 0x02, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static uchar elf_text_sector_byte [elf_text_sector_size] = { +static u1 elf_text_sector_byte [elf_text_sector_size] = { 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -94,7 +94,7 @@ static uchar elf_text_sector_byte [elf_text_sector_size] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static uchar elf_data_sector_byte [elf_data_sector_size] = { +static u1 elf_data_sector_byte [elf_data_sector_size] = { 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -104,36 +104,36 @@ static uchar elf_data_sector_byte [elf_data_sector_size] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static bool register_register (uint to, uint from) { return ((to == operand_register) && (from == operand_register)); } -static bool register_memory (uint to, uint from) { return ((to == operand_register) && (from == operand_memory)); } -static bool register_immediate (uint to, uint from) { return ((to == operand_register) && (from == operand_immediate)); } -static bool memory_register (uint to, uint from) { return ((to == operand_memory) && (from == operand_register)); } -static bool memory_immediate (uint to, uint from) { return ((to == operand_memory) && (from == operand_immediate)); } -static bool register_relative (uint to, uint from) { return ((to == operand_register) && (from == operand_relative)); } +static b4 register_register (u4 to, u4 from) { return ((to == operand_register) && (from == operand_register)); } +static b4 register_memory (u4 to, u4 from) { return ((to == operand_register) && (from == operand_memory)); } +static b4 register_immediate (u4 to, u4 from) { return ((to == operand_register) && (from == operand_immediate)); } +static b4 memory_register (u4 to, u4 from) { return ((to == operand_memory) && (from == operand_register)); } +static b4 memory_immediate (u4 to, u4 from) { return ((to == operand_memory) && (from == operand_immediate)); } +static b4 register_relative (u4 to, u4 from) { return ((to == operand_register) && (from == operand_relative)); } -static uint absolute (void) { return (0x4010b0 - text_sector_size - 4); } -static uint relative (void) { return (0x1000 - text_sector_size - 4); } +static u4 absolute (v0) { return (0x4010b0 - text_sector_size - 4); } +static u4 relative (v0) { return (0x1000 - text_sector_size - 4); } -static void replace (uchar * destination, uchar * source, ulong size) { +static v0 replace (u1 * destination, u1 * source, u8 size) { for (--size; size >= 0; --size) { destination [size] = source [size]; } } -static void inset (bool when, uchar data) { +static v0 inset (b4 when, u1 data) { text_sector_byte [text_sector_size] = data; - text_sector_size += (uint) when; + text_sector_size += (u4) when; } -static void inset_immediate (bool when, uint data) { +static v0 inset_immediate (b4 when, u4 data) { inset (when, (data >> 0) & 0xff); inset (when, (data >> 8) & 0xff); inset (when, (data >> 16) & 0xff); inset (when, (data >> 24) & 0xff); } -static void inset_memory (bool when, uint data, uint base) { +static v0 inset_memory (b4 when, u4 data, u4 base) { empty_array [empty_holes] = text_sector_size; empty_imbue [empty_holes] = data; @@ -142,7 +142,7 @@ static void inset_memory (bool when, uint data, uint base) { inset_immediate (when, base); } -static void inset_relative (bool when, uint data, uint base) { +static v0 inset_relative (b4 when, u4 data, u4 base) { empty_array [empty_holes] = 0; empty_imbue [empty_holes] = data; @@ -151,16 +151,16 @@ static void inset_relative (bool when, uint data, uint base) { inset_immediate (when, base); } -static uint mc0 (uint code, uint base) { +static u4 mc0 (u4 code, u4 base) { return (0xc0 + 0x01 * (code % 8) + 0x08 * (base % 8)); } -static uint m05 (uint code) { +static u4 m05 (u4 code) { return (0x05 + 0x08 * code); } -static uint store_relative (uint * array) { - uint relative = array [1]; +static u4 store_relative (u4 * array) { + u4 relative = array [1]; #ifdef use_debug_printing print ("/3asmrel/- %i", relative); #endif @@ -172,8 +172,8 @@ static uint store_relative (uint * array) { return 1; } -static uint store_memory (uint * array) { - uint memory = array [1]; +static u4 store_memory (u4 * array) { + u4 memory = array [1]; #ifdef use_debug_printing print ("/3asmmem/- %i", memory); #endif @@ -184,38 +184,38 @@ static uint store_memory (uint * array) { return 1; } -static uint store_number (uint * array) { - uint amount = array [1]; +static u4 store_number (u4 * array) { + u4 amount = array [1]; #ifdef use_debug_printing print ("/3asmnum/- %i", amount); #endif - for (uint index = 0; index < amount; ++index) { + for (u4 index = 0; index < amount; ++index) { inset_immediate (true, array [2 + index]); } return amount + 1; } -static uint store_string (uint * array) { - uint amount = array [1]; +static u4 store_string (u4 * array) { + u4 amount = array [1]; #ifdef use_debug_printing print ("/3asmstr/- %i", amount); #endif - for (uint index = 0; index < amount; ++index) { + for (u4 index = 0; index < amount; ++index) { inset (true, array [2 + index]); } return amount + 1; } -static uint build_double (uint * array) { - uint operation = array [0]; - uint to = array [1]; - uint destination = array [2]; - uint from = array [3]; - uint source = array [4]; +static u4 build_f8 (u4 * array) { + u4 operation = array [0]; + u4 to = array [1]; + u4 destination = array [2]; + u4 from = array [3]; + u4 source = array [4]; #ifdef use_debug_printing print ("/3%s/- /6%s/- %i /6%s/- %i", operation_name [operation], operand_name [to], destination, operand_name [from], source); #endif @@ -248,10 +248,10 @@ static uint build_double (uint * array) { return 4; } -static uint build_single (uint * array) { - uint operation = array [0]; - uint to = array [1]; - uint destination = array [2]; +static u4 build_single (u4 * array) { + u4 operation = array [0]; + u4 to = array [1]; + u4 destination = array [2]; #ifdef use_debug_printing print ("/3%s/- /6%s/- %i", operation_name [operation], operand_name [to], destination); #endif @@ -264,11 +264,11 @@ static uint build_single (uint * array) { return 2; } -static uint build_shift (uint * array) { - uint operation = array [0]; - uint to = array [1]; - uint destination = array [2]; - uint offset = array [3]; +static u4 build_shift (u4 * array) { + u4 operation = array [0]; + u4 to = array [1]; + u4 destination = array [2]; + u4 offset = array [3]; #ifdef use_debug_printing print ("/3%s/- /6%s/- %i /cimm/- %i", operation_name [operation], operand_name [to], destination, offset); #endif @@ -284,8 +284,8 @@ static uint build_shift (uint * array) { return 3; } -static uint build_static_1 (uint * array) { - uint operation = array [0]; +static u4 build_static_1 (u4 * array) { + u4 operation = array [0]; #ifdef use_debug_printing print ("/3%s/-", operation_name [operation]); #endif @@ -299,9 +299,9 @@ static uint build_static_1 (uint * array) { return 0; } -static uint build_jump_if (uint * array) { - uint operation = array [0]; - uint location = array [1]; +static u4 build_jump_if (u4 * array) { + u4 operation = array [0]; + u4 location = array [1]; #ifdef use_debug_printing print ("/3%s/- %i", operation_name [operation], location); #endif @@ -313,9 +313,9 @@ static uint build_jump_if (uint * array) { return 2; } -static uint build_jump (uint * array) { - uint to = array [1]; - uint destination = array [2]; +static u4 build_jump (u4 * array) { + u4 to = array [1]; + u4 destination = array [2]; #ifdef use_debug_printing print ("/3jmp/- /6%s/- %i", operand_name [to], destination); #endif @@ -328,11 +328,11 @@ static uint build_jump (uint * array) { return 2; } -static uint build_move (uint * array) { - uint to = array [1]; - uint destination = array [2]; - uint from = array [3]; - uint source = array [4]; +static u4 build_move (u4 * array) { + u4 to = array [1]; + u4 destination = array [2]; + u4 from = array [3]; + u4 source = array [4]; #ifdef use_debug_printing print ("/3mov/- /6%s/- %i /6%s/- %i", operand_name [to], destination, operand_name [from], source); #endif @@ -359,9 +359,9 @@ static uint build_move (uint * array) { return 4; } -static uint build_call (uint * array) { - uint from = array [1]; - uint source = array [2]; +static u4 build_call (u4 * array) { + u4 from = array [1]; + u4 source = array [2]; #ifdef use_debug_printing print ("/3call/- /6%s/- %i", operand_name [from], source); #endif @@ -374,7 +374,7 @@ static uint build_call (uint * array) { return 2; } -static uint (* build_instruction [operation_count]) (uint * array) = { +static u4 (* build_instruction [operation_count]) (u4 * array) = { store_memory, // operation_memory : LABEL store_relative, // operation_relative : "IMPLEMENTED" store_number, @@ -387,7 +387,7 @@ static uint (* build_instruction [operation_count]) (uint * array) = { build_static_1, build_static_1, build_static_1, build_call, build_jump, build_move }; -static void assemble (uint count, uint * array, uint external_memory, uint internal_memory) { +static v0 assemble (u4 count, u4 * array, u4 external_memory, u4 internal_memory) { text_sector_byte = arena_add (external_memory * sizeof (* text_sector_byte)); data_sector_byte = arena_add (external_memory * sizeof (* text_sector_byte)); @@ -395,10 +395,10 @@ static void assemble (uint count, uint * array, uint external_memory, uint inter empty_imbue = arena_add (internal_memory * sizeof (* empty_imbue)); empty_store = arena_add (internal_memory * sizeof (* empty_store)); - for (uint index = 0; index < count; ++index) { - uint size = text_sector_size; + for (u4 index = 0; index < count; ++index) { + u4 size = text_sector_size; - uchar byte = 0; + u1 byte = 0; #ifdef use_debug_nopping inset (array [index] > operation_string, 0x90); #endif @@ -406,28 +406,28 @@ static void assemble (uint count, uint * array, uint external_memory, uint inter #ifdef use_debug_printing print (" /0--/- "); for (byte = size; byte < text_sector_size; ++byte) { - print ("/5%s/- ", format_to_string ((uchar) text_sector_byte [byte], false, 16, 2, '0')); + print ("/5%s/- ", format_to_string ((u1) text_sector_byte [byte], false, 16, 2, '0')); } print ("\n"); #endif } - main_entry_point = empty_store [0]; + main_entry_pos4 = empty_store [0]; - for (uint index = 1; index < empty_holes; ++index) { - uint set = 0; - uint get = empty_array [index]; + for (u4 index = 1; index < empty_holes; ++index) { + u4 set = 0; + u4 get = empty_array [index]; - replace ((uchar *) & set, & text_sector_byte [get], sizeof (set)); + replace ((u1 *) & set, & text_sector_byte [get], sizeof (set)); set += empty_store [empty_imbue [index]]; - replace (& text_sector_byte [get], (uchar *) & set, sizeof (get)); + replace (& text_sector_byte [get], (u1 *) & set, sizeof (get)); } } -static void elf_main_header (uint entry_point, bool has_program, bool for_linux, bool for_x86_64) { - uint enter = entry_point + 0x4000b0; +static v0 elf_main_header (u4 entry_point, b4 has_program, b4 for_linux, b4 for_x86_64) { + u4 enter = entry_pos4 + 0x4000b0; elf_main_header_byte [16] = (has_program) ? 0x02 : 0x03; elf_main_header_byte [ 7] = (for_linux) ? 0x03 : 0x00; @@ -436,17 +436,17 @@ static void elf_main_header (uint entry_point, bool has_program, bool for_linux, memory_copy (& elf_main_header_byte [24], & enter, sizeof (enter)); } -static void elf_text_sector (uint text_size, uint data_size) { - uint text = elf_header_size + text_size - data_size; +static v0 elf_text_sector (u4 text_size, u4 data_size) { + u4 text = elf_header_size + text_size - data_size; memory_copy (& elf_text_sector_byte [32], & text, sizeof (text)); memory_copy (& elf_text_sector_byte [40], & text, sizeof (text)); } -static void elf_data_sector (uint text_size, uint data_size) { - uint data = data_size; - uint core = elf_header_size + text_size - data_size; - uint move = 0x401000 + core; +static v0 elf_data_sector (u4 text_size, u4 data_size) { + u4 data = data_size; + u4 core = elf_header_size + text_size - data_size; + u4 move = 0x401000 + core; memory_copy (& elf_data_sector_byte [ 8], & core, sizeof (core)); memory_copy (& elf_data_sector_byte [16], & move, sizeof (move)); diff --git a/xanguage.h b/xanguage.h index 12b2a86..bf29cfe 100755 --- a/xanguage.h +++ b/xanguage.h @@ -24,38 +24,43 @@ typedef enum { } language_enumeration; typedef struct { - uint comment_colour; - uint processor_colour; - uint character_colour; - uint string_colour; - uint keyword_colour; - uint type_colour; - uint bracket_colour; - uint operator_colour; - uint number_colour; - uint lowercase_colour; - uint uppercase_colour; - uint underscore_colour; - uint register_colour; - uint extension_colour; - uint fatal_colour; - uint comment_effect; - uint processor_effect; - uint character_effect; - uint string_effect; - uint keyword_effect; - uint type_effect; - uint bracket_effect; - uint operator_effect; - uint number_effect; - uint lowercase_effect; - uint uppercase_effect; - uint underscore_effect; - uint register_effect; - uint extension_effect; - uint fatal_effect; + u4 comment_colour; + u4 processor_colour; + u4 character_colour; + u4 string_colour; + u4 keyword_colour; + u4 type_colour; + u4 bracket_colour; + u4 operator_colour; + u4 number_colour; + u4 lowercase_colour; + u4 uppercase_colour; + u4 underscore_colour; + u4 register_colour; + u4 extension_colour; + u4 fatal_colour; + u4 comment_effect; + u4 processor_effect; + u4 character_effect; + u4 string_effect; + u4 keyword_effect; + u4 type_effect; + u4 bracket_effect; + u4 operator_effect; + u4 number_effect; + u4 lowercase_effect; + u4 uppercase_effect; + u4 underscore_effect; + u4 register_effect; + u4 extension_effect; + u4 fatal_effect; } language_structure; +#define language_lowercase "abcdefghijklmnopqrstuvwxyz" +#define language_uppercase "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +#define language_letters "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +#define language_digits "0123456789" + #include #include #include @@ -72,28 +77,28 @@ typedef struct { #include #include -static void (* language_highlighter [language_count]) (language_structure * language, syntax_structure * syntax) = { +static v0 (* language_highlighter [language_count]) (language_structure * language, syntax_structure * syntax) = { language_highlight_common, language_highlight_ada, language_highlight_c, language_highlight_cpp, language_highlight_d, language_highlight_eaxhla, language_highlight_flat, language_highlight_fortran, language_highlight_pascal, language_highlight_python, language_highlight_go, language_highlight_lua, language_highlight_bash, language_highlight_haskell, language_highlight_valgrind }; -static char * language_short_option [language_count] = { +static c1 * language_short_option [language_count] = { "-X", "-A", "-C", "-S", "-D", "-E", "-T", "-F", "-P", "-Y", "-G", "-L", "-B", "-H", "-V" }; -static char * language_long_option [language_count] = { +static c1 * language_long_option [language_count] = { "--common", "--ada", "--c", "--cpp", "--d", "--eaxhla", "--flat", "--fortran", "--pascal", "--python", "--go", "--lua", "--bash", "--haskell", "--valgrind" }; -static char * language_identifier [language_count] = { +static c1 * language_identifier [language_count] = { "Common", "Ada", "C", "C++", "D", "EAXHLA", "Flat", "Fortran", "Pascal", "Python", "Go", "Lua", "Bash", "Haskell", "Valgrind" }; -static language_structure * language_initialize (bool true_colour) { +static language_structure * language_initialize (b4 true_colour) { language_structure * language = allocate (sizeof (* language)); if (true_colour == true) { @@ -152,7 +157,7 @@ static language_structure * language_deinitialize (language_structure * language return (deallocate (language)); } -static void language_conditionally_select (language_structure * language, syntax_structure * syntax, language_enumeration select) { +static v0 language_conditionally_select (language_structure * language, syntax_structure * syntax, language_enumeration select) { if (syntax->count == 0) { if ((select == file_type_c_source) || (select == file_type_c_header)) { language_highlight_c (language, syntax); @@ -175,3 +180,8 @@ static void language_conditionally_select (language_structure * language, syntax } } } + +#undef language_lowercase +#undef language_uppercase +#undef language_letters +#undef language_digits diff --git a/xanguage/ada.h b/xanguage/ada.h index 8773e5e..98cab07 100755 --- a/xanguage/ada.h +++ b/xanguage/ada.h @@ -1,7 +1,7 @@ -static void language_highlight_ada (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/&|()\" \t\r\n"; +static v0 language_highlight_ada (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/&|()\" \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "abort", "else", "new", "return", "abs", "elsif", "not", "reverse", "abstract", "end", "null", "accept", "entry", "select", "access", "of", "separate", "aliased", "exit", "or", "some", "all", "others", "subtype", @@ -18,14 +18,13 @@ static void language_highlight_ada (language_structure * language, syntax_struct syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } syntax_define (syntax, true, false, "()", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+-*/&|'", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_letters, separators, '\0', language->lowercase_colour, language->lowercase_effect); } diff --git a/xanguage/bash.h b/xanguage/bash.h index 7a3b058..706b49f 100755 --- a/xanguage/bash.h +++ b/xanguage/bash.h @@ -1,7 +1,7 @@ -static void language_highlight_bash (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%!&~^?|@#$()[]{}'\" \t\r\n"; +static v0 language_highlight_bash (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%!&~^?|@#$()[]{}'\" \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "exit", "set", "elif", "done", "in", "then", "function", "fi", "if", "else", "do", "while", "for" }; @@ -10,15 +10,15 @@ static void language_highlight_bash (language_structure * language, syntax_struc syntax_define (syntax, false, false, "'", "'", '\0', language->string_colour, language->string_effect); syntax_define (syntax, false, false, "\"", "\"", '\0', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|@#$", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/c++.h b/xanguage/c++.h index b68df96..a805c3c 100755 --- a/xanguage/c++.h +++ b/xanguage/c++.h @@ -1,7 +1,7 @@ -static void language_highlight_cpp (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n"; +static v0 language_highlight_cpp (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "alignas", "alignof", "and", "asm", "auto", "break", "case", "catch", "class", "compl", "concept", "const", "consteval", "constexpr", "constinit", "continue", "decltype", "default", "delete", "do", "else", @@ -14,14 +14,14 @@ static void language_highlight_cpp (language_structure * language, syntax_struct "volatile", "while", "xor", "final", "override", "import", "module" }; - char * types [] = { - "void", "bool", "off_t", "va_list", "float", "double", "float_t", "double_t", + c1 * types [] = { + "v0", "b4", "off_t", "va_list", "float", "double", "float_t", "double_t", "char", "short", "int", "long", "uchar", "ushort", "uint", "ulong", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "signed", "unsigned", "size_t", "ssize_t" }; - char * commons [] = { + c1 * commons [] = { "std", "FILE", "DIR", "EOF", "va_arg", "va_start", "va_end", "va_copy" }; @@ -31,23 +31,23 @@ static void language_highlight_cpp (language_structure * language, syntax_struct syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (types); ++word) { + for (u8 word = 0; word < array_length (types); ++word) { syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect); } - for (ulong word = 0; word < array_length (commons); ++word) { + for (u8 word = 0; word < array_length (commons); ++word) { syntax_define (syntax, false, true, commons [word], separators, '\0', language->extension_colour, language->extension_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/c.h b/xanguage/c.h index 7012ceb..c805818 100755 --- a/xanguage/c.h +++ b/xanguage/c.h @@ -1,25 +1,25 @@ -static void language_highlight_c (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n"; +static v0 language_highlight_c (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "register", "volatile", "auto", "const", "static", "extern", "if", "else", "do", "while", "for", "continue", "switch", "case", "default", "break", "enum", "union", "struct", "typedef", "goto", "return", "sizeof", "inline", "restrict", "true", "false" }; - char * types [] = { - "void", "bool", "off_t", "va_list", "float", "double", "float_t", "double_t", + c1 * types [] = { + "v0", "b4", "off_t", "va_list", "float", "double", "float_t", "double_t", "char", "short", "int", "long", "uchar", "ushort", "uint", "ulong", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "signed", "unsigned", "size_t", "ssize_t" }; - char * commons [] = { + c1 * commons [] = { "null", "NULL", "FILE", "DIR", "va_arg", "va_start", "va_end", "va_copy", "alignas", "alignof", "offsetof", "typeof", "EOF", "ABS", "MIN", "MAX", - "ARRAYSIZE", "SWAP", "UNUSED", "UNREACHABLE", "STRINGIFY", "CONCAT", "assert", "static_assert", - "thread_local", "nullptr" + "ARRAYSIZE", "SWAP", "UNUSED", "UNREACHABLE", "STRINGIFY", "CONCAT", "assert", "nullptr", + "thread_local", "static_assert" }; syntax_define (syntax, false, false, "/*", "*/", '\0', language->comment_colour, language->comment_effect); @@ -28,23 +28,23 @@ static void language_highlight_c (language_structure * language, syntax_structur syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (types); ++word) { + for (u8 word = 0; word < array_length (types); ++word) { syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect); } - for (ulong word = 0; word < array_length (commons); ++word) { + for (u8 word = 0; word < array_length (commons); ++word) { syntax_define (syntax, false, true, commons [word], separators, '\0', language->extension_colour, language->extension_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/common.h b/xanguage/common.h index 2ccd03d..146fe5b 100755 --- a/xanguage/common.h +++ b/xanguage/common.h @@ -1,9 +1,11 @@ -static void language_highlight_common (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+*-/%!&~^?|()[]{}'\"@#$` \t\r\n"; +static v0 language_highlight_common (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+*-/%!&~^?|()[]{}'\"@#$` \t\r\n"; - syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); - syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); - syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|@#$`", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); + syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); + + syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); + syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|@#$`", "", '\0', language->operator_colour, language->operator_effect); + + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); } diff --git a/xanguage/d.h b/xanguage/d.h index 592edcf..030e2d8 100755 --- a/xanguage/d.h +++ b/xanguage/d.h @@ -1,8 +1,8 @@ -static void language_highlight_d (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%!&~^?|@()[]{}'\"` \t\r\n"; +static v0 language_highlight_d (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%!&~^?|@()[]{}'\"` \t\r\n"; - char * keywords [] = { - "abstract", "alias", "align", "asm", "assert", "auto", "body", "bool", + c1 * keywords [] = { + "abstract", "alias", "align", "asm", "assert", "auto", "body", "b4", "break", "byte", "case", "cast", "catch", "cdouble", "cent", "cfloat", "char", "class", "const", "continue", "creal", "dchar", "debug", "default", "delegate", "delete", "deprecated", "do", "double", "else", "enum", "export", @@ -14,13 +14,13 @@ static void language_highlight_d (language_structure * language, syntax_structur "return", "scope", "shared", "short", "static", "struct", "super", "switch", "synchronized", "template", "this", "throw", "true", "try", "typeid", "typeof", "ubyte", "ucent", "uint", "ulong", "union", "unittest", "ushort", "version", - "void", "wchar", "while", "foreach_reverse" + "v0", "wchar", "while", "foreach_reverse" }; - char * types [] = { + c1 * types [] = { "byte", "ubyte", "short", "ushort", "int", "uint", "long", "ulong", "cent", "ucent", "char", "wchar", "dchar", "float", "double", "real", - "ifloat", "idouble", "ireal", "cfloat", "cdouble", "creal", "void", "bool", + "ifloat", "idouble", "ireal", "cfloat", "cdouble", "creal", "v0", "b4", "string" }; @@ -31,19 +31,19 @@ static void language_highlight_d (language_structure * language, syntax_structur syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); syntax_define (syntax, false, false, "`", "`", '\0', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (types); ++word) { + for (u8 word = 0; word < array_length (types); ++word) { syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|@", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/eaxhla.h b/xanguage/eaxhla.h index b24065f..2a1e713 100755 --- a/xanguage/eaxhla.h +++ b/xanguage/eaxhla.h @@ -1,19 +1,19 @@ -static void language_highlight_eaxhla (language_structure * language, syntax_structure * syntax) { - char * separators = ".,+-*/[]<>=; \t\r\n"; +static v0 language_highlight_eaxhla (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,+-*/[]<>=; \t\r\n"; - char * declarations [] = { + c1 * declarations [] = { "program", "procedure", "machine", "library", "fast", "unix", "begin", "end", "if", "then", "else", "repeat", "break", "continue", "until", "exit", "fastcall", "shell", "alias", "macro", "scope", "unscope", "use", "include" }; - char * types [] = { - "s8", "s16", "s32", "s64", "u8", "u16", "u32", "u64", - "f32", "f64", "f80", "v0", "s128", "u128", "s256", "u256", + c1 * types [] = { + "s8", "c16", "s32", "s64", "u8", "u16", "u32", "u64", + "f32", "f64", "f80", "v0", "c128", "u128", "s256", "u256", "s512", "u512" }; - char * instructions [] = { + c1 * instructions [] = { "jnpe", "jpo", "jnpo", "jpe", "jnb", "jae", "jnbe", "ja", "jna", "jbe", "jnae", "jb", "jnl", "jge", "jnle", "jg", "jng", "jle", "jnge", "jl", "cmovng", "cmovle", "cmovnge", "cmovl", @@ -34,7 +34,7 @@ static void language_highlight_eaxhla (language_structure * language, syntax_str "bswap", "bsf", "bsr", "loop", "loope", "loopne" }; - char * registers [] = { + c1 * registers [] = { "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", @@ -45,7 +45,7 @@ static void language_highlight_eaxhla (language_structure * language, syntax_str "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }; - int word; + s4 word; syntax_define (syntax, false, false, "#", "\n", '\0', language->comment_colour, language->comment_effect); syntax_define (syntax, false, false, "---", "\n", '\0', language->comment_colour, language->comment_effect); @@ -53,27 +53,27 @@ static void language_highlight_eaxhla (language_structure * language, syntax_str syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (declarations); ++word) { + for (u8 word = 0; word < array_length (declarations); ++word) { syntax_define (syntax, false, true, declarations [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (types); ++word) { + for (u8 word = 0; word < array_length (types); ++word) { syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect); } - for (ulong word = 0; word < array_length (instructions); ++word) { - syntax_define (syntax, false, true, instructions [word], separators, '\0', language->extension_colour, language->extension_effect); + for (u8 word = 0; word < array_length (instructions); ++word) { + syntax_define (syntax, false, true, instructions [word], " \t\n", '\0', language->extension_colour, language->extension_effect); } - for (ulong word = 0; word < array_length (registers); ++word) { + for (u8 word = 0; word < array_length (registers); ++word) { syntax_define (syntax, false, true, registers [word], separators, '\0', language->register_colour, language->register_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,+*-/%$<>=;", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/flat.h b/xanguage/flat.h index 5fb123e..ce1d588 100755 --- a/xanguage/flat.h +++ b/xanguage/flat.h @@ -1,12 +1,12 @@ -static void language_highlight_flat (language_structure * language, syntax_structure * syntax) { - char * separators = ".,+-=:;(){}[]%$<> \t\r\n"; +static v0 language_highlight_flat (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,+-=:;(){}[]%$<> \t\r\n"; - char * declarations [] = { + c1 * declarations [] = { "format", "executable", "readable", "writable", "segment", "sector", "entry", "macro", "db", "dw", "dd", "dq", "rb", "rw", "rd", "rq" }; - char * instructions [] = { + c1 * instructions [] = { "mov", "movabs", "movapd", "movaps", "movebe", "movsd", "movsx", "movzx", "movsxd", "movd", "movq", "movs", "movsb", "movsw", "movsd", "movsq", "cmovmp", "cmovrcxz", "cmovc", "cmovnc", "cmove", "cmovne", "cmovz", "cmovnz", @@ -26,7 +26,7 @@ static void language_highlight_flat (language_structure * language, syntax_struc "rep", "repe", "repz", "repne", "repnz", "loop", "loope", "loopne" }; - char * registers [] = { + c1 * registers [] = { "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", @@ -38,29 +38,29 @@ static void language_highlight_flat (language_structure * language, syntax_struc "ah", "ch", "dh", "bh" }; - int word; + s4 word; syntax_define (syntax, false, false, ";", "\n", '\0', language->comment_colour, language->comment_effect); syntax_define (syntax, false, false, "'", "'", '\\', language->string_colour, language->string_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (declarations); ++word) { + for (u8 word = 0; word < array_length (declarations); ++word) { syntax_define (syntax, false, true, declarations [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (instructions); ++word) { - syntax_define (syntax, false, true, instructions [word], separators, '\0', language->extension_colour, language->extension_effect); + for (u8 word = 0; word < array_length (instructions); ++word) { + syntax_define (syntax, false, true, instructions [word], " \t", '\0', language->extension_colour, language->extension_effect); } - for (ulong word = 0; word < array_length (registers); ++word) { + for (u8 word = 0; word < array_length (registers); ++word) { syntax_define (syntax, false, true, registers [word], separators, '\0', language->register_colour, language->register_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,+-=:;%$<>", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/fortran.h b/xanguage/fortran.h index 45443ae..b598a9f 100755 --- a/xanguage/fortran.h +++ b/xanguage/fortran.h @@ -1,7 +1,7 @@ -static void language_highlight_fortran (language_structure * language, syntax_structure * syntax) { - char * separators = ",:<=>+-*/&()[]\"\' \t\r\n"; +static v0 language_highlight_fortran (language_structure * language, syntax_structure * syntax) { + c1 * separators = ",:<=>+-*/&()[]\"\' \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "allocatable", "allocate", "associate", "backspace", "block", "call", "case", "common", "contains", "cycle", "data", "deallocate", "d0", "do", "else", "elseif", "end", "enddo", "endfile", "endif", "entry", "equivalence", "exit", "external", @@ -12,11 +12,11 @@ static void language_highlight_fortran (language_structure * language, syntax_st "then", "to", "type", "use", "where", "write" }; - char * types [] = { + c1 * types [] = { "character", "integer", "logical", "real", "complex" }; - char * subkeywords [] = { + c1 * commons [] = { ".and.", ".or.", ".not.", ".true.", ".false.", "in", "out", "len", "dimension", "modulo", "advance" }; @@ -25,23 +25,23 @@ static void language_highlight_fortran (language_structure * language, syntax_st syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (subkeywords); ++word) { - syntax_define (syntax, false, true, subkeywords [word], separators, '\0', language->processor_colour, language->processor_effect); + for (u8 word = 0; word < array_length (commons); ++word) { + syntax_define (syntax, false, true, commons [word], separators, '\0', language->processor_colour, language->processor_effect); } - for (ulong word = 0; word < array_length (types); ++word) { + for (u8 word = 0; word < array_length (types); ++word) { syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect); } syntax_define (syntax, true, false, "()[]", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ",:<=>+-*/&", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/go.h b/xanguage/go.h index c2cf3d7..0c6d50e 100755 --- a/xanguage/go.h +++ b/xanguage/go.h @@ -1,20 +1,20 @@ -static void language_highlight_go (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\"` \t\r\n"; +static v0 language_highlight_go (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\"` \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "break", "default", "func", "interface", "select", "case", "defer", "go", "struct", "else", "goto", "package", "switch", "const", "var", "for", "fallthrough", "if", "range", "type", "continue", "import", "return" }; - char * types [] = { + c1 * types [] = { "map", "uint", "int", "uintptr", "uint8", "uint16", "uint32", "uint64", "int8", "int16", "int32", "int64", "float32", "float64", "complex64", "complex128", - "byte", "rune", "string", "chan", "bool" + "byte", "rune", "string", "chan", "b4" }; - char * commons [] = { + c1 * commons [] = { "true", "false", "nil", "err" }; @@ -24,23 +24,23 @@ static void language_highlight_go (language_structure * language, syntax_structu syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); syntax_define (syntax, false, false, "`", "`", '\0', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (types); ++word) { + for (u8 word = 0; word < array_length (types); ++word) { syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect); } - for (ulong word = 0; word < array_length (commons); ++word) { + for (u8 word = 0; word < array_length (commons); ++word) { syntax_define (syntax, false, true, commons [word], separators, '\0', language->extension_colour, language->extension_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/haskell.h b/xanguage/haskell.h index a2c1409..f2d45c5 100755 --- a/xanguage/haskell.h +++ b/xanguage/haskell.h @@ -1,13 +1,13 @@ -static void language_highlight_haskell (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%!@#$&~^?|()[]{}'\" \t\r\n"; +static v0 language_highlight_haskell (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%!@#$&~^?|()[]{}'\" \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "case", "class", "data", "deriving", "do", "else", "if", "import", "in", "infix", "infixl", "infixr", "instance", "let", "of", "module", "newtype", "then", "type", "where" }; - char * types [] = { + c1 * types [] = { "Int", "Integer", "String", "Char", "Float", "Boolean" }; @@ -16,19 +16,19 @@ static void language_highlight_haskell (language_structure * language, syntax_st syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (types); ++word) { + for (u8 word = 0; word < array_length (types); ++word) { syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+*-/%!@#$&~^?|", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/holy_c.h b/xanguage/holy_c.h index 3041453..6062d56 100755 --- a/xanguage/holy_c.h +++ b/xanguage/holy_c.h @@ -1,25 +1,21 @@ -static void language_highlight_holy_c (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n"; -///////////// DOES NOT FUCKING WORK YET - char * keywords [] = { - "auto", "extern", "if", "else", - "do", "while", "for", "switch", "case", "default", "break", - "enum", "union", "struct", "typedef", "goto", "return", "sizeof", "inline", - "restrict", "true", "false" +static v0 language_highlight_holy_c (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%!&~^|()[]{}'\" \t\r\n"; + + c1 * keywords [] = { + "static", "extern", "import", "auto", "public", "sizeof", "asm", "no_warn", + "do", "while", "for", "switch", "case", "default", "start", "end", + "if", "else", "goto", "return", "break", "try", "catch", "throw", + "enum", "union", "class" }; - char * types [] = { - "void", "bool", "off_t", "va_list", "float", "double", "float_t", "double_t", - "char", "short", "int", "long", "uchar", "ushort", "uint", "ulong", - "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", - "signed", "unsigned", "size_t", "ssize_t" + c1 * types [] = { + "U8", "U16", "U32", "U64", "I8", "I16", "I32", "I64", + "U0", "I0", "F64", "Bool" }; - char * commons [] = { - "null", "NULL", "FILE", "DIR", "va_arg", "va_start", "va_end", "va_copy", - "alignas", "alignof", "offsetof", "typeof", "EOF", "ABS", "MIN", "MAX", - "ARRAYSIZE", "SWAP", "UNUSED", "UNREACHABLE", "STRINGIFY", "CONCAT", "assert", "static_assert", - "thread_local", "nullptr" + c1 * commons [] = { + "_extern", "_intern", "_import", "lastclass", "offset", "defined", "lock", "interrupt", + "reg", "noreg", "argpop", "noargpop", "haserrcode", "NULL" }; syntax_define (syntax, false, false, "/*", "*/", '\0', language->comment_colour, language->comment_effect); @@ -28,23 +24,23 @@ static void language_highlight_holy_c (language_structure * language, syntax_str syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (types); ++word) { + for (u8 word = 0; word < array_length (types); ++word) { syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect); } - for (ulong word = 0; word < array_length (commons); ++word) { + for (u8 word = 0; word < array_length (commons); ++word) { syntax_define (syntax, false, true, commons [word], separators, '\0', language->extension_colour, language->extension_effect); } - syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); - syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', language->operator_colour, language->operator_effect); + syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); + syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^|", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/lua.h b/xanguage/lua.h index bceb0fc..0a960ef 100755 --- a/xanguage/lua.h +++ b/xanguage/lua.h @@ -1,17 +1,17 @@ -static void language_highlight_lua (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%~^#|()[]{}'\" \t\r\n"; +static v0 language_highlight_lua (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%~^#|()[]{}'\" \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "and", "break", "do", "else", "elseif", "end", "false", "for", "function", "if", "in", "local", "nil", "not", "or", "until", "repeat", "return", "then", "true", "while" }; - char * types [] = { - "boolean", "number", "string", "userdata", "function", "thread", "table" + c1 * types [] = { + "b4ean", "number", "string", "userdata", "function", "thread", "table" }; - char * commons [] = { + c1 * commons [] = { "require", "print", "seek", "dofile", "loadfile", "assert", "rawset", "rawget", "setfenv", "pairs", "ipairs", "tonumber", "tostring", "foreach", "setn", "getn", "insert", "concat", "sort", "remove", "abs", "ceil", "floor", "log10", @@ -28,23 +28,23 @@ static void language_highlight_lua (language_structure * language, syntax_struct syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (types); ++word) { + for (u8 word = 0; word < array_length (types); ++word) { syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect); } - for (ulong word = 0; word < array_length (commons); ++word) { + for (u8 word = 0; word < array_length (commons); ++word) { syntax_define (syntax, false, true, commons [word], separators, '\0', language->extension_colour, language->extension_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+-*/%~^#|", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/pascal.h b/xanguage/pascal.h index df95763..1b3902a 100755 --- a/xanguage/pascal.h +++ b/xanguage/pascal.h @@ -1,7 +1,7 @@ -static void language_highlight_pascal (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/&@#$%^()[] \t\r\n"; +static v0 language_highlight_pascal (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/&@#$%^()[] \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "absolute", "and", "array", "asm", "begin", "case", "const", "constructor", "destructor", "div", "do", "downto", "else", "end", "file", "for", "function", "goto", "if", "in", "inherited", "inline", "interface", "xor", @@ -16,14 +16,13 @@ static void language_highlight_pascal (language_structure * language, syntax_str syntax_define (syntax, false, false, "{", "}", '\0', language->comment_colour, language->comment_effect); syntax_define (syntax, false, false, "'", "'", '#', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } syntax_define (syntax, true, false, "[]()", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+-*/&@#$%^", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_letters, separators, '\0', language->lowercase_colour, language->lowercase_effect); } diff --git a/xanguage/python.h b/xanguage/python.h index dfea821..3c06a80 100755 --- a/xanguage/python.h +++ b/xanguage/python.h @@ -1,7 +1,7 @@ -static void language_highlight_python (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n"; +static v0 language_highlight_python (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "and", "as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "False", "finally", "for", "from", "global", "if", "import", "in", "is", "labmda", "None", "nonlocal", "not", @@ -9,8 +9,8 @@ static void language_highlight_python (language_structure * language, syntax_str "yield", "async", "await" }; - char * subkeywords [] = { - "abs", "all", "any", "apply", "ascii", "basestring", "bin", "bool", + c1 * commons [] = { + "abs", "all", "any", "apply", "ascii", "basestring", "bin", "b4", "breakpoint", "buffer", "bytearray", "bytes", "callable", "chr", "classmethod", "cmp", "coerce", "compile", "complex", "copyright", "credits", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "execfile", "exit", "file", "filter", "float", @@ -29,19 +29,19 @@ static void language_highlight_python (language_structure * language, syntax_str syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect); syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect); } - for (ulong word = 0; word < array_length (subkeywords); ++word) { - syntax_define (syntax, false, true, subkeywords [word], separators, '\0', language->extension_colour, language->extension_effect); + for (u8 word = 0; word < array_length (commons); ++word) { + syntax_define (syntax, false, true, commons [word], separators, '\0', language->extension_colour, language->extension_effect); } syntax_define (syntax, true, false, "()[]", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); + syntax_define (syntax, true, true, language_digits, separators, '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->lowercase_colour, language->lowercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect); } diff --git a/xanguage/valgrind.h b/xanguage/valgrind.h index 7cfb9cd..16f0507 100755 --- a/xanguage/valgrind.h +++ b/xanguage/valgrind.h @@ -1,8 +1,7 @@ -static void language_highlight_valgrind (language_structure * language, syntax_structure * syntax) { - char * separators = ".,:;<=>+-*/%!&~^?|@#$()[]{}'\" \t\r\n"; +static v0 language_highlight_valgrind (language_structure * language, syntax_structure * syntax) { + c1 * separators = ".,:;<=>+-*/%!&~^?|@#$()[]{}'\" \t\r\n"; - char * titles [] = { - //~"exit", "set", "elif", "done", "in", "then", "function", "fi", + c1 * titles [] = { "HEAP", "LEAK", "ERROR", "SUMMARY" }; @@ -11,15 +10,15 @@ static void language_highlight_valgrind (language_structure * language, syntax_s syntax_define (syntax, false, false, "(", ")", '\0', language->lowercase_colour, language->lowercase_effect); syntax_define (syntax, false, false, "0x", ":", '\0', language->string_colour, language->string_effect); - for (ulong word = 0; word < array_length (titles); ++word) { + for (u8 word = 0; word < array_length (titles); ++word) { syntax_define (syntax, false, true, titles [word], separators, '\0', language->fatal_colour, language->fatal_effect); } syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect); syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|@#$", "", '\0', language->operator_colour, language->operator_effect); - syntax_define (syntax, true, true, "0123456789", ": ()\t\r\n", '\0', language->number_colour, language->number_effect); - syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect); - syntax_define (syntax, true, true, "_", separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, language_digits, ": ()\t\r\n", '\0', language->number_colour, language->number_effect); + syntax_define (syntax, true, true, language_lowercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, language_uppercase, separators, '\0', language->uppercase_colour, language->uppercase_effect); + syntax_define (syntax, true, true, "_", separators, '\0', language->uppercase_colour, language->uppercase_effect); } diff --git a/xaptor.c b/xaptor.c index 321db38..680c710 100644 --- a/xaptor.c +++ b/xaptor.c @@ -10,14 +10,14 @@ #include #include -int main (void) { +s4 main (v0) { cross_structure * cross = cross_initialize (30, 3); ui_structure * ui = ui_initialize (cross); cross_configure (cross, 640, 480, "Xaptor - File Manager"); while (cross->active == true) { - uint offset = 48; + u4 offset = 48; cross_synchronize (cross, 0x00000000); diff --git a/xaptor.h b/xaptor.h index 5315144..bf97594 100644 --- a/xaptor.h +++ b/xaptor.h @@ -29,38 +29,38 @@ typedef struct { Atom atom_close_button; Atom atom_transparency; - bool signal [signal_count]; - bool cursor [cursor_count]; - int cursor_x; - int cursor_y; - - uint gameplay_framerate; - uint animation_framerate; - uint window_width; - uint window_height; - bool active; - uint framerate; - ulong frame_time; - ulong frame_begin; - ulong frame_end; - uint * framebuffer; - uint global_tick; - uint gameplay_tick; - uint animation_tick; - uint tab_width; - uint sprite_count; - uint font_count; - uint * * sprite_data; - uint * sprite_width; - uint * sprite_height; - uint * * font_index; - uint * * font_width; - uint * * font_height; - char * font_begin; - char * font_end; + b4 signal [signal_count]; + b4 cursor [cursor_count]; + s4 cursor_x; + s4 cursor_y; + + u4 gameplay_framerate; + u4 animation_framerate; + u4 window_width; + u4 window_height; + b4 active; + u4 framerate; + u8 frame_time; + u8 frame_begin; + u8 frame_end; + u4 * framebuffer; + u4 global_tick; + u4 gameplay_tick; + u4 animation_tick; + u4 tab_width; + u4 sprite_count; + u4 font_count; + u4 * * sprite_data; + u4 * sprite_width; + u4 * sprite_height; + u4 * * font_index; + u4 * * font_width; + u4 * * font_height; + c1 * font_begin; + c1 * font_end; } raptor_structure; -static raptor_structure * raptor_initialize (uint gameplay_framerate, uint animation_framerate) { +static raptor_structure * raptor_initialize (u4 gameplay_framerate, u4 animation_framerate) { raptor_structure * raptor = allocate (sizeof (* raptor)); raptor->gameplay_framerate = gameplay_framerate; @@ -71,11 +71,11 @@ static raptor_structure * raptor_initialize (uint gameplay_framerate, uint anima } static raptor_structure * raptor_deinitialize (raptor_structure * raptor) { - for (uint index = 0; index < raptor->sprite_count; ++index) { + for (u4 index = 0; index < raptor->sprite_count; ++index) { raptor->sprite_data [index] = deallocate (raptor->sprite_data [index]); } - for (uint index = 0; index < raptor->font_count; ++index) { + for (u4 index = 0; index < raptor->font_count; ++index) { raptor->font_index [index] = deallocate (raptor->font_index [index]); raptor->font_width [index] = deallocate (raptor->font_width [index]); raptor->font_height [index] = deallocate (raptor->font_height [index]); @@ -105,7 +105,7 @@ static raptor_structure * raptor_deinitialize (raptor_structure * raptor) { return (deallocate (raptor)); } -static uint raptor_sprite_raw_import (raptor_structure * raptor, uint * data, uint width, uint height) { +static u4 raptor_sprite_raw_import (raptor_structure * raptor, u4 * data, u4 width, u4 height) { ++raptor->sprite_count; raptor->sprite_data = reallocate (raptor->sprite_data, raptor->sprite_count * sizeof (* raptor->sprite_data)); @@ -119,13 +119,13 @@ static uint raptor_sprite_raw_import (raptor_structure * raptor, uint * data, ui return (raptor->sprite_count - 1); } -static uint raptor_font_raw_import (raptor_structure * raptor, uint * data, uint image_width, char begin, char end, uint separator_colour) { - uint pointer = 0; - uint width = 0; - uint height = 0; - uint * buffer = null; +static u4 raptor_font_raw_import (raptor_structure * raptor, u4 * data, u4 image_width, c1 begin, c1 end, u4 separator_colour) { + u4 pointer = 0; + u4 width = 0; + u4 height = 0; + u4 * buffer = null; - uint current = raptor->font_count; + u4 current = raptor->font_count; ++raptor->font_count; @@ -138,19 +138,19 @@ static uint raptor_font_raw_import (raptor_structure * raptor, uint * data, uint raptor->font_begin [current] = begin; raptor->font_end [current] = end; - raptor->font_index [current] = allocate ((ulong) (end - begin + 1) * sizeof (* * raptor->font_index)); - raptor->font_width [current] = allocate ((ulong) (end - begin + 1) * sizeof (* * raptor->font_width)); - raptor->font_height [current] = allocate ((ulong) (end - begin + 1) * sizeof (* * raptor->font_height)); + raptor->font_index [current] = allocate ((u8) (end - begin + 1) * sizeof (* * raptor->font_index)); + raptor->font_width [current] = allocate ((u8) (end - begin + 1) * sizeof (* * raptor->font_width)); + raptor->font_height [current] = allocate ((u8) (end - begin + 1) * sizeof (* * raptor->font_height)); - for (char index = begin; index <= end; ++index) { + for (c1 index = begin; index <= end; ++index) { for ( ; data [pointer] == separator_colour; ++pointer); for (width = 0; data [pointer + width] != separator_colour; ++width); for (height = 0; data [pointer + height * image_width] != separator_colour; ++height); buffer = allocate (width * height * sizeof (* buffer)); - for (uint y = 0; y < height; ++y) { - for (uint x = 0; x < width; ++x) { + for (u4 y = 0; y < height; ++y) { + for (u4 x = 0; x < width; ++x) { buffer [y * width + x] = data [pointer + (y * image_width) + x]; } } @@ -171,21 +171,21 @@ static uint raptor_font_raw_import (raptor_structure * raptor, uint * data, uint return (current); } -static uint raptor_sprite_import (raptor_structure * raptor, char * path) { - uint width = 0; - uint height = 0; - uint * data = null; +static u4 raptor_sprite_import (raptor_structure * raptor, c1 * path) { + u4 width = 0; + u4 height = 0; + u4 * data = null; data = format_image_import (path, & width, & height); return (raptor_sprite_raw_import (raptor, data, width, height)); } -static uint raptor_font_import (raptor_structure * raptor, char * path, char begin, char end, uint colour) { - uint width = 0; - uint height = 0; - uint result = 0; - uint * data = null; +static u4 raptor_font_import (raptor_structure * raptor, c1 * path, c1 begin, c1 end, u4 colour) { + u4 width = 0; + u4 height = 0; + u4 result = 0; + u4 * data = null; data = format_image_import (path, & width, & height); @@ -196,43 +196,43 @@ static uint raptor_font_import (raptor_structure * raptor, char * path, char beg return (result); } -static uint raptor_sprite_width (raptor_structure * raptor, uint sprite) { +static u4 raptor_sprite_width (raptor_structure * raptor, u4 sprite) { return (raptor->sprite_width [sprite]); } -static uint raptor_sprite_height (raptor_structure * raptor, uint sprite) { +static u4 raptor_sprite_height (raptor_structure * raptor, u4 sprite) { return (raptor->sprite_height [sprite]); } -static uint raptor_character_width (raptor_structure * raptor, char character, uint font, float scale) { +static u4 raptor_character_width (raptor_structure * raptor, c1 character, u4 font, f4 scale) { if ((character < raptor->font_begin [font]) || (character > raptor->font_end [font])) { return (0); } else { - uint index = raptor->font_index [font] [character - raptor->font_begin [font]]; + u4 index = raptor->font_index [font] [character - raptor->font_begin [font]]; - return ((uint) (scale * (float) raptor->sprite_width [index])); + return ((u4) (scale * (float) raptor->sprite_width [index])); } } -static uint raptor_character_height (raptor_structure * raptor, char character, uint font, float scale) { +static u4 raptor_character_height (raptor_structure * raptor, c1 character, u4 font, f4 scale) { if ((character < raptor->font_begin [font]) || (character > raptor->font_end [font])) { return (0); } else { - uint index = raptor->font_index [font] [character - raptor->font_begin [font]]; + u4 index = raptor->font_index [font] [character - raptor->font_begin [font]]; - return ((uint) (scale * (float) raptor->sprite_height [index])); + return ((u4) (scale * (float) raptor->sprite_height [index])); } } -static uint raptor_string_width (raptor_structure * raptor, char * string, uint font, float scale) { - uint width = 0; - uint match = 0; +static u4 raptor_string_width (raptor_structure * raptor, c1 * string, u4 font, f4 scale) { + u4 width = 0; + u4 match = 0; if (string == null) { return (0); } - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { if (string [index] == '\t') { width += raptor->tab_width * raptor_character_width (raptor, ' ', font, scale); } else if (string [index] == '\n') { @@ -246,14 +246,14 @@ static uint raptor_string_width (raptor_structure * raptor, char * string, uint return (maximum (width, match)); } -static uint raptor_string_height (raptor_structure * raptor, char * string, uint font, float scale) { - uint height = raptor_character_height (raptor, ' ', font, scale); +static u4 raptor_string_height (raptor_structure * raptor, c1 * string, u4 font, f4 scale) { + u4 height = raptor_character_height (raptor, ' ', font, scale); if ((string == null) || (string [0] == '\0')) { return (0); } - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { if (string [index] == '\n') { height += raptor_character_height (raptor, ' ', font, scale); } @@ -262,22 +262,22 @@ static uint raptor_string_height (raptor_structure * raptor, char * string, uint return (height); } -static uint raptor_center_x (raptor_structure * raptor, uint size) { +static u4 raptor_center_x (raptor_structure * raptor, u4 size) { return ((raptor->window_width - size) / 2); } -static uint raptor_center_y (raptor_structure * raptor, uint size) { +static u4 raptor_center_y (raptor_structure * raptor, u4 size) { return ((raptor->window_height - size) / 2); } -static bool raptor_cursor_inside (raptor_structure * raptor, int x, int y, uint width, uint height) { +static b4 raptor_cursor_inside (raptor_structure * raptor, s4 x, s4 y, u4 width, u4 height) { return ((raptor->cursor_x > x) && (raptor->cursor_y > y) && (raptor->cursor_x < x + (int) width) && (raptor->cursor_y < y + (int) height)); } -static bool raptor_cursor_left_click (raptor_structure * raptor, int x, int y, uint width, uint height) { +static b4 raptor_cursor_left_click (raptor_structure * raptor, s4 x, s4 y, u4 width, u4 height) { if (raptor->cursor [cursor_left] == true) { return (raptor_cursor_inside (raptor, x, y, width, height) == true); } @@ -285,7 +285,7 @@ static bool raptor_cursor_left_click (raptor_structure * raptor, int x, int y, u return (false); } -static bool raptor_cursor_right_click (raptor_structure * raptor, int x, int y, uint width, uint height) { +static b4 raptor_cursor_right_click (raptor_structure * raptor, s4 x, s4 y, u4 width, u4 height) { if (raptor->cursor [cursor_right] == true) { return (raptor_cursor_inside (raptor, x, y, width, height)); } @@ -293,8 +293,8 @@ static bool raptor_cursor_right_click (raptor_structure * raptor, int x, int y, return (false); } -static void raptor_configure (raptor_structure * raptor, uint window_width, uint window_height, char * window_title) { - ulong font_bitmap [2 * 95] = { +static v0 raptor_configure (raptor_structure * raptor, u4 window_width, u4 window_height, c1 * window_title) { + u8 font_bitmap [2 * 95] = { 0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000, 0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000, 0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000, @@ -331,9 +331,9 @@ static void raptor_configure (raptor_structure * raptor, uint window_width, uint XSetWindowAttributes window_attributes; - uint * dumb_buffer = allocate (256 * sizeof (* dumb_buffer)); + u4 * dumb_buffer = allocate (256 * sizeof (* dumb_buffer)); - for (uint index = 0; index < 256; ++index) { + for (u4 index = 0; index < 256; ++index) { dumb_buffer [index] = 0xffffffff; } @@ -352,13 +352,13 @@ static void raptor_configure (raptor_structure * raptor, uint window_width, uint raptor->font_width [raptor->font_count - 1] = allocate (95 * sizeof (* * raptor->font_width)); raptor->font_height [raptor->font_count - 1] = allocate (95 * sizeof (* * raptor->font_height)); - for (uint index = 0; index < 95; ++index) { - uint * buffer = allocate (8 * 16 * sizeof (* buffer)); + for (u4 index = 0; index < 95; ++index) { + u4 * buffer = allocate (8 * 16 * sizeof (* buffer)); - for (uint value = 0; value < 2; ++value) { - for (uint bit = 64; bit > 0; --bit) { - uint destination = ((value << 3) - ((bit - 1) >> 3) + 7) * 8 - ((bit - 1) & 7) + 7; - uint source = (font_bitmap [2 * index + value] >> (bit - 1)) & 1; + for (u4 value = 0; value < 2; ++value) { + for (u4 bit = 64; bit > 0; --bit) { + u4 destination = ((value << 3) - ((bit - 1) >> 3) + 7) * 8 - ((bit - 1) & 7) + 7; + u4 source = (font_bitmap [2 * index + value] >> (bit - 1)) & 1; buffer [destination] = (source) ? 0xffffffff : 0x00000000; } @@ -376,7 +376,7 @@ static void raptor_configure (raptor_structure * raptor, uint window_width, uint raptor->display = XOpenDisplay (null); - int screen = DefaultScreen (raptor->display); + s4 screen = DefaultScreen (raptor->display); XMatchVisualInfo (raptor->display, screen, 32, TrueColor, & raptor->visual); @@ -417,39 +417,39 @@ static void raptor_configure (raptor_structure * raptor, uint window_width, uint raptor->frame_begin = nano_time (); } -static void raptor_render_base (raptor_structure * raptor, uint sprite, int x, int y, uint u, uint v, uint width, uint height, float scale_x, - float scale_y, int flip_x, int flip_y, uint upper_left, uint upper_right, uint lower_left, uint lower_right) { - (void) scale_x; - (void) scale_y; - (void) flip_x; - (void) flip_y; +static v0 raptor_render_base (raptor_structure * raptor, u4 sprite, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height, f4 scale_x, + f4 scale_y, s4 flip_x, s4 flip_y, u4 upper_left, u4 upper_right, u4 lower_left, u4 lower_right) { + (v0) scale_x; + (v0) scale_y; + (v0) flip_x; + (v0) flip_y; /// FIX TO INTERPOLATE ALL 4 COLOURS - //~(void) upper_left; - (void) upper_right; - (void) lower_left; - (void) lower_right; + //~(v0) upper_left; + (v0) upper_right; + (v0) lower_left; + (v0) lower_right; - uint interpolate_pixels (uint pixel, uint modifier) { - uint r = (((pixel & 0xff000000) >> 24) * ((modifier & 0x000000ff) >> 0)) / 0xff; - uint g = (((pixel & 0x00ff0000) >> 16) * ((modifier & 0x0000ff00) >> 8)) / 0xff; - uint b = (((pixel & 0x0000ff00) >> 8) * ((modifier & 0x00ff0000) >> 16)) / 0xff; - uint a = (((pixel & 0x000000ff) >> 0) * ((modifier & 0xff000000) >> 24)) / 0xff; + u4 interpolate_pixels (u4 pixel, u4 modifier) { + u4 r = (((pixel & 0xff000000) >> 24) * ((modifier & 0x000000ff) >> 0)) / 0xff; + u4 g = (((pixel & 0x00ff0000) >> 16) * ((modifier & 0x0000ff00) >> 8)) / 0xff; + u4 b = (((pixel & 0x0000ff00) >> 8) * ((modifier & 0x00ff0000) >> 16)) / 0xff; + u4 a = (((pixel & 0x000000ff) >> 0) * ((modifier & 0xff000000) >> 24)) / 0xff; return ((r << 24) | (g << 16) | (b << 8) | a); } if ((x + (int) width < 0) || (y + (int) height < 0) || (x > (int) raptor->window_width) || (y > (int) raptor->window_height)) return; - for (uint vertical = 0; vertical < height; ++vertical) { + for (u4 vertical = 0; vertical < height; ++vertical) { if (vertical + y >= raptor->window_height) break; if (vertical + v >= raptor->sprite_height [sprite]) break; - for (uint horizontal = 0; horizontal < width; ++horizontal) { + for (u4 horizontal = 0; horizontal < width; ++horizontal) { if (horizontal + x >= raptor->window_width) break; if (horizontal + u >= raptor->sprite_width [sprite]) break; - uint pixel = raptor->sprite_data [sprite] [(vertical + v) * raptor->sprite_width [sprite] + horizontal + u]; - uint at = (y + vertical) * raptor->window_width + (x + horizontal); + u4 pixel = raptor->sprite_data [sprite] [(vertical + v) * raptor->sprite_width [sprite] + horizontal + u]; + u4 at = (y + vertical) * raptor->window_width + (x + horizontal); raptor->framebuffer [at] = (((pixel & 0xff000000) >> 24) > 0x77) ? interpolate_pixels (pixel, upper_left) @@ -458,76 +458,76 @@ static void raptor_render_base (raptor_structure * raptor, uint sprite, int x, i } } -static void raptor_render_rectangle (raptor_structure * raptor, int x, int y, uint width, uint height, uint colour) { +static v0 raptor_render_rectangle (raptor_structure * raptor, s4 x, s4 y, u4 width, u4 height, u4 colour) { raptor_render_base (raptor, raptor->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16, (float) height / 16, 0, 0, colour, colour, colour, colour); } -static void raptor_render_sprite (raptor_structure * raptor, uint sprite, int x, int y) { - uint width = raptor->sprite_width [sprite]; - uint height = raptor->sprite_height [sprite]; +static v0 raptor_render_sprite (raptor_structure * raptor, u4 sprite, s4 x, s4 y) { + u4 width = raptor->sprite_width [sprite]; + u4 height = raptor->sprite_height [sprite]; raptor_render_base (raptor, sprite, x, y, 0, 0, width, height, 1.0f, 1.0f, 0, 0, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void raptor_render_sprite_scale (raptor_structure * raptor, uint sprite, int x, int y, float scale_x, float scale_y) { - uint width = raptor->sprite_width [sprite]; - uint height = raptor->sprite_height [sprite]; +static v0 raptor_render_sprite_scale (raptor_structure * raptor, u4 sprite, s4 x, s4 y, f4 scale_x, f4 scale_y) { + u4 width = raptor->sprite_width [sprite]; + u4 height = raptor->sprite_height [sprite]; raptor_render_base (raptor, sprite, x, y, 0, 0, width, height, scale_x, scale_y, 0, 0, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void raptor_render_sprite_crop (raptor_structure * raptor, uint sprite, int x, int y, uint u, uint v, uint width, uint height) { +static v0 raptor_render_sprite_crop (raptor_structure * raptor, u4 sprite, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height) { raptor_render_base (raptor, sprite, x, y, u, v, width, height, 1.0f, 1.0f, 0, 0, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void raptor_render_sprite_colour (raptor_structure * raptor, uint sprite, uint colour, int x, int y) { - uint width = raptor->sprite_width [sprite]; - uint height = raptor->sprite_height [sprite]; +static v0 raptor_render_sprite_colour (raptor_structure * raptor, u4 sprite, u4 colour, s4 x, s4 y) { + u4 width = raptor->sprite_width [sprite]; + u4 height = raptor->sprite_height [sprite]; raptor_render_base (raptor, sprite, x, y, 0, 0, width, height, 1.0f, 1.0f, 0, 0, colour, colour, colour, colour); } -static void raptor_render_sprite_crop_colour (raptor_structure * raptor, uint sprite, uint colour, int x, int y, uint u, uint v, uint width, uint height) { +static v0 raptor_render_sprite_crop_colour (raptor_structure * raptor, u4 sprite, u4 colour, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height) { raptor_render_base (raptor, sprite, x, y, u, v, width, height, 1.0f, 1.0f, 0, 0, colour, colour, colour, colour); } -static void raptor_render_sprite_flip (raptor_structure * raptor, uint sprite, int x, int y, int flip_x, int flip_y) { - uint width = raptor->sprite_width [sprite]; - uint height = raptor->sprite_height [sprite]; +static v0 raptor_render_sprite_flip (raptor_structure * raptor, u4 sprite, s4 x, s4 y, s4 flip_x, s4 flip_y) { + u4 width = raptor->sprite_width [sprite]; + u4 height = raptor->sprite_height [sprite]; raptor_render_base (raptor, sprite, x, y, 0, 0, width, height, 1.0f, 1.0f, flip_x, flip_y, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void raptor_render_sprite_animate (raptor_structure * raptor, uint sprite, int x, int y, uint frames, uint state, uint states) { - uint width = raptor->sprite_width [sprite] / states; - uint height = raptor->sprite_height [sprite] / frames; +static v0 raptor_render_sprite_animate (raptor_structure * raptor, u4 sprite, s4 x, s4 y, u4 frames, u4 state, u4 states) { + u4 width = raptor->sprite_width [sprite] / states; + u4 height = raptor->sprite_height [sprite] / frames; - uint u = width * (state % states); - uint v = height * (raptor->animation_tick % frames); + u4 u = width * (state % states); + u4 v = height * (raptor->animation_tick % frames); raptor_render_sprite_crop (raptor, sprite, x, y, u, v, width, height); } -static void raptor_render_character (raptor_structure * raptor, char character, uint font, int x, int y, float scale, uint colour) { +static v0 raptor_render_character (raptor_structure * raptor, c1 character, u4 font, s4 x, s4 y, f4 scale, u4 colour) { if ((character < raptor->font_begin [font]) || (character > raptor->font_end [font])) return; - uint index = raptor->font_index [font] [character - raptor->font_begin [font]]; + u4 index = raptor->font_index [font] [character - raptor->font_begin [font]]; - uint width = raptor->sprite_width [index]; - uint height = raptor->sprite_height [index]; + u4 width = raptor->sprite_width [index]; + u4 height = raptor->sprite_height [index]; raptor_render_base (raptor, index, x, y, 0, 0, width, height, scale, scale, 0, 0, colour, colour, colour, colour); } -static void raptor_render_string (raptor_structure * raptor, char * string, uint font, int x, int y, float scale, uint colour) { - int offset = x; +static v0 raptor_render_string (raptor_structure * raptor, c1 * string, u4 font, s4 x, s4 y, f4 scale, u4 colour) { + s4 offset = x; if (string == null) return; - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { if (string [index] == '\t') { x += raptor->tab_width * raptor_character_width (raptor, ' ', font, scale); continue; @@ -543,12 +543,12 @@ static void raptor_render_string (raptor_structure * raptor, char * string, uint } } -static void raptor_render_framerate (raptor_structure * raptor, uint font, int x, int y, float scale, uint colour) { +static v0 raptor_render_framerate (raptor_structure * raptor, u4 font, s4 x, s4 y, f4 scale, u4 colour) { raptor_render_string (raptor, number_to_string (raptor->framerate), font, x, y, scale, colour); } -static void raptor_synchronize (raptor_structure * raptor, uint clear_colour) { - uint signal_code [signal_count] = { +static v0 raptor_synchronize (raptor_structure * raptor, u4 clear_colour) { + u4 signal_code [signal_count] = { 0, 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14, @@ -559,21 +559,21 @@ static void raptor_synchronize (raptor_structure * raptor, uint clear_colour) { 85, 79, 80, 81 }; - uint new_window_width = raptor->window_width; - uint new_window_height = raptor->window_height; + u4 new_window_width = raptor->window_width; + u4 new_window_height = raptor->window_height; XEvent event = { 0 }; //~Window root_window = { 0 }; - //~int root_x = 0; - //~int root_y = 0; - //~uint mask = 0; + //~s4 root_x = 0; + //~s4 root_y = 0; + //~u4 mask = 0; - for (uint index = 0; index < cursor_count; ++index) { + for (u4 index = 0; index < cursor_count; ++index) { raptor->cursor [index] = false; } - for (uint index = 0; index < signal_count; ++index) { + for (u4 index = 0; index < signal_count; ++index) { raptor->signal [index] = false; } @@ -603,7 +603,7 @@ static void raptor_synchronize (raptor_structure * raptor, uint clear_colour) { raptor->cursor_y = event.xbutton.y; } break; case (KeyPress): { - for (uint index = 0; index < signal_count; ++index) { + for (u4 index = 0; index < signal_count; ++index) { if (event.xkey.keycode == signal_code [index]) { raptor->signal [index] = true; } @@ -615,14 +615,14 @@ static void raptor_synchronize (raptor_structure * raptor, uint clear_colour) { } break; } - for (uint pixel = 0; pixel < raptor->window_width * raptor->window_height; ++pixel) { - uint r = (raptor->framebuffer [pixel] & 0x00ff0000) >> 16; - uint b = (raptor->framebuffer [pixel] & 0x000000ff) << 16; + for (u4 pixel = 0; pixel < raptor->window_width * raptor->window_height; ++pixel) { + u4 r = (raptor->framebuffer [pixel] & 0x00ff0000) >> 16; + u4 b = (raptor->framebuffer [pixel] & 0x000000ff) << 16; raptor->framebuffer [pixel] = (raptor->framebuffer [pixel] & 0xff00ff00) | b | r; } - raptor->image = XCreateImage (raptor->display, raptor->visual.visual, raptor->visual.depth, ZPixmap, 0, (char *) raptor->framebuffer, + raptor->image = XCreateImage (raptor->display, raptor->visual.visual, raptor->visual.depth, ZPixmap, 0, (c1 *) raptor->framebuffer, raptor->window_width, raptor->window_height, 32, 0); XPutImage (raptor->display, raptor->pixmap, raptor->context, raptor->image, 0, 0, 0, 0, raptor->window_width, raptor->window_height); @@ -644,7 +644,7 @@ static void raptor_synchronize (raptor_structure * raptor, uint clear_colour) { clear_colour = colour_channel_reverse (clear_colour); - for (uint pixel = 0; pixel < raptor->window_width * raptor->window_height; ++pixel) { + for (u4 pixel = 0; pixel < raptor->window_width * raptor->window_height; ++pixel) { raptor->framebuffer [pixel] = clear_colour; } @@ -657,7 +657,7 @@ static void raptor_synchronize (raptor_structure * raptor, uint clear_colour) { } if (raptor->global_tick % raptor->gameplay_framerate == 0) { - raptor->framerate = (uint) (1000000000ul / raptor->frame_time); + raptor->framerate = (u4) (1000000000ul / raptor->frame_time); } ++raptor->global_tick; @@ -672,8 +672,8 @@ static void raptor_synchronize (raptor_structure * raptor, uint clear_colour) { ////////////// MOVE ME PLEASE -static void raptor_render_rectangle_vertical_gradient (raptor_structure * raptor, int x, int y, uint width, uint height, uint colour_up, - uint colour_down) { +static v0 raptor_render_rectangle_vertical_gradient (raptor_structure * raptor, s4 x, s4 y, u4 width, u4 height, u4 colour_up, + u4 colour_down) { raptor_render_base (raptor, raptor->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16.0f, (float) height / 16.0f, 0, 0, colour_up, colour_up, colour_down, colour_down); } diff --git a/xarbon.c b/xarbon.c index cdabfda..5948e5f 100755 --- a/xarbon.c +++ b/xarbon.c @@ -20,20 +20,20 @@ #include #include -static uint background = 0xff181818; -static uint foreground = 0xffcccccc; -static uint font_width = 8; -static uint font_height = 16; -static uint tab_width = 8; -static uint render_border = 10; - -static uint * render_image = null; -static uint render_width = 0; -static uint render_height = 0; -static uint line_number = 0; -static uint line_digits = 0; - -static void conditionally_exit (language_structure * language, syntax_structure * syntax, bool terminate) { +static u4 background = 0xff181818; +static u4 foreground = 0xffcccccc; +static u4 font_width = 8; +static u4 font_height = 16; +static u4 tab_width = 8; +static u4 render_border = 10; + +static u4 * render_image = null; +static u4 render_width = 0; +static u4 render_height = 0; +static u4 line_number = 0; +static u4 line_digits = 0; + +static v0 conditionally_exit (language_structure * language, syntax_structure * syntax, b4 terminate) { syntax = syntax_deinitialize (syntax); language = language_deinitialize (language); @@ -42,13 +42,13 @@ static void conditionally_exit (language_structure * language, syntax_structure } } -static void print_common (void) { +static v0 print_common (v0) { print ("/B/4xarbon/-: /4Source code PNG renderer/-\n\n"); print ("\tAuthor: /4Ognjen 'xolatile' Milan Robovic/-\n"); print ("\tLicense: /4GNU//GPLv3/-\n\n"); } -static void print_help (void) { +static v0 print_help (v0) { print_common (); print ("Example usage:\n\n"); @@ -58,7 +58,7 @@ static void print_help (void) { print ("Supported languages:\n\n"); for (language_enumeration index = 0; index < language_count; ++index) { - char align [32] = ""; + c1 align [32] = ""; print ("\t/B/4%s/- /4%s/- /0---/- %s syntax highlighting\n", language_short_option [index], @@ -67,15 +67,15 @@ static void print_help (void) { } } -static void print_version (void) { +static v0 print_version (v0) { print_common (); print ("\tVersion: /40 (Zero)/-\n"); } -static uint fetch_width (char * data) { - uint image_width = 0; - uint count = 0; +static u4 fetch_width (c1 * data) { + u4 image_width = 0; + u4 count = 0; do { if (* data == '\t') { @@ -91,9 +91,9 @@ static uint fetch_width (char * data) { return (image_width - 1); } -static uint fetch_height (char * data) { - uint image_height = 0; - uint count = 0; +static u4 fetch_height (c1 * data) { + u4 image_height = 0; + u4 count = 0; do { if (* data == '\n') { @@ -112,8 +112,8 @@ static uint fetch_height (char * data) { return (image_height + 1); } -static void render_character (char character, uint * x, uint * y, uint colour) { - ulong glyphmap [192] = { +static v0 render_character (c1 character, u4 * x, u4 * y, u4 colour) { + u8 glyphmap [192] = { 0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000, 0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000, 0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000, @@ -148,10 +148,10 @@ static void render_character (char character, uint * x, uint * y, uint colour) { 0x0000300808080408, 0x0808083000000000, 0x000000000062928c, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000 }; - for (ulong index = 0; index < 2; ++index) { - for (ulong bit = 64; bit > 0; --bit) { - ulong destination = (* y + (index << 3) - ((bit - 1) >> 3) + 7) * render_width + (* x - ((bit - 1) & 7) + 7); - ulong source = (glyphmap [2 * (ulong) (character - ' ') + index] >> (bit - 1)) & 1; + for (u8 index = 0; index < 2; ++index) { + for (u8 bit = 64; bit > 0; --bit) { + u8 destination = (* y + (index << 3) - ((bit - 1) >> 3) + 7) * render_width + (* x - ((bit - 1) & 7) + 7); + u8 source = (glyphmap [2 * (u8) (character - ' ') + index] >> (bit - 1)) & 1; render_image [destination] = (source) ? colour : background; } @@ -160,8 +160,8 @@ static void render_character (char character, uint * x, uint * y, uint colour) { * x += font_width; } -static void render_string (char * string, uint length, uint * x, uint * y, uint colour) { - for (uint offset = 0; offset < length; ++offset) { +static v0 render_string (c1 * string, u4 length, u4 * x, u4 * y, u4 colour) { + for (u4 offset = 0; offset < length; ++offset) { if (string [offset] == '\t') { * x += font_width * tab_width; } else if (string [offset] == '\n') { @@ -178,19 +178,19 @@ static void render_string (char * string, uint length, uint * x, uint * y, uint } } -int main (int argc, char * * argv) { - uint select = language_count; - uint offset = 0; - uint length = 0; - uint x = render_border; - uint y = render_border; - char * buffer = null; - char * dump = null; +s4 main (s4 argc, c1 * * argv) { + u4 select = language_count; + u4 offset = 0; + u4 length = 0; + u4 x = render_border; + u4 y = render_border; + c1 * buffer = null; + c1 * dump = null; syntax_structure * syntax = syntax_initialize (666); language_structure * language = language_initialize (true); - for (int argument = 1; argument < argc; ++argument) { + for (s4 argument = 1; argument < argc; ++argument) { if (argument_compare (argv [argument], "-h", "--help") == true) { print_help (); conditionally_exit (language, syntax, true); @@ -207,7 +207,7 @@ int main (int argc, char * * argv) { continue; } - for (uint index = 0; index < language_count; ++index) { + for (u4 index = 0; index < language_count; ++index) { if (argument_compare (argv [argument], language_short_option [index], language_long_option [index]) == true) { (* (language_highlighter [index])) (language, syntax); select = index; @@ -217,7 +217,7 @@ int main (int argc, char * * argv) { if (file_exists (argv [argument]) == true) { if (select == language_count) { - select = (uint) file_type (argv [argument]); + select = (u4) file_type (argv [argument]); } if (buffer == null) { buffer = file_import (argv [argument]); @@ -260,7 +260,7 @@ int main (int argc, char * * argv) { for (offset = 0; buffer [offset] != '\0'; offset += length) { select = syntax_select (syntax, & buffer [offset], & length); - render_string (& buffer [offset], length, & x, & y, (select >= syntax->count) ? background : (uint) syntax->colour [select]); + render_string (& buffer [offset], length, & x, & y, (select >= syntax->count) ? background : (u4) syntax->colour [select]); } png_image_export (dump, render_image, render_width, render_height); diff --git a/xarticle.h b/xarticle.h index 54beeb8..9f63a0b 100644 --- a/xarticle.h +++ b/xarticle.h @@ -16,18 +16,18 @@ /// for more details, if you dare, it is a lot of text that nobody wants to read... typedef struct { - uint count; - uint limit; - uint * sprite; - float * life; - uint * colour_in; - uint * colour_out; + u4 count; + u4 limit; + u4 * sprite; + f4 * life; + u4 * colour_in; + u4 * colour_out; vector_3 * * position; vector_3 * * target; vector_3 * * speed; } particle_structure; -static particle_structure * particle_initialize (uint limit) { +static particle_structure * particle_initialize (u4 limit) { particle_structure * particle = allocate (sizeof (* particle)); particle->limit = limit; @@ -40,7 +40,7 @@ static particle_structure * particle_initialize (uint limit) { particle->target = allocate (limit * sizeof (* particle->target)); particle->speed = allocate (limit * sizeof (* particle->speed)); - for (uint index = 0; index < limit; ++index) { + for (u4 index = 0; index < limit; ++index) { particle->life [index] = 0.0f; particle->position [index] = allocate (sizeof (* * particle->position)); @@ -56,7 +56,7 @@ static particle_structure * particle_initialize (uint limit) { } static particle_structure * particle_deinitialize (particle_structure * particle) { - for (uint index = 0; index < particle->count; ++index) { + for (u4 index = 0; index < particle->count; ++index) { particle->position [index] = deallocate (particle->position [index]); particle->target [index] = deallocate (particle->target [index]); particle->speed [index] = deallocate (particle->speed [index]); @@ -73,13 +73,13 @@ static particle_structure * particle_deinitialize (particle_structure * particle return (deallocate (particle)); } -static void particle_append (particle_structure * particle, uint sprite, float life, uint colour_in, uint colour_out, vector_3 * position, +static v0 particle_append (particle_structure * particle, u4 sprite, f4 life, u4 colour_in, u4 colour_out, vector_3 * position, vector_3 * target, vector_3 * speed) { if (particle->count + 1 >= particle->limit) return; ++particle->count; - uint current = particle->count - 1; + u4 current = particle->count - 1; particle->sprite [current] = sprite; particle->life [current] = life; @@ -91,7 +91,7 @@ static void particle_append (particle_structure * particle, uint sprite, float l vector_3_copy (particle->speed [current], speed); } -static void particle_switch (particle_structure * particle, uint this, uint with) { +static v0 particle_switch (particle_structure * particle, u4 this, u4 with) { uint_exchange (& particle->sprite [this], & particle->sprite [with]); float_exchange (& particle->life [this], & particle->life [with]); uint_exchange (& particle->colour_in [this], & particle->colour_in [with]); @@ -101,7 +101,7 @@ static void particle_switch (particle_structure * particle, uint this, uint with vector_3_exchange ( particle->speed [this], particle->speed [with]); } -static void particle_remove (particle_structure * particle, uint index) { +static v0 particle_remove (particle_structure * particle, u4 index) { if (index >= particle->count) return; particle_switch (particle, index, particle->count - 1); @@ -109,9 +109,9 @@ static void particle_remove (particle_structure * particle, uint index) { --particle->count; } -static void particle_effect_splash (particle_structure * particle, uint sprite, float life, uint colour_in, uint colour_out, - vector_3 * position, uint ray_count, float ray_force, float ray_error) { - for (uint ray = 0; ray < ray_count; ++ray) { +static v0 particle_effect_splash (particle_structure * particle, u4 sprite, f4 life, u4 colour_in, u4 colour_out, + vector_3 * position, u4 ray_count, f4 ray_force, f4 ray_error) { + for (u4 ray = 0; ray < ray_count; ++ray) { vector_3 target = { //~position->x + frandomize (- ray_force, + ray_force), //~position->y + frandomize (- ray_force, + ray_force), @@ -134,9 +134,9 @@ static void particle_effect_splash (particle_structure * particle, uint sprite, } } -static void particle_effect_evaporate (particle_structure * particle, uint sprite, float life, uint colour_in, uint colour_out, - vector_3 * position, uint ray_count, float ray_force, float ray_error) { - for (uint ray = 0; ray < ray_count; ++ray) { +static v0 particle_effect_evaporate (particle_structure * particle, u4 sprite, f4 life, u4 colour_in, u4 colour_out, + vector_3 * position, u4 ray_count, f4 ray_force, f4 ray_error) { + for (u4 ray = 0; ray < ray_count; ++ray) { vector_3 target = { frandomize (0.0f, + ray_force / 6.0f), frandomize (0.0f, + ray_force / 1.0f), @@ -155,8 +155,8 @@ static void particle_effect_evaporate (particle_structure * particle, uint sprit } } -static void particle_synchronize (particle_structure * particle, uint framerate) { - for (uint index = 0; index < particle->count; ++index) { +static v0 particle_synchronize (particle_structure * particle, u4 framerate) { + for (u4 index = 0; index < particle->count; ++index) { particle->life [index] -= 1.0f / (float) framerate; if (particle->life [index] < 0.0f) { diff --git a/xatrix.h b/xatrix.h index f3677b6..22f7eb6 100644 --- a/xatrix.h +++ b/xatrix.h @@ -15,13 +15,13 @@ /// warranty of merchantability or fitness for a particular purpose, because it is pointless. Please see the GNU (Geenoo) General Public License /// for more details, if you dare, it is a lot of text that nobody wants to read... -typedef float matrix_2 [2] [2]; -typedef float matrix_3 [3] [3]; -typedef float matrix_4 [4] [4]; +typedef f4 matrix_2 [2] [2]; +typedef f4 matrix_3 [3] [3]; +typedef f4 matrix_4 [4] [4]; static matrix_2 * matrix_2_assign (matrix_2 * destination, - float m00, float m01, - float m10, float m11) { + f4 m00, f4 m01, + f4 m10, f4 m11) { destination [0] [0] = m00; destination [0] [1] = m01; destination [1] [0] = m10; @@ -31,9 +31,9 @@ static matrix_2 * matrix_2_assign (matrix_2 * destination, } static matrix_3 * matrix_3_assign (matrix_3 * destination, - float m00, float m01, float m02, - float m10, float m11, float m12, - float m20, float m21, float m22) { + f4 m00, f4 m01, f4 m02, + f4 m10, f4 m11, f4 m12, + f4 m20, f4 m21, f4 m22) { destination [0] [0] = m00; destination [0] [1] = m01; destination [0] [2] = m02; @@ -48,10 +48,10 @@ static matrix_3 * matrix_3_assign (matrix_3 * destination, } static matrix_4 * matrix_4_assign (matrix_4 * destination, - float m00, float m01, float m02, float m03, - float m10, float m11, float m12, float m13, - float m20, float m21, float m22, float m23, - float m30, float m31, float m32, float m33) { + f4 m00, f4 m01, f4 m02, f4 m03, + f4 m10, f4 m11, f4 m12, f4 m13, + f4 m20, f4 m21, f4 m22, f4 m23, + f4 m30, f4 m31, f4 m32, f4 m33) { destination [0] [0] = m00; destination [0] [1] = m01; destination [0] [2] = m02; @@ -73,8 +73,8 @@ static matrix_4 * matrix_4_assign (matrix_4 * destination, } static matrix_2 * matrix_2_nullify (matrix_2 * destination) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { destination [row] [column] = 0.0f; } } @@ -83,8 +83,8 @@ static matrix_2 * matrix_2_nullify (matrix_2 * destination) { } static matrix_3 * matrix_3_nullify (matrix_3 * destination) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { destination [row] [column] = 0.0f; } } @@ -93,8 +93,8 @@ static matrix_3 * matrix_3_nullify (matrix_3 * destination) { } static matrix_4 * matrix_4_nullify (matrix_4 * destination) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { destination [row] [column] = 0.0f; } } @@ -105,7 +105,7 @@ static matrix_4 * matrix_4_nullify (matrix_4 * destination) { static matrix_2 * matrix_2_identity (matrix_2 * destination) { destination = matrix_2_nullify (destination); - for (uint index = 0; index < 2; ++index) { + for (u4 index = 0; index < 2; ++index) { destination [index] [index] = 1.0f; } @@ -115,7 +115,7 @@ static matrix_2 * matrix_2_identity (matrix_2 * destination) { static matrix_3 * matrix_3_identity (matrix_3 * destination) { destination = matrix_3_nullify (destination); - for (uint index = 0; index < 3; ++index) { + for (u4 index = 0; index < 3; ++index) { destination [index] [index] = 1.0f; } @@ -125,21 +125,21 @@ static matrix_3 * matrix_3_identity (matrix_3 * destination) { static matrix_4 * matrix_4_identity (matrix_4 * destination) { destination = matrix_4_nullify (destination); - for (uint index = 0; index < 4; ++index) { + for (u4 index = 0; index < 4; ++index) { destination [index] [index] = 1.0f; } return (destination); } -static float matrix_2_determinant (matrix_2 * matrix) { - float a = matrix [0] [0] * matrix [1] [1]; - float b = matrix [0] [1] * matrix [1] [0]; +static f4 matrix_2_determinant (matrix_2 * matrix) { + f4 a = matrix [0] [0] * matrix [1] [1]; + f4 b = matrix [0] [1] * matrix [1] [0]; return (a - b); } -static float matrix_3_determinant (matrix_3 * matrix) { +static f4 matrix_3_determinant (matrix_3 * matrix) { matrix_2 matrix_a = { { matrix [1] [1], matrix [1] [2] }, { matrix [2] [1], matrix [2] [2] } }; matrix_2 matrix_b = { { matrix [1] [0], matrix [1] [2] }, @@ -147,14 +147,14 @@ static float matrix_3_determinant (matrix_3 * matrix) { matrix_2 matrix_c = { { matrix [1] [0], matrix [1] [1] }, { matrix [2] [0], matrix [2] [1] } }; - float a = matrix [0] [0] * matrix_2_determinant (& matrix_a); - float b = matrix [0] [1] * matrix_2_determinant (& matrix_b); - float c = matrix [0] [2] * matrix_2_determinant (& matrix_c); + f4 a = matrix [0] [0] * matrix_2_determinant (& matrix_a); + f4 b = matrix [0] [1] * matrix_2_determinant (& matrix_b); + f4 c = matrix [0] [2] * matrix_2_determinant (& matrix_c); return (a - b + c); } -static float matrix_4_determinant (matrix_4 * matrix) { +static f4 matrix_4_determinant (matrix_4 * matrix) { matrix_3 matrix_a = { { matrix [1] [1], matrix [1] [2], matrix [1] [3] }, { matrix [2] [1], matrix [2] [2], matrix [2] [3] }, { matrix [3] [1], matrix [3] [2], matrix [3] [3] } }; @@ -168,17 +168,17 @@ static float matrix_4_determinant (matrix_4 * matrix) { { matrix [2] [0], matrix [2] [1], matrix [2] [2] }, { matrix [3] [0], matrix [3] [1], matrix [3] [2] } }; - float a = matrix [0] [0] * matrix_3_determinant (& matrix_a); - float b = matrix [0] [1] * matrix_3_determinant (& matrix_b); - float c = matrix [0] [2] * matrix_3_determinant (& matrix_c); - float d = matrix [0] [3] * matrix_3_determinant (& matrix_d); + f4 a = matrix [0] [0] * matrix_3_determinant (& matrix_a); + f4 b = matrix [0] [1] * matrix_3_determinant (& matrix_b); + f4 c = matrix [0] [2] * matrix_3_determinant (& matrix_c); + f4 d = matrix [0] [3] * matrix_3_determinant (& matrix_d); return (a - b + c - d); } static matrix_2 * matrix_2_copy (matrix_2 * destination, matrix_2 * source) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { destination [row] [column] = source [row] [column]; } } @@ -187,8 +187,8 @@ static matrix_2 * matrix_2_copy (matrix_2 * destination, matrix_2 * source) { } static matrix_3 * matrix_3_copy (matrix_3 * destination, matrix_3 * source) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { destination [row] [column] = source [row] [column]; } } @@ -197,8 +197,8 @@ static matrix_3 * matrix_3_copy (matrix_3 * destination, matrix_3 * source) { } static matrix_4 * matrix_4_copy (matrix_4 * destination, matrix_4 * source) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { destination [row] [column] = source [row] [column]; } } @@ -206,9 +206,9 @@ static matrix_4 * matrix_4_copy (matrix_4 * destination, matrix_4 * source) { return (destination); } -static matrix_2 * matrix_2_scale (matrix_2 * destination, float scale) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { +static matrix_2 * matrix_2_scale (matrix_2 * destination, f4 scale) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { destination [row] [column] *= scale; } } @@ -216,9 +216,9 @@ static matrix_2 * matrix_2_scale (matrix_2 * destination, float scale) { return (destination); } -static matrix_3 * matrix_3_scale (matrix_3 * destination, float scale) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { +static matrix_3 * matrix_3_scale (matrix_3 * destination, f4 scale) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { destination [row] [column] *= scale; } } @@ -226,9 +226,9 @@ static matrix_3 * matrix_3_scale (matrix_3 * destination, float scale) { return (destination); } -static matrix_4 * matrix_4_scale (matrix_4 * destination, float scale) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { +static matrix_4 * matrix_4_scale (matrix_4 * destination, f4 scale) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { destination [row] [column] *= scale; } } @@ -236,9 +236,9 @@ static matrix_4 * matrix_4_scale (matrix_4 * destination, float scale) { return (destination); } -static matrix_2 * matrix_2_scale_to (matrix_2 * destination, matrix_2 * source, float scale) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { +static matrix_2 * matrix_2_scale_to (matrix_2 * destination, matrix_2 * source, f4 scale) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { destination [row] [column] = source [row] [column] * scale; } } @@ -246,9 +246,9 @@ static matrix_2 * matrix_2_scale_to (matrix_2 * destination, matrix_2 * source, return (destination); } -static matrix_3 * matrix_3_scale_to (matrix_3 * destination, matrix_3 * source, float scale) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { +static matrix_3 * matrix_3_scale_to (matrix_3 * destination, matrix_3 * source, f4 scale) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { destination [row] [column] = source [row] [column] * scale; } } @@ -256,9 +256,9 @@ static matrix_3 * matrix_3_scale_to (matrix_3 * destination, matrix_3 * source, return (destination); } -static matrix_4 * matrix_4_scale_to (matrix_4 * destination, matrix_4 * source, float scale) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { +static matrix_4 * matrix_4_scale_to (matrix_4 * destination, matrix_4 * source, f4 scale) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { destination [row] [column] = source [row] [column] * scale; } } @@ -267,8 +267,8 @@ static matrix_4 * matrix_4_scale_to (matrix_4 * destination, matrix_4 * source, } static matrix_2 * matrix_2_add (matrix_2 * destination, matrix_2 * source) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { destination [row] [column] += source [row] [column]; } } @@ -277,8 +277,8 @@ static matrix_2 * matrix_2_add (matrix_2 * destination, matrix_2 * source) { } static matrix_3 * matrix_3_add (matrix_3 * destination, matrix_3 * source) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { destination [row] [column] += source [row] [column]; } } @@ -287,8 +287,8 @@ static matrix_3 * matrix_3_add (matrix_3 * destination, matrix_3 * source) { } static matrix_4 * matrix_4_add (matrix_4 * destination, matrix_4 * source) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { destination [row] [column] += source [row] [column]; } } @@ -297,8 +297,8 @@ static matrix_4 * matrix_4_add (matrix_4 * destination, matrix_4 * source) { } static matrix_2 * matrix_2_add_to (matrix_2 * destination, matrix_2 * matrix_a, matrix_2 * matrix_b) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { destination [row] [column] = matrix_a [row] [column] + matrix_b [row] [column]; } } @@ -307,8 +307,8 @@ static matrix_2 * matrix_2_add_to (matrix_2 * destination, matrix_2 * matrix_a, } static matrix_3 * matrix_3_add_to (matrix_3 * destination, matrix_3 * matrix_a, matrix_3 * matrix_b) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { destination [row] [column] = matrix_a [row] [column] + matrix_b [row] [column]; } } @@ -317,8 +317,8 @@ static matrix_3 * matrix_3_add_to (matrix_3 * destination, matrix_3 * matrix_a, } static matrix_4 * matrix_4_add_to (matrix_4 * destination, matrix_4 * matrix_a, matrix_4 * matrix_b) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { destination [row] [column] = matrix_a [row] [column] + matrix_b [row] [column]; } } @@ -327,8 +327,8 @@ static matrix_4 * matrix_4_add_to (matrix_4 * destination, matrix_4 * matrix_a, } static matrix_2 * matrix_2_subtract (matrix_2 * destination, matrix_2 * source) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { destination [row] [column] -= source [row] [column]; } } @@ -337,8 +337,8 @@ static matrix_2 * matrix_2_subtract (matrix_2 * destination, matrix_2 * source) } static matrix_3 * matrix_3_subtract (matrix_3 * destination, matrix_3 * source) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { destination [row] [column] -= source [row] [column]; } } @@ -347,8 +347,8 @@ static matrix_3 * matrix_3_subtract (matrix_3 * destination, matrix_3 * source) } static matrix_4 * matrix_4_subtract (matrix_4 * destination, matrix_4 * source) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { destination [row] [column] -= source [row] [column]; } } @@ -357,8 +357,8 @@ static matrix_4 * matrix_4_subtract (matrix_4 * destination, matrix_4 * source) } static matrix_2 * matrix_2_subtract_to (matrix_2 * destination, matrix_2 * matrix_a, matrix_2 * matrix_b) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { destination [row] [column] = matrix_a [row] [column] - matrix_b [row] [column]; } } @@ -367,8 +367,8 @@ static matrix_2 * matrix_2_subtract_to (matrix_2 * destination, matrix_2 * matri } static matrix_3 * matrix_3_subtract_to (matrix_3 * destination, matrix_3 * matrix_a, matrix_3 * matrix_b) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { destination [row] [column] = matrix_a [row] [column] - matrix_b [row] [column]; } } @@ -377,8 +377,8 @@ static matrix_3 * matrix_3_subtract_to (matrix_3 * destination, matrix_3 * matri } static matrix_4 * matrix_4_subtract_to (matrix_4 * destination, matrix_4 * matrix_a, matrix_4 * matrix_b) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { destination [row] [column] = matrix_a [row] [column] - matrix_b [row] [column]; } } @@ -387,11 +387,11 @@ static matrix_4 * matrix_4_subtract_to (matrix_4 * destination, matrix_4 * matri } static matrix_2 * matrix_2_multiply (matrix_2 * result, matrix_2 * matrix_a, matrix_2 * matrix_b) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { result [row] [column] = 0.0f; - for (uint index = 0; index < 2; ++index) { + for (u4 index = 0; index < 2; ++index) { result [row] [column] += matrix_a [row] [index] * matrix_b [index] [column]; } } @@ -401,11 +401,11 @@ static matrix_2 * matrix_2_multiply (matrix_2 * result, matrix_2 * matrix_a, mat } static matrix_3 * matrix_3_multiply (matrix_3 * result, matrix_3 * matrix_a, matrix_3 * matrix_b) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { result [row] [column] = 0.0f; - for (uint index = 0; index < 3; ++index) { + for (u4 index = 0; index < 3; ++index) { result [row] [column] += matrix_a [row] [index] * matrix_b [index] [column]; } } @@ -415,11 +415,11 @@ static matrix_3 * matrix_3_multiply (matrix_3 * result, matrix_3 * matrix_a, mat } static matrix_4 * matrix_4_multiply (matrix_4 * result, matrix_4 * matrix_a, matrix_4 * matrix_b) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { result [row] [column] = 0.0f; - for (uint index = 0; index < 4; ++index) { + for (u4 index = 0; index < 4; ++index) { result [row] [column] += matrix_a [row] [index] * matrix_b [index] [column]; } } @@ -428,21 +428,21 @@ static matrix_4 * matrix_4_multiply (matrix_4 * result, matrix_4 * matrix_a, mat return (result); } -static float matrix_2_trace (matrix_2 * matrix) { +static f4 matrix_2_trace (matrix_2 * matrix) { return (matrix [0] [0] + matrix [1] [1]); } -static float matrix_3_trace (matrix_3 * matrix) { +static f4 matrix_3_trace (matrix_3 * matrix) { return (matrix [0] [0] + matrix [1] [1] + matrix [2] [2]); } -static float matrix_4_trace (matrix_4 * matrix) { +static f4 matrix_4_trace (matrix_4 * matrix) { return (matrix [0] [0] + matrix [1] [1] + matrix [2] [2] + matrix [3] [3]); } -static bool matrix_2_compare (matrix_2 * matrix_a, matrix_2 * matrix_b) { - for (uint row = 0; row < 2; ++row) { - for (uint column = 0; column < 2; ++column) { +static b4 matrix_2_compare (matrix_2 * matrix_a, matrix_2 * matrix_b) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = 0; column < 2; ++column) { if (matrix_a [row] [column] != matrix_b [row] [column]) { return (false); } @@ -452,9 +452,9 @@ static bool matrix_2_compare (matrix_2 * matrix_a, matrix_2 * matrix_b) { return (true); } -static bool matrix_3_compare (matrix_3 * matrix_a, matrix_3 * matrix_b) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { +static b4 matrix_3_compare (matrix_3 * matrix_a, matrix_3 * matrix_b) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { if (matrix_a [row] [column] != matrix_b [row] [column]) { return (false); } @@ -464,9 +464,9 @@ static bool matrix_3_compare (matrix_3 * matrix_a, matrix_3 * matrix_b) { return (true); } -static bool matrix_4_compare (matrix_4 * matrix_a, matrix_4 * matrix_b) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { +static b4 matrix_4_compare (matrix_4 * matrix_a, matrix_4 * matrix_b) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { if (matrix_a [row] [column] != matrix_b [row] [column]) { return (false); } @@ -476,10 +476,10 @@ static bool matrix_4_compare (matrix_4 * matrix_a, matrix_4 * matrix_b) { return (true); } -static void matrix_2_transpose (matrix_2 * matrix_a, matrix_2 * matrix_b) { - for (uint row = 0; row < 2; ++row) { - for (uint column = row + 1; column < 2; ++column) { - float temporary = matrix_a [row] [column]; +static v0 matrix_2_transpose (matrix_2 * matrix_a, matrix_2 * matrix_b) { + for (u4 row = 0; row < 2; ++row) { + for (u4 column = row + 1; column < 2; ++column) { + f4 temporary = matrix_a [row] [column]; matrix_a [row] [column] = matrix_b [column] [row]; matrix_b [column] [row] = temporary; @@ -487,10 +487,10 @@ static void matrix_2_transpose (matrix_2 * matrix_a, matrix_2 * matrix_b) { } } -static void matrix_3_transpose (matrix_3 * matrix_a, matrix_3 * matrix_b) { - for (uint row = 0; row < 3; ++row) { - for (uint column = 0; column < 3; ++column) { - float temporary = matrix_a [row] [column]; +static v0 matrix_3_transpose (matrix_3 * matrix_a, matrix_3 * matrix_b) { + for (u4 row = 0; row < 3; ++row) { + for (u4 column = 0; column < 3; ++column) { + f4 temporary = matrix_a [row] [column]; matrix_a [row] [column] = matrix_b [column] [row]; matrix_b [column] [row] = temporary; @@ -498,10 +498,10 @@ static void matrix_3_transpose (matrix_3 * matrix_a, matrix_3 * matrix_b) { } } -static void matrix_4_transpose (matrix_4 * matrix_a, matrix_4 * matrix_b) { - for (uint row = 0; row < 4; ++row) { - for (uint column = 0; column < 4; ++column) { - float temporary = matrix_a [row] [column]; +static v0 matrix_4_transpose (matrix_4 * matrix_a, matrix_4 * matrix_b) { + for (u4 row = 0; row < 4; ++row) { + for (u4 column = 0; column < 4; ++column) { + f4 temporary = matrix_a [row] [column]; matrix_a [row] [column] = matrix_b [column] [row]; matrix_b [column] [row] = temporary; diff --git a/xcript.h b/xcript.h index a644192..9c0bd4f 100755 --- a/xcript.h +++ b/xcript.h @@ -22,32 +22,32 @@ typedef enum { } script_word_type; typedef struct { - char * path; - char * source; - uint prefix; - uint length; - uint suffix; - uint offset; - uint line; - uint last_length; - char * last_string; - bool force; - bool range; + c1 * path; + c1 * source; + u4 prefix; + u4 length; + u4 suffix; + u4 offset; + u4 line; + u4 last_length; + c1 * last_string; + b4 force; + b4 range; } script_structure; typedef struct { - uint counter; - char * * identifier; - uint * index; + u4 counter; + c1 * * identifier; + u4 * index; } script_information; -static void script_warning (script_structure * script, bool condition, char * message) { +static v0 script_warning (script_structure * script, b4 condition, c1 * message) { if (condition == true) { print ("[/3Warning/-] %s: %i: %s\n", script->path, script->line, message); } } -static void script_failure (script_structure * script, bool condition, char * message) { +static v0 script_failure (script_structure * script, b4 condition, c1 * message) { if (condition == true) { print ("[/1Failure/-] %s: %i: %s\n", script->path, script->line, message); @@ -57,7 +57,7 @@ static void script_failure (script_structure * script, bool condition, char * me } } -static script_structure * script_open (char * path) { +static script_structure * script_open (c1 * path) { script_structure * script = allocate (sizeof (* script)); script->path = string_duplicate (path); @@ -81,24 +81,24 @@ static script_structure * script_close (script_structure * script) { return (deallocate (script)); } -static bool script_compare (script_structure * script, char * string) { +static b4 script_compare (script_structure * script, c1 * string) { return (string_compare_limit (string, script->last_string, script->last_length)); } -static bool script_check (script_information * information, uint index, char * identifier) { +static b4 script_check (script_information * information, u4 index, c1 * identifier) { return (string_compare (identifier, information->identifier [index])); } -static char * script_export_string (script_structure * script) { +static c1 * script_export_string (script_structure * script) { return (string_duplicate_limit (script->last_string, script->last_length)); } -static uint script_export_number (script_structure * script) { +static u4 script_export_number (script_structure * script) { return (string_limit_to_number (script->last_string, script->last_length)); } -static uint script_export_marker (script_information * information, script_structure * script) { - for (uint counter = 0; counter < information->counter; ++counter) { +static u4 script_export_marker (script_information * information, script_structure * script) { + for (u4 counter = 0; counter < information->counter; ++counter) { if (script_compare (script, information->identifier [counter]) == true) { return (information->index [counter]); } @@ -207,7 +207,7 @@ static script_word_type script_parser (script_structure * script) { return (word); } -static char * script_expect_header (script_information * information, script_structure * script, uint index, bool accept) { +static c1 * script_expect_header (script_information * information, script_structure * script, u4 index, b4 accept) { if (accept == true) { ++information->counter; @@ -221,7 +221,7 @@ static char * script_expect_header (script_information * information, script_str return (script_export_string (script)); } -static char * script_expect_string (script_structure * script) { +static c1 * script_expect_string (script_structure * script) { script_word_type word = script_unknown; script_failure (script, (word = script_parser (script)) != script_assign, "Expected '=', assignment operator."); @@ -230,7 +230,7 @@ static char * script_expect_string (script_structure * script) { return (script_export_string (script)); } -static uint script_expect_number (script_structure * script) { +static u4 script_expect_number (script_structure * script) { script_word_type word = script_unknown; script_failure (script, (word = script_parser (script)) != script_assign, "Expected '=', assignment operator."); @@ -239,7 +239,7 @@ static uint script_expect_number (script_structure * script) { return (script_export_number (script)); } -static uint script_expect_marker (script_information * information, script_structure * script) { +static u4 script_expect_marker (script_information * information, script_structure * script) { script_word_type word = script_unknown; script_failure (script, (word = script_parser (script)) != script_assign, "Expected '=', assignment operator."); @@ -248,7 +248,7 @@ static uint script_expect_marker (script_information * information, script_struc return (script_export_marker (information, script)); } -static uint script_expect_number_or_marker (script_information * information, script_structure * script) { +static u4 script_expect_number_or_marker (script_information * information, script_structure * script) { script_word_type word = script_unknown; script_failure (script, (word = script_parser (script)) != script_assign, "Expected '=', assignment operator."); @@ -266,11 +266,11 @@ static uint script_expect_number_or_marker (script_information * information, sc return (~ 0u); } -static uint * script_expect_ordered_array (script_information * information, script_structure * script, uint * count) { +static u4 * script_expect_ordered_array (script_information * information, script_structure * script, u4 * count) { script_word_type word = script_unknown; - uint found = 0; - uint * array = null; + u4 found = 0; + u4 * array = null; script_failure (script, (word = script_parser (script)) != script_assign, "Expected '=', assignment operator."); script_failure (script, (word = script_parser (script)) != script_from, "Expected '(', begin range operator."); @@ -299,16 +299,16 @@ static uint * script_expect_ordered_array (script_information * information, scr return (array); } -static uint * script_expect_unordered_array (script_information * information, script_structure * script, uint count) { +static u4 * script_expect_unordered_array (script_information * information, script_structure * script, u4 count) { script_word_type word = script_unknown; - uint * array = allocate (count * sizeof (* array)); + u4 * array = allocate (count * sizeof (* array)); script_failure (script, (word = script_parser (script)) != script_assign, "Expected '=', assignment operator."); script_failure (script, (word = script_parser (script)) != script_from, "Expected '(', begin range operator."); for (word = script_parser (script); word != script_to; word = script_parser (script)) { - uint index = script_export_marker (information, script); + u4 index = script_export_marker (information, script); script_failure (script, word != script_marker, "Expected ranged marker."); @@ -333,7 +333,7 @@ static uint * script_expect_unordered_array (script_information * information, s return (array); } -static script_information * script_initialize (char * general_script_file_path) { +static script_information * script_initialize (c1 * general_script_file_path) { script_information * script = allocate (sizeof (* script)); script_word_type word = script_unknown; @@ -360,7 +360,7 @@ static script_information * script_initialize (char * general_script_file_path) } static script_information * script_deinitialize (script_information * script) { - for (uint index = 0; index < script->counter; ++index) { + for (u4 index = 0; index < script->counter; ++index) { script->identifier [index] = deallocate (script->identifier [index]); } @@ -370,8 +370,8 @@ static script_information * script_deinitialize (script_information * script) { return (deallocate (script)); } -static uint script_indexer (script_information * information, char * identifier) { - for (uint counter = 0; counter < information->counter; ++counter) { +static u4 script_indexer (script_information * information, c1 * identifier) { + for (u4 counter = 0; counter < information->counter; ++counter) { if (string_compare (identifier, information->identifier [counter]) == true) { return (information->index [counter]); } diff --git a/xctree.h b/xctree.h index 8009fa5..bce08e9 100644 --- a/xctree.h +++ b/xctree.h @@ -16,8 +16,8 @@ /// for more details, if you dare, it is a lot of text that nobody wants to read... typedef struct { - bool division; - float scale; + b4 division; + f4 scale; vector_3 * * vertex; vector_3 * origin; vector_3 * offset; @@ -26,7 +26,7 @@ typedef struct { } octree_node; typedef struct { - uint count; - uint limit; + u4 count; + u4 limit; octree_node * * array; } octree_structure; diff --git a/xector.h b/xector.h index d774a0a..43d680b 100755 --- a/xector.h +++ b/xector.h @@ -16,25 +16,25 @@ /// for more details, if you dare, it is a lot of text that nobody wants to read... typedef struct { - float x, y; + f4 x, y; } vector_2; typedef struct { - float x, y, z; + f4 x, y, z; } vector_3; typedef struct { - float x, y, z, w; + f4 x, y, z, w; } vector_4; -static vector_2 * vector_2_assign (vector_2 * destination, float x, float y) { +static vector_2 * vector_2_assign (vector_2 * destination, f4 x, f4 y) { destination->x = x; destination->y = y; return (destination); } -static vector_3 * vector_3_assign (vector_3 * destination, float x, float y, float z) { +static vector_3 * vector_3_assign (vector_3 * destination, f4 x, f4 y, f4 z) { destination->x = x; destination->y = y; destination->z = z; @@ -42,7 +42,7 @@ static vector_3 * vector_3_assign (vector_3 * destination, float x, float y, flo return (destination); } -static vector_4 * vector_4_assign (vector_4 * destination, float x, float y, float z, float w) { +static vector_4 * vector_4_assign (vector_4 * destination, f4 x, f4 y, f4 z, f4 w) { destination->x = x; destination->y = y; destination->z = z; @@ -69,32 +69,32 @@ static vector_4 * vector_4_nullify (vector_4 * destination) { return (destination); } -static float vector_2_length (vector_2 * vector) { - float x = vector->x; - float y = vector->y; +static f4 vector_2_length (vector_2 * vector) { + f4 x = vector->x; + f4 y = vector->y; return (square_root (x * x + y * y)); } -static float vector_3_length (vector_3 * vector) { - float x = vector->x; - float y = vector->y; - float z = vector->z; +static f4 vector_3_length (vector_3 * vector) { + f4 x = vector->x; + f4 y = vector->y; + f4 z = vector->z; return (square_root (x * x + y * y + z * z)); } -static float vector_4_length (vector_4 * vector) { - float x = vector->x; - float y = vector->y; - float z = vector->z; - float w = vector->w; +static f4 vector_4_length (vector_4 * vector) { + f4 x = vector->x; + f4 y = vector->y; + f4 z = vector->z; + f4 w = vector->w; return (square_root (x * x + y * y + z * z + w * w)); } static vector_2 * vector_2_normalize (vector_2 * destination) { - float length = vector_2_length (destination); + f4 length = vector_2_length (destination); destination->x /= length; destination->y /= length; @@ -103,7 +103,7 @@ static vector_2 * vector_2_normalize (vector_2 * destination) { } static vector_3 * vector_3_normalize (vector_3 * destination) { - float length = vector_3_length (destination); + f4 length = vector_3_length (destination); destination->x /= length; destination->y /= length; @@ -113,7 +113,7 @@ static vector_3 * vector_3_normalize (vector_3 * destination) { } static vector_4 * vector_4_normalize (vector_4 * destination) { - float length = vector_4_length (destination); + f4 length = vector_4_length (destination); destination->x /= length; destination->y /= length; @@ -124,7 +124,7 @@ static vector_4 * vector_4_normalize (vector_4 * destination) { } static vector_2 * vector_2_normalize_to (vector_2 * destination, vector_2 * source) { - float length = vector_2_length (source); + f4 length = vector_2_length (source); destination->x = source->x / length; destination->y = source->y / length; @@ -133,7 +133,7 @@ static vector_2 * vector_2_normalize_to (vector_2 * destination, vector_2 * sour } static vector_3 * vector_3_normalize_to (vector_3 * destination, vector_3 * source) { - float length = vector_3_length (source); + f4 length = vector_3_length (source); destination->x = source->x / length; destination->y = source->y / length; @@ -143,7 +143,7 @@ static vector_3 * vector_3_normalize_to (vector_3 * destination, vector_3 * sour } static vector_4 * vector_4_normalize_to (vector_4 * destination, vector_4 * source) { - float length = vector_4_length (source); + f4 length = vector_4_length (source); destination->x = source->x / length; destination->y = source->y / length; @@ -177,32 +177,32 @@ static vector_4 * vector_4_copy (vector_4 * destination, vector_4 * source) { return (destination); } -static void vector_2_exchange (vector_2 * vector_a, vector_2 * vector_b) { +static v0 vector_2_exchange (vector_2 * vector_a, vector_2 * vector_b) { float_exchange (& vector_a->x, & vector_b->x); float_exchange (& vector_a->y, & vector_b->y); } -static void vector_3_exchange (vector_3 * vector_a, vector_3 * vector_b) { +static v0 vector_3_exchange (vector_3 * vector_a, vector_3 * vector_b) { float_exchange (& vector_a->x, & vector_b->x); float_exchange (& vector_a->y, & vector_b->y); float_exchange (& vector_a->z, & vector_b->z); } -static void vector_4_exchange (vector_4 * vector_a, vector_4 * vector_b) { +static v0 vector_4_exchange (vector_4 * vector_a, vector_4 * vector_b) { float_exchange (& vector_a->x, & vector_b->x); float_exchange (& vector_a->y, & vector_b->y); float_exchange (& vector_a->z, & vector_b->z); float_exchange (& vector_a->w, & vector_b->w); } -static vector_2 * vector_2_scale (vector_2 * destination, float scale) { +static vector_2 * vector_2_scale (vector_2 * destination, f4 scale) { destination->x *= scale; destination->y *= scale; return (destination); } -static vector_3 * vector_3_scale (vector_3 * destination, float scale) { +static vector_3 * vector_3_scale (vector_3 * destination, f4 scale) { destination->x *= scale; destination->y *= scale; destination->z *= scale; @@ -210,7 +210,7 @@ static vector_3 * vector_3_scale (vector_3 * destination, float scale) { return (destination); } -static vector_4 * vector_4_scale (vector_4 * destination, float scale) { +static vector_4 * vector_4_scale (vector_4 * destination, f4 scale) { destination->x *= scale; destination->y *= scale; destination->z *= scale; @@ -219,14 +219,14 @@ static vector_4 * vector_4_scale (vector_4 * destination, float scale) { return (destination); } -static vector_2 * vector_2_scale_to (vector_2 * destination, vector_2 * source, float scale) { +static vector_2 * vector_2_scale_to (vector_2 * destination, vector_2 * source, f4 scale) { destination->x = source->x * scale; destination->y = source->y * scale; return (destination); } -static vector_3 * vector_3_scale_to (vector_3 * destination, vector_3 * source, float scale) { +static vector_3 * vector_3_scale_to (vector_3 * destination, vector_3 * source, f4 scale) { destination->x = source->x * scale; destination->y = source->y * scale; destination->z = source->z * scale; @@ -234,7 +234,7 @@ static vector_3 * vector_3_scale_to (vector_3 * destination, vector_3 * source, return (destination); } -static vector_4 * vector_4_scale_to (vector_4 * destination, vector_4 * source, float scale) { +static vector_4 * vector_4_scale_to (vector_4 * destination, vector_4 * source, f4 scale) { destination->x = source->x * scale; destination->y = source->y * scale; destination->z = source->z * scale; @@ -339,7 +339,7 @@ static vector_4 * vector_4_subtract_to (vector_4 * destination, vector_4 * vecto return (destination); } -static bool vector_2_compare (vector_2 * vector_a, vector_2 * vector_b) { +static b4 vector_2_compare (vector_2 * vector_a, vector_2 * vector_b) { if ((vector_a->x == vector_b->x) && (vector_a->y == vector_b->y)) { return (true); } else { @@ -347,7 +347,7 @@ static bool vector_2_compare (vector_2 * vector_a, vector_2 * vector_b) { } } -static bool vector_3_compare (vector_3 * vector_a, vector_3 * vector_b) { +static b4 vector_3_compare (vector_3 * vector_a, vector_3 * vector_b) { if ((vector_a->x == vector_b->x) && (vector_a->y == vector_b->y) && (vector_a->z == vector_b->z)) { return (true); } else { @@ -355,7 +355,7 @@ static bool vector_3_compare (vector_3 * vector_a, vector_3 * vector_b) { } } -static bool vector_4_compare (vector_4 * vector_a, vector_4 * vector_b) { +static b4 vector_4_compare (vector_4 * vector_a, vector_4 * vector_b) { if ((vector_a->x == vector_b->x) && (vector_a->y == vector_b->y) && (vector_a->z == vector_b->z) && (vector_a->w == vector_b->w)) { return (true); } else { @@ -363,19 +363,19 @@ static bool vector_4_compare (vector_4 * vector_a, vector_4 * vector_b) { } } -static float vector_2_dot_product (vector_2 * vector_a, vector_2 * vector_b) { +static f4 vector_2_dot_product (vector_2 * vector_a, vector_2 * vector_b) { return (vector_a->x * vector_b->x + vector_a->y * vector_b->y); } -static float vector_3_dot_product (vector_3 * vector_a, vector_3 * vector_b) { +static f4 vector_3_dot_product (vector_3 * vector_a, vector_3 * vector_b) { return (vector_a->x * vector_b->x + vector_a->y * vector_b->y + vector_a->z * vector_b->z); } -static float vector_4_dot_product (vector_4 * vector_a, vector_4 * vector_b) { +static f4 vector_4_dot_product (vector_4 * vector_a, vector_4 * vector_b) { return (vector_a->x * vector_b->x + vector_a->y * vector_b->y + vector_a->z * vector_b->z + vector_a->w * vector_b->w); } -static float vector_2_cross_product (vector_2 * vector_a, vector_2 * vector_b) { +static f4 vector_2_cross_product (vector_2 * vector_a, vector_2 * vector_b) { return (vector_a->x * vector_b->y - vector_a->y * vector_b->x); } diff --git a/xerminal.h b/xerminal.h index e1a4cda..fc768de 100755 --- a/xerminal.h +++ b/xerminal.h @@ -23,41 +23,41 @@ #define terminal_cursor_length (sizeof ("\033[---;---H") - 1) typedef struct { - char * screen; - uint screen_width; - uint screen_height; + c1 * screen; + u4 screen_width; + u4 screen_height; - char format [terminal_format_length + 1]; - char cursor [terminal_cursor_length + 1]; + c1 format [terminal_format_length + 1]; + c1 cursor [terminal_cursor_length + 1]; - bool active; - bool signal [signal_count]; + b4 active; + b4 signal [signal_count]; - uint character; + u4 character; struct termios * old_terminal; struct termios * new_terminal; } terminal_structure; -static char * terminal_screen_offset (terminal_structure * terminal, uint x, uint y) { +static c1 * terminal_screen_offset (terminal_structure * terminal, u4 x, u4 y) { return (& terminal->screen [terminal_revert_length + terminal_format_length * (y * terminal->screen_width + x) + 2 * y]); } -static uint terminal_screen_length (terminal_structure * terminal) { - uint constant = terminal_revert_length + terminal_cursor_length + 1; - uint variable = terminal_format_length * terminal->screen_height * terminal->screen_width; - uint new_line = 2 * (terminal->screen_height - 1); +static u4 terminal_screen_length (terminal_structure * terminal) { + u4 constant = terminal_revert_length + terminal_cursor_length + 1; + u4 variable = terminal_format_length * terminal->screen_height * terminal->screen_width; + u4 new_line = 2 * (terminal->screen_height - 1); return (constant + variable + new_line); } -static void terminal_screen_dimensions (terminal_structure * terminal) { +static v0 terminal_screen_dimensions (terminal_structure * terminal) { struct winsize screen_dimension = { 0 }; - uint old_width = terminal->screen_width; - uint old_height = terminal->screen_height; + u4 old_width = terminal->screen_width; + u4 old_height = terminal->screen_height; - int status = ioctl (STDOUT_FILENO, TIOCGWINSZ, & screen_dimension); + s4 status = ioctl (STDOUT_FILENO, TIOCGWINSZ, & screen_dimension); fatal_failure (status == -1, "ioctl: Failed to get dimensions."); @@ -74,12 +74,12 @@ static void terminal_screen_dimensions (terminal_structure * terminal) { string_copy (& terminal->screen [0], "\033[H"); - for (uint index = 0; index < terminal->screen_height - 1; ++index) { + for (u4 index = 0; index < terminal->screen_height - 1; ++index) { string_copy (& terminal->screen [terminal_revert_length + index * terminal_format_length * terminal->screen_width], "\r\n"); } } -static char * terminal_format_character (terminal_structure * terminal, char character, int colour, int effect) { +static c1 * terminal_format_character (terminal_structure * terminal, c1 character, s4 colour, s4 effect) { if (character_is_visible (character) == false) { character = ' '; } @@ -94,10 +94,10 @@ static char * terminal_format_character (terminal_structure * terminal, char cha return (terminal->format); } -static terminal_structure * terminal_initialize (void) { +static terminal_structure * terminal_initialize (v0) { terminal_structure * terminal = allocate (sizeof (* terminal)); - int status = -1; + s4 status = -1; string_copy_limit (terminal->format, "\033[-;3-m-\033[0m", terminal_format_length + 1); string_copy_limit (terminal->cursor, "\033[---;---H", terminal_cursor_length + 1); @@ -113,13 +113,13 @@ static terminal_structure * terminal_initialize (void) { memory_copy (terminal->new_terminal, terminal->old_terminal, sizeof (* terminal->old_terminal)); - terminal->new_terminal->c_cc [VMIN] = (uchar) 0; - terminal->new_terminal->c_cc [VTIME] = (uchar) 1; + terminal->new_terminal->c_cc [VMIN] = (u1) 0; + terminal->new_terminal->c_cc [VTIME] = (u1) 1; - terminal->new_terminal->c_iflag &= (uint) ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); - terminal->new_terminal->c_oflag &= (uint) ~(OPOST); - terminal->new_terminal->c_cflag |= (uint) (CS8); - terminal->new_terminal->c_lflag &= (uint) ~(ECHO | ICANON | IEXTEN | ISIG); + terminal->new_terminal->c_iflag &= (u4) ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + terminal->new_terminal->c_oflag &= (u4) ~(OPOST); + terminal->new_terminal->c_cflag |= (u4) (CS8); + terminal->new_terminal->c_lflag &= (u4) ~(ECHO | ICANON | IEXTEN | ISIG); status = tcsetattr (STDIN_FILENO, TCSAFLUSH, terminal->new_terminal); @@ -135,7 +135,7 @@ static terminal_structure * terminal_initialize (void) { } static terminal_structure * terminal_deinitialize (terminal_structure * terminal) { - int status = tcsetattr (STDIN_FILENO, TCSAFLUSH, terminal->old_terminal); + s4 status = tcsetattr (STDIN_FILENO, TCSAFLUSH, terminal->old_terminal); fatal_failure (status == -1, "tcsetattr: Failed to set default attributes."); @@ -150,20 +150,20 @@ static terminal_structure * terminal_deinitialize (terminal_structure * terminal return (deallocate (terminal)); } -static void terminal_synchronize (terminal_structure * terminal) { - uint character = 0; +static v0 terminal_synchronize (terminal_structure * terminal) { + u4 character = 0; output (terminal->screen, terminal_screen_length (terminal)); terminal_screen_dimensions (terminal); - for (uint index = 0; index < signal_count; ++index) { + for (u4 index = 0; index < signal_count; ++index) { terminal->signal [index] = false; } input (& character, sizeof (character)); - terminal->character = (uint) character; + terminal->character = (u4) character; if (character == 0x0000001b) { terminal->signal [signal_escape] = true; @@ -192,14 +192,14 @@ static void terminal_synchronize (terminal_structure * terminal) { } } -static void terminal_render_cursor (terminal_structure * terminal, uint x, uint y) { /* BROKE IT INTENTIONALLY */ +static v0 terminal_render_cursor (terminal_structure * terminal, u4 x, u4 y) { /* BROKE IT INTENTIONALLY */ string_copy_limit (terminal->cursor + 2, string_align_left (number_to_string (y % 1000 + 1), 3, '0'), 3); string_copy_limit (terminal->cursor + 6, string_align_left (number_to_string (x % 1000 + 1), 3, '0'), 3); string_copy_limit (& terminal->screen [terminal_screen_length (terminal) - terminal_cursor_length - 1], terminal->cursor, terminal_cursor_length); } -static void terminal_render_character (terminal_structure * terminal, char character, uint colour, uint effect, uint x, uint y) { +static v0 terminal_render_character (terminal_structure * terminal, c1 character, u4 colour, u4 effect, u4 x, u4 y) { if ((x >= terminal->screen_width) || (y >= terminal->screen_height)) { return; } @@ -207,84 +207,84 @@ static void terminal_render_character (terminal_structure * terminal, char chara string_copy_limit (terminal_screen_offset (terminal, x, y), terminal_format_character (terminal, character, colour, effect), terminal_format_length); } -static void terminal_render_toggle (terminal_structure * terminal, bool toggle, uint x, uint y) { - char marker = (toggle == true) ? '+' : '-'; - char colour = (toggle == true) ? colour_green : colour_red; +static v0 terminal_render_toggle (terminal_structure * terminal, b4 toggle, u4 x, u4 y) { + c1 marker = (toggle == true) ? '+' : '-'; + c1 colour = (toggle == true) ? colour_green : colour_red; terminal_render_character (terminal, '[', colour_grey, effect_bold, x + 0, y); terminal_render_character (terminal, marker, colour, effect_bold, x + 1, y); terminal_render_character (terminal, ']', colour_grey, effect_bold, x + 2, y); } -static void terminal_render_fill_bar (terminal_structure * terminal, uint value, uint limit, char character, uint colour, uint effect, uint x, uint y) { +static v0 terminal_render_fill_bar (terminal_structure * terminal, u4 value, u4 limit, c1 character, u4 colour, u4 effect, u4 x, u4 y) { terminal_render_character (terminal, '[', colour_grey, effect_bold, x, y); terminal_render_character (terminal, ']', colour_grey, effect_bold, x + limit + 1, y); - for (uint index = 0; index < limit; ++index) { + for (u4 index = 0; index < limit; ++index) { terminal_render_character (terminal, (index < value) ? character : ' ', colour, effect, x + index + 1, y); } } -static void terminal_render_string (terminal_structure * terminal, char * string, uint colour, uint effect, uint x, uint y) { - for (uint index = 0; string [index] != '\0'; ++index) { +static v0 terminal_render_string (terminal_structure * terminal, c1 * string, u4 colour, u4 effect, u4 x, u4 y) { + for (u4 index = 0; string [index] != '\0'; ++index) { terminal_render_character (terminal, string [index], colour, effect, x + index, y); } } -static void terminal_render_number (terminal_structure * terminal, int number, uint colour, uint effect, uint x, uint y) { +static v0 terminal_render_number (terminal_structure * terminal, s4 number, u4 colour, u4 effect, u4 x, u4 y) { terminal_render_string (terminal, number_to_string (number), colour, effect, x, y); } -static void terminal_render_string_crop (terminal_structure * terminal, char * string, uint colour, uint effect, uint x, uint y, uint crop) { - for (uint index = 0; (string [index] != '\0') && (index < crop); ++index) { +static v0 terminal_render_string_crop (terminal_structure * terminal, c1 * string, u4 colour, u4 effect, u4 x, u4 y, u4 crop) { + for (u4 index = 0; (string [index] != '\0') && (index < crop); ++index) { terminal_render_character (terminal, string [index], colour, effect, x + index, y); } } -static void terminal_render_number_crop (terminal_structure * terminal, int number, uint colour, uint effect, uint x, uint y, uint crop) { +static v0 terminal_render_number_crop (terminal_structure * terminal, s4 number, u4 colour, u4 effect, u4 x, u4 y, u4 crop) { terminal_render_string_crop (terminal, number_to_string (number), colour, effect, x, y, crop); } -static void terminal_render_vertical_line (terminal_structure * terminal, char character, uint colour, uint effect, uint x, uint y, uint height) { - for (uint offset = 0; offset != height; ++offset) { +static v0 terminal_render_vertical_line (terminal_structure * terminal, c1 character, u4 colour, u4 effect, u4 x, u4 y, u4 height) { + for (u4 offset = 0; offset != height; ++offset) { terminal_render_character (terminal, character, colour, effect, x, y + offset); } } -static void terminal_render_horizontal_line (terminal_structure * terminal, char character, uint colour, uint effect, uint x, uint y, uint width) { - for (uint offset = 0; offset != width; ++offset) { +static v0 terminal_render_horizontal_line (terminal_structure * terminal, c1 character, u4 colour, u4 effect, u4 x, u4 y, u4 width) { + for (u4 offset = 0; offset != width; ++offset) { terminal_render_character (terminal, character, colour, effect, x + offset, y); } } -static void terminal_render_rectangle_line (terminal_structure * terminal, char character, uint colour, uint effect, uint x, uint y, uint width, uint height) { +static v0 terminal_render_rectangle_line (terminal_structure * terminal, c1 character, u4 colour, u4 effect, u4 x, u4 y, u4 width, u4 height) { terminal_render_vertical_line (terminal, character, colour, effect, x + 0, y + 0, height + 0); terminal_render_vertical_line (terminal, character, colour, effect, x + width - 1, y + 0, height + 0); terminal_render_horizontal_line (terminal, character, colour, effect, x + 1, y + 0, width - 1); terminal_render_horizontal_line (terminal, character, colour, effect, x + 1, y + height - 1, width - 1); } -static void terminal_render_rectangle_fill (terminal_structure * terminal, char character, uint colour, uint effect, uint x, uint y, uint width, uint height) { - for (uint offset_y = 0; offset_y != height; ++offset_y) { - for (uint offset_x = 0; offset_x != width; ++offset_x) { +static v0 terminal_render_rectangle_fill (terminal_structure * terminal, c1 character, u4 colour, u4 effect, u4 x, u4 y, u4 width, u4 height) { + for (u4 offset_y = 0; offset_y != height; ++offset_y) { + for (u4 offset_x = 0; offset_x != width; ++offset_x) { terminal_render_character (terminal, character, colour, effect, x + offset_x, y + offset_y); } } } -static void terminal_render_background (terminal_structure * terminal, char character, uint colour, uint effect) { - for (uint y = 0; y != terminal->screen_height; ++y) { - for (uint x = 0; x != terminal->screen_width; ++x) { +static v0 terminal_render_background (terminal_structure * terminal, c1 character, u4 colour, u4 effect) { + for (u4 y = 0; y != terminal->screen_height; ++y) { + for (u4 x = 0; x != terminal->screen_width; ++x) { terminal_render_character (terminal, character, colour, effect, x, y); } } } -static void terminal_render_format (terminal_structure * terminal, char * format, uint x, uint y, ...) { +static v0 terminal_render_format (terminal_structure * terminal, c1 * format, u4 x, u4 y, ...) { va_list list; - uint offset_x = 0; - uint offset_y = 0; + u4 offset_x = 0; + u4 offset_y = 0; colour_enumeration colour = colour_white; effect_enumeration effect = effect_normal; @@ -311,27 +311,27 @@ static void terminal_render_format (terminal_structure * terminal, char * format ++offset_x; } break; case ('i'): { - char * number = number_to_string (va_arg (list, int)); + c1 * number = number_to_string (va_arg (list, int)); terminal_render_string (terminal, number, colour, effect, x + offset_x, y + offset_y); offset_x += string_length (number); } break; case ('t'): { - bool toggle = (bool) va_arg (list, int); + b4 toggle = (b4) va_arg (list, int); terminal_render_toggle (terminal, toggle, x + offset_x, y + offset_y); offset_x += 3; } break; case ('b'): { - bool boolean = (bool) va_arg (list, int); - terminal_render_string (terminal, (boolean == true) ? "true" : "false", colour, effect, x + offset_x, y + offset_y); - offset_x += (boolean == true) ? 4 : 5; + b4 b4ean = (b4) va_arg (list, int); + terminal_render_string (terminal, (b4ean == true) ? "true" : "false", colour, effect, x + offset_x, y + offset_y); + offset_x += (b4ean == true) ? 4 : 5; } break; case ('c'): { - char character = (char) va_arg (list, int); + c1 character = (char) va_arg (list, int); terminal_render_character (terminal, character, colour, effect, x + offset_x, y + offset_y); ++offset_x; } break; case ('s'): { - char * string = va_arg (list, char *); + c1 * string = va_arg (list, c1 *); terminal_render_string (terminal, string, colour, effect, x + offset_x, y + offset_y); offset_x += string_length (string); } break; diff --git a/xhallenge.c b/xhallenge.c index b530ec5..e4e03ca 100755 --- a/xhallenge.c +++ b/xhallenge.c @@ -15,35 +15,35 @@ typedef enum { } special_enumeration; typedef struct { - uint count; - uint limit; - uint * completed; - uint * * requirement; - uint * type; - char * * class; - char * * description; + u4 count; + u4 limit; + u4 * completed; + u4 * * requirement; + u4 * type; + c1 * * class; + c1 * * description; } challenge_structure; -static char * special_name [special_count] = { +static c1 * special_name [special_count] = { "strength", "perception", "edurance", "charisma", "intelligence", "agility", "luck" }; -static bool challenge_is_repeatable (challenge_structure * challenges, uint index) { +static b4 challenge_is_repeatable (challenge_structure * challenges, u4 index) { return ((challenges->type [index] == special_strength + 1) || (challenges->type [index] == special_edurance + 1) || (challenges->type [index] == special_agility + 1)); } -static bool challenge_is_available (challenge_structure * challenges, uint index) { +static b4 challenge_is_available (challenge_structure * challenges, u4 index) { return ((challenges->completed [index] == 0) || (challenge_is_repeatable (challenges, index) == true)); } -static bool challenge_is_completable (uint * special, challenge_structure * challenges, uint index) { +static b4 challenge_is_completable (u4 * special, challenge_structure * challenges, u4 index) { if (challenge_is_available (challenges, index) == false) { return (false); } - for (uint check = 0; check < special_count; ++check) { + for (u4 check = 0; check < special_count; ++check) { if (challenges->requirement [index] [check] > special [check]) { return (false); } @@ -52,11 +52,11 @@ static bool challenge_is_completable (uint * special, challenge_structure * chal return (true); } -static void render_challenge_list (terminal_structure * terminal, uint * special, challenge_structure * challenges, uint x, uint y) { - uint count = 0; - uint * array = allocate (challenges->count * sizeof (* array)); +static v0 render_challenge_list (terminal_structure * terminal, u4 * special, challenge_structure * challenges, u4 x, u4 y) { + u4 count = 0; + u4 * array = allocate (challenges->count * sizeof (* array)); - for (uint index = 0; index < challenges->count; ++index) { + for (u4 index = 0; index < challenges->count; ++index) { if (challenge_is_completable (special, challenges, index) == true) { ++count; array [count - 1] = index; @@ -66,10 +66,10 @@ static void render_challenge_list (terminal_structure * terminal, uint * special terminal_render_format (terminal, "Count of unlocked challenges: /2/B%i", x, y + 0, count); terminal_render_format (terminal, "Count of locked challenges: /1/B%i", x, y + 1, challenges->count - count); - for (uint index = 0; index < count; ++index) { + for (u4 index = 0; index < count; ++index) { terminal_render_character (terminal, '[', colour_grey, effect_bold, x, y + index + 2); - for (uint value = 0; value < special_count; ++value) { + for (u4 value = 0; value < special_count; ++value) { terminal_render_number (terminal, challenges->requirement [array [index]] [value], value + 1, effect_bold, x + 3 * value + 2, y + index + 2); } @@ -83,12 +83,12 @@ static void render_challenge_list (terminal_structure * terminal, uint * special array = deallocate (array); } -static void render_special_attributes (terminal_structure * terminal, uint * special, uint offset, uint selection) { - for (uint index = 0; index < special_count; ++index) { - uint effect = (selection == index) ? effect_bold : effect_normal; - uint length = attribute_maximum + 3; +static v0 render_special_attributes (terminal_structure * terminal, u4 * special, u4 offset, u4 selection) { + for (u4 index = 0; index < special_count; ++index) { + u4 effect = (selection == index) ? effect_bold : effect_normal; + u4 length = attribute_maximum + 3; - char name [32] = ""; + c1 name [32] = ""; string_copy_limit (name, special_name [index], sizeof (name)); @@ -98,13 +98,13 @@ static void render_special_attributes (terminal_structure * terminal, uint * spe } } -static void prompt_special_attributes (uint * special) { +static v0 prompt_special_attributes (u4 * special) { terminal_structure * terminal = terminal_initialize (); - uint selection = 0; - bool show_help = false; + u4 selection = 0; + b4 show_help = false; - char * main_messages [] = { + c1 * main_messages [] = { "Press H or Tab to toggle help.", "Press Q or Escape to use default settings.", "Press S or Enter to save changes.", @@ -112,7 +112,7 @@ static void prompt_special_attributes (uint * special) { "Choose your SPECIAL attributes:" }; - char * help_messages [] = { + c1 * help_messages [] = { "Show help - H or Tab", "Use default settings - Q or Escape", "Save and quit - S or Enter", @@ -122,22 +122,22 @@ static void prompt_special_attributes (uint * special) { "Decrease attribute - N, Left arrow key or KP4" }; - for (uint index = 0; index < special_count; ++index) { + for (u4 index = 0; index < special_count; ++index) { special [index] = 5; } while (terminal->active == true) { terminal_render_background (terminal, ' ', colour_white, effect_normal); - for (uint index = 0; index < array_length (main_messages); ++index) { + for (u4 index = 0; index < array_length (main_messages); ++index) { terminal_render_string (terminal, main_messages [index], colour_white, effect_normal, 0, index); } render_special_attributes (terminal, special, array_length (main_messages) + 1, selection); if (show_help == true) { - for (uint index = 0; index < array_length (help_messages); ++index) { - uint offset = array_length (main_messages) + special_count + 2; + for (u4 index = 0; index < array_length (help_messages); ++index) { + u4 offset = array_length (main_messages) + special_count + 2; terminal_render_string (terminal, help_messages [index], colour_white, effect_normal, 0, index + offset); } @@ -148,7 +148,7 @@ static void prompt_special_attributes (uint * special) { if ((terminal->signal [signal_tabulator] == true) || (terminal->signal [signal_h] == true)) { show_help = ! show_help; } else if ((terminal->signal [signal_escape] == true) || (terminal->signal [signal_q] == true)) { - for (uint index = 0; index < special_count; ++index) { + for (u4 index = 0; index < special_count; ++index) { special [index] = 5; } break; } else if ((terminal->signal [signal_return] == true) || (terminal->signal [signal_s] == true)) { @@ -169,11 +169,11 @@ static void prompt_special_attributes (uint * special) { terminal = terminal_deinitialize (terminal); } -static void import_user_configuration (uint * special, uint challenge_count, uint * * daily_challenges, bool * * completition) { - bool special_defined [special_count] = { false }; +static v0 import_user_configuration (u4 * special, u4 challenge_count, u4 * * daily_challenges, b4 * * completition) { + b4 special_defined [special_count] = { false }; - bool daily_challenges_defined = false; - bool completition_defined = false; + b4 daily_challenges_defined = false; + b4 completition_defined = false; script_information * information = allocate (sizeof (* information)); script_structure * structure = script_open (configuration_format ("xhallenge.cfg")); @@ -181,21 +181,21 @@ static void import_user_configuration (uint * special, uint challenge_count, uin for (script_word_type word = script_parser (structure); word != script_end; word = script_parser (structure)) { if (word == script_marker) { if (script_compare (structure, "challenges") == true) { - uint check = 0; + u4 check = 0; script_failure (structure, daily_challenges_defined == true, "Challenge array was already defined."); (* daily_challenges) = script_expect_ordered_array (information, structure, & check); daily_challenges_defined = true; script_failure (structure, check != challenges_per_day, "Ordered array 'daily_challenges' is incomplete."); - for (uint index = 0; index < challenges_per_day; ++index) { + for (u4 index = 0; index < challenges_per_day; ++index) { script_failure (structure, (* daily_challenges) [index] >= challenge_count, "Invalid index."); } } else if (script_compare (structure, "completition") == true) { - uint check = 0; + u4 check = 0; script_failure (structure, completition_defined == true, "Completition array was already defined."); (* completition) = script_expect_ordered_array (information, structure, & check); completition_defined = true; script_failure (structure, check != challenges_per_day, "Ordered array 'completition' is incomplete."); - } else for (uint index = 0; index < special_count; ++index) { + } else for (u4 index = 0; index < special_count; ++index) { if (script_compare (structure, special_name [index]) == true) { script_failure (structure, special_defined [index] == true, "Attribute was already defined."); special [index] = script_expect_number (structure); @@ -215,15 +215,15 @@ static void import_user_configuration (uint * special, uint challenge_count, uin information = deallocate (information); } -static void export_user_configuration (uint * special, uint * daily_challenges, bool * completition) { - char buffer [4096] = ""; +static v0 export_user_configuration (u4 * special, u4 * daily_challenges, b4 * completition) { + c1 buffer [4096] = ""; - for (uint index = 0; index < special_count; ++index) { + for (u4 index = 0; index < special_count; ++index) { string_concatenate (buffer, format ("%s = %i\n", special_name [index], special [index])); } string_concatenate (buffer, "challenges = ("); - for (uint index = 0; index < challenges_per_day; ++index) { + for (u4 index = 0; index < challenges_per_day; ++index) { string_concatenate (buffer, number_to_string (daily_challenges [index])); if (index < challenges_per_day - 1) { @@ -233,7 +233,7 @@ static void export_user_configuration (uint * special, uint * daily_challenges, string_concatenate (buffer, ")\n"); string_concatenate (buffer, "completition = ("); - for (uint index = 0; index < challenges_per_day; ++index) { + for (u4 index = 0; index < challenges_per_day; ++index) { string_concatenate (buffer, number_to_string (completition [index])); if (index < challenges_per_day - 1) { @@ -245,7 +245,7 @@ static void export_user_configuration (uint * special, uint * daily_challenges, configuration_export ("xhallenge.cfg", buffer); } -static challenge_structure * challenges_initialize (uint limit) { +static challenge_structure * challenges_initialize (u4 limit) { challenge_structure * challenges = allocate (sizeof (* challenges)); challenges->limit = limit; @@ -254,7 +254,7 @@ static challenge_structure * challenges_initialize (uint limit) { } static challenge_structure * challenges_deinitialize (challenge_structure * challenges) { - for (uint index = 0; index < challenges->count; ++index) { + for (u4 index = 0; index < challenges->count; ++index) { challenges->requirement [index] = deallocate (challenges->requirement [index]); challenges->description [index] = deallocate (challenges->description [index]); challenges->class [index] = deallocate (challenges->class [index]); @@ -269,12 +269,12 @@ static challenge_structure * challenges_deinitialize (challenge_structure * chal return (deallocate (challenges)); } -static void import_challenges (challenge_structure * challenges) { - bool completed_defined = false; - bool requirement_defined = false; - bool type_defined = false; - bool class_defined = false; - bool description_defined = false; +static v0 import_challenges (challenge_structure * challenges) { + b4 completed_defined = false; + b4 requirement_defined = false; + b4 type_defined = false; + b4 class_defined = false; + b4 description_defined = false; script_information * information = allocate (sizeof (* information)); script_structure * structure = script_open (configuration_format ("xhallenge_list.cfg")); @@ -302,13 +302,13 @@ static void import_challenges (challenge_structure * challenges) { class_defined = false; description_defined = false; } else if (word == script_marker) { - uint current = challenges->count - 1; + u4 current = challenges->count - 1; if (script_compare (structure, "completed") == true) { script_failure (structure, completed_defined == true, "Marker 'completed' already defined."); challenges->completed [current] = script_expect_number (structure); completed_defined = true; } else if (script_compare (structure, "requirement") == true) { - uint check = 0; + u4 check = 0; script_failure (structure, requirement_defined == true, "Marker 'requirement' already defined."); challenges->requirement [current] = script_expect_ordered_array (information, structure, & check); requirement_defined = true; @@ -339,16 +339,16 @@ static void import_challenges (challenge_structure * challenges) { information = deallocate (information); } -static void export_challenges (challenge_structure * challenges) { - int file = file_open (configuration_format ("xhallenge_list.cfg"), file_flag_edit | file_flag_truncate); +static v0 export_challenges (challenge_structure * challenges) { + s4 file = file_open (configuration_format ("xhallenge_list.cfg"), file_flag_edit | file_flag_truncate); - for (uint index = 0; index < challenges->count; ++index) { + for (u4 index = 0; index < challenges->count; ++index) { file_echo (file, "[] "); file_echo (file, format ("completed = %i ", challenges->completed [index])); file_echo (file, "requirement = ("); - for (uint subindex = 0; subindex < special_count; ++subindex) { + for (u4 subindex = 0; subindex < special_count; ++subindex) { file_echo (file, number_to_string (challenges->requirement [index] [subindex])); if (subindex < special_count - 1) { @@ -365,9 +365,9 @@ static void export_challenges (challenge_structure * challenges) { file = file_close (file); } -static uint generate_challenge (uint * special, challenge_structure * challenges) { - uint index = urandomize (0, challenges->count - 1); - bool valid = false; +static u4 generate_challenge (u4 * special, challenge_structure * challenges) { + u4 index = urandomize (0, challenges->count - 1); + b4 valid = false; while (valid == false) { valid = true; @@ -375,7 +375,7 @@ static uint generate_challenge (uint * special, challenge_structure * challenges if ((challenges->completed [index] > 0) && (challenges->type [index] != 1) && (challenges->type [index] != 3)) continue; - for (uint check = 0; check < special_count; ++check) { + for (u4 check = 0; check < special_count; ++check) { if (challenges->requirement [index] [check] > special [check]) { valid = false; break; @@ -386,23 +386,23 @@ static uint generate_challenge (uint * special, challenge_structure * challenges return (index); } -static void generate_challenges (uint * special, challenge_structure * challenges, uint * * daily_challenges, bool * * completition) { +static v0 generate_challenges (u4 * special, challenge_structure * challenges, u4 * * daily_challenges, b4 * * completition) { (* daily_challenges) = allocate (challenges_per_day * sizeof (* * daily_challenges)); (* completition) = allocate (challenges_per_day * sizeof (* * completition)); - for (uint index = 0; index < challenges_per_day; ++index) { + for (u4 index = 0; index < challenges_per_day; ++index) { (* daily_challenges) [index] = generate_challenge (special, challenges); } } -static void render_challenges (uint * special, challenge_structure * challenges, uint * daily_challenges, bool * completition) { +static v0 render_challenges (u4 * special, challenge_structure * challenges, u4 * daily_challenges, b4 * completition) { terminal_structure * terminal = terminal_initialize (); - uint selection = 0; - bool show_help = false; - bool show_list = false; + u4 selection = 0; + b4 show_help = false; + b4 show_list = false; - char * main_messages [] = { + c1 * main_messages [] = { "Press H or Tab to toggle help.", "Press Q or Escape to quit the program without saving changes.", "Press S or Enter to save changes and quit the program.", @@ -410,7 +410,7 @@ static void render_challenges (uint * special, challenge_structure * challenges, "Your daily challenges:" }; - char * help_messages [] = { + c1 * help_messages [] = { "Show help - H or Tab", "Quit - Q or Escape", "Save and quit - S or Enter", @@ -425,20 +425,20 @@ static void render_challenges (uint * special, challenge_structure * challenges, while (terminal->active == true) { terminal_render_background (terminal, ' ', colour_white, effect_normal); - for (uint index = 0; index < array_length (main_messages); ++index) { + for (u4 index = 0; index < array_length (main_messages); ++index) { terminal_render_string (terminal, main_messages [index], colour_white, effect_normal, 0, index); } - for (uint index = 0; index < challenges_per_day; ++index) { - uint type = challenges->type [daily_challenges [index]]; - char * class = challenges->class [daily_challenges [index]]; - char * description = challenges->description [daily_challenges [index]]; + for (u4 index = 0; index < challenges_per_day; ++index) { + u4 type = challenges->type [daily_challenges [index]]; + c1 * class = challenges->class [daily_challenges [index]]; + c1 * description = challenges->description [daily_challenges [index]]; - uint effect = (selection == index) ? effect_bold : effect_normal; + u4 effect = (selection == index) ? effect_bold : effect_normal; - uint offset = array_length (main_messages) + 2; + u4 offset = array_length (main_messages) + 2; - uint alignment = string_length (class) + 4; + u4 alignment = string_length (class) + 4; terminal_render_toggle (terminal, completition [index], 0, index + offset); @@ -452,9 +452,9 @@ static void render_challenges (uint * special, challenge_structure * challenges, } if (show_help == true) { - uint offset = array_length (main_messages) + challenges_per_day + 3; + u4 offset = array_length (main_messages) + challenges_per_day + 3; - for (uint index = 0; index < array_length (help_messages); ++index) { + for (u4 index = 0; index < array_length (help_messages); ++index) { terminal_render_string (terminal, help_messages [index], colour_white, effect_normal, 0, index + offset); } @@ -483,7 +483,7 @@ static void render_challenges (uint * special, challenge_structure * challenges, daily_challenges [selection] = generate_challenge (special, challenges); completition [selection] = false; } else if (/*(terminal->signal [signal_backspace] == true) || */(terminal->signal [signal_r] == true)) { - for (uint index = 0; index < challenges_per_day; ++index) { + for (u4 index = 0; index < challenges_per_day; ++index) { daily_challenges [index] = generate_challenge (special, challenges); completition [index] = false; } @@ -493,11 +493,11 @@ static void render_challenges (uint * special, challenge_structure * challenges, terminal = terminal_deinitialize (terminal); } -int main (int argc, char * * argv) { - uint special [special_count] = { 0 }; +s4 main (s4 argc, c1 * * argv) { + u4 special [special_count] = { 0 }; - uint * daily_challenges = null; - bool * completition = null; + u4 * daily_challenges = null; + b4 * completition = null; challenge_structure * challenges = challenges_initialize (1024); diff --git a/xhape.h b/xhape.h index f8fe666..e97cff3 100644 --- a/xhape.h +++ b/xhape.h @@ -17,15 +17,15 @@ /// for more details, if you dare, it is a lot of text that nobody wants to read... typedef struct { - uint vertex_count; - uint index_count; - uint vertex_limit; - uint index_limit; - float * vertex_array; - uint * index_array; + u4 vertex_count; + u4 index_count; + u4 vertex_limit; + u4 index_limit; + f4 * vertex_array; + u4 * index_array; } shape_node; -static shape_node * shape_allocate (uint vertex_limit, uint index_limit) { +static shape_node * shape_allocate (u4 vertex_limit, u4 index_limit) { shape_node * shape = allocate (sizeof (* shape)); shape->vertex_limit = vertex_limit; @@ -44,7 +44,7 @@ static shape_node * shape_deallocate (shape_node * shape) { return (deallocate (shape)); } -static void shape_add_vertex_unwrap_colour (shape_node * shape, float x, float y, float z, float u, float v, uint colour) { +static v0 shape_add_vertex_unwrap_colour (shape_node * shape, f4 x, f4 y, f4 z, f4 u, f4 v, u4 colour) { fatal_failure (shape->vertex_count + 9 > shape->vertex_limit, "shape_add_vertex"); if (shape->vertex_count + 9 > shape->vertex_limit) return; @@ -62,7 +62,7 @@ static void shape_add_vertex_unwrap_colour (shape_node * shape, float x, float y shape->vertex_count += 9; } -static void shape_add_index (shape_node * shape, uint a, uint b, uint c) { +static v0 shape_add_index (shape_node * shape, u4 a, u4 b, u4 c) { fatal_failure (shape->index_count + 3 > shape->index_limit, "shape_add_index"); if (shape->index_count + 3 > shape->index_limit) return; @@ -74,24 +74,24 @@ static void shape_add_index (shape_node * shape, uint a, uint b, uint c) { shape->index_count += 3; } -//~static shape_node * shape_tetrahedron_unwrap (float x, float y, float z, float scale) { -//~static shape_node * shape_tetrahedron_unwrap_colour (float x, float y, float z, float scale, uint colour) { -static shape_node * shape_tetrahedron_colour (float x, float y, float z, float scale, uint colour) { +//~static shape_node * shape_tetrahedron_unwrap (f4 x, f4 y, f4 z, f4 scale) { +//~static shape_node * shape_tetrahedron_unwrap_colour (f4 x, f4 y, f4 z, f4 scale, u4 colour) { +static shape_node * shape_tetrahedron_colour (f4 x, f4 y, f4 z, f4 scale, u4 colour) { shape_node * shape = shape_allocate (4 * 9, 4 * 3); - float vertices [12] = { + f4 vertices [12] = { x + scale, y + scale, z + scale, x - scale, y - scale, z + scale, x - scale, y + scale, z - scale, x + scale, y - scale, z - scale }; - for (uint vertex = 0; vertex < 4; ++vertex) { - float x = vertices [3 * vertex + 0]; - float y = vertices [3 * vertex + 1]; - float z = vertices [3 * vertex + 2]; - float u = (binary_sign (vertex >> 0) + 1.0f) / 2.0f; - float v = (binary_sign (vertex >> 1) + 1.0f) / 2.0f; + for (u4 vertex = 0; vertex < 4; ++vertex) { + f4 x = vertices [3 * vertex + 0]; + f4 y = vertices [3 * vertex + 1]; + f4 z = vertices [3 * vertex + 2]; + f4 u = (binary_sign (vertex >> 0) + 1.0f) / 2.0f; + f4 v = (binary_sign (vertex >> 1) + 1.0f) / 2.0f; shape_add_vertex_unwrap_colour (shape, x, y, z, u, v, colour); } @@ -104,12 +104,12 @@ static shape_node * shape_tetrahedron_colour (float x, float y, float z, float s return (shape); } -//~static shape_node * shape_square (vector_3 * origin, float scale, uint colour) { +//~static shape_node * shape_square (vector_3 * origin, f4 scale, u4 colour) { //~shape_node * shape = shape_allocate (4, 2 * 3); //~shape_set_origin (shape, origin); - //~float central = square_root (2.0f) * scale / 2.0f; + //~f4 central = square_root (2.0f) * scale / 2.0f; //~vector_4 normal_colour = { //~normal_r (colour), @@ -118,8 +118,8 @@ static shape_node * shape_tetrahedron_colour (float x, float y, float z, float s //~normal_a (colour) //~}; - //~for (uint vertex = 0; vertex < 4; ++vertex) { - //~vector_3 point = { + //~for (u4 vertex = 0; vertex < 4; ++vertex) { + //~vector_3 pos4 = { //~origin->x + binary_sign (vertex >> 0) * central, //~origin->y + binary_sign (vertex >> 1) * central, //~origin->z @@ -139,12 +139,12 @@ static shape_node * shape_tetrahedron_colour (float x, float y, float z, float s //~return (shape); //~} -//~static shape_node * shape_cube (vector_3 * origin, float scale, uint colour) { +//~static shape_node * shape_cube (vector_3 * origin, f4 scale, u4 colour) { //~shape_node * shape = shape_allocate (8, 12 * 3); //~shape_set_origin (shape, origin); - //~float central = square_root (3.0f) * scale / 2.0f; + //~f4 central = square_root (3.0f) * scale / 2.0f; //~vector_4 normal_colour = { //~normal_r (colour), @@ -153,8 +153,8 @@ static shape_node * shape_tetrahedron_colour (float x, float y, float z, float s //~normal_a (colour) //~}; - //~for (uint vertex = 0; vertex < 8; ++vertex) { - //~vector_3 point = { + //~for (u4 vertex = 0; vertex < 8; ++vertex) { + //~vector_3 pos4 = { //~origin->x + binary_sign (vertex >> 0) * central, //~origin->y + binary_sign (vertex >> 1) * central, //~origin->z + binary_sign (vertex >> 2) * central diff --git a/xiasma.h b/xiasma.h index de68aa4..93fd0e2 100755 --- a/xiasma.h +++ b/xiasma.h @@ -115,19 +115,19 @@ enum { register_8, register_9, register_10, register_11, register_12, register_13, register_14, register_15 }; -static int empty_count = 0; -static int empty_holes = 1; -static int * empty_array = null; -static int * empty_imbue = null; -static int * empty_store = null; +static s4 empty_count = 0; +static s4 empty_holes = 1; +static s4 * empty_array = null; +static s4 * empty_imbue = null; +static s4 * empty_store = null; -static int text_sector_size = 0; -static int data_sector_size = 0; +static s4 text_sector_size = 0; +static s4 data_sector_size = 0; -static unsigned char * text_sector_byte = null; -static unsigned char * data_sector_byte = null; +static unsigned c1 * text_sector_byte = null; +static unsigned c1 * data_sector_byte = null; -static unsigned char elf_main_header_byte [elf_main_header_size] = { +static unsigned c1 elf_main_header_byte [elf_main_header_size] = { 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x3e, 0x00, 0x01, 0x00, 0x00, 0x00, @@ -138,7 +138,7 @@ static unsigned char elf_main_header_byte [elf_main_header_size] = { 0x02, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static unsigned char elf_text_sector_byte [elf_text_sector_size] = { +static unsigned c1 elf_text_sector_byte [elf_text_sector_size] = { 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -148,7 +148,7 @@ static unsigned char elf_text_sector_byte [elf_text_sector_size] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static unsigned char elf_data_sector_byte [elf_data_sector_size] = { +static unsigned c1 elf_data_sector_byte [elf_data_sector_size] = { 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -158,27 +158,27 @@ static unsigned char elf_data_sector_byte [elf_data_sector_size] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static int front (int data) { return ((data >= register_4) && (data <= register_7)); } -static int lower (int data) { return ((data >= register_0) && (data <= register_7)); } -static int upper (int data) { return ((data >= register_8) && (data <= register_15)); } +static s4 front (s4 data) { return ((data >= register_4) && (data <= register_7)); } +static s4 lower (s4 data) { return ((data >= register_0) && (data <= register_7)); } +static s4 upper (s4 data) { return ((data >= register_8) && (data <= register_15)); } -static int far (int label) { return (label && 1); } -static int near (int label) { return (label && 0); } +static s4 far (s4 label) { return (label && 1); } +static s4 near (s4 label) { return (label && 0); } -static void inset (int when, int data) { +static v0 inset (s4 when, s4 data) { text_sector_byte [text_sector_size] = (unsigned char) data; text_sector_size += (unsigned int) when; } -static void inset_immediate (int when, int size, int data) { +static v0 inset_immediate (s4 when, s4 size, s4 data) { inset ((when), (data >> 0) & 0xff); inset ((when) && (size >= size_16), (data >> 8) & 0xff); inset ((when) && (size >= size_32), (data >> 16) & 0xff); inset ((when) && (size >= size_32), (data >> 24) & 0xff); } -static void inset_memory (int when, int size, int data, int base) { +static v0 inset_memory (s4 when, s4 size, s4 data, s4 base) { empty_array [empty_holes] = text_sector_size; empty_imbue [empty_holes] = data; @@ -187,8 +187,8 @@ static void inset_memory (int when, int size, int data, int base) { inset_immediate (when, size, base); } -static int store_relative (int * array) { - int relative = array [1]; +static s4 store_relative (s4 * array) { + s4 relative = array [1]; empty_array [empty_holes] = text_sector_size; empty_imbue [empty_holes] = relative; @@ -198,8 +198,8 @@ static int store_relative (int * array) { return (1); } -static int store_memory (int * array) { - int operation = array [0], +static s4 store_memory (s4 * array) { + s4 operation = array [0], memory = array [1]; empty_store [memory] = text_sector_size; @@ -209,8 +209,8 @@ static int store_memory (int * array) { return (1); } -static int store_immediate (int * array) { - int index = 0, +static s4 store_immediate (s4 * array) { + s4 index = 0, operation = array [0], size = array [1], amount = array [2]; @@ -222,41 +222,41 @@ static int store_immediate (int * array) { return (amount + 2); } -static void short_prefix (int size) { +static v0 short_prefix (s4 size) { inset (size == size_16, 0x66); } -static void long_prefix (int size, int to, int destination, int from, int source) { - int to_upper = (to == for_register) && (upper (destination)), +static v0 long_prefix (s4 size, s4 to, s4 destination, s4 from, s4 source) { + s4 to_upper = (to == for_register) && (upper (destination)), from_upper = (from == for_register) && (upper (source)), extension = (size == size_64); inset (extension || to_upper || from_upper, 0x40 + 0x01 * to_upper + 0x04 * from_upper + 0x08 * extension); } -static void modify_registers (int to, int destination, int from, int source) { - int to_register_from_register = ((to == for_register) && (from == for_register)); +static v0 modify_registers (s4 to, s4 destination, s4 from, s4 source) { + s4 to_register_from_register = ((to == for_register) && (from == for_register)); inset (to_register_from_register, 0xc0 + 0x01 * (destination & 0x07) + 0x08 * (source & 0x07)); } -static void modify_memory (int operation, int to, int from) { - int to_register_from_memory = ((to == for_register) && (from == for_memory)), +static v0 modify_memory (s4 operation, s4 to, s4 from) { + s4 to_register_from_memory = ((to == for_register) && (from == for_memory)), to_memory_from_register = ((to == for_memory) && (from == for_register)), to_memory_from_immediate = ((to == for_memory) && (from == for_immediate)); inset (to_register_from_memory || to_memory_from_register, 0x05 + 0x08 * operation * to_memory_from_immediate); } -static int build_double (int * array) { - int operation = array [0], +static s4 build_f8 (s4 * array) { + s4 operation = array [0], size = array [1], to = array [2], destination = array [3], from = array [4], source = array [5]; - int to_register_from_register = ((to == for_register) && (from == for_register)), + s4 to_register_from_register = ((to == for_register) && (from == for_register)), to_register_from_memory = ((to == for_register) && (from == for_memory)), to_register_from_immediate = ((to == for_register) && (from == for_immediate)), to_register_from_relative = ((to == for_register) && (from == for_relative)), @@ -286,13 +286,13 @@ static int build_double (int * array) { return (5); } -static int build_single (int * array) { - int operation = array [0], +static s4 build_single (s4 * array) { + s4 operation = array [0], size = array [1], to = array [2], destination = array [3]; - int irregularity = ((operation == increment) || (operation == decrement)); + s4 irregularity = ((operation == increment) || (operation == decrement)); short_prefix (size); @@ -310,10 +310,10 @@ static int build_single (int * array) { return (3); } -static int build_static_1 (int * array) { - int operation = array [0]; +static s4 build_static_1 (s4 * array) { + s4 operation = array [0]; - unsigned char data [] = { + unsigned c1 data [] = { 0x90, 0xc3, 0xcb, 0xc9, 0x9d, 0x9c }; @@ -322,10 +322,10 @@ static int build_static_1 (int * array) { return (0); } -static int build_static_2 (int * array) { - int operation = array [0]; +static s4 build_static_2 (s4 * array) { + s4 operation = array [0]; - unsigned short data [] = { + unsigned s2 data [] = { 0x050f, 0xa20f, 0xd0d9, 0xe0d9, 0xe1d9, 0xe4d9, 0xe5d9, 0xe8d9, 0xe9d9, 0xead9, 0xebd9, 0xecd9, 0xedd9, 0xeed9, 0xf0d9, 0xf1d9, 0xf2d9, 0xf3d9, 0xf4d9, 0xf5d9, 0xf6d9, 0xf7d9, 0xf8d9, 0xf9d9, @@ -337,8 +337,8 @@ static int build_static_2 (int * array) { return (0); } -static int build_jump_if (int * array) { - int operation = array [0], +static s4 build_jump_if (s4 * array) { + s4 operation = array [0], size = array [1], location = array [3]; @@ -352,8 +352,8 @@ static int build_jump_if (int * array) { return (3); } -static int build_move_if (int * array) { - int operation = array [0], +static s4 build_move_if (s4 * array) { + s4 operation = array [0], size = array [1], to = array [2], destination = array [3], @@ -374,8 +374,8 @@ static int build_move_if (int * array) { return (5); } -static int build_set_if (int * array) { - int operation = array [0], +static s4 build_set_if (s4 * array) { + s4 operation = array [0], to = array [2], destination = array [3]; @@ -393,8 +393,8 @@ static int build_set_if (int * array) { return (3); } -static int build_jump (int * array) { - int operation = array [0], +static s4 build_jump (s4 * array) { + s4 operation = array [0], size = array [1], to = array [2], destination = array [3]; @@ -413,8 +413,8 @@ static int build_jump (int * array) { return (3); } -static int build_move (int * array) { - int operation = array [0], +static s4 build_move (s4 * array) { + s4 operation = array [0], size = array [1], to = array [2], destination = array [3], @@ -454,8 +454,8 @@ static int build_move (int * array) { return (5 + (size == size_64)); } -static int build_call (int * array) { - int operation = array [0], +static s4 build_call (s4 * array) { + s4 operation = array [0], from = array [1], source = array [2]; @@ -471,8 +471,8 @@ static int build_call (int * array) { return (2); } -static int build_enter (int * array) { - int operation = array [0], +static s4 build_enter (s4 * array) { + s4 operation = array [0], dynamic_storage = array [1], nesting_level = array [2]; @@ -484,8 +484,8 @@ static int build_enter (int * array) { return (2); } -static int build_float (int * array) { - int operation = array [0], +static s4 build_f4 (s4 * array) { + s4 operation = array [0], size = array [1], from = array [2], source = array [3]; @@ -499,8 +499,8 @@ static int build_float (int * array) { return (3); } -static int build_shift (int * array) { - int operation = array [0], +static s4 build_shift (s4 * array) { + s4 operation = array [0], size = array [1], to = array [2], destination = array [3], @@ -521,8 +521,8 @@ static int build_shift (int * array) { return (5); } -static int build_in_out (int * array) { - int move = array [0], +static s4 build_in_out (s4 * array) { + s4 move = array [0], size = array [1], type = array [2], port = array [3]; @@ -536,8 +536,8 @@ static int build_in_out (int * array) { return (3); } -static int build_pop (int * array) { - int operation = array [0], +static s4 build_pop (s4 * array) { + s4 operation = array [0], size = array [1], to = array [2], destination = array [3]; @@ -555,8 +555,8 @@ static int build_pop (int * array) { return (3); } -static int build_push (int * array) { - int operation = array [0], +static s4 build_push (s4 * array) { + s4 operation = array [0], size = array [1], from = array [2], source = array [3]; @@ -576,8 +576,8 @@ static int build_push (int * array) { return (3); } -static int build_swap (int * array) { - int operation = array [0], +static s4 build_swap (s4 * array) { + s4 operation = array [0], size = array [1], destination = array [3]; @@ -589,8 +589,8 @@ static int build_swap (int * array) { return (3); } -static int build_bit_scan (int * array) { - int operation = array [0], +static s4 build_bit_scan (s4 * array) { + s4 operation = array [0], size = array [1], destination = array [3], from = array [4], @@ -611,8 +611,8 @@ static int build_bit_scan (int * array) { return (5); } -static int build_loop (int * array) { - int operation = array [0], +static s4 build_loop (s4 * array) { + s4 operation = array [0], location = array [3]; inset (operation == loop_not_equal, 0xe0); @@ -624,8 +624,8 @@ static int build_loop (int * array) { return (3); } -static void elf_main_header (void) { - int enter = empty_store [0] + 0x4000b0; +static v0 elf_main_header (v0) { + s4 enter = empty_store [0] + 0x4000b0; elf_main_header_byte [16] = 0x02; elf_main_header_byte [ 7] = 0x03; @@ -634,17 +634,17 @@ static void elf_main_header (void) { memory_copy (& elf_main_header_byte [24], & enter, sizeof (enter)); } -static void elf_text_sector (unsigned long text_size, unsigned long data_size) { - unsigned long text = elf_header_size + text_size - data_size; +static v0 elf_text_sector (unsigned s8 text_size, unsigned s8 data_size) { + unsigned s8 text = elf_header_size + text_size - data_size; memory_copy (& elf_text_sector_byte [32], & text, (int) sizeof (text)); memory_copy (& elf_text_sector_byte [40], & text, (int) sizeof (text)); } -static void elf_data_sector (unsigned long text_size, unsigned long data_size) { - unsigned long data = data_size; - unsigned long core = elf_header_size + text_size - data_size; - unsigned long move = 0x401000 + core; +static v0 elf_data_sector (unsigned s8 text_size, unsigned s8 data_size) { + unsigned s8 data = data_size; + unsigned s8 core = elf_header_size + text_size - data_size; + unsigned s8 move = 0x401000 + core; memory_copy (& elf_data_sector_byte [ 8], & core, (int) sizeof (core)); memory_copy (& elf_data_sector_byte [16], & move, (int) sizeof (move)); @@ -653,7 +653,7 @@ static void elf_data_sector (unsigned long text_size, unsigned long data_size) { memory_copy (& elf_data_sector_byte [40], & data, (int) sizeof (data)); } -static int (* build_instruction []) (int * array) = { +static s4 (* build_instruction []) (s4 * array) = { store_memory, store_relative, store_immediate, build_double, build_double, build_double, build_double, build_double, build_double, build_double, build_double, build_single, build_single, build_single, build_single, build_single, build_single, build_single, build_single, @@ -674,20 +674,20 @@ static int (* build_instruction []) (int * array) = { build_swap, build_bit_scan, build_bit_scan, build_loop, build_loop, build_loop }; -static int assemble (int count, int * array) { - for (uint index = 0; index < count; ++index) { +static s4 assemble (s4 count, s4 * array) { + for (u4 index = 0; index < count; ++index) { index += build_instruction [array [index]] (& array [index]); } - for (uint index = 1; index < empty_holes; ++index) { - int set = 0; - int get = empty_array [index]; + for (u4 index = 1; index < empty_holes; ++index) { + s4 set = 0; + s4 get = empty_array [index]; - memory_copy ((char *) & set, (char *) & text_sector_byte [get], (int) sizeof (set)); + memory_copy ((c1 *) & set, (c1 *) & text_sector_byte [get], (int) sizeof (set)); set += empty_store [empty_imbue [index]]; - memory_copy ((char *) & text_sector_byte [get], (char *) & set, (int) sizeof (set)); + memory_copy ((c1 *) & text_sector_byte [get], (c1 *) & set, (int) sizeof (set)); } return (log_success); diff --git a/xighlight.c b/xighlight.c index c6178d3..7f77bd3 100755 --- a/xighlight.c +++ b/xighlight.c @@ -20,7 +20,7 @@ #include #include -static void conditionally_exit (language_structure * language, syntax_structure * syntax, bool terminate) { +static v0 conditionally_exit (language_structure * language, syntax_structure * syntax, b4 terminate) { syntax = syntax_deinitialize (syntax); language = language_deinitialize (language); @@ -29,13 +29,13 @@ static void conditionally_exit (language_structure * language, syntax_structure } } -static void print_common (void) { +static v0 print_common (v0) { print ("/B/4xighlight/-: /4Terminal syntax highlighter/-\n\n"); print ("\tAuthor: /4Ognjen 'xolatile' Milan Robovic/-\n"); print ("\tLicense: /4GNU//GPLv3/-\n\n"); } -static void print_help (void) { +static v0 print_help (v0) { print_common (); print ("Example usage:\n\n"); @@ -45,7 +45,7 @@ static void print_help (void) { print ("Supported languages:\n\n"); for (language_enumeration index = 0; index < language_count; ++index) { - char align [32] = ""; + c1 align [32] = ""; print ("\t/B/4%s/- /4%s/- /0---/- %s syntax highlighting\n", language_short_option [index], @@ -54,21 +54,21 @@ static void print_help (void) { } } -static void print_version (void) { +static v0 print_version (v0) { print_common (); print ("\tVersion: /40 (Zero)/-\n"); } -int main (int argc, char * * argv) { - uint select = language_count; - uint length = 0; - char * buffer = null; +s4 main (s4 argc, c1 * * argv) { + u4 select = language_count; + u4 length = 0; + c1 * buffer = null; syntax_structure * syntax = syntax_initialize (360); language_structure * language = language_initialize (false); - for (int argument = 1; argument < argc; ++argument) { + for (s4 argument = 1; argument < argc; ++argument) { if (argument_compare (argv [argument], "-h", "--help") == true) { print_help (); conditionally_exit (language, syntax, true); @@ -77,7 +77,7 @@ int main (int argc, char * * argv) { conditionally_exit (language, syntax, true); } - for (uint index = 0; index < language_count; ++index) { + for (u4 index = 0; index < language_count; ++index) { if (argument_compare (argv [argument], language_short_option [index], language_long_option [index]) == true) { (* (language_highlighter [index])) (language, syntax); select = index; @@ -87,7 +87,7 @@ int main (int argc, char * * argv) { if (file_exists (argv [argument]) == true) { if (select == language_count) { - select = (uint) file_type (argv [argument]); + select = (u4) file_type (argv [argument]); } if (buffer == null) { buffer = file_import (argv [argument]); @@ -105,7 +105,7 @@ int main (int argc, char * * argv) { language_conditionally_select (language, syntax, select); - for (uint offset = 0; buffer [offset] != '\0'; offset += length) { + for (u4 offset = 0; buffer [offset] != '\0'; offset += length) { select = syntax_select (syntax, & buffer [offset], & length); if (select >= syntax->count) { diff --git a/xision.h b/xision.h index 4e20795..c943734 100644 --- a/xision.h +++ b/xision.h @@ -48,70 +48,70 @@ typedef struct { PFNGLBUFFERDATAPROC glBufferData; PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; - bool signal [signal_count]; - bool cursor [cursor_count]; - int cursor_x; - int cursor_y; - - bool using_precomputed_spritesheet; - ulong spritesheet_size; - ulong vertex_limit; - ulong index_limit; - uint gameplay_framerate; - uint animation_framerate; - uint tab_width; - uint default_font; - bool active; - uint window_width; - uint window_height; - float pixel_width; - float pixel_height; - uint framerate; - ulong frame_time; - ulong frame_begin; - ulong frame_end; - uint global_tick; - uint gameplay_tick; - uint animation_tick; - bool freeze_cursor; - bool freeze_signal; - uint vertex_object; - uint vertex_buffer; - uint index_buffer; - uint vertex_shader; - uint fragment_shader; - uint shader_program; - uint spritesheet; - uint vertex_count; - uint index_count; - float * vertex_array; - uint * index_array; - uint sprite_count; - uint font_count; - uint * spritesheet_data; - uint * * sprite_data; - uint * sprite_width; - uint * sprite_height; - float * sprite_u; - float * sprite_v; - uint * * font_index; - uint * * font_width; - uint * * font_height; - char * font_begin; - char * font_end; - float projection_matrix [16]; - float movement_matrix [16]; - float rotation_matrix [16]; - float aspect_ratio; - float field_of_view; - float far_plane; - float near_plane; - float camera_x; - float camera_y; - float sensitivity; + b4 signal [signal_count]; + b4 cursor [cursor_count]; + s4 cursor_x; + s4 cursor_y; + + b4 using_precomputed_spritesheet; + u8 spritesheet_size; + u8 vertex_limit; + u8 index_limit; + u4 gameplay_framerate; + u4 animation_framerate; + u4 tab_width; + u4 default_font; + b4 active; + u4 window_width; + u4 window_height; + f4 pixel_width; + f4 pixel_height; + u4 framerate; + u8 frame_time; + u8 frame_begin; + u8 frame_end; + u4 global_tick; + u4 gameplay_tick; + u4 animation_tick; + b4 freeze_cursor; + b4 freeze_signal; + u4 vertex_object; + u4 vertex_buffer; + u4 index_buffer; + u4 vertex_shader; + u4 fragment_shader; + u4 shader_program; + u4 spritesheet; + u4 vertex_count; + u4 index_count; + f4 * vertex_array; + u4 * index_array; + u4 sprite_count; + u4 font_count; + u4 * spritesheet_data; + u4 * * sprite_data; + u4 * sprite_width; + u4 * sprite_height; + f4 * sprite_u; + f4 * sprite_v; + u4 * * font_index; + u4 * * font_width; + u4 * * font_height; + c1 * font_begin; + c1 * font_end; + f4 projection_matrix [16]; + f4 movement_matrix [16]; + f4 rotation_matrix [16]; + f4 aspect_ratio; + f4 field_of_view; + f4 far_plane; + f4 near_plane; + f4 camera_x; + f4 camera_y; + f4 sensitivity; } vision_structure; -static uint vision_sprite_raw_import (vision_structure * vision, uint * data, uint width, uint height) { +static u4 vision_sprite_raw_import (vision_structure * vision, u4 * data, u4 width, u4 height) { fatal_failure (vision->active == true, "vision_sprite_raw_import: OpenGL renderer is already initialized."); fatal_failure (data == null, "vision_sprite_raw_import: Data is null pointer."); fatal_failure (width == 0, "vision_sprite_raw_import: Font image width is zero."); @@ -134,10 +134,10 @@ static uint vision_sprite_raw_import (vision_structure * vision, uint * data, ui return (vision->sprite_count - 1); } -static uint vision_font_raw_import (vision_structure * vision, uint * data, uint image_width, char begin, char end, uint empty) { - uint pointer = 0; - uint width = 0; - uint height = 0; +static u4 vision_font_raw_import (vision_structure * vision, u4 * data, u4 image_width, c1 begin, c1 end, u4 empty) { + u4 pointer = 0; + u4 width = 0; + u4 height = 0; fatal_failure (vision->active == true, "vision_font_raw_import: OpenGL renderer is already initialized."); fatal_failure (data == null, "vision_font_raw_import: Data is null pointer."); @@ -155,19 +155,19 @@ static uint vision_font_raw_import (vision_structure * vision, uint * data, uint vision->font_begin [vision->font_count - 1] = begin; vision->font_end [vision->font_count - 1] = end; - vision->font_index [vision->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * vision->font_index)); - vision->font_width [vision->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * vision->font_width)); - vision->font_height [vision->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * vision->font_height)); + vision->font_index [vision->font_count - 1] = allocate ((u8) (end - begin + 1) * sizeof (* * vision->font_index)); + vision->font_width [vision->font_count - 1] = allocate ((u8) (end - begin + 1) * sizeof (* * vision->font_width)); + vision->font_height [vision->font_count - 1] = allocate ((u8) (end - begin + 1) * sizeof (* * vision->font_height)); - for (char index = begin; index <= end; ++index) { + for (c1 index = begin; index <= end; ++index) { for ( ; data [pointer] == empty; ++pointer); for (width = 0; data [pointer + width] != empty; ++width); for (height = 0; data [pointer + height * image_width] != empty; ++height); - uint * buffer = allocate (width * height * sizeof (* buffer)); + u4 * buffer = allocate (width * height * sizeof (* buffer)); - for (uint y = 0; y < height; ++y) { - for (uint x = 0; x < width; ++x) { + for (u4 y = 0; y < height; ++y) { + for (u4 x = 0; x < width; ++x) { buffer [y * width + x] = data [pointer + (y * image_width) + x]; } } @@ -188,21 +188,21 @@ static uint vision_font_raw_import (vision_structure * vision, uint * data, uint return (vision->font_count - 1); } -static uint vision_sprite_import (vision_structure * vision, char * path) { - uint width = 0; - uint height = 0; - uint * data = null; +static u4 vision_sprite_import (vision_structure * vision, c1 * path) { + u4 width = 0; + u4 height = 0; + u4 * data = null; data = format_image_import (path, & width, & height); return (vision_sprite_raw_import (vision, data, width, height)); } -static uint vision_font_import (vision_structure * vision, char * path, char begin, char end, uint colour) { - uint width = 0; - uint height = 0; - uint result = 0; - uint * data = null; +static u4 vision_font_import (vision_structure * vision, c1 * path, c1 begin, c1 end, u4 colour) { + u4 width = 0; + u4 height = 0; + u4 result = 0; + u4 * data = null; data = format_image_import (path, & width, & height); @@ -213,30 +213,30 @@ static uint vision_font_import (vision_structure * vision, char * path, char beg return (result); } -static uint vision_sprite_width (vision_structure * vision, uint sprite) { +static u4 vision_sprite_width (vision_structure * vision, u4 sprite) { return (vision->sprite_width [sprite]); } -static uint vision_sprite_height (vision_structure * vision, uint sprite) { +static u4 vision_sprite_height (vision_structure * vision, u4 sprite) { return (vision->sprite_height [sprite]); } -static uint vision_center_x (vision_structure * vision, uint size) { +static u4 vision_center_x (vision_structure * vision, u4 size) { return ((vision->window_width - size) / 2); } -static uint vision_center_y (vision_structure * vision, uint size) { +static u4 vision_center_y (vision_structure * vision, u4 size) { return ((vision->window_height - size) / 2); } -static bool vision_cursor_inside (vision_structure * vision, int x, int y, uint width, uint height) { +static b4 vision_cursor_inside (vision_structure * vision, s4 x, s4 y, u4 width, u4 height) { return ((vision->cursor_x > x) && (vision->cursor_y > y) && (vision->cursor_x < x + (int) width) && (vision->cursor_y < y + (int) height)); } -static bool vision_cursor_left_click (vision_structure * vision, int x, int y, uint width, uint height) { +static b4 vision_cursor_left_click (vision_structure * vision, s4 x, s4 y, u4 width, u4 height) { if (vision->cursor [cursor_left] == true) { vision->freeze_cursor = true; @@ -246,7 +246,7 @@ static bool vision_cursor_left_click (vision_structure * vision, int x, int y, u return (false); } -static bool vision_cursor_right_click (vision_structure * vision, int x, int y, uint width, uint height) { +static b4 vision_cursor_right_click (vision_structure * vision, s4 x, s4 y, u4 width, u4 height) { if (vision->cursor [cursor_right]) { vision->freeze_cursor = true; @@ -256,8 +256,8 @@ static bool vision_cursor_right_click (vision_structure * vision, int x, int y, return (false); } -static void vision_import_spritesheet (vision_structure * vision, char * data_file) { - int file = file_open (data_file, file_flag_read); +static v0 vision_import_spritesheet (vision_structure * vision, c1 * data_file) { + s4 file = file_open (data_file, file_flag_read); fatal_failure (vision->active == true, "vision_import_spritesheet: OpenGL renderer is already initialized."); @@ -286,14 +286,14 @@ static void vision_import_spritesheet (vision_structure * vision, char * data_fi file_read (file, vision->font_begin, vision->font_count * sizeof (* vision->font_begin)); file_read (file, vision->font_end, vision->font_count * sizeof (* vision->font_end)); - for (uint index = 0; index < vision->font_count; ++index) { - uint range = (uint) (vision->font_end [index] - vision->font_begin [index]) + 1; + for (u4 index = 0; index < vision->font_count; ++index) { + u4 range = (u4) (vision->font_end [index] - vision->font_begin [index]) + 1; vision->font_index [index] = allocate (range * sizeof (* * vision->font_index)); vision->font_width [index] = allocate (range * sizeof (* * vision->font_width)); vision->font_height [index] = allocate (range * sizeof (* * vision->font_height)); - for (uint subindex = 0; subindex < range; ++subindex) { + for (u4 subindex = 0; subindex < range; ++subindex) { file_read (file, & vision->font_index [index] [subindex], sizeof (* * vision->font_index)); file_read (file, & vision->font_width [index] [subindex], sizeof (* * vision->font_width)); file_read (file, & vision->font_height [index] [subindex], sizeof (* * vision->font_height)); @@ -306,8 +306,8 @@ static void vision_import_spritesheet (vision_structure * vision, char * data_fi vision->font_count = 0; } -static void vision_export_spritesheet (vision_structure * vision, char * data_file) { - int file = file_open (data_file, file_flag_write | file_flag_create | file_flag_truncate); +static v0 vision_export_spritesheet (vision_structure * vision, c1 * data_file) { + s4 file = file_open (data_file, file_flag_write | file_flag_create | file_flag_truncate); fatal_failure (vision->spritesheet_data == null, "vision_export_spritesheet: OpenGL renderer can't access spritesheet data."); @@ -325,8 +325,8 @@ static void vision_export_spritesheet (vision_structure * vision, char * data_fi file_write (file, vision->font_begin, vision->font_count * sizeof (* vision->font_begin)); file_write (file, vision->font_end, vision->font_count * sizeof (* vision->font_end)); - for (uint index = 0; index < vision->font_count; ++index) { - for (uint subindex = 0; subindex < (uint) (vision->font_end [index] - vision->font_begin [index]) + 1; ++subindex) { + for (u4 index = 0; index < vision->font_count; ++index) { + for (u4 subindex = 0; subindex < (u4) (vision->font_end [index] - vision->font_begin [index]) + 1; ++subindex) { file_write (file, & vision->font_index [index] [subindex], sizeof (* * vision->font_index)); file_write (file, & vision->font_width [index] [subindex], sizeof (* * vision->font_width)); file_write (file, & vision->font_height [index] [subindex], sizeof (* * vision->font_height)); @@ -338,8 +338,8 @@ static void vision_export_spritesheet (vision_structure * vision, char * data_fi print ("/c Exported internal binary data of OpenGL spritesheet."); } -static vision_structure * vision_initialize (uint gameplay_framerate, uint animation_framerate, bool use_precomputed_spritesheet, - uint vertex_limit, uint index_limit, uint spritesheet_side) { +static vision_structure * vision_initialize (u4 gameplay_framerate, u4 animation_framerate, b4 use_precomputed_spritesheet, + u4 vertex_limit, u4 index_limit, u4 spritesheet_side) { vision_structure * vision = allocate (sizeof (* vision)); vision->using_precomputed_spritesheet = use_precomputed_spritesheet; @@ -370,7 +370,7 @@ static vision_structure * vision_initialize (uint gameplay_framerate, uint anima static vision_structure * vision_deinitialize (vision_structure * vision) { vision->active = false; - for (uint index = 0; index < vision->font_count; ++index) { + for (u4 index = 0; index < vision->font_count; ++index) { vision->font_index [index] = deallocate (vision->font_index [index]); vision->font_width [index] = deallocate (vision->font_width [index]); vision->font_height [index] = deallocate (vision->font_height [index]); @@ -413,8 +413,8 @@ static vision_structure * vision_deinitialize (vision_structure * vision) { return (deallocate (vision)); } -static void vision_configure (vision_structure * vision, uint window_width, uint window_height, char * window_title) { - ulong font_bitmap [190] = { +static v0 vision_configure (vision_structure * vision, u4 window_width, u4 window_height, c1 * window_title) { + u8 font_bitmap [190] = { 0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000, 0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000, 0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000, @@ -449,7 +449,7 @@ static void vision_configure (vision_structure * vision, uint window_width, uint 0x0000300808080408, 0x0808083000000000, 0x000000000062928c, 0x0000000000000000 }; - char * vertex_shader = + c1 * vertex_shader = "#version 330 core\n" "in vec3 vertex_xyz;\n" "in vec2 vertex_uv;\n" @@ -459,34 +459,34 @@ static void vision_configure (vision_structure * vision, uint window_width, uint "uniform mat4 projection_matrix;\n" "uniform mat4 movement_matrix;\n" "uniform mat4 rotation_matrix;\n" - "void main () {\n" + "v0 main () {\n" " gl_Position = movement_matrix * rotation_matrix * projection_matrix * vec4 (vertex_xyz, 1.0);\n" " fragment_uv = vertex_uv;\n" " fragment_rgba = vertex_rgba;\n" "}\n"; - char * fragment_shader = + c1 * fragment_shader = "#version 330 core\n" "uniform sampler2D texture_p;\n" "in vec2 fragment_uv;\n" "in vec4 fragment_rgba;\n" "out vec4 data;\n" - "void main () {\n" + "v0 main () {\n" " data = texture (texture_p, fragment_uv) * fragment_rgba;\n" "}\n"; - uint * dumb_buffer = null; - uint * order = null; + u4 * dumb_buffer = null; + u4 * order = null; - uint xyz_attribute = 0; - uint uv_attribute = 0; - uint rgba_attribute = 0; + u4 xyz_attribute = 0; + u4 uv_attribute = 0; + u4 rgba_attribute = 0; - uint u = 0; - uint v = 0; + u4 u = 0; + u4 v = 0; if (vision->using_precomputed_spritesheet == true) { - for (uint index = 0; index < 95; ++index) { + for (u4 index = 0; index < 95; ++index) { vision->font_index [vision->font_count] [index] = ++vision->sprite_count - 1; } @@ -498,13 +498,13 @@ static void vision_configure (vision_structure * vision, uint window_width, uint dumb_buffer = allocate (256 * sizeof (* dumb_buffer)); - for (uint index = 0; index < 256; ++index) { + for (u4 index = 0; index < 256; ++index) { dumb_buffer [index] = 0xffffffff; } ++vision->font_count; - uint current = vision->font_count - 1; + u4 current = vision->font_count - 1; vision->font_index = reallocate (vision->font_index, vision->font_count * sizeof (* vision->font_index)); vision->font_width = reallocate (vision->font_width, vision->font_count * sizeof (* vision->font_width)); @@ -519,13 +519,13 @@ static void vision_configure (vision_structure * vision, uint window_width, uint vision->font_width [vision->font_count - 1] = allocate (95 * sizeof (* * vision->font_width)); vision->font_height [vision->font_count - 1] = allocate (95 * sizeof (* * vision->font_height)); - for (uint index = 0; index < 95; ++index) { - uint * buffer = allocate (vision_font_width * vision_font_height * sizeof (* buffer)); + for (u4 index = 0; index < 95; ++index) { + u4 * buffer = allocate (vision_font_width * vision_font_height * sizeof (* buffer)); - for (uint value = 0; value < 2; ++value) { - for (uint bit = 64; bit > 0; --bit) { - uint destination = ((value << 3) - ((bit - 1) >> 3) + 7) * vision_font_width - ((bit - 1) & 7) + 7; - uint source = (font_bitmap [2 * index + value] >> (bit - 1)) & 1; + for (u4 value = 0; value < 2; ++value) { + for (u4 bit = 64; bit > 0; --bit) { + u4 destination = ((value << 3) - ((bit - 1) >> 3) + 7) * vision_font_width - ((bit - 1) & 7) + 7; + u4 source = (font_bitmap [2 * index + value] >> (bit - 1)) & 1; buffer [destination] = (source) ? 0xffffffff : 0x00000000; } @@ -542,14 +542,14 @@ static void vision_configure (vision_structure * vision, uint window_width, uint order = allocate (vision->sprite_count * sizeof (* order)); - for (uint index = 0; index < vision->sprite_count; ++index) { + for (u4 index = 0; index < vision->sprite_count; ++index) { order [index] = index; } - for (uint index = 0; index < vision->sprite_count; ++index) { - for (uint subindex = 0; subindex < vision->sprite_count; ++subindex) { + for (u4 index = 0; index < vision->sprite_count; ++index) { + for (u4 subindex = 0; subindex < vision->sprite_count; ++subindex) { if (vision->sprite_height [order [index]] < vision->sprite_height [order [subindex]]) { - uint temporary = order [index]; + u4 temporary = order [index]; order [index] = order [subindex]; order [subindex] = temporary; @@ -557,7 +557,7 @@ static void vision_configure (vision_structure * vision, uint window_width, uint } } - for (uint index = 0; index < vision->sprite_count; ++index) { + for (u4 index = 0; index < vision->sprite_count; ++index) { if (u + vision->sprite_width [order [index]] >= vision->spritesheet_size) { u *= 0; v += vision->sprite_height [order [index]]; @@ -566,10 +566,10 @@ static void vision_configure (vision_structure * vision, uint window_width, uint vision->sprite_u [order [index]] = (float) u / (float) vision->spritesheet_size; vision->sprite_v [order [index]] = (float) v / (float) vision->spritesheet_size; - for (uint y = 0; y < vision->sprite_height [order [index]]; ++y) { - for (uint x = 0; x < vision->sprite_width [order [index]]; ++x) { - uint destination = (v + y) * vision->spritesheet_size + (u + x); - uint source = y * vision->sprite_width [order [index]] + x; + for (u4 y = 0; y < vision->sprite_height [order [index]]; ++y) { + for (u4 x = 0; x < vision->sprite_width [order [index]]; ++x) { + u4 destination = (v + y) * vision->spritesheet_size + (u + x); + u4 source = y * vision->sprite_width [order [index]] + x; vision->spritesheet_data [destination] = vision->sprite_data [order [index]] [source]; } @@ -595,10 +595,10 @@ static void vision_configure (vision_structure * vision, uint window_width, uint glfwInit (); - glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, 1); + glfwWindowHs4 (GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHs4 (GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHs4 (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHs4 (GLFW_OPENGL_FORWARD_COMPAT, 1); vision->window = glfwCreateWindow ((int) window_width, (int) window_height, window_title, null, null); @@ -676,28 +676,28 @@ static void vision_configure (vision_structure * vision, uint window_width, uint vision->glLinkProgram (vision->shader_program); vision->glUseProgram (vision->shader_program); - xyz_attribute = (uint) vision->glGetAttribLocation (vision->shader_program, "vertex_xyz"); + xyz_attribute = (u4) vision->glGetAttribLocation (vision->shader_program, "vertex_xyz"); vision->glEnableVertexAttribArray (xyz_attribute); - vision->glVertexAttribPointer (xyz_attribute, 3, GL_FLOAT, GL_FALSE, 9 * sizeof (float), (void *) 0); + vision->glVertexAttribPointer (xyz_attribute, 3, GL_FLOAT, GL_FALSE, 9 * sizeof (float), (v0 *) 0); - uv_attribute = (uint) vision->glGetAttribLocation (vision->shader_program, "vertex_uv"); + uv_attribute = (u4) vision->glGetAttribLocation (vision->shader_program, "vertex_uv"); vision->glEnableVertexAttribArray (uv_attribute); - vision->glVertexAttribPointer (uv_attribute, 2, GL_FLOAT, GL_FALSE, 9 * sizeof (float), (void *) (3 * sizeof (float))); + vision->glVertexAttribPointer (uv_attribute, 2, GL_FLOAT, GL_FALSE, 9 * sizeof (float), (v0 *) (3 * sizeof (float))); - rgba_attribute = (uint) vision->glGetAttribLocation (vision->shader_program, "vertex_rgba"); + rgba_attribute = (u4) vision->glGetAttribLocation (vision->shader_program, "vertex_rgba"); vision->glEnableVertexAttribArray (rgba_attribute); - vision->glVertexAttribPointer (rgba_attribute, 4, GL_FLOAT, GL_FALSE, 9 * sizeof (float), (void *) (5 * sizeof (float))); + vision->glVertexAttribPointer (rgba_attribute, 4, GL_FLOAT, GL_FALSE, 9 * sizeof (float), (v0 *) (5 * sizeof (float))); vision->vertex_array = allocate (vision->vertex_limit * sizeof (vision->vertex_array)); vision->index_array = allocate (vision->index_limit * sizeof (vision->index_array)); - for (uint index = 0; index < 16; ++index) { + for (u4 index = 0; index < 16; ++index) { vision->projection_matrix [index] = 0.0f; vision->movement_matrix [index] = 0.0f; vision->rotation_matrix [index] = 0.0f; @@ -751,8 +751,8 @@ static void vision_configure (vision_structure * vision, uint window_width, uint print ("[/2Success/-] Configured OpenGL renderer.\n"); } -static void vision_synchronize (vision_structure * vision, uint colour) { - int signal_code [signal_count] = { +static v0 vision_synchronize (vision_structure * vision, u4 colour) { + s4 signal_code [signal_count] = { 0, GLFW_KEY_A, GLFW_KEY_B, GLFW_KEY_C, GLFW_KEY_D, GLFW_KEY_E, GLFW_KEY_F, GLFW_KEY_G, GLFW_KEY_H, @@ -781,8 +781,8 @@ static void vision_synchronize (vision_structure * vision, uint colour) { GLFW_KEY_KP_6, GLFW_KEY_KP_7, GLFW_KEY_KP_8, GLFW_KEY_KP_9 }; - int new_window_width = 0; - int new_window_height = 0; + s4 new_window_width = 0; + s4 new_window_height = 0; glClearColor (normal_r (colour), normal_g (colour), normal_b (colour), normal_a (colour)); @@ -794,36 +794,36 @@ static void vision_synchronize (vision_structure * vision, uint colour) { glfwGetWindowSize (vision->window, & new_window_width, & new_window_height); - if ((vision->window_width != (uint) new_window_width) || (vision->window_height != (uint) new_window_height)) { + if ((vision->window_width != (u4) new_window_width) || (vision->window_height != (u4) new_window_height)) { if ((new_window_width <= 0) || (new_window_height <= 0)) return; glViewport (0, 0, new_window_width, new_window_height); - vision->window_width = (uint) new_window_width; - vision->window_height = (uint) new_window_height; + vision->window_width = (u4) new_window_width; + vision->window_height = (u4) new_window_height; vision->pixel_width = 2.0f / (float) new_window_width; vision->pixel_height = 2.0f / (float) new_window_height; } - vision->cursor [cursor_left] = (bool) (glfwGetMouseButton (vision->window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS); - vision->cursor [cursor_middle] = (bool) (glfwGetMouseButton (vision->window, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS); - vision->cursor [cursor_right] = (bool) (glfwGetMouseButton (vision->window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS); + vision->cursor [cursor_left] = (b4) (glfwGetMouseButton (vision->window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS); + vision->cursor [cursor_middle] = (b4) (glfwGetMouseButton (vision->window, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS); + vision->cursor [cursor_right] = (b4) (glfwGetMouseButton (vision->window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS); glfwSetCursorPos (vision->window, (double) vision->window_width / 2.0, (double) vision->window_height / 2.0); if (vision->freeze_cursor == false) { - double x = 0.0; - double y = 0.0; + f8 x = 0.0; + f8 y = 0.0; glfwGetCursorPos (vision->window, & x, & y); vision->cursor_x = (int) x; vision->cursor_y = (int) y; - //~float offset_x = vision->camera_x - x; + //~f4 offset_x = vision->camera_x - x; - //~for (uint index = 0; index < 16; ++index) { + //~for (u4 index = 0; index < 16; ++index) { //~vision->rotation_matrix [index] = 0.0f; //~} @@ -849,8 +849,8 @@ static void vision_synchronize (vision_structure * vision, uint colour) { } if (vision->freeze_signal == false) { - for (uint index = 0; index < signal_count; ++index) { - vision->signal [index] = (bool) (glfwGetKey (vision->window, signal_code [index]) == GLFW_PRESS); + for (u4 index = 0; index < signal_count; ++index) { + vision->signal [index] = (b4) (glfwGetKey (vision->window, signal_code [index]) == GLFW_PRESS); } } @@ -875,7 +875,7 @@ static void vision_synchronize (vision_structure * vision, uint colour) { } if (vision->global_tick % vision->gameplay_framerate == 0) { - vision->framerate = (uint) (1000000000ul / vision->frame_time); + vision->framerate = (u4) (1000000000ul / vision->frame_time); } ++vision->global_tick; @@ -887,21 +887,21 @@ static void vision_synchronize (vision_structure * vision, uint colour) { vision->frame_begin = nano_time (); } -static void vision_render_base (vision_structure * vision, uint vertex_count, float * vertex_array, uint index_count, - uint * index_array, uint sprite, uint colour) { +static v0 vision_render_base (vision_structure * vision, u4 vertex_count, f4 * vertex_array, u4 index_count, + u4 * index_array, u4 sprite, u4 colour) { if (sprite >= vision->sprite_count) return; if (vision->vertex_count + vertex_count >= vision->vertex_limit) return; if (vision->index_count + index_count >= vision->index_limit) return; - float unwrap_x = (float) vision->sprite_u [sprite] / (float) vision->spritesheet_size; - float unwrap_y = (float) vision->sprite_v [sprite] / (float) vision->spritesheet_size; + f4 unwrap_x = (float) vision->sprite_u [sprite] / (float) vision->spritesheet_size; + f4 unwrap_y = (float) vision->sprite_v [sprite] / (float) vision->spritesheet_size; - float unwrap_width = (float) vision->sprite_width [sprite] / (float) vision->spritesheet_size; - float unwrap_height = (float) vision->sprite_height [sprite] / (float) vision->spritesheet_size; + f4 unwrap_width = (float) vision->sprite_width [sprite] / (float) vision->spritesheet_size; + f4 unwrap_height = (float) vision->sprite_height [sprite] / (float) vision->spritesheet_size; - //~for (uint vertex = 0; vertex < vertex_count; ++vertex) { - //~uint destination = 9 * vertex + vision->vertex_count; - //~uint source = 5 * vertex; + //~for (u4 vertex = 0; vertex < vertex_count; ++vertex) { + //~u4 destination = 9 * vertex + vision->vertex_count; + //~u4 source = 5 * vertex; //~vision->vertex_array [destination + 0] = vertex_array [source + 0]; //~vision->vertex_array [destination + 1] = vertex_array [source + 1]; @@ -914,14 +914,14 @@ static void vision_render_base (vision_structure * vision, uint vertex_count, fl //~vision->vertex_array [destination + 8] = normal_a (colour); //~} - for (uint vertex = 0; vertex < vertex_count; ++vertex) { + for (u4 vertex = 0; vertex < vertex_count; ++vertex) { vision->vertex_array [vision->vertex_count + vertex] = vertex_array [vertex]; } //~vision->vertex_array [destination + 3] = vertex_array [source + 3] * unwrap_width + unwrap_x; //~vision->vertex_array [destination + 4] = vertex_array [source + 4] * unwrap_height + unwrap_y; - for (uint index = 0; index < index_count; ++index) { + for (u4 index = 0; index < index_count; ++index) { vision->index_array [vision->index_count + index] = index_array [index]; } @@ -931,13 +931,13 @@ static void vision_render_base (vision_structure * vision, uint vertex_count, fl vision->index_count += index_count; } -//~static void vision_render_triangle (vision_structure * vision, float * vertex_array, uint colour) { +//~static v0 vision_render_triangle (vision_structure * vision, f4 * vertex_array, u4 colour) { //~if (vision->vertex_count + 3 * 36 >= vision->vertex_limit) return; //~if (vision->index_count + 3 >= vision->index_limit) return; - //~for (uint vertex = 0; vertex < 3; ++vertex) { - //~uint destination = 9 * vertex + vision->vertex_count; - //~uint source = 5 * vertex; + //~for (u4 vertex = 0; vertex < 3; ++vertex) { + //~u4 destination = 9 * vertex + vision->vertex_count; + //~u4 source = 5 * vertex; //~vision->vertex_array [destination + 0] = vertex_array [source + 0]; //~vision->vertex_array [destination + 1] = vertex_array [source + 1]; @@ -950,7 +950,7 @@ static void vision_render_base (vision_structure * vision, uint vertex_count, fl //~vision->vertex_array [destination + 8] = normal_a (colour); //~} - //~for (uint index = 0; index < 3; ++index) { + //~for (u4 index = 0; index < 3; ++index) { //~vision->index_array [vision->index_count + index] = vision->vertex_array [vision->vertex_count / 9 + index]; //~} @@ -958,7 +958,7 @@ static void vision_render_base (vision_structure * vision, uint vertex_count, fl //~vision->index_count += 3; //~} -static void vision_change_field_of_view (vision_structure * vision, float change) { +static v0 vision_change_field_of_view (vision_structure * vision, f4 change) { vision->field_of_view += change; vision->projection_matrix [ 0] = vision->aspect_ratio / tangent (vision->field_of_view / 2.0f); @@ -968,7 +968,7 @@ static void vision_change_field_of_view (vision_structure * vision, float change vision->projection_matrix); } -static void vision_change_translation (vision_structure * vision, float x, float y, float z) { +static v0 vision_change_translation (vision_structure * vision, f4 x, f4 y, f4 z) { vision->movement_matrix [ 3] += x; vision->movement_matrix [ 7] += y; vision->movement_matrix [11] += z; @@ -977,8 +977,8 @@ static void vision_change_translation (vision_structure * vision, float x, float vision->movement_matrix); } -static void vision_change_rotation (vision_structure * vision, float vertical, float horizontal) { - for (uint index = 0; index < 16; ++index) { +static v0 vision_change_rotation (vision_structure * vision, f4 vertical, f4 horizontal) { + for (u4 index = 0; index < 16; ++index) { vision->rotation_matrix [index] = 0.0f; } diff --git a/xogueout.c b/xogueout.c index 7011063..cae83e7 100644 --- a/xogueout.c +++ b/xogueout.c @@ -20,11 +20,11 @@ #include #include -int main (void) { +s4 main (v0) { opengl_structure * opengl = opengl_initialize (60, 60, false, 1024, 1024); - int x = 0; - int y = 0; + s4 x = 0; + s4 y = 0; //~opengl_sprite_import (opengl, ""); diff --git a/xommon.h b/xommon.h index da0aa01..24ac318 100755 --- a/xommon.h +++ b/xommon.h @@ -46,53 +46,53 @@ typedef struct { xcb_gcontext_t context; xcb_pixmap_t pixmap; - bool signal [signal_count]; - bool cursor [cursor_count]; - - bool active; - uint window_width; - uint window_height; - uint framerate; - ulong frame_time; - ulong frame_begin; - ulong frame_end; - uint * framebuffer; - uint global_tick; - uint gameplay_tick; - uint animation_tick; - int cursor_x; - int cursor_y; - bool freeze_cursor; - bool freeze_signal; - uint sprite_count; - uint font_count; - uint dummy; /// TODO USE ME PLEASE - uint * * sprite_data; - uint * sprite_width; - uint * sprite_height; - uint * * font_index; - uint * * font_width; - uint * * font_height; - char * font_begin; - char * font_end; + b4 signal [signal_count]; + b4 cursor [cursor_count]; + + b4 active; + u4 window_width; + u4 window_height; + u4 framerate; + u8 frame_time; + u8 frame_begin; + u8 frame_end; + u4 * framebuffer; + u4 global_tick; + u4 gameplay_tick; + u4 animation_tick; + s4 cursor_x; + s4 cursor_y; + b4 freeze_cursor; + b4 freeze_signal; + u4 sprite_count; + u4 font_count; + u4 dummy; /// TODO USE ME PLEASE + u4 * * sprite_data; + u4 * sprite_width; + u4 * sprite_height; + u4 * * font_index; + u4 * * font_width; + u4 * * font_height; + c1 * font_begin; + c1 * font_end; } common_structure; -static uint common_center_x (common_structure * common, uint size) { +static u4 common_center_x (common_structure * common, u4 size) { return ((common->window_width - size) / 2); } -static uint common_center_y (common_structure * common, uint size) { +static u4 common_center_y (common_structure * common, u4 size) { return ((common->window_height - size) / 2); } -static bool common_cursor_inside (common_structure * common, int x, int y, uint width, uint height) { +static b4 common_cursor_inside (common_structure * common, s4 x, s4 y, u4 width, u4 height) { return ((common->cursor_x > x) && (common->cursor_y > y) && (common->cursor_x < x + (int) width) && (common->cursor_y < y + (int) height)); } -static bool common_cursor_left_click (common_structure * common, int x, int y, uint width, uint height) { +static b4 common_cursor_left_click (common_structure * common, s4 x, s4 y, u4 width, u4 height) { if (common->cursor [cursor_left] == true) { common->freeze_cursor = true; @@ -102,7 +102,7 @@ static bool common_cursor_left_click (common_structure * common, int x, int y, u return (false); } -static bool common_cursor_right_click (common_structure * common, int x, int y, uint width, uint height) { +static b4 common_cursor_right_click (common_structure * common, s4 x, s4 y, u4 width, u4 height) { if (common->cursor [cursor_right]) { common->freeze_cursor = true; @@ -112,7 +112,7 @@ static bool common_cursor_right_click (common_structure * common, int x, int y, return (false); } -static uint common_sprite_raw_import (common_structure * common, uint * data, uint width, uint height) { +static u4 common_sprite_raw_import (common_structure * common, u4 * data, u4 width, u4 height) { ++common->sprite_count; common->sprite_data = reallocate (common->sprite_data, common->sprite_count * sizeof (* common->sprite_data)); @@ -126,11 +126,11 @@ static uint common_sprite_raw_import (common_structure * common, uint * data, ui return (common->sprite_count - 1); } -static uint common_font_raw_import (common_structure * common, uint * data, uint image_width, char begin, char end, uint empty) { - uint pointer = 0; - uint width = 0; - uint height = 0; - uint * buffer = null; +static u4 common_font_raw_import (common_structure * common, u4 * data, u4 image_width, c1 begin, c1 end, u4 empty) { + u4 pointer = 0; + u4 width = 0; + u4 height = 0; + u4 * buffer = null; ++common->font_count; @@ -143,19 +143,19 @@ static uint common_font_raw_import (common_structure * common, uint * data, uint common->font_begin [common->font_count - 1] = begin; common->font_end [common->font_count - 1] = end; - common->font_index [common->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * common->font_index)); - common->font_width [common->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * common->font_width)); - common->font_height [common->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * common->font_height)); + common->font_index [common->font_count - 1] = allocate ((u8) (end - begin + 1) * sizeof (* * common->font_index)); + common->font_width [common->font_count - 1] = allocate ((u8) (end - begin + 1) * sizeof (* * common->font_width)); + common->font_height [common->font_count - 1] = allocate ((u8) (end - begin + 1) * sizeof (* * common->font_height)); - for (char index = begin; index <= end; ++index) { + for (c1 index = begin; index <= end; ++index) { for ( ; data [pointer] == empty; ++pointer); for (width = 0; data [pointer + width] != empty; ++width); for (height = 0; data [pointer + height * image_width] != empty; ++height); buffer = allocate (width * height * sizeof (* buffer)); - for (uint y = 0; y < height; ++y) { - for (uint x = 0; x < width; ++x) { + for (u4 y = 0; y < height; ++y) { + for (u4 x = 0; x < width; ++x) { buffer [y * width + x] = data [pointer + (y * image_width) + x]; } } @@ -176,12 +176,12 @@ static uint common_font_raw_import (common_structure * common, uint * data, uint return (common->font_count - 1); } -static uint common_sprite_import (common_structure * common, char * path) { - uint width = 0; - uint height = 0; - uint * data = null; +static u4 common_sprite_import (common_structure * common, c1 * path) { + u4 width = 0; + u4 height = 0; + u4 * data = null; - char buffer [256] = ""; + c1 buffer [256] = ""; #ifdef use_png_library if ((data == null) && (file_exists (string_concatenate (string_copy (buffer, path), ".png")) == true)) { @@ -200,13 +200,13 @@ static uint common_sprite_import (common_structure * common, char * path) { return (common_sprite_raw_import (common, data, width, height)); } -static uint common_font_import (common_structure * common, char * path, char begin, char end, uint colour) { - uint width = 0; - uint height = 0; - uint result = 0; - uint * data = null; +static u4 common_font_import (common_structure * common, c1 * path, c1 begin, c1 end, u4 colour) { + u4 width = 0; + u4 height = 0; + u4 result = 0; + u4 * data = null; - char buffer [256] = ""; + c1 buffer [256] = ""; #ifdef use_png_library if ((data == null) && (file_exists (string_concatenate (string_copy (buffer, path), ".png")) == true)) { @@ -229,26 +229,26 @@ static uint common_font_import (common_structure * common, char * path, char beg return (result); } -static uint common_sprite_width (common_structure * common, uint sprite) { +static u4 common_sprite_width (common_structure * common, u4 sprite) { return (common->sprite_width [sprite]); } -static uint common_sprite_height (common_structure * common, uint sprite) { +static u4 common_sprite_height (common_structure * common, u4 sprite) { return (common->sprite_height [sprite]); } -static common_structure * common_initialize (void) { +static common_structure * common_initialize (v0) { common_structure * common = allocate (sizeof (* common)); return (common); } static common_structure * common_deinitialize (common_structure * common) { - for (uint index = 0; index < common->sprite_count; ++index) { + for (u4 index = 0; index < common->sprite_count; ++index) { common->sprite_data [index] = deallocate (common->sprite_data [index]); } - for (uint index = 0; index < common->font_count; ++index) { + for (u4 index = 0; index < common->font_count; ++index) { common->font_index [index] = deallocate (common->font_index [index]); common->font_width [index] = deallocate (common->font_width [index]); common->font_height [index] = deallocate (common->font_height [index]); @@ -275,8 +275,8 @@ static common_structure * common_deinitialize (common_structure * common) { return (deallocate (common)); } -static void common_configure (common_structure * common, uint width, uint height, char * title, uint window_flags) { - ulong font_bitmap [190] = { +static v0 common_configure (common_structure * common, u4 width, u4 height, c1 * title, u4 window_flags) { + u8 font_bitmap [190] = { 0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000, 0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000, 0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000, @@ -311,15 +311,15 @@ static void common_configure (common_structure * common, uint width, uint height 0x0000300808080408, 0x0808083000000000, 0x000000000062928c, 0x0000000000000000 }; - uint event_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; + u4 event_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; - uint mask_window_flags [2] = { 0 }; + u4 mask_window_flags [2] = { 0 }; - (void) window_flags; + (v0) window_flags; - uint * dumb_buffer = allocate (256 * sizeof (* dumb_buffer)); + u4 * dumb_buffer = allocate (256 * sizeof (* dumb_buffer)); - for (uint index = 0; index < 256; ++index) { + for (u4 index = 0; index < 256; ++index) { dumb_buffer [index] = 0xffffffff; } @@ -338,13 +338,13 @@ static void common_configure (common_structure * common, uint width, uint height common->font_width [common->font_count - 1] = allocate (95 * sizeof (* * common->font_width)); common->font_height [common->font_count - 1] = allocate (95 * sizeof (* * common->font_height)); - for (uint index = 0; index < 95; ++index) { - uint * buffer = allocate (common_font_width * common_font_height * sizeof (* buffer)); + for (u4 index = 0; index < 95; ++index) { + u4 * buffer = allocate (common_font_width * common_font_height * sizeof (* buffer)); - for (uint value = 0; value < 2; ++value) { - for (uint bit = 64; bit > 0; --bit) { - uint destination = ((value << 3) - ((bit - 1) >> 3) + 7) * common_font_width - ((bit - 1) & 7) + 7; - uint source = (font_bitmap [2 * index + value] >> (bit - 1)) & 1; + for (u4 value = 0; value < 2; ++value) { + for (u4 bit = 64; bit > 0; --bit) { + u4 destination = ((value << 3) - ((bit - 1) >> 3) + 7) * common_font_width - ((bit - 1) & 7) + 7; + u4 source = (font_bitmap [2 * index + value] >> (bit - 1)) & 1; buffer [destination] = (source) ? 0xffffffff : 0x00000000; } @@ -383,17 +383,17 @@ static void common_configure (common_structure * common, uint width, uint height XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_BUTTON_PRESS; - xcb_create_window (common->connection, common->screen->root_depth, common->window, common->screen->root, 0, 0, (ushort) width, - (ushort) height, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT, common->screen->root_visual, event_mask, mask_window_flags); + xcb_create_window (common->connection, common->screen->root_depth, common->window, common->screen->root, 0, 0, (u2) width, + (u2) height, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT, common->screen->root_visual, event_mask, mask_window_flags); xcb_map_window (common->connection, common->window); //~xcb_composite_redirect_window (common->connection, common->window, XCB_COMPOSITE_REDIRECT_MANUAL); xcb_change_property (common->connection, XCB_PROP_MODE_REPLACE, common->window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, - (uint) string_length (title), title); + (u4) string_length (title), title); - xcb_create_pixmap (common->connection, common->screen->root_depth, common->pixmap, common->window, (ushort) width, (ushort ) height); + xcb_create_pixmap (common->connection, common->screen->root_depth, common->pixmap, common->window, (u2) width, (u2 ) height); xcb_create_gc (common->connection, common->context, common->pixmap, 0, null); @@ -406,8 +406,8 @@ static void common_configure (common_structure * common, uint width, uint height common->frame_begin = nano_time (); } -static void common_synchronize (common_structure * common, uint colour) { - uint signal_code [signal_count] = { +static v0 common_synchronize (common_structure * common, u4 colour) { + u4 signal_code [signal_count] = { 0, 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14, @@ -421,7 +421,7 @@ static void common_synchronize (common_structure * common, uint colour) { xcb_generic_event_t * generic_event = xcb_wait_for_event (common->connection); //~xcb_generic_event_t * generic_event = null; - (void) colour; + (v0) colour; //~for (; ; ) { //~generic_event = xcb_poll_for_event (common->connection); @@ -461,7 +461,7 @@ static void common_synchronize (common_structure * common, uint colour) { } break; case (XCB_KEY_PRESS): { xcb_key_press_event_t * key_press = (xcb_key_press_event_t *) generic_event; - for (uint index = 0; index < signal_count; ++index) { + for (u4 index = 0; index < signal_count; ++index) { if (key_press->detail == signal_code [index]) { common->signal [index] = true; } @@ -469,7 +469,7 @@ static void common_synchronize (common_structure * common, uint colour) { } break; case (XCB_KEY_RELEASE): { xcb_key_release_event_t * key_release = (xcb_key_release_event_t *) generic_event; - for (uint index = 0; index < signal_count; ++index) { + for (u4 index = 0; index < signal_count; ++index) { if (key_release->detail == signal_code [index]) { common->signal [index] = false; } @@ -482,24 +482,24 @@ static void common_synchronize (common_structure * common, uint colour) { generic_event = deallocate (generic_event); //~} - for (uint pixel = 0; pixel < common->window_width * common->window_height; ++pixel) { - uint r = (common->framebuffer [pixel] & 0x00ff0000) >> 16; - uint b = (common->framebuffer [pixel] & 0x000000ff) << 16; + for (u4 pixel = 0; pixel < common->window_width * common->window_height; ++pixel) { + u4 r = (common->framebuffer [pixel] & 0x00ff0000) >> 16; + u4 b = (common->framebuffer [pixel] & 0x000000ff) << 16; common->framebuffer [pixel] = (common->framebuffer [pixel] & 0xff00ff00) | b | r; } - common->image = xcb_image_create_native (common->connection, (ushort) common->window_width, (ushort) common->window_height, + common->image = xcb_image_create_native (common->connection, (u2) common->window_width, (u2) common->window_height, XCB_IMAGE_FORMAT_Z_PIXMAP, common->screen->root_depth, common->framebuffer, - (uint) (common->window_width * common->window_height * sizeof (* common->framebuffer)), - (uchar *) common->framebuffer); + (u4) (common->window_width * common->window_height * sizeof (* common->framebuffer)), + (u1 *) common->framebuffer); xcb_image_put (common->connection, common->pixmap, common->context, common->image, 0, 0, 0); xcb_image_destroy (common->image); - xcb_copy_area (common->connection, common->pixmap, common->window, common->context, 0, 0, 0, 0, (ushort) common->window_width, - (ushort) common->window_height); + xcb_copy_area (common->connection, common->pixmap, common->window, common->context, 0, 0, 0, 0, (u2) common->window_width, + (u2) common->window_height); common->framebuffer = allocate (common->window_width * common->window_height * sizeof (* common->framebuffer)); @@ -512,7 +512,7 @@ static void common_synchronize (common_structure * common, uint colour) { } if (common->global_tick % common_gameplay_framerate == 0) { - common->framerate = (uint) (1000000000ul / common->frame_time); + common->framerate = (u4) (1000000000ul / common->frame_time); } ++common->global_tick; @@ -524,117 +524,117 @@ static void common_synchronize (common_structure * common, uint colour) { common->frame_begin = nano_time (); } -static void common_render_base (common_structure * common, uint sprite, int x, int y, uint u, uint v, uint width, uint height, float scale_x, float scale_y, int flip_x, - int flip_y, uint upper_left, uint upper_right, uint lower_left, uint lower_right) { - (void) scale_x; - (void) scale_y; - (void) flip_x; - (void) flip_y; +static v0 common_render_base (common_structure * common, u4 sprite, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height, f4 scale_x, f4 scale_y, s4 flip_x, + s4 flip_y, u4 upper_left, u4 upper_right, u4 lower_left, u4 lower_right) { + (v0) scale_x; + (v0) scale_y; + (v0) flip_x; + (v0) flip_y; /// FIX TO INTERPOLATE ALL 4 COLOURS - //~(void) upper_left; - (void) upper_right; - (void) lower_left; - (void) lower_right; + //~(v0) upper_left; + (v0) upper_right; + (v0) lower_left; + (v0) lower_right; /// COLOUR INTERPOLATION WITH RBGA-ABGR CONVERSION - uint interpolate_pixels (uint pixel, uint modifier) { - uint r = (((pixel & 0xff000000) >> 24) * ((modifier & 0x000000ff) >> 0)) / 0xff; - uint g = (((pixel & 0x00ff0000) >> 16) * ((modifier & 0x0000ff00) >> 8)) / 0xff; - uint b = (((pixel & 0x0000ff00) >> 8) * ((modifier & 0x00ff0000) >> 16)) / 0xff; - uint a = (((pixel & 0x000000ff) >> 0) * ((modifier & 0xff000000) >> 24)) / 0xff; + u4 interpolate_pixels (u4 pixel, u4 modifier) { + u4 r = (((pixel & 0xff000000) >> 24) * ((modifier & 0x000000ff) >> 0)) / 0xff; + u4 g = (((pixel & 0x00ff0000) >> 16) * ((modifier & 0x0000ff00) >> 8)) / 0xff; + u4 b = (((pixel & 0x0000ff00) >> 8) * ((modifier & 0x00ff0000) >> 16)) / 0xff; + u4 a = (((pixel & 0x000000ff) >> 0) * ((modifier & 0xff000000) >> 24)) / 0xff; return ((r << 24) | (g << 16) | (b << 8) | a); } if ((x + (int) width < 0) || (y + (int) height < 0) || (x > (int) common->window_width) || (y > (int) common->window_height)) return; - for (uint vertical = 0; vertical < height; ++vertical) { + for (u4 vertical = 0; vertical < height; ++vertical) { if (vertical + y >= common->window_height) break; if (vertical + v >= common->sprite_height [sprite]) break; - for (uint horizontal = 0; horizontal < width; ++horizontal) { + for (u4 horizontal = 0; horizontal < width; ++horizontal) { if (horizontal + x >= common->window_width) break; if (horizontal + u >= common->sprite_width [sprite]) break; - uint pixel = common->sprite_data [sprite] [(vertical + v) * common->sprite_width [sprite] + horizontal + u]; - uint at = (y + vertical) * common->window_width + (x + horizontal); + u4 pixel = common->sprite_data [sprite] [(vertical + v) * common->sprite_width [sprite] + horizontal + u]; + u4 at = (y + vertical) * common->window_width + (x + horizontal); common->framebuffer [at] = (((pixel & 0xff000000) >> 24) > 0x77) ? interpolate_pixels (pixel, upper_left) : common->framebuffer [at]; } } } -static void common_render_rectangle (common_structure * common, int x, int y, uint width, uint height, uint colour) { +static v0 common_render_rectangle (common_structure * common, s4 x, s4 y, u4 width, u4 height, u4 colour) { common_render_base (common, common->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16, (float) height / 16, 0, 0, colour, colour, colour, colour); } -static void common_render_rectangle_gradient_v (common_structure * common, int x, int y, uint width, uint height, uint colour_up, uint colour_down) { +static v0 common_render_rectangle_gradient_v (common_structure * common, s4 x, s4 y, u4 width, u4 height, u4 colour_up, u4 colour_down) { common_render_base (common, common->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16, (float) height / 16, 0, 0, colour_up, colour_up, colour_down, colour_down); } -static void common_render_rectangle_gradient_h (common_structure * common, int x, int y, uint width, uint height, uint colour_left, uint colour_right) { +static v0 common_render_rectangle_gradient_h (common_structure * common, s4 x, s4 y, u4 width, u4 height, u4 colour_left, u4 colour_right) { common_render_base (common, common->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16, (float) height / 16, 0, 0, colour_left, colour_right, colour_left, colour_right); } -static void common_render_sprite (common_structure * common, uint sprite, int x, int y) { +static v0 common_render_sprite (common_structure * common, u4 sprite, s4 x, s4 y) { common_render_base (common, sprite, x, y, 0, 0, common->sprite_width [sprite], common->sprite_height [sprite], 1, 1, 0, 0, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void common_render_sprite_crop (common_structure * common, uint sprite, int x, int y, uint u, uint v, uint width, uint height) { +static v0 common_render_sprite_crop (common_structure * common, u4 sprite, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height) { common_render_base (common, sprite, x, y, u, v, width, height, 1, 1, 0, 0, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void common_render_sprite_colour (common_structure * common, uint sprite, uint colour, int x, int y) { +static v0 common_render_sprite_colour (common_structure * common, u4 sprite, u4 colour, s4 x, s4 y) { common_render_base (common, sprite, x, y, 0, 0, common->sprite_width [sprite], common->sprite_height [sprite], 1, 1, 0, 0, colour, colour, colour, colour); } -static void common_render_sprite_crop_colour (common_structure * common, uint sprite, uint colour, int x, int y, uint u, uint v, uint width, uint height) { +static v0 common_render_sprite_crop_colour (common_structure * common, u4 sprite, u4 colour, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height) { common_render_base (common, sprite, x, y, u, v, width, height, 1, 1, 0, 0, colour, colour, colour, colour); } -static void common_render_sprite_flip (common_structure * common, uint sprite, int x, int y, int flip_x, int flip_y) { +static v0 common_render_sprite_flip (common_structure * common, u4 sprite, s4 x, s4 y, s4 flip_x, s4 flip_y) { common_render_base (common, sprite, x, y, 0, 0, common->sprite_width [sprite], common->sprite_height [sprite], 1, 1, flip_x, flip_y, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void common_render_sprite_animate (common_structure * common, uint sprite, int x, int y, uint frames, uint state, uint states) { - uint width = common->sprite_width [sprite] / states; - uint height = common->sprite_height [sprite] / frames; - uint u = width * (state % states); - uint v = height * (common->animation_tick % frames); +static v0 common_render_sprite_animate (common_structure * common, u4 sprite, s4 x, s4 y, u4 frames, u4 state, u4 states) { + u4 width = common->sprite_width [sprite] / states; + u4 height = common->sprite_height [sprite] / frames; + u4 u = width * (state % states); + u4 v = height * (common->animation_tick % frames); common_render_sprite_crop (common, sprite, x, y, u, v, width, height); } -static void common_render_sprite_preview (common_structure * common, uint sprite, int x, int y, uint u, uint v, uint width, uint height, float zoom) { +static v0 common_render_sprite_preview (common_structure * common, u4 sprite, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height, f4 zoom) { common_render_base (common, sprite, x, y, u, v, width, height, zoom, zoom, false, false, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void common_render_sprite_control (common_structure * common, uint sprite, int x, int y, uint u, uint v, uint width, uint height, int flip_x, int flip_y) { +static v0 common_render_sprite_control (common_structure * common, u4 sprite, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height, s4 flip_x, s4 flip_y) { common_render_base (common, sprite, x, y, u, v, width, height, 1, 1, flip_x, flip_y, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static uint common_render_string_width (common_structure * common, char * string, uint font, float scale) { - uint length = 0; +static u4 common_render_string_width (common_structure * common, c1 * string, u4 font, f4 scale) { + u4 length = 0; if (string == null) { return (0); } - for (uint index = 0; string [index] != '\0'; ++index) { - uint character = common->font_index [font] [string [index] - common->font_begin [font]]; + for (u4 index = 0; string [index] != '\0'; ++index) { + u4 character = common->font_index [font] [string [index] - common->font_begin [font]]; - length += (uint) ((float) common->sprite_width [character] * scale); + length += (u4) ((float) common->sprite_width [character] * scale); } return (length); } -static void common_render_string (common_structure * common, char * string, uint font, int x, int y, float scale, uint colour) { - int offset = x; +static v0 common_render_string (common_structure * common, c1 * string, u4 font, s4 x, s4 y, f4 scale, u4 colour) { + s4 offset = x; if (string == null) return; @@ -642,8 +642,8 @@ static void common_render_string (common_structure * common, char * string, uint font = common->font_count - 1; } - for (uint index = 0; string [index] != '\0'; ++index) { - uint character = 0; + for (u4 index = 0; string [index] != '\0'; ++index) { + u4 character = 0; if (string [index] == '\t') { x += (int) (scale * (float) common_font_tabulator * (float) common->sprite_width [common->font_index [font] [' ' - common->font_begin [font]]]); diff --git a/xop.c b/xop.c index dc6aeeb..ea65aa6 100755 --- a/xop.c +++ b/xop.c @@ -1,16 +1,16 @@ #include -static void echo_byte (uchar byte) { +static v0 echo_byte (u1 byte) { output ("0123456789ABCDEF" + byte / 16, 1); output ("0123456789ABCDEF" + byte % 16, 1); output (" ", 1); } -int main (int argc, char * * argv) { - int file = 0; - ulong size = 0; - uchar * buffer = null; +s4 main (s4 argc, c1 * * argv) { + s4 file = 0; + u8 size = 0; + u1 * buffer = null; if (argc != 2) { print ("> xop input_file\n"); @@ -27,7 +27,7 @@ int main (int argc, char * * argv) { file = file_close (file); - for (ulong offset = 0; offset < size; ++offset) { + for (u8 offset = 0; offset < size; ++offset) { if (buffer [offset] == 0x90) { echo ("\n"); } diff --git a/xormat.h b/xormat.h index cb9b030..1ac2e58 100644 --- a/xormat.h +++ b/xormat.h @@ -31,12 +31,12 @@ #include #endif -static void * format_image_import (char * path, uint * width, uint * height) { - uint * data = null; +static v0 * format_image_import (c1 * path, u4 * width, u4 * height) { + u4 * data = null; //~#ifdef use_png_library //~if (data == null) { - //~char buffer [256] = ""; + //~c1 buffer [256] = ""; //~if (file_exists (string_concatenate (string_copy (buffer, path), ".png")) == true) { //~data = png_image_import (buffer, width, height); @@ -46,7 +46,7 @@ static void * format_image_import (char * path, uint * width, uint * height) { //~#ifdef use_jxl_library //~if (data == null) { - //~char buffer [256] = ""; + //~c1 buffer [256] = ""; //~if (file_exists (string_concatenate (string_copy (buffer, path), ".jxl")) == true) { //~data = jxl_image_import (buffer, width, height); @@ -56,7 +56,7 @@ static void * format_image_import (char * path, uint * width, uint * height) { //~#ifdef use_jpg_library //~if (data == null) { - //~char buffer [256] = ""; + //~c1 buffer [256] = ""; //~if (file_exists (string_concatenate (string_copy (buffer, path), ".jpg")) == true) { //~data = jpg_image_import (buffer, width, height); @@ -66,7 +66,7 @@ static void * format_image_import (char * path, uint * width, uint * height) { //~#ifdef use_tga_library //~if (data == null) { - //~char buffer [256] = ""; + //~c1 buffer [256] = ""; //~if (file_exists (string_concatenate (string_copy (buffer, path), ".tga")) == true) { //~data = tga_image_import (buffer, width, height); diff --git a/xormat/jxl.h b/xormat/jxl.h index 37932c5..5316a1c 100644 --- a/xormat/jxl.h +++ b/xormat/jxl.h @@ -4,7 +4,7 @@ #define use_jxl_library #endif -static void * jxl_image_import (char * path, uint * width, uint * height) { +static v0 * jxl_image_import (c1 * path, u4 * width, u4 * height) { JxlDecoder * decoder = null; JxlBasicInfo information = { 0 }; JxlPixelFormat format = { 4, JXL_TYPE_UINT8, JXL_NATIVE_ENDIAN, 0 }; @@ -14,10 +14,10 @@ static void * jxl_image_import (char * path, uint * width, uint * height) { fatal_failure (width == null, "jxl_image_import: Width is null pointer."); fatal_failure (height == null, "jxl_image_import: Height is null pointer."); - ulong size = file_size (path); - uchar * data = file_record (path); - uint * pixel_array = null; - ulong output_size = 0; + u8 size = file_size (path); + u1 * data = file_record (path); + u4 * pixel_array = null; + u8 output_size = 0; decoder = JxlDecoderCreate (null); diff --git a/xormat/png.h b/xormat/png.h index cb1f52c..26577be 100644 --- a/xormat/png.h +++ b/xormat/png.h @@ -5,10 +5,10 @@ #define use_png_library #endif -static void * png_image_import (char * path, uint * width, uint * height) { +static v0 * png_image_import (c1 * path, u4 * width, u4 * height) { FILE * file; - uint * data; - uint index; + u4 * data; + u4 index; png_byte colour_type = 0; png_byte bit_depth = 0; @@ -87,7 +87,7 @@ static void * png_image_import (char * path, uint * width, uint * height) { return (data); } -static void png_image_export (char * path, uint * data, uint width, uint height) { +static v0 png_image_export (c1 * path, u4 * data, u4 width, u4 height) { png_image image = { 0 }; fatal_failure (path == null, "png_image_export: File path is null pointer."); diff --git a/xpengl.h b/xpengl.h index 6e8dd2d..06e51c5 100755 --- a/xpengl.h +++ b/xpengl.h @@ -54,60 +54,60 @@ typedef struct { PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; PFNGLBUFFERDATAPROC glBufferData; - bool signal [signal_count]; - bool cursor [cursor_count]; - int cursor_x; - int cursor_y; - - bool using_precomputed_spritesheet; - ulong spritesheet_size; - ulong vertex_limit; - ulong index_limit; - uint gameplay_framerate; - uint animation_framerate; - uint tab_width; - uint default_font; - bool active; - uint window_width; - uint window_height; - float pixel_width; - float pixel_height; - uint framerate; - ulong frame_time; - ulong frame_begin; - ulong frame_end; - uint global_tick; - uint gameplay_tick; - uint animation_tick; - bool freeze_cursor; - bool freeze_signal; - uint vertex_object; - uint vertex_buffer; - uint index_buffer; - uint vertex_shader; - uint fragment_shader; - uint shader_program; - uint spritesheet; - uint vertex_count; - uint index_count; - float * vertex_array; - uint * index_array; - uint sprite_count; - uint font_count; - uint * spritesheet_data; - uint * * sprite_data; - uint * sprite_width; - uint * sprite_height; - float * sprite_u; - float * sprite_v; - uint * * font_index; - uint * * font_width; - uint * * font_height; - char * font_begin; - char * font_end; + b4 signal [signal_count]; + b4 cursor [cursor_count]; + s4 cursor_x; + s4 cursor_y; + + b4 using_precomputed_spritesheet; + u8 spritesheet_size; + u8 vertex_limit; + u8 index_limit; + u4 gameplay_framerate; + u4 animation_framerate; + u4 tab_width; + u4 default_font; + b4 active; + u4 window_width; + u4 window_height; + f4 pixel_width; + f4 pixel_height; + u4 framerate; + u8 frame_time; + u8 frame_begin; + u8 frame_end; + u4 global_tick; + u4 gameplay_tick; + u4 animation_tick; + b4 freeze_cursor; + b4 freeze_signal; + u4 vertex_object; + u4 vertex_buffer; + u4 index_buffer; + u4 vertex_shader; + u4 fragment_shader; + u4 shader_program; + u4 spritesheet; + u4 vertex_count; + u4 index_count; + f4 * vertex_array; + u4 * index_array; + u4 sprite_count; + u4 font_count; + u4 * spritesheet_data; + u4 * * sprite_data; + u4 * sprite_width; + u4 * sprite_height; + f4 * sprite_u; + f4 * sprite_v; + u4 * * font_index; + u4 * * font_width; + u4 * * font_height; + c1 * font_begin; + c1 * font_end; } opengl_structure; -static uint opengl_sprite_raw_import (opengl_structure * opengl, uint * data, uint width, uint height) { +static u4 opengl_sprite_raw_import (opengl_structure * opengl, u4 * data, u4 width, u4 height) { fatal_failure (opengl->active == true, "opengl_sprite_raw_import: OpenGL renderer is already initialized."); fatal_failure (data == null, "opengl_sprite_raw_import: Data is null pointer."); fatal_failure (width == 0, "opengl_sprite_raw_import: Font image width is zero."); @@ -130,10 +130,10 @@ static uint opengl_sprite_raw_import (opengl_structure * opengl, uint * data, ui return (opengl->sprite_count - 1); } -static uint opengl_font_raw_import (opengl_structure * opengl, uint * data, uint image_width, char begin, char end, uint empty) { - uint pointer = 0; - uint width = 0; - uint height = 0; +static u4 opengl_font_raw_import (opengl_structure * opengl, u4 * data, u4 image_width, c1 begin, c1 end, u4 empty) { + u4 pointer = 0; + u4 width = 0; + u4 height = 0; fatal_failure (opengl->active == true, "opengl_font_raw_import: OpenGL renderer is already initialized."); fatal_failure (data == null, "opengl_font_raw_import: Data is null pointer."); @@ -151,19 +151,19 @@ static uint opengl_font_raw_import (opengl_structure * opengl, uint * data, uint opengl->font_begin [opengl->font_count - 1] = begin; opengl->font_end [opengl->font_count - 1] = end; - opengl->font_index [opengl->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * opengl->font_index)); - opengl->font_width [opengl->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * opengl->font_width)); - opengl->font_height [opengl->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * opengl->font_height)); + opengl->font_index [opengl->font_count - 1] = allocate ((u8) (end - begin + 1) * sizeof (* * opengl->font_index)); + opengl->font_width [opengl->font_count - 1] = allocate ((u8) (end - begin + 1) * sizeof (* * opengl->font_width)); + opengl->font_height [opengl->font_count - 1] = allocate ((u8) (end - begin + 1) * sizeof (* * opengl->font_height)); - for (char index = begin; index <= end; ++index) { + for (c1 index = begin; index <= end; ++index) { for ( ; data [pointer] == empty; ++pointer); for (width = 0; data [pointer + width] != empty; ++width); for (height = 0; data [pointer + height * image_width] != empty; ++height); - uint * buffer = allocate (width * height * sizeof (* buffer)); + u4 * buffer = allocate (width * height * sizeof (* buffer)); - for (uint y = 0; y < height; ++y) { - for (uint x = 0; x < width; ++x) { + for (u4 y = 0; y < height; ++y) { + for (u4 x = 0; x < width; ++x) { buffer [y * width + x] = data [pointer + (y * image_width) + x]; } } @@ -184,12 +184,12 @@ static uint opengl_font_raw_import (opengl_structure * opengl, uint * data, uint return (opengl->font_count - 1); } -static uint opengl_sprite_import (opengl_structure * opengl, char * path) { - uint width = 0; - uint height = 0; - uint * data = null; +static u4 opengl_sprite_import (opengl_structure * opengl, c1 * path) { + u4 width = 0; + u4 height = 0; + u4 * data = null; - char buffer [256] = ""; + c1 buffer [256] = ""; if (opengl->using_precomputed_spritesheet == true) { return (++opengl->sprite_count - 1); @@ -214,16 +214,16 @@ static uint opengl_sprite_import (opengl_structure * opengl, char * path) { return (opengl_sprite_raw_import (opengl, data, width, height)); } -static uint opengl_font_import (opengl_structure * opengl, char * path, char begin, char end, uint colour) { - uint width = 0; - uint height = 0; - uint result = 0; - uint * data = null; +static u4 opengl_font_import (opengl_structure * opengl, c1 * path, c1 begin, c1 end, u4 colour) { + u4 width = 0; + u4 height = 0; + u4 result = 0; + u4 * data = null; - char buffer [256] = ""; + c1 buffer [256] = ""; if (opengl->using_precomputed_spritesheet == true) { - for (char index = begin; index <= end; ++index) { + for (c1 index = begin; index <= end; ++index) { opengl->font_index [opengl->font_count] [index - begin] = ++opengl->sprite_count - 1; } @@ -253,30 +253,30 @@ static uint opengl_font_import (opengl_structure * opengl, char * path, char beg return (result); } -static uint opengl_sprite_width (opengl_structure * opengl, uint sprite) { +static u4 opengl_sprite_width (opengl_structure * opengl, u4 sprite) { return (opengl->sprite_width [sprite]); } -static uint opengl_sprite_height (opengl_structure * opengl, uint sprite) { +static u4 opengl_sprite_height (opengl_structure * opengl, u4 sprite) { return (opengl->sprite_height [sprite]); } -static uint opengl_center_x (opengl_structure * opengl, uint size) { +static u4 opengl_center_x (opengl_structure * opengl, u4 size) { return ((opengl->window_width - size) / 2); } -static uint opengl_center_y (opengl_structure * opengl, uint size) { +static u4 opengl_center_y (opengl_structure * opengl, u4 size) { return ((opengl->window_height - size) / 2); } -static bool opengl_cursor_inside (opengl_structure * opengl, int x, int y, uint width, uint height) { +static b4 opengl_cursor_inside (opengl_structure * opengl, s4 x, s4 y, u4 width, u4 height) { return ((opengl->cursor_x > x) && (opengl->cursor_y > y) && (opengl->cursor_x < x + (int) width) && (opengl->cursor_y < y + (int) height)); } -static bool opengl_cursor_left_click (opengl_structure * opengl, int x, int y, uint width, uint height) { +static b4 opengl_cursor_left_click (opengl_structure * opengl, s4 x, s4 y, u4 width, u4 height) { if (opengl->cursor [cursor_left] == true) { opengl->freeze_cursor = true; @@ -286,7 +286,7 @@ static bool opengl_cursor_left_click (opengl_structure * opengl, int x, int y, u return (false); } -static bool opengl_cursor_right_click (opengl_structure * opengl, int x, int y, uint width, uint height) { +static b4 opengl_cursor_right_click (opengl_structure * opengl, s4 x, s4 y, u4 width, u4 height) { if (opengl->cursor [cursor_right]) { opengl->freeze_cursor = true; @@ -296,8 +296,8 @@ static bool opengl_cursor_right_click (opengl_structure * opengl, int x, int y, return (false); } -static void opengl_import_spritesheet (opengl_structure * opengl, char * data_file) { - int file = file_open (data_file, file_flag_read); +static v0 opengl_import_spritesheet (opengl_structure * opengl, c1 * data_file) { + s4 file = file_open (data_file, file_flag_read); fatal_failure (opengl->active == true, "opengl_import_spritesheet: OpenGL renderer is already initialized."); @@ -326,14 +326,14 @@ static void opengl_import_spritesheet (opengl_structure * opengl, char * data_fi file_read (file, opengl->font_begin, opengl->font_count * sizeof (* opengl->font_begin)); file_read (file, opengl->font_end, opengl->font_count * sizeof (* opengl->font_end)); - for (uint index = 0; index < opengl->font_count; ++index) { - uint range = (uint) (opengl->font_end [index] - opengl->font_begin [index]) + 1; + for (u4 index = 0; index < opengl->font_count; ++index) { + u4 range = (u4) (opengl->font_end [index] - opengl->font_begin [index]) + 1; opengl->font_index [index] = allocate (range * sizeof (* * opengl->font_index)); opengl->font_width [index] = allocate (range * sizeof (* * opengl->font_width)); opengl->font_height [index] = allocate (range * sizeof (* * opengl->font_height)); - for (uint subindex = 0; subindex < range; ++subindex) { + for (u4 subindex = 0; subindex < range; ++subindex) { file_read (file, & opengl->font_index [index] [subindex], sizeof (* * opengl->font_index)); file_read (file, & opengl->font_width [index] [subindex], sizeof (* * opengl->font_width)); file_read (file, & opengl->font_height [index] [subindex], sizeof (* * opengl->font_height)); @@ -346,8 +346,8 @@ static void opengl_import_spritesheet (opengl_structure * opengl, char * data_fi opengl->font_count = 0; } -static void opengl_export_spritesheet (opengl_structure * opengl, char * data_file) { - int file = file_open (data_file, file_flag_write | file_flag_create | file_flag_truncate); +static v0 opengl_export_spritesheet (opengl_structure * opengl, c1 * data_file) { + s4 file = file_open (data_file, file_flag_write | file_flag_create | file_flag_truncate); fatal_failure (opengl->spritesheet_data == null, "opengl_export_spritesheet: OpenGL renderer can't access spritesheet data."); @@ -365,8 +365,8 @@ static void opengl_export_spritesheet (opengl_structure * opengl, char * data_fi file_write (file, opengl->font_begin, opengl->font_count * sizeof (* opengl->font_begin)); file_write (file, opengl->font_end, opengl->font_count * sizeof (* opengl->font_end)); - for (uint index = 0; index < opengl->font_count; ++index) { - for (uint subindex = 0; subindex < (uint) (opengl->font_end [index] - opengl->font_begin [index]) + 1; ++subindex) { + for (u4 index = 0; index < opengl->font_count; ++index) { + for (u4 subindex = 0; subindex < (u4) (opengl->font_end [index] - opengl->font_begin [index]) + 1; ++subindex) { file_write (file, & opengl->font_index [index] [subindex], sizeof (* * opengl->font_index)); file_write (file, & opengl->font_width [index] [subindex], sizeof (* * opengl->font_width)); file_write (file, & opengl->font_height [index] [subindex], sizeof (* * opengl->font_height)); @@ -378,8 +378,8 @@ static void opengl_export_spritesheet (opengl_structure * opengl, char * data_fi print ("/c Exported internal binary data of OpenGL spritesheet."); } -static opengl_structure * opengl_initialize (uint gameplay_framerate, uint animation_framerate, bool use_precomputed_spritesheet, - uint maximum_quads_on_screen, uint spritesheet_side) { +static opengl_structure * opengl_initialize (u4 gameplay_framerate, u4 animation_framerate, b4 use_precomputed_spritesheet, + u4 maximum_quads_on_screen, u4 spritesheet_side) { opengl_structure * opengl = allocate (sizeof (* opengl)); opengl->using_precomputed_spritesheet = use_precomputed_spritesheet; @@ -406,7 +406,7 @@ static opengl_structure * opengl_initialize (uint gameplay_framerate, uint anima static opengl_structure * opengl_deinitialize (opengl_structure * opengl) { opengl->active = false; - for (uint index = 0; index < opengl->font_count; ++index) { + for (u4 index = 0; index < opengl->font_count; ++index) { opengl->font_index [index] = deallocate (opengl->font_index [index]); opengl->font_width [index] = deallocate (opengl->font_width [index]); opengl->font_height [index] = deallocate (opengl->font_height [index]); @@ -449,8 +449,8 @@ static opengl_structure * opengl_deinitialize (opengl_structure * opengl) { return (deallocate (opengl)); } -static void opengl_configure (opengl_structure * opengl, uint window_width, uint window_height, char * window_title) { - ulong font_bitmap [190] = { +static v0 opengl_configure (opengl_structure * opengl, u4 window_width, u4 window_height, c1 * window_title) { + u8 font_bitmap [190] = { 0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000, 0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000, 0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000, @@ -485,42 +485,42 @@ static void opengl_configure (opengl_structure * opengl, uint window_width, uint 0x0000300808080408, 0x0808083000000000, 0x000000000062928c, 0x0000000000000000 }; - char * vertex_shader = + c1 * vertex_shader = "# version 330 core\n" "in vec2 vertex_xy;\n" "in vec2 vertex_uv;\n" "in vec4 vertex_rgba;\n" "out vec2 fragment_uv;\n" "out vec4 fragment_rgba;\n" - "void main () {\n" + "v0 main () {\n" " gl_Position = vec4 (vertex_xy, 0, 1);\n" " fragment_uv = vertex_uv;\n" " fragment_rgba = vertex_rgba;\n" "}\n"; - char * fragment_shader = + c1 * fragment_shader = "# version 330 core\n" "uniform sampler2D texture_p;\n" "in vec2 fragment_uv;\n" "in vec4 fragment_rgba;\n" "out vec4 data;\n" - "void main () {\n" + "v0 main () {\n" " data = texture (texture_p, fragment_uv) * fragment_rgba;\n" "}\n"; - uint * dumb_buffer = null; - uint * order = null; + u4 * dumb_buffer = null; + u4 * order = null; - uint xy_attribute = 0; - uint uv_attribute = 0; - uint rgba_attribute = 0; - //~uint flags = 0; + u4 xy_attribute = 0; + u4 uv_attribute = 0; + u4 rgba_attribute = 0; + //~u4 flags = 0; - uint u = 0; - uint v = 0; + u4 u = 0; + u4 v = 0; if (opengl->using_precomputed_spritesheet == true) { - for (uint index = 0; index < 95; ++index) { + for (u4 index = 0; index < 95; ++index) { opengl->font_index [opengl->font_count] [index] = ++opengl->sprite_count - 1; } @@ -532,13 +532,13 @@ static void opengl_configure (opengl_structure * opengl, uint window_width, uint dumb_buffer = allocate (256 * sizeof (* dumb_buffer)); - for (uint index = 0; index < 256; ++index) { + for (u4 index = 0; index < 256; ++index) { dumb_buffer [index] = 0xffffffff; } ++opengl->font_count; - uint current = opengl->font_count - 1; + u4 current = opengl->font_count - 1; opengl->font_index = reallocate (opengl->font_index, opengl->font_count * sizeof (* opengl->font_index)); opengl->font_width = reallocate (opengl->font_width, opengl->font_count * sizeof (* opengl->font_width)); @@ -553,13 +553,13 @@ static void opengl_configure (opengl_structure * opengl, uint window_width, uint opengl->font_width [opengl->font_count - 1] = allocate (95 * sizeof (* * opengl->font_width)); opengl->font_height [opengl->font_count - 1] = allocate (95 * sizeof (* * opengl->font_height)); - for (uint index = 0; index < 95; ++index) { - uint * buffer = allocate (opengl_font_width * opengl_font_height * sizeof (* buffer)); + for (u4 index = 0; index < 95; ++index) { + u4 * buffer = allocate (opengl_font_width * opengl_font_height * sizeof (* buffer)); - for (uint value = 0; value < 2; ++value) { - for (uint bit = 64; bit > 0; --bit) { - uint destination = ((value << 3) - ((bit - 1) >> 3) + 7) * opengl_font_width - ((bit - 1) & 7) + 7; - uint source = (font_bitmap [2 * index + value] >> (bit - 1)) & 1; + for (u4 value = 0; value < 2; ++value) { + for (u4 bit = 64; bit > 0; --bit) { + u4 destination = ((value << 3) - ((bit - 1) >> 3) + 7) * opengl_font_width - ((bit - 1) & 7) + 7; + u4 source = (font_bitmap [2 * index + value] >> (bit - 1)) & 1; buffer [destination] = (source) ? 0xffffffff : 0x00000000; } @@ -576,14 +576,14 @@ static void opengl_configure (opengl_structure * opengl, uint window_width, uint order = allocate (opengl->sprite_count * sizeof (* order)); - for (uint index = 0; index < opengl->sprite_count; ++index) { + for (u4 index = 0; index < opengl->sprite_count; ++index) { order [index] = index; } - for (uint index = 0; index < opengl->sprite_count; ++index) { - for (uint subindex = 0; subindex < opengl->sprite_count; ++subindex) { + for (u4 index = 0; index < opengl->sprite_count; ++index) { + for (u4 subindex = 0; subindex < opengl->sprite_count; ++subindex) { if (opengl->sprite_height [order [index]] < opengl->sprite_height [order [subindex]]) { - uint temporary = order [index]; + u4 temporary = order [index]; order [index] = order [subindex]; order [subindex] = temporary; @@ -591,7 +591,7 @@ static void opengl_configure (opengl_structure * opengl, uint window_width, uint } } - for (uint index = 0; index < opengl->sprite_count; ++index) { + for (u4 index = 0; index < opengl->sprite_count; ++index) { if (u + opengl->sprite_width [order [index]] >= opengl->spritesheet_size) { u *= 0; v += opengl->sprite_height [order [index]]; @@ -600,10 +600,10 @@ static void opengl_configure (opengl_structure * opengl, uint window_width, uint opengl->sprite_u [order [index]] = (float) u / (float) opengl->spritesheet_size; opengl->sprite_v [order [index]] = (float) v / (float) opengl->spritesheet_size; - for (uint y = 0; y < opengl->sprite_height [order [index]]; ++y) { - for (uint x = 0; x < opengl->sprite_width [order [index]]; ++x) { - uint destination = (v + y) * opengl->spritesheet_size + (u + x); - uint source = y * opengl->sprite_width [order [index]] + x; + for (u4 y = 0; y < opengl->sprite_height [order [index]]; ++y) { + for (u4 x = 0; x < opengl->sprite_width [order [index]]; ++x) { + u4 destination = (v + y) * opengl->spritesheet_size + (u + x); + u4 source = y * opengl->sprite_width [order [index]] + x; opengl->spritesheet_data [destination] = opengl->sprite_data [order [index]] [source]; } @@ -633,10 +633,10 @@ static void opengl_configure (opengl_structure * opengl, uint window_width, uint glfwInit (); - glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, 1); + glfwWindowHs4 (GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHs4 (GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHs4 (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHs4 (GLFW_OPENGL_FORWARD_COMPAT, 1); opengl->window = glfwCreateWindow ((int) window_width, (int) window_height, window_title, null, null); @@ -705,23 +705,23 @@ static void opengl_configure (opengl_structure * opengl, uint window_width, uint opengl->glLinkProgram (opengl->shader_program); opengl->glUseProgram (opengl->shader_program); - xy_attribute = (uint) opengl->glGetAttribLocation (opengl->shader_program, "vertex_xy"); + xy_attribute = (u4) opengl->glGetAttribLocation (opengl->shader_program, "vertex_xy"); opengl->glEnableVertexAttribArray (xy_attribute); - opengl->glVertexAttribPointer (xy_attribute, 2, GL_FLOAT, GL_FALSE, 8 * sizeof (float), (void *) 0); + opengl->glVertexAttribPointer (xy_attribute, 2, GL_FLOAT, GL_FALSE, 8 * sizeof (float), (v0 *) 0); - uv_attribute = (uint) opengl->glGetAttribLocation (opengl->shader_program, "vertex_uv"); + uv_attribute = (u4) opengl->glGetAttribLocation (opengl->shader_program, "vertex_uv"); opengl->glEnableVertexAttribArray (uv_attribute); - opengl->glVertexAttribPointer (uv_attribute, 2, GL_FLOAT, GL_FALSE, 8 * sizeof (float), (void *) (2 * sizeof (float))); + opengl->glVertexAttribPointer (uv_attribute, 2, GL_FLOAT, GL_FALSE, 8 * sizeof (float), (v0 *) (2 * sizeof (float))); - rgba_attribute = (uint) opengl->glGetAttribLocation (opengl->shader_program, "vertex_rgba"); + rgba_attribute = (u4) opengl->glGetAttribLocation (opengl->shader_program, "vertex_rgba"); opengl->glEnableVertexAttribArray (rgba_attribute); - opengl->glVertexAttribPointer (rgba_attribute, 4, GL_FLOAT, GL_FALSE, 8 * sizeof (float), (void *) (4 * sizeof (float))); + opengl->glVertexAttribPointer (rgba_attribute, 4, GL_FLOAT, GL_FALSE, 8 * sizeof (float), (v0 *) (4 * sizeof (float))); opengl->vertex_array = allocate (opengl->vertex_limit * sizeof (opengl->vertex_array)); opengl->index_array = allocate (opengl->index_limit * sizeof (opengl->index_array)); @@ -755,8 +755,8 @@ static void opengl_configure (opengl_structure * opengl, uint window_width, uint print ("[/2Success/-] Configured OpenGL renderer.\n"); } -static void opengl_synchronize (opengl_structure * opengl, uint colour) { - int signal_code [signal_count] = { +static v0 opengl_synchronize (opengl_structure * opengl, u4 colour) { + s4 signal_code [signal_count] = { 0, GLFW_KEY_A, GLFW_KEY_B, GLFW_KEY_C, GLFW_KEY_D, GLFW_KEY_E, GLFW_KEY_F, GLFW_KEY_G, GLFW_KEY_H, @@ -785,13 +785,13 @@ static void opengl_synchronize (opengl_structure * opengl, uint colour) { GLFW_KEY_KP_6, GLFW_KEY_KP_7, GLFW_KEY_KP_8, GLFW_KEY_KP_9 }; - float r = (float) ((colour >> 24) & 0xff) / 255.0f; - float g = (float) ((colour >> 16) & 0xff) / 255.0f; - float b = (float) ((colour >> 8) & 0xff) / 255.0f; - float a = (float) ((colour >> 0) & 0xff) / 255.0f; + f4 r = (float) ((colour >> 24) & 0xff) / 255.0f; + f4 g = (float) ((colour >> 16) & 0xff) / 255.0f; + f4 b = (float) ((colour >> 8) & 0xff) / 255.0f; + f4 a = (float) ((colour >> 0) & 0xff) / 255.0f; - int new_window_width = 0; - int new_window_height = 0; + s4 new_window_width = 0; + s4 new_window_height = 0; glClearColor (r, g, b, a); @@ -803,25 +803,25 @@ static void opengl_synchronize (opengl_structure * opengl, uint colour) { glfwGetWindowSize (opengl->window, & new_window_width, & new_window_height); - if ((opengl->window_width != (uint) new_window_width) || (opengl->window_height != (uint) new_window_height)) { + if ((opengl->window_width != (u4) new_window_width) || (opengl->window_height != (u4) new_window_height)) { if ((new_window_width <= 0) || (new_window_height <= 0)) return; glViewport (0, 0, new_window_width, new_window_height); - opengl->window_width = (uint) new_window_width; - opengl->window_height = (uint) new_window_height; + opengl->window_width = (u4) new_window_width; + opengl->window_height = (u4) new_window_height; opengl->pixel_width = 2.0f / (float) new_window_width; opengl->pixel_height = 2.0f / (float) new_window_height; } - opengl->cursor [cursor_left] = (bool) (glfwGetMouseButton (opengl->window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS); - opengl->cursor [cursor_middle] = (bool) (glfwGetMouseButton (opengl->window, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS); - opengl->cursor [cursor_right] = (bool) (glfwGetMouseButton (opengl->window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS); + opengl->cursor [cursor_left] = (b4) (glfwGetMouseButton (opengl->window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS); + opengl->cursor [cursor_middle] = (b4) (glfwGetMouseButton (opengl->window, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS); + opengl->cursor [cursor_right] = (b4) (glfwGetMouseButton (opengl->window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS); if (opengl->freeze_cursor == false) { - double x = 0.0; - double y = 0.0; + f8 x = 0.0; + f8 y = 0.0; glfwGetCursorPos (opengl->window, & x, & y); @@ -842,8 +842,8 @@ static void opengl_synchronize (opengl_structure * opengl, uint colour) { } if (opengl->freeze_signal == false) { - for (uint index = 0; index < signal_count; ++index) { - opengl->signal [index] = (bool) (glfwGetKey (opengl->window, signal_code [index]) == GLFW_PRESS); + for (u4 index = 0; index < signal_count; ++index) { + opengl->signal [index] = (b4) (glfwGetKey (opengl->window, signal_code [index]) == GLFW_PRESS); } } @@ -868,7 +868,7 @@ static void opengl_synchronize (opengl_structure * opengl, uint colour) { } if (opengl->global_tick % opengl->gameplay_framerate == 0) { - opengl->framerate = (uint) (1000000000ul / opengl->frame_time); + opengl->framerate = (u4) (1000000000ul / opengl->frame_time); } ++opengl->global_tick; @@ -880,17 +880,17 @@ static void opengl_synchronize (opengl_structure * opengl, uint colour) { opengl->frame_begin = nano_time (); } -static void opengl_render_base (opengl_structure * opengl, uint sprite, int x, int y, uint u, uint v, uint width, uint height, - float scale_x, float scale_y, int flip_x, int flip_y, - uint colour_upper_left, uint colour_upper_right, uint colour_lower_left, uint colour_lower_right) { - float screen_x = 0.0f; - float screen_y = 0.0f; - float unwrap_x = 0.0f; - float unwrap_y = 0.0f; - float screen_width = 0.0f; - float screen_height = 0.0f; - float unwrap_width = 0.0f; - float unwrap_height = 0.0f; +static v0 opengl_render_base (opengl_structure * opengl, u4 sprite, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height, + f4 scale_x, f4 scale_y, s4 flip_x, s4 flip_y, + u4 colour_upper_left, u4 colour_upper_right, u4 colour_lower_left, u4 colour_lower_right) { + f4 screen_x = 0.0f; + f4 screen_y = 0.0f; + f4 unwrap_x = 0.0f; + f4 unwrap_y = 0.0f; + f4 screen_width = 0.0f; + f4 screen_height = 0.0f; + f4 unwrap_width = 0.0f; + f4 unwrap_height = 0.0f; if ((x > (int) opengl->window_width) || (y > (int) opengl->window_height)) return; @@ -959,89 +959,89 @@ static void opengl_render_base (opengl_structure * opengl, uint sprite, int x, i opengl->index_count += 6; } -static void opengl_render_rectangle (opengl_structure * opengl, int x, int y, uint width, uint height, uint colour) { +static v0 opengl_render_rectangle (opengl_structure * opengl, s4 x, s4 y, u4 width, u4 height, u4 colour) { opengl_render_base (opengl, opengl->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16.0f, (float) height / 16.0f, 0, 0, colour, colour, colour, colour); } -static void opengl_render_rectangle_vertical_gradient (opengl_structure * opengl, int x, int y, uint width, uint height, - uint colour_up, uint colour_down) { +static v0 opengl_render_rectangle_vertical_gradient (opengl_structure * opengl, s4 x, s4 y, u4 width, u4 height, + u4 colour_up, u4 colour_down) { opengl_render_base (opengl, opengl->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16.0f, (float) height / 16.0f, 0, 0, colour_up, colour_up, colour_down, colour_down); } -static void opengl_render_rectangle_horizontal_gradient (opengl_structure * opengl, int x, int y, uint width, uint height, - uint colour_left, uint colour_right) { +static v0 opengl_render_rectangle_horizontal_gradient (opengl_structure * opengl, s4 x, s4 y, u4 width, u4 height, + u4 colour_left, u4 colour_right) { opengl_render_base (opengl, opengl->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16.0f, (float) height / 16.0f, 0, 0, colour_left, colour_right, colour_left, colour_right); } -static void opengl_render_sprite (opengl_structure * opengl, uint sprite, int x, int y) { +static v0 opengl_render_sprite (opengl_structure * opengl, u4 sprite, s4 x, s4 y) { opengl_render_base (opengl, sprite, x, y, 0, 0, opengl->sprite_width [sprite], opengl->sprite_height [sprite], 1.0f, 1.0f, 0, 0, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void opengl_render_sprite_crop (opengl_structure * opengl, uint sprite, int x, int y, uint u, uint v, uint width, uint height) { +static v0 opengl_render_sprite_crop (opengl_structure * opengl, u4 sprite, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height) { opengl_render_base (opengl, sprite, x, y, u, v, width, height, 1.0f, 1.0f, 0, 0, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void opengl_render_sprite_flip (opengl_structure * opengl, uint sprite, int x, int y, int flip_x, int flip_y) { +static v0 opengl_render_sprite_flip (opengl_structure * opengl, u4 sprite, s4 x, s4 y, s4 flip_x, s4 flip_y) { opengl_render_base (opengl, sprite, x, y, 0, 0, opengl->sprite_width [sprite], opengl->sprite_height [sprite], 1.0f, 1.0f, flip_x, flip_y, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void opengl_render_sprite_colour (opengl_structure * opengl, uint sprite, int x, int y, uint colour) { +static v0 opengl_render_sprite_colour (opengl_structure * opengl, u4 sprite, s4 x, s4 y, u4 colour) { opengl_render_base (opengl, sprite, x, y, 0, 0, opengl->sprite_width [sprite], opengl->sprite_height [sprite], 1.0f, 1.0f, 0, 0, colour, colour, colour, colour); } -static void opengl_render_sprite_control (opengl_structure * opengl, uint sprite, int x, int y, uint u, uint v, uint width, uint height, - int flip_x, int flip_y) { +static v0 opengl_render_sprite_control (opengl_structure * opengl, u4 sprite, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height, + s4 flip_x, s4 flip_y) { opengl_render_base (opengl, sprite, x, y, u, v, width, height, 1.0f, 1.0f, flip_x, flip_y, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu); } -static void opengl_render_sprite_crop_colour (opengl_structure * opengl, uint sprite, uint colour, int x, int y, uint u, uint v, uint width, uint height) { +static v0 opengl_render_sprite_crop_colour (opengl_structure * opengl, u4 sprite, u4 colour, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height) { opengl_render_base (opengl, sprite, x, y, u, v, width, height, 1.0f, 1.0f, 0, 0, colour, colour, colour, colour); } -static void opengl_render_sprite_animate (opengl_structure * opengl, uint sprite, int x, int y, uint frames, uint state, uint states) { - uint width = opengl->sprite_width [sprite] / states; - uint height = opengl->sprite_height [sprite] / frames; - uint u = width * (state % states); - uint v = height * (opengl->animation_tick % frames); +static v0 opengl_render_sprite_animate (opengl_structure * opengl, u4 sprite, s4 x, s4 y, u4 frames, u4 state, u4 states) { + u4 width = opengl->sprite_width [sprite] / states; + u4 height = opengl->sprite_height [sprite] / frames; + u4 u = width * (state % states); + u4 v = height * (opengl->animation_tick % frames); opengl_render_sprite_crop (opengl, sprite, x, y, u, v, width, height); } -static uint opengl_render_character_width (opengl_structure * opengl, char character, uint font, float scale) { +static u4 opengl_render_character_width (opengl_structure * opengl, c1 character, u4 font, f4 scale) { if ((character < opengl->font_begin [font]) || (character > opengl->font_end [font])) { return (0); } else { - uint index = opengl->font_index [font] [character - opengl->font_begin [font]]; + u4 index = opengl->font_index [font] [character - opengl->font_begin [font]]; - return ((uint) (scale * (float) opengl->sprite_width [index])); + return ((u4) (scale * (float) opengl->sprite_width [index])); } } -static uint opengl_render_character_height (opengl_structure * opengl, char character, uint font, float scale) { +static u4 opengl_render_character_height (opengl_structure * opengl, c1 character, u4 font, f4 scale) { if ((character < opengl->font_begin [font]) || (character > opengl->font_end [font])) { return (0); } else { - uint index = opengl->font_index [font] [character - opengl->font_begin [font]]; + u4 index = opengl->font_index [font] [character - opengl->font_begin [font]]; - return ((uint) (scale * (float) opengl->sprite_height [index])); + return ((u4) (scale * (float) opengl->sprite_height [index])); } } -static uint opengl_render_string_width (opengl_structure * opengl, char * string, uint font, float scale) { - uint width = 0; - uint match = 0; +static u4 opengl_render_string_width (opengl_structure * opengl, c1 * string, u4 font, f4 scale) { + u4 width = 0; + u4 match = 0; if (string == null) { return (0); } - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { if (string [index] == '\t') { width += opengl->tab_width * opengl_render_character_width (opengl, ' ', font, scale); } else if (string [index] == '\n') { @@ -1055,14 +1055,14 @@ static uint opengl_render_string_width (opengl_structure * opengl, char * string return (maximum (width, match)); } -static uint opengl_render_string_height (opengl_structure * opengl, char * string, uint font, float scale) { - uint height = opengl_render_character_height (opengl, ' ', font, scale); +static u4 opengl_render_string_height (opengl_structure * opengl, c1 * string, u4 font, f4 scale) { + u4 height = opengl_render_character_height (opengl, ' ', font, scale); if ((string == null) || (string [0] == '\0')) { return (0); } - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { if (string [index] == '\n') { height += opengl_render_character_height (opengl, ' ', font, scale); } @@ -1071,43 +1071,43 @@ static uint opengl_render_string_height (opengl_structure * opengl, char * strin return (height); } -static void opengl_render_character_base (opengl_structure * opengl, char character, uint font, int x, int y, float scale, - uint colour_upper_left, uint colour_upper_right, uint colour_lower_left, uint colour_lower_right) { +static v0 opengl_render_character_base (opengl_structure * opengl, c1 character, u4 font, s4 x, s4 y, f4 scale, + u4 colour_upper_left, u4 colour_upper_right, u4 colour_lower_left, u4 colour_lower_right) { if ((character < opengl->font_begin [font]) || (character > opengl->font_end [font])) return; if (font == opengl->default_font) { font = opengl->font_count - 1; } - uint index = opengl->font_index [font] [character - opengl->font_begin [font]]; - uint width = opengl->sprite_width [index]; - uint height = opengl->sprite_height [index]; + u4 index = opengl->font_index [font] [character - opengl->font_begin [font]]; + u4 width = opengl->sprite_width [index]; + u4 height = opengl->sprite_height [index]; opengl_render_base (opengl, index, x, y, 0, 0, width, height, scale, scale, 0, 0, colour_upper_left, colour_upper_right, colour_lower_left, colour_lower_right); } -static void opengl_render_character (opengl_structure * opengl, char character, uint font, int x, int y, float scale, uint colour) { +static v0 opengl_render_character (opengl_structure * opengl, c1 character, u4 font, s4 x, s4 y, f4 scale, u4 colour) { opengl_render_character_base (opengl, character, font, x, y, scale, colour, colour, colour, colour); } -static void opengl_render_character_vertical_gradient (opengl_structure * opengl, char character, uint font, int x, int y, float scale, - uint colour_up, uint colour_down) { +static v0 opengl_render_character_vertical_gradient (opengl_structure * opengl, c1 character, u4 font, s4 x, s4 y, f4 scale, + u4 colour_up, u4 colour_down) { opengl_render_character_base (opengl, character, font, x, y, scale, colour_up, colour_up, colour_down, colour_down); } -static void opengl_render_character_horizontal_gradient (opengl_structure * opengl, char character, uint font, int x, int y, float scale, - uint colour_left, uint colour_right) { +static v0 opengl_render_character_horizontal_gradient (opengl_structure * opengl, c1 character, u4 font, s4 x, s4 y, f4 scale, + u4 colour_left, u4 colour_right) { opengl_render_character_base (opengl, character, font, x, y, scale, colour_left, colour_right, colour_left, colour_right); } -static void opengl_render_string_base (opengl_structure * opengl, char * string, uint font, int x, int y, float scale, - uint colour_upper_left, uint colour_upper_right, uint colour_lower_left, uint colour_lower_right) { - int offset = x; +static v0 opengl_render_string_base (opengl_structure * opengl, c1 * string, u4 font, s4 x, s4 y, f4 scale, + u4 colour_upper_left, u4 colour_upper_right, u4 colour_lower_left, u4 colour_lower_right) { + s4 offset = x; if (string == null) return; - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { if (string [index] == '\t') { x += opengl->tab_width * opengl_render_character_width (opengl, ' ', font, scale); continue; @@ -1124,32 +1124,32 @@ static void opengl_render_string_base (opengl_structure * opengl, char * string, } } -static void opengl_render_string (opengl_structure * opengl, char * string, uint font, int x, int y, float scale, uint colour) { +static v0 opengl_render_string (opengl_structure * opengl, c1 * string, u4 font, s4 x, s4 y, f4 scale, u4 colour) { opengl_render_string_base (opengl, string, font, x, y, scale, colour, colour, colour, colour); } -static void opengl_render_string_vertical_gradient (opengl_structure * opengl, char * string, uint font, int x, int y, float scale, - uint colour_up, uint colour_down) { +static v0 opengl_render_string_vertical_gradient (opengl_structure * opengl, c1 * string, u4 font, s4 x, s4 y, f4 scale, + u4 colour_up, u4 colour_down) { opengl_render_string_base (opengl, string, font, x, y, scale, colour_up, colour_up, colour_down, colour_down); } -static void opengl_render_string_horizontal_gradient (opengl_structure * opengl, char * string, uint font, int x, int y, float scale, - uint colour_left, uint colour_right) { +static v0 opengl_render_string_horizontal_gradient (opengl_structure * opengl, c1 * string, u4 font, s4 x, s4 y, f4 scale, + u4 colour_left, u4 colour_right) { opengl_render_string_base (opengl, string, font, x, y, scale, colour_left, colour_right, colour_left, colour_right); } -static void opengl_render_string_full_vertical_gradient (opengl_structure * opengl, char * string, uint font, int x, int y, float scale, - uint colour_up, uint colour_down) { - int offset = x; - uint back = 0; - uint up = 0; - uint down = 0; +static v0 opengl_render_string_full_vertical_gradient (opengl_structure * opengl, c1 * string, u4 font, s4 x, s4 y, f4 scale, + u4 colour_up, u4 colour_down) { + s4 offset = x; + u4 back = 0; + u4 up = 0; + u4 down = 0; - float interpolator = 1.0f / (float) string_full_height (string); + f4 interpolator = 1.0f / (float) string_full_height (string); if (string == null) return; - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { if (string [index] == '\t') { x += opengl->tab_width * opengl_render_character_width (opengl, ' ', font, scale); continue; @@ -1169,18 +1169,18 @@ static void opengl_render_string_full_vertical_gradient (opengl_structure * open } } -static void opengl_render_string_full_horizontal_gradient (opengl_structure * opengl, char * string, uint font, int x, int y, float scale, - uint colour_left, uint colour_right) { - int offset = x; - uint back = 0; - uint left = 0; - uint right = 0; +static v0 opengl_render_string_full_horizontal_gradient (opengl_structure * opengl, c1 * string, u4 font, s4 x, s4 y, f4 scale, + u4 colour_left, u4 colour_right) { + s4 offset = x; + u4 back = 0; + u4 left = 0; + u4 right = 0; - float interpolator = 1.0f / (float) string_full_width (string, opengl->tab_width); + f4 interpolator = 1.0f / (float) string_full_width (string, opengl->tab_width); if (string == null) return; - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { if (string [index] == '\t') { x += opengl->tab_width * opengl_render_character_width (opengl, ' ', font, scale); continue; @@ -1201,7 +1201,7 @@ static void opengl_render_string_full_horizontal_gradient (opengl_structure * op } } -static void opengl_render_framerate (opengl_structure * opengl, uint font, int x, int y, float scale, uint colour) { +static v0 opengl_render_framerate (opengl_structure * opengl, u4 font, s4 x, s4 y, f4 scale, u4 colour) { opengl_render_string (opengl, number_to_string (opengl->framerate), font, x, y, scale, colour); } diff --git a/xphere.h b/xphere.h index 44e72d3..f0d7e00 100755 --- a/xphere.h +++ b/xphere.h @@ -17,69 +17,69 @@ /// for more details, if you dare, it is a lot of text that nobody wants to read... typedef struct { - float distance; - float horizontal; - float vertical; + f4 distance; + f4 horizontal; + f4 vertical; } sphere_vector; -static bool sphere_epsilon (float error) { +static b4 sphere_epsilon (f4 error) { return (error < 0.000001); } -static float sphere_distance (float x, float y, float z) { +static f4 sphere_distance (f4 x, f4 y, f4 z) { return (square_root (x * x + y * y + z * z)); } -static float sphere_horizontal (float x, float z) { +static f4 sphere_horizontal (f4 x, f4 z) { return ((sphere_epsilon (z)) ? (sign (x) * pi / 2.0f) : (arc_tangent (x / z))); } -static float sphere_vertical (float y, float z) { +static f4 sphere_vertical (f4 y, f4 z) { return ((sphere_epsilon (z)) ? (sign (y) * pi / 2.0f) : (arc_tangent (y / z))); } -static float sphere_x (float horizontal, float z) { +static f4 sphere_x (f4 horizontal, f4 z) { return (z * tangent (horizontal)); } -static float sphere_y (float vertical, float z) { +static f4 sphere_y (f4 vertical, f4 z) { return (z * tangent (vertical)); } -static float sphere_z (float distance, float horizontal, float vertical) { - float x_over_z = tangent (horizontal); - float y_over_z = tangent (vertical); +static f4 sphere_z (f4 distance, f4 horizontal, f4 vertical) { + f4 x_over_z = tangent (horizontal); + f4 y_over_z = tangent (vertical); return (distance * square_root (1.0f / (x_over_z * x_over_z + y_over_z * y_over_z + 1.0f))); } -static void sphere_transpose_x (float * distance, float * horizontal, float x) { - float origin = (* distance) * (* distance); - float offset = x * x; - float square = origin + offset + 2 * x * (* distance) * cosine (* horizontal); +static v0 sphere_transpose_x (f4 * distance, f4 * horizontal, f4 x) { + f4 origin = (* distance) * (* distance); + f4 offset = x * x; + f4 square = origin + offset + 2 * x * (* distance) * cosine (* horizontal); * distance = square_root (square); * horizontal = arc_sine ((square + offset - origin) / (2 * (* distance) * x)); } -static void sphere_transpose_y (float * distance, float * vertical, float y) { - float origin = (* distance) * (* distance); - float offset = y * y; +static v0 sphere_transpose_y (f4 * distance, f4 * vertical, f4 y) { + f4 origin = (* distance) * (* distance); + f4 offset = y * y; * distance = square_root (origin + offset + 2 * y * (* distance) * cosine (* vertical)); } -static void sphere_transpose_z (float * distance, float * horizontal, float * vertical, float z) { - float origin = (* distance) * (* distance); - float offset = z * z; - float side_a = secant (* vertical); - float side_b = tangent (* horizontal); +static v0 sphere_transpose_z (f4 * distance, f4 * horizontal, f4 * vertical, f4 z) { + f4 origin = (* distance) * (* distance); + f4 offset = z * z; + f4 side_a = secant (* vertical); + f4 side_b = tangent (* horizontal); * distance = square_root (origin + offset + 2 * z * (* distance) * square_root (1.0f / (side_a * side_a + sibe_b * side_b))); } -static void sphere_convert (sphere_vector * vector, float x, float y, float z) { +static v0 sphere_convert (sphere_vector * vector, f4 x, f4 y, f4 z) { vector->distance = sphere_distance (x, y, z); vector->horizontal = sphere_horizontal (x, z); vector->vertical = sphere_vertical ( y, z); diff --git a/xprite.h b/xprite.h index 78665b9..84922e7 100755 --- a/xprite.h +++ b/xprite.h @@ -16,7 +16,7 @@ /// warranty of merchantability or fitness for a particular purpose, because it is pointless. Please see the GNU (Geenoo) General Public License /// for more details, if you dare, it is a lot of text that nobody wants to read... -static unsigned int sprite_colour [128] = { +static unsigned s4 sprite_colour [128] = { 0x00000000, 0xff222222, 0xff444444, 0xff666666, 0xff888888, 0xffaaaaaa, 0xffcccccc, 0xffeeeeee, 0x11000000, 0xff000022, 0xff000044, 0xff000066, 0xff000088, 0xff0000aa, 0xff0000cc, 0xff0000ee, 0x22000000, 0xff002200, 0xff004400, 0xff006600, 0xff008800, 0xff00aa00, 0xff00cc00, 0xff00ee00, @@ -35,13 +35,13 @@ static unsigned int sprite_colour [128] = { 0xff000000, 0xff221122, 0xff442244, 0xff663366, 0xff884488, 0xffaa55aa, 0xffcc66cc, 0xffee77ee }; -static void * sprite_import (char * path, int * width, int * height) { - unsigned char check_width = 0; - unsigned char check_height = 0; +static v0 * sprite_import (c1 * path, s4 * width, s4 * height) { + unsigned c1 check_width = 0; + unsigned c1 check_height = 0; - int file, move; + s4 file, move; - unsigned int * data = null; + unsigned s4 * data = null; file = file_open (path, file_flag_read); @@ -57,15 +57,15 @@ static void * sprite_import (char * path, int * width, int * height) { data = allocate ((* width) * (* height) * (int) sizeof (* data)); for (move = 0; move < (* width) * (* height); ++move) { - int colour = 0; - int repeat = 0; + s4 colour = 0; + s4 repeat = 0; file_read (file, & colour, 1); if ((colour & 0x80) == 0) { data [move] = sprite_colour [colour]; } else { - int offset; + s4 offset; file_read (file, & repeat, 1); @@ -85,8 +85,8 @@ static void * sprite_import (char * path, int * width, int * height) { return (data); } -static void sprite_export (char * path, int width, int height, unsigned int * data) { - int file, move; +static v0 sprite_export (c1 * path, s4 width, s4 height, unsigned s4 * data) { + s4 file, move; file = file_open (path, file_flag_edit | file_flag_truncate | file_flag_create); @@ -97,8 +97,8 @@ static void sprite_export (char * path, int width, int height, unsigned int * da file_write (file, & height, 1); for (move = 0; move < width * height; ++move) { - int colour = 0; - int repeat = 0; + s4 colour = 0; + s4 repeat = 0; for (repeat = 1; (move + repeat < width * height) && (data [move] == data [move + repeat]) && (repeat < 256); ++repeat); @@ -122,8 +122,8 @@ static void sprite_export (char * path, int width, int height, unsigned int * da file = file_close (file); } -static void sprite_swap_channels (unsigned int * data, int width, int height) { - int move; +static v0 sprite_swap_channels (unsigned s4 * data, s4 width, s4 height) { + s4 move; for (move = 0; move < width * height; ++move) { data [move] = (data [move] & 0xff00ff00) | ((data [move] & 0xff0000) >> 16) | ((data [move] & 0xff) << 16); diff --git a/xrena.h b/xrena.h index 79ed962..10feaf5 100755 --- a/xrena.h +++ b/xrena.h @@ -19,17 +19,17 @@ #endif static struct { - ulong block_count; - ulong block_limit; + u8 block_count; + u8 block_limit; struct { - ulong count; - ulong capacity; - char * buffer; + u8 count; + u8 capacity; + c1 * buffer; } * * block_array; } * arena = null; -static void arena_initialize (void) { - ulong current = ++arena->block_count - 1; +static v0 arena_initialize (v0) { + u8 current = ++arena->block_count - 1; arena->block_limit = arena_block_limit; @@ -42,8 +42,8 @@ static void arena_initialize (void) { arena->block_array [current]->capacity = arena_block_limit; } -static void arena_deinitialize (void) { - for (ulong index = 0; index < arena->block_count; ++index) { +static v0 arena_deinitialize (v0) { + for (u8 index = 0; index < arena->block_count; ++index) { arena->block_array [index]->buffer = deallocate (arena->block_array [index]->buffer); arena->block_array [index] = deallocate (arena->block_array [index]); } @@ -52,8 +52,8 @@ static void arena_deinitialize (void) { arena = deallocate (arena); } -static void * arena_add (ulong size) { - ulong current = arena->block_count - 1; +static v0 * arena_add (u8 size) { + u8 current = arena->block_count - 1; if (arena == null) { clean_up (arena_deinitialize); @@ -71,37 +71,37 @@ static void * arena_add (ulong size) { arena->block_array [current]->count += size; - return ((void*) & arena->block_array [current]->buffer [arena->block_array [current]->count - size]); + return ((v0*) & arena->block_array [current]->buffer [arena->block_array [current]->count - size]); } -static char * arena_add_data (void * data, ulong size) { - void * pointer = arena_add (size); +static c1 * arena_add_data (v0 * data, u8 size) { + v0 * pointer = arena_add (size); memory_copy (pointer, data, size); return (pointer); } -static char * arena_add_file (char * path, uint flag, bool null_terminate) { - int file = -1; - ulong size = 0; - char * data = null; +static c1 * arena_add_file (c1 * path, u4 flag, b4 null_terminate) { + s4 file = -1; + u8 size = 0; + c1 * data = null; file = file_open (path, flag); - size = file_size (path) + (ulong) null_terminate; + size = file_size (path) + (u8) null_terminate; data = arena_add (size); - file_read (file, data, size - (ulong) null_terminate); + file_read (file, data, size - (u8) null_terminate); file = file_close (file); return (data); } -static ulong arena_usage (void) { - ulong usage = 0; +static u8 arena_usage (v0) { + u8 usage = 0; - for (ulong block = 0; block < arena->block_count; ++block) { + for (u8 block = 0; block < arena->block_count; ++block) { usage += arena->block_array [block]->count; } diff --git a/xrocessor.h b/xrocessor.h index 8934d7c..fb432e1 100755 --- a/xrocessor.h +++ b/xrocessor.h @@ -14,44 +14,45 @@ /// warranty of merchantability or fitness for a particular purpose, because it is pointless. Please see the GNU (Geenoo) General Public License /// for more details, if you dare, it is a lot of text that nobody wants to read... -//~#define token_limit (32) - -//~#include -//~#include - -static int parse_comment (char * buffer); -static int parse_include (char * buffer); -static int parse_use (char * buffer); -static int parse_alias (char * buffer); -static int parse_macro (char * buffer); -static int parse_scope (char * buffer); -static int parse_unscope (char * buffer); -static int parse_default (char * buffer); -static void parse_buffer (char * buffer, int limit); - -enum { - token_comment, token_include, token_use, token_alias, token_macro, token_scope, token_unscope, token_default -}; - -static char * token_key [token_default] = { +#define processor_token_limit (1024) + +static u8 processor_parse_comment (c1 * buffer); +static u8 processor_parse_include (c1 * buffer); +static u8 processor_parse_use (c1 * buffer); +static u8 processor_parse_alias (c1 * buffer); +static u8 processor_parse_macro (c1 * buffer); +static u8 processor_parse_scope (c1 * buffer); +static u8 processor_parse_unscope (c1 * buffer); +static u8 processor_parse_default (c1 * buffer); + +static v0 processor_parse_buffer (c1 * buffer, u8 limit); + +typedef enum { + processor_token_comment, processor_token_include, processor_token_use, processor_token_alias, + processor_token_macro, processor_token_scope, processor_token_unscope, processor_token_default, + processor_token_count +} processor_token_enumeration; + +static c1 * processor_token_key [processor_token_count - 1] = { "---", "include ", "use ", "alias ", "macro ", "scope ", "unscope " }; -static int (* parse_key [token_default + 1]) (char * buffer) = { - parse_comment, parse_include, parse_use, parse_alias, parse_macro, parse_scope, parse_unscope, parse_default +static u8 (* processor_parse_key [processor_token_count]) (c1 * buffer) = { + processor_parse_comment, processor_parse_include, processor_parse_use, processor_parse_alias, + processor_parse_macro, processor_parse_scope, processor_parse_unscope, processor_parse_default }; -static int token_count = 0; +static u4 token_count = 0; static struct { - char * data; - int size; - int type; -} * token_array [token_limit], - * token_value [token_limit]; + c1 * data; + u8 size; + s4 type; +} * token_array [processor_token_limit], + * token_value [processor_token_limit]; -static int parse_default (char * buffer) { - int select; +static u8 processor_parse_default (c1 * buffer) { + s4 select; for (select = 0; select < token_count; ++select) { if (string_compare_limit (buffer, token_array [select]->data, token_array [select]->size) == true) { @@ -68,7 +69,7 @@ static int parse_default (char * buffer) { if (character_is_separator (buffer [-1]) == false) continue; if (character_is_separator (buffer [token_array [select]->size]) == false) continue; - parse_buffer (token_value [select]->data, token_value [select]->size); + processor_parse_buffer (token_value [select]->data, token_value [select]->size); return (token_array [select]->size); } @@ -80,8 +81,8 @@ static int parse_default (char * buffer) { return (1); } -static int parse_comment (char * buffer) { - int offset; +static u8 processor_parse_comment (c1 * buffer) { + s4 offset; for (offset = 3; buffer [offset] != '\0'; ++offset) { if (buffer [offset] == '\n') break; @@ -90,9 +91,9 @@ static int parse_comment (char * buffer) { return (offset + 1); } -static int parse_use (char * buffer) { - int offset; - int length; +static u8 processor_parse_use (c1 * buffer) { + s4 offset; + s4 length; for (offset = 4; (buffer [offset] != '\0') && (character_is_blank (buffer [offset]) == true); ++offset); @@ -110,14 +111,14 @@ static int parse_use (char * buffer) { return (offset + length + 1); } -static int parse_include (char * buffer) { - int length; - int offset; - char * data; +static u8 processor_parse_include (c1 * buffer) { + s4 length; + s4 offset; + c1 * data; for (offset = 8; (buffer [offset] != '\0') && (character_is_blank (buffer [offset]) == true); ++offset); - fatal_failure (buffer [offset] != '"', "parse_include: Not a string."); + fatal_failure (buffer [offset] != '"', "processor_parse_include: Not a string."); ++token_count; @@ -132,14 +133,14 @@ static int parse_include (char * buffer) { data = arena_add_file (token_array [token_count - 1]->data, token_array [token_count - 1]->size); - parse_buffer (data, -1); + processor_parse_buffer (data, -1); return (offset + length + 1); } -static int parse_alias (char * buffer) { - int offset; - int length; +static u8 processor_parse_alias (c1 * buffer) { + s4 offset; + s4 length; for (offset = 6; (buffer [offset] != '\0') && (character_is_blank (buffer [offset]) == true); ++offset); @@ -167,9 +168,9 @@ static int parse_alias (char * buffer) { return (offset + length + 1); } -static int parse_macro (char * buffer) { - int offset; - int length; +static u8 processor_parse_macro (c1 * buffer) { + s4 offset; + s4 length; for (offset = 6; (buffer [offset] != '\0') && (character_is_blank (buffer [offset]) == true); ++offset); @@ -201,10 +202,10 @@ static int parse_macro (char * buffer) { return (offset + length + 9 + 1); } -static int parse_scope (char * buffer) { - int offset; - int length; - int select; +static u8 processor_parse_scope (c1 * buffer) { + s4 offset; + s4 length; + s4 select; for (offset = 6; (buffer [offset] != '\0') && (character_is_blank (buffer [offset]) == true); ++offset); @@ -223,10 +224,10 @@ static int parse_scope (char * buffer) { return (offset + length + 1); } -static int parse_unscope (char * buffer) { - int offset; - int length; - int select; +static u8 processor_parse_unscope (c1 * buffer) { + s4 offset; + s4 length; + s4 select; for (offset = 8; (buffer [offset] != '\0') && (character_is_blank (buffer [offset]) == true); ++offset); @@ -247,10 +248,10 @@ static int parse_unscope (char * buffer) { return (offset + length + 1); } -static void parse_buffer (char * buffer, int limit) { - int offset; - int length; - int select; +static v0 processor_parse_buffer (c1 * buffer, s4 limit) { + s4 offset; + s4 length; + s4 select; for (length = offset = 0; (buffer [offset] != '\0') && (offset != limit); offset += length) { for (select = 0; select < token_default; ++select) { @@ -275,29 +276,6 @@ static void parse_buffer (char * buffer, int limit) { continue; } - length = parse_key [select] (& buffer [offset]); + length = processor_parse_key [select] (& buffer [offset]); } } - -//~int main (int argc, char * * argv) { - //~int offset; - //~char * buffer; - - //~if (argc != 2) return (2); - - //~buffer = arena_add_file (argv [1], string_length (argv [1])); - - //~parse_buffer (buffer, -1); - - //~for (offset = 0; offset < token_count; ++offset) { - //~print ("/6entity %s:: %i == ", token_key [token_array [offset]->type], token_array [offset]->size); - //~output (token_array [offset]->data, token_array [offset]->size); - //~if ((token_array [offset]->type == token_alias) || (token_array [offset]->type == token_macro)) { - //~print (" -> "); - //~output (token_value [offset]->data, token_value [offset]->size); - //~} - //~print ("/-\n"); - //~} - - //~return (log_success); -//~} diff --git a/xscii.c b/xscii.c index 0dff01e..0e657e5 100755 --- a/xscii.c +++ b/xscii.c @@ -1,6 +1,6 @@ #include -static void echo_base (int character, int base, int colour, int effect) { +static v0 echo_base (s4 character, s4 base, s4 colour, s4 effect) { print ("/0 | /-"); echo_colour (colour, effect); @@ -18,8 +18,8 @@ static void echo_base (int character, int base, int colour, int effect) { echo_cancel (); } -static void echo_code (int character) { - char * code [] = { +static v0 echo_code (s4 character) { + c1 * code [] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", " " @@ -37,8 +37,8 @@ static void echo_code (int character) { } } -static void echo_name (int character) { - char * name [] = { +static v0 echo_name (s4 character) { + c1 * name [] = { "Null", "Start of heading", "Start of text", "End of text", "End of transmission", "Enquiry", "Acknowledge", "Bell", "Backspace", "Horizontal tab", "Line feed", "Vertical tab", @@ -78,8 +78,8 @@ static void echo_name (int character) { output (" ", 24 - string_length (name [character])); } -int main (void) { - int character; +s4 main (v0) { + s4 character; for (character = 0; character < 128; ++character) { echo_base (character, 2, colour_white, effect_normal); diff --git a/xtandard.h b/xtandard.h index 94f75a2..585f135 100755 --- a/xtandard.h +++ b/xtandard.h @@ -26,7 +26,7 @@ #include #include -#define null ((void *) 0) +#define null ((v0 *) 0) #define standard_input (STDIN_FILENO) #define standard_output (STDOUT_FILENO) @@ -50,17 +50,28 @@ #define array_length(array) (sizeof ((array)) / sizeof (* (array))) -typedef unsigned char uchar; -typedef unsigned short ushort; -typedef unsigned int uint; -typedef unsigned long ulong; +typedef void v0; +typedef char c1; + +typedef signed char s1; +typedef signed short s2; +typedef signed int s4; +typedef signed long s8; + +typedef unsigned char u1; +typedef unsigned short u2; +typedef unsigned int u4; +typedef unsigned long u8; + +typedef float f4; +typedef double f8; typedef char pstring [256]; typedef enum { false, true -} bool; +} b4; typedef enum { log_success, log_warning, log_failure, log_comment, @@ -145,14 +156,14 @@ typedef enum { signal_count } signal_enumeration; -static char * cursor_name [cursor_count] = { +static c1 * cursor_name [cursor_count] = { "---", "Left button", "Middle button", "Right button", "Scroll up", "Scroll down" }; -static char * signal_name [signal_count] = { +static c1 * signal_name [signal_count] = { "---", "A", "B", "C", "D", "E", "F", "G", "H", @@ -181,48 +192,48 @@ static char * signal_name [signal_count] = { "Key 6", "Key 7", "Key 8", "Key 9" }; -static void randomize_seed_by_time (void) { - srand ((uint) time (null)); +static v0 randomize_seed_by_time (v0) { + srand ((u4) time (null)); } -static int randomize (int from, int to) { +static s4 randomize (s4 from, s4 to) { return (rand () % (to - from + 1) + from); } -static uint urandomize (uint from, uint to) { - return ((uint) rand () % (to - from + 1) + from); +static u4 urandomize (u4 from, u4 to) { + return ((u4) rand () % (to - from + 1) + from); } -static float frandomize (float from, float to) { +static f4 frandomize (f4 from, f4 to) { return (((float) rand () / (float) RAND_MAX) * (to - from) + from); } -static int upper_bound (int a, int b) { +static s4 upper_bound (s4 a, s4 b) { return ((a > b) ? a : b); } -static int lower_bound (int a, int b) { +static s4 lower_bound (s4 a, s4 b) { return ((a < b) ? a : b); } -static void input (void * data, ulong size) { +static v0 input (v0 * data, u8 size) { read (standard_input, data, size); } -static void output (void * data, ulong size) { +static v0 output (v0 * data, u8 size) { write (standard_output, data, size); } -static void clean_up (void (* procedure) (void)) { +static v0 clean_up (v0 (* procedure) (v0)) { atexit (procedure); } #ifdef use_fatal_failure -static void fatal_failure (bool condition, char * message) { +static v0 fatal_failure (b4 condition, c1 * message) { if (condition == true) { echo ("[\x1b[1;31m FATAL \x1b[0m] "); - for (int index = 0; message [index] != '\0'; ++index) { + for (s4 index = 0; message [index] != '\0'; ++index) { output (& message [index], 1); } @@ -235,31 +246,31 @@ static void fatal_failure (bool condition, char * message) { #define fatal_failure(...) #endif -static void execute (char * command) { - int status = 0; +static v0 execute (c1 * command) { + s4 status = 0; system (command); fatal_failure (status != 0, "execute: System returned an error code."); } -static uint tick_tock (void) { - return ((uint) clock ()); +static u4 tick_tock (v0) { + return ((u4) clock ()); } -static ulong nano_time (void) { +static u8 nano_time (v0) { struct timespec time = { 0 }; - ulong result = 0; + u8 result = 0; clock_gettime (CLOCK_MONOTONIC, & time); - result = 1000000000ul * (ulong) time.tv_sec + (ulong) time.tv_nsec; + result = 1000000000ul * (u8) time.tv_sec + (u8) time.tv_nsec; return (result); } -static void nano_wait (ulong time) { +static v0 nano_wait (u8 time) { struct timespec wait = { time / 1000000000, time % 1000000000 @@ -268,26 +279,26 @@ static void nano_wait (ulong time) { while (nanosleep (& wait, null)) continue; } -static float normal_r (uint colour) { return ((float) ((colour >> 24) & 0xff) / 255.0f); } -static float normal_g (uint colour) { return ((float) ((colour >> 16) & 0xff) / 255.0f); } -static float normal_b (uint colour) { return ((float) ((colour >> 8) & 0xff) / 255.0f); } -static float normal_a (uint colour) { return ((float) ((colour >> 0) & 0xff) / 255.0f); } +static f4 normal_r (u4 colour) { return ((float) ((colour >> 24) & 0xff) / 255.0f); } +static f4 normal_g (u4 colour) { return ((float) ((colour >> 16) & 0xff) / 255.0f); } +static f4 normal_b (u4 colour) { return ((float) ((colour >> 8) & 0xff) / 255.0f); } +static f4 normal_a (u4 colour) { return ((float) ((colour >> 0) & 0xff) / 255.0f); } -static uint channel_r (uint colour) { return ((colour >> 24) & 0xff); } -static uint channel_g (uint colour) { return ((colour >> 16) & 0xff); } -static uint channel_b (uint colour) { return ((colour >> 8) & 0xff); } -static uint channel_a (uint colour) { return ((colour >> 0) & 0xff); } +static u4 channel_r (u4 colour) { return ((colour >> 24) & 0xff); } +static u4 channel_g (u4 colour) { return ((colour >> 16) & 0xff); } +static u4 channel_b (u4 colour) { return ((colour >> 8) & 0xff); } +static u4 channel_a (u4 colour) { return ((colour >> 0) & 0xff); } -static uint colour_channel_reverse (uint colour) { - uint r = channel_r (colour); - uint g = channel_g (colour); - uint b = channel_b (colour); - uint a = channel_a (colour); +static u4 colour_channel_reverse (u4 colour) { + u4 r = channel_r (colour); + u4 g = channel_g (colour); + u4 b = channel_b (colour); + u4 a = channel_a (colour); return ((a << 24) | (b << 16) | (g << 8) | (r << 0)); } -static uint colour_linear_interpolation (uint colour_a, uint colour_b, float scale) { +static u4 colour_linear_interpolation (u4 colour_a, u4 colour_b, f4 scale) { if (scale <= 0.0f) { return (colour_a); } @@ -296,16 +307,16 @@ static uint colour_linear_interpolation (uint colour_a, uint colour_b, float sca return (colour_b); } - uint r = (uint) ((1.0f - scale) * channel_r (colour_a) + scale * channel_r (colour_b)); - uint g = (uint) ((1.0f - scale) * channel_g (colour_a) + scale * channel_g (colour_b)); - uint b = (uint) ((1.0f - scale) * channel_b (colour_a) + scale * channel_b (colour_b)); - uint a = (uint) ((1.0f - scale) * channel_a (colour_a) + scale * channel_a (colour_b)); + u4 r = (u4) ((1.0f - scale) * channel_r (colour_a) + scale * channel_r (colour_b)); + u4 g = (u4) ((1.0f - scale) * channel_g (colour_a) + scale * channel_g (colour_b)); + u4 b = (u4) ((1.0f - scale) * channel_b (colour_a) + scale * channel_b (colour_b)); + u4 a = (u4) ((1.0f - scale) * channel_a (colour_a) + scale * channel_a (colour_b)); return ((r << 24) | (g << 16) | (b << 8) | (a << 0)); } -static void * allocate (ulong size) { - char * data = null; +static v0 * allocate (u8 size) { + c1 * data = null; fatal_failure (size <= 0, "allocate: Size is equal or below zero."); @@ -316,7 +327,7 @@ static void * allocate (ulong size) { return (data); } -static void * reallocate (void * data, ulong size) { +static v0 * reallocate (v0 * data, u8 size) { fatal_failure (size <= 0, "reallocate: Size is equal or below zero."); data = realloc (data, size); @@ -326,7 +337,7 @@ static void * reallocate (void * data, ulong size) { return (data); } -static void * deallocate (void * data) { +static v0 * deallocate (v0 * data) { fatal_failure (data == null, "deallocate: Data is null pointer."); free (data); @@ -334,10 +345,10 @@ static void * deallocate (void * data) { return (null); } -static void * record (void) { - char * buffer = null; - ulong offset = 0; - ulong memory = 64 * 1024; +static v0 * record (v0) { + c1 * buffer = null; + u8 offset = 0; + u8 memory = 64 * 1024; buffer = reallocate (buffer, memory); @@ -358,8 +369,8 @@ static void * record (void) { return (buffer); } -static bool character_compare_array (char character, char * character_array) { - for (ulong index = 0; character_array [index] != '\0'; ++index) { +static b4 character_compare_array (c1 character, c1 * character_array) { + for (u8 index = 0; character_array [index] != '\0'; ++index) { if (character == character_array [index]) { return (true); } @@ -368,44 +379,44 @@ static bool character_compare_array (char character, char * character_array) { return (false); } -static bool character_is_uppercase (char character) { +static b4 character_is_uppercase (c1 character) { return ((character >= 'A') && (character <= 'Z')); } -static bool character_is_lowercase (char character) { +static b4 character_is_lowercase (c1 character) { return ((character >= 'a') && (character <= 'z')); } -static bool character_is_digit (char character) { +static b4 character_is_digit (c1 character) { return ((character >= '0') && (character <= '9')); } -static bool character_is_letter (char character) { +static b4 character_is_letter (c1 character) { return (((character >= 'A') && (character <= 'Z')) || ((character >= 'a') && (character <= 'z'))); } -static bool character_is_blank (char character) { +static b4 character_is_blank (c1 character) { return ((character == ' ') || (character == '\t') || (character == '\r') || (character == '\n')); } -static bool character_is_symbol (char character) { +static b4 character_is_symbol (c1 character) { return (((character >= '!') && (character <= '/')) || ((character >= ':') && (character <= '@')) || ((character >= '[') && (character <= '`')) || ((character >= '{') && (character <= '~'))); } -static bool character_is_separator (char character) { +static b4 character_is_separator (c1 character) { return ((character != '_') && ((character_is_blank (character) == true) || (character_is_symbol (character) == true))); } -static bool character_is_identifier (char character) { +static b4 character_is_identifier (c1 character) { return ((character == '_') || (character_is_letter (character) == true) || (character_is_digit (character) == true)); } -static bool character_is_visible (char character) { +static b4 character_is_visible (c1 character) { return ((character >= '!') && (character <= '~')); } -static char * capitalize (char * string) { +static c1 * capitalize (c1 * string) { fatal_failure (string == null, "capitalize: String is null pointer."); string [0] -= (character_is_lowercase (string [0]) == true) ? ' ' : '\0'; @@ -413,28 +424,28 @@ static char * capitalize (char * string) { return (string); } -static char * uppercase (char * string) { +static c1 * uppercase (c1 * string) { fatal_failure (string == null, "uppercase: String is null pointer."); - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { string [index] += (character_is_lowercase (string [index]) == true) ? ' ' : '\0'; } return (string); } -static char * lowercase (char * string) { +static c1 * lowercase (c1 * string) { fatal_failure (string == null, "lowercase: String is null pointer."); - for (uint index = 0; string [index] != '\0'; ++index) { + for (u4 index = 0; string [index] != '\0'; ++index) { string [index] -= (character_is_uppercase (string [index]) == true) ? ' ' : '\0'; } return (string); } -static ulong string_length (char * string) { - ulong length = 0; +static u8 string_length (c1 * string) { + u8 length = 0; fatal_failure (string == null, "string_length: String is null pointer."); @@ -443,23 +454,23 @@ static ulong string_length (char * string) { return (length); } -static char * string_nullify (char * string, ulong length) { +static c1 * string_nullify (c1 * string, u8 length) { fatal_failure (string == null, "string_nullify: String is null pointer."); fatal_failure (length <= 0, "string_nullify: Length is equal or below zero."); - for (ulong index = 0; index < length; ++index) { + for (u8 index = 0; index < length; ++index) { string [index] = '\0'; } return (string); } -static char * string_reverse_limit (char * string, ulong limit) { +static c1 * string_reverse_limit (c1 * string, u8 limit) { fatal_failure (string == null, "string_reverse_limit: String is null pointer."); fatal_failure (limit <= 0, "string_reverse_limit: Limit is equal or below zero."); - for (ulong index = 0; index < limit / 2; ++index) { - char temporary = string [index]; + for (u8 index = 0; index < limit / 2; ++index) { + c1 temporary = string [index]; string [index] = string [limit - 1 - index]; string [limit - 1 - index] = temporary; @@ -468,16 +479,16 @@ static char * string_reverse_limit (char * string, ulong limit) { return (string); } -static char * string_reverse (char * string) { +static c1 * string_reverse (c1 * string) { return (string_reverse_limit (string, string_length (string))); } -static bool string_compare_limit (char * string_a, char * string_b, ulong limit) { +static b4 string_compare_limit (c1 * string_a, c1 * string_b, u8 limit) { fatal_failure (string_a == null, "string_compare_limit: First source string is null pointer."); fatal_failure (string_b == null, "string_compare_limit: Second source string is null pointer."); fatal_failure (limit <= 0, "string_compare_limit: Limit is equal or below zero."); - for (ulong index = 0; index < limit; ++index) { + for (u8 index = 0; index < limit; ++index) { if (string_a [index] != string_b [index]) { return (false); } @@ -486,46 +497,46 @@ static bool string_compare_limit (char * string_a, char * string_b, ulong limit) return (true); } -static bool string_compare (char * string_a, char * string_b) { +static b4 string_compare (c1 * string_a, c1 * string_b) { return (string_compare_limit (string_a, string_b, string_length (string_a) + 1)); } -static char * string_copy_limit (char * destination, char * source, ulong limit) { +static c1 * string_copy_limit (c1 * destination, c1 * source, u8 limit) { fatal_failure (destination == null, "string_copy_limit: Destination string is null pointer."); fatal_failure (source == null, "string_copy_limit: Source string is null pointer."); fatal_failure (limit <= 0, "string_copy_limit: Limit is equal or below zero."); - for (ulong index = 0; index < limit; ++index) { + for (u8 index = 0; index < limit; ++index) { destination [index] = source [index]; } return (destination); } -static char * string_copy (char * destination, char * source) { +static c1 * string_copy (c1 * destination, c1 * source) { return (string_copy_limit (destination, source, string_length (source) + 1)); } -static char * string_concatenate_limit (char * destination, char * source, ulong limit) { - ulong offset = string_length (destination); +static c1 * string_concatenate_limit (c1 * destination, c1 * source, u8 limit) { + u8 offset = string_length (destination); fatal_failure (destination == null, "string_concatenate_limit: Destination string is null pointer."); fatal_failure (source == null, "string_concatenate_limit: Source string is null pointer."); fatal_failure (limit <= 0, "string_concatenate_limit: Limit is equal or below zero."); - for (ulong index = 0; index < limit; ++index) { + for (u8 index = 0; index < limit; ++index) { destination [offset + index] = source [index]; } return (destination); } -static char * string_concatenate (char * destination, char * source) { +static c1 * string_concatenate (c1 * destination, c1 * source) { return (string_concatenate_limit (destination, source, string_length (source) + 1)); } -static char * string_duplicate (char * string) { - char * duplicate = null; +static c1 * string_duplicate (c1 * string) { + c1 * duplicate = null; duplicate = allocate ((string_length (string) + 1) * sizeof (* duplicate)); @@ -534,8 +545,8 @@ static char * string_duplicate (char * string) { return (duplicate); } -static char * string_duplicate_limit (char * string, uint limit) { - char * duplicate = null; +static c1 * string_duplicate_limit (c1 * string, u4 limit) { + c1 * duplicate = null; duplicate = allocate ((limit + 1) * sizeof (* duplicate)); @@ -544,10 +555,10 @@ static char * string_duplicate_limit (char * string, uint limit) { return (duplicate); } -static char * string_align_left (char * string, ulong amount, char character) { - ulong length = string_length (string); +static c1 * string_align_left (c1 * string, u8 amount, c1 character) { + u8 length = string_length (string); - for (ulong offset = length; offset < amount; ++offset) { + for (u8 offset = length; offset < amount; ++offset) { string [offset] = character; } @@ -556,24 +567,24 @@ static char * string_align_left (char * string, ulong amount, char character) { return (string); } -static void memory_nullify (void * memory, ulong size) { - char * cast = (char *) memory; +static v0 memory_nullify (v0 * memory, u8 size) { + c1 * cast = (c1 *) memory; fatal_failure (memory == null, "memory_nullify: Memory is null pointer."); - for (ulong offset = 0; offset < size; ++offset) { + for (u8 offset = 0; offset < size; ++offset) { cast [offset] = (char) 0; } } -static int memory_compare (void * memory_0, void * memory_1, ulong size) { - char * cast_0 = ( char *) memory_0; - char * cast_1 = (char *) memory_1; +static s4 memory_compare (v0 * memory_0, v0 * memory_1, u8 size) { + c1 * cast_0 = ( c1 *) memory_0; + c1 * cast_1 = (c1 *) memory_1; fatal_failure (memory_0 == null, "memory_compare: Memory is null pointer."); fatal_failure (memory_1 == null, "memory_compare: Source is null pointer."); - for (ulong offset = 0; offset < size; ++offset) { + for (u8 offset = 0; offset < size; ++offset) { if (cast_0 [offset] != cast_1 [offset]) { return (false); } @@ -582,20 +593,20 @@ static int memory_compare (void * memory_0, void * memory_1, ulong size) { return (true); } -static void memory_copy (void * destination, void * source, ulong size) { - char * cast_0 = ( char *) destination; - char * cast_1 = (char *) source; +static v0 memory_copy (v0 * destination, v0 * source, u8 size) { + c1 * cast_0 = ( c1 *) destination; + c1 * cast_1 = (c1 *) source; fatal_failure (destination == null, "memory_copy: Destination is null pointer."); fatal_failure (source == null, "memory_copy: Source is null pointer."); - for (ulong offset = 0; offset < size; ++offset) { + for (u8 offset = 0; offset < size; ++offset) { cast_0 [offset] = cast_1 [offset]; } } -static char * string_remove_extension (char * string) { - ulong length = string_length (string); +static c1 * string_remove_extension (c1 * string) { + u8 length = string_length (string); for (--length; string [length] != '.'; --length); @@ -604,12 +615,12 @@ static char * string_remove_extension (char * string) { return (string); } -static void echo_clear (void) { +static v0 echo_clear (v0) { echo ("\033[2J\033[H"); } -static void echo_colour (colour_enumeration colour, effect_enumeration effect) { - char format [8] = "\033[ ;3 m"; +static v0 echo_colour (colour_enumeration colour, effect_enumeration effect) { + c1 format [8] = "\033[ ;3 m"; format [2] = (char) (effect % effect_count) + '0'; format [5] = (char) (colour % colour_count) + '0'; @@ -617,11 +628,11 @@ static void echo_colour (colour_enumeration colour, effect_enumeration effect) { echo (format); } -static void echo_cancel (void) { +static v0 echo_cancel (v0) { echo ("\033[0m"); } -static void show_cursor (bool show) { +static v0 show_cursor (b4 show) { if (show == true) { echo ("\033[?25h"); } else { @@ -629,13 +640,13 @@ static void show_cursor (bool show) { } } -static int file_open (char * path, int mode) { +static s4 file_open (c1 * path, s4 mode) { fatal_failure (path == null, "file_open: File path is null pointer."); return (open (path, mode, 0777)); } -static int file_close (int file) { +static s4 file_close (s4 file) { fatal_failure (file == -1, "file_close: Invalid file descriptor."); close (file); @@ -643,7 +654,7 @@ static int file_close (int file) { return (-1); } -static void file_read (int file, void * data, ulong size) { +static v0 file_read (s4 file, v0 * data, u8 size) { fatal_failure (file <= -1, "file_read: File descriptor is closed or invalid."); fatal_failure (data == null, "file_read: Data is null pointer."); fatal_failure (size == 0, "file_read: Size is zero."); @@ -651,7 +662,7 @@ static void file_read (int file, void * data, ulong size) { read (file, data, size); } -static void file_write (int file, void * data, ulong size) { +static v0 file_write (s4 file, v0 * data, u8 size) { fatal_failure (file <= -1, "file_write: File descriptor is closed or invalid."); fatal_failure (data == null, "file_write: Data is null pointer."); fatal_failure (size == 0, "file_write: Size is zero."); @@ -659,28 +670,28 @@ static void file_write (int file, void * data, ulong size) { write (file, data, size); } -static void file_echo (int file, char * data) { +static v0 file_echo (s4 file, c1 * data) { file_write (file, data, string_length (data)); } -static ulong file_seek (int file, int whence) { +static u8 file_seek (s4 file, s4 whence) { fatal_failure (file == -1, "file_seek: Invalid file descriptor."); - return ((ulong) lseek (file, 0, whence)); + return ((u8) lseek (file, 0, whence)); } -static ulong file_size (char * path) { +static u8 file_size (c1 * path) { struct stat data = { 0 }; fatal_failure (path == null, "file_size: File path is null pointer."); lstat (path, & data); - return ((ulong) data.st_size); + return ((u8) data.st_size); } -static file_type_enumeration file_type (char * path) { /// SHIT BREAKS ON "./THIS/THAT.EXT"... - char * extensions [file_type_count] = { +static file_type_enumeration file_type (c1 * path) { /// SHIT BREAKS ON "./THIS/THAT.EXT"... + c1 * extensions [file_type_count] = { ".c", ".h", ".adb", ".ads", ".cpp", ".hpp", ".f90", ".mod", ".pas", ".d", ".go", ".jai", ".asm", ".eax", ".gas", ".fasm", ".hs", ".el", ".cfg", ".lua", ".sh", ".py", ".tcl", ".4th", @@ -703,20 +714,20 @@ static file_type_enumeration file_type (char * path) { /// SHIT BREAKS ON "./THI return (~ 0u); } -static bool file_exists (char * path) { +static b4 file_exists (c1 * path) { fatal_failure (path == null, "file_record: File path is null pointer."); return ((access (path, F_OK) == 0) ? true : false); } -static void file_remove (char * path) { +static v0 file_remove (c1 * path) { unlink (path); } -static void * file_record (char * path) { - int file = -1; - ulong size = 0; - char * data = null; +static v0 * file_record (c1 * path) { + s4 file = -1; + u8 size = 0; + c1 * data = null; fatal_failure (path == null, "file_record: File path is null pointer."); @@ -731,10 +742,10 @@ static void * file_record (char * path) { return (data); } -static char * file_import (char * path) { - int file = -1; - ulong size = 0; - char * data = null; +static c1 * file_import (c1 * path) { + s4 file = -1; + u8 size = 0; + c1 * data = null; fatal_failure (path == null, "file_import: File path is null pointer."); @@ -751,8 +762,8 @@ static char * file_import (char * path) { return (data); } -static void file_export (char * path, char * data) { - int file = -1; +static v0 file_export (c1 * path, c1 * data) { + s4 file = -1; fatal_failure (path == null, "file_export: File path is null pointer."); fatal_failure (data == null, "file_export: Data is null pointer."); @@ -764,17 +775,17 @@ static void file_export (char * path, char * data) { file = file_close (file); } -static void * folder_open (char * path) { +static v0 * folder_open (c1 * path) { DIR * folder = null; fatal_failure (path == null, "folder_open: Folder path is null pointer."); folder = opendir (path); - return ((void *) folder); + return ((v0 *) folder); } -static char * folder_read (void * handle) { +static c1 * folder_read (v0 * handle) { struct dirent * file = null; DIR * folder = (DIR *) handle; @@ -790,7 +801,7 @@ static char * folder_read (void * handle) { } } -static void * folder_close (void * handle) { +static v0 * folder_close (v0 * handle) { DIR * folder = (DIR *) handle; fatal_failure (handle == null, "folder_read: Folder handle is null pointer."); @@ -800,18 +811,18 @@ static void * folder_close (void * handle) { return (null); } -static char * * folder_create_path_list (char * folder, uint * path_count, bool sort) { - void * handle = null; - char * * path_array = 0; +static c1 * * folder_create_path_list (c1 * folder, u4 * path_count, b4 sort) { + v0 * handle = null; + c1 * * path_array = 0; - (void) sort; + (v0) sort; fatal_failure (folder == null, "folder_create_path_list: Folder handle is null pointer."); fatal_failure (path_count == null, "folder_create_path_list: Path count address is null pointer."); handle = folder_open (folder); - for (char * path = folder_read (handle); path != null; path = folder_read (handle)) { + for (c1 * path = folder_read (handle); path != null; path = folder_read (handle)) { if (path [0] != '.') { (* path_count) += 1; @@ -828,16 +839,16 @@ static char * * folder_create_path_list (char * folder, uint * path_count, bool return (path_array); } -static char * * folder_remove_path_list (char * * path_array, uint path_count) { - for (uint index = 0; index < path_count; ++index) { +static c1 * * folder_remove_path_list (c1 * * path_array, u4 path_count) { + for (u4 index = 0; index < path_count; ++index) { path_array [index] = deallocate (path_array [index]); } return (deallocate (path_array)); } -static char * configuration_format (char * path) { - static char buffer [512] = ""; +static c1 * configuration_format (c1 * path) { + static c1 buffer [512] = ""; string_copy (buffer, getenv ("HOME")); string_concatenate (buffer, "/.config/xolatile/"); @@ -846,29 +857,29 @@ static char * configuration_format (char * path) { return (buffer); } -static bool configuration_exists (char * path) { +static b4 configuration_exists (c1 * path) { return (file_exists (configuration_format (path))); } -static void configuration_remove (char * path) { +static v0 configuration_remove (c1 * path) { file_remove (configuration_format (path)); } -static char * configuration_import (char * path) { +static c1 * configuration_import (c1 * path) { return (file_import (configuration_format (path))); } -static void configuration_export (char * path, char * data) { +static v0 configuration_export (c1 * path, c1 * data) { file_export (configuration_format (path), data); } -static bool argument_compare (char * argument, char * short_option, char * long_option) { +static b4 argument_compare (c1 * argument, c1 * short_option, c1 * long_option) { return ((string_compare (argument, short_option) == true) || (string_compare (argument, long_option) == true)); } -static uint string_full_width (char * string, uint tab_width) { - uint width = 0; - uint count = 0; +static u4 string_full_width (c1 * string, u4 tab_width) { + u4 width = 0; + u4 count = 0; do { if (* string == '\t') { @@ -884,8 +895,8 @@ static uint string_full_width (char * string, uint tab_width) { return (width - 1); } -static uint string_full_height (char * string) { - uint height = 0; +static u4 string_full_height (c1 * string) { + u4 height = 0; do { if (* string == '\n') { @@ -896,26 +907,26 @@ static uint string_full_height (char * string) { return (height + 1); } -static uint string_limit_to_number (char * string, uint limit) { - uint number = 0; +static u4 string_limit_to_number (c1 * string, u4 limit) { + u4 number = 0; - for (uint index = 0; (string [index] != '\0') && (index < limit); ++index) { + for (u4 index = 0; (string [index] != '\0') && (index < limit); ++index) { number *= 10; - number += (uint) (string [index] - '0'); + number += (u4) (string [index] - '0'); } return (number); } -static uint string_to_number (char * string) { +static u4 string_to_number (c1 * string) { return (string_limit_to_number (string, string_length (string))); } -static char * number_to_string (int number) { - static char string [34] = ""; +static c1 * number_to_string (s4 number) { + static c1 string [34] = ""; - uint index = 0; - bool sign = false; + u4 index = 0; + b4 sign = false; string_nullify (string, sizeof (string)); @@ -932,7 +943,7 @@ static char * number_to_string (int number) { sign = false; } - for (index = 0; (number != 0) && (index < (uint) sizeof (string) - 1); ++index) { + for (index = 0; (number != 0) && (index < (u4) sizeof (string) - 1); ++index) { string [index] = (char) (number % 10) + '0'; number /= 10; } @@ -949,10 +960,10 @@ static char * number_to_string (int number) { return (string); } -static char * format_to_string (int number, bool sign, uint base, ulong amount, char character) { - static char string [36]; +static c1 * format_to_string (s4 number, b4 sign, u4 base, u8 amount, c1 character) { + static c1 string [36]; - int i; + s4 i; string_nullify (string, sizeof (string)); @@ -988,8 +999,8 @@ static char * format_to_string (int number, bool sign, uint base, ulong amount, return (string); } -static char * format (char * base, ...) { - static char string [1024]; +static c1 * format (c1 * base, ...) { + static c1 string [1024]; va_list list; @@ -1004,7 +1015,7 @@ static char * format (char * base, ...) { switch (* base) { case ('%'): string_concatenate (string, "%"); break; case ('i'): string_concatenate (string, number_to_string (va_arg (list, int))); break; - case ('s'): string_concatenate (string, va_arg (list, char *)); break; + case ('s'): string_concatenate (string, va_arg (list, c1 *)); break; default: string_concatenate (string, "?"); break; } } break; @@ -1019,7 +1030,7 @@ static char * format (char * base, ...) { return (string); } -static void print (char * format, ...) { +static v0 print (c1 * format, ...) { va_list list; va_start (list, format); @@ -1033,33 +1044,33 @@ static void print (char * format, ...) { output ("%", 1); } break; case ('i'): { - char * string = number_to_string (va_arg (list, int)); + c1 * string = number_to_string (va_arg (list, int)); output (string, string_length (string)); } break; case ('f'): { - float number = (float) va_arg (list, double); - char * upper = number_to_string ((int) number); - char * lower = number_to_string ((int) (number * 1000.0f) % 1000); + f4 number = (float) va_arg (list, double); + c1 * upper = number_to_string ((int) number); + c1 * lower = number_to_string ((int) (number * 1000.0f) % 1000); output (upper, string_length (upper)); output (".", 1); output (lower, string_length (lower)); } break; case ('t'): { - int toggle = (va_arg (list, int)); + s4 toggle = (va_arg (list, int)); echo_colour ((toggle == true) ? colour_green : colour_red, effect_normal); output ((toggle == true) ? "+" : "-", 1); echo_cancel (); } break; case ('b'): { - int boolean = (va_arg (list, int)); - output ((boolean == true) ? "true" : "false", (boolean == true) ? 4 : 5); + s4 b4ean = (va_arg (list, int)); + output ((b4ean == true) ? "true" : "false", (b4ean == true) ? 4 : 5); } break; case ('c'): { - char character = (char) va_arg (list, int); + c1 character = (char) va_arg (list, int); output (& character, 1); } break; case ('s'): { - char * string = va_arg (list, char *); + c1 * string = va_arg (list, c1 *); output (string, string_length (string)); } break; default: { @@ -1104,15 +1115,15 @@ static void print (char * format, ...) { va_end (list); } -static void uint_exchange (uint * a, uint * b) { - uint c = * a; +static v0 uint_exchange (u4 * a, u4 * b) { + u4 c = * a; * a = * b; * b = c; } -static void float_exchange (float * a, float * b) { - float c = * a; +static v0 float_exchange (f4 * a, f4 * b) { + f4 c = * a; * a = * b; * b = c; @@ -1124,22 +1135,22 @@ static void float_exchange (float * a, float * b) { #define pi (3.14159265f) -static float sign (float x) { return ((x > 0.0f) ? + 1.0f : - 1.0f); } -static float binary_sign (uint x) { return ((x > 0) ? + 1.0f : - 1.0f); } +static f4 sign (f4 x) { return ((x > 0.0f) ? + 1.0f : - 1.0f); } +static f4 binary_sign (u4 x) { return ((x > 0) ? + 1.0f : - 1.0f); } -static float square_root (float x) { return (sqrtf (x)); } -static float cube_root (float x) { return (cbrtf (x)); } +static f4 square_root (f4 x) { return (sqrtf (x)); } +static f4 cube_root (f4 x) { return (cbrtf (x)); } -static float sine (float x) { return (sinf (x)); } -static float cosine (float x) { return (cosf (x)); } -static float tangent (float x) { return (tanf (x)); } +static f4 sine (f4 x) { return (sinf (x)); } +static f4 cosine (f4 x) { return (cosf (x)); } +static f4 tangent (f4 x) { return (tanf (x)); } -static float arc_sine (float x) { return (asinf (x)); } -static float arc_cosine (float x) { return (acosf (x)); } -static float arc_tangent (float x) { return (atanf (x)); } +static f4 arc_sine (f4 x) { return (asinf (x)); } +static f4 arc_cosine (f4 x) { return (acosf (x)); } +static f4 arc_tangent (f4 x) { return (atanf (x)); } -static float cosecant (float x) { return (1.0f / sinf (x)); } -static float secant (float x) { return (1.0f / cosf (x)); } -static float cotangent (float x) { return (1.0f / tanf (x)); } +static f4 cosecant (f4 x) { return (1.0f / sinf (x)); } +static f4 secant (f4 x) { return (1.0f / cosf (x)); } +static f4 cotangent (f4 x) { return (1.0f / tanf (x)); } #endif diff --git a/xui.h b/xui.h index db61906..defcf62 100755 --- a/xui.h +++ b/xui.h @@ -49,31 +49,31 @@ typedef enum { } ui_type; typedef struct { - bool freeview; - uint ignore; - uint camera_x; - uint camera_y; - char * help_box_none; - char * help_box_text; - uint help_box_icon; - uint side_panel; - uint font; - uint monofont; - uint sprite [ui_subcount]; - uint width [ui_subcount]; - uint height [ui_subcount]; - uint separator_size; - uint icon_size; - uint overicon_size; - uint ubericon_size; - uint title_bar_size; - uint fill_bar_size; - uint scroll_bar_size; - uint camera_speed; + b4 freeview; + u4 ignore; + u4 camera_x; + u4 camera_y; + c1 * help_box_none; + c1 * help_box_text; + u4 help_box_icon; + u4 side_panel; + u4 font; + u4 monofont; + u4 sprite [ui_subcount]; + u4 width [ui_subcount]; + u4 height [ui_subcount]; + u4 separator_size; + u4 icon_size; + u4 overicon_size; + u4 ubericon_size; + u4 title_bar_size; + u4 fill_bar_size; + u4 scroll_bar_size; + u4 camera_speed; } ui_structure; static ui_structure * ui_initialize (cross_structure * cross) { - char * subtype_file_name [ui_subcount] = { + c1 * subtype_file_name [ui_subcount] = { "window_left", "window_right", "window_upper", "window_lower", "window_upper_left", "window_upper_right", "window_lower_left", "window_lower_right", "frame_left", "frame_right", "frame_upper", "frame_lower", @@ -112,8 +112,8 @@ static ui_structure * ui_initialize (cross_structure * cross) { ui->font = cross_font_import (cross, configuration_format ("xui/regular"), ' ', '~', 0xffee0000u); ui->monofont = cross_font_import (cross, configuration_format ("xui/monospace"), ' ', '~', 0xffeeee00u); - for (uint index = 0; index < ui_subcount; ++index) { - char * file_name = configuration_format (format ("xui/%s", subtype_file_name [index])); + for (u4 index = 0; index < ui_subcount; ++index) { + c1 * file_name = configuration_format (format ("xui/%s", subtype_file_name [index])); ui->sprite [index] = cross_sprite_import (cross, file_name); @@ -142,43 +142,43 @@ static ui_structure * ui_deinitialize (ui_structure * ui) { return (deallocate (ui)); } -static int ui_offset_x (cross_structure * cross, ui_structure * ui) { +static s4 ui_offset_x (cross_structure * cross, ui_structure * ui) { return (ui->camera_x - cross->window_width / 2); } -static int ui_offset_y (cross_structure * cross, ui_structure * ui) { +static s4 ui_offset_y (cross_structure * cross, ui_structure * ui) { return (ui->camera_y - cross->window_height / 2); } -static uint ui_side_panel (ui_structure * ui) { +static u4 ui_side_panel (ui_structure * ui) { return (ui->side_panel); /// MAKE IT WINDOW SIZE DEPENDENT? } -static void ui_camera_upper (ui_structure * ui) { ui->freeview = true; ui->camera_y -= ui->camera_speed; } -static void ui_camera_lower (ui_structure * ui) { ui->freeview = true; ui->camera_y += ui->camera_speed; } -static void ui_camera_left (ui_structure * ui) { ui->freeview = true; ui->camera_x -= ui->camera_speed; } -static void ui_camera_right (ui_structure * ui) { ui->freeview = true; ui->camera_x += ui->camera_speed; } +static v0 ui_camera_upper (ui_structure * ui) { ui->freeview = true; ui->camera_y -= ui->camera_speed; } +static v0 ui_camera_lower (ui_structure * ui) { ui->freeview = true; ui->camera_y += ui->camera_speed; } +static v0 ui_camera_left (ui_structure * ui) { ui->freeview = true; ui->camera_x -= ui->camera_speed; } +static v0 ui_camera_right (ui_structure * ui) { ui->freeview = true; ui->camera_x += ui->camera_speed; } -static void ui_render (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y) { +static v0 ui_render (cross_structure * cross, ui_structure * ui, ui_subtype index, s4 x, s4 y) { cross_render_sprite (cross, ui->sprite [index], x, y); } -static void ui_render_colour (cross_structure * cross, ui_structure * ui, ui_subtype index, uint colour, int x, int y) { +static v0 ui_render_colour (cross_structure * cross, ui_structure * ui, ui_subtype index, u4 colour, s4 x, s4 y) { cross_render_sprite_colour (cross, ui->sprite [index], colour, x, y); } -static void ui_subrender (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y, uint u, uint v, uint width, uint height) { +static v0 ui_subrender (cross_structure * cross, ui_structure * ui, ui_subtype index, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height) { cross_render_sprite_crop (cross, ui->sprite [index], x, y, u, v, width, height); } -static void ui_subrender_colour (cross_structure * cross, ui_structure * ui, ui_subtype index, uint colour, int x, int y, uint u, uint v, uint width, uint height) { +static v0 ui_subrender_colour (cross_structure * cross, ui_structure * ui, ui_subtype index, u4 colour, s4 x, s4 y, u4 u, u4 v, u4 width, u4 height) { cross_render_sprite_crop_colour (cross, ui->sprite [index], colour, x, y, u, v, width, height); } -static void ui_render_horizontal (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y, uint width) { - int entire = (width / ui->width [index]) * ui->width [index]; +static v0 ui_render_horizontal (cross_structure * cross, ui_structure * ui, ui_subtype index, s4 x, s4 y, u4 width) { + s4 entire = (width / ui->width [index]) * ui->width [index]; - for (uint margin = 0; margin < width / ui->width [index]; ++margin) { + for (u4 margin = 0; margin < width / ui->width [index]; ++margin) { ui_render (cross, ui, index, x + margin * ui->width [index], y); } @@ -187,10 +187,10 @@ static void ui_render_horizontal (cross_structure * cross, ui_structure * ui, ui } } -static void ui_render_horizontal_colour (cross_structure * cross, ui_structure * ui, ui_subtype index, uint colour, int x, int y, uint width) { - int entire = (width / ui->width [index]) * ui->width [index]; +static v0 ui_render_horizontal_colour (cross_structure * cross, ui_structure * ui, ui_subtype index, u4 colour, s4 x, s4 y, u4 width) { + s4 entire = (width / ui->width [index]) * ui->width [index]; - for (uint margin = 0; margin < width / ui->width [index]; ++margin) { + for (u4 margin = 0; margin < width / ui->width [index]; ++margin) { ui_render_colour (cross, ui, index, colour, x + margin * ui->width [index], y); } @@ -199,10 +199,10 @@ static void ui_render_horizontal_colour (cross_structure * cross, ui_structure * } } -static void ui_render_vertical (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y, uint height) { - int entire = (height / ui->height [index]) * ui->height [index]; +static v0 ui_render_vertical (cross_structure * cross, ui_structure * ui, ui_subtype index, s4 x, s4 y, u4 height) { + s4 entire = (height / ui->height [index]) * ui->height [index]; - for (uint margin = 0; margin < height / ui->height [index]; ++margin) { + for (u4 margin = 0; margin < height / ui->height [index]; ++margin) { ui_render (cross, ui, index, x, y + margin * ui->height [index]); } @@ -211,15 +211,15 @@ static void ui_render_vertical (cross_structure * cross, ui_structure * ui, ui_s } } -static void ui_render_background (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y, uint width, uint height) { - uint offset_x = (width / ui->width [index]) * ui->width [index]; - uint offset_y = (height / ui->height [index]) * ui->height [index]; +static v0 ui_render_background (cross_structure * cross, ui_structure * ui, ui_subtype index, s4 x, s4 y, u4 width, u4 height) { + u4 offset_x = (width / ui->width [index]) * ui->width [index]; + u4 offset_y = (height / ui->height [index]) * ui->height [index]; - uint cutoff_x = width % ui->width [index]; - uint cutoff_y = height % ui->height [index]; + u4 cutoff_x = width % ui->width [index]; + u4 cutoff_y = height % ui->height [index]; - for (uint vertical = 0; vertical < height / ui->height [index]; ++vertical) { - for (uint horizontal = 0; horizontal < width / ui->width [index]; ++horizontal) { + for (u4 vertical = 0; vertical < height / ui->height [index]; ++vertical) { + for (u4 horizontal = 0; horizontal < width / ui->width [index]; ++horizontal) { ui_render (cross, ui, index, x + horizontal * ui->width [index], y + vertical * ui->height [index]); } @@ -228,7 +228,7 @@ static void ui_render_background (cross_structure * cross, ui_structure * ui, ui } } - for (uint horizontal = 0; horizontal < width / ui->width [index]; ++horizontal) { + for (u4 horizontal = 0; horizontal < width / ui->width [index]; ++horizontal) { ui_subrender (cross, ui, index, x + horizontal * ui->width [index], y + offset_y, 0, 0, ui->width [index], cutoff_y); } @@ -237,29 +237,29 @@ static void ui_render_background (cross_structure * cross, ui_structure * ui, ui } } -static void ui_screen_overlay (cross_structure * cross) { +static v0 ui_screen_overlay (cross_structure * cross) { cross_render_rectangle_vertical_gradient (cross, 0, 0, cross->window_width, cross->window_height / 2, 0xcc, 0x00); cross_render_rectangle_vertical_gradient (cross, 0, cross->window_height / 2, cross->window_width, cross->window_height / 2, 0x00, 0xcc); } -static void ui_render_grid (cross_structure * cross, ui_structure * ui, ui_type element, int x, int y, uint width, uint height, uint margin, bool background) { - uint upper_length = width - ui->width [element + 4] - ui->width [element + 5]; - uint lower_length = width - ui->width [element + 6] - ui->width [element + 7]; - uint left_length = height - ui->height [element + 4] - ui->height [element + 6]; - uint right_length = height - ui->height [element + 5] - ui->height [element + 7]; +static v0 ui_render_grid (cross_structure * cross, ui_structure * ui, ui_type element, s4 x, s4 y, u4 width, u4 height, u4 margin, b4 background) { + u4 upper_length = width - ui->width [element + 4] - ui->width [element + 5]; + u4 lower_length = width - ui->width [element + 6] - ui->width [element + 7]; + u4 left_length = height - ui->height [element + 4] - ui->height [element + 6]; + u4 right_length = height - ui->height [element + 5] - ui->height [element + 7]; - int upper_offset_x = ui->width [element + 4]; - int lower_offset_x = ui->width [element + 6]; - int lower_offset_y = height - ui->height [element + 3]; + s4 upper_offset_x = ui->width [element + 4]; + s4 lower_offset_x = ui->width [element + 6]; + s4 lower_offset_y = height - ui->height [element + 3]; - int right_offset_x = width - ui->width [element + 1]; - int left_offset_y = ui->height [element + 4]; - int right_offset_y = ui->height [element + 5]; + s4 right_offset_x = width - ui->width [element + 1]; + s4 left_offset_y = ui->height [element + 4]; + s4 right_offset_y = ui->height [element + 5]; - int upper_right_offset_x = width - ui->width [element + 5]; - int lower_right_offset_x = width - ui->width [element + 7]; - int lower_left_offset_y = height - ui->height [element + 6]; - int lower_right_offset_y = height - ui->height [element + 7]; + s4 upper_right_offset_x = width - ui->width [element + 5]; + s4 lower_right_offset_x = width - ui->width [element + 7]; + s4 lower_left_offset_y = height - ui->height [element + 6]; + s4 lower_right_offset_y = height - ui->height [element + 7]; if ((background == true) && (width > 2 * margin) && (height > 2 * margin)) { ui_render_background (cross, ui, element + 8, x + margin, y + margin, width - 2 * margin, height - 2 * margin); @@ -277,29 +277,29 @@ static void ui_render_grid (cross_structure * cross, ui_structure * ui, ui_type ui_render (cross, ui, element + 7, x + lower_right_offset_x, y + lower_right_offset_y); } -static void ui_render_window (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) { +static v0 ui_render_window (cross_structure * cross, ui_structure * ui, s4 x, s4 y, u4 width, u4 height) { ui_render_grid (cross, ui, ui_window, x, y, width, height, 0, false); } -static void ui_render_frame (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) { +static v0 ui_render_frame (cross_structure * cross, ui_structure * ui, s4 x, s4 y, u4 width, u4 height) { ui_render_grid (cross, ui, ui_frame, x, y, width, height, 0, false); } -static void ui_render_status (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) { +static v0 ui_render_status (cross_structure * cross, ui_structure * ui, s4 x, s4 y, u4 width, u4 height) { ui_render_grid (cross, ui, ui_status, x, y, width, height, 16, true); } -static void ui_render_menu (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) { +static v0 ui_render_menu (cross_structure * cross, ui_structure * ui, s4 x, s4 y, u4 width, u4 height) { ui_render_grid (cross, ui, ui_menu, x, y, width, height, 24, true); } -static void ui_render_button (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) { +static v0 ui_render_button (cross_structure * cross, ui_structure * ui, s4 x, s4 y, u4 width, u4 height) { ui_render_grid (cross, ui, ui_button, x, y, width, height, 16, true); } -static void ui_render_separator (cross_structure * cross, ui_structure * ui, int x, int y, uint width) { - uint margin = ui->width [ui_separator_left]; - uint length = width - margin - ui->width [ui_separator_right]; +static v0 ui_render_separator (cross_structure * cross, ui_structure * ui, s4 x, s4 y, u4 width) { + u4 margin = ui->width [ui_separator_left]; + u4 length = width - margin - ui->width [ui_separator_right]; ui_render (cross, ui, ui_separator_left, x, y); @@ -310,9 +310,9 @@ static void ui_render_separator (cross_structure * cross, ui_structure * ui, int ui_render (cross, ui, ui_separator_center, x + (width - ui->width [ui_separator_center]) / 2, y); } -static void ui_render_title_bar (cross_structure * cross, ui_structure * ui, char * title, int x, int y, uint width) { - uint margin = ui->width [ui_title_bar_left]; - uint length = width - margin - ui->width [ui_title_bar_right]; +static v0 ui_render_title_bar (cross_structure * cross, ui_structure * ui, c1 * title, s4 x, s4 y, u4 width) { + u4 margin = ui->width [ui_title_bar_left]; + u4 length = width - margin - ui->width [ui_title_bar_right]; ui_render (cross, ui, ui_title_bar_left, x, y); @@ -323,15 +323,15 @@ static void ui_render_title_bar (cross_structure * cross, ui_structure * ui, cha cross_render_string (cross, title, ui->font, x + margin + 8, y + 8, 1, 0x112233ff); } -static void ui_render_icon_and_text (cross_structure * cross, ui_structure * ui, char * title, uint icon, int x, int y) { +static v0 ui_render_icon_and_text (cross_structure * cross, ui_structure * ui, c1 * title, u4 icon, s4 x, s4 y) { cross_render_sprite (cross, icon, x, y); cross_render_string (cross, title, ui->font, x - 2 + ui->icon_size, y + 2, 1, 0x112233ffu); } -static void ui_render_scroll_bar (cross_structure * cross, ui_structure * ui, float slider, int x, int y, uint height) { - uint margin = ui->height [ui_scroll_bar_upper]; - uint length = height - margin - ui->height [ui_scroll_bar_lower]; +static v0 ui_render_scroll_bar (cross_structure * cross, ui_structure * ui, f4 slider, s4 x, s4 y, u4 height) { + u4 margin = ui->height [ui_scroll_bar_upper]; + u4 length = height - margin - ui->height [ui_scroll_bar_lower]; ui_render (cross, ui, ui_scroll_bar_upper, x, y); @@ -339,12 +339,12 @@ static void ui_render_scroll_bar (cross_structure * cross, ui_structure * ui, fl ui_render (cross, ui, ui_scroll_bar_lower, x, y + margin + length); - ui_render (cross, ui, ui_scroll_bar_slider, x, y + margin + (uint) (slider * (float) (length - ui->height [ui_scroll_bar_slider]))); + ui_render (cross, ui, ui_scroll_bar_slider, x, y + margin + (u4) (slider * (float) (length - ui->height [ui_scroll_bar_slider]))); } -static void ui_render_fill_bar (cross_structure * cross, ui_structure * ui, float fill, uint colour, int x, int y, uint width) { - uint margin = ui->width [ui_fill_bar_left]; - uint length = width - margin - ui->width [ui_fill_bar_right]; +static v0 ui_render_fill_bar (cross_structure * cross, ui_structure * ui, f4 fill, u4 colour, s4 x, s4 y, u4 width) { + u4 margin = ui->width [ui_fill_bar_left]; + u4 length = width - margin - ui->width [ui_fill_bar_right]; ui_render (cross, ui, ui_fill_bar_left, x, y); @@ -352,10 +352,10 @@ static void ui_render_fill_bar (cross_structure * cross, ui_structure * ui, floa ui_render (cross, ui, ui_fill_bar_right, x + margin + length, y); - ui_render_horizontal_colour (cross, ui, ui_fill_bar_base, colour, x + margin, y, (uint) (fill * (float) length)); + ui_render_horizontal_colour (cross, ui, ui_fill_bar_base, colour, x + margin, y, (u4) (fill * (float) length)); } -static void ui_render_icon (cross_structure * cross, ui_structure * ui, uint icon, int x, int y) { +static v0 ui_render_icon (cross_structure * cross, ui_structure * ui, u4 icon, s4 x, s4 y) { cross_render_sprite (cross, ui->sprite [ui_icon_frame], x, y); if (icon != ui->ignore) { @@ -363,7 +363,7 @@ static void ui_render_icon (cross_structure * cross, ui_structure * ui, uint ico } } -static void ui_render_overicon (cross_structure * cross, ui_structure * ui, uint icon, int x, int y) { +static v0 ui_render_overicon (cross_structure * cross, ui_structure * ui, u4 icon, s4 x, s4 y) { if (icon != ui->ignore) { cross_render_sprite (cross, icon, x, y); } @@ -371,7 +371,7 @@ static void ui_render_overicon (cross_structure * cross, ui_structure * ui, uint cross_render_sprite (cross, ui->sprite [ui_overicon_frame], x, y); } -static void ui_render_ubericon (cross_structure * cross, ui_structure * ui, uint icon, int x, int y) { +static v0 ui_render_ubericon (cross_structure * cross, ui_structure * ui, u4 icon, s4 x, s4 y) { cross_render_sprite (cross, ui->sprite [ui_ubericon_frame], x, y); if (icon != ui->ignore) { @@ -379,8 +379,8 @@ static void ui_render_ubericon (cross_structure * cross, ui_structure * ui, uint } } -static void ui_render_menu_full (cross_structure * cross, ui_structure * ui, char * title, int x, int y, uint width, uint height) { - uint margin = 24; +static v0 ui_render_menu_full (cross_structure * cross, ui_structure * ui, c1 * title, s4 x, s4 y, u4 width, u4 height) { + u4 margin = 24; ui_screen_overlay (cross); diff --git a/xulkan.h b/xulkan.h index 6603ee1..7111796 100755 --- a/xulkan.h +++ b/xulkan.h @@ -22,56 +22,56 @@ #include typedef struct { - bool active; - bool reconfigure_active; - bool validation_layers; - bool hide_cursor_full; - bool hide_cursor; - uint time; - - uint cursor; /// TODO: PROPER INPUT - int cursor_x; - int cursor_y; - - bool signal [signal_count]; - - float pixel_width; - float pixel_height; - uint frame; - uint width; - uint height; - uint sprite_count; - uint * * sprite_data; - uint * sprite_width; - uint * sprite_height; - float * sprite_u; - float * sprite_v; - uint font_count; - uint * * font_index; - uint * * font_width; - uint * * font_height; - char * font_begin; - char * font_end; + b4 active; + b4 reconfigure_active; + b4 validation_layers; + b4 hide_cursor_full; + b4 hide_cursor; + u4 time; + + u4 cursor; /// TODO: PROPER INPUT + s4 cursor_x; + s4 cursor_y; + + b4 signal [signal_count]; + + f4 pixel_width; + f4 pixel_height; + u4 frame; + u4 width; + u4 height; + u4 sprite_count; + u4 * * sprite_data; + u4 * sprite_width; + u4 * sprite_height; + f4 * sprite_u; + f4 * sprite_v; + u4 font_count; + u4 * * font_index; + u4 * * font_width; + u4 * * font_height; + c1 * font_begin; + c1 * font_end; xcb_connection_t * connection; xcb_screen_t * screen; xcb_window_t window; - uint global_time; - uint gameplay_time; - uint animation_time; - uint framerate; - uint gameplay_framerate; - uint animation_framerate; - ulong frame_time_in_ns; + u4 global_time; + u4 gameplay_time; + u4 animation_time; + u4 framerate; + u4 gameplay_framerate; + u4 animation_framerate; + u8 frame_time_in_ns; VkInstance instance; VkSurfaceKHR surface; VkPhysicalDevice physical_device; VkQueue queue; - uint queue_index; + u4 queue_index; VkDevice logical_device; - uint image_count; + u4 image_count; VkExtent2D extent; VkFormat format; VkPresentModeKHR present_mode; @@ -98,27 +98,27 @@ typedef struct { VkCommandBuffer transfer_buffer; VkBuffer vertex_buffer; VkDeviceMemory vertex_memory; - float * vertex_data; + f4 * vertex_data; VkDeviceSize vertex_size; - uint vertex_count; - uint vertex_limit; + u4 vertex_count; + u4 vertex_limit; VkBuffer index_buffer; VkDeviceMemory index_memory; - uint * index_data; + u4 * index_data; VkDeviceSize index_size; - uint index_count; - uint index_limit; + u4 index_count; + u4 index_limit; VkSampler sampler; VkImage layout_image; VkDeviceMemory layout_memory; VkImageView layout_image_view; - uint * layout_data; - uint layout_size; - uint layout_width; - uint layout_height; + u4 * layout_data; + u4 layout_size; + u4 layout_width; + u4 layout_height; } vulkan_structure; -static char * vulkan_continue_execution [] = { +static c1 * vulkan_continue_execution [] = { "/s Commands successfully completed.\n", "/w Fence or query hasn't yet completed.\n", "/w Wait operation hasn't completed in the specified time.\n", @@ -127,7 +127,7 @@ static char * vulkan_continue_execution [] = { "/w Return array was too small for the result.\n" }; -static char * vulkan_break_execution [] = { +static c1 * vulkan_break_execution [] = { "/f Host memory allocation has failed.\n", "/f Device memory allocation has failed.\n", "/f Initialization of an object couldn't be completed.\n", @@ -144,7 +144,7 @@ static char * vulkan_break_execution [] = { "/f Undefined error has occured.\n" }; -static void vulkan_result (VkResult result) { +static v0 vulkan_result (VkResult result) { if (result == 0) { return; } else if (result > 0) { @@ -155,7 +155,7 @@ static void vulkan_result (VkResult result) { } } -static vulkan_structure * vulkan_initialize (ulong quad_memory, ulong layout_side, uint gameplay_framerate, uint animation_framerate) { +static vulkan_structure * vulkan_initialize (u8 quad_memory, u8 layout_side, u4 gameplay_framerate, u4 animation_framerate) { vulkan_structure * vulkan = allocate (sizeof (* vulkan)); vulkan->vertex_limit = quad_memory * 32; @@ -180,7 +180,7 @@ static vulkan_structure * vulkan_deinitialize (vulkan_structure * vulkan) { vulkan->sprite_v = deallocate (vulkan->sprite_v); if (vulkan->font_count > 0) { - for (uint index = 0; index < vulkan->font_count; ++index) { + for (u4 index = 0; index < vulkan->font_count; ++index) { vulkan->font_index [index] = deallocate (vulkan->font_index [index]); vulkan->font_width [index] = deallocate (vulkan->font_width [index]); vulkan->font_height [index] = deallocate (vulkan->font_height [index]); @@ -215,7 +215,7 @@ static vulkan_structure * vulkan_deinitialize (vulkan_structure * vulkan) { vkDestroyCommandPool (vulkan->logical_device, vulkan->command_pool, null); - for (uint index = 0; index < vulkan->image_count; ++index) { + for (u4 index = 0; index < vulkan->image_count; ++index) { vkDestroyFramebuffer (vulkan->logical_device, vulkan->framebuffers [index], null); } @@ -228,7 +228,7 @@ static vulkan_structure * vulkan_deinitialize (vulkan_structure * vulkan) { vkDestroyDescriptorSetLayout (vulkan->logical_device, vulkan->descriptor_set_layout, null); vkDestroyRenderPass (vulkan->logical_device, vulkan->render_pass, null); - for (uint index = 0; index < vulkan->image_count; ++index) { + for (u4 index = 0; index < vulkan->image_count; ++index) { vkDestroySemaphore (vulkan->logical_device, vulkan->semaphore_set_1 [index], null); vkDestroySemaphore (vulkan->logical_device, vulkan->semaphore_set_2 [index], null); vkDestroyFence (vulkan->logical_device, vulkan->fence_set_1 [index], null); @@ -238,7 +238,7 @@ static vulkan_structure * vulkan_deinitialize (vulkan_structure * vulkan) { vulkan->semaphore_set_2 = deallocate (vulkan->semaphore_set_2); vulkan->fence_set_1 = deallocate (vulkan->fence_set_1); - for (uint index = 0; index < vulkan->image_count; ++index) { + for (u4 index = 0; index < vulkan->image_count; ++index) { vkDestroyImageView (vulkan->logical_device, vulkan->image_views [index], null); } @@ -261,9 +261,9 @@ static vulkan_structure * vulkan_deinitialize (vulkan_structure * vulkan) { return (deallocate (vulkan)); } -static uint vulkan_choose_memory_property (vulkan_structure * vulkan, uint wanted) { - uint index = 0; - uint usable = 0; +static u4 vulkan_choose_memory_property (vulkan_structure * vulkan, u4 wanted) { + u4 index = 0; + u4 usable = 0; VkPhysicalDeviceMemoryProperties memory_properties = { 0 }; @@ -282,8 +282,8 @@ static uint vulkan_choose_memory_property (vulkan_structure * vulkan, uint wante return (usable); } -static void vulkan_create_buffer (vulkan_structure * vulkan, VkBuffer * buffer, VkDeviceMemory * memory, VkDeviceSize size, VkMemoryPropertyFlags usage) { - uint wanted_memory_index = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; +static v0 vulkan_create_buffer (vulkan_structure * vulkan, VkBuffer * buffer, VkDeviceMemory * memory, VkDeviceSize size, VkMemoryPropertyFlags usage) { + u4 wanted_memory_index = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; VkBufferCreateInfo buffer_information = { 0 }; VkMemoryRequirements memory_requirements = { 0 }; @@ -307,7 +307,7 @@ static void vulkan_create_buffer (vulkan_structure * vulkan, VkBuffer * buffer, vulkan_result (vkBindBufferMemory (vulkan->logical_device, * buffer, * memory, 0)); } -static void vulkan_begin_command_buffer (vulkan_structure * vulkan) { +static v0 vulkan_begin_command_buffer (vulkan_structure * vulkan) { VkCommandBufferAllocateInfo command_buffer_allocation_information = { 0 }; VkCommandBufferBeginInfo command_buffer_begin_information = { 0 }; @@ -324,7 +324,7 @@ static void vulkan_begin_command_buffer (vulkan_structure * vulkan) { vulkan_result (vkBeginCommandBuffer (vulkan->transfer_buffer, & command_buffer_begin_information)); } -static void vulkan_end_command_buffer (vulkan_structure * vulkan) { +static v0 vulkan_end_command_buffer (vulkan_structure * vulkan) { VkSubmitInfo submit_information = { 0 }; vkEndCommandBuffer (vulkan->transfer_buffer); @@ -342,8 +342,8 @@ static void vulkan_end_command_buffer (vulkan_structure * vulkan) { vulkan->transfer_buffer = VK_NULL_HANDLE; } -static void vulkan_create_window (vulkan_structure * vulkan, char * application) { - uint window_flags [2] = { 0 }; +static v0 vulkan_create_window (vulkan_structure * vulkan, c1 * application) { + u4 window_flags [2] = { 0 }; vulkan->time = tick_tock (); @@ -367,7 +367,7 @@ static void vulkan_create_window (vulkan_structure * vulkan, char * application) XCB_EVENT_MASK_BUTTON_PRESS; xcb_create_window (vulkan->connection, vulkan->screen->root_depth, vulkan->window, vulkan->screen->root, 0, 0, - (ushort) vulkan->width, (ushort) vulkan->height, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT, + (u2) vulkan->width, (u2) vulkan->height, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT, vulkan->screen->root_visual, XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, window_flags); print ("/c Created /3XCB window/-.\n"); @@ -383,31 +383,31 @@ static void vulkan_create_window (vulkan_structure * vulkan, char * application) print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_instance (vulkan_structure * vulkan, char * application) { - uint current = 0; - uint general = 0; +static v0 vulkan_create_instance (vulkan_structure * vulkan, c1 * application) { + u4 current = 0; + u4 general = 0; VkApplicationInfo application_information = { 0 }; VkInstanceCreateInfo instance_information = { 0 }; - uint instance_layer_count = 0; - uint * instance_layer_index = null; + u4 instance_layer_count = 0; + u4 * instance_layer_index = null; VkLayerProperties * instance_layer_array = null; - uint instance_extension_count = 0; - uint * instance_extension_index = null; + u4 instance_extension_count = 0; + u4 * instance_extension_index = null; VkExtensionProperties * instance_extension_array = null; - uint default_instance_layer_count = (uint) (vulkan->validation_layers == true); - uint default_instance_extension_count = 2; + u4 default_instance_layer_count = (u4) (vulkan->validation_layers == true); + u4 default_instance_extension_count = 2; - char * default_instance_layer_array [VK_MAX_EXTENSION_NAME_SIZE] = { + c1 * default_instance_layer_array [VK_MAX_EXTENSION_NAME_SIZE] = { "VK_LAYER_KHRONOS_validation" //~"VK_LAYER_LUNARG_parameter_validation", //~"VK_LAYER_LUNARG_core_validation", //~"VK_LAYER_LUNARG_standard_validation" }; - char * default_instance_extension_array [VK_MAX_EXTENSION_NAME_SIZE] = { + c1 * default_instance_extension_array [VK_MAX_EXTENSION_NAME_SIZE] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_XCB_SURFACE_EXTENSION_NAME }; @@ -425,7 +425,7 @@ static void vulkan_create_instance (vulkan_structure * vulkan, char * applicatio for (current = 0; current < instance_layer_count; ++current) { for (general = 0; general < default_instance_layer_count; ++general) { - if (string_compare (instance_layer_array [current].layerName, (char *) default_instance_layer_array [general])) { + if (string_compare (instance_layer_array [current].layerName, (c1 *) default_instance_layer_array [general])) { instance_layer_index [current] = true; } } @@ -451,7 +451,7 @@ static void vulkan_create_instance (vulkan_structure * vulkan, char * applicatio for (current = 0; current < instance_extension_count; ++current) { for (general = 0; general < default_instance_extension_count; ++general) { - if (string_compare (instance_extension_array [current].extensionName, (char *) default_instance_extension_array [general])) { + if (string_compare (instance_extension_array [current].extensionName, (c1 *) default_instance_extension_array [general])) { instance_extension_index [current] = true; } } @@ -486,7 +486,7 @@ static void vulkan_create_instance (vulkan_structure * vulkan, char * applicatio print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_surface (vulkan_structure * vulkan) { +static v0 vulkan_create_surface (vulkan_structure * vulkan) { VkXcbSurfaceCreateInfoKHR surface_information = { 0 }; vulkan->time = tick_tock (); @@ -501,21 +501,21 @@ static void vulkan_create_surface (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_device (vulkan_structure * vulkan) { +static v0 vulkan_create_device (vulkan_structure * vulkan) { VkDeviceQueueCreateInfo queues = { 0 }; VkDeviceCreateInfo device_information = { 0 }; VkPhysicalDeviceMemoryProperties memory_properties = { 0 }; - uint queue_count = 0; - uint physical_device_count = 0; + u4 queue_count = 0; + u4 physical_device_count = 0; VkPhysicalDevice * physical_device_array = null; VkBool32 * support = null; - float queue_priorities [1] = { 1 }; + f4 queue_priorities [1] = { 1 }; - uint default_device_extension_count = 1; + u4 default_device_extension_count = 1; - char * default_device_extension_array [VK_MAX_EXTENSION_NAME_SIZE] = { + c1 * default_device_extension_array [VK_MAX_EXTENSION_NAME_SIZE] = { VK_KHR_SWAPCHAIN_EXTENSION_NAME }; @@ -531,12 +531,12 @@ static void vulkan_create_device (vulkan_structure * vulkan) { print ("Enumerated available physical devices.\n"); - for (uint index = 0; index < physical_device_count; ++index) { - uint general = 0; - uint current = 0; + for (u4 index = 0; index < physical_device_count; ++index) { + u4 general = 0; + u4 current = 0; - uint device_extension_count = 0; - uint * device_extension_index = null; + u4 device_extension_count = 0; + u4 * device_extension_index = null; VkExtensionProperties * device_extension_array = null; VkPhysicalDeviceProperties physical_device_properties = { 0 }; @@ -587,7 +587,7 @@ static void vulkan_create_device (vulkan_structure * vulkan) { for (current = 0; current < device_extension_count; ++current) { for (general = 0; general < default_device_extension_count; ++general) { - if (string_compare (device_extension_array [current].extensionName, (char *) default_device_extension_array [general])) { + if (string_compare (device_extension_array [current].extensionName, (c1 *) default_device_extension_array [general])) { device_extension_index [current] = true; } } @@ -652,11 +652,11 @@ static void vulkan_create_device (vulkan_structure * vulkan) { support = allocate (queue_count * sizeof (VkBool32)); - for (uint index = 0; index < queue_count; ++index) { + for (u4 index = 0; index < queue_count; ++index) { vulkan_result (vkGetPhysicalDeviceSurfaceSupportKHR (vulkan->physical_device, index, vulkan->surface, & support [index])); } - for (uint index = 0; (index != queue_count) && (! (vulkan->queue_index = support [index] ? (index++) : 0)); ); + for (u4 index = 0; (index != queue_count) && (! (vulkan->queue_index = support [index] ? (index++) : 0)); ); support = deallocate (support); @@ -664,7 +664,7 @@ static void vulkan_create_device (vulkan_structure * vulkan) { print ("Found /2Vulkan physical device/- memory properties.\n"); - for (uint index = 0; index < memory_properties.memoryTypeCount; ++index) { + for (u4 index = 0; index < memory_properties.memoryTypeCount; ++index) { print ("> %i\n", memory_properties.memoryTypes [index].propertyFlags); } @@ -672,7 +672,7 @@ static void vulkan_create_device (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_choose_extent (vulkan_structure * vulkan) { +static v0 vulkan_choose_extent (vulkan_structure * vulkan) { VkSurfaceCapabilitiesKHR capabilities = { 0 }; vulkan->time = tick_tock (); @@ -697,8 +697,8 @@ static void vulkan_choose_extent (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_choose_format (vulkan_structure * vulkan) { - uint format_count = 0; +static v0 vulkan_choose_format (vulkan_structure * vulkan) { + u4 format_count = 0; VkSurfaceFormatKHR * format_array = null; vulkan->time = tick_tock (); @@ -719,8 +719,8 @@ static void vulkan_choose_format (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_choose_present_mode (vulkan_structure * vulkan) { - uint present_mode_count = 0; +static v0 vulkan_choose_present_mode (vulkan_structure * vulkan) { + u4 present_mode_count = 0; VkPresentModeKHR * present_mode_array = null; vulkan->time = tick_tock (); @@ -740,7 +740,7 @@ static void vulkan_choose_present_mode (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_swapchain (vulkan_structure * vulkan) { +static v0 vulkan_create_swapchain (vulkan_structure * vulkan) { VkSwapchainCreateInfoKHR swapchain_information = { 0 }; vulkan->time = tick_tock (); @@ -768,8 +768,8 @@ static void vulkan_create_swapchain (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_images (vulkan_structure * vulkan) { - uint temporary = vulkan->image_count; +static v0 vulkan_create_images (vulkan_structure * vulkan) { + u4 temporary = vulkan->image_count; vulkan->time = tick_tock (); @@ -783,7 +783,7 @@ static void vulkan_create_images (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_image_views (vulkan_structure * vulkan) { +static v0 vulkan_create_image_views (vulkan_structure * vulkan) { VkComponentMapping component_mapping = { 0 }; VkImageSubresourceRange image_subresource_range = { 0 }; VkImageViewCreateInfo image_view_information = { 0 }; @@ -809,7 +809,7 @@ static void vulkan_create_image_views (vulkan_structure * vulkan) { image_view_information.components = component_mapping; image_view_information.subresourceRange = image_subresource_range; - for (uint index = 0; index < vulkan->image_count; ++index) { + for (u4 index = 0; index < vulkan->image_count; ++index) { image_view_information.image = vulkan->images [index]; vulkan_result (vkCreateImageView (vulkan->logical_device, & image_view_information, null, & vulkan->image_views [index])); @@ -819,7 +819,7 @@ static void vulkan_create_image_views (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_semaphores (vulkan_structure * vulkan) { +static v0 vulkan_create_semaphores (vulkan_structure * vulkan) { VkSemaphoreCreateInfo semaphore_information = { 0 }; vulkan->time = tick_tock (); @@ -829,7 +829,7 @@ static void vulkan_create_semaphores (vulkan_structure * vulkan) { semaphore_information.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; - for (uint index = 0; index < vulkan->image_count; ++index) { + for (u4 index = 0; index < vulkan->image_count; ++index) { vulkan_result (vkCreateSemaphore (vulkan->logical_device, & semaphore_information, null, & vulkan->semaphore_set_1 [index])); vulkan_result (vkCreateSemaphore (vulkan->logical_device, & semaphore_information, null, & vulkan->semaphore_set_2 [index])); } @@ -838,8 +838,8 @@ static void vulkan_create_semaphores (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_fences (vulkan_structure * vulkan) { - uint index = 0; +static v0 vulkan_create_fences (vulkan_structure * vulkan) { + u4 index = 0; VkFenceCreateInfo fence_information = { 0 }; @@ -858,7 +858,7 @@ static void vulkan_create_fences (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_render_pass (vulkan_structure * vulkan) { +static v0 vulkan_create_render_pass (vulkan_structure * vulkan) { VkAttachmentDescription attachment_description = { 0 }; VkAttachmentReference attachment_reference = { 0 }; VkSubpassDescription subpass_description = { 0 }; @@ -881,7 +881,7 @@ static void vulkan_create_render_pass (vulkan_structure * vulkan) { attachment_reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; subpass_description.flags = 0; - subpass_description.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; + subpass_description.pipelineBindPos4 = VK_PIPELINE_BIND_POINT_GRAPHICS; subpass_description.inputAttachmentCount = 0; subpass_description.pInputAttachments = null; subpass_description.colorAttachmentCount = 1; @@ -920,7 +920,7 @@ static void vulkan_create_render_pass (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_descriptor_set_layout (vulkan_structure * vulkan) { +static v0 vulkan_create_descriptor_set_layout (vulkan_structure * vulkan) { VkDescriptorSetLayoutBinding descriptor_set_layout_bindings [2] = { { 0 } }; VkDescriptorSetLayoutCreateInfo descriptor_set_layout_information = { 0 }; @@ -948,8 +948,8 @@ static void vulkan_create_descriptor_set_layout (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_vertex_shader (vulkan_structure * vulkan) { - uint vertex_shader_code [] = { +static v0 vulkan_create_vertex_shader (vulkan_structure * vulkan) { + u4 vertex_shader_code [] = { 0x07230203, 0x00010000, 0x000d000b, 0x00000028, 0x00000000, 0x00020011, 0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x000b000f, 0x00000000, 0x00000004, 0x6e69616d, 0x00000000, 0x0000000d, 0x00000012, 0x00000021, @@ -1006,8 +1006,8 @@ static void vulkan_create_vertex_shader (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_fragment_shader (vulkan_structure * vulkan) { - uint fragment_shader_code [] = { +static v0 vulkan_create_fragment_shader (vulkan_structure * vulkan) { + u4 fragment_shader_code [] = { 0x07230203, 0x00010000, 0x000d000b, 0x00000018, 0x00000000, 0x00020011, 0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0008000f, 0x00000004, 0x00000004, 0x6e69616d, 0x00000000, 0x00000009, 0x00000011, 0x00000015, @@ -1047,7 +1047,7 @@ static void vulkan_create_fragment_shader (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_pipeline_layout (vulkan_structure * vulkan) { +static v0 vulkan_create_pipeline_layout (vulkan_structure * vulkan) { VkPipelineLayoutCreateInfo pipeline_layout_information = { 0 }; vulkan->time = tick_tock (); @@ -1062,7 +1062,7 @@ static void vulkan_create_pipeline_layout (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_pipeline (vulkan_structure * vulkan) { +static v0 vulkan_create_pipeline (vulkan_structure * vulkan) { VkPipelineShaderStageCreateInfo pipeline_shader_stage_information [2] = { { 0 } }; VkPipelineInputAssemblyStateCreateInfo pipeline_input_assembly_state_information = { 0 }; VkVertexInputBindingDescription vertex_input_binding_description [1] = { { 0 } }; @@ -1204,7 +1204,7 @@ static void vulkan_create_pipeline (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_framebuffers (vulkan_structure * vulkan) { +static v0 vulkan_create_framebuffers (vulkan_structure * vulkan) { VkFramebufferCreateInfo framebuffer_information = { 0 }; vulkan->time = tick_tock (); @@ -1218,7 +1218,7 @@ static void vulkan_create_framebuffers (vulkan_structure * vulkan) { framebuffer_information.height = vulkan->extent.height; framebuffer_information.layers = 1; - for (uint index = 0; index < vulkan->image_count; ++index) { + for (u4 index = 0; index < vulkan->image_count; ++index) { framebuffer_information.pAttachments = & vulkan->image_views [index]; vulkan_result (vkCreateFramebuffer (vulkan->logical_device, & framebuffer_information, null, & vulkan->framebuffers [index])); @@ -1228,7 +1228,7 @@ static void vulkan_create_framebuffers (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_command_pool (vulkan_structure * vulkan) { +static v0 vulkan_create_command_pool (vulkan_structure * vulkan) { VkCommandPoolCreateInfo command_pool_information = { 0 }; vulkan->time = tick_tock (); @@ -1243,7 +1243,7 @@ static void vulkan_create_command_pool (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_command_buffers (vulkan_structure * vulkan) { +static v0 vulkan_create_command_buffers (vulkan_structure * vulkan) { VkCommandBufferAllocateInfo command_buffer_information = { 0 }; vulkan->time = tick_tock (); @@ -1261,10 +1261,10 @@ static void vulkan_create_command_buffers (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_vertex_buffer (vulkan_structure * vulkan) { +static v0 vulkan_create_vertex_buffer (vulkan_structure * vulkan) { VkBuffer transfer_buffer = VK_NULL_HANDLE; VkDeviceMemory transfer_memory = VK_NULL_HANDLE; - void * transfer_void = null; + v0 * transfer_v0 = null; VkBufferCopy copy_information = { 0 }; /* @@ -1274,9 +1274,9 @@ static void vulkan_create_vertex_buffer (vulkan_structure * vulkan) { vulkan_create_buffer (vulkan, & transfer_buffer, & transfer_memory, vulkan->vertex_size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT); - vulkan_result (vkMapMemory (vulkan->logical_device, transfer_memory, 0, vulkan->vertex_size, 0, & transfer_void)); + vulkan_result (vkMapMemory (vulkan->logical_device, transfer_memory, 0, vulkan->vertex_size, 0, & transfer_v0)); - memory_copy (transfer_void, vulkan->vertex_data, vulkan->vertex_size); + memory_copy (transfer_v0, vulkan->vertex_data, vulkan->vertex_size); vulkan_create_buffer (vulkan, & vulkan->vertex_buffer, & vulkan->vertex_memory, vulkan->vertex_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT); @@ -1298,10 +1298,10 @@ static void vulkan_create_vertex_buffer (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time);*/ } -static void vulkan_create_index_buffer (vulkan_structure * vulkan) { +static v0 vulkan_create_index_buffer (vulkan_structure * vulkan) { VkBuffer transfer_buffer = VK_NULL_HANDLE; VkDeviceMemory transfer_memory = VK_NULL_HANDLE; - void * transfer_void = null; + v0 * transfer_v0 = null; VkBufferCopy copy_information = { 0 }; /* @@ -1311,9 +1311,9 @@ static void vulkan_create_index_buffer (vulkan_structure * vulkan) { vulkan_create_buffer (vulkan, & transfer_buffer, & transfer_memory, vulkan->index_size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT); - vulkan_result (vkMapMemory (vulkan->logical_device, transfer_memory, 0, vulkan->index_size, 0, & transfer_void)); + vulkan_result (vkMapMemory (vulkan->logical_device, transfer_memory, 0, vulkan->index_size, 0, & transfer_v0)); - memory_copy (transfer_void, vulkan->index_data, vulkan->index_size); + memory_copy (transfer_v0, vulkan->index_data, vulkan->index_size); vulkan_create_buffer (vulkan, & vulkan->index_buffer, & vulkan->index_memory, vulkan->index_size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT); @@ -1335,10 +1335,10 @@ static void vulkan_create_index_buffer (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time);*/ } -static void vulkan_create_image_buffer (vulkan_structure * vulkan) { +static v0 vulkan_create_image_buffer (vulkan_structure * vulkan) { VkBuffer transfer_buffer = VK_NULL_HANDLE; VkDeviceMemory transfer_memory = VK_NULL_HANDLE; - void * transfer_void = null; + v0 * transfer_v0 = null; VkExtent3D image_extent = { 0 }; VkImageCreateInfo image_information = { 0 }; @@ -1357,9 +1357,9 @@ static void vulkan_create_image_buffer (vulkan_structure * vulkan) { vulkan_create_buffer (vulkan, & transfer_buffer, & transfer_memory, vulkan->layout_size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT); - vulkan_result (vkMapMemory (vulkan->logical_device, transfer_memory, 0, vulkan->layout_size, 0, & transfer_void)); + vulkan_result (vkMapMemory (vulkan->logical_device, transfer_memory, 0, vulkan->layout_size, 0, & transfer_v0)); - memory_copy (transfer_void, vulkan->layout_data, vulkan->layout_size); + memory_copy (transfer_v0, vulkan->layout_data, vulkan->layout_size); image_extent.width = vulkan->layout_width; image_extent.height = vulkan->layout_height; @@ -1479,7 +1479,7 @@ static void vulkan_create_image_buffer (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_sampler (vulkan_structure * vulkan) { +static v0 vulkan_create_sampler (vulkan_structure * vulkan) { VkSamplerCreateInfo sampler_information = { 0 }; vulkan->time = tick_tock (); @@ -1507,7 +1507,7 @@ static void vulkan_create_sampler (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_descriptor_pool (vulkan_structure * vulkan) { +static v0 vulkan_create_descriptor_pool (vulkan_structure * vulkan) { VkDescriptorPoolSize descriptor_pool_sizes [2] = { { 0 } }; VkDescriptorPoolCreateInfo descriptor_pool_information = { 0 }; @@ -1530,14 +1530,14 @@ static void vulkan_create_descriptor_pool (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_create_descriptor_sets (vulkan_structure * vulkan) { +static v0 vulkan_create_descriptor_sets (vulkan_structure * vulkan) { VkDescriptorSetAllocateInfo descriptor_set_allocation_information = { 0 }; vulkan->time = tick_tock (); vulkan->descriptor_set_layouts = allocate (vulkan->image_count * sizeof (VkDescriptorSetLayout)); - for (uint index = 0; index < vulkan->image_count; ++index) { + for (u4 index = 0; index < vulkan->image_count; ++index) { vulkan->descriptor_set_layouts [index] = vulkan->descriptor_set_layout; } @@ -1554,7 +1554,7 @@ static void vulkan_create_descriptor_sets (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_record_descriptor_sets (vulkan_structure * vulkan) { +static v0 vulkan_record_descriptor_sets (vulkan_structure * vulkan) { VkDescriptorBufferInfo descriptor_buffer_information = { 0 }; VkDescriptorImageInfo descriptor_image_information = { 0 }; VkWriteDescriptorSet write_descriptor_set = { 0 }; @@ -1573,7 +1573,7 @@ static void vulkan_record_descriptor_sets (vulkan_structure * vulkan) { write_descriptor_set.pImageInfo = & descriptor_image_information; write_descriptor_set.pBufferInfo = null; - for (uint index = 0; index < vulkan->image_count; ++index) { + for (u4 index = 0; index < vulkan->image_count; ++index) { write_descriptor_set.dstSet = vulkan->descriptor_sets [index]; vkUpdateDescriptorSets (vulkan->logical_device, 1, & write_descriptor_set, 0, null); @@ -1583,8 +1583,8 @@ static void vulkan_record_descriptor_sets (vulkan_structure * vulkan) { print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time); } -static void vulkan_record_command_buffers (vulkan_structure * vulkan, int clear_colour, int frame) { - uint index = 0; +static v0 vulkan_record_command_buffers (vulkan_structure * vulkan, s4 clear_colour, s4 frame) { + u4 index = 0; VkCommandBufferBeginInfo command_buffer_begin_information = { 0 }; //~VkImageSubresourceRange image_subresource_range = { 0 }; @@ -1602,7 +1602,7 @@ static void vulkan_record_command_buffers (vulkan_structure * vulkan, int clear_ (float) ((clear_colour & 0x000000ff) >> 0) / 255 } }; - (void) frame; + (v0) frame; /* vulkan->time = tick_tock (); */ @@ -1684,7 +1684,7 @@ static void vulkan_record_command_buffers (vulkan_structure * vulkan, int clear_ print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time);*/ } -static uint vulkan_import_sprite (vulkan_structure * vulkan, uint * data, uint width, uint height) { +static u4 vulkan_import_sprite (vulkan_structure * vulkan, u4 * data, u4 width, u4 height) { fatal_failure (vulkan->active == true, "vulkan_import_sprite: Failed to import sprite, engine was already configured."); fatal_failure (data == null, "vulkan_import_sprite: Failed to import sprite, data is null pointer."); fatal_failure (width <= 0, "vulkan_import_sprite: Failed to import sprite, width is equal or below zero."); @@ -1707,15 +1707,15 @@ static uint vulkan_import_sprite (vulkan_structure * vulkan, uint * data, uint w return (vulkan->sprite_count - 1); } -static uint vulkan_import_font (vulkan_structure * vulkan, uint * data, uint image_width, uint image_height, char begin, char end, uint empty) { - uint pointer = 0; - char index = 0; - uint width = 0; - uint height = 0; - uint x = 0; - uint y = 0; +static u4 vulkan_import_font (vulkan_structure * vulkan, u4 * data, u4 image_width, u4 image_height, c1 begin, c1 end, u4 empty) { + u4 pointer = 0; + c1 index = 0; + u4 width = 0; + u4 height = 0; + u4 x = 0; + u4 y = 0; - uint * buffer = null; + u4 * buffer = null; ++vulkan->font_count; @@ -1761,23 +1761,23 @@ static uint vulkan_import_font (vulkan_structure * vulkan, uint * data, uint ima return (vulkan->font_count - 1); } -static void vulkan_bundle_layout (vulkan_structure * vulkan) { - uint * order = null; +static v0 vulkan_bundle_layout (vulkan_structure * vulkan) { + u4 * order = null; - vulkan->layout_size = vulkan->layout_width * vulkan->layout_height * (uint) sizeof (* vulkan->layout_data); + vulkan->layout_size = vulkan->layout_width * vulkan->layout_height * (u4) sizeof (* vulkan->layout_data); vulkan->layout_data = allocate (vulkan->layout_size); order = allocate (vulkan->sprite_count * sizeof (* order)); - for (uint index = 0; index < vulkan->sprite_count; ++index) { + for (u4 index = 0; index < vulkan->sprite_count; ++index) { order [index] = index; } - for (uint index = 0; index < vulkan->sprite_count; ++index) { - for (uint subindex = 0; subindex < vulkan->sprite_count; ++subindex) { + for (u4 index = 0; index < vulkan->sprite_count; ++index) { + for (u4 subindex = 0; subindex < vulkan->sprite_count; ++subindex) { if (vulkan->sprite_height [order [index]] < vulkan->sprite_height [order [subindex]]) { - int temporary = order [index]; + s4 temporary = order [index]; order [index] = order [subindex]; order [subindex] = temporary; @@ -1785,11 +1785,11 @@ static void vulkan_bundle_layout (vulkan_structure * vulkan) { } } - for (uint index = 0; index < vulkan->sprite_count; ++index) { - uint x = 0; - uint y = 0; - uint u = 0; - uint v = 0; + for (u4 index = 0; index < vulkan->sprite_count; ++index) { + u4 x = 0; + u4 y = 0; + u4 u = 0; + u4 v = 0; if (u + vulkan->sprite_width [order [index]] >= vulkan->layout_width) { @@ -1800,10 +1800,10 @@ static void vulkan_bundle_layout (vulkan_structure * vulkan) { vulkan->sprite_u [order [index]] = (float) u / (float) vulkan->layout_width; vulkan->sprite_v [order [index]] = (float) v / (float) vulkan->layout_height; - for (uint y = 0; y < vulkan->sprite_height [order [index]]; ++y) { - for (uint x = 0; x < vulkan->sprite_width [order [index]]; ++x) { - uint destination = (v + y) * vulkan->layout_width + (u + x); - uint source = y * vulkan->sprite_width [order [index]] + x; + for (u4 y = 0; y < vulkan->sprite_height [order [index]]; ++y) { + for (u4 x = 0; x < vulkan->sprite_width [order [index]]; ++x) { + u4 destination = (v + y) * vulkan->layout_width + (u + x); + u4 source = y * vulkan->sprite_width [order [index]] + x; vulkan->layout_data [destination] = vulkan->sprite_data [order [index]] [source]; } @@ -1818,10 +1818,10 @@ static void vulkan_bundle_layout (vulkan_structure * vulkan) { order = deallocate (order); } -static void vulkan_configure (vulkan_structure * vulkan, int width, int height, char * application) { - int index = 0; +static v0 vulkan_configure (vulkan_structure * vulkan, s4 width, s4 height, c1 * application) { + s4 index = 0; - uint * dumb_buffer = null; + u4 * dumb_buffer = null; if (vulkan->active == true) { return; @@ -1888,8 +1888,8 @@ static void vulkan_configure (vulkan_structure * vulkan, int width, int height, vulkan->active = true; } /* -static void vulkan_reconfigure (void) { - int index; +static v0 vulkan_reconfigure (v0) { + s4 index; vulkan_result (vkQueueWaitIdle (vulkan_queue)); vulkan_result (vkDeviceWaitIdle (vulkan_logical_device)); @@ -1924,20 +1924,20 @@ static void vulkan_reconfigure (void) { vulkan_reconfigure_active = false; } */ -static void vulkan_render_core (vulkan_structure * vulkan, int sprite, int x, int y, int u, int v, int width, int height, - float scale_x, float scale_y, int flip_x, int flip_y, - int colour_0, uint colour_1, uint colour_2, uint colour_3) { - float screen_x = x * vulkan->pixel_width; - float screen_y = y * vulkan->pixel_height; +static v0 vulkan_render_core (vulkan_structure * vulkan, s4 sprite, s4 x, s4 y, s4 u, s4 v, s4 width, s4 height, + f4 scale_x, f4 scale_y, s4 flip_x, s4 flip_y, + s4 colour_0, u4 colour_1, u4 colour_2, u4 colour_3) { + f4 screen_x = x * vulkan->pixel_width; + f4 screen_y = y * vulkan->pixel_height; - float unwrap_x = vulkan->sprite_u [sprite] + (float) u / vulkan->layout_width; - float unwrap_y = vulkan->sprite_v [sprite] + (float) v / vulkan->layout_height; + f4 unwrap_x = vulkan->sprite_u [sprite] + (float) u / vulkan->layout_width; + f4 unwrap_y = vulkan->sprite_v [sprite] + (float) v / vulkan->layout_height; - float screen_width = (float) width * vulkan->pixel_width * scale_x; - float screen_height = (float) height * vulkan->pixel_height * scale_y; + f4 screen_width = (float) width * vulkan->pixel_width * scale_x; + f4 screen_height = (float) height * vulkan->pixel_height * scale_y; - float unwrap_width = (float) width / vulkan->layout_width; - float unwrap_height = (float) height / vulkan->layout_height; + f4 unwrap_width = (float) width / vulkan->layout_width; + f4 unwrap_height = (float) height / vulkan->layout_height; fatal_failure (vulkan->vertex_count + 32 >= vulkan->vertex_limit, "Reached vertex limit."); fatal_failure (vulkan->index_count + 6 >= vulkan->index_limit, "Reached index limit."); @@ -1989,35 +1989,35 @@ static void vulkan_render_core (vulkan_structure * vulkan, int sprite, int x, in vulkan->index_count += 6; } -static void vulkan_render_sprite (vulkan_structure * vulkan, int sprite, int x, int y, uint colour) { +static v0 vulkan_render_sprite (vulkan_structure * vulkan, s4 sprite, s4 x, s4 y, u4 colour) { vulkan_render_core (vulkan, sprite, x, y, 0, 0, vulkan->sprite_width [sprite], vulkan->sprite_height [sprite], 1.0, 1.0, 0, 0, colour, colour, colour,colour); } -static void vulkan_render_sprite_scale (vulkan_structure * vulkan, int sprite, int x, int y, float scale, uint colour) { +static v0 vulkan_render_sprite_scale (vulkan_structure * vulkan, s4 sprite, s4 x, s4 y, f4 scale, u4 colour) { vulkan_render_core (vulkan, sprite, x, y, 0, 0, vulkan->sprite_width [sprite], vulkan->sprite_height [sprite], scale, scale, 0, 0, colour, colour, colour,colour); } -static void vulkan_render_sprite_crop (vulkan_structure * vulkan, int sprite, int x, int y, int u, int v, int width, int height, uint colour) { +static v0 vulkan_render_sprite_crop (vulkan_structure * vulkan, s4 sprite, s4 x, s4 y, s4 u, s4 v, s4 width, s4 height, u4 colour) { vulkan_render_core (vulkan, sprite, x, y, u, v, width, height, 1.0, 1.0, 0, 0, colour, colour, colour, colour); } -static void vulkan_render_rectangle (vulkan_structure * vulkan, int x, int y, int width, int height, uint colour) { +static v0 vulkan_render_rectangle (vulkan_structure * vulkan, s4 x, s4 y, s4 width, s4 height, u4 colour) { vulkan_render_core (vulkan, vulkan->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16, (float) height / 16, 0, 0, colour, colour, colour, colour); } -static void vulkan_render_rectangle_gradient_v (vulkan_structure * vulkan, int x, int y, int width, int height, uint colour_up, uint colour_down) { +static v0 vulkan_render_rectangle_gradient_v (vulkan_structure * vulkan, s4 x, s4 y, s4 width, s4 height, u4 colour_up, u4 colour_down) { vulkan_render_core (vulkan, vulkan->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16, (float) height / 16, 0, 0, colour_up, colour_up, colour_down, colour_down); } -static void vulkan_render_rectangle_gradient_h (vulkan_structure * vulkan, int x, int y, int width, int height, uint colour_left, uint colour_right) { +static v0 vulkan_render_rectangle_gradient_h (vulkan_structure * vulkan, s4 x, s4 y, s4 width, s4 height, u4 colour_left, u4 colour_right) { vulkan_render_core (vulkan, vulkan->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16, (float) height / 16, 0, 0, colour_left, colour_right, colour_left, colour_right); } -static int vulkan_string_width (vulkan_structure * vulkan, char * string, int font, float scale) { - int length = 0; +static s4 vulkan_string_width (vulkan_structure * vulkan, c1 * string, s4 font, f4 scale) { + s4 length = 0; - for (uint index = 0; string [index] != '\0'; ++index) { - int character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; + for (u4 index = 0; string [index] != '\0'; ++index) { + s4 character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; /* if (string [index] == '\t') { length += 8 * vulkan->sprite_width [vulkan->font_index [font] [' ' - vulkan->font_begin [font]]]; @@ -2034,11 +2034,11 @@ static int vulkan_string_width (vulkan_structure * vulkan, char * string, int fo return (length); } -static void vulkan_render_string (vulkan_structure * vulkan, char * string, int font, int x, int y, uint colour) { - int offset = x; +static v0 vulkan_render_string (vulkan_structure * vulkan, c1 * string, s4 font, s4 x, s4 y, u4 colour) { + s4 offset = x; - for (uint index = 0; string [index] != '\0'; ++index) { - int character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; + for (u4 index = 0; string [index] != '\0'; ++index) { + s4 character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; if (string [index] == '\t') { x += 8 * vulkan->sprite_width [vulkan->font_index [font] [' ' - vulkan->font_begin [font]]]; @@ -2057,11 +2057,11 @@ static void vulkan_render_string (vulkan_structure * vulkan, char * string, int } } -static void vulkan_render_string_scale (vulkan_structure * vulkan, char * string, int font, int x, int y, float scale, uint colour) { - int offset = x; +static v0 vulkan_render_string_scale (vulkan_structure * vulkan, c1 * string, s4 font, s4 x, s4 y, f4 scale, u4 colour) { + s4 offset = x; - for (uint index = 0; string [index] != '\0'; ++index) { - int character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; + for (u4 index = 0; string [index] != '\0'; ++index) { + s4 character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; if (string [index] == '\t') { x += 8 * vulkan->sprite_width [vulkan->font_index [font] [' ' - vulkan->font_begin [font]]]; @@ -2081,9 +2081,9 @@ static void vulkan_render_string_scale (vulkan_structure * vulkan, char * string } } -static void vulkan_render_string_offset (vulkan_structure * vulkan, char * string, uint length, uint font, uint offset, int * x, int * y, uint colour) { - for (uint index = 0; (string [index] != '\0') && (index < length); ++index) { - uint character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; +static v0 vulkan_render_string_offset (vulkan_structure * vulkan, c1 * string, u4 length, u4 font, u4 offset, s4 * x, s4 * y, u4 colour) { + for (u4 index = 0; (string [index] != '\0') && (index < length); ++index) { + u4 character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; if (string [index] == '\t') { * x += 8 * vulkan->sprite_width [vulkan->font_index [font] [' ' - vulkan->font_begin [font]]]; @@ -2102,11 +2102,11 @@ static void vulkan_render_string_offset (vulkan_structure * vulkan, char * strin } } -static void vulkan_render_string_gradient_v (vulkan_structure * vulkan, char * string, int font, int x, int y, float scale, uint colour_up, uint colour_down) { - int offset = x; +static v0 vulkan_render_string_gradient_v (vulkan_structure * vulkan, c1 * string, s4 font, s4 x, s4 y, f4 scale, u4 colour_up, u4 colour_down) { + s4 offset = x; - for (uint index = 0; string [index] != '\0'; ++index) { - uint character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; + for (u4 index = 0; string [index] != '\0'; ++index) { + u4 character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; if (string [index] == '\t') { x += 8 * vulkan->sprite_width [vulkan->font_index [font] [' ' - vulkan->font_begin [font]]] * scale; @@ -2126,11 +2126,11 @@ static void vulkan_render_string_gradient_v (vulkan_structure * vulkan, char * s } } -static void vulkan_render_string_gradient_h (vulkan_structure * vulkan, char * string, int font, int x, int y, float scale, uint colour_left, uint colour_right) { - int offset = x; +static v0 vulkan_render_string_gradient_h (vulkan_structure * vulkan, c1 * string, s4 font, s4 x, s4 y, f4 scale, u4 colour_left, u4 colour_right) { + s4 offset = x; - for (uint index = 0; string [index] != '\0'; ++index) { - uint character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; + for (u4 index = 0; string [index] != '\0'; ++index) { + u4 character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]]; if (string [index] == '\t') { x += 8 * vulkan->sprite_width [vulkan->font_index [font] [' ' - vulkan->font_begin [font]]] * scale; @@ -2150,8 +2150,8 @@ static void vulkan_render_string_gradient_h (vulkan_structure * vulkan, char * s } } -static void vulkan_handle_events (vulkan_structure * vulkan) { - static int signal_code [signal_count] = { +static v0 vulkan_handle_events (vulkan_structure * vulkan) { + static s4 signal_code [signal_count] = { 0, 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14, @@ -2162,7 +2162,7 @@ static void vulkan_handle_events (vulkan_structure * vulkan) { 85, 79, 80, 81 }; - int index, key_code; + s4 index, key_code; xcb_generic_event_t * generic_event; @@ -2227,13 +2227,13 @@ static void vulkan_handle_events (vulkan_structure * vulkan) { generic_event = deallocate (generic_event); } -static void vulkan_synchronize (vulkan_structure * vulkan, uint clear_colour) { - uint index = 0; - uint frame = 0; +static v0 vulkan_synchronize (vulkan_structure * vulkan, u4 clear_colour) { + u4 index = 0; + u4 frame = 0; VkResult result = VK_SUCCESS; - void * ubo_void = null; + v0 * ubo_v0 = null; VkPipelineStageFlags wait_stages [1] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT} ; diff --git a/xungeon.h b/xungeon.h index 745176e..5478c60 100755 --- a/xungeon.h +++ b/xungeon.h @@ -16,64 +16,64 @@ // for more details, if you dare, it is a lot of text that nobody wants to read... //~typedef struct { - //~char * name; + //~c1 * name; //~} * _definition; typedef struct { - char * name; // Name string copy. - uint temperature; // ; - uint humidity; // ; + c1 * name; // Name string copy. + u4 temperature; // ; + u4 humidity; // ; } * dungeon_biome_definition; typedef struct { - char * name; // Name string copy. - uint biome; // Index in biome array. - bool clip; // Can entities move through? + c1 * name; // Name string copy. + u4 biome; // Index in biome array. + b4 clip; // Can entities move through? } * dungeon_landmark_definition; typedef struct { - char * name; // Name string copy. + c1 * name; // Name string copy. } * dungeon_expertise_definition; typedef struct { - char * name; // Name string copy. - uint base; // Default amount of points per entity. - uint limit; // After this point, points won't increase. + c1 * name; // Name string copy. + u4 base; // Default amount of points per entity. + u4 limit; // After this point, points won't increase. } * dungeon_attribute_definition; typedef struct { - char * name; // Name string copy. - uint base; // Default amount of points per entity. - uint limit; // After this point, points won't increase. + c1 * name; // Name string copy. + u4 base; // Default amount of points per entity. + u4 limit; // After this point, points won't increase. } * dungeon_skill_definition; typedef struct { - char * name; // Name string copy. - uint base; // Default amount of points per entity. - uint limit; // After this point, points won't increase. - uint value; // Constant trade value per index 0. - uint trade; // Trade rate for acquiring the resource. + c1 * name; // Name string copy. + u4 base; // Default amount of points per entity. + u4 limit; // After this point, points won't increase. + u4 value; // Constant trade value per index 0. + u4 trade; // Trade rate for acquiring the resource. } * dungeon_resource_definition; typedef struct { - char * name; // Name string copy. + c1 * name; // Name string copy. } * dungeon_item_slot_definition; typedef struct { - char * name; // Name string copy. - uint slot; // Index in item slot array. - uint effect; // Index in effect array. + c1 * name; // Name string copy. + u4 slot; // Index in item slot array. + u4 effect; // Index in effect array. } * dungeon_item_definition; typedef struct { - uint biome_count; - uint landmark_count; - uint expertise_count; - uint attribute_count; - uint skill_count; - uint resource_count; - uint item_slot_count; - uint item_count; + u4 biome_count; + u4 landmark_count; + u4 expertise_count; + u4 attribute_count; + u4 skill_count; + u4 resource_count; + u4 item_slot_count; + u4 item_count; dungeon_biome_definition * biome_array; dungeon_landmark_definition * landmark_array; dungeon_expertise_definition * expertise_array; @@ -84,7 +84,7 @@ typedef struct { dungeon_item_definition * item_array; } * dungeon_structure; -static uint dungeon_biome_define (dungeon_structure dungeon, char * name, uint temperature, uint humidity) { +static u4 dungeon_biome_define (dungeon_structure dungeon, c1 * name, u4 temperature, u4 humidity) { dungeon_biome_definition biome = arena_add (sizeof (* biome)); fatal_failure (dungeon == null, "biome_define: Dungeon is not configured."); @@ -102,11 +102,11 @@ static uint dungeon_biome_define (dungeon_structure dungeon, char * name, uint t return (dungeon->biome_count - 1); } -static char * dungeon_biome_name (dungeon_structure dungeon, uint index) { return (dungeon->biome_array [index]->name); } -static uint dungeon_biome_temperature (dungeon_structure dungeon, uint index) { return (dungeon->biome_array [index]->temperature); } -static uint dungeon_biome_humidity (dungeon_structure dungeon, uint index) { return (dungeon->biome_array [index]->humidity); } +static c1 * dungeon_biome_name (dungeon_structure dungeon, u4 index) { return (dungeon->biome_array [index]->name); } +static u4 dungeon_biome_temperature (dungeon_structure dungeon, u4 index) { return (dungeon->biome_array [index]->temperature); } +static u4 dungeon_biome_humidity (dungeon_structure dungeon, u4 index) { return (dungeon->biome_array [index]->humidity); } -static uint dungeon_landmark_define (dungeon_structure dungeon, char * name, uint biome, bool clip) { +static u4 dungeon_landmark_define (dungeon_structure dungeon, c1 * name, u4 biome, b4 clip) { dungeon_landmark_definition landmark = arena_add (sizeof (* landmark)); fatal_failure (dungeon == null, "landmark_define: Dungeon is not configured."); @@ -124,11 +124,11 @@ static uint dungeon_landmark_define (dungeon_structure dungeon, char * name, uin return (dungeon->landmark_count - 1); } -static char * dungeon_landmark_name (dungeon_structure dungeon, uint index) { return (dungeon->landmark_array [index]->name); } -static uint dungeon_landmark_biome (dungeon_structure dungeon, uint index) { return (dungeon->landmark_array [index]->biome); } -static bool dungeon_landmark_clip (dungeon_structure dungeon, uint index) { return (dungeon->landmark_array [index]->clip); } +static c1 * dungeon_landmark_name (dungeon_structure dungeon, u4 index) { return (dungeon->landmark_array [index]->name); } +static u4 dungeon_landmark_biome (dungeon_structure dungeon, u4 index) { return (dungeon->landmark_array [index]->biome); } +static b4 dungeon_landmark_clip (dungeon_structure dungeon, u4 index) { return (dungeon->landmark_array [index]->clip); } -static uint dungeon_expertise_define (dungeon_structure dungeon, char * name) { +static u4 dungeon_expertise_define (dungeon_structure dungeon, c1 * name) { dungeon_expertise_definition expertise = arena_add (sizeof (* expertise)); fatal_failure (dungeon == null, "expertise_define: Dungeon is not configured."); @@ -143,9 +143,9 @@ static uint dungeon_expertise_define (dungeon_structure dungeon, char * name) { return (dungeon->expertise_count - 1); } -static char * dungeon_expertise_name (dungeon_structure dungeon, uint index) { return (dungeon->expertise_array [index]->name); } +static c1 * dungeon_expertise_name (dungeon_structure dungeon, u4 index) { return (dungeon->expertise_array [index]->name); } -static uint dungeon_attribute_define (dungeon_structure dungeon, char * name, uint base, uint limit) { +static u4 dungeon_attribute_define (dungeon_structure dungeon, c1 * name, u4 base, u4 limit) { dungeon_attribute_definition attribute = arena_add (sizeof (* attribute)); fatal_failure (dungeon == null, "attribute_define: Dungeon is not configured."); @@ -163,11 +163,11 @@ static uint dungeon_attribute_define (dungeon_structure dungeon, char * name, ui return (dungeon->attribute_count - 1); } -static char * dungeon_attribute_name (dungeon_structure dungeon, uint index) { return (dungeon->attribute_array [index]->name); } -static uint dungeon_attribute_base (dungeon_structure dungeon, uint index) { return (dungeon->attribute_array [index]->base); } -static uint dungeon_attribute_limit (dungeon_structure dungeon, uint index) { return (dungeon->attribute_array [index]->limit); } +static c1 * dungeon_attribute_name (dungeon_structure dungeon, u4 index) { return (dungeon->attribute_array [index]->name); } +static u4 dungeon_attribute_base (dungeon_structure dungeon, u4 index) { return (dungeon->attribute_array [index]->base); } +static u4 dungeon_attribute_limit (dungeon_structure dungeon, u4 index) { return (dungeon->attribute_array [index]->limit); } -static uint dungeon_skill_define (dungeon_structure dungeon, char * name, uint base, uint limit) { +static u4 dungeon_skill_define (dungeon_structure dungeon, c1 * name, u4 base, u4 limit) { dungeon_skill_definition skill = arena_add (sizeof (* skill)); fatal_failure (dungeon == null, "skill_define: Dungeon is not configured."); @@ -185,11 +185,11 @@ static uint dungeon_skill_define (dungeon_structure dungeon, char * name, uint b return (dungeon->skill_count - 1); } -static char * dungeon_skill_name (dungeon_structure dungeon, uint index) { return (dungeon->skill_array [index]->name); } -static uint dungeon_skill_base (dungeon_structure dungeon, uint index) { return (dungeon->skill_array [index]->base); } -static uint dungeon_skill_limit (dungeon_structure dungeon, uint index) { return (dungeon->skill_array [index]->limit); } +static c1 * dungeon_skill_name (dungeon_structure dungeon, u4 index) { return (dungeon->skill_array [index]->name); } +static u4 dungeon_skill_base (dungeon_structure dungeon, u4 index) { return (dungeon->skill_array [index]->base); } +static u4 dungeon_skill_limit (dungeon_structure dungeon, u4 index) { return (dungeon->skill_array [index]->limit); } -static uint dungeon_resource_define (dungeon_structure dungeon, char * name, uint base, uint limit, uint value, uint trade) { +static u4 dungeon_resource_define (dungeon_structure dungeon, c1 * name, u4 base, u4 limit, u4 value, u4 trade) { dungeon_resource_definition resource = arena_add (sizeof (* resource)); fatal_failure (dungeon == null, "resource_define: Dungeon is not configured."); @@ -209,13 +209,13 @@ static uint dungeon_resource_define (dungeon_structure dungeon, char * name, uin return (dungeon->resource_count - 1); } -static char * dungeon_resource_name (dungeon_structure dungeon, uint index) { return (dungeon->resource_array [index]->name); } -static uint dungeon_resource_base (dungeon_structure dungeon, uint index) { return (dungeon->resource_array [index]->base); } -static uint dungeon_resource_limit (dungeon_structure dungeon, uint index) { return (dungeon->resource_array [index]->limit); } -static uint dungeon_resource_value (dungeon_structure dungeon, uint index) { return (dungeon->resource_array [index]->value); } -static uint dungeon_resource_trade (dungeon_structure dungeon, uint index) { return (dungeon->resource_array [index]->trade); } +static c1 * dungeon_resource_name (dungeon_structure dungeon, u4 index) { return (dungeon->resource_array [index]->name); } +static u4 dungeon_resource_base (dungeon_structure dungeon, u4 index) { return (dungeon->resource_array [index]->base); } +static u4 dungeon_resource_limit (dungeon_structure dungeon, u4 index) { return (dungeon->resource_array [index]->limit); } +static u4 dungeon_resource_value (dungeon_structure dungeon, u4 index) { return (dungeon->resource_array [index]->value); } +static u4 dungeon_resource_trade (dungeon_structure dungeon, u4 index) { return (dungeon->resource_array [index]->trade); } -static uint dungeon_item_slot_define (dungeon_structure dungeon, char * name) { +static u4 dungeon_item_slot_define (dungeon_structure dungeon, c1 * name) { dungeon_item_slot_definition item_slot = arena_add (sizeof (* item_slot)); fatal_failure (dungeon == null, "item_slot_define: Dungeon is not configured."); @@ -230,9 +230,9 @@ static uint dungeon_item_slot_define (dungeon_structure dungeon, char * name) { return (dungeon->item_slot_count - 1); } -static char * dungeon_item_slot_name (dungeon_structure dungeon, uint index) { return (dungeon->item_slot_array [index]->name); } +static c1 * dungeon_item_slot_name (dungeon_structure dungeon, u4 index) { return (dungeon->item_slot_array [index]->name); } -static uint dungeon_item_define (dungeon_structure dungeon, char * name, uint slot, uint effect) { +static u4 dungeon_item_define (dungeon_structure dungeon, c1 * name, u4 slot, u4 effect) { dungeon_item_definition item = arena_add (sizeof (* item)); fatal_failure (dungeon == null, "item_define: Dungeon is not configured."); @@ -250,12 +250,12 @@ static uint dungeon_item_define (dungeon_structure dungeon, char * name, uint sl return (dungeon->item_count - 1); } -static char * dungeon_item_name (dungeon_structure dungeon, uint index) { return (dungeon->item_array [index]->name); } -static uint dungeon_item_slot (dungeon_structure dungeon, uint index) { return (dungeon->item_array [index]->slot); } -static uint dungeon_item_effect (dungeon_structure dungeon, uint index) { return (dungeon->item_array [index]->effect); } +static c1 * dungeon_item_name (dungeon_structure dungeon, u4 index) { return (dungeon->item_array [index]->name); } +static u4 dungeon_item_slot (dungeon_structure dungeon, u4 index) { return (dungeon->item_array [index]->slot); } +static u4 dungeon_item_effect (dungeon_structure dungeon, u4 index) { return (dungeon->item_array [index]->effect); } -static dungeon_structure dungeon_configure (uint biome_limit, uint landmark_limit, uint expertise_limit, uint attribute_limit, uint skill_limit, - uint resource_limit, uint item_slot_limit, uint item_limit) { +static dungeon_structure dungeon_configure (u4 biome_limit, u4 landmark_limit, u4 expertise_limit, u4 attribute_limit, u4 skill_limit, + u4 resource_limit, u4 item_slot_limit, u4 item_limit) { dungeon_structure dungeon = arena_add (sizeof (* dungeon)); dungeon->biome_array = arena_add (biome_limit * sizeof (* dungeon->biome_array)); diff --git a/xuxuxu.c b/xuxuxu.c index 3e929ec..1423d35 100755 --- a/xuxuxu.c +++ b/xuxuxu.c @@ -10,16 +10,16 @@ #define font_height ( 8) #define font_count (96) -static uint * render = null; -static uint colour = foreground; +static u4 * render = null; +static u4 colour = foreground; -static uint width = 0; -static uint height = 0; -static uint x = 0; -static uint y = 0; +static u4 width = 0; +static u4 height = 0; +static u4 x = 0; +static u4 y = 0; -static void render_character (char character) { - ulong font_code [font_count] = { +static v0 render_character (c1 character) { + u8 font_code [font_count] = { 0x0000000000000000, 0x00180018183c3c18, 0x0000000000363636, 0x006c6cfe6cfe6c6c, 0x00187ed07c16fc30, 0x0060660c18306606, 0x00dc66b61c36361c, 0x0000000000181818, 0x0030180c0c0c1830, 0x000c18303030180c, 0x0000187e3c7e1800, 0x000018187e181800, @@ -46,18 +46,18 @@ static void render_character (char character) { 0x0018181818181818, 0x000c18187018180c, 0x000000000062d68c, 0x0000000000000000 }; - for (uint offset = 0; offset < font_width * font_height; ++offset) { - uint u = offset / font_width + y; - uint v = offset % font_width + x; + for (u4 offset = 0; offset < font_width * font_height; ++offset) { + u4 u = offset / font_width + y; + u4 v = offset % font_width + x; - render [u * width + v] = ((font_code [(uint) (character - ' ')] >> offset) % 2) ? colour : background; + render [u * width + v] = ((font_code [(u4) (character - ' ')] >> offset) % 2) ? colour : background; } x += font_width + 1; } -static void render_string (char * string, uint length) { - for (uint offset = 0; offset < length; ++offset) { +static v0 render_string (c1 * string, u4 length) { + for (u4 offset = 0; offset < length; ++offset) { if (string [offset] == '\t') { x += font_width * font_indent; } else if (string [offset] == '\n') { @@ -69,17 +69,17 @@ static void render_string (char * string, uint length) { } } -int main (void) { - uint index = 0; - uint length = 0; - char * buffer = null; +s4 main (v0) { + u4 index = 0; + u4 length = 0; + c1 * buffer = null; - char separator [] = ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n"; + c1 separator [] = ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n"; - char * keywords [] = { + c1 * keywords [] = { "register", "volatile", "auto", "const", "static", "extern", "if", "else", "do", "while", "for", "continue", "switch", "case", "default", "break", - "enum", "union", "struct", "typedef", "goto", "void", "return", "sizeof", + "enum", "union", "struct", "typedef", "goto", "v0", "return", "sizeof", "char", "short", "int", "long", "signed", "unsigned", "float", "double" }; @@ -93,7 +93,7 @@ int main (void) { syntax_define (syntax, true, false, ".,:;<=>+-*/%!&~^?|", "", '\0', 0xffccaa33, 0); syntax_define (syntax, true, false, "(){}[]", "", '\0', 0xffcc3333, 0); - for (ulong word = 0; word < array_length (keywords); ++word) { + for (u8 word = 0; word < array_length (keywords); ++word) { syntax_define (syntax, false, true, keywords [word], separator, '\0', 0xff33aacc, 0); } @@ -107,11 +107,11 @@ int main (void) { render = allocate (4 * width * height); - for (uint offset = 0; offset < width * height; ++offset) { + for (u4 offset = 0; offset < width * height; ++offset) { render [offset] = background; } - for (uint offset = 0; buffer [offset] != '\0'; offset += length) { + for (u4 offset = 0; buffer [offset] != '\0'; offset += length) { index = syntax_select (syntax, & buffer [offset], & length); colour = syntax->colour [index]; diff --git a/xyntax.h b/xyntax.h index eed650c..36dbe06 100755 --- a/xyntax.h +++ b/xyntax.h @@ -17,18 +17,18 @@ /// for more details, if you dare, it is a lot of text that nobody wants to read... typedef struct { - uint count; - uint limit; - bool * enrange; - bool * derange; - char * * begin; - char * * end; - char * escape; - uint * colour; - uint * effect; + u4 count; + u4 limit; + b4 * enrange; + b4 * derange; + c1 * * begin; + c1 * * end; + c1 * escape; + u4 * colour; + u4 * effect; } syntax_structure; -static syntax_structure * syntax_initialize (uint limit) { +static syntax_structure * syntax_initialize (u4 limit) { syntax_structure * syntax = allocate (sizeof (* syntax)); syntax->limit = limit; @@ -47,7 +47,7 @@ static syntax_structure * syntax_initialize (uint limit) { } static syntax_structure * syntax_deinitialize (syntax_structure * syntax) { - for (uint index = 0; index < syntax->count; ++index) { + for (u4 index = 0; index < syntax->count; ++index) { syntax->begin [index] = deallocate (syntax->begin [index]); syntax->end [index] = deallocate (syntax->end [index]); } @@ -63,11 +63,11 @@ static syntax_structure * syntax_deinitialize (syntax_structure * syntax) { return (deallocate (syntax)); } -static uint syntax_define (syntax_structure * syntax, bool enrange, bool derange, char * begin, char * end, char escape, - uint colour, uint effect) { +static u4 syntax_define (syntax_structure * syntax, b4 enrange, b4 derange, c1 * begin, c1 * end, c1 escape, + u4 colour, u4 effect) { ++syntax->count; - uint current = syntax->count - 1; + u4 current = syntax->count - 1; fatal_failure (begin == null, "syntax_define: Begin string is null pointer."); fatal_failure (end == null, "syntax_define: End string is null pointer."); @@ -99,13 +99,13 @@ static uint syntax_define (syntax_structure * syntax, bool enrange, bool derange return (current); } -static uint syntax_select (syntax_structure * syntax, char * string, uint * length) { - uint offset = 0; - uint subset = 0; - uint select = 0; +static u4 syntax_select (syntax_structure * syntax, c1 * string, u4 * length) { + u4 offset = 0; + u4 subset = 0; + u4 select = 0; - ulong begin_length = 0; - ulong end_length = 0; + u8 begin_length = 0; + u8 end_length = 0; for (; select != syntax->count; ++select) { begin_length = string_length (syntax->begin [select]);