/* Module for the Memory and the Memory Management Unit (MMU). Module MEM_MMU.[hc] Copyright (C) 1998/1999 by Andreas Gerlich (agl) This file is part of yaze-ag - yet another Z80 emulator by ag. Yaze-ag is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include "mem_mmu.h" BYTE ram[MEMSIZE*1024]; /* the whole memory space */ #ifdef MMU /* <------------------------- only if MMU is selected ------------ */ #include "simz80.h" /* for the definitions of the Z80 registers */ pagetab_struct MMUtable[MMUTABLES]; /* MMU page tables (default 8) */ pagetab_struct *mmu; /* Pointer to selected MMU-pagetable */ pagetab_struct *dmmu = &MMUtable[0]; /* Pointer to destination MMU-pagetbl */ pagetab_struct *mmuget,*mmuput; /* Pointer for get/put */ int mmutab; /* choosen MMU-pagetable */ /*------------------------------------------- initMEM ------------------*/ void initMEM() { int p; for (p=0; p= 192) { mmu->page[11] = PP(16); /* B000H point to 10000H */ mmu->page[10] = PP(32); /* A000H point to 20000H */ mmu->page[ 9] = PP(19); /* 9000H point to 13000H */ mmu->page[ 8] = PP(18); /* 8000H point to 12000H */ mmu->page[ 7] = PP(0x1E); /* 7000H point to 1E000H */ mmu->page[ 6] = PP(0x1D); /* 6000H point to 1D000H */ mmu->page[ 5] = PP(47); /* 5000H point to 2F000H */ mmu->page[ 4] = PP(44); /* 4000H point to 2C000H */ mmu->page[ 3] = PP(1); /* 3000H point to 2A000H */ mmu->page[ 1] = PP(42); /* 3000H point to 2A000H */ /* mmu->page[ 0] = PP(41); \* 3000H point to 29000H */ } /***** extra test for the MMU-Tables for (m=0; mpage[i] = PP( page ); } else { Sethreg(AF, 0xfe); /* 0xfe not OK */ HL--; /* Points HL-Register to the wrong byte */ #ifdef MMUTEST printf("\r\nYAZE: Load-MMU-Table %d : Page No. %d for " "the %d. pagepointer is wrong!\r\n",h_mmut,page,i); printf(" posible max. number " "is %d\n",RAMPAGES-1); #endif break; /* for */ } } else { Sethreg(AF, 0xff); /* 0xff not OK */ HL--; /* Points HL-Register to the wrong byte */ #ifdef MMUTEST printf("\r\nYAZE: Load-MMU-Table %d <-- Number for the selected " "table is out of range!\r\n",h_mmut); #endif } } /* END of loadMMU() */ /*------------------------------------------- printMMU -----------------*/ void printMMU() { int c,m,i; printf("RAM: %d KByte, %d KByte YAZEPAGESIZE, %d PAGES\r\n", MEMSIZE, YAZEPAGESIZE, RAMPAGES); printf("MMU: %d TABLES, %d PAGEPOINTERS per TABLE, ", MMUTABLES, MMUPAGEPOINTERS); printf("selected MMU-PAGETABLE: T%02d\r\n\n", mmutab); /* puts("Z80-\\ T00 T01 T02 T03 T04 T05 T06 T07" " T08 T09 T10 T11 T12 T13 T14 T15\r\n"); */ printf("Z80-\\ "); for (m=0; m"); else if (m != mmutab+1) printf(" "); if ((i=((MMUtable[m].page[c]-ram)>>12)) <= 0xFFFF ) { printf("%3X",i); } else { printf(" %5X ",i); } if (m == mmutab) printf("< "); } puts("\r"); } puts("-----------------------------------------------------------------" "---------\r"); } /* END of printMMU() */ #endif /* MMU <------------------------- only if MMU is selected ------------ */ /*--------------------------- END of Module mem_mmu.c -----------------------*/