Got it!
After tidying up the ROM contents, things were more or less like before, but now playing at the right speed: ≈11 seconds for 256 kiB ROM, repeating the whole cycle after about one-and-a-half minute -- twice the previous values. Disabling interrupts, changing the sample's length and/or its address made absolutely no difference :?:
I eventually discovered where the problem was -- a matter of assembler syntax! Yes, assembler and not assembly...
Both my source code and yours use a LEA address, A0 instruction at the beginning... but with different addresing modes! While yours (opcode 0x41FA) uses a 16-bit relative offset (which makes a lot of sense since in your version the sample was right after the code), I was using a 32-bit absolute address (opcode 0x41F9 for increased flexibility). When I inserted your code besides mine, I dumbly assumed that your LEA was like mine, and filled the following 32 bits with the absolute address -- actually "eating out" some of the initialization code! :I
Now, the sample is played at the proper position and length (like your original ROM did, of course) and your code finishes properly -- I added an infinite loop after that, working as a 32-bit counter on the screen itself, and I can see the pixels changing quickly as expected.
However, there's still the problem of distorted playback -- something else has to be intialized, it was done somewhere in the original ROM...
After tidying up the ROM contents, things were more or less like before, but now playing at the right speed: ≈11 seconds for 256 kiB ROM, repeating the whole cycle after about one-and-a-half minute -- twice the previous values. Disabling interrupts, changing the sample's length and/or its address made absolutely no difference :?:
I eventually discovered where the problem was -- a matter of assembler syntax! Yes, assembler and not assembly...
Both my source code and yours use a LEA address, A0 instruction at the beginning... but with different addresing modes! While yours (opcode 0x41FA) uses a 16-bit relative offset (which makes a lot of sense since in your version the sample was right after the code), I was using a 32-bit absolute address (opcode 0x41F9 for increased flexibility). When I inserted your code besides mine, I dumbly assumed that your LEA was like mine, and filled the following 32 bits with the absolute address -- actually "eating out" some of the initialization code! :I
Now, the sample is played at the proper position and length (like your original ROM did, of course) and your code finishes properly -- I added an infinite loop after that, working as a 32-bit counter on the screen itself, and I can see the pixels changing quickly as expected.
However, there's still the problem of distorted playback -- something else has to be intialized, it was done somewhere in the original ROM...