2 NEC TK-80BS (COMPO BS/80) Emulator 'eTK-80BS'
\r
4 Author : Takeda.Toshiya
\r
10 #include "display.h"
\r
11 #include "../../fileio.h"
\r
13 static const int dest_x[8] = {
\r
14 1, 26, 51, 76, 106, 131, 156, 181
\r
16 static const int pat_led[35][24] = {
\r
17 {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
\r
18 {9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
\r
19 {9,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,0,0,9},
\r
20 {9,0,0,0,6,0,1,1,1,1,1,1,1,1,1,1,1,1,0,2,2,0,0,9},
\r
21 {9,0,0,0,6,6,0,1,1,1,1,1,1,1,1,1,1,0,2,2,2,0,0,9},
\r
22 {9,0,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,9},
\r
23 {9,0,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,9},
\r
24 {9,0,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,9},
\r
25 {9,0,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,9},
\r
26 {9,0,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,9},
\r
27 {9,0,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,9},
\r
28 {9,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,9},
\r
29 {9,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,9},
\r
30 {9,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,9},
\r
31 {9,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,9},
\r
32 {9,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,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2},
\r
76 {0,0,0,2,2,2,0,0,0,0,0,2,2,2,0,2,2,2,0,0,0,0,2,2,2,0,0,0,2,2,2,0,0,2,2,2,0,0,0,2,2,2},
\r
77 {0,0,0,2,2,2,0,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,0,0,2,2,2,2,2,0,0,0,0,2,2,2,0,0,0,2,2,2},
\r
78 {0,0,0,2,2,2,0,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,0,0,2,2,2,2,2,0,0,0,0,2,2,2,0,0,0,2,2,2},
\r
79 {0,0,0,2,2,2,0,0,0,0,0,2,2,2,0,2,2,2,0,0,0,0,2,2,2,0,0,0,2,2,2,0,0,2,2,2,0,0,0,2,2,2},
\r
80 {0,0,0,2,2,2,0,0,0,0,0,2,2,2,0,2,2,2,0,0,0,0,2,2,2,0,0,0,2,2,2,0,0,2,2,2,0,0,0,2,2,2},
\r
81 {0,0,0,2,2,2,0,0,0,0,0,2,2,2,0,0,0,2,2,2,0,0,2,2,2,0,0,0,2,2,2,0,0,2,2,2,0,0,0,2,2,2},
\r
82 {0,0,0,2,2,2,0,0,0,0,0,2,2,2,0,0,0,2,2,2,0,0,2,2,2,0,0,0,2,2,2,0,0,2,2,2,0,0,0,2,2,2},
\r
83 {0,0,0,2,2,2,0,0,0,0,0,2,2,2,0,0,0,2,2,2,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,2,2,2,2,2,0,0},
\r
84 {0,0,0,2,2,2,0,0,0,0,0,2,2,2,0,0,0,2,2,2,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,2,2,2,2,2,0,0},
\r
87 void DISPLAY::initialize()
\r
90 FILEIO* fio = new FILEIO();
\r
91 if(fio->Fopen(emu->bios_path(_T("FONT.ROM")), FILEIO_READ_BINARY)) {
\r
92 fio->Fread(font, sizeof(font), 1);
\r
101 void DISPLAY::write_signal(int id, uint32 data, uint32 mask)
\r
103 if(id == SIG_DISPLAY_MODE) {
\r
104 // 8255 PC on TK-80BS
\r
105 mode = data & mask;
\r
106 } else if(id == SIG_DISPLAY_DMA) {
\r
107 // 8255 PC on TK-80
\r
112 void DISPLAY::draw_screen()
\r
115 scrntype col_w = (mode & 2) ? RGB_COLOR(255, 255, 255) : 0;
\r
116 scrntype col_b = (mode & 2) ? 0 : RGB_COLOR(255, 255, 255);
\r
117 int code_ofs = (mode & 1) << 8;
\r
120 for(int y = 0; y < 128; y += 8) {
\r
121 for(int x = 0; x < 256; x += 8) {
\r
122 int code = vram[ptr++] | code_ofs;
\r
123 uint8* font_base = &font[code << 3];
\r
125 for(int l = 0; l < 8; l++) {
\r
126 uint8 pat = font_base[l];
\r
127 scrntype* dest = &screen[l][x];
\r
129 dest[0] = (pat & 0x80) ? col_w : col_b;
\r
130 dest[1] = (pat & 0x40) ? col_w : col_b;
\r
131 dest[2] = (pat & 0x20) ? col_w : col_b;
\r
132 dest[3] = (pat & 0x10) ? col_w : col_b;
\r
133 dest[4] = (pat & 0x08) ? col_w : col_b;
\r
134 dest[5] = (pat & 0x04) ? col_w : col_b;
\r
135 dest[6] = (pat & 0x02) ? col_w : col_b;
\r
136 dest[7] = (pat & 0x01) ? col_w : col_b;
\r
139 for(int l = 0; l < 8; l++) {
\r
140 scrntype* dest = emu->screen_buffer(y + l);
\r
141 scrntype* src = screen[l];
\r
142 memcpy(dest, src, 256 * sizeof(scrntype));
\r
146 scrntype col_red = RGB_COLOR(255, 0, 0);
\r
147 scrntype col_on = RGB_COLOR(255, 8, 72);
\r
148 scrntype col_off = RGB_COLOR(56, 0, 0);
\r
151 memset(screen, 0, sizeof(screen));
\r
152 for(int i = 0; i < 8; i++) {
\r
153 for(int i = 0; i < 8; i++) {
\r
154 uint8 pat = dma ? led[i] : 0;
\r
156 col[1] = pat & 0x01 ? col_on : col_off;
\r
157 col[2] = pat & 0x02 ? col_on : col_off;
\r
158 col[3] = pat & 0x04 ? col_on : col_off;
\r
159 col[4] = pat & 0x08 ? col_on : col_off;
\r
160 col[5] = pat & 0x10 ? col_on : col_off;
\r
161 col[6] = pat & 0x20 ? col_on : col_off;
\r
162 col[7] = pat & 0x40 ? col_on : col_off;
\r
163 col[8] = pat & 0x80 ? col_on : col_off;
\r
165 for(int y = 0; y < 35; y++) {
\r
166 scrntype *dest = &screen[y + 1][dest_x[i]];
\r
167 for(int x = 0; x < 24; x++) {
\r
168 dest[x] = col[pat_led[y][x]];
\r
174 col[1] = d_key->read_signal(0) & 1 ? col_red : col_off;
\r
175 col[2] = d_key->read_signal(0) & 2 ? col_red : col_off;
\r
177 for(int y = 0; y < 31; y++) {
\r
178 scrntype *dest = &screen[y + 3][210];
\r
179 for(int x = 0; x < 42; x++) {
\r
180 dest[x] = col[pat_kb[y][x]];
\r
185 for(int y = 0; y < 36; y++) {
\r
186 scrntype* dest = emu->screen_buffer(y + 128);
\r
187 scrntype* src = screen[y];
\r
188 memcpy(dest, src, 256 * sizeof(scrntype));
\r