floppy_overlays_dir = $HOME/amiga/disks
kickstarts_dir = $HOME/amiga/rom
logs_dir = $HOME/amiga/logs
-screenshots_output_dir = $HOME/amiga/shots
+screenshots_output_dir = .
floppy_drive_speed = 0
floppy_drive_volume = 0
kickstart_file = $HOME/amiga/rom/kickstart-1.3.rom
extern uint32_t **_mem_start;
-int init_copper(int maxlist, int nlists)
+int init_copper(uint32_t *cmem, int maxlist, int nlists)
{
/* allocate and set new copper lists */
if(maxlist <= 0) maxlist = 256;
mode = nlists >= COPPER_DOUBLE ? COPPER_DOUBLE : COPPER_SINGLE;
copmem_size = maxlist * 4 * mode;
- copmem = *_mem_start;
+ copmem = cmem ? cmem : *_mem_start;
curlist = copperlist = copmem;
*curlist = COPPER_END;
COPPER_DOUBLE = 2
};
-int init_copper(int maxlist, int nlists);
+int init_copper(uint32_t *cmem, int maxlist, int nlists);
void cleanup_copper(void);
/* enables copper DMA */
#include "gfx.h"
#include "game.h"
-static uint32_t coplist[32];
+static uint32_t coplist[64];
int main(void)
{
wait_vblank();
- uint32_t *copptr = coplist;
+ init_copper(coplist, 32, COPPER_SINGLE);
for(i=0; i<NBPL; i++) {
uint32_t addr = (intptr_t)bplptr[i];
int reg = REGN_BPL1PTH + i * 4;
- *copptr++ = COPPER_MOVE(reg, addr >> 16);
- *copptr++ = COPPER_MOVE(reg + 2, addr);
+ add_copper(COPPER_MOVE(reg, addr >> 16));
+ add_copper(COPPER_MOVE(reg + 2, addr));
}
- *copptr = COPPER_END;
- REG32_COP1LC = (uint32_t)coplist;
- REG_COPJMP1 = 0;
-
- REG_DMACON = SETBITS(DMA_BPL | DMA_COPPER | DMA_BLITTER | DMA_MASTER);
+ *copperlist_end = COPPER_END;
game_init();
+ wait_vblank();
+ REG_DMACON = SETBITS(DMA_BPL | DMA_COPPER | DMA_BLITTER | DMA_SPRITE | DMA_MASTER);
+
for(;;) {
wait_vblank();
game_draw();
#ifndef DATA_H_
#define DATA_H_
+#include <stdint.h>
+
extern unsigned char test_tile[];
extern unsigned char test_tile_mask[];
+extern uint16_t spr0a[];
+extern uint16_t spr0b[];
+extern uint16_t spr1a[];
+extern uint16_t spr1b[];
+extern uint16_t spr2a[];
+extern uint16_t spr2b[];
+extern uint16_t sprpal[];
+
+#define SPRITE_SLICES 3
+#define SPRITE_HEIGHT 48
+#define NUM_HWSPRITES (SPRITE_SLICES * 2)
+
#endif /* DATA_H_ */
#include <string.h>
#include "game.h"
#include "gfx.h"
+#include "copper.h"
#include "data.h"
#include "hwregs.h" /* XXX */
void draw_tile(int tid, int x, int y, int light);
+static uint16_t *sprdata[NUM_HWSPRITES];
+static uint16_t nullspr[] = {
+ 0x2000, 0x2100,
+ 0x0000, 0x0000,
+ 0x0000, 0x0000
+};
+
+#define SPR_POS(x, y) \
+ (((uint16_t)((x) + 0x40) & 0xff) | ((uint16_t)((y) + 0x2c) << 8))
+
int game_init(void)
{
+ int i, sprpos[] = {136, 76};
+ uint32_t nullspr_addr = (intptr_t)nullspr;
+
REG_COLOR0 = 0x221;
REG_COLOR1 = 0x222;
REG_COLOR2 = 0x332;
REG_COLOR6 = 0x654;
REG_COLOR7 = 0x765;
+ for(i=0; i<16; i++) {
+ REG_COLOR_PTR[i + 16] = sprpal[i];
+ }
+
+ sprdata[0] = spr0a;
+ sprdata[1] = spr0b;
+ sprdata[2] = spr1a;
+ sprdata[3] = spr1b;
+ sprdata[4] = spr2a;
+ sprdata[5] = spr2b;
+
+ for(i=0; i<8; i++) {
+ int reg = REGN_SPR0PTH + i * 4;
+ if(i < NUM_HWSPRITES) {
+ uint16_t sx, sy, vstop;
+ /* initialize active sprites, and set the sprite pointers */
+ uint32_t addr = (intptr_t)sprdata[i];
+ add_copper(COPPER_MOVE(reg, addr >> 16));
+ add_copper(COPPER_MOVE(reg + 2, addr));
+
+ sx = 0x80 + sprpos[0] + (i >> 1) * 16;
+ sy = 0x2c + sprpos[1];
+ vstop = sy + SPRITE_HEIGHT;
+
+ sprdata[i][0] = (sx >> 1) | (sy << 8);
+ sprdata[i][1] = (vstop << 8) | ((vstop >> 7) & 2) |
+ (sx & 1) | ((i & 1) ? 0x80 : 0);
+ } else {
+ /* point the sprite pointers to the null sprite for the rest */
+ add_copper(COPPER_MOVE(reg, nullspr_addr >> 16));
+ add_copper(COPPER_MOVE(reg + 2, nullspr_addr));
+ }
+ }
+
+ *copperlist_end = COPPER_END;
+
return 0;
}
{
int i, j, xoffs, yoffs, ntiles;
+ /* reset sprite data */
+
yoffs = 0;
for(i=0; i<YTILES; i++) {
xoffs = i & 1 ? TILE_W / 2 : 0;
exit 1
fi
+# fix header file char -> unsigned char
+sed -i 's/static char/static unsigned char/' "$1"
+
cc -pedantic -Wall -DHDRFILE=\"$1\" -o /tmp/conv_sprite.bin conv_sprite.c
if [ $? != 0 ]; then
exit 1
for(i=0; i<2; i++) {
printf("\n\t.global spr%d%c\n", slice, i == 0 ? 'a' : 'b');
printf("spr%d%c:\n", slice, i == 0 ? 'a' : 'b');
- printf("\t.short 0\n"); /* position x/y */
- printf("\t.short 0\n"); /* vstop */
+ printf("\t.short 0, 0\n"); /* position x/y, vstop */
sprdata = malloc(height * 2 * sizeof *sprdata);
conv_img_data(i, sprdata, img, width, height, pitch);
for(j=0; j<height; j++) {
- printf("\t.short 0x%x\n", (unsigned int)sprdata[j]);
+ printf("\t.short 0x%x, 0x%x\n", (unsigned int)sprdata[j * 2],
+ (unsigned int)sprdata[j * 2 + 1]);
}
printf("\t.long 0\n"); /* end of sprite CW */