Foreground and background tmx maps

This commit is contained in:
alpine9000
2016-04-13 18:48:04 +10:00
parent e45baa57b0
commit 5a38595540
22 changed files with 284 additions and 1740 deletions
+20 -12
View File
@@ -11,11 +11,11 @@ NUM_COLORS=8
BOOTBLOCK_ASM=alpine_bootblock.s
OBJS=out/init.o out/utils.o out/image.o out/blit.o out/scroll.o
IMAGES=gigi_full.png
IMAGEDATA=$(addprefix out/, $(IMAGES:.png=.bin))
SIZEDIMAGEDATA=$(addprefix out/, $(IMAGES:.png=.sized.png))
#IMAGES=gigi_full.png
#IMAGEDATA=$(addprefix out/, $(IMAGES:.png=.bin))
#SIZEDIMAGEDATA=$(addprefix out/, $(IMAGES:.png=.sized.png))
TILEMAPS=2222.png background_tiles.png
TILEMAPS=foreground.png background.png
TILEMAPDATA=$(addprefix out/, $(TILEMAPS:.png=.bin))
VASM_EXTRA_ARGS=-DNUM_COLORS=$(NUM_COLORS)
@@ -26,19 +26,27 @@ 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/%.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/%.bin: assets/%.png
$(IMAGECON) --use-palette=assets/fg.pal --input $< $(IMAGECON_ARGS) --quantize --colors $(NUM_COLORS) --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-grey-palette --output-palette $(DITHER) --output-png --output out/$*
out/foreground.bin: assets/tilemap.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
out/main-map.s: map.tmx
../tools/mapgen/out/mapgen --depth=3 --input=map.tmx
mv main-map.s out
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/foreground-map.s: foreground.tmx
../tools/mapgen/out/mapgen --depth=3 --input=foreground.tmx
mv foreground-map.s out
out/background-map.s: background.tmx
../tools/mapgen/out/mapgen --depth=3 --input=background.tmx
mv background-map.s out
out/blit.o: constants.i macros.i
out/main.o: out/main-map.s $(TILEMAPDATA) $(IMAGEDATA) constants.i macros.i Makefile link.script.x palette.pal
out/main.o: out/background-map.s out/foreground-map.s $(TILEMAPDATA) $(IMAGEDATA) constants.i macros.i Makefile link.script.x assets/palette.pal
out/init.o: constants.i Makefile
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

+8
View File
@@ -0,0 +1,8 @@
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
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

-13
View File
@@ -1,13 +0,0 @@
017 204 255 255
000 153 238 255
000 000 000 255
255 187 017 255
238 221 119 255
153 017 034 255
221 136 153 255
255 204 221 255
221 085 000 255
221 136 051 255
136 238 255 255
255 153 119 255
170 068 085 255
+8
View File
@@ -0,0 +1,8 @@
000 000 000 255
082 000 015 255
133 000 026 255
210 063 006 255
211 116 039 255
253 174 017 255
233 216 100 255
016 132 233 255
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

+25
View File
@@ -0,0 +1,25 @@
000 000 000 255
082 000 015 255
133 000 026 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
232 174 100 255
252 114 100 255
171 049 027 255
004 050 117 255
020 155 173 255
030 236 255 255
252 115 009 255
255 255 011 255
255 255 255 255
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

