2016-08-14 22:07:17 -04:00
|
|
|
/* Copyright holders: Sarah Walker
|
|
|
|
|
see COPYING for more details
|
|
|
|
|
*/
|
2016-06-26 00:34:39 +02:00
|
|
|
#include <stdio.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdint.h>
|
2016-06-26 00:34:39 +02:00
|
|
|
#include <string.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <wchar.h>
|
2017-10-17 01:59:09 -04:00
|
|
|
#include "../86box.h"
|
2017-09-02 20:39:57 +02:00
|
|
|
#include "../io.h"
|
2017-09-04 01:52:29 -04:00
|
|
|
#include "../nmi.h"
|
|
|
|
|
#include "../mem.h"
|
|
|
|
|
#include "../rom.h"
|
2017-09-02 20:39:57 +02:00
|
|
|
#include "../device.h"
|
2017-09-25 04:31:20 -04:00
|
|
|
#include "../nvr.h"
|
2017-11-05 01:57:04 -05:00
|
|
|
#include "../keyboard.h"
|
2017-09-02 20:39:57 +02:00
|
|
|
#include "../lpt.h"
|
2017-11-05 01:57:04 -05:00
|
|
|
#include "../game/gameport.h"
|
|
|
|
|
#include "../video/video.h"
|
2017-10-07 22:18:30 -04:00
|
|
|
#include "machine.h"
|
2017-06-16 16:00:44 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
|
|
|
|
|
uint8_t europcdat[16];
|
2017-06-16 16:00:44 -04:00
|
|
|
|
2017-09-04 01:52:29 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
uint8_t dat[16];
|
2017-08-25 23:17:45 +02:00
|
|
|
uint8_t stat;
|
|
|
|
|
uint8_t addr;
|
2016-06-26 00:34:39 +02:00
|
|
|
} europc_rtc;
|
|
|
|
|
|
2017-06-16 16:00:44 -04:00
|
|
|
|
2017-08-25 23:17:45 +02:00
|
|
|
static uint8_t jim_load_nvr(void)
|
|
|
|
|
{
|
|
|
|
|
FILE *f;
|
|
|
|
|
|
2017-10-03 16:33:01 -04:00
|
|
|
f = nvr_fopen(L"europc_jim.nvr", L"rb");
|
2017-08-25 23:17:45 +02:00
|
|
|
if (f)
|
|
|
|
|
{
|
|
|
|
|
fread(europcdat, 1, 16, f);
|
|
|
|
|
fread(europc_rtc.dat, 1, 16, f);
|
|
|
|
|
fclose(f);
|
|
|
|
|
f = NULL;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-09-04 01:52:29 -04:00
|
|
|
void europc_save_nvr(void)
|
2017-08-25 23:17:45 +02:00
|
|
|
{
|
|
|
|
|
FILE *f;
|
|
|
|
|
|
2017-10-03 16:33:01 -04:00
|
|
|
f = nvr_fopen(L"europc_jim.nvr", L"wb");
|
2017-08-25 23:17:45 +02:00
|
|
|
if (f)
|
|
|
|
|
{
|
|
|
|
|
fwrite(europcdat, 1, 16, f);
|
|
|
|
|
fwrite(europc_rtc.dat, 1, 16, f);
|
|
|
|
|
fclose(f);
|
|
|
|
|
f = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-06-16 16:00:44 -04:00
|
|
|
static void writejim(uint16_t addr, uint8_t val, void *p)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
|
|
|
|
if ((addr&0xFF0)==0x250) europcdat[addr&0xF]=val;
|
|
|
|
|
switch (addr)
|
|
|
|
|
{
|
|
|
|
|
case 0x25A:
|
|
|
|
|
switch (europc_rtc.stat)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
europc_rtc.addr=val&0xF;
|
|
|
|
|
europc_rtc.stat++;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
europc_rtc.dat[europc_rtc.addr]=(europc_rtc.dat[europc_rtc.addr]&0xF)|(val<<4);
|
|
|
|
|
europc_rtc.stat++;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
europc_rtc.dat[europc_rtc.addr]=(europc_rtc.dat[europc_rtc.addr]&0xF0)|(val&0xF);
|
|
|
|
|
europc_rtc.stat=0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-16 16:00:44 -04:00
|
|
|
|
|
|
|
|
static uint8_t readjim(uint16_t addr, void *p)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
|
|
|
|
switch (addr)
|
|
|
|
|
{
|
|
|
|
|
case 0x250: case 0x251: case 0x252: case 0x253: return 0;
|
|
|
|
|
case 0x254: case 0x255: case 0x256: case 0x257: return europcdat[addr&0xF];
|
|
|
|
|
case 0x25A:
|
|
|
|
|
if (europc_rtc.stat==1)
|
|
|
|
|
{
|
|
|
|
|
europc_rtc.stat=2;
|
|
|
|
|
return europc_rtc.dat[europc_rtc.addr]>>4;
|
|
|
|
|
}
|
|
|
|
|
if (europc_rtc.stat==2)
|
|
|
|
|
{
|
|
|
|
|
europc_rtc.stat=0;
|
|
|
|
|
return europc_rtc.dat[europc_rtc.addr]&0xF;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-16 16:00:44 -04:00
|
|
|
|
2017-09-02 20:39:57 +02:00
|
|
|
static void jim_init(void)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
|
|
|
|
uint8_t viddat;
|
|
|
|
|
memset(europc_rtc.dat,0,16);
|
2017-08-25 23:17:45 +02:00
|
|
|
if (!jim_load_nvr())
|
|
|
|
|
{
|
|
|
|
|
europc_rtc.dat[0xF]=1;
|
|
|
|
|
europc_rtc.dat[3]=1;
|
|
|
|
|
europc_rtc.dat[4]=1;
|
|
|
|
|
europc_rtc.dat[5]=0x88;
|
|
|
|
|
}
|
2016-11-02 22:39:07 +01:00
|
|
|
if (gfxcard==GFX_CGA || gfxcard == GFX_COLORPLUS) viddat=0x12;
|
2017-08-25 23:17:45 +02:00
|
|
|
else if (gfxcard==GFX_MDA || gfxcard==GFX_HERCULES || gfxcard==GFX_INCOLOR) viddat=3;
|
2016-06-26 00:34:39 +02:00
|
|
|
else viddat=0x10;
|
|
|
|
|
europc_rtc.dat[0xB]=viddat;
|
|
|
|
|
europc_rtc.dat[0xD]=viddat; /*Checksum*/
|
|
|
|
|
io_sethandler(0x250, 0x10, readjim, NULL, NULL, writejim, NULL, NULL, NULL);
|
|
|
|
|
}
|
2017-09-02 20:39:57 +02:00
|
|
|
|
|
|
|
|
|
2017-10-07 22:18:30 -04:00
|
|
|
void
|
|
|
|
|
machine_europc_init(machine_t *model)
|
2017-09-02 20:39:57 +02:00
|
|
|
{
|
2017-10-07 22:18:30 -04:00
|
|
|
machine_common_init(model);
|
|
|
|
|
|
2017-09-02 20:39:57 +02:00
|
|
|
lpt3_init(0x3bc);
|
|
|
|
|
jim_init();
|
2017-11-05 01:57:04 -05:00
|
|
|
device_add(&keyboard_xt_device);
|
2017-09-02 20:39:57 +02:00
|
|
|
nmi_init();
|
|
|
|
|
if (joystick_type != 7)
|
|
|
|
|
device_add(&gameport_device);
|
|
|
|
|
}
|