Some more moving to proper place and compile fix (nw)

This commit is contained in:
Miodrag Milanovic 2013-02-22 11:09:34 +00:00
parent 3509d4c5f9
commit f23413860a
32 changed files with 865 additions and 1079 deletions

12
.gitattributes vendored
View File

@ -6327,26 +6327,14 @@ src/mess/drivers/zexall.c svneol=native#text/plain
src/mess/drivers/zrt80.c svneol=native#text/plain
src/mess/drivers/zsbc3.c svneol=native#text/plain
src/mess/drivers/zx.c svneol=native#text/plain
src/mess/formats/ace_ace.c svneol=native#text/plain
src/mess/formats/ace_ace.h svneol=native#text/plain
src/mess/formats/atom_atm.c svneol=native#text/plain
src/mess/formats/atom_atm.h svneol=native#text/plain
src/mess/formats/cbm_crt.c svneol=native#text/plain
src/mess/formats/cbm_crt.h svneol=native#text/plain
src/mess/formats/cbm_snqk.c svneol=native#text/plain
src/mess/formats/cbm_snqk.h svneol=native#text/plain
src/mess/formats/comx35_comx.c svneol=native#text/plain
src/mess/formats/comx35_comx.h svneol=native#text/plain
src/mess/formats/m65_snqk.c svneol=native#text/plain
src/mess/formats/m65_snqk.h svneol=native#text/plain
src/mess/formats/spec_snqk.c svneol=native#text/plain
src/mess/formats/spec_snqk.h svneol=native#text/plain
src/mess/formats/studio2_st2.c svneol=native#text/plain
src/mess/formats/studio2_st2.h svneol=native#text/plain
src/mess/formats/timex_dck.c svneol=native#text/plain
src/mess/formats/timex_dck.h svneol=native#text/plain
src/mess/formats/trs_cmd.c svneol=native#text/plain
src/mess/formats/trs_cmd.h svneol=native#text/plain
src/mess/formats/z80bin.c svneol=native#text/plain
src/mess/formats/z80bin.h svneol=native#text/plain
src/mess/includes/a7800.h svneol=native#text/plain

View File

@ -42,7 +42,6 @@ Ports:
#include "emu.h"
#include "cpu/z80/z80.h"
#include "formats/ace_ace.h"
#include "formats/ace_tap.h"
#include "imagedev/cassette.h"
#include "imagedev/snapquik.h"
@ -57,6 +56,107 @@ Ports:
#include "includes/ace.h"
/* Load in .ace files. These are memory images of 0x2000 to 0x7fff
and compressed as follows:
ED 00 : End marker
ED <cnt> <byt> : repeat <byt> count <cnt:1-240> times
<byt> : <byt>
*/
/******************************************************************************
Snapshot Handling
******************************************************************************/
SNAPSHOT_LOAD( ace )
{
cpu_device *cpu = image.device().machine().firstcpu;
UINT8 *RAM = image.device().machine().root_device().memregion(cpu->tag())->base();
address_space &space = cpu->space(AS_PROGRAM);
unsigned char ace_repeat, ace_byte, loop;
int done=0, ace_index=0x2000;
if (image.device().machine().device<ram_device>(RAM_TAG)->size() < 16*1024)
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "At least 16KB RAM expansion required");
image.message("At least 16KB RAM expansion required");
return IMAGE_INIT_FAIL;
}
logerror("Loading file %s.\r\n", image.filename());
while (!done && (ace_index < 0x8001))
{
image.fread( &ace_byte, 1);
if (ace_byte == 0xed)
{
image.fread(&ace_byte, 1);
switch (ace_byte)
{
case 0x00:
logerror("File loaded!\r\n");
done = 1;
break;
case 0x01:
image.fread(&ace_byte, 1);
RAM[ace_index++] = ace_byte;
break;
default:
image.fread(&ace_repeat, 1);
for (loop = 0; loop < ace_byte; loop++)
RAM[ace_index++] = ace_repeat;
break;
}
}
else
RAM[ace_index++] = ace_byte;
}
logerror("Decoded %X bytes.\r\n", ace_index-0x2000);
if (!done)
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "EOF marker not found");
image.message("EOF marker not found");
return IMAGE_INIT_FAIL;
}
// patch CPU registers
// Some games do not follow the standard, and have rubbish in the CPU area. So,
// we check that some other bytes are correct.
// 2080 = memory size of original machine, should be 0000 or 8000 or C000.
// 2118 = new stack pointer, do not use if between 8000 and FF00.
ace_index = RAM[0x2080] | (RAM[0x2081] << 8);
if ((ace_index & 0x3FFF)==0)
{
cpu->set_state_int(Z80_AF, RAM[0x2100] | (RAM[0x2101] << 8));
cpu->set_state_int(Z80_BC, RAM[0x2104] | (RAM[0x2105] << 8));
cpu->set_state_int(Z80_DE, RAM[0x2108] | (RAM[0x2109] << 8));
cpu->set_state_int(Z80_HL, RAM[0x210c] | (RAM[0x210d] << 8));
cpu->set_state_int(Z80_IX, RAM[0x2110] | (RAM[0x2111] << 8));
cpu->set_state_int(Z80_IY, RAM[0x2114] | (RAM[0x2115] << 8));
cpu->set_pc(RAM[0x211c] | (RAM[0x211d] << 8));
cpu->set_state_int(Z80_AF2, RAM[0x2120] | (RAM[0x2121] << 8));
cpu->set_state_int(Z80_BC2, RAM[0x2124] | (RAM[0x2125] << 8));
cpu->set_state_int(Z80_DE2, RAM[0x2128] | (RAM[0x2129] << 8));
cpu->set_state_int(Z80_HL2, RAM[0x212c] | (RAM[0x212d] << 8));
cpu->set_state_int(Z80_IM, RAM[0x2130]);
cpu->set_state_int(Z80_IFF1, RAM[0x2134]);
cpu->set_state_int(Z80_IFF2, RAM[0x2138]);
cpu->set_state_int(Z80_I, RAM[0x213c]);
cpu->set_state_int(Z80_R, RAM[0x2140]);
if ((RAM[0x2119] < 0x80) || !ace_index)
cpu->set_state_int(STATE_GENSP, RAM[0x2118] | (RAM[0x2119] << 8));
}
/* Copy data to the address space */
for (ace_index = 0x2000; ace_index < 0x8000; ace_index++)
space.write_byte(ace_index, RAM[ace_index]);
return IMAGE_INIT_PASS;
}
//**************************************************************************
// READ/WRITE HANDLERS

View File

