Update the french translation regarding the previous revision.
[kugel-rb.git] / apps / plugins / zxbox / spscr.c
blobd419ff0c6651bf3dc2178a7796ef6eefcf2a73da
1 /*
2 * Copyright (C) 1996-1998 Szeredi Miklos
3 * Email: mszeredi@inf.bme.hu
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. See the file COPYING.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "spscr_p.h"
22 #include "spscr.h"
24 #include "spperif.h"
25 #include "z80.h"
28 #include <stdlib.h>
29 #include <stdio.h>
31 #define TABOFFS 2
33 volatile int screen_visible = 1;
34 volatile int accept_keys = 1;
37 byte *update_screen_line(byte *scrp, int coli, int scri, int border,
38 qbyte *cmarkp)
40 qbyte *scrptr;
41 #if LCD_WIDTH == 320 && ( LCD_HEIGHT == 240 || LCD_HEIGHT == 200 )
42 qbyte brd_color;
43 #else
44 (void) border;
45 #endif
46 int i;
47 qbyte *tmptr, *mptr;
48 qbyte mark, cmark;
50 cmark = *cmarkp;
51 scrptr = (qbyte *) scrp;
52 if(scri >= 0) { /* normal line */
53 #if LCD_WIDTH == 320 && ( LCD_HEIGHT == 240 || LCD_HEIGHT == 200 )
54 if(SPNM(border_update)) {
55 brd_color = SPNM(colors)[border];
56 brd_color |= brd_color << 8;
57 brd_color |= brd_color << 16;
58 for(i = 8; i; i--) *scrptr++ = brd_color;
59 scrptr += 0x40;
60 for(i = 8; i; i--) *scrptr++ = brd_color;
61 scrptr -= 0x48;
63 else
64 #endif
65 scrptr += 0x08;
67 tmptr = SPNM(scr_mark) + 0x2C0 + (coli >> 3);
68 mark = *tmptr;
69 if(!(coli & 0x07)) {
70 cmark = mark;
71 *tmptr = 0;
73 else cmark |= mark;
74 mptr = SPNM(scr_mark) + scri;
76 mark = *mptr | cmark;
77 if(mark) {
78 byte *spmp, *spcp;
79 qbyte *scr_tab;
81 *mptr = 0;
82 SPNM(imag_mark)[coli] |= mark;
83 SPNM(imag_horiz) |= mark;
84 coli >>= 3;
85 SPNM(imag_vert) |= BIT_N(coli);
87 spmp = PRNM(proc).mem + (scri << 5);
88 spcp = PRNM(proc).mem + 0x5800 + (coli << 5);
90 if(!SPNM(flash_state)) scr_tab = SPNM(scr_f0_table);
91 else scr_tab = SPNM(scr_f1_table);
92 for(i = 32; i; i--) {
93 register dbyte spcx, spmx;
94 spcx = (*spcp++) << 6;
95 spmx = *spmp++;
96 *scrptr++ = scr_tab[spcx|((spmx & 0xf0) >> 4)];
97 *scrptr++ = scr_tab[spcx|((spmx & 0x0f))];
99 scrptr +=0x08;
101 else scrptr += 0x48;
103 else if(scri == -1) { /* only border */
104 #if LCD_WIDTH == 320 && ( LCD_HEIGHT == 240 || LCD_HEIGHT == 200 )
105 if(SPNM(border_update)) {
106 brd_color = SPNM(colors)[border];
107 brd_color |= brd_color << 8;
108 brd_color |= brd_color << 16;
109 for(i = 0x50; i; i--) *scrptr++ = brd_color;
111 else
112 #endif
113 scrptr += 0x50;
117 *cmarkp = cmark;
118 return (byte *) scrptr;
121 void spscr_init_mask_color(void)
123 int clb;
124 int bwb;
125 int hb;
126 int ix, j;
127 int bc, fc;
128 byte *tab_f0, *tab_f1;
130 sp_scr_f0_table = (qbyte *) (PRNM(proc).mem + 0x10000);
131 sp_scr_f1_table = (qbyte *) (PRNM(proc).mem + 0x20000);
133 sp_colors[8] = sp_colors[0];
135 for(clb = 0; clb < 256; clb++)
136 for(hb = 0; hb < 16; hb++) {
138 bc = (clb & 0x38) >> 3;
139 fc = clb & 0x07;
141 if(clb & 0x40) {
142 fc |= 0x08;
143 bc |= 0x08;
145 bwb = hb;
147 ix = (clb << 8) + (hb << TABOFFS);
148 tab_f0 = ((byte *) sp_scr_f0_table) + ix + 3;
149 tab_f1 = ((byte *) sp_scr_f1_table) + ix + 3;
151 for(j = 4; j; bwb >>= 1, j--) {
152 *tab_f0-- = (byte) sp_colors[(bwb & 0x01) ? fc : bc];
153 *tab_f1-- = (byte) sp_colors[(clb & 0x80) ?
154 ((bwb & 0x01) ? bc : fc) :
155 ((bwb & 0x01) ? fc : bc)];
160 void flash_change(void)
162 int i,j;
163 byte *scp;
164 qbyte *mcp;
165 register unsigned int val;
167 mcp = sp_scr_mark + 0x2C0;
168 scp = z80_proc.mem + 0x5800;
170 for(i = 24; i; mcp++, i--) {
171 val = 0;
172 for(j = 32; j; scp++, j--) {
173 val >>= 1;
174 if(*scp & 0x80) val |= (1 << 31);
176 *mcp |= val;
180 void spscr_init_line_pointers(int lines)
182 int i;
183 int bs;
184 int y;
185 int scline;
187 bs = (lines - 192) / 2;
189 for(i = 0; i < PORT_TIME_NUM; i++) {
191 sp_scri[i] = -2;
193 if(i < ODDHF) scline = i;
194 else scline = i - ODDHF;
196 if(scline >= 64-bs && scline < 256+bs) {
197 if(scline >= 64 && scline < 256) {
198 y = scline - 64;
199 sp_coli[i] = y;
200 sp_scri[i] = 0x200 +
201 (y & 0xC0) + ((y & 0x07) << 3) + ((y & 0x38) >> 3);
203 else sp_scri[i] = -1;