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
/
LvnsText.c
174 lines (148 loc) · 3.25 KB
/
LvnsText.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
/*
* 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: LvnsText.c,v 1.14 2001/08/03 01:55:25 go Exp $
*
*/
/*
* Lvns テキスト処理まわり
*/
#include <stdio.h>
#include <stdlib.h>
#include "Lvns.h"
#include "LvnsEffect.h"
/*
* 文字描画カーソル位置変更
*/
void
LvnsLocate(Lvns *lvns, int x, int y)
{
lvns->tvram[lvns->current_tvram].cur_x = x;
lvns->tvram[lvns->current_tvram].cur_y = y;
}
static void
drawChar(Lvns *lvns, int x, int y, int code, int attr)
{
}
/*
* 文字表示下請ルーチン
*/
static void
PutChar(Lvns *lvns, int code, int attr)
{
int i,j;
struct TextVram *c;
c = &lvns->tvram[lvns->current_tvram].row[i = lvns->tvram[lvns->current_tvram].cur_y].column[j = lvns->tvram[lvns->current_tvram].cur_x];
c->code = code;
c->attribute = attr;
lvns->tvram[lvns->current_tvram].cur_x++;
if (code) {
int x = XPOS(j, i);
int y = YPOS(i);
LVNS->drawChar(lvns, x, y, code, attr);
lvns->flushWindowArea(lvns, x, y, CHARDRAWSIZE, CHARDRAWSIZE);
}
#ifdef USE_MGL
if (lvns->tvram[lvns->current_tvram].cur_x >= TEXT_WIDTH - 1) {
lvns->tvram[lvns->current_tvram].cur_x = 0;
lvns->tvram[lvns->current_tvram].cur_y++;
}
#endif
}
/*
* 一文字表示 (LeafCode用)
*/
void
LvnsPutChar(Lvns *lvns, int c, int attr)
{
PutChar(lvns, c, attr);
/* 文字変更 */
lvns->text_written = True;
/* 文字単位の待ち時間決定 */
if (!lvns->skip &&
!(lvns->select && lvns->key_click_fast) &&
!lvns->fast_text) {
LvnsWait(lvns, lvns->char_wait_time);
}
}
/*
* 一文字表示 (EUC用)
*/
void
LvnsPutCharNormal(Lvns *lvns, int c, int attr)
{
PutChar(lvns, lvns->jis_to_leaf[EucToJisPack(c)], attr);
/* 文字変更 */
lvns->text_written = True;
/* 文字単位の待ち時間決定 */
if (!lvns->skip &&
!(lvns->select && lvns->key_click_fast) &&
!lvns->fast_text) {
LvnsWait(lvns, lvns->char_wait_time);
}
}
/*
* 文字列表示(EUC文字列専用)
*/
void
LvnsPuts(Lvns *lvns, const u_char *str, int attr)
{
int code;
while (*str) {
code = ((str[0]&0x7f)-33) * 94 + (str[1]&0x7f)-33;
PutChar(lvns, lvns->jis_to_leaf[code], attr);
str += 2;
}
lvns->text_written = True;
}
/*
* テキストの消去
*/
void
LvnsClearText(Lvns *lvns)
{
int i, j;
for (i=0; i<TEXT_HEIGHT;i++) {
lvns->tvram[lvns->current_tvram].row[i].offset = 16;
for (j=0; j<TEXT_WIDTH; j++) {
struct TextVram *c =
&lvns->tvram[lvns->current_tvram].row[i].column[j];
c->code = 0;
c->attribute = 0;
}
}
lvns->tvram[lvns->current_tvram].cur_x = 0;
lvns->tvram[lvns->current_tvram].cur_y = 0;
lvns->text_written = False;
}
/*
* 行の表示オフセットを指定
*/
void
LvnsSetTextOffset(Lvns *lvns, int offset)
{
int i;
#ifdef USE_MGL
offset /= 2;
#endif
for (i= lvns->tvram[lvns->current_tvram].cur_y; i < TEXT_HEIGHT; i++)
lvns->tvram[lvns->current_tvram].row[i].offset = offset;
}
/*
* 改行処理
*/
void
LvnsNewLineText(Lvns *lvns)
{
lvns->tvram[lvns->current_tvram].cur_x = 0;
lvns->tvram[lvns->current_tvram].cur_y++;
lvns->char_wait_time = 1;
#ifdef USE_MGL
if (lvns->skip)
MglGetEvent(lvns, 5);
#endif
}