1
0
mirror of https://frontier.innolan.net/github/AmigaExamples.git synced 2026-01-12 01:12:29 +00:00

Added support for greyscale palette

This commit is contained in:
alpine9000
2016-03-05 16:39:00 +11:00
parent c3cdfb0f33
commit f3be7251a1
5 changed files with 94 additions and 1 deletions

View File

@ -43,13 +43,14 @@ $(SHARED_PALETTE): $(IMAGECON)
$(OUTPUT_BASE).bin: $(IMAGECON)
-rm -f $(OUTPUT_BASE).bin $(OUTPUT_BASE)-copper-list.s $(OUTPUT_BASE)-palette.s
$(IMAGECON) --input $(TEST_IMAGE) --output $(OUTPUT_BASE) --output-copperlist --output-bitplanes --output-palette-asm --colors 32 --quantize
$(IMAGECON) --input $(TEST_IMAGE) --output $(OUTPUT_BASE) --output-copperlist --output-bitplanes --output-grey-palette --output-palette-asm --colors 32 --quantize
$(IMAGECON) --input $(BOB_IMAGE) --output $(BOB_BASE) --output-mask --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)-grey.s $(REFERENCE_BASE)-grey.s
diff $(SHARED_PALETTE) $(REFERENCE_SHARED_PALETTE)
diff $(SHARED_BASE).bin $(REFERENCE_SHARED_BASE).bin
diff $(SHARED_BASE)-copper-list.s $(REFERENCE_SHARED_BASE)-copper-list.s

View File

@ -13,6 +13,7 @@ usage
--quantize
--output-palette
--output-palette-asm
--output-grey-palette-asm
--output-bitplanes
--output-mask
--output-copperlist
@ -66,6 +67,10 @@ Generate a palette file of the final palette used. Output will be the output fil
Generate m68k assembler instructions to install the palette. No symbols are generated. Registers are preserved.
**--output-grey-palette-asm**
Generate m68k assembler instructions to install a greyscale version of 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.

View File

@ -20,6 +20,7 @@ imagecon_config_t config = {
.outputPalette = 0,
.outputMask = 0,
.outputPaletteAsm = 0,
.outputPaletteGrey = 0,
.outputBitplanes = 0,
.outputCopperList = 0,
.quantize = 0,
@ -40,6 +41,7 @@ usage()
" --output-copperlist\n"\
" --output-mask\n"\
" --output-palette-asm\n"\
" --output-grey-palette-asm\n"\
" --output-palette\n"\
" --use-palette <palette file>\n"\
" --verbose\n", config.argv[0]);
@ -108,6 +110,7 @@ outputPalette(char* outFilename, imagecon_image_t* ic)
FILE* fp = 0;
FILE* paletteFP = 0;
FILE* paletteAsmFP = 0;
FILE* paletteGreyFP = 0;
if (config.outputCopperList) {
fp = openFileWrite("%s-copper-list.s", outFilename);
@ -117,6 +120,11 @@ outputPalette(char* outFilename, imagecon_image_t* ic)
paletteFP = openFileWrite("%s.pal", outFilename);
}
if (config.outputPaletteGrey) {
paletteGreyFP = openFileWrite("%s-grey.s", outFilename);
fprintf(paletteGreyFP, "\tmovem.l d0-a6,-(sp)\n\tlea CUSTOM,a6\n");
}
if (config.outputPaletteAsm) {
paletteAsmFP = openFileWrite("%s-palette.s", outFilename);
fprintf(paletteAsmFP, "\tmovem.l d0-a6,-(sp)\n\tlea CUSTOM,a6\n");
@ -136,6 +144,11 @@ outputPalette(char* outFilename, imagecon_image_t* ic)
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 (paletteGreyFP) {
unsigned grey = (ic->palette[i].r + ic->palette[i].g + ic->palette[i].b)/3;
fprintf(paletteGreyFP, "\tlea COLOR%02d(a6),a0\n\tmove.w #$%03x,(a0)\n", i, grey << 8 | grey << 4 | grey);
}
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);
}
@ -145,6 +158,11 @@ outputPalette(char* outFilename, imagecon_image_t* ic)
fclose(paletteFP);
}
if (paletteGreyFP) {
fprintf(paletteGreyFP, "\tmovem.l (sp)+,d0-a6\n");
fclose(paletteGreyFP);
}
if (paletteAsmFP) {
fprintf(paletteAsmFP, "\tmovem.l (sp)+,d0-a6\n");
fclose(paletteFP);
@ -478,6 +496,7 @@ main(int argc, char **argv)
{"output-bitplanes", no_argument, &config.outputBitplanes, 1},
{"output-palette", no_argument, &config.outputPalette, 1},
{"output-palette-asm", no_argument, &config.outputPaletteAsm, 1},
{"output-grey-palette-asm", no_argument, &config.outputPaletteGrey, 1},
{"output-mask", no_argument, &config.outputMask, 1},
{"use-palette", required_argument, 0, 'p'},
{"output", required_argument, 0, 'o'},

View File

@ -7,6 +7,7 @@ typedef struct {
int maxColors;
int outputPalette;
int outputPaletteAsm;
int outputPaletteGrey;
int outputMask;
int outputBitplanes;
int outputCopperList;

View File

@ -0,0 +1,67 @@
movem.l d0-a6,-(sp)
lea CUSTOM,a6
lea COLOR00(a6),a0
move.w #$666,(a0)
lea COLOR01(a6),a0
move.w #$777,(a0)
lea COLOR02(a6),a0
move.w #$444,(a0)
lea COLOR03(a6),a0
move.w #$eee,(a0)
lea COLOR04(a6),a0
move.w #$111,(a0)
lea COLOR05(a6),a0
move.w #$333,(a0)
lea COLOR06(a6),a0
move.w #$ddd,(a0)
lea COLOR07(a6),a0
move.w #$777,(a0)
lea COLOR08(a6),a0
move.w #$222,(a0)
lea COLOR09(a6),a0
move.w #$222,(a0)
lea COLOR10(a6),a0
move.w #$555,(a0)
lea COLOR11(a6),a0
move.w #$ccc,(a0)
lea COLOR12(a6),a0
move.w #$444,(a0)
lea COLOR13(a6),a0
move.w #$999,(a0)
lea COLOR14(a6),a0
move.w #$888,(a0)
lea COLOR15(a6),a0
move.w #$666,(a0)
lea COLOR16(a6),a0
move.w #$888,(a0)
lea COLOR17(a6),a0
move.w #$ccc,(a0)
lea COLOR18(a6),a0
move.w #$aaa,(a0)
lea COLOR19(a6),a0
move.w #$bbb,(a0)
lea COLOR20(a6),a0
move.w #$aaa,(a0)
lea COLOR21(a6),a0
move.w #$999,(a0)
lea COLOR22(a6),a0
move.w #$999,(a0)
lea COLOR23(a6),a0
move.w #$eee,(a0)
lea COLOR24(a6),a0
move.w #$888,(a0)
lea COLOR25(a6),a0
move.w #$bbb,(a0)
lea COLOR26(a6),a0
move.w #$fff,(a0)
lea COLOR27(a6),a0
move.w #$666,(a0)
lea COLOR28(a6),a0
move.w #$aaa,(a0)
lea COLOR29(a6),a0
move.w #$666,(a0)
lea COLOR30(a6),a0
move.w #$999,(a0)
lea COLOR31(a6),a0
move.w #$777,(a0)
movem.l (sp)+,d0-a6