Previous 15994 Revisions Next

r7873 Tuesday 20th April, 2010 at 07:50:03 UTC by Curt Coder
[ATOM] Moved *.atm quickload to formats.
[src/mess]mess.mak
[src/mess/drivers]atom.c
[src/mess/formats]atom_atm.c* atom_atm.h*
[src/mess/machine]atom.c

src/mess/machine/atom.c
r7872r7873
2323#include "machine/6522via.h"
2424#include "devices/flopdrv.h"
2525#include "devices/cassette.h"
26#include "devices/snapquik.h"
2726#include "includes/atom.h"
2827#include "sound/speaker.h"
2928
r7872r7873
194193   memory_region(machine, "maincpu")[0x0b] = mame_rand(machine) & 0x0ff;
195194}
196195
197struct atm
198{
199   UINT8   atm_name[16];
200   UINT8   atm_start_high;
201   UINT8   atm_start_low;
202   UINT8   atm_exec_high;
203   UINT8   atm_exec_low;
204   UINT8   atm_size_high;
205   UINT8   atm_size_low;
206};
207
208/* this only works if loaded using file-manager. This should work
209for binary files, but will not work with basic files. This also does not support
210.tap files which contain multiple .atm files joined together! */
211QUICKLOAD_LOAD(atom)
212{
213   unsigned char *quickload_data;
214   int i;
215   unsigned char *data;
216   struct atm *atm_header;
217   unsigned long addr;
218   unsigned long exec;
219   unsigned long size;
220
221   quickload_data = (unsigned char *)malloc(quickload_size);
222   if (!quickload_data)
223      return INIT_FAIL;
224
225   if (image_fread(image, quickload_data, quickload_size) != quickload_size)
226   {
227      free(quickload_data);
228      return INIT_FAIL;
229   }
230
231   atm_header = (struct atm *)quickload_data;
232
233   /* calculate data address */
234   data = quickload_data + sizeof(struct atm);
235
236   /* get start address */
237   addr = (
238         (atm_header->atm_start_low & 0x0ff) |
239         ((atm_header->atm_start_high & 0x0ff)<<8)
240         );
241
242   /* get size */
243   size = (
244         (atm_header->atm_size_low & 0x0ff) |
245         ((atm_header->atm_size_high & 0x0ff)<<8)
246         );
247
248   /* get execute address */
249   exec = (
250      (atm_header->atm_exec_low & 0x0ff)   |
251      ((atm_header->atm_exec_high & 0x0ff)<<8)
252      );
253
254   /* copy data into memory */
255   for (i=size-1; i>=0; i--)
256   {
257      memory_write_byte( cputag_get_address_space( image->machine, "maincpu", ADDRESS_SPACE_PROGRAM ), addr, data[0]);
258      addr++;
259      data++;
260   }
261
262
263   /* set new pc address */
264   cpu_set_reg( devtag_get_device(image->machine, "maincpu"), REG_GENPC, exec);
265
266   /* free the data */
267   free(quickload_data);
268   return INIT_PASS;
269}
270
271196READ8_DEVICE_HANDLER (atom_8255_porta_r )
272197{
273198   /* logerror("8255: Read port a\n"); */
src/mess/formats/atom_atm.c
r0r7873
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/atom_atm.h"
11#include "cpu/cdp1802/cdp1802.h"
12#include "devices/messram.h"
13
14/***************************************************************************
15    PARAMETERS
16***************************************************************************/
17
18#define LOG 1
19
20/***************************************************************************
21    IMPLEMENTATION
22***************************************************************************/
23
24/*
25
26   The format for the .ATM files is as follows:
27
28   Offset Size     Description
29   ------ -------- -----------------------------------------------------------
30   0000h  16 BYTEs ATOM filename (if less than 16 BYTEs, rest is 00h bytes)
31   0010h  WORD     Start address for load
32   0012h  WORD     Execution address
33   0014h  WORD     Size of data in BYTEs
34   0016h  Size     Data
35
36*/
37
38static void image_fread_memory(running_device *image, UINT16 addr, UINT32 count)
39{
40   void *ptr = memory_get_write_ptr(cpu_get_address_space(image->machine->firstcpu, ADDRESS_SPACE_PROGRAM), addr);
41
42   image_fread(image, ptr, count);
43}
44
45QUICKLOAD_LOAD( atom_atm )
46{
47   UINT8 header[0x16] = { 0 };
48
49   image_fread(image, header, 0x16);
50
51   UINT16 start_address = header[0x10] << 8 | header[0x11];
52   UINT16 run_address = header[0x12] << 8 | header[0x13];
53   UINT16 size = header[0x14] << 8 | header[0x15];
54
55   if (LOG)
56   {
57      header[16] = 0;
58      logerror("ATM filename: %s\n", header);
59      logerror("ATM start address: %04x\n", start_address);
60      logerror("ATM run address: %04x\n", run_address);
61      logerror("ATM size: %04x\n", size);
62   }
63
64   image_fread_memory(image, start_address, size);
65
66   cpu_set_reg(image->machine->firstcpu, REG_GENPC, run_address);
67
68   return INIT_PASS;
69}
src/mess/formats/atom_atm.h
r0r7873
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 "devices/snapquik.h"
16
17QUICKLOAD_LOAD( atom_atm );
18
19#endif
src/mess/mess.mak
r7872r7873
541541   $(MESS_VIDEO)/z88.o         \
542542   $(MESS_DRIVERS)/atom.o      \
543543   $(MESS_MACHINE)/atom.o      \
544   $(MESS_FORMATS)/atom_atm.o   \
544545   $(MESS_FORMATS)/uef_cas.o   \
545546   $(MESS_FORMATS)/csw_cas.o   \
546547   $(MESS_VIDEO)/electron.o   \
src/mess/drivers/atom.c
r7872r7873
7070
7171/* Devices */
7272#include "devices/flopdrv.h"
73#include "formats/atom_atm.h"
7374#include "formats/basicdsk.h"
7475#include "devices/cassette.h"
7576#include "devices/snapquik.h"
r7872r7873
324325   MDRV_CENTRONICS_ADD("centronics", atom_centronics_config)
325326
326327   /* quickload */
327   MDRV_QUICKLOAD_ADD("quickload", atom, "atm", 0)
328   MDRV_QUICKLOAD_ADD("quickload", atom_atm, "atm", 0)
328329
329330   /* cassette */
330331   MDRV_CASSETTE_ADD( "cassette", default_cassette_config )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team