src/mess/machine/jupiter.c
| r9727 | r9728 | |
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | |
| 10 | 10 | #include "emu.h" |
| 11 | #include "devices/snapquik.h" |
| 11 | 12 | #include "includes/jupiter.h" |
| 12 | 13 | |
| 13 | 14 | |
| 14 | | static 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); |
| 19 | 15 | |
| 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 | | |
| 28 | 16 | /* Load in .ace files. These are memory images of 0x2000 to 0x7fff |
| 29 | 17 | and compressed as follows: |
| 30 | 18 | |
| r9727 | r9728 | |
| 34 | 22 | <byt> : <byt> |
| 35 | 23 | */ |
| 36 | 24 | |
| 37 | | DEVICE_IMAGE_LOAD( jupiter_ace ) |
| 25 | |
| 26 | /****************************************************************************** |
| 27 | Snapshot Handling |
| 28 | ******************************************************************************/ |
| 29 | |
| 30 | SNAPSHOT_LOAD(jupiter) |
| 38 | 31 | { |
| 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); |
| 40 | 33 | unsigned char jupiter_repeat, jupiter_byte, loop; |
| 41 | | int done=0, jupiter_index=0; |
| 34 | int done=0, jupiter_index=0x2000; |
| 42 | 35 | |
| 43 | | if ((state->data = (UINT8*)malloc(0x6000))) |
| 36 | if (input_port_read(space->machine, "CFG")==0) |
| 44 | 37 | { |
| 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) |
| 47 | 48 | { |
| 48 | | image.fread( &jupiter_byte, 1); |
| 49 | | if (jupiter_byte == 0xed) |
| 49 | image.fread(&jupiter_byte, 1); |
| 50 | switch (jupiter_byte) |
| 50 | 51 | { |
| 51 | | image.fread(&jupiter_byte, 1); |
| 52 | | switch (jupiter_byte) |
| 53 | | { |
| 54 | | case 0x00: |
| 52 | case 0x00: |
| 55 | 53 | logerror("File loaded!\r\n"); |
| 56 | 54 | done = 1; |
| 57 | 55 | break; |
| 58 | | case 0x01: |
| 56 | case 0x01: |
| 59 | 57 | image.fread(&jupiter_byte, 1); |
| 60 | | state->data[jupiter_index++] = jupiter_byte; |
| 58 | space->write_byte(jupiter_index++, jupiter_byte); |
| 61 | 59 | break; |
| 62 | | case 0x02: |
| 60 | case 0x02: |
| 63 | 61 | logerror("Sequence 0xED 0x02 found in .ace file\r\n"); |
| 64 | 62 | break; |
| 65 | | default: |
| 63 | default: |
| 66 | 64 | image.fread(&jupiter_repeat, 1); |
| 67 | 65 | for (loop = 0; loop < jupiter_byte; loop++) |
| 68 | | state->data[jupiter_index++] = jupiter_repeat; |
| 66 | space->write_byte(jupiter_index++, jupiter_repeat); |
| 69 | 67 | break; |
| 70 | | } |
| 71 | 68 | } |
| 72 | | else |
| 73 | | state->data[jupiter_index++] = jupiter_byte; |
| 74 | 69 | } |
| 70 | else |
| 71 | space->write_byte(jupiter_index++, jupiter_byte); |
| 75 | 72 | } |
| 76 | 73 | |
| 74 | logerror("Decoded %X bytes.\r\n", jupiter_index-0x2000); |
| 75 | |
| 77 | 76 | if (!done) |
| 78 | 77 | { |
| 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; |
| 83 | 81 | } |
| 84 | 82 | |
| 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; |
| 91 | 84 | } |
| 92 | 85 | |
src/mess/drivers/jupiter.c
| r9727 | r9728 | |
| 28 | 28 | |
| 29 | 29 | #include "emu.h" |
| 30 | 30 | #include "cpu/z80/z80.h" |
| 31 | | #include "devices/cartslot.h" |
| 32 | 31 | #include "devices/cassette.h" |
| 32 | #include "devices/snapquik.h" |
| 33 | 33 | #include "sound/speaker.h" |
| 34 | 34 | #include "sound/wave.h" |
| 35 | 35 | #include "formats/jupi_tap.h" |
| r9727 | r9728 | |
| 52 | 52 | AM_RANGE(0x2400, 0x27ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(jupiter_state, videoram) |
| 53 | 53 | AM_RANGE(0x2c00, 0x2fff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(jupiter_state, charram) AM_REGION("maincpu", 0x2c00) |
| 54 | 54 | 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 */ |
| 56 | 56 | ADDRESS_MAP_END |
| 57 | 57 | |
| 58 | 58 | /* port i/o functions */ |
| r9727 | r9728 | |
| 189 | 189 | static WRITE8_HANDLER( jupiter_expram_w ) |
| 190 | 190 | { |
| 191 | 191 | 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 | |
| 195 | 193 | if ( offset > 0x4000 ) |
| 196 | 194 | { |
| 197 | 195 | if ( input_port_read(space->machine, "CFG") >= 1 ) |
| r9727 | r9728 | |
| 326 | 324 | MDRV_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 327 | 325 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 328 | 326 | |
| 327 | /* Devices */ |
| 329 | 328 | 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) |
| 335 | 330 | MACHINE_CONFIG_END |
| 336 | 331 | |
| 337 | 332 | |