User Tools

Site Tools


base:memory_management

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
base:memory_management [2015-04-17 04:32] – external edit 127.0.0.1base:memory_management [2022-03-06 10:20] – [With Cartridges] white_flame
Line 3: Line 3:
 (Someone please integrate the texts on this page into one...) (Someone please integrate the texts on this page into one...)
  
-Oswald/Resource here, I will try to give you a much smaller and easier to understand info on the c64's ROM&IO registers banking system:+====== Without Cartridges ======
  
-the c64 has 64k ram overlapped with ROMs and IO register areas. The IO area is where the registers of the various chips of the c64 are visible.+The low 3 bits of $01 control the mapping of specific regions of memory When a bit is set to 0, it activates its bank, but the interplay between them is kind of fiddly:
  
-memory map:+^Name ^Bit ^Region ^0 ^1 ^Notes^ 
 +|LORAM|0|$A000-BFFF|RAM|BASIC|If KERNAL isn't mapped in, then BASIC won'map in either and this region stays mapped to RAM.| 
 +|HIRAM|1|$E000-FFFF|RAM|KERNAL| | 
 +|CHAREN|2|$D000-DFFF|CHARROM|I/O|If HIRAM and LORAM are both set to 0, then this bit is ignored and the area also maps to RAM. This allows for 3 mappings of this regionRAM, CHARROM, or I/O.|
  
-<code> +  * All other memory locations ($0002-9FFF, $C000-CFFF) always map to RAM. 
-0000-A000 RAM +  * Writes to a ROM-mapped region are applied to the underlying RAM at the same address. 
-A000-C000 RAM  _OR_ BASIC ROM +  * I/O includes the registers for the VIC-II, SID, and CIA chips; color RAM; and two external I/O pages that reach out the expansion port. 
-C000-D000 RAM +  * The VIC-II always sees the CHARROM at $1000-1FFF and $9000-9FFF, and RAM everywhere else, regardless of these bits.
-D000-E000 RAM  _OR_ IO         _OR_ CHAR ROM +
-E000-FFFF RAM  _OR_ KERNAL ROM +
-</code>+
  
-Memory address $01 controls if the ROMs or RAMs etc. are visible on the given memory map above.+The mappings from combining these 3 bits are listed below.  Higher bits of location $01 are used for other purposes and default to %00110xxx.
  
-<code> +^$01 value ^$A000-BFFF ^$D000-DFFF ^$E000-FFFF ^Notes^ 
-$01=$37 -> Basic Rom visible A000-C000, IO visible at D000-E000, Kernal Rom Visible at E000-FFFF +|$30 +48 %000 |RAM |RAM |RAM| 
-$01=$36 -> RAM       visible A000-C000, IO visible at D000-E000, Kernal Rom Visible at E000-FFFF +|$31 +49 %001 |RAM |CHARROM |RAM| 
-$01=$35 -> RAM       visible A000-C000, IO visible at D000-E000, RAM        Visible at E000-FFFF +|$32 +50 %010 |RAM |CHARROM |KERNAL| 
-$01=$34 -> RAM       visible A000-C000, RAM visible at D000-E000, RAM        Visible at E000-FFFF +|$33 +51 %011 |BASIC |CHARROM |KERNAL| 
-$01=$33 -> RAM       visible A000-C000, CHAR ROM   at D000-E000, RAM        Visible at E000-FFFF +
-</code>+|$34 +52 %100 |RAM |RAM |RAM| 
 +|$35 +53 %101 |RAM |I/O |RAM| 
 +|$36 +54 %110 |RAM |I/O |KERNAL| 
 +|$37 +55 %111 |BASIC |I/O |KERNAL|Default|
  
-thats all.+***WARNING***: Don't use INC $01 to switch modes from %111 to %000, as that will turn on the tape write head on the next bit up and do bad/unintentional things if there's stuff attached to the tape port.
  
-Char Rom behaves weird, as from the processors point of view normally its invisible, and if you turn it on the CPU "sees" it always at D000-E000. From the VIC's viewpoint this is all different. The VIC sees the char ROM _always_ at the memory areas $1000-$2000 and $9000-$a000 making these ram areas unusable for storing gfx, as no matter what the VIC will read from the char ROM at these addresses. 
  
