///////////////////////////////////////////////////////////////// // initialize // Initialize this application when it starts. Disable firmware, // set the video mode and colours, and initialize map and cursor. // void initialize() { u8 *pmem; // Disable firmware to prevent it from restoring video mode or // interfering with our drawString functions cpct_disableFirmware(); // Set the video Mode to 1 (320x200, 4 colours) cpct_setVideoMode(1); // Use default colours except for palette index 0 (background). // Default colours are (Blue, Yellow, Cyan, Red), let's use // (Black, Yellow, Cyan, Red). Change only colour 0 and border. cpct_setPALColour(0, 0x14); cpct_setBorder(0x14); // Initialize Base Pointer of the map in video memory. This is // the place where the map will start to be drawn (0,0). This // location is (MAP_START_X, MAP_START_Y) with respect to CPCT_VMEM_START. pmem = cpct_getScreenPtr(CPCT_VMEM_START, MAP_START_X, MAP_START_Y); map_setBaseMem(pmem); // Set cursor at the top-left corner of the screen cursor_setLocation(0, 0); // Draw messages with instructions, the map and the cursor drawMessages(); map_draw(); cursor_draw(); }
///////////////////////////////////////////////////////////////////////////////// // Main application's code // void application(void) { // Screen tilemap TScreenTilemap scr = { 0, 0, { 0, 0, MAP_WIDTH, MAP_HEIGHT} }; // First show user messages showMessages(); // Initialize the application cpct_disableFirmware(); // Firmware must be disabled for this application to work cpct_setBorder(0x00); // Set the border colour gray and.. cpct_setPALColour(0, 0x14); // ...background black // VERY IMPORTANT: Before using EasyTileMap functions (etm), the internal // pointer to the tileset must be set. cpct_etm_setTileset2x4(g_tileset); // Indefinitely draw the tilemap, listen to user input, // do changes and draw it again while(1) { drawScreenTilemap(&scr); // Redraws the tilemap readKeyboardInput(&scr); // Waits for a user input and makes associated changes } }
///////////////////////////////////////////////////////////////////////////////// // Machine initialization code // void initialize_CPC() { // Initialize the application cpct_disableFirmware(); // Firmware must be disabled for this application to work cpct_setVideoMode(0); // Set Mode 0 (160x200, 16 Colours) cpct_setPalette(g_palette, 13); // Set Palette cpct_setBorder(0x14); // Set the border and background colours to black cpct_setPALColour(0, 0x14); // // VERY IMPORTANT: Before using EasyTileMap functions (etm), the internal // pointer to the tileset must be set. cpct_etm_setTileset2x4(g_tileset); // Clean up the screen cpct_memset(VIDEOMEM, 0x00, 0x4000); // Draw the full tilemap for the first time cpct_etm_drawTileBox2x4(0, 0, // (X, Y) upper-left corner of the tilemap SCR_TILE_WIDTH, MAP_HEIGHT, // (Width, Height) of the Box to be drawn (all the screen) MAP_WIDTH, // Width of the full tilemap (which is wider than the screen) VIDEOMEM, // Pointer to the start of video memory (upper-left corner of the // ...tilemap in the screen) g_tilemap); // Pointer to the first tile of the tilemap to be drawn (upper-left // ... corner of the tilemap viewport window) }