6 #include "hw_spc2000.h"
14 int spc2000_data_init_(struct dcpu16_hw
*hw
, void *data
) {
17 hw
->data
= calloc(1, sizeof(struct spc2000_
));
18 if (hw
->data
== NULL
) {
19 hw
->vm
->warn_cb_("%s():%s", "calloc", strerror(errno
));
26 void spc2000_data_free_(struct dcpu16_hw
*hw
) {
36 void spc2000_reset_(struct dcpu16
*vm
, struct dcpu16_hw
*hw
) {
37 struct spc2000_
*spc2000
= (struct spc2000_
*)hw
->data
;
41 memset(spc2000
, 0, sizeof *spc2000
);
45 void spc2000_cycle_(struct dcpu16
*vm
, struct dcpu16_hw
*hw
) {
46 struct spc2000_
*spc2000
= (struct spc2000_
*)hw
->data
;
53 void spc2000_hwi_(struct dcpu16
*vm
, struct dcpu16_hw
*hw
) {
54 struct spc2000_
*spc2000
= (struct spc2000_
*)hw
->data
;
55 DCPU16_WORD reg_a
= vm
->reg
[DCPU16_REG_A
],
56 reg_b
= vm
->reg
[DCPU16_REG_B
];
60 case 0: /* GET_STATUS */
61 case 2: /* TRIGGER_DEVICE */
63 vm
->reg
[DCPU16_REG_C
] = 0;
64 vm
->reg
[DCPU16_REG_B
] = 0;
66 || vm
->reg
[DCPU16_REG_C
] != 0)
69 vm
->warn_cb_("spc2000 triggered\n");
72 case 1: /* SET_UNIT_TO_SKIP */
73 spc2000
->skip
= vm
->ram
[reg_b
];
74 x
= vm
->ram
[reg_b
+ 1];
75 spc2000
->skip
|= x
<< 16;
76 x
= vm
->ram
[reg_b
+ 2];
77 spc2000
->skip
|= x
<< 32;
78 x
= vm
->ram
[reg_b
+ 3];
79 spc2000
->skip
|= x
<< 48;
82 case 3: /* SET_SKIP_UNIT */
83 spc2000
->skip_unit
= reg_b
;
88 static struct dcpu16_hw hw_
= {
90 .name_
= "SPC2000 - Suspension Chamber 2000",
97 .cycle
= spc2000_cycle_
,
98 .reset
= spc2000_reset_
,
99 .data
= (struct spc2000_
*)NULL
102 struct dcpu16_hw_module dcpu16_hw_module_spc2000
= {
104 .data_init
= spc2000_data_init_
,
105 .data_free
= spc2000_data_free_
,