Fixed arrow keys on the Amstrads and indentation of the Olivetti machine code.

This commit is contained in:
OBattler
2020-12-19 00:06:41 +01:00
parent dd125854f1
commit bc12981935
4 changed files with 177 additions and 147 deletions

View File

@@ -330,7 +330,8 @@ const scancode scancode_xt[512] = {
static uint8_t key_queue[16]; static uint8_t key_queue[16];
static int key_queue_start = 0, static int key_queue_start = 0,
key_queue_end = 0; key_queue_end = 0;
static int is_t1x00 = 0; static int is_tandy = 0, is_t1x00 = 0,
is_amstrad = 0;
#ifdef ENABLE_KEYBOARD_XT_LOG #ifdef ENABLE_KEYBOARD_XT_LOG
@@ -425,7 +426,7 @@ kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val))
if (!adddata) if (!adddata)
return; return;
if (is_t1x00) { if (is_tandy) {
adddata(val); adddata(val);
return; return;
} }
@@ -433,6 +434,9 @@ kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val))
keyboard_get_states(NULL, &num_lock, NULL); keyboard_get_states(NULL, &num_lock, NULL);
shift_states = keyboard_get_shift() & STATE_SHIFT_MASK; shift_states = keyboard_get_shift() & STATE_SHIFT_MASK;
if (is_amstrad)
num_lock = !num_lock;
switch(val) { switch(val) {
case FAKE_LSHIFT_ON: case FAKE_LSHIFT_ON:
if (num_lock) { if (num_lock) {
@@ -558,15 +562,13 @@ kbd_read(uint16_t port, void *priv)
ret = ((mem_size-64) / 32) & 0x0f; ret = ((mem_size-64) / 32) & 0x0f;
else else
ret = ((mem_size-64) / 32) >> 4; ret = ((mem_size-64) / 32) >> 4;
} } else if (kbd->type == 8) {
else if (kbd->type == 8) {
/* Olivetti M19 */ /* Olivetti M19 */
if (kbd->pb & 0x04) if (kbd->pb & 0x04)
ret = kbd->pd; ret = kbd->pd;
else else
ret = kbd->pd >> 4; ret = kbd->pd >> 4;
} } else {
else {
if (kbd->pb & 0x08) if (kbd->pb & 0x08)
ret = kbd->pd >> 4; ret = kbd->pd >> 4;
else { else {
@@ -618,6 +620,13 @@ kbd_reset(void *priv)
} }
void
keyboard_set_is_amstrad(int ams)
{
is_amstrad = ams;
}
static void * static void *
kbd_init(const device_t *info) kbd_init(const device_t *info)
{ {
@@ -732,8 +741,11 @@ kbd_init(const device_t *info)
keyboard_set_table(scancode_xt); keyboard_set_table(scancode_xt);
is_tandy = (kbd->type == 5);
is_t1x00 = (kbd->type == 6); is_t1x00 = (kbd->type == 6);
is_amstrad = 0;
return(kbd); return(kbd);
} }

View File

@@ -102,6 +102,7 @@ extern void keyboard_set_states(uint8_t cl, uint8_t nl, uint8_t sl);
extern int keyboard_recv(uint16_t key); extern int keyboard_recv(uint16_t key);
extern int keyboard_isfsexit(void); extern int keyboard_isfsexit(void);
extern int keyboard_ismsexit(void); extern int keyboard_ismsexit(void);
extern void keyboard_set_is_amstrad(int ams);
extern void keyboard_at_adddata_keyboard_raw(uint8_t val); extern void keyboard_at_adddata_keyboard_raw(uint8_t val);
extern void keyboard_at_adddata_mouse(uint8_t val); extern void keyboard_at_adddata_mouse(uint8_t val);

View File

@@ -2116,8 +2116,7 @@ kbd_adddata(uint16_t val)
static void static void
kbd_adddata_ex(uint16_t val) kbd_adddata_ex(uint16_t val)
{ {
kbd_adddata(val); kbd_adddata_process(val, kbd_adddata);
// kbd_adddata_process(val, kbd_adddata);
} }
@@ -2500,6 +2499,7 @@ machine_amstrad_init(const machine_t *model, int type)
keyboard_set_table(scancode_xt); keyboard_set_table(scancode_xt);
keyboard_send = kbd_adddata_ex; keyboard_send = kbd_adddata_ex;
keyboard_scan = 1; keyboard_scan = 1;
keyboard_set_is_amstrad(1);
io_sethandler(0x0078, 2, io_sethandler(0x0078, 2,
ms_read, NULL, NULL, ms_write, NULL, NULL, ams); ms_read, NULL, NULL, ms_write, NULL, NULL, ams);

View File

@@ -118,6 +118,7 @@ m24_log(const char *fmt, ...)
#define m24_log(fmt, ...) #define m24_log(fmt, ...)
#endif #endif
static void static void
m24_kbd_poll(void *priv) m24_kbd_poll(void *priv)
{ {
@@ -171,9 +172,8 @@ m24_kbd_write(uint16_t port, uint8_t val, void *priv)
#endif #endif
#if 0 #if 0
if (ram[8] == 0xc3) { if (ram[8] == 0xc3)
output = 3; output = 3;
}
#endif #endif
switch (port) { switch (port) {
case 0x60: case 0x60:
@@ -242,6 +242,7 @@ m24_kbd_write(uint16_t port, uint8_t val, void *priv)
} }
} }
static uint8_t static uint8_t
m24_kbd_read(uint16_t port, void *priv) m24_kbd_read(uint16_t port, void *priv)
{ {
@@ -279,10 +280,12 @@ m24_kbd_read(uint16_t port, void *priv)
return(ret); return(ret);
} }
static void static void
m24_kbd_close(void *priv) m24_kbd_close(void *priv)
{ {
olim24_kbd_t *kbd = (olim24_kbd_t *)priv; olim24_kbd_t *kbd = (olim24_kbd_t *)priv;
/* Stop the timer. */ /* Stop the timer. */
timer_disable(&kbd->send_delay_timer); timer_disable(&kbd->send_delay_timer);
@@ -299,6 +302,7 @@ m24_kbd_close(void *priv)
free(kbd); free(kbd);
} }
static void static void
m24_kbd_reset(void *priv) m24_kbd_reset(void *priv)
{ {
@@ -319,6 +323,7 @@ m24_kbd_reset(void *priv)
m24_kbd->scan[6] = 0x50; m24_kbd->scan[6] = 0x50;
} }
static int static int
ms_poll(int x, int y, int z, int b, void *priv) ms_poll(int x, int y, int z, int b, void *priv)
{ {
@@ -401,8 +406,10 @@ ms_poll(int x, int y, int z, int b, void *priv)
return(0); return(0);
} }
static void static void
m24_kbd_init(olim24_kbd_t *kbd){ m24_kbd_init(olim24_kbd_t *kbd)
{
/* Initialize the keyboard. */ /* Initialize the keyboard. */
io_sethandler(0x0060, 2, io_sethandler(0x0060, 2,
@@ -418,9 +425,10 @@ m24_kbd_init(olim24_kbd_t *kbd){
mouse_set_poll(ms_poll, kbd); mouse_set_poll(ms_poll, kbd);
keyboard_set_table(scancode_xt); keyboard_set_table(scancode_xt);
keyboard_set_is_amstrad(0);
} }
static void static void
m19_vid_out(uint16_t addr, uint8_t val, void *priv) m19_vid_out(uint16_t addr, uint8_t val, void *priv)
{ {
@@ -428,23 +436,21 @@ m19_vid_out(uint16_t addr, uint8_t val, void *priv)
int oldmode = vid->mode; int oldmode = vid->mode;
/* activating plantronics mode */ /* activating plantronics mode */
if (addr == 0x3dd){ if (addr == 0x3dd) {
/* already in graphics mode */ /* already in graphics mode */
if ((val & 0x30) && (vid->ogc.cga.cgamode & 0x2)) { if ((val & 0x30) && (vid->ogc.cga.cgamode & 0x2))
vid->mode = PLANTRONICS_MODE; vid->mode = PLANTRONICS_MODE;
} else { else
vid->mode = OLIVETTI_OGC_MODE; vid->mode = OLIVETTI_OGC_MODE;
}
/* setting graphics mode */ /* setting graphics mode */
} else if (addr == 0x3d8) { } else if (addr == 0x3d8) {
if ((val & 0x2) && (vid->colorplus.control & 0x30)){ if ((val & 0x2) && (vid->colorplus.control & 0x30))
vid->mode = PLANTRONICS_MODE; vid->mode = PLANTRONICS_MODE;
} else { else
vid->mode = OLIVETTI_OGC_MODE; vid->mode = OLIVETTI_OGC_MODE;
} }
}
/* video mode changed */ /* video mode changed */
if(oldmode != vid->mode){ if (oldmode != vid->mode) {
/* activate Plantronics emulation */ /* activate Plantronics emulation */
if (vid->mode == PLANTRONICS_MODE){ if (vid->mode == PLANTRONICS_MODE){
timer_disable(&vid->ogc.cga.timer); timer_disable(&vid->ogc.cga.timer);
@@ -454,41 +460,46 @@ m19_vid_out(uint16_t addr, uint8_t val, void *priv)
timer_disable(&vid->colorplus.cga.timer); timer_disable(&vid->colorplus.cga.timer);
timer_set_delay_u64(&vid->ogc.cga.timer, 0); timer_set_delay_u64(&vid->ogc.cga.timer, 0);
} }
colorplus_recalctimings(&vid->colorplus); colorplus_recalctimings(&vid->colorplus);
ogc_recalctimings(&vid->ogc); ogc_recalctimings(&vid->ogc);
} }
colorplus_out(addr, val, &vid->colorplus); colorplus_out(addr, val, &vid->colorplus);
ogc_out(addr, val, &vid->ogc); ogc_out(addr, val, &vid->ogc);
} }
static uint8_t static uint8_t
m19_vid_in(uint16_t addr, void *priv) m19_vid_in(uint16_t addr, void *priv)
{ {
olim19_vid_t *vid = (olim19_vid_t *)priv; olim19_vid_t *vid = (olim19_vid_t *)priv;
if ( vid->mode == PLANTRONICS_MODE ) {
if (vid->mode == PLANTRONICS_MODE)
return colorplus_in(addr, &vid->colorplus); return colorplus_in(addr, &vid->colorplus);
} else { else
return ogc_in(addr, &vid->ogc); return ogc_in(addr, &vid->ogc);
} }
}
static uint8_t static uint8_t
m19_vid_read(uint32_t addr, void *priv) m19_vid_read(uint32_t addr, void *priv)
{ {
olim19_vid_t *vid = (olim19_vid_t *)priv; olim19_vid_t *vid = (olim19_vid_t *)priv;
vid->colorplus.cga.mapping = vid->ogc.cga.mapping; vid->colorplus.cga.mapping = vid->ogc.cga.mapping;
if ( vid->mode == PLANTRONICS_MODE ) { if (vid->mode == PLANTRONICS_MODE)
return colorplus_read(addr, &vid->colorplus); return colorplus_read(addr, &vid->colorplus);
} else { else
return ogc_read(addr, &vid->ogc); return ogc_read(addr, &vid->ogc);
} }
}
static void static void
m19_vid_write(uint32_t addr, uint8_t val, void *priv) m19_vid_write(uint32_t addr, uint8_t val, void *priv)
{ {
olim19_vid_t *vid = (olim19_vid_t *)priv; olim19_vid_t *vid = (olim19_vid_t *)priv;
colorplus_write(addr, val, &vid->colorplus); colorplus_write(addr, val, &vid->colorplus);
ogc_write(addr, val, &vid->ogc); ogc_write(addr, val, &vid->ogc);
} }
@@ -498,60 +509,64 @@ static void
m19_vid_close(void *priv) m19_vid_close(void *priv)
{ {
olim19_vid_t *vid = (olim19_vid_t *)priv; olim19_vid_t *vid = (olim19_vid_t *)priv;
free(vid->ogc.cga.vram); free(vid->ogc.cga.vram);
free(vid->colorplus.cga.vram); free(vid->colorplus.cga.vram);
free(vid); free(vid);
} }
static void static void
m19_vid_speed_changed(void *priv) m19_vid_speed_changed(void *priv)
{ {
olim19_vid_t *vid = (olim19_vid_t *)priv; olim19_vid_t *vid = (olim19_vid_t *)priv;
colorplus_recalctimings(&vid->colorplus); colorplus_recalctimings(&vid->colorplus);
ogc_recalctimings(&vid->ogc); ogc_recalctimings(&vid->ogc);
} }
static void
m19_vid_init(olim19_vid_t *vid){
//int display_type; static void
m19_vid_init(olim19_vid_t *vid)
{
/* int display_type; */
vid->mode = OLIVETTI_OGC_MODE; vid->mode = OLIVETTI_OGC_MODE;
video_inform(VIDEO_FLAG_TYPE_CGA, &timing_m19_vid); video_inform(VIDEO_FLAG_TYPE_CGA, &timing_m19_vid);
//display_type = device_get_config_int("display_type"); /* display_type = device_get_config_int("display_type"); */
/* OGC emulation part begin */ /* OGC emulation part begin */
loadfont_ex(L"roms/machines/olivetti_m19/BIOS.BIN", 1, 90); loadfont_ex(L"roms/machines/olivetti_m19/BIOS.BIN", 1, 90);
/* composite is not working yet */ /* composite is not working yet */
vid->ogc.cga.composite = 0; // (display_type != CGA_RGB); vid->ogc.cga.composite = 0; // (display_type != CGA_RGB);
//vid->ogc.cga.snow_enabled = device_get_config_int("snow_enabled"); /* vid->ogc.cga.snow_enabled = device_get_config_int("snow_enabled"); */
vid->ogc.cga.vram = malloc(0x8000); vid->ogc.cga.vram = malloc(0x8000);
//cga_comp_init(vid->ogc.cga.revision); /* cga_comp_init(vid->ogc.cga.revision); */
//vid->ogc.cga.rgb_type = device_get_config_int("rgb_type"); /* vid->ogc.cga.rgb_type = device_get_config_int("rgb_type"); */
//cga_palette = (vid->ogc.cga.rgb_type << 1); /* cga_palette = (vid->ogc.cga.rgb_type << 1); */
cga_palette = 0; cga_palette = 0;
cgapal_rebuild(); cgapal_rebuild();
ogc_mdaattr_rebuild(); ogc_mdaattr_rebuild();
/* color display */ /* color display */
// if (device_get_config_int("rgb_type")==0 || device_get_config_int("rgb_type") == 4) /* if (device_get_config_int("rgb_type")==0 || device_get_config_int("rgb_type") == 4) */
vid->ogc.mono_display = 1; vid->ogc.mono_display = 1;
// else /* else */
// vid->ogc.mono_display = 1; /* vid->ogc.mono_display = 1; */
/* OGC emulation part end */ /* OGC emulation part end */
/* Plantronics emulation part begin*/ /* Plantronics emulation part begin*/
/* composite is not working yet */ /* composite is not working yet */
vid->colorplus.cga.composite = 0; //(display_type != CGA_RGB); vid->colorplus.cga.composite = 0; //(display_type != CGA_RGB);
// vid->colorplus.cga.snow_enabled = device_get_config_int("snow_enabled"); /* vid->colorplus.cga.snow_enabled = device_get_config_int("snow_enabled"); */
vid->colorplus.cga.vram = malloc(0x8000); vid->colorplus.cga.vram = malloc(0x8000);
//vid->colorplus.cga.cgamode = 0x1; /* vid->colorplus.cga.cgamode = 0x1; */
/* Plantronics emulation part end*/ /* Plantronics emulation part end*/
timer_add(&vid->ogc.cga.timer, ogc_poll, &vid->ogc, 1); timer_add(&vid->ogc.cga.timer, ogc_poll, &vid->ogc, 1);
@@ -561,9 +576,9 @@ m19_vid_init(olim19_vid_t *vid){
io_sethandler(0x03d0, 0x0010, m19_vid_in, NULL, NULL, m19_vid_out, NULL, NULL, vid); io_sethandler(0x03d0, 0x0010, m19_vid_in, NULL, NULL, m19_vid_out, NULL, NULL, vid);
vid->mode = OLIVETTI_OGC_MODE; vid->mode = OLIVETTI_OGC_MODE;
} }
const device_t m24_kbd_device = { const device_t m24_kbd_device = {
"Olivetti M24 keyboard and mouse", "Olivetti M24 keyboard and mouse",
0, 0,
@@ -590,11 +605,13 @@ m19_get_device(void)
return &m19_vid_device; return &m19_vid_device;
} }
static uint8_t static uint8_t
m24_read(uint16_t port, void *priv) m24_read(uint16_t port, void *priv)
{ {
uint8_t ret = 0x00; uint8_t ret = 0x00;
int i, fdd_count = 0; int i, fdd_count = 0;
switch (port) { switch (port) {
/* /*
* port 66: * port 66:
@@ -650,10 +667,9 @@ m24_read(uint16_t port, void *priv)
*/ */
case 0x67: case 0x67:
for (i = 0; i < FDD_NUM; i++) { for (i = 0; i < FDD_NUM; i++) {
if (fdd_get_flags(i)) { if (fdd_get_flags(i))
fdd_count++; fdd_count++;
} }
}
/* Switches 7, 8 - floppy drives. */ /* Switches 7, 8 - floppy drives. */
if (!fdd_count) if (!fdd_count)
@@ -674,17 +690,19 @@ m24_read(uint16_t port, void *priv)
/* Switch 2 - Set fast startup */ /* Switch 2 - Set fast startup */
ret |= 0x2; ret |= 0x2;
} }
return(ret); return(ret);
} }
const device_t * const device_t *
m24_get_device(void) m24_get_device(void)
{ {
return &ogc_m24_device; return &ogc_m24_device;
} }
int int
machine_xt_olim24_init(const machine_t *model) machine_xt_olim24_init(const machine_t *model)
{ {
@@ -708,7 +726,7 @@ machine_xt_olim24_init(const machine_t *model)
machine_common_init(model); machine_common_init(model);
device_add(&fdc_xt_device); device_add(&fdc_xt_device);
//address 66-67 = mainboard dip-switch settings /* Address 66-67 = mainboard dip-switch settings */
io_sethandler(0x0066, 2, m24_read, NULL, NULL, NULL, NULL, NULL, NULL); io_sethandler(0x0066, 2, m24_read, NULL, NULL, NULL, NULL, NULL, NULL);
m24_kbd_init(m24_kbd); m24_kbd_init(m24_kbd);
@@ -722,7 +740,6 @@ machine_xt_olim24_init(const machine_t *model)
nmi_init(); nmi_init();
return ret; return ret;
} }
@@ -787,7 +804,7 @@ machine_xt_olim19_init(const machine_t *model)
olim19_vid_t *vid; olim19_vid_t *vid;
/* do not move memory allocation elsewhere */ /* Do not move memory allocation elsewhere. */
vid = (olim19_vid_t *)malloc(sizeof(olim19_vid_t)); vid = (olim19_vid_t *)malloc(sizeof(olim19_vid_t));
memset(vid, 0x00, sizeof(olim19_vid_t)); memset(vid, 0x00, sizeof(olim19_vid_t));