write.c 21.6 KB
Newer Older
崔立宝's avatar
崔立宝 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
/*
****************************************************************************
PROJECT : GRAPE_APP
FILE    : $Id: write.c 25427 2013-06-14 07:55:45Z nan.wang $
============================================================================ 
DESCRIPTION
Sample program for demonstration of the D1MX GFX features
============================================================================
                            C O P Y R I G H T
============================================================================
                           Copyright (c) 2014
                                  by 
                       Renesas Electronics (Europe) GmbH. 
                           Arcadiastrasse 10
                          D-40472 Duesseldorf
                               Germany
                          All rights reserved.
============================================================================
Purpose: only for testing, not for mass production

DISCLAIMER 

LICENSEE has read, understood and accepted the terms and conditions defined in
the license agreement, especially the usage rights. In any case, it is
LICENSEE's responsibility to make sure that any user of the software complies
with the terms and conditions of the signed license agreement.

SAMPLE CODE is not part of the licensed software, as such it must not be used in
mass-production applications. It can only be used for evaluation and
demonstration purposes at customer抯 premises listed in the signed license
agreement.
****************************************************************************
*/

/***********************************************************
  Title: Write Module 
  
  This module contains the write functions for bitmap fonts.
*/


/***********************************************************
  Section: Includes
*/

#include "r_typedefs.h"         /* Renesas basic types, e.g. uint32_t */
#include "r_drw2d_os.h"
#include "r_drw2d_api.h"
#include "img_format.h"
#include "font.h"
#include "write.h"
#include "r_config_d1x.h"
#include "main.h"
#include "han00002ce20.h"
//#include "han5c009f00.h"
//#include "han34009fff.h"
/***********************************************************
  Variable: locCurrentFont

  Font to be used by text operations.
*/

static const Font_t *locCurrentFont;

static r_drw2d_Rect_t rect;
static r_drw2d_Rect_t src_rect;
static r_drw2d_Texture_t tex;

/***********************************************************
  Function: locGetCharRemapping
*/

static int locGetCharRemapping(unsigned char Character)
{
    int c;
    
    /* Character remapping */
    if ((Character >= 32) && (Character < 128))
    {
        /* visible ASCII characters start with 32 (blank)
           not visible chars 0-31 and will be omitted */
        c = (Character - 32);
    }
    else
    {
        switch (Character)
        {
            case 0xB0:
            	  /* special remapping for non ASCII character 'degree' (掳 or 0xB0)
            	     non visible char DEL (127) will be used for 'degree' */
                c = (127 - 32);
                break;
            default:
                /* use blank as default */
                c = 0;
                break;
        }
    }
    return c;
}


