Previous 15994 Revisions Next

r2352 Thursday 10th April, 2008 at 10:11:21 UTC by Dirk Best
[COUPE] Improved external memory banking
[src/mess/includes]coupe.h
[src/mess/machine]coupe.c

src/mess/includes/coupe.h
r2351r2352
1515struct coupe_asic
1616{
1717   UINT8 lmpr, hmpr, vmpr; /* memory pages */
18   UINT8 lext, hext;       /* extended memory page */
1819   UINT8 border;           /* border */
1920   UINT8 clut[16];         /* color lookup table, 16 entries */
2021   UINT8 line_int;         /* line interrupt */
src/mess/machine/coupe.c
r2351r2352
3939}
4040
4141
42static void coupe_install_ext_mem(void)
43{
44   UINT8 *mem;
4245
46   /* bank 3 */
47   if (coupe_regs.lext >> 6 < mess_ram_size >> 20)
48      mem = &mess_ram[(mess_ram_size & 0xfffff) + (coupe_regs.lext >> 6) * 0x100000 + (coupe_regs.lext & 0x3f) * 0x4000];
49   else
50      mem = NULL;
51
52   coupe_update_bank(3, mem, FALSE);
53
54   /* bank 4 */
55   if (coupe_regs.hext >> 6 < mess_ram_size >> 20)
56      mem = &mess_ram[(mess_ram_size & 0xfffff) + (coupe_regs.hext >> 6) * 0x100000 + (coupe_regs.hext & 0x3f) * 0x4000];
57   else
58      mem = NULL;
59
60   coupe_update_bank(4, mem, FALSE);
61}
62
63
4364void coupe_update_memory(void)
4465{
66   const int PAGE_MASK = ((mess_ram_size & 0xfffff) / 0x4000) - 1;
4567   UINT8 *rom = memory_region(REGION_CPU1);
46   int PAGE_MASK = ((mess_ram_size & 0xfffff) / 0x4000) - 1;
4768   UINT8 *memory;
4869   int is_readonly;
4970
r2351r2352
6586
6687
6788   /* BANK2 */
68   if (( (coupe_regs.lmpr+1) & 0x1F) <= PAGE_MASK)
69      memory = &mess_ram[((coupe_regs.lmpr+1) & PAGE_MASK) * 0x4000];
89   if (((coupe_regs.lmpr + 1) & 0x1f) <= PAGE_MASK)
90      memory = &mess_ram[((coupe_regs.lmpr + 1) & PAGE_MASK) * 0x4000];
7091   else
7192      memory = NULL;   /* Attempt to page in non existant ram region */
7293   coupe_update_bank(2, memory, FALSE);
7394
7495   /* only update bank 3 and 4 when external memory is not enabled */
75   if (!(coupe_regs.hmpr & HMPR_MCNTRL))
96   if (coupe_regs.hmpr & HMPR_MCNTRL)
7697   {
98      coupe_install_ext_mem();
99   }
100   else
101   {
77102      /* BANK3 */
78      if ( (coupe_regs.hmpr & 0x1F) <= PAGE_MASK )
103      if ((coupe_regs.hmpr & 0x1F) <= PAGE_MASK )
79104         memory = &mess_ram[(coupe_regs.hmpr & PAGE_MASK)*0x4000];
80105      else
81106         memory = NULL;   /* Attempt to page in non existant ram region */
82107      coupe_update_bank(3, memory, FALSE);
83   
84   
108
109
85110      /* BANK4 */
86111      if (coupe_regs.lmpr & LMPR_ROM1)   /* Is Rom1 paged in at bank 4 */
87112      {
r2351r2352
90115      }
91116      else
92117      {
93         if (( (coupe_regs.hmpr+1) & 0x1F) <= PAGE_MASK)
94            memory = &mess_ram[((coupe_regs.hmpr+1) & PAGE_MASK) * 0x4000];
118         if (((coupe_regs.hmpr + 1) & 0x1f) <= PAGE_MASK)
119            memory = &mess_ram[((coupe_regs.hmpr + 1) & PAGE_MASK) * 0x4000];
95120         else
96121            memory = NULL;   /* Attempt to page in non existant ram region */
97122         is_readonly = FALSE;
r2351r2352
99124      coupe_update_bank(4, memory, FALSE);
100125   }
101126
127   /* video memory location */
102128   if (coupe_regs.vmpr & 0x40)   /* if bit set in 2 bank screen mode */
103      videoram = &mess_ram[((coupe_regs.vmpr&0x1E) & PAGE_MASK) * 0x4000];
129      videoram = &mess_ram[((coupe_regs.vmpr & 0x1e) & PAGE_MASK) * 0x4000];
104130   else
105      videoram = &mess_ram[((coupe_regs.vmpr&0x1F) & PAGE_MASK) * 0x4000];
131      videoram = &mess_ram[((coupe_regs.vmpr & 0x1f) & PAGE_MASK) * 0x4000];
106132}
107133
108134
109135WRITE8_HANDLER( coupe_ext_mem_w )
110136{
137   if (offset & 1)
138      coupe_regs.hext = data;
139   else
140      coupe_regs.lext = data;
141
111142   /* external RAM enabled? */
112143   if (coupe_regs.hmpr & HMPR_MCNTRL)
113144   {
114      UINT8 *mem = NULL;
115
116      /* only install if we have enough memory */
117      if (data >> 6 < mess_ram_size >> 20)
118         mem = &mess_ram[(mess_ram_size & 0xfffff) + (data >> 6) * 0x100000 + (data & 0x3f) * 0x4000];
119
120      coupe_update_bank(offset & 1 ? 4 : 3, mem, FALSE);
145      coupe_install_ext_mem();
121146   }
122147}
123148

Previous 15994 Revisions Next


© 1998-2018 The MESS Team