Added fill_rectangle, draws a filled block of pixes
This commit is contained in:
@@ -365,3 +365,80 @@ pub draw_line:
|
|||||||
pop r9
|
pop r9
|
||||||
pop r8
|
pop r8
|
||||||
jmp r13 ; return
|
jmp r13 ; return
|
||||||
|
|
||||||
|
|
||||||
|
pub fill_rectangle:
|
||||||
|
; void fill_rectangle(u32 fill color, u16 left, u16 top, u16 right, u16 bottom)
|
||||||
|
; Draws a rectangle from (left,top) to (right,bottom) with the outline in `border_color`.
|
||||||
|
; Fills it with `fill_color`
|
||||||
|
; Arguments:
|
||||||
|
; - r1: Fill color 24 bit RGB0
|
||||||
|
; - r2: Left coord
|
||||||
|
; - r3: Top coord
|
||||||
|
; - r4: Right coord
|
||||||
|
; - r5: Bottom coord
|
||||||
|
; Returns:
|
||||||
|
; - r1: Color 24 bit RGB0 PRESERVED???
|
||||||
|
; - r2: X1 coord
|
||||||
|
; - r3: Y1 coord
|
||||||
|
; Clobbers:
|
||||||
|
; - r4-r7, flags
|
||||||
|
; - r5: draw_pixel
|
||||||
|
; - r6: draw_pixel
|
||||||
|
; Globals read:
|
||||||
|
; - FB_DRAW_PTR
|
||||||
|
; - FB_DRAW_STRIDE
|
||||||
|
|
||||||
|
|
||||||
|
push r8 ;
|
||||||
|
push r9 ;
|
||||||
|
push r10 ;
|
||||||
|
|
||||||
|
; Compute start and end pixel addresses of first row
|
||||||
|
load_8 flags, [globals.FB_LOG_WIDTH]
|
||||||
|
lsl r7, r5, flags ; bottom * width
|
||||||
|
lsl r5, r3, flags ; top * width
|
||||||
|
add r6, r5, r4 ; top * width + right
|
||||||
|
add r5, r5, r2 ; top * width + left
|
||||||
|
add r7, r7, r4 ; bottom * width + right
|
||||||
|
lsl r6, r6, 2 ; scale pixel to bytes (LOG_BBP)
|
||||||
|
lsl r5, r5, 2 ; scale pixel to bytes (LOG_BBP)
|
||||||
|
lsl r7, r7, 2 ; scale pixel to bytes (LOG_BBP)
|
||||||
|
load_32 flags, [globals.FB_DRAW_PTR]
|
||||||
|
add r7, r7, flags ; bottom_right_ptr += frambuffer_ptr
|
||||||
|
add r6, r6, flags ; row_end_ptr += frambuffer_ptr
|
||||||
|
add r5, r5, flags ; pixel_ptr += frambuffer_ptr
|
||||||
|
|
||||||
|
|
||||||
|
mov r8, 4 ; X increment
|
||||||
|
mov r10, 1
|
||||||
|
load_8 flags, [globals.FB_LOG_WIDTH]
|
||||||
|
lsl r10, r10, flags ; screen width
|
||||||
|
sub r9, r10, r4
|
||||||
|
add r9, r9, r2 ; Y wraparound = screen_width - (right-left)
|
||||||
|
lsl r9, r9, 2 ; scale pixel to bytes (LOG_BBP)
|
||||||
|
lsl r10, r10, 2 ; scale pixel to bytes (LOG_BBP)
|
||||||
|
|
||||||
|
|
||||||
|
jmp fill_rectangle__loop_in
|
||||||
|
; For each row
|
||||||
|
fill_rectangle__loop_y:
|
||||||
|
add r5, r5, r9 ; move to start of next row
|
||||||
|
add r6, r6, r10 ; move end_ptr down 1 row
|
||||||
|
fill_rectangle__loop_in:
|
||||||
|
; Draw pixel
|
||||||
|
store_32 [r5], r1
|
||||||
|
; Fill rest of the row
|
||||||
|
fill_rectangle__loop_x:
|
||||||
|
add r5, r5, r8
|
||||||
|
; Draw pixel
|
||||||
|
store_32 [r5], r1
|
||||||
|
cmp r5, r6
|
||||||
|
jb fill_rectangle__loop_x
|
||||||
|
cmp r5, r7
|
||||||
|
jb fill_rectangle__loop_y
|
||||||
|
|
||||||
|
pop r10
|
||||||
|
pop r9
|
||||||
|
pop r8
|
||||||
|
jmp r13 ; return
|
||||||
|
|||||||
Reference in New Issue
Block a user