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
|
/*
* Copyright (C) 1996-1998 Szeredi Miklos
* Email: mszeredi@inf.bme.hu
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See the file COPYING.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include "spscr_p.h"
#include "spscr.h"
#include "spperif.h"
#include "z80.h"
#include <stdlib.h>
#include <stdio.h>
#define TABOFFS 2
volatile int screen_visible = 1;
volatile int accept_keys = 1;
byte *update_screen_line(byte *scrp, int coli, int scri, int border,
qbyte *cmarkp)
{
qbyte *scrptr;
#if LCD_WIDTH == 320 && ( LCD_HEIGHT == 240 || LCD_HEIGHT == 200 )
qbyte brd_color;
#else
(void) border;
#endif
int i;
qbyte *tmptr, *mptr;
qbyte mark, cmark;
cmark = *cmarkp;
scrptr = (qbyte *) scrp;
if(scri >= 0) { /* normal line */
#if LCD_WIDTH == 320 && ( LCD_HEIGHT == 240 || LCD_HEIGHT == 200 )
if(SPNM(border_update)) {
brd_color = SPNM(colors)[border];
brd_color |= brd_color << 8;
brd_color |= brd_color << 16;
for(i = 8; i; i--) *scrptr++ = brd_color;
scrptr += 0x40;
for(i = 8; i; i--) *scrptr++ = brd_color;
scrptr -= 0x48;
}
else
#endif
scrptr += 0x08;
tmptr = SPNM(scr_mark) + 0x2C0 + (coli >> 3);
mark = *tmptr;
if(!(coli & 0x07)) {
cmark = mark;
*tmptr = 0;
}
else cmark |= mark;
mptr = SPNM(scr_mark) + scri;
mark = *mptr | cmark;
if(mark) {
byte *spmp, *spcp;
qbyte *scr_tab;
*mptr = 0;
SPNM(imag_mark)[coli] |= mark;
SPNM(imag_horiz) |= mark;
coli >>= 3;
SPNM(imag_vert) |= (1 << coli);
spmp = PRNM(proc).mem + (scri << 5);
spcp = PRNM(proc).mem + 0x5800 + (coli << 5);
if(!SPNM(flash_state)) scr_tab = SPNM(scr_f0_table);
else scr_tab = SPNM(scr_f1_table);
for(i = 32; i; i--) {
register dbyte spcx, spmx;
spcx = (*spcp++) << 6;
spmx = *spmp++;
*scrptr++ = scr_tab[spcx|((spmx & 0xf0) >> 4)];
*scrptr++ = scr_tab[spcx|((spmx & 0x0f))];
}
scrptr +=0x08;
}
else scrptr += 0x48;
}
else if(scri == -1) { /* only border */
#if LCD_WIDTH == 320 && ( LCD_HEIGHT == 240 || LCD_HEIGHT == 200 )
if(SPNM(border_update)) {
brd_color = SPNM(colors)[border];
brd_color |= brd_color << 8;
brd_color |= brd_color << 16;
for(i = 0x50; i; i--) *scrptr++ = brd_color;
}
else
#endif
scrptr += 0x50;
}
*cmarkp = cmark;
return (byte *) scrptr;
}
void spscr_init_mask_color(void)
{
int clb;
int bwb;
int hb;
int ix, j;
int bc, fc;
byte *tab_f0, *tab_f1;
sp_scr_f0_table = (qbyte *) (PRNM(proc).mem + 0x10000);
sp_scr_f1_table = (qbyte *) (PRNM(proc).mem + 0x20000);
sp_colors[8] = sp_colors[0];
for(clb = 0; clb < 256; clb++)
for(hb = 0; hb < 16; hb++) {
bc = (clb & 0x38) >> 3;
fc = clb & 0x07;
if(clb & 0x40) {
fc |= 0x08;
bc |= 0x08;
}
bwb = hb;
ix = (clb << 8) + (hb << TABOFFS);
tab_f0 = ((byte *) sp_scr_f0_table) + ix + 3;
tab_f1 = ((byte *) sp_scr_f1_table) + ix + 3;
for(j = 4; j; bwb >>= 1, j--) {
*tab_f0-- = (byte) sp_colors[(bwb & 0x01) ? fc : bc];
*tab_f1-- = (byte) sp_colors[(clb & 0x80) ?
((bwb & 0x01) ? bc : fc) :
((bwb & 0x01) ? fc : bc)];
}
}
}
void flash_change(void)
{
int i,j;
byte *scp;
qbyte *mcp;
register unsigned int val;
mcp = sp_scr_mark + 0x2C0;
scp = z80_proc.mem + 0x5800;
for(i = 24; i; mcp++, i--) {
val = 0;
for(j = 32; j; scp++, j--) {
val >>= 1;
if(*scp & 0x80) val |= (1 << 31);
}
*mcp |= val;
}
}
void spscr_init_line_pointers(int lines)
{
int i;
int bs;
int y;
int scline;
bs = (lines - 192) / 2;
for(i = 0; i < PORT_TIME_NUM; i++) {
sp_scri[i] = -2;
if(i < ODDHF) scline = i;
else scline = i - ODDHF;
if(scline >= 64-bs && scline < 256+bs) {
if(scline >= 64 && scline < 256) {
y = scline - 64;
sp_coli[i] = y;
sp_scri[i] = 0x200 +
(y & 0xC0) + ((y & 0x07) << 3) + ((y & 0x38) >> 3);
}
else sp_scri[i] = -1;
}
}
}
|