src/mess/machine/jupiter.c
| r9725 | r9726 | |
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | |
| 10 | 10 | #include "emu.h" |
| 11 | | #include "cpu/z80/z80.h" |
| 12 | 11 | #include "includes/jupiter.h" |
| 13 | | #include "image.h" |
| 14 | 12 | |
| 15 | | #define JUPITER_NONE 0 |
| 16 | | #define JUPITER_ACE 1 |
| 17 | | #define JUPITER_TAP 2 |
| 18 | 13 | |
| 19 | | static void jupiter_machine_stop(running_machine &machine); |
| 20 | | |
| 21 | | |
| 22 | | /* only gets called at the start of a cpu time slice */ |
| 23 | | |
| 24 | | DIRECT_UPDATE_HANDLER( jupiter_opbaseoverride ) |
| 14 | static TIMER_CALLBACK( jupiter_begin ) |
| 25 | 15 | { |
| 26 | 16 | jupiter_state *state = machine->driver_data<jupiter_state>(); |
| 27 | | UINT16 loop,tmpword; |
| 17 | UINT16 loop; |
| 28 | 18 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 29 | 19 | |
| 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]); |
| 39 | 22 | |
| 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; |
| 68 | 25 | } |
| 69 | 26 | |
| 70 | | MACHINE_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); |
| 74 | 27 | |
| 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 | | |
| 89 | | static 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 | | |
| 100 | 28 | /* Load in .ace files. These are memory images of 0x2000 to 0x7fff |
| 101 | 29 | and compressed as follows: |
| 102 | 30 | |
| r9725 | r9726 | |
| 110 | 38 | { |
| 111 | 39 | jupiter_state *state = image.device().machine->driver_data<jupiter_state>(); |
| 112 | 40 | unsigned char jupiter_repeat, jupiter_byte, loop; |
| 113 | | int done, jupiter_index; |
| 41 | int done=0, jupiter_index=0; |
| 114 | 42 | |
| 115 | | if (state->data_type != JUPITER_NONE) |
| 116 | | return (0); |
| 117 | | |
| 118 | | done = 0; |
| 119 | | jupiter_index = 0; |
| 120 | | |
| 121 | 43 | if ((state->data = (UINT8*)malloc(0x6000))) |
| 122 | 44 | { |
| 123 | 45 | logerror("Loading file %s.\r\n", image.filename()); |
| r9725 | r9726 | |
| 151 | 73 | state->data[jupiter_index++] = jupiter_byte; |
| 152 | 74 | } |
| 153 | 75 | } |
| 76 | |
| 154 | 77 | if (!done) |
| 155 | 78 | { |
| 156 | 79 | logerror("file not loaded\r\n"); |
| 157 | | return (1); |
| 80 | if (state->data) free (state->data); |
| 81 | state->data = NULL; |
| 82 | return 1; |
| 158 | 83 | } |
| 159 | 84 | |
| 160 | 85 | logerror("Decoded %d bytes.\r\n", jupiter_index); |
| 161 | | state->data_type = JUPITER_ACE; |
| 162 | 86 | |
| 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); |
| 166 | 89 | |
| 167 | | DEVICE_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; |
| 225 | 91 | } |
| 226 | 92 | |
| 227 | | DEVICE_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
| r9725 | r9726 | |
| 28 | 28 | |
| 29 | 29 | #include "emu.h" |
| 30 | 30 | #include "cpu/z80/z80.h" |
| 31 | | #include "includes/jupiter.h" |
| 32 | 31 | #include "devices/cartslot.h" |
| 33 | 32 | #include "devices/cassette.h" |
| 34 | 33 | #include "sound/speaker.h" |
| 34 | #include "sound/wave.h" |
| 35 | 35 | #include "formats/jupi_tap.h" |
| 36 | #include "includes/jupiter.h" |
| 36 | 37 | |
| 37 | 38 | |
| 38 | 39 | /* This needs to be moved to drivers/xtal */ |
| r9725 | r9726 | |
| 51 | 52 | AM_RANGE(0x2400, 0x27ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(jupiter_state, videoram) |
| 52 | 53 | AM_RANGE(0x2c00, 0x2fff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(jupiter_state, charram) AM_REGION("maincpu", 0x2c00) |
| 53 | 54 | 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 */ |
| 55 | 56 | ADDRESS_MAP_END |
| 56 | 57 | |
| 57 | 58 | /* port i/o functions */ |
| r9725 | r9726 | |
| 188 | 189 | static WRITE8_HANDLER( jupiter_expram_w ) |
| 189 | 190 | { |
| 190 | 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 |
| 191 | 195 | if ( offset > 0x4000 ) |
| 192 | 196 | { |
| 193 | 197 | if ( input_port_read(space->machine, "CFG") >= 1 ) |
| r9725 | r9726 | |
| 303 | 307 | MDRV_CPU_IO_MAP(jupiter_io) |
| 304 | 308 | MDRV_QUANTUM_TIME(HZ(60)) |
| 305 | 309 | |
| 306 | | MDRV_MACHINE_START( jupiter ) |
| 307 | | |
| 308 | 310 | /* video hardware */ |
| 309 | 311 | MDRV_SCREEN_ADD("screen", RASTER) |
| 310 | 312 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| r9725 | r9726 | |
| 319 | 321 | |
| 320 | 322 | /* sound hardware */ |
| 321 | 323 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 324 | MDRV_SOUND_WAVE_ADD("wave", "cassette") |
| 325 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 322 | 326 | MDRV_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 323 | 327 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 324 | 328 | |