Previous 15994 Revisions Next

r2348 Wednesday 9th April, 2008 at 13:26:03 UTC by Dirk Best
[COUPE] Added support for external memory
[src/mess/drivers]coupe.c
[src/mess/includes]coupe.h
[src/mess/machine]coupe.c

src/mess/includes/coupe.h
r2347r2348
3333
3434void coupe_update_memory(void);
3535
36WRITE8_HANDLER( coupe_ext_mem_w );
3637MACHINE_START( coupe );
3738MACHINE_RESET( coupe );
3839
src/mess/machine/coupe.c
r2347r2348
1414#include "machine/msm6242.h"
1515
1616
17#define LMPR_RAM0   0x20   /* If bit set ram is paged into bank 0, else its rom0 */
18#define LMPR_ROM1   0x40   /* If bit set rom1 is paged into bank 3, else its ram */
17#define LMPR_RAM0    0x20   /* If bit set ram is paged into bank 0, else its rom0 */
18#define LMPR_ROM1    0x40   /* If bit set rom1 is paged into bank 3, else its ram */
19#define HMPR_MCNTRL  0x80   /* If set external RAM is enabled */
1920
2021
2122struct coupe_asic coupe_regs;
r2347r2348
2324
2425static void coupe_update_bank(int bank, UINT8 *memory, int is_readonly)
2526{
26   read8_machine_func rh;
27   write8_machine_func wh;
27   read8_machine_func rh = SMH_NOP;
28   write8_machine_func wh = SMH_NOP;
2829
2930   if (memory)
31   {
3032      memory_set_bankptr(bank, memory);
33      rh = (read8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1);
34      wh = is_readonly ? SMH_UNMAP : (write8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1);
35   }
3136
32   rh = !memory ? SMH_NOP :                        (read8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1);
33   wh = !memory ? SMH_NOP : (is_readonly ? SMH_UNMAP :   (write8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1));
34
3537   memory_install_read8_handler(0,  ADDRESS_SPACE_PROGRAM, ((bank-1) * 0x4000), ((bank-1) * 0x4000) + 0x3FFF, 0, 0, rh);
3638   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, ((bank-1) * 0x4000), ((bank-1) * 0x4000) + 0x3FFF, 0, 0, wh);
3739}
r2347r2348
4143void coupe_update_memory(void)
4244{
4345   UINT8 *rom = memory_region(REGION_CPU1);
44   int PAGE_MASK = (mess_ram_size / 0x4000) - 1;
46   int PAGE_MASK = ((mess_ram_size & 0xfffff) / 0x4000) - 1;
4547   UINT8 *memory;
4648   int is_readonly;
4749
r2347r2348
6971      memory = NULL;   /* Attempt to page in non existant ram region */
7072   coupe_update_bank(2, memory, FALSE);
7173
72
73   /* BANK3 */
74   if ( (coupe_regs.hmpr & 0x1F) <= PAGE_MASK )
75      memory = &mess_ram[(coupe_regs.hmpr & PAGE_MASK)*0x4000];
76   else
77      memory = NULL;   /* Attempt to page in non existant ram region */
78   coupe_update_bank(3, memory, FALSE);
79
80
81   /* BANK4 */
82   if (coupe_regs.lmpr & LMPR_ROM1)   /* Is Rom1 paged in at bank 4 */
74   /* only update bank 3 and 4 when external memory is not enabled */
75   if (!(coupe_regs.hmpr & HMPR_MCNTRL))
8376   {
84      memory = rom + 0x4000;
85      is_readonly = TRUE;
86   }
87   else
88   {
89      if (( (coupe_regs.hmpr+1) & 0x1F) <= PAGE_MASK)
90         memory = &mess_ram[((coupe_regs.hmpr+1) & PAGE_MASK) * 0x4000];
77      /* BANK3 */
78      if ( (coupe_regs.hmpr & 0x1F) <= PAGE_MASK )
79         memory = &mess_ram[(coupe_regs.hmpr & PAGE_MASK)*0x4000];
9180      else
9281         memory = NULL;   /* Attempt to page in non existant ram region */
93      is_readonly = FALSE;
82      coupe_update_bank(3, memory, FALSE);
83   
84   
85      /* BANK4 */
86      if (coupe_regs.lmpr & LMPR_ROM1)   /* Is Rom1 paged in at bank 4 */
87      {
88         memory = rom + 0x4000;
89         is_readonly = TRUE;
90      }
91      else
92      {
93         if (( (coupe_regs.hmpr+1) & 0x1F) <= PAGE_MASK)
94            memory = &mess_ram[((coupe_regs.hmpr+1) & PAGE_MASK) * 0x4000];
95         else
96            memory = NULL;   /* Attempt to page in non existant ram region */
97         is_readonly = FALSE;
98      }
99      coupe_update_bank(4, memory, FALSE);
94100   }
95   coupe_update_bank(4, memory, FALSE);
96101
97
98102   if (coupe_regs.vmpr & 0x40)   /* if bit set in 2 bank screen mode */
99103      videoram = &mess_ram[((coupe_regs.vmpr&0x1E) & PAGE_MASK) * 0x4000];
100104   else
r2347r2348
102106}
103107
104108
109WRITE8_HANDLER( coupe_ext_mem_w )
110{
111   /* external RAM enabled? */
112   if (coupe_regs.hmpr & HMPR_MCNTRL)
113   {
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);
121   }
122}
123
124
105125static READ8_HANDLER( coupe_rtc_r )
106126{
107127   return msm6242_r(machine, offset >> 12);
src/mess/drivers/coupe.c
r2347r2348
290290
291291
292292static ADDRESS_MAP_START( coupe_io, ADDRESS_SPACE_IO, 8 )
293   AM_RANGE(0x80, 0x81) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_WRITE(coupe_ext_mem_w)
293294   AM_RANGE(0xe0, 0xe7) AM_MIRROR(0xff10) AM_MASK(0xffff) AM_READWRITE(coupe_disk_r, coupe_disk_w)
294295   AM_RANGE(0xf8, 0xf8) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_pen_r, coupe_clut_w)
295296   AM_RANGE(0xf9, 0xf9) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_status_r, coupe_line_int_w)
r2347r2348
600601
601602
602603SYSTEM_CONFIG_START(coupe)
603   CONFIG_RAM_DEFAULT(256 * 1024)
604   CONFIG_RAM(512 * 1024)
605
604   CONFIG_RAM(256 * 1024)
605   CONFIG_RAM_DEFAULT(512 * 1024)
606   CONFIG_RAM(256 * 1024 + 1 * 1024 * 1024)
607   CONFIG_RAM(512 * 1024 + 1 * 1024 * 1024)
608   CONFIG_RAM(256 * 1024 + 2 * 1024 * 1024)
609   CONFIG_RAM(512 * 1024 + 2 * 1024 * 1024)
610   CONFIG_RAM(256 * 1024 + 3 * 1024 * 1024)
611   CONFIG_RAM(512 * 1024 + 3 * 1024 * 1024)
612   CONFIG_RAM(256 * 1024 + 4 * 1024 * 1024)
613   CONFIG_RAM(512 * 1024 + 4 * 1024 * 1024)
606614   CONFIG_DEVICE(coupe_floppy_getinfo)
607615SYSTEM_CONFIG_END
608616

Previous 15994 Revisions Next


© 1998-2018 The MESS Team