1 #include "shaders/tile_colour.h"
2 #include "shaders/tile_main.h"
3 #include "shaders/ball.h"
4 #include "shaders/background.h"
5 #include "shaders/wire.h"
6 #include "shaders/button.h"
7 #include "shaders/sprite.h"
8 #include "shaders/post_darken.h"
9 #include "shaders/post_comp.h"
10 #include "shaders/post_blur.h"
13 #define UI_GLYPH_SPACING_X 8
15 void _mc_vg1_register(void){
16 shader_tile_colour_register();
17 shader_tile_main_register();
18 shader_ball_register();
19 shader_background_register();
20 shader_wire_register();
21 shader_button_register();
22 shader_sprite_register();
23 shader_post_darken_register();
24 shader_post_comp_register();
25 shader_post_blur_register();
29 // ===========================================================================================================
31 typedef struct vg1_tex2d vg1_tex2d
;
37 vg1_tex2d tex_tile_data
= { "textures/tileset.qoi" };
38 vg1_tex2d tex_tile_glow
= { "textures/lineset.qoi" };
39 vg1_tex2d tex_tile_detail
= { "textures/tile_overlays.qoi" };
40 vg1_tex2d tex_tiles_wood
= { "textures/tile_wood.qoi" };
41 vg1_tex2d tex_tiles_min
= { "textures/tile_minimal.qoi" };
42 vg1_tex2d tex_tiles_lab
= { "textures/tile_lab.qoi" };
43 vg1_tex2d tex_ball_noise
= { "textures/bnoise.qoi" };
44 vg1_tex2d tex_unkown
= { "textures/unkown.qoi" };
45 vg1_tex2d tex_buttons
= { "textures/buttons.qoi" };
46 vg1_tex2d tex_sprites
= { "textures/autocombine.qoi" };
48 vg1_tex2d
*texture_list
[] = {
61 #include "sprites_autocombine.h"
64 // ===========================================================================================================
67 sfx_vol_control audio_volume_sfx
= { .val
= 1.0f
, .name
= "Sound effects" };
68 sfx_vol_control audio_volume_music
= { .val
= 1.0f
, .name
= "Music" };
70 sfx_system audio_system_sfx
=
74 .vol_src
= &audio_volume_sfx
,
79 audio_clip audio_tile_mod
[] = {
80 { .path
="sound/mod_01.ogg" },
81 { .path
="sound/mod_02.ogg" },
82 { .path
="sound/mod_03.ogg" },
83 { .path
="sound/mod_04.ogg" },
84 { .path
="sound/mod_05.ogg" },
85 { .path
="sound/mod_06.ogg" },
88 audio_clip audio_splitter
[] = {
89 { .path
="sound/splitter_01.ogg" },
92 audio_clip audio_rolls
[] = {
93 { .path
="sound/rolling_01.ogg" },
94 { .path
="sound/rolling_02.ogg" }
97 audio_clip audio_random
[] ={
98 { .path
="sound/random_01.ogg" },
99 { .path
="sound/random_02.ogg" },
100 { .path
="sound/random_03.ogg" },
101 { .path
="sound/random_04.ogg" },
102 { .path
="sound/random_05.ogg" },
103 { .path
="sound/random_06.ogg" },
104 { .path
="sound/random_07.ogg" },
105 { .path
="sound/random_08.ogg" },
108 audio_clip audio_clicks
[] = {
109 { .path
="sound/click_a.ogg" },
110 { .path
="sound/click_b.ogg" },
111 { .path
="sound/click_c.ogg" },
114 audio_clip audio_tones
[] = {
115 { .path
="sound/y0.ogg" },
116 { .path
="sound/y1.ogg" },
117 { .path
="sound/y2.ogg" },
118 { .path
="sound/y3.ogg" },
119 { .path
="sound/y4.ogg" },
120 { .path
="sound/y5.ogg" },
121 { .path
="sound/y6.ogg" },
122 { .path
="sound/y7.ogg" },
123 { .path
="sound/y8.ogg" },
124 { .path
="sound/win.ogg" },
127 audio_clip audio_music
[] = {
128 { .path
="sound/mccompt2.ogg" },
132 static void *load_and_play_bgm( void *_inf
)
134 sfx_set_init( &audio_music
, NULL
);
135 sfx_set_play( &audio_music
, &audio_system_music
, 0 );
140 #define INIT_AUDIO( X ) audio_clip_loadn( X, vg_list_size(X), NULL );
142 static void _mc_resource_load_main(void){
144 for( u32 i
=0; i
<vg_list_size(texture_list
); i
++ ){
145 struct vg1_tex2d
*tex
= texture_list
[i
];
146 vg_tex2d_load_qoi_async_file( tex
->path
, 0, &tex
->name
);
150 INIT_AUDIO( audio_tile_mod
);
151 INIT_AUDIO( audio_tile_mod
);
152 INIT_AUDIO( audio_splitter
);
153 INIT_AUDIO( audio_rolls
);
154 INIT_AUDIO( audio_random
);
155 INIT_AUDIO( audio_clicks
);
156 INIT_AUDIO( audio_tones
);
159 vg_thread_run( load_and_play_bgm
, NULL
);
164 0000 0 | 0001 1 | 0010 2 | 0011 3
168 0100 4 | 0101 5 | 0110 6 | 0111 7
172 1000 8 | 1001 9 | 1010 10 | 1011 11
176 1100 12 | 1101 13 | 1110 14 | 1111 15
187 const char *map_name
;
189 const char *description
;
191 const char *achievement
;
193 int _unlock
, _linked
; // When completed, unlock this level
215 struct world_button btn
;
216 struct cmp_level
*unlock
, *linked
;
219 SteamLeaderboard_t steam_leaderboard
;
223 static struct cmp_level cmp_levels_tutorials
[] =
226 0, "cmp_t01", "PRINCIPLE 1", "",
231 1, "cmp_t02", "PRINCIPLE 2", "",
236 2, "cmp_t03", "PRINCIPLE 3", "",
241 12, "cmp_t04", "PRINCIPLE 4", "",
244 .achievement
= "TUTORIALS"
247 15, "cmp_b10", "PRINCIPLE 5", "",
252 17, "cmp_b11", "PRINCIPLE 6", "(Right click)",
257 26, "cmp_p7", "PRINCIPLE 7", "Emitters",
264 static struct cmp_level cmp_levels_basic
[] =
267 6, "cmp_b04", "PATCH", "",
272 3, "cmp_b01", "SUBDIVISION 1", "",
277 4, "cmp_b02", "SUBDIVISION 2", "",
281 5, "cmp_b03", "RESTRUCTURE", "",
286 31, "cmp_121", "1-2-1", "",
290 7, "cmp_b05", "PATTERNS 1", "",
295 8, "cmp_b06", "PATTERNS 2", "",
299 16, "cmp_routing", "ROUTING PROBLEM", "",
303 9, "cmp_b07", "MIGHTY CONSUMER", "",
306 .achievement
= "MIGHTY_CONSUMER"
309 10, "cmp_b08", "SHIFT", "",
313 11, "cmp_b09", "REVERSE", "",
317 18, "cmp_not", "NOT GATE", "",
322 19, "cmp_and", "AND GATE", "",
326 20, "cmp_xor", "QUALIFICATION PROJECT", "",
328 .achievement
= "GRADUATE"
331 27, "cmp_expander", "EXPAND", "",
335 28, "cmp_pattern3", "PATTERNS 3", "",
339 29, "cmp_routing2", "ROUTING PROBLEM 2", "Spaghetti!",
344 30, "cmp_exact5", "EXACTLY 5", "",
348 32, "cmp_3and2", "THREE AND FOUR", "",
352 34, "doublex2", "DOUBLE DOUBLE", "Delay & repeat",
356 35, "oddoreven", "ODD OR EVEN", ""
360 static struct cmp_level cmp_levels_grad
[] =
363 13, "cmp_i01", "SORT", "",
367 14, "cmp_i02", "THIRDS", "",
371 21, "cmp_grad", "SIMPLE ADDITION", "",
376 22, "cmp_secret", "SECRET CODE", "",
381 static struct cmp_level cmp_levels_computer
[] =
384 23, "cmp_binary", "3 BIT BINARY", "Convert amount to binary",
389 .placement
= k_placement_bottom
,
391 "\t\t\t\t\t\t\t\t\t\t\x83 \x84\n"
392 "\t\t\t\t\t\t\t\t\t\t\x83 \x84 Binary\n"
393 "\t\t\t\t\t\t\t\t\t\t\x83 4 2 1 \x84"
396 .placement
= k_placement_top
,
399 "\t\t\t\t\t\t\t\t\t\t\t Count"
404 24, "cmp_add3b", "3 BIT ADDER", "Binary addition",
409 .placement
= k_placement_top
,
410 //.str ="\t\t\t\t\t\t\t\t\t| NUMBER A | | NUMBER B |\n"
412 "\t\t\t\t\t\t\t\t\t\x8A 4 2 1 \x8B \x8A 4 2 1 \x8B\n"
413 "\t\t\t\t\t\t\t\t\t\x83 \x84 add \x83 \x84\n"
414 "\t\t\t\t\t\t\t\t\t\x83 \x84 \x83 \x84"
417 .placement
= k_placement_bottom
,
420 "\t\t\t\x83 \x84 result a+b\n"
421 "\t\t\t\x83 8 4 2 1 \x84"
426 25, "cmp_plot3x3", "3x3 PLOT", "2 bit x/y",
431 .placement
= k_placement_top
,
433 "\t\t\t\t\t\t\t\t\x8A 2 1 \x8B \x8A 2 1 \x8B\n"
434 "\t\t\t\t\t\t\t\t\x83 \x84 X Y \x83 \x84\n"
435 "\t\t\t\t\t\t\t\t\x83 \x84 \x83 \x84"
440 33, "compactxor", "Compact XOR", "",
444 .placement
= k_placement_top
,
446 "\t\t\t\t\x8A \x8B \x8A \x8B\n"
447 "\t\t\t\t\x83 \x84""A B\x83 \x84\n"
448 "\t\t\t\t\x83 \x84 \x83 \x84"
451 .placement
= k_placement_bottom
,
454 "\t\t\t\x83 \x84 result a xor b\n"
461 #define NUM_CAMPAIGN_LEVELS (vg_list_size( cmp_levels_tutorials ) + vg_list_size( cmp_levels_basic ) + vg_list_size( cmp_levels_grad ) + vg_list_size( cmp_levels_computer ) )
463 static struct career_level_pack
465 struct cmp_level
*pack
;
476 .pack
= cmp_levels_tutorials
,
478 .count
= vg_list_size( cmp_levels_tutorials
),
479 .primary_colour
= { 0.204f
, 0.345f
, 0.553f
},
480 .origin
= { -4, -2 },
484 .pack
= cmp_levels_basic
,
485 .title
= "\x8C\x8D"" Core",
486 .count
= vg_list_size( cmp_levels_basic
),
487 .primary_colour
= { 0.304f
, 0.245f
, 0.553f
},
488 .origin
= { -3, -2 },
492 .pack
= cmp_levels_grad
,
493 .title
= "\x8C\x8E"" Challenge",
494 .count
= vg_list_size( cmp_levels_grad
),
495 .primary_colour
= { 0.75f
, 0.23f
, 0.39f
},
500 .pack
= cmp_levels_computer
,
501 .title
= "\x8C\x8F"" 3 Bit computer\n\n (preview)",
502 .count
= vg_list_size( cmp_levels_computer
),
503 .primary_colour
= { 0.75f
, 0.14f
, 0.1f
},
509 // Setup pointers and that
510 static void career_local_data_init(void)
512 struct cmp_level
*level_ptrs
[ NUM_CAMPAIGN_LEVELS
];
513 for( int i
= 0; i
< NUM_CAMPAIGN_LEVELS
; i
++ )
514 level_ptrs
[i
] = NULL
;
517 for( int i
= 0; i
< vg_list_size( career_packs
); i
++ )
519 struct career_level_pack
*set
= &career_packs
[i
];
521 for( int j
= 0; j
< set
->count
; j
++ )
523 int id
= set
->pack
[j
].serial_id
;
525 if( level_ptrs
[ id
] )
526 vg_error( "Serial id %u already used!\n", id
);
528 level_ptrs
[ set
->pack
[j
].serial_id
] = &set
->pack
[j
];
533 for( int i
= 0; i
< vg_list_size( career_packs
); i
++ )
535 struct career_level_pack
*set
= &career_packs
[i
];
537 for( int j
= 0; j
< set
->count
; j
++ )
539 struct cmp_level
*lvl
= &set
->pack
[j
];
541 if( lvl
->_unlock
>= NUM_CAMPAIGN_LEVELS
||
542 lvl
->_linked
>= NUM_CAMPAIGN_LEVELS
)
544 vg_error( "_unlock / _linked out of range (%d, %d)\n",
545 lvl
->_unlock
, lvl
->_linked
);
549 lvl
->unlock
= lvl
->_unlock
? level_ptrs
[ lvl
->_unlock
]: NULL
;
550 lvl
->linked
= lvl
->_linked
? level_ptrs
[ lvl
->_linked
]: NULL
;