Well the issue I had and fixed in relation to this topic, was actually several. Mostly with my tile drawing loops. One of them was harmless but was drawing garbage to Plane A underneath the bottom of the screen, fixing my loop counter fixed that. Same thing with the loop that draws the FM1-PSG4 columns on the song screen. It was drawing extra columns that were reading table/array data that didn't exist, because the array never went that far. Of course this one was tricky to find because 0x00 shows up as a transparent tile, but when I changed the offset for my font then everything became clear. There might have been more but fixing these lead to the fix my memory crash. Which I can't remember exactly what did it, I spend too much time doing this stuff.
The snag I ran into yesterday which is unrelated was causing incorrect loading and drawing of my Chain data array. See the starting address for this array is actually dynamic, because what part of the array we're drawing on the screen actually depends on what value in which slot we used on the Song screen. I had to come up with what seemed like some crazy functions to make it happen. Because the array stores the row ID in word, and the value in word. The value is directly written for use with the font to display useful numbers. So when you see 3A on the screen, the value in code is actually 13, 21 in hex. So I had to come up with an algorithm to subtract ten from each byte of the value, to turn it into a normal number, or if it's a hex letter, subtract 17 to turn it into a normal hex letter. Then I had to rotate some bits and combine the result into one byte. That byte is then multiplied by 8, which combined with the starting address of the Chain table array gives us our dynamic starting address for which part of the array needs to be loaded. It was trying to LEA that address that failed, because I was loading a pointer to a pointer, where my snag was. But it turns out that I forgot one simple part to my code to make it all work. So although I changed LEA into something like:
Code: Select all
move.l CURRENTSLOTADDRESS, d1
move.l d1, a0
.... it may very well be that I was doing it wrong before we even get to this point. Because the address was changing whenever the cursor moved. Which was not good, I needed that address to only be loaded when we were switching from the Song screen to the Chain editor. Some simple repositioning of code fixed that. Sometimes I forget that all this code isn't happening all at once, but is in fact being read by the cpu line by line at a high rate of speed.... WHEW!
This is why I don't explain things, I get very long winded sometimes...
