Example #1
0
/////////////////////////////////////////////////////////////////////////////////
// Draws the tilemap in a new location or with a change in its viewport.
//  The drawing is done in the backbuffer and then shown in the screen when it's
//  done, switching screen buffers just after the VSYNC
//
void drawScreenTilemap(TScreenTilemap *scr) {
   u8* ptmscr;    // Backbuffer pointer where the tilemap is to be drawn
   
   // Clear the backbuffer
   cpct_memset_f64(g_scrbuffers[1], 0x00, 0x4000);

   // Calculate the new location where the tilemap is to be drawn in
   // the backbuffer, using x, y coordinates of the tilemap
   ptmscr = cpct_getScreenPtr(g_scrbuffers[1], scr->x, scr->y);

   // Draw the viewport of the tilemap in the backbuffer (pointed by ptmscr)
   cpct_etm_drawTileBox2x4(scr->viewport.x, scr->viewport.y, 
                           scr->viewport.w, scr->viewport.h, 
                           MAP_WIDTH, ptmscr, g_tilemap);
   
   // Wait for VSYNC and change screen buffers just afterwards, 
   // to make the backbuffer show on the screen
   cpct_waitVSYNC();
   swapBuffers(g_scrbuffers);
}
Example #2
0
////////////////////////////////////////////////////////////////////////////////
// Sets a video memory buffer with a background colour and a string
// drawn in the middle of the screen
//
void setUpVideoBuffer(u8* vmem, u16 c_pattern, u8* string, u8 pen, u8 bpen) {
   cpct_memset_f64(vmem, c_pattern, VMEM_SIZE);
   vmem = cpct_getScreenPtr(vmem, 0, 80);
   cpct_drawStringM0(string, vmem, pen, bpen);
}