@ -112,6 +112,72 @@ Hardware: PPIA 8255
*/
#include "includes/atom.h"
#include "formats/imageutl.h"
/***************************************************************************
PARAMETERS
***************************************************************************/
#define LOG 1
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
image_fread_memory - read image to memory
-------------------------------------------------*/
static void image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
{
void *ptr = image.device().machine().firstcpu->space(AS_PROGRAM).get_write_ptr(addr);
image.fread( ptr, count);
}
/*-------------------------------------------------
QUICKLOAD_LOAD( atom_atm )
-------------------------------------------------*/
QUICKLOAD_LOAD( atom_atm )
{
/*
The format for the .ATM files is as follows:
Offset Size Description
------ -------- -----------------------------------------------------------
0000h 16 BYTEs ATOM filename (if less than 16 BYTEs, rest is 00h bytes)
0010h WORD Start address for load
0012h WORD Execution address
0014h WORD Size of data in BYTEs
0016h Size Data
*/
UINT8 header[0x16] = { 0 };
image.fread(header, 0x16);
UINT16 start_address = pick_integer_le(header, 0x10, 2);
UINT16 run_address = pick_integer_le(header, 0x12, 2);
UINT16 size = pick_integer_le(header, 0x14, 2);
if (LOG)
{
header[16] = 0;
logerror("ATM filename: %s\n", header);
logerror("ATM start address: %04x\n", start_address);
logerror("ATM run address: %04x\n", run_address);
logerror("ATM size: %04x\n", size);
}
image_fread_memory(image, start_address, size);
image.device().machine().firstcpu->set_pc(run_address);
return IMAGE_INIT_PASS;
}
/***************************************************************************
READ/WRITE HANDLERS

View File

@ -11,8 +11,188 @@
*/
#include "includes/comx35.h"
#include "formats/imageutl.h"
/***************************************************************************
PARAMETERS
***************************************************************************/
#define LOG 1
enum
{
COMX_TYPE_BINARY = 1,
COMX_TYPE_BASIC,
COMX_TYPE_BASIC_FM,
COMX_TYPE_RESERVED,
COMX_TYPE_DATA
};
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
image_fread_memory - read image to memory
-------------------------------------------------*/
static void image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
{
UINT8 *ram = image.device().machine().device<ram_device>(RAM_TAG)->pointer() + (addr - 0x4000);
image.fread(ram, count);
}
/*-------------------------------------------------
QUICKLOAD_LOAD( comx35_comx )
-------------------------------------------------*/
QUICKLOAD_LOAD( comx35_comx )
{
address_space &program = image.device().machine().firstcpu->space(AS_PROGRAM);
UINT8 header[16] = {0};
int size = image.length();
if (size > image.device().machine().device<ram_device>(RAM_TAG)->size())
{
return IMAGE_INIT_FAIL;
}
image.fread( header, 5);
if (header[1] != 'C' || header[2] != 'O' || header[3] != 'M' || header[4] != 'X' )
{
return IMAGE_INIT_FAIL;
}
switch (header[0])
{
case COMX_TYPE_BINARY:
/*
Type 1: pure machine code (i.e. no basic)
Byte 0 to 4: 1 - 'COMX'
Byte 5 and 6: Start address (1802 way; see above)
Byte 6 and 7: End address
Byte 9 and 10: Execution address
Byte 11 to Eof, should be stored in ram from start to end; execution address
'xxxx' for the CALL (@xxxx) basic statement to actually run the code.
*/
{
UINT16 start_address, end_address, run_address;
image.fread(header, 6);
start_address = pick_integer_be(header, 0, 2);
end_address = pick_integer_be(header, 2, 2);
run_address = pick_integer_be(header, 4, 2);
image_fread_memory(image, start_address, end_address - start_address);
popmessage("Type CALL (@%04x) to start program", run_address);
}
break;
case COMX_TYPE_BASIC:
/*
Type 2: Regular basic code or machine code followed by basic
Byte 0 to 4: 2 - 'COMX'
Byte 5 and 6: DEFUS value, to be stored on 0x4281 and 0x4282
Byte 7 and 8: EOP value, to be stored on 0x4283 and 0x4284
Byte 9 and 10: End array, start string to be stored on 0x4292 and 0x4293
Byte 11 and 12: start array to be stored on 0x4294 and 0x4295
Byte 13 and 14: EOD and end string to be stored on 0x4299 and 0x429A
Byte 15 to Eof to be stored on 0x4400 and onwards
Byte 0x4281-0x429A (or at least the ones above) should be set otherwise
BASIC won't 'see' the code.
*/
image_fread_memory(image, 0x4281, 4);
image_fread_memory(image, 0x4292, 4);
image_fread_memory(image, 0x4299, 2);
image_fread_memory(image, 0x4400, size);
break;
case COMX_TYPE_BASIC_FM:
/*
Type 3: F&M basic load
Not the most important! But we designed our own basic extension, you can
find it in the F&M basic folder as F&M Basic.comx. When you run this all
basic code should start at address 0x6700 instead of 0x4400 as from
0x4400-0x6700 the F&M basic stuff is loaded. So format is identical to Type
2 except Byte 15 to Eof should be stored on 0x6700 instead. .comx files of
this format can also be found in the same folder as the F&M basic.comx file.
*/
image_fread_memory(image, 0x4281, 4);
image_fread_memory(image, 0x4292, 4);
image_fread_memory(image, 0x4299, 2);
image_fread_memory(image, 0x6700, size);
break;
case COMX_TYPE_RESERVED:
/*
Type 4: Incorrect DATA format, I suggest to forget this one as it won't work
in most cases. Instead I left this one reserved and designed Type 5 instead.
*/
break;
case COMX_TYPE_DATA:
/*
Type 5: Data load
Byte 0 to 4: 5 - 'COMX'
Byte 5 and 6: Array length
Byte 7 to Eof: Basic 'data'
To load this first get the 'start array' from the running COMX, i.e. address
0x4295/0x4296. Calculate the EOD as 'start array' + length of the data (i.e.
file length - 7). Store the EOD back on 0x4299 and ox429A. Calculate the
'Start String' as 'start array' + 'Array length' (Byte 5 and 6). Store the
'Start String' on 0x4292/0x4293. Load byte 7 and onwards starting from the
'start array' value fetched from 0x4295/0x4296.
*/
{
UINT16 start_array, end_array, start_string, array_length;
image.fread(header, 2);
array_length = pick_integer_be(header, 0, 2);
start_array = (program.read_byte(0x4295) << 8) | program.read_byte(0x4296);
end_array = start_array + (size - 7);
program.write_byte(0x4299, end_array >> 8);
program.write_byte(0x429a, end_array & 0xff);
start_string = start_array + array_length;
program.write_byte(0x4292, start_string >> 8);
program.write_byte(0x4293, start_string & 0xff);
image_fread_memory(image, start_array, size);
}
break;
}
return IMAGE_INIT_PASS;
}
//**************************************************************************
// MEMORY ACCESS

View File

@ -13,7 +13,7 @@
#include "cpu/m6502/m6504.h"
#include "cpu/cop400/cop400.h"
#include "includes/lisa.h"
#include "devices/sonydriv.h"
#include "machine/sonydriv.h"
#include "machine/applefdc.h"
#include "formats/ap_dsk35.h"
#include "machine/6522via.h"

View File

@ -51,7 +51,7 @@
#include "machine/ncr5380.h"
#include "machine/applefdc.h"
#include "machine/swim.h"
#include "devices/sonydriv.h"
#include "machine/sonydriv.h"
#include "formats/ap_dsk35.h"
#include "machine/ram.h"
#include "machine/scsibus.h"

View File

@ -49,7 +49,6 @@
/* Devices */
#include "imagedev/cassette.h"
#include "formats/m65_snqk.h"
static ADDRESS_MAP_START( microtan_map, AS_PROGRAM, 8, microtan_state )

View File

