Shrinkler refactor
This commit is contained in:
parent
6d729d8f3b
commit
ee5964848f
|
@ -3,29 +3,21 @@ INTERLACE=0
|
|||
HAM_MODE=0
|
||||
|
||||
MODULE=shrinkler.s
|
||||
OBJS=out/init.o out/utils.o
|
||||
FLOPPY=bin/shrinkler.adf
|
||||
IMAGEDATA=out/image-palette.s out/image-ham.bin
|
||||
IMAGEFILE=../assets/gigi_full.png
|
||||
SIZED_IMAGEFILE=out/image.png
|
||||
BOOTBLOCK_ASM=shrink_bootblock.s
|
||||
BASE_ADDRESS=50000
|
||||
DECOMPRESS_ADDRESS=10000
|
||||
EXTRA=$(IMAGEDATA) init.s utils.s constants.i Makefile
|
||||
|
||||
ifeq ($(SHRINKLER),1)
|
||||
PROGRAM_BIN=out/shrunk.bin
|
||||
VASM_EXTRA_BOOTBLOCK_ARGS=-DDECOMPRESS_ADDRESS="\$$$(DECOMPRESS_ADDRESS)" -DSHRINKLER=$(SHRINKLER)
|
||||
else
|
||||
PROGRAM_BIN=out/main.bin
|
||||
VASM_EXTRA_BOOTBLOCK_ARGS=-DSHRINKLER=$(SHRINKLER)
|
||||
endif
|
||||
|
||||
ifeq ($(HAM_MODE),1)
|
||||
IMAGEDATA=out/image-palette.s out/image-ham.bin
|
||||
VASM_EXTRA_ARGS=-DINTERLACE=$(INTERLACE) -DHAM_MODE=$(HAM_MODE)
|
||||
IMAGECON_ARGS=--use-palette gigi.pal --dither --ham
|
||||
else
|
||||
VASM_EXTRA_ARGS=-DINTERLACE=$(INTERLACE) -DHAM_MODE=$(HAM_MODE)
|
||||
IMAGECON_ARGS=--colors 32 --quantize
|
||||
IMAGEDATA=out/image-palette.s out/image.bin
|
||||
endif
|
||||
|
||||
ifeq ($(INTERLACE),1)
|
||||
|
@ -36,10 +28,6 @@ endif
|
|||
|
||||
include ../shared/base.mk
|
||||
|
||||
ifeq ($(SHRINKLER),1)
|
||||
$(PROGRAM_BIN): out/main.bin
|
||||
../tools/external/shrinkler/build/native/Shrinkler -d out/main.bin out/shrunk.bin
|
||||
endif
|
||||
|
||||
$(SIZED_IMAGEFILE): $(IMAGEFILE) $(RESIZE) Makefile
|
||||
$(RESIZE) --width=320 $(FLAGS) --blur=0.75 --input=$(IMAGEFILE) --output=$(SIZED_IMAGEFILE)
|
||||
|
@ -48,3 +36,5 @@ $(IMAGEDATA): $(IMAGECON) $(SIZED_IMAGEFILE) Makefile
|
|||
$(IMAGECON) --input $(SIZED_IMAGEFILE) $(IMAGECON_ARGS) --output out/image --output-bitplanes --output-palette-asm --output-palette $(DITHER)
|
||||
|
||||
|
||||
out/main.o: $(IMAGEDATA) constants.i Makefile
|
||||
out/init.o: constants.i Makefile
|
|
@ -1,7 +1,75 @@
|
|||
shrinking with shinkler
|
||||
=======================
|
||||
|
||||
Work in progress
|
||||
In this example I try to integrate the amazing and generally super awsome Shrinkler exe shrinker.
|
||||
|
||||
* [Source repository](https://bitbucket.org/askeksa/shrinkler)
|
||||
* [Forum thread with discussion] (http://ada.untergrund.net/?p=boardthread&id=264&page=0)
|
||||
|
||||
This is a pretty cool bit of kit. I think you can just point an exe and this program and it will produce a compressed version of the exe that it runnable. Seeing as all my examples are based on a trackloaded setup, we use it slightly differently.
|
||||
|
||||
We shrink the "program" that our trackloaded loads as if it were data:
|
||||
|
||||
```
|
||||
Shrinkler -d out/main.bin out/shrunk.bin
|
||||
```
|
||||
|
||||
Shrinker does a very impressive job of shrinking data:
|
||||
|
||||
```
|
||||
Crunching...
|
||||
|
||||
Original After 1st pass After 2nd pass
|
||||
51752 27545.297 26682.832
|
||||
```
|
||||
|
||||
For comparison:
|
||||
|
||||
```
|
||||
# gzip out/main.bin
|
||||
# ls -l out/main.bin.gz
|
||||
-rwxr-xr-x 1 alpine staff 29811 Mar 16 06:04 main.bin.gz
|
||||
```
|
||||
|
||||
So now we have compressed data we need the bootloader to decompress it after it has loaded it. See [../shared/shrinkler_bootblock.s](../shared/shrinkler_bootblock.s) for the modified bootblock. But in a nutshell it's as simple as:
|
||||
|
||||
```
|
||||
; a0 = compressed data
|
||||
lea DECOMPRESS_ADDRESS,a0 ; Where we asked the trackloaded to load the compressed data
|
||||
; a1 = decompressed data destination
|
||||
lea BASE_ADDRESS,a1 ; The location of the decompressed code.
|
||||
; a2 = progress callback, can be zero if no callback is desired.
|
||||
lea Callback(pc),a2
|
||||
bsr ShrinklerDecompress ; -> decompress!
|
||||
```
|
||||
|
||||
With our progress callback as simple as:
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
And then we just include the Shrinkler [decompression code](../tools/external/shrinkler/ShrinklerDecompress.S):
|
||||
|
||||
```
|
||||
include "../tools/external/shrinkler/ShrinklerDecompress.S"
|
||||
```
|
||||
|
||||
In the [Makefile](Makefile) we can enable or disable Shrinkler:
|
||||
|
||||
```
|
||||
SHRINKLER=1
|
||||
```
|
||||
|
||||
In this example I have also started to refactor the structure of the code base ready for slightly more complex examples going forward.
|
||||
|
||||
|
||||
try it
|
||||
------
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
VPOSRLOFBIT equ 15
|
||||
LVL3_INT_VECTOR equ $6c
|
||||
SCREEN_WIDTH equ 320
|
||||
SCREEN_HEIGHT equ (256+(256*INTERLACE))
|
||||
SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
include "../include/registers.i"
|
||||
include "../include/vector.i"
|
||||
include "../include/beambits.i"
|
||||
include "../include/bplconbits.i"
|
||||
include "hardware/dmabits.i"
|
||||
include "hardware/intbits.i"
|
||||
include "constants.i"
|
|
@ -1,4 +1,8 @@
|
|||
include "../include/bplconbits.i"
|
||||
|
||||
include "includes.i"
|
||||
|
||||
xref Init
|
||||
|
||||
;; custom chip base globally in a6
|
||||
Init:
|
||||
movem.l d0-a6,-(sp)
|
||||
|
@ -6,18 +10,18 @@ Init:
|
|||
move #$7fff,INTENA(a6) ; disable all interrupts
|
||||
|
||||
;; set up default palette
|
||||
bsr.s InstallColorPalette
|
||||
jsr 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
|
||||
lea copperListAlternate(pc),a0
|
||||
jsr PokeBitplanePointers
|
||||
endif
|
||||
|
||||
moveq.l #0,d0
|
||||
lea copperLOF(pc),a0
|
||||
bsr.s PokeBitplanePointers
|
||||
lea copperList,a0
|
||||
jsr PokeBitplanePointers
|
||||
|
||||
;; set up playfield
|
||||
move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6)
|
||||
|
@ -43,7 +47,7 @@ HAMBIT equ 0
|
|||
endif
|
||||
|
||||
;; install copper list, then enable dma and selected interrupts
|
||||
lea copperLOF(pc),a0
|
||||
lea copperList,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)
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 135 KiB |
Binary file not shown.
Before Width: | Height: | Size: 144 KiB |
Binary file not shown.
|
@ -1,31 +1,29 @@
|
|||
include "../include/registers.i"
|
||||
include "hardware/dmabits.i"
|
||||
include "hardware/intbits.i"
|
||||
|
||||
include "constants.i"
|
||||
include "includes.i"
|
||||
|
||||
xref InstallColorPalette
|
||||
xref PokeBitplanePointers
|
||||
xref copperList
|
||||
xref copperListAlternate
|
||||
|
||||
Entry:
|
||||
lea CUSTOM,a6
|
||||
bsr Init
|
||||
jsr Init
|
||||
|
||||
.mainLoop:
|
||||
bsr WaitVerticalBlank
|
||||
jsr WaitVerticalBlank
|
||||
|
||||
if INTERLACE == 1
|
||||
btst.w #VPOSRLOFBIT,VPOSR(a6)
|
||||
beq.s .lof
|
||||
lea copper(pc),a0
|
||||
lea copperListAlternate(pc),a0
|
||||
move.l a0,COP1LC(a6)
|
||||
bra .done
|
||||
.lof:
|
||||
lea copperLOF(pc),a0
|
||||
lea copperList(pc),a0
|
||||
move.l a0,COP1LC(a6)
|
||||
.done
|
||||
endif
|
||||
endif ; INTERLACE == 1
|
||||
bra .mainLoop
|
||||
|
||||
include "init.s"
|
||||
include "utils.s"
|
||||
|
||||
|
||||
PokeBitplanePointers: ; d0 = frame offset in bytes, a0 = BPLP copper list address
|
||||
|
@ -50,7 +48,7 @@ InstallColorPalette:
|
|||
rts
|
||||
|
||||
if INTERLACE == 1
|
||||
copper:
|
||||
copperListAlternate:
|
||||
;; bitplane pointers must be first else poking addresses will be incorrect
|
||||
dc.w BPL1PTL,0
|
||||
dc.w BPL1PTH,0
|
||||
|
@ -64,10 +62,10 @@ copper:
|
|||
dc.w BPL5PTH,0
|
||||
dc.w BPL6PTL,0
|
||||
dc.w BPL6PTH,0
|
||||
|
||||
dc.l $fffffffe
|
||||
endif
|
||||
copperLOF:
|
||||
endif ; INTERLACE == 1
|
||||
|
||||
copperList:
|
||||
;; bitplane pointers must be first else poking addresses will be incorrect
|
||||
dc.w BPL1PTL,0
|
||||
dc.w BPL1PTH,0
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
xref WaitVerticalBlank
|
||||
xref WaitRaster
|
||||
|
||||
WaitVerticalBlank:
|
||||
movem.l d0-a6,-(sp)
|
||||
.loop move.l $dff004,d0
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
VPOSRLOFBIT equ 15
|
|
@ -0,0 +1 @@
|
|||
LVL3_INT_VECTOR equ $6c
|
|
@ -4,25 +4,40 @@ HOST_WARNINGS=-pedantic-errors -Wfatal-errors -Wall -Werror -Wextra -Wno-unused-
|
|||
HOST_CFLAGS=$(HOST_WARNINGS)
|
||||
IMAGECONDIR=../tools/imagecon
|
||||
IMAGECON=$(IMAGECONDIR)/out/imagecon
|
||||
SHRINKLERDIR=../tools/external/shrinkler
|
||||
SHRINKLEREXE=$(SHRINKLERDIR)/build/native/Shrinkler
|
||||
RESIZEDIR=../tools/resize
|
||||
RESIZE=$(RESIZEDIR)/out/resize
|
||||
A500_RUN_SCRIPT=~/Google\ Drive/Amiga/amiga500.sh
|
||||
A600_RUN_SCRIPT=~/Google\ Drive/Amiga/amiga600.sh
|
||||
|
||||
ifndef SHRINKLER
|
||||
SHRINKLER=0
|
||||
endif
|
||||
|
||||
ifndef BASE_ADDRESS
|
||||
BASE_ADDRESS=70000
|
||||
endif
|
||||
|
||||
ifndef DECOMPRESS_ADDRESS
|
||||
DECOMPRESS_ADDRESS=10000
|
||||
endif
|
||||
|
||||
ifndef RUN_SCRIPT
|
||||
RUN_SCRIPT=$(A500_RUN_SCRIPT)
|
||||
endif
|
||||
|
||||
ifndef BOOTBLOCK_ASM
|
||||
|
||||
ifeq ($(SHRINKLER),1)
|
||||
BOOTBLOCK_ASM=../shared/shrinkler_bootblock.s
|
||||
PROGRAM_BIN=out/shrunk.bin
|
||||
VASM_EXTRA_BOOTBLOCK_ARGS=-DDECOMPRESS_ADDRESS="\$$$(DECOMPRESS_ADDRESS)" -DSHRINKLER=$(SHRINKLER)
|
||||
else
|
||||
BOOTBLOCK_ASM=../shared/bootblock.s
|
||||
PROGRAM_BIN=out/main.bin
|
||||
VASM_EXTRA_BOOTBLOCK_ARGS=
|
||||
endif
|
||||
|
||||
ifndef PROGRAM_BIN
|
||||
PROGRAM_BIN=out/main.bin
|
||||
endif
|
||||
|
||||
all: bin out $(MAKEADF) $(FLOPPY)
|
||||
|
||||
|
@ -50,6 +65,9 @@ ic:
|
|||
$(IMAGECON):
|
||||
make -C $(IMAGECONDIR)
|
||||
|
||||
$(SHRINKLEREXE):
|
||||
make -C $(SHRINKLERDIR)
|
||||
|
||||
$(RESIZE):
|
||||
make -C $(RESIZEDIR)
|
||||
|
||||
|
@ -68,14 +86,18 @@ out/bootblock.o: $(BOOTBLOCK_ASM) $(PROGRAM_BIN)
|
|||
vasmm68k_mot $(VASM_EXTRA_BOOTBLOCK_ARGS) -DBASE_ADDRESS="\$$$(BASE_ADDRESS)" -Fhunk -phxass -opt-fconst -nowarn=62 -quiet $< -o $@ -I/usr/local/amiga/os-include
|
||||
|
||||
out/main.o: $(MODULE) $(EXTRA)
|
||||
@# -v
|
||||
@#vc -c $< -o $@
|
||||
@#-showopt -no-opt
|
||||
vasmm68k_mot $(VASM_EXTRA_ARGS) -Fhunk -phxass -opt-fconst -nowarn=62 -quiet $< -o $@ -I/usr/local/amiga/os-include
|
||||
|
||||
out/main.bin: out/main.o $(EXTRAOBJS)
|
||||
out/%.o: %.s
|
||||
vasmm68k_mot $(VASM_EXTRA_ARGS) -Fhunk -phxass -opt-fconst -nowarn=62 -quiet $< -o $@ -I/usr/local/amiga/os-include
|
||||
|
||||
out/main.bin: out/main.o $(OBJS)
|
||||
@#-T ../link.script
|
||||
vlink -Ttext 0x$(BASE_ADDRESS) -brawbin1 $< $(EXTRAOBJS) -o $@
|
||||
vlink -Ttext 0x$(BASE_ADDRESS) -brawbin1 $< $(OBJS) -o $@
|
||||
|
||||
|
||||
out/shrunk.bin: $(SHRINKLER_EXE) out/main.bin
|
||||
$(SHRINKLEREXE) -d out/main.bin out/shrunk.bin
|
||||
|
||||
clean:
|
||||
rm -rf out bin *~
|
||||
|
|
|
@ -39,7 +39,7 @@ BootEntry:
|
|||
else ; SHRINKER == 1
|
||||
|
||||
; a0 = compressed data
|
||||
lea $10000,a0
|
||||
lea DECOMPRESS_ADDRESS,a0
|
||||
; a1 = decompressed data destination
|
||||
lea BASE_ADDRESS,a1
|
||||
; a2 = progress callback, can be zero if no callback is desired.
|
||||
|
@ -55,7 +55,7 @@ Callback:
|
|||
;; a0 = Callback argument
|
||||
move.l a6,-(sp)
|
||||
lea CUSTOM,a6
|
||||
move.w d0,COLOR00(a6)
|
||||
move.w d0,COLOR00(a6) ; Set wild background colors as we decompress
|
||||
move.l (sp)+,a6
|
||||
rts
|
||||
|
Loading…
Reference in New Issue