128 lines
2.7 KiB
C
128 lines
2.7 KiB
C
/**
|
|
* What do we need
|
|
* * [ ] screen setup
|
|
*/
|
|
|
|
#include <hardware/custom.h>
|
|
#include <hardware/cia.h>
|
|
|
|
#include <clib/graphics_protos.h>
|
|
|
|
#include "system/system.h"
|
|
#include "system/copper.h"
|
|
#include "system/blitter.h"
|
|
|
|
#include "screen.h"
|
|
|
|
extern struct Custom far custom;
|
|
extern struct CIA far ciaa;
|
|
|
|
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
|
|
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
|
|
uint16_t custom_sprite_control = (uint16_t)offsetof(Custom, spr);
|
|
|
|
extern unsigned char chip coolbun[];
|
|
|
|
int main(void) {
|
|
struct ScreenDefinition screenDefinition;
|
|
struct ActiveScreenBufferDetails activeScreenBufferDetails;
|
|
uint16_t *copperlist, *currentCopperlist;
|
|
void *copperlistBitplanePointers[8][2];
|
|
int i, plane, x, y, dirX, dirY, shift, byteX;
|
|
|
|
allocateDoubleBufferedScreenMemory(
|
|
&screenDefinition,
|
|
&activeScreenBufferDetails,
|
|
320,
|
|
256,
|
|
2
|
|
);
|
|
|
|
copperlist = prepareNewCopperlist(300);
|
|
|
|
currentCopperlist = addDisplayToCopperlist(
|
|
copperlist,
|
|
&screenDefinition,
|
|
&activeScreenBufferDetails,
|
|
&copperlistBitplanePointers
|
|
);
|
|
|
|
COPPERLIST_MOVE(currentCopperlist, custom_color, 0x3a6);
|
|
COPPERLIST_MOVE(currentCopperlist, custom_color + 2, 0x000);
|
|
COPPERLIST_MOVE(currentCopperlist, custom_color + 4, 0xfff);
|
|
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
|
|
|
|
endCopperlist(currentCopperlist);
|
|
|
|
takeOverSystem();
|
|
|
|
setCopperlist(copperlist);
|
|
setUpDisplay((uint32_t)screenDefinition.bitplanes);
|
|
|
|
// Render a bun at 32x50
|
|
|
|
x = 32;
|
|
y = 50;
|
|
dirX = 1;
|
|
dirY = 1;
|
|
|
|
while (1) {
|
|
WaitTOF();
|
|
|
|
swapCurrentScreenBuffer(&screenDefinition, &activeScreenBufferDetails);
|
|
|
|
shift = x & 15;
|
|
byteX = (x >> 4 * 2);
|
|
|
|
for (plane = 0; plane < 2; ++plane) {
|
|
custom.bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
|
|
custom.bltcon1 = BLTCON1(BLITTER_ASCENDING, 0);
|
|
|
|
custom.bltapt = coolbun + (plane * 4 * 32);
|
|
custom.bltdpt = activeScreenBufferDetails.planes[plane] + (y * 320 / 8) + byteX;
|
|
custom.bltafwm = 0xffff;
|
|
|
|
if (shift == 0) {
|
|
custom.bltalwm = 0xffff;;
|
|
} else {
|
|
custom.bltalwm = 0x0000;
|
|
}
|
|
|
|
custom.bltamod = shift ? -2 : 0;
|
|
custom.bltdmod = 40 - (shift ? 6 : 4);
|
|
|
|
custom.bltsize = (shift ? 3 : 2) + (32 << 6);
|
|
|
|
WaitBlit();
|
|
}
|
|
|
|
x += dirX;
|
|
if (x == 320 - 32) {
|
|
x -= 1;
|
|
dirX = -dirX;
|
|
}
|
|
if (x < 0) {
|
|
x = 0;
|
|
dirX = -dirX;
|
|
}
|
|
|
|
y += dirY;
|
|
if (y == 256 - 32) {
|
|
y -= 1;
|
|
dirY = -dirY;
|
|
}
|
|
if (y > 0) {
|
|
y = 0;
|
|
dirY -= dirY;
|
|
}
|
|
|
|
if ((ciaa.ciapra >> 6) != 3) break;
|
|
}
|
|
|
|
giveBackSystem();
|
|
|
|
freeCopperlist(copperlist);
|
|
|
|
teardownScreen(&screenDefinition);
|
|
}
|