Permalink
Browse files

added black bands and text and textcolor.

  • Loading branch information...
Fabien Sanglard
Fabien Sanglard committed Feb 6, 2014
1 parent d75fcab commit 6dd6d32e59d0615ca7be952c6ef6a8b4f8ac4b19
@@ -210,9 +210,8 @@
isa = PBXGroup;
children = (
2D8460ED18939EFA00B652A8 /* precomp.h */,
2DABC59A189C2C47005A172A /* ids */,
2DABC592189C2329005A172A /* CONVS */,
2DABC591189C2323005A172A /* animations */,
2DABC59A189C2C47005A172A /* ids */,
2D8460F9189561B800B652A8 /* menues */,
2D8460F41894389A00B652A8 /* activities */,
2D8460E618939D1100B652A8 /* GameEngine.h */,
@@ -230,6 +229,7 @@
2D8460F41894389A00B652A8 /* activities */ = {
isa = PBXGroup;
children = (
2DABC592189C2329005A172A /* CONVS */,
2D9F30C9189BEA2900712A62 /* OPTIONS */,
2D8460E918939D8E00B652A8 /* IActivity.h */,
2D8460E818939D8E00B652A8 /* IActivity.cpp */,
@@ -118,10 +118,10 @@ void RLEShape::Init(uint8_t* idata, size_t isize){
this->size = isize;
this->data = idata;
/*this->rightDist=*/ stream.ReadShort();
this->leftDist = stream.ReadShort();
this->topDist = stream.ReadShort();
/*this->botDist=*/ stream.ReadShort();
this->rightDist= stream.ReadShort();
this->leftDist = stream.ReadShort();
this->topDist = stream.ReadShort();
this->botDist= stream.ReadShort();
/*rleCenter= dst->data + abs(leftDist) + abs(topDist) * dst->width;*/
data = stream.GetPosition();
@@ -166,6 +166,9 @@ bool RLEShape::WriteColor(uint8_t* dst,int16_t dx, int16_t dy, uint8_t color){
if (finalDest < dst || finalDest >= dst+(320*200))
return true;
color+= colorOffset;
*finalDest = color;
return false;
@@ -26,8 +26,21 @@ class RLEShape{
this->position = *position;
}
inline void SetPositionX(int32_t x){
this->position.x = x;
}
static RLEShape* GetEmptyShape(void);
int32_t GetWidth(void){ return leftDist + this->rightDist;}
int32_t GetHeight(void){ return topDist+botDist;}
int32_t GetTop(void){ return topDist;}
int32_t GetBottom(void){ return botDist;}
void SetColorOffset(size_t offset){ this->colorOffset = offset;}
private:
ByteStream stream;
@@ -54,7 +67,10 @@ class RLEShape{
int16_t leftDist;
int16_t topDist;
int16_t rightDist;
int16_t botDist;
size_t colorOffset;
bool WriteColor(uint8_t* dst,int16_t dx, int16_t dy, uint8_t color);
};
@@ -19,16 +19,20 @@ RSFontManager::~RSFontManager(){
void RSFontManager::Init(void){
/*
const char* fontPath = "..\\..\\DATA\\GAMEFLOW\\BWFONT.SHP";
const char* trePath = "GAMEFLOW.TRE";
TreArchive GAMEFLOW;
GAMEFLOW.InitFromFile(trePath);
TreEntry* convFontEntry = GAMEFLOW.GetEntryByName(fontPath);
*/
//Find the sounds PAKS.
TreEntry* convFontEntry = GAMEFLOW.GetEntryByName(fontPath);
const char* fontPath = "..\\..\\DATA\\FONTS\\CONVFONT.SHP";
const char* trePath = "MISC.TRE";
TreArchive MISC;
MISC.InitFromFile(trePath);
TreEntry* convFontEntry = MISC.GetEntryByName(fontPath);
PakArchive fontArch;
@@ -24,14 +24,15 @@ class RSVGA{
VGAPalette* GetPalette(void);
bool DrawShape(RLEShape* shape);
void DrawText (RSFont* font, Point2D* coo, char* text, uint8_t color);
void DrawText(RSFont* font, Point2D* coo, char* text, uint8_t color,size_t start, size_t end);
void VSync(void);
void Clear(void);
inline uint8_t* GetFrameBuffer(void){ return frameBuffer;}
void FillLineColor(size_t lineIndex, uint8_t color);
private:
VGAPalette palette;
@@ -124,33 +124,45 @@ void RSVGA::VSync(void){
}
void RSVGA::DrawText(RSFont* font, Point2D* coo, char* text, uint8_t color){
void RSVGA::FillLineColor(size_t lineIndex, uint8_t color){
memset(frameBuffer+lineIndex*320, color, 320);
}
void RSVGA::DrawText(RSFont* font, Point2D* coo, char* text, uint8_t color,size_t start, size_t end){
if (text == NULL)
return;
size_t textSize = strlen(text);
if ( textSize == 0 )
if ( start+end > textSize ||start >= textSize)
return;
int32_t leftMargin = coo->x;
// printf("RSVGA: Show Text: '%s' \n",text);
for (size_t i =0; i < textSize; i++) {
for (size_t i =start; i < end; i++) {
RLEShape* shape = font->GetShapeForChar(text[i]);
shape->SetColorOffset(color);
//Adjust height
int32_t lineHeight = coo->y;
coo->y -= shape->GetHeight();
if (text[i]== 'p' ||
text[i]== 'y' ||
text[i]== 'g' )
coo->y += 1;
shape->SetPosition(coo);
DrawShape(shape);
coo->y = lineHeight;
coo->x+=shape->GetWidth() + 3;
if (coo->x == 320 - leftMargin){
coo->x=leftMargin;
coo->y+= 10;
}
else
coo->x+=10;
}
}
@@ -64,6 +64,7 @@ uint8_t ConvAssetManager::GetFacePaletteID(char* name){
return this->facePalettes[name]->index;
}
void ConvAssetManager::ParseBGLayer(uint8_t* data, size_t layerID,ConvBackGround* back ){
ByteStream dataReader ;
@@ -122,9 +123,13 @@ void ConvAssetManager::ParseBGLayer(uint8_t* data, size_t layerID,ConvBackGround
*s = *RLEShape::GetEmptyShape();
return;
}
else
else{
s->Init(subPAK.GetEntry(0)->data, subPAK.GetEntry(0)->size);
if (s->GetHeight() < 199){ // If this is not a background, we need to move down
Point2D pos = {0,CONV_TOP_BAR_HEIGHT+1}; // to allow the black band on top of the screen
s->SetPosition(&pos);
}
}
back->layers.push_back(s);
back->palettes.push_back(paletteArchive->GetEntry(paletteID)->data);
@@ -175,6 +180,17 @@ void ConvAssetManager::ReadFaces(const IffChunk* root){
RSImageSet* imageSet = new RSImageSet();
imageSet->InitFromPakEntry(convShps.GetEntry(pakID));
face->appearances = imageSet;
for (size_t fid=0; fid < imageSet->GetNumImages(); fid++) {
RLEShape*s = imageSet->GetShape(fid);
Point2D pos = {0,CONV_TOP_BAR_HEIGHT+1}; // to allow the black band on top of the screen
s->SetPosition(&pos);
}
printf("Face '%s' features %lu images.\n",face->name,imageSet->GetNumImages());
@@ -9,7 +9,8 @@
#ifndef __libRealSpace__ConAssetManager__
#define __libRealSpace__ConAssetManager__
#define CONV_TOP_BAR_HEIGHT 23
#define CONV_BOTTOM_BAR_HEIGHT 48
typedef struct CharFace{
Oops, something went wrong.

0 comments on commit 6dd6d32

Please sign in to comment.