;set the box size
lda #8 ;y pos
sta rectangle+6
lda #2 ;x pos
sta rectangle+7
lda #22
sta rectangle+8 ;width
lda #6
sta rectangle+9 ;height
jsr drawbox
rts
drawbox
ldy rectangle+6
lda #$00
sta $fa
lda #$04
sta $fb
box0 cpy #0
beq box1
clc
lda $fa
adc #$28
sta $fa
bcs box2
box00 dey
jmp box0
box2 inc $fb
jmp box00
box1 ldy rectangle+7
lda rectangle
sta ($fa),y
lda rectangle+5
ldx rectangle+8
box1a iny
dex
sta ($fa),y
cpx #0
bne box1a
iny
lda rectangle+1
sta ($fa),y
sty recttemp
ldx rectangle+9
box1d cpx #0
beq box1e
clc
lda $fa
adc #$28
sta $fa
bcs box1b
box1c lda rectangle+4
ldy recttemp
sta ($fa),y
ldy rectangle+7
sta ($fa),y
dex
jmp box1d
box1b inc $fb
jmp box1c
box1e clc
lda $fa
adc #$28
sta $fa
bcs box1f
box1g lda rectangle+3
ldy recttemp
sta ($fa),y
lda rectangle+2
ldy rectangle+7
sta ($fa),y
ldy recttemp
dey
lda rectangle+5
box1h sta ($fa),y
dey
cpy rectangle+7
bne box1h
rts
box1f inc $fb
jmp box1g
rectangle .byte 112,110,109,125,93,67
.byte 0,0,0,0 ;y,x,length,height
recttemp .byte 0
;top left, top right, bottom left, bottom right, width piece, height piece