Pinhole imaging is an important test technique to obtain information on the spatial distribution of the radiation field in the target region and has been widely used in nuclear physics and inertial confinement fusion (ICF). Coded-aperture, able to maintain good resolution as well as enhancing signal strength, has become a more frequently used method than pinhole imaging in experimental studies. Thus, implementing Monte Carlo simulations of coded-aperture imaging will improve coded-aperture design, image reconstruction, and other related works. However, the current international mainstream Monte Carlo transport simulation programs do not possess the ability to directly simulate coded-aperture imaging. This paper develops a relatively complete coded-aperture imaging simulation function on the Neutron Photon Transport System code based on the next-event estimation method. With the application of Monte Carlo simulation techniques, such as variance reduction and rejection sampling, it is capable of simulating coded-aperture accurately, flexibly, and efficiently, including problems of multiple shapes and even irregular geometry. The results are consistent with combined pinhole imaging, and the computational efficiency has been improved significantly.