DttSP_EXP void process_samples_thread (unsigned int proc_thread) { while (top[proc_thread].running) { sem_wait (&top[proc_thread].sync.buf.sem); do { gethold(proc_thread); sem_wait (&top[proc_thread].sync.upd.sem); switch (top[proc_thread].state) { case RUN_MUTE: run_mute (proc_thread); break; case RUN_PASS: run_pass (proc_thread); break; case RUN_PLAY: run_play (proc_thread); break; case RUN_SWCH: run_swch (proc_thread); break; } sem_post (&top[proc_thread].sync.upd.sem); } while (canhold (proc_thread)); } }
int main(void) { unsigned char idle = 0; // the crt has disabled interrupts before main is called // z88dk tracks the border colour so that beeper audio does not change the border colour while playing. // (this project contains a 3rd party ntropic player that does not obey z88dk convention so we set the border to same colour) zx_border(INK_BLACK); // set up the block memory allocator with one queue // max size requested by sp1 will be 24 bytes or block size of 25 (+1 for overhead) balloc_reset(0); // make queue 0 empty balloc_addmem(0, sizeof(block_of_ram)/25, 24, block_of_ram); // add free memory from bss section balloc_addmem(0, 8, 24, (void *)0xd101); // another eight from an unused area // interrupt mode 2 setup_int(); // sp1.lib sp1_Initialize(SP1_IFLAG_MAKE_ROTTBL | SP1_IFLAG_OVERWRITE_TILES | SP1_IFLAG_OVERWRITE_DFILE, INK_BLACK | PAPER_BLACK, ' '); // sp1_Validate(&cr); // not necessary since sp1_Initialize will not mark screen for update ps0.bounds = &cr; ps0.flags = SP1_PSSFLAG_INVALIDATE; ps0.visit = 0; intrinsic_ei(); // setup our font pt = font; for (i = 0; i < 96; ++i, pt += 8) sp1_TileEntry(32 + i, pt); // setup the bg tiles pt = tiles; for (i = 0; i < TILES_LEN; ++i, pt += 8) sp1_TileEntry(TILES_BASE + i, pt); init_sprites(); draw_menu(); srand(tick); // 256 different games are possible while(1) { key = in_inkey(); if (key) { if (key == '4') { playfx(FX_SELECT); in_wait_nokey(); run_redefine_keys(); idle = 0; draw_menu(); } if (key == '1' || key == '2' || key == '3') { playfx(FX_SELECT); joy_k.left = in_key_scancode(keys[0]); joy_k.right = in_key_scancode(keys[1]); // we don't use up/down in this game joy_k.down = in_key_scancode(keys[0]); joy_k.up = in_key_scancode(keys[1]); joy_k.fire = in_key_scancode(keys[2]); if (key == '1') joyfunc = (JOYFUNC)in_stick_keyboard; if (key == '2') joyfunc = (JOYFUNC)in_stick_kempston; if (key == '3') joyfunc = (JOYFUNC)in_stick_sinclair1; // run game run_intro(); run_play(); idle = 0; draw_menu(); } } if (idle++ == 255) { // go back to the welcome screen after a while // if the player doesn't do anything idle = 0; draw_menu(); } wait(); sp1_UpdateNow(); } }