big refactor ready for pathway fadeout
This commit is contained in:
parent
4e5a5ded19
commit
1deae4565b
|
@ -11,7 +11,7 @@ BASE_ADDRESS=4000
|
|||
NUM_COLORS=8
|
||||
|
||||
BOOTBLOCK_ASM=alpine_bootblock.s
|
||||
OBJS=out/init.o out/utils.o out/image.o out/blit.o out/joystick.o out/player.o out/items.o out/blitmtext.o out/blittext.o out/music.o out/P6112-Play.o out/splash.o
|
||||
OBJS=out/init.o out/utils.o out/image.o out/blit.o out/joystick.o out/player.o out/items.o out/blitmtext.o out/blittext.o out/music.o out/P6112-Play.o out/splash.o out/background.o
|
||||
|
||||
IMAGES=foreground.png \
|
||||
background.png \
|
||||
|
@ -67,6 +67,9 @@ out/foreground.bin: assets/assets.png
|
|||
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
|
||||
sed -i '' "1s/.*/ dc.w COLOR00,\$$$(BACKGROUND_GREY_COLOR)/" out/foreground-grey-copper.s
|
||||
sed -i '' "2s/.*/ dc.w COLOR01,\$$888/" out/foreground-grey-copper.s
|
||||
sed -i '' "3s/.*/ dc.w COLOR02,\$$bbb/" out/foreground-grey-copper.s
|
||||
|
||||
out/background.bin: assets/assets.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-copperlist --output out/background --palette-offset 8
|
||||
|
@ -115,16 +118,17 @@ out/font%.bin: assets/font%.png
|
|||
out/splash.bin: assets/splash.png
|
||||
$(IMAGECON) --input $< $(IMAGECON_ARGS) --output-bitplanes --output-grey-palette-asm --output-palette-asm --output-palette --output out/splash --colors=32 --full-color-palette-file --output-png --output-copperlist
|
||||
|
||||
out/playarea_fade.s: assets/bottom_section_playarea.pal ../tools/fade/out/fade
|
||||
../tools/fade/out/fade --from-grey --to=assets/bottom_section_playarea.pal --output=playarea > out/playarea_fade.s
|
||||
|
||||
out/flags_fade.s: assets/bottom_section_flags.pal ../tools/fade/out/fade
|
||||
../tools/fade/out/fade --from-grey --to=assets/bottom_section_flags.pal --output=flags > out/flags_fade.s
|
||||
|
||||
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 ../tools/fade/out/fade
|
||||
../tools/fade/out/fade --from-grey --to=assets/panel.pal --output=panel > out/panelFade.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/tileFade.s: assets/tileFadeFrom.pal assets/tileFadeTo.pal ../tools/fade/out/fade
|
||||
../tools/fade/out/fade --colors=2 --from=assets/tileFadeFrom.pal --to=assets/tileFadeTo.pal --output=tileFade > out/tileFade.s
|
||||
|
||||
out/foreground-map.s: foreground.tmx
|
||||
../tools/mapgen/out/mapgen --depth=3 --input=foreground.tmx
|
||||
|
@ -139,5 +143,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/fade.s out/panelFade.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/playarea_fade.s out/flags_fade.s out/panelFade.s out/tileFade.s
|
||||
out/init.o: constants.i Makefile
|
Binary file not shown.
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 11 KiB |
|
@ -0,0 +1,16 @@
|
|||
000 153 238 255
|
||||
253 174 017 255
|
||||
233 216 100 255
|
||||
210 063 006 255
|
||||
211 116 039 255
|
||||
253 174 017 255
|
||||
233 216 100 255
|
||||
016 132 233 255
|
||||
000 000 014 255
|
||||
029 192 255 255
|
||||
121 235 255 255
|
||||
071 174 192 255
|
||||
213 213 213 255
|
||||
210 000 039 255
|
||||
154 154 154 255
|
||||
000 000 000 000
|
|
@ -0,0 +1,2 @@
|
|||
082 000 015 255
|
||||
133 000 026 255
|
|
@ -0,0 +1,2 @@
|
|||
253 174 017 255
|
||||
233 216 100 255
|
|
@ -0,0 +1,72 @@
|
|||
include "includes.i"
|
||||
|
||||
xdef InitialiseBackground
|
||||
xdef RenderNextBackgroundFrame
|
||||
xdef backgroundScrollX
|
||||
xdef backgroundOnscreen
|
||||
|
||||
|
||||
InitialiseBackground:
|
||||
move.l #0,backgroundScrollX
|
||||
move.l backgroundOffscreen,a0
|
||||
move.l #0,d0
|
||||
move.l #256,d1
|
||||
move.l #0,d2
|
||||
jsr BlitFillColor
|
||||
jsr WaitVerticalBlank
|
||||
jsr SwitchBuffers
|
||||
move.l backgroundOffscreen,a0
|
||||
move.l #0,d0
|
||||
move.l #256,d1
|
||||
move.l #0,d2
|
||||
jsr BlitFillColor
|
||||
rts
|
||||
|
||||
RenderBackgroundTile:
|
||||
;; a2 - map
|
||||
move.l backgroundScrollX,d0
|
||||
lsr.w #BACKGROUND_SCROLL_SHIFT_CONVERT,d0 ; convert to pixels
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
move.l backgroundOffscreen,a0
|
||||
add.l d0,a0
|
||||
lea backgroundTilemap,a1
|
||||
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
|
||||
add.w (a2),a1 ; source tile
|
||||
move.l backgroundScrollX,d2
|
||||
lsr.b #BACKGROUND_SCROLL_SHIFT_CONVERT,d2 ; convert to pixels
|
||||
andi.w #$f,d2 ; find the shift component
|
||||
jsr BlitTile
|
||||
rts
|
||||
|
||||
RenderNextBackgroundFrame:
|
||||
lea backgroundMap,a2
|
||||
move.l backgroundScrollX,d0
|
||||
lsr.l #BACKGROUND_SCROLL_TILE_INDEX_CONVERT,d0
|
||||
and.b #$fe,d0
|
||||
add.l d0,a2
|
||||
cmp.w #$FFFF,20(a2)
|
||||
bne .skip
|
||||
move.l #0,backgroundScrollX
|
||||
.skip:
|
||||
bsr RenderBackgroundTile
|
||||
rts
|
||||
|
||||
|
||||
backgroundScrollX:
|
||||
dc.l 0
|
||||
backgroundTilemap:
|
||||
incbin "out/background.bin"
|
||||
backgroundMap:
|
||||
include "out/background-map.s"
|
||||
dc.w $FFFF
|
||||
backgroundOnscreen:
|
||||
dc.l backgroundBitplanes1
|
||||
backgroundOffscreen:
|
||||
dc.l backgroundBitplanes1
|
||||
|
||||
section .bss
|
||||
backgroundBitplanes1:
|
||||
ds.b IMAGESIZE*2
|
||||
|
||||
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
</tileset>
|
||||
<layer name="background" width="200" height="16">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJztmkkOwjAMRcsBOEQR04YltAxXYLgA3AHuv8BdoCKrTW3HHdT+xVtUStPkRRnsJk+SZDcrWbLnOnJhuYIVlV0TG2Jb8x6v70nPr4a2adpg6RNcwEUTmcO3jlTHiTgTF2F9byr3MX6bt/nnTzIecAEXsf0qSKmehbCuK5W7EXfi0eHc9hgPuJi2C+t82dN7hx77VKCd96HxyCLWDrgYrwvPtcMTyf7tvQbCBVxw+tzXYvHen+ECLrRU5QumClzABScmX/DPfAQu4QIuukQaR6WKnEgIr3rgAi6kxOTBpXGUJicSWo/azq3ABVx4MpT89xCAC7gYEogv4ULjIjWcwdr4L98WfH8NxZdwARe8nOUMpv0PY3HdxzjABVx4oD0nxsRBVfFVaByk903hAi5iseYiNPeMLXeSm8aBu/C4Bw0X03LxBT9lUNQ=
|
||||
eJztmssNwjAMQLsANxYA8VsAym8FPgvADrD/AfeAhKKS2olLi/oO74CUhuRZTWI326Ioxh/Mgt/f2CrbVcyFhbAUVsr+bsK9YWyWMaTMCRe4aKJ06GMn7IWDcFQ+8xCeTmN++9PEAxe4yJ1XxUSYKtuehLNwEa5O//+reOBi2C5S35e1sOlwThXW9z4WjxIXuKhx4bl2eKLZv73XQFzgIqTLfS0X7/0ZF7iwUlcvGCq4wEVITr3gk1EP5oILXPwT2jzKUhOJ4dUPLnChJacOrs2jLDWR2HrUdm0FF7jwpC/17z6AC1z0CfJLXFhcpJzB2vgu3xbh/hrLL3GBi7BdyhnM+h3GOw9qKw64wIUH1nNiTh5Ul1/F4qC9b4oLXOSSWouw3DNOuZPcFIfQhcc9aFwMy8ULfVgzRw==
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
||||
|
|
|
@ -143,18 +143,7 @@ BlueFill:
|
|||
jsr BlitFillColor
|
||||
jsr WaitVerticalBlank
|
||||
jsr SwitchBuffers
|
||||
move.l backgroundOffscreen,a0
|
||||
move.l #0,d0
|
||||
move.l #256,d1
|
||||
move.l #0,d2
|
||||
jsr BlitFillColor
|
||||
jsr WaitVerticalBlank
|
||||
jsr SwitchBuffers
|
||||
move.l backgroundOffscreen,a0
|
||||
move.l #0,d0
|
||||
move.l #256,d1
|
||||
move.l #0,d2
|
||||
jsr BlitFillColor
|
||||
jsr InitialiseBackground
|
||||
movem.l (sp)+,d0-a6
|
||||
rts
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ PLAYER_INITIAL_Y equ $e4-32
|
|||
PLAYER_BOTTOM_Y equ $e4+16
|
||||
PLAYER_TOP_Y equ (PLAYER_BOTTOM_Y-(7*16))
|
||||
PLAYER_JUMP_PIXELS equ 8
|
||||
PLAYER_JUMP_SHIFT_CONVERT equ 3 ; x = x / PLAYER_JUMP_PIXELS
|
||||
PLAYER_CHECK_MISS_PIXELS equ 6
|
||||
PLAYER_PAUSE_PIXELS equ 12
|
||||
PLAYER_MOVE_PIXELS equ 2
|
||||
|
|
|
@ -1,18 +1,63 @@
|
|||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
|
||||
typedef struct {
|
||||
unsigned char r, g, b, a;
|
||||
} rgba_t;
|
||||
|
||||
#define NUM_COLORS 16
|
||||
typedef struct {
|
||||
int verbose;
|
||||
int numColors;
|
||||
char** argv;
|
||||
} config_t;
|
||||
|
||||
rgba_t original[NUM_COLORS];
|
||||
rgba_t gray[NUM_COLORS];
|
||||
rgba_t progress[NUM_COLORS];
|
||||
config_t config = {
|
||||
.numColors = 16
|
||||
};
|
||||
|
||||
#define MAX_COLORS 32
|
||||
|
||||
rgba_t original[MAX_COLORS];
|
||||
rgba_t gray[MAX_COLORS];
|
||||
rgba_t progress[MAX_COLORS];
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
config.argv = argv;
|
||||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
{"verbose", no_argument, &config.verbose, 1},
|
||||
{"colors", required_argument, 0, 'c'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
int option_index = 0;
|
||||
|
||||
c = getopt_long (argc, argv, "n:", long_options, &option_index);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 0:
|
||||
break;
|
||||
case 'c':
|
||||
if (sscanf(optarg, "%d", &config.numColors) != 1) {
|
||||
abort_("invalid width");
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FILE* fp = fopen(argv[1], "r");
|
||||
|
||||
rgba_t* p = original;
|
||||
|
@ -24,7 +69,7 @@ main(int argc, char** argv)
|
|||
rgba_t* g = gray;
|
||||
p = original;
|
||||
|
||||
for (int i = 0; i < NUM_COLORS; i++) {
|
||||
for (int i = 0; i < config.numColors; i++) {
|
||||
g->r = g->g = g->b = (p->r + p->g + p->b) / 3;
|
||||
// printf("%d %d %d\n", g->r, g->g, g->b);
|
||||
g++;
|
||||
|
@ -33,7 +78,7 @@ main(int argc, char** argv)
|
|||
|
||||
for (int s = 1; s <= 16; s++) {
|
||||
printf(".step%d\n", s);
|
||||
for (int i = 0; i < NUM_COLORS; i++) {
|
||||
for (int i = 0; i < config.numColors; i++) {
|
||||
int dr = ((((float)original[i].r)-(float)gray[i].r)/16.0)*s;
|
||||
int dg = ((((float)original[i].g)-(float)gray[i].g)/16.0)*s;
|
||||
int db = ((((float)original[i].b)-(float)gray[i].b)/16.0)*s;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</tileset>
|
||||
<layer name="foreground" width="100" height="8">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJy7y8DAwI4D3x2Vo7ucHRAzAbEYFnpUjv5yWjjkiZELB+JeMvSNyuGWoyQ+U4E4mwx9o3L488d5ID6JhYbJwfJAIJrcbmicDJa0NRzkiImzemgc7MYjNxmL3GBKd0NFjlpxXcmAmncGW7obKnKsjLjbYKNy9JcDAOkzS7w=
|
||||
eJxjZ2BgsGTEjtlH5eguZwekmYBYDAs9Kkd/OS0c8sTIhQNxJRn6RuVwy1ESn6zA/MXNOHjS1nCQA8XLbiDWBYarMSMqDZP7CNVzkgFVbjk0TgZL2hoOcsTE2WNofMkz4pb7TsU0MpLlqBXXdxlQ885gS3dDRW4wtvlGshwAqUxa2g==
|
||||
</data>
|
||||
</layer>
|
||||
<layer name="items" width="100" height="8">
|
||||
|
|
394
028.bs/game1.s
394
028.bs/game1.s
|
@ -4,22 +4,26 @@
|
|||
xdef IncrementScore
|
||||
|
||||
xdef copperList
|
||||
xdef mpanelCopperList
|
||||
xdef copperListBpl1Ptr
|
||||
xdef copperListBpl1Ptr2
|
||||
xdef copperListBpl2Ptr
|
||||
xdef copperListBpl2Ptr2
|
||||
xdef backgroundOnscreen
|
||||
xdef backgroundOffscreen
|
||||
|
||||
xdef copperListBpl1Ptr_MP
|
||||
xdef copperListBpl1Ptr2_MP
|
||||
xdef copperListBpl2Ptr_MP
|
||||
xdef copperListBpl2Ptr2_MP
|
||||
|
||||
xdef foregroundOnscreen
|
||||
xdef foregroundOffscreen
|
||||
xdef foregroundScrollX
|
||||
xdef backgroundScrollX
|
||||
xdef map
|
||||
xdef itemsMap
|
||||
xdef mapSize
|
||||
xdef moving
|
||||
xdef foregroundScrollPixels
|
||||
|
||||
TIMING_TEST equ 0
|
||||
TIMING_TEST_MAIN_LOOP equ 1
|
||||
|
||||
byteMap:
|
||||
dc.l Entry
|
||||
|
@ -37,11 +41,9 @@ Entry:
|
|||
|
||||
jsr StartMusic
|
||||
|
||||
move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6)
|
||||
|
||||
jsr ShowSplash
|
||||
|
||||
jsr InstallGreyPalette
|
||||
;; jsr InstallGreyPalette
|
||||
|
||||
;; d0 - fg bitplane pointer offset
|
||||
;; d1 - bg bitplane pointer offset
|
||||
|
@ -49,16 +51,22 @@ Entry:
|
|||
move.l #1,d1
|
||||
jsr SwitchBuffers
|
||||
|
||||
|
||||
move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6)
|
||||
move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_MASTER),DMACON(a6)
|
||||
|
||||
lea panelCopperListBpl1Ptr,a0
|
||||
lea panel,a1
|
||||
jsr PokePanelBitplanePointers
|
||||
|
||||
lea panelCopperListBpl1Ptr_MP,a0
|
||||
lea panel,a1
|
||||
jsr PokePanelBitplanePointers
|
||||
|
||||
|
||||
lea mpanelCopperListBpl1Ptr,a0
|
||||
lea mpanel,a1
|
||||
jsr PokePanelBitplanePointers
|
||||
jsr PokePanelBitplanePointers
|
||||
|
||||
bsr ShowMessagePanel
|
||||
jsr Init ; enable the playfield
|
||||
|
||||
jsr InstallSpriteColorPalette
|
||||
|
@ -69,10 +77,10 @@ Entry:
|
|||
|
||||
Reset:
|
||||
move.w #0,moving
|
||||
move.l #fade,fadePtr
|
||||
move.l #playareaFade,playareaFadePtr
|
||||
move.l #panelFade,panelFadePtr
|
||||
move.l #flagsFade,flagsFadePtr
|
||||
move.l #0,foregroundScrollX
|
||||
move.l #0,backgroundScrollX
|
||||
move.l #-1,frameCount
|
||||
bsr InitAnimPattern
|
||||
jsr ResetBigBangPattern
|
||||
|
@ -83,8 +91,8 @@ Reset:
|
|||
bsr RenderScore
|
||||
|
||||
MainLoop:
|
||||
;; MOVE.W #$0024,BPLCON2(a6)
|
||||
|
||||
MOVE.W #$0024,BPLCON2(a6)
|
||||
move.l #0,frameCount
|
||||
SetupBoardLoop:
|
||||
add.l #1,frameCount
|
||||
move.l frameCount,d6
|
||||
|
@ -101,6 +109,8 @@ SetupBoardLoop:
|
|||
.gotoGameLoop:
|
||||
add.l #1,d6
|
||||
jsr WaitVerticalBlank
|
||||
cmp.l #50,d6
|
||||
ble .gotoGameLoop
|
||||
jsr ProcessJoystick
|
||||
;; cmp.l #FOREGROUND_PLAYAREA_WIDTH_WORDS+50,d6
|
||||
;; bne .gotoGameLoop
|
||||
|
@ -108,12 +118,18 @@ SetupBoardLoop:
|
|||
beq .gotoGameLoop
|
||||
move.w #0,moving
|
||||
move.l #FOREGROUND_SCROLL_PIXELS,foregroundScrollPixels
|
||||
move.w #$ffff,mpanelWaitLinePtr
|
||||
;; move.w #$ffff,mpanelWaitLinePtr
|
||||
;; bsr ClearMPanel
|
||||
bsr HideMessagePanel
|
||||
|
||||
FadeInLoop:
|
||||
add.l #1,frameCount
|
||||
move.l frameCount,d6
|
||||
|
||||
move.l #0,d0
|
||||
.loop:
|
||||
jsr WaitVerticalBlank
|
||||
dbra d0,.loop
|
||||
bsr InstallNextGreyPalette
|
||||
cmp.l #FOREGROUND_PLAYAREA_WIDTH_WORDS+25,d6
|
||||
bne .c1
|
||||
|
@ -127,7 +143,17 @@ GameLoop:
|
|||
add.l #1,frameCount
|
||||
move.l frameCount,d6
|
||||
move.l #FOREGROUND_SCROLL_PIXELS,foregroundScrollPixels
|
||||
jsr WaitVerticalBlank
|
||||
jsr WaitVerticalBlank
|
||||
|
||||
if TIMING_TEST=1
|
||||
if TIMING_TEST_MAIN_LOOP=1
|
||||
move.l #4000,d0
|
||||
.looooo:
|
||||
dbra d0,.looooo
|
||||
move.w #$0f0,COLOR00(a6)
|
||||
endif
|
||||
endif
|
||||
|
||||
bsr HoriScrollPlayfield
|
||||
jsr SwitchBuffers
|
||||
move.l foregroundScrollX,d0
|
||||
|
@ -142,15 +168,14 @@ GameLoop:
|
|||
jsr CheckPlayerMiss
|
||||
bsr Update
|
||||
bsr RenderNextForegroundFrame
|
||||
bsr RenderNextBackgroundFrame
|
||||
jsr RenderNextBackgroundFrame
|
||||
|
||||
|
||||
if 0
|
||||
move.l #002,d0
|
||||
if TIMING_TEST=1
|
||||
move.l #0,d0
|
||||
.checkLoop:
|
||||
dbra d0,.checkLoop
|
||||
move.w #$f00,COLOR00(a6)
|
||||
move.w #$f00,COLOR01(a6)
|
||||
move.w #$f00,COLOR02(a6)
|
||||
endif
|
||||
|
||||
bra GameLoop
|
||||
|
@ -186,6 +211,20 @@ Update:
|
|||
.c1:
|
||||
.skipForegroundUpdates:
|
||||
rts
|
||||
|
||||
|
||||
ShowMessagePanel:
|
||||
lea mpanelCopperList,a0
|
||||
move.l a0,COP1LC(a6)
|
||||
move.w COPJMP1(a6),d0
|
||||
rts
|
||||
|
||||
|
||||
HideMessagePanel:
|
||||
lea copperList,a0
|
||||
move.l a0,COP1LC(a6)
|
||||
move.w COPJMP1(a6),d0
|
||||
rts
|
||||
|
||||
HoriScrollPlayfield:
|
||||
;; d0 - fg x position in pixels
|
||||
|
@ -209,7 +248,9 @@ HoriScrollPlayfield:
|
|||
lsl.w #4,d5
|
||||
or.w d5,d0
|
||||
move.w d0,copperListScrollPtr
|
||||
move.w d0,copperListScrollPtr2
|
||||
;; move.w d0,copperListScrollPtr2
|
||||
move.w d0,copperListScrollPtr_MP
|
||||
move.w d0,copperListScrollPtr2_MP
|
||||
rts
|
||||
|
||||
|
||||
|
@ -270,18 +311,6 @@ ResetBigBangPattern:
|
|||
dbra d1,.loop1
|
||||
rts
|
||||
|
||||
RenderNextBackgroundFrame:
|
||||
lea backgroundMap,a2
|
||||
move.l backgroundScrollX,d0
|
||||
lsr.l #BACKGROUND_SCROLL_TILE_INDEX_CONVERT,d0
|
||||
and.b #$fe,d0
|
||||
add.l d0,a2
|
||||
cmp.w #$FFFF,20(a2)
|
||||
bne .skip
|
||||
move.l #0,backgroundScrollX
|
||||
.skip:
|
||||
bsr RenderBackgroundTile
|
||||
rts
|
||||
|
||||
RenderNextForegroundFrame:
|
||||
lea map,a2
|
||||
|
@ -425,7 +454,7 @@ ClearForegroundTile3:
|
|||
.s1:
|
||||
lea foregroundTilemap,a1
|
||||
;; add.w #21520,a1 ; source tile
|
||||
add.w #$7080,a1
|
||||
add.w #$0,a1
|
||||
.s2:
|
||||
jsr BlitTile
|
||||
rts
|
||||
|
@ -458,29 +487,13 @@ ClearForegroundTile:
|
|||
.s1:
|
||||
lea foregroundTilemap,a1
|
||||
;; add.w #21520,a1 ; source tile
|
||||
add.w #$7080,a1
|
||||
add.w #$0,a1
|
||||
.s2:
|
||||
jsr BlitTile
|
||||
.s3:
|
||||
rts
|
||||
|
||||
|
||||
RenderBackgroundTile:
|
||||
;; a2 - map
|
||||
move.l backgroundScrollX,d0
|
||||
lsr.w #BACKGROUND_SCROLL_SHIFT_CONVERT,d0 ; convert to pixels
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
move.l backgroundOffscreen,a0
|
||||
add.l d0,a0
|
||||
lea backgroundTilemap,a1
|
||||
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
|
||||
add.w (a2),a1 ; source tile
|
||||
move.l backgroundScrollX,d2
|
||||
lsr.b #BACKGROUND_SCROLL_SHIFT_CONVERT,d2 ; convert to pixels
|
||||
andi.w #$f,d2 ; find the shift component
|
||||
jsr BlitTile
|
||||
rts
|
||||
|
||||
|
||||
Level3InterruptHandler:
|
||||
movem.l d0-a6,-(sp)
|
||||
|
@ -516,7 +529,9 @@ Message:
|
|||
move.w #128,d0
|
||||
move.w #11,d1
|
||||
jsr DrawMaskedText8
|
||||
move.w #MPANEL_COPPER_WAIT,mpanelWaitLinePtr
|
||||
;; move.w #MPANEL_COPPER_WAIT,mpanelWaitLinePtr
|
||||
;; jsr EnableMPanel
|
||||
bsr ShowMessagePanel
|
||||
rts
|
||||
|
||||
RenderScore:
|
||||
|
@ -612,14 +627,115 @@ copperListBpl2Ptr:
|
|||
dc.w DDFSTOP,(RASTER_X_START/2-SCREEN_RES)+(8*((SCREEN_WIDTH/16)-1))
|
||||
dc.w BPLCON0,(SCREEN_BIT_DEPTH*2<<12)|COLOR_ON|DBLPF
|
||||
|
||||
if 0
|
||||
|
||||
if TIMING_TEST=1
|
||||
dc.l $fffffffe
|
||||
endif
|
||||
|
||||
playAreaCopperPalettePtr:
|
||||
|
||||
playAreaCopperPalettePtr1:
|
||||
include "out/foreground-copper-list.s"
|
||||
include "out/background-copper-list.s"
|
||||
|
||||
dc.w $84d1
|
||||
dc.w $fffe
|
||||
flagsCopperPalettePtr1:
|
||||
include "out/foreground-copper-list.s"
|
||||
include "out/background-copper-list.s"
|
||||
dc.w $94d1
|
||||
dc.w $fffe
|
||||
|
||||
playAreaCopperPalettePtr2:
|
||||
include "out/foreground-copper-list.s"
|
||||
include "out/background-copper-list.s"
|
||||
|
||||
|
||||
dc.w $f4d1
|
||||
dc.w $fffe
|
||||
flagsCopperPalettePtr2:
|
||||
include "out/foreground-copper-list.s"
|
||||
include "out/background-copper-list.s"
|
||||
dc.w $ffdf
|
||||
dc.w $fffe
|
||||
dc.w $04d1
|
||||
dc.w $fffe
|
||||
|
||||
playAreaCopperPalettePtr3:
|
||||
include "out/foreground-copper-list.s"
|
||||
include "out/background-copper-list.s"
|
||||
|
||||
|
||||
dc.l $fffffffe
|
||||
|
||||
|
||||
mpanelCopperList:
|
||||
panelCopperListBpl1Ptr_MP:
|
||||
dc.w BPL1PTL,0
|
||||
dc.w BPL1PTH,0
|
||||
dc.w BPL2PTL,0
|
||||
dc.w BPL2PTH,0
|
||||
dc.w BPL3PTL,0
|
||||
dc.w BPL3PTH,0
|
||||
dc.w BPL4PTL,0
|
||||
dc.w BPL4PTH,0
|
||||
dc.w BPLCON1,0
|
||||
dc.w DDFSTRT,(RASTER_X_START/2-SCREEN_RES)
|
||||
dc.w DDFSTOP,(RASTER_X_START/2-SCREEN_RES)+(8*((SCREEN_WIDTH/16)-1))
|
||||
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
|
||||
include "out/panel-grey-copper.s"
|
||||
dc.w $5bd1,$fffe
|
||||
|
||||
|
||||
dc.w BPL1MOD,BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES-2
|
||||
dc.w BPL2MOD,BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES-2
|
||||
|
||||
dc.w BPLCON1
|
||||
copperListScrollPtr_MP:
|
||||
dc.w 0
|
||||
copperListBpl1Ptr_MP:
|
||||
;; this is where bitplanes are assigned to playfields
|
||||
;; http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0079.html
|
||||
;; 3 bitplanes per playfield, playfield1 gets bitplanes 1,3,5
|
||||
dc.w BPL1PTL,0
|
||||
dc.w BPL1PTH,0
|
||||
dc.w BPL3PTL,0
|
||||
dc.w BPL3PTH,0
|
||||
dc.w BPL5PTL,0
|
||||
dc.w BPL5PTH,0
|
||||
|
||||
copperListBpl2Ptr_MP:
|
||||
;; 3 bitplanes per playfield, playfield2 gets bitplanes 2,4,6
|
||||
dc.w BPL2PTL,0
|
||||
dc.w BPL2PTH,0
|
||||
dc.w BPL4PTL,0
|
||||
dc.w BPL4PTH,0
|
||||
dc.w BPL6PTL,0
|
||||
dc.w BPL6PTH,0
|
||||
|
||||
dc.w DDFSTRT,(RASTER_X_START/2-SCREEN_RES)-8 ; -8 for extra scrolling word
|
||||
dc.w DDFSTOP,(RASTER_X_START/2-SCREEN_RES)+(8*((SCREEN_WIDTH/16)-1))
|
||||
dc.w BPLCON0,(SCREEN_BIT_DEPTH*2<<12)|COLOR_ON|DBLPF
|
||||
|
||||
|
||||
playAreaCopperPalettePtr1_MP:
|
||||
include "out/foreground-grey-copper.s"
|
||||
include "out/background-grey-copper.s"
|
||||
|
||||
dc.w $84d1
|
||||
dc.w $fffe
|
||||
flagsCopperPalettePtr1_MP:
|
||||
include "out/foreground-grey-copper.s"
|
||||
include "out/background-grey-copper.s"
|
||||
dc.w $94d1
|
||||
dc.w $fffe
|
||||
|
||||
playAreaCopperPalettePtr2_MP:
|
||||
include "out/foreground-grey-copper.s"
|
||||
include "out/background-grey-copper.s"
|
||||
|
||||
|
||||
mpanelWaitLinePtr:
|
||||
dc.w MPANEL_COPPER_WAIT
|
||||
dc.w $fffe
|
||||
|
@ -639,7 +755,7 @@ mpanelCopperListBpl1Ptr:
|
|||
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
|
||||
mpanelCopperPalettePtr:
|
||||
mpanelCopperPalettePtr_MP:
|
||||
include "out/mpanel-copper-list.s"
|
||||
|
||||
dc.w $BAd1,$fffe
|
||||
|
@ -649,9 +765,9 @@ mpanelCopperPalettePtr:
|
|||
dc.w BPL2MOD,BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES-2
|
||||
|
||||
dc.w BPLCON1
|
||||
copperListScrollPtr2:
|
||||
copperListScrollPtr2_MP:
|
||||
dc.w 0
|
||||
copperListBpl1Ptr2:
|
||||
copperListBpl1Ptr2_MP:
|
||||
;; this is where bitplanes are assigned to playfields
|
||||
;; http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0079.html
|
||||
;; 3 bitplanes per playfield, playfield1 gets bitplanes 1,3,5
|
||||
|
@ -662,7 +778,7 @@ copperListBpl1Ptr2:
|
|||
dc.w BPL5PTL,0
|
||||
dc.w BPL5PTH,0
|
||||
|
||||
copperListBpl2Ptr2:
|
||||
copperListBpl2Ptr2_MP:
|
||||
;; 3 bitplanes per playfield, playfield2 gets bitplanes 2,4,6
|
||||
dc.w BPL2PTL,0
|
||||
dc.w BPL2PTH,0
|
||||
|
@ -675,11 +791,27 @@ copperListBpl2Ptr2:
|
|||
dc.w DDFSTOP,(RASTER_X_START/2-SCREEN_RES)+(8*((SCREEN_WIDTH/16)-1))
|
||||
dc.w BPLCON0,(SCREEN_BIT_DEPTH*2<<12)|COLOR_ON|DBLPF
|
||||
|
||||
playAreaCopperPalettePtr2:
|
||||
include "out/foreground-copper-list.s"
|
||||
include "out/background-copper-list.s"
|
||||
playAreaCopperPalettePtr3_MP:
|
||||
include "out/foreground-grey-copper.s"
|
||||
include "out/background-grey-copper.s"
|
||||
|
||||
dc.l $fffffffe
|
||||
|
||||
dc.w $f4d1
|
||||
dc.w $fffe
|
||||
flagsCopperPalettePtr2_MP:
|
||||
include "out/foreground-grey-copper.s"
|
||||
include "out/background-grey-copper.s"
|
||||
dc.w $ffdf
|
||||
dc.w $fffe
|
||||
dc.w $04d1
|
||||
dc.w $fffe
|
||||
|
||||
playAreaCopperPalettePtr4_MP:
|
||||
include "out/foreground-grey-copper.s"
|
||||
include "out/background-grey-copper.s"
|
||||
|
||||
|
||||
dc.l $fffffffe
|
||||
|
||||
InstallSpriteColorPalette:
|
||||
jsr InstallPlayerColorPalette
|
||||
|
@ -687,34 +819,42 @@ InstallSpriteColorPalette:
|
|||
rts
|
||||
|
||||
InstallColorPalette:
|
||||
lea playAreaCopperPalettePtr,a1
|
||||
lea playAreaCopperPalettePtr2,a2
|
||||
lea playAreaCopperPalettePtr1,a1
|
||||
lea playAreaCopperPalettePtr2,a2
|
||||
lea playAreaCopperPalettePtr3,a3
|
||||
lea playAreaPalette,a0
|
||||
add.l #2,a1
|
||||
add.l #2,a2
|
||||
add.l #2,a2
|
||||
add.l #2,a3
|
||||
move.l #15,d0
|
||||
.loop:
|
||||
move.w (a0),(a1)
|
||||
move.w (a0),(a2)
|
||||
move.w (a0),(a2)
|
||||
move.w (a0),(a3)
|
||||
add.l #2,a0
|
||||
add.l #4,a1
|
||||
add.l #4,a2
|
||||
add.l #4,a2
|
||||
add.l #4,a3
|
||||
dbra d0,.loop
|
||||
rts
|
||||
|
||||
InstallGreyPalette:
|
||||
lea playAreaCopperPalettePtr,a1
|
||||
lea playAreaCopperPalettePtr2,a2
|
||||
lea greyPalette,a0
|
||||
lea playAreaCopperPalettePtr1,a1
|
||||
lea playAreaCopperPalettePtr2,a2
|
||||
lea playAreaCopperPalettePtr3,a3
|
||||
lea playareaFade,a0
|
||||
add.l #2,a1
|
||||
add.l #2,a2
|
||||
add.l #2,a2
|
||||
add.l #2,a3
|
||||
move.l #15,d0
|
||||
.loop:
|
||||
move.w (a0),(a1)
|
||||
move.w (a0),(a2)
|
||||
move.w (a0),(a2)
|
||||
move.w (a0),(a3)
|
||||
add.l #2,a0
|
||||
add.l #4,a1
|
||||
add.l #4,a2
|
||||
add.l #4,a2
|
||||
add.l #4,a3
|
||||
dbra d0,.loop
|
||||
|
||||
InstallPanelGreyPalette:
|
||||
|
@ -727,31 +867,48 @@ InstallPanelGreyPalette:
|
|||
add.l #2,a0
|
||||
add.l #4,a1
|
||||
dbra d0,.loop
|
||||
|
||||
|
||||
InstallFlagsGreyPalette:
|
||||
lea flagsCopperPalettePtr1,a1
|
||||
lea flagsCopperPalettePtr2,a2
|
||||
lea flagsFade,a0
|
||||
add.l #2,a1
|
||||
add.l #2,a2
|
||||
move.l #15,d0
|
||||
.loop:
|
||||
move.w (a0),(a1)
|
||||
move.w (a0),(a2)
|
||||
add.l #2,a0
|
||||
add.l #4,a1
|
||||
add.l #4,a2
|
||||
dbra d0,.loop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
InstallNextGreyPalette:
|
||||
lea playAreaCopperPalettePtr,a1
|
||||
lea playAreaCopperPalettePtr2,a3
|
||||
move.l fadePtr,a0
|
||||
lea bottomFadeComplete,a2
|
||||
cmp.l a2,a0
|
||||
lea playAreaCopperPalettePtr1,a1
|
||||
lea playAreaCopperPalettePtr2,a2
|
||||
lea playAreaCopperPalettePtr3,a3
|
||||
move.l playareaFadePtr,a0
|
||||
lea playareaFadeComplete,a5
|
||||
cmp.l a5,a0
|
||||
bge .done
|
||||
add.l #2,a1
|
||||
add.l #2,a3
|
||||
add.l #2,a2
|
||||
add.l #2,a3
|
||||
move.l #15,d0
|
||||
.loop:
|
||||
move.w (a0),(a1)
|
||||
move.w (a0),(a3)
|
||||
move.w (a0),(a2)
|
||||
move.w (a0),(a3)
|
||||
add.l #2,a0
|
||||
add.l #4,a1
|
||||
add.l #4,a3
|
||||
add.l #4,a2
|
||||
add.l #4,a3
|
||||
dbra d0,.loop
|
||||
move.l frameCount,d0
|
||||
lsr.l #1,d0
|
||||
btst.l #0,d0
|
||||
beq .done
|
||||
add.l #16*2,fadePtr
|
||||
add.l #16*2,playareaFadePtr
|
||||
.done
|
||||
|
||||
InstallNextGreyPanelPalette:
|
||||
|
@ -767,12 +924,29 @@ InstallNextGreyPanelPalette:
|
|||
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
|
||||
|
||||
|
||||
InstallFlagGreyPalette:
|
||||
lea flagsCopperPalettePtr1,a1
|
||||
lea flagsCopperPalettePtr2,a2
|
||||
move.l flagsFadePtr,a0
|
||||
lea flagsFadeComplete,a5
|
||||
cmp.l a5,a0
|
||||
bge .done
|
||||
add.l #2,a1
|
||||
add.l #2,a2
|
||||
move.l #15,d0
|
||||
.loop:
|
||||
move.w (a0),(a1)
|
||||
move.w (a0),(a2)
|
||||
add.l #2,a0
|
||||
add.l #4,a1
|
||||
add.l #4,a2
|
||||
dbra d0,.loop
|
||||
add.l #16*2,flagsFadePtr
|
||||
.done
|
||||
rts
|
||||
|
||||
|
||||
|
@ -781,14 +955,8 @@ foregroundOnscreen:
|
|||
dc.l foregroundBitplanes1
|
||||
foregroundOffscreen:
|
||||
dc.l foregroundBitplanes2
|
||||
backgroundOnscreen:
|
||||
dc.l backgroundBitplanes1
|
||||
backgroundOffscreen:
|
||||
dc.l backgroundBitplanes1
|
||||
foregroundTilemap:
|
||||
incbin "out/foreground.bin"
|
||||
backgroundTilemap:
|
||||
incbin "out/background.bin"
|
||||
panel:
|
||||
incbin "out/panel.bin"
|
||||
mpanel:
|
||||
|
@ -802,15 +970,11 @@ itemsMap:
|
|||
mapSize:
|
||||
dc.l itemsMap-map
|
||||
|
||||
backgroundMap:
|
||||
include "out/background-map.s"
|
||||
dc.w $FFFF
|
||||
|
||||
foregroundScrollPixels:
|
||||
dc.l FOREGROUND_SCROLL_PIXELS
|
||||
foregroundScrollX:
|
||||
dc.l 0
|
||||
backgroundScrollX:
|
||||
dc.l 0
|
||||
frameCount:
|
||||
dc.l 0
|
||||
verticalBlankCount:
|
||||
|
@ -818,10 +982,12 @@ verticalBlankCount:
|
|||
moving:
|
||||
dc.w 0
|
||||
|
||||
fadePtr:
|
||||
dc.l fade
|
||||
playareaFadePtr:
|
||||
dc.l playareaFade
|
||||
panelFadePtr:
|
||||
dc.l panelFade
|
||||
flagsFadePtr:
|
||||
dc.l flagsFade
|
||||
|
||||
bigBangIndex:
|
||||
ds.l FOREGROUND_PLAYAREA_HEIGHT_WORDS*FOREGROUND_PLAYAREA_WIDTH_WORDS,0
|
||||
|
@ -905,9 +1071,11 @@ deAnimIndexPattern:
|
|||
dc.l 0
|
||||
dc.l $ffffffff
|
||||
|
||||
if 0
|
||||
greyPalette:
|
||||
include "out/foreground-grey-table.s"
|
||||
include "out/background-grey-table.s"
|
||||
include "out/background-grey-table.s"
|
||||
endif
|
||||
|
||||
panelGreyPalette:
|
||||
include "out/panel-grey-table.s"
|
||||
|
@ -916,21 +1084,21 @@ playAreaPalette:
|
|||
include "out/foreground-palette-table.s"
|
||||
include "out/background-palette-table.s"
|
||||
|
||||
fade:
|
||||
include "out/fade.s"
|
||||
playareaFade:
|
||||
include "out/playarea_fade.s"
|
||||
|
||||
flagsFade:
|
||||
include "out/flags_fade.s"
|
||||
|
||||
panelFade:
|
||||
include "out/panelFade.s"
|
||||
|
||||
|
||||
|
||||
section .bss
|
||||
foregroundBitplanes1:
|
||||
ds.b IMAGESIZE
|
||||
foregroundBitplanes2:
|
||||
ds.b IMAGESIZE
|
||||
|
||||
backgroundBitplanes1:
|
||||
ds.b IMAGESIZE*2
|
||||
|
||||
startUserstack:
|
||||
ds.b $1000 ; size of stack
|
||||
userstack:
|
||||
|
|
|
@ -14,11 +14,17 @@ SwitchBuffers:
|
|||
move.l a0,foregroundOnscreen
|
||||
move.l a0,a1
|
||||
lea copperListBpl1Ptr,a0
|
||||
bsr.s PokeBitplanePointers
|
||||
bsr.s PokeBitplanePointers
|
||||
|
||||
lea copperListBpl1Ptr_MP,a0
|
||||
bsr.s PokeBitplanePointers
|
||||
|
||||
add.l #BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH*(96-1),d0
|
||||
lea copperListBpl1Ptr2,a0
|
||||
bsr.s PokeBitplanePointers
|
||||
;; lea copperListBpl1Ptr2,a0
|
||||
;; bsr.s PokeBitplanePointers
|
||||
|
||||
lea copperListBpl1Ptr2_MP,a0
|
||||
bsr.s PokeBitplanePointers
|
||||
|
||||
|
||||
;; background is not double buffered
|
||||
|
@ -29,9 +35,15 @@ SwitchBuffers:
|
|||
lea copperListBpl2Ptr,a0
|
||||
bsr.s PokeBitplanePointers
|
||||
|
||||
lea copperListBpl2Ptr_MP,a0
|
||||
bsr.s PokeBitplanePointers
|
||||
|
||||
add.l #BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH*(96-48+16),d0
|
||||
lea copperListBpl2Ptr2,a0
|
||||
bsr.s PokeBitplanePointers
|
||||
;; lea copperListBpl2Ptr2,a0
|
||||
;; bsr.s PokeBitplanePointers
|
||||
|
||||
lea copperListBpl2Ptr2_MP,a0
|
||||
bsr.s PokeBitplanePointers
|
||||
|
||||
rts
|
||||
|
||||
|
|
|
@ -29,9 +29,7 @@ Init:
|
|||
|
||||
|
||||
;; install copper list, then enable dma and selected interrupts
|
||||
lea copperList,a0
|
||||
move.l a0,COP1LC(a6)
|
||||
move.w COPJMP1(a6),d0
|
||||
|
||||
;; move.w #(DMAF_SPRITE|DMAF_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6)
|
||||
move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6)
|
||||
;; move.w #PF2PRI,BPLCON2(a6)
|
||||
|
|
|
@ -143,7 +143,7 @@ UpdatePlayer:
|
|||
CalculateScore:
|
||||
move.w playerX,d0
|
||||
move.w playerMaxX,d1
|
||||
lsr.w #3,d0
|
||||
lsr.w #PLAYER_JUMP_SHIFT_CONVERT,d0
|
||||
cmp.w d1,d0
|
||||
ble .skip
|
||||
move.w d0,playerMaxX
|
||||
|
|
|
@ -41,6 +41,7 @@ ShowSplash:
|
|||
include "out/splash-palette.s"
|
||||
|
||||
move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6)
|
||||
move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6)
|
||||
.wait:
|
||||
jsr WaitVerticalBlank
|
||||
jsr ProcessJoystick
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
PROGRAM=./out/fade
|
||||
OBJS=out/fade.o out/file.o
|
||||
LIBS=
|
||||
EXTRA_CFLAGS=
|
||||
|
||||
include ../../shared/tools.mk
|
|
@ -0,0 +1,179 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "fade.h"
|
||||
#include "file.h"
|
||||
|
||||
typedef struct {
|
||||
int r, g, b, a;
|
||||
} rgba_t;
|
||||
|
||||
|
||||
config_t config = {
|
||||
.numColors = 16
|
||||
};
|
||||
|
||||
#define MAX_COLORS 32
|
||||
|
||||
rgba_t original[MAX_COLORS];
|
||||
rgba_t from[MAX_COLORS];
|
||||
rgba_t progress[MAX_COLORS];
|
||||
|
||||
void
|
||||
abort_(const char * s, ...)
|
||||
{
|
||||
fprintf(stderr, "%s: ", config.argv[0]);
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
vfprintf(stderr, s, args);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: --output <output>\n"\
|
||||
"options:\n"\
|
||||
" --to <file.pal>\n"\
|
||||
" --from-grey\n"\
|
||||
" --colors <num colors> (default: 16)\n"\
|
||||
" --verbose\n\n"\
|
||||
"Exactly one 'to' and 'from' option must be specified\n", config.argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
int c;
|
||||
config.argv = argv;
|
||||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
{"verbose", no_argument, &config.verbose, 1},
|
||||
{"from-grey", no_argument, &config.fromGrey, 1},
|
||||
{"from-black", no_argument, &config.fromBlack, 1},
|
||||
{"to", required_argument, 0, 't'},
|
||||
{"from", required_argument, 0, 'f'},
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{"colors", required_argument, 0, 'c'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
int option_index = 0;
|
||||
|
||||
c = getopt_long (argc, argv, "t:c:o:", long_options, &option_index);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 0:
|
||||
break;
|
||||
case 't':
|
||||
config.toFile = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
config.fromFile = optarg;
|
||||
break;
|
||||
case 'o':
|
||||
config.output = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
if (sscanf(optarg, "%d", &config.numColors) != 1) {
|
||||
abort_("invalid number of colors");
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (config.toFile == 0 || config.output == 0) {
|
||||
usage();
|
||||
abort();
|
||||
}
|
||||
|
||||
if (config.fromFile == 0 && (config.fromGrey == 0 && config.fromBlack == 0 && config.fromFile == 0)) {
|
||||
usage();
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
if (config.toFile) {
|
||||
FILE* fp = file_openRead(config.toFile);
|
||||
rgba_t* p = original;
|
||||
while (fscanf(fp, "%d %d %d %d", &p->r, &p->g, &p->b, &p->a) == 4) {
|
||||
p++;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
||||
if (config.fromFile) {
|
||||
FILE* fp = file_openRead(config.fromFile);
|
||||
rgba_t* p = from;
|
||||
while (fscanf(fp, "%d %d %d %d", &p->r, &p->g, &p->b, &p->a) == 4) {
|
||||
p++;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
||||
if (config.fromGrey) {
|
||||
rgba_t* g = from;
|
||||
rgba_t* p = original;
|
||||
|
||||
for (int i = 0; i < config.numColors; i++) {
|
||||
g->r = g->g = g->b = (p->r + p->g + p->b) / 3;
|
||||
g++;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
if (config.fromBlack) {
|
||||
rgba_t* g = from;
|
||||
for (int i = 0; i < config.numColors; i++) {
|
||||
g->r = g->g = g->b = 0;
|
||||
g++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int s = 0; s < 16; s++) {
|
||||
printf(".step%d\n", s);
|
||||
for (int i = 0; i < config.numColors; i++) {
|
||||
int dr = ((((float)original[i].r)-(float)from[i].r)/16.0)*s;
|
||||
int dg = ((((float)original[i].g)-(float)from[i].g)/16.0)*s;
|
||||
int db = ((((float)original[i].b)-(float)from[i].b)/16.0)*s;
|
||||
|
||||
#if 0
|
||||
printf("r:%d %d %d -> %d\n"
|
||||
"g:%d %d %d -> %d\n"
|
||||
"b:%d %d %d -> %d\n",
|
||||
original[i].r,from[i].r, dr, from[i].r+dr,
|
||||
original[i].g,from[i].g, dg, from[i].g+dg,
|
||||
original[i].b,from[i].b, db, from[i].b+db);
|
||||
#endif
|
||||
|
||||
printf("\tdc.w\t$%03x\n",
|
||||
((from[i].r+dr)>>4)<<8|
|
||||
((from[i].g+dg)>>4)<<4|
|
||||
((from[i].b+db)>>4));
|
||||
}
|
||||
}
|
||||
|
||||
printf("%sFadeComplete:\n", config.output);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef struct {
|
||||
int verbose;
|
||||
int numColors;
|
||||
int fromGrey;
|
||||
int fromBlack;
|
||||
char* toFile;
|
||||
char* fromFile;
|
||||
char* output;
|
||||
char** argv;
|
||||
} config_t;
|
||||
|
||||
|
||||
extern config_t config;
|
||||
|
||||
extern void
|
||||
abort_(const char * s, ...);
|
|
@ -0,0 +1,39 @@
|
|||
#include "fade.h"
|
||||
|
||||
FILE *
|
||||
file_openWrite(const char * s, ...)
|
||||
{
|
||||
char buffer[4096];
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
vsprintf(buffer, s, args);
|
||||
va_end(args);
|
||||
|
||||
if (config.verbose) {
|
||||
printf("Opening %s for writing\n", buffer);
|
||||
}
|
||||
|
||||
FILE* fp = fopen(buffer, "w+");
|
||||
if (!fp) {
|
||||
abort_("Failed to open %s for writing\n", buffer);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
FILE *
|
||||
file_openRead(const char * s, ...)
|
||||
{
|
||||
char buffer[4096];
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
vsprintf(buffer, s, args);
|
||||
va_end(args);
|
||||
|
||||
FILE* fp = fopen(buffer, "r");
|
||||
if (!fp) {
|
||||
abort_("Failed to open %s for reading\n", buffer);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
FILE *
|
||||
file_openWrite(const char * s, ...);
|
||||
|
||||
FILE *
|
||||
file_openRead(const char * s, ...);
|
|
@ -59,6 +59,7 @@ palette_output(imagecon_image_t* ic, char* outFilename)
|
|||
FILE* paletteGreyFP = 0;
|
||||
FILE* paletteTableFP = 0;
|
||||
FILE* paletteGreyTableFP = 0;
|
||||
FILE* paletteGreyCopperFP = 0;
|
||||
|
||||
if (config.outputCopperList) {
|
||||
fp = file_openWrite("%s-copper-list.s", outFilename);
|
||||
|
@ -72,6 +73,7 @@ palette_output(imagecon_image_t* ic, char* outFilename)
|
|||
if (config.outputPaletteGrey) {
|
||||
paletteGreyFP = file_openWrite("%s-grey.s", outFilename);
|
||||
paletteGreyTableFP = file_openWrite("%s-grey-table.s", outFilename);
|
||||
paletteGreyCopperFP = file_openWrite("%s-grey-copper.s", outFilename);
|
||||
fprintf(paletteGreyFP, "\tmovem.l d0-a6,-(sp)\n\tlea CUSTOM,a6\n");
|
||||
}
|
||||
|
||||
|
@ -118,6 +120,11 @@ palette_output(imagecon_image_t* ic, char* outFilename)
|
|||
if (fp) {
|
||||
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));
|
||||
}
|
||||
|
||||
if (paletteGreyCopperFP) {
|
||||
unsigned grey = ((RGB24TORGB12(ic->palette[i].r) + RGB24TORGB12(ic->palette[i].g) + RGB24TORGB12(ic->palette[i].b))/3);
|
||||
fprintf(paletteGreyCopperFP, "\tdc.w $%x,$%03x\n", 0x180+((i+config.paletteOffset)*2), grey << 8 | grey << 4 | grey);
|
||||
}
|
||||
}
|
||||
|
||||
if (paletteGreyTableFP) {
|
||||
|
|
Loading…
Reference in New Issue