cool-bun-demo/main.c

127 lines
3.1 KiB
C
Raw Normal View History

2024-04-30 02:12:48 +00:00
#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>
2024-05-27 18:58:13 +00:00
#include <graphics/gfx.h>
2024-05-27 20:50:56 +00:00
#include "system/blitter.h"
#include "system/copper.h"
#include "system/system.h"
2024-05-02 16:52:06 +00:00
#include "screen.h"
#include "types.h"
2024-05-28 12:02:28 +00:00
#include "bun.h"
2024-04-30 02:12:48 +00:00
2024-05-02 16:52:06 +00:00
extern struct Custom far custom;
2024-05-27 18:58:13 +00:00
// 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;
2024-05-28 12:02:28 +00:00
struct CurrentScreen currentScreen;
2024-05-27 18:58:13 +00:00
2024-05-28 12:02:28 +00:00
#define offsetof(s, m) &((struct s *)0)->m
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
2024-05-27 18:58:13 +00:00
2024-04-30 02:12:48 +00:00
int main(void) {
2024-05-02 16:52:06 +00:00
uint16_t *copperlist, *currentCopperlist;
2024-05-27 18:58:13 +00:00
int i, x, y, plane, result;
int blitShiftRight, memoryXOffset, blitWidth;
2024-05-28 12:02:28 +00:00
color_t colors[8];
2024-05-27 18:58:13 +00:00
colors[0] = 0x09b8;
colors[1] = 0x0000;
colors[2] = 0x0fff;
2024-04-30 02:12:48 +00:00
colors[3] = 0x000f;
2024-05-28 12:02:28 +00:00
setupScreen(&screenSetup, SCREEN_WIDTH, SCREEN_HEIGHT, 3);
setupInitialCurrentScreen(&screenSetup, &currentScreen);
2024-04-30 02:12:48 +00:00
2024-05-28 12:02:28 +00:00
teardownScreen(&screenSetup);
return 0;
2024-04-30 02:12:48 +00:00
// blitter copy the first bitplane row down to the second
2024-05-02 16:52:06 +00:00
copperlist = prepareNewCopperlist();
2024-04-30 02:12:48 +00:00
2024-05-02 16:52:06 +00:00
takeOverSystem();
setCopperlist(copperlist);
setUpDisplay(&screenSetup);
currentCopperlist = addDisplayToCopperlist(copperlist, &screenSetup);
2024-05-28 12:02:28 +00:00
//currentCopperlist = addColorsToCopperlist(currentCopperlist, colors, 16);
*(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;
}
2024-05-02 16:52:06 +00:00
endCopperlist(currentCopperlist);
2024-05-27 20:50:56 +00:00
for (i = -31; i < screenSetup.width - 1; ++i) {
2024-05-28 12:02:28 +00:00
//y = WaitBOF(250);
WaitTOF();
/*
2024-05-27 18:58:13 +00:00
for (plane = 0; plane < 2; ++plane) {
2024-05-27 20:50:56 +00:00
custom.bltcon0 = 0xc0 + (1 << 8);
2024-05-27 18:58:13 +00:00
custom.bltcon1 = 0;
custom.bltadat = 0x0000;
custom.bltafwm = 0xffff;
custom.bltalwm = 0xffff;
2024-05-27 20:50:56 +00:00
custom.bltdpt = screenSetup.memoryStart + (45 * screenSetup.width) / 8 + plane * screenSetup.nextBitplaneAdvance;
custom.bltdmod = 0;
custom.bltsize = 20 + (COOL_BUN_MEMORY_SIZE << 6);
2024-05-27 18:58:13 +00:00
WaitBlit();
}
2024-05-28 12:02:28 +00:00
*/
renderBun(i, 45, &screenSetup);
}
2024-05-27 18:58:13 +00:00
2024-05-28 12:02:28 +00:00
for (i = 0; i < 100; ++i) {
WaitTOF();
2024-04-30 02:12:48 +00:00
}
2024-05-02 16:52:06 +00:00
giveBackSystem();
2024-04-30 02:12:48 +00:00
2024-05-28 12:02:28 +00:00
freeScreen(&screenSetup);
2024-04-30 02:12:48 +00:00
2024-05-02 16:52:06 +00:00
freeCopperlist(copperlist);
2024-04-30 02:12:48 +00:00
2024-05-28 12:02:28 +00:00
teardownBun();
2024-05-02 16:52:06 +00:00
2024-04-30 02:12:48 +00:00
return 0;
}