mirror of https://github.com/weiju/amiga-stuff
converted sprite_display.asm from HRM to C
This commit is contained in:
parent
9667769954
commit
cb9243504c
|
@ -16,9 +16,23 @@
|
|||
#define BPL5PTL 0x0f2
|
||||
|
||||
#define BPLCON0 0x100
|
||||
#define COLOR00 0x180
|
||||
#define SPR0PTH 0x120
|
||||
#define SPR0PTL 0x122
|
||||
#define SPR1PTH 0x124
|
||||
#define SPR1PTL 0x126
|
||||
#define SPR2PTH 0x128
|
||||
#define SPR2PTL 0x12a
|
||||
#define SPR3PTH 0x12c
|
||||
#define SPR3PTL 0x12e
|
||||
#define SPR4PTH 0x130
|
||||
#define SPR4PTL 0x132
|
||||
#define SPR5PTH 0x134
|
||||
#define SPR5PTL 0x136
|
||||
#define SPR6PTH 0x138
|
||||
#define SPR6PTL 0x13a
|
||||
#define SPR7PTH 0x13c
|
||||
#define SPR7PTL 0x13e
|
||||
#define COLOR00 0x180
|
||||
|
||||
|
||||
#define USE_PAL 1
|
||||
|
|
|
@ -3,35 +3,42 @@
|
|||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
|
||||
#include "kingtut.h"
|
||||
#define NUM_COLORS 32
|
||||
#define NUM_BITPLANES 5
|
||||
|
||||
/*
|
||||
* A simple setup to display a sprite.
|
||||
*/
|
||||
extern struct Custom custom;
|
||||
char VERSION_STRING[] = "\0$VER: sprites 1.0 (21.09.2016)\0";
|
||||
char VERSION_STRING[] = "\0$VER: sprites1 1.0 (21.09.2016)\0";
|
||||
|
||||
#define NUM_IMG_WORDS (20 * NUM_RASTER_LINES)
|
||||
#define NUM_SPRITES (8)
|
||||
#define COPLIST_SPRPTR_OFFSET 4
|
||||
|
||||
static UWORD __chip imdata[NUM_IMG_WORDS];
|
||||
static UWORD __chip coplist[] = {
|
||||
COP_MOVE(BPL1PTH, 0),
|
||||
COP_MOVE(BPL1PTL, 0),
|
||||
COP_MOVE(BPL2PTH, 0),
|
||||
COP_MOVE(BPL2PTL, 0),
|
||||
COP_MOVE(BPL3PTH, 0),
|
||||
COP_MOVE(BPL3PTL, 0),
|
||||
COP_MOVE(BPL4PTH, 0),
|
||||
COP_MOVE(BPL4PTL, 0),
|
||||
COP_MOVE(BPL5PTH, 0),
|
||||
COP_MOVE(BPL5PTL, 0),
|
||||
COP_MOVE(SPR0PTH, 0),
|
||||
COP_MOVE(SPR0PTL, 0),
|
||||
COP_MOVE(SPR1PTH, 0),
|
||||
COP_MOVE(SPR1PTL, 0),
|
||||
COP_MOVE(SPR2PTH, 0),
|
||||
COP_MOVE(SPR2PTL, 0),
|
||||
COP_MOVE(SPR3PTH, 0),
|
||||
COP_MOVE(SPR3PTL, 0),
|
||||
COP_MOVE(SPR4PTH, 0),
|
||||
COP_MOVE(SPR4PTL, 0),
|
||||
COP_MOVE(SPR5PTH, 0),
|
||||
COP_MOVE(SPR5PTL, 0),
|
||||
COP_MOVE(SPR6PTH, 0),
|
||||
COP_MOVE(SPR6PTL, 0),
|
||||
COP_MOVE(SPR7PTH, 0),
|
||||
COP_MOVE(SPR7PTL, 0),
|
||||
COP_WAIT_END,
|
||||
COP_WAIT_END
|
||||
};
|
||||
|
||||
// space ship data from the Hardware Reference Manual
|
||||
static UWORD __chip spdat0[] = {
|
||||
static UWORD __chip sprite_data[] = {
|
||||
0x6d60, 0x7200, // VSTART+HSTART, VSTOP
|
||||
// data here
|
||||
0x0990, 0x07e0,
|
||||
|
@ -48,31 +55,38 @@ int main(int argc, char **argv)
|
|||
BYTE old_prio = SetTaskPri(current_task, TASK_PRIORITY);
|
||||
BOOL is_pal = init_display();
|
||||
|
||||
custom.bplcon0 = 0x5200; // use bitplane 1-5 = BPU 101, composite color enable
|
||||
custom.bplcon0 = 0x1200; // use bitplane 1-5 = BPU 101, composite color enable
|
||||
custom.bpl1mod = 0; // modulo = 0 for odd bitplanes
|
||||
custom.bplcon1 = 0; // horizontal scroll value = 0 for all playfields
|
||||
custom.bplcon2 = 0x24; // sprites have priority over playfields
|
||||
custom.bpl1mod = 0; // modulo = 0 for odd bitplanes
|
||||
custom.ddfstrt = DDFSTRT_VALUE;
|
||||
custom.ddfstop = DDFSTOP_VALUE;
|
||||
|
||||
custom.diwstrt = DIWSTRT_VALUE;
|
||||
custom.diwstop = DIWSTOP_VALUE;
|
||||
for (int i = 0; i < NUM_COLORS; i++) {
|
||||
custom.color[i] = image_colors[i];
|
||||
|
||||
custom.color[0] = 0x008;
|
||||
custom.color[1] = 0x000;
|
||||
custom.color[17] = 0xff0; // color 1 for sprite 1
|
||||
custom.color[18] = 0x0ff; // color 2 for sprite 1
|
||||
custom.color[19] = 0xf0f; // color 3 for sprite 1
|
||||
|
||||
// fill the whole image data array, effectively setting
|
||||
// the background to color 1
|
||||
for (int i = 0; i < NUM_IMG_WORDS; i++) imdata[i] = 0xffff;
|
||||
|
||||
// set bitmap 0 pointer to initialized data
|
||||
ULONG addr = (ULONG) imdata;
|
||||
coplist[1] = (addr >> 16) & 0xffff;
|
||||
coplist[3] = addr & 0xffff;
|
||||
|
||||
// point sprites 0-7 to the same data structure
|
||||
for (int i = 0; i < NUM_SPRITES; i++) {
|
||||
coplist[COPLIST_SPRPTR_OFFSET + i * 4 + 1] = (((ULONG) sprite_data) >> 16) & 0xffff;
|
||||
coplist[COPLIST_SPRPTR_OFFSET + i * 4 + 3] = ((ULONG) sprite_data) & 0xffff;
|
||||
}
|
||||
|
||||
// Initialize copper list with image data address
|
||||
for (int i = 0; i < NUM_BITPLANES; i++) {
|
||||
ULONG addr = (ULONG) &(image_data[i * 20 * NUM_RASTER_LINES]);
|
||||
coplist[i * 4 + 1] = (addr >> 16) & 0xffff;
|
||||
coplist[i * 4 + 3] = addr & 0xffff;
|
||||
}
|
||||
|
||||
coplist[21] = (((ULONG) spdat0) >> 16) & 0xffff;
|
||||
coplist[23] = ((ULONG) spdat0) & 0xffff;
|
||||
|
||||
//custom.dmacon = 0x8020;
|
||||
custom.cop1lc = (ULONG) coplist;
|
||||
custom.cop1lc = (ULONG) coplist;
|
||||
custom.dmacon = 0x83a0; // Bitplane + Copper + Sprite DMA activate
|
||||
custom.copjmp1 = 1;
|
||||
|
||||
waitmouse();
|
||||
|
|
Loading…
Reference in New Issue