diff --git a/011.ehb_mode/Makefile b/011.ehb_mode/Makefile new file mode 100644 index 0000000..0d10bb7 --- /dev/null +++ b/011.ehb_mode/Makefile @@ -0,0 +1,16 @@ +NUM_COLORS=64 +MODULE=ehb_mode.s +FLOPPY=bin/ehb_mode.adf +IMAGEDATA=out/image-palette.s out/image.bin +IMAGEFILE=../assets/gigi.png +EXTRA=$(IMAGEDATA) $(BOB_IMAGEDATA) init.s utils.s constants.i Makefile +VASM_EXTRA_ARGS=-DSCREEN_COLORS=$(NUM_COLORS) + +ifeq ($(NUM_COLORS),64) +EXTRA_HALF_BRITE=--extra-half-brite +endif + +include ../shared/base.mk + +$(IMAGEDATA): $(IMAGECON) $(IMAGEFILE) $(SHARED_PALETTE) Makefile + $(IMAGECON) --input $(IMAGEFILE) --output out/image --output-bitplanes --output-grey-palette-asm --output-palette-asm --colors=32 --quantize $(EXTRA_HALF_BRITE) diff --git a/011.ehb_mode/README.md b/011.ehb_mode/README.md new file mode 100644 index 0000000..7574273 --- /dev/null +++ b/011.ehb_mode/README.md @@ -0,0 +1,26 @@ +Extra half brite mode +===================== + +[Extra half brite mode](http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0098.html) allows us to use 32 colors as well as 32 "half brite" versions of those colors. + +I basic supprt to [imagecon](../tools/imagecon) to output EHB mode data. It doesn't really do a great job of taking advantage of the EHB mode. + +The only changes I made to the asm code to allow EHB mode was to add the 6th bitplane and make sure the copper reset the extra bitplane pointer. + +We can see from the output that it's not earth shatteringly different. I think if you developed an image with EHB in mind, then imagecon would generate the correct data... maybe ;-) I will test this at some stage. + +64 extra half brite +------------------- +![6 bitplanes](screenshots/64-colors.png?raw=true) + +32 colors +--------- +![5 bitplanes](screenshots/32-colors.png?raw=true) + +The differences +--------------- +![image differences](screenshots/diff.png?raw=true) + +[Download disk image](bin/ehb_mode.adf?raw=true) + + diff --git a/011.ehb_mode/constants.i b/011.ehb_mode/constants.i new file mode 100644 index 0000000..04aab35 --- /dev/null +++ b/011.ehb_mode/constants.i @@ -0,0 +1,27 @@ +LVL3_INT_VECTOR equ $6c +SCREEN_WIDTH equ 320 +SCREEN_HEIGHT equ 256 +SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8) + if SCREEN_COLORS == 64 +SCREEN_BIT_DEPTH equ 6 + endif + if SCREEN_COLORS == 32 +SCREEN_BIT_DEPTH equ 5 + endif + if SCREEN_COLORS == 16 +SCREEN_BIT_DEPTH equ 4 + endif + if SCREEN_COLORS == 8 +SCREEN_BIT_DEPTH equ 3 + endif + if SCREEN_COLORS == 4 +SCREEN_BIT_DEPTH equ 2 + endif + if SCREEN_COLORS == 2 +SCREEN_BIT_DEPTH equ 1 + endif +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/011.ehb_mode/ehb_mode.s b/011.ehb_mode/ehb_mode.s new file mode 100644 index 0000000..47ddadf --- /dev/null +++ b/011.ehb_mode/ehb_mode.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.bin" \ No newline at end of file diff --git a/011.ehb_mode/init.s b/011.ehb_mode/init.s new file mode 100644 index 0000000..a39f8b2 --- /dev/null +++ b/011.ehb_mode/init.s @@ -0,0 +1,41 @@ + ;; 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)|$200,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/011.ehb_mode/screenshots/32-colors.png b/011.ehb_mode/screenshots/32-colors.png new file mode 100644 index 0000000..74fa3cb Binary files /dev/null and b/011.ehb_mode/screenshots/32-colors.png differ diff --git a/011.ehb_mode/screenshots/64-colors.png b/011.ehb_mode/screenshots/64-colors.png new file mode 100644 index 0000000..2706899 Binary files /dev/null and b/011.ehb_mode/screenshots/64-colors.png differ diff --git a/011.ehb_mode/screenshots/diff.png b/011.ehb_mode/screenshots/diff.png new file mode 100644 index 0000000..69cf921 Binary files /dev/null and b/011.ehb_mode/screenshots/diff.png differ diff --git a/011.ehb_mode/utils.s b/011.ehb_mode/utils.s new file mode 100644 index 0000000..bdde568 --- /dev/null +++ b/011.ehb_mode/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