sub16 macro

This commit is contained in:
Joshua Bell 2018-02-04 19:46:41 -08:00
parent faa22b2c2c
commit e20a9bc7bd

View File

@ -53,6 +53,26 @@ INVOKER_FILENAME := $280 ; File to invoke (PREFIX must be set)
jmp target jmp target
.endmacro .endmacro
.macro sub16 aa, bb, rr
.if (.match (.mid (0, 1, {bb}), #))
lda aa
sec
sbc #<(.right (.tcount ({bb})-1, {bb}))
sta rr
lda aa+1
sbc #>(.right (.tcount ({bb})-1, {bb}))
sta rr+1
.else
lda aa
sec
sbc bb
sta rr
lda aa+1
sbc bb+1
sta rr+1
.endif
.endmacro
.macro MGTK_RELAY_CALL call, addr .macro MGTK_RELAY_CALL call, addr
.if .paramcount > 1 .if .paramcount > 1
yax_call MGTK_RELAY, (call), (addr) yax_call MGTK_RELAY, (call), (addr)
@ -1229,24 +1249,24 @@ L97F6: .byte 0
;;; DESKTOP $0A IMPL ;;; DESKTOP $0A IMPL
.proc L97F7 .proc L97F7
ldy #$00 ldy #0
lda ($06),y lda ($06),y
sta L982A sta L982A
tya tya
sta ($06),y sta ($06),y
ldy #$04 ldy #4
L9803: lda ($06),y L9803: lda ($06),y
sta L9C8D,y sta L9C8D,y
sta L9C91,y sta L9C91,y
dey dey
cpy #$00 cpy #0
bne L9803 bne L9803
jsr LA365 jsr LA365
lda L982A lda L982A
jsr L9EB4 jsr L9EB4
sta $06 sta $06
stx $07 stx $06+1
ldy #$02 ldy #2
lda ($06),y lda ($06),y
and #$0F and #$0F
sta L9829 sta L9829
@ -1261,13 +1281,14 @@ L982F: .byte $00
;; DT_HIGHLIGHT_ICON params ;; DT_HIGHLIGHT_ICON params
L9830: .byte $00 L9830: .byte $00
L9831: .byte $00 L9831: .byte $00
L9832: .byte $00 L9832: .byte $00
L9833: .byte $00 L9833: .byte $00
L9834: .byte $00 L9834: .byte $00
L9835: .byte $00,$00,$00,$00,$00,$00,$00,$00 L9835: .byte $00,$00,$00,$00,$00,$00,$00,$00
L983D: lda #$00 L983D: lda #0
sta L9830 sta L9830
sta L9833 sta L9833
L9845: MGTK_CALL MGTK::PeekEvent, peekevent_params L9845: MGTK_CALL MGTK::PeekEvent, peekevent_params
@ -1277,20 +1298,9 @@ L9845: MGTK_CALL MGTK::PeekEvent, peekevent_params
L9852: lda #$02 L9852: lda #$02
jmp L9C65 jmp L9C65
L9857: lda findwindow_params2::mousex L9857: sub16 findwindow_params2::mousex, L9C8E, L982C
sec sub16 findwindow_params2::mousey, L9C90, L982E
sbc L9C8E
sta L982C
lda findwindow_params2::mousex+1
sbc L9C8F
sta L982D
lda findwindow_params2::mousey
sec
sbc L9C90
sta L982E
lda findwindow_params2::mousey+1
sbc L9C91
sta L982F
lda L982D lda L982D
bpl L988C bpl L988C
lda L982C lda L982C
@ -1512,20 +1522,8 @@ L9A33: lda findwindow_params2,x
MGTK_CALL MGTK::FramePoly, drag_outline_buffer MGTK_CALL MGTK::FramePoly, drag_outline_buffer
lda #$00 lda #$00
sta L9830 sta L9830
L9A84: lda findwindow_params2::mousex L9A84: sub16 findwindow_params2::mousex, L9C8E, L9C96
sec sub16 findwindow_params2::mousey, L9C90, L9C98
sbc L9C8E
sta L9C96
lda findwindow_params2::mousex+1
sbc L9C8F
sta L9C97
lda findwindow_params2::mousey
sec
sbc L9C90
sta L9C98
lda findwindow_params2::mousey+1
sbc L9C91
sta L9C99
jsr L9C9E jsr L9C9E
ldx #$00 ldx #$00
L9AAF: lda L9C7A,x L9AAF: lda L9C7A,x
@ -2403,7 +2401,7 @@ LA256: lsr a
sec sec
sbc LA2A4 sbc LA2A4
sta LA2A4 sta LA2A4
lda poly::vertices lda poly::v0::xcoord
sec sec
sbc LA2A4 sbc LA2A4
sta poly::v6::xcoord sta poly::v6::xcoord
@ -3074,20 +3072,8 @@ LA7C8: ldy #$04
lsr a lsr a
ora LA6B1 ora LA6B1
sta LA6B1 sta LA6B1
lda grafport4::left sub16 grafport4::left, #2, grafport4::left
sec sub16 grafport4::cliprect_x1, #2, grafport4::cliprect_x1
sbc #2
sta grafport4::left
lda grafport4::left+1
sbc #0
sta grafport4::left+1
lda grafport4::cliprect_x1
sec
sbc #2
sta grafport4::cliprect_x1
lda grafport4::cliprect_x1+1
sbc #0
sta grafport4::cliprect_x1+1
bit LA6B2 bit LA6B2
bmi LA820 bmi LA820
lda grafport4::top lda grafport4::top
@ -3119,20 +3105,8 @@ LA833: bit LA6B1
bcc LA846 bcc LA846
inc grafport4::width+1 inc grafport4::width+1
LA846: jsr LA382 LA846: jsr LA382
lda grafport4::width sub16 grafport4::width, grafport4::cliprect_x1, LA6C3
sec sub16 grafport4::height, grafport4::cliprect_y1, LA6C5
sbc grafport4::cliprect_x1
sta LA6C3
lda grafport4::width+1
sbc grafport4::cliprect_x1+1
sta LA6C4
lda grafport4::height
sec
sbc grafport4::cliprect_y1
sta LA6C5
lda grafport4::height+1
sbc grafport4::cliprect_y1+1
sta LA6C6
lda LA6C3 lda LA6C3
clc clc
adc grafport4::left adc grafport4::left
@ -4120,20 +4094,8 @@ LBDDB: lda #$02
;;; ================================================== ;;; ==================================================
LBDE0: .byte 0 LBDE0: .byte 0
LBDE1: lda event_params_xcoord LBDE1: sub16 event_params_xcoord, grafport6::viewloc::xcoord, event_params_xcoord
sec sub16 event_params_ycoord, grafport6::viewloc::ycoord, event_params_ycoord
sbc grafport6::viewloc::xcoord
sta event_params_xcoord
lda event_params_xcoord+1
sbc grafport6::viewloc::xcoord+1
sta event_params_xcoord+1
lda event_params_ycoord
sec
sbc grafport6::viewloc::ycoord
sta event_params_ycoord
lda event_params_ycoord+1
sbc grafport6::viewloc::ycoord+1
sta event_params_ycoord+1
rts rts
LBE08: lda #$00 LBE08: lda #$00
@ -9933,20 +9895,8 @@ L5FB9: lda LE22F
jmp L5F80 jmp L5F80
L5FC5: jsr L60D5 L5FC5: jsr L60D5
lda event_params_xcoord sub16 event_params_xcoord, L60CF, L60CB
sec sub16 event_params_ycoord, L60D1, L60CD
sbc L60CF
sta L60CB
lda event_params_xcoord+1
sbc L60D0
sta L60CC
lda event_params_ycoord
sec
sbc L60D1
sta L60CD
lda event_params_ycoord+1
sbc L60D2
sta L60CE
lda L60CC lda L60CC
bpl L5FFE bpl L5FFE
lda L60CB lda L60CB
@ -10280,20 +10230,8 @@ L630F: lda L6388
lda #$01 lda #$01
L6318: rts L6318: rts
L6319: lda L6383 L6319: sub16 L6383, L6385, L6383
sec sub16 L6387, L6389, L6387
sbc L6385
sta L6383
lda L6384
sbc L6386
sta L6384
lda L6387
sec
sbc L6389
sta L6387
lda L6388
sbc L638A
sta L6388
clc clc
ror L6386 ror L6386
ror L6385 ror L6385
@ -10419,13 +10357,7 @@ L644C: tya
L6451: jsr L650F L6451: jsr L650F
sta L64AC sta L64AC
stx L64AD stx L64AD
lda grafport2::cliprect_x1 sub16 grafport2::cliprect_x1, L64AC, L64AE
sec
sbc L64AC
sta L64AE
lda grafport2::cliprect_x1+1
sbc L64AD
sta L64AF
lda L64AE lda L64AE
cmp L7B5F cmp L7B5F
lda L64AF lda L64AF
@ -10477,13 +10409,7 @@ L64E3: lda L7B63
ldx L7B64 ldx L7B64
L64E9: sta grafport2::width L64E9: sta grafport2::width
stx grafport2::width+1 stx grafport2::width+1
lda grafport2::width sub16 grafport2::width, L650B, grafport2::cliprect_x1
sec
sbc L650B
sta grafport2::cliprect_x1
lda grafport2::width+1
sbc L650C
sta grafport2::cliprect_x1+1
jsr L653E jsr L653E
jsr L6DB1 jsr L6DB1
jmp L6556 jmp L6556
@ -10546,30 +10472,12 @@ L656D: lda active_window_id
ldy #$06 ldy #$06
lda ($06),y lda ($06),y
tay tay
lda L7B63 sub16 L7B63, L7B5F, L6602
sec sub16 L6602, L6600, L6602
sbc L7B5F
sta L6602
lda L7B64
sbc L7B60
sta L6603
lda L6602
sec
sbc L6600
sta L6602
lda L6603
sbc L6601
sta L6603
lsr L6603 lsr L6603
ror L6602 ror L6602
ldx L6602 ldx L6602
lda grafport2::cliprect_x1 sub16 grafport2::cliprect_x1, L7B5F, L6602
sec
sbc L7B5F
sta L6602
lda grafport2::cliprect_x1+1
sbc L7B60
sta L6603
bpl L65D0 bpl L65D0
lda #$00 lda #$00
beq L65EB beq L65EB
@ -10605,13 +10513,7 @@ L6604: lda active_window_id
ldy #$08 ldy #$08
lda ($06),y lda ($06),y
tay tay
lda L7B65 sub16 L7B65, L7B61, L66A0
sec
sbc L7B61
sta L66A0
lda L7B66
sbc L7B62
sta L66A1
lda L66A0 lda L66A0
sec sec
sbc L669F sbc L669F
@ -10624,13 +10526,7 @@ L6604: lda active_window_id
lsr L66A1 lsr L66A1
ror L66A0 ror L66A0
ldx L66A0 ldx L66A0
lda grafport2::cliprect_y1 sub16 grafport2::cliprect_y1, L7B61, L66A0
sec
sbc L7B61
sta L66A0
lda grafport2::cliprect_y1+1
sbc L7B62
sta L66A1
bpl L6669 bpl L6669
lda #$00 lda #$00
beq L668A beq L668A
@ -10913,20 +10809,8 @@ L692C: pla
inx inx
jmp L68F9 jmp L68F9
L6932: lda event_params_xcoord L6932: sub16 event_params_xcoord, L6A39, L6A35
sec sub16 event_params_ycoord, L6A3B, L6A37
sbc L6A39
sta L6A35
lda event_params_xcoord+1
sbc L6A3A
sta L6A36
lda event_params_ycoord
sec
sbc L6A3B
sta L6A37
lda event_params_ycoord+1
sbc L6A3C
sta L6A38
lda L6A36 lda L6A36
bpl L6968 bpl L6968
lda L6A35 lda L6A35
@ -11751,13 +11635,7 @@ L70EA: lda $0C23,x
inx inx
cpx #$04 cpx #$04
bne L70EA bne L70EA
lda L485D sub16 L485D, L485F, L72A8
sec
sbc L485F
sta L72A8
lda L485E
sbc L4860
sta L72A9
ldx #$05 ldx #$05
L710A: lsr L72A9 L710A: lsr L72A9
ror L72A8 ror L72A8
@ -11986,20 +11864,8 @@ L72F8: lda get_file_info_params4::auxtype
sta L70BD sta L70BD
lda get_file_info_params4::auxtype+1 lda get_file_info_params4::auxtype+1
sta L70BE sta L70BE
lda get_file_info_params4::auxtype sub16 get_file_info_params4::auxtype, get_file_info_params4::blocks, L70BB
sec sub16 L70BD, L70BB, L70BD
sbc get_file_info_params4::blocks
sta L70BB
lda get_file_info_params4::auxtype+1
sbc get_file_info_params4::blocks+1
sta L70BC
lda L70BD
sec
sbc L70BB
sta L70BD
lda L70BE
sbc L70BC
sta L70BE
lsr L70BC lsr L70BC
ror L70BB ror L70BB
php php
@ -12788,30 +12654,12 @@ L79A7: jsr L79F7
addr_call draw_text2, str_k_available addr_call draw_text2, str_k_available
rts rts
L79F7: lda grafport2::width L79F7: sub16 grafport2::width, grafport2::cliprect_x1, L7ADE
sec sub16 L7ADE, $EBF3, L7ADE
sbc grafport2::cliprect_x1
sta L7ADE
lda grafport2::width+1
sbc grafport2::cliprect_x1+1
sta L7ADF
lda L7ADE
sec
sbc $EBF3
sta L7ADE
lda L7ADF
sbc $EBF4
sta L7ADF
bpl L7A22 bpl L7A22
jmp L7A86 jmp L7A86
L7A22: lda L7ADE L7A22: sub16 L7ADE, $EBF9, L7ADE
sec
sbc $EBF9
sta L7ADE
lda L7ADF
sbc $EBFA
sta L7ADF
bpl L7A3A bpl L7A3A
jmp L7A86 jmp L7A86
@ -12827,13 +12675,7 @@ L7A3A: lda $EBE7
lda L7ADE lda L7ADE
cmp #$18 cmp #$18
bcc L7A6A bcc L7A6A
L7A59: lda point3::xcoord L7A59: sub16 point3::xcoord, #$0C, point3::xcoord
sec
sbc #$0C
sta point3::xcoord
lda point3::xcoord+1
sbc #$00
sta point3::xcoord+1
L7A6A: lsr L7ADF L7A6A: lsr L7ADF
ror L7ADE ror L7ADE
lda LEBE3 lda LEBE3
@ -13026,20 +12868,8 @@ L7C05: lda L7B65
sta L7B65 sta L7B65
bcc L7C13 bcc L7C13
inc L7B66 inc L7B66
L7C13: lda L7B5F L7C13: sub16 L7B5F, #$32, L7B5F
sec sub16 L7B61, #$0F, L7B61
sbc #$32
sta L7B5F
lda L7B60
sbc #$00
sta L7B60
lda L7B61
sec
sbc #$0F
sta L7B61
lda L7B62
sbc #$00
sta L7B62
rts rts
L7C36: tax L7C36: tax
@ -14009,20 +13839,8 @@ L84D1: jsr push_zp_addrs
bit L5B1B bit L5B1B
bmi L84DC bmi L84DC
jsr L6E52 jsr L6E52
L84DC: lda grafport2::width L84DC: sub16 grafport2::width, grafport2::cliprect_x1, L85F8
sec sub16 grafport2::height, grafport2::cliprect_y1, L85FA
sbc grafport2::cliprect_x1
sta L85F8
lda grafport2::width+1
sbc grafport2::cliprect_x1+1
sta L85F9
lda grafport2::height
sec
sbc grafport2::cliprect_y1
sta L85FA
lda grafport2::height+1
sbc grafport2::cliprect_y1+1
sta L85FB
lda event_params_kind lda event_params_kind
cmp #MGTK::event_kind_button_down cmp #MGTK::event_kind_button_down
bne L850C bne L850C
@ -15015,20 +14833,8 @@ L8BC1: lda grafport2,x
dey dey
dex dex
bpl L8BC1 bpl L8BC1
lda grafport2::width sub16 grafport2::width, grafport2::cliprect_x1, L8D54
sec sub16 grafport2::height, grafport2::cliprect_y1, L8D56
sbc grafport2::cliprect_x1
sta L8D54
lda grafport2::width+1
sbc grafport2::cliprect_x1+1
sta L8D55
lda grafport2::height
sec
sbc grafport2::cliprect_y1
sta L8D56
lda grafport2::height+1
sbc grafport2::cliprect_y1+1
sta L8D57
lda $0858 lda $0858
clc clc
adc L8D54 adc L8D54
@ -15047,20 +14853,8 @@ L8BC1: lda grafport2,x
sta L8D4E sta L8D4E
sta L8D4F sta L8D4F
sta L8D4D sta L8D4D
lda $0858 sub16 $0858, L0800, L8D50
sec sub16 $085A, $0802, L8D52
sbc L0800
sta L8D50
lda $0859
sbc $0801
sta L8D51
lda $085A
sec
sbc $0802
sta L8D52
lda $085B
sbc $0803
sta L8D53
bit L8D51 bit L8D51
bpl L8C6A bpl L8C6A
lda #$80 lda #$80
@ -16966,13 +16760,7 @@ L9BC9: yax_call JT_MLI_RELAY, GET_FILE_INFO, file_info_params3
jsr LA497 jsr LA497
jmp L9BC9 jmp L9BC9
L9BDA: lda file_info_params3::auxtype L9BDA: sub16 file_info_params3::auxtype, file_info_params3::blocks, L9BFF
sec
sbc file_info_params3::blocks
sta L9BFF
lda file_info_params3::auxtype+1
sbc file_info_params3::blocks+1
sta L9C00
lda L9BFF lda L9BFF
cmp LA2EF cmp LA2EF
lda L9C00 lda L9C00
@ -17043,13 +16831,7 @@ L9C70: yax_call JT_MLI_RELAY, GET_FILE_INFO, file_info_params3
jmp LA39F jmp LA39F
L9C95: lda file_info_params3::auxtype L9C95: sub16 file_info_params3::auxtype, file_info_params3::blocks, L9CD4
sec
sbc file_info_params3::blocks
sta L9CD4
lda file_info_params3::auxtype+1
sbc file_info_params3::blocks+1
sta L9CD5
lda L9CD4 lda L9CD4
clc clc
adc L9CD8 adc L9CD8
@ -17593,13 +17375,7 @@ LA1A3: lda #7 ; param count for SET_FILE_INFO
LA1C0: jmp LA322 LA1C0: jmp LA322
LA1C3: lda LA2ED LA1C3: sub16 LA2ED, #$01, LA055
sec
sbc #$01
sta LA055
lda LA2EE
sbc #$00
sta LA056
bit L918B bit L918B
bpl LA1DC bpl LA1DC
jmp LA10A jmp LA10A
@ -17843,23 +17619,11 @@ LA3D1: yax_call JT_MGTK_RELAY, MGTK::GetEvent, event_params
LA3EC: lda #$00 LA3EC: lda #$00
LA3EE: rts LA3EE: rts
LA3EF: lda LA2ED LA3EF: sub16 LA2ED, #$01, L9E7A
sec
sbc #$01
sta L9E7A
lda LA2EE
sbc #$00
sta L9E7B
yax_call launch_dialog, index_delete_file_dialog, L9E79 yax_call launch_dialog, index_delete_file_dialog, L9E79
rts rts
LA40A: lda LA2ED LA40A: sub16 LA2ED, #$01, L9938
sec
sbc #$01
sta L9938
lda LA2EE
sbc #$00
sta L9938+1
yax_call launch_dialog, index_copy_file_dialog, L9937 yax_call launch_dialog, index_copy_file_dialog, L9937
rts rts