revamped sound engine
authorhgn <hgodden00@gmail.com>
Mon, 20 Dec 2021 20:41:51 +0000 (20:41 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 20 Dec 2021 20:41:51 +0000 (20:41 +0000)
17 files changed:
fishladder.c
fishladder_resources.h
sound/y0.ogg [new file with mode: 0644]
sound/y1.ogg [new file with mode: 0644]
sound/y2.ogg [new file with mode: 0644]
sound/y3.ogg [new file with mode: 0644]
sound/y4.ogg [new file with mode: 0644]
sound/y5.ogg [new file with mode: 0644]
sound/y6.ogg [new file with mode: 0644]
sound/y7.ogg [new file with mode: 0644]
sound/y8.ogg [new file with mode: 0644]
textures/buttons.png
textures/ubuntu.png
vg/vg_audio.h
vg/vg_console.h
vg/vg_debug.h
vg/vg_ui.h

index 7520c2c86a0ae261868484d14e84642ed3ea44fc..becb812d88b5bb9b48a800ad8846962b2f7509f6 100644 (file)
@@ -702,6 +702,20 @@ static int map_load( const char *str, const char *name )
                                px[3] = 0;
                        }
                }
+               
+               // Level selection area
+               
+               for( int y = 16+2; y < 16+world.h-2; y ++ )
+               {
+                       for( int x = 14; x < 16; x ++ )
+                       {
+                               u8 *px = &info_buffer[((y*64)+x)*4];
+                               px[0] = 0x10;
+                       }
+               }
+               
+               info_buffer[(((16+world.h-3)*64)+world.w+16-1)*4] = 0x30;
+               info_buffer[(((16+world.h-2)*64)+world.w+16-1)*4] = 0x30;
 
                // Random walks.. kinda
                for( int i = 0; i < arrlen(world.io); i ++ )
@@ -1343,6 +1357,9 @@ void vg_update(void)
                
                world.sim_target = (int)floorf(world.sim_internal_time);
                
+               int success_this_frame = 0;
+               int failure_this_frame = 0;
+               
                while( world.sim_frame < world.sim_target )
                {
                        sfx_set_playrnd( &audio_random, &audio_system_balls_switching, 0, 8 );
@@ -1390,7 +1407,16 @@ void vg_update(void)
                                                        {
                                                                struct terminal_run *run = &term->runs[ world.sim_run ];
                                                                if( run->recv_count < vg_list_size( run->recieved ) )
+                                                               {
+                                                                       if( fish->payload == run->conditions[ run->recv_count ] )
+                                                                               success_this_frame = 1;
+                                                                       else
+                                                                               failure_this_frame = 1;
+                                                               
                                                                        run->recieved[ run->recv_count ++ ] = fish->payload;
+                                                               }
+                                                               else
+                                                                       failure_this_frame = 1;
                                                                
                                                                break;
                                                        }
@@ -1736,6 +1762,21 @@ void vg_update(void)
                        world.sim_frame ++;
                }
                
+               // Sounds
+               if( failure_this_frame )
+               {
+                       sfx_set_play( &audio_tones, &audio_system_balls_extra, 0 );
+               }
+               else if( success_this_frame )
+               {
+                       static int succes_counter = 0;
+                       
+                       sfx_set_play( &audio_tones, &audio_system_balls_extra, 1+(succes_counter++) );
+                       
+                       if( succes_counter == 7 )
+                               succes_counter = 0;
+               }
+               
                // Position update
                // =====================================================================================================
                
@@ -1906,6 +1947,7 @@ static void wbutton_run( enum e_world_button btn_name )
        struct cell_button *btn = &world.buttons[btn_name];
        
        // Interaction
+       int tex_offset = 0;
        
        int is_hovering = (world.tile_x == world.w-1 && world.tile_y == world.h-btn_name-2)?1:0;        
        if( vg_get_button_up( "primary" ) && is_hovering )
@@ -1984,6 +2026,13 @@ static void wbutton_run( enum e_world_button btn_name )
        btn->light = vg_lerpf( btn->light, btn->light_target, vg_time_delta*26.0f );
        
        // Draw
+       if( btn_name == k_world_button_sim && world.buttons[ k_world_button_sim ].pressed )
+       {
+               if( world.buttons[ k_world_button_pause ].pressed )
+                       tex_offset = 3;
+               else
+                       tex_offset = 2;
+       }
        
        v4f final_colour;
        v3_copy( button_colours[ btn_name ], final_colour );
@@ -1992,7 +2041,7 @@ static void wbutton_run( enum e_world_button btn_name )
        glUniform4f( SHADER_UNIFORM( shader_buttons, "uOffset" ), 
                world.w-1, 
                world.h-btn_name-2, 
-               (float)btn_name
+               (float)(btn_name+tex_offset)
                3.0f 
        );
        glUniform4fv( SHADER_UNIFORM( shader_buttons, "uColour" ), 1, final_colour );
