ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

commit 506d1b78eb878807fbc889cad6c14de881d7f063
parent 3a734ed06d829dae5e48c0290a6d7269a117dba2
Author: Olav Sørensen <olav.sorensen@live.no>
Date:   Sat, 28 Dec 2019 15:54:22 +0100

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

Diffstat:
Msrc/ft2_about.c | 21+++++++++++++--------
Msrc/ft2_gui.c | 10++++++++++
Msrc/ft2_gui.h | 1+
Msrc/ft2_header.h | 2+-
Msrc/ft2_textboxes.c | 12+++++++++++-
Msrc/ft2_wav_renderer.c | 4++--
6 files changed, 38 insertions(+), 12 deletions(-)

diff --git 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 @@ static void aboutInit(void) 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 @@ static void aboutInit(void) 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 @@ static void aboutInit(void) 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 @@ static void realStars(void) 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 @@ static void realStars(void) 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 @@ void showAboutScreen(void) // called once when About screen is opened 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(); diff --git a/src/ft2_gui.c b/src/ft2_gui.c @@ -520,6 +520,16 @@ 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) +{ + 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) { diff --git a/src/ft2_gui.h b/src/ft2_gui.h @@ -93,6 +93,7 @@ void bigCharOut(uint16_t xPos, uint16_t yPos, uint8_t paletteIndex, char chr); 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); diff --git 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... diff --git a/src/ft2_textboxes.c b/src/ft2_textboxes.c @@ -223,7 +223,7 @@ static void setCursorToMarkEnd(textBox_t *t) static void copyMarkedText(textBox_t *t) { int32_t length, start, end; - char *utf8Text; + char *utf8Text, oldChar; if (!textIsMarked()) return; @@ -237,12 +237,22 @@ static void copyMarkedText(textBox_t *t) 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) { SDL_SetClipboardText(utf8Text); free(utf8Text); } + + t->textPtr[end] = oldChar; // set back original character } static void cutMarkedText(textBox_t *t) diff --git 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 @@ typedef struct wavHeader_t 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)