#include "screen.h" #include "types.h" #include #include /** * Includes double buffer space */ #define TOTAL_SCREEN_SETUP_SIZE(s) ((s->width / 8) * s->height * s->bitplanes * 2) void setupScreen( struct ScreenSetup *screenSetup, uint16_t width, uint16_t height, uint8_t bitplanes ) { unsigned char *memory; screenSetup->width = width; screenSetup->height = height; screenSetup->bitplanes = bitplanes; memory = (unsigned char *)AllocMem( TOTAL_SCREEN_SETUP_SIZE(screenSetup), MEMF_CLEAR | MEMF_CHIP ); screenSetup->memoryStart = memory; screenSetup->byteWidth = width / 8; // memory is not interleaved screenSetup->nextBitplaneAdvance = screenSetup->byteWidth * height; screenSetup->nextBufferAdvance = screenSetup->nextBitplaneAdvance * bitplanes; } void teardownScreen( struct ScreenSetup *screenSetup ) { FreeMem( screenSetup->memoryStart, TOTAL_SCREEN_SETUP_SIZE(screenSetup) ); } void setCurrentScreen( struct ScreenSetup *screenSetup, struct CurrentScreen *currentScreen, short int buffer ) { int plane; currentScreen->currentBuffer = buffer; for (plane = 0; plane < screenSetup->bitplanes; ++plane) { currentScreen->planes[plane] = screenSetup->memoryStart + buffer * screenSetup->nextBufferAdvance + plane * screenSetup->nextBitplaneAdvance; } } void setupInitialCurrentScreen( struct ScreenSetup *screenSetup, struct CurrentScreen *currentScreen ) { currentScreen->pixelWidth = screenSetup->width; currentScreen->pixelHeight = screenSetup->height; currentScreen->byteWidth = screenSetup->byteWidth; setCurrentScreen(screenSetup, currentScreen, 0); }