src/mess/drivers/instruct.c
| r15285 | r15286 | |
| 41 | 41 | not in the matrix, but are connected to hardware directly. This needs |
| 42 | 42 | to be emulated. |
| 43 | 43 | - Connect 10 toggle switches and 10 round red leds. |
| 44 | | - Cassette interface. |
| 44 | - Cassette interface not working. |
| 45 | 45 | |
| 46 | 46 | ****************************************************************************/ |
| 47 | 47 | |
| 48 | 48 | #include "emu.h" |
| 49 | 49 | #include "cpu/s2650/s2650.h" |
| 50 | #include "imagedev/snapquik.h" |
| 51 | #include "imagedev/cassette.h" |
| 52 | #include "sound/wave.h" |
| 50 | 53 | #include "instruct.lh" |
| 51 | 54 | |
| 52 | 55 | class instruct_state : public driver_device |
| r15285 | r15286 | |
| 55 | 58 | instruct_state(const machine_config &mconfig, device_type type, const char *tag) |
| 56 | 59 | : driver_device(mconfig, type, tag), |
| 57 | 60 | m_maincpu(*this, "maincpu"), |
| 58 | | m_p_ram(*this, "p_ram") |
| 61 | m_p_ram(*this, "p_ram"), |
| 62 | m_cass(*this, CASSETTE_TAG) |
| 59 | 63 | { } |
| 60 | 64 | |
| 61 | | required_device<cpu_device> m_maincpu; |
| 62 | 65 | DECLARE_READ8_MEMBER(portfc_r); |
| 63 | 66 | DECLARE_READ8_MEMBER(portfd_r); |
| 64 | 67 | DECLARE_READ8_MEMBER(portfe_r); |
| r15285 | r15286 | |
| 67 | 70 | DECLARE_WRITE8_MEMBER(portf9_w); |
| 68 | 71 | DECLARE_WRITE8_MEMBER(portfa_w); |
| 69 | 72 | virtual void machine_reset(); |
| 70 | | required_shared_ptr<UINT8> m_p_ram; |
| 71 | 73 | UINT8 m_digit; |
| 72 | 74 | bool m_valid_digit; |
| 75 | required_device<cpu_device> m_maincpu; |
| 76 | required_shared_ptr<UINT8> m_p_ram; |
| 77 | required_device<cassette_image_device> m_cass; |
| 73 | 78 | }; |
| 74 | 79 | |
| 75 | 80 | // cassette port |
| r15285 | r15286 | |
| 77 | 82 | // saving can use bits 3,4,5 |
| 78 | 83 | WRITE8_MEMBER( instruct_state::portf8_w ) |
| 79 | 84 | { |
| 85 | m_cass->output(BIT(data, 3) ? -1.0 : +1.0); |
| 80 | 86 | } |
| 81 | 87 | |
| 82 | 88 | // segment output |
| r15285 | r15286 | |
| 124 | 130 | return 0xff; |
| 125 | 131 | } |
| 126 | 132 | |
| 127 | | // read SENS key and cassin |
| 133 | |
| 134 | // Read cassette and SENS key |
| 128 | 135 | READ8_MEMBER( instruct_state::sense_r ) |
| 129 | 136 | { |
| 130 | | return 0; |
| 137 | return ( (m_cass->input() > 0.03) ? 1 : 0) | (ioport("HW")->read() & 1); |
| 131 | 138 | } |
| 132 | 139 | |
| 133 | 140 | static ADDRESS_MAP_START( instruct_mem, AS_PROGRAM, 8, instruct_state ) |
| 134 | 141 | ADDRESS_MAP_UNMAP_HIGH |
| 135 | 142 | AM_RANGE(0x0000, 0x01ff) AM_RAM AM_SHARE("p_ram") // 512 bytes onboard ram |
| 143 | AM_RANGE(0x0200, 0x177f) AM_RAM // expansion ram needed by quickloads |
| 136 | 144 | AM_RANGE(0x1780, 0x17ff) AM_RAM // 128 bytes in s2656 chip |
| 137 | 145 | AM_RANGE(0x1800, 0x1fff) AM_ROM |
| 138 | 146 | ADDRESS_MAP_END |
| r15285 | r15286 | |
| 207 | 215 | memcpy(m_p_ram, ROM+0x1800, 0x0200); |
| 208 | 216 | } |
| 209 | 217 | |
| 218 | QUICKLOAD_LOAD( instruct ) |
| 219 | { |
| 220 | address_space *space = image.device().machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 221 | int i; |
| 222 | int quick_addr = 0x0100; |
| 223 | int exec_addr; |
| 224 | int quick_length; |
| 225 | UINT8 *quick_data; |
| 226 | int read_; |
| 210 | 227 | |
| 228 | quick_length = image.length(); |
| 229 | quick_data = (UINT8*)malloc(quick_length); |
| 230 | if (!quick_data) |
| 231 | { |
| 232 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 233 | image.message(" Cannot open file"); |
| 234 | return IMAGE_INIT_FAIL; |
| 235 | } |
| 236 | |
| 237 | read_ = image.fread( quick_data, quick_length); |
| 238 | if (read_ != quick_length) |
| 239 | { |
| 240 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 241 | image.message(" Cannot read the file"); |
| 242 | return IMAGE_INIT_FAIL; |
| 243 | } |
| 244 | |
| 245 | if (quick_data[0] != 0xc5) |
| 246 | { |
| 247 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 248 | image.message(" Invalid header"); |
| 249 | return IMAGE_INIT_FAIL; |
| 250 | } |
| 251 | |
| 252 | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 253 | |
| 254 | if (exec_addr >= quick_length) |
| 255 | { |
| 256 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 257 | image.message(" Exec address beyond end of file"); |
| 258 | return IMAGE_INIT_FAIL; |
| 259 | } |
| 260 | |
| 261 | if (quick_length < 0x104) |
| 262 | { |
| 263 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 264 | image.message(" File too short"); |
| 265 | return IMAGE_INIT_FAIL; |
| 266 | } |
| 267 | |
| 268 | if (quick_length > 0x17c0) |
| 269 | { |
| 270 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 271 | image.message(" File too long"); |
| 272 | return IMAGE_INIT_FAIL; |
| 273 | } |
| 274 | |
| 275 | for (i = quick_addr; i < quick_length; i++) |
| 276 | { |
| 277 | space->write_byte(i, quick_data[i]); |
| 278 | } |
| 279 | |
| 280 | /* display a message about the loaded quickload */ |
| 281 | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 282 | |
| 283 | // Start the quickload |
| 284 | cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, exec_addr); |
| 285 | return IMAGE_INIT_PASS; |
| 286 | } |
| 287 | |
| 211 | 288 | static MACHINE_CONFIG_START( instruct, instruct_state ) |
| 212 | 289 | /* basic machine hardware */ |
| 213 | 290 | MCFG_CPU_ADD("maincpu",S2650, XTAL_3_579545MHz / 4) |
| r15285 | r15286 | |
| 216 | 293 | |
| 217 | 294 | /* video hardware */ |
| 218 | 295 | MCFG_DEFAULT_LAYOUT(layout_instruct) |
| 296 | |
| 297 | /* quickload */ |
| 298 | MCFG_QUICKLOAD_ADD("quickload", instruct, "pgm", 1) |
| 299 | |
| 300 | /* cassette */ |
| 301 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 302 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 303 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 304 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 219 | 305 | MACHINE_CONFIG_END |
| 220 | 306 | |
| 221 | 307 | /* ROM definition */ |
| r15285 | r15286 | |
| 227 | 313 | /* Driver */ |
| 228 | 314 | |
| 229 | 315 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 230 | | COMP( 1978, instruct, 0, 0, instruct, instruct, 0, "Signetics", "Signetics Instructor 50", GAME_NOT_WORKING | GAME_NO_SOUND_HW ) |
| 316 | COMP( 1978, instruct, 0, 0, instruct, instruct, 0, "Signetics", "Signetics Instructor 50", 0 ) |