From 9de2c05c5602293a11a57f2e88d4575230a4e105 Mon Sep 17 00:00:00 2001 From: tron Date: Sat, 10 Sep 2005 08:17:30 +0000 Subject: [PATCH] (svn r2933) Implement the non-breaking space --- gfx.c | 6 +++--- gfx.h | 2 +- gfxinit.c | 7 +++++-- spritecache.c | 8 ++++++++ spritecache.h | 1 + strgen/strgen.c | 4 +++- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gfx.c b/gfx.c index 38c6cd009a..f86d4b9c63 100644 --- a/gfx.c +++ b/gfx.c @@ -1627,15 +1627,15 @@ void LoadStringWidthTable(void) // 2 equals space. for (i = 2; i != 226; i++) { - *b++ = (i < 93 || i > 113) && i != 116 && i != 117 && (i < 123 || i > 129) && (i < 151 || i > 153) && i != 155 ? GetSprite(i)->width : 0; + *b++ = (i < 93 || i > 97) && (i < 99 || i > 113) && i != 116 && i != 117 && (i < 123 || i > 129) && (i < 151 || i > 153) && i != 155 ? GetSprite(i)->width : 0; } for (i = 226; i != 450; i++) { - *b++ = (i < 317 || i >= 354) && i != 367 && (i < 375 || i > 377) && i != 379 ? GetSprite(i)->width + 1 : 0; + *b++ = (i < 317 || i > 321) && (i < 323 || i > 353) && i != 367 && (i < 375 || i > 377) && i != 379 ? GetSprite(i)->width + 1 : 0; } for (i = 450; i != 674; i++) { - *b++ = (i < 541 || i >= 579) && i != 585 && i != 587 && i != 588 && (i < 590 || i > 597) && (i < 599 || i > 601) && i != 603 && i != 633 && i != 665 ? GetSprite(i)->width + 1 : 0; + *b++ = (i < 541 || i > 577) && i != 585 && i != 587 && i != 588 && (i < 590 || i > 597) && (i < 599 || i > 601) && i != 603 && i != 633 && i != 665 ? GetSprite(i)->width + 1 : 0; } } diff --git a/gfx.h b/gfx.h index d0568a78dd..92f62a4ec0 100644 --- a/gfx.h +++ b/gfx.h @@ -41,7 +41,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo); // XXX doesn't really belong here, but the only // consumers always use it in conjunction with DoDrawString() -#define UPARROW "\xA0" +#define UPARROW "\x80" #define DOWNARROW "\xAA" diff --git a/gfxinit.c b/gfxinit.c index f1bd93659e..f32c826266 100644 --- a/gfxinit.c +++ b/gfxinit.c @@ -192,7 +192,7 @@ static const SpriteID trg1idx[] = { 2, 92, // ' ' till 'z' 0xFFFE, 36, 160, 160, // Move ¾ to the correct position - 130, 130, // TODO Up arrow + 98, 98, // Up arrow 131, 133, 0xFFFE, 1, // skip currency sign 135, 135, @@ -219,7 +219,7 @@ static const SpriteID trg1idx[] = { 342, 346, // place holders for transport markers 0xFFFE, 6, 384, 384, // Move ¾ to the correct position - 354, 354, // TODO Up arrow + 322, 322, // Up arrow 355, 357, 0xFFFE, 1, // skip currency sign 359, 359, @@ -316,6 +316,9 @@ static void LoadSpriteTables(void) files = _use_dos_palette? &files_dos : &files_win; LoadGrfIndexed(files->basic[0].filename, trg1idx, 0); + DupSprite( 2, 130); // non-breaking space medium + DupSprite(226, 354); // non-breaking space tiny + DupSprite(450, 578); // non-breaking space large load_index = 4793; for (i = 1; files->basic[i].filename != NULL; i++) { diff --git a/spritecache.c b/spritecache.c index 967538125d..df64970faf 100644 --- a/spritecache.c +++ b/spritecache.c @@ -155,6 +155,14 @@ bool LoadNextSprite(int load_index, byte file_index) return true; } + +void DupSprite(SpriteID old, SpriteID new) +{ + _sprite_file_pos[new] = _sprite_file_pos[old]; + _sprite_ptr[new] = NULL; +} + + void SkipSprites(uint count) { for (; count > 0; --count) { diff --git a/spritecache.h b/spritecache.h index c2ff671340..ebc37de2b5 100644 --- a/spritecache.h +++ b/spritecache.h @@ -28,6 +28,7 @@ void GfxInitSpriteMem(void); void IncreaseSpriteLRU(void); bool LoadNextSprite(int load_index, byte file_index); +void DupSprite(SpriteID old, SpriteID new); void SkipSprites(uint count); #endif diff --git a/strgen/strgen.c b/strgen/strgen.c index 719f91833a..84df5fa17d 100644 --- a/strgen/strgen.c +++ b/strgen/strgen.c @@ -465,7 +465,9 @@ static const CmdStruct _cmd_structs[] = { // 0x9E=158 is the LAST special character we may use. - {"UPARROW", EmitSingleByte, 0xA0, 0}, + {"UPARROW", EmitSingleByte, 0x80, 0}, + + {"NBSP", EmitSingleByte, 0xA0, 0, C_DONTCOUNT}, {"POUNDSIGN", EmitSingleByte, 0xA3, 0}, {"YENSIGN", EmitSingleByte, 0xA5, 0}, {"COPYRIGHT", EmitSingleByte, 0xA9, 0},