/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: |
} |