branches/alto2/src/emu/machine/diablo_hd.c
| r26229 | r26230 | |
| 109 | 109 | */ |
| 110 | 110 | diablo_hd_device::~diablo_hd_device() |
| 111 | 111 | { |
| 112 | | for (int page = 0; page < m_pages; page++) { |
| 113 | | if (m_cache && m_cache[page]) |
| 114 | | global_free(m_cache[page]); |
| 115 | | if (m_bits && m_bits[page]) |
| 116 | | global_free(m_bits[page]); |
| 117 | | } |
| 118 | | if (m_cache) { |
| 119 | | global_free(m_cache); |
| 120 | | m_cache = 0; |
| 121 | | } |
| 122 | | if (m_bits) { |
| 123 | | global_free(m_bits); |
| 124 | | m_bits = 0; |
| 125 | | } |
| 126 | 112 | } |
| 127 | 113 | |
| 128 | 114 | #if DIABLO_DEBUG |
| r26229 | r26230 | |
| 323 | 309 | } |
| 324 | 310 | |
| 325 | 311 | /* allocate a buffer for this page */ |
| 326 | | m_cache[m_page] = global_alloc_array(UINT8, sizeof(diablo_sector_t)); |
| 312 | m_cache[m_page] = auto_alloc_array(machine(), UINT8, sizeof(diablo_sector_t)); |
| 327 | 313 | /* and read the page from the hard_disk image */ |
| 328 | 314 | if (hard_disk_read(m_disk, m_page, m_cache[m_page])) { |
| 329 | 315 | LOG_DRIVE((2,"[DHD%u] C/H/S:%d/%d/%d => page:%d loaded\n", m_unit, m_cylinder, m_head, m_sector, m_page)); |
| 330 | 316 | } else { |
| 331 | 317 | LOG_DRIVE((0,"[DHD%u] C/H/S:%d/%d/%d => page:%d read failed\n", m_unit, m_cylinder, m_head, m_sector, m_page)); |
| 332 | | global_free(m_cache[m_page]); |
| 318 | auto_free(machine(), m_cache[m_page]); |
| 333 | 319 | m_cache[m_page] = 0; |
| 334 | 320 | } |
| 335 | 321 | } |
| r26229 | r26230 | |
| 453 | 439 | diablo_sector_t *s = reinterpret_cast<diablo_sector_t *>(m_cache[m_page]); |
| 454 | 440 | |
| 455 | 441 | /* allocate a bits image */ |
| 456 | | UINT32 *bits = reinterpret_cast<UINT32 *>(global_alloc_array(UINT32, 400)); |
| 442 | UINT32 *bits = reinterpret_cast<UINT32 *>(auto_alloc_array(machine(), UINT32, 400)); |
| 457 | 443 | |
| 458 | 444 | if (m_diablo31) { |
| 459 | 445 | /* write sync bit after 31 words - 1 bit */ |
| r26229 | r26230 | |
| 784 | 770 | LOG_DRIVE((0,"[DHD%u] cksum check - header:%06o label:%06o data:%06o\n", m_unit, cksum_header, cksum_label, cksum_data)); |
| 785 | 771 | #endif |
| 786 | 772 | } |
| 787 | | global_free(m_bits[m_page]); |
| 773 | auto_free(machine(), m_bits[m_page]); |
| 788 | 774 | m_bits[m_page] = 0; |
| 789 | 775 | |
| 790 | 776 | if (!hard_disk_write(m_disk, m_page, m_cache[m_page])) { |
| r26229 | r26230 | |
| 1152 | 1138 | int bit = 0; |
| 1153 | 1139 | |
| 1154 | 1140 | if (m_rdgate_0) { |
| 1155 | | LOG_DRIVE((8,"[DHD%u] rdgate not asserted\n", m_unit)); |
| 1141 | LOG_DRIVE((0,"[DHD%u] rdgate not asserted\n", m_unit)); |
| 1156 | 1142 | return 1; // read gate is not asserted (active 0) |
| 1157 | 1143 | } |
| 1158 | 1144 | |
| r26229 | r26230 | |
| 1196 | 1182 | |
| 1197 | 1183 | if (index < 0 || index >= bits_per_sector()) { |
| 1198 | 1184 | LOG_DRIVE((0,"[DHD%u] index out of range (%d)\n", m_unit, index)); |
| 1199 | | return 1; // don't read before or beyond the sector |
| 1185 | return 0; // don't read before or beyond the sector |
| 1200 | 1186 | } |
| 1201 | 1187 | |
| 1202 | 1188 | if (0 == m_sector_mark_0) { |
| 1203 | 1189 | LOG_DRIVE((0,"[DHD%u] read while sector mark is asserted\n", m_unit)); |
| 1204 | | return 1; // no clock while sector mark is low (?) |
| 1190 | return 0; // no clock while sector mark is low (?) |
| 1205 | 1191 | } |
| 1206 | 1192 | |
| 1207 | 1193 | if (-1 == m_page) { |
| 1208 | 1194 | LOG_DRIVE((0,"[DHD%u] invalid page\n", m_unit)); |
| 1209 | | return 1; // invalid page |
| 1195 | return 0; // invalid page |
| 1210 | 1196 | } |
| 1211 | 1197 | |
| 1212 | 1198 | UINT32 *bits = expand_sector(); |
| r26229 | r26230 | |
| 1268 | 1254 | m_packs = 1; // FIXME: get from configuration? |
| 1269 | 1255 | m_unit = strstr(m_image->tag(), "diablo0") ? 0 : 1; |
| 1270 | 1256 | |
| 1271 | | m_cache = global_alloc_array(UINT8*, DIABLO_PAGES); |
| 1257 | m_cache = auto_alloc_array(machine(), UINT8*, DIABLO_PAGES); |
| 1272 | 1258 | memset(m_cache, 0, sizeof(UINT8*) * DIABLO_PAGES); |
| 1273 | | m_bits = global_alloc_array(UINT32*, DIABLO_PAGES); |
| 1259 | m_bits = auto_alloc_array(machine(), UINT32*, DIABLO_PAGES); |
| 1274 | 1260 | memset(m_bits, 0, sizeof(UINT32*) * DIABLO_PAGES); |
| 1275 | 1261 | |
| 1276 | 1262 | m_timer = timer_alloc(1, 0); |
branches/alto2/src/emu/cpu/alto2/a2roms.c
| r26229 | r26230 | |
| 98 | 98 | * @param segments number of segments in one page of the result |
| 99 | 99 | * @return pointer to the newly allocated memory filled with source bits |
| 100 | 100 | */ |
| 101 | | UINT8* prom_load(const prom_load_t* prom, const UINT8* src, int pages, int segments) |
| 101 | UINT8* prom_load(running_machine& machine, const prom_load_t* prom, const UINT8* src, int pages, int segments) |
| 102 | 102 | { |
| 103 | 103 | void* array = 0; |
| 104 | 104 | size_t type = prom->type; |
| r26229 | r26230 | |
| 109 | 109 | |
| 110 | 110 | switch (type) { |
| 111 | 111 | case sizeof(UINT8): |
| 112 | | array = global_alloc_array(UINT8, pages * size); |
| 112 | array = auto_alloc_array(machine, UINT8, pages * size); |
| 113 | 113 | break; |
| 114 | 114 | case sizeof(UINT16): |
| 115 | | array = global_alloc_array(UINT16, pages * size); |
| 115 | array = auto_alloc_array(machine, UINT16, pages * size); |
| 116 | 116 | break; |
| 117 | 117 | case sizeof(UINT32): |
| 118 | | array = global_alloc_array(UINT32, pages * size); |
| 118 | array = auto_alloc_array(machine, UINT32, pages * size); |
| 119 | 119 | break; |
| 120 | 120 | } |
| 121 | 121 | |
branches/alto2/src/emu/cpu/alto2/alto2.c
| r26229 | r26230 | |
| 187 | 187 | exit_disp(); |
| 188 | 188 | exit_disk(); |
| 189 | 189 | exit_memory(); |
| 190 | | |
| 191 | | if (m_ucode_crom) { |
| 192 | | global_free(m_ucode_crom); |
| 193 | | m_ucode_crom = 0; |
| 194 | | } |
| 195 | | if (m_ucode_cram) { |
| 196 | | global_free(m_ucode_cram); |
| 197 | | m_ucode_cram = 0; |
| 198 | | } |
| 199 | | if (m_const_data) { |
| 200 | | global_free(m_const_data); |
| 201 | | m_const_data = 0; |
| 202 | | } |
| 203 | | |
| 204 | | if (m_ctl2k_u3) { |
| 205 | | global_free(m_ctl2k_u3); |
| 206 | | m_ctl2k_u3 = 0; |
| 207 | | } |
| 208 | | if (m_ctl2k_u38) { |
| 209 | | global_free(m_ctl2k_u38); |
| 210 | | m_ctl2k_u38 = 0; |
| 211 | | } |
| 212 | | if (m_ctl2k_u76) { |
| 213 | | global_free(m_ctl2k_u76); |
| 214 | | m_ctl2k_u76 = 0; |
| 215 | | } |
| 216 | | if (m_cram3k_a37) { |
| 217 | | global_free(m_cram3k_a37); |
| 218 | | m_cram3k_a37 = 0; |
| 219 | | } |
| 220 | | if (m_madr_a64) { |
| 221 | | global_free(m_madr_a64); |
| 222 | | m_madr_a64 = 0; |
| 223 | | } |
| 224 | | if (m_madr_a65) { |
| 225 | | global_free(m_madr_a65); |
| 226 | | m_madr_a65 = 0; |
| 227 | | } |
| 228 | | if (m_madr_a90) { |
| 229 | | global_free(m_madr_a90); |
| 230 | | m_madr_a90 = 0; |
| 231 | | } |
| 232 | | if (m_madr_a91) { |
| 233 | | global_free(m_madr_a91); |
| 234 | | m_madr_a91 = 0; |
| 235 | | } |
| 236 | | if (m_alu_a10) { |
| 237 | | global_free(m_alu_a10); |
| 238 | | m_alu_a10 = 0; |
| 239 | | } |
| 240 | | |
| 241 | 190 | } |
| 242 | 191 | |
| 243 | 192 | #if ALTO2_DEBUG |
| r26229 | r26230 | |
| 1018 | 967 | m_iomem = &space(AS_2); |
| 1019 | 968 | |
| 1020 | 969 | // decode micro code PROMs to CROM |
| 1021 | | m_ucode_crom = prom_load(pl_ucode, memregion("ucode_proms")->base(), ALTO2_UCODE_ROM_PAGES, 8); |
| 970 | m_ucode_crom = prom_load(machine(), pl_ucode, memregion("ucode_proms")->base(), ALTO2_UCODE_ROM_PAGES, 8); |
| 1022 | 971 | |
| 1023 | 972 | // allocate micro code CRAM |
| 1024 | | m_ucode_cram = global_alloc_array(UINT8, sizeof(UINT32) * ALTO2_UCODE_RAM_PAGES * ALTO2_UCODE_PAGE_SIZE); |
| 973 | m_ucode_cram = auto_alloc_array(machine(), UINT8, sizeof(UINT32) * ALTO2_UCODE_RAM_PAGES * ALTO2_UCODE_PAGE_SIZE); |
| 1025 | 974 | // fill with inverted bits value |
| 1026 | 975 | for (offs_t offset = 0; offset < ALTO2_UCODE_RAM_PAGES * ALTO2_UCODE_PAGE_SIZE; offset++) |
| 1027 | 976 | *reinterpret_cast<UINT32 *>(m_ucode_cram + offset * 4) = ALTO2_UCODE_INVERTED; |
| 1028 | 977 | |
| 1029 | 978 | // decode constant PROMs to const data |
| 1030 | | m_const_data = prom_load(pl_const, memregion("const_proms")->base(), 1, 4); |
| 979 | m_const_data = prom_load(machine(), pl_const, memregion("const_proms")->base(), 1, 4); |
| 1031 | 980 | |
| 1032 | | m_disp_a38 = prom_load(&pl_displ_a38, memregion("displ_a38")->base()); |
| 1033 | | m_disp_a63 = prom_load(&pl_displ_a63, memregion("displ_a63")->base()); |
| 1034 | | m_disp_a66 = prom_load(&pl_displ_a66, memregion("displ_a66")->base()); |
| 1035 | | m_ctl2k_u3 = prom_load(&pl_2kctl_u3, memregion("2kctl_u3")->base()); |
| 1036 | | m_ctl2k_u38 = prom_load(&pl_2kctl_u38, memregion("2kctl_u38")->base()); |
| 1037 | | m_ctl2k_u76 = prom_load(&pl_2kctl_u76, memregion("2kctl_u76")->base()); |
| 1038 | | m_alu_a10 = prom_load(&pl_alu_a10, memregion("alu_a10")->base()); |
| 1039 | | m_cram3k_a37 = prom_load(&pl_3kcram_a37, memregion("3kcram_a37")->base()); |
| 1040 | | m_madr_a32 = prom_load(&pl_madr_a32, memregion("madr_a32")->base()); |
| 1041 | | m_madr_a64 = prom_load(&pl_madr_a64, memregion("madr_a64")->base()); |
| 1042 | | m_madr_a65 = prom_load(&pl_madr_a65, memregion("madr_a65")->base()); |
| 1043 | | m_madr_a90 = prom_load(&pl_madr_a90, memregion("madr_a90")->base()); |
| 1044 | | m_madr_a91 = prom_load(&pl_madr_a91, memregion("madr_a91")->base()); |
| 1045 | | m_ether_a41 = prom_load(&pl_enet_a41, memregion("ether_a41")->base()); |
| 1046 | | m_ether_a42 = prom_load(&pl_enet_a42, memregion("ether_a42")->base()); |
| 1047 | | m_ether_a49 = prom_load(&pl_enet_a49, memregion("ether_a49")->base()); |
| 981 | m_disp_a38 = prom_load(machine(), &pl_displ_a38, memregion("displ_a38")->base()); |
| 982 | m_disp_a63 = prom_load(machine(), &pl_displ_a63, memregion("displ_a63")->base()); |
| 983 | m_disp_a66 = prom_load(machine(), &pl_displ_a66, memregion("displ_a66")->base()); |
| 984 | m_ctl2k_u3 = prom_load(machine(), &pl_2kctl_u3, memregion("2kctl_u3")->base()); |
| 985 | m_ctl2k_u38 = prom_load(machine(), &pl_2kctl_u38, memregion("2kctl_u38")->base()); |
| 986 | m_ctl2k_u76 = prom_load(machine(), &pl_2kctl_u76, memregion("2kctl_u76")->base()); |
| 987 | m_alu_a10 = prom_load(machine(), &pl_alu_a10, memregion("alu_a10")->base()); |
| 988 | m_cram3k_a37 = prom_load(machine(), &pl_3kcram_a37, memregion("3kcram_a37")->base()); |
| 989 | m_madr_a32 = prom_load(machine(), &pl_madr_a32, memregion("madr_a32")->base()); |
| 990 | m_madr_a64 = prom_load(machine(), &pl_madr_a64, memregion("madr_a64")->base()); |
| 991 | m_madr_a65 = prom_load(machine(), &pl_madr_a65, memregion("madr_a65")->base()); |
| 992 | m_madr_a90 = prom_load(machine(), &pl_madr_a90, memregion("madr_a90")->base()); |
| 993 | m_madr_a91 = prom_load(machine(), &pl_madr_a91, memregion("madr_a91")->base()); |
| 994 | m_ether_a41 = prom_load(machine(), &pl_enet_a41, memregion("ether_a41")->base()); |
| 995 | m_ether_a42 = prom_load(machine(), &pl_enet_a42, memregion("ether_a42")->base()); |
| 996 | m_ether_a49 = prom_load(machine(), &pl_enet_a49, memregion("ether_a49")->base()); |
| 1048 | 997 | |
| 1049 | 998 | save_item(NAME(m_task_mpc)); |
| 1050 | 999 | save_item(NAME(m_task_next2)); |
| r26229 | r26230 | |
| 2701 | 2650 | */ |
| 2702 | 2651 | m_bitclk_time -= ALTO2_UCYCLE; |
| 2703 | 2652 | disk_bitclk(0, m_bitclk_index); |
| 2704 | | m_bitclk_index++; |
| 2705 | 2653 | } |
| 2706 | 2654 | #endif |
| 2707 | 2655 | |
branches/alto2/src/emu/cpu/alto2/a2disp.c
| r26229 | r26230 | |
| 439 | 439 | { |
| 440 | 440 | memset(&m_dsp, 0, sizeof(m_dsp)); |
| 441 | 441 | m_dsp.hlc = ALTO2_DISPLAY_HLC_START; |
| 442 | | m_dsp.raw_bitmap = global_alloc_array(UINT16, ALTO2_DISPLAY_HEIGHT * ALTO2_DISPLAY_SCANLINE_WORDS); |
| 442 | m_dsp.raw_bitmap = auto_alloc_array(machine(), UINT16, ALTO2_DISPLAY_HEIGHT * ALTO2_DISPLAY_SCANLINE_WORDS); |
| 443 | 443 | for (int y = 0; y < ALTO2_DISPLAY_HEIGHT; y++) |
| 444 | 444 | memset(m_dsp.raw_bitmap + y * ALTO2_DISPLAY_SCANLINE_WORDS, 0, ALTO2_DISPLAY_VISIBLE_WORDS * sizeof(UINT16)); |
| 445 | 445 | |
| 446 | | m_dsp.scanline_dirty = global_alloc_array(UINT8, ALTO2_DISPLAY_HEIGHT); |
| 446 | m_dsp.scanline_dirty = auto_alloc_array(machine(), UINT8, ALTO2_DISPLAY_HEIGHT); |
| 447 | 447 | memset(m_dsp.scanline_dirty, 1, sizeof(UINT8) * ALTO2_DISPLAY_HEIGHT); |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | void alto2_cpu_device::exit_disp() |
| 451 | 451 | { |
| 452 | | if (m_dsp.scanline_dirty) { |
| 453 | | global_free(m_dsp.scanline_dirty); |
| 454 | | m_dsp.scanline_dirty = 0; |
| 455 | | } |
| 456 | | if (m_dsp.raw_bitmap) { |
| 457 | | global_free(m_dsp.raw_bitmap); |
| 458 | | m_dsp.raw_bitmap = 0; |
| 459 | | } |
| 460 | | if (m_disp_a38) { |
| 461 | | global_free(m_disp_a38); |
| 462 | | m_disp_a38 = 0; |
| 463 | | } |
| 464 | | if (m_disp_a63) { |
| 465 | | global_free(m_disp_a63); |
| 466 | | m_disp_a63 = 0; |
| 467 | | } |
| 468 | | if (m_disp_a66) { |
| 469 | | global_free(m_disp_a66); |
| 470 | | m_disp_a66 = 0; |
| 471 | | } |
| 452 | // nothing to do yet |
| 472 | 453 | } |
| 473 | 454 | |
| 474 | 455 | #define BLACK 1 |