Previous 15994 Revisions Next

r5887 Friday 25th September, 2009 at 12:44:31 UTC by Miodrag Milanović
[B2M] Adding state structure.
[src/mess/drivers]b2m.c
[src/mess/includes]b2m.h
[src/mess/machine]b2m.c
[src/mess/video]b2m.c

src/mess/video/b2m.c
r5886r5887
2020    UINT8 code2;
2121    UINT8 col;
2222   int y, x, b;
23   b2m_state *state = screen->machine->driver_data;
2324     
2425   for (x = 0; x < 48; x++)
2526   {         
2627      for (y = 0; y < 256; y++)
2728      {
28         if (b2m_video_page==0) {
29            code1 = mess_ram[0x11000 + x*256 + ((y + b2m_video_scroll) & 0xff)];
30            code2 = mess_ram[0x15000 + x*256 + ((y + b2m_video_scroll) & 0xff)];
29         if (state->b2m_video_page==0) {
30            code1 = mess_ram[0x11000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
31            code2 = mess_ram[0x15000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
3132         } else {
32            code1 = mess_ram[0x19000 + x*256 + ((y + b2m_video_scroll) & 0xff)];
33            code2 = mess_ram[0x1d000 + x*256 + ((y + b2m_video_scroll) & 0xff)];
33            code1 = mess_ram[0x19000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
34            code2 = mess_ram[0x1d000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
3435         }         
3536         for (b = 7; b >= 0; b--)
3637         {                       
src/mess/includes/b2m.h
r5886r5887
44 *
55 ****************************************************************************/
66
7#ifndef b2m_H_
8#define b2m_H_
7#ifndef B2M_H_
8#define B2M_H_
99
1010#include "machine/i8255a.h"
1111#include "machine/pit8253.h"
r5886r5887
1313#include "sound/speaker.h"
1414#include "sound/wave.h"
1515
16typedef struct _b2m_state b2m_state;
17struct _b2m_state
18{
19   UINT8 b2m_8255_porta;
20   UINT8 b2m_video_scroll;
21   UINT8 b2m_8255_portc;
22
23   UINT8 b2m_video_page;
24   UINT8 b2m_drive;
25   UINT8 b2m_side;
26
27   UINT8 b2m_romdisk_lsb;
28   UINT8 b2m_romdisk_msb;
29
30   UINT8 b2m_color[4];
31   UINT8 b2m_localmachine;
32   UINT8 vblank_state;
33   
34   /* devices */
35   const device_config *fdc;
36   const device_config *pic;
37   const device_config *speaker;
38};
39
1640/*----------- defined in machine/b2m.c -----------*/
1741
18extern UINT8 b2m_video_page;
19extern UINT16 b2m_video_scroll;
20
2142extern const struct pit8253_config b2m_pit8253_intf;
22
2343extern const struct pic8259_interface b2m_pic8259_config;
2444
2545extern const i8255a_interface b2m_ppi8255_interface_1;
src/mess/machine/b2m.c
r5886r5887
1717#include "machine/msm8251.h"
1818#include "includes/b2m.h"
1919
20static int b2m_8255_porta;
21UINT16 b2m_video_scroll;
22static int b2m_8255_portc;
23
24UINT8 b2m_video_page;
25static UINT8 b2m_drive;
26static UINT8 b2m_side;
27
28static UINT8 b2m_romdisk_lsb;
29static UINT8 b2m_romdisk_msb;
30
31static UINT8 b2m_color[4];
32static UINT8 b2m_localmachine;
33
34
3520static READ8_HANDLER (b2m_keyboard_r )
3621{     
3722   UINT8 key = 0x00;
r5886r5887
155140
156141static PIT8253_OUTPUT_CHANGED(bm2_pit_out0)
157142{
158   pic8259_set_irq_line(devtag_get_device(device->machine, "pic8259"),1,state);     
143   b2m_state *st = device->machine->driver_data;
144   pic8259_set_irq_line(st->pic,1,state);     
159145}
160146
161147
162148static PIT8253_OUTPUT_CHANGED(bm2_pit_out1)
163149{   
164   const device_config *speaker = devtag_get_device(device->machine, "speaker");
165   
166   speaker_level_w(speaker, state);
150   b2m_state *st = device->machine->driver_data;   
151   speaker_level_w(st->speaker, state);
167152
168153}
169154
r5886r5887
193178
194179static WRITE8_DEVICE_HANDLER (b2m_8255_porta_w )
195180{   
196   b2m_8255_porta = data;
181   b2m_state *state = device->machine->driver_data;
182   state->b2m_8255_porta = data;
197183}
198184static WRITE8_DEVICE_HANDLER (b2m_8255_portb_w )
199185{   
200   b2m_video_scroll = data;
186   b2m_state *state = device->machine->driver_data;
187   state->b2m_video_scroll = data;
201188}
202189
203190static WRITE8_DEVICE_HANDLER (b2m_8255_portc_w )
204191{   
205   b2m_8255_portc = data;
206   b2m_set_bank(device->machine, b2m_8255_portc & 7);
207   b2m_video_page = (b2m_8255_portc >> 7) & 1;
192   b2m_state *state = device->machine->driver_data;
193
194   state->b2m_8255_portc = data;
195   b2m_set_bank(device->machine, state->b2m_8255_portc & 7);
196   state->b2m_video_page = (state->b2m_8255_portc >> 7) & 1;
208197}
209198
210199static READ8_DEVICE_HANDLER (b2m_8255_portb_r )
211200{
212   return b2m_video_scroll;
201   b2m_state *state = device->machine->driver_data;
202   return state->b2m_video_scroll;
213203}
214204
215205I8255A_INTERFACE( b2m_ppi8255_interface_1 )
r5886r5887
228218{     
229219   UINT8 drive = ((data >> 1) & 1) ^ 1;
230220   UINT8 side  = (data  & 1) ^ 1;   
231   const device_config *fdc = devtag_get_device(device->machine, "wd1793");
232   
233   if (b2m_drive!=drive) {
234      wd17xx_set_drive(fdc,drive);
235      b2m_drive = drive;
221   b2m_state *state = device->machine->driver_data;
222
223   if (state->b2m_drive!=drive) {
224      wd17xx_set_drive(state->fdc,drive);
225      state->b2m_drive = drive;
236226   }
237   if (b2m_side!=side) {
238      wd17xx_set_side(fdc,side);
239      b2m_side = side;
227   if (state->b2m_side!=side) {
228      wd17xx_set_side(state->fdc,side);
229      state->b2m_side = side;
240230   }
241231}
242232
r5886r5887
252242
253243static READ8_DEVICE_HANDLER (b2m_romdisk_porta_r )
254244{
245   b2m_state *state = device->machine->driver_data;
246
255247   UINT8 *romdisk = memory_region(device->machine, "maincpu") + 0x12000;     
256   return romdisk[b2m_romdisk_msb*256+b2m_romdisk_lsb];   
248   return romdisk[state->b2m_romdisk_msb*256+state->b2m_romdisk_lsb];   
257249}
258250
259251static WRITE8_DEVICE_HANDLER (b2m_romdisk_portb_w )
260252{   
261   b2m_romdisk_lsb = data;
253   b2m_state *state = device->machine->driver_data;
254   state->b2m_romdisk_lsb = data;
262255}
263256
264257static WRITE8_DEVICE_HANDLER (b2m_romdisk_portc_w )
265{         
266   b2m_romdisk_msb = data & 0x7f;   
258{
259   b2m_state *state = device->machine->driver_data;
260   state->b2m_romdisk_msb = data & 0x7f;   
267261}
268262
269263I8255A_INTERFACE( b2m_ppi8255_interface_3 )
r5886r5887
280274{     
281275   cputag_set_input_line(device->machine, "maincpu", 0, interrupt ?  HOLD_LINE : CLEAR_LINE); 
282276}
283static UINT8 vblank_state = 0;
284277
285
286278/* Driver initialization */
287279DRIVER_INIT(b2m)
288280{
281   b2m_state *state = machine->driver_data;
282
289283   memset(mess_ram,0,128*1024);   
290   vblank_state = 0;
284   state->vblank_state = 0;
291285}
292286
293287WRITE8_HANDLER ( b2m_palette_w )
294288{
289   b2m_state *state = space->machine->driver_data;
290
295291   UINT8 b = (3 - ((data >> 6) & 3)) * 0x55;
296292   UINT8 g = (3 - ((data >> 4) & 3)) * 0x55;
297293   UINT8 r = (3 - ((data >> 2) & 3)) * 0x55;
298294   
299295   UINT8 bw = (3 - (data & 3)) * 0x55;
300296   
301   b2m_color[offset] = data;     
297   state->b2m_color[offset & 3] = data;     
302298   
303299   if (input_port_read(space->machine,"MONITOR")==1) {
304300      palette_set_color_rgb(space->machine,offset, r, g, b);
r5886r5887
309305
310306READ8_HANDLER ( b2m_palette_r )
311307{
312   return b2m_color[offset];
308   b2m_state *state = space->machine->driver_data;
309   return state->b2m_color[offset];
313310}
314311
315312WRITE8_HANDLER ( b2m_localmachine_w )
316313{
317   b2m_localmachine = data;
314   b2m_state *state = space->machine->driver_data;
315   state->b2m_localmachine = data;
318316}
319317
320318READ8_HANDLER ( b2m_localmachine_r )
321319{
322   return b2m_localmachine;
320   b2m_state *state = space->machine->driver_data;
321   return state->b2m_localmachine;
323322}
324323
324static STATE_POSTLOAD( b2m_postload )
325{
326   b2m_state *state = machine->driver_data;
327   b2m_set_bank(machine, state->b2m_8255_portc & 7);
328}
329
325330MACHINE_START(b2m)
326331{
327   wd17xx_set_pause_time(devtag_get_device(machine, "wd1793"),10);
332   b2m_state *state = machine->driver_data;
333   state->pic = devtag_get_device(machine, "pic8259");
334   state->fdc = devtag_get_device(machine, "wd1793");
335   state->speaker = devtag_get_device(machine, "speaker");
336
337   wd17xx_set_pause_time(state->fdc,10);
338   
339   /* register for state saving */
340   state_save_register_global(machine, state->b2m_8255_porta);
341   state_save_register_global(machine, state->b2m_video_scroll);
342   state_save_register_global(machine, state->b2m_8255_portc);
343   state_save_register_global(machine, state->b2m_video_page);
344   state_save_register_global(machine, state->b2m_drive);
345   state_save_register_global(machine, state->b2m_side);
346   state_save_register_global(machine, state->b2m_romdisk_lsb);
347   state_save_register_global(machine, state->b2m_romdisk_msb);
348   state_save_register_global_pointer(machine, state->b2m_color, 4);
349   state_save_register_global(machine, state->b2m_localmachine);
350   state_save_register_global(machine, state->vblank_state);
351   
352   state_save_register_postload(machine, b2m_postload, NULL);
328353}
329354
330355static IRQ_CALLBACK(b2m_irq_callback)
331356{   
332   return pic8259_acknowledge(devtag_get_device(device->machine, "pic8259"));
357   b2m_state *state = device->machine->driver_data;
358   return pic8259_acknowledge(state->pic);
333359}
334360
335
336361const struct pic8259_interface b2m_pic8259_config = {
337362   b2m_pic_set_int_line
338363};
339364
340365INTERRUPT_GEN (b2m_vblank_interrupt)
341366{   
342   vblank_state++;
343   if (vblank_state>1) vblank_state=0;
344   pic8259_set_irq_line(devtag_get_device(device->machine, "pic8259"), 0, vblank_state);     
367   b2m_state *state = device->machine->driver_data;
368   state->vblank_state++;
369   if (state->vblank_state>1) state->vblank_state=0;
370   pic8259_set_irq_line(state->pic, 0, state->vblank_state);     
345371}
346372
347373MACHINE_RESET(b2m)
348374{   
349   b2m_side = 0;
350   b2m_drive = 0;
375   b2m_state *state = machine->driver_data;
376   state->b2m_side = 0;
377   state->b2m_drive = 0;
351378
352379   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), b2m_irq_callback);
353380   b2m_set_bank(machine, 7);
src/mess/drivers/b2m.c
r5886r5887
193193
194194/* Machine driver */
195195static MACHINE_DRIVER_START( b2m )
196   MDRV_DRIVER_DATA(b2m_state)
196197    /* basic machine hardware */
197198    MDRV_CPU_ADD("maincpu", 8080, 2000000)
198199    MDRV_CPU_PROGRAM_MAP(b2m_mem)
r5886r5887
264265/* Driver */
265266 
266267/*    YEAR  NAME      PARENT  COMPAT  MACHINE    INPUT      INIT      CONFIG COMPANY              FULLNAME   FLAGS */
267COMP( 1989, b2m,    0,        0,      b2m,       b2m,       b2m,     b2m,     "BNPO",                "Bashkiria-2M",    0)
268COMP( 1989, b2mrom,   b2m,    0,      b2mrom,      b2m,       b2m,     b2m,     "BNPO",                "Bashkiria-2M ROM-disk",    0)
268COMP( 1989, b2m,    0,        0,      b2m,       b2m,       b2m,     b2m,     "BNPO",                "Bashkiria-2M",    GAME_SUPPORTS_SAVE)
269COMP( 1989, b2mrom,   b2m,    0,      b2mrom,      b2m,       b2m,     b2m,     "BNPO",                "Bashkiria-2M ROM-disk",    GAME_SUPPORTS_SAVE)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team