From 8450e113fac90e6741baa07462aa7596da49c821 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Sun, 23 Mar 2025 16:43:35 +0100 Subject: [PATCH] Add scroll modifier --- TODO.txt | 2 +- assets.h | 45 +-------------------------------------------- data | 6 ------ game.h | 19 ++++++++++--------- renderer.h | 6 +++--- 5 files changed, 15 insertions(+), 63 deletions(-) diff --git a/TODO.txt b/TODO.txt index ee8f711..0709b16 100644 --- a/TODO.txt +++ b/TODO.txt @@ -7,7 +7,6 @@ data file, try to somehow hack around it (maybe just convert it to an array in the end?) Maybe this: make a standalone C file with the string in it that when compiled and run outputs the array. -- add indicator that menu can be scrolled down - car deglitch idea: deglitch only if the middle joint collided this frame? - some kinda easteregg in menu or smt - culling is very slow now, it showed that distance bailout can accelerate it @@ -69,6 +68,7 @@ =========== HANDLED ============== - add ifdefs that change car color? +- add indicator that menu can be scrolled down - sometimes getting a SLIGHTLY slower time counts as beating it (prolly conversion fail) (SEEMS FIXED NOW) - make a small txt game manual diff --git a/assets.h b/assets.h index 78f9aba..e6d5b49 100644 --- a/assets.h +++ b/assets.h @@ -61,51 +61,8 @@ static const char *LCR_texts[] = // TODO: define string for CLI arguments for frontends? static const char *LCR_internalDataFile = - "Mtestmap;" - "52123 1 :*H1k0" - - ":=s0s0 :fd19" // big concrete - - ":+w0o" - ":+v0n" - ":!x0n" - - ":^s1A0 :fk110" // ramps before wall - ":=s0B0 :fd910" // concrete wall - - ":nu0j1 :uy0j1 :AA0j1 " - - ":vw0m0" - ":vx0m0J" - ":vw0l0L" - ":vx0l0I" - - ":-s0q1" - - ":;p0w0L :f5130" // bugs - - ":>f0s0 :fd110" // small labyrinth - ":oc0p0 :fd110" - ":=f0s0 :f11d0" - ":=c0p0 :f11d0" - - ":=C0s1 :fd190" // big dirt - ":=M0s2 :fd190" // big grass - ":=W0s3 :fd190" // big ice - - ":(s0r0" // hill - ":~t1t2 :~u1t2 :~t1u2" // bumps - ":^t0r0 :fq110 " // ramps - - ":}n0l1J :|n1l1J :|n3l1J- :]n4l1J- :=o0l1 :f151" // loop - ":]n0m1J :|n1m1J :|n3m1J- :]n4m1J- :=o0m1 :f151" // loop - ":}l0k1L :|l1k1L :|l3k1L- :]l4k1L- :=k0k1 :f151" - ":]l0j1L :|l1j1L :|l3j1L- :]l4j1L- :=k0j1 :f151" - ":-k5k1 :f5120" - " map end " - // MAP 1: - "#MLC1;4321 0 " + "MLC1;4321 0 " ":*C2mL:!x6G:+L2H:+D38" // start, finish, CPs // pillars: ":nw0w2L:f151:m151" diff --git a/data b/data index 625500f..e69de29 100644 --- a/data +++ b/data @@ -1,6 +0,0 @@ -#RLCtiny5;00LCtiny5;5c14d8b6 0000283:0021:0153:0041:0069:00a1:0049:0081:0103:0061:0083:00b1:0079:0031:0033:0121:0053:0041:0033:0071:0099:0061:00b3:00c1:0093:0031:0043:0031:0053:0031:0043:0041:0033:0031:0075:0041:01b9:0021:0099:0041 -#BLCtiny5; -#RLC1;00LC1;8bd6e314 0000489:0181:0139:0041:00c9:0051:0049:0051:0039:0031:0039:0041:0039:0031:0049:0031:0049:0031:0189:0061:0045:0021:0039:0021:0059:0041:0039:00f1:0033:0071:00e9:0031:0059:0031:0039:0041:0149:0021:0109:0021:0105:0031:0243:0041:00b3:00f1:00a3:0081:00b3:0031:0415:0031:0099:0041:0073:0041 -#BLC1; -#RLC2;00LC2;3c5ba5dd 0000760:0131:0023:0071:00a9:0061:00a9:0051:0075:0041:0213:0031:0099:0041:0039:0031:0079:0071:00f3:0041:00a3:0071:0063:0031:0043:00a1:00b9:0031:0023:0091:0053:0031:00a3:0031:01c3:0041:0089:0031:0133:0021:0059:0021:00a5:0031:0113:0081:0053:0091:0033:0081:0083:0031:00f3:0021:00b3:0031:00d3:0031:0069:00a1:0079:0061:00a9:0041:0083:0071:0083:0031:0053:00b1:0053:00b1:03c3:0051:0025:0041:0043:0012:0066:0042:00b3:00d1:0279:0041:01c3:0021 -#BLC2; diff --git a/game.h b/game.h index 38f383e..6a59b85 100644 --- a/game.h +++ b/game.h @@ -894,7 +894,7 @@ void LCR_gameLoadMainMenuItems(void) LCR_game.menu.itemNames[j][i + 1] = 0; } - LCR_game.menu.itemCount = 4; + LCR_game.menu.itemCount = 5; } #define LCR_GAME_DATA_FILE_BUFFER_SIZE 32 @@ -940,7 +940,7 @@ void _LCR_gameDataCharWrite(char c) void LCR_gameLoadDataFileChunk(unsigned int startIndex, char magicNumber) { char c; - unsigned char state = 0; + unsigned char state = 0; // 0: read magic num., >= 1: read name, 255: skip LCR_gameEraseMenuItemNames(); @@ -963,7 +963,7 @@ void LCR_gameLoadDataFileChunk(unsigned int startIndex, char magicNumber) if (c == 0) return; - if (state == 0) // second magic char + if (state == 0) // magic number { state = 255; @@ -976,15 +976,14 @@ void LCR_gameLoadDataFileChunk(unsigned int startIndex, char magicNumber) else if (i == 1) state = 1; } - } else if (i == 1 && state != 255) { - if (c == LCR_DATA_FILE_SEPARATOR || - c == LCR_DATA_FILE_SEPARATOR2 || - state >= 1 + LCR_MENU_STRING_SIZE - 1) + if (c == LCR_DATA_FILE_SEPARATOR || c == LCR_DATA_FILE_SEPARATOR2 || + (state >= 1 + LCR_MENU_STRING_SIZE - 1)) { state = 255; + LCR_game.menu.itemCount++; if (LCR_game.menu.itemCount >= LCR_DATA_ITEM_CHUNK) @@ -1676,8 +1675,10 @@ uint8_t LCR_gameStep(uint32_t time) LCR_game.state == LCR_GAME_STATE_LOADING) LCR_rendererDrawMenu(LCR_texts[LCR_TEXTS_TABS + LCR_game.menu.selectedTab],LCR_game.menu.itemNamePtrs, - LCR_game.menu.itemCount + 1,LCR_game.menu.selectedItem); - + LCR_game.menu.itemCount,LCR_game.menu.selectedItem, + (LCR_game.menu.selectedTab > 0) && + LCR_game.dataFile.firstItemIndex + LCR_DATA_ITEM_CHUNK - 1 + < LCR_game.dataFile.itemsTotal); else LCR_gameDraw3DView(); diff --git a/renderer.h b/renderer.h index 9c7b1e0..a5cdebe 100644 --- a/renderer.h +++ b/renderer.h @@ -1822,7 +1822,7 @@ void LCR_rendererBlitImage(uint8_t index, unsigned int x, unsigned int y, } void LCR_rendererDrawMenu(const char *tabName,const char **items, - unsigned char itemCount,char selectedItem) + unsigned char itemCount,char selectedItem, char scroll) { int stripHeight = (2 * LCR_EFFECTIVE_RESOLUTION_Y) / 7; int stripHeight2 = LCR_EFFECTIVE_RESOLUTION_Y / 9; @@ -1881,9 +1881,9 @@ void LCR_rendererDrawMenu(const char *tabName,const char **items, i = stripHeight + (stripHeight2 - LCR_rendererComputeTextHeight(3)) / 2; - for (int j = 0; j < itemCount + 1; ++j) + for (int j = 0; j < itemCount + 1 + (scroll != 0) ; ++j) { - const char *s = j ? items[j - 1] : tabName; + const char *s = j ? (j <= itemCount ? items[j - 1] : "...") : tabName; const char *s2 = s; uint16_t textColor = 0x5aeb;