src/mess/drivers/pce220.c
| r8159 | r8160 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | Sharp PC-E220 |
| 3 | Sharp PC-E220 |
| 4 | 4 | |
| 5 | | 16/11/2009 Skeleton driver. |
| 5 | preliminary driver by Angelo Salese |
| 6 | 6 | |
| 7 | Notes: |
| 8 | - checks for a "machine language" string at some point, nothing in the |
| 9 | current dump match it |
| 10 | |
| 7 | 11 | ****************************************************************************/ |
| 8 | 12 | |
| 9 | 13 | #include "emu.h" |
| 10 | 14 | #include "cpu/z80/z80.h" |
| 11 | 15 | #include "devices/messram.h" |
| 12 | 16 | |
| 13 | | static WRITE8_HANDLER( rom_bank_w) |
| 17 | static UINT8 bank_num; |
| 18 | static UINT16 lcd_index_row,lcd_index_col; |
| 19 | |
| 20 | static VIDEO_START( pce220 ) |
| 14 | 21 | { |
| 22 | } |
| 23 | |
| 24 | static VIDEO_UPDATE( pce220 ) |
| 25 | { |
| 26 | int x, y, xi,yi; |
| 27 | int count = 0; |
| 28 | // static int test_x,test_y; |
| 29 | static UINT8 *vram = memory_region(screen->machine, "lcd_vram"); |
| 30 | |
| 31 | for (y = 0; y < 4; y++) |
| 32 | { |
| 33 | for (x = 0; x < 24; x++) |
| 34 | { |
| 35 | int color; |
| 36 | |
| 37 | for (xi = 0; xi < 5; xi++) |
| 38 | { |
| 39 | for (yi = 0; yi < 8; yi++) |
| 40 | { |
| 41 | color = (vram[count]) >> (yi) & 1; |
| 42 | |
| 43 | //if ((x + xi) <= video_screen_get_visible_area(screen)->max_x && (y + 0) < video_screen_get_visible_area(screen)->max_y) |
| 44 | *BITMAP_ADDR32(bitmap, y*8 + yi, x*5 + xi) = screen->machine->pens[color ^ 1]; |
| 45 | } |
| 46 | |
| 47 | count++; |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static READ8_HANDLER( lcd_status_r ) |
| 55 | { |
| 56 | return 0; //bit 7 lcd busy |
| 57 | } |
| 58 | |
| 59 | static WRITE8_HANDLER( lcd_control_w ) |
| 60 | { |
| 61 | if((data & 0xb8) == 0xb8) |
| 62 | lcd_index_row = (data & 0x07); |
| 63 | if((data & 0x40) == 0x40) |
| 64 | lcd_index_col = (data & 0x3f); |
| 65 | } |
| 66 | |
| 67 | static WRITE8_HANDLER( lcd_data_w ) |
| 68 | { |
| 69 | static UINT8 *vram = memory_region(space->machine, "lcd_vram"); |
| 70 | |
| 71 | vram[lcd_index_row*0x40|lcd_index_col] = data; |
| 72 | |
| 73 | gfx_element_mark_dirty(space->machine->gfx[0], (lcd_index_row*0x40|lcd_index_col)/5); |
| 74 | lcd_index_col++; |
| 75 | } |
| 76 | |
| 77 | static READ8_HANDLER( rom_bank_r ) |
| 78 | { |
| 79 | return bank_num; |
| 80 | } |
| 81 | |
| 82 | static WRITE8_HANDLER( rom_bank_w ) |
| 83 | { |
| 15 | 84 | UINT8 bank2 = data & 0x07; // bits 0,1,2 |
| 16 | | UINT8 bank1 = data & 0x70; // bits 4,5,6 |
| 85 | UINT8 bank1 = (data & 0x70) >> 4; // bits 4,5,6 |
| 17 | 86 | |
| 87 | bank_num = data; |
| 88 | |
| 18 | 89 | memory_set_bankptr(space->machine, "bank3", memory_region(space->machine, "user1") + 0x4000 * bank1); |
| 19 | 90 | memory_set_bankptr(space->machine, "bank4", memory_region(space->machine, "user1") + 0x4000 * bank2); |
| 20 | 91 | } |
| 21 | 92 | |
| 22 | | static WRITE8_HANDLER( ram_bank_w) |
| 93 | static WRITE8_HANDLER( ram_bank_w ) |
| 23 | 94 | { |
| 24 | 95 | const address_space *space_prg = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 25 | 96 | UINT8 bank = BIT(data,2); |
| r8159 | r8160 | |
| 36 | 107 | AM_RANGE(0xc000, 0xffff) AM_ROMBANK("bank4") |
| 37 | 108 | ADDRESS_MAP_END |
| 38 | 109 | |
| 110 | static READ8_HANDLER( battery_status_r ) |
| 111 | { |
| 112 | return 0; //if bit 0 is active, battery is low |
| 113 | } |
| 114 | |
| 115 | /* TODO */ |
| 116 | static UINT8 lcd_timer; |
| 117 | |
| 118 | static READ8_HANDLER( timer_lcd_r ) |
| 119 | { |
| 120 | return mame_rand(space->machine) & 1; |
| 121 | } |
| 122 | |
| 123 | static WRITE8_HANDLER( timer_lcd_w ) |
| 124 | { |
| 125 | lcd_timer = data & 1; |
| 126 | } |
| 127 | |
| 128 | static READ8_HANDLER( port15_r ) |
| 129 | { |
| 130 | /* |
| 131 | x--- ---- XIN input enabled |
| 132 | ---- ---0 |
| 133 | */ |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | static READ8_HANDLER( port18_r ) |
| 138 | { |
| 139 | /* |
| 140 | x--- ---- XOUT/TXD |
| 141 | ---- --x- DOUT |
| 142 | ---- ---x BUSY/CTS |
| 143 | */ |
| 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | static READ8_HANDLER( port1f_r ) |
| 148 | { |
| 149 | /* |
| 150 | x--- ---- ON - resp. break key status (?) |
| 151 | ---- -x-- XIN/RXD |
| 152 | ---- --x- ACK/RTS |
| 153 | ---- ---x DIN |
| 154 | */ |
| 155 | |
| 156 | return 0; |
| 157 | } |
| 158 | |
| 39 | 159 | static ADDRESS_MAP_START( pce220_io , ADDRESS_SPACE_IO, 8) |
| 40 | 160 | ADDRESS_MAP_UNMAP_HIGH |
| 41 | 161 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 42 | | AM_RANGE(0x19, 0x19) AM_WRITE(rom_bank_w) |
| 162 | AM_RANGE(0x10, 0x10) AM_READNOP //key matrix r |
| 163 | AM_RANGE(0x11, 0x12) AM_WRITENOP //key matrix mux |
| 164 | AM_RANGE(0x13, 0x13) AM_READNOP //bit 0 = shift key |
| 165 | AM_RANGE(0x14, 0x14) AM_READ(timer_lcd_r) AM_WRITE(timer_lcd_w) |
| 166 | AM_RANGE(0x15, 0x15) AM_READ(port15_r) AM_WRITENOP |
| 167 | AM_RANGE(0x16, 0x16) AM_NOP // irq status / acks |
| 168 | AM_RANGE(0x17, 0x17) AM_WRITENOP // irq mask |
| 169 | AM_RANGE(0x18, 0x18) AM_READ(port18_r) AM_WRITENOP |
| 170 | AM_RANGE(0x19, 0x19) AM_READ(rom_bank_r) AM_WRITE(rom_bank_w) |
| 171 | AM_RANGE(0x1a, 0x1a) AM_WRITENOP //cleared on BASIC init |
| 43 | 172 | AM_RANGE(0x1b, 0x1b) AM_WRITE(ram_bank_w) |
| 173 | AM_RANGE(0x1c, 0x1c) AM_WRITENOP //peripheral reset |
| 174 | AM_RANGE(0x1d, 0x1d) AM_READ(battery_status_r) |
| 175 | AM_RANGE(0x1e, 0x1e) AM_WRITENOP //??? |
| 176 | AM_RANGE(0x1f, 0x1f) AM_READ(port1f_r) AM_WRITENOP |
| 177 | AM_RANGE(0x58, 0x58) AM_WRITE(lcd_control_w) |
| 178 | AM_RANGE(0x59, 0x59) AM_READ(lcd_status_r) |
| 179 | AM_RANGE(0x5a, 0x5a) AM_WRITE(lcd_data_w) |
| 180 | |
| 44 | 181 | ADDRESS_MAP_END |
| 45 | 182 | |
| 46 | 183 | /* Input ports */ |
| r8159 | r8160 | |
| 55 | 192 | memory_set_bankptr(machine, "bank1", memory_region(machine, "user1") + 0x0000); |
| 56 | 193 | } |
| 57 | 194 | |
| 58 | | static VIDEO_START( pce220 ) |
| 195 | static const gfx_layout test_decode = |
| 59 | 196 | { |
| 60 | | } |
| 197 | 5,7, |
| 198 | RGN_FRAC(1,1), |
| 199 | 1, |
| 200 | { 0 }, |
| 201 | { 0*8, 1*8, 2*8, 3*8, 4*8 }, |
| 202 | { 7, 6, 5, 4, 3, 2, 1 }, |
| 203 | 5*8 |
| 204 | }; |
| 61 | 205 | |
| 62 | | static VIDEO_UPDATE( pce220 ) |
| 63 | | { |
| 64 | | return 0; |
| 65 | | } |
| 206 | /* decoded for debugging purpose, this will be nuked in the end... */ |
| 207 | static GFXDECODE_START( pce220 ) |
| 208 | GFXDECODE_ENTRY( "lcd_vram", 0x00000, test_decode, 0, 1 ) |
| 209 | GFXDECODE_END |
| 66 | 210 | |
| 67 | 211 | static MACHINE_DRIVER_START( pce220 ) |
| 68 | 212 | /* basic machine hardware */ |
| r8159 | r8160 | |
| 77 | 221 | MDRV_SCREEN_ADD("screen", RASTER) |
| 78 | 222 | MDRV_SCREEN_REFRESH_RATE(50) |
| 79 | 223 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 80 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 81 | | MDRV_SCREEN_SIZE(144, 32) |
| 82 | | MDRV_SCREEN_VISIBLE_AREA(0, 144-1, 0, 32-1) |
| 224 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 225 | MDRV_SCREEN_SIZE(32*8, 32*8) |
| 226 | MDRV_SCREEN_VISIBLE_AREA(0, 32*8-1, 0, 32*8-1) |
| 83 | 227 | MDRV_PALETTE_LENGTH(2) |
| 84 | 228 | MDRV_PALETTE_INIT(black_and_white) |
| 229 | MDRV_GFXDECODE(pce220) |
| 85 | 230 | |
| 86 | 231 | MDRV_VIDEO_START(pce220) |
| 87 | 232 | MDRV_VIDEO_UPDATE(pce220) |
| r8159 | r8160 | |
| 108 | 253 | ROMX_LOAD( "bank6_0.1.bin", 0x18000, 0x4000, CRC(e2cda7a6) SHA1(01b1796d9485fde6994cb5afbe97514b54cfbb3a),ROM_BIOS(1)) |
| 109 | 254 | ROMX_LOAD( "bank7.bin", 0x1c000, 0x4000, CRC(5e98b5b6) SHA1(f22d74d6a24f5929efaf2983caabd33859232a94),ROM_BIOS(2)) |
| 110 | 255 | ROMX_LOAD( "bank7_0.1.bin", 0x1c000, 0x4000, CRC(d8e821b2) SHA1(18245a75529d2f496cdbdc28cdf40def157b20c0),ROM_BIOS(1)) |
| 256 | |
| 257 | ROM_REGION( 0x1000, "lcd_vram", ROMREGION_ERASE00) |
| 111 | 258 | ROM_END |
| 112 | 259 | |
| 113 | 260 | /* Driver */ |