Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .proc PostProcessLevel
- Pointer = 0
- LeftPointer = 2
- RightPointer = 4
- RowCount = 6
- BoundaryLeft = 7
- BoundaryRight = 8
- Temp1 = 9
- Temp2 = 10
- ; initialize pointers
- lda #<$6000
- sta Pointer+0
- lda #>$6000
- sta Pointer+1
- lda #<$6010
- sta RightPointer+0
- lda #>$6010
- sta RightPointer+1
- lda #<$5ff0 ; open bus, (LeftPointer) will return a 2
- sta LeftPointer+0
- lda #>$5ff0
- sta LeftPointer+1
- ScreenLoop:
- ldy #0
- ; load boundaries
- lda Pointer+1
- and #$0f
- tax
- lda ScreenFlags+0,x
- and #SCREEN_BOUNDARY
- sta BoundaryLeft
- lda ScreenFlags+1,x
- and #SCREEN_BOUNDARY
- sta BoundaryRight
- RowLoopStart:
- lda #15
- sta RowCount
- RowLoop:
- lda (Pointer),y
- tax
- lda MetatileFlags,x
- and #M_POST_PROCESS
- beq NoPostProcess
- tya
- pha
- txa ; copy block type back to A
- ldx #0
- : cmp ListOfProcessTiles,x
- beq :+
- inx
- bne :-
- : jsr Launch
- pla
- tay
- NoPostProcess:
- iny
- dec RowCount
- bne RowLoop
- iny ; next column
- bne RowLoopStart ; unless we're at the rightmost column again
- ; next screen, update pointers
- lda Pointer+1 ; are we at the last screen in the level?
- and #$0f
- cmp LevelSize
- bcs Exit
- inc Pointer+1
- inc RightPointer+1
- lda Pointer
- sub #16
- sta LeftPointer
- lda Pointer+1
- sbc #0
- sta LeftPointer+1
- jmp ScreenLoop
- Exit:
- rts
- Launch:
- lda ListOfProcessAddrHi,x
- pha
- lda ListOfProcessAddrLo,x
- pha
- rts
- ListOfProcessTiles:
- .byt Metatiles::GROUND_MIDDLE_M
- .byt Metatiles::ROCK_MID_M
- .byt Metatiles::WATER_MAIN
- .byt Metatiles::SOLID_LEDGE_M
- .byt Metatiles::FALLTHROUGH_LEDGE_M
- .byt Metatiles::DOOR_TOP
- .byt Metatiles::EXIT_DOOR_TOP
- .byt Metatiles::CLOUD_M
- ListOfProcessAddrLo:
- .byt <(ProcessGround-1)
- .byt <(ProcessRock-1)
- .byt <(ProcessWater-1)
- .byt <(ProcessSolidLedge-1)
- .byt <(ProcessFallthroughLedge-1)
- .byt <(ProcessDoorTop-1)
- .byt <(ProcessDoorTop-1)
- .byt <(ProcessCloud-1)
- ListOfProcessAddrHi:
- .byt >(ProcessGround-1)
- .byt >(ProcessRock-1)
- .byt >(ProcessWater-1)
- .byt >(ProcessSolidLedge-1)
- .byt >(ProcessFallthroughLedge-1)
- .byt >(ProcessDoorTop-1)
- .byt >(ProcessDoorTop-1)
- .byt >(ProcessCloud-1)
- ProcessCloud:
- lda (LeftPointer),y
- cmp #Metatiles::CLOUD_L
- beq :+
- cmp #Metatiles::CLOUD_M
- beq :+
- lda #Metatiles::CLOUD_L
- sta (Pointer),y
- :
- lda (RightPointer),y
- cmp #Metatiles::CLOUD_M
- beq :+
- lda #Metatiles::CLOUD_R
- sta (Pointer),y
- :
- rts
- ProcessGround:
- lda #0
- sta Temp1
- dey
- lda (Pointer),y
- jsr IsGround
- iny
- lda (LeftPointer),y
- jsr IsGround
- lda (RightPointer),y
- jsr IsGround
- iny
- lda (Pointer),y
- jsr IsGround
- dey
- ldx Temp1
- cpx #15
- beq ExtraGround
- lda GroundLUT,x
- sta (Pointer),y
- rts
- ExtraGround:
- lda #0
- sta Temp1
- dey
- lda (LeftPointer),y
- jsr IsGround
- lda (RightPointer),y
- jsr IsGround
- iny
- ldx Temp1
- lda ExtraGroundTable,x
- sta (Pointer),y
- rts
- ExtraGroundTable:
- .byt Metatiles::GROUND_INNER_BOTH
- .byt Metatiles::GROUND_INNER_LEFT
- .byt Metatiles::GROUND_INNER_RIGHT
- .byt Metatiles::GROUND_MIDDLE_M
- ProcessRock:
- lda #0
- sta Temp1
- dey
- lda (Pointer),y
- jsr IsRock
- iny
- lda (LeftPointer),y
- jsr IsRock
- lda (RightPointer),y
- jsr IsRock
- iny
- lda (Pointer),y
- jsr IsRock
- dey
- ldx Temp1
- lda RockLUT,x
- sta (Pointer),y
- rts
- GroundLUT: ; ULRD
- .byt Metatiles::GROUND_NARROW_TOP ; 0000
- .byt Metatiles::GROUND_NARROW_TOP ; 0001
- .byt Metatiles::GROUND_TOP_L ; 0010
- .byt Metatiles::GROUND_TOP_L ; 0011
- .byt Metatiles::GROUND_TOP_R ; 0100
- .byt Metatiles::GROUND_TOP_R ; 0101
- .byt Metatiles::GROUND_TOP_M ; 0110
- .byt Metatiles::GROUND_TOP_M ; 0111
- .byt Metatiles::GROUND_NARROW_SIDES ; 1000
- .byt Metatiles::GROUND_NARROW_SIDES ; 1001
- .byt Metatiles::GROUND_MIDDLE_L ; 1010
- .byt Metatiles::GROUND_MIDDLE_L ; 1011
- .byt Metatiles::GROUND_MIDDLE_R ; 1100
- .byt Metatiles::GROUND_MIDDLE_R ; 1101
- .byt Metatiles::GROUND_MIDDLE_M ; 1110
- .byt Metatiles::GROUND_MIDDLE_M ; 1111
- RockLUT: ; ULRD
- .byt Metatiles::ROCK_MID_M ; 0000 ?
- .byt Metatiles::ROCK_MID_M ; 0001 ?
- .byt Metatiles::ROCK_MID_M ; 0010 ?
- .byt Metatiles::ROCK_TOP_L ; 0011
- .byt Metatiles::ROCK_MID_M ; 0100 ?
- .byt Metatiles::ROCK_TOP_R ; 0101
- .byt Metatiles::ROCK_MID_M ; 0110 ?
- .byt Metatiles::ROCK_TOP_M ; 0111
- .byt Metatiles::ROCK_MID_M ; 1000 ?
- .byt Metatiles::ROCK_MID_M ; 1001 ?
- .byt Metatiles::ROCK_BOT_L ; 1010
- .byt Metatiles::ROCK_MID_L ; 1011
- .byt Metatiles::ROCK_BOT_R ; 1100
- .byt Metatiles::ROCK_MID_R ; 1101
- .byt Metatiles::ROCK_BOT_M ; 1110
- .byt Metatiles::ROCK_MID_M ; 1111
- IsFallthroughLedge:
- cmp #Metatiles::FALLTHROUGH_LEDGE_L
- bcc NoItIsnt
- cmp #Metatiles::FALLTHROUGH_LEDGE_S+1
- bcs NoItIsnt
- sec
- rol Temp1
- rts
- IsSolidLedge:
- cmp #Metatiles::SOLID_LEDGE_L
- bcc NoItIsnt
- cmp #Metatiles::SOLID_LEDGE_S+1
- bcs NoItIsnt
- sec
- rol Temp1
- rts
- IsGround:
- cmp #Metatiles::GROUND_TOP_L
- bcc NoItIsnt
- cmp #Metatiles::GROUND_CLIMB_R+1
- bcs NoItIsnt
- sec
- rol Temp1
- rts
- NoItIsnt:
- clc
- rol Temp1
- rts
- IsRock:
- cmp #Metatiles::ROCK_TOP_L
- bcc NoItIsnt
- cmp #Metatiles::ROCK_BOT_R+1
- bcs NoItIsnt
- sec
- rol Temp1
- rts
- ProcessWater:
- dey
- lda (Pointer),y
- cmp #Metatiles::WATER_MAIN
- beq TopIsWater
- cmp #Metatiles::WATER_TOP
- beq TopIsWater
- cmp #Metatiles::WATER_BELOW_SOMETHING
- beq TopIsWater
- ; not water, check if it's solid or not
- tax
- lda MetatileFlags,x
- iny
- and #M_SOLID_ALL
- bne :+
- lda #Metatiles::WATER_TOP
- sta (Pointer),y
- rts
- :
- lda #Metatiles::WATER_BELOW_SOMETHING
- sta (Pointer),y
- TopIsWater:
- rts
- ProcessSolidLedge:
- lda #0
- sta Temp1
- lda (LeftPointer),y
- jsr IsSolidLedge
- lda (RightPointer),y
- jsr IsSolidLedge
- ldx Temp1
- lda SolidLedges,x
- sta (Pointer),y
- rts
- SolidLedges:
- .byt Metatiles::SOLID_LEDGE_S
- .byt Metatiles::SOLID_LEDGE_L
- .byt Metatiles::SOLID_LEDGE_R
- .byt Metatiles::SOLID_LEDGE_M
- ProcessFallthroughLedge:
- lda #0
- sta Temp1
- lda (LeftPointer),y
- jsr IsFallthroughLedge
- lda (RightPointer),y
- jsr IsFallthroughLedge
- ldx Temp1
- lda FallLedges,x
- sta (Pointer),y
- rts
- FallLedges:
- .byt Metatiles::FALLTHROUGH_LEDGE_S
- .byt Metatiles::FALLTHROUGH_LEDGE_L
- .byt Metatiles::FALLTHROUGH_LEDGE_R
- .byt Metatiles::FALLTHROUGH_LEDGE_M
- ProcessDoorTop:
- iny
- lda #Metatiles::DOOR_BOTTOM
- sta (Pointer),y
- rts
- .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement