Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 108 → Rev 109

/programs/games/15/trunk/15.ASM
0,0 → 1,489
;
; The famous game 15
; Author: Lloyd, coded by Ivushkin Andrey
; Compile with FASM
;
include 'lang.inc'
include 'macros.inc' ; decreases program size (not required)
 
BgdColor equ 0x02aabbcc
StatusColor equ 0x02ffffff
StatusColor2 equ 0x02dc1e14
BgdColor equ 0x03aabbcc
 
; Main window dimensions
XXwindow equ 200 shl 16+276
YYwindow equ 200 shl 16+300
; Status bar
XYstatus equ 35 shl 16+283
XXbar equ 35 shl 16+136
YYbar equ 280 shl 16+15
; Buttons
BtnTop equ 28
BtnLeft equ 13
BtnSize equ 60
BtnColor equ 0xafbb55
BtnColor2 equ 0x0228c314
 
NumColor equ 0x10000000
; Number shifting for nice look
NumShift equ 24 shl 16+27
NumShift2 equ 4 shl 16
; Shuffle button
XXSh equ 202 shl 16+60
YYSh equ 280 shl 16+12
XYShText equ 212 shl 16+283
 
; Conf button
XXCnf equ 13 shl 16+13
YYCnf equ 280 shl 16+12
XYCnfText equ 18 shl 16+283
 
; Position of the 'hole'
null equ (curconf+16)
; Amount of moves to perform shuffle
SH_CYCLES equ 400
; (Amount of tasks)-1
CONF_COUNT equ 2
 
use32
 
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x2000 ; 8 Kb
dd 0x2000
dd 0x0
dd 0x0
 
 
START:
mov [cptr],CONF_COUNT ; number of task
mov eax,3
int 0x40
mov cl,16
ror eax,cl
mov [generator],eax ; random generator from Tetris
init:
mov ecx,17
movzx eax,[cptr]
inc eax
cmp eax,CONF_COUNT
jna init_ok
xor eax,eax ; cycling 0..CONF_COUNT
init_ok:
mov [cptr],al
mov esi,eax
shl esi,4
add esi,conf
add esi,eax
add al,0x31
mov [lenTitle-1],al ;task number to program title
mov [task],esi
mov edi,curconf
rep movsb ; initial configuration
 
mov [sts],4
jmp red
SHUF:
call shuffle ; immediate shuffle
red: ; window redraw
 
call draw_window
 
still: ; MAIN PROGRAM CYCLE
 
mov eax,10 ; wait for event
int 0x40
 
cmp eax,1 ; redraw? -
je red ; goto red
cmp eax,2 ; key pressed? -
je key ; goto key
cmp eax,3 ; button pressed? -
je button ; goto button
 
jmp still ; no more events to process
 
key: ; Key pressed
mov eax,2
int 0x40
shr eax,8
cmp eax,32 ; <Space> = Shuffle
je SHUF
cmp eax,13 ; <Enter> = Choose task
je init
cmp eax,176
jl still
sub eax,176
cmp eax,3
ja still
movzx eax,byte [eax+correct] ; 'delta' value from correct[]
jmp m_check
 
button: ; Button pressed
mov eax,17
int 0x40
shr eax,8
sub eax,2
 
cmp eax,-1 ; id == 1 (closeme)?
jne noclose
int 0x40
 
noclose:
jl SHUF ; Shuffle (id=0) pressed
cmp eax,18
je init ; Conf button pressed
sub al,byte [null]
mov edi,correct
mov ecx,4
repne scasb ; checking for valid move-part 1
jne fail
m_check:
cmp byte[sts],4 ; puzzle completed, blocking buttons
ja still
call move_check ; checking for valid move-part 2
jnc fail
inc [move_count]
call draw_moves
fail:
jmp still ; ¢®§¢à é ¥¬áï
 
; *******************************
; ******* WINDOW DRAWING *******
; *******************************
 
draw_window:
mov eax,12
mov ebx,1 ; begin draw
int 0x40
 
; CREATING WINDOW
mov eax,0
mov ebx,XXwindow
mov ecx,YYwindow
mov edx,BgdColor
mov esi,0x805080d0
mov edi,0x005080d0
int 0x40
 
; PROGRAM TITLE
mov eax,4
mov ebx,8*65536+8
mov ecx,0x10ddeeff
mov edx,txtTitle
mov esi,lenTitle-txtTitle
int 0x40
 
mov eax,8 ; SHUFFLE BUTTON
mov ebx,XXSh
mov ecx,YYSh
xor edx,edx
mov esi,BtnColor
int 0x40
 
mov ebx,XXCnf ; CONF BUTTON
mov ecx,YYCnf
mov edx,20
mov esi,BtnColor
int 0x40
 
mov ebx, XYShText ; SHUFFLE TEXT
mov ecx, StatusColor
mov edx,txtSh
mov esi,lenSh-txtSh
mov eax,4
int 0x40
 
mov ebx, XYCnfText ; CONF TEXT
mov edx,lenVictory-1
mov esi,1
int 0x40
 
mov ecx, 16 ; FIELD BUTTONS
dbut:
call draw_button
loop dbut
 
call draw_moves
 
mov eax,12
mov ebx,2 ; end of drawing
int 0x40
ret
 
 
; *********************************************
; ******* DRAWING A FIELD BUTTON **************
; *********************************************
; ECX - button number
 
draw_button:
pusha
dec ecx
; calculating button dimensions
mov edi, ecx
lea edx,[ecx+2]
mov ebx,ecx
and ebx,11b
shr ecx,2
 
imul ebx,BtnSize+3
add ebx,BtnLeft
shl ebx,16
add ebx,BtnSize
 
imul ecx,BtnSize+3
add ecx,BtnTop
shl ecx,16
add ecx,BtnSize
movzx eax,byte [null]
cmp eax,edi
jne no_hole
 
pusha
inc ebx
inc ecx
mov edx,BgdColor
mov eax,13 ; clearing - 'hole'
int 0x40
popa
 
or edx,0x80000000 ; and removing button under it
no_hole:
mov al,byte[edi+curconf]
mov esi,[task]
cmp al,byte[edi+esi]
je highlight
mov esi,BtnColor
jmp s_rbutton
highlight:
mov esi,BtnColor2
s_rbutton:
mov eax,8 ; set/remove button
int 0x40
movzx eax,byte [null]
cmp eax,edi
je no_text ; no digits - that's hole
mov edx,ebx
shr ecx,16
mov dx,cx
add edx,NumShift
mov ebx,0x20000
movzx ecx,byte [edi+curconf]
cmp ecx,9
ja two_num
add edx,NumShift2 ; shift to center digits
sub ebx,0x10000
two_num:
mov esi,NumColor
mov eax,47
int 0x40
no_text:
popa
ret
 
 
; *********************************************
; ******* DRAWING STATUS LINE *****************
; *********************************************
 
draw_moves:
mov eax, 13 ; clear area
mov ebx, XXbar
mov ecx, YYbar
mov edx, BgdColor
int 0x40
 
mov eax, 4
mov ebx, XYstatus
mov ecx, StatusColor
cmp ax, [sts]
jl report_victory
jne report_moves
mov edx,txtCnf ; prompt to choose configuration
mov esi,lenCnf-txtCnf
jmp e_dm
report_moves:
mov edx,txtMoves ; how many moves done
mov esi,lenMoves-txtMoves
mov eax,4
int 0x40
mov esi,ecx
mov edx,ebx
add edx, 40 shl 16
mov ebx,0x030000
movzx ecx, byte[move_count]
mov eax,47
jmp e_dm
report_victory: ; puzzle completed
mov ecx,StatusColor2
mov edx,txtVictory
mov esi,lenVictory-txtVictory
e_dm:
int 0x40
ret
 
 
; *********************************************
; ********* SHUFFLE ***************************
; *********************************************
 
shuffle:
xor eax,eax
mov [sts],ax
mov [move_count],ax ; reset moves to 0
mov [sh_off],al
mov eax, [generator]
 
mov ecx,SH_CYCLES
sh_cycle:
sub eax,0x43ab45b5 ; next random number
ror eax,1
xor eax,0x32c4324f
ror eax,1
mov [generator],eax
 
push eax
and eax,11b ; direction 0..3
movzx eax,byte [eax+correct]
call move_check
pop eax
jnc sh_cycle ; if fails then retry
loop sh_cycle
inc byte[sh_off] ; shuffling complete
ret
 
 
; *********************************************
; ********* MOVE VALIDITY CHECK ***************
; *********************************************
; AL - 'DELTA' DIRECTION
 
move_check:
pusha
mov ah,byte [null]
mov bx,ax
cmp bh,3
ja no_top
cmp al,-4 ; top of field
je no_move
no_top:
cmp bh,12
jb no_bottom
cmp al,4 ; bottom of field
je no_move
no_bottom:
and bh,11b
cmp bh,0
jnz no_left
cmp al,-1 ; left of field
je no_move
no_left:
cmp bh,11b
jnz ok
cmp al,1 ; right of field
je no_move
ok:
mov bx,ax
add bh,bl ; bh-new hole
mov byte [null],bh
movzx ecx,ah
mov al,byte[ecx+curconf]
movzx edx,bh
mov bl,byte[edx+curconf] ; swapping button & hole
mov byte[ecx+curconf],bl
mov byte[edx+curconf],al
 
cmp byte[sh_off],0 ; if shuffle in progress,
jz no_win ; then no redraw
 
; drawing button & hole
inc ecx
call draw_button
movzx ecx,bh
inc ecx
call draw_button
; testing if task completed
mov esi,[task]
mov edi,curconf
mov ecx,16
repe cmpsb
cmp ecx,0
jne no_win
mov word[sts],6 ; puzzle done. Victory!
no_win:
popa
stc
ret
no_move:
popa
clc
ret
; this is deprecated debug routine
;ud:
; ud2
 
; These are data used by program
 
correct db 1,-4,4,-1
 
conf db 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,15
db 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0
db 1,2,3,4,12,13,14,5,11,0,15,6,10,9,8,7,9
 
txtMoves:
if lang eq ru
db '•®¤®¢:'
else
db 'Moves:'
end if
lenMoves:
 
txtSh:
if lang eq ru
db '’ á®¢ª '
else
db 'Shuffle'
end if
lenSh:
 
txtCnf:
if lang eq ru
db '‚ë¡¥à¨â¥ § ¤ çã ¨ ­ ¦¬¨â¥->'
else
db 'Select task, then press ->'
end if
lenCnf:
 
txtTitle: ; áâப  § £®«®¢ª 
if lang eq ru
db 'ˆ£à  15 - § ¤ ç  X'
else
db 'Game 15 - puzzle X'
end if
lenTitle: ; ¨ ¥ñ ª®­¥æ
 
txtVictory:
if lang eq ru
db '‚ë à¥è¨«¨ § ¤ çã!  ¦¬¨â¥->'
else
db 'Puzzle completed! Press->'
end if
lenVictory:
 
arrow equ lenVictory-2
 
I_END: ; ª®­¥æ ¯à®£à ¬¬ë
;null db ?
move_count dw ?
cptr db ?
sts dw ?
sh_off db ?
task dd ?
generator dd ?
curconf:
/programs/games/15/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm 15.asm 15
@pause
/programs/games/15/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm 15.asm 15
@pause
/programs/games/15/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/arcanii/trunk/arcanii.asm
0,0 → 1,921
VERSION equ 'ARCANOID II v. 0.30'
; by jj
; (jacek jerzy malinowski)
;
; contact: 4nic8@casiocalc.org
;----------------------------------------
; Compile with FASM for Menuet
;----------------------------------------
 
include 'lang.inc'
include 'ascl.inc'
include 'ascgl.inc'
include 'asjc.inc'
 
X_SIZE equ 400
Y_SIZE equ 300
 
MAX_LEVEL equ 5
 
BACK_CL equ 0x00EFEF ; background color
 
; THE MAIN PROGRAM:
use32
 
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x200000 ; memory for app
dd 0x7fff0 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
START: ; start of execution
 
bmptoimg bmp_file,img_bmp ; loading ... ;]
getimg img_bmp,0,0,10,10,img_ball
getimg img_bmp,20,0,20,10,img_bonus
getimg img_bmp,0,10,40,20,img_brick1
getimg img_bmp,0,30,40,20,img_brick2
getimg img_bmp,0,50,40,20,img_brick3
getimg img_bmp,0,70,40,20,img_brick4
 
call draw_window
 
still:
if_e dword [level],0,.no_intro
call intro
jmp .no_game
.no_intro:
 
if_e dword [mode],2,.end_if1
call level_info
jmp .no_game
.end_if1:
 
if_e dword [mode],4,.end_if2
call game_over
jmp .no_game
.end_if2:
 
call fast_gfx ; <-- the main engine
.no_game:
 
mov eax,11
int 0x40
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
 
jmp still
 
red: ; redraw
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
cmp ah,key_Esc ; if Esc ?
jne .no_q
mov eax,-1
int 0x40
.no_q:
 
if_e dword [mode],4,.end_if6
jmp still
.end_if6:
 
cmp ah,key_Space
jne .no_space
if_e dword [mode],2,.end_if1
mov dword [mode],0
jmp .no_space
.end_if1:
mov dword [mode],1
call fast_gfx
.no_space:
xor ebx,ebx
mov bl,ah
if_e ebx,key_F1,.no_f1
inc dword [del]
.no_f1:
if_e ebx,key_F2,.no_f2
if_a dword [del],0,.end_if3
dec dword [del]
.end_if3:
.no_f2:
 
 
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne noclose
 
mov eax,-1 ; close this program
int 0x40
noclose:
 
jmp still
 
; *********************************************
; ******* VIRTUAL SCREEN FUNCTIONS ************
; *********************************************
 
show_screen: ; flips the virtual screen to the window
push_abc
 
mov eax,7
mov ebx,screen
mov ecx,X_SIZE*65536+Y_SIZE
mov edx,4*65536+20
int 0x40
 
pop_abc
ret
 
put_bmp_screen: ; eax - y , ebx - x, esi - bmp
cmp ebx,X_SIZE-5
jb .ok1
ret
.ok1:
cmp eax,Y_SIZE-5
jb .ok2
ret
.ok2:
 
push_abc
xor ecx,ecx
xor edx,edx
mov edi,screen
mov ecx,3
mul ecx ; xx = 3*y*X_SIZE+3*x
mov ecx,X_SIZE
mul ecx
push eax ; #> 1
mov eax,ebx
mov ecx,3
mul ecx
mov ebx,eax
pop edx ; #< 1
add edx,ebx
add edi,edx ; sets the pointer to x,y of the screen
 
mov cx,[si] ; loops 1
xor ebx,ebx
mov ax,cx
mov dx,3
mul dx
mov bx,ax
 
push ebx ;#>4
 
add si,4
mov ax,[si] ; loops 2
mov cx,[si]
;shr ax,2
mov dx,3 ; dx = ax *3
mul dx
mov bx,ax
add si,4
 
 
pop ebx ;#<4
.l_y:
mov ax,cx
cld
mov cx,bx
rep movs byte [edi],[esi]
add edi,X_SIZE
add edi,X_SIZE
add edi,X_SIZE
sub edi,ebx
mov cx,ax
loop .l_y
 
pop_abc
ret
 
rect_screen: ; eax - y , ebx - x, ecx - size x, edx - size y, si -color
mov edi,ebx
add ebx,ecx
cmp ebx,X_SIZE
jb .ok1
ret
.ok1:
mov ebx,edi
 
mov edi,eax
add eax,edx
cmp eax,Y_SIZE
jb .ok2
ret
.ok2:
mov eax,edi
push_abc
push ecx ;#>2
push edx ;#>3
 
xor ecx,ecx
xor edx,edx
mov edi,screen
mov ecx,3
mul ecx ; xx = 3*y*X_SIZE+3*x
mov ecx,X_SIZE
mul ecx
push eax ; #> 1
mov eax,ebx
mov ecx,3
mul ecx
mov ebx,eax
pop edx ; #< 1
add edx,ebx
 
add edi,edx ; sets the pointer to x,y of the screen
 
pop ecx ; #<3
pop edx ; #<4
mov eax,esi
.l_y:
;mov ax,cx
push ecx
cld
mov ecx,edx
.l_x:
;rep movs byte [edi],[esi]
mov word [edi],ax
push eax
shr eax,16
mov byte [edi+2],al
add edi,3
pop eax
loop .l_x
 
add edi,X_SIZE
add edi,X_SIZE
add edi,X_SIZE
sub edi,edx
sub edi,edx
sub edi,edx
;mov cx,ax
pop ecx
loop .l_y
 
pop_abc
ret
 
grad_rect_screen: ; eax - y , ebx - x, ecx - size x, edx - size y, si -color, d
push edi ;#>0
mov edi,ebx
add ebx,ecx
cmp ebx,X_SIZE
jb .ok1
pop edi ;#<0
ret
.ok1:
mov ebx,edi
 
mov edi,eax
add eax,edx
cmp eax,Y_SIZE
jb .ok2
pop edi ;#<0
ret
.ok2:
mov eax,edi
 
pop edi ;#<0
push_abc
 
push edi ;#>5
push ecx ;#>2
push edx ;#>3
 
xor ecx,ecx
xor edx,edx
mov edi,screen
mov ecx,3
mul ecx ; xx = 3*y*X_SIZE+3*x
mov ecx,X_SIZE
mul ecx
push eax ; #> 1
mov eax,ebx
mov ecx,3
mul ecx
mov ebx,eax
pop edx ; #< 1
add edx,ebx
 
add edi,edx ; sets the pointer to x,y of the screen
 
pop ecx ; #<3
pop edx ; #<2
mov eax,esi
pop esi ; #<5
.l_y:
;mov ax,cx
push ecx
cld
mov ecx,edx
.l_x:
;rep movs byte [edi],[esi]
mov word [edi],ax
push eax
shr eax,16
mov byte [edi+2],al
add edi,3
pop eax
loop .l_x
 
add edi,X_SIZE
add edi,X_SIZE
add edi,X_SIZE
sub edi,edx
sub edi,edx
sub edi,edx
add eax,esi
;mov cx,ax
pop ecx
loop .l_y
 
pop_abc
ret
 
 
fill_screen: ; eax - screen color ( 0x00RRGGBB )
push_abc
mov edi,screen
cld
mov ecx,X_SIZE*Y_SIZE
.lab1:
mov [edi],eax
add edi,3
loop .lab1
pop_abc
ret
 
grad_fill_screen: ; eax - screen color ( 0x00RRGGBB ), ebx - mack
push_abc
mov edi,screen
cld
mov ecx,Y_SIZE
mov dl,0
.lab1:
push ecx
mov ecx,X_SIZE
.lab2:
mov [edi],eax
add edi,3
loop .lab2
mov dh,1 ; dl = 1 - dl
sub dh,dl
mov dl,dh
cmp dl,0
jne .no_ch ; if (dl==0)
add eax,ebx ; change gradient
.no_ch:
pop ecx
loop .lab1
pop_abc
ret
 
 
bmp_fill_screen: ; esi - pointer to a backgroung bmp
push_abc
mov edi,screen
cld
mov ecx,X_SIZE*Y_SIZE
rep movs dword [edi],[esi]
pop_abc
ret
 
;___________________
intro: ; INTRO ;
label 140,200,VERSION,0x100000FF
label 120,220,'by jj (jacek jerzy malinowski)',0x050505
label 100,240,'press SPACE to start a new game',0x10FF0800
label 15,240,'F1 + delay',0xFFA8FF
label 15,260,'F2 + delay',0xFFA8FF
delay 10
ret
 
;___________________
level_info:
label 170,230,'L E V E L',0x100000FF
outcount [level],195,250,0x100000FF,2*65536
label 100,270,'press SPACE to start the level',0x10FF0800
delay 10
ret
 
;_________________________
game_over: ; GAME OVER ;
mov eax,0x00FF00
mov ebx,0xFF01
.g_ok:
call grad_fill_screen
call show_screen ; flips the screen
label 120,150,'G A M E O V E R',0x10050505
label 140,200,'Thanks for playing',0x0FFF800
delay 20
ret
 
 
;-----------------------------;
; THE MAIN THE GAME'S ENGINE ;
;-----------------------------;
fast_gfx:
; the background gradient
if_e dword [level],0,.no_0
mov eax,0xFF
mov ebx,0xFEFF
jmp .g_ok
.no_0:
if_e dword [level],1,.no_1
mov eax,BACK_CL
mov ebx,0xFFFF
jmp .g_ok
.no_1:
if_e dword [level],2,.no_2
mov eax,0xFF0000
mov ebx,0xFF00FF
jmp .g_ok
.no_2:
 
mov eax,BACK_CL
mov ebx,0xFFFF
.g_ok:
call grad_fill_screen
 
mov eax,37 ; get mouse position
mov ebx,1
int 0x40
shr eax,16
mov [x],eax
add eax,[s_x]
cmp eax,X_SIZE ; controls if the pad is in the screen
jb .ok
cmp eax,0x7FFF ; if < 0
jb .upper
mov [x],0
jmp .ok
.upper: ; if > X_SIZE - pad size
mov dword [x],X_SIZE-1
mov eax,[s_x]
sub dword [x],eax
.ok:
mov ebx,[x]
mov eax,[y]
mov ecx,[s_x]
mov edx,15
mov esi,0xFF0000
mov edi,0xF0000F
call grad_rect_screen
 
call draw_level
 
cmp dword [mode],1
jne .no_go ; is the game started ?
mov eax,[v_x]
add dword [b_x],eax
mov eax,[v_y]
add dword [b_y],eax
jmp .go
.no_go:
mov eax,[x] ; b_x = x + x_s/2
mov ebx,[s_x]
shr ebx,1
add eax,ebx
mov dword [b_x],eax
mov eax,[y] ; b_y = y - 10
sub eax,10
mov dword [b_y],eax
 
mov dword [v_x],1
mov dword [v_y],-1
.go:
;TEST WHERE IS THE BALL:
cmp dword [b_x],0x7FFFFFFF
jb .b_ok2 ; if out of the screen (left)
mov dword [b_x],0
mov eax,0
sub eax,[v_x]
mov [v_x],eax
.b_ok2:
cmp dword [b_x],X_SIZE-10
jb .b_ok1 ; if out of the screen (right)
mov dword [b_x],X_SIZE-11
mov eax,0
sub eax,[v_x]
mov [v_x],eax
.b_ok1:
cmp dword [b_y],0x7FFFFFFF
jb .b_ok3 ; if out of the screen (up)
mov dword [b_y],0
mov eax,0
sub eax,[v_y]
mov [v_y],eax
.b_ok3:
cmp dword [b_y],Y_SIZE-10
jb .b_ok4 ; if out of the screen (down)
mov dword [mode],0
if_e dword [lives],0,.end_if5
mov dword [mode],4 ; GAME OVER
jmp still
.end_if5:
dec dword [lives]
.end_else4:
call draw_window
.b_ok4:
 
imgtoimg img_ball,dword [b_x],dword [b_y],screen_img
 
call show_screen ; flips the screen
delay dword [del]
 
call do_tests ; does all needed tests
ret
;----------------------;
; BALL & BRICKS EVENTS ;
;----------------------;
MAX_SPEED equ 3
do_tests:
; BALL <-> PAD
mov eax,[b_x]
add eax,10
cmp eax,[x] ; if (b_x+10)>[pad x]
jb .skip ; &&
mov eax,[b_x]
mov ebx,[s_x]
add ebx,[x]
cmp eax,ebx ; if b_x < x + s_x
ja .skip ; &&
mov eax,[b_y]
add eax,10
cmp eax,[y] ; if (b_y+10) > y
jb .skip
sub eax,15
cmp eax,[y] ; if b_y < y+15
ja .skip
cmp dword [v_y],0x7FFFFF ; if v_y > 0
ja .skip
cmp dword [v_y],MAX_SPEED; speedup:
ja .skip_s
inc dword [speed_t]
cmp dword [speed_t],5
jb .skip_s
inc dword [v_y]
mov dword [speed_t],0
.skip_s:
inc dword [speed_t]
mov eax,0
sub eax,[v_y]
mov [v_y],eax
;counting v_x:--------
mov eax,[b_x]
sub eax,[x]
sub eax,5
mov ecx,eax
if_a eax,100,.end_if3
mov eax,0
sub eax,[v_x]
mov [v_x],eax
jmp .skip
.end_if3:
if_a eax,20,.end_if2
sub eax,20
shr eax,2
mov [v_x],eax
jmp .skip
.end_if2:
mov ebx,20
sub ebx,ecx
shr ebx,2
mov dword [v_x],0
sub dword [v_x],ebx
.skip:
 
; BALL <-> BRICK
mov dword [coliz],0
call colision
if_e dword [coliz],1,.end_if6
;abs dword [v_y]
;abs dword [v_x]
ret
.end_if6:
add dword [b_x],10
call colision
sub dword [b_x],10
if_e dword [coliz],1,.end_if7
;abs dword [v_y]
;abs dword [v_x]
ch_sign dword [v_x]
ret
.end_if7:
add dword [b_y],10
call colision
sub dword [b_y],10
if_e dword [coliz],1,.end_if8
;abs dword [v_y]
;abs dword [v_x]
;ch_sign dword [v_y]
ret
.end_if8:
add dword [b_x],10
add dword [b_y],10
call colision
sub dword [b_x],10
sub dword [b_y],10
if_e dword [coliz],1,.end_if9
;abs dword [v_y]
;abs dword [v_x]
;ch_sign dword [v_x]
;ch_sign dword [v_y]
 
ret
.end_if9:
 
 
ret
 
colision:
 
mov esi,levels
mov eax,[level] ; eax = levels*100
mov bx,100
mul bx
add esi,eax
;--------------
xor edx,edx
mov eax,[b_x]
mov ebx,40
div ebx
mov ecx,eax
push edx ;#>1
 
xor edx,edx
mov eax,[b_y]
mov ebx,20
div ebx
push edx ;#>2
cmp eax,9 ; out of the bricks board
ja .ok2
mov ebx,10
mul ebx
add eax,ecx
add esi,eax
 
cmp byte [esi],0 ; 0 - no brick
je .ok2
if_ne byte [esi],4,.end_if1
dec byte [esi]
.end_if1:
mov dword [coliz],1
pop ebx ;#<2
pop eax ;#<1
cmp ecx,8 ; x < 5 || x >35 - x inv
jb .inv
cmp ecx,33
ja .inv
jmp .no_inv
.inv:
mov eax,0
sub eax,[v_x]
mov [v_x],eax
;jmp .no_ok
.no_inv:
cmp ebx,6 ; if y < 5 || y>15 - y inv
jb .inv_y
cmp ebx,14
ja .inv_y
jmp .no_ok
.inv_y:
mov eax,0
sub eax,[v_y]
mov [v_y],eax
.no_ok:
jmp .ok
.ok2:
pop eax ;#<1
pop eax ;#<2
.ok:
 
 
ret
 
;-----------------------------------;
; DRAWS CURRENT LEVEL ON THE SCREEN ;
;-----------------------------------;
draw_level:
mov esi,levels
mov eax,[level] ; eax = levels*100
mov bx,100
mul bx
add esi,eax
mov ecx,10
mov eax,0
mov dword [l_end],1
.l_y:
push ecx ;#>1
mov ebx,0
mov ecx,10
.l_x:
cmp byte [esi],1 ; if 1 ?
push esi;#>2
jne .no_1
mov esi,img_brick1
call put_bmp_screen
mov dword [l_end],0
.no_1:
cmp byte [esi],2 ; if 2 ?
jne .no_2
mov esi,img_brick2
call put_bmp_screen
mov dword [l_end],0
.no_2:
cmp byte [esi],3 ; if 3 ?
jne .no_3
mov esi,img_brick3
call put_bmp_screen
mov dword [l_end],0
.no_3:
cmp byte [esi],4 ; if 4 ?
jne .no_4
mov esi,img_brick4
call put_bmp_screen
.no_4:
 
add ebx,40
pop esi ;#<2
inc esi
loop .l_x
add eax,20 ;#<1
pop ecx
loop .l_y
;----------------
; NEXT LEVEL
if_e dword [l_end],1,.end_if ; all bricks are taken
if_e dword [mode],1,.end_if
add dword [level],1
if_a dword [level],MAX_LEVEL,.end_if2
mov dword [mode],4 ; game over
jmp still
.end_if2:
call fast_gfx
mov dword [mode],2
.end_if:
ret
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
startwd
 
window 100,100,X_SIZE+8,Y_SIZE+21,0x03ffffff
label 8,8,VERSION,cl_White+font_Big
label 200,8,'LIVES:',0x10ddeeff
outcount dword [lives],250,8,0x10ddeeff,65536
 
call fast_gfx
 
endwd
 
ret
 
;-----------;####################
; DATA AREA ;####################
;-----------;####################
 
lives dd 5
mode dd 0
l_end dd 0 ; if 1 the level is over
; PAD x:
x dd 20
y dd Y_SIZE-20
; PAD length:
s_x dd 40
 
; the ball stuff ;-)
b_x dd 100
b_y dd 250
v_y dd 0
v_x dd 3
 
speed_t dd 0 ; 1/10 times speedup
del dd 1 ; delay
 
coliz dd 0 ; if 1 then colizion with a brick
 
; LEVELS:
level dd 0
levels:
;LEVEL 0:
db 0,0,0,0,0,0,0,0,0,0
db 0,4,0,0,4,4,0,0,0,4
db 4,0,4,0,4,0,4,0,4,0
db 4,0,4,0,4,0,4,0,4,0
db 4,4,4,0,4,4,0,0,4,0
db 4,0,4,0,4,0,4,0,4,0
db 4,0,4,0,4,0,4,0,0,4
db 0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0
 
;LEVEL 1:
db 1,1,1,1,1,1,1,1,1,1
db 0,3,0,0,3,3,0,0,0,3
db 3,0,3,0,3,0,3,0,3,0
db 3,0,3,0,3,0,3,0,3,0
db 3,3,3,0,3,3,0,0,3,0
db 3,0,3,0,3,0,3,0,3,0
db 3,0,3,0,3,0,3,0,0,3
db 2,2,2,2,2,2,2,2,2,2
db 1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1
;LEVEL 2:
db 3,3,3,3,0,0,3,3,3,3
db 3,1,1,1,0,0,1,1,1,3
db 3,1,2,1,3,3,1,2,1,3
db 0,1,0,1,3,3,1,0,1,0
db 2,1,2,1,1,1,1,2,1,2
db 0,1,0,1,2,2,1,0,1,0
db 2,1,2,1,1,1,1,2,1,2
db 0,1,0,1,1,1,1,0,1,0
db 0,0,0,1,0,0,1,0,0,0
db 0,0,0,1,0,0,1,0,0,0
;LEVEL 3:
db 1,2,3,1,2,3,1,3,2,1
db 2,3,1,2,3,1,3,3,1,2
db 3,1,2,3,1,2,3,1,2,3
db 1,2,3,1,2,3,1,3,2,1
db 2,3,1,2,3,1,3,3,1,2
db 3,1,2,3,1,2,3,1,2,3
db 1,2,1,2,1,2,1,2,1,2
db 1,0,1,0,1,0,1,0,1,0
db 0,0,3,0,0,0,0,3,0,0
db 0,0,3,0,0,0,0,3,0,0
;LEVEL 4:
db 0,0,0,1,1,1,1,0,0,0
db 0,0,1,2,2,2,2,1,0,0
db 1,1,1,2,2,2,2,1,1,1
db 1,0,1,0,2,2,0,1,0,1
db 0,1,1,2,2,2,2,1,1,0
db 0,0,1,2,2,2,2,1,0,0
db 0,0,1,2,2,2,2,1,0,0
db 0,0,1,2,3,3,2,1,0,0
db 0,0,1,2,2,2,2,1,0,0
db 0,0,0,1,1,1,1,0,0,0
;LEVEL 5:
db 1,1,1,1,1,1,1,1,1,1
db 1,2,0,0,3,2,0,0,2,1
db 1,2,0,0,2,3,0,0,2,1
db 2,2,0,0,3,2,0,0,2,2
db 0,0,0,0,2,3,0,0,0,0
db 0,0,0,1,1,1,1,0,0,0
db 0,0,1,1,0,0,1,1,0,0
db 0,0,1,1,0,0,1,1,0,0
db 2,1,2,1,2,1,2,1,2,1
db 1,2,1,2,1,2,1,2,1,2
 
 
; BITMAPs and IMAGEs
bmp_file:
file 'arcanii.bmp'
 
img_bmp:
rb 40*90*3+8
img_brick1:
rb 40*20*3+8
img_brick2:
rb 40*20*3+8
img_brick3:
rb 40*20*3+8
img_brick4:
rb 40*20*3+8
img_ball:
rb 10*10*3+8
img_bonus:
rb 20*10*3+8
 
 
screen_img:
dd X_SIZE
dd Y_SIZE
screen:
rb X_SIZE*Y_SIZE*3
 
I_END:
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/arcanii/trunk/arcanii.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/games/arcanii/trunk/ascgl.inc
0,0 → 1,1387
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Graphics
; Libary
;
; Ver 0.18 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 LoadImage
;0.02 SetBmp
;0.03 Bmptoimg, Setimg ~01.03.2004
;0.04 Bug deleted, copyimg ~03.05.2004
;0.05 fullimg, collimg ~05.05.2004
;0.06 getimg ~09.05.2004
;0.07 convbmp ~13.05.2004
;0.08 fps ~14.05.2004
;0.09 drawfbox ~03.06.2004
;0.10 all macros optimized by Halyavin A., add at ~07.06.2004
;0.11 many macros optimized by Halyavin A., add at ~30.08.2004
;0.12 bmptoimg ~07.09.2004
;0.13 imgtoimg ~08.09.2004
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
;0.15 giftoimg, giftoani ~10.09.2004
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
 
aframetoimg_use_count=0
macro aframetoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aframetoimg_use_count=aframetoimg_use_count+1
if aframetoimg_use_count = 1
 
jmp end_aframetoimg_proc
 
acolor dd 0
aframetoimg_proc:
;getout coord
mov [acolor],ebp
 
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aframetoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aframetoimg_proc
}
 
frametoimg_use_count=0
macro frametoimg img, x, y, canvas
{
local loo,loo2
frametoimg_use_count=frametoimg_use_count+1
if frametoimg_use_count = 1
 
jmp end_frametoimg_proc
 
frametoimg_proc:
;getout coord
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
 
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_frametoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call frametoimg_proc
}
 
 
aimgtoimg_use_count=0
macro aimgtoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aimgtoimg_use_count=aimgtoimg_use_count+1
if aimgtoimg_use_count = 1
 
jmp end_aimgtoimg_proc
 
acolor dd 0
aimgtoimg_proc:
;getout coord
mov [acolor],ebp
 
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
 
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aimgtoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aimgtoimg_proc
}
 
 
 
 
imgtoimg_use_count=0
macro imgtoimg img, x, y, canvas
{
local loo,loo2
imgtoimg_use_count=imgtoimg_use_count+1
if imgtoimg_use_count = 1
 
jmp end_imgtoimg_proc
imgtoimg_proc:
;getout coord
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_imgtoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call imgtoimg_proc
}
 
 
;DrawBox
macro drawfbox x,y,xs,ys,color
{
words2reg ebx,x,xs ;x*65536+xs
words2reg ecx,y,ys ;y*65536+ys
mov edx,color
mov eax,13
int 0x40
}
 
; FPS - Set Frame Per Second Display
fps_show_frequency=40
macro fps x,y,color,delcolor
{
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
local no_out_fps
jmp spdat
savetime dd 0
fps_cntr dd 0
fps dd 0
ttt dd 0
spdat:
get_time:
mov eax,3
int 0x40
cmp eax,[savetime]
jne new_time
inc [fps_cntr]
cmp dword [ttt],0
je out_fps
dec dword [ttt]
jmp no_out_fps
new_time:
mov [savetime],eax
mov ebx,[fps_cntr]
mov [fps],ebx
mov [fps_cntr],0
out_fps:
if ~(delcolor eq )
mov ebx,x*65536+36
mov ecx,y*65536+7
mov edx,delcolor
mov eax,13
int 0x40
end if
mov dword [ttt],fps_show_frequency
mov eax,47
mov ebx,6*65536
; mov bl,0
mov edx,x*65536+y
mov esi,color
mov ecx,[fps]
int 0x40
no_out_fps:
}
 
; COLLIMG - Collusion image's
_1dbounce_count=0;
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
{
local bounce,exit,anot,bc,nbc
mov esi,[img1_off] ;xs1
mov edi,[img2_off] ;ys2
mov eax,x1 ;
mov ebx,x2 ;
call _1dbounce
mov edx,ecx
mov esi,[img1_off+4] ;ys1
mov edi,[img2_off+4] ;ys2
mov eax,y1 ;
mov ebx,y2 ;
call _1dbounce
add edx,ecx
cmp edx,2
je bounce
mov otv,0
jmp exit
_1dbounce_count=_1dbounce_count+1
if _1dbounce_count = 1
_1dbounce:
cmp ebx,eax
jb anot
add eax,esi
cmp eax,ebx
jbe nbc
bc:
mov ecx,1
ret
anot:
add ebx,edi
cmp ebx,eax
ja bc
nbc:
xor ecx,ecx
ret
end if
bounce:
mov otv,1
exit:
}
 
macro rgbtobgr image
{
local loo
mov eax,[image]
mul dword [image+4]
mov ecx,eax
mov esi,image+8
; add esi,8
loo:
mov al,[esi]
mov bl,[esi+2]
mov [esi],bl
mov [esi+2],al
add esi,3
dec ecx
jnz loo
}
 
 
macro setimg x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
mov cx,[arg3]
shl ecx,16
add cx,[arg3+4]
; wordstoreg ecx,[arg3],[arg3+4]
; wordstoreg edx,x,y
words2reg edx, x , y ;arg1*65536+arg2
int 0x40
}
 
macro setframe x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
words2reg edx, x , y ;arg1*65536+arg2
add edx,dword [arg3]
mov ecx,dword [arg3+4]
int 0x40
}
 
 
macro getimg imgsrc,x,y,xs,ys,imgdest
{
local cyc
if xs eqtype 0
mov dword [imgdest],xs
else
mov eax,xs
mov dword [imgdest],eax
end if
if ys eqtype 0
mov dword [imgdest+4],ys
else
mov eax,ys
mov dword [imgdest+4],eax
end if
 
mov eax,dword [imgsrc] ;getx size
; lea ecx,[eax+2*eax]
mov ecx,eax
shl ecx,1
add ecx,eax
 
mov ebx,y
mul ebx
add eax,x
mov edx,ecx
lea eax,[eax+2*eax] ;eax=offset on imsrc
; mov ebp,eax
; shl eax,1
; add eax,ebp
 
mov ecx,xs
mov ebx,ys
 
mov edi,8+imgdest
lea esi,[eax+8+imgsrc]
; mov esi,eax
; add esi,8
; add esi,imgsrc
 
cld
cyc:
movsw
movsb
dec ecx
jne cyc
add esi,edx
mov ecx,xs
sub esi,ecx
sub esi,ecx
sub esi,ecx
dec ebx
jne cyc
}
 
macro copyimg img2_off,img1_off
{
mov eax,dword [img1_off]
mov ebx,dword [img1_off+4]
mul ebx
lea ecx,[eax+2*eax]
lea esi,[img1_off+8]
lea edi,[img2_off+8]
cld
rep movsb
}
 
