146 lines
3.4 KiB
C
146 lines
3.4 KiB
C
#include <stdio.h>
|
|
|
|
#include <clib/exec_protos.h>
|
|
#include <clib/graphics_protos.h>
|
|
#include <exec/exec.h>
|
|
|
|
#include <hardware/custom.h>
|
|
#include <hardware/dmabits.h>
|
|
|
|
#include <graphics/gfx.h>
|
|
|
|
#include "system/blitter.h"
|
|
#include "system/copper.h"
|
|
#include "system/system.h"
|
|
|
|
#include "screen.h"
|
|
#include "types.h"
|
|
#include "bun.h"
|
|
|
|
extern struct Custom far custom;
|
|
|
|
// 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)
|
|
|
|
volatile short *dbg = (volatile short *)0x100;
|
|
|
|
unsigned char *scratchArea;
|
|
struct ScreenSetup screenSetup;
|
|
struct CurrentScreen currentScreen;
|
|
void *copperlistBitplanePointers[8][2];
|
|
void *copperlistSpritePointers[8];
|
|
|
|
#define offsetof(s, m) &((struct s *)0)->m
|
|
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
|
|
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
|
|
|
|
int main(void) {
|
|
uint16_t *copperlist, *currentCopperlist, result;
|
|
int i, y, plane;
|
|
|
|
struct BunRenderer bunRenderer;
|
|
|
|
color_t colors[8];
|
|
|
|
colors[0] = 0x09b8;
|
|
colors[1] = 0x0000;
|
|
colors[2] = 0x0fff;
|
|
colors[3] = 0x000f;
|
|
|
|
printf("setting up, i haven't crashed...yet.\n");
|
|
|
|
setupScreen(&screenSetup, SCREEN_WIDTH, SCREEN_HEIGHT, 3);
|
|
setupInitialCurrentScreen(&screenSetup, ¤tScreen);
|
|
|
|
setupBunRenderer(&bunRenderer, &screenSetup, ¤tScreen);
|
|
|
|
// blitter copy the first bitplane row down to the second
|
|
|
|
copperlist = prepareNewCopperlist();
|
|
|
|
takeOverSystem();
|
|
|
|
setCopperlist(copperlist);
|
|
setUpDisplay((uint32_t)screenSetup.bitplanes);
|
|
|
|
currentCopperlist = addDisplayToCopperlist(
|
|
copperlist,
|
|
&screenSetup,
|
|
¤tScreen,
|
|
&copperlistBitplanePointers
|
|
);
|
|
|
|
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
|
|
|
|
*(currentCopperlist++) = custom_color;
|
|
*(currentCopperlist++) = 0x000;
|
|
|
|
*(currentCopperlist++) = custom_color + 2;
|
|
*(currentCopperlist++) = 0x000;
|
|
|
|
*(currentCopperlist++) = custom_color + 4;
|
|
*(currentCopperlist++) = 0xfff;
|
|
|
|
*(currentCopperlist++) = custom_color + 6;
|
|
*(currentCopperlist++) = 0x00F;
|
|
|
|
for (y = 0; y < 256; ++y) {
|
|
*(currentCopperlist++) = 1 + (31 << 1) + ((44 + y) << 8);
|
|
*(currentCopperlist++) = 0xFFFE;
|
|
*(currentCopperlist++) = custom_color;
|
|
*(currentCopperlist++) = 0x9b8;
|
|
|
|
*(currentCopperlist++) = 1 + ((31 + (320 / 4)) << 1) + ((44 + y) << 8);
|
|
*(currentCopperlist++) = 0xFFFE;
|
|
*(currentCopperlist++) = custom_color;
|
|
*(currentCopperlist++) = 0x000;
|
|
}
|
|
|
|
endCopperlist(currentCopperlist);
|
|
|
|
for (i = 0; i < 200; ++i) {
|
|
swapCurrentScreenBuffer(&screenSetup, ¤tScreen);
|
|
|
|
for (plane = 0; plane < 2; ++plane) {
|
|
custom.bltcon0 = 0xc0 + (1 << 8);
|
|
custom.bltcon1 = 0;
|
|
custom.bltadat = 0x0000;
|
|
custom.bltafwm = 0xffff;
|
|
custom.bltalwm = 0xffff;
|
|
custom.bltdpt = currentScreen.planes[plane];
|
|
custom.bltdmod = 0;
|
|
custom.bltsize = screenSetup.byteWidth / 2 + (screenSetup.height << 6);
|
|
WaitBlit();
|
|
}
|
|
|
|
renderBunFrame(i, &bunRenderer);
|
|
|
|
updateDisplayInCopperList(
|
|
&screenSetup,
|
|
¤tScreen,
|
|
copperlistBitplanePointers
|
|
);
|
|
|
|
WaitTOF();
|
|
}
|
|
|
|
/*
|
|
for (i = 0; i < 200; ++i) {
|
|
WaitTOF();
|
|
}
|
|
*/
|
|
|
|
giveBackSystem();
|
|
|
|
teardownScreen(&screenSetup);
|
|
|
|
freeCopperlist(copperlist);
|
|
|
|
teardownBunRenderer();
|
|
|
|
return 0;
|
|
}
|