@ -200,6 +200,82 @@ Notes:
#include "includes/studio2.h"
/***************************************************************************
PARAMETERS
***************************************************************************/
#define LOG 1
#define ST2_BLOCK_SIZE 256
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
struct st2_header
{
UINT8 header[4]; /* "RCA2" in ASCII code */
UINT8 blocks; /* Total number of 256 byte blocks in file (including this one) */
UINT8 format; /* Format Code (this is format number 1) */
UINT8 video; /* If non-zero uses a special video driver, and programs cannot assume that it uses the standard Studio 2 one (top of screen at $0900+RB.0). A value of '1' here indicates the RAM is used normally, but scrolling is not (e.g. the top of the page is always at $900) */
UINT8 reserved0;
UINT8 author[2]; /* 2 byte ASCII code indicating the identity of the program coder */
UINT8 dumper[2]; /* 2 byte ASCII code indicating the identity of the ROM Source */
UINT8 reserved1[4];
UINT8 catalogue[10]; /* RCA Catalogue Code as ASCIIZ string. If a homebrew ROM, may contain any identifying code you wish */
UINT8 reserved2[6];
UINT8 title[32]; /* Cartridge Program Title as ASCIIZ string */
UINT8 page[64]; /* Contain the page addresses for each 256 byte block. The first byte at 64, contains the target address of the data at offset 256, the second byte contains the target address of the data at offset 512, and so on. Unused block bytes should be filled with $00 (an invalid page address). So, if byte 64 contains $1C, the ROM is paged into memory from $1C00-$1CFF */
UINT8 reserved3[128];
};
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
DEVICE_IMAGE_LOAD( st2_cartslot_load )
-------------------------------------------------*/
DEVICE_IMAGE_LOAD_LEGACY( st2_cartslot_load )
{
st2_header header;
/* check file size */
int filesize = image.length();
if (filesize <= ST2_BLOCK_SIZE) {
logerror("Error loading cartridge: Invalid ROM file: %s.\n", image.filename());
return IMAGE_INIT_FAIL;
}
/* read ST2 header */
if (image.fread( &header, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
logerror("Error loading cartridge: Unable to read header from file: %s.\n", image.filename());
return IMAGE_INIT_FAIL;
}
if (LOG) logerror("ST2 Catalogue: %s\n", header.catalogue);
if (LOG) logerror("ST2 Title: %s\n", header.title);
/* read ST2 cartridge into memory */
for (int block = 0; block < (header.blocks - 1); block++)
{
UINT16 offset = header.page[block] << 8;
UINT8 *ptr = ((UINT8 *) image.device().machine().root_device().memregion(CDP1802_TAG)->base()) + offset;
if (LOG) logerror("ST2 Reading block %u to %04x\n", block, offset);
if (image.fread( ptr, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
logerror("Error loading cartridge: Unable to read contents from file: %s.\n", image.filename());
return IMAGE_INIT_FAIL;
}
}
return IMAGE_INIT_PASS;
}
/* Read/Write Handlers */
WRITE8_MEMBER( studio2_state::keylatch_w )

View File

@ -1,114 +0,0 @@
/*********************************************************************
ace_ace.c
Format code for Jupiter Ace snapshot files
*********************************************************************/
#include "emu.h"
#include "ace_ace.h"
#include "cpu/z80/z80.h"
#include "machine/ram.h"
/* Load in .ace files. These are memory images of 0x2000 to 0x7fff
and compressed as follows:
ED 00 : End marker
ED <cnt> <byt> : repeat <byt> count <cnt:1-240> times
<byt> : <byt>
*/
/******************************************************************************
Snapshot Handling
******************************************************************************/
SNAPSHOT_LOAD( ace )
{
cpu_device *cpu = image.device().machine().firstcpu;
UINT8 *RAM = image.device().machine().root_device().memregion(cpu->tag())->base();
address_space &space = cpu->space(AS_PROGRAM);
unsigned char ace_repeat, ace_byte, loop;
int done=0, ace_index=0x2000;
if (image.device().machine().device<ram_device>(RAM_TAG)->size() < 16*1024)
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "At least 16KB RAM expansion required");
image.message("At least 16KB RAM expansion required");
return IMAGE_INIT_FAIL;
}
logerror("Loading file %s.\r\n", image.filename());
while (!done && (ace_index < 0x8001))
{
image.fread( &ace_byte, 1);
if (ace_byte == 0xed)
{
image.fread(&ace_byte, 1);
switch (ace_byte)
{
case 0x00:
logerror("File loaded!\r\n");
done = 1;
break;
case 0x01:
image.fread(&ace_byte, 1);
RAM[ace_index++] = ace_byte;
break;
default:
image.fread(&ace_repeat, 1);
for (loop = 0; loop < ace_byte; loop++)
RAM[ace_index++] = ace_repeat;
break;
}
}
else
RAM[ace_index++] = ace_byte;
}
logerror("Decoded %X bytes.\r\n", ace_index-0x2000);
if (!done)
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "EOF marker not found");
image.message("EOF marker not found");
return IMAGE_INIT_FAIL;
}
// patch CPU registers
// Some games do not follow the standard, and have rubbish in the CPU area. So,
// we check that some other bytes are correct.
// 2080 = memory size of original machine, should be 0000 or 8000 or C000.
// 2118 = new stack pointer, do not use if between 8000 and FF00.
ace_index = RAM[0x2080] | (RAM[0x2081] << 8);
if ((ace_index & 0x3FFF)==0)
{
cpu->set_state_int(Z80_AF, RAM[0x2100] | (RAM[0x2101] << 8));
cpu->set_state_int(Z80_BC, RAM[0x2104] | (RAM[0x2105] << 8));
cpu->set_state_int(Z80_DE, RAM[0x2108] | (RAM[0x2109] << 8));
cpu->set_state_int(Z80_HL, RAM[0x210c] | (RAM[0x210d] << 8));
cpu->set_state_int(Z80_IX, RAM[0x2110] | (RAM[0x2111] << 8));
cpu->set_state_int(Z80_IY, RAM[0x2114] | (RAM[0x2115] << 8));
cpu->set_pc(RAM[0x211c] | (RAM[0x211d] << 8));
cpu->set_state_int(Z80_AF2, RAM[0x2120] | (RAM[0x2121] << 8));
cpu->set_state_int(Z80_BC2, RAM[0x2124] | (RAM[0x2125] << 8));
cpu->set_state_int(Z80_DE2, RAM[0x2128] | (RAM[0x2129] << 8));
cpu->set_state_int(Z80_HL2, RAM[0x212c] | (RAM[0x212d] << 8));
cpu->set_state_int(Z80_IM, RAM[0x2130]);
cpu->set_state_int(Z80_IFF1, RAM[0x2134]);
cpu->set_state_int(Z80_IFF2, RAM[0x2138]);
cpu->set_state_int(Z80_I, RAM[0x213c]);
cpu->set_state_int(Z80_R, RAM[0x2140]);
if ((RAM[0x2119] < 0x80) || !ace_index)
cpu->set_state_int(STATE_GENSP, RAM[0x2118] | (RAM[0x2119] << 8));
}
/* Copy data to the address space */
for (ace_index = 0x2000; ace_index < 0x8000; ace_index++)
space.write_byte(ace_index, RAM[ace_index]);
return IMAGE_INIT_PASS;
}

View File

@ -1,18 +0,0 @@
/*********************************************************************
ace_ace.h
Format code for Jupiter Ace snapshot files
*********************************************************************/
#pragma once
#ifndef ACE_ACE_H
#define ACE_ACE_H
#include "imagedev/snapquik.h"
SNAPSHOT_LOAD( ace );
#endif /* ACE_ACE_H */

View File

@ -1,76 +0,0 @@
/*********************************************************************
formats/atom_atm.c
Quickload code for Acorn Atom atm files
*********************************************************************/
#include "emu.h"
#include "formats/imageutl.h"
#include "formats/atom_atm.h"
/***************************************************************************
PARAMETERS
***************************************************************************/
#define LOG 1
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
image_fread_memory - read image to memory
-------------------------------------------------*/
static void image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
{
void *ptr = image.device().machine().firstcpu->space(AS_PROGRAM).get_write_ptr(addr);
image.fread( ptr, count);
}
/*-------------------------------------------------
QUICKLOAD_LOAD( atom_atm )
-------------------------------------------------*/
QUICKLOAD_LOAD( atom_atm )
{
/*
The format for the .ATM files is as follows:
Offset Size Description
------ -------- -----------------------------------------------------------
0000h 16 BYTEs ATOM filename (if less than 16 BYTEs, rest is 00h bytes)
0010h WORD Start address for load
0012h WORD Execution address
0014h WORD Size of data in BYTEs
0016h Size Data
*/
UINT8 header[0x16] = { 0 };
image.fread(header, 0x16);
UINT16 start_address = pick_integer_le(header, 0x10, 2);
UINT16 run_address = pick_integer_le(header, 0x12, 2);
UINT16 size = pick_integer_le(header, 0x14, 2);
if (LOG)
{
header[16] = 0;
logerror("ATM filename: %s\n", header);
logerror("ATM start address: %04x\n", start_address);
logerror("ATM run address: %04x\n", run_address);
logerror("ATM size: %04x\n", size);
}
image_fread_memory(image, start_address, size);
image.device().machine().firstcpu->set_pc(run_address);
return IMAGE_INIT_PASS;
}

View File

@ -1,19 +0,0 @@
/*********************************************************************
formats/atom_atm.h
Quickload code for Acorn Atom atm files
*********************************************************************/
#pragma once
#ifndef __ATOM_ATM__
#define __ATOM_ATM__
#include "emu.h"
#include "imagedev/snapquik.h"
QUICKLOAD_LOAD( atom_atm );
#endif

View File

