mirror of
https://github.com/holub/mame
synced 2025-10-05 00:38:58 +03:00
(MESS) Olivetti M20: improved keyboard and floppy handling [Christian Grössler]
This commit is contained in:
parent
3cb0e21ea3
commit
e28bcc6f74
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1835,6 +1835,8 @@ src/lib/formats/kim1_cas.c svneol=native#text/plain
|
||||
src/lib/formats/kim1_cas.h svneol=native#text/plain
|
||||
src/lib/formats/lviv_lvt.c svneol=native#text/plain
|
||||
src/lib/formats/lviv_lvt.h svneol=native#text/plain
|
||||
src/lib/formats/m20_dsk.c svneol=native#text/plain
|
||||
src/lib/formats/m20_dsk.h svneol=native#text/plain
|
||||
src/lib/formats/m5_dsk.c svneol=native#text/plain
|
||||
src/lib/formats/m5_dsk.h svneol=native#text/plain
|
||||
src/lib/formats/mfi_dsk.c svneol=native#text/plain
|
||||
|
169
src/lib/formats/m20_dsk.c
Normal file
169
src/lib/formats/m20_dsk.c
Normal file
@ -0,0 +1,169 @@
|
||||
/*********************************************************************
|
||||
|
||||
formats/m20_dsk.c
|
||||
|
||||
Olivetti M20 floppy-disk images
|
||||
|
||||
Track 0/head 0 is FM, 128 byte sectors. The rest is MFM,
|
||||
256 byte sectors.
|
||||
In image files the sectors of track 0/sector 0 are 256 bytes
|
||||
long to simplify access. Only the first half of these sectors
|
||||
contain image data.
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "m20_dsk.h"
|
||||
#include "basicdsk.h"
|
||||
|
||||
static FLOPPY_IDENTIFY(m20_dsk_identify)
|
||||
{
|
||||
*vote = (floppy_image_size(floppy) == 286720) ? 100 : 0;
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static int m20_get_heads_per_disk(floppy_image_legacy *floppy)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int m20_get_tracks_per_disk(floppy_image_legacy *floppy)
|
||||
{
|
||||
return 35;
|
||||
}
|
||||
|
||||
static UINT64 m20_translate_offset(floppy_image_legacy *floppy, int track, int head, int sector)
|
||||
{
|
||||
return 256*(32*track+16*head+sector);
|
||||
}
|
||||
|
||||
static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset)
|
||||
{
|
||||
UINT64 offs;
|
||||
/* translate the sector to a raw sector */
|
||||
if (!sector_is_index)
|
||||
{
|
||||
sector -= 1;
|
||||
}
|
||||
|
||||
/* check to see if we are out of range */
|
||||
if ((head < 0) || (head >= 2) || (track < 0) || (track >= 35) || (sector < 0) || (sector >= 16))
|
||||
return FLOPPY_ERROR_SEEKERROR;
|
||||
|
||||
offs = m20_translate_offset(floppy, track, head, sector);
|
||||
if (offset)
|
||||
*offset = offs;
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t internal_m20_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
|
||||
{
|
||||
UINT64 offset;
|
||||
floperr_t err;
|
||||
|
||||
//printf("internal_m20_read_sector: track = %d, head = %d, sector = %d, secisix = %d, buflen = %ld\n", track, head, sector, sector_is_index, (long)buflen);
|
||||
err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
floppy_image_read(floppy, buffer, offset, buflen);
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t internal_m20_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam)
|
||||
{
|
||||
UINT64 offset;
|
||||
floperr_t err;
|
||||
|
||||
err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
floppy_image_write(floppy, buffer, offset, buflen);
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t m20_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
|
||||
{
|
||||
return internal_m20_read_sector(floppy, head, track, sector, FALSE, buffer, buflen);
|
||||
}
|
||||
|
||||
static floperr_t m20_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
|
||||
{
|
||||
return internal_m20_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam);
|
||||
}
|
||||
|
||||
static floperr_t m20_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
|
||||
{
|
||||
return internal_m20_read_sector(floppy, head, track, sector, TRUE, buffer, buflen);
|
||||
}
|
||||
|
||||
static floperr_t m20_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
|
||||
{
|
||||
return internal_m20_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam);
|
||||
}
|
||||
|
||||
static floperr_t m20_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length)
|
||||
{
|
||||
floperr_t err;
|
||||
err = get_offset(floppy, head, track, sector, FALSE, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (sector_length) {
|
||||
if (track == 0 && head == 0)
|
||||
*sector_length = 128;
|
||||
else
|
||||
*sector_length = 256;
|
||||
}
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t m20_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags)
|
||||
{
|
||||
sector_index += 1;
|
||||
if (cylinder)
|
||||
*cylinder = track;
|
||||
if (side)
|
||||
*side = head;
|
||||
if (sector)
|
||||
*sector = sector_index;
|
||||
if (flags)
|
||||
/* TODO: read DAM or DDAM and determine flags */
|
||||
*flags = 0;
|
||||
return m20_get_sector_length(floppy, head, track, sector_index, sector_length);
|
||||
}
|
||||
|
||||
|
||||
static FLOPPY_CONSTRUCT(m20_dsk_construct)
|
||||
{
|
||||
struct FloppyCallbacks *callbacks;
|
||||
callbacks = floppy_callbacks(floppy);
|
||||
callbacks->read_sector = m20_read_sector;
|
||||
callbacks->write_sector = m20_write_sector;
|
||||
callbacks->read_indexed_sector = m20_read_indexed_sector;
|
||||
callbacks->write_indexed_sector = m20_write_indexed_sector;
|
||||
callbacks->get_sector_length = m20_get_sector_length;
|
||||
callbacks->get_heads_per_disk = m20_get_heads_per_disk;
|
||||
callbacks->get_tracks_per_disk = m20_get_tracks_per_disk;
|
||||
callbacks->get_indexed_sector_info = m20_get_indexed_sector_info;
|
||||
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
LEGACY_FLOPPY_OPTIONS_START( m20 )
|
||||
LEGACY_FLOPPY_OPTION(m20_dsk, "img", "M20 disk image", m20_dsk_identify, m20_dsk_construct, NULL, NULL)
|
||||
LEGACY_FLOPPY_OPTIONS_END
|
18
src/lib/formats/m20_dsk.h
Normal file
18
src/lib/formats/m20_dsk.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*********************************************************************
|
||||
|
||||
formats/m20_dsk.c
|
||||
|
||||
Olivetti M20 floppy-disk images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef M20_DSK_H
|
||||
#define M20_DSK_H
|
||||
|
||||
#include "flopimg.h"
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
LEGACY_FLOPPY_OPTIONS_EXTERN(m20);
|
||||
|
||||
#endif /* M20_DSK_H */
|
@ -139,6 +139,7 @@ FORMATSOBJS = \
|
||||
$(LIBOBJ)/formats/kc85_dsk.o \
|
||||
$(LIBOBJ)/formats/kim1_cas.o \
|
||||
$(LIBOBJ)/formats/lviv_lvt.o \
|
||||
$(LIBOBJ)/formats/m20_dsk.o \
|
||||
$(LIBOBJ)/formats/m5_dsk.o \
|
||||
$(LIBOBJ)/formats/mm_dsk.o \
|
||||
$(LIBOBJ)/formats/msx_dsk.o \
|
||||
|
@ -44,7 +44,7 @@ EI1 Vectored interrupt error
|
||||
#include "machine/pit8253.h"
|
||||
#include "machine/pic8259.h"
|
||||
#include "imagedev/flopdrv.h"
|
||||
#include "formats/basicdsk.h"
|
||||
#include "formats/m20_dsk.h"
|
||||
|
||||
#include "machine/keyboard.h"
|
||||
|
||||
@ -307,8 +307,7 @@ static ADDRESS_MAP_START(m20_mem, AS_PROGRAM, 16, m20_state)
|
||||
AM_RANGE( 0xa0000, 0xaffff ) AM_RAM
|
||||
AM_RANGE( 0xb0000, 0xb3fff ) AM_RAM
|
||||
AM_RANGE( 0xc0000, 0xc3fff ) AM_RAM
|
||||
// AM_RANGE( 0x34000, 0x37fff ) AM_RAM //extra vram for bitmap mode
|
||||
// AM_RANGE( 0x20000, 0x2???? ) //work RAM?
|
||||
// AM_RANGE( 0x34000, 0x37fff ) AM_RAM //extra vram for color mode
|
||||
ADDRESS_MAP_END
|
||||
|
||||
static ADDRESS_MAP_START(m20_io, AS_IO, 16, m20_state)
|
||||
@ -336,7 +335,6 @@ static ADDRESS_MAP_START(m20_io, AS_IO, 16, m20_state)
|
||||
|
||||
AM_RANGE(0x140, 0x143) AM_READWRITE(m20_i8259_r, m20_i8259_w)
|
||||
|
||||
// 0x21?? / 0x21? - fdc ... seems to control the screen colors???
|
||||
ADDRESS_MAP_END
|
||||
|
||||
#if 0
|
||||
@ -418,10 +416,10 @@ WRITE_LINE_MEMBER(m20_state::kbd_rxrdy_int)
|
||||
pic8259_ir4_w(machine().device("i8259"), state);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
READ_LINE_MEMBER(m20_state::wd177x_dden_r)
|
||||
{
|
||||
printf ("wd177x_dden_r called, returning %d\n", !m_port21_sd);
|
||||
//printf ("wd177x_dden_r called, returning %d\n", !m_port21_sd);
|
||||
return !m_port21_sd;
|
||||
}
|
||||
#endif
|
||||
@ -459,21 +457,12 @@ static const i8251_interface tty_i8251_intf =
|
||||
|
||||
const wd17xx_interface m20_wd17xx_interface =
|
||||
{
|
||||
DEVCB_NULL, //DEVCB_DRIVER_LINE_MEMBER(m20_state, wd177x_dden_r),
|
||||
/*DEVCB_NULL,*/ DEVCB_DRIVER_LINE_MEMBER(m20_state, wd177x_dden_r),
|
||||
DEVCB_DRIVER_LINE_MEMBER(m20_state, wd177x_intrq_w),
|
||||
DEVCB_NULL,
|
||||
{FLOPPY_0, FLOPPY_1, NULL, NULL}
|
||||
};
|
||||
|
||||
static LEGACY_FLOPPY_OPTIONS_START(m20)
|
||||
LEGACY_FLOPPY_OPTION(m20, "img", "M20 disk image", basicdsk_identify_default, basicdsk_construct_default, NULL,
|
||||
HEADS([2])
|
||||
TRACKS([35])
|
||||
SECTORS([16])
|
||||
SECTOR_LENGTH([256])
|
||||
FIRST_SECTOR_ID([1]))
|
||||
LEGACY_FLOPPY_OPTIONS_END
|
||||
|
||||
static const floppy_interface m20_floppy_interface =
|
||||
{
|
||||
DEVCB_NULL,
|
||||
@ -487,10 +476,31 @@ static const floppy_interface m20_floppy_interface =
|
||||
NULL
|
||||
};
|
||||
|
||||
static unsigned char kbxlat[] =
|
||||
{
|
||||
0x00, '\\', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '-', '^', '@', '[', ';', ':', ']', ',', '.', '/',
|
||||
0x00, '<', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
||||
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
|
||||
};
|
||||
|
||||
WRITE8_MEMBER( m20_state::kbd_put )
|
||||
{
|
||||
if (data) {
|
||||
if (data == 0xd) data = 0xc1;
|
||||
else if (data == 0x20) data = 0xc0;
|
||||
else if (data == 8) data = 0x69; /* ^H */
|
||||
else if (data == 3) data = 0x64; /* ^C */
|
||||
else if (data >= '0' && data <= '9') data += 0x4c - '0';
|
||||
else {
|
||||
int i;
|
||||
for (i = 0; i < sizeof(kbxlat); i++)
|
||||
if (data == kbxlat[i]) {
|
||||
data = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("kbd_put called with 0x%02X\n", data);
|
||||
m_kbdi8251->receive_character(data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user