src/mess/machine/ti99/gromport.c
| r15583 | r15584 | |
| 1 | | /********************************************************************** |
| 1 | /*************************************************************************** |
| 2 | GROM port - the cartridge port of the TI-99/4, TI-99/4A, and |
| 3 | TI-99/8 console. |
| 2 | 4 | |
| 3 | | Gromport: the cartridge port of the TI-99/4, TI-99/4A, and |
| 4 | | TI-99/8 console. The name refers to the main intended application |
| 5 | | scenario, that is, to host cartridges with GROMs. (The other port |
| 6 | | of the console is called I/O port.) |
| 5 | The name refers to the main intended application scenario, that is, |
| 6 | to host cartridges with GROMs. The second, wider port of the console is |
| 7 | called I/O port and connects to the Peripheral Expansion System |
| 8 | (see peribox.h). |
| 7 | 9 | |
| 8 | | Over the years, many different kinds of cartridges appeared; the |
| 9 | | usual cartridge layout contains GROMs and possibly a ROM circuit |
| 10 | | for time-critical code (since the GROMs were utterly slow). |
| 10 | LEFT |
| 11 | 11 | |
| 12 | | Texas Instruments kept control over all software development by |
| 13 | | reserving GROMs and their programming to them and licensees. |
| 12 | RESET* 1||2 GND |
| 13 | D7 3||4 CRUCLK |
| 14 | D6 5||6 CRUIN |
| 15 | D5 7||8 A15/CRUOUT |
| 16 | D4 9||10 A13 |
| 17 | D3 11||12 A12 |
| 18 | D2 13||14 A11 |
| 19 | D1 15||16 A10 |
| 20 | D0 17||18 A9 |
| 21 | +5V 19||20 A8 |
| 22 | /GS 21||22 A7 |
| 23 | A14 23||24 A3 |
| 24 | DBIN 25||26 A6 |
| 25 | GRMCLK 27||28 A5 |
| 26 | -5V 29||30 A4 |
| 27 | READY 31||32 /WE |
| 28 | GND 33||34 /ROMG |
| 29 | GND 35||36 GND |
| 14 | 30 | |
| 15 | | Interestingly, the OS designers planned for an alternative - |
| 16 | | cartridges which can be run with EPROMs only - which provided |
| 17 | | a means for third-party authors to create cartridges without |
| 18 | | TI license. The last action of TI before their retreat from the |
| 19 | | home computer market was to disable this alternative. |
| 31 | RIGHT |
| 20 | 32 | |
| 21 | | Nevertheless, the majority of consoles runs with different kinds of |
| 22 | | cartridges; most recent developments by third party include |
| 23 | | multi-bank cartridges with storage space up to 128 KiB. |
| 33 | Address bus line ordering, according to TI convention, is A0 (MSB) ... A15 (LSB). |
| 34 | A0, A1, and A2 are not delivered to the port but decoded in the console: |
| 24 | 35 | |
| 25 | | The implementation as shown here goes beyond the simple port |
| 26 | | by realizing a "multi-cartridge extender". This is a somewhat |
| 27 | | mythical device which was never available for the normal |
| 28 | | customer, but there are reports of the existance of such a device |
| 29 | | in development labs or demonstrations. |
| 36 | /ROMG is asserted for A0/A1/A2 = 011 (addresses 6000 - 7fff) |
| 37 | /GS is asserted for A0...A5 = 100110 (addresses 9800 - 9bff) |
| 30 | 38 | |
| 31 | | The interesting thing about this is that the OS of the console |
| 32 | | fully supports this multi-cartridge extender, providing a selection |
| 33 | | option on the screen to switch between different plugged-in |
| 34 | | cartridges. |
| 39 | This means that a maximum of 8 KiB of direct memory space can be accessed. |
| 40 | The /GS line is used to enable GROM circuits on the board (serial ROMs with |
| 41 | own address counter, see grom.h). |
| 35 | 42 | |
| 36 | | The switching is possible by decoding address lines that are reserved |
| 37 | | for GROM access. GROMs are accessed via four separate addresses |
| 38 | | 9800, 9802, 9C00, 9C02. The addressing scheme looks like this: |
| 43 | When a cartridge is inserted the /RESET line is pulled to ground, which |
| 44 | via a R/C component pulls down the /RESET input of the timer circuit for |
| 45 | a short time, which in turn resets the CPU. In order to dump cartridges, |
| 46 | a common procedure was to tape the /RESET line of the cartridge. However, |
| 47 | inserting a cartridge without resetting often caused so much data bus noise |
| 48 | that the console usually locked up. |
| 39 | 49 | |
| 40 | | 1001 1Wxx xxxx xxM0 W = write(1), read(0), M = address(1), data(0) |
| 50 | ---------------- |
| 41 | 51 | |
| 42 | | This leaves 8 bits (256 options) which are not decoded inside the |
| 43 | | console. As the complete address is routed to the port, some circuit |
| 44 | | just needs to decode the xxx lines and turn on the respective slot. |
| 52 | The TI-99/4A computer was strictly designed for cartridge usage. The basic |
| 53 | console had only little directly accessible RAM and offered no ways to |
| 54 | write machine language programs; cartridges were intended to add various |
| 55 | capabilities, or just for running games. |
| 45 | 56 | |
| 46 | | One catch must be considered: Some cartridges contain ROMs which are |
| 47 | | directly accessed and not via ports. This means that the ROMs must |
| 48 | | be activated according to the slot that is selected. |
| 57 | Beside the seemingly simple handling, Texas Instruments had own intentions |
| 58 | behind their cartridge strategy. With only 8 KiB of direct access memory, a |
| 59 | major part of the cartridge code had to be stored in GROMs, which had to be |
| 60 | licensed from Texas Instruments. Thus they kept firm control over all |
| 61 | software development. |
| 49 | 62 | |
| 50 | | Another issue: Each GROM contains an own address counter and an ID. |
| 51 | | According to the ID the GROM only delivers data if the address counter |
| 52 | | is within the ID area (0 = 0000-1fff, 1=2000-3fff ... 7=e000-ffff). |
| 53 | | Thus it is essential that all GROMs stay in sync with their address |
| 54 | | counters. We have to route all address settings to all slots and their |
| 55 | | GROMs, even when the slot has not been selected before. The selected |
| 56 | | just shows its effect when data is read. In this case, only the |
| 57 | | data from the selected slot will be delivered. |
| 63 | Over the years, and with the increasingly difficult market situations, |
| 64 | TI's policies seem to have changed. This may be the reason that the built-in |
| 65 | operating system actually allowed for running ROM-only cartridges until TI |
| 66 | clipped out this part in the OS, banning cartridges without GROMs. Consoles |
| 67 | with this modification were produced in 1983, TI's last year in the home |
| 68 | computer business. |
| 58 | 69 | |
| 59 | | This may be considered as a design flaw within the complete cartridge system |
| 60 | | which eventually led to TI not manufacturing that device for the broad |
| 61 | | market. |
| 70 | Although only 8 KiB were available for direct addressing, clever techniques |
| 71 | were invented by third-party manufacturers. The first extension was utilized |
| 72 | by TI themselves in the Extended Basic cartridge which offers two banks |
| 73 | of ROM contents. Switching between the banks is achieved by writing a value |
| 74 | to the ROM space at 6000 or 6002. Later, cartridges with much more memory |
| 75 | space were created, up to the Super Space II cartridge with 128 KiB of |
| 76 | buffered SRAM. |
| 62 | 77 | |
| 63 | | -------- |
| 78 | ---------------- |
| 64 | 79 | |
| 65 | | This implementation also contains the GRAMKracker, a popular device |
| 66 | | with persistent RAM and a cartridge slot. With it, cartridge contents |
| 67 | | can be read, stored in its RAM, and modified. Moreover, the |
| 68 | | console GROMs can be loaded into the device and overrun the data |
| 69 | | delivered by the console GROMs. (Take care when changing something |
| 70 | | in this emulation - this overrun is emulated by the sequence in which |
| 71 | | the devices on the datamux are executed.) |
| 80 | From the console case layout the GROM port was intended for a single |
| 81 | cartridge only. Although never officially released, the operating system |
| 82 | of the TI console supported a multi-cartridge extender with software |
| 83 | switching. There were also extenders based on hardware switching (like |
| 84 | the Navarone Widget). |
| 72 | 85 | |
| 73 | | -------- |
| 86 | This emulation offers both variants as slot options: |
| 74 | 87 | |
| 75 | | The second part of this file contains the implementation of the |
| 76 | | cartridge image format (RPK). |
| 88 | -gromport single : default single cartridge connector |
| 89 | -gromport multi : software-switchable 4-slot cartridge extender |
| 90 | -gromport gkracker : GRAM Kracker |
| 77 | 91 | |
| 78 | | Michael Zapf, 2012 |
| 92 | The last option enables another popular device, the GRAM Kracker. This is |
| 93 | a device to be plugged into the cartridge slot with five manual switches |
| 94 | at the front and an own cartridge slot at its top. It contains buffered |
| 95 | SRAM, a built-in ROM, and a GROM simulator which simulates GROM behaviour |
| 96 | when accessing the buffered RAM. Its main use is to provide editable |
| 97 | storage for the read-only cartridge contents. Cartridges can be plugged |
| 98 | into its slot; their contents can be read and written to disk, modified as |
| 99 | needed, and loaded into the buffered RAM. Even the console GROMs can be |
| 100 | copied into the device; despite running in parallel, the GROM simulator |
| 101 | is able to override the console GROMs, thus allowing the user to install |
| 102 | a customized OS. |
| 79 | 103 | |
| 80 | | *********************************************************************/ |
| 104 | (Emulation detail: Take care when changing something in this emulation - |
| 105 | this overrun is emulated by the sequence in which the devices on the datamux |
| 106 | are executed.) |
| 81 | 107 | |
| 108 | Michael Zapf, July 2012 |
| 109 | |
| 110 | ***************************************************************************/ |
| 82 | 111 | #include "gromport.h" |
| 83 | | #include "ti99defs.h" |
| 84 | 112 | |
| 85 | 113 | #define VERBOSE 1 |
| 86 | 114 | #define LOG logerror |
| 87 | 115 | |
| 88 | 116 | #define GROM_AREA 0x9800 |
| 89 | 117 | #define GROM_MASK 0xf800 |
| 90 | | #define AUTO -1 |
| 91 | 118 | |
| 92 | | #define CARTGROM_TAG "grom_contents" |
| 93 | | #define CARTROM_TAG "rom_contents" |
| 94 | | #define CARTROM2_TAG "rom2_contents" |
| 95 | | |
| 96 | 119 | #define GROM3_TAG "grom3" |
| 97 | 120 | #define GROM4_TAG "grom4" |
| 98 | 121 | #define GROM5_TAG "grom5" |
| 99 | 122 | #define GROM6_TAG "grom6" |
| 100 | 123 | #define GROM7_TAG "grom7" |
| 101 | 124 | |
| 102 | | enum |
| 125 | #define CARTGROM_TAG "grom_contents" |
| 126 | #define CARTROM_TAG "rom_contents" |
| 127 | #define CARTROM2_TAG "rom2_contents" |
| 128 | #define GKRACKER_ROM_TAG "gkracker_rom" |
| 129 | #define GKRACKER_NVRAM_TAG "gkracker_nvram" |
| 130 | |
| 131 | gromport_device::gromport_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 132 | : bus8z_device(mconfig, GROMPORT, "Cartridge port", tag, owner, clock), |
| 133 | device_slot_interface(mconfig, *this), |
| 134 | m_connector(NULL) |
| 103 | 135 | { |
| 104 | | PCB_STANDARD=1, |
| 105 | | PCB_PAGED, |
| 106 | | PCB_MINIMEM, |
| 107 | | PCB_SUPER, |
| 108 | | PCB_MBX, |
| 109 | | PCB_PAGED379I, |
| 110 | | PCB_PAGEDCRU, |
| 111 | | PCB_GKRACKER |
| 112 | | }; |
| 136 | } |
| 113 | 137 | |
| 114 | | #define GKSWITCH1_TAG "GKSWITCH1" |
| 115 | | #define GKSWITCH2_TAG "GKSWITCH2" |
| 116 | | #define GKSWITCH3_TAG "GKSWITCH3" |
| 117 | | #define GKSWITCH4_TAG "GKSWITCH4" |
| 118 | | #define GKSWITCH5_TAG "GKSWITCH5" |
| 119 | | |
| 120 | | /******************************************* |
| 121 | | Cartridge PCB types |
| 122 | | *******************************************/ |
| 123 | | |
| 124 | | cartridge_pcb_device::cartridge_pcb_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) |
| 125 | | : bus8z_device(mconfig, type, name, tag, owner, clock) |
| 138 | /* Only called for addresses 6000-7fff and GROM addresses (see datamux config) */ |
| 139 | READ8Z_MEMBER(gromport_device::readz) |
| 126 | 140 | { |
| 127 | | if (VERBOSE>7) LOG("cartridge_pcb_device: common initialization\n"); |
| 128 | | for (int i=0; i < 5; i++) m_grom[i] = 0; |
| 129 | | m_rom_ptr = 0; |
| 130 | | m_rom2_ptr = 0; |
| 131 | | m_ram_ptr = 0; |
| 132 | | m_grom_size = 0; |
| 133 | | m_rom_size = 0; |
| 134 | | m_ram_size = 0; |
| 141 | if (m_connector != NULL) |
| 142 | m_connector->readz(space, offset, value); |
| 135 | 143 | } |
| 136 | 144 | |
| 137 | | void cartridge_pcb_device::device_start(void) |
| 145 | WRITE8_MEMBER(gromport_device::write) |
| 138 | 146 | { |
| 147 | if (m_connector != NULL) |
| 148 | m_connector->write(space, offset, data); |
| 139 | 149 | } |
| 140 | 150 | |
| 141 | | cartridge_pcb_standard_device::cartridge_pcb_standard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 142 | | : cartridge_pcb_device(mconfig, TICARTPCBSTD, "Standard cartridge PCB", tag, owner, clock) |
| 151 | void gromport_device::crureadz(offs_t offset, UINT8 *value) |
| 143 | 152 | { |
| 153 | if (m_connector != NULL) |
| 154 | m_connector->crureadz(offset, value); |
| 144 | 155 | } |
| 145 | 156 | |
| 146 | | cartridge_pcb_paged_device::cartridge_pcb_paged_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 147 | | : cartridge_pcb_device(mconfig, TICARTPCBPAG, "Paged cartridge PCB", tag, owner, clock) |
| 157 | void gromport_device::cruwrite(offs_t offset, UINT8 data) |
| 148 | 158 | { |
| 159 | if (m_connector != NULL) |
| 160 | m_connector->cruwrite(offset, data); |
| 149 | 161 | } |
| 150 | 162 | |
| 151 | | cartridge_pcb_minimem_device::cartridge_pcb_minimem_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 152 | | : cartridge_pcb_device(mconfig, TICARTPCBMIN, "MiniMemory cartridge PCB", tag, owner, clock) |
| 163 | WRITE_LINE_MEMBER(gromport_device::ready_line) |
| 153 | 164 | { |
| 165 | m_console_ready(state); |
| 154 | 166 | } |
| 155 | 167 | |
| 156 | | cartridge_pcb_superspace_device::cartridge_pcb_superspace_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 157 | | : cartridge_pcb_device(mconfig, TICARTPCBSUP, "SuperSpace II cartridge PCB", tag, owner, clock) |
| 168 | void gromport_device::device_start() |
| 158 | 169 | { |
| 159 | 170 | } |
| 160 | 171 | |
| 161 | | cartridge_pcb_mbx_device::cartridge_pcb_mbx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 162 | | : cartridge_pcb_device(mconfig, TICARTPCBMBX, "MBX cartridge PCB", tag, owner, clock) |
| 172 | void gromport_device::device_reset() |
| 163 | 173 | { |
| 174 | m_reset_on_insert = (ioport("CARTRESET")->read()==0x01); |
| 164 | 175 | } |
| 165 | 176 | |
| 166 | | cartridge_pcb_paged379i_device::cartridge_pcb_paged379i_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 167 | | : cartridge_pcb_device(mconfig, TICARTPCBPGI, "Paged379i cartridge PCB", tag, owner, clock) |
| 177 | /* |
| 178 | Shall we reset the console when a cartridge has been inserted? |
| 179 | This is triggered by the cartridge by pulling down /RESET via a capacitor. |
| 180 | Accordingly, when we put a tape over the /RESET contact we can avoid the |
| 181 | reset, which is useful when we want to swap the cartridges while a program |
| 182 | is runnning. |
| 183 | */ |
| 184 | void gromport_device::cartridge_inserted() |
| 168 | 185 | { |
| 169 | | m_rom_page = get_paged379i_bank(15); |
| 186 | if (m_reset_on_insert) |
| 187 | { |
| 188 | m_console_reset(ASSERT_LINE); |
| 189 | m_console_reset(CLEAR_LINE); |
| 190 | } |
| 170 | 191 | } |
| 171 | 192 | |
| 172 | | cartridge_pcb_pagedcru_device::cartridge_pcb_pagedcru_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 173 | | : cartridge_pcb_device(mconfig, TICARTPCBPGC, "PagedCRU cartridge PCB", tag, owner, clock) |
| 193 | |
| 194 | void gromport_device::device_config_complete() |
| 174 | 195 | { |
| 196 | const gromport_config *intf = reinterpret_cast<const gromport_config *>(static_config()); |
| 197 | m_console_ready.resolve(intf->ready, *this); |
| 198 | m_console_reset.resolve(intf->reset, *this); |
| 199 | m_connector = static_cast<ti99_cartridge_connector_device*>(first_subdevice()); |
| 175 | 200 | } |
| 176 | 201 | |
| 177 | | cartridge_pcb_gramkracker_device::cartridge_pcb_gramkracker_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 178 | | : cartridge_pcb_device(mconfig, TICARTPCBGRK, "GRAM Kracker cartridge PCB", tag, owner, clock) |
| 202 | SLOT_INTERFACE_START( gromport ) |
| 203 | SLOT_INTERFACE("single", GROMPORT_SINGLE) |
| 204 | SLOT_INTERFACE("multi", GROMPORT_MULTI) |
| 205 | SLOT_INTERFACE("gkracker", GROMPORT_GK) |
| 206 | SLOT_INTERFACE_END |
| 207 | |
| 208 | |
| 209 | INPUT_PORTS_START(gromport) |
| 210 | PORT_START( "CARTRESET" ) |
| 211 | PORT_CONFNAME( 0x01, 0x01, "RESET on cartridge insert" ) |
| 212 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 213 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 214 | INPUT_PORTS_END |
| 215 | |
| 216 | ioport_constructor gromport_device::device_input_ports() const |
| 179 | 217 | { |
| 180 | | m_grom_address = 0; // for the GROM emulation |
| 181 | | for (int i=1; i < 6; i++) m_gk_switch[i] = 0; |
| 218 | return INPUT_PORTS_NAME(gromport); |
| 182 | 219 | } |
| 183 | 220 | |
| 184 | | /***************************************************************************** |
| 185 | | Common methods. |
| 186 | | ******************************************************************************/ |
| 221 | const device_type GROMPORT = &device_creator<gromport_device>; |
| 187 | 222 | |
| 188 | | /* Read function for this cartridge, CRU. */ |
| 189 | | void cartridge_pcb_device::crureadz(offs_t offset, UINT8 *value) { }; |
| 223 | /*************************************************************************** |
| 224 | Different versions of cartridge connections |
| 190 | 225 | |
| 191 | | /* Write function for this cartridge, CRU. */ |
| 192 | | void cartridge_pcb_device::cruwrite(offs_t offset, UINT8 value) { }; |
| 226 | single: the standard console connector, one cartridge |
| 227 | multi: a multi-cart expander, up to 4 cartridges with software selection |
| 228 | gkracker: GRAMKracker, a device with NVRAM which allows the user to copy |
| 229 | the contents of the cartridge plugged into its slot into the NVRAM |
| 230 | and to modify it. |
| 193 | 231 | |
| 194 | | READ8Z_MEMBER( cartridge_pcb_device::gromreadz ) |
| 232 | ***************************************************************************/ |
| 233 | |
| 234 | const device_type GROMPORT_SINGLE = &device_creator<single_conn_device>; |
| 235 | const device_type GROMPORT_MULTI = &device_creator<multi_conn_device>; |
| 236 | const device_type GROMPORT_GK = &device_creator<gkracker_device>; |
| 237 | |
| 238 | ti99_cartridge_connector_device::ti99_cartridge_connector_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) |
| 239 | : bus8z_device(mconfig, type, name, tag, owner, clock) |
| 195 | 240 | { |
| 196 | | for (int i=0; i < 5; i++) |
| 197 | | { |
| 198 | | if (m_grom[i] != NULL) |
| 199 | | { |
| 200 | | m_grom[i]->readz(space, offset, value, mem_mask); |
| 201 | | } |
| 202 | | } |
| 203 | 241 | } |
| 204 | 242 | |
| 205 | | WRITE8_MEMBER( cartridge_pcb_device::gromwrite ) |
| 243 | void ti99_cartridge_connector_device::ready_line(int state) |
| 206 | 244 | { |
| 207 | | for (int i=0; i < 5; i++) |
| 208 | | { |
| 209 | | if (m_grom[i] != NULL) |
| 210 | | { |
| 211 | | m_grom[i]->write(space, offset, data, mem_mask); |
| 212 | | } |
| 213 | | } |
| 245 | m_gromport->ready_line(state); |
| 214 | 246 | } |
| 215 | 247 | |
| 216 | | /***************************************************************************** |
| 217 | | Cartridge type: Standard |
| 218 | | Most cartridges are built in this type. Every cartridge may contain |
| 219 | | GROM between 0 and 40 KiB, and ROM with 8 KiB length, no banking. |
| 220 | | ******************************************************************************/ |
| 248 | single_conn_device::single_conn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 249 | : ti99_cartridge_connector_device(mconfig, GROMPORT_SINGLE, "Standard cartridge connector", tag, owner, clock) |
| 250 | { |
| 251 | m_shortname = "single"; |
| 252 | } |
| 221 | 253 | |
| 222 | | /* Read function for the standard cartridge. */ |
| 223 | | READ8Z_MEMBER(cartridge_pcb_standard_device::readz) |
| 254 | READ8Z_MEMBER(single_conn_device::readz) |
| 224 | 255 | { |
| 225 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 226 | | gromreadz(space, offset, value, mem_mask); |
| 227 | | else |
| 228 | | { |
| 229 | | if (m_rom_ptr!=NULL) |
| 230 | | { |
| 231 | | // For TI-99/8 we should plan for 16K cartridges. However, none was ever produced. |
| 232 | | // Well, forget about that. |
| 233 | | *value = m_rom_ptr[offset & 0x1fff]; |
| 234 | | // LOG("read cartridge rom space %04x = %02x\n", offset, *value); |
| 235 | | } |
| 236 | | } |
| 256 | // Pass through |
| 257 | m_cartridge->readz(space, offset, value); |
| 237 | 258 | } |
| 238 | 259 | |
| 239 | | /* Write function for the standard cartridge. */ |
| 240 | | WRITE8_MEMBER(cartridge_pcb_standard_device::write) |
| 260 | WRITE8_MEMBER(single_conn_device::write) |
| 241 | 261 | { |
| 242 | | // LOG("write standard\n"); |
| 243 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 244 | | gromwrite(space, offset, data, mem_mask); |
| 245 | | else |
| 246 | | { |
| 247 | | if (VERBOSE>5) LOG("cartridge_pcb_device: Cannot write to ROM space at %04x\n", offset); |
| 248 | | } |
| 262 | // Pass through |
| 263 | m_cartridge->write(space, offset, data); |
| 249 | 264 | } |
| 250 | 265 | |
| 251 | | /***************************************************************************** |
| 252 | | Cartridge type: Paged (Extended Basic) |
| 253 | | This cartridge consists of GROM memory and 2 pages of standard ROM. |
| 254 | | The page is set by writing any value to a location in |
| 255 | | the address area, where an even word offset sets the page to 0 and an |
| 256 | | odd word offset sets the page to 1 (e.g. 6000 = bank 0, and |
| 257 | | 6002 = bank 1). |
| 258 | | ******************************************************************************/ |
| 266 | void single_conn_device::crureadz(offs_t offset, UINT8 *value) |
| 267 | { |
| 268 | // Pass through |
| 269 | m_cartridge->crureadz(offset, value); |
| 270 | } |
| 259 | 271 | |
| 260 | | /* Read function for the paged cartridge. */ |
| 261 | | READ8Z_MEMBER(cartridge_pcb_paged_device::readz) |
| 272 | void single_conn_device::cruwrite(offs_t offset, UINT8 data) |
| 262 | 273 | { |
| 263 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 264 | | gromreadz(space, offset, value, mem_mask); |
| 265 | | else |
| 266 | | { |
| 267 | | if (m_rom_page==0) |
| 268 | | { |
| 269 | | *value = m_rom_ptr[offset & 0x1fff]; |
| 270 | | } |
| 271 | | else |
| 272 | | { |
| 273 | | *value = m_rom2_ptr[offset & 0x1fff]; |
| 274 | | } |
| 275 | | } |
| 274 | // Pass through |
| 275 | m_cartridge->cruwrite(offset, data); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | | /* Write function for the paged cartridge. */ |
| 279 | | WRITE8_MEMBER(cartridge_pcb_paged_device::write) |
| 278 | void single_conn_device::device_reset() |
| 280 | 279 | { |
| 281 | | // LOG("write standard\n"); |
| 282 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 283 | | gromwrite(space, offset, data, mem_mask); |
| 280 | m_cartridge->set_slot(0); |
| 281 | } |
| 284 | 282 | |
| 285 | | else |
| 286 | | m_rom_page = (offset >> 1) & 1; |
| 283 | static MACHINE_CONFIG_FRAGMENT( single_slot ) |
| 284 | MCFG_DEVICE_ADD("cartridge", TI99CART, 0) |
| 285 | MACHINE_CONFIG_END |
| 286 | |
| 287 | machine_config_constructor single_conn_device::device_mconfig_additions() const |
| 288 | { |
| 289 | return MACHINE_CONFIG_NAME( single_slot ); |
| 287 | 290 | } |
| 288 | 291 | |
| 292 | void single_conn_device::device_config_complete() |
| 293 | { |
| 294 | m_cartridge = static_cast<ti99_cartridge_device*>(first_subdevice()); |
| 295 | m_gromport = static_cast<gromport_device*>(owner()); |
| 296 | } |
| 289 | 297 | |
| 290 | | /***************************************************************************** |
| 291 | | Cartridge type: Mini Memory |
| 292 | | GROM: 6 KiB (occupies G>6000 to G>7800) |
| 293 | | ROM: 4 KiB (romfile is actually 8 K long, second half with zeros, 0x6000-0x6fff) |
| 294 | | persistent RAM: 4 KiB (0x7000-0x7fff) |
| 295 | | ******************************************************************************/ |
| 298 | /********************************************************/ |
| 296 | 299 | |
| 297 | | /* Read function for the minimem cartridge. */ |
| 298 | | READ8Z_MEMBER(cartridge_pcb_minimem_device::readz) |
| 300 | /* |
| 301 | The multi-cartridge extender |
| 302 | |
| 303 | This is a somewhat mythical device which was never available for the normal |
| 304 | customer, but there are reports of the existance of such a device |
| 305 | in development labs or demonstrations. |
| 306 | |
| 307 | The interesting thing about this is that the OS of the console |
| 308 | fully supports this multi-cartridge extender, providing a selection |
| 309 | option on the screen to switch between different plugged-in |
| 310 | cartridges. |
| 311 | |
| 312 | The switching is possible by decoding address lines that are reserved |
| 313 | for GROM access. GROMs are accessed via four separate addresses |
| 314 | 9800, 9802, 9C00, 9C02. The addressing scheme looks like this: |
| 315 | |
| 316 | 1001 1Wxx xxxx xxM0 W = write(1), read(0), M = address(1), data(0) |
| 317 | |
| 318 | This leaves 8 bits (256 options) which are not decoded inside the |
| 319 | console. As the complete address is routed to the port, some circuit |
| 320 | just needs to decode the xxx lines and turn on the respective slot. |
| 321 | |
| 322 | One catch must be considered: Some cartridges contain ROMs which are |
| 323 | directly accessed and not via ports. This means that the ROMs must |
| 324 | be activated according to the slot that is selected. |
| 325 | |
| 326 | Another issue: Each GROM contains an own address counter and an ID. |
| 327 | According to the ID the GROM only delivers data if the address counter |
| 328 | is within the ID area (0 = 0000-1fff, 1=2000-3fff ... 7=e000-ffff). |
| 329 | Thus it is essential that all GROMs stay in sync with their address |
| 330 | counters. We have to route all address settings to all slots and their |
| 331 | GROMs, even when the slot has not been selected before. The selected |
| 332 | just shows its effect when data is read. In this case, only the |
| 333 | data from the selected slot will be delivered. |
| 334 | |
| 335 | This may be considered as a design flaw within the complete cartridge system |
| 336 | which eventually led to TI not manufacturing that device for the broad |
| 337 | market. |
| 338 | */ |
| 339 | |
| 340 | #define AUTO -1 |
| 341 | |
| 342 | multi_conn_device::multi_conn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 343 | : ti99_cartridge_connector_device(mconfig, GROMPORT_MULTI, "Multi-cartridge extender", tag, owner, clock) |
| 299 | 344 | { |
| 300 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 301 | | gromreadz(space, offset, value, mem_mask); |
| 345 | m_shortname = "multi"; |
| 346 | } |
| 302 | 347 | |
| 348 | /* |
| 349 | Activates a slot in the multi-cartridge extender. |
| 350 | Setting the slot is done by accessing the GROM ports using a |
| 351 | specific address: |
| 352 | |
| 353 | slot 0: 0x9800 (0x9802, 0x9c00, 0x9c02) : cartridge1 |
| 354 | slot 1: 0x9804 (0x9806, 0x9c04, 0x9c06) : cartridge2 |
| 355 | ... |
| 356 | slot 15: 0x983c (0x983e, 0x9c3c, 0x9c3e) : cartridge16 |
| 357 | |
| 358 | Scheme: |
| 359 | |
| 360 | 1001 1Wxx xxxx xxM0 (M=mode; M=0: data, M=1: address; W=write) |
| 361 | |
| 362 | The following addresses are theoretically available, but the |
| 363 | built-in OS does not use them; i.e. cartridges will not be |
| 364 | included in the selection list, and their features will not be |
| 365 | found by lookup, but they could be accessed directly by user |
| 366 | programs. |
| 367 | slot 16: 0x9840 (0x9842, 0x9c40, 0x9c42) |
| 368 | ... |
| 369 | slot 255: 0x9bfc (0x9bfe, 0x9ffc, 0x9ffe) |
| 370 | |
| 371 | Setting the GROM base should select one cartridge, but the ROMs in the |
| 372 | CPU space must also be switched. As there is no known special mechanism |
| 373 | we assume that by switching the GROM base, the ROM is automatically |
| 374 | switched. |
| 375 | |
| 376 | Caution: This means that cartridges which do not have at least one |
| 377 | GROM cannot be switched with this mechanism. |
| 378 | |
| 379 | We assume that the slot number is already calculated in the caller: |
| 380 | slotnumber>=0 && slotnumber<=255 |
| 381 | |
| 382 | NOTE: The OS will stop searching when it finds slots 1 and 2 empty. |
| 383 | Interestingly, cartridge subroutines are found nevertheless, even when |
| 384 | the cartridge is plugged into a higher slot. |
| 385 | */ |
| 386 | void multi_conn_device::set_slot(int slotnumber) |
| 387 | { |
| 388 | if (VERBOSE>7) |
| 389 | if (m_active_slot != slotnumber) LOG("multi_conn_device: Setting cartslot to %d\n", slotnumber); |
| 390 | |
| 391 | if (m_fixed_slot==AUTO) |
| 392 | m_active_slot = slotnumber; |
| 303 | 393 | else |
| 304 | | { |
| 305 | | if ((offset & 0x1000)==0x0000) |
| 306 | | { |
| 307 | | *value = m_rom_ptr[offset & 0x0fff]; |
| 308 | | } |
| 309 | | else |
| 310 | | { |
| 311 | | *value = m_ram_ptr[offset & 0x0fff]; |
| 312 | | } |
| 313 | | } |
| 394 | m_active_slot = m_fixed_slot; |
| 314 | 395 | } |
| 315 | 396 | |
| 316 | | /* Write function for the minimem cartridge. */ |
| 317 | | WRITE8_MEMBER(cartridge_pcb_minimem_device::write) |
| 397 | int multi_conn_device::get_active_slot(bool changebase, offs_t offset) |
| 318 | 398 | { |
| 319 | | // LOG("write standard\n"); |
| 320 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 321 | | gromwrite(space, offset, data, mem_mask); |
| 322 | | |
| 323 | | else |
| 399 | int slot; |
| 400 | if (changebase) |
| 324 | 401 | { |
| 325 | | if ((offset & 0x1000)==0x0000) |
| 402 | if ((offset & GROM_MASK) == GROM_AREA) |
| 326 | 403 | { |
| 327 | | if (VERBOSE>1) LOG("ti99: gromport: Write access to cartridge ROM at address %04x ignored", offset); |
| 404 | set_slot((offset>>2) & 0x00ff); |
| 328 | 405 | } |
| 329 | | else |
| 330 | | { |
| 331 | | m_ram_ptr[offset & 0x0fff] = data; |
| 332 | | } |
| 333 | 406 | } |
| 407 | slot = m_active_slot; |
| 408 | return slot; |
| 334 | 409 | } |
| 335 | 410 | |
| 336 | | /***************************************************************************** |
| 337 | | Cartridge type: SuperSpace II |
| 338 | | SuperSpace cartridge type. SuperSpace is intended as a user-definable |
| 339 | | blank cartridge containing buffered RAM |
| 340 | | It has an Editor/Assembler GROM which helps the user to load |
| 341 | | the user program into the cartridge. If the user program has a suitable |
| 342 | | header, the console recognizes the cartridge as runnable, and |
| 343 | | assigns a number in the selection screen. |
| 344 | | Switching the RAM banks in this cartridge is achieved by setting |
| 345 | | CRU bits (the system serial interface). |
| 411 | void multi_conn_device::insert(int index, ti99_cartridge_device* cart) |
| 412 | { |
| 413 | if (VERBOSE>3) LOG("multi_conn_device: insert slot %d\n", index); |
| 414 | m_cartridge[index] = cart; |
| 415 | m_gromport->cartridge_inserted(); |
| 416 | } |
| 346 | 417 | |
| 347 | | GROM: Editor/Assembler GROM |
| 348 | | ROM: none |
| 349 | | persistent RAM: 32 KiB (0x6000-0x7fff, 4 banks) |
| 350 | | Switching the bank is done via CRU write |
| 351 | | ******************************************************************************/ |
| 418 | void multi_conn_device::remove(int index) |
| 419 | { |
| 420 | if (VERBOSE>3) LOG("multi_conn_device: remove slot %d\n", index); |
| 421 | m_cartridge[index] = NULL; |
| 422 | } |
| 352 | 423 | |
| 353 | | /* Read function for the super cartridge. */ |
| 354 | | READ8Z_MEMBER(cartridge_pcb_superspace_device::readz) |
| 424 | READ8Z_MEMBER(multi_conn_device::readz) |
| 355 | 425 | { |
| 356 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 357 | | gromreadz(space, offset, value, mem_mask); |
| 358 | | else |
| 426 | int slot = get_active_slot(true, offset); |
| 427 | |
| 428 | // If we have a GROM access, we need to send the read request to all |
| 429 | // attached cartridges so the slot is irrelevant here. Each GROM |
| 430 | // contains an internal address counter, and we must make sure they all stay in sync. |
| 431 | if ((offset & GROM_MASK) == GROM_AREA) |
| 359 | 432 | { |
| 360 | | if (m_ram_ptr==NULL) |
| 433 | for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) |
| 361 | 434 | { |
| 362 | | *value = 0; |
| 435 | if (m_cartridge[i] != NULL) |
| 436 | { |
| 437 | UINT8 newval = *value; |
| 438 | m_cartridge[i]->readz(space, offset, &newval, mem_mask); |
| 439 | if (i==slot) |
| 440 | { |
| 441 | *value = newval; |
| 442 | } |
| 443 | } |
| 363 | 444 | } |
| 364 | | else |
| 445 | } |
| 446 | else |
| 447 | { |
| 448 | if (slot < NUMBER_OF_CARTRIDGE_SLOTS && m_cartridge[slot] != NULL) |
| 365 | 449 | { |
| 366 | | offs_t boffset = (m_ram_page << 13) | (offset & 0x1fff); |
| 367 | | *value = m_ram_ptr[boffset]; |
| 450 | m_cartridge[slot]->readz(space, offset, value, mem_mask); |
| 368 | 451 | } |
| 369 | 452 | } |
| 370 | 453 | } |
| 371 | 454 | |
| 372 | | /* Write function for the super cartridge. */ |
| 373 | | WRITE8_MEMBER(cartridge_pcb_superspace_device::write) |
| 455 | WRITE8_MEMBER(multi_conn_device::write) |
| 374 | 456 | { |
| 375 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 376 | | gromwrite(space, offset, data, mem_mask); |
| 377 | | else |
| 457 | int slot = get_active_slot(true, offset); |
| 458 | |
| 459 | // Same issue as above (read) |
| 460 | // We don't have GRAM cartridges, anyway, so it's just used for setting the address. |
| 461 | if ((offset & GROM_MASK) == GROM_AREA) |
| 378 | 462 | { |
| 379 | | if ((offset & 0x1000)==0x0000) |
| 463 | for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) |
| 380 | 464 | { |
| 381 | | if (VERBOSE>1) LOG("ti99: gromport: Write access to cartridge ROM at address %04x ignored", offset); |
| 465 | if (m_cartridge[i] != NULL) |
| 466 | { |
| 467 | m_cartridge[i]->write(space, offset, data, mem_mask); |
| 468 | } |
| 382 | 469 | } |
| 383 | | else |
| 470 | } |
| 471 | else |
| 472 | { |
| 473 | if (slot < NUMBER_OF_CARTRIDGE_SLOTS && m_cartridge[slot] != NULL) |
| 384 | 474 | { |
| 385 | | offs_t boffset = (m_ram_page << 13) | (offset & 0x1fff); |
| 386 | | m_ram_ptr[boffset] = data; |
| 475 | // LOG("try it on slot %d\n", slot); |
| 476 | m_cartridge[slot]->write(space, offset, data, mem_mask); |
| 387 | 477 | } |
| 388 | 478 | } |
| 389 | 479 | } |
| 390 | 480 | |
| 391 | | void cartridge_pcb_superspace_device::crureadz(offs_t offset, UINT8 *value) |
| 481 | void multi_conn_device::crureadz(offs_t offset, UINT8 *value) |
| 392 | 482 | { |
| 393 | | // offset is the bit number. The CRU base address is already divided by 2. |
| 483 | int slot = get_active_slot(false, offset); |
| 484 | /* Sanity check. Higher slots are always empty. */ |
| 485 | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 486 | return; |
| 394 | 487 | |
| 395 | | // ram_page contains the bank number. We have a maximum of |
| 396 | | // 4 banks; the Super Space II manual says: |
| 397 | | // |
| 398 | | // Banks are selected by writing a bit pattern to CRU address >0800: |
| 399 | | // |
| 400 | | // Bank # Value |
| 401 | | // 0 >02 = 0000 0010 |
| 402 | | // 1 >08 = 0000 1000 |
| 403 | | // 2 >20 = 0010 0000 |
| 404 | | // 3 >80 = 1000 0000 |
| 405 | | // |
| 406 | | // With the bank number (0, 1, 2, or 3) in R0: |
| 407 | | // |
| 408 | | // BNKSW LI R12,>0800 Set CRU address |
| 409 | | // LI R1,2 Load Shift Bit |
| 410 | | // SLA R0,1 Align Bank Number |
| 411 | | // JEQ BNKS1 Skip shift if Bank 0 |
| 412 | | // SLA R1,0 Align Shift Bit |
| 413 | | // BNKS1 LDCR R1,0 Switch Banks |
| 414 | | // SRL R0,1 Restore Bank Number (optional) |
| 415 | | // RT |
| 488 | if (m_cartridge[slot] != NULL) |
| 489 | { |
| 490 | m_cartridge[slot]->crureadz(offset, value); |
| 491 | } |
| 492 | } |
| 416 | 493 | |
| 417 | | // Our implementation in MESS always gets 8 bits in one go. Also, the address |
| 418 | | // is twice the bit number. That is, the offset value is always a multiple |
| 419 | | // of 0x10. |
| 494 | void multi_conn_device::cruwrite(offs_t offset, UINT8 data) |
| 495 | { |
| 496 | int slot = get_active_slot(true, offset); |
| 420 | 497 | |
| 421 | | if (VERBOSE>2) LOG("ti99: gromport: Superspace: CRU accessed at %04x\n", offset); |
| 422 | | if ((offset & 0xfff0) != 0x0800) |
| 423 | | *value = 0; |
| 498 | /* Sanity check. Higher slots are always empty. */ |
| 499 | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 500 | return; |
| 424 | 501 | |
| 425 | | // CRU addresses are only 1 bit wide. Bytes are transferred from LSB |
| 426 | | // to MSB. That is, 8 bit are eight consecutive addresses. */ |
| 427 | | *value = (m_ram_page == (offset-1)/2); |
| 502 | if (m_cartridge[slot] != NULL) |
| 503 | { |
| 504 | m_cartridge[slot]->cruwrite(offset, data); |
| 505 | } |
| 428 | 506 | } |
| 429 | 507 | |
| 430 | | void cartridge_pcb_superspace_device::cruwrite(offs_t offset, UINT8 data) |
| 508 | void multi_conn_device::device_start() |
| 431 | 509 | { |
| 432 | | // data is bit |
| 433 | | // offset is address |
| 434 | | if (VERBOSE>2) LOG("ti99: gromport: Superspace: CRU accessed at %04x\n", offset); |
| 435 | | |
| 436 | | if (offset < 16) |
| 510 | m_next_free_slot = 0; |
| 511 | m_active_slot = 0; |
| 512 | for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) |
| 437 | 513 | { |
| 438 | | if (data != 0) |
| 439 | | m_ram_page = (offset-2)/4; |
| 514 | m_cartridge[i] = NULL; |
| 440 | 515 | } |
| 516 | m_gromport = static_cast<gromport_device*>(owner()); |
| 441 | 517 | } |
| 442 | 518 | |
| 443 | | /***************************************************************************** |
| 444 | | Cartridge type: MBX |
| 445 | | GROM: up to 40 KiB |
| 446 | | ROM: up to 16 KiB (in up to 2 banks of 8KiB each) |
| 447 | | RAM: 1022 B (0x6c00-0x6ffd, overrides ROM in that area) |
| 448 | | ROM mapper: 6ffe |
| 519 | void multi_conn_device::device_reset(void) |
| 520 | { |
| 521 | m_active_slot = 0; |
| 522 | m_fixed_slot = ioport("CARTSLOT")->read() - 1; |
| 523 | } |
| 449 | 524 | |
| 450 | | Note that some MBX cartridges assume the presence of the MBX system |
| 451 | | (additional console) and will not run without it. The MBX hardware is |
| 452 | | not emulated yet. |
| 453 | | ******************************************************************************/ |
| 525 | static MACHINE_CONFIG_FRAGMENT( multi_slot ) |
| 526 | MCFG_DEVICE_ADD("cartridge1", TI99CART, 0) |
| 527 | MCFG_DEVICE_ADD("cartridge2", TI99CART, 0) |
| 528 | MCFG_DEVICE_ADD("cartridge3", TI99CART, 0) |
| 529 | MCFG_DEVICE_ADD("cartridge4", TI99CART, 0) |
| 530 | MACHINE_CONFIG_END |
| 454 | 531 | |
| 455 | | /* Read function for the mbx cartridge. */ |
| 456 | | READ8Z_MEMBER(cartridge_pcb_mbx_device::readz) |
| 532 | machine_config_constructor multi_conn_device::device_mconfig_additions() const |
| 457 | 533 | { |
| 458 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 459 | | gromreadz(space, offset, value, mem_mask); |
| 460 | | else |
| 461 | | { |
| 462 | | if ((offset & 0x1c00)==0x0c00) |
| 463 | | { |
| 464 | | // This is the RAM area which overrides any ROM. There is no |
| 465 | | // known banking behavior for the RAM, so we must assume that |
| 466 | | // there is only one bank. |
| 467 | | if (m_ram_ptr != NULL) |
| 468 | | *value = m_ram_ptr[offset & 0x03ff]; |
| 469 | | } |
| 470 | | else |
| 471 | | { |
| 472 | | if (m_rom_ptr!=NULL) |
| 473 | | *value = m_rom_ptr[(offset & 0x1fff) | (m_rom_page<<13)]; |
| 474 | | } |
| 475 | | } |
| 534 | return MACHINE_CONFIG_NAME( multi_slot ); |
| 476 | 535 | } |
| 477 | 536 | |
| 478 | | /* Write function for the mbx cartridge. */ |
| 479 | | WRITE8_MEMBER(cartridge_pcb_mbx_device::write) |
| 537 | INPUT_PORTS_START(multi_slot) |
| 538 | PORT_START( "CARTSLOT" ) |
| 539 | PORT_DIPNAME( 0x0f, 0x00, "Multi-cartridge slot" ) |
| 540 | PORT_DIPSETTING( 0x00, "Auto" ) |
| 541 | PORT_DIPSETTING( 0x01, "Slot 1" ) |
| 542 | PORT_DIPSETTING( 0x02, "Slot 2" ) |
| 543 | PORT_DIPSETTING( 0x03, "Slot 3" ) |
| 544 | PORT_DIPSETTING( 0x04, "Slot 4" ) |
| 545 | INPUT_PORTS_END |
| 546 | |
| 547 | ioport_constructor multi_conn_device::device_input_ports() const |
| 480 | 548 | { |
| 481 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 482 | | gromwrite(space, offset, data, mem_mask); |
| 483 | | else |
| 484 | | { |
| 485 | | if (offset == 0x6ffe) |
| 486 | | { |
| 487 | | m_rom_page = data & 1; |
| 488 | | return; |
| 489 | | } |
| 490 | | |
| 491 | | if ((offset & 0x1c00)==0x0c00) |
| 492 | | { |
| 493 | | if (m_ram_ptr == NULL) return; |
| 494 | | m_ram_ptr[offset & 0x03ff] = data; |
| 495 | | } |
| 496 | | } |
| 549 | return INPUT_PORTS_NAME(multi_slot); |
| 497 | 550 | } |
| 498 | 551 | |
| 499 | | /***************************************************************************** |
| 500 | | Cartridge type: paged379i |
| 501 | | This cartridge consists of one 16 KiB, 32 KiB, 64 KiB, or 128 KiB EEPROM |
| 502 | | which is organised in 2, 4, 8, or 16 pages of 8 KiB each. The complete |
| 503 | | memory contents must be stored in one dump file. |
| 504 | | The pages are selected by writing a value to some memory locations. Due to |
| 505 | | using the inverted outputs of the LS379 latch, setting the inputs of the |
| 506 | | latch to all 0 selects the highest bank, while setting to all 1 selects the |
| 507 | | lowest. There are some cartridges (16 KiB) which are using this scheme, and |
| 508 | | there are new hardware developments mainly relying on this scheme. |
| 552 | /************************************************************************** |
| 509 | 553 | |
| 510 | | Writing to selects page (16K/32K/64K/128K) |
| 511 | | >6000 1 / 3 / 7 / 15 |
| 512 | | >6002 0 / 2 / 6 / 14 |
| 513 | | >6004 1 / 1 / 5 / 13 |
| 514 | | >6006 0 / 0 / 4 / 12 |
| 515 | | >6008 1 / 3 / 3 / 11 |
| 516 | | >600A 0 / 2 / 2 / 10 |
| 517 | | >600C 1 / 1 / 1 / 9 |
| 518 | | >600E 0 / 0 / 0 / 8 |
| 519 | | >6010 1 / 3 / 7 / 7 |
| 520 | | >6012 0 / 2 / 6 / 6 |
| 521 | | >6014 1 / 1 / 5 / 5 |
| 522 | | >6016 0 / 0 / 4 / 4 |
| 523 | | >6018 1 / 3 / 3 / 3 |
| 524 | | >601A 0 / 2 / 2 / 2 |
| 525 | | >601C 1 / 1 / 1 / 1 |
| 526 | | >601E 0 / 0 / 0 / 0 |
| 554 | The GRAM Kracker was manufactured by Miller's Graphics and designed to |
| 555 | fit into the cartridge slot. |
| 527 | 556 | |
| 528 | | The paged379i cartrige does not have any GROMs. |
| 529 | | ******************************************************************************/ |
| 557 | It offers one own cartridge slot at the top side and a row of switches |
| 558 | at its front. It contains buffered SRAM circuits; the base version has |
| 559 | 56 KiB, and the extended version has 80 KiB. |
| 530 | 560 | |
| 531 | | /* |
| 532 | | Determines which bank to set, depending on the size of the ROM. This is |
| 533 | | some magic code that actually represents different PCB versions. |
| 534 | | */ |
| 535 | | int cartridge_pcb_paged379i_device::get_paged379i_bank(int rompage) |
| 536 | | { |
| 537 | | int mask = 0; |
| 538 | | if (m_rom_size > 16384) |
| 539 | | { |
| 540 | | if (m_rom_size > 32768) |
| 541 | | { |
| 542 | | if (m_rom_size > 65536) |
| 543 | | mask = 15; |
| 544 | | else |
| 545 | | mask = 7; |
| 546 | | } |
| 547 | | else |
| 548 | | mask = 3; |
| 549 | | } |
| 550 | | else |
| 551 | | mask = 1; |
| 561 | The operation of the GRAM Kracker is a bit complex and most likely |
| 562 | bound to fail when you have no manual. Accordingly, this emulation is |
| 563 | neither simpler nor more difficult to use. |
| 552 | 564 | |
| 553 | | return rompage & mask; |
| 554 | | } |
| 565 | Concept of operation: |
| 555 | 566 | |
| 567 | Loader: The GRAM Kracker contains a small loader utility |
| 568 | which allows you to dump cartridges and to load the contents into the |
| 569 | SRAM of the GK. This loader utility is active when the switch 5 is put |
| 570 | into "Loader on" state. The activated loader hides the TI BASIC |
| 571 | interpreter in the console. |
| 556 | 572 | |
| 557 | | /* Read function for the paged379i cartridge. */ |
| 558 | | READ8Z_MEMBER(cartridge_pcb_paged379i_device::readz) |
| 559 | | { |
| 560 | | if ((offset & 0xe000)==0x6000) |
| 561 | | *value = m_rom_ptr[(m_rom_page<<13) | (offset & 0x1fff)]; |
| 562 | | } |
| 573 | Cartridges: When a cartridge is plugged into the GK the contents may be |
| 574 | dumped and saved to disk by the loader. They cannot be directly copied |
| 575 | into the GK because the memory locations are hidden by the cartridge. |
| 563 | 576 | |
| 564 | | /* Write function for the paged379i cartridge. Only used to set the bank. */ |
| 565 | | WRITE8_MEMBER(cartridge_pcb_paged379i_device::write) |
| 566 | | { |
| 567 | | // Bits: 0110 0000 000b bbbx |
| 568 | | // x = don't care, bbbb = bank |
| 569 | | if ((offset & 0xffe0)==0x6000) |
| 570 | | { |
| 571 | | // Set bank |
| 572 | | m_rom_page = get_paged379i_bank(15 - ((offset>>1) & 15)); |
| 573 | | } |
| 574 | | } |
| 577 | Loading the cartridge into the SRAM: With the cartridge unplugged, dumps |
| 578 | can be loaded into the SRAM using the loader. This is one major use case |
| 579 | of the GK, that is, to load dumps from disk, and in particular modified |
| 580 | dumps. (There is no checksum, so contents may be freely changed.) |
| 575 | 581 | |
| 576 | | /***************************************************************************** |
| 577 | | Cartridge type: pagedcru |
| 578 | | This cartridge consists of one 16 KiB, 32 KiB, or 64 KiB EEPROM which is |
| 579 | | organised in 2, 4, or 8 pages of 8 KiB each. We assume there is only one |
| 580 | | dump file of the respective size. |
| 581 | | The pages are selected by writing a value to the CRU. This scheme is |
| 582 | | similar to the one used for the SuperSpace cartridge, with the exception |
| 583 | | that we are using ROM only, and we can have up to 8 pages. |
| 582 | Console dump: The GK is also able to dump the console GROMs and also to |
| 583 | load them into the SRAM (only in the extended version). Due to a |
| 584 | peculiarity of the TI console design it is possible to override the |
| 585 | console GROMs with the contents in the cartridge slot. |
| 584 | 586 | |
| 585 | | Bank Value written to CRU>0800 |
| 586 | | 0 >0002 = 0000 0000 0000 0010 |
| 587 | | 1 >0008 = 0000 0000 0000 1000 |
| 588 | | 2 >0020 = 0000 0000 0010 0000 |
| 589 | | 3 >0080 = 0000 0000 1000 0000 |
| 590 | | 4 >0200 = 0000 0010 0000 0000 |
| 591 | | 5 >0800 = 0000 1000 0000 0000 |
| 592 | | 6 >2000 = 0010 0000 0000 0000 |
| 593 | | 7 >8000 = 1000 0000 0000 0000 |
| 587 | A standard procedure for use with the GK: |
| 594 | 588 | |
| 595 | | No GROMs used in this type. |
| 596 | | ******************************************************************************/ |
| 589 | Save cartridge: |
| 597 | 590 | |
| 598 | | /* Read function for the pagedcru cartridge. */ |
| 599 | | READ8Z_MEMBER(cartridge_pcb_pagedcru_device::readz) |
| 600 | | { |
| 601 | | if ((offset & 0xe000)==0x6000) |
| 602 | | *value = m_rom_ptr[(m_rom_page<<13) | (offset & 0x1fff)]; |
| 603 | | } |
| 591 | - Put switches to [Normal | OpSys | TI BASIC | W/P | Loader On] |
| 592 | - Insert a disk image into disk drive 1 |
| 593 | - Plug in a cartridge |
| 594 | - Reset the console (done automatically here) |
| 595 | - Visit the option screen, press 1 for GRAM KRACKER |
| 596 | - In the GK loader, select 2 for Save Module |
| 597 | - Follow the on-screen instructions. Switches are set via the dip switch menu. |
| 598 | - Enter a target file name |
| 599 | - Saving is complete when the Save operation has been unmarked. |
| 604 | 600 | |
| 605 | | /* Write function for the pagedcru cartridge. No effect. */ |
| 606 | | WRITE8_MEMBER(cartridge_pcb_pagedcru_device::write) |
| 607 | | { |
| 608 | | return; |
| 609 | | } |
| 601 | Load cartridge: |
| 610 | 602 | |
| 611 | | void cartridge_pcb_pagedcru_device::crureadz(offs_t offset, UINT8 *value) |
| 612 | | { |
| 613 | | int page = m_rom_page; |
| 614 | | if ((offset & 0xf800)==0x0800) |
| 615 | | { |
| 616 | | int bit = (offset & 0x001e)>>1; |
| 617 | | if (bit != 0) |
| 618 | | { |
| 619 | | page = page-(bit/2); // 4 page flags per 8 bits |
| 620 | | } |
| 621 | | *value = 1 << (page*2+1); |
| 622 | | } |
| 623 | | } |
| 603 | - Put switches to [Normal | OpSys | TI BASIC | W/P | Loader On] |
| 604 | - Insert a disk image into disk drive 1 |
| 605 | - Make sure no cartridge is plugged in |
| 606 | - Press 1 for GRAM KRACKER |
| 607 | - Press 3 for Init Module space; follow instructions |
| 608 | - Press 1 for Load Module; specify file name on disk |
| 609 | - Loading is complete when the Load operation has been unmarked. |
| 624 | 610 | |
| 625 | | void cartridge_pcb_pagedcru_device::cruwrite(offs_t offset, UINT8 data) |
| 626 | | { |
| 627 | | if ((offset & 0xf800)==0x0800) |
| 628 | | { |
| 629 | | int bit = (offset & 0x001e)>>1; |
| 630 | | if (data != 0 && bit > 0) |
| 631 | | { |
| 632 | | m_rom_page = (bit-1)/2; |
| 633 | | } |
| 634 | | } |
| 635 | | } |
| 611 | Memory organisation: |
| 636 | 612 | |
| 637 | | /***************************************************************************** |
| 638 | | Cartridge type: GRAMKracker |
| 613 | The console has three GROMs with 6 KiB size and occupying 8 KiB of address |
| 614 | space each. These are called GROMs 0, 1, and 2. GROM 0 contains the common |
| 615 | routines for the computer operation; GROMs 1 and 2 contain TI BASIC. |
| 639 | 616 | |
| 640 | | The GK is a big cartridge that fits into the same slot as any other |
| 641 | | cartridge but which offers a set of switches, an own cartridge slot, |
| 642 | | and buffered RAM inside. Also, it has a built-in ROM called "LOADER". |
| 617 | Memory locations 6000-7fff are assigned to cartridge ROMs; in some |
| 618 | cartridges, a second ROM bank can be used by writing a value to a special |
| 619 | ROM access. This way, instead of 8 KiB we often have 16 KiB at these |
| 620 | locations. |
| 643 | 621 | |
| 644 | | Its primary use is to allow the user to copy cartridge contents into the |
| 645 | | buffered RAM and to modify it there. That way, ROM cartridges can be |
| 646 | | customized. |
| 622 | Each cartridge can host up to 5 GROMs (called GROM 3, 4, 5, 6, and 7). |
| 623 | As in the console, each one occupies 6 KiB in an 8 KiB window. |
| 647 | 624 | |
| 648 | | The 80 KiB of the GK are allocated as follows |
| 649 | | 00000 - 01fff: GRAM 0 |
| 650 | | 02000 - 03fff: GRAM 1 (alternatively, the loader GROM appears here) |
| 651 | | 04000 - 05fff: GRAM 2 |
| 652 | | 06000 - 0ffff: GRAM 3-7 (alternatively, the guest GROMs appear here) |
| 653 | | 10000 - 11fff: RAM 1 |
| 654 | | 12000 - 13fff: RAM 2 |
| 625 | The GRAM Kracker offers |
| 655 | 626 | |
| 656 | | The GK emulates GROMs, but without a readable address counter. Thus it |
| 657 | | relies on the console GROMs being still in place. |
| 658 | | Also, the GK does not implement a GROM buffer. |
| 627 | - a loader in an own GROM 1 (which hides the console GROM 1 when active, |
| 628 | so we have no BASIC anymore). The contents of the loader must be found |
| 629 | by the emulator in a file named ti99_gkracker.zip. |
| 659 | 630 | |
| 660 | | We need to implement a complete second path of handling as it differs |
| 661 | | from the multi-cart extender. Eventually, the multi-cart extender and |
| 662 | | the GK should be implemented as separate slot devices. |
| 631 | - a complete set of 8 (simulated) GRAMs with full 8 KiB each (done by a |
| 632 | simple addressing circuit); the basic version only offered GRAMs 3-7 |
| 663 | 633 | |
| 664 | | The GK cartridge type is in fact the internal LOADER ROM. In order to use |
| 665 | | the GK, the cartridge must be plugged into one slot, and the "guest" |
| 666 | | cartridge of the GK must be plugged into any other slot. Also, the DIP |
| 667 | | switch of the multi-cart extender must be set to "GRAM Kracker". |
| 668 | | *****************************************************************************/ |
| 634 | - 16 KiB of RAM memory space for the 6000-7fff area (called "bank 1" and "bank 2") |
| 669 | 635 | |
| 670 | | enum |
| 671 | | { |
| 672 | | CART_AUTO = 0, |
| 673 | | CART_1, |
| 674 | | CART_2, |
| 675 | | CART_3, |
| 676 | | CART_4, |
| 677 | | CART_GK = 15 |
| 678 | | }; |
| 636 | Notes: |
| 679 | 637 | |
| 638 | - it is mandatory to turn off the loader when loading into GRAM 1, but only |
| 639 | after prompted in the on-screen instructions, or the loader will crash |
| 640 | - GRAM0 must be properly loaded if switch 2 is set to GRAM0 and the computer is reset |
| 641 | - Switch 4 must not be in W/P position (write protect) when loading data |
| 642 | into the GK (either other position will do). |
| 643 | |
| 644 | |
| 645 | ***************************************************************************/ |
| 680 | 646 | enum |
| 681 | 647 | { |
| 682 | 648 | GK_OFF = 0, |
| r15583 | r15584 | |
| 692 | 658 | GK_LDOFF = 1 |
| 693 | 659 | }; |
| 694 | 660 | |
| 695 | | void cartridge_pcb_gramkracker_device::set_gk_guest(cartridge_device* guest) |
| 661 | #define GKSWITCH1_TAG "GKSWITCH1" |
| 662 | #define GKSWITCH2_TAG "GKSWITCH2" |
| 663 | #define GKSWITCH3_TAG "GKSWITCH3" |
| 664 | #define GKSWITCH4_TAG "GKSWITCH4" |
| 665 | #define GKSWITCH5_TAG "GKSWITCH5" |
| 666 | |
| 667 | gkracker_device::gkracker_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 668 | : ti99_cartridge_connector_device(mconfig, GROMPORT_GK, "GRAMKracker", tag, owner, clock), |
| 669 | device_nvram_interface(mconfig, *this) |
| 696 | 670 | { |
| 697 | | m_gk_guest = guest; |
| 671 | m_shortname = "ti99_gkracker"; |
| 698 | 672 | } |
| 699 | 673 | |
| 700 | | /* |
| 701 | | Read function for the GRAMKracker cartridge. |
| 702 | | */ |
| 703 | | READ8Z_MEMBER(cartridge_pcb_gramkracker_device::readz) |
| 674 | READ8Z_MEMBER(gkracker_device::readz) |
| 704 | 675 | { |
| 705 | 676 | if ((offset & GROM_MASK) == GROM_AREA) |
| 706 | 677 | { |
| 707 | 678 | // Reads from the GRAM space of the GRAM Kracker. |
| 708 | | // m_gk_slot is the slot where the GK module is plugged in |
| 709 | | // m_gk_guest_slot is the slot where the cartridge is plugged in |
| 710 | 679 | |
| 711 | 680 | // The GK does not have a readable address counter, but the console |
| 712 | 681 | // GROMs will keep our address counter up to date. That is |
| r15583 | r15584 | |
| 752 | 721 | // but only if it has GROMs |
| 753 | 722 | bool guest_has_grom = false; |
| 754 | 723 | |
| 755 | | if (m_gk_guest != NULL) |
| 724 | if (m_cartridge != NULL) |
| 756 | 725 | { |
| 757 | | guest_has_grom = (m_gk_guest->has_grom()); |
| 726 | guest_has_grom = m_cartridge->has_grom(); |
| 758 | 727 | // Note that we only have ONE real cartridge and the GK; |
| 759 | 728 | // we need not access all slots. |
| 760 | 729 | if (guest_has_grom) |
| 761 | 730 | { |
| 762 | | m_gk_guest->readz(space, offset, value, mem_mask); // read from guest |
| 731 | m_cartridge->readz(space, offset, value, mem_mask); // read from guest |
| 763 | 732 | } |
| 764 | 733 | } |
| 765 | 734 | if (!guest_has_grom && (m_gk_switch[1]==GK_NORMAL)) |
| r15583 | r15584 | |
| 774 | 743 | } |
| 775 | 744 | else |
| 776 | 745 | { |
| 777 | | if (m_gk_guest != NULL) |
| 746 | if (m_cartridge != NULL) |
| 778 | 747 | { |
| 779 | 748 | // Read from the guest cartridge. |
| 780 | | m_gk_guest->readz(space, offset, value, mem_mask); |
| 749 | m_cartridge->readz(space, offset, value, mem_mask); |
| 781 | 750 | } |
| 782 | 751 | else |
| 783 | 752 | { |
| r15583 | r15584 | |
| 788 | 757 | // RAM is stored behind the GRAM area |
| 789 | 758 | case GK_BANK1: |
| 790 | 759 | *value = m_ram_ptr[offset+0x10000 - 0x6000]; |
| 791 | | |
| 760 | break; |
| 792 | 761 | case GK_BANK2: |
| 793 | 762 | *value = m_ram_ptr[offset+0x12000 - 0x6000]; |
| 763 | break; |
| 794 | 764 | |
| 795 | 765 | default: |
| 796 | 766 | // Switch in middle position (WP, implies auto-select according to the page flag) |
| r15583 | r15584 | |
| 798 | 768 | *value = m_ram_ptr[offset+0x10000 - 0x6000]; |
| 799 | 769 | else |
| 800 | 770 | *value = m_ram_ptr[offset+0x12000 - 0x6000]; |
| 771 | break; |
| 801 | 772 | } |
| 802 | 773 | } |
| 803 | 774 | } |
| 775 | if (VERBOSE>8) LOG("gkracker_device: read %04x -> %02x\n", offset, *value); |
| 804 | 776 | } |
| 805 | 777 | |
| 806 | | /* |
| 807 | | See above. |
| 808 | | */ |
| 809 | | WRITE8_MEMBER(cartridge_pcb_gramkracker_device::write) |
| 778 | WRITE8_MEMBER(gkracker_device::write) |
| 810 | 779 | { |
| 811 | 780 | // write to the guest cartridge if present |
| 812 | | if (m_gk_guest != NULL) |
| 781 | if (m_cartridge != NULL) |
| 813 | 782 | { |
| 814 | | m_gk_guest->write(space, offset, data, mem_mask); |
| 783 | m_cartridge->write(space, offset, data, mem_mask); |
| 815 | 784 | } |
| 816 | 785 | |
| 817 | 786 | if ((offset & GROM_MASK) == GROM_AREA) |
| 818 | 787 | { |
| 819 | | // Writes to the GRAM space of the GRAM Kracker. |
| 788 | // Write to the GRAM space of the GRAM Kracker. |
| 820 | 789 | if ((offset & 0x0002)==0x0002) |
| 821 | 790 | { |
| 822 | 791 | // Set address |
| r15583 | r15584 | |
| 825 | 794 | // Accept low address byte (second write) |
| 826 | 795 | m_grom_address = (m_grom_address & 0xff00) | data; |
| 827 | 796 | m_waddr_LSB = false; |
| 797 | if (VERBOSE>8) LOG("gkracker_device: set grom address %04x\n", m_grom_address); |
| 828 | 798 | } |
| 829 | 799 | else |
| 830 | 800 | { |
| r15583 | r15584 | |
| 836 | 806 | else |
| 837 | 807 | { |
| 838 | 808 | // Write data byte to GRAM area. |
| 809 | if (VERBOSE>7) LOG("gkracker_device: gwrite %04x(%04x) <- %02x\n", offset, m_grom_address, data); |
| 839 | 810 | |
| 840 | 811 | // According to manual: |
| 841 | 812 | // Writing to GRAM 0: switch 2 set to GRAM 0 + Write protect switch (4) in 1 or 2 position |
| r15583 | r15584 | |
| 859 | 830 | m_ram_ptr[m_grom_address] = data; |
| 860 | 831 | break; |
| 861 | 832 | default: |
| 862 | | if (m_gk_switch[1]==GK_NORMAL && m_gk_guest != NULL) |
| 833 | if (m_gk_switch[1]==GK_NORMAL && m_cartridge == NULL) |
| 863 | 834 | m_ram_ptr[m_grom_address] = data; |
| 864 | 835 | break; |
| 865 | 836 | } |
| r15583 | r15584 | |
| 872 | 843 | } |
| 873 | 844 | else |
| 874 | 845 | { |
| 875 | | // Write to the RAM space of the GRAM Kracker. |
| 876 | | if (m_gk_guest == NULL) |
| 846 | // Write to the RAM space of the GRAM Kracker |
| 847 | // (only if no cartridge is present) |
| 848 | if (VERBOSE>7) LOG("gkracker_device: write %04x <- %02x\n", offset, data); |
| 849 | if (m_cartridge == NULL) |
| 877 | 850 | { |
| 878 | 851 | if (m_gk_switch[1] == GK_OFF) return; // just don't do anything |
| 879 | 852 | switch (m_gk_switch[4]) |
| r15583 | r15584 | |
| 897 | 870 | } |
| 898 | 871 | } |
| 899 | 872 | |
| 873 | void gkracker_device::crureadz(offs_t offset, UINT8 *value) |
| 874 | { |
| 875 | if (m_cartridge != NULL) m_cartridge->crureadz(offset, value); |
| 876 | } |
| 877 | |
| 878 | void gkracker_device::cruwrite(offs_t offset, UINT8 data) |
| 879 | { |
| 880 | if (m_cartridge != NULL) m_cartridge->cruwrite(offset, data); |
| 881 | } |
| 882 | |
| 883 | INPUT_CHANGED_MEMBER( gkracker_device::gk_changed ) |
| 884 | { |
| 885 | if (VERBOSE>7) LOG("gkracker_device: input changed %d - %d\n", (int)((UINT64)param & 0x07), newval); |
| 886 | m_gk_switch[(UINT64)param & 0x07] = newval; |
| 887 | } |
| 888 | |
| 889 | void gkracker_device::insert(int index, ti99_cartridge_device* cart) |
| 890 | { |
| 891 | if (VERBOSE>3) LOG("gkracker_device: insert cartridge\n"); |
| 892 | m_cartridge = cart; |
| 893 | // Switch 1 has a third location for resetting. We do the reset by default |
| 894 | // here. It can be turned off in the configuration. |
| 895 | m_gromport->cartridge_inserted(); |
| 896 | } |
| 897 | |
| 898 | void gkracker_device::remove(int index) |
| 899 | { |
| 900 | if (VERBOSE>3) LOG("gkracker_device: remove cartridge\n"); |
| 901 | m_cartridge = NULL; |
| 902 | } |
| 903 | |
| 904 | void gkracker_device::gk_install_menu(const char* menutext, int len, int ptr, int next, int start) |
| 905 | { |
| 906 | const int base = 0x0000; |
| 907 | m_ram_ptr[base + ptr] = (UINT8)((next >> 8) & 0xff); |
| 908 | m_ram_ptr[base + ptr+1] = (UINT8)(next & 0xff); |
| 909 | m_ram_ptr[base + ptr+2] = (UINT8)((start >> 8) & 0xff); |
| 910 | m_ram_ptr[base + ptr+3] = (UINT8)(start & 0xff); |
| 911 | |
| 912 | m_ram_ptr[base + ptr+4] = (UINT8)(len & 0xff); |
| 913 | memcpy(m_ram_ptr + base + ptr+5, menutext, len); |
| 914 | } |
| 915 | |
| 900 | 916 | /* |
| 901 | | Read cartridge mapper CRU interface (Guest in GRAM Kracker) |
| 917 | Define the default for the GRAM Kracker device. The memory is preset with |
| 918 | some sample entries which shall indicate that the memory has been tested |
| 919 | by the manufacturer. |
| 902 | 920 | */ |
| 903 | | void cartridge_pcb_gramkracker_device::crureadz(offs_t offset, UINT8 *value) |
| 921 | void gkracker_device::nvram_default() |
| 904 | 922 | { |
| 905 | | if (m_gk_guest != NULL) m_gk_guest->crureadz(offset, value); |
| 923 | if (VERBOSE>3) LOG("gkracker_device: Creating default NVRAM\n"); |
| 924 | memset(m_ram_ptr, 0, 81920); |
| 925 | |
| 926 | m_ram_ptr[0x6000] = 0xaa; |
| 927 | m_ram_ptr[0x6001] = 0x01; |
| 928 | m_ram_ptr[0x6002] = 0x01; |
| 929 | |
| 930 | m_ram_ptr[0x6006] = 0x60; |
| 931 | m_ram_ptr[0x6007] = 0x20; |
| 932 | |
| 933 | gk_install_menu("GROM 3 OK", 9, 0x60e0, 0, 0x6100); |
| 934 | gk_install_menu("GROM 4 OK", 9, 0x60c0, 0x60e0, 0x6100); |
| 935 | gk_install_menu("GROM 5 OK", 9, 0x60a0, 0x60c0, 0x6100); |
| 936 | gk_install_menu("GROM 6 OK", 9, 0x6080, 0x60a0, 0x6100); |
| 937 | gk_install_menu("PROM OK", 9, 0x6060, 0x6080, 0x6100); |
| 938 | gk_install_menu("RAMS OK", 9, 0x6040, 0x6060, 0x6100); |
| 939 | gk_install_menu("OPTION GRAMS OK", 15, 0x6020, 0x6040, 0x6100); |
| 940 | |
| 941 | m_ram_ptr[0x6100] = 0x0b; // GPL EXIT |
| 906 | 942 | } |
| 907 | 943 | |
| 944 | void gkracker_device::nvram_read(emu_file &file) |
| 945 | { |
| 946 | int readsize = file.read(m_ram_ptr, 81920); |
| 947 | if (VERBOSE>3) LOG("gkracker_device: reading NVRAM\n"); |
| 948 | // If we increased the size, fill the remaining parts with 0 |
| 949 | if (readsize < 81920) |
| 950 | { |
| 951 | memset(m_ram_ptr + readsize, 0, 81920-readsize); |
| 952 | } |
| 953 | } |
| 954 | |
| 955 | void gkracker_device::nvram_write(emu_file &file) |
| 956 | { |
| 957 | if (VERBOSE>3) LOG("gkracker_device: writing NVRAM\n"); |
| 958 | file.write(m_ram_ptr, 81920); |
| 959 | } |
| 960 | |
| 961 | void gkracker_device::device_start() |
| 962 | { |
| 963 | m_ram_ptr = memregion(GKRACKER_NVRAM_TAG)->base(); |
| 964 | m_grom_ptr = memregion(GKRACKER_ROM_TAG)->base(); |
| 965 | m_cartridge = NULL; |
| 966 | m_grom_address = 0; // for the GROM emulation |
| 967 | for (int i=1; i < 6; i++) m_gk_switch[i] = 0; |
| 968 | m_gromport = static_cast<gromport_device*>(owner()); |
| 969 | } |
| 970 | |
| 971 | void gkracker_device::device_reset() |
| 972 | { |
| 973 | m_gk_switch[1] = ioport(GKSWITCH1_TAG)->read(); |
| 974 | m_gk_switch[2] = ioport(GKSWITCH2_TAG)->read(); |
| 975 | m_gk_switch[3] = ioport(GKSWITCH3_TAG)->read(); |
| 976 | m_gk_switch[4] = ioport(GKSWITCH4_TAG)->read(); |
| 977 | m_gk_switch[5] = ioport(GKSWITCH5_TAG)->read(); |
| 978 | } |
| 979 | |
| 980 | static MACHINE_CONFIG_FRAGMENT( gkracker_slot ) |
| 981 | MCFG_DEVICE_ADD("cartridge", TI99CART, 0) |
| 982 | MACHINE_CONFIG_END |
| 983 | |
| 908 | 984 | /* |
| 909 | | Write cartridge mapper CRU interface (Guest in GRAM Kracker) |
| 985 | The GRAMKracker ROM |
| 910 | 986 | */ |
| 911 | | void cartridge_pcb_gramkracker_device::cruwrite(offs_t offset, UINT8 data) |
| 987 | ROM_START( gkracker_rom ) |
| 988 | ROM_REGION(0x14000, GKRACKER_NVRAM_TAG, ROMREGION_ERASE00) |
| 989 | ROM_REGION(0x2000, GKRACKER_ROM_TAG, 0) |
| 990 | ROM_LOAD("gkracker.bin", 0x0000, 0x2000, CRC(86eaaf9f) SHA1(a3bd5257c63e190800921b52dbe3ffa91ad91113)) |
| 991 | ROM_END |
| 992 | |
| 993 | const rom_entry *gkracker_device::device_rom_region() const |
| 912 | 994 | { |
| 913 | | if (m_gk_guest != NULL) m_gk_guest->cruwrite(offset, data); |
| 995 | return ROM_NAME( gkracker_rom ); |
| 914 | 996 | } |
| 915 | 997 | |
| 916 | | /***************************************************************************** |
| 917 | | A cartridge. In fact, just the empty cartridge, as the image to be loaded |
| 918 | | will be included as the PCB. |
| 919 | | *****************************************************************************/ |
| 998 | machine_config_constructor gkracker_device::device_mconfig_additions() const |
| 999 | { |
| 1000 | return MACHINE_CONFIG_NAME( gkracker_slot ); |
| 1001 | } |
| 920 | 1002 | |
| 1003 | INPUT_PORTS_START(gkracker) |
| 1004 | PORT_START( GKSWITCH1_TAG ) |
| 1005 | PORT_DIPNAME( 0x01, 0x01, "GK switch 1" ) PORT_CHANGED_MEMBER(DEVICE_SELF, gkracker_device, gk_changed, 1) |
| 1006 | PORT_DIPSETTING( 0x00, "GK Off" ) |
| 1007 | PORT_DIPSETTING( 0x01, DEF_STR( Normal ) ) |
| 1008 | |
| 1009 | PORT_START( GKSWITCH2_TAG ) |
| 1010 | PORT_DIPNAME( 0x01, 0x01, "GK switch 2" ) PORT_CHANGED_MEMBER(DEVICE_SELF, gkracker_device, gk_changed, 2) |
| 1011 | PORT_DIPSETTING( 0x00, "GRAM 0" ) |
| 1012 | PORT_DIPSETTING( 0x01, "Op Sys" ) |
| 1013 | |
| 1014 | PORT_START( GKSWITCH3_TAG ) |
| 1015 | PORT_DIPNAME( 0x01, 0x01, "GK switch 3" ) PORT_CHANGED_MEMBER(DEVICE_SELF, gkracker_device, gk_changed, 3) |
| 1016 | PORT_DIPSETTING( 0x00, "GRAM 1-2" ) |
| 1017 | PORT_DIPSETTING( 0x01, "TI BASIC" ) |
| 1018 | |
| 1019 | PORT_START( GKSWITCH4_TAG ) |
| 1020 | PORT_DIPNAME( 0x03, 0x01, "GK switch 4" ) PORT_CHANGED_MEMBER(DEVICE_SELF, gkracker_device, gk_changed, 4) |
| 1021 | PORT_DIPSETTING( 0x00, "Bank 1" ) |
| 1022 | PORT_DIPSETTING( 0x01, "W/P" ) |
| 1023 | PORT_DIPSETTING( 0x02, "Bank 2" ) |
| 1024 | |
| 1025 | PORT_START( GKSWITCH5_TAG ) |
| 1026 | PORT_DIPNAME( 0x01, 0x00, "GK switch 5" ) PORT_CHANGED_MEMBER(DEVICE_SELF, gkracker_device, gk_changed, 5) |
| 1027 | PORT_DIPSETTING( 0x00, "Loader On" ) |
| 1028 | PORT_DIPSETTING( 0x01, "Loader Off" ) |
| 1029 | INPUT_PORTS_END |
| 1030 | |
| 1031 | ioport_constructor gkracker_device::device_input_ports() const |
| 1032 | { |
| 1033 | return INPUT_PORTS_NAME(gkracker); |
| 1034 | } |
| 1035 | |
| 1036 | /*************************************************************************** |
| 1037 | Cartridge implementation |
| 1038 | |
| 1039 | Every cartridge is an instance of ti99_cartridge_device, implementing the |
| 1040 | device_image_interface. This means it is capable of loading cartridge |
| 1041 | data into its memory locations. All memory locations are organised as |
| 1042 | regions. |
| 1043 | |
| 1044 | The different cartridge versions are realised by different PCB instances. |
| 1045 | All PCBs are subclassed from ti99_cartridge_pcb. |
| 1046 | |
| 1047 | ***************************************************************************/ |
| 1048 | enum |
| 1049 | { |
| 1050 | PCB_STANDARD=1, |
| 1051 | PCB_PAGED, |
| 1052 | PCB_MINIMEM, |
| 1053 | PCB_SUPER, |
| 1054 | PCB_MBX, |
| 1055 | PCB_PAGED379I, |
| 1056 | PCB_PAGEDCRU |
| 1057 | }; |
| 1058 | |
| 921 | 1059 | static const pcb_type pcbdefs[] = |
| 922 | 1060 | { |
| 923 | 1061 | { PCB_STANDARD, "standard" }, |
| r15583 | r15584 | |
| 927 | 1065 | { PCB_MBX, "mbx" }, |
| 928 | 1066 | { PCB_PAGED379I, "paged379i" }, |
| 929 | 1067 | { PCB_PAGEDCRU, "pagedcru" }, |
| 930 | | { PCB_GKRACKER, "gramkracker" }, |
| 931 | 1068 | { 0, NULL} |
| 932 | 1069 | }; |
| 933 | 1070 | |
| r15583 | r15584 | |
| 939 | 1076 | { 0, NULL} |
| 940 | 1077 | }; |
| 941 | 1078 | |
| 942 | | cartridge_device::cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 943 | | : bus8z_device(mconfig, TICARTRIDGE, "TI-99 cartridge", tag, owner, clock), |
| 944 | | device_image_interface(mconfig, *this), |
| 945 | | m_pcb(NULL) |
| 1079 | ti99_cartridge_device::ti99_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 1080 | : bus8z_device(mconfig, TI99CART, "TI-99 cartridge", tag, owner, clock), |
| 1081 | device_image_interface(mconfig, *this), |
| 1082 | m_pcb(NULL) |
| 946 | 1083 | { |
| 947 | 1084 | m_shortname = "cartridge"; |
| 948 | 1085 | } |
| 949 | 1086 | |
| 950 | | void cartridge_device::device_start() |
| 1087 | void ti99_cartridge_device::prepare_cartridge() |
| 951 | 1088 | { |
| 952 | | if (VERBOSE>7) LOG("cartridge_device: device_start\n"); |
| 953 | | } |
| 954 | | |
| 955 | | void cartridge_device::device_stop() |
| 956 | | { |
| 957 | | if (VERBOSE>7) LOG("cartridge_device: device_stop\n"); |
| 958 | | } |
| 959 | | |
| 960 | | void cartridge_device::device_reset() |
| 961 | | { |
| 962 | | if (m_type==PCB_GKRACKER) |
| 963 | | { |
| 964 | | cartridge_pcb_gramkracker_device* pcb = static_cast<cartridge_pcb_gramkracker_device*>(m_pcb); |
| 965 | | pcb->m_gk_switch[1] = owner()->ioport(GKSWITCH1_TAG)->read(); |
| 966 | | pcb->m_gk_switch[2] = owner()->ioport(GKSWITCH2_TAG)->read(); |
| 967 | | pcb->m_gk_switch[3] = owner()->ioport(GKSWITCH3_TAG)->read(); |
| 968 | | pcb->m_gk_switch[4] = owner()->ioport(GKSWITCH4_TAG)->read(); |
| 969 | | pcb->m_gk_switch[5] = owner()->ioport(GKSWITCH5_TAG)->read(); |
| 970 | | } |
| 971 | | } |
| 972 | | |
| 973 | | void cartridge_device::device_config_complete() |
| 974 | | { |
| 975 | | if (VERBOSE>8) LOG("cartridge_device: device_config_complete\n"); |
| 976 | | update_names(); |
| 977 | | m_softlist = false; |
| 978 | | } |
| 979 | | |
| 980 | | void cartridge_device::prepare_cartridge() |
| 981 | | { |
| 982 | 1089 | int rom2_length; |
| 983 | 1090 | |
| 984 | 1091 | UINT8* grom_ptr; |
| r15583 | r15584 | |
| 996 | 1103 | grom_ptr = m_softlist? get_software_region("grom_socket") : (UINT8*)m_rpk->get_contents_of_socket("grom_socket"); |
| 997 | 1104 | memcpy(regg->base(), grom_ptr, m_pcb->m_grom_size); |
| 998 | 1105 | |
| 999 | | if (m_type==PCB_GKRACKER) |
| 1000 | | { |
| 1001 | | cartridge_pcb_gramkracker_device* pcb = static_cast<cartridge_pcb_gramkracker_device*>(m_pcb); |
| 1002 | | pcb->m_grom_ptr = grom_ptr; |
| 1003 | | } |
| 1004 | | |
| 1005 | 1106 | // Find the GROMs and keep their pointers |
| 1006 | | m_pcb->m_grom[0] = static_cast<ti99_grom_device*>(subdevice(GROM3_TAG)); |
| 1007 | | if (m_pcb->m_grom_size > 0x2000) m_pcb->m_grom[1] = static_cast<ti99_grom_device*>(subdevice(GROM4_TAG)); |
| 1008 | | if (m_pcb->m_grom_size > 0x4000) m_pcb->m_grom[2] = static_cast<ti99_grom_device*>(subdevice(GROM5_TAG)); |
| 1009 | | if (m_pcb->m_grom_size > 0x6000) m_pcb->m_grom[3] = static_cast<ti99_grom_device*>(subdevice(GROM6_TAG)); |
| 1010 | | if (m_pcb->m_grom_size > 0x8000) m_pcb->m_grom[4] = static_cast<ti99_grom_device*>(subdevice(GROM7_TAG)); |
| 1107 | m_pcb->set_grom_pointer(0, subdevice(GROM3_TAG)); |
| 1108 | if (m_pcb->m_grom_size > 0x2000) m_pcb->set_grom_pointer(1, subdevice(GROM4_TAG)); |
| 1109 | if (m_pcb->m_grom_size > 0x4000) m_pcb->set_grom_pointer(2, subdevice(GROM5_TAG)); |
| 1110 | if (m_pcb->m_grom_size > 0x6000) m_pcb->set_grom_pointer(3, subdevice(GROM6_TAG)); |
| 1111 | if (m_pcb->m_grom_size > 0x8000) m_pcb->set_grom_pointer(4, subdevice(GROM7_TAG)); |
| 1011 | 1112 | } |
| 1012 | 1113 | |
| 1013 | 1114 | m_pcb->m_rom_size = m_softlist? get_software_region_length("rom_socket") : m_rpk->get_resource_length("rom_socket"); |
| 1014 | 1115 | if (m_pcb->m_rom_size > 0) |
| 1015 | 1116 | { |
| 1117 | if (VERBOSE>6) LOG("gromport: rom_socket.size=0x%04x\n", m_pcb->m_rom_size); |
| 1016 | 1118 | regr = memregion("rom_contents"); |
| 1017 | 1119 | m_pcb->m_rom_ptr = m_softlist? get_software_region("rom_socket") : (UINT8*)m_rpk->get_contents_of_socket("rom_socket"); |
| 1018 | 1120 | memcpy(regr->base(), m_pcb->m_rom_ptr, m_pcb->m_rom_size); |
| r15583 | r15584 | |
| 1039 | 1141 | } |
| 1040 | 1142 | } |
| 1041 | 1143 | |
| 1042 | | bool cartridge_device::has_grom() |
| 1144 | /* |
| 1145 | Find the index of the cartridge name. We assume the format |
| 1146 | <name><number>, i.e. the number is the longest string from the right |
| 1147 | which can be interpreted as a number. Subtract 1. |
| 1148 | */ |
| 1149 | int ti99_cartridge_device::get_index_from_tagname() |
| 1043 | 1150 | { |
| 1044 | | assert (m_pcb != NULL); |
| 1045 | | return (m_pcb->m_grom_size>0); |
| 1046 | | } |
| 1151 | const char *mytag = tag(); |
| 1152 | int maxlen = strlen(mytag); |
| 1153 | int i; |
| 1047 | 1154 | |
| 1048 | | void cartridge_device::set_gk_guest(cartridge_device* guest) |
| 1049 | | { |
| 1050 | | assert (m_pcb != NULL); |
| 1051 | | assert (m_rpk->get_type()==PCB_GKRACKER); |
| 1155 | for (i=maxlen-1; i >=0; i--) |
| 1156 | if (mytag[i] < 48 || mytag[i] > 57) break; |
| 1052 | 1157 | |
| 1053 | | cartridge_pcb_gramkracker_device* pcb = static_cast<cartridge_pcb_gramkracker_device*>(m_pcb); |
| 1054 | | pcb->set_gk_guest(guest); |
| 1158 | if (i==maxlen-1) return 0; |
| 1159 | return atoi(mytag+i+1)-1; |
| 1055 | 1160 | } |
| 1056 | 1161 | |
| 1057 | | void cartridge_device::set_switch(int swtch, int val) |
| 1162 | bool ti99_cartridge_device::has_grom() |
| 1058 | 1163 | { |
| 1059 | | assert (m_pcb != NULL); |
| 1060 | | assert (m_rpk->get_type()==PCB_GKRACKER); |
| 1061 | | cartridge_pcb_gramkracker_device* pcb = static_cast<cartridge_pcb_gramkracker_device*>(m_pcb); |
| 1062 | | pcb->m_gk_switch[swtch] = val; |
| 1164 | return m_pcb->m_grom_size>0; |
| 1063 | 1165 | } |
| 1064 | 1166 | |
| 1065 | | bool cartridge_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) |
| 1167 | bool ti99_cartridge_device::call_load() |
| 1066 | 1168 | { |
| 1067 | | if (VERBOSE>8) LOG("gromport.cartridge_device: swlist = %s, swname = %s\n", swlist, swname); |
| 1068 | | load_software_part_region(this, swlist, swname, start_entry); |
| 1069 | | m_softlist = true; |
| 1070 | | m_rpk = NULL; |
| 1071 | | return true; |
| 1072 | | } |
| 1073 | | |
| 1074 | | bool cartridge_device::call_load() |
| 1075 | | { |
| 1076 | 1169 | // File name is in m_basename |
| 1077 | 1170 | // return true = error |
| 1078 | | if (VERBOSE>8) LOG("cartridge_device: loading\n"); |
| 1171 | if (VERBOSE>8) LOG("cartridge_device: loading %s in slot %s\n", m_basename.cstr(), tag()); |
| 1079 | 1172 | |
| 1080 | | astring ntag(tag(), ":PCB"); |
| 1081 | | const char* mytag = ntag.cstr(); |
| 1082 | | gromport_device *gp = static_cast<gromport_device*>(owner()); |
| 1083 | | int slot = get_index_from_tagname(); |
| 1084 | | |
| 1085 | 1173 | if (m_softlist) |
| 1086 | 1174 | { |
| 1087 | | LOG("using softlists\n"); |
| 1175 | if (VERBOSE>7) LOG("using softlists\n"); |
| 1088 | 1176 | int i = 0; |
| 1089 | 1177 | const char* pcb = get_feature("pcb"); |
| 1090 | 1178 | do |
| 1091 | 1179 | { |
| 1092 | 1180 | if (strcmp(pcb, sw_pcbdefs[i].name)==0) |
| 1093 | 1181 | { |
| 1094 | | m_type = sw_pcbdefs[i].id; |
| 1182 | m_pcbtype = sw_pcbdefs[i].id; |
| 1095 | 1183 | break; |
| 1096 | 1184 | } |
| 1097 | 1185 | i++; |
| 1098 | 1186 | } while (sw_pcbdefs[i].id != 0); |
| 1099 | | if (VERBOSE>5) LOG("gromport.cartridge_device: Cartridge type is %s (%d)\n", pcb, m_type); |
| 1187 | if (VERBOSE>5) LOG("gromport.cartridge_device: Cartridge type is %s (%d)\n", pcb, m_pcbtype); |
| 1100 | 1188 | } |
| 1101 | 1189 | else |
| 1102 | 1190 | { |
| r15583 | r15584 | |
| 1104 | 1192 | try |
| 1105 | 1193 | { |
| 1106 | 1194 | m_rpk = reader->open(machine().options(), filename(), machine().system().name); |
| 1107 | | m_type = m_rpk->get_type(); |
| 1195 | m_pcbtype = m_rpk->get_type(); |
| 1108 | 1196 | } |
| 1109 | 1197 | catch (rpk_exception& err) |
| 1110 | 1198 | { |
| r15583 | r15584 | |
| 1115 | 1203 | } |
| 1116 | 1204 | } |
| 1117 | 1205 | |
| 1118 | | switch (m_type) |
| 1206 | switch (m_pcbtype) |
| 1119 | 1207 | { |
| 1120 | 1208 | case PCB_STANDARD: |
| 1121 | 1209 | if (VERBOSE>6) LOG("gromport.cartridge_device: standard PCB\n"); |
| 1122 | | m_pcb = static_cast<cartridge_pcb_standard_device*>(&machine().add_dynamic_device(*this, TICARTPCBSTD, mytag, 0)); |
| 1210 | m_pcb = new ti99_standard_cartridge(); |
| 1123 | 1211 | break; |
| 1124 | 1212 | case PCB_PAGED: |
| 1125 | 1213 | if (VERBOSE>6) LOG("gromport.cartridge_device: paged PCB\n"); |
| 1126 | | m_pcb = static_cast<cartridge_pcb_paged_device*>(&machine().add_dynamic_device(*this, TICARTPCBPAG, mytag, 0)); |
| 1214 | m_pcb = new ti99_paged_cartridge(); |
| 1127 | 1215 | break; |
| 1128 | 1216 | case PCB_MINIMEM: |
| 1129 | 1217 | if (VERBOSE>6) LOG("gromport.cartridge_device: minimem PCB\n"); |
| 1130 | | m_pcb = static_cast<cartridge_pcb_minimem_device*>(&machine().add_dynamic_device(*this, TICARTPCBMIN, mytag, 0)); |
| 1218 | m_pcb = new ti99_minimem_cartridge(); |
| 1131 | 1219 | break; |
| 1132 | 1220 | case PCB_SUPER: |
| 1133 | 1221 | if (VERBOSE>6) LOG("gromport.cartridge_device: superspace PCB\n"); |
| 1134 | | m_pcb = static_cast<cartridge_pcb_superspace_device*>(&machine().add_dynamic_device(*this, TICARTPCBSUP, mytag, 0)); |
| 1222 | m_pcb = new ti99_super_cartridge(); |
| 1135 | 1223 | break; |
| 1136 | 1224 | case PCB_MBX: |
| 1137 | 1225 | if (VERBOSE>6) LOG("gromport.cartridge_device: MBX PCB\n"); |
| 1138 | | m_pcb = static_cast<cartridge_pcb_mbx_device*>(&machine().add_dynamic_device(*this, TICARTPCBMBX, mytag, 0)); |
| 1226 | m_pcb = new ti99_mbx_cartridge(); |
| 1139 | 1227 | break; |
| 1140 | 1228 | case PCB_PAGED379I: |
| 1141 | 1229 | if (VERBOSE>6) LOG("gromport.cartridge_device: Paged379i PCB\n"); |
| 1142 | | m_pcb = static_cast<cartridge_pcb_paged379i_device*>(&machine().add_dynamic_device(*this, TICARTPCBPGI, mytag, 0)); |
| 1230 | m_pcb = new ti99_paged379i_cartridge(); |
| 1143 | 1231 | break; |
| 1144 | 1232 | case PCB_PAGEDCRU: |
| 1145 | 1233 | if (VERBOSE>6) LOG("gromport.cartridge_device: PagedCRU PCB\n"); |
| 1146 | | m_pcb = static_cast<cartridge_pcb_pagedcru_device*>(&machine().add_dynamic_device(*this, TICARTPCBPGC, mytag, 0)); |
| 1234 | m_pcb = new ti99_pagedcru_cartridge(); |
| 1147 | 1235 | break; |
| 1148 | | case PCB_GKRACKER: |
| 1149 | | if (VERBOSE>6) LOG("gromport.cartridge_device: GRAMKracker PCB\n"); |
| 1150 | | m_pcb = static_cast<cartridge_pcb_gramkracker_device*>(&machine().add_dynamic_device(*this, TICARTPCBGRK, mytag, 0)); |
| 1151 | | gp->set_gk_slot(slot); |
| 1152 | | break; |
| 1153 | 1236 | } |
| 1154 | 1237 | |
| 1155 | 1238 | prepare_cartridge(); |
| 1156 | | m_pcb->set_machine(machine()); // TODO: Feels like a hack. |
| 1157 | | gp->change_slot(true, slot); |
| 1158 | | |
| 1159 | | machine().schedule_hard_reset(); // could be configurable by DIP switch, simulating taping the RESET line |
| 1160 | | |
| 1239 | m_slot = get_index_from_tagname(); |
| 1240 | m_connector->insert(m_slot, this); |
| 1161 | 1241 | return false; |
| 1162 | 1242 | } |
| 1163 | 1243 | |
| 1164 | | void cartridge_device::call_unload() |
| 1244 | void ti99_cartridge_device::call_unload() |
| 1165 | 1245 | { |
| 1166 | | if (VERBOSE>6) LOG("gromport.cartridge_device: unloading from %s\n", tag()); |
| 1167 | | |
| 1168 | | gromport_device *gp = static_cast<gromport_device*>(owner()); |
| 1169 | | int slot = get_index_from_tagname(); |
| 1170 | | if (slot == gp->m_gk_slot) |
| 1171 | | { |
| 1172 | | gp->m_gk_slot = -1; // Remove GRAMKracker slot index |
| 1173 | | // seems to be no way to change the dip switch except by keyboard |
| 1174 | | } |
| 1175 | | |
| 1246 | if (VERBOSE>7) LOG("ti99_cartridge_device: unload\n"); |
| 1176 | 1247 | if (m_rpk != NULL) |
| 1177 | 1248 | { |
| 1178 | | // Transfer RAM contents back into socket structure |
| 1179 | | /* if (m_pcb->m_ram_size > 0) |
| 1180 | | { |
| 1181 | | UINT8* ram_ptr; |
| 1182 | | ram_ptr = (UINT8*)m_rpk->get_contents_of_socket("ram_socket"); |
| 1183 | | memcpy(ram_ptr, m_pcb->m_ram_ptr, m_pcb->m_ram_size); |
| 1184 | | } */ |
| 1185 | 1249 | m_rpk->close(); // will write NVRAM contents |
| 1186 | 1250 | delete m_rpk; |
| 1187 | 1251 | } |
| 1188 | 1252 | |
| 1189 | | // TODO: How can we remove the dynamically added device? |
| 1253 | delete m_pcb; |
| 1190 | 1254 | m_pcb = NULL; |
| 1191 | | gp->change_slot(false, get_index_from_tagname()); |
| 1255 | m_connector->remove(m_slot); |
| 1192 | 1256 | } |
| 1193 | 1257 | |
| 1194 | | READ8Z_MEMBER(cartridge_device::readz) |
| 1258 | void ti99_cartridge_device::set_slot(int i) |
| 1195 | 1259 | { |
| 1196 | | assert(m_pcb != NULL); |
| 1197 | | m_pcb->readz(space, offset, value, mem_mask); |
| 1260 | m_slot = i; |
| 1198 | 1261 | } |
| 1199 | 1262 | |
| 1200 | | WRITE8_MEMBER(cartridge_device::write) |
| 1263 | bool ti99_cartridge_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) |
| 1201 | 1264 | { |
| 1202 | | assert(m_pcb != NULL); |
| 1203 | | m_pcb->write(space, offset, data, mem_mask); |
| 1265 | if (VERBOSE>8) LOG("ti99_cartridge_device: swlist = %s, swname = %s\n", swlist, swname); |
| 1266 | load_software_part_region(this, swlist, swname, start_entry); |
| 1267 | m_softlist = true; |
| 1268 | m_rpk = NULL; |
| 1269 | return true; |
| 1204 | 1270 | } |
| 1205 | 1271 | |
| 1206 | | void cartridge_device::crureadz(offs_t offset, UINT8 *value) |
| 1272 | READ8Z_MEMBER(ti99_cartridge_device::readz) |
| 1207 | 1273 | { |
| 1208 | | assert(m_pcb != NULL); |
| 1209 | | m_pcb->crureadz(offset, value); |
| 1274 | if (m_pcb != NULL) m_pcb->readz(space, offset, value); |
| 1210 | 1275 | } |
| 1211 | 1276 | |
| 1212 | | void cartridge_device::cruwrite(offs_t offset, UINT8 data) |
| 1277 | WRITE8_MEMBER(ti99_cartridge_device::write) |
| 1213 | 1278 | { |
| 1214 | | assert(m_pcb != NULL); |
| 1215 | | m_pcb->cruwrite(offset, data); |
| 1279 | if (m_pcb != NULL) m_pcb->write(space, offset, data); |
| 1216 | 1280 | } |
| 1217 | 1281 | |
| 1218 | | /* |
| 1219 | | Find the index of the cartridge name. We assume the format |
| 1220 | | <name><number>, i.e. the number is the longest string from the right |
| 1221 | | which can be interpreted as a number. Subtract 1. |
| 1222 | | */ |
| 1223 | | int cartridge_device::get_index_from_tagname() |
| 1282 | void ti99_cartridge_device::crureadz(offs_t offset, UINT8 *value) |
| 1224 | 1283 | { |
| 1225 | | const char *mytag = tag(); |
| 1226 | | int maxlen = strlen(mytag); |
| 1227 | | int i; |
| 1228 | | for (i=maxlen-1; i >=0; i--) |
| 1229 | | if (mytag[i] < 48 || mytag[i] > 57) break; |
| 1284 | if (m_pcb != NULL) m_pcb->crureadz(offset, value); |
| 1285 | } |
| 1230 | 1286 | |
| 1231 | | return atoi(mytag+i+1)-1; |
| 1287 | void ti99_cartridge_device::cruwrite(offs_t offset, UINT8 data) |
| 1288 | { |
| 1289 | if (m_pcb != NULL) m_pcb->cruwrite(offset, data); |
| 1232 | 1290 | } |
| 1233 | 1291 | |
| 1292 | void ti99_cartridge_device::ready_line(int state) |
| 1293 | { |
| 1294 | m_connector->ready_line(state); |
| 1295 | } |
| 1296 | |
| 1297 | void ti99_cartridge_device::device_config_complete() |
| 1298 | { |
| 1299 | update_names(); |
| 1300 | m_softlist = false; |
| 1301 | m_connector = static_cast<ti99_cartridge_connector_device*>(owner()); |
| 1302 | } |
| 1303 | |
| 1234 | 1304 | static GROM_CONFIG(grom3_config) |
| 1235 | 1305 | { |
| 1236 | | false, 3, CARTGROM_TAG, 0x0000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(":gromport", gromport_device, ready_line), GROMFREQ |
| 1306 | false, 3, CARTGROM_TAG, 0x0000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti99_cartridge_device, ready_line), GROMFREQ |
| 1237 | 1307 | }; |
| 1238 | 1308 | static GROM_CONFIG(grom4_config) |
| 1239 | 1309 | { |
| 1240 | | false, 4, CARTGROM_TAG, 0x2000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(":gromport", gromport_device, ready_line), GROMFREQ |
| 1310 | false, 4, CARTGROM_TAG, 0x2000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti99_cartridge_device, ready_line), GROMFREQ |
| 1241 | 1311 | }; |
| 1242 | 1312 | static GROM_CONFIG(grom5_config) |
| 1243 | 1313 | { |
| 1244 | | false, 5, CARTGROM_TAG, 0x4000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(":gromport", gromport_device, ready_line), GROMFREQ |
| 1314 | false, 5, CARTGROM_TAG, 0x4000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti99_cartridge_device, ready_line), GROMFREQ |
| 1245 | 1315 | }; |
| 1246 | 1316 | static GROM_CONFIG(grom6_config) |
| 1247 | 1317 | { |
| 1248 | | false, 6, CARTGROM_TAG, 0x6000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(":gromport", gromport_device, ready_line), GROMFREQ |
| 1318 | false, 6, CARTGROM_TAG, 0x6000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti99_cartridge_device, ready_line), GROMFREQ |
| 1249 | 1319 | }; |
| 1250 | 1320 | static GROM_CONFIG(grom7_config) |
| 1251 | 1321 | { |
| 1252 | | false, 7, CARTGROM_TAG, 0x8000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(":gromport", gromport_device, ready_line), GROMFREQ |
| 1322 | false, 7, CARTGROM_TAG, 0x8000, 0x1800, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti99_cartridge_device, ready_line), GROMFREQ |
| 1253 | 1323 | }; |
| 1254 | 1324 | |
| 1255 | 1325 | /* |
| 1256 | | The GROM devices on a cartridge. |
| 1326 | 5 GROMs that may be contained in a cartridge |
| 1257 | 1327 | */ |
| 1258 | | static MACHINE_CONFIG_FRAGMENT( cartridge_groms ) |
| 1328 | static MACHINE_CONFIG_FRAGMENT( ti99_cartridge ) |
| 1259 | 1329 | MCFG_GROM_ADD( GROM3_TAG, grom3_config ) |
| 1260 | 1330 | MCFG_GROM_ADD( GROM4_TAG, grom4_config ) |
| 1261 | 1331 | MCFG_GROM_ADD( GROM5_TAG, grom5_config ) |
| r15583 | r15584 | |
| 1263 | 1333 | MCFG_GROM_ADD( GROM7_TAG, grom7_config ) |
| 1264 | 1334 | MACHINE_CONFIG_END |
| 1265 | 1335 | |
| 1266 | | machine_config_constructor cartridge_device::device_mconfig_additions() const |
| 1336 | machine_config_constructor ti99_cartridge_device::device_mconfig_additions() const |
| 1267 | 1337 | { |
| 1268 | | return MACHINE_CONFIG_NAME( cartridge_groms ); |
| 1338 | return MACHINE_CONFIG_NAME( ti99_cartridge ); |
| 1269 | 1339 | } |
| 1270 | 1340 | |
| 1271 | 1341 | /* |
| 1272 | | Memory area for one cartridge. |
| 1342 | Memory area for one cartridge. For most cartridges we only need 8 KiB for |
| 1343 | ROM contents, but cartridges of the "paged379i" type have up to 128 KiB |
| 1344 | organised as selectable banks, so we must be sure there is enough space. |
| 1273 | 1345 | */ |
| 1274 | 1346 | ROM_START( cartridge_memory ) |
| 1275 | | ROM_REGION(0xa000, CARTGROM_TAG, 0) |
| 1276 | | ROM_FILL(0x0000, 0xa000, 0x00) |
| 1277 | | ROM_REGION(0x2000, CARTROM_TAG, 0) |
| 1278 | | ROM_FILL(0x0000, 0x2000, 0x00) |
| 1279 | | ROM_REGION(0x2000, CARTROM2_TAG, 0) |
| 1280 | | ROM_FILL(0x0000, 0x2000, 0x00) |
| 1347 | ROM_REGION(0xa000, CARTGROM_TAG, ROMREGION_ERASE00) |
| 1348 | ROM_REGION(0x20000, CARTROM_TAG, ROMREGION_ERASE00) |
| 1349 | ROM_REGION(0x2000, CARTROM2_TAG, ROMREGION_ERASE00) |
| 1281 | 1350 | ROM_END |
| 1282 | 1351 | |
| 1283 | | const rom_entry *cartridge_device::device_rom_region() const |
| 1352 | const rom_entry *ti99_cartridge_device::device_rom_region() const |
| 1284 | 1353 | { |
| 1285 | 1354 | return ROM_NAME( cartridge_memory ); |
| 1286 | 1355 | } |
| 1287 | 1356 | |
| 1288 | | void gromport_device::set_gk_slot(int slot) |
| 1357 | const device_type TI99CART = &device_creator<ti99_cartridge_device>; |
| 1358 | |
| 1359 | /*************************************************************************** |
| 1360 | Cartridge types |
| 1361 | Cartridges differ by the circuits on their PCB which hosts the ROMs. |
| 1362 | Some cartridges also have RAM, and some allow for switching between |
| 1363 | ROMs. |
| 1364 | |
| 1365 | Unlike in the previous implementation we do not model it as a full device. |
| 1366 | ***************************************************************************/ |
| 1367 | |
| 1368 | ti99_cartridge_pcb::ti99_cartridge_pcb() |
| 1289 | 1369 | { |
| 1290 | | if (VERBOSE>5) LOG("gromport_device: Setting slot %d as GK slot.\n", slot); |
| 1291 | | m_gk_slot = slot; |
| 1292 | 1370 | } |
| 1293 | 1371 | |
| 1294 | | void gromport_device::find_gk_guest() |
| 1372 | READ8Z_MEMBER(ti99_cartridge_pcb::gromreadz) |
| 1295 | 1373 | { |
| 1296 | | // The first slot which contains a cartridge (not the GK) is the guest of the GK |
| 1297 | | for (int i=0; i < m_numcart; i++) |
| 1374 | for (int i=0; i < 5; i++) |
| 1298 | 1375 | { |
| 1299 | | if (i==m_gk_slot) continue; |
| 1300 | | if (m_cartridge[i]->is_available()) |
| 1376 | if (m_grom[i] != NULL) |
| 1301 | 1377 | { |
| 1302 | | m_cartridge[m_gk_slot]->set_gk_guest(m_cartridge[i]); |
| 1303 | | if (VERBOSE>5) LOG("gromport_device: Setting slot %d as guest slot.\n", i); |
| 1304 | | return; |
| 1378 | m_grom[i]->readz(space, offset, value, mem_mask); |
| 1305 | 1379 | } |
| 1306 | 1380 | } |
| 1307 | | m_cartridge[m_gk_slot]->set_gk_guest(NULL); |
| 1308 | 1381 | } |
| 1309 | 1382 | |
| 1310 | | /***************************************************************************** |
| 1311 | | The complete multi-port cartridge system. Hosts up to four cartridges |
| 1312 | | at this time. |
| 1313 | | *****************************************************************************/ |
| 1314 | | |
| 1315 | | gromport_device::gromport_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 1316 | | : bus8z_device(mconfig, GROMPORT, "TI-99 multi-cartridge extender", tag, owner, clock) |
| 1383 | WRITE8_MEMBER(ti99_cartridge_pcb::gromwrite) |
| 1317 | 1384 | { |
| 1318 | | m_gk_slot = -1; |
| 1385 | for (int i=0; i < 5; i++) |
| 1386 | { |
| 1387 | if (m_grom[i] != NULL) |
| 1388 | { |
| 1389 | m_grom[i]->write(space, offset, data, mem_mask); |
| 1390 | } |
| 1391 | } |
| 1319 | 1392 | } |
| 1320 | 1393 | |
| 1321 | | /* |
| 1322 | | Activates a slot in the multi-cartridge extender. |
| 1323 | | Setting the slot is done by accessing the GROM ports using a |
| 1324 | | specific address: |
| 1325 | | |
| 1326 | | slot 0: 0x9800 (0x9802, 0x9c00, 0x9c02) : cartridge1 |
| 1327 | | slot 1: 0x9804 (0x9806, 0x9c04, 0x9c06) : cartridge2 |
| 1328 | | ... |
| 1329 | | slot 15: 0x983c (0x983e, 0x9c3c, 0x9c3e) : cartridge16 |
| 1330 | | |
| 1331 | | Scheme: |
| 1332 | | |
| 1333 | | 1001 1Wxx xxxx xxM0 (M=mode; M=0: data, M=1: address; W=write) |
| 1334 | | |
| 1335 | | The following addresses are theoretically available, but the |
| 1336 | | built-in OS does not use them; i.e. cartridges will not be |
| 1337 | | included in the selection list, and their features will not be |
| 1338 | | found by lookup, but they could be accessed directly by user |
| 1339 | | programs. |
| 1340 | | slot 16: 0x9840 (0x9842, 0x9c40, 0x9c42) |
| 1341 | | ... |
| 1342 | | slot 255: 0x9bfc (0x9bfe, 0x9ffc, 0x9ffe) |
| 1343 | | |
| 1344 | | Setting the GROM base should select one cartridge, but the ROMs in the |
| 1345 | | CPU space must also be switched. As there is no known special mechanism |
| 1346 | | we assume that by switching the GROM base, the ROM is automatically |
| 1347 | | switched. |
| 1348 | | |
| 1349 | | Caution: This means that cartridges which do not have at least one |
| 1350 | | GROM cannot be switched with this mechanism. |
| 1351 | | |
| 1352 | | We assume that the slot number is already calculated in the caller: |
| 1353 | | slotnumber>=0 && slotnumber<=255 |
| 1354 | | |
| 1355 | | NOTE: The OS will stop searching when it finds slots 1 and 2 empty. |
| 1356 | | Interestingly, cartridge subroutines are found nevertheless, even when |
| 1357 | | the cartridge is plugged into a higher slot. |
| 1358 | | */ |
| 1359 | | void gromport_device::set_slot(int slotnumber) |
| 1394 | READ8Z_MEMBER(ti99_cartridge_pcb::readz) |
| 1360 | 1395 | { |
| 1361 | | if (VERBOSE>7) |
| 1362 | | if (m_active_slot != slotnumber) LOG("ti99: gromport: Setting cartslot to %d\n", slotnumber); |
| 1363 | | |
| 1364 | | if (m_fixed_slot==AUTO) |
| 1365 | | m_active_slot = slotnumber; |
| 1396 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1397 | gromreadz(space, offset, value, mem_mask); |
| 1366 | 1398 | else |
| 1367 | | m_active_slot = m_fixed_slot; |
| 1399 | { |
| 1400 | if (m_rom_ptr!=NULL) |
| 1401 | { |
| 1402 | // For TI-99/8 we should plan for 16K cartridges. However, none was ever produced. |
| 1403 | // Well, forget about that. |
| 1404 | *value = m_rom_ptr[offset & 0x1fff]; |
| 1405 | // LOG("read cartridge rom space %04x = %02x\n", offset, *value); |
| 1406 | } |
| 1407 | } |
| 1368 | 1408 | } |
| 1369 | 1409 | |
| 1370 | | int gromport_device::get_active_slot(bool changebase, offs_t offset) |
| 1410 | WRITE8_MEMBER(ti99_cartridge_pcb::write) |
| 1371 | 1411 | { |
| 1372 | | int slot; |
| 1373 | | if (changebase) |
| 1412 | // LOG("write standard\n"); |
| 1413 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1414 | gromwrite(space, offset, data, mem_mask); |
| 1415 | else |
| 1374 | 1416 | { |
| 1375 | | if ((offset & GROM_MASK) == GROM_AREA) |
| 1376 | | { |
| 1377 | | set_slot((offset>>2) & 0x00ff); |
| 1378 | | } |
| 1417 | if (VERBOSE>5) LOG("cartridge_pcb_device: Cannot write to ROM space at %04x\n", offset); |
| 1379 | 1418 | } |
| 1380 | | slot = m_active_slot; |
| 1419 | } |
| 1381 | 1420 | |
| 1382 | | // Here we have a design flaw in the operating system of the TI. |
| 1383 | | // The system iterates through all banks to check for multiple cartridges. |
| 1384 | | // If we do not have a multi-cart system, each bank shows the same contents |
| 1385 | | // since there is no decoding of the bank information. |
| 1386 | | // This brings us into trouble here: If only slot 1 is occupied, slot 2 |
| 1387 | | // would deliver zeros only. This differs from slot 1, so we get a |
| 1388 | | // meaningless selection option. |
| 1389 | | // |
| 1390 | | // If we have only one cartridge in slot 1, we pretend that we have a |
| 1391 | | // single-slot system. The slot variable is forced to the first slot. |
| 1421 | void ti99_cartridge_pcb::crureadz(offs_t offset, UINT8 *value) |
| 1422 | { |
| 1423 | } |
| 1392 | 1424 | |
| 1393 | | if (m_fixed_slot==AUTO && m_next_free_slot==1) |
| 1394 | | slot=0; |
| 1425 | void ti99_cartridge_pcb::cruwrite(offs_t offset, UINT8 data) |
| 1426 | { |
| 1427 | } |
| 1395 | 1428 | |
| 1396 | | return slot; |
| 1429 | inline void ti99_cartridge_pcb::set_grom_pointer(int number, device_t *dev) |
| 1430 | { |
| 1431 | m_grom[number] = static_cast<ti99_grom_device*>(dev); |
| 1397 | 1432 | } |
| 1398 | 1433 | |
| 1399 | | void gromport_device::change_slot(bool inserted, int index) |
| 1434 | /***************************************************************************** |
| 1435 | Cartridge type: Paged (Extended Basic) |
| 1436 | This cartridge consists of GROM memory and 2 pages of standard ROM. |
| 1437 | The page is set by writing any value to a location in |
| 1438 | the address area, where an even word offset sets the page to 0 and an |
| 1439 | odd word offset sets the page to 1 (e.g. 6000 = bank 0, and |
| 1440 | 6002 = bank 1). |
| 1441 | ******************************************************************************/ |
| 1442 | |
| 1443 | READ8Z_MEMBER(ti99_paged_cartridge::readz) |
| 1400 | 1444 | { |
| 1401 | | if (inserted) |
| 1402 | | { |
| 1403 | | if (VERBOSE>6) LOG("gromport_device: Inserted into slot %d\n", index); |
| 1404 | | if (m_next_free_slot <= index) |
| 1405 | | m_next_free_slot = index+1; |
| 1406 | | } |
| 1445 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1446 | gromreadz(space, offset, value, mem_mask); |
| 1407 | 1447 | else |
| 1408 | 1448 | { |
| 1409 | | if (VERBOSE>6) LOG("gromport_device: Removed from slot %d\n", index); |
| 1410 | | for (int i=NUMBER_OF_CARTRIDGE_SLOTS-1; i>=0; i--) |
| 1449 | if (m_rom_page==0) |
| 1411 | 1450 | { |
| 1412 | | if (m_cartridge[i]->is_available()) |
| 1413 | | { |
| 1414 | | m_next_free_slot = index+1; |
| 1415 | | break; |
| 1416 | | } |
| 1451 | *value = m_rom_ptr[offset & 0x1fff]; |
| 1417 | 1452 | } |
| 1453 | else |
| 1454 | { |
| 1455 | *value = m_rom2_ptr[offset & 0x1fff]; |
| 1456 | } |
| 1418 | 1457 | } |
| 1419 | | if (VERBOSE>6) LOG("Next free slot: %d\n", m_next_free_slot); |
| 1458 | } |
| 1420 | 1459 | |
| 1421 | | if (m_gk_slot != -1) find_gk_guest(); |
| 1460 | WRITE8_MEMBER(ti99_paged_cartridge::write) |
| 1461 | { |
| 1462 | // LOG("write standard\n"); |
| 1463 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1464 | gromwrite(space, offset, data, mem_mask); |
| 1465 | |
| 1466 | else |
| 1467 | m_rom_page = (offset >> 1) & 1; |
| 1422 | 1468 | } |
| 1423 | 1469 | |
| 1424 | | /**************************************************** |
| 1425 | | Memory space (ROM, GROM) |
| 1426 | | ****************************************************/ |
| 1427 | | READ8Z_MEMBER(gromport_device::readz) |
| 1470 | /***************************************************************************** |
| 1471 | Cartridge type: Mini Memory |
| 1472 | GROM: 6 KiB (occupies G>6000 to G>7800) |
| 1473 | ROM: 4 KiB (romfile is actually 8 K long, second half with zeros, 0x6000-0x6fff) |
| 1474 | persistent RAM: 4 KiB (0x7000-0x7fff) |
| 1475 | ******************************************************************************/ |
| 1476 | |
| 1477 | /* Read function for the minimem cartridge. */ |
| 1478 | READ8Z_MEMBER(ti99_minimem_cartridge::readz) |
| 1428 | 1479 | { |
| 1429 | | // GRAMKracker support |
| 1430 | | // We *could* check the DIP switch, but this would only introduce another |
| 1431 | | // source of confusion when the GRAMKracker is plugged in, but the switch |
| 1432 | | // is not set. |
| 1433 | | // The check for the presence of the GK using the index is safer. |
| 1434 | | if ((m_gk_slot != -1) /*&& (ioport("CARTSLOT")==CART_GK) */) |
| 1435 | | { |
| 1436 | | m_cartridge[m_gk_slot]->readz(space, offset, value, mem_mask); |
| 1437 | | return; |
| 1438 | | } |
| 1480 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1481 | gromreadz(space, offset, value, mem_mask); |
| 1439 | 1482 | |
| 1440 | | int slot = get_active_slot(true, offset); |
| 1441 | | |
| 1442 | | // If we have a GROM access, we need to send the read request to all |
| 1443 | | // attached cartridges so the slot is irrelevant here. Each GROM |
| 1444 | | // contains an internal address counter, and we must make sure they all stay in sync. |
| 1445 | | if ((offset & GROM_MASK) == GROM_AREA) |
| 1483 | else |
| 1446 | 1484 | { |
| 1447 | | for (int i=0; i < m_numcart; i++) |
| 1485 | if ((offset & 0x1000)==0x0000) |
| 1448 | 1486 | { |
| 1449 | | if (m_cartridge[i]->is_available()) |
| 1450 | | { |
| 1451 | | UINT8 newval = *value; |
| 1452 | | m_cartridge[i]->readz(space, offset, &newval, mem_mask); |
| 1453 | | if (i==slot) |
| 1454 | | { |
| 1455 | | *value = newval; |
| 1456 | | } |
| 1457 | | } |
| 1487 | *value = m_rom_ptr[offset & 0x0fff]; |
| 1458 | 1488 | } |
| 1459 | | } |
| 1460 | | else |
| 1461 | | { |
| 1462 | | if (slot < m_numcart && m_cartridge[slot]->is_available()) |
| 1489 | else |
| 1463 | 1490 | { |
| 1464 | | m_cartridge[slot]->readz(space, offset, value, mem_mask); |
| 1491 | *value = m_ram_ptr[offset & 0x0fff]; |
| 1465 | 1492 | } |
| 1466 | 1493 | } |
| 1467 | 1494 | } |
| 1468 | 1495 | |
| 1469 | | WRITE8_MEMBER(gromport_device::write) |
| 1496 | /* Write function for the minimem cartridge. */ |
| 1497 | WRITE8_MEMBER(ti99_minimem_cartridge::write) |
| 1470 | 1498 | { |
| 1471 | | // GRAMKracker support |
| 1472 | | if ((m_gk_slot != -1) /*&& (ioport("CARTSLOT")==CART_GK)*/) |
| 1473 | | { |
| 1474 | | m_cartridge[m_gk_slot]->write(space, offset, data, mem_mask); |
| 1475 | | return; |
| 1476 | | } |
| 1499 | // LOG("write standard\n"); |
| 1500 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1501 | gromwrite(space, offset, data, mem_mask); |
| 1477 | 1502 | |
| 1478 | | int slot = get_active_slot(true, offset); |
| 1479 | | |
| 1480 | | // Same issue as above (read) |
| 1481 | | // We don't have GRAM cartridges, anyway, so it's just used for setting the address. |
| 1482 | | if ((offset & GROM_MASK) == GROM_AREA) |
| 1503 | else |
| 1483 | 1504 | { |
| 1484 | | for (int i=0; i < m_numcart; i++) |
| 1505 | if ((offset & 0x1000)==0x0000) |
| 1485 | 1506 | { |
| 1486 | | if (m_cartridge[i]->is_available()) |
| 1487 | | { |
| 1488 | | m_cartridge[i]->write(space, offset, data, mem_mask); |
| 1489 | | } |
| 1507 | if (VERBOSE>1) LOG("ti99: gromport: Write access to cartridge ROM at address %04x ignored", offset); |
| 1490 | 1508 | } |
| 1509 | else |
| 1510 | { |
| 1511 | m_ram_ptr[offset & 0x0fff] = data; |
| 1512 | } |
| 1491 | 1513 | } |
| 1514 | } |
| 1515 | |
| 1516 | /***************************************************************************** |
| 1517 | Cartridge type: SuperSpace II |
| 1518 | |
| 1519 | SuperSpace is intended as a user-definable blank cartridge containing |
| 1520 | buffered RAM. It has an Editor/Assembler GROM which helps the user to load |
| 1521 | the user program into the cartridge. If the user program has a suitable |
| 1522 | header, the console recognizes the cartridge as runnable, and |
| 1523 | assigns a number in the selection screen. Switching the RAM banks in this |
| 1524 | cartridge is achieved by setting CRU bits (the system serial interface). |
| 1525 | |
| 1526 | GROM: Editor/Assembler GROM |
| 1527 | ROM: none |
| 1528 | persistent RAM: 32 KiB (0x6000-0x7fff, 4 banks) |
| 1529 | Banking: via CRU write |
| 1530 | ******************************************************************************/ |
| 1531 | |
| 1532 | /* Read function for the super cartridge. */ |
| 1533 | READ8Z_MEMBER(ti99_super_cartridge::readz) |
| 1534 | { |
| 1535 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1536 | gromreadz(space, offset, value, mem_mask); |
| 1492 | 1537 | else |
| 1493 | 1538 | { |
| 1494 | | if (slot < m_numcart && m_cartridge[slot]->is_available()) |
| 1539 | if (m_ram_ptr != NULL) |
| 1495 | 1540 | { |
| 1496 | | // LOG("try it on slot %d\n", slot); |
| 1497 | | m_cartridge[slot]->write(space, offset, data, mem_mask); |
| 1541 | *value = m_ram_ptr[(m_ram_page << 13) | (offset & 0x1fff)]; |
| 1498 | 1542 | } |
| 1499 | 1543 | } |
| 1500 | 1544 | } |
| 1501 | 1545 | |
| 1502 | | /* |
| 1503 | | Called from the cartriges. |
| 1504 | | */ |
| 1505 | | WRITE_LINE_MEMBER(gromport_device::ready_line) |
| 1546 | /* Write function for the super cartridge. */ |
| 1547 | WRITE8_MEMBER(ti99_super_cartridge::write) |
| 1506 | 1548 | { |
| 1507 | | m_ready(state); |
| 1549 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1550 | gromwrite(space, offset, data, mem_mask); |
| 1551 | else |
| 1552 | { |
| 1553 | m_ram_ptr[(m_ram_page << 13) | (offset & 0x1fff)] = data; |
| 1554 | } |
| 1508 | 1555 | } |
| 1509 | 1556 | |
| 1510 | | /**************************************************** |
| 1511 | | CRU interface |
| 1512 | | ****************************************************/ |
| 1513 | | void gromport_device::crureadz(offs_t offset, UINT8 *value) |
| 1557 | void ti99_super_cartridge::crureadz(offs_t offset, UINT8 *value) |
| 1514 | 1558 | { |
| 1515 | | // GRAMKracker support |
| 1516 | | if ((m_gk_slot != -1) /* && (ioport("CARTSLOT")==CART_GK)*/) |
| 1517 | | { |
| 1518 | | m_cartridge[m_gk_slot]->crureadz(offset, value); |
| 1519 | | return; |
| 1520 | | } |
| 1559 | // offset is the bit number. The CRU base address is already divided by 2. |
| 1521 | 1560 | |
| 1522 | | int slot = get_active_slot(false, offset); |
| 1561 | // ram_page contains the bank number. We have a maximum of |
| 1562 | // 4 banks; the Super Space II manual says: |
| 1563 | // |
| 1564 | // Banks are selected by writing a bit pattern to CRU address >0800: |
| 1565 | // |
| 1566 | // Bank # Value |
| 1567 | // 0 >02 = 0000 0010 |
| 1568 | // 1 >08 = 0000 1000 |
| 1569 | // 2 >20 = 0010 0000 |
| 1570 | // 3 >80 = 1000 0000 |
| 1571 | // |
| 1572 | // With the bank number (0, 1, 2, or 3) in R0: |
| 1573 | // |
| 1574 | // BNKSW LI R12,>0800 Set CRU address |
| 1575 | // LI R1,2 Load Shift Bit |
| 1576 | // SLA R0,1 Align Bank Number |
| 1577 | // JEQ BNKS1 Skip shift if Bank 0 |
| 1578 | // SLA R1,0 Align Shift Bit |
| 1579 | // BNKS1 LDCR R1,0 Switch Banks |
| 1580 | // SRL R0,1 Restore Bank Number (optional) |
| 1581 | // RT |
| 1523 | 1582 | |
| 1524 | | /* Sanity check. Higher slots are always empty. */ |
| 1525 | | if (slot >= m_numcart) |
| 1526 | | return; |
| 1583 | // Our implementation in MESS always gets 8 bits in one go. Also, the address |
| 1584 | // is twice the bit number. That is, the offset value is always a multiple |
| 1585 | // of 0x10. |
| 1527 | 1586 | |
| 1528 | | if (m_cartridge[slot]->is_available()) |
| 1587 | if ((offset & 0xfff0) == 0x0800) |
| 1529 | 1588 | { |
| 1530 | | m_cartridge[slot]->crureadz(offset, value); |
| 1589 | if (VERBOSE>2) LOG("ti99_super_cartridge: CRU accessed at %04x\n", offset); |
| 1590 | UINT8 val = 0x02 << (m_ram_page << 1); |
| 1591 | *value = (val >> ((offset - 0x0800)>>1)) & 0xff; |
| 1531 | 1592 | } |
| 1532 | 1593 | } |
| 1533 | 1594 | |
| 1534 | | void gromport_device::cruwrite(offs_t offset, UINT8 data) |
| 1595 | void ti99_super_cartridge::cruwrite(offs_t offset, UINT8 data) |
| 1535 | 1596 | { |
| 1536 | | // GRAMKracker support |
| 1537 | | if ((m_gk_slot != -1) /*&& (ioport("CARTSLOT")==CART_GK)*/) |
| 1597 | if ((offset & 0xfff0) == 0x0800) |
| 1538 | 1598 | { |
| 1539 | | m_cartridge[m_gk_slot]->cruwrite(offset, data); |
| 1540 | | return; |
| 1599 | if (VERBOSE>2) LOG("ti99_super_cartridge: CRU accessed at %04x\n", offset); |
| 1600 | if (data != 0) |
| 1601 | m_ram_page = (offset-0x0802)>>2; |
| 1541 | 1602 | } |
| 1603 | } |
| 1542 | 1604 | |
| 1543 | | int slot = get_active_slot(true, offset); |
| 1605 | /***************************************************************************** |
| 1606 | Cartridge type: MBX |
| 1607 | GROM: up to 40 KiB |
| 1608 | ROM: up to 16 KiB (in up to 2 banks of 8KiB each) |
| 1609 | RAM: 1022 B (0x6c00-0x6ffd, overrides ROM in that area) |
| 1610 | ROM mapper: 6ffe |
| 1544 | 1611 | |
| 1545 | | /* Sanity check. Higher slots are always empty. */ |
| 1546 | | if (slot >= m_numcart) |
| 1547 | | return; |
| 1612 | TODO: Some MBX cartridges assume the presence of the MBX system |
| 1613 | (special user interface box with speech input/output) |
| 1614 | and will not run without it. This MBX hardware is not emulated yet. |
| 1615 | ******************************************************************************/ |
| 1548 | 1616 | |
| 1549 | | if (m_cartridge[slot]->is_available()) |
| 1617 | /* Read function for the mbx cartridge. */ |
| 1618 | READ8Z_MEMBER(ti99_mbx_cartridge::readz) |
| 1619 | { |
| 1620 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1621 | gromreadz(space, offset, value, mem_mask); |
| 1622 | else |
| 1550 | 1623 | { |
| 1551 | | m_cartridge[slot]->cruwrite(offset, data); |
| 1624 | if ((offset & 0x1c00)==0x0c00) |
| 1625 | { |
| 1626 | // This is the RAM area which overrides any ROM. There is no |
| 1627 | // known banking behavior for the RAM, so we must assume that |
| 1628 | // there is only one bank. |
| 1629 | if (m_ram_ptr != NULL) |
| 1630 | *value = m_ram_ptr[offset & 0x03ff]; |
| 1631 | } |
| 1632 | else |
| 1633 | { |
| 1634 | if (m_rom_ptr!=NULL) |
| 1635 | *value = m_rom_ptr[(offset & 0x1fff) | (m_rom_page<<13)]; |
| 1636 | } |
| 1552 | 1637 | } |
| 1553 | 1638 | } |
| 1554 | 1639 | |
| 1555 | | /**************************************************** |
| 1556 | | Device management |
| 1557 | | ****************************************************/ |
| 1558 | | void gromport_device::device_start(void) |
| 1640 | /* Write function for the mbx cartridge. */ |
| 1641 | WRITE8_MEMBER(ti99_mbx_cartridge::write) |
| 1559 | 1642 | { |
| 1560 | | // Resolve the callback line |
| 1561 | | const gromport_config *intf = reinterpret_cast<const gromport_config *>(static_config()); |
| 1562 | | m_ready.resolve(intf->ready, *this); |
| 1643 | if ((offset & GROM_MASK)==GROM_AREA) |
| 1644 | gromwrite(space, offset, data, mem_mask); |
| 1645 | else |
| 1646 | { |
| 1647 | if (offset == 0x6ffe) |
| 1648 | { |
| 1649 | m_rom_page = data & 1; |
| 1650 | return; |
| 1651 | } |
| 1563 | 1652 | |
| 1564 | | // Add the cartridges to the list |
| 1565 | | device_iterator *iter = new device_iterator(*this, 1); |
| 1653 | if ((offset & 0x1c00)==0x0c00) |
| 1654 | { |
| 1655 | if (m_ram_ptr == NULL) return; |
| 1656 | m_ram_ptr[offset & 0x03ff] = data; |
| 1657 | } |
| 1658 | } |
| 1659 | } |
| 1566 | 1660 | |
| 1567 | | int i = 0; |
| 1568 | | cartridge_device *cart = static_cast<cartridge_device*>(iter->first()); |
| 1661 | /***************************************************************************** |
| 1662 | Cartridge type: paged379i |
| 1663 | This cartridge consists of one 16 KiB, 32 KiB, 64 KiB, or 128 KiB EEPROM |
| 1664 | which is organised in 2, 4, 8, or 16 pages of 8 KiB each. The complete |
| 1665 | memory contents must be stored in one dump file. |
| 1666 | The pages are selected by writing a value to some memory locations. Due to |
| 1667 | using the inverted outputs of the LS379 latch, setting the inputs of the |
| 1668 | latch to all 0 selects the highest bank, while setting to all 1 selects the |
| 1669 | lowest. There are some cartridges (16 KiB) which are using this scheme, and |
| 1670 | there are new hardware developments mainly relying on this scheme. |
| 1569 | 1671 | |
| 1570 | | // Skip the first node (it's the gromport) |
| 1571 | | cart = static_cast<cartridge_device*>(iter->next()); |
| 1572 | | while (cart != NULL) |
| 1672 | Writing to selects page (16K/32K/64K/128K) |
| 1673 | >6000 1 / 3 / 7 / 15 |
| 1674 | >6002 0 / 2 / 6 / 14 |
| 1675 | >6004 1 / 1 / 5 / 13 |
| 1676 | >6006 0 / 0 / 4 / 12 |
| 1677 | >6008 1 / 3 / 3 / 11 |
| 1678 | >600A 0 / 2 / 2 / 10 |
| 1679 | >600C 1 / 1 / 1 / 9 |
| 1680 | >600E 0 / 0 / 0 / 8 |
| 1681 | >6010 1 / 3 / 7 / 7 |
| 1682 | >6012 0 / 2 / 6 / 6 |
| 1683 | >6014 1 / 1 / 5 / 5 |
| 1684 | >6016 0 / 0 / 4 / 4 |
| 1685 | >6018 1 / 3 / 3 / 3 |
| 1686 | >601A 0 / 2 / 2 / 2 |
| 1687 | >601C 1 / 1 / 1 / 1 |
| 1688 | >601E 0 / 0 / 0 / 0 |
| 1689 | |
| 1690 | The paged379i cartrige does not have any GROMs. |
| 1691 | ******************************************************************************/ |
| 1692 | |
| 1693 | /* |
| 1694 | Determines which bank to set, depending on the size of the ROM. This is |
| 1695 | some magic code that actually represents different PCB versions. |
| 1696 | */ |
| 1697 | int ti99_paged379i_cartridge::get_paged379i_bank(int rompage) |
| 1698 | { |
| 1699 | int mask = 0; |
| 1700 | if (m_rom_size > 16384) |
| 1573 | 1701 | { |
| 1574 | | m_cartridge[i++] = cart; |
| 1575 | | // LOG("tag = %s\n", cart->tag()); |
| 1576 | | cart = static_cast<cartridge_device*>(iter->next()); |
| 1702 | if (m_rom_size > 32768) |
| 1703 | { |
| 1704 | if (m_rom_size > 65536) |
| 1705 | mask = 15; |
| 1706 | else |
| 1707 | mask = 7; |
| 1708 | } |
| 1709 | else |
| 1710 | mask = 3; |
| 1577 | 1711 | } |
| 1578 | | m_numcart = i; |
| 1579 | | m_next_free_slot = 0; |
| 1580 | | m_active_slot = 0; |
| 1581 | | } |
| 1712 | else |
| 1713 | mask = 1; |
| 1582 | 1714 | |
| 1583 | | void gromport_device::device_stop(void) |
| 1584 | | { |
| 1715 | return rompage & mask; |
| 1585 | 1716 | } |
| 1586 | 1717 | |
| 1587 | | void gromport_device::device_reset(void) |
| 1718 | |
| 1719 | /* Read function for the paged379i cartridge. */ |
| 1720 | READ8Z_MEMBER(ti99_paged379i_cartridge::readz) |
| 1588 | 1721 | { |
| 1589 | | m_active_slot = 0; |
| 1590 | | m_fixed_slot = ioport("CARTSLOT")->read() - 1; |
| 1722 | if ((offset & 0xe000)==0x6000) |
| 1723 | *value = m_rom_ptr[(m_rom_page<<13) | (offset & 0x1fff)]; |
| 1591 | 1724 | } |
| 1592 | 1725 | |
| 1593 | | INPUT_CHANGED_MEMBER( gromport_device::gk_changed ) |
| 1726 | /* Write function for the paged379i cartridge. Only used to set the bank. */ |
| 1727 | WRITE8_MEMBER(ti99_paged379i_cartridge::write) |
| 1594 | 1728 | { |
| 1595 | | if (VERBOSE>7) LOG("gromport: input changed %d - %d\n", (int)((UINT64)param & 0x07), newval); |
| 1596 | | if (m_gk_slot != -1) |
| 1729 | // Bits: 0110 0000 000b bbbx |
| 1730 | // x = don't care, bbbb = bank |
| 1731 | if ((offset & 0xffe0)==0x6000) |
| 1597 | 1732 | { |
| 1598 | | m_cartridge[m_gk_slot]->set_switch((UINT64)param & 0x07, newval); // param is a pointer type |
| 1733 | // Set bank |
| 1734 | m_rom_page = get_paged379i_bank(15 - ((offset>>1) & 15)); |
| 1599 | 1735 | } |
| 1600 | 1736 | } |
| 1601 | 1737 | |
| 1602 | | INPUT_PORTS_START(gromport_device) |
| 1603 | | PORT_START( "CARTSLOT" ) |
| 1604 | | PORT_DIPNAME( 0x0f, 0x00, "Multi-cartridge slot" ) |
| 1605 | | PORT_DIPSETTING( 0x00, "Auto" ) |
| 1606 | | PORT_DIPSETTING( 0x01, "Slot 1" ) |
| 1607 | | PORT_DIPSETTING( 0x02, "Slot 2" ) |
| 1608 | | PORT_DIPSETTING( 0x03, "Slot 3" ) |
| 1609 | | PORT_DIPSETTING( 0x04, "Slot 4" ) |
| 1610 | | PORT_DIPSETTING( 0x0f, "GRAM Kracker" ) |
| 1738 | /***************************************************************************** |
| 1739 | Cartridge type: pagedcru |
| 1740 | This cartridge consists of one 16 KiB, 32 KiB, or 64 KiB EEPROM which is |
| 1741 | organised in 2, 4, or 8 pages of 8 KiB each. We assume there is only one |
| 1742 | dump file of the respective size. |
| 1743 | The pages are selected by writing a value to the CRU. This scheme is |
| 1744 | similar to the one used for the SuperSpace cartridge, with the exception |
| 1745 | that we are using ROM only, and we can have up to 8 pages. |
| 1611 | 1746 | |
| 1612 | | PORT_START( GKSWITCH1_TAG ) |
| 1613 | | PORT_DIPNAME( 0x01, 0x01, "GK switch 1" ) PORT_CONDITION( "CARTSLOT", 0x0f, EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 1) |
| 1614 | | PORT_DIPSETTING( 0x00, "GK Off" ) |
| 1615 | | PORT_DIPSETTING( 0x01, DEF_STR( Normal ) ) |
| 1747 | Bank Value written to CRU>0800 |
| 1748 | 0 >0002 = 0000 0000 0000 0010 |
| 1749 | 1 >0008 = 0000 0000 0000 1000 |
| 1750 | 2 >0020 = 0000 0000 0010 0000 |
| 1751 | 3 >0080 = 0000 0000 1000 0000 |
| 1752 | 4 >0200 = 0000 0010 0000 0000 |
| 1753 | 5 >0800 = 0000 1000 0000 0000 |
| 1754 | 6 >2000 = 0010 0000 0000 0000 |
| 1755 | 7 >8000 = 1000 0000 0000 0000 |
| 1616 | 1756 | |
| 1617 | | PORT_START( GKSWITCH2_TAG ) |
| 1618 | | PORT_DIPNAME( 0x01, 0x01, "GK switch 2" ) PORT_CONDITION( "CARTSLOT", 0x0f, EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 2) |
| 1619 | | PORT_DIPSETTING( 0x00, "GRAM 0" ) |
| 1620 | | PORT_DIPSETTING( 0x01, "Op Sys" ) |
| 1757 | No GROMs used in this type. |
| 1758 | ******************************************************************************/ |
| 1621 | 1759 | |
| 1622 | | PORT_START( GKSWITCH3_TAG ) |
| 1623 | | PORT_DIPNAME( 0x01, 0x01, "GK switch 3" ) PORT_CONDITION( "CARTSLOT", 0x0f, EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 3) |
| 1624 | | PORT_DIPSETTING( 0x00, "GRAM 1-2" ) |
| 1625 | | PORT_DIPSETTING( 0x01, "TI BASIC" ) |
| 1760 | /* Read function for the pagedcru cartridge. */ |
| 1761 | READ8Z_MEMBER(ti99_pagedcru_cartridge::readz) |
| 1762 | { |
| 1763 | if ((offset & 0xe000)==0x6000) |
| 1764 | *value = m_rom_ptr[(m_rom_page<<13) | (offset & 0x1fff)]; |
| 1765 | } |
| 1626 | 1766 | |
| 1627 | | PORT_START( GKSWITCH4_TAG ) |
| 1628 | | PORT_DIPNAME( 0x03, 0x01, "GK switch 4" ) PORT_CONDITION( "CARTSLOT", 0x0f, EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 4) |
| 1629 | | PORT_DIPSETTING( 0x00, "Bank 1" ) |
| 1630 | | PORT_DIPSETTING( 0x01, "W/P" ) |
| 1631 | | PORT_DIPSETTING( 0x02, "Bank 2" ) |
| 1767 | /* Write function for the pagedcru cartridge. No effect. */ |
| 1768 | WRITE8_MEMBER(ti99_pagedcru_cartridge::write) |
| 1769 | { |
| 1770 | return; |
| 1771 | } |
| 1632 | 1772 | |
| 1633 | | PORT_START( GKSWITCH5_TAG ) |
| 1634 | | PORT_DIPNAME( 0x01, 0x00, "GK switch 5" ) PORT_CONDITION( "CARTSLOT", 0x0f, EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 5) |
| 1635 | | PORT_DIPSETTING( 0x00, "Loader On" ) |
| 1636 | | PORT_DIPSETTING( 0x01, "Loader Off" ) |
| 1637 | | INPUT_PORTS_END |
| 1638 | | |
| 1639 | | static MACHINE_CONFIG_FRAGMENT(gromport_device) |
| 1640 | | MCFG_DEVICE_ADD("cartridge1", TICARTRIDGE, 0) |
| 1641 | | MCFG_DEVICE_ADD("cartridge2", TICARTRIDGE, 0) |
| 1642 | | MCFG_DEVICE_ADD("cartridge3", TICARTRIDGE, 0) |
| 1643 | | MCFG_DEVICE_ADD("cartridge4", TICARTRIDGE, 0) |
| 1644 | | MACHINE_CONFIG_END |
| 1645 | | |
| 1646 | | machine_config_constructor gromport_device::device_mconfig_additions() const |
| 1773 | void ti99_pagedcru_cartridge::crureadz(offs_t offset, UINT8 *value) |
| 1647 | 1774 | { |
| 1648 | | return MACHINE_CONFIG_NAME( gromport_device ); |
| 1775 | int page = m_rom_page; |
| 1776 | if ((offset & 0xf800)==0x0800) |
| 1777 | { |
| 1778 | int bit = (offset & 0x001e)>>1; |
| 1779 | if (bit != 0) |
| 1780 | { |
| 1781 | page = page-(bit/2); // 4 page flags per 8 bits |
| 1782 | } |
| 1783 | *value = 1 << (page*2+1); |
| 1784 | } |
| 1649 | 1785 | } |
| 1650 | 1786 | |
| 1651 | | ioport_constructor gromport_device::device_input_ports() const |
| 1787 | void ti99_pagedcru_cartridge::cruwrite(offs_t offset, UINT8 data) |
| 1652 | 1788 | { |
| 1653 | | return INPUT_PORTS_NAME(gromport_device); |
| 1789 | if ((offset & 0xf800)==0x0800) |
| 1790 | { |
| 1791 | int bit = (offset & 0x001e)>>1; |
| 1792 | if (data != 0 && bit > 0) |
| 1793 | { |
| 1794 | m_rom_page = (bit-1)/2; |
| 1795 | } |
| 1796 | } |
| 1654 | 1797 | } |
| 1655 | 1798 | |
| 1656 | | const device_type GROMPORT = &device_creator<gromport_device>; |
| 1657 | | const device_type TICARTRIDGE = &device_creator<cartridge_device>; |
| 1799 | /**************************************************************************** |
| 1658 | 1800 | |
| 1659 | | const device_type TICARTPCBSTD = &device_creator<cartridge_pcb_standard_device>; |
| 1660 | | const device_type TICARTPCBPAG = &device_creator<cartridge_pcb_paged_device>; |
| 1661 | | const device_type TICARTPCBMIN = &device_creator<cartridge_pcb_minimem_device>; |
| 1662 | | const device_type TICARTPCBSUP = &device_creator<cartridge_pcb_superspace_device>; |
| 1663 | | const device_type TICARTPCBMBX = &device_creator<cartridge_pcb_mbx_device>; |
| 1664 | | const device_type TICARTPCBPGI = &device_creator<cartridge_pcb_paged379i_device>; |
| 1665 | | const device_type TICARTPCBPGC = &device_creator<cartridge_pcb_pagedcru_device>; |
| 1666 | | const device_type TICARTPCBGRK = &device_creator<cartridge_pcb_gramkracker_device>; |
| 1801 | RPK loader |
| 1667 | 1802 | |
| 1668 | | /***************************************************************************************************************** |
| 1669 | | ****************************************************************************************************************** |
| 1670 | | RPK format support |
| 1803 | RPK format support |
| 1671 | 1804 | |
| 1672 | 1805 | A RPK file ("rompack") contains a collection of dump files and a layout |
| 1673 | 1806 | file that defines the kind of circuit board (PCB) used in the cartridge |
| r15583 | r15584 | |
| 1728 | 1861 | |
| 1729 | 1862 | rpk::~rpk() |
| 1730 | 1863 | { |
| 1731 | | if (VERBOSE>6) LOG("Destroy RPK\n"); |
| 1864 | if (VERBOSE>6) LOG("rpk: Destroy RPK\n"); |
| 1732 | 1865 | } |
| 1733 | 1866 | |
| 1734 | 1867 | /* |
| r15583 | r15584 | |
| 2098 | 2231 | |
| 2099 | 2232 | return newrpk; |
| 2100 | 2233 | } |
| 2234 | |