@@ -27,7 +27,6 @@ SOFTWARE.
27
27
28
28
*/
29
29
30
- use :: c2rust_bitfields;
31
30
pub type int8_t = i8 ;
32
31
pub type int32_t = i32 ;
33
32
pub type uint8_t = u8 ;
@@ -45,8 +44,6 @@ pub trait z80Ctrl {
45
44
fn test_finished ( & self ) -> bool ;
46
45
}
47
46
48
- #[ derive( BitfieldStruct ) ]
49
- #[ repr( C ) ]
50
47
pub struct z80 {
51
48
pub ctrl : Box < dyn z80Ctrl > ,
52
49
pub pc : uint16_t ,
@@ -69,10 +66,9 @@ pub struct z80 {
69
66
pub irq_data : uint8_t ,
70
67
pub irq_pending : uint8_t ,
71
68
pub nmi_pending : uint8_t ,
72
- #[ bitfield( name = "iff1" , ty = "bool" , bits = "0..=0" ) ]
73
- #[ bitfield( name = "iff2" , ty = "bool" , bits = "1..=1" ) ]
74
- #[ bitfield( name = "halted" , ty = "bool" , bits = "2..=2" ) ]
75
- pub iff1_iff2_halted : [ u8 ; 1 ] ,
69
+ halted : bool ,
70
+ iff1 : bool ,
71
+ iff2 : bool ,
76
72
}
77
73
78
74
impl z80 {
@@ -115,7 +111,10 @@ impl z80 {
115
111
irq_data : 0 ,
116
112
irq_pending : 0 ,
117
113
nmi_pending : 0 ,
118
- iff1_iff2_halted : [ 0 ; 1 ] ,
114
+ // iff1_iff2_halted: [0; 1],
115
+ halted : false ,
116
+ iff1 : false ,
117
+ iff2 : false ,
119
118
}
120
119
}
121
120
pub fn init ( & mut self ) {
@@ -136,9 +135,9 @@ impl z80 {
136
135
self . r = 0 as i32 as uint8_t ;
137
136
self . iff_delay = 0 as i32 as uint8_t ;
138
137
self . interrupt_mode = 0 as i32 as uint8_t ;
139
- self . set_iff1 ( 0 as i32 != 0 ) ;
140
- self . set_iff2 ( 0 as i32 != 0 ) ;
141
- self . set_halted ( 0 as i32 != 0 ) ;
138
+ self . iff1 = 0 as i32 != 0 ;
139
+ self . iff2 = 0 as i32 != 0 ;
140
+ self . halted = 0 as i32 != 0 ;
142
141
self . irq_pending = 0 as i32 as uint8_t ;
143
142
self . nmi_pending = 0 as i32 as uint8_t ;
144
143
self . irq_data = 0 as i32 as uint8_t ;
@@ -175,98 +174,82 @@ impl z80 {
175
174
}
176
175
177
176
#[ derive( Copy , Clone ) ]
178
- #[ repr( C ) ]
179
- pub union C2RustUnnamed_0 {
177
+ union C2RustUnnamed_0 {
180
178
pub c2rust_unnamed : C2RustUnnamed_1 ,
181
179
pub h_l_ : uint16_t ,
182
180
}
183
181
#[ derive( Copy , Clone ) ]
184
- #[ repr( C ) ]
185
- pub struct C2RustUnnamed_1 {
182
+ struct C2RustUnnamed_1 {
186
183
pub l_ : uint8_t ,
187
184
pub h_ : uint8_t ,
188
185
}
189
186
#[ derive( Copy , Clone ) ]
190
- #[ repr( C ) ]
191
- pub union C2RustUnnamed_2 {
187
+ union C2RustUnnamed_2 {
192
188
pub c2rust_unnamed : C2RustUnnamed_3 ,
193
189
pub d_e_ : uint16_t ,
194
190
}
195
191
#[ derive( Copy , Clone ) ]
196
- #[ repr( C ) ]
197
- pub struct C2RustUnnamed_3 {
192
+ struct C2RustUnnamed_3 {
198
193
pub e_ : uint8_t ,
199
194
pub d_ : uint8_t ,
200
195
}
201
196
#[ derive( Copy , Clone ) ]
202
- #[ repr( C ) ]
203
- pub union C2RustUnnamed_4 {
197
+ union C2RustUnnamed_4 {
204
198
pub c2rust_unnamed : C2RustUnnamed_5 ,
205
199
pub b_c_ : uint16_t ,
206
200
}
207
201
#[ derive( Copy , Clone ) ]
208
- #[ repr( C ) ]
209
- pub struct C2RustUnnamed_5 {
202
+ struct C2RustUnnamed_5 {
210
203
pub c_ : uint8_t ,
211
204
pub b_ : uint8_t ,
212
205
}
213
206
#[ derive( Copy , Clone ) ]
214
- #[ repr( C ) ]
215
- pub union C2RustUnnamed_6 {
207
+ union C2RustUnnamed_6 {
216
208
pub c2rust_unnamed : C2RustUnnamed_7 ,
217
209
pub a_f_ : uint16_t ,
218
210
}
219
211
#[ derive( Copy , Clone ) ]
220
- #[ repr( C ) ]
221
- pub struct C2RustUnnamed_7 {
212
+ struct C2RustUnnamed_7 {
222
213
pub f_ : uint8_t ,
223
214
pub a_ : uint8_t ,
224
215
}
225
216
#[ derive( Copy , Clone ) ]
226
- #[ repr( C ) ]
227
- pub union C2RustUnnamed_8 {
217
+ union C2RustUnnamed_8 {
228
218
pub c2rust_unnamed : C2RustUnnamed_9 ,
229
219
pub hl : uint16_t ,
230
220
}
231
221
#[ derive( Copy , Clone ) ]
232
- #[ repr( C ) ]
233
- pub struct C2RustUnnamed_9 {
222
+ struct C2RustUnnamed_9 {
234
223
pub l : uint8_t ,
235
224
pub h : uint8_t ,
236
225
}
237
226
#[ derive( Copy , Clone ) ]
238
- #[ repr( C ) ]
239
- pub union C2RustUnnamed_10 {
227
+ union C2RustUnnamed_10 {
240
228
pub c2rust_unnamed : C2RustUnnamed_11 ,
241
229
pub de : uint16_t ,
242
230
}
243
231
#[ derive( Copy , Clone ) ]
244
- #[ repr( C ) ]
245
- pub struct C2RustUnnamed_11 {
232
+ struct C2RustUnnamed_11 {
246
233
pub e : uint8_t ,
247
234
pub d : uint8_t ,
248
235
}
249
236
#[ derive( Copy , Clone ) ]
250
- #[ repr( C ) ]
251
- pub union C2RustUnnamed_12 {
237
+ union C2RustUnnamed_12 {
252
238
pub c2rust_unnamed : C2RustUnnamed_13 ,
253
239
pub bc : uint16_t ,
254
240
}
255
241
#[ derive( Copy , Clone ) ]
256
- #[ repr( C ) ]
257
- pub struct C2RustUnnamed_13 {
242
+ struct C2RustUnnamed_13 {
258
243
pub c : uint8_t ,
259
244
pub b : uint8_t ,
260
245
}
261
246
#[ derive( Copy , Clone ) ]
262
- #[ repr( C ) ]
263
- pub union C2RustUnnamed_14 {
247
+ union C2RustUnnamed_14 {
264
248
pub c2rust_unnamed : C2RustUnnamed_15 ,
265
249
pub af : uint16_t ,
266
250
}
267
251
#[ derive( Copy , Clone ) ]
268
- #[ repr( C ) ]
269
- pub struct C2RustUnnamed_15 {
252
+ struct C2RustUnnamed_15 {
270
253
pub f : uint8_t ,
271
254
pub a : uint8_t ,
272
255
}
@@ -1040,29 +1023,29 @@ unsafe fn process_interrupts(z: *mut z80) -> u32 {
1040
1023
if ( * z) . iff_delay as i32 > 0 as i32 {
1041
1024
( * z) . iff_delay = ( ( * z) . iff_delay as i32 - 1 as i32 ) as uint8_t ;
1042
1025
if ( * z) . iff_delay as i32 == 0 as i32 {
1043
- ( * z) . set_iff1 ( 1 as i32 != 0 ) ;
1044
- ( * z) . set_iff2 ( 1 as i32 != 0 ) ;
1026
+ ( * z) . iff1 = 1 as i32 != 0 ;
1027
+ ( * z) . iff2 = 1 as i32 != 0 ;
1045
1028
}
1046
1029
return cyc;
1047
1030
}
1048
1031
if ( * z) . nmi_pending != 0 {
1049
1032
( * z)
1050
1033
. nmi_pending = ( ( * z) . nmi_pending as i32
1051
1034
& !( Z80_PULSE as i32 ) ) as uint8_t ;
1052
- ( * z) . set_halted ( 0 as i32 != 0 ) ;
1053
- ( * z) . set_iff1 ( 0 as i32 != 0 ) ;
1035
+ ( * z) . halted = 0 as i32 != 0 ;
1036
+ ( * z) . iff1 = 0 as i32 != 0 ;
1054
1037
inc_r ( z) ;
1055
1038
cyc = cyc. wrapping_add ( 11 as i32 as u32 ) ;
1056
1039
call ( z, 0x66 as i32 as uint16_t ) ;
1057
1040
return cyc;
1058
1041
}
1059
- if ( * z) . irq_pending as i32 != 0 && ( * z) . iff1 ( ) as i32 != 0 {
1042
+ if ( * z) . irq_pending as i32 != 0 && ( * z) . iff1 as i32 != 0 {
1060
1043
( * z)
1061
1044
. irq_pending = ( ( * z) . irq_pending as i32
1062
1045
& !( Z80_PULSE as i32 ) ) as uint8_t ;
1063
- ( * z) . set_halted ( 0 as i32 != 0 ) ;
1064
- ( * z) . set_iff1 ( 0 as i32 != 0 ) ;
1065
- ( * z) . set_iff2 ( 0 as i32 != 0 ) ;
1046
+ ( * z) . halted = 0 as i32 != 0 ;
1047
+ ( * z) . iff1 = 0 as i32 != 0 ;
1048
+ ( * z) . iff2 = 0 as i32 != 0 ;
1066
1049
inc_r ( z) ;
1067
1050
match ( * z) . interrupt_mode as i32 {
1068
1051
0 => {
@@ -1098,14 +1081,14 @@ pub unsafe fn z80_reset(z: *mut z80) {
1098
1081
( * z) . r = 0 as i32 as uint8_t ;
1099
1082
( * z) . interrupt_mode = 0 as i32 as uint8_t ;
1100
1083
( * z) . iff_delay = 0 as i32 as uint8_t ;
1101
- ( * z) . set_iff1 ( 0 as i32 != 0 ) ;
1102
- ( * z) . set_iff2 ( 0 as i32 != 0 ) ;
1103
- ( * z) . set_halted ( 0 as i32 != 0 ) ;
1084
+ ( * z) . iff1 = 0 as i32 != 0 ;
1085
+ ( * z) . iff2 = 0 as i32 != 0 ;
1086
+ ( * z) . halted = 0 as i32 != 0 ;
1104
1087
( * z) . nmi_pending = 0 as i32 as uint8_t ;
1105
1088
}
1106
1089
unsafe fn z80_step_s ( z : * mut z80 ) -> u32 {
1107
1090
let mut cyc: u32 = 0 as i32 as u32 ;
1108
- if ( * z) . halted ( ) {
1091
+ if ( * z) . halted {
1109
1092
cyc = cyc. wrapping_add ( exec_opcode ( z, 0 as i32 as uint8_t ) ) ;
1110
1093
} else {
1111
1094
let opcode: uint8_t = nextb ( z) ;
@@ -2142,8 +2125,8 @@ unsafe fn exec_opcode(z: *mut z80, mut opcode: uint8_t) -> u32 {
2142
2125
}
2143
2126
243 => {
2144
2127
cyc = cyc. wrapping_add ( 4 as i32 as u32 ) ;
2145
- ( * z) . set_iff2 ( 0 as i32 != 0 ) ;
2146
- ( * z) . set_iff1 ( ( * z) . iff2 ( ) ) ;
2128
+ ( * z) . iff2 = 0 as i32 != 0 ;
2129
+ ( * z) . iff1 = ( * z) . iff2 ;
2147
2130
}
2148
2131
251 => {
2149
2132
cyc = cyc. wrapping_add ( 4 as i32 as u32 ) ;
@@ -2154,7 +2137,7 @@ unsafe fn exec_opcode(z: *mut z80, mut opcode: uint8_t) -> u32 {
2154
2137
}
2155
2138
118 => {
2156
2139
cyc = cyc. wrapping_add ( 4 as i32 as u32 ) ;
2157
- ( * z) . set_halted ( 1 as i32 != 0 ) ;
2140
+ ( * z) . halted = 1 as i32 != 0 ;
2158
2141
}
2159
2142
60 => {
2160
2143
cyc = cyc. wrapping_add ( 4 as i32 as u32 ) ;
@@ -3768,7 +3751,7 @@ unsafe fn exec_opcode_ed(z: *mut z80, mut opcode: uint8_t) -> u32 {
3768
3751
) ;
3769
3752
flag_set ( z, hf, 0 as i32 != 0 ) ;
3770
3753
flag_set ( z, nf, 0 as i32 != 0 ) ;
3771
- flag_set ( z, pf, ( * z) . iff2 ( ) ) ;
3754
+ flag_set ( z, pf, ( * z) . iff2 ) ;
3772
3755
}
3773
3756
95 => {
3774
3757
cyc = cyc. wrapping_add ( 9 as i32 as u32 ) ;
@@ -3786,11 +3769,11 @@ unsafe fn exec_opcode_ed(z: *mut z80, mut opcode: uint8_t) -> u32 {
3786
3769
) ;
3787
3770
flag_set ( z, hf, 0 as i32 != 0 ) ;
3788
3771
flag_set ( z, nf, 0 as i32 != 0 ) ;
3789
- flag_set ( z, pf, ( * z) . iff2 ( ) ) ;
3772
+ flag_set ( z, pf, ( * z) . iff2 ) ;
3790
3773
}
3791
3774
69 | 85 | 93 | 101 | 109 | 117 | 125 => {
3792
3775
cyc = cyc. wrapping_add ( 14 as i32 as u32 ) ;
3793
- ( * z) . set_iff1 ( ( * z) . iff2 ( ) ) ;
3776
+ ( * z) . iff1 = ( * z) . iff2 ;
3794
3777
ret ( z) ;
3795
3778
}
3796
3779
77 => {
0 commit comments