src/emu/sound/sn76496.c
| r4585 | r4586 | |
| 32 | 32 | 23/04/2007 : Lord Nightmare |
| 33 | 33 | Major update, implement all three different noise generation algorithms and a |
| 34 | 34 | set_variant call to discern among them. |
| 35 | |
| 36 | 28/04/2009 : Lord Nightmare |
| 37 | Add READY line readback; cleaned up struct a bit. Cleaned up comments. |
| 38 | Add more TODOs. Fixed some unsaved savestate related stuff. |
| 35 | 39 | |
| 36 | | TODO: Implement a function for setting stereo regs for the game gear. |
| 37 | | Requires either making the entire core stereo and forcing mono out for all |
| 38 | | chips except gamegear, or somehow making the core support both output typesf. |
| 40 | TODO: * Implement a function for setting stereo regs for the game gear. |
| 41 | Requires making the core support both mono and stereo, and have |
| 42 | a select register which determines which channels go where. |
| 43 | * Implement the TMS9919 and SN94624, which are earlier versions, |
| 44 | possibly lacking the /8 clock divider, of the SN76489, and hence |
| 45 | would have a max clock of 500Khz and 4 clocks per sample, as |
| 46 | opposed to max of 4Mhz and 32 clocks per sample on the SN76489A |
| 47 | * Implement the T6W28; has registers in a weird order, needs writes |
| 48 | to be 'sanitized' first. Also is stereo, similar to game gear. |
| 49 | * Implement the NCR 7496; Is probably 100% compatible with SN76496, |
| 50 | but the whitenoise taps could be different. Needs someone with a |
| 51 | Tandy 1200 or whatever it was which uses this to run some tests. |
| 52 | * Factor out common code so that the SAA1099 can share some code. |
| 39 | 53 | ***************************************************************************/ |
| 40 | 54 | |
| 41 | 55 | #include "sndintrf.h" |
| r4585 | r4586 | |
| 44 | 58 | |
| 45 | 59 | |
| 46 | 60 | #define MAX_OUTPUT 0x7fff |
| 47 | | |
| 48 | 61 | #define STEP 0x10000 |
| 62 | #define NOISEMODE (R->Register[6]&4)?1:0 |
| 49 | 63 | |
| 64 | |
| 50 | 65 | typedef struct _sn76496_state sn76496_state; |
| 51 | 66 | struct _sn76496_state |
| 52 | 67 | { |
| 53 | 68 | sound_stream * Channel; |
| 54 | | int SampleRate; |
| 55 | | int VolTable[16]; /* volume table */ |
| 69 | INT32 VolTable[16]; /* volume table (for 4-bit to db conversion)*/ |
| 56 | 70 | INT32 Register[8]; /* registers */ |
| 57 | 71 | INT32 LastRegister; /* last register written */ |
| 58 | | INT32 Volume[4]; /* volume of voice 0-2 and noise */ |
| 59 | | UINT32 RNG; /* noise generator */ |
| 60 | | INT32 NoiseMode; /* active noise mode */ |
| 61 | | INT32 FeedbackMask; /* mask for feedback */ |
| 62 | | INT32 WhitenoiseTaps; /* mask for white noise taps */ |
| 63 | | INT32 WhitenoiseInvert; /* white noise invert flag */ |
| 64 | | INT32 Period[4]; |
| 65 | | INT32 Count[4]; |
| 66 | | INT32 Output[4]; |
| 72 | INT32 Volume[4]; /* db volume of voice 0-2 and noise */ |
| 73 | UINT32 RNG; /* noise generator LFSR*/ |
| 74 | INT32 FeedbackMask; /* mask for feedback */ |
| 75 | INT32 WhitenoiseTaps; /* mask for white noise taps */ |
| 76 | INT32 WhitenoiseInvert; /* white noise invert flag */ |
| 77 | INT32 Period[4]; /* Length of 1/2 of waveform */ |
| 78 | INT32 Count[4]; /* Position within the waveform */ |
| 79 | INT32 Output[4]; /* 1-bit output of each channel, pre-volume */ |
| 80 | INT32 CyclestoREADY;/* number of cycles until the READY line goes active */ |
| 67 | 81 | }; |
| 68 | 82 | |
| 69 | 83 | |
| r4585 | r4586 | |
| 81 | 95 | return (sn76496_state *)device->token; |
| 82 | 96 | } |
| 83 | 97 | |
| 98 | READ8_DEVICE_HANDLER( sn76496_ready_r ) |
| 99 | { |
| 100 | sn76496_state *R = get_safe_token(device); |
| 101 | stream_update(R->Channel); |
| 102 | return (R->CyclestoREADY? 0 : 1); |
| 103 | } |
| 84 | 104 | |
| 85 | 105 | WRITE8_DEVICE_HANDLER( sn76496_w ) |
| 86 | 106 | { |
| r4585 | r4586 | |
| 91 | 111 | /* update the output buffer before changing the registers */ |
| 92 | 112 | stream_update(R->Channel); |
| 93 | 113 | |
| 114 | /* set number of cycles until READY is active; this is always one 'sample', i.e. it equals the clock divider exactly; until the clock divider is fully supported, we delay until one sample has played */ |
| 115 | R->CyclestoREADY = 4; |
| 116 | |
| 94 | 117 | if (data & 0x80) |
| 95 | 118 | { |
| 96 | 119 | r = (data & 0x70) >> 4; |
| r4585 | r4586 | |
| 128 | 151 | { |
| 129 | 152 | if ((data & 0x80) == 0) R->Register[r] = (R->Register[r] & 0x3f0) | (data & 0x0f); |
| 130 | 153 | n = R->Register[6]; |
| 131 | | R->NoiseMode = (n & 4) ? 1 : 0; |
| 132 | 154 | /* N/512,N/1024,N/2048,Tone #3 output */ |
| 133 | 155 | R->Period[3] = ((n&3) == 3) ? 2 * R->Period[2] : (STEP << (5+(n&3))); |
| 134 | 156 | /* Reset noise shifter */ |
| 135 | | R->RNG = R->FeedbackMask; /* this is correct according to the smspower document */ |
| 136 | | //R->RNG = 0xF35; /* this is not, but sounds better in do run run */ |
| 157 | R->RNG = R->FeedbackMask; |
| 137 | 158 | R->Output[3] = R->RNG & 1; |
| 138 | 159 | } |
| 139 | 160 | break; |
| r4585 | r4586 | |
| 149 | 170 | stream_sample_t *buffer = outputs[0]; |
| 150 | 171 | |
| 151 | 172 | |
| 152 | | /* If the volume is 0, increase the counter */ |
| 173 | /* If the volume is 0, increase the counter; this is more or less |
| 174 | a speedup hack for when silence is to be output */ |
| 153 | 175 | for (i = 0;i < 4;i++) |
| 154 | 176 | { |
| 155 | 177 | if (R->Volume[i] == 0) |
| 156 | 178 | { |
| 157 | | /* note that I do count += samples, NOT count = samples + 1. You might think */ |
| 158 | | /* it's the same since the volume is 0, but doing the latter could cause */ |
| 159 | | /* interferencies when the program is rapidly modulating the volume. */ |
| 179 | /* note that I do count += samples, NOT count = samples + 1. |
| 180 | You might think it's the same since the volume is 0, but doing |
| 181 | the latter could cause interferencies when the program is |
| 182 | rapidly modulating the volume. */ |
| 160 | 183 | if (R->Count[i] <= samples*STEP) R->Count[i] += samples*STEP; |
| 161 | 184 | } |
| 162 | 185 | } |
| r4585 | r4586 | |
| 166 | 189 | int vol[4]; |
| 167 | 190 | unsigned int out; |
| 168 | 191 | int left; |
| 192 | |
| 193 | /* decrement Cycles to READY by one */ |
| 194 | if (R->CyclestoREADY >0) R->CyclestoREADY--; |
| 169 | 195 | |
| 170 | | |
| 171 | 196 | /* vol[] keeps track of how long each square wave stays */ |
| 172 | 197 | /* in the 1 position during the sample period. */ |
| 173 | 198 | vol[0] = vol[1] = vol[2] = vol[3] = 0; |
| r4585 | r4586 | |
| 176 | 201 | { |
| 177 | 202 | if (R->Output[i]) vol[i] += R->Count[i]; |
| 178 | 203 | R->Count[i] -= STEP; |
| 179 | | /* Period[i] is the half period of the square wave. Here, in each */ |
| 180 | | /* loop I add Period[i] twice, so that at the end of the loop the */ |
| 181 | | /* square wave is in the same status (0 or 1) it was at the start. */ |
| 182 | | /* vol[i] is also incremented by Period[i], since the wave has been 1 */ |
| 183 | | /* exactly half of the time, regardless of the initial position. */ |
| 184 | | /* If we exit the loop in the middle, Output[i] has to be inverted */ |
| 185 | | /* and vol[i] incremented only if the exit status of the square */ |
| 186 | | /* wave is 1. */ |
| 204 | /* Period[i] is the half period of the square wave. Here, in each |
| 205 | loop I add Period[i] twice, so that at the end of the loop the |
| 206 | square wave is in the same status (0 or 1) it was at the start. |
| 207 | vol[i] is also incremented by Period[i], since the wave has been 1 |
| 208 | exactly half of the time, regardless of the initial position. |
| 209 | If we exit the loop in the middle, Output[i] has to be inverted |
| 210 | and vol[i] incremented only if the exit status of the square |
| 211 | wave is 1. */ |
| 187 | 212 | while (R->Count[i] <= 0) |
| 188 | 213 | { |
| 189 | 214 | R->Count[i] += R->Period[i]; |
| r4585 | r4586 | |
| 212 | 237 | R->Count[3] -= nextevent; |
| 213 | 238 | if (R->Count[3] <= 0) |
| 214 | 239 | { |
| 215 | | if (R->NoiseMode == 1) /* White Noise Mode */ |
| 240 | if (NOISEMODE == 1) /* White Noise Mode */ |
| 216 | 241 | { |
| 217 | 242 | if (((R->RNG & R->WhitenoiseTaps) != R->WhitenoiseTaps) && ((R->RNG & R->WhitenoiseTaps) != 0)) /* crappy xor! */ |
| 218 | 243 | { |
| r4585 | r4586 | |
| 293 | 318 | |
| 294 | 319 | R->Channel = stream_create(device,0,1,sample_rate,R,SN76496Update); |
| 295 | 320 | |
| 296 | | R->SampleRate = sample_rate; |
| 297 | | |
| 298 | 321 | for (i = 0;i < 4;i++) R->Volume[i] = 0; |
| 299 | 322 | |
| 300 | 323 | R->LastRegister = 0; |
| r4585 | r4586 | |
| 314 | 337 | R->FeedbackMask = 0x4000; /* mask for feedback */ |
| 315 | 338 | R->WhitenoiseTaps = 0x03; /* mask for white noise taps */ |
| 316 | 339 | R->WhitenoiseInvert = 1; /* white noise invert flag */ |
| 340 | R->CyclestoREADY = 1; /* assume ready is not active immediately on init. is this correct?*/ |
| 317 | 341 | |
| 318 | 342 | R->RNG = R->FeedbackMask; |
| 319 | 343 | R->Output[3] = R->RNG & 1; |
| r4585 | r4586 | |
| 334 | 358 | chip->WhitenoiseTaps = noisetaps; |
| 335 | 359 | chip->WhitenoiseInvert = noiseinvert; |
| 336 | 360 | |
| 361 | state_save_register_device_item_array(device, 0, chip->VolTable); |
| 337 | 362 | state_save_register_device_item_array(device, 0, chip->Register); |
| 338 | 363 | state_save_register_device_item(device, 0, chip->LastRegister); |
| 339 | 364 | state_save_register_device_item_array(device, 0, chip->Volume); |
| 340 | 365 | state_save_register_device_item(device, 0, chip->RNG); |
| 341 | | state_save_register_device_item(device, 0, chip->NoiseMode); |
| 366 | state_save_register_device_item(device, 0, chip->FeedbackMask); |
| 367 | state_save_register_device_item(device, 0, chip->WhitenoiseTaps); |
| 368 | state_save_register_device_item(device, 0, chip->WhitenoiseInvert); |
| 342 | 369 | state_save_register_device_item_array(device, 0, chip->Period); |
| 343 | 370 | state_save_register_device_item_array(device, 0, chip->Count); |
| 344 | 371 | state_save_register_device_item_array(device, 0, chip->Output); |
| 372 | state_save_register_device_item(device, 0, chip->CyclestoREADY); |
| 345 | 373 | } |
| 346 | 374 | |
| 347 | 375 | |
src/mess/drivers/crvision.c
| r4585 | r4586 | |
| 5 | 5 | There is also a CreatiVision Mk 2, possibly also known as the Laser 500. This was a proper computer, |
| 6 | 6 | containing a CreatiVision cartridge slot. |
| 7 | 7 | |
| 8 | NOTE: |
| 9 | |
| 10 | If you find that the keys R,D,F,G are not working while using the BASIC cartridge, |
| 11 | please remap the Joystick 2 keys to somewhere else. By default they overlap those keys. |
| 12 | |
| 8 | 13 | TODO: |
| 9 | 14 | |
| 15 | - cassette left (data) / right (audio) separation |
| 10 | 16 | - proper emulation of the monstrous keyboard |
| 17 | - parallel I/O module |
| 18 | - Chopper Rescue 18K cartridge not working |
| 19 | - HAPMON cartridge not working |
| 11 | 20 | |
| 12 | 21 | */ |
| 13 | 22 | |
| 14 | 23 | #include "driver.h" |
| 24 | #include "includes/crvision.h" |
| 15 | 25 | #include "cpu/m6502/m6502.h" |
| 16 | 26 | #include "devices/cartslot.h" |
| 17 | 27 | #include "devices/cassette.h" |
| r4585 | r4586 | |
| 19 | 29 | #include "sound/sn76496.h" |
| 20 | 30 | #include "video/tms9928a.h" |
| 21 | 31 | |
| 22 | | #define M6502_TAG "m6502" |
| 23 | | #define SCREEN_TAG "screen" |
| 32 | static const device_config *cassette_device_image(running_machine *machine) |
| 33 | { |
| 34 | return devtag_get_device(machine, "cassette"); |
| 35 | } |
| 24 | 36 | |
| 25 | 37 | /* Memory Map */ |
| 26 | 38 | |
| 27 | 39 | static ADDRESS_MAP_START( crvision_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 28 | | AM_RANGE(0x0000, 0x03ff) AM_RAM AM_MIRROR(0x0c00) |
| 29 | | AM_RANGE(0x1000, 0x1003) AM_DEVREADWRITE("pia", pia6821_r, pia6821_w) |
| 30 | | AM_RANGE(0x2000, 0x2000) AM_READ(TMS9928A_vram_r) |
| 31 | | AM_RANGE(0x2001, 0x2001) AM_READ(TMS9928A_register_r) |
| 32 | | AM_RANGE(0x3000, 0x3000) AM_WRITE(TMS9928A_vram_w) |
| 33 | | AM_RANGE(0x3001, 0x3001) AM_WRITE(TMS9928A_register_w) |
| 40 | AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x0c00) AM_RAM |
| 41 | AM_RANGE(0x1000, 0x1003) AM_MIRROR(0x0ffc) AM_DEVREADWRITE(PIA6821_TAG, pia6821_r, pia6821_w) |
| 42 | AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x0ffe) AM_READ(TMS9928A_vram_r) |
| 43 | AM_RANGE(0x2001, 0x2001) AM_MIRROR(0x0ffe) AM_READ(TMS9928A_register_r) |
| 44 | AM_RANGE(0x3000, 0x3000) AM_MIRROR(0x0ffe) AM_WRITE(TMS9928A_vram_w) |
| 45 | AM_RANGE(0x3001, 0x3001) AM_MIRROR(0x0ffe) AM_WRITE(TMS9928A_register_w) |
| 34 | 46 | AM_RANGE(0x4000, 0x7fff) AM_ROMBANK(2) |
| 35 | 47 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK(1) |
| 36 | | AM_RANGE(0xc000, 0xc7ff) AM_ROM AM_MIRROR(0x3800) |
| 48 | AM_RANGE(0xc000, 0xc7ff) AM_MIRROR(0x3800) AM_ROM |
| 37 | 49 | ADDRESS_MAP_END |
| 38 | 50 | |
| 39 | 51 | /* Input Ports */ |
| r4585 | r4586 | |
| 229 | 241 | crvision_vdp_interrupt |
| 230 | 242 | }; |
| 231 | 243 | |
| 232 | | static int keylatch; |
| 233 | | |
| 234 | 244 | static WRITE8_DEVICE_HANDLER( crvision_pia_porta_w ) |
| 235 | 245 | { |
| 236 | 246 | /* |
| 237 | 247 | Signal Description |
| 238 | 248 | |
| 239 | | PA0 Keyboard raster player 1 output |
| 240 | | PA1 Keyboard raster player 1 output |
| 241 | | PA2 Keyboard raster player 2 output |
| 242 | | PA3 Keyboard raster player 2 output |
| 249 | PA0 Keyboard raster player 1 output (joystick) |
| 250 | PA1 Keyboard raster player 1 output (hand keys) |
| 251 | PA2 Keyboard raster player 2 output (joystick) |
| 252 | PA3 Keyboard raster player 2 output (hand keys) |
| 243 | 253 | PA4 ? |
| 244 | 254 | PA5 ? |
| 245 | | PA6 ? |
| 246 | | PA7 ? |
| 255 | PA6 Cassette motor |
| 256 | PA7 Cassette data in/out |
| 247 | 257 | */ |
| 248 | 258 | |
| 249 | | keylatch = ~data & 0x0f; |
| 259 | crvision_state *state = device->machine->driver_data; |
| 260 | |
| 261 | /* keyboard raster */ |
| 262 | state->keylatch = ~data & 0x0f; |
| 263 | |
| 264 | /* cassette motor */ |
| 265 | cassette_change_state(cassette_device_image(device->machine), BIT(data, 6) ? CASSETTE_MOTOR_DISABLED : CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 266 | |
| 267 | /* cassette data output */ |
| 268 | cassette_output(cassette_device_image(device->machine), BIT(data, 7) ? +1.0 : -1.0); |
| 250 | 269 | } |
| 251 | 270 | |
| 252 | 271 | static UINT8 read_keyboard(running_machine *machine, int pa) |
| r4585 | r4586 | |
| 280 | 299 | static READ8_DEVICE_HANDLER( crvision_pia_porta_r ) |
| 281 | 300 | { |
| 282 | 301 | /* |
| 283 | | PA0 Keyboard raster player 1 output |
| 284 | | PA1 Keyboard raster player 1 output |
| 285 | | PA2 Keyboard raster player 2 output |
| 286 | | PA3 Keyboard raster player 2 output |
| 302 | PA0 Keyboard raster player 1 output (joystick) |
| 303 | PA1 Keyboard raster player 1 output (hand keys) |
| 304 | PA2 Keyboard raster player 2 output (joystick) |
| 305 | PA3 Keyboard raster player 2 output (hand keys) |
| 287 | 306 | PA4 ? |
| 288 | 307 | PA5 ? |
| 289 | | PA6 ? |
| 290 | | PA7 ? |
| 308 | PA6 Cassette motor |
| 309 | PA7 Cassette data in/out |
| 291 | 310 | */ |
| 292 | 311 | |
| 293 | | return 0xff; |
| 312 | UINT8 data = 0x7f; |
| 313 | |
| 314 | if (cassette_input(cassette_device_image(device->machine)) < +0.0) data |= 0x80; |
| 315 | |
| 316 | return data; |
| 294 | 317 | } |
| 295 | 318 | |
| 296 | 319 | static READ8_DEVICE_HANDLER( crvision_pia_portb_r ) |
| r4585 | r4586 | |
| 308 | 331 | PB7 Keyboard input |
| 309 | 332 | */ |
| 310 | 333 | |
| 311 | | if (keylatch & 0x01) |
| 312 | | { |
| 313 | | return read_keyboard(device->machine, 0); |
| 314 | | } |
| 315 | | else if (keylatch & 0x02) |
| 316 | | { |
| 317 | | return read_keyboard(device->machine, 1); |
| 318 | | } |
| 319 | | else if (keylatch & 0x04) |
| 320 | | { |
| 321 | | return read_keyboard(device->machine, 2); |
| 322 | | } |
| 323 | | else if (keylatch & 0x08) |
| 324 | | { |
| 325 | | return read_keyboard(device->machine, 3); |
| 326 | | } |
| 334 | crvision_state *state = device->machine->driver_data; |
| 327 | 335 | |
| 328 | | return 0xff; |
| 336 | UINT8 data = 0xff; |
| 337 | |
| 338 | if (BIT(state->keylatch, 0)) data &= read_keyboard(device->machine, 0); |
| 339 | if (BIT(state->keylatch, 1)) data &= read_keyboard(device->machine, 1); |
| 340 | if (BIT(state->keylatch, 2)) data &= read_keyboard(device->machine, 2); |
| 341 | if (BIT(state->keylatch, 3)) data &= read_keyboard(device->machine, 3); |
| 342 | |
| 343 | return data; |
| 329 | 344 | } |
| 330 | 345 | |
| 331 | | static READ8_DEVICE_HANDLER( crvision_pia_ca1_r ) |
| 346 | static READ_LINE_DEVICE_HANDLER( crvision_pia_ca_r ) |
| 332 | 347 | { |
| 333 | 348 | return 1; |
| 334 | 349 | } |
| 335 | 350 | |
| 336 | | static READ8_DEVICE_HANDLER( crvision_pia_ca2_r ) |
| 351 | static READ_LINE_DEVICE_HANDLER( crvision_pia_cb1_r ) |
| 337 | 352 | { |
| 338 | | return 1; |
| 339 | | } |
| 353 | crvision_state *state = device->machine->driver_data; |
| 340 | 354 | |
| 341 | | static int sn76489_ready; |
| 342 | | |
| 343 | | static READ8_DEVICE_HANDLER( crvision_pia_cb1_r ) |
| 344 | | { |
| 345 | | return sn76489_ready; |
| 355 | return sn76496_ready_r(state->sn76489, 0); |
| 346 | 356 | } |
| 347 | 357 | |
| 348 | | static TIMER_CALLBACK(sn76489_set_ready) |
| 358 | static WRITE_LINE_DEVICE_HANDLER( crvision_pia_cb2_w ) |
| 349 | 359 | { |
| 350 | | sn76489_ready = 1; |
| 351 | 360 | } |
| 352 | 361 | |
| 353 | 362 | static WRITE8_DEVICE_HANDLER( crvision_pia_portb_w ) |
| r4585 | r4586 | |
| 365 | 374 | PB7 SN76489 data output |
| 366 | 375 | */ |
| 367 | 376 | |
| 368 | | const device_config *sn76489 = devtag_get_device(device->machine, "sn76489"); |
| 369 | | sn76496_w(sn76489, 0, data); |
| 377 | crvision_state *state = device->machine->driver_data; |
| 370 | 378 | |
| 371 | | sn76489_ready = 0; |
| 372 | | |
| 373 | | // wait 32 cycles of 2 MHz to synchronize CPU and SN76489 |
| 374 | | timer_set(device->machine, ATTOTIME_IN_USEC(16), NULL, 0, sn76489_set_ready); |
| 379 | sn76496_w(state->sn76489, 0, data); |
| 375 | 380 | } |
| 376 | 381 | |
| 377 | | static WRITE8_DEVICE_HANDLER( crvision_pia_cb2_w ) |
| 378 | | { |
| 379 | | sn76489_ready = data & 0x01; |
| 380 | | } |
| 381 | | |
| 382 | 382 | static const pia6821_interface crvision_pia_intf = |
| 383 | 383 | { |
| 384 | 384 | DEVCB_HANDLER(crvision_pia_porta_r), // input A |
| 385 | 385 | DEVCB_HANDLER(crvision_pia_portb_r), // input B |
| 386 | | DEVCB_HANDLER(crvision_pia_ca1_r), // input CA1 (+5V) |
| 387 | | DEVCB_HANDLER(crvision_pia_cb1_r), // input CB1 (SN76489 pin READY ) |
| 388 | | DEVCB_HANDLER(crvision_pia_ca2_r), // input CA2 (+5V) |
| 389 | | DEVCB_NULL, // input CB2 |
| 386 | DEVCB_LINE(crvision_pia_ca_r), // input CA1 (+5V) |
| 387 | DEVCB_LINE(crvision_pia_cb1_r), // input CB1 (SN76489 pin READY ) |
| 388 | DEVCB_LINE(crvision_pia_ca_r), // input CA2 (+5V) |
| 389 | DEVCB_LINE(crvision_pia_ca_r), // input CB2 (+5V) |
| 390 | 390 | DEVCB_HANDLER(crvision_pia_porta_w), // output A |
| 391 | 391 | DEVCB_HANDLER(crvision_pia_portb_w), // output B (SN76489 pins D0-D7) |
| 392 | 392 | DEVCB_NULL, // output CA2 |
| 393 | | DEVCB_HANDLER(crvision_pia_cb2_w), // output CB2 (SN76489 pin CE_) |
| 393 | DEVCB_LINE(crvision_pia_cb2_w), // output CB2 (SN76489 pin CE_) |
| 394 | 394 | DEVCB_NULL, // irq A |
| 395 | 395 | DEVCB_NULL // irq B |
| 396 | 396 | }; |
| 397 | 397 | |
| 398 | | static MACHINE_START( crvision ) |
| 398 | static MACHINE_START( creativision ) |
| 399 | 399 | { |
| 400 | | state_save_register_global(machine, keylatch); |
| 401 | | state_save_register_global(machine, sn76489_ready); |
| 400 | crvision_state *state = machine->driver_data; |
| 402 | 401 | |
| 402 | /* find devices */ |
| 403 | state->sn76489 = devtag_get_device(machine, SN76489_TAG); |
| 404 | |
| 405 | /* register for state saving */ |
| 406 | state_save_register_global(machine, state->keylatch); |
| 407 | } |
| 408 | |
| 409 | static MACHINE_START( ntsc ) |
| 410 | { |
| 411 | MACHINE_START_CALL(creativision); |
| 412 | |
| 403 | 413 | TMS9928A_configure(&tms9918_intf); |
| 404 | 414 | } |
| 405 | 415 | |
| 406 | | static MACHINE_START( fnvision ) |
| 416 | static MACHINE_START( pal ) |
| 407 | 417 | { |
| 408 | | state_save_register_global(machine, keylatch); |
| 409 | | state_save_register_global(machine, sn76489_ready); |
| 418 | MACHINE_START_CALL(creativision); |
| 410 | 419 | |
| 411 | 420 | TMS9928A_configure(&tms9929_intf); |
| 412 | 421 | } |
| 413 | 422 | |
| 414 | | |
| 415 | 423 | static DEVICE_IMAGE_LOAD( crvision_cart ) |
| 416 | 424 | { |
| 417 | 425 | int size = image_length(image); |
| 418 | 426 | running_machine *machine = image->machine; |
| 419 | 427 | UINT8 *mem = memory_region(machine, M6502_TAG); |
| 428 | const address_space *program = cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM); |
| 420 | 429 | |
| 421 | 430 | switch (size) |
| 422 | 431 | { |
| 423 | 432 | case 0x1000: // 4K |
| 424 | 433 | image_fread(image, mem + 0x9000, 0x1000); |
| 425 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 434 | memory_install_read8_handler(program, 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 426 | 435 | break; |
| 427 | 436 | |
| 428 | 437 | case 0x1800: // 6K |
| 429 | 438 | image_fread(image, mem + 0x9000, 0x1000); |
| 430 | 439 | image_fread(image, mem + 0x8800, 0x0800); |
| 431 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 440 | memory_install_read8_handler(program, 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 432 | 441 | break; |
| 433 | 442 | |
| 434 | 443 | case 0x2000: // 8K |
| 435 | 444 | image_fread(image, mem + 0x8000, 0x2000); |
| 436 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 445 | memory_install_read8_handler(program, 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 437 | 446 | break; |
| 438 | 447 | |
| 439 | 448 | case 0x2800: // 10K |
| 440 | 449 | image_fread(image, mem + 0x8000, 0x2000); |
| 441 | 450 | image_fread(image, mem + 0x5800, 0x0800); |
| 442 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 443 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x4000, 0x5fff, 0, 0x2000, SMH_BANK2); |
| 451 | memory_install_read8_handler(program, 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 452 | memory_install_read8_handler(program, 0x4000, 0x5fff, 0, 0x2000, SMH_BANK2); |
| 444 | 453 | break; |
| 445 | 454 | |
| 446 | 455 | case 0x3000: // 12K |
| 447 | 456 | image_fread(image, mem + 0x8000, 0x2000); |
| 448 | 457 | image_fread(image, mem + 0x5000, 0x1000); |
| 449 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 450 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x4000, 0x5fff, 0, 0x2000, SMH_BANK2); |
| 458 | memory_install_read8_handler(program, 0x8000, 0x9fff, 0, 0x2000, SMH_BANK1); |
| 459 | memory_install_read8_handler(program, 0x4000, 0x5fff, 0, 0x2000, SMH_BANK2); |
| 451 | 460 | break; |
| 452 | 461 | |
| 453 | 462 | case 0x4000: // 16K |
| 454 | 463 | image_fread(image, mem + 0xa000, 0x2000); |
| 455 | 464 | image_fread(image, mem + 0x8000, 0x2000); |
| 456 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_BANK1); |
| 465 | memory_install_read8_handler(program, 0x8000, 0xbfff, 0, 0, SMH_BANK1); |
| 457 | 466 | break; |
| 458 | 467 | |
| 459 | 468 | case 0x4800: // 18K |
| 460 | 469 | image_fread(image, mem + 0xa000, 0x2000); |
| 461 | 470 | image_fread(image, mem + 0x8000, 0x2000); |
| 462 | 471 | image_fread(image, mem + 0x4800, 0x0800); |
| 463 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x8000, 0x8fff, 0, 0, SMH_BANK1); |
| 464 | | memory_install_read8_handler(cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM), 0x4000, 0x4fff, 0, 0x3000, SMH_BANK2); |
| 472 | memory_install_read8_handler(program, 0x8000, 0x8fff, 0, 0, SMH_BANK1); |
| 473 | memory_install_read8_handler(program, 0x4000, 0x4fff, 0, 0x3000, SMH_BANK2); |
| 465 | 474 | break; |
| 466 | 475 | |
| 467 | 476 | default: |
| r4585 | r4586 | |
| 479 | 488 | |
| 480 | 489 | /* Machine Driver */ |
| 481 | 490 | |
| 482 | | static MACHINE_DRIVER_START( crvision ) |
| 483 | | // basic machine hardware |
| 484 | | MDRV_CPU_ADD(M6502_TAG, M6502, 2000000) |
| 491 | static const cassette_config crvision_cassette_config = |
| 492 | { |
| 493 | cassette_default_formats, |
| 494 | NULL, |
| 495 | CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED |
| 496 | }; |
| 497 | |
| 498 | static MACHINE_DRIVER_START( creativision ) |
| 499 | MDRV_DRIVER_DATA(crvision_state) |
| 500 | |
| 501 | /* basic machine hardware */ |
| 502 | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_2MHz) |
| 485 | 503 | MDRV_CPU_PROGRAM_MAP(crvision_map, 0) |
| 486 | 504 | MDRV_CPU_VBLANK_INT(SCREEN_TAG, crvision_int) |
| 487 | 505 | |
| 488 | | MDRV_MACHINE_START( crvision ) |
| 489 | | |
| 490 | | // video hardware |
| 491 | | MDRV_IMPORT_FROM(tms9928a) |
| 492 | | MDRV_SCREEN_MODIFY(SCREEN_TAG) |
| 493 | | MDRV_SCREEN_REFRESH_RATE(10738635.0/2/342/262) |
| 494 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 495 | | |
| 496 | | MDRV_PIA6821_ADD( "pia", crvision_pia_intf ) |
| 497 | | |
| 498 | | // sound hardware |
| 506 | /* sound hardware */ |
| 499 | 507 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 500 | | MDRV_SOUND_ADD("sn76489", SN76489, 2000000) |
| 508 | MDRV_SOUND_ADD(SN76489_TAG, SN76489, XTAL_2MHz) |
| 501 | 509 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 502 | 510 | |
| 503 | | MDRV_CASSETTE_ADD( "cassette", default_cassette_config ) |
| 511 | /* peripheral hardware */ |
| 512 | MDRV_PIA6821_ADD(PIA6821_TAG, crvision_pia_intf) |
| 504 | 513 | |
| 505 | 514 | /* cartridge */ |
| 506 | 515 | MDRV_CARTSLOT_ADD("cart") |
| 507 | 516 | MDRV_CARTSLOT_EXTENSION_LIST("bin,rom") |
| 508 | 517 | MDRV_CARTSLOT_MANDATORY |
| 509 | 518 | MDRV_CARTSLOT_LOAD(crvision_cart) |
| 519 | |
| 520 | /* cassette */ |
| 521 | MDRV_CASSETTE_ADD("cassette", crvision_cassette_config) |
| 510 | 522 | MACHINE_DRIVER_END |
| 511 | 523 | |
| 512 | | static MACHINE_DRIVER_START( fnvision ) |
| 513 | | MDRV_IMPORT_FROM( crvision ) |
| 514 | | MDRV_MACHINE_START( fnvision ) |
| 524 | static MACHINE_DRIVER_START( ntsc ) |
| 525 | MDRV_IMPORT_FROM(creativision) |
| 526 | |
| 527 | MDRV_MACHINE_START(ntsc) |
| 528 | |
| 529 | /* video hardware */ |
| 530 | MDRV_IMPORT_FROM(tms9928a) |
| 515 | 531 | MDRV_SCREEN_MODIFY(SCREEN_TAG) |
| 516 | | MDRV_SCREEN_REFRESH_RATE(10738635.0/2/342/313) |
| 532 | MDRV_SCREEN_REFRESH_RATE((float)XTAL_10_738635MHz/2/342/262) |
| 533 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 534 | MACHINE_DRIVER_END |
| 517 | 535 | |
| 518 | | MDRV_CASSETTE_REMOVE( "cassette" ) |
| 536 | static MACHINE_DRIVER_START( pal ) |
| 537 | MDRV_IMPORT_FROM(creativision) |
| 538 | |
| 539 | MDRV_MACHINE_START(pal) |
| 540 | |
| 541 | /* video hardware */ |
| 542 | MDRV_IMPORT_FROM(tms9928a) |
| 543 | MDRV_SCREEN_MODIFY(SCREEN_TAG) |
| 544 | MDRV_SCREEN_REFRESH_RATE((float)XTAL_10_738635MHz/2/342/313) |
| 545 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 519 | 546 | MACHINE_DRIVER_END |
| 520 | 547 | |
| 521 | 548 | /* ROMs */ |
| 522 | 549 | |
| 523 | 550 | ROM_START( crvision ) |
| 524 | 551 | ROM_REGION( 0x10000, M6502_TAG, 0 ) |
| 525 | | ROM_LOAD( "crvision.rom", 0xc000, 0x0800, CRC(c3c590c6) SHA1(5ac620c529e4965efb5560fe824854a44c983757) ) |
| 552 | ROM_LOAD( "crvision.u20", 0xc000, 0x0800, CRC(c3c590c6) SHA1(5ac620c529e4965efb5560fe824854a44c983757) ) |
| 526 | 553 | ROM_END |
| 527 | 554 | |
| 528 | 555 | ROM_START( fnvision ) |
| r4585 | r4586 | |
| 530 | 557 | ROM_LOAD( "funboot.rom", 0xc000, 0x0800, CRC(05602697) SHA1(c280b20c8074ba9abb4be4338b538361dfae517f) ) |
| 531 | 558 | ROM_END |
| 532 | 559 | |
| 560 | #define rom_crvisiop rom_crvision |
| 561 | #define rom_wizzard rom_crvision |
| 562 | #define rom_rameses rom_crvision |
| 563 | #define rom_vz2000 rom_crvision |
| 564 | #define rom_crvisio2 rom_crvision |
| 565 | |
| 533 | 566 | /* System Drivers */ |
| 534 | 567 | |
| 535 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 536 | | COMP( 1981, crvision, 0, 0, crvision, crvision, 0, 0, "Video Technology", "CreatiVision (NTSC)", GAME_SUPPORTS_SAVE ) |
| 537 | | CONS( 1983, fnvision, crvision, 0, fnvision, crvision, 0, 0, "Video Technology", "FunVision Computer Video Games System (PAL)", GAME_SUPPORTS_SAVE ) |
| 568 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 569 | COMP( 1982, crvision, 0, 0, ntsc, crvision, 0, 0, "Cheryco", "CreatiVision (Japan)", GAME_SUPPORTS_SAVE ) |
| 570 | CONS( 1982, crvisiop, crvision, 0, pal, crvision, 0, 0, "Video Technology", "CreatiVision", GAME_SUPPORTS_SAVE ) |
| 571 | CONS( 1982, fnvision, crvision, 0, pal, crvision, 0, 0, "Video Technology", "FunVision", GAME_SUPPORTS_SAVE ) |
| 572 | CONS( 1982, wizzard, crvision, 0, pal, crvision, 0, 0, "Dick Smith Electronics", "Wizzard (Australia)", GAME_SUPPORTS_SAVE ) |
| 573 | CONS( 1982, rameses, crvision, 0, pal, crvision, 0, 0, "Hanimex", "Rameses (Australia)", GAME_SUPPORTS_SAVE ) |
| 574 | CONS( 1983, vz2000, crvision, 0, pal, crvision, 0, 0, "Dick Smith Electronics", "VZ 2000 (Australia)", GAME_SUPPORTS_SAVE ) |
| 575 | CONS( 1983, crvisio2, crvision, 0, pal, crvision, 0, 0, "Sanyo Video", "CreatiVision MK-II (Germany)", GAME_SUPPORTS_SAVE ) |