inc16 macro and refactors

This commit is contained in:
Joshua Bell 2018-02-25 16:06:17 -08:00
parent 7da8f698b8
commit 89b157928c
7 changed files with 54 additions and 86 deletions

View File

@ -3830,10 +3830,8 @@ LBE34: lda ($06),y
LBE37 := * + 1
LBE38 := * + 2
sta dummy1234
inc LBE37
bne LBE41
inc LBE38
LBE41: lda LBE5C
inc16 LBE37
lda LBE5C
cmp LBFCC
bcs LBE4E
inc LBE5C
@ -3917,10 +3915,8 @@ LBEDD: lda ($06),y
pha
LBEEB: pla
sta ($06),y
inc LBEBC
bne LBEF6
inc LBEBC+1
LBEF6: lda LBF0B
inc16 LBEBC
lda LBF0B
cmp LBFCC
bcs LBF03
inc LBF0B
@ -11749,9 +11745,7 @@ L72F8: copy16 get_file_info_params4::aux_type, L70BD
lsr16 L70BD
plp
bcc L7342
inc L70BD
bne L7342
inc L70BD+1
inc16 L70BD
L7342: return #0
.endproc
L70BB := L7054::L70BB
@ -11805,13 +11799,9 @@ L73A5: lda LCBANK2
sta ($06),y
lda LCBANK1
lda LCBANK1
inc $06
bne :+
inc $06+1
: inc $08
bne :+
inc $08+1
: lda $08+1
inc16 $06
inc16 $08
lda $08+1
cmp L485F+1
bne L73A5
lda $08
@ -14002,10 +13992,8 @@ L877F: .byte 0
lda (textptr),y
beq exit
sta textlen
inc textptr
bne :+
inc textptr+1
: MGTK_RELAY_CALL MGTK::DrawText, params
inc16 textptr
MGTK_RELAY_CALL MGTK::DrawText, params
exit: rts
.endproc
@ -14021,10 +14009,8 @@ exit: rts
ldy #0
lda (ptr),y
sta len
inc ptr
bne :+
inc ptr+1
: MGTK_RELAY_CALL MGTK::TextWidth, ptr
inc16 ptr
MGTK_RELAY_CALL MGTK::TextWidth, ptr
ldax result
rts
.endproc
@ -14699,9 +14685,7 @@ L8BC1: lda grafport2,x
lda L8D51
eor #$FF
sta L8D51
inc L8D50
bne L8C6A
inc L8D51
inc16 L8D50
L8C6A: bit L8D53
bpl L8C8C
lda #$80
@ -14712,9 +14696,7 @@ L8C6A: bit L8D53
lda L8D53
eor #$FF
sta L8D53
inc L8D52
bne L8C8C
inc L8D53
inc16 L8D52
L8C8C: lsr16 L8D50
lsr16 L8D52
lsr16 L8D54
@ -15929,9 +15911,7 @@ L969E: lda #$40
sta ($06),y
lda ($08),y
tay
inc $06
bne L96DA
inc $06+1
inc16 $06
L96DA: lda ($08),y
sta ($06),y
dey
@ -17271,10 +17251,8 @@ LA2AE: bit L9189
yax_call JT_MLI_RELAY, GET_FILE_INFO, file_info_params2
bne :+
add16 LA2EF, file_info_params2::blocks_used, LA2EF
: inc LA2ED
bne :+
inc LA2ED+1
: bit L9189
: inc16 LA2ED
bit L9189
bvc :+
jsr remove_path_segment_220
: ldax LA2ED
@ -19293,10 +19271,8 @@ erase_ok_button:
jsr load_aux_from_ptr
beq done
sta textlen
inc textptr
bne :+
inc textptr+1
: MGTK_RELAY_CALL MGTK::DrawText, params
inc16 textptr
MGTK_RELAY_CALL MGTK::DrawText, params
done: rts
.endproc

View File

@ -1354,10 +1354,8 @@ L4F11: lda $91
bne L4F25
dex
inc $8E
inc $84
bne L4F23
inc $85
L4F23: lda $92
inc16 $84
lda $92
L4F25: sta $88
lda $96
bne L4F2E
@ -1997,13 +1995,9 @@ ora_2_param_bytes:
iny
ora (params_addr),y
sta $B4
inc params_addr
bne :+
inc params_addr+1
: inc params_addr
bne :+
inc params_addr+1
: ldy #$80
inc16 params_addr
inc16 params_addr
ldy #$80
L5379: rts
;;; ==================================================
@ -2311,10 +2305,8 @@ L55CE: ldx $AC
L55F8: bmi L55FD
jmp L553E
L55FD: inc $A9
bne L5603
inc $AA
L5603: jmp L54C2
L55FD: inc16 $A9
jmp L54C2
L5606: ldy $04A8,x
lda $0780,y
@ -5546,10 +5538,8 @@ L6D55: lda ($84),y
jsr L657E
ldax L6861
jsr fill_and_frame_rect
inc fill_rect_params4::left
bne L6D7A
inc fill_rect_params4::left+1
L6D7A: lda fill_rect_params4::right
inc16 fill_rect_params4::left
lda fill_rect_params4::right
bne L6D82
dec fill_rect_params4::right+1
L6D82: dec fill_rect_params4::right
@ -7246,10 +7236,8 @@ L7A18: lda $CD
sta $CD
bcs L7A23
dec $CE
L7A23: inc $C7
bne L7A29
inc $C8
L7A29: lda $CB
L7A23: inc16 $C7
lda $CB
bne L7A2F
dec $CC
L7A2F: dec $CB
@ -7279,10 +7267,8 @@ L7A57: lda $CB
sta $CB
bcs L7A62
dec $CC
L7A62: inc $C9
bne L7A68
inc $CA
L7A68: lda $CD
L7A62: inc16 $C9
lda $CD
bne L7A6E
dec $CE
L7A6E: dec $CD

View File

@ -950,10 +950,8 @@ L112D: nop
L113A: ldx #$11
L113C: dex
bne L113C
inc $D9
bne L1145
inc $DA
L1145: sec
inc16 $D9
sec
sbc #$01
bne L113A
rts
@ -1229,9 +1227,7 @@ L1307: sta L124A
sbc #1
iny
sta ($06),y
inc $06
bne L132C
inc $06+1
inc16 $06
L132C: ldy #0
lda ($06),y
tay

View File

@ -559,9 +559,7 @@ L94F0: sta $06
ldy #$00
lda ($06),y
sta $08
inc $06
bne L9500
inc $07
inc16 $06
L9500: MGTK_RELAY_CALL MGTK::TextWidth, $0006
lsr $0A
ror $09

View File

@ -1262,9 +1262,7 @@ L5DED: jsr L5DD7
ldy #$00
lda ($06),y
sta $08
inc $06
bne L5E00
inc $07
inc16 $06
L5E00: MGTK_RELAY_CALL MGTK::DrawText, $06
rts
@ -1276,9 +1274,7 @@ L5E0A: jsr L5DD7
ldy #$00
lda ($06),y
sta $08
inc $06
bne L5E1D
inc $07
inc16 $06
L5E1D: MGTK_RELAY_CALL MGTK::TextWidth, $06
lsr $0A
ror $09

View File

@ -363,3 +363,12 @@
lsr arg1+1
ror arg1
.endmacro
;;; Increment 16-bit value
.macro inc16 arg
.local skip
inc arg
bne skip
inc arg+1
skip:
.endmacro

View File

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