diff --git a/006.simple_blit/Makefile b/006.simple_blit/Makefile index 81e4eef..f0234a7 100644 --- a/006.simple_blit/Makefile +++ b/006.simple_blit/Makefile @@ -1,6 +1,6 @@ MODULE=blit.s FLOPPY=bin/blit.adf -IMAGEDATA=out/image-copper-list.s out/image.bin +IMAGEDATA=out/image-palette.s out/image.bin IMAGEFILE=../assets/mission-beach.png TC_IMAGEDATA=out/tc.bin out/tc-mask.bin TC_IMAGEFILE=../assets/tc.png @@ -14,7 +14,7 @@ $(SHARED_PALETTE): $(IMAGEFILE) $(TC_IMAGEFILE) $(IMAGECON) --input $(IMAGEFILE),$(TC_IMAGEFILE) --output $(SHARED_PALETTE_BASE) --colors 32 --quantize --output-palette $(IMAGEDATA): $(IMAGECON) $(IMAGEFILE) $(SHARED_PALETTE) - $(IMAGECON) --input $(IMAGEFILE) --output out/image --output-bitplanes --output-copperlist --use-palette $(SHARED_PALETTE) + $(IMAGECON) --input $(IMAGEFILE) --output out/image --output-bitplanes --output-palette-asm --use-palette $(SHARED_PALETTE) $(TC_IMAGEDATA): $(IMAGECON) $(TC_IMAGEFILE) $(SHARED_PALETTE) - $(IMAGECON) --input $(TC_IMAGEFILE) --output out/tc --output-bitplanes --output-mask --output-copperlist --use-palette $(SHARED_PALETTE) + $(IMAGECON) --input $(TC_IMAGEFILE) --output out/tc --output-bitplanes --output-mask --use-palette $(SHARED_PALETTE) diff --git a/006.simple_blit/README.md b/006.simple_blit/README.md index c7c625f..e15d5d5 100644 --- a/006.simple_blit/README.md +++ b/006.simple_blit/README.md @@ -3,6 +3,7 @@ perform a basic blit We make some changes to [001.simple_image](../001.simple_image): 1. The bitplane pointers are now reset using the copper. + 2. The palette is now installed once and removed from the copper list. 2. Interrupt processing is disabled. 3. A6 is now used as the global base register for CUSTOM. diff --git a/006.simple_blit/bin/blit.adf b/006.simple_blit/bin/blit.adf index 10c7d36..18bbfb2 100644 Binary files a/006.simple_blit/bin/blit.adf and b/006.simple_blit/bin/blit.adf differ diff --git a/006.simple_blit/blit.s b/006.simple_blit/blit.s index a5d2f51..b6cb08a 100644 --- a/006.simple_blit/blit.s +++ b/006.simple_blit/blit.s @@ -20,6 +20,8 @@ entry: move #$7ff,DMACON(a6) ; disable all dma move #$7fff,INTENA(a6) ; disable all interrupts + include "out/image-palette.s" + if 0 ;; reset color registers to white to prevent startup flicker move.l #32,d0 lea COLOR00(a6),a0 @@ -27,6 +29,7 @@ entry: move.w #$FFF,(a0) addq #2,a0 dbra d0,.loop + endif ;; set up playfield move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6) @@ -132,8 +135,7 @@ copper: dc.w BPL4PTH,0 dc.w BPL5PTL,0 dc.w BPL5PTH,0 - - include "out/image-copper-list.s" + dc.l $fffffffe bitplanes: diff --git a/tools/imagecon/Makefile b/tools/imagecon/Makefile index 5c53a79..f5b8b88 100644 --- a/tools/imagecon/Makefile +++ b/tools/imagecon/Makefile @@ -39,12 +39,13 @@ $(SHARED_PALETTE): $(IMAGECON) $(IMAGECON) --input $(TEST_IMAGE),$(TEST_IMAGE2) --output $(SHARED_BASE) --colors 32 --quantize --output-palette $(OUTPUT_BASE).bin: $(IMAGECON) - -rm -f $(OUTPUT_BASE).bin $(OUTPUT_BASE)-copper-list.s $(OUTPUT_BASE)-mask.bin - $(IMAGECON) --input $(TEST_IMAGE) --output $(OUTPUT_BASE) --output-mask --output-copperlist --output-bitplanes --colors 32 --quantize + -rm -f $(OUTPUT_BASE).bin $(OUTPUT_BASE)-copper-list.s $(OUTPUT_BASE)-palette.s $(OUTPUT_BASE)-mask.bin + $(IMAGECON) --input $(TEST_IMAGE) --output $(OUTPUT_BASE) --output-mask --output-copperlist --output-bitplanes --output-palette-asm --colors 32 --quantize test: $(IMAGECON) $(OUTPUT_BASE).bin $(SHARED_PALETTE) $(USED_PALETTE) diff $(OUTPUT_BASE).bin $(REFERENCE_BASE).bin diff $(OUTPUT_BASE)-copper-list.s $(REFERENCE_BASE)-copper-list.s + diff $(OUTPUT_BASE)-palette.s $(REFERENCE_BASE)-palette.s diff $(OUTPUT_BASE)-mask.bin $(REFERENCE_BASE)-mask.bin diff $(SHARED_PALETTE) $(REFERENCE_SHARED_PALETTE) diff $(SHARED_BASE).bin $(REFERENCE_SHARED_BASE).bin diff --git a/tools/imagecon/README.md b/tools/imagecon/README.md index 562ffff..ba04ca9 100644 --- a/tools/imagecon/README.md +++ b/tools/imagecon/README.md @@ -12,6 +12,7 @@ usage --colors --quantize --output-palette + --output-palette-asm --output-bitplanes --output-mask --output-copperlist @@ -23,8 +24,9 @@ The following files can be generated: 1. **<output prefix>.bin** binary interleaved bitplane data 2. **<output prefix>-copper-list.s** m68k assembler syntax copper list with no symbols -3. **<output prefix>.pal** palette file listing the palette colors as hex -3. **<output prefix>-mask.bin** binary interleaved bitplane mask +3. **<output prefix>-palette.s** m68k assembler syntax code to install the color palette (preserves all registers) +4. **<output prefix>.pal** palette file listing the palette colors as hex +5. **<output prefix>-mask.bin** binary interleaved bitplane mask options ------- @@ -60,6 +62,10 @@ Output the binary bitplane data for use as a blitter source mask Generate a palette file of the final palette used. Output will be the output file with the ".pal" extension. +**--output-palette-asm** + +Generate m68k assembler instructions to install the palette. No symbols are generated. Registers are preserved. + **--use-palette** <palette file> Specify a palette file to use that will override the image or quantized palette. Overrides the --colors and --quantize options. diff --git a/tools/imagecon/imagecon.c b/tools/imagecon/imagecon.c index 9960b87..bfe9b97 100644 --- a/tools/imagecon/imagecon.c +++ b/tools/imagecon/imagecon.c @@ -19,6 +19,7 @@ imagecon_config_t config = { .maxColors = MAX_PALETTE, .outputPalette = 0, .outputMask = 0, + .outputPaletteAsm = 0, .outputBitplanes = 0, .outputCopperList = 0, .quantize = 0, @@ -38,6 +39,7 @@ usage() " --output-bitplanes\n"\ " --output-copperlist\n"\ " --output-mask\n"\ + " --output-palette-asm\n"\ " --output-palette\n"\ " --use-palette \n"\ " --verbose\n", config.argv[0]); @@ -105,6 +107,7 @@ outputPalette(char* outFilename, imagecon_image_t* ic) FILE* fp = 0; FILE* paletteFP = 0; + FILE* paletteAsmFP = 0; if (config.outputCopperList) { fp = openFileWrite("%s-copper-list.s", outFilename); @@ -114,6 +117,11 @@ outputPalette(char* outFilename, imagecon_image_t* ic) paletteFP = openFileWrite("%s.pal", outFilename); } + if (config.outputPaletteAsm) { + paletteAsmFP = openFileWrite("%s-palette.s", outFilename); + fprintf(paletteAsmFP, "\tmovem.l d0-a6,-(sp)\n\tlea CUSTOM,a6\n"); + } + if (config.verbose) { printf("outputPalette:\n"); } @@ -125,6 +133,9 @@ outputPalette(char* outFilename, imagecon_image_t* ic) if (paletteFP) { fprintf(paletteFP, "%03x\n", ic->palette[i].r << 8 | ic->palette[i].g << 4 | ic->palette[i].b); } + if (paletteAsmFP) { + fprintf(paletteAsmFP, "\tlea COLOR%02d(a6),a0\n\tmove.w #$%03x,(a0)\n", i, ic->palette[i].r << 8 | ic->palette[i].g << 4 | ic->palette[i].b); + } if (fp) { fprintf(fp, "\tdc.w $%x,$%x\n", 0x180+(i*2), ic->palette[i].r << 8 | ic->palette[i].g << 4 | ic->palette[i].b); } @@ -134,6 +145,11 @@ outputPalette(char* outFilename, imagecon_image_t* ic) fclose(paletteFP); } + if (paletteAsmFP) { + fprintf(paletteAsmFP, "\tmovem.l (sp)+,d0-a6\n"); + fclose(paletteFP); + } + if (fp) { fclose(fp); } @@ -461,6 +477,7 @@ main(int argc, char **argv) {"output-copperlist", no_argument, &config.outputCopperList, 1}, {"output-bitplanes", no_argument, &config.outputBitplanes, 1}, {"output-palette", no_argument, &config.outputPalette, 1}, + {"output-palette-asm", no_argument, &config.outputPaletteAsm, 1}, {"output-mask", no_argument, &config.outputMask, 1}, {"use-palette", required_argument, 0, 'p'}, {"output", required_argument, 0, 'o'}, diff --git a/tools/imagecon/imagecon.h b/tools/imagecon/imagecon.h index e1bf794..0a9a3c2 100644 --- a/tools/imagecon/imagecon.h +++ b/tools/imagecon/imagecon.h @@ -6,6 +6,7 @@ typedef struct { int maxColors; int outputPalette; + int outputPaletteAsm; int outputMask; int outputBitplanes; int outputCopperList; diff --git a/tools/imagecon/reference/mission-beach-palette.s b/tools/imagecon/reference/mission-beach-palette.s new file mode 100644 index 0000000..f062381 --- /dev/null +++ b/tools/imagecon/reference/mission-beach-palette.s @@ -0,0 +1,67 @@ + movem.l d0-a6,-(sp) + lea CUSTOM,a6 + lea COLOR00(a6),a0 + move.w #$36b,(a0) + lea COLOR01(a6),a0 + move.w #$48b,(a0) + lea COLOR02(a6),a0 + move.w #$363,(a0) + lea COLOR03(a6),a0 + move.w #$ffd,(a0) + lea COLOR04(a6),a0 + move.w #$111,(a0) + lea COLOR05(a6),a0 + move.w #$443,(a0) + lea COLOR06(a6),a0 + move.w #$fec,(a0) + lea COLOR07(a6),a0 + move.w #$37b,(a0) + lea COLOR08(a6),a0 + move.w #$222,(a0) + lea COLOR09(a6),a0 + move.w #$332,(a0) + lea COLOR10(a6),a0 + move.w #$574,(a0) + lea COLOR11(a6),a0 + move.w #$eda,(a0) + lea COLOR12(a6),a0 + move.w #$554,(a0) + lea COLOR13(a6),a0 + move.w #$ca5,(a0) + lea COLOR14(a6),a0 + move.w #$59c,(a0) + lea COLOR15(a6),a0 + move.w #$684,(a0) + lea COLOR16(a6),a0 + move.w #$a95,(a0) + lea COLOR17(a6),a0 + move.w #$bde,(a0) + lea COLOR18(a6),a0 + move.w #$aba,(a0) + lea COLOR19(a6),a0 + move.w #$dc9,(a0) + lea COLOR20(a6),a0 + move.w #$9bc,(a0) + lea COLOR21(a6),a0 + move.w #$aa8,(a0) + lea COLOR22(a6),a0 + move.w #$8a9,(a0) + lea COLOR23(a6),a0 + move.w #$def,(a0) + lea COLOR24(a6),a0 + move.w #$897,(a0) + lea COLOR25(a6),a0 + move.w #$bcc,(a0) + lea COLOR26(a6),a0 + move.w #$fff,(a0) + lea COLOR27(a6),a0 + move.w #$765,(a0) + lea COLOR28(a6),a0 + move.w #$db6,(a0) + lea COLOR29(a6),a0 + move.w #$486,(a0) + lea COLOR30(a6),a0 + move.w #$6ad,(a0) + lea COLOR31(a6),a0 + move.w #$8a4,(a0) + movem.l (sp)+,d0-a6