Hey, just something about the doc...
Dish says it's good to never disable the NMI is good, but I can see two reasons to disable it :
- When redrawing something when the screen is turned off, if an NMI happens between two $2006 writes, the NMI will acknownledge the interrupt by reading $2002 and the result would be very bad (this has actually happened to me once).
- When starting a sound effect/a new piece of music if the music engine is called while the sound effect/music is initiated, BAD things could happen.

Unless you programm the NMI to not even acknownledge the interrupt depending on the state of the main engine, and because that NMIs on the 6502 are edge based and not state based, I guess it would be a workarround to issue 1, algouth it's not really "clean".

_________________Life is complex: it has both real and imaginary components.

here is a buffer read routine i came up with based on a simplified version of SMB's routine..

The only problem with your code is that it's quite slow... INY, DEX and BNE for every copied byte is terribly inneficient. Unfortunately I don't have a better suggestion that doesn't require much more ROM.

If there's more ROM available, I can always recommend my pseudo-DMA idea. In my current project, I use a variation of it that is limited to 32 bytes at a time, so it doesn't need so much ROM.

You could kinda compromise and do it both ways at the same time, like StarTropics II.

Assume X is the loop count (the number of bytes remaining that we need to transfer).

The unrolled loop is the equivalent of a loop of 8, so what the program does is use the unrolled loop, copying 8 bytes each time, (subtracting 8 from the loop count each time), until the loop count is < 8, in which it just uses the normal loop for the remaining bytes.

So basically, if you need to transfer 5 bytes, it uses the normal loop with an X of 5.If you need to transfer 8 bytes, it uses the unrolled loop once.For 16 bytes, it uses the unrolled loop twice.For 20 bytes, it's the unrolled loop twice, and the normal loop with an X of 4.

It doesn't rely on huge unrolled loops, indirect jumps, tables, or anything of the sort, yet offers a better efficiency for transfers that are >= 8 bytes in length.

Who is online

Users browsing this forum: Google [Bot] and 9 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum