src/mess/machine/gb.c
| r5695 | r5696 | |
| 175 | 175 | { |
| 176 | 176 | memory_set_bankptr( machine, 5, addr ); |
| 177 | 177 | memory_set_bankptr( machine, 10, addr + 0x0100 ); |
| 178 | memory_set_bankptr( machine, 6, addr + 0x0150 ); |
| 179 | memory_set_bankptr( machine, 11, addr + 0x0400 ); |
| 178 | 180 | } |
| 179 | 181 | |
| 180 | 182 | static void gb_rom16_4000( running_machine *machine, UINT8 *addr ) |
| r5695 | r5696 | |
| 301 | 303 | |
| 302 | 304 | gb_video_init( machine, GB_VIDEO_DMG ); |
| 303 | 305 | |
| 306 | gb_rom16_0000( machine, ROMMap[ROMBank00] ); |
| 307 | |
| 304 | 308 | /* Enable BIOS rom */ |
| 305 | 309 | memory_set_bankptr(machine, 5, memory_region(machine, "maincpu") ); |
| 306 | | memory_set_bankptr(machine, 10, ROMMap[ROMBank00] + 0x0100 ); |
| 307 | 310 | |
| 308 | 311 | gb_timer.divcount = 0x0004; |
| 309 | 312 | } |
| r5695 | r5696 | |
| 316 | 319 | |
| 317 | 320 | gb_init_regs(machine); |
| 318 | 321 | |
| 319 | | memory_set_bankptr(machine, 5, ROMMap[ROMBank00] ? ROMMap[ROMBank00] : gb_dummy_rom_bank ); |
| 320 | | memory_set_bankptr(machine, 10, ROMMap[ROMBank00] ? ROMMap[ROMBank00] + 0x0100 : gb_dummy_rom_bank + 0x0100 ); |
| 322 | gb_rom16_0000( machine, ROMMap[ROMBank00] ? ROMMap[ROMBank00] : gb_dummy_rom_bank ); |
| 321 | 323 | |
| 322 | 324 | sgb_tile_data = auto_alloc_array_clear(machine, UINT8, 0x2000 ); |
| 323 | 325 | memset( sgb_tile_data, 0, 0x2000 ); |
| r5695 | r5696 | |
| 360 | 362 | gb_sound_w(devtag_get_device(machine, "custom"), 0x14,0x77); |
| 361 | 363 | |
| 362 | 364 | /* Enable BIOS rom if we have one */ |
| 363 | | memory_set_bankptr(machine, 5, ROMMap[ROMBank00] ? ROMMap[ROMBank00] : gb_dummy_rom_bank ); |
| 364 | | memory_set_bankptr(machine, 10, ROMMap[ROMBank00] ? ROMMap[ROMBank00] + 0x0100 : gb_dummy_rom_bank + 0x0100); |
| 365 | gb_rom16_0000( machine, ROMMap[ROMBank00] ? ROMMap[ROMBank00] : gb_dummy_rom_bank ); |
| 365 | 366 | |
| 366 | 367 | gb_timer.divcount = 0xABC8; |
| 367 | 368 | } |
| r5695 | r5696 | |
| 381 | 382 | gb_sound_w(devtag_get_device(machine, "custom"), 0x15, 0xF3); |
| 382 | 383 | gb_sound_w(devtag_get_device(machine, "custom"), 0x14, 0x77); |
| 383 | 384 | |
| 384 | | memory_set_bankptr(machine, 5, ROMMap[ROMBank00] ? ROMMap[ROMBank00] : gb_dummy_rom_bank ); |
| 385 | | memory_set_bankptr(machine, 10, ROMMap[ROMBank00] ? ROMMap[ROMBank00] + 0x0100 : gb_dummy_rom_bank + 0x0100); |
| 385 | gb_rom16_0000( machine, ROMMap[ROMBank00] ? ROMMap[ROMBank00] : gb_dummy_rom_bank ); |
| 386 | 386 | |
| 387 | /* Enable BIOS rom */ |
| 388 | memory_set_bankptr(machine, 5, memory_region(machine, "maincpu") ); |
| 389 | memory_set_bankptr(machine, 6, memory_region(machine, "maincpu") + 0x100 ); |
| 390 | |
| 387 | 391 | /* Allocate memory for internal ram */ |
| 388 | 392 | for( ii = 0; ii < 8; ii++ ) |
| 389 | 393 | { |
| r5695 | r5696 | |
| 890 | 894 | if ( offset == 0x10 ) |
| 891 | 895 | { |
| 892 | 896 | /* disable BIOS ROM */ |
| 893 | | memory_set_bankptr(space->machine, 5, ROMMap[ROMBank00]); |
| 897 | gb_rom16_0000( space->machine, ROMMap[ROMBank00] ); |
| 894 | 898 | } |
| 895 | 899 | else |
| 896 | 900 | { |
| r5695 | r5696 | |
| 1986 | 1990 | case 0x0D: /* KEY1 - Prepare speed switch */ |
| 1987 | 1991 | cpu_set_reg( cputag_get_cpu(space->machine, "maincpu"), LR35902_SPEED, data ); |
| 1988 | 1992 | return; |
| 1993 | case 0x10: /* BFF - Bios disable */ |
| 1994 | gb_rom16_0000( space->machine, ROMMap[ROMBank00] ); |
| 1995 | return; |
| 1989 | 1996 | case 0x16: /* RP - Infrared port */ |
| 1990 | 1997 | break; |
| 1991 | 1998 | case 0x30: /* SVBK - RAM bank select */ |
src/mess/drivers/gb.c
| r5695 | r5696 | |
| 445 | 445 | /* Initial value of the cpu registers (hacks until we get bios dumps) */ |
| 446 | 446 | static const UINT16 sgb_cpu_regs[6] = { 0x01B0, 0x0013, 0x00D8, 0x014D, 0xFFFE, 0x0100 }; /* Super Game Boy */ |
| 447 | 447 | static const UINT16 mgb_cpu_regs[6] = { 0xFFB0, 0x0013, 0x00D8, 0x014D, 0xFFFE, 0x0100 }; /* Game Boy Pocket / Super Game Boy 2 */ |
| 448 | | static const UINT16 cgb_cpu_regs[6] = { 0x11B0, 0x0013, 0x00D8, 0x014D, 0xFFFE, 0x0100 }; /* Game Boy Color / Game Boy Advance */ |
| 448 | //static const UINT16 cgb_cpu_regs[6] = { 0x11B0, 0x0013, 0x00D8, 0x014D, 0xFFFE, 0x0100 }; /* Game Boy Color / Game Boy Advance */ |
| 449 | 449 | static const UINT16 megaduck_cpu_regs[6] = { 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFE, 0x0000 }; /* Megaduck */ |
| 450 | 450 | |
| 451 | 451 | static const lr35902_cpu_core dmg_cpu_reset = { NULL, LR35902_FEATURE_HALT_BUG, gb_timer_callback }; |
| 452 | 452 | static const lr35902_cpu_core sgb_cpu_reset = { sgb_cpu_regs, LR35902_FEATURE_HALT_BUG, gb_timer_callback }; |
| 453 | 453 | static const lr35902_cpu_core mgb_cpu_reset = { mgb_cpu_regs, LR35902_FEATURE_HALT_BUG, gb_timer_callback }; |
| 454 | | static const lr35902_cpu_core cgb_cpu_reset = { cgb_cpu_regs, 0, gb_timer_callback }; |
| 454 | static const lr35902_cpu_core cgb_cpu_reset = { NULL, 0, gb_timer_callback }; |
| 455 | 455 | static const lr35902_cpu_core megaduck_cpu_reset = { megaduck_cpu_regs, LR35902_FEATURE_HALT_BUG, gb_timer_callback }; |
| 456 | 456 | |
| 457 | 457 | static ADDRESS_MAP_START(gb_map, ADDRESS_SPACE_PROGRAM, 8) |
| 458 | 458 | ADDRESS_MAP_UNMAP_HIGH |
| 459 | 459 | AM_RANGE(0x0000, 0x00ff) AM_ROMBANK(5) /* BIOS or ROM */ |
| 460 | | AM_RANGE(0x0100, 0x3fff) AM_ROMBANK(10) /* ROM bank */ |
| 460 | AM_RANGE(0x0100, 0x014f) AM_ROMBANK(10) /* ROM bank */ |
| 461 | AM_RANGE(0x0150, 0x03ff) AM_ROMBANK(6) |
| 462 | AM_RANGE(0x0400, 0x3fff) AM_ROMBANK(11) |
| 461 | 463 | AM_RANGE(0x4000, 0x5fff) AM_ROMBANK(1) /* 8KB/16KB switched ROM bank */ |
| 462 | 464 | AM_RANGE(0x6000, 0x7fff) AM_ROMBANK(4) /* 8KB/16KB switched ROM bank */ |
| 463 | 465 | AM_RANGE(0x8000, 0x9fff) AM_READWRITE( gb_vram_r, gb_vram_w ) /* 8k VRAM */ |
| r5695 | r5696 | |
| 476 | 478 | static ADDRESS_MAP_START(sgb_map, ADDRESS_SPACE_PROGRAM, 8) |
| 477 | 479 | ADDRESS_MAP_UNMAP_HIGH |
| 478 | 480 | AM_RANGE(0x0000, 0x00ff) AM_ROMBANK(5) /* 16k fixed ROM bank */ |
| 479 | | AM_RANGE(0x0100, 0x3fff) AM_ROMBANK(10) /* ROM bank */ |
| 481 | AM_RANGE(0x0100, 0x014f) AM_ROMBANK(10) /* ROM bank */ |
| 482 | AM_RANGE(0x0150, 0x03ff) AM_ROMBANK(6) |
| 483 | AM_RANGE(0x0400, 0x3fff) AM_ROMBANK(11) |
| 480 | 484 | AM_RANGE(0x4000, 0x5fff) AM_ROMBANK(1) /* 8KB/16KB switched ROM bank */ |
| 481 | 485 | AM_RANGE(0x6000, 0x7fff) AM_ROMBANK(4) /* 8KB/16KB switched ROM bank */ |
| 482 | 486 | AM_RANGE(0x8000, 0x9fff) AM_READWRITE( gb_vram_r, gb_vram_w ) /* 8k VRAM */ |
| r5695 | r5696 | |
| 495 | 499 | static ADDRESS_MAP_START(gbc_map, ADDRESS_SPACE_PROGRAM, 8) |
| 496 | 500 | ADDRESS_MAP_UNMAP_HIGH |
| 497 | 501 | AM_RANGE(0x0000, 0x00ff) AM_ROMBANK(5) /* 16k fixed ROM bank */ |
| 498 | | AM_RANGE(0x0100, 0x3fff) AM_ROMBANK(10) /* ROM bank */ |
| 502 | AM_RANGE(0x0100, 0x014f) AM_ROMBANK(10) /* ROM bank */ |
| 503 | AM_RANGE(0x0150, 0x03ff) AM_ROMBANK(6) |
| 504 | AM_RANGE(0x0400, 0x3fff) AM_ROMBANK(11) |
| 499 | 505 | AM_RANGE(0x4000, 0x5fff) AM_ROMBANK(1) /* 8KB/16KB switched ROM bank */ |
| 500 | 506 | AM_RANGE(0x6000, 0x7fff) AM_ROMBANK(4) /* 8KB/16KB switched ROM bank */ |
| 501 | 507 | AM_RANGE(0x8000, 0x9fff) AM_READWRITE( gb_vram_r, gb_vram_w ) /* 8k switched VRAM bank */ |
| r5695 | r5696 | |
| 629 | 635 | |
| 630 | 636 | MDRV_PALETTE_LENGTH(32768) |
| 631 | 637 | MDRV_PALETTE_INIT(gbc) |
| 632 | | |
| 633 | | MDRV_CARTSLOT_MODIFY("cart") |
| 634 | | MDRV_CARTSLOT_MANDATORY |
| 635 | 638 | MACHINE_DRIVER_END |
| 636 | 639 | |
| 637 | 640 | static SYSTEM_CONFIG_START(gb_cgb) |
| r5695 | r5696 | |
| 701 | 704 | ROM_END |
| 702 | 705 | |
| 703 | 706 | ROM_START( gbcolor ) |
| 704 | | ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) |
| 705 | | /* ROM_LOAD( "gbc_boot.bin", 0x0000, 0x0100, NO_DUMP ) */ |
| 707 | ROM_REGION( 0x03B0 + 1792, "maincpu", 0 ) |
| 708 | ROM_LOAD( "gbc_boot.1", 0x0000, 0x0100, BAD_DUMP CRC(607a2f81) SHA1(6b232a802ca1f4c3c7c29ad10de10737bbc064bc) ) /* Bootstrap code part 1 */ |
| 709 | ROM_LOAD( "gbc_boot.2", 0x0100, 0x02B0, BAD_DUMP CRC(2a8e6294) SHA1(0b9a3836b524ffbff74729e0a01f33fef45b457b) ) /* Bootstrap code part 2 */ |
| 710 | ROM_LOAD( "gbc_boot.3", 0x03B0, 1792, NO_DUMP ) /* DMG game - palette lookup table(?) */ |
| 706 | 711 | ROM_END |
| 707 | 712 | |
| 708 | 713 | |
| r5695 | r5696 | |
| 715 | 720 | CONS( 1994, supergb, 0, gameboy, supergb, gameboy, 0, 0, "Nintendo", "Super Game Boy" , 0) |
| 716 | 721 | CONS( 1996, gbpocket, gameboy, 0, gbpocket, gameboy, 0, 0, "Nintendo", "Game Boy Pocket" , 0) |
| 717 | 722 | CONS( 1997, gblight, gameboy, 0, gbpocket, gameboy, 0, 0, "Nintendo", "Game Boy Light" , 0) |
| 718 | | CONS( 1998, gbcolor, 0, gameboy, gbcolor, gameboy, 0, gb_cgb, "Nintendo", "Game Boy Color" , GAME_NOT_WORKING) |
| 723 | CONS( 1998, gbcolor, gameboy, 0, gbcolor, gameboy, 0, gb_cgb, "Nintendo", "Game Boy Color" , GAME_NOT_WORKING) |
| 719 | 724 | |
| 720 | 725 | /* Sound is not 100% yet, it generates some sounds which could be ok. Since we're lacking a real |
| 721 | 726 | system there's no way to verify. Same goes for the colors of the LCD. We are no using the default |