@ -1,192 +0,0 @@
/*********************************************************************
formats/comx35_comx.c
Quickload code for COMX-35 comx files
*********************************************************************/
#include "emu.h"
#include "formats/imageutl.h"
#include "formats/comx35_comx.h"
#include "machine/ram.h"
/***************************************************************************
PARAMETERS
***************************************************************************/
#define LOG 1
enum
{
COMX_TYPE_BINARY = 1,
COMX_TYPE_BASIC,
COMX_TYPE_BASIC_FM,
COMX_TYPE_RESERVED,
COMX_TYPE_DATA
};
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
image_fread_memory - read image to memory
-------------------------------------------------*/
static void image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
{
UINT8 *ram = image.device().machine().device<ram_device>(RAM_TAG)->pointer() + (addr - 0x4000);
image.fread(ram, count);
}
/*-------------------------------------------------
QUICKLOAD_LOAD( comx35_comx )
-------------------------------------------------*/
QUICKLOAD_LOAD( comx35_comx )
{
address_space &program = image.device().machine().firstcpu->space(AS_PROGRAM);
UINT8 header[16] = {0};
int size = image.length();
if (size > image.device().machine().device<ram_device>(RAM_TAG)->size())
{
return IMAGE_INIT_FAIL;
}
image.fread( header, 5);
if (header[1] != 'C' || header[2] != 'O' || header[3] != 'M' || header[4] != 'X' )
{
return IMAGE_INIT_FAIL;
}
switch (header[0])
{
case COMX_TYPE_BINARY:
/*
Type 1: pure machine code (i.e. no basic)
Byte 0 to 4: 1 - 'COMX'
Byte 5 and 6: Start address (1802 way; see above)
Byte 6 and 7: End address
Byte 9 and 10: Execution address
Byte 11 to Eof, should be stored in ram from start to end; execution address
'xxxx' for the CALL (@xxxx) basic statement to actually run the code.
*/
{
UINT16 start_address, end_address, run_address;
image.fread(header, 6);
start_address = pick_integer_be(header, 0, 2);
end_address = pick_integer_be(header, 2, 2);
run_address = pick_integer_be(header, 4, 2);
image_fread_memory(image, start_address, end_address - start_address);
popmessage("Type CALL (@%04x) to start program", run_address);
}
break;
case COMX_TYPE_BASIC:
/*
Type 2: Regular basic code or machine code followed by basic
Byte 0 to 4: 2 - 'COMX'
Byte 5 and 6: DEFUS value, to be stored on 0x4281 and 0x4282
Byte 7 and 8: EOP value, to be stored on 0x4283 and 0x4284
Byte 9 and 10: End array, start string to be stored on 0x4292 and 0x4293
Byte 11 and 12: start array to be stored on 0x4294 and 0x4295
Byte 13 and 14: EOD and end string to be stored on 0x4299 and 0x429A
Byte 15 to Eof to be stored on 0x4400 and onwards
Byte 0x4281-0x429A (or at least the ones above) should be set otherwise
BASIC won't 'see' the code.
*/
image_fread_memory(image, 0x4281, 4);
image_fread_memory(image, 0x4292, 4);
image_fread_memory(image, 0x4299, 2);
image_fread_memory(image, 0x4400, size);
break;
case COMX_TYPE_BASIC_FM:
/*
Type 3: F&M basic load
Not the most important! But we designed our own basic extension, you can
find it in the F&M basic folder as F&M Basic.comx. When you run this all
basic code should start at address 0x6700 instead of 0x4400 as from
0x4400-0x6700 the F&M basic stuff is loaded. So format is identical to Type
2 except Byte 15 to Eof should be stored on 0x6700 instead. .comx files of
this format can also be found in the same folder as the F&M basic.comx file.
*/
image_fread_memory(image, 0x4281, 4);
image_fread_memory(image, 0x4292, 4);
image_fread_memory(image, 0x4299, 2);
image_fread_memory(image, 0x6700, size);
break;
case COMX_TYPE_RESERVED:
/*
Type 4: Incorrect DATA format, I suggest to forget this one as it won't work
in most cases. Instead I left this one reserved and designed Type 5 instead.
*/
break;
case COMX_TYPE_DATA:
/*
Type 5: Data load
Byte 0 to 4: 5 - 'COMX'
Byte 5 and 6: Array length
Byte 7 to Eof: Basic 'data'
To load this first get the 'start array' from the running COMX, i.e. address
0x4295/0x4296. Calculate the EOD as 'start array' + length of the data (i.e.
file length - 7). Store the EOD back on 0x4299 and ox429A. Calculate the
'Start String' as 'start array' + 'Array length' (Byte 5 and 6). Store the
'Start String' on 0x4292/0x4293. Load byte 7 and onwards starting from the
'start array' value fetched from 0x4295/0x4296.
*/
{
UINT16 start_array, end_array, start_string, array_length;
image.fread(header, 2);
array_length = pick_integer_be(header, 0, 2);
start_array = (program.read_byte(0x4295) << 8) | program.read_byte(0x4296);
end_array = start_array + (size - 7);
program.write_byte(0x4299, end_array >> 8);
program.write_byte(0x429a, end_array & 0xff);
start_string = start_array + array_length;
program.write_byte(0x4292, start_string >> 8);
program.write_byte(0x4293, start_string & 0xff);
image_fread_memory(image, start_array, size);
}
break;
}
return IMAGE_INIT_PASS;
}

View File

@ -1,19 +0,0 @@
/*********************************************************************
formats/comx35_comx.h
Quickload code for COMX-35 comx files
*********************************************************************/
#pragma once
#ifndef __COMX35_COMX__
#define __COMX35_COMX__
#include "emu.h"
#include "imagedev/snapquik.h"
QUICKLOAD_LOAD( comx35_comx );
#endif

View File

