amiga_boottest

diff src/main.c @ 2:58ebd84822e7

it works
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 22 Feb 2018 12:44:20 +0200
parents 48093e4bd99a
children 555b986cc420
line diff
     1.1 --- a/src/main.c	Wed Feb 21 18:00:45 2018 +0200
     1.2 +++ b/src/main.c	Thu Feb 22 12:44:20 2018 +0200
     1.3 @@ -2,58 +2,69 @@
     1.4  #include "intr.h"
     1.5  #include "copper.h"
     1.6  
     1.7 -void wait_vpos(int x);
     1.8 -void wait_vblank(void);
     1.9 -
    1.10  #define BPLSZ  (320 / 8 * 256)
    1.11  static unsigned char fb0[BPLSZ];
    1.12  
    1.13 +extern uint16_t dbgval;
    1.14 +
    1.15 +#define wait_vpos(x) \
    1.16 +	asm volatile ( \
    1.17 +		"0: move.l 0xdff004, %%d0\n\t" \
    1.18 +		"and.l #0x1ff00, %%d0\n\t" \
    1.19 +		"cmp.l %0, %%d0\n\t" \
    1.20 +		"bne 0b\n\t" \
    1.21 +		:: "i"((x) << 8) : "%d0")
    1.22 +
    1.23 +#define wait_vblank() wait_vpos(300)
    1.24 +#define wait_scanline(x) wait_vpos((x) + 0x2c)
    1.25 +
    1.26 +#define clear_bpl(p) \
    1.27 +	asm volatile ( \
    1.28 +		"move.l %0, %%a0\n\t" \
    1.29 +		"move.l %1, %%d0\n\t" \
    1.30 +		"0: clr.l (%%a0)+\n\t" \
    1.31 +		"dbra %%d0, 0b\n\t" \
    1.32 +		:: "a"(p), "i"(BPLSZ / 4 - 1) \
    1.33 +		: "a0", "d0")
    1.34 +
    1.35 +static uint32_t coplist[] = {
    1.36 +	COPPER_MOVE(REGN_BPL1PTH, 0),
    1.37 +	COPPER_MOVE(REGN_BPL1PTL, 0),
    1.38 +	COPPER_VWAIT(50),
    1.39 +	COPPER_MOVE(REGN_COLOR0, 0x00a),
    1.40 +	COPPER_VWAIT(60),
    1.41 +	COPPER_MOVE(REGN_COLOR0, 0x008),
    1.42 +	COPPER_END
    1.43 +};
    1.44 +
    1.45  int main(void)
    1.46  {
    1.47 -	uint32_t fb0_addr = (uint32_t)fb0;
    1.48 -
    1.49  	REG_INTENA = SETBITS(INTEN_VERTB | INTEN_MASTER);
    1.50  
    1.51  	REG_DMACON = CLRBITS(DMA_ALL);
    1.52 -	REG_BPLCON0 = BPLCON0_COUNT(0) | BPLCON0_COLOR;
    1.53 +	REG_BPLCON0 = BPLCON0_COUNT(1) | BPLCON0_COLOR;
    1.54  	REG_BPLCON1 = 0;
    1.55  	REG_DIWSTART = 0x2981;
    1.56  	REG_DIWSTOP = 0x29c1;
    1.57  	REG_DDFSTART = 0x38;
    1.58  	REG_DDFSTOP = 0xd0;
    1.59  
    1.60 -	REG_COLOR0 = 0x00f;
    1.61 -	REG_COLOR1 = 0xff0;
    1.62 -
    1.63 -	init_copper(0, 0);
    1.64 +	REG_COLOR0 = 0x008;
    1.65 +	REG_COLOR1 = 0xaaa;
    1.66  
    1.67  	wait_vblank();
    1.68 -	add_copper(COPPER_MOVE(REGN_BPL1PTH, fb0_addr >> 16));
    1.69 -	add_copper(COPPER_MOVE(REGN_BPL1PTL, fb0_addr));
    1.70 +	coplist[0] = COPPER_MOVE(REGN_BPL1PTH, (uint32_t)fb0 >> 16);
    1.71 +	coplist[1] = COPPER_MOVE(REGN_BPL1PTL, (uint32_t)fb0);
    1.72 +	REG32_COP1LC = (uint32_t)coplist;
    1.73 +	REG_COPJMP1 = 0;
    1.74  
    1.75 -	add_copper(COPPER_VWAIT(64));
    1.76 -	add_copper(COPPER_MOVE(REGN_COLOR0, 0xf00));
    1.77 -	add_copper(COPPER_VWAIT(70));
    1.78 -	add_copper(COPPER_MOVE(REGN_COLOR0, 0x00f));
    1.79 +	fb0[128 * 320 / 8 + 160 / 8] = 8;
    1.80  
    1.81 -	add_copper(COPPER_END);
    1.82 +	REG_DMACON = SETBITS(DMA_BPL | DMA_COPPER | DMA_MASTER);
    1.83  
    1.84 -	fb0[128 * 320 / 8] = 8;
    1.85 +	for(;;) {
    1.86 +		wait_vblank();
    1.87 +	}
    1.88  
    1.89 -	REG_DMACON = SETBITS(DMA_COPPER | DMA_MASTER);
    1.90 -	enable_intr();
    1.91 -
    1.92 -	for(;;);
    1.93  	return 0;
    1.94  }
    1.95 -
    1.96 -void wait_vpos(int x)
    1.97 -{
    1.98 -	x <<= 8;
    1.99 -	while((REG32_VPOSR & 0x1ff00) < x);
   1.100 -}
   1.101 -
   1.102 -void wait_vblank(void)
   1.103 -{
   1.104 -	wait_vpos(300);
   1.105 -}