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 /* Include necessary system files. */ 24 25 #include "gx_api.h" 26 #include "gx_display.h" 27 28 /**************************************************************************/ 29 /* */ 30 /* FUNCTION RELEASE */ 31 /* */ 32 /* _gx_display_driver_4bpp_horizontal_pattern_line_draw */ 33 /* PORTABLE C */ 34 /* 6.1 */ 35 /* AUTHOR */ 36 /* */ 37 /* Kenneth Maxwell, Microsoft Corporation */ 38 /* */ 39 /* DESCRIPTION */ 40 /* */ 41 /* Horizontal pattern line draw function for 4bpp display driver. */ 42 /* */ 43 /* INPUT */ 44 /* */ 45 /* context Drawing context */ 46 /* xstart x-coord of left endpoint */ 47 /* xend x-coord of right endpoint */ 48 /* ypos y-coord of line top */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* None */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* None */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* GUIX Internal Code */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 67 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* */ 70 /**************************************************************************/ _gx_display_driver_4bpp_horizontal_pattern_line_draw(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT ypos)71VOID _gx_display_driver_4bpp_horizontal_pattern_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos) 72 { 73 INT column; 74 GX_UBYTE *put; 75 GX_UBYTE *rowstart; 76 ULONG pattern; 77 ULONG mask; 78 GX_UBYTE on_color; 79 GX_UBYTE off_color; 80 INT pos; 81 INT len = xend - xstart + 1; 82 GX_UBYTE start_mask; 83 84 /* pick up start address of canvas memory */ 85 rowstart = (GX_UBYTE *)context -> gx_draw_context_memory; 86 87 pos = context -> gx_draw_context_pitch * ypos + xstart; 88 89 /* pick up the requested pattern and mask */ 90 pattern = context -> gx_draw_context_brush.gx_brush_line_pattern; 91 mask = context -> gx_draw_context_brush.gx_brush_pattern_mask; 92 on_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color & 0x0f; 93 on_color |= (GX_UBYTE)(on_color << 4); 94 off_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_fill_color & 0x0f; 95 off_color |= (GX_UBYTE)(off_color << 4); 96 97 put = rowstart; 98 put += pos >> 1; 99 if (pos & 0x01) 100 { 101 start_mask = 0x0f; 102 } 103 else 104 { 105 start_mask = 0xf0; 106 } 107 108 for (column = 0; column < len; column++) 109 { 110 /* Set bits to 0 first */ 111 *put &= (GX_UBYTE)(~start_mask); 112 /* Set bits color */ 113 if (pattern & mask) 114 { 115 *put |= (on_color & start_mask); 116 } 117 else 118 { 119 *put |= (off_color & start_mask); 120 } 121 122 start_mask >>= 4; 123 if (start_mask == 0) 124 { 125 put++; 126 start_mask = 0xf0; 127 } 128 129 mask >>= 1; 130 if (!mask) 131 { 132 mask = 0x80000000; 133 } 134 } 135 136 /* save current masks value back to brush */ 137 context -> gx_draw_context_brush.gx_brush_pattern_mask = mask; 138 } 139 140