1 /* PR tree-optimization/34046 */
2 /* Origin: dcb <dcb314@hotmail.com> */
4 typedef unsigned char bool8
;
5 typedef unsigned char uint8_t;
6 typedef unsigned short int uint16_t;
7 typedef unsigned int uint32_t;
9 typedef uint16_t uint16
;
10 typedef uint32_t uint32
;
28 uint16 TimerTarget
[3];
34 void S9xSetAPUControl (uint8 byte
);
35 void S9xSetAPUDSP (uint8 byte
);
36 uint8
S9xGetAPUDSP ();
38 uint8
S9xAPUGetByte (uint32 Address
)
42 if (Address
<= 0xff && Address
>= 0xf0)
44 if (Address
>= 0xf4 && Address
<= 0xf7)
46 IAPU
.WaitAddress2
= IAPU
.WaitAddress1
;
47 IAPU
.WaitAddress1
= IAPU
.PC
;
48 return (IAPU
.RAM
[Address
]);
50 else if (Address
== 0xf3)
51 return (S9xGetAPUDSP ());
55 IAPU
.WaitAddress2
= IAPU
.WaitAddress1
;
56 IAPU
.WaitAddress1
= IAPU
.PC
;
57 uint8 t
= IAPU
.RAM
[Address
];
58 IAPU
.RAM
[Address
] = 0;
62 return (IAPU
.RAM
[Address
]);
65 return (IAPU
.RAM
[Address
]);
68 void S9xAPUSetByte (uint8 byte
, uint32 Address
)
72 if (Address
<= 0xff && Address
>= 0xf0)
76 else if (Address
>= 0xf4 && Address
<= 0xf7)
77 APU
.OutPorts
[Address
- 0xf4] = byte
;
78 else if (Address
== 0xf1)
79 S9xSetAPUControl (byte
);
80 else if (Address
< 0xfd)
82 IAPU
.RAM
[Address
] = byte
;
86 APU
.TimerTarget
[Address
- 0xfa] = 0x100;
88 APU
.TimerTarget
[Address
- 0xfa] = byte
;
95 IAPU
.RAM
[Address
] = byte
;
98 APU
.ExtraRAM
[Address
- 0xffc0] = byte
;
100 IAPU
.RAM
[Address
] = byte
;
107 IAPU
.Address
= *(uint16
*) (IAPU
.PC
+ 1);
108 IAPU
.Bit
= (uint8
)(IAPU
.Address
>> 13);
110 S9xAPUSetByte (S9xAPUGetByte (IAPU
.Address
) | (1 << IAPU
.Bit
), IAPU
.Address
);
112 S9xAPUSetByte (S9xAPUGetByte (IAPU
.Address
) & ~(1 << IAPU
.Bit
), IAPU
.Address
);