After the events in the escape tunnel, you are sent to Warlock Zone IX.
Warlock Zone IX: Final Story
There will be a cutscene. Afterward, leave the cell and go south. There are Gun Corps who will shoot bullets left or right. The bullets spread in a cone. Make sure not to stand to the left or right of the Gun Corps.
You can enter each cell in this hallway to talk to the prisoners if you wish. The first and third prisoners say the same thing as each other, for some reason.
Go south to the next area. There are two Jutsu schools to the left. Between them, you can buy all four Jutsu, but they are expensive. To the right, there is a prisoner in a cell, a door to the north, and another prisoner in a cell. Go north via the door between the two prisoners.
In this area, there is one cell on the right, and if you go in, you find the real ruler of the castle. He tells you that there is a hidden passage in the cell where you were locked up.
Before you go there, you can go left from the ruler's cell and hit the wall at the leftmost wooden beam. It will open a hidden area. If you don't have enough sandals to get all the treasure, go through the hidden area and use the exit, then go left and you will find a store, a restaurant, and another store. The first one sells sandals. Then you can go back north to go back into the hidden area to the left of the ruler's cell.
Back at the exit of the hidden area, you can visit the stores on the left if you wish, then go to the right. At the far end of the hall, there is a logbook shop where you can get a password to continue your game.
To the left of the logbook shop, hit the wall between the two wooden beams to find another hidden area. After you go through it and exit, you will be next to the north exit that leads back to the cell where you were locked up. Go in and walk north from the cell door, then go slightly to the right, and hit the north wall. If you hit the right spot, the door will open and you can exit this area.