This repository has been archived by the owner on Oct 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
LvnsHistory.c
143 lines (124 loc) · 2.89 KB
/
LvnsHistory.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
/*
* LEAF Visual Novel System For X
* (c) Copyright 1999,2000 Go Watanabe mailto:[email protected]
* All rights reserverd.
*
* ORIGINAL LVNS (c) Copyright 1996-1999 LEAF/AQUAPLUS Inc.
*
* $Id: LvnsHistory.c,v 1.3 2001/08/05 10:58:09 go Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Lvns.h"
/**
* ヒストリ情報の登録
*/
void
LvnsAddHistory(Lvns *lvns, int no)
{
if (lvns->history_pos >= lvns->history_size) {
lvns->history_size += 100;
lvns->history = realloc(lvns->history,
sizeof(lvns->history[0]) * lvns->history_size + 1);
}
{
LvnsHistoryData *hdat = &lvns->history[lvns->history_pos];
hdat->scn = lvns->scn_current;
hdat->blk = lvns->blk_current;
hdat->no = no;
}
lvns->history_pos++;
}
static void
checkCursor(Lvns *lvns)
{
struct TextVram *c;
int y = R_YPOS(lvns->motion_y);
int x = R_XPOS(lvns->motion_x, y);
if (x >= 0 && y >=0 && x < TEXT_WIDTH && y < TEXT_HEIGHT) {
c = &lvns->tvram[lvns->current_tvram].row[y].column[x];
if (lvns->text_cursor_state != c->attribute) {
if (lvns->text_cursor_state != 0)
LvnsClearTextCursor(lvns);
if ((lvns->text_cursor_state = c->attribute) != 0) {
LvnsDrawTextCursor(lvns);
}
}
}
}
void
LvnsHistoryMode(Lvns *lvns)
{
/* 状態の保存 */
int scn = lvns->scn_current;
int blk = lvns->blk_current;
int fast_text = lvns->fast_text;
int scn_offset = lvns->scn_cur - lvns->scn_cur_head;
int pos = lvns->history_pos - 1;
lvns->fast_text = True;
lvns->current_tvram = 1; /* 裏 */
LvnsClearText(lvns);
lvns->text_cursor_state = 0;
lvns->select = False;
lvns->cursor_up = False;
lvns->cursor_down = False;
lvns->motion = False;
LVNS->dispHistory(lvns, pos);
checkCursor(lvns);
while (1) {
LvnsFlip(lvns, True);
if (lvns->cancel) {
break;
}
if (lvns->motion) {
checkCursor(lvns);
lvns->motion = False;
}
if (lvns->select) {
switch (lvns->text_cursor_state) {
case 1:
lvns->cursor_up = True;
break;
case 2:
lvns->cursor_down = True;
break;
default:
break;
}
lvns->select = False;
}
if (lvns->cursor_up) {
if (pos > 0) {
pos --;
lvns->text_cursor_state = 0;
LVNS->dispHistory(lvns, pos);
checkCursor(lvns);
}
lvns->cursor_up = False;
}
if (lvns->cursor_down) {
if (pos < lvns->history_pos-1) {
pos ++;
lvns->text_cursor_state = 0;
LVNS->dispHistory(lvns, pos);
checkCursor(lvns);
} else {
lvns->cancel = True;
}
lvns->cursor_down = False;
}
} /* while */
lvns->select = False;
lvns->cancel = False;
lvns->cursor_up = False;
lvns->cursor_down = False;
lvns->motion = False;
/* 状態を復帰させる */
lvns->fast_text = fast_text;
LvnsLoadScenario(lvns, scn, blk);
lvns->scn_cur = lvns->scn_cur_head + scn_offset;
lvns->current_tvram = 0; /* 表 */
LvnsDispWindow(lvns);
return;
}