Previous 15994 Revisions Next

r6780 Sunday 27th December, 2009 at 03:47:42 UTC by Robbbert
[NEOGEO] Fixed crash.
[src/mess]mess.mak
[src/mess/drivers]ng_aes.c
[src/mess/layout]neogeo.lay*

src/mess/layout/neogeo.lay
r0r6780
1<?xml version="1.0"?>
2<mamelayout version="2">
3   <element name="blank">
4      <rect>
5         <color red="0" green="0" blue="0" />
6      </rect>
7   </element>
8 
9   <view name="Screen 0 Standard (4:3)">
10      <screen index="0">
11         <bounds left="0" top="0" right="4" bottom="3" />
12      </screen>
13   </view>
14 
15   <view name="Screen 0 Cropped (304x224)">
16      <bezel name="blank" element="blank">
17         <bounds left="0" top="0" right="0.1" bottom="3" />
18      </bezel>
19      <bezel name="blank" element="blank">
20         <bounds left="3.9" top="0" right="4" bottom="3" />
21      </bezel>
22      <screen index="0">
23         <bounds left="0" top="0" right="4" bottom="3" />
24      </screen>
25   </view>
26 
27   <view name="Screen 0 Stretched (304x224)">
28      <bounds left="0" top="0" right="4" bottom="3" />
29      <screen index="0">
30         <bounds left="-0.105263" top="0" right="4.105263" bottom="3" />
31      </screen>
32   </view>
33</mamelayout>
src/mess/mess.mak
r6779r6780
16341634$(MESS_DRIVERS)/mmd1.o:      $(MESS_LAYOUT)/mmd1.lh \
16351635                     $(MESS_LAYOUT)/mmd2.lh
16361636$(MESS_DRIVERS)/newbrain.o:   $(MESS_LAYOUT)/newbrain.lh
1637$(MESS_DRIVERS)/ng_aes.o:   $(MESS_LAYOUT)/neogeo.lh
16371638$(MESS_DRIVERS)/poly880.o:   $(MESS_LAYOUT)/poly880.lh
16381639$(MESS_VIDEO)/pc8401a.o:   $(MESS_LAYOUT)/pc8500.lh
16391640$(MESS_DRIVERS)/px4.o:      $(MESS_LAYOUT)/px4.lh
src/mess/drivers/ng_aes.c
r6779r6780
3636#include "sound/2610intf.h"
3737#include "devices/aescart.h"
3838
39#include "neogeo.lh"
3940
41
4042#define LOG_VIDEO_SYSTEM      (0)
4143#define LOG_CPU_COMM         (0)
4244#define LOG_MAIN_CPU_BANKING   (0)
r6779r6780
5052 *
5153 *************************************/
5254
53static UINT8 display_position_interrupt_control;
54static UINT32 display_counter;
55static UINT32 vblank_interrupt_pending;
56static UINT32 display_position_interrupt_pending;
57static UINT32 irq3_pending;
58static emu_timer *display_position_interrupt_timer;
59static emu_timer *display_position_vblank_timer;
60static emu_timer *vblank_interrupt_timer;
61
62static UINT8 controller_select;
63
6455static UINT8 *memcard_data;
65
66static UINT32 main_cpu_bank_address;
67static UINT8 main_cpu_vector_table_source;
68
69static UINT8 audio_result;
70static UINT8 audio_cpu_banks[4];
71static UINT8 audio_cpu_rom_source;
72static UINT8 audio_cpu_rom_source_last;
73
7456static UINT16 *save_ram;
75static UINT8 save_ram_unlocked;
7657
77static UINT8 output_data;
78static UINT8 output_latch;
79static UINT8 el_value;
8058
81
82
8359/*************************************
8460 *
85 *  Forward declerations
61 *  Forward declarations
8662 *
8763 *************************************/
8864
89//static void calendar_clock(void);
65//static void set_output_latch(running_machine *machine, UINT8 data);
66//static void set_output_data(running_machine *machine, UINT8 data);
9067
9168
92
9369/*************************************
9470 *
9571 *  Main CPU interrupt generation
r6779r6780
10278#define IRQ2CTRL_AUTOLOAD_REPEAT   (0x80)
10379
10480
105static void adjust_display_position_interrupt_timer(running_machine *machine)
81static void adjust_display_position_interrupt_timer( running_machine *machine )
10682{
107   if ((display_counter + 1) != 0)
83   neogeo_state *state = (neogeo_state *)machine->driver_data;
84
85   if ((state->display_counter + 1) != 0)
10886   {
109      attotime period = attotime_mul(ATTOTIME_IN_HZ(NEOGEO_PIXEL_CLOCK), display_counter + 1);
110      if (LOG_VIDEO_SYSTEM) logerror("adjust_display_position_interrupt_timer  current y: %02x  current x: %02x   target y: %x  target x: %x\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen), (display_counter + 1) / NEOGEO_HTOTAL, (display_counter + 1) % NEOGEO_HTOTAL);
87      attotime period = attotime_mul(ATTOTIME_IN_HZ(NEOGEO_PIXEL_CLOCK), state->display_counter + 1);
88      if (LOG_VIDEO_SYSTEM) logerror("adjust_display_position_interrupt_timer  current y: %02x  current x: %02x   target y: %x  target x: %x\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen), (state->display_counter + 1) / NEOGEO_HTOTAL, (state->display_counter + 1) % NEOGEO_HTOTAL);
11189
112      timer_adjust_oneshot(display_position_interrupt_timer, period, 0);
90      timer_adjust_oneshot(state->display_position_interrupt_timer, period, 0);
11391   }
11492}
11593
11694
117void neogeo_set_display_position_interrupt_control(running_machine *machine,UINT16 data)
95void neogeo_set_display_position_interrupt_control( running_machine *machine, UINT16 data )
11896{
119   display_position_interrupt_control = data;
97   neogeo_state *state = (neogeo_state *)machine->driver_data;
98   state->display_position_interrupt_control = data;
12099}
121100
122101
123void neogeo_set_display_counter_msb(const address_space *space, UINT16 data)
102void neogeo_set_display_counter_msb( const address_space *space, UINT16 data )
124103{
125   display_counter = (display_counter & 0x0000ffff) | ((UINT32)data << 16);
104   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
126105
127   if (LOG_VIDEO_SYSTEM) logerror("PC %06x: set_display_counter %08x\n", cpu_get_pc(space->cpu), display_counter);
106   state->display_counter = (state->display_counter & 0x0000ffff) | ((UINT32)data << 16);
107
108   if (LOG_VIDEO_SYSTEM) logerror("PC %06x: set_display_counter %08x\n", cpu_get_pc(space->cpu), state->display_counter);
128109}
129110
130111
131void neogeo_set_display_counter_lsb(const address_space *space, UINT16 data)
112void neogeo_set_display_counter_lsb( const address_space *space, UINT16 data )
132113{
133   display_counter = (display_counter & 0xffff0000) | data;
114   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
134115
135   if (LOG_VIDEO_SYSTEM) logerror("PC %06x: set_display_counter %08x\n", cpu_get_pc(space->cpu), display_counter);
116   state->display_counter = (state->display_counter & 0xffff0000) | data;
136117
137   if (display_position_interrupt_control & IRQ2CTRL_LOAD_RELATIVE)
118   if (LOG_VIDEO_SYSTEM) logerror("PC %06x: set_display_counter %08x\n", cpu_get_pc(space->cpu), state->display_counter);
119
120   if (state->display_position_interrupt_control & IRQ2CTRL_LOAD_RELATIVE)
138121   {
139122      if (LOG_VIDEO_SYSTEM) logerror("AUTOLOAD_RELATIVE ");
140123       adjust_display_position_interrupt_timer(space->machine);
r6779r6780
142125}
143126
144127
145static void update_interrupts(running_machine *machine)
128static void update_interrupts( running_machine *machine )
146129{
147   cputag_set_input_line(machine, "maincpu", 1, vblank_interrupt_pending ? ASSERT_LINE : CLEAR_LINE);
148   cputag_set_input_line(machine, "maincpu", 2, display_position_interrupt_pending ? ASSERT_LINE : CLEAR_LINE);
149   cputag_set_input_line(machine, "maincpu", 3, irq3_pending ? ASSERT_LINE : CLEAR_LINE);
130   neogeo_state *state = (neogeo_state *)machine->driver_data;
131
132   cputag_set_input_line(machine, "maincpu", 1, state->vblank_interrupt_pending ? ASSERT_LINE : CLEAR_LINE);
133   cputag_set_input_line(machine, "maincpu", 2, state->display_position_interrupt_pending ? ASSERT_LINE : CLEAR_LINE);
134   cputag_set_input_line(machine, "maincpu", 3, state->irq3_pending ? ASSERT_LINE : CLEAR_LINE);
150135}
151136
152137
153void neogeo_acknowledge_interrupt(running_machine *machine, UINT16 data)
138void neogeo_acknowledge_interrupt( running_machine *machine, UINT16 data )
154139{
155   if (data & 0x01) irq3_pending = 0;
156   if (data & 0x02) display_position_interrupt_pending = 0;
157   if (data & 0x04) vblank_interrupt_pending = 0;
140   neogeo_state *state = (neogeo_state *)machine->driver_data;
158141
142   if (data & 0x01)
143      state->irq3_pending = 0;
144   if (data & 0x02)
145      state->display_position_interrupt_pending = 0;
146   if (data & 0x04)
147      state->vblank_interrupt_pending = 0;
148
159149   update_interrupts(machine);
160150}
161151
162152
163153static TIMER_CALLBACK( display_position_interrupt_callback )
164154{
155   neogeo_state *state = (neogeo_state *)machine->driver_data;
156
165157   if (LOG_VIDEO_SYSTEM) logerror("--- Scanline @ %d,%d\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen));
166   if (display_position_interrupt_control & IRQ2CTRL_ENABLE)
158
159   if (state->display_position_interrupt_control & IRQ2CTRL_ENABLE)
167160   {
168161      if (LOG_VIDEO_SYSTEM) logerror("*** Scanline interrupt (IRQ2) ***  y: %02x  x: %02x\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen));
169      display_position_interrupt_pending = 1;
162      state->display_position_interrupt_pending = 1;
170163
171164      update_interrupts(machine);
172165   }
173166
174   if (display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_REPEAT)
167   if (state->display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_REPEAT)
175168   {
176169      if (LOG_VIDEO_SYSTEM) logerror("AUTOLOAD_REPEAT ");
177170      adjust_display_position_interrupt_timer(machine);
r6779r6780
181174
182175static TIMER_CALLBACK( display_position_vblank_callback )
183176{
184   if (display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_VBLANK)
177   neogeo_state *state = (neogeo_state *)machine->driver_data;
178
179   if (state->display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_VBLANK)
185180   {
186181      if (LOG_VIDEO_SYSTEM) logerror("AUTOLOAD_VBLANK ");
187182      adjust_display_position_interrupt_timer(machine);
188183   }
189184
190185   /* set timer for next screen */
191   timer_adjust_oneshot(display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0);
186   timer_adjust_oneshot(state->display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0);
192187}
193188
194189
195190static TIMER_CALLBACK( vblank_interrupt_callback )
196191{
197   const device_config *upd4990a = devtag_get_device(machine, "upd4990a");
192   neogeo_state *state = (neogeo_state *)machine->driver_data;
198193
199194   if (LOG_VIDEO_SYSTEM) logerror("+++ VBLANK @ %d,%d\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen));
200195
201196   /* add a timer tick to the pd4990a */
202   upd4990a_addretrace(upd4990a);
197   upd4990a_addretrace(state->upd4990a);
203198
204   vblank_interrupt_pending = 1;
199   state->vblank_interrupt_pending = 1;
205200
206201   update_interrupts(machine);
207202
208203   /* set timer for next screen */
209   timer_adjust_oneshot(vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0);
204   timer_adjust_oneshot(state->vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0);
210205}
211206
212207
213static void create_interrupt_timers(running_machine *machine)
208static void create_interrupt_timers( running_machine *machine )
214209{
215   display_position_interrupt_timer = timer_alloc(machine, display_position_interrupt_callback, NULL);
216   display_position_vblank_timer = timer_alloc(machine, display_position_vblank_callback, NULL);
217   vblank_interrupt_timer = timer_alloc(machine, vblank_interrupt_callback, NULL);
210   neogeo_state *state = (neogeo_state *)machine->driver_data;
211   state->display_position_interrupt_timer = timer_alloc(machine, display_position_interrupt_callback, NULL);
212   state->display_position_vblank_timer = timer_alloc(machine, display_position_vblank_callback, NULL);
213   state->vblank_interrupt_timer = timer_alloc(machine, vblank_interrupt_callback, NULL);
218214}
219215
220216
221static void start_interrupt_timers(running_machine *machine)
217static void start_interrupt_timers( running_machine *machine )
222218{
223   timer_adjust_oneshot(vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0);
224   timer_adjust_oneshot(display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0);
219   neogeo_state *state = (neogeo_state *)machine->driver_data;
220   timer_adjust_oneshot(state->vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0);
221   timer_adjust_oneshot(state->display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0);
225222}
226223
227224
r6779r6780
234231
235232static void audio_cpu_irq(const device_config *device, int assert)
236233{
237   cputag_set_input_line(device->machine, "audiocpu", 0, assert ? ASSERT_LINE : CLEAR_LINE);
234   neogeo_state *state = (neogeo_state *)device->machine->driver_data;
235   cpu_set_input_line(state->audiocpu, 0, assert ? ASSERT_LINE : CLEAR_LINE);
238236}
239237
240238
241239static void audio_cpu_assert_nmi(running_machine *machine)
242240{
243   cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, ASSERT_LINE);
241   neogeo_state *state = (neogeo_state *)machine->driver_data;
242   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, ASSERT_LINE);
244243}
245244
246245
247246static WRITE8_HANDLER( audio_cpu_clear_nmi_w )
248247{
249   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE);
248   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
249   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE);
250250}
251251
252252
r6779r6780
257257 *
258258 *************************************/
259259
260static void select_controller(UINT8 data)
260static void select_controller( running_machine *machine, UINT8 data )
261261{
262   controller_select = data;
262   neogeo_state *state = (neogeo_state *)machine->driver_data;
263   state->controller_select = data;
263264}
264265
265266
r6779r6780
305306
306307static WRITE16_HANDLER( io_control_w )
307308{
308   const device_config *upd4990a = devtag_get_device(space->machine, "upd4990a");
309
309   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
310310   switch (offset)
311311   {
312   case 0x00: select_controller(data & 0x00ff); break;
313//  case 0x18: set_output_latch(space->machine, data & 0x00ff); break;
314//  case 0x20: set_output_data(data & 0x00ff); break;
315   case 0x28: upd4990a_control_16_w(upd4990a, 0, data, mem_mask); break;
312   case 0x00: select_controller(space->machine, data & 0x00ff); break;
313//   case 0x18: set_output_latch(space->machine, data & 0x00ff); break;
314//   case 0x20: set_output_data(space->machine, data & 0x00ff); break;
315   case 0x28: upd4990a_control_16_w(state->upd4990a, 0, data, mem_mask); break;
316316//  case 0x30: break; // coin counters
317317//  case 0x31: break; // coin counters
318318//  case 0x32: break; // coin lockout
r6779r6780
334334
335335READ16_HANDLER( neogeo_unmapped_r )
336336{
337   static UINT8 recurse = 0;
337   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
338338   UINT16 ret;
339339
340340   /* unmapped memory returns the last word on the data bus, which is almost always the opcode
341341       of the next instruction due to prefetch */
342342
343343   /* prevent recursion */
344   if (recurse)
344   if (state->recurse)
345345      ret = 0xffff;
346346   else
347347   {
348      recurse = 1;
348      state->recurse = 1;
349349      ret = memory_read_word(space, cpu_get_pc(space->cpu));
350      recurse = 0;
350      state->recurse = 0;
351351   }
352352
353353   return ret;
r6779r6780
355355
356356
357357
358
358359/*************************************
359360 *
360361 *  uPD4990A calendar chip
r6779r6780
388389
389390static CUSTOM_INPUT( get_calendar_status )
390391{
391   const device_config *upd4990a = devtag_get_device(field->port->machine, "upd4990a");
392   return (upd4990a_databit_r(upd4990a, 0) << 1) | upd4990a_testbit_r(upd4990a, 0);
392   neogeo_state *state = (neogeo_state *)field->port->machine->driver_data;
393   return (upd4990a_databit_r(state->upd4990a, 0) << 1) | upd4990a_testbit_r(state->upd4990a, 0);
393394}
394395
395396
r6779r6780
416417}
417418
418419
419static void set_save_ram_unlock(UINT8 data)
420static void set_save_ram_unlock( running_machine *machine, UINT8 data )
420421{
421   save_ram_unlocked = data;
422   neogeo_state *state = (neogeo_state *)machine->driver_data;
423   state->save_ram_unlocked = data;
422424}
423425
424426
425427static WRITE16_HANDLER( save_ram_w )
426428{
427   if (save_ram_unlocked)
429   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
430
431   if (state->save_ram_unlocked)
428432      COMBINE_DATA(&save_ram[offset]);
429433}
430434
r6779r6780
529533
530534static WRITE8_HANDLER( audio_result_w )
531535{
532   if (LOG_CPU_COMM && (audio_result != data)) logerror(" AUD CPU PC   %04x: audio_result_w %02x\n", cpu_get_pc(space->cpu), data);
536   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
533537
534   audio_result = data;
538   if (LOG_CPU_COMM && (state->audio_result != data)) logerror(" AUD CPU PC   %04x: audio_result_w %02x\n", cpu_get_pc(space->cpu), data);
539
540   state->audio_result = data;
535541}
536542
537543
538544static CUSTOM_INPUT( get_audio_result )
539545{
540   UINT32 ret = audio_result;
546   neogeo_state *state = (neogeo_state *)field->port->machine->driver_data;
547   UINT32 ret = state->audio_result;
541548
542549//  if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(cputag_get_cpu(field->port->machine, "maincpu")), ret);
543550
r6779r6780
552559 *
553560 *************************************/
554561
555static void _set_main_cpu_vector_table_source(running_machine *machine)
562static void _set_main_cpu_vector_table_source( running_machine *machine )
556563{
557   memory_set_bank(machine, NEOGEO_BANK_VECTORS, main_cpu_vector_table_source);
564   neogeo_state *state = (neogeo_state *)machine->driver_data;
565   memory_set_bank(machine, NEOGEO_BANK_VECTORS, state->main_cpu_vector_table_source);
558566}
559567
560568
561static void set_main_cpu_vector_table_source(running_machine *machine, UINT8 data)
569static void set_main_cpu_vector_table_source( running_machine *machine, UINT8 data )
562570{
563   main_cpu_vector_table_source = data;
571   neogeo_state *state = (neogeo_state *)machine->driver_data;
572   state->main_cpu_vector_table_source = data;
564573
565574   _set_main_cpu_vector_table_source(machine);
566575}
567576
568577
569static void _set_main_cpu_bank_address(running_machine *machine)
578static void _set_main_cpu_bank_address( running_machine *machine )
570579{
571   memory_set_bankptr(machine, NEOGEO_BANK_CARTRIDGE, &memory_region(machine, "maincpu")[main_cpu_bank_address]);
580   neogeo_state *state = (neogeo_state *)machine->driver_data;
581   memory_set_bankptr(machine, NEOGEO_BANK_CARTRIDGE, &memory_region(machine, "maincpu")[state->main_cpu_bank_address]);
572582}
573583
574584
575void neogeo_set_main_cpu_bank_address(const address_space *space, UINT32 bank_address)
585void neogeo_set_main_cpu_bank_address( const address_space *space, UINT32 bank_address )
576586{
587   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
588
577589   if (LOG_MAIN_CPU_BANKING) logerror("MAIN CPU PC %06x: neogeo_set_main_cpu_bank_address %06x\n", cpu_get_pc(space->cpu), bank_address);
578590
579   main_cpu_bank_address = bank_address;
591   state->main_cpu_bank_address = bank_address;
580592
581593   _set_main_cpu_bank_address(space->machine);
582594}
r6779r6780
604616}
605617
606618
607static void main_cpu_banking_init(running_machine *machine)
619static void main_cpu_banking_init( running_machine *machine )
608620{
609621   const address_space *mainspace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
610622
r6779r6780
627639 *
628640 *************************************/
629641
630static void set_audio_cpu_banking(running_machine *machine)
642static void set_audio_cpu_banking( running_machine *machine )
631643{
644   neogeo_state *state = (neogeo_state *)machine->driver_data;
632645   int region;
633646
634647   for (region = 0; region < 4; region++)
635      memory_set_bank(machine, NEOGEO_BANK_AUDIO_CPU_CART_BANK + region, audio_cpu_banks[region]);
648      memory_set_bank(machine, NEOGEO_BANK_AUDIO_CPU_CART_BANK + region, state->audio_cpu_banks[region]);
636649}
637650
638651
639static void audio_cpu_bank_select(const address_space *space, int region, UINT8 bank)
652static void audio_cpu_bank_select( const address_space *space, int region, UINT8 bank )
640653{
654   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
655
641656   if (LOG_AUDIO_CPU_BANKING) logerror("Audio CPU PC %03x: audio_cpu_bank_select: Region: %d   Bank: %02x\n", cpu_get_pc(space->cpu), region, bank);
642657
643   audio_cpu_banks[region] = bank;
658   state->audio_cpu_banks[region] = bank;
644659
645660   set_audio_cpu_banking(space->machine);
646661}
r6779r6780
678693}
679694
680695
681static void _set_audio_cpu_rom_source(const address_space *space)
696static void _set_audio_cpu_rom_source( const address_space *space )
682697{
698   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
699
683700/*  if (!memory_region(machine, "audiobios"))   */
684      audio_cpu_rom_source = 1;
701      state->audio_cpu_rom_source = 1;
685702
686   memory_set_bank(space->machine, NEOGEO_BANK_AUDIO_CPU_MAIN_BANK, audio_cpu_rom_source);
703   memory_set_bank(space->machine, NEOGEO_BANK_AUDIO_CPU_MAIN_BANK, state->audio_cpu_rom_source);
687704
688705   /* reset CPU if the source changed -- this is a guess */
689   if (audio_cpu_rom_source != audio_cpu_rom_source_last)
706   if (state->audio_cpu_rom_source != state->audio_cpu_rom_source_last)
690707   {
691      audio_cpu_rom_source_last = audio_cpu_rom_source;
708      state->audio_cpu_rom_source_last = state->audio_cpu_rom_source;
692709
693710      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, PULSE_LINE);
694711
695      if (LOG_AUDIO_CPU_BANKING) logerror("Audio CPU PC %03x: selectign %s ROM\n", cpu_get_pc(space->cpu), audio_cpu_rom_source ? "CARTRIDGE" : "BIOS");
712      if (LOG_AUDIO_CPU_BANKING) logerror("Audio CPU PC %03x: selectign %s ROM\n", cpu_get_pc(space->cpu), state->audio_cpu_rom_source ? "CARTRIDGE" : "BIOS");
696713   }
697714}
698715
699716
700static void set_audio_cpu_rom_source(const address_space *space, UINT8 data)
717static void set_audio_cpu_rom_source( const address_space *space, UINT8 data )
701718{
702   audio_cpu_rom_source = data;
719   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
720   state->audio_cpu_rom_source = data;
703721
704722   _set_audio_cpu_rom_source(space);
705723}
706724
707725
708static void audio_cpu_banking_init(running_machine *machine)
726static void audio_cpu_banking_init( running_machine *machine )
709727{
728   neogeo_state *state = (neogeo_state *)machine->driver_data;
710729   int region;
711730   int bank;
712731   UINT8 *rgn;
r6779r6780
732751
733752   /* set initial audio banks --
734753       how does this really work, or is it even neccessary? */
735   audio_cpu_banks[0] = 0x1e;
736   audio_cpu_banks[1] = 0x0e;
737   audio_cpu_banks[2] = 0x06;
738   audio_cpu_banks[3] = 0x02;
754   state->audio_cpu_banks[0] = 0x1e;
755   state->audio_cpu_banks[1] = 0x0e;
756   state->audio_cpu_banks[2] = 0x06;
757   state->audio_cpu_banks[3] = 0x02;
739758
740759   set_audio_cpu_banking(machine);
741760
742   audio_cpu_rom_source_last = 0;
761   state->audio_cpu_rom_source_last = 0;
743762   set_audio_cpu_rom_source(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0);
744763}
745764
r6779r6780
764783      case 0x01: set_main_cpu_vector_table_source(space->machine, bit);
765784               set_audio_cpu_rom_source(space, bit); /* this is a guess */
766785               break;
767      case 0x05: neogeo_set_fixed_layer_source(space->machine,bit); break;
768      case 0x06: set_save_ram_unlock(bit); break;
786      case 0x05: neogeo_set_fixed_layer_source(space->machine, bit); break;
787      case 0x06: set_save_ram_unlock(space->machine, bit); break;
769788      case 0x07: neogeo_set_palette_bank(space->machine, bit); break;
770789
771790      case 0x02: /* unknown - HC32 middle pin 1 */
r6779r6780
795814
796815static MACHINE_START( neogeo )
797816{
817   neogeo_state *state = (neogeo_state *)machine->driver_data;
818
798819   /* set the BIOS bank */
799820   memory_set_bankptr(machine, NEOGEO_BANK_BIOS, memory_region(machine, "mainbios"));
800821
r6779r6780
806827
807828   create_interrupt_timers(machine);
808829
809   /* initialize the celander IC to 'right now' */
810//  calendar_init(machine);
811
812830   /* initialize the memcard data structure */
813831   memcard_data = auto_alloc_array_clear(machine, UINT8, MEMCARD_SIZE);
814832
815833   /* start with an IRQ3 - but NOT on a reset */
816   irq3_pending = 1;
834   state->irq3_pending = 1;
817835
836   /* get devices */
837   state->maincpu = devtag_get_device(machine, "maincpu");
838   state->audiocpu = devtag_get_device(machine, "audiocpu");
839   state->upd4990a = devtag_get_device(machine, "upd4990a");
840
818841   /* register state save */
819   state_save_register_global(machine, display_position_interrupt_control);
820   state_save_register_global(machine, display_counter);
821   state_save_register_global(machine, vblank_interrupt_pending);
822   state_save_register_global(machine, display_position_interrupt_pending);
823   state_save_register_global(machine, irq3_pending);
824   state_save_register_global(machine, audio_result);
825   state_save_register_global(machine, controller_select);
826   state_save_register_global(machine, main_cpu_bank_address);
827   state_save_register_global(machine, main_cpu_vector_table_source);
828   state_save_register_global_array(machine, audio_cpu_banks);
829   state_save_register_global(machine, audio_cpu_rom_source);
830   state_save_register_global(machine, audio_cpu_rom_source_last);
831   state_save_register_global(machine, save_ram_unlocked);
842   state_save_register_global(machine, state->display_position_interrupt_control);
843   state_save_register_global(machine, state->display_counter);
844   state_save_register_global(machine, state->vblank_interrupt_pending);
845   state_save_register_global(machine, state->display_position_interrupt_pending);
846   state_save_register_global(machine, state->irq3_pending);
847   state_save_register_global(machine, state->audio_result);
848   state_save_register_global(machine, state->controller_select);
849   state_save_register_global(machine, state->main_cpu_bank_address);
850   state_save_register_global(machine, state->main_cpu_vector_table_source);
851   state_save_register_global_array(machine, state->audio_cpu_banks);
852   state_save_register_global(machine, state->audio_cpu_rom_source);
853   state_save_register_global(machine, state->audio_cpu_rom_source_last);
854   state_save_register_global(machine, state->save_ram_unlocked);
832855   state_save_register_global_pointer(machine, memcard_data, 0x800);
833   state_save_register_global(machine, output_data);
834   state_save_register_global(machine, output_latch);
835   state_save_register_global(machine, el_value);
856   state_save_register_global(machine, state->output_data);
857   state_save_register_global(machine, state->output_latch);
858   state_save_register_global(machine, state->el_value);
859   state_save_register_global(machine, state->led1_value);
860   state_save_register_global(machine, state->led2_value);
861   state_save_register_global(machine, state->recurse);
836862
837863   state_save_register_postload(machine, aes_postload, NULL);
838864}
r6779r6780
847873
848874static MACHINE_RESET( neogeo )
849875{
876   neogeo_state *state = (neogeo_state *)machine->driver_data;
850877   offs_t offs;
851878   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
852879
853880   /* reset system control registers */
854881   for (offs = 0; offs < 8; offs++)
855882      system_control_w(space, offs, 0, 0x00ff);
883
856884   device_reset(cputag_get_cpu(machine, "maincpu"));
857885
858886   neogeo_reset_rng(machine);
r6779r6780
862890   /* trigger the IRQ3 that was set by MACHINE_START */
863891   update_interrupts(machine);
864892
893   state->recurse = 0;
894
865895   /* AES apparently always uses the cartridge's fixed bank mode */
866896   neogeo_set_fixed_layer_source(machine,1);
867897}
r6779r6780
11961226
11971227static MACHINE_DRIVER_START( neogeo )
11981228
1229   /* driver data */
1230   MDRV_DRIVER_DATA(neogeo_state)
1231
11991232   /* basic machine hardware */
12001233   MDRV_CPU_ADD("maincpu", M68000, NEOGEO_MAIN_CPU_CLOCK)
12011234   MDRV_CPU_PROGRAM_MAP(main_map)
r6779r6780
12131246   MDRV_VIDEO_START(neogeo)
12141247   MDRV_VIDEO_RESET(neogeo)
12151248   MDRV_VIDEO_UPDATE(neogeo)
1249   MDRV_DEFAULT_LAYOUT(layout_neogeo)
12161250
12171251   MDRV_SCREEN_ADD("screen", RASTER)
12181252   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
r6779r6780
12411275 *
12421276 *  Driver initalization
12431277 *
1244? *************************************/
1278 *************************************/
12451279
12461280static DRIVER_INIT( neogeo )
12471281{

Previous 15994 Revisions Next


© 1998-2018 The MESS Team