Thomas Jentzsch Posted May 5, 2018 Share Posted May 5, 2018 (edited) I suppose everyone who ever had to use standard Atari bankswitching sooner or later developed some kind of pattern how to use it. And there are numerous ways to do it. But most of have to be used very carefully and are often not easy to maintain. So I came up with the idea of using macros to make things as convenient as possible. The price for that convenience are more CPU cycles and destroyed registers and flags. So here they are: BANK_SIZE = $1000 ; Use at the start of each bank, required by JMP_LBL macro MAC START_BANK ; bank number BANK_NUM SET {1} ; this is not related to bankswitching, but nevertheless useful BANK_ORG SET $8000 + BANK_NUM*BANK_SIZE BANK_RORG SET $1000 + BANK_NUM*BANK_SIZE*2 SEG code ORG BANK_ORG, $55 RORG BANK_RORG ECHO " start of bank", [BANK_NUM]d, ", ORG", BANK_ORG, ", RORG", BANK_RORG ENDM ; Insert code for executing the bankswitch, ; should be put at the very end of each bank, right before the hotspots MAC SWITCH_BANK ORG BANK_ORG + $ff4 - BANKSWITCH_SIZE RORG BANK_RORG + $ff4 - BANKSWITCH_SIZE, "before bankswitching code" SwitchBank = (. & $fff) | $1000 pha txa pha lda BANK0,y ; e.g $fff8 rts BANKSWITCH_SIZE = ((. & $fff) | $1000) - SwitchBank ENDM ; Define a label which can be used by JMP_LBL macro ; Example: ; DEF_LBL Foo MAC DEF_LBL ; address {1} {1}_BANK = BANK_NUM ENDM ; Jump to a label in other or same bank. The assembler will take care if the ; code has to bankswitch or not. ; Example: ; JMP_LBL Foo MAC JMP_LBL ; address IF {1}_BANK != BANK_NUM ; convenience IF ldy #{1}_BANK lda #>({1}-1) ldx #<({1}-1) jmp SwitchBank ; always at the same address in each bank ELSE jmp {1} ENDIF ENDM As of now only JMP is supported, but macros for JSR could be created that way too. Edited May 5, 2018 by Thomas Jentzsch 7 Quote Link to comment Share on other sites More sharing options...
JeremiahK Posted May 6, 2018 Share Posted May 6, 2018 Thank you, I am in the process of upgrading my 4K project to a 16K one, and this will be very helpful. Quote Link to comment Share on other sites More sharing options...
Kylearan Posted May 11, 2018 Share Posted May 11, 2018 In TIM1T, I used the ARPM bankswitching macros found here and found them very helpful - you might take a look at them for inspiration or comparison. Just note that the original macros have a small bug - see my post in that thread for details. 2 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted May 11, 2018 Author Share Posted May 11, 2018 Those macros look very interesting. I will check them for sure. Maybe they are even easier to use than mine. Quote Link to comment Share on other sites More sharing options...
JeremiahK Posted May 11, 2018 Share Posted May 11, 2018 (edited) And for reference, here is how SpiceWare has done it. It's intended to be used after manually setting the ORG rather than automating that process for you. For my case, I will probably just take ideas from these concepts for my own method. Edited May 11, 2018 by JeremiahK 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.