forked from catmirrors/xlvns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoheart.c
1775 lines (1599 loc) · 45.2 KB
/
toheart.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
/*
* LEAF Visual Novel System For X
* (c) Copyright 1999,2000 Go Watanabe mailto:go@denpa.org
* All rights reserverd.
*
* ORIGINAL LVNS (c) Copyright 1996-1999 LEAF/AQUAPLUS Inc.
*
* $Id: toheart.c,v 1.49 2001/08/11 19:59:36 tf Exp $
*
*/
/*
* To Heart シナリオ処理エンジン
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "toheart.h"
/* 時計アニメーション */
static LvnsAnimationData clock_anim[] = {
{ LVNS_ANIM_IMAGE_ADD, "OC_00.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_01.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_02.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_03.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_04.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_05.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_06.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_07.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_08.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_09.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_10.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_11.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_12.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_13.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_14.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_15.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_16.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_17.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_18.LF2", 0, 160, 0 },
{ LVNS_ANIM_IMAGE_ADD, "OC_19.LF2", 0, 160, 0 },
{ LVNS_ANIM_NONE }
};
static struct {
const char *name;
LvnsImage *image;
} calendar_data[] = {
{ "CBAK.LF2" },
{ "CBAK_00.LF2"},
{ "CBAK_01.LF2"},
{ "CBAK_02.LF2"},
{ "CBAK_03.LF2"},
{ "CBAK_04.LF2"},
{ "CBAK_05.LF2"},
};
/* カレンダーアニメーション */
static LvnsAnimationData calendar_anim[] = {
/* 前日 */
{ LVNS_ANIM_IMAGE, NULL, 0, 0, 0}, /* 背景 */
{ LVNS_ANIM_IMAGE_ADD, NULL, 10, 192, 80 },
{ LVNS_ANIM_IMAGE_ADD, NULL, 10, 192, 80 },
{ LVNS_ANIM_IMAGE_ADD, NULL, 10, 192, 80 },
{ LVNS_ANIM_IMAGE_ADD, NULL, 10, 192, 56 },
{ LVNS_ANIM_IMAGE_ADD, NULL, 10, 192, 24 },
{ LVNS_ANIM_IMAGE_ADD, NULL, 10, 192, 24 },
{ LVNS_ANIM_IMAGE_ADD, "CBAK_06.LF2", 10, 440, 24 },
{ LVNS_ANIM_IMAGE_ADD, "CBAK_07.LF2", 10, 584, 24 },
{ LVNS_ANIM_WAIT, NULL, 300 },
{ LVNS_ANIM_NONE }
};
/**
* 名前データ
*/
static u_char names[][14] = {
"藤田",
"浩之",
"ヒロ",
"ひろゆき",
"ヒロユキ"
};
u_char *posstr[] = {
"左",
"右",
"中央"
};
char *
FlgName(int c)
{
static char foo[10];
switch (c) {
case 0x00:
return "<一時イベントビット>";
case 0x01:
return "<あかりイベントビット>";
case 0x02:
return "<芹香イベントビット>";
case 0x03:
return "<智子イベントビット>";
case 0x04:
return "<志保イベントビット?>";
case 0x06:
return "<マルチイベントビット?>";
case 0x08:
return "<レミィイベントフラグ>";
case 0x09:
return "<レミィイベントカウンタ2?>";
case 0x0c:
return "<志保イベントビット>";
case 0x0d:
return "<あかりvsイベントフラグ>";
case 0x0e:
return "<レミィ必須イベントフラグ>";
case 0x0f:
return "<その他vsイベントフラグ>";
case 0x11:
return "理緒イベントビット";
case 0x20:
return "<智子イベント通過>";
case 0x14:
return "<あかり好感度>";
case 0x15:
return "<芹香好感度>";
case 0x16:
return "<智子好感度>";
case 0x17:
return "<志保好感度>";
case 0x18:
return "<葵好感度>";
case 0x19:
return "<マルチ好感度>";
case 0x1a:
return "<琴音好感度>";
case 0x1b:
return "<レミィ好感度>";
case 0x1d:
return "<理緒好感度>";
case 0x1e:
return "<あかり回数イベント>";
case 0x1f:
return "<芹香回数イベント>";
case 0x22:
return "<葵回数イベント>";
case 0x23:
return "<マルチ回数イベント>";
case 0x24:
return "<琴音回数イベント>";
case 0x27:
return "<理緒イベントカウンタ>";
case 0x29:
return "<芹香イベントカウンタ>";
case 0x2a:
return "<智子イベントカウンタ>";
case 0x2c:
return "<葵イベントカウンタ>";
case 0x2d:
return "<マルチイベントカウンタ>";
case 0x2e:
return "<琴音イベントカウンタ>";
case 0x2f:
return "<レミィイベントカウンタ>";
case 0x33:
return "<芹香イベントカウンタ2>";
case 0x34:
return "<智子イベントカウンタ2>";
case 0x35:
return "<葵イベントカウンタ2>";
case 0x37:
return "<マルチイベントカウンタ2>";
case 0x38:
return "<琴音イベントカウンタ2>";
case 0x39:
return "<レミィイベントカウンタ2>";
case 0x3b:
return "<理緒イベントカウンタ>";
case 0x3e:
return "<智子イベントカウンタ3>";
case 0x42:
return "<琴音イベントカウンタ3>";
case 0x4c:
return "<琴音イベントカウンタ4>";
case 0x50:
return "<エンディングフラグ1>";
case 0x51:
return "<エンディングフラグ2>";
case 0xa6:
return "<その日の行動用フラグ?>";
case 0xab:
return "<日付カウンタ>";
case 0xac:
return "<放課後移動位置フラグ>?";
case 0xad:
return "<曜日カウンタ>";
case 0xae:
return "<時間カウンタ>";
case 0xaf:
return "<放課後移動量カウンタ>?";
}
sprintf(foo, "flg:%02x", c);
return foo;
}
char *
FlgBit(int flg, int c)
{
static char foo[10];
switch (flg) {
case 0x00:
switch (c) {
case 2: return "<授業中助けてくれたお礼を屋上で>";
case 6:
return "<琴音ちゃんと出会う>";
}
case 0x01:
switch (c) {
case 0:
return "<髪型変更>";
case 1:
return "<試験勉強>";
case 2:
return "<修学旅行相談>";
case 3:
return "<風邪引き中>";
}
break;
case 0x02:
switch (c) {
case 0:
return "<4/1の降霊会>";
case 1:
return "<4/1の降霊会のお詫び>";
}
case 0x04:
switch (c) {
case 0:
return "<補習を受ける>";
case 1:
return "<カラオケで勝つ>";
}
case 0x06:
switch (c) {
case 0:
return "<卒業式を迎える>";
}
case 0x08:
switch (c) {
case 0:
return "<ハンターイベント1>";
case 1:
return "<ハンターイベント2>";
case 2:
return "<デート約束>";
case 3:
return "<デート>";
case 4:
return "<レミィ姉が来ることを聞く>";
case 5:
return "<初恋イベント>";
case 6:
return "<レミィと迷子を捜す>";
}
case 0x0c:
switch (c) {
case 0:
return "<中庭でパンツ見る>";
case 1:
return "<個人情報誌>";
case 2:
return "<橋本先輩>";
case 3:
return "<ゲーセンで勝負約束>";
case 4:
return "<ゲーセンで勝負>";
case 5:
return "<ゲーセンで勝負2>";
case 6:
return "<二人でカラオケ>";
}
case 0x0d:
switch (c) {
case 0:
return "<vs智子>";
case 1:
return "<vsレミィ>";
case 2:
return "<vs葵>";
case 3:
return "<vs琴音>";
case 4:
return "<vs志保>";
}
break;
case 0x0e:
switch (c) {
case 0:
return "<初恋イベント>";
case 1:
return "<弓道部イベント>";
case 2:
return "<レミィと迷子を捜す>";
case 3:
return "<レミィ姉と会う>";
case 4:
return "<転校するので元気がないレミィに会う>";
}
case 0x0f:
switch (c) {
case 0:
return "<葵vs琴音>";
case 1:
return "<智子vs志保>";
case 2:
return "<芹香vsマルチ>";
case 3:
return "<マルチvsレミィ>";
}
case 0x50:
switch (c) {
case 0:
return "<あかりエンド>";
case 1:
return "<芹香エンド>";
case 2:
return "<智子エンド>";
case 3:
return "<志保エンド>";
case 4:
return "<葵エンド>";
case 5:
return "<マルチエンド>";
case 6:
return "<琴音エンド>";
case 7:
return "<レミィエンド>";
}
case 0x51:
switch (c) {
case 0:
return "<雅史エンド>";
case 1:
return "<理緒エンド>";
case 7:
return "<おまけシナリオ>";
}
}
sprintf(foo, "%d", c);
return foo;
}
/**
* エフェクトパラメータ変換
*/
static LvnsEffectType
text_effect(int no)
{
static LvnsEffectType toheart_effect[] = {
LVNS_EFFECT_FADE_PALETTE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_FADE_MASK,
LVNS_EFFECT_FADE_SQUARE,
LVNS_EFFECT_WIPE_SQUARE_LTOR,
LVNS_EFFECT_FADE_MASK,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_WIPE_MASK_LTOR,
LVNS_EFFECT_SLIDE_LTOR,
LVNS_EFFECT_WIPE_LTOR,
LVNS_EFFECT_NO_EFFECT,
LVNS_EFFECT_FADE_MASK,
LVNS_EFFECT_NONE,
LVNS_EFFECT_TOP_SCROLL,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_BLOOD,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_NONE,
LVNS_EFFECT_FADE_PALETTE
};
LvnsEffectType ret;
if (no == 255) {
ret = LVNS_EFFECT_NONE;
} else {
ret = toheart_effect[no];
}
dprintf((stderr, "(%2d)%s\n", no, LvnsEffectName(ret)));
return ret;
}
/*
* bgm パラメータ変換
*/
static int
bgmmap(int no)
{
switch (no) {
case 27:
return 31;
case 28:
return 32;
case 29:
return 33;
case 30:
return 34;
case 31:
return 35;
case 32:
return 29; /* ??? */
case 33:
return 30;
default:
return no+2;
}
}
/* ---------------------------------------------------------------- */
/* カレンダー処理 */
static void
init_calendar(Lvns *lvns)
{
int i;
for (i=0; i< sizeof calendar_data / sizeof calendar_data[0]; i++) {
lvnsimage_copy(calendar_data[i].image,
calendar_anim[i].image);
}
}
static void
set_calendar(Lvns *lvns, int day, int trans)
{
char name[20];
int i, col, mon, weekday;
LvnsImage *week;
LvnsImage *month;
LvnsImage *day1;
LvnsImage *day2;
weekday = (day + 5) % 7;
/* 今日 */
if (weekday == 0) { /* 日曜 */
col = 1;
} else if (weekday == 6) { /* 土曜 */
col = 2;
} else { /* 平日 */
col = 0;
}
if (day <= 31) {
mon = 3;
} else if (day <= 61) {
mon = 4;
day -= 31;
} else {
mon = 5;
day -= 61;
}
snprintf(name, sizeof name, "CWEEK_%02d.LF2", weekday);
week = LvnsLoadImage(lvns, name, NULL);
snprintf(name, sizeof name, "CMON_%02d.LF2", mon);
month = LvnsLoadImage(lvns, name, NULL);
#if 0
dprintf((stderr, "day: %d\n", day));
#endif
if (day <= 9) {
snprintf(name, sizeof name, "CLNO_%02d.LF2", day);
day1 = NULL;
day2 = LvnsLoadImage(lvns, name, NULL);
} else {
snprintf(name, sizeof name, "CSNO_%02d.LF2", day / 10);
day1 = LvnsLoadImage(lvns, name, NULL);
snprintf(name, sizeof name, "CSNO_%02d.LF2", day % 10);
day2 = LvnsLoadImage(lvns, name, NULL);
}
/* 画像合成 */
for (i=0; i< sizeof calendar_data / sizeof calendar_data[0]; i++) {
if (day1) {
lvnsimage_add3(day1, calendar_anim[i].image,
232-calendar_anim[i].x,
196-calendar_anim[i].y,
col * 26,
trans, i);
lvnsimage_add3(day2, calendar_anim[i].image,
320-calendar_anim[i].x,
196-calendar_anim[i].y,
col * 26,
trans, i);
} else {
lvnsimage_add3(day2, calendar_anim[i].image,
264-calendar_anim[i].x,
196-calendar_anim[i].y,
col * 26,
trans, i);
}
lvnsimage_add3(week, calendar_anim[i].image,
280-calendar_anim[i].x,
344-calendar_anim[i].y,
col * 26,
trans, i);
lvnsimage_add3(month, calendar_anim[i].image,
200-calendar_anim[i].x,
88-calendar_anim[i].y,
col * 26,
trans, i);
}
lvnsimage_delete(week);
lvnsimage_delete(month);
lvnsimage_delete(day1);
lvnsimage_delete(day2);
}
/*
* カレンダー表示
* 拡大サイズ→通常→日めくり→拡大
*/
static Bool
calendar(Lvns *lvns, int *effect_state)
{
ToHeartState *state = (ToHeartState *)lvns->system_state;
if (*effect_state < 16) {
double ratio = (16 - *effect_state) / 4.0 + 1.0;
int width = WIDTH * ratio;
int height = HEIGHT * ratio;
lvnsimage_copy_palette(calendar_anim[0].image, lvns->vram);
lvnsimage_copy_scale(calendar_anim[0].image, 0, 0,
calendar_anim[0].image->rwidth,
calendar_anim[0].image->rheight,
lvns->vram,
-(width-WIDTH)/2,
-(height-HEIGHT)/2,
width, height);
lvns->setPaletteMulti(lvns, *effect_state);
lvns->drawWindow(lvns);
lvns->flushWindow(lvns);
(*effect_state)++;
return False;
} else if (*effect_state == 16) {
if (state->flag[TOHEART_FLAG_DATE] == state->calendar_day) {
state->flag[TOHEART_FLAG_WEEKDAY] =
(state->flag[TOHEART_FLAG_DATE] + 5) % 7;
lvnsimage_copy(lvns->vram, lvns->background);
(*effect_state)++;
} else {
init_calendar(lvns);
set_calendar(lvns, state->flag[TOHEART_FLAG_DATE]++, 209);
set_calendar(lvns, state->flag[TOHEART_FLAG_DATE], 211);
// lvns->anim_data = calendar_anim;
}
return False;
} else if (!state->fast_calendar && *effect_state <= 32) {
int st = 32 - *effect_state;
double ratio = (16 - st) / 4.0 + 1.0;
int width = WIDTH * ratio;
int height = HEIGHT * ratio;
lvnsimage_copy_palette(lvns->background, lvns->vram);
lvnsimage_copy_scale(lvns->background, 0, 0,
lvns->background->rwidth,
lvns->background->rheight,
lvns->vram,
-(width-WIDTH)/2,
-(height-HEIGHT)/2,
width, height);
lvns->setPaletteMulti(lvns, st);
lvns->drawWindow(lvns);
lvns->flushWindow(lvns);
(*effect_state)++;
return False;
} else {
lvnsimage_clear(lvns->background);
return True;
}
}
/* ---------------------------------------------------------------- */
/**
* シナリオ初期化
*/
void
ToHeartScenarioInit(Lvns *lvns)
{
ToHeartState *state = (ToHeartState *)lvns->system_state;
int i;
/* セーブ状態状態初期化 */
LvnsInitSavePoint(lvns, &lvns->savepoint);
for (i=0; i<TOHEART_FLAG_NO; i++) {
state->flag_save[i] = 0;
}
state->flag_save[TOHEART_FLAG_DATE] = 3;
state->flag_save[TOHEART_FLAG_WEEKDAY] =
(state->flag_save[TOHEART_FLAG_DATE] + 5) % 7;
}
/**
* しおり初期化 (全フラグ消去)
* ToHeartは全しおりを同時に初期化する
*/
void
ToHeartSioriInit(Lvns *lvns)
{
ToHeartState *state = (ToHeartState *)lvns->system_state;
int i;
/* シナリオデータ初期化 */
ToHeartScenarioInit(lvns);
/* 未見フラグ全消去 */
for (i=0;i<sizeof state->seen_flag / sizeof state->seen_flag[0];i++) {
state->seen_flag[i] = 0;
}
/* 残りの制御フラグの消去 */
}
static void TextParser(Lvns *lvns, int no, Bool history_mode);
/*
* ToHeart コマンド処理
*/
#define c (*p)
static int
CommandParser(Lvns *lvns, const u_char **p, Bool history_mode)
{
ToHeartState *state = (ToHeartState *)lvns->system_state;
switch (c[0]) {
case 0x20:
dprintf((stderr, "[END()]\n")); /* シナリオ終了 */
c++;
return True;
case 0x21:
if (c[1] == 3) {
ToHeartState *state = (ToHeartState *)lvns->system_state;
dprintf((stderr, "[タイトル処理? 0x21,0x03]\n"));
if (!history_mode) {
// 真っ白な背景
ToHeartLoadBG(lvns, 254);
// タイトルロゴ
lvnsimage_delete(state->title);
state->title = LvnsLoadImage(lvns, "TITLE2.LF2", NULL);
state->title_mask = 16;
lvns->latitude = 16;
ToHeartSakuraSetRandomNumber(lvns, 40);
LvnsSetBackEffect(lvns, &toHeartSakuraEffect);
LvnsWhiteIn(lvns);
LvnsWait(lvns, 120);
lvnsimage_delete(state->title);
state->title = NULL;
}
c += 2;
} else if (c[1] == 8) { /* 謎 あかりシナリオ終盤で利用される */
dprintf((stderr, "[あかりシナリオ終盤 0x21,0x08,%x,%x,%x,%x]\n",
c[2],c[3],c[4],c[5]));
c += 6;
}
break;
case 0x23:
dprintf((stderr, "[謎23(%02x)]\n", c[1]));
c += 2;
break;
case 0x24: /* 選択肢 */
dprintf((stderr, "[選択肢(%d)]-[メッセージ:%d]\n", c[2], c[1]));
LvnsSetSavePoint(lvns, &lvns->selectpoint);
memcpy(state->flag_select, state->flag, sizeof state->flag);
{
int i;
TextParser(lvns, c[1], True);
for (i = 0; i < c[2]; i++) {
dprintf((stderr,
"[選択肢 %d]-[メッセージ:%d]-[オフセット:%02x]\n",
i, c[3 + i*2], c[4 + i*2]));
lvns->text_attr = i+1;
TextParser(lvns, c[3+i*2], False);
}
lvns->text_attr = 0;
i = LvnsWaitSelect(lvns, c[2]);
LvnsAddHistory(lvns, c[3+i*2]);
dprintf((stderr, "選択分岐: %d (+%02x)\n", i, c[4 + i*2]));
c = c + 3 + c[2] * 2 + c[4+i*2];
}
break;
case 0x26:
dprintf((stderr, "[謎26()]\n"));
c++;
break;
case 0x27:
dprintf((stderr, "[1つ前の選択肢に戻るマーク????]\n"));
c++;
break;
case 0x28:
dprintf((stderr, "[ジャンプ %04x - Block %d]\n",
c[1]*256 + c[2], c[3]));
ToHeartLoadScenario(lvns, c[1] * 256 + c[2], c[3]);
break;
case 0x29:
dprintf((stderr, "[ブロックジャンプ- Block %d]\n", c[1]));
LvnsLoadScenarioBlock(lvns, c[1]);
break;
case 0x2b:
dprintf((stderr, "[可変選択肢(選択肢オフセット:%d)] - [メッセージ:%d]\n", c[1], c[2]));
{
int i, select_num = 0;
int selmap[12];
TextParser(lvns, c[2], True);
for (i = 0; i < 12; i++) {
int msg = state->flag[TOHEART_FLAG_VSELECT_MSG + i];
if (msg != 0) {
dprintf((stderr,
"[選択肢 %d][メッセージ:%d][オフセット:%02x]\n",
i, msg,
state->flag[TOHEART_FLAG_VSELECT_OFF + i]));
selmap[select_num++] = i;
lvns->text_attr = select_num;
TextParser(lvns, msg, False);
}
}
lvns->text_attr = 0;
i = selmap[LvnsWaitSelect(lvns, select_num)];
LvnsAddHistory(lvns, state->flag[TOHEART_FLAG_VSELECT_MSG + i]);
c = c + 3 + state->flag[TOHEART_FLAG_VSELECT_OFF + i] * c[1];
}
break;
case 0x2c:
dprintf((stderr, "[選択肢前位置()]\n"));
{
int i;
LvnsSetSavePoint(lvns, &lvns->selectpoint);
memcpy(state->flag_select, state->flag, sizeof state->flag);
for (i=0; i<12; i++)
state->flag[TOHEART_FLAG_VSELECT_MSG + i] = 0;
}
c++;
break;
case 0x2d:
dprintf((stderr,
"[PUSH(2d)(%02x%02x, Block - %02d)]\n", c[1], c[2], c[3]));
state->flag[TOHEART_FLAG_2D_SCN] = c[1];
state->flag[TOHEART_FLAG_2D_SCN+1] = c[2];
state->flag[TOHEART_FLAG_2D_BLK] = c[3];
c += 4;
break;
case 0x2e:
dprintf((stderr, "[RETURN-2d()]\n"));
ToHeartLoadScenario(lvns,
state->flag[TOHEART_FLAG_2D_SCN] * 256 +
state->flag[TOHEART_FLAG_2D_SCN+1],
state->flag[TOHEART_FLAG_2D_BLK]);
break;
case 0x2f:
dprintf((stderr,
"[PUSH(2f)(%02x%02x, Block - %02d)]\n", c[1], c[2], c[3]));
state->flag[TOHEART_FLAG_2F_SCN] = c[1];
state->flag[TOHEART_FLAG_2F_SCN+1] = c[2];
state->flag[TOHEART_FLAG_2F_BLK] = c[3];
c += 4;
break;
case 0x30:
dprintf((stderr, "[RETURN-2f()]\n"));
ToHeartLoadScenario(lvns,
state->flag[TOHEART_FLAG_2F_SCN] * 256 +
state->flag[TOHEART_FLAG_2F_SCN+1],
state->flag[TOHEART_FLAG_2F_BLK]);
break;
case 0x32: /* 日付を設定する */
dprintf((stderr, "[日付設定(カレンダー無)(%02x)]\n", c[1]));
if (c[1] == 0xf0) {
state->flag[TOHEART_FLAG_DATE] = 3; /* 日付初期化 */
} else {
state->flag[TOHEART_FLAG_DATE] ++; /* 一日追加 */
}
state->flag[TOHEART_FLAG_WEEKDAY] =
(state->flag[TOHEART_FLAG_DATE] + 5) % 7;
c+=2;
break;
case 0x33: /* 時刻を設定する */
dprintf((stderr, "[時刻設定(%02x)]\n", c[1]));
/* 行動フラグ初期化。ここで良いのかどうかは不明 */
state->flag[TOHEART_FLAG_EVENT_DONE] = 0;
state->flag[TOHEART_FLAG_IDOU] = 0;
if (c[1] >= 0xf0) {
/* 表示無し更新 */
state->flag[TOHEART_FLAG_TIME] = c[1] - 0xf0;
} else {
/* 表示有り更新 */
int i;
int start;
if (state->fast_clock) {
start = c[1];
} else {
start = state->flag[TOHEART_FLAG_TIME];
}
state->flag[TOHEART_FLAG_TIME] = c[1];
for (i=start; i<c[1]+1;i++) {
clock_anim[i].type = LVNS_ANIM_IMAGE_ADD;
}
clock_anim[i].type = LVNS_ANIM_NONE;
LvnsAnimation(lvns, clock_anim + start);
}
c += 2;
break;
case 0x34: /* フラグ加算 */
dprintf((stderr, "[%s += %d]\n", FlgName(c[1]), c[2]));
state->flag[c[1]] += c[2];
c += 3;
break;
case 0x35: /* フラグ減算 */
dprintf((stderr, "[%s -= %d]\n", FlgName(c[1]), c[2]));
state->flag[c[1]] -= c[2];
c += 3;
break;
case 0x3c:/* 背景ロード */
dprintf((stderr, "[背景ロード to VRAM? 0x3c(%d/%d)]\n", c[1]/50, c[1]%50));
if (!history_mode) {
ToHeartLoadBG(lvns, c[1]);
/* 絵を仮想VRAMに設定 */
lvnsimage_copy(lvns->background, lvns->vram);
LVNS->mergeCharacter(lvns);
}
c += 2;
break;
case 0x3d:
dprintf((stderr, "[キャラクタ消去 0x3d(%d)]\n", c[1]));
if (!history_mode) {
ToHeartClearCharacter(lvns, c[1]);
}
c += 2;
break;
case 0x40:
dprintf((stderr, "[謎40(%02x)]\n", c[1]));
c += 2;
break;
case 0x42:
dprintf((stderr, "[VISUALロード 0x42 (V%02x.LF2)]\n", c[1]));
if (!history_mode) {
ToHeartLoadVisual(lvns, c[1]);
}
c += 2;
break;
case 0x43:
dprintf((stderr, "[キャラクタ表示 0x43 (%s, C%02x%02x.LF2)]\n",
posstr[c[1]], c[2], c[3]));
if (!history_mode) {
ToHeartLoadCharacter(lvns, c[2]<<8|c[3], c[1]);
}
c += 4;
break;
case 0x44: /* 消去表示処理 */
dprintf((stderr, "[???? 0x44 謎表示処理?(%02x, %02x)]\n", c[1], c[2]));
c += 3;
break;
case 0x45:
dprintf((stderr, "[表示処理(%02x)]\n", c[1]));
if (!history_mode) {
LvnsDisp(lvns, text_effect(c[1]));
}
c += 2;
break;
case 0x47:
switch (c[1]) {
case 1:
dprintf((stderr, "[セピア表示]\n"));
lvns->sepia_mode_next = True;
break;
default:
dprintf((stderr, "[パレット処理? 0x47(%02x)]\n", c[1]));
}
c += 2;
break;
case 0x50:
dprintf((stderr, "[謎 0x50]\n"));
c ++;
break;
case 0x55:
dprintf((stderr, "[同一ブロック内部ジャンプ?(%02x)]\n", c[1]));
lvns->scn_cur += c[1];
c += 2;
break;
case 0x56:
c++;
{
int flag = *c++;
int data = *c++;
int offset = *c++;
dprintf((stderr, "[if (%s(%d) == %d) pc += %02d)]\n",
FlgName(flag), state->flag[flag], data, offset));
if (state->flag[flag] == data)
lvns->scn_cur += offset;
}
break;
case 0x57:
c++;
{
int flag = *c++;
int data = *c++;
int offset = *c++;
dprintf((stderr, "[if (%s(%d) != %d) pc += %02d)]\n",
FlgName(flag),state->flag[flag], data, offset));
if (state->flag[flag] != data)
lvns->scn_cur += offset;
}
break;
case 0x58:
c++;
{
int flag = *c++;
int data = *c++;
int offset = *c++;
dprintf((stderr, "[if (%s(%d) > %d) pc += %02d)]\n",
FlgName(flag), state->flag[flag], data, offset));
if (state->flag[flag] > data)
lvns->scn_cur += offset;
}
break;
case 0x59:
c++;
{
int flag = *c++;
int data = *c++;
int offset = *c++;
dprintf((stderr, "[if (%s(%d) < %d) pc += %02d)]\n",
FlgName(flag), state->flag[flag], data, offset));
if (state->flag[flag] < data)
lvns->scn_cur += offset;
}
break;
case 0x5a:
c++;
{