mirror of
https://github.com/mi57730/a2d.git
synced 2025-01-05 18:29:21 +00:00
factor out mul/div routines
This commit is contained in:
parent
e92822eb8d
commit
411b0fda72
@ -253,6 +253,56 @@ op: lda dummy1234
|
||||
rts
|
||||
.endproc
|
||||
|
||||
;;; ============================================================
|
||||
;;; Input: numbers in A,X, Y
|
||||
;;; Output: number in A,X
|
||||
|
||||
.proc Multiply_16_8_16
|
||||
stax num16
|
||||
sty num8
|
||||
copy16 #0, accum
|
||||
ldx num8
|
||||
beq done
|
||||
|
||||
loop: add16 num16, accum, accum
|
||||
dex
|
||||
bne loop
|
||||
|
||||
done: ldax accum
|
||||
rts
|
||||
|
||||
num16: .word 0
|
||||
num8: .byte 0
|
||||
accum: .word 0
|
||||
|
||||
.endproc
|
||||
|
||||
;;; ============================================================
|
||||
;;; Input: numerator in A,X, divisor in Y
|
||||
;;; Output: result in A,X
|
||||
|
||||
.proc Divide_16_8_16
|
||||
stax numerator
|
||||
sty divisor
|
||||
copy16 #0, result
|
||||
|
||||
loop: sub16_8 numerator, divisor, numerator
|
||||
bmi done
|
||||
inc16 result
|
||||
jmp loop
|
||||
|
||||
done: ldax result
|
||||
rts
|
||||
|
||||
numerator:
|
||||
.word 0
|
||||
divisor:
|
||||
.byte 0
|
||||
|
||||
result: .word 0
|
||||
|
||||
.endproc
|
||||
|
||||
;;; ============================================================
|
||||
|
||||
PAD_TO $D200
|
||||
|
@ -14102,7 +14102,7 @@ done: jmp reset_grafport3a
|
||||
jmp skip
|
||||
|
||||
;; Compute text width and center it
|
||||
: tya
|
||||
: and #$7F ; strip "center?" flag
|
||||
pha
|
||||
add16 ptr, #1, textptr
|
||||
jsr load_aux_from_ptr
|
||||
@ -14111,14 +14111,13 @@ done: jmp reset_grafport3a
|
||||
lsr16 result
|
||||
sub16 #200, result, dialog_label_pos
|
||||
pla
|
||||
and #$7F ; strip "center?" flag
|
||||
tay
|
||||
|
||||
;; y = base + desktop_aux::dialog_label_height * line
|
||||
skip: copy16 dialog_label_base_pos::ycoord, dialog_label_pos::ycoord
|
||||
: add16 dialog_label_pos::ycoord, #desktop_aux::dialog_label_height, dialog_label_pos::ycoord
|
||||
dey
|
||||
bne :-
|
||||
skip: ldx #0
|
||||
ldy #desktop_aux::dialog_label_height
|
||||
jsr Multiply_16_8_16
|
||||
stax dialog_label_pos::ycoord
|
||||
add16 dialog_label_pos::ycoord, dialog_label_base_pos::ycoord, dialog_label_pos::ycoord
|
||||
MGTK_RELAY_CALL MGTK::MoveTo, dialog_label_pos
|
||||
addr_call_indirect draw_text1, ptr
|
||||
ldx dialog_label_pos
|
||||
|
@ -255,7 +255,7 @@ L0B47: .byte 0
|
||||
|
||||
;;; ============================================================
|
||||
|
||||
labels_voffset = 40
|
||||
labels_voffset = 49
|
||||
|
||||
L0B48: cmp16 screentowindow_windowx, #40
|
||||
bpl :+
|
||||
@ -265,7 +265,7 @@ L0B48: cmp16 screentowindow_windowx, #40
|
||||
return #$FF
|
||||
: lda screentowindow_windowy
|
||||
sec
|
||||
sbc #labels_voffset+desktop_aux::dialog_label_height
|
||||
sbc #labels_voffset
|
||||
sta screentowindow_windowy
|
||||
lda screentowindow_windowy+1
|
||||
sbc #0
|
||||
@ -274,17 +274,12 @@ L0B48: cmp16 screentowindow_windowx, #40
|
||||
: sta screentowindow_windowy+1
|
||||
|
||||
;; Divide by desktop_aux::dialog_label_height
|
||||
ldx #0
|
||||
lda screentowindow_windowy
|
||||
: sec
|
||||
sbc #desktop_aux::dialog_label_height
|
||||
bmi :+
|
||||
inx
|
||||
bne :- ; always
|
||||
ldax screentowindow_windowy
|
||||
ldy #desktop_aux::dialog_label_height
|
||||
jsr Divide_16_8_16
|
||||
stax screentowindow_windowy
|
||||
|
||||
: stx screentowindow_windowy
|
||||
lda screentowindow_windowy
|
||||
cmp #$04
|
||||
cmp #4
|
||||
bcc L0B98
|
||||
return #$FF
|
||||
|
||||
@ -359,16 +354,13 @@ L0C20: ldy #39
|
||||
txa
|
||||
sec
|
||||
sbc L0CA9 ; entry % 4
|
||||
tax
|
||||
lda #0
|
||||
: clc
|
||||
adc #desktop_aux::dialog_label_height
|
||||
dex
|
||||
bpl :-
|
||||
adc #labels_voffset
|
||||
sta select_volume_rect::y1
|
||||
lda #0
|
||||
sta select_volume_rect::y1+1
|
||||
ldx #0
|
||||
|
||||
ldy #desktop_aux::dialog_label_height
|
||||
jsr Multiply_16_8_16
|
||||
stax select_volume_rect::y1
|
||||
add16_8 select_volume_rect::y1, #labels_voffset, select_volume_rect::y1
|
||||
|
||||
add16 select_volume_rect::x1, #label_width-1, select_volume_rect::x2
|
||||
add16 select_volume_rect::y1, #desktop_aux::dialog_label_height-1, select_volume_rect::y2
|
||||
MGTK_RELAY_CALL MGTK::SetPenMode, penXOR
|
||||
|
Loading…
Reference in New Issue
Block a user