trunk/src/mess/video/k1ge.c
| r22773 | r22774 | |
| 10 | 10 | #include "emu.h" |
| 11 | 11 | #include "k1ge.h" |
| 12 | 12 | |
| 13 | | struct k1ge_t |
| 14 | | { |
| 15 | | const k1ge_interface *intf; |
| 16 | | screen_device *screen; |
| 17 | | devcb_resolved_write8 vblank_pin_w; |
| 18 | | devcb_resolved_write8 hblank_pin_w; |
| 19 | | UINT8 *vram; |
| 20 | | UINT8 wba_h, wba_v, wsi_h, wsi_v; |
| 21 | 13 | |
| 22 | | void (*draw)( device_t *device, int line ); |
| 23 | | |
| 24 | | emu_timer *timer; |
| 25 | | emu_timer *hblank_on_timer; |
| 26 | | bitmap_ind16 *bitmap; |
| 27 | | }; |
| 28 | | |
| 29 | | |
| 30 | 14 | PALETTE_INIT( k1ge ) |
| 31 | 15 | { |
| 32 | 16 | int i; |
| r22773 | r22774 | |
| 57 | 41 | } |
| 58 | 42 | |
| 59 | 43 | |
| 60 | | INLINE k1ge_t *get_safe_token( device_t *device ) |
| 44 | READ8_MEMBER( k1ge_device::read ) |
| 61 | 45 | { |
| 62 | | assert( device != NULL ); |
| 63 | | assert( device->type() == K1GE || device->type() == K2GE ); |
| 46 | UINT8 data = m_vram[offset & 0x7ff]; |
| 64 | 47 | |
| 65 | | return ( k1ge_t *) downcast<k1ge_device *>(device)->token(); |
| 66 | | } |
| 67 | | |
| 68 | | |
| 69 | | READ8_DEVICE_HANDLER( k1ge_r ) |
| 70 | | { |
| 71 | | k1ge_t *k1ge = get_safe_token( device ); |
| 72 | | UINT8 data = k1ge->vram[offset & 0x7ff]; |
| 73 | | |
| 74 | 48 | switch( offset ) |
| 75 | 49 | { |
| 76 | 50 | case 0x008: /* RAS.H */ |
| 77 | | data = k1ge->screen->hpos() >> 2; |
| 51 | data = m_screen->hpos() >> 2; |
| 78 | 52 | break; |
| 79 | 53 | case 0x009: /* RAS.V */ |
| 80 | | data = k1ge->screen->vpos(); |
| 54 | data = m_screen->vpos(); |
| 81 | 55 | break; |
| 82 | 56 | } |
| 83 | 57 | return data; |
| 84 | 58 | } |
| 85 | 59 | |
| 86 | 60 | |
| 87 | | WRITE8_DEVICE_HANDLER( k1ge_w ) |
| 61 | WRITE8_MEMBER( k1ge_device::write ) |
| 88 | 62 | { |
| 89 | | k1ge_t *k1ge = get_safe_token( device ); |
| 90 | | |
| 91 | 63 | switch( offset ) |
| 92 | 64 | { |
| 93 | 65 | case 0x000: |
| 94 | | if (!k1ge->vblank_pin_w.isnull()) |
| 95 | | k1ge->vblank_pin_w(0, ( data & 0x80 ) ? ( ( k1ge->vram[0x010] & 0x40 ) ? 1 : 0 ) : 0 ); |
| 66 | m_vblank_pin_w( ( data & 0x80 ) ? ( ( m_vram[0x010] & 0x40 ) ? 1 : 0 ) : 0 ); |
| 96 | 67 | break; |
| 97 | 68 | case 0x030: |
| 98 | 69 | data &= 0x80; |
| r22773 | r22774 | |
| 106 | 77 | data &= 0x07; |
| 107 | 78 | break; |
| 108 | 79 | case 0x7e2: |
| 109 | | if ( k1ge->vram[0x7f0] != 0xAA ) |
| 80 | if ( m_vram[0x7f0] != 0xAA ) |
| 110 | 81 | return; |
| 111 | 82 | data &= 0x80; |
| 112 | 83 | break; |
| r22773 | r22774 | |
| 118 | 89 | data &= 0x0f; |
| 119 | 90 | } |
| 120 | 91 | |
| 121 | | k1ge->vram[offset & 0x7ff] = data; |
| 92 | m_vram[offset & 0x7ff] = data; |
| 122 | 93 | } |
| 123 | 94 | |
| 124 | 95 | |
| 125 | | INLINE void k1ge_draw_scroll_plane( k1ge_t *k1ge, UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, int pal_base ) |
| 96 | void k1ge_device::draw_scroll_plane( UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, int pal_base ) |
| 126 | 97 | { |
| 127 | 98 | int i; |
| 128 | 99 | int offset_x = ( scroll_x >> 3 ) * 2; |
| r22773 | r22774 | |
| 136 | 107 | base += ( ( ( ( scroll_y + line ) >> 3 ) * 0x0040 ) & 0x7ff ); |
| 137 | 108 | |
| 138 | 109 | /* setup */ |
| 139 | | map_data = k1ge->vram[ base + offset_x ] | ( k1ge->vram[ base + offset_x + 1 ] << 8 ); |
| 110 | map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); |
| 140 | 111 | hflip = map_data & 0x8000; |
| 141 | 112 | pcode = pal_base + ( ( map_data & 0x2000 ) ? 4 : 0 ); |
| 142 | 113 | tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); |
| r22773 | r22774 | |
| 144 | 115 | tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; |
| 145 | 116 | else |
| 146 | 117 | tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; |
| 147 | | tile_data = k1ge->vram[ tile_addr ] | ( k1ge->vram[ tile_addr + 1 ] << 8 ); |
| 118 | tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); |
| 148 | 119 | if ( hflip ) |
| 149 | 120 | tile_data >>= 2 * ( scroll_x & 0x07 ); |
| 150 | 121 | else |
| r22773 | r22774 | |
| 168 | 139 | |
| 169 | 140 | if ( col ) |
| 170 | 141 | { |
| 171 | | p[ i ] = k1ge->vram[ pcode + col ]; |
| 142 | p[ i ] = m_vram[ pcode + col ]; |
| 172 | 143 | } |
| 173 | 144 | |
| 174 | 145 | px++; |
| 175 | 146 | if ( px >= 8 ) |
| 176 | 147 | { |
| 177 | 148 | offset_x = ( offset_x + 2 ) & 0x3f; |
| 178 | | map_data = k1ge->vram[ base + offset_x ] | ( k1ge->vram[ base + offset_x + 1 ] << 8 ); |
| 149 | map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); |
| 179 | 150 | hflip = map_data & 0x8000; |
| 180 | 151 | pcode = pal_base + ( ( map_data & 0x2000 ) ? 4 : 0 ); |
| 181 | 152 | tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); |
| r22773 | r22774 | |
| 183 | 154 | tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; |
| 184 | 155 | else |
| 185 | 156 | tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; |
| 186 | | tile_data = k1ge->vram[ tile_addr ] | ( k1ge->vram[ tile_addr + 1 ] << 8 ); |
| 157 | tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); |
| 187 | 158 | px = 0; |
| 188 | 159 | } |
| 189 | 160 | } |
| 190 | 161 | } |
| 191 | 162 | |
| 192 | 163 | |
| 193 | | INLINE void k1ge_draw_sprite_plane( k1ge_t *k1ge, UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ) |
| 164 | void k1ge_device::draw_sprite_plane( UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ) |
| 194 | 165 | { |
| 195 | 166 | struct { |
| 196 | 167 | UINT16 spr_data; |
| r22773 | r22774 | |
| 207 | 178 | /* Select sprites */ |
| 208 | 179 | for ( i = 0; i < 256; i += 4 ) |
| 209 | 180 | { |
| 210 | | UINT16 spr_data = k1ge->vram[ 0x800 + i ] | ( k1ge->vram[ 0x801 + i ] << 8 ); |
| 211 | | UINT8 x = k1ge->vram[ 0x802 + i ]; |
| 212 | | UINT8 y = k1ge->vram[ 0x803 + i ]; |
| 181 | UINT16 spr_data = m_vram[ 0x800 + i ] | ( m_vram[ 0x801 + i ] << 8 ); |
| 182 | UINT8 x = m_vram[ 0x802 + i ]; |
| 183 | UINT8 y = m_vram[ 0x803 + i ]; |
| 213 | 184 | |
| 214 | 185 | spr_x = ( spr_data & 0x0400 ) ? ( spr_x + x ) : ( scroll_x + x ); |
| 215 | 186 | spr_y = ( spr_data & 0x0200 ) ? ( spr_y + y ) : ( scroll_y + y ); |
| r22773 | r22774 | |
| 239 | 210 | tile_addr += ( 7 - ( ( line - spr[i].y ) & 0x07 ) ) * 2; |
| 240 | 211 | else |
| 241 | 212 | tile_addr += ( ( line - spr[i].y ) & 0x07 ) * 2; |
| 242 | | tile_data = k1ge->vram[ tile_addr ] | ( k1ge->vram[ tile_addr + 1 ] << 8 ); |
| 213 | tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); |
| 243 | 214 | |
| 244 | 215 | for ( j = 0; j < 8; j++ ) |
| 245 | 216 | { |
| r22773 | r22774 | |
| 260 | 231 | |
| 261 | 232 | if ( spr_x < 160 && col ) |
| 262 | 233 | { |
| 263 | | p[ spr_x ] = k1ge->vram[ pcode + col ]; |
| 234 | p[ spr_x ] = m_vram[ pcode + col ]; |
| 264 | 235 | } |
| 265 | 236 | } |
| 266 | 237 | } |
| 267 | 238 | } |
| 268 | 239 | |
| 269 | 240 | |
| 270 | | static void k1ge_draw( device_t *device, int line ) |
| 241 | void k1ge_device::draw( int line ) |
| 271 | 242 | { |
| 272 | | k1ge_t *k1ge = get_safe_token( device ); |
| 273 | | UINT16 *p = &k1ge->bitmap->pix16(line); |
| 274 | | UINT16 oowcol = k1ge->vram[0x012] & 0x07; |
| 243 | UINT16 *p = &m_bitmap->pix16(line); |
| 244 | UINT16 oowcol = m_vram[0x012] & 0x07; |
| 275 | 245 | int i; |
| 276 | 246 | |
| 277 | | if ( line < k1ge->wba_v || line >= k1ge->wba_v + k1ge->wsi_v ) |
| 247 | if ( line < m_wba_v || line >= m_wba_v + m_wsi_v ) |
| 278 | 248 | { |
| 279 | 249 | for( i = 0; i < 160; i++ ) |
| 280 | 250 | { |
| r22773 | r22774 | |
| 283 | 253 | } |
| 284 | 254 | else |
| 285 | 255 | { |
| 286 | | UINT16 col = ( ( k1ge->vram[0x118] & 0xc0 ) == 0x80 ) ? k1ge->vram[0x118] & 0x07 : 0; |
| 256 | UINT16 col = ( ( m_vram[0x118] & 0xc0 ) == 0x80 ) ? m_vram[0x118] & 0x07 : 0; |
| 287 | 257 | |
| 288 | 258 | for ( i = 0; i < 160; i++ ) |
| 289 | 259 | p[i] = col; |
| 290 | 260 | |
| 291 | | if ( k1ge->vram[0x030] & 0x80 ) |
| 261 | if ( m_vram[0x030] & 0x80 ) |
| 292 | 262 | { |
| 293 | 263 | /* Draw sprites with 01 priority */ |
| 294 | | k1ge_draw_sprite_plane( k1ge, p, 1, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 264 | draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); |
| 295 | 265 | |
| 296 | 266 | /* Draw PF1 */ |
| 297 | | k1ge_draw_scroll_plane( k1ge, p, 0x1000, line, k1ge->vram[0x032], k1ge->vram[0x033], 0x108 ); |
| 267 | draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x108 ); |
| 298 | 268 | |
| 299 | 269 | /* Draw sprites with 10 priority */ |
| 300 | | k1ge_draw_sprite_plane( k1ge, p, 2, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 270 | draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); |
| 301 | 271 | |
| 302 | 272 | /* Draw PF2 */ |
| 303 | | k1ge_draw_scroll_plane( k1ge, p, 0x1800, line, k1ge->vram[0x034], k1ge->vram[0x035], 0x110 ); |
| 273 | draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x110 ); |
| 304 | 274 | |
| 305 | 275 | /* Draw sprites with 11 priority */ |
| 306 | | k1ge_draw_sprite_plane( k1ge, p, 3, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 276 | draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); |
| 307 | 277 | } |
| 308 | 278 | else |
| 309 | 279 | { |
| 310 | 280 | /* Draw sprites with 01 priority */ |
| 311 | | k1ge_draw_sprite_plane( k1ge, p, 1, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 281 | draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); |
| 312 | 282 | |
| 313 | 283 | /* Draw PF2 */ |
| 314 | | k1ge_draw_scroll_plane( k1ge, p, 0x1800, line, k1ge->vram[0x034], k1ge->vram[0x035], 0x110 ); |
| 284 | draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x110 ); |
| 315 | 285 | |
| 316 | 286 | /* Draw sprites with 10 priority */ |
| 317 | | k1ge_draw_sprite_plane( k1ge, p, 2, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 287 | draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); |
| 318 | 288 | |
| 319 | 289 | /* Draw PF1 */ |
| 320 | | k1ge_draw_scroll_plane( k1ge, p, 0x1000, line, k1ge->vram[0x032], k1ge->vram[0x033], 0x108 ); |
| 290 | draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x108 ); |
| 321 | 291 | |
| 322 | 292 | /* Draw sprites with 11 priority */ |
| 323 | | k1ge_draw_sprite_plane( k1ge, p, 3, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 293 | draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); |
| 324 | 294 | } |
| 325 | 295 | |
| 326 | | for( i = 0; i < k1ge->wba_h; i++ ) |
| 296 | for( i = 0; i < m_wba_h; i++ ) |
| 327 | 297 | { |
| 328 | 298 | p[i] = oowcol; |
| 329 | 299 | } |
| 330 | 300 | |
| 331 | | for( i = k1ge->wba_h + k1ge->wsi_h; i < 160; i++ ) |
| 301 | for( i = m_wba_h + m_wsi_h; i < 160; i++ ) |
| 332 | 302 | { |
| 333 | 303 | p[i] = oowcol; |
| 334 | 304 | } |
| r22773 | r22774 | |
| 336 | 306 | } |
| 337 | 307 | |
| 338 | 308 | |
| 339 | | INLINE void k2ge_draw_scroll_plane( k1ge_t *k1ge, UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, UINT16 pal_base ) |
| 309 | void k2ge_device::draw_scroll_plane( UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, UINT16 pal_base ) |
| 340 | 310 | { |
| 341 | 311 | int i; |
| 342 | 312 | int offset_x = ( scroll_x >> 3 ) * 2; |
| r22773 | r22774 | |
| 350 | 320 | base += ( ( ( ( scroll_y + line ) >> 3 ) * 0x0040 ) & 0x7ff ); |
| 351 | 321 | |
| 352 | 322 | /* setup */ |
| 353 | | map_data = k1ge->vram[ base + offset_x ] | ( k1ge->vram[ base + offset_x + 1 ] << 8 ); |
| 323 | map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); |
| 354 | 324 | hflip = map_data & 0x8000; |
| 355 | 325 | pcode = pal_base + ( ( map_data & 0x1e00 ) >> 6 ); |
| 356 | 326 | tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); |
| r22773 | r22774 | |
| 358 | 328 | tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; |
| 359 | 329 | else |
| 360 | 330 | tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; |
| 361 | | tile_data = k1ge->vram[ tile_addr ] | ( k1ge->vram[ tile_addr + 1 ] << 8 ); |
| 331 | tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); |
| 362 | 332 | if ( hflip ) |
| 363 | 333 | tile_data >>= 2 * ( scroll_x & 0x07 ); |
| 364 | 334 | else |
| r22773 | r22774 | |
| 382 | 352 | |
| 383 | 353 | if ( col ) |
| 384 | 354 | { |
| 385 | | p[ i ] = k1ge->vram[ pcode + col * 2 ] | ( k1ge->vram[ pcode + col * 2 + 1 ] << 8 ); |
| 355 | p[ i ] = m_vram[ pcode + col * 2 ] | ( m_vram[ pcode + col * 2 + 1 ] << 8 ); |
| 386 | 356 | } |
| 387 | 357 | |
| 388 | 358 | px++; |
| 389 | 359 | if ( px >= 8 ) |
| 390 | 360 | { |
| 391 | 361 | offset_x = ( offset_x + 2 ) & 0x3f; |
| 392 | | map_data = k1ge->vram[ base + offset_x ] | ( k1ge->vram[ base + offset_x + 1 ] << 8 ); |
| 362 | map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); |
| 393 | 363 | hflip = map_data & 0x8000; |
| 394 | 364 | pcode = pal_base + ( ( map_data & 0x1e00 ) >> 6 ); |
| 395 | 365 | tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); |
| r22773 | r22774 | |
| 397 | 367 | tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; |
| 398 | 368 | else |
| 399 | 369 | tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; |
| 400 | | tile_data = k1ge->vram[ tile_addr ] | ( k1ge->vram[ tile_addr + 1 ] << 8 ); |
| 370 | tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); |
| 401 | 371 | px = 0; |
| 402 | 372 | } |
| 403 | 373 | } |
| 404 | 374 | } |
| 405 | 375 | |
| 406 | 376 | |
| 407 | | INLINE void k2ge_draw_sprite_plane( k1ge_t *k1ge, UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ) |
| 377 | void k2ge_device::draw_sprite_plane( UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ) |
| 408 | 378 | { |
| 409 | 379 | struct { |
| 410 | 380 | UINT16 spr_data; |
| r22773 | r22774 | |
| 422 | 392 | /* Select sprites */ |
| 423 | 393 | for ( i = 0; i < 256; i += 4 ) |
| 424 | 394 | { |
| 425 | | UINT16 spr_data = k1ge->vram[ 0x800 + i ] | ( k1ge->vram[ 0x801 + i ] << 8 ); |
| 426 | | UINT8 x = k1ge->vram[ 0x802 + i ]; |
| 427 | | UINT8 y = k1ge->vram[ 0x803 + i ]; |
| 395 | UINT16 spr_data = m_vram[ 0x800 + i ] | ( m_vram[ 0x801 + i ] << 8 ); |
| 396 | UINT8 x = m_vram[ 0x802 + i ]; |
| 397 | UINT8 y = m_vram[ 0x803 + i ]; |
| 428 | 398 | |
| 429 | 399 | spr_x = ( spr_data & 0x0400 ) ? ( spr_x + x ) : ( scroll_x + x ); |
| 430 | 400 | spr_y = ( spr_data & 0x0200 ) ? ( spr_y + y ) : ( scroll_y + y ); |
| r22773 | r22774 | |
| 448 | 418 | int j; |
| 449 | 419 | UINT16 tile_addr; |
| 450 | 420 | UINT16 tile_data; |
| 451 | | UINT16 pcode = 0x0200 + ( ( k1ge->vram[0x0c00 + spr[i].index ] & 0x0f ) << 3 ); |
| 421 | UINT16 pcode = 0x0200 + ( ( m_vram[0x0c00 + spr[i].index ] & 0x0f ) << 3 ); |
| 452 | 422 | |
| 453 | 423 | tile_addr = 0x2000 + ( ( spr[i].spr_data & 0x1ff ) * 16 ); |
| 454 | 424 | if ( spr[i].spr_data & 0x4000 ) |
| 455 | 425 | tile_addr += ( 7 - ( ( line - spr[i].y ) & 0x07 ) ) * 2; |
| 456 | 426 | else |
| 457 | 427 | tile_addr += ( ( line - spr[i].y ) & 0x07 ) * 2; |
| 458 | | tile_data = k1ge->vram[ tile_addr ] | ( k1ge->vram[ tile_addr + 1 ] << 8 ); |
| 428 | tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); |
| 459 | 429 | |
| 460 | 430 | for ( j = 0; j < 8; j++ ) |
| 461 | 431 | { |
| r22773 | r22774 | |
| 476 | 446 | |
| 477 | 447 | if ( spr_x < 160 && col ) |
| 478 | 448 | { |
| 479 | | p[ spr_x ] = k1ge->vram[ pcode + col * 2 ] | ( k1ge->vram[ pcode + col * 2 + 1 ] << 8 ); |
| 449 | p[ spr_x ] = m_vram[ pcode + col * 2 ] | ( m_vram[ pcode + col * 2 + 1 ] << 8 ); |
| 480 | 450 | } |
| 481 | 451 | } |
| 482 | 452 | } |
| 483 | 453 | } |
| 484 | 454 | |
| 485 | 455 | |
| 486 | | INLINE void k2ge_k1ge_draw_scroll_plane( k1ge_t *k1ge, UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, UINT16 pal_lut_base, UINT16 k2ge_lut_base ) |
| 456 | void k2ge_device::k1ge_draw_scroll_plane( UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, UINT16 pal_lut_base, UINT16 k2ge_lut_base ) |
| 487 | 457 | { |
| 488 | 458 | int i; |
| 489 | 459 | int offset_x = ( scroll_x >> 3 ) * 2; |
| r22773 | r22774 | |
| 497 | 467 | base += ( ( ( ( scroll_y + line ) >> 3 ) * 0x0040 ) & 0x7ff ); |
| 498 | 468 | |
| 499 | 469 | /* setup */ |
| 500 | | map_data = k1ge->vram[ base + offset_x ] | ( k1ge->vram[ base + offset_x + 1 ] << 8 ); |
| 470 | map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); |
| 501 | 471 | hflip = map_data & 0x8000; |
| 502 | 472 | pcode = ( map_data & 0x2000 ) ? 1 : 0; |
| 503 | 473 | tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); |
| r22773 | r22774 | |
| 505 | 475 | tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; |
| 506 | 476 | else |
| 507 | 477 | tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; |
| 508 | | tile_data = k1ge->vram[ tile_addr ] | ( k1ge->vram[ tile_addr + 1 ] << 8 ); |
| 478 | tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); |
| 509 | 479 | if ( hflip ) |
| 510 | 480 | tile_data >>= 2 * ( scroll_x & 0x07 ); |
| 511 | 481 | else |
| r22773 | r22774 | |
| 529 | 499 | |
| 530 | 500 | if ( col ) |
| 531 | 501 | { |
| 532 | | UINT16 col2 = 16 * pcode + ( k1ge->vram[ pal_lut_base + 4 * pcode + col ] * 2 ); |
| 533 | | p[ i ] = k1ge->vram[ k2ge_lut_base + col2 ] | ( k1ge->vram[ k2ge_lut_base + col2 + 1 ] << 8 ); |
| 502 | UINT16 col2 = 16 * pcode + ( m_vram[ pal_lut_base + 4 * pcode + col ] * 2 ); |
| 503 | p[ i ] = m_vram[ k2ge_lut_base + col2 ] | ( m_vram[ k2ge_lut_base + col2 + 1 ] << 8 ); |
| 534 | 504 | } |
| 535 | 505 | |
| 536 | 506 | px++; |
| 537 | 507 | if ( px >= 8 ) |
| 538 | 508 | { |
| 539 | 509 | offset_x = ( offset_x + 2 ) & 0x3f; |
| 540 | | map_data = k1ge->vram[ base + offset_x ] | ( k1ge->vram[ base + offset_x + 1 ] << 8 ); |
| 510 | map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); |
| 541 | 511 | hflip = map_data & 0x8000; |
| 542 | 512 | pcode = ( map_data & 0x2000 ) ? 1 : 0; |
| 543 | 513 | tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); |
| r22773 | r22774 | |
| 545 | 515 | tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; |
| 546 | 516 | else |
| 547 | 517 | tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; |
| 548 | | tile_data = k1ge->vram[ tile_addr ] | ( k1ge->vram[ tile_addr + 1 ] << 8 ); |
| 518 | tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); |
| 549 | 519 | px = 0; |
| 550 | 520 | } |
| 551 | 521 | } |
| 552 | 522 | } |
| 553 | 523 | |
| 554 | 524 | |
| 555 | | INLINE void k2ge_k1ge_draw_sprite_plane( k1ge_t *k1ge, UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ) |
| 525 | void k2ge_device::k1ge_draw_sprite_plane( UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ) |
| 556 | 526 | { |
| 557 | 527 | struct { |
| 558 | 528 | UINT16 spr_data; |
| r22773 | r22774 | |
| 569 | 539 | /* Select sprites */ |
| 570 | 540 | for ( i = 0; i < 256; i += 4 ) |
| 571 | 541 | { |
| 572 | | UINT16 spr_data = k1ge->vram[ 0x800 + i ] | ( k1ge->vram[ 0x801 + i ] << 8 ); |
| 573 | | UINT8 x = k1ge->vram[ 0x802 + i ]; |
| 574 | | UINT8 y = k1ge->vram[ 0x803 + i ]; |
| 542 | UINT16 spr_data = m_vram[ 0x800 + i ] | ( m_vram[ 0x801 + i ] << 8 ); |
| 543 | UINT8 x = m_vram[ 0x802 + i ]; |
| 544 | UINT8 y = m_vram[ 0x803 + i ]; |
| 575 | 545 | |
| 576 | 546 | spr_x = ( spr_data & 0x0400 ) ? ( spr_x + x ) : ( scroll_x + x ); |
| 577 | 547 | spr_y = ( spr_data & 0x0200 ) ? ( spr_y + y ) : ( scroll_y + y ); |
| r22773 | r22774 | |
| 601 | 571 | tile_addr += ( 7 - ( ( line - spr[i].y ) & 0x07 ) ) * 2; |
| 602 | 572 | else |
| 603 | 573 | tile_addr += ( ( line - spr[i].y ) & 0x07 ) * 2; |
| 604 | | tile_data = k1ge->vram[ tile_addr ] | ( k1ge->vram[ tile_addr + 1 ] << 8 ); |
| 574 | tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); |
| 605 | 575 | |
| 606 | 576 | for ( j = 0; j < 8; j++ ) |
| 607 | 577 | { |
| r22773 | r22774 | |
| 622 | 592 | |
| 623 | 593 | if ( spr_x < 160 && col ) |
| 624 | 594 | { |
| 625 | | UINT16 col2 = 16 * pcode + k1ge->vram[ 0x100 + 4 * pcode + col ] * 2; |
| 626 | | p[ spr_x ] = k1ge->vram[ 0x380 + col2 ] | ( k1ge->vram[ 0x381 + col2 ] << 8 ); |
| 595 | UINT16 col2 = 16 * pcode + m_vram[ 0x100 + 4 * pcode + col ] * 2; |
| 596 | p[ spr_x ] = m_vram[ 0x380 + col2 ] | ( m_vram[ 0x381 + col2 ] << 8 ); |
| 627 | 597 | } |
| 628 | 598 | } |
| 629 | 599 | } |
| 630 | 600 | } |
| 631 | 601 | |
| 632 | 602 | |
| 633 | | static void k2ge_draw( device_t *device, int line ) |
| 603 | void k2ge_device::draw( int line ) |
| 634 | 604 | { |
| 635 | | k1ge_t *k1ge = get_safe_token( device ); |
| 636 | | UINT16 *p = &k1ge->bitmap->pix16(line); |
| 605 | UINT16 *p = &m_bitmap->pix16(line); |
| 637 | 606 | UINT16 col = 0; |
| 638 | 607 | UINT16 oowcol; |
| 639 | 608 | int i; |
| 640 | 609 | |
| 641 | | oowcol = ( k1ge->vram[0x012] & 0x07 ) * 2; |
| 642 | | oowcol = k1ge->vram[0x3f0 + oowcol ] | ( k1ge->vram[0x3f1 + oowcol ] << 8 ); |
| 610 | oowcol = ( m_vram[0x012] & 0x07 ) * 2; |
| 611 | oowcol = m_vram[0x3f0 + oowcol ] | ( m_vram[0x3f1 + oowcol ] << 8 ); |
| 643 | 612 | |
| 644 | | if ( line < k1ge->wba_v || line >= k1ge->wba_v + k1ge->wsi_v ) |
| 613 | if ( line < m_wba_v || line >= m_wba_v + m_wsi_v ) |
| 645 | 614 | { |
| 646 | 615 | for( i = 0; i < 160; i++ ) |
| 647 | 616 | { |
| r22773 | r22774 | |
| 651 | 620 | else |
| 652 | 621 | { |
| 653 | 622 | /* Determine the background color */ |
| 654 | | if ( ( k1ge->vram[0x118] & 0xc0 ) == 0x80 ) |
| 623 | if ( ( m_vram[0x118] & 0xc0 ) == 0x80 ) |
| 655 | 624 | { |
| 656 | | col = ( k1ge->vram[0x118] & 0x07 ) * 2; |
| 625 | col = ( m_vram[0x118] & 0x07 ) * 2; |
| 657 | 626 | } |
| 658 | | col = k1ge->vram[0x3e0 + col ] | ( k1ge->vram[0x3e1 + col ] << 8 ); |
| 627 | col = m_vram[0x3e0 + col ] | ( m_vram[0x3e1 + col ] << 8 ); |
| 659 | 628 | |
| 660 | 629 | /* Set the bacground color */ |
| 661 | 630 | for ( i = 0; i < 160; i++ ) |
| r22773 | r22774 | |
| 663 | 632 | p[i] = col; |
| 664 | 633 | } |
| 665 | 634 | |
| 666 | | if ( k1ge->vram[0x7e2] & 0x80 ) |
| 635 | if ( m_vram[0x7e2] & 0x80 ) |
| 667 | 636 | { |
| 668 | 637 | /* K1GE compatibility mode */ |
| 669 | | if ( k1ge->vram[0x030] & 0x80 ) |
| 638 | if ( m_vram[0x030] & 0x80 ) |
| 670 | 639 | { |
| 671 | 640 | /* Draw sprites with 01 priority */ |
| 672 | | k2ge_k1ge_draw_sprite_plane( k1ge, p, 1, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 641 | k1ge_draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); |
| 673 | 642 | |
| 674 | 643 | /* Draw PF1 */ |
| 675 | | k2ge_k1ge_draw_scroll_plane( k1ge, p, 0x1000, line, k1ge->vram[0x032], k1ge->vram[0x033], 0x108, 0x3a0 ); |
| 644 | k1ge_draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x108, 0x3a0 ); |
| 676 | 645 | |
| 677 | 646 | /* Draw sprites with 10 priority */ |
| 678 | | k2ge_k1ge_draw_sprite_plane( k1ge, p, 2, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 647 | k1ge_draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); |
| 679 | 648 | |
| 680 | 649 | /* Draw PF2 */ |
| 681 | | k2ge_k1ge_draw_scroll_plane( k1ge, p, 0x1800, line, k1ge->vram[0x034], k1ge->vram[0x035], 0x110, 0x3c0 ); |
| 650 | k1ge_draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x110, 0x3c0 ); |
| 682 | 651 | |
| 683 | 652 | /* Draw sprites with 11 priority */ |
| 684 | | k2ge_k1ge_draw_sprite_plane( k1ge, p, 3, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 653 | k1ge_draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); |
| 685 | 654 | } |
| 686 | 655 | else |
| 687 | 656 | { |
| 688 | 657 | /* Draw sprites with 01 priority */ |
| 689 | | k2ge_k1ge_draw_sprite_plane( k1ge, p, 1, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 658 | k1ge_draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); |
| 690 | 659 | |
| 691 | 660 | /* Draw PF2 */ |
| 692 | | k2ge_k1ge_draw_scroll_plane( k1ge, p, 0x1800, line, k1ge->vram[0x034], k1ge->vram[0x035], 0x110, 0x3c0 ); |
| 661 | k1ge_draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x110, 0x3c0 ); |
| 693 | 662 | |
| 694 | 663 | /* Draw sprites with 10 priority */ |
| 695 | | k2ge_k1ge_draw_sprite_plane( k1ge, p, 2, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 664 | k1ge_draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); |
| 696 | 665 | |
| 697 | 666 | /* Draw PF1 */ |
| 698 | | k2ge_k1ge_draw_scroll_plane( k1ge, p, 0x1000, line, k1ge->vram[0x032], k1ge->vram[0x033], 0x108, 0x3a0 ); |
| 667 | k1ge_draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x108, 0x3a0 ); |
| 699 | 668 | |
| 700 | 669 | /* Draw sprites with 11 priority */ |
| 701 | | k2ge_k1ge_draw_sprite_plane( k1ge, p, 3, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 670 | k1ge_draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); |
| 702 | 671 | } |
| 703 | 672 | } |
| 704 | 673 | else |
| 705 | 674 | { |
| 706 | 675 | /* K2GE mode */ |
| 707 | | if ( k1ge->vram[0x030] & 0x80 ) |
| 676 | if ( m_vram[0x030] & 0x80 ) |
| 708 | 677 | { |
| 709 | 678 | /* Draw sprites with 01 priority */ |
| 710 | | k2ge_draw_sprite_plane( k1ge, p, 1, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 679 | draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); |
| 711 | 680 | |
| 712 | 681 | /* Draw PF1 */ |
| 713 | | k2ge_draw_scroll_plane( k1ge, p, 0x1000, line, k1ge->vram[0x032], k1ge->vram[0x033], 0x280 ); |
| 682 | draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x280 ); |
| 714 | 683 | |
| 715 | 684 | /* Draw sprites with 10 priority */ |
| 716 | | k2ge_draw_sprite_plane( k1ge, p, 2, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 685 | draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); |
| 717 | 686 | |
| 718 | 687 | /* Draw PF2 */ |
| 719 | | k2ge_draw_scroll_plane( k1ge, p, 0x1800, line, k1ge->vram[0x034], k1ge->vram[0x035], 0x300 ); |
| 688 | draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x300 ); |
| 720 | 689 | |
| 721 | 690 | /* Draw sprites with 11 priority */ |
| 722 | | k2ge_draw_sprite_plane( k1ge, p, 3, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 691 | draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); |
| 723 | 692 | } |
| 724 | 693 | else |
| 725 | 694 | { |
| 726 | 695 | /* Draw sprites with 01 priority */ |
| 727 | | k2ge_draw_sprite_plane( k1ge, p, 1, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 696 | draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); |
| 728 | 697 | |
| 729 | 698 | /* Draw PF2 */ |
| 730 | | k2ge_draw_scroll_plane( k1ge, p, 0x1800, line, k1ge->vram[0x034], k1ge->vram[0x035], 0x300 ); |
| 699 | draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x300 ); |
| 731 | 700 | |
| 732 | 701 | /* Draw sprites with 10 priority */ |
| 733 | | k2ge_draw_sprite_plane( k1ge, p, 2, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 702 | draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); |
| 734 | 703 | |
| 735 | 704 | /* Draw PF1 */ |
| 736 | | k2ge_draw_scroll_plane( k1ge, p, 0x1000, line, k1ge->vram[0x032], k1ge->vram[0x033], 0x280 ); |
| 705 | draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x280 ); |
| 737 | 706 | |
| 738 | 707 | /* Draw sprites with 11 priority */ |
| 739 | | k2ge_draw_sprite_plane( k1ge, p, 3, line, k1ge->vram[0x020], k1ge->vram[0x021] ); |
| 708 | draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); |
| 740 | 709 | } |
| 741 | 710 | } |
| 742 | 711 | |
| 743 | | for ( i = 0; i < k1ge->wba_h; i++ ) |
| 712 | for ( i = 0; i < m_wba_h; i++ ) |
| 744 | 713 | { |
| 745 | 714 | p[i] = oowcol; |
| 746 | 715 | } |
| 747 | 716 | |
| 748 | | for ( i = k1ge->wba_h + k1ge->wsi_h; i < 160; i++ ) |
| 717 | for ( i = m_wba_h + m_wsi_h; i < 160; i++ ) |
| 749 | 718 | { |
| 750 | 719 | p[i] = oowcol; |
| 751 | 720 | } |
| r22773 | r22774 | |
| 753 | 722 | } |
| 754 | 723 | |
| 755 | 724 | |
| 756 | | static TIMER_CALLBACK( k1ge_hblank_on_timer_callback ) |
| 725 | TIMER_CALLBACK_MEMBER( k1ge_device::hblank_on_timer_callback ) |
| 757 | 726 | { |
| 758 | | device_t *device = (device_t *)ptr; |
| 759 | | k1ge_t *k1ge = get_safe_token( device ); |
| 760 | | |
| 761 | | if (!k1ge->hblank_pin_w.isnull()) |
| 762 | | k1ge->hblank_pin_w(0, 0); |
| 727 | m_hblank_pin_w(0); |
| 763 | 728 | } |
| 764 | 729 | |
| 765 | 730 | |
| 766 | | static TIMER_CALLBACK( k1ge_timer_callback ) |
| 731 | TIMER_CALLBACK_MEMBER( k1ge_device::timer_callback ) |
| 767 | 732 | { |
| 768 | | device_t *device = (device_t *)ptr; |
| 769 | | k1ge_t *k1ge = get_safe_token( device ); |
| 770 | | int y = k1ge->screen->vpos(); |
| 733 | int y = m_screen->vpos(); |
| 771 | 734 | |
| 772 | 735 | /* Check for start of VBlank */ |
| 773 | 736 | if ( y >= 152 ) |
| 774 | 737 | { |
| 775 | | k1ge->vram[0x010] |= 0x40; |
| 776 | | if ((k1ge->vram[0x000] & 0x80 ) && !k1ge->vblank_pin_w.isnull()) |
| 777 | | k1ge->vblank_pin_w(0, 1); |
| 738 | m_vram[0x010] |= 0x40; |
| 739 | if (m_vram[0x000] & 0x80) |
| 740 | { |
| 741 | m_vblank_pin_w(1); |
| 742 | } |
| 778 | 743 | } |
| 779 | 744 | |
| 780 | 745 | /* Check for end of VBlank */ |
| 781 | 746 | if ( y == 0 ) |
| 782 | 747 | { |
| 783 | | k1ge->wba_h = k1ge->vram[0x002]; |
| 784 | | k1ge->wba_v = k1ge->vram[0x003]; |
| 785 | | k1ge->wsi_h = k1ge->vram[0x004]; |
| 786 | | k1ge->wsi_v = k1ge->vram[0x005]; |
| 787 | | k1ge->vram[0x010] &= ~ 0x40; |
| 788 | | if ((k1ge->vram[0x000] & 0x80 ) && !k1ge->vblank_pin_w.isnull()) |
| 789 | | k1ge->vblank_pin_w(0, 0); |
| 748 | m_wba_h = m_vram[0x002]; |
| 749 | m_wba_v = m_vram[0x003]; |
| 750 | m_wsi_h = m_vram[0x004]; |
| 751 | m_wsi_v = m_vram[0x005]; |
| 752 | m_vram[0x010] &= ~ 0x40; |
| 753 | if (m_vram[0x000] & 0x80) |
| 754 | { |
| 755 | m_vblank_pin_w(0); |
| 756 | } |
| 790 | 757 | } |
| 791 | 758 | |
| 792 | 759 | /* Check if Hint should be triggered */ |
| 793 | 760 | if ( y == K1GE_SCREEN_HEIGHT - 1 || y < 151 ) |
| 794 | 761 | { |
| 795 | | if (!k1ge->hblank_pin_w.isnull()) |
| 762 | if (!m_hblank_pin_w.isnull()) |
| 796 | 763 | { |
| 797 | | if ( k1ge->vram[0x000] & 0x40 ) |
| 798 | | k1ge->hblank_pin_w(0, 1); |
| 799 | | k1ge->hblank_on_timer->adjust( k1ge->screen->time_until_pos(y, 480 ) ); |
| 764 | if (m_vram[0x000] & 0x40) |
| 765 | { |
| 766 | m_hblank_pin_w(1); |
| 767 | } |
| 768 | m_hblank_on_timer->adjust( m_screen->time_until_pos(y, 480 ) ); |
| 800 | 769 | } |
| 801 | 770 | } |
| 802 | 771 | |
| 803 | 772 | /* Draw a line when inside visible area */ |
| 804 | 773 | if ( y && y < 153 ) |
| 805 | 774 | { |
| 806 | | k1ge->draw( device, y - 1 ); |
| 775 | draw( y - 1 ); |
| 807 | 776 | } |
| 808 | 777 | |
| 809 | | k1ge->timer->adjust( k1ge->screen->time_until_pos(( y + 1 ) % K1GE_SCREEN_HEIGHT, 0 ) ); |
| 778 | m_timer->adjust( m_screen->time_until_pos(( y + 1 ) % K1GE_SCREEN_HEIGHT, 0 ) ); |
| 810 | 779 | } |
| 811 | 780 | |
| 812 | 781 | |
| 813 | | void k1ge_update( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 782 | void k1ge_device::update( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 814 | 783 | { |
| 815 | | k1ge_t *k1ge = get_safe_token( device ); |
| 816 | | |
| 817 | | copybitmap( bitmap, *k1ge->bitmap, 0, 0, 0, 0, cliprect ); |
| 784 | copybitmap( bitmap, *m_bitmap, 0, 0, 0, 0, cliprect ); |
| 818 | 785 | } |
| 819 | 786 | |
| 820 | 787 | |
| 821 | | static DEVICE_START( k1ge ) |
| 822 | | { |
| 823 | | k1ge_t *k1ge = get_safe_token( device ); |
| 788 | //------------------------------------------------- |
| 789 | // device_start - device-specific startup |
| 790 | //------------------------------------------------- |
| 824 | 791 | |
| 825 | | k1ge->intf = (const k1ge_interface*)device->static_config(); |
| 826 | | |
| 827 | | k1ge->vblank_pin_w.resolve(k1ge->intf->vblank_pin_w, *device); |
| 828 | | k1ge->hblank_pin_w.resolve(k1ge->intf->hblank_pin_w, *device); |
| 829 | | |
| 830 | | k1ge->timer = device->machine().scheduler().timer_alloc(FUNC(k1ge_timer_callback), (void *) device ); |
| 831 | | k1ge->hblank_on_timer = device->machine().scheduler().timer_alloc(FUNC(k1ge_hblank_on_timer_callback), (void *) device ); |
| 832 | | k1ge->screen = device->machine().device<screen_device>(k1ge->intf->screen_tag); |
| 833 | | k1ge->vram = device->machine().root_device().memregion( k1ge->intf->vram_tag )->base(); |
| 834 | | k1ge->bitmap = auto_bitmap_ind16_alloc( device->machine(), k1ge->screen->width(), k1ge->screen->height() ); |
| 835 | | k1ge->draw = k1ge_draw; |
| 836 | | } |
| 837 | | |
| 838 | | |
| 839 | | static DEVICE_START( k2ge ) |
| 792 | void k1ge_device::device_start() |
| 840 | 793 | { |
| 841 | | k1ge_t *k1ge = get_safe_token( device ); |
| 794 | m_vblank_pin_w.resolve(); |
| 795 | m_hblank_pin_w.resolve(); |
| 842 | 796 | |
| 843 | | DEVICE_START_CALL( k1ge ); |
| 844 | | k1ge->draw = k2ge_draw; |
| 797 | m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(k1ge_device::timer_callback), this)); |
| 798 | m_hblank_on_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(k1ge_device::hblank_on_timer_callback), this)); |
| 799 | m_screen = machine().device<screen_device>(m_screen_tag); |
| 800 | m_vram = machine().root_device().memregion( m_vram_tag )->base(); |
| 801 | m_bitmap = auto_bitmap_ind16_alloc( machine(), m_screen->width(), m_screen->height() ); |
| 845 | 802 | } |
| 846 | 803 | |
| 847 | 804 | |
| 848 | | static DEVICE_RESET( k1ge ) |
| 805 | //------------------------------------------------- |
| 806 | // device_reset - device-specific reset |
| 807 | //------------------------------------------------- |
| 808 | |
| 809 | void k1ge_device::device_reset() |
| 849 | 810 | { |
| 850 | | k1ge_t *k1ge = get_safe_token( device ); |
| 811 | m_vram[0x000] = 0x00; /* Interrupt enable */ |
| 812 | m_vram[0x002] = 0x00; /* WBA.H */ |
| 813 | m_vram[0x003] = 0x00; /* WVA.V */ |
| 814 | m_vram[0x004] = 0xFF; /* WSI.H */ |
| 815 | m_vram[0x005] = 0xFF; /* WSI.V */ |
| 816 | m_vram[0x007] = 0xc6; /* REF */ |
| 817 | m_vram[0x012] = 0x00; /* 2D control */ |
| 818 | m_vram[0x020] = 0x00; /* PO.H */ |
| 819 | m_vram[0x021] = 0x00; /* PO.V */ |
| 820 | m_vram[0x030] = 0x00; /* PF */ |
| 821 | m_vram[0x032] = 0x00; /* S1SO.H */ |
| 822 | m_vram[0x033] = 0x00; /* S1SO.V */ |
| 823 | m_vram[0x034] = 0x00; /* S2SO.H */ |
| 824 | m_vram[0x035] = 0x00; /* S2SO.V */ |
| 825 | m_vram[0x101] = 0x07; /* SPPLT01 */ |
| 826 | m_vram[0x102] = 0x07; /* SPPLT02 */ |
| 827 | m_vram[0x103] = 0x07; /* SPPLT03 */ |
| 828 | m_vram[0x105] = 0x07; /* SPPLT11 */ |
| 829 | m_vram[0x106] = 0x07; /* SPPLT12 */ |
| 830 | m_vram[0x107] = 0x07; /* SPPLT13 */ |
| 831 | m_vram[0x109] = 0x07; /* SC1PLT01 */ |
| 832 | m_vram[0x10a] = 0x07; /* SC1PLT02 */ |
| 833 | m_vram[0x10b] = 0x07; /* SC1PLT03 */ |
| 834 | m_vram[0x10d] = 0x07; /* SC1PLT11 */ |
| 835 | m_vram[0x10e] = 0x07; /* SC1PLT12 */ |
| 836 | m_vram[0x10f] = 0x07; /* SC1PLT13 */ |
| 837 | m_vram[0x111] = 0x07; /* SC2PLT01 */ |
| 838 | m_vram[0x112] = 0x07; /* SC2PLT02 */ |
| 839 | m_vram[0x113] = 0x07; /* SC2PLT03 */ |
| 840 | m_vram[0x115] = 0x07; /* SC2PLT11 */ |
| 841 | m_vram[0x116] = 0x07; /* SC2PLT12 */ |
| 842 | m_vram[0x117] = 0x07; /* SC2PLT13 */ |
| 843 | m_vram[0x118] = 0x07; /* BG */ |
| 844 | m_vram[0x400] = 0xFF; /* LED control */ |
| 845 | m_vram[0x402] = 0x80; /* LEDFREG */ |
| 846 | m_vram[0x7e0] = 0x52; /* RESET */ |
| 847 | m_vram[0x7e2] = 0x00; /* MODE */ |
| 851 | 848 | |
| 852 | | k1ge->vram[0x000] = 0x00; /* Interrupt enable */ |
| 853 | | k1ge->vram[0x002] = 0x00; /* WBA.H */ |
| 854 | | k1ge->vram[0x003] = 0x00; /* WVA.V */ |
| 855 | | k1ge->vram[0x004] = 0xFF; /* WSI.H */ |
| 856 | | k1ge->vram[0x005] = 0xFF; /* WSI.V */ |
| 857 | | k1ge->vram[0x007] = 0xc6; /* REF */ |
| 858 | | k1ge->vram[0x012] = 0x00; /* 2D control */ |
| 859 | | k1ge->vram[0x020] = 0x00; /* PO.H */ |
| 860 | | k1ge->vram[0x021] = 0x00; /* PO.V */ |
| 861 | | k1ge->vram[0x030] = 0x00; /* PF */ |
| 862 | | k1ge->vram[0x032] = 0x00; /* S1SO.H */ |
| 863 | | k1ge->vram[0x033] = 0x00; /* S1SO.V */ |
| 864 | | k1ge->vram[0x034] = 0x00; /* S2SO.H */ |
| 865 | | k1ge->vram[0x035] = 0x00; /* S2SO.V */ |
| 866 | | k1ge->vram[0x101] = 0x07; /* SPPLT01 */ |
| 867 | | k1ge->vram[0x102] = 0x07; /* SPPLT02 */ |
| 868 | | k1ge->vram[0x103] = 0x07; /* SPPLT03 */ |
| 869 | | k1ge->vram[0x105] = 0x07; /* SPPLT11 */ |
| 870 | | k1ge->vram[0x106] = 0x07; /* SPPLT12 */ |
| 871 | | k1ge->vram[0x107] = 0x07; /* SPPLT13 */ |
| 872 | | k1ge->vram[0x109] = 0x07; /* SC1PLT01 */ |
| 873 | | k1ge->vram[0x10a] = 0x07; /* SC1PLT02 */ |
| 874 | | k1ge->vram[0x10b] = 0x07; /* SC1PLT03 */ |
| 875 | | k1ge->vram[0x10d] = 0x07; /* SC1PLT11 */ |
| 876 | | k1ge->vram[0x10e] = 0x07; /* SC1PLT12 */ |
| 877 | | k1ge->vram[0x10f] = 0x07; /* SC1PLT13 */ |
| 878 | | k1ge->vram[0x111] = 0x07; /* SC2PLT01 */ |
| 879 | | k1ge->vram[0x112] = 0x07; /* SC2PLT02 */ |
| 880 | | k1ge->vram[0x113] = 0x07; /* SC2PLT03 */ |
| 881 | | k1ge->vram[0x115] = 0x07; /* SC2PLT11 */ |
| 882 | | k1ge->vram[0x116] = 0x07; /* SC2PLT12 */ |
| 883 | | k1ge->vram[0x117] = 0x07; /* SC2PLT13 */ |
| 884 | | k1ge->vram[0x118] = 0x07; /* BG */ |
| 885 | | k1ge->vram[0x400] = 0xFF; /* LED control */ |
| 886 | | k1ge->vram[0x402] = 0x80; /* LEDFREG */ |
| 887 | | k1ge->vram[0x7e0] = 0x52; /* RESET */ |
| 888 | | k1ge->vram[0x7e2] = 0x00; /* MODE */ |
| 889 | | |
| 890 | | k1ge->timer->adjust( k1ge->screen->time_until_pos(( k1ge->screen->vpos() + 1 ) % K1GE_SCREEN_HEIGHT, 0 ) ); |
| 849 | m_timer->adjust( m_screen->time_until_pos(( m_screen->vpos() + 1 ) % K1GE_SCREEN_HEIGHT, 0 ) ); |
| 891 | 850 | } |
| 892 | 851 | |
| 893 | 852 | |
| r22773 | r22774 | |
| 895 | 854 | |
| 896 | 855 | k1ge_device::k1ge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 897 | 856 | : device_t(mconfig, K1GE, "K1GE Monochrome Graphics + LCD", tag, owner, clock) |
| 857 | , m_vblank_pin_w(*this) |
| 858 | , m_hblank_pin_w(*this) |
| 898 | 859 | { |
| 899 | | m_token = global_alloc_clear(k1ge_t); |
| 900 | 860 | } |
| 901 | 861 | |
| 902 | 862 | k1ge_device::k1ge_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) |
| 903 | 863 | : device_t(mconfig, type, name, tag, owner, clock) |
| 864 | , m_vblank_pin_w(*this) |
| 865 | , m_hblank_pin_w(*this) |
| 904 | 866 | { |
| 905 | | m_token = global_alloc_clear(k1ge_t); |
| 906 | 867 | } |
| 907 | 868 | |
| 908 | | //------------------------------------------------- |
| 909 | | // device_config_complete - perform any |
| 910 | | // operations now that the configuration is |
| 911 | | // complete |
| 912 | | //------------------------------------------------- |
| 913 | 869 | |
| 914 | | void k1ge_device::device_config_complete() |
| 915 | | { |
| 916 | | } |
| 917 | | |
| 918 | | //------------------------------------------------- |
| 919 | | // device_start - device-specific startup |
| 920 | | //------------------------------------------------- |
| 921 | | |
| 922 | | void k1ge_device::device_start() |
| 923 | | { |
| 924 | | DEVICE_START_NAME( k1ge )(this); |
| 925 | | } |
| 926 | | |
| 927 | | //------------------------------------------------- |
| 928 | | // device_reset - device-specific reset |
| 929 | | //------------------------------------------------- |
| 930 | | |
| 931 | | void k1ge_device::device_reset() |
| 932 | | { |
| 933 | | DEVICE_RESET_NAME( k1ge )(this); |
| 934 | | } |
| 935 | | |
| 936 | | |
| 937 | 870 | const device_type K2GE = &device_creator<k2ge_device>; |
| 938 | 871 | |
| 939 | 872 | k2ge_device::k2ge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| r22773 | r22774 | |
| 941 | 874 | { |
| 942 | 875 | } |
| 943 | 876 | |
| 944 | | //------------------------------------------------- |
| 945 | | // device_start - device-specific startup |
| 946 | | //------------------------------------------------- |
| 947 | | |
| 948 | | void k2ge_device::device_start() |
| 949 | | { |
| 950 | | DEVICE_START_NAME( k2ge )(this); |
| 951 | | } |