Improve clarity on screen definition functions
This commit is contained in:
parent
3a42da655b
commit
1d7e327194
88
bun.c
88
bun.c
|
@ -73,8 +73,8 @@ uint8_t *coolbunPlaneStarts[3][2];
|
|||
void bun_offRightSide(
|
||||
int plusXValue,
|
||||
int y,
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen,
|
||||
struct ScreenDefinition *screenDefinition,
|
||||
struct ActiveScreenBufferDetails *activeScreenBufferDetails,
|
||||
struct BunClear *bunClear
|
||||
) {
|
||||
uint8_t i, plane = 0;
|
||||
|
@ -82,8 +82,8 @@ void bun_offRightSide(
|
|||
uint8_t wordShift = (plusXValue >> 4);
|
||||
uint16_t bltalwm, bltcon0, bltcon1, bltdmod, bltsize;
|
||||
|
||||
bunClear->memoryStartOffsetBytes = (y * screenSetup->byteWidth) +
|
||||
screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES +
|
||||
bunClear->memoryStartOffsetBytes = (y * screenDefinition->byteWidth) +
|
||||
screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES +
|
||||
wordShift * 2;
|
||||
bunClear->heightRows = COOL_BUN_HEIGHT;
|
||||
bunClear->widthWords = 2 - wordShift;
|
||||
|
@ -97,7 +97,7 @@ void bun_offRightSide(
|
|||
bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
|
||||
bltcon1 = BLTCON1(bunClear->direction, shift);
|
||||
|
||||
bltdmod = screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES +
|
||||
bltdmod = screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES +
|
||||
wordShift * 2;
|
||||
|
||||
bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
|
||||
|
@ -107,7 +107,7 @@ void bun_offRightSide(
|
|||
custom.bltcon1 = bltcon1;
|
||||
|
||||
custom.bltapt = coolbunPlaneStarts[BUN_OFF_RIGHT_SIDE][plane];
|
||||
custom.bltdpt = currentScreen->planes[plane] +
|
||||
custom.bltdpt = activeScreenBufferDetails->planes[plane] +
|
||||
bunClear->memoryStartOffsetBytes;
|
||||
|
||||
custom.bltafwm = 0xffff;
|
||||
|
@ -125,8 +125,8 @@ void bun_offRightSide(
|
|||
void bun_offLeftSide(
|
||||
int minusXValue,
|
||||
int y,
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen,
|
||||
struct ScreenDefinition *screenDefinition,
|
||||
struct ActiveScreenBufferDetails *activeScreenBufferDetails,
|
||||
struct BunClear *bunClear
|
||||
) {
|
||||
unsigned char plane;
|
||||
|
@ -138,7 +138,7 @@ void bun_offLeftSide(
|
|||
// y can't be 0 otherwise we will corrupt memory for now
|
||||
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;
|
||||
bunClear->heightRows = COOL_BUN_HEIGHT;
|
||||
bunClear->widthWords = 2 - wordShift;
|
||||
|
@ -151,7 +151,7 @@ void bun_offLeftSide(
|
|||
|
||||
bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
|
||||
bltcon1 = BLTCON1(bunClear->direction, shift);
|
||||
bltdmod = screenSetup->byteWidth - 4 + wordShift * 2;
|
||||
bltdmod = screenDefinition->byteWidth - 4 + wordShift * 2;
|
||||
|
||||
bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
|
||||
|
||||
|
@ -164,7 +164,7 @@ void bun_offLeftSide(
|
|||
custom.bltapt = coolbunPlaneStarts[BUN_OFF_LEFT_SIDE][plane];
|
||||
|
||||
// d is the part on screen
|
||||
custom.bltdpt = currentScreen->planes[plane] + bunClear->memoryStartOffsetBytes;
|
||||
custom.bltdpt = activeScreenBufferDetails->planes[plane] + bunClear->memoryStartOffsetBytes;
|
||||
|
||||
custom.bltafwm = 0xffff;
|
||||
custom.bltalwm = bltalwm;
|
||||
|
@ -181,8 +181,8 @@ void bun_offLeftSide(
|
|||
void bun_anywhere(
|
||||
int x,
|
||||
int y,
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen,
|
||||
struct ScreenDefinition *screenDefinition,
|
||||
struct ActiveScreenBufferDetails *activeScreenBufferDetails,
|
||||
struct BunClear *bunClear
|
||||
) {
|
||||
uint8_t plane;
|
||||
|
@ -190,7 +190,7 @@ void bun_anywhere(
|
|||
uint8_t needsExtraWord = shift != 0;
|
||||
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->widthWords = 2 + needsExtraWord;
|
||||
|
@ -207,7 +207,7 @@ void bun_anywhere(
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
for (plane = 0; plane < 2; ++plane) {
|
||||
|
@ -215,7 +215,7 @@ void bun_anywhere(
|
|||
custom.bltcon1 = bltcon1;
|
||||
|
||||
custom.bltapt = coolbunPlaneStarts[BUN_ANYWHERE][plane];
|
||||
custom.bltdpt = currentScreen->planes[plane] +
|
||||
custom.bltdpt = activeScreenBufferDetails->planes[plane] +
|
||||
bunClear->memoryStartOffsetBytes;
|
||||
|
||||
custom.bltafwm = 0xffff;
|
||||
|
@ -232,8 +232,8 @@ void bun_anywhere(
|
|||
void renderBun(
|
||||
int x,
|
||||
int y,
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen,
|
||||
struct ScreenDefinition *screenDefinition,
|
||||
struct ActiveScreenBufferDetails *activeScreenBufferDetails,
|
||||
struct BunClear *bunClear
|
||||
) {
|
||||
/**
|
||||
|
@ -243,32 +243,32 @@ void renderBun(
|
|||
* TODO: Handle top/bottom off-screen as well.
|
||||
*/
|
||||
if (x < -31) return;
|
||||
if (x > screenSetup->width + 31) return;
|
||||
if (x > screenDefinition->width + 31) 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) {
|
||||
bun_offLeftSide(
|
||||
-x,
|
||||
y,
|
||||
screenSetup,
|
||||
currentScreen,
|
||||
screenDefinition,
|
||||
activeScreenBufferDetails,
|
||||
bunClear
|
||||
);
|
||||
} else if (x > screenSetup->width - COOL_BUN_WIDTH) {
|
||||
} else if (x > screenDefinition->width - COOL_BUN_WIDTH) {
|
||||
bun_offRightSide(
|
||||
x - (screenSetup->width - COOL_BUN_WIDTH),
|
||||
x - (screenDefinition->width - COOL_BUN_WIDTH),
|
||||
y,
|
||||
screenSetup,
|
||||
currentScreen,
|
||||
screenDefinition,
|
||||
activeScreenBufferDetails,
|
||||
bunClear
|
||||
);
|
||||
} else {
|
||||
bun_anywhere(
|
||||
x,
|
||||
y,
|
||||
screenSetup,
|
||||
currentScreen,
|
||||
screenDefinition,
|
||||
activeScreenBufferDetails,
|
||||
bunClear
|
||||
);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ int bunAngleAdjustments[BUN_COUNT];
|
|||
void calculateBunPositions(
|
||||
uint16_t frame,
|
||||
short int bunPositions[BUN_COUNT][2],
|
||||
struct ScreenSetup *screenSetup
|
||||
struct ScreenDefinition *screenDefinition
|
||||
) {
|
||||
int x, y, row, column, current;
|
||||
float angle, startAngle;
|
||||
|
@ -323,7 +323,7 @@ void calculateBunPositions(
|
|||
short int allBunPositionsByFrame[FRAMES_FOR_SCREEN][BUN_COUNT][2];
|
||||
|
||||
void calculateAllBunPositions(
|
||||
struct ScreenSetup *screenSetup
|
||||
struct ScreenDefinition *screenDefinition
|
||||
) {
|
||||
int frame;
|
||||
|
||||
|
@ -331,7 +331,7 @@ void calculateAllBunPositions(
|
|||
calculateBunPositions(
|
||||
frame,
|
||||
allBunPositionsByFrame[frame],
|
||||
screenSetup
|
||||
screenDefinition
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -361,14 +361,14 @@ void precalculateBunRenderInfo(void) {
|
|||
|
||||
void setupBunRenderer(
|
||||
struct BunRenderer *bunRenderer,
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen) {
|
||||
bunRenderer->screenSetup = screenSetup;
|
||||
bunRenderer->currentScreen = currentScreen;
|
||||
struct ScreenDefinition *screenDefinition,
|
||||
struct ActiveScreenBufferDetails *activeScreenBufferDetails) {
|
||||
bunRenderer->screenDefinition = screenDefinition;
|
||||
bunRenderer->activeScreenBufferDetails = activeScreenBufferDetails;
|
||||
|
||||
setupBun();
|
||||
buildBunAngleAdjustments();
|
||||
calculateAllBunPositions(screenSetup);
|
||||
calculateAllBunPositions(screenDefinition);
|
||||
precalculateBunRenderInfo();
|
||||
}
|
||||
|
||||
|
@ -382,15 +382,15 @@ void clearCurrentBuns(
|
|||
struct BunClear *currentBunClear;
|
||||
uint16_t bltcon0, bltcon1, bltdmod, bltsize;
|
||||
|
||||
if (!hasBunClear[bunRenderer->currentScreen->currentBuffer]) return;
|
||||
if (!hasBunClear[bunRenderer->activeScreenBufferDetails->currentBuffer]) return;
|
||||
|
||||
bltcon0 = 0xc0 + (1 << 8);
|
||||
|
||||
for (bun = 0; bun < BUN_COUNT; ++bun) {
|
||||
currentBunClear = &bunClearForScreen[bunRenderer->currentScreen->currentBuffer][bun];
|
||||
currentBunClear = &bunClearForScreen[bunRenderer->activeScreenBufferDetails->currentBuffer][bun];
|
||||
|
||||
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);
|
||||
|
||||
for (plane = 0; plane < 2; ++plane) {
|
||||
|
@ -399,7 +399,7 @@ void clearCurrentBuns(
|
|||
custom.bltadat = 0x0000;
|
||||
custom.bltafwm = 0xffff;
|
||||
custom.bltalwm = 0xffff;
|
||||
custom.bltdpt = bunRenderer->currentScreen->planes[plane] +
|
||||
custom.bltdpt = bunRenderer->activeScreenBufferDetails->planes[plane] +
|
||||
currentBunClear->memoryStartOffsetBytes;
|
||||
custom.bltdmod = bltdmod;
|
||||
custom.bltsize = bltsize;
|
||||
|
@ -421,13 +421,13 @@ void renderBunFrame(
|
|||
renderBun(
|
||||
allBunPositionsByFrame[frame][bun][0],
|
||||
allBunPositionsByFrame[frame][bun][1],
|
||||
bunRenderer->screenSetup,
|
||||
bunRenderer->currentScreen,
|
||||
&bunClearForScreen[bunRenderer->currentScreen->currentBuffer][bun]
|
||||
bunRenderer->screenDefinition,
|
||||
bunRenderer->activeScreenBufferDetails,
|
||||
&bunClearForScreen[bunRenderer->activeScreenBufferDetails->currentBuffer][bun]
|
||||
);
|
||||
}
|
||||
|
||||
hasBunClear[bunRenderer->currentScreen->currentBuffer] = 1;
|
||||
hasBunClear[bunRenderer->activeScreenBufferDetails->currentBuffer] = 1;
|
||||
}
|
||||
|
||||
void teardownBunRenderer() {
|
||||
|
|
8
bun.h
8
bun.h
|
@ -6,14 +6,14 @@
|
|||
#define FRAMES_FOR_SCREEN (60)
|
||||
|
||||
struct BunRenderer {
|
||||
struct ScreenSetup *screenSetup;
|
||||
struct CurrentScreen *currentScreen;
|
||||
struct ScreenDefinition *screenDefinition;
|
||||
struct ActiveScreenBufferDetails *activeScreenBufferDetails;
|
||||
};
|
||||
|
||||
void setupBunRenderer(
|
||||
struct BunRenderer *,
|
||||
struct ScreenSetup *,
|
||||
struct CurrentScreen *
|
||||
struct ScreenDefinition *,
|
||||
struct ActiveScreenBufferDetails *
|
||||
);
|
||||
|
||||
void renderBunFrame(
|
||||
|
|
48
main.c
48
main.c
|
@ -21,20 +21,13 @@
|
|||
extern struct Custom far custom;
|
||||
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
|
||||
#define RENDER_SPRITES (1)
|
||||
|
||||
volatile short *dbg = (volatile short *)0x100;
|
||||
|
||||
unsigned char *scratchArea;
|
||||
struct ScreenSetup screenSetup;
|
||||
struct CurrentScreen currentScreen;
|
||||
struct ScreenDefinition screenDefinition;
|
||||
struct ActiveScreenBufferDetails activeScreenBufferDetails;
|
||||
void *copperlistBitplanePointers[8][2];
|
||||
void *copperlistSpritePointers[8];
|
||||
|
||||
|
@ -68,7 +61,7 @@ void renderTopaz(void) {
|
|||
uint8_t *bltbpt;
|
||||
|
||||
bltcon0 = 0xca + (1 << 8) + (1 << 9) + (1 << 10) + (1 << 11);
|
||||
bltcmod = screenSetup.byteWidth - TOPAZ_WIDTH_BYTES;
|
||||
bltcmod = screenDefinition.byteWidth - TOPAZ_WIDTH_BYTES;
|
||||
bltbpt = TopazBitplanes;
|
||||
|
||||
for (plane = 0; plane < 3; ++plane) {
|
||||
|
@ -78,8 +71,8 @@ void renderTopaz(void) {
|
|||
custom.bltalwm = 0xffff;
|
||||
custom.bltapt = MaskBitplane;
|
||||
custom.bltbpt = bltbpt;
|
||||
custom.bltcpt = currentScreen.planes[plane] + 8;
|
||||
custom.bltdpt = currentScreen.planes[plane] + 8;
|
||||
custom.bltcpt = activeScreenBufferDetails.planes[plane] + 8;
|
||||
custom.bltdpt = activeScreenBufferDetails.planes[plane] + 8;
|
||||
custom.bltamod = 0;
|
||||
custom.bltbmod = 0;
|
||||
custom.bltcmod = bltcmod;
|
||||
|
@ -121,10 +114,19 @@ int main(void) {
|
|||
printf("\nEnjoy, and thanks for watching!\n");
|
||||
printf("John (theindustriousrabbit.com)\n\n");
|
||||
|
||||
setupScreen(&screenSetup, SCREEN_WIDTH, SCREEN_HEIGHT, 3);
|
||||
setupInitialCurrentScreen(&screenSetup, ¤tScreen);
|
||||
allocateDoubleBufferedScreenMemory(
|
||||
&screenDefinition,
|
||||
&activeScreenBufferDetails,
|
||||
SCREEN_WIDTH,
|
||||
SCREEN_HEIGHT,
|
||||
3
|
||||
);
|
||||
|
||||
setupBunRenderer(&bunRenderer, &screenSetup, ¤tScreen);
|
||||
setupBunRenderer(
|
||||
&bunRenderer,
|
||||
&screenDefinition,
|
||||
&activeScreenBufferDetails
|
||||
);
|
||||
|
||||
// blitter copy the first bitplane row down to the second
|
||||
|
||||
|
@ -132,8 +134,8 @@ int main(void) {
|
|||
|
||||
currentCopperlist = addDisplayToCopperlist(
|
||||
copperlist,
|
||||
&screenSetup,
|
||||
¤tScreen,
|
||||
&screenDefinition,
|
||||
&activeScreenBufferDetails,
|
||||
&copperlistBitplanePointers
|
||||
);
|
||||
|
||||
|
@ -216,12 +218,12 @@ int main(void) {
|
|||
takeOverSystem();
|
||||
|
||||
setCopperlist(copperlist);
|
||||
setUpDisplay((uint32_t)screenSetup.bitplanes);
|
||||
setUpDisplay((uint32_t)screenDefinition.bitplanes);
|
||||
|
||||
i = 0;
|
||||
|
||||
while (1) {
|
||||
swapCurrentScreenBuffer(&screenSetup, ¤tScreen);
|
||||
swapCurrentScreenBuffer(&screenDefinition, &activeScreenBufferDetails);
|
||||
|
||||
clearCurrentBuns(&bunRenderer);
|
||||
|
||||
|
@ -230,8 +232,8 @@ int main(void) {
|
|||
renderTopaz();
|
||||
|
||||
updateDisplayInCopperList(
|
||||
&screenSetup,
|
||||
¤tScreen,
|
||||
&screenDefinition,
|
||||
&activeScreenBufferDetails,
|
||||
copperlistBitplanePointers
|
||||
);
|
||||
|
||||
|
@ -239,13 +241,13 @@ int main(void) {
|
|||
|
||||
if ((ciaa.ciapra >> 6) != 3) break;
|
||||
|
||||
i++;
|
||||
//i++;
|
||||
i %= FRAMES_FOR_SCREEN;
|
||||
}
|
||||
|
||||
giveBackSystem();
|
||||
|
||||
teardownScreen(&screenSetup);
|
||||
teardownScreen(&screenDefinition);
|
||||
|
||||
freeCopperlist(copperlist);
|
||||
|
||||
|
|
60
screen.c
60
screen.c
|
@ -9,66 +9,66 @@
|
|||
*/
|
||||
#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 height,
|
||||
uint8_t bitplanes
|
||||
) {
|
||||
unsigned char *memory;
|
||||
|
||||
screenSetup->width = width;
|
||||
screenSetup->height = height;
|
||||
screenSetup->bitplanes = bitplanes;
|
||||
screenDefinition->width = width;
|
||||
screenDefinition->height = height;
|
||||
screenDefinition->bitplanes = bitplanes;
|
||||
|
||||
memory = (unsigned char *)AllocMem(
|
||||
TOTAL_SCREEN_SETUP_SIZE(screenSetup),
|
||||
TOTAL_SCREEN_SETUP_SIZE(screenDefinition),
|
||||
MEMF_CLEAR | MEMF_CHIP
|
||||
);
|
||||
|
||||
screenSetup->memoryStart = memory;
|
||||
screenSetup->byteWidth = width / 8;
|
||||
screenDefinition->memoryStart = memory;
|
||||
screenDefinition->byteWidth = width / 8;
|
||||
|
||||
// memory is not interleaved
|
||||
screenSetup->nextBitplaneAdvance = screenSetup->byteWidth * height;
|
||||
screenSetup->nextBufferAdvance = screenSetup->nextBitplaneAdvance * bitplanes;
|
||||
screenDefinition->nextBitplaneAdvance = screenDefinition->byteWidth * height;
|
||||
screenDefinition->nextBufferAdvance = screenDefinition->nextBitplaneAdvance * bitplanes;
|
||||
|
||||
setActiveScreenBuffer(screenDefinition, activeScreenBufferDetails, 0);
|
||||
}
|
||||
|
||||
void teardownScreen(
|
||||
struct ScreenSetup *screenSetup
|
||||
struct ScreenDefinition *screenDefinition
|
||||
) {
|
||||
FreeMem(
|
||||
screenSetup->memoryStart,
|
||||
TOTAL_SCREEN_SETUP_SIZE(screenSetup)
|
||||
screenDefinition->memoryStart,
|
||||
TOTAL_SCREEN_SETUP_SIZE(screenDefinition)
|
||||
);
|
||||
}
|
||||
|
||||
void setCurrentScreen(
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen,
|
||||
void setActiveScreenBuffer(
|
||||
struct ScreenDefinition *screenDefinition,
|
||||
struct ActiveScreenBufferDetails *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;
|
||||
for (plane = 0; plane < screenDefinition->bitplanes; ++plane) {
|
||||
currentScreen->planes[plane] = screenDefinition->memoryStart +
|
||||
buffer * screenDefinition->nextBufferAdvance +
|
||||
plane * screenDefinition->nextBitplaneAdvance;
|
||||
}
|
||||
}
|
||||
|
||||
void swapCurrentScreenBuffer(
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen
|
||||
struct ScreenDefinition *screenDefinition,
|
||||
struct ActiveScreenBufferDetails *currentScreen
|
||||
) {
|
||||
setCurrentScreen(screenSetup, currentScreen, 1 - currentScreen->currentBuffer);
|
||||
}
|
||||
|
||||
void setupInitialCurrentScreen(
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen
|
||||
) {
|
||||
setCurrentScreen(screenSetup, currentScreen, 0);
|
||||
setActiveScreenBuffer(screenDefinition, currentScreen, 1 - currentScreen->currentBuffer);
|
||||
}
|
||||
|
||||
|
|
25
screen.h
25
screen.h
|
@ -6,7 +6,7 @@
|
|||
#define SCREEN_WIDTH (320)
|
||||
#define SCREEN_HEIGHT (256)
|
||||
|
||||
struct ScreenSetup {
|
||||
struct ScreenDefinition {
|
||||
// human entered
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
|
@ -19,32 +19,33 @@ struct ScreenSetup {
|
|||
uint16_t nextBufferAdvance;
|
||||
};
|
||||
|
||||
struct CurrentScreen {
|
||||
struct ActiveScreenBufferDetails {
|
||||
uint16_t currentBuffer;
|
||||
unsigned char *planes[8];
|
||||
};
|
||||
|
||||
void setupScreen(
|
||||
struct ScreenSetup *screenSetup,
|
||||
void allocateDoubleBufferedScreenMemory(
|
||||
struct ScreenDefinition *screenSetup,
|
||||
struct ActiveScreenBufferDetails *currentScreen,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
uint8_t bitplanes
|
||||
);
|
||||
void teardownScreen(struct ScreenSetup *screenSetup);
|
||||
void teardownScreen(struct ScreenDefinition *screenSetup);
|
||||
|
||||
void setCurrentScreen(
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen,
|
||||
void setActiveScreenBuffer(
|
||||
struct ScreenDefinition *screenSetup,
|
||||
struct ActiveScreenBufferDetails *currentScreen,
|
||||
short int buffer
|
||||
);
|
||||
|
||||
void swapCurrentScreenBuffer(
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen
|
||||
struct ScreenDefinition *screenSetup,
|
||||
struct ActiveScreenBufferDetails *currentScreen
|
||||
);
|
||||
|
||||
void setupInitialCurrentScreen(
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen
|
||||
struct ScreenDefinition *screenSetup,
|
||||
struct ActiveScreenBufferDetails *currentScreen
|
||||
);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue