Made some changes to reflect my improved understanding
This commit is contained in:
parent
b55eba8c32
commit
71bffd453a
|
@ -1,3 +1,12 @@
|
|||
Copper bars
|
||||
===========
|
||||
|
||||
Now I discover how vertical copper waiting works.
|
||||
|
||||
Some notes:
|
||||
1. The first line is copper address $2c
|
||||
2. The last last is copper address $2c + 256 (screen height) = $12c
|
||||
|
||||
At copper line 255 ($FF), we run out of bits in the copper wait instruction, so if we want to wait for lines after this, we need to wait for a wrapped value. [See here](http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node004D.html)
|
||||
|
||||
[copper_gen.c](copper_gen.c) will generate a copper list with horizontal bars. See http://krazydad.com/tutorials/makecolors.php for details on the algorithm used to generate the bars. You can generate all sorts of different kinds of patterns by changing the algorithm parameters.
|
|
@ -17,14 +17,19 @@ entry:
|
|||
;; custom chip base globally in a6
|
||||
lea CUSTOM,a6
|
||||
|
||||
move #$7ff,DMACON(a6) ; disable all dma
|
||||
move #$7fff,INTENA(a6) ; disable all interrupts
|
||||
|
||||
;; poke bitplane pointers into the copper list
|
||||
lea bitplane(pc),a0
|
||||
lea copperBitPlanePtr(pc),a1
|
||||
lea _BPL1PTL(pc),a1
|
||||
move.l a0,d0
|
||||
move.w d0,6(a1) ;BPL1PTL
|
||||
move.w d0,(a1) ; poke BPL1PTL
|
||||
swap d0
|
||||
move.w d0,2(a1) ;BPL1PTH
|
||||
lea _BPL1PTH(pc),a1
|
||||
move.w d0,(a1) ; poke BPL1PTH
|
||||
|
||||
;; set up playfield
|
||||
move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6)
|
||||
move.w #((RASTER_Y_STOP-256)<<8)|(RASTER_X_STOP-256),DIWSTOP(a6)
|
||||
|
||||
|
@ -34,25 +39,25 @@ entry:
|
|||
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
|
||||
;; install copper list, then enable dma and selected interrupts
|
||||
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)
|
||||
move.w #(DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6)
|
||||
move.w #(INTF_SETCLR|INTF_INTEN|INTF_EXTER),INTENA(a6)
|
||||
|
||||
.mainLoop:
|
||||
bra.b .mainLoop
|
||||
|
||||
copper:
|
||||
dc.w $1fc,0 ;slow fetch mode, AGA compatibility
|
||||
copperBitPlanePtr:
|
||||
dc.w BPL1PTH,0 ; address of the bitplane will be poked once we know it
|
||||
dc.w BPL1PTL,0
|
||||
|
||||
dc.w BPL1PTH
|
||||
_BPL1PTH:
|
||||
dc.w 0 ; hi word address of the bitplane will be poked once we know it
|
||||
dc.w BPL1PTL
|
||||
_BPL1PTL:
|
||||
dc.w 0 ; lo word address of the bitplane will be poked once we know it
|
||||
dc.w COLOR00,$0000
|
||||
|
||||
include "out/copper-list.s"
|
||||
|
||||
include "out/copper-list.s"
|
||||
dc.l $fffffffe
|
||||
|
||||
bitplane:
|
||||
|
|
|
@ -1,34 +1,40 @@
|
|||
// http://krazydad.com/tutorials/makecolors.php
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
char* hpos = "07";
|
||||
int firstVisibleScanLine = 0x2c; // hard coded value from AHRM
|
||||
float numLines = 312; // PAL only
|
||||
|
||||
// Change these values to generate different patterns in the copper list
|
||||
// http://krazydad.com/tutorials/makecolors.php
|
||||
float frequencyr = 0.3, frequencyg = 0.3, frequencyb = 0.3;
|
||||
float phase1 = 0, phase2 = 2, phase3 = 4;
|
||||
float basePhase = 0;
|
||||
float phase1 = basePhase + 0, phase2 = basePhase + 1, phase3 = basePhase + 2;
|
||||
float center = 0x7;
|
||||
float width = 0x7;
|
||||
|
||||
for (int i = 0, line = firstVisibleScanLine; i < (numLines-firstVisibleScanLine); ++i, ++line) {
|
||||
// These values are set up for a standard low-res PAL 320x256 playfield
|
||||
int startLine = 0x2c; // hard coded value from AHRM
|
||||
int screenHeight = 256;
|
||||
int endLine = startLine+screenHeight;
|
||||
int startHpos = 6;
|
||||
int i, line;
|
||||
|
||||
for (i = 0, line = startLine; line < endLine; ++i, ++line) {
|
||||
unsigned char r = (sin(frequencyr*i + phase1) * width + center) + 0.5;
|
||||
unsigned char g = (sin(frequencyg*i + phase2) * width + center) + 0.5;
|
||||
unsigned char b = (sin(frequencyb*i + phase3) * width + center) + 0.5;
|
||||
if (line <= 255) {
|
||||
printf("\tdc.w $%x%s,$fffe\n\tdc.w COLOR00,$%x%x%x\n",line, hpos, r, g, b);
|
||||
if (0x2c+i == 255) {
|
||||
printf(".greaterThan255Hack:\n");
|
||||
printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n",line<<8|startHpos|1, r, g, b);
|
||||
if (line == 255) {
|
||||
printf(".verticalPositionWrapped:\n");
|
||||
printf("\tdc.w $%xdf,$fffe\n",line);
|
||||
}
|
||||
} else {
|
||||
printf("\tdc.w $%x%s,$fffe\n\tdc.w COLOR00,$%x%x%x\n", line-256, hpos,r, g, b);
|
||||
printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n", (line-256)<<8|startHpos|1, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n", (line-256)<<8|startHpos|1, 0, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue