shithub: ft²

Download patch

ref: 506d1b78eb878807fbc889cad6c14de881d7f063
parent: 3a734ed06d829dae5e48c0290a6d7269a117dba2
author: Olav Sørensen <[email protected]>
date: Sat Dec 28 10:54:49 EST 2019

Pushed v1.05 code

- Bugfix: When copying marked text in a text box, too much data would be copied
- Changed default WAV rendering frequency (Harddisk recording) to 48kHz

--- a/src/ft2_about.c
+++ b/src/ft2_about.c
@@ -7,7 +7,7 @@
 
 // ported from original FT2 code
 
-#define NUM_STARS 512
+#define NUM_STARS 650
 #define ABOUT_SCREEN_W 626
 #define ABOUT_SCREEN_H 167
 #define FT2_LOGO_W 449
@@ -113,7 +113,7 @@
 			hastighet = 0;
 			for (i = 0; i < NUM_STARS; i++)
 			{
-				if (i < (NUM_STARS / 4))
+				if (i < NUM_STARS/4)
 				{
 					starcrd[i].z = (int16_t)random32(0xFFFF) - 0x8000;
 					starcrd[i].y = (int16_t)random32(0xFFFF) - 0x8000;
@@ -127,8 +127,8 @@
 					ww = (((M_PI * 2.0) / 5.0) * n) + (r / 12000.0) + (w / 3000000.0);
 					h = ((sqr(r) / 30000) * (random32(10000) - 5000)) / 12000;
 
-					starcrd[i].x = (int16_t)trunc(r * cos(ww));
-					starcrd[i].y = (int16_t)trunc(r * sin(ww));
+					starcrd[i].x = (int16_t)(r * cos(ww));
+					starcrd[i].y = (int16_t)(r * sin(ww));
 					starcrd[i].z = (int16_t)h;
 				}
 			}
@@ -156,6 +156,10 @@
 			break;
 	}
 
+	star_a.x = 0;
+	star_a.y = 748;
+	star_a.z = 200;
+
 	for (i = 0; i < NUM_STARS; i++)
 		lastStarScreenPos[i] = -1;
 }
@@ -186,7 +190,8 @@
 		star = &starcrd[i];
 		star->z += hastighet;
 
-		z = (((xz * star->x) >> 16) + ((yz * star->y) >> 16) + ((zz * star->z) >> 16)) + 9000;
+		z = ((xz * star->x) >> 16) + ((yz * star->y) >> 16) + ((zz * star->z) >> 16);
+		z += 9000;
 		if (z <= 100)
 			continue;
 
@@ -207,7 +212,7 @@
 			col = ((uint8_t)~(z >> 8) >> 3) - (22 - 8);
 			if (col < 24)
 			{
-				video.frameBuffer[screenBufferPos] = video.palette[starColConv[col]] & 0xFFFFFF;
+				video.frameBuffer[screenBufferPos] = video.palette[starColConv[col]] & 0x00FFFFFF;
 				lastStarScreenPos[i] = screenBufferPos;
 			}
 		}
@@ -245,12 +250,12 @@
 
 	x = 5 + (SCREEN_W - textWidth(infoString)) / 2;
 	y = 147;
-	textOut(x, y, PAL_FORGRND, infoString);
+	textOutBorder(x, y, PAL_FORGRND, PAL_BUTTON2, infoString);
 
 	sprintf(verText, "v%s (compiled on %s)", PROG_VER_STR, __DATE__);
 	x = ((3 + ABOUT_SCREEN_W) - textWidth(verText)) / 2;
 	y = (3 + ABOUT_SCREEN_H) - ((FONT1_CHAR_H - 2) + 3);
-	textOut(x, y, PAL_FORGRND, verText);
+	textOutBorder(x, y, PAL_FORGRND, PAL_BUTTON2, verText);
 
 	aboutInit();
 
--- a/src/ft2_gui.c
+++ b/src/ft2_gui.c
@@ -520,6 +520,16 @@
 	}
 }
 
+void textOutBorder(uint16_t x, uint16_t y, uint8_t paletteIndex, uint8_t borderPaletteIndex, const char *textPtr)
+{
+	textOut(x,   y-1, borderPaletteIndex, textPtr); // top
+	textOut(x+1, y,   borderPaletteIndex, textPtr); // right
+	textOut(x,   y+1, borderPaletteIndex, textPtr); // bottom
+	textOut(x-1, y,   borderPaletteIndex, textPtr); // left
+
+	textOut(x, y, paletteIndex, textPtr);
+}
+
 // fixed width
 void textOutFixed(uint16_t x, uint16_t y, uint8_t fgPaltete, uint8_t bgPalette, const char *textPtr)
 {
--- a/src/ft2_gui.h
+++ b/src/ft2_gui.h
@@ -93,6 +93,7 @@
 void charOutShadow(uint16_t x, uint16_t y, uint8_t paletteIndex, uint8_t shadowPaletteIndex, char chr);
 void charOutOutlined(uint16_t x, uint16_t y, uint8_t paletteIndex, char chr);
 void textOut(uint16_t x, uint16_t y, uint8_t paletteIndex, const char *textPtr);
+void textOutBorder(uint16_t x, uint16_t y, uint8_t paletteIndex, uint8_t borderPaletteIndex, const char *textPtr);
 void textOutFixed(uint16_t x, uint16_t y, uint8_t fgPaltete, uint8_t bgPalette, const char *textPtr);
 void bigTextOut(uint16_t x, uint16_t y, uint8_t paletteIndex, const char *textPtr);
 void bigTextOutShadow(uint16_t x, uint16_t y, uint8_t paletteIndex, uint8_t shadowPaletteIndex, const char *textPtr);
--- a/src/ft2_header.h
+++ b/src/ft2_header.h
@@ -12,7 +12,7 @@
 #endif
 #include "ft2_replayer.h"
 
-#define PROG_VER_STR "1.04"
+#define PROG_VER_STR "1.05"
 
 // do NOT change these! It will only mess things up...
 
--- a/src/ft2_textboxes.c
+++ b/src/ft2_textboxes.c
@@ -223,7 +223,7 @@
 static void copyMarkedText(textBox_t *t)
 {
 	int32_t length, start, end;
-	char *utf8Text;
+	char *utf8Text, oldChar;
 
 	if (!textIsMarked())
 		return;
@@ -237,6 +237,14 @@
 	if (length < 1)
 		return;
 
+	/* Change mark-end character to NUL so that we
+	 * we only copy the marked section of the string.
+	 * There's always room for a NUL at the end of
+	 * the text box string, so this is safe.
+	 */
+	oldChar = t->textPtr[end];
+	t->textPtr[end] = '\0';
+
 	utf8Text = cp437ToUtf8(&t->textPtr[start]);
 	if (utf8Text != NULL)
 	{
@@ -243,6 +251,8 @@
 		SDL_SetClipboardText(utf8Text);
 		free(utf8Text);
 	}
+
+	t->textPtr[end] = oldChar; // set back original character
 }
 
 static void cutMarkedText(textBox_t *t)
--- a/src/ft2_wav_renderer.c
+++ b/src/ft2_wav_renderer.c
@@ -18,7 +18,7 @@
 #include "ft2_audio.h"
 #include "ft2_wav_renderer.h"
 
-#define TICKS_PER_RENDER_CHUNK 32
+#define TICKS_PER_RENDER_CHUNK 64
 
 enum
 {
@@ -38,7 +38,7 @@
 static char WAV_SysReqText[192];
 static uint8_t WDBitDepth = 16, WDStartPos, WDStopPos, *wavRenderBuffer;
 static int16_t WDAmp;
-static uint32_t WDFrequency = 44100;
+static uint32_t WDFrequency = 48000;
 static SDL_Thread *thread;
 
 static void updateWavRenderer(void)