src/mess/machine/gamecom.c
| r3658 | r3659 | |
| 72 | 72 | MACHINE_RESET( gamecom ) |
| 73 | 73 | { |
| 74 | 74 | UINT8 *rom = memory_region(machine, "user1"); |
| 75 | | memory_set_bankptr( 1, rom ); |
| 76 | | memory_set_bankptr( 2, rom ); |
| 77 | | memory_set_bankptr( 3, rom ); |
| 78 | | memory_set_bankptr( 4, rom ); |
| 75 | memory_set_bankptr( machine, 1, rom ); |
| 76 | memory_set_bankptr( machine, 2, rom ); |
| 77 | memory_set_bankptr( machine, 3, rom ); |
| 78 | memory_set_bankptr( machine, 4, rom ); |
| 79 | 79 | |
| 80 | 80 | /* should possibly go in a DRIVER_INIT piece? */ |
| 81 | 81 | gamecom_clock_timer = timer_alloc( gamecom_clock_timer_callback , NULL); |
| 82 | 82 | |
| 83 | 83 | /* intialize the empty dummy bank */ |
| 84 | | if ( dummy_bank == NULL ) { |
| 84 | if ( dummy_bank == NULL ) |
| 85 | { |
| 85 | 86 | dummy_bank = auto_malloc( 8 * 1024 ); |
| 86 | 87 | } |
| 87 | 88 | memset( dummy_bank, 0xff, 8 * 1024 ); |
| r3658 | r3659 | |
| 90 | 91 | gamecom_dma.enabled = 0; |
| 91 | 92 | |
| 92 | 93 | memset( internal_registers, 0x00, sizeof(internal_registers) ); |
| 93 | | gamecom_internal_w( machine, SM8521_URTT, 0xFF ); |
| 94 | | gamecom_internal_w( machine, SM8521_URTS, 0x42 ); |
| 95 | | gamecom_internal_w( machine, SM8521_WDTC, 0x38 ); |
| 94 | gamecom_internal_w( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), SM8521_URTT, 0xFF ); |
| 95 | gamecom_internal_w( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), SM8521_URTS, 0x42 ); |
| 96 | gamecom_internal_w( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), SM8521_WDTC, 0x38 ); |
| 96 | 97 | } |
| 97 | 98 | |
| 98 | | static void gamecom_set_mmu( running_machine *machine, int mmu, UINT8 data ) { |
| 99 | | if ( data < 32 ) { |
| 99 | static void gamecom_set_mmu( running_machine *machine, int mmu, UINT8 data ) |
| 100 | { |
| 101 | if ( data < 32 ) |
| 102 | { |
| 100 | 103 | /* select internal ROM bank */ |
| 101 | | memory_set_bankptr( mmu, memory_region(machine, "user1") + (data << 13) ); |
| 102 | | } else { |
| 104 | memory_set_bankptr( machine, mmu, memory_region(machine, "user1") + (data << 13) ); |
| 105 | } |
| 106 | else |
| 107 | { |
| 103 | 108 | /* select cartridge bank */ |
| 104 | | if ( cartridge == NULL ) { |
| 105 | | memory_set_bankptr( mmu, dummy_bank ); |
| 106 | | } else { |
| 107 | | memory_set_bankptr( mmu, cartridge + ( data << 13 ) ); |
| 109 | if ( cartridge == NULL ) |
| 110 | { |
| 111 | memory_set_bankptr( machine, mmu, dummy_bank ); |
| 112 | } |
| 113 | else |
| 114 | { |
| 115 | memory_set_bankptr( machine, mmu, cartridge + ( data << 13 ) ); |
| 108 | 116 | } |
| 109 | 117 | } |
| 110 | 118 | } |
| 111 | 119 | |
| 112 | | static void handle_stylus_press( running_machine *machine, UINT8 column ) { |
| 120 | static void handle_stylus_press( running_machine *machine, UINT8 column ) |
| 121 | { |
| 113 | 122 | static const UINT16 row_data[10] = { 0x3FE, 0x3FD, 0x3FB, 0x3F7, 0x3EF, 0x3DF, 0x3BF, 0x37F, 0x2FF, 0x1FF }; |
| 114 | 123 | static UINT32 stylus_x; |
| 115 | 124 | static UINT32 stylus_y; |
| 116 | 125 | |
| 117 | | if ( column == 0 ) { |
| 118 | | if ( ! ( input_port_read(machine, "IN2") & 0x04 ) ) { |
| 126 | if ( column == 0 ) |
| 127 | { |
| 128 | if ( ! ( input_port_read(machine, "IN2") & 0x04 ) ) |
| 129 | { |
| 119 | 130 | stylus_x = input_port_read(machine, "IN3") >> 4; |
| 120 | 131 | stylus_y = input_port_read(machine, "IN4") >> 4; |
| 121 | | } else { |
| 132 | } |
| 133 | else |
| 134 | { |
| 122 | 135 | stylus_x = 16; |
| 123 | 136 | stylus_y = 16; |
| 124 | 137 | } |
| 125 | 138 | } |
| 126 | 139 | |
| 127 | | if ( stylus_x == column ) { |
| 128 | | cpunum_set_reg( 0, SM8500_P0, row_data[stylus_y] & 0xFF ); |
| 129 | | cpunum_set_reg( 0, SM8500_P1, ( cpunum_get_reg( 0, SM8500_P1 ) & 0xFC ) | ( ( row_data[stylus_y] >> 8 ) & 0x03 ) ); |
| 130 | | } else { |
| 131 | | cpunum_set_reg( 0, SM8500_P0, 0xFF ); |
| 132 | | cpunum_set_reg( 0, SM8500_P1, ( cpunum_get_reg( 0, SM8500_P1 ) & 0xFC ) | 0x03 ); |
| 140 | if ( stylus_x == column ) |
| 141 | { |
| 142 | cpu_set_reg( machine->cpu[0], SM8500_P0, row_data[stylus_y] & 0xFF ); |
| 143 | cpu_set_reg( machine->cpu[0], SM8500_P1, ( cpu_get_reg( machine->cpu[0], SM8500_P1 ) & 0xFC ) | ( ( row_data[stylus_y] >> 8 ) & 0x03 ) ); |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | cpu_set_reg( machine->cpu[0], SM8500_P0, 0xFF ); |
| 148 | cpu_set_reg( machine->cpu[0], SM8500_P1, ( cpu_get_reg( machine->cpu[0], SM8500_P1 ) & 0xFC ) | 0x03 ); |
| 133 | 149 | } |
| 134 | 150 | } |
| 135 | 151 | |
| 136 | 152 | WRITE8_HANDLER( gamecom_internal_w ) |
| 137 | 153 | { |
| 138 | | if ( offset >= 0x80 ) { |
| 154 | if ( offset >= 0x80 ) |
| 155 | { |
| 139 | 156 | internal_ram[offset] = data; |
| 140 | 157 | return; |
| 141 | 158 | } |
| 142 | 159 | |
| 143 | | switch( offset ) { |
| 144 | | case SM8521_IE0: cpunum_set_reg( 0, SM8500_IE0, data ); return; |
| 145 | | case SM8521_IE1: cpunum_set_reg( 0, SM8500_IE1, data ); return; |
| 146 | | case SM8521_IR0: cpunum_set_reg( 0, SM8500_IR0, data ); return; |
| 147 | | case SM8521_IR1: cpunum_set_reg( 0, SM8500_IR1, data ); return; |
| 148 | | case SM8521_P0: cpunum_set_reg( 0, SM8500_P0, data ); return; |
| 149 | | case SM8521_P1: cpunum_set_reg( 0, SM8500_P1, data ); return; |
| 150 | | case SM8521_P2: cpunum_set_reg( 0, SM8500_P2, data ); |
| 151 | | switch( ( cpunum_get_reg( 0, SM8500_P1 ) << 8 ) | data ) { |
| 160 | switch( offset ) |
| 161 | { |
| 162 | case SM8521_IE0: cpu_set_reg( space->machine->cpu[0], SM8500_IE0, data ); return; |
| 163 | case SM8521_IE1: cpu_set_reg( space->machine->cpu[0], SM8500_IE1, data ); return; |
| 164 | case SM8521_IR0: cpu_set_reg( space->machine->cpu[0], SM8500_IR0, data ); return; |
| 165 | case SM8521_IR1: cpu_set_reg( space->machine->cpu[0], SM8500_IR1, data ); return; |
| 166 | case SM8521_P0: cpu_set_reg( space->machine->cpu[0], SM8500_P0, data ); return; |
| 167 | case SM8521_P1: cpu_set_reg( space->machine->cpu[0], SM8500_P1, data ); return; |
| 168 | case SM8521_P2: cpu_set_reg( space->machine->cpu[0], SM8500_P2, data ); |
| 169 | switch( ( cpu_get_reg( space->machine->cpu[0], SM8500_P1 ) << 8 ) | data ) |
| 170 | { |
| 152 | 171 | case 0xFBFF: /* column #0 */ |
| 153 | 172 | /* P0 bit 0 cleared => 01 */ |
| 154 | 173 | /* P0 bit 1 cleared => 0E */ |
| r3658 | r3659 | |
| 160 | 179 | /* P0 bit 7 cleared => */ |
| 161 | 180 | /* P1 bit 0 cleared => */ |
| 162 | 181 | /* P1 bit 1 cleared => */ |
| 163 | | handle_stylus_press( machine, 0 ); |
| 182 | handle_stylus_press( space->machine, 0 ); |
| 164 | 183 | break; |
| 165 | 184 | case 0xF7FF: /* column #1 */ |
| 166 | | handle_stylus_press( machine, 1 ); |
| 185 | handle_stylus_press( space->machine, 1 ); |
| 167 | 186 | break; |
| 168 | 187 | case 0xEFFF: /* column #2 */ |
| 169 | | handle_stylus_press( machine, 2 ); |
| 188 | handle_stylus_press( space->machine, 2 ); |
| 170 | 189 | break; |
| 171 | 190 | case 0xDFFF: /* column #3 */ |
| 172 | | handle_stylus_press( machine, 3 ); |
| 191 | handle_stylus_press( space->machine, 3 ); |
| 173 | 192 | break; |
| 174 | 193 | case 0xBFFF: /* column #4 */ |
| 175 | | handle_stylus_press( machine, 4 ); |
| 194 | handle_stylus_press( space->machine, 4 ); |
| 176 | 195 | break; |
| 177 | 196 | case 0x7FFF: /* column #5 */ |
| 178 | | handle_stylus_press( machine, 5 ); |
| 197 | handle_stylus_press( space->machine, 5 ); |
| 179 | 198 | break; |
| 180 | 199 | case 0xFFFE: /* column #6 */ |
| 181 | | handle_stylus_press( machine, 6 ); |
| 200 | handle_stylus_press( space->machine, 6 ); |
| 182 | 201 | break; |
| 183 | 202 | case 0xFFFD: /* column #7 */ |
| 184 | | handle_stylus_press( machine, 7 ); |
| 203 | handle_stylus_press( space->machine, 7 ); |
| 185 | 204 | break; |
| 186 | 205 | case 0xFFFB: /* column #8 */ |
| 187 | | handle_stylus_press( machine, 8 ); |
| 206 | handle_stylus_press( space->machine, 8 ); |
| 188 | 207 | break; |
| 189 | 208 | case 0xFFF7: /* column #9 */ |
| 190 | | handle_stylus_press( machine, 9 ); |
| 209 | handle_stylus_press( space->machine, 9 ); |
| 191 | 210 | break; |
| 192 | 211 | case 0xFFEF: /* column #10 */ |
| 193 | | handle_stylus_press( machine, 10 ); |
| 212 | handle_stylus_press( space->machine, 10 ); |
| 194 | 213 | break; |
| 195 | 214 | case 0xFFDF: /* column #11 */ |
| 196 | | handle_stylus_press( machine, 11 ); |
| 215 | handle_stylus_press( space->machine, 11 ); |
| 197 | 216 | break; |
| 198 | 217 | case 0xFFBF: /* column #12 */ |
| 199 | | handle_stylus_press( machine, 12 ); |
| 218 | handle_stylus_press( space->machine, 12 ); |
| 200 | 219 | break; |
| 201 | 220 | case 0xFF7F: /* keys #1 */ |
| 202 | 221 | /* P0 bit 0 cleared => 83 (up) */ |
| r3658 | r3659 | |
| 209 | 228 | /* P0 bit 7 cleared => 8B (button A) */ |
| 210 | 229 | /* P1 bit 0 cleared => 8C (button B) */ |
| 211 | 230 | /* P1 bit 1 cleared => 8D (button C) */ |
| 212 | | cpunum_set_reg( 0, SM8500_P0, input_port_read(machine, "IN0") ); |
| 213 | | cpunum_set_reg( 0, SM8500_P1, ( cpunum_get_reg( 0, SM8500_P1 ) & 0xFC ) | ( input_port_read(machine, "IN1") & 0x03 ) ); |
| 231 | cpu_set_reg( space->machine->cpu[0], SM8500_P0, input_port_read(space->machine, "IN0") ); |
| 232 | cpu_set_reg( space->machine->cpu[0], SM8500_P1, ( cpu_get_reg( space->machine->cpu[0], SM8500_P1 ) & 0xFC ) | ( input_port_read(space->machine, "IN1") & 0x03 ) ); |
| 214 | 233 | break; |
| 215 | 234 | case 0xFFFF: /* keys #2 */ |
| 216 | 235 | /* P0 bit 0 cleared => 88 (power) */ |
| r3658 | r3659 | |
| 223 | 242 | /* P0 bit 7 cleared => A0 */ |
| 224 | 243 | /* P1 bit 0 cleared => A0 */ |
| 225 | 244 | /* P1 bit 1 cleared => A0 */ |
| 226 | | cpunum_set_reg( 0, SM8500_P0, ( cpunum_get_reg( 0, SM8500_P0 ) & 0xFC ) | ( input_port_read(machine, "IN2") & 0x03 ) ); |
| 227 | | cpunum_set_reg( 0, SM8500_P1, 0xFF ); |
| 245 | cpu_set_reg( space->machine->cpu[0], SM8500_P0, ( cpu_get_reg( space->machine->cpu[0], SM8500_P0 ) & 0xFC ) | ( input_port_read(space->machine, "IN2") & 0x03 ) ); |
| 246 | cpu_set_reg( space->machine->cpu[0], SM8500_P1, 0xFF ); |
| 228 | 247 | break; |
| 229 | 248 | } |
| 230 | 249 | return; |
| 231 | 250 | case SM8521_P3: |
| 232 | 251 | /* P3 bit7 clear, bit6 set -> enable cartridge port #0? */ |
| 233 | 252 | /* P3 bit6 clear, bit7 set -> enable cartridge port #1? */ |
| 234 | | cpunum_set_reg( 0, SM8500_P3, data ); |
| 235 | | switch( data & 0xc0 ) { |
| 253 | cpu_set_reg( space->machine->cpu[0], SM8500_P3, data ); |
| 254 | switch( data & 0xc0 ) |
| 255 | { |
| 236 | 256 | case 0x40: cartridge = cartridge1; break; |
| 237 | 257 | case 0x80: cartridge = cartridge2; break; |
| 238 | 258 | default: cartridge = NULL; break; |
| 239 | 259 | } |
| 240 | 260 | /* update banks to reflect possible change of cartridge slot */ |
| 241 | | gamecom_set_mmu( machine, 1, internal_registers[SM8521_MMU1] ); |
| 242 | | gamecom_set_mmu( machine, 2, internal_registers[SM8521_MMU2] ); |
| 243 | | gamecom_set_mmu( machine, 3, internal_registers[SM8521_MMU3] ); |
| 244 | | gamecom_set_mmu( machine, 4, internal_registers[SM8521_MMU4] ); |
| 261 | gamecom_set_mmu( space->machine, 1, internal_registers[SM8521_MMU1] ); |
| 262 | gamecom_set_mmu( space->machine, 2, internal_registers[SM8521_MMU2] ); |
| 263 | gamecom_set_mmu( space->machine, 3, internal_registers[SM8521_MMU3] ); |
| 264 | gamecom_set_mmu( space->machine, 4, internal_registers[SM8521_MMU4] ); |
| 245 | 265 | return; |
| 246 | | case SM8521_SYS: cpunum_set_reg( 0, SM8500_SYS, data ); return; |
| 247 | | case SM8521_CKC: cpunum_set_reg( 0, SM8500_CKC, data ); return; |
| 248 | | case SM8521_SPH: cpunum_set_reg( 0, SM8500_SPH, data ); return; |
| 249 | | case SM8521_SPL: cpunum_set_reg( 0, SM8500_SPL, data ); return; |
| 250 | | case SM8521_PS0: cpunum_set_reg( 0, SM8500_PS0, data ); return; |
| 251 | | case SM8521_PS1: cpunum_set_reg( 0, SM8500_PS1, data ); return; |
| 252 | | case SM8521_P0C: cpunum_set_reg( 0, SM8500_P0C, data ); return; |
| 253 | | case SM8521_P1C: cpunum_set_reg( 0, SM8500_P1C, data ); return; |
| 254 | | case SM8521_P2C: cpunum_set_reg( 0, SM8500_P2C, data ); return; |
| 255 | | case SM8521_P3C: cpunum_set_reg( 0, SM8500_P3C, data ); return; |
| 266 | case SM8521_SYS: cpu_set_reg( space->machine->cpu[0], SM8500_SYS, data ); return; |
| 267 | case SM8521_CKC: cpu_set_reg( space->machine->cpu[0], SM8500_CKC, data ); return; |
| 268 | case SM8521_SPH: cpu_set_reg( space->machine->cpu[0], SM8500_SPH, data ); return; |
| 269 | case SM8521_SPL: cpu_set_reg( space->machine->cpu[0], SM8500_SPL, data ); return; |
| 270 | case SM8521_PS0: cpu_set_reg( space->machine->cpu[0], SM8500_PS0, data ); return; |
| 271 | case SM8521_PS1: cpu_set_reg( space->machine->cpu[0], SM8500_PS1, data ); return; |
| 272 | case SM8521_P0C: cpu_set_reg( space->machine->cpu[0], SM8500_P0C, data ); return; |
| 273 | case SM8521_P1C: cpu_set_reg( space->machine->cpu[0], SM8500_P1C, data ); return; |
| 274 | case SM8521_P2C: cpu_set_reg( space->machine->cpu[0], SM8500_P2C, data ); return; |
| 275 | case SM8521_P3C: cpu_set_reg( space->machine->cpu[0], SM8500_P3C, data ); return; |
| 256 | 276 | case SM8521_MMU0: /* disable bootstrap ROM? most likely not written to on game.com */ |
| 257 | 277 | logerror( "Write to MMU0\n" ); |
| 258 | 278 | break; |
| 259 | 279 | case SM8521_MMU1: |
| 260 | | gamecom_set_mmu( machine, 1, data ); |
| 280 | gamecom_set_mmu( space->machine, 1, data ); |
| 261 | 281 | break; |
| 262 | 282 | case SM8521_MMU2: |
| 263 | | gamecom_set_mmu( machine, 2, data ); |
| 283 | gamecom_set_mmu( space->machine, 2, data ); |
| 264 | 284 | break; |
| 265 | 285 | case SM8521_MMU3: |
| 266 | | gamecom_set_mmu( machine, 3, data ); |
| 286 | gamecom_set_mmu( space->machine, 3, data ); |
| 267 | 287 | break; |
| 268 | 288 | case SM8521_MMU4: |
| 269 | | gamecom_set_mmu( machine, 4, data ); |
| 289 | gamecom_set_mmu( space->machine, 4, data ); |
| 270 | 290 | break; |
| 271 | 291 | |
| 272 | 292 | /* Video hardware and DMA */ |
| r3658 | r3659 | |
| 283 | 303 | gamecom_dma.decrement_x = data & 0x08; |
| 284 | 304 | gamecom_dma.decrement_y = data & 0x10; |
| 285 | 305 | gamecom_dma.enabled = data & 0x80; |
| 286 | | if ( gamecom_dma.enabled ) { |
| 287 | | gamecom_dma_init(machine); |
| 306 | if ( gamecom_dma.enabled ) |
| 307 | { |
| 308 | gamecom_dma_init(space->machine); |
| 288 | 309 | } |
| 289 | 310 | break; |
| 290 | 311 | case SM8521_DMX1: |
| r3658 | r3659 | |
| 324 | 345 | gamecom_timer[1].counter = 0; |
| 325 | 346 | break; |
| 326 | 347 | case SM8521_CLKT: /* bit 6-7 */ |
| 327 | | if ( data & 0x80 ) { |
| 348 | if ( data & 0x80 ) |
| 349 | { |
| 328 | 350 | /* timer run */ |
| 329 | | if ( data & 0x40 ) { |
| 351 | if ( data & 0x40 ) |
| 352 | { |
| 330 | 353 | /* timer resolution 1 minute */ |
| 331 | 354 | timer_adjust_periodic(gamecom_clock_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(60)); |
| 332 | | } else { |
| 355 | } |
| 356 | else |
| 357 | { |
| 333 | 358 | /* TImer resolution 1 second */ |
| 334 | 359 | timer_adjust_periodic(gamecom_clock_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1)); |
| 335 | 360 | } |
| 336 | | } else { |
| 361 | } |
| 362 | else |
| 363 | { |
| 337 | 364 | /* disable timer reset */ |
| 338 | 365 | timer_enable( gamecom_clock_timer, 0 ); |
| 339 | 366 | data &= 0xC0; |
| r3658 | r3659 | |
| 349 | 376 | case SM8521_55: case SM8521_56: case SM8521_57: case SM8521_58: |
| 350 | 377 | case SM8521_59: case SM8521_5A: case SM8521_5B: case SM8521_5C: |
| 351 | 378 | case SM8521_5D: |
| 352 | | logerror( "%X: Write to reserved address (0x%02X). Value written: 0x%02X\n", activecpu_get_pc(), offset, data ); |
| 379 | logerror( "%X: Write to reserved address (0x%02X). Value written: 0x%02X\n", cpu_get_pc(space->cpu), offset, data ); |
| 353 | 380 | break; |
| 354 | 381 | } |
| 355 | 382 | internal_registers[offset] = data; |
| r3658 | r3659 | |
| 357 | 384 | |
| 358 | 385 | READ8_HANDLER( gamecom_internal_r ) |
| 359 | 386 | { |
| 360 | | if ( offset >= 0x80 ) { |
| 387 | if ( offset >= 0x80 ) |
| 388 | { |
| 361 | 389 | return internal_ram[offset]; |
| 362 | 390 | } |
| 363 | 391 | |
| 364 | | switch( offset ) { |
| 392 | switch( offset ) |
| 393 | { |
| 365 | 394 | case SM8521_R0: case SM8521_R1: case SM8521_R2: case SM8521_R3: |
| 366 | 395 | case SM8521_R4: case SM8521_R5: case SM8521_R6: case SM8521_R7: |
| 367 | 396 | case SM8521_R8: case SM8521_R9: case SM8521_R10: case SM8521_R11: |
| 368 | 397 | case SM8521_R12: case SM8521_R13: case SM8521_R14: case SM8521_R15: |
| 369 | 398 | return sm85cpu_mem_readbyte( offset ); |
| 370 | | case SM8521_IE0: return cpunum_get_reg( 0, SM8500_IE0 ); |
| 371 | | case SM8521_IE1: return cpunum_get_reg( 0, SM8500_IE1 ); |
| 372 | | case SM8521_IR0: return cpunum_get_reg( 0, SM8500_IR0 ); |
| 373 | | case SM8521_IR1: return cpunum_get_reg( 0, SM8500_IR1 ); |
| 374 | | case SM8521_P0: /* logerror( "%X: Read from P0\n", activecpu_get_pc() ); */ return cpunum_get_reg( 0, SM8500_P0 ); |
| 375 | | case SM8521_P1: /* logerror( "%X: Read from P1\n", activecpu_get_pc() ); */ return cpunum_get_reg( 0, SM8500_P1 ); |
| 376 | | case SM8521_P2: /* logerror( "%X: Read from P2\n", activecpu_get_pc() ); */ return cpunum_get_reg( 0, SM8500_P2 ); |
| 377 | | case SM8521_P3: return cpunum_get_reg( 0, SM8500_P3 ); |
| 378 | | case SM8521_SYS: return cpunum_get_reg( 0, SM8500_SYS ); |
| 379 | | case SM8521_CKC: return cpunum_get_reg( 0, SM8500_CKC ); |
| 380 | | case SM8521_SPH: return cpunum_get_reg( 0, SM8500_SPH ); |
| 381 | | case SM8521_SPL: return cpunum_get_reg( 0, SM8500_SPL ); |
| 382 | | case SM8521_PS0: return cpunum_get_reg( 0, SM8500_PS0 ); |
| 383 | | case SM8521_PS1: return cpunum_get_reg( 0, SM8500_PS1 ); |
| 384 | | case SM8521_P0C: return cpunum_get_reg( 0, SM8500_P0C ); |
| 385 | | case SM8521_P1C: return cpunum_get_reg( 0, SM8500_P1C ); |
| 386 | | case SM8521_P2C: return cpunum_get_reg( 0, SM8500_P2C ); |
| 387 | | case SM8521_P3C: return cpunum_get_reg( 0, SM8500_P3C ); |
| 399 | case SM8521_IE0: return cpu_get_reg( space->machine->cpu[0], SM8500_IE0 ); |
| 400 | case SM8521_IE1: return cpu_get_reg( space->machine->cpu[0], SM8500_IE1 ); |
| 401 | case SM8521_IR0: return cpu_get_reg( space->machine->cpu[0], SM8500_IR0 ); |
| 402 | case SM8521_IR1: return cpu_get_reg( space->machine->cpu[0], SM8500_IR1 ); |
| 403 | case SM8521_P0: /* logerror( "%X: Read from P0\n", cpu_get_pc(space->cpu) ); */ return cpu_get_reg( space->machine->cpu[0], SM8500_P0 ); |
| 404 | case SM8521_P1: /* logerror( "%X: Read from P1\n", cpu_get_pc(space->cpu) ); */ return cpu_get_reg( space->machine->cpu[0], SM8500_P1 ); |
| 405 | case SM8521_P2: /* logerror( "%X: Read from P2\n", cpu_get_pc(space->cpu) ); */ return cpu_get_reg( space->machine->cpu[0], SM8500_P2 ); |
| 406 | case SM8521_P3: return cpu_get_reg( space->machine->cpu[0], SM8500_P3 ); |
| 407 | case SM8521_SYS: return cpu_get_reg( space->machine->cpu[0], SM8500_SYS ); |
| 408 | case SM8521_CKC: return cpu_get_reg( space->machine->cpu[0], SM8500_CKC ); |
| 409 | case SM8521_SPH: return cpu_get_reg( space->machine->cpu[0], SM8500_SPH ); |
| 410 | case SM8521_SPL: return cpu_get_reg( space->machine->cpu[0], SM8500_SPL ); |
| 411 | case SM8521_PS0: return cpu_get_reg( space->machine->cpu[0], SM8500_PS0 ); |
| 412 | case SM8521_PS1: return cpu_get_reg( space->machine->cpu[0], SM8500_PS1 ); |
| 413 | case SM8521_P0C: return cpu_get_reg( space->machine->cpu[0], SM8500_P0C ); |
| 414 | case SM8521_P1C: return cpu_get_reg( space->machine->cpu[0], SM8500_P1C ); |
| 415 | case SM8521_P2C: return cpu_get_reg( space->machine->cpu[0], SM8500_P2C ); |
| 416 | case SM8521_P3C: return cpu_get_reg( space->machine->cpu[0], SM8500_P3C ); |
| 388 | 417 | case SM8521_TM0D: return gamecom_timer[0].counter; |
| 389 | 418 | case SM8521_TM1D: return gamecom_timer[1].counter; |
| 390 | 419 | // case SM8521_CLKT: /* bit 0-5 read only, 6-7 read/write */ |
| r3658 | r3659 | |
| 399 | 428 | case SM8521_55: case SM8521_56: case SM8521_57: case SM8521_58: |
| 400 | 429 | case SM8521_59: case SM8521_5A: case SM8521_5B: case SM8521_5C: |
| 401 | 430 | case SM8521_5D: |
| 402 | | // logerror( "%X: Read from reserved address (0x%02X)\n", activecpu_get_pc(), offset ); |
| 431 | // logerror( "%X: Read from reserved address (0x%02X)\n", cpu_get_pc(space->cpu), offset ); |
| 403 | 432 | break; |
| 404 | 433 | |
| 405 | 434 | } |
| r3658 | r3659 | |
| 408 | 437 | |
| 409 | 438 | /* The manual is not conclusive as to which bit of the DMVP register (offset 0x3D) determines |
| 410 | 439 | which page for source or destination is used */ |
| 411 | | static void gamecom_dma_init(running_machine *machine) { |
| 412 | | if ( gamecom_dma.decrement_x || gamecom_dma.decrement_y ) { |
| 440 | static void gamecom_dma_init(running_machine *machine) |
| 441 | { |
| 442 | if ( gamecom_dma.decrement_x || gamecom_dma.decrement_y ) |
| 443 | { |
| 413 | 444 | logerror( "TODO: Decrement-x and decrement-y are not supported yet\n" ); |
| 414 | 445 | } |
| 415 | 446 | gamecom_dma.width_x = internal_registers[SM8521_DMDX]; |
| r3658 | r3659 | |
| 432 | 463 | gamecom_dma.dest_mask = 0x1FFF; |
| 433 | 464 | // logerror("DMA: width %Xx%X, source (%X,%X), dest (%X,%X), transfer_mode %X, banks %X \n", gamecom_dma.width_x, gamecom_dma.width_y, gamecom_dma.source_x, gamecom_dma.source_y, gamecom_dma.dest_x, gamecom_dma.dest_y, gamecom_dma.transfer_mode, internal_registers[SM8521_DMVP] ); |
| 434 | 465 | // logerror( " Palette: %d, %d, %d, %d\n", gamecom_dma.palette[0], gamecom_dma.palette[1], gamecom_dma.palette[2], gamecom_dma.palette[3] ); |
| 435 | | switch( gamecom_dma.transfer_mode ) { |
| 466 | switch( gamecom_dma.transfer_mode ) |
| 467 | { |
| 436 | 468 | case 0x00: |
| 437 | 469 | /* VRAM->VRAM */ |
| 438 | 470 | gamecom_dma.source_bank = &gamecom_vram[(internal_registers[SM8521_DMVP] & 0x01) ? 0x2000 : 0x0000]; |
| r3658 | r3659 | |
| 442 | 474 | /* ROM->VRAM */ |
| 443 | 475 | // logerror( "DMA DMBR = %X\n", internal_registers[SM8521_DMBR] ); |
| 444 | 476 | gamecom_dma.source_width = 64; |
| 445 | | if ( internal_registers[SM8521_DMBR] < 16 ) { |
| 477 | if ( internal_registers[SM8521_DMBR] < 16 ) |
| 478 | { |
| 446 | 479 | gamecom_dma.source_bank = memory_region(machine, "user1") + (internal_registers[SM8521_DMBR] << 14); |
| 447 | 480 | gamecom_dma.source_mask = 0x3FFF; |
| 448 | | } else { |
| 481 | } |
| 482 | else |
| 483 | { |
| 449 | 484 | logerror( "TODO: Reading from external ROMs not supported yet\n" ); |
| 450 | 485 | gamecom_dma.source_bank = memory_region(machine, "user1"); |
| 451 | 486 | } |
| r3658 | r3659 | |
| 454 | 489 | case 0x04: |
| 455 | 490 | /* Extend RAM->VRAM */ |
| 456 | 491 | gamecom_dma.source_width = 64; |
| 457 | | gamecom_dma.source_bank = memory_get_read_ptr(0, ADDRESS_SPACE_PROGRAM, 0xE000 ); |
| 492 | gamecom_dma.source_bank = memory_get_read_ptr(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xE000 ); |
| 458 | 493 | gamecom_dma.dest_bank = &gamecom_vram[(internal_registers[SM8521_DMVP] & 0x02) ? 0x2000 : 0x0000]; |
| 459 | 494 | break; |
| 460 | 495 | case 0x06: |
| 461 | 496 | /* VRAM->Extend RAM */ |
| 462 | 497 | gamecom_dma.source_bank = &gamecom_vram[(internal_registers[SM8521_DMVP] & 0x01) ? 0x2000 : 0x0000]; |
| 463 | 498 | gamecom_dma.dest_width = 64; |
| 464 | | gamecom_dma.dest_bank = memory_get_read_ptr(0, ADDRESS_SPACE_PROGRAM, 0xE000 ); |
| 499 | gamecom_dma.dest_bank = memory_get_read_ptr(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xE000 ); |
| 465 | 500 | break; |
| 466 | 501 | } |
| 467 | 502 | gamecom_dma.source_current = gamecom_dma.source_width * gamecom_dma.source_y; |
| r3658 | r3659 | |
| 477 | 512 | Their usage is also not explained properly in the manuals. Guess we'll have to wait |
| 478 | 513 | for them to show up in some rom images... |
| 479 | 514 | */ |
| 480 | | void gamecom_handle_dma( int cycles ) { |
| 515 | void gamecom_handle_dma( int cycles ) |
| 516 | { |
| 481 | 517 | unsigned y_count, x_count; |
| 482 | 518 | /* If not enabled, ignore */ |
| 483 | | if ( ! gamecom_dma.enabled ) { |
| 519 | if ( ! gamecom_dma.enabled ) |
| 520 | { |
| 484 | 521 | return; |
| 485 | 522 | } |
| 486 | | for( y_count = 0; y_count <= gamecom_dma.width_y; y_count++ ) { |
| 487 | | for( x_count = 0; x_count <= gamecom_dma.width_x; x_count++ ) { |
| 523 | for( y_count = 0; y_count <= gamecom_dma.width_y; y_count++ ) |
| 524 | { |
| 525 | for( x_count = 0; x_count <= gamecom_dma.width_x; x_count++ ) |
| 526 | { |
| 488 | 527 | int source_pixel = 0; |
| 489 | 528 | int dest_pixel = 0; |
| 490 | 529 | int src_addr = gamecom_dma.source_current & gamecom_dma.source_mask; |
| 491 | 530 | int dest_addr = gamecom_dma.dest_current & gamecom_dma.dest_mask; |
| 492 | 531 | /* handle DMA for 1 pixel */ |
| 493 | 532 | /* Read pixel data */ |
| 494 | | switch ( gamecom_dma.source_x_current & 0x03 ) { |
| 533 | switch ( gamecom_dma.source_x_current & 0x03 ) |
| 534 | { |
| 495 | 535 | case 0x00: source_pixel = ( gamecom_dma.source_bank[src_addr] & 0xC0 ) >> 6; break; |
| 496 | 536 | case 0x01: source_pixel = ( gamecom_dma.source_bank[src_addr] & 0x30 ) >> 4; break; |
| 497 | 537 | case 0x02: source_pixel = ( gamecom_dma.source_bank[src_addr] & 0x0C ) >> 2; break; |
| 498 | 538 | case 0x03: source_pixel = ( gamecom_dma.source_bank[src_addr] & 0x03 ); break; |
| 499 | 539 | } |
| 500 | 540 | |
| 501 | | if ( !gamecom_dma.overwrite_mode && source_pixel == 0 ) { |
| 502 | | switch ( gamecom_dma.dest_x_current & 0x03 ) { |
| 541 | if ( !gamecom_dma.overwrite_mode && source_pixel == 0 ) |
| 542 | { |
| 543 | switch ( gamecom_dma.dest_x_current & 0x03 ) |
| 544 | { |
| 503 | 545 | case 0x00: dest_pixel = ( gamecom_dma.dest_bank[dest_addr] & 0xC0 ) >> 6; break; |
| 504 | 546 | case 0x01: dest_pixel = ( gamecom_dma.dest_bank[dest_addr] & 0x30 ) >> 4; break; |
| 505 | 547 | case 0x02: dest_pixel = ( gamecom_dma.dest_bank[dest_addr] & 0x0C ) >> 2; break; |
| r3658 | r3659 | |
| 512 | 554 | /* Not sure if this should be done before the compound stuff - WP */ |
| 513 | 555 | source_pixel = gamecom_dma.palette[ source_pixel ]; |
| 514 | 556 | /* Write pixel data */ |
| 515 | | switch( gamecom_dma.dest_x_current & 0x03 ) { |
| 557 | switch( gamecom_dma.dest_x_current & 0x03 ) |
| 558 | { |
| 516 | 559 | case 0x00: |
| 517 | 560 | gamecom_dma.dest_bank[dest_addr] = ( gamecom_dma.dest_bank[dest_addr] & 0x3F ) | ( source_pixel << 6 ); |
| 518 | 561 | break; |
| r3658 | r3659 | |
| 528 | 571 | } |
| 529 | 572 | |
| 530 | 573 | /* Advance a pixel */ |
| 531 | | if ( gamecom_dma.decrement_x ) { |
| 574 | if ( gamecom_dma.decrement_x ) |
| 575 | { |
| 532 | 576 | gamecom_dma.source_x_current--; |
| 533 | | if ( ( gamecom_dma.source_x_current & 0x03 ) == 0x03 ) { |
| 577 | if ( ( gamecom_dma.source_x_current & 0x03 ) == 0x03 ) |
| 578 | { |
| 534 | 579 | gamecom_dma.source_current--; |
| 535 | 580 | } |
| 536 | | } else { |
| 581 | } |
| 582 | else |
| 583 | { |
| 537 | 584 | gamecom_dma.source_x_current++; |
| 538 | | if ( ( gamecom_dma.source_x_current & 0x03 ) == 0x00 ) { |
| 585 | if ( ( gamecom_dma.source_x_current & 0x03 ) == 0x00 ) |
| 586 | { |
| 539 | 587 | gamecom_dma.source_current++; |
| 540 | 588 | } |
| 541 | 589 | } |
| 542 | 590 | gamecom_dma.dest_x_current++; |
| 543 | | if ( ( gamecom_dma.dest_x_current & 0x03 ) == 0x00 ) { |
| 591 | if ( ( gamecom_dma.dest_x_current & 0x03 ) == 0x00 ) |
| 592 | { |
| 544 | 593 | gamecom_dma.dest_current++; |
| 545 | 594 | } |
| 546 | 595 | } |
| r3658 | r3659 | |
| 557 | 606 | cpu_set_input_line(Machine->cpu[0], DMA_INT, HOLD_LINE ); |
| 558 | 607 | } |
| 559 | 608 | |
| 560 | | void gamecom_update_timers( int cycles ) { |
| 561 | | if ( gamecom_timer[0].enabled ) { |
| 609 | void gamecom_update_timers( int cycles ) |
| 610 | { |
| 611 | if ( gamecom_timer[0].enabled ) |
| 612 | { |
| 562 | 613 | gamecom_timer[0].state_count += cycles; |
| 563 | | while ( gamecom_timer[0].state_count >= gamecom_timer[0].state_limit ) { |
| 614 | while ( gamecom_timer[0].state_count >= gamecom_timer[0].state_limit ) |
| 615 | { |
| 564 | 616 | gamecom_timer[0].state_count -= gamecom_timer[0].state_limit; |
| 565 | 617 | gamecom_timer[0].counter++; |
| 566 | | if ( gamecom_timer[0].counter == gamecom_timer[0].check_value ) { |
| 618 | if ( gamecom_timer[0].counter == gamecom_timer[0].check_value ) |
| 619 | { |
| 567 | 620 | gamecom_timer[0].counter = 0; |
| 568 | 621 | cpu_set_input_line(Machine->cpu[0], TIM0_INT, HOLD_LINE ); |
| 569 | 622 | } |
| 570 | 623 | } |
| 571 | 624 | } |
| 572 | | if ( gamecom_timer[1].enabled ) { |
| 625 | if ( gamecom_timer[1].enabled ) |
| 626 | { |
| 573 | 627 | gamecom_timer[1].state_count += cycles; |
| 574 | | while ( gamecom_timer[1].state_count >= gamecom_timer[1].state_limit ) { |
| 628 | while ( gamecom_timer[1].state_count >= gamecom_timer[1].state_limit ) |
| 629 | { |
| 575 | 630 | gamecom_timer[1].state_count -= gamecom_timer[1].state_limit; |
| 576 | 631 | gamecom_timer[1].counter++; |
| 577 | | if ( gamecom_timer[1].counter == gamecom_timer[1].check_value ) { |
| 632 | if ( gamecom_timer[1].counter == gamecom_timer[1].check_value ) |
| 633 | { |
| 578 | 634 | gamecom_timer[1].counter = 0; |
| 579 | 635 | cpu_set_input_line(Machine->cpu[0], TIM1_INT, HOLD_LINE ); |
| 580 | 636 | } |
| r3658 | r3659 | |
| 582 | 638 | } |
| 583 | 639 | } |
| 584 | 640 | |
| 585 | | WRITE8_HANDLER( gamecom_vram_w ) { |
| 641 | WRITE8_HANDLER( gamecom_vram_w ) |
| 642 | { |
| 586 | 643 | gamecom_vram[offset] = data; |
| 587 | 644 | } |
| 588 | 645 | |
| 589 | | READ8_HANDLER( gamecom_vram_r ) { |
| 646 | READ8_HANDLER( gamecom_vram_r ) |
| 647 | { |
| 590 | 648 | return gamecom_vram[offset]; |
| 591 | 649 | } |
| 592 | 650 | |
| r3658 | r3659 | |
| 602 | 660 | int load_offset = 0; |
| 603 | 661 | |
| 604 | 662 | /* allocate memory on first load of a cartridge */ |
| 605 | | if ( cartridge1 == NULL ) { |
| 663 | if ( cartridge1 == NULL ) |
| 664 | { |
| 606 | 665 | cartridge1 = auto_malloc( 2048 * 1024 ); |
| 607 | 666 | } |
| 608 | 667 | filesize = image_length( image ); |
| 609 | | switch( filesize ) { |
| 668 | switch( filesize ) |
| 669 | { |
| 610 | 670 | case 0x008000: load_offset = 0; break; /* 32 KB */ |
| 611 | 671 | case 0x040000: load_offset = 0; break; /* 256KB */ |
| 612 | 672 | case 0x080000: load_offset = 0; break; /* 512KB */ |
| r3658 | r3659 | |
| 617 | 677 | logerror( "Error loading cartridge: Invalid file size.\n" ); |
| 618 | 678 | return INIT_FAIL; |
| 619 | 679 | } |
| 620 | | if ( image_fread( image, cartridge1 + load_offset, filesize ) != filesize ) { |
| 680 | if ( image_fread( image, cartridge1 + load_offset, filesize ) != filesize ) |
| 681 | { |
| 621 | 682 | logerror( "Error loading cartridge: Unable to read from file: %s.\n", image_filename(image) ); |
| 622 | 683 | return INIT_FAIL; |
| 623 | 684 | } |
src/mess/machine/thomson.c
| r3658 | r3659 | |
| 105 | 105 | /* hack, feed existing bits */ |
| 106 | 106 | if ( bitpos >= to7_k7_bitsize ) |
| 107 | 107 | bitpos = to7_k7_bitsize -1; |
| 108 | | VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i\n", |
| 109 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), state, pos, bitpos, |
| 110 | | to7_k7_bits[ bitpos ] )); |
| 108 | // VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i\n", |
| 109 | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), state, pos, bitpos, |
| 110 | // to7_k7_bits[ bitpos ] )); |
| 111 | 111 | return to7_k7_bits[ bitpos ]; |
| 112 | 112 | } |
| 113 | 113 | else |
| r3658 | r3659 | |
| 126 | 126 | chg++; |
| 127 | 127 | } |
| 128 | 128 | k = ( chg >= 13 ) ? 1 : 0; |
| 129 | | VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i (%i)\n", |
| 130 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), state, pos, bitpos, |
| 131 | | k, chg )); |
| 129 | // VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i (%i)\n", |
| 130 | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), state, pos, bitpos, |
| 131 | // k, chg )); |
| 132 | 132 | return k; |
| 133 | 133 | } |
| 134 | 134 | |
| r3658 | r3659 | |
| 150 | 150 | |
| 151 | 151 | static WRITE8_HANDLER ( to7_set_cassette_motor ) |
| 152 | 152 | { |
| 153 | | const device_config* img = thom_cassette_img(machine); |
| 153 | const device_config* img = thom_cassette_img(space->machine); |
| 154 | 154 | cassette_state state = cassette_get_state( img ); |
| 155 | 155 | double pos = cassette_get_position(img); |
| 156 | 156 | |
| 157 | 157 | LOG (( "$%04x %f to7_set_cassette_motor: cassette motor %s bitpos=%i\n", |
| 158 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ? "off" : "on", |
| 158 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ? "off" : "on", |
| 159 | 159 | (int) (pos / TO7_BIT_LENGTH) )); |
| 160 | 160 | |
| 161 | 161 | if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED && !data && pos > 0.3 ) |
| r3658 | r3659 | |
| 204 | 204 | cassette_get_sample( cass, 0, pos, 0, &hbit ); |
| 205 | 205 | hbit = hbit >= 0; |
| 206 | 206 | |
| 207 | | VLOG (( "$%04x %f mo5_get_cassette: state=$%X pos=%f hbitpos=%i hbit=%i\n", |
| 208 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), state, pos, |
| 209 | | (int) (pos / MO5_HBIT_LENGTH), hbit )); |
| 207 | // VLOG (( "$%04x %f mo5_get_cassette: state=$%X pos=%f hbitpos=%i hbit=%i\n", |
| 208 | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), state, pos, |
| 209 | // (int) (pos / MO5_HBIT_LENGTH), hbit )); |
| 210 | 210 | return hbit; |
| 211 | 211 | } |
| 212 | 212 | else |
| r3658 | r3659 | |
| 225 | 225 | |
| 226 | 226 | static WRITE8_HANDLER ( mo5_set_cassette_motor ) |
| 227 | 227 | { |
| 228 | | const device_config* img = thom_cassette_img(machine); |
| 228 | const device_config* img = thom_cassette_img(space->machine); |
| 229 | 229 | cassette_state state = cassette_get_state( img ); |
| 230 | 230 | double pos = cassette_get_position(img); |
| 231 | 231 | |
| 232 | 232 | LOG (( "$%04x %f mo5_set_cassette_motor: cassette motor %s hbitpos=%i\n", |
| 233 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ? "off" : "on", |
| 233 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ? "off" : "on", |
| 234 | 234 | (int) (pos / MO5_HBIT_LENGTH) )); |
| 235 | 235 | |
| 236 | 236 | if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED && !data && pos > 0.3 ) |
| r3658 | r3659 | |
| 514 | 514 | if ( thom_cart_nb_banks ) |
| 515 | 515 | { |
| 516 | 516 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 517 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 517 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | if ( bank != old_bank ) |
| 521 | 521 | LOG_BANK(( "to7_update_cart_bank: CART is cartridge bank %i\n", bank )); |
| 522 | 522 | |
| 523 | | memory_set_bank( THOM_CART_BANK, bank ); |
| 523 | memory_set_bank( machine, THOM_CART_BANK, bank ); |
| 524 | 524 | old_bank = bank; |
| 525 | 525 | } |
| 526 | 526 | |
| r3658 | r3659 | |
| 540 | 540 | return; |
| 541 | 541 | |
| 542 | 542 | thom_cart_bank = offset & 3; |
| 543 | | to7_update_cart_bank(machine); |
| 543 | to7_update_cart_bank(space->machine); |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | |
| r3658 | r3659 | |
| 548 | 548 | /* read signal to 0000-0003 generates a bank switch */ |
| 549 | 549 | READ8_HANDLER ( to7_cartridge_r ) |
| 550 | 550 | { |
| 551 | | UINT8* pos = memory_region( machine, "main" ) + 0x10000; |
| 551 | UINT8* pos = memory_region( space->machine, "main" ) + 0x10000; |
| 552 | 552 | UINT8 data = pos[offset + (thom_cart_bank % thom_cart_nb_banks) * 0x4000]; |
| 553 | 553 | thom_cart_bank = offset & 3; |
| 554 | | to7_update_cart_bank(machine); |
| 554 | to7_update_cart_bank(space->machine); |
| 555 | 555 | return data; |
| 556 | 556 | } |
| 557 | 557 | |
| r3658 | r3659 | |
| 563 | 563 | |
| 564 | 564 | static WRITE8_HANDLER ( to7_timer_port_out ) |
| 565 | 565 | { |
| 566 | | thom_set_mode_point( data & 1 ); /* bit 0: video bank switch */ |
| 566 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 567 | 567 | thom_set_caps_led( (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */ |
| 568 | 568 | thom_set_border_color( ((data & 0x10) ? 1 : 0) | /* bits 4-6: border color */ |
| 569 | 569 | ((data & 0x20) ? 2 : 0) | |
| r3658 | r3659 | |
| 581 | 581 | |
| 582 | 582 | static READ8_HANDLER ( to7_timer_port_in ) |
| 583 | 583 | { |
| 584 | | int lightpen = (input_port_read(machine, "lightpen_button") & 1) ? 2 : 0; |
| 585 | | int cass = to7_get_cassette(machine) ? 0x80 : 0; |
| 584 | int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0; |
| 585 | int cass = to7_get_cassette(space->machine) ? 0x80 : 0; |
| 586 | 586 | return lightpen | cass; |
| 587 | 587 | } |
| 588 | 588 | |
| r3658 | r3659 | |
| 591 | 591 | static WRITE8_HANDLER ( to7_timer_tco_out ) |
| 592 | 592 | { |
| 593 | 593 | /* 1-bit cassette output */ |
| 594 | | to7_set_cassette( machine, data ); |
| 594 | to7_set_cassette( space->machine, data ); |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | |
| r3658 | r3659 | |
| 669 | 669 | if ( to7_lightpen ) |
| 670 | 670 | { |
| 671 | 671 | /* lightpen hi */ |
| 672 | | return to7_lightpen_gpl( machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step ) >> 8; |
| 672 | return to7_lightpen_gpl( space->machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step ) >> 8; |
| 673 | 673 | } |
| 674 | 674 | else |
| 675 | 675 | { |
| r3658 | r3659 | |
| 683 | 683 | for ( i = 0; i < 8; i++ ) |
| 684 | 684 | { |
| 685 | 685 | if ( ! (keyline & (1 << i)) ) |
| 686 | | val &= input_port_read(machine, keynames[i]); |
| 686 | val &= input_port_read(space->machine, keynames[i]); |
| 687 | 687 | } |
| 688 | 688 | return val; |
| 689 | 689 | } |
| r3658 | r3659 | |
| 694 | 694 | static READ8_HANDLER ( to7_sys_portb_in ) |
| 695 | 695 | { |
| 696 | 696 | /* lightpen low */ |
| 697 | | return to7_lightpen_gpl( machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step ) & 0xff; |
| 697 | return to7_lightpen_gpl( space->machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step ) & 0xff; |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | |
| r3658 | r3659 | |
| 764 | 764 | int tx = data & 1; |
| 765 | 765 | int dtr = ( data & 2 ) ? 1 : 0; |
| 766 | 766 | |
| 767 | | LOG_IO(( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), tx, dtr )); |
| 767 | LOG_IO(( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), tx, dtr )); |
| 768 | 768 | if ( dtr ) |
| 769 | 769 | to7_io_line.State |= SERIAL_STATE_DTR; |
| 770 | 770 | else |
| r3658 | r3659 | |
| 782 | 782 | int dsr = ( to7_io_line.input_state & SERIAL_STATE_DSR ) ? 0 : 1; |
| 783 | 783 | int rd = get_in_data_bit( to7_io_line.input_state ); |
| 784 | 784 | |
| 785 | | if ( to7_io_mode(machine) == TO7_IO_RS232 ) |
| 785 | if ( to7_io_mode(space->machine) == TO7_IO_RS232 ) |
| 786 | 786 | cts = to7_io_line.input_state & SERIAL_STATE_CTS ? 0 : 1; |
| 787 | 787 | else |
| 788 | 788 | cts = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 1 : 0; |
| 789 | 789 | |
| 790 | | LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_io_mode(machine), cts, dsr, rd )); |
| 790 | LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), to7_io_mode(space->machine), cts, dsr, rd )); |
| 791 | 791 | |
| 792 | 792 | return (dsr ? 0x20 : 0) | (cts ? 0x40 : 0) | (rd ? 0x80: 0); |
| 793 | 793 | } |
| r3658 | r3659 | |
| 798 | 798 | { |
| 799 | 799 | /* set 8-bit data */ |
| 800 | 800 | |
| 801 | | LOG_IO(( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 801 | LOG_IO(( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data )); |
| 802 | 802 | |
| 803 | 803 | centronics_write_data( 0, data ); |
| 804 | 804 | } |
| r3658 | r3659 | |
| 809 | 809 | { |
| 810 | 810 | /* send STROBE to printer */ |
| 811 | 811 | |
| 812 | | LOG_IO(( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 812 | LOG_IO(( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data )); |
| 813 | 813 | |
| 814 | 814 | centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE ); |
| 815 | 815 | } |
| r3658 | r3659 | |
| 975 | 975 | |
| 976 | 976 | READ8_HANDLER ( to7_modem_mea8000_r ) |
| 977 | 977 | { |
| 978 | | if ( input_port_read(machine, "mconfig") & 1 ) |
| 979 | | return mea8000_r( machine, offset ); |
| 978 | if ( input_port_read(space->machine, "mconfig") & 1 ) |
| 979 | return mea8000_r( space, offset ); |
| 980 | 980 | else |
| 981 | 981 | { |
| 982 | 982 | switch ( offset ) { |
| 983 | | case 0: return acia6850_0_stat_r( machine, 0 ); |
| 984 | | case 1: return acia6850_0_data_r( machine, 0 ); |
| 983 | case 0: return acia6850_0_stat_r( space, 0 ); |
| 984 | case 1: return acia6850_0_data_r( space, 0 ); |
| 985 | 985 | default: return 0; |
| 986 | 986 | } |
| 987 | 987 | } |
| r3658 | r3659 | |
| 991 | 991 | |
| 992 | 992 | WRITE8_HANDLER ( to7_modem_mea8000_w ) |
| 993 | 993 | { |
| 994 | | if ( input_port_read(machine, "mconfig") & 1 ) |
| 995 | | mea8000_w( machine, offset, data ); |
| 994 | if ( input_port_read(space->machine, "mconfig") & 1 ) |
| 995 | mea8000_w( space, offset, data ); |
| 996 | 996 | else |
| 997 | 997 | { |
| 998 | 998 | switch ( offset ) { |
| 999 | | case 0: acia6850_0_ctrl_w( machine, 0, data ); break; |
| 1000 | | case 1: acia6850_0_data_w( machine, 0, data ); break; |
| 999 | case 0: acia6850_0_ctrl_w( space, 0, data ); break; |
| 1000 | case 1: acia6850_0_data_w( space, 0, data ); break; |
| 1001 | 1001 | } |
| 1002 | 1002 | } |
| 1003 | 1003 | } |
| r3658 | r3659 | |
| 1060 | 1060 | static READ8_HANDLER ( to7_game_porta_in ) |
| 1061 | 1061 | { |
| 1062 | 1062 | UINT8 data; |
| 1063 | | if ( input_port_read(machine, "config") & 1 ) |
| 1063 | if ( input_port_read(space->machine, "config") & 1 ) |
| 1064 | 1064 | { |
| 1065 | 1065 | /* mouse */ |
| 1066 | | data = to7_get_mouse_signal(machine) & 0x0c; /* XB, YB */ |
| 1067 | | data |= input_port_read(machine, "mouse_button") & 3; /* buttons */ |
| 1066 | data = to7_get_mouse_signal(space->machine) & 0x0c; /* XB, YB */ |
| 1067 | data |= input_port_read(space->machine, "mouse_button") & 3; /* buttons */ |
| 1068 | 1068 | } |
| 1069 | 1069 | else |
| 1070 | 1070 | { |
| 1071 | 1071 | /* joystick */ |
| 1072 | | data = input_port_read(machine, "game_port_directions"); |
| 1072 | data = input_port_read(space->machine, "game_port_directions"); |
| 1073 | 1073 | /* bit 0=0 => P1 up bit 4=0 => P2 up |
| 1074 | 1074 | bit 1=0 => P1 down bit 5=0 => P2 down |
| 1075 | 1075 | bit 2=0 => P1 left bit 6=0 => P2 left |
| r3658 | r3659 | |
| 1101 | 1101 | static READ8_HANDLER ( to7_game_portb_in ) |
| 1102 | 1102 | { |
| 1103 | 1103 | UINT8 data; |
| 1104 | | if ( input_port_read(machine, "config") & 1 ) |
| 1104 | if ( input_port_read(space->machine, "config") & 1 ) |
| 1105 | 1105 | { |
| 1106 | 1106 | /* mouse */ |
| 1107 | | UINT8 mouse = to7_get_mouse_signal(machine); |
| 1107 | UINT8 mouse = to7_get_mouse_signal(space->machine); |
| 1108 | 1108 | data = 0; |
| 1109 | 1109 | if ( mouse & 1 ) |
| 1110 | 1110 | data |= 0x04; /* XA */ |
| r3658 | r3659 | |
| 1118 | 1118 | /* bits 2-3: action buttons B (0=pressed) */ |
| 1119 | 1119 | /* bits 4-5: unused (ouput) */ |
| 1120 | 1120 | /* bits 0-1: unknown! */ |
| 1121 | | data = input_port_read(machine, "game_port_buttons"); |
| 1121 | data = input_port_read(space->machine, "game_port_buttons"); |
| 1122 | 1122 | } |
| 1123 | 1123 | return data; |
| 1124 | 1124 | } |
| r3658 | r3659 | |
| 1295 | 1295 | /* bit 6: parity error (ignored) */ |
| 1296 | 1296 | /* bit 7: interrupt */ |
| 1297 | 1297 | LOG_MIDI(( "$%04x %f to7_midi_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, irq=%i)\n", |
| 1298 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_midi_status, |
| 1298 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), to7_midi_status, |
| 1299 | 1299 | (to7_midi_status & ACIA_6850_RDRF) ? 1 : 0, |
| 1300 | 1300 | (to7_midi_status & ACIA_6850_TDRE) ? 1 : 0, |
| 1301 | 1301 | (to7_midi_status & ACIA_6850_OVRN) ? 1 : 0, |
| r3658 | r3659 | |
| 1313 | 1313 | to7_midi_status &= ~ACIA_6850_OVRN; |
| 1314 | 1314 | to7_midi_overrun = 0; |
| 1315 | 1315 | LOG_MIDI(( "$%04x %f to7_midi_r: read data $%02X\n", |
| 1316 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 1316 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data )); |
| 1317 | 1317 | to7_midi_update_irq(); |
| 1318 | 1318 | return data; |
| 1319 | 1319 | } |
| r3658 | r3659 | |
| 1321 | 1321 | |
| 1322 | 1322 | default: |
| 1323 | 1323 | logerror( "$%04x to7_midi_r: invalid offset %i\n", |
| 1324 | | activecpu_get_previouspc(), offset ); |
| 1324 | cpu_get_previouspc(space->cpu), offset ); |
| 1325 | 1325 | return 0; |
| 1326 | 1326 | } |
| 1327 | 1327 | } |
| r3658 | r3659 | |
| 1340 | 1340 | if ( (data & 3) == 3 ) |
| 1341 | 1341 | { |
| 1342 | 1342 | /* reset */ |
| 1343 | | LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 1343 | LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data )); |
| 1344 | 1344 | to7_midi_overrun = 0; |
| 1345 | 1345 | to7_midi_status = 2; |
| 1346 | 1346 | to7_midi_intr = 0; |
| r3658 | r3659 | |
| 1357 | 1357 | static const int stop[8] = { 2,2,1,1,2,1,1,1 }; |
| 1358 | 1358 | static const char parity[8] = { 'e','o','e','o','-','-','e','o' }; |
| 1359 | 1359 | LOG_MIDI(( "$%04x %f to7_midi_w: set control to $%02X (bits=%i, stop=%i, parity=%c, intr in=%i out=%i)\n", |
| 1360 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 1360 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), |
| 1361 | 1361 | data, |
| 1362 | 1362 | bits[ (data >> 2) & 7 ], |
| 1363 | 1363 | stop[ (data >> 2) & 7 ], |
| r3658 | r3659 | |
| 1371 | 1371 | |
| 1372 | 1372 | |
| 1373 | 1373 | case 1: /* output data */ |
| 1374 | | LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 1374 | LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data )); |
| 1375 | 1375 | if ( data == 0x55 ) |
| 1376 | 1376 | /* cable-detect: shortcut */ |
| 1377 | 1377 | chardev_fake_in( to7_midi_chardev, 0x55 ); |
| r3658 | r3659 | |
| 1385 | 1385 | |
| 1386 | 1386 | |
| 1387 | 1387 | default: |
| 1388 | | logerror( "$%04x to7_midi_w: invalid offset %i (data=$%02X) \n", activecpu_get_previouspc(), offset, data ); |
| 1388 | logerror( "$%04x to7_midi_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc(space->cpu), offset, data ); |
| 1389 | 1389 | } |
| 1390 | 1390 | } |
| 1391 | 1391 | |
| r3658 | r3659 | |
| 1482 | 1482 | thom_set_video_mode( THOM_VMODE_TO770 ); |
| 1483 | 1483 | thom_set_init_callback( to7_set_init ); |
| 1484 | 1484 | thom_set_lightpen_callback( 3, to7_lightpen_cb ); |
| 1485 | | thom_set_mode_point( 0 ); |
| 1485 | thom_set_mode_point( machine, 0 ); |
| 1486 | 1486 | thom_set_border_color( 0 ); |
| 1487 | 1487 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 1488 | 1488 | |
| r3658 | r3659 | |
| 1517 | 1517 | /* memory */ |
| 1518 | 1518 | thom_cart_bank = 0; |
| 1519 | 1519 | thom_vram = mess_ram; |
| 1520 | | memory_configure_bank( THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x2000 ); |
| 1521 | | memory_configure_bank( THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 ); |
| 1522 | | memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 1523 | | memory_set_bank( THOM_BASE_BANK, 0 ); |
| 1524 | | memory_set_bank( THOM_VRAM_BANK, 0 ); |
| 1525 | | memory_set_bank( THOM_CART_BANK, 0 ); |
| 1520 | memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x2000 ); |
| 1521 | memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 ); |
| 1522 | memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 1523 | memory_set_bank( machine, THOM_BASE_BANK, 0 ); |
| 1524 | memory_set_bank( machine, THOM_VRAM_BANK, 0 ); |
| 1525 | memory_set_bank( machine, THOM_CART_BANK, 0 ); |
| 1526 | 1526 | |
| 1527 | 1527 | if ( mess_ram_size > 24*1024 ) |
| 1528 | 1528 | { |
| 1529 | 1529 | /* install 16 KB or 16 KB + 8 KB memory extensions */ |
| 1530 | 1530 | /* BASIC instruction to see free memory: ?FRE(0) */ |
| 1531 | 1531 | int extram = mess_ram_size - 24*1024; |
| 1532 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x8000 + extram - 1, 0, 0, |
| 1533 | | (write8_machine_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1534 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x8000 + extram - 1, 0, 0, |
| 1535 | | (read8_machine_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1536 | | memory_configure_bank( THOM_RAM_BANK, 0, 1, mess_ram + 0x6000, extram ); |
| 1537 | | memory_set_bank( THOM_RAM_BANK, 0 ); |
| 1532 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000 + extram - 1, 0, 0, |
| 1533 | (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1534 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000 + extram - 1, 0, 0, |
| 1535 | (read8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1536 | memory_configure_bank( machine, THOM_RAM_BANK, 0, 1, mess_ram + 0x6000, extram ); |
| 1537 | memory_set_bank( machine, THOM_RAM_BANK, 0 ); |
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | 1540 | /* force 2 topmost color bits to 1 */ |
| r3658 | r3659 | |
| 1562 | 1562 | static WRITE8_HANDLER ( to770_sys_cb2_out ) |
| 1563 | 1563 | { |
| 1564 | 1564 | /* video overlay: black pixels are transparent and show TV image underneath */ |
| 1565 | | LOG(( "$%04x to770_sys_cb2_out: video overlay %i\n", activecpu_get_previouspc(), data )); |
| 1565 | LOG(( "$%04x to770_sys_cb2_out: video overlay %i\n", cpu_get_previouspc(space->cpu), data )); |
| 1566 | 1566 | } |
| 1567 | 1567 | |
| 1568 | 1568 | |
| r3658 | r3659 | |
| 1574 | 1574 | "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" }; |
| 1575 | 1575 | int keyline = pia_get_output_b( THOM_PIA_SYS ) & 7; |
| 1576 | 1576 | |
| 1577 | | return input_port_read(machine, keynames[7 - keyline]); |
| 1577 | return input_port_read(space->machine, keynames[7 - keyline]); |
| 1578 | 1578 | } |
| 1579 | 1579 | |
| 1580 | 1580 | |
| r3658 | r3659 | |
| 1610 | 1610 | |
| 1611 | 1611 | if ( mess_ram_size == 128*1024 || bank < 2 ) |
| 1612 | 1612 | { |
| 1613 | | memory_set_bank( THOM_RAM_BANK, bank ); |
| 1614 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, (write8_machine_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1613 | memory_set_bank( machine, THOM_RAM_BANK, bank ); |
| 1614 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1615 | 1615 | } |
| 1616 | 1616 | else |
| 1617 | 1617 | { |
| 1618 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, SMH_UNMAP ); |
| 1618 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, SMH_UNMAP ); |
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | old_bank = bank; |
| r3658 | r3659 | |
| 1632 | 1632 | |
| 1633 | 1633 | static WRITE8_HANDLER ( to770_sys_portb_out ) |
| 1634 | 1634 | { |
| 1635 | | to770_update_ram_bank(machine); |
| 1635 | to770_update_ram_bank(space->machine); |
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | 1638 | |
| r3658 | r3659 | |
| 1653 | 1653 | |
| 1654 | 1654 | static WRITE8_HANDLER ( to770_timer_port_out ) |
| 1655 | 1655 | { |
| 1656 | | thom_set_mode_point( data & 1 ); /* bit 0: video bank switch */ |
| 1656 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 1657 | 1657 | thom_set_caps_led( (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */ |
| 1658 | 1658 | thom_set_border_color( ((data & 0x10) ? 1 : 0) | /* 4-bit border color */ |
| 1659 | 1659 | ((data & 0x20) ? 2 : 0) | |
| r3658 | r3659 | |
| 1679 | 1679 | READ8_HANDLER ( to770_gatearray_r ) |
| 1680 | 1680 | { |
| 1681 | 1681 | struct thom_vsignal v = thom_get_vsignal(); |
| 1682 | | struct thom_vsignal l = thom_get_lightpen_vsignal( machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 ); |
| 1682 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 ); |
| 1683 | 1683 | int count, inil, init, lt3; |
| 1684 | 1684 | count = to7_lightpen ? l.count : v.count; |
| 1685 | 1685 | inil = to7_lightpen ? l.inil : v.inil; |
| r3658 | r3659 | |
| 1693 | 1693 | case 2: return (lt3 << 7) | (inil << 6); |
| 1694 | 1694 | case 3: return (init << 7); |
| 1695 | 1695 | default: |
| 1696 | | logerror( "$%04x to770_gatearray_r: invalid offset %i\n", activecpu_get_previouspc(), offset ); |
| 1696 | logerror( "$%04x to770_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 1697 | 1697 | return 0; |
| 1698 | 1698 | } |
| 1699 | 1699 | } |
| r3658 | r3659 | |
| 1732 | 1732 | thom_set_video_mode( THOM_VMODE_TO770 ); |
| 1733 | 1733 | thom_set_init_callback( to7_set_init ); |
| 1734 | 1734 | thom_set_lightpen_callback( 3, to7_lightpen_cb ); |
| 1735 | | thom_set_mode_point( 0 ); |
| 1735 | thom_set_mode_point( machine, 0 ); |
| 1736 | 1736 | thom_set_border_color( 8 ); |
| 1737 | 1737 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 1738 | 1738 | |
| r3658 | r3659 | |
| 1768 | 1768 | /* memory */ |
| 1769 | 1769 | thom_cart_bank = 0; |
| 1770 | 1770 | thom_vram = mess_ram; |
| 1771 | | memory_configure_bank( THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 1772 | | memory_configure_bank( THOM_RAM_BANK, 0, 6, mess_ram + 0x8000, 0x4000 ); |
| 1773 | | memory_configure_bank( THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 ); |
| 1774 | | memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 1775 | | memory_set_bank( THOM_BASE_BANK, 0 ); |
| 1776 | | memory_set_bank( THOM_RAM_BANK, 0 ); |
| 1777 | | memory_set_bank( THOM_VRAM_BANK, 0 ); |
| 1778 | | memory_set_bank( THOM_CART_BANK, 0 ); |
| 1771 | memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 1772 | memory_configure_bank( machine, THOM_RAM_BANK, 0, 6, mess_ram + 0x8000, 0x4000 ); |
| 1773 | memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 ); |
| 1774 | memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 1775 | memory_set_bank( machine, THOM_BASE_BANK, 0 ); |
| 1776 | memory_set_bank( machine, THOM_RAM_BANK, 0 ); |
| 1777 | memory_set_bank( machine, THOM_VRAM_BANK, 0 ); |
| 1778 | memory_set_bank( machine, THOM_CART_BANK, 0 ); |
| 1779 | 1779 | |
| 1780 | 1780 | /* save-state */ |
| 1781 | 1781 | state_save_register_global( thom_cart_nb_banks ); |
| r3658 | r3659 | |
| 1844 | 1844 | |
| 1845 | 1845 | static WRITE8_HANDLER ( mo5_sys_porta_out ) |
| 1846 | 1846 | { |
| 1847 | | thom_set_mode_point( data & 1 ); /* bit 0: video bank switch */ |
| 1847 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 1848 | 1848 | thom_set_border_color( (data >> 1) & 15 ); /* bit 1-4: border color */ |
| 1849 | | mo5_set_cassette( machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 1849 | mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 1850 | 1850 | } |
| 1851 | 1851 | |
| 1852 | 1852 | |
| r3658 | r3659 | |
| 1854 | 1854 | static READ8_HANDLER ( mo5_sys_porta_in ) |
| 1855 | 1855 | { |
| 1856 | 1856 | return |
| 1857 | | (mo5_get_cassette(machine) ? 0x80 : 0) | /* bit 7: cassette input */ |
| 1858 | | ((input_port_read(machine, "lightpen_button") & 1) ? 0x20 : 0) |
| 1857 | (mo5_get_cassette(space->machine) ? 0x80 : 0) | /* bit 7: cassette input */ |
| 1858 | ((input_port_read(space->machine, "lightpen_button") & 1) ? 0x20 : 0) |
| 1859 | 1859 | /* bit 5: lightpen button */; |
| 1860 | 1860 | } |
| 1861 | 1861 | |
| r3658 | r3659 | |
| 1876 | 1876 | static const char *keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", |
| 1877 | 1877 | "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" }; |
| 1878 | 1878 | |
| 1879 | | return ( input_port_read(machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0; |
| 1879 | return ( input_port_read(space->machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0; |
| 1880 | 1880 | } |
| 1881 | 1881 | |
| 1882 | 1882 | |
| r3658 | r3659 | |
| 1902 | 1902 | READ8_HANDLER ( mo5_gatearray_r ) |
| 1903 | 1903 | { |
| 1904 | 1904 | struct thom_vsignal v = thom_get_vsignal(); |
| 1905 | | struct thom_vsignal l = thom_get_lightpen_vsignal( machine, MO5_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 ); |
| 1905 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, MO5_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 ); |
| 1906 | 1906 | int count, inil, init, lt3; |
| 1907 | 1907 | count = to7_lightpen ? l.count : v.count; |
| 1908 | 1908 | inil = to7_lightpen ? l.inil : v.inil; |
| r3658 | r3659 | |
| 1915 | 1915 | case 2: return (lt3 << 7) | (inil << 6); |
| 1916 | 1916 | case 3: return (init << 7); |
| 1917 | 1917 | default: |
| 1918 | | logerror( "$%04x mo5_gatearray_r: invalid offset %i\n", activecpu_get_previouspc(), offset ); |
| 1918 | logerror( "$%04x mo5_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 1919 | 1919 | return 0; |
| 1920 | 1920 | } |
| 1921 | 1921 | } |
| r3658 | r3659 | |
| 1990 | 1990 | int rom_is_ram = mo5_reg_cart & 4; |
| 1991 | 1991 | int bank = 0; |
| 1992 | 1992 | |
| 1993 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, |
| 1994 | | (read8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 1993 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, |
| 1994 | (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 1995 | 1995 | |
| 1996 | 1996 | if ( rom_is_ram && thom_cart_nb_banks == 4 ) |
| 1997 | 1997 | { |
| 1998 | 1998 | /* 64 KB ROM from "JANE" cartridge */ |
| 1999 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 1999 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 2000 | 2000 | bank = mo5_reg_cart & 3; |
| 2001 | 2001 | if ( bank != old_bank ) |
| 2002 | 2002 | LOG_BANK(( "mo5_update_cart_bank: CART is cartridge bank %i (A7CB style)\n", bank )); |
| r3658 | r3659 | |
| 2006 | 2006 | /* 64 KB RAM from network extension */ |
| 2007 | 2007 | int write_enable = mo5_reg_cart & 8; |
| 2008 | 2008 | bank = 4 + ( mo5_reg_cart & 3 ); |
| 2009 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, write_enable ? |
| 2010 | | (write8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 2009 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, write_enable ? |
| 2010 | (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 2011 | 2011 | if ( bank != old_bank ) |
| 2012 | 2012 | LOG_BANK(( "mo5_update_cart_bank: CART is nanonetwork RAM bank %i (write-enable=%i)\n", mo5_reg_cart & 3, write_enable ? 1 : 0 )); |
| 2013 | 2013 | } |
| 2014 | 2014 | else |
| 2015 | 2015 | { |
| 2016 | 2016 | /* regular cartridge bank switch */ |
| 2017 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, mo5_cartridge_w ); |
| 2017 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, mo5_cartridge_w ); |
| 2018 | 2018 | if ( thom_cart_nb_banks ) |
| 2019 | 2019 | { |
| 2020 | 2020 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 2021 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xbffc, 0xbfff, 0, 0, mo5_cartridge_r ); |
| 2021 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xbffc, 0xbfff, 0, 0, mo5_cartridge_r ); |
| 2022 | 2022 | } |
| 2023 | 2023 | if ( bank != old_bank ) |
| 2024 | 2024 | LOG_BANK(( "mo5_update_cart_bank: CART is internal / cartridge bank %i\n", thom_cart_bank )); |
| 2025 | 2025 | } |
| 2026 | | memory_set_bank( THOM_CART_BANK, bank ); |
| 2026 | memory_set_bank( machine, THOM_CART_BANK, bank ); |
| 2027 | 2027 | old_bank = bank; |
| 2028 | 2028 | } |
| 2029 | 2029 | |
| r3658 | r3659 | |
| 2043 | 2043 | return; |
| 2044 | 2044 | |
| 2045 | 2045 | thom_cart_bank = offset & 3; |
| 2046 | | mo5_update_cart_bank(machine); |
| 2046 | mo5_update_cart_bank(space->machine); |
| 2047 | 2047 | } |
| 2048 | 2048 | |
| 2049 | 2049 | |
| r3658 | r3659 | |
| 2051 | 2051 | /* read signal to bffc-bfff generates a bank switch */ |
| 2052 | 2052 | READ8_HANDLER ( mo5_cartridge_r ) |
| 2053 | 2053 | { |
| 2054 | | UINT8* pos = memory_region( machine, "main" ) + 0x10000; |
| 2054 | UINT8* pos = memory_region( space->machine, "main" ) + 0x10000; |
| 2055 | 2055 | UINT8 data = pos[offset + 0xbffc + (thom_cart_bank % thom_cart_nb_banks) * 0x4000]; |
| 2056 | 2056 | thom_cart_bank = offset & 3; |
| 2057 | | mo5_update_cart_bank(machine); |
| 2057 | mo5_update_cart_bank(space->machine); |
| 2058 | 2058 | return data; |
| 2059 | 2059 | } |
| 2060 | 2060 | |
| r3658 | r3659 | |
| 2064 | 2064 | WRITE8_HANDLER ( mo5_ext_w ) |
| 2065 | 2065 | { |
| 2066 | 2066 | mo5_reg_cart = data; |
| 2067 | | mo5_update_cart_bank(machine); |
| 2067 | mo5_update_cart_bank(space->machine); |
| 2068 | 2068 | } |
| 2069 | 2069 | |
| 2070 | 2070 | |
| r3658 | r3659 | |
| 2093 | 2093 | /* video */ |
| 2094 | 2094 | thom_set_video_mode( THOM_VMODE_MO5 ); |
| 2095 | 2095 | thom_set_lightpen_callback( 3, mo5_lightpen_cb ); |
| 2096 | | thom_set_mode_point( 0 ); |
| 2096 | thom_set_mode_point( machine, 0 ); |
| 2097 | 2097 | thom_set_border_color( 0 ); |
| 2098 | 2098 | pia_set_input_ca1( THOM_PIA_SYS, 0 ); |
| 2099 | 2099 | |
| r3658 | r3659 | |
| 2130 | 2130 | thom_cart_bank = 0; |
| 2131 | 2131 | mo5_reg_cart = 0; |
| 2132 | 2132 | thom_vram = mess_ram; |
| 2133 | | memory_configure_bank( THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x8000 ); |
| 2134 | | memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 2135 | | memory_configure_bank( THOM_CART_BANK, 4, 4, mess_ram + 0xc000, 0x4000 ); |
| 2136 | | memory_configure_bank( THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 ); |
| 2137 | | memory_set_bank( THOM_BASE_BANK, 0 ); |
| 2138 | | memory_set_bank( THOM_CART_BANK, 0 ); |
| 2139 | | memory_set_bank( THOM_VRAM_BANK, 0 ); |
| 2133 | memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x8000 ); |
| 2134 | memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 2135 | memory_configure_bank( machine, THOM_CART_BANK, 4, 4, mess_ram + 0xc000, 0x4000 ); |
| 2136 | memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 ); |
| 2137 | memory_set_bank( machine, THOM_BASE_BANK, 0 ); |
| 2138 | memory_set_bank( machine, THOM_CART_BANK, 0 ); |
| 2139 | memory_set_bank( machine, THOM_VRAM_BANK, 0 ); |
| 2140 | 2140 | |
| 2141 | 2141 | /* save-state */ |
| 2142 | 2142 | state_save_register_global( thom_cart_nb_banks ); |
| r3658 | r3659 | |
| 2164 | 2164 | |
| 2165 | 2165 | WRITE8_HANDLER ( to9_ieee_w ) |
| 2166 | 2166 | { |
| 2167 | | logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data, offset ); |
| 2167 | logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data, offset ); |
| 2168 | 2168 | } |
| 2169 | 2169 | |
| 2170 | 2170 | |
| 2171 | 2171 | |
| 2172 | 2172 | READ8_HANDLER ( to9_ieee_r ) |
| 2173 | 2173 | { |
| 2174 | | logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset ); |
| 2174 | logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset ); |
| 2175 | 2175 | return 0; |
| 2176 | 2176 | } |
| 2177 | 2177 | |
| r3658 | r3659 | |
| 2188 | 2188 | READ8_HANDLER ( to9_gatearray_r ) |
| 2189 | 2189 | { |
| 2190 | 2190 | struct thom_vsignal v = thom_get_vsignal(); |
| 2191 | | struct thom_vsignal l = thom_get_lightpen_vsignal( machine, TO9_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 ); |
| 2191 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO9_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 ); |
| 2192 | 2192 | int count, inil, init, lt3; |
| 2193 | 2193 | count = to7_lightpen ? l.count : v.count; |
| 2194 | 2194 | inil = to7_lightpen ? l.inil : v.inil; |
| r3658 | r3659 | |
| 2202 | 2202 | case 2: return (lt3 << 7) | (inil << 6); |
| 2203 | 2203 | case 3: return (v.init << 7) | (init << 6); /* != TO7/70 */ |
| 2204 | 2204 | default: |
| 2205 | | logerror( "$%04x to9_gatearray_r: invalid offset %i\n", activecpu_get_previouspc(), offset ); |
| 2205 | logerror( "$%04x to9_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 2206 | 2206 | return 0; |
| 2207 | 2207 | } |
| 2208 | 2208 | } |
| r3658 | r3659 | |
| 2297 | 2297 | |
| 2298 | 2298 | WRITE8_HANDLER ( to9_vreg_w ) |
| 2299 | 2299 | { |
| 2300 | | LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset, 0xe7da + offset, data )); |
| 2300 | LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset, 0xe7da + offset, data )); |
| 2301 | 2301 | |
| 2302 | 2302 | switch ( offset ) |
| 2303 | 2303 | { |
| r3658 | r3659 | |
| 2357 | 2357 | int slot = ( mc6846_get_output_port(machine) >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2358 | 2358 | |
| 2359 | 2359 | /* reset cartridge read handler */ |
| 2360 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, (read8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 2360 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 2361 | 2361 | |
| 2362 | 2362 | switch ( slot ) |
| 2363 | 2363 | { |
| r3658 | r3659 | |
| 2384 | 2384 | if ( thom_cart_nb_banks ) |
| 2385 | 2385 | { |
| 2386 | 2386 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 2387 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 2387 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 2388 | 2388 | } |
| 2389 | 2389 | if ( bank != old_bank ) |
| 2390 | 2390 | LOG_BANK(( "to9_update_cart_bank: CART is cartridge bank %i\n", thom_cart_bank )); |
| 2391 | 2391 | break; |
| 2392 | 2392 | } |
| 2393 | 2393 | |
| 2394 | | memory_set_bank( THOM_CART_BANK, bank ); |
| 2394 | memory_set_bank( machine, THOM_CART_BANK, bank ); |
| 2395 | 2395 | old_bank = bank; |
| 2396 | 2396 | } |
| 2397 | 2397 | |
| r3658 | r3659 | |
| 2407 | 2407 | /* write signal to 0000-1fff generates a bank switch */ |
| 2408 | 2408 | WRITE8_HANDLER ( to9_cartridge_w ) |
| 2409 | 2409 | { |
| 2410 | | int slot = ( mc6846_get_output_port(machine) >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2410 | int slot = ( mc6846_get_output_port(space->machine) >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2411 | 2411 | |
| 2412 | 2412 | if ( offset >= 0x2000 ) |
| 2413 | 2413 | return; |
| r3658 | r3659 | |
| 2416 | 2416 | thom_cart_bank = offset & 3; |
| 2417 | 2417 | else |
| 2418 | 2418 | to9_soft_bank = offset & 3; |
| 2419 | | to9_update_cart_bank(machine); |
| 2419 | to9_update_cart_bank(space->machine); |
| 2420 | 2420 | } |
| 2421 | 2421 | |
| 2422 | 2422 | |
| r3658 | r3659 | |
| 2424 | 2424 | /* read signal to 0000-0003 generates a bank switch */ |
| 2425 | 2425 | READ8_HANDLER ( to9_cartridge_r ) |
| 2426 | 2426 | { |
| 2427 | | UINT8* pos = memory_region( machine, "main" ) + 0x10000; |
| 2427 | UINT8* pos = memory_region( space->machine, "main" ) + 0x10000; |
| 2428 | 2428 | UINT8 data = pos[offset + (thom_cart_bank % thom_cart_nb_banks) * 0x4000]; |
| 2429 | 2429 | thom_cart_bank = offset & 3; |
| 2430 | | to9_update_cart_bank(machine); |
| 2430 | to9_update_cart_bank(space->machine); |
| 2431 | 2431 | return data; |
| 2432 | 2432 | } |
| 2433 | 2433 | |
| r3658 | r3659 | |
| 2467 | 2467 | |
| 2468 | 2468 | if ( mess_ram_size == 192*1024 || bank < 6 ) |
| 2469 | 2469 | { |
| 2470 | | memory_set_bank( THOM_RAM_BANK, bank ); |
| 2471 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, (write8_machine_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 2470 | memory_set_bank( machine, THOM_RAM_BANK, bank ); |
| 2471 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 2472 | 2472 | } |
| 2473 | 2473 | else |
| 2474 | 2474 | { |
| 2475 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, SMH_NOP ); |
| 2475 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, SMH_NOP ); |
| 2476 | 2476 | } |
| 2477 | 2477 | |
| 2478 | 2478 | old_bank = bank; |
| r3658 | r3659 | |
| 2592 | 2592 | /* bit 7: interrupt */ |
| 2593 | 2593 | |
| 2594 | 2594 | LOG_KBD(( "$%04x %f to9_kbd_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, pe=%i, irq=%i)\n", |
| 2595 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_status, |
| 2595 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), to9_kbd_status, |
| 2596 | 2596 | (to9_kbd_status & ACIA_6850_RDRF) ? 1 : 0, |
| 2597 | 2597 | (to9_kbd_status & ACIA_6850_TDRE) ? 1 : 0, |
| 2598 | 2598 | (to9_kbd_status & ACIA_6850_OVRN) ? 1 : 0, |
| r3658 | r3659 | |
| 2607 | 2607 | else |
| 2608 | 2608 | to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF); |
| 2609 | 2609 | to9_kbd_overrun = 0; |
| 2610 | | LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_in )); |
| 2611 | | to9_kbd_update_irq(machine); |
| 2610 | LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), to9_kbd_in )); |
| 2611 | to9_kbd_update_irq(space->machine); |
| 2612 | 2612 | return to9_kbd_in; |
| 2613 | 2613 | |
| 2614 | 2614 | default: |
| 2615 | | logerror( "$%04x to9_kbd_r: invalid offset %i\n", activecpu_get_previouspc(), offset ); |
| 2615 | logerror( "$%04x to9_kbd_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 2616 | 2616 | return 0; |
| 2617 | 2617 | } |
| 2618 | 2618 | } |
| r3658 | r3659 | |
| 2634 | 2634 | to9_kbd_overrun = 0; |
| 2635 | 2635 | to9_kbd_status = ACIA_6850_TDRE; |
| 2636 | 2636 | to9_kbd_intr = 0; |
| 2637 | | LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 2637 | LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data )); |
| 2638 | 2638 | } |
| 2639 | 2639 | else |
| 2640 | 2640 | { |
| r3658 | r3659 | |
| 2648 | 2648 | to9_kbd_intr = data >> 5; |
| 2649 | 2649 | |
| 2650 | 2650 | LOG_KBD(( "$%04x %f to9_kbd_w: set control to $%02X (parity=%i, intr in=%i out=%i)\n", |
| 2651 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 2651 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), |
| 2652 | 2652 | data, to9_kbd_parity, to9_kbd_intr >> 2, |
| 2653 | 2653 | (to9_kbd_intr & 3) ? 1 : 0 )); |
| 2654 | 2654 | } |
| 2655 | | to9_kbd_update_irq(machine); |
| 2655 | to9_kbd_update_irq(space->machine); |
| 2656 | 2656 | break; |
| 2657 | 2657 | |
| 2658 | 2658 | case 1: /* output data */ |
| 2659 | 2659 | to9_kbd_status &= ~(ACIA_6850_irq | ACIA_6850_TDRE); |
| 2660 | | to9_kbd_update_irq(machine); |
| 2660 | to9_kbd_update_irq(space->machine); |
| 2661 | 2661 | /* TODO: 1 ms delay here ? */ |
| 2662 | 2662 | to9_kbd_status |= ACIA_6850_TDRE; /* data transmit ready again */ |
| 2663 | | to9_kbd_update_irq(machine); |
| 2663 | to9_kbd_update_irq(space->machine); |
| 2664 | 2664 | |
| 2665 | 2665 | switch ( data ) |
| 2666 | 2666 | { |
| r3658 | r3659 | |
| 2679 | 2679 | case 0xFE: to9_kbd_periph = 0; break; |
| 2680 | 2680 | |
| 2681 | 2681 | default: |
| 2682 | | logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ); |
| 2682 | logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ); |
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | thom_set_caps_led( ! to9_kbd_caps ); |
| 2686 | 2686 | |
| 2687 | 2687 | LOG(( "$%04x %f to9_kbd_w: kbd command %02X (caps=%i, pad=%i, periph=%i)\n", |
| 2688 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data, |
| 2688 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data, |
| 2689 | 2689 | to9_kbd_caps, to9_kbd_pad, to9_kbd_periph )); |
| 2690 | 2690 | |
| 2691 | 2691 | break; |
| 2692 | 2692 | |
| 2693 | 2693 | default: |
| 2694 | | logerror( "$%04x to9_kbd_w: invalid offset %i (data=$%02X) \n", activecpu_get_previouspc(), offset, data ); |
| 2694 | logerror( "$%04x to9_kbd_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc(space->cpu), offset, data ); |
| 2695 | 2695 | } |
| 2696 | 2696 | } |
| 2697 | 2697 | |
| r3658 | r3659 | |
| 2963 | 2963 | centronics_write_data( 0, data ); |
| 2964 | 2964 | centronics_write_handshake( 0, (b & 2) ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE ); |
| 2965 | 2965 | |
| 2966 | | LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n", |
| 2967 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data, |
| 2968 | | (b & 2) ? 1 : 0 )); |
| 2966 | // LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n", |
| 2967 | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data, |
| 2968 | // (b & 2) ? 1 : 0 )); |
| 2969 | 2969 | } |
| 2970 | 2970 | |
| 2971 | 2971 | |
| 2972 | 2972 | |
| 2973 | 2973 | static READ8_HANDLER ( to9_sys_porta_in ) |
| 2974 | 2974 | { |
| 2975 | | UINT8 ktest = to9_kbd_ktest(machine); |
| 2975 | UINT8 ktest = to9_kbd_ktest(space->machine); |
| 2976 | 2976 | |
| 2977 | 2977 | LOG_KBD(( "to9_sys_porta_in: ktest=%i\n", ktest )); |
| 2978 | 2978 | |
| r3658 | r3659 | |
| 2983 | 2983 | |
| 2984 | 2984 | static WRITE8_HANDLER ( to9_sys_porta_out ) |
| 2985 | 2985 | { |
| 2986 | | to9_update_centronics(machine); /* bits 1-7: printer */ |
| 2986 | to9_update_centronics(space->machine); /* bits 1-7: printer */ |
| 2987 | 2987 | } |
| 2988 | 2988 | |
| 2989 | 2989 | |
| 2990 | 2990 | |
| 2991 | 2991 | static WRITE8_HANDLER ( to9_sys_portb_out ) |
| 2992 | 2992 | { |
| 2993 | | to9_update_centronics(machine); /* bits 0-1: printer */ |
| 2994 | | to9_update_ram_bank(machine); |
| 2993 | to9_update_centronics(space->machine); /* bits 0-1: printer */ |
| 2994 | to9_update_ram_bank(space->machine); |
| 2995 | 2995 | |
| 2996 | 2996 | if ( data & 4 ) /* bit 2: video overlay (TODO) */ |
| 2997 | 2997 | LOG(( "to9_sys_portb_out: video overlay not handled\n" )); |
| r3658 | r3659 | |
| 3018 | 3018 | |
| 3019 | 3019 | static WRITE8_HANDLER ( to9_timer_port_out ) |
| 3020 | 3020 | { |
| 3021 | | thom_set_mode_point( data & 1 ); /* bit 0: video bank */ |
| 3022 | | to9_update_ram_bank(machine); |
| 3023 | | to9_update_cart_bank(machine); |
| 3021 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank */ |
| 3022 | to9_update_ram_bank(space->machine); |
| 3023 | to9_update_cart_bank(space->machine); |
| 3024 | 3024 | } |
| 3025 | 3025 | |
| 3026 | 3026 | |
| r3658 | r3659 | |
| 3060 | 3060 | thom_set_video_mode( THOM_VMODE_TO9 ); |
| 3061 | 3061 | thom_set_lightpen_callback( 3, to7_lightpen_cb ); |
| 3062 | 3062 | thom_set_border_color( 8 ); |
| 3063 | | thom_set_mode_point( 0 ); |
| 3063 | thom_set_mode_point( machine, 0 ); |
| 3064 | 3064 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 3065 | 3065 | |
| 3066 | 3066 | /* memory */ |
| r3658 | r3659 | |
| 3098 | 3098 | /* memory */ |
| 3099 | 3099 | thom_vram = mess_ram; |
| 3100 | 3100 | thom_cart_bank = 0; |
| 3101 | | memory_configure_bank( THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 ); |
| 3102 | | memory_configure_bank( THOM_CART_BANK, 0, 12, mem + 0x10000, 0x4000 ); |
| 3103 | | memory_configure_bank( THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 3104 | | memory_configure_bank( THOM_RAM_BANK, 0, 10, mess_ram + 0x8000, 0x4000 ); |
| 3105 | | memory_set_bank( THOM_VRAM_BANK, 0 ); |
| 3106 | | memory_set_bank( THOM_CART_BANK, 0 ); |
| 3107 | | memory_set_bank( THOM_BASE_BANK, 0 ); |
| 3108 | | memory_set_bank( THOM_RAM_BANK, 0 ); |
| 3101 | memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 ); |
| 3102 | memory_configure_bank( machine, THOM_CART_BANK, 0, 12, mem + 0x10000, 0x4000 ); |
| 3103 | memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 3104 | memory_configure_bank( machine, THOM_RAM_BANK, 0, 10, mess_ram + 0x8000, 0x4000 ); |
| 3105 | memory_set_bank( machine, THOM_VRAM_BANK, 0 ); |
| 3106 | memory_set_bank( machine, THOM_CART_BANK, 0 ); |
| 3107 | memory_set_bank( machine, THOM_BASE_BANK, 0 ); |
| 3108 | memory_set_bank( machine, THOM_RAM_BANK, 0 ); |
| 3109 | 3109 | |
| 3110 | 3110 | /* save-state */ |
| 3111 | 3111 | state_save_register_global( thom_cart_nb_banks ); |
| r3658 | r3659 | |
| 3471 | 3471 | |
| 3472 | 3472 | |
| 3473 | 3473 | |
| 3474 | | static void to8_update_floppy_bank( void ) |
| 3474 | static void to8_update_floppy_bank(running_machine *machine) |
| 3475 | 3475 | { |
| 3476 | 3476 | static int old_bank = -1; |
| 3477 | 3477 | int bank = (to8_reg_sys1 & 0x80) ? to7_floppy_bank : (to8_bios_bank + TO7_NB_FLOP_BANK); |
| r3658 | r3659 | |
| 3480 | 3480 | LOG_BANK(( "to8_update_floppy_bank: floppy ROM is %s bank %i\n", |
| 3481 | 3481 | (to8_reg_sys1 & 0x80) ? "external" : "internal", |
| 3482 | 3482 | bank % TO7_NB_FLOP_BANK )); |
| 3483 | | memory_set_bank( THOM_FLOP_BANK, bank ); |
| 3483 | memory_set_bank( machine, THOM_FLOP_BANK, bank ); |
| 3484 | 3484 | old_bank = bank; |
| 3485 | 3485 | } |
| 3486 | 3486 | |
| r3658 | r3659 | |
| 3488 | 3488 | |
| 3489 | 3489 | static STATE_POSTLOAD( to8_update_floppy_bank_postload ) |
| 3490 | 3490 | { |
| 3491 | | to8_update_floppy_bank(); |
| 3491 | to8_update_floppy_bank(machine); |
| 3492 | 3492 | } |
| 3493 | 3493 | |
| 3494 | 3494 | |
| r3658 | r3659 | |
| 3535 | 3535 | to8_data_vpage = bank; |
| 3536 | 3536 | if ( mess_ram_size == 512*1024 || to8_data_vpage < 16 ) |
| 3537 | 3537 | { |
| 3538 | | memory_set_bank( TO8_DATA_LO, to8_data_vpage ); |
| 3539 | | memory_set_bank( TO8_DATA_HI, to8_data_vpage ); |
| 3540 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, to8_data_vpage <= 4 ? to8_data_lo_w : (write8_machine_func)(STATIC_BANK1 + TO8_DATA_LO - 1) ); |
| 3541 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, to8_data_vpage <= 4 ? to8_data_hi_w : (write8_machine_func)(STATIC_BANK1 + TO8_DATA_HI - 1) ); |
| 3538 | memory_set_bank( machine, TO8_DATA_LO, to8_data_vpage ); |
| 3539 | memory_set_bank( machine, TO8_DATA_HI, to8_data_vpage ); |
| 3540 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0, to8_data_vpage <= 4 ? to8_data_lo_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_LO - 1) ); |
| 3541 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xdfff, 0, 0, to8_data_vpage <= 4 ? to8_data_hi_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_HI - 1) ); |
| 3542 | 3542 | } |
| 3543 | 3543 | else |
| 3544 | 3544 | { |
| 3545 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, SMH_NOP ); |
| 3546 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, SMH_NOP ); |
| 3545 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0, SMH_NOP ); |
| 3546 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xdfff, 0, 0, SMH_NOP ); |
| 3547 | 3547 | } |
| 3548 | 3548 | } |
| 3549 | 3549 | |
| r3658 | r3659 | |
| 3562 | 3562 | int bank = 0; |
| 3563 | 3563 | |
| 3564 | 3564 | /* reset bank switch */ |
| 3565 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, (read8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 3565 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 3566 | 3566 | |
| 3567 | 3567 | if ( to8_reg_cart & 0x20 ) |
| 3568 | 3568 | { |
| 3569 | 3569 | /* RAM space */ |
| 3570 | 3570 | to8_cart_vpage = to8_reg_cart & 31; |
| 3571 | 3571 | bank = 8 + to8_cart_vpage; |
| 3572 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, |
| 3572 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, |
| 3573 | 3573 | ((to8_cart_vpage < 8 || mess_ram_size == 512*1024) && (to8_reg_cart & 0x40)) ? |
| 3574 | 3574 | (to8_cart_vpage <= 4) ? to8_vcart_w : |
| 3575 | | (write8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : |
| 3575 | (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : |
| 3576 | 3576 | SMH_NOP ); |
| 3577 | 3577 | if ( bank != old_bank ) |
| 3578 | 3578 | LOG_BANK(( "to8_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 )); |
| 3579 | 3579 | } |
| 3580 | 3580 | else |
| 3581 | 3581 | { |
| 3582 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, to8_cartridge_w ); |
| 3582 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, to8_cartridge_w ); |
| 3583 | 3583 | if ( to8_soft_select ) |
| 3584 | 3584 | { |
| 3585 | 3585 | /* internal software ROM space */ |
| r3658 | r3659 | |
| 3594 | 3594 | if ( thom_cart_nb_banks ) |
| 3595 | 3595 | { |
| 3596 | 3596 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 3597 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, to8_cartridge_r ); |
| 3597 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to8_cartridge_r ); |
| 3598 | 3598 | |
| 3599 | 3599 | } |
| 3600 | 3600 | |
| r3658 | r3659 | |
| 3605 | 3605 | |
| 3606 | 3606 | if ( mess_ram_size == 512*1024 || bank < 16 ) |
| 3607 | 3607 | { |
| 3608 | | memory_set_bank( THOM_CART_BANK, bank ); |
| 3608 | memory_set_bank( machine, THOM_CART_BANK, bank ); |
| 3609 | 3609 | } |
| 3610 | 3610 | |
| 3611 | 3611 | old_bank = bank; |
| r3658 | r3659 | |
| 3631 | 3631 | else |
| 3632 | 3632 | thom_cart_bank = offset & 3; |
| 3633 | 3633 | |
| 3634 | | to8_update_cart_bank(machine); |
| 3634 | to8_update_cart_bank(space->machine); |
| 3635 | 3635 | } |
| 3636 | 3636 | |
| 3637 | 3637 | |
| r3658 | r3659 | |
| 3639 | 3639 | /* read signal to 0000-0003 generates a bank switch */ |
| 3640 | 3640 | READ8_HANDLER ( to8_cartridge_r ) |
| 3641 | 3641 | { |
| 3642 | | UINT8* pos = memory_region( machine, "main" ) + 0x10000; |
| 3642 | UINT8* pos = memory_region( space->machine, "main" ) + 0x10000; |
| 3643 | 3643 | UINT8 data = pos[offset + (thom_cart_bank % thom_cart_nb_banks) * 0x4000]; |
| 3644 | 3644 | thom_cart_bank = offset & 3; |
| 3645 | | to8_update_cart_bank(machine); |
| 3645 | to8_update_cart_bank(space->machine); |
| 3646 | 3646 | return data; |
| 3647 | 3647 | } |
| 3648 | 3648 | |
| r3658 | r3659 | |
| 3665 | 3665 | to7_floppy_reset(machine); |
| 3666 | 3666 | if ( THOM_FLOPPY_INT ) |
| 3667 | 3667 | thmfc_floppy_reset(machine); |
| 3668 | | memory_configure_bank( THOM_FLOP_BANK, TO7_NB_FLOP_BANK, 2, mem + 0x30000, 0x2000 ); |
| 3668 | memory_configure_bank( machine, THOM_FLOP_BANK, TO7_NB_FLOP_BANK, 2, mem + 0x30000, 0x2000 ); |
| 3669 | 3669 | } |
| 3670 | 3670 | |
| 3671 | 3671 | |
| r3658 | r3659 | |
| 3674 | 3674 | { |
| 3675 | 3675 | if ( (to8_reg_sys1 & 0x80) && THOM_FLOPPY_EXT ) |
| 3676 | 3676 | /* external controller */ |
| 3677 | | return to7_floppy_r( machine, offset ); |
| 3677 | return to7_floppy_r( space, offset ); |
| 3678 | 3678 | else if ( ! (to8_reg_sys1 & 0x80) && THOM_FLOPPY_INT ) |
| 3679 | 3679 | /* internal controller */ |
| 3680 | | return thmfc_floppy_r( machine, offset ); |
| 3680 | return thmfc_floppy_r( space, offset ); |
| 3681 | 3681 | else |
| 3682 | 3682 | /* no controller */ |
| 3683 | 3683 | return 0; |
| r3658 | r3659 | |
| 3689 | 3689 | { |
| 3690 | 3690 | if ( (to8_reg_sys1 & 0x80) && THOM_FLOPPY_EXT ) |
| 3691 | 3691 | /* external controller */ |
| 3692 | | to7_floppy_w( machine, offset, data ); |
| 3692 | to7_floppy_w( space, offset, data ); |
| 3693 | 3693 | else if ( ! (to8_reg_sys1 & 0x80) && THOM_FLOPPY_INT ) |
| 3694 | 3694 | /* internal controller */ |
| 3695 | | thmfc_floppy_w( machine, offset, data ); |
| 3695 | thmfc_floppy_w( space, offset, data ); |
| 3696 | 3696 | } |
| 3697 | 3697 | |
| 3698 | 3698 | |
| r3658 | r3659 | |
| 3708 | 3708 | READ8_HANDLER ( to8_gatearray_r ) |
| 3709 | 3709 | { |
| 3710 | 3710 | struct thom_vsignal v = thom_get_vsignal(); |
| 3711 | | struct thom_vsignal l = thom_get_lightpen_vsignal( machine, TO8_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 ); |
| 3711 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO8_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 ); |
| 3712 | 3712 | int count, inil, init, lt3; |
| 3713 | 3713 | UINT8 res; |
| 3714 | 3714 | count = to7_lightpen ? l.count : v.count; |
| r3658 | r3659 | |
| 3729 | 3729 | case 1: /* ram register / lightpen register 2 */ |
| 3730 | 3730 | if ( to7_lightpen ) |
| 3731 | 3731 | { |
| 3732 | | thom_firq_2( machine, 0 ); |
| 3732 | thom_firq_2( space->machine, 0 ); |
| 3733 | 3733 | to8_lightpen_intr = 0; |
| 3734 | 3734 | res = count & 0xff; |
| 3735 | 3735 | } |
| r3658 | r3659 | |
| 3749 | 3749 | break; |
| 3750 | 3750 | |
| 3751 | 3751 | default: |
| 3752 | | logerror( "$%04x to8_gatearray_r: invalid offset %i\n", activecpu_get_previouspc(), offset ); |
| 3752 | logerror( "$%04x to8_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 3753 | 3753 | res = 0; |
| 3754 | 3754 | } |
| 3755 | 3755 | |
| 3756 | 3756 | LOG_VIDEO(( "$%04x %f to8_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 3757 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 3757 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), |
| 3758 | 3758 | offset, 0xe7e4 + offset, res, to7_lightpen )); |
| 3759 | 3759 | |
| 3760 | 3760 | return res; |
| r3658 | r3659 | |
| 3765 | 3765 | WRITE8_HANDLER ( to8_gatearray_w ) |
| 3766 | 3766 | { |
| 3767 | 3767 | LOG_VIDEO(( "$%04x %f to8_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 3768 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 3768 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), |
| 3769 | 3769 | offset, 0xe7e4 + offset, data )); |
| 3770 | 3770 | |
| 3771 | 3771 | switch ( offset ) |
| r3658 | r3659 | |
| 3779 | 3779 | if ( to8_reg_sys1 & 0x10 ) |
| 3780 | 3780 | { |
| 3781 | 3781 | to8_reg_ram = data; |
| 3782 | | to8_update_ram_bank(machine); |
| 3782 | to8_update_ram_bank(space->machine); |
| 3783 | 3783 | } |
| 3784 | 3784 | break; |
| 3785 | 3785 | |
| 3786 | 3786 | case 2: /* cartridge register */ |
| 3787 | 3787 | to8_reg_cart = data; |
| 3788 | | to8_update_cart_bank(machine); |
| 3788 | to8_update_cart_bank(space->machine); |
| 3789 | 3789 | break; |
| 3790 | 3790 | |
| 3791 | 3791 | case 3: /* system register 1 */ |
| 3792 | 3792 | to8_reg_sys1 = data; |
| 3793 | | to8_update_floppy_bank(); |
| 3794 | | to8_update_ram_bank(machine); |
| 3795 | | to8_update_cart_bank(machine); |
| 3793 | to8_update_floppy_bank(space->machine); |
| 3794 | to8_update_ram_bank(space->machine); |
| 3795 | to8_update_cart_bank(space->machine); |
| 3796 | 3796 | break; |
| 3797 | 3797 | |
| 3798 | 3798 | default: |
| 3799 | 3799 | logerror( "$%04x to8_gatearray_w: invalid offset %i (data=$%02X)\n", |
| 3800 | | activecpu_get_previouspc(), offset, data ); |
| 3800 | cpu_get_previouspc(space->cpu), offset, data ); |
| 3801 | 3801 | } |
| 3802 | 3802 | } |
| 3803 | 3803 | |
| r3658 | r3659 | |
| 3813 | 3813 | if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) && ( to8_reg_sys1 & 0x80 ) ) |
| 3814 | 3814 | { |
| 3815 | 3815 | if ( THOM_FLOPPY_EXT ) |
| 3816 | | return to7_floppy_r( machine, 0xc ); |
| 3816 | return to7_floppy_r( space, 0xc ); |
| 3817 | 3817 | else |
| 3818 | 3818 | return 0; |
| 3819 | 3819 | } |
| r3658 | r3659 | |
| 3846 | 3846 | WRITE8_HANDLER ( to8_vreg_w ) |
| 3847 | 3847 | { |
| 3848 | 3848 | LOG_VIDEO(( "$%04x %f to8_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 3849 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 3849 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), |
| 3850 | 3850 | offset, 0xe7da + offset, data )); |
| 3851 | 3851 | |
| 3852 | 3852 | switch ( offset ) |
| r3658 | r3659 | |
| 3877 | 3877 | if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) && ( to8_reg_sys1 & 0x80 ) ) |
| 3878 | 3878 | { |
| 3879 | 3879 | if ( THOM_FLOPPY_EXT ) |
| 3880 | | to7_floppy_w( machine, 0xc, data ); |
| 3880 | to7_floppy_w( space, 0xc, data ); |
| 3881 | 3881 | } |
| 3882 | 3882 | else |
| 3883 | 3883 | { |
| r3658 | r3659 | |
| 3900 | 3900 | |
| 3901 | 3901 | static READ8_HANDLER ( to8_sys_porta_in ) |
| 3902 | 3902 | { |
| 3903 | | int ktest = to8_kbd_ktest (machine); |
| 3903 | int ktest = to8_kbd_ktest (space->machine); |
| 3904 | 3904 | |
| 3905 | | LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), ktest )); |
| 3905 | LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), ktest )); |
| 3906 | 3906 | |
| 3907 | 3907 | return ktest; |
| 3908 | 3908 | } |
| r3658 | r3659 | |
| 3911 | 3911 | |
| 3912 | 3912 | static WRITE8_HANDLER ( to8_sys_portb_out ) |
| 3913 | 3913 | { |
| 3914 | | to9_update_centronics(machine); /* bits 0-1: printer */ |
| 3915 | | to8_update_ram_bank(machine); |
| 3914 | to9_update_centronics(space->machine); /* bits 0-1: printer */ |
| 3915 | to8_update_ram_bank(space->machine); |
| 3916 | 3916 | |
| 3917 | 3917 | if ( data & 4 ) /* bit 2: video overlay (TODO) */ |
| 3918 | 3918 | LOG(( "to8_sys_portb_out: video overlay not handled\n" )); |
| r3658 | r3659 | |
| 3936 | 3936 | |
| 3937 | 3937 | static READ8_HANDLER ( to8_timer_port_in ) |
| 3938 | 3938 | { |
| 3939 | | int lightpen = (input_port_read(machine, "lightpen_button") & 1) ? 2 : 0; |
| 3940 | | int cass = to7_get_cassette(machine) ? 0x80 : 0; |
| 3939 | int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0; |
| 3940 | int cass = to7_get_cassette(space->machine) ? 0x80 : 0; |
| 3941 | 3941 | int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40; |
| 3942 | 3942 | int lock = to8_kbd_caps ? 0 : 8; /* undocumented! */ |
| 3943 | 3943 | return lightpen | cass | dtr | lock; |
| r3658 | r3659 | |
| 3949 | 3949 | { |
| 3950 | 3950 | int ack = (data & 0x20) ? 1 : 0; /* bit 5: keyboard ACK */ |
| 3951 | 3951 | to8_bios_bank = (data & 0x10) ? 1 : 0; /* bit 4: BIOS bank*/ |
| 3952 | | thom_set_mode_point( data & 1 ); /* bit 0: video bank switch */ |
| 3953 | | memory_set_bank( TO8_BIOS_BANK, to8_bios_bank ); |
| 3952 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 3953 | memory_set_bank( space->machine, TO8_BIOS_BANK, to8_bios_bank ); |
| 3954 | 3954 | to8_soft_select = (data & 0x04) ? 1 : 0; /* bit 2: internal ROM select */ |
| 3955 | | to8_update_floppy_bank(); |
| 3956 | | to8_update_cart_bank(machine); |
| 3955 | to8_update_floppy_bank(space->machine); |
| 3956 | to8_update_cart_bank(space->machine); |
| 3957 | 3957 | to8_kbd_set_ack( ack ); |
| 3958 | 3958 | } |
| 3959 | 3959 | |
| r3658 | r3659 | |
| 4029 | 4029 | thom_set_video_mode( THOM_VMODE_TO770 ); |
| 4030 | 4030 | thom_set_lightpen_callback( 4, to8_lightpen_cb ); |
| 4031 | 4031 | thom_set_border_color( 0 ); |
| 4032 | | thom_set_mode_point( 0 ); |
| 4032 | thom_set_mode_point( machine, 0 ); |
| 4033 | 4033 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 4034 | 4034 | |
| 4035 | 4035 | /* memory */ |
| r3658 | r3659 | |
| 4039 | 4039 | to8_bios_bank = 0; |
| 4040 | 4040 | to8_update_ram_bank(machine); |
| 4041 | 4041 | to8_update_cart_bank(machine); |
| 4042 | | to8_update_floppy_bank(); |
| 4043 | | memory_set_bank( TO8_BIOS_BANK, 0 ); |
| 4042 | to8_update_floppy_bank(machine); |
| 4043 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 4044 | 4044 | /* thom_cart_bank not reset */ |
| 4045 | 4045 | } |
| 4046 | 4046 | |
| r3658 | r3659 | |
| 4069 | 4069 | /* memory */ |
| 4070 | 4070 | thom_cart_bank = 0; |
| 4071 | 4071 | thom_vram = mess_ram; |
| 4072 | | memory_configure_bank( THOM_CART_BANK, 0, 8, mem + 0x10000, 0x4000 ); |
| 4073 | | memory_configure_bank( THOM_CART_BANK, 8, 32, mess_ram, 0x4000 ); |
| 4074 | | memory_configure_bank( THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 ); |
| 4075 | | memory_configure_bank( TO8_SYS_LO, 0, 1, mess_ram + 0x6000, 0x4000 ); |
| 4076 | | memory_configure_bank( TO8_SYS_HI, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 4077 | | memory_configure_bank( TO8_DATA_LO, 0, 32, mess_ram + 0x2000, 0x4000 ); |
| 4078 | | memory_configure_bank( TO8_DATA_HI, 0, 32, mess_ram + 0x0000, 0x4000 ); |
| 4079 | | memory_configure_bank( TO8_BIOS_BANK, 0, 2, mem + 0x30800, 0x2000 ); |
| 4080 | | memory_set_bank( THOM_CART_BANK, 0 ); |
| 4081 | | memory_set_bank( THOM_VRAM_BANK, 0 ); |
| 4082 | | memory_set_bank( TO8_SYS_LO, 0 ); |
| 4083 | | memory_set_bank( TO8_SYS_HI, 0 ); |
| 4084 | | memory_set_bank( TO8_DATA_LO, 0 ); |
| 4085 | | memory_set_bank( TO8_DATA_HI, 0 ); |
| 4086 | | memory_set_bank( TO8_BIOS_BANK, 0 ); |
| 4072 | memory_configure_bank( machine, THOM_CART_BANK, 0, 8, mem + 0x10000, 0x4000 ); |
| 4073 | memory_configure_bank( machine, THOM_CART_BANK, 8, 32, mess_ram, 0x4000 ); |
| 4074 | memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 ); |
| 4075 | memory_configure_bank( machine, TO8_SYS_LO, 0, 1, mess_ram + 0x6000, 0x4000 ); |
| 4076 | memory_configure_bank( machine, TO8_SYS_HI, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 4077 | memory_configure_bank( machine, TO8_DATA_LO, 0, 32, mess_ram + 0x2000, 0x4000 ); |
| 4078 | memory_configure_bank( machine, TO8_DATA_HI, 0, 32, mess_ram + 0x0000, 0x4000 ); |
| 4079 | memory_configure_bank( machine, TO8_BIOS_BANK, 0, 2, mem + 0x30800, 0x2000 ); |
| 4080 | memory_set_bank( machine, THOM_CART_BANK, 0 ); |
| 4081 | memory_set_bank( machine, THOM_VRAM_BANK, 0 ); |
| 4082 | memory_set_bank( machine, TO8_SYS_LO, 0 ); |
| 4083 | memory_set_bank( machine, TO8_SYS_HI, 0 ); |
| 4084 | memory_set_bank( machine, TO8_DATA_LO, 0 ); |
| 4085 | memory_set_bank( machine, TO8_DATA_HI, 0 ); |
| 4086 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 4087 | 4087 | |
| 4088 | 4088 | /* save-state */ |
| 4089 | 4089 | state_save_register_global( thom_cart_nb_banks ); |
| r3658 | r3659 | |
| 4132 | 4132 | |
| 4133 | 4133 | static READ8_HANDLER ( to9p_timer_port_in ) |
| 4134 | 4134 | { |
| 4135 | | int lightpen = (input_port_read(machine, "lightpen_button") & 1) ? 2 : 0; |
| 4136 | | int cass = to7_get_cassette(machine) ? 0x80 : 0; |
| 4135 | int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0; |
| 4136 | int cass = to7_get_cassette(space->machine) ? 0x80 : 0; |
| 4137 | 4137 | int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40; |
| 4138 | 4138 | return lightpen | cass | dtr; |
| 4139 | 4139 | } |
| r3658 | r3659 | |
| 4143 | 4143 | static WRITE8_HANDLER ( to9p_timer_port_out ) |
| 4144 | 4144 | { |
| 4145 | 4145 | int bios_bank = (data & 0x10) ? 1 : 0; /* bit 4: BIOS bank */ |
| 4146 | | thom_set_mode_point( data & 1 ); /* bit 0: video bank switch */ |
| 4147 | | memory_set_bank( TO8_BIOS_BANK, bios_bank ); |
| 4146 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 4147 | memory_set_bank( space->machine, TO8_BIOS_BANK, bios_bank ); |
| 4148 | 4148 | to8_soft_select = (data & 0x04) ? 1 : 0; /* bit 2: internal ROM select */ |
| 4149 | | to8_update_floppy_bank(); |
| 4150 | | to8_update_cart_bank(machine); |
| 4149 | to8_update_floppy_bank(space->machine); |
| 4150 | to8_update_cart_bank(space->machine); |
| 4151 | 4151 | } |
| 4152 | 4152 | |
| 4153 | 4153 | |
| r3658 | r3659 | |
| 4196 | 4196 | thom_set_video_mode( THOM_VMODE_TO770 ); |
| 4197 | 4197 | thom_set_lightpen_callback( 4, to8_lightpen_cb ); |
| 4198 | 4198 | thom_set_border_color( 0 ); |
| 4199 | | thom_set_mode_point( 0 ); |
| 4199 | thom_set_mode_point( machine, 0 ); |
| 4200 | 4200 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 4201 | 4201 | |
| 4202 | 4202 | /* memory */ |
| r3658 | r3659 | |
| 4206 | 4206 | to8_bios_bank = 0; |
| 4207 | 4207 | to8_update_ram_bank(machine); |
| 4208 | 4208 | to8_update_cart_bank(machine); |
| 4209 | | to8_update_floppy_bank(); |
| 4210 | | memory_set_bank( TO8_BIOS_BANK, 0 ); |
| 4209 | to8_update_floppy_bank(machine); |
| 4210 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 4211 | 4211 | /* thom_cart_bank not reset */ |
| 4212 | 4212 | } |
| 4213 | 4213 | |
| r3658 | r3659 | |
| 4236 | 4236 | /* memory */ |
| 4237 | 4237 | thom_cart_bank = 0; |
| 4238 | 4238 | thom_vram = mess_ram; |
| 4239 | | memory_configure_bank( THOM_CART_BANK, 0, 8, mem + 0x10000, 0x4000 ); |
| 4240 | | memory_configure_bank( THOM_CART_BANK, 8, 32, mess_ram, 0x4000 ); |
| 4241 | | memory_configure_bank( THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 ); |
| 4242 | | memory_configure_bank( TO8_SYS_LO, 0, 1, mess_ram + 0x6000, 0x4000 ); |
| 4243 | | memory_configure_bank( TO8_SYS_HI, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 4244 | | memory_configure_bank( TO8_DATA_LO, 0, 32, mess_ram + 0x2000, 0x4000 ); |
| 4245 | | memory_configure_bank( TO8_DATA_HI, 0, 32, mess_ram + 0x0000, 0x4000 ); |
| 4246 | | memory_configure_bank( TO8_BIOS_BANK, 0, 2, mem + 0x30800, 0x2000 ); |
| 4247 | | memory_set_bank( THOM_CART_BANK, 0 ); |
| 4248 | | memory_set_bank( THOM_VRAM_BANK, 0 ); |
| 4249 | | memory_set_bank( TO8_SYS_LO, 0 ); |
| 4250 | | memory_set_bank( TO8_SYS_HI, 0 ); |
| 4251 | | memory_set_bank( TO8_DATA_LO, 0 ); |
| 4252 | | memory_set_bank( TO8_DATA_HI, 0 ); |
| 4253 | | memory_set_bank( TO8_BIOS_BANK, 0 ); |
| 4239 | memory_configure_bank( machine, THOM_CART_BANK, 0, 8, mem + 0x10000, 0x4000 ); |
| 4240 | memory_configure_bank( machine, THOM_CART_BANK, 8, 32, mess_ram, 0x4000 ); |
| 4241 | memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 ); |
| 4242 | memory_configure_bank( machine, TO8_SYS_LO, 0, 1, mess_ram + 0x6000, 0x4000 ); |
| 4243 | memory_configure_bank( machine, TO8_SYS_HI, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 4244 | memory_configure_bank( machine, TO8_DATA_LO, 0, 32, mess_ram + 0x2000, 0x4000 ); |
| 4245 | memory_configure_bank( machine, TO8_DATA_HI, 0, 32, mess_ram + 0x0000, 0x4000 ); |
| 4246 | memory_configure_bank( machine, TO8_BIOS_BANK, 0, 2, mem + 0x30800, 0x2000 ); |
| 4247 | memory_set_bank( machine, THOM_CART_BANK, 0 ); |
| 4248 | memory_set_bank( machine, THOM_VRAM_BANK, 0 ); |
| 4249 | memory_set_bank( machine, TO8_SYS_LO, 0 ); |
| 4250 | memory_set_bank( machine, TO8_SYS_HI, 0 ); |
| 4251 | memory_set_bank( machine, TO8_DATA_LO, 0 ); |
| 4252 | memory_set_bank( machine, TO8_DATA_HI, 0 ); |
| 4253 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 4254 | 4254 | |
| 4255 | 4255 | /* save-state */ |
| 4256 | 4256 | state_save_register_global( thom_cart_nb_banks ); |
| r3658 | r3659 | |
| 4283 | 4283 | |
| 4284 | 4284 | |
| 4285 | 4285 | |
| 4286 | | static void mo6_update_ram_bank ( void ) |
| 4286 | static void mo6_update_ram_bank (running_machine *machine) |
| 4287 | 4287 | { |
| 4288 | 4288 | UINT8 bank = 0; |
| 4289 | 4289 | |
| r3658 | r3659 | |
| 4294 | 4294 | LOG_BANK(( "mo6_update_ram_bank: select bank %i (new style)\n", bank )); |
| 4295 | 4295 | } |
| 4296 | 4296 | to8_data_vpage = bank; |
| 4297 | | memory_set_bank( TO8_DATA_LO, to8_data_vpage ); |
| 4298 | | memory_set_bank( TO8_DATA_HI, to8_data_vpage ); |
| 4297 | memory_set_bank( machine, TO8_DATA_LO, to8_data_vpage ); |
| 4298 | memory_set_bank( machine, TO8_DATA_HI, to8_data_vpage ); |
| 4299 | 4299 | } |
| 4300 | 4300 | |
| 4301 | 4301 | |
| 4302 | 4302 | |
| 4303 | 4303 | static STATE_POSTLOAD( mo6_update_ram_bank_postload ) |
| 4304 | 4304 | { |
| 4305 | | mo6_update_ram_bank(); |
| 4305 | mo6_update_ram_bank(machine); |
| 4306 | 4306 | } |
| 4307 | 4307 | |
| 4308 | 4308 | |
| r3658 | r3659 | |
| 4313 | 4313 | static int old_bank = -1; |
| 4314 | 4314 | int bank = 0; |
| 4315 | 4315 | |
| 4316 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, (read8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 4316 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 4317 | 4317 | |
| 4318 | 4318 | if ( ( ( to8_reg_sys1 & 0x40 ) && ( to8_reg_cart & 0x20 ) ) || ( ! ( to8_reg_sys1 & 0x40 ) && ( mo5_reg_cart & 4 ) ) ) |
| 4319 | 4319 | { |
| r3658 | r3659 | |
| 4323 | 4323 | /* use a7e6 */ |
| 4324 | 4324 | to8_cart_vpage = to8_reg_cart & 7; /* 128 KB RAM only = 8 pages */ |
| 4325 | 4325 | bank = 8 + to8_cart_vpage; |
| 4326 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, |
| 4326 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, |
| 4327 | 4327 | (to8_reg_cart & 0x40) ? (to8_cart_vpage <= 4) ? to8_vcart_w : |
| 4328 | | (write8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 4328 | (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 4329 | 4329 | if ( bank != old_bank ) |
| 4330 | 4330 | LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 )); |
| 4331 | 4331 | } |
| 4332 | 4332 | else if ( thom_cart_nb_banks == 4 ) |
| 4333 | 4333 | { |
| 4334 | 4334 | /* "JANE"-style cartridge bank switching */ |
| 4335 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 4335 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 4336 | 4336 | bank = mo5_reg_cart & 3; |
| 4337 | 4337 | if ( bank != old_bank ) |
| 4338 | 4338 | LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i (A7CB style)\n", bank )); |
| r3658 | r3659 | |
| 4343 | 4343 | int write_enable = mo5_reg_cart & 8; |
| 4344 | 4344 | to8_cart_vpage = (mo5_reg_cart & 3) | 4; |
| 4345 | 4345 | bank = 8 + to8_cart_vpage; |
| 4346 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, write_enable ? |
| 4347 | | (write8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 4346 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, write_enable ? |
| 4347 | (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 4348 | 4348 | if ( bank != old_bank ) |
| 4349 | 4349 | LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i) (MO5 compat.)\n", to8_cart_vpage, write_enable ? 1 : 0 )); |
| 4350 | 4350 | } |
| r3658 | r3659 | |
| 4352 | 4352 | else |
| 4353 | 4353 | { |
| 4354 | 4354 | /* ROM space */ |
| 4355 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 4355 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 4356 | 4356 | if ( to8_reg_sys2 & 0x20 ) |
| 4357 | 4357 | { |
| 4358 | 4358 | /* internal ROM */ |
| r3658 | r3659 | |
| 4366 | 4366 | else |
| 4367 | 4367 | { |
| 4368 | 4368 | /* cartridge */ |
| 4369 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, mo6_cartridge_w ); |
| 4369 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, mo6_cartridge_w ); |
| 4370 | 4370 | if ( thom_cart_nb_banks ) |
| 4371 | 4371 | { |
| 4372 | 4372 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 4373 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xbffc, 0xbfff, 0, 0, mo6_cartridge_r ); |
| 4373 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xbffc, 0xbfff, 0, 0, mo6_cartridge_r ); |
| 4374 | 4374 | } |
| 4375 | 4375 | if ( bank != old_bank ) |
| 4376 | 4376 | LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i\n", bank )); |
| r3658 | r3659 | |
| 4378 | 4378 | } |
| 4379 | 4379 | |
| 4380 | 4380 | old_bank = bank; |
| 4381 | | memory_set_bank( THOM_CART_BANK, bank ); |
| 4382 | | memory_set_bank( TO8_BIOS_BANK, b ); |
| 4381 | memory_set_bank( machine, THOM_CART_BANK, bank ); |
| 4382 | memory_set_bank( machine, TO8_BIOS_BANK, b ); |
| 4383 | 4383 | } |
| 4384 | 4384 | |
| 4385 | 4385 | |
| r3658 | r3659 | |
| 4398 | 4398 | return; |
| 4399 | 4399 | |
| 4400 | 4400 | thom_cart_bank = offset & 3; |
| 4401 | | mo6_update_cart_bank(machine); |
| 4401 | mo6_update_cart_bank(space->machine); |
| 4402 | 4402 | } |
| 4403 | 4403 | |
| 4404 | 4404 | |
| r3658 | r3659 | |
| 4406 | 4406 | /* read signal generates a bank switch */ |
| 4407 | 4407 | READ8_HANDLER ( mo6_cartridge_r ) |
| 4408 | 4408 | { |
| 4409 | | UINT8* pos = memory_region( machine, "main" ) + 0x10000; |
| 4409 | UINT8* pos = memory_region( space->machine, "main" ) + 0x10000; |
| 4410 | 4410 | UINT8 data = pos[offset + 0xbffc + (thom_cart_bank % thom_cart_nb_banks) * 0x4000]; |
| 4411 | 4411 | thom_cart_bank = offset & 3; |
| 4412 | | mo6_update_cart_bank(machine); |
| 4412 | mo6_update_cart_bank(space->machine); |
| 4413 | 4413 | return data; |
| 4414 | 4414 | } |
| 4415 | 4415 | |
| r3658 | r3659 | |
| 4419 | 4419 | { |
| 4420 | 4420 | /* MO5 network extension compatible */ |
| 4421 | 4421 | mo5_reg_cart = data; |
| 4422 | | mo6_update_cart_bank(machine); |
| 4422 | mo6_update_cart_bank(space->machine); |
| 4423 | 4423 | } |
| 4424 | 4424 | |
| 4425 | 4425 | |
| r3658 | r3659 | |
| 4433 | 4433 | static WRITE8_HANDLER ( mo6_game_porta_out ) |
| 4434 | 4434 | { |
| 4435 | 4435 | /* centronics data */ |
| 4436 | | LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 4436 | LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data )); |
| 4437 | 4437 | centronics_write_data( 0, data ); |
| 4438 | 4438 | } |
| 4439 | 4439 | |
| r3658 | r3659 | |
| 4443 | 4443 | { |
| 4444 | 4444 | int dtr = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 0 : 1; |
| 4445 | 4445 | /* note: printer busy signal replaces button */ |
| 4446 | | LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), dtr )); |
| 4446 | LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), dtr )); |
| 4447 | 4447 | return dtr; |
| 4448 | 4448 | } |
| 4449 | 4449 | |
| r3658 | r3659 | |
| 4452 | 4452 | static WRITE8_HANDLER ( mo6_game_cb2_out ) |
| 4453 | 4453 | { |
| 4454 | 4454 | /* centronics strobe */ |
| 4455 | | LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data )); |
| 4455 | LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data )); |
| 4456 | 4456 | centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, |
| 4457 | 4457 | CENTRONICS_STROBE ); |
| 4458 | 4458 | } |
| r3658 | r3659 | |
| 4519 | 4519 | static READ8_HANDLER ( mo6_sys_porta_in ) |
| 4520 | 4520 | { |
| 4521 | 4521 | return |
| 4522 | | (mo5_get_cassette(machine) ? 0x80 : 0) | /* bit 7: cassette input */ |
| 4522 | (mo5_get_cassette(space->machine) ? 0x80 : 0) | /* bit 7: cassette input */ |
| 4523 | 4523 | 8 | /* bit 3: kbd-line float up to 1 */ |
| 4524 | | ((input_port_read(machine, "lightpen_button") & 1) ? 2 : 0); |
| 4524 | ((input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0); |
| 4525 | 4525 | /* bit 1: lightpen button */; |
| 4526 | 4526 | } |
| 4527 | 4527 | |
| r3658 | r3659 | |
| 4541 | 4541 | lin = 8; /* A bit 3: 9-th kbd line select */ |
| 4542 | 4542 | |
| 4543 | 4543 | return |
| 4544 | | ( input_port_read(machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0; |
| 4544 | ( input_port_read(space->machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0; |
| 4545 | 4545 | /* bit 7: key up */ |
| 4546 | 4546 | } |
| 4547 | 4547 | |
| r3658 | r3659 | |
| 4549 | 4549 | |
| 4550 | 4550 | static WRITE8_HANDLER ( mo6_sys_porta_out ) |
| 4551 | 4551 | { |
| 4552 | | thom_set_mode_point( data & 1 ); /* bit 0: video bank switch */ |
| 4552 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 4553 | 4553 | to7_game_mute = data & 4; /* bit 2: sound mute */ |
| 4554 | 4554 | thom_set_caps_led( (data & 16) ? 0 : 1 ) ; /* bit 4: keyboard led */ |
| 4555 | | mo5_set_cassette( machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 4556 | | mo6_update_cart_bank(machine); /* bit 5: rom bank */ |
| 4555 | mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 4556 | mo6_update_cart_bank(space->machine); /* bit 5: rom bank */ |
| 4557 | 4557 | to7_game_sound_update(); |
| 4558 | 4558 | } |
| 4559 | 4559 | |
| r3658 | r3659 | |
| 4593 | 4593 | READ8_HANDLER ( mo6_gatearray_r ) |
| 4594 | 4594 | { |
| 4595 | 4595 | struct thom_vsignal v = thom_get_vsignal(); |
| 4596 | | struct thom_vsignal l = thom_get_lightpen_vsignal( machine, MO6_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 ); |
| 4596 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, MO6_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 ); |
| 4597 | 4597 | int count, inil, init, lt3; |
| 4598 | 4598 | UINT8 res; |
| 4599 | 4599 | count = to7_lightpen ? l.count : v.count; |
| r3658 | r3659 | |
| 4614 | 4614 | case 1: /* ram register / lightpen register 2 */ |
| 4615 | 4615 | if ( to7_lightpen ) |
| 4616 | 4616 | { |
| 4617 | | thom_firq_2( machine, 0 ); |
| 4617 | thom_firq_2( space->machine, 0 ); |
| 4618 | 4618 | to8_lightpen_intr = 0; |
| 4619 | 4619 | res = count & 0xff; |
| 4620 | 4620 | } |
| r3658 | r3659 | |
| 4634 | 4634 | break; |
| 4635 | 4635 | |
| 4636 | 4636 | default: |
| 4637 | | logerror( "$%04x mo6_gatearray_r: invalid offset %i\n", activecpu_get_previouspc(), offset ); |
| 4637 | logerror( "$%04x mo6_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 4638 | 4638 | res = 0; |
| 4639 | 4639 | } |
| 4640 | 4640 | |
| 4641 | 4641 | LOG_VIDEO(( "$%04x %f mo6_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 4642 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 4642 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), |
| 4643 | 4643 | offset, 0xa7e4 + offset, res, to7_lightpen )); |
| 4644 | 4644 | |
| 4645 | 4645 | return res; |
| r3658 | r3659 | |
| 4650 | 4650 | WRITE8_HANDLER ( mo6_gatearray_w ) |
| 4651 | 4651 | { |
| 4652 | 4652 | LOG_VIDEO(( "$%04x %f mo6_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 4653 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 4653 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), |
| 4654 | 4654 | offset, 0xa7e4 + offset, data )); |
| 4655 | 4655 | |
| 4656 | 4656 | switch ( offset ) |
| r3658 | r3659 | |
| 4664 | 4664 | if ( to8_reg_sys1 & 0x10 ) |
| 4665 | 4665 | { |
| 4666 | 4666 | to8_reg_ram = data; |
| 4667 | | mo6_update_ram_bank(); |
| 4667 | mo6_update_ram_bank(space->machine); |
| 4668 | 4668 | } |
| 4669 | 4669 | break; |
| 4670 | 4670 | |
| 4671 | 4671 | case 2: /* cartridge register */ |
| 4672 | 4672 | to8_reg_cart = data; |
| 4673 | | mo6_update_cart_bank(machine); |
| 4673 | mo6_update_cart_bank(space->machine); |
| 4674 | 4674 | break; |
| 4675 | 4675 | |
| 4676 | 4676 | case 3: /* system register 1 */ |
| 4677 | 4677 | to8_reg_sys1 = data; |
| 4678 | | mo6_update_ram_bank(); |
| 4679 | | mo6_update_cart_bank(machine); |
| 4678 | mo6_update_ram_bank(space->machine); |
| 4679 | mo6_update_cart_bank(space->machine); |
| 4680 | 4680 | break; |
| 4681 | 4681 | |
| 4682 | 4682 | default: |
| 4683 | | logerror( "$%04x mo6_gatearray_w: invalid offset %i (data=$%02X)\n", activecpu_get_previouspc(), offset, data ); |
| 4683 | logerror( "$%04x mo6_gatearray_w: invalid offset %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), offset, data ); |
| 4684 | 4684 | } |
| 4685 | 4685 | } |
| 4686 | 4686 | |
| r3658 | r3659 | |
| 4693 | 4693 | { |
| 4694 | 4694 | /* 0xa7dc from external floppy drive aliases the video gate-array */ |
| 4695 | 4695 | if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) ) |
| 4696 | | return to7_floppy_r( machine, 0xc ); |
| 4696 | return to7_floppy_r( space, 0xc ); |
| 4697 | 4697 | |
| 4698 | 4698 | switch ( offset ) |
| 4699 | 4699 | { |
| 4700 | 4700 | |
| 4701 | 4701 | case 0: /* palette data */ |
| 4702 | 4702 | case 1: /* palette address */ |
| 4703 | | return to8_vreg_r( machine, offset ); |
| 4703 | return to8_vreg_r( space, offset ); |
| 4704 | 4704 | |
| 4705 | 4705 | case 2: |
| 4706 | 4706 | case 3: |
| r3658 | r3659 | |
| 4717 | 4717 | WRITE8_HANDLER ( mo6_vreg_w ) |
| 4718 | 4718 | { |
| 4719 | 4719 | LOG_VIDEO(( "$%04x %f mo6_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 4720 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), |
| 4720 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), |
| 4721 | 4721 | offset, 0xa7da + offset, data )); |
| 4722 | 4722 | |
| 4723 | 4723 | switch ( offset ) |
| r3658 | r3659 | |
| 4725 | 4725 | |
| 4726 | 4726 | case 0: /* palette data */ |
| 4727 | 4727 | case 1: /* palette address */ |
| 4728 | | to8_vreg_w( machine, offset, data ); |
| 4728 | to8_vreg_w( space, offset, data ); |
| 4729 | 4729 | return; |
| 4730 | 4730 | |
| 4731 | 4731 | case 2: /* display / external floppy register */ |
| 4732 | 4732 | if ( ( to8_reg_sys1 & 0x80 ) && ( to8_reg_ram & 0x80 ) ) |
| 4733 | | to7_floppy_w( machine, 0xc, data ); |
| 4733 | to7_floppy_w( space, 0xc, data ); |
| 4734 | 4734 | else |
| 4735 | 4735 | to9_set_video_mode( data, 2 ); |
| 4736 | 4736 | break; |
| r3658 | r3659 | |
| 4738 | 4738 | case 3: /* system register 2 */ |
| 4739 | 4739 | /* 0xa7dc from external floppy drive aliases the video gate-array */ |
| 4740 | 4740 | if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) ) |
| 4741 | | to7_floppy_w( machine, 0xc, data ); |
| 4741 | to7_floppy_w( space, 0xc, data ); |
| 4742 | 4742 | else |
| 4743 | 4743 | { |
| 4744 | 4744 | to8_reg_sys2 = data; |
| 4745 | 4745 | thom_set_video_page( data >> 6 ); |
| 4746 | 4746 | thom_set_border_color( data & 15 ); |
| 4747 | | mo6_update_cart_bank(machine); |
| 4747 | mo6_update_cart_bank(space->machine); |
| 4748 | 4748 | } |
| 4749 | 4749 | break; |
| 4750 | 4750 | |
| r3658 | r3659 | |
| 4788 | 4788 | thom_set_video_mode( THOM_VMODE_MO5 ); |
| 4789 | 4789 | thom_set_lightpen_callback( 3, to8_lightpen_cb ); |
| 4790 | 4790 | thom_set_border_color( 0 ); |
| 4791 | | thom_set_mode_point( 0 ); |
| 4791 | thom_set_mode_point( machine, 0 ); |
| 4792 | 4792 | pia_set_input_ca1( THOM_PIA_SYS, 0 ); |
| 4793 | 4793 | |
| 4794 | 4794 | /* memory */ |
| 4795 | 4795 | to8_cart_vpage = 0; |
| 4796 | 4796 | to8_data_vpage = 0; |
| 4797 | | mo6_update_ram_bank(); |
| 4797 | mo6_update_ram_bank(machine); |
| 4798 | 4798 | mo6_update_cart_bank(machine); |
| 4799 | 4799 | /* mo5_reg_cart not reset */ |
| 4800 | 4800 | /* thom_cart_bank not reset */ |
| r3658 | r3659 | |
| 4825 | 4825 | thom_cart_bank = 0; |
| 4826 | 4826 | mo5_reg_cart = 0; |
| 4827 | 4827 | thom_vram = mess_ram; |
| 4828 | | memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 4829 | | memory_configure_bank( THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 ); |
| 4830 | | memory_configure_bank( THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 ); |
| 4831 | | memory_configure_bank( THOM_CART_BANK, 8, 8, mess_ram, 0x4000 ); |
| 4832 | | memory_configure_bank( THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 ); |
| 4833 | | memory_configure_bank( TO8_SYS_LO, 0, 1, mess_ram + 0x6000, 0x4000 ); |
| 4834 | | memory_configure_bank( TO8_SYS_HI, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 4835 | | memory_configure_bank( TO8_DATA_LO, 0, 8, mess_ram + 0x2000, 0x4000 ); |
| 4836 | | memory_configure_bank( TO8_DATA_HI, 0, 8, mess_ram + 0x0000, 0x4000 ); |
| 4837 | | memory_configure_bank( TO8_BIOS_BANK, 0, 2, mem + 0x23000, 0x4000 ); |
| 4838 | | memory_set_bank( THOM_CART_BANK, 0 ); |
| 4839 | | memory_set_bank( THOM_VRAM_BANK, 0 ); |
| 4840 | | memory_set_bank( TO8_SYS_LO, 0 ); |
| 4841 | | memory_set_bank( TO8_SYS_HI, 0 ); |
| 4842 | | memory_set_bank( TO8_DATA_LO, 0 ); |
| 4843 | | memory_set_bank( TO8_DATA_HI, 0 ); |
| 4844 | | memory_set_bank( TO8_BIOS_BANK, 0 ); |
| 4828 | memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 4829 | memory_configure_bank( machine, THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 ); |
| 4830 | memory_configure_bank( machine, THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 ); |
| 4831 | memory_configure_bank( machine, THOM_CART_BANK, 8, 8, mess_ram, 0x4000 ); |
| 4832 | memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 ); |
| 4833 | memory_configure_bank( machine, TO8_SYS_LO, 0, 1, mess_ram + 0x6000, 0x4000 ); |
| 4834 | memory_configure_bank( machine, TO8_SYS_HI, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 4835 | memory_configure_bank( machine, TO8_DATA_LO, 0, 8, mess_ram + 0x2000, 0x4000 ); |
| 4836 | memory_configure_bank( machine, TO8_DATA_HI, 0, 8, mess_ram + 0x0000, 0x4000 ); |
| 4837 | memory_configure_bank( machine, TO8_BIOS_BANK, 0, 2, mem + 0x23000, 0x4000 ); |
| 4838 | memory_set_bank( machine, THOM_CART_BANK, 0 ); |
| 4839 | memory_set_bank( machine, THOM_VRAM_BANK, 0 ); |
| 4840 | memory_set_bank( machine, TO8_SYS_LO, 0 ); |
| 4841 | memory_set_bank( machine, TO8_SYS_HI, 0 ); |
| 4842 | memory_set_bank( machine, TO8_DATA_LO, 0 ); |
| 4843 | memory_set_bank( machine, TO8_DATA_HI, 0 ); |
| 4844 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 4845 | 4845 | |
| 4846 | 4846 | /* save-state */ |
| 4847 | 4847 | state_save_register_global( thom_cart_nb_banks ); |
| r3658 | r3659 | |
| 4874 | 4874 | READ8_HANDLER ( mo5nr_net_r ) |
| 4875 | 4875 | { |
| 4876 | 4876 | if ( to7_controller_type ) |
| 4877 | | return to7_floppy_r ( machine, offset ); |
| 4877 | return to7_floppy_r ( space, offset ); |
| 4878 | 4878 | |
| 4879 | | logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset ); |
| 4879 | logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset ); |
| 4880 | 4880 | |
| 4881 | 4881 | if ( to7_controller_type ) |
| 4882 | | return to7_floppy_r ( machine, offset ); |
| 4882 | return to7_floppy_r ( space, offset ); |
| 4883 | 4883 | |
| 4884 | 4884 | return 0; |
| 4885 | 4885 | } |
| r3658 | r3659 | |
| 4889 | 4889 | WRITE8_HANDLER ( mo5nr_net_w ) |
| 4890 | 4890 | { |
| 4891 | 4891 | if ( to7_controller_type ) |
| 4892 | | to7_floppy_w ( machine, offset, data ); |
| 4892 | to7_floppy_w ( space, offset, data ); |
| 4893 | 4893 | else |
| 4894 | 4894 | logerror( "$%04x %f mo5nr_net_w: write $%02X to reg %i\n", |
| 4895 | | activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data, offset ); |
| 4895 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data, offset ); |
| 4896 | 4896 | } |
| 4897 | 4897 | |
| 4898 | 4898 | |
| r3658 | r3659 | |
| 4920 | 4920 | return 0x80; |
| 4921 | 4921 | |
| 4922 | 4922 | default: |
| 4923 | | logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset ); |
| 4923 | logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset ); |
| 4924 | 4924 | return 0; |
| 4925 | 4925 | } |
| 4926 | 4926 | } |
| r3658 | r3659 | |
| 4942 | 4942 | break; |
| 4943 | 4943 | |
| 4944 | 4944 | default: |
| 4945 | | logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset, data ); |
| 4945 | logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset, data ); |
| 4946 | 4946 | } |
| 4947 | 4947 | } |
| 4948 | 4948 | |
| r3658 | r3659 | |
| 4961 | 4961 | static const char *keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", |
| 4962 | 4962 | "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" }; |
| 4963 | 4963 | |
| 4964 | | return ( input_port_read(machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0; |
| 4964 | return ( input_port_read(space->machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0; |
| 4965 | 4965 | /* bit 7: key up */ |
| 4966 | 4966 | } |
| 4967 | 4967 | |
| r3658 | r3659 | |
| 4970 | 4970 | static WRITE8_HANDLER ( mo5nr_sys_porta_out ) |
| 4971 | 4971 | { |
| 4972 | 4972 | /* no keyboard LED */ |
| 4973 | | thom_set_mode_point( data & 1 ); /* bit 0: video bank switch */ |
| 4973 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 4974 | 4974 | to7_game_mute = data & 4; /* bit 2: sound mute */ |
| 4975 | | mo5_set_cassette( machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 4976 | | mo6_update_cart_bank(machine); /* bit 5: rom bank */ |
| 4975 | mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 4976 | mo6_update_cart_bank(space->machine); /* bit 5: rom bank */ |
| 4977 | 4977 | to7_game_sound_update(); |
| 4978 | 4978 | } |
| 4979 | 4979 | |
| r3658 | r3659 | |
| 5062 | 5062 | thom_set_video_mode( THOM_VMODE_MO5 ); |
| 5063 | 5063 | thom_set_lightpen_callback( 3, to8_lightpen_cb ); |
| 5064 | 5064 | thom_set_border_color( 0 ); |
| 5065 | | thom_set_mode_point( 0 ); |
| 5065 | thom_set_mode_point( machine, 0 ); |
| 5066 | 5066 | pia_set_input_ca1( THOM_PIA_SYS, 0 ); |
| 5067 | 5067 | |
| 5068 | 5068 | /* memory */ |
| 5069 | 5069 | to8_cart_vpage = 0; |
| 5070 | 5070 | to8_data_vpage = 0; |
| 5071 | | mo6_update_ram_bank(); |
| 5071 | mo6_update_ram_bank(machine); |
| 5072 | 5072 | mo6_update_cart_bank(machine); |
| 5073 | 5073 | /* mo5_reg_cart not reset */ |
| 5074 | 5074 | /* thom_cart_bank not reset */ |
| r3658 | r3659 | |
| 5099 | 5099 | thom_cart_bank = 0; |
| 5100 | 5100 | mo5_reg_cart = 0; |
| 5101 | 5101 | thom_vram = mess_ram; |
| 5102 | | memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 5103 | | memory_configure_bank( THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 ); |
| 5104 | | memory_configure_bank( THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 ); |
| 5105 | | memory_configure_bank( THOM_CART_BANK, 8, 8, mess_ram, 0x4000 ); |
| 5106 | | memory_configure_bank( THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 ); |
| 5107 | | memory_configure_bank( TO8_SYS_LO, 0, 1, mess_ram + 0x6000, 0x4000 ); |
| 5108 | | memory_configure_bank( TO8_SYS_HI, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 5109 | | memory_configure_bank( TO8_DATA_LO, 0, 8, mess_ram + 0x2000, 0x4000 ); |
| 5110 | | memory_configure_bank( TO8_DATA_HI, 0, 8, mess_ram + 0x0000, 0x4000 ); |
| 5111 | | memory_configure_bank( TO8_BIOS_BANK, 0, 2, mem + 0x23000, 0x4000 ); |
| 5112 | | memory_set_bank( THOM_CART_BANK, 0 ); |
| 5113 | | memory_set_bank( THOM_VRAM_BANK, 0 ); |
| 5114 | | memory_set_bank( TO8_SYS_LO, 0 ); |
| 5115 | | memory_set_bank( TO8_SYS_HI, 0 ); |
| 5116 | | memory_set_bank( TO8_DATA_LO, 0 ); |
| 5117 | | memory_set_bank( TO8_DATA_HI, 0 ); |
| 5118 | | memory_set_bank( TO8_BIOS_BANK, 0 ); |
| 5102 | memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 ); |
| 5103 | memory_configure_bank( machine, THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 ); |
| 5104 | memory_configure_bank( machine, THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 ); |
| 5105 | memory_configure_bank( machine, THOM_CART_BANK, 8, 8, mess_ram, 0x4000 ); |
| 5106 | memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 ); |
| 5107 | memory_configure_bank( machine, TO8_SYS_LO, 0, 1, mess_ram + 0x6000, 0x4000 ); |
| 5108 | memory_configure_bank( machine, TO8_SYS_HI, 0, 1, mess_ram + 0x4000, 0x4000 ); |
| 5109 | memory_configure_bank( machine, TO8_DATA_LO, 0, 8, mess_ram + 0x2000, 0x4000 ); |
| 5110 | memory_configure_bank( machine, TO8_DATA_HI, 0, 8, mess_ram + 0x0000, 0x4000 ); |
| 5111 | memory_configure_bank( machine, TO8_BIOS_BANK, 0, 2, mem + 0x23000, 0x4000 ); |
| 5112 | memory_set_bank( machine, THOM_CART_BANK, 0 ); |
| 5113 | memory_set_bank( machine, THOM_VRAM_BANK, 0 ); |
| 5114 | memory_set_bank( machine, TO8_SYS_LO, 0 ); |
| 5115 | memory_set_bank( machine, TO8_SYS_HI, 0 ); |
| 5116 | memory_set_bank( machine, TO8_DATA_LO, 0 ); |
| 5117 | memory_set_bank( machine, TO8_DATA_HI, 0 ); |
| 5118 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 5119 | 5119 | |
| 5120 | 5120 | /* save-state */ |
| 5121 | 5121 | state_save_register_global( thom_cart_nb_banks ); |
src/mess/devices/thomflop.c
| r3658 | r3659 | |
| 278 | 278 | static READ8_HANDLER ( to7_5p14_r ) |
| 279 | 279 | { |
| 280 | 280 | if ( offset < 4 ) |
| 281 | | return wd17xx_r( machine, offset ); |
| 281 | return wd17xx_r( space, offset ); |
| 282 | 282 | else if ( offset == 8 ) |
| 283 | 283 | return to7_5p14_select; |
| 284 | 284 | else |
| 285 | | logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset ); |
| 285 | logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset ); |
| 286 | 286 | return 0; |
| 287 | 287 | } |
| 288 | 288 | |
| r3658 | r3659 | |
| 291 | 291 | static WRITE8_HANDLER( to7_5p14_w ) |
| 292 | 292 | { |
| 293 | 293 | if ( offset < 4 ) |
| 294 | | wd17xx_w( machine, offset, data ); |
| 294 | wd17xx_w( space, offset, data ); |
| 295 | 295 | else if ( offset == 8 ) |
| 296 | 296 | { |
| 297 | 297 | /* drive select */ |
| r3658 | r3659 | |
| 306 | 306 | case 4: drive = 2; side = 0; break; |
| 307 | 307 | case 5: drive = 3; side = 1; break; |
| 308 | 308 | default: |
| 309 | | logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ); |
| 309 | logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | dens = (data & 0x80) ? DEN_FM_LO : DEN_MFM_LO; |
| r3658 | r3659 | |
| 321 | 321 | wd17xx_set_drive( drive ); |
| 322 | 322 | wd17xx_set_side( side ); |
| 323 | 323 | LOG(( "%f $%04x to7_5p14_w: $%02X set drive=%i side=%i density=%s\n", |
| 324 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), |
| 324 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), |
| 325 | 325 | data, drive, side, (dens == DEN_FM_LO) ? "FM" : "MFM" )); |
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | else |
| 329 | 329 | logerror ( "%f $%04x to7_5p14_w: invalid write offset %i (data=$%02X)\n", |
| 330 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data ); |
| 330 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data ); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | |
| r3658 | r3659 | |
| 375 | 375 | static READ8_HANDLER ( to7_5p14sd_r ) |
| 376 | 376 | { |
| 377 | 377 | if ( offset < 8 ) |
| 378 | | return mc6843_r( machine, offset ); |
| 378 | return mc6843_r( space, offset ); |
| 379 | 379 | else if ( offset >= 8 && offset <= 9 ) |
| 380 | 380 | return to7_5p14sd_select; |
| 381 | 381 | else |
| 382 | | logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset ); |
| 382 | logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset ); |
| 383 | 383 | return 0; |
| 384 | 384 | } |
| 385 | 385 | |
| r3658 | r3659 | |
| 388 | 388 | static WRITE8_HANDLER( to7_5p14sd_w ) |
| 389 | 389 | { |
| 390 | 390 | if ( offset < 8 ) |
| 391 | | mc6843_w( machine, offset, data ); |
| 391 | mc6843_w( space, offset, data ); |
| 392 | 392 | else if ( offset >= 8 && offset <= 9 ) |
| 393 | 393 | { |
| 394 | 394 | /* drive select */ |
| r3658 | r3659 | |
| 423 | 423 | mc6843_set_drive( drive ); |
| 424 | 424 | mc6843_set_side( side ); |
| 425 | 425 | LOG(( "%f $%04x to7_5p14sd_w: $%02X set drive=%i side=%i\n", |
| 426 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, drive, side )); |
| 426 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, drive, side )); |
| 427 | 427 | } |
| 428 | 428 | } |
| 429 | 429 | else |
| 430 | 430 | logerror ( "%f $%04x to7_5p14sd_w: invalid write offset %i (data=$%02X)\n", |
| 431 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data ); |
| 431 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data ); |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | |
| r3658 | r3659 | |
| 604 | 604 | else |
| 605 | 605 | data = to7qdd->data[ to7qdd->data_idx ]; |
| 606 | 606 | |
| 607 | | VLOG(( "%f $%04x to7_qdd_read_byte: RDATA off=%i/%i data=$%02X\n", |
| 608 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), |
| 609 | | to7qdd->data_idx, to7qdd->data_size, data )); |
| 607 | // VLOG(( "%f $%04x to7_qdd_read_byte: RDATA off=%i/%i data=$%02X\n", |
| 608 | // attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), |
| 609 | // to7qdd->data_idx, to7qdd->data_size, data )); |
| 610 | 610 | |
| 611 | 611 | to7qdd->data_idx++; |
| 612 | 612 | to7qdd->start_idx = to7qdd->data_idx; |
| r3658 | r3659 | |
| 645 | 645 | to7qdd->data[ to7qdd->data_idx ] = data; |
| 646 | 646 | to7qdd->data_idx++; |
| 647 | 647 | |
| 648 | | VLOG (( "%f $%04x to7_qdd_write_byte: got $%02X offs=%i-%i\n", |
| 649 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 650 | | to7qdd->start_idx, to7qdd->data_idx )); |
| 648 | // VLOG (( "%f $%04x to7_qdd_write_byte: got $%02X offs=%i-%i\n", |
| 649 | // attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 650 | // to7qdd->start_idx, to7qdd->data_idx )); |
| 651 | 651 | |
| 652 | 652 | /* end of tentative id field */ |
| 653 | 653 | if ( to7qdd->data_idx == to7qdd->start_idx + 4 && |
| r3658 | r3659 | |
| 659 | 659 | int sector = (int) to7qdd->data[ to7qdd->start_idx + 1 ] * 256 + (int) to7qdd->data[ to7qdd->start_idx + 2 ]; |
| 660 | 660 | UINT8 filler = 0xff; |
| 661 | 661 | |
| 662 | | LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n", |
| 663 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector )); |
| 662 | // LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n", |
| 663 | // attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), sector )); |
| 664 | 664 | |
| 665 | 665 | floppy_drive_format_sector( to7_qdd_image(), |
| 666 | 666 | 0, sector, 0, 0, sector, 128, filler ); |
| r3658 | r3659 | |
| 688 | 688 | /* got an id & a data field => write */ |
| 689 | 689 | int sector = (int) to7qdd->data[ i + 1 ] * 256 + (int) to7qdd->data[ i + 2 ]; |
| 690 | 690 | |
| 691 | | LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n", |
| 692 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector )); |
| 691 | // LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n", |
| 692 | // attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), sector )); |
| 693 | 693 | |
| 694 | 694 | floppy_drive_write_sector_data( to7_qdd_image(), 0, sector, to7qdd->data + to7qdd->start_idx + 1, 128, 0 ); |
| 695 | 695 | } |
| r3658 | r3659 | |
| 711 | 711 | case 0: /* MC6852 status */ |
| 712 | 712 | to7_qdd_stat_update(); |
| 713 | 713 | VLOG(( "%f $%04x to7_qdd_r: STAT=$%02X irq=%i pe=%i ovr=%i und=%i tr=%i rd=%i ncts=%i\n", |
| 714 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), to7qdd->status, |
| 714 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), to7qdd->status, |
| 715 | 715 | to7qdd->status & QDD_S_IRQ ? 1 : 0, |
| 716 | 716 | to7qdd->status & QDD_S_PE ? 1 : 0, |
| 717 | 717 | to7qdd->status & QDD_S_OVR ? 1 : 0, |
| r3658 | r3659 | |
| 734 | 734 | data |= 0x40; /* disk present */ |
| 735 | 735 | if ( to7qdd->index_pulse ) |
| 736 | 736 | data |= 0x80; /* disk start */ |
| 737 | | VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 737 | VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 738 | 738 | return data; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | default: |
| 742 | | logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset ); |
| 742 | logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset ); |
| 743 | 743 | return 0; |
| 744 | 744 | } |
| 745 | 745 | } |
| r3658 | r3659 | |
| 761 | 761 | to7qdd->ctrl1 = ( data & ~(QDD_C1_RRESET | QDD_C1_TRESET) ) |( data & (QDD_C1_RRESET | QDD_C1_TRESET) & to7qdd->ctrl1 ); |
| 762 | 762 | to7_qdd_stat_update(); |
| 763 | 763 | VLOG(( "%f $%04x to7_qdd_w: CTRL1=$%02X reset=%c%c %s%sirq=%c%c\n", |
| 764 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 764 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 765 | 765 | data & QDD_C1_RRESET ? 'r' : '-', data & QDD_C1_TRESET ? 't' : '-', |
| 766 | 766 | data & QDD_C1_STRIPSYNC ? "strip-sync " : "", |
| 767 | 767 | data & QDD_C1_CLRSYNC ? "clear-sync " : "", |
| r3658 | r3659 | |
| 785 | 785 | parity = par[ (data >> 3) & 7 ]; |
| 786 | 786 | to7_qdd_stat_update(); |
| 787 | 787 | VLOG(( "%f $%04x to7_qdd_w: CTRL2=$%02X bits=%i par=%s blen=%i under=%s%s\n", |
| 788 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 788 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 789 | 789 | bits, parname[ parity ], data & QDD_C2_BLEN ? 1 : 2, |
| 790 | 790 | data & QDD_C2_TSYNC ? "sync" : "ff", |
| 791 | 791 | data & QDD_C2_EIE ? "irq-err" : "" )); |
| r3658 | r3659 | |
| 803 | 803 | to7qdd->status &= ~QDD_S_NCTS; |
| 804 | 804 | to7_qdd_stat_update(); |
| 805 | 805 | VLOG(( "%f $%04x to7_qdd_w: CTRL3=$%02X %s%ssync-len=%i sync-mode=%s\n", |
| 806 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 806 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 807 | 807 | data & QDD_C3_CLRTUF ? "clr-tuf " : "", |
| 808 | 808 | data & QDD_C3_CLRCTS ? "clr-cts " : "", |
| 809 | 809 | data & QDD_C3_SYNCLEN ? 1 : 2, |
| r3658 | r3659 | |
| 815 | 815 | break; |
| 816 | 816 | |
| 817 | 817 | case 3: /* MC6852 data out => does not seem to be used */ |
| 818 | | VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 818 | VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 819 | 819 | break; |
| 820 | 820 | |
| 821 | 821 | } |
| r3658 | r3659 | |
| 823 | 823 | |
| 824 | 824 | case 8: /* set drive */ |
| 825 | 825 | to7qdd->drive = data; |
| 826 | | VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 826 | VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 827 | 827 | break; |
| 828 | 828 | |
| 829 | 829 | case 12: /* motor pulse ? */ |
| 830 | 830 | thom_floppy_active( 0 ); |
| 831 | | VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 831 | VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 832 | 832 | break; |
| 833 | 833 | |
| 834 | 834 | default: |
| 835 | | logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data ); |
| 835 | logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data ); |
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | 838 | |
| r3658 | r3659 | |
| 1058 | 1058 | { |
| 1059 | 1059 | UINT8 data = thmfc1->data[ thmfc1->data_idx ]; |
| 1060 | 1060 | |
| 1061 | | VLOG(( "%f $%04x thmfc_floppy_read_byte: off=%i/%i/%i data=$%02X\n", |
| 1062 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), |
| 1063 | | thmfc1->data_idx, thmfc1->data_finish - 1, thmfc1->data_size - 1, |
| 1064 | | data )); |
| 1061 | // VLOG(( "%f $%04x thmfc_floppy_read_byte: off=%i/%i/%i data=$%02X\n", |
| 1062 | // attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), |
| 1063 | // thmfc1->data_idx, thmfc1->data_finish - 1, thmfc1->data_size - 1, |
| 1064 | // data )); |
| 1065 | 1065 | |
| 1066 | 1066 | if ( thmfc1->data_idx >= thmfc1->data_size - 1 ) |
| 1067 | 1067 | thmfc_floppy_cmd_complete(); |
| r3658 | r3659 | |
| 1101 | 1101 | else |
| 1102 | 1102 | data = thmfc1->data[ thmfc1->data_raw_idx ]; |
| 1103 | 1103 | |
| 1104 | | VLOG(( "%f $%04x thmfc_floppy_raw_read_byte: off=%i/%i data=$%02X\n", |
| 1105 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), |
| 1106 | | thmfc1->data_raw_idx, thmfc1->data_raw_size, data )); |
| 1104 | // VLOG(( "%f $%04x thmfc_floppy_raw_read_byte: off=%i/%i data=$%02X\n", |
| 1105 | // attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), |
| 1106 | // thmfc1->data_raw_idx, thmfc1->data_raw_size, data )); |
| 1107 | 1107 | |
| 1108 | 1108 | thmfc1->data_raw_idx++; |
| 1109 | 1109 | |
| r3658 | r3659 | |
| 1139 | 1139 | thmfc1->data_idx = thmfc1->data_raw_idx; |
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | | VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: $%02X offs=%i-%i\n", |
| 1143 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 1144 | | thmfc1->data_idx,thmfc1->data_raw_idx )); |
| 1142 | // VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: $%02X offs=%i-%i\n", |
| 1143 | // attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 1144 | // thmfc1->data_idx,thmfc1->data_raw_idx )); |
| 1145 | 1145 | |
| 1146 | 1146 | if ( thmfc1->data_raw_idx == thmfc1->data_idx + 3 && |
| 1147 | 1147 | thmfc1->data[ thmfc1->data_idx - 1 ] == 0xA5 && |
| r3658 | r3659 | |
| 1152 | 1152 | int sector = (int) thmfc1->data[ thmfc1->data_idx ] * 256 + (int) thmfc1->data[ thmfc1->data_idx + 1 ]; |
| 1153 | 1153 | UINT8 filler = 0xff; |
| 1154 | 1154 | |
| 1155 | | LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector )); |
| 1155 | // LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), sector )); |
| 1156 | 1156 | |
| 1157 | 1157 | floppy_drive_format_sector( thmfc_floppy_image(), 0, sector, 0, 0, sector, 128, filler ); |
| 1158 | 1158 | thmfc1->data_idx = 0; |
| r3658 | r3659 | |
| 1180 | 1180 | int sector = (int) thmfc1->data[ i + 1 ] * 256 + |
| 1181 | 1181 | (int) thmfc1->data[ i + 2 ]; |
| 1182 | 1182 | |
| 1183 | | LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n", |
| 1184 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector )); |
| 1183 | // LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n", |
| 1184 | // attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), sector )); |
| 1185 | 1185 | |
| 1186 | 1186 | floppy_drive_write_sector_data( img, 0, sector, thmfc1->data + thmfc1->data_idx, 128, 0 ); |
| 1187 | 1187 | } |
| r3658 | r3659 | |
| 1195 | 1195 | else |
| 1196 | 1196 | { |
| 1197 | 1197 | thmfc1->data_raw_idx++; |
| 1198 | | VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 1198 | // VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | 1201 | } |
| r3658 | r3659 | |
| 1205 | 1205 | /* intelligent writing */ |
| 1206 | 1206 | static void thmfc_floppy_write_byte ( UINT8 data ) |
| 1207 | 1207 | { |
| 1208 | | VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n", |
| 1209 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), |
| 1210 | | thmfc1->data_idx, thmfc1->data_size - 1, data )); |
| 1208 | // VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n", |
| 1209 | // attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), |
| 1210 | // thmfc1->data_idx, thmfc1->data_size - 1, data )); |
| 1211 | 1211 | |
| 1212 | 1212 | thmfc1->data_raw_size = 0; |
| 1213 | 1213 | thmfc1->data[ thmfc1->data_idx ] = data; |
| r3658 | r3659 | |
| 1220 | 1220 | /* intelligent formatting */ |
| 1221 | 1221 | static void thmfc_floppy_format_byte ( UINT8 data ) |
| 1222 | 1222 | { |
| 1223 | | VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 1223 | // VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 1224 | 1224 | |
| 1225 | 1225 | thmfc1->data_raw_size = 0; |
| 1226 | 1226 | |
| r3658 | r3659 | |
| 1260 | 1260 | |
| 1261 | 1261 | case 0: /* STAT0 */ |
| 1262 | 1262 | thmfc1->stat0 ^= THMFC1_STAT0_SYNCHRO | THMFC1_STAT0_BYTE_READY_POL; |
| 1263 | | VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), thmfc1->stat0 )); |
| 1263 | VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), thmfc1->stat0 )); |
| 1264 | 1264 | return thmfc1->stat0; |
| 1265 | 1265 | |
| 1266 | 1266 | case 1: /* STAT1 */ |
| r3658 | r3659 | |
| 1291 | 1291 | data |= 0x10; |
| 1292 | 1292 | if ( flags & FLOPPY_DRIVE_DISK_WRITE_PROTECTED ) |
| 1293 | 1293 | data |= 0x04; |
| 1294 | | VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 1294 | VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 1295 | 1295 | return data; |
| 1296 | 1296 | } |
| 1297 | 1297 | |
| r3658 | r3659 | |
| 1309 | 1309 | { |
| 1310 | 1310 | /* undocumented => emulate TO7 QDD controller ? */ |
| 1311 | 1311 | UINT8 data = thmfc1->ipl << 7; |
| 1312 | | VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 1312 | VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 1313 | 1313 | return data; |
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | default: |
| 1317 | | logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset ); |
| 1317 | logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset ); |
| 1318 | 1318 | return 0; |
| 1319 | 1319 | } |
| 1320 | 1320 | } |
| r3658 | r3659 | |
| 1334 | 1334 | thom_floppy_set_density( dens ); |
| 1335 | 1335 | thmfc1->formatting = (data >> 2) & 1; |
| 1336 | 1336 | LOG (( "%f $%04x thmfc_floppy_w: CMD0=$%02X dens=%s wsync=%i dsync=%i fmt=%i op=%i\n", |
| 1337 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 1337 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 1338 | 1338 | (dens == DEN_FM_LO) ? "MF" : "MFM", |
| 1339 | 1339 | wsync, (data >> 3) & 1, |
| 1340 | 1340 | thmfc1->formatting, data & 3 )); |
| r3658 | r3659 | |
| 1419 | 1419 | if ( thmfc1->sector_size > 256 ) |
| 1420 | 1420 | { |
| 1421 | 1421 | logerror( "$%04x thmfc_floppy_w: sector size %i > 256 not handled\n", |
| 1422 | | activecpu_get_previouspc(), thmfc1->sector_size ); |
| 1422 | cpu_get_previouspc(space->cpu), thmfc1->sector_size ); |
| 1423 | 1423 | thmfc1->sector_size = 256; |
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | 1426 | LOG (( "%f $%04x thmfc_floppy_w: CMD1=$%02X sect-size=%i comp=%i head=%i\n", |
| 1427 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 1427 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 1428 | 1428 | thmfc1->sector_size, (data >> 1) & 7, thmfc1->side )); |
| 1429 | 1429 | break; |
| 1430 | 1430 | |
| r3658 | r3659 | |
| 1452 | 1452 | thom_floppy_active( 0 ); |
| 1453 | 1453 | |
| 1454 | 1454 | LOG (( "%f $%04x thmfc_floppy_w: CMD2=$%02X drv=%i step=%i motor=%i\n", |
| 1455 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 1455 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 1456 | 1456 | thmfc1->drive, seek, motor )); |
| 1457 | 1457 | |
| 1458 | 1458 | if ( seek ) |
| r3658 | r3659 | |
| 1482 | 1482 | { |
| 1483 | 1483 | /* TODO: implement other forms of raw track writing */ |
| 1484 | 1484 | LOG (( "%f $%04x thmfc_floppy_w: ignored raw WDATA $%02X\n", |
| 1485 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 1485 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 1486 | 1486 | } |
| 1487 | 1487 | break; |
| 1488 | 1488 | |
| r3658 | r3659 | |
| 1490 | 1490 | case 4: /* WCLK (unemulated) */ |
| 1491 | 1491 | /* clock configuration: FF for data, 0A for synchro */ |
| 1492 | 1492 | LOG (( "%f $%04x thmfc_floppy_w: WCLK=$%02X (%s)\n", |
| 1493 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 1493 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 1494 | 1494 | (data == 0xff) ? "data" : (data == 0x0A) ? "synchro" : "?" )); |
| 1495 | 1495 | break; |
| 1496 | 1496 | |
| 1497 | 1497 | case 5: /* WSECT */ |
| 1498 | 1498 | thmfc1->sector = data; |
| 1499 | 1499 | LOG (( "%f $%04x thmfc_floppy_w: WSECT=%i\n", |
| 1500 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 1500 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 1501 | 1501 | break; |
| 1502 | 1502 | |
| 1503 | 1503 | case 6: /* WTRCK */ |
| 1504 | 1504 | thmfc1->track = data; |
| 1505 | 1505 | LOG (( "%f $%04x thmfc_floppy_w: WTRCK=%i (real=%i)\n", |
| 1506 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, |
| 1506 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, |
| 1507 | 1507 | floppy_drive_get_current_track( thmfc_floppy_image() ) )); |
| 1508 | 1508 | break; |
| 1509 | 1509 | |
| 1510 | 1510 | case 7: /* WCELL */ |
| 1511 | 1511 | /* precompensation (unemulated) */ |
| 1512 | 1512 | LOG (( "%f $%04x thmfc_floppy_w: WCELL=$%02X\n", |
| 1513 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data )); |
| 1513 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data )); |
| 1514 | 1514 | break; |
| 1515 | 1515 | |
| 1516 | 1516 | default: |
| 1517 | 1517 | logerror ( "%f $%04x thmfc_floppy_w: invalid write offset %i (data=$%02X)\n", |
| 1518 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data ); |
| 1518 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data ); |
| 1519 | 1519 | } |
| 1520 | 1520 | } |
| 1521 | 1521 | |
| r3658 | r3659 | |
| 1711 | 1711 | static READ8_HANDLER ( to7_network_r ) |
| 1712 | 1712 | { |
| 1713 | 1713 | if ( offset >= 0 && offset < 4 ) |
| 1714 | | return mc6854_r( machine, offset ); |
| 1714 | return mc6854_r( space, offset ); |
| 1715 | 1715 | |
| 1716 | 1716 | if ( offset == 8 ) |
| 1717 | 1717 | { |
| 1718 | 1718 | /* network ID of the computer */ |
| 1719 | | UINT8 id = input_port_read(machine, "fconfig") >> 3; |
| 1720 | | VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), id )); |
| 1719 | UINT8 id = input_port_read(space->machine, "fconfig") >> 3; |
| 1720 | VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), id )); |
| 1721 | 1721 | return id; |
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | | logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset ); |
| 1724 | logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset ); |
| 1725 | 1725 | return 0; |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| r3658 | r3659 | |
| 1730 | 1730 | static WRITE8_HANDLER ( to7_network_w ) |
| 1731 | 1731 | { |
| 1732 | 1732 | if ( offset >= 0 && offset < 4 ) |
| 1733 | | mc6854_w( machine, offset, data ); |
| 1733 | mc6854_w( space, offset, data ); |
| 1734 | 1734 | else |
| 1735 | 1735 | { |
| 1736 | 1736 | logerror( "%f $%04x to7_network_w: invalid write offset %i (data=$%02X)\n", |
| 1737 | | attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data ); |
| 1737 | attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data ); |
| 1738 | 1738 | } |
| 1739 | 1739 | } |
| 1740 | 1740 | |
| r3658 | r3659 | |
| 1760 | 1760 | |
| 1761 | 1761 | void to7_floppy_init ( running_machine *machine, void* base ) |
| 1762 | 1762 | { |
| 1763 | | memory_configure_bank( THOM_FLOP_BANK, 0, TO7_NB_FLOP_BANK, base, 0x800 ); |
| 1763 | memory_configure_bank( machine, THOM_FLOP_BANK, 0, TO7_NB_FLOP_BANK, base, 0x800 ); |
| 1764 | 1764 | state_save_register_global( to7_controller_type ); |
| 1765 | 1765 | state_save_register_global( to7_floppy_bank ); |
| 1766 | 1766 | to7_5p14sd_init(machine); |
| r3658 | r3659 | |
| 1809 | 1809 | break; |
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | | memory_set_bank( THOM_FLOP_BANK, to7_floppy_bank ); |
| 1812 | memory_set_bank( machine, THOM_FLOP_BANK, to7_floppy_bank ); |
| 1813 | 1813 | } |
| 1814 | 1814 | |
| 1815 | 1815 | |
| r3658 | r3659 | |
| 1820 | 1820 | { |
| 1821 | 1821 | |
| 1822 | 1822 | case 1: |
| 1823 | | return to7_5p14sd_r( machine, offset ); |
| 1823 | return to7_5p14sd_r( space, offset ); |
| 1824 | 1824 | |
| 1825 | 1825 | case 2: |
| 1826 | | return to7_5p14_r( machine, offset ); |
| 1826 | return to7_5p14_r( space, offset ); |
| 1827 | 1827 | |
| 1828 | 1828 | case 3: |
| 1829 | | return thmfc_floppy_r( machine, offset ); |
| 1829 | return thmfc_floppy_r( space, offset ); |
| 1830 | 1830 | |
| 1831 | 1831 | case 4: |
| 1832 | | return to7_qdd_r( machine, offset ); |
| 1832 | return to7_qdd_r( space, offset ); |
| 1833 | 1833 | |
| 1834 | 1834 | case 5: |
| 1835 | | return to7_network_r( machine, offset ); |
| 1835 | return to7_network_r( space, offset ); |
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | 1838 | return 0; |
| r3658 | r3659 | |
| 1846 | 1846 | { |
| 1847 | 1847 | |
| 1848 | 1848 | case 1: |
| 1849 | | to7_5p14sd_w( machine, offset, data ); |
| 1849 | to7_5p14sd_w( space, offset, data ); |
| 1850 | 1850 | return; |
| 1851 | 1851 | |
| 1852 | 1852 | case 2: |
| 1853 | | to7_5p14_w( machine, offset, data ); |
| 1853 | to7_5p14_w( space, offset, data ); |
| 1854 | 1854 | break; |
| 1855 | 1855 | |
| 1856 | 1856 | case 3: |
| 1857 | 1857 | if ( offset == 8 ) |
| 1858 | 1858 | { |
| 1859 | 1859 | to7_floppy_bank = 3 + (data & 3); |
| 1860 | | memory_set_bank( THOM_FLOP_BANK, to7_floppy_bank ); |
| 1860 | memory_set_bank( space->machine, THOM_FLOP_BANK, to7_floppy_bank ); |
| 1861 | 1861 | VLOG (( "to7_floppy_w: set CD 90-351 ROM bank to %i\n", data & 3 )); |
| 1862 | 1862 | } |
| 1863 | 1863 | else |
| 1864 | | thmfc_floppy_w( machine, offset, data ); |
| 1864 | thmfc_floppy_w( space, offset, data ); |
| 1865 | 1865 | break; |
| 1866 | 1866 | |
| 1867 | 1867 | case 4: |
| 1868 | | to7_qdd_w( machine, offset, data ); |
| 1868 | to7_qdd_w( space, offset, data ); |
| 1869 | 1869 | break; |
| 1870 | 1870 | |
| 1871 | 1871 | case 5: |
| 1872 | | to7_network_w( machine, offset, data ); |
| 1872 | to7_network_w( space, offset, data ); |
| 1873 | 1873 | break; |
| 1874 | 1874 | } |
| 1875 | 1875 | } |
| r3658 | r3659 | |
| 1887 | 1887 | void to9_floppy_init( running_machine *machine, void* int_base, void* ext_base ) |
| 1888 | 1888 | { |
| 1889 | 1889 | to7_floppy_init( machine, ext_base ); |
| 1890 | | memory_configure_bank( THOM_FLOP_BANK, TO7_NB_FLOP_BANK, 1, int_base, 0x800 ); |
| 1890 | memory_configure_bank( machine, THOM_FLOP_BANK, TO7_NB_FLOP_BANK, 1, int_base, 0x800 ); |
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | |
| r3658 | r3659 | |
| 1903 | 1903 | { |
| 1904 | 1904 | LOG(( "to9_floppy_reset: internal controller\n" )); |
| 1905 | 1905 | to7_5p14_reset(machine); |
| 1906 | | memory_set_bank( THOM_FLOP_BANK, TO7_NB_FLOP_BANK ); |
| 1906 | memory_set_bank( machine, THOM_FLOP_BANK, TO7_NB_FLOP_BANK ); |
| 1907 | 1907 | } |
| 1908 | 1908 | } |
| 1909 | 1909 | |
| r3658 | r3659 | |
| 1912 | 1912 | READ8_HANDLER ( to9_floppy_r ) |
| 1913 | 1913 | { |
| 1914 | 1914 | if ( THOM_FLOPPY_EXT ) |
| 1915 | | return to7_floppy_r( machine, offset ); |
| 1915 | return to7_floppy_r( space, offset ); |
| 1916 | 1916 | else |
| 1917 | | return to7_5p14_r( machine, offset ); |
| 1917 | return to7_5p14_r( space, offset ); |
| 1918 | 1918 | } |
| 1919 | 1919 | |
| 1920 | 1920 | WRITE8_HANDLER ( to9_floppy_w ) |
| 1921 | 1921 | { |
| 1922 | 1922 | if ( THOM_FLOPPY_EXT ) |
| 1923 | | to7_floppy_w( machine, offset, data ); |
| 1923 | to7_floppy_w( space, offset, data ); |
| 1924 | 1924 | else |
| 1925 | | to7_5p14_w( machine, offset, data ); |
| 1925 | to7_5p14_w( space, offset, data ); |
| 1926 | 1926 | } |