Previous 15994 Revisions Next

r9726 Sunday 5th December, 2010 at 01:57:22 UTC by Robbbert
[JUPITER] Fixed load of images; ace and tap files work. Removed a heap of unused code. Added cassette wav sound.
[src/mess/drivers]jupiter.c
[src/mess/machine]jupiter.c

src/mess/machine/jupiter.c
r9725r9726
88***************************************************************************/
99
1010#include "emu.h"
11#include "cpu/z80/z80.h"
1211#include "includes/jupiter.h"
13#include "image.h"
1412
15#define   JUPITER_NONE   0
16#define   JUPITER_ACE   1
17#define   JUPITER_TAP   2
1813
19static void jupiter_machine_stop(running_machine &machine);
20
21
22/* only gets called at the start of a cpu time slice */
23
24DIRECT_UPDATE_HANDLER( jupiter_opbaseoverride )
14static TIMER_CALLBACK( jupiter_begin )
2515{
2616   jupiter_state *state = machine->driver_data<jupiter_state>();
27   UINT16 loop,tmpword;
17   UINT16 loop;
2818   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
2919
30   if (address == 0x059d)
31   {
32      if (state->data_type == JUPITER_ACE)
33      {
34         for (loop = 0; loop < 0x6000; loop++)
35            space->write_byte(loop + 0x2000, state->data[loop]);
36      }
37      else if (state->data_type == JUPITER_TAP)
38      {
20   for (loop = 0; loop < 0x6000; loop++)
21      space->write_byte(loop + 0x2000, state->data[loop]);
3922
40         for (loop = 0; loop < state->tape.dat_len; loop++)
41            space->write_byte(loop + state->tape.hdr_addr, state->data[loop]);
42
43         space->write_byte(0x3c27, 0x01);
44
45         for (loop = 0; loop < 8; loop++)
46            space->write_byte(loop + 0x3c31, state->tape.hdr_vars[loop]);
47         space->write_byte(0x3c39, 0x00);
48         space->write_byte(0x3c3a, 0x00);
49
50         tmpword = space->read_byte(0x3c3b) + space->read_byte(0x3c3c) * 256 + state->tape.hdr_len;
51
52         space->write_byte(0x3c3b, tmpword & 0xff);
53         space->write_byte(0x3c3c, (tmpword >> 8) & 0xff);
54
55         space->write_byte(0x3c45, 0x0c);   /* ? */
56
57         space->write_byte(0x3c4c, state->tape.hdr_3c4c);
58         space->write_byte(0x3c4d, state->tape.hdr_3c4d);
59
60         if (!space->read_byte(0x3c57) && !space->read_byte(0x3c58))
61         {
62            space->write_byte(0x3c57, 0x49);
63            space->write_byte(0x3c58, 0x3c);
64         }
65      }
66   }
67   return ~1;
23   free(state->data);
24   state->data = NULL;
6825}
6926
70MACHINE_START( jupiter )
71{
72   jupiter_state *state = machine->driver_data<jupiter_state>();
73   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
7427
75   state->data_type = JUPITER_NONE;
76   logerror("jupiter_init\r\n");
77   logerror("data: %p\n", state->data);
78
79   if (state->data)
80   {
81      logerror("data: %p. type: %d.\n", state->data,   state->data_type);
82      space->set_direct_update_handler(direct_update_delegate_create_static(jupiter_opbaseoverride, *machine));
83
84   }
85
86   machine->add_notifier(MACHINE_NOTIFY_EXIT, jupiter_machine_stop);
87}
88
89static void jupiter_machine_stop(running_machine &machine)
90{
91   jupiter_state *state = machine.driver_data<jupiter_state>();
92   if (state->data)
93   {
94      free(state->data);
95      state->data = NULL;
96      state->data_type = JUPITER_NONE;
97   }
98}
99
10028/* Load in .ace files. These are memory images of 0x2000 to 0x7fff
10129   and compressed as follows:
10230
r9725r9726
11038{
11139   jupiter_state *state = image.device().machine->driver_data<jupiter_state>();
11240   unsigned char jupiter_repeat, jupiter_byte, loop;
113   int done, jupiter_index;
41   int done=0, jupiter_index=0;
11442
115   if (state->data_type != JUPITER_NONE)
116      return (0);
117
118   done = 0;
119   jupiter_index = 0;
120
12143   if ((state->data = (UINT8*)malloc(0x6000)))
12244   {
12345      logerror("Loading file %s.\r\n", image.filename());
r9725r9726
15173            state->data[jupiter_index++] = jupiter_byte;
15274      }
15375   }
76
15477   if (!done)
15578   {
15679      logerror("file not loaded\r\n");
157      return (1);
80      if (state->data) free (state->data);
81      state->data = NULL;
82      return 1;
15883   }
15984
16085   logerror("Decoded %d bytes.\r\n", jupiter_index);
161   state->data_type = JUPITER_ACE;
16286
163   logerror("data: %p\n", state->data);
164   return (0);
165}
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);
16689
167DEVICE_IMAGE_LOAD( jupiter_tap )
168{
169   jupiter_state *state = image.device().machine->driver_data<jupiter_state>();
170   UINT8 inpbyt;
171   int loop;
172   UINT16 hdr_len;
173
174   if (state->data_type != JUPITER_NONE)
175      return (0);
176
177   logerror("Loading file %s.\r\n", image.filename());
178
179    image.fread(&inpbyt, 1);
180   hdr_len = inpbyt;
181   image.fread(&inpbyt, 1);
182   hdr_len += (inpbyt * 256);
183
184   /* Read header block */
185
186   image.fread(&state->tape.hdr_type, 1);
187   image.fread(state->tape.hdr_name, 10);
188   image.fread(&inpbyt, 1);
189   state->tape.hdr_len = inpbyt;
190   image.fread(&inpbyt, 1);
191   state->tape.hdr_len += (inpbyt * 256);
192   image.fread(&inpbyt, 1);
193   state->tape.hdr_addr = inpbyt;
194   image.fread(&inpbyt, 1);
195   state->tape.hdr_addr += (inpbyt * 256);
196   image.fread(&state->tape.hdr_3c4c, 1);
197   image.fread(&state->tape.hdr_3c4d, 1);
198   image.fread(state->tape.hdr_vars, 8);
199   if (hdr_len > 0x19)
200      for (loop = 0x19; loop < hdr_len; loop++)
201         image.fread(&inpbyt, 1);
202
203   /* Read data block */
204
205   image.fread(&inpbyt, 1);
206   state->tape.dat_len = inpbyt;
207   image.fread(&inpbyt, 1);
208   state->tape.dat_len += (inpbyt * 256);
209
210   if ((state->data = (UINT8*)malloc(state->tape.dat_len)))
211   {
212      image.fread(state->data, state->tape.dat_len);
213      state->data_type = JUPITER_TAP;
214      logerror("File loaded\r\n");
215   }
216
217   if (!state->data)
218   {
219      logerror("file not loaded\r\n");
220      return (1);
221   }
222
223   return (0);
224
90   return 0;
22591}
22692
227DEVICE_IMAGE_UNLOAD( jupiter_tap )
228{
229   jupiter_state *state = image.device().machine->driver_data<jupiter_state>();
230   logerror("jupiter_tap_unload\n");
231   if (state->data)
232   {
233      free(state->data);
234      state->data = NULL;
235      state->data_type = JUPITER_NONE;
236   }
237}
src/mess/drivers/jupiter.c
r9725r9726
2828
2929#include "emu.h"
3030#include "cpu/z80/z80.h"
31#include "includes/jupiter.h"
3231#include "devices/cartslot.h"
3332#include "devices/cassette.h"
3433#include "sound/speaker.h"
34#include "sound/wave.h"
3535#include "formats/jupi_tap.h"
36#include "includes/jupiter.h"
3637
3738
3839/* This needs to be moved to drivers/xtal */
r9725r9726
5152   AM_RANGE(0x2400, 0x27ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(jupiter_state, videoram)
5253   AM_RANGE(0x2c00, 0x2fff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(jupiter_state, charram) AM_REGION("maincpu", 0x2c00)
5354   AM_RANGE(0x3c00, 0x3fff) AM_MIRROR(0x0c00) AM_RAM
54   AM_RANGE(0x4800, 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 */
5556ADDRESS_MAP_END
5657
5758/* port i/o functions */
r9725r9726
188189static WRITE8_HANDLER( jupiter_expram_w )
189190{
190191   jupiter_state *state = space->machine->driver_data<jupiter_state>();
192   if (space->machine->phase() == MACHINE_PHASE_INIT)
193      state->expram[offset] = data;
194   else
191195   if ( offset > 0x4000 )
192196   {
193197      if ( input_port_read(space->machine, "CFG") >= 1 )
r9725r9726
303307   MDRV_CPU_IO_MAP(jupiter_io)
304308   MDRV_QUANTUM_TIME(HZ(60))
305309
306   MDRV_MACHINE_START( jupiter )
307
308310   /* video hardware */
309311   MDRV_SCREEN_ADD("screen", RASTER)
310312   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
r9725r9726
319321
320322   /* sound hardware */
321323   MDRV_SPEAKER_STANDARD_MONO("mono")
324   MDRV_SOUND_WAVE_ADD("wave", "cassette")
325   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
322326   MDRV_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
323327   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
324328

Previous 15994 Revisions Next


© 1998-2018 The MESS Team