/***********************************************************
  Function: locWriteChar

  Write a single character.

  Use the currently selected buffer, font and color to draw
  a character at the given position.

  Parameters:
  Dev        - R_DRW2D device structure
  PosX       - Display X position (not turned)
  PosY       - Display Y position (not turned)
  Character  - ASCII value of the character

  Returns:
  void
*/
static const FontPos_t FontPos[] = {
    { 0, 4}, /*   */
    { 4, 4}, /* ! */
    { 8, 8}, /* " */
    { 16, 9}, /* # */
    { 25, 9}, /* $ */
    { 34, 16}, /* % */
    { 50, 12}, /* & */
    { 62, 4}, /* ' */
    { 66, 5}, /* ( */
    { 71, 5}, /* ) */
    { 76, 6}, /* * */
    { 82, 9}, /* + */
    { 91, 4}, /* , */
    { 95, 5}, /* - */
    { 100, 4}, /* . */
    { 104, 4}, /* / */
    { 108, 9}, /* 0 */
    { 117, 9}, /* 1 */
    { 126, 9}, /* 2 */
    { 135, 9}, /* 3 */
    { 144, 9}, /* 4 */
    { 153, 9}, /* 5 */
    { 162, 9}, /* 6 */
    { 171, 9}, /* 7 */
    { 180, 9}, /* 8 */
    { 189, 9}, /* 9 */
    { 198, 6}, /* : */
    { 204, 6}, /* ; */
    { 210, 9}, /* < */
    { 219, 9}, /* = */
    { 228, 9}, /* > */
    { 237, 10}, /* ? */
    { 247, 16}, /* @ */
    { 263, 11}, /* A */
    { 274, 12}, /* B */
    { 286, 12}, /* C */
    { 298, 12}, /* D */
    { 310, 11}, /* E */
    { 321, 10}, /* F */
    { 331, 12}, /* G */
    { 343, 12}, /* H */
    { 355, 4}, /* I */
    { 359, 9}, /* J */
    { 368, 12}, /* K */
    { 380, 10}, /* L */
    { 390, 13}, /* M */
    { 403, 12}, /* N */
    { 415, 12}, /* O */
    { 427, 11}, /* P */
    { 438, 12}, /* Q */
    { 450, 12}, /* R */
    { 462, 11}, /* S */
    { 473, 10}, /* T */
    { 483, 12}, /* U */
    { 495, 11}, /* V */
    { 506, 15}, /* W */
    { 521, 11}, /* X */
    { 532, 10}, /* Y */
    { 542, 9}, /* Z */
    { 551, 5}, /* [ */
    { 556, 4}, /* \ */
    { 560, 5}, /* ] */
    { 565, 9}, /* ^ */
    { 574, 9}, /* _ */
    { 583, 5}, /* ` */
    { 588, 9}, /* a */
    { 597, 10}, /* b */
    { 607, 9}, /* c */
    { 616, 10}, /* d */
    { 626, 9}, /* e */
    { 635, 6}, /* f */
    { 641, 9}, /* g */
    { 650, 10}, /* h */
    { 660, 4}, /* i */
    { 664, 5}, /* j */
    { 669, 9}, /* k */
    { 678, 4}, /* l */
    { 682, 14}, /* m */
    { 696, 10}, /* n */
    { 706, 10}, /* o */
    { 716, 10}, /* p */
    { 726, 10}, /* q */
    { 736, 6}, /* r */
    { 742, 9}, /* s */
    { 751, 5}, /* t */
    { 756, 10}, /* u */
    { 766, 9}, /* v */
    { 775, 13}, /* w */
    { 788, 9}, /* x */
    { 797, 9}, /* y */
    { 806, 9}, /* z */
    { 815, 6}, /* { */
    { 821, 4}, /* | */
    { 825, 6}, /* } */
    { 831, 10}, /* ~ */
    { 841, 6}, /*  */
};

static void locWriteChar(r_drw2d_Device_t Dev, int PosX, int PosY, unsigned char Character)
{
    int       xsrc;
    int       wsrc;
    char      c;
   
    c = locGetCharRemapping(Character);
    xsrc  = FontPos[c].Offset;
    wsrc  = FontPos[c].Width;

    rect.Pos.X = R_DRW2D_2X(PosX);
    rect.Pos.Y = R_DRW2D_2X(PosY);
    //rect.Size.Height = R_DRW2D_2X(locCurrentFont->Height);
    rect.Size.Height = R_DRW2D_2X(19);
    rect.Size.Width = R_DRW2D_2X(wsrc);

    src_rect.Pos.X = R_DRW2D_2X(xsrc);
    src_rect.Pos.Y = R_DRW2D_2X(0);
    //src_rect.Size.Height = R_DRW2D_2X(locCurrentFont->Height);
	 src_rect.Size.Height = R_DRW2D_2X(19);
    src_rect.Size.Width = R_DRW2D_2X(wsrc);

    R_DRW2D_TextureBlit(Dev, &src_rect, &rect);
}

/***********************************************************
  Section: Global Functions

  Description see: <write.h>
*/

/***********************************************************
  Function: SelectFont
*/
/*
void SelectFont(const Font_t *Font)
{
    locCurrentFont = Font;
}
*/

/***********************************************************
  Function: GetFontHeight
*/

int GetFontHeight(void)
{
    return locCurrentFont->Height;
}



/***********************************************************
  Function: GetCharWidth
*/

int GetCharWidth(char Character)
{
    int c;

    c = locGetCharRemapping(Character);
    if ((c < 0) || (c > 95))
    {
        return 0;
    }
   // return locCurrentFont->Pos[c].Width;
    return FontPos[c].Width;
}


/***********************************************************
  Function: GetTextWidth
*/

int GetTextWidth(char *Text)
{
    int w;

    w = 0;
    while (*Text != 0)
    {
        w += GetCharWidth(*Text);
        Text++;
    }
    return w;
}

/***********************************************************
  Function: GetTextHeight
*/

int GetTextHeight(char *Text)
{
    int h;

    h = 1; /* To include the last line */
    while (*Text != 0)
    {
        if (*Text == '\n')
        {
            h += GetFontHeight();
        }
        Text++;
    }
    return h;
}

void Write_Hanzi(r_drw2d_Device_t Dev,int PosX, int PosY, r_drw2d_Color_t  Color, uint16_t a[],uint16_t count)
{
    int                   startx,starty;
    
    static r_drw2d_Texture_t tex1,tex2;
    int  counti,countj,counta;
    int i,j;
    static r_drw2d_Rect_t rect;
    static r_drw2d_Rect_t src_rect;
    r_drw2d_EffectStage_t effect[2];
    uint32_t xPos, yPos;
    unsigned short xsrc,ysrc,wsrc,hsrc;
    i=0;
    j=0;
    counta =0;
    tex1.Buffer.Data =  0x134F9020u;//0x106b2c00;
    tex1.Buffer.Pitch = 3000;
    tex1.Buffer.PixelFormat = R_DRW2D_PIXELFORMAT_AL8;
    tex1.Buffer.Size.Height = 2200;
    tex1.Buffer.Size.Width = 3000;
    tex1.Flags = R_DRW2D_TEX_BILINEAR;
    tex1.Handle = 0;
  
    R_DRW2D_CtxIdentity(Dev);
    R_DRW2D_CtxTextureIdentity(Dev);

    R_DRW2D_CtxBlendMode(Dev, R_DRW2D_BLENDMODE_SRC_OVER);
    R_DRW2D_CtxFillMode(Dev, R_DRW2D_FILLMODE_TEXTURE);

    effect[0].Name = R_DRW2D_EFFECT_MODULATE;
    effect[0].Args[0].Source = R_DRW2D_EFFECT_SOURCE_TEXTURE_UNIT;
    effect[0].Args[0].Param.Color.Source.TextureUnit = 0;
    effect[0].Args[0].Param.Color.Operand = R_DRW2D_EFFECT_COLOR_OPERAND_RGBA;
    effect[0].Args[1].Source = R_DRW2D_EFFECT_SOURCE_CONSTANT_COLOR;
    effect[0].Args[1].Param.Color.Source.ConstantColor = Color;
    effect[0].Args[1].Param.Color.Operand = R_DRW2D_EFFECT_COLOR_OPERAND_RGBA;

    R_DRW2D_CtxEffectsSet(Dev, effect, 1);
    R_DRW2D_CtxTextureSet(Dev, 0, &tex1);
 
    startx = PosX;
    starty = PosY;
	
	PosY= starty;
	PosX= startx; 


   for(int i=0;i<count ;i++)
   {
      	counta = a[i]; 	
	if((counta>0x0020)&&(counta<0x007f))//CJK latin zihao 20,15*15.
	{
	 xsrc =Hansans00002ce20[counta].Xpos;
	 ysrc =Hansans00002ce20[counta].Ypos;
	 wsrc =Hansans00002ce20[counta].Width;
	 hsrc =Hansans00002ce20[counta].Height;

	 rect.Pos.X = R_DRW2D_2X(PosX);
	 rect.Pos.Y = R_DRW2D_2X(PosY+(15-hsrc)/2);
	 rect.Size.Width  = R_DRW2D_2X(wsrc);
	 rect.Size.Height = R_DRW2D_2X(hsrc);

	 src_rect.Pos.X = R_DRW2D_2X(xsrc);
	 src_rect.Pos.Y = R_DRW2D_2X(ysrc);
	 src_rect.Size.Width = R_DRW2D_2X(wsrc);
	 src_rect.Size.Height = R_DRW2D_2X(hsrc);
	 
	 R_DRW2D_TextureBlit(Dev, &src_rect, &rect);

	 PosX += wsrc ;

	}
	else if((counta>0x33ff)&&(counta<0x4db6))//CJK siyuanheiti zihao 20,15*15.
	{
	 counta -=0x2a5f;
	 xsrc =Hansans00002ce20[counta].Xpos;
	 ysrc =Hansans00002ce20[counta].Ypos;
	 wsrc =Hansans00002ce20[counta].Width;
	 hsrc =Hansans00002ce20[counta].Height;
	 rect.Pos.X = R_DRW2D_2X(PosX);
	 rect.Pos.Y = R_DRW2D_2X(PosY+(15-hsrc)/2);
	 rect.Size.Width  = R_DRW2D_2X(wsrc);
	 rect.Size.Height = R_DRW2D_2X(hsrc);

	 src_rect.Pos.X = R_DRW2D_2X(xsrc);
	 src_rect.Pos.Y = R_DRW2D_2X(ysrc);
	 src_rect.Size.Width = R_DRW2D_2X(wsrc);
	 src_rect.Size.Height = R_DRW2D_2X(hsrc);
	 R_DRW2D_TextureBlit(Dev, &src_rect, &rect);

	 PosX += wsrc ;
	 }
	 else if((counta>0x4e00)&&(counta<0xa000))//CJK siyuanheiti zihao 20,15*15.
	 {
	 counta -=0x2aa9;
	 xsrc =Hansans00002ce20[counta].Xpos;
	 ysrc =Hansans00002ce20[counta].Ypos;
	 wsrc =Hansans00002ce20[counta].Width;
	 hsrc =Hansans00002ce20[counta].Height;

	 rect.Pos.X = R_DRW2D_2X(PosX);
	 rect.Pos.Y = R_DRW2D_2X(PosY+(15-hsrc)/2);
	 rect.Size.Width  = R_DRW2D_2X(wsrc);
	 rect.Size.Height = R_DRW2D_2X(hsrc);

	 src_rect.Pos.X = R_DRW2D_2X(xsrc);
	 src_rect.Pos.Y = R_DRW2D_2X(ysrc);
	 src_rect.Size.Width = R_DRW2D_2X(wsrc);
	 src_rect.Size.Height = R_DRW2D_2X(hsrc);
	 
	 R_DRW2D_TextureBlit(Dev, &src_rect, &rect);

	 PosX += wsrc ;
	 }
	 else
	 {
	 counta =0x03f7;
	 xsrc =Hansans00002ce20[counta].Xpos;
	 ysrc =Hansans00002ce20[counta].Ypos;
	 wsrc =Hansans00002ce20[counta].Width;
	 hsrc =Hansans00002ce20[counta].Height;

	 rect.Pos.X = R_DRW2D_2X(PosX);
	 rect.Pos.Y = R_DRW2D_2X(PosY+(15-hsrc)/2);
	 rect.Size.Width  = R_DRW2D_2X(wsrc);
	 rect.Size.Height = R_DRW2D_2X(hsrc);

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0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
};

void Write_String(r_drw2d_Device_t Dev,int PosX, int PosY, r_drw2d_Color_t  Color, char *Text)
{
    
    int                   startx;
    static r_drw2d_Texture_t tex1;
    
    static r_drw2d_Rect_t rect;
    static r_drw2d_Rect_t src_rect;
    r_drw2d_EffectStage_t effect[2];
    uint32_t xPos, yPos;
    tex1.Buffer.Data = &EnglishFont;
    tex1.Buffer.Pitch =  850;/* Pic_Attribute[FONT_English].u16Pic_Width;*/
    tex1.Buffer.PixelFormat = R_DRW2D_PIXELFORMAT_AL8;
    tex1.Buffer.Size.Height =  19;/*Pic_Attribute[FONT_English].u16Pic_Height;*/
    tex1.Buffer.Size.Width =   850;/*Pic_Attribute[FONT_English].u16Pic_Width;*/
    tex1.Flags = R_DRW2D_TEX_BILINEAR;
    tex1.Handle = 0;


    R_DRW2D_CtxIdentity(Dev);
    R_DRW2D_CtxTextureIdentity(Dev);

    R_DRW2D_CtxBlendMode(Dev, R_DRW2D_BLENDMODE_SRC_OVER);
    R_DRW2D_CtxFillMode(Dev, R_DRW2D_FILLMODE_TEXTURE);

    effect[0].Name = R_DRW2D_EFFECT_MODULATE;
    effect[0].Args[0].Source = R_DRW2D_EFFECT_SOURCE_TEXTURE_UNIT;
    effect[0].Args[0].Param.Color.Source.TextureUnit = 0;
    effect[0].Args[0].Param.Color.Operand = R_DRW2D_EFFECT_COLOR_OPERAND_RGBA;
    effect[0].Args[1].Source = R_DRW2D_EFFECT_SOURCE_CONSTANT_COLOR;
    effect[0].Args[1].Param.Color.Source.ConstantColor = Color;
    effect[0].Args[1].Param.Color.Operand = R_DRW2D_EFFECT_COLOR_OPERAND_RGBA;

    R_DRW2D_CtxEffectsSet(Dev, effect, 1);
    R_DRW2D_CtxTextureSet(Dev, 0, &tex1);

    startx = PosX;
    while (*Text != 0)
    {
        if (*Text == '\n')
        {
            PosX  = startx;
	    PosY += 19;
        }
        else
        {
            locWriteChar(Dev, PosX, PosY, *Text);
            PosX += GetCharWidth(*Text);
        }
        Text++;
    } 
    
    R_DRW2D_CtxEffectsDelete(Dev);

}