1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** GUIX Component */ 17 /** */ 18 /** Display Management (Display) */ 19 /** */ 20 /**************************************************************************/ 21 22 #define GX_SOURCE_CODE 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_pixel_write PORTABLE C */ 33 /* 6.1 */ 34 /* AUTHOR */ 35 /* */ 36 /* Kenneth Maxwell, Microsoft Corporation */ 37 /* */ 38 /* DESCRIPTION */ 39 /* */ 40 /* Pixel write function for the 4bpp display driver. */ 41 /* */ 42 /* INPUT */ 43 /* */ 44 /* context Drawing context */ 45 /* x X coordinate */ 46 /* y Y coordinate */ 47 /* color Color of pixel to write */ 48 /* */ 49 /* OUTPUT */ 50 /* */ 51 /* None */ 52 /* */ 53 /* CALLS */ 54 /* */ 55 /* _gx_display_driver_4bpp_pixel_write Calculate row pitch */ 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 /* */ 69 /**************************************************************************/ _gx_display_driver_4bpp_pixel_write(GX_DRAW_CONTEXT * context,INT x,INT y,GX_COLOR color)70VOID _gx_display_driver_4bpp_pixel_write(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color) 71 { 72 GX_UBYTE *put = (GX_UBYTE *)context -> gx_draw_context_memory; 73 GX_UBYTE mask; 74 UINT stride; 75 GX_UBYTE put_color; 76 77 /* Get row pitch in bytes. */ 78 stride = _gx_display_driver_4bpp_row_pitch_get((USHORT)(context -> gx_draw_context_pitch)); 79 put_color = color & 0x0f; 80 put_color |= (GX_UBYTE)(put_color << 4); 81 82 /* Calculate address of writing byte. */ 83 put = (GX_UBYTE *)((INT)put + y * (INT)stride); 84 put += x >> 1; 85 86 if (x & 0x01) 87 { 88 mask = 0x0f; 89 } 90 else 91 { 92 mask = 0xf0; 93 } 94 95 *put &= (GX_UBYTE)(~mask); 96 *put |= mask & put_color; 97 } 98 99