drawmesg.c
31.3 KB
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
/********************************************************************************
NINTENDO64 Disk Drive IPL4
message & clock drawing module
July 17, 1997
********************************************************************************/
#include <ultra64.h>
#include "ipl4.h"
#include "static.h"
#include "graphics.h"
#include "AUDIO/cpuaudio.h"
#define NUM_DMA_MESGS 1
static OSMesgQueue DmaMesgque; /* DMA message queue */
static OSMesg DmaMesgbuf[NUM_DMA_MESGS]; /* DMA message buffer */
static uchar *TexClockDigit[10] = {
ClockNum0, ClockNum1, ClockNum2, ClockNum3, ClockNum4,
ClockNum5, ClockNum6, ClockNum7, ClockNum8, ClockNum9
};
static uchar *TexClockWeek[7] = {
ClockMon, ClockTue, ClockWed, ClockThu, ClockFri, ClockSat, ClockSun
};
/********************************************************************************/
/* */
/* Font cache and string buffer. */
/* */
/********************************************************************************/
#define NUM_FONTCACHES 120
#define NUM_MESGS 16
#define STRLEN 40
#define FONT_SIZE8 128
#define FONT_SIZE64 (FONT_SIZE8/8)
typedef struct {
uwlong data[FONT_SIZE64]; /* font data (16x16, 4bit) */
ushort sjis; /* Shift JIS code */
ushort dist; /* distance to next character */
uchar width; /* width of font */
uchar height; /* height of font */
short center; /* center of font */
} FontCache;
static FontCache fontCache[NUM_FONTCACHES]; /* font cache memory */
static int numfonts = 0; /* number of the fonts in cache */
static short degitData[10]; /* degit font list */
/********************************************************************************/
/* */
/* Message data. */
/* */
/********************************************************************************/
#ifdef JAPANESE
static short msgErrorNumber[] = {
0x8347, 0x8389, 0x815B, 0x8146, 0x0000,
};
static short msgReadManual1[] = { /* Toriatukaisetumeisyo Wo Oyomikudasai */
0x8EE6, 0x88B5, 0x90E0, 0x96BE, 0x8F91, 0x82F0, 0x82A8, 0x93C7, 0x82DD, 0x82AD,
0x82BE, 0x82B3, 0x82A2, 0x8142, 0x0000
};
static short msgReadManual2[] = { /* Kuwashiku Wa Toriatukaisetumeisyo Wo Oyomikudasai */
0x8FDA, 0x82B5, 0x82AD, 0x82CD, 0x8141, 0x8EE6, 0x88B5, 0x90E0, 0x96BE, 0x8F91,
0x82F0, 0x82A8, 0x93C7, 0x82DD, 0x82AD, 0x82BE, 0x82B3, 0x82A2, 0x8142, 0x0000
};
static short msgPressReset[] = { /* Risetto Suitti Wo Oshitekudasai */
0x838A, 0x835A, 0x8362, 0x8367, 0x8358, 0x8343, 0x8362, 0x8360, 0x82F0,
0x899F, 0x82B5, 0x82C4, 0x82AD, 0x82BE, 0x82B3, 0x82A2, 0x8142, 0x0000
};
static short msgNoEject1[] = { /* Cyuui Akusesu Ranpu Tenmetucyuu Ni */
0x928D, 0x88D3, 0x8140, 0x8341, 0x834E, 0x835A, 0x8358, 0x8389, 0x8393, 0x8376,
0x935F, 0x96C5, 0x9286, 0x82C9, 0x8140, 0x0000
};
static short msgNoEject2[] = { /* Dhisuku Wo Nukanaide Kudasai */
0x8366, 0x8342, 0x8358, 0x834E, 0x82F0, 0x94B2, 0x82A9, 0x82C8, 0x82A2, 0x82C5,
0x82AD, 0x82BE, 0x82B3, 0x82A2, 0x8142, 0x0000
};
static short msgMemoryError1[] = { /* Memori Kakucyou Pakku Ga Tadashiku */
0x8381, 0x8382, 0x838A, 0x815B, 0x8A67, 0x92A3, 0x8370, 0x8362, 0x834E, 0x82AA,
0x90B3, 0x82B5, 0x82AD, 0x0000
};
static short msgMemoryError2[] = { /* Sashikonde Arimasuka */
0x8DB7, 0x82B5, 0x8D9E, 0x82F1, 0x82C5, 0x82A0, 0x82E8, 0x82DC, 0x82B7, 0x82A9,
0x8148, 0x0000
};
static short msgClockError[] = { /* Jikoku Wo Settei Wo Okonattekudasai */
0x8E9E, 0x8D8F, 0x82F0, 0x90DD, 0x92E8, 0x82B5, 0x82C4, 0x82AD, 0x82BE, 0x82B3,
0x82A2, 0x8142, 0x0000
};
static short msgClockTitle[] = { /* Jikoku Settei */
0x8E9E, 0x8D8F, 0x90DD, 0x92E8, 0x0000
};
static short msgClockAdjust[] = { /* Settei: */
0x90DD, 0x92E8, 0x8146, 0x8F5C, 0x8E9A, 0x834C, 0x815B, 0x8141, 0x8252, 0x8263,
0x8358, 0x8365, 0x8342, 0x8362, 0x834E, 0x82CC, 0x8FE3, 0x89BA, 0x0000
};
static short msgClockSelect[] = { /* Idou: */
0x88DA, 0x93AE, 0x8146, 0x8F5C, 0x8E9A, 0x834C, 0x815B, 0x8141, 0x8252, 0x8263,
0x8358, 0x8365, 0x8342, 0x8362, 0x834E, 0x82CC, 0x8DB6, 0x8945, 0x0000
};
static short msgClockOk[] = { /* Kettei: */
0x8C88, 0x92E8, 0x8146, 0x8260, 0x837B, 0x835E, 0x8393, 0x8141, 0x8358, 0x835E,
0x815B, 0x8367, 0x837B, 0x835E, 0x8393, 0x0000
};
static short msgClockCancel[] = { /* Torikeshi: */
0x8EE6, 0x8FC1, 0x8146, 0x8261, 0x837B, 0x835E, 0x8393, 0x0000
};
static short msgClockContents[] = {
0x944E, 0x8C8E, 0x93FA, /* date 0 */
0x8C8E, 0x89CE, 0x9085, 0x96D8, 0x8BE0, 0x9379, 0x93FA, /* month 3 */
0x8CDF, 0x914F, 0x8CDF, 0x8CE3, 0x8E9E, 0x95AA, /* time 10 */
0x8169, 0x816A, 0x8146, 0x0000 /* mark 16 */
};
static short* messageTable[] = {
(short *)msgErrorNumber , (short *)msgReadManual1 , (short *)msgReadManual2 , (short *)msgPressReset ,
(short *)msgNoEject1 , (short *)msgNoEject2 , (short *)msgMemoryError1 , (short *)msgMemoryError2 ,
(short *)msgClockError , (short *)msgClockTitle , (short *)msgClockAdjust , (short *)msgClockSelect ,
(short *)msgClockOk , (short *)msgClockCancel , (short *)msgClockContents, (short *)NULL
};
#endif
#ifdef ENGLISH
static uchar msgErrorNumber[] = "^E^r^r^o^r^:\0";
static uchar msgReadManualA1[] = "_P_l_e_a_s_e_ _r_e_f_e_r_ _t_o_ _t_h_e_ _E_r_r_o_r_ _M_e_s_s_a_g_e\0";
static uchar msgReadManualA2[] = "_s_e_c_t_i_o_n_ _o_f_ _t_h_e_ _I_n_s_t_r_u_c_t_i_o_n_ _B_o_o_k_l_e_t_.\0";
static uchar msgReadManualB1[] = "_F_o_r_e_ _m_o_r_e_ _d_e_t_a_i_l_s_,_ _p_l_e_a_s_e_ _r_e_f_e_r\0";
static uchar msgReadManualB2[] = "_t_o_ _t_h_e_ _E_r_r_o_r_ _M_e_s_s_a_g_e_ _s_e_c_t_i_o_n_ _o_f\0";
static uchar msgReadManualB3[] = "_t_h_e_ _I_n_s_t_r_u_c_t_i_o_n_ _B_o_o_k_l_e_t_.\0";
static uchar msgPressReset[] = "_P_l_e_a_s_e_ _p_u_s_h_ _t_h_e_ _R_e_s_e_t_ _b_u_t_t_o_n_.\0";
static uchar msgNoEject1[] = "^N^O^T^E^:_ _D_o_ _n_o_t_ _r_e_m_o_v_e_ _t_h_e_ _D_i_s_k\0";
static uchar msgNoEject2[] = "_w_h_e_n_ _t_h_e_ _a_c_c_e_s_s_ _l_i_g_h_t_ _i_s_ _f_l_a_s_h_i_n_g_.\0";
static uchar msgMemoryError1[] = "_I_s_ _t_h_e_ _M_e_m_o_r_y_ _P_a_k_ _i_n_s_e_r_t_e_d\0";
static uchar msgMemoryError2[] = "_c_o_r_r_e_c_t_l_y_ _?\0";
static uchar msgClockError[] = "_P_l_e_a_s_e_ _s_e_t_ _t_h_e_ _t_i_m_e_ _a_n_d_ _d_a_t_e_.\0";
static uchar msgClockTitle[] = "^S^e^t^ ^t^i^m^e^ ^a^n^d^ ^d^a^t^e\0";
static uchar msgClockAdjust[] = "~C~H~A~N~G~E~:~ ~u~p~ ~o~r~ ~d~o~w~n~ ~o~n~ ~t~h~e~ \010\360~ ~C~o~n~t~r~o~l~ ~P~a~d~.\0";
static uchar msgClockSelect[] = "~S~E~L~E~C~T~:~ ~l~e~f~t~ ~o~r~ ~r~i~g~h~t~ ~o~n~ ~t~h~e~ \010\360~ ~C~o~n~t~r~o~l~ ~P~a~d~.\0";
static uchar msgClockOk[] = "~ ~ ~S~E~T~:~ _A~ ~b~u~t~t~o~n~ ~o~r~ ~S~T~A~R~T~.\0";
static uchar msgClockCancel[] = "~C~A~N~C~E~L~:~ _B~ ~b~u~t~t~o~n~.\0";
static uchar msgClockContents[] = "_M_o_n_T_u_e_W_e_d_T_h_u_F_r_i_S_a_t_S_u_n_a_p_m_._/_:_(_)\0";
static short* messageTable[] = {
(short *)msgErrorNumber , (short *)msgReadManualA1 , (short *)msgReadManualA2 , (short *)msgReadManualB1 ,
(short *)msgReadManualB2 , (short *)msgReadManualB3 , (short *)msgPressReset , (short *)msgNoEject1 ,
(short *)msgNoEject2 , (short *)msgMemoryError1 , (short *)msgMemoryError2 , (short *)msgClockError ,
(short *)msgClockTitle , (short *)msgClockAdjust , (short *)msgClockSelect , (short *)msgClockOk ,
(short *)msgClockCancel , (short *)msgClockContents , (short *)NULL
};
#endif
//////////////////////////////////////////////////////////////////////////////////
//
//
//
//
// Initialize error message.
//
//
//
//
//////////////////////////////////////////////////////////////////////////////////
/********************************************************************************/
/* */
/* Read a font data from ROM. */
/* */
/********************************************************************************/
static int
AdjustAsciiData(uchar *data, int width, int height)
{
if (width < 15) {
int colum = (width + 1) / 2;
int skip = 8 - colum;
uchar *bottom = data + colum * height;
uchar *expand = data + 8 * height;
while (height -- > 0) {
int cntx;
for (cntx = 0; cntx < skip; cntx++) {
*--expand = 0x00;
}
for (cntx = 0; cntx < colum; cntx++) {
*--expand = *--bottom;
}
}
}
}
/********************************************************************************/
/* */
/* Read a font data from ROM. */
/* */
/********************************************************************************/
static int
ReadAsciiData(ushort code)
{
OSIoMesg ioMesgBuf;
OSMesg message;
int width, height, center;
int fontid = numfonts;
ulong romAddr = (ulong )FONTDATA_ROMADDR + LeoGetAAdr(code, &width, &height, ¢er);
uchar * ramAddr = (uchar *)&fontCache[numfonts].data;
osInvalDCache(ramAddr, FONT_SIZE8);
/*
osPiStartDma(&ioMesgBuf, OS_MESG_PRI_NORMAL, OS_READ, romAddr, ramAddr, FONT_SIZE8, &DmaMesgque);
*/
osPiStartDma_DriveRomOnly(&ioMesgBuf, OS_MESG_PRI_NORMAL, OS_READ, romAddr, ramAddr, FONT_SIZE8, &DmaMesgque);
fontCache[numfonts].sjis = code;
fontCache[numfonts].dist = width+1;
fontCache[numfonts].width = (width < 16) ? width+1 : width;
fontCache[numfonts].height = height;
fontCache[numfonts].center = center-12;
numfonts += 1;
osRecvMesg(&DmaMesgque, &message, OS_MESG_BLOCK);
AdjustAsciiData(ramAddr, width, height);
return(fontid);
}
/********************************************************************************/
/* */
/* Read a font data from ROM. */
/* */
/********************************************************************************/
static int
ReadKanjiData(ushort sjis, ushort dist)
{
OSIoMesg ioMesgBuf;
OSMesg message;
int fontid = numfonts;
ulong romAddr = (ulong )FONTDATA_ROMADDR + LeoGetKAdr(sjis);
uchar * ramAddr = (uchar *)&fontCache[numfonts].data;
osInvalDCache(ramAddr, FONT_SIZE8);
/*
osPiStartDma(&ioMesgBuf, OS_MESG_PRI_NORMAL, OS_READ, romAddr, ramAddr, FONT_SIZE8, &DmaMesgque);
*/
osPiStartDma_DriveRomOnly(&ioMesgBuf, OS_MESG_PRI_NORMAL, OS_READ, romAddr, ramAddr, FONT_SIZE8, &DmaMesgque);
fontCache[numfonts].sjis = sjis;
fontCache[numfonts].dist = dist;
fontCache[numfonts].width = 16;
fontCache[numfonts].height = 16;
fontCache[numfonts].center = 0;
numfonts += 1;
osRecvMesg(&DmaMesgque, &message, OS_MESG_BLOCK);
return(fontid);
}
/********************************************************************************/
/* */
/* Find a font data from the font cache. */
/* */
/********************************************************************************/
static int
FindFontData(ushort sjis, ushort dist)
{
int index;
int ascii = sjis >> 8;
if (ascii == '^') sjis = (sjis & 0x00ff) - 0x20 + 0x0540;
if (ascii == '~') sjis = (sjis & 0x00ff) - 0x20 + 0x06C0;
if (ascii == '_') sjis = (sjis & 0x00ff) - 0x20 + 0x0480;
for (index = 0; index < numfonts; index++) {
if (fontCache[index].sjis == sjis) return(index);
}
if (sjis < 0x8000) index = ReadAsciiData(sjis );
else index = ReadKanjiData(sjis, dist);
return(index);
}
/********************************************************************************/
/* */
/* Initialize message data. */
/* */
/********************************************************************************/
extern void
InitErrorMessage(void)
{
int index;
short *message;
osCreateMesgQueue(&DmaMesgque, DmaMesgbuf, NUM_DMA_MESGS);
for (index = 0; (message = messageTable[index]) != NULL; index++) {
while (*message != 0x0000) {
*message = FindFontData((ushort)*message, 14);
message++;
}
*message = -1;
}
for (index = 0; index < 10; index++) {
degitData[index] = ReadKanjiData(0x824f+index, 10);
}
// osSyncPrintf("font cache = %d\n", numfonts);
}
//////////////////////////////////////////////////////////////////////////////////
//
//
//
//
// Draw error message.
//
//
//
//
//////////////////////////////////////////////////////////////////////////////////
/********************************************************************************/
/* */
/* Centering */
/* */
/********************************************************************************/
static int
Centering(int posx, void *message)
{
int length = 0;
short * string = (short *)message;
while (*string >= 0) {
length += fontCache[*string++].dist;
}
return(posx - length / 2);
}
/********************************************************************************/
/* */
/* Open message window */
/* */
/********************************************************************************/
static void
OpenMessageWindow(int left, int top, int right, int bottom)
{
gSPDisplayList(graphicp++, Gfx_BeginWindow);
gSPTextureRectangle(graphicp++, left*4, top*4, right*4, bottom*4, G_TX_RENDERTILE, 0, 0, 1024, 1024);
gSPDisplayList(graphicp++, Gfx_EndWindow);
}
/********************************************************************************/
/* */
/* Draw a font texture */
/* */
/********************************************************************************/
static void
DrawMessageTexture(short posx, short posy, short code)
{
FontCache *font = &fontCache[code];
short left = (posx ) * 4;
short right = (posx + font->width ) * 4;
short top = (posy - font->center ) * 4;
short bottom = (posy - font->center + font->height) * 4;
gDPLoadTextureBlock_4b(graphicp++, font->data, G_IM_FMT_I, 16, font->height, 0,
G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD
);
gSPTextureRectangle(graphicp++, left, top, right, bottom, G_TX_RENDERTILE, 0, 0, 1024, 1024);
}
/********************************************************************************/
/* */
/* Draw string */
/* */
/********************************************************************************/
static void
DrawString(int posx, int posy, void *message)
{
short *string = (short *)message;
while (*string != -1) {
if (*string >= 0) {
DrawMessageTexture(posx, posy, *string);
posx += fontCache[*string++].dist;
} else {
posx -= *string++;
}
}
}
/********************************************************************************/
/* */
/* Draw number (Max == 99) */
/* */
/********************************************************************************/
static void
DrawNumber(int posx, int posy, int number)
{
short font1 = degitData[number / 10];
short font2 = degitData[number % 10];
DrawMessageTexture(posx, posy, font1);
posx += fontCache[font1].dist;
DrawMessageTexture(posx, posy, font2);
}
/********************************************************************************/
/* */
/* Set number */
/* */
/********************************************************************************/
static void
SetNumber(short *buffer, int number, int zeroflag)
{
short font1 = degitData[number / 10];
short font2 = degitData[number % 10];
if (!zeroflag && ((number/10) == 0)) font1 = -10;
*buffer++ = font1;
*buffer++ = font2;
}
/********************************************************************************/
/* */
/* Draw error */
/* */
/********************************************************************************/
#ifdef JAPANESE
#define ERROR_NUMBER_POSH 88
#endif
#ifdef ENGLISH
#define ERROR_NUMBER_POSH 74
#endif
static void
DrawErrorNo(int errorNo)
{
DrawString(35, 75, (short *)msgErrorNumber);
DrawNumber(ERROR_NUMBER_POSH, 75, errorNo);
}
/********************************************************************************/
/* */
/* Draw message */
/* */
/********************************************************************************/
static void
DrawMessage(int posx, int posy, void *message)
{
DrawString(Centering(posx, message), posy, message);
}
/********************************************************************************/
/* */
/* Draw error message. */
/* */
/********************************************************************************/
#ifdef JAPANESE
extern void
DrawErrorMessage(int status)
{
static int drawing = 0;
if (status == 0) {
drawing = 0;
} else {
if (status != drawing) {
Nacp_SeStart(NACP_ERROR);
drawing = status;
}
switch (status & ERRMSG_KINDMASK) {
case ERRMSG_NOCONNECT: OpenMessageWindow(25, 70, 295, 170);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(41);
DrawMessage(160, 105, msgReadManual1);
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_NORAMPACK: OpenMessageWindow(25, 70, 295, 170);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(44);
DrawMessage(160, 100, msgMemoryError1);
DrawMessage(160, 120, msgMemoryError2);
DrawMessage(165, 145, msgReadManual2 );
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_CLOCKSTOP: OpenMessageWindow(25, 70, 295, 170);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(48);
DrawMessage(160, 105, msgClockError );
DrawMessage(165, 145, msgReadManual2);
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_BADINSERT: OpenMessageWindow(25, 70, 295, 170);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(50);
DrawMessage(160, 105, msgReadManual1);
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_DISKEJECT: OpenMessageWindow(25, 70, 295, 170);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(51);
DrawMessage(160, 95, msgPressReset );
DrawMessage(165, 148, msgReadManual2);
gDPSetEnvColor(graphicp++, 255,120,80,255);
DrawMessage(160, 114, msgNoEject1 );
DrawMessage(160, 130, msgNoEject2 );
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_DISKERROR: OpenMessageWindow(25, 70, 295, 170);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(status & ERRMSG_NUMMASK);
DrawMessage(160, 105, msgReadManual1);
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
}
}
}
#endif
#ifdef ENGLISH
extern void
DrawErrorMessage(int status)
{
static int drawing = 0;
if (status == 0) {
drawing = 0;
} else {
if (status != drawing) {
Nacp_SeStart(NACP_ERROR);
drawing = status;
}
switch (status & ERRMSG_KINDMASK) {
case ERRMSG_NOCONNECT: OpenMessageWindow(25, 70, 295, 170);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(41);
DrawMessage(160, 105, msgReadManualA1);
DrawMessage(160, 125, msgReadManualA2);
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_NORAMPACK: OpenMessageWindow(25, 70, 295, 200);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(44);
DrawMessage(160, 100, msgMemoryError1);
DrawMessage(160, 120, msgMemoryError2);
DrawMessage(165, 144, msgReadManualB1);
DrawMessage(165, 160, msgReadManualB2);
DrawMessage(165, 176, msgReadManualB3);
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_CLOCKSTOP: OpenMessageWindow(25, 70, 295, 190);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(48);
DrawMessage(160, 105, msgClockError );
DrawMessage(165, 134, msgReadManualB1);
DrawMessage(165, 150, msgReadManualB2);
DrawMessage(165, 166, msgReadManualB3);
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_BADINSERT: OpenMessageWindow(25, 70, 295, 170);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(50);
DrawMessage(160, 105, msgReadManualA1);
DrawMessage(160, 125, msgReadManualA2);
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_DISKEJECT: OpenMessageWindow(25, 70, 295, 200);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(51);
DrawMessage(160, 95, msgPressReset );
DrawMessage(165, 148, msgReadManualB1);
DrawMessage(165, 164, msgReadManualB2);
DrawMessage(165, 180, msgReadManualB3);
gDPSetEnvColor(graphicp++, 255,120,80,255);
DrawMessage(160, 114, msgNoEject1 );
DrawMessage(160, 130, msgNoEject2 );
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
case ERRMSG_DISKERROR: OpenMessageWindow(25, 70, 295, 170);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawErrorNo(status & ERRMSG_NUMMASK);
DrawMessage(160, 105, msgReadManualA1);
DrawMessage(160, 125, msgReadManualA2);
gSPDisplayList(graphicp++, Gfx_EndKanji);
break;
}
}
}
#endif
//////////////////////////////////////////////////////////////////////////////////
//
//
//
//
// Draw the clock setting screen
//
//
//
//
//////////////////////////////////////////////////////////////////////////////////
#if JAPANESE
/********************************************************************************/
/* */
/* Draw string */
/* */
/********************************************************************************/
static void
DrawDate(int posx, int posy, short year, short month, short day, short week, short blink)
{
short date[20];
SetNumber(&date[ 0], year/100, TRUE);
SetNumber(&date[ 2], year%100, TRUE);
SetNumber(&date[ 7], month , FALSE);
SetNumber(&date[12], day , FALSE);
date[ 4] = -3;
date[ 5] = msgClockContents[ 0];
date[ 6] = -6;
date[ 9] = -3;
date[10] = msgClockContents[ 1];
date[11] = -6;
date[14] = -3;
date[15] = msgClockContents[ 2];
date[16] = msgClockContents[16];
date[17] = msgClockContents[3+week];
date[18] = msgClockContents[17];
date[19] = -1;
switch (blink) {
case 1: date[0] = date[1] = date[2] = date[3] = -10;
break;
case 2: date[7] = date[8] = -10;
break;
case 3: date[12] = date[13] = -10;
date[17] = -14;
break;
}
DrawString(posx, posy, date);
}
/********************************************************************************/
/* */
/* Draw string */
/* */
/********************************************************************************/
static void
DrawTime(int posx, int posy, short hour, short minute, short blink)
{
short date[13];
int noon = 0;
if (hour >= 12) {
noon = 2;
hour -= 12;
}
SetNumber(&date[3], hour , FALSE);
SetNumber(&date[8], minute, TRUE);
date[ 0] = msgClockContents[10+noon];
date[ 1] = msgClockContents[11+noon];
date[ 2] = -6;
date[ 5] = -3;
date[ 6] = msgClockContents[14];
date[ 7] = -6;
date[10] = -3;
date[11] = msgClockContents[15];
date[12] = -1;
switch (blink) {
case 4: date[0] = date[1] = -14;
date[3] = date[4] = -10;
break;
case 5: date[8] = date[9] = -10;
break;
}
DrawString(posx, posy, date);
}
/********************************************************************************/
/* */
/* Draw error message. */
/* */
/********************************************************************************/
extern void
DrawClockSetting(ClockInfo *clock)
{
int blink = (clock->blink < 6) ? clock->cursor : 0;
clock->blink = (clock->blink + 1) % 20;
OpenMessageWindow(25, 65, 295, 210);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawString(Centering(160, msgClockTitle), 70, msgClockTitle );
DrawString( 35, 140, msgClockAdjust);
DrawString( 35, 156, msgClockSelect);
DrawString( 35, 172, msgClockOk );
DrawString( 35, 188, msgClockCancel);
DrawDate(70, 95, 1900+clock->year, clock->month, clock->day, clock->week, blink);
DrawTime(99, 115, clock->hour, clock->minute, blink);
gSPDisplayList(graphicp++, Gfx_EndKanji);
}
#endif
#ifdef ENGLISH
/********************************************************************************/
/* */
/* Draw string */
/* */
/********************************************************************************/
static void
DrawDate(int posx, int posy, short year, short month, short day, short week, short blink)
{
short date[19];
short * character = (short *)msgClockContents;
SetNumber(&date[ 0], month , FALSE);
SetNumber(&date[ 4], day , FALSE);
SetNumber(&date[ 8], year/100, TRUE);
SetNumber(&date[10], year%100, TRUE);
date[ 2] = -6;
date[ 3] = character[25];
date[ 6] = -6;
date[ 7] = character[25];
date[12] = -6;
date[13] = character[27];
date[14] = character[week*3+0];
date[15] = character[week*3+1];
date[16] = character[week*3+2];
date[17] = character[28];
date[18] = -1;
switch (blink) {
case 1: date[8] = date[9] = date[10] = date[11] = -10;
break;
case 2: date[0] = date[1] = -10;
break;
case 3: date[4] = date[5] = -10;
date[12] = -1;
break;
}
DrawString(posx, posy, date);
}
/********************************************************************************/
/* */
/* Draw string */
/* */
/********************************************************************************/
static void
DrawTime(int posx, int posy, short hour, short minute, short blink)
{
short date[12];
short * character = (short *)msgClockContents;
int noon = 0;
if (hour >= 12) {
noon = 1;
hour -= 12;
}
SetNumber(&date[0], hour , FALSE);
SetNumber(&date[4], minute, TRUE);
date[ 2] = -6;
date[ 3] = character[26];
date[ 6] = -5;
date[ 7] = character[21+noon];
date[ 8] = character[24];
date[ 9] = character[23];
date[10] = character[24];
date[11] = -1;
switch (blink) {
case 4: date[ 0] = date[ 1] = -10;
date[ 7] = -1;
break;
case 5: date[4] = date[5] = -10;
break;
}
DrawString(posx, posy, date);
}
/********************************************************************************/
/* */
/* Draw error message. */
/* */
/********************************************************************************/
extern void
DrawClockSetting(ClockInfo *clock)
{
int blink = (clock->blink < 6) ? clock->cursor : 0;
clock->blink = (clock->blink + 1) % 20;
OpenMessageWindow(25, 65, 295, 210);
gSPDisplayList(graphicp++, Gfx_BeginKanji);
DrawString(Centering(160, msgClockTitle), 70, msgClockTitle );
DrawString( 36, 139, msgClockAdjust);
DrawString( 35, 156, msgClockSelect);
DrawString( 39, 173, msgClockOk );
DrawString( 33, 190, msgClockCancel);
DrawDate( 75, 95, 1900+clock->year, clock->month, clock->day, clock->week, blink);
DrawTime(110, 115, clock->hour, clock->minute, blink);
gSPDisplayList(graphicp++, Gfx_EndKanji);
}
#endif
//////////////////////////////////////////////////////////////////////////////////
//
//
//
//
// Draw the clock
//
//
//
//
//////////////////////////////////////////////////////////////////////////////////
/********************************************************************************/
/* */
/* Draw a font texture */
/* */
/********************************************************************************/
static void
DrawClockChr(short posx, short posy, short width, short height, uchar *texture)
{
short left = (posx ) * 4;
short right = (posx+width ) * 4;
short top = (posy ) * 4;
short bottom = (posy+height) * 4;
short sizeh = (width + 15) & 0xfff0;
gDPLoadTextureBlock_4b(graphicp++, texture, G_IM_FMT_I, sizeh, height, 0,
G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD
);
gSPTextureRectangle(graphicp++, left, top, right, bottom, G_TX_RENDERTILE, 0, 0, 1024, 1024);
}
/********************************************************************************/
/* */
/* Draw a font texture */
/* */
/********************************************************************************/
static void
DrawClockNum(short posx, short posy, int number, int zeroflag)
{
uchar *font1 = TexClockDigit[number / 10];
uchar *font2 = TexClockDigit[number % 10];
if (zeroflag || ((number/10) != 0)) {
DrawClockChr(posx, posy, 12, 12, font1);
}
DrawClockChr(posx+8, posy, 12, 12, font2);
}
/********************************************************************************/
/* */
/* Draw clock */
/* */
/********************************************************************************/
#ifdef JAPANESE
extern void
DrawClock(int posx, int posy, short month, short day, short week, short hour, short minute, short second, short alpha)
{
static short oldsec = 0;
static short blink = 0;
if (second != oldsec) {
oldsec = second;
blink = 50;
}
gSPDisplayList(graphicp++, Gfx_BeginKanji);
// gDPSetEnvColor(graphicp++, 82,75,152,255);
// gDPSetEnvColor(graphicp++,80,160,255,128);
if (blink == 0) {
gDPSetEnvColor(graphicp++,100,100,100, (alpha < 128) ? alpha : 128);
} else {
gDPSetEnvColor(graphicp++,100,100,100, alpha);
}
DrawClockNum(posx+ 0, posy, month, FALSE );
DrawClockChr(posx+18, posy, 12, 12, ClockMon );
DrawClockNum(posx+28, posy, day, FALSE );
DrawClockChr(posx+46, posy, 12, 12, ClockSun );
DrawClockChr(posx+52, posy, 12, 12, ClockBracket1 );
DrawClockChr(posx+62, posy, 12, 12, TexClockWeek[week] );
DrawClockChr(posx+72, posy, 12, 12, ClockBracket2 );
if (hour >= 12) {
DrawClockChr(posx+ 86, posy , 12, 12, ClockNoon );
DrawClockChr(posx+ 98, posy , 12, 12, ClockAfter );
DrawClockNum(posx+110, posy+1, hour-12, FALSE );
} else {
DrawClockChr(posx+ 86, posy , 12, 12, ClockNoon );
DrawClockChr(posx+ 98, posy , 12, 12, ClockBefore );
DrawClockNum(posx+110, posy+1, hour, FALSE );
}
if (blink > 30) DrawClockChr(posx+124, posy+1, 12, 12, ClockColon);
if (blink > 0) blink -= 1;
DrawClockNum(posx+130, posy+1, minute, TRUE);
gSPDisplayList(graphicp++, Gfx_EndKanji);
}
#endif
#ifdef ENGLISH
extern void
DrawClock(int posx, int posy, short month, short day, short week, short hour, short minute, short second, short alpha)
{
static short oldsec = 0;
static short blink = 0;
if (second != oldsec) {
oldsec = second;
blink = 50;
}
gSPDisplayList(graphicp++, Gfx_BeginKanji);
if (blink == 0) {
gDPSetEnvColor(graphicp++,100,100,100, (alpha < 128) ? alpha : 128);
} else {
gDPSetEnvColor(graphicp++,100,100,100, alpha);
}
DrawClockNum(posx+ 0, posy, month, FALSE );
DrawClockChr(posx+18, posy, 12, 12, ClockSlash );
DrawClockNum(posx+26, posy, day , FALSE );
DrawClockChr(posx+42, posy-1, 12, 12, ClockBracket1 );
DrawClockChr(posx+52, posy+0, 27, 10, TexClockWeek[week]);
DrawClockChr(posx+76, posy-1, 12, 12, ClockBracket2 );
if (hour >= 12) {
DrawClockNum(posx+ 82, posy+0, hour-12, FALSE );
DrawClockChr(posx+122, posy+4, 25, 9, ClockAfter);
} else {
DrawClockNum(posx+ 82, posy+0, hour, FALSE );
DrawClockChr(posx+122, posy+4, 25, 9, ClockBefore);
}
if (blink > 30) DrawClockChr(posx+96, posy+0, 12, 12, ClockColon);
if (blink > 0) blink -= 1;
DrawClockNum(posx+102, posy+0, minute, TRUE);
gSPDisplayList(graphicp++, Gfx_EndKanji);
}
#endif