Separate calculating hand position from drawing it
This commit is contained in:
parent
70e6513b76
commit
27bf2bb54c
44
dosclock.asm
44
dosclock.asm
|
@ -79,8 +79,10 @@ mainloop:
|
|||
|
||||
; Draw hour hand
|
||||
mov ax, hour_hand_len
|
||||
mov cl, hour_hand_color
|
||||
call draw_hand
|
||||
mov bp, line_sx
|
||||
call calculate_hand_position
|
||||
mov bl, hour_hand_color
|
||||
call draw_line
|
||||
|
||||
; 1 minute = 5° rotation of minute hand
|
||||
mov ax, [minute]
|
||||
|
@ -94,8 +96,10 @@ mainloop:
|
|||
|
||||
; Draw minute hand
|
||||
mov ax, minute_hand_len
|
||||
mov cl, minute_hand_color
|
||||
call draw_hand
|
||||
mov bp, line_sx
|
||||
call calculate_hand_position
|
||||
mov bl, minute_hand_color
|
||||
call draw_line
|
||||
|
||||
; 1 second = 5° rotation of second hand
|
||||
mov ax, [second]
|
||||
|
@ -104,8 +108,10 @@ mainloop:
|
|||
|
||||
; Draw second hand
|
||||
mov ax, second_hand_len
|
||||
mov cl, second_hand_color
|
||||
call draw_hand
|
||||
mov bp, line_sx
|
||||
call calculate_hand_position
|
||||
mov bl, second_hand_color
|
||||
call draw_line
|
||||
|
||||
.unchanged:
|
||||
hlt
|
||||
|
@ -135,30 +141,30 @@ clear_screen:
|
|||
; in:
|
||||
; ax = hand length
|
||||
; bx = hand angle
|
||||
; cl = hand color
|
||||
draw_hand:
|
||||
; bp = points data area
|
||||
; out:
|
||||
; [bp] = start x
|
||||
; [bp + 2] = start y
|
||||
; [bp + 4] = end x
|
||||
; [bp + 6] = end y
|
||||
calculate_hand_position:
|
||||
push ax
|
||||
push bx
|
||||
push dx
|
||||
|
||||
mov word [line_sx], midpoint_x
|
||||
mov word [line_sy], midpoint_y
|
||||
mov word [line_ex], midpoint_x
|
||||
mov word [line_ey], midpoint_y
|
||||
mov word [bp], midpoint_x
|
||||
mov word [bp + 2], midpoint_y
|
||||
mov word [bp + 4], midpoint_x
|
||||
mov word [bp + 6], midpoint_y
|
||||
|
||||
mov dx, ax
|
||||
call sinx
|
||||
add [line_ex], ax
|
||||
add [bp + 4], ax
|
||||
|
||||
mov ax, dx
|
||||
call cosx
|
||||
sub [line_ey], ax
|
||||
|
||||
mov bl, cl
|
||||
call draw_line
|
||||
sub [bp + 6], ax
|
||||
|
||||
pop dx
|
||||
pop bx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
|
|
Loading…
Reference in New Issue