@ -1,372 +0,0 @@
/******************************************************************************
* Microtan 65
*
* Snapshot and quickload formats
*
* Juergen Buchmueller <pullmoll@t-online.de>, Jul 2000
*
* Thanks go to Geoff Macdonald <mail@geoff.org.uk>
* for his site http:://www.geo255.redhotant.com
* and to Fabrice Frances <frances@ensica.fr>
* for his site http://www.ifrance.com/oric/microtan.html
*
*****************************************************************************/
#include "emu.h"
#include "cpu/m6502/m6502.h"
#include "includes/microtan.h"
#include "machine/6522via.h"
#include "machine/mos6551.h"
#include "sound/ay8910.h"
#include "formats/m65_snqk.h"
static int microtan_verify_snapshot(UINT8 *data, int size)
{
if (size == 8263)
{
logerror("microtan_snapshot_id: magic size %d found\n", size);
return IMAGE_VERIFY_PASS;
}
else
{
if (4 + data[2] + 256 * data[3] + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 == size)
{
logerror("microtan_snapshot_id: header RAM size + structures matches filesize %d\n", size);
return IMAGE_VERIFY_PASS;
}
}
return IMAGE_VERIFY_FAIL;
}
static int parse_intel_hex(UINT8 *snapshot_buff, char *src)
{
char line[128];
int /*row = 0,*/ column = 0, last_addr = 0, last_size = 0;
while (*src)
{
if (*src == '\r' || *src == '\n')
{
if (column)
{
unsigned int size, addr, null, b[32], cs, n;
line[column] = '\0';
/*row++;*/
n = sscanf(line, ":%02x%04x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
&size, &addr, &null,
&b[ 0], &b[ 1], &b[ 2], &b[ 3], &b[ 4], &b[ 5], &b[ 6], &b[ 7],
&b[ 8], &b[ 9], &b[10], &b[11], &b[12], &b[13], &b[14], &b[15],
&b[16], &b[17], &b[18], &b[19], &b[20], &b[21], &b[22], &b[23],
&b[24], &b[25], &b[26], &b[27], &b[28], &b[29], &b[30], &b[31],
&cs);
if (n == 0)
{
logerror("parse_intel_hex: malformed line [%s]\n", line);
}
else if (n == 1)
{
logerror("parse_intel_hex: only size found [%s]\n", line);
}
else if (n == 2)
{
logerror("parse_intel_hex: only size and addr found [%s]\n", line);
}
else if (n == 3)
{
logerror("parse_intel_hex: only size, addr and null found [%s]\n", line);
}
else
if (null != 0)
{
logerror("parse_intel_hex: warning null byte is != 0 [%s]\n", line);
}
else
{
int i, sum;
n -= 3;
sum = size + (addr & 0xff) + ((addr >> 8) & 0xff);
if (n != 32 + 1)
cs = b[n-1];
last_addr = addr;
last_size = n-1;
logerror("parse_intel_hex: %04X", addr);
for (i = 0; i < n-1; i++)
{
sum += b[i];
snapshot_buff[addr++] = b[i];
}
logerror("-%04X checksum %02X+%02X = %02X\n", addr-1, cs, sum & 0xff, (cs + sum) & 0xff);
}
}
column = 0;
}
else
{
line[column++] = *src;
}
src++;
}
/* register preset? */
if (last_size == 7)
{
logerror("parse_intel_hex: registers (?) at %04X\n", last_addr);
memcpy(&snapshot_buff[8192+64], &snapshot_buff[last_addr], last_size);
}
return IMAGE_INIT_PASS;
}
static int parse_zillion_hex(UINT8 *snapshot_buff, char *src)
{
char line[128];
int parsing = 0, /*row = 0,*/ column = 0;
while (*src)
{
if (parsing)
{
if (*src == '}')
parsing = 0;
else
{
if (*src == '\r' || *src == '\n')
{
if (column)
{
unsigned int addr, b[8], n;
line[column] = '\0';
/*row++;*/
n = sscanf(line, "%x %x %x %x %x %x %x %x %x", &addr, &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], &b[6], &b[7]);
if (n == 0)
{
logerror("parse_zillion_hex: malformed line [%s]\n", line);
}
else if (n == 1)
{
logerror("parse_zillion_hex: only addr found [%s]\n", line);
}
else
{
int i;
logerror("parse_zillion_hex: %04X", addr);
for (i = 0; i < n-1; i++)
snapshot_buff[addr++] = b[i];
logerror("-%04X\n", addr-1);
}
}
column = 0;
}
else
{
line[column++] = *src;
}
}
}
else
{
if (*src == '\r' || *src == '\n')
{
if (column)
{
int addr, n;
/*row++;*/
line[column] = '\0';
n = sscanf(line, "G%x", (unsigned int *) &addr);
if (n == 1 && !snapshot_buff[8192+64+0] && !snapshot_buff[8192+64+1])
{
logerror("microtan_hexfile_init: go addr %04X\n", addr);
snapshot_buff[8192+64+0] = addr & 0xff;
snapshot_buff[8192+64+1] = (addr >> 8) & 0xff;
}
}
column = 0;
}
else
{
line[column++] = *src;
}
if (*src == '{')
{
parsing = 1;
column = 0;
}
}
src++;
}
return IMAGE_INIT_PASS;
}
static void microtan_set_cpu_regs(running_machine &machine,const UINT8 *snapshot_buff, int base)
{
logerror("microtan_snapshot_copy: PC:%02X%02X P:%02X A:%02X X:%02X Y:%02X SP:1%02X",
snapshot_buff[base+1], snapshot_buff[base+0], snapshot_buff[base+2], snapshot_buff[base+3],
snapshot_buff[base+4], snapshot_buff[base+5], snapshot_buff[base+6]);
machine.device("maincpu")->state().set_state_int(M6502_PC, snapshot_buff[base+0] + 256 * snapshot_buff[base+1]);
machine.device("maincpu")->state().set_state_int(M6502_P, snapshot_buff[base+2]);
machine.device("maincpu")->state().set_state_int(M6502_A, snapshot_buff[base+3]);
machine.device("maincpu")->state().set_state_int(M6502_X, snapshot_buff[base+4]);
machine.device("maincpu")->state().set_state_int(M6502_Y, snapshot_buff[base+5]);
machine.device("maincpu")->state().set_state_int(M6502_S, snapshot_buff[base+6]);
}
static void microtan_snapshot_copy(running_machine &machine, UINT8 *snapshot_buff, int snapshot_size)
{
microtan_state *state = machine.driver_data<microtan_state>();
UINT8 *RAM = state->memregion("maincpu")->base();
address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
via6522_device *via_1 = machine.device<via6522_device>("via6522_1");
device_t *ay8910 = machine.device("ay8910.1");
/* check for .DMP file format */
if (snapshot_size == 8263)
{
int i, base;
/********** DMP format
* Lower 8k of RAM (0000 to 1fff)
* 64 bytes of chunky graphics bits (first byte bit is for character at 0200, bit 1=0201, etc)
* 7 bytes of CPU registers (PCL, PCH, PSW, A, IX, IY, SP)
*/
logerror("microtan_snapshot_copy: magic size %d found, assuming *.DMP format\n", snapshot_size);
base = 0;
/* 8K of RAM from 0000 to 1fff */
memcpy(RAM, &snapshot_buff[base], 8192);
base += 8192;
/* 64 bytes of chunky graphics info */
for (i = 0; i < 32*16; i++)
{
state->m_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
}
base += 64;
microtan_set_cpu_regs(machine, snapshot_buff, base);
}
else
{
int i, ramend, base;
/********** M65 format ************************************
* 2 bytes: File version
* 2 bytes: RAM size
* n bytes: RAM (0000 to RAM Size)
* 16 bytes: 1st 6522 (0xbfc0 to 0xbfcf)
* 16 bytes: 2ns 6522 (0xbfe0 to 0xbfef)
* 16 bytes: Microtan IO (0xbff0 to 0xbfff)
* 1 byte : Invaders sound (0xbc04)
* 1 byte : Chunky graphics state (0=off, 1=on)
* 16 bytes: 1st AY8910 registers
* 16 bytes: 2nd AY8910 registers
* 64 bytes: Chunky graphics bits (first byte bit 0 is for character at 0200, bit 1=0201, etc)
* 7 bytes: CPU registers (PCL, PCH, PSW, A, IX, IY, SP)
*/
ramend = snapshot_buff[2] + 256 * snapshot_buff[3];
if (2 + 2 + ramend + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 != snapshot_size)
{
logerror("microtan_snapshot_copy: size %d doesn't match RAM size %d + structure size\n", snapshot_size, ramend+1);
return;
}
logerror("microtan_snapshot_copy: size %d found, assuming *.M65 format\n", snapshot_size);
base = 4;
memcpy(RAM, &snapshot_buff[base], snapshot_buff[2] + 256 * snapshot_buff[3] + 1);
base += ramend + 1;
/* first set of VIA6522 registers */
for (i = 0; i < 16; i++ )
via_0->write(space, i, snapshot_buff[base++]);
/* second set of VIA6522 registers */
for (i = 0; i < 16; i++ )
via_1->write(space, i, snapshot_buff[base++]);
/* microtan IO bff0-bfff */
for (i = 0; i < 16; i++ )
{
RAM[0xbff0+i] = snapshot_buff[base++];
if (i < 4)
state->microtan_bffx_w(space, i, RAM[0xbff0+i]);
}
state->microtan_sound_w(space, 0, snapshot_buff[base++]);
state->m_chunky_graphics = snapshot_buff[base++];
/* first set of AY8910 registers */
for (i = 0; i < 16; i++ )
{
ay8910_address_w(ay8910, state->generic_space(), 0, i);
ay8910_data_w(ay8910, state->generic_space(), 0, snapshot_buff[base++]);
}
/* second set of AY8910 registers */
for (i = 0; i < 16; i++ )
{
ay8910_address_w(ay8910, state->generic_space(), 0, i);
ay8910_data_w(ay8910, state->generic_space(), 0, snapshot_buff[base++]);
}
for (i = 0; i < 32*16; i++)
{
state->m_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
}
base += 64;
microtan_set_cpu_regs(machine, snapshot_buff, base);
}
}
SNAPSHOT_LOAD( microtan )
{
UINT8 *snapshot_buff;
snapshot_buff = (UINT8*)image.ptr();
if (!snapshot_buff)
return IMAGE_INIT_FAIL;
if (microtan_verify_snapshot(snapshot_buff, snapshot_size)==IMAGE_VERIFY_FAIL)
return IMAGE_INIT_FAIL;
microtan_snapshot_copy(image.device().machine(), snapshot_buff, snapshot_size);
return IMAGE_INIT_PASS;
}
QUICKLOAD_LOAD( microtan )
{
int snapshot_size;
UINT8 *snapshot_buff;
char *buff;
int rc;
snapshot_size = 8263; /* magic size */
snapshot_buff = (UINT8*)malloc(snapshot_size);
if (!snapshot_buff)
{
logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", snapshot_size);
return IMAGE_INIT_FAIL;
}
memset(snapshot_buff, 0, snapshot_size);
buff = (char*)malloc(quickload_size + 1);
if (!buff)
{
free(snapshot_buff);
logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", quickload_size);
return IMAGE_INIT_FAIL;
}
image.fread( buff, quickload_size);
buff[quickload_size] = '\0';
if (buff[0] == ':')
rc = parse_intel_hex(snapshot_buff, buff);
else
rc = parse_zillion_hex(snapshot_buff, buff);
if (rc == IMAGE_INIT_PASS)
microtan_snapshot_copy(image.device().machine(), snapshot_buff, snapshot_size);
free(snapshot_buff);
return rc;
}

View File

@ -1,23 +0,0 @@
/******************************************************************************
* Microtan 65
*
* Snapshot and quickload formats
*
* Juergen Buchmueller <pullmoll@t-online.de>, Jul 2000
*
* Thanks go to Geoff Macdonald <mail@geoff.org.uk>
* for his site http:://www.geo255.redhotant.com
* and to Fabrice Frances <frances@ensica.fr>
* for his site http://www.ifrance.com/oric/microtan.html
*
*****************************************************************************/
#ifndef __M65_SNQK_H__
#define __M65_SNQK_H__
#include "imagedev/snapquik.h"
SNAPSHOT_LOAD( microtan );
QUICKLOAD_LOAD( microtan );
#endif /* __M65_SNQK_H__ */

View File

