src/mess/devices/z80bin.c
| r2442 | r2443 | |
| 22 | 22 | ***************************************************************************/ |
| 23 | 23 | |
| 24 | 24 | /*------------------------------------------------- |
| 25 | | z80bin_load_file - this is a public function |
| 26 | | that really should be static |
| 25 | z80bin_load_file - load a z80bin file into |
| 26 | memory |
| 27 | 27 | -------------------------------------------------*/ |
| 28 | 28 | |
| 29 | | int z80bin_load_file(const device_config *image, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr ) |
| 29 | static int z80bin_load_file(const device_config *image, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr ) |
| 30 | 30 | { |
| 31 | 31 | int ch; |
| 32 | 32 | UINT16 args[3]; |
| r2442 | r2443 | |
| 98 | 98 | |
| 99 | 99 | static QUICKLOAD_LOAD( z80bin ) |
| 100 | 100 | { |
| 101 | const z80bin_config *config; |
| 101 | 102 | UINT16 exec_addr, start_addr, end_addr; |
| 103 | int autorun; |
| 102 | 104 | |
| 103 | | if (z80bin_load_file( image, file_type, &exec_addr, &start_addr, &end_addr ) == INIT_FAIL) |
| 105 | /* load the binary into memory */ |
| 106 | if (z80bin_load_file(image, file_type, &exec_addr, &start_addr, &end_addr) == INIT_FAIL) |
| 104 | 107 | return INIT_FAIL; |
| 105 | 108 | |
| 106 | | if (exec_addr != 0xffff) /* non-executable data file */ |
| 107 | | cpunum_set_reg(0, REG_PC, exec_addr); /* start program */ |
| 109 | /* is this file executable? */ |
| 110 | if (exec_addr != 0xffff) |
| 111 | { |
| 112 | config = (const z80bin_config *) image->inline_config; |
| 108 | 113 | |
| 114 | /* check to see if autorun is on (I hate how this works) */ |
| 115 | autorun = input_port_read_safe(image->machine, "CONFIG", 0xFF) & 1; |
| 116 | |
| 117 | /* start program */ |
| 118 | if (config->execute != NULL) |
| 119 | { |
| 120 | (*config->execute)(start_addr, end_addr, exec_addr, autorun); |
| 121 | } |
| 122 | else |
| 123 | { |
| 124 | if (autorun) |
| 125 | cpunum_set_reg(0, REG_PC, exec_addr); |
| 126 | } |
| 127 | } |
| 128 | |
| 109 | 129 | return INIT_PASS; |
| 110 | 130 | } |
| 111 | 131 | |
| r2442 | r2443 | |
| 120 | 140 | /* quickload */ |
| 121 | 141 | switch(state) |
| 122 | 142 | { |
| 143 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 144 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(z80bin_config); break; |
| 145 | |
| 123 | 146 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 124 | 147 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 125 | 148 | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: info->s = "bin"; break; |
src/mess/devices/z80bin.h
| r2442 | r2443 | |
| 11 | 11 | #define __Z80BIN_H__ |
| 12 | 12 | |
| 13 | 13 | #include "image.h" |
| 14 | #include "snapquik.h" |
| 14 | 15 | |
| 15 | 16 | |
| 16 | 17 | /*************************************************************************** |
| r2442 | r2443 | |
| 19 | 20 | |
| 20 | 21 | #define Z80BIN DEVICE_GET_INFO_NAME(z80bin) |
| 21 | 22 | |
| 23 | #define Z80BIN_EXECUTE_NAME(name) z80bin_execute_##name |
| 24 | #define Z80BIN_EXECUTE(name) void Z80BIN_EXECUTE_NAME(name)(UINT16 start_address, UINT16 end_address, UINT16 execute_address, int autorun) |
| 22 | 25 | |
| 26 | #define z80bin_execute_default NULL |
| 23 | 27 | |
| 28 | |
| 29 | |
| 24 | 30 | /*************************************************************************** |
| 25 | 31 | TYPE DEFINITIONS |
| 26 | 32 | ***************************************************************************/ |
| 27 | 33 | |
| 34 | typedef void (*z80bin_execute_func)(UINT16 start_address, UINT16 end_address, UINT16 execute_address, int autorun); |
| 35 | |
| 36 | typedef struct _z80bin_config z80bin_config; |
| 37 | struct _z80bin_config |
| 38 | { |
| 39 | snapquick_config base; |
| 40 | z80bin_execute_func execute; |
| 41 | }; |
| 42 | |
| 43 | |
| 44 | |
| 45 | /*************************************************************************** |
| 46 | Z80BIN QUICKLOAD DEVICE CONFIGURATION MACROS |
| 47 | ***************************************************************************/ |
| 48 | |
| 49 | #define MDRV_Z80BIN_QUICKLOAD_ADD(_execute, _delay) \ |
| 50 | MDRV_DEVICE_ADD(TAG_QUICKLOAD, Z80BIN) \ |
| 51 | MDRV_DEVICE_CONFIG_DATA64(snapquick_config, delay_seconds, (seconds_t) (_delay)) \ |
| 52 | MDRV_DEVICE_CONFIG_DATA64(snapquick_config, delay_attoseconds, (attoseconds_t) (((_delay) - (int)(_delay)) * ATTOSECONDS_PER_SECOND)) \ |
| 53 | MDRV_DEVICE_CONFIG_DATAPTR(z80bin_config, execute, Z80BIN_EXECUTE_NAME(_execute)) |
| 54 | |
| 55 | |
| 56 | |
| 57 | /*************************************************************************** |
| 58 | TYPE DEFINITIONS |
| 59 | ***************************************************************************/ |
| 60 | |
| 28 | 61 | /* device getinfo function */ |
| 29 | 62 | DEVICE_GET_INFO(z80bin); |
| 30 | 63 | |
| 31 | | /* please stop using this method - z80bin needs to be encapsulated into a proper device */ |
| 32 | | int z80bin_load_file(const device_config *image, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr ); |
| 33 | 64 | |
| 34 | 65 | |
| 35 | 66 | #endif /* __Z80BIN_H__ */ |
src/mess/drivers/mbee.c
| r2442 | r2443 | |
| 58 | 58 | #include "devices/z80bin.h" |
| 59 | 59 | |
| 60 | 60 | static SNAPSHOT_LOAD( mbee ); |
| 61 | | static QUICKLOAD_LOAD( mbee ); |
| 61 | static Z80BIN_EXECUTE( mbee ); |
| 62 | 62 | |
| 63 | 63 | static size_t mbee_size; |
| 64 | 64 | |
| r2442 | r2443 | |
| 313 | 313 | |
| 314 | 314 | /* devices */ |
| 315 | 315 | MDRV_SNAPSHOT_ADD(mbee, "mwb", 0.5) |
| 316 | | MDRV_QUICKLOAD_ADD(mbee, "bin", 0) |
| 316 | MDRV_Z80BIN_QUICKLOAD_ADD(mbee, 0) |
| 317 | 317 | MACHINE_DRIVER_END |
| 318 | 318 | |
| 319 | 319 | |
| r2442 | r2443 | |
| 350 | 350 | |
| 351 | 351 | /* devices */ |
| 352 | 352 | MDRV_SNAPSHOT_ADD(mbee, "mwb", 0.5) |
| 353 | | MDRV_QUICKLOAD_ADD(mbee, "bin", 0) |
| 353 | MDRV_Z80BIN_QUICKLOAD_ADD(mbee, 0) |
| 354 | 354 | MACHINE_DRIVER_END |
| 355 | 355 | |
| 356 | 356 | |
| r2442 | r2443 | |
| 447 | 447 | |
| 448 | 448 | ***************************************************************************/ |
| 449 | 449 | |
| 450 | | static QUICKLOAD_LOAD( mbee ) |
| 450 | static Z80BIN_EXECUTE( mbee ) |
| 451 | 451 | { |
| 452 | | UINT8 sw = input_port_read(image->machine, "CONFIG") & 1; /* reading the dipswitch: 1 = autorun */ |
| 453 | | UINT16 exec_addr, start_addr, end_addr; |
| 452 | program_write_word_16le(0xa6, execute_address); /* fix the EXEC command */ |
| 454 | 453 | |
| 455 | | if (z80bin_load_file(image, file_type, &exec_addr, &start_addr, &end_addr ) == INIT_FAIL) |
| 456 | | return INIT_FAIL; |
| 457 | | |
| 458 | | if (exec_addr == 0xffff) return INIT_PASS; /* data file */ |
| 459 | | |
| 460 | | program_write_word_16le(0xa6,exec_addr); /* fix the EXEC command */ |
| 461 | | |
| 462 | | if (sw) |
| 454 | if (autorun) |
| 463 | 455 | { |
| 464 | | program_write_word_16le(0xa2,exec_addr); /* fix warm-start vector to get around some copy-protections */ |
| 465 | | cpunum_set_reg(0, REG_PC, exec_addr); |
| 456 | program_write_word_16le(0xa2, execute_address); /* fix warm-start vector to get around some copy-protections */ |
| 457 | cpunum_set_reg(0, REG_PC, execute_address); |
| 466 | 458 | } |
| 467 | 459 | else |
| 468 | | program_write_word_16le(0xa2,0x8517); |
| 469 | | |
| 470 | | return INIT_PASS; |
| 460 | { |
| 461 | program_write_word_16le(0xa2, 0x8517); |
| 462 | } |
| 471 | 463 | } |
| 472 | 464 | |
| 473 | 465 | static SNAPSHOT_LOAD( mbee ) |
src/mess/drivers/super80.c
| r2442 | r2443 | |
| 10 | 10 | #include "sound/speaker.h" |
| 11 | 11 | #include "deprecat.h" /* "Machine" needed for z80pio interrupt */ |
| 12 | 12 | |
| 13 | | static QUICKLOAD_LOAD( super80 ); |
| 14 | | |
| 15 | 13 | static UINT8 super80_mhz=2; /* state of bit 2 of port F0 */ |
| 16 | 14 | static UINT16 vidpg=0xfe00; /* Home position of video page being displayed */ |
| 17 | 15 | static UINT8 int_sw; /* internal 1 mhz flipflop */ |
| r2442 | r2443 | |
| 818 | 816 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 819 | 817 | |
| 820 | 818 | /* quickload */ |
| 821 | | MDRV_QUICKLOAD_ADD(super80, "bin", 0) |
| 819 | MDRV_Z80BIN_QUICKLOAD_ADD(default, 0) |
| 822 | 820 | MACHINE_DRIVER_END |
| 823 | 821 | |
| 824 | 822 | static MACHINE_DRIVER_START( super80d ) |
| r2442 | r2443 | |
| 867 | 865 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 868 | 866 | |
| 869 | 867 | /* quickload */ |
| 870 | | MDRV_QUICKLOAD_ADD(super80, "bin", 0) |
| 868 | MDRV_Z80BIN_QUICKLOAD_ADD(default, 0) |
| 871 | 869 | MACHINE_DRIVER_END |
| 872 | 870 | |
| 873 | 871 | static void driver_init_common( void ) |
| r2442 | r2443 | |
| 957 | 955 | |
| 958 | 956 | /**************************** DEVICES *****************************************************************/ |
| 959 | 957 | |
| 960 | | static QUICKLOAD_LOAD( super80 ) |
| 961 | | { |
| 962 | | UINT8 sw = input_port_read(image->machine, "CONFIG") & 1; /* reading the dipswitch: 1 = autorun */ |
| 963 | | UINT16 exec_addr, start_addr, end_addr; |
| 964 | | |
| 965 | | if (z80bin_load_file(image, file_type, &exec_addr, &start_addr, &end_addr ) == INIT_FAIL) |
| 966 | | return INIT_FAIL; |
| 967 | | |
| 968 | | if ((exec_addr != 0xffff) && (sw)) |
| 969 | | cpunum_set_reg(0, REG_PC, exec_addr); |
| 970 | | |
| 971 | | return INIT_PASS; |
| 972 | | } |
| 973 | | |
| 974 | 958 | static DEVICE_IMAGE_LOAD( super80_cart ) |
| 975 | 959 | { |
| 976 | 960 | /* int size = mame_fsize(fp); |
src/mess/drivers/exidy.c
| r2442 | r2443 | |
| 96 | 96 | #include "sound/speaker.h" |
| 97 | 97 | |
| 98 | 98 | |
| 99 | | static QUICKLOAD_LOAD( exidy ); |
| 99 | static Z80BIN_EXECUTE( exidy ); |
| 100 | 100 | |
| 101 | 101 | static DEVICE_IMAGE_LOAD( exidy_floppy ) |
| 102 | 102 | { |
| r2442 | r2443 | |
| 755 | 755 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 756 | 756 | |
| 757 | 757 | /* quickload */ |
| 758 | | MDRV_QUICKLOAD_ADD(exidy, "bin", 0) |
| 758 | MDRV_Z80BIN_QUICKLOAD_ADD(exidy, 0) |
| 759 | 759 | MACHINE_DRIVER_END |
| 760 | 760 | |
| 761 | 761 | static MACHINE_DRIVER_START( exidyd ) |
| r2442 | r2443 | |
| 804 | 804 | ROM_LOAD_OPTIONAL("bruce.dat", 0x0000, 0x0020, CRC(fae922cb) SHA1(470a86844cfeab0d9282242e03ff1d8a1b2238d1)) /* video prom */ |
| 805 | 805 | ROM_END |
| 806 | 806 | |
| 807 | | static QUICKLOAD_LOAD( exidy ) |
| 807 | static Z80BIN_EXECUTE( exidy ) |
| 808 | 808 | { |
| 809 | | UINT8 sw = input_port_read(image->machine, "CONFIG") & 1; /* reading the dipswitch: 1 = autorun */ |
| 810 | | UINT16 exec_addr, start_addr, end_addr; |
| 809 | if ((execute_address >= 0xc000) && (execute_address <= 0xdfff) && (program_read_byte(0xdffa) != 0xc3)) |
| 810 | return; /* can't run a program if the cartridge isn't in */ |
| 811 | 811 | |
| 812 | | if (z80bin_load_file(image, file_type, &exec_addr, &start_addr, &end_addr ) == INIT_FAIL) |
| 813 | | return INIT_FAIL; |
| 814 | | |
| 815 | | if (exec_addr == 0xffff) return INIT_PASS; /* data file */ |
| 816 | | |
| 817 | | if ((exec_addr >= 0xc000) && (exec_addr <= 0xdfff) && (program_read_byte(0xdffa) != 0xc3)) |
| 818 | | return INIT_PASS; /* can't run a program if the cartridge isn't in */ |
| 819 | | |
| 820 | 812 | /* Since Exidy Basic is by Microsoft, it needs some preprocessing before it can be run. |
| 821 | 813 | 1. A start address of 01D5 indicates a basic program which needs its pointers fixed up. |
| 822 | 814 | 2. If autorunning, jump to C689 (command processor), else jump to C3DD (READY prompt). |
| r2442 | r2443 | |
| 825 | 817 | C858 = an autorun basic program will have this exec address on the tape |
| 826 | 818 | C3DD = part of basic that displays READY and lets user enter input */ |
| 827 | 819 | |
| 828 | | if ((start_addr == 0x1d5) || (exec_addr == 0xc858)) |
| 820 | if ((start_address == 0x1d5) || (execute_address == 0xc858)) |
| 829 | 821 | { |
| 830 | 822 | UINT8 i, data[]={ |
| 831 | 823 | 0xcd, 0x26, 0xc4, // CALL C426 ;set up other pointers |
| r2442 | r2443 | |
| 833 | 825 | 0x36, 0, // LD (HL),00 ;make sure dummy end-of-line is there |
| 834 | 826 | 0xc3, 0x89, 0xc6,}; // JP C689 ;run program |
| 835 | 827 | |
| 836 | | for (i = 0; i < 11; i++) program_write_byte(0xf01f + i, data[i]); |
| 837 | | if (!sw) program_write_word_16le(0xf028,0xc3dd); |
| 838 | | program_write_byte(0x1b7, end_addr&0xff); /* Tell BASIC where program ends */ |
| 839 | | program_write_byte(0x1b8, end_addr>>8); |
| 840 | | if ((exec_addr != 0xc858) && (sw)) program_write_word_16le(0xf028,exec_addr); |
| 828 | for (i = 0; i < ARRAY_LENGTH(data); i++) |
| 829 | program_write_byte(0xf01f + i, data[i]); |
| 830 | |
| 831 | if (!autorun) |
| 832 | program_write_word_16le(0xf028,0xc3dd); |
| 833 | |
| 834 | /* tell BASIC where program ends */ |
| 835 | program_write_byte(0x1b7, (end_address >> 0) & 0xff); |
| 836 | program_write_byte(0x1b8, (end_address >> 8) & 0xff); |
| 837 | |
| 838 | if ((execute_address != 0xc858) && autorun) |
| 839 | program_write_word_16le(0xf028, execute_address); |
| 840 | |
| 841 | 841 | cpunum_set_reg(0, REG_PC, 0xf01f); |
| 842 | 842 | } |
| 843 | 843 | else |
| 844 | | if (sw) cpunum_set_reg(0, REG_PC, exec_addr); |
| 845 | | |
| 846 | | return INIT_PASS; |
| 844 | { |
| 845 | if (autorun) |
| 846 | cpunum_set_reg(0, REG_PC, execute_address); |
| 847 | } |
| 847 | 848 | } |
| 848 | 849 | |
| 849 | 850 | static void exidy_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
src/mess/drivers/vtech1.c
| r2442 | r2443 | |
| 115 | 115 | #include "formats/vt_cas.h" |
| 116 | 116 | |
| 117 | 117 | |
| 118 | | static QUICKLOAD_LOAD(vtech1); |
| 118 | static Z80BIN_EXECUTE(vtech1); |
| 119 | 119 | |
| 120 | 120 | /****************************************************************************** |
| 121 | 121 | Address Maps |
| r2442 | r2443 | |
| 332 | 332 | |
| 333 | 333 | /* snapshot/quickload */ |
| 334 | 334 | MDRV_SNAPSHOT_ADD(vtech1, "vz", 0.5) |
| 335 | | MDRV_QUICKLOAD_ADD(vtech1, "bin", 0) |
| 335 | MDRV_Z80BIN_QUICKLOAD_ADD(vtech1, 0) |
| 336 | 336 | MACHINE_DRIVER_END |
| 337 | 337 | |
| 338 | 338 | static MACHINE_DRIVER_START(laser200) |
| r2442 | r2443 | |
| 412 | 412 | System Config |
| 413 | 413 | ******************************************************************************/ |
| 414 | 414 | |
| 415 | | static QUICKLOAD_LOAD( vtech1 ) |
| 415 | static Z80BIN_EXECUTE( vtech1 ) |
| 416 | 416 | { |
| 417 | | UINT8 sw = input_port_read(image->machine, "CONFIG") & 1; /* reading the dipswitch: 1 = autorun */ |
| 418 | | UINT16 exec_addr, start_addr, end_addr; |
| 419 | | |
| 420 | | if (z80bin_load_file(image, file_type, &exec_addr, &start_addr, &end_addr ) == INIT_FAIL) |
| 421 | | return INIT_FAIL; |
| 422 | | |
| 423 | 417 | /* A Microsoft Basic program needs some manipulation before it can be run. |
| 424 | 418 | 1. A start address of 7ae9 indicates a basic program which needs its pointers fixed up. |
| 425 | 419 | 2. If autorun is turned off, the pointers still need fixing, but then display READY. |
| r2442 | r2443 | |
| 428 | 422 | 7ae9 = start (load) address of a conventional basic program |
| 429 | 423 | 791e = custom routine to fix basic pointers */ |
| 430 | 424 | |
| 431 | | program_write_word_16le(0x791c,end_addr+1); |
| 432 | | program_write_word_16le(0x781e,exec_addr); |
| 425 | program_write_word_16le(0x791c, end_address + 1); |
| 426 | program_write_word_16le(0x781e, execute_address); |
| 433 | 427 | |
| 434 | | if (start_addr == 0x7ae9) |
| 428 | if (start_address == 0x7ae9) |
| 435 | 429 | { |
| 436 | | UINT8 i, data[17]={ |
| 430 | UINT8 i, data[]={ |
| 437 | 431 | 0xe5, // PUSH HL ;save pcode pointer |
| 438 | 432 | 0x2a, 0x1c, 0x79, // LD HL,(791C) ;get saved end_addr+1 |
| 439 | 433 | 0x22, 0xf9, 0x78, // LD (78F9),HL ;move it to correct place |
| r2442 | r2443 | |
| 442 | 436 | 0xcb, 0x9e, // RES 3,(HL) ;turn off verify (just in case) |
| 443 | 437 | 0xc3, 0xcf, 0x36,}; // JP 36CF ;enter bios at autorun point |
| 444 | 438 | |
| 445 | | for (i = 0; i < 17; i++) program_write_byte(0x791e + i, data[i]); |
| 446 | | if (!sw) program_write_byte(0x7929, 0xb6); /* turn off autorun */ |
| 439 | for (i = 0; i < ARRAY_LENGTH(data); i++) |
| 440 | program_write_byte(0x791e + i, data[i]); |
| 441 | |
| 442 | if (!autorun) |
| 443 | program_write_byte(0x7929, 0xb6); /* turn off autorun */ |
| 444 | |
| 447 | 445 | cpunum_set_reg(0, REG_PC, 0x791e); |
| 448 | 446 | } |
| 449 | 447 | else |
| 450 | | if ((exec_addr != 0xffff) && (sw)) cpunum_set_reg(0, REG_PC, exec_addr); |
| 451 | | |
| 452 | | return INIT_PASS; |
| 448 | { |
| 449 | if (autorun) |
| 450 | cpunum_set_reg(0, REG_PC, execute_address); |
| 451 | } |
| 453 | 452 | } |
| 454 | 453 | |
| 455 | 454 | static void vtech1_cassette_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |