mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2025-02-21 12:29:07 +00:00
Compensate for the fact the Tiled animation IDs are one off of the map TileIDs
This commit is contained in:
parent
d5421afdbd
commit
59f9e61559
@ -58,56 +58,14 @@ EvtLoop
|
|||||||
bne :1
|
bne :1
|
||||||
brl Exit
|
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
|
:1
|
||||||
|
jsl DoTimers
|
||||||
|
jsl Render
|
||||||
|
bra EvtLoop
|
||||||
|
|
||||||
cmp #'r'
|
cmp #'r'
|
||||||
bne EvtLoop
|
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
|
jsl Render
|
||||||
brl EvtLoop
|
brl EvtLoop
|
||||||
|
|
||||||
@ -514,67 +472,3 @@ qtRec adrl $0000
|
|||||||
PUT gen/App.TileMapBG0.s
|
PUT gen/App.TileMapBG0.s
|
||||||
PUT gen/App.TileMapBG1.s
|
PUT gen/App.TileMapBG1.s
|
||||||
PUT gen/App.TileSetAnim.s
|
PUT gen/App.TileSetAnim.s
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,65 +1,52 @@
|
|||||||
|
|
||||||
TileAnimInit ENT
|
TileAnimInit ENT
|
||||||
|
|
||||||
ldx #168
|
ldx #169
|
||||||
ldy #0
|
ldy #0
|
||||||
jsl CopyTileToDyn
|
jsl CopyTileToDyn
|
||||||
ldx #169
|
ldx #170
|
||||||
ldy #1
|
ldy #1
|
||||||
jsl CopyTileToDyn
|
jsl CopyTileToDyn
|
||||||
ldx #208
|
ldx #209
|
||||||
ldy #2
|
ldy #2
|
||||||
jsl CopyTileToDyn
|
jsl CopyTileToDyn
|
||||||
ldx #209
|
ldx #210
|
||||||
ldy #3
|
ldy #3
|
||||||
jsl CopyTileToDyn
|
jsl CopyTileToDyn
|
||||||
|
lda #TileAnim_168
|
||||||
lda #TileAnim_168 ; low word of handler
|
ldx #^TileAnim_168
|
||||||
ldx #^TileAnim_168 ; high word of handler
|
ldy #15
|
||||||
ldy #15 ; number of ticks
|
jsl StartScript
|
||||||
jsl StartScript
|
lda #TileAnim_169
|
||||||
|
ldx #^TileAnim_169
|
||||||
lda #TileAnim_169
|
ldy #15
|
||||||
ldx #^TileAnim_169
|
jsl StartScript
|
||||||
ldy #15
|
lda #TileAnim_208
|
||||||
clc
|
ldx #^TileAnim_208
|
||||||
jsl StartScript
|
ldy #15
|
||||||
|
jsl StartScript
|
||||||
lda #TileAnim_208
|
lda #TileAnim_209
|
||||||
ldx #^TileAnim_208
|
ldx #^TileAnim_209
|
||||||
ldy #15
|
ldy #15
|
||||||
clc
|
jsl StartScript
|
||||||
jsl StartScript
|
rts
|
||||||
|
|
||||||
lda #TileAnim_209
|
|
||||||
ldx #^TileAnim_209
|
|
||||||
ldy #15
|
|
||||||
clc
|
|
||||||
jsl StartScript
|
|
||||||
rts
|
|
||||||
TileAnim_168
|
TileAnim_168
|
||||||
dw $8006,169,0,0
|
dw $8006,169,0,0
|
||||||
dw $8006,171,0,0
|
dw $8006,171,0,0
|
||||||
dw $8006,173,0,0
|
dw $8006,173,0,0
|
||||||
dw $cd06,175,0,0
|
dw $cd06,175,0,0
|
||||||
TileAnim_169
|
TileAnim_169
|
||||||
dw $8006,170,1,0
|
dw $8006,170,1,0
|
||||||
dw $8006,172,1,0
|
dw $8006,172,1,0
|
||||||
dw $8006,174,1,0
|
dw $8006,174,1,0
|
||||||
dw $cd06,176,1,0
|
dw $cd06,176,1,0
|
||||||
TileAnim_208
|
TileAnim_208
|
||||||
dw $8006,209,2,0
|
dw $8006,209,2,0
|
||||||
dw $8006,211,2,0
|
dw $8006,211,2,0
|
||||||
dw $8006,213,2,0
|
dw $8006,213,2,0
|
||||||
dw $cd06,215,2,0
|
dw $cd06,215,2,0
|
||||||
TileAnim_209
|
TileAnim_209
|
||||||
dw $8006,210,3,0
|
dw $8006,210,3,0
|
||||||
dw $8006,212,3,0
|
dw $8006,212,3,0
|
||||||
dw $8006,214,3,0
|
dw $8006,214,3,0
|
||||||
dw $cd06,216,3,0
|
dw $cd06,216,3,0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -286,6 +286,9 @@ function buildTiles(buff, width, transparentIndex = -1) {
|
|||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
const tile = buildTile(buff, width, x, y, transparentIndex);
|
const tile = buildTile(buff, width, x, y, transparentIndex);
|
||||||
|
|
||||||
|
// Tiled TileIDs start at 1
|
||||||
|
tile.tileId = count + 1;
|
||||||
tiles.push(tile);
|
tiles.push(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ function findAnimatedTiles(tileset) {
|
|||||||
const millis = parseInt(f.duration, 10);
|
const millis = parseInt(f.duration, 10);
|
||||||
const ticksPerMillis = 60. / 1000.;
|
const ticksPerMillis = 60. / 1000.;
|
||||||
return {
|
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),
|
ticks: Math.round(millis * ticksPerMillis),
|
||||||
millis
|
millis
|
||||||
};
|
};
|
||||||
@ -370,6 +370,8 @@ function emitLayerData(sb, layer, tileset) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Map the bit flags used in Tiled to compatible values in GTE
|
* 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) {
|
function convertTileID(tileId, tileset) {
|
||||||
const GTE_MASK_BIT = 0x1000;
|
const GTE_MASK_BIT = 0x1000;
|
||||||
@ -390,11 +392,11 @@ function convertTileID(tileId, tileset) {
|
|||||||
|
|
||||||
// Mask out the flip bits
|
// Mask out the flip bits
|
||||||
const tileIndex = tileId & 0x1FFFFFFF;
|
const tileIndex = tileId & 0x1FFFFFFF;
|
||||||
if (tileIndex > 511) {
|
if (tileIndex >= 512) {
|
||||||
throw new Error('A maximum of 511 tiles are supported');
|
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
|
// because a special zero tile is inserted, but we have to manually adjust here
|
||||||
const mask_bit = !tileset[tileIndex - 1].isSolid;
|
const mask_bit = !tileset[tileIndex - 1].isSolid;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user