trunk/src/emu/devcb.c
| r18445 | r18446 | |
| 51 | 51 | UINT8 devcb_resolved_write8::s_null; |
| 52 | 52 | UINT8 devcb_resolved_read16::s_null; |
| 53 | 53 | UINT8 devcb_resolved_write16::s_null; |
| 54 | UINT8 devcb_resolved_read32::s_null; |
| 55 | UINT8 devcb_resolved_write32::s_null; |
| 56 | UINT8 devcb_resolved_read64::s_null; |
| 57 | UINT8 devcb_resolved_write64::s_null; |
| 54 | 58 | |
| 55 | 59 | |
| 56 | 60 | |
| r18445 | r18446 | |
| 921 | 925 | { |
| 922 | 926 | m_object.execute->set_input_line(m_helper.input_line, (data & 1) ? ASSERT_LINE : CLEAR_LINE); |
| 923 | 927 | } |
| 928 | |
| 929 | //************************************************************************** |
| 930 | // DEVCB RESOLVED WRITE32 |
| 931 | //************************************************************************** |
| 932 | |
| 933 | //------------------------------------------------- |
| 934 | // devcb_resolved_write32 - empty constructor |
| 935 | //------------------------------------------------- |
| 936 | |
| 937 | devcb_resolved_write32::devcb_resolved_write32() |
| 938 | { |
| 939 | m_object.port = NULL; |
| 940 | m_helper.write_line = NULL; |
| 941 | } |
| 942 | |
| 943 | |
| 944 | //------------------------------------------------- |
| 945 | // resolve - resolve to a delegate from a static |
| 946 | // structure definition |
| 947 | //------------------------------------------------- |
| 948 | |
| 949 | void devcb_resolved_write32::resolve(const devcb_write32 &desc, device_t &device) |
| 950 | { |
| 951 | switch (desc.type) |
| 952 | { |
| 953 | default: |
| 954 | case DEVCB_TYPE_NULL: |
| 955 | m_helper.null_indicator = &s_null; |
| 956 | *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_null, "(null)", this); |
| 957 | break; |
| 958 | |
| 959 | case DEVCB_TYPE_IOPORT: |
| 960 | m_object.port = devcb_resolver::resolve_port(desc.tag, device); |
| 961 | *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_port, desc.tag, this); |
| 962 | break; |
| 963 | |
| 964 | case DEVCB_TYPE_DEVICE: |
| 965 | m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); |
| 966 | if (desc.writedevice != NULL) |
| 967 | { |
| 968 | m_helper.write32_device = desc.writedevice; |
| 969 | *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_write32, desc.name, this); |
| 970 | } |
| 971 | else |
| 972 | { |
| 973 | m_helper.write_line = desc.writeline; |
| 974 | *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_writeline, desc.name, this); |
| 975 | } |
| 976 | break; |
| 977 | |
| 978 | case DEVCB_TYPE_LEGACY_SPACE: |
| 979 | m_object.space = &devcb_resolver::resolve_space(desc.index, desc.tag, device); |
| 980 | *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(desc.writespace, desc.name, m_object.space); |
| 981 | break; |
| 982 | |
| 983 | case DEVCB_TYPE_INPUT_LINE: |
| 984 | m_object.execute = devcb_resolver::resolve_execute_interface(desc.tag, device); |
| 985 | m_helper.input_line = desc.index; |
| 986 | *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_input, desc.tag, this); |
| 987 | break; |
| 988 | |
| 989 | case DEVCB_TYPE_UNMAP: |
| 990 | m_helper.null_indicator = &s_null; |
| 991 | m_object.device = &device; |
| 992 | *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_unmap, "unmap", this); |
| 993 | break; |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | |
| 998 | //------------------------------------------------- |
| 999 | // to_null - helper to handle a NULL write |
| 1000 | //------------------------------------------------- |
| 1001 | |
| 1002 | void devcb_resolved_write32::to_null(offs_t offset, UINT32 data, UINT32 mask) |
| 1003 | { |
| 1004 | } |
| 1005 | |
| 1006 | |
| 1007 | //------------------------------------------------- |
| 1008 | // to_unmap - helper to handle a unmap write |
| 1009 | //------------------------------------------------- |
| 1010 | |
| 1011 | void devcb_resolved_write32::to_unmap(offs_t offset, UINT32 data, UINT32 mask) |
| 1012 | { |
| 1013 | logerror("%s: unmapped devcb write %s & %s\n", |
| 1014 | m_object.device->tag(), |
| 1015 | core_i64_format(data, 2 * sizeof(UINT32),false), |
| 1016 | core_i64_format(mask, 2 * sizeof(UINT32),false)); |
| 1017 | } |
| 1018 | |
| 1019 | //------------------------------------------------- |
| 1020 | // to_port - helper to convert to an I/O port |
| 1021 | // value from a line value |
| 1022 | //------------------------------------------------- |
| 1023 | |
| 1024 | void devcb_resolved_write32::to_port(offs_t offset, UINT32 data, UINT32 mask) |
| 1025 | { |
| 1026 | m_object.port->write(data, mask); |
| 1027 | } |
| 1028 | |
| 1029 | |
| 1030 | //------------------------------------------------- |
| 1031 | // to_write32 - helper to convert to a 32-bit |
| 1032 | // memory read value from a line value |
| 1033 | //------------------------------------------------- |
| 1034 | |
| 1035 | void devcb_resolved_write32::to_write32(offs_t offset, UINT32 data, UINT32 mask) |
| 1036 | { |
| 1037 | (*m_helper.write32_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, data, mask); |
| 1038 | } |
| 1039 | |
| 1040 | |
| 1041 | //------------------------------------------------- |
| 1042 | // to_write32 - helper to convert to a 32-bit |
| 1043 | // memory read value from a line value |
| 1044 | //------------------------------------------------- |
| 1045 | |
| 1046 | void devcb_resolved_write32::to_writeline(offs_t offset, UINT32 data, UINT32 mask) |
| 1047 | { |
| 1048 | (*m_helper.write_line)(m_object.device, (data & 1) ? ASSERT_LINE : CLEAR_LINE); |
| 1049 | } |
| 1050 | |
| 1051 | |
| 1052 | //------------------------------------------------- |
| 1053 | // to_input - helper to convert to a device input |
| 1054 | // value from a line value |
| 1055 | //------------------------------------------------- |
| 1056 | |
| 1057 | void devcb_resolved_write32::to_input(offs_t offset, UINT32 data, UINT32 mask) |
| 1058 | { |
| 1059 | m_object.execute->set_input_line(m_helper.input_line, (data & 1) ? ASSERT_LINE : CLEAR_LINE); |
| 1060 | } |
| 1061 | |
| 1062 | //************************************************************************** |
| 1063 | // DEVCB RESOLVED WRITE64 |
| 1064 | //************************************************************************** |
| 1065 | |
| 1066 | //------------------------------------------------- |
| 1067 | // devcb_resolved_write64 - empty constructor |
| 1068 | //------------------------------------------------- |
| 1069 | |
| 1070 | devcb_resolved_write64::devcb_resolved_write64() |
| 1071 | { |
| 1072 | m_object.port = NULL; |
| 1073 | m_helper.write_line = NULL; |
| 1074 | } |
| 1075 | |
| 1076 | |
| 1077 | //------------------------------------------------- |
| 1078 | // resolve - resolve to a delegate from a static |
| 1079 | // structure definition |
| 1080 | //------------------------------------------------- |
| 1081 | |
| 1082 | void devcb_resolved_write64::resolve(const devcb_write64 &desc, device_t &device) |
| 1083 | { |
| 1084 | switch (desc.type) |
| 1085 | { |
| 1086 | default: |
| 1087 | case DEVCB_TYPE_NULL: |
| 1088 | m_helper.null_indicator = &s_null; |
| 1089 | *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_null, "(null)", this); |
| 1090 | break; |
| 1091 | |
| 1092 | case DEVCB_TYPE_IOPORT: |
| 1093 | m_object.port = devcb_resolver::resolve_port(desc.tag, device); |
| 1094 | *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_port, desc.tag, this); |
| 1095 | break; |
| 1096 | |
| 1097 | case DEVCB_TYPE_DEVICE: |
| 1098 | m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); |
| 1099 | if (desc.writedevice != NULL) |
| 1100 | { |
| 1101 | m_helper.write64_device = desc.writedevice; |
| 1102 | *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_write64, desc.name, this); |
| 1103 | } |
| 1104 | else |
| 1105 | { |
| 1106 | m_helper.write_line = desc.writeline; |
| 1107 | *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_writeline, desc.name, this); |
| 1108 | } |
| 1109 | break; |
| 1110 | |
| 1111 | case DEVCB_TYPE_LEGACY_SPACE: |
| 1112 | m_object.space = &devcb_resolver::resolve_space(desc.index, desc.tag, device); |
| 1113 | *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(desc.writespace, desc.name, m_object.space); |
| 1114 | break; |
| 1115 | |
| 1116 | case DEVCB_TYPE_INPUT_LINE: |
| 1117 | m_object.execute = devcb_resolver::resolve_execute_interface(desc.tag, device); |
| 1118 | m_helper.input_line = desc.index; |
| 1119 | *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_input, desc.tag, this); |
| 1120 | break; |
| 1121 | |
| 1122 | case DEVCB_TYPE_UNMAP: |
| 1123 | m_helper.null_indicator = &s_null; |
| 1124 | m_object.device = &device; |
| 1125 | *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_unmap, "unmap", this); |
| 1126 | break; |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | |
| 1131 | //------------------------------------------------- |
| 1132 | // to_null - helper to handle a NULL write |
| 1133 | //------------------------------------------------- |
| 1134 | |
| 1135 | void devcb_resolved_write64::to_null(offs_t offset, UINT64 data, UINT64 mask) |
| 1136 | { |
| 1137 | } |
| 1138 | |
| 1139 | |
| 1140 | //------------------------------------------------- |
| 1141 | // to_unmap - helper to handle a unmap write |
| 1142 | //------------------------------------------------- |
| 1143 | |
| 1144 | void devcb_resolved_write64::to_unmap(offs_t offset, UINT64 data, UINT64 mask) |
| 1145 | { |
| 1146 | logerror("%s: unmapped devcb write %s & %s\n", |
| 1147 | m_object.device->tag(), |
| 1148 | core_i64_format(data, 2 * sizeof(UINT64),false), |
| 1149 | core_i64_format(mask, 2 * sizeof(UINT64),false)); |
| 1150 | } |
| 1151 | |
| 1152 | //------------------------------------------------- |
| 1153 | // to_port - helper to convert to an I/O port |
| 1154 | // value from a line value |
| 1155 | //------------------------------------------------- |
| 1156 | |
| 1157 | void devcb_resolved_write64::to_port(offs_t offset, UINT64 data, UINT64 mask) |
| 1158 | { |
| 1159 | m_object.port->write(data, mask); |
| 1160 | } |
| 1161 | |
| 1162 | |
| 1163 | //------------------------------------------------- |
| 1164 | // to_write64 - helper to convert to a 64-bit |
| 1165 | // memory read value from a line value |
| 1166 | //------------------------------------------------- |
| 1167 | |
| 1168 | void devcb_resolved_write64::to_write64(offs_t offset, UINT64 data, UINT64 mask) |
| 1169 | { |
| 1170 | (*m_helper.write64_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, data, mask); |
| 1171 | } |
| 1172 | |
| 1173 | |
| 1174 | //------------------------------------------------- |
| 1175 | // to_write64 - helper to convert to a 64-bit |
| 1176 | // memory read value from a line value |
| 1177 | //------------------------------------------------- |
| 1178 | |
| 1179 | void devcb_resolved_write64::to_writeline(offs_t offset, UINT64 data, UINT64 mask) |
| 1180 | { |
| 1181 | (*m_helper.write_line)(m_object.device, (data & 1) ? ASSERT_LINE : CLEAR_LINE); |
| 1182 | } |
| 1183 | |
| 1184 | |
| 1185 | //------------------------------------------------- |
| 1186 | // to_input - helper to convert to a device input |
| 1187 | // value from a line value |
| 1188 | //------------------------------------------------- |
| 1189 | |
| 1190 | void devcb_resolved_write64::to_input(offs_t offset, UINT64 data, UINT64 mask) |
| 1191 | { |
| 1192 | m_object.execute->set_input_line(m_helper.input_line, (data & 1) ? ASSERT_LINE : CLEAR_LINE); |
| 1193 | } |
trunk/src/emu/devcb.h
| r18445 | r18446 | |
| 50 | 50 | write8_device_func: (device, offset, data) |
| 51 | 51 | read16_device_func: (device, offset) |
| 52 | 52 | write16_device_func: (device, offset, data) |
| 53 | read32_device_func: (device, offset) |
| 54 | write32_device_func: (device, offset, data) |
| 55 | read64_device_func: (device, offset) |
| 56 | write64_device_func: (device, offset, data) |
| 53 | 57 | |
| 54 | 58 | The adapted callback types supported are: |
| 55 | 59 | |
| r18445 | r18446 | |
| 65 | 69 | write16_device_func: (device, offset, data) |
| 66 | 70 | read16_space_func: (space, offset) |
| 67 | 71 | write16_space_func: (space, offset, data) |
| 72 | read32_device_func: (device, offset) |
| 73 | write32_device_func: (device, offset, data) |
| 74 | read32_space_func: (space, offset) |
| 75 | write32_space_func: (space, offset, data) |
| 76 | read64_device_func: (device, offset) |
| 77 | write64_device_func: (device, offset, data) |
| 78 | read64_space_func: (space, offset) |
| 79 | write64_space_func: (space, offset, data) |
| 68 | 80 | |
| 69 | 81 | ***************************************************************************/ |
| 70 | 82 | |
| r18445 | r18446 | |
| 127 | 139 | return (target->*_Function)(space, offset, mem_mask); |
| 128 | 140 | } |
| 129 | 141 | |
| 142 | // static template for a read32 stub function that calls through a given READ32_MEMBER |
| 143 | template<class _Class, UINT32 (_Class::*_Function)(address_space &, offs_t, UINT32)> |
| 144 | UINT32 devcb_stub32(device_t *device, address_space &space, offs_t offset, UINT32 mem_mask) |
| 145 | { |
| 146 | _Class *target = downcast<_Class *>(device); |
| 147 | return (target->*_Function)(space, offset, mem_mask); |
| 148 | } |
| 149 | |
| 150 | // static template for a read64 stub function that calls through a given READ64_MEMBER |
| 151 | template<class _Class, UINT64 (_Class::*_Function)(address_space &, offs_t, UINT64)> |
| 152 | UINT64 devcb_stub64(device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 153 | { |
| 154 | _Class *target = downcast<_Class *>(device); |
| 155 | return (target->*_Function)(space, offset, mem_mask); |
| 156 | } |
| 157 | |
| 130 | 158 | // static template for a write_line stub function that calls through a given WRITE_LINE_MEMBER |
| 131 | 159 | template<class _Class, void (_Class::*_Function)(int state)> |
| 132 | 160 | void devcb_line_stub(device_t *device, int state) |
| r18445 | r18446 | |
| 151 | 179 | (target->*_Function)(space, offset, data, mem_mask); |
| 152 | 180 | } |
| 153 | 181 | |
| 182 | // static template for a write32 stub function that calls through a given WRITE32_MEMBER |
| 183 | template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT32, UINT32)> |
| 184 | void devcb_stub32(device_t *device, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 185 | { |
| 186 | _Class *target = downcast<_Class *>(device); |
| 187 | (target->*_Function)(space, offset, data, mem_mask); |
| 188 | } |
| 189 | |
| 190 | // static template for a write64 stub function that calls through a given WRITE64_MEMBER |
| 191 | template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT64, UINT64)> |
| 192 | void devcb_stub64(device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 193 | { |
| 194 | _Class *target = downcast<_Class *>(device); |
| 195 | (target->*_Function)(space, offset, data, mem_mask); |
| 196 | } |
| 197 | |
| 154 | 198 | #define DEVCB_NULL { DEVCB_TYPE_NULL } |
| 155 | 199 | |
| 156 | 200 | // standard line or read/write handlers with the calling device passed |
| r18445 | r18446 | |
| 159 | 203 | #define DEVCB_HANDLER(func) { DEVCB_TYPE_DEVICE, 0, "", #func, NULL, func, NULL } |
| 160 | 204 | #define DEVCB_MEMBER(cls,memb) { DEVCB_TYPE_DEVICE, 0, "", #cls "::" #memb, NULL, &devcb_stub<cls, &cls::memb>, NULL } |
| 161 | 205 | #define DEVCB_MEMBER16(cls,memb) { DEVCB_TYPE_DEVICE, 0, "", #cls "::" #memb, NULL, &devcb_stub16<cls, &cls::memb>, NULL } |
| 206 | #define DEVCB_MEMBER32(cls,memb) { DEVCB_TYPE_DEVICE, 0, "", #cls "::" #memb, NULL, &devcb_stub32<cls, &cls::memb>, NULL } |
| 207 | #define DEVCB_MEMBER64(cls,memb) { DEVCB_TYPE_DEVICE, 0, "", #cls "::" #memb, NULL, &devcb_stub64<cls, &cls::memb>, NULL } |
| 162 | 208 | |
| 163 | 209 | // line or read/write handlers for the driver device |
| 164 | 210 | #define DEVCB_DRIVER_LINE_MEMBER(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, &devcb_line_stub<cls, &cls::memb>, NULL, NULL } |
| 165 | 211 | #define DEVCB_DRIVER_MEMBER(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub<cls, &cls::memb>, NULL } |
| 166 | 212 | #define DEVCB_DRIVER_MEMBER16(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub16<cls, &cls::memb>, NULL } |
| 213 | #define DEVCB_DRIVER_MEMBER32(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub32<cls, &cls::memb>, NULL } |
| 214 | #define DEVCB_DRIVER_MEMBER64(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub64<cls, &cls::memb>, NULL } |
| 167 | 215 | |
| 168 | 216 | // line or read/write handlers for another device |
| 169 | 217 | #define DEVCB_DEVICE_LINE(tag,func) { DEVCB_TYPE_DEVICE, 0, tag, #func, func, NULL, NULL } |
| r18445 | r18446 | |
| 171 | 219 | #define DEVCB_DEVICE_HANDLER(tag,func) { DEVCB_TYPE_DEVICE, 0, tag, #func, NULL, func, NULL } |
| 172 | 220 | #define DEVCB_DEVICE_MEMBER(tag,cls,memb) { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub<cls, &cls::memb>, NULL } |
| 173 | 221 | #define DEVCB_DEVICE_MEMBER16(tag,cls,memb) { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub16<cls, &cls::memb>, NULL } |
| 222 | #define DEVCB_DEVICE_MEMBER32(tag,cls,memb) { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub32<cls, &cls::memb>, NULL } |
| 223 | #define DEVCB_DEVICE_MEMBER64(tag,cls,memb) { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub64<cls, &cls::memb>, NULL } |
| 174 | 224 | |
| 175 | 225 | // constant values |
| 176 | 226 | #define DEVCB_CONSTANT(value) { DEVCB_TYPE_CONSTANT, value, NULL, NULL, NULL, NULL } |
| r18445 | r18446 | |
| 228 | 278 | read8_space_func read8_space; |
| 229 | 279 | read16_device_func read16_device; |
| 230 | 280 | read16_space_func read16_space; |
| 281 | read32_device_func read32_device; |
| 282 | read32_space_func read32_space; |
| 283 | read64_device_func read64_device; |
| 284 | read64_space_func read64_space; |
| 231 | 285 | }; |
| 232 | 286 | |
| 233 | 287 | union devcb_resolved_write_helpers |
| r18445 | r18446 | |
| 238 | 292 | write8_space_func write8_space; |
| 239 | 293 | write16_device_func write16_device; |
| 240 | 294 | write16_space_func write16_space; |
| 295 | write32_device_func write32_device; |
| 296 | write32_space_func write32_space; |
| 297 | write64_device_func write64_device; |
| 298 | write64_space_func write64_space; |
| 241 | 299 | int input_line; |
| 242 | 300 | }; |
| 243 | 301 | |
| r18445 | r18446 | |
| 471 | 529 | |
| 472 | 530 | // ======================> devcb_resolved_read16 |
| 473 | 531 | |
| 474 | | // base delegate type for a write8 |
| 532 | // base delegate type for a write16 |
| 475 | 533 | typedef delegate<UINT16 (offs_t, UINT16)> devcb_read16_delegate; |
| 476 | 534 | |
| 477 | 535 | // class which wraps resolving a devcb_read16 into a delegate |
| r18445 | r18446 | |
| 525 | 583 | |
| 526 | 584 | // ======================> devcb_resolved_write16 |
| 527 | 585 | |
| 528 | | // base delegate type for a write8 |
| 586 | // base delegate type for a write16 |
| 529 | 587 | typedef delegate<void (offs_t, UINT16, UINT16)> devcb_write16_delegate; |
| 530 | 588 | |
| 531 | 589 | // class which wraps resolving a devcb_write16 into a delegate |
| r18445 | r18446 | |
| 562 | 620 | static UINT8 s_null; |
| 563 | 621 | }; |
| 564 | 622 | |
| 623 | // ======================> devcb_read32 |
| 565 | 624 | |
| 625 | // static structure used for device configuration when the desired callback type is a read32_device_func |
| 626 | struct devcb_read32 |
| 627 | { |
| 628 | UINT16 type; // one of the special DEVCB_TYPE values |
| 629 | UINT16 index; // index related to the above types |
| 630 | const char * tag; // tag of target, where appropriate |
| 631 | const char * name; // name of the target function |
| 632 | read_line_device_func readline; // read line function |
| 633 | read32_device_func readdevice; // read device function |
| 634 | read32_space_func readspace; // read space function |
| 635 | }; |
| 636 | |
| 637 | |
| 638 | // ======================> devcb_resolved_read32 |
| 639 | |
| 640 | // base delegate type for a write32 |
| 641 | typedef delegate<UINT32 (offs_t, UINT32)> devcb_read32_delegate; |
| 642 | |
| 643 | // class which wraps resolving a devcb_read32 into a delegate |
| 644 | class devcb_resolved_read32 : public devcb_read32_delegate |
| 645 | { |
| 646 | DISABLE_COPYING(devcb_resolved_read32); |
| 647 | |
| 648 | public: |
| 649 | // construction/destruction |
| 650 | devcb_resolved_read32(); |
| 651 | devcb_resolved_read32(const devcb_read32 &desc, device_t &device) { resolve(desc, device); } |
| 652 | |
| 653 | // resolution |
| 654 | void resolve(const devcb_read32 &desc, device_t &device); |
| 655 | |
| 656 | // override parent class' notion of NULL |
| 657 | bool isnull() const { return m_helper.null_indicator == &s_null; } |
| 658 | |
| 659 | // provide default for mem_mask |
| 660 | UINT32 operator()(offs_t offset, UINT32 mem_mask = 0xffff) const { return devcb_read32_delegate::operator()(offset, mem_mask); } |
| 661 | |
| 662 | private: |
| 663 | // internal helpers |
| 664 | UINT32 from_port(offs_t offset, UINT32 mask); |
| 665 | UINT32 from_read32(offs_t offset, UINT32 mask); |
| 666 | UINT32 from_readline(offs_t offset, UINT32 mask); |
| 667 | UINT32 from_constant(offs_t offset, UINT32 mask); |
| 668 | UINT32 from_unmap(offs_t offset, UINT32 mask); |
| 669 | |
| 670 | // internal state |
| 671 | devcb_resolved_objects m_object; |
| 672 | devcb_resolved_read_helpers m_helper; |
| 673 | static UINT8 s_null; |
| 674 | }; |
| 675 | |
| 676 | |
| 677 | // ======================> devcb_write32 |
| 678 | |
| 679 | // static structure used for device configuration when the desired callback type is a write32_device_func |
| 680 | struct devcb_write32 |
| 681 | { |
| 682 | UINT16 type; // one of the special DEVCB_TYPE values |
| 683 | UINT16 index; // index related to the above types |
| 684 | const char * tag; // tag of target, where appropriate |
| 685 | const char * name; // name of the target function |
| 686 | write_line_device_func writeline; // write line function |
| 687 | write32_device_func writedevice; // write device function |
| 688 | write32_space_func writespace; // write space function |
| 689 | }; |
| 690 | |
| 691 | |
| 692 | // ======================> devcb_resolved_write32 |
| 693 | |
| 694 | // base delegate type for a write32 |
| 695 | typedef delegate<void (offs_t, UINT32, UINT32)> devcb_write32_delegate; |
| 696 | |
| 697 | // class which wraps resolving a devcb_write32 into a delegate |
| 698 | class devcb_resolved_write32 : public devcb_write32_delegate |
| 699 | { |
| 700 | DISABLE_COPYING(devcb_resolved_write32); |
| 701 | |
| 702 | public: |
| 703 | // construction/destruction |
| 704 | devcb_resolved_write32(); |
| 705 | devcb_resolved_write32(const devcb_write32 &desc, device_t &device) { resolve(desc, device); } |
| 706 | |
| 707 | // resolution |
| 708 | void resolve(const devcb_write32 &desc, device_t &device); |
| 709 | |
| 710 | // override parent class' notion of NULL |
| 711 | bool isnull() const { return m_helper.null_indicator == &s_null; } |
| 712 | |
| 713 | // provide default for mem_mask |
| 714 | void operator()(offs_t offset, UINT32 data, UINT32 mem_mask = 0xffff) const { devcb_write32_delegate::operator()(offset, data, mem_mask); } |
| 715 | |
| 716 | private: |
| 717 | // internal helpers |
| 718 | void to_null(offs_t offset, UINT32 data, UINT32 mask); |
| 719 | void to_port(offs_t offset, UINT32 data, UINT32 mask); |
| 720 | void to_write32(offs_t offset, UINT32 data, UINT32 mask); |
| 721 | void to_writeline(offs_t offset, UINT32 data, UINT32 mask); |
| 722 | void to_input(offs_t offset, UINT32 data, UINT32 mask); |
| 723 | void to_unmap(offs_t offset, UINT32 data, UINT32 mask); |
| 724 | |
| 725 | // internal state |
| 726 | devcb_resolved_objects m_object; |
| 727 | devcb_resolved_write_helpers m_helper; |
| 728 | static UINT8 s_null; |
| 729 | }; |
| 730 | |
| 731 | // ======================> devcb_read64 |
| 732 | |
| 733 | // static structure used for device configuration when the desired callback type is a read64_device_func |
| 734 | struct devcb_read64 |
| 735 | { |
| 736 | UINT16 type; // one of the special DEVCB_TYPE values |
| 737 | UINT16 index; // index related to the above types |
| 738 | const char * tag; // tag of target, where appropriate |
| 739 | const char * name; // name of the target function |
| 740 | read_line_device_func readline; // read line function |
| 741 | read64_device_func readdevice; // read device function |
| 742 | read64_space_func readspace; // read space function |
| 743 | }; |
| 744 | |
| 745 | |
| 746 | // ======================> devcb_resolved_read64 |
| 747 | |
| 748 | // base delegate type for a write64 |
| 749 | typedef delegate<UINT64 (offs_t, UINT64)> devcb_read64_delegate; |
| 750 | |
| 751 | // class which wraps resolving a devcb_read64 into a delegate |
| 752 | class devcb_resolved_read64 : public devcb_read64_delegate |
| 753 | { |
| 754 | DISABLE_COPYING(devcb_resolved_read64); |
| 755 | |
| 756 | public: |
| 757 | // construction/destruction |
| 758 | devcb_resolved_read64(); |
| 759 | devcb_resolved_read64(const devcb_read64 &desc, device_t &device) { resolve(desc, device); } |
| 760 | |
| 761 | // resolution |
| 762 | void resolve(const devcb_read64 &desc, device_t &device); |
| 763 | |
| 764 | // override parent class' notion of NULL |
| 765 | bool isnull() const { return m_helper.null_indicator == &s_null; } |
| 766 | |
| 767 | // provide default for mem_mask |
| 768 | UINT64 operator()(offs_t offset, UINT64 mem_mask = 0xffff) const { return devcb_read64_delegate::operator()(offset, mem_mask); } |
| 769 | |
| 770 | private: |
| 771 | // internal helpers |
| 772 | UINT64 from_port(offs_t offset, UINT64 mask); |
| 773 | UINT64 from_read64(offs_t offset, UINT64 mask); |
| 774 | UINT64 from_readline(offs_t offset, UINT64 mask); |
| 775 | UINT64 from_constant(offs_t offset, UINT64 mask); |
| 776 | UINT64 from_unmap(offs_t offset, UINT64 mask); |
| 777 | |
| 778 | // internal state |
| 779 | devcb_resolved_objects m_object; |
| 780 | devcb_resolved_read_helpers m_helper; |
| 781 | static UINT8 s_null; |
| 782 | }; |
| 783 | |
| 784 | |
| 785 | // ======================> devcb_write64 |
| 786 | |
| 787 | // static structure used for device configuration when the desired callback type is a write64_device_func |
| 788 | struct devcb_write64 |
| 789 | { |
| 790 | UINT16 type; // one of the special DEVCB_TYPE values |
| 791 | UINT16 index; // index related to the above types |
| 792 | const char * tag; // tag of target, where appropriate |
| 793 | const char * name; // name of the target function |
| 794 | write_line_device_func writeline; // write line function |
| 795 | write64_device_func writedevice; // write device function |
| 796 | write64_space_func writespace; // write space function |
| 797 | }; |
| 798 | |
| 799 | |
| 800 | // ======================> devcb_resolved_write64 |
| 801 | |
| 802 | // base delegate type for a write64 |
| 803 | typedef delegate<void (offs_t, UINT64, UINT64)> devcb_write64_delegate; |
| 804 | |
| 805 | // class which wraps resolving a devcb_write64 into a delegate |
| 806 | class devcb_resolved_write64 : public devcb_write64_delegate |
| 807 | { |
| 808 | DISABLE_COPYING(devcb_resolved_write64); |
| 809 | |
| 810 | public: |
| 811 | // construction/destruction |
| 812 | devcb_resolved_write64(); |
| 813 | devcb_resolved_write64(const devcb_write64 &desc, device_t &device) { resolve(desc, device); } |
| 814 | |
| 815 | // resolution |
| 816 | void resolve(const devcb_write64 &desc, device_t &device); |
| 817 | |
| 818 | // override parent class' notion of NULL |
| 819 | bool isnull() const { return m_helper.null_indicator == &s_null; } |
| 820 | |
| 821 | // provide default for mem_mask |
| 822 | void operator()(offs_t offset, UINT64 data, UINT64 mem_mask = 0xffff) const { devcb_write64_delegate::operator()(offset, data, mem_mask); } |
| 823 | |
| 824 | private: |
| 825 | // internal helpers |
| 826 | void to_null(offs_t offset, UINT64 data, UINT64 mask); |
| 827 | void to_port(offs_t offset, UINT64 data, UINT64 mask); |
| 828 | void to_write64(offs_t offset, UINT64 data, UINT64 mask); |
| 829 | void to_writeline(offs_t offset, UINT64 data, UINT64 mask); |
| 830 | void to_input(offs_t offset, UINT64 data, UINT64 mask); |
| 831 | void to_unmap(offs_t offset, UINT64 data, UINT64 mask); |
| 832 | |
| 833 | // internal state |
| 834 | devcb_resolved_objects m_object; |
| 835 | devcb_resolved_write_helpers m_helper; |
| 836 | static UINT8 s_null; |
| 837 | }; |
| 838 | |
| 566 | 839 | #endif // __DEVCB_H__ |