trunk/src/mame/drivers/progolf.c
| r243624 | r243625 | |
| 64 | 64 | public: |
| 65 | 65 | progolf_state(const machine_config &mconfig, device_type type, const char *tag) |
| 66 | 66 | : driver_device(mconfig, type, tag), |
| 67 | | m_fbram(*this, "fbram"), |
| 68 | 67 | m_maincpu(*this, "maincpu"), |
| 69 | 68 | m_audiocpu(*this, "audiocpu"), |
| 70 | 69 | m_gfxdecode(*this, "gfxdecode"), |
| 71 | | m_palette(*this, "palette") { } |
| 70 | m_palette(*this, "palette"), |
| 71 | m_videoram(*this, "videoram"), |
| 72 | m_fbram(*this, "fbram") { } |
| 72 | 73 | |
| 73 | | UINT8 *m_videoram; |
| 74 | required_device<cpu_device> m_maincpu; |
| 75 | required_device<cpu_device> m_audiocpu; |
| 76 | required_device<gfxdecode_device> m_gfxdecode; |
| 77 | required_device<palette_device> m_palette; |
| 78 | |
| 79 | required_shared_ptr<UINT8> m_videoram; |
| 80 | required_shared_ptr<UINT8> m_fbram; |
| 81 | |
| 74 | 82 | UINT8 m_char_pen; |
| 75 | 83 | UINT8 m_char_pen_vreg; |
| 76 | 84 | UINT8 *m_fg_fb; |
| 77 | | required_shared_ptr<UINT8> m_fbram; |
| 78 | 85 | UINT8 m_scrollx_hi; |
| 79 | 86 | UINT8 m_scrollx_lo; |
| 80 | 87 | UINT8 m_gfx_switch; |
| 81 | 88 | UINT8 m_sound_cmd; |
| 82 | | DECLARE_WRITE8_MEMBER(progolf_charram_w); |
| 83 | | DECLARE_WRITE8_MEMBER(progolf_char_vregs_w); |
| 84 | | DECLARE_WRITE8_MEMBER(progolf_scrollx_lo_w); |
| 85 | | DECLARE_WRITE8_MEMBER(progolf_scrollx_hi_w); |
| 86 | | DECLARE_WRITE8_MEMBER(progolf_flip_screen_w); |
| 89 | |
| 90 | DECLARE_WRITE8_MEMBER(charram_w); |
| 91 | DECLARE_WRITE8_MEMBER(char_vregs_w); |
| 92 | DECLARE_WRITE8_MEMBER(scrollx_lo_w); |
| 93 | DECLARE_WRITE8_MEMBER(scrollx_hi_w); |
| 94 | DECLARE_WRITE8_MEMBER(flip_screen_w); |
| 87 | 95 | DECLARE_WRITE8_MEMBER(audio_command_w); |
| 88 | 96 | DECLARE_READ8_MEMBER(audio_command_r); |
| 89 | | DECLARE_READ8_MEMBER(progolf_videoram_r); |
| 90 | | DECLARE_WRITE8_MEMBER(progolf_videoram_w); |
| 97 | DECLARE_READ8_MEMBER(videoram_r); |
| 98 | DECLARE_WRITE8_MEMBER(videoram_w); |
| 99 | |
| 91 | 100 | DECLARE_INPUT_CHANGED_MEMBER(coin_inserted); |
| 101 | |
| 102 | virtual void machine_start(); |
| 92 | 103 | virtual void video_start(); |
| 93 | 104 | DECLARE_PALETTE_INIT(progolf); |
| 94 | | UINT32 screen_update_progolf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 95 | | required_device<cpu_device> m_maincpu; |
| 96 | | required_device<cpu_device> m_audiocpu; |
| 97 | | required_device<gfxdecode_device> m_gfxdecode; |
| 98 | | required_device<palette_device> m_palette; |
| 105 | |
| 106 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 99 | 107 | }; |
| 100 | 108 | |
| 101 | 109 | |
| 110 | void progolf_state::machine_start() |
| 111 | { |
| 112 | save_item(NAME(m_sound_cmd)); |
| 113 | } |
| 102 | 114 | |
| 103 | | |
| 104 | 115 | void progolf_state::video_start() |
| 105 | 116 | { |
| 106 | 117 | m_scrollx_hi = 0; |
| 107 | 118 | m_scrollx_lo = 0; |
| 108 | 119 | |
| 109 | 120 | m_fg_fb = auto_alloc_array(machine(), UINT8, 0x2000*8); |
| 110 | | m_videoram = auto_alloc_array(machine(), UINT8, 0x1000); |
| 121 | |
| 122 | save_item(NAME(m_char_pen)); |
| 123 | save_item(NAME(m_char_pen_vreg)); |
| 124 | save_pointer(NAME(m_fg_fb), 0x2000*8); |
| 125 | save_item(NAME(m_scrollx_hi)); |
| 126 | save_item(NAME(m_scrollx_lo)); |
| 127 | save_item(NAME(m_gfx_switch)); |
| 111 | 128 | } |
| 112 | 129 | |
| 113 | 130 | |
| 114 | | UINT32 progolf_state::screen_update_progolf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 131 | UINT32 progolf_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 115 | 132 | { |
| 116 | | UINT8 *videoram = m_videoram; |
| 117 | 133 | int count,color,x,y,xi,yi; |
| 118 | 134 | |
| 119 | 135 | { |
| r243624 | r243625 | |
| 125 | 141 | { |
| 126 | 142 | for(y=0;y<32;y++) |
| 127 | 143 | { |
| 128 | | int tile = videoram[count]; |
| 144 | int tile = m_videoram[count]; |
| 129 | 145 | |
| 130 | 146 | m_gfxdecode->gfx(0)->opaque(bitmap,cliprect,tile,1,0,0,(256-x*8)+scroll,y*8); |
| 131 | 147 | /* wrap-around */ |
| r243624 | r243625 | |
| 163 | 179 | return 0; |
| 164 | 180 | } |
| 165 | 181 | |
| 166 | | WRITE8_MEMBER(progolf_state::progolf_charram_w) |
| 182 | WRITE8_MEMBER(progolf_state::charram_w) |
| 167 | 183 | { |
| 168 | 184 | int i; |
| 169 | 185 | m_fbram[offset] = data; |
| r243624 | r243625 | |
| 185 | 201 | } |
| 186 | 202 | } |
| 187 | 203 | |
| 188 | | WRITE8_MEMBER(progolf_state::progolf_char_vregs_w) |
| 204 | WRITE8_MEMBER(progolf_state::char_vregs_w) |
| 189 | 205 | { |
| 190 | 206 | m_char_pen = data & 0x07; |
| 191 | 207 | m_gfx_switch = data & 0xf0; |
| 192 | 208 | m_char_pen_vreg = data & 0x30; |
| 193 | 209 | } |
| 194 | 210 | |
| 195 | | WRITE8_MEMBER(progolf_state::progolf_scrollx_lo_w) |
| 211 | WRITE8_MEMBER(progolf_state::scrollx_lo_w) |
| 196 | 212 | { |
| 197 | 213 | m_scrollx_lo = data; |
| 198 | 214 | } |
| 199 | 215 | |
| 200 | | WRITE8_MEMBER(progolf_state::progolf_scrollx_hi_w) |
| 216 | WRITE8_MEMBER(progolf_state::scrollx_hi_w) |
| 201 | 217 | { |
| 202 | 218 | m_scrollx_hi = data; |
| 203 | 219 | } |
| 204 | 220 | |
| 205 | | WRITE8_MEMBER(progolf_state::progolf_flip_screen_w) |
| 221 | WRITE8_MEMBER(progolf_state::flip_screen_w) |
| 206 | 222 | { |
| 207 | 223 | flip_screen_set(data & 1); |
| 208 | 224 | if(data & 0xfe) |
| r243624 | r243625 | |
| 221 | 237 | return m_sound_cmd; |
| 222 | 238 | } |
| 223 | 239 | |
| 224 | | READ8_MEMBER(progolf_state::progolf_videoram_r) |
| 240 | READ8_MEMBER(progolf_state::videoram_r) |
| 225 | 241 | { |
| 226 | | UINT8 *videoram = m_videoram; |
| 227 | 242 | UINT8 *gfx_rom = memregion("gfx1")->base(); |
| 228 | 243 | |
| 229 | 244 | if (offset >= 0x0800) |
| r243624 | r243625 | |
| 235 | 250 | else if (m_gfx_switch == 0x70) |
| 236 | 251 | return gfx_rom[offset + 0x2000]; |
| 237 | 252 | else |
| 238 | | return videoram[offset]; |
| 253 | return m_videoram[offset]; |
| 239 | 254 | } else { |
| 240 | 255 | if (m_gfx_switch == 0x10) |
| 241 | 256 | return gfx_rom[offset]; |
| r243624 | r243625 | |
| 244 | 259 | else if (m_gfx_switch == 0x30) |
| 245 | 260 | return gfx_rom[offset + 0x2000]; |
| 246 | 261 | else |
| 247 | | return videoram[offset]; |
| 262 | return m_videoram[offset]; |
| 248 | 263 | } |
| 249 | 264 | } |
| 250 | 265 | |
| 251 | | WRITE8_MEMBER(progolf_state::progolf_videoram_w) |
| 266 | WRITE8_MEMBER(progolf_state::videoram_w) |
| 252 | 267 | { |
| 253 | | UINT8 *videoram = m_videoram; |
| 254 | 268 | //if(m_gfx_switch & 0x40) |
| 255 | | videoram[offset] = data; |
| 269 | m_videoram[offset] = data; |
| 256 | 270 | } |
| 257 | 271 | |
| 258 | 272 | static ADDRESS_MAP_START( main_cpu, AS_PROGRAM, 8, progolf_state ) |
| 259 | 273 | AM_RANGE(0x0000, 0x5fff) AM_RAM |
| 260 | | AM_RANGE(0x6000, 0x7fff) AM_RAM_WRITE(progolf_charram_w) AM_SHARE("fbram") |
| 261 | | AM_RANGE(0x8000, 0x8fff) AM_READWRITE(progolf_videoram_r,progolf_videoram_w) |
| 262 | | AM_RANGE(0x9000, 0x9000) AM_READ_PORT("IN2") AM_WRITE(progolf_char_vregs_w) |
| 263 | | AM_RANGE(0x9200, 0x9200) AM_READ_PORT("P1") AM_WRITE(progolf_scrollx_hi_w) //p1 inputs |
| 264 | | AM_RANGE(0x9400, 0x9400) AM_READ_PORT("P2") AM_WRITE(progolf_scrollx_lo_w) //p2 inputs |
| 265 | | AM_RANGE(0x9600, 0x9600) AM_READ_PORT("IN0") AM_WRITE(progolf_flip_screen_w) /* VBLANK */ |
| 274 | AM_RANGE(0x6000, 0x7fff) AM_RAM_WRITE(charram_w) AM_SHARE("fbram") |
| 275 | AM_RANGE(0x8000, 0x8fff) AM_READWRITE(videoram_r, videoram_w) AM_SHARE("videoram") |
| 276 | AM_RANGE(0x9000, 0x9000) AM_READ_PORT("IN2") AM_WRITE(char_vregs_w) |
| 277 | AM_RANGE(0x9200, 0x9200) AM_READ_PORT("P1") AM_WRITE(scrollx_hi_w) //p1 inputs |
| 278 | AM_RANGE(0x9400, 0x9400) AM_READ_PORT("P2") AM_WRITE(scrollx_lo_w) //p2 inputs |
| 279 | AM_RANGE(0x9600, 0x9600) AM_READ_PORT("IN0") AM_WRITE(flip_screen_w) /* VBLANK */ |
| 266 | 280 | AM_RANGE(0x9800, 0x9800) AM_READ_PORT("DSW1") |
| 267 | 281 | AM_RANGE(0x9800, 0x9800) AM_DEVWRITE("crtc", mc6845_device, address_w) |
| 268 | 282 | AM_RANGE(0x9801, 0x9801) AM_DEVWRITE("crtc", mc6845_device, register_w) |
| r243624 | r243625 | |
| 362 | 376 | PORT_DIPUNUSED( 0x80, IP_ACTIVE_HIGH ) |
| 363 | 377 | INPUT_PORTS_END |
| 364 | 378 | |
| 365 | | static const gfx_layout progolf_charlayout = |
| 379 | static const gfx_layout charlayout = |
| 366 | 380 | { |
| 367 | 381 | 8,8, /* 8*8 characters */ |
| 368 | 382 | RGN_FRAC(1,3), /* 512 characters */ |
| r243624 | r243625 | |
| 374 | 388 | }; |
| 375 | 389 | |
| 376 | 390 | static GFXDECODE_START( progolf ) |
| 377 | | GFXDECODE_ENTRY( "gfx1", 0x0000, progolf_charlayout, 0, 8 ) /* sprites */ |
| 391 | GFXDECODE_ENTRY( "gfx1", 0x0000, charlayout, 0, 8 ) /* sprites */ |
| 378 | 392 | GFXDECODE_END |
| 379 | 393 | |
| 380 | 394 | |
| r243624 | r243625 | |
| 423 | 437 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3072)) |
| 424 | 438 | MCFG_SCREEN_SIZE(256, 256) |
| 425 | 439 | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1) |
| 426 | | MCFG_SCREEN_UPDATE_DRIVER(progolf_state, screen_update_progolf) |
| 440 | MCFG_SCREEN_UPDATE_DRIVER(progolf_state, screen_update) |
| 427 | 441 | MCFG_SCREEN_PALETTE("palette") |
| 428 | 442 | |
| 429 | 443 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", progolf) |
| r243624 | r243625 | |
| 500 | 514 | |
| 501 | 515 | |
| 502 | 516 | // this uses DECO222 style encryption |
| 503 | | GAME( 1981, progolf, 0, progolf, progolf, driver_device, 0, ROT270, "Data East Corporation", "18 Holes Pro Golf (set 1)", GAME_IMPERFECT_GRAPHICS | GAME_NO_COCKTAIL ) |
| 517 | GAME( 1981, progolf, 0, progolf, progolf, driver_device, 0, ROT270, "Data East Corporation", "18 Holes Pro Golf (set 1)", GAME_IMPERFECT_GRAPHICS | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) |
| 504 | 518 | // this uses DECO CPU-6 as custom module CPU (the same as Zoar, are we sure? our Zoar has different encryption, CPU-7 style) |
| 505 | | GAME( 1981, progolfa, progolf, progolfa,progolf, driver_device, 0, ROT270, "Data East Corporation", "18 Holes Pro Golf (set 2)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_COCKTAIL ) |
| 519 | GAME( 1981, progolfa, progolf, progolfa,progolf, driver_device, 0, ROT270, "Data East Corporation", "18 Holes Pro Golf (set 2)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) |