Previous 199869 Revisions Next

r21308 Friday 22nd February, 2013 at 11:09:34 UTC by Miodrag Milanović
Some more moving to proper place and compile fix (nw)
[src/mess]mess.mak
[src/mess/drivers]ace.c atom.c comx35.c lisa.c mac.c microtan.c studio2.c
[src/mess/formats]ace_ace.c ace_ace.h atom_atm.c atom_atm.h comx35_comx.c comx35_comx.h m65_snqk.c m65_snqk.h studio2_st2.c studio2_st2.h trs_cmd.c trs_cmd.h
[src/mess/includes]atom.h comx35.h lisa.h microtan.h studio2.h trs80.h
[src/mess/machine]apple2gs.c mac.c macpci.c microtan.c trs80.c

trunk/src/mess/formats/studio2_st2.c
r21307r21308
1/*********************************************************************
2
3    formats/studio2_st2.c
4
5    Cartridge code for RCA Studio II st2 files
6
7*********************************************************************/
8
9#include "emu.h"
10#include "includes/studio2.h"
11#include "formats/studio2_st2.h"
12
13/***************************************************************************
14    PARAMETERS
15***************************************************************************/
16
17#define LOG 1
18
19#define ST2_BLOCK_SIZE 256
20
21/***************************************************************************
22    TYPE DEFINITIONS
23***************************************************************************/
24
25struct st2_header
26{
27   UINT8 header[4];            /* "RCA2" in ASCII code */
28   UINT8 blocks;               /* Total number of 256 byte blocks in file (including this one) */
29   UINT8 format;               /* Format Code (this is format number 1) */
30   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) */
31   UINT8 reserved0;
32   UINT8 author[2];            /* 2 byte ASCII code indicating the identity of the program coder */
33   UINT8 dumper[2];            /* 2 byte ASCII code indicating the identity of the ROM Source */
34   UINT8 reserved1[4];
35   UINT8 catalogue[10];        /* RCA Catalogue Code as ASCIIZ string. If a homebrew ROM, may contain any identifying code you wish */
36   UINT8 reserved2[6];
37   UINT8 title[32];            /* Cartridge Program Title as ASCIIZ string */
38   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 */
39   UINT8 reserved3[128];
40};
41
42/***************************************************************************
43    IMPLEMENTATION
44***************************************************************************/
45
46/*-------------------------------------------------
47    DEVICE_IMAGE_LOAD( st2_cartslot_load )
48-------------------------------------------------*/
49
50DEVICE_IMAGE_LOAD_LEGACY( st2_cartslot_load )
51{
52   st2_header header;
53
54   /* check file size */
55   int filesize = image.length();
56
57   if (filesize <= ST2_BLOCK_SIZE) {
58      logerror("Error loading cartridge: Invalid ROM file: %s.\n", image.filename());
59      return IMAGE_INIT_FAIL;
60   }
61
62   /* read ST2 header */
63   if (image.fread( &header, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
64      logerror("Error loading cartridge: Unable to read header from file: %s.\n", image.filename());
65      return IMAGE_INIT_FAIL;
66   }
67
68   if (LOG) logerror("ST2 Catalogue: %s\n", header.catalogue);
69   if (LOG) logerror("ST2 Title: %s\n", header.title);
70
71   /* read ST2 cartridge into memory */
72   for (int block = 0; block < (header.blocks - 1); block++)
73   {
74      UINT16 offset = header.page[block] << 8;
75      UINT8 *ptr = ((UINT8 *) image.device().machine().root_device().memregion(CDP1802_TAG)->base()) + offset;
76
77      if (LOG) logerror("ST2 Reading block %u to %04x\n", block, offset);
78
79      if (image.fread( ptr, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
80         logerror("Error loading cartridge: Unable to read contents from file: %s.\n", image.filename());
81         return IMAGE_INIT_FAIL;
82      }
83   }
84
85   return IMAGE_INIT_PASS;
86}
trunk/src/mess/formats/studio2_st2.h
r21307r21308
1/*********************************************************************
2
3    formats/studio2_St2.h
4
5    Cartridge code for RCA Studio II st2 files
6
7*********************************************************************/
8
9#pragma once
10
11#ifndef __STUDIO2_ST2__
12#define __STUDIO2_ST2__
13
14#include "emu.h"
15
16DEVICE_IMAGE_LOAD_LEGACY( st2_cartslot_load );
17
18#endif
trunk/src/mess/formats/trs_cmd.c
r21307r21308
1/*********************************************************************
2
3    formats/trs_cmd.c
4
5    Quickload code for TRS-80 /CMD files
6
7*********************************************************************/
8
9#include "emu.h"
10#include "formats/trs_cmd.h"
11#include "cpu/z80/z80.h"
12
13/***************************************************************************
14    PARAMETERS
15***************************************************************************/
16
17#define LOG 1
18
19#define CMD_TYPE_OBJECT_CODE                            0x01
20#define CMD_TYPE_TRANSFER_ADDRESS                       0x02
21#define CMD_TYPE_END_OF_PARTITIONED_DATA_SET_MEMBER     0x04
22#define CMD_TYPE_LOAD_MODULE_HEADER                     0x05
23#define CMD_TYPE_PARTITIONED_DATA_SET_HEADER            0x06
24#define CMD_TYPE_PATCH_NAME_HEADER                      0x07
25#define CMD_TYPE_ISAM_DIRECTORY_ENTRY                   0x08
26#define CMD_TYPE_END_OF_ISAM_DIRECTORY_ENTRY            0x0a
27#define CMD_TYPE_PDS_DIRECTORY_ENTRY                    0x0c
28#define CMD_TYPE_END_OF_PDS_DIRECTORY_ENTRY             0x0e
29#define CMD_TYPE_YANKED_LOAD_BLOCK                      0x10
30#define CMD_TYPE_COPYRIGHT_BLOCK                        0x1f
31
32/***************************************************************************
33    IMPLEMENTATION
34***************************************************************************/
35
36QUICKLOAD_LOAD( trs80_cmd )
37{
38   address_space &program = image.device().machine().firstcpu->space(AS_PROGRAM);
39
40   UINT8 type, length;
41   UINT8 data[0x100];
42   UINT8 addr[2];
43   void *ptr;
44
45   while (!image.image_feof())
46   {
47      image.fread( &type, 1);
48      image.fread( &length, 1);
49
50      length -= 2;
51      int block_length = length ? length : 256;
52
53      switch (type)
54      {
55      case CMD_TYPE_OBJECT_CODE:
56         {
57         image.fread( &addr, 2);
58         UINT16 address = (addr[1] << 8) | addr[0];
59         if (LOG) logerror("/CMD object code block: address %04x length %u\n", address, block_length);
60         ptr = program.get_write_ptr(address);
61         image.fread( ptr, block_length);
62         }
63         break;
64
65      case CMD_TYPE_TRANSFER_ADDRESS:
66         {
67         image.fread( &addr, 2);
68         UINT16 address = (addr[1] << 8) | addr[0];
69         if (LOG) logerror("/CMD transfer address %04x\n", address);
70         image.device().machine().firstcpu->set_state_int(Z80_PC, address);
71         }
72         break;
73
74      case CMD_TYPE_LOAD_MODULE_HEADER:
75         image.fread( &data, block_length);
76         if (LOG) logerror("/CMD load module header '%s'\n", data);
77         break;
78
79      case CMD_TYPE_COPYRIGHT_BLOCK:
80         image.fread( &data, block_length);
81         if (LOG) logerror("/CMD copyright block '%s'\n", data);
82         break;
83
84      default:
85         image.fread( &data, block_length);
86         logerror("/CMD unsupported block type %u!\n", type);
87      }
88   }
89
90   return IMAGE_INIT_PASS;
91}
trunk/src/mess/formats/trs_cmd.h
r21307r21308
1/*********************************************************************
2
3    formats/trs_cmd.h
4
5    Quickload code for TRS-80 /CMD files
6
7*********************************************************************/
8
9#pragma once
10
11#ifndef __TRS_CMD__
12#define __TRS_CMD__
13
14#include "emu.h"
15#include "imagedev/snapquik.h"
16
17QUICKLOAD_LOAD( trs80_cmd );
18
19#endif
trunk/src/mess/formats/ace_ace.c
r21307r21308
1/*********************************************************************
2
3    ace_ace.c
4
5    Format code for Jupiter Ace snapshot files
6
7*********************************************************************/
8
9#include "emu.h"
10#include "ace_ace.h"
11#include "cpu/z80/z80.h"
12#include "machine/ram.h"
13
14/* Load in .ace files. These are memory images of 0x2000 to 0x7fff
15   and compressed as follows:
16
17   ED 00        : End marker
18   ED <cnt> <byt>   : repeat <byt> count <cnt:1-240> times
19   <byt>        : <byt>
20*/
21
22/******************************************************************************
23 Snapshot Handling
24******************************************************************************/
25
26SNAPSHOT_LOAD( ace )
27{
28   cpu_device *cpu = image.device().machine().firstcpu;
29   UINT8 *RAM = image.device().machine().root_device().memregion(cpu->tag())->base();
30   address_space &space = cpu->space(AS_PROGRAM);
31   unsigned char ace_repeat, ace_byte, loop;
32   int done=0, ace_index=0x2000;
33
34   if (image.device().machine().device<ram_device>(RAM_TAG)->size() < 16*1024)
35   {
36      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "At least 16KB RAM expansion required");
37      image.message("At least 16KB RAM expansion required");
38      return IMAGE_INIT_FAIL;
39   }
40
41   logerror("Loading file %s.\r\n", image.filename());
42   while (!done && (ace_index < 0x8001))
43   {
44      image.fread( &ace_byte, 1);
45      if (ace_byte == 0xed)
46      {
47         image.fread(&ace_byte, 1);
48         switch (ace_byte)
49         {
50         case 0x00:
51               logerror("File loaded!\r\n");
52               done = 1;
53               break;
54         case 0x01:
55               image.fread(&ace_byte, 1);
56               RAM[ace_index++] = ace_byte;
57               break;
58         default:
59               image.fread(&ace_repeat, 1);
60               for (loop = 0; loop < ace_byte; loop++)
61                  RAM[ace_index++] = ace_repeat;
62               break;
63         }
64      }
65      else
66         RAM[ace_index++] = ace_byte;
67   }
68
69   logerror("Decoded %X bytes.\r\n", ace_index-0x2000);
70
71   if (!done)
72   {
73      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "EOF marker not found");
74      image.message("EOF marker not found");
75      return IMAGE_INIT_FAIL;
76   }
77
78      // patch CPU registers
79      // Some games do not follow the standard, and have rubbish in the CPU area. So,
80      // we check that some other bytes are correct.
81      // 2080 = memory size of original machine, should be 0000 or 8000 or C000.
82      // 2118 = new stack pointer, do not use if between 8000 and FF00.
83
84   ace_index = RAM[0x2080] | (RAM[0x2081] << 8);
85
86   if ((ace_index & 0x3FFF)==0)
87   {
88      cpu->set_state_int(Z80_AF, RAM[0x2100] | (RAM[0x2101] << 8));
89      cpu->set_state_int(Z80_BC, RAM[0x2104] | (RAM[0x2105] << 8));
90      cpu->set_state_int(Z80_DE, RAM[0x2108] | (RAM[0x2109] << 8));
91      cpu->set_state_int(Z80_HL, RAM[0x210c] | (RAM[0x210d] << 8));
92      cpu->set_state_int(Z80_IX, RAM[0x2110] | (RAM[0x2111] << 8));
93      cpu->set_state_int(Z80_IY, RAM[0x2114] | (RAM[0x2115] << 8));
94      cpu->set_pc(RAM[0x211c] | (RAM[0x211d] << 8));
95      cpu->set_state_int(Z80_AF2, RAM[0x2120] | (RAM[0x2121] << 8));
96      cpu->set_state_int(Z80_BC2, RAM[0x2124] | (RAM[0x2125] << 8));
97      cpu->set_state_int(Z80_DE2, RAM[0x2128] | (RAM[0x2129] << 8));
98      cpu->set_state_int(Z80_HL2, RAM[0x212c] | (RAM[0x212d] << 8));
99      cpu->set_state_int(Z80_IM, RAM[0x2130]);
100      cpu->set_state_int(Z80_IFF1, RAM[0x2134]);
101      cpu->set_state_int(Z80_IFF2, RAM[0x2138]);
102      cpu->set_state_int(Z80_I, RAM[0x213c]);
103      cpu->set_state_int(Z80_R, RAM[0x2140]);
104
105      if ((RAM[0x2119] < 0x80) || !ace_index)
106         cpu->set_state_int(STATE_GENSP, RAM[0x2118] | (RAM[0x2119] << 8));
107   }
108
109   /* Copy data to the address space */
110   for (ace_index = 0x2000; ace_index < 0x8000; ace_index++)
111      space.write_byte(ace_index, RAM[ace_index]);
112
113   return IMAGE_INIT_PASS;
114}
trunk/src/mess/formats/atom_atm.c
r21307r21308
1/*********************************************************************
2
3    formats/atom_atm.c
4
5    Quickload code for Acorn Atom atm files
6
7*********************************************************************/
8
9#include "emu.h"
10#include "formats/imageutl.h"
11#include "formats/atom_atm.h"
12
13/***************************************************************************
14    PARAMETERS
15***************************************************************************/
16
17#define LOG 1
18
19/***************************************************************************
20    IMPLEMENTATION
21***************************************************************************/
22
23/*-------------------------------------------------
24    image_fread_memory - read image to memory
25-------------------------------------------------*/
26
27static void image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
28{
29   void *ptr = image.device().machine().firstcpu->space(AS_PROGRAM).get_write_ptr(addr);
30
31   image.fread( ptr, count);
32}
33
34/*-------------------------------------------------
35    QUICKLOAD_LOAD( atom_atm )
36-------------------------------------------------*/
37
38QUICKLOAD_LOAD( atom_atm )
39{
40   /*
41
42       The format for the .ATM files is as follows:
43
44       Offset Size     Description
45       ------ -------- -----------------------------------------------------------
46       0000h  16 BYTEs ATOM filename (if less than 16 BYTEs, rest is 00h bytes)
47       0010h  WORD     Start address for load
48       0012h  WORD     Execution address
49       0014h  WORD     Size of data in BYTEs
50       0016h  Size     Data
51
52   */
53
54   UINT8 header[0x16] = { 0 };
55
56   image.fread(header, 0x16);
57
58   UINT16 start_address = pick_integer_le(header, 0x10, 2);
59   UINT16 run_address = pick_integer_le(header, 0x12, 2);
60   UINT16 size = pick_integer_le(header, 0x14, 2);
61
62   if (LOG)
63   {
64      header[16] = 0;
65      logerror("ATM filename: %s\n", header);
66      logerror("ATM start address: %04x\n", start_address);
67      logerror("ATM run address: %04x\n", run_address);
68      logerror("ATM size: %04x\n", size);
69   }
70
71   image_fread_memory(image, start_address, size);
72
73   image.device().machine().firstcpu->set_pc(run_address);
74
75   return IMAGE_INIT_PASS;
76}
trunk/src/mess/formats/m65_snqk.c
r21307r21308
1/******************************************************************************
2 *  Microtan 65
3 *
4 *  Snapshot and quickload formats
5 *
6 *  Juergen Buchmueller <pullmoll@t-online.de>, Jul 2000
7 *
8 *  Thanks go to Geoff Macdonald <mail@geoff.org.uk>
9 *  for his site http:://www.geo255.redhotant.com
10 *  and to Fabrice Frances <frances@ensica.fr>
11 *  for his site http://www.ifrance.com/oric/microtan.html
12 *
13 *****************************************************************************/
14#include "emu.h"
15#include "cpu/m6502/m6502.h"
16#include "includes/microtan.h"
17#include "machine/6522via.h"
18#include "machine/mos6551.h"
19#include "sound/ay8910.h"
20#include "formats/m65_snqk.h"
21
22static int microtan_verify_snapshot(UINT8 *data, int size)
23{
24   if (size == 8263)
25   {
26      logerror("microtan_snapshot_id: magic size %d found\n", size);
27      return IMAGE_VERIFY_PASS;
28   }
29   else
30   {
31      if (4 + data[2] + 256 * data[3] + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 == size)
32      {
33         logerror("microtan_snapshot_id: header RAM size + structures matches filesize %d\n", size);
34         return IMAGE_VERIFY_PASS;
35      }
36   }
37
38   return IMAGE_VERIFY_FAIL;
39}
40
41static int parse_intel_hex(UINT8 *snapshot_buff, char *src)
42{
43   char line[128];
44   int /*row = 0,*/ column = 0, last_addr = 0, last_size = 0;
45
46   while (*src)
47   {
48      if (*src == '\r' || *src == '\n')
49      {
50         if (column)
51         {
52            unsigned int size, addr, null, b[32], cs, n;
53
54            line[column] = '\0';
55            /*row++;*/
56            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",
57               &size, &addr, &null,
58               &b[ 0], &b[ 1], &b[ 2], &b[ 3], &b[ 4], &b[ 5], &b[ 6], &b[ 7],
59               &b[ 8], &b[ 9], &b[10], &b[11], &b[12], &b[13], &b[14], &b[15],
60               &b[16], &b[17], &b[18], &b[19], &b[20], &b[21], &b[22], &b[23],
61               &b[24], &b[25], &b[26], &b[27], &b[28], &b[29], &b[30], &b[31],
62               &cs);
63            if (n == 0)
64            {
65               logerror("parse_intel_hex: malformed line [%s]\n", line);
66            }
67            else if (n == 1)
68            {
69               logerror("parse_intel_hex: only size found [%s]\n", line);
70            }
71            else if (n == 2)
72            {
73               logerror("parse_intel_hex: only size and addr found [%s]\n", line);
74            }
75            else if (n == 3)
76            {
77               logerror("parse_intel_hex: only size, addr and null found [%s]\n", line);
78            }
79            else
80            if (null != 0)
81            {
82               logerror("parse_intel_hex: warning null byte is != 0 [%s]\n", line);
83            }
84            else
85            {
86               int i, sum;
87
88               n -= 3;
89
90               sum = size + (addr & 0xff) + ((addr >> 8) & 0xff);
91               if (n != 32 + 1)
92                  cs = b[n-1];
93
94               last_addr = addr;
95               last_size = n-1;
96               logerror("parse_intel_hex: %04X", addr);
97               for (i = 0; i < n-1; i++)
98               {
99                  sum += b[i];
100                  snapshot_buff[addr++] = b[i];
101               }
102               logerror("-%04X checksum %02X+%02X = %02X\n", addr-1, cs, sum & 0xff, (cs + sum) & 0xff);
103            }
104         }
105         column = 0;
106      }
107      else
108      {
109         line[column++] = *src;
110      }
111      src++;
112   }
113   /* register preset? */
114   if (last_size == 7)
115   {
116      logerror("parse_intel_hex: registers (?) at %04X\n", last_addr);
117      memcpy(&snapshot_buff[8192+64], &snapshot_buff[last_addr], last_size);
118   }
119   return IMAGE_INIT_PASS;
120}
121
122static int parse_zillion_hex(UINT8 *snapshot_buff, char *src)
123{
124   char line[128];
125   int parsing = 0, /*row = 0,*/ column = 0;
126
127   while (*src)
128   {
129      if (parsing)
130      {
131         if (*src == '}')
132            parsing = 0;
133         else
134         {
135            if (*src == '\r' || *src == '\n')
136            {
137               if (column)
138               {
139                  unsigned int addr, b[8], n;
140
141                  line[column] = '\0';
142                  /*row++;*/
143                  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]);
144                  if (n == 0)
145                  {
146                     logerror("parse_zillion_hex: malformed line [%s]\n", line);
147                  }
148                  else if (n == 1)
149                  {
150                     logerror("parse_zillion_hex: only addr found [%s]\n", line);
151                  }
152                  else
153                  {
154                     int i;
155
156                     logerror("parse_zillion_hex: %04X", addr);
157                     for (i = 0; i < n-1; i++)
158                        snapshot_buff[addr++] = b[i];
159                     logerror("-%04X\n", addr-1);
160                  }
161               }
162               column = 0;
163            }
164            else
165            {
166               line[column++] = *src;
167            }
168         }
169      }
170      else
171      {
172         if (*src == '\r' || *src == '\n')
173         {
174            if (column)
175            {
176               int addr, n;
177
178               /*row++;*/
179               line[column] = '\0';
180               n = sscanf(line, "G%x", (unsigned int *) &addr);
181               if (n == 1 && !snapshot_buff[8192+64+0] && !snapshot_buff[8192+64+1])
182               {
183                  logerror("microtan_hexfile_init: go addr %04X\n", addr);
184                  snapshot_buff[8192+64+0] = addr & 0xff;
185                  snapshot_buff[8192+64+1] = (addr >> 8) & 0xff;
186               }
187            }
188            column = 0;
189         }
190         else
191         {
192            line[column++] = *src;
193         }
194         if (*src == '{')
195         {
196            parsing = 1;
197            column = 0;
198         }
199      }
200      src++;
201   }
202   return IMAGE_INIT_PASS;
203}
204
205static void microtan_set_cpu_regs(running_machine &machine,const UINT8 *snapshot_buff, int base)
206{
207   logerror("microtan_snapshot_copy: PC:%02X%02X P:%02X A:%02X X:%02X Y:%02X SP:1%02X",
208      snapshot_buff[base+1], snapshot_buff[base+0], snapshot_buff[base+2], snapshot_buff[base+3],
209      snapshot_buff[base+4], snapshot_buff[base+5], snapshot_buff[base+6]);
210   machine.device("maincpu")->state().set_state_int(M6502_PC, snapshot_buff[base+0] + 256 * snapshot_buff[base+1]);
211   machine.device("maincpu")->state().set_state_int(M6502_P, snapshot_buff[base+2]);
212   machine.device("maincpu")->state().set_state_int(M6502_A, snapshot_buff[base+3]);
213   machine.device("maincpu")->state().set_state_int(M6502_X, snapshot_buff[base+4]);
214   machine.device("maincpu")->state().set_state_int(M6502_Y, snapshot_buff[base+5]);
215   machine.device("maincpu")->state().set_state_int(M6502_S, snapshot_buff[base+6]);
216}
217
218static void microtan_snapshot_copy(running_machine &machine, UINT8 *snapshot_buff, int snapshot_size)
219{
220   microtan_state *state = machine.driver_data<microtan_state>();
221   UINT8 *RAM = state->memregion("maincpu")->base();
222   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
223   via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
224   via6522_device *via_1 = machine.device<via6522_device>("via6522_1");
225   device_t *ay8910 = machine.device("ay8910.1");
226
227   /* check for .DMP file format */
228   if (snapshot_size == 8263)
229   {
230      int i, base;
231      /********** DMP format
232       * Lower 8k of RAM (0000 to 1fff)
233       * 64 bytes of chunky graphics bits (first byte bit is for character at 0200, bit 1=0201, etc)
234       * 7 bytes of CPU registers (PCL, PCH, PSW, A, IX, IY, SP)
235       */
236      logerror("microtan_snapshot_copy: magic size %d found, assuming *.DMP format\n", snapshot_size);
237
238      base = 0;
239      /* 8K of RAM from 0000 to 1fff */
240      memcpy(RAM, &snapshot_buff[base], 8192);
241      base += 8192;
242      /* 64 bytes of chunky graphics info */
243      for (i = 0; i < 32*16; i++)
244      {
245         state->m_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
246      }
247      base += 64;
248      microtan_set_cpu_regs(machine, snapshot_buff, base);
249   }
250   else
251   {
252      int i, ramend, base;
253      /********** M65 format ************************************
254       *  2 bytes: File version
255       *  2 bytes: RAM size
256       *  n bytes: RAM (0000 to RAM Size)
257       * 16 bytes: 1st 6522 (0xbfc0 to 0xbfcf)
258       * 16 bytes: 2ns 6522 (0xbfe0 to 0xbfef)
259       * 16 bytes: Microtan IO (0xbff0 to 0xbfff)
260       *  1 byte : Invaders sound (0xbc04)
261       *  1 byte : Chunky graphics state (0=off, 1=on)
262       * 16 bytes: 1st AY8910 registers
263       * 16 bytes: 2nd AY8910 registers
264       * 64 bytes: Chunky graphics bits (first byte bit 0 is for character at 0200, bit 1=0201, etc)
265       *  7 bytes: CPU registers (PCL, PCH, PSW, A, IX, IY, SP)
266       */
267      ramend = snapshot_buff[2] + 256 * snapshot_buff[3];
268      if (2 + 2 + ramend + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 != snapshot_size)
269      {
270         logerror("microtan_snapshot_copy: size %d doesn't match RAM size %d + structure size\n", snapshot_size, ramend+1);
271         return;
272      }
273
274      logerror("microtan_snapshot_copy: size %d found, assuming *.M65 format\n", snapshot_size);
275      base = 4;
276      memcpy(RAM, &snapshot_buff[base], snapshot_buff[2] + 256 * snapshot_buff[3] + 1);
277      base += ramend + 1;
278
279      /* first set of VIA6522 registers */
280      for (i = 0; i < 16; i++ )
281         via_0->write(space, i, snapshot_buff[base++]);
282
283      /* second set of VIA6522 registers */
284      for (i = 0; i < 16; i++ )
285         via_1->write(space, i, snapshot_buff[base++]);
286
287      /* microtan IO bff0-bfff */
288      for (i = 0; i < 16; i++ )
289      {
290         RAM[0xbff0+i] = snapshot_buff[base++];
291         if (i < 4)
292            state->microtan_bffx_w(space, i, RAM[0xbff0+i]);
293      }
294
295      state->microtan_sound_w(space, 0, snapshot_buff[base++]);
296      state->m_chunky_graphics = snapshot_buff[base++];
297
298      /* first set of AY8910 registers */
299      for (i = 0; i < 16; i++ )
300      {
301         ay8910_address_w(ay8910, state->generic_space(), 0, i);
302         ay8910_data_w(ay8910, state->generic_space(), 0, snapshot_buff[base++]);
303      }
304
305      /* second set of AY8910 registers */
306      for (i = 0; i < 16; i++ )
307      {
308         ay8910_address_w(ay8910, state->generic_space(), 0, i);
309         ay8910_data_w(ay8910, state->generic_space(), 0, snapshot_buff[base++]);
310      }
311
312      for (i = 0; i < 32*16; i++)
313      {
314         state->m_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
315      }
316      base += 64;
317
318      microtan_set_cpu_regs(machine, snapshot_buff, base);
319   }
320}
321
322SNAPSHOT_LOAD( microtan )
323{
324   UINT8 *snapshot_buff;
325
326   snapshot_buff = (UINT8*)image.ptr();
327   if (!snapshot_buff)
328      return IMAGE_INIT_FAIL;
329
330   if (microtan_verify_snapshot(snapshot_buff, snapshot_size)==IMAGE_VERIFY_FAIL)
331      return IMAGE_INIT_FAIL;
332
333   microtan_snapshot_copy(image.device().machine(), snapshot_buff, snapshot_size);
334   return IMAGE_INIT_PASS;
335}
336
337QUICKLOAD_LOAD( microtan )
338{
339   int snapshot_size;
340   UINT8 *snapshot_buff;
341   char *buff;
342   int rc;
343
344   snapshot_size = 8263;   /* magic size */
345   snapshot_buff = (UINT8*)malloc(snapshot_size);
346   if (!snapshot_buff)
347   {
348      logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", snapshot_size);
349      return IMAGE_INIT_FAIL;
350   }
351   memset(snapshot_buff, 0, snapshot_size);
352
353   buff = (char*)malloc(quickload_size + 1);
354   if (!buff)
355   {
356      free(snapshot_buff);
357      logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", quickload_size);
358      return IMAGE_INIT_FAIL;
359   }
360   image.fread( buff, quickload_size);
361
362   buff[quickload_size] = '\0';
363
364   if (buff[0] == ':')
365      rc = parse_intel_hex(snapshot_buff, buff);
366   else
367      rc = parse_zillion_hex(snapshot_buff, buff);
368   if (rc == IMAGE_INIT_PASS)
369      microtan_snapshot_copy(image.device().machine(), snapshot_buff, snapshot_size);
370   free(snapshot_buff);
371   return rc;
372}
trunk/src/mess/formats/comx35_comx.c
r21307r21308
1/*********************************************************************
2
3    formats/comx35_comx.c
4
5    Quickload code for COMX-35 comx files
6
7*********************************************************************/
8
9#include "emu.h"
10#include "formats/imageutl.h"
11#include "formats/comx35_comx.h"
12#include "machine/ram.h"
13
14/***************************************************************************
15    PARAMETERS
16***************************************************************************/
17
18#define LOG 1
19
20enum
21{
22   COMX_TYPE_BINARY = 1,
23   COMX_TYPE_BASIC,
24   COMX_TYPE_BASIC_FM,
25   COMX_TYPE_RESERVED,
26   COMX_TYPE_DATA
27};
28
29/***************************************************************************
30    IMPLEMENTATION
31***************************************************************************/
32
33/*-------------------------------------------------
34    image_fread_memory - read image to memory
35-------------------------------------------------*/
36
37static void image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
38{
39   UINT8 *ram = image.device().machine().device<ram_device>(RAM_TAG)->pointer() + (addr - 0x4000);
40
41   image.fread(ram, count);
42}
43
44/*-------------------------------------------------
45    QUICKLOAD_LOAD( comx35_comx )
46-------------------------------------------------*/
47
48QUICKLOAD_LOAD( comx35_comx )
49{
50   address_space &program = image.device().machine().firstcpu->space(AS_PROGRAM);
51
52   UINT8 header[16] = {0};
53   int size = image.length();
54
55   if (size > image.device().machine().device<ram_device>(RAM_TAG)->size())
56   {
57      return IMAGE_INIT_FAIL;
58   }
59
60   image.fread( header, 5);
61
62   if (header[1] != 'C' || header[2] != 'O' || header[3] != 'M' || header[4] != 'X' )
63   {
64      return IMAGE_INIT_FAIL;
65   }
66
67   switch (header[0])
68   {
69   case COMX_TYPE_BINARY:
70      /*
71
72          Type 1: pure machine code (i.e. no basic)
73
74          Byte 0 to 4: 1 - 'COMX'
75          Byte 5 and 6: Start address (1802 way; see above)
76          Byte 6 and 7: End address
77          Byte 9 and 10: Execution address
78
79          Byte 11 to Eof, should be stored in ram from start to end; execution address
80          'xxxx' for the CALL (@xxxx) basic statement to actually run the code.
81
82      */
83      {
84         UINT16 start_address, end_address, run_address;
85
86         image.fread(header, 6);
87
88         start_address = pick_integer_be(header, 0, 2);
89         end_address = pick_integer_be(header, 2, 2);
90         run_address = pick_integer_be(header, 4, 2);
91
92         image_fread_memory(image, start_address, end_address - start_address);
93
94         popmessage("Type CALL (@%04x) to start program", run_address);
95      }
96      break;
97
98   case COMX_TYPE_BASIC:
99      /*
100
101          Type 2: Regular basic code or machine code followed by basic
102
103          Byte 0 to 4: 2 - 'COMX'
104          Byte 5 and 6: DEFUS value, to be stored on 0x4281 and 0x4282
105          Byte 7 and 8: EOP value, to be stored on 0x4283 and 0x4284
106          Byte 9 and 10: End array, start string to be stored on 0x4292 and 0x4293
107          Byte 11 and 12: start array to be stored on 0x4294 and 0x4295
108          Byte 13 and 14: EOD and end string to be stored on 0x4299 and 0x429A
109
110          Byte 15 to Eof to be stored on 0x4400 and onwards
111
112          Byte 0x4281-0x429A (or at least the ones above) should be set otherwise
113          BASIC won't 'see' the code.
114
115      */
116
117      image_fread_memory(image, 0x4281, 4);
118      image_fread_memory(image, 0x4292, 4);
119      image_fread_memory(image, 0x4299, 2);
120      image_fread_memory(image, 0x4400, size);
121      break;
122
123   case COMX_TYPE_BASIC_FM:
124      /*
125
126          Type 3: F&M basic load
127
128          Not the most important! But we designed our own basic extension, you can
129          find it in the F&M basic folder as F&M Basic.comx. When you run this all
130          basic code should start at address 0x6700 instead of 0x4400 as from
131          0x4400-0x6700 the F&M basic stuff is loaded. So format is identical to Type
132          2 except Byte 15 to Eof should be stored on 0x6700 instead. .comx files of
133          this format can also be found in the same folder as the F&M basic.comx file.
134
135      */
136
137      image_fread_memory(image, 0x4281, 4);
138      image_fread_memory(image, 0x4292, 4);
139      image_fread_memory(image, 0x4299, 2);
140      image_fread_memory(image, 0x6700, size);
141      break;
142
143   case COMX_TYPE_RESERVED:
144      /*
145
146          Type 4: Incorrect DATA format, I suggest to forget this one as it won't work
147          in most cases. Instead I left this one reserved and designed Type 5 instead.
148
149      */
150      break;
151
152   case COMX_TYPE_DATA:
153      /*
154
155          Type 5: Data load
156
157          Byte 0 to 4: 5 - 'COMX'
158          Byte 5 and 6: Array length
159          Byte 7 to Eof: Basic 'data'
160
161          To load this first get the 'start array' from the running COMX, i.e. address
162          0x4295/0x4296. Calculate the EOD as 'start array' + length of the data (i.e.
163          file length - 7). Store the EOD back on 0x4299 and ox429A. Calculate the
164          'Start String' as 'start array' + 'Array length' (Byte 5 and 6). Store the
165          'Start String' on 0x4292/0x4293. Load byte 7 and onwards starting from the
166          'start array' value fetched from 0x4295/0x4296.
167
168      */
169      {
170         UINT16 start_array, end_array, start_string, array_length;
171
172         image.fread(header, 2);
173
174         array_length = pick_integer_be(header, 0, 2);
175         start_array = (program.read_byte(0x4295) << 8) | program.read_byte(0x4296);
176         end_array = start_array + (size - 7);
177
178         program.write_byte(0x4299, end_array >> 8);
179         program.write_byte(0x429a, end_array & 0xff);
180
181         start_string = start_array + array_length;
182
183         program.write_byte(0x4292, start_string >> 8);
184         program.write_byte(0x4293, start_string & 0xff);
185
186         image_fread_memory(image, start_array, size);
187      }
188      break;
189   }
190
191   return IMAGE_INIT_PASS;
192}
trunk/src/mess/formats/ace_ace.h
r21307r21308
1/*********************************************************************
2
3    ace_ace.h
4
5    Format code for Jupiter Ace snapshot files
6
7*********************************************************************/
8
9#pragma once
10
11#ifndef ACE_ACE_H
12#define ACE_ACE_H
13
14#include "imagedev/snapquik.h"
15
16SNAPSHOT_LOAD( ace );
17
18#endif /* ACE_ACE_H */
trunk/src/mess/formats/atom_atm.h
r21307r21308
1/*********************************************************************
2
3    formats/atom_atm.h
4
5    Quickload code for Acorn Atom atm files
6
7*********************************************************************/
8
9#pragma once
10
11#ifndef __ATOM_ATM__
12#define __ATOM_ATM__
13
14#include "emu.h"
15#include "imagedev/snapquik.h"
16
17QUICKLOAD_LOAD( atom_atm );
18
19#endif
trunk/src/mess/formats/m65_snqk.h
r21307r21308
1/******************************************************************************
2 *  Microtan 65
3 *
4 *  Snapshot and quickload formats
5 *
6 *  Juergen Buchmueller <pullmoll@t-online.de>, Jul 2000
7 *
8 *  Thanks go to Geoff Macdonald <mail@geoff.org.uk>
9 *  for his site http:://www.geo255.redhotant.com
10 *  and to Fabrice Frances <frances@ensica.fr>
11 *  for his site http://www.ifrance.com/oric/microtan.html
12 *
13 *****************************************************************************/
14
15#ifndef __M65_SNQK_H__
16#define __M65_SNQK_H__
17
18#include "imagedev/snapquik.h"
19
20SNAPSHOT_LOAD( microtan );
21QUICKLOAD_LOAD( microtan );
22
23#endif /* __M65_SNQK_H__ */
trunk/src/mess/formats/comx35_comx.h
r21307r21308
1/*********************************************************************
2
3    formats/comx35_comx.h
4
5    Quickload code for COMX-35 comx files
6
7*********************************************************************/
8
9#pragma once
10
11#ifndef __COMX35_COMX__
12#define __COMX35_COMX__
13
14#include "emu.h"
15#include "imagedev/snapquik.h"
16
17QUICKLOAD_LOAD( comx35_comx );
18
19#endif
trunk/src/mess/drivers/ace.c
r21307r21308
4242
4343#include "emu.h"
4444#include "cpu/z80/z80.h"
45#include "formats/ace_ace.h"
4645#include "formats/ace_tap.h"
4746#include "imagedev/cassette.h"
4847#include "imagedev/snapquik.h"
r21307r21308
5756#include "includes/ace.h"
5857
5958
59/* Load in .ace files. These are memory images of 0x2000 to 0x7fff
60   and compressed as follows:
6061
62   ED 00        : End marker
63   ED <cnt> <byt>   : repeat <byt> count <cnt:1-240> times
64   <byt>        : <byt>
65*/
66
67/******************************************************************************
68 Snapshot Handling
69******************************************************************************/
70
71SNAPSHOT_LOAD( ace )
72{
73   cpu_device *cpu = image.device().machine().firstcpu;
74   UINT8 *RAM = image.device().machine().root_device().memregion(cpu->tag())->base();
75   address_space &space = cpu->space(AS_PROGRAM);
76   unsigned char ace_repeat, ace_byte, loop;
77   int done=0, ace_index=0x2000;
78
79   if (image.device().machine().device<ram_device>(RAM_TAG)->size() < 16*1024)
80   {
81      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "At least 16KB RAM expansion required");
82      image.message("At least 16KB RAM expansion required");
83      return IMAGE_INIT_FAIL;
84   }
85
86   logerror("Loading file %s.\r\n", image.filename());
87   while (!done && (ace_index < 0x8001))
88   {
89      image.fread( &ace_byte, 1);
90      if (ace_byte == 0xed)
91      {
92         image.fread(&ace_byte, 1);
93         switch (ace_byte)
94         {
95         case 0x00:
96               logerror("File loaded!\r\n");
97               done = 1;
98               break;
99         case 0x01:
100               image.fread(&ace_byte, 1);
101               RAM[ace_index++] = ace_byte;
102               break;
103         default:
104               image.fread(&ace_repeat, 1);
105               for (loop = 0; loop < ace_byte; loop++)
106                  RAM[ace_index++] = ace_repeat;
107               break;
108         }
109      }
110      else
111         RAM[ace_index++] = ace_byte;
112   }
113
114   logerror("Decoded %X bytes.\r\n", ace_index-0x2000);
115
116   if (!done)
117   {
118      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "EOF marker not found");
119      image.message("EOF marker not found");
120      return IMAGE_INIT_FAIL;
121   }
122
123      // patch CPU registers
124      // Some games do not follow the standard, and have rubbish in the CPU area. So,
125      // we check that some other bytes are correct.
126      // 2080 = memory size of original machine, should be 0000 or 8000 or C000.
127      // 2118 = new stack pointer, do not use if between 8000 and FF00.
128
129   ace_index = RAM[0x2080] | (RAM[0x2081] << 8);
130
131   if ((ace_index & 0x3FFF)==0)
132   {
133      cpu->set_state_int(Z80_AF, RAM[0x2100] | (RAM[0x2101] << 8));
134      cpu->set_state_int(Z80_BC, RAM[0x2104] | (RAM[0x2105] << 8));
135      cpu->set_state_int(Z80_DE, RAM[0x2108] | (RAM[0x2109] << 8));
136      cpu->set_state_int(Z80_HL, RAM[0x210c] | (RAM[0x210d] << 8));
137      cpu->set_state_int(Z80_IX, RAM[0x2110] | (RAM[0x2111] << 8));
138      cpu->set_state_int(Z80_IY, RAM[0x2114] | (RAM[0x2115] << 8));
139      cpu->set_pc(RAM[0x211c] | (RAM[0x211d] << 8));
140      cpu->set_state_int(Z80_AF2, RAM[0x2120] | (RAM[0x2121] << 8));
141      cpu->set_state_int(Z80_BC2, RAM[0x2124] | (RAM[0x2125] << 8));
142      cpu->set_state_int(Z80_DE2, RAM[0x2128] | (RAM[0x2129] << 8));
143      cpu->set_state_int(Z80_HL2, RAM[0x212c] | (RAM[0x212d] << 8));
144      cpu->set_state_int(Z80_IM, RAM[0x2130]);
145      cpu->set_state_int(Z80_IFF1, RAM[0x2134]);
146      cpu->set_state_int(Z80_IFF2, RAM[0x2138]);
147      cpu->set_state_int(Z80_I, RAM[0x213c]);
148      cpu->set_state_int(Z80_R, RAM[0x2140]);
149
150      if ((RAM[0x2119] < 0x80) || !ace_index)
151         cpu->set_state_int(STATE_GENSP, RAM[0x2118] | (RAM[0x2119] << 8));
152   }
153
154   /* Copy data to the address space */
155   for (ace_index = 0x2000; ace_index < 0x8000; ace_index++)
156      space.write_byte(ace_index, RAM[ace_index]);
157
158   return IMAGE_INIT_PASS;
159}
160
61161//**************************************************************************
62162//  READ/WRITE HANDLERS
63163//**************************************************************************
trunk/src/mess/drivers/lisa.c
r21307r21308
1313#include "cpu/m6502/m6504.h"
1414#include "cpu/cop400/cop400.h"
1515#include "includes/lisa.h"
16#include "devices/sonydriv.h"
16#include "machine/sonydriv.h"
1717#include "machine/applefdc.h"
1818#include "formats/ap_dsk35.h"
1919#include "machine/6522via.h"
trunk/src/mess/drivers/studio2.c
r21307r21308
200200
201201#include "includes/studio2.h"
202202
203/***************************************************************************
204    PARAMETERS
205***************************************************************************/
206
207#define LOG 1
208
209#define ST2_BLOCK_SIZE 256
210
211/***************************************************************************
212    TYPE DEFINITIONS
213***************************************************************************/
214
215struct st2_header
216{
217   UINT8 header[4];            /* "RCA2" in ASCII code */
218   UINT8 blocks;               /* Total number of 256 byte blocks in file (including this one) */
219   UINT8 format;               /* Format Code (this is format number 1) */
220   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) */
221   UINT8 reserved0;
222   UINT8 author[2];            /* 2 byte ASCII code indicating the identity of the program coder */
223   UINT8 dumper[2];            /* 2 byte ASCII code indicating the identity of the ROM Source */
224   UINT8 reserved1[4];
225   UINT8 catalogue[10];        /* RCA Catalogue Code as ASCIIZ string. If a homebrew ROM, may contain any identifying code you wish */
226   UINT8 reserved2[6];
227   UINT8 title[32];            /* Cartridge Program Title as ASCIIZ string */
228   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 */
229   UINT8 reserved3[128];
230};
231
232/***************************************************************************
233    IMPLEMENTATION
234***************************************************************************/
235
236/*-------------------------------------------------
237    DEVICE_IMAGE_LOAD( st2_cartslot_load )
238-------------------------------------------------*/
239
240DEVICE_IMAGE_LOAD_LEGACY( st2_cartslot_load )
241{
242   st2_header header;
243
244   /* check file size */
245   int filesize = image.length();
246
247   if (filesize <= ST2_BLOCK_SIZE) {
248      logerror("Error loading cartridge: Invalid ROM file: %s.\n", image.filename());
249      return IMAGE_INIT_FAIL;
250   }
251
252   /* read ST2 header */
253   if (image.fread( &header, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
254      logerror("Error loading cartridge: Unable to read header from file: %s.\n", image.filename());
255      return IMAGE_INIT_FAIL;
256   }
257
258   if (LOG) logerror("ST2 Catalogue: %s\n", header.catalogue);
259   if (LOG) logerror("ST2 Title: %s\n", header.title);
260
261   /* read ST2 cartridge into memory */
262   for (int block = 0; block < (header.blocks - 1); block++)
263   {
264      UINT16 offset = header.page[block] << 8;
265      UINT8 *ptr = ((UINT8 *) image.device().machine().root_device().memregion(CDP1802_TAG)->base()) + offset;
266
267      if (LOG) logerror("ST2 Reading block %u to %04x\n", block, offset);
268
269      if (image.fread( ptr, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
270         logerror("Error loading cartridge: Unable to read contents from file: %s.\n", image.filename());
271         return IMAGE_INIT_FAIL;
272      }
273   }
274
275   return IMAGE_INIT_PASS;
276}
277
278
203279/* Read/Write Handlers */
204280
205281WRITE8_MEMBER( studio2_state::keylatch_w )
trunk/src/mess/drivers/atom.c
r21307r21308
112112*/
113113
114114#include "includes/atom.h"
115#include "formats/imageutl.h"
115116
116117/***************************************************************************
118    PARAMETERS
119***************************************************************************/
120
121#define LOG 1
122
123/***************************************************************************
124    IMPLEMENTATION
125***************************************************************************/
126
127/*-------------------------------------------------
128    image_fread_memory - read image to memory
129-------------------------------------------------*/
130
131static void image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
132{
133   void *ptr = image.device().machine().firstcpu->space(AS_PROGRAM).get_write_ptr(addr);
134
135   image.fread( ptr, count);
136}
137
138/*-------------------------------------------------
139    QUICKLOAD_LOAD( atom_atm )
140-------------------------------------------------*/
141
142QUICKLOAD_LOAD( atom_atm )
143{
144   /*
145
146       The format for the .ATM files is as follows:
147
148       Offset Size     Description
149       ------ -------- -----------------------------------------------------------
150       0000h  16 BYTEs ATOM filename (if less than 16 BYTEs, rest is 00h bytes)
151       0010h  WORD     Start address for load
152       0012h  WORD     Execution address
153       0014h  WORD     Size of data in BYTEs
154       0016h  Size     Data
155
156   */
157
158   UINT8 header[0x16] = { 0 };
159
160   image.fread(header, 0x16);
161
162   UINT16 start_address = pick_integer_le(header, 0x10, 2);
163   UINT16 run_address = pick_integer_le(header, 0x12, 2);
164   UINT16 size = pick_integer_le(header, 0x14, 2);
165
166   if (LOG)
167   {
168      header[16] = 0;
169      logerror("ATM filename: %s\n", header);
170      logerror("ATM start address: %04x\n", start_address);
171      logerror("ATM run address: %04x\n", run_address);
172      logerror("ATM size: %04x\n", size);
173   }
174
175   image_fread_memory(image, start_address, size);
176
177   image.device().machine().firstcpu->set_pc(run_address);
178
179   return IMAGE_INIT_PASS;
180}
181
182/***************************************************************************
117183    READ/WRITE HANDLERS
118184***************************************************************************/
119185
trunk/src/mess/drivers/mac.c
r21307r21308
5151#include "machine/ncr5380.h"
5252#include "machine/applefdc.h"
5353#include "machine/swim.h"
54#include "devices/sonydriv.h"
54#include "machine/sonydriv.h"
5555#include "formats/ap_dsk35.h"
5656#include "machine/ram.h"
5757#include "machine/scsibus.h"
trunk/src/mess/drivers/microtan.c
r21307r21308
4949
5050/* Devices */
5151#include "imagedev/cassette.h"
52#include "formats/m65_snqk.h"
5352
5453
5554static ADDRESS_MAP_START( microtan_map, AS_PROGRAM, 8, microtan_state )
trunk/src/mess/drivers/comx35.c
r21307r21308
1111*/
1212
1313#include "includes/comx35.h"
14#include "formats/imageutl.h"
1415
1516
17/***************************************************************************
18    PARAMETERS
19***************************************************************************/
1620
21#define LOG 1
22
23enum
24{
25   COMX_TYPE_BINARY = 1,
26   COMX_TYPE_BASIC,
27   COMX_TYPE_BASIC_FM,
28   COMX_TYPE_RESERVED,
29   COMX_TYPE_DATA
30};
31
32/***************************************************************************
33    IMPLEMENTATION
34***************************************************************************/
35
36/*-------------------------------------------------
37    image_fread_memory - read image to memory
38-------------------------------------------------*/
39
40static void image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
41{
42   UINT8 *ram = image.device().machine().device<ram_device>(RAM_TAG)->pointer() + (addr - 0x4000);
43
44   image.fread(ram, count);
45}
46
47/*-------------------------------------------------
48    QUICKLOAD_LOAD( comx35_comx )
49-------------------------------------------------*/
50
51QUICKLOAD_LOAD( comx35_comx )
52{
53   address_space &program = image.device().machine().firstcpu->space(AS_PROGRAM);
54
55   UINT8 header[16] = {0};
56   int size = image.length();
57
58   if (size > image.device().machine().device<ram_device>(RAM_TAG)->size())
59   {
60      return IMAGE_INIT_FAIL;
61   }
62
63   image.fread( header, 5);
64
65   if (header[1] != 'C' || header[2] != 'O' || header[3] != 'M' || header[4] != 'X' )
66   {
67      return IMAGE_INIT_FAIL;
68   }
69
70   switch (header[0])
71   {
72   case COMX_TYPE_BINARY:
73      /*
74
75          Type 1: pure machine code (i.e. no basic)
76
77          Byte 0 to 4: 1 - 'COMX'
78          Byte 5 and 6: Start address (1802 way; see above)
79          Byte 6 and 7: End address
80          Byte 9 and 10: Execution address
81
82          Byte 11 to Eof, should be stored in ram from start to end; execution address
83          'xxxx' for the CALL (@xxxx) basic statement to actually run the code.
84
85      */
86      {
87         UINT16 start_address, end_address, run_address;
88
89         image.fread(header, 6);
90
91         start_address = pick_integer_be(header, 0, 2);
92         end_address = pick_integer_be(header, 2, 2);
93         run_address = pick_integer_be(header, 4, 2);
94
95         image_fread_memory(image, start_address, end_address - start_address);
96
97         popmessage("Type CALL (@%04x) to start program", run_address);
98      }
99      break;
100
101   case COMX_TYPE_BASIC:
102      /*
103
104          Type 2: Regular basic code or machine code followed by basic
105
106          Byte 0 to 4: 2 - 'COMX'
107          Byte 5 and 6: DEFUS value, to be stored on 0x4281 and 0x4282
108          Byte 7 and 8: EOP value, to be stored on 0x4283 and 0x4284
109          Byte 9 and 10: End array, start string to be stored on 0x4292 and 0x4293
110          Byte 11 and 12: start array to be stored on 0x4294 and 0x4295
111          Byte 13 and 14: EOD and end string to be stored on 0x4299 and 0x429A
112
113          Byte 15 to Eof to be stored on 0x4400 and onwards
114
115          Byte 0x4281-0x429A (or at least the ones above) should be set otherwise
116          BASIC won't 'see' the code.
117
118      */
119
120      image_fread_memory(image, 0x4281, 4);
121      image_fread_memory(image, 0x4292, 4);
122      image_fread_memory(image, 0x4299, 2);
123      image_fread_memory(image, 0x4400, size);
124      break;
125
126   case COMX_TYPE_BASIC_FM:
127      /*
128
129          Type 3: F&M basic load
130
131          Not the most important! But we designed our own basic extension, you can
132          find it in the F&M basic folder as F&M Basic.comx. When you run this all
133          basic code should start at address 0x6700 instead of 0x4400 as from
134          0x4400-0x6700 the F&M basic stuff is loaded. So format is identical to Type
135          2 except Byte 15 to Eof should be stored on 0x6700 instead. .comx files of
136          this format can also be found in the same folder as the F&M basic.comx file.
137
138      */
139
140      image_fread_memory(image, 0x4281, 4);
141      image_fread_memory(image, 0x4292, 4);
142      image_fread_memory(image, 0x4299, 2);
143      image_fread_memory(image, 0x6700, size);
144      break;
145
146   case COMX_TYPE_RESERVED:
147      /*
148
149          Type 4: Incorrect DATA format, I suggest to forget this one as it won't work
150          in most cases. Instead I left this one reserved and designed Type 5 instead.
151
152      */
153      break;
154
155   case COMX_TYPE_DATA:
156      /*
157
158          Type 5: Data load
159
160          Byte 0 to 4: 5 - 'COMX'
161          Byte 5 and 6: Array length
162          Byte 7 to Eof: Basic 'data'
163
164          To load this first get the 'start array' from the running COMX, i.e. address
165          0x4295/0x4296. Calculate the EOD as 'start array' + length of the data (i.e.
166          file length - 7). Store the EOD back on 0x4299 and ox429A. Calculate the
167          'Start String' as 'start array' + 'Array length' (Byte 5 and 6). Store the
168          'Start String' on 0x4292/0x4293. Load byte 7 and onwards starting from the
169          'start array' value fetched from 0x4295/0x4296.
170
171      */
172      {
173         UINT16 start_array, end_array, start_string, array_length;
174
175         image.fread(header, 2);
176
177         array_length = pick_integer_be(header, 0, 2);
178         start_array = (program.read_byte(0x4295) << 8) | program.read_byte(0x4296);
179         end_array = start_array + (size - 7);
180
181         program.write_byte(0x4299, end_array >> 8);
182         program.write_byte(0x429a, end_array & 0xff);
183
184         start_string = start_array + array_length;
185
186         program.write_byte(0x4292, start_string >> 8);
187         program.write_byte(0x4293, start_string & 0xff);
188
189         image_fread_memory(image, start_array, size);
190      }
191      break;
192   }
193
194   return IMAGE_INIT_PASS;
195}
196
17197//**************************************************************************
18198//  MEMORY ACCESS
19199//**************************************************************************
trunk/src/mess/mess.mak
r21307r21308
580580   $(MESS_DRIVERS)/a7000.o     \
581581   $(MESS_DRIVERS)/acrnsys1.o  \
582582   $(MESS_DRIVERS)/atom.o      \
583   $(MESS_FORMATS)/atom_atm.o  \
584583   $(MESS_VIDEO)/bbc.o         \
585584   $(MESS_MACHINE)/bbc.o       \
586585   $(MESS_DRIVERS)/bbc.o       \
r21307r21308
810809
811810$(MESSOBJ)/cantab.a:            \
812811   $(MESS_DRIVERS)/ace.o       \
813   $(MESS_FORMATS)/ace_ace.o   \
814812
815813$(MESSOBJ)/casio.a:             \
816814   $(MESS_DRIVERS)/casloopy.o  \
r21307r21308
10171015
10181016$(MESSOBJ)/comx.a:              \
10191017   $(MESS_DRIVERS)/comx35.o    \
1020   $(MESS_FORMATS)/comx35_comx.o   \
10211018   $(MESS_MACHINE)/comxpl80.o  \
10221019   $(MESS_VIDEO)/comx35.o      \
10231020   $(MESS_MACHINE)/comxexp.o   \
r21307r21308
15781575
15791576$(MESSOBJ)/rca.a:               \
15801577   $(MESS_DRIVERS)/studio2.o   \
1581   $(MESS_FORMATS)/studio2_st2.o   \
15821578   $(MESS_DRIVERS)/vip.o       \
15831579   $(MESS_MACHINE)/vip_byteio.o    \
15841580   $(MESS_MACHINE)/vip_exp.o   \
r21307r21308
17691765   $(MESS_VIDEO)/microtan.o    \
17701766   $(MESS_MACHINE)/microtan.o  \
17711767   $(MESS_DRIVERS)/microtan.o  \
1772   $(MESS_FORMATS)/m65_snqk.o  \
17731768   $(MESS_DRIVERS)/oric.o      \
17741769   $(MESS_VIDEO)/oric.o        \
17751770   $(MESS_MACHINE)/oric.o      \
r21307r21308
19141909   $(MESS_DRIVERS)/mc10.o      \
19151910   $(MESS_MACHINE)/trs80.o     \
19161911   $(MESS_VIDEO)/trs80.o       \
1917   $(MESS_FORMATS)/trs_cmd.o   \
19181912   $(MESS_DRIVERS)/trs80.o     \
19191913   $(MESS_DRIVERS)/trs80m2.o   \
19201914   $(MESS_MACHINE)/trs80m2kb.o \
trunk/src/mess/machine/macpci.c
r21307r21308
1313#include "machine/8530scc.h"
1414#include "cpu/m68000/m68000.h"
1515#include "machine/applefdc.h"
16#include "devices/sonydriv.h"
16#include "machine/sonydriv.h"
1717#include "includes/macpci.h"
1818#include "debug/debugcpu.h"
1919#include "machine/ram.h"
trunk/src/mess/machine/mac.c
r21307r21308
9696#include "machine/8530scc.h"
9797#include "cpu/m68000/m68000.h"
9898#include "machine/applefdc.h"
99#include "devices/sonydriv.h"
99#include "machine/sonydriv.h"
100100#include "machine/ncr5380.h"
101101#include "sound/asc.h"
102102#include "includes/mac.h"
trunk/src/mess/machine/trs80.c
r21307r21308
910910   m_reg_load = 1;
911911   lnw80_fe_w(space, 0, 0);
912912}
913
914
915/***************************************************************************
916    PARAMETERS
917***************************************************************************/
918
919#define LOG 1
920
921#define CMD_TYPE_OBJECT_CODE                            0x01
922#define CMD_TYPE_TRANSFER_ADDRESS                       0x02
923#define CMD_TYPE_END_OF_PARTITIONED_DATA_SET_MEMBER     0x04
924#define CMD_TYPE_LOAD_MODULE_HEADER                     0x05
925#define CMD_TYPE_PARTITIONED_DATA_SET_HEADER            0x06
926#define CMD_TYPE_PATCH_NAME_HEADER                      0x07
927#define CMD_TYPE_ISAM_DIRECTORY_ENTRY                   0x08
928#define CMD_TYPE_END_OF_ISAM_DIRECTORY_ENTRY            0x0a
929#define CMD_TYPE_PDS_DIRECTORY_ENTRY                    0x0c
930#define CMD_TYPE_END_OF_PDS_DIRECTORY_ENTRY             0x0e
931#define CMD_TYPE_YANKED_LOAD_BLOCK                      0x10
932#define CMD_TYPE_COPYRIGHT_BLOCK                        0x1f
933
934/***************************************************************************
935    IMPLEMENTATION
936***************************************************************************/
937
938QUICKLOAD_LOAD( trs80_cmd )
939{
940   address_space &program = image.device().machine().firstcpu->space(AS_PROGRAM);
941
942   UINT8 type, length;
943   UINT8 data[0x100];
944   UINT8 addr[2];
945   void *ptr;
946
947   while (!image.image_feof())
948   {
949      image.fread( &type, 1);
950      image.fread( &length, 1);
951
952      length -= 2;
953      int block_length = length ? length : 256;
954
955      switch (type)
956      {
957      case CMD_TYPE_OBJECT_CODE:
958         {
959         image.fread( &addr, 2);
960         UINT16 address = (addr[1] << 8) | addr[0];
961         if (LOG) logerror("/CMD object code block: address %04x length %u\n", address, block_length);
962         ptr = program.get_write_ptr(address);
963         image.fread( ptr, block_length);
964         }
965         break;
966
967      case CMD_TYPE_TRANSFER_ADDRESS:
968         {
969         image.fread( &addr, 2);
970         UINT16 address = (addr[1] << 8) | addr[0];
971         if (LOG) logerror("/CMD transfer address %04x\n", address);
972         image.device().machine().firstcpu->set_state_int(Z80_PC, address);
973         }
974         break;
975
976      case CMD_TYPE_LOAD_MODULE_HEADER:
977         image.fread( &data, block_length);
978         if (LOG) logerror("/CMD load module header '%s'\n", data);
979         break;
980
981      case CMD_TYPE_COPYRIGHT_BLOCK:
982         image.fread( &data, block_length);
983         if (LOG) logerror("/CMD copyright block '%s'\n", data);
984         break;
985
986      default:
987         image.fread( &data, block_length);
988         logerror("/CMD unsupported block type %u!\n", type);
989      }
990   }
991
992   return IMAGE_INIT_PASS;
993}
trunk/src/mess/machine/microtan.c
r21307r21308
580580   }
581581   set_led_status(machine(), 1, (m_keyrows[3] & 0x80) ? 0 : 1);
582582}
583
584static int microtan_verify_snapshot(UINT8 *data, int size)
585{
586   if (size == 8263)
587   {
588      logerror("microtan_snapshot_id: magic size %d found\n", size);
589      return IMAGE_VERIFY_PASS;
590   }
591   else
592   {
593      if (4 + data[2] + 256 * data[3] + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 == size)
594      {
595         logerror("microtan_snapshot_id: header RAM size + structures matches filesize %d\n", size);
596         return IMAGE_VERIFY_PASS;
597      }
598   }
599
600   return IMAGE_VERIFY_FAIL;
601}
602
603static int parse_intel_hex(UINT8 *snapshot_buff, char *src)
604{
605   char line[128];
606   int /*row = 0,*/ column = 0, last_addr = 0, last_size = 0;
607
608   while (*src)
609   {
610      if (*src == '\r' || *src == '\n')
611      {
612         if (column)
613         {
614            unsigned int size, addr, null, b[32], cs, n;
615
616            line[column] = '\0';
617            /*row++;*/
618            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",
619               &size, &addr, &null,
620               &b[ 0], &b[ 1], &b[ 2], &b[ 3], &b[ 4], &b[ 5], &b[ 6], &b[ 7],
621               &b[ 8], &b[ 9], &b[10], &b[11], &b[12], &b[13], &b[14], &b[15],
622               &b[16], &b[17], &b[18], &b[19], &b[20], &b[21], &b[22], &b[23],
623               &b[24], &b[25], &b[26], &b[27], &b[28], &b[29], &b[30], &b[31],
624               &cs);
625            if (n == 0)
626            {
627               logerror("parse_intel_hex: malformed line [%s]\n", line);
628            }
629            else if (n == 1)
630            {
631               logerror("parse_intel_hex: only size found [%s]\n", line);
632            }
633            else if (n == 2)
634            {
635               logerror("parse_intel_hex: only size and addr found [%s]\n", line);
636            }
637            else if (n == 3)
638            {
639               logerror("parse_intel_hex: only size, addr and null found [%s]\n", line);
640            }
641            else
642            if (null != 0)
643            {
644               logerror("parse_intel_hex: warning null byte is != 0 [%s]\n", line);
645            }
646            else
647            {
648               int i, sum;
649
650               n -= 3;
651
652               sum = size + (addr & 0xff) + ((addr >> 8) & 0xff);
653               if (n != 32 + 1)
654                  cs = b[n-1];
655
656               last_addr = addr;
657               last_size = n-1;
658               logerror("parse_intel_hex: %04X", addr);
659               for (i = 0; i < n-1; i++)
660               {
661                  sum += b[i];
662                  snapshot_buff[addr++] = b[i];
663               }
664               logerror("-%04X checksum %02X+%02X = %02X\n", addr-1, cs, sum & 0xff, (cs + sum) & 0xff);
665            }
666         }
667         column = 0;
668      }
669      else
670      {
671         line[column++] = *src;
672      }
673      src++;
674   }
675   /* register preset? */
676   if (last_size == 7)
677   {
678      logerror("parse_intel_hex: registers (?) at %04X\n", last_addr);
679      memcpy(&snapshot_buff[8192+64], &snapshot_buff[last_addr], last_size);
680   }
681   return IMAGE_INIT_PASS;
682}
683
684static int parse_zillion_hex(UINT8 *snapshot_buff, char *src)
685{
686   char line[128];
687   int parsing = 0, /*row = 0,*/ column = 0;
688
689   while (*src)
690   {
691      if (parsing)
692      {
693         if (*src == '}')
694            parsing = 0;
695         else
696         {
697            if (*src == '\r' || *src == '\n')
698            {
699               if (column)
700               {
701                  unsigned int addr, b[8], n;
702
703                  line[column] = '\0';
704                  /*row++;*/
705                  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]);
706                  if (n == 0)
707                  {
708                     logerror("parse_zillion_hex: malformed line [%s]\n", line);
709                  }
710                  else if (n == 1)
711                  {
712                     logerror("parse_zillion_hex: only addr found [%s]\n", line);
713                  }
714                  else
715                  {
716                     int i;
717
718                     logerror("parse_zillion_hex: %04X", addr);
719                     for (i = 0; i < n-1; i++)
720                        snapshot_buff[addr++] = b[i];
721                     logerror("-%04X\n", addr-1);
722                  }
723               }
724               column = 0;
725            }
726            else
727            {
728               line[column++] = *src;
729            }
730         }
731      }
732      else
733      {
734         if (*src == '\r' || *src == '\n')
735         {
736            if (column)
737            {
738               int addr, n;
739
740               /*row++;*/
741               line[column] = '\0';
742               n = sscanf(line, "G%x", (unsigned int *) &addr);
743               if (n == 1 && !snapshot_buff[8192+64+0] && !snapshot_buff[8192+64+1])
744               {
745                  logerror("microtan_hexfile_init: go addr %04X\n", addr);
746                  snapshot_buff[8192+64+0] = addr & 0xff;
747                  snapshot_buff[8192+64+1] = (addr >> 8) & 0xff;
748               }
749            }
750            column = 0;
751         }
752         else
753         {
754            line[column++] = *src;
755         }
756         if (*src == '{')
757         {
758            parsing = 1;
759            column = 0;
760         }
761      }
762      src++;
763   }
764   return IMAGE_INIT_PASS;
765}
766
767static void microtan_set_cpu_regs(running_machine &machine,const UINT8 *snapshot_buff, int base)
768{
769   logerror("microtan_snapshot_copy: PC:%02X%02X P:%02X A:%02X X:%02X Y:%02X SP:1%02X",
770      snapshot_buff[base+1], snapshot_buff[base+0], snapshot_buff[base+2], snapshot_buff[base+3],
771      snapshot_buff[base+4], snapshot_buff[base+5], snapshot_buff[base+6]);
772   machine.device("maincpu")->state().set_state_int(M6502_PC, snapshot_buff[base+0] + 256 * snapshot_buff[base+1]);
773   machine.device("maincpu")->state().set_state_int(M6502_P, snapshot_buff[base+2]);
774   machine.device("maincpu")->state().set_state_int(M6502_A, snapshot_buff[base+3]);
775   machine.device("maincpu")->state().set_state_int(M6502_X, snapshot_buff[base+4]);
776   machine.device("maincpu")->state().set_state_int(M6502_Y, snapshot_buff[base+5]);
777   machine.device("maincpu")->state().set_state_int(M6502_S, snapshot_buff[base+6]);
778}
779
780static void microtan_snapshot_copy(running_machine &machine, UINT8 *snapshot_buff, int snapshot_size)
781{
782   microtan_state *state = machine.driver_data<microtan_state>();
783   UINT8 *RAM = state->memregion("maincpu")->base();
784   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
785   via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
786   via6522_device *via_1 = machine.device<via6522_device>("via6522_1");
787   device_t *ay8910 = machine.device("ay8910.1");
788
789   /* check for .DMP file format */
790   if (snapshot_size == 8263)
791   {
792      int i, base;
793      /********** DMP format
794       * Lower 8k of RAM (0000 to 1fff)
795       * 64 bytes of chunky graphics bits (first byte bit is for character at 0200, bit 1=0201, etc)
796       * 7 bytes of CPU registers (PCL, PCH, PSW, A, IX, IY, SP)
797       */
798      logerror("microtan_snapshot_copy: magic size %d found, assuming *.DMP format\n", snapshot_size);
799
800      base = 0;
801      /* 8K of RAM from 0000 to 1fff */
802      memcpy(RAM, &snapshot_buff[base], 8192);
803      base += 8192;
804      /* 64 bytes of chunky graphics info */
805      for (i = 0; i < 32*16; i++)
806      {
807         state->m_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
808      }
809      base += 64;
810      microtan_set_cpu_regs(machine, snapshot_buff, base);
811   }
812   else
813   {
814      int i, ramend, base;
815      /********** M65 format ************************************
816       *  2 bytes: File version
817       *  2 bytes: RAM size
818       *  n bytes: RAM (0000 to RAM Size)
819       * 16 bytes: 1st 6522 (0xbfc0 to 0xbfcf)
820       * 16 bytes: 2ns 6522 (0xbfe0 to 0xbfef)
821       * 16 bytes: Microtan IO (0xbff0 to 0xbfff)
822       *  1 byte : Invaders sound (0xbc04)
823       *  1 byte : Chunky graphics state (0=off, 1=on)
824       * 16 bytes: 1st AY8910 registers
825       * 16 bytes: 2nd AY8910 registers
826       * 64 bytes: Chunky graphics bits (first byte bit 0 is for character at 0200, bit 1=0201, etc)
827       *  7 bytes: CPU registers (PCL, PCH, PSW, A, IX, IY, SP)
828       */
829      ramend = snapshot_buff[2] + 256 * snapshot_buff[3];
830      if (2 + 2 + ramend + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 != snapshot_size)
831      {
832         logerror("microtan_snapshot_copy: size %d doesn't match RAM size %d + structure size\n", snapshot_size, ramend+1);
833         return;
834      }
835
836      logerror("microtan_snapshot_copy: size %d found, assuming *.M65 format\n", snapshot_size);
837      base = 4;
838      memcpy(RAM, &snapshot_buff[base], snapshot_buff[2] + 256 * snapshot_buff[3] + 1);
839      base += ramend + 1;
840
841      /* first set of VIA6522 registers */
842      for (i = 0; i < 16; i++ )
843         via_0->write(space, i, snapshot_buff[base++]);
844
845      /* second set of VIA6522 registers */
846      for (i = 0; i < 16; i++ )
847         via_1->write(space, i, snapshot_buff[base++]);
848
849      /* microtan IO bff0-bfff */
850      for (i = 0; i < 16; i++ )
851      {
852         RAM[0xbff0+i] = snapshot_buff[base++];
853         if (i < 4)
854            state->microtan_bffx_w(space, i, RAM[0xbff0+i]);
855      }
856
857      state->microtan_sound_w(space, 0, snapshot_buff[base++]);
858      state->m_chunky_graphics = snapshot_buff[base++];
859
860      /* first set of AY8910 registers */
861      for (i = 0; i < 16; i++ )
862      {
863         ay8910_address_w(ay8910, state->generic_space(), 0, i);
864         ay8910_data_w(ay8910, state->generic_space(), 0, snapshot_buff[base++]);
865      }
866
867      /* second set of AY8910 registers */
868      for (i = 0; i < 16; i++ )
869      {
870         ay8910_address_w(ay8910, state->generic_space(), 0, i);
871         ay8910_data_w(ay8910, state->generic_space(), 0, snapshot_buff[base++]);
872      }
873
874      for (i = 0; i < 32*16; i++)
875      {
876         state->m_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
877      }
878      base += 64;
879
880      microtan_set_cpu_regs(machine, snapshot_buff, base);
881   }
882}
883
884SNAPSHOT_LOAD( microtan )
885{
886   UINT8 *snapshot_buff;
887
888   snapshot_buff = (UINT8*)image.ptr();
889   if (!snapshot_buff)
890      return IMAGE_INIT_FAIL;
891
892   if (microtan_verify_snapshot(snapshot_buff, snapshot_size)==IMAGE_VERIFY_FAIL)
893      return IMAGE_INIT_FAIL;
894
895   microtan_snapshot_copy(image.device().machine(), snapshot_buff, snapshot_size);
896   return IMAGE_INIT_PASS;
897}
898
899QUICKLOAD_LOAD( microtan )
900{
901   int snapshot_size;
902   UINT8 *snapshot_buff;
903   char *buff;
904   int rc;
905
906   snapshot_size = 8263;   /* magic size */
907   snapshot_buff = (UINT8*)malloc(snapshot_size);
908   if (!snapshot_buff)
909   {
910      logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", snapshot_size);
911      return IMAGE_INIT_FAIL;
912   }
913   memset(snapshot_buff, 0, snapshot_size);
914
915   buff = (char*)malloc(quickload_size + 1);
916   if (!buff)
917   {
918      free(snapshot_buff);
919      logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", quickload_size);
920      return IMAGE_INIT_FAIL;
921   }
922   image.fread( buff, quickload_size);
923
924   buff[quickload_size] = '\0';
925
926   if (buff[0] == ':')
927      rc = parse_intel_hex(snapshot_buff, buff);
928   else
929      rc = parse_zillion_hex(snapshot_buff, buff);
930   if (rc == IMAGE_INIT_PASS)
931      microtan_snapshot_copy(image.device().machine(), snapshot_buff, snapshot_size);
932   free(snapshot_buff);
933   return rc;
934}
trunk/src/mess/machine/apple2gs.c
r21307r21308
121121#include "includes/apple2.h"
122122#include "machine/ay3600.h"
123123#include "machine/applefdc.h"
124#include "devices/sonydriv.h"
124#include "machine/sonydriv.h"
125125#include "machine/8530scc.h"
126126#include "imagedev/flopdrv.h"
127127#include "cpu/g65816/g65816.h"
trunk/src/mess/includes/comx35.h
r21307r21308
66
77#include "emu.h"
88#include "cpu/cosmac/cosmac.h"
9#include "formats/comx35_comx.h"
109#include "imagedev/cassette.h"
1110#include "imagedev/printer.h"
1211#include "imagedev/snapquik.h"
trunk/src/mess/includes/microtan.h
r21307r21308
8484extern const via6522_interface microtan_via6522_1;
8585
8686SNAPSHOT_LOAD( microtan );
87QUICKLOAD_LOAD( microtan_hexfile );
88
87QUICKLOAD_LOAD( microtan );
8988#endif /* MICROTAN_H_ */
trunk/src/mess/includes/lisa.h
r21307r21308
1414#include "machine/8530scc.h"
1515#include "machine/6522via.h"
1616#include "machine/applefdc.h"
17#include "devices/sonydriv.h"
17#include "machine/sonydriv.h"
1818#include "cpu/m68000/m68000.h"
1919#include "sound/speaker.h"
2020
trunk/src/mess/includes/studio2.h
r21307r21308
77#include "emu.h"
88#include "cpu/cosmac/cosmac.h"
99#include "imagedev/cartslot.h"
10#include "formats/studio2_st2.h"
1110#include "sound/beep.h"
1211#include "sound/cdp1864.h"
1312#include "sound/discrete.h"
trunk/src/mess/includes/trs80.h
r21307r21308
1818#include "imagedev/flopdrv.h"
1919#include "imagedev/snapquik.h"
2020#include "formats/trs_cas.h"
21#include "formats/trs_cmd.h"
2221#include "formats/trs_dsk.h"
2322
2423
r21307r21308
193192
194193extern const wd17xx_interface trs80_wd17xx_interface;
195194
195QUICKLOAD_LOAD( trs80_cmd );
196
196197#endif  /* TRS80_H_ */
trunk/src/mess/includes/atom.h
r21307r21308
1111#include "imagedev/flopdrv.h"
1212#include "machine/ram.h"
1313#include "imagedev/snapquik.h"
14#include "formats/atom_atm.h"
1514#include "formats/atom_tap.h"
1615#include "formats/basicdsk.h"
1716#include "formats/uef_cas.h"

Previous 199869 Revisions Next


© 1997-2024 The MAME Team