From 2e2094975346560d40f1cf48515c29c4d879ef54 Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Mon, 21 Mar 2016 14:32:20 +1100 Subject: [PATCH] Refactored slideshow code --- 023.slideshow/Makefile | 8 +-- 023.slideshow/image.s | 101 ++++++++++++++++++++++++++ 023.slideshow/init.s | 2 +- 023.slideshow/slideshow.s | 146 ++++++-------------------------------- 4 files changed, 126 insertions(+), 131 deletions(-) create mode 100644 023.slideshow/image.s diff --git a/023.slideshow/Makefile b/023.slideshow/Makefile index 783b9ef..3bbd257 100644 --- a/023.slideshow/Makefile +++ b/023.slideshow/Makefile @@ -6,7 +6,7 @@ HAM_MODE=1 BOOTBLOCK_ASM=alpine_bootblock.s -OBJS=out/init.o out/utils.o out/trackloader.o +OBJS=out/init.o out/utils.o out/trackloader.o out/image.o IMAGES=mr.png batgirl.png catwoman.png kb.png fe.png ww.png @@ -32,7 +32,8 @@ else FLAGS=--height=256 endif -LINK_COMMANDLINE=vlink -T link.script -brawbin1 $< $(OBJS) -M -o $@ +#-M +LINK_COMMANDLINE=vlink -T link.script -brawbin1 $< $(OBJS) -o $@ include ../shared/base.mk out/%.sized.png: ../assets/%.png @@ -42,8 +43,7 @@ out/%.bin: out/%.sized.png $(IMAGECON) --input $< $(IMAGECON_ARGS) --output-bitplanes --output-palette-asm --output-palette $(DITHER) --output out/$* out/%-ham.bin: out/%.sized.png - echo $(IMAGEDATA) - $(IMAGECON) --input $< $(IMAGECON_ARGS) --output-bitplanes --output-palette-asm --output-palette $(DITHER) --output out/$* + $(IMAGECON) --input $< $(IMAGECON_ARGS) --output-bitplanes --output-palette-asm --output-palette $(DITHER) --output out/$* --use-palette=palettes/$*.pal out/main.o: $(SIZEDIMAGEDATA) $(IMAGEDATA) constants.i Makefile link.script out/init.o: constants.i Makefile \ No newline at end of file diff --git a/023.slideshow/image.s b/023.slideshow/image.s new file mode 100644 index 0000000..2f53103 --- /dev/null +++ b/023.slideshow/image.s @@ -0,0 +1,101 @@ + include "includes.i" + + xref LoadNextImage + +LoadNextImage: + movem.l d0-a6,-(sp) + lea imageLookupTable,a1 + add.l imageIndex,a1 + cmp.l #0,(a1) ; lookup table is terminated with 0 + bne .showImage + move.l #0,imageIndex + lea imageLookupTable,a1 +.showImage + move.l a1,a2 + move.l (a1),a1 ; address of InsallColorPalette(X) + move.l 4(a2),a2 ; address of LoadImage(X) + jsr (a2) + add.l #8,imageIndex + movem.l (sp)+,d0-a6 + rts + +LoadImage1: + ;; a1 - start address + lea InstallColorPalette,a0 + move.l imageSize,d0 + bsr DoLoadImage + jsr InstallColorPalette + lea bitplanes,a1 + bsr SetupImage + rts + +LoadImage2: + ;; a1 - start address + lea InstallColorPalette2,a0 + move.l imageSize,d0 + bsr DoLoadImage + jsr InstallColorPalette2 + lea bitplanes2,a1 + bsr SetupImage + rts + +SetupImage: + ;; a1 - bitplanes address + movem.l d0-a6,-(sp) + if INTERLACE==1 + ;; poke the bitplane pointers for the two copper lists. + move.l #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d0 + lea copperListAlternate,a0 + jsr PokeBitplanePointers + endif + + moveq.l #0,d0 + lea copperList,a0 + jsr PokeBitplanePointers + movem.l (sp)+,d0-a6 + rts + +DoLoadImage: + ;; a0 - destination address + ;; a1 - start address + ;; d0 - size + movem.l d0-a6,-(sp) + lea $dff002,a6 ;Loader uses this custom base addr + + move.l d0,d1 + + move.l a1,d0 + move.l #startCode,d2 + sub.l d2,d0 ; offset from start of this module + lsr.l #6,d0 ; bytes -> sectors + lsr.l #3,d0 + add.l #2,d0 ; offset for bootblock + + + add.l #512,d1 + lsr.l #6,d1 ; bytes -> sectors + lsr.l #3,d1 + neg.w d1 + jsr LoadMFMB + + movem.l (sp)+,d0-a6 + rts + +imageLookupTable: + dc.l InstallColorPalette + dc.l LoadImage2 + dc.l InstallColorPalette2 + dc.l LoadImage1 + dc.l InstallColorPalette3 + dc.l LoadImage2 + dc.l InstallColorPalette4 + dc.l LoadImage1 + dc.l InstallColorPalette5 + dc.l LoadImage2 + dc.l InstallColorPalette6 + dc.l LoadImage1 + dc.l 0 + +imageIndex: + dc.l 0 + \ No newline at end of file diff --git a/023.slideshow/init.s b/023.slideshow/init.s index 8c89ead..058e077 100644 --- a/023.slideshow/init.s +++ b/023.slideshow/init.s @@ -10,7 +10,7 @@ Init: move #$7ff,DMACON(a6) ; disable all dma move #$7fff,INTENA(a6) ; disable all interrupts - lea level3InterruptHandler,a3 + lea Level3InterruptHandler,a3 move.l a3,LVL3_INT_VECTOR ;; set up playfield diff --git a/023.slideshow/slideshow.s b/023.slideshow/slideshow.s index 9144445..6e3d4d5 100644 --- a/023.slideshow/slideshow.s +++ b/023.slideshow/slideshow.s @@ -2,13 +2,19 @@ xref InstallColorPalette xref PokeBitplanePointers + xref Level3InterruptHandler xref copperList xref copperListAlternate - xref MFMbuf - xref level3InterruptHandler - -IMAGESIZE equ endbitplanes-InstallColorPalette - + xref imageSize + xref bitplanes + xref bitplanes2 + xref InstallColorPalette + xref InstallColorPalette2 + xref InstallColorPalette3 + xref InstallColorPalette4 + xref InstallColorPalette5 + xref InstallColorPalette6 + byteMap: dc.l Entry dc.l endCode-byteMap @@ -17,79 +23,25 @@ Entry: move.l #userstack,a7 lea CUSTOM,a6 - lea InstallColorPalette,a1 - bsr LoadImage1 + jsr LoadNextImage jsr Init .mainLoop: jsr WaitVerticalBlank - cmp.l #0,doLoad - beq .updateCounter - -.image1: - cmp.l #0,imageIndex - bne .image2 - lea InstallColorPalette2,a1 - bsr LoadImage2 - -.image2: - cmp.l #1,imageIndex - bne .image3 - lea InstallColorPalette3,a1 - bsr LoadImage1 - -.image3: - cmp.l #2,imageIndex - bne .image4 - lea InstallColorPalette4,a1 - bsr LoadImage2 - -.image4: - cmp.l #3,imageIndex - bne .image5 - lea InstallColorPalette5,a1 - bsr LoadImage1 - -.image5: - cmp.l #4,imageIndex - bne .image6 - lea InstallColorPalette6,a1 - bsr LoadImage2 - -.image6: - cmp.l #5,imageIndex - bne .image7 - lea InstallColorPalette,a1 - bsr LoadImage1 - move.l #0,imageIndex - bra .updateCounter - -.image7: -.incr - add.l #1,imageIndex + cmp.l #50*5,counter + bne .updateCounter + jsr LoadNextImage + move.l #0,counter .updateCounter: - move.l #0,doLoad - cmp.l #50*5,counter - beq .display add.l #1,counter - bra .done - -.display: - move.l #0,counter - move.l #1,doLoad -.done bra .mainLoop -doLoad: - dc.l 0 counter: dc.l 0 -imageIndex: - dc.l 0 -level3InterruptHandler: +Level3InterruptHandler: movem.l d0-a6,-(sp) lea CUSTOM,a6 .checkVerticalBlank: @@ -120,68 +72,7 @@ level3InterruptHandler: .interruptComplete: movem.l (sp)+,d0-a6 rte - -LoadImage1: - ;; a1 - start address - lea InstallColorPalette,a0 - move.l #IMAGESIZE,d0 - bsr DoLoadImage - jsr InstallColorPalette - lea bitplanes,a1 - bsr SetupImage - rts - -LoadImage2: - ;; a1 - start address - lea InstallColorPalette2,a0 - move.l #IMAGESIZE,d0 - bsr DoLoadImage - jsr InstallColorPalette2 - lea bitplanes2,a1 - bsr SetupImage - rts -SetupImage: - ;; a1 - bitplanes address - movem.l d0-a6,-(sp) - if INTERLACE==1 - ;; poke the bitplane pointers for the two copper lists. - move.l #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d0 - lea copperListAlternate,a0 - jsr PokeBitplanePointers - endif - - moveq.l #0,d0 - lea copperList,a0 - jsr PokeBitplanePointers - movem.l (sp)+,d0-a6 - rts - -DoLoadImage: - ;; a0 - destination address - ;; a1 - start address - ;; d0 - size - movem.l d0-a6,-(sp) - lea $dff002,a6 ;Loader uses this custom base addr - - move.l d0,d1 - - move.l a1,d0 - move.l #startCode,d2 - sub.l d2,d0 ; offset from start of this module - lsr.l #6,d0 ; bytes -> sectors - lsr.l #3,d0 - add.l #2,d0 ; offset for bootblock - - - add.l #512,d1 - lsr.l #6,d1 ; bytes -> sectors - lsr.l #3,d1 - neg.w d1 - jsr LoadMFMB - - movem.l (sp)+,d0-a6 - rts PokeBitplanePointers: ; d0 = frame offset in bytes @@ -235,6 +126,9 @@ copperList: dc.w BPL6PTH,0 dc.l $fffffffe +imageSize: + dc.l endbitplanes-InstallColorPalette + section .photo InstallColorPalette: include "out/mr-palette.s"