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-06-01 11:42:11 +00:00
|
|
|
void *copperlistBitplanePointers[8][2];
|
|
|
|
void *copperlistSpritePointers[8];
|
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-06-01 11:42:11 +00:00
|
|
|
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
|
2024-06-02 20:03:16 +00:00
|
|
|
uint16_t custom_sprite_control = (uint16_t)offsetof(Custom, spr);
|
|
|
|
|
|
|
|
uint16_t chip spriteData[200];
|
2024-06-03 16:46:32 +00:00
|
|
|
uint16_t chip spriteData2[20];
|
2024-06-02 20:03:16 +00:00
|
|
|
|
|
|
|
uint16_t spritePositionsEachLine[256][2];
|
|
|
|
|
|
|
|
void calculageSpritePositionsEachLine() {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 255; ++i) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SPRPOS(x, y) (((y & 0xff) << 8) + ((x & 0x1fe) >> 1))
|
|
|
|
#define SPRCTL(x, y, height) ( \
|
|
|
|
((height & 0xff) << 8) + \
|
|
|
|
((y & 0x100) >> 6) + \
|
|
|
|
((height & 0x100) >> 7) + \
|
|
|
|
(x & 1) \
|
|
|
|
)
|
2024-05-27 18:58:13 +00:00
|
|
|
|
2024-04-30 02:12:48 +00:00
|
|
|
int main(void) {
|
2024-06-01 11:42:11 +00:00
|
|
|
uint16_t *copperlist, *currentCopperlist, result;
|
2024-06-02 20:03:16 +00:00
|
|
|
int i, x, y, height, plane;
|
2024-05-27 18:58:13 +00:00
|
|
|
|
2024-06-02 18:37:37 +00:00
|
|
|
struct BunRenderer bunRenderer;
|
|
|
|
|
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-06-02 20:03:16 +00:00
|
|
|
printf("%p\n", &spriteData);
|
2024-06-02 18:37:37 +00:00
|
|
|
printf("setting up, i haven't crashed...yet.\n");
|
|
|
|
|
2024-06-02 20:03:16 +00:00
|
|
|
x = 150;
|
2024-06-03 16:46:32 +00:00
|
|
|
y = 47;
|
2024-06-02 20:03:16 +00:00
|
|
|
height = y + 98;
|
|
|
|
|
|
|
|
printf("%d, %d, %d\n", x, y, height);
|
|
|
|
|
|
|
|
spriteData[0] = SPRPOS(x, y);
|
|
|
|
spriteData[1] = SPRCTL(x, y, height);
|
|
|
|
|
|
|
|
printf("%0x %0x\n", spriteData[0], spriteData[1]);
|
|
|
|
|
2024-06-03 16:46:32 +00:00
|
|
|
for (i = 2; i < 198; i += 2) {
|
|
|
|
spriteData[i] = 0x0f + i % 16;
|
|
|
|
spriteData[i + 1] = 0xf0f0;
|
2024-06-02 20:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
spriteData[198] = 0x0000;
|
|
|
|
spriteData[199] = 0x0000;
|
|
|
|
|
2024-06-03 16:46:32 +00:00
|
|
|
spriteData2[0] = SPRPOS(220, 70);
|
|
|
|
spriteData2[1] = SPRCTL(220, 70, 72);
|
|
|
|
/*
|
|
|
|
spriteData2[2] = 0x0345;
|
|
|
|
spriteData2[3] = 0x5678;
|
|
|
|
spriteData2[4] = 0x9abc;
|
|
|
|
spriteData2[5] = 0xdef0;
|
|
|
|
*/
|
|
|
|
spriteData2[2] = 0xffff;
|
|
|
|
spriteData2[3] = 0xffff;
|
|
|
|
spriteData2[4] = 0xffff;
|
|
|
|
spriteData2[5] = 0xffff;
|
|
|
|
spriteData2[6] = SPRPOS(230, 150);
|
|
|
|
spriteData2[7] = SPRCTL(230, 150, 151);
|
|
|
|
spriteData2[8] = 0xffff;
|
|
|
|
spriteData2[9] = 0xffff;
|
|
|
|
spriteData2[10] = 0;
|
|
|
|
spriteData2[11] = 0;
|
|
|
|
|
2024-05-28 12:02:28 +00:00
|
|
|
setupScreen(&screenSetup, SCREEN_WIDTH, SCREEN_HEIGHT, 3);
|
|
|
|
setupInitialCurrentScreen(&screenSetup, ¤tScreen);
|
2024-04-30 02:12:48 +00:00
|
|
|
|
2024-06-02 20:03:16 +00:00
|
|
|
//setupBunRenderer(&bunRenderer, &screenSetup, ¤tScreen);
|
2024-06-02 18:37:37 +00:00
|
|
|
|
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);
|
2024-05-29 11:57:08 +00:00
|
|
|
setUpDisplay((uint32_t)screenSetup.bitplanes);
|
2024-05-02 16:52:06 +00:00
|
|
|
|
2024-06-01 11:42:11 +00:00
|
|
|
currentCopperlist = addDisplayToCopperlist(
|
|
|
|
copperlist,
|
|
|
|
&screenSetup,
|
|
|
|
¤tScreen,
|
|
|
|
&copperlistBitplanePointers
|
|
|
|
);
|
|
|
|
|
|
|
|
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
|
|
|
|
|
2024-05-28 12:02:28 +00:00
|
|
|
*(currentCopperlist++) = custom_color;
|
|
|
|
*(currentCopperlist++) = 0x000;
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_color + 2;
|
|
|
|
*(currentCopperlist++) = 0x000;
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_color + 4;
|
|
|
|
*(currentCopperlist++) = 0xfff;
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_color + 6;
|
|
|
|
*(currentCopperlist++) = 0x00F;
|
|
|
|
|
2024-06-02 20:03:16 +00:00
|
|
|
// sprites
|
|
|
|
*(currentCopperlist++) = custom_color + 34;
|
|
|
|
*(currentCopperlist++) = 0xF0F;
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_color + 36;
|
|
|
|
*(currentCopperlist++) = 0xFF0;
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_color + 38;
|
|
|
|
*(currentCopperlist++) = 0x00F;
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_sprite;
|
2024-06-03 16:46:32 +00:00
|
|
|
*(currentCopperlist++) = ((uint32_t)&spriteData2 >> 16);
|
2024-06-02 20:03:16 +00:00
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_sprite + 2;
|
2024-06-03 16:46:32 +00:00
|
|
|
*(currentCopperlist++) = ((uint32_t)&spriteData2 & 0xffff);
|
2024-06-02 20:03:16 +00:00
|
|
|
|
2024-05-28 12:02:28 +00:00
|
|
|
for (y = 0; y < 256; ++y) {
|
2024-06-03 16:46:32 +00:00
|
|
|
/*
|
|
|
|
if (y > 100 && y < 135) {
|
2024-06-02 20:03:16 +00:00
|
|
|
*(currentCopperlist++) = custom_sprite_control;
|
|
|
|
*(currentCopperlist++) = SPRPOS(60 + y, y);
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_sprite_control + 2;
|
|
|
|
*(currentCopperlist++) = SPRCTL(60 + y, y, 0);
|
|
|
|
}
|
2024-06-03 16:46:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
*(currentCopperlist++) = 1 + (1 << 1) + ((44 + y) << 8);
|
|
|
|
*(currentCopperlist++) = 0xFFFE;
|
|
|
|
|
|
|
|
if (y == 27) {
|
|
|
|
/*
|
|
|
|
*(currentCopperlist++) = custom_sprite_control;
|
|
|
|
*(currentCopperlist++) = 0;
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_sprite_control + 2;
|
|
|
|
*(currentCopperlist++) = 0;
|
|
|
|
*/
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_sprite;
|
|
|
|
*(currentCopperlist++) = ((uint32_t)&spriteData >> 16);
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_sprite + 2;
|
|
|
|
*(currentCopperlist++) = ((uint32_t)&spriteData & 0xffff);
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_sprite_control;
|
|
|
|
*(currentCopperlist++) = SPRPOS(60, 100);
|
|
|
|
|
|
|
|
*(currentCopperlist++) = custom_sprite_control + 2;
|
|
|
|
*(currentCopperlist++) = SPRCTL(60, 100, 198);
|
|
|
|
}
|
2024-06-02 20:03:16 +00:00
|
|
|
|
2024-05-28 12:02:28 +00:00
|
|
|
*(currentCopperlist++) = 1 + (31 << 1) + ((44 + y) << 8);
|
|
|
|
*(currentCopperlist++) = 0xFFFE;
|
|
|
|
*(currentCopperlist++) = custom_color;
|
|
|
|
*(currentCopperlist++) = 0x9b8;
|
|
|
|
|
2024-06-01 11:42:11 +00:00
|
|
|
*(currentCopperlist++) = 1 + ((31 + (320 / 4)) << 1) + ((44 + y) << 8);
|
2024-05-28 12:02:28 +00:00
|
|
|
*(currentCopperlist++) = 0xFFFE;
|
|
|
|
*(currentCopperlist++) = custom_color;
|
|
|
|
*(currentCopperlist++) = 0x000;
|
2024-06-03 16:46:32 +00:00
|
|
|
|
2024-05-28 12:02:28 +00:00
|
|
|
}
|
|
|
|
|
2024-05-02 16:52:06 +00:00
|
|
|
endCopperlist(currentCopperlist);
|
|
|
|
|
2024-06-02 18:37:37 +00:00
|
|
|
for (i = 0; i < 200; ++i) {
|
2024-06-02 20:03:16 +00:00
|
|
|
/*
|
2024-06-01 11:42:11 +00:00
|
|
|
swapCurrentScreenBuffer(&screenSetup, ¤tScreen);
|
2024-05-28 12:02:28 +00:00
|
|
|
|
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-06-01 12:19:10 +00:00
|
|
|
custom.bltdpt = currentScreen.planes[plane];
|
2024-05-27 20:50:56 +00:00
|
|
|
custom.bltdmod = 0;
|
2024-06-01 12:19:10 +00:00
|
|
|
custom.bltsize = screenSetup.byteWidth / 2 + (screenSetup.height << 6);
|
2024-05-27 18:58:13 +00:00
|
|
|
WaitBlit();
|
|
|
|
}
|
2024-05-28 12:02:28 +00:00
|
|
|
|
2024-06-02 20:03:16 +00:00
|
|
|
//renderBunFrame(i, &bunRenderer);
|
2024-06-01 11:42:11 +00:00
|
|
|
|
|
|
|
updateDisplayInCopperList(
|
|
|
|
&screenSetup,
|
|
|
|
¤tScreen,
|
|
|
|
copperlistBitplanePointers
|
|
|
|
);
|
2024-06-02 20:03:16 +00:00
|
|
|
*/
|
2024-06-01 11:42:11 +00:00
|
|
|
|
|
|
|
WaitTOF();
|
2024-05-28 12:02:28 +00:00
|
|
|
}
|
2024-05-27 18:58:13 +00:00
|
|
|
|
2024-06-01 12:19:10 +00:00
|
|
|
/*
|
|
|
|
for (i = 0; i < 200; ++i) {
|
|
|
|
WaitTOF();
|
2024-04-30 02:12:48 +00:00
|
|
|
}
|
2024-06-01 12:19:10 +00:00
|
|
|
*/
|
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-06-02 20:03:16 +00:00
|
|
|
for (i = 10; i < 50; ++i) {
|
|
|
|
printf("%x ", copperlist[i]);
|
|
|
|
}
|
|
|
|
|
2024-05-29 11:57:08 +00:00
|
|
|
teardownScreen(&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-06-02 18:42:36 +00:00
|
|
|
teardownBunRenderer();
|
2024-06-01 12:19:10 +00:00
|
|
|
|
2024-04-30 02:12:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|