n900 data packages moved to another sections
[awish.git] / asm / mainmenu.awa
blob924b5da40a6e2ba87db35833d01453bf105cbd02
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  */
16 proc: main_menu
17 locals: .actitem
18   set [.actitem], 0
19   ;
20 .main_loop:
21   set [key_left], 0
22   set [key_right], 0
23   set [key_up], 0
24   set [key_down], 0
25   set [key_start], 0
26   set [key_escape], 0
27   bsr mm_fix_start_level
28   bsr mm_fix_sound
29   ;
30   psh [polyfix_base]  ; scale
31   psh 0               ; angle
32   rst FRST_START_POLY, 140, 85  ; ofsx, ofsy
33   rst FRST_ADD_POLY_POINT, 0, 0
34   rst FRST_ADD_POLY_POINT, 130, 0
35   rst FRST_ADD_POLY_POINT, 130, 90
36   rst FRST_ADD_POLY_POINT, 0, 90
37   rst FRST_END_POLY, 0, 180
38   ;
39   psh [.actitem]
40   bsr draw_menu, 100, main_menu_data
41   ;
42   brk
43   jne quit_program, [key_quit], 0
44   ;
45   jeq @@f, [key_escape], 0
46   ret 0
47 @@:
48   jeq @@f, [key_start], 0
49   jeq quit_program, [.actitem], 3
50   jlt .start, [.actitem], 2
51   ; sound toggle
52   sub 1, [sound_disabled], [sound_disabled]
53 @@:
54   jeq @@f, [key_up], 0
55   jeq @@f, [.actitem], 0
56   sub [.actitem], 1
57 @@:
58   jeq @@f, [key_down], 0
59   jeq @@f, [.actitem], 3
60   add [.actitem], 1
61 @@:
62   jeq @@f, [key_left], 0
63   jne @@f, [.actitem], 1
64   jeq @@f, [start_level], 0
65   sub [start_level], 1
66 @@:
67   jeq @@f, [key_right], 0
68   jne @@f, [.actitem], 1
69   jeq @@f, [start_level], [max_level]
70   add [start_level], 1
71 @@:
72   jmp .main_loop
73 .start:
74   ret 1
75 endp: main_menu
78 proc: mm_fix_start_level
79   jlt .onedigit, [start_level], 9
80   ;
81   psh main_menu_level_digit1
82   psh [start_level]
83   add 1
84   mod 10
85   add 48
86   wxc
87   psh main_menu_level_digit0
88   psh [start_level]
89   add 1
90   div 10
91   mod 10
92   add 48
93   wxc
94   ret
95 .onedigit:
96   psh main_menu_level_digit0
97   psh [start_level]
98   add 1
99   mod 10
100   add 48
101   wxc
102   wxc main_menu_level_digit1, 32
103   ret
104 endp: mm_fix_start_level
107 proc: mm_fix_sound
108   jeq .sound, [sound_disabled], 0
109   wxc main_menu_sound_text0, 110
110   wxc main_menu_sound_text1, 111
111   wxc main_menu_sound_text2, 32
112   ret
113 .sound:
114   wxc main_menu_sound_text0, 121
115   wxc main_menu_sound_text1, 101
116   wxc main_menu_sound_text2, 115
117   ret
118 endp: mm_fix_sound
121 proc: draw_menu
122 args: .actitem, .y, .menu
123 locals: .t
124 .draw_loop:
125   rxc [.menu]
126   jeq .quit, 0
127   ;
128   psh 150    ; x
129   psh [.-5]  ; y
130   psh [polyfix_base]  ; scale
131   mul 3
132   div 4
133   psh 0    ; angle
134   psh 4    ; color
135   jne @@f, [.-10], 0  ; .actitem
136   drp
137   psh 1
139   rst FRST_DRAW_TEXT, [.-8]  ; .menu
141   rxc [.menu], [.t]
142   add [.menu], 1
143   jne @@b, [.t], 0
144   add [.y], 20
145   sub [.actitem], 1
146   jmp .draw_loop
147 .quit:
148   ret
149 endp: draw_menu
151 main_menu_data:
152   dz: "Start Game"
153   dz: "Level:01"
154 label: main_menu_level_digit0 = $-3
155 label: main_menu_level_digit1 = $-2
156   dz: "Sound:yes"
157 label: main_menu_sound_text0 = $-4
158 label: main_menu_sound_text1 = $-3
159 label: main_menu_sound_text2 = $-2
160   dz: "Quit"
161   db: 0