Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;PlaceBorder
- ;
- ;Parameters:
- ; Temp+0 - X Position
- ; Temp+2 - Y Position
- ; Temp+4 - Inside Width
- ; Temp+6 - Inside Height
- ;
- ;Used Temporary Memory:
- ; Temp+8 - Temporary counter
- ; Temp+10 - Top-left tile offset (for placing the sides)
- ; Temp+12 - Top-right tile offset (for placing the sides)
- PlaceBorder:
- rep #$20 ;Set A to 16-bit
- ;Calculate the offset for the top border tiles:
- lda Temp+2 ;Load the Y position into A
- asl
- asl
- asl
- asl
- asl ;Multiply it by 32
- clc ;Clear the carry flag
- adc Temp+0 ;Add the X position to it
- asl ;Multiply it by 2
- tax ;Transfer A to X
- sta Temp+10 ;Store A for later
- lda Temp+4 ;Load the inside width into A
- clc ;Clear the carry flag
- adc #1 ;Add one to it
- asl ;Multiply it by 2
- clc ;Clear the carry flag
- adc Temp+10 ;Add the stored left offset to it, to get the right offset
- sta Temp+12 ;Store the right offset into memory
- ;Calculate the offset for the bottom border tiles:
- lda Temp+2 ;Load the Y position into A
- clc ;Clear the carry flag
- adc Temp+6 ;Add the inside height
- clc ;Clear the carry flag
- adc #1 ;Add 1 more
- asl
- asl
- asl
- asl
- asl ;Multiply it by 32
- clc ;Clear the carry flag
- adc Temp+0 ;Add the X position to it
- asl ;Multiply it by 2
- tay ;Transfer A to Y
- sep #$20 ;Set A to 8-bit
- lda #14
- sta Screen, x ;Top-left corner
- lda #30
- sta Screen, y ;Bottom-left corner
- inx
- inx ;Point to the tile to the right on the top
- iny
- iny ;Point to the tile to the right on the bottom
- lda #$00
- sta Temp+8 ;Temporary counter
- .placeTopAndBottomBorderLoop:
- lda #13
- sta Screen, x ;Place a border tile on the top
- sta Screen, y ;Place a border tile on the bottom
- inx
- inx ;Point to the tile to the right on the top
- iny
- iny ;Point to the tile on the right on the bottom
- lda Temp+8 ;Load the temporary counter into A
- ina ;Increment A
- sta Temp+8 ;Store A into the temporary counter
- cmp Temp+4 ;Compare it with the inside width
- bne .placeTopAndBottomBorderLoop ;If not equal, place another tile on the top and bottom
- lda #15
- sta Screen, x ;Place the top-right tile
- lda #31
- sta Screen, y ;Place the bottom-right tile
- rep #$20 ;Set A to 16-bit
- lda Temp+10 ;Load the left offset into A
- clc ;Clear the carry flag
- adc #64 ;Point to one tile down
- tax ;Copy A to X
- lda Temp+12 ;Load the right offset into A
- clc ;Clear the carry flag
- adc #64 ;Point to one tile down
- tay ;Copy A to Y
- sep #$20 ;Set A to 8-bit
- lda #$00
- sta Temp+8 ;Temporary counter
- .placeLeftAndRightBorderLoop:
- lda #29
- sta Screen, x
- sta Screen, y
- rep #$20 ;Set A to 16-bit
- txa ;Copy X to A
- clc ;Clear the carry flag
- adc #64 ;Point to one tile down
- tax ;Copy A to X
- tya ;Copy Y to A
- clc ;Clear the carry flag
- adc #64 ;Point to one tile down
- tay ;Copy A to Y
- lda Temp+8 ;Load the temporary counter into A
- ina ;Increment A
- sta Temp+8 ;Store A into the temporary counter
- cmp Temp+6 ;Compare it with the inside height
- sep #$20 ;Set A to 8-bit
- bne .placeLeftAndRightBorderLoop ;If not equal, place another tile on the left and right
- rtl
Advertisement
RAW Paste Data
Copied
Advertisement