cmp16 refactors

This commit is contained in:
Joshua Bell 2018-02-25 16:20:20 -08:00
parent 10c2c6099a
commit c2b7c6810b
4 changed files with 29 additions and 48 deletions

View File

@ -289,17 +289,11 @@ L0B31: pha
L0B46: .byte 0 L0B46: .byte 0
L0B47: .byte 0 L0B47: .byte 0
lda $D20D cmp16 $D20D, #$0028
cmp #$28
lda $D20E
sbc #$00
bpl L0B57 bpl L0B57
return #$FF return #$FF
L0B57: lda $D20D L0B57: cmp16 $D20D, #$0168
cmp #$68
lda $D20E
sbc #$01
bcc L0B66 bcc L0B66
return #$FF return #$FF
@ -323,16 +317,10 @@ L0B79: sta $D210
L0B98: lda #$02 L0B98: lda #$02
sta L0C1F sta L0C1F
lda $D20D cmp16 $D20D, #$0118
cmp #$18
lda $D20E
sbc #$01
bcs L0BBB bcs L0BBB
dec L0C1F dec L0C1F
lda $D20D cmp16 $D20D, #$00A0
cmp #$A0
lda $D20E
sbc #$00
bcs L0BBB bcs L0BBB
dec L0C1F dec L0C1F
L0BBB: lda L0C1F L0BBB: lda L0C1F

View File

@ -713,15 +713,9 @@ L96EF: lda $D20D
bpl L9716 bpl L9716
return #$FF return #$FF
L9716: lda $D20D L9716: cmp16 $D20D, #$006E
cmp #$6E
lda $D20E
sbc #$00
bmi L9736 bmi L9736
lda $D20D cmp16 $D20D, #$00DC
cmp #$DC
lda $D20E
sbc #$00
bmi L9732 bmi L9732
lda #$02 lda #$02
bne L9738 bne L9738

View File

@ -2136,10 +2136,7 @@ L6718: rts
L6719: jsr L6E45 L6719: jsr L6E45
stax $06 stax $06
lda $D20D cmp16 $D20D, $06
cmp $06
lda $D20E
sbc $07
bcs L672F bcs L672F
jmp L67C4 jmp L67C4
@ -2155,10 +2152,7 @@ L672F: jsr L6E45
sta $08 sta $08
L6751: MGTK_RELAY_CALL MGTK::TextWidth, $06 L6751: MGTK_RELAY_CALL MGTK::TextWidth, $06
add16 $09, L684D, $09 add16 $09, L684D, $09
lda $09 cmp16 $09, $D20D
cmp $D20D
lda $0A
sbc $D20E
bcc L6783 bcc L6783
dec $08 dec $08
lda $08 lda $08
@ -2205,10 +2199,7 @@ L67C4: copy16 #$D402, $06
sta $08 sta $08
L67D1: MGTK_RELAY_CALL MGTK::TextWidth, $06 L67D1: MGTK_RELAY_CALL MGTK::TextWidth, $06
add16 $09, $DAA6, $09 add16 $09, $DAA6, $09
lda $09 cmp16 $09, $D20D
cmp $D20D
lda $0A
sbc $D20E
bcc L6800 bcc L6800
dec $08 dec $08
lda $08 lda $08
@ -2273,10 +2264,7 @@ L688F: rts
L6890: jsr L6E72 L6890: jsr L6E72
stax $06 stax $06
lda $D20D cmp16 $D20D, $06
cmp $06
lda $D20E
sbc $07
bcs L68A6 bcs L68A6
jmp L693B jmp L693B
@ -2292,10 +2280,7 @@ L68A6: jsr L6E72
sta $08 sta $08
L68C8: MGTK_RELAY_CALL MGTK::TextWidth, $06 L68C8: MGTK_RELAY_CALL MGTK::TextWidth, $06
add16 $09, L69C4, $09 add16 $09, L69C4, $09
lda $09 cmp16 $09, $D20D
cmp $D20D
lda $0A
sbc $D20E
bcc L68FA bcc L68FA
dec $08 dec $08
lda $08 lda $08
@ -2342,10 +2327,7 @@ L693B: copy16 #$D443, $06
sta $08 sta $08
L6948: MGTK_RELAY_CALL MGTK::TextWidth, $06 L6948: MGTK_RELAY_CALL MGTK::TextWidth, $06
add16 $09, $DAB2, $09 add16 $09, $DAB2, $09
lda $09 cmp16 $09, $D20D
cmp $D20D
lda $0A
sbc $D20E
bcc L6977 bcc L6977
dec $08 dec $08
lda $08 lda $08

View File

@ -180,6 +180,23 @@ $text =~ s/
(hex(substr($3,1)) + 1 == hex(substr($6,1))) (hex(substr($3,1)) + 1 == hex(substr($6,1)))
? "sub16 $1, $2, $3" : $&/egx; ? "sub16 $1, $2, $3" : $&/egx;
$text =~ s/
\b lda \s+ ([L\$][0-9A-F]{2,4}) \n
\s+ cmp \s+ ([L\$][0-9A-F]{2,4}) \n
\s+ lda \s+ ([L\$][0-9A-F]{2,4}) \n
\s+ sbc \s+ ([L\$][0-9A-F]{2,4}) \b
/(hex(substr($1,1)) + 1 == hex(substr($3,1))) &&
(hex(substr($2,1)) + 1 == hex(substr($4,1)))
? "cmp16 $1, $2" : $&/egx;
$text =~ s/
\b lda \s+ ([L\$][0-9A-F]{2,4}) \n
\s+ cmp \s+ \#\$([0-9A-F]{2}) \n
\s+ lda \s+ ([L\$][0-9A-F]{2,4}) \n
\s+ sbc \s+ \#\$([0-9A-F]{2}) \b
/(hex(substr($1,1)) + 1 == hex(substr($3,1)))
? "cmp16 $1, #\$$4$2" : $&/egx;
$text =~ s/ $text =~ s/
\b inc \s+ ([L\$][0-9A-F]{2,4}) \n \b inc \s+ ([L\$][0-9A-F]{2,4}) \n
\s+ bne \s+ (\w+) \n \s+ bne \s+ (\w+) \n