Spider Posted January 6 Report Share Posted January 6 15 hours ago, IRF said: That's similar to my solution, but not identical. You seem to have a spare byte in there, so you could afford to retain the original two-byte LD D, #00 command, instead of the single-byte LD D, A. That would mean the patch isn't reliant on A having been reset to zero beforehand. (Since a lot of game designers ditch the preceding inactivity code which sets A=0.) Yes , it assumes that A is still set to zero as a result of the command at #8B3C IRF 1 Quote Link to comment Share on other sites More sharing options...
IRF Posted January 6 Author Report Share Posted January 6 (edited) I must admit I used AND #01 to affect the Zero flag - to decide when to increment (or not) the music note index - but it never occurred to me to just directly add the value of A (after the AND command) to the note index, which has the same effect since A can only hold 00 or 01 at that point. A very elegant and efficient solution! (Mine might be slightly more adaptable, as you can decide whether to advance the music on an 'odd' or an 'even' game tick, by selecting the polarity of the conditional jump: JR Z or JR NZ. However, mine needed an extra precious byte compared to yours, so yours wins!) Edited January 6 by IRF Quote Link to comment Share on other sites More sharing options...
jetsetdanny Posted January 6 Report Share Posted January 6 17 hours ago, IRF said: Indeed! Only 64 bytes per tune though. If you had 20 tunes of 256 bytes each, that wouldn't leave much room for anything else! 5 hours ago, jetsetdanny said: Exactly. Even with 64-byte-long tunes there was no room left for any extras. A suggestion was made after the game was released that it could do with a non-standard font. It was a very good suggestion, but unfortunately impossible to apply without far-reaching changes to the game engine that would optimise the code 'a la Norman Sword' and free up enough space to implement a new font. Actually, I need to correct both yourself, Ian, and myself! (I let myself be carried by your erroneous and, in fact, slightly blasphemous suggestion! 🤪) Each of the 20 in-game tunes in "Manic Person" is 128 bytes long. If they were 'only' 64 bytes long, there would be enough spare space also for a custom font (1280 spare bytes versus 768 needed for a full font). Spider and IRF 2 Quote Link to comment Share on other sites More sharing options...
IRF Posted January 8 Author Report Share Posted January 8 (edited) On 1/5/2024 at 6:45 PM, Spider said: Nopping out #8B47 and #8B49 would do but its too fast then. So... XOR A ;8B3C ; clear the inactivity timer at L85E0 LD (inactivity),A ;8B3D ;L85E0 LD D,A ;8B40 ; initialise the mSB LD a,(game ticker) ;8B41 ;L85CB the game ticker at 85CB AND 1 ;8B44 ; issolate odd or even game ticker bit LD HL,(ingame_music) ;8B46 ;L865F set HL to the music offset pointer LD E,(HL) ;8B49 ; get the present offset ADD A,E ;8B4A ; add the ticker (odd/even) value LD (HL),A ;8B4B ; store the updated offset NOP ; 8b4C ; back to the original code LD HL,ingame_music ;8B4D ;L865F ADD HL,DE ; 8B50 ; >>> HL IS POINTING AT THE NOTE value Actually Andy, you might need to think again there. Did you actually try that out? Because looking at it again, E isn't actually updated when the tune note index is increased, so when DE is added to HL (the second definition of HL) at #8B50, it won't pick up the new note during the current pass through the Main Loop. So you would need to use that spare, NOPped out byte at #8B4C for a LD E, A instruction. Edit: Thinking about it, the effect of E not being updated straight away probably just means that the tune will be playing 'one note behind'. It should play at the right speed. But the first note (first pitch value) will only play half as long as it should when you start playing the game. (And the normal fix for that - setting the music note index to #FF during game initialisation - won't work this time; I think that would cause the last note of the tune to be played during the first pass through the Main Loop.) Edited January 9 by IRF jetsetdanny, Spider and Norman Sword 1 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.