source/SweetValentine/Renderer.cpp
// performs graphical rendering of the game scene
performs graphical rendering of the game scene
performs graphical rendering of the game scene
void Renderer::draw() {
    uint8_t slices = SCREEN_HEIGHT / RENDERING_SLICE_HEIGHT;
    for (uint8_t sliceIndex = 0; sliceIndex < slices; sliceIndex++) {
        uint16_t* buffer = sliceIndex % 2 == 0 ? buffer1 : buffer2;
        uint8_t sliceY = sliceIndex * RENDERING_SLICE_HEIGHT;
        for (uint8_t i=0; i<numListeners; i++) {
            listeners[i]->draw(sliceY, RENDERING_SLICE_HEIGHT, buffer);
        }
        if (sliceIndex != 0) waitForPreviousDraw();
        customDrawBuffer(0, sliceY, buffer, SCREEN_WIDTH, RENDERING_SLICE_HEIGHT);
    }
    waitForPreviousDraw();
}
void Renderer :: draw ( ) { uint8_t slices = SCREEN_HEIGHT / RENDERING_SLICE_HEIGHT ; for ( uint8_t sliceIndex = 0 ; sliceIndex < slices ; sliceIndex ++ ) { uint16_t * buffer = sliceIndex % 2 == 0 ? buffer1 : buffer2 ; uint8_t sliceY = sliceIndex * RENDERING_SLICE_HEIGHT ; for ( uint8_t i = 0 ; i < numListeners ; i ++ ) { listeners [ i ] -> draw ( sliceY , RENDERING_SLICE_HEIGHT , buffer ) ; } if ( sliceIndex != 0 ) waitForPreviousDraw ( ) ; customDrawBuffer ( 0 , sliceY , buffer , SCREEN_WIDTH , RENDERING_SLICE_HEIGHT ) ; } waitForPreviousDraw ( ) ; }
performs graphical rendering of the game scene
performs graphical rendering of the game scene
// the number of horizontal slices to be cut is calculated // then we go through each slice one by one // we define a pointer that will alternate between the two memory buffers // the ordinate of the first horizontal fringe of the slice is calculated // a notification is sent to all observers to ask them to // graphically render their appearance on the game scene // then we make sure that the sending of the previous buffer // to the DMA controller has taken place // after which we can then send the current buffer // always wait until the DMA transfer is completed. // for the last slice before leaving the method!