Videopac / Odyssey2 forum
November 21, 2019, 02:59:26 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Join Rafael's Haunted Woods contest and win a copy of the game!
 
   Home   arcade Help Login Register links videopac.nl  
Pages: [1]   Go Down
  Print  
Author Topic: Bank usage: an idea I have  (Read 1268 times)
Chris!
Give this man a Jopac!
******
Posts: 1146



WWW
« on: October 13, 2017, 10:55:39 AM »

So I have been working on a game that is a little like GoSub where there's different mazes and stuff. What I want to do is have a 4k game, where the game logic and a few puzzles be in the first 2k bank and have the rest of the puzzles be in the second 2k bank. This would give me a good amount of mazes to deal with. But I have a question: Is this setup possible? Can I switch to the bank with the puzzles in it, get a puzzle's data and then have the game return to the game logic with the maze loaded and on screen? If so, how would I go about doing this?
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
samscudder
Trying to get the cartridge in...
*
Posts: 3


« Reply #1 on: November 02, 2017, 04:47:08 PM »

If by maze, you mean the grid, it wouldn't be altered when you change banks.

Normally some routines (interrupts and so on) are copied across banks, so that you they work correctly whichever bank is selected.

Banks are selected (in almost all of the carts), by using bits 0 and 1 of P1. When you turn on a Odyssey2/Videopac, P10 and P11 are SET. If you don't have these lines hooked up to a cart (on a 2K cart for example), the same 2K bank is visible to the processor at bank 0, 1, 2 and 3. If you have a 4K cart, bank 0 is also visible at bank 2, and bank 1 is also visible at bank 3.

Using OR and AND operations, bits 0 and 1 of P1 are set and reset to select up to 4 different 2K banks.

KC's Crazy Chase (a 4K cart) has a routine at address 411h to switch banks:

In bank 1:

Code:
411 99 FE ANL P1,#FE       ; resets bytes 0 and 1 or P1, switching to bank 0 (equal to bank 2)
413 00    NOP
414 84 21 JMP 0421


And in bank 0:

Code:
411 89 03 ORL P1,#03       ; sets bytes 0 and 1 of P1, switching to bank 3 (equal to bank 1)
413 00    NOP
414 84 23 JMP 0423

So, if you CALL or JMP to 411 in bank 1, the bank switches and JMPs to 0423 in bank 0. If you CALL or JMP to 411 in bank 0, the bank switches and JMPs to 421 in bank 1.

Normally a few bytes after the switch command are NOPs to give the hardware time to switch safely.

Switching banks doesn't interfere with RAM contents in any way. You can have a gameplay routine in one page, and a setup routine in the other page.
Logged
Rafael
Pedit5
I'd sell my mother for a Videopac
*
Posts: 2496



« Reply #2 on: November 03, 2017, 12:39:39 AM »

A sleeping giant has awakened. Wink
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!