Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .proc DecodeLevelMap
- BufPos = 0
- Param = 1
- Temp = 2
- Code = 3
- Width = 4
- Height = 5
- Pointer = 6 ;is also 7
- BlockId = 8
- lda LevelMapPointer+0 ; LevelMapPointer isn't in zeropage, so copy it there
- sta Pointer+0
- lda LevelMapPointer+1
- sta Pointer+1
- lda #1
- sta IsMappedLevel
- ldy #0
- Loop:
- lda (Pointer),y
- sta BufPos
- iny
- lda (Pointer),y
- bne :+
- lda BufPos ; reload the position, we need that
- unpack LevelEditStartX, LevelEditStartY
- rts
- : iny
- pha ; get param
- and #15
- sta Param
- tax ; just in case this needs to use the param as a block number
- lda LevelData_MetaList,x
- sta BlockId
- pla
- and #$f0 ; get function
- lsr
- lsr
- lsr
- sty Temp
- jsr Call
- ldy Temp
- jmp Loop
- Call:
- tax
- lsr
- sta Code
- lda ObjectTypeTable+1,x
- pha
- lda ObjectTypeTable+0,x
- pha
- lda Code
- ldx BufPos
- rts
- ObjectTypeTable:
- .raddr ZeroType
- .raddr HorzRepeat
- .raddr HorzRepeat
- .raddr HorzRepeat
- .raddr VertRepeat
- .raddr VertRepeat
- .raddr RectFill
- ZeroType:
- lda BlockId
- sta LevelBuf,x
- rts
- HorzRepeat:
- sub #1
- tay
- lda FillTypeTable,y
- ldy Param
- iny
- : sta LevelBuf,x
- inx
- dey
- bne :-
- rts
- VertRepeat:
- sub #4
- tay
- lda FillTypeTable,y
- ldy Param
- iny
- : sta LevelBuf,x
- pha
- txa
- axs #-16
- pla
- dey
- bne :-
- rts
- RectFill:
- inc Temp
- lda (Pointer),y
- unpack Width,Height
- inc Width
- inc Height
- HeightLoop:
- ldy Width
- lda BlockId
- stx BufPos
- WidthLoop:
- sta LevelBuf,x
- inx
- dey
- bne WidthLoop
- lax BufPos
- axs #-16
- dec Height
- bne HeightLoop
- rts
- FillTypeTable:
- .byt METATILE_SOLID, METATILE_EMPTY, METATILE_PLATFM
- .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement