Nukey Shay Posted October 6, 2004 Share Posted October 6, 2004 Problems with 8k hacks that I've been doing.... On actual hardware, a game needs the ability to initialize in either bank...right? So the solution that I was using was to do this: ;bank1 * $D000 START1: LDA $1FF9 * $DFFC .word START1 ;bank2 * $F000 NOP NOP NOP JMP START2 * (anywhere in bank2) START2: ; (initialize ram and run program) * $FFFC .word START2 So the program should flip over to bank 2 and jump to the initialize routine no matter what, right? The vector in bank 1 calls a bankswitch that flips over to bank 2 and then jumps to the routine, and the vector in bank 2 points right at the routine. For some reason, it's not working the way it should (tho it does under emulation) Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 6, 2004 Share Posted October 6, 2004 Code looks ok. Are you sure there is no other bug? Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted October 6, 2004 Author Share Posted October 6, 2004 In Hack'Em, the bankswitch was missing the JMP in the other bank by 1 byte (possibly correcting that problem if the code is supposed to work). In 8k Pacman tho, I'm stumped - the banks match up perfectly as far as I can tell I'm not aware if this problem also appears on Space Invaders and Adventure...but if it's wrong in this one, it's wrong in all of them as well. Assembly pacman8k.zip Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 6, 2004 Share Posted October 6, 2004 Does work only ~50% when using the KrokoCart. But the code still looks ok to me. Hm... BTW: You are displaying one scanline too many (all B/W on my PAL TV). Quote Link to comment Share on other sites More sharing options...
Bruce Tomlin Posted October 6, 2004 Share Posted October 6, 2004 You could try adding another NOP at D004/F004 and see if that helps. Maybe the switch is too slow or something. Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted October 7, 2004 Author Share Posted October 7, 2004 Does work only ~50% when using the KrokoCart. But the code still looks ok to me. Hm... Puzzler You could try adding another NOP at D004/F004 and see if that helps. Maybe the switch is too slow or something. I don't see why it would be - those NOP instructions are never even seen by the program (when the first LDA $1FF9 happens in bank1, a bankswitch occurs...jumping to address $F003 in bank2. The JMP there sends it right to the initialization routine). Those 3 NOPs in each bank can be anything, because the program never reads them. Here's a diagram of what happens when the program begins execution at $D000: Address bank1 bank2 ------------------------------ 000 LDA NOP 001 $F9 NOP 002 $1F NOP bankswitch------------> 003 NOP JMP 004 NOP <START 005 NOP >START This only happens once...right when the cart is powered up by the console. The LDA and JMP instructions both use 3 bytes, which is why 3 NOP's are used in each bank to take up the slack. Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted October 7, 2004 Author Share Posted October 7, 2004 Are the values that exist at $DFF8/9 and $FFF8/9 related to bankswitching in any way? Do they need to be any particular value...or are they completely ignored? Quote Link to comment Share on other sites More sharing options...
+batari Posted October 7, 2004 Share Posted October 7, 2004 Are the values that exist at $DFF8/9 and $FFF8/9 related to bankswitching in any way? Do they need to be any particular value...or are they completely ignored? The values don't matter. All the bankswitching hardware does is switch if it encounters the address 1FF8 or 1FF9, which corresponds to a certain combination of logic levels on the address pins of the rom. The data pins are ignored completely. Concerning your problem... I have a hunch. Maybe it has something to do with the hardware switching banks just as the address vector at $DFFC or $FFFC is being read, and you're getting the wrong values. If both banks have the same values, however, you will avoid the problem, and there's no reason why you can't do this in your code the way you have written it. The only difference is you'll be executing those NOPs... So try: ;bank1 * $D000 START1: LDA $1FF9 * $DFFC .word START1 ;bank2 * $F000 START2: NOP NOP NOP JMP START3 START3: ;whereever START2 used to be * $FFFC .word START2 Let me know if it works... Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted October 7, 2004 Author Share Posted October 7, 2004 I suppose it's a possibility...but whether or not it works is out of my range, since I only have emulation Does this work with a Kroco? Both banks hold nearly identical data here (besides $DFFD being $D0 and $FFFD being $F0, all other bytes are set at zero). I suppose I could even make both of them $D0 or $F0...with only 13-bit addressing, either value would have the same effect right? BTW I took a look at a disassembly of PacMan Arcade (which is based off the Ms. Pac program)...and sure enough, the start vector is functionally the same in both of them - $D000 and $F000. But what are all those other vectors doing in there? They look to be pointing outside the rom area LDFF8: .byte $12,$22,$1A,$8F,$00,$D0,$E6,$01 LFFF8: .byte $12,$22,$09,$82,$00,$F0,$1E,$01 pacman8k.zip Quote Link to comment Share on other sites More sharing options...
+batari Posted October 7, 2004 Share Posted October 7, 2004 I think that FFFE is the IRQ vector, so if no BRK instructions are encountered then I think that the vector will never be used. And yes, you could make them both D0 or F0, but I don't think that's necessary, I would think that the problem is that somehow you're getting one byte from one bank and the other byte from the other bank. Come to think of it, the issue might be due to a timing glitch in the bankswitching logic. Years ago I made my own bankswitching circuit with an inverter, a 13-input AND gate and a latch, and the way I did it, address bits 1 and 2 would be connected to the inverter before the AND so there might be a few dozen nanoseconds of propogation delay before going into the AND gate. Under the right (or wrong) conditions, accessing addresses FFFA-FFFF *might* cause a glitch, prehaps even inadvertantly switching banks during a reset or power-on, depending on how the circuit was designed. BUT... if both banks were the same, it doesn't matter what you do from FFFA-FFFF since those address are only enocuntered upon reset, power on or an IRQ. Still, I'm just making a big guess here, and the only way I currently have to test the hardware is an eprom burner, and I have no spare eproms... Quote Link to comment Share on other sites More sharing options...
Kroko Posted October 7, 2004 Share Posted October 7, 2004 I have compiled your first source and tested it on my krokodile cart. For me it seems to start just normal in 100% of the cases. Maybe it would be a good idea to post the binary, then we are sure that everybody is testing the same thing. You only need to somehow put 1FF8 or 1FF9 on the adressbus. You should probably try a STA $1FF9. I would be interested if this changes something. The bus timing is differend while loading and storing AFAIK. Quote Link to comment Share on other sites More sharing options...
Kroko Posted October 7, 2004 Share Posted October 7, 2004 Ah ... you posted a ROM already. This one works without problems as well But now there are colors on my PAL TV ... Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted October 7, 2004 Author Share Posted October 7, 2004 Ah ... you posted a ROM already. This one works without problems as well It works? Good...that means that I can only use F8 bankswitching when both banks' start vector is identical (in the lower 13 bits). But now there are colors on my PAL TV ... Yeah, the one at the top was displaying an odd number of scanlines...this has been bumped down to 262. I'm using the NTSC palette, so I can't gaurantee correct colors for PAL** ** NOTE: I could add PAL colors in the B&W color table, but doing so would shut out 7800 users from accessing them. Was the 7800 console made in PAL...or was that console NTSC only? Quote Link to comment Share on other sites More sharing options...
Kroko Posted October 7, 2004 Share Posted October 7, 2004 It works? Good...that means that I can only use F8 bankswitching when both banks' start vector is identical (in the lower 13 bits). No, not Good. The First version worked on my cart, too. It worked though the vectors were not identical. I have no idea, why it makes problems on Thomas' device ... I think your binary still makes problems on his system ... Quote Link to comment Share on other sites More sharing options...
+Mitch Posted October 8, 2004 Share Posted October 8, 2004 Was the 7800 console made in PAL...or was that console NTSC only? It was made in both NTSC and PAL. Mitch Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted October 8, 2004 Author Share Posted October 8, 2004 It works? Good...that means that I can only use F8 bankswitching when both banks' start vector is identical (in the lower 13 bits). No, not Good. The First version worked on my cart, too. It worked though the vectors were not identical. I have no idea, why it makes problems on Thomas' device ... I think your binary still makes problems on his system ... Odd...so I guess the real question would be does the problem only show up in some systems...or what causes the start vector to be misread on some systems? But if identical vectors is all it takes to avoid the problem on some systems, it's no big deal < master of G.I.G.O. Quote Link to comment Share on other sites More sharing options...
Kroko Posted October 8, 2004 Share Posted October 8, 2004 But if identical vectors is all it takes to avoid the problem on some systems, it's no big deal Sure, but you still have to make sure, that the identical vectors don't make trouble on the systems that made trouble with the different vectors Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted October 8, 2004 Author Share Posted October 8, 2004 Huh? From what I gather, the problem is that some systems might grab bank 2's vector (or part of it) when trying to grab bank 1's (or visa-versa). If both vectors are 13 bit-identical, either vector can be applicable to either bank - and the error is avoided. At least I hope so In any case, I've heard that the binary now works when burned to an eprom Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 8, 2004 Share Posted October 8, 2004 Don't worry any longer! I suppose my problems are more related to my hardware (quite weak power adapter) than your code. Quote Link to comment Share on other sites More sharing options...
Blinky Posted October 10, 2004 Share Posted October 10, 2004 If the bankswitching hardware switches a a little too late the CPU will read the NOP in bank 1 instead of the JMP opcode in bank 2. Put a JMP opcode in bank 1 after the bankswitch too. ;bank1 * $D000 START1: LDA $1FF9 JMP START2 Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted October 11, 2004 Author Share Posted October 11, 2004 I thought that bankswitching has an immediate effect? But no prob. I'll just use the JMP instead of having the 3 unused NOP's there Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 11, 2004 Share Posted October 11, 2004 I thought that bankswitching has an immediate effect? Yes, it should have. But maybe at powerup and with a weak power supply, some stuff get's delayed a bit. Quote Link to comment Share on other sites More sharing options...
atwwong Posted October 15, 2004 Share Posted October 15, 2004 Hi. I'm a relative newbie to programming and I'm hoping that I'm posting in the right place and wondering if someone could please help me with a problem that I think is related to bankswitching in the 8kAdventure code. I've used the code posted here and I've been told "All of the chips work about half of the time. The other half of the time the screen is slightly garbled and the actual levels go funny. I've tried different chip brands and different Atari systems, and I get the same results." Here is the bankswitch code. I apologize for all the comments. I've added the areas around it in case I messed up there. ;----------------start of bank 1---------------- ORG $1000;set 0 RORG $D000 ;deal with unknown flipflop status Bank1Start: LDA $1FF9 ;4 switch banks in case it begins here JMP StartGame;(i.e. instead of 3 nops) ;note: this JMP should never be executed...but is included ;to correct any possibility of "lag time" glitches ; NOP ;2 these NOPs are never executed ; NOP ;2 (i.e. slack taken by bank2) ; NOP ;2 ;Print Display PrintDisplayX: LDA $1FF9 ;4 STA HMCLR ;Clear horzontal motion. ;3 LDA Obj1X ;Position Player00 Sprite To ;3 LDX #$00 ; the X Coordinate of Object1. ;2 JSR PosSpriteX ;6 LDA Obj2X ;Position Player01 Sprite to ;3 ;bank 1 code ORG $1FF8 RORG $DFF8 ;I removed 2 of those $FF's to add in the 6502 start vector ; .byte $FF ; .byte $FF ; .byte $FF ; .byte $FF ; .word Bank1Start ; .byte $FF ; .byte $FF .word 0,0,Bank1Start,0 ;-----------------end of bank 1----------------- ;----------------start of bank 2---------------- ;bank 1 equates: removed;no longer needed ;note: PosSpriteX on bank 1 changed to PosSpriteX2 on bank 2 ; processor 6502 ;Default 2600 Constants set up by dissasembler.. ORG $2000 RORG $F000 Start2: NOP ;2 these NOPs are executed NOP ;2 in order to keep both starting NOP ;2 places the same JMP StartGame;4 Jump and initialize the game PrintDisplay: LDA $1FF8 ;4 call bank 1 RTS ;6 return ;bank 2 code ORG $2FF8 RORG $FFF8 ;do not use $fff8/$fff9...bankswitch rom locations ; .word $FFFF,$F000,Start2,$F000 .word 0,0,Start2,0 Does anyone have any ideas? I'm stumped. I've tried I tried removing the JMP StartGame from bank 1 and replacing it with 3 nop's and... adding JMP StartGame in bank 2 in place of the nop's. Of course, both work with emulation; I don't have hardware to test it at my immediate disposal. Quote Link to comment Share on other sites More sharing options...
Kroko Posted October 15, 2004 Share Posted October 15, 2004 Can you post a binary ? Quote Link to comment Share on other sites More sharing options...
atwwong Posted October 15, 2004 Share Posted October 15, 2004 Here's the original binary (8kha2.zip), along with my two attempts at fixing it. 8kha2-v06.zip has the JMP StartGame from bank 1 removed. 8kha2-v08.zip has the JMP StartGame in bank 2 in place of the nop's added. 8kha2.zip 8kha2_v06.zip 8kha2_v08.zip 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.