-===== Related: from Graham's page =====+====== With Cartridges ====== 
 + 
 +The expansion port has 2 configuration inputs (/EXROM and /GAME), and 4 chip select outputs (/IO1, /IO2, /ROML, /ROMH). 
 + 
 +/IO1 and /IO2 lines are active on both reads & writes to their respective memory ranges, any time that I/O is banked in: 
 +  * /IO1 = $DE00 - $DEFF 
 +  * /IO2 = $DF00 - $DFFF 
 + 
 +/ROML and /ROMH are active on reads depending on how the cartridge sets the configuration inputs.  Normally, ROML sits right before the BASIC ROM at $8000-9FFF, while ROMH replaces BASIC itself.  Writes to these areas still go to internal RAM and do not activate the external chip select lines.  Ultimax mode has ROMH replacing the KERNAL and unmaps a lot of the internal RAM. 
 + 
 + 
 +===== Cart pulls /EXROM low ===== 
 + 
 +The simplest C64-mode cartridge configuration, only using ROML.  Any time the BASIC ROM is visible in at $A000, ROML is also visible in the 8kB before it. 
 + 
 +^$01 value ^$8000-9FFF ^$A000-BFFF ^$D000-DFFF ^$E000-FFFF ^Notes^ 
 +|$30 +48 %000 |RAM |RAM |RAM |RAM| 
 +|$31 +49 %001 |RAM |RAM |CHARROM |RAM| 
 +|$32 +50 %010 |RAM |RAM |CHARROM |KERNAL| 
 +|$33 +51 %011 |**__ROML__** |BASIC |CHARROM |KERNAL| 
 +
 +|$34 +52 %100 |RAM |RAM |RAM |RAM| 
 +|$35 +53 %101 |RAM |RAM |I/O |RAM| 
 +|$36 +54 %110 |RAM |RAM |I/O |KERNAL| 
 +|$37 +55 %111 |**__ROML__** |BASIC |I/O |KERNAL|Default| 
 + 
 +===== Cart pulls /EXROM + /GAME low ===== 
 + 
 +ROML is before BASIC, and is swapped out with the LORAM bit in $01.  ROMH replaces BASIC, and HIRAM swaps out both it and the KERNAL.  There is no KERNAL-only mode in this configuration. 
 + 
 +^$01 value ^$8000-9FFF ^$A000-BFFF ^$D000-DFFF ^$E000-FFFF ^Notes^ 
 +|$30 +48 %000 |RAM |RAM |RAM |RAM| 
 +|$31 +49 %001 |RAM |RAM |CHARROM |RAM| 
 +|$32 +50 %010 |RAM |**__ROMH__** |CHARROM |KERNAL| 
 +|$33 +51 %011 |**__ROML__** |**__ROMH__** |CHARROM |KERNAL| 
 +
 +|$34 +52 %100 |RAM |RAM |RAM |RAM| 
 +|$35 +53 %101 |RAM |RAM |I/O |RAM| 
 +|$36 +54 %110 |RAM |**__ROMH__** |I/O |KERNAL| 
 +|$37 +55 %111 |**__ROML__** |**__ROMH__** |I/O |KERNAL|Default| 
 + 
 +===== Cart pulls only /GAME low (Ultimax mode) ===== 
 + 
 +ROMH replaces the KERNAL at $E000, ROML is still at $8000.  Only the lowest 4kB of internal RAM remains visible, and I/O cannot be swapped out.  None of the bits in $01 affect the banking in this mode. 
 + 
 +^$0000-0FFF ^$1000-7FFF ^$8000-9FFF ^$A000-CFFF ^$D000-DFFF ^$E000-FFFF ^ 
 +|RAM |unmapped |**__ROML__** |unmapped |I/O |**__ROMH__**| 
 + 
 +The VIC-II will also see the first 4kB of ROMH at $3000-3FFF in all of its 16kB banks, with no access to CHARROM. 
 + 
 + 
 +- White Flame 
 + 
 + 
 +====== Related: from Graham's page ======
  
 In the C64/C128 series of computers, slightly modified versions of the 6502 were used. The modifications did not affect the functional part of the processor itself. Only a so-called processor port was added. This port, in combination with an external PLA, was used to map ROM and I/O areas into the 64KB RAM of the C64. Also, some bits of the port were used for the legendary Datasette. In the C64/C128 series of computers, slightly modified versions of the 6502 were used. The modifications did not affect the functional part of the processor itself. Only a so-called processor port was added. This port, in combination with an external PLA, was used to map ROM and I/O areas into the 64KB RAM of the C64. Also, some bits of the port were used for the legendary Datasette.
base/memory_management.txt · Last modified: 2022-04-17 05:36 by white_flame