/*
NEC TK-80BS (COMPO BS/80) Emulator 'eTK-80BS'
+ NEC TK-80 Emulator 'eTK-80'
+ NEC TK-85 Emulator 'eTK-85'
Author : Takeda.Toshiya
Date : 2008.08.26 -
#include "display.h"
-static const int led_pattern[46][33] = {
+namespace TK80 {
+
+static const int led_pattern[LED_SIZE_Y][LED_SIZE_X] = {
+#if defined(_TK80BS) || defined(_TK80)
{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
+#else
+ {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
+ {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
+ {9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,9},
+ {9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,9},
+ {9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,9},
+ {9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,9},
+ {9,9,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1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rom image
FILEIO* fio = new FILEIO();
if(fio->Fopen(create_local_path(_T("FONT.ROM")), FILEIO_READ_BINARY)) {
delete fio;
mode = 2;
+#endif
dma = true;
}
void DISPLAY::write_signal(int id, uint32_t data, uint32_t mask)
{
+#if defined(_TK80BS)
if(id == SIG_DISPLAY_MODE) {
// 8255 PC on TK-80BS
mode = data & mask;
- } else if(id == SIG_DISPLAY_DMA) {
+ } else
+#endif
+ if(id == SIG_DISPLAY_DMA) {
// 8255 PC on TK-80
dma = ((data & mask) != 0);
}
void DISPLAY::draw_screen()
{
+#if defined(_TK80BS)
// draw screen
scrntype_t color_w = (mode & 2) ? RGB_COLOR(255, 255, 255) : RGB_COLOR(0, 0, 1);
scrntype_t color_b = (mode & 2) ? RGB_COLOR(0, 0, 1) : RGB_COLOR(255, 255, 255);
+ scrntype_t screen[36][256] = {0};
int code_ofs = (mode & 1) << 8;
int ptr = 0;
for(int x = 0; x < 256; x += 8) {
int code = vram[ptr++];
if(code != 0x20) {
- vm->draw_ranges = 9;
+ static_cast<VM *>(vm)->draw_ranges = 9;
}
code |= code_ofs;
uint8_t* font_base = &font[code << 3];
memcpy(dest1, dest0, 256 * 2 * sizeof(scrntype_t));
}
}
+#endif
+
// draw 7-seg LEDs
scrntype_t col[10];
scrntype_t color_on = RGB_COLOR(255, 8, 72);
+#if defined(_TK80BS) || defined(_TK80)
scrntype_t color_off = RGB_COLOR(56, 0, 0);
col[0] = RGB_COLOR(38, 8, 0);
+#else
+ scrntype_t color_off = RGB_COLOR(111, 33, 33);
+ col[0] = RGB_COLOR(96, 53, 53);
+#endif
col[9] = color_off;
- memset(screen, 0, sizeof(screen));
for(int i = 0; i < 8; i++) {
uint8_t pat = dma ? led[i] : 0;
col[1] = pat & 0x01 ? color_on : color_off;
col[6] = pat & 0x20 ? color_on : color_off;
col[7] = pat & 0x40 ? color_on : color_off;
col[8] = pat & 0x80 ? color_on : color_off;
- for(int y = 0; y < 46; y++) {
+ for(int y = 0; y < LED_SIZE_Y; y++) {
scrntype_t* dest = emu->get_screen_buffer(vm_ranges[i].y + y) + vm_ranges[i].x;
- for(int x = 0; x < 33; x++) {
+ for(int x = 0; x < LED_SIZE_X; x++) {
dest[x] = col[led_pattern[y][x]];
}
}
#define STATE_VERSION 1
-void DISPLAY::save_state(FILEIO* state_fio)
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->FputInt32(mode);
- state_fio->FputBool(dma);
-}
-
-bool DISPLAY::load_state(FILEIO* state_fio)
-{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- mode = state_fio->FgetInt32();
- dma = state_fio->FgetBool();
+#if defined(_TK80BS)
+ state_fio->StateInt32(mode);
+#endif
+ state_fio->StateBool(dma);
return true;
}
+}