amiga_boottest

diff src/main.c @ 3:555b986cc420

IFS
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 22 Feb 2018 14:46:32 +0200
parents 58ebd84822e7
children 995d42b33974
line diff
     1.1 --- a/src/main.c	Thu Feb 22 12:44:20 2018 +0200
     1.2 +++ b/src/main.c	Thu Feb 22 14:46:32 2018 +0200
     1.3 @@ -1,6 +1,7 @@
     1.4  #include "hwregs.h"
     1.5  #include "intr.h"
     1.6  #include "copper.h"
     1.7 +#include "rng.h"
     1.8  
     1.9  #define BPLSZ  (320 / 8 * 256)
    1.10  static unsigned char fb0[BPLSZ];
    1.11 @@ -30,15 +31,27 @@
    1.12  static uint32_t coplist[] = {
    1.13  	COPPER_MOVE(REGN_BPL1PTH, 0),
    1.14  	COPPER_MOVE(REGN_BPL1PTL, 0),
    1.15 -	COPPER_VWAIT(50),
    1.16 -	COPPER_MOVE(REGN_COLOR0, 0x00a),
    1.17 -	COPPER_VWAIT(60),
    1.18 -	COPPER_MOVE(REGN_COLOR0, 0x008),
    1.19 +
    1.20 +	COPPER_MOVE(REGN_COLOR0, 0x234),
    1.21 +	COPPER_VWAIT(15),
    1.22 +	COPPER_MOVE(REGN_COLOR0, 0x012),
    1.23 +	COPPER_VWAIT(20),
    1.24 +	COPPER_MOVE(REGN_COLOR0, 0x235),
    1.25 +
    1.26 +	COPPER_OVERFLOW,
    1.27 +
    1.28 +	COPPER_VWAIT(220),
    1.29 +	COPPER_MOVE(REGN_COLOR0, 0x346),
    1.30 +	COPPER_VWAIT(225),
    1.31 +	COPPER_MOVE(REGN_COLOR0, 0x234),
    1.32 +
    1.33  	COPPER_END
    1.34  };
    1.35  
    1.36  int main(void)
    1.37  {
    1.38 +	int32_t x = 0, y = 0;
    1.39 +
    1.40  	REG_INTENA = SETBITS(INTEN_VERTB | INTEN_MASTER);
    1.41  
    1.42  	REG_DMACON = CLRBITS(DMA_ALL);
    1.43 @@ -49,8 +62,8 @@
    1.44  	REG_DDFSTART = 0x38;
    1.45  	REG_DDFSTOP = 0xd0;
    1.46  
    1.47 -	REG_COLOR0 = 0x008;
    1.48 -	REG_COLOR1 = 0xaaa;
    1.49 +	REG_COLOR0 = 0x235;
    1.50 +	REG_COLOR1 = 0x2f5;
    1.51  
    1.52  	wait_vblank();
    1.53  	coplist[0] = COPPER_MOVE(REGN_BPL1PTH, (uint32_t)fb0 >> 16);
    1.54 @@ -58,11 +71,44 @@
    1.55  	REG32_COP1LC = (uint32_t)coplist;
    1.56  	REG_COPJMP1 = 0;
    1.57  
    1.58 -	fb0[128 * 320 / 8 + 160 / 8] = 8;
    1.59 -
    1.60  	REG_DMACON = SETBITS(DMA_BPL | DMA_COPPER | DMA_MASTER);
    1.61  
    1.62 +	srand(0);
    1.63 +
    1.64 +#define CDF0	655
    1.65 +#define CDF1	56361
    1.66 +#define CDF2	60948
    1.67 +
    1.68  	for(;;) {
    1.69 +		int sel = rand() & 0xffff;
    1.70 +		int32_t px, py;
    1.71 +		unsigned char *pptr;
    1.72 +
    1.73 +		if(sel < CDF0) {
    1.74 +			x = 0;
    1.75 +			y = (y >> 8) * (10486 >> 8);
    1.76 +		} else if(sel < CDF1) {
    1.77 +			int32_t nx = (x >> 8) * (55705 >> 8) + (y >> 8) * (2621 >> 8);
    1.78 +			y = (y >> 8) * (55705 >> 8) - (x >> 8) * (2621 >> 8) + 104857;
    1.79 +			x = nx;
    1.80 +		} else if(sel < CDF2) {
    1.81 +			int32_t nx = (x >> 8) * (13107 >> 8) - (y >> 8) * (17039 >> 8);
    1.82 +			y = (x >> 8) * (15073 >> 8) + (y >> 8) * (14417 >> 8) + 104857;
    1.83 +			x = nx;
    1.84 +		} else {
    1.85 +			int32_t nx = (y >> 8) * (18350 >> 8) - (x >> 8) * (9830 >> 8);
    1.86 +			y = (x >> 8) * (17039 >> 8) + (y >> 8) * (15728 >> 8) + 28835;
    1.87 +			x = nx;
    1.88 +		}
    1.89 +
    1.90 +		px = (y >> 11);
    1.91 +		py = 128 - (x >> 11);
    1.92 +
    1.93 +		if(py >= 0) {
    1.94 +			pptr = fb0 + (py * 320 + px) / 8;
    1.95 +			*pptr = *pptr | (0x80 >> (px & 7));
    1.96 +		}
    1.97 +
    1.98  		wait_vblank();
    1.99  	}
   1.100