trunk/src/mess/machine/snesobc1.c
| r21599 | r21600 | |
| 17 | 17 | int address; |
| 18 | 18 | int offset; |
| 19 | 19 | int shift; |
| 20 | UINT8 ram[0x2000]; |
| 20 | 21 | }; |
| 21 | 22 | |
| 22 | 23 | static snes_obc1_state obc1_state; |
| r21599 | r21600 | |
| 30 | 31 | switch (address) |
| 31 | 32 | { |
| 32 | 33 | case 0x1ff0: |
| 33 | | value = snes_ram[obc1_state.offset + (obc1_state.address << 2) + 0]; |
| 34 | value = obc1_state.ram[obc1_state.offset + (obc1_state.address << 2) + 0]; |
| 34 | 35 | break; |
| 35 | 36 | |
| 36 | 37 | case 0x1ff1: |
| 37 | | value = snes_ram[obc1_state.offset + (obc1_state.address << 2) + 1]; |
| 38 | value = obc1_state.ram[obc1_state.offset + (obc1_state.address << 2) + 1]; |
| 38 | 39 | break; |
| 39 | 40 | |
| 40 | 41 | case 0x1ff2: |
| 41 | | value = snes_ram[obc1_state.offset + (obc1_state.address << 2) + 2]; |
| 42 | value = obc1_state.ram[obc1_state.offset + (obc1_state.address << 2) + 2]; |
| 42 | 43 | break; |
| 43 | 44 | |
| 44 | 45 | case 0x1ff3: |
| 45 | | value = snes_ram[obc1_state.offset + (obc1_state.address << 2) + 3]; |
| 46 | value = obc1_state.ram[obc1_state.offset + (obc1_state.address << 2) + 3]; |
| 46 | 47 | break; |
| 47 | 48 | |
| 48 | 49 | case 0x1ff4: |
| 49 | | value = snes_ram[obc1_state.offset + (obc1_state.address >> 2) + 0x200]; |
| 50 | value = obc1_state.ram[obc1_state.offset + (obc1_state.address >> 2) + 0x200]; |
| 50 | 51 | break; |
| 51 | 52 | |
| 52 | 53 | default: |
| 53 | | value = snes_ram[address]; |
| 54 | value = obc1_state.ram[address]; |
| 54 | 55 | break; |
| 55 | 56 | } |
| 56 | 57 | |
| r21599 | r21600 | |
| 66 | 67 | switch(address) |
| 67 | 68 | { |
| 68 | 69 | case 0x1ff0: |
| 69 | | snes_ram[obc1_state.offset + (obc1_state.address << 2) + 0] = data; |
| 70 | obc1_state.ram[obc1_state.offset + (obc1_state.address << 2) + 0] = data; |
| 70 | 71 | break; |
| 71 | 72 | |
| 72 | 73 | case 0x1ff1: |
| 73 | | snes_ram[obc1_state.offset + (obc1_state.address << 2) + 1] = data; |
| 74 | obc1_state.ram[obc1_state.offset + (obc1_state.address << 2) + 1] = data; |
| 74 | 75 | break; |
| 75 | 76 | |
| 76 | 77 | case 0x1ff2: |
| 77 | | snes_ram[obc1_state.offset + (obc1_state.address << 2) + 2] = data; |
| 78 | obc1_state.ram[obc1_state.offset + (obc1_state.address << 2) + 2] = data; |
| 78 | 79 | break; |
| 79 | 80 | |
| 80 | 81 | case 0x1ff3: |
| 81 | | snes_ram[obc1_state.offset + (obc1_state.address << 2) + 3] = data; |
| 82 | obc1_state.ram[obc1_state.offset + (obc1_state.address << 2) + 3] = data; |
| 82 | 83 | break; |
| 83 | 84 | |
| 84 | 85 | case 0x1ff4: |
| 85 | | temp = snes_ram[obc1_state.offset + (obc1_state.address >> 2) + 0x200]; |
| 86 | temp = obc1_state.ram[obc1_state.offset + (obc1_state.address >> 2) + 0x200]; |
| 86 | 87 | temp = (temp & ~(3 << obc1_state.shift)) | ((data & 0x03) << obc1_state.shift); |
| 87 | | snes_ram[obc1_state.offset + (obc1_state.address >> 2) + 0x200] = temp; |
| 88 | obc1_state.ram[obc1_state.offset + (obc1_state.address >> 2) + 0x200] = temp; |
| 88 | 89 | break; |
| 89 | 90 | |
| 90 | 91 | case 0x1ff5: |
| 91 | 92 | obc1_state.offset = (data & 0x01) ? 0x1800 : 0x1c00; |
| 92 | | snes_ram[address & 0x1fff] = data; |
| 93 | obc1_state.ram[address & 0x1fff] = data; |
| 93 | 94 | break; |
| 94 | 95 | |
| 95 | 96 | case 0x1ff6: |
| 96 | 97 | obc1_state.address = data & 0x7f; |
| 97 | 98 | obc1_state.shift = (data & 0x03) << 1; |
| 98 | | snes_ram[address & 0x1fff] = data; |
| 99 | obc1_state.ram[address & 0x1fff] = data; |
| 99 | 100 | break; |
| 100 | 101 | |
| 101 | 102 | default: |
| 102 | | snes_ram[address & 0x1fff] = data; |
| 103 | obc1_state.ram[address & 0x1fff] = data; |
| 103 | 104 | break; |
| 104 | 105 | } |
| 105 | 106 | } |
| 106 | 107 | |
| 107 | 108 | void obc1_init( running_machine &machine ) |
| 108 | 109 | { |
| 109 | | obc1_state.offset = (snes_ram[0x1ff5] & 0x01) ? 0x1800 : 0x1c00; |
| 110 | | obc1_state.address = (snes_ram[0x1ff6] & 0x7f); |
| 111 | | obc1_state.shift = (snes_ram[0x1ff6] & 0x03) << 1; |
| 110 | memset(obc1_state.ram, 0x00, sizeof(obc1_state.ram)); |
| 111 | obc1_state.offset = (obc1_state.ram[0x1ff5] & 0x01) ? 0x1800 : 0x1c00; |
| 112 | obc1_state.address = (obc1_state.ram[0x1ff6] & 0x7f); |
| 113 | obc1_state.shift = (obc1_state.ram[0x1ff6] & 0x03) << 1; |
| 112 | 114 | |
| 113 | 115 | state_save_register_global(machine, obc1_state.offset); |
| 114 | 116 | state_save_register_global(machine, obc1_state.address); |
| 115 | 117 | state_save_register_global(machine, obc1_state.shift); |
| 118 | state_save_register_global_array(machine, obc1_state.ram); |
| 116 | 119 | } |