;
; Phoenix Game. Based on ASCL Library
;
;**********************************************************************
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd IM_END ; size of image
dd I_END ; memory for app
dd I_END ; esp stack position
dd 0x0 , 0x0 ; I_Param , I_Icon
;**********************************************************************
include 'lang.inc' ; for SVN 'lang.inc'
include '../../../macros.inc' ; for SVN '..\..\..\macros.inc;'
include 'ascl.inc' ; main
include 'ascgl.inc' ; graphics
include 'ascpoal.inc' ; processing object array
include 'ascgml.inc' ; game library for collision detection
; debug flags
keyboard_debug=0 ; Set to 1 to view all keyboard keys state in game
light_space=0 ; May used for check canvas position in window
debug_scenario=0 ; May used for fast test of gameplay
stack_leak_debug=0 ; Show stack size on screen
debug_mode=1 ; Support keys:
; A - set player hp = 10000. Make player ship undestructible
; E - player hp / 2
; W - view final screen after game begin
screen_w equ 640
screen_h equ 440
;screen_w equ 1014
;screen_h equ 739
; Define special colors
cl_DarkRed equ 0x990000
cl_Orange equ 0xbbbb00
; Define objects type id
EmptyObject equ 0
; This numbers not possible for modify because draw_objects:
BlueWarShip equ 1
GreenWarShip equ 2
Asteroid equ 3
Box equ 4
Laser equ 1
Plasma equ 2
StaticPlasma equ 3
;**************************************************************
; Start of programm
;**************************************************************
START: ; start of execution
max_particles = 400
particle_size = 20
mov [particles],dword max_particles
mov [particles+4],dword particle_size
max_objects = 100
object_size = 20
mov [objects],dword max_objects
mov [objects+4],dword object_size
keyboard_set_input_mode 1 ; 0 - ASCII; 1 - scancodes;
;giftoimg gif_file_area2,canvas
giftoimg gif_file_area,objects_image
; load sprites
mov cl,9 ; cl - counter
xor esi,esi ; esi = 0
lea edi,[ship_img] ; address of first sprite
load_sprite:
pushad
getimg objects_image,esi,0,32,32,edi
popad
add edi,8+32*32*3 ; incrase offest of image data
add esi,32 ; incrase x position
dec cl
jnz load_sprite
set_main_menu:
mov ebx,-1 ; at start event_mode = -1
lea ecx,[draw_main_window]
lea edx,[menu_keyboard]
set_draw_proc:
; assembler extract command ; for use only bl
mov [event_mode],ebx
mov [draw_proc],ecx
mov [keyboard_proc],edx
; at first draw window
main_menu:
redraw_event: ; redraw event appears if user move, show/hide window
call draw_window
no_event:
call [draw_proc] ; no event no requre draw_window for no flickering
if stack_leak_debug = 1
; stack memory leak debug
lea ebp,[I_END]
sub ebp,esp
outcount ebp,10,30,cl_Green,5*65536
end if
menu_loop:
;wait_event redraw_event,keyboard_event,button_event
mov eax,10 ; wait event
mov ebx,[event_mode]
cmp ebx,-1 ; ebx delay for mcall 23
je wait_ev
mov eax,23 ; time event
wait_ev:
mcall
dec eax
js no_event
jz redraw_event
dec eax
jz keyboard_event
dec eax
jz button_event
jmp menu_loop ; if unknown event, skip it
keyboard_event: ; keyboard event if user press button
call [keyboard_proc]
jmp menu_loop
button_event:
window_get_button
cmp ah,1 ; if button id=1 (Red X of window) then close app
je close_app
cmp ah,2 ; if button id=2 then close app
je close_app
cmp ah,3 ; if button id=3 then start game
je start_game
cmp ah,4 ; if button id=3 then show help menu
je set_help_window ; jmp with redraw window
cmp ah,5 ; if button id=5 then back to main menu
je set_main_menu ; jmp with redraw window
cmp ah,6
je next_level ; run next level
cmp ah,7
je restart_lev ; restart level from gameover
cmp ah,9
je set_game_window ; back to game from menu
jmp menu_loop
close_app:
mov eax,-1 ; close this program
mcall
menu_keyboard:
; nothing do
window_get_key
ret
;***********************
; Main screen menu
;***********************
draw_main_window:
draw_label 160,160,'Phoenix',cl_Red+font_size_x8
draw_button 3,300,320,60,14,'START',cl_DarkRed,cl_Yellow
draw_button 4,300,340,60,14,'HELP',cl_DarkRed,cl_Yellow
draw_button 2,300,360,60,14,'EXIT',cl_DarkRed,cl_Yellow
ret
;**********************
; End level process
;**********************
set_end_level_window_from_call:
add esp,4 ; remove call address from stack
set_end_level_window:
lea edx,[menu_keyboard]
mov ebx,-1
lea ecx,[draw_end_level_window]
jmp set_draw_proc
draw_end_level_window:
draw_frect 170,130,300,190,cl_Grey
draw_label 280,150,'LEVEL COMPLETE',cl_Black
draw_button 2,180,300,80,14,'EXIT',cl_DarkRed,cl_Black
draw_button 5,280,300,80,14,'