From f244f9f345536d39fa324eb87b95eb8dbcc20bf1 Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Thu, 10 Mar 2016 10:42:57 +1100 Subject: [PATCH] Improved version of lace_mode --- 014.lace_mode/Makefile | 9 +++- 014.lace_mode/README.md | 44 ++++++++++++++++++- 014.lace_mode/constants.i | 3 +- 014.lace_mode/init.s | 22 +++++++++- 014.lace_mode/lace_mode.s | 92 +++++++++++++++++++-------------------- Makefile | 4 +- 6 files changed, 120 insertions(+), 54 deletions(-) diff --git a/014.lace_mode/Makefile b/014.lace_mode/Makefile index c02e320..f274b5d 100644 --- a/014.lace_mode/Makefile +++ b/014.lace_mode/Makefile @@ -1,10 +1,15 @@ +INTERLACE=1 MODULE=lace_mode.s FLOPPY=bin/lace_mode.adf IMAGEDATA=out/image-palette.s out/image-ham.bin +ifeq ($(INTERLACE),1) IMAGEFILE=../assets/gigi_320x512.png +else +IMAGEFILE=../assets/gigi.png +endif EXTRA=$(IMAGEDATA) $(BOB_IMAGEDATA) init.s utils.s constants.i Makefile -BASE_ADDRESS=40000 - +BASE_ADDRESS=40000 # The extra data in a 512 row bitplane dataset caused the original base (0x70000) to crash into something bad +VASM_EXTRA_ARGS=-DINTERLACE=$(INTERLACE) USE_PALETTE=--use-palette gigi.pal DITHER=--dither diff --git a/014.lace_mode/README.md b/014.lace_mode/README.md index c0deb83..4fb81e0 100644 --- a/014.lace_mode/README.md +++ b/014.lace_mode/README.md @@ -1,7 +1,49 @@ interlaced playfield ==================== -Work in progress +For interlace mode, we can enable it by simply setting the LACE bit in BPLCON0: + + ``` + move.w #(SCREEN_BIT_DEPTH<<12)|COLOR_ON|HOMOD|LACE,BPLCON0(a6) +`` ` + +Now each alternating frame will be offset vertically by half a scan line. + +So for this to work, we need to make some other changes. Firstly we need twice the number of rows in our bitplane data. Then on each alternating frame we need to set up the bitplane pointers such that they point at the correct set of row data. For this we set up two copper lists, then poke offset bitplane pointers into one of them: + + ``` + ;; poke the bitplane pointers for the two copper lists. + move.l #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d0 + lea copper(pc),a0 + bsr.s pokeBitplanePointers + + moveq.l #0,d0 + lea copperLOF(pc),a0 + bsr.s pokeBitplanePointers +``` + +Then, during the vertical blank, depending on the LOF bit in the VPOSR register, we install the correct copper list: + + ``` +.mainLoop: + bsr waitVerticalBlank + + btst.w #VPOSRLOFBIT,VPOSR(a6) + beq.s .lof + lea copper(pc),a0 + move.l a0,COP1LC(a6) + bra .done +.lof: + lea copperLOF(pc),a0 + move.l a0,COP1LC(a6) +.done + bra .mainLoop +``` + +This example allows your to enable/disable INTERLACE mode in the [Makefile](Makefile) + ``` +INTERLACE=1 +``` try it ------ diff --git a/014.lace_mode/constants.i b/014.lace_mode/constants.i index aceb242..9a09d06 100644 --- a/014.lace_mode/constants.i +++ b/014.lace_mode/constants.i @@ -1,6 +1,7 @@ +VPOSRLOFBIT equ 15 LVL3_INT_VECTOR equ $6c SCREEN_WIDTH equ 320 -SCREEN_HEIGHT equ 512 +SCREEN_HEIGHT equ (256+(256*INTERLACE)) SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8) SCREEN_BIT_DEPTH equ 6 SCREEN_RES equ 8 ; 8=lo resolution, 4=hi resolution diff --git a/014.lace_mode/init.s b/014.lace_mode/init.s index 186620b..13d9500 100644 --- a/014.lace_mode/init.s +++ b/014.lace_mode/init.s @@ -7,6 +7,17 @@ init: ;; set up default palette bsr.s installColorPalette + + if INTERLACE == 1 + ;; poke the bitplane pointers for the two copper lists. + move.l #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d0 + lea copper(pc),a0 + bsr.s pokeBitplanePointers + endif + + moveq.l #0,d0 + lea copperLOF(pc),a0 + bsr.s pokeBitplanePointers ;; set up playfield move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6) @@ -14,13 +25,20 @@ init: 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) - + + if INTERLACE == 1 move.w #(SCREEN_BIT_DEPTH<<12)|COLOR_ON|HOMOD|LACE,BPLCON0(a6) move.w #2*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL1MOD(a6) move.w #2*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL2MOD(a6) + else + 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) + endif + ;; install copper list, then enable dma and selected interrupts - lea copper(pc),a0 + lea copperLOF(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) diff --git a/014.lace_mode/lace_mode.s b/014.lace_mode/lace_mode.s index c76da38..864ca07 100644 --- a/014.lace_mode/lace_mode.s +++ b/014.lace_mode/lace_mode.s @@ -5,69 +5,50 @@ include "constants.i" entry: - lea CUSTOM,a6 + lea CUSTOM,a6 bsr init - bsr.s installColorPalette .mainLoop: bsr waitVerticalBlank - cmpi.w #0,cycle - bne.s .alternate - move.w #1,cycle - bsr.s pokeBitplanePointers2 + + if INTERLACE == 1 + btst.w #VPOSRLOFBIT,VPOSR(a6) + beq.s .lof + lea copper(pc),a0 + move.l a0,COP1LC(a6) bra .done -.alternate: - move.w #0,cycle - bsr.s pokeBitplanePointers +.lof: + lea copperLOF(pc),a0 + move.l a0,COP1LC(a6) .done + endif bra .mainLoop include "init.s" include "utils.s" -pokeBitplanePointers: - ;; poke bitplane pointers - movem.l d0-a6,-(sp) - 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 - movem.l (sp)+,d0-a6 - rts - -pokeBitplanePointers2: - ;; poke bitplane pointers - movem.l d0-a6,-(sp) - lea bitplanes(pc),a1 - add.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,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 - movem.l (sp)+,d0-a6 - rts - +pokeBitplanePointers: ; d0 = frame offset in bytes, a0 = BPLP copper list address + movem.l d0-a6,-(sp) + lea bitplanes(pc),a1 + add.l d0,a1 ; Offset for odd/even frames + moveq #SCREEN_BIT_DEPTH-1,d0 +.bitplaneloop: + move.l a1,d1 + move.w d1,2(a0) + swap d1 + move.w d1,6(a0) + lea SCREEN_WIDTH_BYTES(a1),a1 + addq #8,a0 + dbra d0,.bitplaneloop + movem.l (sp)+,d0-a6 + rts + installColorPalette: include "out/image-palette.s" rts -cycle: - dc.l 0 copper: ;; bitplane pointers must be first else poking addresses will be incorrect dc.w BPL1PTL,0 @@ -83,7 +64,24 @@ copper: dc.w BPL6PTL,0 dc.w BPL6PTH,0 - dc.l $fffffffe + dc.l $fffffffe + +copperLOF: + ;; 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/Makefile b/Makefile index 1fef1c1..91e1137 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,9 @@ SUBDIRS=tools/makeadf \ 009.anim_blit\ 010.blit_speed\ 011.ehb_mode\ - 012.ham_mode + 012.ham_mode\ + 013.dithered_ham\ + 014.lace_mode .PHONY: subdirs $(SUBDIRS)