trunk/src/mess/drivers/binbug.c
| r22578 | r22579 | |
| 222 | 222 | { |
| 223 | 223 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 224 | 224 | int i; |
| 225 | | int quick_addr = 0x0440; |
| 225 | int quick_addr = 0x440; |
| 226 | 226 | int exec_addr; |
| 227 | 227 | int quick_length; |
| 228 | 228 | UINT8 *quick_data; |
| 229 | 229 | int read_; |
| 230 | int result = IMAGE_INIT_FAIL; |
| 230 | 231 | |
| 231 | 232 | quick_length = image.length(); |
| 232 | | quick_data = (UINT8*)malloc(quick_length); |
| 233 | | if (!quick_data) |
| 233 | if (quick_length < 0x0444) |
| 234 | 234 | { |
| 235 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 236 | | image.message(" Cannot open file"); |
| 237 | | return IMAGE_INIT_FAIL; |
| 235 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 236 | image.message(" File too short"); |
| 238 | 237 | } |
| 239 | | |
| 240 | | read_ = image.fread( quick_data, quick_length); |
| 241 | | if (read_ != quick_length) |
| 238 | else if (quick_length > 0x8000) |
| 242 | 239 | { |
| 243 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 244 | | image.message(" Cannot read the file"); |
| 245 | | return IMAGE_INIT_FAIL; |
| 240 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 241 | image.message(" File too long"); |
| 246 | 242 | } |
| 247 | | |
| 248 | | if (quick_data[0] != 0xc4) |
| 243 | else |
| 249 | 244 | { |
| 250 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 251 | | image.message(" Invalid header"); |
| 252 | | return IMAGE_INIT_FAIL; |
| 253 | | } |
| 245 | quick_data = (UINT8*)malloc(quick_length); |
| 246 | if (!quick_data) |
| 247 | { |
| 248 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 249 | image.message(" Cannot open file"); |
| 250 | } |
| 251 | else |
| 252 | { |
| 253 | read_ = image.fread( quick_data, quick_length); |
| 254 | if (read_ != quick_length) |
| 255 | { |
| 256 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 257 | image.message(" Cannot read the file"); |
| 258 | } |
| 259 | else if (quick_data[0] != 0xc4) |
| 260 | { |
| 261 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 262 | image.message(" Invalid header"); |
| 263 | } |
| 264 | else |
| 265 | { |
| 266 | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 254 | 267 | |
| 255 | | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 268 | if (exec_addr >= quick_length) |
| 269 | { |
| 270 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 271 | image.message(" Exec address beyond end of file"); |
| 272 | } |
| 273 | else |
| 274 | { |
| 275 | for (i = quick_addr; i < read_; i++) |
| 276 | space.write_byte(i, quick_data[i]); |
| 256 | 277 | |
| 257 | | if (exec_addr >= quick_length) |
| 258 | | { |
| 259 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 260 | | image.message(" Exec address beyond end of file"); |
| 261 | | return IMAGE_INIT_FAIL; |
| 262 | | } |
| 278 | /* display a message about the loaded quickload */ |
| 279 | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 263 | 280 | |
| 264 | | if (quick_length < 0x444) |
| 265 | | { |
| 266 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 267 | | image.message(" File too short"); |
| 268 | | return IMAGE_INIT_FAIL; |
| 269 | | } |
| 281 | // Start the quickload |
| 282 | m_maincpu->set_pc(exec_addr); |
| 270 | 283 | |
| 271 | | if (quick_length > 0x8000) |
| 272 | | { |
| 273 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 274 | | image.message(" File too long"); |
| 275 | | return IMAGE_INIT_FAIL; |
| 276 | | } |
| 284 | result = IMAGE_INIT_PASS; |
| 285 | } |
| 286 | } |
| 287 | } |
| 277 | 288 | |
| 278 | | for (i = quick_addr; i < quick_length; i++) |
| 279 | | { |
| 280 | | space.write_byte(i, quick_data[i]); |
| 289 | free( quick_data ); |
| 281 | 290 | } |
| 282 | 291 | |
| 283 | | /* display a message about the loaded quickload */ |
| 284 | | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 285 | | |
| 286 | | // Start the quickload |
| 287 | | m_maincpu->set_pc(exec_addr); |
| 288 | | return IMAGE_INIT_PASS; |
| 292 | return result; |
| 289 | 293 | } |
| 290 | 294 | |
| 291 | 295 | static MACHINE_CONFIG_START( binbug, binbug_state ) |
| r22578 | r22579 | |
| 360 | 364 | 0x0C = enable; 0x0E = protect). There are 256 pages so |
| 361 | 365 | each page is 256 bytes. |
| 362 | 366 | |
| 363 | | To turn the clock on (if it was working), put a non-zero |
| 364 | | into D80D. |
| 367 | The clock is controlled by the byte in D80D. |
| 365 | 368 | |
| 366 | 369 | Monitor Commands: |
| 367 | 370 | C (compare)* |
trunk/src/mess/drivers/instruct.c
| r22578 | r22579 | |
| 231 | 231 | { |
| 232 | 232 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 233 | 233 | int i; |
| 234 | | int quick_addr = 0x0100; |
| 234 | int quick_addr = 0x100; |
| 235 | 235 | int exec_addr; |
| 236 | 236 | int quick_length; |
| 237 | 237 | UINT8 *quick_data; |
| 238 | 238 | int read_; |
| 239 | int result = IMAGE_INIT_FAIL; |
| 239 | 240 | |
| 240 | 241 | quick_length = image.length(); |
| 241 | | quick_data = (UINT8*)malloc(quick_length); |
| 242 | | if (!quick_data) |
| 242 | if (quick_length < 0x0104) |
| 243 | 243 | { |
| 244 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 245 | | image.message(" Cannot open file"); |
| 246 | | return IMAGE_INIT_FAIL; |
| 244 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 245 | image.message(" File too short"); |
| 247 | 246 | } |
| 248 | | |
| 249 | | read_ = image.fread( quick_data, quick_length); |
| 250 | | if (read_ != quick_length) |
| 247 | else if (quick_length > 0x17c0) |
| 251 | 248 | { |
| 252 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 253 | | image.message(" Cannot read the file"); |
| 254 | | return IMAGE_INIT_FAIL; |
| 249 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 250 | image.message(" File too long"); |
| 255 | 251 | } |
| 256 | | |
| 257 | | if (quick_data[0] != 0xc5) |
| 252 | else |
| 258 | 253 | { |
| 259 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 260 | | image.message(" Invalid header"); |
| 261 | | return IMAGE_INIT_FAIL; |
| 262 | | } |
| 254 | quick_data = (UINT8*)malloc(quick_length); |
| 255 | if (!quick_data) |
| 256 | { |
| 257 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 258 | image.message(" Cannot open file"); |
| 259 | } |
| 260 | else |
| 261 | { |
| 262 | read_ = image.fread( quick_data, quick_length); |
| 263 | if (read_ != quick_length) |
| 264 | { |
| 265 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 266 | image.message(" Cannot read the file"); |
| 267 | } |
| 268 | else if (quick_data[0] != 0xc5) |
| 269 | { |
| 270 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 271 | image.message(" Invalid header"); |
| 272 | } |
| 273 | else |
| 274 | { |
| 275 | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 263 | 276 | |
| 264 | | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 277 | if (exec_addr >= quick_length) |
| 278 | { |
| 279 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 280 | image.message(" Exec address beyond end of file"); |
| 281 | } |
| 282 | else |
| 283 | { |
| 284 | for (i = quick_addr; i < read_; i++) |
| 285 | space.write_byte(i, quick_data[i]); |
| 265 | 286 | |
| 266 | | if (exec_addr >= quick_length) |
| 267 | | { |
| 268 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 269 | | image.message(" Exec address beyond end of file"); |
| 270 | | return IMAGE_INIT_FAIL; |
| 271 | | } |
| 287 | /* display a message about the loaded quickload */ |
| 288 | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 272 | 289 | |
| 273 | | if (quick_length < 0x104) |
| 274 | | { |
| 275 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 276 | | image.message(" File too short"); |
| 277 | | return IMAGE_INIT_FAIL; |
| 278 | | } |
| 290 | // Start the quickload |
| 291 | m_maincpu->set_pc(exec_addr); |
| 279 | 292 | |
| 280 | | if (quick_length > 0x17c0) |
| 281 | | { |
| 282 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 283 | | image.message(" File too long"); |
| 284 | | return IMAGE_INIT_FAIL; |
| 285 | | } |
| 293 | result = IMAGE_INIT_PASS; |
| 294 | } |
| 295 | } |
| 296 | } |
| 286 | 297 | |
| 287 | | for (i = quick_addr; i < quick_length; i++) |
| 288 | | { |
| 289 | | space.write_byte(i, quick_data[i]); |
| 298 | free( quick_data ); |
| 290 | 299 | } |
| 291 | 300 | |
| 292 | | /* display a message about the loaded quickload */ |
| 293 | | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 294 | | |
| 295 | | // Start the quickload |
| 296 | | m_maincpu->set_pc(exec_addr); |
| 297 | | return IMAGE_INIT_PASS; |
| 301 | return result; |
| 298 | 302 | } |
| 299 | 303 | |
| 300 | 304 | static MACHINE_CONFIG_START( instruct, instruct_state ) |
trunk/src/mess/drivers/pipbug.c
| r22578 | r22579 | |
| 97 | 97 | { |
| 98 | 98 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 99 | 99 | int i; |
| 100 | | int quick_addr = 0x0440; |
| 100 | int quick_addr = 0x440; |
| 101 | 101 | int exec_addr; |
| 102 | 102 | int quick_length; |
| 103 | 103 | UINT8 *quick_data; |
| 104 | 104 | int read_; |
| 105 | int result = IMAGE_INIT_FAIL; |
| 105 | 106 | |
| 106 | 107 | quick_length = image.length(); |
| 107 | | quick_data = (UINT8*)malloc(quick_length); |
| 108 | | if (!quick_data) |
| 108 | if (quick_length < 0x0444) |
| 109 | 109 | { |
| 110 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 111 | | image.message(" Cannot open file"); |
| 112 | | return IMAGE_INIT_FAIL; |
| 110 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 111 | image.message(" File too short"); |
| 113 | 112 | } |
| 114 | | |
| 115 | | read_ = image.fread( quick_data, quick_length); |
| 116 | | if (read_ != quick_length) |
| 113 | else if (quick_length > 0x8000) |
| 117 | 114 | { |
| 118 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 119 | | image.message(" Cannot read the file"); |
| 120 | | return IMAGE_INIT_FAIL; |
| 115 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 116 | image.message(" File too long"); |
| 121 | 117 | } |
| 122 | | |
| 123 | | if (quick_data[0] != 0xc4) |
| 118 | else |
| 124 | 119 | { |
| 125 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 126 | | image.message(" Invalid header"); |
| 127 | | return IMAGE_INIT_FAIL; |
| 128 | | } |
| 120 | quick_data = (UINT8*)malloc(quick_length); |
| 121 | if (!quick_data) |
| 122 | { |
| 123 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 124 | image.message(" Cannot open file"); |
| 125 | } |
| 126 | else |
| 127 | { |
| 128 | read_ = image.fread( quick_data, quick_length); |
| 129 | if (read_ != quick_length) |
| 130 | { |
| 131 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 132 | image.message(" Cannot read the file"); |
| 133 | } |
| 134 | else if (quick_data[0] != 0xc4) |
| 135 | { |
| 136 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 137 | image.message(" Invalid header"); |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 129 | 142 | |
| 130 | | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 143 | if (exec_addr >= quick_length) |
| 144 | { |
| 145 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 146 | image.message(" Exec address beyond end of file"); |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | for (i = quick_addr; i < read_; i++) |
| 151 | space.write_byte(i, quick_data[i]); |
| 131 | 152 | |
| 132 | | if (exec_addr >= quick_length) |
| 133 | | { |
| 134 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 135 | | image.message(" Exec address beyond end of file"); |
| 136 | | return IMAGE_INIT_FAIL; |
| 137 | | } |
| 153 | /* display a message about the loaded quickload */ |
| 154 | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 138 | 155 | |
| 139 | | if (quick_length < 0x444) |
| 140 | | { |
| 141 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 142 | | image.message(" File too short"); |
| 143 | | return IMAGE_INIT_FAIL; |
| 144 | | } |
| 156 | // Start the quickload |
| 157 | m_maincpu->set_pc(exec_addr); |
| 145 | 158 | |
| 146 | | if (quick_length > 0x8000) |
| 147 | | { |
| 148 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 149 | | image.message(" File too long"); |
| 150 | | return IMAGE_INIT_FAIL; |
| 151 | | } |
| 159 | result = IMAGE_INIT_PASS; |
| 160 | } |
| 161 | } |
| 162 | } |
| 152 | 163 | |
| 153 | | for (i = quick_addr; i < quick_length; i++) |
| 154 | | { |
| 155 | | space.write_byte(i, quick_data[i]); |
| 164 | free( quick_data ); |
| 156 | 165 | } |
| 157 | 166 | |
| 158 | | /* display a message about the loaded quickload */ |
| 159 | | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 160 | | |
| 161 | | // Start the quickload |
| 162 | | m_maincpu->set_pc(exec_addr); |
| 163 | | return IMAGE_INIT_PASS; |
| 167 | return result; |
| 164 | 168 | } |
| 165 | 169 | |
| 166 | 170 | static MACHINE_CONFIG_START( pipbug, pipbug_state ) |