2024-05-02 16:52:06 +00:00
|
|
|
#include "screen.h"
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
#include <clib/exec_protos.h>
|
|
|
|
#include <exec/memory.h>
|
|
|
|
|
2024-05-28 12:02:28 +00:00
|
|
|
/**
|
|
|
|
* 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(
|
2024-05-02 16:52:06 +00:00
|
|
|
TOTAL_SCREEN_SETUP_SIZE(screenSetup),
|
|
|
|
MEMF_CLEAR | MEMF_CHIP
|
|
|
|
);
|
|
|
|
|
|
|
|
screenSetup->memoryStart = memory;
|
2024-05-28 12:02:28 +00:00
|
|
|
screenSetup->byteWidth = width / 8;
|
|
|
|
|
|
|
|
// memory is not interleaved
|
|
|
|
screenSetup->nextBitplaneAdvance = screenSetup->byteWidth * height;
|
|
|
|
screenSetup->nextBufferAdvance = screenSetup->nextBitplaneAdvance * bitplanes;
|
2024-05-02 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
2024-05-28 12:02:28 +00:00
|
|
|
void teardownScreen(
|
|
|
|
struct ScreenSetup *screenSetup
|
|
|
|
) {
|
2024-05-02 16:52:06 +00:00
|
|
|
FreeMem(
|
|
|
|
screenSetup->memoryStart,
|
|
|
|
TOTAL_SCREEN_SETUP_SIZE(screenSetup)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-05-28 12:02:28 +00:00
|
|
|
void setCurrentScreen(
|
2024-05-02 16:52:06 +00:00
|
|
|
struct ScreenSetup *screenSetup,
|
2024-05-28 12:02:28 +00:00
|
|
|
struct CurrentScreen *currentScreen,
|
|
|
|
short int buffer
|
2024-05-02 16:52:06 +00:00
|
|
|
) {
|
2024-05-28 12:02:28 +00:00
|
|
|
int plane;
|
|
|
|
|
|
|
|
currentScreen->currentBuffer = buffer;
|
|
|
|
|
|
|
|
for (plane = 0; plane < screenSetup->bitplanes; ++plane) {
|
|
|
|
currentScreen->planes[plane] = screenSetup->memoryStart +
|
|
|
|
buffer * screenSetup->nextBufferAdvance +
|
|
|
|
plane * screenSetup->nextBitplaneAdvance;
|
|
|
|
}
|
2024-05-02 16:52:06 +00:00
|
|
|
}
|
2024-05-28 12:02:28 +00:00
|
|
|
|
|
|
|
void setupInitialCurrentScreen(
|
|
|
|
struct ScreenSetup *screenSetup,
|
|
|
|
struct CurrentScreen *currentScreen
|
|
|
|
) {
|
|
|
|
currentScreen->pixelWidth = screenSetup->width;
|
|
|
|
currentScreen->pixelHeight = screenSetup->height;
|
|
|
|
currentScreen->byteWidth = screenSetup->byteWidth;
|
|
|
|
|
|
|
|
setCurrentScreen(screenSetup, currentScreen, 0);
|
|
|
|
}
|
|
|
|
|