|
Post by jmpff3d on Nov 10, 2018 20:21:35 GMT
; ;=============================================================================== ; ; Commodore 128 - 8722 MEMORY MANAGEMENT UNIT ; mmu =$d500 ;configuration reg in I/O block mmuhi =$ff00 ;configuration reg in hi RAM ; ; mmucr =mmuhi ;configuration... ; ; 7 6 54 32 1 0 ;---------------- ; 0 x xx xx x x ; | || || | | ; | || || | +---> $D000-$DFFF: 0 = I/O hardware ; | || || | 1 = RAM or character ROM ; | || || +----> $4000-$7FFF: 0 = system ROM ; | || || 1 = RAM ; | || ++-----> $8000-$BFFF: 00 = system ROM ; | || 01 = internal function ROM ; | || 10 = external function ROM ; | || 11 = RAM ; | ++-------> $C000-$FFFF: 00 = system ROM ; | 01 = internal function ROM ; | 10 = external function ROM ; | 11 = RAM ; +---------> RAM bank: 0 = RAM-0 ; 1 = RAM-1 ; pcra =mmu+1 ;preconfiguration A pcrb =mmu+2 ;preconfiguration B pcrc =mmu+3 ;preconfiguration C pcrd =mmu+4 ;preconfiguration D ; ; mmumcr =mmu+5 ;mode configuration... ; ; 7 6 5 4 3 21 0 ;----------------- ; x x x x x 00 x ; | | | | | | ; | | | | | +---> active MPU: 0 = Z80 ; | | | | | 1 = 8502 ; | | | | +------> FSDIR (fast serial control) ; | | | +-------> /GAME ; | | +--------> /EXROM ; | +---------> ROM select: 0 = C-128 ; | 1 = C-64 ; +----------> 40/80 key: 0 = 80 (down) ; 1 = 40 (up) ; ; mmurcr =mmu+6 ;memory map configuration... ; ; 7 6 54 32 10 ;--------------- ; 0 x 00 xx xx ; | || || ; | || ++---> common RAM size: 00 = 1K ; | || 01 = 4K ; | || 10 = 8K ; | || 11 = 16K ; | ++-----> common RAM area: 00 = none ; | 01 = bottom ; | 10 = top ; | 11 = both ; +---------> VIC video bank: 0 = RAM-0 ; 1 = RAM-1 ; mmup0l =mmu+7 ;virtual zero page location mmup0h =mmu+8 ;virtual zero page RAM bank mmup1l =mmu+9 ;virtual MPU stack location mmup1h =mmu+10 ;virtual MPU stack RAM bank ; lcra =mmucr+1 ;select configuration A lcrb =mmucr+2 ;select configuration B lcrc =mmucr+3 ;select configuration C lcrd =mmucr+4 ;select configuration D ;
|
|
|
Post by jmpff3d on Nov 11, 2018 23:07:21 GMT
Sample code, related to MMU BitSwitching ...
; "proof of mmu banking" is by #$00 written to ram at $d020/21 without causing change of screen color ; visible in 128 ml monitor -- use .. m 1d020 ; ; redirecting zp and stack (and back again) to show it can be done while the system is running ; the relocated stack is unfortunately not directly visible through ml monitor, after you return to normal stack
. 12000 78 sei . 12001 a9 7f lda #$7f ; sets up alt ramblock with "bank1" config . 12003 8d 00 ff sta $ff00 ; mmu config register mirror . 12006 a2 01 ldx #$01 . 12008 8e 0a d5 stx $d50a ; sets stack to alt ramblock (1) .. required . 1200b 8e 09 d5 stx $d509 ; sets stack to page one .. (not needed here, only for formality) . 1200e 8e 08 d5 stx $d508 ; sets zp to alt ramblock (1) .. required . 12011 ca dex . 12012 8e 07 d5 stx $d507 ; sets zp to page 0 .. (not needed here, only for formality) . 12015 49 7f eor #$7f ; zeros out A . 12017 8d 06 d5 sta $d506 ; 0 to $d506 mmu ram config for all ram access to alt ramblock, no i/o . 1201a a0 04 ldy #$04 . 1201c 8d 20 d0 sta $d020 ; hits here should -NOT- cause visible screen display changes . 1201f 99 04 01 sta $0104,y ; tiny test fill of stack now at alt-ramblock ; c128 BASIC/Monitor will still poll from zp/stack, if you allow it . 12022 88 dey . 12023 d0 f7 bne $201c . 12025 8e 20 d0 stx $d020 ; hits here should -NOT- cause visible screen display changes . 12028 8c 20 d0 sty $d020 ; " " . 1202b 8c 21 d0 sty $d021 ; " " . 1202e 8c 0a d5 sty $d50a ; sets stack to normal ramblock (0) .. required . 12031 8c 08 d5 sty $d508 ; sets zp to normal ramblock (0) .. required . 12034 88 dey . 12035 8c 00 ff sty $ff00 ; mmu config register back to "bank0" config . 12038 a9 04 lda #$04 ; mmu ram config back to normal . 1203a 8d 06 d5 sta $d506 . 1203d 58 cli . 1203e 60 rts
; you can paste these bytes below into emulated machine @ ml monitor, for quick testing of the above code >12000 78 a9 7f 8d 00 ff a2 01 >12008 8e 0a d5 8e 09 d5 8e 08 >12010 d5 ca 8e 07 d5 49 7f 8d >12018 06 d5 a0 04 8d 20 d0 99 >12020 04 01 88 d0 f7 8e 20 d0 >12028 8c 20 d0 8c 21 d0 8c 0a >12030 d5 8c 08 d5 88 8c 00 ff >12038 a9 04 8d 06 d5 58 60 ff
|
|