1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** GUIX Component */
16 /** */
17 /** Display Management (Display) */
18 /** */
19 /**************************************************************************/
20
21 #define GX_SOURCE_CODE
22
23
24 /* Include necessary system files. */
25
26 #include "gx_api.h"
27 #include "gx_display.h"
28 /**************************************************************************/
29 /* */
30 /* FUNCTION RELEASE */
31 /* */
32 /* _gx_display_driver_4bpp_vertical_pattern_line_draw PORTABLE C */
33 /* 6.1.7 */
34 /* AUTHOR */
35 /* */
36 /* Kenneth Maxwell, Microsoft Corporation */
37 /* */
38 /* DESCRIPTION */
39 /* */
40 /* Vertical line draw function for 4bpp display driver. */
41 /* */
42 /* INPUT */
43 /* */
44 /* context Drawing context */
45 /* ystart y-coord of top endpoint */
46 /* yend y-coord of bottom endpoint */
47 /* xpos x-coord of left edge */
48 /* */
49 /* OUTPUT */
50 /* */
51 /* None */
52 /* */
53 /* CALLS */
54 /* */
55 /* None */
56 /* */
57 /* CALLED BY */
58 /* */
59 /* GUIX Internal Code */
60 /* */
61 /* RELEASE HISTORY */
62 /* */
63 /* DATE NAME DESCRIPTION */
64 /* */
65 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
66 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
67 /* resulting in version 6.1 */
68 /* 06-02-2021 Kenneth Maxwell Modified comment(s), */
69 /* removed unused variable */
70 /* assignment, */
71 /* resulting in version 6.1.7 */
72 /* */
73 /**************************************************************************/
_gx_display_driver_4bpp_vertical_pattern_line_draw(GX_DRAW_CONTEXT * context,INT ystart,INT yend,INT xpos)74 VOID _gx_display_driver_4bpp_vertical_pattern_line_draw(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos)
75 {
76 INT row;
77 GX_UBYTE *put;
78 GX_UBYTE *putrow;
79 ULONG pattern;
80 ULONG pattern_mask;
81 GX_UBYTE on_color;
82 GX_UBYTE off_color;
83 GX_UBYTE draw_mask;
84 INT stride;
85
86 /* pick up row pitch in bytes. */
87 stride = (context -> gx_draw_context_pitch + 1) >> 1;
88
89 /* pick up starting address of canvas memory */
90 putrow = (GX_UBYTE *)context -> gx_draw_context_memory;
91 putrow += ystart * stride;
92 putrow += (xpos >> 1);
93
94 /* pick up the requested pattern and mask */
95 pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
96 pattern_mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
97
98 on_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color & 0x0f;
99 on_color |= (GX_UBYTE)(on_color << 4);
100 off_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_fill_color & 0x0f;
101 off_color |= (GX_UBYTE)(off_color << 4);
102
103 /* draw line from top to bottom */
104 for (row = ystart; row <= yend; row++)
105 {
106 put = putrow;
107 if (xpos & 0x01)
108 {
109 draw_mask = 0x0f;
110 }
111 else
112 {
113 draw_mask = 0xf0;
114 }
115
116 /* Set bits to 0 first */
117 *put &= (GX_UBYTE)(~draw_mask);
118
119 /* Set bits color */
120 if (pattern & pattern_mask)
121 {
122 *put |= (on_color & draw_mask);
123 }
124 else
125 {
126 *put |= (off_color & draw_mask);
127 }
128
129 pattern_mask >>= 1;
130 if (!pattern_mask)
131 {
132 pattern_mask = 0x80000000;
133 }
134
135 /* advance to the next scaneline */
136 putrow += stride;
137 }
138
139 /* save current masks value back to brush */
140 context -> gx_draw_context_brush.gx_brush_pattern_mask = pattern_mask;
141 }
142
143