KevKelley Posted June 10, 2020 Share Posted June 10, 2020 I was playing around with expanding my game from 8k to 16k as a test. I had moved my "inline 6lives_statusbar.asm" to the last bank (bank 4 as opposed to the previous bank 2). I made no other changes to the code. When I ran in Stella, the game worked but I noticed the cycles would jump more. I was wondering if certain things use more cycles depending on which bank or how many banks you use. Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted June 10, 2020 Share Posted June 10, 2020 Code or data could have shifted and caused a page crossing penalty. This occurs with many instructions, refer to an opcode reference such as: http://6502.org/tutorials/6502opcodes.html Quote Link to comment Share on other sites More sharing options...
+Karl G Posted June 10, 2020 Share Posted June 10, 2020 I think SpiceWare's guess is the only likely explanation. The last bank contains the display kernel, which is why a minikernel needs to go there as well. Before, bank 2 had the display kernel, the minikernel, and all of the other code you had in that bank. Now bank 4 has the display kernel and minikernel, but the bank 2 code hasn't been moved, so your code and data are probably aligned differently. You could test this if you want by moving all of your bank 2 code and data to bank 4 to see if it goes back to normal. Really though if shifting code like this is causing you to run out of cycles, a better solution is needed. I would recommend some tasks that don't have to run every single frame, and split them up to run on different frames. Also, if you aren't already doing so, try putting some stuff that you are doing in your main loop into vblank instead to free up more cycles. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted June 10, 2020 Share Posted June 10, 2020 Also, it may not be clear that this is a bB question since it was not posted in that subforum, which might cause some confusion. Quote Link to comment Share on other sites More sharing options...
KevKelley Posted June 10, 2020 Author Share Posted June 10, 2020 Just now, Karl G said: Also, it may not be clear that this is a bB question since it was not posted in that subforum, which might cause some confusion. I suppose I should have specified that it was bB but I really do appreciate the explanation, as I want to understand more than the dos and donts of bB. Based off what I had seen, reading the explanation of page crossing makes sense. I was tempted to move bank 2 into bank 4 to see if the issue persists but I agree a better solution is needed. I had noticed that I get an occasional 263 cycles normally that I have been working on an moving code to after the vblank sounds like it could work. Implementation of vblank in bB had confused me so I will definitely look into that . I assume I would have to put some code after drawscreen and that would basically take that out of using cycles? Quote Link to comment Share on other sites More sharing options...
+Karl G Posted June 10, 2020 Share Posted June 10, 2020 Whatever code you put in the vblank "function" automatically gets run every frame. You don't call it from anywhere in your code. It gets run from the last bank, so any data tables you reference have to be there, too, although there's nothing preventing you from bankswitching if you need to, so long as you return. bB code runs in the overscan time slice. It uses the vblank time slice for housekeeping tasks like positioning sprites and such, but there are still a fair number of unused cycles in vblank. If you move code to vblank, that code uses the free cycles in the vblank time slice, freeing up cycles from the normal overscan time slice where the rest of your code runs. Quote Link to comment Share on other sites More sharing options...
KevKelley Posted June 10, 2020 Author Share Posted June 10, 2020 Thank you very much. I will read up on both the bB process and the 6502 tutorials. I think I have an idea on what to do to. I would imagine that if the cycles are only jumping 3 or 4 and never really above that, the moves would be minimal... Quote Link to comment Share on other sites More sharing options...
KevKelley Posted June 10, 2020 Author Share Posted June 10, 2020 (edited) So I moved all of bank 2 to bank 4 and the issue stopped. I still have an occasional 263 cycles and while I don't get any screen rolls or jumps on hardware, I still want to try and rectify this so I will look into vblank. I had tried playing around with vblank, seeing that it took up about 20 bytes, I wasn't able to get things to work since I barely had any space so now I started to moving things around since I have 2 free banks so that I can try using that. I did move a segment of code that didn't seem to interfere with the cycle issue and moved it to the vblank just as a test and it did eliminate the issue so there is hope! Thank you again for the explanations. I do find the underlying cause very interesting and hope to learn more as I progress. Edited June 10, 2020 by KevKelley Quote Link to comment Share on other sites More sharing options...
bogax Posted June 11, 2020 Share Posted June 11, 2020 changing banks takes time if you were doing alot of that it could cause problems 1 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.