+4 -4
View File
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="left-down" width="100" height="16" tilewidth="16" tileheight="16" nextobjectid="1">
<tileset firstgid="1" name="background_tiles" tilewidth="16" tileheight="16" tilecount="320" columns="20">
<image source="assets/background_tiles.png" width="320" height="256"/>
<tileset firstgid="1" name="tilemap" tilewidth="16" tileheight="16" tilecount="320" columns="20">
<image source="assets/tilemap.png" width="320" height="256"/>
</tileset>
<layer name="Tile Layer 1" width="100" height="16">
<layer name="background" width="100" height="16">
<data encoding="base64" compression="zlib">
eJzt1UcBgEAUA9FdwALFAsUCxb8qxkX+YQ5zeAaS3lobaKSJuo56poVW2nTcOx100qXjvumhlz4dd3ovtf9R2em91P5HZaf3UvsflZ3eS+1/VHZ6L7X/UdnpvdT+R2X/ApfLIQ==
eJztmMsNwjAMhrMAQxSVxwK8WYHHAiB1BNj/gC8VUhSc346bJhWH71I1ru3Yzt90zrkOpA08exBP5dqeveBdbh3HglgSK2IN2gvF5vsm8SHFT/Q7L+Jt7JPPzsDGgTgSJ+KcITbf534fY3Wh8ZPDul44GmIOvnshrsSNuGf0UZpvqZ+afIfqG5kfMTbEdsTcauLg8m0xB4aqkxJA8lNDHAilzI+pxIH0qVX/oRpuCvj6bQauy9mnVhoOja1GSunTVNDzuHG4luOwsmONpZZIsYX2uUTLcX1YgiYsmZr73OKf4c+XVJ0iOcM1Z2fj5LO1phrxc/JLp7TgXqX0NmJfM1ulOk+z52PUQ2iv0HtWrX0LpDWScp6Gep6rB8v8aRjy+1oNJblv09zNxerBz0nsvv4DB9VA2Q==
</data>
</layer>
</map>
+19 -6
View File
@@ -56,7 +56,7 @@ BlitFillColor:
BlitScroll:
_BlitScroll:
;; left scroll a screen wide region
;; a0 - dest bitplane pointer
;; a1 - source bitplane pointer
@@ -105,8 +105,8 @@ BlitTile:
;; a1 - source tile pointer
;; d2 - y tile index
WaitBlitter
movem.l d0-a6,-(sp)
WaitBlitter
movem.l d2/a0,-(sp)
move.w #0,BLTCON1(a6) ;
move.w #BC0F_SRCA|BC0F_DEST|$f0,BLTCON0(a6)
@@ -115,13 +115,12 @@ BlitTile:
mulu.w #BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH*16,d2
add.l d2,a0
;; add.l d2,a1
move.l a1,BLTAPTH(a6) ; source
move.l a0,BLTDPTH(a6) ; dest
move.w #$ffff,BLTAFWM(a6)
move.w #$ffff,BLTALWM(a6)
move.w #(16*SCREEN_BIT_DEPTH)<<6|(1),BLTSIZE(a6) ;rectangle size, starts blit
movem.l (sp)+,d0-a6
movem.l (sp)+,d2/a0
rts
@@ -142,7 +141,21 @@ BlueFill:
move.l #0,d0
move.l #256,d1
move.l #0,d2
jsr BlitFillColor
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
movem.l (sp)+,d0-a6
rts
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="left-down" width="100" height="16" tilewidth="16" tileheight="16" nextobjectid="1">
<tileset firstgid="1" name="tilemap" tilewidth="16" tileheight="16" tilecount="320" columns="20">
<image source="assets/tilemap.png" width="320" height="256"/>
</tileset>
<layer name="foreground" width="100" height="16">
<data encoding="base64" compression="zlib">
eJzt1rEJACAMRNHoDrqDI2Z7tRdBED3ILx4p/OUVupk5AACXNJovTRry4tbNG83bZt5CI9MobiRyo7iRyI3iRiI3ihuJ0ij++WgAADjTAfVp2oQ=
</data>
</layer>
</map>
+14 -9
View File
@@ -4,9 +4,10 @@
SwitchBuffers:
;; offscreen - bitplane address
;; d0 - fg bitplane pointer offset
;; d1 - bg bitplane pointer offset
movem.l d0/a0-a1,-(sp)
;; movem.l d0/a0-a1,-(sp)
move.l fg_xpos,d0
lsr.l #3,d0 ; bytes to scroll
move.l offscreen,a0
move.l onscreen,offscreen
move.l a0,onscreen
@@ -14,19 +15,23 @@ SwitchBuffers:
lea copperListBpl1Ptr,a0
jsr PokeBitplanePointers
lea bg_bitplanes,a1
move.l bg_xpos,d0
lsr.l #3,d0 ; bytes to scroll
move.l backgroundOffscreen,a0
move.l backgroundOnscreen,backgroundOffscreen
move.l a0,backgroundOnscreen
move.l a0,a1
lea copperListBpl2Ptr,a0
move.l d1,d0
jsr PokeBitplanePointers
movem.l (sp)+,d0/a0-a1
;; movem.l (sp)+,d0/a0-a1
rts
PokeBitplanePointers:
; d0 = frame offset in bytes
; a0 = BPLP copper list address
; a1 = bitplanes pointer
movem.l d0-a6,-(sp)
;; movem.l d0-a6,-(sp)
add.l d0,a1 ; bitplane offset
moveq #SCREEN_BIT_DEPTH-1,d0
.bitplaneloop:
@@ -37,7 +42,7 @@ PokeBitplanePointers:
lea BITPLANE_WIDTH_BYTES(a1),a1
addq #8,a0
dbra d0,.bitplaneloop
movem.l (sp)+,d0-a6
;; movem.l (sp)+,d0-a6
rts
File diff suppressed because it is too large Load Diff
-11
View File
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="left-down" width="100" height="16" tilewidth="16" tileheight="16" nextobjectid="1">
<tileset firstgid="1" name="tile" tilewidth="16" tileheight="16" tilecount="320" columns="20">
<image source="assets/2222.png" trans="000000" width="320" height="256"/>
</tileset>
<layer name="main" width="100" height="16">
<data encoding="base64" compression="zlib">
eJzt07ENgDAMBVFXZgfYAXZghuw/C1mAVGBfccVTit+cZGVExJAk6QMneCe3/WWftilf3s6d1lZxj2PRk807rc3/wWrzf7Da/B+stop7XIuebN5pbRX3uME7uU2SpC4PE4aIHQ==
</data>
</layer>
</map>
-17
View File
@@ -1,17 +0,0 @@
000 000 000 255
255 255 255 255
255 000 000 255
000 255 000 255
000 000 255 255
055 255 055 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 200 000 255
+53
View File
@@ -0,0 +1,53 @@
movem.l d0-a6,-(sp)
lea CUSTOM,a6
lea COLOR00(a6),a0
move.w #$000,(a0)
lea COLOR01(a6),a0
move.w #$500,(a0)
lea COLOR02(a6),a0
move.w #$801,(a0)
lea COLOR03(a6),a0
move.w #$d30,(a0)
lea COLOR04(a6),a0
move.w #$d72,(a0)
lea COLOR05(a6),a0
move.w #$fa1,(a0)
lea COLOR06(a6),a0
move.w #$ed6,(a0)
lea COLOR07(a6),a0
move.w #$18e,(a0)
lea COLOR08(a6),a0
move.w #$000,(a0)
lea COLOR09(a6),a0
move.w #$1cf,(a0)
lea COLOR10(a6),a0
move.w #$7ef,(a0)
lea COLOR11(a6),a0
move.w #$4ac,(a0)
lea COLOR12(a6),a0
move.w #$ddd,(a0)
lea COLOR13(a6),a0
move.w #$d02,(a0)
lea COLOR14(a6),a0
move.w #$999,(a0)
lea COLOR15(a6),a0
move.w #$000,(a0)
lea COLOR16(a6),a0
move.w #$ea6,(a0)
lea COLOR17(a6),a0
move.w #$f76,(a0)
lea COLOR18(a6),a0
move.w #$a31,(a0)
lea COLOR19(a6),a0
move.w #$037,(a0)
lea COLOR20(a6),a0
move.w #$19a,(a0)
lea COLOR21(a6),a0
move.w #$1ef,(a0)
lea COLOR22(a6),a0
move.w #$f70,(a0)
lea COLOR23(a6),a0
move.w #$ff0,(a0)
lea COLOR24(a6),a0
move.w #$fff,(a0)
movem.l (sp)+,d0-a6
Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

