mirror of
https://frontier.innolan.net/github/AmigaExamples.git
synced 2026-09-12 01:32:35 +00:00
First attempt at a copper list
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
MAKEADF=../tools/makeadf
|
||||
FLOPPY=bin/image.adf
|
||||
EXTRA=out/copper-list.s
|
||||
|
||||
MODULE=copper.s
|
||||
|
||||
include ../base.mk
|
||||
|
||||
out/copper-list.s: out/copper_gen
|
||||
./out/copper_gen > out/copper-list.s
|
||||
|
||||
out/copper_gen: copper_gen.c
|
||||
gcc copper_gen.c -o out/copper_gen
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Copper bars
|
||||
===========
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
include "../include/registers.i"
|
||||
include "hardware/dmabits.i"
|
||||
include "hardware/intbits.i"
|
||||
|
||||
LVL3_INT_VECTOR equ $6c
|
||||
SCREEN_WIDTH equ 320
|
||||
SCREEN_HEIGHT equ 256
|
||||
SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8)
|
||||
SCREEN_BIT_DEPTH equ 1
|
||||
SCREEN_RES equ 8 ; 8=lo resolution, 4=hi resolution
|
||||
RASTER_X_START equ $81 ; Hard coded coordinates from hardware manual
|
||||
RASTER_Y_START equ $2c
|
||||
RASTER_X_STOP equ RASTER_X_START+SCREEN_WIDTH
|
||||
RASTER_Y_STOP equ RASTER_Y_START+SCREEN_HEIGHT
|
||||
|
||||
entry:
|
||||
;; custom chip base globally in a6
|
||||
lea CUSTOM,a6
|
||||
|
||||
;; poke bitplane pointers into the copper list
|
||||
lea bitplane(pc),a0
|
||||
lea copperBitPlanePtr(pc),a1
|
||||
move.l a0,d0
|
||||
move.w d0,6(a1) ;BPL1PTL
|
||||
swap d0
|
||||
move.w d0,2(a1) ;BPL1PTH
|
||||
|
||||
move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6)
|
||||
move.w #((RASTER_Y_STOP-256)<<8)|(RASTER_X_STOP-256),DIWSTOP(a6)
|
||||
|
||||
move.w #(RASTER_X_START/2-SCREEN_RES),DDFSTRT(a6)
|
||||
move.w #(RASTER_X_START/2-SCREEN_RES)+(8*((SCREEN_WIDTH/16)-1)),DDFSTOP(a6)
|
||||
|
||||
move.w #(SCREEN_BIT_DEPTH<<12)|$200,BPLCON0(a6)
|
||||
move.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL1MOD(a6)
|
||||
|
||||
;; install copper list and enable DMA
|
||||
lea copper(pc),a0
|
||||
move.l a0,COP1LC(a6)
|
||||
move.w COPJMP1(a6),d0
|
||||
move.w #(DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),dmacon(a6)
|
||||
|
||||
.mainLoop:
|
||||
bra.b .mainLoop
|
||||
|
||||
copper:
|
||||
copperBitPlanePtr:
|
||||
dc.w BPL1PTH,0 ; address of the bitplane will be poked once we know it
|
||||
dc.w BPL1PTL,0
|
||||
|
||||
dc.w COLOR00,$0000
|
||||
|
||||
include "out/copper-list.s"
|
||||
|
||||
dc.l $fffffffe
|
||||
|
||||
bitplane:
|
||||
dcb.b (SCREEN_WIDTH*SCREEN_HEIGHT)/8,$00
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,69 @@
|
||||
// http://krazydad.com/tutorials/makecolors.php
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
typedef struct {
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
} color;
|
||||
|
||||
#define numColors 50
|
||||
color colors[numColors];
|
||||
|
||||
void
|
||||
makeColorGradient()
|
||||
{
|
||||
float frequencyr = 02;
|
||||
float frequencyg = 02;
|
||||
float frequencyb = 02;
|
||||
float phase1 = 0.1, phase2 = 0.1, phase3 = 0.1;
|
||||
float center = 0x7;
|
||||
float width = 0x7;
|
||||
float len = numColors;
|
||||
|
||||
for (int i = 0; i < len; ++i) {
|
||||
color* c = &colors[i];
|
||||
c->r = sin(frequencyr*i + phase1) * width + center;
|
||||
c->g = sin(frequencyg*i + phase2) * width + center;
|
||||
c->b = sin(frequencyb*i + phase3) * width + center;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
makeColorGradient();
|
||||
|
||||
int lines = 312;
|
||||
color start = { 0x0, 0x0, 0x0};
|
||||
color end = { 0xF, 0xF, 0xF};
|
||||
color current = {0};
|
||||
int count = lines-0x2c;
|
||||
int from = 0, to = 1;
|
||||
int segment = count/((sizeof(colors)/sizeof(color))-1);
|
||||
|
||||
for (int i = 0, y = 0; i < count; i++) {
|
||||
if (i != 0 && i % segment == 0) {
|
||||
from++;
|
||||
to++;
|
||||
}
|
||||
|
||||
float distance = (float)((i)%segment)/segment;
|
||||
color* start = &colors[from];
|
||||
color* end = &colors[to];
|
||||
current.r = start->r + ((end->r-start->r)*distance);
|
||||
current.g = start->g + ((end->g-start->g)*distance);
|
||||
current.b = start->b + ((end->b-start->b)*distance);
|
||||
|
||||
if (0x2c+i <= 255) {
|
||||
printf("\tdc.w $%xdf,$fffe\n\tdc.w COLOR00,$%x%x%x\n",0x2c+i, (int)(current.r+0.5), (int)(current.g+0.5), (int)(current.b+0.5));
|
||||
} else {
|
||||
printf("\tdc.w $%xdf,$fffe\n\tdc.w COLOR00,$%x%x%x\n",y++, (int)(current.r+0.5), (int)(current.g+0.5), (int)(current.b+0.5));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user