Previous 15994 Revisions Next

r7549 Thursday 11th March, 2010 at 06:13:52 UTC by MooglyGuy
[CRAFT] Considerably re-wrote the Craft skeleton driver. [Harmony]
- The driver does less now, but it should be easier to add features in the future.
[VSMILE] Added a skeleton driver for the V-Tech V-Smile and ported some SPG video-related code from Unununium. [Segher, Harmony]
[src/mess/drivers]craft.c vii.c
[src/mess/machine]avr8.h*

src/mess/machine/avr8.h
r0r7549
1#ifndef __EMU_MACHINE_AVR8_H__
2#define __EMU_MACHINE_AVR8_H__
3
4// Helpful enums and defines for the Atmel 8-bit AVR series of microcontrollers
5
6enum
7{
8   AVR8_REG_R0 = 0,
9   AVR8_REG_R1,
10   AVR8_REG_R2,
11   AVR8_REG_R3,
12   AVR8_REG_R4,
13   AVR8_REG_R5,
14   AVR8_REG_R6,
15   AVR8_REG_R7,
16   AVR8_REG_R8,
17   AVR8_REG_R9,
18   AVR8_REG_R10,
19   AVR8_REG_R11,
20   AVR8_REG_R12,
21   AVR8_REG_R13,
22   AVR8_REG_R14,
23   AVR8_REG_R15,
24   AVR8_REG_R16,
25   AVR8_REG_R17,
26   AVR8_REG_R18,
27   AVR8_REG_R19,
28   AVR8_REG_R20,
29   AVR8_REG_R21,
30   AVR8_REG_R22,
31   AVR8_REG_R23,
32   AVR8_REG_R24,
33   AVR8_REG_R25,
34   AVR8_REG_R26,
35   AVR8_REG_R27,
36   AVR8_REG_R28,
37   AVR8_REG_R29,
38   AVR8_REG_R30,
39   AVR8_REG_R31,
40
41   AVR8_REG_PINB = 0x23,
42   AVR8_REG_DDRB,
43   AVR8_REG_PORTB,
44   AVR8_REG_PINC,
45   AVR8_REG_DDRC,
46   AVR8_REG_PORTC,
47   AVR8_REG_PIND,
48   AVR8_REG_DDRD,
49   AVR8_REG_PORTD,
50
51   AVR8_REG_TIFR0 = 0x35,
52   AVR8_REG_TIFR1,
53   AVR8_REG_TIFR2,
54
55   AVR8_REG_PCIFR = 0x3b,
56   AVR8_REG_EIFR,
57   AVR8_REG_EIMSK,
58   AVR8_REG_GPIOR0,
59   AVR8_REG_EECR,
60   AVR8_REG_EEDR,
61   AVR8_REG_EEARL,
62   AVR8_REG_EEARH,
63   AVR8_REG_GTCCR,
64   AVR8_REG_TCCR0A,
65   AVR8_REG_TCCR0B,
66   AVR8_REG_TCNT0,
67   AVR8_REG_OCR0A,
68   AVR8_REG_OCR0B,
69
70   AVR8_REG_GPIOR1 = 0x4a,
71   AVR8_REG_GPIOR2,
72   AVR8_REG_SPCR,
73   AVR8_REG_SPSR,
74   AVR8_REG_SPDR,
75
76   AVR8_REG_ACSR = 0x50,
77
78   AVR8_REG_SMCR = 0x53,
79   AVR8_REG_MCUSR,
80   AVR8_REG_MCUCR,
81
82   AVR8_REG_SPMCSR = 0x57,
83
84   AVR8_REG_SPL = 0x5d,
85   AVR8_REG_SPH,
86   AVR8_REG_SREG,
87   AVR8_REG_WDTCSR,
88   AVR8_REG_CLKPR,
89
90   AVR8_REG_PRR = 0X64,
91
92   AVR8_REG_OSCCAL = 0X66,
93
94   AVR8_REG_PCICR = 0X68,
95   AVR8_REG_EICRA,
96
97   AVR8_REG_PCMSK0 = 0X6B,
98   AVR8_REG_PCMSK1,
99   AVR8_REG_PCMSK2,
100   AVR8_REG_TIMSK0,
101   AVR8_REG_TIMSK1,
102   AVR8_REG_TIMSK2,
103
104   AVR8_REG_ADCL = 0X78,
105   AVR8_REG_ADCH,
106   AVR8_REG_ADCSRA,
107   AVR8_REG_ADCSRB,
108   AVR8_REG_ADMUX,
109
110   AVR8_REG_DIDR0 = 0x7e,
111   AVR8_REG_DIDR1,
112   AVR8_REG_TCCR1A,
113   AVR8_REG_TCCR1B,
114   AVR8_REG_TCCR1C,
115
116   AVR8_REG_TCNT1L = 0x84,
117   AVR8_REG_TCNT1H,
118   AVR8_REG_ICR1L,
119   AVR8_REG_ICR1H,
120   AVR8_REG_OCR1AL,
121   AVR8_REG_OCR1AH,
122   AVR8_REG_OCR1BL,
123   AVR8_REG_OCR1BH,
124
125   AVR8_REG_TCCR2A = 0xb0,
126   AVR8_REG_TCCR2B,
127   AVR8_REG_TCNT2,
128   AVR8_REG_OCR2A,
129   AVR8_REG_OCR2B,
130
131   AVR8_REG_ASSR = 0xb6,
132
133   AVR8_REG_TWBR = 0xb8,
134   AVR8_REG_TWSR,
135   AVR8_REG_TWAR,
136   AVR8_REG_TWDR,
137   AVR8_REG_TWCR,
138   AVR8_REG_TWAMR,
139
140   AVR8_REG_UCSR0A = 0xc0,
141   AVR8_REG_UCSR0B,
142   AVR8_REG_UCSR0C,
143
144   AVR8_REG_UBRR0L = 0xc4,
145   AVR8_REG_UBRR0H,
146   AVR8_REG_UDR0
147};
148
149#define AVR8_OCR1BH            (state->regs[AVR8_REG_OCR1BH])
150#define AVR8_OCR1BL            (state->regs[AVR8_REG_OCR1BL])
151#define AVR8_OCR1AH            (state->regs[AVR8_REG_OCR1AH])
152#define AVR8_OCR1AL            (state->regs[AVR8_REG_OCR1AL])
153#define AVR8_ICR1H            (state->regs[AVR8_REG_ICR1H])
154#define AVR8_ICR1L            (state->regs[AVR8_REG_ICR1L])
155#define AVR8_TCNT1H            (state->regs[AVR8_REG_TCNT1H])
156#define AVR8_TCNT1L            (state->regs[AVR8_REG_TCNT1L])
157#define AVR8_TCCR1B            (state->regs[AVR8_REG_TCCR1B])
158#define AVR8_TCCR1A            (state->regs[AVR8_REG_TCCR1A])
159#define AVR8_TIMSK1            (state->regs[AVR8_REG_TIMSK1])
160#define AVR8_TIMSK1_OCIE1A     0x02
161#define AVR8_TIMSK1_OCIE1B     0x04
162#define AVR8_OCR1A            ((AVR8_OCR1AH << 8) | AVR8_OCR1AL)
163#define AVR8_OCR1B            ((AVR8_OCR1BH << 8) | AVR8_OCR1BL)
164#define AVR8_ICR1            ((AVR8_ICR1H  << 8) | AVR8_ICR1L)
165#define AVR8_TCNT1            ((AVR8_TCNT1H << 8) | AVR8_TCNT1L)
166#define AVR8_WGM1            (((AVR8_TCCR1B & 0x18) >> 1) | (AVR8_TCCR1A & 0x03))
167#define AVR8_TCNT1_DIR         (state->tcnt1_direction)
168
169enum
170{
171   AVR8_WGM1_NORMAL = 0,
172   AVR8_WGM1_PWM_8_PC,
173   AVR8_WGM1_PWM_9_PC,
174   AVR8_WGM1_PWM_10_PC,
175   AVR8_WGM1_CTC_OCR,
176   AVR8_WGM1_FAST_PWM_8,
177   AVR8_WGM1_FAST_PWM_9,
178   AVR8_WGM1_FAST_PWM_10,
179   AVR8_WGM1_PWM_PFC_ICR,
180   AVR8_WGM1_PWM_PFC_OCR,
181   AVR8_WGM1_PWM_PC_ICR,
182   AVR8_WGM1_PWM_PC_OCR,
183   AVR8_WGM1_CTC_ICR,
184   AVR8_WGM1_RESERVED,
185   AVR8_WGM1_FAST_PWM_ICR,
186   AVR8_WGM1_FAST_PWM_OCR
187};
188
189#endif // __EMU_MACHINE_AVR8_H__
No newline at end of file
src/mess/drivers/vii.c
r7548r7549
3333         D - SPG243 - The Batman
3434         D - SPG243 - Wall-E
3535         D - SPG243 - Chintendo / KenSingTon / Siatronics / Jungle Soft Vii
36 Partial D - SPG200 - V-Tech V-Smile
3637        ND - Likely many more
3738
3839*******************************************************************************/
r7548r7549
7778   }
7879   screen[320*240];
7980
80   UINT16 io_regs[0x100];
81   UINT16 io_regs[0x200];
8182   UINT16 uart_rx_count;
8283   UINT8 controller_input[8];
8384   UINT32 spg243_mode;
r7548r7549
8788{
8889   SPG243_VII = 0,
8990   SPG243_BATMAN,
91   SPG243_VSMILE,
9092
9193   SPG243_MODEL_COUNT,
9294};
r7548r7549
153155   state->screen[offset].b = expand_rgb5_to_rgb8(rgb);
154156}
155157
156static void vii_blit(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 xoff, UINT32 yoff, UINT32 flags, UINT32 bitmap_addr, UINT16 tile)
158static void vii_blit(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 xoff, UINT32 yoff, UINT32 attr, UINT32 ctrl, UINT32 bitmap_addr, UINT16 tile)
157159{
158160   vii_state *state = (vii_state *)machine->driver_data;
159161   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
160162
161   UINT32 h = 8 << ((flags & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
162   UINT32 w = 8 << ((flags & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);
163   UINT32 h = 8 << ((attr & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
164   UINT32 w = 8 << ((attr & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);
163165
164   UINT32 yflipmask = flags & TILE_Y_FLIP ? h - 1 : 0;
165   UINT32 xflipmask = flags & TILE_X_FLIP ? w - 1 : 0;
166   UINT32 yflipmask = attr & TILE_Y_FLIP ? h - 1 : 0;
167   UINT32 xflipmask = attr & TILE_X_FLIP ? w - 1 : 0;
166168
167   UINT32 nc = ((flags & 0x0003) + 1) << 1;
169   UINT32 nc = ((attr & 0x0003) + 1) << 1;
168170
169   UINT32 palette_offset = (flags & 0x0f00) >> 4;
171   UINT32 palette_offset = (attr & 0x0f00) >> 4;
172   palette_offset >>= nc;
173   palette_offset <<= nc;
170174
171175   UINT32 m = bitmap_addr + nc*w*h/16*tile;
172176   UINT32 bits = 0;
r7548r7549
193197         }
194198         nbits -= nc;
195199
196         pal = palette_offset + (bits >> 16);
200         pal = palette_offset | (bits >> 16);
197201         bits &= 0xffff;
198202
199         if((flags & 0x00100000) && yy < 240)
203         if((ctrl & 0x0010) && yy < 240)
200204         {
201205            xx = (xx - (INT16)state->rowscroll[yy]) & 0x01ff;
202206         }
r7548r7549
206210            UINT16 rgb = state->palette[pal];
207211            if(!(rgb & 0x8000))
208212            {
209               if (flags & 0x4000)
213               if (attr & 0x4000)
210214               {
211215                  vii_mix_pixel(state, xx + 320*yy, rgb);
212216               }
r7548r7549
225229   UINT32 x0, y0;
226230   UINT32 xscroll = regs[0];
227231   UINT32 yscroll = regs[1];
228   UINT32 flags = regs[2];
229   UINT32 flags2 = regs[3];
232   UINT32 attr = regs[2];
233   UINT32 ctrl = regs[3];
230234   UINT32 tilemap = regs[4];
231235   UINT32 palette_map = regs[5];
232236   UINT32 h, w, hn, wn;
233237   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
234238
235   if(!(flags2 & PAGE_ENABLE_MASK))
239   if(!(ctrl & PAGE_ENABLE_MASK))
236240   {
237241      return;
238242   }
239243
240   if(((flags & PAGE_DEPTH_FLAG_MASK) >> PAGE_DEPTH_FLAG_SHIFT) != depth)
244   if(((attr & PAGE_DEPTH_FLAG_MASK) >> PAGE_DEPTH_FLAG_SHIFT) != depth)
241245   {
242246      return;
243247   }
244248
245   h = 8 << ((flags & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
246   w = 8 << ((flags & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);
249   h = 8 << ((attr & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
250   w = 8 << ((attr & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);
247251
248252   hn = 256 / h;
249253   wn = 512 / w;
r7548r7549
254258      {
255259         UINT16 tile = memory_read_word_16le(space, (tilemap + x0 + wn * y0) << 1);
256260         UINT16 palette = 0;
257         UINT32 tileflags = 0;
258261         UINT32 xx, yy;
259262
260263         if(!tile)
r7548r7549
268271            palette >>= 8;
269272         }
270273
271         if(palette & 0x10) // X flip
272         {
273            tileflags |= 4;
274         UINT32 tileattr = attr;
275         UINT32 tilectrl = ctrl;
276         if ((ctrl & 2) == 0)
277         {   // -(1) bld(1) flip(2) pal(4)
278            tileattr &= ~0x000c;
279            tileattr |= (palette >> 2) & 0x000c;   // flip
280
281            tileattr &= ~0x0f00;
282            tileattr |= (palette << 8) & 0x0f00;   // palette
283
284            tileattr &= ~0x0100;
285            tileattr |= (palette << 2) & 0x0100;   // blend
274286         }
275         tileflags |= (palette & 0x0f) << 8;
276287
277288         yy = ((h*y0 - yscroll + 0x10) & 0xff) - 0x10;
278289         xx = (w*x0 - xscroll) & 0x1ff;
279290
280         vii_blit(machine, bitmap, cliprect, xx, yy, (flags2 << 16) | flags | tileflags, bitmap_addr, tile);
291         vii_blit(machine, bitmap, cliprect, xx, yy, tileattr, tilectrl, bitmap_addr, tile);
281292      }
282293   }
283294}
r7548r7549
286297{
287298   vii_state *state = (vii_state *)machine->driver_data;
288299   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
289   UINT16 tile, flags;
300   UINT16 tile, attr;
290301   INT16 x, y;
291302   UINT32 h, w;
292303   UINT32 bitmap_addr = 0x40 * state->video_regs[0x22];
r7548r7549
294305   tile = memory_read_word_16le(space, (base_addr + 0) << 1);
295306   x = memory_read_word_16le(space, (base_addr + 1) << 1);
296307   y = memory_read_word_16le(space, (base_addr + 2) << 1);
297   flags = memory_read_word_16le(space, (base_addr + 3) << 1);
308   attr = memory_read_word_16le(space, (base_addr + 3) << 1);
298309
299   if(((flags & PAGE_DEPTH_FLAG_MASK) >> PAGE_DEPTH_FLAG_SHIFT) != depth)
310   if(!tile)
300311   {
301312      return;
302313   }
303314
315   if(((attr & PAGE_DEPTH_FLAG_MASK) >> PAGE_DEPTH_FLAG_SHIFT) != depth)
316   {
317      return;
318   }
319
304320   if(state->centered_coordinates)
305321   {
306322      x = 160 + x;
307323      y = 120 - y;
308324
309      h = 8 << ((flags & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
310      w = 8 << ((flags & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);
325      h = 8 << ((attr & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
326      w = 8 << ((attr & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);
311327
312328      x -= (w/2);
313329      y -= (h/2) - 8;
r7548r7549
316332   x &= 0x01ff;
317333   y &= 0x01ff;
318334
319   vii_blit(machine, bitmap, cliprect, x, y, flags, bitmap_addr, tile);
335   vii_blit(machine, bitmap, cliprect, x, y, attr, 0, bitmap_addr, tile);
320336}
321337
322338static void vii_blit_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int depth)
323339{
324   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
340   vii_state *state = (vii_state *)machine->driver_data;
325341   UINT32 n;
342
343   if (!(state->video_regs[0x42] & 1))
344   {
345      return;
346   }
347
326348   for(n = 0; n < 256; n++)
327349   {
328      if(memory_read_word_16le(space, (0x2c00 + 4*n) << 1))
350      //if(memory_read_word_16le(space, (0x2c00 + 4*n) << 1))
329351      {
330352         vii_blit_sprite(machine, bitmap, cliprect, depth, 0x2c00 + 4*n);
331353      }
r7548r7549
485507   UINT16 buffer = state->io_regs[5*index + 2];
486508   UINT16 dir    = state->io_regs[5*index + 3];
487509   UINT16 attr   = state->io_regs[5*index + 4];
510   UINT16 special= state->io_regs[5*index + 5];
488511
489512   UINT16 push   = dir;
490513   UINT16 pull   = (~dir) & (~attr);
491   UINT16 what   = (buffer & (push | pull)) ^ (dir &~ attr);
514   UINT16 what   = (buffer & (push | pull));
515   what ^= (dir & ~attr);
516   what &= ~special;
492517
493518   if(state->spg243_mode == SPG243_VII)
494519   {
r7548r7549
525550{
526551}
527552
553static void spg_do_dma(running_machine *machine, UINT32 len)
554{
555   vii_state *state = (vii_state *)machine->driver_data;
556   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
557
558   UINT32 src = ((state->io_regs[0x101] & 0x3f) << 16) | state->io_regs[0x100];
559   UINT32 dst = state->io_regs[0x103] & 0x3fff;
560   UINT32 j;
561
562   for(j = 0; j < len; j++)
563   {
564      memory_write_word_16le(space, (dst+j) << 1, memory_read_word_16le(space, (src+j) << 1));
565   }
566
567   state->io_regs[0x102] = 0;
568}
569
528570static READ16_HANDLER( vii_io_r )
529571{
530572   static const char *gpioregs[] = { "GPIO Data Port", "GPIO Buffer Port", "GPIO Direction Port", "GPIO Attribute Port", "GPIO IRQ/Latch Port" };
r7548r7549
654696         COMBINE_DATA(&state->io_regs[offset]);
655697         break;
656698
699      case 0x32: // UART Reset
700         verboselog(space->machine, 3, "vii_io_r: UART Reset\n");
701         break;
702
657703      case 0x33: // UART Baud Rate
658         verboselog(space->machine, 3, "vii_io_w: UART Baud Rate = %04x (%04x)\n", data, mem_mask);
704         verboselog(space->machine, 3, "vii_io_w: UART Baud Rate = %u\n", 27000000 / 16 / (0x10000 - (state->io_regs[0x34] << 8) - data));
659705         COMBINE_DATA(&state->io_regs[offset]);
660706         break;
661707
662708      case 0x35: // UART TX Data
663         verboselog(space->machine, 3, "vii_io_w: UART TX Data = %04x (%04x)\n", data, mem_mask);
709         verboselog(space->machine, 3, "vii_io_w: UART Baud Rate = %u\n", 27000000 / 16 / (0x10000 - (data << 8) - state->io_regs[0x33]));
664710         COMBINE_DATA(&state->io_regs[offset]);
665711         break;
666712
r7548r7549
705751         state->io_regs[offset] &= ~data;
706752         break;
707753
754      case 0x100: // DMA Source (L)
755      case 0x101: // DMA Source (H)
756      case 0x103: // DMA Destination
757         COMBINE_DATA(&state->io_regs[offset]);
758         break;
759
760      case 0x102: // DMA Length
761         spg_do_dma(space->machine, data);
762         break;
763
708764      default:
709765         verboselog(space->machine, 3, "vii_io_w: Unknown register %04x = %04x (%04x)\n", 0x3800 + offset, data, mem_mask);
710766         COMBINE_DATA(&state->io_regs[offset]);
r7548r7549
769825      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON4 )       PORT_PLAYER(1) PORT_NAME("X Button")
770826INPUT_PORTS_END
771827
828static INPUT_PORTS_START( vsmile )
829   PORT_START("P1")
830      PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP )    PORT_PLAYER(1) PORT_NAME("Joypad Up")
831      PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN )  PORT_PLAYER(1) PORT_NAME("Joypad Down")
832      PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT )  PORT_PLAYER(1) PORT_NAME("Joypad Left")
833      PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_NAME("Joypad Right")
834      PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )        PORT_PLAYER(1) PORT_NAME("A Button")
835      PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 )        PORT_PLAYER(1) PORT_NAME("Menu")
836      PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON3 )        PORT_PLAYER(1) PORT_NAME("B Button")
837      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON4 )       PORT_PLAYER(1) PORT_NAME("X Button")
838INPUT_PORTS_END
839
772840static DEVICE_IMAGE_LOAD( vii_cart )
773841{
774842   vii_state *state = (vii_state *)image->machine->driver_data;
r7548r7549
797865   return INIT_PASS;
798866}
799867
868static DEVICE_IMAGE_LOAD( vsmile_cart )
869{
870   vii_state *state = (vii_state *)image->machine->driver_data;
871   UINT8 *cart = memory_region( image->machine, "cart" );
872   int size = image_length( image );
873
874   if( image_fread( image, cart, size ) != size )
875   {
876      image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file" );
877      return INIT_FAIL;
878   }
879
880   memcpy(state->cart, cart + 0x4000*2, (0x400000 - 0x4000) * 2);
881
882   return INIT_PASS;
883}
884
800885static MACHINE_START( vii )
801886{
802887   vii_state *state = (vii_state *)machine->driver_data;
r7548r7549
878963   MDRV_VIDEO_UPDATE( vii )
879964MACHINE_DRIVER_END
880965
966static MACHINE_DRIVER_START( vsmile )
967
968   MDRV_DRIVER_DATA( vii_state )
969
970   MDRV_CPU_ADD( "maincpu", UNSP, XTAL_27MHz)
971   MDRV_CPU_PROGRAM_MAP( vii_mem )
972   MDRV_CPU_VBLANK_INT("screen", vii_vblank)
973
974   MDRV_MACHINE_START( vii )
975   MDRV_MACHINE_RESET( vii )
976
977   MDRV_SCREEN_ADD( "screen", RASTER )
978   MDRV_SCREEN_REFRESH_RATE(60)
979   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
980   MDRV_SCREEN_SIZE(320, 240)
981   MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 240-1)
982
983   MDRV_PALETTE_LENGTH(32768)
984
985   MDRV_CARTSLOT_ADD( "cart" )
986   MDRV_CARTSLOT_EXTENSION_LIST( "bin" )
987   MDRV_CARTSLOT_MANDATORY
988   MDRV_CARTSLOT_LOAD( vsmile_cart )
989
990   MDRV_VIDEO_START( vii )
991   MDRV_VIDEO_UPDATE( vii )
992MACHINE_DRIVER_END
993
881994static MACHINE_DRIVER_START( batman )
882995
883996   MDRV_DRIVER_DATA( vii_state )
r7548r7549
9201033   i2cmem_init(machine, 0, I2CMEM_SLAVE_ADDRESS, 0, 0x200, NULL);
9211034}
9221035
1036static DRIVER_INIT( vsmile )
1037{
1038   vii_state *state = (vii_state *)machine->driver_data;
1039
1040   state->spg243_mode = SPG243_VSMILE;
1041   state->centered_coordinates = 1;
1042}
1043
9231044ROM_START( vii )
9241045   ROM_REGION( 0x800000, "maincpu", ROMREGION_ERASEFF )      /* dummy region for u'nSP */
9251046
r7548r7549
9311052   ROM_LOAD16_WORD_SWAP( "batman.bin", 0x000000, 0x400000, CRC(46f848e5) SHA1(5875d57bb3fe0cac5d20e626e4f82a0e5f9bb94c) )
9321053ROM_END
9331054
1055ROM_START( vsmile )
1056   ROM_REGION( 0x800000, "maincpu", ROMREGION_ERASEFF )      /* dummy region for u'nSP */
1057
1058   ROM_REGION( 0x2000000, "cart", ROMREGION_ERASE00 )
1059ROM_END
1060
9341061/*    YEAR  NAME     PARENT    COMPAT    MACHINE   INPUT     INIT      COMPANY                                              FULLNAME      FLAGS */
9351062CONS( 2004, batman,  0,        0,        batman,   batman,   batman,   "JAKKS Pacific, Inc. / HotGen, Ltd.",                "The Batman", GAME_NO_SOUND )
936CONS( 2007, vii,     0,        0,        vii,      vii,      vii,      "Jungle Soft / KenSingTon / Chintendo / Siatronics", "Vii",        GAME_NOT_WORKING | GAME_NO_SOUND)
1063CONS( 2005, vsmile,  0,        0,        vsmile,   vsmile,   vsmile,   "V-Tech",                                            "V-Smile",    GAME_NO_SOUND | GAME_NOT_WORKING )
1064CONS( 2007, vii,     0,        0,        vii,      vii,      vii,      "Jungle Soft / KenSingTon / Chintendo / Siatronics", "Vii",        GAME_NO_SOUND )
src/mess/drivers/craft.c
r7548r7549
1/*
2    Linus Akesson's "Craft"
1/*\
2* * Linus Akesson's "Craft"
3* *
4* * Skeleton driver by MooglyGuy
5* * Partial rewrite by Harmony
6\*/
37
4    Skeleton driver by MooglyGuy
5*/
6
78#include "emu.h"
89#include "cpu/avr8/avr8.h"
10#include "machine/avr8.h"
911#include "sound/dac.h"
1012
13#define VERBOSE_LEVEL   (0)
14
15#define ENABLE_VERBOSE_LOG (0)
16
17#if ENABLE_VERBOSE_LOG
18INLINE void verboselog(running_machine *machine, int n_level, const char *s_fmt, ...)
19{
20   if( VERBOSE_LEVEL >= n_level )
21   {
22      va_list v;
23      char buf[ 32768 ];
24      va_start( v, s_fmt );
25      vsprintf( buf, s_fmt, v );
26      va_end( v );
27      logerror( "%08x: %s", cpu_get_pc(devtag_get_device(machine, "maincpu")), buf );
28   }
29}
30#else
31#define verboselog(x,y,z,...)
32#endif
33
1134#define MASTER_CLOCK 20000000
1235
1336/****************************************************\
1437* I/O devices                                        *
1538\****************************************************/
1639
17typedef struct
18{
19    UINT8 r[0x20];
20
21    UINT8 res0[3];
22
23    UINT8 pinb;
24    UINT8 ddrb;
25    UINT8 portb;
26    UINT8 pinc;
27    UINT8 ddrc;
28    UINT8 portc;
29    UINT8 pind;
30    UINT8 ddrd;
31    UINT8 portd;
32
33    UINT8 res1[9];
34
35    UINT8 tifr0;
36    UINT8 tifr1;
37    UINT8 tifr2;
38
39    UINT8 res2[3];
40
41    UINT8 pcifr;
42    UINT8 eifr;
43    UINT8 eimsk;
44    UINT8 gpior0;
45    UINT8 eecr;
46    UINT8 eedr;
47    UINT8 eearl;
48    UINT8 eearh;
49    UINT8 gtccr;
50    UINT8 tccr0a;
51    UINT8 tccr0b;
52    UINT8 tcnt0;
53    UINT8 ocr0a;
54    UINT8 ocr0b;
55
56    UINT8 res3;
57
58    UINT8 gpior1;
59    UINT8 gpior2;
60    UINT8 spcr;
61    UINT8 spsr;
62    UINT8 spdr;
63
64    UINT8 res4;
65
66    UINT8 acsr;
67
68    UINT8 res5[2];
69
70    UINT8 smcr;
71    UINT8 mcusr;
72    UINT8 mcucr;
73
74    UINT8 res6;
75
76    UINT8 spmcsr;
77
78    UINT8 res7[5];
79
80    UINT16 sp;
81    UINT8 sreg;
82
83    UINT8 wdtcsr;
84    UINT8 clkpr;
85
86    UINT8 res8[2];
87
88    UINT8 prr;
89
90    UINT8 res9;
91
92    UINT8 osccal;
93
94    UINT8 res10;
95
96    UINT8 pcicr;
97    UINT8 eicra;
98
99    UINT8 res11;
100
101    UINT8 pcmsk0;
102    UINT8 pcmsk1;
103    UINT8 pcmsk2;
104    UINT8 timsk0;
105    UINT8 timsk1;
106    UINT8 timsk2;
107
108    UINT8 res12[7];
109
110    UINT8 adcl;
111    UINT8 adch;
112    UINT8 adcsra;
113    UINT8 adcsrb;
114    UINT8 admux;
115
116    UINT8 res13;
117
118    UINT8 didr0;
119    UINT8 didr1;
120    UINT8 tccr1a;
121    UINT8 tccr1b;
122    UINT8 tccr1c;
123
124    UINT8 res14;
125
126    UINT16 tcnt1;
127    UINT16 icr1;
128    UINT16 ocr1a;
129    UINT16 ocr1b;
130
131    UINT8 res15[36];
132
133    UINT8 tccr2a;
134    UINT8 tccr2b;
135    UINT8 tcnt2;
136    UINT8 ocr2a;
137    UINT8 ocr2b;
138
139    UINT8 res16;
140
141    UINT8 assr;
142
143    UINT8 res17;
144
145    UINT8 twbr;
146    UINT8 twsr;
147    UINT8 twar;
148    UINT8 twdr;
149    UINT8 twcr;
150    UINT8 twamr;
151
152    UINT8 res18[2];
153
154    UINT8 ucsr0a;
155    UINT8 ucsr0b;
156    UINT8 ucsr0c;
157
158    UINT8 res19;
159
160    UINT8 ubrr0l;
161    UINT8 ubrr0h;
162    UINT8 udr0;
163
164    UINT8 res20[57];
165
166    UINT8 hidden_high;
167
168    INT64 last_tcnt1_cycle;
169
170    emu_timer *ocr1a_timer;
171    emu_timer *ocr1b_timer;
172} avr8_regs;
173
174
17540class craft_state
17641{
17742public:
r7548r7549
17944
18045   craft_state(running_machine &machine) { }
18146
182   avr8_regs regs;
183   int blah;
47   UINT8 regs[0x100];
48   INT32 tcnt1_direction;
49
50   emu_timer* ocr1a_timer;
51   emu_timer* ocr1b_timer;
18452};
18553
186#define AVR8_TIMSK1_OCIE1A  0x02
187#define AVR8_TIMSK1_OCIE1B  0x04
188
189static UINT64 avr8_get_timer_1_frequency(avr8_regs *device)
54#if 0
55static UINT64 avr8_get_timer_1_frequency(craft_state *state)
19056{
19157    UINT64 frequency = 0;
192    switch(device->tccr1b & 0x07)
58    switch(AVR8_TCCR1B & 0x07)
19359    {
19460        case 0: // No clock source (Timer/Counter stopped).
19561        case 6: // External clock source on T1 pin.  Clock on falling edge.
r7548r7549
21884            break;
21985
22086        default:
221            frequency = 0;
222            printf( "device->tccr1b & 0x07 returned a value not in the range of 0 to 7.  This is\n" );
223            printf( "impossible.  Please ensure that your walls are not bleeding and your bathroom\n" );
224            printf( "has not turned into a psychokinetic vortex.\n" );
87           frequency = 0;
88            fatalerror( "&state->tccr1b & 0x07 returned a value not in the range of 0 to 7.\n" );
22589            break;
22690    }
22791
22892    return frequency;
22993}
23094
231static void avr8_maybe_start_timer_1(avr8_regs *device)
95static UINT16 avr8_get_tc1_top(craft_state *state)
23296{
233    UINT64 frequency = avr8_get_timer_1_frequency(device);
97   switch(AVR8_WGM1)
98   {
99      case AVR8_WGM1_NORMAL:
100         return 0xffff;
101
102      case AVR8_WGM1_PWM_8_PC:
103      case AVR8_WGM1_FAST_PWM_8:
104         return 0x00ff;
105
106      case AVR8_WGM1_PWM_9_PC:
107      case AVR8_WGM1_FAST_PWM_9:
108         return 0x01ff;
109
110      case AVR8_WGM1_PWM_10_PC:
111      case AVR8_WGM1_FAST_PWM_10:
112         return 0x03ff;
113
114      case AVR8_WGM1_CTC_ICR:
115      case AVR8_WGM1_PWM_PFC_ICR:
116      case AVR8_WGM1_PWM_PC_ICR:
117      case AVR8_WGM1_FAST_PWM_ICR:
118         return AVR8_ICR1;
119
120      case AVR8_WGM1_CTC_OCR:
121      case AVR8_WGM1_PWM_PFC_OCR:
122      case AVR8_WGM1_PWM_PC_OCR:
123      case AVR8_WGM1_FAST_PWM_OCR:
124         return AVR8_OCR1A;
125
126      case AVR8_WGM1_RESERVED:
127         logerror("Attempting to retrieve TOP for a reserved waveform generation mode\n");
128         return 0xffff;
129   }
130   return 0xffff;
131}
132
133enum
134{
135   AVR8_REG_A = 0,
136   AVR8_REG_B,
137};
138
139static UINT16 avr8_get_tc1_distance(craft_state *state, INT32 reg)
140{
141   UINT16 top = avr8_get_tc1_top(state);
142   UINT16 ocr = (reg == AVR8_REG_A) ? AVR8_OCR1A : AVR8_OCR1B;
143   if(AVR8_TCNT1_DIR > 0)
144   {
145      if(AVR8_TCNT1 < ocr)
146      {
147         return ocr - AVR8_TCNT1;
148      }
149      else
150      {
151         return top - AVR8_TCNT1;
152      }
153   }
154   else
155   {
156      if(AVR8_TCNT1 > ocr)
157      {
158         return AVR8_TCNT1 - ocr;
159      }
160      else
161      {
162         return ocr;
163      }
164   }
165   return 0xffff;
166}
167
168static void avr8_maybe_start_timer_1(craft_state *state)
169{
170    UINT64 frequency = avr8_get_timer_1_frequency(state);
234171    if(frequency == 0)
235172    {
236        timer_adjust_oneshot(device->ocr1a_timer, attotime_never, 0);
237        timer_adjust_oneshot(device->ocr1b_timer, attotime_never, 0);
173        timer_adjust_oneshot(state->ocr1a_timer, attotime_never, 0);
174        timer_adjust_oneshot(state->ocr1b_timer, attotime_never, 0);
238175    }
239176    else
240177    {
241        UINT16 wrap_count_a = (UINT16)(((UINT32)device->ocr1a - (UINT32)device->tcnt1) & 0x0000ffff);
242        UINT16 wrap_count_b = (UINT16)(((UINT32)device->ocr1b - (UINT32)device->tcnt1) & 0x0000ffff);
243        attotime period_a = attotime_mul(ATTOTIME_IN_HZ(frequency), wrap_count_a);
244        attotime period_b = attotime_mul(ATTOTIME_IN_HZ(frequency), wrap_count_b);
245        if(device->timsk1 & AVR8_TIMSK1_OCIE1A)
246        {
247            timer_adjust_oneshot(device->ocr1a_timer, period_a, 0);
248        }
249        if(device->timsk1 & AVR8_TIMSK1_OCIE1B)
250        {
251            timer_adjust_oneshot(device->ocr1b_timer, period_b, 0);
252        }
178        attotime period_a = attotime_mul(ATTOTIME_IN_HZ(frequency), avr8_get_tc1_distance(state, AVR8_REG_A));
179        attotime period_b = attotime_mul(ATTOTIME_IN_HZ(frequency), avr8_get_tc1_distance(state, AVR8_REG_B));
180      timer_adjust_oneshot(state->ocr1a_timer, period_a, 0);
181      timer_adjust_oneshot(state->ocr1b_timer, period_b, 0);
253182    }
254183}
184#endif
255185
256186static TIMER_CALLBACK( ocr1a_timer_compare )
257187{
258    craft_state *state = (craft_state *)machine->driver_data;
259    avr8_regs *regs = &state->regs;
188    //craft_state *state = (craft_state *)machine->driver_data;
189    //avr8_regs *regs = &state->regs;
260190
261    printf( "ocr1a_timer_compare %d\n", state->blah++ );
262    avr8_maybe_start_timer_1(regs);
191   // TODO
263192
264    // Inaccurate
265    cpu_set_input_line(devtag_get_device(machine, "maincpu"), AVR8_INT_T1COMPA, ASSERT_LINE);
193    //avr8_maybe_start_timer_1(regs);
194    //cpu_set_input_line(devtag_get_device(machine, "maincpu"), AVR8_INT_T1COMPA, ASSERT_LINE);
266195}
267196
268197static TIMER_CALLBACK( ocr1b_timer_compare )
269198{
270    craft_state *state = (craft_state *)machine->driver_data;
271    avr8_regs *regs = &state->regs;
199    //craft_state *state = (craft_state *)machine->driver_data;
200    //avr8_regs *regs = &state->regs;
272201
273    printf( "ocr1b_timer_compare\n" );
274    avr8_maybe_start_timer_1(regs);
202   // TODO
275203
276    // Inaccurate
277    cpu_set_input_line(devtag_get_device(machine, "maincpu"), AVR8_INT_T1COMPB, ASSERT_LINE);
204    //avr8_maybe_start_timer_1(regs);
205    //cpu_set_input_line(devtag_get_device(machine, "maincpu"), AVR8_INT_T1COMPB, ASSERT_LINE);
278206}
279207
280208static READ8_HANDLER( avr8_read )
281209{
282210    craft_state *state = (craft_state *)space->machine->driver_data;
283    avr8_regs *regs = &state->regs;
284211
212   if(offset <= AVR8_REG_R31)
213   {
214      return state->regs[offset];
215   }
216
285217    switch( offset )
286218    {
287        case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
288        case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
289        case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
290        case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
291            return regs->r[offset];
292        case 0x24:
293            printf( "AVR8: R: regs->ddrb (%02x)\n", regs->ddrb );
294            return regs->ddrb;
295        case 0x25:
296            printf( "AVR8: R: regs->portb (%02x)\n", regs->portb );
297            return regs->portb;
298        case 0x27:
299            printf( "AVR8: R: regs->ddrc (%02x)\n", regs->ddrc );
300            return regs->ddrc;
301        case 0x2a:
302            printf( "AVR8: R: regs->ddrd (%02x)\n", regs->ddrd );
303            return regs->ddrd;
304        case 0x4c:
305            printf( "AVR8: R: regs->spcr (%02x)\n", regs->spcr );
306            return regs->spcr;
307        case 0x4d:
308            printf( "AVR8: R: regs->spsr (%02x)\n", regs->spsr );
309            return regs->spsr;
310        case 0x5d:
311            //printf( "AVR8: R: regs->spl (%02x)\n", regs->spl );
312            return regs->sp & 0x00ff;
313        case 0x5e:
314            //printf( "AVR8: R: regs->sph (%02x)\n", regs->sph );
315            return (regs->sp >> 8) & 0x00ff;
316        case 0x5f:
317            return regs->sreg;
318        case 0x6f:
319            printf( "AVR8: R: regs->timsk1 (%02x)\n", regs->timsk1 );
320            return regs->timsk1;
321        case 0x80:
322            printf( "AVR8: R: regs->tccr1a (%02x)\n", regs->tccr1a );
323            return regs->tccr1a;
324        case 0x81:
325            printf( "AVR8: R: regs->tccr1b (%02x)\n", regs->tccr1b );
326            return regs->tccr1b;
327        case 0x84:
328        {
329            //INT64 divisor = 1;
330#if 0
331            INT64 update = (INT64)(cpu_get_total_cycles(space->cpu)) - last_tcnt1_cycle;
332            switch(device->tccr1b & 0x07)
333            {
334                case 0: // No clock source (Timer/Counter stopped).
335                case 1: // clk / 1 (No prescaling)
336                case 6: // External clock source on T1 pin.  Clock on falling edge.
337                case 7: // External clock source on T1 pin.  Clock on rising edge.
338                    divisor = 1;
339                    break;
340
341                case 2: // clk / 8 (From prescaler)
342                    divisor = 8;
343                    break;
344
345                case 3: // clk / 64 (From prescaler)
346                    divisor = 64;
347                    break;
348
349                case 4: // clk / 256 (From prescaler)
350                    divisor = 256;
351                    break;
352
353                case 5: // clk / 1024 (From prescaler)
354                    divisor = 1024;
355                    break;
356
357                default:
358                    divisor = 1;
359                    printf( "device->tccr1b & 0x07 returned a value not in the range of 0 to 7.  This is\n" );
360                    printf( "impossible.  Please ensure that your walls are not bleeding and your bathroom\n" );
361                    printf( "has not turned into a psychokinetic vortex.\n" );
362                    break;
363            }
364            diff /= divisor;
365            diff %= regs->ocr1a;
366            printf( "AVR8: R: regs->tcnt1l read: %04x\n",  );
367#endif
368            break;
369        }
370
371        case 0x85:
372            printf( "AVR8: R: regs->tcnt1h\n" );
373            break;
374        case 0x88:
375            printf( "AVR8: R: regs->ocr1al (%02x)\n", regs->ocr1a & 0x00ff );
376            return regs->ocr1a & 0x00ff;
377        case 0x89:
378            printf( "AVR8: R: regs->ocr1ah (%02x)\n", (regs->ocr1a >> 8) & 0x00ff );
379            return (regs->ocr1a >> 8) & 0x00ff;
380        case 0x8a:
381            printf( "AVR8: R: regs->ocr1bl (%02x)\n", regs->ocr1b & 0x00ff );
382            return regs->ocr1b & 0x00ff;
383        case 0x8b:
384            printf( "AVR8: R: regs->ocr1bh (%02x)\n", (regs->ocr1b >> 8) & 0x00ff );
385            return (regs->ocr1b >> 8) & 0x00ff;
386        case 0xb0:
387            printf( "AVR8: R: regs->tccr2a (%02x)\n", regs->tccr2a );
388            return regs->tccr2a;
389        case 0xb1:
390            printf( "AVR8: R: regs->tccr2b (%02x)\n", regs->tccr2b );
391            return regs->tccr2b;
392219        default:
393            printf( "AVR8: Unrecognized register read: %02x\n", offset );
220            verboselog(space->machine, 0, "AVR8: Unrecognized register read: %02x\n", offset );
394221    }
222
395223    return 0;
396224}
397225
398226static WRITE8_HANDLER( avr8_write )
399227{
400228    craft_state *state = (craft_state *)space->machine->driver_data;
401    avr8_regs *regs = &state->regs;
402229
230   if(offset <= AVR8_REG_R31)
231   {
232      state->regs[offset] = data;
233   }
234
403235    switch( offset )
404236    {
405        case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
406        case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
407        case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
408        case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
409            regs->r[offset] = data;
410            break;
411        case 0x24:
412            printf( "AVR8: W: regs->ddrb = %02x\n", data );
413            regs->ddrb = data;
414            break;
415        case 0x25:
416            printf( "AVR8: W: regs->portb = %02x\n", data );
417            regs->portb = data;
418            break;
419        case 0x27:
420            printf( "AVR8: W: regs->ddrc = %02x\n", data );
421            regs->ddrc = data;
422            break;
423        case 0x2a:
424            printf( "AVR8: W: regs->ddrd = %02x\n", data );
425            regs->ddrd = data;
426            break;
427        case 0x2b:
428            dac_data_w(devtag_get_device(space->machine, "dac"), data);
429            break;
430        case 0x4c:
431            printf( "AVR8: W: regs->spcr = %02x\n", data );
432            regs->spcr = data;
433            break;
434        case 0x4d:
435            printf( "AVR8: W: regs->spsr = %02x\n", data );
436            regs->spsr = data;
437            break;
438        case 0x5d:
439            //printf( "AVR8: W: regs->sp(L) = %02x\n", data );
440            regs->sp = (regs->hidden_high << 8) | data;
441            break;
442        case 0x5e:
443            //printf( "AVR8: W: regs->sp(H) = %02x\n", data );
444            regs->hidden_high = data & 0x07;
445            break;
446        case 0x5f:
447            regs->sreg = data;
448            break;
449        case 0x6f:
450            printf( "AVR8: W: regs->timsk1 = %02x\n", data );
451            regs->timsk1 = data;
452            avr8_maybe_start_timer_1(regs);
453            break;
454        case 0x80:
455            printf( "AVR8: W: regs->tccr1a = %02x\n", data );
456            regs->tccr1a = data;
457            break;
458        case 0x81:
459            printf( "AVR8: W: regs->tccr1b = %02x\n", data );
460            regs->tccr1b = data;
461            break;
462        case 0x88:
463            printf( "AVR8: W: regs->ocr1a(L) = %02x\n", data );
464            regs->ocr1a = (regs->hidden_high << 8) | data;
465            avr8_maybe_start_timer_1(regs);
466            break;
467        case 0x89:
468            printf( "AVR8: W: regs->ocr1a(H) = %02x\n", data );
469            regs->hidden_high = data;
470            break;
471        case 0x8a:
472            printf( "AVR8: W: regs->ocr1b(L) = %02x\n", data );
473            regs->ocr1b = (regs->hidden_high << 8) | data;
474            avr8_maybe_start_timer_1(regs);
475            break;
476        case 0x8b:
477            printf( "AVR8: W: regs->ocr1b(H) = %02x\n", data );
478            regs->hidden_high = data;
479            break;
480        case 0xb0:
481            printf( "AVR8: W: regs->tccr2a = %02x\n", data );
482            regs->tccr2a = data;
483            break;
484        case 0xb1:
485            printf( "AVR8: W: regs->tccr2b = %02x\n", data );
486            regs->tccr2b = data;
487            break;
488237        default:
489            printf( "AVR8: Unrecognized register write: %02x = %02x\n", offset, data );
238            verboselog(space->machine, 0, "AVR8: Unrecognized register write: %02x = %02x\n", offset, data );
490239    }
491240}
492241
r7548r7549
528277static DRIVER_INIT( craft )
529278{
530279    craft_state *state = (craft_state *)machine->driver_data;
531    avr8_regs *regs = &state->regs;
532280
533    regs->ocr1a_timer = timer_alloc(machine, ocr1a_timer_compare, 0);
534    regs->ocr1b_timer = timer_alloc(machine, ocr1b_timer_compare, 0);
281    state->ocr1a_timer = timer_alloc(machine, ocr1a_timer_compare, 0);
282    state->ocr1b_timer = timer_alloc(machine, ocr1b_timer_compare, 0);
535283}
536284
537285static MACHINE_RESET( craft )
538286{
539287    craft_state *state = (craft_state *)machine->driver_data;
540    avr8_regs *regs = &state->regs;
541288
542    regs->timsk1 = 0;
543    regs->tcnt1 = 0;
544    regs->ocr1a = 0;
545    regs->ocr1b = 0;
546    regs->icr1 = 0;
547    regs->last_tcnt1_cycle = 0;
289    AVR8_TIMSK1 = 0;
290    AVR8_OCR1AH = 0;
291    AVR8_OCR1AL = 0;
292    AVR8_OCR1BH = 0;
293    AVR8_OCR1BL = 0;
294    AVR8_ICR1H = 0;
295    AVR8_ICR1L = 0;
296    AVR8_TCNT1H = 0;
297    AVR8_TCNT1L = 0;
548298
549299    dac_data_w(devtag_get_device(machine, "dac"), 0x00);
550300}
r7548r7549
587337ROM_END
588338
589339/*   YEAR  NAME      PARENT    COMPAT    MACHINE   INPUT     INIT      COMPANY          FULLNAME */
590CONS(2008, craft,    0,        0,        craft,    craft,    craft,    "Linus Akesson", "Craft", GAME_NO_SOUND | GAME_NOT_WORKING)
340CONS(2008, craft,    0,        0,        craft,    craft,    craft,    "Linus Akesson", "Craft", GAME_NO_SOUND | GAME_NOT_WORKING)
No newline at end of file

Previous 15994 Revisions Next


© 1998-2018 The MESS Team