@ -1,86 +0,0 @@
/*********************************************************************
formats/studio2_st2.c
Cartridge code for RCA Studio II st2 files
*********************************************************************/
#include "emu.h"
#include "includes/studio2.h"
#include "formats/studio2_st2.h"
/***************************************************************************
PARAMETERS
***************************************************************************/
#define LOG 1
#define ST2_BLOCK_SIZE 256
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
struct st2_header
{
UINT8 header[4]; /* "RCA2" in ASCII code */
UINT8 blocks; /* Total number of 256 byte blocks in file (including this one) */
UINT8 format; /* Format Code (this is format number 1) */
UINT8 video; /* If non-zero uses a special video driver, and programs cannot assume that it uses the standard Studio 2 one (top of screen at $0900+RB.0). A value of '1' here indicates the RAM is used normally, but scrolling is not (e.g. the top of the page is always at $900) */
UINT8 reserved0;
UINT8 author[2]; /* 2 byte ASCII code indicating the identity of the program coder */
UINT8 dumper[2]; /* 2 byte ASCII code indicating the identity of the ROM Source */
UINT8 reserved1[4];
UINT8 catalogue[10]; /* RCA Catalogue Code as ASCIIZ string. If a homebrew ROM, may contain any identifying code you wish */
UINT8 reserved2[6];
UINT8 title[32]; /* Cartridge Program Title as ASCIIZ string */
UINT8 page[64]; /* Contain the page addresses for each 256 byte block. The first byte at 64, contains the target address of the data at offset 256, the second byte contains the target address of the data at offset 512, and so on. Unused block bytes should be filled with $00 (an invalid page address). So, if byte 64 contains $1C, the ROM is paged into memory from $1C00-$1CFF */
UINT8 reserved3[128];
};
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
DEVICE_IMAGE_LOAD( st2_cartslot_load )
-------------------------------------------------*/
DEVICE_IMAGE_LOAD_LEGACY( st2_cartslot_load )
{
st2_header header;
/* check file size */
int filesize = image.length();
if (filesize <= ST2_BLOCK_SIZE) {
logerror("Error loading cartridge: Invalid ROM file: %s.\n", image.filename());
return IMAGE_INIT_FAIL;
}
/* read ST2 header */
if (image.fread( &header, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
logerror("Error loading cartridge: Unable to read header from file: %s.\n", image.filename());
return IMAGE_INIT_FAIL;
}
if (LOG) logerror("ST2 Catalogue: %s\n", header.catalogue);
if (LOG) logerror("ST2 Title: %s\n", header.title);
/* read ST2 cartridge into memory */
for (int block = 0; block < (header.blocks - 1); block++)
{
UINT16 offset = header.page[block] << 8;
UINT8 *ptr = ((UINT8 *) image.device().machine().root_device().memregion(CDP1802_TAG)->base()) + offset;
if (LOG) logerror("ST2 Reading block %u to %04x\n", block, offset);
if (image.fread( ptr, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
logerror("Error loading cartridge: Unable to read contents from file: %s.\n", image.filename());
return IMAGE_INIT_FAIL;
}
}
return IMAGE_INIT_PASS;
}

View File

@ -1,18 +0,0 @@
/*********************************************************************
formats/studio2_St2.h
Cartridge code for RCA Studio II st2 files
*********************************************************************/
#pragma once
#ifndef __STUDIO2_ST2__
#define __STUDIO2_ST2__
#include "emu.h"
DEVICE_IMAGE_LOAD_LEGACY( st2_cartslot_load );
#endif

View File

@ -1,91 +0,0 @@
/*********************************************************************
formats/trs_cmd.c
Quickload code for TRS-80 /CMD files
*********************************************************************/
#include "emu.h"
#include "formats/trs_cmd.h"
#include "cpu/z80/z80.h"
/***************************************************************************
PARAMETERS
***************************************************************************/
#define LOG 1
#define CMD_TYPE_OBJECT_CODE 0x01
#define CMD_TYPE_TRANSFER_ADDRESS 0x02
#define CMD_TYPE_END_OF_PARTITIONED_DATA_SET_MEMBER 0x04
#define CMD_TYPE_LOAD_MODULE_HEADER 0x05
#define CMD_TYPE_PARTITIONED_DATA_SET_HEADER 0x06
#define CMD_TYPE_PATCH_NAME_HEADER 0x07
#define CMD_TYPE_ISAM_DIRECTORY_ENTRY 0x08
#define CMD_TYPE_END_OF_ISAM_DIRECTORY_ENTRY 0x0a
#define CMD_TYPE_PDS_DIRECTORY_ENTRY 0x0c
#define CMD_TYPE_END_OF_PDS_DIRECTORY_ENTRY 0x0e
#define CMD_TYPE_YANKED_LOAD_BLOCK 0x10
#define CMD_TYPE_COPYRIGHT_BLOCK 0x1f
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
QUICKLOAD_LOAD( trs80_cmd )
{
address_space &program = image.device().machine().firstcpu->space(AS_PROGRAM);
UINT8 type, length;
UINT8 data[0x100];
UINT8 addr[2];
void *ptr;
while (!image.image_feof())
{
image.fread( &type, 1);
image.fread( &length, 1);
length -= 2;
int block_length = length ? length : 256;
switch (type)
{
case CMD_TYPE_OBJECT_CODE:
{
image.fread( &addr, 2);
UINT16 address = (addr[1] << 8) | addr[0];
if (LOG) logerror("/CMD object code block: address %04x length %u\n", address, block_length);
ptr = program.get_write_ptr(address);
image.fread( ptr, block_length);
}
break;
case CMD_TYPE_TRANSFER_ADDRESS:
{
image.fread( &addr, 2);
UINT16 address = (addr[1] << 8) | addr[0];
if (LOG) logerror("/CMD transfer address %04x\n", address);
image.device().machine().firstcpu->set_state_int(Z80_PC, address);
}
break;
case CMD_TYPE_LOAD_MODULE_HEADER:
image.fread( &data, block_length);
if (LOG) logerror("/CMD load module header '%s'\n", data);
break;
case CMD_TYPE_COPYRIGHT_BLOCK:
image.fread( &data, block_length);
if (LOG) logerror("/CMD copyright block '%s'\n", data);
break;
default:
image.fread( &data, block_length);
logerror("/CMD unsupported block type %u!\n", type);
}
}
return IMAGE_INIT_PASS;
}

View File

@ -1,19 +0,0 @@
/*********************************************************************
formats/trs_cmd.h
Quickload code for TRS-80 /CMD files
*********************************************************************/
#pragma once
#ifndef __TRS_CMD__
#define __TRS_CMD__
#include "emu.h"
#include "imagedev/snapquik.h"
QUICKLOAD_LOAD( trs80_cmd );
#endif

View File

@ -11,7 +11,6 @@
#include "imagedev/flopdrv.h"
#include "machine/ram.h"
#include "imagedev/snapquik.h"
#include "formats/atom_atm.h"
#include "formats/atom_tap.h"
#include "formats/basicdsk.h"
#include "formats/uef_cas.h"

View File

@ -6,7 +6,6 @@
#include "emu.h"
#include "cpu/cosmac/cosmac.h"
#include "formats/comx35_comx.h"
#include "imagedev/cassette.h"
#include "imagedev/printer.h"
#include "imagedev/snapquik.h"

View File

@ -14,7 +14,7 @@
#include "machine/8530scc.h"
#include "machine/6522via.h"
#include "machine/applefdc.h"
#include "devices/sonydriv.h"
#include "machine/sonydriv.h"
#include "cpu/m68000/m68000.h"
#include "sound/speaker.h"

View File

@ -84,6 +84,5 @@ extern const via6522_interface microtan_via6522_0;
extern const via6522_interface microtan_via6522_1;
SNAPSHOT_LOAD( microtan );
QUICKLOAD_LOAD( microtan_hexfile );
QUICKLOAD_LOAD( microtan );
#endif /* MICROTAN_H_ */

View File

@ -7,7 +7,6 @@
#include "emu.h"
#include "cpu/cosmac/cosmac.h"
#include "imagedev/cartslot.h"
#include "formats/studio2_st2.h"
#include "sound/beep.h"
#include "sound/cdp1864.h"
#include "sound/discrete.h"

View File

@ -18,7 +18,6 @@
#include "imagedev/flopdrv.h"
#include "imagedev/snapquik.h"
#include "formats/trs_cas.h"
#include "formats/trs_cmd.h"
#include "formats/trs_dsk.h"
@ -193,4 +192,6 @@ protected:
extern const wd17xx_interface trs80_wd17xx_interface;
QUICKLOAD_LOAD( trs80_cmd );
#endif /* TRS80_H_ */

View File

@ -121,7 +121,7 @@
#include "includes/apple2.h"
#include "machine/ay3600.h"
#include "machine/applefdc.h"
#include "devices/sonydriv.h"
#include "machine/sonydriv.h"
#include "machine/8530scc.h"
#include "imagedev/flopdrv.h"
#include "cpu/g65816/g65816.h"

View File

@ -96,7 +96,7 @@
#include "machine/8530scc.h"
#include "cpu/m68000/m68000.h"
#include "machine/applefdc.h"
#include "devices/sonydriv.h"
#include "machine/sonydriv.h"
#include "machine/ncr5380.h"
#include "sound/asc.h"
#include "includes/mac.h"

View File

@ -13,7 +13,7 @@
#include "machine/8530scc.h"
#include "cpu/m68000/m68000.h"
#include "machine/applefdc.h"
#include "devices/sonydriv.h"
#include "machine/sonydriv.h"
#include "includes/macpci.h"
#include "debug/debugcpu.h"
#include "machine/ram.h"

View File

@ -580,3 +580,355 @@ void microtan_state::machine_reset()
}
set_led_status(machine(), 1, (m_keyrows[3] & 0x80) ? 0 : 1);
}
static int microtan_verify_snapshot(UINT8 *data, int size)
{
if (size == 8263)
{
logerror("microtan_snapshot_id: magic size %d found\n", size);
return IMAGE_VERIFY_PASS;
}
else
{
if (4 + data[2] + 256 * data[3] + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 == size)
{
logerror("microtan_snapshot_id: header RAM size + structures matches filesize %d\n", size);
return IMAGE_VERIFY_PASS;
}
}
return IMAGE_VERIFY_FAIL;
}
static int parse_intel_hex(UINT8 *snapshot_buff, char *src)
{
char line[128];
int /*row = 0,*/ column = 0, last_addr = 0, last_size = 0;
while (*src)
{
if (*src == '\r' || *src == '\n')
{
if (column)
{
unsigned int size, addr, null, b[32], cs, n;
line[column] = '\0';
/*row++;*/
n = sscanf(line, ":%02x%04x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
&size, &addr, &null,
&b[ 0], &b[ 1], &b[ 2], &b[ 3], &b[ 4], &b[ 5], &b[ 6], &b[ 7],
&b[ 8], &b[ 9], &b[10], &b[11], &b[12], &b[13], &b[14], &b[15],
&b[16], &b[17], &b[18], &b[19], &b[20], &b[21], &b[22], &b[23],
&b[24], &b[25], &b[26], &b[27], &b[28], &b[29], &b[30], &b[31],
&cs);
if (n == 0)
{
logerror("parse_intel_hex: malformed line [%s]\n", line);
}
else if (n == 1)
{
logerror("parse_intel_hex: only size found [%s]\n", line);
}
else if (n == 2)
{
logerror("parse_intel_hex: only size and addr found [%s]\n", line);
}
else if (n == 3)
{
logerror("parse_intel_hex: only size, addr and null found [%s]\n", line);
}
else
if (null != 0)
{
logerror("parse_intel_hex: warning null byte is != 0 [%s]\n", line);
}
else
{
int i, sum;
n -= 3;
sum = size + (addr & 0xff) + ((addr >> 8) & 0xff);
if (n != 32 + 1)
cs = b[n-1];
last_addr = addr;
last_size = n-1;
logerror("parse_intel_hex: %04X", addr);
for (i = 0; i < n-1; i++)
{
sum += b[i];
snapshot_buff[addr++] = b[i];
}
logerror("-%04X checksum %02X+%02X = %02X\n", addr-1, cs, sum & 0xff, (cs + sum) & 0xff);
}
}
column = 0;
}
else
{
line[column++] = *src;
}
src++;
}
/* register preset? */
if (last_size == 7)
{
logerror("parse_intel_hex: registers (?) at %04X\n", last_addr);
memcpy(&snapshot_buff[8192+64], &snapshot_buff[last_addr], last_size);
}
return IMAGE_INIT_PASS;
}
static int parse_zillion_hex(UINT8 *snapshot_buff, char *src)
{
char line[128];
int parsing = 0, /*row = 0,*/ column = 0;
while (*src)
{
if (parsing)
{
if (*src == '}')
parsing = 0;
else
{
if (*src == '\r' || *src == '\n')
{
if (column)
{
unsigned int addr, b[8], n;
line[column] = '\0';
/*row++;*/
n = sscanf(line, "%x %x %x %x %x %x %x %x %x", &addr, &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], &b[6], &b[7]);
if (n == 0)
{
logerror("parse_zillion_hex: malformed line [%s]\n", line);
}
else if (n == 1)
{
logerror("parse_zillion_hex: only addr found [%s]\n", line);
}
else
{
int i;
logerror("parse_zillion_hex: %04X", addr);
for (i = 0; i < n-1; i++)
snapshot_buff[addr++] = b[i];
logerror("-%04X\n", addr-1);
}
}
column = 0;
}
else
{
line[column++] = *src;
}
}
}
else
{
if (*src == '\r' || *src == '\n')
{
if (column)
{
int addr, n;
/*row++;*/
line[column] = '\0';
n = sscanf(line, "G%x", (unsigned int *) &addr);
if (n == 1 && !snapshot_buff[8192+64+0] && !snapshot_buff[8192+64+1])
{
logerror("microtan_hexfile_init: go addr %04X\n", addr);
snapshot_buff[8192+64+0] = addr & 0xff;
snapshot_buff[8192+64+1] = (addr >> 8) & 0xff;
}
}
column = 0;
}
else
{
line[column++] = *src;
}
if (*src == '{')
{
parsing = 1;
column = 0;
}
}
src++;
}
return IMAGE_INIT_PASS;
}
static void microtan_set_cpu_regs(running_machine &machine,const UINT8 *snapshot_buff, int base)
{
logerror("microtan_snapshot_copy: PC:%02X%02X P:%02X A:%02X X:%02X Y:%02X SP:1%02X",
snapshot_buff[base+1], snapshot_buff[base+0], snapshot_buff[base+2], snapshot_buff[base+3],
snapshot_buff[base+4], snapshot_buff[base+5], snapshot_buff[base+6]);
machine.device("maincpu")->state().set_state_int(M6502_PC, snapshot_buff[base+0] + 256 * snapshot_buff[base+1]);
machine.device("maincpu")->state().set_state_int(M6502_P, snapshot_buff[base+2]);
machine.device("maincpu")->state().set_state_int(M6502_A, snapshot_buff[base+3]);
machine.device("maincpu")->state().set_state_int(M6502_X, snapshot_buff[base+4]);
machine.device("maincpu")->state().set_state_int(M6502_Y, snapshot_buff[base+5]);
machine.device("maincpu")->state().set_state_int(M6502_S, snapshot_buff[base+6]);
}
static void microtan_snapshot_copy(running_machine &machine, UINT8 *snapshot_buff, int snapshot_size)
{
microtan_state *state = machine.driver_data<microtan_state>();
UINT8 *RAM = state->memregion("maincpu")->base();
address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
via6522_device *via_1 = machine.device<via6522_device>("via6522_1");
device_t *ay8910 = machine.device("ay8910.1");
/* check for .DMP file format */
if (snapshot_size == 8263)
{
int i, base;
/********** DMP format
* Lower 8k of RAM (0000 to 1fff)
* 64 bytes of chunky graphics bits (first byte bit is for character at 0200, bit 1=0201, etc)
* 7 bytes of CPU registers (PCL, PCH, PSW, A, IX, IY, SP)
*/
logerror("microtan_snapshot_copy: magic size %d found, assuming *.DMP format\n", snapshot_size);
base = 0;
/* 8K of RAM from 0000 to 1fff */
memcpy(RAM, &snapshot_buff[base], 8192);
base += 8192;
/* 64 bytes of chunky graphics info */
for (i = 0; i < 32*16; i++)
{
state->m_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
}
base += 64;
microtan_set_cpu_regs(machine, snapshot_buff, base);
}
else
{
int i, ramend, base;
/********** M65 format ************************************
* 2 bytes: File version
* 2 bytes: RAM size
* n bytes: RAM (0000 to RAM Size)
* 16 bytes: 1st 6522 (0xbfc0 to 0xbfcf)
* 16 bytes: 2ns 6522 (0xbfe0 to 0xbfef)
* 16 bytes: Microtan IO (0xbff0 to 0xbfff)
* 1 byte : Invaders sound (0xbc04)
* 1 byte : Chunky graphics state (0=off, 1=on)
* 16 bytes: 1st AY8910 registers
* 16 bytes: 2nd AY8910 registers
* 64 bytes: Chunky graphics bits (first byte bit 0 is for character at 0200, bit 1=0201, etc)
* 7 bytes: CPU registers (PCL, PCH, PSW, A, IX, IY, SP)
*/
ramend = snapshot_buff[2] + 256 * snapshot_buff[3];
if (2 + 2 + ramend + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 != snapshot_size)
{
logerror("microtan_snapshot_copy: size %d doesn't match RAM size %d + structure size\n", snapshot_size, ramend+1);
return;
}
logerror("microtan_snapshot_copy: size %d found, assuming *.M65 format\n", snapshot_size);
base = 4;
memcpy(RAM, &snapshot_buff[base], snapshot_buff[2] + 256 * snapshot_buff[3] + 1);
base += ramend + 1;
/* first set of VIA6522 registers */
for (i = 0; i < 16; i++ )
via_0->write(space, i, snapshot_buff[base++]);
/* second set of VIA6522 registers */
for (i = 0; i < 16; i++ )
via_1->write(space, i, snapshot_buff[base++]);
/* microtan IO bff0-bfff */
for (i = 0; i < 16; i++ )
{
RAM[0xbff0+i] = snapshot_buff[base++];
if (i < 4)
state->microtan_bffx_w(space, i, RAM[0xbff0+i]);
}
state->microtan_sound_w(space, 0, snapshot_buff[base++]);
state->m_chunky_graphics = snapshot_buff[base++];
/* first set of AY8910 registers */
for (i = 0; i < 16; i++ )
{
ay8910_address_w(ay8910, state->generic_space(), 0, i);
ay8910_data_w(ay8910, state->generic_space(), 0, snapshot_buff[base++]);
}
/* second set of AY8910 registers */
for (i = 0; i < 16; i++ )
{
ay8910_address_w(ay8910, state->generic_space(), 0, i);
ay8910_data_w(ay8910, state->generic_space(), 0, snapshot_buff[base++]);
}
for (i = 0; i < 32*16; i++)
{
state->m_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
}
base += 64;
microtan_set_cpu_regs(machine, snapshot_buff, base);
}
}
SNAPSHOT_LOAD( microtan )
{
UINT8 *snapshot_buff;
snapshot_buff = (UINT8*)image.ptr();
if (!snapshot_buff)
return IMAGE_INIT_FAIL;
if (microtan_verify_snapshot(snapshot_buff, snapshot_size)==IMAGE_VERIFY_FAIL)
return IMAGE_INIT_FAIL;
microtan_snapshot_copy(image.device().machine(), snapshot_buff, snapshot_size);
return IMAGE_INIT_PASS;
}
QUICKLOAD_LOAD( microtan )
{
int snapshot_size;
UINT8 *snapshot_buff;
char *buff;
int rc;
snapshot_size = 8263; /* magic size */
snapshot_buff = (UINT8*)malloc(snapshot_size);
if (!snapshot_buff)
{
logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", snapshot_size);
return IMAGE_INIT_FAIL;
}
memset(snapshot_buff, 0, snapshot_size);
buff = (char*)malloc(quickload_size + 1);
if (!buff)
{
free(snapshot_buff);
logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", quickload_size);
return IMAGE_INIT_FAIL;
}
image.fread( buff, quickload_size);
buff[quickload_size] = '\0';
if (buff[0] == ':')
rc = parse_intel_hex(snapshot_buff, buff);
else
rc = parse_zillion_hex(snapshot_buff, buff);
if (rc == IMAGE_INIT_PASS)
microtan_snapshot_copy(image.device().machine(), snapshot_buff, snapshot_size);
free(snapshot_buff);
return rc;
}

