n900 data packages moved to another sections
[awish.git] / asm / game.awa
blobd471bb2725eeb1e4ab722dcfcffa722f7c53075c
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   jgt .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   set [game_want_key], 0
83   rst FRST_ML_GAME
84   set [cur_level], [start_level]
85   ;
86   set [mouse_hidden], 1
87   jeq @@f, [goobers], 0
88   set [mouse_hidden], 0
89 @@:
90   /*
91   set [cur_level], 11
92   set [cur_level], 16
93   set [cur_level], 13
94   set [cur_level], 12
95   */
96   rst FRST_STOP_CHANNEL, -1
97   ; load sounds
98   psh 0
99 @@:
100   dup
101   rst FRST_LOAD_SOUND
102   add 1
103   dup
104   jlt @@b, 23
105   drp
106   ;
107   rst FRST_GET_GOOBERS_INITER
108   jlt @@f, [rst_result], 0
109   bsr [rst_result]
111   ;ret  ; not needed
114 entry_game_restart_level:
115   set [start_level], [cur_level]
116   set [game_want_key], 0
117   rst FRST_ML_GAME
118   bsr clear_stack
119   bsr kill_all_threads
120   ; stop all sound
121   rst FRST_STOP_CHANNEL, -1
122   ;
123   set [game_state], GAME_STATE_STARTED
124   brk
125   ;
126   set [key_quit], 0
127   set [key_start], 0
128   set [key_escape], 0
129   ;
130   set [key_left], 0
131   set [key_right], 0
132   set [key_up], 0
133   set [key_down], 0
134   set [key_take], 0
135   set [key_use], 0
136   set [key_minimap], 0
137   set [key_restart], 0
138   ;
139   set [in_menu], 0
140   set [game_want_key], 0
141   ;
142   set [key_fall_cheat], 0
143   set [key_walk_cheat], 0
144   set [key_plev_cheat], 0
145   set [key_nlev_cheat], 0
146   ;
147   ;set [prof_fall_count], 0
148   set [pos_tx], 0
149   set [pos_ty], 0
150   set [prof_item], 0
151   set [monster_tid], -666
152   ;
153   set [spr_item], -1
154   set [item_name_ofs], 0
155   set [item_name_len], 0
156   rst FRST_SET_ITEM_NAME, [item_name_ofs], [item_name_len]
157   ;
158   bsr game_load_level
159   ;
160   rst FRST_GET_GOOBERS_ONLOAD
161   jlt @@f, [rst_result], 0
162   bsr [rst_result]
164   ;
165   set [game_state], GAME_STATE_PLAYING
166   set [game_want_key], 0
167   brk ; give all threads a chance to initialize themselves
168   ;
169   jmp game_facing_loop_w2f
172 include: game/utils.awa
173 include: game/walkcheck.awa
174 include: game/falling.awa
175 include: game/fanchecks.awa
176 include: game/dodie.awa
177 include: game/scrolls.awa
178 include: game/doors.awa
179 include: game/sidemove.awa
180 include: game/loops_main.awa
181 include: game/jumps.awa
182 include: game/nono.awa
183 include: game/check_do_earth.awa
184 include: game/frame_common.awa
185 include: game/zlayers.awa