Jump to content
IGNORED

Figuring out a 64k bank switching scheme?


Trip2018

Recommended Posts

So I'm trying to make a demo. I want it to be a 64K demo, but I find swapping all 4k of a bank to waste too many cycles when all I'm doing is loading a byte or 2. So I've opted to have a 2k split format similar to what's elaborated here, where the last 2k is static and the rest is bank switched. Problem is, I don't think it exists for 64k... Maybe... I had no issues splitting up the chunks, but I'm not sure how to go about using "hotspots" for a scheme like this.

 

So what I wanna know is: How do these hotspots work? Are they tied to the console, or the rom's chipset?

 

If it's the rom, does that mean I have to define and write my own bankswitching scheme/hotspots? What emulators could I test it on that would work for a case like that?

Link to comment
Share on other sites

I think Tigervision's 3F is what you are looking for. 

We used deviation with RAM (3E) for Boulder Dash, but we found out that even 2K are not flexible enough. The fixed bank turned out to be a bottleneck. So I went for 3E+, which uses four 1K banks. It allows up to 64K ROM and 32K RAM.

 

Comment from Stella's source code:

  Cartridge class for new tiling engine "Boulder Dash" format games with RAM.
  Kind of a combination of 3F and 3E, with better switchability.
  B.Watson's Cart3E was used as a template for building this implementation.

  The destination bank (0-3) is held in the top bits of the value written to
  $3E (for RAM switching) or $3F (for ROM switching). The low 6 bits give
  the actual bank number (0-63) corresponding to 512 byte blocks for RAM and
  1024 byte blocks for ROM. The maximum size is therefore 32K RAM and 64K ROM.

  D7D6         indicate the bank number (0-3)
  D5D4D3D2D1D0 indicate the actual # (0-63) from the image/ram

  ROM:

  Note: In descriptions $F000 is equivalent to $1000 -- that is, we only deal
  with the low 13 bits of addressing. Stella code uses $1000, I'm used to $F000
  So, mask with top bits clear :) when reading this document.

  In this scheme, the 4K address space is broken into four 1K ROM/512b RAM segments
  living at 0x1000, 0x1400, 0x1800, 0x1C00 (or, same thing, 0xF000... etc.),

  The last 1K ROM ($FC00-$FFFF) segment in the 6502 address space (ie: $1C00-$1FFF)
  is initialised to point to the FIRST 1K of the ROM image, so the reset vectors
  must be placed at the end of the first 1K in the ROM image.

  Note: This is DIFFERENT to 3E which switches in the UPPER bank and this bank is
  fixed.  This allows variable sized ROM without having to detect size.

  ROM switching (write of block+bank number to $3F) D7D6 upper 2 bits of bank #
  indicates the destination segment (0-3, corresponding to $F000, $F400, $F800,
  $FC00), and lower 6 bits indicate the 1K bank to switch in.  Can handle 64
  x 1K ROM banks (64K total).

  D7 D6 D5D4D3D2D1D0
  0  0   x x x x x x   switch a 1K ROM bank xxxxxx to $F000
  0  1                 switch a 1K ROM bank xxxxxx to $F400
  1  0                 switch a 1K ROM bank xxxxxx to $F800
  1  1                 switch a 1K ROM bank xxxxxx to $FC00

  RAM switching (write of segment+bank number to $3E) with D7D6 upper 2 bits of
  bank # indicates the destination RAM segment (0-3, corresponding to $F000,
  $F400, $F800, $FC00).

  Can handle 64 x 512 byte RAM banks (32K total)

  D7 D6 D5D4D3D2D1D0
  0  0   x x x x x x   switch a 512 byte RAM bank xxxxxx to $F000 with write @ $F200
  0  1                 switch a 512 byte RAM bank xxxxxx to $F400 with write @ $F600
  1  0                 switch a 512 byte RAM bank xxxxxx to $F800 with write @ $FA00
  1  1                 switch a 512 byte RAM bank xxxxxx to $FC00 with write @ $FE00

 

  • Like 2
Link to comment
Share on other sites

On 10/11/2022 at 2:10 AM, Trip2018 said:

So I'm trying to make a demo. I want it to be a 64K demo, but I find swapping all 4k of a bank to waste too many cycles when all I'm doing is loading a byte or 2. So I've opted to have a 2k split format similar to what's elaborated here, where the last 2k is static and the rest is bank switched. Problem is, I don't think it exists for 64k... Maybe... I had no issues splitting up the chunks, but I'm not sure how to go about using "hotspots" for a scheme like this.

 

So what I wanna know is: How do these hotspots work? Are they tied to the console, or the rom's chipset?

 

If it's the rom, does that mean I have to define and write my own bankswitching scheme/hotspots? What emulators could I test it on that would work for a case like that?

64K? Pretty sure you could get 32K if you aren't doing anything extreme.. You're getting into Soni- cough cough, Zippy rom size stuff.

Link to comment
Share on other sites

7 hours ago, Ecernosoft said:

64K? Pretty sure you could get 32K if you aren't doing anything extreme.. You're getting into Soni- cough cough, Zippy rom size stuff.

It's compressed fmv. Nuff said! 👀 😅 Lucky me, after all the kernel and data I'll still have an extra 6k to fool around with. Maybe for an intro?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...