src/mess/drivers/pipbug.c
| r15281 | r15282 | |
| 28 | 28 | The Baby 2650 (featured in Electronics Australia magazine in |
| 29 | 29 | March 1977) has 256 bytes of RAM. |
| 30 | 30 | |
| 31 | The terminal is expected to have a papertape device attached, and |
| 32 | use it to save and load programs. PIPBUG still thinks it is talking |
| 33 | to the terminal, when in fact the data is flowing to the papertape |
| 34 | reader and punch. |
| 31 | 35 | |
| 32 | 36 | ****************************************************************************/ |
| 33 | 37 | |
| 34 | 38 | #include "emu.h" |
| 35 | 39 | #include "cpu/s2650/s2650.h" |
| 36 | 40 | #include "machine/terminal.h" |
| 41 | #include "imagedev/snapquik.h" |
| 37 | 42 | |
| 38 | 43 | |
| 39 | 44 | class pipbug_state : public driver_device |
| r15281 | r15282 | |
| 85 | 90 | DEVCB_NULL |
| 86 | 91 | }; |
| 87 | 92 | |
| 93 | QUICKLOAD_LOAD( pipbug ) |
| 94 | { |
| 95 | address_space *space = image.device().machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 96 | int i; |
| 97 | int quick_addr = 0x0440; |
| 98 | int exec_addr; |
| 99 | int quick_length; |
| 100 | UINT8 *quick_data; |
| 101 | int read_; |
| 102 | |
| 103 | quick_length = image.length(); |
| 104 | quick_data = (UINT8*)malloc(quick_length); |
| 105 | if (!quick_data) |
| 106 | { |
| 107 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 108 | image.message(" Cannot open file"); |
| 109 | return IMAGE_INIT_FAIL; |
| 110 | } |
| 111 | |
| 112 | read_ = image.fread( quick_data, quick_length); |
| 113 | if (read_ != quick_length) |
| 114 | { |
| 115 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 116 | image.message(" Cannot read the file"); |
| 117 | return IMAGE_INIT_FAIL; |
| 118 | } |
| 119 | |
| 120 | if (quick_data[0] != 0xc4) |
| 121 | { |
| 122 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 123 | image.message(" Invalid header"); |
| 124 | return IMAGE_INIT_FAIL; |
| 125 | } |
| 126 | |
| 127 | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 128 | |
| 129 | if (exec_addr >= quick_length) |
| 130 | { |
| 131 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 132 | image.message(" Exec address beyond end of file"); |
| 133 | return IMAGE_INIT_FAIL; |
| 134 | } |
| 135 | |
| 136 | if (quick_length < 0x444) |
| 137 | { |
| 138 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 139 | image.message(" File too short"); |
| 140 | return IMAGE_INIT_FAIL; |
| 141 | } |
| 142 | |
| 143 | if (quick_length > 0x8000) |
| 144 | { |
| 145 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 146 | image.message(" File too long"); |
| 147 | return IMAGE_INIT_FAIL; |
| 148 | } |
| 149 | |
| 150 | for (i = quick_addr; i < quick_length; i++) |
| 151 | { |
| 152 | space->write_byte(i, quick_data[i]); |
| 153 | } |
| 154 | |
| 155 | /* display a message about the loaded quickload */ |
| 156 | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 157 | |
| 158 | // Start the quickload |
| 159 | cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, exec_addr); |
| 160 | return IMAGE_INIT_PASS; |
| 161 | } |
| 162 | |
| 88 | 163 | static MACHINE_CONFIG_START( pipbug, pipbug_state ) |
| 89 | 164 | /* basic machine hardware */ |
| 90 | 165 | MCFG_CPU_ADD("maincpu",S2650, XTAL_1MHz) |
| r15281 | r15282 | |
| 93 | 168 | |
| 94 | 169 | /* video hardware */ |
| 95 | 170 | MCFG_SERIAL_TERMINAL_ADD(TERMINAL_TAG, terminal_intf, 110) |
| 171 | |
| 172 | /* quickload */ |
| 173 | MCFG_QUICKLOAD_ADD("quickload", pipbug, "pgm", 0) |
| 96 | 174 | MACHINE_CONFIG_END |
| 97 | 175 | |
| 176 | |
| 98 | 177 | /* ROM definition */ |
| 99 | 178 | ROM_START( pipbug ) |
| 100 | 179 | ROM_REGION( 0x8000, "maincpu", ROMREGION_ERASEFF ) |