+17 -24
View File
@@ -5,38 +5,31 @@
HoriScrollPlayfield:
;; d0 - fg x position in pixels
;; d1 - bg x position in pixels
;; out:
;; d0 - fg bitplane pointer increment in bytes
;; d1 - bg bitplane pointer increment in bytes
movem.l d2-a6,-(sp)
move.l d0,d3
move.l d1,d0
;; movem.l d0-d6,-(sp)
move.l d1,d2
lsr.l #3,d0 ; bytes to scroll
move.l d0,d4 ; save bitplane pointer increment (bytes) for return value
and.l #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
move.l #$F,d0
sub.l d2,d0 ; bits to delay
move.l d0,d5 ; d5 == bg bits to delay
move.w d0,d3
move.w d1,d0
move.w d1,d2
lsr.w #3,d0 ; bytes to scroll
and.w #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
move.w #$F,d0
sub.w d2,d0 ; bits to delay
move.w d0,d5 ; d5 == bg bits to delay
move.l d3,d0
move.l d0,d2
lsr.l #3,d0 ; bytes to scroll
move.l d0,d3 ; save bitplane pointer increment (bytes) for return value
and.l #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
move.l #$F,d0
sub.l d2,d0 ; bits to delay
move.w d3,d0
move.w d0,d2
lsr.w #3,d0 ; bytes to scroll
and.w #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
move.w #$F,d0
sub.w d2,d0 ; bits to delay
lsl.w #4,d5
or.w d5,d0
move.w d0,BPLCON1(a6)
move.l d3,d0 ; restore d0 for return value
move.l d4,d1 ; restore d1 for return value
movem.l (sp)+,d2-a6
;; movem.l (sp)+,d0-d6
rts
-20
View File
@@ -1,20 +0,0 @@
idnt "test.c"
opt 0
opt NQLPSMRBT
section "CODE",code
public _blah
cnop 0,4
_blah
movem.l l2,-(a7)
moveq #0,d0
move.w (6+l4,a7),d0
move.l #320,-(a7)
move.l d0,-(a7)
public __lmods
jsr __lmods
addq.w #8,a7
l1
l2 reg
l4 equ 0
rts
; stacksize=8
Binary file not shown.
+105 -24
View File
@@ -6,7 +6,10 @@
xdef copperListBpl1Ptr
xdef copperListBpl2Ptr
xdef backgroundTiles
xdef bg_bitplanes
xdef backgroundOnscreen
xdef backgroundOffscreen
xdef fg_xpos
xdef bg_xpos
byteMap:
dc.l Entry
@@ -20,7 +23,10 @@ Entry:
move #$7fff,INTENA(a6) ; disable all interrupts
jsr InstallPalette
move.w #$09e,COLOR00(a6)
move.w #$09e,COLOR08(a6)
lea Level3InterruptHandler,a3
move.l a3,LVL3_INT_VECTOR
@@ -35,26 +41,37 @@ Entry:
jsr Init ; enable the playfield
Reset:
move.l #0,fg_xpos ; x pos (d1)
move.l #0,fg_shift ; shift counter (d2)
move.l #0,fg_tileIndex ; tile index (d3)
move.l #0,bg_xpos
move.l #0,bg_shift ; shift counter (d2)
move.l #0,bg_tileIndex ; tile index (d3)
jsr BlueFill
MainLoop:
add.l #1,fg_xpos
cmp.l #1,bg_delay
bne .s1
add.l #1,bg_xpos
.s1:
jsr WaitVerticalBlank
jsr WaitVerticalBlank
jsr WaitVerticalBlank
bsr RenderNextFrame
jsr UpdateShiftCounter
jsr UpdateBackgroundXpos
;; d0 - fg bitplane pointer offset
;; d1 - bg bitplane pointer offset
jsr SwitchBuffers ; takes bitplane pointer offset in d0
bra MainLoop
RenderNextFrame:
@@ -62,29 +79,57 @@ RenderNextFrame:
move.l bg_xpos,d1 ; bg x position in pixels
lea map,a2
add.l fg_tileIndex,a2
cmp.w #0,20(a2)
cmp.w #$FFFF,20(a2)
bne .skip
bra Reset
.skip:
jsr HoriScrollPlayfield ; returns fg bitplane pointer offset in d0
move.l onscreen,a0
bsr RenderTile
move.l offscreen,a0
bsr RenderTile
jsr HoriScrollPlayfield
bsr RenderForegroundTile
add.l #2,fg_tileIndex ; increment tile index
rts
RenderTile:
;; a0 - dest bitplane
;; d0 - x position in pixels
RenderForegroundTile:
;; a2 - map
;; movem.l a4,-(sp)
move.l fg_xpos,d0
lsr.w #3,d0 ; bytes to scroll
move.l onscreen,a0
add.l d0,a0
lea tilemap,a1
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
add.w (a2),a1 ; source tile
move.l fg_shift,d2
jsr BlitTile
rts
move.l offscreen,a0
add.l d0,a0
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
jsr BlitTile
;; movem.l (sp)+,a4
rts
RenderBackgroundTile:
;; a2 - map
;; movem.l a1,-(sp)
move.l bg_xpos,d0
lsr.w #3,d0 ; bytes to scroll
move.l backgroundOnscreen,a0
add.l d0,a0
lea backgroundTilemap,a1
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
add.w (a2),a1 ; source tile
move.l bg_shift,d2
jsr BlitTile
move.l backgroundOffscreen,a0
add.l d0,a0
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
jsr BlitTile
;; movem.l (sp)+,a4
rts
UpdateShiftCounter:
cmp.l #15,fg_shift
bne .s1
@@ -95,15 +140,40 @@ UpdateShiftCounter:
.s2:
rts
UpdateBackgroundShiftCounter:
cmp.l #15,bg_shift
bne .s1
move.l #0,bg_shift
bra .s2
.s1:
add.l #1,bg_shift
.s2:
rts
UpdateBackgroundXpos:
;; movem.l d0-a6,-(sp)
cmp.l #1,bg_delay
bne .s1
move.l #0,bg_delay
add.l #1,bg_xpos
lea backgroundMap,a2
add.l bg_tileIndex,a2
bsr RenderBackgroundTile
add.l #2,bg_tileIndex ; increment tile index
cmp.l #15,bg_shift
bne .s01
move.l #0,bg_shift
bra .s02
.s01:
add.l #1,bg_shift
.s02:
bra .s2
.s1:
add.l #1,bg_delay
.s2:
;; movem.l (sp)+,d0-a6
rts
Level3InterruptHandler:
@@ -167,7 +237,7 @@ copperListBplPtr:
endif
InstallPalette:
include "out/2222-palette.s"
include "palette.s"
rts
onscreen:
@@ -175,8 +245,16 @@ onscreen:
offscreen:
dc.l bitplanes2
backgroundOnscreen:
dc.l backgroundBitplanes1
backgroundOffscreen:
dc.l backgroundBitplanes2
tilemap:
incbin "out/2222.bin"
incbin "out/foreground.bin"
backgroundTilemap:
incbin "out/background.bin"
bitplanes1:
@@ -186,17 +264,20 @@ bitplanes2:
ds.b IMAGESIZE
ds.b BITPLANE_WIDTH_BYTES*20
bg_bitplanes:
incbin "out/gigi_full.bin"
backgroundBitplanes1:
ds.b IMAGESIZE
ds.b BITPLANE_WIDTH_BYTES*20
backgroundBitplanes2:
ds.b IMAGESIZE
ds.b BITPLANE_WIDTH_BYTES*20
map:
include "out/main-map.s"
dc.w 0
backgroundTiles:
include "out/background_tiles.bin"
include "out/foreground-map.s"
dc.w $FFFF
backgroundMap:
include "out/background-map.s"
fg_shift:
dc.l 0
fg_xpos: