From b96de9af412d6fc062abf2f7e79a92969a20ee35 Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Mon, 21 Mar 2016 16:56:34 +1100 Subject: [PATCH] Refactor ready for adding compression --- 023.slideshow/Makefile | 7 +- 023.slideshow/constants.i | 1 + 023.slideshow/image.s | 161 +++++++++++++++++++++++++++++++++----- 023.slideshow/slideshow.s | 75 ++++-------------- 4 files changed, 165 insertions(+), 79 deletions(-) diff --git a/023.slideshow/Makefile b/023.slideshow/Makefile index 3bbd257..b54a1fc 100644 --- a/023.slideshow/Makefile +++ b/023.slideshow/Makefile @@ -24,6 +24,7 @@ IMAGECON_ARGS=--colors 32 --quantize IMAGEDATA=$(addprefix out/, $(IMAGES:.png=.bin)) endif +SHRUNKDATA=$(IMAGEDATA:.bin=.bin.sz) SIZEDIMAGEDATA=$(addprefix out/, $(IMAGES:.png=.sized.png)) ifeq ($(INTERLACE),1) @@ -42,8 +43,12 @@ out/%.sized.png: ../assets/%.png out/%.bin: out/%.sized.png $(IMAGECON) --input $< $(IMAGECON_ARGS) --output-bitplanes --output-palette-asm --output-palette $(DITHER) --output out/$* +out/%.bin.sz: out/%.bin + $(SHRINKLEREXE) -d $< $@ + + out/%-ham.bin: out/%.sized.png $(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/main.o: $(SIZEDIMAGEDATA) $(IMAGEDATA) $(SHRUNKDATA) constants.i Makefile link.script out/init.o: constants.i Makefile \ No newline at end of file diff --git a/023.slideshow/constants.i b/023.slideshow/constants.i index 689db18..8a4aff6 100644 --- a/023.slideshow/constants.i +++ b/023.slideshow/constants.i @@ -11,3 +11,4 @@ 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+256 +IMAGESIZE equ SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH*SCREEN_HEIGHT \ No newline at end of file diff --git a/023.slideshow/image.s b/023.slideshow/image.s index 2f53103..db1657b 100644 --- a/023.slideshow/image.s +++ b/023.slideshow/image.s @@ -1,6 +1,8 @@ include "includes.i" xref LoadNextImage + + LoadNextImage: movem.l d0-a6,-(sp) @@ -11,34 +13,78 @@ LoadNextImage: 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 + move.l a1,a3 + move.l (a1),a2 ; address of InsallColorPalette(X) + move.l 4(a3),a1 ; address of compressed image on disk + move.l 8(a3),d0 ; size of compressed image + move.l 12(a3),a3 ; address of LoadImage(X) + jsr (a3) + add.l #16,imageIndex movem.l (sp)+,d0-a6 rts + +Callback: + ;; d0 = Number of bytes decompressed so far + ;; a0 = Callback argument + move.l a6,-(sp) + lea CUSTOM,a6 + move.w d0,COLOR00(a6) ; Set wild background colors as we decompress + move.l (sp)+,a6 + rts LoadImage1: + ;; d0 - size ;; a1 - start address - lea InstallColorPalette,a0 - move.l imageSize,d0 + ;; a2 - InstallColorPalette(X) address + if 0 + move.l bitplanesp3,a0 ; Load compressed data into bitplanes3 + endif + + move.l bitplanesp1,a0 bsr DoLoadImage - jsr InstallColorPalette - lea bitplanes,a1 - bsr SetupImage - rts + + if 0 + ;; Decompress + ; a0 = compressed data + ; a1 = decompressed data destination + move.l bitplanesp1,a1 + ; a2 = progress callback, can be zero if no callback is desired. + lea Callback(pc),a2 + bsr ShrinklerDecompress ; -> decompress! + endif -LoadImage2: - ;; a1 - start address - lea InstallColorPalette2,a0 - move.l imageSize,d0 - bsr DoLoadImage - jsr InstallColorPalette2 - lea bitplanes2,a1 + jsr (a2) + move.l bitplanesp1,a1 bsr SetupImage rts +LoadImage2: + ;; d0 - size + ;; a1 - start address + ;; a2 - InstallColorPalette(X) address + if 0 + move.l bitplanesp3,a0 ; Load compressed data into bitplanes3 + endif + + move.l bitplanesp2,a0 + bsr DoLoadImage + + if 0 + ;; Decompress + ; a0 = compressed data + ; a1 = decompressed data destination + move.l bitplanesp2,a1 + ; a2 = progress callback, can be zero if no callback is desired. + lea Callback(pc),a2 + bsr ShrinklerDecompress ; -> decompress! + endif + + jsr (a2) + move.l bitplanesp2,a1 + bsr SetupImage + rts + + SetupImage: ;; a1 - bitplanes address movem.l d0-a6,-(sp) @@ -83,19 +129,96 @@ DoLoadImage: imageLookupTable: dc.l InstallColorPalette + dc.l imageData1 + dc.l endImageData1-imageData1 dc.l LoadImage2 + dc.l InstallColorPalette2 + dc.l imageData2 + dc.l endImageData2-imageData2 dc.l LoadImage1 + dc.l InstallColorPalette3 + dc.l imageData3 + dc.l endImageData3-imageData3 dc.l LoadImage2 + dc.l InstallColorPalette4 + dc.l imageData4 + dc.l endImageData4-imageData4 dc.l LoadImage1 + dc.l InstallColorPalette5 + dc.l imageData5 + dc.l endImageData5-imageData5 dc.l LoadImage2 + dc.l InstallColorPalette6 + dc.l imageData6 + dc.l endImageData6-imageData6 dc.l LoadImage1 dc.l 0 imageIndex: dc.l 0 - \ No newline at end of file + + + include "../tools/external/shrinkler/ShrinklerDecompress.S" + + + + section .photo + + cnop 0,512 +imageData1: + if HAM_MODE==1 + incbin "out/mr-ham.bin" + else + incbin "out/mr.bin" + endif +endImageData1: + + cnop 0,512 +imageData2: + if HAM_MODE==1 + incbin "out/catwoman-ham.bin" + else + incbin "out/catwoman.bin" + endif +endImageData2: + + cnop 0,512 +imageData3: + if HAM_MODE==1 + incbin "out/batgirl-ham.bin" + else + incbin "out/batgirl.bin" + endif +endImageData3: + + cnop 0,512 +imageData4: + if HAM_MODE==1 + incbin "out/kb-ham.bin" + else + incbin "out/kb.bin" + endif +endImageData4: + + cnop 0,512 +imageData5: + if HAM_MODE==1 + incbin "out/fe-ham.bin" + else + incbin "out/fe.bin" + endif +endImageData5: + + cnop 0,512 +imageData6: + if HAM_MODE==1 + incbin "out/ww-ham.bin" + else + incbin "out/ww.bin" + endif +endImageData6: \ No newline at end of file diff --git a/023.slideshow/slideshow.s b/023.slideshow/slideshow.s index 6e3d4d5..197385f 100644 --- a/023.slideshow/slideshow.s +++ b/023.slideshow/slideshow.s @@ -5,15 +5,16 @@ xref Level3InterruptHandler xref copperList xref copperListAlternate - xref imageSize - xref bitplanes - xref bitplanes2 xref InstallColorPalette xref InstallColorPalette2 xref InstallColorPalette3 xref InstallColorPalette4 xref InstallColorPalette5 xref InstallColorPalette6 + xref bitplanesp1 + xref bitplanesp2 + xref bitplanesp3 + byteMap: dc.l Entry @@ -126,76 +127,32 @@ copperList: dc.w BPL6PTH,0 dc.l $fffffffe -imageSize: - dc.l endbitplanes-InstallColorPalette - - section .photo InstallColorPalette: include "out/mr-palette.s" - rts -bitplanes: - if HAM_MODE==1 - incbin "out/mr-ham.bin" - else - incbin "out/mr.bin" - endif -endbitplanes: - - - cnop 0,512 + rts InstallColorPalette2: include "out/catwoman-palette.s" rts -bitplanes2: - if HAM_MODE==1 - incbin "out/catwoman-ham.bin" - else - incbin "out/catwoman.bin" - endif -endbitplanes2: - - - cnop 0,512 InstallColorPalette3: include "out/batgirl-palette.s" rts - if HAM_MODE==1 - incbin "out/batgirl-ham.bin" - else - incbin "out/batgirl.bin" - endif -endbitplanes3: - - - cnop 0,512 InstallColorPalette4: include "out/kb-palette.s" rts - if HAM_MODE==1 - incbin "out/kb-ham.bin" - else - incbin "out/kb.bin" - endif -endbitplanes4: - - cnop 0,512 InstallColorPalette5: include "out/fe-palette.s" rts - if HAM_MODE==1 - incbin "out/fe-ham.bin" - else - incbin "out/fe.bin" - endif -endbitplanes5: - - cnop 0,512 InstallColorPalette6: include "out/ww-palette.s" rts - if HAM_MODE==1 - incbin "out/ww-ham.bin" - else - incbin "out/ww.bin" - endif -endbitplanes6: \ No newline at end of file + + align 4 + + +bitplanesp1: + dc.l endCode +bitplanesp2: + dc.l endCode+(512)+IMAGESIZE +bitplanesp3: + dc.l endCode+(512*2)+(2*IMAGESIZE) + \ No newline at end of file