code cleanups, on to sprites
This commit is contained in:
parent
b06af2cb4a
commit
eb5daa1684
84
bun.c
84
bun.c
|
@ -14,6 +14,31 @@
|
|||
#include "bun.h"
|
||||
#include "system/system.h"
|
||||
|
||||
#define COOL_BUN_WIDTH (32)
|
||||
#define COOL_BUN_WIDTH_BYTES (COOL_BUN_WIDTH / 8)
|
||||
#define COOL_BUN_HEIGHT (32)
|
||||
#define COOL_BUN_PLANES (2)
|
||||
#define COOL_BUN_LAST_ROW (COOL_BUN_HEIGHT - 1)
|
||||
#define COOL_BUN_LAST_ROW_BYTES (COOL_BUN_LAST_ROW * COOL_BUN_WIDTH_BYTES)
|
||||
|
||||
#define COOL_BUN_PLANE_SIZE (COOL_BUN_WIDTH_BYTES * COOL_BUN_HEIGHT)
|
||||
#define COOL_BUN_MEMORY_SIZE (COOL_BUN_PLANE_SIZE * COOL_BUN_PLANES)
|
||||
|
||||
#define BUN_MAX_RANGE (31 + 320)
|
||||
|
||||
#define BUN_COUNT (12)
|
||||
#define BUN_SPEED (1)
|
||||
|
||||
#define BUN_HORIZ_DISTANCE_BETWEEN_BUNS ((BUN_MAX_RANGE / 4) - COOL_BUN_WIDTH)
|
||||
#define BUN_TOTAL_HORIZ_DISTANCE (BUN_HORIZ_DISTANCE_BETWEEN_BUNS + COOL_BUN_WIDTH)
|
||||
#define BUN_ROW_START (30)
|
||||
#define BUN_VERT_DISTANCE_BETWEEN_BUNS (20)
|
||||
#define BUN_TOTAL_VERT_DISTANCE (COOL_BUN_HEIGHT + BUN_VERT_DISTANCE_BETWEEN_BUNS)
|
||||
#define FRAME_MAX (BUN_TOTAL_HORIZ_DISTANCE / BUN_SPEED)
|
||||
|
||||
#define FRAMES_FOR_SCREEN (90)
|
||||
#define BUN_WAVE_LENGTH (FRAMES_FOR_SCREEN / 2)
|
||||
|
||||
// linked as raw bytes in assembler
|
||||
extern unsigned char far coolbun[];
|
||||
|
||||
|
@ -26,9 +51,8 @@ unsigned char *coolbunArea;
|
|||
|
||||
extern struct Custom far custom;
|
||||
|
||||
void setupBun() {
|
||||
void setupBun(void) {
|
||||
unsigned char *currentCoolBunArea, *currentCoolBun;
|
||||
unsigned int x, y, plane;
|
||||
|
||||
coolbunArea = AllocMem(COOL_BUN_MEMORY_SIZE, MEMF_CHIP | MEMF_CLEAR);
|
||||
currentCoolBunArea = coolbunArea;
|
||||
|
@ -37,7 +61,7 @@ void setupBun() {
|
|||
CopyMem(coolbun, coolbunArea, COOL_BUN_MEMORY_SIZE);
|
||||
}
|
||||
|
||||
void teardownBun() {
|
||||
void teardownBun(void) {
|
||||
FreeMem(coolbunArea, COOL_BUN_MEMORY_SIZE);
|
||||
}
|
||||
|
||||
|
@ -195,37 +219,10 @@ void renderBun(
|
|||
}
|
||||
}
|
||||
|
||||
short int allBunPositionsByFrame[FRAMES_FOR_SCREEN][BUN_COUNT][2];
|
||||
|
||||
void calculateAllBunPositions(
|
||||
struct ScreenSetup *screenSetup
|
||||
) {
|
||||
int frame;
|
||||
|
||||
for (frame = 0; frame < FRAMES_FOR_SCREEN; ++frame) {
|
||||
calculateBunPositions(
|
||||
frame,
|
||||
allBunPositionsByFrame[frame],
|
||||
screenSetup
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#define MAX_SINE_WAVE_CHANGE (20)
|
||||
|
||||
int bunAngleAdjustments[BUN_COUNT];
|
||||
|
||||
void buildBunAngleAdjustments() {
|
||||
int row, column, current, angleAdjustment;
|
||||
for (current = 0; current < BUN_COUNT; ++current) {
|
||||
angleAdjustment = 0;
|
||||
if (current % 2 == 1) angleAdjustment += 180;
|
||||
if (current / 4 == 1) angleAdjustment += 90;
|
||||
|
||||
bunAngleAdjustments[current] = angleAdjustment;
|
||||
}
|
||||
}
|
||||
|
||||
void calculateBunPositions(
|
||||
uint16_t frame,
|
||||
short int bunPositions[BUN_COUNT][2],
|
||||
|
@ -261,6 +258,33 @@ void calculateBunPositions(
|
|||
}
|
||||
}
|
||||
|
||||
short int allBunPositionsByFrame[FRAMES_FOR_SCREEN][BUN_COUNT][2];
|
||||
|
||||
void calculateAllBunPositions(
|
||||
struct ScreenSetup *screenSetup
|
||||
) {
|
||||
int frame;
|
||||
|
||||
for (frame = 0; frame < FRAMES_FOR_SCREEN; ++frame) {
|
||||
calculateBunPositions(
|
||||
frame,
|
||||
allBunPositionsByFrame[frame],
|
||||
screenSetup
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void buildBunAngleAdjustments() {
|
||||
int current, angleAdjustment;
|
||||
for (current = 0; current < BUN_COUNT; ++current) {
|
||||
angleAdjustment = 0;
|
||||
if (current % 2 == 1) angleAdjustment += 180;
|
||||
if (current / 4 == 1) angleAdjustment += 90;
|
||||
|
||||
bunAngleAdjustments[current] = angleAdjustment;
|
||||
}
|
||||
}
|
||||
|
||||
void setupBunRenderer(
|
||||
struct BunRenderer *bunRenderer,
|
||||
struct ScreenSetup *screenSetup,
|
||||
|
|
39
bun.h
39
bun.h
|
@ -3,31 +3,6 @@
|
|||
|
||||
#include "screen.h"
|
||||
|
||||
#define COOL_BUN_WIDTH (32)
|
||||
#define COOL_BUN_WIDTH_BYTES (COOL_BUN_WIDTH / 8)
|
||||
#define COOL_BUN_HEIGHT (32)
|
||||
#define COOL_BUN_PLANES (2)
|
||||
#define COOL_BUN_LAST_ROW (COOL_BUN_HEIGHT - 1)
|
||||
#define COOL_BUN_LAST_ROW_BYTES (COOL_BUN_LAST_ROW * COOL_BUN_WIDTH_BYTES)
|
||||
|
||||
#define COOL_BUN_PLANE_SIZE (COOL_BUN_WIDTH_BYTES * COOL_BUN_HEIGHT)
|
||||
#define COOL_BUN_MEMORY_SIZE (COOL_BUN_PLANE_SIZE * COOL_BUN_PLANES)
|
||||
|
||||
#define BUN_MAX_RANGE (31 + 320)
|
||||
|
||||
#define BUN_COUNT (12)
|
||||
#define BUN_SPEED (1)
|
||||
|
||||
#define BUN_HORIZ_DISTANCE_BETWEEN_BUNS ((BUN_MAX_RANGE / 4) - COOL_BUN_WIDTH)
|
||||
#define BUN_TOTAL_HORIZ_DISTANCE (BUN_HORIZ_DISTANCE_BETWEEN_BUNS + COOL_BUN_WIDTH)
|
||||
#define BUN_ROW_START (30)
|
||||
#define BUN_VERT_DISTANCE_BETWEEN_BUNS (20)
|
||||
#define BUN_TOTAL_VERT_DISTANCE (COOL_BUN_HEIGHT + BUN_VERT_DISTANCE_BETWEEN_BUNS)
|
||||
#define FRAME_MAX (BUN_TOTAL_HORIZ_DISTANCE / BUN_SPEED)
|
||||
|
||||
#define FRAMES_FOR_SCREEN (90)
|
||||
#define BUN_WAVE_LENGTH (FRAMES_FOR_SCREEN / 2)
|
||||
|
||||
struct BunRenderer {
|
||||
struct ScreenSetup *screenSetup;
|
||||
struct CurrentScreen *currentScreen;
|
||||
|
@ -43,17 +18,5 @@ void renderBunFrame(
|
|||
int frame,
|
||||
struct BunRenderer *
|
||||
);
|
||||
|
||||
void renderBun(
|
||||
int x,
|
||||
int y,
|
||||
struct ScreenSetup *screenSetup,
|
||||
struct CurrentScreen *currentScreen
|
||||
);
|
||||
void calculateBunPositions(
|
||||
uint16_t frame,
|
||||
short int bunPositions[BUN_COUNT][2],
|
||||
struct ScreenSetup *screenSetup
|
||||
);
|
||||
|
||||
void teardownBunRenderer(void);
|
||||
#endif
|
||||
|
|
13
main.c
13
main.c
|
@ -37,13 +37,9 @@ void *copperlistSpritePointers[8];
|
|||
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
|
||||
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
|
||||
|
||||
short int bunPositions[BUN_COUNT][2];
|
||||
|
||||
int main(void) {
|
||||
uint16_t *copperlist, *currentCopperlist, result;
|
||||
int i, j, x, y, plane;
|
||||
int blitShiftRight, memoryXOffset, blitWidth;
|
||||
uint32_t wow, wow2;
|
||||
int i, y, plane;
|
||||
|
||||
struct BunRenderer bunRenderer;
|
||||
|
||||
|
@ -56,7 +52,6 @@ int main(void) {
|
|||
|
||||
printf("setting up, i haven't crashed...yet.\n");
|
||||
|
||||
setupBun();
|
||||
setupScreen(&screenSetup, SCREEN_WIDTH, SCREEN_HEIGHT, 3);
|
||||
setupInitialCurrentScreen(&screenSetup, ¤tScreen);
|
||||
|
||||
|
@ -144,11 +139,7 @@ int main(void) {
|
|||
|
||||
freeCopperlist(copperlist);
|
||||
|
||||
teardownBun();
|
||||
|
||||
for (i = 0; i < BUN_COUNT; ++i) {
|
||||
printf("%d %d\n", bunPositions[i][0], bunPositions[i][1]);
|
||||
}
|
||||
teardownBunRenderer();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue