From b93fd11dbbcb2a5139c67f155e01ba62555482dd Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Mon, 29 Feb 2016 21:33:01 +1100 Subject: [PATCH] First try and vertical copper bars --- 005.copper_vert/Makefile | 14 +++++++ 005.copper_vert/README.md | 3 ++ 005.copper_vert/copper_gen_vert.c | 44 +++++++++++++++++++++ 005.copper_vert/copper_vert.s | 65 +++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 005.copper_vert/Makefile create mode 100644 005.copper_vert/README.md create mode 100644 005.copper_vert/copper_gen_vert.c create mode 100644 005.copper_vert/copper_vert.s diff --git a/005.copper_vert/Makefile b/005.copper_vert/Makefile new file mode 100644 index 0000000..5a4071b --- /dev/null +++ b/005.copper_vert/Makefile @@ -0,0 +1,14 @@ +MAKEADF=../tools/makeadf +FLOPPY=bin/copper_vert.adf +EXTRA=out/copper-list.s + +MODULE=copper_vert.s + +include ../base.mk + +out/copper-list.s: out/copper_gen + ./out/copper_gen_vert > out/copper-list.s + +out/copper_gen: copper_gen_vert.c + gcc $(HOST_CFLAGS) copper_gen_vert.c -o out/copper_gen_vert + diff --git a/005.copper_vert/README.md b/005.copper_vert/README.md new file mode 100644 index 0000000..38e98e6 --- /dev/null +++ b/005.copper_vert/README.md @@ -0,0 +1,3 @@ +Vertical copper bars +==================== + diff --git a/005.copper_vert/copper_gen_vert.c b/005.copper_vert/copper_gen_vert.c new file mode 100644 index 0000000..3b4e06c --- /dev/null +++ b/005.copper_vert/copper_gen_vert.c @@ -0,0 +1,44 @@ +// http://krazydad.com/tutorials/makecolors.php + +#include +#include + +int +main(int argc, char** argv) +{ + int startLine = 0x2c; // hard coded value from AHRM + int screenHeight = 256; + int endLine = startLine+screenHeight; + int startHpos = 6+8; + int i, c, line; + + // These values are set up to be in sync with the vertical bars + float frequencyr = 0.3, frequencyg = 0.3, frequencyb = 0.3; + float phase1 = 0, phase2 = 2, phase3 = 4; + float offset = 0; + float center = 0x7; + float width = 0x7; + int hstep = 16; + + for (line = startLine; line < endLine; ++line) { + for (i = 0, c = startHpos; c < 0xdf; c+= hstep, i++) { + unsigned char r = (sin(frequencyr*i + phase1 + offset) * width + center) + 0.5; + unsigned char g = (sin(frequencyg*i + phase2 + offset) * width + center) + 0.5; + unsigned char b = (sin(frequencyb*i + phase3 + offset) * width + center) + 0.5; + if (line == 0 && i == 0) { + + } else { + if (line <= 255) { + printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n",line<<8|c|1, r, g, b); + if (line == 255 && c+hstep >= 0xdf) { + printf(".verticalPositionWrapped:\n"); + } + } else { + printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n", (line-256)<<8|c|1, r, g, b); + } + } + } + } + + return 0; +} diff --git a/005.copper_vert/copper_vert.s b/005.copper_vert/copper_vert.s new file mode 100644 index 0000000..3d286bb --- /dev/null +++ b/005.copper_vert/copper_vert.s @@ -0,0 +1,65 @@ + 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 + + move #$7ff,DMACON(a6) ; disable all dma + move #$7fff,INTENA(a6) ; disable all interrupts + + ;; poke bitplane pointers into the copper list + lea copper(pc),a1 + lea bitplane-copper(a1),a0 + lea _BPL1PTL(pc),a1 + move.l a0,d0 + move.w d0,(a1) ; poke BPL1PTL + swap d0 + 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) + + 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, 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 #(INTF_SETCLR|INTF_INTEN|INTF_EXTER),INTENA(a6) + +.mainLoop: + bra.b .mainLoop + +copper: + 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" + dc.l $fffffffe + +bitplane: + dcb.b (SCREEN_WIDTH*SCREEN_HEIGHT)/8,$00