void setup(void) { // Initialize Sega VDP VDP_init(); // Configure the screen with to 40 columns VDP_setScreenWidth320(); // Configure background planes to be 64 x 32 cells VDP_setPlanSize(64,32); // Initialize column text output (DMA graphic tiles) col_init(); // Disable interrupts during configuration SYS_disableInts(); // Allow all three interrupts SYS_setInterruptMaskLevel(0); // Set pointers to interrupt service routines SYS_setVIntCallback((_voidCallback *)v_int); SYS_setHIntCallback((_voidCallback *)h_int); // Now we can enable interrupts SYS_enableInts(); // Configure the screen with to 40 columns VDP_setScreenWidth320(); // Configure background planes to be 64 x 32 cells VDP_setPlanSize(64,32); }
int main() { VDP_setScreenWidth320(); Vector2D speed = { FIX32(0.2), FIX32(0.2) }; Vector2D position = { FIX32( 1), FIX32( 1) }; // Init joy handler JOY_init(); JOY_setEventHandler( &joyAtkHandler ); // Under construction // SPR_init( (4 * 8) + (3 * 3 * 9) ); // Knighty is 2x2 tiles and 8 frames, Wizard is 3x3 and 9 frames SPR_init( (4 * 8) + (3 * 3 * 9) ); draw_arena(); init_player_wizard(140, 128); init_player_knighty(128, 128); spr_players[1] = WIZARD_SPR; spr_players[0] = KNIGHTY_SPR; // game loop while (1) { // directionalInput( &p1, &p2 ); wizard_control(&p1, JOY_1); knighty_control(&p2, JOY_2); bounceCharacter( &speed, &position ); debugPlayers(p1, p2, p1_dir, p2_dir); // control_wizard(&p1); SPR_update(spr_players, 2); // wait for the screen to refresh VDP_waitVSync(); } SPR_end(); return 0; }
int main() { u16 i, j; const driver_def *cur_driver; const cmd_def *cur_cmd; JOY_setEventHandler(joyEvent); VDP_setScreenWidth320(); VDP_setHInterrupt(0); VDP_setHilightShadow(0); SYS_setVIntCallback(vintEvent); // point to first driver driver = &drivers[0]; cmd = NULL; dmaMethod = 0; for(i = 0, cur_driver = drivers; i < NUM_DRIVER; i++, cur_driver++) for(j = 0, cur_cmd = cur_driver->cmds; j < MAX_CMD; j++, cur_cmd++) params_value[i][j] = cur_cmd->params; VDP_setPalette(PAL0, font_pal_lib.data); VDP_setPaletteColor((PAL1 * 16) + 15, 0x0888); VDP_setTextPalette(PAL0); VDP_drawText("Current Z80 driver", 10, 1); VDP_drawText("DMA Method:", 1, 26); refreshDriverInfos(); while(1) { VDP_waitVSync(); } }
int main(void) { music_init(); music_play(3); u16 delay_mod = 4; u16 col_inc_cnt = 0; setup(); reset_demo: hint_val = 3; col = 0; col_off = 0; phrase_num = 0; scroll_off = 0; dscroll = 0; term_pos = 0; term_scrolling = 0; sprites_dma_simple(); term_pos = 0; VDP_setHInterrupt(0); VDP_clearPlan(VDP_PLAN_A, 0); VDP_clearPlan(VDP_PLAN_B, 0); // Greyscale palette for text VDP_setPaletteColor(0,0x000); VDP_setPaletteColor(1,0x444); VDP_setPaletteColor(2,0x888); VDP_setPaletteColor(3,0xEEE); VDP_setScreenWidth256(); bios_boot_demo(); VDP_setScreenWidth320(); VDP_clearPlan(VDP_PLAN_A, 0); VDP_clearPlan(VDP_PLAN_B, 0); awful_put_logo(8, 2); startup_stretch(); VDP_setVerticalScroll(PLAN_A, 252); VDP_setVerticalScroll(PLAN_B, 252); VDP_setHIntCounter(hint_val); SYS_setHIntCallback((_voidCallback *)h_int); volatile u8 p1 = pad_read(0); sprites_init(); col_puts40(8,0,"Computer Science House"); // Initialize background stars star stars[NUM_STARS]; u16 i = 0; for (i = 0; i < NUM_STARS; i++) { stars[i].x = i * 5; stars[i].y = 128 + i * 8; stars[i].speed = (i % 7) + 1; stars[i].offset = (3 * i) % 4; stars[i].size = (i % 4 == 0) ? ('.' + COL_FONT_VRAM_OFFSET) : (128 + '.' + COL_FONT_VRAM_OFFSET); } print_phrase(8); u16 delay = 0; u8 dir = 0; VDP_setHInterrupt(1); for (;;) { delay++; if (col_inc_cnt == 0) { col_inc_cnt = hint_val; col_off += 0x002; } else { col_inc_cnt--; } if (delay == 512) { if (phrase_num == 8) { phrase_num = 0; VDP_setHInterrupt(0); sprite_set(0, 0, 0, 0, 0, 0); sprites_dma_simple(); while (vbl_wait) { __asm__("nop"); } vbl_wait = 1; goto reset_demo; } hint_val++; if (hint_val == 10) { hint_val = 3; } delay_mod = delay_mod >> 1; if (delay_mod == 0) { delay_mod = delay_mod = 4; } VDP_setHIntCounter(hint_val); VDP_setHInterrupt(0); print_phrase(phrase_num); VDP_setHInterrupt(1); phrase_num++; delay = 0; } process_stars(&stars); while (vbl_wait) { __asm__("nop"); } VDP_setHInterrupt(0); VDP_setPaletteColor(14,palette[col]); col = col_off; vbl_wait = 1; sprites_dma_simple(); VDP_setHInterrupt(1); } return 0; }
int main() { u16 i, newJoy = 0, oldJoy = 0, autoRepeatDelay = 0, redraw = 1; s16 choice = 0; const char *str; struct FileSystem fs; u16 numFiles; // Init the screen, display message VDP_setScreenWidth320(); VDP_setHInterrupt(0); VDP_setHilightShadow(0); VDP_setTextPalette(PAL0); VDP_drawText("MakeStuff USB MegaDrive Dev Kit v2", 3, 10); VDP_drawText("Reading SD-card...", 11, 12); // Initialise the SD card sdInit(); // Get the geometry of the first SD-card partition fatOpenFileSystem(&fs); // Initialise workspace for the directory list initFiles((u16*)0x440000); // Get the list of game ROMs fatListDirectory(&fs, fs.rootDirCluster, storeFile); // Sort the list alphabetically numFiles = dirPtr - dirList; quickSort((CVPtr *)dirList, 0, numFiles, (CompareFunc)myFileComp); // Display the list for ( ; ; ) { newJoy = JOY_readJoypad(0); if ( newJoy & BUTTON_UP && choice > 0 ) { if ( !(oldJoy & BUTTON_UP) ) { choice--; redraw = 1; autoRepeatDelay = 0; } else { if ( autoRepeatDelay == 10 ) { choice--; redraw = 1; } else { autoRepeatDelay++; } } } if ( newJoy & BUTTON_DOWN && choice < numFiles-1 ) { if ( !(oldJoy & BUTTON_DOWN) ) { choice++; redraw = 1; autoRepeatDelay = 0; } else { if ( autoRepeatDelay == 10 ) { choice++; redraw = 1; } else { autoRepeatDelay++; } } } if ( newJoy & BUTTON_START ) { doSelect(&fs, choice); } oldJoy = newJoy; VDP_waitVSync(); if ( redraw ) { VDP_clearPlan(VDP_PLAN_A, 1); VDP_waitDMACompletion(); for ( i = 2; i < 26; i++ ) { if ( i >= 11-choice && i < numFiles-choice+11 ) { str = dirList[choice+i-11]->fileName; if ( i == 11 ) { VDP_setTextPalette(PAL1); VDP_drawText(str, 2, i); VDP_setTextPalette(PAL0); } else { VDP_drawText(str, 2, i); } } } } redraw = 0; } }