Resource::Resource(string name, int sprite, int color) { if (name.length() > 6) oslDebug("Name cannot be longer than six characters!"); this->name = name; this->sprite = sprite; this->color = color; }
void input_gym::calc_gym_time_length(SONGINFO* info) { if (gym_start == 0 || gym_size == 0) { oslDebug("GYM not initialized properly for length calculation!"); } int loop, num_zeros = 0; for(loop = 0; loop < gym_size; loop++) { switch(gym_start[loop]) { case(0x00): num_zeros++; continue; case(0x01): loop += 2; continue; case(0x02): loop += 2; continue; case(0x03): loop += 1; continue; } } song_length = num_zeros / fnum(60.0) * fnum(1000.0); if (gym_loop) { loop_length = (song_length - gym_loop / fnum(60.0) * fnum(1000.0)); gym_length = song_length + cfg_num_loop * loop_length; gym_length_with_fade = gym_length + fnum(1000.0) * cfg_fade_length; } else { loop_length = fnum(0.0); gym_length = gym_length_with_fade = song_length; } info->set_length(gym_length_with_fade / fnum(1000.0)); }
char input_gym::open(CFILE * r, SONGINFO * info, unsigned int flags) //multiinstance safety ? { if (!open_file(r,info,flags)) return 0; // if (!(flags & OPEN_FLAG_DECODE)) return 1; char failed = false; // g_decoder_sync.enter(); if (g_decoder == 0) g_decoder = this; else if (g_decoder!=this) failed = true; // g_decoder_sync.leave(); if (failed) { oslDebug("GYM decoder does not support multiple instances; please stop other decoding processes and try again"); return 0; } void *gymFile = gym_backup.get_ptr(); if (!gym_loaded) { if (gym_tag) { if (gym_tag -> compressed) { if (memcmp((char *)((int)gymFile + sizeof(GYMTAG)), "EZPK", 4) == 0) { // EZPK-compressed if (!load_ezpk_gym(gymFile)) return 0; } else { // standard zlib-compressed if (!load_zlib_gym(gymFile)) return 0; } } else { // not compressed gym_start = (unsigned char *)gymFile + sizeof(GYMTAG); gym_size = gym_backup.get_size() - sizeof(GYMTAG); } } else { // no tag, assume not compressed gym_start = (unsigned char *)gymFile; gym_size = gym_backup.get_size(); } gym_loaded = true; } gym_pos = gym_start; YM2612_Enable = cfg_ym2612_enable; YM2612_Improv = cfg_ym2612_interp; Chan_Enable[0] = cfg_chan1_enable; Chan_Enable[1] = cfg_chan2_enable; Chan_Enable[2] = cfg_chan3_enable; Chan_Enable[3] = cfg_chan4_enable; Chan_Enable[4] = cfg_chan5_enable; Chan_Enable[5] = cfg_chan6_enable; DAC_Enable = cfg_dac_enable; PSG_Enable = cfg_psg_enable; PSG_Improv = cfg_psg_interp; PSG_Chan_Enable[0] = cfg_psg_chan1_enable; PSG_Chan_Enable[1] = cfg_psg_chan2_enable; PSG_Chan_Enable[2] = cfg_psg_chan3_enable; PSG_Chan_Enable[3] = cfg_psg_chan4_enable; playingSampleRate = cfg_samplerate; Start_Play_GYM(playingSampleRate); // sample_buffer.check_size(Seg_Lenght << 2); sample_buffer.new_block(Seg_Lenght << 2); return 1; }