From fbc2a85fd91295f33020b17669c22d0f876b5b3e Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Tue, 19 Apr 2016 13:29:53 +1000 Subject: [PATCH] cleaned up palette handling a bit --- 028.game2/Makefile | 31 ++-- 028.game2/assets/panel.pal | 3 + 028.game2/fade.c | 2 +- 028.game2/fade.s | 273 ------------------------------ 028.game2/game1.s | 69 ++++++-- 028.game2/tilemap-copper-list.s | 16 -- 028.game2/tilemap-grey-table.s | 25 --- 028.game2/tilemap-palette-table.s | 25 --- tools/imagecon/palette.c | 2 +- 9 files changed, 79 insertions(+), 367 deletions(-) delete mode 100644 028.game2/fade.s delete mode 100644 028.game2/tilemap-copper-list.s delete mode 100644 028.game2/tilemap-grey-table.s delete mode 100644 028.game2/tilemap-palette-table.s diff --git a/028.game2/Makefile b/028.game2/Makefile index 6496dde..2e1944f 100644 --- a/028.game2/Makefile +++ b/028.game2/Makefile @@ -1,4 +1,6 @@ EXAMPLE_NAME=game1 +BACKGROUND_COLOR=09e +BACKGROUND_GREY_COLOR=777 # userstack used by bootblock USERSTACK_ADDRESS=7fffc @@ -28,7 +30,7 @@ IMAGES=foreground.png \ sprite_coin4.png \ sprite_coin6.png \ sprite_coin7.png - + IMAGEDATA=$(addprefix out/, $(IMAGES:.png=.bin)) VASM_EXTRA_ARGS=-DNUM_COLORS=$(NUM_COLORS) @@ -38,24 +40,20 @@ LINKER_OPTIONS=-T link.script.x include ../shared/base.mk - -#out/%.sized.png: ../assets/%.png -# $(RESIZE) --width=352 --height=256 --blur=0.75 --input=$< --output=$@ - out/%.bin: out/%.sized.png $(IMAGECON) --input $< $(IMAGECON_ARGS) --quantize --colors $(NUM_COLORS) --output-bitplanes --output-palette-asm --output-grey-palette --output-palette $(DITHER) --output out/$* out/foreground.bin: assets/foregroundTilemap.png - $(IMAGECON) --use-palette=assets/foreground.pal --input $< $(IMAGECON_ARGS) --colors $(NUM_COLORS) --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-grey-palette --output-palette --output-png --output out/foreground + $(IMAGECON) --use-palette=assets/foreground.pal --input $< $(IMAGECON_ARGS) --colors $(NUM_COLORS) --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-grey-palette --output-palette --output-png --output-copperlist --output out/foreground + sed -i '' "1s/.*/ dc.w COLOR00,\$$$(BACKGROUND_COLOR)/" out/foreground-copper-list.s + sed -i '' "1s/.*/ dc.w \$$$(BACKGROUND_COLOR)/" out/foreground-palette-table.s + sed -i '' "1s/.*/ dc.w \$$$(BACKGROUND_GREY_COLOR)/" out/foreground-grey-table.s out/background.bin: assets/tilemap.png - $(IMAGECON) --use-palette=assets/background.pal --input $< $(IMAGECON_ARGS) --colors $(NUM_COLORS) --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-grey-palette --output-palette --output-png --output out/background - -out/tilemap-palette.s: assets/tilemap.png - $(IMAGECON) --use-palette=assets/palette.pal --full-color-palette-file --input=assets/tilemap.png --output-palette-asm --output=out/tilemap --output-copperlist --output-grey-palette + $(IMAGECON) --use-palette=assets/background.pal --input $< $(IMAGECON_ARGS) --colors $(NUM_COLORS) --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-grey-palette --output-palette --output-png --output-copperlist --output out/background --palette-offset 8 out/panel.bin: assets/panel.png - $(IMAGECON) --input $< $(IMAGECON_ARGS) --colors 16 --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-palette --output-png --output-copperlist --output out/panel --use-palette=assets/panel.pal + $(IMAGECON) --input $< $(IMAGECON_ARGS) --colors 16 --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-palette --output-png --output-copperlist --output-grey-palette --output out/panel --use-palette=assets/panel.pal out/sprite_pig_%.bin: assets/sprite_pig_%.png $(IMAGECON) --input $< $(IMAGECON_ARGS) --colors 4 --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-palette --output-png --output-copperlist --output out/sprite_pig_$* --palette-offset 16 --use-palette=assets/pig.pal @@ -63,6 +61,15 @@ out/sprite_pig_%.bin: assets/sprite_pig_%.png out/sprite_coin%.bin: assets/sprite_coin%.png $(IMAGECON) --input $< $(IMAGECON_ARGS) --colors 4 --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-palette --output-png --output-copperlist --output out/sprite_coin$* --palette-offset 20 --use-palette=assets/coin.pal +out/fade.s: assets/bottom_section.pal out/fade + ./out/fade assets/bottom_section.pal bottom > out/fade.s + +out/panelFade.s: assets/panel.pal out/fade + ./out/fade assets/panel.pal panel > out/panelFade.s + +out/fade: fade.c + gcc fade.c -o out/fade + out/foreground-map.s: foreground.tmx ../tools/mapgen/out/mapgen --depth=3 --input=foreground.tmx mv foreground-map.s out @@ -76,5 +83,5 @@ out/background-map.s: background.tmx rm background-indexes.s out/blit.o: constants.i macros.i -out/main.o: out/background-map.s out/foreground-map.s $(IMAGEDATA) constants.i macros.i Makefile link.script.x assets/palette.pal out/tilemap-palette.s +out/main.o: out/background-map.s out/foreground-map.s $(IMAGEDATA) constants.i macros.i Makefile link.script.x assets/palette.pal out/fade.s out/panelFade.s out/init.o: constants.i Makefile \ No newline at end of file diff --git a/028.game2/assets/panel.pal b/028.game2/assets/panel.pal index 8d338cf..077644a 100644 --- a/028.game2/assets/panel.pal +++ b/028.game2/assets/panel.pal @@ -11,3 +11,6 @@ 000 068 119 255 085 221 204 255 170 187 153 255 +000 000 000 255 +000 000 000 255 +000 000 000 255 diff --git a/028.game2/fade.c b/028.game2/fade.c index 1c19c6f..fc6a351 100644 --- a/028.game2/fade.c +++ b/028.game2/fade.c @@ -54,7 +54,7 @@ main(int argc, char** argv) } } - printf("fadeComplete:\n"); + printf("%sFadeComplete:\n", argv[2]); fclose(fp); } diff --git a/028.game2/fade.s b/028.game2/fade.s deleted file mode 100644 index 2cfcd20..0000000 --- a/028.game2/fade.s +++ /dev/null @@ -1,273 +0,0 @@ -.step1 - dc.w $788 - dc.w $211 - dc.w $333 - dc.w $655 - dc.w $777 - dc.w $998 - dc.w $bbb - dc.w $778 - dc.w $000 - dc.w $9aa - dc.w $ccc - dc.w $899 - dc.w $ddd - dc.w $545 - dc.w $999 - dc.w $000 -.step2 - dc.w $788 - dc.w $211 - dc.w $323 - dc.w $655 - dc.w $877 - dc.w $a98 - dc.w $bba - dc.w $778 - dc.w $000 - dc.w $8aa - dc.w $ccd - dc.w $899 - dc.w $ddd - dc.w $644 - dc.w $999 - dc.w $000 -.step3 - dc.w $689 - dc.w $211 - dc.w $423 - dc.w $754 - dc.w $876 - dc.w $a97 - dc.w $cba - dc.w $679 - dc.w $000 - dc.w $8ab - dc.w $bdd - dc.w $899 - dc.w $ddd - dc.w $644 - dc.w $999 - dc.w $000 -.step4 - dc.w $689 - dc.w $211 - dc.w $422 - dc.w $754 - dc.w $976 - dc.w $a97 - dc.w $cba - dc.w $689 - dc.w $000 - dc.w $7ab - dc.w $bdd - dc.w $799 - dc.w $ddd - dc.w $734 - dc.w $999 - dc.w $000 -.step5 - dc.w $58a - dc.w $211 - dc.w $422 - dc.w $854 - dc.w $976 - dc.w $b96 - dc.w $cc9 - dc.w $58a - dc.w $000 - dc.w $7ab - dc.w $bdd - dc.w $799 - dc.w $ddd - dc.w $734 - dc.w $999 - dc.w $000 -.step6 - dc.w $58a - dc.w $311 - dc.w $522 - dc.w $853 - dc.w $975 - dc.w $b96 - dc.w $cc9 - dc.w $58a - dc.w $000 - dc.w $6ac - dc.w $add - dc.w $79a - dc.w $ddd - dc.w $834 - dc.w $999 - dc.w $000 -.step7 - dc.w $48b - dc.w $311 - dc.w $512 - dc.w $953 - dc.w $a75 - dc.w $c95 - dc.w $cc9 - dc.w $48a - dc.w $000 - dc.w $6ac - dc.w $ade - dc.w $79a - dc.w $ddd - dc.w $824 - dc.w $999 - dc.w $000 -.step8 - dc.w $48b - dc.w $311 - dc.w $512 - dc.w $943 - dc.w $a75 - dc.w $ca5 - dc.w $dc8 - dc.w $48b - dc.w $000 - dc.w $5ac - dc.w $ade - dc.w $69a - dc.w $ddd - dc.w $923 - dc.w $999 - dc.w $000 -.step9 - dc.w $38b - dc.w $301 - dc.w $612 - dc.w $942 - dc.w $a74 - dc.w $ca4 - dc.w $dc8 - dc.w $48b - dc.w $000 - dc.w $5bd - dc.w $9de - dc.w $6aa - dc.w $ddd - dc.w $923 - dc.w $999 - dc.w $000 -.step10 - dc.w $39c - dc.w $301 - dc.w $612 - dc.w $a42 - dc.w $b74 - dc.w $da4 - dc.w $dc8 - dc.w $38c - dc.w $000 - dc.w $4bd - dc.w $9de - dc.w $6aa - dc.w $ddd - dc.w $a23 - dc.w $999 - dc.w $000 -.step11 - dc.w $29c - dc.w $401 - dc.w $612 - dc.w $a42 - dc.w $b74 - dc.w $da3 - dc.w $dc7 - dc.w $38c - dc.w $000 - dc.w $4be - dc.w $9ee - dc.w $5ab - dc.w $ddd - dc.w $a13 - dc.w $999 - dc.w $000 -.step12 - dc.w $29d - dc.w $401 - dc.w $702 - dc.w $b41 - dc.w $b73 - dc.w $ea3 - dc.w $dc7 - dc.w $28c - dc.w $000 - dc.w $3be - dc.w $8ef - dc.w $5ab - dc.w $ddd - dc.w $b13 - dc.w $999 - dc.w $000 -.step13 - dc.w $19d - dc.w $401 - dc.w $702 - dc.w $b41 - dc.w $c73 - dc.w $ea2 - dc.w $dd7 - dc.w $28d - dc.w $000 - dc.w $3be - dc.w $8ef - dc.w $5ab - dc.w $ddd - dc.w $b13 - dc.w $999 - dc.w $000 -.step14 - dc.w $19e - dc.w $401 - dc.w $701 - dc.w $c41 - dc.w $c73 - dc.w $ea2 - dc.w $ed6 - dc.w $18d - dc.w $000 - dc.w $2bf - dc.w $8ef - dc.w $5ab - dc.w $ddd - dc.w $c02 - dc.w $999 - dc.w $000 -.step15 - dc.w $09e - dc.w $401 - dc.w $801 - dc.w $c40 - dc.w $c72 - dc.w $fa1 - dc.w $ed6 - dc.w $18e - dc.w $000 - dc.w $2bf - dc.w $7ef - dc.w $4ab - dc.w $ddd - dc.w $c02 - dc.w $999 - dc.w $000 -.step16 - dc.w $09e - dc.w $500 - dc.w $801 - dc.w $d30 - dc.w $d72 - dc.w $fa1 - dc.w $ed6 - dc.w $18e - dc.w $000 - dc.w $1cf - dc.w $7ef - dc.w $4ac - dc.w $ddd - dc.w $d02 - dc.w $999 - dc.w $000 -fadeComplete: diff --git a/028.game2/game1.s b/028.game2/game1.s index 894b94d..9e8afe6 100644 --- a/028.game2/game1.s +++ b/028.game2/game1.s @@ -373,8 +373,9 @@ panelCopperListBpl1Ptr: dc.w BPLCON0,(4<<12)|COLOR_ON ; 4 bit planes dc.w BPL1MOD,SCREEN_WIDTH_BYTES*4-SCREEN_WIDTH_BYTES dc.w BPL2MOD,SCREEN_WIDTH_BYTES*4-SCREEN_WIDTH_BYTES +panelCopperPalettePtr: include "out/panel-copper-list.s" - dc.W $5bd1,$fffe + dc.w $5bd1,$fffe dc.w BPL1MOD,BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES-2 @@ -408,8 +409,8 @@ copperListBpl2Ptr: dc.w BPLCON0,(SCREEN_BIT_DEPTH*2<<12)|COLOR_ON|DBLPF tileMapCopperPalettePtr: - include "tilemap-copper-list.s" - + include "out/foreground-copper-list.s" + include "out/background-copper-list.s" dc.l $fffffffe InstallSpriteColorPalette: @@ -439,13 +440,24 @@ InstallGreyPalette: add.l #2,a0 add.l #4,a1 dbra d0,.loop - rts + +InstallPanelGreyPalette: + lea panelCopperPalettePtr,a1 + lea panelGreyPalette,a0 + add.l #2,a1 + move.l #15,d0 +.loop: + move.w (a0),(a1) + add.l #2,a0 + add.l #4,a1 + dbra d0,.loop + rts InstallNextGreyPalette: lea tileMapCopperPalettePtr,a1 move.l fadePtr,a0 - lea fadeComplete,a2 + lea bottomFadeComplete,a2 cmp.l a2,a0 bge .done add.l #2,a1 @@ -461,11 +473,27 @@ InstallNextGreyPalette: beq .done add.l #16*2,fadePtr .done - rts - -InstallPalette: - include "out/tilemap-palette.s" - rts + +InstallNextGreyPanelPalette: + lea panelCopperPalettePtr,a1 + move.l panelFadePtr,a0 + lea panelFadeComplete,a2 + cmp.l a2,a0 + bge .done + add.l #2,a1 + move.l #15,d0 +.loop: + move.w (a0),(a1) + add.l #2,a0 + add.l #4,a1 + dbra d0,.loop + move.l frameCount,d0 + lsr.l #1,d0 + btst.l #0,d0 + beq .done + add.l #16*2,panelFadePtr +.done + rts foregroundOnscreen: dc.l foregroundBitplanes1 @@ -509,7 +537,9 @@ moving: fadePtr: dc.l fade - +panelFadePtr: + dc.l panelFade + animIndex: ds.l 16,0 deAnimIndex: @@ -590,13 +620,24 @@ deAnimIndexPattern: dc.l $ffffffff greyPalette: - include "tilemap-grey-table.s" + include "out/foreground-grey-table.s" + include "out/background-grey-table.s" +panelGreyPalette: + include "out/panel-grey-table.s" + tilemapPalette: - include "tilemap-palette-table.s" + if 0 + include "tilemap-palette-table.s" + endif + include "out/foreground-palette-table.s" + include "out/background-palette-table.s" fade: - include "fade.s" + include "out/fade.s" + +panelFade: + include "out/panelFade.s" section .bss foregroundBitplanes1: diff --git a/028.game2/tilemap-copper-list.s b/028.game2/tilemap-copper-list.s deleted file mode 100644 index dddbc79..0000000 --- a/028.game2/tilemap-copper-list.s +++ /dev/null @@ -1,16 +0,0 @@ - dc.w COLOR00,$09e - dc.w $182,$500 - dc.w $184,$801 - dc.w $186,$d30 - dc.w $188,$d72 - dc.w $18a,$fa1 - dc.w $18c,$ed6 - dc.w $18e,$18e - dc.w $190,$0f0 - dc.w $192,$1cf - dc.w $194,$7ef - dc.w $196,$4ac - dc.w $198,$ddd - dc.w $19a,$d02 - dc.w $19c,$999 - dc.w $19e,$00f diff --git a/028.game2/tilemap-grey-table.s b/028.game2/tilemap-grey-table.s deleted file mode 100644 index e13405a..0000000 --- a/028.game2/tilemap-grey-table.s +++ /dev/null @@ -1,25 +0,0 @@ - dc.w $777 - dc.w $111 - dc.w $333 - dc.w $555 - dc.w $777 - dc.w $888 - dc.w $bbb - dc.w $777 - dc.w $000 - dc.w $999 - dc.w $ccc - dc.w $888 - dc.w $ddd - dc.w $555 - dc.w $999 - dc.w $000 - dc.w $aaa - dc.w $999 - dc.w $444 - dc.w $333 - dc.w $666 - dc.w $aaa - dc.w $777 - dc.w $aaa - dc.w $fff diff --git a/028.game2/tilemap-palette-table.s b/028.game2/tilemap-palette-table.s deleted file mode 100644 index c922644..0000000 --- a/028.game2/tilemap-palette-table.s +++ /dev/null @@ -1,25 +0,0 @@ - dc.w $09e - dc.w $500 - dc.w $801 - dc.w $d30 - dc.w $d72 - dc.w $fa1 - dc.w $ed6 - dc.w $18e - dc.w $000 - dc.w $1cf - dc.w $7ef - dc.w $4ac - dc.w $ddd - dc.w $d02 - dc.w $999 - dc.w $000 - dc.w $ea6 - dc.w $f76 - dc.w $a31 - dc.w $037 - dc.w $19a - dc.w $1ef - dc.w $f70 - dc.w $ff0 - dc.w $fff diff --git a/tools/imagecon/palette.c b/tools/imagecon/palette.c index 461d5a7..c21295c 100644 --- a/tools/imagecon/palette.c +++ b/tools/imagecon/palette.c @@ -116,7 +116,7 @@ palette_output(imagecon_image_t* ic, char* outFilename) } if (fp) { - fprintf(fp, "\tdc.w $%x,$%x\n", 0x180+(i*2), RGB24TORGB12(ic->palette[i].r) << 8 | RGB24TORGB12(ic->palette[i].g) << 4 | RGB24TORGB12(ic->palette[i].b)); + fprintf(fp, "\tdc.w $%x,$%x\n", 0x180+((i+config.paletteOffset)*2), RGB24TORGB12(ic->palette[i].r) << 8 | RGB24TORGB12(ic->palette[i].g) << 4 | RGB24TORGB12(ic->palette[i].b)); } }