trunk/src/mame/includes/zac2650.h
| r24774 | r24775 | |
| 1 | #include "sound/s2636.h" |
| 2 | |
| 1 | 3 | class zac2650_state : public driver_device |
| 2 | 4 | { |
| 3 | 5 | public: |
| r24774 | r24775 | |
| 5 | 7 | : driver_device(mconfig, type, tag), |
| 6 | 8 | m_videoram(*this, "videoram"), |
| 7 | 9 | m_s2636_0_ram(*this, "s2636_0_ram"), |
| 8 | | m_maincpu(*this, "maincpu") { } |
| 10 | m_maincpu(*this, "maincpu"), |
| 11 | m_s2636_sound(*this, "s2636snd") { } |
| 9 | 12 | |
| 10 | 13 | required_shared_ptr<UINT8> m_videoram; |
| 11 | 14 | required_shared_ptr<UINT8> m_s2636_0_ram; |
| 15 | |
| 16 | required_device<cpu_device> m_maincpu; |
| 17 | required_device<s2636_sound_device> m_s2636_sound; |
| 18 | |
| 12 | 19 | bitmap_ind16 m_bitmap; |
| 13 | 20 | bitmap_ind16 m_spritebitmap; |
| 14 | 21 | int m_CollisionBackground; |
| r24774 | r24775 | |
| 25 | 32 | UINT32 screen_update_tinvader(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 26 | 33 | int SpriteCollision(int first,int second); |
| 27 | 34 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 28 | | required_device<cpu_device> m_maincpu; |
| 29 | 35 | }; |
trunk/src/emu/sound/s2636.c
| r24774 | r24775 | |
| 6 | 6 | |
| 7 | 7 | #include "emu.h" |
| 8 | 8 | #include "sound/s2636.h" |
| 9 | | #include "devlegcy.h" |
| 10 | 9 | |
| 10 | const device_type S2636_SOUND = &device_creator<s2636_sound_device>; |
| 11 | 11 | |
| 12 | | struct s2636_sound |
| 12 | s2636_sound_device::s2636_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 13 | : device_t(mconfig, S2636_SOUND, "S2636", tag, owner, clock, "s2636", __FILE__), |
| 14 | device_sound_interface(mconfig, *this), |
| 15 | m_channel(NULL), |
| 16 | m_size(0), |
| 17 | m_pos(0), |
| 18 | m_level(0) |
| 13 | 19 | { |
| 14 | | sound_stream *channel; |
| 15 | | UINT8 reg[1]; |
| 16 | | int size, pos; |
| 17 | | unsigned level; |
| 18 | | }; |
| 20 | for (int i = 0; i < 1; i++) |
| 21 | m_reg[i] = 0; |
| 22 | } |
| 19 | 23 | |
| 24 | //------------------------------------------------- |
| 25 | // device_config_complete - perform any |
| 26 | // operations now that the configuration is |
| 27 | // complete |
| 28 | //------------------------------------------------- |
| 20 | 29 | |
| 21 | | static s2636_sound *get_token(device_t *device) |
| 30 | void s2636_sound_device::device_config_complete() |
| 22 | 31 | { |
| 23 | | assert(device != NULL); |
| 24 | | assert(device->type() == S2636_SOUND); |
| 25 | | return (s2636_sound *) downcast<s2636_sound_device *>(device)->token(); |
| 26 | 32 | } |
| 27 | 33 | |
| 34 | //------------------------------------------------- |
| 35 | // device_start - device-specific startup |
| 36 | //------------------------------------------------- |
| 28 | 37 | |
| 29 | | void s2636_soundport_w (device_t *device, int offset, int data) |
| 38 | void s2636_sound_device::device_start() |
| 30 | 39 | { |
| 31 | | s2636_sound *token = get_token(device); |
| 40 | m_channel = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate(), this); |
| 41 | save_item(NAME(m_size)); |
| 42 | save_item(NAME(m_pos)); |
| 43 | save_item(NAME(m_level)); |
| 44 | |
| 45 | for (int i = 0; i < 1; i++) |
| 46 | save_item(NAME(m_reg[i]), i); |
| 47 | } |
| 32 | 48 | |
| 33 | | token->channel->update(); |
| 34 | | token->reg[offset] = data; |
| 49 | |
| 50 | void s2636_sound_device::soundport_w (int offset, int data) |
| 51 | { |
| 52 | m_channel->update(); |
| 53 | m_reg[offset] = data; |
| 35 | 54 | switch (offset) |
| 36 | 55 | { |
| 37 | 56 | case 0: |
| 38 | | token->pos = 0; |
| 39 | | token->level = TRUE; |
| 57 | m_pos = 0; |
| 58 | m_level = TRUE; |
| 40 | 59 | // frequency 7874/(data+1) |
| 41 | | token->size = device->machine().sample_rate() * (data + 1) /7874; |
| 60 | m_size = machine().sample_rate() * (data + 1) /7874; |
| 42 | 61 | break; |
| 43 | 62 | } |
| 44 | 63 | } |
| 45 | 64 | |
| 46 | 65 | |
| 66 | //------------------------------------------------- |
| 67 | // sound_stream_update - handle a stream update |
| 68 | //------------------------------------------------- |
| 47 | 69 | |
| 48 | | /************************************/ |
| 49 | | /* Sound handler update */ |
| 50 | | /************************************/ |
| 51 | | |
| 52 | | static STREAM_UPDATE( s2636_update ) |
| 70 | void s2636_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 53 | 71 | { |
| 54 | 72 | int i; |
| 55 | | s2636_sound *token = get_token(device); |
| 56 | 73 | stream_sample_t *buffer = outputs[0]; |
| 57 | 74 | |
| 58 | 75 | for (i = 0; i < samples; i++, buffer++) |
| 59 | 76 | { |
| 60 | 77 | *buffer = 0; |
| 61 | | if (token->reg[0] && token->pos <= token->size / 2) |
| 78 | if (m_reg[0] && m_pos <= m_size / 2) |
| 62 | 79 | { |
| 63 | 80 | *buffer = 0x7fff; |
| 64 | 81 | } |
| 65 | | if (token->pos <= token->size) |
| 66 | | token->pos++; |
| 67 | | if (token->pos > token->size) |
| 68 | | token->pos = 0; |
| 82 | if (m_pos <= m_size) |
| 83 | m_pos++; |
| 84 | if (m_pos > m_size) |
| 85 | m_pos = 0; |
| 69 | 86 | } |
| 70 | 87 | } |
| 71 | | |
| 72 | | |
| 73 | | |
| 74 | | /************************************/ |
| 75 | | /* Sound handler start */ |
| 76 | | /************************************/ |
| 77 | | |
| 78 | | static DEVICE_START(s2636_sound) |
| 79 | | { |
| 80 | | s2636_sound *token = get_token(device); |
| 81 | | memset(token, 0, sizeof(*token)); |
| 82 | | token->channel = device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), 0, s2636_update); |
| 83 | | } |
| 84 | | |
| 85 | | const device_type S2636_SOUND = &device_creator<s2636_sound_device>; |
| 86 | | |
| 87 | | s2636_sound_device::s2636_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 88 | | : device_t(mconfig, S2636_SOUND, "S2636", tag, owner, clock, "s2636", __FILE__), |
| 89 | | device_sound_interface(mconfig, *this) |
| 90 | | { |
| 91 | | m_token = global_alloc_clear(s2636_sound); |
| 92 | | } |
| 93 | | |
| 94 | | //------------------------------------------------- |
| 95 | | // device_config_complete - perform any |
| 96 | | // operations now that the configuration is |
| 97 | | // complete |
| 98 | | //------------------------------------------------- |
| 99 | | |
| 100 | | void s2636_sound_device::device_config_complete() |
| 101 | | { |
| 102 | | } |
| 103 | | |
| 104 | | //------------------------------------------------- |
| 105 | | // device_start - device-specific startup |
| 106 | | //------------------------------------------------- |
| 107 | | |
| 108 | | void s2636_sound_device::device_start() |
| 109 | | { |
| 110 | | DEVICE_START_NAME( s2636_sound )(this); |
| 111 | | } |
| 112 | | |
| 113 | | //------------------------------------------------- |
| 114 | | // sound_stream_update - handle a stream update |
| 115 | | //------------------------------------------------- |
| 116 | | |
| 117 | | void s2636_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 118 | | { |
| 119 | | // should never get here |
| 120 | | fatalerror("sound_stream_update called; not applicable to legacy sound devices\n"); |
| 121 | | } |