180
184
// Trackball doesn't work correctly
181
185
static READ8_HANDLER( borntofi_inputs_r )
183
fantland_state *state = space->machine->driver_data<fantland_state>();
187
fantland_state *state = space->machine().driver_data<fantland_state>();
186
switch (input_port_read(space->machine, "Controls") & 0x03)
190
switch (input_port_read(space->machine(), "Controls") & 0x03)
189
case 1: return input_port_read(space->machine, offset ? "P2_GUN" : "P1_GUN"); // Lightgun buttons
190
case 2: return input_port_read(space->machine, offset ? "P2_JOY" : "P1_JOY"); // Joystick
193
case 1: return input_port_read(space->machine(), offset ? "P2_GUN" : "P1_GUN"); // Lightgun buttons
194
case 2: return input_port_read(space->machine(), offset ? "P2_JOY" : "P1_JOY"); // Joystick
195
x = input_port_read(space->machine, offset ? "P2 Trackball X" : "P1 Trackball X");
196
y = input_port_read(space->machine, offset ? "P2 Trackball Y" : "P1 Trackball Y");
197
f = space->machine->primary_screen->frame_number();
199
x = input_port_read(space->machine(), offset ? "P2 Trackball X" : "P1 Trackball X");
200
y = input_port_read(space->machine(), offset ? "P2 Trackball Y" : "P1 Trackball Y");
201
f = space->machine().primary_screen->frame_number();
199
state->input_ret[offset] = (state->input_ret[offset] & 0x14) | (input_port_read(space->machine, offset ? "P2_TRACK" : "P1_TRACK") & 0xc3);
203
state->m_input_ret[offset] = (state->m_input_ret[offset] & 0x14) | (input_port_read(space->machine(), offset ? "P2_TRACK" : "P1_TRACK") & 0xc3);
201
205
x = (x & 0x7f) - (x & 0x80);
202
206
y = (y & 0x7f) - (y & 0x80);
204
if (state->old_x[offset] > 0)
206
state->input_ret[offset] = (state->input_ret[offset] ^ 0x04) | ((state->input_ret[offset] & 0x04) << 1);
207
state->old_x[offset]--;
209
else if (state->old_x[offset] < 0)
211
state->input_ret[offset] = (state->input_ret[offset] ^ 0x04) | (((~state->input_ret[offset]) & 0x04) << 1);
212
state->old_x[offset]++;
215
if (state->old_y[offset] > 0)
217
state->input_ret[offset] = (state->input_ret[offset] ^ 0x10) | ((state->input_ret[offset] & 0x10) << 1);
218
state->old_y[offset]--;
220
else if (state->old_y[offset] < 0)
222
state->input_ret[offset] = (state->input_ret[offset] ^ 0x10) | (((~state->input_ret[offset]) & 0x10) << 1);
223
state->old_y[offset]++;
226
// if (offset == 0) popmessage("x %02d y %02d", state->old_x[offset], state->old_y[offset]);
228
if ((f - state->old_f[offset]) > 0)
230
state->old_x[offset] = x;
231
state->old_y[offset] = y;
232
state->old_f[offset] = f;
235
return state->input_ret[offset];
208
if (state->m_old_x[offset] > 0)
210
state->m_input_ret[offset] = (state->m_input_ret[offset] ^ 0x04) | ((state->m_input_ret[offset] & 0x04) << 1);
211
state->m_old_x[offset]--;
213
else if (state->m_old_x[offset] < 0)
215
state->m_input_ret[offset] = (state->m_input_ret[offset] ^ 0x04) | (((~state->m_input_ret[offset]) & 0x04) << 1);
216
state->m_old_x[offset]++;
219
if (state->m_old_y[offset] > 0)
221
state->m_input_ret[offset] = (state->m_input_ret[offset] ^ 0x10) | ((state->m_input_ret[offset] & 0x10) << 1);
222
state->m_old_y[offset]--;
224
else if (state->m_old_y[offset] < 0)
226
state->m_input_ret[offset] = (state->m_input_ret[offset] ^ 0x10) | (((~state->m_input_ret[offset]) & 0x10) << 1);
227
state->m_old_y[offset]++;
230
// if (offset == 0) popmessage("x %02d y %02d", state->m_old_x[offset], state->m_old_y[offset]);
232
if ((f - state->m_old_f[offset]) > 0)
234
state->m_old_x[offset] = x;
235
state->m_old_y[offset] = y;
236
state->m_old_f[offset] = f;
239
return state->m_input_ret[offset];
238
static ADDRESS_MAP_START( borntofi_map, ADDRESS_SPACE_PROGRAM, 8 )
242
static ADDRESS_MAP_START( borntofi_map, AS_PROGRAM, 8 )
239
243
AM_RANGE( 0x00000, 0x07fff ) AM_RAM
240
244
AM_RANGE( 0x10000, 0x2ffff ) AM_ROM
244
248
AM_RANGE( 0x53002, 0x53002 ) AM_READ_PORT( "DSW" ) AM_WRITE( fantland_soundlatch_w )
245
249
AM_RANGE( 0x53003, 0x53003 ) AM_READ_PORT( "Controls" )
247
AM_RANGE( 0x54000, 0x567ff ) AM_RAM AM_BASE_GENERIC( spriteram )
251
AM_RANGE( 0x54000, 0x567ff ) AM_RAM AM_BASE_MEMBER(fantland_state, m_spriteram)
249
253
AM_RANGE( 0x57000, 0x57000 ) AM_READ_PORT( "P1 Lightgun Y" )
250
254
AM_RANGE( 0x57001, 0x57001 ) AM_READ_PORT( "P1 Lightgun X" )
251
255
AM_RANGE( 0x57002, 0x57002 ) AM_READ_PORT( "P2 Lightgun Y" )
252
256
AM_RANGE( 0x57003, 0x57003 ) AM_READ_PORT( "P2 Lightgun X" )
254
AM_RANGE( 0x60000, 0x6ffff ) AM_RAM AM_BASE_GENERIC( spriteram2 )
258
AM_RANGE( 0x60000, 0x6ffff ) AM_RAM AM_BASE_MEMBER(fantland_state, m_spriteram2)
256
260
AM_RANGE( 0x70000, 0x7ffff ) AM_ROM
257
261
AM_RANGE( 0xf0000, 0xfffff ) AM_ROM
290
294
***************************************************************************/
292
static ADDRESS_MAP_START( fantland_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
296
static ADDRESS_MAP_START( fantland_sound_map, AS_PROGRAM, 8 )
293
297
AM_RANGE( 0x00000, 0x01fff ) AM_RAM
294
298
AM_RANGE( 0x80000, 0x9ffff ) AM_ROM
295
299
AM_RANGE( 0xc0000, 0xfffff ) AM_ROM
298
static ADDRESS_MAP_START( fantland_sound_iomap, ADDRESS_SPACE_IO, 8 )
302
static ADDRESS_MAP_START( fantland_sound_iomap, AS_IO, 8 )
299
303
AM_RANGE( 0x0080, 0x0080 ) AM_READ( soundlatch_r )
300
304
AM_RANGE( 0x0100, 0x0101 ) AM_DEVREADWRITE( "ymsnd", ym2151_r, ym2151_w )
301
305
AM_RANGE( 0x0180, 0x0180 ) AM_DEVWRITE( "dac", dac_w )
304
static ADDRESS_MAP_START( galaxygn_sound_iomap, ADDRESS_SPACE_IO, 8 )
308
static ADDRESS_MAP_START( galaxygn_sound_iomap, AS_IO, 8 )
305
309
AM_RANGE( 0x0080, 0x0080 ) AM_READ( soundlatch_r )
306
310
AM_RANGE( 0x0100, 0x0101 ) AM_DEVREADWRITE( "ymsnd", ym2151_r, ym2151_w )
314
318
static void borntofi_adpcm_start( device_t *device, int voice )
316
fantland_state *state = device->machine->driver_data<fantland_state>();
320
fantland_state *state = device->machine().driver_data<fantland_state>();
317
321
msm5205_reset_w(device, 0);
318
state->adpcm_playing[voice] = 1;
319
state->adpcm_nibble[voice] = 0;
320
// logerror("%s: adpcm start = %06x, stop = %06x\n", cpuexec_describe_context(device->machine), state->adpcm_addr[0][voice], state->adpcm_addr[1][voice]);
322
state->m_adpcm_playing[voice] = 1;
323
state->m_adpcm_nibble[voice] = 0;
324
// logerror("%s: adpcm start = %06x, stop = %06x\n", device->machine().describe_context(), state->m_adpcm_addr[0][voice], state->m_adpcm_addr[1][voice]);
323
327
static void borntofi_adpcm_stop( device_t *device, int voice )
325
fantland_state *state = device->machine->driver_data<fantland_state>();
329
fantland_state *state = device->machine().driver_data<fantland_state>();
326
330
msm5205_reset_w(device, 1);
327
state->adpcm_playing[voice] = 0;
331
state->m_adpcm_playing[voice] = 0;
330
334
static WRITE8_HANDLER( borntofi_msm5205_w )
332
fantland_state *state = space->machine->driver_data<fantland_state>();
336
fantland_state *state = space->machine().driver_data<fantland_state>();
333
337
int voice = offset / 8;
334
338
int reg = offset % 8;
358
362
int shift = (reg - 1) * 4;
359
363
int mask = ~(0xf << shift);
361
state->adpcm_addr[0][voice] = (state->adpcm_addr[0][voice] & mask) | (((data & 0xf0) >> 4) << shift);
362
state->adpcm_addr[1][voice] = (state->adpcm_addr[1][voice] & mask) | (((data & 0x0f) >> 0) << shift);
365
state->m_adpcm_addr[0][voice] = (state->m_adpcm_addr[0][voice] & mask) | (((data & 0xf0) >> 4) << shift);
366
state->m_adpcm_addr[1][voice] = (state->m_adpcm_addr[1][voice] & mask) | (((data & 0x0f) >> 0) << shift);
366
370
static void borntofi_adpcm_int( device_t *device, int voice )
368
fantland_state *state = device->machine->driver_data<fantland_state>();
372
fantland_state *state = device->machine().driver_data<fantland_state>();
373
if (!state->adpcm_playing[voice])
377
if (!state->m_adpcm_playing[voice])
376
rom = device->machine->region("adpcm")->base();
377
len = device->machine->region("adpcm")->bytes() * 2;
380
rom = device->machine().region("adpcm")->base();
381
len = device->machine().region("adpcm")->bytes() * 2;
379
start = state->adpcm_addr[0][voice] + state->adpcm_nibble[voice];
380
stop = state->adpcm_addr[1][voice];
383
start = state->m_adpcm_addr[0][voice] + state->m_adpcm_nibble[voice];
384
stop = state->m_adpcm_addr[1][voice];
382
386
if (start >= len)
658
662
PORT_DIPSETTING( 0x06, DEF_STR( 1C_2C ) )
659
663
PORT_DIPSETTING( 0x05, DEF_STR( 1C_3C ) )
660
664
PORT_DIPSETTING( 0x04, DEF_STR( 1C_4C ) )
661
PORT_DIPSETTING( 0x00, "Invulnerability" )
662
PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
665
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )
666
PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("DSW1:4")
663
667
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
664
668
PORT_DIPSETTING( 0x08, DEF_STR( On ) )
665
PORT_DIPNAME( 0x10, 0x10, DEF_STR( Allow_Continue ) )
669
PORT_DIPNAME( 0x10, 0x10, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("DSW1:5")
666
670
PORT_DIPSETTING( 0x00, DEF_STR( No ) )
667
671
PORT_DIPSETTING( 0x10, DEF_STR( Yes ) )
668
PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )
672
PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("DSW1:6,7")
669
673
PORT_DIPSETTING( 0x60, DEF_STR( Normal ) )
670
PORT_DIPSETTING( 0x40, DEF_STR( Hard ) )
671
PORT_DIPSETTING( 0x20, DEF_STR( Harder ) )
672
PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) )
673
PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
674
PORT_DIPSETTING( 0x40, DEF_STR( Medium ) )
675
PORT_DIPSETTING( 0x20, DEF_STR( Medium_Hard ) )
676
PORT_DIPSETTING( 0x00, DEF_STR( Hard ) )
677
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Service_Mode ) ) PORT_DIPLOCATION("DSW1:8")
678
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
679
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
681
// PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
675
683
PORT_START( "Controls" ) /* IN7 - 53003 */
676
PORT_DIPNAME( 0x03, 0x03, DEF_STR( Controls ) )
684
PORT_DIPNAME( 0x03, 0x03, DEF_STR( Controls ) ) PORT_DIPLOCATION("DSW2:1,2")
677
685
// PORT_DIPSETTING( 0x01, "Lightgun" )
678
686
PORT_DIPSETTING( 0x03, "Lightgun" )
679
687
PORT_DIPSETTING( 0x00, DEF_STR( Trackball ) )
680
688
PORT_DIPSETTING( 0x02, DEF_STR( Joystick ) )
681
PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) ) // tested
689
PORT_DIPNAME( 0x04, 0x04, "Sound Test" ) PORT_DIPLOCATION("DSW2:3")
682
690
PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
683
691
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
684
PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
685
PORT_DIPSETTING( 0x08, "180" )
686
PORT_DIPSETTING( 0x00, "0" )
687
PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
688
PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
689
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
690
PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
691
PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
692
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
693
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
694
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
695
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
696
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
697
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
698
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
692
PORT_DIPNAME( 0x08, 0x08, "Free Bullets" ) PORT_DIPLOCATION("DSW2:4")
693
PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
694
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
695
PORT_DIPUNUSED_DIPLOC( 0x10, 0x0010, "DSW2:5" )
696
PORT_DIPUNUSED_DIPLOC( 0x20, 0x0020, "DSW2:6" )
697
PORT_DIPUNUSED_DIPLOC( 0x40, 0x0040, "DSW2:7" )
698
PORT_DIPUNUSED_DIPLOC( 0x80, 0x0080, "DSW2:8" )
700
700
PORT_START("P1 Lightgun Y") /* 57000 */
701
701
PORT_BIT( 0xff, 0xb0, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, (352.0 - 12) / 352, 12.0 / 352, 0) PORT_MINMAX(0x80,0xfc) PORT_SENSITIVITY(100) PORT_KEYDELTA(5) PORT_PLAYER(1)
828
828
static MACHINE_START( fantland )
830
fantland_state *state = machine->driver_data<fantland_state>();
832
state->audio_cpu = machine->device("audiocpu");
834
state_save_register_global(machine, state->nmi_enable);
830
fantland_state *state = machine.driver_data<fantland_state>();
832
state->m_audio_cpu = machine.device("audiocpu");
834
state->save_item(NAME(state->m_nmi_enable));
837
837
static MACHINE_RESET( fantland )
839
fantland_state *state = machine->driver_data<fantland_state>();
840
state->nmi_enable = 0;
839
fantland_state *state = machine.driver_data<fantland_state>();
840
state->m_nmi_enable = 0;
843
843
static INTERRUPT_GEN( fantland_irq )
845
fantland_state *state = device->machine->driver_data<fantland_state>();
846
if (state->nmi_enable & 8)
847
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
845
fantland_state *state = device->machine().driver_data<fantland_state>();
846
if (state->m_nmi_enable & 8)
847
device_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
850
850
static INTERRUPT_GEN( fantland_sound_irq )
852
cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0x80 / 4);
852
device_set_input_line_and_vector(device, 0, HOLD_LINE, 0x80 / 4);
855
855
static MACHINE_CONFIG_START( fantland, fantland_state )
969
968
static MACHINE_START( borntofi )
971
fantland_state *state = machine->driver_data<fantland_state>();
970
fantland_state *state = machine.driver_data<fantland_state>();
973
972
MACHINE_START_CALL(fantland);
975
state->msm1 = machine->device("msm1");
976
state->msm2 = machine->device("msm2");
977
state->msm3 = machine->device("msm3");
978
state->msm4 = machine->device("msm4");
974
state->m_msm1 = machine.device("msm1");
975
state->m_msm2 = machine.device("msm2");
976
state->m_msm3 = machine.device("msm3");
977
state->m_msm4 = machine.device("msm4");
980
state_save_register_global_array(machine, state->old_x);
981
state_save_register_global_array(machine, state->old_y);
982
state_save_register_global_array(machine, state->old_f);
983
state_save_register_global_array(machine, state->input_ret);
984
state_save_register_global_array(machine, state->adpcm_playing);
985
state_save_register_global_array(machine, state->adpcm_addr[0]);
986
state_save_register_global_array(machine, state->adpcm_addr[1]);
987
state_save_register_global_array(machine, state->adpcm_nibble);
979
state->save_item(NAME(state->m_old_x));
980
state->save_item(NAME(state->m_old_y));
981
state->save_item(NAME(state->m_old_f));
982
state->save_item(NAME(state->m_input_ret));
983
state->save_item(NAME(state->m_adpcm_playing));
984
state->save_item(NAME(state->m_adpcm_addr[0]));
985
state->save_item(NAME(state->m_adpcm_addr[1]));
986
state->save_item(NAME(state->m_adpcm_nibble));
990
989
static MACHINE_RESET( borntofi )
992
fantland_state *state = machine->driver_data<fantland_state>();
991
fantland_state *state = machine.driver_data<fantland_state>();
995
994
MACHINE_RESET_CALL(fantland);
997
996
for (i = 0; i < 2; i++)
1000
state->old_y[i] = 0;
1001
state->old_f[i] = 0;
1002
state->input_ret[i] = 0;
998
state->m_old_x[i] = 0;
999
state->m_old_y[i] = 0;
1000
state->m_old_f[i] = 0;
1001
state->m_input_ret[i] = 0;
1005
1004
for (i = 0; i < 4; i++)
1007
state->adpcm_playing[i] = 1;
1008
state->adpcm_addr[0][i] = 0;
1009
state->adpcm_addr[1][i] = 0;
1010
state->adpcm_nibble[i] = 0;
1006
state->m_adpcm_playing[i] = 1;
1007
state->m_adpcm_addr[0][i] = 0;
1008
state->m_adpcm_addr[1][i] = 0;
1009
state->m_adpcm_nibble[i] = 0;
1013
borntofi_adpcm_stop(machine->device("msm1"), 0);
1014
borntofi_adpcm_stop(machine->device("msm2"), 1);
1015
borntofi_adpcm_stop(machine->device("msm3"), 2);
1016
borntofi_adpcm_stop(machine->device("msm4"), 3);
1012
borntofi_adpcm_stop(machine.device("msm1"), 0);
1013
borntofi_adpcm_stop(machine.device("msm2"), 1);
1014
borntofi_adpcm_stop(machine.device("msm3"), 2);
1015
borntofi_adpcm_stop(machine.device("msm4"), 3);
1019
1018
static MACHINE_CONFIG_START( borntofi, fantland_state )
1456
1453
GAME( 19??, fantland, 0, fantland, fantland, 0, ROT0, "Electronic Devices Italy", "Fantasy Land (set 1)", GAME_SUPPORTS_SAVE )
1457
1454
GAME( 19??, fantlanda, fantland, fantland, fantland, 0, ROT0, "Electronic Devices Italy", "Fantasy Land (set 2)", GAME_SUPPORTS_SAVE )
1458
1455
GAME( 19??, wheelrun, 0, wheelrun, wheelrun, 0, ROT0, "International Games", "Wheels Runner", GAME_SUPPORTS_SAVE )
1459
GAME( 1989, galaxygn, 0, galaxygn, galaxygn, 0, ROT90, "Electronics Devices Italy", "Galaxy Gunners", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1456
GAME( 1989, galaxygn, 0, galaxygn, galaxygn, 0, ROT90, "Electronic Devices Italy", "Galaxy Gunners", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )