void _start_entry() { // initiate random number generator randbase = 0xD94B ^ GET_HVCOUNTER; vtimer = 0; // default interrupt callback busErrorCB = _buserror_callback; addressErrorCB = _addresserror_callback; illegalInstCB = _illegalinst_callback; zeroDivideCB = _zerodivide_callback; chkInstCB = _chkinst_callback; trapvInstCB = _trapvinst_callback; privilegeViolationCB = _privilegeviolation_callback; traceCB = _trace_callback; line1x1xCB = _line1x1x_callback; errorExceptionCB = _errorexception_callback; intCB = _int_callback; internalVIntCB = _vint_callback; internalHIntCB = _hint_callback; internalExtIntCB = _extint_callback; internal_reset(); #if (ENABLE_LOGO != 0) { Bitmap *logo = unpackBitmap(&logo_lib, NULL); // correctly unpacked if (logo) { const Palette *logo_pal = logo->palette; // display logo (use BMP mode for that) BMP_init(TRUE, PAL0, FALSE); #if (ZOOMING_LOGO != 0) // init fade in to 30 step u16 step_fade = 30; if (VDP_initFading(logo_pal->index, logo_pal->index + (logo_pal->length - 1), palette_black, logo_pal->data, step_fade)) { // prepare zoom u16 size = 256; // while zoom not completed while(size > 0) { // sort of log decrease if (size > 20) size = size - (size / 6); else if (size > 5) size -= 5; else size = 0; // get new size const u32 w = 256 - size; // adjust palette for fade if (step_fade-- > 0) VDP_doStepFading(FALSE); // zoom logo BMP_loadAndScaleBitmap(logo, 64 + ((256 - w) >> 2), (256 - w) >> 1, w >> 1, w >> 1, FALSE); // flip to screen BMP_flip(0); } // while fade not completed while(step_fade--) VDP_doStepFading(TRUE); } // wait 1 second waitTick(TICKPERSECOND * 1); #else // set palette 0 to black VDP_setPalette(PAL0, palette_black); // don't load the palette immediatly BMP_loadBitmap(logo, 64, 0, FALSE); // flip BMP_flip(0); // fade in logo VDP_fade((PAL0 << 4) + logo_pal->index, (PAL0 << 4) + (logo_pal->index + (logo_pal->length - 1)), palette_black, logo_pal->data, 30, FALSE); // wait 1.5 second waitTick(TICKPERSECOND * 1.5); #endif // fade out logo VDP_fadePalOut(PAL0, 20, 0); // wait 0.5 second waitTick(TICKPERSECOND * 0.5); // shut down bmp mode BMP_end(); // release bitmap memory MEM_free(logo); // reinit vdp before program execution VDP_init(); } }
int main() { char col; JOY_setEventHandler(joyEvent); VDP_setScreenWidth256(); VDP_setHInterrupt(0); VDP_setHilightShadow(0); BMP_init(TRUE, PLAN_A, PAL0, FALSE); paused = 0; col = 0xFF; /* Initialise particules */ baseposx = intToFix16(BMP_WIDTH / 2); baseposy = intToFix16(BMP_HEIGHT / 2); gravity = FIX16(0.4); initPartic(100); /* Do main job here */ while(1) { char str[8]; handleInput(); if (!paused) { // calculates particules physic updatePartic(partics, numpartic); // ensure previous flip buffer request has been started BMP_waitWhileFlipRequestPending(); // can now draw text BMP_showFPS(0); // display particul number intToStr(numpartic, str, 1); BMP_clearText(1, 3, 4); BMP_drawText(str, 1, 3); // display gravity fix16ToStr(gravity, str, 2); BMP_clearText(1, 4, 5); BMP_drawText(str, 1, 4); // clear bitmap BMP_clear(); // draw particules drawPartic(partics, numpartic, col); // swap buffer BMP_flip(1); } else { BMP_drawText("PAUSE", 1, 4); } } }
int main() { char str[16]; VDP_setScreenWidth256(); VDP_setHInterrupt(0); VDP_setHilightShadow(0); // speed up controller checking JOY_setSupport(PORT_1, JOY_SUPPORT_6BTN); JOY_setSupport(PORT_2, JOY_SUPPORT_OFF); JOY_setEventHandler(handleJoyEvent); BMP_init(TRUE, PAL0, FALSE); camdist = FIX16(15); M3D_reset(); M3D_setCamDistance(camdist); M3D_setLightEnabled(1); M3D_setLightXYZ(FIX16(0.9), FIX16(0.9), FIX16(-0.9)); // allocate translation and rotation structure M3D_setTransform(&transformation, &translation, &rotation); M3D_setTranslation(&transformation, FIX16(0), FIX16(0), FIX16(20)); M3D_setRotation(&transformation, FIX16(0), FIX16(0), FIX16(0)); flatDrawing = 0; while (1) { doActionJoy(JOY_1, JOY_readJoypad(JOY_1)); M3D_setCamDistance(camdist); // do work here rotation.x += rotstep.x; rotation.y += rotstep.y; rotation.z += rotstep.z; transformation.rebuildMat = 1; updatePointsPos(); // ensure previous flip buffer request has been started BMP_waitWhileFlipRequestPending(); BMP_showFPS(1); BMP_clear(); drawPoints(0xFF); BMP_drawText("trans z:", 0, 2); fix16ToStr(translation.z, str, 2); BMP_drawText(str, 10, 2); BMP_drawText("cam dist:", 0, 3); fix16ToStr(camdist, str, 2); BMP_drawText(str, 11, 3); BMP_flip(1); } }