From 1f72da2c19f25734654e45dc170ad9049558e7a4 Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Mon, 29 Feb 2016 14:00:06 +1100 Subject: [PATCH] Tweaked copper list to work with SAE --- 004.copper_bars/Makefile | 4 +- 004.copper_bars/copper.s | 3 +- 004.copper_bars/copper_gen.c | 73 ++++++++++-------------------------- base.mk | 3 ++ 4 files changed, 26 insertions(+), 57 deletions(-) diff --git a/004.copper_bars/Makefile b/004.copper_bars/Makefile index 721ca4b..31e6f34 100644 --- a/004.copper_bars/Makefile +++ b/004.copper_bars/Makefile @@ -1,5 +1,5 @@ MAKEADF=../tools/makeadf -FLOPPY=bin/image.adf +FLOPPY=bin/copper_bars.adf EXTRA=out/copper-list.s MODULE=copper.s @@ -10,5 +10,5 @@ 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 + gcc $(HOST_CFLAGS) copper_gen.c -o out/copper_gen diff --git a/004.copper_bars/copper.s b/004.copper_bars/copper.s index 60462c0..aa96c57 100644 --- a/004.copper_bars/copper.s +++ b/004.copper_bars/copper.s @@ -8,7 +8,7 @@ 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_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 @@ -44,6 +44,7 @@ entry: 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 diff --git a/004.copper_bars/copper_gen.c b/004.copper_bars/copper_gen.c index 297c0f3..82c7143 100644 --- a/004.copper_bars/copper_gen.c +++ b/004.copper_bars/copper_gen.c @@ -3,66 +3,31 @@ #include #include -typedef struct { - float r; - float g; - float b; -} color; - -#define numColors 50 -color colors[numColors]; - -void -makeColorGradient() +int +main(int argc, char** argv) { - float frequencyr = 02; - float frequencyg = 02; - float frequencyb = 02; - float phase1 = 0.1, phase2 = 0.1, phase3 = 0.1; + char* hpos = "07"; + int firstVisibleScanLine = 0x2c; // hard coded value from AHRM + float numLines = 312; // PAL only + + float frequencyr = 0.3, frequencyg = 0.3, frequencyb = 0.3; + float phase1 = 0, phase2 = 2, phase3 = 4; 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)); + for (int i = 0, line = firstVisibleScanLine; i < (numLines-firstVisibleScanLine); ++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 $%xdf,$fffe\n",line); + } } 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)); + printf("\tdc.w $%x%s,$fffe\n\tdc.w COLOR00,$%x%x%x\n", line-256, hpos,r, g, b); } - } return 0; diff --git a/base.mk b/base.mk index 37bc8e9..62fd25e 100644 --- a/base.mk +++ b/base.mk @@ -1,3 +1,6 @@ +HOST_WARNINGS=-pedantic-errors -Wfatal-errors -Wall -Werror -Wextra -Wno-unused-parameter -Wshadow +HOST_CFLAGS=-g $(HOST_WARNINGS) + all: bin out $(MAKEADF) $(FLOPPY) gdrive: all