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
/
LvnsDisp.c
269 lines (240 loc) · 5.64 KB
/
LvnsDisp.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
/*
* 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: LvnsDisp.c,v 1.16 2001/08/11 19:59:36 tf Exp $
*
*/
/*
* Lvns 表示処理周辺
*/
#include <stdio.h>
#include "Lvns.h"
#include "LvnsEffect.h"
/**
* 現在のテキストレイヤを全部再描画する
*/
static void
DrawTextLayerAll(Lvns *lvns)
{
int i, j;
for (i=0; i<TEXT_HEIGHT;i++) {
for (j=0; j<TEXT_WIDTH; j++) {
struct TextVram *c =
&lvns->tvram[lvns->current_tvram].row[i].column[j];
if (c->code) {
int x = XPOS(j,i);
int y = YPOS(i);
LVNS->drawChar(lvns, x, y, c->code, c->attribute);
}
}
}
}
/*
* カーソルの消去
*/
void
LvnsClearCursor(Lvns *lvns)
{
if (lvns->cursor_state) {
int x = XPOS(lvns->tvram[lvns->current_tvram].o_cur_x,
lvns->tvram[lvns->current_tvram].o_cur_y);
int y = YPOS(lvns->tvram[lvns->current_tvram].o_cur_y);
lvns->drawWindowArea(lvns, x, y, CHARDRAWSIZE, CHARDRAWSIZE, x, y);
lvns->flushWindowArea(lvns, x, y, CHARDRAWSIZE, CHARDRAWSIZE);
lvns->cursor_state = 0;
}
}
/*
* カーソルの描画
*/
void
LvnsDrawCursor(Lvns *lvns, LvnsCursorType cursor_type)
{
int cursor;
if (cursor_type == LVNS_CURSOR_PAGE) {
cursor = LVNS->cursor_page;
} else
cursor = LVNS->cursor_key;
if (lvns->cursor_state == 0) {
int x = XPOS(lvns->tvram[lvns->current_tvram].cur_x,
lvns->tvram[lvns->current_tvram].cur_y);
int y = YPOS(lvns->tvram[lvns->current_tvram].cur_y);
LVNS->drawChar(lvns, x, y, cursor, 0);
lvns->flushWindowArea(lvns, x, y, CHARDRAWSIZE, CHARDRAWSIZE);
lvns->tvram[lvns->current_tvram].o_cur_x =
lvns->tvram[lvns->current_tvram].cur_x;
lvns->tvram[lvns->current_tvram].o_cur_y =
lvns->tvram[lvns->current_tvram].cur_y;
lvns->cursor_state = 1;
} else {
LvnsClearCursor(lvns);
}
}
/**
* テキストカーソルの消去
*/
void
LvnsClearTextCursor(Lvns *lvns)
{
int i, j;
for (i=0; i<TEXT_HEIGHT;i++) {
for (j=0; j<TEXT_WIDTH; j++) {
struct TextVram *c =
&lvns->tvram[lvns->current_tvram].row[i].column[j];
if (c->code && c->attribute == lvns->text_cursor_state) {
int x = XPOS(j,i);
int y = YPOS(i);
LVNS->drawChar(lvns, x, y, c->code, 1);
lvns->flushWindowArea(lvns, x, y, CHARDRAWSIZE, CHARDRAWSIZE);
}
}
}
}
/**
* テキストカーソルの表示
*/
void
LvnsDrawTextCursor(Lvns *lvns)
{
int i, j;
for (i=0; i<TEXT_HEIGHT;i++) {
for (j=0; j<TEXT_WIDTH; j++) {
struct TextVram *c =
&lvns->tvram[lvns->current_tvram].row[i].column[j];
if (c->code && c->attribute == lvns->text_cursor_state) {
int x = XPOS(j,i);
int y = YPOS(i);
LVNS->drawChar(lvns, x, y, c->code, 0);
lvns->flushWindowArea(lvns, x, y, CHARDRAWSIZE, CHARDRAWSIZE);
}
}
}
}
/**
* 現在の画面(背景 + 文字)を 仮想 vram から描画させる
*/
void
LvnsDispWindow(Lvns *lvns)
{
/* グラフィック部 */
lvns->setPaletteMulti(lvns, lvns->latitude);
lvns->drawWindow(lvns);
/* 追加表示処理(メニューなどで利用) */
if (lvns->disp_func)
lvns->disp_func(lvns, lvns->disp_func_param);
/* テキスト表示 */
if (lvns->text_mode) {
DrawTextLayerAll(lvns);
}
lvns->flushWindow(lvns);
}
/* 文字消去処理 */
void
LvnsUndispText(Lvns *lvns)
{
LvnsFlip(lvns, True); // 描画同期のため…
lvns->text_mode = False;
if (lvns->skip) {
lvns->latitude = 16;
LvnsDispWindow(lvns);
} else {
LvnsLighten(lvns);
}
}
/* 文字再表示処理 */
void
LvnsDispText(Lvns *lvns)
{
if (!lvns->text_mode) {
lvns->text_mode = True;
if (lvns->skip) {
lvns->latitude = lvns->latitude_dark;
} else {
LvnsDarken(lvns);
}
LvnsDispWindow(lvns);
LvnsFlip(lvns, True); // 描画同期のため…
}
}
/**
* 背景とキャラクタの状態から画像を合成して表示する
* 表示後しばらく待ちが入る
*/
void
LvnsDisp(Lvns *lvns, LvnsEffectType effect)
{
/* BGM 変更チェック */
LvnsStartNextMusic(lvns);
/* 背景エフェクト指定 */
if (lvns->effect_back_next) {
lvns->effect_back = lvns->effect_back_next;
lvns->effect_back_next = NULL;
}
/* 絵を仮想VRAMに設定 */
lvnsimage_copy(lvns->background, lvns->vram);
LVNS->mergeCharacter(lvns);
/* セピア調表示ならパレット修正 */
if (lvns->sepia_mode) {
lvnsimage_set_sepia(lvns->vram);
}
if (lvns->skip) {
LvnsDispWindow(lvns);
} else {
LvnsDispLow(lvns, effect);
LvnsWait(lvns, 500 * INTERVAL / 1000);
}
}
/**
* 消去処理を行う
*
*/
void
LvnsClear(Lvns *lvns, LvnsEffectType effect)
{
if (lvns->skip) {
lvnsimage_clear(lvns->vram);
LvnsDispWindow(lvns);
} else {
LvnsClearLow(lvns, effect);
}
LvnsSetBackEffect(lvns, NULL);
}
/**
* 直接テキスト描画
*/
void
LvnsDrawString(Lvns *lvns, int x, int y, const u_char *str, int attr)
{
int code;
while (*str) {
code = ((str[0]&0x7f)-33) * 94 + (str[1]&0x7f)-33;
code = lvns->jis_to_leaf[code];
if (code)
LVNS->drawChar(lvns, x, y, code, attr);
str += 2;
x += CHARSIZE;
}
}
/*
* 直接テキスト描画(センタリング)
*/
void
LvnsDrawStringCenter(Lvns *lvns, int y, const u_char *str, int attr)
{
LvnsDrawString(lvns, (WIDTH - strlen(str)/2 * CHARSIZE)/2,
y, str, attr);
}
void
LvnsTextOff(Lvns *lvns)
{
lvns->text_mode = False;
}
void
LvnsTextOn(Lvns *lvns)
{
lvns->text_mode = True;
}