Cisano Posted January 26, 2022 Share Posted January 26, 2022 Hi. My game needs 8k. I use Visual Studio. Bank 0 org $1000 rorg $1000 ;code org $1FFA rorg $FFFA Bank 1 org $2000 rorg $1000 ;code org $2FFA rorg $FFFA I know how to swtch the banks, thank to 8bitworkshop. My question. The code must be in the same file? Because I have "Failed to create compiled file" error. No other help about the reason. Thanks. Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted January 26, 2022 Share Posted January 26, 2022 It might just be a typo, but org (binary file origin) should start counting from $0000, not $1000. Also rorg (relocated "code" origin) should be within a 4k region ($1000 .. $1FFF, or $F000..$FFFA) for the start and end of each of your banks. Fixed in the following: Bank 0 org $0000 rorg $1000 ;code org $0FFA rorg $1FFA Bank 1 org $1000 rorg $1000 ;code org $1FFA rorg $1FFA 1 Quote Link to comment Share on other sites More sharing options...
Cisano Posted January 26, 2022 Author Share Posted January 26, 2022 Are you sure about the values for the Bank 1? Because I continues to get error. Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted January 26, 2022 Share Posted January 26, 2022 I just tried this and it worked: ;------------------------------------ ;---- 8k DASM example processor 6502 ;----------- ;-- Bank 0 org $0000 rorg $1000 lda $1ff8 boot: ;put code here org $0FFA rorg $1FFA word 0 word boot word boot ;----------- ;-- Bank 1 org $1000 rorg $1000 goto_boot: lda $1ff8 ;-- switch back to bank 0 and continue execution at "boot" ;put code here org $1FFA rorg $1FFA word 0 word goto_boot word goto_boot 1 Quote Link to comment Share on other sites More sharing options...
Cisano Posted January 26, 2022 Author Share Posted January 26, 2022 It works, thanks very much. 1 Quote Link to comment Share on other sites More sharing options...
Cisano Posted January 27, 2022 Author Share Posted January 27, 2022 One last thing. From 8bitworkshop: MAC BANK_SWITCH .Bank SET {1} .Addr SET {2} lda #>(.Addr-1) ldy #<(.Addr-1) ldx #.Bank jmp BankSwitch ENDM Having 2 label with the same name in the 2 banks "BankSwitch", I get "Label mismatch" error. How to fix it? You use: lda $1ff8 Is it enough to use lda instruction for the switch? Thanks for every info. Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted January 27, 2022 Share Posted January 27, 2022 Yes, reading/writing to 1FF8 (for bank 0) or 1FF9 (for bank 1) will switch banks in the 8k/F8 bank-switching scheme. But, you need to be careful because the bank-switching happens immediately. The code in 8bitworkshop is quite complex. I don't really have any experience with using techniques like that. In PaintTheCity, I use a much simpler technique which involves defining a jump table at the beginning of each bank. (ChaoticGrill also uses a similar jump-table technique) Here is an example of the jump-table bank-switching technique. This example shows a layout where Display code and Graphics data would be located in bank 0, and game logic would be located in bank 1. F8_banking_example.asm 2 Quote Link to comment Share on other sites More sharing options...
Cisano Posted January 30, 2022 Author Share Posted January 30, 2022 I've taken the decision to use the code in F8 banking example. It works and from Bank1 pressing the fire button it goes in the Bank0 and the game starts. I have this problem now. The Bank0 has free memory. If I write some instuctions (it doesn't matter which) I get, just started, "invalid instruction" by Stella. If I delete one and check, one and check, etc ... it begins to work again. The funny thing is, that code is not executed. Thanks for every info. Quote Link to comment Share on other sites More sharing options...
Cisano Posted February 1, 2022 Author Share Posted February 1, 2022 I have understood the problem. I use align $100 for a big sprite. This create a strange problem in both the banks. Anyway it seems fixed. 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.