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