@@ -2517,6 +2566,7 @@ ui_data;
 
 void vg_ui(void)
 {
+       /*
        // UI memory
        static int pack_selection = 0;
        static struct pack_info
@@ -2558,7 +2608,7 @@ void vg_ui(void)
                gui_capture_mouse( 9999 );
                gui_fill_rect( ui_global_ctx.cursor, 0xff5a4e4d );
                
-               gui_text( "ASSIGNMENTS", 8, 0 );
+               gui_text( "ASSIGNMENTS", 32, 0 );
                
                ui_global_ctx.cursor[1] += 30;
                ui_global_ctx.cursor[3] = 25;
@@ -2579,7 +2629,7 @@ void vg_ui(void)
                                        pack_selection = i;
                                
                                ui_global_ctx.cursor[1] += 2;
-                               gui_text( pack_is_unlocked? pack_infos[i].name: "???", 4, 0 );
+                               gui_text( pack_is_unlocked? pack_infos[i].name: "???", 24, 0 );
                                gui_end_right();
                                
                                gui_reset_colours();
@@ -2651,18 +2701,18 @@ void vg_ui(void)
                                                }
                                                
                                                ui_global_ctx.override_colour = 0xffffffff;
-                                               gui_text( lvl_info->title, 6, 0 );
+                                               gui_text( lvl_info->title, 24, 0 );
                                                ui_global_ctx.cursor[1] += 18;
-                                               gui_text( lvl_info->completed_score>0? "passed": "incomplete", 4, 0 );
+                                               gui_text( lvl_info->completed_score>0? "passed": "incomplete", 24, 0 );
                                        }
                                        else
                                        {
                                                gui_button( 2 + i );
                                                
                                                ui_global_ctx.override_colour = 0xff786f6f;
-                                               gui_text( "???", 6, 0 );
+                                               gui_text( "???", 24, 0 );
                                                ui_global_ctx.cursor[1] += 18;
-                                               gui_text( "locked", 4, 0 );
+                                               gui_text( "locked", 24, 0 );
                                        }
                                        
                                        gui_end_down();
@@ -2692,7 +2742,7 @@ void vg_ui(void)
                        
                        gui_fill_rect( ui_global_ctx.cursor, 0xff5a4e4d );
                        ui_global_ctx.cursor[1] += 4;
-                       gui_text( ui_data.level_selected->title, 6, 0 );
+                       gui_text( ui_data.level_selected->title, 24, 0 );
                        
                        ui_global_ctx.cursor[1] += 30;
                        ui_rect_pad( ui_global_ctx.cursor, 8 );
@@ -2704,11 +2754,11 @@ void vg_ui(void)
                        }
                        gui_end_down();
                        
-                       ui_text_use_paragraph( &ui_global_ctx );
+                       //ui_text_use_paragraph( &ui_global_ctx );
                        ui_global_ctx.cursor[1] += 2;
                        
-                       gui_text( ui_data.level_selected->description, 5, 0 );
-                       ui_text_use_title( &ui_global_ctx );
+                       gui_text( ui_data.level_selected->description, 16, 0 );
+                       //ui_text_use_title( &ui_global_ctx );
                        
                        // Buttons at the bottom
                        ui_global_ctx.cursor[3] = 25;
@@ -2721,7 +2771,7 @@ void vg_ui(void)
                        {
                                ui_data.level_selected = NULL;
                        }
-                       gui_text( "BACK", 6, k_text_alignment_center );
+                       gui_text( "BACK", 24, k_text_alignment_center );
                        gui_end();
                        
                        gui_align_right();
@@ -2735,7 +2785,7 @@ void vg_ui(void)
                                
                                ui_global_ctx.override_colour = 0xff888888;
                                
-                               gui_text( "RESTORE SOLUTION", 6, k_text_alignment_center );
+                               gui_text( "RESTORE SOLUTION", 24, k_text_alignment_center );
                                gui_end_right();
                                ui_global_ctx.override_colour = 0xffffffff;
                        }
@@ -2755,7 +2805,7 @@ void vg_ui(void)
                                                ui_data.leaderboard_show = 0;
                                        }
                                }
-                               gui_text( "PLAY", 6, k_text_alignment_center );
+                               gui_text( "PLAY", 24, k_text_alignment_center );
                                gui_end();
                        }
                        
@@ -2773,7 +2823,7 @@ void vg_ui(void)
                        gui_new_node();
                        {
                                gui_fill_rect( ui_global_ctx.cursor, 0xff5a4e4d );
-                               gui_text( "FRIEND LEADERBOARD", 6, 0 );
+                               gui_text( "FRIEND LEADERBOARD", 24, 0 );
                        }
                        gui_end_down();
                        
@@ -2794,7 +2844,7 @@ void vg_ui(void)
                                                
                                                // 1,2,3 ...
                                                static const char *places[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
-                                               gui_text( places[i], 7, 0 );
+                                               gui_text( places[i], 24, 0 );
                                                ui_global_ctx.cursor[0] += 32;
                                                
                                                struct leaderboard_player *player = &ui_data.leaderboard_players[i];
@@ -2810,12 +2860,12 @@ void vg_ui(void)
                                                gui_end_right();
                                                
                                                // Players name
-                                               gui_text( player->player_name, 7, 0 );
+                                               gui_text( player->player_name, 24, 0 );
                                                
                                                ui_global_ctx.cursor[2] = 50;
                                                gui_align_right();
                                                
-                                               gui_text( player->score_text, 7, k_text_alignment_right );
+                                               gui_text( player->score_text, 24, k_text_alignment_right );
                                        }
                                        gui_end_down();
                                        
@@ -2825,6 +2875,7 @@ void vg_ui(void)
                        gui_end();
                }
        }
+       */
 }
 
 void leaderboard_dispatch_score(void)
index 9b787d536ef5e9590fb876c3335e8e5f6c04d72d..24ba9933069c814e8761115cca6ad23f475ee619 100644 (file)
 // FONTS
