src/mess/video/abc80.c
| r9582 | r9583 | |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | //------------------------------------------------- |
| 39 | | // PALETTE_INIT( abc80 ) |
| 39 | // TIMER_DEVICE_CALLBACK( blink_tick ) |
| 40 | 40 | //------------------------------------------------- |
| 41 | 41 | |
| 42 | | static PALETTE_INIT( abc80 ) |
| 42 | static TIMER_DEVICE_CALLBACK( blink_tick ) |
| 43 | 43 | { |
| 44 | | palette_set_color(machine, 0, RGB_BLACK); |
| 45 | | palette_set_color(machine, 1, RGB_WHITE); |
| 46 | | palette_set_color(machine, 2, RGB_WHITE); |
| 47 | | palette_set_color(machine, 3, RGB_BLACK); |
| 44 | abc80_state *state = timer.machine->driver_data<abc80_state>(); |
| 45 | |
| 46 | state->m_blink = !state->m_blink; |
| 48 | 47 | } |
| 49 | 48 | |
| 50 | 49 | |
| 51 | 50 | //------------------------------------------------- |
| 52 | | // TILE_GET_INFO( abc80_get_tile_info ) |
| 51 | // TIMER_DEVICE_CALLBACK( vsync_on_tick ) |
| 53 | 52 | //------------------------------------------------- |
| 54 | 53 | |
| 55 | | static TILE_GET_INFO( abc80_get_tile_info ) |
| 54 | static TIMER_DEVICE_CALLBACK( vsync_on_tick ) |
| 56 | 55 | { |
| 57 | | abc80_state *state = machine->driver_data<abc80_state>(); |
| 56 | abc80_state *state = timer.machine->driver_data<abc80_state>(); |
| 58 | 57 | |
| 59 | | int attr = state->m_video_ram[tile_index]; |
| 60 | | int code = attr & 0x7f; |
| 61 | | int color = (state->m_blink && (attr & 0x80)) ? 1 : 0; |
| 62 | | int r = (tile_index & 0x78) >> 3; |
| 63 | | int l = (tile_index & 0x380) >> 7; |
| 64 | | int row = l + ((r / 5) * 8); |
| 65 | | |
| 66 | | if (row != state->m_char_row) |
| 67 | | { |
| 68 | | state->m_char_bank = 0; |
| 69 | | state->m_char_row = row; |
| 70 | | } |
| 71 | | |
| 72 | | if (code == ABC80_MODE_TEXT) |
| 73 | | { |
| 74 | | state->m_char_bank = 0; |
| 75 | | } |
| 76 | | |
| 77 | | if (code == ABC80_MODE_GFX) |
| 78 | | { |
| 79 | | state->m_char_bank = 1; |
| 80 | | } |
| 81 | | |
| 82 | | SET_TILE_INFO(state->m_char_bank, code, color, 0); |
| 58 | cpu_set_input_line(state->m_maincpu, INPUT_LINE_NMI, ASSERT_LINE); |
| 83 | 59 | } |
| 84 | 60 | |
| 85 | 61 | |
| 86 | 62 | //------------------------------------------------- |
| 87 | | // abc80_tilemap_scan - tilemap scanning |
| 63 | // TIMER_DEVICE_CALLBACK( vsync_off_tick ) |
| 88 | 64 | //------------------------------------------------- |
| 89 | 65 | |
| 90 | | static UINT32 abc80_tilemap_scan( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows ) |
| 66 | static TIMER_DEVICE_CALLBACK( vsync_off_tick ) |
| 91 | 67 | { |
| 92 | | /* logical (col,row) -> memory offset */ |
| 93 | | return ((row & 0x07) << 7) + (row >> 3) * num_cols + col; |
| 94 | | } |
| 95 | | |
| 96 | | |
| 97 | | //------------------------------------------------- |
| 98 | | // TIMER_DEVICE_CALLBACK( blink_tick ) |
| 99 | | //------------------------------------------------- |
| 100 | | |
| 101 | | static TIMER_DEVICE_CALLBACK( blink_tick ) |
| 102 | | { |
| 103 | 68 | abc80_state *state = timer.machine->driver_data<abc80_state>(); |
| 104 | 69 | |
| 105 | | state->m_blink = !state->m_blink; |
| 70 | cpu_set_input_line(state->m_maincpu, INPUT_LINE_NMI, CLEAR_LINE); |
| 106 | 71 | } |
| 107 | 72 | |
| 108 | 73 | |
| r9582 | r9583 | |
| 112 | 77 | |
| 113 | 78 | void abc80_state::update_screen(bitmap_t *bitmap, const rectangle *cliprect) |
| 114 | 79 | { |
| 115 | | UINT16 videoram_addr; |
| 116 | | int y, sx, c = 0, r = 0; |
| 80 | int c = 0; |
| 81 | int r = 0; |
| 82 | int mode = 0; |
| 117 | 83 | |
| 118 | | for (y = 0; y < 312; y++) |
| 84 | for (int y = 0; y < 312; y++) |
| 119 | 85 | { |
| 120 | 86 | UINT8 vsync_data = m_vsync_prom[y]; |
| 121 | 87 | UINT8 l = m_line_prom[y]; |
| 122 | 88 | int dv = (vsync_data & ABC80_K2_DV) ? 1 : 0; |
| 123 | | int mode = 1; |
| 124 | 89 | |
| 125 | | if (vsync_data & ABC80_K2_FRAME_END) |
| 90 | if (!(vsync_data & ABC80_K2_FRAME_RESET)) |
| 91 | { |
| 92 | // reset F2 |
| 126 | 93 | r = 0; |
| 94 | } |
| 127 | 95 | |
| 128 | | if (vsync_data & ABC80_K2_FRAME_START) |
| 129 | | r++; |
| 130 | | |
| 131 | | for (sx = 0; sx < 64; sx++) |
| 96 | for (int sx = 0; sx < 64; sx++) |
| 132 | 97 | { |
| 133 | 98 | UINT8 hsync_data = m_hsync_prom[sx]; |
| 134 | 99 | int dh = (hsync_data & ABC80_K5_DH) ? 1 : 0; |
| 135 | | UINT8 attr_addr; |
| 136 | | UINT8 videoram_data, attr_data; |
| 137 | 100 | UINT8 data = 0; |
| 138 | | int cursor, blank, tecken, graf, versal; |
| 139 | | int bit; |
| 140 | 101 | |
| 141 | 102 | if (hsync_data & ABC80_K5_LINE_END) |
| 103 | { |
| 104 | // reset F4 |
| 142 | 105 | c = 0; |
| 143 | 106 | |
| 144 | | if (hsync_data & ABC80_K5_ROW_START) |
| 145 | | c++; |
| 107 | // reset J5 |
| 108 | mode = 0; |
| 109 | } |
| 146 | 110 | |
| 147 | 111 | /* |
| 148 | 112 | |
| r9582 | r9583 | |
| 155 | 119 | |
| 156 | 120 | */ |
| 157 | 121 | |
| 158 | | videoram_addr = ((r & 0x07) << 7) | ((((c >> 3) & 0x07) + ((r >> 3) | (r >> 1))) & 0x0f) | (c & 0x07); |
| 159 | | videoram_data = m_video_ram[videoram_addr]; |
| 160 | | attr_addr = ((dh & dv) << 7) & (data & 0x7f); |
| 161 | | attr_data = m_attr_prom[attr_addr]; |
| 122 | int a = (c >> 3) & 0x07; |
| 123 | int b = ((r >> 1) & 0x0c) | ((r >> 3) & 0x03); |
| 124 | int s = (a + b) & 0x0f; |
| 125 | UINT16 videoram_addr = ((r & 0x07) << 7) | (s << 3) | (c & 0x07); |
| 126 | UINT8 videoram_data = m_latch; |
| 127 | UINT8 attr_addr = ((dh & dv) << 7) | (videoram_data & 0x7f); |
| 128 | UINT8 attr_data = m_attr_prom[attr_addr]; |
| 162 | 129 | |
| 163 | | blank = (attr_data & ABC80_J3_BLANK) ? 1 : 0; |
| 164 | | tecken = (attr_data & ABC80_J3_TEXT) ? 1 : 0; |
| 165 | | graf = (attr_data & ABC80_J3_GRAPHICS) ? 1 : 0; |
| 166 | | versal = (attr_data & ABC80_J3_VERSAL) ? 1 : 0; |
| 167 | | cursor = (videoram_data & ABC80_CHAR_CURSOR) ? 1 : 0; |
| 130 | int blank = (attr_data & ABC80_J3_BLANK) ? 1 : 0; |
| 131 | int j = (attr_data & ABC80_J3_TEXT) ? 1 : 0; |
| 132 | int k = (attr_data & ABC80_J3_GRAPHICS) ? 1 : 0; |
| 133 | int versal = (attr_data & ABC80_J3_VERSAL) ? 1 : 0; |
| 134 | int cursor = (videoram_data & ABC80_CHAR_CURSOR) ? 1 : 0; |
| 168 | 135 | |
| 169 | | if (tecken) mode = 1; |
| 170 | | if (graf) mode = 0; |
| 136 | if (!j && k) mode = 0; |
| 137 | if (j && !k) mode = 1; |
| 138 | if (j && k) mode = !mode; |
| 171 | 139 | |
| 172 | | if (mode || versal) |
| 140 | if (mode & versal) |
| 173 | 141 | { |
| 174 | | /* text mode */ |
| 142 | // graphics mode |
| 143 | int r0 = 1, r1 = 1, r2 = 1; |
| 175 | 144 | |
| 176 | | UINT16 chargen_addr = ((videoram_data & 0x7f) * 10) + l; |
| 145 | if (l < 3) r0 = 0; else if (l < 7) r1 = 0; else r2 = 0; |
| 177 | 146 | |
| 178 | | data = m_char_rom[chargen_addr]; |
| 147 | int c0 = BIT(videoram_data, 0) | r0; |
| 148 | int c1 = BIT(videoram_data, 1) | r0; |
| 149 | int c2 = BIT(videoram_data, 2) | r1; |
| 150 | int c3 = BIT(videoram_data, 3) | r1; |
| 151 | int c4 = BIT(videoram_data, 4) | r2; |
| 152 | int c5 = BIT(videoram_data, 6) | r2; |
| 153 | |
| 154 | if (!(c0 & c2 & c4)) data |= 0xe0; |
| 155 | if (!(c1 & c3 & c5)) data |= 0x1c; |
| 179 | 156 | } |
| 180 | 157 | else |
| 181 | 158 | { |
| 182 | | /* graphics mode */ |
| 159 | // text mode |
| 160 | UINT16 chargen_addr = ((videoram_data & 0x7f) * 10) + l; |
| 183 | 161 | |
| 184 | | int c0, c1, c2, c3, c4, c5; |
| 185 | | int r0 = 1, r1 = 1, r2 = 1; |
| 186 | | |
| 187 | | switch (l) |
| 188 | | { |
| 189 | | case 0: case 1: case 2: |
| 190 | | r0 = 0; |
| 191 | | break; |
| 192 | | case 3: case 4: case 5: case 6: |
| 193 | | r1 = 0; |
| 194 | | break; |
| 195 | | case 7: case 8: case 9: |
| 196 | | r2 = 0; |
| 197 | | break; |
| 198 | | } |
| 199 | | |
| 200 | | c0 = BIT(videoram_data, 0) | r2; |
| 201 | | c1 = BIT(videoram_data, 2) | r2; |
| 202 | | c2 = BIT(videoram_data, 3) | r1; |
| 203 | | c3 = BIT(videoram_data, 4) | r1; |
| 204 | | c4 = BIT(videoram_data, 5) | r0; |
| 205 | | c5 = BIT(videoram_data, 6) | r0; |
| 206 | | |
| 207 | | if (c0 & c2 & c4) data |= 0x38; |
| 208 | | if (c1 & c3 & c5) data |= 0x07; |
| 162 | data = m_char_rom[chargen_addr]; |
| 209 | 163 | } |
| 210 | 164 | |
| 211 | | data <<= 2; |
| 212 | | |
| 213 | | /* shift out pixels */ |
| 214 | | for (bit = 0; bit < 6; bit++) |
| 165 | // shift out pixels |
| 166 | for (int bit = 0; bit < 6; bit++) |
| 215 | 167 | { |
| 216 | 168 | int color = BIT(data, 7); |
| 217 | 169 | int x = (sx * 6) + bit; |
| r9582 | r9583 | |
| 223 | 175 | |
| 224 | 176 | data <<= 1; |
| 225 | 177 | } |
| 178 | |
| 179 | m_latch = m_video_ram[videoram_addr]; |
| 180 | |
| 181 | if (hsync_data & ABC80_K5_ROW_START) |
| 182 | { |
| 183 | // clock F4 |
| 184 | c++; |
| 185 | } |
| 226 | 186 | } |
| 187 | |
| 188 | if (vsync_data & ABC80_K2_FRAME_END) |
| 189 | { |
| 190 | // clock F2 |
| 191 | r++; |
| 192 | } |
| 227 | 193 | } |
| 228 | 194 | } |
| 229 | 195 | |
| r9582 | r9583 | |
| 234 | 200 | |
| 235 | 201 | void abc80_state::video_start() |
| 236 | 202 | { |
| 237 | | /* create tx_tilemap */ |
| 238 | | m_tx_tilemap = tilemap_create(machine, abc80_get_tile_info, abc80_tilemap_scan, 6, 10, 40, 24); |
| 239 | | |
| 240 | | tilemap_set_scrolldx(m_tx_tilemap, ABC80_HDSTART, ABC80_HDSTART); |
| 241 | | tilemap_set_scrolldy(m_tx_tilemap, ABC80_VDSTART, ABC80_VDSTART); |
| 242 | | |
| 243 | | /* find memory regions */ |
| 203 | // find memory regions |
| 244 | 204 | m_char_rom = memory_region(machine, "chargen"); |
| 245 | 205 | m_hsync_prom = memory_region(machine, "hsync"); |
| 246 | 206 | m_vsync_prom = memory_region(machine, "vsync"); |
| 247 | 207 | m_line_prom = memory_region(machine, "line"); |
| 248 | 208 | m_attr_prom = memory_region(machine, "attr"); |
| 249 | 209 | |
| 250 | | /* register for state saving */ |
| 210 | // register for state saving |
| 251 | 211 | state_save_register_global(machine, m_blink); |
| 252 | | state_save_register_global(machine, m_char_bank); |
| 253 | | state_save_register_global(machine, m_char_row); |
| 212 | state_save_register_global(machine, m_latch); |
| 254 | 213 | } |
| 255 | 214 | |
| 256 | 215 | |
| r9582 | r9583 | |
| 260 | 219 | |
| 261 | 220 | bool abc80_state::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect) |
| 262 | 221 | { |
| 263 | | rectangle rect; |
| 222 | update_screen(&bitmap, &cliprect); |
| 264 | 223 | |
| 265 | | rect.min_x = ABC80_HDSTART; |
| 266 | | rect.max_x = ABC80_HDSTART + 40 * 6 - 1; |
| 267 | | rect.min_y = ABC80_VDSTART; |
| 268 | | rect.max_y = ABC80_VDSTART + 240 - 1; |
| 269 | | |
| 270 | | bitmap_fill(&bitmap, &cliprect, get_black_pen(machine)); |
| 271 | | |
| 272 | | tilemap_mark_all_tiles_dirty(m_tx_tilemap); |
| 273 | | tilemap_draw(&bitmap, &rect, m_tx_tilemap, 0, 0); |
| 274 | | |
| 275 | | //abc80_update(screen->machine, bitmap, cliprect); |
| 276 | | |
| 277 | 224 | return 0; |
| 278 | 225 | } |
| 279 | 226 | |
| r9582 | r9583 | |
| 284 | 231 | |
| 285 | 232 | MACHINE_CONFIG_FRAGMENT( abc80_video ) |
| 286 | 233 | MDRV_TIMER_ADD_PERIODIC("blink", blink_tick, HZ(ABC80_XTAL/2/6/64/312/16)) |
| 234 | MDRV_TIMER_ADD_SCANLINE("vsync_on", vsync_on_tick, SCREEN_TAG, 0, ABC80_VTOTAL) |
| 235 | MDRV_TIMER_ADD_SCANLINE("vsync_off", vsync_off_tick, SCREEN_TAG, 16, ABC80_VTOTAL) |
| 287 | 236 | |
| 288 | 237 | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER) |
| 289 | 238 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 290 | 239 | |
| 291 | 240 | MDRV_GFXDECODE(abc80) |
| 292 | 241 | |
| 293 | | MDRV_PALETTE_LENGTH(4) |
| 294 | | MDRV_PALETTE_INIT(abc80) |
| 242 | MDRV_PALETTE_LENGTH(2) |
| 243 | MDRV_PALETTE_INIT(black_and_white) |
| 295 | 244 | |
| 296 | 245 | MDRV_SCREEN_RAW_PARAMS(ABC80_XTAL/2, ABC80_HTOTAL, ABC80_HBEND, ABC80_HBSTART, ABC80_VTOTAL, ABC80_VBEND, ABC80_VBSTART) |
| 297 | 246 | MACHINE_CONFIG_END |