Hi sdm here is a function for metatiles it comes from road fighter
Code:
///////////////////////////////////////////////////////////////////////////////
//Update Object Vertical Position,ObjectTile,Attributes,Horizontal Position
///////////////////////////////////////////////////////////////////////////////
//_TmpObjectMetaTileCounter = $9b
//_TmpObjectYposition = $9c
//_TmpObjectXposition = $9d
//_TmpXIndex = $ec
///////////////////////////////////////////////////////////////////////////////
Do_HandleUpdateObjectsCont:
and #$1F
asl
tay
lda ObjectDataStructureTabL,y
sta ObjectDataStructurePtr
lda ObjectDataStructureTabH,y
sta ObjectDataStructurePtr+1
ldy #0
lda (ObjectDataStructurePtr),y
sta _TmpObjectMetaTileCounter
lda #1
jsr Do_HandleAdjustObjectDataStructurePtrs
-:
ldx _TmpXIndex
ldy #0
lda (ObjectDataStructurePtr),y
clc
adc _TmpObjectYposition
sta $0200,x
inx
iny
lda (ObjectDataStructurePtr),y
sta $0200,x
inx
iny
lda (ObjectDataStructurePtr),y
sta $0200,x
inx
iny
lda (ObjectDataStructurePtr),Y
clc
adc _TmpObjectXposition
sta $0200,x
lda #4
jsr Do_HandleAdjustObjectDataStructurePtrs
inx
stx _TmpXIndex
dec _TmpObjectMetaTileCounter
bne -
rts
///////////////////////////////////////////////////////////////////////////////
Do_HandleAdjustObjectDataStructurePtrs:
clc
adc ObjectDataStructurePtr
sta ObjectDataStructurePtr
lda #$00
adc ObjectDataStructurePtr+1
sta ObjectDataStructurePtr+1
rts
///////////////////////////////////////////////////////////////////////////////
ObjectDataStructureTabL:
.byte <YellowCarStructure
ObjectDataStructureTabH:
.byte >YellowCarStructure
YellowCarStructure:
.byte 4 //Number of 8x8 sprites that creates the metatile used as counter
//Tile 0
.byte $00 //Vertical
.byte $6A //Tile
.byte $03 //Attrib
.byte $00 //Horizontal
//Tile 1
.byte $08 //Vertical
.byte $7A //Tile
.byte $03 //Attrib
.byte $00 //Horizontal
//Tile 2
.byte $00 //Vertical
.byte $6B //Tile
.byte $03 //Attrib
.byte $08 //Horizontal
//Tile 3
.byte $08 //Vertical
.byte $7B //Tile
.byte $03 //Attrib
.byte $08 //Horizontal