Finally climbing the steep mounting of trying to sort out a copy/paste solution for my music tracker but admittedly I'm not sure if the approach is too naive and thought I'd see what some more seasoned assembly folk might think of it. This isn't in assembly yet, just a generalized approach:
Variables:
Source Pattern (Bank)
Source Channel Start
Source Channel End
Source Row Start
Source Row End
Source Row-Byte-Size
Source Number of Rows
Dest Channel Start
Dest Row Start
Overview:
Use VRAM as a buffer and memory_copy to copy each row from the source pattern (bank) to the destination (which could be the same pattern) row by row. Copy is channel-aligned (no partial copying of channels for now)
Function:
Like Impulse Tracker:
CTRL-B sets pattern, channel start / row start
CTRL-E sets channel end / row end
On CTRL-V, data is pasted at the position of the current channel/row
Paste Process:
* Determine if the block to be copied fits into the area. If not, figure out the subset that does fit and adjust the row and channel end variables to accommodate (throwing out the bit that won't fit)
* Figure out how many bytes we need to read per row
* Get the memory location of the start of the channel the cursor is on.
* Read those bytes from source pattern and use memory_copy to chuck them into VRAM (it would be 85 bytes at most)
* Write those bytes to the current pattern starting a memory location found above
* Jump to the next row which should be done by taking the start address and adding the full row size and loop through the operation for the number of rows copied
memory_copy I was hoping should speed up the line by line copy without having to write single bytes one at a time with constant bank switching. Likewise the copy should allow for pasting on top of a buffer (such as if I wanted to move notes over in the same pattern). The above approach wouldn't work for a cut/paste however. For that I would need to use buffer space to store the cut data. For that I'd either use spare memory in pages (each pattern is less than 6k, so that leaves 2k and some change per page for extra stuff right now) or just allocate a specific page as the buffer.
The selection could also be used for in-pattern update operations (swap instruments for example) but that's something for another day methinks.
Any big landmines folks see with this approach or any suggestions on how I can make it better (and by better I mean generally easier to write since it doesn't have to be a high performance operation, within reason).
Copy/Paste Operations In Assembly
Copy/Paste Operations In Assembly
Author of Dreamtracker (https://www.dreamtracker.org/)
Check Out My Band: https://music.victimcache.com/
Check Out My Band: https://music.victimcache.com/