shelves/new_menus/src/mame/video/slapfght.c
| r29303 | r29304 | |
| 19 | 19 | TILE_GET_INFO_MEMBER(slapfght_state::get_pf_tile_info) |
| 20 | 20 | { |
| 21 | 21 | /* For Performan only */ |
| 22 | | int tile = m_slapfight_videoram[tile_index] | ((m_slapfight_colorram[tile_index] & 0x03) << 8); |
| 23 | | int color = (m_slapfight_colorram[tile_index] >> 3) & 0x0f; |
| 22 | int tile = m_videoram[tile_index] | ((m_colorram[tile_index] & 0x03) << 8); |
| 23 | int color = (m_colorram[tile_index] >> 3) & 0x0f; |
| 24 | 24 | |
| 25 | 25 | SET_TILE_INFO_MEMBER(0, tile, color, 0); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | TILE_GET_INFO_MEMBER(slapfght_state::get_pf1_tile_info) |
| 29 | 29 | { |
| 30 | | int tile = m_slapfight_videoram[tile_index] | ((m_slapfight_colorram[tile_index] & 0x0f) << 8); |
| 31 | | int color = (m_slapfight_colorram[tile_index] & 0xf0) >> 4; |
| 30 | int tile = m_videoram[tile_index] | ((m_colorram[tile_index] & 0x0f) << 8); |
| 31 | int color = (m_colorram[tile_index] & 0xf0) >> 4; |
| 32 | 32 | |
| 33 | 33 | SET_TILE_INFO_MEMBER(1, tile, color, 0); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | TILE_GET_INFO_MEMBER(slapfght_state::get_fix_tile_info) |
| 37 | 37 | { |
| 38 | | int tile = m_slapfight_fixvideoram[tile_index] | ((m_slapfight_fixcolorram[tile_index] & 0x03) << 8); |
| 39 | | int color = (m_slapfight_fixcolorram[tile_index] & 0xfc) >> 2; |
| 38 | int tile = m_fixvideoram[tile_index] | ((m_fixcolorram[tile_index] & 0x03) << 8); |
| 39 | int color = (m_fixcolorram[tile_index] & 0xfc) >> 2; |
| 40 | 40 | |
| 41 | 41 | SET_TILE_INFO_MEMBER(0, tile, color, 0); |
| 42 | 42 | } |
| r29303 | r29304 | |
| 60 | 60 | { |
| 61 | 61 | m_pf1_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(slapfght_state::get_pf1_tile_info), this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); |
| 62 | 62 | m_fix_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(slapfght_state::get_fix_tile_info), this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); |
| 63 | |
| 64 | m_fix_tilemap->set_scrolldy(0, 15); |
| 65 | m_pf1_tilemap->set_scrolldy(0, 14); |
| 63 | 66 | |
| 64 | 67 | m_fix_tilemap->set_transparent_pen(0); |
| 65 | 68 | } |
| r29303 | r29304 | |
| 72 | 75 | |
| 73 | 76 | ***************************************************************************/ |
| 74 | 77 | |
| 75 | | WRITE8_MEMBER(slapfght_state::slapfight_videoram_w) |
| 78 | WRITE8_MEMBER(slapfght_state::videoram_w) |
| 76 | 79 | { |
| 77 | | m_slapfight_videoram[offset] = data; |
| 80 | m_videoram[offset] = data; |
| 78 | 81 | m_pf1_tilemap->mark_tile_dirty(offset); |
| 79 | 82 | } |
| 80 | 83 | |
| 81 | | WRITE8_MEMBER(slapfght_state::slapfight_colorram_w) |
| 84 | WRITE8_MEMBER(slapfght_state::colorram_w) |
| 82 | 85 | { |
| 83 | | m_slapfight_colorram[offset] = data; |
| 86 | m_colorram[offset] = data; |
| 84 | 87 | m_pf1_tilemap->mark_tile_dirty(offset); |
| 85 | 88 | } |
| 86 | 89 | |
| 87 | | WRITE8_MEMBER(slapfght_state::slapfight_fixram_w) |
| 90 | WRITE8_MEMBER(slapfght_state::fixram_w) |
| 88 | 91 | { |
| 89 | | m_slapfight_fixvideoram[offset] = data; |
| 92 | m_fixvideoram[offset] = data; |
| 90 | 93 | m_fix_tilemap->mark_tile_dirty(offset); |
| 91 | 94 | } |
| 92 | 95 | |
| 93 | | WRITE8_MEMBER(slapfght_state::slapfight_fixcol_w) |
| 96 | WRITE8_MEMBER(slapfght_state::fixcol_w) |
| 94 | 97 | { |
| 95 | | m_slapfight_fixcolorram[offset] = data; |
| 98 | m_fixcolorram[offset] = data; |
| 96 | 99 | m_fix_tilemap->mark_tile_dirty(offset); |
| 97 | 100 | } |
| 98 | 101 | |
| 102 | WRITE8_MEMBER(slapfght_state::scrollx_lo_w) |
| 103 | { |
| 104 | m_scrollx_lo = data; |
| 105 | } |
| 106 | |
| 107 | WRITE8_MEMBER(slapfght_state::scrollx_hi_w) |
| 108 | { |
| 109 | m_scrollx_hi = data; |
| 110 | } |
| 111 | |
| 112 | WRITE8_MEMBER(slapfght_state::scrolly_w) |
| 113 | { |
| 114 | m_scrolly = data; |
| 115 | } |
| 116 | |
| 99 | 117 | WRITE8_MEMBER(slapfght_state::flipscreen_w) |
| 100 | 118 | { |
| 101 | | m_flipscreen = offset ? 0 : 1; |
| 119 | flip_screen_set(offset ? 0 : 1); |
| 102 | 120 | } |
| 103 | 121 | |
| 104 | 122 | WRITE8_MEMBER(slapfght_state::palette_bank_w) |
| r29303 | r29304 | |
| 114 | 132 | |
| 115 | 133 | ***************************************************************************/ |
| 116 | 134 | |
| 117 | | void slapfght_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority_to_display) |
| 135 | void slapfght_state::draw_perfrman_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int layer) |
| 118 | 136 | { |
| 119 | 137 | UINT8 *src = m_spriteram->buffer(); |
| 120 | | |
| 138 | |
| 121 | 139 | for (int offs = 0; offs < m_spriteram->bytes(); offs += 4) |
| 122 | 140 | { |
| 123 | | int sx, sy; |
| 124 | | |
| 125 | | if ((src[offs + 2] & 0x80) == priority_to_display) |
| 141 | /* |
| 142 | 0: xxxxxxxx - code |
| 143 | 1: xxxxxxxx - x |
| 144 | 2: x....... - priority over backdrop |
| 145 | .x...... - sprite-sprite priority (see point-pop sprites) |
| 146 | ..x..... - ? |
| 147 | ...xx... - no function? |
| 148 | .....xxx - color |
| 149 | 3: xxxxxxxx - y |
| 150 | */ |
| 151 | |
| 152 | int code = src[offs + 0]; |
| 153 | int sy = src[offs + 3] - 1; |
| 154 | int sx = src[offs + 1] - 13; |
| 155 | int pri = src[offs + 2] >> 6 & 3; |
| 156 | int color = (src[offs + 2] >> 1 & 3) | (src[offs + 2] << 2 & 4) | (m_palette_bank << 3); |
| 157 | int fx = 0, fy = 0; |
| 158 | |
| 159 | if (flip_screen()) |
| 126 | 160 | { |
| 127 | | if (m_flipscreen) |
| 128 | | { |
| 129 | | sx = 265 - src[offs + 1]; |
| 130 | | sy = 239 - src[offs + 3]; |
| 131 | | sy &= 0xff; |
| 132 | | } |
| 133 | | else |
| 134 | | { |
| 135 | | sx = src[offs + 1] + 3; |
| 136 | | sy = src[offs + 3] - 1; |
| 137 | | } |
| 138 | | |
| 139 | | m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, |
| 140 | | src[offs], |
| 141 | | ((src[offs + 2] >> 1) & 3) | ((src[offs + 2] << 2) & 4) | (m_palette_bank << 3), |
| 142 | | m_flipscreen, m_flipscreen, |
| 143 | | sx, sy, 0 |
| 144 | | ); |
| 161 | sy = 256 - sy; |
| 162 | sx = 240 - sx; |
| 163 | fx = fy = 1; |
| 145 | 164 | } |
| 165 | |
| 166 | if (layer == pri) |
| 167 | m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, code, color, fx, fy, sx, sy, 0); |
| 146 | 168 | } |
| 147 | 169 | } |
| 148 | 170 | |
| 149 | | |
| 150 | 171 | UINT32 slapfght_state::screen_update_perfrman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 151 | 172 | { |
| 152 | | m_pf1_tilemap->set_flip(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); |
| 153 | | m_pf1_tilemap->set_scrolly(0, 0); |
| 154 | | if (m_flipscreen) |
| 155 | | m_pf1_tilemap->set_scrollx(0, 264); |
| 156 | | else |
| 157 | | m_pf1_tilemap->set_scrollx(0, -16); |
| 173 | m_pf1_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE); |
| 174 | draw_perfrman_sprites(bitmap, cliprect, 0); |
| 175 | draw_perfrman_sprites(bitmap, cliprect, 1); |
| 158 | 176 | |
| 159 | | m_pf1_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 160 | | draw_sprites(bitmap,cliprect, 0); |
| 161 | | m_pf1_tilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 162 | | draw_sprites(bitmap,cliprect, 0x80); |
| 177 | m_pf1_tilemap->draw(screen, bitmap, cliprect, 0); |
| 178 | draw_perfrman_sprites(bitmap, cliprect, 2); |
| 179 | draw_perfrman_sprites(bitmap, cliprect, 3); |
| 163 | 180 | |
| 164 | 181 | return 0; |
| 165 | 182 | } |
| 166 | 183 | |
| 167 | 184 | |
| 168 | | UINT32 slapfght_state::screen_update_slapfight(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 185 | void slapfght_state::draw_slapfight_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 169 | 186 | { |
| 170 | 187 | UINT8 *src = m_spriteram->buffer(); |
| 171 | 188 | |
| 172 | | machine().tilemap().set_flip_all(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); |
| 173 | | if (m_flipscreen) |
| 189 | for (int offs = 0; offs < m_spriteram->bytes(); offs += 4) |
| 174 | 190 | { |
| 175 | | m_fix_tilemap->set_scrollx(0, 296); |
| 176 | | m_pf1_tilemap->set_scrollx(0, (*m_slapfight_scrollx_lo + 256 * *m_slapfight_scrollx_hi) + 296); |
| 177 | | m_pf1_tilemap->set_scrolly(0, (*m_slapfight_scrolly) + 15); |
| 178 | | m_fix_tilemap->set_scrolly(0, -1); /* Glitch in Tiger Heli otherwise */ |
| 191 | /* |
| 192 | 0: xxxxxxxx - code low |
| 193 | 1: xxxxxxxx - x low |
| 194 | 2: xx...... - code high |
| 195 | ..x..... - no function? |
| 196 | ...xxxx. - color |
| 197 | .......x - x high |
| 198 | 3: xxxxxxxx - y |
| 199 | */ |
| 200 | |
| 201 | int code = src[offs + 0] | ((src[offs + 2] & 0xc0) << 2); |
| 202 | int sy = src[offs + 3]; |
| 203 | int sx = (src[offs + 1] | (src[offs + 2] << 8 & 0x100)) - 13; |
| 204 | int color = src[offs + 2] >> 1 & 0xf; |
| 205 | int fx = 0, fy = 0; |
| 206 | |
| 207 | if (flip_screen()) |
| 208 | { |
| 209 | sy = (238 - sy) & 0xff; |
| 210 | sx = 284 - sx; |
| 211 | fx = fy = 1; |
| 212 | } |
| 213 | |
| 214 | m_gfxdecode->gfx(2)->transpen(bitmap, cliprect, code, color, fx, fy, sx, sy, 0); |
| 179 | 215 | } |
| 180 | | else |
| 181 | | { |
| 182 | | m_fix_tilemap->set_scrollx(0, 0); |
| 183 | | m_pf1_tilemap->set_scrollx(0, (*m_slapfight_scrollx_lo + 256 * *m_slapfight_scrollx_hi)); |
| 184 | | m_pf1_tilemap->set_scrolly(0, (*m_slapfight_scrolly) - 1); |
| 185 | | m_fix_tilemap->set_scrolly(0, -1); /* Glitch in Tiger Heli otherwise */ |
| 186 | | } |
| 216 | } |
| 187 | 217 | |
| 218 | UINT32 slapfght_state::screen_update_slapfight(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 219 | { |
| 220 | m_pf1_tilemap->set_scrollx(m_scrollx_hi << 8 | m_scrollx_lo); |
| 221 | m_pf1_tilemap->set_scrolly(m_scrolly); |
| 222 | |
| 188 | 223 | m_pf1_tilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 189 | | |
| 190 | | /* Draw the sprites */ |
| 191 | | for (int offs = 0; offs < m_spriteram->bytes(); offs += 4) |
| 192 | | { |
| 193 | | if (m_flipscreen) |
| 194 | | m_gfxdecode->gfx(2)->transpen(bitmap, cliprect, |
| 195 | | src[offs] + ((src[offs + 2] & 0xc0) << 2), |
| 196 | | (src[offs + 2] & 0x1e) >> 1, |
| 197 | | 1, 1, |
| 198 | | 288 - (src[offs + 1] + ((src[offs + 2] & 0x01) << 8)) + 18, 240 - src[offs + 3], 0 |
| 199 | | ); |
| 200 | | else |
| 201 | | m_gfxdecode->gfx(2)->transpen(bitmap, cliprect, |
| 202 | | src[offs] + ((src[offs + 2] & 0xc0) << 2), |
| 203 | | (src[offs + 2] & 0x1e) >> 1, |
| 204 | | 0, 0, |
| 205 | | (src[offs + 1] + ((src[offs + 2] & 0x01) << 8)) - 13, src[offs + 3], 0 |
| 206 | | ); |
| 207 | | } |
| 208 | | |
| 224 | draw_slapfight_sprites(bitmap, cliprect); |
| 209 | 225 | m_fix_tilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 210 | 226 | |
| 211 | 227 | return 0; |
shelves/new_menus/src/mame/drivers/namcos23.c
| r29303 | r29304 | |
| 1427 | 1427 | UINT32 m_tile_mask; |
| 1428 | 1428 | UINT32 m_ptrom_limit; |
| 1429 | 1429 | |
| 1430 | int m_vblank_count; |
| 1431 | |
| 1430 | 1432 | // It may only be 128 |
| 1431 | 1433 | // At 0x1e bytes per slot, rounded up to 0x20, that's 0x1000 to 0x2000 bytes. |
| 1432 | 1434 | // That fits pretty much anywhere, including inside a IC |
| r29303 | r29304 | |
| 1603 | 1605 | return m_matrices[id]; |
| 1604 | 1606 | } |
| 1605 | 1607 | |
| 1606 | | void namcos23_state::c435_matrix_matrix_mul() // 000. |
| 1608 | void namcos23_state::c435_matrix_matrix_mul() // 0.0 |
| 1607 | 1609 | { |
| 1608 | | if(m_c435_buffer[0] != 0x0004) |
| 1610 | if((m_c435_buffer[0] & 0xf) != 4) |
| 1609 | 1611 | { |
| 1610 | 1612 | logerror("WARNING: c435_matrix_matrix_mul with size %d\n", m_c435_buffer[0] & 0xf); |
| 1611 | 1613 | return; |
| r29303 | r29304 | |
| 1614 | 1616 | logerror("WARNING: c435_matrix_matrix_mul with +2=%04x\n", m_c435_buffer[3]); |
| 1615 | 1617 | |
| 1616 | 1618 | INT16 *t = c435_getm(m_c435_buffer[1]); |
| 1617 | | const INT16 *m1 = c435_getm(m_c435_buffer[2]); |
| 1618 | | const INT16 *m2 = c435_getm(m_c435_buffer[4]); |
| 1619 | const INT16 *m2 = c435_getm(m_c435_buffer[2]); |
| 1620 | const INT16 *m1 = c435_getm(m_c435_buffer[4]); |
| 1619 | 1621 | |
| 1620 | | t[0] = INT16((m1[0]*m2[0] + m1[1]*m2[3] + m1[2]*m2[6]) >> 14); |
| 1621 | | t[1] = INT16((m1[0]*m2[1] + m1[1]*m2[4] + m1[2]*m2[7]) >> 14); |
| 1622 | | t[2] = INT16((m1[0]*m2[2] + m1[1]*m2[5] + m1[2]*m2[8]) >> 14); |
| 1623 | | t[3] = INT16((m1[3]*m2[0] + m1[4]*m2[3] + m1[5]*m2[6]) >> 14); |
| 1624 | | t[4] = INT16((m1[3]*m2[1] + m1[4]*m2[4] + m1[5]*m2[7]) >> 14); |
| 1625 | | t[5] = INT16((m1[3]*m2[2] + m1[4]*m2[5] + m1[5]*m2[8]) >> 14); |
| 1626 | | t[6] = INT16((m1[6]*m2[0] + m1[7]*m2[3] + m1[8]*m2[6]) >> 14); |
| 1627 | | t[7] = INT16((m1[6]*m2[1] + m1[7]*m2[4] + m1[8]*m2[7]) >> 14); |
| 1628 | | t[8] = INT16((m1[6]*m2[2] + m1[7]*m2[5] + m1[8]*m2[8]) >> 14); |
| 1622 | t[0] = INT16((m1[0]*m2[0] + m1[1]*m2[1] + m1[2]*m2[2]) >> 14); |
| 1623 | t[1] = INT16((m1[0]*m2[3] + m1[1]*m2[4] + m1[2]*m2[5]) >> 14); |
| 1624 | t[2] = INT16((m1[0]*m2[6] + m1[1]*m2[7] + m1[2]*m2[8]) >> 14); |
| 1625 | t[3] = INT16((m1[3]*m2[0] + m1[4]*m2[1] + m1[5]*m2[2]) >> 14); |
| 1626 | t[4] = INT16((m1[3]*m2[3] + m1[4]*m2[4] + m1[5]*m2[5]) >> 14); |
| 1627 | t[5] = INT16((m1[3]*m2[6] + m1[4]*m2[7] + m1[5]*m2[8]) >> 14); |
| 1628 | t[6] = INT16((m1[6]*m2[0] + m1[7]*m2[1] + m1[8]*m2[2]) >> 14); |
| 1629 | t[7] = INT16((m1[6]*m2[3] + m1[7]*m2[4] + m1[8]*m2[5]) >> 14); |
| 1630 | t[8] = INT16((m1[6]*m2[6] + m1[7]*m2[7] + m1[8]*m2[8]) >> 14); |
| 1629 | 1631 | } |
| 1630 | 1632 | |
| 1631 | | void namcos23_state::c435_matrix_set() // 004. |
| 1633 | void namcos23_state::c435_matrix_vector_mul() // 0.1 |
| 1632 | 1634 | { |
| 1633 | | if(m_c435_buffer[0] != 0x004a) |
| 1635 | if((m_c435_buffer[0] & 0xf) != 4) |
| 1634 | 1636 | { |
| 1635 | | logerror("WARNING: c435_matrix_set with size %d\n", m_c435_buffer[0] & 0xf); |
| 1636 | | return; |
| 1637 | | } |
| 1638 | | INT16 *t = c435_getm(m_c435_buffer[1]); |
| 1639 | | for(int i=0; i<9; i++) |
| 1640 | | t[i] = m_c435_buffer[i+2]; |
| 1641 | | } |
| 1642 | | |
| 1643 | | void namcos23_state::c435_vector_set() // 005. |
| 1644 | | { |
| 1645 | | if(m_c435_buffer[0] != 0x0057) |
| 1646 | | { |
| 1647 | | logerror("WARNING: c435_vector_set with size %d\n", m_c435_buffer[0] & 0xf); |
| 1648 | | return; |
| 1649 | | } |
| 1650 | | INT32 *t = c435_getv(m_c435_buffer[1]); |
| 1651 | | for(int i=0; i<3; i++) |
| 1652 | | t[i] = u32_to_s24((m_c435_buffer[2*i+2] << 16) | m_c435_buffer[2*i+3]); |
| 1653 | | } |
| 1654 | | |
| 1655 | | void namcos23_state::c435_matrix_vector_mul() // 081. |
| 1656 | | { |
| 1657 | | if(m_c435_buffer[0] != 0x0814) |
| 1658 | | { |
| 1659 | 1637 | logerror("WARNING: c435_matrix_vector_mul with size %d\n", m_c435_buffer[0] & 0xf); |
| 1660 | 1638 | return; |
| 1661 | 1639 | } |
| r29303 | r29304 | |
| 1667 | 1645 | const INT32 *v = c435_getv(m_c435_buffer[4]); |
| 1668 | 1646 | |
| 1669 | 1647 | t[0] = INT32((m[0]*INT64(v[0]) + m[1]*INT64(v[1]) + m[2]*INT64(v[2])) >> 14); |
| 1670 | | t[1] = INT32((m[3]*INT64(v[0]) + m[4]*INT64(v[1]) + m[7]*INT64(v[2])) >> 14); |
| 1648 | t[1] = INT32((m[3]*INT64(v[0]) + m[4]*INT64(v[1]) + m[5]*INT64(v[2])) >> 14); |
| 1671 | 1649 | t[2] = INT32((m[6]*INT64(v[0]) + m[7]*INT64(v[1]) + m[8]*INT64(v[2])) >> 14); |
| 1672 | 1650 | } |
| 1673 | 1651 | |
| 1674 | | void namcos23_state::c435_vector_matrix_mul() // 101. |
| 1652 | void namcos23_state::c435_matrix_set() // 0.4 |
| 1675 | 1653 | { |
| 1676 | | if(m_c435_buffer[0] != 0x1014) |
| 1654 | if((m_c435_buffer[0] & 0xf) != 10) |
| 1677 | 1655 | { |
| 1678 | | logerror("WARNING: c435_vector_matrix_mul with size %d\n", m_c435_buffer[0] & 0xf); |
| 1656 | logerror("WARNING: c435_matrix_set with size %d\n", m_c435_buffer[0] & 0xf); |
| 1679 | 1657 | return; |
| 1680 | 1658 | } |
| 1681 | | if(m_c435_buffer[3] != 0xffff) |
| 1682 | | logerror("WARNING: c435_vector_matrix_mul with [3]=%04x\n", m_c435_buffer[3]); |
| 1659 | INT16 *t = c435_getm(m_c435_buffer[1]); |
| 1660 | for(int i=0; i<9; i++) |
| 1661 | t[i] = m_c435_buffer[i+2]; |
| 1662 | } |
| 1683 | 1663 | |
| 1684 | | INT32 *t = c435_getv(m_c435_buffer[1]); |
| 1685 | | const INT16 *m = c435_getm(m_c435_buffer[2]); |
| 1686 | | const INT32 *v = c435_getv(m_c435_buffer[4]); |
| 1687 | | |
| 1688 | | t[0] = INT32((m[0]*INT64(v[0]) + m[3]*INT64(v[1]) + m[6]*INT64(v[2])) >> 14); |
| 1689 | | t[1] = INT32((m[1]*INT64(v[0]) + m[4]*INT64(v[1]) + m[7]*INT64(v[2])) >> 14); |
| 1690 | | t[2] = INT32((m[2]*INT64(v[0]) + m[5]*INT64(v[1]) + m[8]*INT64(v[2])) >> 14); |
| 1664 | void namcos23_state::c435_vector_set() // 0.5 |
| 1665 | { |
| 1666 | if((m_c435_buffer[0] & 0xf) != 7) |
| 1667 | { |
| 1668 | logerror("WARNING: c435_vector_set with size %d\n", m_c435_buffer[0] & 0xf); |
| 1669 | return; |
| 1670 | } |
| 1671 | INT32 *t = c435_getv(m_c435_buffer[1]); |
| 1672 | for(int i=0; i<3; i++) |
| 1673 | t[i] = u32_to_s24((m_c435_buffer[2*i+2] << 16) | m_c435_buffer[2*i+3]); |
| 1691 | 1674 | } |
| 1692 | 1675 | |
| 1693 | | void namcos23_state::c435_scaling_set() // 44.. |
| 1676 | void namcos23_state::c435_scaling_set() // 4.4 |
| 1694 | 1677 | { |
| 1695 | | if(m_c435_buffer[0] != 0x4401) |
| 1678 | if((m_c435_buffer[0] & 0xff) != 1) |
| 1696 | 1679 | { |
| 1697 | 1680 | logerror("WARNING: c435_scaling_set with size %d\n", m_c435_buffer[0] & 0xff); |
| 1698 | 1681 | return; |
| r29303 | r29304 | |
| 1700 | 1683 | m_scaling = m_c435_buffer[1]; |
| 1701 | 1684 | } |
| 1702 | 1685 | |
| 1703 | | void namcos23_state::c435_state_set_interrupt() // 4f.. 0001 |
| 1686 | void namcos23_state::c435_state_set_interrupt() // 4.f.0001 |
| 1704 | 1687 | { |
| 1705 | 1688 | if(m_c435_buffer[0] != 0x4f02) |
| 1706 | 1689 | { |
| r29303 | r29304 | |
| 1713 | 1696 | update_main_interrupts(m_main_irqcause & ~MAIN_C435_IRQ); |
| 1714 | 1697 | } |
| 1715 | 1698 | |
| 1716 | | void namcos23_state::c435_state_set() // 4f.. |
| 1699 | void namcos23_state::c435_state_set() // 4.f |
| 1717 | 1700 | { |
| 1718 | | if(m_c435_buffer[0] == 0x4f00) |
| 1701 | if((m_c435_buffer[0] & 0xff) == 0) |
| 1719 | 1702 | { |
| 1720 | 1703 | logerror("WARNING: c435_state_set with size %d\n", m_c435_buffer[0] & 0xff); |
| 1721 | 1704 | return; |
| r29303 | r29304 | |
| 1728 | 1711 | } |
| 1729 | 1712 | } |
| 1730 | 1713 | |
| 1731 | | void namcos23_state::c435_render() // 800. 808. |
| 1714 | void namcos23_state::c435_render() // 8 |
| 1732 | 1715 | { |
| 1733 | | if(m_c435_buffer[0] != 0x8003 && m_c435_buffer[0] != 0x8083) |
| 1716 | if((m_c435_buffer[0] & 0xf) != 3) |
| 1734 | 1717 | { |
| 1735 | | logerror("WARNING: c435_render with header %04x\n", m_c435_buffer[0]); |
| 1718 | logerror("WARNING: c435_render with size %d, header %04x", m_c435_buffer[0] & 0xf, m_c435_buffer[0]); |
| 1736 | 1719 | return; |
| 1737 | 1720 | } |
| 1738 | 1721 | |
| r29303 | r29304 | |
| 1768 | 1751 | render.count[render.cur]++; |
| 1769 | 1752 | } |
| 1770 | 1753 | |
| 1771 | | void namcos23_state::c435_flush() // c00. |
| 1754 | void namcos23_state::c435_flush() // c |
| 1772 | 1755 | { |
| 1773 | | if(m_c435_buffer[0] != 0xc000) |
| 1756 | if((m_c435_buffer[0] & 0xf) != 0) |
| 1774 | 1757 | { |
| 1775 | 1758 | logerror("WARNING: c435_flush with size %d\n", m_c435_buffer[0] & 0xf); |
| 1776 | 1759 | return; |
| r29303 | r29304 | |
| 1787 | 1770 | { |
| 1788 | 1771 | m_c435_buffer[m_c435_buffer_pos++] = data; |
| 1789 | 1772 | UINT16 h = m_c435_buffer[0]; |
| 1790 | | UINT16 h1; |
| 1791 | 1773 | int psize; |
| 1792 | | if(h & 0x4000) |
| 1793 | | { |
| 1794 | | h1 = h & 0xff00; |
| 1774 | if((h & 0x4000) == 0x4000) |
| 1795 | 1775 | psize = h & 0xff; |
| 1796 | | } |
| 1797 | 1776 | else |
| 1798 | | { |
| 1799 | | h1 = h & 0xfff0; |
| 1800 | 1777 | psize = h & 0xf; |
| 1801 | | } |
| 1802 | 1778 | if(m_c435_buffer_pos < psize+1) |
| 1803 | 1779 | return; |
| 1804 | 1780 | |
| 1805 | | switch(h1) |
| 1806 | | { |
| 1807 | | case 0x0000: c435_matrix_matrix_mul(); break; |
| 1808 | | case 0x0040: c435_matrix_set(); break; |
| 1809 | | case 0x0050: c435_vector_set(); break; |
| 1810 | | case 0x0810: c435_matrix_vector_mul(); break; |
| 1811 | | case 0x1010: c435_vector_matrix_mul(); break; |
| 1812 | | case 0x4400: c435_scaling_set(); break; |
| 1813 | | case 0x4f00: c435_state_set(); break; |
| 1814 | | case 0x8000: c435_render(); break; |
| 1815 | | case 0x8080: c435_render(); break; |
| 1816 | | case 0xc000: c435_flush(); break; |
| 1817 | | default: |
| 1818 | | if(1) |
| 1819 | | { |
| 1820 | | logerror("c435 - [%04x]", h1); |
| 1821 | | for(int i=0; i<m_c435_buffer_pos; i++) |
| 1822 | | logerror(" %04x", m_c435_buffer[i]); |
| 1823 | | logerror("\n"); |
| 1781 | bool known = true; |
| 1782 | switch(h & 0xc000) { |
| 1783 | case 0x0000: |
| 1784 | switch(h & 0xf0) { |
| 1785 | case 0x00: c435_matrix_matrix_mul(); break; |
| 1786 | case 0x10: c435_matrix_vector_mul(); break; |
| 1787 | case 0x40: c435_matrix_set(); break; |
| 1788 | case 0x50: c435_vector_set(); break; |
| 1789 | default: known = false; break; |
| 1824 | 1790 | } |
| 1825 | 1791 | break; |
| 1792 | |
| 1793 | case 0x4000: |
| 1794 | switch(h & 0xf00) { |
| 1795 | case 0x400: c435_scaling_set(); break; |
| 1796 | case 0xf00: c435_state_set(); break; |
| 1797 | default: known = false; break; |
| 1798 | } |
| 1799 | break; |
| 1800 | |
| 1801 | case 0x8000: c435_render(); break; |
| 1802 | case 0xc000: c435_flush(); break; |
| 1826 | 1803 | } |
| 1804 | |
| 1805 | if(!known) { |
| 1806 | logerror("c435 -"); |
| 1807 | for(int i=0; i<m_c435_buffer_pos; i++) |
| 1808 | logerror(" %04x", m_c435_buffer[i]); |
| 1809 | logerror("\n"); |
| 1810 | } |
| 1811 | |
| 1827 | 1812 | m_c435_buffer_pos = 0; |
| 1828 | 1813 | } |
| 1829 | 1814 | |
| r29303 | r29304 | |
| 1902 | 1887 | |
| 1903 | 1888 | void namcos23_state::render_apply_transform(INT32 xi, INT32 yi, INT32 zi, const namcos23_render_entry *re, poly_vertex &pv) |
| 1904 | 1889 | { |
| 1905 | | pv.x = (INT32((re->model.m[0]*INT64(xi) + re->model.m[3]*INT64(yi) + re->model.m[6]*INT64(zi)) >> 14)*re->model.scaling + re->model.v[0])/16384.0; |
| 1906 | | pv.y = (INT32((re->model.m[1]*INT64(xi) + re->model.m[4]*INT64(yi) + re->model.m[7]*INT64(zi)) >> 14)*re->model.scaling + re->model.v[1])/16384.0; |
| 1907 | | pv.p[0] = (INT32((re->model.m[2]*INT64(xi) + re->model.m[5]*INT64(yi) + re->model.m[8]*INT64(zi)) >> 14)*re->model.scaling + re->model.v[2])/16384.0; |
| 1890 | pv.x = (INT32((re->model.m[0]*INT64(xi) + re->model.m[1]*INT64(yi) + re->model.m[2]*INT64(zi)) >> 14)*re->model.scaling + re->model.v[0])/16384.0; |
| 1891 | pv.y = (INT32((re->model.m[3]*INT64(xi) + re->model.m[4]*INT64(yi) + re->model.m[5]*INT64(zi)) >> 14)*re->model.scaling + re->model.v[1])/16384.0; |
| 1892 | pv.p[0] = (INT32((re->model.m[6]*INT64(xi) + re->model.m[7]*INT64(yi) + re->model.m[8]*INT64(zi)) >> 14)*re->model.scaling + re->model.v[2])/16384.0; |
| 1908 | 1893 | } |
| 1909 | 1894 | |
| 1910 | 1895 | void namcos23_state::render_apply_matrot(INT32 xi, INT32 yi, INT32 zi, const namcos23_render_entry *re, INT32 &x, INT32 &y, INT32 &z) |
| r29303 | r29304 | |
| 1963 | 1948 | UINT32 type = m_ptrom[adr++]; |
| 1964 | 1949 | UINT32 h = m_ptrom[adr++]; |
| 1965 | 1950 | |
| 1966 | | |
| 1967 | 1951 | float tbase = (type >> 24) << 12; |
| 1968 | 1952 | UINT8 color = (h >> 24) & 0x7f; |
| 1969 | 1953 | int lmode = (type >> 19) & 3; |
| r29303 | r29304 | |
| 2004 | 1988 | |
| 2005 | 1989 | switch(lmode) |
| 2006 | 1990 | { |
| 2007 | | case 0: case 1: |
| 1991 | case 0: |
| 2008 | 1992 | pv[i].p[3] = ((light >> (8*(3-i))) & 0xff) / 64.0; |
| 2009 | 1993 | break; |
| 1994 | case 1: |
| 1995 | pv[i].p[3] = ((light >> (8*(3-i))) & 0xff) / 64.0; |
| 1996 | break; |
| 2010 | 1997 | case 2: |
| 2011 | 1998 | pv[i].p[3] = 1.0; |
| 2012 | 1999 | break; |
| r29303 | r29304 | |
| 2018 | 2005 | INT32 nz = u32_to_s10(norm); |
| 2019 | 2006 | INT32 nrx, nry, nrz; |
| 2020 | 2007 | render_apply_matrot(nx, ny, nz, re, nrx, nry, nrz); |
| 2021 | | |
| 2022 | 2008 | float lsi = float(nrx*m_light_vector[0] + nry*m_light_vector[1] + nrz*m_light_vector[2])/4194304.0; |
| 2023 | 2009 | if(lsi < 0) |
| 2024 | 2010 | lsi = 0; |
| 2025 | 2011 | |
| 2026 | 2012 | // Mapping taken out of a hat |
| 2027 | | pv[i].p[3] = 0.5+lsi; |
| 2013 | pv[i].p[3] = 0.25+1.5*lsi; |
| 2028 | 2014 | break; |
| 2029 | 2015 | } |
| 2030 | 2016 | } |
| r29303 | r29304 | |
| 2201 | 2187 | if (m_c404.layer & 4) |
| 2202 | 2188 | m_bgtilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 2203 | 2189 | |
| 2190 | m_vblank_count++; |
| 2191 | |
| 2204 | 2192 | return 0; |
| 2205 | 2193 | } |
| 2206 | 2194 | |
| r29303 | r29304 | |
| 2323 | 2311 | m_c417.pointrom_adr = 0; |
| 2324 | 2312 | break; |
| 2325 | 2313 | case 4: |
| 2326 | | //logerror("c417_w %04x = %04x (%08x, %08x)\n", c417.adr, data, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| 2314 | //logerror("c417_w %04x = %04x (%08x, %08x)\n", m_c417.adr, data, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| 2327 | 2315 | COMBINE_DATA(m_c417.ram + m_c417.adr); |
| 2328 | 2316 | break; |
| 2329 | 2317 | case 7: |
| r29303 | r29304 | |
| 3164 | 3152 | PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 3165 | 3153 | |
| 3166 | 3154 | PORT_START("SERVICE") |
| 3167 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 ) |
| 3155 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) |
| 3168 | 3156 | |
| 3169 | 3157 | PORT_START("DSW") |
| 3170 | 3158 | PORT_SERVICE( 0x01, IP_ACTIVE_LOW ) |
| r29303 | r29304 | |
| 3222 | 3210 | |
| 3223 | 3211 | void namcos23_state::machine_reset() |
| 3224 | 3212 | { |
| 3213 | m_vblank_count = 0; |
| 3225 | 3214 | m_c435_buffer_pos = 0; |
| 3226 | 3215 | m_subcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 3227 | 3216 | } |
shelves/new_menus/src/mame/drivers/slapfght.c
| r29303 | r29304 | |
| 12 | 12 | |
| 13 | 13 | TODO: |
| 14 | 14 | - proper MCU emulation (mame/machine/slapfght.c) |
| 15 | - alcon cocktail/flipscreen, it doesn't write to the flipscreen reg |
| 15 | 16 | |
| 16 | 17 | |
| 17 | 18 | **************************************************************************** |
| r29303 | r29304 | |
| 271 | 272 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 272 | 273 | AM_RANGE(0x8000, 0x87ff) AM_RAM |
| 273 | 274 | AM_RANGE(0x8800, 0x8fff) AM_RAM AM_SHARE("share1") |
| 274 | | AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(slapfight_videoram_w) AM_SHARE("videoram") |
| 275 | | AM_RANGE(0x9800, 0x9fff) AM_RAM_WRITE(slapfight_colorram_w) AM_SHARE("colorram") |
| 275 | AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(videoram_w) AM_SHARE("videoram") |
| 276 | AM_RANGE(0x9800, 0x9fff) AM_RAM_WRITE(colorram_w) AM_SHARE("colorram") |
| 276 | 277 | AM_RANGE(0xa000, 0xa7ff) AM_RAM AM_SHARE("spriteram") |
| 277 | 278 | ADDRESS_MAP_END |
| 278 | 279 | |
| r29303 | r29304 | |
| 281 | 282 | AM_RANGE(0x0000, 0xbfff) AM_ROM |
| 282 | 283 | AM_RANGE(0xc000, 0xc7ff) AM_RAM |
| 283 | 284 | AM_RANGE(0xc800, 0xcfff) AM_RAM AM_SHARE("share1") |
| 284 | | AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_SHARE("videoram") |
| 285 | | AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_SHARE("colorram") |
| 285 | AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(videoram_w) AM_SHARE("videoram") |
| 286 | AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(colorram_w) AM_SHARE("colorram") |
| 286 | 287 | AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_SHARE("spriteram") |
| 287 | | AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_SHARE("scrollx_lo") |
| 288 | | AM_RANGE(0xe801, 0xe801) AM_WRITEONLY AM_SHARE("scrollx_hi") |
| 289 | | AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_SHARE("scrolly") |
| 288 | AM_RANGE(0xe800, 0xe800) AM_WRITE(scrollx_lo_w) |
| 289 | AM_RANGE(0xe801, 0xe801) AM_WRITE(scrollx_hi_w) |
| 290 | AM_RANGE(0xe802, 0xe802) AM_WRITE(scrolly_w) |
| 290 | 291 | AM_RANGE(0xe803, 0xe803) AM_READWRITE(tigerh_mcu_r, tigerh_mcu_w) |
| 291 | | AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_SHARE("fixvideoram") |
| 292 | | AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_SHARE("fixcolorram") |
| 292 | AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(fixram_w) AM_SHARE("fixvideoram") |
| 293 | AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(fixcol_w) AM_SHARE("fixcolorram") |
| 293 | 294 | ADDRESS_MAP_END |
| 294 | 295 | |
| 295 | 296 | static ADDRESS_MAP_START( tigerhb1_map, AS_PROGRAM, 8, slapfght_state ) |
| r29303 | r29304 | |
| 308 | 309 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") |
| 309 | 310 | AM_RANGE(0xc000, 0xc7ff) AM_RAM |
| 310 | 311 | AM_RANGE(0xc800, 0xcfff) AM_RAM AM_SHARE("share1") |
| 311 | | AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_SHARE("videoram") |
| 312 | | AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_SHARE("colorram") |
| 312 | AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(videoram_w) AM_SHARE("videoram") |
| 313 | AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(colorram_w) AM_SHARE("colorram") |
| 313 | 314 | AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_SHARE("spriteram") |
| 314 | | AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_SHARE("scrollx_lo") |
| 315 | | AM_RANGE(0xe801, 0xe801) AM_WRITEONLY AM_SHARE("scrollx_hi") |
| 316 | | AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_SHARE("scrolly") |
| 315 | AM_RANGE(0xe800, 0xe800) AM_WRITE(scrollx_lo_w) |
| 316 | AM_RANGE(0xe801, 0xe801) AM_WRITE(scrollx_hi_w) |
| 317 | AM_RANGE(0xe802, 0xe802) AM_WRITE(scrolly_w) |
| 317 | 318 | AM_RANGE(0xe803, 0xe803) AM_READWRITE(tigerh_mcu_r, tigerh_mcu_w) |
| 318 | | AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_SHARE("fixvideoram") |
| 319 | | AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_SHARE("fixcolorram") |
| 319 | AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(fixram_w) AM_SHARE("fixvideoram") |
| 320 | AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(fixcol_w) AM_SHARE("fixcolorram") |
| 320 | 321 | ADDRESS_MAP_END |
| 321 | 322 | |
| 322 | 323 | static ADDRESS_MAP_START( slapfighb1_map, AS_PROGRAM, 8, slapfght_state ) |
| r29303 | r29304 | |
| 334 | 335 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") |
| 335 | 336 | AM_RANGE(0xc000, 0xc7ff) AM_RAM |
| 336 | 337 | AM_RANGE(0xc800, 0xcfff) AM_RAM AM_SHARE("share1") |
| 337 | | AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_SHARE("videoram") |
| 338 | | AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_SHARE("colorram") |
| 338 | AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(videoram_w) AM_SHARE("videoram") |
| 339 | AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(colorram_w) AM_SHARE("colorram") |
| 339 | 340 | AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_SHARE("spriteram") |
| 340 | | AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_SHARE("scrollx_hi") |
| 341 | | AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_SHARE("scrolly") |
| 342 | | AM_RANGE(0xe803, 0xe803) AM_WRITEONLY AM_SHARE("scrollx_lo") |
| 341 | AM_RANGE(0xe800, 0xe800) AM_WRITE(scrollx_hi_w) |
| 342 | AM_RANGE(0xe802, 0xe802) AM_WRITE(scrolly_w) |
| 343 | AM_RANGE(0xe803, 0xe803) AM_WRITE(scrollx_lo_w) |
| 343 | 344 | AM_RANGE(0xec00, 0xefff) AM_ROM // it reads a copy of the logo from here! |
| 344 | | AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_SHARE("fixvideoram") |
| 345 | | AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_SHARE("fixcolorram") |
| 345 | AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(fixram_w) AM_SHARE("fixvideoram") |
| 346 | AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(fixcol_w) AM_SHARE("fixcolorram") |
| 346 | 347 | ADDRESS_MAP_END |
| 347 | 348 | |
| 348 | 349 | |
| r29303 | r29304 | |
| 757 | 758 | { |
| 758 | 759 | // zerofill |
| 759 | 760 | m_palette_bank = 0; |
| 760 | | m_flipscreen = 0; |
| 761 | m_scrollx_lo = 0; |
| 762 | m_scrollx_hi = 0; |
| 763 | m_scrolly = 0; |
| 761 | 764 | m_main_irq_enabled = false; |
| 762 | 765 | m_sound_nmi_enabled = false; |
| 763 | 766 | |
| r29303 | r29304 | |
| 786 | 789 | |
| 787 | 790 | // savestates |
| 788 | 791 | save_item(NAME(m_palette_bank)); |
| 789 | | save_item(NAME(m_flipscreen)); |
| 792 | save_item(NAME(m_scrollx_lo)); |
| 793 | save_item(NAME(m_scrollx_hi)); |
| 794 | save_item(NAME(m_scrolly)); |
| 790 | 795 | save_item(NAME(m_main_irq_enabled)); |
| 791 | 796 | save_item(NAME(m_sound_nmi_enabled)); |
| 792 | 797 | |
| r29303 | r29304 | |
| 1009 | 1014 | MCFG_SCREEN_REFRESH_RATE(60) |
| 1010 | 1015 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) |
| 1011 | 1016 | MCFG_SCREEN_SIZE(64*8, 32*8) |
| 1012 | | MCFG_SCREEN_VISIBLE_AREA(1*8, 34*8-1, 2*8, 32*8-1) |
| 1017 | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 32*8-1) |
| 1013 | 1018 | MCFG_SCREEN_UPDATE_DRIVER(slapfght_state, screen_update_perfrman) |
| 1014 | 1019 | MCFG_SCREEN_VBLANK_DEVICE("spriteram", buffered_spriteram8_device, vblank_copy_rising) |
| 1015 | 1020 | MCFG_SCREEN_PALETTE("palette") |
| r29303 | r29304 | |
| 1055 | 1060 | MCFG_SCREEN_REFRESH_RATE(60) |
| 1056 | 1061 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) |
| 1057 | 1062 | MCFG_SCREEN_SIZE(64*8, 32*8) |
| 1058 | | MCFG_SCREEN_VISIBLE_AREA(1*8, 36*8-1, 2*8, 32*8-1) |
| 1063 | MCFG_SCREEN_VISIBLE_AREA(1*8, 36*8-1, 2*8-1, 32*8-1-1) |
| 1059 | 1064 | MCFG_SCREEN_UPDATE_DRIVER(slapfght_state, screen_update_slapfight) |
| 1060 | 1065 | MCFG_SCREEN_VBLANK_DEVICE("spriteram", buffered_spriteram8_device, vblank_copy_rising) |
| 1061 | 1066 | MCFG_SCREEN_PALETTE("palette") |
| r29303 | r29304 | |
| 1118 | 1123 | MCFG_SCREEN_REFRESH_RATE(60) |
| 1119 | 1124 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) |
| 1120 | 1125 | MCFG_SCREEN_SIZE(64*8, 32*8) |
| 1121 | | MCFG_SCREEN_VISIBLE_AREA(1*8, 36*8-1, 2*8, 32*8-1) |
| 1126 | MCFG_SCREEN_VISIBLE_AREA(1*8, 36*8-1, 2*8-1, 32*8-1-1) |
| 1122 | 1127 | MCFG_SCREEN_UPDATE_DRIVER(slapfght_state, screen_update_slapfight) |
| 1123 | 1128 | MCFG_SCREEN_VBLANK_DEVICE("spriteram", buffered_spriteram8_device, vblank_copy_rising) |
| 1124 | 1129 | MCFG_SCREEN_PALETTE("palette") |
| r29303 | r29304 | |
| 1981 | 1986 | GAME( 1985, perfrman, 0, perfrman, perfrman, driver_device, 0, ROT270, "Toaplan / Data East Corporation", "Performan (Japan)", GAME_SUPPORTS_SAVE ) |
| 1982 | 1987 | GAME( 1985, perfrmanu, perfrman, perfrman, perfrman, driver_device, 0, ROT270, "Toaplan / Data East USA", "Performan (US)", GAME_SUPPORTS_SAVE ) |
| 1983 | 1988 | |
| 1984 | | GAME( 1985, tigerh, 0, tigerh, tigerh, driver_device, 0, ROT270, "Toaplan / Taito America Corp.", "Tiger Heli (US)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 1985 | | GAME( 1985, tigerhj, tigerh, tigerh, tigerh, driver_device, 0, ROT270, "Toaplan / Taito", "Tiger Heli (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 1986 | | GAME( 1985, tigerhb1, tigerh, tigerhb1, tigerh, driver_device, 0, ROT270, "bootleg", "Tiger Heli (bootleg set 1)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 1987 | | GAME( 1985, tigerhb2, tigerh, tigerhb2, tigerh, driver_device, 0, ROT270, "bootleg", "Tiger Heli (bootleg set 2)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 1988 | | GAME( 1985, tigerhb3, tigerh, tigerhb2, tigerh, driver_device, 0, ROT270, "bootleg", "Tiger Heli (bootleg set 3)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 1989 | GAME( 1985, tigerh, 0, tigerh, tigerh, driver_device, 0, ROT270, "Toaplan / Taito America Corp.", "Tiger Heli (US)", GAME_SUPPORTS_SAVE ) |
| 1990 | GAME( 1985, tigerhj, tigerh, tigerh, tigerh, driver_device, 0, ROT270, "Toaplan / Taito", "Tiger Heli (Japan)", GAME_SUPPORTS_SAVE ) |
| 1991 | GAME( 1985, tigerhb1, tigerh, tigerhb1, tigerh, driver_device, 0, ROT270, "bootleg", "Tiger Heli (bootleg set 1)", GAME_SUPPORTS_SAVE ) |
| 1992 | GAME( 1985, tigerhb2, tigerh, tigerhb2, tigerh, driver_device, 0, ROT270, "bootleg", "Tiger Heli (bootleg set 2)", GAME_SUPPORTS_SAVE ) |
| 1993 | GAME( 1985, tigerhb3, tigerh, tigerhb2, tigerh, driver_device, 0, ROT270, "bootleg", "Tiger Heli (bootleg set 3)", GAME_SUPPORTS_SAVE ) |
| 1989 | 1994 | |
| 1990 | 1995 | GAME( 1986, alcon, 0, slapfigh, slapfigh, slapfght_state, slapfigh, ROT270, "Toaplan / Taito America Corp.", "Alcon (US)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 1991 | 1996 | GAME( 1986, slapfigh, alcon, slapfigh, slapfigh, slapfght_state, slapfigh, ROT270, "Toaplan / Taito", "Slap Fight (Japan set 1)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| r29303 | r29304 | |
| 1994 | 1999 | GAME( 1986, slapfighb2, alcon, slapfighb2, slapfigh, slapfght_state, slapfigh, ROT270, "bootleg", "Slap Fight (bootleg set 2)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) // England? |
| 1995 | 2000 | GAME( 1986, slapfighb3, alcon, slapfighb2, slapfigh, slapfght_state, slapfigh, ROT270, "bootleg", "Slap Fight (bootleg set 3)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) // PCB labeled 'slap fighter' |
| 1996 | 2001 | |
| 1997 | | GAME( 1986, grdian, 0, getstar, getstar, slapfght_state, getstar, ROT0, "Toaplan / Taito America Corporation (Kitkorp license)", "Guardian (US)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 1998 | | GAME( 1986, getstarj, grdian, getstar, getstarj, slapfght_state, getstarj, ROT0, "Toaplan / Taito", "Get Star (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 2002 | GAME( 1986, grdian, 0, getstar, getstar, slapfght_state, getstar, ROT0, "Toaplan / Taito America Corporation (Kitkorp license)", "Guardian (US)", GAME_SUPPORTS_SAVE ) |
| 2003 | GAME( 1986, getstarj, grdian, getstar, getstarj, slapfght_state, getstarj, ROT0, "Toaplan / Taito", "Get Star (Japan)", GAME_SUPPORTS_SAVE ) |
| 1999 | 2004 | GAME( 1986, getstarb1, grdian, getstarb1, getstarj, slapfght_state, getstarb1, ROT0, "bootleg", "Get Star (bootleg set 1)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 2000 | | GAME( 1986, getstarb2, grdian, getstarb2, getstarb2, slapfght_state, getstarb2, ROT0, "bootleg", "Get Star (bootleg set 2)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) |
| 2005 | GAME( 1986, getstarb2, grdian, getstarb2, getstarb2, slapfght_state, getstarb2, ROT0, "bootleg", "Get Star (bootleg set 2)", GAME_SUPPORTS_SAVE ) |
shelves/new_menus/src/emu/bus/rs232/teleprinter.c
| r29303 | r29304 | |
| 1 | | #include "teleprinter.h" |
| 2 | | |
| 3 | | #define KEYBOARD_TAG "keyboard" |
| 4 | | |
| 5 | | static const UINT8 teleprinter_font[128*8] = |
| 6 | | { |
| 7 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 8 | | 0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00, |
| 9 | | 0x38,0x38,0x38,0x38,0x00,0x00,0x00,0x00, |
| 10 | | 0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x00,0x00, |
| 11 | | 0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07, |
| 12 | | 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07, |
| 13 | | 0x38,0x38,0x38,0x38,0x07,0x07,0x07,0x07, |
| 14 | | 0x3f,0x3f,0x3f,0x3f,0x07,0x07,0x07,0x07, |
| 15 | | 0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38, |
| 16 | | 0x07,0x07,0x07,0x07,0x38,0x38,0x38,0x38, |
| 17 | | 0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38, |
| 18 | | 0x3f,0x3f,0x3f,0x3f,0x38,0x38,0x38,0x38, |
| 19 | | 0x00,0x00,0x00,0x00,0x3f,0x3f,0x3f,0x3f, |
| 20 | | 0x07,0x07,0x07,0x07,0x3f,0x3f,0x3f,0x3f, |
| 21 | | 0x38,0x38,0x38,0x38,0x3f,0x3f,0x3f,0x3f, |
| 22 | | 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, |
| 23 | | 0x00,0x00,0x00,0x00,0x2a,0x15,0x2a,0x15, |
| 24 | | 0x2a,0x15,0x2a,0x15,0x00,0x00,0x00,0x00, |
| 25 | | 0x3f,0x3f,0x3f,0x3f,0x2a,0x15,0x2a,0x15, |
| 26 | | 0x2a,0x15,0x2a,0x15,0x3f,0x3f,0x3f,0x3f, |
| 27 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 28 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 29 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 30 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 31 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 32 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 33 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 34 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 35 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 36 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 37 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 38 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 39 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 40 | | 0x08,0x08,0x08,0x08,0x08,0x00,0x08,0x00, |
| 41 | | 0x14,0x14,0x14,0x00,0x00,0x00,0x00,0x00, |
| 42 | | 0x14,0x14,0x3e,0x14,0x3e,0x14,0x14,0x00, |
| 43 | | 0x08,0x3c,0x0a,0x1c,0x28,0x1e,0x08,0x00, |
| 44 | | 0x06,0x26,0x10,0x08,0x04,0x32,0x30,0x00, |
| 45 | | 0x08,0x14,0x14,0x0c,0x2a,0x12,0x2c,0x00, |
| 46 | | 0x08,0x08,0x04,0x00,0x00,0x00,0x00,0x00, |
| 47 | | 0x10,0x08,0x04,0x04,0x04,0x08,0x10,0x00, |
| 48 | | 0x04,0x08,0x10,0x10,0x10,0x08,0x04,0x00, |
| 49 | | 0x00,0x08,0x2a,0x1c,0x2a,0x08,0x00,0x00, |
| 50 | | 0x00,0x08,0x08,0x3e,0x08,0x08,0x00,0x00, |
| 51 | | 0x00,0x00,0x00,0x00,0x08,0x08,0x04,0x00, |
| 52 | | 0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x00, |
| 53 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00, |
| 54 | | 0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00, |
| 55 | | 0x1c,0x22,0x32,0x2a,0x26,0x22,0x1c,0x00, |
| 56 | | 0x08,0x0c,0x08,0x08,0x08,0x08,0x1c,0x00, |
| 57 | | 0x1c,0x22,0x20,0x18,0x04,0x02,0x3e,0x00, |
| 58 | | 0x3e,0x20,0x10,0x18,0x20,0x22,0x1c,0x00, |
| 59 | | 0x10,0x18,0x14,0x12,0x3e,0x10,0x10,0x00, |
| 60 | | 0x3e,0x02,0x1e,0x20,0x20,0x22,0x1c,0x00, |
| 61 | | 0x10,0x08,0x04,0x1c,0x22,0x22,0x1c,0x00, |
| 62 | | 0x3e,0x20,0x10,0x08,0x04,0x04,0x04,0x00, |
| 63 | | 0x1c,0x22,0x22,0x1c,0x22,0x22,0x1c,0x00, |
| 64 | | 0x1c,0x22,0x22,0x1c,0x10,0x08,0x04,0x00, |
| 65 | | 0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x00, |
| 66 | | 0x00,0x00,0x08,0x00,0x08,0x08,0x04,0x00, |
| 67 | | 0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x00, |
| 68 | | 0x00,0x00,0x3e,0x00,0x3e,0x00,0x00,0x00, |
| 69 | | 0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00, |
| 70 | | 0x1c,0x22,0x20,0x10,0x08,0x00,0x08,0x00, |
| 71 | | 0x1c,0x22,0x32,0x2a,0x3a,0x02,0x3c,0x00, |
| 72 | | 0x08,0x14,0x22,0x22,0x3e,0x22,0x22,0x00, |
| 73 | | 0x1e,0x22,0x22,0x1e,0x22,0x22,0x1e,0x00, |
| 74 | | 0x1c,0x22,0x02,0x02,0x02,0x22,0x1c,0x00, |
| 75 | | 0x1e,0x24,0x24,0x24,0x24,0x24,0x1e,0x00, |
| 76 | | 0x3e,0x02,0x02,0x1e,0x02,0x02,0x3e,0x00, |
| 77 | | 0x3e,0x02,0x02,0x1e,0x02,0x02,0x02,0x00, |
| 78 | | 0x1c,0x22,0x02,0x02,0x32,0x22,0x3c,0x00, |
| 79 | | 0x22,0x22,0x22,0x3e,0x22,0x22,0x22,0x00, |
| 80 | | 0x1c,0x08,0x08,0x08,0x08,0x08,0x1c,0x00, |
| 81 | | 0x38,0x10,0x10,0x10,0x10,0x12,0x0c,0x00, |
| 82 | | 0x22,0x12,0x0a,0x06,0x0a,0x12,0x22,0x00, |
| 83 | | 0x02,0x02,0x02,0x02,0x02,0x02,0x3e,0x00, |
| 84 | | 0x22,0x36,0x2a,0x2a,0x22,0x22,0x22,0x00, |
| 85 | | 0x22,0x22,0x26,0x2a,0x32,0x22,0x22,0x00, |
| 86 | | 0x1c,0x22,0x22,0x22,0x22,0x22,0x1c,0x00, |
| 87 | | 0x1e,0x22,0x22,0x1e,0x02,0x02,0x02,0x00, |
| 88 | | 0x1c,0x22,0x22,0x22,0x2a,0x12,0x2c,0x00, |
| 89 | | 0x1e,0x22,0x22,0x1e,0x0a,0x12,0x22,0x00, |
| 90 | | 0x1c,0x22,0x02,0x1c,0x20,0x22,0x1c,0x00, |
| 91 | | 0x3e,0x08,0x08,0x08,0x08,0x08,0x08,0x00, |
| 92 | | 0x22,0x22,0x22,0x22,0x22,0x22,0x1c,0x00, |
| 93 | | 0x22,0x22,0x22,0x14,0x14,0x08,0x08,0x00, |
| 94 | | 0x22,0x22,0x22,0x2a,0x2a,0x2a,0x14,0x00, |
| 95 | | 0x22,0x22,0x14,0x08,0x14,0x22,0x22,0x00, |
| 96 | | 0x22,0x22,0x22,0x14,0x08,0x08,0x08,0x00, |
| 97 | | 0x3e,0x20,0x10,0x08,0x04,0x02,0x3e,0x00, |
| 98 | | 0x0e,0x02,0x02,0x02,0x02,0x02,0x0e,0x00, |
| 99 | | 0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00, |
| 100 | | 0x38,0x20,0x20,0x20,0x20,0x20,0x38,0x00, |
| 101 | | 0x08,0x1c,0x2a,0x08,0x08,0x08,0x08,0x00, |
| 102 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00, |
| 103 | | 0x04,0x08,0x00,0x00,0x00,0x00,0x00,0x00, |
| 104 | | 0x00,0x00,0x1c,0x20,0x3c,0x22,0x3c,0x00, |
| 105 | | 0x02,0x02,0x1e,0x22,0x22,0x22,0x1e,0x00, |
| 106 | | 0x00,0x00,0x3c,0x02,0x02,0x02,0x3c,0x00, |
| 107 | | 0x20,0x20,0x3c,0x22,0x22,0x22,0x3c,0x00, |
| 108 | | 0x00,0x00,0x1c,0x22,0x3e,0x02,0x1c,0x00, |
| 109 | | 0x18,0x04,0x0e,0x04,0x04,0x04,0x04,0x00, |
| 110 | | 0x00,0x00,0x3c,0x22,0x22,0x3c,0x20,0x18, |
| 111 | | 0x02,0x02,0x1e,0x22,0x22,0x22,0x22,0x00, |
| 112 | | 0x08,0x00,0x0c,0x08,0x08,0x08,0x1c,0x00, |
| 113 | | 0x10,0x00,0x18,0x10,0x10,0x10,0x12,0x0c, |
| 114 | | 0x02,0x02,0x22,0x12,0x0e,0x16,0x22,0x00, |
| 115 | | 0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x00, |
| 116 | | 0x00,0x00,0x16,0x2a,0x2a,0x2a,0x2a,0x00, |
| 117 | | 0x00,0x00,0x1a,0x26,0x22,0x22,0x22,0x00, |
| 118 | | 0x00,0x00,0x1c,0x22,0x22,0x22,0x1c,0x00, |
| 119 | | 0x00,0x00,0x1e,0x22,0x22,0x1e,0x02,0x02, |
| 120 | | 0x00,0x00,0x3c,0x22,0x22,0x3c,0x20,0x20, |
| 121 | | 0x00,0x00,0x34,0x0c,0x04,0x04,0x04,0x00, |
| 122 | | 0x00,0x00,0x3c,0x02,0x1c,0x20,0x1e,0x00, |
| 123 | | 0x08,0x08,0x1c,0x08,0x08,0x08,0x10,0x00, |
| 124 | | 0x00,0x00,0x22,0x22,0x22,0x32,0x2c,0x00, |
| 125 | | 0x00,0x00,0x22,0x22,0x22,0x14,0x08,0x00, |
| 126 | | 0x00,0x00,0x22,0x22,0x2a,0x2a,0x14,0x00, |
| 127 | | 0x00,0x00,0x22,0x14,0x08,0x14,0x22,0x00, |
| 128 | | 0x00,0x00,0x22,0x22,0x14,0x08,0x04,0x02, |
| 129 | | 0x00,0x00,0x3e,0x10,0x08,0x04,0x3e,0x00, |
| 130 | | 0x10,0x08,0x08,0x04,0x08,0x08,0x10,0x00, |
| 131 | | 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00, |
| 132 | | 0x04,0x08,0x08,0x10,0x08,0x08,0x04,0x00, |
| 133 | | 0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 134 | | 0x2a,0x15,0x2a,0x15,0x2a,0x15,0x2a,0x15 |
| 135 | | }; |
| 136 | | |
| 137 | | teleprinter_device::teleprinter_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 138 | | : generic_terminal_device(mconfig, TELEPRINTER, "Teleprinter", tag, owner, clock, "teleprinter", __FILE__) |
| 139 | | { |
| 140 | | } |
| 141 | | |
| 142 | | void teleprinter_device::scroll_line() |
| 143 | | { |
| 144 | | memmove(m_buffer,m_buffer+TELEPRINTER_WIDTH,(TELEPRINTER_HEIGHT-1)*TELEPRINTER_WIDTH); |
| 145 | | memset(m_buffer + TELEPRINTER_WIDTH*(TELEPRINTER_HEIGHT-1),0x20,TELEPRINTER_WIDTH); |
| 146 | | } |
| 147 | | |
| 148 | | void teleprinter_device::write_char(UINT8 data) { |
| 149 | | m_buffer[(TELEPRINTER_HEIGHT-1)*TELEPRINTER_WIDTH+m_x_pos] = data; |
| 150 | | m_x_pos++; |
| 151 | | if (m_x_pos >= TELEPRINTER_WIDTH) |
| 152 | | { |
| 153 | | m_x_pos = 0; |
| 154 | | scroll_line(); |
| 155 | | } |
| 156 | | } |
| 157 | | |
| 158 | | void teleprinter_device::clear() { |
| 159 | | memset(m_buffer,0,TELEPRINTER_WIDTH*TELEPRINTER_HEIGHT); |
| 160 | | m_x_pos = 0; |
| 161 | | } |
| 162 | | |
| 163 | | void teleprinter_device::term_write(UINT8 data) |
| 164 | | { |
| 165 | | switch(data) { |
| 166 | | case 10: m_x_pos = 0; |
| 167 | | scroll_line(); |
| 168 | | break; |
| 169 | | case 13: m_x_pos = 0; break; |
| 170 | | case 9: m_x_pos = (m_x_pos & 0xf8) + 8; |
| 171 | | if (m_x_pos >= TELEPRINTER_WIDTH) |
| 172 | | m_x_pos = TELEPRINTER_WIDTH-1; |
| 173 | | |
| 174 | | break; |
| 175 | | case 16: break; |
| 176 | | default: write_char(data); break; |
| 177 | | } |
| 178 | | } |
| 179 | | |
| 180 | | /*************************************************************************** |
| 181 | | VIDEO HARDWARE |
| 182 | | ***************************************************************************/ |
| 183 | | UINT32 teleprinter_device::tp_update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 184 | | { |
| 185 | | UINT8 code; |
| 186 | | int y, c, x, b; |
| 187 | | |
| 188 | | for (y = 0; y < TELEPRINTER_HEIGHT; y++) |
| 189 | | { |
| 190 | | for (c = 0; c < 8; c++) |
| 191 | | { |
| 192 | | int horpos = 0; |
| 193 | | for (x = 0; x < TELEPRINTER_WIDTH; x++) |
| 194 | | { |
| 195 | | code = teleprinter_font[(m_buffer[y*TELEPRINTER_WIDTH + x] & 0x7f) *8 + c]; |
| 196 | | for (b = 0; b < 8; b++) |
| 197 | | { |
| 198 | | bitmap.pix32(y*8 + c, horpos++) = (code >> b) & 0x01 ? 0 : 0x00ffffff; |
| 199 | | } |
| 200 | | } |
| 201 | | } |
| 202 | | } |
| 203 | | return 0; |
| 204 | | } |
| 205 | | |
| 206 | | static ASCII_KEYBOARD_INTERFACE( keyboard_intf ) |
| 207 | | { |
| 208 | | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, generic_terminal_device, kbd_put) |
| 209 | | }; |
| 210 | | |
| 211 | | /*************************************************************************** |
| 212 | | VIDEO HARDWARE |
| 213 | | ***************************************************************************/ |
| 214 | | MACHINE_CONFIG_FRAGMENT( generic_teleprinter ) |
| 215 | | MCFG_SCREEN_ADD(TELEPRINTER_SCREEN_TAG, RASTER) |
| 216 | | MCFG_SCREEN_REFRESH_RATE(50) |
| 217 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 218 | | MCFG_SCREEN_SIZE(TELEPRINTER_WIDTH*8, TELEPRINTER_HEIGHT*8) |
| 219 | | MCFG_SCREEN_VISIBLE_AREA(0, TELEPRINTER_WIDTH*8-1, 0, TELEPRINTER_HEIGHT*8-1) |
| 220 | | MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, teleprinter_device, tp_update) |
| 221 | | MCFG_ASCII_KEYBOARD_ADD(KEYBOARD_TAG, keyboard_intf) |
| 222 | | MACHINE_CONFIG_END |
| 223 | | |
| 224 | | machine_config_constructor teleprinter_device::device_mconfig_additions() const |
| 225 | | { |
| 226 | | return MACHINE_CONFIG_NAME(generic_teleprinter); |
| 227 | | } |
| 228 | | |
| 229 | | /*------------------------------------------------- |
| 230 | | device_reset - device-specific reset |
| 231 | | -------------------------------------------------*/ |
| 232 | | |
| 233 | | void teleprinter_device::device_reset() |
| 234 | | { |
| 235 | | clear(); |
| 236 | | generic_terminal_device::device_reset(); |
| 237 | | } |
| 238 | | |
| 239 | | const device_type TELEPRINTER = &device_creator<teleprinter_device>; |
shelves/new_menus/src/emu/machine/mc6843.c
| r29303 | r29304 | |
| 139 | 139 | /* setup/reset floppy drive */ |
| 140 | 140 | for ( i = 0; i < 4; i++ ) |
| 141 | 141 | { |
| 142 | | device_t * img = floppy_image( i ); |
| 143 | | floppy_mon_w(img, CLEAR_LINE); |
| 144 | | floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 ); |
| 145 | | floppy_drive_set_rpm( img, 300. ); |
| 142 | legacy_floppy_image_device * img = floppy_image( i ); |
| 143 | img->floppy_mon_w(CLEAR_LINE); |
| 144 | img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0 ); |
| 145 | img->floppy_drive_set_rpm( 300. ); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /* reset registers */ |
| r29303 | r29304 | |
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | |
| 165 | | device_t* mc6843_device::floppy_image( UINT8 drive ) |
| 165 | legacy_floppy_image_device* mc6843_device::floppy_image( UINT8 drive ) |
| 166 | 166 | { |
| 167 | | device_t *img = floppy_get_device( machine(), drive ); |
| 167 | legacy_floppy_image_device *img = floppy_get_device( machine(), drive ); |
| 168 | 168 | if (!img && owner()) { |
| 169 | 169 | // For slot devices, drives are typically attached to the slot rather than the machine |
| 170 | 170 | const char *floppy_name = NULL; |
| r29303 | r29304 | |
| 182 | 182 | floppy_name = FLOPPY_3; |
| 183 | 183 | break; |
| 184 | 184 | } |
| 185 | | img = owner()->subdevice(floppy_name); |
| 185 | img = owner()->subdevice<legacy_floppy_image_device>(floppy_name); |
| 186 | 186 | } |
| 187 | 187 | return img; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
| 191 | | device_t* mc6843_device::floppy_image( ) |
| 191 | legacy_floppy_image_device* mc6843_device::floppy_image( ) |
| 192 | 192 | { |
| 193 | 193 | return floppy_image( m_drive ); |
| 194 | 194 | } |
| r29303 | r29304 | |
| 262 | 262 | /* Seek Track Zero bottom half */ |
| 263 | 263 | void mc6843_device::finish_STZ( ) |
| 264 | 264 | { |
| 265 | | device_t* img = floppy_image( ); |
| 265 | legacy_floppy_image_device* img = floppy_image( ); |
| 266 | 266 | int i; |
| 267 | 267 | |
| 268 | 268 | /* seek to track zero */ |
| 269 | 269 | for ( i=0; i<83; i++ ) |
| 270 | 270 | { |
| 271 | | if (floppy_tk00_r(img) == CLEAR_LINE) |
| 271 | if (img->floppy_tk00_r() == CLEAR_LINE) |
| 272 | 272 | break; |
| 273 | | floppy_drive_seek( img, -1 ); |
| 273 | img->floppy_drive_seek( -1 ); |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | | LOG(( "%f mc6843_finish_STZ: actual=%i\n", machine().time().as_double(), floppy_drive_get_current_track( img ) )); |
| 276 | LOG(( "%f mc6843_finish_STZ: actual=%i\n", machine().time().as_double(), img->floppy_drive_get_current_track() )); |
| 277 | 277 | |
| 278 | 278 | /* update state */ |
| 279 | 279 | m_CTAR = 0; |
| 280 | 280 | m_GCR = 0; |
| 281 | 281 | m_SAR = 0; |
| 282 | | m_STRB |= floppy_tk00_r(img) << 4; |
| 282 | m_STRB |= img->floppy_tk00_r() << 4; |
| 283 | 283 | |
| 284 | 284 | cmd_end( ); |
| 285 | 285 | } |
| r29303 | r29304 | |
| 289 | 289 | /* Seek bottom half */ |
| 290 | 290 | void mc6843_device::finish_SEK( ) |
| 291 | 291 | { |
| 292 | | device_t* img = floppy_image( ); |
| 292 | legacy_floppy_image_device* img = floppy_image( ); |
| 293 | 293 | |
| 294 | 294 | /* seek to track */ |
| 295 | 295 | // TODO: not sure how CTAR bit 7 is handled here, but this is the safest approach for now |
| 296 | | floppy_drive_seek( img, m_GCR - (m_CTAR & 0x7F) ); |
| 296 | img->floppy_drive_seek( m_GCR - (m_CTAR & 0x7F) ); |
| 297 | 297 | |
| 298 | | LOG(( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", machine().time().as_double(), (m_CTAR & 0x7F), m_GCR, floppy_drive_get_current_track( img ) )); |
| 298 | LOG(( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", machine().time().as_double(), (m_CTAR & 0x7F), m_GCR, img->floppy_drive_get_current_track() )); |
| 299 | 299 | |
| 300 | 300 | /* update state */ |
| 301 | 301 | m_CTAR = m_GCR; |
| r29303 | r29304 | |
| 308 | 308 | /* preamble to all sector read / write commands, returns 1 if found */ |
| 309 | 309 | int mc6843_device::address_search( chrn_id* id ) |
| 310 | 310 | { |
| 311 | | device_t* img = floppy_image( ); |
| 311 | legacy_floppy_image_device* img = floppy_image( ); |
| 312 | 312 | int r = 0; |
| 313 | 313 | |
| 314 | 314 | while ( 1 ) |
| 315 | 315 | { |
| 316 | | if ( ( ! floppy_drive_get_next_id( img, m_side, id ) ) || ( id->flags & ID_FLAG_CRC_ERROR_IN_ID_FIELD ) || ( id->N != 0 ) ) |
| 316 | if ( ( ! img->floppy_drive_get_next_id( m_side, id ) ) || ( id->flags & ID_FLAG_CRC_ERROR_IN_ID_FIELD ) || ( id->N != 0 ) ) |
| 317 | 317 | { |
| 318 | 318 | /* read address error */ |
| 319 | 319 | LOG(( "%f mc6843_address_search: get_next_id failed\n", machine().time().as_double() )); |
| r29303 | r29304 | |
| 343 | 343 | return 1; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | | if ( floppy_drive_get_flag_state( img, FLOPPY_DRIVE_INDEX ) ) |
| 346 | if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) ) |
| 347 | 347 | { |
| 348 | 348 | r++; |
| 349 | 349 | if ( r >= 4 ) |
| r29303 | r29304 | |
| 403 | 403 | void mc6843_device::cont_SR( ) |
| 404 | 404 | { |
| 405 | 405 | chrn_id id; |
| 406 | | device_t* img = floppy_image( ); |
| 406 | legacy_floppy_image_device* img = floppy_image( ); |
| 407 | 407 | |
| 408 | 408 | /* sector seek */ |
| 409 | 409 | if ( ! address_search_read( &id ) ) |
| 410 | 410 | return; |
| 411 | 411 | |
| 412 | 412 | /* sector read */ |
| 413 | | floppy_drive_read_sector_data( img, m_side, id.data_id, m_data, 128 ); |
| 413 | img->floppy_drive_read_sector_data( m_side, id.data_id, m_data, 128 ); |
| 414 | 414 | m_data_idx = 0; |
| 415 | 415 | m_data_size = 128; |
| 416 | 416 | m_STRA |= 0x01; /* set Data Transfer Request */ |
| r29303 | r29304 | |
| 551 | 551 | data = m_CTAR; |
| 552 | 552 | LOG(( "%f %s mc6843_r: read CTAR %i (actual=%i)\n", |
| 553 | 553 | machine().time().as_double(), machine().describe_context(), data, |
| 554 | | floppy_drive_get_current_track( floppy_image( ) ) )); |
| 554 | floppy_image()->floppy_drive_get_current_track())); |
| 555 | 555 | break; |
| 556 | 556 | |
| 557 | 557 | case 2: /* Interrupt Status Register (ISR) */ |
| r29303 | r29304 | |
| 569 | 569 | case 3: /* Status Register A (STRA) */ |
| 570 | 570 | { |
| 571 | 571 | /* update */ |
| 572 | | device_t* img = floppy_image( ); |
| 573 | | int flag = floppy_drive_get_flag_state( img, FLOPPY_DRIVE_READY); |
| 572 | legacy_floppy_image_device* img = floppy_image( ); |
| 573 | int flag = img->floppy_drive_get_flag_state( FLOPPY_DRIVE_READY); |
| 574 | 574 | m_STRA &= 0xa3; |
| 575 | 575 | if ( flag & FLOPPY_DRIVE_READY ) |
| 576 | 576 | m_STRA |= 0x04; |
| 577 | 577 | |
| 578 | | m_STRA |= !floppy_tk00_r(img) << 3; |
| 579 | | m_STRA |= !floppy_wpt_r(img) << 4; |
| 578 | m_STRA |= !img->floppy_tk00_r() << 3; |
| 579 | m_STRA |= !img->floppy_wpt_r() << 4; |
| 580 | 580 | |
| 581 | 581 | if ( m_index_pulse ) |
| 582 | 582 | m_STRA |= 0x40; |
| r29303 | r29304 | |
| 605 | 605 | data = m_LTAR; |
| 606 | 606 | LOG(( "%f %s mc6843_r: read LTAR %i (actual=%i)\n", |
| 607 | 607 | machine().time().as_double(), machine().describe_context(), data, |
| 608 | | floppy_drive_get_current_track( floppy_image( ) ) )); |
| 608 | floppy_image()->floppy_drive_get_current_track())); |
| 609 | 609 | break; |
| 610 | 610 | |
| 611 | 611 | default: |
| r29303 | r29304 | |
| 639 | 639 | if ( m_data_idx >= m_data_size ) |
| 640 | 640 | { |
| 641 | 641 | /* end of sector write */ |
| 642 | | device_t* img = floppy_image( ); |
| 642 | legacy_floppy_image_device* img = floppy_image( ); |
| 643 | 643 | |
| 644 | 644 | LOG(( "%f %s mc6843_w: write sector %i\n", machine().time().as_double(), machine().describe_context(), m_data_id )); |
| 645 | 645 | |
| 646 | | floppy_drive_write_sector_data( |
| 647 | | img, m_side, m_data_id, |
| 646 | img->floppy_drive_write_sector_data( |
| 647 | m_side, m_data_id, |
| 648 | 648 | m_data, m_data_size, |
| 649 | 649 | (cmd == CMD_SWD) ? ID_FLAG_DELETED_DATA : 0 ); |
| 650 | 650 | |
| r29303 | r29304 | |
| 701 | 701 | if ( (m_data[2] == 0) && (m_data[4] == 0) ) |
| 702 | 702 | { |
| 703 | 703 | /* valid address id field */ |
| 704 | | device_t* img = floppy_image( ); |
| 704 | legacy_floppy_image_device* img = floppy_image( ); |
| 705 | 705 | UINT8 track = m_data[1]; |
| 706 | 706 | UINT8 sector = m_data[3]; |
| 707 | 707 | UINT8 filler = 0xe5; /* standard Thomson filler */ |
| 708 | 708 | LOG(( "%f %s mc6843_w: address id detected track=%i sector=%i\n", machine().time().as_double(), machine().describe_context(), track, sector)); |
| 709 | | floppy_drive_format_sector( img, m_side, sector, track, 0, sector, 0, filler ); |
| 709 | img->floppy_drive_format_sector( m_side, sector, track, 0, sector, 0, filler ); |
| 710 | 710 | } |
| 711 | 711 | else |
| 712 | 712 | { |
| r29303 | r29304 | |
| 736 | 736 | m_CTAR = data; |
| 737 | 737 | LOG(( "%f %s mc6843_w: set CTAR to %i %02X (actual=%i) \n", |
| 738 | 738 | machine().time().as_double(), machine().describe_context(), m_CTAR, data, |
| 739 | | floppy_drive_get_current_track( floppy_image( ) ) )); |
| 739 | floppy_image()->floppy_drive_get_current_track())); |
| 740 | 740 | break; |
| 741 | 741 | |
| 742 | 742 | case 2: /* Command Register (CMR) */ |
| r29303 | r29304 | |
| 816 | 816 | m_LTAR = data & 0x7f; |
| 817 | 817 | LOG(( "%f %s mc6843_w: set LTAR to %i %02X (actual=%i)\n", |
| 818 | 818 | machine().time().as_double(), machine().describe_context(), m_LTAR, data, |
| 819 | | floppy_drive_get_current_track( floppy_image( ) ) )); |
| 819 | floppy_image()->floppy_drive_get_current_track())); |
| 820 | 820 | break; |
| 821 | 821 | |
| 822 | 822 | default: |
shelves/new_menus/src/emu/machine/smc92x4.c
| r29303 | r29304 | |
| 200 | 200 | |
| 201 | 201 | int smc92x4_device::image_is_single_density() |
| 202 | 202 | { |
| 203 | | floppy_image_legacy *image = flopimg_get_image(m_drive); |
| 203 | floppy_image_legacy *image = m_drive->flopimg_get_image(); |
| 204 | 204 | return (floppy_get_track_size(image, 0, 0)<4000); |
| 205 | 205 | } |
| 206 | 206 | |
| r29303 | r29304 | |
| 436 | 436 | int redcur; |
| 437 | 437 | int precomp; |
| 438 | 438 | int write_long; |
| 439 | | mfm_harddisk_device *harddisk; |
| 440 | 439 | |
| 441 | 440 | switch (id) |
| 442 | 441 | { |
| r29303 | r29304 | |
| 481 | 480 | else |
| 482 | 481 | { |
| 483 | 482 | if (VERBOSE>5) LOG("smc92x4 step %s direction %d\n", m_drive->tag(), m_step_direction); |
| 484 | | floppy_drive_seek(m_drive, m_step_direction); |
| 483 | m_drive->floppy_drive_seek(m_step_direction); |
| 485 | 484 | } |
| 486 | 485 | } |
| 487 | 486 | else |
| 488 | 487 | { |
| 489 | 488 | if (VERBOSE>6) LOG("smc92x4 step harddisk direction %d\n", m_step_direction); |
| 490 | | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 491 | | harddisk->seek(m_step_direction); |
| 489 | m_harddisk->seek(m_step_direction); |
| 492 | 490 | } |
| 493 | 491 | sync_status_in(); |
| 494 | 492 | break; |
| r29303 | r29304 | |
| 566 | 564 | { |
| 567 | 565 | int des_cylinder, cur_cylinder; |
| 568 | 566 | bool found = false; |
| 569 | | mfm_harddisk_device *harddisk; |
| 570 | 567 | |
| 571 | 568 | sync_latches_out(); |
| 572 | 569 | sync_status_in(); |
| r29303 | r29304 | |
| 579 | 576 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 580 | 577 | { |
| 581 | 578 | chrn_id idflop; |
| 582 | | if (flopimg_get_image(m_drive) == NULL) |
| 579 | if (m_drive->flopimg_get_image() == NULL) |
| 583 | 580 | { |
| 584 | 581 | if (VERBOSE>2) LOG("smc92x4 warn: No disk in drive\n"); |
| 585 | 582 | m_register_r[CHIP_STATUS] |= CS_SYNCERR; |
| r29303 | r29304 | |
| 590 | 587 | if ((image_is_single_density() && in_single_density_mode()) |
| 591 | 588 | || (!image_is_single_density() && !in_single_density_mode())) |
| 592 | 589 | { |
| 593 | | found = floppy_drive_get_next_id(m_drive, m_register_w[DESIRED_HEAD]&0x0f, &idflop); |
| 590 | found = m_drive->floppy_drive_get_next_id(m_register_w[DESIRED_HEAD]&0x0f, &idflop); |
| 594 | 591 | copyid(idflop, id); /* Need to use bigger values for HD, but we don't use separate variables here */ |
| 595 | 592 | } |
| 596 | 593 | else |
| r29303 | r29304 | |
| 608 | 605 | } |
| 609 | 606 | else |
| 610 | 607 | { |
| 611 | | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 612 | | |
| 613 | | harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id); |
| 608 | m_harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id); |
| 614 | 609 | sync_status_in(); |
| 615 | 610 | if (!(m_register_r[DRIVE_STATUS]& DS_READY)) |
| 616 | 611 | { |
| r29303 | r29304 | |
| 670 | 665 | int found = false; |
| 671 | 666 | int foundsect = false; |
| 672 | 667 | int des_cylinder = 0; |
| 673 | | mfm_harddisk_device *harddisk; |
| 674 | 668 | |
| 675 | 669 | // Set command termination code. The error code is set first, and |
| 676 | 670 | // on success, it is cleared. |
| r29303 | r29304 | |
| 683 | 677 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 684 | 678 | { |
| 685 | 679 | chrn_id idflop; |
| 686 | | found = floppy_drive_get_next_id(m_drive, m_register_w[DESIRED_HEAD]&0x0f, &idflop); |
| 680 | found = m_drive->floppy_drive_get_next_id(m_register_w[DESIRED_HEAD]&0x0f, &idflop); |
| 687 | 681 | copyid(idflop, id); |
| 688 | 682 | if (/* pass==1 && */!found) |
| 689 | 683 | { |
| r29303 | r29304 | |
| 694 | 688 | } |
| 695 | 689 | else |
| 696 | 690 | { |
| 697 | | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 698 | | harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id); |
| 691 | m_harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id); |
| 699 | 692 | sync_status_in(); |
| 700 | 693 | if (!(m_register_r[DRIVE_STATUS]& DS_READY)) |
| 701 | 694 | { |
| r29303 | r29304 | |
| 742 | 735 | void smc92x4_device::data_transfer_read(chrn_id_hd id, int transfer_enable) |
| 743 | 736 | { |
| 744 | 737 | int i, retry, sector_len; |
| 745 | | mfm_harddisk_device *harddisk; |
| 746 | 738 | |
| 747 | 739 | int sector_data_id; |
| 748 | 740 | dynamic_buffer buf; |
| r29303 | r29304 | |
| 780 | 772 | |
| 781 | 773 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 782 | 774 | { |
| 783 | | floppy_drive_read_sector_data(m_drive, id.H, sector_data_id, buf, sector_len); |
| 775 | m_drive->floppy_drive_read_sector_data(id.H, sector_data_id, buf, sector_len); |
| 784 | 776 | } |
| 785 | 777 | else |
| 786 | 778 | { |
| 787 | 779 | // TODO: Should we get the sector length from the harddisk? |
| 788 | | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 789 | | harddisk->read_sector(id.C, id.H, id.R, buf); |
| 780 | m_harddisk->read_sector(id.C, id.H, id.R, buf); |
| 790 | 781 | } |
| 791 | 782 | sync_status_in(); |
| 792 | 783 | |
| r29303 | r29304 | |
| 837 | 828 | int retry, i, sector_len; |
| 838 | 829 | dynamic_buffer buf; |
| 839 | 830 | int sector_data_id; |
| 840 | | mfm_harddisk_device *harddisk; |
| 841 | 831 | sync_latches_out(); |
| 842 | 832 | sync_status_in(); |
| 843 | 833 | |
| r29303 | r29304 | |
| 876 | 866 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 877 | 867 | { |
| 878 | 868 | if (VERBOSE>4) LOG("smc92x4 info: write sector CHS=(%d,%d,%d)\n", id.C, id.H, id.R); |
| 879 | | floppy_drive_write_sector_data(m_drive, id.H, sector_data_id, buf, sector_len, false); |
| 869 | m_drive->floppy_drive_write_sector_data(id.H, sector_data_id, buf, sector_len, false); |
| 880 | 870 | } |
| 881 | 871 | else |
| 882 | 872 | { |
| 883 | | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 884 | | harddisk->write_sector(id.C, id.H, id.R, buf); |
| 873 | m_harddisk->write_sector(id.C, id.H, id.R, buf); |
| 885 | 874 | } |
| 886 | 875 | sync_status_in(); |
| 887 | 876 | |
| r29303 | r29304 | |
| 1344 | 1333 | |
| 1345 | 1334 | sync_status_in(); |
| 1346 | 1335 | |
| 1347 | | floppy = flopimg_get_image(m_drive); |
| 1336 | floppy = m_drive->flopimg_get_image(); |
| 1348 | 1337 | |
| 1349 | 1338 | if (floppy != NULL) |
| 1350 | 1339 | data_count = floppy_get_track_size(floppy, 0, 0); |
| r29303 | r29304 | |
| 1486 | 1475 | memset(&buffer[index], gap_byte, gap4); |
| 1487 | 1476 | index += gap4; |
| 1488 | 1477 | |
| 1489 | | floppy_drive_write_track_data_info_buffer(m_drive, m_register_w[DESIRED_HEAD]&0x0f, buffer, &data_count); |
| 1478 | m_drive->floppy_drive_write_track_data_info_buffer(m_register_w[DESIRED_HEAD]&0x0f, buffer, &data_count); |
| 1490 | 1479 | sync_status_in(); |
| 1491 | 1480 | } |
| 1492 | 1481 | |
| r29303 | r29304 | |
| 1506 | 1495 | int normal_data_mark = flags & 0x10; |
| 1507 | 1496 | int data_count=0; |
| 1508 | 1497 | |
| 1509 | | mfm_harddisk_device *harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 1510 | | |
| 1511 | 1498 | dynamic_buffer buffer; |
| 1512 | 1499 | |
| 1513 | 1500 | sync_status_in(); |
| r29303 | r29304 | |
| 1585 | 1572 | for (i=0; i < gap4; i++) buffer[index++] = gap_byte; |
| 1586 | 1573 | |
| 1587 | 1574 | // Now write the whole track |
| 1588 | | harddisk->write_track(m_register_w[DESIRED_HEAD]&0x0f, buffer, data_count); |
| 1575 | m_harddisk->write_track(m_register_w[DESIRED_HEAD]&0x0f, buffer, data_count); |
| 1589 | 1576 | |
| 1590 | 1577 | sync_status_in(); |
| 1591 | 1578 | } |
| r29303 | r29304 | |
| 1618 | 1605 | |
| 1619 | 1606 | sync_latches_out(); |
| 1620 | 1607 | |
| 1621 | | floppy = flopimg_get_image(m_drive); |
| 1608 | floppy = m_drive->flopimg_get_image(); |
| 1622 | 1609 | |
| 1623 | 1610 | /* Determine the track size. We cannot allow different sizes in this design. */ |
| 1624 | 1611 | if (floppy != NULL) |
| r29303 | r29304 | |
| 1634 | 1621 | |
| 1635 | 1622 | buffer = global_alloc_array(UINT8, data_count); |
| 1636 | 1623 | |
| 1637 | | floppy_drive_read_track_data_info_buffer(m_drive, m_register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count); |
| 1624 | m_drive->floppy_drive_read_track_data_info_buffer(m_register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count); |
| 1638 | 1625 | sync_status_in(); |
| 1639 | 1626 | |
| 1640 | 1627 | // Transfer the buffer to the external memory. We assume the memory |
| r29303 | r29304 | |
| 1662 | 1649 | int i; |
| 1663 | 1650 | UINT8 *buffer; |
| 1664 | 1651 | int data_count=0; |
| 1665 | | mfm_harddisk_device *harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 1666 | | |
| 1667 | 1652 | sync_latches_out(); |
| 1668 | 1653 | |
| 1669 | | data_count = harddisk->get_track_length(); |
| 1654 | data_count = m_harddisk->get_track_length(); |
| 1670 | 1655 | buffer = global_alloc_array(UINT8, data_count); |
| 1671 | 1656 | |
| 1672 | 1657 | /* buffer and data_count are allocated and set by the function. */ |
| 1673 | | harddisk->read_track(m_register_w[DESIRED_HEAD]&0x0f, buffer); |
| 1658 | m_harddisk->read_track(m_register_w[DESIRED_HEAD]&0x0f, buffer); |
| 1674 | 1659 | sync_status_in(); |
| 1675 | 1660 | |
| 1676 | 1661 | if (!(m_register_r[DRIVE_STATUS] & DS_READY)) |
| r29303 | r29304 | |
| 2004 | 1989 | if (VERBOSE>0) LOG("smc92x4: use realistic timing: %02x\n", realistic); |
| 2005 | 1990 | } |
| 2006 | 1991 | |
| 2007 | | void smc92x4_device::connect_drive(device_t *drive) |
| 1992 | void smc92x4_device::connect_floppy_drive(legacy_floppy_image_device *drive) |
| 2008 | 1993 | { |
| 2009 | 1994 | m_drive = drive; |
| 2010 | 1995 | if (VERBOSE>3) |
| r29303 | r29304 | |
| 2013 | 1998 | else LOG("smc92x4: Connect drive %s\n", drive->tag()); |
| 2014 | 1999 | } |
| 2015 | 2000 | } |
| 2001 | void smc92x4_device::connect_hard_drive(mfm_harddisk_device *drive) |
| 2002 | { |
| 2003 | m_harddisk = drive; |
| 2004 | if (VERBOSE>3) |
| 2005 | { |
| 2006 | if (drive==NULL) LOG("smc92x4: Unselect all drives\n"); |
| 2007 | else LOG("smc92x4: Connect drive %s\n", drive->tag()); |
| 2008 | } |
| 2009 | } |
| 2016 | 2010 | |
| 2017 | 2011 | void smc92x4_device::reset() |
| 2018 | 2012 | { |
shelves/new_menus/src/emu/machine/wd17xx.c
| r29303 | r29304 | |
| 154 | 154 | #include "emu.h" |
| 155 | 155 | #include "formats/imageutl.h" |
| 156 | 156 | #include "machine/wd17xx.h" |
| 157 | | #include "imagedev/flopdrv.h" |
| 158 | 157 | |
| 159 | 158 | /*************************************************************************** |
| 160 | 159 | CONSTANTS |
| r29303 | r29304 | |
| 494 | 493 | if (1) // image_slotexists(m_drive) : FIXME |
| 495 | 494 | { |
| 496 | 495 | /* keep stepping until track 0 is received or 255 steps have been done */ |
| 497 | | while (floppy_tk00_r(m_drive) && (step_counter != 0)) |
| 496 | while (m_drive->floppy_tk00_r() && (step_counter != 0)) |
| 498 | 497 | { |
| 499 | 498 | /* update time to simulate seek time busy signal */ |
| 500 | 499 | m_busy_count++; |
| 501 | | floppy_drive_seek(m_drive, m_direction); |
| 500 | m_drive->floppy_drive_seek(m_direction); |
| 502 | 501 | step_counter--; |
| 503 | 502 | } |
| 504 | 503 | } |
| r29303 | r29304 | |
| 539 | 538 | //int len = m_buffer[i+4]; |
| 540 | 539 | int filler = 0xe5; /* IBM and Thomson */ |
| 541 | 540 | int density = m_density; |
| 542 | | floppy_drive_format_sector(m_drive,side,sector,track, |
| 541 | m_drive->floppy_drive_format_sector(side,sector,track, |
| 543 | 542 | m_hd,sector,density?1:0,filler); |
| 544 | 543 | i += 128; /* at least... */ |
| 545 | 544 | } |
| r29303 | r29304 | |
| 556 | 555 | selected format. |
| 557 | 556 | */ |
| 558 | 557 | m_data_count = 0; |
| 559 | | floppy = flopimg_get_image(m_drive); |
| 558 | floppy = m_drive->flopimg_get_image(); |
| 560 | 559 | if (floppy != NULL) |
| 561 | 560 | m_data_count = floppy_get_track_size(floppy, m_hd, m_track); |
| 562 | 561 | |
| r29303 | r29304 | |
| 568 | 567 | m_data_count = wd17xx_dden() ? TRKSIZE_SD : TRKSIZE_DD; |
| 569 | 568 | } |
| 570 | 569 | |
| 571 | | floppy_drive_write_track_data_info_buffer( m_drive, m_hd, (char *)m_buffer, &(m_data_count) ); |
| 570 | m_drive->floppy_drive_write_track_data_info_buffer( m_hd, (char *)m_buffer, &(m_data_count) ); |
| 572 | 571 | |
| 573 | 572 | m_data_offset = 0; |
| 574 | 573 | |
| r29303 | r29304 | |
| 707 | 706 | /* Determine the track size. We cannot allow different sizes in this |
| 708 | 707 | design (see above, write_track). */ |
| 709 | 708 | m_data_count = 0; |
| 710 | | floppy = flopimg_get_image(m_drive); |
| 709 | floppy = m_drive->flopimg_get_image(); |
| 711 | 710 | if (floppy != NULL) |
| 712 | 711 | m_data_count = floppy_get_track_size(floppy, m_hd, m_track); |
| 713 | 712 | |
| r29303 | r29304 | |
| 719 | 718 | m_data_count = wd17xx_dden() ? TRKSIZE_SD : TRKSIZE_DD; |
| 720 | 719 | } |
| 721 | 720 | |
| 722 | | floppy_drive_read_track_data_info_buffer( m_drive, m_hd, (char *)m_buffer, &(m_data_count) ); |
| 721 | m_drive->floppy_drive_read_track_data_info_buffer( m_hd, (char *)m_buffer, &(m_data_count) ); |
| 723 | 722 | |
| 724 | 723 | m_data_offset = 0; |
| 725 | 724 | |
| r29303 | r29304 | |
| 736 | 735 | m_status &= ~(STA_2_CRC_ERR | STA_2_REC_N_FND); |
| 737 | 736 | |
| 738 | 737 | /* get next id from disc */ |
| 739 | | if (floppy_drive_get_next_id(m_drive, m_hd, &id)) |
| 738 | if (m_drive->floppy_drive_get_next_id(m_hd, &id)) |
| 740 | 739 | { |
| 741 | 740 | UINT16 crc = 0xffff; |
| 742 | 741 | |
| r29303 | r29304 | |
| 809 | 808 | |
| 810 | 809 | while (revolution_count!=4) |
| 811 | 810 | { |
| 812 | | if (floppy_drive_get_next_id(m_drive, m_hd, &id)) |
| 811 | if (m_drive->floppy_drive_get_next_id(m_hd, &id)) |
| 813 | 812 | { |
| 814 | 813 | /* compare track */ |
| 815 | 814 | if (id.C == m_track) |
| r29303 | r29304 | |
| 834 | 833 | } |
| 835 | 834 | |
| 836 | 835 | /* index set? */ |
| 837 | | if (floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_INDEX)) |
| 836 | if (m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_INDEX)) |
| 838 | 837 | { |
| 839 | 838 | /* update revolution count */ |
| 840 | 839 | revolution_count++; |
| r29303 | r29304 | |
| 886 | 885 | m_data_count = m_sector_length; |
| 887 | 886 | |
| 888 | 887 | /* read data */ |
| 889 | | floppy_drive_read_sector_data(m_drive, m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length); |
| 888 | m_drive->floppy_drive_read_sector_data(m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length); |
| 890 | 889 | |
| 891 | 890 | wd17xx_timed_data_request(); |
| 892 | 891 | |
| r29303 | r29304 | |
| 936 | 935 | m_data_count = m_sector_length; |
| 937 | 936 | |
| 938 | 937 | /* write data */ |
| 939 | | floppy_drive_write_sector_data(m_drive, m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length, m_write_cmd & 0x01); |
| 938 | m_drive->floppy_drive_write_sector_data(m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length, m_write_cmd & 0x01); |
| 940 | 939 | } |
| 941 | 940 | } |
| 942 | 941 | |
| r29303 | r29304 | |
| 957 | 956 | /* must be found within 5 revolutions otherwise error */ |
| 958 | 957 | while (revolution_count!=5) |
| 959 | 958 | { |
| 960 | | if (floppy_drive_get_next_id(m_drive, m_hd, &id)) |
| 959 | if (m_drive->floppy_drive_get_next_id( m_hd, &id)) |
| 961 | 960 | { |
| 962 | 961 | /* compare track */ |
| 963 | 962 | if (id.C == m_track) |
| r29303 | r29304 | |
| 969 | 968 | } |
| 970 | 969 | |
| 971 | 970 | /* index set? */ |
| 972 | | if (floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_INDEX)) |
| 971 | if (m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_INDEX)) |
| 973 | 972 | { |
| 974 | 973 | /* update revolution count */ |
| 975 | 974 | revolution_count++; |
| r29303 | r29304 | |
| 992 | 991 | if (VERBOSE) |
| 993 | 992 | logerror("wd179x: Read Sector callback.\n"); |
| 994 | 993 | |
| 995 | | if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) |
| 994 | if (!m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 996 | 995 | wd17xx_complete_command(DELAY_NOTREADY); |
| 997 | 996 | else |
| 998 | 997 | wd17xx_read_sector(); |
| r29303 | r29304 | |
| 1008 | 1007 | if (VERBOSE) |
| 1009 | 1008 | logerror("wd179x: Write Sector callback.\n"); |
| 1010 | 1009 | |
| 1011 | | if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) |
| 1010 | if (!m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1012 | 1011 | wd17xx_complete_command(DELAY_NOTREADY); |
| 1013 | 1012 | else |
| 1014 | 1013 | { |
| 1015 | 1014 | /* drive write protected? */ |
| 1016 | | if (floppy_wpt_r(m_drive) == CLEAR_LINE) |
| 1015 | if (m_drive->floppy_wpt_r() == CLEAR_LINE) |
| 1017 | 1016 | { |
| 1018 | 1017 | m_status |= STA_2_WRITE_PRO; |
| 1019 | 1018 | |
| r29303 | r29304 | |
| 1080 | 1079 | |
| 1081 | 1080 | if (m_intf->floppy_drive_tags[drive] != NULL) |
| 1082 | 1081 | { |
| 1083 | | m_drive = siblingdevice(m_intf->floppy_drive_tags[drive]); |
| 1082 | m_drive = siblingdevice<legacy_floppy_image_device>(m_intf->floppy_drive_tags[drive]); |
| 1084 | 1083 | } |
| 1085 | 1084 | } |
| 1086 | 1085 | |
| r29303 | r29304 | |
| 1201 | 1200 | else |
| 1202 | 1201 | { |
| 1203 | 1202 | m_status &= ~STA_1_NOT_READY; |
| 1204 | | if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) |
| 1203 | if (!m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1205 | 1204 | m_status |= STA_1_NOT_READY; |
| 1206 | 1205 | } |
| 1207 | 1206 | |
| r29303 | r29304 | |
| 1216 | 1215 | result |= m_idx << 1; |
| 1217 | 1216 | |
| 1218 | 1217 | /* bit 2, track 0 state, inverted */ |
| 1219 | | result |= !floppy_tk00_r(m_drive) << 2; |
| 1218 | result |= !m_drive->floppy_tk00_r() << 2; |
| 1220 | 1219 | |
| 1221 | 1220 | if (m_command_type==TYPE_I) |
| 1222 | 1221 | { |
| r29303 | r29304 | |
| 1227 | 1226 | } |
| 1228 | 1227 | |
| 1229 | 1228 | /* bit 6, write protect, inverted */ |
| 1230 | | result |= !floppy_wpt_r(m_drive) << 6; |
| 1229 | result |= !m_drive->floppy_wpt_r() << 6; |
| 1231 | 1230 | } |
| 1232 | 1231 | |
| 1233 | 1232 | /* eventually set data request bit */ |
| r29303 | r29304 | |
| 1283 | 1282 | if (type() == WD1770 || type() == WD1772) |
| 1284 | 1283 | { |
| 1285 | 1284 | m_mo = ASSERT_LINE; |
| 1286 | | floppy_mon_w(m_drive, CLEAR_LINE); |
| 1285 | m_drive->floppy_mon_w(CLEAR_LINE); |
| 1287 | 1286 | } |
| 1288 | 1287 | |
| 1289 | | floppy_drive_set_ready_state(m_drive, 1,0); |
| 1288 | m_drive->floppy_drive_set_ready_state(1,0); |
| 1290 | 1289 | |
| 1291 | 1290 | if (!BIT(m_interrupt, 3)) |
| 1292 | 1291 | { |
| r29303 | r29304 | |
| 1409 | 1408 | m_status &= ~STA_2_LOST_DAT; |
| 1410 | 1409 | wd17xx_clear_drq(); |
| 1411 | 1410 | |
| 1412 | | if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) |
| 1411 | if (!m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1413 | 1412 | { |
| 1414 | 1413 | wd17xx_complete_command(DELAY_NOTREADY); |
| 1415 | 1414 | } |
| 1416 | 1415 | else |
| 1417 | 1416 | { |
| 1418 | 1417 | /* drive write protected? */ |
| 1419 | | if (floppy_wpt_r(m_drive) == CLEAR_LINE) |
| 1418 | if (m_drive->floppy_wpt_r() == CLEAR_LINE) |
| 1420 | 1419 | { |
| 1421 | 1420 | /* yes */ |
| 1422 | 1421 | m_status |= STA_2_WRITE_PRO; |
| r29303 | r29304 | |
| 1452 | 1451 | |
| 1453 | 1452 | wd17xx_clear_drq(); |
| 1454 | 1453 | |
| 1455 | | if (floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) |
| 1454 | if (m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1456 | 1455 | wd17xx_read_id(); |
| 1457 | 1456 | else |
| 1458 | 1457 | wd17xx_complete_command(DELAY_NOTREADY); |
| r29303 | r29304 | |
| 1519 | 1518 | /* update track reg */ |
| 1520 | 1519 | m_track += m_direction; |
| 1521 | 1520 | |
| 1522 | | floppy_drive_seek(m_drive, m_direction); |
| 1521 | m_drive->floppy_drive_seek(m_direction); |
| 1523 | 1522 | } |
| 1524 | 1523 | |
| 1525 | 1524 | /* simulate seek time busy signal */ |
| r29303 | r29304 | |
| 1541 | 1540 | /* simulate seek time busy signal */ |
| 1542 | 1541 | m_busy_count = 0; //((data & FDC_STEP_RATE) + 1); |
| 1543 | 1542 | |
| 1544 | | floppy_drive_seek(m_drive, m_direction); |
| 1543 | m_drive->floppy_drive_seek(m_direction); |
| 1545 | 1544 | |
| 1546 | 1545 | if (data & FDC_STEP_UPDATE) |
| 1547 | 1546 | m_track += m_direction; |
| r29303 | r29304 | |
| 1564 | 1563 | /* simulate seek time busy signal */ |
| 1565 | 1564 | m_busy_count = 0; //((data & FDC_STEP_RATE) + 1); |
| 1566 | 1565 | |
| 1567 | | floppy_drive_seek(m_drive, m_direction); |
| 1566 | m_drive->floppy_drive_seek(m_direction); |
| 1568 | 1567 | |
| 1569 | 1568 | if (data & FDC_STEP_UPDATE) |
| 1570 | 1569 | m_track += m_direction; |
| r29303 | r29304 | |
| 1586 | 1585 | m_busy_count = 0; //((data & FDC_STEP_RATE) + 1); |
| 1587 | 1586 | |
| 1588 | 1587 | /* for now only allows a single drive to be selected */ |
| 1589 | | floppy_drive_seek(m_drive, m_direction); |
| 1588 | m_drive->floppy_drive_seek(m_direction); |
| 1590 | 1589 | |
| 1591 | 1590 | if (data & FDC_STEP_UPDATE) |
| 1592 | 1591 | m_track += m_direction; |
| r29303 | r29304 | |
| 2045 | 2044 | for (i = 0; i < 4; i++) |
| 2046 | 2045 | { |
| 2047 | 2046 | if(m_intf->floppy_drive_tags[i]!=NULL) { |
| 2048 | | device_t *img = NULL; |
| 2047 | legacy_floppy_image_device *img = NULL; |
| 2049 | 2048 | |
| 2050 | | img = siblingdevice(m_intf->floppy_drive_tags[i]); |
| 2049 | img = siblingdevice<legacy_floppy_image_device>(m_intf->floppy_drive_tags[i]); |
| 2051 | 2050 | |
| 2052 | 2051 | if (img!=NULL) { |
| 2053 | | floppy_drive_set_controller(img,this); |
| 2054 | | floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback); |
| 2055 | | floppy_drive_set_rpm( img, 300.); |
| 2052 | img->floppy_drive_set_controller(this); |
| 2053 | img->floppy_drive_set_index_pulse_callback(wd17xx_index_pulse_callback); |
| 2054 | img->floppy_drive_set_rpm( 300.); |
| 2056 | 2055 | } |
| 2057 | 2056 | } |
| 2058 | 2057 | } |
shelves/new_menus/src/emu/machine/i8271.c
| r29303 | r29304 | |
| 14 | 14 | |
| 15 | 15 | #include "emu.h" |
| 16 | 16 | #include "i8271.h" |
| 17 | | #include "imagedev/flopdrv.h" |
| 18 | 17 | |
| 19 | 18 | /* data request */ |
| 20 | 19 | #define I8271_FLAGS_DATA_REQUEST 0x01 |
| r29303 | r29304 | |
| 238 | 237 | set_dma_drq(); |
| 239 | 238 | } |
| 240 | 239 | |
| 241 | | device_t *i8271_device::current_image() |
| 240 | legacy_floppy_image_device *i8271_device::current_image() |
| 242 | 241 | { |
| 243 | 242 | if (m_floppy_drive_tags[m_drive]!=NULL) { |
| 244 | | return machine().device(m_floppy_drive_tags[m_drive]); |
| 243 | return machine().device<legacy_floppy_image_device>(m_floppy_drive_tags[m_drive]); |
| 245 | 244 | } else { |
| 246 | 245 | return NULL; |
| 247 | 246 | } |
| r29303 | r29304 | |
| 250 | 249 | |
| 251 | 250 | void i8271_device::seek_to_track(int track) |
| 252 | 251 | { |
| 253 | | device_t *img = current_image(); |
| 252 | legacy_floppy_image_device *img = current_image(); |
| 254 | 253 | if (track==0) |
| 255 | 254 | { |
| 256 | 255 | /* seek to track 0 */ |
| r29303 | r29304 | |
| 259 | 258 | /*logerror("step\n"); */ |
| 260 | 259 | |
| 261 | 260 | /* track 0 not set, not seeked more than 255 tracks */ |
| 262 | | while (floppy_tk00_r(img) && (StepCount != 0)) |
| 261 | while (img->floppy_tk00_r() && (StepCount != 0)) |
| 263 | 262 | { |
| 264 | 263 | /* logerror("step\n"); */ |
| 265 | 264 | StepCount--; |
| 266 | | floppy_drive_seek(img, -1); |
| 265 | img->floppy_drive_seek(-1); |
| 267 | 266 | } |
| 268 | 267 | |
| 269 | 268 | m_CurrentTrack[m_drive] = 0; |
| r29303 | r29304 | |
| 297 | 296 | |
| 298 | 297 | |
| 299 | 298 | /* seek to track 0 */ |
| 300 | | floppy_drive_seek(img, SignedTracks); |
| 299 | img->floppy_drive_seek(SignedTracks); |
| 301 | 300 | |
| 302 | 301 | m_CurrentTrack[m_drive] = track; |
| 303 | 302 | } |
| r29303 | r29304 | |
| 610 | 609 | case I8271_COMMAND_WRITE_DATA_SINGLE_RECORD: |
| 611 | 610 | { |
| 612 | 611 | /* put the buffer to the sector */ |
| 613 | | floppy_drive_write_sector_data(current_image(), m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7),0); |
| 612 | current_image()->floppy_drive_write_sector_data(m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7),0); |
| 614 | 613 | |
| 615 | 614 | /* completed all sectors? */ |
| 616 | 615 | m_Counter--; |
| r29303 | r29304 | |
| 653 | 652 | if (find_sector()) |
| 654 | 653 | { |
| 655 | 654 | /* get the sector into the buffer */ |
| 656 | | floppy_drive_read_sector_data(current_image(), m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7)); |
| 655 | current_image()->floppy_drive_read_sector_data(m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7)); |
| 657 | 656 | |
| 658 | 657 | /* initialise for reading */ |
| 659 | 658 | initialise_execution_phase_read(1<<(m_ID_N+7)); |
| r29303 | r29304 | |
| 672 | 671 | chrn_id id; |
| 673 | 672 | |
| 674 | 673 | /* get next id from disc */ |
| 675 | | floppy_drive_get_next_id(current_image(), m_side,&id); |
| 674 | current_image()->floppy_drive_get_next_id(m_side,&id); |
| 676 | 675 | |
| 677 | 676 | m_pExecutionPhaseData[0] = id.C; |
| 678 | 677 | m_pExecutionPhaseData[1] = id.H; |
| r29303 | r29304 | |
| 704 | 703 | |
| 705 | 704 | int i8271_device::find_sector() |
| 706 | 705 | { |
| 707 | | device_t *img = current_image(); |
| 706 | legacy_floppy_image_device *img = current_image(); |
| 708 | 707 | // int track_count_attempt; |
| 709 | 708 | |
| 710 | 709 | // track_count_attempt |
| r29303 | r29304 | |
| 719 | 718 | chrn_id id; |
| 720 | 719 | |
| 721 | 720 | /* get next id from disc */ |
| 722 | | if (floppy_drive_get_next_id(img, m_side,&id)) |
| 721 | if (img->floppy_drive_get_next_id(m_side,&id)) |
| 723 | 722 | { |
| 724 | 723 | /* tested on Amstrad CPC - All bytes must match, otherwise |
| 725 | 724 | a NO DATA error is reported */ |
| r29303 | r29304 | |
| 742 | 741 | } |
| 743 | 742 | |
| 744 | 743 | /* index set? */ |
| 745 | | if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_INDEX)) |
| 744 | if (img->floppy_drive_get_flag_state(FLOPPY_DRIVE_INDEX)) |
| 746 | 745 | { |
| 747 | 746 | index_count++; |
| 748 | 747 | } |
| r29303 | r29304 | |
| 759 | 758 | |
| 760 | 759 | void i8271_device::command_execute() |
| 761 | 760 | { |
| 762 | | device_t *img = current_image(); |
| 761 | legacy_floppy_image_device *img = current_image(); |
| 763 | 762 | |
| 764 | 763 | /* clear it = good completion status */ |
| 765 | 764 | /* this will be changed if anything bad happens! */ |
| r29303 | r29304 | |
| 885 | 884 | m_drive_control_input = (1<<6) | (1<<2); |
| 886 | 885 | |
| 887 | 886 | /* bit 3 = 0 if write protected */ |
| 888 | | m_drive_control_input |= floppy_wpt_r(img) << 3; |
| 887 | m_drive_control_input |= img->floppy_wpt_r() << 3; |
| 889 | 888 | |
| 890 | 889 | /* bit 1 = 0 if head at track 0 */ |
| 891 | | m_drive_control_input |= floppy_tk00_r(img) << 1; |
| 890 | m_drive_control_input |= img->floppy_tk00_r() << 1; |
| 892 | 891 | |
| 893 | 892 | /* need to setup this register based on drive selected */ |
| 894 | 893 | data = m_drive_control_input; |
| r29303 | r29304 | |
| 1021 | 1020 | |
| 1022 | 1021 | /* load head - on mini-sized drives this turns on the disc motor, |
| 1023 | 1022 | on standard-sized drives this loads the head and turns the motor on */ |
| 1024 | | floppy_mon_w(img, !BIT(m_CommandParameters[1], 3)); |
| 1025 | | floppy_drive_set_ready_state(img, 1, 1); |
| 1023 | img->floppy_mon_w(!BIT(m_CommandParameters[1], 3)); |
| 1024 | img->floppy_drive_set_ready_state(1, 1); |
| 1026 | 1025 | |
| 1027 | 1026 | /* step pin changed? if so perform a step in the direction indicated */ |
| 1028 | 1027 | if (((m_drive_control_output^m_CommandParameters[1]) & (1<<1))!=0) |
| r29303 | r29304 | |
| 1042 | 1041 | signed_tracks = -1; |
| 1043 | 1042 | } |
| 1044 | 1043 | |
| 1045 | | floppy_drive_seek(img, signed_tracks); |
| 1044 | img->floppy_drive_seek(signed_tracks); |
| 1046 | 1045 | } |
| 1047 | 1046 | } |
| 1048 | 1047 | |
| r29303 | r29304 | |
| 1081 | 1080 | /* these two do not appear to be set at all! ?? */ |
| 1082 | 1081 | |
| 1083 | 1082 | if (m_floppy_drive_tags[0]!=NULL) { |
| 1084 | | if (floppy_drive_get_flag_state(machine().device(m_floppy_drive_tags[0]), FLOPPY_DRIVE_READY)) |
| 1083 | if (machine().device<legacy_floppy_image_device>(m_floppy_drive_tags[0])->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1085 | 1084 | { |
| 1086 | 1085 | status |= (1<<2); |
| 1087 | 1086 | } |
| 1088 | 1087 | } |
| 1089 | 1088 | |
| 1090 | 1089 | if (m_floppy_drive_tags[1]!=NULL) { |
| 1091 | | if (floppy_drive_get_flag_state(machine().device(m_floppy_drive_tags[1]), FLOPPY_DRIVE_READY)) |
| 1090 | if (machine().device<legacy_floppy_image_device>(m_floppy_drive_tags[1])->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1092 | 1091 | { |
| 1093 | 1092 | status |= (1<<6); |
| 1094 | 1093 | } |
| 1095 | 1094 | } |
| 1096 | 1095 | |
| 1097 | 1096 | /* bit 3 = 1 if write protected */ |
| 1098 | | status |= !floppy_wpt_r(img) << 3; |
| 1097 | status |= !img->floppy_wpt_r() << 3; |
| 1099 | 1098 | |
| 1100 | 1099 | /* bit 1 = 1 if head at track 0 */ |
| 1101 | | status |= !floppy_tk00_r(img) << 1; |
| 1100 | status |= !img->floppy_tk00_r() << 1; |
| 1102 | 1101 | |
| 1103 | 1102 | m_ResultRegister = status; |
| 1104 | 1103 | command_complete(1,0); |
| r29303 | r29304 | |
| 1140 | 1139 | |
| 1141 | 1140 | get_drive(); |
| 1142 | 1141 | |
| 1143 | | if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| 1142 | if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1144 | 1143 | { |
| 1145 | 1144 | /* Completion type: operation intervention probably required for recovery */ |
| 1146 | 1145 | /* Completion code: Drive not ready */ |
| r29303 | r29304 | |
| 1173 | 1172 | |
| 1174 | 1173 | get_drive(); |
| 1175 | 1174 | |
| 1176 | | if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| 1175 | if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1177 | 1176 | { |
| 1178 | 1177 | /* Completion type: operation intervention probably required for recovery */ |
| 1179 | 1178 | /* Completion code: Drive not ready */ |
| r29303 | r29304 | |
| 1212 | 1211 | |
| 1213 | 1212 | m_drive_control_output &=~1; |
| 1214 | 1213 | |
| 1215 | | if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| 1214 | if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1216 | 1215 | { |
| 1217 | 1216 | /* Completion type: operation intervention probably required for recovery */ |
| 1218 | 1217 | /* Completion code: Drive not ready */ |
| r29303 | r29304 | |
| 1221 | 1220 | } |
| 1222 | 1221 | else |
| 1223 | 1222 | { |
| 1224 | | if (floppy_wpt_r(img) == CLEAR_LINE) |
| 1223 | if (img->floppy_wpt_r() == CLEAR_LINE) |
| 1225 | 1224 | { |
| 1226 | 1225 | /* Completion type: operation intervention probably required for recovery */ |
| 1227 | 1226 | /* Completion code: Drive write protected */ |
| r29303 | r29304 | |
| 1257 | 1256 | |
| 1258 | 1257 | m_drive_control_output &=~1; |
| 1259 | 1258 | |
| 1260 | | if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| 1259 | if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1261 | 1260 | { |
| 1262 | 1261 | /* Completion type: operation intervention probably required for recovery */ |
| 1263 | 1262 | /* Completion code: Drive not ready */ |
| r29303 | r29304 | |
| 1266 | 1265 | } |
| 1267 | 1266 | else |
| 1268 | 1267 | { |
| 1269 | | if (floppy_wpt_r(img) == CLEAR_LINE) |
| 1268 | if (img->floppy_wpt_r() == CLEAR_LINE) |
| 1270 | 1269 | { |
| 1271 | 1270 | /* Completion type: operation intervention probably required for recovery */ |
| 1272 | 1271 | /* Completion code: Drive write protected */ |
| r29303 | r29304 | |
| 1296 | 1295 | |
| 1297 | 1296 | get_drive(); |
| 1298 | 1297 | |
| 1299 | | if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| 1298 | if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY)) |
| 1300 | 1299 | { |
| 1301 | 1300 | /* Completion type: operation intervention probably required for recovery */ |
| 1302 | 1301 | /* Completion code: Drive not ready */ |
shelves/new_menus/src/emu/imagedev/flopdrv.c
| r29303 | r29304 | |
| 29 | 29 | TYPE DEFINITIONS |
| 30 | 30 | ***************************************************************************/ |
| 31 | 31 | |
| 32 | | struct floppy_drive |
| 33 | | { |
| 34 | | /* callbacks */ |
| 35 | | devcb_resolved_write_line out_idx_func; |
| 36 | | devcb_resolved_read_line in_mon_func; |
| 37 | | devcb_resolved_write_line out_tk00_func; |
| 38 | | devcb_resolved_write_line out_wpt_func; |
| 39 | | devcb_resolved_write_line out_rdy_func; |
| 40 | | devcb_resolved_write_line out_dskchg_func; |
| 41 | | |
| 42 | | /* state of input lines */ |
| 43 | | int drtn; /* direction */ |
| 44 | | int stp; /* step */ |
| 45 | | int wtg; /* write gate */ |
| 46 | | int mon; /* motor on */ |
| 47 | | |
| 48 | | /* state of output lines */ |
| 49 | | int idx; /* index pulse */ |
| 50 | | int tk00; /* track 00 */ |
| 51 | | int wpt; /* write protect */ |
| 52 | | int rdy; /* ready */ |
| 53 | | int dskchg; /* disk changed */ |
| 54 | | |
| 55 | | /* drive select logic */ |
| 56 | | int drive_id; |
| 57 | | int active; |
| 58 | | |
| 59 | | const floppy_interface *config; |
| 60 | | |
| 61 | | /* flags */ |
| 62 | | int flags; |
| 63 | | /* maximum track allowed */ |
| 64 | | int max_track; |
| 65 | | /* num sides */ |
| 66 | | int num_sides; |
| 67 | | /* current track - this may or may not relate to the present cylinder number |
| 68 | | stored by the fdc */ |
| 69 | | int current_track; |
| 70 | | |
| 71 | | /* index pulse timer */ |
| 72 | | emu_timer *index_timer; |
| 73 | | /* index pulse callback */ |
| 74 | | void (*index_pulse_callback)(device_t *controller,device_t *image, int state); |
| 75 | | /* rotation per minute => gives index pulse frequency */ |
| 76 | | float rpm; |
| 77 | | |
| 78 | | void (*ready_state_change_callback)(device_t *controller,device_t *img, int state); |
| 79 | | |
| 80 | | int id_index; |
| 81 | | |
| 82 | | device_t *controller; |
| 83 | | |
| 84 | | floppy_image_legacy *floppy; |
| 85 | | int track; |
| 86 | | void (*load_proc)(device_image_interface &image); |
| 87 | | void (*unload_proc)(device_image_interface &image); |
| 88 | | int floppy_drive_type; |
| 89 | | }; |
| 90 | | |
| 91 | | |
| 92 | 32 | struct floppy_error_map |
| 93 | 33 | { |
| 94 | 34 | floperr_t ferr; |
| r29303 | r29304 | |
| 115 | 55 | IMPLEMENTATION |
| 116 | 56 | ***************************************************************************/ |
| 117 | 57 | |
| 118 | | INLINE floppy_drive *get_safe_token(device_t *device) |
| 119 | | { |
| 120 | | assert( device != NULL ); |
| 121 | | return (floppy_drive *) downcast<legacy_floppy_image_device *>(device)->token(); |
| 122 | | } |
| 123 | 58 | |
| 124 | | floppy_image_legacy *flopimg_get_image(device_t *image) |
| 59 | floppy_image_legacy *legacy_floppy_image_device::flopimg_get_image() |
| 125 | 60 | { |
| 126 | | return get_safe_token(image)->floppy; |
| 61 | return m_floppy; |
| 127 | 62 | } |
| 128 | 63 | |
| 129 | | static int flopimg_get_sectors_per_track(device_t *image, int side) |
| 64 | int legacy_floppy_image_device::flopimg_get_sectors_per_track(int side) |
| 130 | 65 | { |
| 131 | 66 | floperr_t err; |
| 132 | 67 | int sector_count; |
| 133 | | floppy_drive *flopimg = get_safe_token( image ); |
| 134 | 68 | |
| 135 | | if (!flopimg || !flopimg->floppy) |
| 69 | if (!m_floppy) |
| 136 | 70 | return 0; |
| 137 | 71 | |
| 138 | | err = floppy_get_sector_count(flopimg->floppy, side, flopimg->track, §or_count); |
| 72 | err = floppy_get_sector_count(m_floppy, side, m_track, §or_count); |
| 139 | 73 | if (err) |
| 140 | 74 | return 0; |
| 141 | 75 | return sector_count; |
| 142 | 76 | } |
| 143 | 77 | |
| 144 | | static void flopimg_get_id_callback(device_t *image, chrn_id *id, int id_index, int side) |
| 78 | void legacy_floppy_image_device::flopimg_get_id_callback(chrn_id *id, int id_index, int side) |
| 145 | 79 | { |
| 146 | | floppy_drive *flopimg; |
| 147 | 80 | int cylinder, sector, N; |
| 148 | 81 | unsigned long flags; |
| 149 | 82 | UINT32 sector_length; |
| 150 | 83 | |
| 151 | | flopimg = get_safe_token( image ); |
| 152 | | if (!flopimg || !flopimg->floppy) |
| 84 | if (!m_floppy) |
| 153 | 85 | return; |
| 154 | 86 | |
| 155 | | floppy_get_indexed_sector_info(flopimg->floppy, side, flopimg->track, id_index, &cylinder, &side, §or, §or_length, &flags); |
| 87 | floppy_get_indexed_sector_info(m_floppy, side, m_track, id_index, &cylinder, &side, §or, §or_length, &flags); |
| 156 | 88 | |
| 157 | 89 | N = compute_log2(sector_length); |
| 158 | 90 | |
| r29303 | r29304 | |
| 164 | 96 | id->N = ((N >= 7) && (N <= 10)) ? N - 7 : 0; |
| 165 | 97 | } |
| 166 | 98 | |
| 167 | | static void log_readwrite(const char *name, int head, int track, int sector, const char *buf, int length) |
| 99 | void legacy_floppy_image_device::log_readwrite(const char *name, int head, int track, int sector, const char *buf, int length) |
| 168 | 100 | { |
| 169 | 101 | char membuf[1024]; |
| 170 | 102 | int i; |
| r29303 | r29304 | |
| 173 | 105 | logerror("%s: head=%i track=%i sector=%i buffer='%s'\n", name, head, track, sector, membuf); |
| 174 | 106 | } |
| 175 | 107 | |
| 176 | | static void floppy_drive_set_geometry_absolute(device_t *img, int tracks, int sides) |
| 108 | void legacy_floppy_image_device::floppy_drive_set_geometry_absolute(int tracks, int sides) |
| 177 | 109 | { |
| 178 | | floppy_drive *pDrive = get_safe_token( img ); |
| 179 | | pDrive->max_track = tracks; |
| 180 | | pDrive->num_sides = sides; |
| 110 | m_max_track = tracks; |
| 111 | m_num_sides = sides; |
| 181 | 112 | } |
| 182 | 113 | |
| 183 | | void floppy_drive_set_geometry(device_t *img, floppy_type_t type) |
| 114 | void legacy_floppy_image_device::floppy_drive_set_geometry(floppy_type_t type) |
| 184 | 115 | { |
| 185 | | floppy_drive_set_geometry_absolute(img, type.max_track_number, type.head_number); |
| 116 | floppy_drive_set_geometry_absolute(type.max_track_number, type.head_number); |
| 186 | 117 | } |
| 187 | 118 | |
| 188 | | static TIMER_CALLBACK(floppy_drive_index_callback); |
| 189 | | |
| 190 | 119 | /* this is called on device init */ |
| 191 | | static void floppy_drive_init(device_t *img) |
| 120 | void legacy_floppy_image_device::floppy_drive_init() |
| 192 | 121 | { |
| 193 | | floppy_drive *pDrive = get_safe_token( img ); |
| 194 | | |
| 195 | 122 | /* initialise flags */ |
| 196 | | pDrive->flags = 0; |
| 197 | | pDrive->index_pulse_callback = NULL; |
| 198 | | pDrive->ready_state_change_callback = NULL; |
| 199 | | pDrive->index_timer = img->machine().scheduler().timer_alloc(FUNC(floppy_drive_index_callback), (void *) img); |
| 200 | | pDrive->idx = 0; |
| 123 | m_flags = 0; |
| 124 | m_index_pulse_callback = NULL; |
| 125 | m_ready_state_change_callback = NULL; |
| 126 | m_index_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(legacy_floppy_image_device::floppy_drive_index_callback),this)); |
| 127 | m_idx = 0; |
| 201 | 128 | |
| 202 | | floppy_drive_set_geometry(img, ((floppy_interface*)img->static_config())->floppy_type); |
| 129 | floppy_drive_set_geometry(((floppy_interface*)static_config())->floppy_type); |
| 203 | 130 | |
| 204 | 131 | /* initialise id index - not so important */ |
| 205 | | pDrive->id_index = 0; |
| 132 | m_id_index = 0; |
| 206 | 133 | /* initialise track */ |
| 207 | | pDrive->current_track = 0; |
| 134 | m_current_track = 0; |
| 208 | 135 | |
| 209 | 136 | /* default RPM */ |
| 210 | | pDrive->rpm = 300; |
| 137 | m_rpm = 300; |
| 211 | 138 | |
| 212 | | pDrive->controller = NULL; |
| 139 | m_controller = NULL; |
| 213 | 140 | |
| 214 | | pDrive->floppy_drive_type = FLOPPY_TYPE_REGULAR; |
| 141 | m_floppy_drive_type = FLOPPY_TYPE_REGULAR; |
| 215 | 142 | } |
| 216 | 143 | |
| 217 | 144 | /* index pulses at rpm/60 Hz, and stays high 1/20th of time */ |
| 218 | | static void floppy_drive_index_func(device_t *img) |
| 145 | void legacy_floppy_image_device::floppy_drive_index_func() |
| 219 | 146 | { |
| 220 | | floppy_drive *drive = get_safe_token( img ); |
| 147 | double ms = 1000.0 / (m_rpm / 60.0); |
| 221 | 148 | |
| 222 | | double ms = 1000.0 / (drive->rpm / 60.0); |
| 223 | | |
| 224 | | if (drive->idx) |
| 149 | if (m_idx) |
| 225 | 150 | { |
| 226 | | drive->idx = 0; |
| 227 | | drive->index_timer->adjust(attotime::from_double(ms*19/20/1000.0)); |
| 151 | m_idx = 0; |
| 152 | m_index_timer->adjust(attotime::from_double(ms*19/20/1000.0)); |
| 228 | 153 | } |
| 229 | 154 | else |
| 230 | 155 | { |
| 231 | | drive->idx = 1; |
| 232 | | drive->index_timer->adjust(attotime::from_double(ms/20/1000.0)); |
| 156 | m_idx = 1; |
| 157 | m_index_timer->adjust(attotime::from_double(ms/20/1000.0)); |
| 233 | 158 | } |
| 234 | 159 | |
| 235 | | drive->out_idx_func(drive->idx); |
| 160 | m_out_idx_func(m_idx); |
| 236 | 161 | |
| 237 | | if (drive->index_pulse_callback) |
| 238 | | drive->index_pulse_callback(drive->controller, img, drive->idx); |
| 162 | if (m_index_pulse_callback) |
| 163 | m_index_pulse_callback(m_controller, this, m_idx); |
| 239 | 164 | } |
| 240 | 165 | |
| 241 | | static TIMER_CALLBACK(floppy_drive_index_callback) |
| 166 | TIMER_CALLBACK_MEMBER(legacy_floppy_image_device::floppy_drive_index_callback) |
| 242 | 167 | { |
| 243 | | device_t *image = (device_t *) ptr; |
| 244 | | floppy_drive_index_func(image); |
| 168 | floppy_drive_index_func(); |
| 245 | 169 | } |
| 246 | 170 | |
| 247 | 171 | /*************************************************************************/ |
| 248 | 172 | /* IO_FLOPPY device functions */ |
| 249 | 173 | |
| 250 | 174 | /* set flag state */ |
| 251 | | void floppy_drive_set_flag_state(device_t *img, int flag, int state) |
| 175 | void legacy_floppy_image_device::floppy_drive_set_flag_state(int flag, int state) |
| 252 | 176 | { |
| 253 | | floppy_drive *drv = get_safe_token( img ); |
| 254 | 177 | int prev_state; |
| 255 | 178 | int new_state; |
| 256 | 179 | |
| 257 | 180 | /* get old state */ |
| 258 | | prev_state = drv->flags & flag; |
| 181 | prev_state = m_flags & flag; |
| 259 | 182 | |
| 260 | 183 | /* set new state */ |
| 261 | | drv->flags &= ~flag; |
| 184 | m_flags &= ~flag; |
| 262 | 185 | if (state) |
| 263 | | drv->flags |= flag; |
| 186 | m_flags |= flag; |
| 264 | 187 | |
| 265 | 188 | /* get new state */ |
| 266 | | new_state = drv->flags & flag; |
| 189 | new_state = m_flags & flag; |
| 267 | 190 | |
| 268 | 191 | /* changed state? */ |
| 269 | 192 | if (prev_state ^ new_state) |
| r29303 | r29304 | |
| 271 | 194 | if (flag & FLOPPY_DRIVE_READY) |
| 272 | 195 | { |
| 273 | 196 | /* trigger state change callback */ |
| 274 | | drv->out_rdy_func(new_state ? ASSERT_LINE : CLEAR_LINE); |
| 197 | m_out_rdy_func(new_state ? ASSERT_LINE : CLEAR_LINE); |
| 275 | 198 | |
| 276 | | if (drv->ready_state_change_callback) |
| 277 | | drv->ready_state_change_callback(drv->controller, img, new_state); |
| 199 | if (m_ready_state_change_callback) |
| 200 | m_ready_state_change_callback(m_controller, this, new_state); |
| 278 | 201 | } |
| 279 | 202 | } |
| 280 | 203 | } |
| r29303 | r29304 | |
| 282 | 205 | /* for pc, drive is always ready, for amstrad,pcw,spectrum it is only ready under |
| 283 | 206 | a fixed set of circumstances */ |
| 284 | 207 | /* use this to set ready state of drive */ |
| 285 | | void floppy_drive_set_ready_state(device_t *img, int state, int flag) |
| 286 | | { |
| 287 | | floppy_drive *drive = get_safe_token(img); |
| 288 | | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 208 | void legacy_floppy_image_device::floppy_drive_set_ready_state(int state, int flag) |
| 209 | { |
| 289 | 210 | if (flag) |
| 290 | 211 | { |
| 291 | 212 | /* set ready only if drive is present, disk is in the drive, |
| r29303 | r29304 | |
| 293 | 214 | |
| 294 | 215 | /* drive present? */ |
| 295 | 216 | /* disk inserted? */ |
| 296 | | if (image->exists()) |
| 217 | if (exists()) |
| 297 | 218 | { |
| 298 | | if (drive->mon == CLEAR_LINE) |
| 219 | if (m_mon == CLEAR_LINE) |
| 299 | 220 | { |
| 300 | 221 | /* set state */ |
| 301 | | floppy_drive_set_flag_state(img, FLOPPY_DRIVE_READY, state); |
| 222 | floppy_drive_set_flag_state(FLOPPY_DRIVE_READY, state); |
| 302 | 223 | return; |
| 303 | 224 | } |
| 304 | 225 | } |
| 305 | | floppy_drive_set_flag_state(img, FLOPPY_DRIVE_READY, 0); |
| 226 | floppy_drive_set_flag_state(FLOPPY_DRIVE_READY, 0); |
| 306 | 227 | } |
| 307 | 228 | else |
| 308 | 229 | { |
| 309 | 230 | /* force ready state - for PC driver */ |
| 310 | | floppy_drive_set_flag_state(img, FLOPPY_DRIVE_READY, state); |
| 231 | floppy_drive_set_flag_state(FLOPPY_DRIVE_READY, state); |
| 311 | 232 | } |
| 312 | 233 | } |
| 313 | 234 | |
| 314 | 235 | /* get flag state */ |
| 315 | | int floppy_drive_get_flag_state(device_t *img, int flag) |
| 236 | int legacy_floppy_image_device::floppy_drive_get_flag_state(int flag) |
| 316 | 237 | { |
| 317 | | floppy_drive *drv = get_safe_token( img ); |
| 318 | 238 | int drive_flags; |
| 319 | 239 | int flags; |
| 320 | 240 | |
| 321 | 241 | flags = 0; |
| 322 | 242 | |
| 323 | | drive_flags = drv->flags; |
| 243 | drive_flags = m_flags; |
| 324 | 244 | |
| 325 | 245 | /* these flags are independent of a real drive/disk image */ |
| 326 | 246 | flags |= drive_flags & (FLOPPY_DRIVE_READY | FLOPPY_DRIVE_INDEX); |
| r29303 | r29304 | |
| 331 | 251 | } |
| 332 | 252 | |
| 333 | 253 | |
| 334 | | void floppy_drive_seek(device_t *img, signed int signed_tracks) |
| 335 | | { |
| 336 | | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 337 | | floppy_drive *pDrive; |
| 254 | void legacy_floppy_image_device::floppy_drive_seek(signed int signed_tracks) |
| 255 | { |
| 256 | LOG(("seek from: %d delta: %d\n",m_current_track, signed_tracks)); |
| 338 | 257 | |
| 339 | | pDrive = get_safe_token( img ); |
| 340 | | |
| 341 | | LOG(("seek from: %d delta: %d\n",pDrive->current_track, signed_tracks)); |
| 342 | | |
| 343 | 258 | /* update position */ |
| 344 | | pDrive->current_track+=signed_tracks; |
| 259 | m_current_track+=signed_tracks; |
| 345 | 260 | |
| 346 | | if (pDrive->current_track<0) |
| 261 | if (m_current_track<0) |
| 347 | 262 | { |
| 348 | | pDrive->current_track = 0; |
| 263 | m_current_track = 0; |
| 349 | 264 | } |
| 350 | 265 | else |
| 351 | | if (pDrive->current_track>=pDrive->max_track) |
| 266 | if (m_current_track>=m_max_track) |
| 352 | 267 | { |
| 353 | | pDrive->current_track = pDrive->max_track-1; |
| 268 | m_current_track = m_max_track-1; |
| 354 | 269 | } |
| 355 | 270 | |
| 356 | 271 | /* set track 0 flag */ |
| 357 | | pDrive->tk00 = (pDrive->current_track == 0) ? CLEAR_LINE : ASSERT_LINE; |
| 358 | | pDrive->out_tk00_func(pDrive->tk00); |
| 272 | m_tk00 = (m_current_track == 0) ? CLEAR_LINE : ASSERT_LINE; |
| 273 | m_out_tk00_func(m_tk00); |
| 359 | 274 | |
| 360 | 275 | /* clear disk changed flag */ |
| 361 | | pDrive->dskchg = ASSERT_LINE; |
| 362 | | //flopimg->out_dskchg_func(flopimg->dskchg); |
| 276 | m_dskchg = ASSERT_LINE; |
| 277 | //m_out_dskchg_func(m_dskchg); |
| 363 | 278 | |
| 364 | 279 | /* inform disk image of step operation so it can cache information */ |
| 365 | | if (image->exists()) |
| 366 | | pDrive->track = pDrive->current_track; |
| 280 | if (exists()) |
| 281 | m_track = m_current_track; |
| 367 | 282 | |
| 368 | | pDrive->id_index = 0; |
| 283 | m_id_index = 0; |
| 369 | 284 | } |
| 370 | 285 | |
| 371 | 286 | |
| 372 | 287 | /* this is not accurate. But it will do for now */ |
| 373 | | int floppy_drive_get_next_id(device_t *img, int side, chrn_id *id) |
| 288 | int legacy_floppy_image_device::floppy_drive_get_next_id(int side, chrn_id *id) |
| 374 | 289 | { |
| 375 | | floppy_drive *pDrive; |
| 376 | 290 | int spt; |
| 377 | 291 | |
| 378 | | pDrive = get_safe_token( img ); |
| 379 | | |
| 380 | 292 | /* get sectors per track */ |
| 381 | | spt = flopimg_get_sectors_per_track(img, side); |
| 293 | spt = flopimg_get_sectors_per_track(side); |
| 382 | 294 | |
| 383 | 295 | /* set index */ |
| 384 | | if ((pDrive->id_index==(spt-1)) || (spt==0)) |
| 296 | if ((m_id_index==(spt-1)) || (spt==0)) |
| 385 | 297 | { |
| 386 | | floppy_drive_set_flag_state(img, FLOPPY_DRIVE_INDEX, 1); |
| 298 | floppy_drive_set_flag_state(FLOPPY_DRIVE_INDEX, 1); |
| 387 | 299 | } |
| 388 | 300 | else |
| 389 | 301 | { |
| 390 | | floppy_drive_set_flag_state(img, FLOPPY_DRIVE_INDEX, 0); |
| 302 | floppy_drive_set_flag_state(FLOPPY_DRIVE_INDEX, 0); |
| 391 | 303 | } |
| 392 | 304 | |
| 393 | 305 | /* get id */ |
| 394 | 306 | if (spt!=0) |
| 395 | 307 | { |
| 396 | | flopimg_get_id_callback(img, id, pDrive->id_index, side); |
| 308 | flopimg_get_id_callback(id, m_id_index, side); |
| 397 | 309 | } |
| 398 | 310 | |
| 399 | | pDrive->id_index++; |
| 311 | m_id_index++; |
| 400 | 312 | if (spt!=0) |
| 401 | | pDrive->id_index %= spt; |
| 313 | m_id_index %= spt; |
| 402 | 314 | else |
| 403 | | pDrive->id_index = 0; |
| 315 | m_id_index = 0; |
| 404 | 316 | |
| 405 | 317 | return (spt == 0) ? 0 : 1; |
| 406 | 318 | } |
| 407 | 319 | |
| 408 | | void floppy_drive_read_track_data_info_buffer(device_t *img, int side, void *ptr, int *length ) |
| 320 | void legacy_floppy_image_device::floppy_drive_read_track_data_info_buffer(int side, void *ptr, int *length ) |
| 409 | 321 | { |
| 410 | | floppy_drive *flopimg; |
| 411 | | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 412 | | |
| 413 | | if (image->exists()) |
| 322 | if (exists()) |
| 414 | 323 | { |
| 415 | | flopimg = get_safe_token( img ); |
| 416 | | if (!flopimg || !flopimg->floppy) |
| 324 | if (!m_floppy) |
| 417 | 325 | return; |
| 418 | 326 | |
| 419 | | floppy_read_track_data(flopimg->floppy, side, flopimg->track, ptr, *length); |
| 327 | floppy_read_track_data(m_floppy, side, m_track, ptr, *length); |
| 420 | 328 | } |
| 421 | 329 | } |
| 422 | 330 | |
| 423 | | void floppy_drive_write_track_data_info_buffer(device_t *img, int side, const void *ptr, int *length ) |
| 331 | void legacy_floppy_image_device::floppy_drive_write_track_data_info_buffer(int side, const void *ptr, int *length ) |
| 424 | 332 | { |
| 425 | | floppy_drive *flopimg; |
| 426 | | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 427 | | |
| 428 | | if (image->exists()) |
| 333 | if (exists()) |
| 429 | 334 | { |
| 430 | | flopimg = get_safe_token( img ); |
| 431 | | if (!flopimg || !flopimg->floppy) |
| 335 | if (!m_floppy) |
| 432 | 336 | return; |
| 433 | 337 | |
| 434 | | floppy_write_track_data(flopimg->floppy, side, flopimg->track, ptr, *length); |
| 338 | floppy_write_track_data(m_floppy, side, m_track, ptr, *length); |
| 435 | 339 | } |
| 436 | 340 | } |
| 437 | 341 | |
| 438 | | void floppy_drive_format_sector(device_t *img, int side, int sector_index,int c,int h, int r, int n, int filler) |
| 342 | void legacy_floppy_image_device::floppy_drive_format_sector(int side, int sector_index,int c,int h, int r, int n, int filler) |
| 439 | 343 | { |
| 440 | | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 441 | | |
| 442 | | if (image->exists()) |
| 344 | if (exists()) |
| 443 | 345 | { |
| 444 | | /* if (drv->interface_.format_sector) |
| 445 | | drv->interface_.format_sector(img, side, sector_index,c, h, r, n, filler);*/ |
| 346 | /* if (m_interface_.format_sector) |
| 347 | m_interface_.format_sector(img, side, sector_index,c, h, r, n, filler);*/ |
| 446 | 348 | } |
| 447 | 349 | } |
| 448 | 350 | |
| 449 | | void floppy_drive_read_sector_data(device_t *img, int side, int index1, void *ptr, int length) |
| 351 | void legacy_floppy_image_device::floppy_drive_read_sector_data(int side, int index1, void *ptr, int length) |
| 450 | 352 | { |
| 451 | | floppy_drive *flopimg; |
| 452 | | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 453 | | |
| 454 | | if (image->exists()) |
| 353 | if (exists()) |
| 455 | 354 | { |
| 456 | | flopimg = get_safe_token( img ); |
| 457 | | if (!flopimg || !flopimg->floppy) |
| 355 | if (!m_floppy) |
| 458 | 356 | return; |
| 459 | 357 | |
| 460 | | floppy_read_indexed_sector(flopimg->floppy, side, flopimg->track, index1, 0, ptr, length); |
| 358 | floppy_read_indexed_sector(m_floppy, side, m_track, index1, 0, ptr, length); |
| 461 | 359 | |
| 462 | 360 | if (LOG_FLOPPY) |
| 463 | | log_readwrite("sector_read", side, flopimg->track, index1, (const char *)ptr, length); |
| 361 | log_readwrite("sector_read", side, m_track, index1, (const char *)ptr, length); |
| 464 | 362 | |
| 465 | 363 | } |
| 466 | 364 | } |
| 467 | 365 | |
| 468 | | void floppy_drive_write_sector_data(device_t *img, int side, int index1, const void *ptr,int length, int ddam) |
| 366 | void legacy_floppy_image_device::floppy_drive_write_sector_data(int side, int index1, const void *ptr,int length, int ddam) |
| 469 | 367 | { |
| 470 | | floppy_drive *flopimg; |
| 471 | | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 472 | | |
| 473 | | if (image->exists()) |
| 368 | if (exists()) |
| 474 | 369 | { |
| 475 | | flopimg = get_safe_token( img ); |
| 476 | | if (!flopimg || !flopimg->floppy) |
| 370 | if (!m_floppy) |
| 477 | 371 | return; |
| 478 | 372 | |
| 479 | 373 | if (LOG_FLOPPY) |
| 480 | | log_readwrite("sector_write", side, flopimg->track, index1, (const char *)ptr, length); |
| 374 | log_readwrite("sector_write", side, m_track, index1, (const char *)ptr, length); |
| 481 | 375 | |
| 482 | | floppy_write_indexed_sector(flopimg->floppy, side, flopimg->track, index1, 0, ptr, length, ddam); |
| 376 | floppy_write_indexed_sector(m_floppy, side, m_track, index1, 0, ptr, length, ddam); |
| 483 | 377 | } |
| 484 | 378 | } |
| 485 | 379 | |
| 486 | | void floppy_install_load_proc(device_t *image, void (*proc)(device_image_interface &image)) |
| 380 | void legacy_floppy_image_device::floppy_install_load_proc(void (*proc)(device_image_interface &image)) |
| 487 | 381 | { |
| 488 | | floppy_drive *flopimg = get_safe_token( image ); |
| 489 | | flopimg->load_proc = proc; |
| 382 | m_load_proc = proc; |
| 490 | 383 | } |
| 491 | 384 | |
| 492 | | void floppy_install_unload_proc(device_t *image, void (*proc)(device_image_interface &image)) |
| 385 | void legacy_floppy_image_device::floppy_install_unload_proc(void (*proc)(device_image_interface &image)) |
| 493 | 386 | { |
| 494 | | floppy_drive *flopimg = get_safe_token( image ); |
| 495 | | flopimg->unload_proc = proc; |
| 387 | m_unload_proc = proc; |
| 496 | 388 | } |
| 497 | 389 | |
| 498 | 390 | /* set the callback for the index pulse */ |
| 499 | | void floppy_drive_set_index_pulse_callback(device_t *img, void (*callback)(device_t *controller,device_t *image, int state)) |
| 391 | void legacy_floppy_image_device::floppy_drive_set_index_pulse_callback(void (*callback)(device_t *controller, device_t *img, int state)) |
| 500 | 392 | { |
| 501 | | floppy_drive *pDrive = get_safe_token( img ); |
| 502 | | pDrive->index_pulse_callback = callback; |
| 393 | m_index_pulse_callback = callback; |
| 503 | 394 | } |
| 504 | 395 | |
| 505 | | |
| 506 | | void floppy_drive_set_ready_state_change_callback(device_t *img, void (*callback)(device_t *controller,device_t *img, int state)) |
| 396 | void legacy_floppy_image_device::floppy_drive_set_ready_state_change_callback(void (*callback)(device_t *controller,device_t *img, int state)) |
| 507 | 397 | { |
| 508 | | floppy_drive *pDrive = get_safe_token( img ); |
| 509 | | pDrive->ready_state_change_callback = callback; |
| 398 | m_ready_state_change_callback = callback; |
| 510 | 399 | } |
| 511 | 400 | |
| 512 | | int floppy_drive_get_current_track(device_t *img) |
| 401 | int legacy_floppy_image_device::floppy_drive_get_current_track() |
| 513 | 402 | { |
| 514 | | floppy_drive *drv = get_safe_token( img ); |
| 515 | | return drv->current_track; |
| 403 | return m_current_track; |
| 516 | 404 | } |
| 517 | 405 | |
| 518 | | UINT64 floppy_drive_get_current_track_size(device_t *img, int head) |
| 406 | UINT64 legacy_floppy_image_device::floppy_drive_get_current_track_size(int head) |
| 519 | 407 | { |
| 520 | | floppy_drive *drv = get_safe_token( img ); |
| 521 | 408 | int size = 0; |
| 522 | | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 523 | | |
| 524 | | if (image->exists()) |
| 409 | if (exists()) |
| 525 | 410 | { |
| 526 | | size = floppy_get_track_size(drv->floppy, head, drv->current_track); |
| 411 | size = floppy_get_track_size(m_floppy, head, m_current_track); |
| 527 | 412 | } |
| 528 | 413 | |
| 529 | 414 | return size; |
| 530 | 415 | } |
| 531 | 416 | |
| 532 | | void floppy_drive_set_rpm(device_t *img, float rpm) |
| 417 | void legacy_floppy_image_device::floppy_drive_set_rpm(float rpm) |
| 533 | 418 | { |
| 534 | | floppy_drive *drv = get_safe_token( img ); |
| 535 | | drv->rpm = rpm; |
| 419 | m_rpm = rpm; |
| 536 | 420 | } |
| 537 | 421 | |
| 538 | | void floppy_drive_set_controller(device_t *img, device_t *controller) |
| 422 | void legacy_floppy_image_device::floppy_drive_set_controller(device_t *controller) |
| 539 | 423 | { |
| 540 | | floppy_drive *drv = get_safe_token( img ); |
| 541 | | drv->controller = controller; |
| 424 | m_controller = controller; |
| 542 | 425 | } |
| 543 | 426 | |
| 544 | | static int internal_floppy_device_load(device_image_interface *image, int create_format, option_resolution *create_args) |
| 427 | int legacy_floppy_image_device::internal_floppy_device_load(int create_format, option_resolution *create_args) |
| 545 | 428 | { |
| 546 | 429 | floperr_t err; |
| 547 | | floppy_drive *flopimg; |
| 548 | 430 | const struct FloppyFormat *floppy_options; |
| 549 | 431 | int floppy_flags, i; |
| 550 | 432 | const char *extension; |
| 551 | 433 | |
| 552 | | /* look up instance data */ |
| 553 | | flopimg = get_safe_token( &image->device() ); |
| 434 | device_image_interface *image = NULL; |
| 435 | interface(image); /* figure out the floppy options */ |
| 436 | floppy_options = ((floppy_interface*)static_config())->formats; |
| 554 | 437 | |
| 555 | | /* figure out the floppy options */ |
| 556 | | floppy_options = ((floppy_interface*)image->device().static_config())->formats; |
| 557 | | |
| 558 | | if (image->has_been_created()) |
| 438 | if (has_been_created()) |
| 559 | 439 | { |
| 560 | 440 | /* creating an image */ |
| 561 | 441 | assert(create_format >= 0); |
| 562 | | err = floppy_create((void *) image, &image_ioprocs, &floppy_options[create_format], create_args, &flopimg->floppy); |
| 442 | err = floppy_create((void *) image, &image_ioprocs, &floppy_options[create_format], create_args, &m_floppy); |
| 563 | 443 | if (err) |
| 564 | 444 | goto error; |
| 565 | 445 | } |
| 566 | 446 | else |
| 567 | 447 | { |
| 568 | 448 | /* opening an image */ |
| 569 | | floppy_flags = !image->is_readonly() ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY; |
| 570 | | extension = image->filetype(); |
| 571 | | err = floppy_open_choices((void *) image, &image_ioprocs, extension, floppy_options, floppy_flags, &flopimg->floppy); |
| 449 | floppy_flags = !is_readonly() ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY; |
| 450 | extension = filetype(); |
| 451 | err = floppy_open_choices((void *) image, &image_ioprocs, extension, floppy_options, floppy_flags, &m_floppy); |
| 572 | 452 | if (err) |
| 573 | 453 | goto error; |
| 574 | 454 | } |
| 575 | | if (floppy_callbacks(flopimg->floppy)->get_heads_per_disk && floppy_callbacks(flopimg->floppy)->get_tracks_per_disk) |
| 455 | if (floppy_callbacks(m_floppy)->get_heads_per_disk && floppy_callbacks(m_floppy)->get_tracks_per_disk) |
| 576 | 456 | { |
| 577 | | floppy_drive_set_geometry_absolute(&image->device(), |
| 578 | | floppy_get_tracks_per_disk(flopimg->floppy), |
| 579 | | floppy_get_heads_per_disk(flopimg->floppy)); |
| 457 | floppy_drive_set_geometry_absolute(floppy_get_tracks_per_disk(m_floppy),floppy_get_heads_per_disk(m_floppy)); |
| 580 | 458 | } |
| 581 | 459 | /* disk changed */ |
| 582 | | flopimg->dskchg = CLEAR_LINE; |
| 460 | m_dskchg = CLEAR_LINE; |
| 583 | 461 | |
| 584 | 462 | return IMAGE_INIT_PASS; |
| 585 | 463 | |
| r29303 | r29304 | |
| 587 | 465 | for (i = 0; i < ARRAY_LENGTH(errmap); i++) |
| 588 | 466 | { |
| 589 | 467 | if (err == errmap[i].ferr) |
| 590 | | image->seterror(errmap[i].ierr, errmap[i].message); |
| 468 | seterror(errmap[i].ierr, errmap[i].message); |
| 591 | 469 | } |
| 592 | 470 | return IMAGE_INIT_FAIL; |
| 593 | 471 | } |
| 594 | 472 | |
| 595 | | static TIMER_CALLBACK( set_wpt ) |
| 473 | TIMER_CALLBACK_MEMBER( legacy_floppy_image_device::set_wpt ) |
| 596 | 474 | { |
| 597 | | floppy_drive *flopimg = (floppy_drive *)ptr; |
| 598 | | |
| 599 | | flopimg->wpt = param; |
| 600 | | flopimg->out_wpt_func(param); |
| 475 | m_wpt = param; |
| 476 | m_out_wpt_func(param); |
| 601 | 477 | } |
| 602 | 478 | |
| 603 | | device_t *floppy_get_device(running_machine &machine,int drive) |
| 479 | legacy_floppy_image_device *floppy_get_device(running_machine &machine,int drive) |
| 604 | 480 | { |
| 605 | 481 | switch(drive) { |
| 606 | | case 0 : return machine.device(FLOPPY_0); |
| 607 | | case 1 : return machine.device(FLOPPY_1); |
| 608 | | case 2 : return machine.device(FLOPPY_2); |
| 609 | | case 3 : return machine.device(FLOPPY_3); |
| 482 | case 0 : return machine.device<legacy_floppy_image_device>(FLOPPY_0); |
| 483 | case 1 : return machine.device<legacy_floppy_image_device>(FLOPPY_1); |
| 484 | case 2 : return machine.device<legacy_floppy_image_device>(FLOPPY_2); |
| 485 | case 3 : return machine.device<legacy_floppy_image_device>(FLOPPY_3); |
| 610 | 486 | } |
| 611 | 487 | return NULL; |
| 612 | 488 | } |
| 613 | 489 | |
| 614 | | int floppy_get_drive_type(device_t *image) |
| 490 | int legacy_floppy_image_device::floppy_get_drive_type() |
| 615 | 491 | { |
| 616 | | floppy_drive *flopimg = get_safe_token( image ); |
| 617 | | return flopimg->floppy_drive_type; |
| 492 | return m_floppy_drive_type; |
| 618 | 493 | } |
| 619 | 494 | |
| 620 | | void floppy_set_type(device_t *image,int ftype) |
| 495 | void legacy_floppy_image_device::floppy_set_type(int ftype) |
| 621 | 496 | { |
| 622 | | floppy_drive *flopimg = get_safe_token( image ); |
| 623 | | flopimg->floppy_drive_type = ftype; |
| 497 | m_floppy_drive_type = ftype; |
| 624 | 498 | } |
| 625 | 499 | |
| 626 | | device_t *floppy_get_device_by_type(running_machine &machine,int ftype,int drive) |
| 500 | legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,int ftype,int drive) |
| 627 | 501 | { |
| 628 | 502 | int i; |
| 629 | 503 | int cnt = 0; |
| 630 | 504 | for (i=0;i<4;i++) { |
| 631 | | device_t *disk = floppy_get_device(machine,i); |
| 632 | | if (floppy_get_drive_type(disk)==ftype) { |
| 505 | legacy_floppy_image_device *disk = floppy_get_device(machine,i); |
| 506 | if (disk->floppy_get_drive_type()==ftype) { |
| 633 | 507 | if (cnt==drive) { |
| 634 | 508 | return disk; |
| 635 | 509 | } |
| r29303 | r29304 | |
| 649 | 523 | return drive; |
| 650 | 524 | } |
| 651 | 525 | |
| 652 | | int floppy_get_drive_by_type(device_t *image,int ftype) |
| 526 | int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype) |
| 653 | 527 | { |
| 654 | 528 | int i,drive =0; |
| 655 | 529 | for (i=0;i<4;i++) { |
| 656 | | device_t *disk = floppy_get_device(image->machine(),i); |
| 657 | | if (floppy_get_drive_type(disk)==ftype) { |
| 530 | legacy_floppy_image_device *disk = floppy_get_device(image->machine(),i); |
| 531 | if (disk->floppy_get_drive_type()==ftype) { |
| 658 | 532 | if (image==disk) { |
| 659 | 533 | return drive; |
| 660 | 534 | } |
| r29303 | r29304 | |
| 667 | 541 | int floppy_get_count(running_machine &machine) |
| 668 | 542 | { |
| 669 | 543 | int cnt = 0; |
| 670 | | if (machine.device(FLOPPY_0)) cnt++; |
| 671 | | if (machine.device(FLOPPY_1)) cnt++; |
| 672 | | if (machine.device(FLOPPY_2)) cnt++; |
| 673 | | if (machine.device(FLOPPY_3)) cnt++; |
| 544 | if (machine.device<legacy_floppy_image_device>(FLOPPY_0)) cnt++; |
| 545 | if (machine.device<legacy_floppy_image_device>(FLOPPY_1)) cnt++; |
| 546 | if (machine.device<legacy_floppy_image_device>(FLOPPY_2)) cnt++; |
| 547 | if (machine.device<legacy_floppy_image_device>(FLOPPY_3)) cnt++; |
| 674 | 548 | return cnt; |
| 675 | 549 | } |
| 676 | 550 | |
| 677 | 551 | |
| 678 | 552 | /* drive select 0 */ |
| 679 | | WRITE_LINE_DEVICE_HANDLER( floppy_ds0_w ) |
| 553 | WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds0_w ) |
| 680 | 554 | { |
| 681 | | floppy_drive *drive = get_safe_token(device); |
| 682 | | |
| 683 | 555 | if (state == CLEAR_LINE) |
| 684 | | drive->active = (drive->drive_id == 0); |
| 556 | m_active = (m_drive_id == 0); |
| 685 | 557 | } |
| 686 | 558 | |
| 687 | 559 | /* drive select 1 */ |
| 688 | | WRITE_LINE_DEVICE_HANDLER( floppy_ds1_w ) |
| 560 | WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds1_w ) |
| 689 | 561 | { |
| 690 | | floppy_drive *drive = get_safe_token(device); |
| 691 | | |
| 692 | 562 | if (state == CLEAR_LINE) |
| 693 | | drive->active = (drive->drive_id == 1); |
| 563 | m_active = (m_drive_id == 1); |
| 694 | 564 | } |
| 695 | 565 | |
| 696 | 566 | /* drive select 2 */ |
| 697 | | WRITE_LINE_DEVICE_HANDLER( floppy_ds2_w ) |
| 567 | WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds2_w ) |
| 698 | 568 | { |
| 699 | | floppy_drive *drive = get_safe_token(device); |
| 700 | | |
| 701 | 569 | if (state == CLEAR_LINE) |
| 702 | | drive->active = (drive->drive_id == 2); |
| 570 | m_active = (m_drive_id == 2); |
| 703 | 571 | } |
| 704 | 572 | |
| 705 | 573 | /* drive select 3 */ |
| 706 | | WRITE_LINE_DEVICE_HANDLER( floppy_ds3_w ) |
| 574 | WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds3_w ) |
| 707 | 575 | { |
| 708 | | floppy_drive *drive = get_safe_token(device); |
| 709 | | |
| 710 | 576 | if (state == CLEAR_LINE) |
| 711 | | drive->active = (drive->drive_id == 3); |
| 577 | m_active = (m_drive_id == 3); |
| 712 | 578 | } |
| 713 | 579 | |
| 714 | 580 | /* shortcut to write all four ds lines */ |
| 715 | | WRITE8_DEVICE_HANDLER( floppy_ds_w ) |
| 581 | WRITE8_MEMBER( legacy_floppy_image_device::floppy_ds_w ) |
| 716 | 582 | { |
| 717 | | floppy_ds0_w(device, BIT(data, 0)); |
| 718 | | floppy_ds1_w(device, BIT(data, 1)); |
| 719 | | floppy_ds2_w(device, BIT(data, 2)); |
| 720 | | floppy_ds3_w(device, BIT(data, 3)); |
| 583 | floppy_ds0_w(BIT(data, 0)); |
| 584 | floppy_ds1_w(BIT(data, 1)); |
| 585 | floppy_ds2_w(BIT(data, 2)); |
| 586 | floppy_ds3_w(BIT(data, 3)); |
| 721 | 587 | } |
| 722 | 588 | |
| 723 | 589 | /* motor on, active low */ |
| 724 | | WRITE_LINE_DEVICE_HANDLER( floppy_mon_w ) |
| 590 | WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_mon_w ) |
| 725 | 591 | { |
| 726 | | floppy_drive *drive = get_safe_token(device); |
| 727 | | device_image_interface *image = dynamic_cast<device_image_interface *>(device); |
| 728 | 592 | /* force off if there is no attached image */ |
| 729 | | if (!image->exists()) |
| 593 | if (!exists()) |
| 730 | 594 | state = ASSERT_LINE; |
| 731 | 595 | |
| 732 | 596 | /* off -> on */ |
| 733 | | if (drive->mon && state == CLEAR_LINE) |
| 597 | if (m_mon && state == CLEAR_LINE) |
| 734 | 598 | { |
| 735 | | drive->idx = 0; |
| 736 | | floppy_drive_index_func(device); |
| 599 | m_idx = 0; |
| 600 | floppy_drive_index_func(); |
| 737 | 601 | } |
| 738 | 602 | |
| 739 | 603 | /* on -> off */ |
| 740 | | else if (drive->mon == CLEAR_LINE && state) |
| 741 | | drive->index_timer->adjust(attotime::zero); |
| 604 | else if (m_mon == CLEAR_LINE && state) |
| 605 | m_index_timer->adjust(attotime::zero); |
| 742 | 606 | |
| 743 | | drive->mon = state; |
| 607 | m_mon = state; |
| 744 | 608 | } |
| 745 | 609 | |
| 746 | 610 | /* direction */ |
| 747 | | WRITE_LINE_DEVICE_HANDLER( floppy_drtn_w ) |
| 611 | WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_drtn_w ) |
| 748 | 612 | { |
| 749 | | floppy_drive *drive = get_safe_token(device); |
| 750 | | drive->drtn = state; |
| 613 | m_drtn = state; |
| 751 | 614 | } |
| 752 | 615 | |
| 753 | 616 | /* write data */ |
| 754 | | WRITE_LINE_DEVICE_HANDLER( floppy_wtd_w ) |
| 617 | WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_wtd_w ) |
| 755 | 618 | { |
| 756 | 619 | } |
| 757 | 620 | |
| 758 | 621 | /* step */ |
| 759 | | WRITE_LINE_DEVICE_HANDLER( floppy_stp_w ) |
| 622 | WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_stp_w ) |
| 760 | 623 | { |
| 761 | | floppy_drive *drive = get_safe_token(device); |
| 762 | 624 | |
| 763 | 625 | /* move head one track when going from high to low and write gate is high */ |
| 764 | | if (drive->active && drive->stp && state == CLEAR_LINE && drive->wtg) |
| 626 | if (m_active && m_stp && state == CLEAR_LINE && m_wtg) |
| 765 | 627 | { |
| 766 | 628 | /* move head according to the direction line */ |
| 767 | | if (drive->drtn) |
| 629 | if (m_drtn) |
| 768 | 630 | { |
| 769 | 631 | /* move head outward */ |
| 770 | | if (drive->current_track > 0) |
| 771 | | drive->current_track--; |
| 632 | if (m_current_track > 0) |
| 633 | m_current_track--; |
| 772 | 634 | |
| 773 | 635 | /* are we at track 0 now? */ |
| 774 | | drive->tk00 = (drive->current_track == 0) ? CLEAR_LINE : ASSERT_LINE; |
| 636 | m_tk00 = (m_current_track == 0) ? CLEAR_LINE : ASSERT_LINE; |
| 775 | 637 | } |
| 776 | 638 | else |
| 777 | 639 | { |
| 778 | 640 | /* move head inward */ |
| 779 | | if (drive->current_track < drive->max_track) |
| 780 | | drive->current_track++; |
| 641 | if (m_current_track < m_max_track) |
| 642 | m_current_track++; |
| 781 | 643 | |
| 782 | 644 | /* we can't be at track 0 here, so reset the line */ |
| 783 | | drive->tk00 = ASSERT_LINE; |
| 645 | m_tk00 = ASSERT_LINE; |
| 784 | 646 | } |
| 785 | 647 | |
| 786 | 648 | /* update track 0 line with new status */ |
| 787 | | drive->out_tk00_func(drive->tk00); |
| 649 | m_out_tk00_func(m_tk00); |
| 788 | 650 | } |
| 789 | 651 | |
| 790 | | drive->stp = state; |
| 652 | m_stp = state; |
| 791 | 653 | } |
| 792 | 654 | |
| 793 | 655 | /* write gate */ |
| 794 | | WRITE_LINE_DEVICE_HANDLER( floppy_wtg_w ) |
| 656 | WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_wtg_w ) |
| 795 | 657 | { |
| 796 | | floppy_drive *drive = get_safe_token(device); |
| 797 | | drive->wtg = state; |
| 658 | m_wtg = state; |
| 798 | 659 | } |
| 799 | 660 | |
| 800 | 661 | /* write protect signal, active low */ |
| 801 | | READ_LINE_DEVICE_HANDLER( floppy_wpt_r ) |
| 662 | READ_LINE_MEMBER( legacy_floppy_image_device::floppy_wpt_r ) |
| 802 | 663 | { |
| 803 | | floppy_drive *drive = get_safe_token(device); |
| 804 | | return drive->wpt; |
| 664 | return m_wpt; |
| 805 | 665 | } |
| 806 | 666 | |
| 807 | 667 | /* track 0 detect */ |
| 808 | | READ_LINE_DEVICE_HANDLER( floppy_tk00_r ) |
| 668 | READ_LINE_MEMBER( legacy_floppy_image_device::floppy_tk00_r ) |
| 809 | 669 | { |
| 810 | | floppy_drive *drive = get_safe_token(device); |
| 811 | | return drive->tk00; |
| 670 | return m_tk00; |
| 812 | 671 | } |
| 813 | 672 | |
| 814 | 673 | /* disk changed */ |
| 815 | | READ_LINE_DEVICE_HANDLER( floppy_dskchg_r ) |
| 674 | READ_LINE_MEMBER( legacy_floppy_image_device::floppy_dskchg_r ) |
| 816 | 675 | { |
| 817 | | floppy_drive *drive = get_safe_token(device); |
| 818 | | return drive->dskchg; |
| 676 | return m_dskchg; |
| 819 | 677 | } |
| 820 | 678 | |
| 821 | 679 | /* 2-sided disk */ |
| 822 | | READ_LINE_DEVICE_HANDLER( floppy_twosid_r ) |
| 680 | READ_LINE_MEMBER( legacy_floppy_image_device::floppy_twosid_r ) |
| 823 | 681 | { |
| 824 | | floppy_drive *drive = get_safe_token(device); |
| 825 | | |
| 826 | | if (drive->floppy == NULL) |
| 682 | if (m_floppy == NULL) |
| 827 | 683 | return ASSERT_LINE; |
| 828 | 684 | else |
| 829 | | return !floppy_get_heads_per_disk(drive->floppy); |
| 685 | return !floppy_get_heads_per_disk(m_floppy); |
| 830 | 686 | } |
| 831 | 687 | |
| 832 | | READ_LINE_DEVICE_HANDLER( floppy_index_r ) |
| 688 | READ_LINE_MEMBER( legacy_floppy_image_device::floppy_index_r ) |
| 833 | 689 | { |
| 834 | | floppy_drive *drive = get_safe_token(device); |
| 835 | | return drive->idx; |
| 690 | return m_idx; |
| 836 | 691 | } |
| 837 | 692 | |
| 838 | | READ_LINE_DEVICE_HANDLER( floppy_ready_r ) |
| 693 | READ_LINE_MEMBER( legacy_floppy_image_device::floppy_ready_r ) |
| 839 | 694 | { |
| 840 | | return !(floppy_drive_get_flag_state(device, FLOPPY_DRIVE_READY) == FLOPPY_DRIVE_READY); |
| 695 | return !(floppy_drive_get_flag_state(FLOPPY_DRIVE_READY) == FLOPPY_DRIVE_READY); |
| 841 | 696 | } |
| 842 | 697 | |
| 843 | 698 | // device type definition |
| r29303 | r29304 | |
| 849 | 704 | |
| 850 | 705 | legacy_floppy_image_device::legacy_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 851 | 706 | : device_t(mconfig, LEGACY_FLOPPY, "Floppy Disk", tag, owner, clock, "legacy_floppy_image", __FILE__), |
| 852 | | device_image_interface(mconfig, *this), |
| 853 | | m_token(NULL) |
| 707 | device_image_interface(mconfig, *this) |
| 854 | 708 | { |
| 855 | | m_token = global_alloc_clear(floppy_drive); |
| 856 | 709 | } |
| 857 | 710 | |
| 858 | 711 | legacy_floppy_image_device::legacy_floppy_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) |
| 859 | 712 | : device_t(mconfig, type, name, tag, owner, clock, shortname, source), |
| 860 | | device_image_interface(mconfig, *this), |
| 861 | | m_token(NULL) |
| 713 | device_image_interface(mconfig, *this) |
| 862 | 714 | { |
| 863 | | m_token = global_alloc_clear(floppy_drive); |
| 864 | 715 | } |
| 865 | 716 | |
| 866 | 717 | //------------------------------------------------- |
| r29303 | r29304 | |
| 869 | 720 | |
| 870 | 721 | legacy_floppy_image_device::~legacy_floppy_image_device() |
| 871 | 722 | { |
| 872 | | global_free(m_token); |
| 873 | 723 | } |
| 874 | 724 | |
| 875 | 725 | //------------------------------------------------- |
| r29303 | r29304 | |
| 878 | 728 | |
| 879 | 729 | void legacy_floppy_image_device::device_start() |
| 880 | 730 | { |
| 881 | | floppy_drive *floppy = get_safe_token( this ); |
| 882 | | floppy->config = (const floppy_interface*)static_config(); |
| 883 | | floppy_drive_init(this); |
| 731 | m_config = (const floppy_interface*)static_config(); |
| 732 | floppy_drive_init(); |
| 884 | 733 | |
| 885 | | floppy->drive_id = floppy_get_drive(this); |
| 886 | | floppy->active = FALSE; |
| 734 | m_drive_id = floppy_get_drive(this); |
| 735 | m_active = FALSE; |
| 887 | 736 | |
| 888 | 737 | /* resolve callbacks */ |
| 889 | | floppy->out_idx_func.resolve(floppy->config->out_idx_func, *this); |
| 890 | | floppy->in_mon_func.resolve(floppy->config->in_mon_func, *this); |
| 891 | | floppy->out_tk00_func.resolve(floppy->config->out_tk00_func, *this); |
| 892 | | floppy->out_wpt_func.resolve(floppy->config->out_wpt_func, *this); |
| 893 | | floppy->out_rdy_func.resolve(floppy->config->out_rdy_func, *this); |
| 894 | | // floppy->out_dskchg_func.resolve(floppy->config->out_dskchg_func, *this); |
| 738 | m_out_idx_func.resolve(m_config->out_idx_func, *this); |
| 739 | m_in_mon_func.resolve(m_config->in_mon_func, *this); |
| 740 | m_out_tk00_func.resolve(m_config->out_tk00_func, *this); |
| 741 | m_out_wpt_func.resolve(m_config->out_wpt_func, *this); |
| 742 | m_out_rdy_func.resolve(m_config->out_rdy_func, *this); |
| 743 | // m_out_dskchg_func.resolve(m_config->out_dskchg_func, *this); |
| 895 | 744 | |
| 896 | 745 | /* by default we are not write-protected */ |
| 897 | | floppy->wpt = ASSERT_LINE; |
| 898 | | floppy->out_wpt_func(floppy->wpt); |
| 746 | m_wpt = ASSERT_LINE; |
| 747 | m_out_wpt_func(m_wpt); |
| 899 | 748 | |
| 900 | 749 | /* not at track 0 */ |
| 901 | | floppy->tk00 = ASSERT_LINE; |
| 902 | | floppy->out_tk00_func(floppy->tk00); |
| 750 | m_tk00 = ASSERT_LINE; |
| 751 | m_out_tk00_func(m_tk00); |
| 903 | 752 | |
| 904 | 753 | /* motor off */ |
| 905 | | floppy->mon = ASSERT_LINE; |
| 754 | m_mon = ASSERT_LINE; |
| 906 | 755 | |
| 907 | 756 | /* disk changed */ |
| 908 | | floppy->dskchg = CLEAR_LINE; |
| 909 | | // floppy->out_dskchg_func(floppy->dskchg); |
| 757 | m_dskchg = CLEAR_LINE; |
| 758 | // m_out_dskchg_func(m_dskchg); |
| 910 | 759 | } |
| 911 | 760 | |
| 912 | 761 | |
| r29303 | r29304 | |
| 936 | 785 | |
| 937 | 786 | bool legacy_floppy_image_device::call_create(int format_type, option_resolution *format_options) |
| 938 | 787 | { |
| 939 | | return internal_floppy_device_load(this, format_type, format_options); |
| 788 | return internal_floppy_device_load(format_type, format_options); |
| 940 | 789 | } |
| 941 | 790 | |
| 942 | 791 | bool legacy_floppy_image_device::call_load() |
| 943 | 792 | { |
| 944 | | floppy_drive *flopimg; |
| 945 | | int retVal = internal_floppy_device_load(this, -1, NULL); |
| 946 | | flopimg = get_safe_token( this); |
| 793 | int retVal = internal_floppy_device_load(-1, NULL); |
| 947 | 794 | if (retVal==IMAGE_INIT_PASS) { |
| 948 | 795 | /* if we have one of our hacky unload procs, call it */ |
| 949 | | if (flopimg->load_proc) |
| 950 | | flopimg->load_proc(*this); |
| 796 | if (m_load_proc) |
| 797 | m_load_proc(*this); |
| 951 | 798 | } |
| 952 | 799 | |
| 953 | 800 | /* push disk halfway into drive */ |
| 954 | | flopimg->wpt = CLEAR_LINE; |
| 955 | | flopimg->out_wpt_func(flopimg->wpt); |
| 801 | m_wpt = CLEAR_LINE; |
| 802 | m_out_wpt_func(m_wpt); |
| 956 | 803 | |
| 957 | 804 | /* set timer for disk load */ |
| 958 | 805 | int next_wpt; |
| r29303 | r29304 | |
| 962 | 809 | else |
| 963 | 810 | next_wpt = CLEAR_LINE; |
| 964 | 811 | |
| 965 | | machine().scheduler().timer_set(attotime::from_msec(250), FUNC(set_wpt), next_wpt, flopimg); |
| 812 | machine().scheduler().timer_set(attotime::from_msec(250), timer_expired_delegate(FUNC(legacy_floppy_image_device::set_wpt),this), next_wpt); |
| 966 | 813 | |
| 967 | 814 | return retVal; |
| 968 | 815 | } |
| 969 | 816 | |
| 970 | 817 | void legacy_floppy_image_device::call_unload() |
| 971 | 818 | { |
| 972 | | floppy_drive *flopimg = get_safe_token( this); |
| 973 | | if (flopimg->unload_proc) |
| 974 | | flopimg->unload_proc(*this); |
| 819 | if (m_unload_proc) |
| 820 | m_unload_proc(*this); |
| 975 | 821 | |
| 976 | | floppy_close(flopimg->floppy); |
| 977 | | flopimg->floppy = NULL; |
| 822 | floppy_close(m_floppy); |
| 823 | m_floppy = NULL; |
| 978 | 824 | |
| 979 | 825 | /* disk changed */ |
| 980 | | flopimg->dskchg = CLEAR_LINE; |
| 981 | | //flopimg->out_dskchg_func(flopimg->dskchg); |
| 826 | m_dskchg = CLEAR_LINE; |
| 827 | //m_out_dskchg_func(m_dskchg); |
| 982 | 828 | |
| 983 | 829 | /* pull disk halfway out of drive */ |
| 984 | | flopimg->wpt = CLEAR_LINE; |
| 985 | | flopimg->out_wpt_func(flopimg->wpt); |
| 830 | m_wpt = CLEAR_LINE; |
| 831 | m_out_wpt_func(m_wpt); |
| 986 | 832 | |
| 987 | 833 | /* set timer for disk eject */ |
| 988 | | machine().scheduler().timer_set(attotime::from_msec(250), FUNC(set_wpt), ASSERT_LINE, flopimg); |
| 834 | machine().scheduler().timer_set(attotime::from_msec(250), timer_expired_delegate(FUNC(legacy_floppy_image_device::set_wpt),this), ASSERT_LINE); |
| 989 | 835 | } |
| 990 | 836 | |
| 991 | 837 | void legacy_floppy_image_device::call_display_info() |
shelves/new_menus/src/emu/imagedev/flopdrv.h
| r29303 | r29304 | |
| 90 | 90 | /* set if index has just occurred */ |
| 91 | 91 | #define FLOPPY_DRIVE_INDEX 0x0020 |
| 92 | 92 | |
| 93 | | /* a callback which will be executed if the ready state of the drive changes e.g. not ready->ready, ready->not ready */ |
| 94 | | void floppy_drive_set_ready_state_change_callback(device_t *img, void (*callback)(device_t *controller,device_t *img, int state)); |
| 95 | 93 | |
| 96 | | void floppy_drive_set_index_pulse_callback(device_t *img, void (*callback)(device_t *controller,device_t *image, int state)); |
| 97 | | |
| 98 | | /* set flag state */ |
| 99 | | int floppy_drive_get_flag_state(device_t *img, int flag); |
| 100 | | /* get flag state */ |
| 101 | | void floppy_drive_set_flag_state(device_t *img, int flag, int state); |
| 102 | | /* get current physical track drive is on */ |
| 103 | | int floppy_drive_get_current_track(device_t *img); |
| 104 | | /* get current physical track size */ |
| 105 | | UINT64 floppy_drive_get_current_track_size(device_t *img, int head); |
| 106 | | |
| 107 | | /* get next id from track, 1 if got a id, 0 if no id was got */ |
| 108 | | int floppy_drive_get_next_id(device_t *img, int side, chrn_id *); |
| 109 | | /* set ready state of drive. If flag == 1, set ready state only if drive present, |
| 110 | | disk is in drive, and motor is on. Otherwise set ready state to the state passed */ |
| 111 | | void floppy_drive_set_ready_state(device_t *img, int state, int flag); |
| 112 | | |
| 113 | | /* seek up or down */ |
| 114 | | void floppy_drive_seek(device_t *img, signed int signed_tracks); |
| 115 | | |
| 116 | | void floppy_drive_read_track_data_info_buffer(device_t *img, int side, void *ptr, int *length ); |
| 117 | | void floppy_drive_write_track_data_info_buffer(device_t *img, int side, const void *ptr, int *length ); |
| 118 | | void floppy_drive_format_sector(device_t *img, int side, int sector_index, int c, int h, int r, int n, int filler); |
| 119 | | void floppy_drive_read_sector_data(device_t *img, int side, int index1, void *pBuffer, int length); |
| 120 | | void floppy_drive_write_sector_data(device_t *img, int side, int index1, const void *pBuffer, int length, int ddam); |
| 121 | | |
| 122 | | /* set motor speed to get correct index pulses |
| 123 | | standard RPM are 300 RPM (common) and 360 RPM |
| 124 | | Note: this actually only works for soft sectored disks: one index pulse per |
| 125 | | track. |
| 126 | | */ |
| 127 | | void floppy_drive_set_rpm(device_t *image, float rpm); |
| 128 | | |
| 129 | | void floppy_drive_set_controller(device_t *img, device_t *controller); |
| 130 | | |
| 131 | | floppy_image_legacy *flopimg_get_image(device_t *image); |
| 132 | | |
| 133 | | /* hack for apple II; replace this when we think of something better */ |
| 134 | | void floppy_install_unload_proc(device_t *image, void (*proc)(device_image_interface &image)); |
| 135 | | |
| 136 | | void floppy_install_load_proc(device_t *image, void (*proc)(device_image_interface &image)); |
| 137 | | |
| 138 | | device_t *floppy_get_device(running_machine &machine,int drive); |
| 139 | | device_t *floppy_get_device_by_type(running_machine &machine,int ftype,int drive); |
| 140 | | int floppy_get_drive_type(device_t *image); |
| 141 | | void floppy_set_type(device_t *image,int ftype); |
| 142 | | int floppy_get_count(running_machine &machine); |
| 143 | | |
| 144 | | int floppy_get_drive(device_t *image); |
| 145 | | int floppy_get_drive_by_type(device_t *image,int ftype); |
| 146 | | |
| 147 | | void floppy_drive_set_geometry(device_t *img, floppy_type_t type); |
| 148 | | |
| 149 | | /* drive select lines */ |
| 150 | | WRITE_LINE_DEVICE_HANDLER( floppy_ds0_w ); |
| 151 | | WRITE_LINE_DEVICE_HANDLER( floppy_ds1_w ); |
| 152 | | WRITE_LINE_DEVICE_HANDLER( floppy_ds2_w ); |
| 153 | | WRITE_LINE_DEVICE_HANDLER( floppy_ds3_w ); |
| 154 | | DECLARE_WRITE8_DEVICE_HANDLER( floppy_ds_w ); |
| 155 | | |
| 156 | | WRITE_LINE_DEVICE_HANDLER( floppy_mon_w ); |
| 157 | | WRITE_LINE_DEVICE_HANDLER( floppy_drtn_w ); |
| 158 | | WRITE_LINE_DEVICE_HANDLER( floppy_stp_w ); |
| 159 | | WRITE_LINE_DEVICE_HANDLER( floppy_wtd_w ); |
| 160 | | WRITE_LINE_DEVICE_HANDLER( floppy_wtg_w ); |
| 161 | | |
| 162 | | /* write-protect */ |
| 163 | | READ_LINE_DEVICE_HANDLER( floppy_wpt_r ); |
| 164 | | |
| 165 | | /* track 0 detect */ |
| 166 | | READ_LINE_DEVICE_HANDLER( floppy_tk00_r ); |
| 167 | | |
| 168 | | /* disk changed */ |
| 169 | | READ_LINE_DEVICE_HANDLER( floppy_dskchg_r ); |
| 170 | | |
| 171 | | /* 2-sided disk */ |
| 172 | | READ_LINE_DEVICE_HANDLER( floppy_twosid_r ); |
| 173 | | |
| 174 | | // index pulse |
| 175 | | READ_LINE_DEVICE_HANDLER( floppy_index_r ); |
| 176 | | |
| 177 | | // drive ready |
| 178 | | READ_LINE_DEVICE_HANDLER( floppy_ready_r ); |
| 179 | | |
| 180 | 94 | class legacy_floppy_image_device : public device_t, |
| 181 | 95 | public device_image_interface |
| 182 | 96 | { |
| r29303 | r29304 | |
| 203 | 117 | virtual const char *file_extensions() const { return m_extension_list; } |
| 204 | 118 | virtual const option_guide *create_option_guide() const { return floppy_option_guide; } |
| 205 | 119 | |
| 206 | | // access to legacy token |
| 207 | | struct floppy_drive *token() const { assert(m_token != NULL); return m_token; } |
| 120 | floppy_image_legacy *flopimg_get_image(); |
| 121 | void floppy_drive_set_geometry(floppy_type_t type); |
| 122 | void floppy_drive_set_flag_state(int flag, int state); |
| 123 | void floppy_drive_set_ready_state(int state, int flag); |
| 124 | int floppy_drive_get_flag_state(int flag); |
| 125 | void floppy_drive_seek(signed int signed_tracks); |
| 126 | int floppy_drive_get_next_id(int side, chrn_id *id); |
| 127 | void floppy_drive_read_track_data_info_buffer(int side, void *ptr, int *length ); |
| 128 | void floppy_drive_write_track_data_info_buffer(int side, const void *ptr, int *length ); |
| 129 | void floppy_drive_format_sector(int side, int sector_index,int c,int h, int r, int n, int filler); |
| 130 | void floppy_drive_read_sector_data(int side, int index1, void *ptr, int length); |
| 131 | void floppy_drive_write_sector_data(int side, int index1, const void *ptr,int length, int ddam); |
| 132 | void floppy_install_load_proc(void (*proc)(device_image_interface &image)); |
| 133 | void floppy_install_unload_proc(void (*proc)(device_image_interface &image)); |
| 134 | void floppy_drive_set_index_pulse_callback(void (*callback)(device_t *controller,device_t *image, int state)); |
| 135 | void floppy_drive_set_ready_state_change_callback(void (*callback)(device_t *controller,device_t *img, int state)); |
| 136 | int floppy_drive_get_current_track(); |
| 137 | UINT64 floppy_drive_get_current_track_size(int head); |
| 138 | void floppy_drive_set_rpm(float rpm); |
| 139 | void floppy_drive_set_controller(device_t *controller); |
| 140 | int floppy_get_drive_type(); |
| 141 | void floppy_set_type(int ftype); |
| 142 | WRITE_LINE_MEMBER( floppy_ds0_w ); |
| 143 | WRITE_LINE_MEMBER( floppy_ds1_w ); |
| 144 | WRITE_LINE_MEMBER( floppy_ds2_w ); |
| 145 | WRITE_LINE_MEMBER( floppy_ds3_w ); |
| 146 | WRITE8_MEMBER( floppy_ds_w ); |
| 147 | WRITE_LINE_MEMBER( floppy_mon_w ); |
| 148 | WRITE_LINE_MEMBER( floppy_drtn_w ); |
| 149 | WRITE_LINE_MEMBER( floppy_wtd_w ); |
| 150 | WRITE_LINE_MEMBER( floppy_stp_w ); |
| 151 | WRITE_LINE_MEMBER( floppy_wtg_w ); |
| 152 | READ_LINE_MEMBER( floppy_wpt_r ); |
| 153 | READ_LINE_MEMBER( floppy_tk00_r ); |
| 154 | READ_LINE_MEMBER( floppy_dskchg_r ); |
| 155 | READ_LINE_MEMBER( floppy_twosid_r ); |
| 156 | READ_LINE_MEMBER( floppy_index_r ); |
| 157 | READ_LINE_MEMBER( floppy_ready_r ); |
| 158 | |
| 159 | |
| 160 | private: |
| 161 | int flopimg_get_sectors_per_track(int side); |
| 162 | void flopimg_get_id_callback(chrn_id *id, int id_index, int side); |
| 163 | void log_readwrite(const char *name, int head, int track, int sector, const char *buf, int length); |
| 164 | void floppy_drive_set_geometry_absolute(int tracks, int sides); |
| 165 | TIMER_CALLBACK_MEMBER(floppy_drive_index_callback); |
| 166 | void floppy_drive_init(); |
| 167 | void floppy_drive_index_func(); |
| 168 | TIMER_CALLBACK(floppy_drive_index_callback); |
| 169 | int internal_floppy_device_load(int create_format, option_resolution *create_args); |
| 170 | TIMER_CALLBACK_MEMBER( set_wpt ); |
| 171 | |
| 208 | 172 | protected: |
| 209 | 173 | // device overrides |
| 210 | 174 | virtual void device_config_complete(); |
| 211 | 175 | virtual void device_start(); |
| 212 | 176 | |
| 213 | | struct floppy_drive *m_token; |
| 177 | /* callbacks */ |
| 178 | devcb_resolved_write_line m_out_idx_func; |
| 179 | devcb_resolved_read_line m_in_mon_func; |
| 180 | devcb_resolved_write_line m_out_tk00_func; |
| 181 | devcb_resolved_write_line m_out_wpt_func; |
| 182 | devcb_resolved_write_line m_out_rdy_func; |
| 183 | devcb_resolved_write_line m_out_dskchg_func; |
| 184 | |
| 185 | /* state of input lines */ |
| 186 | int m_drtn; /* direction */ |
| 187 | int m_stp; /* step */ |
| 188 | int m_wtg; /* write gate */ |
| 189 | int m_mon; /* motor on */ |
| 190 | |
| 191 | /* state of output lines */ |
| 192 | int m_idx; /* index pulse */ |
| 193 | int m_tk00; /* track 00 */ |
| 194 | int m_wpt; /* write protect */ |
| 195 | int m_rdy; /* ready */ |
| 196 | int m_dskchg; /* disk changed */ |
| 197 | |
| 198 | /* drive select logic */ |
| 199 | int m_drive_id; |
| 200 | int m_active; |
| 201 | |
| 202 | const floppy_interface *m_config; |
| 203 | |
| 204 | /* flags */ |
| 205 | int m_flags; |
| 206 | /* maximum track allowed */ |
| 207 | int m_max_track; |
| 208 | /* num sides */ |
| 209 | int m_num_sides; |
| 210 | /* current track - this may or may not relate to the present cylinder number |
| 211 | stored by the fdc */ |
| 212 | int m_current_track; |
| 213 | |
| 214 | /* index pulse timer */ |
| 215 | emu_timer *m_index_timer; |
| 216 | /* index pulse callback */ |
| 217 | void (*m_index_pulse_callback)(device_t *controller,device_t *image, int state); |
| 218 | /* rotation per minute => gives index pulse frequency */ |
| 219 | float m_rpm; |
| 220 | |
| 221 | void (*m_ready_state_change_callback)(device_t *controller,device_t *img, int state); |
| 222 | |
| 223 | int m_id_index; |
| 224 | |
| 225 | device_t *m_controller; |
| 226 | |
| 227 | floppy_image_legacy *m_floppy; |
| 228 | int m_track; |
| 229 | void (*m_load_proc)(device_image_interface &image); |
| 230 | void (*m_unload_proc)(device_image_interface &image); |
| 231 | int m_floppy_drive_type; |
| 232 | |
| 214 | 233 | char m_extension_list[256]; |
| 215 | 234 | }; |
| 216 | 235 | |
| 217 | 236 | // device type definition |
| 218 | 237 | extern const device_type LEGACY_FLOPPY; |
| 219 | 238 | |
| 239 | |
| 240 | |
| 241 | legacy_floppy_image_device *floppy_get_device(running_machine &machine,int drive); |
| 242 | legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,int ftype,int drive); |
| 243 | int floppy_get_drive(device_t *image); |
| 244 | int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype); |
| 245 | int floppy_get_count(running_machine &machine); |
| 246 | |
| 247 | |
| 220 | 248 | /*************************************************************************** |
| 221 | 249 | DEVICE CONFIGURATION MACROS |
| 222 | 250 | ***************************************************************************/ |
shelves/new_menus/src/mess/drivers/wicat.c
| r29303 | r29304 | |
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | | // internal terminal |
| 752 | | static mc2661_interface wicat_uart0_intf = |
| 753 | | { |
| 754 | | 0, // RXC |
| 755 | | 0, // TXC |
| 756 | | DEVCB_DEVICE_LINE_MEMBER("videouart0",mc2661_device, rx_w), // TXD out |
| 757 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // RXRDY out |
| 758 | | DEVCB_NULL, // TXRDY out |
| 759 | | DEVCB_DEVICE_LINE_MEMBER("videouart0", mc2661_device, cts_w), // RTS out |
| 760 | | DEVCB_DEVICE_LINE_MEMBER("videouart0", mc2661_device, dsr_w), // DTR out |
| 761 | | DEVCB_NULL, // TXEMT out |
| 762 | | DEVCB_NULL, // BKDET out |
| 763 | | DEVCB_NULL // XSYNC out |
| 764 | | }; |
| 765 | | |
| 766 | | // RS232C ports (x5) |
| 767 | | static mc2661_interface wicat_uart1_intf = |
| 768 | | { |
| 769 | | 0, |
| 770 | | 0, |
| 771 | | DEVCB_DEVICE_LINE_MEMBER("serial1", rs232_port_device, write_txd), |
| 772 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // RXRDY out |
| 773 | | DEVCB_NULL, |
| 774 | | DEVCB_DEVICE_LINE_MEMBER("serial1", rs232_port_device, write_rts), |
| 775 | | DEVCB_DEVICE_LINE_MEMBER("serial1", rs232_port_device, write_dtr), |
| 776 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // TXEMT out |
| 777 | | DEVCB_NULL, |
| 778 | | DEVCB_NULL |
| 779 | | }; |
| 780 | | |
| 781 | | static mc2661_interface wicat_uart2_intf = |
| 782 | | { |
| 783 | | 0, |
| 784 | | 0, |
| 785 | | DEVCB_DEVICE_LINE_MEMBER("serial2", rs232_port_device, write_txd), |
| 786 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // RXRDY out |
| 787 | | DEVCB_NULL, |
| 788 | | DEVCB_DEVICE_LINE_MEMBER("serial2", rs232_port_device, write_rts), |
| 789 | | DEVCB_DEVICE_LINE_MEMBER("serial2", rs232_port_device, write_dtr), |
| 790 | | DEVCB_NULL, // TXEMT out |
| 791 | | DEVCB_NULL, |
| 792 | | DEVCB_NULL |
| 793 | | }; |
| 794 | | |
| 795 | | static mc2661_interface wicat_uart3_intf = |
| 796 | | { |
| 797 | | 0, |
| 798 | | 0, |
| 799 | | DEVCB_DEVICE_LINE_MEMBER("serial3", rs232_port_device, write_txd), |
| 800 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // RXRDY out |
| 801 | | DEVCB_NULL, |
| 802 | | DEVCB_DEVICE_LINE_MEMBER("serial3", rs232_port_device, write_rts), |
| 803 | | DEVCB_DEVICE_LINE_MEMBER("serial3", rs232_port_device, write_dtr), |
| 804 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // TXEMT out |
| 805 | | DEVCB_NULL, |
| 806 | | DEVCB_NULL |
| 807 | | }; |
| 808 | | |
| 809 | | static mc2661_interface wicat_uart4_intf = |
| 810 | | { |
| 811 | | 0, |
| 812 | | 0, |
| 813 | | DEVCB_DEVICE_LINE_MEMBER("serial4", rs232_port_device, write_txd), |
| 814 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // RXRDY out |
| 815 | | DEVCB_NULL, |
| 816 | | DEVCB_DEVICE_LINE_MEMBER("serial4", rs232_port_device, write_rts), |
| 817 | | DEVCB_DEVICE_LINE_MEMBER("serial4", rs232_port_device, write_dtr), |
| 818 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // TXEMT out |
| 819 | | DEVCB_NULL, |
| 820 | | DEVCB_NULL |
| 821 | | }; |
| 822 | | |
| 823 | | static mc2661_interface wicat_uart5_intf = |
| 824 | | { |
| 825 | | 0, |
| 826 | | 0, |
| 827 | | DEVCB_DEVICE_LINE_MEMBER("serial5", rs232_port_device, write_txd), |
| 828 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // RXRDY out |
| 829 | | DEVCB_NULL, |
| 830 | | DEVCB_DEVICE_LINE_MEMBER("serial5", rs232_port_device, write_rts), |
| 831 | | DEVCB_DEVICE_LINE_MEMBER("serial5", rs232_port_device, write_dtr), |
| 832 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // TXEMT out |
| 833 | | DEVCB_NULL, |
| 834 | | DEVCB_NULL |
| 835 | | }; |
| 836 | | |
| 837 | | // modem |
| 838 | | static mc2661_interface wicat_uart6_intf = |
| 839 | | { |
| 840 | | 0, // RXC |
| 841 | | 0, // TXC |
| 842 | | DEVCB_NULL, //DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, write_txd), // RXD out |
| 843 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // RXRDY out |
| 844 | | DEVCB_NULL, // TXRDY out |
| 845 | | DEVCB_NULL, //DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, write_rts), // RTS out |
| 846 | | DEVCB_NULL, //DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, write_dtr), // DTR out |
| 847 | | DEVCB_CPU_INPUT_LINE("maincpu",M68K_IRQ_2), // TXEMT out |
| 848 | | DEVCB_NULL, // BKDET out |
| 849 | | DEVCB_NULL // XSYNC out |
| 850 | | }; |
| 851 | | |
| 852 | | // terminal (2x INS2651, 1x IM6042 - one of these is for the keyboard, another communicates with the main board, the third is unknown) |
| 853 | | static mc2661_interface wicat_video_uart0_intf = |
| 854 | | { |
| 855 | | 0, // RXC |
| 856 | | 0, // TXC |
| 857 | | DEVCB_DEVICE_LINE_MEMBER("uart0",mc2661_device, rx_w), // RXD out |
| 858 | | DEVCB_CPU_INPUT_LINE("videocpu",INPUT_LINE_IRQ0), // RXRDY out |
| 859 | | DEVCB_NULL, // TXRDY out |
| 860 | | DEVCB_DEVICE_LINE_MEMBER("uart0",mc2661_device, cts_w), // RTS out |
| 861 | | DEVCB_DEVICE_LINE_MEMBER("uart0",mc2661_device, dsr_w), // DTR out |
| 862 | | DEVCB_NULL, // TXEMT out |
| 863 | | DEVCB_NULL, // BKDET out |
| 864 | | DEVCB_NULL // XSYNC out |
| 865 | | }; |
| 866 | | |
| 867 | | static mc2661_interface wicat_video_uart1_intf = |
| 868 | | { |
| 869 | | 19200, // RXC |
| 870 | | 19200, // TXC |
| 871 | | DEVCB_NULL, // RXD out |
| 872 | | DEVCB_CPU_INPUT_LINE("videocpu",INPUT_LINE_IRQ0), // RXRDY out |
| 873 | | DEVCB_NULL, // TXRDY out |
| 874 | | DEVCB_NULL, //DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, write_rts), // RTS out |
| 875 | | DEVCB_NULL, //DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, write_dtr), // DTR out |
| 876 | | DEVCB_NULL, // TXEMT out |
| 877 | | DEVCB_NULL, // BKDET out |
| 878 | | DEVCB_NULL // XSYNC out |
| 879 | | }; |
| 880 | | |
| 881 | 751 | static mm58274c_interface wicat_rtc_intf = |
| 882 | 752 | { |
| 883 | 753 | 0, // 12 hour |
| r29303 | r29304 | |
| 909 | 779 | |
| 910 | 780 | MCFG_MM58274C_ADD("rtc",wicat_rtc_intf) // actually an MM58174AN, but should be compatible |
| 911 | 781 | |
| 912 | | MCFG_MC2661_ADD("uart0", XTAL_5_0688MHz, wicat_uart0_intf) // connected to terminal board |
| 913 | | MCFG_MC2661_ADD("uart1", XTAL_5_0688MHz, wicat_uart1_intf) |
| 914 | | MCFG_MC2661_ADD("uart2", XTAL_5_0688MHz, wicat_uart2_intf) |
| 915 | | MCFG_MC2661_ADD("uart3", XTAL_5_0688MHz, wicat_uart3_intf) |
| 916 | | MCFG_MC2661_ADD("uart4", XTAL_5_0688MHz, wicat_uart4_intf) |
| 917 | | MCFG_MC2661_ADD("uart5", XTAL_5_0688MHz, wicat_uart5_intf) |
| 918 | | MCFG_MC2661_ADD("uart6", XTAL_5_0688MHz, wicat_uart6_intf) // connected to modem port |
| 782 | // internal terminal |
| 783 | MCFG_DEVICE_ADD("uart0", MC2661, XTAL_5_0688MHz) // connected to terminal board |
| 784 | MCFG_MC2661_TXD_HANDLER(DEVWRITELINE("videouart0", mc2661_device, rx_w)) |
| 785 | MCFG_MC2661_RXRDY_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 786 | MCFG_MC2661_RTS_HANDLER(DEVWRITELINE("videouart0", mc2661_device, cts_w)) |
| 787 | MCFG_MC2661_DTR_HANDLER(DEVWRITELINE("videouart0", mc2661_device, dsr_w)) |
| 919 | 788 | |
| 789 | // RS232C ports (x5) |
| 790 | MCFG_DEVICE_ADD("uart1", MC2661, XTAL_5_0688MHz) |
| 791 | MCFG_MC2661_TXD_HANDLER(DEVWRITELINE("serial1", rs232_port_device, write_txd)) |
| 792 | MCFG_MC2661_RXRDY_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 793 | MCFG_MC2661_RTS_HANDLER(DEVWRITELINE("serial1", rs232_port_device, write_rts)) |
| 794 | MCFG_MC2661_DTR_HANDLER(DEVWRITELINE("serial1", rs232_port_device, write_dtr)) |
| 795 | MCFG_MC2661_TXEMT_DSCHG_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 796 | |
| 797 | MCFG_DEVICE_ADD("uart2", MC2661, XTAL_5_0688MHz) |
| 798 | MCFG_MC2661_TXD_HANDLER(DEVWRITELINE("serial2", rs232_port_device, write_txd)) |
| 799 | MCFG_MC2661_RXRDY_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 800 | MCFG_MC2661_RTS_HANDLER(DEVWRITELINE("serial2", rs232_port_device, write_rts)) |
| 801 | MCFG_MC2661_DTR_HANDLER(DEVWRITELINE("serial2", rs232_port_device, write_dtr)) |
| 802 | |
| 803 | MCFG_DEVICE_ADD("uart3", MC2661, XTAL_5_0688MHz) |
| 804 | MCFG_MC2661_TXD_HANDLER(DEVWRITELINE("serial3", rs232_port_device, write_txd)) |
| 805 | MCFG_MC2661_RXRDY_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 806 | MCFG_MC2661_RTS_HANDLER(DEVWRITELINE("serial3", rs232_port_device, write_rts)) |
| 807 | MCFG_MC2661_DTR_HANDLER(DEVWRITELINE("serial3", rs232_port_device, write_dtr)) |
| 808 | MCFG_MC2661_TXEMT_DSCHG_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 809 | |
| 810 | MCFG_DEVICE_ADD("uart4", MC2661, XTAL_5_0688MHz) |
| 811 | MCFG_MC2661_TXD_HANDLER(DEVWRITELINE("serial4", rs232_port_device, write_txd)) |
| 812 | MCFG_MC2661_RXRDY_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 813 | MCFG_MC2661_RTS_HANDLER(DEVWRITELINE("serial4", rs232_port_device, write_rts)) |
| 814 | MCFG_MC2661_DTR_HANDLER(DEVWRITELINE("serial4", rs232_port_device, write_dtr)) |
| 815 | MCFG_MC2661_TXEMT_DSCHG_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 816 | |
| 817 | MCFG_DEVICE_ADD("uart5", MC2661, XTAL_5_0688MHz) |
| 818 | MCFG_MC2661_TXD_HANDLER(DEVWRITELINE("serial5", rs232_port_device, write_txd)) |
| 819 | MCFG_MC2661_RXRDY_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 820 | MCFG_MC2661_RTS_HANDLER(DEVWRITELINE("serial5", rs232_port_device, write_rts)) |
| 821 | MCFG_MC2661_DTR_HANDLER(DEVWRITELINE("serial5", rs232_port_device, write_dtr)) |
| 822 | MCFG_MC2661_TXEMT_DSCHG_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 823 | |
| 824 | // modem |
| 825 | MCFG_DEVICE_ADD("uart6", MC2661, XTAL_5_0688MHz) // connected to modem port |
| 826 | MCFG_MC2661_RXRDY_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 827 | MCFG_MC2661_TXEMT_DSCHG_HANDLER(INPUTLINE("maincpu", M68K_IRQ_2)) |
| 828 | |
| 920 | 829 | MCFG_RS232_PORT_ADD("serial1",default_rs232_devices,NULL) |
| 921 | 830 | MCFG_RS232_RXD_HANDLER(DEVWRITELINE("uart1",mc2661_device,rx_w)) |
| 922 | 831 | MCFG_RS232_DCD_HANDLER(DEVWRITELINE("uart1",mc2661_device,dcd_w)) |
| r29303 | r29304 | |
| 955 | 864 | MCFG_AM9517A_ADD("videodma", XTAL_8MHz, wicat_videodma_intf) // clock is a bit of guess |
| 956 | 865 | MCFG_IM6402_ADD("videouart", 0, 0) |
| 957 | 866 | MCFG_IM6402_DR_CALLBACK(WRITELINE(wicat_state, kb_data_ready)) |
| 958 | | MCFG_MC2661_ADD("videouart0", XTAL_5_0688MHz, wicat_video_uart0_intf) // the INS2651 looks similar enough to the MC2661... |
| 959 | | MCFG_MC2661_ADD("videouart1", XTAL_5_0688MHz, wicat_video_uart1_intf) |
| 867 | |
| 868 | // terminal (2x INS2651, 1x IM6042 - one of these is for the keyboard, another communicates with the main board, the third is unknown) |
| 869 | MCFG_DEVICE_ADD("videouart0", MC2661, XTAL_5_0688MHz) // the INS2651 looks similar enough to the MC2661... |
| 870 | MCFG_MC2661_TXD_HANDLER(DEVWRITELINE("uart0", mc2661_device, rx_w)) |
| 871 | MCFG_MC2661_RXRDY_HANDLER(INPUTLINE("videocpu", INPUT_LINE_IRQ0)) |
| 872 | MCFG_MC2661_RTS_HANDLER(DEVWRITELINE("uart0", mc2661_device, cts_w)) |
| 873 | MCFG_MC2661_DTR_HANDLER(DEVWRITELINE("uart0", mc2661_device, dsr_w)) |
| 874 | |
| 875 | MCFG_DEVICE_ADD("videouart1", MC2661, XTAL_5_0688MHz) |
| 876 | MCFG_MC2661_RXC(19200) |
| 877 | MCFG_MC2661_TXC(19200) |
| 878 | MCFG_MC2661_RXRDY_HANDLER(INPUTLINE("videocpu", INPUT_LINE_IRQ0)) |
| 879 | |
| 960 | 880 | MCFG_X2210_ADD("vsram") // XD2210 |
| 961 | 881 | |
| 962 | 882 | MCFG_SCREEN_ADD("screen",RASTER) |
shelves/new_menus/src/mess/machine/teleprinter.c
| r0 | r29304 | |
| 1 | #include "teleprinter.h" |
| 2 | |
| 3 | #define KEYBOARD_TAG "keyboard" |
| 4 | |
| 5 | static const UINT8 teleprinter_font[128*8] = |
| 6 | { |
| 7 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 8 | 0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00, |
| 9 | 0x38,0x38,0x38,0x38,0x00,0x00,0x00,0x00, |
| 10 | 0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x00,0x00, |
| 11 | 0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07, |
| 12 | 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07, |
| 13 | 0x38,0x38,0x38,0x38,0x07,0x07,0x07,0x07, |
| 14 | 0x3f,0x3f,0x3f,0x3f,0x07,0x07,0x07,0x07, |
| 15 | 0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38, |
| 16 | 0x07,0x07,0x07,0x07,0x38,0x38,0x38,0x38, |
| 17 | 0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38, |
| 18 | 0x3f,0x3f,0x3f,0x3f,0x38,0x38,0x38,0x38, |
| 19 | 0x00,0x00,0x00,0x00,0x3f,0x3f,0x3f,0x3f, |
| 20 | 0x07,0x07,0x07,0x07,0x3f,0x3f,0x3f,0x3f, |
| 21 | 0x38,0x38,0x38,0x38,0x3f,0x3f,0x3f,0x3f, |
| 22 | 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, |
| 23 | 0x00,0x00,0x00,0x00,0x2a,0x15,0x2a,0x15, |
| 24 | 0x2a,0x15,0x2a,0x15,0x00,0x00,0x00,0x00, |
| 25 | 0x3f,0x3f,0x3f,0x3f,0x2a,0x15,0x2a,0x15, |
| 26 | 0x2a,0x15,0x2a,0x15,0x3f,0x3f,0x3f,0x3f, |
| 27 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 28 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 29 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 30 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 31 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 32 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 33 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 34 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 35 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 36 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 37 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 38 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 39 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 40 | 0x08,0x08,0x08,0x08,0x08,0x00,0x08,0x00, |
| 41 | 0x14,0x14,0x14,0x00,0x00,0x00,0x00,0x00, |
| 42 | 0x14,0x14,0x3e,0x14,0x3e,0x14,0x14,0x00, |
| 43 | 0x08,0x3c,0x0a,0x1c,0x28,0x1e,0x08,0x00, |
| 44 | 0x06,0x26,0x10,0x08,0x04,0x32,0x30,0x00, |
| 45 | 0x08,0x14,0x14,0x0c,0x2a,0x12,0x2c,0x00, |
| 46 | 0x08,0x08,0x04,0x00,0x00,0x00,0x00,0x00, |
| 47 | 0x10,0x08,0x04,0x04,0x04,0x08,0x10,0x00, |
| 48 | 0x04,0x08,0x10,0x10,0x10,0x08,0x04,0x00, |
| 49 | 0x00,0x08,0x2a,0x1c,0x2a,0x08,0x00,0x00, |
| 50 | 0x00,0x08,0x08,0x3e,0x08,0x08,0x00,0x00, |
| 51 | 0x00,0x00,0x00,0x00,0x08,0x08,0x04,0x00, |
| 52 | 0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x00, |
| 53 | 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00, |
| 54 | 0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00, |
| 55 | 0x1c,0x22,0x32,0x2a,0x26,0x22,0x1c,0x00, |
| 56 | 0x08,0x0c,0x08,0x08,0x08,0x08,0x1c,0x00, |
| 57 | 0x1c,0x22,0x20,0x18,0x04,0x02,0x3e,0x00, |
| 58 | 0x3e,0x20,0x10,0x18,0x20,0x22,0x1c,0x00, |
| 59 | 0x10,0x18,0x14,0x12,0x3e,0x10,0x10,0x00, |
| 60 | 0x3e,0x02,0x1e,0x20,0x20,0x22,0x1c,0x00, |
| 61 | 0x10,0x08,0x04,0x1c,0x22,0x22,0x1c,0x00, |
| 62 | 0x3e,0x20,0x10,0x08,0x04,0x04,0x04,0x00, |
| 63 | 0x1c,0x22,0x22,0x1c,0x22,0x22,0x1c,0x00, |
| 64 | 0x1c,0x22,0x22,0x1c,0x10,0x08,0x04,0x00, |
| 65 | 0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x00, |
| 66 | 0x00,0x00,0x08,0x00,0x08,0x08,0x04,0x00, |
| 67 | 0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x00, |
| 68 | 0x00,0x00,0x3e,0x00,0x3e,0x00,0x00,0x00, |
| 69 | 0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00, |
| 70 | 0x1c,0x22,0x20,0x10,0x08,0x00,0x08,0x00, |
| 71 | 0x1c,0x22,0x32,0x2a,0x3a,0x02,0x3c,0x00, |
| 72 | 0x08,0x14,0x22,0x22,0x3e,0x22,0x22,0x00, |
| 73 | 0x1e,0x22,0x22,0x1e,0x22,0x22,0x1e,0x00, |
| 74 | 0x1c,0x22,0x02,0x02,0x02,0x22,0x1c,0x00, |
| 75 | 0x1e,0x24,0x24,0x24,0x24,0x24,0x1e,0x00, |
| 76 | 0x3e,0x02,0x02,0x1e,0x02,0x02,0x3e,0x00, |
| 77 | 0x3e,0x02,0x02,0x1e,0x02,0x02,0x02,0x00, |
| 78 | 0x1c,0x22,0x02,0x02,0x32,0x22,0x3c,0x00, |
| 79 | 0x22,0x22,0x22,0x3e,0x22,0x22,0x22,0x00, |
| 80 | 0x1c,0x08,0x08,0x08,0x08,0x08,0x1c,0x00, |
| 81 | 0x38,0x10,0x10,0x10,0x10,0x12,0x0c,0x00, |
| 82 | 0x22,0x12,0x0a,0x06,0x0a,0x12,0x22,0x00, |
| 83 | 0x02,0x02,0x02,0x02,0x02,0x02,0x3e,0x00, |
| 84 | 0x22,0x36,0x2a,0x2a,0x22,0x22,0x22,0x00, |
| 85 | 0x22,0x22,0x26,0x2a,0x32,0x22,0x22,0x00, |
| 86 | 0x1c,0x22,0x22,0x22,0x22,0x22,0x1c,0x00, |
| 87 | 0x1e,0x22,0x22,0x1e,0x02,0x02,0x02,0x00, |
| 88 | 0x1c,0x22,0x22,0x22,0x2a,0x12,0x2c,0x00, |
| 89 | 0x1e,0x22,0x22,0x1e,0x0a,0x12,0x22,0x00, |
| 90 | 0x1c,0x22,0x02,0x1c,0x20,0x22,0x1c,0x00, |
| 91 | 0x3e,0x08,0x08,0x08,0x08,0x08,0x08,0x00, |
| 92 | 0x22,0x22,0x22,0x22,0x22,0x22,0x1c,0x00, |
| 93 | 0x22,0x22,0x22,0x14,0x14,0x08,0x08,0x00, |
| 94 | 0x22,0x22,0x22,0x2a,0x2a,0x2a,0x14,0x00, |
| 95 | 0x22,0x22,0x14,0x08,0x14,0x22,0x22,0x00, |
| 96 | 0x22,0x22,0x22,0x14,0x08,0x08,0x08,0x00, |
| 97 | 0x3e,0x20,0x10,0x08,0x04,0x02,0x3e,0x00, |
| 98 | 0x0e,0x02,0x02,0x02,0x02,0x02,0x0e,0x00, |
| 99 | 0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00, |
| 100 | 0x38,0x20,0x20,0x20,0x20,0x20,0x38,0x00, |
| 101 | 0x08,0x1c,0x2a,0x08,0x08,0x08,0x08,0x00, |
| 102 | 0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00, |
| 103 | 0x04,0x08,0x00,0x00,0x00,0x00,0x00,0x00, |
| 104 | 0x00,0x00,0x1c,0x20,0x3c,0x22,0x3c,0x00, |
| 105 | 0x02,0x02,0x1e,0x22,0x22,0x22,0x1e,0x00, |
| 106 | 0x00,0x00,0x3c,0x02,0x02,0x02,0x3c,0x00, |
| 107 | 0x20,0x20,0x3c,0x22,0x22,0x22,0x3c,0x00, |
| 108 | 0x00,0x00,0x1c,0x22,0x3e,0x02,0x1c,0x00, |
| 109 | 0x18,0x04,0x0e,0x04,0x04,0x04,0x04,0x00, |
| 110 | 0x00,0x00,0x3c,0x22,0x22,0x3c,0x20,0x18, |
| 111 | 0x02,0x02,0x1e,0x22,0x22,0x22,0x22,0x00, |
| 112 | 0x08,0x00,0x0c,0x08,0x08,0x08,0x1c,0x00, |
| 113 | 0x10,0x00,0x18,0x10,0x10,0x10,0x12,0x0c, |
| 114 | 0x02,0x02,0x22,0x12,0x0e,0x16,0x22,0x00, |
| 115 | 0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x00, |
| 116 | 0x00,0x00,0x16,0x2a,0x2a,0x2a,0x2a,0x00, |
| 117 | 0x00,0x00,0x1a,0x26,0x22,0x22,0x22,0x00, |
| 118 | 0x00,0x00,0x1c,0x22,0x22,0x22,0x1c,0x00, |
| 119 | 0x00,0x00,0x1e,0x22,0x22,0x1e,0x02,0x02, |
| 120 | 0x00,0x00,0x3c,0x22,0x22,0x3c,0x20,0x20, |
| 121 | 0x00,0x00,0x34,0x0c,0x04,0x04,0x04,0x00, |
| 122 | 0x00,0x00,0x3c,0x02,0x1c,0x20,0x1e,0x00, |
| 123 | 0x08,0x08,0x1c,0x08,0x08,0x08,0x10,0x00, |
| 124 | 0x00,0x00,0x22,0x22,0x22,0x32,0x2c,0x00, |
| 125 | 0x00,0x00,0x22,0x22,0x22,0x14,0x08,0x00, |
| 126 | 0x00,0x00,0x22,0x22,0x2a,0x2a,0x14,0x00, |
| 127 | 0x00,0x00,0x22,0x14,0x08,0x14,0x22,0x00, |
| 128 | 0x00,0x00,0x22,0x22,0x14,0x08,0x04,0x02, |
| 129 | 0x00,0x00,0x3e,0x10,0x08,0x04,0x3e,0x00, |
| 130 | 0x10,0x08,0x08,0x04,0x08,0x08,0x10,0x00, |
| 131 | 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00, |
| 132 | 0x04,0x08,0x08,0x10,0x08,0x08,0x04,0x00, |
| 133 | 0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 134 | 0x2a,0x15,0x2a,0x15,0x2a,0x15,0x2a,0x15 |
| 135 | }; |
| 136 | |
| 137 | teleprinter_device::teleprinter_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 138 | : generic_terminal_device(mconfig, TELEPRINTER, "Teleprinter", tag, owner, clock, "teleprinter", __FILE__) |
| 139 | { |
| 140 | } |
| 141 | |
| 142 | void teleprinter_device::scroll_line() |
| 143 | { |
| 144 | memmove(m_buffer,m_buffer+TELEPRINTER_WIDTH,(TELEPRINTER_HEIGHT-1)*TELEPRINTER_WIDTH); |
| 145 | memset(m_buffer + TELEPRINTER_WIDTH*(TELEPRINTER_HEIGHT-1),0x20,TELEPRINTER_WIDTH); |
| 146 | } |
| 147 | |
| 148 | void teleprinter_device::write_char(UINT8 data) { |
| 149 | m_buffer[(TELEPRINTER_HEIGHT-1)*TELEPRINTER_WIDTH+m_x_pos] = data; |
| 150 | m_x_pos++; |
| 151 | if (m_x_pos >= TELEPRINTER_WIDTH) |
| 152 | { |
| 153 | m_x_pos = 0; |
| 154 | scroll_line(); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | void teleprinter_device::clear() { |
| 159 | memset(m_buffer,0,TELEPRINTER_WIDTH*TELEPRINTER_HEIGHT); |
| 160 | m_x_pos = 0; |
| 161 | } |
| 162 | |
| 163 | void teleprinter_device::term_write(UINT8 data) |
| 164 | { |
| 165 | switch(data) { |
| 166 | case 10: m_x_pos = 0; |
| 167 | scroll_line(); |
| 168 | break; |
| 169 | case 13: m_x_pos = 0; break; |
| 170 | case 9: m_x_pos = (m_x_pos & 0xf8) + 8; |
| 171 | if (m_x_pos >= TELEPRINTER_WIDTH) |
| 172 | m_x_pos = TELEPRINTER_WIDTH-1; |
| 173 | |
| 174 | break; |
| 175 | case 16: break; |
| 176 | default: write_char(data); break; |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | /*************************************************************************** |
| 181 | VIDEO HARDWARE |
| 182 | ***************************************************************************/ |
| 183 | UINT32 teleprinter_device::tp_update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 184 | { |
| 185 | UINT8 code; |
| 186 | int y, c, x, b; |
| 187 | |
| 188 | for (y = 0; y < TELEPRINTER_HEIGHT; y++) |
| 189 | { |
| 190 | for (c = 0; c < 8; c++) |
| 191 | { |
| 192 | int horpos = 0; |
| 193 | for (x = 0; x < TELEPRINTER_WIDTH; x++) |
| 194 | { |
| 195 | code = teleprinter_font[(m_buffer[y*TELEPRINTER_WIDTH + x] & 0x7f) *8 + c]; |
| 196 | for (b = 0; b < 8; b++) |
| 197 | { |
| 198 | bitmap.pix32(y*8 + c, horpos++) = (code >> b) & 0x01 ? 0 : 0x00ffffff; |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | static ASCII_KEYBOARD_INTERFACE( keyboard_intf ) |
| 207 | { |
| 208 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, generic_terminal_device, kbd_put) |
| 209 | }; |
| 210 | |
| 211 | /*************************************************************************** |
| 212 | VIDEO HARDWARE |
| 213 | ***************************************************************************/ |
| 214 | MACHINE_CONFIG_FRAGMENT( generic_teleprinter ) |
| 215 | MCFG_SCREEN_ADD(TELEPRINTER_SCREEN_TAG, RASTER) |
| 216 | MCFG_SCREEN_REFRESH_RATE(50) |
| 217 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 218 | MCFG_SCREEN_SIZE(TELEPRINTER_WIDTH*8, TELEPRINTER_HEIGHT*8) |
| 219 | MCFG_SCREEN_VISIBLE_AREA(0, TELEPRINTER_WIDTH*8-1, 0, TELEPRINTER_HEIGHT*8-1) |
| 220 | MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, teleprinter_device, tp_update) |
| 221 | MCFG_ASCII_KEYBOARD_ADD(KEYBOARD_TAG, keyboard_intf) |
| 222 | MACHINE_CONFIG_END |
| 223 | |
| 224 | machine_config_constructor teleprinter_device::device_mconfig_additions() const |
| 225 | { |
| 226 | return MACHINE_CONFIG_NAME(generic_teleprinter); |
| 227 | } |
| 228 | |
| 229 | /*------------------------------------------------- |
| 230 | device_reset - device-specific reset |
| 231 | -------------------------------------------------*/ |
| 232 | |
| 233 | void teleprinter_device::device_reset() |
| 234 | { |
| 235 | clear(); |
| 236 | generic_terminal_device::device_reset(); |
| 237 | } |
| 238 | |
| 239 | const device_type TELEPRINTER = &device_creator<teleprinter_device>; |
shelves/new_menus/src/mess/machine/thomflop.c
| r29303 | r29304 | |
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /* build a sector, with header & space */ |
| 118 | | int thomson_state::thom_floppy_make_sector( device_t* img, chrn_id id, UINT8* dst, int sector_size ) |
| 118 | int thomson_state::thom_floppy_make_sector( legacy_floppy_image_device* img, chrn_id id, UINT8* dst, int sector_size ) |
| 119 | 119 | { |
| 120 | 120 | if ( sector_size == 128 ) |
| 121 | 121 | { |
| 122 | 122 | /* single density */ |
| 123 | 123 | memset( dst, 0x00, 6 ); /* synchro bytes */ |
| 124 | 124 | dst[ 6 ] = 0xfb; /* data field mark */ |
| 125 | | floppy_drive_read_sector_data |
| 126 | | ( img, id.H, id.data_id, dst + 7, sector_size ); |
| 125 | img->floppy_drive_read_sector_data |
| 126 | ( id.H, id.data_id, dst + 7, sector_size ); |
| 127 | 127 | dst[ sector_size + 7 ] = 0; /* TODO: CRC */ |
| 128 | 128 | dst[ sector_size + 8 ] = 0; /* TODO: CRC */ |
| 129 | 129 | memset( dst + sector_size + 9, 0xff, 22 ); /* end mark */ |
| r29303 | r29304 | |
| 134 | 134 | /* double density */ |
| 135 | 135 | memset( dst, 0xa1, 3 ); /* synchro bytes */ |
| 136 | 136 | dst[ 3 ] = 0xfb; /* data field mark */ |
| 137 | | floppy_drive_read_sector_data |
| 138 | | ( img, id.H, id.data_id, dst + 4, sector_size ); |
| 137 | img->floppy_drive_read_sector_data |
| 138 | ( id.H, id.data_id, dst + 4, sector_size ); |
| 139 | 139 | dst[ sector_size + 4 ] = 0; /* TODO: CRC */ |
| 140 | 140 | dst[ sector_size + 5 ] = 0; /* TODO: CRC */ |
| 141 | 141 | memset( dst + sector_size + 6, 0xF7, 74 ); /* end mark */ |
| r29303 | r29304 | |
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | /* build a whole track */ |
| 149 | | int thomson_state::thom_floppy_make_track( device_t* img, UINT8* dst, int sector_size, int side ) |
| 149 | int thomson_state::thom_floppy_make_track( legacy_floppy_image_device* img, UINT8* dst, int sector_size, int side ) |
| 150 | 150 | { |
| 151 | 151 | UINT8 space = ( sector_size == 128 ) ? 0xff : 0; |
| 152 | 152 | UINT8* org = dst; |
| r29303 | r29304 | |
| 154 | 154 | int nb; |
| 155 | 155 | |
| 156 | 156 | /* go to start of track */ |
| 157 | | while ( ! floppy_drive_get_flag_state( img, FLOPPY_DRIVE_INDEX ) ) |
| 157 | while ( ! img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) ) |
| 158 | 158 | { |
| 159 | | if ( ! floppy_drive_get_next_id( img, side, &id ) ) |
| 159 | if ( ! img->floppy_drive_get_next_id( side, &id ) ) |
| 160 | 160 | return 0; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /* for each sector... */ |
| 164 | 164 | for ( nb = 0; nb < 16; nb++ ) |
| 165 | 165 | { |
| 166 | | if ( ! floppy_drive_get_next_id( img, side, &id ) ) |
| 166 | if ( ! img->floppy_drive_get_next_id( side, &id ) ) |
| 167 | 167 | break; |
| 168 | 168 | |
| 169 | 169 | memset( dst, space, THOM_SIZE_SYNCHRO ); dst += THOM_SIZE_SYNCHRO; |
| r29303 | r29304 | |
| 171 | 171 | memset( dst, space, THOM_SIZE_SYNCHRO ); dst += THOM_SIZE_SYNCHRO; |
| 172 | 172 | dst += thom_floppy_make_sector( img, id, dst, sector_size ); |
| 173 | 173 | |
| 174 | | if ( floppy_drive_get_flag_state( img, FLOPPY_DRIVE_INDEX ) ) |
| 174 | if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) ) |
| 175 | 175 | break; |
| 176 | 176 | } |
| 177 | 177 | return dst - org; |
| r29303 | r29304 | |
| 222 | 222 | |
| 223 | 223 | |
| 224 | 224 | /* build a sector, with header */ |
| 225 | | int thomson_state::thom_qdd_make_sector( device_t* img, int sector, UINT8* dst ) |
| 225 | int thomson_state::thom_qdd_make_sector( legacy_floppy_image_device* img, int sector, UINT8* dst ) |
| 226 | 226 | { |
| 227 | 227 | int i; |
| 228 | 228 | dst[ 0 ] = 0x5a; |
| 229 | | floppy_drive_read_sector_data ( img, 0, sector, dst + 1, 128 ); |
| 229 | img->floppy_drive_read_sector_data ( 0, sector, dst + 1, 128 ); |
| 230 | 230 | dst[ 129 ] = 0; |
| 231 | 231 | for ( i = 0; i < 129; i++ ) |
| 232 | 232 | dst[ 129 ] += dst[ i ]; |
| r29303 | r29304 | |
| 236 | 236 | |
| 237 | 237 | |
| 238 | 238 | /* build a whole disk */ |
| 239 | | int thomson_state::thom_qdd_make_disk ( device_t* img, UINT8* dst ) |
| 239 | int thomson_state::thom_qdd_make_disk ( legacy_floppy_image_device* img, UINT8* dst ) |
| 240 | 240 | { |
| 241 | 241 | UINT8* org = dst; |
| 242 | 242 | int i; |
| r29303 | r29304 | |
| 418 | 418 | machine().time().as_double(), m_maincpu->pc(), offset, data ); |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | | void thomson_state::to7_5p14_index_pulse_callback( device_t *controller,device_t *image, int state ) |
| 421 | void thomson_state::to7_5p14_index_pulse_callback( device_t *controller,legacy_floppy_image_device *image, int state ) |
| 422 | 422 | { |
| 423 | 423 | m_mc6843->set_index_pulse( state ); |
| 424 | 424 | } |
| r29303 | r29304 | |
| 429 | 429 | LOG(( "to7_5p14sd_reset: CD 90-015 controller\n" )); |
| 430 | 430 | for ( i = 0; i < floppy_get_count( machine() ); i++ ) |
| 431 | 431 | { |
| 432 | | device_t * img = floppy_get_device( machine(), i ); |
| 432 | legacy_floppy_image_device * img = floppy_get_device( machine(), i ); |
| 433 | 433 | if (img) { |
| 434 | | floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 ); |
| 435 | | floppy_drive_set_rpm( img, 300. ); |
| 436 | | floppy_drive_seek( img, - floppy_drive_get_current_track( img ) ); |
| 434 | img->floppy_drive_set_ready_state( FLOPPY_DRIVE_READY, 0 ); |
| 435 | img->floppy_drive_set_rpm( 300. ); |
| 436 | img->floppy_drive_seek( - img->floppy_drive_get_current_track() ); |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | } |
| r29303 | r29304 | |
| 515 | 515 | |
| 516 | 516 | |
| 517 | 517 | |
| 518 | | void thomson_state::to7_qdd_index_pulse_cb( device_t *controller,device_t *image, int state ) |
| 518 | void thomson_state::to7_qdd_index_pulse_cb( device_t *controller,legacy_floppy_image_device *image, int state ) |
| 519 | 519 | { |
| 520 | 520 | to7qdd->index_pulse = state; |
| 521 | 521 | |
| r29303 | r29304 | |
| 532 | 532 | |
| 533 | 533 | |
| 534 | 534 | |
| 535 | | device_t * thomson_state::to7_qdd_image() |
| 535 | legacy_floppy_image_device * thomson_state::to7_qdd_image() |
| 536 | 536 | { |
| 537 | 537 | return floppy_get_device( machine(), 0 ); |
| 538 | 538 | } |
| r29303 | r29304 | |
| 548 | 548 | to7qdd->status |= QDD_S_PE; |
| 549 | 549 | |
| 550 | 550 | /* write-protect */ |
| 551 | | if (floppy_wpt_r(to7_qdd_image()) == CLEAR_LINE) |
| 551 | if (to7_qdd_image()->floppy_wpt_r() == CLEAR_LINE) |
| 552 | 552 | to7qdd->status |= QDD_S_NCTS; |
| 553 | 553 | |
| 554 | 554 | /* sticky reset conditions */ |
| r29303 | r29304 | |
| 644 | 644 | LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n", |
| 645 | 645 | machine().time().as_double(), m_maincpu->pc(), sector )); |
| 646 | 646 | |
| 647 | | floppy_drive_format_sector( to7_qdd_image(), |
| 647 | to7_qdd_image()->floppy_drive_format_sector( |
| 648 | 648 | 0, sector, 0, 0, sector, 128, filler ); |
| 649 | 649 | thom_floppy_active( 1 ); |
| 650 | 650 | to7qdd->start_idx = to7qdd->data_idx; |
| r29303 | r29304 | |
| 673 | 673 | LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n", |
| 674 | 674 | machine().time().as_double(), m_maincpu->pc(), sector )); |
| 675 | 675 | |
| 676 | | floppy_drive_write_sector_data( to7_qdd_image(), 0, sector, to7qdd->data + to7qdd->start_idx + 1, 128, 0 ); |
| 676 | to7_qdd_image()->floppy_drive_write_sector_data( 0, sector, to7qdd->data + to7qdd->start_idx + 1, 128, 0 ); |
| 677 | 677 | thom_floppy_active( 1 ); |
| 678 | 678 | } |
| 679 | 679 | |
| r29303 | r29304 | |
| 825 | 825 | |
| 826 | 826 | for ( i = 0; i < floppy_get_count( machine() ); i++ ) |
| 827 | 827 | { |
| 828 | | device_t * img = floppy_get_device( machine(), i ); |
| 828 | legacy_floppy_image_device * img = floppy_get_device( machine(), i ); |
| 829 | 829 | if (img) { |
| 830 | | floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 ); |
| 830 | img->floppy_drive_set_ready_state( FLOPPY_DRIVE_READY, 0 ); |
| 831 | 831 | |
| 832 | 832 | motor_on = CLEAR_LINE; |
| 833 | | floppy_mon_w(img, motor_on); |
| 833 | img->floppy_mon_w( motor_on); |
| 834 | 834 | |
| 835 | 835 | /* pulse each time the whole-disk spiraling track ends */ |
| 836 | 836 | /* at 90us per byte read, the disk can be read in 6s */ |
| 837 | | floppy_drive_set_rpm( img, 60. / 6. ); |
| 837 | img->floppy_drive_set_rpm( 60. / 6. ); |
| 838 | 838 | } |
| 839 | 839 | } |
| 840 | 840 | |
| r29303 | r29304 | |
| 927 | 927 | |
| 928 | 928 | |
| 929 | 929 | |
| 930 | | device_t * thomson_state::thmfc_floppy_image() |
| 930 | legacy_floppy_image_device * thomson_state::thmfc_floppy_image() |
| 931 | 931 | { |
| 932 | 932 | return floppy_get_device( machine(), thmfc1->drive ); |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | |
| 936 | 936 | |
| 937 | | int thomson_state::thmfc_floppy_is_qdd ( device_image_interface *image ) |
| 937 | int thomson_state::thmfc_floppy_is_qdd ( legacy_floppy_image_device *image ) |
| 938 | 938 | { |
| 939 | 939 | if (image==NULL) return 0; |
| 940 | 940 | if (!image->exists()) return 0; |
| r29303 | r29304 | |
| 943 | 943 | |
| 944 | 944 | |
| 945 | 945 | |
| 946 | | void thomson_state::thmfc_floppy_index_pulse_cb ( device_t *controller,device_t *image, int state ) |
| 946 | void thomson_state::thmfc_floppy_index_pulse_cb ( device_t *controller,legacy_floppy_image_device *image, int state ) |
| 947 | 947 | { |
| 948 | 948 | if ( image != thmfc_floppy_image()) |
| 949 | 949 | return; |
| 950 | 950 | |
| 951 | | if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(image))) |
| 951 | if ( thmfc_floppy_is_qdd(image)) |
| 952 | 952 | { |
| 953 | 953 | /* pulse each time the whole-disk spiraling track ends */ |
| 954 | | floppy_drive_set_rpm( image, 16.92f /* 423/25 */ ); |
| 954 | image->floppy_drive_set_rpm( 16.92f /* 423/25 */ ); |
| 955 | 955 | thmfc1->ipl = state; |
| 956 | 956 | if ( state ) |
| 957 | 957 | { |
| r29303 | r29304 | |
| 962 | 962 | } |
| 963 | 963 | else |
| 964 | 964 | { |
| 965 | | floppy_drive_set_rpm( image, 300. ); |
| 965 | image->floppy_drive_set_rpm( 300. ); |
| 966 | 966 | thmfc1->ipl = state; |
| 967 | 967 | if ( state ) |
| 968 | 968 | thmfc1->data_raw_idx = 0; |
| r29303 | r29304 | |
| 975 | 975 | |
| 976 | 976 | int thomson_state::thmfc_floppy_find_sector( chrn_id* dst ) |
| 977 | 977 | { |
| 978 | | device_t* img = thmfc_floppy_image(); |
| 978 | legacy_floppy_image_device* img = thmfc_floppy_image(); |
| 979 | 979 | chrn_id id; |
| 980 | 980 | int r = 0; |
| 981 | 981 | |
| 982 | 982 | /* scan track, try 4 revolutions */ |
| 983 | 983 | while ( r < 4 ) |
| 984 | 984 | { |
| 985 | | if ( floppy_drive_get_next_id( img, thmfc1->side, &id ) ) |
| 985 | if ( img->floppy_drive_get_next_id( thmfc1->side, &id ) ) |
| 986 | 986 | { |
| 987 | 987 | if ( id.C == thmfc1->track && |
| 988 | 988 | id.R == thmfc1->sector && |
| r29303 | r29304 | |
| 997 | 997 | } |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | | if ( floppy_drive_get_flag_state( img, FLOPPY_DRIVE_INDEX ) ) |
| 1000 | if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) ) |
| 1001 | 1001 | r++; |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | thmfc1->stat0 = THMFC1_STAT0_CRC_ERROR | THMFC1_STAT0_FINISHED; |
| 1005 | | LOG (( "thmfc_floppy_find_sector: sector not found drive=%i track=%i sector=%i\n", floppy_get_drive( img ), thmfc1->track, thmfc1->sector )); |
| 1005 | LOG (( "thmfc_floppy_find_sector: sector not found drive=%i track=%i sector=%i\n", floppy_get_drive(img), thmfc1->track, thmfc1->sector )); |
| 1006 | 1006 | return 0; |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| r29303 | r29304 | |
| 1017 | 1017 | |
| 1018 | 1018 | if ( thmfc1->op == THMFC1_OP_WRITE_SECT ) |
| 1019 | 1019 | { |
| 1020 | | device_t * img = thmfc_floppy_image(); |
| 1021 | | floppy_drive_write_sector_data( img, thmfc1->side, thmfc1->sector_id, thmfc1->data + 3, thmfc1->data_size - 3, 0 ); |
| 1020 | legacy_floppy_image_device * img = thmfc_floppy_image(); |
| 1021 | img->floppy_drive_write_sector_data( thmfc1->side, thmfc1->sector_id, thmfc1->data + 3, thmfc1->data_size - 3, 0 ); |
| 1022 | 1022 | thom_floppy_active( 1 ); |
| 1023 | 1023 | } |
| 1024 | 1024 | thmfc1->op = THMFC1_OP_RESET; |
| r29303 | r29304 | |
| 1068 | 1068 | /* rebuild track if needed */ |
| 1069 | 1069 | if ( ! thmfc1->data_raw_size ) |
| 1070 | 1070 | { |
| 1071 | | if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image()))) |
| 1071 | if ( thmfc_floppy_is_qdd(thmfc_floppy_image())) |
| 1072 | 1072 | /* QDD: track = whole disk */ |
| 1073 | 1073 | thmfc1->data_raw_size = thom_qdd_make_disk ( thmfc_floppy_image(), thmfc1->data ); |
| 1074 | 1074 | else |
| r29303 | r29304 | |
| 1136 | 1136 | |
| 1137 | 1137 | LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", machine().time().as_double(), m_maincpu->pc(), sector )); |
| 1138 | 1138 | |
| 1139 | | floppy_drive_format_sector( thmfc_floppy_image(), 0, sector, 0, 0, sector, 128, filler ); |
| 1139 | thmfc_floppy_image()->floppy_drive_format_sector( 0, sector, 0, 0, sector, 128, filler ); |
| 1140 | 1140 | thom_floppy_active( 1 ); |
| 1141 | 1141 | thmfc1->data_idx = 0; |
| 1142 | 1142 | } |
| r29303 | r29304 | |
| 1158 | 1158 | if ( i >= 0 ) |
| 1159 | 1159 | { |
| 1160 | 1160 | /* got an id & a data field => write */ |
| 1161 | | device_t * img = thmfc_floppy_image(); |
| 1161 | legacy_floppy_image_device * img = thmfc_floppy_image(); |
| 1162 | 1162 | int sector = (int) thmfc1->data[ i + 1 ] * 256 + |
| 1163 | 1163 | (int) thmfc1->data[ i + 2 ]; |
| 1164 | 1164 | |
| 1165 | 1165 | LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n", |
| 1166 | 1166 | machine().time().as_double(), m_maincpu->pc(), sector )); |
| 1167 | 1167 | |
| 1168 | | floppy_drive_write_sector_data( img, 0, sector, thmfc1->data + thmfc1->data_idx, 128, 0 ); |
| 1168 | img->floppy_drive_write_sector_data( 0, sector, thmfc1->data + thmfc1->data_idx, 128, 0 ); |
| 1169 | 1169 | thom_floppy_active( 1 ); |
| 1170 | 1170 | } |
| 1171 | 1171 | |
| r29303 | r29304 | |
| 1218 | 1218 | if ( !memcmp ( thmfc1->data, header, sizeof( header ) ) ) |
| 1219 | 1219 | { |
| 1220 | 1220 | /* got id field => format */ |
| 1221 | | device_t * img = thmfc_floppy_image(); |
| 1221 | legacy_floppy_image_device * img = thmfc_floppy_image(); |
| 1222 | 1222 | UINT8 track = thmfc1->data[4]; |
| 1223 | 1223 | UINT8 side = thmfc1->data[5]; |
| 1224 | 1224 | UINT8 sector = thmfc1->data[6]; |
| r29303 | r29304 | |
| 1227 | 1227 | chrn_id id; |
| 1228 | 1228 | if ( thmfc_floppy_find_sector( &id ) ) |
| 1229 | 1229 | { |
| 1230 | | floppy_drive_format_sector( img, side, thmfc1->sector_id, track, thmfc1->side, sector, length, filler ); |
| 1230 | img->floppy_drive_format_sector( side, thmfc1->sector_id, track, thmfc1->side, sector, length, filler ); |
| 1231 | 1231 | thom_floppy_active( 1 ); |
| 1232 | 1232 | } |
| 1233 | 1233 | } |
| r29303 | r29304 | |
| 1252 | 1252 | case 1: /* STAT1 */ |
| 1253 | 1253 | { |
| 1254 | 1254 | UINT8 data = 0; |
| 1255 | | device_image_interface * img = dynamic_cast<device_image_interface *>(thmfc_floppy_image()); |
| 1256 | | int flags = floppy_drive_get_flag_state( &img->device(), -1 ); |
| 1255 | legacy_floppy_image_device * img = thmfc_floppy_image(); |
| 1256 | int flags = img->floppy_drive_get_flag_state(-1 ); |
| 1257 | 1257 | if ( thmfc_floppy_is_qdd(img) ) |
| 1258 | 1258 | { |
| 1259 | 1259 | if ( ! img->exists() ) |
| r29303 | r29304 | |
| 1269 | 1269 | if ( img->exists() ) |
| 1270 | 1270 | data |= 0x20; /* disk change (?) */ |
| 1271 | 1271 | |
| 1272 | | data |= !floppy_tk00_r(&img->device()) << 3; |
| 1272 | data |= !img->floppy_tk00_r() << 3; |
| 1273 | 1273 | |
| 1274 | 1274 | if ( flags & FLOPPY_DRIVE_READY ) |
| 1275 | 1275 | data |= 0x02; |
| 1276 | 1276 | } |
| 1277 | 1277 | if (!motor_on) |
| 1278 | 1278 | data |= 0x10; |
| 1279 | | if (!floppy_wpt_r(&img->device())) |
| 1279 | if (!img->floppy_wpt_r()) |
| 1280 | 1280 | data |= 0x04; |
| 1281 | 1281 | VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", machine().time().as_double(), m_maincpu->pc(), data )); |
| 1282 | 1282 | return data; |
| r29303 | r29304 | |
| 1314 | 1314 | case 0: /* CMD0 */ |
| 1315 | 1315 | { |
| 1316 | 1316 | int wsync = (data >> 4) & 1; |
| 1317 | | int qdd = thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image())); |
| 1317 | int qdd = thmfc_floppy_is_qdd(thmfc_floppy_image()); |
| 1318 | 1318 | chrn_id id; |
| 1319 | 1319 | thmfc1->formatting = (data >> 2) & 1; |
| 1320 | 1320 | LOG (( "%f $%04x thmfc_floppy_w: CMD0=$%02X dens=%s wsync=%i dsync=%i fmt=%i op=%i\n", |
| r29303 | r29304 | |
| 1415 | 1415 | |
| 1416 | 1416 | case 2: /* CMD2 */ |
| 1417 | 1417 | { |
| 1418 | | device_t * img; |
| 1418 | legacy_floppy_image_device * img; |
| 1419 | 1419 | int seek = 0, motor; |
| 1420 | 1420 | thmfc1->drive = data & 2; |
| 1421 | 1421 | |
| 1422 | | img = thmfc_floppy_image(); |
| 1423 | | if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(img))) |
| 1422 | img = thmfc_floppy_image(); |
| 1423 | if ( thmfc_floppy_is_qdd(img)) |
| 1424 | 1424 | { |
| 1425 | 1425 | motor = !(data & 0x40); |
| 1426 | 1426 | /* no side select & no seek for QDD */ |
| r29303 | r29304 | |
| 1443 | 1443 | if ( seek ) |
| 1444 | 1444 | { |
| 1445 | 1445 | thmfc1->data_raw_size = 0; |
| 1446 | | floppy_drive_seek( img, seek ); |
| 1446 | img->floppy_drive_seek( seek ); |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | /* in real life, to keep the motor running, it is sufficient to |
| r29303 | r29304 | |
| 1451 | 1451 | instead of counting, we assume the motor is always running... |
| 1452 | 1452 | */ |
| 1453 | 1453 | motor_on = CLEAR_LINE /* motor */; |
| 1454 | | floppy_mon_w(img, motor_on); |
| 1454 | img->floppy_mon_w(motor_on); |
| 1455 | 1455 | } |
| 1456 | 1456 | break; |
| 1457 | 1457 | |
| 1458 | 1458 | |
| 1459 | 1459 | case 3: /* WDATA */ |
| 1460 | 1460 | thmfc1->wsync = data; |
| 1461 | | if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image()))) |
| 1461 | if ( thmfc_floppy_is_qdd(thmfc_floppy_image())) |
| 1462 | 1462 | thmfc_floppy_qdd_write_byte( data ); |
| 1463 | 1463 | else if ( thmfc1->op==THMFC1_OP_WRITE_SECT ) |
| 1464 | 1464 | thmfc_floppy_write_byte( data ); |
| r29303 | r29304 | |
| 1490 | 1490 | thmfc1->track = data; |
| 1491 | 1491 | LOG (( "%f $%04x thmfc_floppy_w: WTRCK=%i (real=%i)\n", |
| 1492 | 1492 | machine().time().as_double(), m_maincpu->pc(), data, |
| 1493 | | floppy_drive_get_current_track( thmfc_floppy_image() ) )); |
| 1493 | thmfc_floppy_image()->floppy_drive_get_current_track())); |
| 1494 | 1494 | break; |
| 1495 | 1495 | |
| 1496 | 1496 | case 7: /* WCELL */ |
| r29303 | r29304 | |
| 1514 | 1514 | |
| 1515 | 1515 | for ( i = 0; i < floppy_get_count( machine() ); i++ ) |
| 1516 | 1516 | { |
| 1517 | | device_t * img = floppy_get_device( machine(), i ); |
| 1517 | legacy_floppy_image_device * img = floppy_get_device( machine(), i ); |
| 1518 | 1518 | if (img) { |
| 1519 | | floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 ); |
| 1520 | | floppy_drive_seek( img, - floppy_drive_get_current_track( img ) ); |
| 1519 | img->floppy_drive_set_ready_state( FLOPPY_DRIVE_READY, 0 ); |
| 1520 | img->floppy_drive_seek( - img->floppy_drive_get_current_track() ); |
| 1521 | 1521 | } |
| 1522 | 1522 | } |
| 1523 | 1523 | |
| r29303 | r29304 | |
| 1912 | 1912 | to7_5p14_w( space, offset, data, mem_mask ); |
| 1913 | 1913 | } |
| 1914 | 1914 | |
| 1915 | | void thomson_state::thomson_index_callback(device_t *device, int state) |
| 1915 | void thomson_state::thomson_index_callback(legacy_floppy_image_device *device, int state) |
| 1916 | 1916 | { |
| 1917 | 1917 | switch ( to7_controller_type ) |
| 1918 | 1918 | { |
shelves/new_menus/src/mess/video/apollo.c
| r29303 | r29304 | |
| 96 | 96 | #define LUT_C0 0x01 |
| 97 | 97 | #define LUT_C1_C0(a) ((a)& (LUT_C1|LUT_C0)) |
| 98 | 98 | |
| 99 | | #define LUT_FIFO_SIZE 1024 |
| 100 | 99 | |
| 101 | | //************************************************************************** |
| 102 | | // class apollo_graphics |
| 103 | | //************************************************************************** |
| 104 | | |
| 105 | | class apollo_graphics /*: public device_t*/ |
| 100 | apollo_graphics_15i::bt458::bt458(running_machine &running_machine) |
| 106 | 101 | { |
| 107 | | public: |
| 108 | | apollo_graphics() |
| 109 | | { |
| 110 | | } |
| 111 | | |
| 112 | | void device_start(running_machine &m_machine); |
| 113 | | void device_reset(); |
| 114 | | void device_reset_mono19i(); |
| 115 | | |
| 116 | | // monochrome control |
| 117 | | READ8_DEVICE_HANDLER( apollo_mcr_r ); |
| 118 | | WRITE8_DEVICE_HANDLER( apollo_mcr_w ); |
| 119 | | |
| 120 | | // monochrome and color memory |
| 121 | | READ16_DEVICE_HANDLER( apollo_mem_r ); |
| 122 | | WRITE16_DEVICE_HANDLER( apollo_mem_w ); |
| 123 | | |
| 124 | | // color control |
| 125 | | READ8_DEVICE_HANDLER( apollo_ccr_r ); |
| 126 | | WRITE8_DEVICE_HANDLER( apollo_ccr_w ); |
| 127 | | |
| 128 | | UINT32 screen_update(bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 129 | | void vblank_state_changed(device_t *device, screen_device &screen, bool vblank_state); |
| 130 | | |
| 131 | | int is_mono() { return m_n_planes == 1; } |
| 132 | | |
| 133 | | private: |
| 134 | | class lut_fifo; |
| 135 | | class bt458; |
| 136 | | |
| 137 | | running_machine &machine() const |
| 138 | | { |
| 139 | | assert(m_machine != NULL); |
| 140 | | return *m_machine; |
| 141 | | } |
| 142 | | |
| 143 | | const char *cr_text(offs_t offset, UINT8 data, UINT8 rw); |
| 144 | | |
| 145 | | void increment_h_clock(); |
| 146 | | void increment_v_clock(); |
| 147 | | void increment_p_clock(); |
| 148 | | |
| 149 | | void log_cr1(const char * text, device_t *device); |
| 150 | | void set_cr1(device_t *device, UINT8 data); |
| 151 | | void set_cr3a(device_t *device, UINT8 data); |
| 152 | | void set_cr3b(device_t *device, UINT8 data); |
| 153 | | void set_lut_cr(device_t *device, UINT8 data); |
| 154 | | |
| 155 | | UINT32 set_msb0(UINT32 value, UINT8 data) |
| 156 | | { |
| 157 | | return (value & 0xffffff00) | data; |
| 158 | | } |
| 159 | | UINT32 set_lsb0(UINT32 value, UINT8 data) |
| 160 | | { |
| 161 | | return (value & 0xffff00ff) | (data << 8); |
| 162 | | } |
| 163 | | UINT32 set_msb1(UINT32 value, UINT8 data) |
| 164 | | { |
| 165 | | return (value & 0xff00ffff) | (data << 16); |
| 166 | | } |
| 167 | | UINT32 set_lsb1(UINT32 value, UINT8 data) |
| 168 | | { |
| 169 | | return (value & 0x00ffffff) | (data << 24); |
| 170 | | } |
| 171 | | UINT8 get_msb1(UINT32 value) |
| 172 | | { |
| 173 | | return (value >> 16) & 0xff; |
| 174 | | } |
| 175 | | UINT8 get_lsb1(UINT32 value) |
| 176 | | { |
| 177 | | return (value >> 24) & 0xff; |
| 178 | | } |
| 179 | | |
| 180 | | void set_status_rmw(); |
| 181 | | UINT16 rop(UINT16 dest_data, UINT16 src_data, UINT8 plane); |
| 182 | | void set_source_data(UINT32 offset); |
| 183 | | UINT32 get_source_data(UINT8 plane); |
| 184 | | void blt(UINT32 dest_addr, UINT16 mem_mask); |
| 185 | | |
| 186 | | UINT8 get_pixel(UINT32 offset, UINT16 mask); |
| 187 | | UINT8 c4p_read_adc(UINT8 data); |
| 188 | | UINT8 c8p_read_adc(UINT8 data); |
| 189 | | |
| 190 | | void screen_update1(bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 191 | | |
| 192 | | UINT16 m_n_planes; |
| 193 | | UINT16 m_width; |
| 194 | | UINT16 m_height; |
| 195 | | UINT16 m_buffer_width; |
| 196 | | UINT16 m_buffer_height; |
| 197 | | |
| 198 | | UINT8 m_sr; |
| 199 | | UINT8 m_device_id; |
| 200 | | UINT16 m_write_enable_register; |
| 201 | | UINT32 m_rop_register; |
| 202 | | UINT16 m_diag_mem_request; |
| 203 | | UINT8 m_cr0; |
| 204 | | UINT8 m_cr1; |
| 205 | | UINT8 m_cr2; |
| 206 | | UINT8 m_cr2b; |
| 207 | | UINT8 m_cr2_s_data; |
| 208 | | UINT8 m_cr2_s_plane; |
| 209 | | UINT8 m_cr2_d_plane; |
| 210 | | UINT8 m_cr3a; |
| 211 | | UINT8 m_cr3b; |
| 212 | | UINT8 m_ad_result; |
| 213 | | UINT8 m_ad_pending; |
| 214 | | |
| 215 | | UINT8 m_lut_control; |
| 216 | | UINT8 m_lut_data; |
| 217 | | |
| 218 | | UINT8 m_update_flag; |
| 219 | | UINT8 m_update_pending; |
| 220 | | |
| 221 | | UINT8 m_blt_cycle_count; |
| 222 | | UINT32 m_image_offset; |
| 223 | | UINT32 m_guard_latch[8]; |
| 224 | | |
| 225 | | int m_h_clock; |
| 226 | | int m_v_clock; |
| 227 | | int m_p_clock; |
| 228 | | int m_data_clock; |
| 229 | | |
| 230 | | UINT16 *m_image_memory; |
| 231 | | int m_image_plane_size; |
| 232 | | int m_image_memory_size; |
| 233 | | |
| 234 | | UINT32 m_color_lookup_table[16]; |
| 235 | | |
| 236 | | lut_fifo *m_lut_fifo; |
| 237 | | bt458 *m_bt458; |
| 238 | | |
| 239 | | running_machine *m_machine; |
| 240 | | }; |
| 241 | | |
| 242 | | //************************************************************************** |
| 243 | | // class LUT Fifo |
| 244 | | //************************************************************************** |
| 245 | | |
| 246 | | class apollo_graphics::lut_fifo |
| 247 | | { |
| 248 | | public: |
| 249 | | lut_fifo() |
| 250 | | { |
| 251 | | reset(); |
| 252 | | } |
| 253 | | |
| 254 | | void reset() |
| 255 | | { |
| 256 | | m_size = LUT_FIFO_SIZE; |
| 257 | | m_get_index = 0; |
| 258 | | m_put_index = 0; |
| 259 | | } |
| 260 | | |
| 261 | | void put(const UINT8 data) |
| 262 | | { |
| 263 | | if (!is_full()) |
| 264 | | { |
| 265 | | m_data[m_put_index] = data; |
| 266 | | m_put_index = (m_put_index + 1) % m_size; |
| 267 | | } |
| 268 | | } |
| 269 | | |
| 270 | | UINT8 get() |
| 271 | | { |
| 272 | | UINT8 data = is_empty() ? 0xff : m_data[m_get_index]; |
| 273 | | m_get_index = (m_get_index + 1) % m_size; |
| 274 | | return data; |
| 275 | | } |
| 276 | | |
| 277 | | int is_empty() |
| 278 | | { |
| 279 | | return m_get_index == m_put_index; |
| 280 | | } |
| 281 | | |
| 282 | | int is_full() |
| 283 | | { |
| 284 | | return ((m_put_index + 1) % m_size) == m_get_index; |
| 285 | | } |
| 286 | | |
| 287 | | private: |
| 288 | | UINT16 m_size; |
| 289 | | UINT16 m_get_index; |
| 290 | | UINT16 m_put_index; |
| 291 | | UINT8 m_data[LUT_FIFO_SIZE]; |
| 292 | | }; |
| 293 | | |
| 294 | | //************************************************************************** |
| 295 | | // class Brooktree Bt458 |
| 296 | | //************************************************************************** |
| 297 | | |
| 298 | | class apollo_graphics::bt458 |
| 299 | | { |
| 300 | | public: |
| 301 | | bt458(running_machine &running_machine); |
| 302 | | void start(); |
| 303 | | void reset(); |
| 304 | | UINT8 read(UINT8 c10); |
| 305 | | void write(UINT8 data, UINT8 c10); |
| 306 | | UINT32 get_rgb(UINT8 index); |
| 307 | | |
| 308 | | private: |
| 309 | | running_machine &machine() const |
| 310 | | { |
| 311 | | assert(m_machine != NULL); |
| 312 | | return *m_machine; |
| 313 | | } |
| 314 | | |
| 315 | | UINT8 m_color_counter; |
| 316 | | UINT8 m_red; |
| 317 | | UINT8 m_green; |
| 318 | | |
| 319 | | UINT8 m_address_register; |
| 320 | | UINT32 m_color_palette_RAM[256]; |
| 321 | | UINT32 m_overlay_color[4]; |
| 322 | | UINT8 m_read_mask_register; |
| 323 | | UINT8 m_blink_mask_register; |
| 324 | | UINT8 m_command_register; |
| 325 | | UINT8 m_control_test_register; |
| 326 | | |
| 327 | | running_machine *m_machine; |
| 328 | | }; |
| 329 | | |
| 330 | | apollo_graphics::bt458::bt458(running_machine &running_machine) |
| 331 | | { |
| 332 | 102 | m_machine = &running_machine; |
| 333 | 103 | } |
| 334 | 104 | |
| 335 | | void apollo_graphics::bt458::start() |
| 105 | void apollo_graphics_15i::bt458::start() |
| 336 | 106 | { |
| 337 | | MLOG1(("start apollo_graphics::bt458")); |
| 107 | MLOG1(("start apollo_graphics_15i::bt458")); |
| 338 | 108 | } |
| 339 | 109 | |
| 340 | | void apollo_graphics::bt458::reset() |
| 110 | void apollo_graphics_15i::bt458::reset() |
| 341 | 111 | { |
| 342 | | MLOG1(("reset apollo_graphics::bt458")); |
| 112 | MLOG1(("reset apollo_graphics_15i::bt458")); |
| 343 | 113 | |
| 344 | 114 | m_color_counter = 0; |
| 345 | 115 | m_red = 0; |
| r29303 | r29304 | |
| 354 | 124 | m_control_test_register = 0; |
| 355 | 125 | } |
| 356 | 126 | |
| 357 | | void apollo_graphics::bt458::write(UINT8 data, UINT8 c10) |
| 127 | void apollo_graphics_15i::bt458::write(UINT8 data, UINT8 c10) |
| 358 | 128 | { |
| 359 | 129 | MLOG1(("writing Bt458 data=%02x C1,C0=%d", data, c10)); |
| 360 | 130 | switch (c10) |
| r29303 | r29304 | |
| 427 | 197 | } |
| 428 | 198 | } |
| 429 | 199 | |
| 430 | | UINT8 apollo_graphics::bt458::read(UINT8 c10) |
| 200 | UINT8 apollo_graphics_15i::bt458::read(UINT8 c10) |
| 431 | 201 | { |
| 432 | 202 | UINT8 data = 0xff; |
| 433 | 203 | |
| r29303 | r29304 | |
| 498 | 268 | return data; |
| 499 | 269 | } |
| 500 | 270 | |
| 501 | | UINT32 apollo_graphics::bt458::get_rgb(UINT8 index) |
| 271 | UINT32 apollo_graphics_15i::bt458::get_rgb(UINT8 index) |
| 502 | 272 | { |
| 503 | 273 | return m_color_palette_RAM[index]; |
| 504 | 274 | } |
| 505 | 275 | |
| 506 | | /***************************************************************************** |
| 507 | | INLINE FUNCTIONS |
| 508 | | *****************************************************************************/ |
| 509 | | |
| 510 | | INLINE apollo_graphics *get_safe_token(device_t *device) |
| 511 | | { |
| 512 | | assert(device != NULL); |
| 513 | | assert(device->type() == APOLLO_GRAPHICS || device->type() == APOLLO_MONO19I ); |
| 514 | | return (apollo_graphics *) downcast<apollo_graphics_15i *> (device)->token(); |
| 515 | | } |
| 516 | | |
| 517 | | void apollo_graphics::device_start(running_machine &running_machine) |
| 518 | | { |
| 519 | | m_n_planes = 0; |
| 520 | | m_width = 0; |
| 521 | | m_height = 0; |
| 522 | | m_buffer_width = 0; |
| 523 | | m_buffer_height = 0; |
| 524 | | |
| 525 | | m_sr = 0; |
| 526 | | m_device_id = 0; |
| 527 | | m_write_enable_register = 0; |
| 528 | | m_rop_register = 0; |
| 529 | | m_diag_mem_request = 0; |
| 530 | | m_cr0 = 0; |
| 531 | | m_cr1 = 0; |
| 532 | | m_cr2 = 0; |
| 533 | | m_cr2b = 0; |
| 534 | | m_cr2_s_data = 0; |
| 535 | | m_cr2_s_plane = 0x00; |
| 536 | | m_cr2_d_plane = 0x0e; |
| 537 | | m_cr3a = 0; |
| 538 | | m_cr3b = 0; |
| 539 | | m_ad_result = 0; |
| 540 | | m_ad_pending = 0; |
| 541 | | |
| 542 | | m_lut_control = 0; |
| 543 | | m_lut_data = 0; |
| 544 | | |
| 545 | | m_update_flag = 0; |
| 546 | | m_update_pending = 0; |
| 547 | | |
| 548 | | m_blt_cycle_count = 0; |
| 549 | | m_image_offset = 0; |
| 550 | | memset(m_guard_latch, 0, sizeof(m_guard_latch)); |
| 551 | | |
| 552 | | m_h_clock = 0; |
| 553 | | m_v_clock = 0; |
| 554 | | m_p_clock = 0; |
| 555 | | m_data_clock = 0; |
| 556 | | |
| 557 | | m_image_memory = 0; |
| 558 | | m_image_plane_size = 0; |
| 559 | | m_image_memory_size = 0; |
| 560 | | |
| 561 | | memset(m_color_lookup_table, 0, sizeof(m_color_lookup_table)); |
| 562 | | |
| 563 | | m_lut_fifo = NULL; |
| 564 | | m_bt458 = NULL; |
| 565 | | |
| 566 | | m_machine = &running_machine; |
| 567 | | } |
| 568 | | |
| 569 | | void apollo_graphics::device_reset() |
| 570 | | { |
| 571 | | if (m_n_planes == 0) |
| 572 | | { |
| 573 | | if (apollo_config(APOLLO_CONF_MONO_19I)) |
| 574 | | { |
| 575 | | // monochrome 1280x1024 |
| 576 | | m_n_planes = 1; |
| 577 | | m_device_id = SCREEN_DEVICE_ID_19I; |
| 578 | | m_width = 1280; |
| 579 | | m_height = 1024; |
| 580 | | m_buffer_width = 2048; |
| 581 | | m_buffer_height = 1024; |
| 582 | | } |
| 583 | | else if (apollo_config(APOLLO_CONF_MONO_15I)) |
| 584 | | { |
| 585 | | // monochrome 1024x800 |
| 586 | | m_n_planes = 1; |
| 587 | | m_device_id = SCREEN_DEVICE_ID_15I; |
| 588 | | m_width = 1024; |
| 589 | | m_height = 800; |
| 590 | | m_buffer_width = 1024; |
| 591 | | m_buffer_height = 1024; |
| 592 | | } |
| 593 | | else if (apollo_config(APOLLO_CONF_4_PLANES)) |
| 594 | | { |
| 595 | | // 4-planes color 1024x800 |
| 596 | | m_n_planes = 4; |
| 597 | | m_device_id = SCREEN_DEVICE_ID_C4P; |
| 598 | | m_width = 1024; |
| 599 | | m_height = 800; |
| 600 | | m_buffer_width = 1024; |
| 601 | | m_buffer_height = 1024; |
| 602 | | } |
| 603 | | else |
| 604 | | { |
| 605 | | // 8-planes color 1024x800 |
| 606 | | m_n_planes = 8; |
| 607 | | m_device_id = SCREEN_DEVICE_ID_C8P; |
| 608 | | m_width = 1024; |
| 609 | | m_height = 800; |
| 610 | | m_buffer_width = 1024; |
| 611 | | m_buffer_height = 1024; |
| 612 | | |
| 613 | | m_lut_fifo = new lut_fifo(); |
| 614 | | |
| 615 | | m_bt458 = new bt458(*m_machine); |
| 616 | | m_bt458->start(); |
| 617 | | m_bt458->reset(); |
| 618 | | } |
| 619 | | } |
| 620 | | |
| 621 | | if (m_image_memory == NULL) |
| 622 | | { |
| 623 | | /* allocate the memory image */ |
| 624 | | m_image_plane_size = m_buffer_height * m_buffer_width / 16; |
| 625 | | m_image_memory_size = m_image_plane_size * m_n_planes; |
| 626 | | m_image_memory |
| 627 | | = auto_alloc_array(machine(), UINT16, m_image_memory_size); |
| 628 | | assert(m_image_memory != NULL); |
| 629 | | |
| 630 | | MLOG1(("device reset apollo graphics: buffer=%p size=%0x", m_image_memory, m_image_memory_size)); |
| 631 | | } |
| 632 | | |
| 633 | | memset(m_color_lookup_table, 0, sizeof(m_color_lookup_table)); |
| 634 | | memset(m_image_memory, 0, m_image_memory_size * 2); |
| 635 | | |
| 636 | | // register_vblank_callback(this); |
| 637 | | } |
| 638 | | |
| 639 | | void apollo_graphics::device_reset_mono19i() |
| 640 | | { |
| 641 | | if (m_n_planes == 0) |
| 642 | | { |
| 643 | | // monochrome 1280x1024 |
| 644 | | m_n_planes = 1; |
| 645 | | m_device_id = SCREEN_DEVICE_ID_19I; |
| 646 | | m_width = 1280; |
| 647 | | m_height = 1024; |
| 648 | | m_buffer_width = 2048; |
| 649 | | m_buffer_height = 1024; |
| 650 | | } |
| 651 | | |
| 652 | | device_reset(); |
| 653 | | } |
| 654 | | |
| 655 | 276 | /*************************************************************************** |
| 656 | 277 | Monochrome Controller Registers at 0x5d800 - 0x5dc07 |
| 657 | 278 | ***************************************************************************/ |
| 658 | 279 | |
| 659 | | const char *apollo_graphics::cr_text(offs_t offset, UINT8 data, UINT8 rw) |
| 280 | const char *apollo_graphics_15i::cr_text(offs_t offset, UINT8 data, UINT8 rw) |
| 660 | 281 | { |
| 661 | 282 | static const char *cr0[8] = |
| 662 | 283 | { "cr0 mode=0 CPU dest BLT", "cr0 mode=1 Alternating BLT", |
| r29303 | r29304 | |
| 708 | 329 | } |
| 709 | 330 | } |
| 710 | 331 | |
| 711 | | void apollo_graphics::log_cr1(const char * text, device_t *device) |
| 332 | void apollo_graphics_15i::log_cr1(const char * text) |
| 712 | 333 | { |
| 713 | | DLOG2(("%s: cr0=%02x cr1=%02x sr=%02x pixel_clock=%3d/%3d bl=%d vb=%d vs=%d hs=%d hc=%d vck=%d hck=%d pck=%d vd=%d", |
| 334 | MLOG2(("%s: cr0=%02x cr1=%02x sr=%02x pixel_clock=%3d/%3d bl=%d vb=%d vs=%d hs=%d hc=%d vck=%d hck=%d pck=%d vd=%d", |
| 714 | 335 | text, |
| 715 | 336 | m_cr0, |
| 716 | 337 | m_cr1, |
| r29303 | r29304 | |
| 728 | 349 | m_sr & SR_V_DATA ? 1 : 0)); |
| 729 | 350 | } |
| 730 | 351 | |
| 731 | | void apollo_graphics::increment_h_clock() |
| 352 | void apollo_graphics_15i::increment_h_clock() |
| 732 | 353 | { |
| 733 | 354 | MLOG1(("increment_h_clock: sr=%02x m_h_clock=%d", m_sr, m_h_clock)); |
| 734 | 355 | |
| r29303 | r29304 | |
| 809 | 430 | m_h_clock++; |
| 810 | 431 | } |
| 811 | 432 | |
| 812 | | void apollo_graphics::increment_v_clock() |
| 433 | void apollo_graphics_15i::increment_v_clock() |
| 813 | 434 | { |
| 814 | 435 | MLOG1(("increment_v_clock: sr=%02x m_v_clock=%d", m_sr, m_v_clock)); |
| 815 | 436 | |
| r29303 | r29304 | |
| 896 | 517 | m_data_clock = 0; |
| 897 | 518 | } |
| 898 | 519 | |
| 899 | | void apollo_graphics::increment_p_clock() |
| 520 | void apollo_graphics_15i::increment_p_clock() |
| 900 | 521 | { |
| 901 | 522 | if (m_n_planes == 1) |
| 902 | 523 | { |
| r29303 | r29304 | |
| 954 | 575 | } |
| 955 | 576 | } |
| 956 | 577 | |
| 957 | | void apollo_graphics::set_cr1(device_t *device, UINT8 data) |
| 578 | void apollo_graphics_15i::set_cr1(UINT8 data) |
| 958 | 579 | { |
| 959 | 580 | UINT8 diffs = m_cr1 ^ data; |
| 960 | 581 | m_cr1 = data; |
| r29303 | r29304 | |
| 992 | 613 | m_sr = SR_H_CK | SR_V_BLANK | SR_SYNC | SR_DONE; |
| 993 | 614 | } |
| 994 | 615 | } |
| 995 | | log_cr1("CR1_RESET", device); |
| 616 | log_cr1("CR1_RESET"); |
| 996 | 617 | } |
| 997 | 618 | else |
| 998 | 619 | { |
| 999 | 620 | if ((diffs & CR1_RESET) && (m_cr1 & CR1_RESET) != 0) |
| 1000 | 621 | { |
| 1001 | | log_cr1("CR1_RESET", device); |
| 622 | log_cr1("CR1_RESET"); |
| 1002 | 623 | } |
| 1003 | 624 | |
| 1004 | 625 | if (dh_clock) |
| 1005 | 626 | { |
| 1006 | 627 | increment_h_clock(); |
| 1007 | | log_cr1("CR1_DH_CK", device); |
| 628 | log_cr1("CR1_DH_CK"); |
| 1008 | 629 | } |
| 1009 | 630 | |
| 1010 | 631 | if (dv_clock) |
| 1011 | 632 | { |
| 1012 | 633 | increment_v_clock(); |
| 1013 | | log_cr1("CR1_DV_CK", device); |
| 634 | log_cr1("CR1_DV_CK"); |
| 1014 | 635 | } |
| 1015 | 636 | |
| 1016 | 637 | if (dp_clock) |
| 1017 | 638 | { |
| 1018 | 639 | increment_p_clock(); |
| 1019 | | log_cr1("CR1_DP_CK", device); |
| 640 | log_cr1("CR1_DP_CK"); |
| 1020 | 641 | } |
| 1021 | 642 | |
| 1022 | 643 | if ((m_sr & SR_V_BLANK) == 0) |
| r29303 | r29304 | |
| 1032 | 653 | } |
| 1033 | 654 | } |
| 1034 | 655 | |
| 1035 | | void apollo_graphics::set_cr3a(device_t *device, UINT8 data) |
| 656 | void apollo_graphics_15i::set_cr3a(UINT8 data) |
| 1036 | 657 | { |
| 1037 | 658 | m_cr3a = data; |
| 1038 | 659 | if ((data & 0x80) == 0) |
| r29303 | r29304 | |
| 1041 | 662 | UINT8 bit_mask = 1 << shift; |
| 1042 | 663 | if (data & 0x01) |
| 1043 | 664 | { |
| 1044 | | set_cr1(device, m_cr1 | bit_mask); |
| 665 | set_cr1(m_cr1 | bit_mask); |
| 1045 | 666 | } |
| 1046 | 667 | else |
| 1047 | 668 | { |
| 1048 | | set_cr1(device, m_cr1 & ~bit_mask); |
| 669 | set_cr1(m_cr1 & ~bit_mask); |
| 1049 | 670 | } |
| 1050 | 671 | } |
| 1051 | 672 | } |
| 1052 | 673 | |
| 1053 | | void apollo_graphics::set_cr3b(device_t *device, UINT8 data) |
| 674 | void apollo_graphics_15i::set_cr3b(UINT8 data) |
| 1054 | 675 | { |
| 1055 | 676 | m_cr3b = data; |
| 1056 | 677 | if ((data & 0x80) == 0) |
| r29303 | r29304 | |
| 1059 | 680 | UINT8 bit_mask = 1 << shift; |
| 1060 | 681 | if (data & 0x01) |
| 1061 | 682 | { |
| 1062 | | set_lut_cr(device, m_lut_control | bit_mask); |
| 683 | set_lut_cr(m_lut_control | bit_mask); |
| 1063 | 684 | } |
| 1064 | 685 | else |
| 1065 | 686 | { |
| 1066 | | set_lut_cr(device, m_lut_control & ~bit_mask); |
| 687 | set_lut_cr(m_lut_control & ~bit_mask); |
| 1067 | 688 | } |
| 1068 | 689 | } |
| 1069 | 690 | } |
| 1070 | 691 | |
| 1071 | | void apollo_graphics::set_lut_cr(device_t *device, UINT8 data) |
| 692 | void apollo_graphics_15i::set_lut_cr(UINT8 data) |
| 1072 | 693 | { |
| 1073 | 694 | UINT8 diffs = m_lut_control ^ data; |
| 1074 | 695 | m_lut_control = data; |
| 1075 | 696 | |
| 1076 | 697 | if ((diffs & LUT_CPAL_CS) && (data & LUT_CPAL_CS) != 0) |
| 1077 | 698 | { |
| 1078 | | DLOG1(("writing Color Graphics Controller: LUT_CPAL_CS Disabled")); |
| 699 | MLOG1(("writing Color Graphics Controller: LUT_CPAL_CS Disabled")); |
| 1079 | 700 | while (!m_lut_fifo->is_empty()) |
| 1080 | 701 | { |
| 1081 | 702 | m_bt458->write(m_lut_fifo->get(), LUT_C1_C0(m_lut_control)); |
| r29303 | r29304 | |
| 1084 | 705 | |
| 1085 | 706 | if ((diffs & LUT_FIFO_RST) && (data & LUT_FIFO_RST) == 0) |
| 1086 | 707 | { |
| 1087 | | DLOG1(("writing Color Graphics Controller: LUT_FIFO_RST Active")); |
| 708 | MLOG1(("writing Color Graphics Controller: LUT_FIFO_RST Active")); |
| 1088 | 709 | m_lut_fifo->reset(); |
| 1089 | 710 | m_sr |= SR_LUT_OK; |
| 1090 | 711 | } |
| 1091 | 712 | |
| 1092 | 713 | if ((diffs & LUT_FIFO_CS) && (data & LUT_FIFO_CS) == 0) |
| 1093 | 714 | { |
| 1094 | | DLOG1(("writing Color Graphics Controller: LUT_FIFO_CS Enabled")); |
| 715 | MLOG1(("writing Color Graphics Controller: LUT_FIFO_CS Enabled")); |
| 1095 | 716 | } |
| 1096 | 717 | |
| 1097 | 718 | if ((diffs & LUT_ST_LUK) && (data & LUT_ST_LUK) == 0) |
| 1098 | 719 | { |
| 1099 | | DLOG1(("writing Color Graphics Controller: LUT_ST_LUK Active")); |
| 720 | MLOG1(("writing Color Graphics Controller: LUT_ST_LUK Active")); |
| 1100 | 721 | m_sr &= ~SR_LUT_OK; |
| 1101 | 722 | } |
| 1102 | 723 | } |
| 1103 | 724 | |
| 1104 | | READ8_DEVICE_HANDLER( apollo_graphics::apollo_mcr_r ) |
| 725 | READ8_MEMBER( apollo_graphics_15i::apollo_mcr_r ) |
| 1105 | 726 | { |
| 1106 | 727 | UINT8 data; |
| 1107 | 728 | switch (offset & 0x407) |
| r29303 | r29304 | |
| 1140 | 761 | { |
| 1141 | 762 | if (offset == 0) |
| 1142 | 763 | status0 = data; |
| 1143 | | DLOG1(("reading Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 1))); |
| 764 | MLOG1(("reading Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 1))); |
| 1144 | 765 | } |
| 1145 | 766 | |
| 1146 | 767 | return data; |
| 1147 | 768 | } |
| 1148 | 769 | |
| 1149 | | WRITE8_DEVICE_HANDLER( apollo_graphics::apollo_mcr_w ) |
| 770 | WRITE8_MEMBER( apollo_graphics_15i::apollo_mcr_w ) |
| 1150 | 771 | { |
| 1151 | | DLOG1(("writing Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 0))); |
| 772 | MLOG1(("writing Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 0))); |
| 1152 | 773 | switch (offset & 0x407) |
| 1153 | 774 | { |
| 1154 | 775 | case 0: |
| r29303 | r29304 | |
| 1176 | 797 | m_cr0 = data; |
| 1177 | 798 | break; |
| 1178 | 799 | case 0x402: |
| 1179 | | set_cr1(device, data); |
| 800 | set_cr1(data); |
| 1180 | 801 | break; |
| 1181 | 802 | case 0x404: |
| 1182 | 803 | m_cr2 = data; |
| r29303 | r29304 | |
| 1187 | 808 | m_sr |= SR_R_M_W; |
| 1188 | 809 | break; |
| 1189 | 810 | case 0x406: |
| 1190 | | set_cr3a(device, data); |
| 811 | set_cr3a(data); |
| 1191 | 812 | break; |
| 1192 | 813 | case 0x407: // A/D Channel Register |
| 1193 | 814 | m_ad_pending = 1; |
| r29303 | r29304 | |
| 1196 | 817 | } |
| 1197 | 818 | } |
| 1198 | 819 | |
| 1199 | | void apollo_graphics::set_status_rmw() |
| 820 | void apollo_graphics_15i::set_status_rmw() |
| 1200 | 821 | { |
| 1201 | 822 | UINT8 plane, d_plane_bit; |
| 1202 | 823 | UINT32 rop_reg; |
| r29303 | r29304 | |
| 1225 | 846 | } |
| 1226 | 847 | } |
| 1227 | 848 | |
| 1228 | | UINT16 apollo_graphics::rop(UINT16 dest_data, UINT16 src_data, UINT8 plane) |
| 849 | UINT16 apollo_graphics_15i::rop(UINT16 dest_data, UINT16 src_data, UINT8 plane) |
| 1229 | 850 | { |
| 1230 | 851 | UINT16 src_data1 = src_data; |
| 1231 | 852 | if (m_cr1 & CR1_ROP_EN) |
| r29303 | r29304 | |
| 1285 | 906 | return src_data; |
| 1286 | 907 | } |
| 1287 | 908 | |
| 1288 | | void apollo_graphics::set_source_data(UINT32 offset) |
| 909 | void apollo_graphics_15i::set_source_data(UINT32 offset) |
| 1289 | 910 | { |
| 1290 | 911 | if (m_n_planes == 1 || (m_cr1 & CR1_AD_BIT)) |
| 1291 | 912 | { |
| r29303 | r29304 | |
| 1305 | 926 | } |
| 1306 | 927 | } |
| 1307 | 928 | |
| 1308 | | UINT32 apollo_graphics::get_source_data(UINT8 plane) |
| 929 | UINT32 apollo_graphics_15i::get_source_data(UINT8 plane) |
| 1309 | 930 | { |
| 1310 | 931 | UINT32 src_data; |
| 1311 | 932 | |
| r29303 | r29304 | |
| 1344 | 965 | return src_data; |
| 1345 | 966 | } |
| 1346 | 967 | |
| 1347 | | void apollo_graphics::blt(UINT32 dest_addr, UINT16 mem_mask) |
| 968 | void apollo_graphics_15i::blt(UINT32 dest_addr, UINT16 mem_mask) |
| 1348 | 969 | { |
| 1349 | 970 | UINT16 src_data, dest_data; |
| 1350 | 971 | UINT8 d_plane_bit; |
| r29303 | r29304 | |
| 1372 | 993 | Color graphics memory space at A0000 - BFFFF |
| 1373 | 994 | ***************************************************************************/ |
| 1374 | 995 | |
| 1375 | | READ16_DEVICE_HANDLER( apollo_graphics::apollo_mem_r ) |
| 996 | READ16_MEMBER( apollo_graphics_15i::apollo_mem_r ) |
| 1376 | 997 | { |
| 1377 | 998 | UINT16 data; |
| 1378 | 999 | UINT32 src_addr; |
| r29303 | r29304 | |
| 1380 | 1001 | if (offset >= m_image_memory_size) |
| 1381 | 1002 | { |
| 1382 | 1003 | // 128 kB display buffer of 15" screen seems to be shadowed from $fa0000 to $fc0000 |
| 1383 | | DLOG1(("reading Graphics Memory at invalid offset %05x", offset)); |
| 1004 | MLOG1(("reading Graphics Memory at invalid offset %05x", offset)); |
| 1384 | 1005 | offset %= m_image_memory_size; |
| 1385 | 1006 | } |
| 1386 | 1007 | |
| r29303 | r29304 | |
| 1402 | 1023 | // omit excessive logging |
| 1403 | 1024 | if ((offset & (m_image_plane_size - 1)) < 8) |
| 1404 | 1025 | { |
| 1405 | | DLOG1(("reading Graphics Memory with mode %d: src_addr %05x = %04x & %04x", CR0_MODE(m_cr0), src_addr, data, mem_mask)); |
| 1026 | MLOG1(("reading Graphics Memory with mode %d: src_addr %05x = %04x & %04x", CR0_MODE(m_cr0), src_addr, data, mem_mask)); |
| 1406 | 1027 | } |
| 1407 | 1028 | else if ((offset & (m_image_plane_size - 1)) == 8) |
| 1408 | 1029 | { |
| 1409 | | DLOG1(("...")); |
| 1030 | MLOG1(("...")); |
| 1410 | 1031 | } |
| 1411 | 1032 | return data; |
| 1412 | 1033 | } |
| 1413 | 1034 | |
| 1414 | | WRITE16_DEVICE_HANDLER( apollo_graphics::apollo_mem_w ) |
| 1035 | WRITE16_MEMBER( apollo_graphics_15i::apollo_mem_w ) |
| 1415 | 1036 | { |
| 1416 | 1037 | UINT32 dest_addr; |
| 1417 | 1038 | UINT32 src_addr; |
| r29303 | r29304 | |
| 1419 | 1040 | if (offset >= m_image_memory_size) |
| 1420 | 1041 | { |
| 1421 | 1042 | // 128 kB display buffer of 15" screen seems to be shadowed from $fa0000 to $fc0000 |
| 1422 | | DLOG1(("writing Graphics Memory at invalid offset %05x = %04x & %04x ", offset, data, mem_mask)); |
| 1043 | MLOG1(("writing Graphics Memory at invalid offset %05x = %04x & %04x ", offset, data, mem_mask)); |
| 1423 | 1044 | offset %= m_image_memory_size; |
| 1424 | 1045 | } |
| 1425 | 1046 | |
| 1426 | 1047 | // omit excessive logging |
| 1427 | 1048 | if (offset < 24) |
| 1428 | 1049 | { |
| 1429 | | DLOG1(("writing Graphics Memory with mode %d: offset=%04x data=%04x mask=%04x", CR0_MODE(m_cr0), offset, data, mem_mask)); |
| 1050 | MLOG1(("writing Graphics Memory with mode %d: offset=%04x data=%04x mask=%04x", CR0_MODE(m_cr0), offset, data, mem_mask)); |
| 1430 | 1051 | } |
| 1431 | 1052 | else if (offset == 24) |
| 1432 | 1053 | { |
| 1433 | | DLOG1(("...")); |
| 1054 | MLOG1(("...")); |
| 1434 | 1055 | } |
| 1435 | 1056 | |
| 1436 | 1057 | switch (CR0_MODE(m_cr0)) |
| r29303 | r29304 | |
| 1518 | 1139 | break; |
| 1519 | 1140 | |
| 1520 | 1141 | default: |
| 1521 | | DLOG(("writing Graphics Memory - unexpected cr0 mode %d", CR0_MODE(m_cr0))) |
| 1142 | MLOG(("writing Graphics Memory - unexpected cr0 mode %d", CR0_MODE(m_cr0))) |
| 1522 | 1143 | ; |
| 1523 | 1144 | break; |
| 1524 | 1145 | } |
| r29303 | r29304 | |
| 1529 | 1150 | Color Screen |
| 1530 | 1151 | ***************************************************************************/ |
| 1531 | 1152 | |
| 1532 | | READ8_DEVICE_HANDLER( apollo_graphics::apollo_ccr_r ) |
| 1153 | READ8_MEMBER( apollo_graphics_15i::apollo_ccr_r ) |
| 1533 | 1154 | { |
| 1534 | 1155 | UINT8 data; |
| 1535 | 1156 | |
| r29303 | r29304 | |
| 1544 | 1165 | data = m_ad_result; |
| 1545 | 1166 | break; |
| 1546 | 1167 | default: |
| 1547 | | return apollo_mcr_r(device, space, offset, mem_mask); |
| 1168 | return apollo_mcr_r(space, offset, mem_mask); |
| 1548 | 1169 | } |
| 1549 | 1170 | } |
| 1550 | 1171 | else if (m_n_planes == 8) |
| r29303 | r29304 | |
| 1569 | 1190 | } |
| 1570 | 1191 | else if ((m_lut_control & LUT_R_W) == 0) |
| 1571 | 1192 | { |
| 1572 | | DLOG1(("apollo_graphics::apollo_ccr_r: reading LUT data register with unexpected RW = 0 in LUT Control register")); |
| 1193 | MLOG1(("apollo_graphics_15i::apollo_ccr_r: reading LUT data register with unexpected RW = 0 in LUT Control register")); |
| 1573 | 1194 | data = m_lut_data; |
| 1574 | 1195 | } |
| 1575 | 1196 | else if ((m_lut_control & LUT_AD_CS) == 0) |
| r29303 | r29304 | |
| 1582 | 1203 | } |
| 1583 | 1204 | else |
| 1584 | 1205 | { |
| 1585 | | DLOG1(("apollo_graphics::apollo_ccr_r: reading LUT data register with unexpected CS in LUT Control register")); |
| 1206 | MLOG1(("apollo_graphics_15i::apollo_ccr_r: reading LUT data register with unexpected CS in LUT Control register")); |
| 1586 | 1207 | data = m_lut_data; |
| 1587 | 1208 | } |
| 1588 | 1209 | break; |
| r29303 | r29304 | |
| 1603 | 1224 | data = m_cr3b; |
| 1604 | 1225 | break; |
| 1605 | 1226 | default: |
| 1606 | | return apollo_mcr_r(device, space, offset, mem_mask); |
| 1227 | return apollo_mcr_r(space, offset, mem_mask); |
| 1607 | 1228 | } |
| 1608 | 1229 | } |
| 1609 | 1230 | else |
| r29303 | r29304 | |
| 1617 | 1238 | { |
| 1618 | 1239 | if (offset == 0) |
| 1619 | 1240 | status1 = data; |
| 1620 | | DLOG1(("reading Color Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 1))); |
| 1241 | MLOG1(("reading Color Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 1))); |
| 1621 | 1242 | } |
| 1622 | 1243 | |
| 1623 | 1244 | return data; |
| 1624 | 1245 | } |
| 1625 | 1246 | |
| 1626 | | UINT8 apollo_graphics::get_pixel(UINT32 offset, UINT16 mask) |
| 1247 | UINT8 apollo_graphics_15i::get_pixel(UINT32 offset, UINT16 mask) |
| 1627 | 1248 | { |
| 1628 | 1249 | UINT8 data = 0; |
| 1629 | 1250 | UINT16 *source_ptr = m_image_memory + offset; |
| r29303 | r29304 | |
| 1666 | 1287 | |
| 1667 | 1288 | // read the 4-plane ADC value for data |
| 1668 | 1289 | |
| 1669 | | UINT8 apollo_graphics::c4p_read_adc(UINT8 data) |
| 1290 | UINT8 apollo_graphics_15i::c4p_read_adc(UINT8 data) |
| 1670 | 1291 | { |
| 1671 | 1292 | UINT8 value = 0; |
| 1672 | 1293 | |
| r29303 | r29304 | |
| 1720 | 1341 | |
| 1721 | 1342 | // read the 8-plane ADC value for data |
| 1722 | 1343 | |
| 1723 | | UINT8 apollo_graphics::c8p_read_adc(UINT8 data) |
| 1344 | UINT8 apollo_graphics_15i::c8p_read_adc(UINT8 data) |
| 1724 | 1345 | { |
| 1725 | 1346 | UINT8 value = 0; |
| 1726 | 1347 | |
| r29303 | r29304 | |
| 1771 | 1392 | return value; |
| 1772 | 1393 | } |
| 1773 | 1394 | |
| 1774 | | WRITE8_DEVICE_HANDLER( apollo_graphics::apollo_ccr_w ) |
| 1395 | WRITE8_MEMBER( apollo_graphics_15i::apollo_ccr_w ) |
| 1775 | 1396 | { |
| 1776 | 1397 | static const UINT8 rgb_value[16] = |
| 1777 | 1398 | { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, |
| r29303 | r29304 | |
| 1812 | 1433 | m_sr |= SR_DONE; |
| 1813 | 1434 | break; |
| 1814 | 1435 | default: |
| 1815 | | apollo_mcr_w(device, space, offset, data, mem_mask); |
| 1436 | apollo_mcr_w(space, offset, data, mem_mask); |
| 1816 | 1437 | return; |
| 1817 | 1438 | } |
| 1818 | 1439 | } |
| r29303 | r29304 | |
| 1844 | 1465 | m_lut_data = data; |
| 1845 | 1466 | if ((m_lut_control & LUT_R_W) == 1) |
| 1846 | 1467 | { |
| 1847 | | DLOG1(("apollo_graphics::apollo_ccr_w: writing LUT data register with RW = 1 in LUT Control register")); |
| 1468 | MLOG1(("apollo_graphics_15i::apollo_ccr_w: writing LUT data register with RW = 1 in LUT Control register")); |
| 1848 | 1469 | } |
| 1849 | 1470 | else if ((m_lut_control & LUT_AD_CS) == 0) |
| 1850 | 1471 | { |
| r29303 | r29304 | |
| 1862 | 1483 | } |
| 1863 | 1484 | else |
| 1864 | 1485 | { |
| 1865 | | DLOG1(("apollo_graphics::apollo_ccr_w: writing LUT data register with unexpected CS in LUT Control register")); |
| 1486 | MLOG1(("apollo_graphics_15i::apollo_ccr_w: writing LUT data register with unexpected CS in LUT Control register")); |
| 1866 | 1487 | } |
| 1867 | 1488 | break; |
| 1868 | 1489 | case 0x403: |
| 1869 | 1490 | // LUT control register |
| 1870 | | set_lut_cr(device, data); |
| 1491 | set_lut_cr(data); |
| 1871 | 1492 | break; |
| 1872 | 1493 | case 0x404: |
| 1873 | 1494 | // cr2a |
| r29303 | r29304 | |
| 1883 | 1504 | break; |
| 1884 | 1505 | case 0x407: |
| 1885 | 1506 | // cr3b |
| 1886 | | set_cr3b(device, data); |
| 1507 | set_cr3b(data); |
| 1887 | 1508 | break; |
| 1888 | 1509 | default: |
| 1889 | | apollo_mcr_w(device, space, offset, data, mem_mask); |
| 1510 | apollo_mcr_w(space, offset, data, mem_mask); |
| 1890 | 1511 | return; |
| 1891 | 1512 | } |
| 1892 | 1513 | } |
| 1893 | 1514 | |
| 1894 | | DLOG1(("writing Color Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 0))); |
| 1515 | MLOG1(("writing Color Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 0))); |
| 1895 | 1516 | } |
| 1896 | 1517 | |
| 1897 | | READ16_DEVICE_HANDLER( apollo_cgm_r ) |
| 1518 | READ16_MEMBER( apollo_graphics_15i::apollo_cgm_r ) |
| 1898 | 1519 | { |
| 1899 | | apollo_graphics *apollo_graphics = get_safe_token(device); |
| 1900 | | if (!apollo_graphics->is_mono()) |
| 1520 | if (!is_mono()) |
| 1901 | 1521 | { |
| 1902 | | return apollo_graphics->apollo_mem_r(device, space, offset, mem_mask); |
| 1522 | return apollo_mem_r(space, offset, mem_mask); |
| 1903 | 1523 | } |
| 1904 | 1524 | else |
| 1905 | 1525 | { |
| r29303 | r29304 | |
| 1907 | 1527 | } |
| 1908 | 1528 | } |
| 1909 | 1529 | |
| 1910 | | WRITE16_DEVICE_HANDLER( apollo_cgm_w ) |
| 1530 | WRITE16_MEMBER( apollo_graphics_15i::apollo_cgm_w ) |
| 1911 | 1531 | { |
| 1912 | | apollo_graphics *apollo_graphics = get_safe_token(device); |
| 1913 | | if (!apollo_graphics->is_mono()) |
| 1532 | if (!is_mono()) |
| 1914 | 1533 | { |
| 1915 | | apollo_graphics->apollo_mem_w(device, space, offset, data, mem_mask); |
| 1534 | apollo_mem_w(space, offset, data, mem_mask); |
| 1916 | 1535 | } |
| 1917 | 1536 | } |
| 1918 | 1537 | |
| r29303 | r29304 | |
| 1920 | 1539 | VIDEO HARDWARE |
| 1921 | 1540 | ***************************************************************************/ |
| 1922 | 1541 | |
| 1923 | | UINT32 apollo_graphics::screen_update(bitmap_rgb32 &bitmap, |
| 1924 | | const rectangle &cliprect) |
| 1542 | UINT32 apollo_graphics_15i::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 1925 | 1543 | { |
| 1926 | 1544 | int has_changed = 0; |
| 1927 | 1545 | |
| r29303 | r29304 | |
| 1936 | 1554 | return has_changed ? 0 : UPDATE_HAS_NOT_CHANGED; |
| 1937 | 1555 | } |
| 1938 | 1556 | |
| 1939 | | void apollo_graphics::screen_update1(bitmap_rgb32 &bitmap, |
| 1940 | | const rectangle &cliprect) |
| 1557 | void apollo_graphics_15i::screen_update1(bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 1941 | 1558 | { |
| 1942 | 1559 | UINT16 *source_ptr = m_image_memory; |
| 1943 | 1560 | int x, y; |
| r29303 | r29304 | |
| 2041 | 1658 | called on each state change of the VBLANK signal |
| 2042 | 1659 | -------------------------------------------------*/ |
| 2043 | 1660 | |
| 2044 | | void apollo_graphics::vblank_state_changed(device_t *device, |
| 2045 | | screen_device &screen, bool vblank_state) |
| 1661 | void apollo_graphics_15i::vblank_state_changed(screen_device &screen, bool vblank_state) |
| 2046 | 1662 | { |
| 2047 | 1663 | if ((m_cr1 & CR1_RESET) && (m_cr1 & CR1_SYNC_EN)) |
| 2048 | 1664 | { |
| r29303 | r29304 | |
| 2077 | 1693 | } |
| 2078 | 1694 | } |
| 2079 | 1695 | |
| 2080 | | void vblank_state_changed(device_t *device, screen_device &screen, |
| 2081 | | bool vblank_state) |
| 1696 | void apollo_graphics_15i::register_vblank_callback() |
| 2082 | 1697 | { |
| 2083 | | apollo_graphics *apollo_graphics = get_safe_token(device); |
| 2084 | | apollo_graphics->vblank_state_changed(device, screen, vblank_state); |
| 2085 | | } |
| 1698 | MLOG1(("register_vblank_callback")); |
| 2086 | 1699 | |
| 2087 | | static void register_vblank_callback(device_t *device) |
| 2088 | | { |
| 2089 | | DLOG1(("register_vblank_callback")); |
| 2090 | | |
| 2091 | 1700 | /* register for VBLANK callbacks */ |
| 2092 | | screen_device *screen = (screen_device *) device->machine().device( |
| 2093 | | VIDEO_SCREEN_TAG); |
| 2094 | | screen->register_vblank_callback(vblank_state_delegate( |
| 2095 | | FUNC(vblank_state_changed),device) ); |
| 1701 | screen_device *screen = (screen_device *)machine().device(VIDEO_SCREEN_TAG); |
| 1702 | screen->register_vblank_callback(vblank_state_delegate(FUNC(apollo_graphics_15i::vblank_state_changed),this)); |
| 2096 | 1703 | } |
| 2097 | 1704 | |
| 2098 | | UINT32 apollo_graphics_15i::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 2099 | | { |
| 2100 | | apollo_graphics *apollo_graphics = get_safe_token(this); |
| 2101 | | return apollo_graphics->screen_update(bitmap, cliprect); |
| 2102 | | } |
| 2103 | 1705 | |
| 2104 | 1706 | /*************************************************************************** |
| 2105 | 1707 | MACHINE DRIVERS |
| r29303 | r29304 | |
| 2118 | 1720 | |
| 2119 | 1721 | const device_type APOLLO_GRAPHICS = &device_creator<apollo_graphics_15i> ; |
| 2120 | 1722 | |
| 2121 | | apollo_graphics_15i::apollo_graphics_15i(const machine_config &mconfig, |
| 2122 | | const char *tag, device_t *owner, UINT32 clock) : |
| 2123 | | device_t(mconfig, APOLLO_GRAPHICS, "Apollo Screen", tag, owner, clock, |
| 2124 | | "apollo_graphics_15i", __FILE__) |
| 1723 | apollo_graphics_15i::apollo_graphics_15i(const machine_config &mconfig,const char *tag, device_t *owner, UINT32 clock) : |
| 1724 | device_t(mconfig, APOLLO_GRAPHICS, "Apollo Screen", tag, owner, clock,"apollo_graphics_15i", __FILE__), |
| 1725 | m_lut_fifo(NULL), |
| 1726 | m_bt458(NULL) |
| 2125 | 1727 | { |
| 2126 | | m_token = new apollo_graphics; |
| 1728 | |
| 2127 | 1729 | } |
| 2128 | 1730 | |
| 2129 | | apollo_graphics_15i::apollo_graphics_15i(const machine_config &mconfig, |
| 2130 | | const char *tag, device_t *owner, UINT32 clock, device_type type, |
| 2131 | | const char *name, const char *shortname, const char *source) : |
| 2132 | | device_t(mconfig, type, name, tag, owner, clock, shortname, source) |
| 1731 | apollo_graphics_15i::apollo_graphics_15i(const machine_config &mconfig,const char *tag, device_t *owner, UINT32 clock, device_type type,const char *name, const char *shortname, const char *source) : |
| 1732 | device_t(mconfig, type, name, tag, owner, clock, shortname, source), |
| 1733 | m_lut_fifo(NULL), |
| 1734 | m_bt458(NULL) |
| 2133 | 1735 | { |
| 2134 | | m_token = new apollo_graphics; |
| 2135 | 1736 | } |
| 2136 | 1737 | |
| 2137 | 1738 | apollo_graphics_15i::~apollo_graphics_15i() |
| 2138 | 1739 | { |
| 2139 | | global_free(m_token); |
| 1740 | if (m_lut_fifo) global_free(m_lut_fifo); |
| 1741 | if (m_bt458) global_free(m_bt458); |
| 2140 | 1742 | } |
| 2141 | 1743 | |
| 2142 | 1744 | //------------------------------------------------- |
| r29303 | r29304 | |
| 2157 | 1759 | { |
| 2158 | 1760 | MLOG1(("apollo_graphics_15i::device_start")) |
| 2159 | 1761 | |
| 2160 | | apollo_graphics *apollo_graphics = get_safe_token(this); |
| 2161 | | apollo_graphics->device_start(machine()); |
| 1762 | m_n_planes = 0; |
| 1763 | m_width = 0; |
| 1764 | m_height = 0; |
| 1765 | m_buffer_width = 0; |
| 1766 | m_buffer_height = 0; |
| 1767 | |
| 1768 | m_sr = 0; |
| 1769 | m_device_id = 0; |
| 1770 | m_write_enable_register = 0; |
| 1771 | m_rop_register = 0; |
| 1772 | m_diag_mem_request = 0; |
| 1773 | m_cr0 = 0; |
| 1774 | m_cr1 = 0; |
| 1775 | m_cr2 = 0; |
| 1776 | m_cr2b = 0; |
| 1777 | m_cr2_s_data = 0; |
| 1778 | m_cr2_s_plane = 0x00; |
| 1779 | m_cr2_d_plane = 0x0e; |
| 1780 | m_cr3a = 0; |
| 1781 | m_cr3b = 0; |
| 1782 | m_ad_result = 0; |
| 1783 | m_ad_pending = 0; |
| 1784 | |
| 1785 | m_lut_control = 0; |
| 1786 | m_lut_data = 0; |
| 1787 | |
| 1788 | m_update_flag = 0; |
| 1789 | m_update_pending = 0; |
| 1790 | |
| 1791 | m_blt_cycle_count = 0; |
| 1792 | m_image_offset = 0; |
| 1793 | memset(m_guard_latch, 0, sizeof(m_guard_latch)); |
| 1794 | |
| 1795 | m_h_clock = 0; |
| 1796 | m_v_clock = 0; |
| 1797 | m_p_clock = 0; |
| 1798 | m_data_clock = 0; |
| 1799 | |
| 1800 | m_image_memory = 0; |
| 1801 | m_image_plane_size = 0; |
| 1802 | m_image_memory_size = 0; |
| 1803 | |
| 1804 | memset(m_color_lookup_table, 0, sizeof(m_color_lookup_table)); |
| 1805 | |
| 1806 | m_lut_fifo = NULL; |
| 1807 | m_bt458 = NULL; |
| 2162 | 1808 | } |
| 2163 | 1809 | |
| 2164 | 1810 | //------------------------------------------------- |
| r29303 | r29304 | |
| 2169 | 1815 | { |
| 2170 | 1816 | MLOG1(("apollo_graphics_15i::device_reset")); |
| 2171 | 1817 | |
| 2172 | | apollo_graphics *apollo_graphics = get_safe_token(this); |
| 2173 | | apollo_graphics->device_reset(); |
| 1818 | if (m_n_planes == 0) |
| 1819 | { |
| 1820 | if (apollo_config(APOLLO_CONF_MONO_19I)) |
| 1821 | { |
| 1822 | // monochrome 1280x1024 |
| 1823 | m_n_planes = 1; |
| 1824 | m_device_id = SCREEN_DEVICE_ID_19I; |
| 1825 | m_width = 1280; |
| 1826 | m_height = 1024; |
| 1827 | m_buffer_width = 2048; |
| 1828 | m_buffer_height = 1024; |
| 1829 | } |
| 1830 | else if (apollo_config(APOLLO_CONF_MONO_15I)) |
| 1831 | { |
| 1832 | // monochrome 1024x800 |
| 1833 | m_n_planes = 1; |
| 1834 | m_device_id = SCREEN_DEVICE_ID_15I; |
| 1835 | m_width = 1024; |
| 1836 | m_height = 800; |
| 1837 | m_buffer_width = 1024; |
| 1838 | m_buffer_height = 1024; |
| 1839 | } |
| 1840 | else if (apollo_config(APOLLO_CONF_4_PLANES)) |
| 1841 | { |
| 1842 | // 4-planes color 1024x800 |
| 1843 | m_n_planes = 4; |
| 1844 | m_device_id = SCREEN_DEVICE_ID_C4P; |
| 1845 | m_width = 1024; |
| 1846 | m_height = 800; |
| 1847 | m_buffer_width = 1024; |
| 1848 | m_buffer_height = 1024; |
| 1849 | } |
| 1850 | else |
| 1851 | { |
| 1852 | // 8-planes color 1024x800 |
| 1853 | m_n_planes = 8; |
| 1854 | m_device_id = SCREEN_DEVICE_ID_C8P; |
| 1855 | m_width = 1024; |
| 1856 | m_height = 800; |
| 1857 | m_buffer_width = 1024; |
| 1858 | m_buffer_height = 1024; |
| 2174 | 1859 | |
| 2175 | | /* FIXME: register for VBLANK callbacks */ |
| 2176 | | register_vblank_callback(this); |
| 2177 | | } |
| 1860 | if (m_lut_fifo) global_free(m_lut_fifo); |
| 1861 | if (m_bt458) global_free(m_bt458); |
| 2178 | 1862 | |
| 2179 | | READ8_DEVICE_HANDLER( apollo_ccr_r ) |
| 2180 | | { |
| 2181 | | apollo_graphics *apollo_graphics = get_safe_token(device); |
| 2182 | | return apollo_graphics->apollo_ccr_r(device, space, offset, mem_mask); |
| 2183 | | } |
| 1863 | m_lut_fifo = global_alloc(lut_fifo); |
| 2184 | 1864 | |
| 2185 | | WRITE8_DEVICE_HANDLER( apollo_ccr_w ) |
| 2186 | | { |
| 2187 | | apollo_graphics *apollo_graphics = get_safe_token(device); |
| 2188 | | apollo_graphics->apollo_ccr_w(device, space, offset, data, mem_mask); |
| 1865 | m_bt458 = global_alloc(bt458(machine())); |
| 1866 | m_bt458->start(); |
| 1867 | m_bt458->reset(); |
| 1868 | } |
| 1869 | } |
| 1870 | |
| 1871 | if (m_image_memory == NULL) |
| 1872 | { |
| 1873 | /* allocate the memory image */ |
| 1874 | m_image_plane_size = m_buffer_height * m_buffer_width / 16; |
| 1875 | m_image_memory_size = m_image_plane_size * m_n_planes; |
| 1876 | m_image_memory |
| 1877 | = auto_alloc_array(machine(), UINT16, m_image_memory_size); |
| 1878 | assert(m_image_memory != NULL); |
| 1879 | |
| 1880 | MLOG1(("device reset apollo graphics: buffer=%p size=%0x", m_image_memory, m_image_memory_size)); |
| 1881 | } |
| 1882 | |
| 1883 | memset(m_color_lookup_table, 0, sizeof(m_color_lookup_table)); |
| 1884 | memset(m_image_memory, 0, m_image_memory_size * 2); |
| 1885 | |
| 1886 | // register_vblank_callback(this); |
| 1887 | |
| 1888 | /* FIXME: register for VBLANK callbacks */ |
| 1889 | register_vblank_callback(); |
| 2189 | 1890 | } |
| 2190 | 1891 | |
| 2191 | 1892 | //------------------------------------------------- |
| r29303 | r29304 | |
| 2240 | 1941 | { |
| 2241 | 1942 | MLOG1(("apollo_graphics_19i::device_reset")); |
| 2242 | 1943 | |
| 2243 | | apollo_graphics *apollo_graphics = get_safe_token(this); |
| 2244 | | apollo_graphics->device_reset_mono19i(); |
| 1944 | if (m_n_planes == 0) |
| 1945 | { |
| 1946 | // monochrome 1280x1024 |
| 1947 | m_n_planes = 1; |
| 1948 | m_device_id = SCREEN_DEVICE_ID_19I; |
| 1949 | m_width = 1280; |
| 1950 | m_height = 1024; |
| 1951 | m_buffer_width = 2048; |
| 1952 | m_buffer_height = 1024; |
| 1953 | } |
| 2245 | 1954 | |
| 1955 | apollo_graphics_15i::device_reset(); |
| 1956 | |
| 2246 | 1957 | /* FIXME: register for VBLANK callbacks */ |
| 2247 | | register_vblank_callback(this); |
| 1958 | register_vblank_callback(); |
| 2248 | 1959 | } |
| 2249 | 1960 | |
| 2250 | | READ8_DEVICE_HANDLER( apollo_mcr_r ) |
| 2251 | | { |
| 2252 | | apollo_graphics *apollo_graphics = get_safe_token(device); |
| 2253 | | return apollo_graphics->apollo_mcr_r(device, space, offset, mem_mask); |
| 2254 | | } |
| 2255 | 1961 | |
| 2256 | | WRITE8_DEVICE_HANDLER( apollo_mcr_w ) |
| 2257 | | { |
| 2258 | | apollo_graphics *apollo_graphics = get_safe_token(device); |
| 2259 | | apollo_graphics->apollo_mcr_w(device, space, offset, data, mem_mask); |
| 2260 | | } |
| 2261 | | |
| 2262 | | READ16_DEVICE_HANDLER( apollo_mgm_r ) |
| 2263 | | { |
| 2264 | | apollo_graphics *apollo_graphics = get_safe_token(device); |
| 2265 | | if (apollo_graphics->is_mono()) |
| 1962 | READ16_MEMBER( apollo_graphics_15i::apollo_mgm_r ) |
| 1963 | { |
| 1964 | if (is_mono()) |
| 2266 | 1965 | { |
| 2267 | | return apollo_graphics->apollo_mem_r(device, space, offset, mem_mask); |
| 1966 | return apollo_mem_r(space, offset, mem_mask); |
| 2268 | 1967 | } |
| 2269 | 1968 | else |
| 2270 | 1969 | { |
| r29303 | r29304 | |
| 2272 | 1971 | } |
| 2273 | 1972 | } |
| 2274 | 1973 | |
| 2275 | | WRITE16_DEVICE_HANDLER( apollo_mgm_w ) |
| 1974 | WRITE16_MEMBER( apollo_graphics_15i::apollo_mgm_w ) |
| 2276 | 1975 | { |
| 2277 | | apollo_graphics *apollo_graphics = get_safe_token(device); |
| 2278 | | if (apollo_graphics->is_mono()) |
| 1976 | if (is_mono()) |
| 2279 | 1977 | { |
| 2280 | | apollo_graphics->apollo_mem_w(device, space, offset, data, mem_mask); |
| 1978 | apollo_mem_w(space, offset, data, mem_mask); |
| 2281 | 1979 | } |
| 2282 | 1980 | } |