+/*
 vg_tex2d tex_ubuntu            =  { .path = "textures/ubuntu.qoi" };
 
-static Character characters_Ubuntu[] = {
-  {983, 90, 18, 18, 9, 9, 7},
-  {55, 90, 23, 40, 7, 31, 9},
-  {794, 90, 27, 26, 7, 33, 13},
-  {356, 49, 36, 40, 7, 31, 21},
-  {307, 0, 32, 46, 7, 34, 18},
-  {564, 0, 42, 41, 7, 31, 27},
-  {646, 0, 38, 41, 8, 31, 21},
-  {821, 90, 21, 26, 7, 33, 7},
-  {118, 0, 26, 49, 6, 34, 10},
-  {144, 0, 26, 49, 9, 34, 10},
-  {674, 90, 31, 31, 8, 31, 15},
-  {511, 90, 33, 34, 7, 26, 18},
-  {771, 90, 23, 27, 8, 12, 8},
-  {957, 90, 26, 21, 8, 20, 9},
-  {900, 90, 23, 22, 7, 13, 8},
-  {0, 0, 32, 49, 10, 34, 12},
-  {791, 0, 33, 41, 7, 32, 18},
-  {28, 90, 27, 40, 6, 31, 18},
-  {956, 0, 32, 41, 7, 32, 18},
-  {988, 0, 32, 41, 7, 32, 18},
-  {604, 49, 34, 40, 8, 31, 18},
-  {0, 49, 32, 41, 7, 31, 18},
-  {872, 49, 32, 40, 7, 31, 18},
-  {740, 49, 33, 40, 7, 31, 18},
-  {824, 0, 33, 41, 7, 31, 18},
-  {773, 49, 33, 40, 7, 31, 18},
-  {446, 90, 23, 35, 7, 25, 8},
-  {78, 90, 23, 40, 8, 26, 8},
-  {608, 90, 33, 33, 7, 26, 18},
-  {738, 90, 33, 27, 7, 23, 18},
-  {641, 90, 33, 33, 7, 26, 18},
-  {64, 49, 30, 41, 8, 31, 13},
-  {339, 0, 44, 45, 7, 31, 30},
-  {204, 49, 39, 40, 9, 31, 21},
-  {638, 49, 34, 40, 6, 31, 20},
-  {684, 0, 36, 41, 7, 31, 20},
-  {392, 49, 36, 40, 6, 31, 23},
-  {806, 49, 33, 40, 6, 31, 18},
-  {904, 49, 32, 40, 6, 31, 17},
-  {720, 0, 36, 41, 7, 31, 21},
-  {464, 49, 35, 40, 6, 31, 22},
-  {101, 90, 21, 40, 6, 31, 8},
-  {968, 49, 31, 40, 9, 31, 16},
-  {499, 49, 35, 40, 6, 31, 20},
-  {936, 49, 32, 40, 6, 31, 16},
-  {162, 49, 42, 40, 7, 31, 28},
-  {428, 49, 36, 40, 6, 31, 23},
-  {606, 0, 40, 41, 7, 31, 25},
-  {672, 49, 34, 40, 6, 31, 19},
-  {267, 0, 40, 46, 7, 31, 25},
-  {756, 0, 35, 41, 6, 31, 20},
-  {857, 0, 33, 41, 8, 32, 17},
-  {534, 49, 35, 40, 8, 31, 18},
-  {569, 49, 35, 40, 6, 31, 22},
-  {243, 49, 39, 40, 9, 31, 21},
-  {116, 49, 46, 40, 8, 31, 29},
-  {282, 49, 37, 40, 8, 31, 20},
-  {319, 49, 37, 40, 9, 31, 19},
-  {706, 49, 34, 40, 8, 31, 18},
-  {170, 0, 25, 49, 6, 34, 10},
-  {32, 0, 32, 49, 10, 34, 12},
-  {195, 0, 25, 49, 9, 34, 10},
-  {705, 90, 33, 30, 7, 31, 18},
-  {923, 90, 34, 21, 9, 6, 15},
-  {842, 90, 24, 24, 7, 34, 12},
-  {295, 90, 31, 35, 8, 26, 16},
-  {383, 0, 33, 43, 6, 34, 19},
-  {326, 90, 31, 35, 7, 26, 15},
-  {416, 0, 33, 43, 7, 34, 19},
-  {197, 90, 33, 35, 7, 26, 18},
-  {512, 0, 28, 43, 6, 34, 12},
-  {32, 49, 32, 41, 7, 26, 18},
-  {481, 0, 31, 43, 6, 34, 18},
-  {94, 49, 22, 41, 7, 32, 8},
-  {241, 0, 26, 47, 11, 32, 8},
-  {449, 0, 32, 43, 6, 34, 16},
-  {540, 0, 24, 43, 7, 34, 8},
-  {122, 90, 41, 35, 6, 26, 27},
-  {357, 90, 31, 35, 6, 26, 18},
-  {163, 90, 34, 35, 7, 26, 19},
-  {890, 0, 33, 41, 6, 26, 19},
-  {923, 0, 33, 41, 7, 26, 19},
-  {418, 90, 28, 35, 6, 26, 12},
-  {388, 90, 30, 35, 8, 26, 14},
-  {0, 90, 28, 40, 7, 31, 13},
-  {263, 90, 32, 35, 7, 25, 18},
-  {544, 90, 33, 34, 8, 25, 16},
-  {469, 90, 42, 34, 8, 25, 25},
-  {230, 90, 33, 35, 8, 26, 16},
-  {839, 49, 33, 40, 9, 25, 16},
-  {577, 90, 31, 34, 8, 25, 15},
-  {64, 0, 27, 49, 8, 34, 10},
-  {220, 0, 21, 49, 6, 34, 9},
-  {91, 0, 27, 49, 9, 34, 10},
-  {866, 90, 34, 23, 8, 21, 18},
+static struct ui_sdf_char characters_Ubuntu[] = {
+  {62911, 23039, 64063, 27647, 9, 9, 18, 18, 7},
+  {3519, 23039, 4991, 33279, 7, 31, 23, 40, 9},
+  {50815, 23039, 52543, 29695, 7, 33, 27, 26, 13},
+  {22783, 12543, 25087, 22783, 7, 31, 36, 40, 21},
+  {19647, 0, 21695, 11775, 7, 34, 32, 46, 18},
+  {36095, 0, 38783, 10495, 7, 31, 42, 41, 27},
+  {41343, 0, 43775, 10495, 8, 31, 38, 41, 21},
+  {52543, 23039, 53887, 29695, 7, 33, 21, 26, 7},
+  {7551, 0, 9215, 12543, 6, 34, 26, 49, 10},
+  {9215, 0, 10879, 12543, 9, 34, 26, 49, 10},
+  {43135, 23039, 45119, 30975, 8, 31, 31, 31, 15},
+  {32703, 23039, 34815, 31743, 7, 26, 33, 34, 18},
+  {49343, 23039, 50815, 29951, 8, 12, 23, 27, 8},
+  {61247, 23039, 62911, 28415, 8, 20, 26, 21, 9},
+  {57599, 23039, 59071, 28671, 7, 13, 23, 22, 8},
+  {0, 0, 2047, 12543, 10, 34, 32, 49, 12},
+  {50623, 0, 52735, 10495, 7, 32, 33, 41, 18},
+  {1791, 23039, 3519, 33279, 6, 31, 27, 40, 18},
+  {61183, 0, 63231, 10495, 7, 32, 32, 41, 18},
+  {63231, 0, 65279, 10495, 7, 32, 32, 41, 18},
+  {38655, 12543, 40831, 22783, 8, 31, 34, 40, 18},
+  {0, 12543, 2047, 23039, 7, 31, 32, 41, 18},
+  {55807, 12543, 57855, 22783, 7, 31, 32, 40, 18},
+  {47359, 12543, 49471, 22783, 7, 31, 33, 40, 18},
+  {52735, 0, 54847, 10495, 7, 31, 33, 41, 18},
+  {49471, 12543, 51583, 22783, 7, 31, 33, 40, 18},
+  {28543, 23039, 30015, 31999, 7, 25, 23, 35, 8},
+  {4991, 23039, 6463, 33279, 8, 26, 23, 40, 8},
+  {38911, 23039, 41023, 31487, 7, 26, 33, 33, 18},
+  {47231, 23039, 49343, 29951, 7, 23, 33, 27, 18},
+  {41023, 23039, 43135, 31487, 7, 26, 33, 33, 18},
+  {4095, 12543, 6015, 23039, 8, 31, 30, 41, 13},
+  {21695, 0, 24511, 11519, 7, 31, 44, 45, 30},
+  {13055, 12543, 15551, 22783, 9, 31, 39, 40, 21},
+  {40831, 12543, 43007, 22783, 6, 31, 34, 40, 20},
+  {43775, 0, 46079, 10495, 7, 31, 36, 41, 20},
+  {25087, 12543, 27391, 22783, 6, 31, 36, 40, 23},
+  {51583, 12543, 53695, 22783, 6, 31, 33, 40, 18},
+  {57855, 12543, 59903, 22783, 6, 31, 32, 40, 17},
+  {46079, 0, 48383, 10495, 7, 31, 36, 41, 21},
+  {29695, 12543, 31935, 22783, 6, 31, 35, 40, 22},
+  {6463, 23039, 7807, 33279, 6, 31, 21, 40, 8},
+  {61951, 12543, 63935, 22783, 9, 31, 31, 40, 16},
+  {31935, 12543, 34175, 22783, 6, 31, 35, 40, 20},
+  {59903, 12543, 61951, 22783, 6, 31, 32, 40, 16},
+  {10367, 12543, 13055, 22783, 7, 31, 42, 40, 28},
+  {27391, 12543, 29695, 22783, 6, 31, 36, 40, 23},
+  {38783, 0, 41343, 10495, 7, 31, 40, 41, 25},
+  {43007, 12543, 45183, 22783, 6, 31, 34, 40, 19},
+  {17087, 0, 19647, 11775, 7, 31, 40, 46, 25},
+  {48383, 0, 50623, 10495, 6, 31, 35, 41, 20},
+  {54847, 0, 56959, 10495, 8, 32, 33, 41, 17},
+  {34175, 12543, 36415, 22783, 8, 31, 35, 40, 18},
+  {36415, 12543, 38655, 22783, 6, 31, 35, 40, 22},
+  {15551, 12543, 18047, 22783, 9, 31, 39, 40, 21},
+  {7423, 12543, 10367, 22783, 8, 31, 46, 40, 29},
+  {18047, 12543, 20415, 22783, 8, 31, 37, 40, 20},
+  {20415, 12543, 22783, 22783, 9, 31, 37, 40, 19},
+  {45183, 12543, 47359, 22783, 8, 31, 34, 40, 18},
+  {10879, 0, 12479, 12543, 6, 34, 25, 49, 10},
+  {2047, 0, 4095, 12543, 10, 34, 32, 49, 12},
+  {12479, 0, 14079, 12543, 9, 34, 25, 49, 10},
+  {45119, 23039, 47231, 30719, 7, 31, 33, 30, 18},
+  {59071, 23039, 61247, 28415, 9, 6, 34, 21, 15},
+  {53887, 23039, 55423, 29183, 7, 34, 24, 24, 12},
+  {18879, 23039, 20863, 31999, 8, 26, 31, 35, 16},
+  {24511, 0, 26623, 11007, 6, 34, 33, 43, 19},
+  {20863, 23039, 22847, 31999, 7, 26, 31, 35, 15},
+  {26623, 0, 28735, 11007, 7, 34, 33, 43, 19},
+  {12607, 23039, 14719, 31999, 7, 26, 33, 35, 18},
+  {32767, 0, 34559, 11007, 6, 34, 28, 43, 12},
+  {2047, 12543, 4095, 23039, 7, 26, 32, 41, 18},
+  {30783, 0, 32767, 11007, 6, 34, 31, 43, 18},
+  {6015, 12543, 7423, 23039, 7, 32, 22, 41, 8},
+  {15423, 0, 17087, 12031, 11, 32, 26, 47, 8},
+  {28735, 0, 30783, 11007, 6, 34, 32, 43, 16},
+  {34559, 0, 36095, 11007, 7, 34, 24, 43, 8},
+  {7807, 23039, 10431, 31999, 6, 26, 41, 35, 27},
+  {22847, 23039, 24831, 31999, 6, 26, 31, 35, 18},
+  {10431, 23039, 12607, 31999, 7, 26, 34, 35, 19},
+  {56959, 0, 59071, 10495, 6, 26, 33, 41, 19},
+  {59071, 0, 61183, 10495, 7, 26, 33, 41, 19},
+  {26751, 23039, 28543, 31999, 6, 26, 28, 35, 12},
+  {24831, 23039, 26751, 31999, 8, 26, 30, 35, 14},
+  {0, 23039, 1791, 33279, 7, 31, 28, 40, 13},
+  {16831, 23039, 18879, 31999, 7, 25, 32, 35, 18},
+  {34815, 23039, 36927, 31743, 8, 25, 33, 34, 16},
+  {30015, 23039, 32703, 31743, 8, 25, 42, 34, 25},
+  {14719, 23039, 16831, 31999, 8, 26, 33, 35, 16},
+  {53695, 12543, 55807, 22783, 9, 25, 33, 40, 16},
+  {36927, 23039, 38911, 31743, 8, 25, 31, 34, 15},
+  {4095, 0, 5823, 12543, 8, 34, 27, 49, 10},
+  {14079, 0, 15423, 12543, 6, 34, 21, 49, 9},
+  {5823, 0, 7551, 12543, 9, 34, 27, 49, 10},
+  {55423, 23039, 57599, 28927, 8, 21, 34, 23, 18},
 };
 
-static Font font_Ubuntu = { "Ubuntu", 32, 0, 0, 1024, 256, 95, characters_Ubuntu };
+static struct ui_sdf_font font_Ubuntu = { "Ubuntu", 32, 1024, 256, characters_Ubuntu, &tex_ubuntu };
+*/
 
 // TEXTURES
 // ===========================================================================================================
