/*-
* Copyright (c) 2002 TAKEMRUA Shin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
void
fb_drawpixel(struct fb *fb, int x, int y, fb_pixel_t pixel)
{
int pack;
if (fb->conf.hf_access_flags & HPCFB_ACCESS_Y_TO_X)
SWAP(x, y);
if (fb->conf.hf_access_flags & HPCFB_ACCESS_R_TO_L)
x = fb->conf.hf_width - x - 1;
if (fb->conf.hf_access_flags & HPCFB_ACCESS_B_TO_T)
y = fb->conf.hf_height - y - 1;
if (x < 0 || y < 0 || fb->conf.hf_width <= x || fb->conf.hf_height < y)
return;
pack = x / fb->conf.hf_pixels_per_pack;
x %= fb->conf.hf_pixels_per_pack;
if (fb->conf.hf_access_flags & HPCFB_ACCESS_LSB_TO_MSB)
x = fb->conf.hf_pixels_per_pack - x - 1;
x *= fb->conf.hf_pixel_width;
if (fb->conf.hf_access_flags & HPCFB_ACCESS_PACK_BLANK)
x += (fb->conf.hf_pack_width -
fb->conf.hf_pixel_width * fb->conf.hf_pixels_per_pack);
x += pack * fb->conf.hf_pack_width;
if (fb->linecache_y != y) {
fb_flush(fb);
fb_fetchline(fb, y);
}