Previous 15994 Revisions Next

r3795 Monday 8th December, 2008 at 21:52:41 UTC by Wilbert Pol
Pointer-ified the PDP1/TX0 core.
[PDP1/TX0] Removed usage of Machine.
[src/emu/cpu/pdp1]tx0.c tx0.h
[src/mess/drivers]tx0.c
[src/mess/includes]tx0.h
[src/mess/machine]tx0.c

src/emu/cpu/pdp1/tx0.h
r3794r3795
3636        5: reserved (for unimplemented typ instruction?)
3737        6: p6h
3838        7: p7h */
39   void (*io_handlers[8])(void);
39   void (*io_handlers[8])(const device_config *device);
4040   /* select instruction handler */
41   void (*sel_handler)(void);
41   void (*sel_handler)(const device_config *device);
4242   /* callback called when reset line is pulsed: IO devices should reset */
43   void (*io_reset_callback)(void);
43   void (*io_reset_callback)(const device_config *device);
4444};
4545
4646/* PUBLIC FUNCTIONS */
4747CPU_GET_INFO( tx0_64kw );
4848CPU_GET_INFO( tx0_8kw );
4949
50#define READ_TX0_18BIT(A) ((signed)memory_read_dword_32be(tx0.program, (A)<<2))
51#define WRITE_TX0_18BIT(A,V) (memory_write_dword_32be(tx0.program, (A)<<2,(V)))
52
5350CPU_DISASSEMBLE( tx0_64kw );
5451CPU_DISASSEMBLE( tx0_8kw );
5552
src/emu/cpu/pdp1/tx0.c
r3794r3795
1515#define LOG 0
1616#define LOG_EXTRA 0
1717
18static void execute_instruction_64kw(void);
19static void execute_instruction_8kw(void);
20static void pulse_reset(void);
18static void execute_instruction_64kw(const device_config *device);
19static void execute_instruction_8kw(const device_config *device);
20static void pulse_reset(const device_config *device);
2121
2222
2323/* TX-0 Registers */
24typedef struct
24typedef struct _tx0_state tx0_state;
25struct _tx0_state
2526{
27   const tx0_reset_param_t *iface;
28
2629   /* processor registers */
2730   int mbr;      /* memory buffer register (18 bits) */
2831   int ac;         /* accumulator (18 bits) */
r3794r3795
5962   int address_mask;      /* address mask */
6063   int ir_mask;         /* IR mask */
6164
62   /* 8 standard I/O handlers:
63        0: cpy (8kW only)
64        1: r1l
65        2: dis
66        3: r3l
67        4: prt
68        5: reserved
69        6: p6h
70        7: p7h */
71   void (*io_handlers[8])(void);
72   /* select instruction handler */
73   void (*sel_handler)(void);
74   /* called when reset line is pulsed: IO devices should reset */
75   void (*io_reset_callback)(void);
65   int icount;
7666
7767   const device_config *device;
7868   const address_space *program;
79}
80tx0_Regs;
69};
8170
82#define io_handler_rim 3
8371
84static tx0_Regs tx0;
72#define READ_TX0_18BIT(A) ((signed)memory_read_dword_32be(cpustate->program, (A)<<2))
73#define WRITE_TX0_18BIT(A,V) (memory_write_dword_32be(cpustate->program, (A)<<2,(V)))
8574
86#define PC      tx0.pc
87#define IR      tx0.ir
88#define MBR      tx0.mbr
89#define MAR      tx0.mar
90#define AC      tx0.ac
91#define LR      tx0.lr
92#define XR      tx0.xr
93#define PF      tx0.pf
9475
76#define io_handler_rim 3
77
78#define PC      cpustate->pc
79#define IR      cpustate->ir
80#define MBR      cpustate->mbr
81#define MAR      cpustate->mar
82#define AC      cpustate->ac
83#define LR      cpustate->lr
84#define XR      cpustate->xr
85#define PF      cpustate->pf
86
9587#define ADDRESS_MASK_64KW   0177777
9688#define ADDRESS_MASK_8KW   0017777
9789
9890#define INCREMENT_PC_64KW   (PC = (PC+1) & ADDRESS_MASK_64KW)
9991#define INCREMENT_PC_8KW   (PC = (PC+1) & ADDRESS_MASK_8KW)
10092
101/* public globals */
102static signed int tx0_ICount;
10393
104
105static int tx0_read(offs_t address)
94static int tx0_read(tx0_state *cpustate, offs_t address)
10695{
107   if ((address >= 16) || (tx0.gbl_cm_sel) || ((tx0.cm_sel >> address) & 1))
96   if ((address >= 16) || (cpustate->gbl_cm_sel) || ((cpustate->cm_sel >> address) & 1))
10897      /* core memory (CM) */
10998      return READ_TX0_18BIT(address);
110   else if ((tx0.lr_sel >> address) & 1)
99   else if ((cpustate->lr_sel >> address) & 1)
111100      /* live register (LR) */
112101      return LR;
113102   else
114103      /* toggle switch storage (TSS) */
115      return tx0.tss[address];
104      return cpustate->tss[address];
116105}
117106
118static void tx0_write(offs_t address, int data)
107static void tx0_write(tx0_state *cpustate, offs_t address, int data)
119108{
120   if ((address >= 16) || (tx0.gbl_cm_sel) || ((tx0.cm_sel >> address) & 1))
109   if ((address >= 16) || (cpustate->gbl_cm_sel) || ((cpustate->cm_sel >> address) & 1))
121110      /* core memory (CM) */
122111      WRITE_TX0_18BIT(address, data);
123   else if ((tx0.lr_sel >> address) & 1)
112   else if ((cpustate->lr_sel >> address) & 1)
124113      /* live register (LR) */
125114      LR = data;
126115   else
r3794r3795
131120
132121static void tx0_init_common(int is_64kw, const device_config *device, int index, int clock, cpu_irq_callback irqcallback)
133122{
134   int i;
135   tx0_reset_param_t *param = (tx0_reset_param_t *) device->static_config;
123   tx0_state *cpustate = device->token;
136124
137125   /* clean-up */
138   memset (&tx0, 0, sizeof (tx0));
126   cpustate->iface = device->static_config;
139127
140   /* set up params and callbacks */
141   for (i=0; i<8; i++)
142      tx0.io_handlers[i] = (param) ? param->io_handlers[i] : NULL;
143   tx0.sel_handler = (param) ? param->sel_handler : NULL;
144   tx0.io_reset_callback = (param) ? param->io_reset_callback : NULL;
128   cpustate->address_mask = is_64kw ? ADDRESS_MASK_64KW : ADDRESS_MASK_8KW;
129   cpustate->ir_mask = is_64kw ? 03 : 037;
145130
146   tx0.address_mask = is_64kw ? ADDRESS_MASK_64KW : ADDRESS_MASK_8KW;
147   tx0.ir_mask = is_64kw ? 03 : 037;
148
149   tx0.device = device;
150   tx0.program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
131   cpustate->device = device;
132   cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
151133}
152134
153135static CPU_INIT( tx0_64kw )
r3794r3795
162144
163145static CPU_RESET( tx0 )
164146{
147   tx0_state *cpustate = device->token;
148
165149   /* reset CPU flip-flops */
166   pulse_reset();
150   pulse_reset(device);
167151
168   tx0.gbl_cm_sel = 1;   /* HACK */
152   cpustate->gbl_cm_sel = 1;   /* HACK */
169153}
170154
171155static CPU_GET_CONTEXT( tx0 )
172156{
173   if (dst)
174      *(tx0_Regs *) dst = tx0;
175157}
176158
177159static CPU_SET_CONTEXT( tx0 )
178160{
179   if (src)
180      tx0 = *(tx0_Regs *) src;
181161}
182162
183163
184164/* execute instructions on this CPU until icount expires */
185165static CPU_EXECUTE( tx0_64kw )
186166{
187   tx0_ICount = cycles;
167   tx0_state *cpustate = device->token;
188168
169   cpustate->icount = cycles;
170
189171   do
190172   {
191173      debugger_instruction_hook(device, PC);
192174
193175
194      if (tx0.ioh && tx0.ios)
176      if (cpustate->ioh && cpustate->ios)
195177      {
196         tx0.ioh = 0;
197         tx0.ios = 0;
178         cpustate->ioh = 0;
179         cpustate->ios = 0;
198180      }
199181
200182
201      if ((! tx0.run) && (! tx0.rim))
202         tx0_ICount = 0;   /* if processor is stopped, just burn cycles */
203      else if (tx0.rim)
183      if ((! cpustate->run) && (! cpustate->rim))
184         cpustate->icount = 0;   /* if processor is stopped, just burn cycles */
185      else if (cpustate->rim)
204186      {
205         switch (tx0.rim_step)
187         switch (cpustate->rim_step)
206188         {
207189         case 0:
208190            /* read first word as instruction */
209191            AC = 0;
210            if (tx0.io_handlers[io_handler_rim])
211               (*tx0.io_handlers[io_handler_rim])();   /* data will be transferred to AC */
212            tx0.rim_step = 1;
192            if (cpustate->iface->io_handlers[io_handler_rim])
193               (*cpustate->iface->io_handlers[io_handler_rim])(device);   /* data will be transferred to AC */
194            cpustate->rim_step = 1;
213195            break;
214196
215197         case 1:
216            if (! tx0.ios)
198            if (! cpustate->ios)
217199            {   /* transfer incomplete: wait some more */
218               tx0_ICount = 0;
200               cpustate->icount = 0;
219201            }
220202            else
221203            {   /* data transfer complete */
222               tx0.ios = 0;
204               cpustate->ios = 0;
223205
224206               MBR = AC;
225207               IR = MBR >> 16;      /* basic opcode */
226208               if ((IR == 2) || (IR == 1))    /* trn or add instruction? */
227209               {
228210                  PC = MBR & ADDRESS_MASK_64KW;
229                  tx0.rim = 0;   /* exit read-in mode */
230                  tx0.run = (IR == 2) ? 1 : 0;   /* stop if add instruction */
231                  tx0.rim_step = 0;
211                  cpustate->rim = 0;   /* exit read-in mode */
212                  cpustate->run = (IR == 2) ? 1 : 0;   /* stop if add instruction */
213                  cpustate->rim_step = 0;
232214               }
233215               else if ((IR == 0) || (IR == 3))   /* sto or opr instruction? */
234216               {
235217                  MAR = MBR & ADDRESS_MASK_64KW;
236                  tx0.rim_step = 2;
218                  cpustate->rim_step = 2;
237219               }
238220            }
239221            break;
r3794r3795
241223         case 2:
242224            /* read second word as data */
243225            AC = 0;
244            if (tx0.io_handlers[io_handler_rim])
245               (*tx0.io_handlers[io_handler_rim])();   /* data will be transferred to AC */
246            tx0.rim_step = 3;
226            if (cpustate->iface->io_handlers[io_handler_rim])
227               (*cpustate->iface->io_handlers[io_handler_rim])(device);   /* data will be transferred to AC */
228            cpustate->rim_step = 3;
247229            break;
248230
249231         case 3:
250            if (! tx0.ios)
232            if (! cpustate->ios)
251233            {   /* transfer incomplete: wait some more */
252               tx0_ICount = 0;
234               cpustate->icount = 0;
253235            }
254236            else
255237            {   /* data transfer complete */
256               tx0.ios = 0;
238               cpustate->ios = 0;
257239
258               tx0_write(MAR, MBR = AC);
240               tx0_write(cpustate, MAR, MBR = AC);
259241
260               tx0.rim_step = 0;
242               cpustate->rim_step = 0;
261243            }
262244            break;
263245         }
264246      }
265247      else
266248      {
267         if (tx0.cycle == 0)
249         if (cpustate->cycle == 0)
268250         {   /* fetch new instruction */
269            MBR = tx0_read(MAR = PC);
251            MBR = tx0_read(cpustate, MAR = PC);
270252            INCREMENT_PC_64KW;
271253            IR = MBR >> 16;      /* basic opcode */
272254            MAR = MBR & ADDRESS_MASK_64KW;
273255         }
274256
275         if (! tx0.ioh)
257         if (! cpustate->ioh)
276258         {
277            if ((tx0.stop_cyc0 && (tx0.cycle == 0))
278               || (tx0.stop_cyc1 && (tx0.cycle == 1)))
279               tx0.run = 0;
259            if ((cpustate->stop_cyc0 && (cpustate->cycle == 0))
260               || (cpustate->stop_cyc1 && (cpustate->cycle == 1)))
261               cpustate->run = 0;
280262
281            execute_instruction_64kw();   /* execute instruction */
263            execute_instruction_64kw(device);   /* execute instruction */
282264         }
283265
284         tx0_ICount --;
266         cpustate->icount --;
285267      }
286268   }
287   while (tx0_ICount > 0);
269   while (cpustate->icount > 0);
288270
289   return cycles - tx0_ICount;
271   return cycles - cpustate->icount;
290272}
291273
292274/* execute instructions on this CPU until icount expires */
293275static CPU_EXECUTE( tx0_8kw )
294276{
295   tx0_ICount = cycles;
277   tx0_state *cpustate = device->token;
296278
279   cpustate->icount = cycles;
280
297281   do
298282   {
299283      debugger_instruction_hook(device, PC);
300284
301285
302      if (tx0.ioh && tx0.ios)
286      if (cpustate->ioh && cpustate->ios)
303287      {
304         tx0.ioh = 0;
305         tx0.ios = 0;
288         cpustate->ioh = 0;
289         cpustate->ios = 0;
306290      }
307291
308292
309      if ((! tx0.run) && (! tx0.rim))
310         tx0_ICount = 0;   /* if processor is stopped, just burn cycles */
311      else if (tx0.rim)
293      if ((! cpustate->run) && (! cpustate->rim))
294         cpustate->icount = 0;   /* if processor is stopped, just burn cycles */
295      else if (cpustate->rim)
312296      {
313         switch (tx0.rim_step)
297         switch (cpustate->rim_step)
314298         {
315299         case 0:
316300            /* read first word as instruction */
317301            AC = 0;
318            if (tx0.io_handlers[io_handler_rim])
319               (*tx0.io_handlers[io_handler_rim])();   /* data will be transferred to AC */
320            tx0.rim_step = 1;
302            if (cpustate->iface->io_handlers[io_handler_rim])
303               (*cpustate->iface->io_handlers[io_handler_rim])(device);   /* data will be transferred to AC */
304            cpustate->rim_step = 1;
321305            break;
322306
323307         case 1:
324            if (! tx0.ios)
308            if (! cpustate->ios)
325309            {   /* transfer incomplete: wait some more */
326               tx0_ICount = 0;
310               cpustate->icount = 0;
327311            }
328312            else
329313            {   /* data transfer complete */
330               tx0.ios = 0;
314               cpustate->ios = 0;
331315
332316               MBR = AC;
333317               IR = MBR >> 13;      /* basic opcode */
334318               if ((IR == 16) || (IR == 8))    /* trn or add instruction? */
335319               {
336320                  PC = MBR & ADDRESS_MASK_8KW;
337                  tx0.rim = 0;   /* exit read-in mode */
338                  tx0.run = (IR == 16) ? 1 : 0;   /* stop if add instruction */
339                  tx0.rim_step = 0;
321                  cpustate->rim = 0;   /* exit read-in mode */
322                  cpustate->run = (IR == 16) ? 1 : 0;   /* stop if add instruction */
323                  cpustate->rim_step = 0;
340324               }
341325               else if ((IR == 0) || (IR == 24))   /* sto or opr instruction? */
342326               {
343327                  MAR = MBR & ADDRESS_MASK_8KW;
344                  tx0.rim_step = 2;
328                  cpustate->rim_step = 2;
345329               }
346330            }
347331            break;
r3794r3795
349333         case 2:
350334            /* read second word as data */
351335            AC = 0;
352            if (tx0.io_handlers[io_handler_rim])
353               (*tx0.io_handlers[io_handler_rim])();   /* data will be transferred to AC */
354            tx0.rim_step = 3;
336            if (cpustate->iface->io_handlers[io_handler_rim])
337               (*cpustate->iface->io_handlers[io_handler_rim])(device);   /* data will be transferred to AC */
338            cpustate->rim_step = 3;
355339            break;
356340
357341         case 3:
358            if (! tx0.ios)
342            if (! cpustate->ios)
359343            {   /* transfer incomplete: wait some more */
360               tx0_ICount = 0;
344               cpustate->icount = 0;
361345            }
362346            else
363347            {   /* data transfer complete */
364               tx0.ios = 0;
348               cpustate->ios = 0;
365349
366               tx0_write(MAR, MBR = AC);
350               tx0_write(cpustate, MAR, MBR = AC);
367351
368               tx0.rim_step = 0;
352               cpustate->rim_step = 0;
369353            }
370354            break;
371355         }
372356      }
373357      else
374358      {
375         if (tx0.cycle == 0)
359         if (cpustate->cycle == 0)
376360         {   /* fetch new instruction */
377            MBR = tx0_read(MAR = PC);
361            MBR = tx0_read(cpustate, MAR = PC);
378362            INCREMENT_PC_8KW;
379363            IR = MBR >> 13;      /* basic opcode */
380364            MAR = MBR & ADDRESS_MASK_8KW;
381365         }
382366
383         if (! tx0.ioh)
367         if (! cpustate->ioh)
384368         {
385            if ((tx0.stop_cyc0 && (tx0.cycle == 0))
386               || (tx0.stop_cyc1 && (tx0.cycle == 1)))
387               tx0.run = 0;
369            if ((cpustate->stop_cyc0 && (cpustate->cycle == 0))
370               || (cpustate->stop_cyc1 && (cpustate->cycle == 1)))
371               cpustate->run = 0;
388372
389            execute_instruction_8kw();   /* execute instruction */
373            execute_instruction_8kw(device);   /* execute instruction */
390374         }
391375
392         tx0_ICount -= 1;
376         cpustate->icount -= 1;
393377      }
394378   }
395   while (tx0_ICount > 0);
379   while (cpustate->icount > 0);
396380
397   return cycles - tx0_ICount;
381   return cycles - cpustate->icount;
398382}
399383
400384
401385static CPU_SET_INFO( tx0 )
402386{
387   tx0_state *cpustate = device->token;
388
403389   switch (state)
404390   {
405391   /* --- the following bits of info are set as 64-bit signed integers --- */
406   case CPUINFO_INT_SP:                  (void) info->i;   /* no SP */               break;
392   case CPUINFO_INT_SP:                  (void) info->i;   /* no SP */                     break;
407393   case CPUINFO_INT_PC:
408   case CPUINFO_INT_REGISTER + TX0_PC:         PC = info->i & tx0.address_mask;         break;
409   case CPUINFO_INT_REGISTER + TX0_IR:         IR = info->i & tx0.ir_mask; /* weird idea */break;
410   case CPUINFO_INT_REGISTER + TX0_MBR:      MBR = info->i & 0777777;               break;
411   case CPUINFO_INT_REGISTER + TX0_MAR:      MAR = info->i & tx0.address_mask;         break;
412   case CPUINFO_INT_REGISTER + TX0_AC:         AC = info->i & 0777777;                  break;
413   case CPUINFO_INT_REGISTER + TX0_LR:         LR = info->i & 0777777;                  break;
414   case CPUINFO_INT_REGISTER + TX0_XR:         XR = info->i & 0037777;                  break;
415   case CPUINFO_INT_REGISTER + TX0_PF:         PF = info->i & 077;                     break;
416   case CPUINFO_INT_REGISTER + TX0_TBR:      tx0.tbr = info->i & 0777777;            break;
417   case CPUINFO_INT_REGISTER + TX0_TAC:      tx0.tac = info->i & 0777777;            break;
394   case CPUINFO_INT_REGISTER + TX0_PC:         PC = info->i & cpustate->address_mask;            break;
395   case CPUINFO_INT_REGISTER + TX0_IR:         IR = info->i & cpustate->ir_mask; /* weird idea */   break;
396   case CPUINFO_INT_REGISTER + TX0_MBR:      MBR = info->i & 0777777;                     break;
397   case CPUINFO_INT_REGISTER + TX0_MAR:      MAR = info->i & cpustate->address_mask;            break;
398   case CPUINFO_INT_REGISTER + TX0_AC:         AC = info->i & 0777777;                        break;
399   case CPUINFO_INT_REGISTER + TX0_LR:         LR = info->i & 0777777;                        break;
400   case CPUINFO_INT_REGISTER + TX0_XR:         XR = info->i & 0037777;                        break;
401   case CPUINFO_INT_REGISTER + TX0_PF:         PF = info->i & 077;                           break;
402   case CPUINFO_INT_REGISTER + TX0_TBR:      cpustate->tbr = info->i & 0777777;               break;
403   case CPUINFO_INT_REGISTER + TX0_TAC:      cpustate->tac = info->i & 0777777;               break;
418404   case CPUINFO_INT_REGISTER + TX0_TSS00:
419405   case CPUINFO_INT_REGISTER + TX0_TSS01:
420406   case CPUINFO_INT_REGISTER + TX0_TSS02:
r3794r3795
430416   case CPUINFO_INT_REGISTER + TX0_TSS14:
431417   case CPUINFO_INT_REGISTER + TX0_TSS15:
432418   case CPUINFO_INT_REGISTER + TX0_TSS16:
433   case CPUINFO_INT_REGISTER + TX0_TSS17:      tx0.tss[state-(CPUINFO_INT_REGISTER + TX0_TSS00)] = info->i & 0777777;   break;
434   case CPUINFO_INT_REGISTER + TX0_CM_SEL:      tx0.cm_sel = info->i & 0177777;            break;
435   case CPUINFO_INT_REGISTER + TX0_LR_SEL:      tx0.lr_sel = info->i & 0177777;            break;
436   case CPUINFO_INT_REGISTER + TX0_GBL_CM_SEL:   tx0.gbl_cm_sel = info->i ? 1 : 0;         break;
437   case CPUINFO_INT_REGISTER + TX0_STOP_CYC0:   tx0.stop_cyc0 = info->i ? 1 : 0;         break;
438   case CPUINFO_INT_REGISTER + TX0_STOP_CYC1:   tx0.stop_cyc1 = info->i ? 1 : 0;         break;
439   case CPUINFO_INT_REGISTER + TX0_RUN:      tx0.run = info->i ? 1 : 0;               break;
440   case CPUINFO_INT_REGISTER + TX0_RIM:      tx0.rim = info->i ? 1 : 0;               break;
419   case CPUINFO_INT_REGISTER + TX0_TSS17:      cpustate->tss[state-(CPUINFO_INT_REGISTER + TX0_TSS00)] = info->i & 0777777;   break;
420   case CPUINFO_INT_REGISTER + TX0_CM_SEL:      cpustate->cm_sel = info->i & 0177777;            break;
421   case CPUINFO_INT_REGISTER + TX0_LR_SEL:      cpustate->lr_sel = info->i & 0177777;            break;
422   case CPUINFO_INT_REGISTER + TX0_GBL_CM_SEL:   cpustate->gbl_cm_sel = info->i ? 1 : 0;            break;
423   case CPUINFO_INT_REGISTER + TX0_STOP_CYC0:   cpustate->stop_cyc0 = info->i ? 1 : 0;            break;
424   case CPUINFO_INT_REGISTER + TX0_STOP_CYC1:   cpustate->stop_cyc1 = info->i ? 1 : 0;            break;
425   case CPUINFO_INT_REGISTER + TX0_RUN:      cpustate->run = info->i ? 1 : 0;               break;
426   case CPUINFO_INT_REGISTER + TX0_RIM:      cpustate->rim = info->i ? 1 : 0;               break;
441427   case CPUINFO_INT_REGISTER + TX0_CYCLE:      if (LOG) logerror("tx0_set_reg to cycle counter ignored\n");/* no way!*/ break;
442428   case CPUINFO_INT_REGISTER + TX0_IOH:      if (LOG) logerror("tx0_set_reg to ioh flip-flop ignored\n");/* no way!*/ break;
443429   case CPUINFO_INT_REGISTER + TX0_IOS:      if (LOG) logerror("tx0_set_reg to ios flip-flop ignored\n");/* no way!*/ break;
444   case CPUINFO_INT_REGISTER + TX0_RESET:      pulse_reset();                     break;
445   case CPUINFO_INT_REGISTER + TX0_IO_COMPLETE:tx0.ios = 1;                     break;
430   case CPUINFO_INT_REGISTER + TX0_RESET:      pulse_reset(device);                        break;
431   case CPUINFO_INT_REGISTER + TX0_IO_COMPLETE:cpustate->ios = 1;                           break;
446432   }
447433}
448434
449435
450436CPU_GET_INFO( tx0_64kw )
451437{
438   tx0_state *cpustate = ( device != NULL ) ? device->token : NULL;
439
452440   switch (state)
453441   {
454442   /* --- the following bits of info are returned as 64-bit signed integers --- */
455   case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(tx0);               break;
456   case CPUINFO_INT_INPUT_LINES:               info->i = 0;                     break;
457   case CPUINFO_INT_DEFAULT_IRQ_VECTOR:         info->i = 0;                     break;
458   case CPUINFO_INT_ENDIANNESS:               info->i = ENDIANNESS_BIG;   /*don't care*/   break;
459   case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                     break;
460   case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 1;                     break;
461   case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 4;                     break;
462   case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 4;                     break;
463   case CPUINFO_INT_MIN_CYCLES:               info->i = 1;                     break;
464   case CPUINFO_INT_MAX_CYCLES:               info->i = 3;                     break;
443   case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(tx0_state);               break;
444   case CPUINFO_INT_INPUT_LINES:               info->i = 0;                           break;
445   case CPUINFO_INT_DEFAULT_IRQ_VECTOR:         info->i = 0;                           break;
446   case CPUINFO_INT_ENDIANNESS:               info->i = ENDIANNESS_BIG;   /*don't care*/      break;
447   case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                           break;
448   case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 1;                           break;
449   case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 4;                           break;
450   case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 4;                           break;
451   case CPUINFO_INT_MIN_CYCLES:               info->i = 1;                           break;
452   case CPUINFO_INT_MAX_CYCLES:               info->i = 3;                           break;
465453
466   case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM:   info->i = 32;               break;
467   case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 16;               break;
468   case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = -2;               break;
469   case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA:   info->i = 0;               break;
470   case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA:    info->i = 0;               break;
471   case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA:    info->i = 0;               break;
472   case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO:      info->i = 0;               break;
473   case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO:       info->i = 0;               break;
474   case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO:       info->i = 0;               break;
454   case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM:   info->i = 32;                     break;
455   case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 16;                     break;
456   case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = -2;                     break;
457   case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA:   info->i = 0;                     break;
458   case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA:    info->i = 0;                     break;
459   case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA:    info->i = 0;                     break;
460   case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO:      info->i = 0;                     break;
461   case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO:       info->i = 0;                     break;
462   case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO:       info->i = 0;                     break;
475463
476   case CPUINFO_INT_SP:                     info->i = 0;   /* no SP */            break;
477   case CPUINFO_INT_PC:                     info->i = PC;                     break;
478   case CPUINFO_INT_PREVIOUSPC:               info->i = 0;   /* TODO??? */         break;
464   case CPUINFO_INT_SP:                     info->i = 0;   /* no SP */                  break;
465   case CPUINFO_INT_PC:                     info->i = PC;                           break;
466   case CPUINFO_INT_PREVIOUSPC:               info->i = 0;   /* TODO??? */               break;
479467
480   case CPUINFO_INT_REGISTER + TX0_PC:            info->i = PC;                     break;
481   case CPUINFO_INT_REGISTER + TX0_IR:            info->i = IR;                     break;
482   case CPUINFO_INT_REGISTER + TX0_MBR:         info->i = MBR;                     break;
483   case CPUINFO_INT_REGISTER + TX0_MAR:         info->i = MAR;                     break;
484   case CPUINFO_INT_REGISTER + TX0_AC:            info->i = AC;                     break;
485   case CPUINFO_INT_REGISTER + TX0_LR:            info->i = LR;                     break;
486   case CPUINFO_INT_REGISTER + TX0_XR:            info->i = XR;                     break;
487   case CPUINFO_INT_REGISTER + TX0_PF:            info->i = PF;                     break;
488   case CPUINFO_INT_REGISTER + TX0_TBR:         info->i = tx0.tbr;                  break;
489   case CPUINFO_INT_REGISTER + TX0_TAC:         info->i = tx0.tac;                  break;
468   case CPUINFO_INT_REGISTER + TX0_PC:            info->i = PC;                           break;
469   case CPUINFO_INT_REGISTER + TX0_IR:            info->i = IR;                           break;
470   case CPUINFO_INT_REGISTER + TX0_MBR:         info->i = MBR;                           break;
471   case CPUINFO_INT_REGISTER + TX0_MAR:         info->i = MAR;                           break;
472   case CPUINFO_INT_REGISTER + TX0_AC:            info->i = AC;                           break;
473   case CPUINFO_INT_REGISTER + TX0_LR:            info->i = LR;                           break;
474   case CPUINFO_INT_REGISTER + TX0_XR:            info->i = XR;                           break;
475   case CPUINFO_INT_REGISTER + TX0_PF:            info->i = PF;                           break;
476   case CPUINFO_INT_REGISTER + TX0_TBR:         info->i = cpustate->tbr;                  break;
477   case CPUINFO_INT_REGISTER + TX0_TAC:         info->i = cpustate->tac;                  break;
490478   case CPUINFO_INT_REGISTER + TX0_TSS00:
491479   case CPUINFO_INT_REGISTER + TX0_TSS01:
492480   case CPUINFO_INT_REGISTER + TX0_TSS02:
r3794r3795
502490   case CPUINFO_INT_REGISTER + TX0_TSS14:
503491   case CPUINFO_INT_REGISTER + TX0_TSS15:
504492   case CPUINFO_INT_REGISTER + TX0_TSS16:
505   case CPUINFO_INT_REGISTER + TX0_TSS17:         info->i = tx0.tss[state-(CPUINFO_INT_REGISTER + TX0_TSS00)]; break;
506   case CPUINFO_INT_REGISTER + TX0_CM_SEL:         info->i = tx0.cm_sel;               break;
507   case CPUINFO_INT_REGISTER + TX0_LR_SEL:         info->i = tx0.lr_sel;               break;
508   case CPUINFO_INT_REGISTER + TX0_GBL_CM_SEL:      info->i = tx0.gbl_cm_sel;            break;
509   case CPUINFO_INT_REGISTER + TX0_STOP_CYC0:      info->i = tx0.stop_cyc0;            break;
510   case CPUINFO_INT_REGISTER + TX0_STOP_CYC1:      info->i = tx0.stop_cyc1;            break;
511   case CPUINFO_INT_REGISTER + TX0_RUN:         info->i = tx0.run;                  break;
512   case CPUINFO_INT_REGISTER + TX0_RIM:         info->i = tx0.rim;                  break;
513   case CPUINFO_INT_REGISTER + TX0_CYCLE:         info->i = tx0.cycle;               break;
514   case CPUINFO_INT_REGISTER + TX0_IOH:         info->i = tx0.ioh;                  break;
515   case CPUINFO_INT_REGISTER + TX0_IOS:         info->i = tx0.ios;                  break;
493   case CPUINFO_INT_REGISTER + TX0_TSS17:         info->i = cpustate->tss[state-(CPUINFO_INT_REGISTER + TX0_TSS00)]; break;
494   case CPUINFO_INT_REGISTER + TX0_CM_SEL:         info->i = cpustate->cm_sel;                  break;
495   case CPUINFO_INT_REGISTER + TX0_LR_SEL:         info->i = cpustate->lr_sel;                  break;
496   case CPUINFO_INT_REGISTER + TX0_GBL_CM_SEL:      info->i = cpustate->gbl_cm_sel;               break;
497   case CPUINFO_INT_REGISTER + TX0_STOP_CYC0:      info->i = cpustate->stop_cyc0;               break;
498   case CPUINFO_INT_REGISTER + TX0_STOP_CYC1:      info->i = cpustate->stop_cyc1;               break;
499   case CPUINFO_INT_REGISTER + TX0_RUN:         info->i = cpustate->run;                  break;
500   case CPUINFO_INT_REGISTER + TX0_RIM:         info->i = cpustate->rim;                  break;
501   case CPUINFO_INT_REGISTER + TX0_CYCLE:         info->i = cpustate->cycle;                  break;
502   case CPUINFO_INT_REGISTER + TX0_IOH:         info->i = cpustate->ioh;                  break;
503   case CPUINFO_INT_REGISTER + TX0_IOS:         info->i = cpustate->ios;                  break;
516504
517505   /* --- the following bits of info are returned as pointers to data or functions --- */
518506   case CPUINFO_PTR_SET_INFO:                  info->setinfo = CPU_SET_INFO_NAME(tx0);         break;
519507   case CPUINFO_PTR_GET_CONTEXT:               info->getcontext = CPU_GET_CONTEXT_NAME(tx0);      break;
520508   case CPUINFO_PTR_SET_CONTEXT:               info->setcontext = CPU_SET_CONTEXT_NAME(tx0);      break;
521   case CPUINFO_PTR_INIT:                     info->init = CPU_INIT_NAME(tx0_64kw);   break;
522   case CPUINFO_PTR_RESET:                     info->reset = CPU_RESET_NAME(tx0);      break;
523   case CPUINFO_PTR_EXECUTE:                  info->execute = CPU_EXECUTE_NAME(tx0_64kw);   break;
524   case CPUINFO_PTR_BURN:                     info->burn = NULL;                  break;
509   case CPUINFO_PTR_INIT:                     info->init = CPU_INIT_NAME(tx0_64kw);         break;
510   case CPUINFO_PTR_RESET:                     info->reset = CPU_RESET_NAME(tx0);            break;
511   case CPUINFO_PTR_EXECUTE:                  info->execute = CPU_EXECUTE_NAME(tx0_64kw);      break;
512   case CPUINFO_PTR_BURN:                     info->burn = NULL;                        break;
525513   case CPUINFO_PTR_DISASSEMBLE:               info->disassemble = CPU_DISASSEMBLE_NAME(tx0_64kw);      break;
526   case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &tx0_ICount;            break;
514   case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &cpustate->icount;                  break;
527515
528516   /* --- the following bits of info are returned as NULL-terminated strings --- */
529   case CPUINFO_STR_NAME:                      strcpy(info->s, "TX-0");   break;
530   case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "TX-0");   break;
531   case CPUINFO_STR_CORE_VERSION:               strcpy(info->s, "1.0");   break;
532   case CPUINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__);   break;
533   case CPUINFO_STR_CORE_CREDITS:               strcpy(info->s, "Raphael Nabet");   break;
517   case CPUINFO_STR_NAME:                      strcpy(info->s, "TX-0");                  break;
518   case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "TX-0");                  break;
519   case CPUINFO_STR_CORE_VERSION:               strcpy(info->s, "1.0");                     break;
520   case CPUINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__);                  break;
521   case CPUINFO_STR_CORE_CREDITS:               strcpy(info->s, "Raphael Nabet");            break;
534522
535    case CPUINFO_STR_FLAGS:                     strcpy(info->s, "");   break;
523    case CPUINFO_STR_FLAGS:                     strcpy(info->s, "");                     break;
536524
537   case CPUINFO_STR_REGISTER + TX0_PC:            sprintf(info->s, "PC:0%06o", PC); break;
538   case CPUINFO_STR_REGISTER + TX0_IR:            sprintf(info->s, "IR:0%02o", IR); break;
539   case CPUINFO_STR_REGISTER + TX0_MBR:         sprintf(info->s, "MBR:0%06o", MBR); break;
540   case CPUINFO_STR_REGISTER + TX0_MAR:         sprintf(info->s, "MAR:0%06o", MAR); break;
541   case CPUINFO_STR_REGISTER + TX0_AC:            sprintf(info->s, "AC:0%06o", AC); break;
542   case CPUINFO_STR_REGISTER + TX0_LR:            sprintf(info->s, "LR:0%06o", LR); break;
543   case CPUINFO_STR_REGISTER + TX0_XR:            sprintf(info->s, "XR:0%05o", XR); break;
544   case CPUINFO_STR_REGISTER + TX0_PF:            sprintf(info->s, "PF:0%02o", PF); break;                     break;
545   case CPUINFO_STR_REGISTER + TX0_TBR:         sprintf(info->s, "TBR:0%06o", tx0.tbr); break;
546   case CPUINFO_STR_REGISTER + TX0_TAC:         sprintf(info->s, "TAC:0%06o", tx0.tac); break;
525   case CPUINFO_STR_REGISTER + TX0_PC:            sprintf(info->s, "PC:0%06o", PC);            break;
526   case CPUINFO_STR_REGISTER + TX0_IR:            sprintf(info->s, "IR:0%02o", IR);            break;
527   case CPUINFO_STR_REGISTER + TX0_MBR:         sprintf(info->s, "MBR:0%06o", MBR);            break;
528   case CPUINFO_STR_REGISTER + TX0_MAR:         sprintf(info->s, "MAR:0%06o", MAR);            break;
529   case CPUINFO_STR_REGISTER + TX0_AC:            sprintf(info->s, "AC:0%06o", AC);            break;
530   case CPUINFO_STR_REGISTER + TX0_LR:            sprintf(info->s, "LR:0%06o", LR);            break;
531   case CPUINFO_STR_REGISTER + TX0_XR:            sprintf(info->s, "XR:0%05o", XR);            break;
532   case CPUINFO_STR_REGISTER + TX0_PF:            sprintf(info->s, "PF:0%02o", PF);            break;
533   case CPUINFO_STR_REGISTER + TX0_TBR:         sprintf(info->s, "TBR:0%06o", cpustate->tbr);   break;
534   case CPUINFO_STR_REGISTER + TX0_TAC:         sprintf(info->s, "TAC:0%06o", cpustate->tac);   break;
547535   case CPUINFO_STR_REGISTER + TX0_TSS00:
548536   case CPUINFO_STR_REGISTER + TX0_TSS01:
549537   case CPUINFO_STR_REGISTER + TX0_TSS02:
r3794r3795
559547   case CPUINFO_STR_REGISTER + TX0_TSS14:
560548   case CPUINFO_STR_REGISTER + TX0_TSS15:
561549   case CPUINFO_STR_REGISTER + TX0_TSS16:
562   case CPUINFO_STR_REGISTER + TX0_TSS17:         sprintf(info->s, "TSS%02o:0%06o", state-(CPUINFO_STR_REGISTER + TX0_TSS00), tx0.tss[state-(CPUINFO_STR_REGISTER + TX0_TSS00)]); break;
563   case CPUINFO_STR_REGISTER + TX0_CM_SEL:         sprintf(info->s, "CMSEL:0%06o", tx0.cm_sel); break;
564   case CPUINFO_STR_REGISTER + TX0_LR_SEL:         sprintf(info->s, "LRSEL:0%06o", tx0.lr_sel); break;
565   case CPUINFO_STR_REGISTER + TX0_GBL_CM_SEL:      sprintf(info->s, "GBLCMSEL:%X", tx0.gbl_cm_sel); break;
566   case CPUINFO_STR_REGISTER + TX0_STOP_CYC0:      sprintf(info->s, "STOPCYC0:%X", tx0.stop_cyc0); break;
567   case CPUINFO_STR_REGISTER + TX0_STOP_CYC1:      sprintf(info->s, "STOPCYC1:%X", tx0.stop_cyc1); break;
568   case CPUINFO_STR_REGISTER + TX0_RUN:         sprintf(info->s, "RUN:%X", tx0.run); break;
569   case CPUINFO_STR_REGISTER + TX0_RIM:         sprintf(info->s, "RIM:%X", tx0.rim); break;
570   case CPUINFO_STR_REGISTER + TX0_CYCLE:         sprintf(info->s, "CYCLE:%X", tx0.cycle); break;
571   case CPUINFO_STR_REGISTER + TX0_IOH:         sprintf(info->s, "IOH:%X", tx0.ioh); break;
572   case CPUINFO_STR_REGISTER + TX0_IOS:         sprintf(info->s, "IOS:%X", tx0.ios); break;
550   case CPUINFO_STR_REGISTER + TX0_TSS17:         sprintf(info->s, "TSS%02o:0%06o", state-(CPUINFO_STR_REGISTER + TX0_TSS00), cpustate->tss[state-(CPUINFO_STR_REGISTER + TX0_TSS00)]); break;
551   case CPUINFO_STR_REGISTER + TX0_CM_SEL:         sprintf(info->s, "CMSEL:0%06o", cpustate->cm_sel); break;
552   case CPUINFO_STR_REGISTER + TX0_LR_SEL:         sprintf(info->s, "LRSEL:0%06o", cpustate->lr_sel); break;
553   case CPUINFO_STR_REGISTER + TX0_GBL_CM_SEL:      sprintf(info->s, "GBLCMSEL:%X", cpustate->gbl_cm_sel); break;
554   case CPUINFO_STR_REGISTER + TX0_STOP_CYC0:      sprintf(info->s, "STOPCYC0:%X", cpustate->stop_cyc0); break;
555   case CPUINFO_STR_REGISTER + TX0_STOP_CYC1:      sprintf(info->s, "STOPCYC1:%X", cpustate->stop_cyc1); break;
556   case CPUINFO_STR_REGISTER + TX0_RUN:         sprintf(info->s, "RUN:%X", cpustate->run); break;
557   case CPUINFO_STR_REGISTER + TX0_RIM:         sprintf(info->s, "RIM:%X", cpustate->rim); break;
558   case CPUINFO_STR_REGISTER + TX0_CYCLE:         sprintf(info->s, "CYCLE:%X", cpustate->cycle); break;
559   case CPUINFO_STR_REGISTER + TX0_IOH:         sprintf(info->s, "IOH:%X", cpustate->ioh); break;
560   case CPUINFO_STR_REGISTER + TX0_IOS:         sprintf(info->s, "IOS:%X", cpustate->ios); break;
573561   }
574562}
575563
576564CPU_GET_INFO( tx0_8kw )
577565{
566   tx0_state *cpustate = ( device != NULL ) ? device->token : NULL;
567
578568   switch (state)
579569   {
580570   /* --- the following bits of info are returned as 64-bit signed integers --- */
581   case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(tx0);               break;
571   case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(tx0_state);               break;
582572   case CPUINFO_INT_INPUT_LINES:               info->i = 0;                     break;
583573   case CPUINFO_INT_DEFAULT_IRQ_VECTOR:         info->i = 0;                     break;
584574   case CPUINFO_INT_ENDIANNESS:               info->i = ENDIANNESS_BIG;   /*don't care*/   break;
r3794r3795
611601   case CPUINFO_INT_REGISTER + TX0_LR:            info->i = LR;                     break;
612602   case CPUINFO_INT_REGISTER + TX0_XR:            info->i = XR;                     break;
613603   case CPUINFO_INT_REGISTER + TX0_PF:            info->i = PF;                     break;
614   case CPUINFO_INT_REGISTER + TX0_TBR:         info->i = tx0.tbr;                  break;
615   case CPUINFO_INT_REGISTER + TX0_TAC:         info->i = tx0.tac;                  break;
604   case CPUINFO_INT_REGISTER + TX0_TBR:         info->i = cpustate->tbr;                  break;
605   case CPUINFO_INT_REGISTER + TX0_TAC:         info->i = cpustate->tac;                  break;
616606   case CPUINFO_INT_REGISTER + TX0_TSS00:
617607   case CPUINFO_INT_REGISTER + TX0_TSS01:
618608   case CPUINFO_INT_REGISTER + TX0_TSS02:
r3794r3795
628618   case CPUINFO_INT_REGISTER + TX0_TSS14:
629619   case CPUINFO_INT_REGISTER + TX0_TSS15:
630620   case CPUINFO_INT_REGISTER + TX0_TSS16:
631   case CPUINFO_INT_REGISTER + TX0_TSS17:         info->i = tx0.tss[state-(CPUINFO_INT_REGISTER + TX0_TSS00)]; break;
632   case CPUINFO_INT_REGISTER + TX0_CM_SEL:         info->i = tx0.cm_sel;               break;
633   case CPUINFO_INT_REGISTER + TX0_LR_SEL:         info->i = tx0.lr_sel;               break;
634   case CPUINFO_INT_REGISTER + TX0_GBL_CM_SEL:      info->i = tx0.gbl_cm_sel;            break;
635   case CPUINFO_INT_REGISTER + TX0_STOP_CYC0:      info->i = tx0.stop_cyc0;            break;
636   case CPUINFO_INT_REGISTER + TX0_STOP_CYC1:      info->i = tx0.stop_cyc1;            break;
637   case CPUINFO_INT_REGISTER + TX0_RUN:         info->i = tx0.run;                  break;
638   case CPUINFO_INT_REGISTER + TX0_RIM:         info->i = tx0.rim;                  break;
639   case CPUINFO_INT_REGISTER + TX0_CYCLE:         info->i = tx0.cycle;               break;
640   case CPUINFO_INT_REGISTER + TX0_IOH:         info->i = tx0.ioh;                  break;
641   case CPUINFO_INT_REGISTER + TX0_IOS:         info->i = tx0.ios;                  break;
621   case CPUINFO_INT_REGISTER + TX0_TSS17:         info->i = cpustate->tss[state-(CPUINFO_INT_REGISTER + TX0_TSS00)]; break;
622   case CPUINFO_INT_REGISTER + TX0_CM_SEL:         info->i = cpustate->cm_sel;               break;
623   case CPUINFO_INT_REGISTER + TX0_LR_SEL:         info->i = cpustate->lr_sel;               break;
624   case CPUINFO_INT_REGISTER + TX0_GBL_CM_SEL:      info->i = cpustate->gbl_cm_sel;            break;
625   case CPUINFO_INT_REGISTER + TX0_STOP_CYC0:      info->i = cpustate->stop_cyc0;            break;
626   case CPUINFO_INT_REGISTER + TX0_STOP_CYC1:      info->i = cpustate->stop_cyc1;            break;
627   case CPUINFO_INT_REGISTER + TX0_RUN:         info->i = cpustate->run;                  break;
628   case CPUINFO_INT_REGISTER + TX0_RIM:         info->i = cpustate->rim;                  break;
629   case CPUINFO_INT_REGISTER + TX0_CYCLE:         info->i = cpustate->cycle;               break;
630   case CPUINFO_INT_REGISTER + TX0_IOH:         info->i = cpustate->ioh;                  break;
631   case CPUINFO_INT_REGISTER + TX0_IOS:         info->i = cpustate->ios;                  break;
642632
643633   /* --- the following bits of info are returned as pointers to data or functions --- */
644634   case CPUINFO_PTR_SET_INFO:                  info->setinfo = CPU_SET_INFO_NAME(tx0);         break;
r3794r3795
649639   case CPUINFO_PTR_EXECUTE:                  info->execute = CPU_EXECUTE_NAME(tx0_8kw);   break;
650640   case CPUINFO_PTR_BURN:                     info->burn = NULL;                  break;
651641   case CPUINFO_PTR_DISASSEMBLE:               info->disassemble = CPU_DISASSEMBLE_NAME(tx0_8kw);      break;
652   case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &tx0_ICount;            break;
642   case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &cpustate->icount;            break;
653643
654644   /* --- the following bits of info are returned as NULL-terminated strings --- */
655645   case CPUINFO_STR_NAME:                      strcpy(info->s, "TX-0");   break;
r3794r3795
668658   case CPUINFO_STR_REGISTER + TX0_LR:            sprintf(info->s, "LR:0%06o", LR); break;
669659   case CPUINFO_STR_REGISTER + TX0_XR:            sprintf(info->s, "XR:0%05o", XR); break;
670660   case CPUINFO_STR_REGISTER + TX0_PF:            sprintf(info->s, "PF:0%02o", PF); break;                     break;
671   case CPUINFO_STR_REGISTER + TX0_TBR:         sprintf(info->s, "TBR:0%06o", tx0.tbr); break;
672   case CPUINFO_STR_REGISTER + TX0_TAC:         sprintf(info->s, "TAC:0%06o", tx0.tac); break;
661   case CPUINFO_STR_REGISTER + TX0_TBR:         sprintf(info->s, "TBR:0%06o", cpustate->tbr); break;
662   case CPUINFO_STR_REGISTER + TX0_TAC:         sprintf(info->s, "TAC:0%06o", cpustate->tac); break;
673663   case CPUINFO_STR_REGISTER + TX0_TSS00:
674664   case CPUINFO_STR_REGISTER + TX0_TSS01:
675665   case CPUINFO_STR_REGISTER + TX0_TSS02:
r3794r3795
685675   case CPUINFO_STR_REGISTER + TX0_TSS14:
686676   case CPUINFO_STR_REGISTER + TX0_TSS15:
687677   case CPUINFO_STR_REGISTER + TX0_TSS16:
688   case CPUINFO_STR_REGISTER + TX0_TSS17:         sprintf(info->s, "TSS%02o:0%06o", state-(CPUINFO_STR_REGISTER + TX0_TSS00), tx0.tss[state-(CPUINFO_STR_REGISTER + TX0_TSS00)]); break;
689   case CPUINFO_STR_REGISTER + TX0_CM_SEL:         sprintf(info->s, "CMSEL:0%06o", tx0.cm_sel); break;
690   case CPUINFO_STR_REGISTER + TX0_LR_SEL:         sprintf(info->s, "LRSEL:0%06o", tx0.lr_sel); break;
691   case CPUINFO_STR_REGISTER + TX0_GBL_CM_SEL:      sprintf(info->s, "GBLCMSEL:%X", tx0.gbl_cm_sel); break;
692   case CPUINFO_STR_REGISTER + TX0_STOP_CYC0:      sprintf(info->s, "STOPCYC0:%X", tx0.stop_cyc0); break;
693   case CPUINFO_STR_REGISTER + TX0_STOP_CYC1:      sprintf(info->s, "STOPCYC1:%X", tx0.stop_cyc1); break;
694   case CPUINFO_STR_REGISTER + TX0_RUN:         sprintf(info->s, "RUN:%X", tx0.run); break;
695   case CPUINFO_STR_REGISTER + TX0_RIM:         sprintf(info->s, "RIM:%X", tx0.rim); break;
696   case CPUINFO_STR_REGISTER + TX0_CYCLE:         sprintf(info->s, "CYCLE:%X", tx0.cycle); break;
697   case CPUINFO_STR_REGISTER + TX0_IOH:         sprintf(info->s, "IOH:%X", tx0.ioh); break;
698   case CPUINFO_STR_REGISTER + TX0_IOS:         sprintf(info->s, "IOS:%X", tx0.ios); break;
678   case CPUINFO_STR_REGISTER + TX0_TSS17:         sprintf(info->s, "TSS%02o:0%06o", state-(CPUINFO_STR_REGISTER + TX0_TSS00), cpustate->tss[state-(CPUINFO_STR_REGISTER + TX0_TSS00)]); break;
679   case CPUINFO_STR_REGISTER + TX0_CM_SEL:         sprintf(info->s, "CMSEL:0%06o", cpustate->cm_sel); break;
680   case CPUINFO_STR_REGISTER + TX0_LR_SEL:         sprintf(info->s, "LRSEL:0%06o", cpustate->lr_sel); break;
681   case CPUINFO_STR_REGISTER + TX0_GBL_CM_SEL:      sprintf(info->s, "GBLCMSEL:%X", cpustate->gbl_cm_sel); break;
682   case CPUINFO_STR_REGISTER + TX0_STOP_CYC0:      sprintf(info->s, "STOPCYC0:%X", cpustate->stop_cyc0); break;
683   case CPUINFO_STR_REGISTER + TX0_STOP_CYC1:      sprintf(info->s, "STOPCYC1:%X", cpustate->stop_cyc1); break;
684   case CPUINFO_STR_REGISTER + TX0_RUN:         sprintf(info->s, "RUN:%X", cpustate->run); break;
685   case CPUINFO_STR_REGISTER + TX0_RIM:         sprintf(info->s, "RIM:%X", cpustate->rim); break;
686   case CPUINFO_STR_REGISTER + TX0_CYCLE:         sprintf(info->s, "CYCLE:%X", cpustate->cycle); break;
687   case CPUINFO_STR_REGISTER + TX0_IOH:         sprintf(info->s, "IOH:%X", cpustate->ioh); break;
688   case CPUINFO_STR_REGISTER + TX0_IOS:         sprintf(info->s, "IOS:%X", cpustate->ios); break;
699689   }
700690}
701691
702692
703693/* execute one instruction */
704static void execute_instruction_64kw(void)
694static void execute_instruction_64kw(const device_config *device)
705695{
706   if (! tx0.cycle)
696   tx0_state *cpustate = device->token;
697
698   if (! cpustate->cycle)
707699   {
708      tx0.cycle = 1;   /* most frequent case */
700      cpustate->cycle = 1;   /* most frequent case */
709701      switch (IR)
710702      {
711703      case 0:         /* STOre */
r3794r3795
716708         if (AC & 0400000)
717709         {
718710            PC = MAR & ADDRESS_MASK_64KW;
719            tx0.cycle = 0;   /* instruction only takes one cycle if branch
711            cpustate->cycle = 0;   /* instruction only takes one cycle if branch
720712                                    is taken */
721713         }
722714         break;
r3794r3795
733725         if (((MAR & 0030000) >> 12) == 1)
734726            /* (0.8) IOS In-Out Stop = Stop machine so that an In-Out command
735727                    (specified by digits 6 7 8 of MAR) may be executed */
736            tx0.ioh = 1;
728            cpustate->ioh = 1;
737729
738730         if (((MAR & 0007000) >> 9) != 0)
739731         {
r3794r3795
767759            /* (5 is undefined) */
768760            int index = (MAR & 0007000) >> 9;
769761
770            if (tx0.io_handlers[index])
771               (*tx0.io_handlers[index])();
772            tx0.ioh = 1;
762            if (cpustate->iface->io_handlers[index])
763               (*cpustate->iface->io_handlers[index])(device);
764            cpustate->ioh = 1;
773765         }
774766         break;
775767      }
776768   }
777769   else
778770   {
779      tx0.cycle = 0;   /* always true */
771      cpustate->cycle = 0;   /* always true */
780772      switch (IR)
781773      {
782774      case 0:         /* STOre */
783         tx0_write(MAR, (MBR = AC));
775         tx0_write(cpustate, MAR, (MBR = AC));
784776         break;
785777
786778      case 1:         /* ADD */
787         MBR = tx0_read(MAR);
779         MBR = tx0_read(cpustate, MAR);
788780
789781         AC = AC + MBR;
790782         AC = (AC + (AC >> 18)) & 0777777;   /* propagate carry around */
r3794r3795
872864
873865         if (((MAR & 0030000) >> 12) == 3)
874866            /* (1.8) Hlt = Halt the computer */
875            tx0.run = 0;
867            cpustate->run = 0;
876868
877869         break;
878870      }
879871   }
880872}
881873
882static void indexed_address_eval(void)
874static void indexed_address_eval(tx0_state *cpustate)
883875{
884876   MAR = MAR + XR;
885877   MAR = (MAR + (MAR >> 14)) & 0037777;   /* propagate carry around */
r3794r3795
890882}
891883
892884/* execute one instruction */
893static void execute_instruction_8kw(void)
885static void execute_instruction_8kw(const device_config *device)
894886{
895   if (! tx0.cycle)
887   tx0_state *cpustate = device->token;
888
889   if (! cpustate->cycle)
896890   {
897      tx0.cycle = 1;   /* most frequent case */
891      cpustate->cycle = 1;   /* most frequent case */
898892      switch (IR)
899893      {
900894      case 0:      /* STOre */
r3794r3795
918912         if (AC & 0400000)
919913         {
920914            PC = MAR & 0017777;
921            tx0.cycle = 0;   /* instruction only takes one cycle if branch
915            cpustate->cycle = 0;   /* instruction only takes one cycle if branch
922916                                    is taken */
923917         }
924918         break;
r3794r3795
927921         if ((AC == 0000000) || (AC == 0777777))
928922         {
929923            PC = MAR & 0017777;
930            tx0.cycle = 0;   /* instruction only takes one cycle if branch
924            cpustate->cycle = 0;   /* instruction only takes one cycle if branch
931925                                    is taken */
932926         }
933927         break;
r3794r3795
935929      case 18:   /* Transfer and Set indeX */
936930         XR = PC;
937931         PC = MAR & 0017777;
938         tx0.cycle = 0;   /* instruction only takes one cycle if branch
932         cpustate->cycle = 0;   /* instruction only takes one cycle if branch
939933                                is taken */
940934         break;
941935
r3794r3795
947941            else
948942               XR--;
949943            PC = MAR & 0017777;
950            tx0.cycle = 0;   /* instruction only takes one cycle if branch
944            cpustate->cycle = 0;   /* instruction only takes one cycle if branch
951945                                    is taken */
952946         }
953947         break;
954948
955949      case 21:   /* TRansfer indeXed */
956         indexed_address_eval();
950         indexed_address_eval(cpustate);
957951      case 20:   /* TRAnsfer */
958952         PC = MAR & 0017777;
959         tx0.cycle = 0;   /* instruction only takes one cycle if branch
953         cpustate->cycle = 0;   /* instruction only takes one cycle if branch
960954                                is taken */
961955         break;
962956
r3794r3795
964958         /*if (...)
965959            {
966960                PC = MAR & 0017777;
967                tx0.cycle = 0;*/   /* instruction only takes one cycle if branch
961                cpustate->cycle = 0;*/   /* instruction only takes one cycle if branch
968962                                    is taken */
969963         /*}*/
970964         break;
r3794r3795
984978               AC = 0;
985979
986980            /* (IOS???) SEL = SELect */
987            if (tx0.sel_handler)
988               (*tx0.sel_handler)();
981            if (cpustate->iface->sel_handler)
982               (*cpustate->iface->sel_handler)(device);
989983         }
990984         else
991985         {   /* Normal operate class instruction */
r3794r3795
10351029               /* (5 is undefined) */
10361030               int index = (MAR & 0007000) >> 9;
10371031
1038               if (tx0.io_handlers[index])
1039                  (*tx0.io_handlers[index])();
1040               tx0.ioh = 1;
1032               if (cpustate->iface->io_handlers[index])
1033                  (*cpustate->iface->io_handlers[index])(device);
1034               cpustate->ioh = 1;
10411035            }
10421036
10431037            if (((IR & 001) == 00) && ((MAR & 010000) == 010000))
r3794r3795
10531047   }
10541048   else
10551049   {
1056      if (((IR != 2) && (IR != 3)) || (tx0.cycle == 2))
1057         tx0.cycle = 0;
1050      if (((IR != 2) && (IR != 3)) || (cpustate->cycle == 2))
1051         cpustate->cycle = 0;
10581052      else
1059         tx0.cycle = 2;   /* SXA and ADO have an extra cycle 2 */
1053         cpustate->cycle = 2;   /* SXA and ADO have an extra cycle 2 */
10601054      switch (IR)
10611055      {
10621056      case 1:      /* STore indeXed */
1063         indexed_address_eval();
1057         indexed_address_eval(cpustate);
10641058      case 0:      /* STOre */
1065         tx0_write(MAR, (MBR = AC));
1059         tx0_write(cpustate, MAR, (MBR = AC));
10661060         break;
10671061
10681062      case 2:      /* Store indeX in Address */
1069         if (tx0.cycle)
1063         if (cpustate->cycle)
10701064         {   /* cycle 1 */
1071            MBR = tx0_read(MAR);
1065            MBR = tx0_read(cpustate, MAR);
10721066            MBR = (MBR & 0760000) | (XR & 0017777);
10731067         }
10741068         else
10751069         {   /* cycle 2 */
1076            tx0_write(MAR, MBR);
1070            tx0_write(cpustate, MAR, MBR);
10771071         }
10781072         break;
10791073
10801074      case 3:      /* ADd One */
1081         if (tx0.cycle)
1075         if (cpustate->cycle)
10821076         {   /* cycle 1 */
1083            AC = tx0_read(MAR) + 1;
1077            AC = tx0_read(cpustate, MAR) + 1;
10841078
10851079            #if 0
10861080               AC = (AC + (AC >> 18)) & 0777777;   /* propagate carry around */
r3794r3795
10931087         }
10941088         else
10951089         {   /* cycle 2 */
1096            tx0_write(MAR, (MBR = AC));
1090            tx0_write(cpustate, MAR, (MBR = AC));
10971091         }
10981092         break;
10991093
11001094      case 5:      /* Store Lr indeXed */
1101         indexed_address_eval();
1095         indexed_address_eval(cpustate);
11021096      case 4:      /* Store LR */
1103         tx0_write(MAR, (MBR = LR));
1097         tx0_write(cpustate, MAR, (MBR = LR));
11041098         break;
11051099
11061100      case 6:      /* STore Zero */
1107         tx0_write(MAR, (MBR = 0));
1101         tx0_write(cpustate, MAR, (MBR = 0));
11081102         break;
11091103
11101104      case 9:      /* ADd indeXed */
1111         indexed_address_eval();
1105         indexed_address_eval(cpustate);
11121106      case 8:      /* ADD */
1113         MBR = tx0_read(MAR);
1107         MBR = tx0_read(cpustate, MAR);
11141108
11151109         AC = AC + MBR;
11161110         AC = (AC + (AC >> 18)) & 0777777;   /* propagate carry around */
r3794r3795
11201114         break;
11211115
11221116      case 10:   /* LoaD indeX */
1123         MBR = tx0_read(MAR);
1117         MBR = tx0_read(cpustate, MAR);
11241118         XR = (MBR & 0017777) | ((MBR >> 4) & 0020000);
11251119         break;
11261120
11271121      case 11:   /* AUgment indeX */
1128         MBR = tx0_read(MAR);
1122         MBR = tx0_read(cpustate, MAR);
11291123
11301124         XR = XR + ((MBR & 0017777) | ((MBR >> 4) & 0020000));
11311125         XR = (XR + (XR >> 14)) & 0037777;   /* propagate carry around */
r3794r3795
11351129         break;
11361130
11371131      case 13:   /* Load Lr indeXed */
1138         indexed_address_eval();
1132         indexed_address_eval(cpustate);
11391133      case 12:   /* Load LR */
1140         LR = MBR = tx0_read(MAR);
1134         LR = MBR = tx0_read(cpustate, MAR);
11411135         break;
11421136
11431137      case 15:   /* Load Ac indeXed */
1144         indexed_address_eval();
1138         indexed_address_eval(cpustate);
11451139      case 14:   /* LoaD Ac */
1146         AC = MBR = tx0_read(MAR);
1140         AC = MBR = tx0_read(cpustate, MAR);
11471141         break;
11481142
11491143      case 16:   /* TRansfer on Negative */
r3794r3795
11781172
11791173            if (((IR & 001) == 00) && ((MAR & 017000) == 001000))
11801174               /* (1.1) TAC = transfer TAC into ac (inclusive or) */
1181               AC |= tx0.tac;
1175               AC |= cpustate->tac;
11821176
11831177            if (((IR & 001) == 00) && ((MAR & 017000) == 002000))
11841178               /* (1.2) TBR = transfer TBR into mbr (inclusive or) */
1185               MBR |= tx0.tbr;
1179               MBR |= cpustate->tbr;
11861180
11871181            if (((IR & 001) == 00) && ((MAR & 017000) == 006000))
11881182               /* (1.2) RPF = Read Program Flag register into mbr (inclusive or) */
r3794r3795
12781272
12791273            if (((IR & 001) == 01) && ((MAR & 017000) == 010000))
12801274               /* (1.8) HLT = HaLT the computer and sound chime */
1281               tx0.run = 0;
1275               cpustate->run = 0;
12821276         }
12831277         break;
12841278
r3794r3795
12941288    reset most registers and flip-flops, and initialize a few emulator state
12951289    variables.
12961290*/
1297static void pulse_reset(void)
1291static void pulse_reset(const device_config *device)
12981292{
1293   tx0_state *cpustate = device->token;
1294
12991295   /* processor registers */
13001296   PC = 0;         /* ??? */
13011297   IR = 0;         /* ??? */
r3794r3795
13051301   /*LR = 0;*/      /* ??? */
13061302
13071303   /* processor state flip-flops */
1308   tx0.run = 0;      /* ??? */
1309   tx0.rim = 0;      /* ??? */
1310   tx0.ioh = 0;      /* ??? */
1311   tx0.ios = 0;      /* ??? */
1304   cpustate->run = 0;      /* ??? */
1305   cpustate->rim = 0;      /* ??? */
1306   cpustate->ioh = 0;      /* ??? */
1307   cpustate->ios = 0;      /* ??? */
13121308
1313   tx0.rim_step = 0;
1309   cpustate->rim_step = 0;
13141310
13151311   /* now, we kindly ask IO devices to reset, too */
1316   if (tx0.io_reset_callback)
1317      (*tx0.io_reset_callback)();
1312   if (cpustate->iface->io_reset_callback)
1313      (*cpustate->iface->io_reset_callback)(device);
13181314}
src/mess/includes/tx0.h
r3794r3795
2121DEVICE_START( tx0_tape );
2222DEVICE_IMAGE_LOAD( tx0_tape );
2323DEVICE_IMAGE_UNLOAD( tx0_tape );
24void tx0_io_r1l(void);
25void tx0_io_r3l(void);
26void tx0_io_p6h(void);
27void tx0_io_p7h(void);
24void tx0_io_r1l(const device_config *device);
25void tx0_io_r3l(const device_config *device);
26void tx0_io_p6h(const device_config *device);
27void tx0_io_p7h(const device_config *device);
2828DEVICE_IMAGE_LOAD(tx0_typewriter);
2929DEVICE_IMAGE_UNLOAD(tx0_typewriter);
30void tx0_io_prt(void);
31void tx0_io_dis(void);
30void tx0_io_prt(const device_config *device);
31void tx0_io_dis(const device_config *device);
3232DEVICE_START( tx0_magtape );
3333DEVICE_IMAGE_LOAD( tx0_magtape );
3434DEVICE_IMAGE_UNLOAD( tx0_magtape );
35void tx0_sel(void);
36void tx0_io_cpy(void);
37void tx0_io_reset_callback(void);
35void tx0_sel(const device_config *device);
36void tx0_io_cpy(const device_config *device);
37void tx0_io_reset_callback(const device_config *device);
3838INTERRUPT_GEN( tx0_interrupt );
3939
4040
src/mess/machine/tx0.c
r3794r3795
55*/
66
77#include "driver.h"
8
98#include "cpu/pdp1/tx0.h"
109#include "includes/tx0.h"
1110#include "video/crt.h"
12#include "deprecat.h"
1311
1412
1513static TIMER_CALLBACK(reader_callback);
r3794r3795
141139};
142140
143141
144static DIRECT_UPDATE_HANDLER(setOPbasefunc)
145{
146   /* just to get rid of the warnings */
147   return -1;
148}
149
150
151142MACHINE_RESET( tx0 )
152143{
153144   /* reset device state */
r3794r3795
165156
166157MACHINE_START( tx0 )
167158{
168   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
169   memory_set_direct_update_handler(space, setOPbasefunc);;
170
171159   tape_reader.timer = timer_alloc(machine, reader_callback, NULL);
172160   tape_puncher.timer = timer_alloc(machine, puncher_callback, NULL);
173161   typewriter.prt_timer = timer_alloc(machine, prt_callback, NULL);
r3794r3795
373361/*
374362   Initiate read of a 6-bit word from tape
375363*/
376void tx0_io_r1l(void)
364void tx0_io_r1l(const device_config *device)
377365{
378366   begin_tape_read(0);
379367}
r3794r3795
381369/*
382370   Initiate read of a 18-bit word from tape (used in read-in mode)
383371*/
384void tx0_io_r3l(void)
372void tx0_io_r3l(const device_config *device)
385373{
386374   begin_tape_read(1);
387375}
r3794r3795
389377/*
390378   Write a 7-bit word to tape (7th bit clear)
391379*/
392void tx0_io_p6h(void)
380void tx0_io_p6h(const device_config *device)
393381{
394382   int ac;
395383
396384   /* read current AC */
397   ac = cpu_get_reg(Machine->cpu[0], TX0_AC);
385   ac = cpu_get_reg(device, TX0_AC);
398386   /* shuffle and punch 6-bit word */
399387   tape_write(((ac & 0100000) >> 15) | ((ac & 0010000) >> 11) | ((ac & 0001000) >> 7) | ((ac & 0000100) >> 3) | ((ac & 0000010) << 1) | ((ac & 0000001) << 5));
400388
r3794r3795
404392/*
405393   Write a 7-bit word to tape (7th bit set)
406394*/
407void tx0_io_p7h(void)
395void tx0_io_p7h(const device_config *device)
408396{
409397   int ac;
410398
411399   /* read current AC */
412   ac = cpu_get_reg(Machine->cpu[0], TX0_AC);
400   ac = cpu_get_reg(device, TX0_AC);
413401   /* shuffle and punch 6-bit word */
414402   tape_write(((ac & 0100000) >> 15) | ((ac & 0010000) >> 11) | ((ac & 0001000) >> 7) | ((ac & 0000100) >> 3) | ((ac & 0000010) << 1) | ((ac & 0000001) << 5) | 0100);
415403
r3794r3795
461449/*
462450   prt io callback
463451*/
464void tx0_io_prt(void)
452void tx0_io_prt(const device_config *device)
465453{
466454   int ac;
467455   int ch;
468456
469457   /* read current AC */
470   ac = cpu_get_reg(Machine->cpu[0], TX0_AC);
458   ac = cpu_get_reg(device, TX0_AC);
471459   /* shuffle and print 6-bit word */
472460   ch = ((ac & 0100000) >> 15) | ((ac & 0010000) >> 11) | ((ac & 0001000) >> 7) | ((ac & 0000100) >> 3) | ((ac & 0000010) << 1) | ((ac & 0000001) << 5);
473   typewriter_out(Machine, ch);
461   typewriter_out(device->machine, ch);
474462
475463   timer_adjust_oneshot(typewriter.prt_timer, ATTOTIME_IN_MSEC(100), 0);
476464}
r3794r3795
487475/*
488476   Plot one point on crt
489477*/
490void tx0_io_dis(void)
478void tx0_io_dis(const device_config *device)
491479{
492480   int ac;
493481   int x;
494482   int y;
495483
496   ac = cpu_get_reg(Machine->cpu[0], TX0_AC);
484   ac = cpu_get_reg(device, TX0_AC);
497485   x = ac >> 9;
498486   y = ac & 0777;
499487   tx0_plot(x, y);
r3794r3795
602590   }
603591}
604592
605static void magtape_callback(int dummy)
593static void magtape_callback(const device_config *device)
606594{
607595   UINT8 buf = 0;
608596   int lr;
609597
610   (void) dummy;
611
612598   switch (magtape.state)
613599   {
614600   case MTS_UNSELECTING:
r3794r3795
619605      {
620606         int mar;
621607
622         mar = cpu_get_reg(Machine->cpu[0], TX0_MAR);
608         mar = cpu_get_reg(device, TX0_MAR);
623609
624610         if ((mar & 03) != 1)
625611         {   /* unimplemented device: remain in unselected state and set rwc
626612            flag? */
627            cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_RWC);
613            cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_RWC);
628614         }
629615         else
630616         {
r3794r3795
639625         }
640626
641627         magtape.sel_pending = FALSE;
642         cpu_set_reg(Machine->cpu[0], TX0_IO_COMPLETE, 0);
628         cpu_set_reg(device, TX0_IO_COMPLETE, 0);
643629      }
644630      break;
645631
r3794r3795
682668         if (image_ftell(magtape.img) == 0)
683669         {   /* tape at ldp */
684670            magtape.state = MTS_UNSELECTING;
685            cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_RWC);
671            cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_RWC);
686672            schedule_unselect();
687673         }
688674         else if (image_fseek(magtape.img, -1, SEEK_CUR))
r3794r3795
751737                     logerror("invalid longitudinal parity\n");
752738                  /* set EOR and unselect... */
753739                  magtape.state = MTS_UNSELECTING;
754                  cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_EOR);
740                  cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_EOR);
755741                  schedule_unselect();
756742                  magtape.irg_pos = MTIRGP_ENDMINUS1;
757743               }
r3794r3795
807793               /*image_unload(magtape.img);*/
808794               /* Or do we stop at EOT mark??? */
809795               magtape.state = MTS_UNSELECTING;
810               cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_EOT);
796               cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_EOT);
811797               schedule_unselect();
812798            }
813799         }
r3794r3795
824810                  if (magtape.cpy_pending)
825811                  {   /* read command */
826812                     magtape.u.read.space_flag = FALSE;
827                     cpu_set_reg(Machine->cpu[0], TX0_IO_COMPLETE, 0);
828                     cpu_set_reg(Machine->cpu[0], TX0_LR, ((cpu_get_reg(Machine->cpu[0], TX0_LR) >> 1) & 0333333)
813                     cpu_set_reg(device, TX0_IO_COMPLETE, 0);
814                     cpu_set_reg(device, TX0_LR, ((cpu_get_reg(device, TX0_LR) >> 1) & 0333333)
829815                                          | ((buf & 040) << 12) | ((buf & 020) << 10) | ((buf & 010) << 8) | ((buf & 004) << 6) | ((buf & 002) << 4) | ((buf & 001) << 2));
830816                     /* check parity */
831817                     if (! (((buf ^ (buf >> 1) ^ (buf >> 2) ^ (buf >> 3) ^ (buf >> 4) ^ (buf >> 5) ^ (buf >> 6) ^ (buf >> 7)) & 1) ^ magtape.binary_flag))
832                        cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_PC);
818                        cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_PC);
833819                  }
834820                  else
835821                  {   /* space command */
r3794r3795
848834               }
849835               if (!magtape.u.read.space_flag)
850836               {
851                  cpu_set_reg(Machine->cpu[0], TX0_LR, ((cpu_get_reg(Machine->cpu[0], TX0_LR) >> 1) & 0333333)
837                  cpu_set_reg(device, TX0_LR, ((cpu_get_reg(device, TX0_LR) >> 1) & 0333333)
852838                                       | ((buf & 040) << 12) | ((buf & 020) << 10) | ((buf & 010) << 8) | ((buf & 004) << 6) | ((buf & 002) << 4) | ((buf & 001) << 2));
853839                  /* check parity */
854840                  if (! (((buf ^ (buf >> 1) ^ (buf >> 2) ^ (buf >> 3) ^ (buf >> 4) ^ (buf >> 5) ^ (buf >> 6) ^ (buf >> 7)) & 1) ^ magtape.binary_flag))
855                     cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_PC);
841                     cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_PC);
856842               }
857843               magtape.u.read.state = MTRDS_STATE2;
858844               break;
r3794r3795
866852               }
867853               if (!magtape.u.read.space_flag)
868854               {
869                  cpu_set_reg(Machine->cpu[0], TX0_LR, ((cpu_get_reg(Machine->cpu[0], TX0_LR) >> 1) & 0333333)
855                  cpu_set_reg(device, TX0_LR, ((cpu_get_reg(device, TX0_LR) >> 1) & 0333333)
870856                                       | ((buf & 040) << 12) | ((buf & 020) << 10) | ((buf & 010) << 8) | ((buf & 004) << 6) | ((buf & 002) << 4) | ((buf & 001) << 2));
871857                  /* check parity */
872858                  if (! (((buf ^ (buf >> 1) ^ (buf >> 2) ^ (buf >> 3) ^ (buf >> 4) ^ (buf >> 5) ^ (buf >> 6) ^ (buf >> 7)) & 1) ^ magtape.binary_flag))
873                     cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_PC);
859                     cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_PC);
874860                  /* synchronize with cpy instruction */
875861                  if (magtape.cpy_pending)
876                     cpu_set_reg(Machine->cpu[0], TX0_IO_COMPLETE, 0);
862                     cpu_set_reg(device, TX0_IO_COMPLETE, 0);
877863                  else
878                     cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_RWC);
864                     cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_RWC);
879865               }
880866               magtape.u.read.state = MTRDS_STATE3;
881867               break;
r3794r3795
887873                  magtape.u.read.state = MTRDS_STATE1;
888874                  if (!magtape.u.read.space_flag)
889875                  {
890                     cpu_set_reg(Machine->cpu[0], TX0_LR, ((cpu_get_reg(Machine->cpu[0], TX0_LR) >> 1) & 0333333)
876                     cpu_set_reg(device, TX0_LR, ((cpu_get_reg(device, TX0_LR) >> 1) & 0333333)
891877                                          | ((buf & 040) << 12) | ((buf & 020) << 10) | ((buf & 010) << 8) | ((buf & 004) << 6) | ((buf & 002) << 4) | ((buf & 001) << 2));
892878                     /* check parity */
893879                     if (! (((buf ^ (buf >> 1) ^ (buf >> 2) ^ (buf >> 3) ^ (buf >> 4) ^ (buf >> 5) ^ (buf >> 6) ^ (buf >> 7)) & 1) ^ magtape.binary_flag))
894                        cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_PC);
880                        cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_PC);
895881                  }
896882               }
897883               else
r3794r3795
931917                  logerror("invalid longitudinal parity\n");
932918                  /* no idea if the original tx-0 magtape controller
933919                  checks parity, but can't harm if we do */
934                  cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_PC);
920                  cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_PC);
935921               }
936922               /* set EOR and unselect... */
937923               magtape.state = MTS_UNSELECTING;
938               cpu_set_reg(Machine->cpu[0], TX0_PF, cpu_get_reg(Machine->cpu[0], TX0_PF) | PF_EOR);
924               cpu_set_reg(device, TX0_PF, cpu_get_reg(device, TX0_PF) | PF_EOR);
939925               schedule_unselect();
940926               magtape.irg_pos = MTIRGP_START;
941927               break;
r3794r3795
973959            if (magtape.u.write.counter)
974960            {
975961               magtape.u.write.counter--;
976               lr = cpu_get_reg(Machine->cpu[0], TX0_LR);
962               lr = cpu_get_reg(device, TX0_LR);
977963               buf = ((lr >> 10) & 040) | ((lr >> 8) & 020) | ((lr >> 6) & 010) | ((lr >> 4) & 004) | ((lr >> 2) & 002) | (lr & 001);
978964               buf |= ((buf << 1) ^ (buf << 2) ^ (buf << 3) ^ (buf << 4) ^ (buf << 5) ^ (buf << 6) ^ ((!magtape.binary_flag) << 6)) & 0100;
979               cpu_set_reg(Machine->cpu[0], TX0_LR, lr >> 1);
965               cpu_set_reg(device, TX0_LR, lr >> 1);
980966            }
981967            else
982968            {
983969               if (magtape.cpy_pending)
984970               {
985                  cpu_set_reg(Machine->cpu[0], TX0_IO_COMPLETE, 0);
986                  lr = cpu_get_reg(Machine->cpu[0], TX0_LR);
971                  cpu_set_reg(device, TX0_IO_COMPLETE, 0);
972                  lr = cpu_get_reg(device, TX0_LR);
987973                  buf = ((lr >> 10) & 040) | ((lr >> 8) & 020) | ((lr >> 6) & 010) | ((lr >> 4) & 004) | ((lr >> 2) & 002) | (lr & 001);
988974                  buf |= ((buf << 1) ^ (buf << 2) ^ (buf << 3) ^ (buf << 4) ^ (buf << 5) ^ (buf << 6) ^ ((!magtape.binary_flag) << 6)) & 0100;
989                  cpu_set_reg(Machine->cpu[0], TX0_LR, lr >> 1);
975                  cpu_set_reg(device, TX0_LR, lr >> 1);
990976                  magtape.u.write.counter = 2;
991977                  break;
992978               }
r3794r3795
10441030   }
10451031}
10461032
1047void tx0_sel(void)
1033void tx0_sel(const device_config *device)
10481034{
10491035   magtape.sel_pending = TRUE;
10501036
10511037   if (magtape.state == MTS_UNSELECTED)
10521038   {
10531039      if (0)
1054         magtape_callback(0);
1040         magtape_callback(device);
10551041      timer_adjust_oneshot(magtape.timer, attotime_zero, 0);
10561042   }
10571043}
10581044
1059void tx0_io_cpy(void)
1045void tx0_io_cpy(const device_config *device)
10601046{
10611047   switch (magtape.state)
10621048   {
10631049   case MTS_UNSELECTED:
10641050   case MTS_UNSELECTING:
10651051      /* ignore instruction and set rwc flag? */
1066      cpu_set_reg(Machine->cpu[0], TX0_IO_COMPLETE, 0);
1052      cpu_set_reg(device, TX0_IO_COMPLETE, 0);
10671053      break;
10681054
10691055   case MTS_SELECTING:
r3794r3795
10731059      case 0:   /* backspace */
10741060      case 2:   /* rewind */
10751061         /* ignore instruction and set rwc flag? */
1076         cpu_set_reg(Machine->cpu[0], TX0_IO_COMPLETE, 0);
1062         cpu_set_reg(device, TX0_IO_COMPLETE, 0);
10771063         break;
10781064      case 1:   /* read */
10791065      case 3:   /* write */
r3794r3795
10901076
10911077   IO devices should reset
10921078*/
1093void tx0_io_reset_callback(void)
1079void tx0_io_reset_callback(const device_config *device)
10941080{
10951081   tape_reader.rcl = tape_reader.rc = 0;
10961082   if (tape_reader.timer)
src/mess/drivers/tx0.c
r3794r3795
44    Raphael Nabet, 2004
55*/
66
7#include <math.h>
87#include "driver.h"
98#include "cpu/pdp1/tx0.h"
109#include "includes/tx0.h"
1110#include "video/crt.h"
1211
1312
14/* pointer to TX-0 RAM */
15static UINT32 *tx0_memory;
16
1713/*
1814    driver init function
19
20    Set up the tx0_memory pointer
2115*/
2216static DRIVER_INIT( tx0 )
2317{
r3794r3795
7569      0x00,0x68,0xb0,0x00,0x00,0x00,0x00,0x00,0x20,0x50,0x20,0x50,0xa8,0x50,0x00,0x00,
7670   };
7771
78   /* set up memory regions */
79   tx0_memory = (UINT32 *) memory_region(machine, "main");
80
8172   /* set up our font */
8273   dst = memory_region(machine, "gfx1");
8374
r3794r3795
8576}
8677
8778
88static READ18_HANDLER(tx0_read_mem)
89{
90   return tx0_memory ? tx0_memory[offset] : 0;
91}
92
93static WRITE18_HANDLER(tx0_write_mem)
94{
95   if (tx0_memory)
96      tx0_memory[offset] = data;
97}
98
99
10079static ADDRESS_MAP_START(tx0_64kw_map, ADDRESS_SPACE_PROGRAM, 32)
101   AM_RANGE(0x0000, 0xffff) AM_READWRITE(tx0_read_mem, tx0_write_mem)
80   AM_RANGE(0x0000, 0xffff) AM_RAM
10281ADDRESS_MAP_END
10382
83
10484static ADDRESS_MAP_START(tx0_8kw_map, ADDRESS_SPACE_PROGRAM, 32)
105   AM_RANGE(0x0000, 0x1fff) AM_READWRITE(tx0_read_mem, tx0_write_mem)
85   AM_RANGE(0x0000, 0x1fff) AM_RAM
10686ADDRESS_MAP_END
10787
10888

Previous 15994 Revisions Next


© 1998-2018 The MESS Team