@@ -107,13 +109,12 @@ static Font font_Ubuntu = { "Ubuntu", 32, 0, 0, 1024, 256, 95, characters_Ubuntu
 vg_tex2d tex_tile_data =       { .path = "textures/tileset.qoi" };
 vg_tex2d tex_tile_detail = { .path = "textures/tile_overlays.qoi" };
 vg_tex2d tex_wood =                    { .path = "textures/wood.qoi" };
-vg_tex2d tex_background =      { .path = "textures/background.qoi" };
 vg_tex2d tex_ball_noise =  { .path = "textures/bnoise.qoi" };
 vg_tex2d tex_monofur   =  { .path = "textures/ascii.qoi", .flags = VG_TEXTURE_NO_MIP };
 vg_tex2d tex_unkown            =  { .path = "textures/unkown.qoi" };
 vg_tex2d tex_buttons           =  { .path = "textures/buttons.qoi" };
 
-vg_tex2d *texture_list[] = { &tex_tile_detail, &tex_tile_data, &tex_wood, &tex_background, &tex_ball_noise, &tex_monofur, &tex_unkown, &tex_buttons, &tex_ubuntu };
+vg_tex2d *texture_list[] = { &tex_tile_detail, &tex_tile_data, &tex_wood, &tex_ball_noise, &tex_monofur, &tex_unkown, &tex_buttons };
 
 // AUDIO
 // ===========================================================================================================
@@ -175,17 +176,31 @@ sound/click_b.ogg\0\
 sound/click_c.ogg\0"
 };
 
+sfx_set audio_tones = 
+{
+       .sources = "\
+sound/y0.ogg\0\
+sound/y1.ogg\0\
+sound/y2.ogg\0\
+sound/y3.ogg\0\
+sound/y4.ogg\0\
+sound/y5.ogg\0\
+sound/y6.ogg\0\
+sound/y7.ogg\0\
+sound/y8.ogg\0"
+};
+
 // One two or three layers of rolling noise
 sfx_system audio_system_balls_rolling =
 {
-       .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx, 
-       .name = "Balls Rolling", .flags = SFX_FLAG_REPEAT
+       .vol = 0.7f, .ch = 1, .vol_src = &audio_volume_sfx, 
+       .name = "Balls Rolling", .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT
 };
 
 // Various oneshots
 sfx_system audio_system_balls_switching =
 {
-       .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx, 
+       .vol = 0.2f, .ch = 1, .vol_src = &audio_volume_sfx, 
        .name = "Balls Switching"
 };
 
