int coleco_init(int video_system) { int i; float tmp; int region = SMS_REGION_EXPORT; if(video_system == SMS_VIDEO_NTSC) { tmp = NTSC_Z80_CLOCK / PSG_DIVISOR / NTSC_FPS / NTSC_LINES_PER_FRAME / NTSC_CLOCKS_PER_SAMPLE; for(i = 0; i < NTSC_LINES_PER_FRAME; ++i) { psg_samples[i] = (uint32) (tmp * (i + 1)) - (uint32) (tmp * i); } /* We end up generating 734 samples per frame @ 44100 Hz, 60fps, but we need 735. */ psg_samples[261] += 1; region |= SMS_VIDEO_NTSC; sn76489_init(&psg, NTSC_Z80_CLOCK, 44100.0f, SN76489_NOISE_BITS_NORMAL, SN76489_NOISE_TAPPED_NORMAL); } else { tmp = PAL_Z80_CLOCK / PSG_DIVISOR / PAL_FPS / PAL_LINES_PER_FRAME / PAL_CLOCKS_PER_SAMPLE; for(i = 0; i < PAL_LINES_PER_FRAME; ++i) { psg_samples[i] = (uint32) (tmp * (i + 1)) - (uint32) (tmp * i); } /* We need 882 samples per frame @ 44100 Hz, 50fps. */ region |= SMS_VIDEO_PAL; sn76489_init(&psg, PAL_Z80_CLOCK, 44100.0f, SN76489_NOISE_BITS_NORMAL, SN76489_NOISE_TAPPED_NORMAL); } sms_region = region; gui_set_console((console_t *)&colecovision_cons); coleco_mem_init(); sms_vdp_init(video_system, 0); sms_z80_init(); sound_init(2, video_system); sms_z80_set_pread(&coleco_port_read); sms_z80_set_pwrite(&coleco_port_write); cycles_run = cycles_to_run = scanline = 0; colecovision_cons._base.initialized = 1; return 0; }
void *pssj_init(const device_t *info) { pssj_t *pssj = malloc(sizeof(pssj_t)); memset(pssj, 0, sizeof(pssj_t)); sn76489_init(&pssj->sn76489, 0x00c0, 0x0004, PSSJ, 3579545); io_sethandler(0x00C4, 0x0004, pssj_read, NULL, NULL, pssj_write, NULL, NULL, pssj); timer_add(pssj_callback, &pssj->timer_count, &pssj->enable, pssj); sound_add_handler(pssj_get_buffer, pssj); return pssj; }