src/mess/machine/atom.c
| r7872 | r7873 | |
| 23 | 23 | #include "machine/6522via.h" |
| 24 | 24 | #include "devices/flopdrv.h" |
| 25 | 25 | #include "devices/cassette.h" |
| 26 | | #include "devices/snapquik.h" |
| 27 | 26 | #include "includes/atom.h" |
| 28 | 27 | #include "sound/speaker.h" |
| 29 | 28 | |
| r7872 | r7873 | |
| 194 | 193 | memory_region(machine, "maincpu")[0x0b] = mame_rand(machine) & 0x0ff; |
| 195 | 194 | } |
| 196 | 195 | |
| 197 | | struct atm |
| 198 | | { |
| 199 | | UINT8 atm_name[16]; |
| 200 | | UINT8 atm_start_high; |
| 201 | | UINT8 atm_start_low; |
| 202 | | UINT8 atm_exec_high; |
| 203 | | UINT8 atm_exec_low; |
| 204 | | UINT8 atm_size_high; |
| 205 | | UINT8 atm_size_low; |
| 206 | | }; |
| 207 | | |
| 208 | | /* this only works if loaded using file-manager. This should work |
| 209 | | for binary files, but will not work with basic files. This also does not support |
| 210 | | .tap files which contain multiple .atm files joined together! */ |
| 211 | | QUICKLOAD_LOAD(atom) |
| 212 | | { |
| 213 | | unsigned char *quickload_data; |
| 214 | | int i; |
| 215 | | unsigned char *data; |
| 216 | | struct atm *atm_header; |
| 217 | | unsigned long addr; |
| 218 | | unsigned long exec; |
| 219 | | unsigned long size; |
| 220 | | |
| 221 | | quickload_data = (unsigned char *)malloc(quickload_size); |
| 222 | | if (!quickload_data) |
| 223 | | return INIT_FAIL; |
| 224 | | |
| 225 | | if (image_fread(image, quickload_data, quickload_size) != quickload_size) |
| 226 | | { |
| 227 | | free(quickload_data); |
| 228 | | return INIT_FAIL; |
| 229 | | } |
| 230 | | |
| 231 | | atm_header = (struct atm *)quickload_data; |
| 232 | | |
| 233 | | /* calculate data address */ |
| 234 | | data = quickload_data + sizeof(struct atm); |
| 235 | | |
| 236 | | /* get start address */ |
| 237 | | addr = ( |
| 238 | | (atm_header->atm_start_low & 0x0ff) | |
| 239 | | ((atm_header->atm_start_high & 0x0ff)<<8) |
| 240 | | ); |
| 241 | | |
| 242 | | /* get size */ |
| 243 | | size = ( |
| 244 | | (atm_header->atm_size_low & 0x0ff) | |
| 245 | | ((atm_header->atm_size_high & 0x0ff)<<8) |
| 246 | | ); |
| 247 | | |
| 248 | | /* get execute address */ |
| 249 | | exec = ( |
| 250 | | (atm_header->atm_exec_low & 0x0ff) | |
| 251 | | ((atm_header->atm_exec_high & 0x0ff)<<8) |
| 252 | | ); |
| 253 | | |
| 254 | | /* copy data into memory */ |
| 255 | | for (i=size-1; i>=0; i--) |
| 256 | | { |
| 257 | | memory_write_byte( cputag_get_address_space( image->machine, "maincpu", ADDRESS_SPACE_PROGRAM ), addr, data[0]); |
| 258 | | addr++; |
| 259 | | data++; |
| 260 | | } |
| 261 | | |
| 262 | | |
| 263 | | /* set new pc address */ |
| 264 | | cpu_set_reg( devtag_get_device(image->machine, "maincpu"), REG_GENPC, exec); |
| 265 | | |
| 266 | | /* free the data */ |
| 267 | | free(quickload_data); |
| 268 | | return INIT_PASS; |
| 269 | | } |
| 270 | | |
| 271 | 196 | READ8_DEVICE_HANDLER (atom_8255_porta_r ) |
| 272 | 197 | { |
| 273 | 198 | /* logerror("8255: Read port a\n"); */ |
src/mess/formats/atom_atm.c
| r0 | r7873 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | formats/atom_atm.c |
| 4 | |
| 5 | Quickload code for Acorn Atom atm files |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #include "emu.h" |
| 10 | #include "formats/atom_atm.h" |
| 11 | #include "cpu/cdp1802/cdp1802.h" |
| 12 | #include "devices/messram.h" |
| 13 | |
| 14 | /*************************************************************************** |
| 15 | PARAMETERS |
| 16 | ***************************************************************************/ |
| 17 | |
| 18 | #define LOG 1 |
| 19 | |
| 20 | /*************************************************************************** |
| 21 | IMPLEMENTATION |
| 22 | ***************************************************************************/ |
| 23 | |
| 24 | /* |
| 25 | |
| 26 | The format for the .ATM files is as follows: |
| 27 | |
| 28 | Offset Size Description |
| 29 | ------ -------- ----------------------------------------------------------- |
| 30 | 0000h 16 BYTEs ATOM filename (if less than 16 BYTEs, rest is 00h bytes) |
| 31 | 0010h WORD Start address for load |
| 32 | 0012h WORD Execution address |
| 33 | 0014h WORD Size of data in BYTEs |
| 34 | 0016h Size Data |
| 35 | |
| 36 | */ |
| 37 | |
| 38 | static void image_fread_memory(running_device *image, UINT16 addr, UINT32 count) |
| 39 | { |
| 40 | void *ptr = memory_get_write_ptr(cpu_get_address_space(image->machine->firstcpu, ADDRESS_SPACE_PROGRAM), addr); |
| 41 | |
| 42 | image_fread(image, ptr, count); |
| 43 | } |
| 44 | |
| 45 | QUICKLOAD_LOAD( atom_atm ) |
| 46 | { |
| 47 | UINT8 header[0x16] = { 0 }; |
| 48 | |
| 49 | image_fread(image, header, 0x16); |
| 50 | |
| 51 | UINT16 start_address = header[0x10] << 8 | header[0x11]; |
| 52 | UINT16 run_address = header[0x12] << 8 | header[0x13]; |
| 53 | UINT16 size = header[0x14] << 8 | header[0x15]; |
| 54 | |
| 55 | if (LOG) |
| 56 | { |
| 57 | header[16] = 0; |
| 58 | logerror("ATM filename: %s\n", header); |
| 59 | logerror("ATM start address: %04x\n", start_address); |
| 60 | logerror("ATM run address: %04x\n", run_address); |
| 61 | logerror("ATM size: %04x\n", size); |
| 62 | } |
| 63 | |
| 64 | image_fread_memory(image, start_address, size); |
| 65 | |
| 66 | cpu_set_reg(image->machine->firstcpu, REG_GENPC, run_address); |
| 67 | |
| 68 | return INIT_PASS; |
| 69 | } |
src/mess/drivers/atom.c
| r7872 | r7873 | |
| 70 | 70 | |
| 71 | 71 | /* Devices */ |
| 72 | 72 | #include "devices/flopdrv.h" |
| 73 | #include "formats/atom_atm.h" |
| 73 | 74 | #include "formats/basicdsk.h" |
| 74 | 75 | #include "devices/cassette.h" |
| 75 | 76 | #include "devices/snapquik.h" |
| r7872 | r7873 | |
| 324 | 325 | MDRV_CENTRONICS_ADD("centronics", atom_centronics_config) |
| 325 | 326 | |
| 326 | 327 | /* quickload */ |
| 327 | | MDRV_QUICKLOAD_ADD("quickload", atom, "atm", 0) |
| 328 | MDRV_QUICKLOAD_ADD("quickload", atom_atm, "atm", 0) |
| 328 | 329 | |
| 329 | 330 | /* cassette */ |
| 330 | 331 | MDRV_CASSETTE_ADD( "cassette", default_cassette_config ) |