| 1 |
;ACME 0.95 |
| 2 |
|
| 3 |
!ifdef lib_cbm_c128_mmu_a !eof |
| 4 |
lib_cbm_c128_mmu_a = 2 |
| 5 |
|
| 6 |
; Memory Management Unit (MMU) 8722 |
| 7 |
|
| 8 |
|
| 9 |
; registers in i/o area (i/o needs to be enabled to access these): |
| 10 |
|
| 11 |
!address { |
| 12 |
; configuration register |
| 13 |
mmu_cr_d500 = $d500 ; same as "mmu_cr" at $ff00. Use "mmu_cr" instead, as that is *always* available. |
| 14 |
; preconfiguration registers (internal format just like mmu_cr) |
| 15 |
mmu_pcr_a = $d501 ; c128 kernal default is $3f (BANK 0) |
| 16 |
mmu_pcr_b = $d502 ; c128 kernal default is $7f (BANK 1) |
| 17 |
mmu_pcr_c = $d503 ; c128 kernal default is $01 (BANK 14) |
| 18 |
mmu_pcr_d = $d504 ; c128 kernal default is $41 (all system roms, with ram 1) |
| 19 |
} |
| 20 |
; contents of cr and all four pcr: |
| 21 |
mmu_CR_RAMBANK_MASK = %##...... ; this controls which RAM bank is used in areas where RAM is enabled |
| 22 |
;mmu_CR_RAMBANK_0 = %........ |
| 23 |
mmu_CR_RAMBANK_1 = %.#...... |
| 24 |
mmu_CR_RAMBANK_2 = %#....... ; on an unmodified c128, there is no ram bank 2 (0 will be used instead) |
| 25 |
mmu_CR_RAMBANK_3 = %##...... ; on an unmodified c128, there is no ram bank 3 (1 will be used instead) |
| 26 |
|
| 27 |
mmu_CR_HIGH_MASK = %..##.... ; this controls the "high area" (c000..ffff), but i/o (d000..dfff) is separate |
| 28 |
;mmu_CR_HIGH_SYSROM = %........ ; editor, charset (or i/o, see below), kernal |
| 29 |
mmu_CR_HIGH_INTFUNCROM = %...#.... |
| 30 |
mmu_CR_HIGH_EXTFUNCROM = %..#..... |
| 31 |
mmu_CR_HIGH_RAM = %..##.... |
| 32 |
|
| 33 |
mmu_CR_MID_MASK = %....##.. ; this controls the "middle area" (8000..bfff) |
| 34 |
;mmu_CR_MID_SYSROM = %........ ; this is the upper half of basic |
| 35 |
mmu_CR_MID_INTFUNCROM = %.....#.. |
| 36 |
mmu_CR_MID_EXTFUNCROM = %....#... |
| 37 |
mmu_CR_MID_RAM = %....##.. |
| 38 |
|
| 39 |
mmu_CR_LOW_MASK = %......#. ; this controls the "low area" (4000..7fff) |
| 40 |
;mmu_CR_LOW_SYSROM = %........ ; this is the lower half of basic |
| 41 |
mmu_CR_LOW_RAM = %......#. |
| 42 |
|
| 43 |
mmu_CR_IO_MASK = %.......# ; this controls i/o space (d000..dfff) |
| 44 |
;mmu_CR_IO_ON = %........ |
| 45 |
mmu_CR_IO_OFF = %.......# ; if i/o is off, contents depend on "high area" |
| 46 |
|
| 47 |
; configuration register values used by C128 firmware (lookup table at $f7f0, see end of file): |
| 48 |
mmu_CR_BANK0 = $3f ; full 64 KiB ram bank 0 |
| 49 |
mmu_CR_BANK1 = $7f ; full 64 KiB ram bank 1 |
| 50 |
mmu_CR_BANK2 = $bf ; full 64 KiB ram bank 2 |
| 51 |
mmu_CR_BANK3 = $ff ; full 64 KiB ram bank 3 |
| 52 |
mmu_CR_BANK4 = $16 ; 32 KiB bank 0; 32 KiB IFROM with i/o overlay |
| 53 |
mmu_CR_BANK5 = $56 ; 32 KiB bank 1; 32 KiB IFROM with i/o overlay |
| 54 |
mmu_CR_BANK6 = $96 ; 32 KiB bank 2; 32 KiB IFROM with i/o overlay |
| 55 |
mmu_CR_BANK7 = $d6 ; 32 KiB bank 3; 32 KiB IFROM with i/o overlay |
| 56 |
mmu_CR_BANK8 = $2a ; 32 KiB bank 0; 32 KiB EFROM with i/o overlay |
| 57 |
mmu_CR_BANK9 = $6a ; 32 KiB bank 1; 32 KiB EFROM with i/o overlay |
| 58 |
mmu_CR_BANK10 = $aa ; 32 KiB bank 2; 32 KiB EFROM with i/o overlay |
| 59 |
mmu_CR_BANK11 = $ea ; 32 KiB bank 3; 32 KiB EFROM with i/o overlay |
| 60 |
mmu_CR_BANK12 = $06 ; 32 KiB bank 0; 16 KiB IFROM; 16 KiB kernal with i/o overlay |
| 61 |
mmu_CR_BANK13 = $0a ; 32 KiB bank 0; 16 KiB EFROM; 16 KiB kernal with i/o overlay |
| 62 |
mmu_CR_BANK14 = $01 ; 16 KiB bank 0; 32 KiB basic; 16 KiB kernal with font overlay |
| 63 |
mmu_CR_BANK15 = $00 ; 16 KiB bank 0; 32 KiB basic; 16 KiB kernal with i/o overlay |
| 64 |
; An unmodified C128 does not have a "ram bank 2" or "ram bank 3". |
| 65 |
; Whenever one of these is activated, ram banks 0 and 1 will be used instead. |
| 66 |
; IFROM means internal function ROM (socket U36) |
| 67 |
; EFROM means external function ROM (socket in a REU, for example) |
| 68 |
|
| 69 |
!address { |
| 70 |
; mode configuration register |
| 71 |
mmu_mcr = $d505 |
| 72 |
} |
| 73 |
; contents: |
| 74 |
mmu_MCR_40COLUMNS = %#....... ; (pin 48) 40/80 key: 0 means pressed, 1 means released (writable! if cleared, will always read as 0!) |
| 75 |
mmu_MCR_C64MODE = %.#...... ; (pin 47) setting this bit makes the MMU disappear from the memory map :) |
| 76 |
mmu_MCR_EXROM = %..#..... ; (pin 46) if zero on boot, system will enter c64 mode (writable!) |
| 77 |
mmu_MCR_GAME = %...#.... ; (pin 45) if zero on boot, system will enter c64 mode (writable!) |
| 78 |
mmu_MCR_FSDIR_OUTPUT = %....#... ; (pin 44) direction of fast serial bus |
| 79 |
mmu_MCR_UNUSED = %.....##. ; always set |
| 80 |
mmu_MCR_8502MODE = %.......# ; (pin 43 inverted) setting this to zero switches to Z80 cpu |
| 81 |
|
| 82 |
!address { |
| 83 |
; ram configuration register |
| 84 |
mmu_rcr = $d506 |
| 85 |
} |
| 86 |
; contents: |
| 87 |
mmu_RCR_VICBANK_MASK = %##...... ; this controls which RAM bank is "seen" by VIC |
| 88 |
;mmu_RCR_VICBANK_0 = %........ |
| 89 |
mmu_RCR_VICBANK_1 = %.#...... |
| 90 |
mmu_RCR_VICBANK_2 = %#....... ; on an unmodified c128, there is no ram bank 2 (0 will be used instead) |
| 91 |
mmu_RCR_VICBANK_3 = %##...... ; on an unmodified c128, there is no ram bank 3 (1 will be used instead) |
| 92 |
|
| 93 |
mmu_RCR_RAMBLOCK_MASK = %..##.... ; on an unmodified c128, these bits are irrelevant (they select 256 KiB of 1 MiB of memory) |
| 94 |
;mmu_RCR_RAMBLOCK_0 = %........ |
| 95 |
mmu_RCR_RAMBLOCK_1 = %...#.... ; on an unmodified c128, there is only ram block 0 |
| 96 |
mmu_RCR_RAMBLOCK_2 = %..#..... ; on an unmodified c128, there is only ram block 0 |
| 97 |
mmu_RCR_RAMBLOCK_3 = %..##.... ; on an unmodified c128, there is only ram block 0 |
| 98 |
|
| 99 |
mmu_RCR_SHARE_MASK = %....##.. |
| 100 |
;mmu_RCR_SHARE_NONE = %........ |
| 101 |
mmu_RCR_SHARE_BOTTOM = %.....#.. ; system default |
| 102 |
mmu_RCR_SHARE_TOP = %....#... |
| 103 |
|
| 104 |
mmu_RCR_SHARESIZE_MASK = %......## |
| 105 |
;mmu_RCR_SHARESIZE_1K = %........ ; system default |
| 106 |
mmu_RCR_SHARESIZE_4K = %.......# |
| 107 |
mmu_RCR_SHARESIZE_8K = %......#. |
| 108 |
mmu_RCR_SHARESIZE_16K = %......## |
| 109 |
|
| 110 |
!address { |
| 111 |
; page pointers for zero page and stack: |
| 112 |
; write to "bank" register will be latched (reading gives old value) |
| 113 |
; until "page" register is written to as well. |
| 114 |
mmu_zp_page = $d507 ; address bits a8..a15, default $00 |
| 115 |
mmu_zp_bank = $d508 ; address bits a16..a19, default $0 (on an unmodified c128, only bit0 is meaningful) |
| 116 |
mmu_stack_page = $d509 ; address bits a8..a15, default $01 |
| 117 |
mmu_stack_bank = $d50a ; address bits a16..a19, default $0 (on an unmodified c128, only bit0 is meaningful) |
| 118 |
} |
| 119 |
mmu_PxH_UNUSED = %####.... ; always set |
| 120 |
|
| 121 |
mmu_PxH_RAMBLOCK_MASK = %....##.. |
| 122 |
;mmu_PxH_RAMBLOCK_0 = %........ |
| 123 |
mmu_PxH_RAMBLOCK_1 = %.....#.. ; on an unmodified c128, there is only ram block 0 |
| 124 |
mmu_PxH_RAMBLOCK_2 = %....#... ; on an unmodified c128, there is only ram block 0 |
| 125 |
mmu_PxH_RAMBLOCK_3 = %....##.. ; on an unmodified c128, there is only ram block 0 |
| 126 |
|
| 127 |
mmu_PxH_RAMBANK_MASK = %......## |
| 128 |
;mmu_PxH_RAMBANK_0 = %........ |
| 129 |
mmu_PxH_RAMBANK_1 = %.......# |
| 130 |
mmu_PxH_RAMBANK_2 = %......#. ; on an unmodified c128, there is no ram bank 2 (0 will be used instead) |
| 131 |
mmu_PxH_RAMBANK_3 = %......## ; on an unmodified c128, there is no ram bank 3 (1 will be used instead) |
| 132 |
|
| 133 |
!address { |
| 134 |
; version register |
| 135 |
mmu_vr = $d50b ; read-only, value is $20 |
| 136 |
} |
| 137 |
mmu_VR_BANKS_MASK = %####.... ; 2 ram banks |
| 138 |
mmu_VR_VERSION_MASK = %....#### ; mmu version 0 |
| 139 |
|
| 140 |
; reading addresses up until $d5ff returns $ff |
| 141 |
|
| 142 |
|
| 143 |
; these registers are always available (in *every* memory configuration) unless C64 mode is entered: |
| 144 |
|
| 145 |
!address { |
| 146 |
; configuration register |
| 147 |
mmu_cr = $ff00 ; always use this instead of $d500 |
| 148 |
; load configuration registers: |
| 149 |
; a read access will return the value of the corresponding preconfiguration register |
| 150 |
; any write access will copy the value of the corresponding preconfiguration register to mmu_cr |
| 151 |
mmu_lcr_a = $ff01 ; c128 kernal default is $3f (BANK 0) |
| 152 |
mmu_lcr_b = $ff02 ; c128 kernal default is $7f (BANK 1) |
| 153 |
mmu_lcr_c = $ff03 ; c128 kernal default is $01 (BANK 14) |
| 154 |
mmu_lcr_d = $ff04 ; c128 kernal default is $41 (all system roms, with ram 1) |
| 155 |
|
| 156 |
; the c128 ROMs contain a look-up table to convert bank numbers to their |
| 157 |
; corresponding configuration register values: |
| 158 |
; romc_* needs "high rom area" enabled ($c000..$ffff) |
| 159 |
romc_bank_to_cr_table = $f7f0 ; 3f 7f bf ff 16 56 96 d6 2a 6a aa ea 06 0a 01 00 |
| 160 |
} |