diff --git a/013.dithered_ham/Makefile b/013.dithered_ham/Makefile new file mode 100644 index 0000000..089a0bc --- /dev/null +++ b/013.dithered_ham/Makefile @@ -0,0 +1,16 @@ +MODULE=dithered_ham.s +FLOPPY=bin/dithered_ham.adf +IMAGEDATA=out/image-palette.s out/image-ham.bin +IMAGEFILE=../assets/gigi.png +#IMAGEFILE=../assets/demo.png +EXTRA=$(IMAGEDATA) $(BOB_IMAGEDATA) init.s utils.s constants.i Makefile + +USE_PALETTE=--use-palette gigi.pal +#USE_PALETTE=--use-palette demo.pal +#USE_PALETTE=--ham-brute-force +DITHER=--dither + +include ../shared/base.mk + +$(IMAGEDATA): $(IMAGECON) $(IMAGEFILE) Makefile + $(IMAGECON) --input $(IMAGEFILE) --output out/image --ham --output-bitplanes --output-palette-asm $(USE_PALETTE) --output-palette $(DITHER) diff --git a/013.dithered_ham/README.md b/013.dithered_ham/README.md new file mode 100644 index 0000000..8aacd3c --- /dev/null +++ b/013.dithered_ham/README.md @@ -0,0 +1,8 @@ +Ditherered HAM +============== + +Work in progress + +[Download disk image](bin/dither_ham.adf?raw=true) + + diff --git a/013.dithered_ham/bin/dithered_ham.adf b/013.dithered_ham/bin/dithered_ham.adf new file mode 100644 index 0000000..28e3823 Binary files /dev/null and b/013.dithered_ham/bin/dithered_ham.adf differ diff --git a/013.dithered_ham/constants.i b/013.dithered_ham/constants.i new file mode 100644 index 0000000..4b1a596 --- /dev/null +++ b/013.dithered_ham/constants.i @@ -0,0 +1,10 @@ +LVL3_INT_VECTOR equ $6c +SCREEN_WIDTH equ 320 +SCREEN_HEIGHT equ 256 +SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8) +SCREEN_BIT_DEPTH equ 6 +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 diff --git a/013.dithered_ham/demo.pal b/013.dithered_ham/demo.pal new file mode 100644 index 0000000..535ad8c --- /dev/null +++ b/013.dithered_ham/demo.pal @@ -0,0 +1,16 @@ +caa +d2d +cef +333 +c85 +4be +be3 +c7f +d18 +222 +655 +25d +c97 +6c2 +d22 +cda diff --git a/013.dithered_ham/dithered_ham.s b/013.dithered_ham/dithered_ham.s new file mode 100644 index 0000000..b4c5881 --- /dev/null +++ b/013.dithered_ham/dithered_ham.s @@ -0,0 +1,41 @@ + include "../include/registers.i" + include "hardware/dmabits.i" + include "hardware/intbits.i" + + include "constants.i" + +entry: + lea CUSTOM,a6 + bsr init + bsr.s installColorPalette + +.mainLoop: + bsr waitVerticalBlank + bra .mainLoop + + include "init.s" + include "utils.s" + +installColorPalette: + include "out/image-palette.s" + rts + +copper: + ;; bitplane pointers must be first else poking addresses will be incorrect + dc.w BPL1PTL,0 + dc.w BPL1PTH,0 + dc.w BPL2PTL,0 + dc.w BPL2PTH,0 + dc.w BPL3PTL,0 + dc.w BPL3PTH,0 + dc.w BPL4PTL,0 + dc.w BPL4PTH,0 + dc.w BPL5PTL,0 + dc.w BPL5PTH,0 + dc.w BPL6PTL,0 + dc.w BPL6PTH,0 + + dc.l $fffffffe + +bitplanes: + incbin "out/image-ham.bin" \ No newline at end of file diff --git a/013.dithered_ham/gigi.pal b/013.dithered_ham/gigi.pal new file mode 100644 index 0000000..ea66f13 --- /dev/null +++ b/013.dithered_ham/gigi.pal @@ -0,0 +1,16 @@ +875 +542 +ca7 +89a +421 +853 +c85 +565 +cc9 +a63 +211 +642 +689 +8ab +531 +997 diff --git a/013.dithered_ham/init.s b/013.dithered_ham/init.s new file mode 100644 index 0000000..7961c1c --- /dev/null +++ b/013.dithered_ham/init.s @@ -0,0 +1,42 @@ + include "../include/bplconbits.i" + ;; custom chip base globally in a6 +init: + movem.l d0-a6,-(sp) + move #$7ff,DMACON(a6) ; disable all dma + move #$7fff,INTENA(a6) ; disable all interrupts + + ;; set up default palette + bsr.s installColorPalette + + ;; 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)|COLOR_ON|HOMOD,BPLCON0(a6) + move.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL1MOD(a6) + move.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL2MOD(a6) + + ;; poke bitplane pointers + lea bitplanes(pc),a1 + lea copper(pc),a2 + moveq #SCREEN_BIT_DEPTH-1,d0 +.bitplaneloop: + move.l a1,d1 + move.w d1,2(a2) + swap d1 + move.w d1,6(a2) + lea SCREEN_WIDTH_BYTES(a1),a1 ; bit plane data is interleaved + addq #8,a2 + dbra d0,.bitplaneloop + + ;; 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_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6) + ;; move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6) + movem.l (sp)+,d0-a6 + rts \ No newline at end of file diff --git a/013.dithered_ham/screenshots/dithered.png b/013.dithered_ham/screenshots/dithered.png new file mode 100644 index 0000000..e3d85c0 Binary files /dev/null and b/013.dithered_ham/screenshots/dithered.png differ diff --git a/013.dithered_ham/utils.s b/013.dithered_ham/utils.s new file mode 100644 index 0000000..bdde568 --- /dev/null +++ b/013.dithered_ham/utils.s @@ -0,0 +1,23 @@ +waitVerticalBlank: + movem.l d0-a6,-(sp) +.loop move.l $dff004,d0 + and.l #$1ff00,d0 + cmp.l #303<<8,d0 + bne.b .loop + movem.l (sp)+,d0-a6 + rts + + + +waitRaster: ;wait for rasterline d0.w. Modifies d0-d2/a0. + movem.l d0-a6,-(sp) + move.l #$1ff00,d2 + lsl.l #8,d0 + and.l d2,d0 + lea $dff004,a0 +.wr: move.l (a0),d1 + and.l d2,d1 + cmp.l d1,d0 + bne.s .wr + movem.l (sp)+,d0-a6 + rts \ No newline at end of file