View File

@ -910,3 +910,84 @@ MACHINE_RESET_MEMBER(trs80_state,lnw80)
m_reg_load = 1;
lnw80_fe_w(space, 0, 0);
}
/***************************************************************************
PARAMETERS
***************************************************************************/
#define LOG 1
#define CMD_TYPE_OBJECT_CODE 0x01
#define CMD_TYPE_TRANSFER_ADDRESS 0x02
#define CMD_TYPE_END_OF_PARTITIONED_DATA_SET_MEMBER 0x04
#define CMD_TYPE_LOAD_MODULE_HEADER 0x05
#define CMD_TYPE_PARTITIONED_DATA_SET_HEADER 0x06
#define CMD_TYPE_PATCH_NAME_HEADER 0x07
#define CMD_TYPE_ISAM_DIRECTORY_ENTRY 0x08
#define CMD_TYPE_END_OF_ISAM_DIRECTORY_ENTRY 0x0a
#define CMD_TYPE_PDS_DIRECTORY_ENTRY 0x0c
#define CMD_TYPE_END_OF_PDS_DIRECTORY_ENTRY 0x0e
#define CMD_TYPE_YANKED_LOAD_BLOCK 0x10
#define CMD_TYPE_COPYRIGHT_BLOCK 0x1f
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
QUICKLOAD_LOAD( trs80_cmd )
{
address_space &program = image.device().machine().firstcpu->space(AS_PROGRAM);
UINT8 type, length;
UINT8 data[0x100];
UINT8 addr[2];
void *ptr;
while (!image.image_feof())
{
image.fread( &type, 1);
image.fread( &length, 1);
length -= 2;
int block_length = length ? length : 256;
switch (type)
{
case CMD_TYPE_OBJECT_CODE:
{
image.fread( &addr, 2);
UINT16 address = (addr[1] << 8) | addr[0];
if (LOG) logerror("/CMD object code block: address %04x length %u\n", address, block_length);
ptr = program.get_write_ptr(address);
image.fread( ptr, block_length);
}
break;
case CMD_TYPE_TRANSFER_ADDRESS:
{
image.fread( &addr, 2);
UINT16 address = (addr[1] << 8) | addr[0];
if (LOG) logerror("/CMD transfer address %04x\n", address);
image.device().machine().firstcpu->set_state_int(Z80_PC, address);
}
break;
case CMD_TYPE_LOAD_MODULE_HEADER:
image.fread( &data, block_length);
if (LOG) logerror("/CMD load module header '%s'\n", data);
break;
case CMD_TYPE_COPYRIGHT_BLOCK:
image.fread( &data, block_length);
if (LOG) logerror("/CMD copyright block '%s'\n", data);
break;
default:
image.fread( &data, block_length);
logerror("/CMD unsupported block type %u!\n", type);
}
}
return IMAGE_INIT_PASS;
}

