First of all make all the needed edits with the CFG for the Patcher.
Then here's the State-Info you'll need:
state: goes to stage: 5019 1-9 5029 2-9 5039 3-9 5049 4-9 5059 5-9These states have some special effects in stage mode, else they work like state 15. If you use it and you go to another stage the background will not change.
The easiest way to use it is to go use a criminal with state 50xx instead of 80xx - if you hurt it you go to the secret stage, but there're a few other things you have to care about.
First you need to code a Stage x-9, if you don't the stage simply ends.
<stage> id: 8 #stage 1-9 <phase> bound: 900 ... <phase_end> <stage_end>Next you need to know that you will enter the phase that is 1 + the phase number that you have come from. So if you played in Stage 1-1 / Phase 2 and use state 5019, you will go on in Stage 1-9 / Phase 3. So make sure you made enough empty phases...
<stage> id: 8 #stage 1-9 <phase> bound: 900 <phase_end> <phase> bound: 901 <phase_end> <phase> bound: 902 ... <phase_end> <stage_end>Last thing you should know is that you are not allowed to code Stage x-8, if you do so you'll be able to enter stage x-9 after you played x-8 and it's not a secret stage anymore.
Now you know everything, have fun coding :D