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

View File

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

View File

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

View File

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

View File

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

View File

@ -363,3 +363,12 @@
lsr arg1+1 lsr arg1+1
ror arg1 ror arg1
.endmacro .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))) (hex(substr($3,1)) + 1 == hex(substr($6,1)))
? "sub16 $1, $2, $3" : $&/egx; ? "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/ $text =~ s/
\b lda \s+ ( (?: [L\$][0-9A-F]{2,4} ) | (?: \#\$[0-9A-F]{2} ) ) \n \b lda \s+ ( (?: [L\$][0-9A-F]{2,4} ) | (?: \#\$[0-9A-F]{2} ) ) \n
\s+ rts \b \s+ rts \b