Improve clarity on screen definition functions

This commit is contained in:
John Bintz 2024-09-19 07:47:48 -04:00
parent 3a42da655b
commit 1d7e327194
5 changed files with 116 additions and 113 deletions

88
bun.c
View File

@ -73,8 +73,8 @@ uint8_t *coolbunPlaneStarts[3][2];
void bun_offRightSide( void bun_offRightSide(
int plusXValue, int plusXValue,
int y, int y,
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenDefinition,
struct CurrentScreen *currentScreen, struct ActiveScreenBufferDetails *activeScreenBufferDetails,
struct BunClear *bunClear struct BunClear *bunClear
) { ) {
uint8_t i, plane = 0; uint8_t i, plane = 0;
@ -82,8 +82,8 @@ void bun_offRightSide(
uint8_t wordShift = (plusXValue >> 4); uint8_t wordShift = (plusXValue >> 4);
uint16_t bltalwm, bltcon0, bltcon1, bltdmod, bltsize; uint16_t bltalwm, bltcon0, bltcon1, bltdmod, bltsize;
bunClear->memoryStartOffsetBytes = (y * screenSetup->byteWidth) + bunClear->memoryStartOffsetBytes = (y * screenDefinition->byteWidth) +
screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES + screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES +
wordShift * 2; wordShift * 2;
bunClear->heightRows = COOL_BUN_HEIGHT; bunClear->heightRows = COOL_BUN_HEIGHT;
bunClear->widthWords = 2 - wordShift; bunClear->widthWords = 2 - wordShift;
@ -97,7 +97,7 @@ void bun_offRightSide(
bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift); bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
bltcon1 = BLTCON1(bunClear->direction, shift); bltcon1 = BLTCON1(bunClear->direction, shift);
bltdmod = screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES + bltdmod = screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES +
wordShift * 2; wordShift * 2;
bltsize = bunClear->widthWords + (bunClear->heightRows << 6); bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
@ -107,7 +107,7 @@ void bun_offRightSide(
custom.bltcon1 = bltcon1; custom.bltcon1 = bltcon1;
custom.bltapt = coolbunPlaneStarts[BUN_OFF_RIGHT_SIDE][plane]; custom.bltapt = coolbunPlaneStarts[BUN_OFF_RIGHT_SIDE][plane];
custom.bltdpt = currentScreen->planes[plane] + custom.bltdpt = activeScreenBufferDetails->planes[plane] +
bunClear->memoryStartOffsetBytes; bunClear->memoryStartOffsetBytes;
custom.bltafwm = 0xffff; custom.bltafwm = 0xffff;
@ -125,8 +125,8 @@ void bun_offRightSide(
void bun_offLeftSide( void bun_offLeftSide(
int minusXValue, int minusXValue,
int y, int y,
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenDefinition,
struct CurrentScreen *currentScreen, struct ActiveScreenBufferDetails *activeScreenBufferDetails,
struct BunClear *bunClear struct BunClear *bunClear
) { ) {
unsigned char plane; unsigned char plane;
@ -138,7 +138,7 @@ void bun_offLeftSide(
// y can't be 0 otherwise we will corrupt memory for now // y can't be 0 otherwise we will corrupt memory for now
if (y == 0) return; if (y == 0) return;
bunClear->memoryStartOffsetBytes = (screenSetup->byteWidth * (y + COOL_BUN_LAST_ROW)) + bunClear->memoryStartOffsetBytes = (screenDefinition->byteWidth * (y + COOL_BUN_LAST_ROW)) +
2 - wordShift * 2; 2 - wordShift * 2;
bunClear->heightRows = COOL_BUN_HEIGHT; bunClear->heightRows = COOL_BUN_HEIGHT;
bunClear->widthWords = 2 - wordShift; bunClear->widthWords = 2 - wordShift;
@ -151,7 +151,7 @@ void bun_offLeftSide(
bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift); bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
bltcon1 = BLTCON1(bunClear->direction, shift); bltcon1 = BLTCON1(bunClear->direction, shift);
bltdmod = screenSetup->byteWidth - 4 + wordShift * 2; bltdmod = screenDefinition->byteWidth - 4 + wordShift * 2;
bltsize = bunClear->widthWords + (bunClear->heightRows << 6); bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
@ -164,7 +164,7 @@ void bun_offLeftSide(
custom.bltapt = coolbunPlaneStarts[BUN_OFF_LEFT_SIDE][plane]; custom.bltapt = coolbunPlaneStarts[BUN_OFF_LEFT_SIDE][plane];
// d is the part on screen // d is the part on screen
custom.bltdpt = currentScreen->planes[plane] + bunClear->memoryStartOffsetBytes; custom.bltdpt = activeScreenBufferDetails->planes[plane] + bunClear->memoryStartOffsetBytes;
custom.bltafwm = 0xffff; custom.bltafwm = 0xffff;
custom.bltalwm = bltalwm; custom.bltalwm = bltalwm;
@ -181,8 +181,8 @@ void bun_offLeftSide(
void bun_anywhere( void bun_anywhere(
int x, int x,
int y, int y,
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenDefinition,
struct CurrentScreen *currentScreen, struct ActiveScreenBufferDetails *activeScreenBufferDetails,
struct BunClear *bunClear struct BunClear *bunClear
) { ) {
uint8_t plane; uint8_t plane;
@ -190,7 +190,7 @@ void bun_anywhere(
uint8_t needsExtraWord = shift != 0; uint8_t needsExtraWord = shift != 0;
uint16_t bltcon0, bltcon1, bltalwm, bltamod, bltdmod, bltsize; uint16_t bltcon0, bltcon1, bltalwm, bltamod, bltdmod, bltsize;
bunClear->memoryStartOffsetBytes = WORD_ALIGNED_BYTE_POSITION(screenSetup->width, x, y); bunClear->memoryStartOffsetBytes = WORD_ALIGNED_BYTE_POSITION(screenDefinition->width, x, y);
bunClear->heightRows = COOL_BUN_HEIGHT; bunClear->heightRows = COOL_BUN_HEIGHT;
bunClear->widthWords = 2 + needsExtraWord; bunClear->widthWords = 2 + needsExtraWord;
@ -207,7 +207,7 @@ void bun_anywhere(
} }
bltamod = -(needsExtraWord * 2); bltamod = -(needsExtraWord * 2);
bltdmod = screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES - (needsExtraWord * 2); bltdmod = screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES - (needsExtraWord * 2);
bltsize = bunClear->widthWords + (bunClear->heightRows << 6); bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
for (plane = 0; plane < 2; ++plane) { for (plane = 0; plane < 2; ++plane) {
@ -215,7 +215,7 @@ void bun_anywhere(
custom.bltcon1 = bltcon1; custom.bltcon1 = bltcon1;
custom.bltapt = coolbunPlaneStarts[BUN_ANYWHERE][plane]; custom.bltapt = coolbunPlaneStarts[BUN_ANYWHERE][plane];
custom.bltdpt = currentScreen->planes[plane] + custom.bltdpt = activeScreenBufferDetails->planes[plane] +
bunClear->memoryStartOffsetBytes; bunClear->memoryStartOffsetBytes;
custom.bltafwm = 0xffff; custom.bltafwm = 0xffff;
@ -232,8 +232,8 @@ void bun_anywhere(
void renderBun( void renderBun(
int x, int x,
int y, int y,
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenDefinition,
struct CurrentScreen *currentScreen, struct ActiveScreenBufferDetails *activeScreenBufferDetails,
struct BunClear *bunClear struct BunClear *bunClear
) { ) {
/** /**
@ -243,32 +243,32 @@ void renderBun(
* TODO: Handle top/bottom off-screen as well. * TODO: Handle top/bottom off-screen as well.
*/ */
if (x < -31) return; if (x < -31) return;
if (x > screenSetup->width + 31) return; if (x > screenDefinition->width + 31) return;
if (y < 1) return; if (y < 1) return;
if (y > screenSetup->height - COOL_BUN_HEIGHT - 1) return; if (y > screenDefinition->height - COOL_BUN_HEIGHT - 1) return;
if (x < 0) { if (x < 0) {
bun_offLeftSide( bun_offLeftSide(
-x, -x,
y, y,
screenSetup, screenDefinition,
currentScreen, activeScreenBufferDetails,
bunClear bunClear
); );
} else if (x > screenSetup->width - COOL_BUN_WIDTH) { } else if (x > screenDefinition->width - COOL_BUN_WIDTH) {
bun_offRightSide( bun_offRightSide(
x - (screenSetup->width - COOL_BUN_WIDTH), x - (screenDefinition->width - COOL_BUN_WIDTH),
y, y,
screenSetup, screenDefinition,
currentScreen, activeScreenBufferDetails,
bunClear bunClear
); );
} else { } else {
bun_anywhere( bun_anywhere(
x, x,
y, y,
screenSetup, screenDefinition,
currentScreen, activeScreenBufferDetails,
bunClear bunClear
); );
} }
@ -281,7 +281,7 @@ int bunAngleAdjustments[BUN_COUNT];
void calculateBunPositions( void calculateBunPositions(
uint16_t frame, uint16_t frame,
short int bunPositions[BUN_COUNT][2], short int bunPositions[BUN_COUNT][2],
struct ScreenSetup *screenSetup struct ScreenDefinition *screenDefinition
) { ) {
int x, y, row, column, current; int x, y, row, column, current;
float angle, startAngle; float angle, startAngle;
@ -323,7 +323,7 @@ void calculateBunPositions(
short int allBunPositionsByFrame[FRAMES_FOR_SCREEN][BUN_COUNT][2]; short int allBunPositionsByFrame[FRAMES_FOR_SCREEN][BUN_COUNT][2];
void calculateAllBunPositions( void calculateAllBunPositions(
struct ScreenSetup *screenSetup struct ScreenDefinition *screenDefinition
) { ) {
int frame; int frame;
@ -331,7 +331,7 @@ void calculateAllBunPositions(
calculateBunPositions( calculateBunPositions(
frame, frame,
allBunPositionsByFrame[frame], allBunPositionsByFrame[frame],
screenSetup screenDefinition
); );
} }
} }
@ -361,14 +361,14 @@ void precalculateBunRenderInfo(void) {
void setupBunRenderer( void setupBunRenderer(
struct BunRenderer *bunRenderer, struct BunRenderer *bunRenderer,
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenDefinition,
struct CurrentScreen *currentScreen) { struct ActiveScreenBufferDetails *activeScreenBufferDetails) {
bunRenderer->screenSetup = screenSetup; bunRenderer->screenDefinition = screenDefinition;
bunRenderer->currentScreen = currentScreen; bunRenderer->activeScreenBufferDetails = activeScreenBufferDetails;
setupBun(); setupBun();
buildBunAngleAdjustments(); buildBunAngleAdjustments();
calculateAllBunPositions(screenSetup); calculateAllBunPositions(screenDefinition);
precalculateBunRenderInfo(); precalculateBunRenderInfo();
} }
@ -382,15 +382,15 @@ void clearCurrentBuns(
struct BunClear *currentBunClear; struct BunClear *currentBunClear;
uint16_t bltcon0, bltcon1, bltdmod, bltsize; uint16_t bltcon0, bltcon1, bltdmod, bltsize;
if (!hasBunClear[bunRenderer->currentScreen->currentBuffer]) return; if (!hasBunClear[bunRenderer->activeScreenBufferDetails->currentBuffer]) return;
bltcon0 = 0xc0 + (1 << 8); bltcon0 = 0xc0 + (1 << 8);
for (bun = 0; bun < BUN_COUNT; ++bun) { for (bun = 0; bun < BUN_COUNT; ++bun) {
currentBunClear = &bunClearForScreen[bunRenderer->currentScreen->currentBuffer][bun]; currentBunClear = &bunClearForScreen[bunRenderer->activeScreenBufferDetails->currentBuffer][bun];
bltcon1 = BLTCON1(currentBunClear->direction, 0); bltcon1 = BLTCON1(currentBunClear->direction, 0);
bltdmod = bunRenderer->screenSetup->byteWidth - (currentBunClear->widthWords * 2); bltdmod = bunRenderer->screenDefinition->byteWidth - (currentBunClear->widthWords * 2);
bltsize = currentBunClear->widthWords + (currentBunClear->heightRows << 6); bltsize = currentBunClear->widthWords + (currentBunClear->heightRows << 6);
for (plane = 0; plane < 2; ++plane) { for (plane = 0; plane < 2; ++plane) {
@ -399,7 +399,7 @@ void clearCurrentBuns(
custom.bltadat = 0x0000; custom.bltadat = 0x0000;
custom.bltafwm = 0xffff; custom.bltafwm = 0xffff;
custom.bltalwm = 0xffff; custom.bltalwm = 0xffff;
custom.bltdpt = bunRenderer->currentScreen->planes[plane] + custom.bltdpt = bunRenderer->activeScreenBufferDetails->planes[plane] +
currentBunClear->memoryStartOffsetBytes; currentBunClear->memoryStartOffsetBytes;
custom.bltdmod = bltdmod; custom.bltdmod = bltdmod;
custom.bltsize = bltsize; custom.bltsize = bltsize;
@ -421,13 +421,13 @@ void renderBunFrame(
renderBun( renderBun(
allBunPositionsByFrame[frame][bun][0], allBunPositionsByFrame[frame][bun][0],
allBunPositionsByFrame[frame][bun][1], allBunPositionsByFrame[frame][bun][1],
bunRenderer->screenSetup, bunRenderer->screenDefinition,
bunRenderer->currentScreen, bunRenderer->activeScreenBufferDetails,
&bunClearForScreen[bunRenderer->currentScreen->currentBuffer][bun] &bunClearForScreen[bunRenderer->activeScreenBufferDetails->currentBuffer][bun]
); );
} }
hasBunClear[bunRenderer->currentScreen->currentBuffer] = 1; hasBunClear[bunRenderer->activeScreenBufferDetails->currentBuffer] = 1;
} }
void teardownBunRenderer() { void teardownBunRenderer() {

8
bun.h
View File

@ -6,14 +6,14 @@
#define FRAMES_FOR_SCREEN (60) #define FRAMES_FOR_SCREEN (60)
struct BunRenderer { struct BunRenderer {
struct ScreenSetup *screenSetup; struct ScreenDefinition *screenDefinition;
struct CurrentScreen *currentScreen; struct ActiveScreenBufferDetails *activeScreenBufferDetails;
}; };
void setupBunRenderer( void setupBunRenderer(
struct BunRenderer *, struct BunRenderer *,
struct ScreenSetup *, struct ScreenDefinition *,
struct CurrentScreen * struct ActiveScreenBufferDetails *
); );
void renderBunFrame( void renderBunFrame(

48
main.c
View File

@ -21,20 +21,13 @@
extern struct Custom far custom; extern struct Custom far custom;
extern struct CIA far ciaa; extern struct CIA far ciaa;
// this should be large enough to hold one bitplane of the largest object
// you are blitting, plus one additional word on each side
#define SCRATCH_AREA_WIDTH_BYTES (8)
#define SCRATCH_AREA_HEIGHT_ROWS (34)
#define SCRATCH_AREA_MEMORY_SIZE (SCRATCH_AREA_WIDTH_BYTES * SCRATCH_AREA_HEIGHT_ROWS)
// change to 0 to not render sprites // change to 0 to not render sprites
#define RENDER_SPRITES (1) #define RENDER_SPRITES (1)
volatile short *dbg = (volatile short *)0x100; volatile short *dbg = (volatile short *)0x100;
unsigned char *scratchArea; struct ScreenDefinition screenDefinition;
struct ScreenSetup screenSetup; struct ActiveScreenBufferDetails activeScreenBufferDetails;
struct CurrentScreen currentScreen;
void *copperlistBitplanePointers[8][2]; void *copperlistBitplanePointers[8][2];
void *copperlistSpritePointers[8]; void *copperlistSpritePointers[8];
@ -68,7 +61,7 @@ void renderTopaz(void) {
uint8_t *bltbpt; uint8_t *bltbpt;
bltcon0 = 0xca + (1 << 8) + (1 << 9) + (1 << 10) + (1 << 11); bltcon0 = 0xca + (1 << 8) + (1 << 9) + (1 << 10) + (1 << 11);
bltcmod = screenSetup.byteWidth - TOPAZ_WIDTH_BYTES; bltcmod = screenDefinition.byteWidth - TOPAZ_WIDTH_BYTES;
bltbpt = TopazBitplanes; bltbpt = TopazBitplanes;
for (plane = 0; plane < 3; ++plane) { for (plane = 0; plane < 3; ++plane) {
@ -78,8 +71,8 @@ void renderTopaz(void) {
custom.bltalwm = 0xffff; custom.bltalwm = 0xffff;
custom.bltapt = MaskBitplane; custom.bltapt = MaskBitplane;
custom.bltbpt = bltbpt; custom.bltbpt = bltbpt;
custom.bltcpt = currentScreen.planes[plane] + 8; custom.bltcpt = activeScreenBufferDetails.planes[plane] + 8;
custom.bltdpt = currentScreen.planes[plane] + 8; custom.bltdpt = activeScreenBufferDetails.planes[plane] + 8;
custom.bltamod = 0; custom.bltamod = 0;
custom.bltbmod = 0; custom.bltbmod = 0;
custom.bltcmod = bltcmod; custom.bltcmod = bltcmod;
@ -121,10 +114,19 @@ int main(void) {
printf("\nEnjoy, and thanks for watching!\n"); printf("\nEnjoy, and thanks for watching!\n");
printf("John (theindustriousrabbit.com)\n\n"); printf("John (theindustriousrabbit.com)\n\n");
setupScreen(&screenSetup, SCREEN_WIDTH, SCREEN_HEIGHT, 3); allocateDoubleBufferedScreenMemory(
setupInitialCurrentScreen(&screenSetup, &currentScreen); &screenDefinition,
&activeScreenBufferDetails,
SCREEN_WIDTH,
SCREEN_HEIGHT,
3
);
setupBunRenderer(&bunRenderer, &screenSetup, &currentScreen); setupBunRenderer(
&bunRenderer,
&screenDefinition,
&activeScreenBufferDetails
);
// blitter copy the first bitplane row down to the second // blitter copy the first bitplane row down to the second
@ -132,8 +134,8 @@ int main(void) {
currentCopperlist = addDisplayToCopperlist( currentCopperlist = addDisplayToCopperlist(
copperlist, copperlist,
&screenSetup, &screenDefinition,
&currentScreen, &activeScreenBufferDetails,
&copperlistBitplanePointers &copperlistBitplanePointers
); );
@ -216,12 +218,12 @@ int main(void) {
takeOverSystem(); takeOverSystem();
setCopperlist(copperlist); setCopperlist(copperlist);
setUpDisplay((uint32_t)screenSetup.bitplanes); setUpDisplay((uint32_t)screenDefinition.bitplanes);
i = 0; i = 0;
while (1) { while (1) {
swapCurrentScreenBuffer(&screenSetup, &currentScreen); swapCurrentScreenBuffer(&screenDefinition, &activeScreenBufferDetails);
clearCurrentBuns(&bunRenderer); clearCurrentBuns(&bunRenderer);
@ -230,8 +232,8 @@ int main(void) {
renderTopaz(); renderTopaz();
updateDisplayInCopperList( updateDisplayInCopperList(
&screenSetup, &screenDefinition,
&currentScreen, &activeScreenBufferDetails,
copperlistBitplanePointers copperlistBitplanePointers
); );
@ -239,13 +241,13 @@ int main(void) {
if ((ciaa.ciapra >> 6) != 3) break; if ((ciaa.ciapra >> 6) != 3) break;
i++; //i++;
i %= FRAMES_FOR_SCREEN; i %= FRAMES_FOR_SCREEN;
} }
giveBackSystem(); giveBackSystem();
teardownScreen(&screenSetup); teardownScreen(&screenDefinition);
freeCopperlist(copperlist); freeCopperlist(copperlist);

View File

@ -9,66 +9,66 @@
*/ */
#define TOTAL_SCREEN_SETUP_SIZE(s) ((s->width / 8) * s->height * s->bitplanes * 2) #define TOTAL_SCREEN_SETUP_SIZE(s) ((s->width / 8) * s->height * s->bitplanes * 2)
void setupScreen( /**
struct ScreenSetup *screenSetup, * Stores internal allocation details in screenSetup.
* Sets current
*/
void allocateDoubleBufferedScreenMemory(
struct ScreenDefinition *screenDefinition,
struct ActiveScreenBufferDetails *activeScreenBufferDetails,
uint16_t width, uint16_t width,
uint16_t height, uint16_t height,
uint8_t bitplanes uint8_t bitplanes
) { ) {
unsigned char *memory; unsigned char *memory;
screenSetup->width = width; screenDefinition->width = width;
screenSetup->height = height; screenDefinition->height = height;
screenSetup->bitplanes = bitplanes; screenDefinition->bitplanes = bitplanes;
memory = (unsigned char *)AllocMem( memory = (unsigned char *)AllocMem(
TOTAL_SCREEN_SETUP_SIZE(screenSetup), TOTAL_SCREEN_SETUP_SIZE(screenDefinition),
MEMF_CLEAR | MEMF_CHIP MEMF_CLEAR | MEMF_CHIP
); );
screenSetup->memoryStart = memory; screenDefinition->memoryStart = memory;
screenSetup->byteWidth = width / 8; screenDefinition->byteWidth = width / 8;
// memory is not interleaved // memory is not interleaved
screenSetup->nextBitplaneAdvance = screenSetup->byteWidth * height; screenDefinition->nextBitplaneAdvance = screenDefinition->byteWidth * height;
screenSetup->nextBufferAdvance = screenSetup->nextBitplaneAdvance * bitplanes; screenDefinition->nextBufferAdvance = screenDefinition->nextBitplaneAdvance * bitplanes;
setActiveScreenBuffer(screenDefinition, activeScreenBufferDetails, 0);
} }
void teardownScreen( void teardownScreen(
struct ScreenSetup *screenSetup struct ScreenDefinition *screenDefinition
) { ) {
FreeMem( FreeMem(
screenSetup->memoryStart, screenDefinition->memoryStart,
TOTAL_SCREEN_SETUP_SIZE(screenSetup) TOTAL_SCREEN_SETUP_SIZE(screenDefinition)
); );
} }
void setCurrentScreen( void setActiveScreenBuffer(
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenDefinition,
struct CurrentScreen *currentScreen, struct ActiveScreenBufferDetails *currentScreen,
short int buffer short int buffer
) { ) {
int plane; int plane;
currentScreen->currentBuffer = buffer; currentScreen->currentBuffer = buffer;
for (plane = 0; plane < screenSetup->bitplanes; ++plane) { for (plane = 0; plane < screenDefinition->bitplanes; ++plane) {
currentScreen->planes[plane] = screenSetup->memoryStart + currentScreen->planes[plane] = screenDefinition->memoryStart +
buffer * screenSetup->nextBufferAdvance + buffer * screenDefinition->nextBufferAdvance +
plane * screenSetup->nextBitplaneAdvance; plane * screenDefinition->nextBitplaneAdvance;
} }
} }
void swapCurrentScreenBuffer( void swapCurrentScreenBuffer(
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenDefinition,
struct CurrentScreen *currentScreen struct ActiveScreenBufferDetails *currentScreen
) { ) {
setCurrentScreen(screenSetup, currentScreen, 1 - currentScreen->currentBuffer); setActiveScreenBuffer(screenDefinition, currentScreen, 1 - currentScreen->currentBuffer);
}
void setupInitialCurrentScreen(
struct ScreenSetup *screenSetup,
struct CurrentScreen *currentScreen
) {
setCurrentScreen(screenSetup, currentScreen, 0);
} }

View File

@ -6,7 +6,7 @@
#define SCREEN_WIDTH (320) #define SCREEN_WIDTH (320)
#define SCREEN_HEIGHT (256) #define SCREEN_HEIGHT (256)
struct ScreenSetup { struct ScreenDefinition {
// human entered // human entered
uint16_t width; uint16_t width;
uint16_t height; uint16_t height;
@ -19,32 +19,33 @@ struct ScreenSetup {
uint16_t nextBufferAdvance; uint16_t nextBufferAdvance;
}; };
struct CurrentScreen { struct ActiveScreenBufferDetails {
uint16_t currentBuffer; uint16_t currentBuffer;
unsigned char *planes[8]; unsigned char *planes[8];
}; };
void setupScreen( void allocateDoubleBufferedScreenMemory(
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenSetup,
struct ActiveScreenBufferDetails *currentScreen,
uint16_t width, uint16_t width,
uint16_t height, uint16_t height,
uint8_t bitplanes uint8_t bitplanes
); );
void teardownScreen(struct ScreenSetup *screenSetup); void teardownScreen(struct ScreenDefinition *screenSetup);
void setCurrentScreen( void setActiveScreenBuffer(
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenSetup,
struct CurrentScreen *currentScreen, struct ActiveScreenBufferDetails *currentScreen,
short int buffer short int buffer
); );
void swapCurrentScreenBuffer( void swapCurrentScreenBuffer(
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenSetup,
struct CurrentScreen *currentScreen struct ActiveScreenBufferDetails *currentScreen
); );
void setupInitialCurrentScreen( void setupInitialCurrentScreen(
struct ScreenSetup *screenSetup, struct ScreenDefinition *screenSetup,
struct CurrentScreen *currentScreen struct ActiveScreenBufferDetails *currentScreen
); );
#endif #endif