void betadisk_clear_status(device_t *device) { beta_disk_state *beta = get_safe_token(device); beta->betadisk_status = 0; }
static DEVICE_RESET( ym2608 ) { ym2608_state *info = get_safe_token(device); ym2608_reset_chip(info->chip); }
static TIMER_CALLBACK( namco_53xx_irq_clear ) { namco_53xx_state *state = get_safe_token((running_device *)ptr); cpu_set_input_line(state->cpu, 0, CLEAR_LINE); }
static void pandora_draw( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect ) { kaneko_pandora_state *pandora = get_safe_token(device); int sx = 0, sy = 0, x = 0, y = 0, offs; /* * Sprite Tile Format * ------------------ * * Byte | Bit(s) | Use * -----+-76543210-+---------------- * 0-2 | -------- | unused * 3 | xxxx.... | Palette Bank * 3 | .......x | XPos - Sign Bit * 3 | ......x. | YPos - Sign Bit * 3 | .....x.. | Use Relative offsets * 4 | xxxxxxxx | XPos * 5 | xxxxxxxx | YPos * 6 | xxxxxxxx | Sprite Number (low 8 bits) * 7 | ....xxxx | Sprite Number (high 4 bits) * 7 | x....... | Flip Sprite Y-Axis * 7 | .x...... | Flip Sprite X-Axis */ for (offs = 0; offs < 0x1000; offs += 8) { int dx = pandora->spriteram[offs + 4]; int dy = pandora->spriteram[offs + 5]; int tilecolour = pandora->spriteram[offs + 3]; int attr = pandora->spriteram[offs + 7]; int flipx = attr & 0x80; int flipy = (attr & 0x40) << 1; int tile = ((attr & 0x3f) << 8) + (pandora->spriteram[offs + 6] & 0xff); if (tilecolour & 1) dx |= 0x100; if (tilecolour & 2) dy |= 0x100; if (tilecolour & 4) { x += dx; y += dy; } else { x = dx; y = dy; } if (flip_screen_get(device->machine())) { sx = 240 - x; sy = 240 - y; flipx = !flipx; flipy = !flipy; } else { sx = x; sy = y; } /* global offset */ sx += pandora->xoffset; sy += pandora->yoffset; sx &= 0x1ff; sy &= 0x1ff; if (sx & 0x100) sx -= 0x200; if (sy & 0x100) sy -= 0x200; drawgfx_transpen(bitmap,cliprect,device->machine().gfx[pandora->region], tile, (tilecolour & 0xf0) >> 4, flipx, flipy, sx,sy,0); } }
void pandora_set_clear_bitmap( device_t *device, int clear ) { kaneko_pandora_state *pandora = get_safe_token(device); pandora->clear_bitmap = clear; }
static DEVICE_STOP( ym3526 ) { ym3526_state *info = get_safe_token(device); ym3526_shutdown(info->chip); }
static DEVICE_RESET( mb3773 ) { mb3773_state *mb3773 = get_safe_token(device); mb3773->ck = 0; }
void mc6843_set_index_pulse ( device_t *device, int index_pulse ) { mc6843_t* mc6843 = get_safe_token( device ); mc6843->index_pulse = index_pulse; }
static WRITE8_HANDLER( namco_52xx_P_w ) { namco_52xx_state *state = get_safe_token(space->cpu->owner()); discrete_sound_w(state->discrete, NAMCO_52XX_P_DATA(state->basenode), data & 0x0f); }
void mc6843_set_drive( device_t *device, int drive ) { mc6843_t* mc6843 = get_safe_token( device ); mc6843->drive = drive; }
void mc6843_set_side( device_t *device, int side ) { mc6843_t* mc6843 = get_safe_token( device ); mc6843->side = side; }
static device_t* mc6843_floppy_image ( device_t *device ) { mc6843_t* mc6843 = get_safe_token( device ); return floppy_get_device( device->machine(), mc6843->drive ); }
int *svision_dma_finished(device_t *device) { svision_sound_state *state = get_safe_token(device); return &state->dma.finished; }
static STREAM_UPDATE( svision_update ) { svision_sound_state *state = get_safe_token(device); stream_sample_t *left=outputs[0], *right=outputs[1]; int i, j; SVISION_CHANNEL *channel; for (i = 0; i < samples; i++, left++, right++) { *left = 0; *right = 0; for (channel=state->channel, j=0; j<ARRAY_LENGTH(state->channel); j++, channel++) { if (channel->size != 0) { if (channel->on||channel->count) { int on = FALSE; switch (channel->waveform) { case 0: on = channel->pos <= (28 * channel->size) >> 5; break; case 1: on = channel->pos <= (24 * channel->size) >> 5; break; default: case 2: on = channel->pos <= channel->size / 2; break; case 3: on = channel->pos <= (9 * channel->size) >> 5; break; } { INT16 s = on ? channel->volume << 8 : 0; if (j == 0) *right += s; else *left += s; } } channel->pos++; if (channel->pos >= channel->size) channel->pos = 0; } } if (state->noise.on && (state->noise.play || state->noise.count)) { INT16 s = (state->noise.value ? 1 << 8: 0) * state->noise.volume; int b1, b2; if (state->noise.left) *left += s; if (state->noise.right) *right += s; state->noise.pos += state->noise.step; if (state->noise.pos >= 1.0) { switch (state->noise.type) { case SVISION_NOISE_Type7Bit: state->noise.value = state->noise.state & 0x40 ? 1 : 0; b1 = (state->noise.state & 0x40) != 0; b2 = (state->noise.state & 0x20) != 0; state->noise.state=(state->noise.state<<1)+(b1!=b2?1:0); break; case SVISION_NOISE_Type14Bit: default: state->noise.value = state->noise.state & 0x2000 ? 1 : 0; b1 = (state->noise.state & 0x2000) != 0; b2 = (state->noise.state & 0x1000) != 0; state->noise.state = (state->noise.state << 1) + (b1 != b2 ? 1 : 0); } state->noise.pos -= 1; } } if (state->dma.on) { UINT8 sample; INT16 s; UINT16 addr = state->dma.start + (unsigned) state->dma.pos / 2; if (addr >= 0x8000 && addr < 0xc000) { sample = device->machine().region("user1")->base()[(addr & 0x3fff) | state->dma.ca14to16]; } else { sample = device->machine().device("maincpu")->memory().space(AS_PROGRAM)->read_byte(addr); } if (((unsigned)state->dma.pos) & 1) s = (sample & 0xf); else s = (sample & 0xf0) >> 4; s <<= 8; if (state->dma.left) *left += s; if (state->dma.right) *right += s; state->dma.pos += state->dma.step; if (state->dma.pos >= state->dma.size) { state->dma.finished = TRUE; state->dma.on = FALSE; svision_irq(device->machine()); } }
/* generate sound to the mix buffer in mono */ static STREAM_UPDATE( gomoku_update_mono ) { gomoku_sound_state *state = get_safe_token(device); stream_sample_t *buffer = outputs[0]; sound_channel *voice; short *mix; int i, ch; /* if no sound, we're done */ if (state->m_sound_enable == 0) { memset(buffer, 0, samples * sizeof(*buffer)); return; } /* zap the contents of the mixer buffer */ memset(state->m_mixer_buffer, 0, samples * sizeof(short)); /* loop over each voice and add its contribution */ for (ch = 0, voice = state->m_channel_list; voice < state->m_last_channel; ch++, voice++) { int f = 16 * voice->frequency; int v = voice->volume; /* only update if we have non-zero volume and frequency */ if (v && f) { int w_base; int c = voice->counter; if (ch < 3) w_base = 0x20 * (state->m_soundregs1[0x06 + (ch * 8)] & 0x0f); else w_base = 0x100 * (state->m_soundregs2[0x1d] & 0x0f); mix = state->m_mixer_buffer; /* add our contribution */ for (i = 0; i < samples; i++) { c += f; if (ch < 3) { int offs = w_base | ((c >> 16) & 0x1f); /* use full byte, first the high 4 bits, then the low 4 bits */ if (c & 0x8000) *mix++ += ((state->m_sound_rom[offs] & 0x0f) - 8) * v; else *mix++ += (((state->m_sound_rom[offs]>>4) & 0x0f) - 8) * v; } else { int offs = (w_base + (c >> 16)) & 0x0fff; if (state->m_sound_rom[offs] == 0xff) { voice->oneshotplaying = 0; } if (voice->oneshotplaying) { /* use full byte, first the high 4 bits, then the low 4 bits */ if (c & 0x8000) *mix++ += ((state->m_sound_rom[offs] & 0x0f) - 8) * v; else *mix++ += (((state->m_sound_rom[offs]>>4) & 0x0f) - 8) * v; } } /* update the counter for this voice */ voice->counter = c; }
static WRITE8_HANDLER( namco_52xx_R3_w ) { namco_52xx_state *state = get_safe_token(space->cpu->owner()); state->address = (state->address & 0xff0f) | ((data & 0xf) << 4); }
void flt_volume_set_volume(device_t *device, float volume) { filter_volume_state *info = get_safe_token(device); info->gain = (int)(volume * 256); }
static TIMER_CALLBACK( external_clock_pulse ) { namco_52xx_state *state = get_safe_token((device_t *)ptr); mb88_external_clock_w(state->cpu, 1); mb88_external_clock_w(state->cpu, 0); }
static void reset_timer( running_device *device ) { mb3773_state *mb3773 = get_safe_token(device); timer_adjust_oneshot(mb3773->watchdog_timer, ATTOTIME_IN_SEC( 5 ), 0); }
static TIMER_CALLBACK( namco_52xx_latch_callback ) { namco_52xx_state *state = get_safe_token((device_t *)ptr); state->latched_cmd = param; }
static DEVICE_RESET( iremga20 ) { iremga20_reset(get_safe_token(device)); }
static READ8_HANDLER( namco_52xx_K_r ) { namco_52xx_state *state = get_safe_token(space->cpu->owner()); return state->latched_cmd & 0x0f; }
void pandora_set_bg_pen( device_t *device, int pen ) { kaneko_pandora_state *pandora = get_safe_token(device); pandora->bg_pen = pen; }
static READ8_HANDLER( namco_52xx_SI_r ) { namco_52xx_state *state = get_safe_token(space->cpu->owner()); return devcb_call_read8(&state->si, 0) ? 1 : 0; }
static DEVICE_STOP( ym2608 ) { ym2608_state *info = get_safe_token(device); ym2608_shutdown(info->chip); ay8910_stop_ym(info->psg); }
static READ8_HANDLER( namco_52xx_R1_r ) { namco_52xx_state *state = get_safe_token(space->cpu->owner()); return devcb_call_read8(&state->romread, state->address) >> 4; }
static WRITE8_HANDLER( namco_53xx_P_w ) { namco_53xx_state *state = get_safe_token(space->cpu->owner); devcb_call_write8(&state->p, 0, data); }
static CPU_EXECUTE( tms0980 ) { tms0980_state *cpustate = get_safe_token( device ); do { // debugger_instruction_hook( device, ( ( cpustate->pa << cpustate->pc_size ) | cpustate->pc ) << 1 ); cpustate->icount--; switch( cpustate->subcycle ) { case 0: /* fetch: rom address 0 */ /* execute: read ram, alu input, execute br/call, k input valid */ tms0980_set_cki_bus( device ); cpustate->ram_data = cpustate->data->read_byte( cpustate->ram_address ); cpustate->status = 1; cpustate->p = 0; cpustate->n = 0; cpustate->carry_in = 0; break; case 1: /* fetch: rom address 1 */ if ( cpustate->pc_size == 6 ) cpustate->rom_address = ( cpustate->pa << 6 ) | tms1000_pc_decode[ cpustate->pc ]; else cpustate->rom_address = ( cpustate->pa << 7 ) | cpustate->pc; /* execute: k input valid */ if ( cpustate->decode & MICRO_MASK ) { /* Check N inputs */ if ( cpustate->decode & ( M_15TN | M_ATN | M_CKN | M_MTN | M_NATN ) ) { cpustate->n = 0; if ( cpustate->decode & M_15TN ) { cpustate->n |= 0x0F; } if ( cpustate->decode & M_ATN ) { cpustate->n |= cpustate->a; } if ( cpustate->decode & M_CKN ) { cpustate->n |= cpustate->cki_bus; } if ( cpustate->decode & M_MTN ) { cpustate->n |= cpustate->ram_data; } if ( cpustate->decode & M_NATN ) { cpustate->n |= ( ( ~cpustate->a ) & 0x0F ); } } /* Check P inputs */ if ( cpustate->decode & ( M_CKP | M_DMTP | M_MTP | M_NDMTP | M_YTP ) ) { cpustate->p = 0; if ( cpustate->decode & M_CKP ) { cpustate->p |= cpustate->cki_bus; } if ( cpustate->decode & M_DMTP ) { cpustate->p |= cpustate->dam; } if ( cpustate->decode & M_MTP ) { cpustate->p |= cpustate->ram_data; } if ( cpustate->decode & M_NDMTP ) { cpustate->p |= ( ( ~cpustate->dam ) & 0x0F ); } if ( cpustate->decode & M_YTP ) { cpustate->p |= cpustate->y; } } /* Carry In input */ if ( cpustate->decode & M_CIN ) { cpustate->carry_in = 1; } } break; case 2: /* fetch: nothing */ /* execute: write ram */ /* perform adder logic */ cpustate->adder_result = cpustate->p + cpustate->n + cpustate->carry_in; if ( cpustate->decode & MICRO_MASK ) { if ( cpustate->decode & M_NE ) { if ( cpustate->n == cpustate->p ) { cpustate->status = 0; } } if ( cpustate->decode & M_C8 ) { cpustate->status = cpustate->adder_result >> 4; } if ( cpustate->decode & M_STO ) { cpustate->data->write_byte( cpustate->ram_address, cpustate->a ); } if ( cpustate->decode & M_CKM ) { cpustate->data->write_byte( cpustate->ram_address, cpustate->cki_bus ); } } else { if ( cpustate->decode & F_SBIT ) { cpustate->data->write_byte( cpustate->ram_address, cpustate->ram_data | tms0980_bit_value[ cpustate->opcode & 0x03 ] ); } if ( cpustate->decode & F_RBIT ) { cpustate->data->write_byte( cpustate->ram_address, cpustate->ram_data & tms0980_nbit_value[ cpustate->opcode & 0x03 ] ); } if ( cpustate->decode & F_SETR ) { cpustate->r = cpustate->r | ( 1 << cpustate->y ); if ( cpustate->config->write_r ) { cpustate->config->write_r( device, 0, cpustate->r & cpustate->r_mask, 0xffff ); } } if ( cpustate->decode & F_RSTR ) { cpustate->r = cpustate->r & ( ~( 1 << cpustate->y ) ); if ( cpustate->config->write_r ) { cpustate->config->write_r( device, 0, cpustate->r & cpustate->r_mask, 0xffff ); } } if ( cpustate->decode & F_TDO ) { int i = 0; /* Calculate O-outputs based on status latch, A, and the output PLA configuration */ cpustate->o = 0; for ( i = 0; i < 20; i++ ) { if ( ( ( cpustate->status_latch << 4 ) | cpustate->a ) == cpustate->config->o_pla[i].value ) { cpustate->o = cpustate->config->o_pla[i].output; } } if ( cpustate->config->write_o ) { cpustate->config->write_o( device, 0, cpustate->o & cpustate->o_mask, 0xffff ); } } if ( cpustate->decode & F_CLO ) { cpustate->o = 0; if ( cpustate->config->write_o ) { cpustate->config->write_o( device, 0, cpustate->o & cpustate->o_mask, 0xffff ); } } if ( cpustate->decode & F_LDX ) { cpustate->x = tms0980_c2_value[ cpustate->opcode & 0x03 ]; } if ( cpustate->decode & F_COMX ) { cpustate->x = cpustate->x ^ 0x03; } if ( cpustate->decode & F_COMC ) { cpustate->cb = cpustate->cb ^ 0x01; } if ( cpustate->decode & F_LDP ) { cpustate->pb = tms0980_c4_value[ cpustate->opcode & 0x0F ]; } if ( cpustate->decode & F_REAC ) { cpustate->special_status = 0; } if ( cpustate->decode & F_SEAC ) { cpustate->special_status = 1; } if ( cpustate->decode == F_SAL ) { cpustate->add_latch = 1; } if ( cpustate->decode == F_SBL ) { cpustate->branch_latch = 1; } } break; case 3: /* fetch: fetch, update pc, ram address */ /* execute: register store */ break; case 4: /* execute: register store */ if ( cpustate->decode & MICRO_MASK ) { if ( cpustate->decode & M_AUTA ) { cpustate->a = cpustate->adder_result & 0x0F; } if ( cpustate->decode & M_AUTY ) { cpustate->y = cpustate->adder_result & 0x0F; } if ( cpustate->decode & M_STSL ) { cpustate->status_latch = cpustate->status; } } /* fetch: fetch, update pc, ram address */ if ( cpustate->byte_size > 8 ) { debugger_instruction_hook( device, cpustate->rom_address << 1 ); cpustate->opcode = cpustate->program->read_word( cpustate->rom_address << 1 ) & 0x1FF; } else { debugger_instruction_hook( device, cpustate->rom_address ); cpustate->opcode = cpustate->program->read_word( cpustate->rom_address ) & 0xFF; } tms0980_next_pc( cpustate ); if (LOG) logerror( "tms0980: read opcode %04x from %04x. Set pc to %04x\n", cpustate->opcode, cpustate->rom_address, cpustate->pc ); /* ram address */ cpustate->ram_address = ( cpustate->x << 4 ) | cpustate->y; break; case 5: /* fetch: instruction decode */ cpustate->decode = cpustate->decode_table[ cpustate->opcode ]; /* execute: execute br/call */ if ( cpustate->status ) { if ( cpustate->decode == F_BR ) { if ( cpustate->call_latch == 0 ) { cpustate->pa = cpustate->pb; } cpustate->pc = cpustate->opcode & ( ( 1 << cpustate->pc_size ) - 1 ); } if ( cpustate->decode == F_CALL ) { UINT8 t = cpustate->pa; if ( cpustate->call_latch == 0 ) { cpustate->sr = cpustate->pc; cpustate->call_latch = 1; cpustate->pa = cpustate->pb; } cpustate->pb = t; cpustate->pc = cpustate->opcode & ( ( 1 << cpustate->pc_size ) - 1 ); } } if ( cpustate->decode == F_RETN ) { if ( cpustate->call_latch == 1 ) { cpustate->pc = cpustate->sr; cpustate->call_latch = 0; } cpustate->add_latch = 0; cpustate->pa = cpustate->pb; } else { cpustate->branch_latch = 0; } break; }
static READ8_HANDLER( namco_53xx_Rx_r ) { namco_53xx_state *state = get_safe_token(space->cpu->owner); return devcb_call_read8(&state->in[offset], 0); }
void betadisk_disable(device_t *device) { beta_disk_state *beta = get_safe_token(device); beta->betadisk_active = 0; }