int main(int argc, char *argv[]) { const char *filename_wav, *filename_png; kiss_fftr_cfg fft; int err = 0; for (;;) { const int c = getopt(argc, argv, "h"); if (0 > c) break; switch (c) { case '?': err = EINVAL; /*@fallthrough@*/ case 'h': usage(); return err; } } if (argc < 3 || argc != (optind + 2)) { usage(); return -EINVAL; } filename_wav = argv[optind++]; filename_png = argv[optind++]; fft = kiss_fftr_alloc(NUM_FFT, 0, 0, 0); if (!fft) { err = ENOMEM; goto out; } err = read_wav(fft, filename_wav); if (err) goto out; err = plot_spectrum(filename_png); if (err) goto out; out: if (fft) kiss_fftr_free(fft); tmr_debug(); mem_debug(); return err; }
Mod::Mod(tl::FsNode& root) { auto sprite_dir = root / "sprites"_S; auto sound_dir = root / "sounds"_S; this->large_sprites = read_full_tga((sprite_dir / "large.tga"_S).try_get_source(), &this->pal); this->small_sprites = read_full_tga((sprite_dir / "small.tga"_S).try_get_source()); this->small_font_sprites = read_full_tga((sprite_dir / "text.tga"_S).try_get_source()); //this->font_sprites = read_full_tga((sprite_dir / "font.tga"_S).try_get_source(), &this->pal); tl::Palette dummyPal; tl::read_tga((sprite_dir / "font.tga"_S).try_get_source(), this->font_sprites, dummyPal); worm_sprites[0] = tl::Image(16, 7 * 3 * 16, 4); worm_sprites[1] = tl::Image(16, 7 * 3 * 16, 4); muzzle_fire_sprites[0] = tl::Image(16, 7 * 16, 4); muzzle_fire_sprites[1] = tl::Image(16, 7 * 16, 4); auto worms = large_sprites.crop(tl::RectU(0, 16 * 16, 16, 16 * (16 + 7 * 3))); worm_sprites[0].blit(worms); worm_sprites[1].blit(worms, 0, 0, 0, tl::ImageSlice::Flip); auto muzzle_fire = large_sprites.crop(tl::RectU(0, 16 * 9, 16, 16 * (9 + 7))); muzzle_fire_sprites[0].blit(muzzle_fire); muzzle_fire_sprites[1].blit(muzzle_fire, 0, 0, 0, tl::ImageSlice::Flip); { for (u32 y = 0; y < this->large_sprites.height(); ++y) { LargeSpriteRow row = {0, 0}; for (u32 x = 0; x < 16; ++x) { auto p = tl::Color(this->large_sprites.unsafe_pixel32(x, y)); bool draw = p.a() > 0; bool half = p.a() == 1 || p.a() == 2; bool bit0 = draw; bool bit1 = !(!draw || half); row.bit0 |= bit0 << x; row.bit1 |= bit1 << x; } this->large_sprites_bits.push_back(row); } } auto r = (root / "tc.dat"_S); auto src = r.try_get_source(); auto buf = src.read_all(); ss::Expander expander(buf); //auto* tc = expander.expand_root<TcData>(*(ss::StructOffset<TcDataReader> const*)buf.begin()); auto* tc = (liero::TcData *)expander.expand(liero::TcData::expand_program(), buf.begin()); this->tcdata = tc; this->weapon_types = tc->weapons().begin(); this->level_effects = tc->level_effects().begin(); this->nobject_types = tc->nobjects().begin(); this->sobject_types = tc->sobjects().begin(); for (auto& sound_name : tc->sound_names()) { tl::Vec<i16> sound_data; read_wav((sound_dir / sound_name.get()).try_get_source(), sound_data); this->sounds.push_back(move(sound_data)); } this->mod_data = expander.to_buffer(); }