macro fullimg img_off,xs,ys,color
{
local cop
mov eax,xs
mov ebx,ys
mov dword [img_off],eax
mov dword [img_off+4],ebx
mul ebx
lea ebp,[eax+2*eax]
mov esi,color
if color eqtype 0
6
else
mov ecx,esi
shr ecx,16
end if
xor edi,edi
cop:
mov word [img_off+8+edi],si
add edi,2
mov byte [img_off+8+edi],cl
inc edi
cmp edi,ebp
jne cop
}
 
 
 
; number of frame in ecx
; callculatin offset of raw data
 
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame
{
local loo,setpic
mov ebp,num_of_frame ;ecx
mov esi,offset_of_animation;Image
loo:
cmp ebp,0
je setpic
movzx eax,word [esi+4]
movzx ebx,word [esi+6]
mul ebx ;dword [esi+4]
mov ebx,3
mul ebx
add eax,8
add esi,eax
dec ebp
jmp loo
setpic:
mov dword offset_of_frame,esi
}
 
 
; BMPTOIMG -Convert BMP format TO IMG format
; (SYNTAX) BMPTOIMG BMP_source_offset,IMG_dest_ofset
; (SAMPLE) View BMPLS.ASM sample.
; ( NOTE ) This is macros is not brake bmp structure! Tested in 32,8,4 bits
 
 
bmptoimg_data_area_count=0
macro bmptoimg bmp_load_area,img_dest_area
{
local fileinfo,string,end_bmp,nodix
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
;local qwe,bmpfn
 
; convert:
movzx eax,word [bmp_load_area+28]
mul dword [bmp_load_area+18]
add eax,31
shr eax,5
mov dword [bmptoimg_data_area_dwps],eax ;dwps-doublewords per string
shl eax,2
mov dword [bmptoimg_data_area_bps],eax ;bps-bytes per string
 
cmp dword [bmp_load_area+34],0
jne yespicsize ;if picture size is defined
mul dword [bmp_load_area+22]
mov dword [bmp_load_area+34],eax
 
yespicsize:
mov ebp,img_dest_area+8
 
mov eax,bmp_load_area
mov ebx,eax
add ebx, [bmp_load_area+2];file size
inc ebx
mov dword [bmptoimg_soi],ebx ;soi-start of image area for drawing
 
add eax, [bmp_load_area+10]
mov dword [bmptoimg_data_area_sop],eax ;sop-start of picture in file
add eax, [bmp_load_area+34]
mov dword [bmptoimg_data_area_eop],eax ;eop-end of picture in file
mov eax, [bmp_load_area+18]
lea eax,[eax+2*eax] ;3x pixels in eax
 
mov edi,dword [bmptoimg_soi] ;initializing
mov esi,dword [bmptoimg_data_area_eop]
sub esi,dword [bmptoimg_data_area_bps]
 
 
nextstring:
push edi
push ebp
cmp word [bmp_load_area+28],24
jne convertno32
 
mov edi,ebp
mov ecx,[bmptoimg_data_area_dwps]
cld
rep movsd
 
convert1:
pop ebp
pop edi
sub esi,dword [bmptoimg_data_area_bps]
sub esi,dword [bmptoimg_data_area_bps]
cmp esi,dword [bmptoimg_data_area_sop]
jb end_bmp
add edi,eax
add ebp,eax
jmp nextstring
 
convertno32:
mov ebx,bmp_load_area
add ebx, [bmp_load_area+14]
add ebx,14 ;start of color table
push esi
add esi,dword [bmptoimg_data_area_bps]
mov dword [bmptoimg_data_area_eos],esi
pop esi
nextelem:
push eax
movzx eax,byte [esi]
cmp word [bmp_load_area+28],4
je convert4bpp
cmp word [bmp_load_area+28],1
je convert1bpp
call converttable
 
convert2:
pop eax
inc esi
cmp esi,dword [bmptoimg_data_area_eos]
jae convert1
add edi,3
 
add ebp,3
 
jmp nextelem
 
convert4bpp:
shl ax,4
shr al,4
push ax
movzx eax,ah
call converttable
add edi,3
 
add ebp,3
 
pop ax
movzx eax,al
call converttable
jmp convert2
 
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
push edx
call converttable
pop edx
dec edx
js convert2
add edi,3
 
add ebp,3
 
jmp nextbit
 
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
; mov dword [edi],edx
mov [ebp],edx
ret
 
bmptoimg_data_area_count=bmptoimg_data_area_count+1
if bmptoimg_data_area_count = 1
; DATA AREA
bmptoimg_soi dd 0
bmptoimg_data_area_bps dd 0
bmptoimg_data_area_dwps dd 0
bmptoimg_data_area_sop dd 0
bmptoimg_data_area_eop dd 0
bmptoimg_data_area_eos dd 0
end if
 
end_bmp:
mov eax,dword [bmp_load_area+18]
mov ebx,dword [bmp_load_area+22]
mov dword [img_dest_area],eax
mov dword [img_dest_area+4],ebx
}
 
; For convert RGB to BGR
COLOR_ORDER equ MENUETOS
 
macro giftoani gifsrc,imgsrc,num_of_frames
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null fix 0x1000 ; 0x1000
 
; jmp sss
; if defined gif_hash_offset
; else
; hasharea:
; times 4096 dd 0 ;4096
; end if
;sss:
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
push ecx
pop dword num_of_frames
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
movsd
movsd
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
cmp byte[edi],0x3b ;read next frame
jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
 
 
macro giftoimg gifsrc,imgsrc
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null fix 0x1000 ; 0x1000
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
; movsd
; movsd
 
mov bp,word[esi+4]
movzx ebx,bp
mov [edi],ebx
 
mov bp,word[esi+6]
movzx ebx,bp
mov [edi+4],ebx
 
add edi,8
add esi,8
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
; cmp byte[edi],0x3b ;read next frame
; jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/arcanii/trunk/ascl.inc
0,0 → 1,906
lang equ ru ; ru en fr ge fi
 
;
; Assembler
; SMALL
; CODE
; Libary
;
; Ver 0.14 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;Please compile aplications on FASM ver1.54 or higer!!!
 
;InfoList
;0.01 scank,putpix,puttxt
;0.02 label,random,colors
;0.03 window,startwd,endwd,attributes
;0.04 close,delay,scevent ~30.04.2004
;0.05 small random, ~04.05.2004
;0.06 wtevent ~09.05.2004
;0.07 timeevent ~23.05.2004
;0.08 txtput ~14.06.2004
;0.09 opendialog,savedialog ~20.06.2004
;0.10 wordstoreg by halyavin, add at ~30.08.2004
; random bug deleted eax is use.
;0.11 loadfile from me +puttxt bug del ~07.09.2004
;0.12 open/save dialog ~13.09.2004
;0.13 dialogs bugs deleted
;0.14 drawlbut ~03.10.2004
;0.15 extendet label!
 
; LOADFILE
; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area
; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area
 
 
macro loadfile file_name,file_load_area,file_temp_area
{
local open,fileinfo,string
jmp open
fileinfo:
dd 0
dd 0
dd 1
dd file_load_area
dd file_temp_area
string:
db file_name,0
open:
mov dword [fileinfo+8],1 ; how many blocks to read (1)
mov eax,58
mov ebx,fileinfo
int 0x40
mov eax,[file_load_area+2]
shr eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
}
 
 
;macro wordstoreg reg,hiword,loword
;{
;if hiword eqtype 0 & loword eqtype 0
; mov reg,dword hiword*65536+loword
;else if hiword eqtype 12 & loword eqtype eax
; mov reg,dword hiword*65536
; add reg,dword loword
;else if hiword eqtype 12 & loword eqtype [123]
; mov reg,dword hiword*65536
; add reg,dword loword
;else
; mov reg,dword hiword
; shl reg,16
; add reg,dword loword
;end if
;}
 
macro dword2reg reg,doubleword
{
if doubleword eq
; not changes
else
mov reg,dword doubleword
end if
}
 
macro words2reg reg,hiword,lowword
{
if hiword eq
if lowword eq
; not changes
else
if lowword eqtype 12
and reg,dword 0xffff0000
add reg,dword lowword
else
and reg,dword 0xffff0000
add reg,dword lowword
end if
end if
else
if lowword eq
if hiword eqtype 12
and reg,dword 0x0000ffff
add reg,dword hiword*65536
else
shl reg,16
add reg,dword hiword
ror reg,16
end if
else
if lowword eqtype 12 & hiword eqtype 12
if lowword eq 0 & hiword eq 0
xor reg,reg
else
mov reg,dword hiword*65536+lowword
end if
else
mov reg,dword hiword
shl reg,16
add reg,dword lowword
end if
end if
end if
}
 
 
 
 
; DRAW BUTTON with label
 
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor
{
local asd,lab
jmp asd
lab db text ;arg label
asd:
words2reg ebx,x,xs
words2reg ecx,y,ys
mov edx,id
mov esi,bcolor
mov eax,8
int 0x40
 
mov eax,asd-lab ;calc size
mov ebx,6
mul ebx
mov esi,eax
 
mov eax,xs
sub eax,esi
shr eax,1
add eax,x
 
mov edx,ys
sub edx,7
shr edx,1
add edx,y
 
mov ebx,eax
shl ebx,16
add ebx,edx
 
mov ecx,tcolor ;arg4 color
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
 
macro opendialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,150 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
mov eax,2
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
dd 0 ; My dec PID
dd 0,0 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo ; 0x10000
;run_filepath
db '/RD/1/SYSXTREE',0
 
procinfo:
times 1024 db 0
}
 
 
macro savedialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, run_filepath, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,150 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
mov eax,2
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
dd 0 ; My dec PID
dd 0,0 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo
;run_filepath:
db '/RD/1/SYSXTREE',0
 
procinfo:
times 1024 db 0
}
 
 
 
 
; RANDOM - generate random count (small)
; (SYNTAX) RANDOM MaxCount,OutArgument
; (SAMPLE) RANDOM 10000,eax
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations
 
randomuse = 0
 
macro random arg1,arg2
{
local rxproc
randomuse = randomuse + 1
 
jmp rxproc
 
if defined randomuse & randomuse = 1
randomproc:
jmp rnj
rsx1 dw 0x4321
rsx2 dw 0x1234
rnj:
; mov eax,arg1
push bx
push cx
push dx
push si
push di
mov cx,ax
mov ax,word ptr rsx1
mov bx,word ptr rsx2
mov si,ax
mov di,bx
mov dl,ah
mov ah,al
mov al,bh
mov bh,bl
xor bl,bl
rcr dl,1
rcr ax,1
rcr bx,1
add bx,di
adc ax,si
add bx,0x62e9
adc ax,0x3619
mov word ptr rsx1,bx
mov word ptr rsx2,ax
xor dx,dx
cmp ax,0
je nodiv
cmp cx,0
je nodiv
div cx
nodiv:
mov ax,dx
pop di
pop si
pop dx
pop cx
pop bx
and eax,0000ffffh
; mov arg2,0
; mov arg2,eax
ret
end if
 
rxproc:
mov eax,arg1
call randomproc
mov arg2,eax
}
 
macro scank
{
mov eax,10
int 0x40
}
 
macro putpix x,y,color
{
mov ebx,x
mov ecx,y
mov edx,color
mov eax,1
int 0x40
}
 
macro bar x,y,sizex,sizey,color
{
words2reg ebx,x,sizex
words2reg ecx,y,sizey
dword2reg edx,color
mov eax,13
int 0x40
 
}
 
macro puttxt x,y,offs,size,color
{
; mov ebx,x
; shl ebx,16
; add ebx,y
words2reg ebx,x,y
 
dword2reg ecx,color
dword2reg edx,offs
dword2reg esi,size
 
; mov ecx,color
; mov edx,offs
mov esi,size
mov eax,4
int 0x40
}
 
macro outcount data, x, y, color, numtype
{
mov ecx,data
mov ebx,numtype
mov bl,0
; mov edx,x*65536+y
words2reg edx,x,y
mov esi,color
mov eax,47
int 0x40
}
 
; SCEVENT - Scan event
 
macro scevent red,key,but
{
mov eax,11
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; WTEVENT - Wait event
 
macro wtevent red,key,but
{
mov eax,10
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; TIMEEVENT - Wite for event with timeout
 
macro timeevent xfps,noevent,red,key,but
{
mov eax,23
mov ebx,xfps
int 0x40
cmp eax,0
je noevent
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
 
; CLOSE - Close program
 
macro close
{
mov eax,-1
int 0x40
}
 
; DELAY - Create delay 1/100 sec
; (SYNTAX) Delay time
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec
 
macro delay arg1
{
mov eax,5
mov ebx,arg1
int 0x40
}
 
; WINDOW - Draw window
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned
 
macro window arg1,arg2,arg3,arg4,arg5
{
; mov ebx,arg1*65536+arg3
; mov ecx,arg2*65536+arg4
words2reg ebx,arg1,arg3
words2reg ecx,arg2,arg4
mov edx,arg5
mov eax,0
int 0x40
}
 
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
{
mov ebx,arg1*65536+arg3
mov ecx,arg2*65536+arg4
mov edx,arg5
mov esi,arg6
mov edi,arg7
mov eax,0
int 0x40
}
 
 
; STARTWD - Start of window draw
 
macro startwd
{
mov eax,12
mov ebx,1
int 0x40
}
 
; ENDWD - End window draw
 
macro endwd
{
mov eax,12
mov ebx,2
int 0x40
}
 
; LABEL - Put text to frame
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big
 
macro label arg1,arg2,arg3,arg4
{
local asd,lab
jmp asd
lab db arg3 ;arg label
asd:
; mov ebx,arg1 ;arg1=y arg2=x
; shl ebx,16
; add ebx,arg2
 
words2reg ebx,arg1,arg2
 
dword2reg ecx,arg4
 
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
;Key's
key_Up equ 178
key_Down equ 177
key_Right equ 179
key_Left equ 176
key_Esc equ 27
key_Space equ 32
key_Enter equ 13
key_Bspace equ 8
key_F1 equ 50
key_F2 equ 51
key_F3 equ 52
key_F4 equ 53
key_F5 equ 54
key_F6 equ 55
key_F7 equ 56
key_F8 equ 57
key_F9 equ 48
key_F10 equ 49
key_F11 equ 68
key_F12 equ 255
key_Home equ 180
key_End equ 181
key_PgUp equ 184
key_PgDown equ 183
 
;Attributes
 
;Window Attributes
window_Skinned equ 0x03000000
window_Type2 equ 0x02000000
window_Type1 equ 0x00000000
window_Reserve equ 0x01000000
 
;Font Attributes
font_Big equ 0x10000000
 
;Colors
cl_White equ 0x00ffffff
cl_Black equ 0x00000000
cl_Grey equ 0x00888888
cl_Red equ 0x00ff0000
cl_Lime equ 0x0000ff00
cl_Green equ 0x0000af00
cl_Blue equ 0x000000ff
cl_Purple equ 0x008080ff
cl_Violet equ 0x008040f
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/arcanii/trunk/asjc.inc
0,0 → 1,115
;-------------------------
;
; ASM JJ's 2 C macros ;-)
;
; version history:
;
; *0.01(02/08/05): if_e, if_ne, if_a, if_b
; *0.02(02/09/05): push_abc, pop_abc
; ch_sign, abs
;
; E.X.: if_e dword [x],100,.end_if
; if x = 100 do the instrucsions to .end_if:
; ==
macro if_e arg1,arg2,label
{
if arg1 eq 0 | arg2 eq 0 | arg1 eqtype 12 | arg2 eqtype 12
cmp arg1,arg2
jne label
else
push edx
mov edx,arg1
cmp edx,arg2
pop edx
jne label
end if
}
 
; !=
macro if_ne arg1,arg2,label
{
if arg1 eq 0 | arg2 eq 0 | arg1 eqtype 12 | arg2 eqtype 12
cmp arg1,arg2
je label
else
push edx
mov edx,arg1
cmp edx,arg2
pop edx
je label
end if
}
 
; >
macro if_a arg1,arg2,label
{
if arg1 eq 0 | arg2 eq 0 | arg1 eqtype 12 | arg2 eqtype 12
cmp arg1,arg2
jbe label
else
push edx
mov edx,arg1
cmp edx,arg2
pop edx
jbe label
end if
}
 
; <
macro if_b arg1,arg2,label
{
if arg1 eq 0 | arg2 eq 0 | arg1 eqtype 12 | arg2 eqtype 12
cmp arg1,arg2
jae label
else
push edx
mov edx,arg1
cmp edx,arg2
pop edx
jae label
end if
}
 
macro push_abc
{
push eax
push ebx
push ecx
push edx
push edi
push esi
}
 
macro pop_abc
{
pop esi
pop edi
pop edx
pop ecx
pop ebx
pop eax
}
 
UNDER_0 equ 0x7FFFFFFF
; changes sign e.x. ch_sign -1 = 1
macro ch_sign arg
{
push edx
mov edx,0
sub edx,arg
pop edx
}
 
; absolut e.x. abs -24 = 24
macro abs arg
{
local .end_if
if_a arg,UNDER_0,.end_if
ch_sign arg
.end_if:
}
;---------------------------------------
 
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/arcanii/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm arcanii.asm arcanii
@pause
/programs/games/arcanii/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm arcanii.asm arcanii
@pause
/programs/games/arcanoid/trunk/ARC.BMP
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/games/arcanoid/trunk/arcanoid.asm
0,0 → 1,561
;
; Arcanoid Gaem 4Ver Mini Sample by Pavlushin Evgeni for ASCL
; www.waptap@mail.ru www.cyberdeck.fatal.ru www.deck4.narod.ru
; Play again and exit button added
;
; 3Ver Play again, Exit button.
; 4Ver Next level function.
;
;******************************************************************************
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd IM_END ; size of image
dd 0x300000 ; memory for app
dd 0x300000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
;******************************************************************************
 
include 'lang.inc'
include 'ascl.inc'
include 'ascgl.inc'
include 'ascgml.inc'
 
 
START: ; start of execution
bmptoimg arc_file,pong
getimg pong,0,0,80,4,img
getimg pong,0,4,80,4,img2
getimg pong,5,38,15,15,img3
getimg pong,0,8,80,20,img5
fullimg img4 , 80 ,20 ,0x00000000 ;black for rocket
fullimg img6 , 15 ,15 ,0x00000000 ;black for ball
fullimg img7a , 60,20,0x0000cf00
fullimg img7b , 60,20,0x00af0000
fullimg img7c , 60,20,0x000000cf
fullimg img8 , 60,20,0x00000000
 
call draw_window
 
still:
 
scevent red,key,button
 
cmp [againbut],1
je stl2
 
outcount dword [scoreb],256,8,cl_Blue,5*65536
outcount dword [scorea],332,8,cl_Red,5*65536
outcount dword [level],368,8,cl_White,2*65536
 
del_images:
setimg dword [ply1x],dword [ply1y],img4
setimg dword [ballx],dword [bally],img6
setimg dword [gravx],dword [gravy],img4
 
del_blocks:
mov ecx,0
xxx:
pushad
mov esi,dword [mass+ecx]
mov edi,dword [mass+ecx+4]
mov ebp,dword [mass+ecx+8]
cmp ebp,0
jne notptx
setimg esi,edi,img8
notptx:
popad
add ecx,12
cmp ecx,[blocks_max]
jne xxx
 
 
 
move_ply1:
 
correct [ply1x],[ply1rx],2
correct [ply1y],[ply1ry],2
 
;automove ball
mov eax,dword [ballxv]
add dword [ballx],eax
mov eax,dword [ballyv]
add dword [bally],eax
 
;autoslow ball for rocket gravitation (Space key)
cmp dword [ballxv],0
jl ballb
balla:
cmp dword [ballxv],2
jng balln
dec dword [ballxv]
jmp balln
ballb:
cmp dword [ballxv],-2
jnl balln
inc dword [ballxv]
jmp balln
balln:
cmp dword [ballyv],2
jng by_n
dec dword [ballyv]
by_n:
 
;ball collusion of screen
cmp dword [ballx],400-12
jna xa_ok
neg dword [ballxv]
xa_ok:
cmp dword [ballx],6
jnb xb_ok
neg dword [ballxv]
xb_ok:
 
cmp dword [bally],30
jnb yb_ok
neg dword [ballyv]
yb_ok:
 
 
;if ball far out of screen come back
cmp dword [bally],466
jng yax_ok
call draw_window
dec dword [scoreb]
mov eax,[ply1ry]
sub eax,6
mov dword [bally],eax ;240
mov eax,[ply1rx]
add eax,30
mov dword [ballx],eax ;200
mov dword [ballyv],2
random 3,dword [ballxv]
sub dword [ballxv],1
yax_ok:
 
xorx:
cmp dword [ballxv],0
jne norx
random 3,dword [ballxv]
sub dword [ballxv],1
cmp dword [ballxv],0
je xorx
norx:
 
;test on collusion ply1 of ball
collusion_test:
collimg img,[ply1x],[ply1y],img3,[ballx],[bally],eax
cmp eax,1
jne not_coll
neg dword [ballyv]
sub dword [bally],4
; neg dword [ballxv]
not_coll:
 
;test on collusion gravity of ball
collusion_grav:
collimg img,[gravx],[gravy],img3,[ballx],[bally],eax
cmp eax,1
jne not_collg
sub dword [bally],30
neg dword [ballyv]
cmp dword [ballyv],0
jl ab
jg bf
jmp not_collgx
ab:
sub dword [ballyv],10
jmp not_collgx
bf:
add dword [ballyv],10
not_collgx:
cmp dword [ballxv],0
jl abx
jg bfx
jmp not_collg
abx:
sub dword [ballxv],0 ;8 ;15
jmp not_collg
bfx:
add dword [ballxv],0 ;8
 
 
; mov dword [ballyv],20
not_collg:
 
;ply contorl
control 12,316,[ply1rx]
control 380,470,[ply1ry]
 
;garvity
gravity:
cmp dword [gravtime],0
je no_dg
dec dword [gravtime]
no_dg:
 
draw_gravity:
cmp dword [gravtime],0
je nograv
mov eax,dword [ply1x]
mov ebx,dword [ply1y]
sub ebx,30
mov dword [gravx],eax
mov dword [gravy],ebx
jmp endgrav
nograv:
mov dword [gravx],1000
mov dword [gravy],1000
endgrav:
 
redraw_images:
setimg dword [ply1x],dword [ply1y],img2
setimg dword [ballx],dword [bally],img3
setimg dword [gravx],dword [gravy],img5
 
draw_blocks:
mov ecx,0
xxx2:
pushad
mov esi,dword [mass+ecx]
mov edi,dword [mass+ecx+4]
mov ebp,dword [mass+ecx+8]
cmp ebp,0
je notpt
cmp ebp,1
jne no_a
setimg esi,edi,img7a
jmp notpt
no_a:
cmp ebp,2
jne no_b
setimg esi,edi,img7b
jmp notpt
no_b:
cmp ebp,3
jne no_c
setimg esi,edi,img7c
jmp notpt
no_c:
 
notpt:
popad
add ecx,12
cmp ecx,[blocks_max]
jne xxx2
 
;collusion ball of blocks
coll_blocks:
mov [temp3],0
mov ecx,0
testloop:
pushad
mov ebp,dword [mass+ecx+8]
cmp ebp,0
jne testcol
jmp notest
testcol:
mov [temp3],1
mov esi,dword [mass+ecx]
mov edi,dword [mass+ecx+4]
mov [temp1],esi
mov [temp2],edi
push ecx
collimg img8,[temp1],[temp2],img3,[ballx],[bally],eax
pop ecx
cmp eax,1
jne notest
mov dword [mass+ecx+8],0
; neg [ballxv]
neg [ballyv]
add [scorea],30
call draw_window
jmp end_col
notest:
popad
add ecx,12
cmp ecx,[blocks_max]
jne testloop
end_col:
 
cmp [delay_cnt],0
jne no_delay
mov [delay_cnt],1
delay 1 ;don't generate delay for fast speed programm
no_delay:
dec [delay_cnt]
 
win_test:
cmp [temp3],1
je stl
; inc [level]
mov [nextlev],1
mov [againbut],1
call draw_window
; label 160,200,'You Win!',cl_Green+font_Big
; label 130,220,'Youre Score:',cl_Green+font_Big
; outcount dword [scorea],230,220,cl_Green,5*65536
; label 130,234,'Youre Lives:',cl_Green+font_Big
; outcount dword [scoreb],230,234,cl_Green,5*65536
; delay 600 ;wait 2sec
; close ;exit from program
stl:
 
lose_test:
cmp [scoreb],0
jne stl2
; call draw_window
; label 160,200,'You Lose!',cl_Red+font_Big
; label 130,220,'Youre Score:',cl_Red+font_Big
; outcount dword [scorea],230,220,cl_Red,5*65536
; delay 300 ;wait 2sec
; close ;exit from program
; mov ebx,10*65536+40
; mov ebx,10*65536+20
; mov edx,2
; mov esi,0x0000ff00
; mov eax,8
; int 0x40
mov [level],0
mov [nextlev],0
mov [againbut],1
call draw_window
 
stl2:
 
jmp still
 
red:
call draw_window
jmp still
 
key: ; key
mov eax,2
int 0x40
cmp ah,key_Left
jne no_l
sub dword [ply1rx],50 ;24 ;16
no_l:
cmp ah,key_Right
jne no_r
add dword [ply1rx],50 ;24 ;16
no_r:
cmp ah,key_Up
jne no_u
sub dword [ply1ry],20
no_u:
cmp ah,key_Down
jne no_d
add dword [ply1ry],20
no_d:
cmp ah,key_Space
jne no_sp
mov dword [gravtime],100
no_sp:
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne noclose
mov eax,-1 ; close this program
int 0x40
noclose:
cmp ah,2
jne noplayagain
mov [xt],100
mov [yt],100
mov [gravtime],10
mov [gravx],1000
mov [gravy],1000
mov [ply1rx],160
mov [ply1ry],460
mov [ply1x],160
mov [ply1y],400
mov [ballx],200
mov [bally],300
mov [ballyv],2
mov [ballxv],1
 
cmp [nextlev],1
je noch
mov [scorex],0
mov [scorea],0
mov [scoreb],3
jmp noch2
noch:
inc [scoreb]
inc [level]
mov eax,[maxlev]
cmp [level],eax
jna noch2
mov [level],eax
noch2:
 
mov eax,18*4*5
mul [level]
mov ebp,eax
add ebp,levels
mov ecx,18*4*5 ;bytes
loo:
mov eax,dword [ebp+ecx]
mov dword [mass+ecx],eax
sub ecx,4
jnz loo
 
mov [againbut],0
 
call draw_window
noplayagain:
jmp still
 
 
draw_window:
startwd
window 0,0,400+8,480+24,window_Skinned
label 12,8,'ARCANOID: USE ARROW KEYS LIVES SCORE',cl_White+font_Big
 
cmp [againbut],0
je no_againbut
 
cmp [nextlev],1
je nlev
label 160,200,'You Lose!',cl_Red+font_Big
label 130,220,'Youre Score:',cl_Red+font_Big
outcount dword [scorea],230,220,cl_Red,5*65536
mov ebx,150*65536+80
mov ecx,240*65536+12
mov edx,2
mov esi,0x0000aa00
mov eax,8
int 0x40
mov ecx,260*65536+12
mov edx,1
int 0x40
label 152,244,'Play again?',cl_Red+font_Big
jmp elev
nlev:
label 160,200,'You Win!',cl_Green+font_Big
label 130,220,'Youre Score:',cl_Green+font_Big
outcount dword [scorea],230,220,cl_Green,5*65536
mov ebx,150*65536+80
mov ecx,240*65536+12
mov edx,2
mov esi,0x0000aa00
mov eax,8
int 0x40
mov ecx,260*65536+12
mov edx,1
int 0x40
label 152,244,'Next level?',cl_Red+font_Big
elev:
 
label 178,264,'Exit?',cl_Red+font_Big
no_againbut:
 
endwd
ret
 
 
; DATA AREA
againbut dd 0
 
xt dd 100
yt dd 100
 
gravtime dd 10
gravx dd 1000
gravy dd 1000
 
ply1rx dd 160
ply1ry dd 460
 
ply1x dd 160
ply1y dd 400
 
ballx dd 200
bally dd 300
 
ballyv dd 2
ballxv dd 1
 
temp1 dd 0
temp2 dd 0
temp3 dd 0
 
scorex dd 0
scorea dd 0
scoreb dd 3
 
level dd 0
nextlev dd 0
maxlev dd 2
 
counter dd 0
tsoi dd 0
 
delay_cnt dd 0
 
blocks_max dd 6*5*12 ;size in bytes 5*3 dd
 
mass:
dd 30,200,0 ,90,200,0 ,150,200,0 ,210,200,0 ,270,200,0 ,330,200,0
dd 30,180,0 ,90,180,0 ,150,180,0 ,210,180,0 ,270,180,0 ,330,180,0
dd 30,160,0 ,90,160,0 ,150,160,0 ,210,160,0 ,270,160,0 ,330,160,0
dd 30,140,0 ,90,140,1 ,150,140,1 ,210,140,1 ,270,140,0 ,330,140,0
dd 30,120,0 ,90,120,0 ,150,120,0 ,210,120,0 ,270,120,0 ,330,120,0
 
levels:
dd 30,200,0 ,90,200,0 ,150,200,0 ,210,200,2 ,270,200,0 ,330,200,0
dd 30,180,2 ,90,180,1 ,150,180,1 ,210,180,2 ,270,180,2 ,330,180,0
dd 30,160,1 ,90,160,3 ,150,160,1 ,210,160,2 ,270,160,2 ,330,160,2
dd 30,140,2 ,90,140,1 ,150,140,1 ,210,140,2 ,270,140,2 ,330,140,0
dd 30,120,0 ,90,120,0 ,150,120,0 ,210,120,2 ,270,120,0 ,330,120,0
;level2
dd 30,200,0 ,90,200,3 ,150,200,0 ,210,200,2 ,270,200,2 ,330,200,2
dd 30,180,0 ,90,180,1 ,150,180,0 ,210,180,2 ,270,180,2 ,330,180,2
dd 30,160,0 ,90,160,3 ,150,160,0 ,210,160,2 ,270,160,2 ,330,160,2
dd 30,140,0 ,90,140,1 ,150,140,0 ,210,140,2 ,270,140,2 ,330,140,2
dd 30,120,0 ,90,120,3 ,150,120,0 ,210,120,2 ,270,120,2 ,330,120,2
;level3
dd 30,200,1 ,90,200,3 ,150,200,1 ,210,200,2 ,270,200,2 ,330,200,2
dd 30,180,2 ,90,180,1 ,150,180,1 ,210,180,2 ,270,180,2 ,330,180,2
dd 30,160,1 ,90,160,3 ,150,160,1 ,210,160,2 ,270,160,2 ,330,160,2
dd 30,140,2 ,90,140,1 ,150,140,1 ,210,140,2 ,270,140,2 ,330,140,2
dd 30,120,1 ,90,120,3 ,150,120,1 ,210,120,2 ,270,120,2 ,330,120,2
 
arc_file:
file 'arc.bmp'
 
rb 20000
 
IM_END:
 
pong:
rb 80*60*3+8
img:
rb 32*32*3+8
img2:
rb 32*32*3+8
img3:
rb 32*32*3+8
img4:
rb 80*20*3+8
img5:
rb 80*20*3+8
img6:
rb 15*15*3+8
img7a:
rb 60*20*3+8
img7b:
rb 60*20*3+8
img7c:
rb 60*20*3+8
img8:
rb 60*40*3+8
 
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/arcanoid/trunk/ascgl.inc
0,0 → 1,1385
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Graphics
; Libary
;
; Ver 0.18 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 LoadImage
;0.02 SetBmp
;0.03 Bmptoimg, Setimg ~01.03.2004
;0.04 Bug deleted, copyimg ~03.05.2004
;0.05 fullimg, collimg ~05.05.2004
;0.06 getimg ~09.05.2004
;0.07 convbmp ~13.05.2004
;0.08 fps ~14.05.2004
;0.09 drawfbox ~03.06.2004
;0.10 all macros optimized by halyavin, add at ~07.06.2004
;0.11 many macros optimized by halyavin, add at ~30.08.2004
;0.12 bmptoimg ~07.09.2004
;0.13 imgtoimg ~08.09.2004
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
;0.15 giftoimg, giftoani ~10.09.2004
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
 
aframetoimg_use_count=0
macro aframetoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aframetoimg_use_count=aframetoimg_use_count+1
if aframetoimg_use_count = 1
 
jmp end_aframetoimg_proc
 
acolor dd 0
aframetoimg_proc:
;getout coord
mov [acolor],ebp
 
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aframetoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aframetoimg_proc
}
 
frametoimg_use_count=0
macro frametoimg img, x, y, canvas
{
local loo,loo2
frametoimg_use_count=frametoimg_use_count+1
if frametoimg_use_count = 1
 
jmp end_frametoimg_proc
 
frametoimg_proc:
;getout coord
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
 
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_frametoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call frametoimg_proc
}
 
 
aimgtoimg_use_count=0
macro aimgtoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aimgtoimg_use_count=aimgtoimg_use_count+1
if aimgtoimg_use_count = 1
 
jmp end_aimgtoimg_proc
 
acolor dd 0
aimgtoimg_proc:
;getout coord
mov [acolor],ebp
 
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
 
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aimgtoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aimgtoimg_proc
}
 
 
 
 
imgtoimg_use_count=0
macro imgtoimg img, x, y, canvas
{
local loo,loo2
imgtoimg_use_count=imgtoimg_use_count+1
if imgtoimg_use_count = 1
 
jmp end_imgtoimg_proc
imgtoimg_proc:
;getout coord
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_imgtoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call imgtoimg_proc
}
 
 
;DrawBox
macro drawfbox x,y,xs,ys,color
{
wordstoreg ebx,x,xs ;x*65536+xs
wordstoreg ecx,y,ys ;y*65536+ys
mov edx,color
mov eax,13
int 0x40
}
 
; FPS - Set Frame Per Second Display
fps_show_frequency=40
macro fps x,y,color,delcolor
{
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
local no_out_fps
jmp spdat
savetime dd 0
fps_cntr dd 0
fps dd 0
ttt dd 0
spdat:
get_time:
mov eax,3
int 0x40
cmp eax,[savetime]
jne new_time
inc [fps_cntr]
cmp dword [ttt],0
je out_fps
dec dword [ttt]
jmp no_out_fps
new_time:
mov [savetime],eax
mov ebx,[fps_cntr]
mov [fps],ebx
mov [fps_cntr],0
out_fps:
if ~(delcolor eq )
mov ebx,x*65536+30
mov ecx,y*65536+7
mov edx,delcolor
mov eax,13
int 0x40
end if
mov dword [ttt],fps_show_frequency
mov eax,47
mov ebx,5*65536
; mov bl,0
mov edx,x*65536+y
mov esi,color
mov ecx,[fps]
int 0x40
no_out_fps:
}
 
; COLLIMG - Collusion image's
_1dbounce_count=0;
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
{
local bounce,exit,anot,bc,nbc
mov esi,[img1_off] ;xs1
mov edi,[img2_off] ;ys2
mov eax,x1 ;
mov ebx,x2 ;
call _1dbounce
mov edx,ecx
mov esi,[img1_off+4] ;ys1
mov edi,[img2_off+4] ;ys2
mov eax,y1 ;
mov ebx,y2 ;
call _1dbounce
add edx,ecx
cmp edx,2
je bounce
mov otv,0
jmp exit
_1dbounce_count=_1dbounce_count+1
if _1dbounce_count = 1
_1dbounce:
cmp ebx,eax
jb anot
add eax,esi
cmp eax,ebx
jbe nbc
bc:
mov ecx,1
ret
anot:
add ebx,edi
cmp ebx,eax
ja bc
nbc:
xor ecx,ecx
ret
end if
bounce:
mov otv,1
exit:
}
 
macro rgbtobgr image
{
local loo
mov eax,[image]
mul dword [image+4]
mov ecx,eax
mov esi,image+8
; add esi,8
loo:
mov al,[esi]
mov bl,[esi+2]
mov [esi],bl
mov [esi+2],al
add esi,3
dec ecx
jnz loo
}
 
 
macro setimg x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
mov cx,[arg3]
shl ecx,16
add cx,[arg3+4]
; wordstoreg ecx,[arg3],[arg3+4]
wordstoreg edx, x , y ;arg1*65536+arg2
int 0x40
}
 
macro setframe x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
wordstoreg edx, x , y ;arg1*65536+arg2
add edx,dword [arg3]
mov ecx,dword [arg3+4]
int 0x40
}
 
 
macro getimg imgsrc,x,y,xs,ys,imgdest
{
local cyc
if xs eqtype 0
mov dword [imgdest],xs
else
mov eax,xs
mov dword [imgdest],eax
end if
if ys eqtype 0
mov dword [imgdest+4],ys
else
mov eax,ys
mov dword [imgdest+4],eax
end if
 
mov eax,dword [imgsrc] ;getx size
; lea ecx,[eax+2*eax]
mov ecx,eax
shl ecx,1
add ecx,eax
 
mov ebx,y
mul ebx
add eax,x
mov edx,ecx
lea eax,[eax+2*eax] ;eax=offset on imsrc
; mov ebp,eax
; shl eax,1
; add eax,ebp
 
mov ecx,xs
mov ebx,ys
 
mov edi,8+imgdest
lea esi,[eax+8+imgsrc]
; mov esi,eax
; add esi,8
; add esi,imgsrc
 
cld
cyc:
movsw
movsb
dec ecx
jne cyc
add esi,edx
mov ecx,xs
sub esi,ecx
sub esi,ecx
sub esi,ecx
dec ebx
jne cyc
}
 
macro copyimg img2_off,img1_off
{
mov eax,dword [img1_off]
mov ebx,dword [img1_off+4]
mul ebx
lea ecx,[eax+2*eax]
lea esi,[img1_off+8]
lea edi,[img2_off+8]
cld
rep movsb
}
 
macro fullimg img_off,xs,ys,color
{
local cop
mov eax,xs
mov ebx,ys
mov dword [img_off],eax
mov dword [img_off+4],ebx
mul ebx
lea ebp,[eax+2*eax]
mov esi,color
if color eqtype 0
mov ecx,color/65536
else
mov ecx,esi
shr ecx,16
end if
xor edi,edi
cop:
mov word [img_off+8+edi],si
add edi,2
mov byte [img_off+8+edi],cl
inc edi
cmp edi,ebp
jne cop
}
 
 
 
; number of frame in ecx
; callculatin offset of raw data
 
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame
{
local loo,setpic
mov ebp,num_of_frame ;ecx
mov esi,offset_of_animation;Image
loo:
cmp ebp,0
je setpic
movzx eax,word [esi+4]
movzx ebx,word [esi+6]
mul ebx ;dword [esi+4]
mov ebx,3
mul ebx
add eax,8
add esi,eax
dec ebp
jmp loo
setpic:
mov dword offset_of_frame,esi
}
 
 
; BMPTOIMG -Convert BMP format TO IMG format
; (SYNTAX) BMPTOIMG BMP_source_offset,IMG_dest_ofset
; (SAMPLE) View BMPLS.ASM sample.
; ( NOTE ) This is macros is not brake bmp structure! Tested in 32,8,4 bits
 
 
bmptoimg_data_area_count=0
macro bmptoimg bmp_load_area,img_dest_area
{
local fileinfo,string,end_bmp,nodix
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
;local qwe,bmpfn
 
; convert:
movzx eax,word [bmp_load_area+28]
mul dword [bmp_load_area+18]
add eax,31
shr eax,5
mov dword [bmptoimg_data_area_dwps],eax ;dwps-doublewords per string
shl eax,2
mov dword [bmptoimg_data_area_bps],eax ;bps-bytes per string
 
cmp dword [bmp_load_area+34],0
jne yespicsize ;if picture size is defined
mul dword [bmp_load_area+22]
mov dword [bmp_load_area+34],eax
 
yespicsize:
mov ebp,img_dest_area+8
 
mov eax,bmp_load_area
mov ebx,eax
add ebx, [bmp_load_area+2];file size
inc ebx
mov dword [bmptoimg_soi],ebx ;soi-start of image area for drawing
 
add eax, [bmp_load_area+10]
mov dword [bmptoimg_data_area_sop],eax ;sop-start of picture in file
add eax, [bmp_load_area+34]
mov dword [bmptoimg_data_area_eop],eax ;eop-end of picture in file
mov eax, [bmp_load_area+18]
lea eax,[eax+2*eax] ;3x pixels in eax
 
mov edi,dword [bmptoimg_soi] ;initializing
mov esi,dword [bmptoimg_data_area_eop]
sub esi,dword [bmptoimg_data_area_bps]
 
 
nextstring:
push edi
push ebp
cmp word [bmp_load_area+28],24
jne convertno32
 
mov edi,ebp
mov ecx,[bmptoimg_data_area_dwps]
cld
rep movsd
 
convert1:
pop ebp
pop edi
sub esi,dword [bmptoimg_data_area_bps]
sub esi,dword [bmptoimg_data_area_bps]
cmp esi,dword [bmptoimg_data_area_sop]
jb end_bmp
add edi,eax
add ebp,eax
jmp nextstring
 
convertno32:
mov ebx,bmp_load_area
add ebx, [bmp_load_area+14]
add ebx,14 ;start of color table
push esi
add esi,dword [bmptoimg_data_area_bps]
mov dword [bmptoimg_data_area_eos],esi
pop esi
nextelem:
push eax
movzx eax,byte [esi]
cmp word [bmp_load_area+28],4
je convert4bpp
cmp word [bmp_load_area+28],1
je convert1bpp
call converttable
 
convert2:
pop eax
inc esi
cmp esi,dword [bmptoimg_data_area_eos]
jae convert1
add edi,3
 
add ebp,3
 
jmp nextelem
 
convert4bpp:
shl ax,4
shr al,4
push ax
movzx eax,ah
call converttable
add edi,3
 
add ebp,3
 
pop ax
movzx eax,al
call converttable
jmp convert2
 
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
push edx
call converttable
pop edx
dec edx
js convert2
add edi,3
 
add ebp,3
 
jmp nextbit
 
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
; mov dword [edi],edx
mov [ebp],edx
ret
 
bmptoimg_data_area_count=bmptoimg_data_area_count+1
if bmptoimg_data_area_count = 1
; DATA AREA
bmptoimg_soi dd 0
bmptoimg_data_area_bps dd 0
bmptoimg_data_area_dwps dd 0
bmptoimg_data_area_sop dd 0
bmptoimg_data_area_eop dd 0
bmptoimg_data_area_eos dd 0
end if
 
end_bmp:
mov eax,dword [bmp_load_area+18]
mov ebx,dword [bmp_load_area+22]
mov dword [img_dest_area],eax
mov dword [img_dest_area+4],ebx
}
 
; For convert RGB to BGR
COLOR_ORDER equ MENUETOS
 
macro giftoani gifsrc,imgsrc,num_of_frames
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null fix 0x1000 ; 0x1000
 
; jmp sss
; if defined gif_hash_offset
; else
; hasharea:
; times 4096 dd 0 ;4096
; end if
;sss:
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
push ecx
pop dword num_of_frames
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
movsd
movsd
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
cmp byte[edi],0x3b ;read next frame
jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
 
 
macro giftoimg gifsrc,imgsrc
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null fix 0x1000 ; 0x1000
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
; movsd
; movsd
 
mov bp,word[esi+4]
movzx ebx,bp
mov [edi],ebx
 
mov bp,word[esi+6]
movzx ebx,bp
mov [edi+4],ebx
 
add edi,8
add esi,8
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
; cmp byte[edi],0x3b ;read next frame
; jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/arcanoid/trunk/ascgml.inc
0,0 → 1,49
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; GaMe
; Libary
;
; Ver 0.03 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 correct
;0.02 control ~14.05.2004
;0.03 all macros optimized by halyavin, add at ~07.06.2004
 
 
; corectiryemoe,corectnoe,step
macro correct arg1,arg2,arg3
{
local plus,minus,equal
mov eax,arg2
cmp arg1,eax
je equal
mov eax,arg3
ja minus
plus:
add arg1,eax
jmp equal
minus:
sub arg1,eax
equal:
}
 
macro control min,max,arg
{
local gr,low,norm
mov eax,max
cmp arg,eax
jg gr
mov eax,min
cmp arg,eax
jnl norm
gr:
low:
mov arg,eax
norm:
}
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/arcanoid/trunk/ascl.inc
0,0 → 1,835
lang equ ru ; ru en fr ge fi
 
;
; Assembler
; SMALL
; CODE
; Libary
;
; Ver 0.14 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;Please compile aplications on FASM ver1.54 or higer!!!
 
;InfoList
;0.01 scank,putpix,puttxt
;0.02 label,random,colors
;0.03 window,startwd,endwd,attributes
;0.04 close,delay,scevent ~30.04.2004
;0.05 small random, ~04.05.2004
;0.06 wtevent ~09.05.2004
;0.07 timeevent ~23.05.2004
;0.08 txtput ~14.06.2004
;0.09 opendialog,savedialog ~20.06.2004
;0.10 wordstoreg by halyavin, add at ~30.08.2004
; random bug deleted eax is use.
;0.11 loadfile from me +puttxt bug del ~07.09.2004
;0.12 open/save dialog ~13.09.2004
;0.13 dialogs bugs deleted
;0.14 drawlbut ~03.10.2004
 
; LOADFILE
; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area
; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area
 
macro loadfile file_name,file_load_area,file_temp_area
{
local open,fileinfo,string
jmp open
fileinfo:
dd 0
dd 0
dd 1
dd file_load_area
dd file_temp_area
string:
db file_name,0
open:
mov dword [fileinfo+8],1 ; how many blocks to read (1)
mov eax,58
mov ebx,fileinfo
int 0x40
mov eax,[file_load_area+2]
shr eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
}
 
 
macro wordstoreg reg,hiword,loword
{
if hiword eqtype 0 & loword eqtype 0
mov reg,hiword*65536+loword
else if hiword eqtype 12 & loword eqtype eax
mov reg,hiword*65536
add reg,loword
else if hiword eqtype 12 & loword eqtype [123]
mov reg,hiword*65536
add reg,loword
else
mov reg,hiword
shl reg,16
add reg,loword
end if
}
 
 
; DRAW BUTTON with label
 
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor
{
local asd,lab
jmp asd
lab db text ;arg label
asd:
wordstoreg ebx,x,xs
wordstoreg ecx,y,ys
mov edx,id
mov esi,bcolor
mov eax,8
int 0x40
 
mov eax,asd-lab ;calc size
mov ebx,6
mul ebx
mov esi,eax
 
mov eax,xs
sub eax,esi
shr eax,1
add eax,x
 
mov edx,ys
sub edx,7
shr edx,1
add edx,y
 
mov ebx,eax
shl ebx,16
add ebx,edx
 
mov ecx,tcolor ;arg4 color
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
 
macro opendialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,150 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
mov eax,2
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
dd 0 ; My dec PID
dd 0,0 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo ; 0x10000
;run_filepath
db '/RD/1/SYSXTREE',0
 
procinfo:
times 256 db 0
}
 
 
macro savedialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, run_filepath, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,120 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
rb 4 ; My dec PID
rb 6 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo
run_filepath:
db '/RD/1/SYSXTREE',0
 
procinfo:
times 256 db 0
}
 
 
 
 
; RANDOM - generate random count (small)
; (SYNTAX) RANDOM MaxCount,OutArgument
; (SAMPLE) RANDOM 10000,eax
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations
 
randomuse = 0
 
macro random arg1,arg2
{
local rxproc
randomuse = randomuse + 1
 
jmp rxproc
 
if defined randomuse & randomuse = 1
randomproc:
jmp rnj
rsx1 dw 0x4321
rsx2 dw 0x1234
rnj:
; mov eax,arg1
push bx
push cx
push dx
push si
push di
mov cx,ax
mov ax,word ptr rsx1
mov bx,word ptr rsx2
mov si,ax
mov di,bx
mov dl,ah
mov ah,al
mov al,bh
mov bh,bl
xor bl,bl
rcr dl,1
rcr ax,1
rcr bx,1
add bx,di
adc ax,si
add bx,0x62e9
adc ax,0x3619
mov word ptr rsx1,bx
mov word ptr rsx2,ax
xor dx,dx
cmp ax,0
je nodiv
cmp cx,0
je nodiv
div cx
nodiv:
mov ax,dx
pop di
pop si
pop dx
pop cx
pop bx
and eax,0000ffffh
; mov arg2,0
; mov arg2,eax
ret
end if
 
rxproc:
mov eax,arg1
call randomproc
mov arg2,eax
}
 
macro scank
{
mov eax,10
int 0x40
}
 
macro putpix x,y,color
{
mov ebx,x
mov ecx,y
mov edx,color
mov eax,1
int 0x40
}
 
macro puttxt x,y,offs,size,color
{
; mov ebx,x
; shl ebx,16
; add ebx,y
wordstoreg ebx,x,y
mov ecx,color
mov edx,offs
mov esi,size
mov eax,4
int 0x40
}
 
macro outcount data, x, y, color, numtype
{
mov ecx,data
mov ebx,numtype
mov bl,0
; mov edx,x*65536+y
wordstoreg edx,x,y
mov esi,color
mov eax,47
int 0x40
}
 
; SCEVENT - Scan event
 
