src/mess/drivers/pasopia.c
| r8412 | r8413 | |
| 8 | 8 | |
| 9 | 9 | #include "emu.h" |
| 10 | 10 | #include "cpu/z80/z80.h" |
| 11 | #include "sound/ay8910.h" |
| 12 | #include "video/mc6845.h" |
| 11 | 13 | |
| 14 | static UINT8 vram_sel; |
| 15 | static UINT8 *p7_vram; |
| 16 | |
| 17 | static VIDEO_START( paso7 ) |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | static VIDEO_UPDATE( paso7 ) |
| 22 | { |
| 23 | int x,y; |
| 24 | int count; |
| 25 | |
| 26 | count = 0x10; |
| 27 | |
| 28 | for(y=0;y<25;y++) |
| 29 | { |
| 30 | for(x=0;x<40;x++) |
| 31 | { |
| 32 | int tile = p7_vram[count]; |
| 33 | |
| 34 | drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],tile,0,0,0,x*8,y*8); |
| 35 | |
| 36 | count+=8; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | static READ8_HANDLER( vram_r ) |
| 45 | { |
| 46 | if(vram_sel) |
| 47 | return 0xff; |
| 48 | |
| 49 | return p7_vram[offset]; |
| 50 | } |
| 51 | |
| 52 | static WRITE8_HANDLER( vram_w ) |
| 53 | { |
| 54 | if(!vram_sel) |
| 55 | p7_vram[offset] = data; |
| 56 | } |
| 57 | |
| 12 | 58 | // sketchy port 0x3c implementation to see what the CPU does... |
| 13 | 59 | // however, it writes 0x11 - in theory setting BASIC+BIOS in the lower banks |
| 14 | | // and then it writes at 0x0000... maybe bank1 should be RAM? or |
| 60 | // and then it writes at 0x0000... maybe bank1 should be RAM? or |
| 15 | 61 | // should we have writes to RAM and only reads to BIOS/BASIC? |
| 16 | 62 | static WRITE8_HANDLER( paso7_bankswitch ) |
| 17 | 63 | { |
| r8412 | r8413 | |
| 20 | 66 | |
| 21 | 67 | if (BIT(data, 0)) |
| 22 | 68 | { |
| 23 | | memory_unmap_write(space, 0x0000, 0x7fff, 0, 0); |
| 24 | 69 | memory_set_bankptr(space->machine, "bank1", basic); |
| 25 | 70 | memory_set_bankptr(space->machine, "bank2", cpu + 0x10000); |
| 71 | memory_unmap_write(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x7fff, 0, 0); |
| 26 | 72 | } |
| 27 | 73 | else if (BIT(data, 1)) |
| 28 | 74 | { |
| 29 | | memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank1"); |
| 30 | | memory_install_write_bank(space, 0x4000, 0x7fff, 0, 0, "bank2"); |
| 31 | 75 | memory_set_bankptr(space->machine, "bank1", cpu); |
| 32 | 76 | memory_set_bankptr(space->machine, "bank2", cpu + 0x4000); |
| 77 | memory_install_write_bank(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, "bank1"); |
| 78 | memory_install_write_bank(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4000, 0x7fff, 0, 0, "bank2"); |
| 33 | 79 | } |
| 34 | | else |
| 80 | else |
| 35 | 81 | { |
| 36 | | memory_unmap_write(space, 0x0000, 0x7fff, 0, 0); |
| 37 | 82 | memory_set_bankptr(space->machine, "bank1", cpu + 0x10000); |
| 38 | 83 | memory_set_bankptr(space->machine, "bank2", cpu + 0x10000); |
| 84 | memory_unmap_write(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x7fff, 0, 0); |
| 39 | 85 | } |
| 40 | 86 | |
| 41 | | if (BIT(data, 2)) |
| 42 | | memory_unmap_readwrite(space, 0x8000, 0xbfff, 0, 0); |
| 43 | | else |
| 44 | | { |
| 45 | | memory_install_write_bank(space, 0x8000, 0xbfff, 0, 0, "bank3"); |
| 46 | | memory_set_bankptr(space->machine, "bank3", cpu + 0x8000); |
| 47 | | } |
| 48 | | // bit 2 also selects vram |
| 87 | vram_sel = data & 4; |
| 49 | 88 | |
| 50 | 89 | // bit 3? PIO2 port C |
| 51 | 90 | |
| 52 | 91 | // bank4 is always RAM |
| 53 | 92 | } |
| 54 | 93 | |
| 94 | static READ8_HANDLER( test_r ) |
| 95 | { |
| 96 | return mame_rand(space->machine); |
| 97 | } |
| 98 | |
| 99 | |
| 100 | #if 0 |
| 101 | static WRITE8_HANDLER( test_w ) |
| 102 | { |
| 103 | printf("%02x %02x\n",offset,data); |
| 104 | } |
| 105 | #endif |
| 106 | |
| 107 | static READ8_HANDLER( test2_r ) |
| 108 | { |
| 109 | return 0xff; |
| 110 | } |
| 111 | |
| 55 | 112 | static ADDRESS_MAP_START(paso7_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 56 | 113 | ADDRESS_MAP_UNMAP_HIGH |
| 57 | 114 | AM_RANGE( 0x0000, 0x3fff ) AM_RAMBANK("bank1") |
| 58 | 115 | AM_RANGE( 0x4000, 0x7fff ) AM_RAMBANK("bank2") |
| 59 | | AM_RANGE( 0x8000, 0xbfff ) AM_RAMBANK("bank3") |
| 116 | AM_RANGE( 0x8000, 0xbfff ) AM_READWRITE(vram_r, vram_w ) AM_BASE(&p7_vram) |
| 60 | 117 | AM_RANGE( 0xc000, 0xffff ) AM_RAMBANK("bank4") |
| 61 | 118 | ADDRESS_MAP_END |
| 62 | 119 | |
| 63 | 120 | static ADDRESS_MAP_START( paso7_io , ADDRESS_SPACE_IO, 8) |
| 64 | 121 | ADDRESS_MAP_UNMAP_HIGH |
| 65 | 122 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 123 | AM_RANGE( 0x09, 0x09 ) AM_READ(test_r) |
| 124 | AM_RANGE( 0x10, 0x10 ) AM_DEVWRITE("crtc", mc6845_address_w) |
| 125 | AM_RANGE( 0x11, 0x11 ) AM_DEVWRITE("crtc", mc6845_register_w) |
| 126 | AM_RANGE( 0x22, 0x22 ) AM_READ(test2_r) AM_WRITENOP |
| 66 | 127 | AM_RANGE( 0x3c, 0x3c ) AM_WRITE(paso7_bankswitch) |
| 67 | | #if 0 |
| 68 | | AM_RANGE( 0x08, 0x0b ) // PIO0 |
| 69 | | AM_RANGE( 0x0c, 0x0f ) // PIO1 |
| 70 | | AM_RANGE( 0x10, 0x11 ) // CRTC |
| 71 | | AM_RANGE( 0x20, 0x23 ) // PIO2 |
| 72 | | AM_RANGE( 0x28, 0x2b ) // CTC |
| 73 | | AM_RANGE( 0x3a, 0x3a ) // PSG0 |
| 74 | | AM_RANGE( 0x3b, 0x3b ) // PSG1 |
| 75 | | AM_RANGE( 0xe0, 0xe6 ) // FLOPPY |
| 76 | | #endif |
| 128 | // AM_RANGE( 0x08, 0x0b ) // PIO0 |
| 129 | // AM_RANGE( 0x0c, 0x0f ) // PIO1 |
| 130 | // AM_RANGE( 0x20, 0x23 ) // PIO2 |
| 131 | // AM_RANGE( 0x28, 0x2b ) // CTC |
| 132 | // AM_RANGE( 0x3a, 0x3a ) // PSG0 |
| 133 | // AM_RANGE( 0x3b, 0x3b ) // PSG1 |
| 134 | // AM_RANGE( 0xe0, 0xe6 ) // FLOPPY |
| 77 | 135 | ADDRESS_MAP_END |
| 78 | 136 | |
| 79 | 137 | /* Input ports */ |
| r8412 | r8413 | |
| 84 | 142 | { |
| 85 | 143 | } |
| 86 | 144 | |
| 87 | | static VIDEO_START( paso7 ) |
| 145 | static const gfx_layout p7_chars_8x8 = |
| 88 | 146 | { |
| 89 | | } |
| 147 | 8,8, |
| 148 | RGN_FRAC(1,1), |
| 149 | 1, |
| 150 | { 0 }, |
| 151 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 152 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 153 | 8*8 |
| 154 | }; |
| 90 | 155 | |
| 91 | | static VIDEO_UPDATE( paso7 ) |
| 156 | static const gfx_layout p7_chars_16x16 = |
| 92 | 157 | { |
| 93 | | return 0; |
| 94 | | } |
| 158 | 16,16, |
| 159 | RGN_FRAC(1,1), |
| 160 | 1, |
| 161 | { 0 }, |
| 162 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, |
| 163 | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, |
| 164 | 16*16 |
| 165 | }; |
| 95 | 166 | |
| 167 | static GFXDECODE_START( pasopia7 ) |
| 168 | GFXDECODE_ENTRY( "font", 0x00000, p7_chars_8x8, 0, 1 ) |
| 169 | GFXDECODE_ENTRY( "kanji", 0x00000, p7_chars_16x16, 0, 1 ) |
| 170 | GFXDECODE_END |
| 171 | |
| 172 | static const mc6845_interface mc6845_intf = |
| 173 | { |
| 174 | "screen", /* screen we are acting on */ |
| 175 | 8, /* number of pixels per video memory address */ |
| 176 | NULL, /* before pixel update callback */ |
| 177 | NULL, /* row update callback */ |
| 178 | NULL, /* after pixel update callback */ |
| 179 | DEVCB_NULL, /* callback for display state changes */ |
| 180 | DEVCB_NULL, /* callback for cursor state changes */ |
| 181 | DEVCB_NULL, /* HSYNC callback */ |
| 182 | DEVCB_NULL, /* VSYNC callback */ |
| 183 | NULL /* update address callback */ |
| 184 | }; |
| 185 | |
| 96 | 186 | static MACHINE_DRIVER_START( paso7 ) |
| 97 | 187 | /* basic machine hardware */ |
| 98 | 188 | MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz) |
| 99 | 189 | MDRV_CPU_PROGRAM_MAP(paso7_mem) |
| 100 | 190 | MDRV_CPU_IO_MAP(paso7_io) |
| 191 | // MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) |
| 101 | 192 | |
| 102 | 193 | MDRV_MACHINE_RESET(paso7) |
| 103 | 194 | |
| 104 | 195 | /* video hardware */ |
| 105 | 196 | MDRV_SCREEN_ADD("screen", RASTER) |
| 106 | | MDRV_SCREEN_REFRESH_RATE(50) |
| 197 | MDRV_SCREEN_REFRESH_RATE(60) |
| 107 | 198 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 108 | 199 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 109 | 200 | MDRV_SCREEN_SIZE(640, 480) |
| 110 | 201 | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 202 | MDRV_MC6845_ADD("crtc", H46505, XTAL_3_579545MHz/4, mc6845_intf) /* unknown clock, hand tuned to get ~60 fps */ |
| 111 | 203 | MDRV_PALETTE_LENGTH(2) |
| 112 | 204 | MDRV_PALETTE_INIT(black_and_white) |
| 113 | 205 | |
| 206 | MDRV_GFXDECODE( pasopia7 ) |
| 207 | |
| 114 | 208 | MDRV_VIDEO_START(paso7) |
| 115 | 209 | MDRV_VIDEO_UPDATE(paso7) |
| 116 | 210 | MACHINE_DRIVER_END |
| r8412 | r8413 | |
| 135 | 229 | UINT8 *bios = memory_region(machine, "maincpu"); |
| 136 | 230 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 137 | 231 | |
| 138 | | memory_unmap_write(space, 0x0000, 0xbfff, 0, 0); |
| 232 | memory_unmap_write(space, 0x0000, 0x7fff, 0, 0); |
| 139 | 233 | memory_set_bankptr(machine, "bank1", bios + 0x10000); |
| 140 | 234 | memory_set_bankptr(machine, "bank2", bios + 0x10000); |
| 141 | | memory_set_bankptr(machine, "bank3", bios + 0x10000); |
| 235 | // memory_set_bankptr(machine, "bank3", bios + 0x10000); |
| 142 | 236 | // memory_set_bankptr(machine, "bank4", bios + 0x10000); |
| 143 | 237 | } |
| 144 | 238 | |