+atari2600land Posted February 7 Share Posted February 7 I'm making a game in assembly. I want it to be 8k. I got the title screen in the fixed bank working, but I don't know how to switch to the in-game part which is in bank 0. Do I need any special code snippet in order to do this or what? bert27.asm Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted February 7 Author Share Posted February 7 I found this but I don't understand it. I worked on my game some more but if you press reset switch the game goes back to the fixed bank instead of the bank I want it to go to. There's something wrong here... bert27a.asm Quote Link to comment Share on other sites More sharing options...
+Bruce-Robert Pocock Posted February 7 Share Posted February 7 I'm not sure what you mean by, "fixed bank" in this context. The usual Atari (brand) -style bankswitching does not have a "fixed" bank. Each bank completely replaces the memory at $f000 (and mirrors) with a different 4kiB bank. To swap between 2 4kiB banks using Atari F8 bankswitching, you strobe the address at $fff8 or $fff9 (thus the name). The usual way to do this is `nop $fff8`, which uses an "undocumented" nop mode; you can instead use `bit` or any other read operation if you want to avoid "undocumented" instructions for some reason, but it's quite reliable on the 6507. (Write operations like `sta` can work too, but they will stroke the register twice, since every write is preceded by a read also.) Basically you're turning the page on the cartridge, but the CPU has no idea, so the Program Counter is just going to roll up to the next address in line after the bank switch. If the bank switch occurs at $f120, and takes a 3 byte instruction, then the next instruction is fetched from $f123 in whatever bank it happens to have switched into. The trickiest thing is to make sure that the next line of code, in that other bank, is where you need it to be. For example: At startup, any bank might be active (depending on a lot of things). Usually, your Cold Start code will be something that triggers a bank switch to a certain bank (e.g. bank 0) and then jumps to your startup sequence. RES vector $fffd => .word ColdStart In Bank 1: ColdStart: nop $fff8 ; switch to bank 0 ;; the next line will never be reached, ;; the CPU will fetch its next instruction from Bank 0 In Bank 0: ColdStart: nop ; skip over the bank switch code in bank 1 nop nop ;; OK, this is where Bank 1 joins us, now do actual start up work sei ; whatever It's important that ColdStartVector must be the same address in each bank. eg, $ff00 or so. What I personally do with these sort of "all or nothing" bank switching schemes is to create a small region in high ROM that is included into each bank (I call mine EndBank.s, e.g. this one in Grizzards) which always starts at a known, fixed address and has functions that are aligned between all the banks. For example, the above ColdStart routine could be at $ff00 in each bank. The $fffd RES vector could point to $ff00. the $fffe BRK vector could also point to something in the shared region, if you use it. You then can add other routines to pass control between one bank and the next. Each of these routines needs to have at least a tiny stub in the common area, so that when the bank switch occurs, the Program Counter is pointing to the next instruction. e.g. again: Suppose your DrawScore routine is in Bank 1. ;;; in Bank 0 GoDrawScore: nop $fff9 ; switch to bank 1 nop ; never reached, padding nop brk ;;; in Bank 1 GoDrawScore: nop ; no need to switch banks, but nop ; we do need to align the next jmp nop ; with the PC when the bank is switched jmp DrawScore Of course there are lots of ways to arrange something like this, but perhaps that helps shed a little light on things. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted February 7 Author Share Posted February 7 Oh wow. It seems so complicated. You have to line things up exactly within each bank? 1 Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted February 7 Share Posted February 7 4 minutes ago, atari2600land said: You have to line things up exactly within each bank? You can use 'jump' tables positioned at the start of each bank to make things easier. Here's an example template for using the Atari F8 scheme which has two 4k banks. F8_banking_example.asm 1 Quote Link to comment Share on other sites More sharing options...
+littaum Posted February 7 Share Posted February 7 I had good success following this thread to make a 8K bankswitched game: Quote Link to comment Share on other sites More sharing options...
+MarcoJ Posted February 8 Share Posted February 8 12 hours ago, atari2600land said: It seems so complicated. You have to line things up exactly within each bank? Yes, when the bank switch command is issued , the whole 4K bank switches. It's like the code execution falls off a cliff, since the program counter moves onto whatever is next in the bank. It could be anything and may get stuck between an operand series. The alignment of the two banks makes a safe area for bankswitching. 1 Quote Link to comment Share on other sites More sharing options...
Windless Posted February 23 Share Posted February 23 there is this rather "in depth" explaination that as many many typos and syntax error that I should correct one day, maybe it can help : https://gitlab.com/FTregan/bank-switching-rom-atari-2600 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.