~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/mame/drivers/calorie.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
{
88
88
public:
89
89
        calorie_state(const machine_config &mconfig, device_type type, const char *tag)
90
 
                : driver_device(mconfig, type, tag) { }
 
90
                : driver_device(mconfig, type, tag) ,
 
91
                m_fg_ram(*this, "fg_ram"),
 
92
                m_sprites(*this, "sprites"){ }
91
93
 
92
94
        /* memory pointers */
93
 
        UINT8 *  m_fg_ram;
94
 
        UINT8 *  m_sprites;
 
95
        required_shared_ptr<UINT8> m_fg_ram;
 
96
        required_shared_ptr<UINT8> m_sprites;
95
97
//  UINT8 *  m_paletteram;    // currently this uses generic palette handling
96
98
 
97
99
        /* video-related */
98
100
        tilemap_t  *m_bg_tilemap;
99
101
        tilemap_t  *m_fg_tilemap;
100
102
        UINT8    m_bg_bank;
 
103
        DECLARE_WRITE8_MEMBER(fg_ram_w);
 
104
        DECLARE_WRITE8_MEMBER(bg_bank_w);
 
105
        DECLARE_WRITE8_MEMBER(calorie_flipscreen_w);
 
106
        DECLARE_READ8_MEMBER(calorie_soundlatch_r);
 
107
        DECLARE_WRITE8_MEMBER(bogus_w);
101
108
};
102
109
 
103
110
 