macro scevent red,key,but
{
mov eax,11
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; WTEVENT - Wait event
 
macro wtevent red,key,but
{
mov eax,10
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; TIMEEVENT - Wite for event with timeout
 
macro timeevent xfps,noevent,red,key,but
{
mov eax,23
mov ebx,xfps
int 0x40
cmp eax,0
je noevent
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
 
; CLOSE - Close program
 
macro close
{
mov eax,-1
int 0x40
}
 
; DELAY - Create delay 1/100 sec
; (SYNTAX) Delay time
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec
 
macro delay arg1
{
mov eax,5
mov ebx,arg1
int 0x40
}
 
; WINDOW - Draw window
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned
 
macro window arg1,arg2,arg3,arg4,arg5
{
; mov ebx,arg1*65536+arg3
; mov ecx,arg2*65536+arg4
wordstoreg ebx,arg1,arg3
wordstoreg ecx,arg2,arg4
mov edx,arg5
mov eax,0
int 0x40
}
 
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
{
mov ebx,arg1*65536+arg3
mov ecx,arg2*65536+arg4
mov edx,arg5
mov esi,arg6
mov edi,arg7
mov eax,0
int 0x40
}
 
 
; STARTWD - Start of window draw
 
macro startwd
{
mov eax,12
mov ebx,1
int 0x40
}
 
; ENDWD - End window draw
 
macro endwd
{
mov eax,12
mov ebx,2
int 0x40
}
 
; LABEL - Put text to frame
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big
 
macro label arg1,arg2,arg3,arg4
{
local asd,lab
jmp asd
lab db arg3 ;arg label
asd:
; mov ebx,arg1 ;arg1=y arg2=x
; shl ebx,16
; add ebx,arg2
wordstoreg ebx,arg1,arg2
mov ecx,arg4 ;arg4 color
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
;Key's
key_Up equ 178
key_Down equ 177
key_Right equ 179
key_Left equ 176
key_Esc equ 27
key_Space equ 32
key_Enter equ 13
key_Bspace equ 8
key_F1 equ 50
key_F2 equ 51
key_F3 equ 52
key_F4 equ 53
key_F5 equ 54
key_F6 equ 55
key_F7 equ 56
key_F8 equ 57
key_F9 equ 48
key_F10 equ 49
key_F11 equ 68
key_F12 equ 255
key_Home equ 180
key_End equ 181
key_PgUp equ 184
key_PgDown equ 183
 
;Attributes
 
;Window Attributes
window_Skinned equ 0x03000000
window_Type2 equ 0x02000000
window_Type1 equ 0x00000000
window_Reserve equ 0x01000000
 
;Font Attributes
font_Big equ 0x10000000
 
;Colors
cl_White equ 0x00ffffff
cl_Black equ 0x00000000
cl_Grey equ 0x00888888
cl_Red equ 0x00ff0000
cl_Lime equ 0x0000ff00
cl_Green equ 0x0000af00
cl_Blue equ 0x000000ff
cl_Purple equ 0x008080ff
cl_Violet equ 0x008040ff
cl_Cyan equ 0x0040e0ff
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/arcanoid/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm arcanoid.asm arcanoid
@pause
/programs/games/arcanoid/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm arcanoid.asm arcanoid
@pause
/programs/games/c4/trunk/Readme.txt
0,0 → 1,27
C4 0.1
Copyright (C) 2002 Thomas Mathys
killer@vantage.ch
 
 
What's this ?
-------------
 
C4 is a connect four clone for MenuetOS
(http://www.menuetos.org).
 
 
Installation
------------
 
Simply copy the executable (C4) onto your MenuetOS floppy.
You don't need to copy anything else, the image files are
linked into the executable.
 
If you want to compile C4 yourself you need NASM.
Get it from http://nasm.sourceforge.net.
 
Compile C4 using the following command:
 
nasm -f bin -o c4 c4.asm
(nasmw if you have the win32 version)
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/c4/trunk/ai.inc
0,0 → 1,270
; C4
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This file is part of C4.
;
; C4 is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; C4 is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with C4; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
%ifndef _AI_INC
%define _AI_INC
 
 
INFTY equ 1000000000
 
 
 
section .data
 
; table used to perform some primitive move "ordering":
; middle columns which are usually more important are
; searched first.
moveorder dd 1,7,2,6,3,5,4
 
; table used for static evaluation.
; this table is taken from 4st attack: it is ways better
; than the table i used before =)
evaltable: dd 0, 0, 0, 0, 0, 0, 0, 0, 0
dd 0, 3, 4, 5, 7, 5, 4, 3, 0
dd 0, 4, 6, 8,10, 8, 6, 4, 0
dd 0, 5, 8,12,13,12, 8, 5, 0
dd 0, 5, 8,12,13,12, 8, 5, 0
dd 0, 4, 6, 8,10, 8, 6, 4, 0
dd 0, 3, 4, 5, 7, 5, 4, 3, 0
dd 0, 0, 0, 0, 0, 0, 0, 0, 0
 
 
 
section .bss
 
cpulevel resd 1 ; level of current cpu player
bestval resd 1 ; value of best move found so far
nbestmoves resd 1 ; # of best moves found so far
bestmoves resd 7 ; array to hold all best moves
 
 
 
section .text
 
 
 
;**********************************************************
; aiGetMove
; returns a move for a computer player
;
; input : eax = cpu level ( >= 1)
; output : eax = move
; destroys : everything
;**********************************************************
aiGetMove:
 
; initialize variables
mov [cpulevel],eax
mov dword [bestval],-INFTY
mov dword [nbestmoves],0
; try every move
mov ecx,6
.evalmoves:
 
; get move to make from move order table
mov eax,[moveorder+ecx*4]
; if this is an invalid move, continue with next move
BOARDISVALIDMOVE eax
jz .nextmove
 
; make move for current player
mov ebx,[currentplayer]
call boardMakeMove
; evaluate move
push eax ; save move #
push ecx ; save loop counter
push dword [cpulevel] ; ply
mov ebx,[currentplayer] ; player
BOARDGETOTHERPLAYER ebx
push ebx
push dword -INFTY ; alpha
push dword INFTY ; beta
call alphabeta
neg eax ; damn, how could i forget this ???
mov ebx,eax ; save result for later
pop ecx ; restore loop counter
pop eax ; restore move #
; undo move (eax = move #)
call boardUndoMove
; let's see wether we have a new best move
cmp ebx,[bestval] ; new best value found ?
jle .nonewbestval
mov [bestval],ebx ; yes -> save it
mov dword [nbestmoves],1 ; delete everything that was in the list
mov [bestmoves+0],eax ; save move number in list
jmp short .nextmove ; continue with next move
.nonewbestval:
cmp ebx,[bestval] ; another best value found ?
jne .nextmove
mov ebx,[nbestmoves] ; yes -> add move to list
mov [bestmoves+ebx*4],eax
inc dword [nbestmoves]
 
.nextmove:
dec ecx
js .done
jmp .evalmoves
.done:
; randomly pick one of the best moves
call rand ; rand() % nbestmoves
xor edx,edx
div dword [nbestmoves]
mov eax,[bestmoves+edx*4] ; get move from list
ret
 
; test code : pick first move from list
mov eax,[bestmoves+0]
ret
 
 
 
;**********************************************************
; alphabeta
;
; input : see below
; output : eax = move value
; destroys : everything
;**********************************************************
alphabeta:
 
%define ply (ebp+20)
%define player (ebp+16)
%define alpha (ebp+12)
%define beta (ebp+ 8)
 
enter 0,0
; win for other player -> end search
mov eax,[player]
BOARDGETOTHERPLAYER eax
call boardIsWin
or eax,eax
jz .nowin
mov eax,-1000000
mov ebx,[ply]
shl ebx,10
sub eax,ebx
leave
ret 4*4
.nowin:
; board full but no win -> draw -> end search
BOARDISFULL
jnz .notfull
xor eax,eax
leave
ret 4*4
.notfull
; max search depth reached -> do static evaluation
cmp dword [ply],0
je .staticeval
 
; for each move
mov ecx,6
.evalmoves:
 
; while (alpha < beta)
mov eax,[alpha]
cmp eax,[beta]
jge .done
 
; pick move from move order table
mov eax,[moveorder+ecx*4]
; invalid move ? if so, continue with next move
BOARDISVALIDMOVE eax
jz .nextmove
; make move for current player
mov ebx,[player]
call boardMakeMove
; evaluate move
push eax
push ecx
mov eax,[ply] ; ply = ply-1
dec eax
push eax
mov ebx,[player] ; player = other player
BOARDGETOTHERPLAYER ebx
push ebx
mov ecx,[beta] ; alpha = -beta
neg ecx
push ecx
mov edx,[alpha] ; beta = -alpha
neg edx
push edx
call alphabeta
neg eax
; new alpha ?
cmp eax,[alpha]
jle .nonewalpha
mov [alpha],eax ; yes -> save it
.nonewalpha:
pop ecx
pop eax
; undo move
call boardUndoMove
 
.nextmove: ; evaluate next move
dec ecx
jns .evalmoves
.done:
mov eax,[alpha]
leave
ret 4*4
; static evaluation
.staticeval:
xor eax,eax
mov esi,BWIDTH*BHEIGHT-1
.l:
mov ebx,[board+esi*4] ; get stone from board
cmp ebx,[player] ; player's stone ?
jne .notplayer ; nope -> go on
add eax,[evaltable+esi*4] ; yes -> add stone value to eax
jmp .next ; next stone
.notplayer:
cmp ebx,EMPTY ; other player's stone ?
je .empty ; nope -> go on
sub eax,[evaltable+esi*4] ; yes -> sub stone value from eax
.empty:
.next: ; next stone
dec esi
jns .l
leave ; eax contains static value
ret 4*4
 
%undef ply
%undef player
%undef alpha
%undef beta
 
%endif
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/c4/trunk/blue.pcx
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/games/c4/trunk/board.inc
0,0 → 1,318
; C4
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This file is part of C4.
;
; C4 is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; C4 is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with C4; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
%ifndef _BOARD_INC
%define _BOARD_INC
 
 
;**********************************************************
; magic numbers
;**********************************************************
 
EMPTY equ 0
PLAYER1 equ 1
PLAYER2 equ 2
 
; board dimensions (+2 for border)
BWIDTH equ 9
BHEIGHT equ 8
 
 
 
;**********************************************************
; uninitialized data
;**********************************************************
 
section .bss
board resd BHEIGHT*BWIDTH ; the board
free resd BWIDTH ; # of free fields for each column
totalfree resd 1 ; total # of free fields
currentplayer resd 1 ; player to make next move
lastmove resd 1 ; last move done on the board
; (0 if no last move available)
 
 
 
;**********************************************************
; code
;**********************************************************
section .text
 
;**********************************************************
; boardReset
; reset board for new game
;
; input : nothing
; output : nothing
; destroys : nothing
;**********************************************************
boardReset:
pushfd
pushad
; clear all fields
mov edi,board
mov ecx,BHEIGHT * BWIDTH
mov eax,EMPTY
rep stosd
; init free array
mov edi,free
mov ecx,BWIDTH
mov eax,BHEIGHT - 2
rep stosd
mov dword [totalfree],(BWIDTH-2)*(BHEIGHT-2)
mov dword [currentplayer],PLAYER1
mov dword [lastmove],0
popad
popfd
ret
 
 
 
;**********************************************************
; BOARDISVALIDMOVE
; checks wether a move is valid
;
; input : 32 bit register containing a move
; number (1..7)
; output : zero flag set -> move is invalid
; zero flag clear -> move is valid
; destroys : nothing
;**********************************************************
%macro BOARDISVALIDMOVE 1
cmp dword [free+%1*4],0
%endmacro
 
 
 
;**********************************************************
; boardMakeMove
; make a move
;
; input : eax = move number (1..7)
; ebx = PLAYER1/PLAYER2
; output : nothing
; destroys : edi, flags
;**********************************************************
 
boardMakeMove:
mov edi,[free+eax*4] ; place stone
imul edi,BWIDTH
add edi,eax
mov [board+edi*4],ebx
dec dword [free+eax*4] ; one stone more in this column
dec dword [totalfree] ; one stone more on the board
mov [lastmove],eax ; store move for undo
ret
 
 
 
;**********************************************************
; boardUndoMove
; undo a move
;
; input : eax = move number to undo (1..7)
; output : move is undone
; destroys : edi, flags
;**********************************************************
boardUndoMove:
inc dword [free+eax*4] ; one stone less in this column
inc dword [totalfree] ; one stone less on the board
mov dword [lastmove],0 ; no last move available
mov edi,[free+eax*4] ; remove stone from board
imul edi,BWIDTH
add edi,eax
mov dword [board+edi*4],EMPTY
ret
 
 
 
;**********************************************************
; BOARDSWITCHPLAYERS
; switch current player
;
; input : nothing
; output : current player is switched
; destroys : flags
;**********************************************************
%macro BOARDSWITCHPLAYERS 0
xor dword [currentplayer],(PLAYER1 ^ PLAYER2)
%endmacro
 
 
 
;**********************************************************
; BOARDGETOTHERPLAYER
; get other player =)
;
; input : 32 bit register or variable
; output : player changed
; destroys : flags
;**********************************************************
%macro BOARDGETOTHERPLAYER 1
xor %1,(PLAYER1 ^ PLAYER2)
%endmacro
 
 
 
;**********************************************************
; BOARDISFULL
; check wether board is full
;
; input : nothing
; output : zero flag set -> board is full
; zero flag clear -> board isn't full
;**********************************************************
%macro BOARDISFULL 0
cmp dword [totalfree],0
%endmacro
 
 
 
;**********************************************************
; boardIsWin
; check wether the current board state is a win for the
; given player
;
; input : eax = player
; output : eax = nonzero -> win for player
; destroys : everything
;**********************************************************
 
boardIsWin:
 
; check wether last move is available
cmp dword [lastmove],0
jne .lastmoveok
xor eax,eax
ret
.lastmoveok:
 
; calculate the address of the most recently placed stone (edi)
mov edi,[lastmove]
mov esi,[free + edi*4]
inc esi
imul esi,BWIDTH
add edi,esi
shl edi,2
add edi,board
; check vertically
xor ecx,ecx ; reset counter
mov esi,edi ; start at last stone
.vertical:
cmp [esi],eax ; loop as long the stone [esi] belongs to player
jne .verticalend
add esi,BWIDTH*4 ; move to next stone
inc ecx ; one stone more in row
jmp short .vertical
.verticalend:
cmp ecx,4 ; 4 or more stones ?
jl .nope1 ; nope -> continue
mov eax,1 ; yeah -> tell caller =)
ret
.nope1:
 
; check horizontally
xor ecx,ecx
mov esi,edi
.horizontal1: ; left
cmp [esi],eax
jne .horizontalend1
sub esi,4
inc ecx
jmp short .horizontal1
.horizontalend1:
lea esi,[edi+4] ; right
.horizontal2:
cmp [esi],eax
jne .horizontalend2
add esi,4
inc ecx
jmp short .horizontal2
.horizontalend2:
cmp ecx,4
jl .nope2
mov eax,1
ret
.nope2:
 
; diagonally forward
xor ecx,ecx
mov esi,edi
.forward1:
cmp [esi],eax
jne .forwardend1
sub esi,(1+BWIDTH)*4
inc ecx
jmp short .forward1
.forwardend1:
lea esi,[edi+(1+BWIDTH)*4]
.forward2:
cmp [esi],eax
jne .forwardend2
add esi,(1+BWIDTH)*4
inc ecx
jmp short .forward2
.forwardend2:
cmp ecx,4
jl .nope3
mov eax,1
ret
.nope3:
 
; diagonally backward
xor ecx,ecx
mov esi,edi
.backward1:
cmp [esi],eax
jne .backwardend1
add esi,(1-BWIDTH)*4
inc ecx
jmp short .backward1
.backwardend1:
lea esi,[edi+(BWIDTH-1)*4]
.backward2:
cmp [esi],eax
jne .backwardend2
add esi,(BWIDTH-1)*4
inc ecx
jmp short .backward2
.backwardend2:
cmp ecx,4
jl .nope4
mov eax,1
ret
.nope4:
 
; no win for this player
xor eax,eax
ret
 
 
%endif
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/c4/trunk/c4.asm
0,0 → 1,910
; C4
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This file is part of C4.
;
; C4 is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; C4 is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with C4; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
bits 32
%include 'mos.inc'
section .text
 
MOS_HEADER01 start,end
 
 
 
;**********************************************************
; magic numbers
;**********************************************************
 
; initial player types
PL1TYPE_INIT equ 0
PL2TYPE_INIT equ 4
 
; window
WND_WIDTH equ 259
WND_HEIGHT equ 300
WND_WORKCOLOR equ 0
 
; button dimensions
BUTTON_HEIGHT equ 12
 
BUTTON_NEW_X equ 14
BUTTON_NEW_Y equ 30
BUTTON_NEW_WIDTH equ 56
 
BUTTON_SPIN_WIDTH equ 8
BUTTON_PL1DN_X equ 228
BUTTON_PL1DN_Y equ 30
BUTTON_PL1UP_X equ (BUTTON_PL1DN_X + BUTTON_SPIN_WIDTH + 1)
BUTTON_PL1UP_Y equ BUTTON_PL1DN_Y
 
BUTTON_PL2DN_X equ BUTTON_PL1DN_X
BUTTON_PL2DN_Y equ (BUTTON_PL1DN_Y + 20)
BUTTON_PL2UP_X equ (BUTTON_PL2DN_X + BUTTON_SPIN_WIDTH + 1)
BUTTON_PL2UP_Y equ BUTTON_PL2DN_Y
 
; label dimensions
LABEL_PL1_X equ 90
LABEL_PL1_Y equ (1 + BUTTON_PL1DN_Y + (BUTTON_HEIGHT-8)/2)
LABEL_PL2_X equ LABEL_PL1_X
LABEL_PL2_Y equ (1 + BUTTON_PL2DN_Y + (BUTTON_HEIGHT-8)/2)
LABEL_PL1TYPE_X equ (LABEL_PL1_X + 10*6)
LABEL_PL1TYPE_Y equ LABEL_PL1_Y
LABEL_PL2TYPE_X equ LABEL_PL1TYPE_X
LABEL_PL2TYPE_Y equ LABEL_PL2_Y
LABEL_STATUS_X equ 14
LABEL_STATUS_Y equ 279
LABEL_STATUS_WIDTH equ 220
LABEL_STATUS_HEIGHT equ 8
 
 
 
; board and stones
STONESIZE equ 32 ; stone height and width
GRIDX equ 14 ; upper left corner
GRIDY equ 70
GRIDSPACING equ (STONESIZE + 1) ; space between lines
GRIDHEIGHT equ (6*GRIDSPACING+1) ; total grid width and height
GRIDWIDTH equ (7*GRIDSPACING+1)
GRIDCOLOR equ MOS_RGB(128,128,128)
 
 
 
; button id's
BT_QUIT equ 1
BT_NEW equ 2
BT_PLAYER1DN equ 3
BT_PLAYER1UP equ 4
BT_PLAYER2DN equ 5
BT_PLAYER2UP equ 6
 
 
start:
jmp main
 
%include "pcx.inc"
%include "windows.inc"
%include "board.inc"
%include "rng.inc"
; %include "randomai.inc"
%include "ai.inc"
 
 
 
;**********************************************************
; main program
;**********************************************************
main:
call randomize
call defineWindow
call decrunchImages
call newGame
 
.msgpump:
; wait for event
mov ebx,1
mov eax,MOS_SC_WAITEVENTTIMEOUT
int 0x40
 
; process events
cmp eax,MOS_EVT_REDRAW
je short .redraw
cmp eax,MOS_EVT_KEY
je short .key
cmp eax,MOS_EVT_BUTTON
je short .button
 
call pollMouse
call gameLoop
jmp short .msgpump
 
.redraw:
call defineWindow
jmp short .msgpump
.key:
call keyboardInput
jmp short .msgpump
.button:
call handleButton
jmp short .msgpump
 
 
 
;**********************************************************
; button handling function
;**********************************************************
handleButton:
mov eax,MOS_SC_GETPRESSEDBUTTON ; get button id
int 0x40
 
cmp al,1 ; button pressed ?
je short .bye ; nope -> nothing to do
 
cmp ah,BT_QUIT ; which button has been pressed ?
je short .quit
cmp ah,BT_NEW
je short .new
cmp ah,BT_PLAYER1DN
je short .player1dn
cmp ah,BT_PLAYER1UP
je short .player1up
cmp ah,BT_PLAYER2DN
je short .player2dn
cmp ah,BT_PLAYER2UP
je short .player2up
.bye:
ret
.quit:
MOS_EXIT
.new:
call newGame
ret
.player1dn:
mov eax,[player1_type] ; get current type
or eax,eax ; already zero ?
jz .bla
dec eax ; nope -> decrement
mov [player1_type],eax ; write back
mov edi,label_pl1type ; and update label
call updatePlayerType
.bla:
ret
.player1up:
mov eax,[player1_type] ; get current type
cmp eax,NPLAYERTYPES-1 ; already max ?
je .bla2
inc eax ; nope -> increment
mov [player1_type],eax ; write back
mov edi,label_pl1type ; update label
call updatePlayerType
.bla2:
ret
.player2dn:
mov eax,[player2_type] ; get current type
or eax,eax ; already zero ?
jz .bla3
dec eax ; nope -> decrement
mov [player2_type],eax ; write back
mov edi,label_pl2type ; and update label
call updatePlayerType
.bla3:
ret
.player2up:
mov eax,[player2_type]
cmp eax,NPLAYERTYPES-1
je .bla4
inc eax
mov [player2_type],eax
mov edi,label_pl2type
call updatePlayerType
.bla4:
ret
 
 
 
;**********************************************************
; window definition function
;**********************************************************
defineWindow:
MOS_STARTREDRAW
 
mov edi,window
call drawWindow
 
mov edi,buttons
mov ecx,NBUTTONS
call drawButtons
 
mov edi,labels
mov ecx,NLABELS
call drawLabels
 
xor eax,eax
call drawBoard
MOS_ENDREDRAW
ret
 
 
 
;**********************************************************
; updateStatusText
;
; input : esi = ptr to new string
; output : status bar is updated
; destroys : everything
;**********************************************************
updateStatusText:
 
; different text ?
cmp [statusbar + LABEL.caption],esi
je .bye ; nope -> bye
mov dword [statusbar + LABEL.caption],esi ; yeah -> save & redraw
 
; clear background
mov ebx,MOS_DWORD(LABEL_STATUS_X,LABEL_STATUS_WIDTH)
mov ecx,MOS_DWORD(LABEL_STATUS_Y,LABEL_STATUS_HEIGHT)
xor edx,edx
mov eax,MOS_SC_DRAWBAR
int 0x40
; redraw label
mov edi,statusbar
mov ecx,1
call drawLabels
.bye:
ret
 
 
 
;**********************************************************
; updatePlayerType
; update player type label
; input: eax = new type
; edi = address label structure to update
;**********************************************************
updatePlayerType:
mov ebx,PLAYERTYPELEN ; calculate type string address
mul ebx
add eax,playertypes
mov [edi + LABEL.caption],eax ; write address
mov ecx,1 ; and redraw label
call drawLabels
ret
 
 
 
;**********************************************************
; board drawing stuff
;**********************************************************
 
; drawBoard
; draw whole board
;
; input : eax nonzero = clear board background
drawBoard:
 
; clear background ?
or eax,eax
jz .noclear
mov ebx,MOS_DWORD(GRIDX,GRIDWIDTH)
mov ecx,MOS_DWORD(GRIDY,GRIDHEIGHT)
mov edx,WND_WORKCOLOR
mov eax,MOS_SC_DRAWBAR
int 0x40
.noclear:
call drawGrid
call drawStones
ret
 
 
 
drawGrid:
; vertical lines
mov ebx,MOS_DWORD(GRIDX,GRIDX)
mov ecx,MOS_DWORD(GRIDY,GRIDY+GRIDHEIGHT-1)
mov edx,GRIDCOLOR
mov eax,MOS_SC_DRAWLINE
mov esi,8
.vlines:
int 0x40
add ebx,MOS_DWORD(GRIDSPACING,GRIDSPACING)
dec esi
jnz .vlines
; horizontal lines
mov ebx,MOS_DWORD(GRIDX,GRIDX+GRIDWIDTH-1)
mov ecx,MOS_DWORD(GRIDY,GRIDY)
mov esi,7
.hlines:
int 0x40
add ecx,MOS_DWORD(GRIDSPACING,GRIDSPACING)
dec esi
jnz .hlines
ret
drawStones:
mov ebx,6
.col:
mov ecx,7
.row:
call drawStone
loop .row
dec ebx
jnz .col
ret
 
 
; ecx = column (1..7)
; ebx = row (1..6)
drawStone:
pushad
 
; see which image to draw.
; the image offset is stored in ebp
mov eax,BWIDTH ; calculate address
mul ebx
add eax,ecx
mov eax,[board+eax*4] ; get stone ?
cmp eax,EMPTY ; empty field -> nothing to do
je .bye
mov ebp,redstone ; assume red stone
cmp eax,PLAYER1 ; red ?
je .stoneok ; yeah -> continue
mov ebp,bluestone ; nope -> use blue stone
.stoneok:
 
; calculate image position (edx)
mov eax,GRIDSPACING
dec ecx
mul ecx
add eax,GRIDX + 1
shl eax,16
mov ecx,eax
mov eax,GRIDSPACING
dec ebx
mul ebx
add eax,GRIDY + 1
mov cx,ax
mov edx,ecx
 
; put image (position is already in edx)
mov ebx,ebp ; image address
mov ecx,MOS_DWORD(STONESIZE,STONESIZE) ; image dimensions
mov eax,MOS_SC_PUTIMAGE
int 0x40
 
.bye:
popad
ret
 
 
 
decrunchImages:
mov esi,redpcx ; red stone
mov edi,redstone
mov ebx,REDPCXSIZE
call loadPCX
mov esi,bluepcx ; blue stone
mov edi,bluestone
mov ebx,BLUEPCXSIZE
call loadPCX
ret
 
 
 
resetInput:
mov dword [playerinput],0 ; no player input
mov dword [mouseinput],0
ret
 
 
 
;**********************************************************
; newGame
; set up everything for a game
;
; input : nothing
; output : nothing
; destroys : everything
;**********************************************************
newGame:
call boardReset ; reset and redraw board
mov eax,1
call drawBoard
call resetInput ; reset input
mov dword [gameover],0 ; game is running
ret
 
 
 
;**********************************************************
; pollMouse
; mouse polling routine
;
; input : nothing
; output : playerinput will be updated, if
; the player clicked on a valid
; field
; destroys : everything
;**********************************************************
pollMouse:
mov ebx,2
mov eax,MOS_SC_GETMOUSEPOSITION
int 0x40
and eax,1
jz .mousenotpressed
.mousepressed:
mov dword [mouseinput],0
call isActiveApp
or al,al
jz .notactive1
call getMouseCol
mov [mouseinput],eax
.notactive1:
ret
.mousenotpressed:
call isActiveApp
or al,al
jz .notactive2
call getMouseCol
cmp eax,[mouseinput]
jne .nonewinput
cmp dword [playerinput],0
jne .nonewinput
mov [playerinput],eax
.nonewinput:
.notactive2:
mov dword [mouseinput],0
ret
 
 
 
;**********************************************************
; getMouseCol
; calculate in which column the mouse is. or so.
;
; input : nothing
; output : eax = 0 -> mouse outside board
; eax = 1..7 -> column
; destroys : everything
;**********************************************************
getMouseCol:
 
mov ebx,1 ; get mouse position, window relative
mov eax,MOS_SC_GETMOUSEPOSITION
int 0x40
 
movzx ebx,ax ; y clipping
cmp ebx,GRIDY
jl .outside
cmp ebx,GRIDY + GRIDHEIGHT - 1
jg .outside
 
shr eax,16 ; calculate column from x coordinate
sub eax,GRIDX
js .outside ; negative -> outside of board (left)
cdq ; !
mov ebx,GRIDSPACING
div ebx
cmp eax,BWIDTH-3 ; right outside of board ?
jg .outside ; yes -> bye
inc eax ; xform into range [1,7]
ret
.outside
xor eax,eax
ret
 
 
 
;**********************************************************
; isActiveApp
; check wether we're the active application
;
; input : nothing
; output : al nonzero -> we are the active app
; destroys : everything
;**********************************************************
isActiveApp:
 
%define PROCINFO (ebp-MOS_PROCESSINFO_size)
 
enter MOS_PROCESSINFO_size,0
; get process information
mov eax,MOS_SC_GETPROCESSINFO
lea ebx,[ebp-MOS_PROCESSINFO_size]
mov ecx,-1
int 0x40
 
; set al to 1 if we are the active application
cmp ax,[PROCINFO+MOS_PROCESSINFO.windowStackPos]
sete al
leave
ret
%undef PROCINFO
 
 
 
;**********************************************************
; keyboardInput
; keyboard input handler, called from main loop
;
; input : nothing
; output : playerinput is updated
; destroys : everything
;**********************************************************
keyboardInput:
mov eax,MOS_SC_GETKEY ; get key
int 0x40
or al,al ; key available ?
jnz .bye ; no -> bye
cmp dword [playerinput],0 ; unprocessed input available ?
jne .bye ; yes -> bye
 
sub ah,'1' ; valid key ?
cmp ah,BWIDTH-3
ja .bye ; treat as unsigned : keys below '1' will
; be greater too =)
 
mov al,ah ; save input
and eax,255
inc eax
mov [playerinput],eax
 
.bye:
ret
 
 
 
;**********************************************************
; gameLoop
; game logic code or however you wish to call it.
; actually this is not a loop, but is called from
; the main loop
;**********************************************************
gameLoop:
 
; if the game is over, return
cmp dword [gameover],0
je .gamerunning
ret
.gamerunning:
 
call updatePlayerStatusText
 
; get move
call getMoveForCurrentPlayer
or eax,eax
jnz .moveok
ret ; no move available -> bye
.moveok:
 
; make move and update board graphics
mov ebx,[currentplayer] ; ebx = current player, eax contains already move
call boardMakeMove
call drawStones
 
; check wether game is over (either by a win or because the board is full)
mov eax,[currentplayer] ; win for current player ?
call boardIsWin
or eax,eax
jz .nowin ; no -> continue
mov esi,player1wins ; yes -> display message...
cmp dword [currentplayer],PLAYER1
je .blubb
mov esi,player2wins
.blubb:
call updateStatusText
mov dword [gameover],1 ; ...and end game
ret
.nowin:
BOARDISFULL ; board full, but no win ?
jnz .notfull ; no -> continue
mov esi,itisadraw ; yes -> display message...
call updateStatusText
mov dword [gameover],1 ; ...and end game
ret
.notfull:
 
; switch players and return to main loop
BOARDSWITCHPLAYERS
ret
 
 
 
;**********************************************************
; getMoveForCurrentPlayer
; returns the move made by the current player
; (either cpu or human)
;
; input : nothing
; output : eax = 0 -> no move made. this is
; usually the case for human players,
; when no valid input is available.
; else eax = move number
;**********************************************************
getMoveForCurrentPlayer:
 
; get type of current player
mov eax,[player1_type]
cmp dword [currentplayer],PLAYER1
je .ok
mov eax,[player2_type]
.ok:
 
; get move for human/cpu player
or eax,eax
jnz .cpu
.human:
mov eax,[playerinput] ; get input
or eax,eax ; input available ?
jz .nomove ; no -> return no move available
call resetInput ; !
BOARDISVALIDMOVE eax ; valid move `?
jz .nomove ; no -> return no move available
ret ; valid move available -> return it (eax)
 
.cpu:
call dword [aicode] ; call ai machine. cpu level is already in eax
ret
.nomove:
xor eax,eax
ret
 
 
 
;**********************************************************
; update status bar : which player's turn it is
;**********************************************************
updatePlayerStatusText:
cmp dword [currentplayer],PLAYER2
je .player2
mov esi,player1hmnprmpt
cmp dword [player1_type],0
je .statustextok
mov esi,player1cpuprmpt
jmp short .statustextok
.player2:
mov esi,player2hmnprmpt
cmp dword [player2_type],0
je .statustextok
mov esi,player2cpuprmpt
.statustextok:
call updateStatusText
ret
 
 
 
;**********************************************************
; initialized data
;**********************************************************
 
section .data
 
;
; window definition
;
windowtitle db "C4 0.1",0
window:
istruc WND
at WND.xposandsize, dd MOS_DWORD(0,WND_WIDTH)
at WND.yposandsize, dd MOS_DWORD(0,WND_HEIGHT)
at WND.workcolor, dd 0x03000000 | WND_WORKCOLOR
at WND.grabcolor, dd 0
at WND.framecolor, dd 0
at WND.caption, dd windowtitle
at WND.captioncolor, dd 0
at WND.flags, dd WND_CENTER | WND_DEFAULT_GRABCOLOR | WND_DEFAULT_FRAMECOLOR | WND_DEFAULT_CAPTIONCOLOR
iend
 
;
; button table
;
buttons:
istruc BUTTON ; new
at BUTTON.xposandsize
dd MOS_DWORD(BUTTON_NEW_X,BUTTON_NEW_WIDTH)
dd MOS_DWORD(BUTTON_NEW_Y,BUTTON_HEIGHT)
dd BT_NEW
dd BUTTON_COLOR_WORK
iend
istruc BUTTON ; player 1 down
at BUTTON.xposandsize
dd MOS_DWORD(BUTTON_PL1DN_X,BUTTON_SPIN_WIDTH)
dd MOS_DWORD(BUTTON_PL1DN_Y,BUTTON_HEIGHT)
dd BT_PLAYER1DN
dd BUTTON_COLOR_WORK
iend
istruc BUTTON ; player 1 up
at BUTTON.xposandsize
dd MOS_DWORD(BUTTON_PL1UP_X,BUTTON_SPIN_WIDTH)
dd MOS_DWORD(BUTTON_PL1UP_Y,BUTTON_HEIGHT)
dd BT_PLAYER1UP
dd BUTTON_COLOR_WORK
iend
istruc BUTTON ; player 2 down
at BUTTON.xposandsize
dd MOS_DWORD(BUTTON_PL2DN_X,BUTTON_SPIN_WIDTH)
dd MOS_DWORD(BUTTON_PL2DN_Y,BUTTON_HEIGHT)
dd BT_PLAYER2DN
dd BUTTON_COLOR_WORK
iend
istruc BUTTON ; player 2 up
at BUTTON.xposandsize
dd MOS_DWORD(BUTTON_PL2UP_X,BUTTON_SPIN_WIDTH)
dd MOS_DWORD(BUTTON_PL2UP_Y,BUTTON_HEIGHT)
dd BT_PLAYER2UP
dd BUTTON_COLOR_WORK
iend
NBUTTONS equ (($-buttons)/BUTTON_size)
 
 
;
; label table
;
 
newgame db "New game",0
down db "<",0
up db ">",0
pl1 db "Player 1:",0
pl2 db "Player 2:",0
 
 
playertypes:
db "Human ",0
PLAYERTYPELEN equ ($ - playertypes)
db "CPU level 1 ",0
db "CPU level 2 ",0
db "CPU level 3 ",0
db "CPU level 4 ",0
db "CPU level 5 ",0
db "CPU level 6 ",0
db "CPU level 7 ",0
db "CPU level 8 ",0
NPLAYERTYPES equ (($-playertypes)/PLAYERTYPELEN)
 
labels:
istruc LABEL ; new
at LABEL.position
dd MOS_DWORD(BUTTON_NEW_X+4,1+BUTTON_NEW_Y+(BUTTON_HEIGHT-8)/2)
dd newgame
dd LABEL_COLOR_WORKBUTTON
dd LABEL_BGCOLOR_TRANSPARENT
iend
istruc LABEL ; player 1 down
at LABEL.position
dd MOS_DWORD(BUTTON_PL1DN_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL1DN_Y+(BUTTON_HEIGHT-8)/2)
dd down
dd LABEL_COLOR_WORKBUTTON
dd LABEL_BGCOLOR_TRANSPARENT
iend
istruc LABEL ; player 1 up
at LABEL.position
dd MOS_DWORD(1+BUTTON_PL1UP_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL1UP_Y+(BUTTON_HEIGHT-8)/2)
dd up
dd LABEL_COLOR_WORKBUTTON
dd LABEL_BGCOLOR_TRANSPARENT
iend
istruc LABEL ; player 2 down
at LABEL.position
dd MOS_DWORD(BUTTON_PL2DN_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL2DN_Y+(BUTTON_HEIGHT-8)/2)
dd down
dd LABEL_COLOR_WORKBUTTON
dd LABEL_BGCOLOR_TRANSPARENT
iend
istruc LABEL ; player 2 up
at LABEL.position
dd MOS_DWORD(1+BUTTON_PL2UP_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL2UP_Y+(BUTTON_HEIGHT-8)/2)
dd up
dd LABEL_COLOR_WORKBUTTON
dd LABEL_BGCOLOR_TRANSPARENT
iend
istruc LABEL ; player 1
at LABEL.position
dd MOS_DWORD(LABEL_PL1_X,LABEL_PL1_Y)
dd pl1
dd MOS_RGB(255,255,255)
dd LABEL_BGCOLOR_TRANSPARENT
iend
istruc LABEL ; player 2
at LABEL.position
dd MOS_DWORD(LABEL_PL2_X,LABEL_PL2_Y)
dd pl2
dd MOS_RGB(255,255,255)
dd LABEL_BGCOLOR_TRANSPARENT
iend
statusbar: ; status bar
istruc LABEL
at LABEL.position
dd MOS_DWORD(LABEL_STATUS_X,LABEL_STATUS_Y)
dd 0
dd MOS_RGB(255,255,255)
dd LABEL_BGCOLOR_TRANSPARENT
iend
label_pl1type:
istruc LABEL
at LABEL.position
dd MOS_DWORD(LABEL_PL1TYPE_X,LABEL_PL1TYPE_Y)
dd playertypes+PL1TYPE_INIT*PLAYERTYPELEN
dd MOS_RGB(255,255,255)
dd MOS_RGB(0,0,0)
iend
label_pl2type:
istruc LABEL
at LABEL.position
dd MOS_DWORD(LABEL_PL2TYPE_X,LABEL_PL2TYPE_Y)
dd playertypes+PL2TYPE_INIT*PLAYERTYPELEN
dd MOS_RGB(255,255,255)
dd MOS_RGB(0,0,0)
iend
NLABELS equ (($-labels)/LABEL_size)
 
 
; player types
player1_type dd PL1TYPE_INIT
player2_type dd PL2TYPE_INIT
 
 
; status messages
player1hmnprmpt db "Make your move, player 1.",0
player2hmnprmpt db "Make your move, player 2.",0
player1cpuprmpt db "Player 1 is thinking, please wait...",0
player2cpuprmpt db "Player 2 is thinking, please wait...",0
itisadraw db "It's a draw.",0
player1wins db "Player 1 wins.",0
player2wins db "Player 2 wins.",0
 
 
; pointer to ai player. future releases C4 might
; or might not support different ai players =)
aicode dd aiGetMove
 
 
; button images
redpcx: incbin "red.pcx"
REDPCXSIZE equ ($ - redpcx)
bluepcx: incbin "blue.pcx"
BLUEPCXSIZE equ ($ - bluepcx)
 
 
 
;**********************************************************
; uninitialized data
;**********************************************************
 
section .bss
 
; player input
; 0 : no input available
; 1..7 : column to drop stone into
playerinput resd 1
 
mouseinput resd 1
gameover resd 1
 
redstone resb STONESIZE*STONESIZE*3
bluestone resb STONESIZE*STONESIZE*3
 
end:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/c4/trunk/mos.inc
0,0 → 1,305
; mos.inc 0.0.2
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
;
;
; revision history
; ----------------
;
; 10-04-2002 version 0.0.2
; - removed MOS_WNDCOLORS_SIZE and similar constants.
; while reading the docs i realized that NASM creates
; such symbols already itself...
; + macros: MOS_WAITEVENT, MOS_WAITEVENT_S, MOS_STARTREDRAW,
; MOS_STARTREDRAW_S, MOS_ENDREDRAW, MOS_ENDREDRAW_S,
; MOS_GETSCREENMAX, MOS_GETSCREENMAX_S, MOS_EXIT, MOS_EXIT_S
; + event bit masks
; + some syscall numbers
; + process info structure
;
; 08-??-2002 version 0.0.1
; first release
;
%ifndef _MOS_INC
%define _MOS_INC
 
 
 
;**********************************************************
; generates a menuetos 01 header
; takes 2-6 parameters:
;
; MOS_HEADER01 start,end[,appmem,esp,i_param,i_icon]
;**********************************************************
 
%macro MOS_HEADER01 2-6 0x100000,0x7fff0,0,0
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd %1 ; start of code
dd %2 ; image size
dd %3 ; application memory
dd %4 ; esp
dd %5 ; i_param
dd %6 ; i_icon
%endmacro
 
 
;**********************************************************
; MOS_DWORD
; packs 2 words into a double word
;**********************************************************
 
%define MOS_DWORD(hi,lo) ((((hi) & 0xffff) << 16) + ((lo) & 0xffff))
 
 
;**********************************************************
; MOS_RGB
; creates a menuet os compatible color (0x00RRGGBB)
;**********************************************************
 
%define MOS_RGB(r,g,b) ((((r) & 255) << 16) + (((g) & 255) << 8) + ((b) & 255))
 
 
;**********************************************************
; window color structure
;**********************************************************
 
struc MOS_WNDCOLORS
.frame: resd 1
.grab: resd 1
.grabButton: resd 1
.grabButtonText: resd 1
.grabText: resd 1
.work: resd 1
.workButton: resd 1
.workButtonText: resd 1
.workText: resd 1
.workGraphics: resd 1
endstruc
 
 
;**********************************************************
; process info structure
;**********************************************************
 
struc MOS_PROCESSINFO
.CPUUsage: resd 1 ; cpu usage
.windowStackPos: resw 1 ; process' position in windowing stack
.windowStackVal: resw 1 ; window stack value at ecx
.reserved1: resw 1
.processName: resb 12 ; process name
.memStart: resd 1 ; start of process memory
.memUsed: resd 1 ; memory used by the process
.pid: resd 1 ; process id
.reserved2: resb (1024-34)
endstruc
 
 
 
;**********************************************************
; system call numbers
;**********************************************************
 
MOS_SC_EXIT equ -1
MOS_SC_DEFINEWINDOW equ 0
MOS_SC_PUTPIXEL equ 1
MOS_SC_GETKEY equ 2
MOS_SC_GETSYSCLOCK equ 3
MOS_SC_WRITETEXT equ 4
MOS_SC_DELAY equ 5
MOS_SC_OPENFILEFLOPPY equ 6
MOS_SC_PUTIMAGE equ 7
MOS_SC_DEFINEBUTTON equ 8
MOS_SC_GETPROCESSINFO equ 9
MOS_SC_WAITEVENT equ 10
MOS_SC_CHECKEVENT equ 11
MOS_SC_REDRAWSTATUS equ 12
MOS_SC_DRAWBAR equ 13
MOS_SC_GETSCREENMAX equ 14
MOS_SC_SETBACKGROUND equ 15
MOS_SC_GETPRESSEDBUTTON equ 17
MOS_SC_SYSTEMSERVICE equ 18
MOS_SC_STARTPROGRAM equ 19
MOS_SC_MIDIINTERFACE equ 20
MOS_SC_DEVICESETUP equ 21
MOS_SC_WAITEVENTTIMEOUT equ 23
MOS_SC_CDAUDIO equ 24
MOS_SC_SB16MIXER1 equ 25
MOS_SC_GETDEVICESETUP equ 26
MOS_SC_WSS equ 27
MOS_SC_SB16MIXER2 equ 28
MOS_SC_GETDATE equ 29
MOS_SC_READHD equ 30
MOS_SC_STARTPROGRAMHD equ 31
MOS_SC_GETSCREENPIXEL equ 35
MOS_SC_GETMOUSEPOSITION equ 37
MOS_SC_DRAWLINE equ 38
MOS_SC_GETBACKGROUND equ 39
MOS_SC_SETEVENTMASK equ 40
MOS_SC_WRITENUMBER equ 47
MOS_SC_WINDOWPROPERTIES equ 48
 
 
;**********************************************************
; event numbers
;**********************************************************
 
MOS_EVT_NONE equ 0
MOS_EVT_REDRAW equ 1
MOS_EVT_KEY equ 2
MOS_EVT_BUTTON equ 3
 
 
;**********************************************************
; event bits
;**********************************************************
 
MOS_EVTBIT_REDRAW equ (1 << 0)
MOS_EVTBIT_KEY equ (1 << 1)
MOS_EVTBIT_BUTTON equ (1 << 2)
MOS_EVTBIT_ENDREQUEST equ (1 << 3)
MOS_EVTBIT_BGDRAW equ (1 << 4)
MOS_EVTBIT_MOUSECHANGE equ (1 << 5)
MOS_EVTBIT_IPCEVENT equ (1 << 6)
MOS_EVTBIT_IRQ0 equ (1 << 16)
MOS_EVTBIT_IRQ1 equ (1 << 17)
MOS_EVTBIT_IRQ2 equ (1 << 18)
MOS_EVTBIT_IRQ3 equ (1 << 19)
MOS_EVTBIT_IRQ4 equ (1 << 20)
MOS_EVTBIT_IRQ5 equ (1 << 21)
MOS_EVTBIT_IRQ6 equ (1 << 22)
MOS_EVTBIT_IRQ7 equ (1 << 23)
MOS_EVTBIT_IRQ8 equ (1 << 24)
MOS_EVTBIT_IRQ9 equ (1 << 25)
MOS_EVTBIT_IRQ10 equ (1 << 26)
MOS_EVTBIT_IRQ11 equ (1 << 27)
MOS_EVTBIT_IRQ12 equ (1 << 28)
MOS_EVTBIT_IRQ13 equ (1 << 29)
MOS_EVTBIT_IRQ14 equ (1 << 30)
MOS_EVTBIT_IRQ15 equ (1 << 31)
 
 
;**********************************************************
; exit application (syscall -1)
;**********************************************************
 
; exit application
%macro MOS_EXIT 0
mov eax,MOS_SC_EXIT
int 0x40
%endmacro
 
; exit application, smaller version
%macro MOS_EXIT_S 0
xor eax,eax
dec eax
int 0x40
%endmacro
 
 
;**********************************************************
; wait event stuff
; (MOS_SC_WAITEVENT, syscall 10)
;**********************************************************
 
; wait for event
; destroys : nothing
; returns : eax = event type
%macro MOS_WAITEVENT 0
mov eax,MOS_SC_WAITEVENT
int 0x40
%endmacro
 
; wait for event, smaller version
; destroys : flags
; returns : eax = event type
%macro MOS_WAITEVENT_S 0
xor eax,eax
mov al,MOS_SC_WAITEVENT
int 0x40
%endmacro
 
 
;**********************************************************
; window redraw status stuff
; (MOS_SC_REDRAWSTATUS, syscall 12)
;**********************************************************
 
MOS_RS_STARTREDRAW equ 1
MOS_RS_ENDREDRAW equ 2
 
; start window redraw
; destroys: eax,ebx
%macro MOS_STARTREDRAW 0
mov ebx,MOS_RS_STARTREDRAW
mov eax,MOS_SC_REDRAWSTATUS
int 0x40
%endmacro
 
; start window redraw, smaller version
; destroys: eax,ebx,flags
%macro MOS_STARTREDRAW_S 0
xor ebx,ebx
inc ebx
xor eax,eax
mov al,MOS_SC_REDRAWSTATUS
int 0x40
%endmacro
 
; end window redraw
; destroys: eax,ebx
%macro MOS_ENDREDRAW 0
mov ebx,MOS_RS_ENDREDRAW
mov eax,MOS_SC_REDRAWSTATUS
int 0x40
%endmacro
 
; end window redraw, smaller version
; destroys: eax,ebx,flags
%macro MOS_ENDREDRAW_S 0
xor ebx,ebx
mov bl,MOS_RS_ENDREDRAW
xor eax,eax
mov al,MOS_SC_REDRAWSTATUS
int 0x40
%endmacro
 
 
;**********************************************************
; get screen max stuff (syscall 14)
;**********************************************************
 
; get screen dimensions in eax
; destroys: nothing
%macro MOS_GETSCREENMAX 0
mov eax,MOS_SC_GETSCREENMAX
int 0x40
%endmacro
 
; get screen dimensions in eax, smaller version
; destroys: flags
%macro MOS_GETSCREENMAX_S 0
xor eax,eax
mov al,MOS_SC_GETSCREENMAX
int 0x40
%endmacro
 
 
 
%endif
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/c4/trunk/pcx.inc
0,0 → 1,137
; pcx.inc
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
%ifndef _PCX_INC
%define _PCX_INC
 
 
;**********************************************************
; pcx header
;**********************************************************
 
PCXHEADER_SIZE equ 128
struc PCXHEADER
.id: resb 1 ; id, should be 10
.version: resb 1 ; pcx version
.encoding: resb 1 ; 1 = rle
.bpp: resb 1 ; bits per pixel
.xmin: resw 1 ; image dimensions
.ymin: resw 1
.xmax: resw 1
.ymax: resw 1
.hdpi: resw 1 ; horizontal resolution in dpi
.vdpi: resw 1 ; verttical resolution in dpi
.colormap: resb 48 ; 16 color palette
.reserved1: resb 1
.nplanes: resb 1 ; # of color planes
.bytesperline: resw 1 ; # of bytes per scanline. always even
.palinfo: resw 1 ; 1 = color/bw, 2 = grayscale
.hscreensize: resw 1 ; horizontal screen size
.vscreensize: resw 1 ; vertical screen size
.reserved2: resb 54
endstruc
 
 
section .text
 
 
 
;**********************************************************
; lousy pcx decoder. reads only 8 bit rle packed color images (pcx version 5)
; oh, and yes, currently it can't read images with an odd width.
;
; the routine does not only decode the image data, it converts
; it also to a menuetos putimage compatible format (24 bit, rrggbb)
;
; input : esi address of the pcx file in memory
; edi pointer to the memory where the depacked
; image data should go. (width*height*3 bytes)
; ebx file size in bytes
;
; output : decoded image in [edi]
;
; destroys : nothing
;
;**********************************************************
 
loadPCX:
pushad
pushfd
 
; calculate number of pixels to decode.
; this is actually wrong, because if the image has an odd
; width, there will be an unused pixel at the end of each
; scanline.
movzx eax,word [esi+PCXHEADER.xmax] ; eax = image width
sub ax,[esi+PCXHEADER.xmin]
inc eax
movzx ecx,word [esi+PCXHEADER.ymax] ; ecx = image height
sub cx,[esi+PCXHEADER.ymin]
inc ecx
mul ecx
mov ebp,eax ; ebp = # of pixels to decode
 
; move ebx to beginning of palette and
; esi to beginning of packed image data
sub ebx,768
add ebx,esi
add esi,PCXHEADER_SIZE
; decode image data
xor ecx,ecx ; clear bits 8..31 !
xor eax,eax ; "
.decode:
lodsb ; read byte from input stream
cmp al,192 ; encoded/unencoded byte ?
jae short .encoded
lea edx,[eax*2+eax] ; read color values from
mov al,[ebx+edx+2] ; palette and store them
stosb ; in the destination image
mov al,[ebx+edx+1]
stosb
mov al,[ebx+edx+0]
stosb
dec ebp ; one less to go...
jmp short .continue
.encoded:
and al,00111111b ; calc # of times to repeat
mov cl,al
lodsb ; read data byte
lea edx,[eax*2+eax] ; read color values from palette
mov al,[ebx+edx+2]
mov ah,[ebx+edx+1]
mov dl,[ebx+edx+0]
.bla: ; write color values
stosb
mov [edi],ah
inc edi
mov [edi],dl
inc edi
dec ebp ; one less to go...
loop .bla
xor ah,ah ; reset ah to 0 !
.continue:
or ebp,ebp ; all pixels decoded ?
jnz short .decode
 
popfd
popad
ret
 
 
%endif
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/c4/trunk/randomai.inc
0,0 → 1,50
; C4
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This file is part of C4.
;
; C4 is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; C4 is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with C4; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
%infdef _RANDOMAI_INC
%define _RANDOMAI_INC
 
section .text
 
 
 
;**********************************************************
; randomaiGetMove
; getmove routine for random "ai" player
;
; input : eax = cpu level (ignored by this player:)
; output : eax = move
; destroys : everything
;**********************************************************
randomaiGetMove
 
.l:
call rand ; get random number in the range [1,7]
xor edx,edx ; !
mov ebx,7
div ebx
inc edx
BOARDISVALIDMOVE edx ; is this a valid move ?
jz .l ; no -> try again
 
mov eax,edx ; return move
ret
 
%endif
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/c4/trunk/red.pcx
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/games/c4/trunk/rng.inc
0,0 → 1,76
; C4
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This file is part of C4.
;
; C4 is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; C4 is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with C4; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
%ifndef _RNG_INC
%define _RNG_INC
 
section .data
 
 
; random seed
seed dd 0
 
 
 
section .text
 
 
;**********************************************************
; randomize
; initialize random number generator.
; initialization is done using the get system clock syscall
;
; input : nothing
; output : nothing
; destroys : nothing
;**********************************************************
randomize:
push eax
mov eax,MOS_SC_GETSYSCLOCK
int 0x40
mov [seed],eax
pop eax
ret
 
 
 
;**********************************************************
; rand
; return an unsigned 32 bit "random" number
;
; input : nothing
; output : eax = unsigned 32 bit random number
; destroys : nothing
;**********************************************************
rand:
pushfd
push edx
mov eax,32719
mul dword [seed]
add eax,123
xchg al,ah
rol eax,16
xchg al,ah
mov [seed],eax
pop edx
popfd
ret
%endif
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/c4/trunk/windows.inc
0,0 → 1,356
; windows.inc
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
%ifndef _WINDOWS_INC
%define _WINDOWS_INC
 
 
WND_CENTER equ (1 << 0)
WND_DEFAULT_WORKCOLOR equ (1 << 1)
WND_DEFAULT_GRABCOLOR equ (1 << 2)
WND_DEFAULT_FRAMECOLOR equ (1 << 3)
WND_DEFAULT_CAPTIONCOLOR equ (1 << 4)
WND_DEFAULT_COLORS equ (WND_DEFAULT_WORKCOLOR | WND_DEFAULT_GRABCOLOR | WND_DEFAULT_FRAMECOLOR | WND_DEFAULT_CAPTIONCOLOR)
 
 
struc WND
.xposandsize resd 1 ; x position and size (like syscall)
.yposandsize resd 1 ; y position and size (like syscall)
.workcolor resd 1 ; work area color (like syscall)
.grabcolor resd 1 ; grab bar color (like syscall)
.framecolor resd 1 ; frame color (like syscall)
.caption resd 1 ; pointer to caption (zero terminated)
; can be zero, if no caption is desired.
.captioncolor resd 1 ; caption color
.flags resd 1 ; combination of WND_xxx flags, or zero.
endstruc
 
 
BUTTON_COLOR_GRAB equ 0x01000000
BUTTON_COLOR_WORK equ 0x02000000
 
 
struc BUTTON
.xposandsize resd 1 ; x position and size (like syscall)
.yposandsize resd 1 ; y position and size (like syscall)
.id resd 1 ; button id
.color resd 1 ; button color. can be a real color
; or one of the BUTTON_COLOR_xxx constants
endstruc
 
 
LABEL_COLOR_GRABBUTTON equ 0x01000000 ; use grab button text default color
LABEL_COLOR_GRAB equ 0x02000000 ; use grab text default color
LABEL_COLOR_WORKBUTTON equ 0x03000000 ; use work button text default color
LABEL_COLOR_WORK equ 0x04000000 ; use work text default color
LABEL_BGCOLOR_TRANSPARENT equ 0x01000000 ; transparent
LABEL_BGCOLOR_WORK equ 0x02000000 ; use work area color
 
 
struc LABEL
.position resd 1 ; position, x in upper word, y in lower word
.caption resd 1 ; pointer to caption (zero terminated)
; if this is field is zero, the label will
; not be drawn.
.color resd 1 ; text color, or a LABEL_COLOR_xxx constant
.bgcolor resd 1 ; background color, or a LABEL_BGCOLOR_xxx constant
endstruc
 
 
section .text
 
 
;***********************************************************
; draw a window
;
; input: edi = pointer to a WND structure
; output: nothing
; destroys: nothing
; notes: you must call begin redraw/end redraw
; yourself, before and after calling
; this function.
;***********************************************************
drawWindow:
 
%define WNDCOLORS ebp-MOS_WNDCOLORS_size
 
enter MOS_WNDCOLORS_size,0
pushfd
pushad
 
; get default window colors
mov ebx,3
lea ecx,[WNDCOLORS]
mov edx,MOS_WNDCOLORS_size
mov eax,MOS_SC_WINDOWPROPERTIES
int 0x40
 
;
; window position
;
test dword [edi + WND.flags],WND_CENTER ; center window ?
jnz short .center
mov ebx,[edi + WND.xposandsize] ; nope -> just load dimensions
mov ecx,[edi + WND.yposandsize]
jmp short .positionok
.center: ; so let's center this window...
MOS_GETSCREENMAX ; get screen dimensions
mov ebx,eax ; xpos = (screenx-width)/2
shr ebx,16
sub bx,[edi + WND.xposandsize]
jns short .xok
xor ebx,ebx
.xok:
shl ebx,15 ; / 2, move result to hi-word
mov bx,[edi + WND.xposandsize]
movzx ecx,ax ; same for ypos
sub cx,[edi + WND.yposandsize]
jns short .yok
xor ecx,ecx
.yok:
shl ecx,15
mov cx,[edi + WND.yposandsize]
.positionok: ; ebx/ecx contain dimensions
 
;
; colors
;
push edi
mov edx,[edi + WND.workcolor]
test dword [edi + WND.flags],WND_DEFAULT_WORKCOLOR
jz short .workcolorok
and edx,0xff000000
or edx,[WNDCOLORS + MOS_WNDCOLORS.work]
.workcolorok:
mov esi,[edi + WND.grabcolor]
test dword [edi + WND.flags],WND_DEFAULT_GRABCOLOR
jz short .grabcolorok
and esi,0xff000000
or esi,[WNDCOLORS + MOS_WNDCOLORS.grab]
.grabcolorok:
test dword [edi + WND.flags],WND_DEFAULT_FRAMECOLOR
mov edi,[edi + WND.framecolor]
jz short .framecolorok
and edi,0xff000000
or edi,[WNDCOLORS + MOS_WNDCOLORS.frame]
.framecolorok:
 
; define window
mov eax,MOS_SC_DEFINEWINDOW
int 0x40
pop edi
 
;
; caption
;
cmp dword [edi + WND.caption],0 ; is there a caption ?
je short .captionok ; nope -> do nothing
mov ebx,MOS_DWORD(8,8) ; ebx = position
mov edx,[edi + WND.caption] ; edx -> string
push edi ; get string length
mov edi,edx
mov ecx,-1
xor al,al ; scan for zero byte
repne scasb
sub edi,edx
dec edi
mov esi,edi
pop edi ; esi = string length
mov ecx,[edi + WND.captioncolor]
test dword [edi + WND.flags],WND_DEFAULT_CAPTIONCOLOR
jz short .captioncolorok
mov ecx,[WNDCOLORS + MOS_WNDCOLORS.grabText]
.captioncolorok:
mov eax,MOS_SC_WRITETEXT
int 0x40
.captionok:
 
popad
popfd
leave
ret
%undef WNDCOLORS
 
 
;***********************************************************
; draw a bunch of buttons
;
; input: edi = pointer to an array of BUTTON structs
; ecx = # of buttons to draw
; output: nothing
; destroys: nothing
; notes: you must call begin redraw/end redraw yourself
;***********************************************************
 
drawButtons:
 
%define WNDCOLORS ebp-MOS_WNDCOLORS_size
 
or ecx,ecx
jnz short .ok
ret
.ok:
enter MOS_WNDCOLORS_size,0
pushfd
pushad
; get default window colors
push ecx
mov ebx,3
lea ecx,[WNDCOLORS]
mov edx,MOS_WNDCOLORS_size
mov eax,MOS_SC_WINDOWPROPERTIES
int 0x40
pop ecx
.drawall:
push ecx
mov ebx,[edi + BUTTON.xposandsize]
mov ecx,[edi + BUTTON.yposandsize]
mov edx,[edi + BUTTON.id]
mov esi,[edi + BUTTON.color]
cmp esi,BUTTON_COLOR_GRAB ; use a default color ?
jne .ok1
mov esi,[WNDCOLORS + MOS_WNDCOLORS.grabButton]
.ok1:
cmp esi,BUTTON_COLOR_WORK
jne .ok2
mov esi,[WNDCOLORS + MOS_WNDCOLORS.workButton]
.ok2:
mov eax,MOS_SC_DEFINEBUTTON
int 0x40
add edi,BUTTON_size
pop ecx
loop .drawall
popad
popfd
leave
ret
%undef WNDCOLORS
 
 
;***********************************************************
; draw a bunch of labels
;
; input: edi = pointer to an array of LABEL structs
; ecx = # of labels to draw
; output: nothing
; destroys: nothing
;***********************************************************
 
drawLabels:
 
%define WNDCOLORS ebp-MOS_WNDCOLORS_size
 
or ecx,ecx
jnz short .ok
ret
.ok:
enter MOS_WNDCOLORS_size,0
pushfd
pushad
; get default window colors
push ecx
mov ebx,3
lea ecx,[WNDCOLORS]
mov edx,MOS_WNDCOLORS_size
mov eax,MOS_SC_WINDOWPROPERTIES
int 0x40
pop ecx
.drawall:
push ecx
cmp dword [edi + LABEL.caption],0
jne short .notnull
jmp .next
.notnull:
; get caption length
push edi
mov edi,[edi + LABEL.caption]
mov ecx,-1
xor al,al
repne scasb ; search for zero byte
mov esi,edi
pop edi
sub esi,[edi + LABEL.caption]
dec esi ; esi = string length
; clear background, if necessary
cmp dword [edi + LABEL.bgcolor],LABEL_BGCOLOR_TRANSPARENT
je .clearok
mov ebx,[edi + LABEL.position] ; ebx = xstart/width
mov eax,esi ; width = stringlength * 6
mov edx,6
mul edx
mov bx,ax
mov ecx,[edi + LABEL.position] ; ecx = ystart/height
shl ecx,16
mov cx,8
mov edx,[edi + LABEL.bgcolor]
cmp edx,LABEL_BGCOLOR_WORK
jne short .bgcolorok
mov edx,[WNDCOLORS + MOS_WNDCOLORS.work]
.bgcolorok:
mov eax,MOS_SC_DRAWBAR
int 0x40
.clearok:
 
; draw label
mov ebx,[edi + LABEL.position] ; ebx = label position
mov edx,[edi + LABEL.caption] ; edx -> caption
mov ecx,[edi + LABEL.color] ; ecx = color
cmp ecx,LABEL_COLOR_GRABBUTTON
jne short .ok1
mov ecx,[WNDCOLORS + MOS_WNDCOLORS.grabButtonText]
.ok1:
cmp ecx,LABEL_COLOR_GRAB
jne short .ok2
mov ecx,[WNDCOLORS + MOS_WNDCOLORS.grabText]
.ok2:
cmp ecx,LABEL_COLOR_WORKBUTTON
jne short .ok3
mov ecx,[WNDCOLORS + MOS_WNDCOLORS.workButtonText]
.ok3:
cmp ecx,LABEL_COLOR_WORK
jne short .ok4
mov ecx,[WNDCOLORS + MOS_WNDCOLORS.workText]
.ok4:
mov eax,MOS_SC_WRITETEXT
int 0x40
 
.next
add edi,LABEL_size ; next label
pop ecx
dec ecx
jz .done
jmp .drawall
.done:
 
popad
popfd
leave
ret
%undef WNDCOLORS
 
 
%endif
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/chess/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm chess.asm chess
@pause
/programs/games/chess/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm chess.asm chess
@pause
/programs/games/chess/trunk/chess.asm
0,0 → 1,1323
;
; CHESS CLIENT for CHESSCLUB.COM (VT)
;
; Compile with FASM for Menuet
;
use32
org 0x0
db 'MENUET00' ; 8 byte id
dd 38 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x100000 ; required amount of memory
; esp = 0x7FFF0
dd 0x00000000 ; reserved=no extended header
include 'lang.inc'
include 'macros.inc'
file_info:
dd 0,0,-1,0x4000,0x20000
db '/rd/1/chess.bmp',0
pawn_color:
dd 0x000000
dd 0x222222
dd 0x444444
dd 0xf0f0f0
dd 0xc0c0c0
dd 0xa0a0a0
dd 0xa0a0a0
dd 0x707070
dd 0xb0b0b0
dd 0xc0c0c0
dd 0xd0d0d0
dd 0xd8d8d8
dd 0xe0e0e0
dd 0xe8e8e8
dd 0x00ff00
dd 0xffffff
texts equ board_old+80*30
text equ texts+80*32*4
START: ; start of execution
mov eax,58
mov ebx,file_info
int 0x40
mov esi,0x4000+22*3+4+24*2
mov edi,0x10000+18*3
mov ebx,0
mov ecx,0
newp:
xor eax,eax
mov al,[esi]
and al,0xf0
shr al,4
shl eax,2
mov eax,[pawn_color+eax]
mov [edi+0],eax
xor eax,eax
mov al,[esi]
and al,0x0f
shl eax,2
mov eax,[pawn_color+eax]
mov [edi+3],eax
add edi,6
add esi,1
inc ebx
cmp ebx,23
jbe newp
sub edi,12
mov ebx,0
inc ecx
cmp ecx,279
jb newp
; Clear the screen memory
mov eax, ' '
mov edi,text
mov ecx,80*30 /4
cld
rep stosd
call draw_window
still:
call check_for_board
call board_changed
call draw_board
; check connection status
mov eax,53
mov ebx,6
mov ecx,[socket]
int 0x40
mov ebx, [socket_status]
mov [socket_status], eax
cmp eax, ebx
je waitev
call display_status
waitev:
mov eax,23 ; wait here for event
mov ebx,20
int 0x40
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
; any data from the socket?
mov eax, 53
mov ebx, 2
mov ecx, [socket]
int 0x40
cmp eax, 0
jne read_input
jmp still
read_input:
push ecx
mov eax, 53
mov ebx, 3
mov ecx, [socket]
int 0x40
pop ecx
call handle_data
push ecx
mov eax, 53
mov ebx, 2
mov ecx, [socket]
int 0x40
pop ecx
cmp eax, 0
jne read_input
call draw_text
jmp still
check_for_board:
pusha
mov esi,text-80
news:
add esi,80
cmp esi,text+80*10
je board_not_found
cmp [esi+12],dword '----'
je cfb1
jmp news
cfb1:
cmp [esi+16*80+12],dword '----'
je cfb2
jmp news
cfb2:
cmp [esi+2*80+12],dword '+---'
jne news
cmp [esi+4*80+12],dword '+---'
jne news
board_found:
mov edi,chess_board
mov ecx,80*18
cld
rep movsb
board_not_found:
popa
ret
yst dd 150
textx equ 10
ysts equ 410
boardx dd 45
boardy dd 45
boardxs dd 44
boardys dd 44
conx equ 420
cony equ 118
dconx equ 420
dcony equ 148
statusx equ 420
statusy equ 178
drsq:
push eax ebx
mov ecx,ebx
mov ebx,eax
mov eax,ebx
add eax,ecx
imul ebx,[boardxs]
add ebx,[boardx]
shl ebx,16
imul ecx,[boardys]
add ecx,[boardy]
shl ecx,16
add ebx,[boardxs]
add ecx,[boardys]
mov edx,[sq_black]
test eax,1
jnz dbl22
mov edx,[sq_white]
dbl22:
mov eax,13
int 0x40
pop ebx eax
ret
draw_pawn:
; edi,0 ; white / black
; esi,0 ; from position 2 , 20 square
; eax,2 ; board x
; ebx,0 ; board y
pusha
call drsq
cmp esi,20
jne no_sqd
popa
ret
no_sqd:
imul eax,[boardxs]
imul ebx,[boardys]
add eax,[boardx]
add ebx,[boardy]
imul esi,44*45*3
add esi,0x10000+18*3
mov ecx,43
dp0:
pusha
mov ecx,44
ldp1:
pusha
mov ecx,ebx
mov ebx,eax
mov edx,[esi]
and edx,0xffffff
mov eax,1
cmp edx,0x00ff00
je nowp
cmp edi,1
jne nobl
shr edx,1
and edx,0x7f7f7f
nobl:
int 0x40
nowp:
popa
add esi,3
add eax,1
dec ecx
jnz ldp1
popa
add ebx,1
add esi,3*44
dec ecx
jnz dp0
popa
ret
board_changed:
pusha
mov eax,0
mov esi,chess_board
bcl1:
add eax,[esi]
add esi,4
cmp esi,chess_board+19*80
jb bcl1
cmp eax,[checksum]
je bcl2
mov [changed],1
bcl2:
mov [checksum],eax
popa
ret
checksum dd 0
changed db 1
draw_board:
pusha
cmp [changed],1
jne no_change_in_board
mov [changed],0
mov eax,0
mov ebx,0
scan_board:
push eax ebx
mov esi,ebx
imul esi,2
imul esi,80
add esi,80
imul eax,4
add eax,10
add esi,eax
movzx edx,word [chess_board+esi]
cmp dx,[board_old+esi]
je empty_slot
mov ecx,13
newseek2:
mov edi,ecx
imul edi,8
sub edi,8
cmp dx,[edi+nappulat]
je foundnappula2
loop newseek2
jmp empty_slot
foundnappula2:
mov esi,[edi+nappulat+4]
mov edi,0
cmp dl,'*'
jne nnbb
mov edi,1
nnbb:
mov eax,[esp+4]
mov ebx,[esp]
call draw_pawn
empty_slot:
pop ebx eax
inc eax
cmp eax,8
jb scan_board
mov eax,0
inc ebx
cmp ebx,8
jb scan_board
mov esi,chess_board
mov edi,board_old
mov ecx,80*19
cld
rep movsb
mov eax,13
mov ebx,[boardx]
sub ebx,14
shl ebx,16
add ebx,8
mov ecx,[boardy]
shl ecx,16
add ecx,46*8
mov edx,[wcolor]
int 0x40
mov eax,4 ; numbers at left
mov ebx,[boardx]
sub ebx,14
shl ebx,16
add ebx,[boardy]
add ebx,18
mov ecx,[tcolor]
mov edx,chess_board+80+5
mov esi,3
db1:
int 0x40
add edx,80*2
add ebx,[boardxs]
cmp edx,chess_board+80*16
jb db1
mov eax,13
mov ebx,[boardx]
shl ebx,16
add ebx,8*46
mov ecx,[boardys]
imul ecx,8
add ecx,[boardy]
add ecx,8
shl ecx,16
add ecx,10
mov edx,[wcolor]
int 0x40
mov eax,4 ; letters at bottom
mov ebx,[boardx]
add ebx,3
shl ebx,16
mov bx,word [boardys]
imul bx,8
add ebx,[boardy]
add ebx,8
mov ecx,[tcolor]
mov edx,chess_board+80*17+8
mov esi,4
db3:
int 0x40
mov edi,[boardxs]
shl edi,16
add ebx,edi
add edx,4
cmp edx,chess_board+80*17+8+4*8
jb db3
; print player times
mov edi,74
cmp [chess_board+80+5],byte '1'
jne nowww2
mov edi,371
nowww2:
mov eax,13
mov ebx,(conx)*65536+100
mov ecx,edi
shl ecx,16
add ecx,10
mov edx,[wcolor]
int 0x40
mov eax,4
mov ebx,(conx)*65536
add ebx,edi
mov ecx,[tcolor]
mov edx,chess_board+80*7+59-1
mov esi,20
int 0x40
mov edi,74
cmp [chess_board+80+5],byte '1'
je nowww
mov edi,371
nowww:
mov eax,13
mov ebx,(conx)*65536+100
mov ecx,edi
shl ecx,16
add ecx,10
mov edx,[wcolor]
int 0x40
mov eax,4
mov ebx,(conx)*65536
add ebx,edi
mov ecx,[tcolor]
mov edx,chess_board+80*9+59-1
mov esi,20
int 0x40
; move #
mov eax,13
mov ebx,conx*65536+120
mov ecx,200*65536+10
mov edx,[wcolor]
int 0x40
mov eax,4
mov ebx,conx*65536
add ebx,200
mov ecx,[tcolor]
mov edx,chess_board+80*1+46
mov esi,30
int 0x40
no_change_in_board:
popa
ret
handle_data:
; Telnet servers will want to negotiate options about our terminal window
; just reject them all.
; Telnet options start with the byte 0xff and are 3 bytes long.
mov al, [telnetstate]
cmp al, 0
je state0
cmp al, 1
je state1
cmp al, 2
je state2
jmp hd001
state0:
cmp bl, 255
jne hd001
mov al, 1
mov [telnetstate], al
ret
state1:
mov al, 2
mov [telnetstate], al
ret
state2:
mov al, 0
mov [telnetstate], al
mov [telnetrep+2], bl
mov edx, 3
mov eax,53
mov ebx,7
mov ecx,[socket]
mov esi, telnetrep
int 0x40
ret
hd001:
cmp bl,13 ; BEGINNING OF LINE
jne nobol
mov ecx,[pos]
add ecx,1
boll1:
sub ecx,1
mov eax,ecx
xor edx,edx
mov ebx,80
div ebx
cmp edx,0
jne boll1
mov [pos],ecx
call check_for_board
jmp newdata
nobol:
cmp bl,10 ; LINE DOWN
jne nolf
addx1:
add [pos],dword 1
mov eax,[pos]
xor edx,edx
mov ecx,80
div ecx
cmp edx,0
jnz addx1
mov eax,[pos]
jmp cm1
nolf:
cmp bl,9 ; TAB
jne notab
add [pos],dword 8
jmp newdata
notab:
cmp bl,8 ; BACKSPACE
jne nobasp
mov eax,[pos]
dec eax
mov [pos],eax
mov [eax+text],byte 32
mov [eax+text+60*80],byte 0
jmp newdata
nobasp:
cmp bl,15 ; CHARACTER
jbe newdata
mov eax,[pos]
mov [eax+text],bl
mov eax,[pos]
add eax,1
cm1:
mov ebx,[scroll+4]
imul ebx,80
cmp eax,ebx
jb noeaxz
mov esi,text+80
mov edi,text
mov ecx,ebx
cld
rep movsb
mov eax,ebx
sub eax,80
noeaxz:
mov [pos],eax
newdata:
ret
red: ; REDRAW WINDOW
call draw_window
jmp still
key: ; KEY
mov eax,2 ; send to modem
int 0x40
mov ebx, [socket_status]
cmp ebx, 4 ; connection open?
jne still ; no, so ignore key
shr eax,8
cmp eax,178 ; ARROW KEYS
jne noaup
mov al,'A'
call arrow
jmp still
noaup:
cmp eax,177
jne noadown
mov al,'B'
call arrow
jmp still
noadown:
cmp eax,179
jne noaright
mov al,'C'
call arrow
jmp still
noaright:
cmp eax,176
jne noaleft
mov al,'D'
call arrow
jmp still
noaleft:
modem_out:
call to_modem
jmp still
button: ; BUTTON
mov eax,17
int 0x40
cmp ah,1 ; CLOSE PROGRAM
jne noclose
mov eax,53
mov ebx,8
mov ecx,[socket]
int 0x40
mov eax,-1
int 0x40
noclose:
cmp ah, 4 ; connect
jne notcon
mov eax, [socket_status]
cmp eax, 4
je still
call connect
jmp still
notcon:
cmp ah,5 ; disconnect
jne notdiscon
call disconnect
jmp still
notdiscon:
jmp still
arrow:
push eax
mov al,27
call to_modem
mov al,'['
call to_modem
pop eax
call to_modem
ret
to_modem:
pusha
push ax
mov [tx_buff], al
mov edx, 1
cmp al, 13
jne tm_000
mov edx, 2
tm_000:
mov eax,53
mov ebx,7
mov ecx,[socket]
mov esi, tx_buff
int 0x40
pop bx
mov al, [echo]
cmp al, 0
je tm_001
push bx
call handle_data
pop bx
cmp bl, 13
jne tm_002
mov bl, 10
call handle_data
tm_002:
call draw_text
tm_001:
popa
ret
disconnect:
mov eax,53
mov ebx,8
mov ecx,[socket]
int 0x40
ret
connect:
pusha
mov ecx, 1000 ; local port starting at 1000
getlp:
inc ecx
push ecx
mov eax, 53
mov ebx, 9
int 0x40
pop ecx
cmp eax, 0 ; is this local port in use?
jz getlp ; yes - so try next
mov eax,53
mov ebx,5
mov dl, [ip_address + 3]
shl edx, 8
mov dl, [ip_address + 2]
shl edx, 8
mov dl, [ip_address + 1]
shl edx, 8
mov dl, [ip_address]
mov esi, edx
movzx edx, word [port] ; telnet port id
mov edi,1 ; active open
int 0x40
mov [socket], eax
popa
ret
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
pusha
mov eax,12
mov ebx,1
int 0x40
mov eax,14
int 0x40
mov ebx,eax
mov ecx,eax
shr ebx,16
and ebx,0xffff
and ecx,0xffff
shr ebx,1
shr ecx,1
sub ebx,275
sub ecx,235
shl ebx,16
shl ecx,16
mov eax,0 ; DRAW WINDOW
mov bx,550
mov cx,470
mov edx,[wcolor]
add edx,0x03000000
mov esi,0x80557799
mov edi,0x00557799
int 0x40
mov eax,4 ; WINDOW LABEL
mov ebx,8*65536+8
mov ecx,0x10ffffff
mov edx,labelt
mov esi,labellen-labelt
int 0x40
call display_status
mov eax,8 ; BUTTON 4: Connect
mov ebx,conx*65536+80
mov ecx,cony*65536+15
mov esi,[wbutton]
mov edx,4
int 0x40
mov eax,4 ; Button text
mov ebx,(conx+4)*65536+cony+4
mov ecx,0xffffff
mov edx,cont
mov esi,conlen-cont
int 0x40
mov eax,8 ; BUTTON 5: disconnect
mov ebx,dconx*65536+80
mov ecx,dcony*65536+15
mov edx,5
mov esi,[wbutton]
int 0x40
mov eax,4 ; Button text
mov ebx,(dconx+4)*65536+dcony+4
mov ecx,0x00ffffff
mov edx,dist
mov esi,dislen-dist
int 0x40
xor eax,eax
mov edi,text+80*30
mov ecx,80*30 /4
cld
rep stosd
call draw_text
mov [changed],1
mov edi,board_old
mov ecx,80*19
mov al,0
cld
rep stosb
mov eax,4
mov ebx,conx*65536+52
mov ecx,[tcolor]
mov edx,quick_start
mov esi,30
prqs:
int 0x40
add ebx,10
add edx,30
cmp [edx],byte 'x'
jne prqs
mov eax,12
mov ebx,2
int 0x40
popa
ret
display_status:
pusha
; draw status bar
mov eax, 13
mov ebx, statusx*65536+80
mov ecx, statusy*65536 + 16
mov edx, [wcolor]
int 0x40
mov esi,contlen-contt ; display connected status
mov edx, contt
mov eax, [socket_status]
cmp eax, 4 ; 4 is connected
je pcon
mov esi,discontlen-discontt
mov edx, discontt
pcon:
mov eax,4 ; status text
mov ebx,statusx*65536+statusy+2
mov ecx,[tcolor]
int 0x40
popa
ret
nappulat:
dd '*P ',5
dd '*K ',3
dd '*Q ',4
dd '*R ',0
dd '*N ',1
dd '*B ',2
dd ' ',20
dd 'P ',5
dd 'K ',3
dd 'Q ',4
dd 'R ',0
dd 'N ',1
dd 'B ',2
row dd 0x0
col dd 0x0
draw_text:
mov esi,text+80*24
mov edi,texts+80*3
dtl1:
cmp [esi],dword 'logi'
je add_text
cmp [esi],dword 'aics'
je add_text
cmp [esi],dword 'You '
je add_text
cmp [esi],dword 'Your'
je add_text
cmp [esi],dword 'Game'
je add_text
cmp [esi],dword 'Ille'
je add_text
cmp [esi],dword 'No s'
je add_text
sub esi,80
cmp esi,text
jge dtl1
dtl2:
mov eax,13
mov ebx,10*65536+532
mov ecx,420*65536+40
mov edx,[wtcom]
int 0x40
mov eax,4
mov ebx,10*65536+420
mov ecx,[wtxt]
mov edx,texts
mov esi,80
dtl3:
int 0x40
add edx,80
add ebx,10
cmp edx,texts+4*80
jb dtl3
ret
add_text:
pusha
cld
mov ecx,80
rep movsb
popa
sub esi,80
sub edi,80
cmp edi,texts
jb dtl2
jmp dtl1
read_string:
mov edi,string
mov eax,'_'
mov ecx,[string_length]
inc ecx
cld
rep stosb
call print_text
mov edi,string
f11:
mov eax,10
int 0x40
cmp eax,2
jne read_done
mov eax,2
int 0x40
shr eax,8
cmp eax,13
je read_done
cmp eax,8
jnz nobsl
cmp edi,string
jz f11
sub edi,1
mov [edi],byte '_'
call print_text
jmp f11
nobsl:
cmp eax,dword 31
jbe f11
cmp eax,dword 95
jb keyok
sub eax,32
keyok:
mov [edi],al
call print_text
inc edi
mov esi,string
add esi,[string_length]
cmp esi,edi
jnz f11
read_done:
call print_text
ret
print_text:
pusha
mov eax,13
mov ebx,[string_x]
shl ebx,16
add ebx,[string_length]
imul bx,6
mov ecx,[string_y]
shl ecx,16
mov cx,8
mov edx,[wcolor]
int 0x40
mov eax,4
mov ebx,[string_x]
shl ebx,16
add ebx,[string_y]
mov ecx,[tcolor]
mov edx,string
mov esi,[string_length]
int 0x40
popa
ret
; DATA AREA
telnetrep db 0xff,0xfc,0x00
telnetstate db 0
string_length dd 16
string_x dd 200
string_y dd 60
string db '________________'
tx_buff db 0, 10
ip_address db 204,178,125,65
port dw 5051 ; 0,0
echo db 1
socket dd 0x0
socket_status dd 0x0
pos dd 80 * 22
scroll dd 1
dd 24
wbutton dd 0x336688
wtcom dd 0x336688 ; 0x666666
wtxt dd 0xffffff
wcolor dd 0xe0e0e0
tcolor dd 0x000000
sq_black dd 0x336688 ; 666666
sq_white dd 0xffffff
labelt db 'Chess Client for Chessclub.com - v0.1'
labellen:
setipt db ' . . .'
setiplen:
setportt db ' '
setportlen:
cont db 'Connect'
conlen:
dist db 'Disconnect'
dislen:
contt db 'Connected'
contlen:
discontt db 'Disconnected'
discontlen:
echot db 'Echo On'
echolen:
echoot db 'Echo Off'
echoolen:
quick_start:
db '( OPPONENT ) '
times 16 db ' 1'
db 'Quick start: '
db ' '
db '1 Connect '
db '2 login: "guest" '
db '3 aics% "seek 10 0" '
db ' (for a player) '
db ' (wait) '
db '4 Play eg. "e7e5" '
db ' or "d2d4" '
db '5 aics% "resign" '
db ' (quit game) '
db '6 Disconnect '
times 5 db ' '
db '( YOU ) '
db 'x'
chess_board:
times 80 db 0
db ' 8 *R *N *B *Q *K *B *N *R'
db ' '
times 80 db 0
db ' 7 *P *P *P *P *P *P *P *P'
db ' '
times 80 db 0
db ' 6 '
db ' '
times 80 db 0
db ' 5 '
db ' '
times 80 db 0
db ' 4 '
db ' '
times 80 db 0
db ' 3 '
db ' '
times 80 db 0
db ' 2 P P P P P P P P '
db ' '
times 80 db 0
db ' 1 R N B Q K B N R '
db ' '
times 80 db 0
db ' a b c d e f g h '
db ' '
times 80*20 db 0
board_old:
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/chess/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/life/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm life.asm life
@pause
/programs/games/life/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm life.asm life
@pause
/programs/games/life/trunk/life.asm
0,0 → 1,254
;
; LIFE.ASM
;
; This program displays Conways game of life
;
; Compile with FASM v1.49 for DOS;
;
; Version 0.1a 20th May 2004
; Ivan Poddubny
;
; Version 0.1 30th March 2004
; Mike Hibbett
;
; This is an experiment to see how small a usefull application can get
 
include "lang.inc"
include "macros.inc"
 
use32
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0xc1000 ; memory for app
dd 0xc1000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
;include "DEBUG.INC"
macro setcell x,y { mov [esi + 512*(y)*3 + (x)*3], al }
 
START:
 
mov al, 0xFF
mov esi, I_END
 
; This is the seed pattern.
 
; Life needs a seed pattern, which is 'hardcode' at compile time
; The grid is 512 wide (x direction) by 512 deep (y direction)
; setcell take the arguments setcell x,y
; 0,0 is the top left corner.
 
; setcell 200,120
; setcell 201,120
; setcell 200,121
; setcell 199,121
; setcell 200,122
 
; setcell 70,120
; setcell 71,120
; setcell 70,121
; setcell 69,121
; setcell 70,122
 
mov eax, 40
mov ebx, 100101b
int 0x40
 
call draw_window
 
still:
 
; mov eax, 23 ; wait here for event
; mov ebx, 5
; int 0x40
mov eax, 11
int 0x40
 
test eax, eax
je nokey
cmp eax,1 ; redraw request ?
je red
cmp eax,3 ; button in buffer ?
je button
cmp eax,6
je mouse
 
jmp still
 
 
mouse:
mov eax, 37
mov ebx, 2
int 0x40
test eax, eax
jz still
 
mov eax, 37
mov ebx, 1
int 0x40
sub eax, 5*65536+20
mov ebx, eax
shr eax, 16
and ebx, 0xffff
 
; WRITE COORDINATES
; dpd eax
; dps " "
; dpd ebx
; dps <10,13>
 
cmp ax, 0
js still
cmp bx, 0
js still
 
shl ebx, 9
add ebx, eax
imul ebx, 3
add ebx, I_END
mov [ebx], dword 0xFFFFFFFF
jmp draw
 
red: ; REDRAW WINDOW
call draw_window
jmp still
 
 
nokey:
; cycle life state
 
mov eax,5
mov ebx,5
int 0x40
 
mov esi, I_END + 512*3
 
mov al, 0xFF
 
lifeloop:
mov ah, 0
cmp [esi - 3], al
jne t2
inc ah
t2:
cmp [esi + 3], al
jne t3
inc ah
t3:
cmp [esi - 512*3], al
jne t4
inc ah
t4:
cmp [esi + 512*3], al
jne t5
inc ah
t5:
cmp [esi - 512*3 - 3], al
jne t6
inc ah
t6:
cmp [esi - 512*3 + 3], al
jne t7
inc ah
t7:
cmp [esi + 512*3 - 3], al
jne t8
inc ah
t8:
cmp [esi + 512*3 + 3], al
jne tend
inc ah
 
tend:
; If cell is empty but has 3 neigbours, birth
; If cell is occupied and has 2,3 neigbours, live
; else die
 
cmp ah, 3
jne btest
mov [esi+1], al
jmp nextcell
 
btest:
cmp ah, 2
jne nextcell
cmp [esi], al
jne nextcell
mov [esi+1], al
 
nextcell:
add esi, 3
cmp esi, I_END + 512*512*3
jne lifeloop
 
; copy new generation across
 
 
mov ecx, 512*512*3
mov esi, I_END+1
mov edi, I_END
rep movsb ; copy the data across
 
mov ecx, 512*512
mov esi, I_END
nc1:
mov [esi+2], byte 0
add esi, 3
loop nc1
draw:
mov ebx, I_END
mov ecx, 512*65536+512
mov edx, 5*65536+22
mov eax,7
int 0x40
 
jmp still
 
button: ; BUTTON - only close supported
or eax,-1
int 0x40
 
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
mov eax,12
mov ebx,1
int 0x40
 
mov eax,0 ; open window
mov ebx,50*65536+512+9
mov ecx,50*65536+512+22+4
mov edx,0x03000000
int 0x40
 
mov eax,4 ; WINDOW LABEL
mov ebx,8*65536+8
mov ecx,0x10ffffff
mov edx,header
mov esi,header.size
int 0x40
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
 
; DATA AREA
 
header db 'Life'
.size = $ - header
 
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/life/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/mblocks/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm mblocks.asm mblocks
@pause
/programs/games/mblocks/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm mblocks.asm mblocks
@pause
/programs/games/mblocks/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/mblocks/trunk/mblocks.asm
0,0 → 1,1642
;
; Memory Blocks for Menuet v0.1
; Crown Soft (c) crown_s@rambler.ru
;
; Compile with FASM for Menuet
;
 
use32
 
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x4000 ; memory for app
dd 0x4000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
include 'macros.inc'
labelt db 'Memory Blocks for Menuet v0.1 Crown Soft (c)'
labellen:
 
 
 
START: ; start of execution
call initpict
 
still:
mov eax,10 ; wait here for event
int 0x40
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
jmp still
 
red: ; redraw
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jz close
 
cmp ah,100 ; button id=100 ?
jz init
 
movzx ebx,ah
 
dec bl
dec bl ; bl -number bitton
mov al,[bitstat+ebx*1]
cmp al,1 ; is pictures on bitton?
jz still
 
inc [nkeydown]
 
cmp [firstbit],0xff
jz tofirst
 
cmp [secondbit],0xff
jz tosecond
 
 
movzx eax,[firstbit]
mov [bitstat+eax*1],0
 
mov al,[secondbit]
mov [bitstat+eax*1],0
 
mov [secondbit],0xff
 
 
tofirst:
mov [firstbit],bl
mov [bitstat+ebx*1],1
call draw_window
jmp still
 
tosecond:
mov [secondbit],bl
mov [bitstat+ebx*1],1
 
mov al,[bitpict+ebx*1]
mov bl,[firstbit] ; comply pictures on first bitton
cmp [bitpict+ebx*1],al ; with pictures on second
jnz tosm1
mov [firstbit] ,0xff
mov [secondbit],0xff
tosm1:
 
call draw_window
jmp still
 
init:
call initpict
jmp still
 
close:
mov eax,-1 ; close program
int 0x40
 
 
 
;======================================================================
;=============== WINDOW DEFINITIONS AND DRAW ========================
;======================================================================
draw_window:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov ebx,100*65536+413 ; [x start] *65536 + [x size]
mov ecx,100*65536+295 ; [y start] *65536 + [y size]
mov edx,0x83000000 ; color of work area RRGGBB,8->color gl
mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl
mov edi,0x005080d0 ; color of frames RRGGBB
int 0x40
 
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
; ; CLOSE BUTTON
; mov eax,8 ; function 8 : define and draw button
; mov ebx,(411-19)*65536+12 ; [x start] *65536 + [x size]
; mov ecx,5*65536+12 ; [y start] *65536 + [y size]
; mov edx,1 ; button id
; mov esi,0x6688dd ; button color RRGGBB
; int 0x40
 
; init BUTTON
mov eax,8 ; function 8 : define and draw button
mov ebx,10*65536+55 ; [x start] *65536 + [x size]
mov ecx,270*65536+12 ; [y start] *65536 + [y size]
mov edx,100 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
; NEW GAME LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,15*65536+273 ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; color of text RRGGBB
mov edx,labnew ; pointer to text beginning
mov esi,labnewlen-labnew ; text length
int 0x40
 
mov ebx,40001h
mov ecx,nkeydown
mov edx,135*65536+273
mov esi,0x00ffffff
mov eax,47
int 0x40
 
 
;--- draw buttons ---
mov [bitid],2
mov ecx,10
drm1:
mov ebx,ecx
mov ecx,6
drm2:
pushad
; BUTTON
imul bx,bx,40
sub bx,30
shl ebx,16
mov bx,34 ; ebx=[x start]*65536+[x size]
 
imul cx,cx,40
sub cx,13
shl ecx,16
mov cx,34 ; ecx=[y start]*65536+[y size]
 
movzx edx,[bitid] ; button id
 
mov esi,[coltbl+16*4] ; button color RRGGBB
mov eax,8 ; function 8 : define and draw button
int 0x40
 
; PICTURE
dec edx
dec edx
; edx - number of bitton
mov al,[bitstat+edx*1]
cmp al,0
jz drm3
movzx eax,[bitpict+edx*1] ; al - number of picture
call unpack
 
mov edx,ebx
shr ecx,16
mov dx,cx ; ecx=[x size]*65536+[y size]
add edx,10001h
 
mov ebx,mas
mov ecx,32*65536+32 ; image size
mov eax,7 ; function 7 : putimage
int 0x40
drm3:
 
inc [bitid]
popad
loop drm2
mov ecx,ebx
loop drm1
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
;========== put pictures number eax to mas ==================================
unpack:
pushad
cld
mov esi,[pict+eax*4]
 
mov edi, mas
 
lodsb ; al - mask color
mov dl,al ; dl - mask color
 
xor ecx,ecx
m2:
xor eax,eax
lodsb
mov cl,al
and cl,0Fh
shr al,4
 
cmp al,dl ; is color mask?
jnz m5
mov al,16
m5:
 
cmp cl,ch ; ch=00h
jz m1
mov eax,[coltbl+eax*4]
m3:
stosd
dec edi
loop m3
jmp m2
 
m1:
 
mov eax,[coltbl+16*4]
m7:
cmp edi,1024*3+mas
jnb m6
stosd
dec edi
jmp m7
 
m6:
popad
ret
;============================================================================
 
;============================= initpict =====================================
initpict:
pushad
mov edi,nkeydown
 
mov ecx,60+4
xor al,al
rep stosb ; nkeydown=0 bitstat=0
 
mov ecx,60+2
mov al,0ffh
rep stosb ; bitpict=0ffh firstbit=0ffh secondbit=0ffh
 
; Initialize RND
mov eax,3
int 0x40 ; eax=00SSMMHH
rol eax,16 ; eax=MMHH00SS - fist random number
 
mov ebx,8088405h
 
mov ecx,30
ck1:
ck2:
mul ebx ; compute next random number
inc eax ; new := 8088405h * old + 1
 
movzx edx,al
and dl,3fh
 
cmp dl,59
ja ck2
 
cmp [bitpict+edx*1],0ffh
jnz ck2
dec cl
mov [bitpict+edx*1],cl
inc cl
 
mul ebx ; compute next random number
inc eax ; new := 8088405h * old + 1
 
ck3:
mul ebx ; compute next random number
inc eax ; new := 8088405h * old + 1
 
movzx edx,al
and dl,3fh
 
cmp dl,59
ja ck3
 
cmp [bitpict+edx*1],0ffh
jnz ck3
dec cl
mov [bitpict+edx*1],cl
inc cl
 
loop ck1
 
call draw_window
popad
ret
 
;======================================================================
;======================== DATA AREA ===================================
;======================================================================
 
 
 
;----------------------- Compressed pictures --------------------------
 
key1 db 1 ; this color will background
db 01Fh,01Fh,01Fh,01Fh,01Fh,01Fh,01Fh,01Dh ; each byte is 0CNh
db 005h,01Fh,01Ah,002h,0F1h,071h,0F1h,071h ; there C - color
db 0F1h,002h,01Fh,017h,001h,071h,0F1h,071h ; N - number pixels
db 0F1h,071h,0F1h,071h,0F1h,071h,001h,01Fh ;
db 011h,002h,012h,001h,071h,0F1h,071h,0F1h ; byte 0X0h - end of picture
db 071h,0F1h,071h,0F1h,071h,0F1h,071h,001h
db 01Fh,001h,0F1h,001h,011h,001h,0F1h,071h
db 0F1h,071h,0F1h,071h,0F1h,071h,0F1h,071h
db 0F1h,001h,012h,00Eh,071h,002h,072h,0F1h
db 071h,0F1h,071h,0F1h,071h,003h,071h,0F1h
db 002h,0F1h,071h,0F1h,071h,0F1h,071h,0F1h
db 071h,0F1h,071h,0F1h,071h,0F1h,077h,0F1h
db 071h,0F1h,071h,001h,083h,001h,071h,002h
db 07Fh,074h,0F1h,071h,0F1h,071h,0F1h,001h
db 013h,001h,0F1h,001h,011h,001h,07Fh,074h
db 0F1h,071h,0F1h,071h,001h,013h,001h,071h
db 001h,012h,00Fh,001h,072h,0F1h,071h,0F1h
db 071h,0F1h,071h,003h,071h,0F1h,001h,013h
db 001h,082h,003h,084h,002h,081h,001h,011h
db 001h,072h,0F1h,071h,0F1h,071h,0F1h,071h
db 0F1h,071h,0F1h,001h,015h,002h,013h,004h
db 011h,002h,012h,001h,071h,0F1h,071h,0F1h
db 071h,0F1h,071h,0F1h,071h,0F1h,071h,001h
db 01Fh,015h,001h,071h,0F1h,071h,0F1h,071h
db 0F1h,071h,0F1h,071h,001h,01Fh,016h,081h
db 002h,0F1h,071h,0F1h,071h,0F1h,002h,081h
db 01Fh,011h,081h,013h,081h,011h,081h,011h
db 005h,011h,081h,011h,081h,01Fh,011h,081h
db 013h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,014h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,012h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,013h,081h,011h,082h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 015h,081h,012h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,013h,081h,011h,081h
db 012h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,014h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,013h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,011h,081h
db 016h,081h,015h,081h,011h,081h,011h,081h
db 013h,081h,011h,081h,011h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,01Fh,015h
db 081h,011h,081h,011h,081h,011h,081h,011h
db 081h,011h,081h,01Fh,017h,081h,011h,081h
db 011h,081h,011h,081h,011h,081h,01Fh,01Bh
db 081h,011h,081h,000h
 
globe db 1
db 01Ch,008h,01Fh,016h,003h,0C2h,0A1h,0C5h
db 003h,01Fh,011h,002h,0A4h,0C5h,0A2h,0C3h
db 002h,01Dh,001h,0A5h,0C4h,0A2h,0C1h,0A1h
db 0C4h,0A1h,001h,01Bh,001h,0A6h,0C4h,0A2h
db 0C1h,0A1h,0C4h,0A2h,001h,019h,001h,0A8h
db 0C1h,0A1h,0C1h,0A4h,0C4h,0A3h,001h,017h
db 001h,0AFh,0C6h,0A3h,001h,015h,001h,0C2h
db 0AEh,0C6h,0A4h,001h,014h,001h,0C2h,0AEh
db 0C7h,0A1h,0C2h,001h,013h,001h,0C3h,0ADh
db 0CBh,0A1h,001h,012h,001h,0C3h,0ADh,0CAh
db 0A2h,001h,012h,001h,0C3h,0A7h,0C1h,0A5h
db 0C9h,0A3h,001h,011h,001h,0C5h,0A6h,0C1h
db 0A2h,0C1h,0A2h,0C9h,0A4h,002h,0C6h,0A3h
db 0C7h,0A2h,0C8h,0A4h,002h,0C6h,0A4h,0C7h
db 0A1h,0C9h,0A3h,002h,0C7h,0A3h,0CFh,0C3h
db 0A2h,002h,0C9h,0A2h,0CFh,0C3h,0A1h,002h
db 0CBh,0A3h,0CFh,0A1h,002h,0CBh,0A3h,0CFh
db 0C1h,002h,0CDh,0A2h,0C1h,0A3h,0CBh,001h
db 011h,001h,0CCh,0AAh,0C6h,001h,012h,001h
db 0CCh,0ABh,0C5h,001h,012h,001h,0CCh,0ABh
db 0C5h,001h,013h,001h,0CBh,0ABh,0C4h,001h
db 014h,001h,0CDh,0A7h,0C6h,001h,015h,001h
db 0CCh,0A7h,0C5h,001h,017h,001h,0CDh,0A4h
db 0C5h,001h,019h,001h,0CCh,0A3h,0C5h,001h
db 01Bh,001h,0CBh,0A3h,0C4h,001h,01Dh,002h
db 0CAh,0A2h,0C2h,002h,01Fh,011h,003h,0C8h
db 003h,01Fh,016h,008h,000h
 
wa db 1
db 01Ch,008h,01Fh,016h,00Eh,01Fh,011h,004h
db 031h,0B8h,031h,004h,01Dh,003h,0BEh,003h
db 01Bh,002h,031h,0B3h,031h,008h,031h,0B3h
db 031h,002h,019h,002h,0B5h,00Ah,0B5h,002h
db 017h,002h,0B6h,00Ah,0B6h,002h,015h,002h
db 031h,0B7h,008h,0B7h,031h,002h,014h,002h
db 0B8h,008h,0B8h,002h,013h,002h,0BAh,006h
db 0BAh,002h,012h,002h,0BAh,006h,0BAh,002h
db 012h,001h,031h,0BBh,004h,0BBh,031h,001h
db 011h,002h,0BFh,0BDh,004h,0BCh,031h,002h
db 031h,0BCh,004h,0BBh,031h,004h,031h,0BBh
db 004h,0BBh,006h,0BBh,004h,0B2h,007h,031h
db 0B1h,006h,0B1h,031h,007h,0B2h,004h,0B2h
db 008h,0B1h,031h,004h,031h,0B1h,008h,0B2h
db 004h,0B2h,008h,031h,0B1h,031h,002h,031h
db 0B1h,031h,008h,0B2h,004h,0B2h,009h,0B6h
db 009h,0B2h,002h,011h,001h,031h,0B2h,007h
db 0B8h,007h,0B2h,031h,001h,012h,002h,0B2h
db 007h,0B8h,007h,0B2h,002h,012h,002h,0B3h
db 005h,0BAh,005h,0B3h,002h,013h,002h,0B3h
db 004h,0BAh,004h,0B3h,002h,014h,002h,031h
db 0B3h,002h,0BCh,002h,0B3h,031h,002h,015h
db 002h,0BFh,0B7h,002h,017h,002h,0BFh,0B5h
db 002h,019h,002h,031h,0BFh,0B1h,031h,002h
db 01Bh,003h,0BEh,003h,01Dh,004h,031h,0B8h
db 031h,004h,01Fh,011h,00Eh,01Fh,016h,008h
db 000h
 
sword db 2
db 02Fh,02Fh,023h,003h,02Fh,02Eh,001h,072h
db 001h,02Fh,02Dh,001h,072h,0F1h,001h,02Fh
db 02Dh,001h,0F1h,071h,0F1h,001h,02Fh,02Dh
db 001h,0F3h,001h,02Fh,02Dh,001h,0F3h,001h
db 02Fh,02Dh,001h,0F3h,001h,02Fh,02Dh,001h
db 0F3h,001h,02Fh,02Dh,001h,0F2h,071h,001h
db 02Fh,02Dh,001h,073h,001h,02Fh,02Dh,001h
db 073h,001h,02Fh,02Dh,001h,073h,001h,02Fh
db 02Dh,001h,073h,001h,02Fh,02Dh,001h,073h
db 001h,02Fh,02Dh,001h,072h,081h,001h,02Fh
db 02Dh,001h,083h,001h,02Fh,02Dh,001h,083h
db 001h,02Fh,02Dh,001h,083h,001h,02Fh,02Dh
db 001h,083h,001h,024h,001h,02Fh,028h,001h
db 083h,001h,022h,001h,02Fh,02Ah,001h,083h
db 002h,02Fh,02Ch,001h,082h,002h,02Fh,02Dh
db 002h,032h,001h,02Fh,02Ch,002h,031h,011h
db 0B1h,001h,02Fh,02Ah,001h,022h,001h,0B1h
db 031h,071h,001h,02Fh,028h,001h,024h,001h
db 071h,031h,0F1h,001h,02Fh,02Dh,001h,0F3h
db 001h,02Fh,02Dh,001h,0F2h,001h,02Fh,02Eh
db 002h,000h
 
cow db 1
db 018h,004h,01Fh,01Ch,004h,01Ch,003h,01Ch
db 001h,0B2h,001h,01Eh,002h,01Bh,002h,0B1h
db 001h,01Fh,003h,01Ah,001h,0B2h,001h,01Fh
db 001h,0B1h,001h,01Ah,001h,0B2h,001h,015h
db 004h,016h,001h,0B1h,001h,01Ah,001h,0B2h
db 002h,012h,003h,0F2h,002h,014h,002h,0B1h
db 001h,01Ah,002h,0B3h,003h,0F3h,071h,0F1h
db 006h,0B2h,001h,01Bh,001h,0B4h,001h,0F1h
db 071h,0F1h,071h,0F1h,071h,0F2h,002h,0B4h
db 001h,01Bh,002h,0B3h,0F1h,071h,0F1h,071h
db 0F1h,071h,0F1h,071h,0F2h,001h,0B4h,001h
db 01Ch,001h,0B1h,004h,071h,0F1h,071h,004h
db 071h,0F1h,001h,0B2h,002h,018h,006h,0E2h
db 005h,0E2h,003h,071h,001h,0B1h,002h,017h
db 002h,0F5h,001h,0E2h,003h,0F1h,001h,0E2h
db 003h,071h,005h,016h,001h,0F3h,002h,0F2h
db 004h,0F1h,071h,0F1h,004h,072h,001h,074h
db 001h,015h,003h,0F2h,003h,071h,0F1h,071h
db 0F1h,071h,0F1h,071h,0F1h,071h,0F1h,075h
db 002h,071h,002h,017h,003h,0F1h,001h,0F1h
db 071h,0F1h,071h,0F1h,071h,0F1h,071h,0F1h
db 074h,002h,073h,002h,01Ah,001h,0F1h,071h
db 0F1h,071h,0F1h,071h,0F1h,071h,0F1h,075h
db 006h,01Ah,002h,071h,0F1h,071h,0F1h,071h
db 0F1h,071h,0F1h,071h,0F1h,074h,002h,01Eh
db 001h,071h,0F1h,071h,0F1h,071h,0F1h,071h
db 0F1h,071h,0F1h,076h,001h,01Dh,001h,071h
db 0F1h,071h,0F1h,071h,0F1h,071h,0F1h,071h
db 0F1h,071h,0F1h,074h,003h,01Ch,001h,0F1h
db 071h,0F1h,071h,0F1h,071h,0F1h,071h,0F1h
db 071h,0F1h,075h,001h,0F1h,001h,01Ch,001h
db 071h,0F1h,071h,0F1h,071h,0F1h,071h,0F1h
db 071h,0F1h,076h,001h,0F1h,001h,01Ch,001h
db 072h,0F1h,071h,0F1h,071h,0F1h,071h,0F1h
db 077h,003h,01Ch,001h,07Fh,071h,001h,0F1h
db 001h,01Ch,001h,073h,003h,072h,003h,0F1h
db 074h,001h,0F1h,001h,01Ch,002h,072h,003h
db 072h,003h,075h,003h,01Dh,002h,07Dh,001h
db 0F2h,001h,01Eh,002h,07Bh,003h,0F1h,001h
db 01Fh,003h,077h,003h,0F2h,001h,01Fh,013h
db 003h,073h,003h,0F2h,002h,01Fh,016h,009h
db 000h
 
mace db 1
db 01Fh,01Fh,01Bh,081h,01Fh,01Fh,011h,082h
db 01Ah,081h,01Fh,014h,081h,0F1h,081h,018h
db 082h,01Fh,014h,081h,0F1h,071h,085h,012h
db 081h,0F1h,081h,01Fh,013h,082h,0F1h,071h
db 081h,004h,082h,0F1h,071h,081h,01Fh,012h
db 081h,002h,082h,006h,081h,072h,081h,01Fh
db 011h,081h,00Ch,082h,01Fh,011h,081h,00Fh
db 001h,01Bh,085h,008h,082h,007h,01Bh,081h
db 0F1h,072h,081h,006h,081h,0F1h,071h,081h
db 006h,01Ch,081h,0F1h,071h,081h,006h,081h
db 072h,081h,006h,085h,017h,082h,0F1h,008h
db 082h,006h,081h,0F3h,081h,018h,081h,00Fh
db 003h,081h,072h,081h,019h,081h,005h,082h
db 00Ch,082h,01Ah,081h,004h,081h,0F1h,071h
db 081h,003h,082h,007h,01Bh,081h,004h,081h
db 072h,081h,002h,081h,072h,081h,006h,01Bh
db 082h,004h,082h,003h,081h,0F1h,071h,081h
db 006h,013h,082h,015h,081h,0F1h,071h,081h
db 009h,081h,0F1h,081h,005h,011h,083h,0B1h
db 081h,001h,013h,081h,0F1h,072h,081h,00Ah
db 082h,002h,082h,001h,081h,0B1h,004h,0B1h
db 001h,011h,086h,00Bh,081h,001h,081h,072h
db 081h,003h,013h,082h,001h,016h,004h,082h
db 007h,081h,0F1h,071h,081h,016h,081h,0B1h
db 001h,017h,002h,081h,0F1h,071h,081h,007h
db 081h,0F1h,081h,015h,082h,002h,018h,001h
db 081h,0F1h,071h,081h,006h,012h,082h,015h
db 081h,0B1h,001h,01Ah,081h,0F1h,081h,005h
db 015h,081h,013h,082h,003h,01Ah,082h,01Fh
db 081h,0B1h,001h,01Ch,081h,01Fh,081h,003h
db 01Fh,01Ch,081h,0B1h,001h,01Fh,01Eh,081h
db 002h,01Fh,01Eh,082h,001h,01Fh,01Eh,081h
db 0B1h,001h,01Fh,01Fh,001h,000h
 
cube db 1
db 01Dh,00Ah,01Fh,016h,001h,0C8h,002h,01Fh
db 015h,001h,0C8h,001h,0A1h,001h,01Fh,014h
db 001h,0C8h,001h,0A2h,001h,01Fh,013h,00Ah
db 0A3h,001h,01Fh,013h,001h,098h,001h,0A3h
db 005h,01Eh,001h,098h,001h,0A3h,001h,0C2h
db 002h,01Eh,001h,098h,001h,0A3h,001h,0C1h
db 001h,0A1h,001h,01Eh,001h,098h,001h,0A3h
db 002h,0A2h,001h,019h,006h,098h,001h,0A3h
db 00Ah,013h,001h,0C5h,001h,098h,001h,0A2h
db 001h,0C8h,002h,012h,001h,0C6h,001h,098h
db 001h,0A1h,001h,0C8h,001h,0A1h,001h,011h
db 001h,0C7h,001h,098h,002h,0C8h,001h,0A2h
db 00Fh,00Eh,0A3h,002h,097h,001h,0C8h,002h
db 098h,001h,0A3h,002h,096h,001h,0C8h,001h
db 0A1h,001h,098h,001h,0A3h,002h,095h,001h
db 0C8h,001h,0A2h,001h,098h,001h,0A3h,002h
db 094h,00Ah,0A3h,001h,098h,001h,0A3h,002h
db 094h,001h,098h,001h,0A3h,001h,098h,001h
db 0A3h,002h,094h,001h,098h,001h,0A3h,001h
db 098h,001h,0A2h,001h,011h,001h,094h,001h
db 098h,001h,0A3h,001h,098h,001h,0A1h,001h
db 012h,001h,094h,001h,098h,001h,0A3h,001h
db 098h,002h,013h,006h,098h,001h,0A3h,00Ah
db 019h,001h,098h,001h,0A2h,002h,0A3h,001h
db 01Eh,001h,098h,001h,0A1h,001h,091h,001h
db 0A3h,001h,01Eh,001h,098h,002h,092h,001h
db 0A3h,001h,01Eh,00Ah,093h,001h,0A3h,001h
db 01Fh,013h,001h,098h,001h,0A3h,001h,01Fh
db 013h,001h,098h,001h,0A2h,001h,01Fh,014h
db 001h,098h,001h,0A1h,001h,01Fh,015h,001h
db 098h,002h,01Fh,016h,00Ah,000h
 
ball db 1
db 01Fh,01Fh,01Eh,082h,004h,081h,01Fh,018h
db 083h,008h,01Fh,014h,082h,0F2h,071h,0F1h
db 071h,081h,001h,084h,002h,01Fh,011h,082h
db 0F4h,071h,0F1h,071h,0F1h,071h,0F1h,071h
db 083h,001h,01Eh,081h,001h,0F6h,071h,0F1h
db 071h,0F1h,071h,0F1h,071h,083h,001h,01Ch
db 081h,002h,0F7h,071h,0F1h,071h,0F1h,073h
db 083h,001h,01Bh,002h,081h,0F5h,071h,081h
db 0F1h,071h,0F1h,073h,081h,071h,081h,002h
db 01Ah,081h,001h,081h,0F5h,081h,002h,081h
db 0F1h,071h,0F1h,073h,082h,003h,019h,081h
db 001h,0F4h,071h,081h,004h,081h,0F1h,073h
db 081h,071h,004h,019h,081h,071h,0F4h,081h
db 006h,081h,072h,081h,071h,081h,005h,017h
db 081h,071h,0F5h,071h,006h,081h,073h,082h
db 005h,017h,081h,0F1h,071h,0F3h,071h,0F1h
db 006h,081h,072h,081h,071h,081h,005h,017h
db 081h,071h,0F3h,071h,0F1h,071h,081h,004h
db 081h,072h,081h,071h,083h,004h,017h,081h
db 0F1h,071h,0F1h,071h,0F1h,071h,0F1h,072h
db 083h,074h,085h,001h,081h,001h,017h,082h
db 0F1h,071h,0F1h,071h,0F1h,079h,081h,071h
db 086h,001h,017h,083h,072h,0F1h,077h,081h
db 071h,081h,071h,087h,001h,018h,081h,003h
db 079h,081h,071h,087h,001h,019h,081h,003h
db 076h,081h,071h,081h,071h,081h,071h,086h
db 001h,01Ah,004h,074h,081h,071h,081h,071h
db 004h,084h,001h,01Bh,081h,003h,071h,081h
db 071h,081h,071h,081h,071h,006h,083h,001h
db 01Ch,081h,002h,081h,071h,081h,071h,081h
db 071h,007h,082h,001h,01Eh,001h,081h,071h
db 081h,071h,081h,071h,081h,006h,082h,001h
db 01Fh,011h,002h,071h,081h,071h,082h,005h
db 081h,002h,021h,0A1h,01Dh,0A4h,002h,087h
db 002h,024h,0A1h,01Ah,0A6h,022h,007h,025h
db 0A1h,021h,0A1h,018h,0A7h,021h,0A1h,02Bh
db 081h,021h,0A2h,018h,0A8h,021h,0A1h,021h
db 0A1h,021h,081h,021h,081h,021h,081h,021h
db 0A1h,021h,0A1h,021h,0A1h,019h,0A8h,021h
db 0A1h,021h,0A1h,021h,0A1h,021h,0A1h,021h
db 0A1h,021h,0A1h,021h,0A1h,01Ch,0A9h,021h
db 0A1h,021h,0A1h,021h,0A1h,021h,0A1h,021h
db 0A1h,01Fh,011h,0AEh,000h
 
dish db 1
db 019h,091h,01Fh,01Ch,091h,013h,091h,01Dh
db 084h,01Bh,091h,012h,091h,01Bh,082h,0F3h
db 071h,001h,018h,091h,012h,091h,01Bh,082h
db 0F2h,083h,0F1h,001h,019h,091h,013h,082h
db 017h,081h,0F2h,085h,0F1h,001h,01Ah,091h
db 011h,082h,0F1h,001h,015h,081h,0F1h,086h
db 0F1h,002h,017h,092h,013h,083h,0F1h,001h
db 013h,081h,0F1h,087h,0F1h,002h,01Ah,091h
db 012h,005h,011h,081h,0F1h,087h,0F1h,001h
db 081h,001h,019h,091h,017h,002h,0F1h,088h
db 0F1h,001h,081h,001h,018h,091h,018h,003h
db 087h,0F1h,001h,082h,001h,01Fh,011h,081h
db 0F1h,081h,002h,086h,0F1h,001h,081h,001h
db 01Fh,011h,081h,0F1h,083h,002h,084h,0F1h
db 001h,082h,001h,01Fh,081h,0F1h,085h,002h
db 082h,0F1h,001h,083h,001h,01Eh,081h,0F1h
db 087h,002h,0F1h,001h,081h,071h,081h,001h
db 01Eh,081h,0F1h,089h,0F1h,001h,081h,072h
db 081h,001h,01Dh,081h,0F1h,089h,0F1h,001h
db 081h,072h,082h,001h,01Dh,081h,0F1h,088h
db 0F1h,001h,081h,073h,081h,001h,01Dh,081h
db 0F1h,088h,0F1h,001h,081h,074h,081h,003h
db 01Ah,081h,0F1h,088h,0F1h,001h,081h,074h
db 081h,002h,071h,081h,001h,019h,081h,0F1h
db 087h,0F1h,001h,081h,074h,081h,002h,072h
db 081h,001h,018h,081h,0F1h,087h,0F1h,001h
db 081h,074h,081h,002h,072h,082h,001h,018h
db 081h,0F1h,085h,0F2h,001h,081h,073h,081h
db 003h,073h,081h,001h,01Ah,081h,0F5h,002h
db 072h,081h,004h,074h,081h,001h,01Ch,00Ah
db 012h,001h,073h,082h,001h,01Fh,019h,001h
db 072h,083h,001h,01Fh,019h,001h,085h,001h
db 01Fh,019h,001h,085h,001h,01Fh,014h,085h
db 00Ch,01Eh,081h,0F1h,07Fh,081h,001h,01Ch
db 001h,08Fh,084h,001h,01Ch,00Fh,004h,000h
 
flag db 1
db 01Fh,01Fh,01Fh,01Fh,01Fh,012h,006h,01Fh
db 019h,009h,01Fh,016h,007h,0F2h,004h,01Fh
db 013h,008h,0F3h,003h,016h,002h,018h,003h
db 0F1h,006h,0F5h,004h,013h,002h,015h,004h
db 0F3h,006h,0F6h,008h,015h,002h,0F5h,006h
db 0F6h,008h,015h,007h,0F6h,006h,0F6h,002h
db 015h,007h,0F6h,006h,0F6h,002h,015h,007h
db 0F6h,006h,0F6h,002h,015h,007h,0F6h,006h
db 0F6h,002h,015h,007h,0F6h,006h,0F6h,002h
db 015h,007h,0F6h,006h,0F6h,002h,015h,002h
db 0F5h,006h,0F6h,008h,015h,002h,0F5h,006h
db 0F6h,008h,015h,002h,0F5h,009h,0F3h,008h
db 015h,002h,0F3h,00Dh,0F1h,008h,015h,002h
db 0F2h,006h,016h,00Bh,015h,006h,01Bh,004h
db 0F4h,002h,015h,004h,01Eh,009h,015h,003h
db 01Fh,012h,007h,01Fh,01Fh,002h,01Fh,01Fh
db 002h,01Fh,01Fh,002h,01Fh,01Fh,002h,01Fh
db 01Fh,002h,01Fh,01Fh,002h,01Fh,01Fh,002h
db 000h
 
apple db 4
db 04Fh,04Fh,04Fh,04Fh,04Ah,024h,04Fh,04Ah
db 023h,0A1h,021h,082h,001h,04Fh,04Ah,021h
db 0A3h,021h,081h,021h,001h,04Fh,04Ah,023h
db 0A2h,022h,001h,04Fh,04Ah,022h,0A1h,021h
db 082h,001h,043h,031h,001h,04Fh,047h,021h
db 0A1h,082h,021h,001h,041h,031h,0B1h,001h
db 04Fh,048h,022h,0A1h,021h,002h,0B1h,001h
db 04Fh,04Bh,023h,031h,071h,001h,015h,04Fh
db 044h,012h,092h,011h,031h,071h,001h,093h
db 014h,04Fh,041h,011h,091h,0F1h,071h,091h
db 012h,002h,0D2h,071h,092h,012h,001h,04Eh
db 011h,091h,0F1h,073h,0D7h,072h,091h,012h
db 001h,04Ch,011h,091h,0F3h,092h,077h,094h
db 012h,001h,04Bh,011h,091h,0F1h,091h,0F1h
db 071h,09Dh,011h,001h,04Bh,011h,091h,0F1h
db 092h,073h,09Bh,011h,001h,04Ch,013h,09Fh
db 012h,001h,04Bh,031h,071h,0F1h,012h,09Dh
db 012h,001h,04Ch,031h,071h,0F1h,0B1h,011h
db 09Ch,012h,001h,04Ch,031h,071h,0B1h,071h
db 011h,09Ch,012h,001h,04Dh,031h,071h,0F1h
db 071h,011h,09Bh,012h,001h,04Dh,031h,071h
db 0B1h,071h,011h,09Bh,012h,001h,04Dh,031h
db 071h,0F1h,071h,011h,09Bh,012h,001h,04Dh
db 031h,071h,0B1h,071h,011h,09Bh,011h,001h
db 04Dh,031h,071h,0F1h,071h,011h,09Ch,011h
db 001h,04Ch,031h,073h,011h,09Ch,011h,001h
db 04Dh,014h,09Dh,011h,001h,04Eh,011h,09Eh
db 011h,001h,04Fh,041h,011h,09Bh,012h,001h
db 04Fh,043h,012h,098h,011h,002h,04Fh,046h
db 009h,000h
 
ok db 1
db 01Fh,01Fh,01Eh,007h,01Fh,017h,003h,027h
db 003h,01Fh,012h,002h,02Dh,002h,01Eh,001h
db 02Fh,022h,001h,01Ch,001h,02Fh,024h,001h
db 01Ah,001h,02Fh,026h,001h,018h,001h,02Fh
db 028h,001h,017h,001h,02Fh,028h,001h,081h
db 015h,001h,02Fh,021h,0F4h,025h,001h,081h
db 014h,001h,02Fh,071h,0F3h,071h,025h,001h
db 081h,014h,001h,02Fh,0F4h,026h,001h,082h
db 012h,001h,02Fh,071h,0F3h,071h,027h,001h
db 081h,012h,001h,02Fh,0F4h,028h,001h,081h
db 012h,001h,02Eh,071h,0F3h,071h,028h,001h
db 082h,011h,001h,02Eh,0F4h,029h,001h,082h
db 011h,001h,027h,0F3h,071h,022h,071h,0F3h
db 071h,029h,001h,082h,011h,001h,027h,071h
db 0F3h,071h,021h,0F4h,02Ah,001h,082h,011h
db 001h,028h,071h,0F3h,071h,0F3h,071h,02Ah
db 001h,082h,012h,001h,028h,071h,0F6h,02Ah
db 001h,083h,012h,001h,029h,071h,0F4h,071h
db 02Ah,001h,083h,012h,001h,02Ah,071h,0F3h
db 02Bh,001h,082h,014h,001h,02Ah,071h,0F1h
db 071h,02Ah,001h,083h,014h,001h,02Fh,028h
db 001h,083h,015h,001h,02Fh,026h,001h,083h
db 017h,001h,02Fh,024h,001h,084h,018h,001h
db 02Fh,022h,001h,084h,01Ah,002h,02Dh,002h
db 084h,01Ch,081h,003h,027h,003h,085h,01Eh
db 083h,007h,087h,01Fh,012h,08Dh,01Fh,017h
db 087h,000h
 
speaker db 1
db 016h,08Fh,084h,01Ch,08Fh,086h,01Ah,081h
db 07Fh,076h,081h,019h,081h,071h,008h,083h
db 009h,081h,019h,081h,071h,007h,081h,003h
db 081h,008h,081h,019h,081h,071h,006h,081h
db 005h,081h,007h,081h,019h,081h,071h,006h
db 081h,001h,081h,001h,081h,001h,081h,007h
db 081h,019h,081h,071h,006h,081h,001h,081h
db 071h,081h,001h,081h,007h,081h,019h,081h
db 071h,007h,081h,003h,081h,008h,081h,019h
db 081h,071h,008h,083h,009h,081h,019h,081h
db 071h,00Fh,005h,081h,019h,081h,071h,007h
db 081h,003h,081h,008h,081h,019h,081h,071h
db 006h,081h,005h,081h,007h,081h,019h,081h
db 071h,006h,081h,001h,081h,001h,081h,001h
db 081h,007h,081h,019h,081h,071h,006h,081h
db 001h,081h,071h,081h,001h,081h,007h,081h
db 019h,081h,071h,007h,081h,003h,081h,008h
db 081h,019h,081h,071h,008h,083h,009h,081h
db 019h,081h,071h,00Fh,005h,081h,019h,081h
db 071h,005h,089h,006h,081h,019h,081h,071h
db 004h,081h,009h,081h,005h,081h,019h,081h
db 071h,003h,081h,00Bh,081h,004h,081h,019h
db 081h,071h,002h,081h,005h,081h,071h,081h
db 002h,081h,002h,081h,003h,081h,019h,081h
db 071h,002h,081h,002h,081h,001h,081h,003h
db 081h,002h,081h,001h,081h,003h,081h,019h
db 081h,071h,002h,081h,001h,081h,008h,081h
db 002h,081h,003h,081h,019h,081h,071h,002h
db 081h,002h,083h,003h,082h,001h,081h,001h
db 081h,003h,081h,019h,081h,071h,002h,081h
db 001h,082h,072h,081h,002h,072h,081h,002h
db 081h,003h,081h,019h,081h,071h,002h,081h
db 001h,081h,071h,0F1h,071h,003h,081h,0F1h
db 071h,081h,001h,081h,003h,081h,019h,081h
db 071h,003h,081h,001h,0F1h,071h,081h,004h
db 071h,0F1h,001h,081h,004h,081h,019h,081h
db 071h,004h,081h,009h,081h,005h,081h,019h
db 081h,071h,005h,089h,006h,081h,019h,081h
db 071h,00Fh,005h,081h,019h,08Fh,088h,000h
 
print db 1
db 01Fh,01Fh,01Fh,01Fh,01Dh,00Fh,001h,01Fh
db 011h,001h,0FEh,001h,01Fh,082h,0FDh,082h
db 01Fh,001h,0F2h,0C3h,0F9h,001h,01Fh,011h
db 001h,0FEh,001h,01Fh,011h,001h,0F2h,0C9h
db 0F3h,001h,01Ch,005h,0FEh,005h,014h,002h
db 011h,001h,074h,001h,0F2h,0CAh,0F2h,001h
db 081h,073h,001h,011h,003h,0F1h,002h,0F4h
db 001h,0FEh,001h,071h,0F3h,002h,0F1h,002h
db 0F1h,081h,001h,082h,005h,0F3h,084h,0F3h
db 005h,082h,001h,081h,0F1h,002h,081h,002h
db 081h,001h,0F1h,0B1h,0F1h,0B1h,0F1h,001h
db 0F1h,081h,0F4h,081h,0F1h,001h,0B1h,0F1h
db 0B1h,0F1h,031h,001h,081h,002h,081h,003h
db 011h,002h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,001h,076h,001h,0B1h,0F1h,0B1h,0F1h
db 0B1h,0F1h,031h,002h,011h,002h,013h,002h
db 0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h
db 006h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 031h,002h,017h,001h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,031h,001h,018h,001h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,031h,001h,018h,001h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,031h,001h,018h,001h,0B1h
db 0F1h,001h,0F2h,001h,0F2h,001h,0F2h,001h
db 0F2h,001h,0F2h,001h,0F2h,001h,031h,001h
db 017h,001h,0B1h,00Fh,006h,0B1h,031h,001h
db 015h,001h,0B1h,0F2h,001h,0F2h,001h,0F2h
db 001h,0F2h,001h,0F2h,001h,0F2h,001h,0F2h
db 001h,0F2h,001h,031h,001h,013h,001h,0B1h
db 0F1h,00Fh,009h,0B1h,031h,001h,011h,001h
db 0B1h,0F3h,001h,0F2h,001h,0F2h,001h,0F2h
db 001h,0F2h,001h,0F2h,001h,0F2h,001h,0F2h
db 001h,0F2h,001h,031h,002h,0F1h,0B1h,00Fh
db 00Ch,031h,002h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 031h,002h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,0B1h,0F1h,031h
db 002h,03Fh,03Fh,001h,011h,00Fh,00Fh,012h
db 001h,0F1h,082h,001h,01Fh,013h,001h,0F1h
db 082h,001h,015h,003h,01Fh,015h,003h,000h
 
light db 1
db 01Dh,086h,01Fh,019h,082h,0F5h,071h,081h
db 001h,01Fh,016h,081h,071h,0B3h,0F4h,071h
db 081h,001h,01Fh,014h,081h,071h,0B2h,0F7h
db 071h,081h,001h,01Fh,012h,081h,071h,0B1h
db 0F9h,071h,082h,001h,01Fh,081h,071h,0B1h
db 0F1h,0B2h,0F7h,0B1h,071h,082h,001h,01Eh
db 081h,071h,0B1h,0F1h,0B2h,0F8h,0B1h,071h
db 081h,001h,081h,01Ch,081h,071h,0F1h,0B1h
db 0F1h,0B6h,0F4h,0B1h,071h,082h,001h,01Ch
db 081h,071h,0B3h,0F1h,0B1h,0F8h,0B1h,071h
db 082h,001h,01Ch,081h,071h,0B1h,0F1h,0B1h
db 0FAh,0B1h,071h,082h,001h,01Ch,081h,071h
db 0B1h,0F1h,0B1h,0FBh,071h,082h,001h,01Ch
db 081h,071h,0B1h,0F1h,0B1h,0FBh,071h,082h
db 001h,01Ch,081h,071h,0F2h,0B1h,0FBh,071h
db 082h,001h,01Ch,081h,071h,0F2h,0B1h,072h
db 081h,0F5h,081h,0F2h,071h,082h,001h,01Dh
db 081h,071h,0F1h,0B1h,081h,0F2h,081h,0F3h
db 082h,0F1h,071h,082h,001h,01Fh,081h,071h
db 0F1h,081h,0F1h,0B1h,081h,0F3h,082h,0F1h
db 071h,081h,001h,081h,01Fh,081h,071h,0F1h
db 081h,0F1h,0B1h,081h,0F3h,071h,081h,071h
db 082h,001h,01Fh,012h,081h,072h,082h,0F1h
db 071h,081h,071h,081h,0F1h,071h,081h,001h
db 01Fh,014h,081h,071h,0F3h,081h,0F1h,081h
db 0F1h,071h,081h,001h,01Fh,016h,081h,071h
db 0F1h,082h,0F2h,071h,081h,001h,01Fh,017h
db 081h,071h,0F2h,071h,081h,0F1h,071h,081h
db 001h,01Fh,018h,081h,071h,0F1h,081h,0F1h
db 071h,081h,001h,01Fh,019h,081h,071h,0F1h
db 081h,0F1h,071h,081h,001h,01Fh,019h,081h
db 071h,0F1h,081h,0F1h,071h,081h,001h,01Fh
db 019h,081h,071h,0F1h,081h,0F1h,071h,081h
db 001h,01Fh,019h,031h,071h,0F1h,081h,0F1h
db 071h,081h,001h,01Fh,019h,033h,0F2h,071h
db 002h,01Fh,019h,031h,0F1h,0B1h,003h,031h
db 001h,01Fh,019h,031h,0B1h,031h,0B1h,071h
db 031h,002h,01Fh,019h,031h,0F1h,0B1h,031h
db 002h,031h,001h,01Fh,01Ah,001h,031h,0B1h
db 071h,031h,001h,01Fh,01Ch,004h,000h
 
foto db 1
db 01Fh,01Fh,01Fh,01Fh,01Fh,01Fh,01Fh,01Fh
db 01Fh,017h,004h,01Fh,01Ch,001h,0F3h,081h
db 001h,01Fh,014h,002h,081h,013h,001h,074h
db 001h,081h,001h,012h,004h,081h,019h,002h
db 0F1h,081h,004h,076h,004h,0F3h,081h,003h
db 016h,001h,071h,003h,081h,072h,001h,086h
db 001h,081h,071h,005h,081h,072h,001h,014h
db 001h,0FFh,0F9h,071h,081h,001h,013h,001h
db 0F1h,07Fh,079h,082h,001h,013h,001h,0F1h
db 079h,005h,07Ah,082h,001h,013h,001h,0F1h
db 077h,002h,074h,0F1h,002h,078h,081h,002h
db 013h,009h,081h,0F5h,073h,00Bh,013h,001h
db 082h,001h,081h,001h,081h,001h,081h,075h
db 0F2h,071h,082h,001h,081h,001h,081h,001h
db 081h,002h,081h,001h,013h,001h,081h,001h
db 081h,001h,081h,001h,072h,005h,072h,082h
db 001h,081h,001h,081h,001h,081h,001h,081h
db 003h,013h,001h,082h,001h,081h,001h,071h
db 081h,001h,085h,001h,081h,071h,001h,081h
db 003h,081h,001h,081h,002h,081h,001h,013h
db 001h,081h,001h,081h,001h,081h,071h,001h
db 082h,071h,0F1h,071h,082h,001h,071h,081h
db 003h,081h,001h,081h,001h,081h,003h,013h
db 001h,082h,002h,071h,001h,082h,071h,0F1h
db 085h,001h,071h,004h,081h,001h,081h,002h
db 081h,001h,013h,001h,081h,001h,081h,001h
db 071h,001h,082h,0F1h,071h,085h,001h,071h
db 003h,081h,001h,081h,001h,081h,003h,013h
db 001h,082h,002h,071h,001h,082h,0F1h,086h
db 001h,071h,004h,081h,001h,081h,002h,081h
db 001h,013h,001h,081h,001h,081h,001h,071h
db 001h,082h,071h,086h,001h,071h,003h,081h
db 001h,081h,001h,081h,003h,013h,001h,082h
db 002h,071h,001h,089h,001h,071h,002h,081h
db 001h,081h,001h,081h,002h,081h,001h,013h
db 001h,081h,001h,081h,001h,081h,071h,001h
db 087h,001h,071h,081h,001h,081h,001h,081h
db 001h,081h,001h,081h,003h,013h,001h,082h
db 001h,081h,001h,071h,081h,001h,085h,001h
db 081h,071h,001h,081h,001h,081h,001h,081h
db 001h,081h,003h,015h,002h,081h,001h,081h
db 001h,072h,005h,072h,001h,081h,001h,081h
db 001h,081h,001h,081h,001h,081h,001h,017h
db 006h,081h,075h,081h,00Bh,01Eh,081h,005h
db 081h,000h
 
flop db 1
db 011h,00Fh,00Dh,013h,001h,073h,001h,0FFh
db 0F5h,001h,073h,001h,012h,001h,073h,001h
db 0FFh,0F5h,001h,073h,001h,081h,011h,001h
db 073h,001h,0FFh,0F5h,001h,071h,001h,071h
db 001h,082h,001h,073h,001h,0FFh,0F5h,001h
db 071h,001h,071h,001h,082h,001h,073h,001h
db 0FFh,0F5h,001h,073h,001h,082h,001h,073h
db 001h,0FFh,0F5h,001h,073h,001h,082h,001h
db 073h,001h,0FFh,0F5h,001h,073h,001h,082h
db 001h,073h,001h,0FFh,0F5h,001h,073h,001h
db 082h,001h,073h,001h,0FFh,0F5h,001h,073h
db 001h,082h,001h,073h,001h,0FFh,0F5h,001h
db 073h,001h,082h,001h,073h,001h,0FFh,0F5h
db 001h,073h,001h,082h,001h,073h,001h,0FFh
db 0F5h,001h,073h,001h,082h,001h,073h,001h
db 0FFh,0F5h,001h,073h,001h,082h,001h,073h
db 001h,0FFh,0F5h,001h,073h,001h,082h,001h
db 073h,001h,0FFh,0F5h,001h,073h,001h,082h
db 001h,073h,00Fh,007h,073h,001h,082h,001h
db 07Fh,07Dh,001h,082h,001h,07Fh,07Dh,001h
db 082h,001h,07Fh,07Dh,001h,082h,001h,077h
db 00Fh,003h,073h,001h,082h,001h,077h,001h
db 08Ch,001h,073h,001h,073h,001h,082h,001h
db 077h,001h,082h,004h,086h,001h,073h,001h
db 073h,001h,082h,001h,077h,001h,082h,001h
db 072h,001h,086h,001h,073h,001h,073h,001h
db 082h,001h,077h,001h,082h,001h,072h,001h
db 086h,001h,073h,001h,073h,001h,082h,001h
db 077h,001h,082h,001h,072h,001h,086h,001h
db 073h,001h,073h,001h,082h,001h,077h,001h
db 082h,001h,072h,001h,086h,001h,073h,001h
db 073h,001h,082h,001h,077h,001h,082h,004h
db 086h,001h,073h,001h,073h,001h,082h,011h
db 001h,076h,001h,08Ch,001h,073h,001h,073h
db 001h,082h,012h,00Fh,00Ch,083h,012h,08Fh
db 08Fh,013h,08Fh,08Dh,000h
 
pillar db 1
db 016h,08Fh,084h,01Bh,082h,0FFh,0F4h,082h
db 018h,081h,0F2h,073h,0F1h,071h,0F1h,071h
db 0F1h,071h,0F1h,071h,0F1h,071h,0F1h,071h
db 0F1h,075h,001h,017h,081h,0F1h,071h,083h
db 07Dh,083h,0F1h,071h,001h,016h,081h,0F1h
db 071h,081h,0F3h,001h,071h,081h,071h,081h
db 071h,081h,071h,081h,071h,081h,071h,001h
db 0F3h,081h,0F1h,071h,001h,015h,081h,0F1h
db 071h,081h,073h,0F1h,001h,089h,001h,071h
db 0F1h,072h,081h,0F1h,071h,001h,015h,081h
db 0F1h,071h,081h,071h,0F1h,081h,0F1h,00Bh
db 0F1h,081h,072h,081h,0F1h,071h,001h,016h
db 081h,0F1h,071h,082h,071h,0F1h,001h,0F7h
db 072h,001h,071h,0F1h,082h,0F1h,071h,001h
db 017h,081h,0F1h,071h,0F2h,071h,0F1h,001h
db 071h,081h,0F1h,071h,081h,0F1h,071h,081h
db 071h,001h,072h,0F2h,072h,001h,018h,001h
db 0F1h,073h,001h,0F1h,071h,081h,0F1h,071h
db 081h,0F1h,071h,081h,071h,081h,001h,074h
db 001h,01Ah,004h,081h,0F1h,071h,081h,0F1h
db 071h,081h,0F1h,071h,081h,071h,081h,005h
db 01Fh,081h,0F1h,071h,081h,0F1h,071h,081h
db 0F1h,071h,081h,071h,081h,001h,01Fh,014h
db 081h,0F1h,071h,081h,0F1h,071h,081h,0F1h
db 071h,081h,071h,081h,001h,01Fh,014h,081h
db 0F1h,071h,081h,0F1h,071h,081h,0F1h,071h
db 081h,071h,081h,001h,01Fh,014h,081h,0F1h
db 071h,081h,0F1h,071h,081h,0F1h,071h,081h
db 071h,081h,001h,01Fh,014h,081h,0F1h,071h
db 081h,0F1h,071h,081h,0F1h,071h,081h,071h
db 081h,001h,01Fh,014h,081h,0F1h,071h,081h
db 0F1h,071h,081h,0F1h,071h,081h,071h,081h
db 001h,01Fh,014h,081h,0F1h,071h,081h,0F1h
db 071h,081h,0F1h,071h,081h,071h,081h,001h
db 01Fh,014h,081h,0F1h,071h,081h,0F1h,071h
db 081h,0F1h,071h,081h,071h,081h,001h,01Fh
db 014h,081h,0F1h,071h,081h,0F1h,071h,081h
db 0F1h,071h,081h,071h,081h,001h,01Fh,014h
db 081h,0F1h,071h,081h,0F1h,071h,081h,0F1h
db 071h,081h,071h,081h,001h,01Fh,014h,081h
db 0F1h,071h,081h,0F1h,071h,081h,0F1h,071h
db 081h,071h,081h,001h,01Fh,014h,081h,0F1h
db 071h,081h,0F1h,071h,081h,0F1h,071h,081h
db 071h,081h,001h,01Fh,014h,081h,0F1h,071h
db 081h,0F1h,071h,081h,0F1h,071h,081h,071h
db 081h,001h,01Fh,014h,081h,0F1h,071h,081h
db 0F1h,071h,081h,0F1h,071h,081h,071h,081h
db 001h,01Fh,014h,081h,0F1h,071h,081h,0F1h
db 071h,081h,0F1h,071h,081h,071h,081h,001h
db 01Fh,014h,081h,0F1h,071h,081h,0F1h,071h
db 081h,0F1h,071h,081h,071h,081h,001h,01Fh
db 012h,08Fh,081h,001h,01Eh,081h,0F3h,07Eh
db 001h,01Ch,08Fh,084h,002h,01Ah,081h,0F2h
db 07Fh,073h,081h,001h,019h,00Fh,008h,000h
 
newspaper db 1
db 01Fh,01Fh,01Fh,01Fh,01Fh,01Fh,01Fh,013h
db 003h,01Fh,01Dh,001h,0F3h,002h,01Fh,01Ah
db 001h,0F2h,001h,0F3h,002h,01Fh,017h,001h
db 0F2h,002h,0F1h,001h,0F3h,002h,01Fh,014h
db 001h,0F2h,001h,0F1h,002h,0F2h,001h,081h
db 0F2h,002h,01Fh,011h,001h,0F2h,001h,0F2h
db 001h,0F2h,001h,0F1h,081h,001h,0F3h,002h
db 01Dh,001h,0F1h,071h,0F3h,001h,0F2h,001h
db 071h,001h,0F2h,001h,0F4h,002h,01Ah,001h
db 0F2h,081h,001h,081h,0F3h,001h,081h,0F3h
db 001h,0F1h,081h,0F1h,081h,0F3h,002h,017h
db 001h,0F1h,071h,0F3h,081h,001h,071h,0F2h
db 071h,001h,0F1h,001h,0F1h,082h,0F1h,001h
db 0F1h,001h,081h,0F2h,002h,014h,001h,0F2h
db 081h,001h,081h,0F3h,071h,001h,081h,0F3h
db 003h,0F1h,001h,0F1h,001h,0F1h,081h,001h
db 0F3h,001h,012h,001h,0F1h,071h,0F3h,081h
db 001h,071h,0F3h,081h,001h,081h,0F3h,002h
db 0F3h,001h,0F4h,001h,071h,011h,001h,0F2h
db 081h,001h,081h,0F3h,071h,001h,081h,0F3h
db 071h,0F1h,001h,0F3h,001h,081h,0F1h,001h
db 0F3h,001h,071h,002h,081h,071h,0F3h,081h
db 001h,071h,0F3h,081h,001h,081h,0F2h,001h
db 0F1h,002h,0F2h,081h,001h,0F3h,001h,071h
db 001h,071h,001h,0F1h,081h,001h,081h,0F3h
db 071h,001h,081h,0F3h,071h,0F1h,001h,071h
db 0F3h,002h,0F4h,001h,071h,001h,071h,002h
db 0F3h,081h,001h,071h,0F3h,081h,001h,081h
db 0F2h,001h,074h,0F3h,001h,0F2h,001h,071h
db 001h,071h,001h,071h,001h,071h,001h,081h
db 0F2h,071h,001h,081h,0F3h,071h,0F1h,001h
db 083h,074h,001h,0F2h,001h,071h,001h,071h
db 001h,071h,002h,081h,072h,001h,081h,0F2h
db 081h,001h,081h,0F3h,002h,084h,071h,001h
db 0F2h,001h,071h,001h,071h,001h,071h,001h
db 012h,002h,081h,073h,081h,0F2h,081h,072h
db 0F3h,002h,082h,001h,0F2h,001h,071h,001h
db 071h,001h,071h,001h,015h,002h,081h,072h
db 001h,081h,0F2h,071h,001h,081h,0F3h,002h
db 0F2h,001h,071h,001h,071h,001h,071h,001h
db 018h,002h,081h,072h,001h,081h,0F2h,081h
db 001h,081h,0F4h,001h,071h,001h,071h,001h
db 071h,001h,01Bh,002h,081h,071h,0F1h,071h
db 081h,0F2h,081h,001h,0F2h,001h,071h,001h
db 071h,001h,071h,001h,01Eh,002h,081h,071h
db 081h,001h,081h,0F3h,001h,071h,001h,071h
db 001h,071h,001h,01Fh,012h,002h,081h,072h
db 001h,0F1h,001h,071h,001h,071h,001h,071h
db 001h,01Fh,015h,002h,081h,072h,001h,071h
db 002h,071h,001h,01Fh,018h,002h,081h,001h
db 081h,072h,001h,01Fh,01Bh,005h,000h
 
umbrella db 1
db 01Fh,01Fh,01Fh,036h,01Fh,018h,033h,0F6h
db 032h,01Fh,014h,032h,0F3h,0B1h,0F1h,0B1h
db 0F1h,0B1h,0F1h,0B1h,0F1h,032h,015h,082h
db 019h,031h,0F2h,0B1h,0F1h,0B1h,0F1h,0B1h
db 0F1h,0B3h,032h,0B2h,032h,012h,081h,001h
db 081h,018h,038h,0F1h,0B2h,032h,0B6h,032h
db 001h,01Ah,03Bh,0B7h,031h,0B1h,071h,001h
db 01Ah,03Dh,0B4h,031h,0B3h,071h,001h,019h
db 03Eh,0B2h,031h,0B4h,071h,001h,019h,034h
db 0B1h,071h,0B1h,071h,0B1h,071h,0B1h,035h
db 0B6h,071h,001h,018h,032h,071h,0B1h,071h
db 0B1h,071h,0B1h,071h,0B1h,071h,0B1h,071h
db 0B1h,031h,001h,0B6h,071h,001h,019h,031h
db 0B1h,071h,0B1h,071h,0B1h,071h,0B1h,071h
db 0B1h,071h,0B1h,001h,081h,001h,031h,0B6h
db 031h,001h,018h,031h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,071h,0B1h,001h,081h
db 001h,0B1h,032h,0B4h,031h,071h,001h,019h
db 031h,071h,0B1h,071h,0B1h,071h,0B1h,071h
db 0B1h,001h,081h,001h,0B1h,071h,0B1h,032h
db 0B2h,031h,0B2h,071h,001h,018h,031h,0B1h
db 071h,0B1h,071h,0B1h,071h,0B1h,001h,081h
db 001h,0B1h,071h,0B1h,071h,034h,0B3h,071h
db 001h,019h,031h,0B1h,071h,0B1h,071h,0B1h
db 001h,081h,001h,0B1h,071h,0B1h,071h,0B1h
db 033h,0B4h,071h,001h,01Ah,031h,0B1h,071h
db 0B1h,001h,081h,001h,0B1h,071h,0B1h,071h
db 0B1h,071h,034h,0B3h,071h,001h,01Bh,031h
db 0B1h,001h,081h,001h,0B1h,071h,0B1h,071h
db 0B1h,071h,0B1h,034h,0B3h,071h,001h,01Ch
db 001h,081h,001h,0B1h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,035h,0B2h,071h,001h,01Bh
db 081h,071h,001h,0B1h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,035h,0B2h,071h,001h
db 01Ah,081h,071h,001h,011h,001h,0B1h,071h
db 0B1h,071h,0B1h,071h,0B1h,071h,035h,0B1h
db 071h,001h,01Ah,081h,071h,001h,013h,001h
db 0B1h,071h,0B1h,071h,0B1h,071h,037h,071h
db 001h,019h,081h,071h,001h,015h,002h,071h
db 0B1h,071h,038h,001h,019h,081h,071h,001h
db 018h,002h,038h,001h,015h,082h,012h,081h
db 071h,001h,01Bh,008h,015h,081h,071h,001h
db 011h,081h,071h,001h,01Fh,019h,081h,071h
db 001h,011h,081h,071h,001h,01Fh,01Ah,001h
db 071h,011h,081h,071h,001h,01Fh,01Bh,002h
db 081h,071h,001h,01Fh,01Dh,003h,000h
 
books db 0
db 00Fh,00Fh,006h,061h,021h,003h,022h,00Fh
db 009h,061h,0A1h,024h,0A1h,021h,00Eh,052h
db 003h,052h,002h,061h,0A1h,021h,071h,0F1h
db 071h,0A1h,022h,00Dh,051h,0D1h,054h,0D1h
db 051h,001h,061h,0A1h,021h,071h,0F1h,071h
db 0A1h,023h,012h,003h,012h,005h,051h,0D1h
db 051h,071h,0F1h,071h,0D1h,052h,061h,022h
db 071h,0F1h,071h,024h,011h,091h,014h,091h
db 011h,004h,051h,0D1h,051h,071h,0F1h,071h
db 0D1h,053h,061h,0A1h,027h,011h,091h,011h
db 071h,0F1h,071h,091h,012h,042h,001h,041h
db 052h,071h,0F1h,071h,055h,061h,0A1h,063h
db 023h,011h,091h,011h,071h,0F1h,071h,091h
db 011h,091h,041h,071h,043h,0D1h,059h,061h
db 0A1h,062h,023h,013h,071h,0F1h,071h,012h
db 091h,041h,071h,041h,071h,0F1h,041h,0D1h
db 059h,061h,0A1h,034h,021h,011h,081h,014h
db 091h,011h,041h,071h,041h,071h,0F1h,071h
db 041h,0D1h,059h,061h,0A1h,062h,023h,011h
db 081h,095h,011h,042h,071h,0F1h,071h,042h
db 0D1h,059h,061h,0A1h,063h,022h,011h,081h
db 095h,011h,071h,046h,0D1h,059h,061h,0A1h
db 034h,021h,011h,081h,034h,091h,011h,071h
db 046h,0D1h,059h,061h,0A1h,063h,022h,011h
db 081h,095h,011h,071h,046h,0D1h,059h,061h
db 0A1h,062h,023h,011h,081h,095h,011h,071h
db 0C4h,042h,0D1h,059h,061h,0A1h,063h,022h
db 011h,081h,034h,091h,011h,071h,046h,0D1h
db 059h,061h,0A1h,062h,023h,011h,081h,095h
db 011h,071h,0C4h,042h,0D1h,059h,061h,0A1h
db 063h,022h,011h,081h,095h,011h,071h,046h
db 0D1h,059h,061h,0A1h,062h,023h,011h,081h
db 095h,011h,071h,046h,0D1h,059h,061h,0A1h
db 063h,022h,011h,081h,095h,011h,071h,046h
db 0D1h,059h,061h,0A1h,062h,023h,011h,081h
db 095h,011h,071h,046h,0D1h,059h,061h,0A1h
db 063h,022h,011h,081h,095h,011h,071h,046h
db 0D1h,059h,061h,0A1h,062h,023h,011h,081h
db 095h,011h,071h,046h,0D1h,059h,061h,0A1h
db 063h,022h,011h,081h,095h,011h,071h,046h
db 0D1h,059h,061h,0A1h,034h,021h,011h,081h
db 034h,091h,011h,071h,046h,0D1h,059h,061h
db 0A1h,063h,022h,011h,081h,095h,011h,071h
db 0C4h,042h,0D1h,059h,061h,0A1h,062h,023h
db 011h,081h,095h,011h,071h,046h,0D1h,059h
db 061h,0A1h,034h,021h,011h,081h,034h,091h
db 011h,071h,0C4h,042h,0D1h,059h,061h,0A1h
db 063h,022h,011h,081h,095h,011h,071h,046h
db 0D1h,058h,001h,061h,0A1h,062h,023h,011h
db 081h,095h,011h,071h,046h,0D1h,057h,003h
db 026h,001h,016h,001h,046h,001h,056h,000h
 
paint db 6
db 06Fh,06Fh,069h,008h,06Fh,067h,002h,071h
db 0F6h,071h,002h,06Fh,064h,001h,0F3h,071h
db 0B1h,071h,0B1h,071h,0B1h,072h,031h,001h
db 06Fh,062h,001h,0F1h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,071h,0B1h,071h,0B1h
db 031h,001h,06Bh,001h,063h,001h,0F1h,071h
db 0B1h,071h,0B1h,0D6h,071h,0B1h,071h,0B1h
db 031h,001h,06Ah,002h,062h,001h,0F1h,0B1h
db 071h,0B1h,071h,0B1h,0D6h,051h,0B1h,071h
db 031h,001h,06Ah,002h,061h,001h,071h,0F1h
db 071h,0B1h,071h,0B1h,0D7h,051h,071h,0B1h
db 071h,031h,001h,068h,001h,0F1h,001h,061h
db 001h,0F1h,071h,0B1h,071h,0B1h,071h,0B1h
db 051h,0D6h,051h,071h,0B1h,031h,001h,067h
db 001h,0F1h,002h,061h,001h,0F1h,0B1h,071h
db 0B1h,071h,0B1h,071h,0B1h,052h,0D3h,052h
db 0B1h,071h,0B1h,031h,001h,066h,004h,061h
db 001h,0F1h,071h,0B1h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,054h,0B1h,071h,0B1h,071h
db 031h,001h,065h,004h,061h,001h,0F1h,071h
db 0B1h,071h,0A1h,021h,0A1h,071h,0B1h,071h
db 0B1h,071h,0B1h,071h,0B1h,071h,0B1h,071h
db 0B1h,071h,031h,001h,063h,001h,0F1h,001h
db 063h,001h,0F1h,0B1h,071h,0A1h,021h,0A1h
db 021h,0A1h,021h,0B1h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,071h,0B1h,071h,031h
db 001h,061h,001h,0F1h,001h,064h,001h,0F1h
db 071h,0B1h,021h,0A1h,021h,0A1h,021h,0A1h
db 021h,0B1h,071h,0B1h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,071h,031h,001h,0F1h
db 001h,065h,001h,0F1h,0B1h,021h,0A1h,021h
db 0A1h,021h,0A1h,022h,071h,0B1h,071h,0B1h
db 071h,0B1h,072h,033h,071h,001h,0C1h,002h
db 065h,001h,0F1h,071h,022h,0A1h,021h,0A1h
db 022h,071h,0B1h,071h,0B1h,071h,0B1h,072h
db 031h,004h,0C1h,001h,082h,001h,064h,001h
db 0F1h,0B1h,071h,025h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,031h,001h,062h,001h
db 0C1h,002h,081h,071h,031h,001h,063h,001h
db 0F1h,071h,0B1h,071h,0B1h,071h,0B1h,071h
db 0B1h,071h,0B1h,071h,0B1h,071h,0B1h,071h
db 031h,001h,061h,001h,0C1h,001h,061h,001h
db 073h,031h,001h,062h,001h,0F1h,0B1h,071h
db 0B1h,071h,0B1h,071h,093h,071h,0B1h,071h
db 0B1h,071h,0B1h,031h,002h,0C1h,001h,062h
db 001h,071h,0B1h,071h,031h,001h,062h,001h
db 0F1h,071h,0B1h,071h,0B1h,071h,094h,011h
db 071h,0B1h,071h,0B1h,071h,0B1h,031h,002h
db 062h,001h,071h,0B1h,071h,0B1h,071h,031h
db 001h,062h,001h,0B1h,071h,0B1h,071h,095h
db 011h,0B1h,071h,0B1h,071h,0B1h,071h,0B1h
db 031h,003h,071h,0B1h,071h,0B1h,071h,0B1h
db 031h,001h,062h,001h,071h,0B1h,071h,0B1h
db 096h,011h,0B1h,071h,0B1h,071h,0B1h,071h
db 0B1h,071h,0B1h,071h,0B1h,071h,0B1h,071h
db 0B1h,071h,031h,001h,062h,001h,0B1h,071h
db 0B1h,071h,011h,096h,011h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,031h,001h,063h,001h
db 0B1h,071h,0B1h,071h,011h,093h,012h,0B1h
db 071h,0B1h,071h,0C3h,071h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,071h,031h,001h,063h
db 001h,0F1h,0B1h,071h,0B1h,071h,013h,071h
db 0B1h,071h,0B1h,0C6h,041h,0B1h,071h,0B1h
db 071h,0B1h,071h,0B1h,031h,001h,064h,001h
db 0F1h,0B1h,071h,0B1h,071h,0B1h,071h,0B1h
db 071h,0B1h,0C8h,041h,0B1h,071h,0B1h,071h
db 0B1h,032h,001h,065h,001h,0F1h,0B1h,071h
db 0B1h,071h,0B1h,071h,0B1h,071h,0C8h,041h
db 071h,0B1h,071h,0B1h,071h,031h,001h,067h
db 001h,0F1h,0B1h,071h,0B1h,071h,0B1h,071h
db 0B1h,041h,0C5h,042h,071h,0B1h,071h,0B1h
db 071h,032h,001h,068h,001h,081h,0B1h,071h
db 0B1h,071h,0B1h,071h,0B1h,045h,0B1h,071h
db 0B1h,071h,0B1h,071h,032h,001h,06Ah,002h
db 031h,071h,0B1h,071h,0B1h,071h,0B1h,071h
db 0B1h,071h,0B1h,071h,0B1h,071h,033h,002h
db 06Bh,005h,03Bh,003h,06Ch,002h,064h,00Bh
db 000h
 
molecule db 1
db 01Eh,084h,01Fh,01Bh,082h,064h,002h,01Fh
db 018h,081h,068h,001h,01Fh,017h,081h,061h
db 0F1h,071h,065h,001h,01Fh,013h,033h,082h
db 061h,072h,066h,001h,033h,01Ch,032h,093h
db 002h,062h,034h,063h,001h,093h,002h,019h
db 031h,097h,032h,094h,002h,061h,001h,094h
db 031h,001h,018h,031h,091h,0F1h,071h,093h
db 031h,097h,031h,001h,0F1h,071h,093h,031h
db 001h,017h,031h,092h,072h,093h,031h,091h
db 0F1h,071h,094h,031h,001h,072h,093h,032h
db 001h,016h,031h,096h,031h,092h,072h,094h
db 032h,001h,094h,032h,001h,016h,031h,096h
db 031h,097h,033h,001h,093h,033h,001h,017h
db 001h,095h,031h,097h,033h,001h,082h,091h
db 032h,001h,016h,082h,001h,093h,083h,001h
db 094h,034h,001h,063h,002h,031h,003h,013h
db 081h,063h,001h,082h,063h,001h,038h,001h
db 064h,081h,001h,063h,001h,012h,081h,061h
db 0F1h,071h,081h,066h,002h,034h,002h,065h
db 081h,001h,063h,001h,011h,081h,062h,072h
db 081h,061h,0F1h,071h,064h,081h,004h,021h
db 0F1h,071h,064h,082h,001h,062h,081h,001h
db 081h,063h,081h,062h,072h,064h,081h,034h
db 021h,072h,063h,083h,001h,062h,081h,001h
db 081h,063h,081h,067h,032h,094h,002h,064h
db 083h,001h,061h,082h,002h,063h,081h,066h
db 031h,097h,031h,001h,063h,083h,001h,061h
db 082h,001h,011h,001h,063h,001h,065h,031h
db 091h,0F1h,071h,094h,031h,001h,085h,001h
db 031h,082h,001h,012h,001h,082h,031h,001h
db 084h,031h,092h,072h,094h,032h,001h,084h
db 001h,031h,082h,001h,013h,001h,031h,091h
db 071h,002h,082h,031h,097h,033h,001h,082h
db 002h,091h,031h,002h,015h,031h,094h,002h
db 031h,097h,033h,003h,093h,031h,001h,016h
db 031h,097h,001h,094h,034h,001h,095h,032h
db 001h,016h,031h,097h,001h,038h,001h,095h
db 032h,001h,017h,001h,094h,033h,002h,034h
db 002h,094h,033h,001h,018h,001h,037h,001h
db 061h,004h,061h,001h,037h,001h,019h,002h
db 033h,002h,066h,082h,002h,033h,002h,01Ch
db 004h,067h,083h,004h,01Fh,013h,001h,088h
db 001h,01Fh,018h,002h,084h,002h,01Fh,01Bh
db 004h,000h
 
cd db 1
db 01Fh,01Fh,01Fh,01Fh,01Fh,01Fh,01Fh,014h
db 086h,01Fh,018h,083h,0B3h,073h,083h,01Fh
db 013h,083h,0E2h,0B3h,076h,002h,01Fh,081h
db 0A2h,0E3h,0B3h,078h,001h,01Dh,081h,0A4h
db 0E3h,0B2h,079h,001h,01Bh,081h,072h,0A3h
db 0E3h,0B2h,07Ah,001h,01Ah,081h,0E1h,072h
db 0A3h,0E2h,0B2h,07Ah,001h,019h,081h,0E3h
db 072h,0A2h,0E2h,0B2h,07Bh,001h,018h,081h
db 072h,0E2h,072h,0A2h,0E1h,0B2h,07Bh,001h
db 017h,081h,075h,0E1h,072h,0A2h,084h,07Ah
db 001h,016h,081h,076h,0E1h,072h,081h,005h
db 071h,0F1h,077h,001h,016h,081h,077h,0E1h
db 081h,001h,014h,001h,081h,078h,001h,016h
db 081h,078h,081h,001h,014h,001h,081h,078h
db 001h,016h,082h,071h,081h,071h,081h,071h
db 081h,071h,081h,001h,014h,001h,081h,078h
db 001h,016h,081h,071h,081h,071h,081h,071h
db 081h,071h,082h,001h,014h,001h,081h,078h
db 001h,016h,082h,071h,081h,071h,081h,071h
db 081h,0F1h,071h,081h,004h,081h,079h,001h
db 016h,081h,071h,081h,071h,081h,071h,081h
db 0F1h,071h,0F1h,071h,084h,0E1h,079h,001h
db 017h,081h,071h,081h,071h,081h,0F1h,071h
db 0F1h,074h,0B1h,071h,0E2h,077h,001h,018h
db 082h,071h,081h,0F1h,071h,0F1h,074h,0B2h
db 0A1h,071h,0E2h,076h,001h,019h,082h,0F1h
db 071h,0F1h,076h,0B1h,0A1h,071h,0E3h,074h
db 001h,01Ah,081h,0F1h,071h,0F1h,076h,0B2h
db 0A2h,071h,0E3h,073h,001h,01Bh,081h,0F1h
db 078h,0B1h,0A2h,071h,0E4h,071h,001h,01Dh
db 081h,077h,0B3h,0A2h,071h,0E3h,001h,01Fh
db 082h,076h,0B2h,0A2h,071h,081h,002h,01Fh
db 013h,082h,073h,0B3h,0A1h,003h,01Fh,017h
db 007h,000h
 
trumpet db 1
db 01Ch,03Dh,001h,01Fh,014h,031h,0F1h,0B2h
db 036h,071h,001h,01Fh,016h,031h,0F1h,0B1h
db 035h,071h,001h,01Fh,018h,031h,0F1h,0B1h
db 033h,071h,001h,01Fh,013h,034h,012h,031h
db 0F1h,0B1h,033h,071h,001h,01Fh,012h,031h
db 0B2h,072h,032h,011h,031h,0B1h,032h,071h
db 001h,01Fh,012h,031h,0B1h,071h,003h,071h
db 0B1h,032h,0B1h,032h,071h,001h,01Fh,011h
db 031h,0F1h,071h,001h,013h,001h,071h,081h
db 031h,0B1h,032h,071h,001h,01Fh,011h,031h
db 0F1h,001h,014h,031h,001h,0B1h,031h,0B1h
db 032h,071h,001h,01Fh,011h,031h,0B1h,001h
db 014h,031h,001h,0B1h,031h,0B1h,032h,071h
db 001h,01Fh,011h,031h,0F1h,001h,012h,031h
db 011h,031h,001h,0B1h,031h,0B1h,032h,071h
db 001h,01Fh,011h,031h,0B1h,001h,011h,034h
db 001h,0B1h,031h,0B1h,032h,071h,001h,01Fh
db 011h,031h,0F1h,001h,031h,0F1h,0B2h,081h
db 001h,0B1h,031h,0B1h,032h,071h,001h,01Fh
db 011h,031h,0B1h,001h,031h,0B1h,081h,071h
db 081h,001h,0B1h,031h,0F5h,032h,011h,031h
db 001h,01Bh,031h,071h,031h,0F1h,0B1h,081h
db 001h,0B1h,001h,0F2h,035h,002h,032h,001h
db 01Bh,031h,0B1h,032h,003h,0B1h,0F1h,032h
db 0B1h,032h,071h,001h,012h,001h,031h,001h
db 01Bh,031h,071h,031h,0B2h,031h,001h,0B1h
db 031h,0B1h,031h,0B1h,032h,071h,001h,013h
db 002h,01Bh,031h,071h,032h,003h,0B1h,001h
db 0B1h,031h,0B1h,032h,071h,001h,01Fh,011h
db 031h,071h,031h,0B2h,031h,001h,0B1h,001h
db 0B1h,031h,0B1h,032h,071h,001h,01Fh,011h
db 031h,071h,032h,003h,0B1h,001h,0B1h,031h
db 0B1h,032h,071h,001h,01Fh,011h,031h,071h
db 031h,0B2h,001h,0B1h,031h,001h,0B1h,031h
db 0B1h,032h,071h,001h,01Fh,011h,031h,071h
db 031h,0B1h,081h,001h,0B1h,081h,001h,0B1h
db 031h,0B1h,032h,071h,001h,01Fh,011h,031h
db 071h,031h,0B1h,081h,001h,0B1h,081h,001h
db 0B1h,031h,0B1h,032h,071h,001h,01Fh,011h
db 031h,071h,031h,0B1h,081h,001h,0B1h,031h
db 001h,0B1h,031h,0B1h,032h,071h,001h,01Fh
db 011h,031h,0B1h,031h,0B1h,081h,001h,032h
db 001h,0B1h,031h,0B1h,032h,071h,001h,01Fh
db 011h,031h,0F1h,031h,0B1h,001h,031h,001h
db 031h,001h,0B1h,031h,0B1h,032h,071h,001h
db 01Fh,011h,031h,0B1h,032h,0B1h,001h,031h
db 002h,0B1h,031h,0B1h,032h,071h,001h,01Fh
db 012h,031h,0B1h,001h,034h,001h,0B1h,031h
db 0B1h,031h,071h,001h,01Fh,013h,031h,071h
db 031h,004h,032h,0B1h,001h,031h,071h,001h
db 01Fh,014h,031h,071h,0B1h,001h,0B2h,003h
db 072h,001h,01Fh,016h,002h,036h,002h,01Fh
db 019h,006h,000h
 
liquid db 1
db 019h,08Dh,01Fh,084h,06Dh,084h,018h,083h
db 06Fh,066h,083h,014h,081h,071h,06Dh,071h
db 0F3h,071h,067h,071h,081h,013h,081h,071h
db 06Ch,071h,0F5h,071h,066h,071h,081h,013h
db 081h,071h,06Eh,073h,068h,071h,081h,014h
db 081h,073h,06Fh,064h,073h,001h,015h,081h
db 0F1h,062h,073h,06Dh,073h,062h,081h,001h
db 016h,061h,0F1h,064h,07Dh,064h,081h,001h
db 017h,061h,0F1h,06Fh,066h,081h,001h,017h
db 061h,0F1h,06Fh,066h,081h,001h,017h,061h
db 0F1h,061h,0F1h,073h,06Fh,061h,081h,001h
db 017h,061h,0F1h,061h,0F1h,071h,063h,0AAh
db 065h,081h,001h,017h,061h,0F1h,061h,0F1h
db 071h,0AFh,0A1h,062h,081h,001h,017h,061h
db 0F1h,0A1h,0F1h,071h,0AFh,0A3h,081h,001h
db 017h,061h,0F1h,0A1h,0F1h,073h,0ABh,0F1h
db 0A4h,081h,001h,017h,061h,0F1h,0A1h,0F1h
db 071h,0AEh,0F1h,0A3h,081h,001h,017h,061h
db 0F3h,071h,0A3h,0F3h,0A6h,0F2h,0A4h,081h
db 001h,017h,061h,0F1h,0A1h,0F1h,071h,0A6h
db 0F6h,0A5h,0F1h,081h,001h,017h,061h,0F1h
db 0A1h,0F1h,073h,0AEh,0F1h,0A1h,081h,001h
db 017h,061h,0F1h,0A1h,0F1h,071h,0A1h,0F2h
db 0AAh,0F3h,0A2h,081h,001h,017h,061h,0F1h
db 0A1h,0F1h,071h,0A3h,0FAh,0A5h,081h,001h
db 017h,061h,0F1h,0A1h,0F1h,071h,0A3h,08Ah
db 0A5h,081h,001h,017h,061h,0F1h,0A1h,0F1h
db 073h,081h,0A5h,071h,0F2h,071h,0A1h,083h
db 0A2h,081h,001h,017h,061h,0F1h,0A1h,0F1h
db 071h,0A8h,071h,0F2h,071h,0A4h,083h,001h
db 017h,061h,0F1h,0A1h,0F1h,071h,0A9h,0F1h
db 071h,0A7h,081h,001h,017h,061h,0F1h,0A1h
db 0F1h,071h,0A9h,0F1h,071h,0A7h,081h,001h
db 018h,001h,081h,0A2h,072h,0A7h,0F2h,071h
db 0A5h,081h,001h,019h,001h,081h,0AAh,071h
db 0F2h,071h,0A5h,081h,001h,01Ah,001h,083h
db 0A7h,071h,0F2h,071h,0A2h,083h,001h,01Ch
db 003h,088h,072h,083h,003h,01Fh,011h,00Dh
db 000h
 
telephone db 1
db 01Fh,01Fh,01Fh,01Fh,01Dh,006h,01Fh,019h
db 002h,0F1h,0B5h,003h,01Fh,015h,001h,0B3h
db 0F5h,0B3h,003h,01Fh,011h,001h,0B4h,032h
db 002h,0B1h,0F3h,0B3h,002h,01Dh,001h,0B4h
db 032h,001h,0F1h,0B1h,001h,0B3h,0F2h,0B3h
db 002h,01Bh,002h,0B2h,033h,001h,0B1h,071h
db 031h,001h,0B4h,0F2h,0B3h,002h,019h,001h
db 0B1h,002h,031h,003h,0B1h,071h,031h,001h
db 031h,0B2h,002h,031h,0F2h,0B3h,001h,018h
db 001h,0B2h,031h,001h,071h,0B3h,071h,031h
db 001h,032h,001h,0F1h,0B1h,001h,031h,0B1h
db 0F1h,0B3h,001h,018h,001h,031h,001h,071h
db 0B7h,003h,0B1h,071h,031h,001h,031h,0B1h
db 0F1h,0B3h,001h,018h,001h,071h,0B2h,0F2h
db 031h,0B5h,001h,0B1h,071h,031h,001h,031h
db 0B2h,0F1h,0B3h,001h,016h,001h,071h,0B3h
db 031h,001h,0F2h,031h,0B5h,071h,031h,001h
db 031h,0B2h,0F1h,0B3h,0F1h,001h,014h,001h
db 071h,0B2h,0F2h,031h,0B1h,031h,001h,0F2h
db 031h,0B5h,001h,031h,0B3h,0F3h,031h,001h
db 013h,001h,071h,0B3h,031h,001h,0F2h,031h
db 0B1h,031h,001h,0B5h,071h,001h,031h,0B3h
db 071h,033h,001h,012h,001h,071h,0B2h,0F2h
db 031h,0B1h,031h,001h,0F2h,031h,0B5h,071h
db 031h,001h,031h,0B3h,071h,033h,001h,011h
db 001h,071h,0B3h,031h,001h,0F2h,031h,0B1h
db 031h,001h,0B5h,071h,032h,002h,0B3h,071h
db 033h,002h,071h,0F2h,0B4h,031h,001h,0F2h
db 031h,0B5h,071h,033h,001h,032h,0B2h,071h
db 032h,003h,071h,0F4h,0B4h,031h,001h,0B5h
db 071h,034h,001h,031h,0B1h,032h,003h,031h
db 002h,071h,0B2h,0F4h,0B8h,071h,036h,001h
db 0B3h,071h,033h,002h,071h,0B4h,0F4h,0B5h
db 071h,037h,002h,0B2h,033h,001h,011h,001h
db 071h,0B6h,0F4h,0B2h,071h,039h,006h,012h
db 002h,072h,0B6h,0F3h,071h,03Bh,002h,017h
db 002h,072h,0B6h,0F1h,03Ah,002h,01Bh,002h
db 072h,0B5h,038h,002h,01Fh,002h,072h,0B3h
db 036h,002h,01Fh,014h,002h,072h,0B1h,034h
db 002h,01Fh,018h,002h,071h,032h,002h,01Fh
db 01Ch,003h,000h
 
smile db 1
db 01Ch,008h,01Fh,016h,003h,0B8h,003h,01Fh
db 011h,002h,0BEh,002h,01Dh,002h,0BFh,0B1h
db 002h,01Bh,001h,0BFh,0B5h,001h,019h,001h
db 0BFh,0B7h,001h,017h,001h,0BFh,0B9h,001h
db 015h,002h,0BFh,0B9h,002h,014h,001h,0B8h
db 002h,0B6h,002h,0B8h,001h,013h,001h,0B8h
db 004h,0B4h,004h,0B8h,001h,012h,001h,0B8h
db 004h,0B4h,004h,0B8h,001h,012h,001h,0B8h
db 004h,0B4h,004h,0B8h,001h,011h,001h,0B9h
db 004h,0B4h,004h,0B9h,002h,0B9h,004h,0B4h
db 004h,0B9h,002h,0BAh,002h,0B6h,002h,0BAh
db 002h,0B7h,001h,0BEh,001h,0B7h,002h,0B7h
db 001h,0BEh,001h,0B7h,002h,0B6h,001h,0BFh
db 0B1h,001h,0B6h,002h,0B3h,004h,0BFh,0B1h
db 004h,0B3h,002h,0B7h,001h,0BEh,001h,0B7h
db 001h,011h,001h,0B7h,001h,0BCh,001h,0B7h
db 001h,012h,001h,0B7h,002h,0BAh,002h,0B7h
db 001h,012h,001h,0B8h,003h,0B6h,003h,0B8h
db 001h,013h,001h,0B8h,001h,091h,006h,091h
db 001h,0B8h,001h,014h,002h,0B8h,001h,096h
db 001h,0B8h,002h,015h,001h,0B9h,001h,094h
db 001h,0B9h,001h,017h,001h,0B9h,004h,0B9h
db 001h,019h,001h,0BFh,0B5h,001h,01Bh,002h
db 0BFh,0B1h,002h,01Dh,002h,0BEh,002h,01Fh
db 011h,003h,0B8h,003h,01Fh,016h,008h,000h
 
banana db 1
db 01Fh,01Fh,01Fh,01Fh,01Ah,002h,01Fh,01Eh
db 003h,01Fh,01Eh,003h,01Fh,01Eh,003h,01Fh
db 01Eh,003h,01Fh,01Dh,005h,01Fh,01Ch,001h
db 0B1h,001h,0B1h,001h,01Fh,01Bh,002h,0B1h
db 001h,0B2h,001h,01Fh,01Ah,001h,0B2h,001h
db 0B2h,001h,01Fh,01Ah,001h,0B2h,001h,0B3h
db 001h,01Fh,019h,001h,0B3h,001h,0B2h,001h
db 01Fh,019h,001h,0B3h,001h,0B3h,001h,01Fh
db 018h,001h,0B4h,001h,0B3h,001h,01Fh,017h
db 001h,0B4h,001h,0B4h,001h,01Fh,017h,001h
db 0B4h,001h,0B4h,001h,01Fh,016h,001h,0B5h
db 001h,0B4h,001h,01Fh,016h,001h,0B5h,001h
db 0B4h,002h,01Fh,015h,001h,0B5h,001h,0B5h
db 001h,01Fh,014h,001h,0B6h,001h,0B5h,002h
db 01Fh,013h,001h,0B6h,001h,0B6h,002h,01Fh
db 012h,001h,0B6h,002h,0B6h,002h,01Fh,011h
db 001h,0B7h,002h,0B6h,002h,01Fh,002h,0B7h
db 003h,0B5h,002h,01Fh,001h,0B9h,008h,01Fh
db 002h,0BCh,002h,01Fh,013h,004h,0B6h,003h
db 01Fh,018h,006h,000h
 
bolt db 1
db 01Fh,01Fh,01Fh,006h,01Fh,01Ah,001h,085h
db 002h,01Fh,018h,001h,078h,001h,01Fh,017h
db 081h,002h,071h,004h,081h,001h,01Fh,017h
db 001h,083h,073h,002h,081h,01Fh,017h,081h
db 001h,072h,085h,001h,01Fh,016h,002h,083h
db 073h,002h,081h,001h,01Fh,013h,002h,071h
db 081h,001h,072h,085h,001h,071h,002h,01Eh
db 002h,073h,001h,083h,073h,002h,081h,073h
db 002h,01Bh,001h,075h,081h,001h,087h,001h
db 075h,001h,01Ah,001h,0F2h,074h,081h,006h
db 081h,074h,003h,01Ah,001h,072h,0F2h,07Ch
db 002h,082h,001h,01Ah,001h,074h,0FBh,001h
db 084h,001h,01Ah,001h,075h,0F1h,078h,001h
db 085h,001h,01Ah,001h,075h,0F1h,078h,001h
db 085h,001h,01Bh,002h,073h,0F1h,078h,001h
db 083h,002h,01Eh,002h,071h,0F1h,078h,001h
db 081h,002h,01Fh,013h,00Ch,01Fh,016h,081h
db 001h,072h,085h,001h,01Fh,016h,002h,083h
db 073h,002h,081h,001h,01Fh,013h,002h,071h
db 081h,001h,072h,085h,001h,071h,002h,01Eh
db 002h,073h,001h,083h,073h,002h,081h,073h
db 002h,01Bh,001h,075h,081h,001h,072h,085h
db 001h,075h,001h,01Ah,001h,0F2h,074h,081h
db 006h,081h,074h,003h,01Ah,001h,072h,0F2h
db 07Ch,002h,082h,001h,01Ah,001h,074h,0FBh
db 001h,084h,001h,01Ah,001h,075h,0F1h,078h
db 001h,085h,001h,01Ah,001h,075h,0F1h,078h
db 001h,085h,001h,01Bh,002h,073h,0F1h,078h
db 001h,083h,002h,01Eh,002h,071h,0F1h,078h
db 001h,081h,002h,01Fh,013h,00Ch,000h
 
 
coltbl dd 000000h,800000h,008000h,808000h
dd 000080h,800080h,008080h,0C0C0C0h
dd 808080h,0FF0000h,00FF00h,0FFFF00h
dd 0000FFh,0FF00FFh,00FFFFh,0FFFFFFh
dd 0006688ddh ; bitton color
 
 
pict dd globe
dd wa
dd sword
dd cow
dd mace
dd cube
dd ball
dd dish
dd apple
dd ok
dd speaker
dd print
dd light
dd key1
dd foto
dd flop
dd pillar
dd newspaper
dd umbrella
dd books
dd flag
dd paint
dd molecule
dd cd
dd trumpet
dd liquid
dd telephone
dd smile
dd banana
dd bolt
 
labnew db 'New game Clicks:'
labnewlen:
 
 
nkeydown dd ?
bitstat db ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
db ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
db ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
bitpict db ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
db ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
db ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
firstbit db ?
secondbit db ?
 
 
bitid db ?
 
 
mas: ; mas db (32*32)*3+1 dup (?)
 
I_END=mas+(32*32)*3+1
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/mine/trunk/access.h--
0,0 → 1,68
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
*******************************************************************************/
 
:int get_value(int x, y)
{
EBX=x*ncy+y;
return massiv[EBX].value;
}
 
:void set_value(int x, y, byte val)
{
EBX=x*ncy+y;
massiv[EBX].value=val;
}
 
:int get_open(int x, y)
{
EBX=x*ncy+y;
return massiv[EBX].open;
}
 
:void set_open(int x, y, byte op)
{
EBX=x*ncy+y;
massiv[EBX].open=op;
}
 
:int get_press(int x, y)
{
EBX=x*ncy+y;
return massiv[EBX].press;
}
 
:void set_press(int x, y, byte pr)
{
EBX=x*ncy+y;
massiv[EBX].press=pr;
}
 
:int get_mark(int x, y)
{
EBX=x*ncy+y;
return massiv[EBX].mark;
}
 
:void set_mark(int x, y, byte mar)
{
EBX=x*ncy+y;
massiv[EBX].mark=mar;
}
/programs/games/mine/trunk/changelog.txt
0,0 → 1,15
v0.3a (11/08/2003)
- fixed a bug on old kernels
 
v0.3 (09/08/2003)
- fixed some bugs
- new timer
- better random number generator
- user can't blow up after first mouse click
- uses system colors
 
v0.2 (29/06/2003)
- fixed a lot of bugs
 
v0.1 (22/06/2003)
- first public version
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/mine/trunk/draw.h--
0,0 → 1,184
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
*******************************************************************************/
 
void draw_window()
// Ïðîöåäóðà îòðèñîâêè îêíà
{
mouse_disable();
 
sys_window_redraw(1);
sys_get_colors(#colors, 40);
 
// WINDOW
EBX = xpos << 16 + xsize;
ECX = ypos << 16 + ysize;
sys_draw_window(EBX, ECX, 0x02CCCCCC, colors.w_grab | 0x80000000, colors.w_frames);
 
// LABEL
sys_write_text(8<<16+8, colors.w_grab_text | 0x10000000, "MeOS MineSweeper", 16);
 
// <CLOSE> BUTTON (1)
EBX = xsize - 19; EBX = EBX<<16 + 12;
sys_draw_button(EBX, 5<<16+12, 1, colors.w_grab_button);
 
// <NEW GAME> BUTTON (911)
EBX = xsize / 2 - 10;
EBX = EBX << 16 + 20;
sys_draw_button(EBX, 25<<16+20, 911, clLightGray);
 
// <CHANGE MODE> BUTTON (1001)
sys_draw_button(10<<16+7, 23<<16+7, 1001, 0x118811);
 
// <USER FIELD> BUTTON (1002)
//sys_draw_button(20<<16+7, ECX, EDX+1, 0xddbb44);
 
// <OPTIONS> BUTTON (1003)
// sys_draw_button();
 
// <SCORES> BUTTON (1004)
// sys_draw_button();
 
// <ABOUT> BUTTON (1005)
// sys_draw_button();
 
sys_window_redraw(2);
 
draw_time(); // draw timer
draw_minesi(); // draw mines
draw_squares(); // draw field
 
mouse_enable();
}
 
dword num_colors[8]=
{
0x4444d0, // 1
0x118811, // 2
0xd04444, // 3
0x111199, // 4
0x991111, // 5
0x117089, // 6
0x000000, // 7
0x808080 // 8
};
 
void draw_square(int x, y)
// Îòðèñîâêà îäíîé êëåòêè
{
int xl, xr, yt, yb;
dword tcolor = clBlack;
byte tchar,tval;
 
xl = XPX * x + XST;
xr = xl + XPX - 1;
yt = YPX * y + YST;
yb = yt + YPX - 1;
 
EBX = xl << 16 + xr - xl;
ECX = yt << 16 + yb - yt;
$inc ebx
$inc ecx
sys_draw_bar(EBX, ECX, clLightGray);
 
if (!get_open(x, y))
{
ECX = yt << 16 + yb - 1;
sys_draw_line(xl<<16+xl, ECX, clWhite);
EBX = xl << 16 + xr - 1;
sys_draw_line(EBX, yt << 16 + yt, EDX);
sys_draw_line(xr << 16 + xl, yb << 16 + yb, clDarkGray);
sys_draw_line(xr << 16 + xr, yb << 16 + yt, EDX);
 
SWITCH (get_mark(x, y))
{
CASE 2: tcolor = 0x121288; tchar = '?'; BREAK;
CASE 1: tcolor = 0xd04444; tchar = 'P';
}
 
IF (get_mark(x,y))
{
EBX = xl + 5; EBX <<= 16; EBX += yt + 4;
sys_write_text(EBX, tcolor, #tchar, 1);
EBX += 0x00010000;
/* Âòîðîé ðàç - ðåãèñòðû ñîõðàíÿþòñÿ */
sys_write_text(EBX, ECX, EDX, ESI);
}
}
else // get_open(x,y)==TRUE
{
tval = get_value(x, y);
IF (tval == 0)
{
//tcolor=clLightGray;
//tchar=' ';
GOTO NOCHAR;
}
ELSE IF (tval == MINE)
{
tcolor = 0xee1111;
tchar = '*';
}
ELSE
{
tchar = tval + '0';
tcolor = num_colors[tval-1];
}
 
EBX = xl + 5; EBX <<= 16; EBX += yt + 5;
sys_write_text(EBX, tcolor, #tchar, 1);
EBX += 0x00010000;
sys_write_text(EBX, ECX, EDX, ESI);
NOCHAR:
sys_draw_line(xl << 16 + xl, yt << 16 + yb, clDarkGray);
sys_draw_line(xl << 16 + xr, yt << 16 + yt, EDX);
}
}
 
void draw_time()
// Òàéìåð
{
sys_draw_bar(XST<<16+25, 31<<16+10, 0xCCCCCC);
EBX = 0x00030000;
sys_write_number(EBX, time, XST<<16+32, 0x10ff0000);
}
 
void draw_minesi()
// Èíäèêàòîð êîëè÷åñòâà íåðàññòàâëåííûõ ìèí
{
EBX = xsize - XST - 25;
$PUSH EBX
EBX = EBX << 16 + 25;
sys_draw_bar(EBX, 31<<16+12, 0xCCCCCC);
$POP EDX
EDX <<= 16; EDX += 30;
EBX = 0x00030000;
sys_write_number(EBX, cmines, EDX, 0x10ff0000);
}
 
void draw_squares()
// Îòðèñîâêà ìèííîãî ïîëÿ
{
int x,y;
 
FOR (x=0; x < ncx; x++)
FOR (y=0; y < ncy; y++)
draw_square(x, y);
}
/programs/games/mine/trunk/mine.c--
0,0 → 1,468
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
*******************************************************************************/
 
//? pragma option LST // generate ASM listing file - ñîçäàòü àññåìáëåðíûé ëèñòèíã
//? warning TRUE // âêëþ÷èòü ðåæèì âûâîäà ïðåäóïðåæäåíèé
? pragma option meos
? jumptomain NONE
? include "msys.h--" // MenuetOS system functions - ñèñòåìíûå ôóíêöèè MenuetOS
 
? print "\nÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
? print "\n³ MeOS MineSweeper v0.3 ³"
? print "\n³ (C) Ivan Poddubny (ivan-yar@bk.ru) 2003 ³"
? print "\nÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n"
 
/************************************** DATA **************************************/
 
? define XPX 16 // X pixels by square - ðàçìåð êëåòêè â ïèêñåëÿõ
? define YPX 16 // Y pixels by square
? define MINE 255 // çíà÷åíèå äëÿ ìèíû â ïîëå value
 
struct
{
byte value; // number of mines - êîëè÷åñòâî ìèí â îêðóæàþùèõ êëåòêàõ
byte open; // square is open - êëåòêà îòêðûòà
byte press; // reserved - çàðåçåðâèðîâàíî
byte mark; // square is marked - êëåòêà ïîìå÷åíà
} massiv[30*30];
 
struct
{
byte a_inc;
byte b_inc;
} matrix[8] = {-1,-1,1,0,1,0,0,1,-2,0,0,1,1,0,1,0};
 
struct
{
byte x_size;
byte y_size;
byte nmines;
} stdmodes[3] = {9,9,10, 16,16,40, 30,16,99}; // {x,y,m}
 
int XST, // offset of first pixel X - ñìåùåíèå ïîëÿ îò ãðàíèöû îêíà
YST,
ncx, // number of squares in X - ðàçìåð ïîë
ncy,
cmines, // mines discovered - êîëè÷åñòâî íåîòêðûòûõ ìèí
initmines, // number of initial mines - èçíà÷àëüíîå êîëè÷åñòâî ìèí
sqclosed; // squares still closed - êîëè÷åñòâî çàêðûòûõ êëåòîê
 
dword xpos = 100, // window coordinates - êîîðäèíàòû îêíà
ypos = 100,
xsize, // window size
ysize;
 
byte stop_game = FALSE, // game stopped - ïðèçíàê êîíöà èãðû
mouse_en = TRUE, // mouse enabled - ìûøü
mode = 3, // ðåæèì èãðû 1-íîâè÷îê 2-ëþáèòåëü 3-ýêñïåðò (0 îñîáûé)
mouse_status,
firstmine;
 
ProcessInfo procinfo;
SystemColors colors;
 
/************************************** CODE **************************************/
 
inline void fastcall mouse_enable()
{
$mov eax,40
$mov ebx,100111b
$int 0x40
}
 
inline void fastcall mouse_disable()
{
$mov eax,40
$mov ebx,000111b
$int 0x40
}
 
? include "timer.h--" // timer functions
? include "draw.h--" // drawing functions
? include "access.h--" // get & set functions
? include "random.h--" // random number generator
//? include "uf.h--" // user field window
 
void init()
// Èíèöèàëèçàöè
{
XST = 10; YST = 52; // FIELD POSITION IN WINDOW
 
ECX = mode;
IF (ECX != 0)
{
//ncx = stdmodes[ECX-1].x_size;
//ncy = stdmodes[ECX-1].y_size;
//cmines = initmines = stdmodes[ECX-1].nmines;
 
EBX = #stdmodes;
ECX--; ECX *= 3;
EBX += ECX;
 
ncx = DSBYTE[EBX]; EBX++;
ncy = DSBYTE[EBX]; EBX++;
cmines = initmines = DSBYTE[EBX];
}
 
xsize = ncx * XPX + XST + XST;
ysize = ncy * YPX + YST + XST;
} // init
 
void clear_all()
// Î÷èñòèòü ïîëå
{
EAX = 0;
EDI = #massiv;
ECX = ncx * ncy;
$REP $STOSD
} // clear_all
 
void new_game()
// Íîâàÿ èãðà
{
init(); // èíèöèàëèçàöè
randomize(); // ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
clear_all(); // î÷èñòèòü ïîëå
 
firstmine = TRUE; // èãðà íå íà÷àòà
mouse_en = TRUE; // ìûøü ðàçðåøåíà
stop_game = FALSE; // èãðà íå çàêîí÷åíà
stop_timer();
time = 0; // âðåìÿ = 0
} // new_game
 
void set_mines(int nminas, no_x, no_y)
// Ðàññòàâèòü ìèíû
{
int i, x, y, a, b;
 
sqclosed = ncx * ncy - nminas; // êîëè÷åñòâî ÍÅîòêðûòûõ êëåòîê = ïëîùàäü ïîëÿ - êîë-âî ìèí
 
FOR (i = nminas; i > 0; i--) // ðàññòàâèòü ìèíû
{
x = random(ncx); y = random(ncy);
WHILE ((get_value(x, y) == MINE) || ((x == no_x) && (y == no_y)))
{
x = random(ncx);
y = random(ncy);
}
set_value(x, y, MINE);
}
 
for (x = ncx-1; x >= 0; x--) // ðàññòàâèòü öèôðû
{
for (y = ncy-1; y >= 0; y--)
{
IF (get_value(x, y) == MINE)
continue;
EDX = x * ncy + y*4 + #massiv;
a = x; b = y;
FOR (i = 0; i < 8; i++)
{
AL = matrix[i].a_inc;
$movsx eax,al
a += EAX;
AL = matrix[i].b_inc;
$movsx eax,al
b += EAX;
IF ((a >= 0) && (b >= 0) && (a < ncx) && (b < ncy) && (get_value(a, b) == MINE))
DSBYTE[EDX]++;
}
}
}
} // set_mines
 
inline void do_mouse(void)
// Îáðàáîò÷èê ìûøè
{
int x,y;
 
EAX = sys_read_mouse(2); // ìûøü íå íàæàòà -> âûõîä
IF (EAX == 0) return;
 
mouse_status = AL;
 
EAX = sys_read_mouse(1); // ìûøü âíå ïîëÿ -> âûõîä
EBX = EAX; EAX >>= 16; EBX &= 0xffff;
ECX = ncx * XPX + XST - 1;
EDX = ncy * YPX + YST - 1;
IF ((EAX < XST) || (EBX < YST) || (EAX > ECX) || (EBX > EDX)) return;
 
EAX -= XST; EAX /= XPX; x = EAX; // âû÷èñëèòü x è y
EBX -= YST; EBX /= YPX; y = EBX;
 
IF ((mouse_status == 1) && (!get_open(x, y)) && (get_mark(x, y) != 1))
{
// íà íåîòêðûòîé êëåòêå áåç ôëàæêà íàæàòà ëåâàÿ êíîïêà ìûøè
// left mouse button is pressed
IF (firstmine == TRUE)
{
firstmine = FALSE;
set_mines(cmines, x, y);
start_timer();
}
IF (get_value(x, y) == MINE)
{
end_game();
return;
}
open_square(x, y);
}
else IF ((mouse_status == 2) && (!get_open(x, y)))
{
// íà íåîòêðûòîé êëåòêå íàæàòà ïðàâàÿ êíîïêà ìûøè
// right mouse button is pressed
EBX = get_mark(x, y); EBX++;
EBX = EBX%3;
SWITCH (EBX)
{
CASE 2: cmines++; BREAK;
CASE 1: cmines--;
}
 
set_mark(x, y, EBX);
 
draw_minesi();
draw_square(x, y);
return;
}
ELSE IF ((mouse_status == 3) && (get_open(x, y)))
{
// íà îòêðûòîé êëåòêå íàæàòû îáå êíîïêè ìûøè
// both mouse buttons are pressed
IF (open_near_squares(x, y) == TRUE)
end_game();
}
 
if (sqclosed == 0)
// îòêðûòû âñå êëåòêè
// all squares are opened
{
mouse_en = FALSE; // çàïðåòèòü ìûøü
stop_timer();
stop_game = TRUE; // èãðà çàâåðøåíà
 
// ïîñòàâèòü íåðàññòàâëåííûå ìèíû
FOR (x = 0; x < ncx; x++)
FOR (y = 0; y < ncy; y++)
IF ((get_value(x, y) == MINE) && (get_mark(x, y) != 1))
{
set_mark(x, y, 1);
cmines--;
draw_square(x, y);
}
draw_minesi();
}
} // do_mouse
 
void open_square(int x, y)
// Îòêðûòü êëåòêó
{
int a, b, i;
 
set_open(x, y, TRUE);
sqclosed--;
 
IF (get_value(x, y) != 0)
{
draw_square(x, y);
}
else
{
draw_square(x, y);
a = x; b = y;
FOR (i = 0; i < 8; i++)
{
//a += matrix[i].a_inc;
//b += matrix[i].b_inc;
AL = matrix[i].a_inc;
$movsx eax,al
a += EAX;
AL = matrix[i].b_inc;
$movsx eax,al
b += EAX;
IF ((a >= 0) && (b >= 0) && (a < ncx) && (b < ncy) && (!get_open(a, b)) && (get_mark(a, b) != 1))
open_square(a, b);
}
}
} // open_square
 
int open_near_squares(int x, y)
// Îòêðûòü áëèçëåæàùèå êëåòêè (îáå êíîïêè ìûøè âìåñòå)
{
int a, b, i;
dword suma = 0;
 
a = x;
b = y;
FOR (i = 0; i < 8; i++)
{
//a+=matrix[i].a_inc;
//b+=matrix[i].b_inc;
AL = matrix[i].a_inc;
$movsx eax,al
a += EAX;
AL = matrix[i].b_inc;
$movsx eax,al
b += EAX;
IF ((a >= 0) && (b >= 0) && (a < ncx) && (b < ncy) && (get_mark(a, b) == 1))
suma++;
}
 
if (suma == get_value(x, y))
{
suma = 0;
a = x;
b = y;
for (i = 0; i < 8; i++)
{
//a+=matrix[i].a_inc;
//b+=matrix[i].b_inc;
AL = matrix[i].a_inc;
$movsx eax,al
a += EAX;
AL = matrix[i].b_inc;
$movsx eax,al
b += EAX;
IF ((a >= 0) && (b >= 0) && (a < ncx) && (b < ncy) && (!get_open(a, b)) && (get_mark(a, b) != 1))
{
IF (get_value(a, b) == MINE)
suma = 1;
open_square(a, b);
}
}
RETURN suma;
}
ELSE
RETURN 0;
} // open_near_squares
 
void end_game()
{
int x,y;
 
stop_game = TRUE;
stop_timer();
for (x=0; x<ncx; x++)
{
for (y=0; y<ncy; y++)
{
IF (get_value(x, y) == MINE)
{
set_mark(x, y, FALSE); // ñíÿòü ôëàã
open_square(x, y);
}
ELSE IF (get_mark(x, y) == 1) // åñëè ìèíû íåò, à ôëàæîê åñòü
{
EBX = XPX * x + XST; // x left
ECX = EBX + XPX - 1; // x right
EBX <<= 16; EBX += ECX;
$PUSH EBX
 
ECX = YPX * y + YST; // y top
$PUSH ECX
EDX = ECX + YPX - 1; // y bottom
ECX <<= 16; ECX += EDX;
sys_draw_line(EBX, ECX, clBlack);
 
$POP EDX
ECX = EDX + YPX - 1;
ECX <<= 16; ECX += EDX;
$POP EBX
sys_draw_line(EBX, ECX, clBlack);
CONTINUE;
}
}
}
} // end_game
 
 
void main()
{
sys_delay(5); // for old kernel only!
new_game();
draw_window();
 
mouse_enable();
while()
{
switch (sys_wait_event_timeout(100)) // wait for 1 second
{
CASE evReDraw:
draw_window();
continue;
 
CASE evKey:
IF (sys_get_key() == 27)
sys_exit_process();
continue;
 
CASE evButton:
EAX = sys_get_button_id();
IF (EAX == 911) // new game
{
new_game();
draw_squares();
draw_time();
draw_minesi();
}
ELSE IF (EAX == 1001) // change mode
{
// mode++; mode%=3; mode++;
EAX = mode; EAX++; EAX = EAX%3; EAX++; mode = AL;
 
// get window position - ïîëó÷èòü êîîðäèíàòû îêíà
sys_process_info(#procinfo, -1);
xpos = procinfo.xstart;
ypos = procinfo.ystart;
 
// start a new process and terminate this one
sys_create_thread(#main, ESP);
sys_exit_process();
}
//ELSE IF (EAX == 1002)
//{
// start_uf();
//}
ELSE IF (EAX == 1) // close window
sys_exit_process();
CONTINUE;
 
case evMouse:
IF (!mouse_en) // is mouse enabled ?
CONTINUE;
do_mouse();
// wait for mouse release - æäàòü îòïóñêàíèÿ êíîïêè
WHILE (sys_read_mouse(2) == mouse_status)
{
check_timer();
sys_delay(6);
CONTINUE;
}
check_timer();
IF (stop_game) // disable mouse if game is stopped
mouse_en = FALSE;
CONTINUE;
}
check_timer();
sys_delay(2);
}
} // main
/programs/games/mine/trunk/msys.h--
0,0 → 1,806
/*
Sphinx C-- header file for MenuetOS applications.
Based on msys.h-- written by Alexey Sugonyaev and modified by Barry Kauler.
This extended version is written by Ivan Poddubny.
 
e-mail: ivan-yar@bk.ru
*/
 
// KeyCode constant
#define UP_KEY 130+48
#define DOWN_KEY 129+48
#define LEFT_KEY 128+48
#define RIGHT_KEY 131+48
#define RETURN_KEY 13
#define BACKSPACE_KEY 8
 
// Color constant
#define clWhite 0x00ffffff
#define clGray 0x00808080
#define clLightGray 0x00c0c0c0
#define clDarkGray 0x00707070
#define clBlack 0x00000000
#define clRed 0x00ff0000
#define clGreen 0x0000ff00
#define clBlue 0x000000ff
 
#define evReDraw 1
#define evKey 2
#define evButton 3
#define evMouse 6
#define evIPC 7
 
struct FileInfo
{
dword read,
firstBlock,
qnBlockRead,
retPtr,
Work;
byte filedir;
};
 
struct ProcessInfo
{
dword cpu_usage;
word winstackpos;
word winstackval;
word not_used1;
byte name[12];
dword memstart,
memory_used,
PID,
xstart,
ystart,
xsize,
ysize;
byte not_used2[974];
};
 
#define SystemColors SystemColours // usa/british
 
struct SystemColours
{
dword w_frames,
w_grab,
w_grab_button,
w_grab_button_text,
w_grab_text,
w_work,
w_work_button,
w_work_button_text,
w_work_text,
w_work_graph;
};
 
/*
0 = DEFINE WINDOW
{x_start|y_start}, {x_size|y_size}, color_back, color_title, color_frames
EBX = [x_start][x_size]
ECX = [y_start][y_size]
EDX, ESI, EDI = [00RRGGBB]
*/
inline fastcall void sys_draw_window(dword EBX, ECX, EDX, ESI, EDI)
{
EAX = 0; // function 0 : define and draw window
$int 0x40
}
 
/*
01 = PUTPIXEL
ebx [x]
ecx [y]
edx pixel color 0x0XRRGGBB
^ 0 normal put, 1 negative
ret: nothing changed
*/
inline fastcall void sys_put_pixel(dword EBX,ECX,EDX)
{
EAX=1;
$int 0x40
}
 
/*
02 = GET KEY
ret: al 0 successful -> ah = key
al 1 no key in buffer
MODIFIED, see below...
*/
inline fastcall dword sys_get_key()
{
EAX = 2; // just read it key from buffer
$int 0x40
$shr eax,8
} //return eax=key code.
 
/*
03 = GET SYSTEM CLOCK
ret: eax 0x00SSMMHH sec,min,hour
*/
inline fastcall dword sys_get_clock()
{
EAX=3;
$int 0x40
}
 
/*
04 = WRITE TEXT TO WINDOW
ebx [x start]*65536 + [y start]
ecx text color 0x00RRGGBB
edx pointer to text beginning
esi text length
ret: nothing changed
*/
inline fastcall void sys_write_text(dword EBX, ECX, EDX, ESI)
{
EAX = 4;
$int 0x40;
}
 
/*
05 = DELAY X/100 SECS
ebx delay in 1/100 secs
ret: nothing changed
*/
inline fastcall void sys_delay(dword EBX)
{
EAX = 5;
$int 0x40
}
 
/*
06 = OPEN FILE FROM FLOPPY
ebx pointer to filename -> 11 capital letters
ecx set 0x00000000 - reserved
edx set 0xffffffff - reserved
esi read to mem position
ret: nothing changed
*/
inline fastcall void sys_open_file_floppy(dword EBX, ESI)
{
$xor ecx,ecx
EDX = -1;
EAX = 6;
$int 0x40
}
 
/*
07 = PUTIMAGE
ebx pointer to image in memory - RRGGBBRRGGBB..
ecx image size [x]*65536+[y]
edx image position in window [x]*65536+[y]
ret: eax 0 succesful, 1 overlapped
*/
inline fastcall dword sys_put_image(dword EBX, ECX, EDX)
{
EAX = 7;
$int 0x40
}
 
/*
08 = DEFINE BUTTON
ebx [x start]*65536 + [x size]
ecx [y start]*65536 + [y size]
edx button id number
esi button color 0x 00 RR GG BB
ret: nothing changed
*/
inline fastcall void sys_draw_button(dword EBX, ECX, EDX, ESI)
{
EAX = 8;
$int 0x40
}
 
/*
09 = PROCESS INFO
ebx pointer to 1024 bytes table
ecx process number or -1 = who am I
ret: eax number of processes
table : +00 dword cpu usage
+04 word processes position in windowing stack
+06 word window stack value at ecx
+10 12 db name of the process
+22 dword start of processes memory
+26 dword memory used by process
+30 dword PID of the process
+34 dword window x start
+38 dword window y start
+42 dword window x size
+46 dword window y size
*/
inline fastcall dword sys_process_info(dword EBX, ECX)
{
EAX = 9;
$int 0x40
}
 
/*
10 = WAIT FOR EVENT
ret: eax event type, 1 window redraw, 2 key in buffer, 3 button pressed
*/
inline fastcall dword sys_wait_event()
{
EAX = 10; // wait here for event
$int 0x40
}
 
/*
11 = CHECK FOR EVENT, NO WAIT
ret: eax 0 no event, 1 window redraw, 2 key in buffer, 3 button pressed
*/
inline fastcall dword sys_nowait_event()
{
EAX = 11;
$int 0x40
}
 
/* 12 = WINDOW REDRAW
EBX=1 start of draw, =2 end of draw.
*/
inline fastcall void sys_window_redraw(dword EBX)
{
EAX = 12; // function 12:tell os about windowdraw
$int 0x40
}
 
/*
13 = DRAW BAR
DrawBar(EBX=[xstart][xsize],ECX=[ystart][ysize],EDX=[0x00RRGGBB])
ebx [x start]*65536 + [x size]
ecx [y start]*65536 + [y size]
edx color 0x00RRGGBB
ret: nothing changed
*/
inline fastcall void sys_draw_bar(dword EBX, ECX, EDX)
{
EAX = 13;
$int 0x40
}
 
/*
14 = GET SCREEN MAX
ret: eax [screen x max]*65536 + [screen y max]
*/
inline fastcall dword sys_get_screen_size()
{
EAX = 14;
$int 0x40
}
 
/*
15 = BACKGROUND
ebx 1 : set background size
ecx x size
edx y size
ebx 2 : write to background memory - max (0x100000-16)
ecx position in memory in bytes
edx color 0x00RRGGBB
ebx 3 : draw background
ebx 4 : type of background draw
ecx 1 - tile
ecx 2 - stretch
ebx 5 : blockmove image to os bgr memory
ecx - from
edx - to where in os bgr memory
esi - count of bytes to move
*/
inline fastcall void sys_set_background(dword EBX, ECX, EDX, ESI)
{
EAX = 15;
$int 0x40
}
 
 
/*
17 = GET PRESSED BUTTON ID
ret: al 0 successful -> ah = id number al 1 no key in buffer.
MODIFIED, see below.
*/
inline fastcall dword sys_get_button_id()
{
EAX = 17; // Get ID
$int 0x40
$shr eax,8
} //eax=id, eax=0 no id.
 
/*
18 = SYSTEM SERVICE
ebx 1 - system boot
ebx 2 - force terminate , ecx process no
ebx 4 - idle clock cycles / second
ebx 5 - time stamp counter / second - cpu speed
HD-> ebx 6 - save ramdisk to /hd/1/menuet.img
*/
inline fastcall dword sys_service(dword EBX, ECX)
{
EAX = 18;
$int 0x40
}
 
/*
19 = START PROGRAM from RAMDISK
ebx point to 11 char filename
ecx 0, or point to ASCIIZ start parameters - max 256 bytes
ret: eax 0 successful
eax other error code
*/
inline fastcall dword sys_exec_app_ramdisk(dword EBX, ECX)
{
EAX = 19;
$int 0x40
}
 
/*
20 = MIDI INTERFACE - MPU401
ebx 1 - reset device
ebx 2 - cl midi data to output
*/
inline fastcall void sys_midi(dword EBX)
{
EAX = 20;
$int 0x40
}
 
/*
21 = SETUP FOR DEVICES
ebx 1=roland mpu midi base , base io address
ebx 2=keyboard 1 base keymap 2 shift keymap (ecx pointer to keymap)
9 country 1eng 2fi 3ger 4rus
ebx 3=cd base 1 pri.master 2 pri slave,
3 sec master 4 sec slave
ebx 4=sb16 base, base io address
ebx 5=system language, 1eng 2fi 3ger 4rus
ebx 6=wss base, base io address
ebx 7=hd base, 1 pri.master 2 pri slave
3 sec master 4 sec slave
ebx 8=fat32 partition in hd
*/
inline fastcall void sys_setup_devices(dword EBX, ECX)
{
EAX = 21;
$int 0x40
}
 
/*
23 = WAIT FOR EVENT WITH TIMEOUT
ebx time to delay in hs
ret: eax event type: 0 no event, 1 window redraw,
2 key in buffer, 3 button
*/
inline fastcall dword sys_wait_event_timeout(dword EBX)
{
EAX = 23;
$int 0x40
}
 
/*
24 = CD AUDIO
ebx 1 - play from ecx 00 FR SS MM
ebx 2 - get playlist size of ecx to [edx]
ebx 3 - stop/pause play
*/
inline fastcall void sys_cd_audio(dword EBX, ECX, EDX)
{
EAX = 24;
$int 0x40
}
 
/*
25 = SB16 - mixer I
ebx 1 - set main volume cl [L]*16+[R]
ebx 2 - set cd volume cl [L]*16+[R]
*/
inline fastcall void sys_sb16_mixer_1(dword EBX, ECX)
{
EAX = 25;
$int 0x40
}
 
/*
26 = GET SETUP FOR DEVICES
ebx 1=roland mpu midi base , base io address
ebx 2=keyboard 1 base keymap 2 shift keymap
9 country 1eng 2fi 3ger 4rus
ebx 3=cd base 1 pri.master 2 pri slave,
3 sec master 4 sec slave
ebx 4=sb16 base, base io address
ebx 5=system language, 1eng 2fi 3ger 4rus
ebx 6=wss base, base io address
ebx 7=hd base, 1 pri.master 2 pri slave
3 sec master 4 sec slave
ebx 8=fat32 partition in hd
ebx 9=1/100 timer tics from stard -> eax
return value in eax
*/
inline fastcall dword sys_get_setup_devices(dword EBX)
{
EAX = 26;
$int 0x40
}
 
/*
27 = WINDOWS SOUND SYSTEM
ebx 1 - set main volume to cl 0-255
ebx 2 - set cd volume to cl 0-255
*/
inline fastcall void sys_windows_sound_system(dword EBX, ECX)
{
EAX = 27;
$int 0x40
}
 
/*
28 = SB16 - mixer II
ebx 1 - set main volume to cl 0-255
ebx 2 - set cd volume to cl 0-255
*/
inline fastcall void sys_sb16_mixer_2(dword EBX, ECX)
{
EAX = 28;
$int 0x40
}
 
/*
29 = GET DATE
ret: eax 0x00YYDDMM year date month
*/
inline fastcall dword sys_get_date()
{
EAX = 29;
$int 0x40
}
 
/*
30 = READ HD
ebx pointer to file
ecx file lenght
edx block to read, starts from 1, blocksize = 512 bytes
esi reserved, set as 1
edi pointer to return/work area (atleast 20 000 bytes)
return: work_area+1024 <- requested block of 512 bytes
*/
inline fastcall dword sys_read_hd(dword EBX, ECX, EDX, ESI, EDI)
{
EAX = 30;
$int 0x40
}
 
/*
31 = START APP FROM HD
ebx pointer to file
ecx file lenght
edx pointer to return/work area (atleast 20 000 bytes)
ret eax=0 successful, eax<>0 errorcode
*/
inline fastcall dword sys_exec_app_hd()
{
EAX = 31;
$int 0x40
}
 
/*
32 = DELETE FILE FROM FLOPPY IMAGE IN MEMORY
ebx pointer to filename
*/
 
inline fastcall dword sys_floppy_delete(EBX)
{
EAX = 32;
$int 0x40
}
 
/*
33 = SAVE FILE TO FLOPPY IMAGE IN MEMORY
ebx pointer to file name
ecx pointer to data
edx count to write in bytes
esi 0 create new , ( 1 append - not implemented yet )
*/
inline fastcall dword sys_floppy_save(EBX,ECX,EDX)
{
EAX = 33;
ESI = 0;
$int 0x40
}
 
/*
34 = READ DIRECTORY FROM FLOPPY
ebx reserved : set as zero
ecx reserved : set as zero
edx start 512 block to read
esi reserved : set as 1
edi pointer to return area
 
 
35 = READ SCREEN PIXEL
ebx = pixel count from top left of the screen
return : eax = 0x00RRGGBB
*/
 
/*
37 = READ MOUSE POSITION
ebx=0 screen relative
ebx=1 window relative
ebx=2 buttons pressed
return in eax
*/
inline fastcall dword sys_read_mouse(dword EBX)
{
EAX = 37;
$int 0x40
}
 
/*
38 = DRAW LINE
ebx [x start] shl 16 + [x end]
ecx [y start] shl 16 + [y end]
edx colour 0x00RRGGBB
return : nothing changed
*/
inline fastcall void sys_draw_line(dword EBX, ECX, EDX)
{
EAX = 38;
$int 0x40
}
 
/*
39 = GET BACKGROUND
ebx=1 -> eax=[bgr x size] shl 16 + [bgr y size]
ebx=2
ecx= postition of backgrounds memorymap to return in eax
ebx=4 -> eax=1 tiled, eax=2 stretched
*/
inline fastcall dword sys_get_background(dword EBX, ECX)
{
EAX = 39;
$int 0x40
}
 
/*
40 = SET BITFIELD FOR WANTED EVENTS
as default:
ebx = 00000000 00000000 00000000 00000111b events:
I window draw
I key in buffer
I button in buffer
I (end request)
I desktop background draw
I (mouse change)
I---------------I get irqs data
 
 
41 = GET IRQ OWNER
ebx = irq
return : PID of the process
 
 
42 = GET DATA READ BY IRQ
ebx IRQ number
return : eax number of bytes in buffer
bl data
ecx 0 = successful data read
1 = no data in buffer
2 = incorrect IRQ owner
 
 
43 = SEND DATA TO DEVICE
bx : port
cl : data
return : eax = if 0 successful, other = error
 
 
44 = PROGRAM IRQ's
ebx pointer to table
ecx irq number
 
 
45 = RESERVE/FREE IRQ
ebx 0 reserve 1 free
ecx IRQ number
ret eax 0 successful, 1 error
 
 
46 = RESERVE/FREE PORT AREA
ebx 0 reserve 1 free
ecx port area start
edx port area end
ret eax 0 successful, 1 error
*/
 
/*
47 = DISPLAY NUMBER TO WINDOW
ebx = print type, bl=0 -> ecx is number
bl=1 -> ecx is pointer
bh=0 -> display decimal
bh=1 -> display hexadecimal
bh=2 -> display binary
bits 16-21 = number of digits to display (0-32)
bits 22-31 = reserved
ecx = number or pointer
edx = x shl 16 + y
esi = color
*/
inline fastcall void sys_write_number(dword EBX, ECX, EDX, ESI)
{
EAX = 47;
$int 0x40
}
 
/*
48 = DEFINE GENERAL WINDOW PROPERTIES
ebx = 0 apply/redraw
ecx = 0 , apply/redraw desktop
ebx = 1 define button style
ecx = 0 , set flat buttons
ecx = 1 , set 3d buttons
ebx = 2 define window colors
ecx = pointer to table
edx = number of bytes defined
ebx = 3 get define window colors
ecx = pointer to table
edx = number of bytes to get
*/
 
inline fastcall void sys_redraw_desktop()
{
EAX = 48;
EBX = ECX = 0;
$int 0x40
}
 
inline fastcall void sys_set_button_style(dword ECX)
{
EAX = 48;
EBX = 1;
$int 0x40
}
 
inline fastcall void sys_set_colors(dword ECX,EDX)
{
EAX = 48;
EBX = 2;
$int 0x40
}
 
inline fastcall void sys_get_colors(dword ECX,EDX)
{
EAX = 48;
EBX = 3;
$int 0x40
}
 
/*
49 = DEFINE APPLICATIONS INTERNAL INTERRUPTS
ebx = 0
ecx point to dword x 256 table of interrupt entries
inside the application
return : nothing changed
 
 
50 = FREE FORM WINDOW SHAPE AND SCALE
ebx = 0 ; shape reference area
ecx = pointer to reference area
byte per pixel, 0 not used, 1=used, other = reserved
ebx = 1 ; scale of reference area (default 1:1)
ecx : scale is set to 2^ecx
return: nothing changed
 
 
51 = CREATE THREAD
ebx = 1 ; create
ecx ; = thread entry point
edx ; = thread stack position
return : eax = pid or 0xfffffff0+ for error
*/
 
inline fastcall dword sys_create_thread(dword ECX,EDX)
{
EAX = 51;
EBX = 1;
$int 0x40
}
 
/*
 
52 = STACK DRIVER STATUS
- see stack.txt
 
 
53 = SOCKET INTERFACE
- see stack.txt
 
 
54 = USER EVENTS
- not ready yet
 
 
55 = SOUND INTERFACE
ebx = 0 ; load 44 khz 8 bit mono sound block
ecx ; = pointer to 65536 byte soundblock
ebx = 1 ; play 44 khz 8 bit mono sound block
 
 
56 = WRITE FILE TO HD
ebx pointer to 12 char filename
ecx bytes to write
edx pointer to data to write
esi pointer to path
path db 0
 
 
57 = DELETE FILE FROM HD
ebx pointer to filename : 11 capital letters
edx pointer to path : path db 0
*/
 
 
/*
58 = SYSTEM TREE ACCESS
ebx pointer to fileinfo block
fileinfo:
dd 0x0 ; 0=read (/write/delete/append)
dd 0x0 ; 512 block to read 0+
dd 0x1 ; blocks to read (/bytes to write/append)
dd 0x20000 ; return data pointer
dd 0x10000 ; work area for os - 16384 bytes
db '/RAMDISK/FIRST/KERNEL.ASM',0 ; ASCIIZ dir & filename
*/
inline fastcall void sys_tree_access(dword EBX)
{
EAX = 58;
$int 0x40
}
 
/*
59 = TRACE FOR SYSTEM CALLS FROM PROCESSES
ebx = 0 ; get system events
ecx ; pointer to table -> ; 64 bytes/system call descriptor
; +00 PID
; +32 EDI
; +36 ESI
; +40 EBP
; +44 ESP
; +48 EBX
; +52 EDX
; +56 ECX
; +60 EAX
edx ; number of bytes to return to table (currently max 16*64)
return: eax = number of system calls from start
latest call is saved to (eax mod 16)*64 in table
ebx = 0 : above format
*/
 
/*
60 = IPC
ebx = 1 ; define receive area
ecx = pointer to start
edx = size of area
 
ebx = 2 ; send message
ecx = PID
edx = pointer to message
esi = length
*/
 
inline fastcall void sys_ipc_init(dword ECX, EDX)
{
EAX = 60;
EBX = 1;
$int 0x40
}
 
inline fastcall void sys_ipc_send(dword ECX, EDX, ESI)
{
EAX = 60;
EBX = 2;
$int 0x40
}
 
/* -1 = EXIT PROCESS */
 
inline fastcall void sys_exit_process()
{
$xor eax,eax
$dec eax
$int 0x40
}
/programs/games/mine/trunk/random.h--
0,0 → 1,52
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
*******************************************************************************/
 
dword generator; // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
 
:int random(int max)
// get pseudo-random number - ïîëó÷èòü ïñåâäîñëó÷àéíîå ÷èñëî
{
$rdtsc // eax & edx
$xor eax,edx
$not eax
 
EBX = generator;
$ror ebx,3
$xor ebx,0xdeadbeef
EBX += EAX;
generator = EBX;
EAX += EBX;
EAX = EAX % max;
return EAX;
}
 
:randomize()
// initialize random number generator - èíèöèàëèçèðîâàòü ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
{
asm
{
mov eax,3
int 0x40
ror eax,16
}
generator = EAX;
}
/programs/games/mine/trunk/timer.h--
0,0 → 1,52
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
*******************************************************************************/
 
dword time,
ttime;
 
byte timer_life;
 
start_timer()
{
timer_life = TRUE;
ttime = sys_get_clock();
}
 
stop_timer()
{
timer_life = FALSE;
}
 
check_timer()
{
IF (!timer_life) return;
 
EAX = sys_get_clock();
IF (EAX == 0xffffff) return;
IF (ttime != EAX)
{
ttime = EAX;
IF (time < 999)
time++;
draw_time();
}
}
/programs/games/mine/trunk/uf.h--
0,0 → 1,135
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
*******************************************************************************/
 
// USER FIELD WINDOW
 
byte px,py,pm;
 
byte uf_open = FALSE;
byte uf_stack[2048];
 
byte str1[5];
byte str2[5];
byte str3[5];
 
dword uf_x,
uf_y;
 
void draw_uf_window()
{
sys_get_colors(#colors, 40);
sys_window_redraw(1);
 
EDX = colors.w_work;
$bts edx,25
sys_draw_window(uf_x, uf_y, EDX, colors.w_grab | 0x80000000, colors.w_frames);
ECX = colors.w_grab_text | 0x10000000;
sys_write_text(8<<16+8, colors.w_grab_text | 0x10000000, "USER FIELD", 10);
sys_draw_button(81<<16+12, 5<<16+12, 1, colors.w_grab_button);
 
ECX = colors.w_work_text | 0x10000000;
sys_write_text(8<<16+31, ECX, "WIDTH", 5);
sys_write_text(8<<16+49, ECX, "HEIGHT", 6);
sys_write_text(8<<16+67, ECX, "MINES", 5);
 
// three buttons:
// 1) WIDTH 10
// 2) HEIGHT 11
// 3) MINES 12
// and also:
// OK, Cancel - 20,21
 
sys_draw_button(54<<16+38, 30<<16+10, 10, 0xe0e0e0); // WIDTH
EDX++; sys_draw_button(EBX, 48<<16+10, EDX, ESI); // HEIGHT
EDX++; sys_draw_button(EBX, 66<<16+10, EDX, ESI); // MINES
 
ESI = colors.w_work_button;
ECX = 84<<16+10;
sys_draw_button( 8<<16+38, ECX, 20, ESI); EDX++;
sys_draw_button(54<<16+38, ECX, EDX, ESI);
 
sys_write_text(21<<16+85, colors.w_work_button_text, "OK Cancel", 12);
 
sys_window_redraw(2);
}
 
void uf_main()
{
uf_x <<= 16; uf_x += 100;
uf_y <<= 16; uf_y += 104;
draw_uf_window();
 
WHILE()
{
SWITCH (sys_wait_event())
{
case 1: draw_uf_window();
break;
 
case 2: IF (sys_get_key() == 27)
{
uf_open = FALSE;
sys_exit_process();
}
break;
 
case 3: uf_button();
}
}
}
 
uf_button()
{
switch (sys_get_button_id())
{
//case 10:
//case 11:
//case 12:
 
case 20:
case 21:
 
case 1:
uf_open = FALSE;
sys_exit_process();
}
}
 
void start_uf()
{
sys_process_info(#procinfo, -1);
uf_x = procinfo.xstart + XST;
uf_y = procinfo.ystart + YST;
 
sys_create_thread(#uf_main, #uf_stack + 2048);
uf_open = TRUE;
mouse_disable();
WHILE (uf_open == TRUE)
{
SWITCH (sys_wait_event_timeout(5))
{
CASE 1: draw_window(); CONTINUE;
CASE 2: sys_get_key(); CONTINUE;
CASE 3: sys_get_button_id(); CONTINUE;
}
}
mouse_enable();
}
/programs/games/phenix/trunk/ascgl.inc
0,0 → 1,1385
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Graphics
; Libary
;
; Ver 0.18 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 LoadImage
;0.02 SetBmp
;0.03 Bmptoimg, Setimg ~01.03.2004
;0.04 Bug deleted, copyimg ~03.05.2004
;0.05 fullimg, collimg ~05.05.2004
;0.06 getimg ~09.05.2004
;0.07 convbmp ~13.05.2004
;0.08 fps ~14.05.2004
;0.09 drawfbox ~03.06.2004
;0.10 all macros optimized by halyavin, add at ~07.06.2004
;0.11 many macros optimized by halyavin, add at ~30.08.2004
;0.12 bmptoimg ~07.09.2004
;0.13 imgtoimg ~08.09.2004
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
;0.15 giftoimg, giftoani ~10.09.2004
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
 
aframetoimg_use_count=0
macro aframetoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aframetoimg_use_count=aframetoimg_use_count+1
if aframetoimg_use_count = 1
 
jmp end_aframetoimg_proc
 
acolor dd 0
aframetoimg_proc:
;getout coord
mov [acolor],ebp
 
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aframetoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aframetoimg_proc
}
 
frametoimg_use_count=0
macro frametoimg img, x, y, canvas
{
local loo,loo2
frametoimg_use_count=frametoimg_use_count+1
if frametoimg_use_count = 1
 
jmp end_frametoimg_proc
 
frametoimg_proc:
;getout coord
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
 
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_frametoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call frametoimg_proc
}
 
 
aimgtoimg_use_count=0
macro aimgtoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aimgtoimg_use_count=aimgtoimg_use_count+1
if aimgtoimg_use_count = 1
 
jmp end_aimgtoimg_proc
 
acolor dd 0
aimgtoimg_proc:
;getout coord
mov [acolor],ebp
 
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
 
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aimgtoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aimgtoimg_proc
}
 
 
 
 
imgtoimg_use_count=0
macro imgtoimg img, x, y, canvas
{
local loo,loo2
imgtoimg_use_count=imgtoimg_use_count+1
if imgtoimg_use_count = 1
 
jmp end_imgtoimg_proc
imgtoimg_proc:
;getout coord
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_imgtoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call imgtoimg_proc
}
 
 
;DrawBox
macro drawfbox x,y,xs,ys,color
{
wordstoreg ebx,x,xs ;x*65536+xs
wordstoreg ecx,y,ys ;y*65536+ys
mov edx,color
mov eax,13
int 0x40
}
 
; FPS - Set Frame Per Second Display
fps_show_frequency=40
macro fps x,y,color,delcolor
{
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
local no_out_fps
jmp spdat
savetime dd 0
fps_cntr dd 0
fps dd 0
ttt dd 0
spdat:
get_time:
mov eax,3
int 0x40
cmp eax,[savetime]
jne new_time
inc [fps_cntr]
cmp dword [ttt],0
je out_fps
dec dword [ttt]
jmp no_out_fps
new_time:
mov [savetime],eax
mov ebx,