@@ -199,7 +214,7 @@ sfx_system audio_system_balls_important =
 // Suplemental sounds
 sfx_system audio_system_balls_extra = 
 {
-       .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx, 
+       .vol = 0.27f, .ch = 1, .vol_src = &audio_volume_sfx, 
        .name = "Balls Extra"
 };
 
@@ -223,11 +238,8 @@ ui_colourset ui_fl_colours_inactive = {
 
 static void resource_load_main(void)
 {
-       // Textures
+       // Textures // UI
        vg_tex2d_init( texture_list, vg_list_size( texture_list ) );
-       
-       ui_override_font( tex_monofur.name, 7 );
-
        ui_global_ctx.colours_main = &ui_fl_colours;
        gui_reset_colours();
        
@@ -237,6 +249,7 @@ static void resource_load_main(void)
        sfx_set_init( &audio_rolls, NULL );
        sfx_set_init( &audio_random, NULL );
        sfx_set_init( &audio_clicks, NULL );
+       sfx_set_init( &audio_tones, NULL );
 }
 
 static void resource_free_main(void)
@@ -248,6 +261,7 @@ static void resource_free_main(void)
        sfx_set_free( &audio_rolls );
        sfx_set_free( &audio_random );
        sfx_set_free( &audio_clicks );
+       sfx_set_free( &audio_tones );
 }
 
 // SHADERS
diff --git a/sound/y0.ogg b/sound/y0.ogg
new file mode 100644 (file)
index 0000000..f4735af
Binary files /dev/null and b/sound/y0.ogg differ
diff --git a/sound/y1.ogg b/sound/y1.ogg
new file mode 100644 (file)
index 0000000..bed449b
Binary files /dev/null and b/sound/y1.ogg differ
diff --git a/sound/y2.ogg b/sound/y2.ogg
new file mode 100644 (file)
index 0000000..2994944
Binary files /dev/null and b/sound/y2.ogg differ
diff --git a/sound/y3.ogg b/sound/y3.ogg
new file mode 100644 (file)
index 0000000..740ca0a
Binary files /dev/null and b/sound/y3.ogg differ
diff --git a/sound/y4.ogg b/sound/y4.ogg
new file mode 100644 (file)
index 0000000..0156c5a
Binary files /dev/null and b/sound/y4.ogg differ
diff --git a/sound/y5.ogg b/sound/y5.ogg
new file mode 100644 (file)
index 0000000..8af3fc6
Binary files /dev/null and b/sound/y5.ogg differ
diff --git a/sound/y6.ogg b/sound/y6.ogg
new file mode 100644 (file)
index 0000000..f51a778
Binary files /dev/null and b/sound/y6.ogg differ
diff --git a/sound/y7.ogg b/sound/y7.ogg
new file mode 100644 (file)
index 0000000..f7f1cb8
Binary files /dev/null and b/sound/y7.ogg differ
diff --git a/sound/y8.ogg b/sound/y8.ogg
new file mode 100644 (file)
index 0000000..935503e
Binary files /dev/null and b/sound/y8.ogg differ
index 52e900131690dedd33c1456c0434f597d481b8da..6ef752da2657b68f1349ae6e20ae2152f0020920 100644 (file)
Binary files a/textures/buttons.png and b/textures/buttons.png differ
index 33972e1f2e3a788637148d771b9364bf7941b575..55383a66a679d80c39bda2793c70b599aa92e1cd 100644 (file)
Binary files a/textures/ubuntu.png and b/textures/ubuntu.png differ
index aefc0fc81cd0693688a125304877a15ae354be39..35d775621b1bdddd27edb6b948c9425a84834477 100644 (file)
@@ -7,10 +7,10 @@
 #include "stb/stb_vorbis.h"
 
 #define SFX_MAX_SYSTEMS        32
-#define SFX_FLAG_ONESHOT       0x1
+//#define SFX_FLAG_ONESHOT     0x1
 #define SFX_FLAG_STEREO                0x2
 #define SFX_FLAG_REPEAT        0x4
-#define SFX_FLAG_GHOST         0x8
+#define SFX_FLAG_PERSISTENT 0x8
 #define FADEOUT_LENGTH                 4410
 #define FADEOUT_DIVISOR        (1.f/(float)FADEOUT_LENGTH)
 
@@ -25,6 +25,8 @@ struct sfx_vol_control
 
 struct sfx_system
 {
+       sfx_system *persisitent_source;
+
        // Source buffer start
        float *source, *replacement;
        
@@ -32,7 +34,7 @@ struct sfx_system
        
        // Modifiers
        sfx_vol_control *vol_src;
-       float   vol;
+       float   vol, cvol;
        
        // Info
        u32 ch, end, cur;
@@ -41,10 +43,7 @@ struct sfx_system
        // Effects
        u32 fadeout, fadeout_current;
        
-       sfx_system *thread_clone; // Memory of this structure is copied into thread 2
-       
        // Diagnostic
-       float   signal_average; // Current signal volume
        const char *name;
 };
 
@@ -55,7 +54,7 @@ struct sfx_set
        float *main;
        char *sources;
        
-       u32 segments[16];       //from->to,from->to ...
+       u32 segments[20];       //from->to,from->to ...
        u32 numsegments;
        u32 ch;
        u32 flags;
@@ -239,8 +238,13 @@ static int sfx_begin_edit( sfx_system *sys )
        return 1;
 }
 
+static void sfx_end_edit( sfx_system *sys )
+{
+       MUTEX_UNLOCK( sfx_mux_t01 );
+}
+
 // Mark change to be uploaded to queue system