View File

@ -580,7 +580,6 @@ $(MESSOBJ)/acorn.a: \
$(MESS_DRIVERS)/a7000.o \
$(MESS_DRIVERS)/acrnsys1.o \
$(MESS_DRIVERS)/atom.o \
$(MESS_FORMATS)/atom_atm.o \
$(MESS_VIDEO)/bbc.o \
$(MESS_MACHINE)/bbc.o \
$(MESS_DRIVERS)/bbc.o \
@ -810,7 +809,6 @@ $(MESSOBJ)/canon.a: \
$(MESSOBJ)/cantab.a: \
$(MESS_DRIVERS)/ace.o \
$(MESS_FORMATS)/ace_ace.o \
$(MESSOBJ)/casio.a: \
$(MESS_DRIVERS)/casloopy.o \
@ -1017,7 +1015,6 @@ $(MESSOBJ)/cromemco.a: \
$(MESSOBJ)/comx.a: \
$(MESS_DRIVERS)/comx35.o \
$(MESS_FORMATS)/comx35_comx.o \
$(MESS_MACHINE)/comxpl80.o \
$(MESS_VIDEO)/comx35.o \
$(MESS_MACHINE)/comxexp.o \
@ -1578,7 +1575,6 @@ $(MESSOBJ)/radio.a: \
$(MESSOBJ)/rca.a: \
$(MESS_DRIVERS)/studio2.o \
$(MESS_FORMATS)/studio2_st2.o \
$(MESS_DRIVERS)/vip.o \
$(MESS_MACHINE)/vip_byteio.o \
$(MESS_MACHINE)/vip_exp.o \
@ -1769,7 +1765,6 @@ $(MESSOBJ)/tangerin.a: \
$(MESS_VIDEO)/microtan.o \
$(MESS_MACHINE)/microtan.o \
$(MESS_DRIVERS)/microtan.o \
$(MESS_FORMATS)/m65_snqk.o \
$(MESS_DRIVERS)/oric.o \
$(MESS_VIDEO)/oric.o \
$(MESS_MACHINE)/oric.o \
@ -1914,7 +1909,6 @@ $(MESSOBJ)/trs.a: \
$(MESS_DRIVERS)/mc10.o \
$(MESS_MACHINE)/trs80.o \
$(MESS_VIDEO)/trs80.o \
$(MESS_FORMATS)/trs_cmd.o \
$(MESS_DRIVERS)/trs80.o \
$(MESS_DRIVERS)/trs80m2.o \
$(MESS_MACHINE)/trs80m2kb.o \