src/mess/machine/coleco.c
| r2900 | r2901 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | coleco.c |
| 4 | | |
| 5 | | Machine file to handle emulation of the Colecovision. |
| 6 | | |
| 7 | | TODO: |
| 8 | | - Extra controller support |
| 9 | | ***************************************************************************/ |
| 10 | | |
| 11 | | #include "driver.h" |
| 12 | | #include "video/tms9928a.h" |
| 13 | | #include "includes/coleco.h" |
| 14 | | #include "devices/cartslot.h" |
| 15 | | |
| 16 | | |
| 17 | | static int JoyMode=0; |
| 18 | | int JoyStat[2]; |
| 19 | | |
| 20 | | int coleco_cart_verify(const UINT8 *cartdata, size_t size) |
| 21 | | { |
| 22 | | int retval = IMAGE_VERIFY_FAIL; |
| 23 | | |
| 24 | | /* Verify the file is in Colecovision format */ |
| 25 | | if ((cartdata[0] == 0xAA) && (cartdata[1] == 0x55)) /* Production Cartridge */ |
| 26 | | retval = IMAGE_VERIFY_PASS; |
| 27 | | if ((cartdata[0] == 0x55) && (cartdata[1] == 0xAA)) /* "Test" Cartridge. Some games use this method to skip ColecoVision title screen and delay */ |
| 28 | | retval = IMAGE_VERIFY_PASS; |
| 29 | | |
| 30 | | return retval; |
| 31 | | } |
| 32 | | |
| 33 | | READ8_HANDLER ( coleco_paddle_r ) |
| 34 | | { |
| 35 | | /* Player 1 */ |
| 36 | | if ((offset & 0x02)==0) |
| 37 | | { |
| 38 | | /* Keypad and fire 1 (SAC Yellow Button) */ |
| 39 | | if (JoyMode==0) |
| 40 | | { |
| 41 | | int inport0,inport1,inport6,data; |
| 42 | | |
| 43 | | inport0 = input_port_read(machine, "IN0"); |
| 44 | | inport1 = input_port_read(machine, "IN1"); |
| 45 | | inport6 = input_port_read(machine, "IN6"); |
| 46 | | |
| 47 | | /* Numeric pad buttons are not independent on a real ColecoVision, if you push more |
| 48 | | than one, a real ColecoVision think that it is a third button, so we are going to emulate |
| 49 | | the right behaviour */ |
| 50 | | |
| 51 | | data = 0x0F; /* No key pressed by default */ |
| 52 | | if (!(inport6&0x01)) /* If Driving Controller enabled -> no keypad 1*/ |
| 53 | | { |
| 54 | | if (!(inport0 & 0x01)) data &= 0x0A; /* 0 */ |
| 55 | | if (!(inport0 & 0x02)) data &= 0x0D; /* 1 */ |
| 56 | | if (!(inport0 & 0x04)) data &= 0x07; /* 2 */ |
| 57 | | if (!(inport0 & 0x08)) data &= 0x0C; /* 3 */ |
| 58 | | if (!(inport0 & 0x10)) data &= 0x02; /* 4 */ |
| 59 | | if (!(inport0 & 0x20)) data &= 0x03; /* 5 */ |
| 60 | | if (!(inport0 & 0x40)) data &= 0x0E; /* 6 */ |
| 61 | | if (!(inport0 & 0x80)) data &= 0x05; /* 7 */ |
| 62 | | if (!(inport1 & 0x01)) data &= 0x01; /* 8 */ |
| 63 | | if (!(inport1 & 0x02)) data &= 0x0B; /* 9 */ |
| 64 | | if (!(inport1 & 0x04)) data &= 0x06; /* # */ |
| 65 | | if (!(inport1 & 0x08)) data &= 0x09; /* . */ |
| 66 | | } |
| 67 | | return (inport1 & 0x70) | (data); |
| 68 | | } |
| 69 | | /* Joystick and fire 2 (SAC Red Button) */ |
| 70 | | else |
| 71 | | { |
| 72 | | int data = input_port_read(machine, "IN2") & 0xCF; |
| 73 | | int inport6 = input_port_read(machine, "IN6"); |
| 74 | | |
| 75 | | if (inport6&0x07) /* If Extra Contollers enabled */ |
| 76 | | { |
| 77 | | if (JoyStat[0]==0) data|=0x30; /* Spinner Move Left*/ |
| 78 | | else if (JoyStat[0]==1) data|=0x20; /* Spinner Move Right */ |
| 79 | | } |
| 80 | | return data | 0x80; |
| 81 | | } |
| 82 | | } |
| 83 | | /* Player 2 */ |
| 84 | | else |
| 85 | | { |
| 86 | | /* Keypad and fire 1 */ |
| 87 | | if (JoyMode==0) |
| 88 | | { |
| 89 | | int inport3,inport4,data; |
| 90 | | |
| 91 | | inport3 = input_port_read(machine, "IN3"); |
| 92 | | inport4 = input_port_read(machine, "IN4"); |
| 93 | | |
| 94 | | /* Numeric pad buttons are not independent on a real ColecoVision, if you push more |
| 95 | | than one, a real ColecoVision think that it is a third button, so we are going to emulate |
| 96 | | the right behaviour */ |
| 97 | | |
| 98 | | data = 0x0F; /* No key pressed by default */ |
| 99 | | if (!(inport3 & 0x01)) data &= 0x0A; /* 0 */ |
| 100 | | if (!(inport3 & 0x02)) data &= 0x0D; /* 1 */ |
| 101 | | if (!(inport3 & 0x04)) data &= 0x07; /* 2 */ |
| 102 | | if (!(inport3 & 0x08)) data &= 0x0C; /* 3 */ |
| 103 | | if (!(inport3 & 0x10)) data &= 0x02; /* 4 */ |
| 104 | | if (!(inport3 & 0x20)) data &= 0x03; /* 5 */ |
| 105 | | if (!(inport3 & 0x40)) data &= 0x0E; /* 6 */ |
| 106 | | if (!(inport3 & 0x80)) data &= 0x05; /* 7 */ |
| 107 | | if (!(inport4 & 0x01)) data &= 0x01; /* 8 */ |
| 108 | | if (!(inport4 & 0x02)) data &= 0x0B; /* 9 */ |
| 109 | | if (!(inport4 & 0x04)) data &= 0x06; /* # */ |
| 110 | | if (!(inport4 & 0x08)) data &= 0x09; /* . */ |
| 111 | | |
| 112 | | return (inport4 & 0x70) | (data); |
| 113 | | } |
| 114 | | /* Joystick and fire 2*/ |
| 115 | | else |
| 116 | | { |
| 117 | | int data = input_port_read(machine, "IN5") & 0xCF; |
| 118 | | int inport6 = input_port_read(machine, "IN6"); |
| 119 | | |
| 120 | | if (inport6&0x02) /* If Roller Controller enabled */ |
| 121 | | { |
| 122 | | if (JoyStat[1]==0) data|=0x30; |
| 123 | | else if (JoyStat[1]==1) data|=0x20; |
| 124 | | } |
| 125 | | |
| 126 | | return data | 0x80; |
| 127 | | } |
| 128 | | } |
| 129 | | |
| 130 | | } |
| 131 | | |
| 132 | | |
| 133 | | WRITE8_HANDLER ( coleco_paddle_toggle_off ) |
| 134 | | { |
| 135 | | JoyMode=0; |
| 136 | | return; |
| 137 | | } |
| 138 | | |
| 139 | | WRITE8_HANDLER ( coleco_paddle_toggle_on ) |
| 140 | | { |
| 141 | | JoyMode=1; |
| 142 | | return; |
| 143 | | } |
| 144 | | |
src/mess/drivers/coleco.c
| r2900 | r2901 | |
| 54 | 54 | |
| 55 | 55 | ***************************************************************************/ |
| 56 | 56 | |
| 57 | /* |
| 58 | |
| 59 | TODO: |
| 60 | |
| 61 | - Dina SG-1000 mode |
| 62 | |
| 63 | */ |
| 64 | |
| 57 | 65 | #include "driver.h" |
| 58 | 66 | #include "sound/sn76496.h" |
| 59 | 67 | #include "video/tms9928a.h" |
| 60 | | #include "includes/coleco.h" |
| 61 | 68 | #include "devices/cartslot.h" |
| 62 | 69 | |
| 63 | | READ8_HANDLER(coleco_video_r) |
| 70 | static int joy_mode; |
| 71 | static int joy_status[2]; |
| 72 | |
| 73 | /* Read/Write Handlers */ |
| 74 | |
| 75 | static READ8_HANDLER( paddle_1_r ) |
| 64 | 76 | { |
| 65 | | return ((offset & 0x01) ? TMS9928A_register_r(machine, 1) : TMS9928A_vram_r(machine, 0)); |
| 77 | UINT8 inport6 = input_port_read_safe(machine, "IN6", 0); |
| 78 | |
| 79 | /* Keypad and fire 1 (SAC Yellow Button) */ |
| 80 | if (joy_mode==0) |
| 81 | { |
| 82 | UINT8 inport0 = input_port_read(machine, "IN0"); |
| 83 | UINT8 inport1 = input_port_read(machine, "IN1"); |
| 84 | |
| 85 | /* Numeric pad buttons are not independent on a real ColecoVision, if you push more |
| 86 | than one, a real ColecoVision think that it is a third button, so we are going to emulate |
| 87 | the right behaviour */ |
| 88 | |
| 89 | UINT8 data = 0x0F; /* No key pressed by default */ |
| 90 | |
| 91 | if (!(inport6 & 0x01)) /* If Driving Controller enabled -> no keypad 1*/ |
| 92 | { |
| 93 | if (!(inport0 & 0x01)) data &= 0x0A; /* 0 */ |
| 94 | if (!(inport0 & 0x02)) data &= 0x0D; /* 1 */ |
| 95 | if (!(inport0 & 0x04)) data &= 0x07; /* 2 */ |
| 96 | if (!(inport0 & 0x08)) data &= 0x0C; /* 3 */ |
| 97 | if (!(inport0 & 0x10)) data &= 0x02; /* 4 */ |
| 98 | if (!(inport0 & 0x20)) data &= 0x03; /* 5 */ |
| 99 | if (!(inport0 & 0x40)) data &= 0x0E; /* 6 */ |
| 100 | if (!(inport0 & 0x80)) data &= 0x05; /* 7 */ |
| 101 | if (!(inport1 & 0x01)) data &= 0x01; /* 8 */ |
| 102 | if (!(inport1 & 0x02)) data &= 0x0B; /* 9 */ |
| 103 | if (!(inport1 & 0x04)) data &= 0x06; /* # */ |
| 104 | if (!(inport1 & 0x08)) data &= 0x09; /* . */ |
| 105 | } |
| 106 | return (inport1 & 0x70) | (data); |
| 107 | } |
| 108 | /* Joystick and fire 2 (SAC Red Button) */ |
| 109 | else |
| 110 | { |
| 111 | UINT8 data = input_port_read(machine, "IN2") & 0xCF; |
| 112 | |
| 113 | if (inport6 & 0x07) /* If Extra Contollers enabled */ |
| 114 | { |
| 115 | if (joy_status[0] == 0) data |= 0x30; /* Spinner Move Left*/ |
| 116 | else if (joy_status[0] == 1) data |= 0x20; /* Spinner Move Right */ |
| 117 | } |
| 118 | |
| 119 | return data | 0x80; |
| 120 | } |
| 66 | 121 | } |
| 67 | 122 | |
| 68 | | WRITE8_HANDLER(coleco_video_w) |
| 123 | static READ8_HANDLER( paddle_2_r ) |
| 69 | 124 | { |
| 70 | | (offset & 0x01) ? TMS9928A_register_w(machine, 1, data) : TMS9928A_vram_w(machine, 0, data); |
| 125 | /* Keypad and fire 1 */ |
| 126 | if (joy_mode == 0) |
| 127 | { |
| 128 | UINT8 inport3 = input_port_read(machine, "IN3"); |
| 129 | UINT8 inport4 = input_port_read(machine, "IN4"); |
| 130 | |
| 131 | /* Numeric pad buttons are not independent on a real ColecoVision, if you push more |
| 132 | than one, a real ColecoVision think that it is a third button, so we are going to emulate |
| 133 | the right behaviour */ |
| 134 | |
| 135 | UINT8 data = 0x0F; /* No key pressed by default */ |
| 136 | |
| 137 | if (!(inport3 & 0x01)) data &= 0x0A; /* 0 */ |
| 138 | if (!(inport3 & 0x02)) data &= 0x0D; /* 1 */ |
| 139 | if (!(inport3 & 0x04)) data &= 0x07; /* 2 */ |
| 140 | if (!(inport3 & 0x08)) data &= 0x0C; /* 3 */ |
| 141 | if (!(inport3 & 0x10)) data &= 0x02; /* 4 */ |
| 142 | if (!(inport3 & 0x20)) data &= 0x03; /* 5 */ |
| 143 | if (!(inport3 & 0x40)) data &= 0x0E; /* 6 */ |
| 144 | if (!(inport3 & 0x80)) data &= 0x05; /* 7 */ |
| 145 | if (!(inport4 & 0x01)) data &= 0x01; /* 8 */ |
| 146 | if (!(inport4 & 0x02)) data &= 0x0B; /* 9 */ |
| 147 | if (!(inport4 & 0x04)) data &= 0x06; /* # */ |
| 148 | if (!(inport4 & 0x08)) data &= 0x09; /* . */ |
| 149 | |
| 150 | return (inport4 & 0x70) | (data); |
| 151 | } |
| 152 | /* Joystick and fire 2*/ |
| 153 | else |
| 154 | { |
| 155 | UINT8 data = input_port_read(machine, "IN5") & 0xCF; |
| 156 | UINT8 inport6 = input_port_read_safe(machine, "IN6", 0); |
| 157 | |
| 158 | if (inport6 & 0x02) /* If Roller Controller enabled */ |
| 159 | { |
| 160 | if (joy_status[1] == 0) data |= 0x30; |
| 161 | else if (joy_status[1] == 1) data |= 0x20; |
| 162 | } |
| 163 | |
| 164 | return data | 0x80; |
| 165 | } |
| 71 | 166 | } |
| 72 | 167 | |
| 168 | static WRITE8_HANDLER( paddle_off_w ) |
| 169 | { |
| 170 | joy_mode = 0; |
| 171 | } |
| 172 | |
| 173 | static WRITE8_HANDLER( paddle_on_w ) |
| 174 | { |
| 175 | joy_mode = 1; |
| 176 | } |
| 177 | |
| 178 | /* Memory Maps */ |
| 179 | |
| 73 | 180 | static ADDRESS_MAP_START( coleco_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 74 | 181 | AM_RANGE(0x0000, 0x1fff) AM_ROM |
| 75 | | AM_RANGE(0x2000, 0x5fff) AM_NOP |
| 76 | 182 | AM_RANGE(0x6000, 0x63ff) AM_RAM AM_MIRROR(0x1c00) |
| 77 | 183 | AM_RANGE(0x8000, 0xffff) AM_ROM |
| 78 | 184 | ADDRESS_MAP_END |
| 79 | 185 | |
| 80 | 186 | static ADDRESS_MAP_START( coleco_io_map, ADDRESS_SPACE_IO, 8 ) |
| 81 | 187 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 82 | | AM_RANGE(0x80, 0x9f) AM_WRITE(coleco_paddle_toggle_off) |
| 83 | | AM_RANGE(0xa0, 0xbf) AM_READWRITE(coleco_video_r, coleco_video_w) |
| 84 | | AM_RANGE(0xc0, 0xdf) AM_WRITE(coleco_paddle_toggle_on) |
| 85 | | AM_RANGE(0xe0, 0xff) AM_READWRITE(coleco_paddle_r, SN76496_0_w) |
| 188 | AM_RANGE(0x80, 0x80) AM_MIRROR(0x1f) AM_WRITE(paddle_off_w) |
| 189 | AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x1e) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w) |
| 190 | AM_RANGE(0xa1, 0xa1) AM_MIRROR(0x1e) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 191 | AM_RANGE(0xc0, 0xc0) AM_MIRROR(0x1f) AM_WRITE(paddle_on_w) |
| 192 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x1f) AM_WRITE(SN76496_0_w) |
| 193 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x1d) AM_READ(paddle_1_r) |
| 194 | AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x1d) AM_READ(paddle_2_r) |
| 86 | 195 | ADDRESS_MAP_END |
| 87 | 196 | |
| 197 | static ADDRESS_MAP_START( czz50_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 198 | AM_RANGE(0x0000, 0x3fff) AM_ROM |
| 199 | AM_RANGE(0x6000, 0x63ff) AM_RAM AM_MIRROR(0x1c00) |
| 200 | AM_RANGE(0x8000, 0xffff) AM_ROM |
| 201 | ADDRESS_MAP_END |
| 202 | |
| 203 | static ADDRESS_MAP_START( czz50_io_map, ADDRESS_SPACE_IO, 8 ) |
| 204 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 205 | AM_RANGE(0x80, 0x80) AM_MIRROR(0x1f) AM_WRITE(paddle_off_w) |
| 206 | AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x1e) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w) |
| 207 | AM_RANGE(0xa1, 0xa1) AM_MIRROR(0x1e) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 208 | AM_RANGE(0xc0, 0xc0) AM_MIRROR(0x1f) AM_WRITE(paddle_on_w) |
| 209 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x1f) AM_WRITE(SN76496_0_w) |
| 210 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x1d) AM_READ(paddle_1_r) |
| 211 | AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x1d) AM_READ(paddle_2_r) |
| 212 | ADDRESS_MAP_END |
| 213 | |
| 214 | /* Input Ports */ |
| 215 | |
| 88 | 216 | static INPUT_PORTS_START( coleco ) |
| 89 | 217 | PORT_START_TAG("IN0") |
| 90 | 218 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("0 (pad 1)") PORT_CODE(KEYCODE_0) |
| r2900 | r2901 | |
| 156 | 284 | PORT_BIT( 0x0f, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(20) PORT_KEYDELTA(10) PORT_CODE_DEC(KEYCODE_I) PORT_CODE_INC(KEYCODE_K) PORT_RESET PORT_PLAYER(2) |
| 157 | 285 | INPUT_PORTS_END |
| 158 | 286 | |
| 287 | static INPUT_PORTS_START( czz50 ) |
| 288 | PORT_START_TAG("IN0") |
| 289 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 290 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 291 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2') |
| 292 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 293 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4') |
| 294 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5') |
| 295 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6') |
| 296 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7') |
| 159 | 297 | |
| 298 | PORT_START_TAG("IN1") |
| 299 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8') |
| 300 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9') |
| 301 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("#") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('#') |
| 302 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(".") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('.') |
| 303 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) |
| 304 | PORT_BIT( 0xb0, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 160 | 305 | |
| 306 | PORT_START_TAG("IN2") |
| 307 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) |
| 308 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) |
| 309 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) |
| 310 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) |
| 311 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) |
| 312 | PORT_BIT( 0xb0, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 313 | |
| 314 | PORT_START_TAG("IN3") |
| 315 | PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 316 | |
| 317 | PORT_START_TAG("IN4") |
| 318 | PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 319 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) |
| 320 | PORT_BIT( 0xb0, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 321 | |
| 322 | PORT_START_TAG("IN5") |
| 323 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) |
| 324 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) |
| 325 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) |
| 326 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) |
| 327 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) |
| 328 | PORT_BIT( 0xb0, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 329 | INPUT_PORTS_END |
| 330 | |
| 161 | 331 | /*************************************************************************** |
| 162 | 332 | |
| 163 | 333 | The interrupts come from the vdp. The vdp (tms9928a) interrupt can go up |
| r2900 | r2901 | |
| 177 | 347 | TMS9928A_interrupt(machine); |
| 178 | 348 | } |
| 179 | 349 | |
| 180 | | static void coleco_vdp_interrupt (running_machine *machine, int state) |
| 350 | static void coleco_vdp_interrupt(running_machine *machine, int state) |
| 181 | 351 | { |
| 182 | 352 | static int last_state = 0; |
| 183 | 353 | |
| r2900 | r2901 | |
| 186 | 356 | last_state = state; |
| 187 | 357 | } |
| 188 | 358 | |
| 189 | | static TIMER_CALLBACK(paddle_callback) |
| 359 | static TIMER_CALLBACK( paddle_callback ) |
| 190 | 360 | { |
| 191 | | int port7 = input_port_read(machine, "IN7"); |
| 192 | | int port8 = input_port_read(machine, "IN8"); |
| 361 | int port7 = input_port_read_safe(machine, "IN7", 0); |
| 362 | int port8 = input_port_read_safe(machine, "IN8", 0); |
| 193 | 363 | |
| 194 | 364 | if (port7 == 0) |
| 195 | | JoyStat[0] = 0; |
| 365 | joy_status[0] = 0; |
| 196 | 366 | else if (port7 & 0x08) |
| 197 | | JoyStat[0] = -1; |
| 367 | joy_status[0] = -1; |
| 198 | 368 | else |
| 199 | | JoyStat[0] = 1; |
| 369 | joy_status[0] = 1; |
| 200 | 370 | |
| 201 | 371 | if (port8 == 0) |
| 202 | | JoyStat[1] = 0; |
| 372 | joy_status[1] = 0; |
| 203 | 373 | else if (port8 & 0x08) |
| 204 | | JoyStat[1] = -1; |
| 374 | joy_status[1] = -1; |
| 205 | 375 | else |
| 206 | | JoyStat[1] = 1; |
| 376 | joy_status[1] = 1; |
| 207 | 377 | |
| 208 | | if (JoyStat[0] || JoyStat[1]) |
| 209 | | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 378 | if (joy_status[0] || joy_status[1]) |
| 379 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, HOLD_LINE); |
| 210 | 380 | } |
| 211 | 381 | |
| 382 | /* Machine Initialization */ |
| 383 | |
| 212 | 384 | static const TMS9928a_interface tms9928a_interface = |
| 213 | 385 | { |
| 214 | 386 | TMS99x8A, |
| r2900 | r2901 | |
| 222 | 394 | TMS9928A_configure(&tms9928a_interface); |
| 223 | 395 | } |
| 224 | 396 | |
| 225 | | static MACHINE_RESET(coleco) |
| 397 | static MACHINE_RESET( coleco ) |
| 226 | 398 | { |
| 227 | | cpunum_set_input_line_vector(0, 0, 0xff); |
| 399 | cpunum_set_input_line_vector(0, INPUT_LINE_IRQ0, 0xff); |
| 228 | 400 | memset(&memory_region(REGION_CPU1)[0x6000], 0xff, 0x400); // initialize RAM |
| 229 | 401 | timer_pulse(ATTOTIME_IN_MSEC(20), NULL, 0, paddle_callback); |
| 230 | 402 | } |
| 231 | 403 | |
| 404 | /* Machine Drivers */ |
| 405 | |
| 232 | 406 | static MACHINE_DRIVER_START( coleco ) |
| 233 | 407 | // basic machine hardware |
| 234 | | MDRV_CPU_ADD(Z80, 7159090/2) // 3.579545 MHz |
| 408 | MDRV_CPU_ADD(Z80, XTAL_7_15909MHz/2) // 3.579545 MHz |
| 235 | 409 | MDRV_CPU_PROGRAM_MAP(coleco_map, 0) |
| 236 | 410 | MDRV_CPU_IO_MAP(coleco_io_map, 0) |
| 237 | 411 | MDRV_CPU_VBLANK_INT("main", coleco_interrupt) |
| r2900 | r2901 | |
| 242 | 416 | // video hardware |
| 243 | 417 | MDRV_IMPORT_FROM(tms9928a) |
| 244 | 418 | MDRV_SCREEN_MODIFY("main") |
| 245 | | MDRV_SCREEN_REFRESH_RATE(60) |
| 419 | MDRV_SCREEN_REFRESH_RATE((float)XTAL_10_738635MHz/2/342/262) |
| 246 | 420 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 247 | 421 | |
| 248 | 422 | // sound hardware |
| 249 | 423 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 250 | | MDRV_SOUND_ADD(SN76489A, 7159090/2) /* 3.579545 MHz */ |
| 424 | MDRV_SOUND_ADD(SN76489A, XTAL_7_15909MHz/2) /* 3.579545 MHz */ |
| 251 | 425 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 252 | 426 | MACHINE_DRIVER_END |
| 253 | 427 | |
| 428 | static MACHINE_DRIVER_START( czz50 ) |
| 429 | // basic machine hardware |
| 430 | MDRV_CPU_ADD(Z80, XTAL_7_15909MHz/2) // ??? |
| 431 | MDRV_CPU_PROGRAM_MAP(czz50_map, 0) |
| 432 | MDRV_CPU_IO_MAP(czz50_io_map, 0) |
| 433 | MDRV_CPU_VBLANK_INT("main", coleco_interrupt) |
| 434 | |
| 435 | MDRV_MACHINE_START(coleco) |
| 436 | MDRV_MACHINE_RESET(coleco) |
| 437 | |
| 438 | // video hardware |
| 439 | MDRV_IMPORT_FROM(tms9928a) |
| 440 | MDRV_SCREEN_MODIFY("main") |
| 441 | MDRV_SCREEN_REFRESH_RATE((float)XTAL_10_738635MHz/2/342/262) |
| 442 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 443 | |
| 444 | // sound hardware |
| 445 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 446 | MDRV_SOUND_ADD(SN76489A, XTAL_7_15909MHz/2) // ??? |
| 447 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 448 | MACHINE_DRIVER_END |
| 449 | |
| 450 | static MACHINE_DRIVER_START( dina ) |
| 451 | MDRV_IMPORT_FROM(czz50) |
| 452 | MDRV_SCREEN_MODIFY("main") |
| 453 | MDRV_SCREEN_REFRESH_RATE((float)XTAL_10_738635MHz/2/342/313) |
| 454 | MACHINE_DRIVER_END |
| 455 | |
| 456 | /* ROMs */ |
| 457 | |
| 254 | 458 | ROM_START (coleco) |
| 255 | 459 | ROM_REGION( 0x10000, REGION_CPU1, 0 ) |
| 256 | 460 | ROM_LOAD( "coleco.rom", 0x0000, 0x2000, CRC(3aa93ef3) SHA1(45bedc4cbdeac66c7df59e9e599195c778d86a92) ) |
| r2900 | r2901 | |
| 270 | 474 | ROM_CART_LOAD(0, "rom,col,bin", 0x8000, 0x8000, ROM_NOMIRROR | ROM_OPTIONAL) |
| 271 | 475 | ROM_END |
| 272 | 476 | |
| 477 | ROM_START( czz50 ) |
| 478 | ROM_REGION( 0x10000, REGION_CPU1, 0 ) |
| 479 | ROM_LOAD( "czz50.rom", 0x0000, 0x2000, CRC(4999abc6) SHA1(96aecec3712c94517103d894405bc98a7dafa440) ) |
| 480 | ROM_CONTINUE( 0x8000, 0x2000 ) |
| 481 | ROM_END |
| 482 | |
| 483 | #define rom_dina rom_czz50 |
| 484 | #define rom_prsarcde rom_czz50 |
| 485 | |
| 486 | /* System Configuration */ |
| 487 | |
| 488 | static int coleco_cart_verify(const UINT8 *cartdata, size_t size) |
| 489 | { |
| 490 | int retval = IMAGE_VERIFY_FAIL; |
| 491 | |
| 492 | /* Verify the file is in Colecovision format */ |
| 493 | if ((cartdata[0] == 0xAA) && (cartdata[1] == 0x55)) /* Production Cartridge */ |
| 494 | retval = IMAGE_VERIFY_PASS; |
| 495 | if ((cartdata[0] == 0x55) && (cartdata[1] == 0xAA)) /* "Test" Cartridge. Some games use this method to skip ColecoVision title screen and delay */ |
| 496 | retval = IMAGE_VERIFY_PASS; |
| 497 | |
| 498 | return retval; |
| 499 | } |
| 500 | |
| 273 | 501 | static void coleco_cartslot_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 274 | 502 | { |
| 275 | 503 | /* cartslot */ |
| 276 | 504 | switch(state) |
| 277 | 505 | { |
| 278 | 506 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 279 | | case MESS_DEVINFO_PTR_VERIFY: info->imgverify = coleco_cart_verify; break; |
| 507 | case MESS_DEVINFO_PTR_VERIFY: info->imgverify = coleco_cart_verify; break; |
| 280 | 508 | |
| 281 | 509 | default: cartslot_device_getinfo(devclass, state, info); break; |
| 282 | 510 | } |
| 283 | 511 | } |
| 284 | 512 | |
| 285 | | static SYSTEM_CONFIG_START(coleco) |
| 513 | static SYSTEM_CONFIG_START( coleco ) |
| 286 | 514 | CONFIG_DEVICE(coleco_cartslot_getinfo) |
| 287 | 515 | SYSTEM_CONFIG_END |
| 288 | 516 | |
| 289 | | // YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME |
| 290 | | CONS( 1982, coleco, 0, 0, coleco, coleco, 0, coleco, "Coleco", "ColecoVision" , 0) |
| 291 | | CONS( 1982, colecoa, coleco, 0, coleco, coleco, 0, coleco, "Coleco", "ColecoVision (Thick Characters)" , 0) |
| 292 | | CONS( 1983, colecob, coleco, 0, coleco, coleco, 0, coleco, "Spectravideo", "SVI-603 Coleco Game Adapter" , 0) |
| 517 | static DEVICE_IMAGE_LOAD( czz50_cart ) |
| 518 | { |
| 519 | int size = image_length(image); |
| 520 | UINT8 *ptr = memory_region(REGION_CPU1) + 0x8000; |
| 521 | |
| 522 | if (image_fread(image, ptr, size ) != size) |
| 523 | { |
| 524 | return INIT_FAIL; |
| 525 | } |
| 526 | |
| 527 | return INIT_PASS; |
| 528 | } |
| 529 | |
| 530 | static void czz50_cartslot_getinfo( const mess_device_class *devclass, UINT32 state, union devinfo *info ) |
| 531 | { |
| 532 | switch( state ) |
| 533 | { |
| 534 | case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 535 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(czz50_cart); break; |
| 536 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "rom,col,bin"); break; |
| 537 | |
| 538 | default: cartslot_device_getinfo( devclass, state, info ); break; |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | static SYSTEM_CONFIG_START( czz50 ) |
| 543 | CONFIG_DEVICE(czz50_cartslot_getinfo) |
| 544 | SYSTEM_CONFIG_END |
| 545 | |
| 546 | /* System Drivers */ |
| 547 | |
| 548 | // YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS |
| 549 | CONS( 1982, coleco, 0, 0, coleco, coleco, 0, coleco, "Coleco", "ColecoVision", 0 ) |
| 550 | CONS( 1982, colecoa, coleco, 0, coleco, coleco, 0, coleco, "Coleco", "ColecoVision (Thick Characters)", 0 ) |
| 551 | CONS( 1983, colecob, coleco, 0, coleco, coleco, 0, coleco, "Spectravideo", "SVI-603 Coleco Game Adapter", 0 ) |
| 552 | CONS( 1986, czz50, 0, 0, czz50, czz50, 0, czz50, "Bit Corporation", "Chuang Zao Zhe 50", 0 ) |
| 553 | CONS( 1988, dina, czz50, 0, dina, czz50, 0, czz50, "Telegames", "Dina", 0 ) |
| 554 | CONS( 1988, prsarcde, czz50, 0, czz50, czz50, 0, czz50, "Telegames", "Personal Arcade", 0 ) |