trunk/src/mame/drivers/galaxia.c
| r24875 | r24876 | |
| 61 | 61 | */ |
| 62 | 62 | |
| 63 | 63 | #include "emu.h" |
| 64 | | #include "video/s2636.h" |
| 65 | 64 | #include "sound/s2636.h" |
| 66 | 65 | #include "cpu/s2650/s2650.h" |
| 67 | 66 | #include "includes/galaxia.h" |
| r24875 | r24876 | |
| 123 | 122 | static ADDRESS_MAP_START( galaxia_mem_map, AS_PROGRAM, 8, galaxia_state ) |
| 124 | 123 | AM_RANGE(0x0000, 0x13ff) AM_ROM |
| 125 | 124 | AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("bullet_ram") |
| 126 | | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w) |
| 127 | | AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w) |
| 128 | | AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_2", s2636_work_ram_r, s2636_work_ram_w) |
| 125 | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w) |
| 126 | AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w) |
| 127 | AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_2", s2636_device, work_ram_r, work_ram_w) |
| 129 | 128 | AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READ(cvs_video_or_color_ram_r) AM_WRITE(galaxia_video_w) AM_SHARE("video_ram") |
| 130 | 129 | AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM |
| 131 | 130 | AM_RANGE(0x2000, 0x33ff) AM_ROM |
| r24875 | r24876 | |
| 135 | 134 | static ADDRESS_MAP_START( astrowar_mem_map, AS_PROGRAM, 8, galaxia_state ) |
| 136 | 135 | AM_RANGE(0x0000, 0x13ff) AM_ROM |
| 137 | 136 | AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_RAM |
| 138 | | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w) |
| 137 | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w) |
| 139 | 138 | AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READ(cvs_video_or_color_ram_r) AM_WRITE(galaxia_video_w) AM_SHARE("video_ram") |
| 140 | 139 | AM_RANGE(0x1c00, 0x1cff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("bullet_ram") |
| 141 | 140 | AM_RANGE(0x2000, 0x33ff) AM_ROM |
| r24875 | r24876 | |
| 277 | 276 | |
| 278 | 277 | static const s2636_interface galaxia_s2636_config[3] = |
| 279 | 278 | { |
| 280 | | { "screen", 0x100, 3, -26, "s2636snd_0" }, |
| 281 | | { "screen", 0x100, 3, -26, "s2636snd_1" }, |
| 282 | | { "screen", 0x100, 3, -26, "s2636snd_2" } |
| 279 | { 0x100, 3, -26, "s2636snd_0" }, |
| 280 | { 0x100, 3, -26, "s2636snd_1" }, |
| 281 | { 0x100, 3, -26, "s2636snd_2" } |
| 283 | 282 | }; |
| 284 | 283 | |
| 285 | 284 | static const s2636_interface astrowar_s2636_config = |
| 286 | 285 | { |
| 287 | | "screen", |
| 288 | 286 | 0x100, |
| 289 | 287 | 3, 0, |
| 290 | 288 | "s2636snd_0" |
trunk/src/mame/drivers/malzak.c
| r24875 | r24876 | |
| 66 | 66 | #include "cpu/s2650/s2650.h" |
| 67 | 67 | #include "sound/sn76477.h" |
| 68 | 68 | #include "sound/s2636.h" |
| 69 | | #include "video/s2636.h" |
| 70 | 69 | #include "video/saa5050.h" |
| 71 | 70 | #include "machine/nvram.h" |
| 72 | 71 | #include "includes/malzak.h" |
| r24875 | r24876 | |
| 74 | 73 | |
| 75 | 74 | READ8_MEMBER(malzak_state::fake_VRLE_r) |
| 76 | 75 | { |
| 77 | | return (s2636_work_ram_r(m_s2636_0, space, 0xcb) & 0x3f) + (m_screen->vblank() * 0x40); |
| 76 | return (m_s2636_0->work_ram_r(space, 0xcb) & 0x3f) + (m_screen->vblank() * 0x40); |
| 78 | 77 | } |
| 79 | 78 | |
| 80 | 79 | READ8_MEMBER(malzak_state::s2636_portA_r) |
| r24875 | r24876 | |
| 106 | 105 | AM_RANGE(0x1200, 0x12ff) AM_MIRROR(0x6000) AM_RAM |
| 107 | 106 | AM_RANGE(0x1300, 0x13ff) AM_MIRROR(0x6000) AM_RAM |
| 108 | 107 | AM_RANGE(0x14cb, 0x14cb) AM_MIRROR(0x6000) AM_READ(fake_VRLE_r) |
| 109 | | AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w) |
| 110 | | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w) |
| 108 | AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w) |
| 109 | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w) |
| 111 | 110 | AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_RAM_WRITE(malzak_playfield_w) |
| 112 | 111 | AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_RAM |
| 113 | 112 | AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("videoram") |
| r24875 | r24876 | |
| 127 | 126 | AM_RANGE(0x1300, 0x13ff) AM_MIRROR(0x6000) AM_RAM |
| 128 | 127 | AM_RANGE(0x14cb, 0x14cb) AM_MIRROR(0x6000) AM_READ(fake_VRLE_r) |
| 129 | 128 | AM_RANGE(0x14cc, 0x14cc) AM_MIRROR(0x6000) AM_READ(s2636_portA_r) |
| 130 | | AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w) |
| 131 | | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w) |
| 129 | AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w) |
| 130 | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w) |
| 132 | 131 | AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_RAM_WRITE(malzak_playfield_w) |
| 133 | 132 | AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("nvram") |
| 134 | 133 | AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("videoram") |
| r24875 | r24876 | |
| 303 | 302 | |
| 304 | 303 | static const s2636_interface malzac_s2636_0_config = |
| 305 | 304 | { |
| 306 | | "screen", |
| 307 | 305 | 0x100, |
| 308 | 306 | 0, -16, /* -8, -16 */ |
| 309 | 307 | "s2636snd_0" |
| r24875 | r24876 | |
| 311 | 309 | |
| 312 | 310 | static const s2636_interface malzac_s2636_1_config = |
| 313 | 311 | { |
| 314 | | "screen", |
| 315 | 312 | 0x100, |
| 316 | 313 | 0, -16, /* -9, -16 */ |
| 317 | 314 | "s2636snd_1" |
| r24875 | r24876 | |
| 332 | 329 | { |
| 333 | 330 | membank("bank1")->configure_entries(0, 2, memregion("user2")->base(), 0x400); |
| 334 | 331 | |
| 335 | | m_s2636_0 = machine().device("s2636_0"); |
| 336 | | m_s2636_1 = machine().device("s2636_1"); |
| 337 | 332 | m_saa5050 = machine().device("saa5050"); |
| 338 | 333 | |
| 339 | 334 | save_item(NAME(m_playfield_code)); |
trunk/src/mame/drivers/laserbat.c
| r24875 | r24876 | |
| 22 | 22 | #include "machine/6821pia.h" |
| 23 | 23 | #include "sound/sn76477.h" |
| 24 | 24 | #include "sound/tms3615.h" |
| 25 | | #include "video/s2636.h" |
| 26 | 25 | #include "includes/laserbat.h" |
| 27 | 26 | |
| 28 | 27 | |
| r24875 | r24876 | |
| 165 | 164 | AM_RANGE(0x7800, 0x7bff) AM_ROM |
| 166 | 165 | |
| 167 | 166 | AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_WRITENOP // always 0 (bullet ram in Quasar) |
| 168 | | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w) |
| 169 | | AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_2", s2636_work_ram_r, s2636_work_ram_w) |
| 170 | | AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_3", s2636_work_ram_r, s2636_work_ram_w) |
| 167 | AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w) |
| 168 | AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_2", s2636_device, work_ram_r, work_ram_w) |
| 169 | AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_3", s2636_device, work_ram_r, work_ram_w) |
| 171 | 170 | AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_WRITE(laserbat_videoram_w) |
| 172 | 171 | AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM |
| 173 | 172 | ADDRESS_MAP_END |
| r24875 | r24876 | |
| 498 | 497 | m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 499 | 498 | |
| 500 | 499 | /* update the S2636 chips */ |
| 501 | | bitmap_ind16 &s2636_1_bitmap = s2636_update(m_s2636_1, cliprect); |
| 502 | | bitmap_ind16 &s2636_2_bitmap = s2636_update(m_s2636_2, cliprect); |
| 503 | | bitmap_ind16 &s2636_3_bitmap = s2636_update(m_s2636_3, cliprect); |
| 500 | bitmap_ind16 &s2636_1_bitmap = m_s2636_1->update(cliprect); |
| 501 | bitmap_ind16 &s2636_2_bitmap = m_s2636_2->update(cliprect); |
| 502 | bitmap_ind16 &s2636_3_bitmap = m_s2636_3->update(cliprect); |
| 504 | 503 | |
| 505 | 504 | /* copy the S2636 images into the main bitmap */ |
| 506 | 505 | for (y = cliprect.min_y; y <= cliprect.max_y; y++) |
| r24875 | r24876 | |
| 657 | 656 | |
| 658 | 657 | static const s2636_interface s2636_1_config = |
| 659 | 658 | { |
| 660 | | "screen", |
| 661 | 659 | 0x100, |
| 662 | 660 | 0, -19, |
| 663 | 661 | NULL |
| r24875 | r24876 | |
| 665 | 663 | |
| 666 | 664 | static const s2636_interface s2636_2_config = |
| 667 | 665 | { |
| 668 | | "screen", |
| 669 | 666 | 0x100, |
| 670 | 667 | 0, -19, |
| 671 | 668 | NULL |
| r24875 | r24876 | |
| 673 | 670 | |
| 674 | 671 | static const s2636_interface s2636_3_config = |
| 675 | 672 | { |
| 676 | | "screen", |
| 677 | 673 | 0x100, |
| 678 | 674 | 0, -19, |
| 679 | 675 | NULL |
| r24875 | r24876 | |
| 681 | 677 | |
| 682 | 678 | void laserbat_state::machine_start() |
| 683 | 679 | { |
| 684 | | m_s2636_1 = machine().device("s2636_1"); |
| 685 | | m_s2636_2 = machine().device("s2636_2"); |
| 686 | | m_s2636_3 = machine().device("s2636_3"); |
| 687 | 680 | m_pia = machine().device<pia6821_device>("pia"); |
| 688 | 681 | m_sn = machine().device("snsnd"); |
| 689 | 682 | m_tms1 = machine().device<tms3615_device>("tms1"); |
trunk/src/emu/video/s2636.c
| r24875 | r24876 | |
| 78 | 78 | #include "emu.h" |
| 79 | 79 | #include "video/s2636.h" |
| 80 | 80 | #include "sound/s2636.h" |
| 81 | | #include "devlegcy.h" |
| 82 | 81 | |
| 82 | |
| 83 | |
| 83 | 84 | /************************************* |
| 84 | 85 | * |
| 85 | | * Constants |
| 86 | * Device interface |
| 86 | 87 | * |
| 87 | 88 | *************************************/ |
| 88 | 89 | |
| 89 | | #define SPRITE_WIDTH (8) |
| 90 | | #define SPRITE_HEIGHT (10) |
| 90 | const device_type S2636 = &device_creator<s2636_device>; |
| 91 | 91 | |
| 92 | | static const int sprite_offsets[4] = { 0x00, 0x10, 0x20, 0x40 }; |
| 92 | s2636_device::s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 93 | : device_t(mconfig, S2636, "Signetics 2636", tag, owner, clock, "s2636", __FILE__), |
| 94 | device_video_interface(mconfig, *this), |
| 95 | m_work_ram(NULL), |
| 96 | m_bitmap(NULL), |
| 97 | m_collision_bitmap(NULL) |
| 98 | { |
| 99 | } |
| 93 | 100 | |
| 94 | | /************************************* |
| 95 | | * |
| 96 | | * Internal S2636 data structure |
| 97 | | * |
| 98 | | *************************************/ |
| 101 | //------------------------------------------------- |
| 102 | // device_config_complete - perform any |
| 103 | // operations now that the configuration is |
| 104 | // complete |
| 105 | //------------------------------------------------- |
| 99 | 106 | |
| 100 | | struct s2636_state |
| 107 | void s2636_device::device_config_complete() |
| 101 | 108 | { |
| 102 | | UINT8 *work_ram; |
| 103 | | int work_ram_size; |
| 104 | | int y_offset; |
| 105 | | int x_offset; |
| 109 | // inherit a copy of the static data |
| 110 | const s2636_interface *intf = reinterpret_cast<const s2636_interface *>(static_config()); |
| 111 | if (intf != NULL) |
| 112 | *static_cast<s2636_interface *>(this) = *intf; |
| 106 | 113 | |
| 107 | | bitmap_ind16 *bitmap; |
| 108 | | bitmap_ind16 *collision_bitmap; |
| 109 | | }; |
| 114 | // or initialize to defaults if none provided |
| 115 | else |
| 116 | { |
| 117 | m_work_ram_size = 0; |
| 118 | m_y_offset = 0; |
| 119 | m_x_offset = 0; |
| 120 | m_sound_tag = ""; |
| 121 | } |
| 122 | } |
| 110 | 123 | |
| 124 | //------------------------------------------------- |
| 125 | // device_start - device-specific startup |
| 126 | //------------------------------------------------- |
| 127 | |
| 128 | void s2636_device::device_start() |
| 129 | { |
| 130 | int width = m_screen->width(); |
| 131 | int height = m_screen->height(); |
| 132 | |
| 133 | m_work_ram = auto_alloc_array_clear(machine(), UINT8, m_work_ram_size); |
| 134 | m_bitmap = auto_bitmap_ind16_alloc(machine(), width, height); |
| 135 | m_collision_bitmap = auto_bitmap_ind16_alloc(machine(), width, height); |
| 136 | |
| 137 | save_item(NAME(m_x_offset)); |
| 138 | save_item(NAME(m_y_offset)); |
| 139 | save_pointer(NAME(m_work_ram), m_work_ram_size); |
| 140 | save_item(NAME(*m_bitmap)); |
| 141 | save_item(NAME(*m_collision_bitmap)); |
| 142 | } |
| 143 | |
| 111 | 144 | /************************************* |
| 112 | 145 | * |
| 113 | | * Inline functions |
| 146 | * Constants |
| 114 | 147 | * |
| 115 | 148 | *************************************/ |
| 116 | 149 | |
| 117 | | INLINE s2636_state *get_safe_token( device_t *device ) |
| 118 | | { |
| 119 | | assert(device != NULL); |
| 120 | | assert(device->type() == S2636); |
| 150 | #define SPRITE_WIDTH (8) |
| 151 | #define SPRITE_HEIGHT (10) |
| 121 | 152 | |
| 122 | | return (s2636_state *)downcast<s2636_device *>(device)->token(); |
| 123 | | } |
| 153 | static const int sprite_offsets[4] = { 0x00, 0x10, 0x20, 0x40 }; |
| 124 | 154 | |
| 125 | | INLINE const s2636_interface *get_interface( device_t *device ) |
| 126 | | { |
| 127 | | assert(device != NULL); |
| 128 | | assert((device->type() == S2636)); |
| 129 | | return (const s2636_interface *) device->static_config(); |
| 130 | | } |
| 131 | 155 | |
| 132 | 156 | |
| 157 | |
| 133 | 158 | /************************************* |
| 134 | 159 | * |
| 135 | 160 | * Draw a sprite |
| r24875 | r24876 | |
| 187 | 212 | * |
| 188 | 213 | *************************************/ |
| 189 | 214 | |
| 190 | | static int check_collision( device_t *device, int spriteno1, int spriteno2, const rectangle &cliprect ) |
| 215 | int s2636_device::check_collision( int spriteno1, int spriteno2, const rectangle &cliprect ) |
| 191 | 216 | { |
| 192 | | s2636_state *s2636 = get_safe_token(device); |
| 193 | 217 | int checksum = 0; |
| 194 | 218 | |
| 195 | | UINT8* attr1 = &s2636->work_ram[sprite_offsets[spriteno1]]; |
| 196 | | UINT8* attr2 = &s2636->work_ram[sprite_offsets[spriteno2]]; |
| 219 | UINT8* attr1 = &m_work_ram[sprite_offsets[spriteno1]]; |
| 220 | UINT8* attr2 = &m_work_ram[sprite_offsets[spriteno2]]; |
| 197 | 221 | |
| 198 | 222 | /* TODO: does not check shadow sprites yet */ |
| 199 | 223 | |
| 200 | | s2636->collision_bitmap->fill(0, cliprect); |
| 224 | m_collision_bitmap->fill(0, cliprect); |
| 201 | 225 | |
| 202 | 226 | if ((attr1[0x0a] != 0xff) && (attr2[0x0a] != 0xff)) |
| 203 | 227 | { |
| 204 | 228 | int x, y; |
| 205 | 229 | |
| 206 | | int x1 = attr1[0x0a] + s2636->x_offset; |
| 207 | | int y1 = attr1[0x0c] + s2636->y_offset; |
| 208 | | int x2 = attr2[0x0a] + s2636->x_offset; |
| 209 | | int y2 = attr2[0x0c] + s2636->y_offset; |
| 230 | int x1 = attr1[0x0a] + m_x_offset; |
| 231 | int y1 = attr1[0x0c] + m_y_offset; |
| 232 | int x2 = attr2[0x0a] + m_x_offset; |
| 233 | int y2 = attr2[0x0c] + m_y_offset; |
| 210 | 234 | |
| 211 | | int expand1 = (s2636->work_ram[0xc0] >> (spriteno1 << 1)) & 0x03; |
| 212 | | int expand2 = (s2636->work_ram[0xc0] >> (spriteno2 << 1)) & 0x03; |
| 235 | int expand1 = (m_work_ram[0xc0] >> (spriteno1 << 1)) & 0x03; |
| 236 | int expand2 = (m_work_ram[0xc0] >> (spriteno2 << 1)) & 0x03; |
| 213 | 237 | |
| 214 | 238 | /* draw first sprite */ |
| 215 | | draw_sprite(attr1, 1, y1, x1, expand1, FALSE, *s2636->collision_bitmap, cliprect); |
| 239 | draw_sprite(attr1, 1, y1, x1, expand1, FALSE, *m_collision_bitmap, cliprect); |
| 216 | 240 | |
| 217 | 241 | /* get fingerprint */ |
| 218 | 242 | for (x = x1; x < x1 + SPRITE_WIDTH; x++) |
| r24875 | r24876 | |
| 221 | 245 | if (!cliprect.contains(x, y)) |
| 222 | 246 | continue; |
| 223 | 247 | |
| 224 | | checksum = checksum + s2636->collision_bitmap->pix16(y, x); |
| 248 | checksum = checksum + m_collision_bitmap->pix16(y, x); |
| 225 | 249 | } |
| 226 | 250 | |
| 227 | 251 | /* black out second sprite */ |
| 228 | | draw_sprite(attr2, 0, y2, x2, expand2, FALSE, *s2636->collision_bitmap, cliprect); |
| 252 | draw_sprite(attr2, 0, y2, x2, expand2, FALSE, *m_collision_bitmap, cliprect); |
| 229 | 253 | |
| 230 | 254 | /* remove fingerprint */ |
| 231 | 255 | for (x = x1; x < x1 + SPRITE_WIDTH; x++) |
| r24875 | r24876 | |
| 234 | 258 | if (!cliprect.contains(x, y)) |
| 235 | 259 | continue; |
| 236 | 260 | |
| 237 | | checksum = checksum - s2636->collision_bitmap->pix16(y, x); |
| 261 | checksum = checksum - m_collision_bitmap->pix16(y, x); |
| 238 | 262 | } |
| 239 | 263 | } |
| 240 | 264 | |
| r24875 | r24876 | |
| 249 | 273 | * |
| 250 | 274 | *************************************/ |
| 251 | 275 | |
| 252 | | bitmap_ind16 &s2636_update( device_t *device, const rectangle &cliprect ) |
| 276 | bitmap_ind16 &s2636_device::update( const rectangle &cliprect ) |
| 253 | 277 | { |
| 254 | | s2636_state *s2636 = get_safe_token(device); |
| 255 | 278 | UINT8 collision = 0; |
| 256 | 279 | int spriteno; |
| 257 | 280 | |
| 258 | | s2636->bitmap->fill(0, cliprect); |
| 281 | m_bitmap->fill(0, cliprect); |
| 259 | 282 | |
| 260 | 283 | for (spriteno = 0; spriteno < 4; spriteno++) |
| 261 | 284 | { |
| 262 | 285 | int color, expand, x, y; |
| 263 | | UINT8* attr = &s2636->work_ram[sprite_offsets[spriteno]]; |
| 286 | UINT8* attr = &m_work_ram[sprite_offsets[spriteno]]; |
| 264 | 287 | |
| 265 | 288 | /* get out if sprite is turned off */ |
| 266 | 289 | if (attr[0x0a] == 0xff) |
| 267 | 290 | continue; |
| 268 | 291 | |
| 269 | | x = attr[0x0a] + s2636->x_offset; |
| 270 | | y = attr[0x0c] + s2636->y_offset; |
| 292 | x = attr[0x0a] + m_x_offset; |
| 293 | y = attr[0x0c] + m_y_offset; |
| 271 | 294 | |
| 272 | | color = (s2636->work_ram[0xc1 + (spriteno >> 1)] >> ((spriteno & 1) ? 0 : 3)) & 0x07; |
| 273 | | expand = (s2636->work_ram[0xc0] >> (spriteno << 1)) & 0x03; |
| 295 | color = (m_work_ram[0xc1 + (spriteno >> 1)] >> ((spriteno & 1) ? 0 : 3)) & 0x07; |
| 296 | expand = (m_work_ram[0xc0] >> (spriteno << 1)) & 0x03; |
| 274 | 297 | |
| 275 | | draw_sprite(attr, color, y, x, expand, TRUE, *s2636->bitmap, cliprect); |
| 298 | draw_sprite(attr, color, y, x, expand, TRUE, *m_bitmap, cliprect); |
| 276 | 299 | |
| 277 | 300 | /* bail if no shadow sprites */ |
| 278 | 301 | if ((attr[0x0b] == 0xff) || (attr[0x0d] == 0xfe)) |
| 279 | 302 | continue; |
| 280 | 303 | |
| 281 | | x = attr[0x0b] + s2636->x_offset; |
| 304 | x = attr[0x0b] + m_x_offset; |
| 282 | 305 | |
| 283 | 306 | while (y < 0xff) |
| 284 | 307 | { |
| 285 | 308 | y = y + SPRITE_HEIGHT + attr[0x0d]; |
| 286 | 309 | |
| 287 | | draw_sprite(attr, color, y, x, expand, TRUE, *s2636->bitmap, cliprect); |
| 310 | draw_sprite(attr, color, y, x, expand, TRUE, *m_bitmap, cliprect); |
| 288 | 311 | } |
| 289 | 312 | } |
| 290 | 313 | |
| 291 | 314 | /* collision detection */ |
| 292 | | if (check_collision(device, 0, 1, cliprect)) collision |= 0x20; |
| 293 | | if (check_collision(device, 0, 2, cliprect)) collision |= 0x10; |
| 294 | | if (check_collision(device, 0, 3, cliprect)) collision |= 0x08; |
| 295 | | if (check_collision(device, 1, 2, cliprect)) collision |= 0x04; |
| 296 | | if (check_collision(device, 1, 3, cliprect)) collision |= 0x02; |
| 297 | | if (check_collision(device, 2, 3, cliprect)) collision |= 0x01; |
| 315 | if (check_collision(0, 1, cliprect)) collision |= 0x20; |
| 316 | if (check_collision(0, 2, cliprect)) collision |= 0x10; |
| 317 | if (check_collision(0, 3, cliprect)) collision |= 0x08; |
| 318 | if (check_collision(1, 2, cliprect)) collision |= 0x04; |
| 319 | if (check_collision(1, 3, cliprect)) collision |= 0x02; |
| 320 | if (check_collision(2, 3, cliprect)) collision |= 0x01; |
| 298 | 321 | |
| 299 | | s2636->work_ram[0xcb] = collision; |
| 322 | m_work_ram[0xcb] = collision; |
| 300 | 323 | |
| 301 | | return *s2636->bitmap; |
| 324 | return *m_bitmap; |
| 302 | 325 | } |
| 303 | 326 | |
| 304 | 327 | |
| r24875 | r24876 | |
| 308 | 331 | * |
| 309 | 332 | *************************************/ |
| 310 | 333 | |
| 311 | | WRITE8_DEVICE_HANDLER( s2636_work_ram_w ) |
| 334 | WRITE8_MEMBER( s2636_device::work_ram_w ) |
| 312 | 335 | { |
| 313 | | s2636_state *s2636 = get_safe_token(device); |
| 336 | assert(offset < m_work_ram_size); |
| 314 | 337 | |
| 315 | | assert(offset < s2636->work_ram_size); |
| 316 | | |
| 317 | 338 | if ( offset == 0xc7 ) |
| 318 | 339 | { |
| 319 | | const s2636_interface *intf = get_interface(device); |
| 320 | | if ( intf->sound && *intf->sound ) |
| 340 | if ( m_sound_tag && *m_sound_tag ) |
| 321 | 341 | { |
| 322 | | device->machine().device<s2636_sound_device>(intf->sound)->soundport_w(0, data); |
| 342 | machine().device<s2636_sound_device>(m_sound_tag)->soundport_w(0, data); |
| 323 | 343 | } |
| 324 | 344 | } |
| 325 | 345 | |
| 326 | | s2636->work_ram[offset] = data; |
| 346 | m_work_ram[offset] = data; |
| 327 | 347 | } |
| 328 | 348 | |
| 329 | 349 | |
| 330 | | READ8_DEVICE_HANDLER( s2636_work_ram_r ) |
| 350 | READ8_MEMBER( s2636_device::work_ram_r ) |
| 331 | 351 | { |
| 332 | | s2636_state *s2636 = get_safe_token(device); |
| 352 | assert(offset < m_work_ram_size); |
| 333 | 353 | |
| 334 | | assert(offset < s2636->work_ram_size); |
| 335 | | |
| 336 | | return s2636->work_ram[offset]; |
| 354 | return m_work_ram[offset]; |
| 337 | 355 | } |
| 338 | | |
| 339 | | /************************************* |
| 340 | | * |
| 341 | | * Device interface |
| 342 | | * |
| 343 | | *************************************/ |
| 344 | | |
| 345 | | static DEVICE_START( s2636 ) |
| 346 | | { |
| 347 | | s2636_state *s2636 = get_safe_token(device); |
| 348 | | const s2636_interface *intf = get_interface(device); |
| 349 | | screen_device *screen = downcast<screen_device *>(device->machine().device(intf->screen)); |
| 350 | | int width = screen->width(); |
| 351 | | int height = screen->height(); |
| 352 | | |
| 353 | | s2636->work_ram_size = intf->work_ram_size; |
| 354 | | s2636->x_offset = intf->x_offset; |
| 355 | | s2636->y_offset = intf->y_offset; |
| 356 | | |
| 357 | | s2636->work_ram = auto_alloc_array_clear(device->machine(), UINT8, intf->work_ram_size); |
| 358 | | s2636->bitmap = auto_bitmap_ind16_alloc(device->machine(), width, height); |
| 359 | | s2636->collision_bitmap = auto_bitmap_ind16_alloc(device->machine(), width, height); |
| 360 | | |
| 361 | | device->save_item(NAME(s2636->x_offset)); |
| 362 | | device->save_item(NAME(s2636->y_offset)); |
| 363 | | device->save_pointer(NAME(s2636->work_ram), s2636->work_ram_size); |
| 364 | | device->save_item(NAME(*s2636->bitmap)); |
| 365 | | device->save_item(NAME(*s2636->collision_bitmap)); |
| 366 | | } |
| 367 | | |
| 368 | | const device_type S2636 = &device_creator<s2636_device>; |
| 369 | | |
| 370 | | s2636_device::s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 371 | | : device_t(mconfig, S2636, "Signetics 2636", tag, owner, clock, "s2636", __FILE__) |
| 372 | | { |
| 373 | | m_token = global_alloc_clear(s2636_state); |
| 374 | | } |
| 375 | | |
| 376 | | //------------------------------------------------- |
| 377 | | // device_config_complete - perform any |
| 378 | | // operations now that the configuration is |
| 379 | | // complete |
| 380 | | //------------------------------------------------- |
| 381 | | |
| 382 | | void s2636_device::device_config_complete() |
| 383 | | { |
| 384 | | } |
| 385 | | |
| 386 | | //------------------------------------------------- |
| 387 | | // device_start - device-specific startup |
| 388 | | //------------------------------------------------- |
| 389 | | |
| 390 | | void s2636_device::device_start() |
| 391 | | { |
| 392 | | DEVICE_START_NAME( s2636 )(this); |
| 393 | | } |