void renderTextbox()
{
Rect clipRect;
Rect frameRect = {0,0,488,16};
//get xBase and yBase
int xBase = 77;
int yBase, i;
if (msgState & 1) //if the message box is at the top
yBase = 40;
else
yBase = 348;
clipRect.left = xBase + 17;
clipRect.right = clipRect.left + 460;
clipRect.up = yBase + 16;
clipRect.down = clipRect.up + 96;
if (msgState & 0x40) { //show the box
rectBlit(BMP_TEXTBOX, frameRect, xBase, yBase);
frameRect.up += 16;
frameRect.down += 16;
for (i = 1; i < 7; i++)
rectBlit(BMP_TEXTBOX, frameRect, xBase, yBase + i*16);
frameRect.up += 16;
frameRect.down += 16;
rectBlit(BMP_TEXTBOX, frameRect, xBase, yBase + 0x70);
}
if (msgState & 0x80) { //show the text
frameRect.up = 0;
frameRect.right = 460;
frameRect.down = 20;
int currentRow; //current row -> the current top row
if (textRow > 2)
currentRow = (textRow-2)%4;
else
currentRow = 0;
//offset the text from the face
int txtOff = 20;
if (currentFace)
txtOff += 100;
//update the face position
if (facePos < 90)
facePos += 16;
//update text position
if (textOffset > 0)
textOffset -= 3;
for (i = 0; i < 4; i++) { //for each thing
clipBlit(BMP_TEXT1 + currentRow, frameRect, xBase + txtOff, yBase + (LINE_SPACING * i) - 12 + textOffset, clipRect);
currentRow++;
if (currentRow > 3)
currentRow = 0;
} //for each text obj.
//render the face
if (currentFace) {
int faceSize = 96;
frameRect.left = (currentFace % 6) * faceSize;
frameRect.up = (currentFace / 6) * faceSize;
frameRect.right = frameRect.left + faceSize;
frameRect.down = frameRect.up + faceSize;
clipBlit(BMP_FACE, frameRect, facePos, yBase + 12, clipRect);
}
//render cursor blip
if (!(msgState & 2)) {
frameRect.left = 476;
frameRect.up = 64;
frameRect.right = frameRect.left + 12;
frameRect.down = frameRect.up + 20;
if ((blipTimer++%20)>12) {
if (tscState == 2) {
int lastRow = textRow;
if (lastRow > 2)
lastRow = 2;
int blipX = FONT_WIDTH * (textColumn+1) + xBase + txtOff;
int blipY = yBase + lastRow * LINE_SPACING + 20 + textOffset;
clipBlit(BMP_TEXTBOX, frameRect, blipX, blipY, clipRect);
}
}
}
}//if showText
//render yes/no box
if (tscState == 6) {
frameRect.left = 304;
frameRect.up = 96;
frameRect.right = frameRect.left + 160;
frameRect.down = frameRect.up + 64;
rectBlit(BMP_TEXTBOX, frameRect, 434, 288);
frameRect.left = 224;
frameRect.up = 176;
frameRect.right = frameRect.left + 32;
frameRect.down = frameRect.up + 32;
rectBlit(BMP_TEXTBOX, frameRect, 422 + 80*selectionCursor, 308);
}
}