110
117
static TILE_GET_INFO( get_bg_tile_info )
111
118
{
112
119
        calorie_state *state = machine.driver_data<calorie_state>();
113
 
        UINT8 *src = machine.region("user1")->base();
 
120
        UINT8 *src = state->memregion("user1")->base();
114
121
        int bg_base = (state->m_bg_bank & 0x0f) * 0x200;
115
122
        int code  = src[bg_base + tile_index] | (((src[bg_base + tile_index + 0x100]) & 0x10) << 4);
116
123
        int color = src[bg_base + tile_index + 0x100] & 0x0f;
166
173
                ypos = 0xff - state->m_sprites[x + 2];
167
174
                xpos = state->m_sprites[x + 3];
168
175
 
169
 
                if (flip_screen_get(screen.machine()))
 
176
                if (state->flip_screen())
170
177
                {
171
178
                        if (state->m_sprites[x + 1] & 0x10)
172
179
                                ypos = 0xff - ypos + 32;
198
205
 *
199
206
 *************************************/
200
207
 
201
 
static WRITE8_HANDLER( fg_ram_w )
202
 
{
203
 
        calorie_state *state = space->machine().driver_data<calorie_state>();
204
 
        state->m_fg_ram[offset] = data;
205
 
        state->m_fg_tilemap->mark_tile_dirty(offset & 0x3ff);
206
 
}
207
 
 
208
 
static WRITE8_HANDLER( bg_bank_w )
209
 
{
210
 
        calorie_state *state = space->machine().driver_data<calorie_state>();
211
 
        if((state->m_bg_bank & ~0x10) != (data & ~0x10))
212
 
                state->m_bg_tilemap->mark_all_dirty();
213
 
 
214
 
        state->m_bg_bank = data;
215
 
}
216
 
 
217
 
static WRITE8_HANDLER( calorie_flipscreen_w )
218
 
{
219
 
        flip_screen_set(space->machine(), data & 1);
220
 
}
221
 
 
222
 
static READ8_HANDLER( calorie_soundlatch_r )
223
 
{
224
 
        UINT8 latch = soundlatch_r(space, 0);
225
 
        soundlatch_clear_w(space, 0, 0);
 
208
WRITE8_MEMBER(calorie_state::fg_ram_w)
 
209
{
 
210
        m_fg_ram[offset] = data;
 
211
        m_fg_tilemap->mark_tile_dirty(offset & 0x3ff);
 
212
}
 
213
 
 
214
WRITE8_MEMBER(calorie_state::bg_bank_w)
 
215
{
 
216
        if((m_bg_bank & ~0x10) != (data & ~0x10))
 
217
                m_bg_tilemap->mark_all_dirty();
 
218
 
 
219
        m_bg_bank = data;
 
220
}
 
221
 
 
222
WRITE8_MEMBER(calorie_state::calorie_flipscreen_w)
 
223
{
 
224
        flip_screen_set(data & 1);
 
225
}
 
226
 
 
227
READ8_MEMBER(calorie_state::calorie_soundlatch_r)
 
228
{
 
229
        UINT8 latch = soundlatch_byte_r(space, 0);
 
230
        soundlatch_clear_byte_w(space, 0, 0);
226
231
        return latch;
227
232
}
228
233
 
229
 
static WRITE8_HANDLER( bogus_w )
 
234
WRITE8_MEMBER(calorie_state::bogus_w)
230
235
{
231
236
        popmessage("written to 3rd sound chip: data = %02X port = %02X", data, offset);
232
237
}
237
242
 *
238
243
 *************************************/
239
244
 
240
 
static ADDRESS_MAP_START( calorie_map, AS_PROGRAM, 8 )
 
245
static ADDRESS_MAP_START( calorie_map, AS_PROGRAM, 8, calorie_state )
241
246
        AM_RANGE(0x0000, 0x7fff) AM_ROM
242
247
        AM_RANGE(0x8000, 0xbfff) AM_ROM
243
248
        AM_RANGE(0xc000, 0xcfff) AM_RAM
244
 
        AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(fg_ram_w) AM_BASE_MEMBER(calorie_state, m_fg_ram)
245
 
        AM_RANGE(0xd800, 0xdbff) AM_RAM AM_BASE_MEMBER(calorie_state, m_sprites)
246
 
        AM_RANGE(0xdc00, 0xdcff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_le_w) AM_BASE_GENERIC(paletteram)
 
249
        AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(fg_ram_w) AM_SHARE("fg_ram")
 
250
        AM_RANGE(0xd800, 0xdbff) AM_RAM AM_SHARE("sprites")
 
251
        AM_RANGE(0xdc00, 0xdcff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_byte_le_w) AM_SHARE("paletteram")
247
252
        AM_RANGE(0xde00, 0xde00) AM_WRITE(bg_bank_w)
248
253
        AM_RANGE(0xf000, 0xf000) AM_READ_PORT("P1")
249
254
        AM_RANGE(0xf001, 0xf001) AM_READ_PORT("P2")
250
255
        AM_RANGE(0xf002, 0xf002) AM_READ_PORT("SYSTEM")
251
256
        AM_RANGE(0xf004, 0xf004) AM_READ_PORT("DSW1") AM_WRITE(calorie_flipscreen_w)
252
257
        AM_RANGE(0xf005, 0xf005) AM_READ_PORT("DSW2")
253
 
        AM_RANGE(0xf800, 0xf800) AM_WRITE(soundlatch_w)
 
258
        AM_RANGE(0xf800, 0xf800) AM_WRITE(soundlatch_byte_w)
254
259
ADDRESS_MAP_END
255
260
 
256
261
 
257
 
static ADDRESS_MAP_START( calorie_sound_map, AS_PROGRAM, 8 )
 
262
static ADDRESS_MAP_START( calorie_sound_map, AS_PROGRAM, 8, calorie_state )
258
263
        AM_RANGE(0x0000, 0x3fff) AM_ROM
259
264
        AM_RANGE(0x8000, 0x87ff) AM_RAM
260
265
        AM_RANGE(0xc000, 0xc000) AM_READ(calorie_soundlatch_r)
261
266
ADDRESS_MAP_END
262
267
 
263
 
static ADDRESS_MAP_START( calorie_sound_io_map, AS_IO, 8 )
 
268
static ADDRESS_MAP_START( calorie_sound_io_map, AS_IO, 8, calorie_state )
264
269
        ADDRESS_MAP_GLOBAL_MASK(0xff)
265
 
        AM_RANGE(0x00, 0x01) AM_DEVWRITE("ay1", ay8910_address_data_w)
266
 
        AM_RANGE(0x01, 0x01) AM_DEVREAD("ay1", ay8910_r)
267
 
        AM_RANGE(0x10, 0x11) AM_DEVWRITE("ay2", ay8910_address_data_w)
268
 
        AM_RANGE(0x11, 0x11) AM_DEVREAD("ay2", ay8910_r)
 
270
        AM_RANGE(0x00, 0x01) AM_DEVWRITE_LEGACY("ay1", ay8910_address_data_w)
 
271
        AM_RANGE(0x01, 0x01) AM_DEVREAD_LEGACY("ay1", ay8910_r)
 
272
        AM_RANGE(0x10, 0x11) AM_DEVWRITE_LEGACY("ay2", ay8910_address_data_w)
 
273
        AM_RANGE(0x11, 0x11) AM_DEVREAD_LEGACY("ay2", ay8910_r)
269
274
        // 3rd ?
270
275
        AM_RANGE(0x00, 0xff) AM_WRITE(bogus_w)
271
276
ADDRESS_MAP_END
551
556
static DRIVER_INIT( calorieb )
552
557
{
553
558
        address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
554
 
        space->set_decrypted_region(0x0000, 0x7fff, machine.region("maincpu")->base() + 0x10000);
 
559
        space->set_decrypted_region(0x0000, 0x7fff, machine.root_device().memregion("maincpu")->base() + 0x10000);
555
560
}
556
561
 
557
562