-static int sfx_save( sfx_system *sys )
+static int sfx_push( sfx_system *sys )
 {
        // Mark change in queue
        sfx_q[ sfx_q_len ++ ] = sys;
@@ -375,91 +379,60 @@ void audio_mixer_callback( ma_device *pDevice, void *pOutBuf, const void *pInput
                sfx_system *src = sfx_q[sfx_q_len];
                sfx_system *clone;
                
-               // This is a 'new' sound if thread_clone not set.
-               if( !src->thread_clone || (src->flags & SFX_FLAG_ONESHOT) )
-               {
-                       clone = sfx_alloc();
-                       if( !clone )
-                               break;
-                               
-                       src->thread_clone = clone;
-               }
-               else
-               {
-                       clone = src->thread_clone;
-               
-                       // Modifying an active system's cursor spawns a small fadeout ghost system
-                       if( clone->cur != src->cur )
-                       {
-                               sfx_system *ghost_system = sfx_alloc();
-                               
-                               if( !ghost_system )
-                                       break;
-                               
-                               ghost_system->source = clone->source;
-                               ghost_system->ch = clone->ch;
-                               ghost_system->end = clone->end;
-                               ghost_system->cur = clone->cur;
-                               ghost_system->flags = SFX_FLAG_GHOST;
-                               ghost_system->fadeout = FADEOUT_LENGTH;
-                               ghost_system->fadeout_current = FADEOUT_LENGTH;
-                               ghost_system->vol_src = clone->vol_src;
-                               ghost_system->name = clone->name;
-                               ghost_system->thread_clone = src;
-                       }
-               }               
+               // Copy
+               clone = sfx_alloc();
+               *clone = *src;
                
-               // run replacement routine if one is waiting (todo: what is this?)
-               if( src->replacement )
-               {
-                       free( src->source );
-                       
-                       src->source = src->replacement;
-                       src->replacement = NULL;
-               }
-               
-               // Localize data to thread 1's memory pool
-               clone->source = src->source;
-               clone->ch = src->ch;
-               clone->end = src->end;
-               clone->cur = src->cur;
-               clone->flags = src->flags;
-               clone->vol_src = src->vol_src;
-               clone->name = src->name;
-               clone->fadeout = src->fadeout;
-               clone->fadeout_current = src->fadeout_current;
-
-               // loopback pointer, mainly used for persistent sound handles
-               clone->thread_clone = src;
+               // Links need to exist on persistent sounds
+               clone->persisitent_source = src->flags & SFX_FLAG_PERSISTENT? src: NULL;
        }
        
        sfx_q_len = 0;
        
-       // Pull in volume sliders
+       // Volume modifiers
        for( int i = 0; i < sfx_sys_len; i ++ )
        {
                sfx_system *sys = sfx_sys + i;
-               sys->vol = sys->thread_clone->vol * g_master_volume;
                
+               // Apply persistent volume if linked
+               if( sys->flags & SFX_FLAG_PERSISTENT )
+               {
+                       sys->vol = sys->persisitent_source->vol * g_master_volume;
+                       
+                       // Persistent triggers
+                       // -------------------
+                       
+                       // Fadeout effect ( + remove )
+                       if( sys->persisitent_source->fadeout )
+                       {
+                               sys->fadeout_current = sys->persisitent_source->fadeout_current;
+                               sys->fadeout = sys->persisitent_source->fadeout;
+                               
+                               sys->persisitent_source = NULL;
+                               sys->flags &= ~SFX_FLAG_PERSISTENT;
+                       }
+               }
+                       
+               // Apply volume slider if it has one linked
                if( sys->vol_src ) 
-                       sys->vol *= sys->vol_src->val;
+                       sys->cvol = sys->vol * sys->vol_src->val;
+               else
+                       sys->cvol = sys->vol;
        }
        
        MUTEX_UNLOCK( sfx_mux_t01 );
        
-       // Clear buffer ( is necessary ? )
+       // Clear buffer
        float *pOut32F = (float *)pOutBuf;
        for( int i = 0; i < frameCount * 2; i ++ ){
                pOut32F[i] = 0.f;
        }
 
-       // Do something with local..
        for( int i = 0; i < sfx_sys_len; i ++ )
        {
                sfx_system *sys = sfx_sys + i;
                
                u32 cursor = sys->cur, buffer_pos = 0;          
-               float avgvol = 0.f;
                float pcf[2] = { 0.f, 0.0f };
                
                u32 frames_write = frameCount;
@@ -471,10 +444,10 @@ void audio_mixer_callback( ma_device *pDevice, void *pOutBuf, const void *pInput
                
                        if( sys->fadeout )
                        {
-                               // Force this system to be removed
+                               // Force this system to be removed now
                                if( sys->fadeout_current == 0 )
                                {
-                                       sys->flags = SFX_FLAG_GHOST;
+                                       sys->flags &= 0x00000000;
                                        sys->cur = sys->end;
                                        break;
                                }
@@ -502,9 +475,6 @@ void audio_mixer_callback( ma_device *pDevice, void *pOutBuf, const void *pInput
                                pOut32F[ buffer_pos*2+0 ] += pcf[0] * vol;
                                pOut32F[ buffer_pos*2+1 ] += pcf[1] * vol;
                                
-                               avgvol += fabs( pcf[0] * vol );
-                               avgvol += fabs( pcf[1] * vol );
-                               
                                cursor ++;
                                buffer_pos ++;
                        }
@@ -521,8 +491,6 @@ void audio_mixer_callback( ma_device *pDevice, void *pOutBuf, const void *pInput
                        }
 
                        sys->cur = cursor;
-                       sys->signal_average = avgvol / (float)(buffer_pos*2);
-                       
                        break;
                }
        }
@@ -538,20 +506,8 @@ void audio_mixer_callback( ma_device *pDevice, void *pOutBuf, const void *pInput
                // Keep only if cursor is before end or repeating
                if( src->cur < src->end || (src->flags & SFX_FLAG_REPEAT) ) 
                {
-                       // Correct source pointer on persisitent originals since we shifted ID's
-                       if( !(src->flags & (SFX_FLAG_ONESHOT|SFX_FLAG_GHOST)) )
-                       {
-                               src->thread_clone->thread_clone = sfx_sys + wr;
-                       }
-                       
                        sfx_sys[ wr ++ ] = sfx_sys[ idx ];
                }
-               else
-               {
-                       // Clear link on persistent sources (done playing)
-                       if( !(src->flags & (SFX_FLAG_ONESHOT|SFX_FLAG_GHOST)) )
-                               src->thread_clone->thread_clone = NULL;
-               }
                
                idx ++ ;
        }
@@ -630,6 +586,7 @@ static void sfx_set_play( sfx_set *source, sfx_system *sys, int id )
        if( sfx_begin_edit( sys ) )
        {
                sys->fadeout = 0;
+               sys->fadeout_current = 0;
                sys->source = source->main;
                sys->cur        = source->segments[ id*2 + 0 ];
                sys->end        = source->segments[ id*2 + 1 ];
@@ -640,7 +597,7 @@ static void sfx_set_play( sfx_set *source, sfx_system *sys, int id )
                sys->clip_end = sys->end;
                sys->buffer_length = source->segments[ (source->numsegments-1)*2 + 1 ];
                
-               sfx_save( sys );
+               sfx_push( sys );
        }
 }
 
@@ -665,21 +622,10 @@ static void sfx_system_fadeout( sfx_system *sys, u32 length_samples )
 {
        if( sfx_begin_edit( sys ) )
        {
-               if( sys->end )
-               {
-                       sys->fadeout_current = length_samples;
-                       sys->fadeout = length_samples;
-                       
-                       if( sys->thread_clone )
-                               sys->cur = sys->thread_clone->cur;
+               sys->fadeout_current = length_samples;
+               sys->fadeout = length_samples;
                
-                       sfx_save( sys );
-               }
-               else
-               {
-                       // Sound was not initialized
-                       MUTEX_UNLOCK( sfx_mux_t01 );
-               }
+               sfx_end_edit( sys );
        }
 }
 
index c10abd653fb1cb3fc23f611ddaef545c459895fd..558df185bae8a9086ee9531577f8c361a5ffa171 100644 (file)
@@ -80,7 +80,7 @@ static void vg_console_draw( void )
                
                for( int i = 0; i < vg_console.len; i ++ )
                {
-                       ui_text( &ui_global_ctx, vg_console.lines[ptr], vg_console.scale*2, 0 );
+                       ui_text( &ui_global_ctx, vg_console.lines[ptr], vg_console.scale );
                        ui_global_ctx.cursor[1] -= 8*vg_console.scale;
                
                        ptr --;
@@ -97,12 +97,12 @@ static void vg_console_draw( void )
        {
                ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x77333333 );
                
-               ui_text( &ui_global_ctx, vg_console.input, vg_console.scale*2, 0 );
+               ui_text( &ui_global_ctx, vg_console.input, vg_console.scale );
                
                int start = VG_MIN( vg_console.cursor_pos, vg_console.cursor_user ),
                         end   = VG_MAX( vg_console.cursor_pos, vg_console.cursor_user );
                
-               ui_global_ctx.cursor[0] = (start * ui_glyph_spacing_x * vg_console.scale)/2 + 2;
+               ui_global_ctx.cursor[0] = (start * ui_glyph_spacing_x * vg_console.scale) + 2;
                ui_global_ctx.cursor[2] = (start == end? 0.2f: (float)(end-start)) * (float)ui_glyph_spacing_x * (float)vg_console.scale * 0.5f;
                
                ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x66ffffff );
index 9c7d87fbb5219f1ec3345204a3e09d207d0a5be6..16dbbe1592927915a7a573d9048b051543ae4a3e 100644 (file)
@@ -31,23 +31,13 @@ static void sfx_internal_debug_overlay(void)
                sfx_system *sys = sfx_sys + i;
                struct sound_info *snd = &infos[ i ];
                
-               snd->signal = sys->signal_average;
+               //snd->signal = sys->signal_average;
                snd->name = sys->name;
                snd->cursor = sys->cur;
                snd->flags = sys->flags;
-               
-               if( sys->thread_clone )
-               {
-                       snd->clip_start = sys->thread_clone->clip_start;
-                       snd->clip_end = sys->thread_clone->clip_end;
-                       snd->buffer_length = sys->thread_clone->buffer_length;
-               }
-               else
-               {
-                       snd->clip_start = 0;
-                       snd->clip_end = sys->end;
-                       snd->buffer_length = sys->end;
-               }
+               snd->clip_start = sys->clip_start;
+               snd->clip_end = sys->clip_end;
+               snd->buffer_length = sys->buffer_length;
        }
        
        MUTEX_UNLOCK( sfx_mux_t01 );
