Here's some more optimizations:

`arch snes.cpu`

macro seek(n) {

origin (({n} & 0x7f0000) >> 1) | ({n} & 0x7fff)

base {n}

}

seek($809d7e)

rep #$30

lda $66

bne ++

ldx #$1200

-;

lda $00,x

beq +

stx $fc

jsl $809da0

ldx $fc

+;

txa

clc

adc #$0010

tax

cpx #$1280

bcc -

+;

rtl

seek($80ed75)

jml collision_a

seek($80ebeb)

jsl collision_b

seek($80ed7e)

jml collision_b

seek($80edd4)

jml collision_c

seek($8df100)

collision_a:

clc

lda $10

adc #$0003

sta $0c

sec

lda $000a,y

sbc $08

bpl +

eor #$ffff

inc

+;

cmp $0c

bcs ++

clc

lda $12

adc #$0003

sta $0e

sec

lda $000e,y

sbc $0a

bpl +

eor #$ffff

inc

+;

cmp $0e

+;

rtl

collision_b:

clc

lda $10

adc $0028,y

sta $0c

sec

lda $000a,y

sbc $08

bpl +

eor #$ffff

inc

+;

cmp $0c

bcs ++

clc

lda $12

adc $002a,y

sta $0e

sec

lda $000e,y

sbc $0a

bpl +

eor #$ffff

inc

+;

cmp $0e

+;

rtl

collision_c:

clc

lda $10

adc #$000b

sta $0c

clc

lda $0028,y

adc $000a,y

sec

sbc #$000b

sec

sbc $08

bpl +

eor #$ffff

inc

+;

cmp $0c

bcc +

jml $80eb57

+;

lda $12

adc #$0003

sta $0e

sec

lda $000e,y

sbc $0a

bpl +

eor #$ffff

inc

+;

cmp $0e

bcc +

jml $80eb57

+;

jml $80eb2f

sprite_processing:

lda $0000,x

-;

lsr

lsr

bcc -

sta $0000,x

inx

inx

cpx #$3e19

bcs +

txa

-;

stz $0000,x

stz $0002,x

stz $0004,x

stz $0006,x

adc #$0008

tax

cpx #$3e1a

bcc -

+;

cpx #$3e20

bcs +

-;

stz $0000,x

inx

inx

cpx #$3e20

bcc -

+;

cpy #$3d64

bcs +

-;

sep #$20

lda #$f0

sta $0001,y

sta $0005,y

sta $0009,y

sta $000d,y

sta $0011,y

sta $0015,y

sta $0019,y

sta $001d,y

rep #$21

tya

adc #$0020

tay

cpy #$3d64

bcc -

+;

cpy #$3d74

bcs +

lda #$00f0

sta $0001,y

sta $0005,y

sta $0009,y

sta $000d,y

tya

adc #$0010

tay

+;

cpy #$3d80

bcs +

sep #$20

lda #$f0

-;

sta $0001,y

iny #4

cpy #$3d80

bcc -

rep #$20

+;

lda $92

ora $66

ora $12f8

sta $18

tya

lsr

and #$003e

tax

-;

lda lut_b,x

cmp $0002,y

beq +

sta $0002,y

lda lut_c,x

sta $0000,y

+;

lda $18

bne big_jump

lda lut_a,x

and $1e

bne +

sep #$20

lda $0000,y

dec

sta $0000,y

rep #$20

+;

big_jump:

inx

inx

iny

iny

iny

iny

cpy #$3e00

bcc -

sep #$20

lda #$01

pha

plb

rep #$20

rtl

lut_a:

dw $000f,$0007,$0007,$0007,$0003,$0003,$0001,$0000,$000f,$0007,$0007,$0007,$0003,$0003,$0001,$0000

dw $000f,$0007,$0007,$0007,$0003,$0003,$0001,$0000,$000f,$0007,$0007,$0007,$0003,$0003,$0001,$0000

lut_b:

dw $08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef

dw $08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef

lut_c:

dw $a850,$0858,$4040,$c848,$2070,$9878,$7060,$b468,$6810,$0018,$b800,$5808,$3030,$8838,$6020,$9028

dw $28d0,$d8d8,$48c0,$a0c8,$38f0,$b0f8,$80e0,$48e8,$1890,$9498,$7880,$1088,$50b0,$c0b8,$d0a0,$6ca8

seek($8281f5)

ldy #$1280

phx

tyx

clc

lda $00,x

adc $0a

sta $10

and #$01f8

bit #$0100

beq +

eor #$2100

+;

lsr

lsr

sta $00

clc

lda $18,x

adc $0e

sec

sbc #$0010

and $90

sta $12

and #$01fc

asl

asl

asl

adc #$0800

and #$17e0

bit #$0020

beq +

eor #$0021

+;

ora $00

sta $14

eor #$8000

tax

stx $16

lda $7dffff,x

plx

and #$c000

rtl

seek($829903)

phy

lda $18,x

ldy $1c,x

sty $18,x

sta $1c,x

lda $1a,x

ldy $1e,x

sty $1a,x

sta $1e,x

ply

bra +

+;

seek($829819)

lda $18

clc

adc #$0004

sta $18

seek($8096d5)

-;

ldx $00

ldy $0000,x

inx

inx

stx $00

jsl $808ea0

lda $f6

beq +

sty $f2

+;

stz $02

ldx $00

-;

lda $0000,x

inx

and #$00ff

cmp #$00ff

beq label_0

cmp #$00fe

beq label_1

cmp #$00fd

beq label_2

ldy $f0

beq +

lda #$0000

+;

ora $04

stx $00

jsl $808ed8

ldx $00

lda $f6

beq -

stx $f4

lda $04

sta $f8

inc $f2

lda $0000,x

and #$00ff

cmp #$00ff

bne +

label_0:

stz $f0

stz $f6

+;

stx $00

jml $808ee3

label_2:

lda $0000,x

sta $05

inx

bra -

label_1:

stx $00

jsl $808ee3

bra --

seek($808f6e)

jml sprite_processing