Mario Style Camera

I’m currently trying to recreate a 2d Mario platformer (Super Mario Bros, to be exact) as a small project, to practice some skills, however I’m having a lot of trouble trying to make the camera work for me. Currently he moves in the center of the screen and the camera follows him, but obviously this isn’t how other mario games cameras work. I have found no helpful information on this subject so far other than one person who was told to use a grid system to lock the camera to each part of the grid. I unfortunately have no idea how to create such a grid if this is the only way, especially as a 2d platformer (if this is the only way any help would be appreciated since I haven’t found a good tutorial for the subject yet). I also want to make sure the camera stops at the edge of the map, so that it cannot be seen. Any help is greatly appreciated.

This is mine

63142-world_1-1_(super_mario_bros.)_start.png

How it should be

So the camera is originally programmed on a pixel by pixel basis. Mario starts 42 pixels from the left side of the platform, with the left side of the camera at 0. As he moves, his left side cannot go further than 112 pixels from the left side of the screen.