• R/O
  • SSH
  • HTTPS

oricsdk: Commit


Commit MetaInfo

Revision1711 (tree)
Time2023-10-01 16:29:51
Authordbug

Log Message

Added a PlayStream function to handle things like "reading the book" or "looking at the map", which allows using the bytecode system instead of C compiled code, resulting in quite a lot of memory saving.
Moved a few remaining hardcoded strings from out the game_main.c file

Change Summary

Incremental Difference

--- users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/common.h (revision 1710)
+++ users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/common.h (revision 1711)
@@ -92,6 +92,7 @@
9292 // game_misc
9393 extern void HandleByteStream();
9494 extern void SetByteStream(const char* byteStream);
95+extern void PlayStream(const char* byteStream);
9596
9697 extern const char* gCurrentStream;
9798 extern const unsigned int* gCurrentStreamInt;
--- users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_defines.h (revision 1710)
+++ users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_defines.h (revision 1711)
@@ -121,6 +121,8 @@
121121 extern const char gTextNotDead[]; // "Not dead" - Debugging text
122122 extern const char gTextDogJumpingAtMe[]; // "a dog jumping at me"
123123 extern const char gTextThugShootingAtMe[]; // "a thug shooting at me"
124+extern const char gTextAGenericWhiteBag[]; // "It's just a white generic bag"
125+extern const char gTextThickBookBookmarks[]; // "A thick book with some boomarks"
124126
125127 // Error messages
126128 extern const char gTextErrorInvalidDirection[]; // "Impossible to move in that direction"
@@ -147,6 +149,7 @@
147149 extern const char gTextErrorAlreadySearched[]; // "You've already frisked him"
148150 extern const char gTextErrorInappropriate[]; // "Probably inappropriate"
149151 extern const char gTextErrorDeadDontMove[]; // "Dead don't move"
152+extern const char gTextErrorNothingSpecial[]; // "Nothing special"
150153
151154 // Places
152155 extern const char gTextLocationMarketPlace[]; // "You are in a deserted market square"
@@ -262,3 +265,10 @@
262265 extern const char gTextItemLadderInTheHole[]; // "a ladder in a hole"
263266 extern const char gTextItemeRopeAttachedToATree[]; // "a rope attached to a tree"
264267
268+// Scene actions
269+extern const char gSceneActionReadNewsPaper[];
270+extern const char gSceneActionReadPrintedNote[];
271+extern const char gSceneActionReadChemistryRecipes[];
272+extern const char gSceneActionReadChemistryBook[];
273+extern const char gSceneActionInspectMap[];
274+
--- users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_main.c (revision 1710)
+++ users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_main.c (revision 1711)
@@ -550,15 +550,6 @@
550550 }
551551 }
552552
553-
554-void ShowFullScreenItem(int image_id, const char* description)
555-{
556- ClearMessageWindow(16+4);
557- LoadFileAt(image_id,ImageBuffer);
558- PrintTopDescription(description);
559- BlitBufferToHiresWindow();
560-}
561-
562553 char ItemCheck(unsigned char itemId)
563554 {
564555 if (itemId<e_ITEM_COUNT_)
@@ -586,31 +577,17 @@
586577 switch (itemId)
587578 {
588579 case e_ITEM_Newspaper:
589- ShowFullScreenItem(LOADER_PICTURE_NEWSPAPER,"The Daily Telegraph, September 29th");
590- PrintInformationMessage("I have to find her fast...");
591- WaitFrames(50*2);
592- PrintInformationMessage("...I hope she is fine!");
593- WaitFrames(50*2);
580+ PlayStream(gSceneActionReadNewsPaper);
594581 LoadScene();
595582 break;
596583
597584 case e_ITEM_PrintedNote:
598- ShowFullScreenItem(LOADER_PICTURE_HANDWRITTEN_NOTE,"A hand written note");
599- WaitFrames(50*2);
600- PrintInformationMessage("That could be useful...");
601- WaitFrames(50*2);
602- PrintInformationMessage("...if I can access it!");
603- WaitFrames(50*2);
585+ PlayStream(gSceneActionReadPrintedNote);
604586 LoadScene();
605587 break;
606588
607589 case e_ITEM_ChemistryBook:
608- ShowFullScreenItem(LOADER_PICTURE_SCIENCE_BOOK,"A science book");
609- WaitFrames(50*2);
610- PrintInformationMessage("I don't understand much...");
611- WaitFrames(50*2);
612- PrintInformationMessage("...but looks like someone took notes.");
613- WaitFrames(50*2);
590+ PlayStream(gSceneActionReadChemistryBook);
614591 if (gItems[e_ITEM_ChemistryRecipes].location==e_LOCATION_NONE)
615592 {
616593 // If the recipes were not yet found, they now appear at the current location
@@ -620,17 +597,12 @@
620597 break;
621598
622599 case e_ITEM_ChemistryRecipes:
623- ShowFullScreenItem(LOADER_PICTURE_CHEMISTRY_RECIPES,"A few useful recipes");
624- WaitFrames(50*2);
625- PrintInformationMessage("I can definitely use these...");
626- WaitFrames(50*2);
627- PrintInformationMessage("...just need to find the materials.");
628- WaitFrames(50*2);
600+ PlayStream(gSceneActionReadChemistryRecipes);
629601 LoadScene();
630602 break;
631603
632604 case e_ITEM_PlasticBag:
633- PrintErrorMessage("It's just a white generic bag");
605+ PrintErrorMessage(gTextAGenericWhiteBag); // "It's just a white generic bag"
634606 break;
635607
636608 default:
@@ -819,18 +791,16 @@
819791 switch (itemId)
820792 {
821793 case e_ITEM_UnitedKingdomMap:
822- ShowFullScreenItem(LOADER_PICTURE_UK_MAP,"A map of the United Kingdom");
823- PrintInformationMessage("It shows Ireland, Wales and England");
824- WaitFrames(50*2);
794+ PlayStream(gSceneActionInspectMap);
825795 LoadScene();
826796 break;
827797
828798 case e_ITEM_ChemistryBook:
829- PrintInformationMessage("A thick book with some boomarks");
799+ PrintInformationMessage(gTextThickBookBookmarks); // "A thick book with some boomarks"
830800 break;
831801
832802 default:
833- PrintErrorMessage("Nothing special");
803+ PrintErrorMessage(gTextErrorNothingSpecial); // "Nothing special"
834804 break;
835805 }
836806 }
@@ -1182,6 +1152,10 @@
11821152 //gCurrentLocation =e_LOCATION_NARROWPATH;
11831153 //gCurrentLocation = e_LOCATION_LIBRARY;
11841154 //gItems[e_ITEM_PlasticBag].location = e_LOCATION_INVENTORY;
1155+
1156+ gItems[e_ITEM_ChemistryBook].location = e_LOCATION_INVENTORY;
1157+ gCurrentLocation =e_LOCATION_LIBRARY;
1158+
11851159 #else
11861160 // In normal gameplay, the player starts from the marketplace with an empty inventory
11871161 gCurrentLocation = e_LOCATION_MARKETPLACE;
--- users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_misc.c (revision 1710)
+++ users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_misc.c (revision 1711)
@@ -83,7 +83,21 @@
8383 }
8484
8585
86+void PlayStream(const char* byteStream)
87+{
88+ const char* originalByteStream = gCurrentStream;
89+ gCurrentStream = byteStream;
90+ gDelayStream = 0;
8691
92+ do
93+ {
94+ WaitIRQ();
95+ HandleByteStream();
96+ }
97+ while (gCurrentStream);
98+}
99+
100+
87101 // The various commands:
88102 // - COMMAND_END indicates the end of the stream
89103 // - COMMAND_BUBBLE draws speech bubble and requires a number of parameters:
@@ -156,6 +170,13 @@
156170 }
157171 break;
158172
173+ case COMMAND_INFO_MESSAGE:
174+ {
175+ PrintInformationMessage(gCurrentStream); // Should probably return the length or pointer to the end of string
176+ gCurrentStream += strlen(gCurrentStream)+1;
177+ }
178+ break;
179+
159180 case COMMAND_BITMAP:
160181 {
161182 unsigned char loaderId = *gCurrentStream++;
@@ -174,6 +195,19 @@
174195 }
175196 break;
176197
198+ case COMMAND_FULLSCREEN_ITEM:
199+ {
200+ unsigned char loaderId = *gCurrentStream++;
201+
202+ ClearMessageWindow(16+4);
203+ LoadFileAt(loaderId,ImageBuffer);
204+ PrintTopDescription(gCurrentStream);
205+ BlitBufferToHiresWindow();
206+
207+ gCurrentStream += strlen(gCurrentStream)+1;
208+ }
209+ break;
210+
177211 case COMMAND_FADE_BUFFER:
178212 BlitBufferToHiresWindow();
179213 break;
--- users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_text.s (revision 1710)
+++ users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/game_text.s (revision 1711)
@@ -36,6 +36,8 @@
3636 _gTextNotDead .byt "Pas mort",0 // Debugging text
3737 _gTextDogJumpingAtMe .byt "un chien qui me saute dessus",0
3838 _gTextThugShootingAtMe .byt "un malfaiteur qui me tire dessus",0
39+_gTextAGenericWhiteBag .byt "Juste un sac blanc normal",0
40+_gTextThickBookBookmarks .byt "Un livre épais avec des marques",0
3941 #else
4042 _gTextAskInput .byt "What are you going to do now?",0
4143 _gTextNothingHere .byt "There is nothing of interest here",0
@@ -59,6 +61,8 @@
5961 _gTextNotDead .byt "Not dead",0 // Debugging text
6062 _gTextDogJumpingAtMe .byt "a dog jumping at me",0
6163 _gTextThugShootingAtMe .byt "a thug shooting at me",0
64+_gTextAGenericWhiteBag .byt "It's just a white generic bag",0
65+_gTextThickBookBookmarks .byt "A thick book with some boomarks",0
6266 #endif
6367 _EndMessagesAndPrompts
6468
@@ -89,6 +93,7 @@
8993 _gTextErrorAlreadySearched .byt "Vous l'avez déjà fouillé",0
9094 _gTextErrorInappropriate .byt "Probablement inapproprié",0
9195 _gTextErrorDeadDontMove .byt "Les morts ne bougent pas",0
96+_gTextErrorNothingSpecial .byt "Rien de spécial",0
9297 #else
9398 _gTextErrorInvalidDirection .byt "Impossible to move in that direction",0
9499 _gTextErrorCantTakeNoSee .byt "You can only take something you see",0
@@ -114,6 +119,7 @@
114119 _gTextErrorAlreadySearched .byt "You've already frisked him",0
115120 _gTextErrorInappropriate .byt "Probably inappropriate",0
116121 _gTextErrorDeadDontMove .byt "Dead don't move",0
122+_gTextErrorNothingSpecial .byt "Nothing special",0
117123 #endif
118124 _EndErrorMessages
119125
@@ -826,6 +832,54 @@
826832 END
827833 _EndSceneScripts
828834
835+
836+// Scene actions
837+_StartSceneActions
838+
839+_gSceneActionReadNewsPaper
840+ .byt COMMAND_FULLSCREEN_ITEM,LOADER_PICTURE_NEWSPAPER,"The Daily Telegraph, September 29th",0
841+ .byt COMMAND_INFO_MESSAGE,"I have to find her fast...",0
842+ WAIT(50*2)
843+ .byt COMMAND_INFO_MESSAGE,"...I hope she is fine!",0
844+ WAIT(50*2)
845+ END
846+
847+_gSceneActionReadPrintedNote
848+ .byt COMMAND_FULLSCREEN_ITEM,LOADER_PICTURE_HANDWRITTEN_NOTE,"A hand written note",0
849+ WAIT(50*2)
850+ .byt COMMAND_INFO_MESSAGE,"That could be useful...",0
851+ WAIT(50*2)
852+ .byt COMMAND_INFO_MESSAGE,"...if I can access it!",0
853+ WAIT(50*2)
854+ END
855+
856+_gSceneActionReadChemistryRecipes
857+ .byt COMMAND_FULLSCREEN_ITEM,LOADER_PICTURE_CHEMISTRY_RECIPES,"A few useful recipes",0
858+ WAIT(50*2)
859+ .byt COMMAND_INFO_MESSAGE,"I can definitely use these...",0
860+ WAIT(50*2)
861+ .byt COMMAND_INFO_MESSAGE,"...just need to find the materials.",0
862+ WAIT(50*2)
863+ END
864+
865+_gSceneActionReadChemistryBook
866+ .byt COMMAND_FULLSCREEN_ITEM,LOADER_PICTURE_SCIENCE_BOOK,"A science book",0
867+ WAIT(50*2)
868+ .byt COMMAND_INFO_MESSAGE,"I don't understand much...",0
869+ WAIT(50*2)
870+ .byt COMMAND_INFO_MESSAGE,"...but looks like someone took notes.",0
871+ WAIT(50*2)
872+ END
873+
874+_gSceneActionInspectMap
875+ .byt COMMAND_FULLSCREEN_ITEM,LOADER_PICTURE_UK_MAP,"A map of the United Kingdom",0
876+ .byt COMMAND_INFO_MESSAGE,"It shows Ireland, Wales and England",0
877+ WAIT(50*2)
878+ END
879+
880+_EndSceneActions
881+
882+
829883 _EndGameTextData
830884
831885 ;
@@ -837,4 +891,6 @@
837891 #print - Location names = (_EndLocationNames - _StartLocationNames)
838892 #print - Item names = (_EndItemNames - _StartItemNames)
839893 #print - Scene scripts = (_EndSceneScripts - _StartSceneScripts)
894+#print - Scene actions = (_EndSceneActions - _StartSceneActions)
840895
896+
--- users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/params.h (revision 1710)
+++ users/dbug/UpgradeTime/Encounter/FloppyBuilderVersion/code/params.h (revision 1711)
@@ -70,6 +70,8 @@
7070 #define COMMAND_JUMP 8 // Really, that's a GOTO :p
7171 #define COMMAND_JUMP_IF_TRUE 9
7272 #define COMMAND_JUMP_IF_FALSE 10
73+#define COMMAND_INFO_MESSAGE 11
74+#define COMMAND_FULLSCREEN_ITEM 12
7375
7476 // Operator opcodes
7577 #define OPERATOR_CHECK_ITEM_LOCATION 0
Show on old repository browser