@@ -61,7 +51,7 @@ static void sfx_internal_debug_overlay(void)
                ui_global_ctx.cursor[2] = 150;
                ui_global_ctx.cursor[3] = 12;
                
-               u32 alpha = (infos[i].flags & SFX_FLAG_GHOST)? 0x44000000: 0xff000000;
+               u32 alpha = (infos[i].flags & SFX_FLAG_PERSISTENT)? 0xff000000: 0x22000000;
 
                ui_new_node( &ui_global_ctx );
                {               
@@ -86,7 +76,7 @@ static void sfx_internal_debug_overlay(void)
                        
                        ui_global_ctx.cursor[0] = baseline + 2;
                        ui_global_ctx.cursor[1] += 2;
-                       ui_text( &ui_global_ctx, infos[i].name, 1, 0 );
+                       ui_text( &ui_global_ctx, infos[i].name, 1 );
                }
                ui_end_down( &ui_global_ctx );
                ui_global_ctx.cursor[1] += 1;
index 70d30aa64677e985150df3fd2e6b7775b15d6093..f6693cbcd7e3320be1d4aef22a9a2abae929dc1a 100644 (file)
@@ -4,7 +4,7 @@ SHADER_DEFINE( shader_ui,
 
        // VERTEX
        "layout (location=0) in vec2 a_co;"                     // i16, i16, .. ?
-       "layout (location=1) in vec2 a_uv;"                     // i8, i8
+       "layout (location=1) in vec2 a_uv;"                     // i16, i16
        "layout (location=2) in vec4 a_colour;" // u32
        "layout (location=3) in vec4 a_clip;"           // i16, i16, i16, i16
        "uniform mat3 uPv;"
@@ -17,7 +17,7 @@ SHADER_DEFINE( shader_ui,
        "void main()"
        "{"
                "gl_Position = vec4( uPv * vec3( a_co, 1.0 ), 1.0 );"
-               "aTexCoords = a_uv * 0.0078125;"
+               "aTexCoords = a_uv * 0.01388888888;"
                "aColour = a_colour;"
                
                "aWsp = a_co;"
@@ -37,9 +37,19 @@ SHADER_DEFINE( shader_ui,
        "void main()"
        "{"
                "float clip_blend = step( aWsp.x, aClip.z ) * step( aWsp.y, aClip.w ) * step( aClip.x, aWsp.x ) * step( aClip.y, aWsp.y );"
-       
-               "vec4 glyph = texture( uTexGlyphs, aTexCoords );"
-               "FragColor = vec4( aColour.rgb * glyph.rgb, aColour.a*glyph.a*clip_blend );"
+               "vec4 glyph = vec4(1.0,1.0,1.0,1.0);"
+               
+               "if( aColour.a == 0.0 )"
+               "{"
+                       "glyph = texture( uTexGlyphs, aTexCoords );"
+                       "glyph.a = smoothstep( 0.47, 0.53, glyph.r );"
+               "}"
+               "else"
+               "{"
+                       "glyph.a = aColour.a;"
+               "}"
+               
+               "FragColor = vec4( aColour.rgb, glyph.a*clip_blend );"
        "}"
        ,
        UNIFORMS({ "uPv", "uTexGlyphs" })
@@ -93,7 +103,7 @@ struct ui_ctx
        struct ui_vert
        {
                ui_px co[2];    //32 4
-               i16 uv[2];              //32 4
+               u8 uv[2];               //16 2
                u32 colour;             //32 4
                ui_rect clip;   //64 8
        }
@@ -134,18 +144,6 @@ struct ui_ctx
        int image_count;
 };
 
-struct ui_sdf_char 
-{
-  int x, y, width, height, originX, originY, advance;
-};
-
-struct ui_sdf_font 
-{
-  const char *name;
-  int size, width, height;
-  struct ui_sdf_char *characters;
-};
-
 // Globals
 // ===========================================================================================================
 
@@ -197,7 +195,7 @@ static void ui_init_context( ui_ctx *ctx, int index_buffer_size )
                glEnableVertexAttribArray( 0 );
                
                // UV
-               glVertexAttribPointer( 1, 2, GL_SHORT, GL_FALSE, stride, (void *)offsetof( struct ui_vert, uv ) );
+               glVertexAttribPointer( 1, 2, GL_UNSIGNED_BYTE, GL_FALSE, stride, (void *)offsetof( struct ui_vert, uv ) );
                glEnableVertexAttribArray( 1 );
                
                // COLOUR
@@ -572,51 +570,16 @@ static struct ui_vert *ui_fill_rect( ui_ctx *ctx, ui_rect rect, u32 colour )
        return ui_fill_rect_uv( ctx, rect, colour, (ui_px[4]){ 4,124,4,124 } );
 }
 
-static void ui_text_use_title( ui_ctx *ctx )
-{
-       ctx->glyph_base = 0;
-}
-
-static void ui_text_use_paragraph( ui_ctx *ctx )
-{
-       ctx->glyph_base = 6;
-}
-
-enum text_alignment
-{
-       k_text_alignment_left = 0,
-       k_text_alignment_center,
-       k_text_alignment_right
-};
-
-static ui_px ui_text( ui_ctx *ctx, const char *str, ui_px scale, enum text_alignment alignment )
+static void ui_text( ui_ctx *ctx, const char *str, ui_px scale )
 {
        ui_rect text_cursor;
 
        text_cursor[0] = ctx->cursor[0];
        text_cursor[1] = ctx->cursor[1];
-       text_cursor[2] = (scale*8)/2;
-       text_cursor[3] = (scale*8)/2;
-
-       u32 current_colour = ctx->override_colour;
+       text_cursor[2] = 7*scale;
+       text_cursor[3] = 7*scale;
 
-       ui_px offset = 0;
-       if( alignment != k_text_alignment_left )
-       {
-               const char *pch = str;
-               for(;;)
-               {
-                       offset += (ui_glyph_spacing_x*scale)/4;
-                       if( !(*pch) || *pch == '\n' )
-                               break;
-                       pch ++;
-               }
-               
-               if( alignment == k_text_alignment_right )
-                       text_cursor[0] = ctx->cursor[0]+ctx->cursor[2]-offset;
-               else
-                       text_cursor[0] = (ctx->cursor[0]+(ctx->cursor[2]/2))-(offset/2);
-       }
+       u32 current_colour = 0x00ffffff;
 
        const char *_c = str;
        char c;
@@ -624,7 +587,7 @@ static ui_px ui_text( ui_ctx *ctx, const char *str, ui_px scale, enum text_align
        {
                if( c == '\n' )
                {
-                       text_cursor[1] += (7*scale)/2;
+                       text_cursor[1] += 10*scale;
                        text_cursor[0] = ctx->cursor[0];
                        continue;
                }
@@ -632,19 +595,13 @@ static ui_px ui_text( ui_ctx *ctx, const char *str, ui_px scale, enum text_align
                {
                        u8 glyph_base[2];
                        u8 glyph_index = c - 32;
-                       glyph_base[0] = (glyph_index&0xf);
-                       glyph_base[1] = ctx->glyph_base + ((glyph_index-glyph_base[0])>>4);
-
-                       glyph_base[0] *= 8;
-                       glyph_base[1] *= 8;
+                       glyph_base[0] = glyph_index%10;
+                       glyph_base[1] = (glyph_index-glyph_base[0])/10;
                        
-                       ui_fill_rect_uv( ctx, text_cursor, current_colour, 
-                               (ui_px[4]){
-                                       glyph_base[0],
-                                       128-glyph_base[1],
-                                       glyph_base[0]+8,
-                                       128-(glyph_base[1]+8)
-                               });
+                       glyph_base[0] *= 7;
+                       glyph_base[1] *= 7;
+                       
+                       ui_fill_rect_uv( ctx, text_cursor, current_colour, (ui_px[4]){glyph_base[0],glyph_base[1],glyph_base[0]+7,glyph_base[1]+7} );
                }
                else if( c == '\x1B' )
                {
@@ -660,14 +617,14 @@ static ui_px ui_text( ui_ctx *ctx, const char *str, ui_px scale, enum text_align
                                                
                                                switch( colour_id )
                                                {
-                                                       case '0': current_colour = 0xffffffff; break;
-                                                       case '3'|'1'<<8: current_colour = 0xff201fee; break;
-                                                       case '3'|'2'<<8: current_colour = 0xff37e420; break;
-                                                       case '3'|'3'<<8: current_colour = 0xff0ed8e2; break;
-                                                       case '3'|'4'<<8: current_colour = 0xfff15010; break;
-                                                       case '3'|'5'<<8: current_colour = 0xffee20ee; break;
-                                                       case '3'|'6'<<8: current_colour = 0xffeeee20; break;
-                                                       case '3'|'7'<<8: current_colour = 0xffffffff; break;
+                                                       case '0': current_colour = 0x00ffffff; break;
+                                                       case '3'|'1'<<8: current_colour = 0x00201fee; break;
+                                                       case '3'|'2'<<8: current_colour = 0x0037e420; break;
+                                                       case '3'|'3'<<8: current_colour = 0x000ed8e2; break;
+                                                       case '3'|'4'<<8: current_colour = 0x00f15010; break;
+                                                       case '3'|'5'<<8: current_colour = 0x00ee20ee; break;
+                                                       case '3'|'6'<<8: current_colour = 0x00eeee20; break;
+                                                       case '3'|'7'<<8: current_colour = 0x00ffffff; break;
                                                }
                                                
                                                break;
@@ -681,13 +638,10 @@ static ui_px ui_text( ui_ctx *ctx, const char *str, ui_px scale, enum text_align
                                        break;
                                }
                        }
-                       continue;
                }
                
-               text_cursor[0] += (ui_glyph_spacing_x*scale)/4;
+               text_cursor[0] += 6*scale;
        }
-       
-       return text_cursor[0];
 }
 
 // API control
@@ -819,7 +773,7 @@ static int ui_window( ui_ctx *ctx, struct ui_window *window, u32 control_group )
                        // title..
                        ctx->cursor[0] += 2;
                        ctx->cursor[1] += 2;
-                       ui_text( ctx, window->title, 2, 0 );
+                       ui_text( ctx, window->title, 2 );
                        
                        // Close button
                        ctx->cursor[3] = 25;
@@ -833,7 +787,7 @@ static int ui_window( ui_ctx *ctx, struct ui_window *window, u32 control_group )
                                vg_info( "Click clacked\n" );
                        }
                        ctx->cursor[0] += 2;
-                       ui_text( ctx, "x", 2, 0 );
+                       ui_text( ctx, "x", 2 );
                        ui_end( ctx );
                        
                        if( ui_hasmouse( ctx ) )