Previous 15994 Revisions Next

r9728 Sunday 5th December, 2010 at 08:29:26 UTC by Robbbert
[JUPITER] Loading of ace files is now done via snapshot.
[src/mess/drivers]jupiter.c
[src/mess/includes]jupiter.h
[src/mess/machine]jupiter.c

src/mess/machine/jupiter.c
r9727r9728
88***************************************************************************/
99
1010#include "emu.h"
11#include "devices/snapquik.h"
1112#include "includes/jupiter.h"
1213
1314
14static TIMER_CALLBACK( jupiter_begin )
15{
16   jupiter_state *state = machine->driver_data<jupiter_state>();
17   UINT16 loop;
18   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
1915
20   for (loop = 0; loop < 0x6000; loop++)
21      space->write_byte(loop + 0x2000, state->data[loop]);
22
23   free(state->data);
24   state->data = NULL;
25}
26
27
2816/* Load in .ace files. These are memory images of 0x2000 to 0x7fff
2917   and compressed as follows:
3018
r9727r9728
3422   <byt>        : <byt>
3523*/
3624
37DEVICE_IMAGE_LOAD( jupiter_ace )
25
26/******************************************************************************
27 Snapshot Handling
28******************************************************************************/
29
30SNAPSHOT_LOAD(jupiter)
3831{
39   jupiter_state *state = image.device().machine->driver_data<jupiter_state>();
32   address_space *space = cputag_get_address_space(image.device().machine, "maincpu", ADDRESS_SPACE_PROGRAM);
4033   unsigned char jupiter_repeat, jupiter_byte, loop;
41   int done=0, jupiter_index=0;
34   int done=0, jupiter_index=0x2000;
4235
43   if ((state->data = (UINT8*)malloc(0x6000)))
36   if (input_port_read(space->machine, "CFG")==0)
4437   {
45      logerror("Loading file %s.\r\n", image.filename());
46      while (!done && (jupiter_index < 0x6001))
38      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "At least 16KB RAM expansion required");
39      image.message("At least 16KB RAM expansion required");
40      return IMAGE_INIT_FAIL;
41   }
42
43   logerror("Loading file %s.\r\n", image.filename());
44   while (!done && (jupiter_index < 0x8001))
45   {
46      image.fread( &jupiter_byte, 1);
47      if (jupiter_byte == 0xed)
4748      {
48         image.fread( &jupiter_byte, 1);
49         if (jupiter_byte == 0xed)
49         image.fread(&jupiter_byte, 1);
50         switch (jupiter_byte)
5051         {
51            image.fread(&jupiter_byte, 1);
52            switch (jupiter_byte)
53            {
54            case 0x00:
52         case 0x00:
5553               logerror("File loaded!\r\n");
5654               done = 1;
5755               break;
58            case 0x01:
56         case 0x01:
5957               image.fread(&jupiter_byte, 1);
60               state->data[jupiter_index++] = jupiter_byte;
58               space->write_byte(jupiter_index++, jupiter_byte);
6159               break;
62            case 0x02:
60         case 0x02:
6361               logerror("Sequence 0xED 0x02 found in .ace file\r\n");
6462               break;
65            default:
63         default:
6664               image.fread(&jupiter_repeat, 1);
6765               for (loop = 0; loop < jupiter_byte; loop++)
68                  state->data[jupiter_index++] = jupiter_repeat;
66                  space->write_byte(jupiter_index++, jupiter_repeat);
6967               break;
70            }
7168         }
72         else
73            state->data[jupiter_index++] = jupiter_byte;
7469      }
70      else
71         space->write_byte(jupiter_index++, jupiter_byte);
7572   }
7673
74   logerror("Decoded %X bytes.\r\n", jupiter_index-0x2000);
75
7776   if (!done)
7877   {
79      logerror("file not loaded\r\n");
80      if (state->data) free (state->data);
81      state->data = NULL;
82      return 1;
78      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "EOF marker not found");
79      image.message("EOF marker not found");
80      return IMAGE_INIT_FAIL;
8381   }
8482
85   logerror("Decoded %d bytes.\r\n", jupiter_index);
86
87   // wait for machine to start up, then load file into ram
88   timer_set(image.device().machine, ATTOTIME_IN_SEC(1), NULL, 0, jupiter_begin);
89
90   return 0;
83   return IMAGE_INIT_PASS;
9184}
9285
src/mess/includes/jupiter.h
r9727r9728
3232   UINT8 *charram;
3333   UINT8 *expram;
3434   jupiter_tape_t tape;
35   UINT8 *data;
36   int data_type;
3735};
3836
3937
4038/*----------- defined in machine/jupiter.c -----------*/
4139
42DIRECT_UPDATE_HANDLER( jupiter_opbaseoverride );
43MACHINE_START( jupiter );
4440
45DEVICE_IMAGE_LOAD( jupiter_ace );
46DEVICE_IMAGE_LOAD( jupiter_tap );
47DEVICE_IMAGE_UNLOAD( jupiter_tap );
41SNAPSHOT_LOAD(jupiter);
4842
4943
5044/*----------- defined in video/jupiter.c -----------*/
src/mess/drivers/jupiter.c
r9727r9728
2828
2929#include "emu.h"
3030#include "cpu/z80/z80.h"
31#include "devices/cartslot.h"
3231#include "devices/cassette.h"
32#include "devices/snapquik.h"
3333#include "sound/speaker.h"
3434#include "sound/wave.h"
3535#include "formats/jupi_tap.h"
r9727r9728
5252   AM_RANGE(0x2400, 0x27ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(jupiter_state, videoram)
5353   AM_RANGE(0x2c00, 0x2fff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(jupiter_state, charram) AM_REGION("maincpu", 0x2c00)
5454   AM_RANGE(0x3c00, 0x3fff) AM_MIRROR(0x0c00) AM_RAM
55   AM_RANGE(0x4000, 0xffff) AM_RAM_WRITE( jupiter_expram_w ) AM_BASE_MEMBER(jupiter_state, expram)         /* Expansion RAM */
55   AM_RANGE(0x4000, 0xffff) AM_RAM_WRITE( jupiter_expram_w ) AM_BASE_MEMBER(jupiter_state, expram) /* Expansion RAM */
5656ADDRESS_MAP_END
5757
5858/* port i/o functions */
r9727r9728
189189static WRITE8_HANDLER( jupiter_expram_w )
190190{
191191   jupiter_state *state = space->machine->driver_data<jupiter_state>();
192   if (space->machine->phase() == MACHINE_PHASE_INIT)
193      state->expram[offset] = data;
194   else
192
195193   if ( offset > 0x4000 )
196194   {
197195      if ( input_port_read(space->machine, "CFG") >= 1 )
r9727r9728
326324   MDRV_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
327325   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
328326
327   /* Devices */
329328   MDRV_CASSETTE_ADD( "cassette", jupiter_cassette_config )
330
331   MDRV_CARTSLOT_ADD("cart")
332   MDRV_CARTSLOT_EXTENSION_LIST("ace")
333   MDRV_CARTSLOT_NOT_MANDATORY
334   MDRV_CARTSLOT_LOAD(jupiter_ace)
329   MDRV_SNAPSHOT_ADD("snapshot", jupiter, "ace", 1)
335330MACHINE_CONFIG_END
336331
337332

Previous 15994 Revisions Next


© 1998-2018 The MESS Team