trunk/src/mame/includes/battlera.h
| r32530 | r32531 | |
| 1 | 1 | #include "sound/msm5205.h" |
| 2 | #include "video/huc6260.h" |
| 3 | #include "video/huc6270.h" |
| 4 | #include "video/huc6202.h" |
| 2 | 5 | |
| 6 | #define MAIN_CLOCK 21477270 |
| 7 | |
| 3 | 8 | class battlera_state : public driver_device |
| 4 | 9 | { |
| 5 | 10 | public: |
| r32530 | r32531 | |
| 8 | 13 | m_maincpu(*this, "maincpu"), |
| 9 | 14 | m_audiocpu(*this, "audiocpu"), |
| 10 | 15 | m_msm(*this, "msm"), |
| 11 | | m_gfxdecode(*this, "gfxdecode"), |
| 12 | 16 | m_screen(*this, "screen"), |
| 13 | | m_palette(*this, "palette"), |
| 14 | | m_generic_paletteram_8(*this, "paletteram") { } |
| 17 | m_huc6260(*this, "huc6260") |
| 18 | { } |
| 15 | 19 | |
| 16 | 20 | int m_control_port_select; |
| 17 | 21 | int m_msm5205next; |
| 18 | 22 | int m_toggle; |
| 19 | | int m_HuC6270_registers[20]; |
| 20 | | int m_VDC_register; |
| 21 | | int m_vram_ptr; |
| 22 | | UINT8 *m_HuC6270_vram; |
| 23 | | UINT8 *m_vram_dirty; |
| 24 | | bitmap_ind16 *m_tile_bitmap; |
| 25 | | bitmap_ind16 *m_front_bitmap; |
| 26 | | UINT32 m_tile_dirtyseq; |
| 27 | | int m_current_scanline; |
| 28 | 23 | int m_inc_value; |
| 29 | 24 | int m_irq_enable; |
| 30 | 25 | int m_rcr_enable; |
| 31 | 26 | int m_sb_enable; |
| 32 | 27 | int m_bb_enable; |
| 33 | 28 | int m_bldwolf_vblank; |
| 34 | | UINT8 m_blank_tile[32]; |
| 35 | 29 | |
| 36 | 30 | required_device<cpu_device> m_maincpu; |
| 37 | 31 | DECLARE_WRITE8_MEMBER(battlera_sound_w); |
| 38 | 32 | DECLARE_WRITE8_MEMBER(control_data_w); |
| 39 | 33 | DECLARE_READ8_MEMBER(control_data_r); |
| 40 | 34 | DECLARE_WRITE8_MEMBER(battlera_adpcm_data_w); |
| 41 | | DECLARE_WRITE8_MEMBER(battlera_palette_w); |
| 42 | | DECLARE_READ8_MEMBER(HuC6270_debug_r); |
| 43 | | DECLARE_WRITE8_MEMBER(HuC6270_debug_w); |
| 44 | | DECLARE_READ8_MEMBER(HuC6270_register_r); |
| 45 | | DECLARE_WRITE8_MEMBER(HuC6270_register_w); |
| 46 | | DECLARE_READ8_MEMBER(HuC6270_data_r); |
| 47 | | DECLARE_WRITE8_MEMBER(HuC6270_data_w); |
| 35 | |
| 48 | 36 | DECLARE_WRITE8_MEMBER(battlera_adpcm_reset_w); |
| 49 | | virtual void video_start(); |
| 50 | | UINT32 screen_update_battlera(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 51 | | TIMER_DEVICE_CALLBACK_MEMBER(battlera_irq); |
| 52 | | void draw_sprites(bitmap_ind16 &bitmap,const rectangle &clip,int pri); |
| 37 | |
| 38 | |
| 53 | 39 | DECLARE_WRITE_LINE_MEMBER(battlera_adpcm_int); |
| 54 | 40 | required_device<cpu_device> m_audiocpu; |
| 55 | 41 | required_device<msm5205_device> m_msm; |
| 56 | | required_device<gfxdecode_device> m_gfxdecode; |
| 57 | 42 | required_device<screen_device> m_screen; |
| 58 | | required_device<palette_device> m_palette; |
| 59 | | required_shared_ptr<UINT8> m_generic_paletteram_8; |
| 43 | optional_device<huc6260_device> m_huc6260; |
| 44 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 45 | DECLARE_WRITE_LINE_MEMBER(pce_irq_changed); |
| 60 | 46 | }; |
trunk/src/mame/video/battlera.c
| r32530 | r32531 | |
| 1 | | /******************************************************************************* |
| 1 | // delete me |
| 2 | 2 | |
| 3 | | Battle Rangers - Bryan McPhail, mish@tendril.co.uk |
| 4 | | |
| 5 | | This file only implements necessary features - not all PC-Engine video |
| 6 | | features are used in this game (no DMA for one). |
| 7 | | |
| 8 | | *******************************************************************************/ |
| 9 | | |
| 10 | | #include "emu.h" |
| 11 | | #include "cpu/h6280/h6280.h" |
| 12 | | #include "includes/battlera.h" |
| 13 | | |
| 14 | | |
| 15 | | /******************************************************************************/ |
| 16 | | |
| 17 | | void battlera_state::video_start() |
| 18 | | { |
| 19 | | m_HuC6270_vram=auto_alloc_array(machine(), UINT8, 0x20000); |
| 20 | | m_vram_dirty=auto_alloc_array(machine(), UINT8, 0x1000); |
| 21 | | |
| 22 | | memset(m_HuC6270_vram,0,0x20000); |
| 23 | | memset(m_vram_dirty,1,0x1000); |
| 24 | | |
| 25 | | m_tile_bitmap=auto_bitmap_ind16_alloc(machine(),512,512); |
| 26 | | m_front_bitmap=auto_bitmap_ind16_alloc(machine(),512,512); |
| 27 | | |
| 28 | | m_vram_ptr=0; |
| 29 | | m_inc_value=1; |
| 30 | | m_current_scanline=0; |
| 31 | | m_irq_enable=m_rcr_enable=m_sb_enable=m_bb_enable=0; |
| 32 | | |
| 33 | | m_gfxdecode->gfx(0)->set_source(m_HuC6270_vram); |
| 34 | | m_gfxdecode->gfx(1)->set_source(m_HuC6270_vram); |
| 35 | | m_gfxdecode->gfx(2)->set_source(m_blank_tile); |
| 36 | | } |
| 37 | | |
| 38 | | /******************************************************************************/ |
| 39 | | |
| 40 | | WRITE8_MEMBER(battlera_state::battlera_palette_w) |
| 41 | | { |
| 42 | | int pal_word; |
| 43 | | |
| 44 | | m_generic_paletteram_8[offset]=data; |
| 45 | | if (offset%2) offset-=1; |
| 46 | | |
| 47 | | pal_word=m_generic_paletteram_8[offset] | (m_generic_paletteram_8[offset+1]<<8); |
| 48 | | m_palette->set_pen_color(offset/2, pal3bit(pal_word >> 3), pal3bit(pal_word >> 6), pal3bit(pal_word >> 0)); |
| 49 | | } |
| 50 | | |
| 51 | | /******************************************************************************/ |
| 52 | | |
| 53 | | READ8_MEMBER(battlera_state::HuC6270_debug_r) |
| 54 | | { |
| 55 | | return m_HuC6270_vram[offset]; |
| 56 | | } |
| 57 | | |
| 58 | | WRITE8_MEMBER(battlera_state::HuC6270_debug_w) |
| 59 | | { |
| 60 | | m_HuC6270_vram[offset]=data; |
| 61 | | } |
| 62 | | READ8_MEMBER(battlera_state::HuC6270_register_r) |
| 63 | | { |
| 64 | | int rr; |
| 65 | | |
| 66 | | if ((m_current_scanline+56)==m_HuC6270_registers[6]) rr=1; else rr=0; |
| 67 | | |
| 68 | | return 0 /* CR flag */ |
| 69 | | | (0 << 1) /* OR flag */ |
| 70 | | | (rr << 2) /* RR flag */ |
| 71 | | | (0 << 3) /* DS flag */ |
| 72 | | | (0 << 4) /* DV flag */ |
| 73 | | | (m_bldwolf_vblank << 5) /* VD flag (1 when vblank else 0) */ |
| 74 | | | (0 << 6) /* BSY flag (1 when dma active, else 0) */ |
| 75 | | | (0 << 7); /* Always zero */ |
| 76 | | } |
| 77 | | |
| 78 | | WRITE8_MEMBER(battlera_state::HuC6270_register_w) |
| 79 | | { |
| 80 | | switch (offset) { |
| 81 | | case 0: /* Select data region */ |
| 82 | | m_VDC_register=data; |
| 83 | | break; |
| 84 | | case 1: /* Unused */ |
| 85 | | break; |
| 86 | | } |
| 87 | | } |
| 88 | | |
| 89 | | /******************************************************************************/ |
| 90 | | |
| 91 | | #ifdef UNUSED_FUNCTION |
| 92 | | READ8_MEMBER(battlera_state::HuC6270_data_r) |
| 93 | | { |
| 94 | | int result; |
| 95 | | |
| 96 | | switch (offset) { |
| 97 | | case 0: /* LSB */ |
| 98 | | return m_HuC6270_vram[(m_HuC6270_registers[1]<<1)|1]; |
| 99 | | |
| 100 | | case 1:/* MSB */ |
| 101 | | result=m_HuC6270_vram[(m_HuC6270_registers[1]<<1)|0]; |
| 102 | | m_HuC6270_registers[1]=(m_HuC6270_registers[1]+m_inc_value)&0xffff; |
| 103 | | return result; |
| 104 | | } |
| 105 | | |
| 106 | | return 0; |
| 107 | | } |
| 108 | | #endif |
| 109 | | |
| 110 | | WRITE8_MEMBER(battlera_state::HuC6270_data_w) |
| 111 | | { |
| 112 | | switch (offset) { |
| 113 | | case 0: /* LSB */ |
| 114 | | switch (m_VDC_register) { |
| 115 | | case 0: /* MAWR */ |
| 116 | | m_HuC6270_registers[0]=(m_HuC6270_registers[0]&0xff00) | (data); |
| 117 | | return; |
| 118 | | |
| 119 | | case 1: /* MARR */ |
| 120 | | m_HuC6270_registers[0]=(m_HuC6270_registers[1]&0xff00) | (data); |
| 121 | | return; |
| 122 | | |
| 123 | | case 2: /* VRAM */ |
| 124 | | if (m_HuC6270_vram[(m_HuC6270_registers[0]<<1)|1]!=data) { |
| 125 | | m_HuC6270_vram[(m_HuC6270_registers[0]<<1)|1]=data; |
| 126 | | m_gfxdecode->gfx(0)->mark_dirty(m_HuC6270_registers[0]>>4); |
| 127 | | m_gfxdecode->gfx(1)->mark_dirty(m_HuC6270_registers[0]>>6); |
| 128 | | } |
| 129 | | if (m_HuC6270_registers[0]<0x1000) m_vram_dirty[m_HuC6270_registers[0]]=1; |
| 130 | | return; |
| 131 | | |
| 132 | | case 3: break; /* Unused */ |
| 133 | | case 4: break; /* Unused */ |
| 134 | | |
| 135 | | case 5: /* CR - Control register */ |
| 136 | | /* Bits 0,1 unknown */ |
| 137 | | m_rcr_enable=data&0x4; /* Raster interrupt enable */ |
| 138 | | m_irq_enable=data&0x8; /* VBL interrupt enable */ |
| 139 | | /* Bits 4,5 unknown (EX) */ |
| 140 | | m_sb_enable=data&0x40; /* Sprites enable */ |
| 141 | | m_bb_enable=data&0x80; /* Background enable */ |
| 142 | | return; |
| 143 | | |
| 144 | | case 6: /* RCR - Raster counter register */ |
| 145 | | m_HuC6270_registers[6]=(m_HuC6270_registers[6]&0xff00) | (data); |
| 146 | | return; |
| 147 | | |
| 148 | | case 7: /* BXR - X scroll */ |
| 149 | | m_HuC6270_registers[7]=(m_HuC6270_registers[7]&0xff00) | (data); |
| 150 | | return; |
| 151 | | |
| 152 | | case 8: /* BYR - Y scroll */ |
| 153 | | m_HuC6270_registers[8]=(m_HuC6270_registers[8]&0xff00) | (data); |
| 154 | | return; |
| 155 | | |
| 156 | | case 15: /* DMA */ |
| 157 | | case 16: |
| 158 | | case 17: |
| 159 | | case 18: |
| 160 | | logerror("%04x: dma 2 %02x\n",space.device().safe_pc(),data); |
| 161 | | break; |
| 162 | | |
| 163 | | case 19: /* SATB */ |
| 164 | | m_HuC6270_registers[19]=(m_HuC6270_registers[19]&0xff00) | (data); |
| 165 | | return; |
| 166 | | |
| 167 | | } |
| 168 | | break; |
| 169 | | |
| 170 | | /*********************************************/ |
| 171 | | |
| 172 | | case 1: /* MSB (Autoincrement on this write) */ |
| 173 | | switch (m_VDC_register) { |
| 174 | | case 0: /* MAWR - Memory Address Write Register */ |
| 175 | | m_HuC6270_registers[0]=(m_HuC6270_registers[0]&0xff) | (data<<8); |
| 176 | | return; |
| 177 | | |
| 178 | | case 1: /* MARR */ |
| 179 | | m_HuC6270_registers[1]=(m_HuC6270_registers[1]&0xff) | (data<<8); |
| 180 | | return; |
| 181 | | |
| 182 | | case 2: /* VWR - VRAM */ |
| 183 | | if (m_HuC6270_vram[(m_HuC6270_registers[0]<<1)|0]!=data) { |
| 184 | | m_HuC6270_vram[(m_HuC6270_registers[0]<<1)|0]=data; |
| 185 | | m_gfxdecode->gfx(0)->mark_dirty(m_HuC6270_registers[0]>>4); |
| 186 | | m_gfxdecode->gfx(1)->mark_dirty(m_HuC6270_registers[0]>>6); |
| 187 | | if (m_HuC6270_registers[0]<0x1000) m_vram_dirty[m_HuC6270_registers[0]]=1; |
| 188 | | } |
| 189 | | m_HuC6270_registers[0]+=m_inc_value; |
| 190 | | m_HuC6270_registers[0]=m_HuC6270_registers[0]&0xffff; |
| 191 | | return; |
| 192 | | |
| 193 | | case 5: /* CR */ |
| 194 | | /* IW - Auto-increment values */ |
| 195 | | switch ((data>>3)&3) { |
| 196 | | case 0: m_inc_value=1; break; |
| 197 | | case 1: m_inc_value=32;break; |
| 198 | | case 2: m_inc_value=64; break; |
| 199 | | case 3: m_inc_value=128; break; |
| 200 | | } |
| 201 | | |
| 202 | | /* DR, TE unknown */ |
| 203 | | return; |
| 204 | | |
| 205 | | case 6: /* RCR - Raster counter register */ |
| 206 | | m_HuC6270_registers[6]=(m_HuC6270_registers[6]&0xff) | (data<<8); |
| 207 | | return; |
| 208 | | |
| 209 | | case 7: /* BXR - X scroll */ |
| 210 | | m_HuC6270_registers[7]=(m_HuC6270_registers[7]&0xff) | (data<<8); |
| 211 | | return; |
| 212 | | |
| 213 | | case 8: /* BYR - Y scroll */ |
| 214 | | m_HuC6270_registers[8]=(m_HuC6270_registers[8]&0xff) | (data<<8); |
| 215 | | return; |
| 216 | | |
| 217 | | case 15: /* DMA */ |
| 218 | | case 16: |
| 219 | | case 17: |
| 220 | | case 18: |
| 221 | | logerror("%04x: dma 2 %02x\n",space.device().safe_pc(),data); |
| 222 | | break; |
| 223 | | |
| 224 | | case 19: /* SATB - Sprites */ |
| 225 | | m_HuC6270_registers[19]=(m_HuC6270_registers[19]&0xff) | (data<<8); |
| 226 | | return; |
| 227 | | } |
| 228 | | break; |
| 229 | | } |
| 230 | | logerror("%04x: unknown write to VDC_register %02x (%02x) at %02x\n",space.device().safe_pc(),m_VDC_register,data,offset); |
| 231 | | } |
| 232 | | |
| 233 | | /******************************************************************************/ |
| 234 | | |
| 235 | | void battlera_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &clip,int pri) |
| 236 | | { |
| 237 | | int offs,my,mx,code,code2,fx,fy,cgy=0,cgx,colour,i,yinc; |
| 238 | | |
| 239 | | /* Draw sprites, starting at SATB, draw in _reverse_ order */ |
| 240 | | for (offs=(m_HuC6270_registers[19]<<1)+0x200-8; offs>=(m_HuC6270_registers[19]<<1); offs-=8) |
| 241 | | { |
| 242 | | if ((m_HuC6270_vram[offs+7]&0x80) && !pri) continue; |
| 243 | | if (!(m_HuC6270_vram[offs+7]&0x80) && pri) continue; |
| 244 | | |
| 245 | | code=m_HuC6270_vram[offs+5] + (m_HuC6270_vram[offs+4]<<8); |
| 246 | | code=code>>1; |
| 247 | | |
| 248 | | my=m_HuC6270_vram[offs+1] + (m_HuC6270_vram[offs+0]<<8); |
| 249 | | mx=m_HuC6270_vram[offs+3] + (m_HuC6270_vram[offs+2]<<8); |
| 250 | | |
| 251 | | mx-=32; |
| 252 | | my-=57; |
| 253 | | |
| 254 | | fx=m_HuC6270_vram[offs+6]&0x8; |
| 255 | | fy=m_HuC6270_vram[offs+6]&0x80; |
| 256 | | cgx=m_HuC6270_vram[offs+6]&1; |
| 257 | | colour=m_HuC6270_vram[offs+7]&0xf; |
| 258 | | |
| 259 | | switch ((m_HuC6270_vram[offs+6]>>4)&3) { |
| 260 | | case 0: cgy=1; break; |
| 261 | | case 1: cgy=2; break; |
| 262 | | case 2: cgy=0; break; /* Illegal */ |
| 263 | | case 3: cgy=4; break; |
| 264 | | } |
| 265 | | |
| 266 | | if (cgx && cgy==2) code=code&0x3fc; /* Title screen */ |
| 267 | | |
| 268 | | if (fx && cgx) {code2=code; code++;} /* Swap tile order on X flips */ |
| 269 | | else code2=code+1; |
| 270 | | |
| 271 | | yinc = 16; |
| 272 | | if (fy) { my += 16*(cgy-1); yinc = -16; } /* Swap tile order on Y flips */ |
| 273 | | |
| 274 | | for (i=0; i<cgy; i++) { |
| 275 | | m_gfxdecode->gfx(1)->transpen(bitmap,clip, |
| 276 | | code, |
| 277 | | colour, |
| 278 | | fx,fy, |
| 279 | | mx,my,0); |
| 280 | | |
| 281 | | if (cgx) |
| 282 | | m_gfxdecode->gfx(1)->transpen(bitmap,clip, |
| 283 | | code2, |
| 284 | | colour, |
| 285 | | fx,fy, |
| 286 | | mx+16,my,0); |
| 287 | | my += yinc; |
| 288 | | /* if (cgx) */ /* Different from console? */ |
| 289 | | code += 2; |
| 290 | | code2 += 2; |
| 291 | | /*else code += 1; */ /* Different from console? */ |
| 292 | | } |
| 293 | | } |
| 294 | | |
| 295 | | } |
| 296 | | |
| 297 | | /******************************************************************************/ |
| 298 | | |
| 299 | | UINT32 battlera_state::screen_update_battlera(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 300 | | { |
| 301 | | int offs,code,scrollx,scrolly,mx,my; |
| 302 | | |
| 303 | | /* if any tiles changed, redraw the VRAM */ |
| 304 | | if (m_gfxdecode->gfx(0)->dirtyseq() != m_tile_dirtyseq) |
| 305 | | { |
| 306 | | m_tile_dirtyseq = m_gfxdecode->gfx(0)->dirtyseq(); |
| 307 | | memset(m_vram_dirty, 1, 0x1000); |
| 308 | | } |
| 309 | | |
| 310 | | mx=-1; |
| 311 | | my=0; |
| 312 | | for (offs = 0x0000;offs < 0x2000;offs += 2) |
| 313 | | { |
| 314 | | mx++; |
| 315 | | if (mx==64) {mx=0; my++;} |
| 316 | | code=m_HuC6270_vram[offs+1] + ((m_HuC6270_vram[offs] & 0x0f) << 8); |
| 317 | | |
| 318 | | /* If this tile was changed OR tilemap was changed, redraw */ |
| 319 | | if (m_vram_dirty[offs/2]) { |
| 320 | | m_vram_dirty[offs/2]=0; |
| 321 | | m_gfxdecode->gfx(0)->opaque(*m_tile_bitmap,m_tile_bitmap->cliprect(), |
| 322 | | code, |
| 323 | | m_HuC6270_vram[offs] >> 4, |
| 324 | | 0,0, |
| 325 | | 8*mx,8*my); |
| 326 | | m_gfxdecode->gfx(2)->opaque(*m_front_bitmap,m_tile_bitmap->cliprect(), |
| 327 | | 0, |
| 328 | | 0, /* fill the spot with pen 256 */ |
| 329 | | 0,0, |
| 330 | | 8*mx,8*my); |
| 331 | | m_gfxdecode->gfx(0)->transmask(*m_front_bitmap,m_tile_bitmap->cliprect(), |
| 332 | | code, |
| 333 | | m_HuC6270_vram[offs] >> 4, |
| 334 | | 0,0, |
| 335 | | 8*mx,8*my,0x1); |
| 336 | | } |
| 337 | | } |
| 338 | | |
| 339 | | /* Render bitmap */ |
| 340 | | scrollx=-m_HuC6270_registers[7]; |
| 341 | | scrolly=-m_HuC6270_registers[8]+cliprect.min_y-1; |
| 342 | | |
| 343 | | copyscrollbitmap(bitmap,*m_tile_bitmap,1,&scrollx,1,&scrolly,cliprect); |
| 344 | | |
| 345 | | /* Todo: Background enable (not used anyway) */ |
| 346 | | |
| 347 | | /* Render low priority sprites, if enabled */ |
| 348 | | if (m_sb_enable) draw_sprites(bitmap,cliprect,0); |
| 349 | | |
| 350 | | /* Render background over sprites */ |
| 351 | | copyscrollbitmap_trans(bitmap,*m_front_bitmap,1,&scrollx,1,&scrolly,cliprect,256); |
| 352 | | |
| 353 | | /* Render high priority sprites, if enabled */ |
| 354 | | if (m_sb_enable) draw_sprites(bitmap,cliprect,1); |
| 355 | | |
| 356 | | return 0; |
| 357 | | } |
| 358 | | |
| 359 | | /******************************************************************************/ |
| 360 | | |
| 361 | | TIMER_DEVICE_CALLBACK_MEMBER(battlera_state::battlera_irq) |
| 362 | | { |
| 363 | | m_current_scanline = param; /* 8 lines clipped at top */ |
| 364 | | |
| 365 | | /* If raster interrupt occurs, refresh screen _up_ to this point */ |
| 366 | | if (m_rcr_enable && (m_current_scanline+56)==m_HuC6270_registers[6]) { |
| 367 | | m_screen->update_partial(m_current_scanline); |
| 368 | | m_maincpu->set_input_line(0, HOLD_LINE); /* RCR interrupt */ |
| 369 | | } |
| 370 | | |
| 371 | | /* Start of vblank */ |
| 372 | | else if (m_current_scanline==240) { |
| 373 | | m_bldwolf_vblank=1; |
| 374 | | m_screen->update_partial(240); |
| 375 | | if (m_irq_enable) |
| 376 | | m_maincpu->set_input_line(0, HOLD_LINE); /* VBL */ |
| 377 | | } |
| 378 | | |
| 379 | | /* End of vblank */ |
| 380 | | if (m_current_scanline==254) { |
| 381 | | m_bldwolf_vblank=0; |
| 382 | | } |
| 383 | | } |
trunk/src/mame/drivers/battlera.c
| r32530 | r32531 | |
| 13 | 13 | Twice as much VRAM. |
| 14 | 14 | |
| 15 | 15 | Todo: |
| 16 | | - Convert this driver to use proper PC-Engine video. |
| 17 | | - Priority is wrong for the submarine at the end of level 1. |
| 18 | 16 | - There seems to be a bug with a stuck note from the YM2203 FM channel |
| 19 | 17 | at the start of scene 3 and near the ending when your characters are |
| 20 | 18 | flying over a forest in a helicopter. |
| r32530 | r32531 | |
| 65 | 63 | |
| 66 | 64 | static ADDRESS_MAP_START( battlera_map, AS_PROGRAM, 8, battlera_state ) |
| 67 | 65 | AM_RANGE(0x000000, 0x0fffff) AM_ROM |
| 68 | | AM_RANGE(0x100000, 0x10ffff) AM_READWRITE(HuC6270_debug_r, HuC6270_debug_w) /* Cheat to edit vram data */ |
| 69 | 66 | AM_RANGE(0x1e0800, 0x1e0801) AM_WRITE(battlera_sound_w) |
| 70 | | AM_RANGE(0x1e1000, 0x1e13ff) AM_WRITE(battlera_palette_w) AM_SHARE("paletteram") |
| 67 | AM_RANGE(0x1e1000, 0x1e13ff) AM_DEVREADWRITE( "huc6260", huc6260_device, palette_direct_read, palette_direct_write) AM_SHARE("paletteram") |
| 71 | 68 | AM_RANGE(0x1f0000, 0x1f1fff) AM_RAMBANK("bank8") /* Main ram */ |
| 72 | | AM_RANGE(0x1fe000, 0x1fe001) AM_READWRITE(HuC6270_register_r, HuC6270_register_w) |
| 73 | | AM_RANGE(0x1fe002, 0x1fe003) AM_WRITE(HuC6270_data_w) |
| 74 | 69 | AM_RANGE(0x1ff000, 0x1ff001) AM_READWRITE(control_data_r, control_data_w) |
| 75 | | AM_RANGE(0x1ff400, 0x1ff403) AM_DEVWRITE("maincpu", h6280_device, irq_status_w) |
| 70 | |
| 71 | AM_RANGE( 0x1FE000, 0x1FE3FF) AM_DEVREADWRITE( "huc6270", huc6270_device, read, write ) |
| 72 | AM_RANGE( 0x1FE400, 0x1FE7FF) AM_DEVREADWRITE( "huc6260", huc6260_device, read, write ) |
| 73 | AM_RANGE( 0x1FEC00, 0x1FEFFF) AM_DEVREADWRITE( "maincpu", h6280_device, timer_r, timer_w ) |
| 74 | AM_RANGE( 0x1FF400, 0x1FF7FF) AM_DEVREADWRITE( "maincpu", h6280_device, irq_status_r, irq_status_w ) |
| 75 | |
| 76 | 76 | ADDRESS_MAP_END |
| 77 | 77 | |
| 78 | 78 | static ADDRESS_MAP_START( battlera_portmap, AS_IO, 8, battlera_state ) |
| 79 | | AM_RANGE(0x00, 0x01) AM_WRITE(HuC6270_register_w) |
| 80 | | AM_RANGE(0x02, 0x03) AM_WRITE(HuC6270_data_w) |
| 79 | AM_RANGE( 0x00, 0x03) AM_DEVREADWRITE( "huc6270", huc6270_device, read, write ) |
| 81 | 80 | ADDRESS_MAP_END |
| 82 | 81 | |
| 83 | 82 | /******************************************************************************/ |
| r32530 | r32531 | |
| 179 | 178 | PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW2:8" ) /* Listed as "Unused" */ |
| 180 | 179 | INPUT_PORTS_END |
| 181 | 180 | |
| 181 | |
| 182 | 182 | /******************************************************************************/ |
| 183 | 183 | |
| 184 | | static const gfx_layout tiles = |
| 184 | WRITE_LINE_MEMBER(battlera_state::pce_irq_changed) |
| 185 | 185 | { |
| 186 | | 8,8, |
| 187 | | 4096, |
| 188 | | 4, |
| 189 | | { 16*8, 16*8+8, 0, 8 }, |
| 190 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 191 | | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 }, |
| 192 | | 32*8 |
| 193 | | }; |
| 186 | m_maincpu->set_input_line(0, state); |
| 187 | } |
| 194 | 188 | |
| 195 | | static const gfx_layout sprites = |
| 189 | UINT32 battlera_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 196 | 190 | { |
| 197 | | 16,16, |
| 198 | | 1024, |
| 199 | | 4, |
| 200 | | { 96*8, 64*8, 32*8, 0 }, |
| 201 | | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, |
| 202 | | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16, |
| 203 | | 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, |
| 204 | | 128*8 |
| 205 | | }; |
| 191 | m_huc6260->video_update( bitmap, cliprect ); |
| 192 | return 0; |
| 193 | } |
| 206 | 194 | |
| 207 | | static GFXDECODE_START( battlera ) |
| 208 | | GFXDECODE_ENTRY( NULL, 0, tiles, 0, 16 ) /* Dynamically modified */ |
| 209 | | GFXDECODE_ENTRY( NULL, 0, sprites, 256, 16 ) /* Dynamically modified */ |
| 210 | | GFXDECODE_ENTRY( NULL, 0, tiles , 256, 16 ) /* Blank tile */ |
| 211 | | GFXDECODE_END |
| 212 | 195 | |
| 213 | | /******************************************************************************/ |
| 214 | | |
| 215 | 196 | static MACHINE_CONFIG_START( battlera, battlera_state ) |
| 216 | 197 | |
| 217 | 198 | /* basic machine hardware */ |
| 218 | 199 | MCFG_CPU_ADD("maincpu", H6280,21477200/3) |
| 219 | 200 | MCFG_CPU_PROGRAM_MAP(battlera_map) |
| 220 | 201 | MCFG_CPU_IO_MAP(battlera_portmap) |
| 221 | | MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", battlera_state, battlera_irq, "screen", 0, 1) /* 8 prelines, 232 lines, 16 vblank? */ |
| 222 | 202 | |
| 223 | 203 | MCFG_CPU_ADD("audiocpu", H6280,21477200/3) |
| 224 | 204 | MCFG_CPU_PROGRAM_MAP(sound_map) |
| 225 | 205 | |
| 226 | 206 | /* video hardware */ |
| 227 | 207 | MCFG_SCREEN_ADD("screen", RASTER) |
| 228 | | MCFG_SCREEN_REFRESH_RATE(60) |
| 229 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) |
| 230 | | MCFG_SCREEN_SIZE(32*8, 32*8) |
| 231 | | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 30*8-1) |
| 232 | | MCFG_SCREEN_UPDATE_DRIVER(battlera_state, screen_update_battlera) |
| 233 | | MCFG_SCREEN_PALETTE("palette") |
| 208 | MCFG_SCREEN_RAW_PARAMS(MAIN_CLOCK, HUC6260_WPF, 64, 64 + 1024 + 64, HUC6260_LPF, 18, 18 + 242) |
| 209 | MCFG_SCREEN_UPDATE_DRIVER( battlera_state, screen_update ) |
| 210 | MCFG_SCREEN_PALETTE("huc6260:palette") |
| 234 | 211 | |
| 235 | | MCFG_GFXDECODE_ADD("gfxdecode", "palette", battlera) |
| 236 | | MCFG_PALETTE_ADD("palette", 512) |
| 212 | MCFG_DEVICE_ADD( "huc6260", HUC6260, MAIN_CLOCK ) |
| 213 | MCFG_HUC6260_NEXT_PIXEL_DATA_CB(DEVREAD16("huc6270", huc6270_device, next_pixel)) |
| 214 | MCFG_HUC6260_TIME_TIL_NEXT_EVENT_CB(DEVREAD16("huc6270", huc6270_device, time_until_next_event)) |
| 215 | MCFG_HUC6260_VSYNC_CHANGED_CB(DEVWRITELINE("huc6270", huc6270_device, vsync_changed)) |
| 216 | MCFG_HUC6260_HSYNC_CHANGED_CB(DEVWRITELINE("huc6270", huc6270_device, hsync_changed)) |
| 237 | 217 | |
| 218 | MCFG_DEVICE_ADD( "huc6270", HUC6270, 0 ) |
| 219 | MCFG_HUC6270_VRAM_SIZE(0x20000) |
| 220 | MCFG_HUC6270_IRQ_CHANGED_CB(WRITELINE(battlera_state, pce_irq_changed)) |
| 238 | 221 | |
| 222 | |
| 239 | 223 | /* sound hardware */ |
| 240 | 224 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 241 | 225 | |