easmith Posted March 9, 2019 Share Posted March 9, 2019 i ordered a few carts from AA for the game attached. I am employing f8 bankswitching. I have always felt a little shaky on this , but thought I had found a workable scheme online . I used the same code on a previous game for which the carts function on real hardware just fine. The game works in Stella, and works on Harmony Cart on my 2600 Jr . When Albert was making the carts, he said it did not load properly on his light-sixer 2600, but worked on a 7800. I wonder if anyone could look at stella disassembly and spot any problem with the approach. I would rather not share source code if possible.?? KungFuCombat3.1.NTSC.bin Quote Link to comment Share on other sites More sharing options...
+Karl G Posted March 9, 2019 Share Posted March 9, 2019 If you don't want to share source, then perhaps you could make a simple example that includes your bankswitching code, and not much else? Quote Link to comment Share on other sites More sharing options...
azure Posted March 9, 2019 Share Posted March 9, 2019 When it starts up in bank 0, I get a black screen. The code zeros out memory and then calls brk. Your brk handler ($10fe - $10ff) is pointing to $1000, which runs your initialization again, so it enters an infinite loop. When the code starts up in bank 1, it seems to work correctly. You have to assume the bank you start in will be random or indeterminate, so if you want your game to always start in bank 1, you need to make bank 0's initialization switch to bank 1. Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted March 9, 2019 Share Posted March 9, 2019 When you're a developer you want to use the Developer settings in Stella. When using that, your game fails to run half the time. hit TAB to bring up the Options menu Click Developer... Select Developer settings Key thing for your game is the Random startup bank. If the cartridge starts up in bank 0 your game fails to run. You need to have a startup routine in all banks. The startup routine in bank 0 should switch to bank 1 and jump to the real startup routine. 3 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted March 9, 2019 Share Posted March 9, 2019 Steps to test startup sequence in a specific bank: Hit ` to enter the debugger type reset in the prompt Select the CartridgeF8 tab Change Set bank to the one you want to test for startup Click Exit When you do this for bank 0 the game doesn't work. When done for bank 1 it works. 2 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted March 9, 2019 Share Posted March 9, 2019 Forgot to mention that depending upon how the bankswitching was implemented, real hardware could start up in a random bank. Stella by default will start up in bank 1, as seen in CartF8.cxx. I suspect Harmony uses same logic. void CartridgeF8::reset() { initializeStartBank(1); // Upon reset we switch to the reset bank bank(startBank()); } There are some exceptions to it starting up in bank 1. If you look at Stella.pro you'll find a few games that override StartBank, such as Private Eye: "Cartridge.MD5" "bc24440b59092559a1ec26055fd1270e" "Cartridge.Name" "Private Eye (1984) (Activision) [a]" "Cartridge.StartBank" "0" "" Quote Link to comment Share on other sites More sharing options...
easmith Posted March 9, 2019 Author Share Posted March 9, 2019 Ok , I see this now . I think it works now . However now there is a new mystery. I am pretty much doing the same thing in One on One, but now when One On One starts up in bank 0 , it appears that none of the ram is being initialized or accessed correctly, so that none of the graphics show and the logic does not register in Ram . The ram does not change either when players move , etc. Man this 2600 specific stuff is kicking my butt. KFCbank.bin OneonOneProto3.bin Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted March 9, 2019 Share Posted March 9, 2019 About to head out so can't check out your ROMs at the moment. However, this is how I did it in Medieval Mayhem (which is a 32K game using F4 bankswitching): At F000 for every single bank is this bit of code: InitSystem cmp SelectBank5 ; inits system then goes to the menu jmp InitSystemCode In bank 5 is this: InitSystemCode CLEAN_START reset vectors for every bank are: ; .word InitSystem ; 7 and 8 overlap NMI .word InitSystem ; RESET .word InitSystem ; IRQ 2 Quote Link to comment Share on other sites More sharing options...
Omegamatrix Posted March 9, 2019 Share Posted March 9, 2019 I didn't look at what you're doing, but consider this: - You will have a certain bank that has your initialization code, whether it be bank 0, bank1, etc... - Don't count on your game starting in the same bank each time. Instead plan on it starting in a bank that is randomly selected. - The first thing your game must do is bankswitch to the bank that holds your initialization code. Every bank that does not hold the initialization code must do this. - Once you have bankswitched to the correct bank you must get to that code. 2 Quote Link to comment Share on other sites More sharing options...
Mr SQL Posted March 9, 2019 Share Posted March 9, 2019 i ordered a few carts from AA for the game attached. I am employing f8 bankswitching. I have always felt a little shaky on this , but thought I had found a workable scheme online . I used the same code on a previous game for which the carts function on real hardware just fine. The game works in Stella, and works on Harmony Cart on my 2600 Jr . When Albert was making the carts, he said it did not load properly on his light-sixer 2600, but worked on a 7800. Did you set the decimal flag? Differrent variants of the 6502 will intialize the flag differently and could account for that if the 7800 is consistently running the game. Quote Link to comment Share on other sites More sharing options...
easmith Posted March 9, 2019 Author Share Posted March 9, 2019 (edited) Yes I had done that . I think I got it working now. Thanks everyone for the help KFCbankscorrect.bin OneonOneProto3.bin Edited March 10, 2019 by easmith Quote Link to comment Share on other sites More sharing options...
easmith Posted March 17, 2019 Author Share Posted March 17, 2019 (edited) attempting to extend F8 method to F6 . Here is my outline. It is not working. I suspect maybe I need to alter the reset vectors but not sure how bank 0 (startup) processor 6502 include "vcs.h" include "macro.h" seg.u Variables org $80 ram definition seg.code org $1000 Graphics and PF data CLEAN_START Ram Inititalization Vblank Vblank Logic Kernel Overscan OverScan Logic jsr callbank1 jsr callbank2 jsr callbank3 org $1FC0 callbank1 ldx $1FF7 nop ; $1FC3 in bank 1 nop nop nop nop nop rts org $1FD0 callbank2 ldx $1FF8 nop ; $1FD3 in bank 2 nop nop nop nop nop rts org $1FE0 callbank3 ldx $1FF9 nop ; $1FE3 in bank 3 nop nop nop nop nop rts reset ORG $1FF6 JMP CLEAN_START .byte 0,0,0,$F6,$FF,0,0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; end bank0 ;;;;;;bank1 org $2000 rorg $1000 bank1logic rts Org $2FC3 rorg $1FC3 jsr bank1logic ldx $1FF6 ; return to bank0 ORG $2FF6 rorg $1FF6 JMP CLEAN_START .byte 0,0,0,$F6,$FF,0,0 ;;;;;;bank 2 org $3000 rorg $1000 bank2logic rts Org $3FD3 rorg $1FD3 jsr bank2logic ldx $1FF6 ; return to bank0 ORG $3FF6 rorg $1FF6 JMP CLEAN_START .byte 0,0,0,$F6,$FF,0,0 ;;;;;;bank 3 org $4000 rorg $1000 bank3logic rts Org $4FE3 rorg $1FE3 jsr bank3logic ldx $1FF6 ; return to bank 0 ORG $4FF6 rorg $1FF6 JMP CLEAN_START .byte 0,0,0,$F6,$FF,0,0 Edited March 17, 2019 by easmith Quote Link to comment Share on other sites More sharing options...
Omegamatrix Posted March 17, 2019 Share Posted March 17, 2019 Don't put code in the hotspots. In this case the hotspots ar $FFF6-$FFF9, so JMP CLEAN_START will trigger an unintentional bankswitch. Also, you can have data before the hotspots ($FFF5) and it can be read and used as normal. However If you had code in $FFF5 then you have to be wary that as soon as the instruction is read the PC has incremented so that would trigger $FFF6. This is non-impacting if you are already in bank 0, but would of course be a bug if you were in other banks. I often just leave a buffer byte before the hotspot or just have data there. Example: rts ; $FFF5 will switch to bank 0 as PC increments to $FFF6 triggering the hotspot .byte 0 ; $FFF6 bank 0 hotspot .byte 0 ; $FFF7 bank 1 hotspot .byte 0 ; $FFF8 bank 2 hotspot .byte 0 ; $FFF9 bank 3 hotspot Quote Link to comment Share on other sites More sharing options...
easmith Posted March 17, 2019 Author Share Posted March 17, 2019 Don't put code in the hotspots. In this case the hotspots ar $FFF6-$FFF9, so JMP CLEAN_START will trigger an unintentional bankswitch. Also, you can have data before the hotspots ($FFF5) and it can be read and used as normal. However If you had code in $FFF5 then you have to be wary that as soon as the instruction is read the PC has incremented so that would trigger $FFF6. This is non-impacting if you are already in bank 0, but would of course be a bug if you were in other banks. I often just leave a buffer byte before the hotspot or just have data there. Example: rts ; $FFF5 will switch to bank 0 as PC increments to $FFF6 triggering the hotspot .byte 0 ; $FFF6 bank 0 hotspot .byte 0 ; $FFF7 bank 1 hotspot .byte 0 ; $FFF8 bank 2 hotspot .byte 0 ; $FFF9 bank 3 hotspot Thanks . If I change the $fff6 tp $fffc and take away the other .byte 0 etc info it seems to work . I think I understand now what the ORG $1FF6 JMP CLEAN_START .byte 0,0,0,$F6,$FF,0,0 was doing and that there were 0's in the hotspots ( I think) Quote Link to comment Share on other sites More sharing options...
easmith Posted March 17, 2019 Author Share Posted March 17, 2019 I take that back . Now it is only registering as 4K . Isn't $fffc read upon startup? Quote Link to comment Share on other sites More sharing options...
easmith Posted March 17, 2019 Author Share Posted March 17, 2019 never mind, I think I got it now .......thanks! 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.