src/mess/machine/vtech1.c
| r6100 | r6101 | |
| 1 | | /****************************************************************************** |
| 2 | | |
| 3 | | Video Technology Laser 110-310 computers: |
| 4 | | |
| 5 | | Video Technology Laser 110 |
| 6 | | Sanyo Laser 110 |
| 7 | | Video Technology Laser 200 |
| 8 | | Salora Fellow |
| 9 | | Texet TX-8000 |
| 10 | | Video Technology VZ-200 |
| 11 | | Video Technology Laser 210 |
| 12 | | Dick Smith Electronics VZ-200 |
| 13 | | Sanyo Laser 210 |
| 14 | | Video Technology Laser 310 |
| 15 | | Dick Smith Electronics VZ-300 |
| 16 | | |
| 17 | | Machine driver: |
| 18 | | |
| 19 | | Juergen Buchmueller <pullmoll@t-online.de>, Dec 1999 |
| 20 | | - everything |
| 21 | | |
| 22 | | Dirk Best <duke@redump.de>, May 2004 |
| 23 | | - clean up |
| 24 | | - fixed mode 1 display (graphic mode) |
| 25 | | - fixed loading of the DOS ROM |
| 26 | | - preliminary printer emulation |
| 27 | | |
| 28 | | Dirk Best <duke@redump.de>, March 2006 |
| 29 | | - 64K bank switched memory implemented |
| 30 | | - better printer emulation |
| 31 | | - cartridge support |
| 32 | | |
| 33 | | Thanks go to: |
| 34 | | |
| 35 | | - Guy Thomason |
| 36 | | - Jason Oakley |
| 37 | | - Bushy Maunder |
| 38 | | - and anybody else on the vzemu list :) |
| 39 | | - Davide Moretti for the detailed description of the colors. |
| 40 | | |
| 41 | | Todo: |
| 42 | | |
| 43 | | - Lightpen |
| 44 | | - RS232 serial |
| 45 | | |
| 46 | | ****************************************************************************/ |
| 47 | | |
| 48 | | |
| 49 | | #include "driver.h" |
| 50 | | #include "utils.h" |
| 51 | | #include "includes/vtech1.h" |
| 52 | | #include "cpu/z80/z80.h" |
| 53 | | #include "video/m6847.h" |
| 54 | | #include "sound/speaker.h" |
| 55 | | #include "machine/ctronics.h" |
| 56 | | #include "devices/cassette.h" |
| 57 | | #include "devices/messram.h" |
| 58 | | |
| 59 | | #define LOG_VTECH1_LATCH 0 |
| 60 | | #define LOG_VTECH1_FDC 0 |
| 61 | | |
| 62 | | int vtech1_latch = -1; |
| 63 | | |
| 64 | | #define TRKSIZE_VZ 0x9b0 /* arbitrary (actually from analyzing format) */ |
| 65 | | #define TRKSIZE_FM 3172 /* size of a standard FM mode track */ |
| 66 | | |
| 67 | | static UINT8 vtech1_track_x2[2] = {80, 80}; |
| 68 | | static UINT8 vtech1_fdc_wrprot[2] = {0x80, 0x80}; |
| 69 | | static UINT8 vtech1_fdc_status = 0; |
| 70 | | static UINT8 vtech1_fdc_data[TRKSIZE_FM]; |
| 71 | | |
| 72 | | static int vtech1_data; |
| 73 | | |
| 74 | | static int vtech1_fdc_edge = 0; |
| 75 | | static int vtech1_fdc_bits = 8; |
| 76 | | static int vtech1_drive = -1; |
| 77 | | static int vtech1_fdc_start = 0; |
| 78 | | static int vtech1_fdc_write = 0; |
| 79 | | static int vtech1_fdc_offs = 0; |
| 80 | | static int vtech1_fdc_latch = 0; |
| 81 | | |
| 82 | | /****************************************************************************** |
| 83 | | Machine Initialisation |
| 84 | | ******************************************************************************/ |
| 85 | | |
| 86 | | static void common_init_machine(running_machine *machine, int base) |
| 87 | | { |
| 88 | | /* internal ram */ |
| 89 | | memory_configure_bank(machine, 1, 0, 1, messram_get_ptr(devtag_get_device(machine, "messram")), 0); |
| 90 | | memory_set_bank(machine, 1, 0); |
| 91 | | |
| 92 | | /* expansion memory configuration */ |
| 93 | | switch (messram_get_size(devtag_get_device(machine, "messram"))) { |
| 94 | | case 18 * 1024: |
| 95 | | case 22 * 1024: |
| 96 | | case 32 * 1024: |
| 97 | | /* install 16KB memory expansion */ |
| 98 | | memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), base, base + 0x3fff, 0, 0, SMH_BANK(2)); |
| 99 | | memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), base, base + 0x3fff, 0, 0, SMH_BANK(2)); |
| 100 | | memory_configure_bank(machine, 2, 0, 1, messram_get_ptr(devtag_get_device(machine, "messram")) + base - 0x7800, 0); |
| 101 | | memory_set_bank(machine, 2, 0); |
| 102 | | |
| 103 | | memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), base + 0x4000, 0xffff, 0, 0, SMH_NOP); |
| 104 | | memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), base + 0x4000, 0xffff, 0, 0, SMH_NOP); |
| 105 | | break; |
| 106 | | |
| 107 | | case 66 * 1024: |
| 108 | | case 4098 * 1024: |
| 109 | | /* 64KB/4MB memory expansion */ |
| 110 | | |
| 111 | | /* install fixed first bank */ |
| 112 | | memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_BANK(2)); |
| 113 | | memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_BANK(2)); |
| 114 | | memory_configure_bank(machine, 2, 0, 1, messram_get_ptr(devtag_get_device(machine, "messram")) + 0x800, 0); |
| 115 | | memory_set_bank(machine, 2, 0); |
| 116 | | |
| 117 | | /* install the others, dynamically banked in */ |
| 118 | | memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc000, 0xffff, 0, 0, SMH_BANK(3)); |
| 119 | | memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc000, 0xffff, 0, 0, SMH_BANK(3)); |
| 120 | | memory_configure_bank(machine, 3, 0, (messram_get_size(devtag_get_device(machine, "messram")) - 0x4800) / 0x4000, messram_get_ptr(devtag_get_device(machine, "messram")) + 0x4800, 0x4000); |
| 121 | | memory_set_bank(machine, 3, 0); |
| 122 | | break; |
| 123 | | |
| 124 | | default: |
| 125 | | /* no memory expansion */ |
| 126 | | memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), base, 0xffff, 0, 0, SMH_NOP); |
| 127 | | memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), base, 0xffff, 0, 0, SMH_NOP); |
| 128 | | break; |
| 129 | | } |
| 130 | | } |
| 131 | | |
| 132 | | MACHINE_START(laser110) |
| 133 | | { |
| 134 | | common_init_machine(machine, 0x8000); |
| 135 | | } |
| 136 | | |
| 137 | | MACHINE_START(laser210) |
| 138 | | { |
| 139 | | common_init_machine(machine, 0x9000); |
| 140 | | } |
| 141 | | |
| 142 | | MACHINE_START(laser310) |
| 143 | | { |
| 144 | | common_init_machine(machine, 0xb800); |
| 145 | | } |
| 146 | | |
| 147 | | |
| 148 | | /****************************************************************************** |
| 149 | | Memory Bank Handling |
| 150 | | |
| 151 | | TODO: What happens when an invalid bank is selected? |
| 152 | | Currently, we just ignore it and keep the current bank. |
| 153 | | ******************************************************************************/ |
| 154 | | |
| 155 | | WRITE8_HANDLER (vtech1_memory_bank_w) |
| 156 | | { |
| 157 | | logerror("vtech1_memory_bank_w $%02X\n", data); |
| 158 | | |
| 159 | | if (data >= 1) |
| 160 | | if ((data <= 3 && (messram_get_size(devtag_get_device(space->machine, "messram")) == (66 * 1024))) || (messram_get_size(devtag_get_device(space->machine, "messram")) == (4098 * 1024))) |
| 161 | | memory_set_bank(space->machine, 3, data - 1); |
| 162 | | } |
| 163 | | |
| 164 | | |
| 165 | | /****************************************************************************** |
| 166 | | Cassette Handling |
| 167 | | ******************************************************************************/ |
| 168 | | |
| 169 | | static const device_config *cassette_device_image(running_machine *machine) |
| 170 | | { |
| 171 | | return devtag_get_device(machine, "cassette"); |
| 172 | | } |
| 173 | | |
| 174 | | |
| 175 | | /****************************************************************************** |
| 176 | | Snapshot Handling |
| 177 | | ******************************************************************************/ |
| 178 | | |
| 179 | | SNAPSHOT_LOAD(vtech1) |
| 180 | | { |
| 181 | | const address_space *space = cputag_get_address_space(image->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 182 | | UINT8 i, header[24]; |
| 183 | | UINT16 start, end, size; |
| 184 | | char pgmname[18]; |
| 185 | | |
| 186 | | /* get the header */ |
| 187 | | image_fread(image, &header, sizeof(header)); |
| 188 | | for (i = 0; i < 16; i++) pgmname[i] = header[i+4]; |
| 189 | | pgmname[16] = '\0'; |
| 190 | | |
| 191 | | /* get start and end addresses */ |
| 192 | | start = pick_integer_le(header, 22, 2); |
| 193 | | end = start + snapshot_size - sizeof(header); |
| 194 | | size = end - start; |
| 195 | | |
| 196 | | /* check if we have enough ram */ |
| 197 | | if (messram_get_size(devtag_get_device(image->machine, "messram")) < size) |
| 198 | | { |
| 199 | | char message[256]; |
| 200 | | snprintf(message, ARRAY_LENGTH(message), "SNAPLOAD: %s\nInsufficient RAM - need %04X",pgmname,size); |
| 201 | | image_seterror(image, IMAGE_ERROR_INVALIDIMAGE, message); |
| 202 | | image_message(image, "SNAPLOAD: %s\nInsufficient RAM - need %04X",pgmname,size); |
| 203 | | return INIT_FAIL; |
| 204 | | } |
| 205 | | |
| 206 | | /* write it to ram */ |
| 207 | | image_fread(image, &messram_get_ptr(devtag_get_device(image->machine, "messram"))[start - 0x7800], size); |
| 208 | | |
| 209 | | /* patch variables depending on snapshot type */ |
| 210 | | switch (header[21]) |
| 211 | | { |
| 212 | | case VZ_BASIC: /* 0xF0 */ |
| 213 | | memory_write_byte(space, 0x78a4, start % 256); /* start of basic program */ |
| 214 | | memory_write_byte(space, 0x78a5, start / 256); |
| 215 | | memory_write_byte(space, 0x78f9, end % 256); /* end of basic program */ |
| 216 | | memory_write_byte(space, 0x78fa, end / 256); |
| 217 | | memory_write_byte(space, 0x78fb, end % 256); /* start variable table */ |
| 218 | | memory_write_byte(space, 0x78fc, end / 256); |
| 219 | | memory_write_byte(space, 0x78fd, end % 256); /* start free mem, end variable table */ |
| 220 | | memory_write_byte(space, 0x78fe, end / 256); |
| 221 | | image_message(image, " %s (B)\nsize=%04X : start=%04X : end=%04X",pgmname,size,start,end); |
| 222 | | break; |
| 223 | | |
| 224 | | case VZ_MCODE: /* 0xF1 */ |
| 225 | | memory_write_byte(space, 0x788e, start % 256); /* usr subroutine address */ |
| 226 | | memory_write_byte(space, 0x788f, start / 256); |
| 227 | | image_message(image, " %s (M)\nsize=%04X : start=%04X : end=%04X",pgmname,size,start,end); |
| 228 | | cpu_set_reg(cputag_get_cpu(image->machine, "maincpu"), REG_GENPC, start); /* start program */ |
| 229 | | break; |
| 230 | | |
| 231 | | default: |
| 232 | | image_seterror(image, IMAGE_ERROR_UNSUPPORTED, "Snapshot format not supported."); |
| 233 | | image_message(image, "Snapshot format not supported."); |
| 234 | | return INIT_FAIL; |
| 235 | | } |
| 236 | | |
| 237 | | return INIT_PASS; |
| 238 | | } |
| 239 | | |
| 240 | | |
| 241 | | /****************************************************************************** |
| 242 | | Floppy Handling |
| 243 | | ******************************************************************************/ |
| 244 | | |
| 245 | | static const device_config *vtech1_file(running_machine *machine) |
| 246 | | { |
| 247 | | if (vtech1_drive < 0) |
| 248 | | return NULL; |
| 249 | | |
| 250 | | return image_from_devtype_and_index(machine, IO_FLOPPY, vtech1_drive); |
| 251 | | } |
| 252 | | |
| 253 | | /* |
| 254 | | int vtech1_floppy_id(int id) |
| 255 | | { |
| 256 | | mame_file *file; |
| 257 | | UINT8 buff[32]; |
| 258 | | |
| 259 | | file = image_fopen(IO_FLOPPY, id, FILETYPE_IMAGE, OSD_FOPEN_READ); |
| 260 | | if (file) |
| 261 | | { |
| 262 | | mame_fread(file, buff, sizeof(buff)); |
| 263 | | mame_fclose(file); |
| 264 | | if( memcmp(buff, "\x80\x80\x80\x80\x80\x80\x00\xfe\0xe7\0x18\0xc3\x00\x00\x00\x80\x80", 16) == 0 ) |
| 265 | | return 1; |
| 266 | | } |
| 267 | | return 0; |
| 268 | | } |
| 269 | | */ |
| 270 | | |
| 271 | | DEVICE_IMAGE_LOAD(vtech1_floppy) |
| 272 | | { |
| 273 | | int id = image_index_in_device(image); |
| 274 | | |
| 275 | | if (image_is_writable(image)) |
| 276 | | vtech1_fdc_wrprot[id] = 0x00; |
| 277 | | else |
| 278 | | vtech1_fdc_wrprot[id] = 0x80; |
| 279 | | |
| 280 | | return INIT_PASS; |
| 281 | | } |
| 282 | | |
| 283 | | static void vtech1_get_track(running_machine *machine) |
| 284 | | { |
| 285 | | /* drive selected or and image file ok? */ |
| 286 | | if (vtech1_drive >= 0 && image_exists(vtech1_file(machine))) |
| 287 | | { |
| 288 | | int size, offs; |
| 289 | | size = TRKSIZE_VZ; |
| 290 | | offs = TRKSIZE_VZ * vtech1_track_x2[vtech1_drive]/2; |
| 291 | | image_fseek(vtech1_file(machine), offs, SEEK_SET); |
| 292 | | size = image_fread(vtech1_file(machine), vtech1_fdc_data, size); |
| 293 | | if (LOG_VTECH1_FDC) |
| 294 | | logerror("get track @$%05x $%04x bytes\n", offs, size); |
| 295 | | } |
| 296 | | vtech1_fdc_offs = 0; |
| 297 | | vtech1_fdc_write = 0; |
| 298 | | } |
| 299 | | |
| 300 | | static void vtech1_put_track(running_machine *machine) |
| 301 | | { |
| 302 | | /* drive selected and image file ok? */ |
| 303 | | if (vtech1_drive >= 0 && vtech1_file(machine) != NULL) |
| 304 | | { |
| 305 | | int size, offs; |
| 306 | | offs = TRKSIZE_VZ * vtech1_track_x2[vtech1_drive]/2; |
| 307 | | image_fseek(vtech1_file(machine), offs + vtech1_fdc_start, SEEK_SET); |
| 308 | | size = image_fwrite(vtech1_file(machine), &vtech1_fdc_data[vtech1_fdc_start], vtech1_fdc_write); |
| 309 | | if (LOG_VTECH1_FDC) |
| 310 | | logerror("put track @$%05X+$%X $%04X/$%04X bytes\n", offs, vtech1_fdc_start, size, vtech1_fdc_write); |
| 311 | | } |
| 312 | | } |
| 313 | | |
| 314 | | #define PHI0(n) (((n)>>0)&1) |
| 315 | | #define PHI1(n) (((n)>>1)&1) |
| 316 | | #define PHI2(n) (((n)>>2)&1) |
| 317 | | #define PHI3(n) (((n)>>3)&1) |
| 318 | | |
| 319 | | READ8_HANDLER(vtech1_fdc_r) |
| 320 | | { |
| 321 | | int data = 0xff; |
| 322 | | switch (offset) |
| 323 | | { |
| 324 | | case 1: /* data (read-only) */ |
| 325 | | if (vtech1_fdc_bits > 0) |
| 326 | | { |
| 327 | | if( vtech1_fdc_status & 0x80 ) |
| 328 | | vtech1_fdc_bits--; |
| 329 | | data = (vtech1_data >> vtech1_fdc_bits) & 0xff; |
| 330 | | if (LOG_VTECH1_FDC) { |
| 331 | | logerror("vtech1_fdc_r bits %d%d%d%d%d%d%d%d\n", |
| 332 | | (data>>7)&1,(data>>6)&1,(data>>5)&1,(data>>4)&1, |
| 333 | | (data>>3)&1,(data>>2)&1,(data>>1)&1,(data>>0)&1 ); |
| 334 | | } |
| 335 | | } |
| 336 | | if (vtech1_fdc_bits == 0) |
| 337 | | { |
| 338 | | vtech1_data = vtech1_fdc_data[vtech1_fdc_offs]; |
| 339 | | if (LOG_VTECH1_FDC) |
| 340 | | logerror("vtech1_fdc_r %d : data ($%04X) $%02X\n", offset, vtech1_fdc_offs, vtech1_data); |
| 341 | | if(vtech1_fdc_status & 0x80) |
| 342 | | { |
| 343 | | vtech1_fdc_bits = 8; |
| 344 | | vtech1_fdc_offs = (vtech1_fdc_offs + 1) % TRKSIZE_FM; |
| 345 | | } |
| 346 | | vtech1_fdc_status &= ~0x80; |
| 347 | | } |
| 348 | | break; |
| 349 | | case 2: /* polling (read-only) */ |
| 350 | | /* fake */ |
| 351 | | if (vtech1_drive >= 0) |
| 352 | | vtech1_fdc_status |= 0x80; |
| 353 | | data = vtech1_fdc_status; |
| 354 | | break; |
| 355 | | case 3: /* write protect status (read-only) */ |
| 356 | | if (vtech1_drive >= 0) |
| 357 | | data = vtech1_fdc_wrprot[vtech1_drive]; |
| 358 | | if (LOG_VTECH1_FDC) |
| 359 | | logerror("vtech1_fdc_r %d : write_protect $%02X\n", offset, data); |
| 360 | | break; |
| 361 | | } |
| 362 | | return data; |
| 363 | | } |
| 364 | | |
| 365 | | WRITE8_HANDLER(vtech1_fdc_w) |
| 366 | | { |
| 367 | | int drive; |
| 368 | | |
| 369 | | switch (offset) |
| 370 | | { |
| 371 | | case 0: /* latch (write-only) */ |
| 372 | | drive = (data & 0x10) ? 0 : (data & 0x80) ? 1 : -1; |
| 373 | | if (drive != vtech1_drive) |
| 374 | | { |
| 375 | | vtech1_drive = drive; |
| 376 | | if (vtech1_drive >= 0) |
| 377 | | vtech1_get_track(space->machine); |
| 378 | | } |
| 379 | | if (vtech1_drive >= 0) |
| 380 | | { |
| 381 | | if ((PHI0(data) && !(PHI1(data) || PHI2(data) || PHI3(data)) && PHI1(vtech1_fdc_latch)) || |
| 382 | | (PHI1(data) && !(PHI0(data) || PHI2(data) || PHI3(data)) && PHI2(vtech1_fdc_latch)) || |
| 383 | | (PHI2(data) && !(PHI0(data) || PHI1(data) || PHI3(data)) && PHI3(vtech1_fdc_latch)) || |
| 384 | | (PHI3(data) && !(PHI0(data) || PHI1(data) || PHI2(data)) && PHI0(vtech1_fdc_latch))) |
| 385 | | { |
| 386 | | if (vtech1_track_x2[vtech1_drive] > 0) |
| 387 | | vtech1_track_x2[vtech1_drive]--; |
| 388 | | if (LOG_VTECH1_FDC) |
| 389 | | logerror("vtech1_fdc_w(%d) $%02X drive %d: stepout track #%2d.%d\n", offset, data, vtech1_drive, vtech1_track_x2[vtech1_drive]/2,5*(vtech1_track_x2[vtech1_drive]&1)); |
| 390 | | if ((vtech1_track_x2[vtech1_drive] & 1) == 0) |
| 391 | | vtech1_get_track(space->machine); |
| 392 | | } |
| 393 | | else |
| 394 | | if ((PHI0(data) && !(PHI1(data) || PHI2(data) || PHI3(data)) && PHI3(vtech1_fdc_latch)) || |
| 395 | | (PHI1(data) && !(PHI0(data) || PHI2(data) || PHI3(data)) && PHI0(vtech1_fdc_latch)) || |
| 396 | | (PHI2(data) && !(PHI0(data) || PHI1(data) || PHI3(data)) && PHI1(vtech1_fdc_latch)) || |
| 397 | | (PHI3(data) && !(PHI0(data) || PHI1(data) || PHI2(data)) && PHI2(vtech1_fdc_latch))) |
| 398 | | { |
| 399 | | if (vtech1_track_x2[vtech1_drive] < 2*40) |
| 400 | | vtech1_track_x2[vtech1_drive]++; |
| 401 | | if (LOG_VTECH1_FDC) |
| 402 | | logerror("vtech1_fdc_w(%d) $%02X drive %d: stepin track #%2d.%d\n", offset, data, vtech1_drive, vtech1_track_x2[vtech1_drive]/2,5*(vtech1_track_x2[vtech1_drive]&1)); |
| 403 | | if ((vtech1_track_x2[vtech1_drive] & 1) == 0) |
| 404 | | vtech1_get_track(space->machine); |
| 405 | | } |
| 406 | | if ((data & 0x40) == 0) |
| 407 | | { |
| 408 | | vtech1_data <<= 1; |
| 409 | | if ((vtech1_fdc_latch ^ data) & 0x20) |
| 410 | | vtech1_data |= 1; |
| 411 | | if ((vtech1_fdc_edge ^= 1) == 0) |
| 412 | | { |
| 413 | | if (--vtech1_fdc_bits == 0) |
| 414 | | { |
| 415 | | UINT8 value = 0; |
| 416 | | vtech1_data &= 0xffff; |
| 417 | | if (vtech1_data & 0x4000 ) value |= 0x80; |
| 418 | | if (vtech1_data & 0x1000 ) value |= 0x40; |
| 419 | | if (vtech1_data & 0x0400 ) value |= 0x20; |
| 420 | | if (vtech1_data & 0x0100 ) value |= 0x10; |
| 421 | | if (vtech1_data & 0x0040 ) value |= 0x08; |
| 422 | | if (vtech1_data & 0x0010 ) value |= 0x04; |
| 423 | | if (vtech1_data & 0x0004 ) value |= 0x02; |
| 424 | | if (vtech1_data & 0x0001 ) value |= 0x01; |
| 425 | | if (LOG_VTECH1_FDC) |
| 426 | | logerror("vtech1_fdc_w(%d) data($%04X) $%02X <- $%02X ($%04X)\n", offset, vtech1_fdc_offs, vtech1_fdc_data[vtech1_fdc_offs], value, vtech1_data); |
| 427 | | vtech1_fdc_data[vtech1_fdc_offs] = value; |
| 428 | | vtech1_fdc_offs = (vtech1_fdc_offs + 1) % TRKSIZE_FM; |
| 429 | | vtech1_fdc_write++; |
| 430 | | vtech1_fdc_bits = 8; |
| 431 | | } |
| 432 | | } |
| 433 | | } |
| 434 | | /* change of write signal? */ |
| 435 | | if ((vtech1_fdc_latch ^ data) & 0x40) |
| 436 | | { |
| 437 | | /* falling edge? */ |
| 438 | | if (vtech1_fdc_latch & 0x40) |
| 439 | | { |
| 440 | | vtech1_fdc_start = vtech1_fdc_offs; |
| 441 | | vtech1_fdc_edge = 0; |
| 442 | | } |
| 443 | | else |
| 444 | | { |
| 445 | | /* data written to track before? */ |
| 446 | | if (vtech1_fdc_write) |
| 447 | | vtech1_put_track(space->machine); |
| 448 | | } |
| 449 | | vtech1_fdc_bits = 8; |
| 450 | | vtech1_fdc_write = 0; |
| 451 | | } |
| 452 | | } |
| 453 | | vtech1_fdc_latch = data; |
| 454 | | break; |
| 455 | | } |
| 456 | | } |
| 457 | | |
| 458 | | |
| 459 | | /****************************************************************************** |
| 460 | | Input Handling |
| 461 | | ******************************************************************************/ |
| 462 | | |
| 463 | | READ8_HANDLER(vtech1_lightpen_r) |
| 464 | | { |
| 465 | | logerror("vtech1_lightpen_r(%d)\n", offset); |
| 466 | | return 0xff; |
| 467 | | } |
| 468 | | |
| 469 | | READ8_HANDLER(vtech1_joystick_r) |
| 470 | | { |
| 471 | | int data = 0xff; |
| 472 | | |
| 473 | | if (!(offset & 1)) |
| 474 | | data &= input_port_read(space->machine, "joystick_0"); |
| 475 | | if (!(offset & 2)) |
| 476 | | data &= input_port_read(space->machine, "joystick_0_arm"); |
| 477 | | if (!(offset & 4)) |
| 478 | | data &= input_port_read(space->machine, "joystick_1"); |
| 479 | | if (!(offset & 8)) |
| 480 | | data &= input_port_read(space->machine, "joystick_1_arm"); |
| 481 | | |
| 482 | | return data; |
| 483 | | } |
| 484 | | |
| 485 | | READ8_HANDLER(vtech1_keyboard_r) |
| 486 | | { |
| 487 | | static int cassette_bit = 0; |
| 488 | | int row, data = 0xff; |
| 489 | | double level; |
| 490 | | static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", |
| 491 | | "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" }; |
| 492 | | |
| 493 | | /* scan keyboard rows */ |
| 494 | | for (row = 0; row < 8; row++) |
| 495 | | { |
| 496 | | if (!(offset & (1 << row))) |
| 497 | | data &= input_port_read(space->machine, keynames[row]); |
| 498 | | } |
| 499 | | |
| 500 | | if (video_screen_get_vblank(space->machine->primary_screen)) |
| 501 | | data &= ~0x80; |
| 502 | | |
| 503 | | /* cassette input is bit 5 (0x40) */ |
| 504 | | level = cassette_input(cassette_device_image(space->machine)); |
| 505 | | if (level < -0.008) |
| 506 | | cassette_bit = 0x00; |
| 507 | | if (level > +0.008) |
| 508 | | cassette_bit = 0x40; |
| 509 | | |
| 510 | | data &= ~cassette_bit; |
| 511 | | |
| 512 | | return data; |
| 513 | | } |
| 514 | | |
| 515 | | /************************************************* |
| 516 | | * bit function |
| 517 | | * 7 not assigned |
| 518 | | * 6 not assigned |
| 519 | | * 5 speaker B |
| 520 | | * 4 VDC background 0 green, 1 orange |
| 521 | | * 3 VDC display mode 0 text, 1 graphics |
| 522 | | * 2 cassette out (MSB) |
| 523 | | * 1 cassette out (LSB) |
| 524 | | * 0 speaker A |
| 525 | | ************************************************/ |
| 526 | | WRITE8_HANDLER( vtech1_latch_w ) |
| 527 | | { |
| 528 | | const device_config *speaker = devtag_get_device(space->machine, "speaker"); |
| 529 | | const device_config *mc6847 = devtag_get_device(space->machine, "mc6847"); |
| 530 | | |
| 531 | | if (LOG_VTECH1_LATCH) |
| 532 | | logerror("vtech1_latch_w $%02X\n", data); |
| 533 | | |
| 534 | | /* vdc mode control lines */ |
| 535 | | mc6847_ag_w(mc6847, BIT(data, 3)); |
| 536 | | mc6847_css_w(mc6847, BIT(data, 4)); |
| 537 | | |
| 538 | | /* cassette data bits toggle? */ |
| 539 | | if ((vtech1_latch ^ data ) & 0x06) |
| 540 | | { |
| 541 | | static const double amp[4] = { +1.0, +0.5, -0.5, -1.0 }; |
| 542 | | cassette_output(cassette_device_image(space->machine), amp[(data >> 1) & 3]); |
| 543 | | } |
| 544 | | |
| 545 | | /* speaker data bits toggle? */ |
| 546 | | if ((vtech1_latch ^ data ) & 0x41) |
| 547 | | speaker_level_w(speaker, (data & 1) | ((data >> 5) & 2)); |
| 548 | | |
| 549 | | vtech1_latch = data; |
| 550 | | } |
| 551 | | |
| 552 | | |
| 553 | | /****************************************************************************** |
| 554 | | Printer Handling |
| 555 | | ******************************************************************************/ |
| 556 | | |
| 557 | | /* |
| 558 | | The VZ200/300 printer interface uses I/O port address OE Hex for the ASCII |
| 559 | | character code data and strobe output, and address OOH for the busy/ready-bar |
| 560 | | status input (bit 0). |
| 561 | | */ |
| 562 | | |
| 563 | | READ8_HANDLER( vtech1_printer_r ) |
| 564 | | { |
| 565 | | const device_config *printer = devtag_get_device(space->machine, "centronics"); |
| 566 | | UINT8 result = 0xff; |
| 567 | | |
| 568 | | result &= ~(!centronics_busy_r(printer)); |
| 569 | | |
| 570 | | return result; |
| 571 | | } |
| 572 | | |
| 573 | | /* TODO: figure out how this really works */ |
| 574 | | WRITE8_HANDLER( vtech1_strobe_w ) |
| 575 | | { |
| 576 | | const device_config *printer = devtag_get_device(space->machine, "centronics"); |
| 577 | | centronics_strobe_w(printer, TRUE); |
| 578 | | centronics_strobe_w(printer, FALSE); |
| 579 | | } |
| 580 | | |
| 581 | | |
| 582 | | /****************************************************************************** |
| 583 | | Serial RS232 Handling |
| 584 | | ******************************************************************************/ |
| 585 | | |
| 586 | | READ8_HANDLER(vtech1_serial_r) |
| 587 | | { |
| 588 | | int data = 0xff; |
| 589 | | logerror("vtech1_serial_r offset $%02x\n", offset); |
| 590 | | return data; |
| 591 | | } |
| 592 | | |
| 593 | | WRITE8_HANDLER(vtech1_serial_w) |
| 594 | | { |
| 595 | | logerror("vtech1_serial_w $%02x, offset %02x\n", data, offset); |
| 596 | | } |
| 597 | | |
| 598 | | |
| 599 | | /*************************************************************************** |
| 600 | | MC6847 |
| 601 | | ***************************************************************************/ |
| 602 | | |
| 603 | | READ8_DEVICE_HANDLER( vtech1_mc6847_videoram_r ) |
| 604 | | { |
| 605 | | mc6847_inv_w(device, BIT(videoram[offset], 6)); |
| 606 | | mc6847_as_w(device, BIT(videoram[offset], 7)); |
| 607 | | |
| 608 | | return videoram[offset]; |
| 609 | | } |
| 610 | | |
| 611 | | VIDEO_UPDATE( vtech1 ) |
| 612 | | { |
| 613 | | const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847"); |
| 614 | | return mc6847_update(mc6847, bitmap, cliprect); |
| 615 | | } |
src/mess/drivers/vtech1.c
| r6100 | r6101 | |
| 82 | 82 | 8000-BFFF 64K memory expansion, first bank |
| 83 | 83 | C000-FFFF 64K memory expansion, other banks |
| 84 | 84 | |
| 85 | |
| 86 | Memory expansions available for the Laser/VZ computers: |
| 87 | |
| 88 | - a 16kb expansion without banking |
| 89 | - a 64kb expansion where the first bank is fixed and the other 3 are |
| 90 | banked in as needed |
| 91 | - a banked memory expansion similar to the 64kb one, that the user could |
| 92 | fill themselves with memory up to 4MB total. |
| 93 | |
| 94 | They are externally connected devices. The 16kb extension is different |
| 95 | between Laser 110/210/310 computers, though it could be relativly |
| 96 | easily modified to work on another model. |
| 97 | |
| 98 | |
| 85 | 99 | Todo: |
| 86 | 100 | |
| 87 | 101 | - Figure out which machines were shipped with which ROM version |
| 88 | 102 | where not known (currently only a guess) |
| 89 | 103 | - Lightpen support |
| 90 | | - External keyboard? (and maybe the other strange I/O stuff which is |
| 91 | | commented out at the moment...) |
| 104 | - Rewrite floppy and move to its own file |
| 92 | 105 | |
| 93 | 106 | Notes: |
| 94 | 107 | |
| r6100 | r6101 | |
| 98 | 111 | |
| 99 | 112 | ******************************************************************************/ |
| 100 | 113 | |
| 101 | | /* Core includes */ |
| 102 | 114 | #include "driver.h" |
| 115 | #include "utils.h" |
| 103 | 116 | #include "cpu/z80/z80.h" |
| 117 | #include "video/m6847.h" |
| 118 | #include "machine/ctronics.h" |
| 104 | 119 | #include "sound/wave.h" |
| 105 | | #include "includes/vtech1.h" |
| 106 | | |
| 107 | | /* Components */ |
| 108 | | #include "video/m6847.h" |
| 109 | 120 | #include "sound/speaker.h" |
| 110 | | |
| 111 | | /* Devices */ |
| 112 | 121 | #include "devices/cartslot.h" |
| 113 | 122 | #include "devices/snapquik.h" |
| 114 | 123 | #include "devices/cassette.h" |
| 115 | | #include "machine/ctronics.h" |
| 116 | 124 | #include "devices/z80bin.h" |
| 125 | #include "devices/messram.h" |
| 117 | 126 | #include "formats/vt_cas.h" |
| 118 | | #include "devices/messram.h" |
| 119 | 127 | |
| 120 | | static Z80BIN_EXECUTE(vtech1); |
| 121 | 128 | |
| 129 | /*************************************************************************** |
| 130 | CONSTANTS & MACROS |
| 131 | ***************************************************************************/ |
| 122 | 132 | |
| 123 | | /****************************************************************************** |
| 124 | | Address Maps |
| 125 | | ******************************************************************************/ |
| 133 | #define LOG_VTECH1_LATCH 0 |
| 134 | #define LOG_VTECH1_FDC 0 |
| 126 | 135 | |
| 127 | | /* Note: Expansion memory is dynamically mapped in machine/vtech1.c */ |
| 136 | #define VTECH1_CLK 3579500 |
| 137 | #define VZ300_XTAL1_CLK XTAL_17_73447MHz |
| 128 | 138 | |
| 129 | | static ADDRESS_MAP_START(laser110_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 139 | #define VZ_BASIC 0xf0 |
| 140 | #define VZ_MCODE 0xf1 |
| 141 | |
| 142 | #define TRKSIZE_VZ 0x9b0 /* arbitrary (actually from analyzing format) */ |
| 143 | #define TRKSIZE_FM 3172 /* size of a standard FM mode track */ |
| 144 | |
| 145 | #define PHI0(n) (((n)>>0)&1) |
| 146 | #define PHI1(n) (((n)>>1)&1) |
| 147 | #define PHI2(n) (((n)>>2)&1) |
| 148 | #define PHI3(n) (((n)>>3)&1) |
| 149 | |
| 150 | |
| 151 | /*************************************************************************** |
| 152 | TYPE DEFINITIONS |
| 153 | ***************************************************************************/ |
| 154 | |
| 155 | typedef struct _vtech1_state vtech1_state; |
| 156 | struct _vtech1_state |
| 157 | { |
| 158 | /* devices */ |
| 159 | const device_config *mc6847; |
| 160 | const device_config *speaker; |
| 161 | const device_config *cassette; |
| 162 | const device_config *printer; |
| 163 | |
| 164 | UINT8 *ram; |
| 165 | UINT32 ram_size; |
| 166 | |
| 167 | /* floppy */ |
| 168 | int drive; |
| 169 | UINT8 fdc_track_x2[2]; |
| 170 | UINT8 fdc_wrprot[2]; |
| 171 | UINT8 fdc_status; |
| 172 | UINT8 fdc_data[TRKSIZE_FM]; |
| 173 | int data; |
| 174 | int fdc_edge; |
| 175 | int fdc_bits; |
| 176 | int fdc_start; |
| 177 | int fdc_write; |
| 178 | int fdc_offs; |
| 179 | int fdc_latch; |
| 180 | }; |
| 181 | |
| 182 | |
| 183 | /*************************************************************************** |
| 184 | SNAPSHOT LOADING |
| 185 | ***************************************************************************/ |
| 186 | |
| 187 | static SNAPSHOT_LOAD( vtech1 ) |
| 188 | { |
| 189 | vtech1_state *vtech1 = image->machine->driver_data; |
| 190 | const address_space *space = cputag_get_address_space(image->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 191 | UINT8 i, header[24]; |
| 192 | UINT16 start, end, size; |
| 193 | char pgmname[18]; |
| 194 | |
| 195 | /* get the header */ |
| 196 | image_fread(image, &header, sizeof(header)); |
| 197 | for (i = 0; i < 16; i++) pgmname[i] = header[i+4]; |
| 198 | pgmname[16] = '\0'; |
| 199 | |
| 200 | /* get start and end addresses */ |
| 201 | start = pick_integer_le(header, 22, 2); |
| 202 | end = start + snapshot_size - sizeof(header); |
| 203 | size = end - start; |
| 204 | |
| 205 | /* check if we have enough ram */ |
| 206 | if (vtech1->ram_size < size) |
| 207 | { |
| 208 | char message[256]; |
| 209 | snprintf(message, ARRAY_LENGTH(message), "SNAPLOAD: %s\nInsufficient RAM - need %04X",pgmname,size); |
| 210 | image_seterror(image, IMAGE_ERROR_INVALIDIMAGE, message); |
| 211 | image_message(image, "SNAPLOAD: %s\nInsufficient RAM - need %04X",pgmname,size); |
| 212 | return INIT_FAIL; |
| 213 | } |
| 214 | |
| 215 | /* write it to ram */ |
| 216 | image_fread(image, &vtech1->ram[start - 0x7800], size); |
| 217 | |
| 218 | /* patch variables depending on snapshot type */ |
| 219 | switch (header[21]) |
| 220 | { |
| 221 | case VZ_BASIC: /* 0xF0 */ |
| 222 | memory_write_byte(space, 0x78a4, start % 256); /* start of basic program */ |
| 223 | memory_write_byte(space, 0x78a5, start / 256); |
| 224 | memory_write_byte(space, 0x78f9, end % 256); /* end of basic program */ |
| 225 | memory_write_byte(space, 0x78fa, end / 256); |
| 226 | memory_write_byte(space, 0x78fb, end % 256); /* start variable table */ |
| 227 | memory_write_byte(space, 0x78fc, end / 256); |
| 228 | memory_write_byte(space, 0x78fd, end % 256); /* start free mem, end variable table */ |
| 229 | memory_write_byte(space, 0x78fe, end / 256); |
| 230 | image_message(image, " %s (B)\nsize=%04X : start=%04X : end=%04X",pgmname,size,start,end); |
| 231 | break; |
| 232 | |
| 233 | case VZ_MCODE: /* 0xF1 */ |
| 234 | memory_write_byte(space, 0x788e, start % 256); /* usr subroutine address */ |
| 235 | memory_write_byte(space, 0x788f, start / 256); |
| 236 | image_message(image, " %s (M)\nsize=%04X : start=%04X : end=%04X",pgmname,size,start,end); |
| 237 | cpu_set_reg(cputag_get_cpu(image->machine, "maincpu"), REG_GENPC, start); /* start program */ |
| 238 | break; |
| 239 | |
| 240 | default: |
| 241 | image_seterror(image, IMAGE_ERROR_UNSUPPORTED, "Snapshot format not supported."); |
| 242 | image_message(image, "Snapshot format not supported."); |
| 243 | return INIT_FAIL; |
| 244 | } |
| 245 | |
| 246 | return INIT_PASS; |
| 247 | } |
| 248 | |
| 249 | static Z80BIN_EXECUTE( vtech1 ) |
| 250 | { |
| 251 | const device_config *cpu = cputag_get_cpu(machine, "maincpu"); |
| 252 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 253 | |
| 254 | /* A Microsoft Basic program needs some manipulation before it can be run. |
| 255 | 1. A start address of 7ae9 indicates a basic program which needs its pointers fixed up. |
| 256 | 2. If autorun is turned off, the pointers still need fixing, but then display READY. |
| 257 | Important addresses: |
| 258 | 7ae9 = start (load) address of a conventional basic program |
| 259 | 791e = custom routine to fix basic pointers */ |
| 260 | |
| 261 | memory_write_word_16le(space, 0x791c, end_address + 1); |
| 262 | memory_write_word_16le(space, 0x781e, execute_address); |
| 263 | |
| 264 | if (start_address == 0x7ae9) |
| 265 | { |
| 266 | UINT8 i, data[]={ |
| 267 | 0xe5, // PUSH HL ;save pcode pointer |
| 268 | 0x2a, 0x1c, 0x79, // LD HL,(791C) ;get saved end_addr+1 |
| 269 | 0x22, 0xf9, 0x78, // LD (78F9),HL ;move it to correct place |
| 270 | 0x21, 0x39, 0x78, // LD HL,7839 ;point to control flag |
| 271 | 0xcb, 0xf6, // SET 6,(HL) ;turn on autorun (cb b6 = manual run) |
| 272 | 0xcb, 0x9e, // RES 3,(HL) ;turn off verify (just in case) |
| 273 | 0xc3, 0xcf, 0x36,}; // JP 36CF ;enter bios at autorun point |
| 274 | |
| 275 | for (i = 0; i < ARRAY_LENGTH(data); i++) |
| 276 | memory_write_byte(space, 0x791e + i, data[i]); |
| 277 | |
| 278 | if (!autorun) |
| 279 | memory_write_byte(space, 0x7929, 0xb6); /* turn off autorun */ |
| 280 | |
| 281 | cpu_set_reg(cpu, REG_GENPC, 0x791e); |
| 282 | } |
| 283 | else |
| 284 | { |
| 285 | if (autorun) |
| 286 | cpu_set_reg(cpu, REG_GENPC, execute_address); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | |
| 291 | /*************************************************************************** |
| 292 | FLOPPY DRIVE |
| 293 | ***************************************************************************/ |
| 294 | |
| 295 | static const device_config *vtech1_file(running_machine *machine) |
| 296 | { |
| 297 | vtech1_state *vtech1 = machine->driver_data; |
| 298 | |
| 299 | if (vtech1->drive < 0) |
| 300 | return NULL; |
| 301 | |
| 302 | return image_from_devtype_and_index(machine, IO_FLOPPY, vtech1->drive); |
| 303 | } |
| 304 | |
| 305 | static DEVICE_IMAGE_LOAD( vtech1_floppy ) |
| 306 | { |
| 307 | vtech1_state *vtech1 = image->machine->driver_data; |
| 308 | int id = image_index_in_device(image); |
| 309 | |
| 310 | if (image_is_writable(image)) |
| 311 | vtech1->fdc_wrprot[id] = 0x00; |
| 312 | else |
| 313 | vtech1->fdc_wrprot[id] = 0x80; |
| 314 | |
| 315 | return INIT_PASS; |
| 316 | } |
| 317 | |
| 318 | static void vtech1_get_track(running_machine *machine) |
| 319 | { |
| 320 | vtech1_state *vtech1 = machine->driver_data; |
| 321 | |
| 322 | /* drive selected or and image file ok? */ |
| 323 | if (vtech1->drive >= 0 && image_exists(vtech1_file(machine))) |
| 324 | { |
| 325 | int size, offs; |
| 326 | size = TRKSIZE_VZ; |
| 327 | offs = TRKSIZE_VZ * vtech1->fdc_track_x2[vtech1->drive]/2; |
| 328 | image_fseek(vtech1_file(machine), offs, SEEK_SET); |
| 329 | size = image_fread(vtech1_file(machine), vtech1->fdc_data, size); |
| 330 | if (LOG_VTECH1_FDC) |
| 331 | logerror("get track @$%05x $%04x bytes\n", offs, size); |
| 332 | } |
| 333 | vtech1->fdc_offs = 0; |
| 334 | vtech1->fdc_write = 0; |
| 335 | } |
| 336 | |
| 337 | static void vtech1_put_track(running_machine *machine) |
| 338 | { |
| 339 | vtech1_state *vtech1 = machine->driver_data; |
| 340 | |
| 341 | /* drive selected and image file ok? */ |
| 342 | if (vtech1->drive >= 0 && vtech1_file(machine) != NULL) |
| 343 | { |
| 344 | int size, offs; |
| 345 | offs = TRKSIZE_VZ * vtech1->fdc_track_x2[vtech1->drive]/2; |
| 346 | image_fseek(vtech1_file(machine), offs + vtech1->fdc_start, SEEK_SET); |
| 347 | size = image_fwrite(vtech1_file(machine), &vtech1->fdc_data[vtech1->fdc_start], vtech1->fdc_write); |
| 348 | if (LOG_VTECH1_FDC) |
| 349 | logerror("put track @$%05X+$%X $%04X/$%04X bytes\n", offs, vtech1->fdc_start, size, vtech1->fdc_write); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | static READ8_HANDLER( vtech1_fdc_r ) |
| 354 | { |
| 355 | vtech1_state *vtech1 = space->machine->driver_data; |
| 356 | int data = 0xff; |
| 357 | |
| 358 | switch (offset) |
| 359 | { |
| 360 | case 1: /* data (read-only) */ |
| 361 | if (vtech1->fdc_bits > 0) |
| 362 | { |
| 363 | if( vtech1->fdc_status & 0x80 ) |
| 364 | vtech1->fdc_bits--; |
| 365 | data = (vtech1->data >> vtech1->fdc_bits) & 0xff; |
| 366 | if (LOG_VTECH1_FDC) { |
| 367 | logerror("vtech1_fdc_r bits %d%d%d%d%d%d%d%d\n", |
| 368 | (data>>7)&1,(data>>6)&1,(data>>5)&1,(data>>4)&1, |
| 369 | (data>>3)&1,(data>>2)&1,(data>>1)&1,(data>>0)&1 ); |
| 370 | } |
| 371 | } |
| 372 | if (vtech1->fdc_bits == 0) |
| 373 | { |
| 374 | vtech1->data = vtech1->fdc_data[vtech1->fdc_offs]; |
| 375 | if (LOG_VTECH1_FDC) |
| 376 | logerror("vtech1_fdc_r %d : data ($%04X) $%02X\n", offset, vtech1->fdc_offs, vtech1->data); |
| 377 | if(vtech1->fdc_status & 0x80) |
| 378 | { |
| 379 | vtech1->fdc_bits = 8; |
| 380 | vtech1->fdc_offs = (vtech1->fdc_offs + 1) % TRKSIZE_FM; |
| 381 | } |
| 382 | vtech1->fdc_status &= ~0x80; |
| 383 | } |
| 384 | break; |
| 385 | case 2: /* polling (read-only) */ |
| 386 | /* fake */ |
| 387 | if (vtech1->drive >= 0) |
| 388 | vtech1->fdc_status |= 0x80; |
| 389 | data = vtech1->fdc_status; |
| 390 | break; |
| 391 | case 3: /* write protect status (read-only) */ |
| 392 | if (vtech1->drive >= 0) |
| 393 | data = vtech1->fdc_wrprot[vtech1->drive]; |
| 394 | if (LOG_VTECH1_FDC) |
| 395 | logerror("vtech1_fdc_r %d : write_protect $%02X\n", offset, data); |
| 396 | break; |
| 397 | } |
| 398 | return data; |
| 399 | } |
| 400 | |
| 401 | static WRITE8_HANDLER( vtech1_fdc_w ) |
| 402 | { |
| 403 | vtech1_state *vtech1 = space->machine->driver_data; |
| 404 | int drive; |
| 405 | |
| 406 | switch (offset) |
| 407 | { |
| 408 | case 0: /* latch (write-only) */ |
| 409 | drive = (data & 0x10) ? 0 : (data & 0x80) ? 1 : -1; |
| 410 | if (drive != vtech1->drive) |
| 411 | { |
| 412 | vtech1->drive = drive; |
| 413 | if (vtech1->drive >= 0) |
| 414 | vtech1_get_track(space->machine); |
| 415 | } |
| 416 | if (vtech1->drive >= 0) |
| 417 | { |
| 418 | if ((PHI0(data) && !(PHI1(data) || PHI2(data) || PHI3(data)) && PHI1(vtech1->fdc_latch)) || |
| 419 | (PHI1(data) && !(PHI0(data) || PHI2(data) || PHI3(data)) && PHI2(vtech1->fdc_latch)) || |
| 420 | (PHI2(data) && !(PHI0(data) || PHI1(data) || PHI3(data)) && PHI3(vtech1->fdc_latch)) || |
| 421 | (PHI3(data) && !(PHI0(data) || PHI1(data) || PHI2(data)) && PHI0(vtech1->fdc_latch))) |
| 422 | { |
| 423 | if (vtech1->fdc_track_x2[vtech1->drive] > 0) |
| 424 | vtech1->fdc_track_x2[vtech1->drive]--; |
| 425 | if (LOG_VTECH1_FDC) |
| 426 | logerror("vtech1_fdc_w(%d) $%02X drive %d: stepout track #%2d.%d\n", offset, data, vtech1->drive, vtech1->fdc_track_x2[vtech1->drive]/2,5*(vtech1->fdc_track_x2[vtech1->drive]&1)); |
| 427 | if ((vtech1->fdc_track_x2[vtech1->drive] & 1) == 0) |
| 428 | vtech1_get_track(space->machine); |
| 429 | } |
| 430 | else |
| 431 | if ((PHI0(data) && !(PHI1(data) || PHI2(data) || PHI3(data)) && PHI3(vtech1->fdc_latch)) || |
| 432 | (PHI1(data) && !(PHI0(data) || PHI2(data) || PHI3(data)) && PHI0(vtech1->fdc_latch)) || |
| 433 | (PHI2(data) && !(PHI0(data) || PHI1(data) || PHI3(data)) && PHI1(vtech1->fdc_latch)) || |
| 434 | (PHI3(data) && !(PHI0(data) || PHI1(data) || PHI2(data)) && PHI2(vtech1->fdc_latch))) |
| 435 | { |
| 436 | if (vtech1->fdc_track_x2[vtech1->drive] < 2*40) |
| 437 | vtech1->fdc_track_x2[vtech1->drive]++; |
| 438 | if (LOG_VTECH1_FDC) |
| 439 | logerror("vtech1_fdc_w(%d) $%02X drive %d: stepin track #%2d.%d\n", offset, data, vtech1->drive, vtech1->fdc_track_x2[vtech1->drive]/2,5*(vtech1->fdc_track_x2[vtech1->drive]&1)); |
| 440 | if ((vtech1->fdc_track_x2[vtech1->drive] & 1) == 0) |
| 441 | vtech1_get_track(space->machine); |
| 442 | } |
| 443 | if ((data & 0x40) == 0) |
| 444 | { |
| 445 | vtech1->data <<= 1; |
| 446 | if ((vtech1->fdc_latch ^ data) & 0x20) |
| 447 | vtech1->data |= 1; |
| 448 | if ((vtech1->fdc_edge ^= 1) == 0) |
| 449 | { |
| 450 | vtech1->fdc_bits--; |
| 451 | |
| 452 | if (vtech1->fdc_bits == 0) |
| 453 | { |
| 454 | UINT8 value = 0; |
| 455 | vtech1->data &= 0xffff; |
| 456 | if (vtech1->data & 0x4000 ) value |= 0x80; |
| 457 | if (vtech1->data & 0x1000 ) value |= 0x40; |
| 458 | if (vtech1->data & 0x0400 ) value |= 0x20; |
| 459 | if (vtech1->data & 0x0100 ) value |= 0x10; |
| 460 | if (vtech1->data & 0x0040 ) value |= 0x08; |
| 461 | if (vtech1->data & 0x0010 ) value |= 0x04; |
| 462 | if (vtech1->data & 0x0004 ) value |= 0x02; |
| 463 | if (vtech1->data & 0x0001 ) value |= 0x01; |
| 464 | if (LOG_VTECH1_FDC) |
| 465 | logerror("vtech1_fdc_w(%d) data($%04X) $%02X <- $%02X ($%04X)\n", offset, vtech1->fdc_offs, vtech1->fdc_data[vtech1->fdc_offs], value, vtech1->data); |
| 466 | vtech1->fdc_data[vtech1->fdc_offs] = value; |
| 467 | vtech1->fdc_offs = (vtech1->fdc_offs + 1) % TRKSIZE_FM; |
| 468 | vtech1->fdc_write++; |
| 469 | vtech1->fdc_bits = 8; |
| 470 | } |
| 471 | } |
| 472 | } |
| 473 | /* change of write signal? */ |
| 474 | if ((vtech1->fdc_latch ^ data) & 0x40) |
| 475 | { |
| 476 | /* falling edge? */ |
| 477 | if (vtech1->fdc_latch & 0x40) |
| 478 | { |
| 479 | vtech1->fdc_start = vtech1->fdc_offs; |
| 480 | vtech1->fdc_edge = 0; |
| 481 | } |
| 482 | else |
| 483 | { |
| 484 | /* data written to track before? */ |
| 485 | if (vtech1->fdc_write) |
| 486 | vtech1_put_track(space->machine); |
| 487 | } |
| 488 | vtech1->fdc_bits = 8; |
| 489 | vtech1->fdc_write = 0; |
| 490 | } |
| 491 | } |
| 492 | vtech1->fdc_latch = data; |
| 493 | break; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | |
| 498 | /*************************************************************************** |
| 499 | PRINTER |
| 500 | ***************************************************************************/ |
| 501 | |
| 502 | static READ8_DEVICE_HANDLER( vtech1_printer_r ) |
| 503 | { |
| 504 | UINT8 result = 0xff; |
| 505 | |
| 506 | result &= ~(!centronics_busy_r(device)); |
| 507 | |
| 508 | return result; |
| 509 | } |
| 510 | |
| 511 | /* TODO: figure out how this really works */ |
| 512 | static WRITE8_DEVICE_HANDLER( vtech1_strobe_w ) |
| 513 | { |
| 514 | centronics_strobe_w(device, TRUE); |
| 515 | centronics_strobe_w(device, FALSE); |
| 516 | } |
| 517 | |
| 518 | |
| 519 | /*************************************************************************** |
| 520 | RS232 SERIAL |
| 521 | ***************************************************************************/ |
| 522 | |
| 523 | static READ8_HANDLER( vtech1_serial_r ) |
| 524 | { |
| 525 | logerror("vtech1_serial_r offset $%02x\n", offset); |
| 526 | return 0xff; |
| 527 | } |
| 528 | |
| 529 | static WRITE8_HANDLER( vtech1_serial_w ) |
| 530 | { |
| 531 | logerror("vtech1_serial_w $%02x, offset %02x\n", data, offset); |
| 532 | } |
| 533 | |
| 534 | |
| 535 | /*************************************************************************** |
| 536 | INPUTS |
| 537 | ***************************************************************************/ |
| 538 | |
| 539 | static READ8_HANDLER( vtech1_lightpen_r ) |
| 540 | { |
| 541 | logerror("vtech1_lightpen_r(%d)\n", offset); |
| 542 | return 0xff; |
| 543 | } |
| 544 | |
| 545 | static READ8_HANDLER( vtech1_joystick_r ) |
| 546 | { |
| 547 | int result = 0xff; |
| 548 | |
| 549 | if (!BIT(offset, 0)) result &= input_port_read(space->machine, "joystick_0"); |
| 550 | if (!BIT(offset, 1)) result &= input_port_read(space->machine, "joystick_0_arm"); |
| 551 | if (!BIT(offset, 2)) result &= input_port_read(space->machine, "joystick_1"); |
| 552 | if (!BIT(offset, 3)) result &= input_port_read(space->machine, "joystick_1_arm"); |
| 553 | |
| 554 | return result; |
| 555 | } |
| 556 | |
| 557 | static READ8_HANDLER( vtech1_keyboard_r ) |
| 558 | { |
| 559 | vtech1_state *vtech1 = space->machine->driver_data; |
| 560 | UINT8 result = 0x3f; |
| 561 | |
| 562 | /* bit 0 to 5, keyboard input */ |
| 563 | if (!BIT(offset, 0)) result &= input_port_read(space->machine, "keyboard_0"); |
| 564 | if (!BIT(offset, 1)) result &= input_port_read(space->machine, "keyboard_1"); |
| 565 | if (!BIT(offset, 2)) result &= input_port_read(space->machine, "keyboard_2"); |
| 566 | if (!BIT(offset, 3)) result &= input_port_read(space->machine, "keyboard_3"); |
| 567 | if (!BIT(offset, 4)) result &= input_port_read(space->machine, "keyboard_4"); |
| 568 | if (!BIT(offset, 5)) result &= input_port_read(space->machine, "keyboard_5"); |
| 569 | if (!BIT(offset, 6)) result &= input_port_read(space->machine, "keyboard_6"); |
| 570 | if (!BIT(offset, 7)) result &= input_port_read(space->machine, "keyboard_7"); |
| 571 | |
| 572 | /* bit 6, cassette input */ |
| 573 | result |= (cassette_input(vtech1->cassette) > 0 ? 1 : 0) << 6; |
| 574 | |
| 575 | /* bit 7, field sync */ |
| 576 | result |= mc6847_fs_r(vtech1->mc6847) << 7; |
| 577 | |
| 578 | return result; |
| 579 | } |
| 580 | |
| 581 | |
| 582 | /*************************************************************************** |
| 583 | I/O LATCH |
| 584 | ***************************************************************************/ |
| 585 | |
| 586 | static WRITE8_HANDLER( vtech1_latch_w ) |
| 587 | { |
| 588 | vtech1_state *vtech1 = space->machine->driver_data; |
| 589 | |
| 590 | if (LOG_VTECH1_LATCH) |
| 591 | logerror("vtech1_latch_w $%02X\n", data); |
| 592 | |
| 593 | /* bit 2, cassette out */ |
| 594 | cassette_output(vtech1->cassette, BIT(data, 2) ? +1.0 : -1.0); |
| 595 | |
| 596 | /* bit 3 and 4, vdc mode control lines */ |
| 597 | mc6847_ag_w(vtech1->mc6847, BIT(data, 3)); |
| 598 | mc6847_css_w(vtech1->mc6847, BIT(data, 4)); |
| 599 | |
| 600 | /* bit 0 and 5, speaker */ |
| 601 | speaker_level_w(vtech1->speaker, (BIT(data, 5) << 1) | BIT(data, 0)); |
| 602 | } |
| 603 | |
| 604 | |
| 605 | /*************************************************************************** |
| 606 | MEMORY BANKING |
| 607 | ***************************************************************************/ |
| 608 | |
| 609 | static WRITE8_HANDLER( vtech1_memory_bank_w ) |
| 610 | { |
| 611 | vtech1_state *vtech1 = space->machine->driver_data; |
| 612 | |
| 613 | logerror("vtech1_memory_bank_w $%02X\n", data); |
| 614 | |
| 615 | if (data >= 1) |
| 616 | if ((data <= 3 && vtech1->ram_size == 66*1024) || (vtech1->ram_size == 4098*1024)) |
| 617 | memory_set_bank(space->machine, 3, data - 1); |
| 618 | } |
| 619 | |
| 620 | |
| 621 | /*************************************************************************** |
| 622 | VIDEO EMULATION |
| 623 | ***************************************************************************/ |
| 624 | |
| 625 | static READ8_DEVICE_HANDLER( vtech1_mc6847_videoram_r ) |
| 626 | { |
| 627 | mc6847_inv_w(device, BIT(videoram[offset], 6)); |
| 628 | mc6847_as_w(device, BIT(videoram[offset], 7)); |
| 629 | |
| 630 | return videoram[offset]; |
| 631 | } |
| 632 | |
| 633 | static VIDEO_UPDATE( vtech1 ) |
| 634 | { |
| 635 | vtech1_state *vtech1 = screen->machine->driver_data; |
| 636 | return mc6847_update(vtech1->mc6847, bitmap, cliprect); |
| 637 | } |
| 638 | |
| 639 | |
| 640 | /*************************************************************************** |
| 641 | DRIVER INIT |
| 642 | ***************************************************************************/ |
| 643 | |
| 644 | static DRIVER_INIT( vtech1 ) |
| 645 | { |
| 646 | vtech1_state *vtech1 = machine->driver_data; |
| 647 | const address_space *prg = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 648 | |
| 649 | /* find devices */ |
| 650 | vtech1->mc6847 = devtag_get_device(machine, "mc6847"); |
| 651 | vtech1->speaker = devtag_get_device(machine, "speaker"); |
| 652 | vtech1->cassette = devtag_get_device(machine, "cassette"); |
| 653 | vtech1->printer = devtag_get_device(machine, "printer"); |
| 654 | |
| 655 | /* ram */ |
| 656 | vtech1->ram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 657 | vtech1->ram_size = messram_get_size(devtag_get_device(machine, "messram")); |
| 658 | |
| 659 | /* setup memory banking */ |
| 660 | memory_set_bankptr(machine, 1, vtech1->ram); |
| 661 | |
| 662 | /* 16k memory expansion? */ |
| 663 | if (vtech1->ram_size == 18*1024 || vtech1->ram_size == 22*1024 || vtech1->ram_size == 32*1024) |
| 664 | { |
| 665 | offs_t base = 0x7800 + (vtech1->ram_size - 0x4000); |
| 666 | memory_install_readwrite8_handler(prg, base, base + 0x3fff, 0, 0, SMH_BANK(2), SMH_BANK(2)); |
| 667 | memory_set_bankptr(machine, 2, vtech1->ram + base - 0x7800); |
| 668 | } |
| 669 | |
| 670 | /* 64k expansion? */ |
| 671 | if (vtech1->ram_size >= 66*1024) |
| 672 | { |
| 673 | /* install fixed first bank */ |
| 674 | memory_install_readwrite8_handler(prg, 0x8000, 0xbfff, 0, 0, SMH_BANK(2), SMH_BANK(2)); |
| 675 | memory_set_bankptr(machine, 2, vtech1->ram + 0x800); |
| 676 | |
| 677 | /* install the others, dynamically banked in */ |
| 678 | memory_install_readwrite8_handler(prg, 0xc000, 0xffff, 0, 0, SMH_BANK(3), SMH_BANK(3)); |
| 679 | memory_configure_bank(machine, 3, 0, (vtech1->ram_size - 0x4800) / 0x4000, vtech1->ram + 0x4800, 0x4000); |
| 680 | memory_set_bank(machine, 3, 0); |
| 681 | } |
| 682 | |
| 683 | /* initialize floppy */ |
| 684 | vtech1->drive = -1; |
| 685 | vtech1->fdc_track_x2[0] = 80; |
| 686 | vtech1->fdc_track_x2[1] = 80; |
| 687 | vtech1->fdc_wrprot[0] = 0x80; |
| 688 | vtech1->fdc_wrprot[1] = 0x80; |
| 689 | vtech1->fdc_status = 0; |
| 690 | vtech1->fdc_edge = 0; |
| 691 | vtech1->fdc_bits = 8; |
| 692 | vtech1->fdc_start = 0; |
| 693 | vtech1->fdc_write = 0; |
| 694 | vtech1->fdc_offs = 0; |
| 695 | vtech1->fdc_latch = 0; |
| 696 | } |
| 697 | |
| 698 | |
| 699 | /*************************************************************************** |
| 700 | ADDRESS MAPS |
| 701 | ***************************************************************************/ |
| 702 | |
| 703 | static ADDRESS_MAP_START( laser110_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 130 | 704 | AM_RANGE(0x0000, 0x3fff) AM_ROM /* basic rom */ |
| 131 | 705 | AM_RANGE(0x4000, 0x5fff) AM_ROM /* dos rom or other catridges */ |
| 132 | 706 | AM_RANGE(0x6000, 0x67ff) AM_ROM /* reserved for cartridges */ |
| 133 | 707 | AM_RANGE(0x6800, 0x6fff) AM_READWRITE(vtech1_keyboard_r, vtech1_latch_w) |
| 134 | 708 | AM_RANGE(0x7000, 0x77ff) AM_RAM AM_BASE(&videoram) AM_SIZE(&videoram_size) /* (6847) */ |
| 135 | | AM_RANGE(0x7800, 0x7fff) AM_RAMBANK(1) /* 2KB user ram */ |
| 709 | AM_RANGE(0x7800, 0x7fff) AM_RAMBANK(1) /* 2k user ram */ |
| 710 | AM_RANGE(0x8000, 0xbfff) AM_NOP /* 16k ram expansion */ |
| 711 | AM_RANGE(0xc000, 0xffff) AM_NOP |
| 136 | 712 | ADDRESS_MAP_END |
| 137 | 713 | |
| 138 | | static ADDRESS_MAP_START(laser210_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 714 | static ADDRESS_MAP_START( laser210_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 139 | 715 | AM_RANGE(0x0000, 0x3fff) AM_ROM /* basic rom */ |
| 140 | 716 | AM_RANGE(0x4000, 0x5fff) AM_ROM /* dos rom or other catridges */ |
| 141 | 717 | AM_RANGE(0x6000, 0x67ff) AM_ROM /* reserved for cartridges */ |
| 142 | 718 | AM_RANGE(0x6800, 0x6fff) AM_READWRITE(vtech1_keyboard_r, vtech1_latch_w) |
| 143 | 719 | AM_RANGE(0x7000, 0x77ff) AM_RAM AM_BASE(&videoram) AM_SIZE(&videoram_size) /* U7 (6847) */ |
| 144 | | AM_RANGE(0x7800, 0x8fff) AM_RAMBANK(1) /* 6KB user ram */ |
| 720 | AM_RANGE(0x7800, 0x8fff) AM_RAMBANK(1) /* 6k user ram */ |
| 721 | AM_RANGE(0x9000, 0xcfff) AM_NOP /* 16k ram expansion */ |
| 722 | AM_RANGE(0xd000, 0xffff) AM_NOP |
| 145 | 723 | ADDRESS_MAP_END |
| 146 | 724 | |
| 147 | | static ADDRESS_MAP_START(laser310_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 725 | static ADDRESS_MAP_START( laser310_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 148 | 726 | AM_RANGE(0x0000, 0x3fff) AM_ROM /* basic rom */ |
| 149 | 727 | AM_RANGE(0x4000, 0x5fff) AM_ROM /* dos rom or other catridges */ |
| 150 | 728 | AM_RANGE(0x6000, 0x67ff) AM_ROM /* reserved for cartridges */ |
| 151 | 729 | AM_RANGE(0x6800, 0x6fff) AM_READWRITE(vtech1_keyboard_r, vtech1_latch_w) |
| 152 | 730 | AM_RANGE(0x7000, 0x77ff) AM_RAM AM_BASE(&videoram) AM_SIZE(&videoram_size) /* (6847) */ |
| 153 | | AM_RANGE(0x7800, 0xb7ff) AM_RAMBANK(1) /* 16KB user ram */ |
| 731 | AM_RANGE(0x7800, 0xb7ff) AM_RAMBANK(1) /* 16k user ram */ |
| 732 | AM_RANGE(0xb800, 0xf7ff) AM_NOP /* 16k ram expansion */ |
| 733 | AM_RANGE(0xf8ff, 0xffff) AM_NOP |
| 154 | 734 | ADDRESS_MAP_END |
| 155 | 735 | |
| 156 | | static ADDRESS_MAP_START(vtech1_io, ADDRESS_SPACE_IO, 8) |
| 736 | static ADDRESS_MAP_START( vtech1_io, ADDRESS_SPACE_IO, 8 ) |
| 157 | 737 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 158 | | AM_RANGE(0x00, 0x00) AM_READ(vtech1_printer_r) |
| 159 | | AM_RANGE(0x0d, 0x0d) AM_WRITE(vtech1_strobe_w) |
| 738 | AM_RANGE(0x00, 0x00) AM_DEVREAD("centronics", vtech1_printer_r) |
| 739 | AM_RANGE(0x0d, 0x0d) AM_DEVWRITE("centronics", vtech1_strobe_w) |
| 160 | 740 | AM_RANGE(0x0e, 0x0e) AM_DEVWRITE("centronics", centronics_data_w) |
| 161 | 741 | AM_RANGE(0x10, 0x1f) AM_READWRITE(vtech1_fdc_r, vtech1_fdc_w) |
| 162 | 742 | AM_RANGE(0x20, 0x2f) AM_READ(vtech1_joystick_r) |
| 163 | 743 | AM_RANGE(0x30, 0x3f) AM_READWRITE(vtech1_serial_r, vtech1_serial_w) |
| 164 | 744 | AM_RANGE(0x40, 0x4f) AM_READ(vtech1_lightpen_r) |
| 165 | | AM_RANGE(0x50, 0x5f) AM_NOP /* Real time clock (proposed) */ |
| 166 | | AM_RANGE(0x60, 0x6f) AM_NOP /* External keyboard */ |
| 167 | 745 | AM_RANGE(0x70, 0x7f) AM_WRITE(vtech1_memory_bank_w) |
| 168 | | AM_RANGE(0x80, 0xff) AM_NOP |
| 169 | | // AM_RANGE(0xc9, 0xca) AM_NOP /* Eprom programmer */ |
| 170 | | // AM_RANGE(0xd8, 0xe7) AM_NOP /* Auto boot at 8000-9fff (proposed) */ |
| 171 | | // AM_RANGE(0xe8, 0xf7) AM_NOP /* RDOS at 6000-67ff (proposed) */ |
| 172 | | // AM_RANGE(0xf0, 0xf3) AM_NOP /* 24 bit I/O interface */ |
| 173 | | // AM_RANGE(0xf8, 0xff) AM_NOP /* RAM Disk at 4000-5fff (proposed) */ |
| 174 | | // AM_RANGE(0xe0, 0xff) AM_NOP /* D. Newcombes Rom Board */ |
| 175 | 746 | ADDRESS_MAP_END |
| 176 | 747 | |
| 177 | 748 | |
| 178 | | /****************************************************************************** |
| 179 | | Input Ports |
| 180 | | ******************************************************************************/ |
| 749 | /*************************************************************************** |
| 750 | INPUT PORTS |
| 751 | ***************************************************************************/ |
| 181 | 752 | |
| 182 | 753 | static INPUT_PORTS_START(vtech1) |
| 183 | 754 | PORT_START("keyboard_0") |
| r6100 | r6101 | |
| 289 | 860 | INPUT_PORTS_END |
| 290 | 861 | |
| 291 | 862 | |
| 292 | | /****************************************************************************** |
| 293 | | Audio Initialisation |
| 294 | | ******************************************************************************/ |
| 863 | /*************************************************************************** |
| 864 | PALETTE |
| 865 | ***************************************************************************/ |
| 295 | 866 | |
| 296 | | static const INT16 speaker_levels[] = {-32768, 0, 32767, 0}; |
| 297 | | |
| 298 | | static const speaker_interface vtech1_speaker_interface = |
| 299 | | { |
| 300 | | 4, |
| 301 | | speaker_levels |
| 302 | | }; |
| 303 | | |
| 304 | | |
| 305 | | /****************************************************************************** |
| 306 | | Machine Drivers |
| 307 | | ******************************************************************************/ |
| 308 | | |
| 309 | | static const cassette_config laser_cassette_config = |
| 310 | | { |
| 311 | | vtech1_cassette_formats, |
| 312 | | NULL, |
| 313 | | CASSETTE_PLAY |
| 314 | | }; |
| 315 | | |
| 316 | 867 | static const UINT32 vtech1_palette_mono[] = |
| 317 | 868 | { |
| 318 | 869 | MAKE_RGB(131, 131, 131), |
| r6100 | r6101 | |
| 333 | 884 | MAKE_RGB(193, 193, 193) |
| 334 | 885 | }; |
| 335 | 886 | |
| 887 | |
| 888 | /*************************************************************************** |
| 889 | MACHINE DRIVERS |
| 890 | ***************************************************************************/ |
| 891 | |
| 892 | static const INT16 speaker_levels[] = {-32768, 0, 32767, 0}; |
| 893 | |
| 894 | static const speaker_interface vtech1_speaker_interface = |
| 895 | { |
| 896 | 4, |
| 897 | speaker_levels |
| 898 | }; |
| 899 | |
| 900 | static const cassette_config laser_cassette_config = |
| 901 | { |
| 902 | vtech1_cassette_formats, |
| 903 | NULL, |
| 904 | CASSETTE_PLAY |
| 905 | }; |
| 906 | |
| 336 | 907 | static const mc6847_interface vtech1_mc6847_intf = |
| 337 | 908 | { |
| 338 | 909 | DEVCB_HANDLER(vtech1_mc6847_videoram_r), |
| r6100 | r6101 | |
| 349 | 920 | DEVCB_NULL, |
| 350 | 921 | }; |
| 351 | 922 | |
| 352 | | static MACHINE_DRIVER_START(laser110) |
| 923 | static MACHINE_DRIVER_START( laser110 ) |
| 924 | MDRV_DRIVER_DATA(vtech1_state) |
| 925 | |
| 353 | 926 | /* basic machine hardware */ |
| 354 | 927 | MDRV_CPU_ADD("maincpu", Z80, VTECH1_CLK) /* 3.57950 MHz */ |
| 355 | 928 | MDRV_CPU_PROGRAM_MAP(laser110_mem) |
| 356 | 929 | MDRV_CPU_IO_MAP(vtech1_io) |
| 357 | 930 | |
| 358 | | MDRV_MACHINE_START(laser110) |
| 359 | | |
| 360 | 931 | /* video hardware */ |
| 361 | 932 | MDRV_SCREEN_ADD("screen", RASTER) |
| 362 | 933 | MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND) |
| r6100 | r6101 | |
| 390 | 961 | /* cartridge */ |
| 391 | 962 | MDRV_CARTSLOT_ADD("cart") |
| 392 | 963 | MDRV_CARTSLOT_EXTENSION_LIST("rom") |
| 393 | | |
| 964 | |
| 394 | 965 | /* internal ram */ |
| 395 | 966 | MDRV_RAM_ADD("messram") |
| 396 | 967 | MDRV_RAM_DEFAULT_SIZE("66K") |
| 397 | 968 | MDRV_RAM_EXTRA_OPTIONS("2K,18K,4098K") |
| 398 | 969 | MACHINE_DRIVER_END |
| 399 | 970 | |
| 400 | | static MACHINE_DRIVER_START(laser200) |
| 971 | static MACHINE_DRIVER_START( laser200 ) |
| 401 | 972 | MDRV_IMPORT_FROM(laser110) |
| 402 | 973 | |
| 403 | 974 | MDRV_DEVICE_MODIFY("mc6847") |
| 404 | 975 | MDRV_MC6847_PALETTE(NULL) |
| 405 | 976 | MACHINE_DRIVER_END |
| 406 | 977 | |
| 407 | | static MACHINE_DRIVER_START(laser210) |
| 978 | static MACHINE_DRIVER_START( laser210 ) |
| 408 | 979 | MDRV_IMPORT_FROM(laser200) |
| 409 | 980 | MDRV_CPU_MODIFY("maincpu") |
| 410 | 981 | MDRV_CPU_PROGRAM_MAP(laser210_mem) |
| 411 | 982 | |
| 412 | | MDRV_MACHINE_START(laser210) |
| 413 | | |
| 414 | 983 | /* internal ram */ |
| 415 | 984 | MDRV_RAM_MODIFY("messram") |
| 416 | 985 | MDRV_RAM_DEFAULT_SIZE("66K") |
| 417 | | MDRV_RAM_EXTRA_OPTIONS("6K,22K,4098K") |
| 986 | MDRV_RAM_EXTRA_OPTIONS("6K,22K,4098K") |
| 418 | 987 | MACHINE_DRIVER_END |
| 419 | 988 | |
| 420 | | static MACHINE_DRIVER_START(laser310) |
| 421 | | MDRV_IMPORT_FROM( laser200 ) |
| 422 | | MDRV_CPU_REPLACE( "maincpu", Z80, VZ300_XTAL1_CLK/5) /* 3.546894 MHz */ |
| 989 | static MACHINE_DRIVER_START( laser310 ) |
| 990 | MDRV_IMPORT_FROM(laser200) |
| 991 | MDRV_CPU_REPLACE("maincpu", Z80, VZ300_XTAL1_CLK / 5) /* 3.546894 MHz */ |
| 423 | 992 | MDRV_CPU_PROGRAM_MAP(laser310_mem) |
| 424 | 993 | |
| 425 | | MDRV_MACHINE_START(laser310) |
| 426 | 994 | /* internal ram */ |
| 427 | 995 | MDRV_RAM_MODIFY("messram") |
| 428 | 996 | MDRV_RAM_DEFAULT_SIZE("66K") |
| 429 | 997 | MDRV_RAM_EXTRA_OPTIONS("16K,32K,4098K") |
| 430 | 998 | MACHINE_DRIVER_END |
| 431 | 999 | |
| 432 | | /****************************************************************************** |
| 433 | | ROM Definitions |
| 434 | | ******************************************************************************/ |
| 435 | 1000 | |
| 436 | | ROM_START(laser110) |
| 1001 | /*************************************************************************** |
| 1002 | ROM DEFINITIONS |
| 1003 | ***************************************************************************/ |
| 1004 | |
| 1005 | ROM_START( laser110 ) |
| 437 | 1006 | ROM_REGION(0x6800, "maincpu", 0) |
| 438 | 1007 | ROM_LOAD("vtechv12.u09", 0x0000, 0x2000, CRC(99412d43) SHA1(6aed8872a0818be8e1b08ecdfd92acbe57a3c96d)) |
| 439 | 1008 | ROM_LOAD("vtechv12.u10", 0x2000, 0x2000, CRC(e4c24e8b) SHA1(9d8fb3d24f3d4175b485cf081a2d5b98158ab2fb)) |
| r6100 | r6101 | |
| 442 | 1011 | |
| 443 | 1012 | /* The VZ-200 sold in Germany and the Netherlands came with BASIC V1.1, which |
| 444 | 1013 | is currently not dumped. */ |
| 445 | | ROM_START(vz200de) |
| 1014 | ROM_START( vz200de ) |
| 446 | 1015 | ROM_REGION(0x6800, "maincpu", 0) |
| 447 | 1016 | ROM_LOAD("vtechv11.u09", 0x0000, 0x2000, NO_DUMP) |
| 448 | 1017 | ROM_LOAD("vtechv11.u10", 0x2000, 0x2000, NO_DUMP) |
| r6100 | r6101 | |
| 457 | 1026 | needs to be verified */ |
| 458 | 1027 | #define rom_tx8000 rom_laser110 |
| 459 | 1028 | |
| 460 | | ROM_START(laser210) |
| 1029 | ROM_START( laser210 ) |
| 461 | 1030 | ROM_REGION(0x6800, "maincpu", 0) |
| 462 | 1031 | ROM_LOAD("vtechv20.u09", 0x0000, 0x2000, CRC(cc854fe9) SHA1(6e66a309b8e6dc4f5b0b44e1ba5f680467353d66)) |
| 463 | 1032 | ROM_LOAD("vtechv20.u10", 0x2000, 0x2000, CRC(7060f91a) SHA1(8f3c8f24f97ebb98f3c88d4e4ba1f91ffd563440)) |
| r6100 | r6101 | |
| 467 | 1036 | #define rom_las210de rom_laser210 |
| 468 | 1037 | #define rom_vz200 rom_laser210 |
| 469 | 1038 | |
| 470 | | ROM_START(laser310) |
| 1039 | ROM_START( laser310 ) |
| 471 | 1040 | ROM_REGION(0x6800, "maincpu", 0) |
| 472 | 1041 | ROM_SYSTEM_BIOS(0, "basic20", "BASIC V2.0") |
| 473 | 1042 | ROMX_LOAD("vtechv20.u12", 0x0000, 0x4000, CRC(613de12c) SHA1(f216c266bc09b0dbdbad720796e5ea9bc7d91e53), ROM_BIOS(1)) |
| r6100 | r6101 | |
| 479 | 1048 | #define rom_vz300 rom_laser310 |
| 480 | 1049 | |
| 481 | 1050 | |
| 482 | | /****************************************************************************** |
| 483 | | System Config |
| 484 | | ******************************************************************************/ |
| 1051 | /*************************************************************************** |
| 1052 | SYSTEM_CONFIG |
| 1053 | ***************************************************************************/ |
| 485 | 1054 | |
| 486 | | static Z80BIN_EXECUTE( vtech1 ) |
| 487 | | { |
| 488 | | const device_config *cpu = cputag_get_cpu(machine, "maincpu"); |
| 489 | | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 490 | | |
| 491 | | /* A Microsoft Basic program needs some manipulation before it can be run. |
| 492 | | 1. A start address of 7ae9 indicates a basic program which needs its pointers fixed up. |
| 493 | | 2. If autorun is turned off, the pointers still need fixing, but then display READY. |
| 494 | | Important addresses: |
| 495 | | 7ae9 = start (load) address of a conventional basic program |
| 496 | | 791e = custom routine to fix basic pointers */ |
| 497 | | |
| 498 | | memory_write_word_16le(space, 0x791c, end_address + 1); |
| 499 | | memory_write_word_16le(space, 0x781e, execute_address); |
| 500 | | |
| 501 | | if (start_address == 0x7ae9) |
| 502 | | { |
| 503 | | UINT8 i, data[]={ |
| 504 | | 0xe5, // PUSH HL ;save pcode pointer |
| 505 | | 0x2a, 0x1c, 0x79, // LD HL,(791C) ;get saved end_addr+1 |
| 506 | | 0x22, 0xf9, 0x78, // LD (78F9),HL ;move it to correct place |
| 507 | | 0x21, 0x39, 0x78, // LD HL,7839 ;point to control flag |
| 508 | | 0xcb, 0xf6, // SET 6,(HL) ;turn on autorun (cb b6 = manual run) |
| 509 | | 0xcb, 0x9e, // RES 3,(HL) ;turn off verify (just in case) |
| 510 | | 0xc3, 0xcf, 0x36,}; // JP 36CF ;enter bios at autorun point |
| 511 | | |
| 512 | | for (i = 0; i < ARRAY_LENGTH(data); i++) |
| 513 | | memory_write_byte(space, 0x791e + i, data[i]); |
| 514 | | |
| 515 | | if (!autorun) |
| 516 | | memory_write_byte(space, 0x7929, 0xb6); /* turn off autorun */ |
| 517 | | |
| 518 | | cpu_set_reg(cpu, REG_GENPC, 0x791e); |
| 519 | | } |
| 520 | | else |
| 521 | | { |
| 522 | | if (autorun) |
| 523 | | cpu_set_reg(cpu, REG_GENPC, execute_address); |
| 524 | | } |
| 525 | | } |
| 526 | | |
| 527 | | |
| 528 | 1055 | static void vtech1_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 529 | 1056 | { |
| 530 | | /* floppy */ |
| 531 | | switch(state) |
| 1057 | switch (state) |
| 532 | 1058 | { |
| 533 | 1059 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 534 | | case MESS_DEVINFO_INT_TYPE: info->i = IO_FLOPPY; break; |
| 535 | | case MESS_DEVINFO_INT_READABLE: info->i = 1; break; |
| 536 | | case MESS_DEVINFO_INT_WRITEABLE: info->i = 1; break; |
| 537 | | case MESS_DEVINFO_INT_CREATABLE: info->i = 1; break; |
| 538 | | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 1060 | case MESS_DEVINFO_INT_TYPE: info->i = IO_FLOPPY; break; |
| 1061 | case MESS_DEVINFO_INT_READABLE: info->i = 1; break; |
| 1062 | case MESS_DEVINFO_INT_WRITEABLE: info->i = 1; break; |
| 1063 | case MESS_DEVINFO_INT_CREATABLE: info->i = 1; break; |
| 1064 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 539 | 1065 | |
| 540 | 1066 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 541 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(vtech1_floppy); break; |
| 1067 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(vtech1_floppy); break; |
| 542 | 1068 | |
| 543 | 1069 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 544 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break; |
| 1070 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break; |
| 545 | 1071 | } |
| 546 | 1072 | } |
| 547 | 1073 | |
| 548 | | /* Memory expansions available for the Laser/VZ computers: |
| 549 | | |
| 550 | | - a 16kb expansion without banking |
| 551 | | - a 64kb expansion where the first bank is fixed and the other 3 are |
| 552 | | banked in as needed |
| 553 | | - a banked memory expansion similar to the 64kb one, that the user could |
| 554 | | fill themselves with memory up to 4MB total. |
| 555 | | |
| 556 | | They are externally connected devices. The 16kb extension is different |
| 557 | | between Laser 110/210/310 computers, though it could be relativly |
| 558 | | easily modified to work on another model. */ |
| 559 | | |
| 560 | | static SYSTEM_CONFIG_START(vtech1) |
| 1074 | static SYSTEM_CONFIG_START( vtech1 ) |
| 561 | 1075 | CONFIG_DEVICE(vtech1_floppy_getinfo) |
| 562 | 1076 | SYSTEM_CONFIG_END |
| 563 | 1077 | |
| 564 | 1078 | |
| 565 | | /****************************************************************************** |
| 566 | | Drivers |
| 567 | | ******************************************************************************/ |
| 1079 | /*************************************************************************** |
| 1080 | GAME DRIVERS |
| 1081 | ***************************************************************************/ |
| 568 | 1082 | |
| 569 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 570 | | COMP( 1983, laser110, 0, 0, laser110, vtech1, 0, vtech1, "Video Technology", "Laser 110", 0 ) |
| 571 | | COMP( 1983, las110de, laser110, 0, laser110, vtech1, 0, vtech1, "Sanyo", "Laser 110 (Germany)", 0 ) |
| 572 | | |
| 573 | | COMP( 1983, laser200, 0, 0, laser200, vtech1, 0, vtech1, "Video Technology", "Laser 200", 0 ) |
| 574 | | COMP( 1983, vz200de, laser200, 0, laser200, vtech1, 0, vtech1, "Video Technology", "VZ-200 (Germany & Netherlands)", GAME_NOT_WORKING ) |
| 575 | | COMP( 1983, fellow, laser200, 0, laser200, vtech1, 0, vtech1, "Salora", "Fellow (Finland)", 0 ) |
| 576 | | COMP( 1983, tx8000, laser200, 0, laser200, vtech1, 0, vtech1, "Texet", "TX-8000 (UK)", 0 ) |
| 577 | | |
| 578 | | COMP( 1984, laser210, 0, 0, laser210, vtech1, 0, vtech1, "Video Technology", "Laser 210", 0 ) |
| 579 | | COMP( 1984, vz200, laser210, 0, laser210, vtech1, 0, vtech1, "Dick Smith Electronics", "VZ-200 (Oceania)", 0 ) |
| 580 | | COMP( 1984, las210de, laser210, 0, laser210, vtech1, 0, vtech1, "Sanyo", "Laser 210 (Germany)", 0 ) |
| 581 | | |
| 582 | | COMP( 1984, laser310, 0, 0, laser310, vtech1, 0, vtech1, "Video Technology", "Laser 310", 0 ) |
| 583 | | COMP( 1984, vz300, laser310, 0, laser310, vtech1, 0, vtech1, "Dick Smith Electronics", "VZ-300 (Oceania)", 0 ) |
| 1083 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 1084 | COMP( 1983, laser110, 0, 0, laser110, vtech1, vtech1, vtech1, "Video Technology", "Laser 110", 0 ) |
| 1085 | COMP( 1983, las110de, laser110, 0, laser110, vtech1, vtech1, vtech1, "Sanyo", "Laser 110 (Germany)", 0 ) |
| 1086 | COMP( 1983, laser200, 0, 0, laser200, vtech1, vtech1, vtech1, "Video Technology", "Laser 200", 0 ) |
| 1087 | COMP( 1983, vz200de, laser200, 0, laser200, vtech1, vtech1, vtech1, "Video Technology", "VZ-200 (Germany & Netherlands)", 0 ) |
| 1088 | COMP( 1983, fellow, laser200, 0, laser200, vtech1, vtech1, vtech1, "Salora", "Fellow (Finland)", 0 ) |
| 1089 | COMP( 1983, tx8000, laser200, 0, laser200, vtech1, vtech1, vtech1, "Texet", "TX-8000 (UK)", 0 ) |
| 1090 | COMP( 1984, laser210, 0, 0, laser210, vtech1, vtech1, vtech1, "Video Technology", "Laser 210", 0 ) |
| 1091 | COMP( 1984, vz200, laser210, 0, laser210, vtech1, vtech1, vtech1, "Dick Smith Electronics", "VZ-200 (Oceania)", 0 ) |
| 1092 | COMP( 1984, las210de, laser210, 0, laser210, vtech1, vtech1, vtech1, "Sanyo", "Laser 210 (Germany)", 0 ) |
| 1093 | COMP( 1984, laser310, 0, 0, laser310, vtech1, vtech1, vtech1, "Video Technology", "Laser 310", 0 ) |
| 1094 | COMP( 1984, vz300, laser310, 0, laser310, vtech1, vtech1, vtech1, "Dick Smith Electronics", "VZ-300 (Oceania)", 0 ) |