void application() { scene = G_sceneMenu; // Primera escena (y la actual) nextScene = scene; // Siguiente escena (siempre empieza siendo igual a la primera) interruptId = 0; // Primera interrupcion // Initialize CPC before starting the game initializeCPC(); // Inicializamos la primera escena initScene(&scene); // Main loop while (1) { // Scene updates switch(scene) { case G_sceneMenu: nextScene = updateMenu(); break; case G_sceneGame: nextScene = updateGame(); break; } // Comprobamos si vamos a cambiar de escena if(scene != nextScene) { // Cambiamos la escena actual y la inicializamos scene = nextScene; initScene(&scene); } } }
////////////////////////////////////////////////////////////////////////////// // MAIN: code execution starts here // Initializes buffers at 0x4000 and 0xC000 and goes switching between // both of them on keypresses // void main(void) { u8 scr = 0; // Video buffer selector: selects what is to be shown on the screen u16 pattern; // Will contain a 4 pixel-colour pattern // First, Initialize the CPC initializeCPC(); // Construct a color pattern with 4 consecutive pixels of 4 different // colours in mode 0, that will be used to fill up the second buffer pattern = ( cpct_px2byteM0(4, 6) << 8 ) | cpct_px2byteM0(8, 9); // Second, Set up the 0x4000 video buffer. This set up will erase // all code placed in the 0x4000 area that has already been used // for initializing the CPC. Therefore, this code will have been // used one and then replaced to gain some space. setUpVideoBuffer(VMEM_1, pattern, "0x4000 Screen Buffer", 0, 6); // Main Loop while (1) { // Wait for VSYNC and show pressently // selected video buffer in the screen cpct_waitVSYNC(); cpct_setVideoMemoryPage(g_buffers[scr]); // Sets the memory page that will be shown on screen // Select the alternate video buffer and wait // for a keypress to change what is being shown on screen scr = scr ^ 0x01; // Does operation scr XOR 1, which alternates the value of the last bit of scr, // ... so that it alternates between 0 and 1. wait4KeyPress(); } }