-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpage0.c
1875 lines (1490 loc) · 49.3 KB
/
page0.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "types.h"
uword dummy_uword_in_zero_address = 0xCAFE;
// void p0_p0_pagein()
// {
// __asm__("NEXTREG $50, 36");
// __asm__("NEXTREG $51, 37");
// }
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// # #
// ## ## ## # # #
// # # # # # # # ## #
// # # # # # # # # #
// # # ###### # # # #
// # # # # # # ##
// # # # # # # #
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "types.h"
#include "screen_main.h"
#include "gui.h"
#include "spmgr.h"
#include "mouse.h"
#include "colors.h"
#include "screen_controller.h"
#include "screen_provs.h"
#include "screen_game.h"
#include "screen_epilog.h"
#include "print_tile.h"
#include "player_data.h"
#include "sound.h"
#include "keyb.h"
#include "board.h"
#include "params.h"
#define SM_ST_X 10
#define SM_ST_Y 11
#define SM_ST_W 20
#define SM_ST_H 5
#define SM_ST2_X 10
#define SM_ST2_Y 10
#define SM_ST2_W 9
#define SM_ST2_H 6
#define SM_BP_X 19
#define SM_BP_Y 10
#define SM_BP_W 11
#define SM_BP_H 6
#define SM_OP_X 19
#define SM_OP_Y 16
#define SM_OP_W 11
#define SM_OP_H 5
#define SM_AB_X 10
#define SM_AB_Y 16
#define SM_AB_W 9
#define SM_AB_H 5
GuiButton sm_btn_start;
GuiButton sm_btn_bonus;
GuiButton sm_btn_opts;
GuiButton sm_btn_about;
const char* str_TRAINYARD_EXPRESS = "TRAINYARD EXPRESS";
const char* str_DEVELOPMENT_BUILD = "DEVELOPMENT BUILD";
const char* str_OPTIONS = "OPTIONS";
const char* str_ABOUT = "ABOUT";
ubyte sm_show_bonus_btn;
void si_init_trains();
void si_update_trains();
void p0_sm_enter()
{
spmgr_init();
spmgr_setup_cursor();
gui_clear_screen();
si_init_trains();
sm_show_bonus_btn = 0;
if (pd_all_levels_unlocked || pd_base_levels_solved)
sm_show_bonus_btn = 1;
print_set_color(COLOR_WHI);
#define TITLE_TILE 60
for (ubyte i = 0; i < 4; i++) {
draw_tile_xy(12 + 4*i, 5, TITLE_TILE + i);
}
print_set_color(CTEXT_WHI);
// print_set_pos(11, 8);
// print_str(str_TRAINYARD_EXPRESS);
if (!sm_show_bonus_btn) {
print_set_color(CTEXT_GRE);
GUIBUTTON_INIT(sm_btn_start, SM_ST_X, SM_ST_Y, SM_ST_W, SM_ST_H);
guibutton_draw(&sm_btn_start);
print_set_color(CTEXT_WHI);
print_set_pos(SM_ST_X + 3, SM_ST_Y + 2);
print_str("START THE GAME!");
}
else {
print_set_color(CTEXT_GRE);
GUIBUTTON_INIT(sm_btn_start, SM_ST2_X, SM_ST2_Y, SM_ST2_W, SM_ST2_H);
guibutton_draw(&sm_btn_start);
print_set_color(CTEXT_WHI);
print_set_pos(SM_ST2_X + 2, SM_ST2_Y + 2);
print_str("START");
print_set_pos(SM_ST2_X + 2, SM_ST2_Y + 3);
print_str("GAME!");
print_set_color(CTEXT_BLU);
GUIBUTTON_INIT(sm_btn_bonus, SM_BP_X, SM_BP_Y, SM_BP_W, SM_BP_H);
guibutton_draw(&sm_btn_bonus);
print_set_color(CTEXT_WHI);
print_set_pos(SM_BP_X + 3, SM_BP_Y + 2);
print_str("BONUS");
print_set_pos(SM_BP_X + 2, SM_BP_Y + 3);
print_str("PUZZLES");
}
print_set_color(CTEXT_WHI);
GUIBUTTON_INIT(sm_btn_opts, SM_OP_X, SM_OP_Y, SM_OP_W, SM_OP_H);
guibutton_draw(&sm_btn_opts);
print_set_pos(SM_OP_X + 2, SM_OP_Y + 2);
print_str(str_OPTIONS);
GUIBUTTON_INIT(sm_btn_about, SM_AB_X, SM_AB_Y, SM_AB_W, SM_AB_H);
guibutton_draw(&sm_btn_about);
print_set_pos(SM_AB_X + 2, SM_AB_Y + 2);
print_str(str_ABOUT);
}
void sm_on_start()
{
sc_switch_screen(sp_enter, sp_update, NULL);
}
void sm_on_opts()
{
sc_switch_screen(so_enter, so_update, NULL);
}
void sm_on_about()
{
sc_switch_screen(sa_enter, sa_update, NULL);
}
void sm_on_bonus()
{
sc_switch_screen(sb_enter, sb_update, NULL);
}
void p0_sm_update()
{
mouseAction = nullMouseAction;
if (guibutton_mouseinto(&sm_btn_start)) mouseAction = sm_on_start;
else if (guibutton_mouseinto(&sm_btn_opts)) mouseAction = sm_on_opts;
else if (guibutton_mouseinto(&sm_btn_about)) mouseAction = sm_on_about;
else if (sm_show_bonus_btn) {
if (guibutton_mouseinto(&sm_btn_bonus)) mouseAction = sm_on_bonus;
}
if (mouseAction == nullMouseAction) spmgr_cursor_set_arrow();
else spmgr_cursor_set_hand();
spmgr_update_cursor(mouse_x, mouse_y);
// check clicked buttons
if (mouse_released_l) mouseAction();
si_update_trains();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// ######
// # # ##### #### # # ####
// # # # # # # # # #
// ###### # # # # # # ####
// # ##### # # # # #
// # # # # # # # # #
// # # # #### ## ####
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "screen_provs.h"
#include "gui.h"
#include "spmgr.h"
#include "mouse.h"
#include "colors.h"
#include "screen_controller.h"
#include "screen_levels.h"
#include "screen_game.h"
#include "screen_main.h"
#include "print_tile.h"
#include "player_data.h"
#include "level.h"
#include <string.h>
#define SP_COL0_X 0
#define SP_COL1_X 20
#define SP_COL_W 20
#define SP_ROW_Y 5
#define SP_ROW_H 4
#define SP_ROW_DY 5
#define SP_TXT_AVAIL 18
#define NUM_PROVS_IN_COL 5
#define NUM_PROVS 10
GuiButton sp_prov_btns[NUM_PROVS];
ubyte sp_prov_unlocked[NUM_PROVS];
extern GuiButton sg_back_btn;
extern void sg_init_back_btn();
const char* str_Provinces = "Provinces";
const char* str_4_qmarks = "? ? ? ?";
const char* str__slash_ = " / ";
const char* str__to_unlock = " to unlock";
void sp_draw_sep_line()
{
print_set_pos(0, 3);
print_set_attr((CTEXT_GRE << 4) | ATTR___R_);
print_set_symbol(BLOCK_FSTR);
ubyte cnt = 40;
while (cnt--)
print_symbol();
}
void p0_sp_enter()
{
spmgr_init();
spmgr_setup_cursor();
gui_clear_screen();
sp_draw_sep_line();
sg_draw_score();
sg_init_back_btn();
print_set_color(CTEXT_WHI);
print_set_pos(9, 1);
print_str(str_Provinces);
ubyte x, y;
for (ubyte i = 0; i < NUM_PROVS; i++)
{
if (i < NUM_PROVS_IN_COL) {
x = SP_COL0_X;
y = SP_ROW_Y + i * SP_ROW_DY;
}
else {
x = SP_COL1_X;
y = SP_ROW_Y + (i - NUM_PROVS_IN_COL) * SP_ROW_DY;
}
GuiButton* btn = &sp_prov_btns[i];
GUIBUTTON_INIT((*btn), x, y, SP_COL_W, SP_ROW_H);
ubyte* provrec = provarr[i];
uword ustars = *((uword*)provrec);
const char* provname = (const char*)(provrec + 2);
ubyte pnlen = strlen(provname);
ubyte levcount = *(provrec + pnlen + 3);
ubyte levidx = *(provrec + pnlen + 4);
ubyte levactcount = 0; // actual level count (no tutorials)
ubyte levsolcount = 0; // solved level count
for (ubyte j = 0; j < levcount; j++) {
ubyte* levrec = levarr[levidx+j];
ubyte levstars = *levrec;
if (!levstars) continue;
levactcount++;
ubyte levsolved = pd_levels_solved[levidx+j];
if (!levsolved) continue;
levsolcount++;
}
if (ustars <= pd_score || pd_all_levels_unlocked)
{
sp_prov_unlocked[i] = 1;
print_set_color(CTEXT_WHI);
guibutton_draw(btn);
const char* provname = (const char*)(provrec + 2);
ubyte dx = (SP_TXT_AVAIL - ((ubyte)strlen(provname))) >> 1;
print_set_pos(btn->x+1+dx, btn->y+1);
print_str(provname);
print_set_pos(btn->x+7, btn->y+2);
if (levsolcount < levactcount) print_set_color(CTEXT_YEL);
else print_set_color(CTEXT_GRE);
print_hex_nibble(levsolcount);
print_str(str__slash_);
print_hex_nibble(levactcount);
}
else
{
sp_prov_unlocked[i] = 0;
print_set_color(CTEXT_ORA);
guibutton_draw(btn);
print_set_pos(btn->x+5, btn->y+1);
print_str(str_4_qmarks);
ustars -= pd_score;
ubyte dx = 2;
if (ustars < 100) dx++;
if (ustars < 10) dx++;
print_set_color(CTEXT_YEL);
print_set_pos(btn->x+dx, btn->y+2);
print_dec_word(ustars);
print_block(BLOCK_STAR);
print_str(str__to_unlock);
}
}
}
void sp_on_back_btn()
{
sc_switch_screen(sm_enter, sm_update, NULL);
}
ubyte sp_over_prov_idx = 0;
void sp_on_prov_btn()
{
sg_prov_idx = sp_over_prov_idx;
sc_switch_screen(sl_enter, sl_update, NULL);
}
void p0_sp_update()
{
mouseAction = nullMouseAction;
if (guibutton_mouseinto(&sg_back_btn)) {
mouseAction = sp_on_back_btn;
}
else for (ubyte i = 0; i < NUM_PROVS; i++) {
if (!sp_prov_unlocked[i]) break;
GuiButton* btn = &sp_prov_btns[i];
if (guibutton_mouseinto(btn)) {
sp_over_prov_idx = i;
mouseAction = sp_on_prov_btn;
break;
}
}
if (mouseAction == nullMouseAction) spmgr_cursor_set_arrow();
else spmgr_cursor_set_hand();
spmgr_update_cursor(mouse_x, mouse_y);
// check clicked buttons
if (mouse_released_l) mouseAction();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// ######
// # # #### # # # # ####
// # # # # ## # # # #
// ###### # # # # # # # ####
// # # # # # # # # # #
// # # # # # ## # # # #
// ###### #### # # #### ####
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "screen_provs.h"
#include "gui.h"
#include "spmgr.h"
#include "mouse.h"
#include "colors.h"
#include "screen_controller.h"
#include "screen_levels.h"
#include "screen_game.h"
#include "screen_main.h"
#include "print_tile.h"
#include "player_data.h"
#include "level.h"
#include <string.h>
#define SB_COL_X 10
#define SB_COL1_X 20
#define SB_COL_W 20
#define SB_ROW_Y 5
#define SB_ROW_H 4
#define SB_ROW_DY 5
#define SB_TXT_AVAIL 18
#define FIRST_BONUS_PROV 10
#define NUM_BONUS_PROVS 3
GuiButton sb_prov_btns[NUM_BONUS_PROVS];
ubyte sb_prov_unlocked[NUM_BONUS_PROVS];
extern GuiButton sg_back_btn;
extern void sg_init_back_btn();
// const char* str_4_qmarks = "? ? ? ?";
// const char* str__slash_ = " / ";
// const char* str__to_unlock = " to unlock";
void p0_sb_enter()
{
spmgr_init();
spmgr_setup_cursor();
gui_clear_screen();
sp_draw_sep_line();
sg_draw_score();
sg_init_back_btn();
print_set_color(CTEXT_WHI);
print_set_pos(9, 1);
print_str("Bonus Puzzles");
for (ubyte i = 0; i < NUM_BONUS_PROVS; i++)
{
ubyte x = SB_COL_X;
ubyte y = SB_ROW_Y + i * SB_ROW_DY;
GuiButton* btn = &sb_prov_btns[FIRST_BONUS_PROV + i];
GUIBUTTON_INIT((*btn), x, y, SB_COL_W, SB_ROW_H);
ubyte* provrec = provarr[FIRST_BONUS_PROV + i];
uword ustars = *((uword*)provrec);
const char* provname = (const char*)(provrec + 2);
ubyte pnlen = strlen(provname);
ubyte levcount = *(provrec + pnlen + 3);
ubyte levidx = *(provrec + pnlen + 4);
ubyte levactcount = 0; // actual level count (no tutorials)
ubyte levsolcount = 0; // solved level count
for (ubyte j = 0; j < levcount; j++) {
ubyte* levrec = levarr[levidx+j];
ubyte levstars = *levrec;
if (!levstars) continue;
levactcount++;
ubyte levsolved = pd_levels_solved[levidx+j];
if (!levsolved) continue;
levsolcount++;
}
if (ustars <= pd_score || pd_all_levels_unlocked)
{
sb_prov_unlocked[FIRST_BONUS_PROV + i] = 1;
print_set_color(CTEXT_WHI);
guibutton_draw(btn);
const char* provname = (const char*)(provrec + 2);
ubyte dx = (SB_TXT_AVAIL - ((ubyte)strlen(provname))) >> 1;
print_set_pos(btn->x+1+dx, btn->y+1);
print_str(provname);
print_set_pos(btn->x+7, btn->y+2);
if (levsolcount < levactcount) print_set_color(CTEXT_YEL);
else print_set_color(CTEXT_GRE);
print_hex_nibble(levsolcount);
print_str(str__slash_);
print_hex_nibble(levactcount);
}
else
{
sb_prov_unlocked[FIRST_BONUS_PROV + i] = 0;
print_set_color(CTEXT_ORA);
guibutton_draw(btn);
print_set_pos(btn->x+5, btn->y+1);
print_str(str_4_qmarks);
ustars -= pd_score;
ubyte dx = 2;
if (ustars < 100) dx++;
if (ustars < 10) dx++;
print_set_color(CTEXT_YEL);
print_set_pos(btn->x+dx, btn->y+2);
print_dec_word(ustars);
print_block(BLOCK_STAR);
print_str(str__to_unlock);
}
}
}
void sb_on_back_btn()
{
sc_switch_screen(sm_enter, sm_update, NULL);
}
ubyte sb_over_prov_idx = 0;
void sb_on_prov_btn()
{
sg_prov_idx = sb_over_prov_idx;
sc_switch_screen(sl_enter, sl_update, NULL);
}
void p0_sb_update()
{
mouseAction = nullMouseAction;
if (guibutton_mouseinto(&sg_back_btn)) {
mouseAction = sb_on_back_btn;
}
else for (ubyte i = 0; i < NUM_BONUS_PROVS; i++) {
if (!sb_prov_unlocked[FIRST_BONUS_PROV + i]) break;
GuiButton* btn = &sb_prov_btns[FIRST_BONUS_PROV + i];
if (guibutton_mouseinto(btn)) {
sb_over_prov_idx = FIRST_BONUS_PROV + i;
mouseAction = sb_on_prov_btn;
break;
}
}
if (mouseAction == nullMouseAction) spmgr_cursor_set_arrow();
else spmgr_cursor_set_hand();
spmgr_update_cursor(mouse_x, mouse_y);
// check clicked buttons
if (mouse_released_l) mouseAction();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// #
// # ###### # # ###### # ####
// # # # # # # #
// # ##### # # ##### # ####
// # # # # # # #
// # # # # # # # #
// ####### ###### ## ###### ###### ####
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#define SL_COL0_X 0
#define SL_COL1_X 20
#define SL_COL_W 20
#define SL_ROW_Y 5
#define SL_ROW_H 4
#define SL_ROW_DY 5
#define SL_TXT_AVAIL 18
#define MAX_LEVELS_IN_PROV 8
#define NUM_LEVELS_IN_COL 4
GuiButton sl_level_btns[MAX_LEVELS_IN_PROV];
extern GuiButton sg_back_btn;
extern void sg_init_back_btn();
ubyte* sl_provrec;
uword sl_ustars;
const char* sl_provname;
ubyte sl_pnlen;
ubyte sl_levcount;
ubyte sl_levidx;
void p0_sl_enter()
{
spmgr_init();
spmgr_setup_cursor();
gui_clear_screen();
sp_draw_sep_line();
sg_init_back_btn();
sg_draw_score();
print_set_color(CTEXT_WHI);
sl_provrec = provarr[sg_prov_idx];
sl_ustars = *((uword*)sl_provrec);
sl_provname = (const char*)(sl_provrec + 2);
sl_pnlen = strlen(sl_provname);
sl_levcount = *(sl_provrec + sl_pnlen + 3);
sl_levidx = *(sl_provrec + sl_pnlen + 4);
print_set_pos(9, 1);
print_str(sl_provname);
ubyte x, y;
for (ubyte i = 0; i < sl_levcount; i++)
{
if (i < NUM_LEVELS_IN_COL) {
x = SL_COL0_X;
y = SL_ROW_Y + i * SL_ROW_DY;
}
else {
x = SL_COL1_X;
y = SL_ROW_Y + (i - NUM_LEVELS_IN_COL) * SL_ROW_DY;
}
GuiButton* btn = &sl_level_btns[i];
GUIBUTTON_INIT((*btn), x, y, SL_COL_W, SL_ROW_H);
ubyte* levrec = levarr[sl_levidx + i];
ubyte levstars = *levrec;
const char* levname = (const char*)(levrec + 2);
ubyte levsolved = pd_levels_solved[sl_levidx + i];
ubyte dx = (SL_TXT_AVAIL - ((ubyte)strlen(levname))) >> 1;
print_set_pos(btn->x+1+dx, btn->y+1);
if (levstars != 0) {
print_set_color(CTEXT_WHI);
print_str(levname);
guibutton_draw(btn);
if (!levsolved) {
print_set_color(CTEXT_YEL);
print_set_pos(btn->x+8, btn->y+2);
print_dec_byte(levstars);
print_block(BLOCK_STAR);
}
else {
print_set_color(CTEXT_GRE);
print_set_pos(btn->x+7, btn->y+2);
print_str("SOLVED");
}
}
else {
print_set_color(CTEXT_BLU);
print_str(levname);
guibutton_draw(btn);
print_set_pos(btn->x+6, btn->y+2);
if (levsolved) print_set_color(CTEXT_GRE);
else print_set_color(CTEXT_YEL);
print_str("TUTORIAL");
}
}
// GUIBUTTON_INIT(sl_btn_start, SL_ST_X, SL_ST_Y, SL_ST_W, SL_ST_H);
// guibutton_draw(&sl_btn_start);
// print_set_pos(SL_ST_X + 3, SL_ST_Y + 2);
// print_str("START GAME");
}
void sl_on_back()
{
if (sg_prov_idx < 10)
sc_switch_screen(sp_enter, sp_update, NULL);
else
sc_switch_screen(sb_enter, sb_update, NULL);
}
ubyte sl_over_level_idx = 0;
void sl_on_level_btn()
{
sg_level_idx = sl_over_level_idx;
sc_switch_level(sg_level_idx);
}
void p0_sl_update()
{
mouseAction = nullMouseAction;
if (guibutton_mouseinto(&sg_back_btn)) {
mouseAction = sl_on_back;
}
else for (ubyte i = 0; i < sl_levcount; i++)
{
GuiButton* btn = &sl_level_btns[i];
if (guibutton_mouseinto(btn)) {
sl_over_level_idx = sl_levidx + i;
mouseAction = sl_on_level_btn;
break;
}
}
if (mouseAction == nullMouseAction) spmgr_cursor_set_arrow();
else spmgr_cursor_set_hand();
spmgr_update_cursor(mouse_x, mouse_y);
// check clicked buttons
if (mouse_released_l) mouseAction();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// #
// # # ##### #### # # #####
// # # # # # # # # #
// # # ##### # # # # #
// ####### # # # # # # #
// # # # # # # # # #
// # # ##### #### #### #
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "update_build_version.h"
#include "keyb.h"
extern GuiButton sg_back_btn;
extern void sg_init_back_btn();
void sa_print_build_version();
void p0_sa_enter()
{
spmgr_init();
spmgr_setup_cursor();
gui_clear_screen();
sp_draw_sep_line();
sg_init_back_btn();
print_set_color(CTEXT_WHI);
print_set_pos(9, 1);
print_str("About Trainyard Express");
print_set_color(CTEXT_WHI);
print_set_pos(1, 8);
print_str("Spectrum Next version by David Crespo");
print_set_pos(8, 9);
print_str("Developed in summer 2022");
print_set_color(CTEXT_BLU);
print_set_pos(9, 11);
print_str("https://dcrespo.com");
print_set_pos(1, 13);
print_str("https://www.youtube.com/DavidPrograma");
print_set_color(CTEXT_WHI);
print_set_pos(3, 18);
print_str("Original game concept by Matt Rix");
print_set_pos(7, 19);
print_str("Developed for smartphones");
print_set_pos(7, 20);
print_str("and first released in 2010");
print_set_color(CTEXT_BLU);
print_set_pos(9, 22);
print_str("https://trainyard.ca");
if (pd_debug_on)
sa_print_build_version();
}
void sa_print_build_version()
{
print_set_color(CTEXT_WHI);
print_set_pos(4, 30);
print_str(BUILD_STR);
}
void sa_on_back_btn()
{
sc_switch_screen(sm_enter, sm_update, NULL);
}
void p0_sa_update()
{
mouseAction = nullMouseAction;
if (GBMI(&sg_back_btn)) mouseAction = sa_on_back_btn;
if (mouseAction == nullMouseAction) spmgr_cursor_set_arrow();
else spmgr_cursor_set_hand();
spmgr_update_cursor(mouse_x, mouse_y);
// check clicked buttons
if (mouse_released_l) mouseAction();
if (zxkeyQ() && zxkeyZ() && zxkeyP() && zxkeyM()) {
pd_debug_on = 1;
sa_print_build_version();
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// #####
// # # ##### ##### # #### # # ####
// # # # # # # # # ## # #
// # # # # # # # # # # # ####
// # # ##### # # # # # # # #
// # # # # # # # # ## # #
// ##### # # # #### # # ####
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
extern GuiButton sg_back_btn;
extern void sg_init_back_btn();
#define SENS_BTN_CNT 3
GuiButton so_sens_btns[SENS_BTN_CNT];
const char* so_sens_txts[SENS_BTN_CNT] = {"LOW", "MED", "HIGH" };
ubyte so_sens_w [SENS_BTN_CNT] = { 5, 5, 6 };
void so_draw_sens_btns();
void p0_so_enter()
{
spmgr_init();
spmgr_setup_cursor();
gui_clear_screen();
sp_draw_sep_line();
sg_init_back_btn();
print_set_color(CTEXT_WHI);
print_set_pos(9, 1);
print_str("Options");
print_set_pos(14, 6);
print_str("Cursor speed");
so_draw_sens_btns();
}
void so_draw_sens_btns()
{
ubyte x = 12;
ubyte y = 8;
for (ubyte i = 0; i < SENS_BTN_CNT; i++) {
ubyte w = so_sens_w[i];
GUIBUTTON_INIT(so_sens_btns[i], x, y, w, 3);
if (i == pd_sens) print_set_color(CTEXT_BLU);
else print_set_color(CTEXT_WHI);
guibutton_draw(&so_sens_btns[i]);
print_set_pos(x+1,y+1);
print_str(so_sens_txts[i]);
x += w;
}
}
void so_on_back_btn()
{
sc_switch_screen(sm_enter, sm_update, NULL);
}
ubyte so_sens_idx = 0;
void so_on_sens_btn()
{
pd_set_sens(so_sens_idx);
so_draw_sens_btns();
}
void p0_so_update()
{
mouseAction = nullMouseAction;
if (GBMI(&sg_back_btn)) mouseAction = so_on_back_btn;
else for (ubyte i = 0; i < SENS_BTN_CNT; i++) {
if (GBMI(&so_sens_btns[i])) {
so_sens_idx = i;
mouseAction = so_on_sens_btn;
break;
}
}
if (mouseAction == nullMouseAction) spmgr_cursor_set_arrow();
else spmgr_cursor_set_hand();
spmgr_update_cursor(mouse_x, mouse_y);
// check clicked buttons
if (mouse_released_l) mouseAction();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// ###
// # # # ##### ##### ####
// # ## # # # # # #
// # # # # # # # # #
// # # # # # ##### # #
// # # ## # # # # #
// ### # # # # # ####
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
extern GuiButton sg_back_btn;
extern void sg_init_back_btn();
GuiButton si_btn_cont;
#define SI_CX 14
#define SI_CY 23
#define SI_CW 12
#define SI_CH 3
ubyte si_train0_idx;
void p0_si_enter()
{
spmgr_init();
spmgr_setup_cursor();
gui_clear_screen();
si_init_trains();
// sp_draw_sep_line();
// sg_init_back_btn();
print_set_color(CTEXT_WHI);
print_set_pos(5, 7);
print_str("Welcome to ");
print_set_color(CTEXT_GRE);
print_str("Trainyard Express!");
print_set_color(CTEXT_WHI);
print_set_pos(2, 10);
print_str("In this game you will use the ");
print_set_color(CTEXT_GRE);
print_set_color(CTEXT_WHI);
print_str("cursor\n");
print_str("for drawing tracks for the trains.\n");
print_str("\n");
print_str("For moving the cursor, you can use:\n");
print_str("- ");
print_set_color(CTEXT_BLU);
print_str("Mouse");
print_set_color(CTEXT_WHI);
print_str(", using the PS/2 port\n");
print_str("- ");
print_set_color(CTEXT_BLU);
print_str("Joystick");
print_set_color(CTEXT_WHI);
print_str(", using Kempston port 1\n");
print_str("- ");
print_set_color(CTEXT_BLU);
print_str("Keyboard");