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 /* FUNCTION RELEASE */ 30 /* */ 31 /* _gx_display_driver_1bpp_pixel_write PORTABLE C */ 32 /* 6.1 */ 33 /* AUTHOR */ 34 /* */ 35 /* Kenneth Maxwell, Microsoft Corporation */ 36 /* */ 37 /* DESCRIPTION */ 38 /* */ 39 /* Pixel write function for the 1bpp display driver. */ 40 /* */ 41 /* INPUT */ 42 /* */ 43 /* context Drawing context */ 44 /* x X coordinate */ 45 /* y Y coordinate */ 46 /* color Color of pixel to write */ 47 /* */ 48 /* OUTPUT */ 49 /* */ 50 /* None */ 51 /* */ 52 /* CALLS */ 53 /* */ 54 /* None */ 55 /* */ 56 /* CALLED BY */ 57 /* */ 58 /* GUIX Internal Code */ 59 /* */ 60 /* RELEASE HISTORY */ 61 /* */ 62 /* DATE NAME DESCRIPTION */ 63 /* */ 64 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 65 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 66 /* resulting in version 6.1 */ 67 /* */ 68 /**************************************************************************/ _gx_display_driver_1bpp_pixel_write(GX_DRAW_CONTEXT * context,INT x,INT y,GX_COLOR color)69VOID _gx_display_driver_1bpp_pixel_write(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color) 70 { 71 GX_UBYTE *put = (GX_UBYTE *)context -> gx_draw_context_memory; 72 GX_UBYTE mask; 73 UINT stride; 74 75 /* Get row pitch in bytes. */ 76 stride = _gx_display_driver_1bpp_row_pitch_get((USHORT)(context -> gx_draw_context_pitch)); 77 78 /* Calculate address of writing byte. */ 79 put = (GX_UBYTE *)((INT)put + y * (INT)stride); 80 put += x >> 3; 81 82 mask = (GX_UBYTE)(0x80 >> (x & 0x07)); 83 84 /* Write the pixel value. */ 85 if (color == 0x00) 86 { 87 *put = (GX_UBYTE)(*put & (~mask)); 88 } 89 else if (color == 0x01) 90 { 91 *put |= mask; 92 } 93 } 94 95