lsnes rr2-β24
[lsnes.git] / src / emulation / sky / state.cpp
blob8cc77fb7fc1be54fbac7598bf2f8d95465612298
1 #include "state.hpp"
2 #include "romimage.hpp"
4 namespace sky
6 const char* const statenames[] = {
7 "MENU_FADEIN", "MENU", "MENU_FADEOUT", "LOAD_LEVEL", "LEVEL_FADEIN", "LEVEL_PLAY", "LEVEL_COMPLETE",
8 "LEVEL_FADEOUT", "LOAD_MENU", "LEVEL_UNAVAIL", "DEMO_UNAVAIL", "LEVEL_FADEOUT_RETRY"
9 };
11 void gstate::level_init(uint8_t _stage)
13 stage = _stage;
14 p.level_init(curlevel);
15 paused = 0;
16 speedind = 0;
17 fuelind = 0;
18 o2ind = 0;
19 distind = 0;
20 lockind = 0;
21 beep_phase = 0;
23 uint8_t gstate::simulate_frame(noise_maker& sfx, int lr, int ad, bool jump)
25 uint8_t dstatus = p.simulate_frame(curlevel, sfx, lr, ad, jump);
26 uint16_t lt = p.lpos >> 16;
27 uint8_t ht = (p.hpos - 12160) / 5888;
28 if(secret == 1 && p.is_set(physics::flag_landed) && ht <= 2 && lt >= 131 && lt <= 170)
29 secret |= 0x80;
30 else if(secret == 2 && p.is_set(physics::flag_landed) && ht == 3 && lt >= 58 && lt <= 62)
31 secret |= 0x80;
32 return dstatus;
34 void gstate::change_state(uint8_t newstate)
36 state = newstate;
37 fadecount = 0;
40 std::pair<uint8_t*, size_t> gstate::as_ram()
42 return std::make_pair(reinterpret_cast<uint8_t*>(this), sizeof(*this));