Is there a way to determine whether a game ends in failure (all lives lost) or success (ENDGAME event), so that when returning to BASIC you could, for instance, load a new level or display a "game over" or "congratulations" screen previously stored in memory?
I'll try to explain my request better with an example. Let's suppose I make a game split across different levels. Once the player manages to reach the end of the first one, the machine code returns to the BASIC housekeeping program, which checks whether the previous part has been successfully completed (ENDGAME event) or not, and in the first case it loads the following level from tape or RAMdisk.
Poking memory in a certain location from the game itself as soon as the player reaches the end-of-game screen, could, as far as I know, be possible. The problem is, this would probably require to "hack" the game code and I just don't know how to do this.
Alessandro, isn't the AGD code like LET M 10 work like POKEing?
All AGD commands POKE something in the Spectrum memory, I guess The problem is, I don't know how to tell exactly which memory address corresponds to each variable in the game script, neither I know whether all variables are deleted after the return to BASIC or not.
It looks quite like so. But how did you manage to discover that the 32031 address holds the LIVES variable? I would never have made it for the life of me
Anyway, it seems that variables are not reset once the program returns to BASIC. I ran Apulija-13 and intentionally lost all of my lives. Back to the BASIC frontend program, 32031 contained a value of 0. By starting the game again, 32031 was again set to 3. So variables are defined at the start of game in the Game Initialization event, it seems.
EDIT: By playing a bit with the Spin debugger, I managed at least to understand that in Apulija-13 the G (ammunition) variable is located at 32038 and the H variable (health) is located at 32039. However if you hadn't pointed me in the right direction I would hardly have been able to find them myself
EDIT 2: It looks like the addresses between 32032 and 32047 hold the values for the variables from 'a' to 'p' respectively. Now, if I could understand where the score is located...
Last Edit: Jan 11, 2013 19:05:00 GMT by alessandro