sound system seems to work ok
[awish.git] / asm / game.awa
blob5e8f4f6faee8ca38fcc08393659fb70e2c05a0fe
1 /*
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
14  */
15 ; used in fanchecks
16 deftvar: game_fan_left_v   ; have left working fan?
17 deftvar: game_fan_right_v  ; have right working fan?
18 deftvar: game_fan_dx_v     ; !0: some fan in effect
20 ; used in 'monster death'
21 deftvar: monster_tid
24 const: PSPR_STANDING = 0
25 const: PSPR_WALKING_LAST = 9
26 const: PSPR_TURNING = 10
27 const: PSPR_FACING = 11
28 const: PSPR_JUMPING = 12
29 const: PSPR_TAKING0 = 13
30 const: PSPR_TAKING1 = 14
31 const: PSPR_USING = 15
32 const: PSPR_CLOSED_EYES = 16
33 const: PSPR_LYING_DEAD = 19
34 const: PSPR_DRILLING0 = 20
35 const: PSPR_DRILLING1 = 21
36 const: PSPR_HARRY_EATS_PROF_START = 33
37 const: PSPR_HARRY_EATS_PROF_END = 38
40 const: PDIR_LEFT   = -1
41 const: PDIR_RIGHT  =  1
42 const: PDIR_FACING =  0
45 game_load_level:
46   bsr kill_all_threads
47   ;
48   set [item_id], 0
49   set [spr_bank], BANK_PROF
50   set [spr_num], PSPR_FACING
51   set [spr_dir], DIR_LEFT
52   ;
53   jlt .bad_level, [cur_level], 0
54   jge .bad_level, [cur_level], [max_level]
55   jmp .do_load
56 .bad_level:
57   set [cur_level], 0
58 .do_load:
59   bsr entry_get_level_code, [cur_level]
60   ;
61   psh avish_level_loader
62   rst FRST_GET_LEVEL_LOADER
63   jlt .no_custom_loader, [rst_result], 0
64   drp
65   psh [rst_result]
66 .no_custom_loader:
67   psh [cur_level]
68   swp
69   bsr ; call level loader
70   ; call local initializer (if any)
71   rst FRST_GET_LEVEL_INITER
72   jlt .no_custom_init, [rst_result], 0
73   bsr [rst_result]
74 .no_custom_init:
75   ;
76   rst FRST_SET_LEVEL_CODE, [level_code_ofs], [level_code_len]
77   bsr prof_fix_position
78   ret
81 entry_game_initialize:
82   rst FRST_ML_GAME
83   set [cur_level], [start_level]
84   /*
85   set [cur_level], 11
86   set [cur_level], 16
87   set [cur_level], 13
88   set [cur_level], 12
89   */
90   rst FRST_STOP_CHANNEL, -1
91   ; load sounds
92   psh 0
93 @@:
94   dup
95   rst FRST_LOAD_SOUND
96   add 1
97   dup
98   jlt @@b, 23
99   drp
101 entry_game_restart_level:
102   rst FRST_ML_GAME
103   bsr clear_stack
104   bsr kill_all_threads
105   ; stop all sound
106   rst FRST_STOP_CHANNEL, -1
107   rst FRST_PLAY_SOUND, SND_HARRY_EATS_APPLE
108   ;
109   set [game_state], GAME_STATE_STARTED
110   brk
111   ;
112   set [key_quit], 0
113   set [key_start], 0
114   ;
115   set [key_left], 0
116   set [key_right], 0
117   set [key_up], 0
118   set [key_down], 0
119   set [key_take], 0
120   set [key_use], 0
121   set [key_minimap], 0
122   set [key_restart], 0
123   ;
124   set [key_fall_cheat], 0
125   set [key_walk_cheat], 0
126   set [key_plev_cheat], 0
127   set [key_nlev_cheat], 0
128   ;
129   ;set [prof_fall_count], 0
130   set [pos_tx], 0
131   set [pos_ty], 0
132   set [prof_item], 0
133   set [monster_tid], -666
134   ;
135   set [spr_item], -1
136   set [item_name_ofs], 0
137   set [item_name_len], 0
138   rst FRST_SET_ITEM_NAME, [item_name_ofs], [item_name_len]
139   ;
140   bsr game_load_level
141   set [game_state], GAME_STATE_PLAYING
142   brk ; give all threads a chance to initialize themselves
143   ;
144   jmp game_facing_loop_w2f
147 include: game/utils.awa
148 include: game/walkcheck.awa
149 include: game/falling.awa
150 include: game/fanchecks.awa
151 include: game/dodie.awa
152 include: game/scrolls.awa
153 include: game/doors.awa
154 include: game/sidemove.awa
155 include: game/loops_main.awa
156 include: game/jumps.awa
157 include: game/nono.awa
158 include: game/check_do_earth.awa
159 include: game/frame_common.awa