diff --git a/demos/shell/App.Main.s b/demos/shell/App.Main.s index 1a6ff53..4f2cded 100644 --- a/demos/shell/App.Main.s +++ b/demos/shell/App.Main.s @@ -58,56 +58,14 @@ EvtLoop bne :1 brl Exit -tcounter dw 0 -tileIDs dw 168,170,172,174,168,170,172,174 - dw 169,171,173,175,169,171,173,175 - dw 208,210,212,214,208,210,212,214 - dw 209,211,213,215,209,211,213,215 - -;tileIDs dw 1,1,1,1,1,1,1,5 -; dw 2,2,2,2,2,2,2,6 -; dw 3,3,3,3,3,3,3,7 -; dw 4,4,4,4,4,4,4,8 - - :1 + jsl DoTimers + jsl Render + bra EvtLoop + cmp #'r' bne EvtLoop - jsl DoTimers - - inc tcounter - - lda tcounter - and #$0007 - asl - tay - lda tileIDs,y - pha - lda tileIDs+16,y - pha - lda tileIDs+32,y - pha - ldx tileIDs+48,y - inx - ldy #3 - jsl CopyTileToDyn - - plx - inx - ldy #2 - jsl CopyTileToDyn - - plx - inx - ldy #1 - jsl CopyTileToDyn - - plx - inx - ldy #0 - jsl CopyTileToDyn - jsl Render brl EvtLoop @@ -514,67 +472,3 @@ qtRec adrl $0000 PUT gen/App.TileMapBG0.s PUT gen/App.TileMapBG1.s PUT gen/App.TileSetAnim.s - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demos/shell/gen/App.TileSetAnim.s b/demos/shell/gen/App.TileSetAnim.s index eaf5459..b03e14f 100644 --- a/demos/shell/gen/App.TileSetAnim.s +++ b/demos/shell/gen/App.TileSetAnim.s @@ -1,65 +1,52 @@ -TileAnimInit ENT +TileAnimInit ENT - ldx #168 - ldy #0 - jsl CopyTileToDyn - ldx #169 - ldy #1 - jsl CopyTileToDyn - ldx #208 - ldy #2 - jsl CopyTileToDyn - ldx #209 - ldy #3 - jsl CopyTileToDyn - - lda #TileAnim_168 ; low word of handler - ldx #^TileAnim_168 ; high word of handler - ldy #15 ; number of ticks - jsl StartScript - - lda #TileAnim_169 - ldx #^TileAnim_169 - ldy #15 - clc - jsl StartScript - - lda #TileAnim_208 - ldx #^TileAnim_208 - ldy #15 - clc - jsl StartScript - - lda #TileAnim_209 - ldx #^TileAnim_209 - ldy #15 - clc - jsl StartScript - rts + ldx #169 + ldy #0 + jsl CopyTileToDyn + ldx #170 + ldy #1 + jsl CopyTileToDyn + ldx #209 + ldy #2 + jsl CopyTileToDyn + ldx #210 + ldy #3 + jsl CopyTileToDyn + lda #TileAnim_168 + ldx #^TileAnim_168 + ldy #15 + jsl StartScript + lda #TileAnim_169 + ldx #^TileAnim_169 + ldy #15 + jsl StartScript + lda #TileAnim_208 + ldx #^TileAnim_208 + ldy #15 + jsl StartScript + lda #TileAnim_209 + ldx #^TileAnim_209 + ldy #15 + jsl StartScript + rts TileAnim_168 - dw $8006,169,0,0 - dw $8006,171,0,0 - dw $8006,173,0,0 - dw $cd06,175,0,0 + dw $8006,169,0,0 + dw $8006,171,0,0 + dw $8006,173,0,0 + dw $cd06,175,0,0 TileAnim_169 - dw $8006,170,1,0 - dw $8006,172,1,0 - dw $8006,174,1,0 - dw $cd06,176,1,0 + dw $8006,170,1,0 + dw $8006,172,1,0 + dw $8006,174,1,0 + dw $cd06,176,1,0 TileAnim_208 - dw $8006,209,2,0 - dw $8006,211,2,0 - dw $8006,213,2,0 - dw $cd06,215,2,0 + dw $8006,209,2,0 + dw $8006,211,2,0 + dw $8006,213,2,0 + dw $cd06,215,2,0 TileAnim_209 - dw $8006,210,3,0 - dw $8006,212,3,0 - dw $8006,214,3,0 - dw $cd06,216,3,0 - - - - - - + dw $8006,210,3,0 + dw $8006,212,3,0 + dw $8006,214,3,0 + dw $cd06,216,3,0 \ No newline at end of file diff --git a/tools/png2iigs.js b/tools/png2iigs.js index 0be657c..07d0c44 100644 --- a/tools/png2iigs.js +++ b/tools/png2iigs.js @@ -286,6 +286,9 @@ function buildTiles(buff, width, transparentIndex = -1) { return tiles; } const tile = buildTile(buff, width, x, y, transparentIndex); + + // Tiled TileIDs start at 1 + tile.tileId = count + 1; tiles.push(tile); } } diff --git a/tools/tiled2iigs.js b/tools/tiled2iigs.js index db36ba5..70f7ead 100644 --- a/tools/tiled2iigs.js +++ b/tools/tiled2iigs.js @@ -174,7 +174,7 @@ function findAnimatedTiles(tileset) { const millis = parseInt(f.duration, 10); const ticksPerMillis = 60. / 1000.; return { - tileId: parseInt(f.tileid, 10), + tileId: parseInt(f.tileid, 10) + 1, // The IDs in the XML file appear to be zero-based. The JSON files appear to be one-based ticks: Math.round(millis * ticksPerMillis), millis }; @@ -370,6 +370,8 @@ function emitLayerData(sb, layer, tileset) { /** * Map the bit flags used in Tiled to compatible values in GTE + * + * tileID is a value from the exported TileD data. It starts at index 1. */ function convertTileID(tileId, tileset) { const GTE_MASK_BIT = 0x1000; @@ -390,11 +392,11 @@ function convertTileID(tileId, tileset) { // Mask out the flip bits const tileIndex = tileId & 0x1FFFFFFF; - if (tileIndex > 511) { + if (tileIndex >= 512) { throw new Error('A maximum of 511 tiles are supported'); } - // The tileId start at one, but the tile set starts at zero. It's ok when we export, + // The tileId starts at one, but the tile set starts at zero. It's ok when we export, // because a special zero tile is inserted, but we have to manually adjust here const mask_bit = !tileset[tileIndex - 1].isSolid;