programs sources added
git-svn-id: svn://kolibrios.org@31 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
1 parent
4a0bec74c6
commit
065b8d32b2
667 files changed
+191000
No files matched your search
@@ -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:
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm 15.asm 15
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm 15.asm 15
|
||||
@pause
|
||||
@@ -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
|
||||
@@ -0,0 +1,691 @@
|
||||
;
|
||||
; 3D POLYGONAL CUBE - ASCL
|
||||
;
|
||||
; Pavlushin Evgeni
|
||||
; mail: waptap@mail.ru site: www.deck4.narod.ru
|
||||
;
|
||||
; Create on base 3D test sample
|
||||
; Mikolaj Felix mfelix@polbox.com
|
||||
;
|
||||
|
||||
use32
|
||||
org 0x0
|
||||
db 'MENUET01' ; 8 byte id
|
||||
dd 0x01 ; header version
|
||||
dd START ; start of code
|
||||
dd I_END ; size of image
|
||||
dd 0x30000 ; memory for app
|
||||
dd 0x30000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Icon
|
||||
|
||||
MAX_POINTS equ 8
|
||||
MAX_TRIANGLES equ 12
|
||||
SCREEN_X equ 320
|
||||
SCREEN_Y equ 200
|
||||
|
||||
include 'lang.inc'
|
||||
include 'ascl.inc'
|
||||
include 'ascgl.inc'
|
||||
include 'macros.inc'
|
||||
START:
|
||||
call draw_window
|
||||
call init_sin_cos
|
||||
|
||||
still:
|
||||
; mov eax,23 ; wait for system event with 10 ms timeout
|
||||
; mov ebx,1 ; wait 10 ms, then continue
|
||||
; int 0x40
|
||||
|
||||
mov eax,11
|
||||
int 0x40
|
||||
|
||||
dec eax
|
||||
; cmp eax,1 ; window redraw request ?
|
||||
jz red
|
||||
dec eax
|
||||
; cmp eax,2 ; key in buffer ?
|
||||
jz key
|
||||
dec eax
|
||||
; cmp eax,3 ; button in buffer ?
|
||||
jz button
|
||||
|
||||
fps 280,8,cl_White,cl_Black
|
||||
|
||||
main_loop:
|
||||
|
||||
mov esi,object
|
||||
mov edi,object_rotated
|
||||
mov ecx,MAX_POINTS*3
|
||||
cld
|
||||
rep movsw
|
||||
|
||||
mov esi,angle_x
|
||||
mov edi,object_rotated
|
||||
mov ecx,MAX_POINTS
|
||||
call rotate_points
|
||||
|
||||
mov esi,object_rotated
|
||||
mov edi,object_translated
|
||||
mov ecx,MAX_POINTS
|
||||
call translate_points
|
||||
|
||||
call draw_faces
|
||||
|
||||
call clear_screen_buffer
|
||||
|
||||
add [angle_x],2
|
||||
add [angle_y],3
|
||||
add [angle_z],1
|
||||
|
||||
jmp still
|
||||
|
||||
red:
|
||||
call draw_window
|
||||
jmp still
|
||||
key:
|
||||
mov eax,2
|
||||
int 0x40
|
||||
jmp still
|
||||
button:
|
||||
mov eax,17
|
||||
int 0x40
|
||||
cmp ah,1
|
||||
jne still
|
||||
exit:
|
||||
mov eax,-1
|
||||
int 0x40
|
||||
|
||||
;Draw window
|
||||
draw_window:
|
||||
mov eax,12 ;Start
|
||||
mov ebx,1
|
||||
int 0x40
|
||||
|
||||
mov eax,0 ;Draw window
|
||||
mov ebx,100*65536+(SCREEN_X+9) ;x start*65536+x size
|
||||
mov ecx,100*65536+(SCREEN_Y+26) ;y start*65536+y size
|
||||
mov edx,0x03000000 ;0x03 use skinned window
|
||||
int 0x40
|
||||
|
||||
mov eax,4 ;Out Text
|
||||
mov ebx,8*65536+8 ;x start*65536+y start
|
||||
mov ecx,0x00ffffff ;color White
|
||||
mov edx,head_label
|
||||
mov esi,hl_end-head_label
|
||||
int 0x40
|
||||
|
||||
mov eax,12 ;End
|
||||
mov ebx,2
|
||||
int 0x40
|
||||
ret
|
||||
|
||||
head_label: db "3D TEST SAMPLE FOR MENUETOS"
|
||||
hl_end:
|
||||
|
||||
|
||||
|
||||
; Draw faces procedure
|
||||
|
||||
draw_faces:
|
||||
|
||||
mov esi,link
|
||||
mov ecx,MAX_TRIANGLES
|
||||
df_draw:
|
||||
push ecx
|
||||
mov ecx,3
|
||||
mov edi,@@tx1 ;bp
|
||||
df_get_point:
|
||||
xor bh,bh
|
||||
mov bl,byte [esi]
|
||||
shl bx,2
|
||||
mov ax,word [object_translated+bx]
|
||||
mov word [edi],ax
|
||||
mov ax,word [object_translated+bx+2]
|
||||
mov word [edi+2],ax
|
||||
inc esi
|
||||
add edi,4
|
||||
dec ecx
|
||||
jnz df_get_point
|
||||
|
||||
mov ax,[@@ty1]
|
||||
sub ax,[@@ty3]
|
||||
mov bx,[@@tx2]
|
||||
sub bx,[@@tx1]
|
||||
imul bx
|
||||
shl edx,16
|
||||
mov dx,ax
|
||||
push edx
|
||||
mov ax,[@@tx1]
|
||||
sub ax,[@@tx3]
|
||||
mov bx,[@@ty2]
|
||||
sub bx,[@@ty1]
|
||||
imul bx
|
||||
shl edx,16
|
||||
mov dx,ax
|
||||
pop ebx
|
||||
sub ebx,edx
|
||||
or ebx,ebx
|
||||
jge df_next
|
||||
|
||||
xor ah,ah
|
||||
mov al,byte [si]
|
||||
|
||||
mov [@@xcol],ax
|
||||
|
||||
call filled_triangle
|
||||
df_next:
|
||||
inc si
|
||||
pop ecx
|
||||
dec ecx
|
||||
jnz df_draw
|
||||
ret
|
||||
|
||||
;modify
|
||||
;include graphlib.asm
|
||||
|
||||
clear_screen_buffer:
|
||||
|
||||
;outscrbuf
|
||||
mov ebx,scrbuf
|
||||
mov ecx,SCREEN_X*65536+SCREEN_Y
|
||||
mov edx,5*65536+22
|
||||
mov ax,7
|
||||
int 0x40
|
||||
|
||||
;White background
|
||||
mov edi,scrbuf
|
||||
mov ecx,(SCREEN_X*SCREEN_Y*3)/4
|
||||
mov eax,0xffffffff
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
ret
|
||||
|
||||
;include triangle.asm
|
||||
; Mikolaj Felix 14/5/2001
|
||||
; mfelix@polbox.com
|
||||
|
||||
;filled trangle procedure
|
||||
|
||||
@@tx1 dw 0
|
||||
@@ty1 dw 0
|
||||
@@tx2 dw 0
|
||||
@@ty2 dw 0
|
||||
@@tx3 dw 0
|
||||
@@ty3 dw 0
|
||||
@@xcol dw 0
|
||||
|
||||
@@dx12 dw 0
|
||||
@@dx13 dw 0
|
||||
@@dx23 dw 0
|
||||
|
||||
filled_triangle:
|
||||
|
||||
mov ax,[@@xcol] ;trnsforming color
|
||||
mov bl,al ;byte bbbggrrx
|
||||
mov dl,al ;to 3 byte
|
||||
mov dh,al ;bbbxxxxx ggxxxxxx rrxxxxxx
|
||||
and dh,00000001b
|
||||
|
||||
and al,11100000b
|
||||
and bl,00011000b
|
||||
and dl,00000110b
|
||||
shl bl,3
|
||||
shl dl,5
|
||||
|
||||
cmp dh,1
|
||||
jne no_bitup
|
||||
or al,00011111b
|
||||
or bl,00111111b
|
||||
or dl,00111111b
|
||||
no_bitup:
|
||||
|
||||
shl eax,8 ;puck colors
|
||||
mov al,bl
|
||||
shl eax,8
|
||||
mov al,dl
|
||||
mov dword [@@rgb],eax
|
||||
mov eax,0 ; for 16 bit instructions
|
||||
|
||||
mov ax,[@@ty1]
|
||||
cmp ax,[@@ty3]
|
||||
jb ft_check1
|
||||
|
||||
xchg ax,[@@ty3]
|
||||
mov [@@ty1],ax
|
||||
|
||||
mov ax,[@@tx1]
|
||||
xchg ax,[@@tx3]
|
||||
mov [@@tx1],ax
|
||||
ft_check1:
|
||||
mov ax,[@@ty2]
|
||||
cmp ax,[@@ty3]
|
||||
jb ft_check2
|
||||
|
||||
xchg ax,[@@ty3]
|
||||
mov [@@ty2],ax
|
||||
|
||||
mov ax,[@@tx2]
|
||||
xchg ax,[@@tx3]
|
||||
mov [@@tx2],ax
|
||||
ft_check2:
|
||||
mov ax,[@@ty1]
|
||||
cmp ax,[@@ty2]
|
||||
jb ft_check3
|
||||
|
||||
xchg ax,[@@ty2]
|
||||
mov [@@ty1],ax
|
||||
|
||||
mov ax,[@@tx1]
|
||||
xchg ax,[@@tx2]
|
||||
mov [@@tx1],ax
|
||||
ft_check3:
|
||||
|
||||
mov bx,[@@ty2]
|
||||
sub bx,[@@ty1]
|
||||
jnz ft_dx12_make
|
||||
|
||||
mov [@@dx12],word 0
|
||||
jmp ft_dx12_done
|
||||
ft_dx12_make:
|
||||
mov ax,[@@tx2]
|
||||
sub ax,[@@tx1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@dx12],ax ; dx12 = (x2-x1)/(y2-y1)
|
||||
ft_dx12_done:
|
||||
|
||||
mov bx,[@@ty3]
|
||||
sub bx,[@@ty1]
|
||||
jnz ft_dx13_make
|
||||
|
||||
mov [@@dx13],word 0
|
||||
jmp ft_dx13_done
|
||||
ft_dx13_make:
|
||||
mov ax,[@@tx3]
|
||||
sub ax,[@@tx1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@dx13],ax ; dx13 = (x3-x1)/(y3-y1)
|
||||
ft_dx13_done:
|
||||
|
||||
mov bx,[@@ty3]
|
||||
sub bx,[@@ty2]
|
||||
jnz ft_dx23_make
|
||||
|
||||
mov [@@dx23],word 0
|
||||
jmp ft_dx23_done
|
||||
ft_dx23_make:
|
||||
mov ax,[@@tx3]
|
||||
sub ax,[@@tx2]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@dx23],ax ; dx23 = (x3-x2)/(y3-y2)
|
||||
ft_dx23_done:
|
||||
|
||||
mov ax,[@@tx1]
|
||||
shl ax,7
|
||||
mov bx,ax
|
||||
|
||||
mov cx,[@@ty1]
|
||||
ft_loop1:
|
||||
|
||||
pushad
|
||||
|
||||
mov [@@ly],cx
|
||||
mov dx,bx
|
||||
shr dx,7
|
||||
mov [@@lx2],dx
|
||||
mov dx,ax
|
||||
shr dx,7
|
||||
mov [@@lx1],dx
|
||||
mov ax,[@@xcol]
|
||||
mov [@@lcol],ax
|
||||
call horizontal_line
|
||||
|
||||
popad
|
||||
|
||||
add ax,[@@dx13]
|
||||
add bx,[@@dx12]
|
||||
inc cx
|
||||
cmp cx,[@@ty2]
|
||||
jb ft_loop1
|
||||
|
||||
|
||||
mov bx,[@@tx2]
|
||||
shl bx,7
|
||||
mov cx,[@@ty2]
|
||||
ft_loop2:
|
||||
|
||||
pushad
|
||||
|
||||
mov [@@ly],cx
|
||||
mov dx,bx
|
||||
shr dx,7
|
||||
mov [@@lx2],dx
|
||||
mov dx,ax
|
||||
shr dx,7
|
||||
mov [@@lx1],dx
|
||||
mov ax,[@@xcol]
|
||||
mov [@@lcol],ax
|
||||
call horizontal_line
|
||||
|
||||
popad
|
||||
|
||||
add ax,[@@dx13]
|
||||
add bx,[@@dx23]
|
||||
inc ecx
|
||||
cmp cx,[@@ty3]
|
||||
jb ft_loop2
|
||||
|
||||
ret
|
||||
|
||||
;horizontal line subproc
|
||||
|
||||
@@lx1 dw 0
|
||||
@@lx2 dw 0
|
||||
@@ly dw 0
|
||||
@@lcol dw 0
|
||||
|
||||
@@rgb dd 0
|
||||
|
||||
horizontal_line:
|
||||
|
||||
mov ecx,0
|
||||
mov cx,[@@lx1]
|
||||
cmp cx,[@@lx2]
|
||||
ja x12
|
||||
je ext
|
||||
; ret
|
||||
mov cx,[@@lx2]
|
||||
sub cx,[@@lx1]
|
||||
mov edi,3
|
||||
jmp xx
|
||||
x12:
|
||||
mov cx,[@@lx1]
|
||||
sub cx,[@@lx2]
|
||||
mov edi,-3
|
||||
jmp xx
|
||||
ext:
|
||||
mov ecx,-1 ;1
|
||||
; sub ebp,3
|
||||
xx:
|
||||
mov eax,0
|
||||
mov ax,[@@ly]
|
||||
mov ebx,SCREEN_X ;320
|
||||
mul ebx
|
||||
mov ebp,0
|
||||
mov bp,[@@lx1] ;for correct 16 bit size
|
||||
add eax,ebp
|
||||
mov ebx,3
|
||||
mul ebx
|
||||
mov ebp,eax
|
||||
sub ebp,3 ;for delete white dots
|
||||
add ecx,2
|
||||
loo:
|
||||
|
||||
mov eax,dword [@@rgb]
|
||||
mov bl,al
|
||||
shr eax,8 ;puck colors
|
||||
|
||||
mov byte [scrbuf+ebp],ah
|
||||
mov byte [scrbuf+ebp+1],al
|
||||
mov byte [scrbuf+ebp+2],bl
|
||||
add ebp,edi
|
||||
dec ecx
|
||||
jnz loo
|
||||
|
||||
ret
|
||||
|
||||
;include fixed3d.asm
|
||||
; Mikolaj Felix 25/5/2001
|
||||
; mfelix@polbox.com
|
||||
|
||||
;------------------------------------------------------------
|
||||
; ds:si - offset to angles
|
||||
; ds:di - offset to 3d points
|
||||
; cx - number of points
|
||||
;------------------------------------------------------------
|
||||
|
||||
@@sin_x dw 0
|
||||
@@cos_x dw 0
|
||||
@@sin_y dw 0
|
||||
@@cos_y dw 0
|
||||
@@sin_z dw 0
|
||||
@@cos_z dw 0
|
||||
|
||||
@@px equ word [edi]
|
||||
@@py equ word [edi+2]
|
||||
@@pz equ word [edi+4]
|
||||
|
||||
rotate_points:
|
||||
|
||||
push edi
|
||||
mov edi,@@sin_x
|
||||
mov edx,3
|
||||
rp_sin_cos:
|
||||
mov bx,word [esi]
|
||||
and bx,511
|
||||
shl bx,1
|
||||
mov ax,word [sin_table+bx]
|
||||
mov word [edi],ax
|
||||
mov ax,word [cos_table+bx]
|
||||
mov word [edi+2],ax
|
||||
|
||||
add esi,2
|
||||
add edi,4
|
||||
dec edx
|
||||
jnz rp_sin_cos
|
||||
pop edi
|
||||
|
||||
rp_rotate:
|
||||
|
||||
; rotate around x-axis
|
||||
|
||||
mov ax,@@py
|
||||
imul [@@cos_x]
|
||||
mov bx,ax
|
||||
mov si,dx
|
||||
|
||||
mov ax,@@pz
|
||||
imul [@@sin_x]
|
||||
sub bx,ax
|
||||
sbb si,dx
|
||||
shrd bx,si,14
|
||||
push bx
|
||||
|
||||
mov ax,@@py
|
||||
imul [@@sin_x]
|
||||
mov bx,ax
|
||||
mov si,dx
|
||||
|
||||
mov ax,@@pz
|
||||
imul [@@cos_x]
|
||||
add bx,ax
|
||||
adc si,dx
|
||||
shrd bx,si,14
|
||||
|
||||
pop @@py
|
||||
mov @@pz,bx
|
||||
|
||||
; rotate around y-axis
|
||||
|
||||
mov ax,@@px
|
||||
imul [@@cos_y]
|
||||
mov bx,ax
|
||||
mov si,dx
|
||||
|
||||
mov ax,@@pz
|
||||
imul [@@sin_y]
|
||||
sub bx,ax
|
||||
sbb si,dx
|
||||
shrd bx,si,14
|
||||
push bx
|
||||
|
||||
mov ax,@@px
|
||||
imul [@@sin_y]
|
||||
mov bx,ax
|
||||
mov si,dx
|
||||
|
||||
mov ax,@@pz
|
||||
imul [@@cos_y]
|
||||
add bx,ax
|
||||
adc si,dx
|
||||
shrd bx,si,14
|
||||
|
||||
pop @@px
|
||||
mov @@pz,bx
|
||||
|
||||
; rotate around z-axis
|
||||
|
||||
mov ax,@@px
|
||||
imul [@@cos_z]
|
||||
mov bx,ax
|
||||
mov si,dx
|
||||
|
||||
mov ax,@@py
|
||||
imul [@@sin_z]
|
||||
sub bx,ax
|
||||
sbb si,dx
|
||||
shrd bx,si,14
|
||||
push bx
|
||||
|
||||
mov ax,@@px
|
||||
imul [@@sin_z]
|
||||
mov bx,ax
|
||||
mov si,dx
|
||||
|
||||
mov ax,@@py
|
||||
imul [@@cos_z]
|
||||
add bx,ax
|
||||
adc si,dx
|
||||
shrd bx,si,14
|
||||
|
||||
pop @@px
|
||||
mov @@py,bx
|
||||
|
||||
add edi,6
|
||||
dec ecx
|
||||
jnz rp_rotate
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------
|
||||
; ds:si - offset to 3d points
|
||||
; es:di - offset to 2d points
|
||||
; cx - number of points
|
||||
;------------------------------------------------------------
|
||||
|
||||
mx dw 0
|
||||
my dw 0
|
||||
|
||||
translate_points:
|
||||
pushad
|
||||
mov eax,37
|
||||
mov ebx,1
|
||||
int 0x40
|
||||
mov ebx,eax
|
||||
shr eax,16
|
||||
and ebx,0xffff
|
||||
cmp ax,SCREEN_X
|
||||
jna x_n
|
||||
mov ax,0 ;SCREEN_X
|
||||
x_n:
|
||||
cmp bx,SCREEN_Y
|
||||
jna y_n
|
||||
mov bx,0 ;SCREEN_Y
|
||||
y_n:
|
||||
mov [mx],ax
|
||||
mov [my],bx
|
||||
popad
|
||||
|
||||
mov ebx,0 ;?
|
||||
mov bx,word [esi+4]
|
||||
mov ax,[my]
|
||||
cmp ax,0
|
||||
jng no_m
|
||||
shl ax,3
|
||||
add bx,ax
|
||||
no_m:
|
||||
add bx,256 ; Z factor (zoom)
|
||||
|
||||
mov eax,0 ;?
|
||||
mov ax,word [esi]
|
||||
shl ax,8
|
||||
cwd
|
||||
idiv bx; bx
|
||||
add ax,(SCREEN_X/2) ;160 ;X factor (center X)
|
||||
stosw
|
||||
|
||||
mov eax,0 ;?
|
||||
mov ax,word [esi+2]
|
||||
shl ax,8
|
||||
cwd
|
||||
idiv bx
|
||||
add ax,(SCREEN_Y/2) ;100 ;Y factor (center Y)
|
||||
stosw
|
||||
|
||||
add esi,6
|
||||
dec ecx
|
||||
jnz translate_points
|
||||
ret
|
||||
|
||||
init_sin_cos:
|
||||
finit
|
||||
fldz
|
||||
fstp [temp]
|
||||
xor edi,edi
|
||||
mov ecx,512
|
||||
isc_make:
|
||||
fld [temp]
|
||||
fld st0
|
||||
fld st0
|
||||
fsin
|
||||
fmul [fixed_point_const]
|
||||
fistp word [sin_table+edi]
|
||||
fcos
|
||||
fmul [fixed_point_const]
|
||||
fistp word [cos_table+edi]
|
||||
|
||||
fadd [inc_angle]
|
||||
fstp [temp]
|
||||
|
||||
add edi,2
|
||||
loop isc_make
|
||||
ret
|
||||
|
||||
temp dd 0
|
||||
|
||||
fixed_point_const dd 16384.0
|
||||
inc_angle dd 0.01227184630309 ; pi/256
|
||||
|
||||
angle_x dw 0
|
||||
angle_y dw 0
|
||||
angle_z dw 0
|
||||
|
||||
object dw -50,-50,-50, 50,-50,-50, 50,50,-50, -50,50,-50
|
||||
dw -50,-50, 50, 50,-50, 50, 50,50, 50, -50,50, 50
|
||||
|
||||
link:
|
||||
db 0,1,2,10000011b, 0,2,3,10000011b ;purpure side
|
||||
db 5,4,7,00000111b, 5,7,6,00000111b ;soft-red side
|
||||
db 1,5,6,00011000b, 1,6,2,00011000b ;soft-lime side
|
||||
db 4,0,3,11100001b, 4,3,7,11100001b ;soft-blue side
|
||||
db 4,5,1,00011111b, 1,0,4,00011111b ;yellow side
|
||||
db 3,2,6,00000000b, 3,6,7,00000000b ;black side
|
||||
|
||||
sin_table:
|
||||
rw 512
|
||||
cos_table:
|
||||
rw 512
|
||||
|
||||
object_rotated:
|
||||
rw MAX_POINTS*3
|
||||
object_translated:
|
||||
rw MAX_POINTS*2
|
||||
|
||||
scrbuf:
|
||||
I_END:
|
||||
@@ -0,0 +1,624 @@
|
||||
lang equ ru
|
||||
|
||||
;
|
||||
; Assembler
|
||||
; SMALL
|
||||
; CODE
|
||||
; Graphics
|
||||
; Libary
|
||||
;
|
||||
; Ver 0.10 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
|
||||
|
||||
;DrawBox
|
||||
macro drawfbox x,y,xs,ys,color
|
||||
{
|
||||
mov ecx,y
|
||||
mov ebx,x
|
||||
shl ebx,16
|
||||
add ebx,xs
|
||||
shl ecx,16
|
||||
add ecx,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
|
||||
_ldbounce_count=0;
|
||||
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
|
||||
{
|
||||
local bounce,exit,_1dbounce,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
|
||||
_ldbounce_count=_ldbounce_count+1
|
||||
if (_ldbounce_count = 1)
|
||||
_1dbounce:
|
||||
cmp ebx,eax
|
||||
jnae anot
|
||||
add eax,esi
|
||||
cmp eax,ebx
|
||||
jna nbc
|
||||
jmp bc
|
||||
anot:
|
||||
add ebx,edi
|
||||
cmp ebx,eax
|
||||
jna nbc
|
||||
bc:
|
||||
mov ecx,1
|
||||
ret
|
||||
nbc:
|
||||
mov ecx,0
|
||||
ret
|
||||
end if
|
||||
bounce:
|
||||
mov otv,1
|
||||
exit:
|
||||
}
|
||||
|
||||
; SETBMP - Set bmp to window
|
||||
; (SYNTAX) SETBMP dd xstart ,dd ystart ,BMP_offset,dd soi
|
||||
; (SAMPLE) SETBMP dword [xt],dword [yt],I_END,dword [tsoi]
|
||||
; SETBMP 15,10,I_END,dword [tsoi]
|
||||
; ( NOTE ) SOI - Start of image
|
||||
|
||||
macro setbmp arg1,arg2,arg3,arg4
|
||||
{
|
||||
local nodi
|
||||
cmp word [arg3],word 'BM'
|
||||
jne nodi
|
||||
mov eax,7
|
||||
mov ebx,arg4 ;[soi]
|
||||
mov ecx,dword [arg3+18]
|
||||
shl ecx,16
|
||||
add ecx,dword [arg3+22]
|
||||
if (arg1 eqtype 0) & (arg2 eqtype 0)
|
||||
mov edx,arg1*65536+arg2
|
||||
else
|
||||
mov edx,arg1
|
||||
shl edx,16
|
||||
add edx,arg2
|
||||
end if
|
||||
int 0x40
|
||||
nodi:
|
||||
}
|
||||
|
||||
macro setimg arg1,arg2,arg3
|
||||
{
|
||||
local nodi
|
||||
mov eax,7
|
||||
mov ebx,arg3
|
||||
add ebx,8
|
||||
mov ecx,dword [arg3]
|
||||
shl ecx,16
|
||||
add ecx,dword [arg3+4]
|
||||
if (arg1 eqtype 0) & (arg2 eqtype 0)
|
||||
mov edx,arg1*65536+arg2
|
||||
else
|
||||
mov edx,arg1
|
||||
shl edx,16
|
||||
add edx,arg2
|
||||
end if
|
||||
int 0x40
|
||||
}
|
||||
|
||||
;Not optimiz
|
||||
macro getimg imgsrc,x,y,xs,ys,imgdest
|
||||
{
|
||||
local cyc
|
||||
mov eax,xs
|
||||
mov dword [imgdest],eax
|
||||
mov eax,ys
|
||||
mov dword [imgdest+4],eax
|
||||
|
||||
mov eax,dword [imgsrc] ;getx size
|
||||
mov edi,eax
|
||||
mov ebx,y
|
||||
mul ebx
|
||||
add eax,x
|
||||
mov ebx,3
|
||||
mul ebx ;eax=offset on imsrc
|
||||
|
||||
mov ecx,0
|
||||
mov ebx,0
|
||||
mov ebp,eax
|
||||
mov esi,0
|
||||
|
||||
add esi,8
|
||||
add ebp,8
|
||||
|
||||
cyc:
|
||||
mov al,byte [imgsrc+ebp]
|
||||
mov [imgdest+esi],al
|
||||
mov al,byte [imgsrc+ebp+1]
|
||||
mov [imgdest+esi+1],al
|
||||
mov al,byte [imgsrc+ebp+2]
|
||||
mov [imgdest+esi+2],al
|
||||
add esi,3
|
||||
add ebp,3
|
||||
inc ecx
|
||||
cmp ecx,xs
|
||||
jne cyc
|
||||
add ebp,edi
|
||||
add ebp,edi
|
||||
add ebp,edi
|
||||
sub ebp,xs
|
||||
sub ebp,xs
|
||||
sub ebp,xs
|
||||
mov ecx,0
|
||||
inc ebx
|
||||
cmp ebx,ys
|
||||
jne cyc
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
macro bmptoimg bmp_off,soi,img_off
|
||||
{
|
||||
local nodix,conv
|
||||
cmp word [bmp_off],word 'BM'
|
||||
jne nodix
|
||||
mov eax,dword [bmp_off+18]
|
||||
mov ebx,dword [bmp_off+22]
|
||||
mov dword [img_off],eax
|
||||
mov dword [img_off+4],ebx
|
||||
mul ebx
|
||||
lea ecx,[eax+2*eax]
|
||||
lea edi,[img_off+8]
|
||||
mov esi,dword [soi]
|
||||
cld
|
||||
rep movsb
|
||||
nodix:
|
||||
}
|
||||
|
||||
macro copyimg img2_off,img1_off
|
||||
{
|
||||
local cop
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
macro convbmp bmp_load_area,bmp_soi
|
||||
{
|
||||
local status,bps,dwps,soi,sop,eop,eos,process,fileinfo,string,end_bmp
|
||||
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
|
||||
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
|
||||
local noaddword
|
||||
;local qwe,bmpfn
|
||||
|
||||
; convert:
|
||||
movzx eax,word [bmp_load_area+28]
|
||||
mul dword [bmp_load_area+18]
|
||||
mov ebx,32
|
||||
div ebx
|
||||
test edx,edx
|
||||
je noaddword
|
||||
inc eax
|
||||
noaddword:
|
||||
mov dword [dwps],eax ;dwps-doublewords per string
|
||||
shl eax,2
|
||||
mov dword [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 eax,bmp_load_area
|
||||
mov ebx,eax
|
||||
add ebx, [bmp_load_area+2];file size
|
||||
inc ebx
|
||||
mov dword [bmp_soi],ebx ;soi-start of image area for drawing
|
||||
add eax, [bmp_load_area+10]
|
||||
mov dword [sop],eax ;sop-start of picture in file
|
||||
add eax, [bmp_load_area+34]
|
||||
mov dword [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 [bmp_soi] ;initializing
|
||||
mov esi,dword [eop]
|
||||
sub esi,dword [bps]
|
||||
|
||||
|
||||
nextstring:
|
||||
push edi
|
||||
cmp word [bmp_load_area+28],24
|
||||
jne convertno32
|
||||
|
||||
mov ecx,[dwps]
|
||||
cld
|
||||
rep movsd
|
||||
convert1:
|
||||
pop edi
|
||||
sub esi,dword [bps]
|
||||
sub esi,dword [bps]
|
||||
cmp esi,dword [sop]
|
||||
jb end_bmp;nomorestring
|
||||
add edi,eax
|
||||
jmp nextstring
|
||||
|
||||
; nomorestring:
|
||||
; jmp end_bmp
|
||||
|
||||
convertno32:
|
||||
mov ebx,bmp_load_area
|
||||
add ebx, [bmp_load_area+14]
|
||||
add ebx,14 ;start of color table
|
||||
push esi
|
||||
add esi,dword [bps]
|
||||
mov dword [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 [eos]
|
||||
jae convert1
|
||||
add edi,3
|
||||
jmp nextelem
|
||||
|
||||
convert4bpp:
|
||||
shl ax,4
|
||||
shr al,4
|
||||
push ax
|
||||
movzx eax,ah
|
||||
call converttable
|
||||
add edi,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
|
||||
cmp edx,0xffffffff
|
||||
je convert2
|
||||
add edi,3
|
||||
jmp nextbit
|
||||
|
||||
converttable:
|
||||
shl eax,2
|
||||
add eax,ebx
|
||||
mov edx, dword [eax]
|
||||
mov dword [edi],edx
|
||||
ret
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
;status dd 0 ;bit0=1 if file thread is created
|
||||
bps dd 0
|
||||
dwps dd 0
|
||||
;soi dd 0
|
||||
sop dd 0
|
||||
eop dd 0
|
||||
eos dd 0
|
||||
;process dd 0
|
||||
|
||||
end_bmp:
|
||||
; mov eax,dword [soi]
|
||||
; mov dword [bmp_soi],eax
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
; LOADBMP - Load bmp image from file
|
||||
; (SYNTAX) LOADBMP 'file_path',temp_area(rb 0x10000),load_area,dd soi
|
||||
; (SAMPLE) LOADBMP '/rd/1/menuet.bmp',temp_area,I_END,tsoi
|
||||
; ( NOTE ) Macros create on Base of
|
||||
; Picture browser by lisovin@26.ru & Ivan Poddubny
|
||||
; SOI - Start of image
|
||||
|
||||
macro loadbmp bmp_file_name,bmp_temp_area,bmp_load_area,bmp_soi
|
||||
{
|
||||
local status,bps,dwps,soi,sop,eop,eos,process,fileinfo,string,end_bmp
|
||||
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
|
||||
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
|
||||
local noaddword
|
||||
;local qwe,bmpfn
|
||||
|
||||
mov dword [fileinfo+8],1 ; how many blocks to read (1)
|
||||
mov eax,58
|
||||
mov ebx,fileinfo
|
||||
int 0x40
|
||||
mov eax,[bmp_load_area+2]
|
||||
shr eax,9 ; поделим на 512 и прибавим 1 - получим число блоков
|
||||
inc eax
|
||||
mov dword [fileinfo+8],eax
|
||||
mov eax,58
|
||||
mov ebx,fileinfo
|
||||
int 0x40
|
||||
|
||||
; jmp qwe
|
||||
;bmpfn db bmp_file_name
|
||||
;qwe:
|
||||
; mov eax,6
|
||||
; mov ebx,bmpfn
|
||||
; mov ecx,0
|
||||
; mov edx,0xFFFFFF
|
||||
; mov esi,bmp_load_area
|
||||
; mov edi,0
|
||||
; int 0x40
|
||||
|
||||
; convert:
|
||||
movzx eax,word [bmp_load_area+28]
|
||||
mul dword [bmp_load_area+18]
|
||||
mov ebx,32
|
||||
div ebx
|
||||
test edx,edx
|
||||
je noaddword
|
||||
inc eax
|
||||
noaddword:
|
||||
mov dword [dwps],eax ;dwps-doublewords per string
|
||||
shl eax,2
|
||||
mov dword [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 eax,bmp_load_area
|
||||
push eax
|
||||
add eax, [bmp_load_area+2];file size
|
||||
inc eax
|
||||
mov dword [soi],eax ;soi-start of image area for drawing
|
||||
pop eax
|
||||
add eax, [bmp_load_area+10]
|
||||
mov dword [sop],eax ;sop-start of picture in file
|
||||
add eax, [bmp_load_area+34]
|
||||
mov dword [eop],eax ;eop-end of picture in file
|
||||
mov eax, [bmp_load_area+18]
|
||||
mov ebx,3
|
||||
mul ebx ;3x pixels in eax
|
||||
|
||||
mov edi,dword [soi] ;initializing
|
||||
mov esi,dword [eop]
|
||||
sub esi,dword [bps]
|
||||
|
||||
|
||||
nextstring:
|
||||
push edi
|
||||
cmp word [bmp_load_area+28],24
|
||||
jne convertno32
|
||||
|
||||
mov ecx,[dwps]
|
||||
cld
|
||||
rep movsd
|
||||
convert1:
|
||||
pop edi
|
||||
sub esi,dword [bps]
|
||||
sub esi,dword [bps]
|
||||
cmp esi,dword [sop]
|
||||
jb nomorestring
|
||||
add edi,eax
|
||||
jmp nextstring
|
||||
|
||||
nomorestring:
|
||||
jmp end_bmp
|
||||
|
||||
convertno32:
|
||||
mov ebx,bmp_load_area
|
||||
add ebx, [bmp_load_area+14]
|
||||
add ebx,14 ;start of color table
|
||||
push esi
|
||||
add esi,dword [bps]
|
||||
mov dword [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 [eos]
|
||||
jae convert1
|
||||
add edi,3
|
||||
jmp nextelem
|
||||
|
||||
convert4bpp:
|
||||
shl ax,4
|
||||
shr al,4
|
||||
push ax
|
||||
movzx eax,ah
|
||||
call converttable
|
||||
add edi,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
|
||||
cmp edx,0xffffffff
|
||||
je convert2
|
||||
add edi,3
|
||||
jmp nextbit
|
||||
|
||||
converttable:
|
||||
shl eax,2
|
||||
add eax,ebx
|
||||
mov edx, dword [eax]
|
||||
mov dword [edi],edx
|
||||
ret
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
;status dd 0 ;bit0=1 if file thread is created
|
||||
bps dd 0
|
||||
dwps dd 0
|
||||
soi dd 0
|
||||
sop dd 0
|
||||
eop dd 0
|
||||
eos dd 0
|
||||
;process dd 0
|
||||
|
||||
; DATA AREA
|
||||
fileinfo:
|
||||
dd 0
|
||||
dd 0
|
||||
dd 1 ;number of blocks of 512 bytes
|
||||
dd bmp_load_area
|
||||
dd bmp_temp_area
|
||||
string:
|
||||
db bmp_file_name,0
|
||||
db ' '
|
||||
db ' '
|
||||
db ' '
|
||||
db ' ',0
|
||||
|
||||
|
||||
end_bmp:
|
||||
mov eax,dword [soi]
|
||||
mov dword [bmp_soi],eax
|
||||
|
||||
}
|
||||
@@ -0,0 +1,499 @@
|
||||
lang equ ru ; ru en fr ge fi
|
||||
|
||||
;
|
||||
; Assembler
|
||||
; SMALL
|
||||
; CODE
|
||||
; Libary
|
||||
;
|
||||
; Ver 0.09 By Pavlushin Evgeni (RUSSIA)
|
||||
; www.waptap@mail.ru
|
||||
|
||||
;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
|
||||
|
||||
macro opendialog redproc,openoff,erroff,path,testtime
|
||||
{
|
||||
local still, dlg_file, clip_file, redwait
|
||||
local button, key, red, zzz, still, zzz2, incf, file_is_open, zzz3
|
||||
|
||||
mov ecx,200
|
||||
zzz3:
|
||||
mov byte [path+ecx-1],0
|
||||
loop zzz3
|
||||
|
||||
dec byte [clip_file+7]
|
||||
incf:
|
||||
inc byte [clip_file+7]
|
||||
mov eax,6
|
||||
mov ebx,clip_file
|
||||
mov ecx,0
|
||||
mov edx,-1
|
||||
mov esi,path
|
||||
int 0x40
|
||||
cmp byte [clip_file+7],'Z'
|
||||
je erroff
|
||||
cmp eax,0xffffffff
|
||||
jne incf
|
||||
|
||||
mov ecx,200
|
||||
zzz2:
|
||||
mov byte [path+ecx],0
|
||||
loop zzz2
|
||||
|
||||
mov ebx,clip_file
|
||||
mov ecx,path
|
||||
mov edx,100
|
||||
mov esi,0
|
||||
mov eax,33
|
||||
int 0x40
|
||||
|
||||
mov ebx,dlg_file
|
||||
mov ecx,clip_file
|
||||
mov eax,19
|
||||
int 0x40
|
||||
|
||||
still:
|
||||
scevent red,key,button
|
||||
cmp byte [path],0
|
||||
jne file_is_open
|
||||
cmp dword [redwait],testtime ;20
|
||||
jnae zzz
|
||||
mov eax,6
|
||||
mov ebx,clip_file
|
||||
mov ecx,0
|
||||
mov edx,-1
|
||||
mov esi,path
|
||||
int 0x40
|
||||
cmp eax,0xffffffff
|
||||
je erroff ;errexit
|
||||
mov dword [redwait],0
|
||||
zzz:
|
||||
delay 5
|
||||
inc dword [redwait]
|
||||
jmp still
|
||||
|
||||
file_is_open:
|
||||
mov eax,32
|
||||
mov ebx,clip_file
|
||||
int 0x40
|
||||
jmp openoff
|
||||
|
||||
key: ; key
|
||||
int 0x40 ; read (eax=2)
|
||||
jmp still
|
||||
button: ; button
|
||||
mov eax,17 ; get id
|
||||
int 0x40
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jne still
|
||||
mov eax,-1 ; close this program
|
||||
int 0x40
|
||||
|
||||
red:
|
||||
call redproc
|
||||
jmp still
|
||||
|
||||
dlg_file db 'SYSXTREE '
|
||||
clip_file db 'OPENCLPACLP'
|
||||
db 'O' ;Dialog type O-open S-save
|
||||
db 0 ;Marker
|
||||
redwait dd 0
|
||||
}
|
||||
|
||||
macro savedialog redproc,openoff,erroff,path,testtime
|
||||
{
|
||||
local still, dlg_file, clip_file, redwait, zzz3
|
||||
local button, key, red, zzz, still, zzz2, incf, file_is_open
|
||||
|
||||
mov ecx,200
|
||||
zzz3:
|
||||
mov byte [path+ecx-1],0
|
||||
loop zzz3
|
||||
|
||||
dec byte [clip_file+7]
|
||||
incf:
|
||||
inc byte [clip_file+7]
|
||||
mov eax,6
|
||||
mov ebx,clip_file
|
||||
mov ecx,0
|
||||
mov edx,-1
|
||||
mov esi,path
|
||||
int 0x40
|
||||
cmp byte [clip_file+7],'Z'
|
||||
je erroff
|
||||
cmp eax,0xffffffff
|
||||
jne incf
|
||||
|
||||
mov ecx,200
|
||||
zzz2:
|
||||
mov byte [path+ecx],0
|
||||
loop zzz2
|
||||
|
||||
mov ebx,clip_file
|
||||
mov ecx,path
|
||||
mov edx,100
|
||||
mov esi,0
|
||||
mov eax,33
|
||||
int 0x40
|
||||
|
||||
mov ebx,dlg_file
|
||||
mov ecx,clip_file
|
||||
mov eax,19
|
||||
int 0x40
|
||||
|
||||
still:
|
||||
scevent red,key,button
|
||||
cmp byte [path],0
|
||||
jne file_is_open
|
||||
cmp dword [redwait],testtime ;20
|
||||
jnae zzz
|
||||
mov eax,6
|
||||
mov ebx,clip_file
|
||||
mov ecx,0
|
||||
mov edx,-1
|
||||
mov esi,path
|
||||
int 0x40
|
||||
cmp eax,0xffffffff
|
||||
je erroff ;errexit
|
||||
mov dword [redwait],0
|
||||
zzz:
|
||||
delay 5
|
||||
inc dword [redwait]
|
||||
jmp still
|
||||
|
||||
file_is_open:
|
||||
mov eax,32
|
||||
mov ebx,clip_file
|
||||
int 0x40
|
||||
jmp openoff
|
||||
|
||||
key: ; key
|
||||
int 0x40 ; read (eax=2)
|
||||
jmp still
|
||||
button: ; button
|
||||
mov eax,17 ; get id
|
||||
int 0x40
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jne still
|
||||
mov eax,-1 ; close this program
|
||||
int 0x40
|
||||
|
||||
red:
|
||||
call redproc
|
||||
jmp still
|
||||
|
||||
dlg_file db 'SYSXTREE '
|
||||
clip_file db 'SAVECLPACLP'
|
||||
db 'S' ;Dialog type O-open S-save
|
||||
db 0 ;Marker
|
||||
redwait dd 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
|
||||
; mov arg2,0
|
||||
; mov arg2,eax
|
||||
ret
|
||||
end if
|
||||
|
||||
rxproc:
|
||||
mov eax,arg1
|
||||
call randomproc
|
||||
mov arg2,0
|
||||
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
|
||||
mov ecx,color
|
||||
mov edx,offs
|
||||
mov esi,size
|
||||
mov eax,4
|
||||
int 0x40
|
||||
}
|
||||
|
||||
;_ equ '____'
|
||||
|
||||
;macro libtest x,y,color
|
||||
;{
|
||||
;if x = as dword
|
||||
; mov ebx,x
|
||||
;end if
|
||||
; mov ecx,y
|
||||
; mov edx,color
|
||||
; mov eax,1
|
||||
; int 0x40
|
||||
;}
|
||||
|
||||
|
||||
macro outcount data, x, y, color, numtype
|
||||
{
|
||||
mov ecx,data
|
||||
mov ebx,numtype
|
||||
mov bl,0
|
||||
mov edx,x*65536+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
|
||||
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
|
||||
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
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm 3dcube2.asm 3dcube2
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm 3dcube2.asm 3dcube2
|
||||
@pause
|
||||
@@ -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 { ; mike.dld
|
||||
if ~a 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
|
||||
}
|
||||
|
||||
|
||||
|
||||
; language for programs
|
||||
lang fix ru ; ru en fr ge fi
|
||||
|
||||
|
||||
|
||||
; 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
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,897 @@
|
||||
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 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 0x008040ff
|
||||
cl_Cyan equ 0x0040e0ff
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm 3detx60b.asm 3detx60b
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm 3detx60b.asm 3detx60b
|
||||
@pause
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,938 @@
|
||||
;
|
||||
; 9 Ver Screen saver
|
||||
; 5 Ver 24 bit texture.
|
||||
; 23/8/2004
|
||||
; Pavlushin Evgeni 3d cube screen saver
|
||||
; mail: waptap@mail.ru site: www.deck4.narod.ru
|
||||
;
|
||||
; This programm develop on sample text3d to Mikolaj Felix 25/5/2001
|
||||
; mfelix@polbox.com
|
||||
;
|
||||
|
||||
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 0x200000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Icon
|
||||
|
||||
include 'lang.inc'
|
||||
MAX_DEGS equ 512 ;quantity of angels 2^n.Minimize for speedup
|
||||
MAX_POINTS equ 8 ;quantity of points
|
||||
MAX_FACES equ 6 ;quantity of points
|
||||
|
||||
START:
|
||||
finit
|
||||
call draw_window
|
||||
call clear_screen
|
||||
call init_sincos
|
||||
|
||||
still:
|
||||
mov eax,23 ; wait for system event with 2 ms timeout
|
||||
mov ebx,2 ; wait 2 ms, then continue
|
||||
int 0x40
|
||||
|
||||
; mov eax,11 ;If you want maximum speed! :)
|
||||
; int 0x40
|
||||
|
||||
dec eax ; window redraw request ?
|
||||
je red
|
||||
dec eax ; key in buffer ?
|
||||
je key
|
||||
dec eax ; button in buffer ?
|
||||
je button
|
||||
|
||||
main_loop:
|
||||
call fade_texture
|
||||
|
||||
mov esi,cube
|
||||
mov edi,cube_rotated
|
||||
mov ecx,MAX_POINTS*3
|
||||
copy_object:
|
||||
fild word [esi]
|
||||
fstp dword [edi]
|
||||
add esi,2
|
||||
add edi,4
|
||||
dec ecx
|
||||
jnz copy_object
|
||||
|
||||
mov esi,angle_x
|
||||
mov edi,cube_rotated
|
||||
mov ecx,MAX_POINTS
|
||||
call rotate_points
|
||||
|
||||
mov esi,cube_rotated
|
||||
mov edi,coord2d
|
||||
mov ecx,MAX_POINTS
|
||||
call translate_points
|
||||
|
||||
call draw_textured_faces
|
||||
call clear_screen_buffer
|
||||
|
||||
add [angle_x],1
|
||||
add [angle_y],3
|
||||
add [angle_z],1
|
||||
|
||||
jmp still
|
||||
|
||||
red:
|
||||
call draw_window
|
||||
jmp still
|
||||
key:
|
||||
mov eax,2
|
||||
jmp exit
|
||||
button:
|
||||
mov eax,17
|
||||
int 0x40
|
||||
cmp ah,1
|
||||
jne still
|
||||
exit:
|
||||
mov eax,-1
|
||||
int 0x40
|
||||
|
||||
;Draw window
|
||||
draw_window:
|
||||
mov eax,12 ;Start
|
||||
mov ebx,1
|
||||
int 0x40
|
||||
|
||||
mov eax,0 ;Draw window
|
||||
mov ebx,0*65536+(799) ;x start*65536+x size
|
||||
mov ecx,0*65536+(599) ;y start*65536+y size
|
||||
mov edx,0x00000000 ;0x03 use skinned window
|
||||
int 0x40
|
||||
|
||||
call clear_screen
|
||||
|
||||
mov eax,12 ;End
|
||||
mov ebx,2
|
||||
int 0x40
|
||||
ret
|
||||
|
||||
head_label: db "3D TEXTURED CUBE THE LITTLE SCREEN SAVER FOR MENUETOS. USE "
|
||||
db "800x600 SCREEN MODE FROM VIEW. PRESS ANY KEY FOR EXIT"
|
||||
hl_end:
|
||||
|
||||
;FADE IN FADE OUT TEXTURE
|
||||
|
||||
x_step db 0
|
||||
x_num db 1
|
||||
|
||||
fade_texture:
|
||||
mov ecx,0
|
||||
loox:
|
||||
mov al,[file_texture+ecx]
|
||||
mov [texture+ecx],al
|
||||
inc ecx
|
||||
cmp ecx,128*128*3
|
||||
jnae loox
|
||||
|
||||
mov ecx,0
|
||||
loox2:
|
||||
mov al,[file_texture+ecx]
|
||||
cmp [x_step],al
|
||||
jae xxx
|
||||
sub al,[x_step]
|
||||
jmp nnn
|
||||
xxx:
|
||||
mov al,0
|
||||
nnn:
|
||||
mov [texture+ecx],al
|
||||
inc ecx
|
||||
cmp ecx,128*128*3
|
||||
jnae loox2
|
||||
|
||||
cmp [x_step],255
|
||||
jne no_max
|
||||
mov [x_num],-1
|
||||
no_max:
|
||||
cmp [x_step],0
|
||||
jne no_min
|
||||
mov [x_num],1
|
||||
no_min:
|
||||
mov al,[x_num]
|
||||
add [x_step],al
|
||||
ret
|
||||
|
||||
; Clear Screen
|
||||
clear_screen:
|
||||
mov eax,13
|
||||
mov ebx,0*65536+800
|
||||
mov ecx,0*65536+600
|
||||
mov edx,0
|
||||
int 40h
|
||||
|
||||
mov eax,4 ;Out Text
|
||||
mov ebx,8*65536+8 ;x start*65536+y start
|
||||
mov ecx,0x00ffffff ;color White
|
||||
mov edx,head_label
|
||||
mov esi,hl_end-head_label
|
||||
int 0x40
|
||||
ret
|
||||
|
||||
clear_screen_buffer:
|
||||
mov ebx,scrbuf
|
||||
mov ecx,800*65536+(600-40) ;sub 40 for antiflickering title
|
||||
mov edx,0*65536+40
|
||||
mov eax,7
|
||||
int 0x40
|
||||
|
||||
mov eax,4 ;Out Text
|
||||
mov ebx,8*65536+580 ;x start*65536+y start
|
||||
mov ebp,[n_step]
|
||||
shl ebp,16
|
||||
sub ebx,ebp
|
||||
mov ecx,0x0000ff00 ;color White
|
||||
mov edx,move_text
|
||||
add edx,[step]
|
||||
mov esi,130 ;mt_end-move_text
|
||||
int 0x40
|
||||
|
||||
inc [n_step]
|
||||
cmp [n_step],6
|
||||
jna t_ok
|
||||
mov [n_step],0
|
||||
inc [step]
|
||||
cmp [step],mt_end-move_text-130
|
||||
jng t_ok
|
||||
mov [step],0
|
||||
t_ok:
|
||||
|
||||
mov edi,scrbuf
|
||||
mov eax,0 ;black background
|
||||
mov ecx,800*600*3/4 ; 16000
|
||||
cld
|
||||
rep stosd
|
||||
ret
|
||||
|
||||
n_step dd 0
|
||||
step dd 0
|
||||
|
||||
move_text: db " "
|
||||
db " "
|
||||
db " "
|
||||
db "***** 3D TEXTURED CUBE THE LITTLE SCREEN SAVER FOR "
|
||||
db "MENUET OS. SET 800x600 SCREEN MODE FROM VIEW THIS SCREEN "
|
||||
db "SAVER ***** "
|
||||
db "SITE OF THE RUSSIAN DEVELOPERS TO MENUETOS: "
|
||||
db "www.menuet.narod.ru "
|
||||
db "RUSSIAN MENUET APLICATION ARCHIVE PAGE ON: "
|
||||
db "www.meosfiles.narod.ru "
|
||||
db "AUTOR OF THIS SCREEN SAVER Pavlushin Evgeni "
|
||||
db "MY SITE: www.deck4.narod.ru (Slow update) "
|
||||
db "AND MAIL BOX: waptap@mail.ru "
|
||||
db "THANK YOU FOR USE! "
|
||||
db " "
|
||||
db " "
|
||||
db " "
|
||||
mt_end:
|
||||
|
||||
|
||||
;include graphlib.asm Mikolaj Felix 9/12/2000 mfelix@polbox.com
|
||||
;Draw textured faces proc
|
||||
|
||||
@@rx1 dw 0 ;equ [bp-2]
|
||||
@@ry1 dw 0 ;equ [bp-4]
|
||||
@@rx2 dw 0 ;equ [bp-6]
|
||||
@@ry2 dw 0 ;equ [bp-8]
|
||||
@@rx3 dw 0 ;equ [bp-10]
|
||||
@@ry3 dw 0 ;equ [bp-12]
|
||||
@@rx4 dw 0 ;equ [bp-14]
|
||||
@@ry4 dw 0 ;equ [bp-16]
|
||||
|
||||
draw_textured_faces:
|
||||
|
||||
mov esi,link
|
||||
mov ecx,MAX_FACES
|
||||
dtf_loop:
|
||||
push ecx
|
||||
|
||||
xor ebx,ebx
|
||||
mov bl,byte [esi] ; point 1
|
||||
shl bx,2
|
||||
mov eax,dword [coord2d+bx] ;COPY 1 FOURANGLE POINT
|
||||
mov dword [@@rx1],eax
|
||||
|
||||
xor ebx,ebx
|
||||
mov bl,byte [esi+1] ; point 2
|
||||
shl bx,2
|
||||
mov eax,dword [coord2d+bx] ;COPY 2 FOURANGLE POINT
|
||||
mov dword [@@rx2],eax
|
||||
|
||||
xor ebx,ebx
|
||||
mov bl,byte [esi+2] ; point 3
|
||||
shl bx,2
|
||||
mov eax,dword [coord2d+bx] ;COPY 3 FOURANGLE POINT
|
||||
mov dword [@@rx3],eax
|
||||
|
||||
xor bh,bh ; point 4
|
||||
mov bl,byte [esi+3]
|
||||
shl bx,2
|
||||
mov eax,dword [coord2d+bx] ;COPY 4 FOURANGLE POINT
|
||||
mov dword [@@rx4],eax
|
||||
|
||||
mov ax,[@@ry1]
|
||||
sub ax,[@@ry3]
|
||||
mov bx,[@@rx2]
|
||||
sub bx,[@@rx1]
|
||||
imul bx
|
||||
shl edx,16
|
||||
mov dx,ax
|
||||
push edx
|
||||
mov ax,[@@rx1]
|
||||
sub ax,[@@rx3]
|
||||
mov bx,[@@ry2]
|
||||
sub bx,[@@ry1]
|
||||
imul bx
|
||||
shl edx,16
|
||||
mov dx,ax
|
||||
pop ebx
|
||||
sub ebx,edx ; normal_z = (y1-y3)*(x2-x1)-(x1-x3)*(y2-y1)
|
||||
or ebx,ebx
|
||||
jl dtf_next_face ; normal_z < 0
|
||||
|
||||
; FIRST PICE OF FOUR ANGLE
|
||||
|
||||
; Set 3 triangel puts for texture ycoord*65536+xcoord
|
||||
mov dword [@@tex_x3],127*65536+127 ;3 point
|
||||
mov dword [@@tex_x2],0*65536+127 ;2 point
|
||||
mov dword [@@tex_x1],0*65536+0 ;1 point
|
||||
; Set texture bitmap offset
|
||||
mov [@@tex_off],texture
|
||||
; Set 3 triangel puts coordinates
|
||||
mov eax,dword [@@rx3]
|
||||
mov dword [@@x3],eax
|
||||
mov eax,dword [@@rx2]
|
||||
mov dword [@@x2],eax
|
||||
mov eax,dword [@@rx1]
|
||||
mov dword [@@x1],eax
|
||||
call textured_triangle
|
||||
|
||||
; SECOND PICE OF FOUR ANGLE
|
||||
|
||||
; Set 3 triangel puts for texture ycoord*65536+xcoord
|
||||
mov dword [@@tex_x3],127*65536+0 ;3 point
|
||||
mov dword [@@tex_x2],127*65536+127 ;2 point
|
||||
mov dword [@@tex_x1],0*65536+0 ;1 point
|
||||
; Set texture bitmap offset
|
||||
mov [@@tex_off],texture
|
||||
; Set 3 triangel puts coordinates
|
||||
mov eax,dword [@@rx4]
|
||||
mov dword [@@x3],eax
|
||||
mov eax,dword [@@rx3]
|
||||
mov dword [@@x2],eax
|
||||
mov eax,dword [@@rx1]
|
||||
mov dword [@@x1],eax
|
||||
call textured_triangle
|
||||
|
||||
dtf_next_face:
|
||||
add esi,4
|
||||
pop ecx
|
||||
dec ecx
|
||||
jnz dtf_loop
|
||||
ret
|
||||
|
||||
;include tex3.asm Mikolaj Felix 15/5/2001 mfelix@polbox.com
|
||||
|
||||
@@x1 dw 0 ;equ [bp+4]
|
||||
@@y1 dw 0 ;equ [bp+6]
|
||||
@@x2 dw 0 ;equ [bp+8]
|
||||
@@y2 dw 0 ;equ [bp+10]
|
||||
@@x3 dw 0 ;equ [bp+12]
|
||||
@@y3 dw 0 ;equ [bp+14]
|
||||
|
||||
@@tex_off dd 0 ;equ [bp+16]
|
||||
@@tex_x1 dw 0 ;equ [bp+18]
|
||||
@@tex_y1 dw 0 ;equ [bp+20]
|
||||
@@tex_x2 dw 0 ;equ [bp+22]
|
||||
@@tex_y2 dw 0 ;equ [bp+24]
|
||||
@@tex_x3 dw 0 ;equ [bp+26]
|
||||
@@tex_y3 dw 0 ;equ [bp+28]
|
||||
|
||||
@@dx12 dw 0 ;equ [bp-2]
|
||||
@@dx13 dw 0 ;equ [bp-4]
|
||||
@@dx23 dw 0 ;equ [bp-6]
|
||||
|
||||
@@tex_dx12 dw 0 ;equ [bp-8]
|
||||
@@tex_dy12 dw 0 ;equ [bp-10]
|
||||
@@tex_dx13 dw 0 ;equ [bp-12]
|
||||
@@tex_dy13 dw 0 ;equ [bp-14]
|
||||
@@tex_dx23 dw 0 ;equ [bp-16]
|
||||
@@tex_dy23 dw 0 ;equ [bp-18]
|
||||
|
||||
@@scan_x1 dw 0 ;equ [bp-20]
|
||||
@@scan_y1 dw 0 ;equ [bp-22]
|
||||
@@scan_x2 dw 0 ;equ [bp-24]
|
||||
@@scan_y2 dw 0 ;equ [bp-26]
|
||||
|
||||
|
||||
textured_triangle:
|
||||
|
||||
mov ax,[@@y1]
|
||||
cmp ax,[@@y3]
|
||||
jb tt_check1
|
||||
|
||||
xchg ax,[@@y3]
|
||||
mov [@@y1],ax
|
||||
|
||||
mov ax,[@@x1]
|
||||
xchg ax,[@@x3]
|
||||
mov [@@x1],ax
|
||||
|
||||
mov ax,[@@tex_y1]
|
||||
xchg ax,[@@tex_y3]
|
||||
mov [@@tex_y1],ax
|
||||
|
||||
mov ax,[@@tex_x1]
|
||||
xchg ax,[@@tex_x3]
|
||||
mov [@@tex_x1],ax
|
||||
tt_check1:
|
||||
mov ax,[@@y2]
|
||||
cmp ax,[@@y3]
|
||||
jb tt_check2
|
||||
|
||||
xchg ax,[@@y3]
|
||||
mov [@@y2],ax
|
||||
|
||||
mov ax,[@@x2]
|
||||
xchg ax,[@@x3]
|
||||
mov [@@x2],ax
|
||||
|
||||
mov ax,[@@tex_y2]
|
||||
xchg ax,[@@tex_y3]
|
||||
mov [@@tex_y2],ax
|
||||
|
||||
mov ax,[@@tex_x2]
|
||||
xchg ax,[@@tex_x3]
|
||||
mov [@@tex_x2],ax
|
||||
tt_check2:
|
||||
mov ax,[@@y1]
|
||||
cmp ax,[@@y2]
|
||||
jb tt_check3
|
||||
|
||||
xchg ax,[@@y2]
|
||||
mov [@@y1],ax
|
||||
|
||||
mov ax,[@@x1]
|
||||
xchg ax,[@@x2]
|
||||
mov [@@x1],ax
|
||||
|
||||
mov ax,[@@tex_y1]
|
||||
xchg ax,[@@tex_y2]
|
||||
mov [@@tex_y1],ax
|
||||
|
||||
mov ax,[@@tex_x1]
|
||||
xchg ax,[@@tex_x2]
|
||||
mov [@@tex_x1],ax
|
||||
tt_check3:
|
||||
|
||||
mov bx,[@@y2]
|
||||
sub bx,[@@y1]
|
||||
jnz tt_dx12_make
|
||||
|
||||
mov word [@@dx12],0
|
||||
mov word [@@tex_dx12],0
|
||||
mov word [@@tex_dy12],0
|
||||
jmp tt_dx12_done
|
||||
tt_dx12_make:
|
||||
mov ax,[@@x2]
|
||||
sub ax,[@@x1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@dx12],ax ; dx12 = (x2-x1)/(y2-y1)
|
||||
|
||||
mov ax,[@@tex_x2]
|
||||
sub ax,[@@tex_x1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@tex_dx12],ax ; tex_dx12 = (tex_x2-tex_x1)/(y2-y1)
|
||||
|
||||
mov ax,[@@tex_y2]
|
||||
sub ax,[@@tex_y1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@tex_dy12],ax ; tex_dy12 = (tex_y2-tex_y1)/(y2-y1)
|
||||
tt_dx12_done:
|
||||
|
||||
mov bx,[@@y3]
|
||||
sub bx,[@@y1]
|
||||
jnz tt_dx13_make
|
||||
|
||||
mov word [@@dx13],0
|
||||
mov word [@@tex_dx13],0
|
||||
mov word [@@tex_dy13],0
|
||||
jmp tt_dx13_done
|
||||
tt_dx13_make:
|
||||
mov ax,[@@x3]
|
||||
sub ax,[@@x1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@dx13],ax ; dx13 = (x3-x1)/(y3-y1)
|
||||
|
||||
mov ax,[@@tex_x3]
|
||||
sub ax,[@@tex_x1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@tex_dx13],ax ; tex_dx13 = (tex_x3-tex_x1)/(y3-y1)
|
||||
|
||||
mov ax,[@@tex_y3]
|
||||
sub ax,[@@tex_y1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@tex_dy13],ax ; tex_dy13 = (tex_y3-tex_x1)/(y3-y1)
|
||||
tt_dx13_done:
|
||||
|
||||
mov bx,[@@y3]
|
||||
sub bx,[@@y2]
|
||||
jnz tt_dx23_make
|
||||
|
||||
mov word [@@dx23],0
|
||||
mov word [@@tex_dx23],0
|
||||
mov word [@@tex_dy23],0
|
||||
jmp tt_dx23_done
|
||||
tt_dx23_make:
|
||||
mov ax,[@@x3]
|
||||
sub ax,[@@x2]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@dx23],ax ; dx23 = (x3-x2)/(y3-y2)
|
||||
|
||||
mov ax,[@@tex_x3]
|
||||
sub ax,[@@tex_x2]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@tex_dx23],ax ; tex_dx23 = (tex_x3-tex_x2)/(y3-y2)
|
||||
|
||||
mov ax,[@@tex_y3]
|
||||
sub ax,[@@tex_y2]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv bx
|
||||
mov [@@tex_dy23],ax ; tex_dy23 = (tex_y3-tex_y2)/(y3-y2)
|
||||
tt_dx23_done:
|
||||
|
||||
|
||||
mov ax,[@@x1]
|
||||
shl ax,7
|
||||
mov bx,ax
|
||||
mov cx,[@@y1]
|
||||
|
||||
mov dx,[@@tex_x1]
|
||||
shl dx,7
|
||||
mov [@@scan_x1],dx
|
||||
mov [@@scan_x2],dx
|
||||
mov dx,[@@tex_y1]
|
||||
shl dx,7
|
||||
mov [@@scan_y1],dx
|
||||
mov [@@scan_y2],dx
|
||||
tt_loop1:
|
||||
pushad
|
||||
; push ax
|
||||
; push bx
|
||||
; push cx
|
||||
|
||||
mov dx,[@@scan_y2]
|
||||
shr dx,7
|
||||
mov [@@tex_ly2],dx ;push dx
|
||||
mov dx,[@@scan_x2]
|
||||
shr dx,7
|
||||
mov [@@tex_lx2],dx ;push dx
|
||||
mov dx,[@@scan_y1]
|
||||
shr dx,7
|
||||
mov [@@tex_ly1],dx ;push dx
|
||||
mov dx,[@@scan_x1]
|
||||
shr dx,7
|
||||
mov [@@tex_lx1],dx ;push dx
|
||||
mov ebp,dword [@@tex_off] ;push word ptr @@tex_off
|
||||
mov [@@tex_loff],ebp
|
||||
|
||||
mov [@@ly],cx ;push cx
|
||||
mov dx,bx
|
||||
shr dx,7
|
||||
mov [@@lx2],dx ;push dx
|
||||
mov dx,ax
|
||||
shr dx,7
|
||||
mov [@@lx1],dx ; push dx
|
||||
call textured_horizontal_line
|
||||
|
||||
; pop cx
|
||||
; pop bx
|
||||
; pop ax
|
||||
popad
|
||||
|
||||
mov dx,[@@tex_dx13]
|
||||
add [@@scan_x1],dx
|
||||
mov dx,[@@tex_dx12]
|
||||
add [@@scan_x2],dx
|
||||
mov dx,[@@tex_dy13]
|
||||
add [@@scan_y1],dx
|
||||
mov dx,[@@tex_dy12]
|
||||
add [@@scan_y2],dx
|
||||
|
||||
add ax,[@@dx13]
|
||||
add bx,[@@dx12]
|
||||
inc cx
|
||||
cmp cx,[@@y2]
|
||||
jb tt_loop1
|
||||
|
||||
mov bx,[@@x2]
|
||||
shl bx,7
|
||||
mov cx,[@@y2]
|
||||
|
||||
mov dx,[@@tex_x2]
|
||||
shl dx,7
|
||||
mov [@@scan_x2],dx
|
||||
mov dx,[@@tex_y2]
|
||||
shl dx,7
|
||||
mov [@@scan_y2],dx
|
||||
tt_loop2:
|
||||
|
||||
pushad
|
||||
; push ax
|
||||
; push bx
|
||||
; push cx
|
||||
|
||||
mov dx,[@@scan_y2]
|
||||
shr dx,7
|
||||
mov [@@tex_ly2],dx ;push dx
|
||||
mov dx,[@@scan_x2]
|
||||
shr dx,7
|
||||
mov [@@tex_lx2],dx ;push dx
|
||||
mov dx,[@@scan_y1]
|
||||
shr dx,7
|
||||
mov [@@tex_ly1],dx ;push dx
|
||||
mov dx,[@@scan_x1]
|
||||
shr dx,7
|
||||
mov [@@tex_lx1],dx ;push dx
|
||||
mov ebp,dword [@@tex_off] ;push word ptr @@tex_off
|
||||
mov [@@tex_loff],ebp
|
||||
|
||||
mov [@@ly],cx ;push cx
|
||||
mov dx,bx
|
||||
shr dx,7
|
||||
mov [@@lx2],dx ;push dx
|
||||
mov dx,ax
|
||||
shr dx,7
|
||||
mov [@@lx1],dx ; push dx
|
||||
call textured_horizontal_line
|
||||
|
||||
; pop cx
|
||||
; pop bx
|
||||
; pop ax
|
||||
popad
|
||||
|
||||
mov dx,[@@tex_dx13]
|
||||
add [@@scan_x1],dx
|
||||
mov dx,[@@tex_dx23]
|
||||
add [@@scan_x2],dx
|
||||
mov dx,[@@tex_dy13]
|
||||
add [@@scan_y1],dx
|
||||
mov dx,[@@tex_dy23]
|
||||
add [@@scan_y2],dx
|
||||
|
||||
add ax,[@@dx13]
|
||||
add bx,[@@dx23]
|
||||
inc cx
|
||||
cmp cx,[@@y3]
|
||||
jb tt_loop2
|
||||
ret
|
||||
|
||||
@@lx1 dw 0 ;equ [bp+4]
|
||||
@@lx2 dw 0 ;equ [bp+6]
|
||||
@@ly dw 0 ;equ [bp+8]
|
||||
|
||||
@@tex_loff dd 0 ;equ [bp+10]
|
||||
@@tex_lx1 dw 0 ;equ [bp+12]
|
||||
@@tex_ly1 dw 0 ;equ [bp+14]
|
||||
@@tex_lx2 dw 0 ;equ [bp+16]
|
||||
@@tex_ly2 dw 0 ;equ [bp+18]
|
||||
|
||||
@@tex_ldx dw 0 ;equ [bp-2]
|
||||
@@tex_ldy dw 0 ;equ [bp-4]
|
||||
|
||||
textured_horizontal_line:
|
||||
|
||||
mov ax,[@@lx1]
|
||||
cmp ax,[@@lx2]
|
||||
je thl_quit
|
||||
jb thl_ok
|
||||
|
||||
xchg ax,[@@lx2]
|
||||
mov [@@lx1],ax
|
||||
|
||||
mov ax,[@@tex_lx1]
|
||||
xchg ax,[@@tex_lx2]
|
||||
mov [@@tex_lx1],ax
|
||||
|
||||
mov ax,[@@tex_ly1]
|
||||
xchg ax,[@@tex_ly2]
|
||||
mov [@@tex_ly1],ax
|
||||
thl_ok:
|
||||
|
||||
; Fast method
|
||||
; mov edi,0
|
||||
; mov di,[@@ly] ;edi = calculating start of line
|
||||
; mov ax,di
|
||||
; shl di,6 ;ly*64
|
||||
; shl ax,8 ;ly*256
|
||||
; add di,ax ;di = (ly*64)+(ly*256)
|
||||
; add di,[@@lx1] ;di = ly*320+lx1
|
||||
; mov eax,edi
|
||||
; shl eax,1
|
||||
; add edi,eax
|
||||
; add edi,scrbuf
|
||||
|
||||
; Uneversal method
|
||||
movsx edi,[@@ly]
|
||||
mov eax,800 ;di = ly*320+lx1
|
||||
mul edi
|
||||
movsx ebx,[@@lx1]
|
||||
add eax,ebx ;[@@lx1]
|
||||
mov edi,3
|
||||
mul edi
|
||||
mov edi,eax
|
||||
add edi,scrbuf
|
||||
|
||||
mov cx,[@@lx2]
|
||||
sub cx,[@@lx1]
|
||||
|
||||
mov ax,[@@tex_lx2]
|
||||
sub ax,[@@tex_lx1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv cx
|
||||
mov [@@tex_ldx],ax ; tex_dx = (tex_x2-tex_x1)/(x2-x1)
|
||||
|
||||
mov ax,[@@tex_ly2]
|
||||
sub ax,[@@tex_ly1]
|
||||
shl ax,7
|
||||
cwd
|
||||
idiv cx
|
||||
mov [@@tex_ldy],ax ; tex_dy = (tex_y2-tex_y1)/(x2-x1)
|
||||
|
||||
cld
|
||||
inc cx
|
||||
mov ax,[@@tex_lx1]
|
||||
shl ax,7
|
||||
mov bx,[@@tex_ly1]
|
||||
shl bx,7
|
||||
|
||||
thl_loop:
|
||||
mov dx,ax
|
||||
push bx
|
||||
|
||||
and bx,0ff80h
|
||||
shr ax,7
|
||||
add bx,ax
|
||||
mov ebp,0
|
||||
mov bp,bx
|
||||
mov eax,ebp
|
||||
shl eax,1
|
||||
add ebp,eax
|
||||
add ebp,[@@tex_loff]
|
||||
|
||||
mov al,byte [ebp+2]
|
||||
stosb
|
||||
mov al,byte [ebp+1]
|
||||
stosb
|
||||
mov al,byte [ebp]
|
||||
stosb
|
||||
|
||||
pop bx
|
||||
mov ax,dx
|
||||
|
||||
add ax,[@@tex_ldx]
|
||||
add bx,[@@tex_ldy]
|
||||
dec cx
|
||||
jnz thl_loop
|
||||
thl_quit:
|
||||
ret
|
||||
|
||||
;include math3d_2.asm
|
||||
; Mikolaj Felix 20/06/2001
|
||||
; mfelix@polbox.com
|
||||
|
||||
;------------------------------------------------------------
|
||||
; ds:si - offset to angles (int)
|
||||
; ds:di - offset to array of 3d points
|
||||
; cx - number of points
|
||||
;------------------------------------------------------------
|
||||
|
||||
@@sin_x dd 0 ;equ dword ptr [bp-4]
|
||||
@@cos_x dd 0 ;equ dword ptr [bp-8]
|
||||
@@sin_y dd 0 ;equ dword ptr [bp-12]
|
||||
@@cos_y dd 0 ;equ dword ptr [bp-16]
|
||||
@@sin_z dd 0 ;equ dword ptr [bp-20]
|
||||
@@cos_z dd 0 ;equ dword ptr [bp-24]
|
||||
|
||||
@@x equ dword [edi]
|
||||
@@y equ dword [edi+4]
|
||||
@@z equ dword [edi+8]
|
||||
|
||||
rotate_points:
|
||||
|
||||
push edi
|
||||
mov edi,@@sin_x
|
||||
mov edx,3
|
||||
rp_sin_cos:
|
||||
mov bx,word [esi]
|
||||
and bx,MAX_DEGS-1
|
||||
shl bx,2
|
||||
mov eax,dword [sintab+bx]
|
||||
mov dword [edi],eax
|
||||
mov eax,dword [costab+bx]
|
||||
mov dword [edi+4],eax
|
||||
add edi,8
|
||||
add esi,2
|
||||
dec edx
|
||||
jnz rp_sin_cos
|
||||
pop edi
|
||||
|
||||
rp_rotate:
|
||||
fld @@y
|
||||
fmul [@@cos_x]
|
||||
fld @@z
|
||||
fmul [@@sin_x]
|
||||
fsubp st1,st
|
||||
fld @@y
|
||||
fxch st1
|
||||
fstp @@y ; Yrotated = Cos (A)*Y - Sin (A)*Z
|
||||
fmul [@@sin_x]
|
||||
fld @@z
|
||||
fmul [@@cos_x]
|
||||
faddp st1,st
|
||||
fstp @@z ; Zrotated = Sin (A)*Y + Cos (A)*Z
|
||||
|
||||
fld @@x
|
||||
fmul [@@cos_y]
|
||||
fld @@z
|
||||
fmul [@@sin_y]
|
||||
fsubp st1,st
|
||||
fld @@x
|
||||
fxch st1
|
||||
fstp @@x ; Xrotated = Cos (A)*X - Sin (A)*Z
|
||||
fmul [@@sin_y]
|
||||
fld @@z
|
||||
fmul [@@cos_y]
|
||||
faddp st1,st
|
||||
fstp @@z ; Zrotated = Sin (A)*X + Cos (A)*Z
|
||||
|
||||
fld @@x
|
||||
fmul [@@cos_z]
|
||||
fld @@y
|
||||
fmul [@@sin_z]
|
||||
fsubp st1,st
|
||||
fld @@x
|
||||
fxch st1
|
||||
fstp @@x ; Xrotated = Cos (A)*X - Sin (A)*Y
|
||||
fmul [@@sin_z]
|
||||
fld @@y
|
||||
fmul [@@cos_z]
|
||||
faddp st1,st
|
||||
fstp @@y ; Yrotated = Sin (A)*X + Cos (A)*Y
|
||||
|
||||
add edi,12
|
||||
dec ecx
|
||||
jnz rp_rotate
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------
|
||||
; ds:si - offset to array of 3d points
|
||||
; ds:di - offset to 2d points
|
||||
; cx - number of points
|
||||
;------------------------------------------------------------
|
||||
|
||||
translate_points:
|
||||
|
||||
fld dword [esi+8]
|
||||
fadd [perspective]
|
||||
|
||||
fld dword [esi]
|
||||
fmul [perspective]
|
||||
fdiv st,st1
|
||||
fadd [correct_x]
|
||||
fistp word [edi] ; x2d = (x*persp)/(z+persp)+correct_x
|
||||
|
||||
fld dword [esi+4]
|
||||
fmul [perspective]
|
||||
fdivrp st1,st
|
||||
fadd [correct_y]
|
||||
fistp word [edi+2] ; y2d = (y*persp)/(z+persp)+correct_y
|
||||
|
||||
add esi,12
|
||||
add edi,4
|
||||
dec ecx
|
||||
jnz translate_points
|
||||
ret
|
||||
|
||||
; initalize SIN&COS table
|
||||
|
||||
@@temp1 dd 0 ;dword ptr [bp-4]
|
||||
@@temp2 dd 0 ;dword ptr [bp-8]
|
||||
|
||||
init_sincos:
|
||||
mov [@@temp1],0
|
||||
fldpi
|
||||
mov [@@temp2],MAX_DEGS/2
|
||||
fidiv [@@temp2]
|
||||
fstp [@@temp2]
|
||||
|
||||
xor edi,edi
|
||||
mov ecx,MAX_DEGS
|
||||
isc_loop:
|
||||
fld [@@temp1]
|
||||
fld st0
|
||||
fld st0
|
||||
fsin
|
||||
fstp dword [sintab+edi]
|
||||
fcos
|
||||
fstp dword [costab+edi]
|
||||
fadd [@@temp2]
|
||||
fstp [@@temp1]
|
||||
|
||||
add edi,4
|
||||
dec ecx
|
||||
jnz isc_loop
|
||||
ret
|
||||
|
||||
perspective dd 256.0
|
||||
correct_x dd 400.0
|
||||
correct_y dd 300.0
|
||||
|
||||
angle_x dw 0
|
||||
angle_y dw 0
|
||||
angle_z dw 0
|
||||
|
||||
file_texture:
|
||||
file 'texture.raw'
|
||||
|
||||
cube dw -50,-50,50, 50,-50,50, 50,50,50, -50,50,50
|
||||
dw -50,-50,-50, 50,-50,-50, 50,50,-50, -50,50,-50
|
||||
|
||||
link db 0,1,2,3, 5,4,7,6, 1,5,6,2, 4,0,3,7, 4,5,1,0, 3,2,6,7
|
||||
|
||||
sintab:
|
||||
rd MAX_DEGS
|
||||
costab:
|
||||
rd MAX_DEGS
|
||||
|
||||
cube_rotated:
|
||||
rd MAX_POINTS*3
|
||||
coord2d:
|
||||
rw MAX_POINTS*2
|
||||
texture:
|
||||
rb 128*128*3
|
||||
scrbuf:
|
||||
|
||||
I_END:
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm 3dtcub10.asm 3dtcub10
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm 3dtcub10.asm 3dtcub10
|
||||
@pause
|
||||
Binary file not shown.
@@ -0,0 +1,288 @@
|
||||
; Vendor ids
|
||||
INTEL_VID = 0x8086
|
||||
SIS_VID = 0x1039
|
||||
NVIDIA_VID = 0x10DE
|
||||
AMD_VID = 0x1022
|
||||
|
||||
; Device ids
|
||||
ICH_DID = 0x2415
|
||||
ICH0_DID = 0x2425
|
||||
ICH2_DID = 0x2445
|
||||
ICH3_DID = 0x2485
|
||||
ICH4_DID = 0x24C5
|
||||
ICH5_DID = 0x24D5
|
||||
MX440_DID = 0x7195
|
||||
SI7012_DID = 0x7012
|
||||
NFORCE_DID = 0x01B1
|
||||
NFORCE2_DID = 0x006A
|
||||
AMD8111_DID = 0x764D
|
||||
AMD768_DID = 0x7445
|
||||
|
||||
NAMBAR_REG = 0x10 ; native audio mixer BAR
|
||||
NAM_SIZE = 256 ; 256 bytes required.
|
||||
|
||||
NABMBAR_REG = 0x14 ; native audio bus mastering BAR
|
||||
NABM_SIZE = 64 ; 64 bytes
|
||||
|
||||
IRQ_REG = 0x3c ; IRQ holder for PCI
|
||||
INT_REG = 0x3d ; INT pin
|
||||
ICH4_CFG_REG = 0x41 ; ICH4 config register
|
||||
|
||||
|
||||
; BUS master registers, accessed via NABMBAR+offset
|
||||
|
||||
; ICH supports 3 different types of register sets for three types of things
|
||||
; it can do, thus:
|
||||
;
|
||||
; PCM in (for recording) aka PI
|
||||
; PCM out (for playback) aka PO
|
||||
; MIC in (for recording) aka MC
|
||||
|
||||
PI_BDBAR_REG = 0 ; PCM in buffer descriptor BAR
|
||||
PO_BDBAR_REG = 10h ; PCM out buffer descriptor BAR
|
||||
MC_BDBAR_REG = 20h ; MIC in buffer descriptor BAR
|
||||
|
||||
; each buffer descriptor BAR holds a pointer which has entries to the buffer
|
||||
; contents of the .WAV file we're going to play. Each entry is 8 bytes long
|
||||
; (more on that later) and can contain 32 entries total, so each BAR is
|
||||
; 256 bytes in length, thus:
|
||||
|
||||
BDL_SIZE = 32*8 ; Buffer Descriptor List size
|
||||
INDEX_MASK = 31 ; indexes must be 0-31
|
||||
|
||||
|
||||
|
||||
PI_CIV_REG = 4 ; PCM in current Index value (RO)
|
||||
PO_CIV_REG = 14h ; PCM out current Index value (RO)
|
||||
MC_CIV_REG = 24h ; MIC in current Index value (RO)
|
||||
|
||||
;8bit read only
|
||||
; each current index value is simply a pointer showing us which buffer
|
||||
; (0-31) the codec is currently processing. Once this counter hits 31, it
|
||||
; wraps back to 0.
|
||||
; this can be handy to know, as once it hits 31, we're almost out of data to
|
||||
; play back or room to record!
|
||||
|
||||
|
||||
PI_LVI_REG = 5 ; PCM in Last Valid Index
|
||||
PO_LVI_REG = 15h ; PCM out Last Valid Index
|
||||
MC_LVI_REG = 25h ; MIC in Last Valid Index
|
||||
;8bit read/write
|
||||
; The Last Valid Index is a number (0-31) to let the codec know what buffer
|
||||
; number to stop on after processing. It could be very nasty to play audio
|
||||
; from buffers that aren't filled with the audio we want to play.
|
||||
|
||||
|
||||
PI_SR_REG = 6 ; PCM in Status register
|
||||
PO_SR_REG = 16h ; PCM out Status register
|
||||
MC_SR_REG = 26h ; MIC in Status register
|
||||
;16bit read/write
|
||||
; status registers. Bitfields follow:
|
||||
|
||||
FIFO_ERR = BIT4 ; FIFO Over/Underrun W1TC.
|
||||
|
||||
BCIS = BIT3 ; buffer completion interrupt status.
|
||||
; Set whenever the last sample in ANY
|
||||
; buffer is finished. Bit is only
|
||||
; set when the Interrupt on Complete
|
||||
; (BIT4 of control reg) is set.
|
||||
|
||||
LVBCI = BIT2 ; Set whenever the codec has processed
|
||||
; the last buffer in the buffer list.
|
||||
; Will fire an interrupt if IOC bit is
|
||||
; set. Probably set after the last
|
||||
; sample in the last buffer is
|
||||
; processed. W1TC
|
||||
|
||||
|
||||
CELV = BIT1 ; Current buffer == last valid.
|
||||
; Bit is RO and remains set until LVI is
|
||||
; cleared. Probably set up the start
|
||||
; of processing for the last buffer.
|
||||
|
||||
|
||||
DCH = BIT0 ; DMA controller halted.
|
||||
; set whenever audio stream is stopped
|
||||
; or something else goes wrong.
|
||||
|
||||
|
||||
PI_PICB_REG = 8 ; PCM in position in current buffer(RO)
|
||||
PO_PICB_REG = 18h ; PCM out position in current buffer(RO)
|
||||
MC_PICB_REG = 28h ; MIC in position in current buffer (RO)
|
||||
;16bit read only
|
||||
; position in current buffer regs show the number of dwords left to be
|
||||
; processed in the current buffer.
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PI_PIV_REG = 0ah ; PCM in Prefected index value
|
||||
PO_PIV_REG = 1ah ; PCM out Prefected index value
|
||||
MC_PIV_REG = 2ah ; MIC in Prefected index value
|
||||
;8bit, read only
|
||||
; Prefetched index value register.
|
||||
; tells which buffer number (0-31) has be prefetched. I'd imagine this
|
||||
; value follows the current index value fairly closely. (CIV+1)
|
||||
;
|
||||
|
||||
|
||||
PI_CR_REG = 0bh ; PCM in Control Register
|
||||
PO_CR_REG = 1bh ; PCM out Control Register
|
||||
MC_CR_REG = 2bh ; MIC in Control Register
|
||||
; 8bit
|
||||
; Control register *MUST* only be accessed as an 8bit value.
|
||||
; Control register. See bitfields below.
|
||||
;
|
||||
|
||||
|
||||
IOCE = BIT4 ; interrupt on complete enable.
|
||||
; set this bit if you want an intrtpt
|
||||
; to fire whenever LVBCI is set.
|
||||
FEIFE = BIT3 ; set if you want an interrupt to fire
|
||||
; whenever there is a FIFO (over or
|
||||
; under) error.
|
||||
LVBIE = BIT2 ; last valid buffer interrupt enable.
|
||||
; set if you want an interrupt to fire
|
||||
; whenever the completion of the last
|
||||
; valid buffer.
|
||||
RR = BIT1 ; reset registers. Nukes all regs
|
||||
; except bits 4:2 of this register.
|
||||
; Only set this bit if BIT 0 is 0
|
||||
RPBM = BIT0 ; Run/Pause
|
||||
; set this bit to start the codec!
|
||||
|
||||
|
||||
GLOB_CNT_REG = 2ch ; Global control register
|
||||
SEC_RES_EN = BIT5 ; secondary codec resume event
|
||||
; interrupt enable. Not used here.
|
||||
PRI_RES_EN = BIT4 ; ditto for primary. Not used here.
|
||||
ACLINK_OFF = BIT3 ; Turn off the AC97 link
|
||||
ACWARM_RESET = BIT2 ; Awaken the AC97 link from sleep.
|
||||
; registers preserved, bit self clears
|
||||
ACCOLD_RESET = BIT1 ; Reset everything in the AC97 and
|
||||
; reset all registers. Not self clearin
|
||||
;g
|
||||
|
||||
GPIIE = BIT0 ; GPI Interrupt enable.
|
||||
; set if you want an interrupt to
|
||||
; fire upon ANY of the bits in the
|
||||
; GPI (general pursose inputs?) not used
|
||||
;.
|
||||
|
||||
GLOB_STS_REG = 30h ; Global Status register (RO)
|
||||
|
||||
MD3 = BIT17 ; modem powerdown status (yawn)
|
||||
AD3 = BIT16 ; Audio powerdown status (yawn)
|
||||
RD_COMPLETE_STS = BIT15 ; Codec read timed out. 0=normal
|
||||
BIT3SLOT12 = BIT14 ; shadowed status of bit 3 in slot 12
|
||||
BIT2SLOT12 = BIT13 ; shadowed status of bit 2 in slot 12
|
||||
BIT1SLOT12 = BIT12 ; shadowed status of bit 1 in slot 12
|
||||
SEC_RESUME_STS = BIT11 ; secondary codec has resumed (and irqed)
|
||||
PRI_RESUME_STS = BIT10 ; primary codec has resumed (and irqed)
|
||||
SEC_CODEC_RDY = BIT9 ; secondary codec is ready for action
|
||||
PRI_CODEC_RDY = BIT8 ; Primary codec is ready for action
|
||||
; software must check these bits before
|
||||
; starting the codec!
|
||||
MIC_IN_IRQ = BIT7 ; MIC in caused an interrupt
|
||||
PCM_OUT_IRQ = BIT6 ; One of the PCM out channels IRQed
|
||||
PCM_IN_IRQ = BIT5 ; One of the PCM in channels IRQed
|
||||
MODEM_OUT_IRQ = BIT2 ; modem out channel IRQed
|
||||
MODEM_IN_IRQ = BIT1 ; modem in channel IRQed
|
||||
GPI_STS_CHANGE = BIT0 ; set whenever GPI's have changed.
|
||||
; BIT0 of slot 12 also reflects this.
|
||||
|
||||
|
||||
ACC_SEMA_REG = 34h ; Codec write semiphore register
|
||||
CODEC_BUSY = BIT0 ; codec register I/O is happening
|
||||
; self clearing
|
||||
|
||||
|
||||
|
||||
;
|
||||
; Buffer Descriptors List
|
||||
; As stated earlier, each buffer descriptor list is a set of (up to) 32
|
||||
; descriptors, each 8 bytes in length. Bytes 0-3 of a descriptor entry point
|
||||
; to a chunk of memory to either play from or record to. Bytes 4-7 of an
|
||||
; entry describe various control things detailed below.
|
||||
;
|
||||
; Buffer pointers must always be aligned on a Dword boundry.
|
||||
;
|
||||
;
|
||||
|
||||
IOC = BIT31 ; Fire an interrupt whenever this
|
||||
; buffer is complete.
|
||||
|
||||
BUP = BIT30 ; Buffer Underrun Policy.
|
||||
; if this buffer is the last buffer
|
||||
; in a playback, fill the remaining
|
||||
; samples with 0 (silence) or not.
|
||||
; It's a good idea to set this to 1
|
||||
; for the last buffer in playback,
|
||||
; otherwise you're likely to get a lot
|
||||
; of noise at the end of the sound.
|
||||
|
||||
;
|
||||
; Bits 15:0 contain the length of the buffer, in number of samples, which
|
||||
; are 16 bits each, coupled in left and right pairs, or 32bits each.
|
||||
; Luckily for us, that's the same format as .wav files.
|
||||
;
|
||||
; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about
|
||||
; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data.
|
||||
;
|
||||
; A value of 0 in these bits means play no samples.
|
||||
;
|
||||
|
||||
|
||||
;*****************************************************************************
|
||||
;* AC97 Codec registers include (based on Jeff Leyda AC97 wav player SDK :-)
|
||||
;*****************************************************************************
|
||||
|
||||
; Not all codecs are created =al. Refer to the spec for your specific codec.
|
||||
; All registers are 16bits wide. Access to codec registers over the AC97 link
|
||||
; is defined by the OEM.
|
||||
; Secondary codec's are accessed by ORing in BIT7 of all register accesses.
|
||||
|
||||
|
||||
; each codec/mixer register is 16bits
|
||||
|
||||
CODEC_RESET_REG = 00 ; reset codec
|
||||
CODEC_MASTER_VOL_REG = 02 ; master volume
|
||||
CODEC_HP_VOL_REG = 04 ; headphone volume
|
||||
CODEC_MASTER_MONO_VOL_REG = 06 ; master mono volume
|
||||
CODEC_MASTER_TONE_REG = 08 ; master tone (R+L)
|
||||
CODEC_PCBEEP_VOL_REG = 0ah ; PC beep volume
|
||||
CODEC_PHONE_VOL_REG = 0ch ; phone volume
|
||||
CODEC_MIC_VOL_REG = 0eh ; MIC volume
|
||||
CODEC_LINE_IN_VOL_REG = 10h ; line input volume
|
||||
CODEC_CD_VOL_REG = 12h ; CD volume
|
||||
CODEC_VID_VOL_REG = 14h ; video volume
|
||||
CODEC_AUX_VOL_REG = 16h ; aux volume
|
||||
CODEC_PCM_OUT_REG = 18h ; PCM output volume
|
||||
CODEC_RECORD_SELECT_REG = 1ah ; record select input
|
||||
CODEC_RECORD_VOL_REG = 1ch ; record volume
|
||||
CODEC_RECORD_MIC_VOL_REG = 1eh ; record mic volume
|
||||
CODEC_GP_REG = 20h ; general purpose
|
||||
CODEC_3D_CONTROL_REG = 22h ; 3D control
|
||||
; 24h is reserved
|
||||
CODEC_POWER_CTRL_REG = 26h ; powerdown control
|
||||
CODEC_EXT_AUDIO_REG = 28h ; extended audio
|
||||
CODEC_EXT_AUDIO_CTRL_REG = 2ah ; extended audio control
|
||||
CODEC_PCM_FRONT_DACRATE_REG = 2ch ; PCM out sample rate
|
||||
CODEC_PCM_SURND_DACRATE_REG = 2eh ; surround sound sample rate
|
||||
CODEC_PCM_LFE_DACRATE_REG = 30h ; LFE sample rate
|
||||
CODEC_LR_ADCRATE_REG = 32h ; PCM in sample rate
|
||||
CODEC_MIC_ADCRATE_REG = 34h ; mic in sample rate
|
||||
|
||||
|
||||
; registers 36-7a are reserved on the ICH
|
||||
|
||||
CODEC_VENDORID1_REG = 7ch ; codec vendor ID 1
|
||||
CODEC_VENDORID2_REG = 7eh ; codec vendor ID 2
|
||||
|
||||
|
||||
; When 2 codecs are present in the system, use BIT7 to access the 2nd
|
||||
; set of registers, ie 80h-feh
|
||||
|
||||
SECONDARY_CODEC = BIT7 ; 80-8f registers for 2nda
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm ac97wav.asm ac97wav
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm ac97wav.asm ac97wav
|
||||
@pause
|
||||
@@ -0,0 +1,344 @@
|
||||
|
||||
NAMBAR_read_byte:
|
||||
add dx, [NAMBAR]
|
||||
in al, dx
|
||||
ret
|
||||
|
||||
|
||||
NAMBAR_read_word:
|
||||
add dx, [NAMBAR]
|
||||
in ax, dx
|
||||
ret
|
||||
|
||||
|
||||
NAMBAR_read_dword:
|
||||
add dx, [NAMBAR]
|
||||
in eax, dx
|
||||
ret
|
||||
|
||||
NAMBAR_write_byte:
|
||||
add dx, [NAMBAR]
|
||||
out dx, al
|
||||
ret
|
||||
|
||||
NAMBAR_write_word:
|
||||
add dx, [NAMBAR]
|
||||
out dx, ax
|
||||
ret
|
||||
|
||||
NAMBAR_write_dword:
|
||||
add dx, [NAMBAR]
|
||||
out dx, eax
|
||||
ret
|
||||
|
||||
|
||||
|
||||
NABMBAR_read_byte:
|
||||
add dx, [NABMBAR]
|
||||
in al, dx
|
||||
ret
|
||||
|
||||
NABMBAR_read_word:
|
||||
add dx, [NABMBAR]
|
||||
in ax, dx
|
||||
ret
|
||||
|
||||
NABMBAR_read_dword:
|
||||
add dx, [NABMBAR]
|
||||
in eax, dx
|
||||
ret
|
||||
|
||||
NABMBAR_write_byte:
|
||||
add dx, [NABMBAR]
|
||||
out dx, al
|
||||
ret
|
||||
|
||||
NABMBAR_write_word:
|
||||
add dx, [NABMBAR]
|
||||
out dx, ax
|
||||
ret
|
||||
|
||||
NABMBAR_write_dword:
|
||||
add dx, [NABMBAR]
|
||||
out dx, eax
|
||||
ret
|
||||
|
||||
|
||||
|
||||
semaphore:
|
||||
push ecx edx
|
||||
|
||||
mov edx, GLOB_STS_REG ; 0x30 global status register
|
||||
call NABMBAR_read_dword
|
||||
and eax, PRI_CODEC_RDY ; 100h primary codec ready
|
||||
jz .success ; exit if codec not ready !!!
|
||||
|
||||
; mov ecx, 1024 ; try 1024 times
|
||||
mov ecx, 0ffffh ; try 65535 times
|
||||
.wait:
|
||||
mov edx, ACC_SEMA_REG ; 0x34 codec write semaphore
|
||||
call NABMBAR_read_byte
|
||||
and al, CODEC_BUSY ; 01h codec access semaphore
|
||||
jz .success ; exit if codec not busy !!!
|
||||
|
||||
dec ecx
|
||||
jnz .wait
|
||||
|
||||
pop edx ecx
|
||||
mov eax, 0
|
||||
jmp .exit
|
||||
|
||||
.success:
|
||||
pop edx ecx
|
||||
mov eax, 1
|
||||
.exit:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
codecStop:
|
||||
push eax ebx edx
|
||||
|
||||
mov edx, PO_CR_REG ; 0x1B control register
|
||||
mov al, 0 ; stop all PCM out data
|
||||
call NABMBAR_write_byte
|
||||
|
||||
mcall MF_DELAY, eax ; ebx = (eax = MF_DELAY = 5); wait 50 ms
|
||||
|
||||
mov edx, PO_CR_REG ; 0x1B control register
|
||||
mov al, RR ; reset PCM out regs
|
||||
call NABMBAR_write_byte
|
||||
|
||||
mcall MF_DELAY, eax
|
||||
|
||||
pop edx ebx eax
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
; set voulme
|
||||
; in ax = volume level
|
||||
setVolume:
|
||||
push eax edx
|
||||
|
||||
push eax
|
||||
call semaphore
|
||||
mov edx, CODEC_RESET_REG ; 0
|
||||
xor eax, eax ; register reset the codec
|
||||
call NAMBAR_write_word
|
||||
|
||||
call semaphore
|
||||
pop eax
|
||||
imul ax, 0101h ; set volume for both chn
|
||||
mov edx, CODEC_MASTER_VOL_REG ; 2
|
||||
call NAMBAR_write_word
|
||||
push eax
|
||||
|
||||
call semaphore
|
||||
pop eax ; set volume for both chn
|
||||
mov edx, CODEC_HP_VOL_REG ; 4
|
||||
call NAMBAR_write_word
|
||||
push eax
|
||||
|
||||
call semaphore
|
||||
mov edx, CODEC_CD_VOL_REG ; 12h
|
||||
pop eax ; set volume for both chn
|
||||
shr eax, 2 ; adjust CD VOL
|
||||
call NAMBAR_write_word
|
||||
|
||||
call semaphore
|
||||
mov edx, CODEC_PCM_OUT_REG ; 18h
|
||||
mov ax, 0808h ; standard PCM out volume
|
||||
call NAMBAR_write_word
|
||||
|
||||
pop edx eax
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
samplerate dw 0
|
||||
|
||||
|
||||
|
||||
; enable codec, unmute stuff, set output to desired rate
|
||||
; in : ax = desired sample rate
|
||||
; out: ax = true or false
|
||||
;
|
||||
codecConfig:
|
||||
pushad
|
||||
mov [samplerate], ax ; save sample rate
|
||||
|
||||
|
||||
; mov edx, GLOB_STS_REG ; 30h global status register
|
||||
; call NABMBAR_read_dword
|
||||
; and eax, PRI_CODEC_RDY ; 0100h primary codec ready
|
||||
; jnz skip_init ; skip init if codec ready !!!
|
||||
|
||||
; stop the codec if currently playing
|
||||
;;; call codecStop
|
||||
|
||||
; mov edx, GLOB_STS_REG
|
||||
; call NABMBAR_read_dword
|
||||
; dps "GLOB_STA = "
|
||||
; dph eax
|
||||
; newline
|
||||
|
||||
; mov edx, GLOB_CNT_REG
|
||||
; call NABMBAR_read_dword
|
||||
; dps "GLOB_CNT = "
|
||||
; dph eax
|
||||
; newline
|
||||
|
||||
; mcall 5, 10
|
||||
|
||||
;; test eax, ACCOLD_RESET
|
||||
;; jnz .skip_cold_reset
|
||||
|
||||
; print "cold reset"
|
||||
; do a cold reset
|
||||
mov edx, GLOB_CNT_REG ; 2ch global control register
|
||||
xor eax, eax
|
||||
call NABMBAR_write_dword ; enable (AC Link off clear)
|
||||
|
||||
; print "wait"
|
||||
mcall 5, 5
|
||||
; print "alive!"
|
||||
|
||||
;; .skip_cold_reset:
|
||||
|
||||
mov edx, GLOB_CNT_REG ; 2ch global control register
|
||||
mov eax, ACCOLD_RESET + PRI_RES_EN ; cold reset + primary resume
|
||||
call NABMBAR_write_dword ; 2 channels & 16 bit samples
|
||||
|
||||
mov edx, GLOB_CNT_REG ; 2ch global control register
|
||||
call NABMBAR_read_dword
|
||||
and eax, ACCOLD_RESET ; cold reset
|
||||
jz init_error ; INIT FAILED !!!
|
||||
|
||||
; print "cold reset finished"
|
||||
|
||||
; wait for primary codec ready status
|
||||
mov ecx, 128
|
||||
codec_ready_loop:
|
||||
mov edx, GLOB_STS_REG ; 30h global status register
|
||||
call NABMBAR_read_dword
|
||||
and eax, PRI_CODEC_RDY ; 0100h primary codec ready
|
||||
jnz codec_ready_exit ; move on if codec ready !!!
|
||||
mcall 5, 1
|
||||
dec ecx
|
||||
jnz codec_ready_loop
|
||||
;dps "~"
|
||||
codec_ready_exit:
|
||||
|
||||
; wait until codec init ready (*** replaces warm reset wait ***)
|
||||
mcall 5, 60
|
||||
|
||||
; test if codec ready bit is finally set
|
||||
mov edx, GLOB_STS_REG ; 30h global status register
|
||||
call NABMBAR_read_dword
|
||||
and eax, PRI_CODEC_RDY ; 0100h primary codec ready
|
||||
jnz codec_ready_bit_set ; move on if codec ready !!!
|
||||
cmp [AC97ICH4], 1
|
||||
jne init_error
|
||||
; je codec_ready_bit_set ; ignore codec ready for ICH4
|
||||
; jmp init_error ; codec ready bit not set !!!
|
||||
codec_ready_bit_set:
|
||||
|
||||
; clear semaphore flag
|
||||
mov edx, CODEC_RESET_REG ; 0h codec reset register
|
||||
call NAMBAR_read_word
|
||||
|
||||
|
||||
; check if codec sections ready
|
||||
call semaphore
|
||||
test eax, eax
|
||||
jz init_error
|
||||
mov edx, CODEC_POWER_CTRL_REG ; 26h codec powerdown ctrl
|
||||
call NAMBAR_read_word
|
||||
and eax, 01111b
|
||||
cmp eax, 01111b
|
||||
jne init_error ; codec sections not ready
|
||||
|
||||
|
||||
|
||||
; disable interrupts
|
||||
mov al, 0
|
||||
|
||||
mov edx, PI_CR_REG ; 0Bh PCM in control register
|
||||
call NABMBAR_write_byte
|
||||
|
||||
mov edx, PO_CR_REG ; 1Bh PCM out control register
|
||||
call NABMBAR_write_byte
|
||||
|
||||
mov edx, MC_CR_REG ; 2Bh MIC in control register
|
||||
call NABMBAR_write_byte
|
||||
|
||||
; reset channels
|
||||
mov al, RR ; 02h reset Bus master regs
|
||||
|
||||
mov edx, PI_CR_REG ; 0Bh PCM in control register
|
||||
call NABMBAR_write_byte
|
||||
|
||||
mov edx, PO_CR_REG ; 1Bh PCM out control register
|
||||
call NABMBAR_write_byte
|
||||
|
||||
mov edx, MC_CR_REG ; 2Bh MIC in control register
|
||||
call NABMBAR_write_byte
|
||||
|
||||
; set default volume
|
||||
mov eax, 15 ; set average volume level
|
||||
call setVolume
|
||||
|
||||
; set VRA and clear DRA (if not supported will be skipped)
|
||||
call semaphore
|
||||
test eax, eax
|
||||
jz init_error
|
||||
mov edx, CODEC_EXT_AUDIO_CTRL_REG ; register 2ah
|
||||
call NAMBAR_read_word ; get ext audio ctl
|
||||
|
||||
mov ebx, eax
|
||||
call semaphore
|
||||
test eax, eax
|
||||
jz init_error
|
||||
mov eax, ebx
|
||||
and eax, 0FFFFh - BIT1 ; clear DRA (BIT1)
|
||||
or eax, BIT0 ; set VRA (BIT0)
|
||||
mov edx, CODEC_EXT_AUDIO_CTRL_REG ; register 2ah
|
||||
call NAMBAR_write_word ; write ext audio ctl
|
||||
|
||||
; set desired sample rate
|
||||
skip_init:
|
||||
call semaphore
|
||||
test eax, eax
|
||||
jz init_error
|
||||
|
||||
; mov edx, CODEC_PCM_FRONT_DACRATE_REG
|
||||
; call NAMBAR_read_word
|
||||
; and eax, 0xFFFF
|
||||
; newline
|
||||
; dps "old PCM OUT RATE: "
|
||||
; dpd eax
|
||||
; newline
|
||||
|
||||
mov ax, [samplerate] ; restore sample rate
|
||||
; mov edx, CODEC_PCM_FRONT_DACRATE_REG ; register 2ch
|
||||
; call NAMBAR_write_word
|
||||
call set_sample_rate
|
||||
|
||||
popad
|
||||
mov eax, 1 ; exit with success
|
||||
jmp exit_config
|
||||
init_error:
|
||||
popad
|
||||
xor eax, eax ; exit with error
|
||||
exit_config:
|
||||
ret
|
||||
|
||||
set_sample_rate: ; rate in ax
|
||||
mov edx, CODEC_PCM_FRONT_DACRATE_REG ; 0x2C reg
|
||||
call NAMBAR_write_word
|
||||
ret
|
||||
@@ -0,0 +1,35 @@
|
||||
;constants of stuff that seem hard to remember at times.
|
||||
|
||||
BIT0 EQU 1
|
||||
BIT1 EQU 2
|
||||
BIT2 EQU 4
|
||||
BIT3 EQU 8
|
||||
BIT4 EQU 10h
|
||||
BIT5 EQU 20h
|
||||
BIT6 EQU 40h
|
||||
BIT7 EQU 80h
|
||||
BIT8 EQU 100h
|
||||
BIT9 EQU 200h
|
||||
BIT10 EQU 400h
|
||||
BIT11 EQU 800h
|
||||
BIT12 EQU 1000h
|
||||
BIT13 EQU 2000h
|
||||
BIT14 EQU 4000h
|
||||
BIT15 EQU 8000h
|
||||
BIT16 EQU 10000h
|
||||
BIT17 EQU 20000h
|
||||
BIT18 EQU 40000h
|
||||
BIT19 EQU 80000h
|
||||
BIT20 EQU 100000h
|
||||
BIT21 EQU 200000h
|
||||
BIT22 EQU 400000h
|
||||
BIT23 EQU 800000h
|
||||
BIT24 EQU 1000000h
|
||||
BIT25 EQU 2000000h
|
||||
BIT26 EQU 4000000h
|
||||
BIT27 EQU 8000000h
|
||||
BIT28 EQU 10000000h
|
||||
BIT29 EQU 20000000h
|
||||
BIT30 EQU 40000000h
|
||||
BIT31 EQU 80000000h
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
macro debug_print str
|
||||
{
|
||||
local ..string, ..label
|
||||
|
||||
jmp ..label
|
||||
..string db str,0
|
||||
..label:
|
||||
|
||||
pushf
|
||||
pushad
|
||||
mov edx,..string
|
||||
call debug_outstr
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
dps fix debug_print
|
||||
|
||||
macro debug_print_dec arg
|
||||
{
|
||||
pushf
|
||||
pushad
|
||||
if ~arg eq eax
|
||||
mov eax,arg
|
||||
end if
|
||||
call debug_outdec
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
dpd fix debug_print_dec
|
||||
|
||||
;---------------------------------
|
||||
debug_outdec: ;(eax - num, edi-str)
|
||||
push 10 ;2
|
||||
pop ecx ;1
|
||||
push -'0' ;2
|
||||
.l0:
|
||||
xor edx,edx ;2
|
||||
div ecx ;2
|
||||
push edx ;1
|
||||
test eax,eax ;2
|
||||
jnz .l0 ;2
|
||||
.l1:
|
||||
pop eax ;1
|
||||
add al,'0' ;2
|
||||
call debug_outchar ; stosb
|
||||
jnz .l1 ;2
|
||||
ret ;1
|
||||
;---------------------------------
|
||||
|
||||
debug_outchar: ; al - char
|
||||
pushf
|
||||
pushad
|
||||
mov cl,al
|
||||
mov eax,63
|
||||
mov ebx,1
|
||||
int 0x40
|
||||
popad
|
||||
popf
|
||||
ret
|
||||
|
||||
debug_outstr:
|
||||
mov eax,63
|
||||
mov ebx,1
|
||||
@@:
|
||||
mov cl,[edx]
|
||||
test cl,cl
|
||||
jz @f
|
||||
int 40h
|
||||
inc edx
|
||||
jmp @b
|
||||
@@:
|
||||
ret
|
||||
|
||||
|
||||
macro newline
|
||||
{
|
||||
dps <13,10>
|
||||
}
|
||||
|
||||
macro print message
|
||||
{
|
||||
dps message
|
||||
newline
|
||||
}
|
||||
|
||||
macro pregs
|
||||
{
|
||||
dps "EAX: "
|
||||
dpd eax
|
||||
dps " EBX: "
|
||||
dpd ebx
|
||||
newline
|
||||
dps "ECX: "
|
||||
dpd ecx
|
||||
dps " EDX: "
|
||||
dpd edx
|
||||
newline
|
||||
}
|
||||
|
||||
macro debug_print_hex arg
|
||||
{
|
||||
pushf
|
||||
pushad
|
||||
if ~arg eq eax
|
||||
mov eax, arg
|
||||
end if
|
||||
call debug_outhex
|
||||
popad
|
||||
popf
|
||||
}
|
||||
dph fix debug_print_hex
|
||||
|
||||
debug_outhex:
|
||||
; eax - number
|
||||
mov edx, 8
|
||||
.new_char:
|
||||
rol eax, 4
|
||||
movzx ecx, al
|
||||
and cl, 0x0f
|
||||
mov cl, [__hexdigits + ecx]
|
||||
pushad
|
||||
mcall 63, 1
|
||||
popad
|
||||
dec edx
|
||||
jnz .new_char
|
||||
ret
|
||||
|
||||
__hexdigits:
|
||||
db '0123456789ABCDEF'
|
||||
@@ -0,0 +1,270 @@
|
||||
thread:
|
||||
call draw_window
|
||||
call main_loop
|
||||
mov [status], ST_EXIT
|
||||
mcall MF_EXIT
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
main_loop:
|
||||
cmp [status], ST_PLAY
|
||||
je @f
|
||||
mcall MF_WAIT_EVENT
|
||||
jmp .handle_event
|
||||
@@:
|
||||
call draw_progress_bar
|
||||
mcall MF_WAIT_EVENT_TIMEOUT, 80
|
||||
.handle_event:
|
||||
cmp eax, EV_REDRAW
|
||||
je redraw
|
||||
cmp eax, EV_BUTTON
|
||||
je button
|
||||
cmp eax, EV_KEY
|
||||
je key
|
||||
jmp main_loop
|
||||
|
||||
redraw:
|
||||
call draw_window
|
||||
jmp main_loop
|
||||
|
||||
key:
|
||||
mcall MF_GETKEY
|
||||
cmp [textbox_active], 1
|
||||
jne main_loop
|
||||
cmp ah, 13
|
||||
je .enter
|
||||
cmp ah, 8
|
||||
je .backspace
|
||||
movzx ecx, [textbox_position]
|
||||
cmp ecx, 47
|
||||
jae .enter
|
||||
mov [textbox_string + ecx], ah
|
||||
inc [textbox_position]
|
||||
call textbox_draw
|
||||
jmp main_loop
|
||||
.enter:
|
||||
mov [textbox_active], 0
|
||||
call textbox_draw
|
||||
jmp main_loop
|
||||
.backspace:
|
||||
movzx ecx, [textbox_position]
|
||||
test ecx, ecx
|
||||
jz main_loop
|
||||
mov [textbox_string + ecx], byte 0
|
||||
dec [textbox_position]
|
||||
call textbox_draw
|
||||
jmp main_loop
|
||||
|
||||
button:
|
||||
mcall MF_GETBUTTON
|
||||
cmp ah, 0x10
|
||||
je play_button
|
||||
cmp ah, 0x11
|
||||
je stop_button
|
||||
cmp ah, 0x12
|
||||
je decr_button
|
||||
cmp ah, 0x13
|
||||
je incr_button
|
||||
cmp ah, 0x14
|
||||
je volm_button
|
||||
cmp ah, 0x15
|
||||
je volp_button
|
||||
cmp ah, 0x20
|
||||
je activate_textbox
|
||||
cmp ah, 0x30
|
||||
je progressbar_click
|
||||
cmp ah, 1
|
||||
jne main_loop
|
||||
|
||||
; mov [status], ST_STOP
|
||||
; mcall MF_DELAY, 40
|
||||
ret
|
||||
|
||||
play_button:
|
||||
xor eax, eax
|
||||
xchg al, [textbox_active]
|
||||
cmp al, 0
|
||||
je @f
|
||||
call textbox_draw
|
||||
@@:
|
||||
mov [status], ST_PLAY
|
||||
jmp main_loop
|
||||
stop_button:
|
||||
mov [status], ST_STOP
|
||||
jmp main_loop
|
||||
|
||||
decr_button:
|
||||
; mov [status], ST_STOP
|
||||
; @@:
|
||||
; mcall 5, 1
|
||||
; cmp [status], ST_DONE
|
||||
; jne @b
|
||||
; movzx esi, [textbox_position]
|
||||
; add esi, textbox_string
|
||||
; @@:
|
||||
; cmp byte [esi], '/'
|
||||
; je @f
|
||||
; dec esi
|
||||
; jmp @b
|
||||
; @@:
|
||||
; mov byte [esi+1], 0
|
||||
; mov [fileinfo.first_block], 0
|
||||
; mov [fileinfo.dest], WAV_BUFFER1
|
||||
; mcall 58, fileinfo
|
||||
; add ebx, WAV_BUFFER1
|
||||
; mov esi, WAV_BUFFER1+8
|
||||
; .next_file:
|
||||
; cmp ebx, esi
|
||||
; jbe .fin
|
||||
; cmp word [esi], "WA"
|
||||
; jne .next_file
|
||||
; cmp byte [esi+1], "V"
|
||||
; jne .next_file
|
||||
; .fin:
|
||||
|
||||
;mov eax, [fileinfo.first_block]
|
||||
;cmp eax, 1000
|
||||
;jnl @f
|
||||
;mov [fileinfo.first_block], 0
|
||||
;jmp main_loop
|
||||
;@@:
|
||||
;sub [fileinfo.first_block], 1000
|
||||
;jmp main_loop
|
||||
|
||||
incr_button:
|
||||
;add [fileinfo.first_block], 1000
|
||||
jmp main_loop
|
||||
|
||||
volm_button:
|
||||
inc byte [volume]
|
||||
and byte [volume], 0x1f
|
||||
jz volp_button
|
||||
or [volume], 0x10000000
|
||||
jmp _print_volume
|
||||
; jmp main_loop
|
||||
|
||||
volp_button:
|
||||
dec byte [volume]
|
||||
and byte [volume], 0x1f
|
||||
jz volm_button
|
||||
or [volume], 0x10000000
|
||||
; jmp main_loop
|
||||
|
||||
_print_volume:
|
||||
movzx eax, byte [volume]
|
||||
neg eax
|
||||
add eax, 31
|
||||
dps "Volume: "
|
||||
dpd eax
|
||||
newline
|
||||
jmp main_loop
|
||||
|
||||
activate_textbox:
|
||||
cmp [status], ST_DONE
|
||||
jne main_loop
|
||||
mov [textbox_active], 1
|
||||
call textbox_draw
|
||||
jmp main_loop
|
||||
|
||||
progressbar_click:
|
||||
;print "click on progress bar"
|
||||
cmp [status], ST_DONE
|
||||
je main_loop
|
||||
mcall MF_GETMOUSE, MS_COORDS_WINDOW
|
||||
shr eax, 16 ; get mouse.x
|
||||
sub eax, 7
|
||||
test eax, eax
|
||||
jz @f
|
||||
imul eax, [file_size]
|
||||
mov ebx, 286
|
||||
cdq
|
||||
div ebx
|
||||
@@:
|
||||
;dps "block: "
|
||||
;dpd eax
|
||||
;newline
|
||||
mov [fileinfo.first_block], eax
|
||||
call draw_progress_bar
|
||||
jmp main_loop
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
PBAR_WIDTH = 286
|
||||
|
||||
draw_window:
|
||||
mcall MF_DRAWSTATUS, DS_BEGIN
|
||||
|
||||
mcall MF_WINDOW, <100,299>, <100,72>, 0x03404040
|
||||
|
||||
; create six buttons
|
||||
mov edi, 6
|
||||
mpack ebx, 7, 45
|
||||
mpack ecx, 24, 13
|
||||
mov edx, 0x10
|
||||
mov esi, 0xA0A0A0
|
||||
@@:
|
||||
mcall MF_BUTTON
|
||||
add ebx, 48 shl 16
|
||||
inc edx
|
||||
dec edi
|
||||
jnz @b
|
||||
|
||||
mcall MF_TEXT, <8,8>, 0x10FFFFFF, header, header.size
|
||||
|
||||
mcall ,<13,28>, 0x404040, buttons_text, buttons_text.size
|
||||
sub ebx, 0x00010001
|
||||
mov ecx, 0xFFFFFF
|
||||
mcall
|
||||
|
||||
call draw_progress_bar
|
||||
call textbox_draw
|
||||
|
||||
mcall MF_DRAWSTATUS, DS_END
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
textbox_draw:
|
||||
mcall MF_BUTTON, <7,285>, <55,10>, 0x60000020
|
||||
|
||||
mov edx, 0x808080
|
||||
cmp [textbox_active], 1
|
||||
jne @f
|
||||
mov edx, 0xA0A0A0
|
||||
@@:
|
||||
mcall MF_BAR, <7,286>, <55,11>
|
||||
|
||||
movzx esi, [textbox_position]
|
||||
mcall MF_TEXT, <10,56>, 0x404040, textbox_string
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
draw_progress_bar:
|
||||
pushad
|
||||
|
||||
imul eax, [fileinfo.first_block], PBAR_WIDTH
|
||||
cdq
|
||||
div [file_size]
|
||||
|
||||
push eax
|
||||
mcall MF_BAR, <7,286>, <41,11>, 0x808080
|
||||
mcall MF_BUTTON, , , 0x60000030
|
||||
pop eax
|
||||
|
||||
mov bx, ax
|
||||
mov edx, 0xA0A0A0
|
||||
mcall MF_BAR
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
sz header, "AC'97 WAV player - all PCM audio"
|
||||
sz buttons_text, " Play Stop << >> Vol- Vol+"
|
||||
|
||||
textbox_active db 0
|
||||
textbox_position db textbox_string.size-1
|
||||
file_size dd 100
|
||||
@@ -0,0 +1,10 @@
|
||||
include "MACROS.INC"
|
||||
include "DEBUG.INC"
|
||||
include "CONSTANT.INC"
|
||||
include "AC97.INC"
|
||||
include "PCI.INC"
|
||||
include "CODEC.INC"
|
||||
include "FRONTEND.INC"
|
||||
|
||||
|
||||
MF_PCI = 62
|
||||
@@ -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
|
||||
@@ -0,0 +1,29 @@
|
||||
MF_WINDOW = 0
|
||||
MF_GETKEY = 2
|
||||
MF_TEXT = 4
|
||||
MF_DELAY = 5
|
||||
MF_BUTTON = 8
|
||||
MF_PROCINFO = 9
|
||||
PN_MYSELF = -1
|
||||
MF_WAIT_EVENT = 10
|
||||
MF_DRAWSTATUS = 12
|
||||
DS_BEGIN = 1
|
||||
DS_END = 2
|
||||
MF_BAR = 13
|
||||
MF_GETBUTTON = 17
|
||||
MF_WAIT_EVENT_TIMEOUT = 23
|
||||
MF_GETMOUSE = 37
|
||||
MS_COORDS_WINDOW = 1
|
||||
MF_PORTS = 46
|
||||
PRT_RESERVE = 0
|
||||
PRT_FREE = 1
|
||||
MF_THREAD = 51
|
||||
THR_CREATE = 1
|
||||
MF_SYSTREE = 58
|
||||
MF_PCI = 62
|
||||
MF_EXIT = -1
|
||||
MF_INTERNAL_SERVICES = 68
|
||||
ALLOC_PHYS_MEM =5
|
||||
FREE_PHYS_MEM =6
|
||||
SET_PHYS_BUFFER =7
|
||||
GET_PHYS_BUFFER =8
|
||||
@@ -0,0 +1,46 @@
|
||||
PCI_CMD_REG = 04h ; reg 04, command reg
|
||||
IO_ENA = 0x00000001 ; i/o decode enable
|
||||
MEM_ENA = 0x00000002 ; memory decode enable
|
||||
BM_ENA = 0x00000004 ; bus master enable
|
||||
|
||||
pciRegRead8: ; register in CL!
|
||||
mov bl, 4
|
||||
mov bh, [bus]
|
||||
mov ch, [devfn]
|
||||
mcall MF_PCI
|
||||
ret
|
||||
|
||||
pciRegRead16:
|
||||
mov bl, 5
|
||||
mov bh, [bus]
|
||||
mov ch, [devfn]
|
||||
mcall MF_PCI
|
||||
ret
|
||||
|
||||
pciRegRead32:
|
||||
mov bl, 6
|
||||
mov bh, [bus]
|
||||
mov ch, [devfn]
|
||||
mcall MF_PCI
|
||||
ret
|
||||
|
||||
pciRegWrite8: ; value in DL!
|
||||
mov bl, 8
|
||||
mov bh, [bus]
|
||||
mov ch, [devfn]
|
||||
mcall MF_PCI
|
||||
ret
|
||||
|
||||
pciRegWrite16:
|
||||
mov bl, 9
|
||||
mov bh, [bus]
|
||||
mov ch, [devfn]
|
||||
mcall MF_PCI
|
||||
ret
|
||||
|
||||
pciRegWrite32:
|
||||
mov bl, 10
|
||||
mov bh, [bus]
|
||||
mov ch, [devfn]
|
||||
mcall MF_PCI
|
||||
ret
|
||||
@@ -0,0 +1,85 @@
|
||||
AClock 1.1
|
||||
Copyright (c) 2002,2003 Thomas Mathys
|
||||
killer@vantage.ch
|
||||
|
||||
|
||||
what the hell is this ?
|
||||
-----------------------
|
||||
|
||||
this is aclock, a silly analog clock application
|
||||
for menuetos (http://www.menuetos.org).
|
||||
|
||||
|
||||
why do i need it ?
|
||||
------------------
|
||||
|
||||
well, this is certainly one of the last programs on
|
||||
earth you'd ever need. anyway, it demonstrates how
|
||||
how to do certain things:
|
||||
|
||||
- writing menuet apps that parse the command line.
|
||||
includes a strtok-like function that you might
|
||||
want to use in own projects. or maybe rather not.
|
||||
- writing menuet apps that are aware of the current
|
||||
window size and that have no problems with different
|
||||
skin heights.
|
||||
- how to write menuet apps with nasm instead of fasm
|
||||
(there should be a gas version aswell, don't you think ?)
|
||||
and how to write kick-ass code with nasm in general =)
|
||||
|
||||
|
||||
compiling instructions
|
||||
----------------------
|
||||
|
||||
yes, it's still written for nasm.
|
||||
i really can't be bothered to work with fasm.
|
||||
|
||||
oh yes, you wanted to know how to compile aclock:
|
||||
|
||||
nasm -t -f bin -o aclock aclock.asm
|
||||
|
||||
if you get error messages like
|
||||
|
||||
nasm: unrecognised option `-t
|
||||
type `nasm -h' for help
|
||||
|
||||
then you've got an old version of nasm.
|
||||
get a newer version (0.98.36 or later) from
|
||||
http://nasm.sourceforge.net
|
||||
|
||||
|
||||
configuration
|
||||
-------------
|
||||
|
||||
you might want to change some of the constants defined
|
||||
somewhere at the top of aclock.asm. the following might
|
||||
be useful:
|
||||
|
||||
- DEFAULT_XPOS
|
||||
- DEFAULT_YPOS
|
||||
- DEFAULT_WIDTH
|
||||
- DEFAULT_HEIGHT
|
||||
- MIN_WIDTH
|
||||
- MIN_HEIGHT
|
||||
|
||||
for more info about DEFAULT_XPOS/DEFAULT_YPOS see next
|
||||
section.
|
||||
|
||||
|
||||
usage
|
||||
-----
|
||||
|
||||
this version of AClock introduces command line parameters.
|
||||
here's an example command line:
|
||||
|
||||
aclock w128 h128 x20 y-20
|
||||
|
||||
this creates a window that is 128 pixels wide and 128 pixels
|
||||
high (that's for the work area, without border/title bar).
|
||||
the window is placed at x=20, y=screen resolution-20
|
||||
(because of the minus sign after the y).
|
||||
|
||||
all parameters are optional and may appear in any order.
|
||||
you can't have any whitespaces in a parameter, e.g.
|
||||
"w 128" is an invalid parameter (which will simply be ignored).
|
||||
the command line parser is case sensitive.
|
||||
@@ -0,0 +1,223 @@
|
||||
; aclock 1.1
|
||||
; 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
|
||||
|
||||
bits 32
|
||||
%include 'mos.inc'
|
||||
section .text
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; configuration stuff
|
||||
;********************************************************************
|
||||
|
||||
%define APPNAME "AClock 1.1"
|
||||
%define STACKSIZE 1024
|
||||
|
||||
; default window position/dimensions (work area)
|
||||
%define DEFAULT_XPOS -20
|
||||
%define DEFAULT_YPOS 20
|
||||
%define DEFAULT_WIDTH 80
|
||||
%define DEFAULT_HEIGHT 80
|
||||
|
||||
; minimal size (horizontal and vertical) of work area
|
||||
%define MIN_WIDTH 80
|
||||
%define MIN_HEIGHT 80
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; header
|
||||
;********************************************************************
|
||||
|
||||
MOS_HEADER01 main,image_end,memory_end,stacktop-4,cmdLine,0
|
||||
|
||||
; these includes introduce code and thus mustn't stand
|
||||
; before the menuet header =)
|
||||
%include 'dbgboard.inc'
|
||||
%include 'strlen.inc'
|
||||
%include 'str2dwrd.inc'
|
||||
%include 'strtok.inc'
|
||||
%include 'cmdline.inc'
|
||||
%include 'adjstwnd.inc'
|
||||
%include 'draw.inc'
|
||||
|
||||
;********************************************************************
|
||||
; main program
|
||||
;********************************************************************
|
||||
main:
|
||||
call getDefaultWindowColors
|
||||
call parseCommandLine
|
||||
|
||||
; check minimal window dimensions
|
||||
cmp dword [wndWidth],MIN_WIDTH
|
||||
jae .widthok
|
||||
mov dword [wndWidth],MIN_WIDTH
|
||||
.widthok:
|
||||
cmp dword [wndHeight],MIN_HEIGHT
|
||||
jae .heightok
|
||||
mov dword [wndHeight],MIN_HEIGHT
|
||||
.heightok:
|
||||
|
||||
; adjust window dimensions
|
||||
mov eax,ADJSTWND_TYPE_SKINNED
|
||||
mov ebx,[wndXPos]
|
||||
mov ecx,[wndYPos]
|
||||
mov edx,[wndWidth]
|
||||
mov esi,[wndHeight]
|
||||
call adjustWindowDimensions
|
||||
mov [wndXPos],ebx
|
||||
mov [wndYPos],ecx
|
||||
mov [wndWidth],edx
|
||||
mov [wndHeight],esi
|
||||
|
||||
call drawWindow
|
||||
.msgpump:
|
||||
call drawClock
|
||||
|
||||
; wait up to a second for next event
|
||||
mov eax,MOS_SC_WAITEVENTTIMEOUT
|
||||
mov ebx,100
|
||||
int 0x40
|
||||
|
||||
cmp eax,MOS_EVT_REDRAW
|
||||
je .redraw
|
||||
cmp eax,MOS_EVT_KEY
|
||||
je .key
|
||||
cmp eax,MOS_EVT_BUTTON
|
||||
je .button
|
||||
jmp .msgpump
|
||||
|
||||
.redraw:
|
||||
call drawWindow
|
||||
jmp .msgpump
|
||||
.key:
|
||||
mov eax,MOS_SC_GETKEY
|
||||
int 0x40
|
||||
jmp .msgpump
|
||||
.button:
|
||||
mov eax,MOS_SC_EXIT
|
||||
int 0x40
|
||||
jmp .msgpump
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; get default window colors
|
||||
; input : nothing
|
||||
; output : wndColors contains default colors
|
||||
; destroys : nothing
|
||||
;********************************************************************
|
||||
getDefaultWindowColors:
|
||||
pushad
|
||||
pushfd
|
||||
mov eax,MOS_SC_WINDOWPROPERTIES
|
||||
mov ebx,3
|
||||
mov ecx,wndColors
|
||||
mov edx,MOS_WNDCOLORS_size
|
||||
int 0x40
|
||||
popfd
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; define and draw window
|
||||
; input nothing
|
||||
; output nothing
|
||||
; destroys flags
|
||||
;********************************************************************
|
||||
align 4
|
||||
drawWindow:
|
||||
pusha
|
||||
|
||||
; start window redraw
|
||||
mov eax,MOS_SC_REDRAWSTATUS
|
||||
mov ebx,1
|
||||
int 0x40
|
||||
|
||||
; create window
|
||||
mov eax,MOS_SC_DEFINEWINDOW
|
||||
mov ebx,[wndXPos]
|
||||
shl ebx,16
|
||||
or ebx,[wndWidth]
|
||||
mov ecx,[wndYPos]
|
||||
shl ecx,16
|
||||
or ecx,[wndHeight]
|
||||
mov edx,[wndColors+MOS_WNDCOLORS.work]
|
||||
or edx,0x03000000
|
||||
mov esi,[wndColors+MOS_WNDCOLORS.grab]
|
||||
mov edi,[wndColors+MOS_WNDCOLORS.frame]
|
||||
int 0x40
|
||||
|
||||
; draw window label
|
||||
mov eax,MOS_SC_WRITETEXT
|
||||
mov ebx,MOS_DWORD(8,8)
|
||||
mov ecx,[wndColors+MOS_WNDCOLORS.grabText]
|
||||
mov edx,label
|
||||
mov esi,LABEL_LEN
|
||||
int 0x40
|
||||
|
||||
call drawClock
|
||||
|
||||
; end window redraw
|
||||
mov eax,MOS_SC_REDRAWSTATUS
|
||||
mov ebx,2
|
||||
int 0x40
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; initialized data
|
||||
;********************************************************************
|
||||
|
||||
; window position and dimensions.
|
||||
; dimensions are for work area only.
|
||||
wndXPos dd DEFAULT_XPOS
|
||||
wndYPos dd DEFAULT_YPOS
|
||||
wndWidth dd DEFAULT_WIDTH
|
||||
wndHeight dd DEFAULT_HEIGHT
|
||||
|
||||
; window label
|
||||
label db APPNAME,0
|
||||
LABEL_LEN equ ($-label-1)
|
||||
|
||||
; token delimiter list for command line
|
||||
delimiters db 9,10,11,12,13,32,0
|
||||
|
||||
; don't insert anything after this label
|
||||
image_end:
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; uninitialized data
|
||||
;********************************************************************
|
||||
section .bss
|
||||
|
||||
wndColors resb MOS_WNDCOLORS_size
|
||||
procInfo resb MOS_PROCESSINFO_size
|
||||
|
||||
; space for command line. at the end we have an additional
|
||||
; byte for a terminating zero, just to be sure...
|
||||
cmdLine resb 257
|
||||
|
||||
alignb 4
|
||||
stack resb STACKSIZE
|
||||
stacktop:
|
||||
|
||||
; don't insert anything after this label
|
||||
memory_end:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1,147 @@
|
||||
; adjustWindowDimensions
|
||||
; adjust menut window dimensions to get a certain work area size.
|
||||
; or so. who on earth cares anyway, i certinaly don't, i'm just
|
||||
; writing this code because i've got to kill time somehow...
|
||||
;
|
||||
; 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 _ADJSTWND_INC
|
||||
%define _ADJSTWND_INC
|
||||
|
||||
|
||||
;window types
|
||||
ADJSTWND_TYPE_SKINNED equ 0
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; adjust window dimensions to get a certain work area size
|
||||
;
|
||||
; - first the window width and height are adjusted
|
||||
; and clamped if they're too large for the screen.
|
||||
; - then the window positions are adjusted, if the
|
||||
; window goes out of the screen.
|
||||
;
|
||||
; input:
|
||||
; eax window type, one of the ADJSTWND_TYPE_xxx constants
|
||||
; ebx window x position
|
||||
; ecx window y position
|
||||
; edx desired work area width
|
||||
; esi desired work area height
|
||||
;
|
||||
; output:
|
||||
; eax return code. 0 = ok, -1 = invalid window type
|
||||
; ebx adjusted window x position
|
||||
; ecx adjusted window y position
|
||||
; edx window width to get desired work area width
|
||||
; esi window height to get desired work area height
|
||||
;
|
||||
; destroys:
|
||||
; nothing
|
||||
;
|
||||
; normally x and y are the upper left corner of the window,
|
||||
; relative to the upper left corner of the screen.
|
||||
; if you pass a negative x or y it will be treated as the
|
||||
; lower right corner of the window, relative to the lower
|
||||
; right corner of the screen.
|
||||
;********************************************************************
|
||||
adjustWindowDimensions:
|
||||
push edi
|
||||
push ebp
|
||||
pushfd
|
||||
|
||||
; adjust window dimensions, depending on the window type
|
||||
cmp eax,ADJSTWND_TYPE_SKINNED
|
||||
je .adjust_skinned
|
||||
mov eax,-1 ; invalid window type,
|
||||
jmp .bye ; return error code
|
||||
|
||||
; clamp window dimensions
|
||||
.clamp:
|
||||
mov eax,MOS_SC_GETSCREENMAX ; get screen dimensions
|
||||
int 0x40
|
||||
mov edi,eax ; edi = screen width
|
||||
shr edi,16
|
||||
mov ebp,eax ; ebp = screen height
|
||||
and ebp,0xffff
|
||||
cmp edx,edi ; window width > screen width ?
|
||||
jna .widthok
|
||||
mov edx,edi ; yes -> use screen width
|
||||
.widthok:
|
||||
cmp esi,ebp ; wnd height > screen height ?
|
||||
jna .heightok
|
||||
mov esi,ebp ; yes -> use screen height
|
||||
.heightok:
|
||||
|
||||
; adjust x position
|
||||
or ebx,ebx ; do the lower right corner
|
||||
jns .foo ; stuff if x is negative.
|
||||
add ebx,edi
|
||||
sub ebx,edx
|
||||
.foo:
|
||||
or ebx,ebx ; x < 0 ?
|
||||
jns .xnotnegative
|
||||
xor ebx,ebx ; yes -> x = 0
|
||||
.xnotnegative:
|
||||
mov eax,ebx ; x + width > screen width ?
|
||||
add eax,edx
|
||||
cmp eax,edi
|
||||
jna .xok
|
||||
sub eax,edi ; yes -> adjust
|
||||
sub ebx,eax
|
||||
.xok:
|
||||
|
||||
; adjust y position
|
||||
or ecx,ecx ; do the lower right corner
|
||||
jns .bar ; stuff if y is negative.
|
||||
add ecx,ebp
|
||||
sub ecx,esi
|
||||
.bar:
|
||||
or ecx,ecx ; y < 0 ?
|
||||
jns .ynotnegative
|
||||
xor ecx,ecx ; yes -> y = 0
|
||||
.ynotnegative:
|
||||
mov eax,ecx ; y + height > screen height ?
|
||||
add eax,esi
|
||||
cmp eax,ebp
|
||||
jna .yok
|
||||
sub eax,ebp ; yes -> adjust
|
||||
sub ecx,eax
|
||||
.yok:
|
||||
|
||||
.done:
|
||||
xor eax,eax
|
||||
.bye:
|
||||
popfd
|
||||
pop ebp
|
||||
pop edi
|
||||
ret
|
||||
|
||||
.adjust_skinned:
|
||||
; adjust width (edx)
|
||||
add edx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT
|
||||
; adjust height (esi). we need the skin height to do this.
|
||||
push ebx
|
||||
mov eax,MOS_SC_WINDOWPROPERTIES
|
||||
mov ebx,4
|
||||
int 0x40
|
||||
lea esi,[esi+eax+MOS_WND_SKIN_BORDER_BOTTOM]
|
||||
pop ebx
|
||||
jmp .clamp
|
||||
|
||||
%endif
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
; command line parsing code for aclock
|
||||
;
|
||||
; Copyright (c) 2003 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 _CMDLINE_INC
|
||||
%define _CMDLINE_INC
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; parse the command line
|
||||
; input : nothing
|
||||
; output : wndXPos, wndYPos, wndWidth, wndHeight
|
||||
; are changed.
|
||||
; destroys : nothing
|
||||
;********************************************************************
|
||||
parseCommandLine:
|
||||
pushad
|
||||
pushfd
|
||||
|
||||
; terminate command line, just to be sure
|
||||
mov byte [cmdLine + 256],0
|
||||
|
||||
; go through all tokens
|
||||
mov eax,cmdLine ; eax -> command line
|
||||
.parseloop:
|
||||
mov ebx,delimiters ; ebx -> token delimiter list
|
||||
call strtok ; get next parameter
|
||||
or eax,eax ; no more parameters ?
|
||||
jz .nomoretokens
|
||||
mov cl,[eax] ; get 1st char of parameter
|
||||
cmp cl,'x' ; which parameter is it ?
|
||||
je .param_x
|
||||
cmp cl,'y'
|
||||
je .param_y
|
||||
cmp cl,'w'
|
||||
je .param_w
|
||||
cmp cl,'h'
|
||||
je .param_h
|
||||
; if we reach this line it's an unknown parameter, ignore it
|
||||
.nextparam:
|
||||
xor eax,eax ; set eax = 0 to continue
|
||||
jmp .parseloop ; after last token.
|
||||
.nomoretokens:
|
||||
DBG_BOARD_PRINTDWORD [wndXPos]
|
||||
DBG_BOARD_PRINTCHAR 32
|
||||
DBG_BOARD_PRINTDWORD [wndYPos]
|
||||
DBG_BOARD_PRINTCHAR 32
|
||||
DBG_BOARD_PRINTDWORD [wndWidth]
|
||||
DBG_BOARD_PRINTCHAR 32
|
||||
DBG_BOARD_PRINTDWORD [wndHeight]
|
||||
DBG_BOARD_PRINTNEWLINE
|
||||
popfd
|
||||
popad
|
||||
ret
|
||||
|
||||
; eax -> first character of the parameter
|
||||
.param_x:
|
||||
push eax
|
||||
call parsePositionParam
|
||||
mov [wndXPos],eax
|
||||
pop eax
|
||||
jmp .nextparam
|
||||
|
||||
; eax -> first character of the parameter
|
||||
.param_y:
|
||||
push eax
|
||||
call parsePositionParam
|
||||
mov [wndYPos],eax
|
||||
pop eax
|
||||
jmp .nextparam
|
||||
|
||||
; eax -> first character of the parameter
|
||||
.param_w:
|
||||
push eax
|
||||
call parseSizeParam
|
||||
mov [wndWidth],eax
|
||||
pop eax
|
||||
jmp .nextparam
|
||||
|
||||
; eax -> first character of the parameter
|
||||
.param_h:
|
||||
push eax
|
||||
call parseSizeParam
|
||||
mov [wndHeight],eax
|
||||
pop eax
|
||||
jmp .nextparam
|
||||
|
||||
; parse position parameter
|
||||
; input : eax = address of first character of parameter
|
||||
; output : eax contains position
|
||||
; destroys : nothing
|
||||
parsePositionParam:
|
||||
push ebx
|
||||
push esi
|
||||
pushfd
|
||||
|
||||
; is the second char of the parameter a '-' ?
|
||||
inc eax
|
||||
xor ebx,ebx ; assume it isn't
|
||||
cmp byte [eax],'-'
|
||||
jne .nominus
|
||||
mov ebx,1 ; yes -> set flag...
|
||||
inc eax ; ...and move to next char
|
||||
.nominus:
|
||||
|
||||
; convert rest of parameter to doubleword
|
||||
mov esi,eax
|
||||
call string2dword
|
||||
|
||||
; negate if necessary
|
||||
or ebx,ebx
|
||||
jz .rotationshyperboloid
|
||||
neg eax
|
||||
.rotationshyperboloid:
|
||||
|
||||
popfd
|
||||
pop esi
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; parse dimension parameter
|
||||
; input : eax = address of first char of parameter
|
||||
; output : eax contains dimension
|
||||
; destroys : nothing
|
||||
parseSizeParam:
|
||||
push esi
|
||||
pushfd
|
||||
lea esi,[eax + 1] ; esi -> 2nd char of parameter
|
||||
call string2dword
|
||||
popfd
|
||||
pop esi
|
||||
ret
|
||||
|
||||
|
||||
%endif
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
; macros to write stuff to menuet's debug message board.
|
||||
; the macros don't change any registers, not even flags.
|
||||
; they take only effect if DEBUG is defined.
|
||||
;
|
||||
; Copyright (c) 2003 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 _DBGBOARD_INC
|
||||
%define _DBGBOARD_INC
|
||||
|
||||
|
||||
%ifdef DEBUG
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; print newline
|
||||
; no input
|
||||
;********************************************************************
|
||||
%macro DBG_BOARD_PRINTNEWLINE 0
|
||||
call dbg_board_printnewline
|
||||
%endm
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; print a character
|
||||
;
|
||||
; examples : DBG_BOARD_PRINTCHAR '?'
|
||||
; DBG_BOARD_PRINTCHAR 65
|
||||
; DBG_BOARD_PRINTCHAR cl
|
||||
; DBG_BOARD_PRINTCHAR [esi]
|
||||
; DBG_BOARD_PRINTCHAR [somevariable]
|
||||
;********************************************************************
|
||||
%macro DBG_BOARD_PRINTCHAR 1
|
||||
push ecx
|
||||
mov cl,byte %1
|
||||
call dbg_board_printchar
|
||||
pop ecx
|
||||
%endm
|
||||
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; print a dword (in hex)
|
||||
;
|
||||
; examples: DBG_BOARD_PRINTDWORD esp
|
||||
; DBG_BOARD_PRINTDWORD 0xdeadbeef
|
||||
; DBG_BOARD_PRINTDWORD [somevariable]
|
||||
;********************************************************************
|
||||
%macro DBG_BOARD_PRINTDWORD 1
|
||||
push dword %1
|
||||
call dbg_board_printdword
|
||||
%endm
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; print a string literal
|
||||
; a terminating zero is automagically appended to the string.
|
||||
;
|
||||
; examples DBG_BOARD_PRINTSTRINGLITERAL "foo",0
|
||||
; DBG_BOARD_PRINTSTRINGLITERAL "bar",10,13,0
|
||||
;********************************************************************
|
||||
%macro DBG_BOARD_PRINTSTRINGLITERAL 1+
|
||||
jmp %%bar
|
||||
%%foo db %1, 0 ; terminate string, just to be sure
|
||||
%%bar:
|
||||
push dword %%foo
|
||||
call dbg_board_printstring
|
||||
%endm
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; print a string (asciiz)
|
||||
;
|
||||
; examples DBG_BOARD_PRINTSTRING addressofstring
|
||||
; DBG_BOARD_PRINTSTRING esi
|
||||
; DBG_BOARD_PRINTSTRING [ebx]
|
||||
;********************************************************************
|
||||
%macro DBG_BOARD_PRINTSTRING 1
|
||||
push dword %1
|
||||
call dbg_board_printstring
|
||||
%endm
|
||||
|
||||
|
||||
; no input
|
||||
dbg_board_printnewline:
|
||||
pushad
|
||||
pushfd
|
||||
mov eax,MOS_SC_DEBUGBOARD
|
||||
mov ebx,1
|
||||
mov ecx,10
|
||||
int 0x40
|
||||
mov ecx,13
|
||||
int 0x40
|
||||
popfd
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
; input : cl = character to print
|
||||
dbg_board_printchar:
|
||||
pushad
|
||||
pushfd
|
||||
mov eax,MOS_SC_DEBUGBOARD
|
||||
mov ebx,1
|
||||
and ecx,0xff
|
||||
int 0x40
|
||||
popfd
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
; input : dword to print on stack
|
||||
dbg_board_printdword:
|
||||
enter 0,0
|
||||
pushad
|
||||
pushfd
|
||||
mov eax,MOS_SC_DEBUGBOARD
|
||||
mov ebx,1
|
||||
mov ecx,'0' ; print 0x prefix
|
||||
int 0x40
|
||||
mov ecx,'x'
|
||||
int 0x40
|
||||
mov edx,[ebp + 8] ; get dword to print
|
||||
mov esi,8 ; iterate through all nibbles
|
||||
.loop:
|
||||
mov ecx,edx ; display hex digit
|
||||
shr ecx,28
|
||||
movzx ecx,byte [dbg_board_printdword_digits + ecx]
|
||||
int 0x40
|
||||
shl edx,4 ; next nibble
|
||||
dec esi
|
||||
jnz .loop
|
||||
popfd
|
||||
popad
|
||||
leave
|
||||
ret 4
|
||||
dbg_board_printdword_digits:
|
||||
db '0','1','2','3','4','5','6','7'
|
||||
db '8','9','a','b','c','d','e','f'
|
||||
|
||||
|
||||
; input : address of string (asciiz) to print on stack
|
||||
dbg_board_printstring:
|
||||
enter 0,0
|
||||
pushad
|
||||
pushfd
|
||||
cld
|
||||
mov esi,[ebp + 8] ; esi -> string
|
||||
mov ebx,1
|
||||
.loop:
|
||||
lodsb ; get character
|
||||
or al,al ; zero ?
|
||||
je .done ; yeah -> get outta here
|
||||
movzx ecx,al ; nope -> display character
|
||||
mov eax,MOS_SC_DEBUGBOARD
|
||||
int 0x40
|
||||
jmp .loop
|
||||
.done:
|
||||
popfd
|
||||
popad
|
||||
leave
|
||||
ret 4
|
||||
|
||||
%else
|
||||
|
||||
|
||||
%macro DBG_BOARD_PRINTNEWLINE 0
|
||||
%endm
|
||||
|
||||
%macro DBG_BOARD_PRINTCHAR 1
|
||||
%endm
|
||||
|
||||
%macro DBG_BOARD_PRINTDWORD 1
|
||||
%endm
|
||||
|
||||
%macro DBG_BOARD_PRINTSTRINGLITERAL 1+
|
||||
%endm
|
||||
|
||||
%macro DBG_BOARD_PRINTSTRING 1
|
||||
%endm
|
||||
|
||||
%endif
|
||||
|
||||
|
||||
%endif
|
||||
|
||||
@@ -0,0 +1,430 @@
|
||||
; drawing code for aclock
|
||||
;
|
||||
; Copyright (c) 2003 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 _DRAW_INC
|
||||
%define _DRAW_INC
|
||||
|
||||
|
||||
TMR1_FACTOR dd 0.45
|
||||
TMR2_FACTOR dd 0.426315789
|
||||
SECR_FACTOR dd 0.378947368
|
||||
MINR_FACTOR dd 0.355263158
|
||||
HOURR_FACTOR dd 0.189473684
|
||||
DATE_FACTOR dd 0.1
|
||||
|
||||
|
||||
monthNames:
|
||||
db "Jan"
|
||||
db "Feb"
|
||||
db "Mar"
|
||||
db "Apr"
|
||||
db "May"
|
||||
db "Jun"
|
||||
db "Jul"
|
||||
db "Aug"
|
||||
db "Sep"
|
||||
db "Oct"
|
||||
db "Nov"
|
||||
db "Dec"
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; draws the clock
|
||||
; input : nothing
|
||||
; output : nothing
|
||||
; destroys : nothing
|
||||
;********************************************************************
|
||||
drawClock:
|
||||
%push drawClock_context
|
||||
%stacksize flat
|
||||
%assign %$localsize 0
|
||||
|
||||
%local i:dword, \
|
||||
TMR1X:dword, \
|
||||
TMR1Y:dword, \
|
||||
TMR2X:dword, \
|
||||
TMR2Y:dword, \
|
||||
SECRX:dword, \
|
||||
SECRY:dword, \
|
||||
MINRX:dword, \
|
||||
MINRY:dword, \
|
||||
HOURRX:dword, \
|
||||
HOURRY:dword, \
|
||||
workwidth:dword, \
|
||||
workheight:dword, \
|
||||
foo:dword
|
||||
|
||||
enter %$localsize,0
|
||||
pushad
|
||||
pushfd
|
||||
|
||||
; get window dimensions
|
||||
mov eax,MOS_SC_GETPROCESSINFO
|
||||
mov ebx,procInfo
|
||||
mov ecx,-1
|
||||
int 0x40
|
||||
|
||||
; calculate work area size (width/height = ecx/edx)
|
||||
; if the work area is too small (maybe the window is shaded)
|
||||
; we don't draw anything.
|
||||
mov eax,MOS_SC_WINDOWPROPERTIES
|
||||
mov ebx,4 ; get skin height (eax)
|
||||
int 0x40
|
||||
mov ecx,[procInfo + MOS_PROCESSINFO.wndWidth]
|
||||
sub ecx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT
|
||||
mov edx,[procInfo + MOS_PROCESSINFO.wndHeight]
|
||||
sub edx,eax
|
||||
sub edx,MOS_WND_SKIN_BORDER_BOTTOM
|
||||
cmp ecx,0 ; width too small ?
|
||||
jle .bye
|
||||
cmp edx,0 ; height too small ?
|
||||
jnle .continue
|
||||
.bye:
|
||||
jmp .byebye
|
||||
.continue:
|
||||
mov [workwidth],ecx ; save for later (for fpu)
|
||||
mov [workheight],edx
|
||||
|
||||
; calculate center of clock (x/y = esi/edi)
|
||||
mov esi,[procInfo + MOS_PROCESSINFO.wndWidth]
|
||||
shr esi,1
|
||||
mov edi,[procInfo + MOS_PROCESSINFO.wndHeight]
|
||||
sub edi,MOS_WND_SKIN_BORDER_BOTTOM
|
||||
sub edi,eax
|
||||
shr edi,1
|
||||
add edi,eax
|
||||
|
||||
; clear work area
|
||||
pushad
|
||||
mov ebx,(MOS_WND_SKIN_BORDER_LEFT)*0x10000 ; x start
|
||||
or ebx,ecx ; width
|
||||
mov ecx,eax ; y start
|
||||
shl ecx,16 ; (=skin height)
|
||||
or ecx,edx ; height
|
||||
mov edx,[wndColors + MOS_WNDCOLORS.work]
|
||||
mov eax,MOS_SC_DRAWBAR
|
||||
int 0x40
|
||||
popad
|
||||
|
||||
; calculate second hand radii
|
||||
fild dword [workwidth]
|
||||
fmul dword [SECR_FACTOR]
|
||||
fstp dword [SECRX]
|
||||
fild dword [workheight]
|
||||
fmul dword [SECR_FACTOR]
|
||||
fstp dword [SECRY]
|
||||
|
||||
; calculate minute hand radii
|
||||
fild dword [workwidth]
|
||||
fmul dword [MINR_FACTOR]
|
||||
fstp dword [MINRX]
|
||||
fild dword [workheight]
|
||||
fmul dword [MINR_FACTOR]
|
||||
fstp dword [MINRY]
|
||||
|
||||
; calculate hour hand radii
|
||||
fild dword [workwidth]
|
||||
fmul dword [HOURR_FACTOR]
|
||||
fstp dword [HOURRX]
|
||||
fild dword [workheight]
|
||||
fmul dword [HOURR_FACTOR]
|
||||
fstp dword [HOURRY]
|
||||
|
||||
; calculate tick mark radii
|
||||
fild dword [workwidth]
|
||||
fmul dword [TMR1_FACTOR]
|
||||
fstp dword [TMR1X]
|
||||
fild dword [workheight]
|
||||
fmul dword [TMR1_FACTOR]
|
||||
fstp dword [TMR1Y]
|
||||
fild dword [workwidth]
|
||||
fmul dword [TMR2_FACTOR]
|
||||
fstp dword [TMR2X]
|
||||
fild dword [workheight]
|
||||
fmul dword [TMR2_FACTOR]
|
||||
fstp dword [TMR2Y]
|
||||
|
||||
; get system clock (edx)
|
||||
mov eax,MOS_SC_GETSYSCLOCK
|
||||
int 0x40
|
||||
mov edx,eax
|
||||
|
||||
; draw second hand
|
||||
push edx
|
||||
mov eax,edx
|
||||
shr eax,16
|
||||
call bcdbin
|
||||
mov ecx,eax ; save seconds for later
|
||||
push ecx
|
||||
push eax
|
||||
fpush32 0.104719755 ; 2*pi/60
|
||||
push dword [SECRX]
|
||||
push dword [SECRY]
|
||||
push esi
|
||||
push edi
|
||||
call getHandCoords
|
||||
mov eax,MOS_SC_DRAWLINE
|
||||
shl ebx,16
|
||||
or ebx,esi
|
||||
shl ecx,16
|
||||
or ecx,edi
|
||||
mov edx,[wndColors + MOS_WNDCOLORS.workText]
|
||||
int 0x40
|
||||
pop ecx
|
||||
pop edx
|
||||
|
||||
; draw minute hand
|
||||
push edx
|
||||
mov eax,edx
|
||||
shr eax,8
|
||||
call bcdbin
|
||||
mov edx,60
|
||||
mul edx
|
||||
add eax,ecx
|
||||
mov ecx,eax ; save for later
|
||||
push ecx
|
||||
push eax
|
||||
fpush32 0.001745329 ; 2*pi/60/60
|
||||
push dword [MINRX]
|
||||
push dword [MINRY]
|
||||
push esi
|
||||
push edi
|
||||
call getHandCoords
|
||||
mov eax,MOS_SC_DRAWLINE
|
||||
shl ebx,16
|
||||
or ebx,esi
|
||||
shl ecx,16
|
||||
or ecx,edi
|
||||
mov edx,[wndColors + MOS_WNDCOLORS.workText]
|
||||
int 0x40
|
||||
pop ecx
|
||||
pop edx
|
||||
|
||||
; draw hour hand
|
||||
push edx
|
||||
mov eax,edx
|
||||
call bcdbin
|
||||
cmp eax,11 ; % 12 (just to be sure)
|
||||
jnae .hoursok
|
||||
sub eax,12
|
||||
.hoursok:
|
||||
mov edx,60*60
|
||||
mul edx
|
||||
add eax,ecx
|
||||
push eax
|
||||
fpush32 0.000145444 ; 2*pi/60/60/12
|
||||
push dword [HOURRX]
|
||||
push dword [HOURRY]
|
||||
push esi
|
||||
push edi
|
||||
call getHandCoords
|
||||
mov eax,MOS_SC_DRAWLINE
|
||||
shl ebx,16
|
||||
or ebx,esi
|
||||
shl ecx,16
|
||||
or ecx,edi
|
||||
mov edx,[wndColors + MOS_WNDCOLORS.workText]
|
||||
int 0x40
|
||||
pop edx
|
||||
|
||||
; draw tick marks
|
||||
mov dword [i],11 ; draw 12 marks
|
||||
.drawtickmarks:
|
||||
push dword [i] ; calculate start point
|
||||
fpush32 0.523598776 ; 2*pi/12
|
||||
push dword [TMR1X]
|
||||
push dword [TMR1Y]
|
||||
push esi
|
||||
push edi
|
||||
call getHandCoords
|
||||
mov eax,ebx ; save in eax and edx
|
||||
mov edx,ecx
|
||||
push dword [i]
|
||||
fpush32 0.523598776 ; 2*pi/12
|
||||
push dword [TMR2X]
|
||||
push dword [TMR2Y]
|
||||
push esi
|
||||
push edi
|
||||
call getHandCoords
|
||||
shl eax,16
|
||||
shl edx,16
|
||||
or ebx,eax ; ebx = x start and end
|
||||
or ecx,edx ; ecx = y start and end
|
||||
mov edx,[wndColors + MOS_WNDCOLORS.workText]
|
||||
mov eax,MOS_SC_DRAWLINE
|
||||
int 0x40
|
||||
dec dword [i]
|
||||
jns .drawtickmarks
|
||||
|
||||
%define DATE_WIDTH 48
|
||||
|
||||
; calculate text start position
|
||||
mov eax,[procInfo+MOS_PROCESSINFO.wndWidth]
|
||||
sub eax,DATE_WIDTH ; x = (wndwidth-textwidth)/2
|
||||
shr eax,1 ; eax = x
|
||||
fild dword [workheight] ; y = DATE_FACTOR*workheight...
|
||||
fmul dword [DATE_FACTOR]
|
||||
mov [foo],edi ; ... + y_clockcenter
|
||||
fiadd dword [foo]
|
||||
fistp dword [foo]
|
||||
mov ebx,[foo] ; ebx = y
|
||||
|
||||
; draw text at all ?
|
||||
cmp dword [workwidth],DATE_WIDTH ; text too wide ?
|
||||
jb .goodbye
|
||||
mov ecx,ebx ; text too high ?
|
||||
add ecx,10-1
|
||||
mov edx,[procInfo+MOS_PROCESSINFO.wndHeight]
|
||||
sub edx,MOS_WND_SKIN_BORDER_BOTTOM
|
||||
cmp ecx,edx
|
||||
jnae .yousuck
|
||||
.goodbye:
|
||||
jmp .bye
|
||||
.yousuck:
|
||||
|
||||
|
||||
; ebx = (x << 16) | y
|
||||
shl eax,16
|
||||
or ebx,eax
|
||||
|
||||
; get date (edi)
|
||||
mov eax,MOS_SC_GETDATE
|
||||
int 0x40
|
||||
mov edi,eax
|
||||
|
||||
; display month
|
||||
mov eax,edi ; get month
|
||||
shr eax,8
|
||||
call bcdbin
|
||||
; ebx contains already position
|
||||
mov ecx,[wndColors+MOS_WNDCOLORS.workText]
|
||||
lea edx,[monthNames-3+eax*2+eax]; -3 because eax = 1..12 =]
|
||||
mov esi,3 ; text length
|
||||
mov eax,MOS_SC_WRITETEXT
|
||||
int 0x40
|
||||
|
||||
; display date
|
||||
add ebx,MOS_DWORD(3*6+3,0)
|
||||
mov eax,edi ; get date
|
||||
shr eax,16
|
||||
call bcdbin
|
||||
mov edx,ebx ; position must be in edx
|
||||
mov ebx,0x00020000 ; number, display two digits
|
||||
mov ecx,eax ; number to display
|
||||
mov esi,[wndColors+MOS_WNDCOLORS.workText]
|
||||
mov eax,MOS_SC_WRITENUMBER
|
||||
int 0x40
|
||||
|
||||
; display year. the way we avoid the y2k bug is even
|
||||
; simpler, yet much better than in the last version:
|
||||
; now we simply display the last two digits and let the
|
||||
; user decide wether it's the year 1903 or 2003 =]
|
||||
add edx,MOS_DWORD(2*6+3,0)
|
||||
mov eax,edi ; get year
|
||||
call bcdbin
|
||||
mov ebx,0x00020000 ; number, display two digits
|
||||
mov ecx,eax ; number to display
|
||||
; edx contains already position
|
||||
mov esi,[wndColors+MOS_WNDCOLORS.workText]
|
||||
mov eax,MOS_SC_WRITENUMBER
|
||||
int 0x40
|
||||
|
||||
.byebye:
|
||||
popfd
|
||||
popad
|
||||
leave
|
||||
ret
|
||||
%pop
|
||||
|
||||
|
||||
;**********************************************************
|
||||
; bcdbin
|
||||
; converts a 8 bit bcd number into a 32 bit binary number
|
||||
;
|
||||
; in al = 8 bit bcd number
|
||||
; out eax = 32 bit binary number
|
||||
; destroys dl,flags
|
||||
;**********************************************************
|
||||
bcdbin:
|
||||
push edx
|
||||
pushfd
|
||||
mov dl,al ; save bcd number
|
||||
shr al,4 ; convert upper nibble
|
||||
mov ah,10
|
||||
mul ah
|
||||
and dl,15 ; add lower nibble
|
||||
add al,dl
|
||||
and eax,255 ; !
|
||||
popfd
|
||||
pop edx
|
||||
ret
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; getHandCoords
|
||||
; calculates the end point of a hand
|
||||
;
|
||||
; input (on stack, push from top to bottom):
|
||||
; ANGLE angle (integer)
|
||||
; DEG2RAD conversion factor for ANGLE (32 bit real)
|
||||
; RADIUSX x radius (32 bit real)
|
||||
; RADIUSY y radius (32 bit real)
|
||||
; CENTERX x center of the clock (integer)
|
||||
; CENTERY y center of the clock (integer)
|
||||
;
|
||||
; output:
|
||||
; ebx x coordinate in bits 0..15, bits 16..31 are zero
|
||||
; ecx y coordinate in bits 0..15, bits 16..31 are zero
|
||||
;
|
||||
; destroys:
|
||||
; nothing
|
||||
;********************************************************************
|
||||
getHandCoords:
|
||||
|
||||
ANGLE equ 28
|
||||
DEG2RAD equ 24
|
||||
RADIUSX equ 20
|
||||
RADIUSY equ 16
|
||||
CENTERX equ 12
|
||||
CENTERY equ 8
|
||||
|
||||
enter 0,0
|
||||
pushfd
|
||||
|
||||
fild dword [ebp+ANGLE] ; get angle
|
||||
fmul dword [ebp+DEG2RAD] ; convert to radians
|
||||
fsincos
|
||||
fmul dword [ebp+RADIUSY] ; -y * radius + clockcy
|
||||
fchs
|
||||
fiadd dword [ebp+CENTERY]
|
||||
fistp dword [ebp+CENTERY]
|
||||
fmul dword [ebp+RADIUSX] ; x * radius + clockcx
|
||||
fiadd dword [ebp+CENTERX]
|
||||
fistp dword [ebp+CENTERX]
|
||||
|
||||
mov ebx,[ebp+CENTERX]
|
||||
mov ecx,[ebp+CENTERY]
|
||||
|
||||
popfd
|
||||
leave
|
||||
ret 4*6
|
||||
|
||||
|
||||
%endif
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
@rem nasm -t -f bin -o aclock -l aclock.lst aclock.asm -DDEBUG
|
||||
nasm -t -f bin -o aclock aclock.asm
|
||||
@@ -0,0 +1,334 @@
|
||||
; mos.inc 0.03
|
||||
; 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 _MOS_INC
|
||||
%define _MOS_INC
|
||||
|
||||
|
||||
;**********************************************************
|
||||
; generates a menuetos 01 header
|
||||
; takes 6 parameters:
|
||||
;
|
||||
; MOS_HEADER01 start, end, appmem, esp, i_param, i_icon
|
||||
;**********************************************************
|
||||
|
||||
%macro MOS_HEADER01 6
|
||||
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 stuff
|
||||
;**********************************************************
|
||||
|
||||
; default window colors
|
||||
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
|
||||
|
||||
; skinned window borders
|
||||
MOS_WND_SKIN_BORDER_LEFT equ 5
|
||||
MOS_WND_SKIN_BORDER_RIGHT equ 5
|
||||
MOS_WND_SKIN_BORDER_BOTTOM equ 5
|
||||
|
||||
|
||||
;**********************************************************
|
||||
; process info structure
|
||||
;**********************************************************
|
||||
|
||||
struc MOS_PROCESSINFO
|
||||
.CPUUsage: resd 1
|
||||
.windowStackPos: resw 1
|
||||
.windowStackVal: resw 1
|
||||
.reserved1: resw 1
|
||||
.processName: resb 12
|
||||
.memStart: resd 1
|
||||
.memUsed: resd 1
|
||||
.pid: resd 1
|
||||
.wndXPos resd 1
|
||||
.wndYPos resd 1
|
||||
.wndWidth resd 1
|
||||
.wndHeight resd 1
|
||||
.reserved2: resb (1024 - 50)
|
||||
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 ; obsolete
|
||||
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 ; obsolete
|
||||
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 ; obsolete
|
||||
MOS_SC_STARTPROGRAMHD equ 31 ; obsolete
|
||||
MOS_SC_DELETEFILEFLOPPY equ 32
|
||||
MOS_SC_SAVEFILERAMDISK equ 33 ; obsolete
|
||||
MOS_SC_READDIRRAMDISK equ 34 ; obsolete
|
||||
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_GETIRQOWNER equ 41
|
||||
MOS_SC_GETDATAREADBYIRQ equ 42
|
||||
MOS_SC_SENDDATATODEVICE equ 43
|
||||
MOS_SC_PROGRAMIRQS equ 44
|
||||
MOS_SC_RESERVEFREEIRQ equ 45
|
||||
MOS_SC_RESERVEFREEPORTS equ 46
|
||||
MOS_SC_WRITENUMBER equ 47
|
||||
MOS_SC_WINDOWPROPERTIES equ 48
|
||||
MOS_SC_SHAPEDWINDOWS equ 50
|
||||
MOS_SC_CREATETHREAD equ 51
|
||||
MOS_SC_STACKDRIVERSTATE equ 52
|
||||
MOS_SC_SOCKETINTERFACE equ 53
|
||||
MOS_SC_SOUNDINTERFACE equ 55
|
||||
MOS_SC_WRITEFILEHD equ 56 ; obsolete
|
||||
MOS_SC_DELETEFILEHD equ 57
|
||||
MOS_SC_SYSTREEACCESS equ 58
|
||||
MOS_SC_SYSCALLTRACE equ 59
|
||||
MOS_SC_IPC equ 60
|
||||
MOS_SC_DIRECTGRAPHICS equ 61
|
||||
MOS_SC_PCI equ 62
|
||||
MOS_SC_DEBUGBOARD equ 63
|
||||
|
||||
|
||||
;**********************************************************
|
||||
; 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
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; opcode hacks
|
||||
;********************************************************************
|
||||
|
||||
; nasm refuses to assemble stuff like
|
||||
; push dword 4.44
|
||||
; with the following macro this becomes possible:
|
||||
; fpush32 9.81
|
||||
; don't forget to use a decimal point. things like
|
||||
; fpush32 1
|
||||
; will probably not do what you expect. instead, write:
|
||||
; fpush32 1.0
|
||||
%macro fpush32 1
|
||||
db 0x68 ; push imm32
|
||||
dd %1
|
||||
%endm
|
||||
|
||||
%endif
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
; string2dword - a useless string to double word conversion routine
|
||||
;
|
||||
; Copyright (c) 2003 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
|
||||
;
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; converts an asciiz string into an unsigned doubleword.
|
||||
; (base 10 is assumed)
|
||||
;
|
||||
; - first, leading whitespaces are skipped
|
||||
; - then the function converts the string, until it
|
||||
; finds the terminating zero, another character it
|
||||
; cannot convert or the number becomes too large.
|
||||
;
|
||||
; input : esi = pointer to string
|
||||
; output : eax = unsigned doubleword
|
||||
; the function tries to convert as
|
||||
; many digits as possible, before it
|
||||
; stops. if the value of the dword
|
||||
; becomes too large, 0xffffffff is
|
||||
; returned.
|
||||
; destroys : nothing
|
||||
;********************************************************************
|
||||
string2dword:
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push esi
|
||||
pushfd
|
||||
|
||||
xor ebx,ebx ; ebx : dword
|
||||
|
||||
; skip leading whitespaces
|
||||
.skipspaces:
|
||||
lodsb
|
||||
cmp al,32 ; space
|
||||
je .skipspaces
|
||||
cmp al,12 ; ff
|
||||
je .skipspaces
|
||||
cmp al,10 ; lf
|
||||
je .skipspaces
|
||||
cmp al,13 ; cr
|
||||
je .skipspaces
|
||||
cmp al,9 ; ht
|
||||
je .skipspaces
|
||||
cmp al,11 ; vt
|
||||
je .skipspaces
|
||||
|
||||
; convert string
|
||||
dec esi ; esi -> 1st non-whitespace
|
||||
.convert:
|
||||
xor eax,eax ; get character
|
||||
lodsb
|
||||
sub al,'0' ; convert to digit
|
||||
cmp al,9 ; is digit in range [0,9] ?
|
||||
ja .done ; nope -> stop conversion
|
||||
mov ecx,eax ; save new digit
|
||||
mov eax,10 ; dword = dword * 10
|
||||
mul ebx
|
||||
jc .overflow
|
||||
add eax,ecx ; + new digit
|
||||
jc .overflow
|
||||
mov ebx,eax
|
||||
jmp .convert
|
||||
|
||||
.overflow:
|
||||
mov ebx,0xffffffff
|
||||
.done:
|
||||
mov eax,ebx
|
||||
popfd
|
||||
pop esi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
; strlen function
|
||||
;
|
||||
; Copyright (c) 2003 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 _STRLEN_INC
|
||||
%define _STRLEN_INC
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; returns the length of an asciiz string
|
||||
; input : esi = pointer to string
|
||||
; output : eax = string length
|
||||
; destroys : nothing
|
||||
;********************************************************************
|
||||
strlen:
|
||||
push ecx
|
||||
push edi
|
||||
pushfd
|
||||
cld ; !
|
||||
mov ecx,-1
|
||||
mov edi,esi ; find terminating zero
|
||||
xor al,al
|
||||
repne scasb
|
||||
mov eax,edi ; calculate string length
|
||||
sub eax,esi
|
||||
dec eax
|
||||
popfd
|
||||
pop edi
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
|
||||
%endif
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
; some strtok-like function
|
||||
;
|
||||
; Copyright (c) 2003 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 _STRTOK_INC
|
||||
%define _STRTOK_INC
|
||||
|
||||
|
||||
;********************************************************************
|
||||
; strtok
|
||||
; this function works like strtok from a c runtime library.
|
||||
; note that it is not threadsafe. it would be an easy task
|
||||
; to make it threadsafe, though:
|
||||
; .adx must be removed, instead the last search address is
|
||||
; stored at some location provided by the user (passed as
|
||||
; a third parameter in ecx or so)
|
||||
;
|
||||
; input:
|
||||
;
|
||||
; eax : address of string to be searched (asciiz), or
|
||||
; 0 to get the next token of the current string
|
||||
; ebx : address of delimiter list (asciiz)
|
||||
;
|
||||
; output:
|
||||
;
|
||||
; eax : pointer to the next token, or 0 if there
|
||||
; aren't any tokens anymore.
|
||||
;
|
||||
; destroys: nothing
|
||||
;
|
||||
;********************************************************************
|
||||
strtok:
|
||||
pushad
|
||||
pushfd
|
||||
|
||||
; get start address
|
||||
; if the new start address is 0, and the old address (.adx)
|
||||
; is also 0, then there's nothing to do and we return 0.
|
||||
or eax,eax ; new address = 0 ?
|
||||
jz .nonewstring ; nope -> use old string
|
||||
mov [.adx],eax ; yeah -> store new string adx
|
||||
.nonewstring:
|
||||
mov esi,[.adx] ; load string address
|
||||
or esi,esi ; 0 ?
|
||||
jnz .startadxok ; nope -> ok
|
||||
xor eax,eax ; yeah -> return 0
|
||||
je .bye
|
||||
.startadxok:
|
||||
|
||||
; skip leading delimiters
|
||||
.skipdelimiters:
|
||||
lodsb ; read character
|
||||
mov edi,ebx ; edi -> delimiter list
|
||||
.foo:
|
||||
mov cl,[edi] ; get delimiter
|
||||
inc edi
|
||||
or cl,cl ; end of delimiter list
|
||||
jz .endofdelimiterlist
|
||||
cmp al,cl ; if AL is a delimiter, then
|
||||
je .skipdelimiters ; we need to skip it too...
|
||||
jmp .foo ; otherwise try next delimiter
|
||||
.endofdelimiterlist:
|
||||
|
||||
; end of string reached without finding any non-delimiters ?
|
||||
or al,al ; character = 0 ?
|
||||
jnz .bar ; nope -> continue
|
||||
mov dword [.adx],0 ; yeah -> remember this
|
||||
xor eax,eax ; and return 0
|
||||
jmp .bye
|
||||
.bar:
|
||||
|
||||
; found the start of a token, let's store its address
|
||||
mov edx,esi
|
||||
dec edx ; edx = start address of token
|
||||
|
||||
; find the end of the token
|
||||
.abraham:
|
||||
lodsb ; get character
|
||||
mov edi,ebx ; edi -> delimiter list
|
||||
.bebraham:
|
||||
mov cl,[edi] ; get delimiter
|
||||
inc edi
|
||||
cmp al,cl ; is AL a delimiter ?
|
||||
jne .cebraham ; nope -> continue
|
||||
or al,al ; terminating zero found ?
|
||||
jnz .argle
|
||||
xor esi,esi ; yeah -> remember this
|
||||
jmp .bargle
|
||||
.argle:
|
||||
mov byte [esi-1],0 ; nope -> mark end of token
|
||||
.bargle:
|
||||
mov [.adx],esi ; remember search address
|
||||
mov eax,edx ; return token address
|
||||
jmp .bye
|
||||
.cebraham:
|
||||
or cl,cl ; end of delimiter list ?
|
||||
jnz .bebraham ; nope -> try next delimiter
|
||||
jmp .abraham
|
||||
|
||||
; write return value into stack, so that when popad
|
||||
; gets executed, eax will receive the return value.
|
||||
.bye:
|
||||
mov [esp+4*8],eax
|
||||
popfd
|
||||
popad
|
||||
ret
|
||||
.adx dd 0
|
||||
|
||||
%endif
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm airc.asm airc
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm airc.asm airc
|
||||
@pause
|
||||
@@ -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
|
||||
@@ -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:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
File diff suppressed because it is too large.
Load diff
@@ -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
|
||||
@@ -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:
|
||||
}
|
||||
;---------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm arcanii.asm arcanii
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm arcanii.asm arcanii
|
||||
@pause
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
@@ -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:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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:
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm arcanoid.asm arcanoid
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm arcanoid.asm arcanoid
|
||||
@pause
|
||||
@@ -0,0 +1,424 @@
|
||||
; @RCHER - DEflate unpacker v1.0
|
||||
;
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
;
|
||||
; Created: May 6, 2005
|
||||
;
|
||||
; Last changed: July 14, 2005
|
||||
;
|
||||
; Compile with FASM
|
||||
|
||||
|
||||
SYS equ meos
|
||||
PARAM_PTR equ png_image
|
||||
DUMPFILE equ '/hd/1/out.txt'
|
||||
|
||||
SHOW_RBLOCK equ 0;1
|
||||
SHOW_PNG_SEC equ 0;1
|
||||
SHOW_METH equ 0;1
|
||||
FILE_NUM equ 0
|
||||
MEMORY equ 0x800000
|
||||
|
||||
BITS equ 16
|
||||
BUFSIZE equ 32
|
||||
BUFPTR equ area
|
||||
|
||||
PASSW_LEN equ 32
|
||||
NO_STOPS equ 1
|
||||
SHOW_CHARS equ 0
|
||||
BSIZE equ 512
|
||||
INBUF equ BUFSIZE*BSIZE*2
|
||||
OUTBUF equ 4*1024*1024
|
||||
IGNORE_DIRS equ 0
|
||||
|
||||
MOVE_SLINE_LEV equ 8
|
||||
|
||||
DECRYPT_MODE equ 100b
|
||||
PNG_MODE equ 10b
|
||||
TAR_MODE equ 1000b
|
||||
STAY_MODE equ 10000b
|
||||
IPC_MODE equ 100000b
|
||||
RAW_MODE equ 1000000b
|
||||
THREAD_YES equ 10000000b
|
||||
|
||||
if SYS eq win
|
||||
format PE console
|
||||
entry start
|
||||
;match =win,SYS
|
||||
;{
|
||||
; include 'D:\Ivushkin\projects\fasmw\INCLUDE\win32a.inc'
|
||||
;}
|
||||
else
|
||||
use32
|
||||
|
||||
org 0x0
|
||||
|
||||
db 'MENUET01'
|
||||
dd 0x01
|
||||
dd start
|
||||
dd I_END
|
||||
dd MEMORY
|
||||
dd MEMORY-2048
|
||||
if PARAM_PTR eq param
|
||||
dd 0
|
||||
else
|
||||
dd PARAM_PTR
|
||||
end if
|
||||
dd 0x0
|
||||
include "lang.inc"
|
||||
|
||||
if PARAM_PTR eq param
|
||||
param db 'RQ'
|
||||
db '000037'
|
||||
db '/hd/1/zip/png.zip',0
|
||||
end if
|
||||
;match =meos,SYS
|
||||
;{
|
||||
include "macros.inc"
|
||||
; purge mov
|
||||
include "debug.inc"
|
||||
;}
|
||||
end if
|
||||
|
||||
language equ en
|
||||
|
||||
if SYS eq win
|
||||
section '.text' code readable executable writeable
|
||||
end if
|
||||
include "arcmacro.inc"
|
||||
include "parser.inc"
|
||||
include "deflate.inc"
|
||||
include "sys.inc"
|
||||
|
||||
FileNum dd FILE_NUM
|
||||
;FNAME equ '/hd/1/zip/pngsuite/s01n3p01.png'
|
||||
|
||||
start:
|
||||
if SYS eq win
|
||||
invoke GetStdHandle, STD_OUTPUT_HANDLE
|
||||
mov [cons],eax
|
||||
invoke GetStdHandle, STD_INPUT_HANDLE
|
||||
mov [cons_in],eax
|
||||
Msg 0
|
||||
Msg 1
|
||||
else
|
||||
Msg 0
|
||||
Msg 1
|
||||
mcall 40,10000101b
|
||||
; jmp again
|
||||
CmdLine
|
||||
red:
|
||||
call draw_window
|
||||
mcall 12,2
|
||||
|
||||
still:
|
||||
mcall 10
|
||||
cmp eax,1
|
||||
je red
|
||||
cmp eax,2
|
||||
jne .nokey
|
||||
mcall 2
|
||||
cmp ah,9
|
||||
jz quit
|
||||
jmp still
|
||||
.nokey:
|
||||
cmp eax,3
|
||||
jne still
|
||||
mcall 17
|
||||
cmp ah,1
|
||||
jne still
|
||||
mcall 23,30
|
||||
cmp eax,3
|
||||
jne .noquit
|
||||
call KillViewer
|
||||
mcall -1
|
||||
.noquit:
|
||||
mcall 17
|
||||
QueryFile
|
||||
and [FileNum],0
|
||||
test eax,eax
|
||||
jnz still
|
||||
end if
|
||||
again:
|
||||
Newline
|
||||
xor eax,eax
|
||||
; and [Flags],STAY_MODE
|
||||
and [CRC32],eax
|
||||
and [IDATsize],eax
|
||||
mov [Adler32],1
|
||||
call OpenFile
|
||||
test ebx,ebx
|
||||
jnz .sizeok2
|
||||
.sizebad2:
|
||||
Msg 14
|
||||
jmp quit
|
||||
.sizeok2:
|
||||
mov [filesize],ebx
|
||||
test [Flags],RAW_MODE
|
||||
jz .norawm
|
||||
mov eax,[arc_base]
|
||||
xor ebx,ebx
|
||||
call FileSeek
|
||||
jmp .sizeok
|
||||
.norawm:
|
||||
call SfxParse
|
||||
|
||||
call ZipParse
|
||||
cmp edx,52
|
||||
je .notzip
|
||||
mov ecx,[FileNum]
|
||||
call ZipFindN
|
||||
cmp edx,4
|
||||
je quit
|
||||
test [Flags],DECRYPT_MODE
|
||||
jz .nopass
|
||||
call ZipDecrypt
|
||||
push esi
|
||||
mov ecx,31
|
||||
._:
|
||||
mov al,[esi]
|
||||
push eax
|
||||
call decrypt_byte
|
||||
xor al,byte[esp]
|
||||
add esp,4
|
||||
call UKeys
|
||||
mov [esi],al
|
||||
inc esi
|
||||
loop ._
|
||||
pop esi
|
||||
ud2
|
||||
.nopass:
|
||||
cmp [unp_size],0
|
||||
jne .sizeok
|
||||
.sizebadq:
|
||||
Msg 13
|
||||
jmp quit
|
||||
.notzip:
|
||||
call GzipParse
|
||||
test edx,edx
|
||||
jne .notgzip
|
||||
jmp .sizeok
|
||||
.notgzip:
|
||||
call PngParse
|
||||
test edx,edx
|
||||
jz .sizeok1
|
||||
cmp edx,21
|
||||
je .sizebad
|
||||
test [Flags],RAW_MODE
|
||||
jne .sizeok
|
||||
Msg 40
|
||||
jmp exit
|
||||
.sizebad:
|
||||
Msg 17
|
||||
jmp exit
|
||||
.sizeok1:
|
||||
if ~ SYS eq win
|
||||
call KillViewer
|
||||
end if
|
||||
Msg 39
|
||||
mov edi,[outp]
|
||||
call Deflate.blkbegin
|
||||
jmp .defl_end
|
||||
.sizeok:
|
||||
call Deflate ; <===========
|
||||
.defl_end:
|
||||
test [bits],7
|
||||
jnz .esi_ok
|
||||
dec esi
|
||||
.esi_ok:
|
||||
push dword[esi] ; <- Adler !!!
|
||||
mov esi,output
|
||||
sub edi,esi
|
||||
mov ecx,edi
|
||||
mov [outfile.size],ecx
|
||||
test [Flags],RAW_MODE
|
||||
jnz .skipAdler
|
||||
test [Flags],PNG_MODE
|
||||
jnz .skipCRC
|
||||
push esi ecx
|
||||
call UCRC
|
||||
Msg 11
|
||||
mov eax,[CRC32]
|
||||
mov edx,36
|
||||
cmp eax,[CRC_check]
|
||||
je .crcok
|
||||
dec edx
|
||||
.crcok:
|
||||
Msg edx
|
||||
if SYS eq win
|
||||
else
|
||||
dph eax
|
||||
end if
|
||||
pop ecx esi
|
||||
jmp .skipAdler
|
||||
.skipCRC:
|
||||
call UAdler
|
||||
Msg 10
|
||||
mov eax,[Adler32]
|
||||
bswap eax ; <- calculated Adler !!!
|
||||
mov edx,36
|
||||
cmp eax,[esp]
|
||||
je .adlok
|
||||
dec edx
|
||||
.adlok:
|
||||
Msg edx
|
||||
if SYS eq win
|
||||
else
|
||||
dph eax
|
||||
end if
|
||||
.skipAdler:
|
||||
pop eax
|
||||
Newline
|
||||
.nomoreIDAT:
|
||||
mov ebx,output
|
||||
if SYS eq win
|
||||
Msg 37
|
||||
invoke CloseHandle, [hnd]
|
||||
|
||||
invoke CreateFile,dumpfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
|
||||
mov [hnd],eax
|
||||
invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
|
||||
invoke CloseHandle, [hnd]
|
||||
else
|
||||
test [Flags],PNG_MODE
|
||||
jnz .nosave
|
||||
test [Flags],TAR_MODE
|
||||
jnz .nomsg
|
||||
Msg 37
|
||||
.nomsg:
|
||||
mov [outfile.out],ebx
|
||||
mcall 58,outfile
|
||||
test [Flags],TAR_MODE
|
||||
jnz .nosave
|
||||
call StartPad
|
||||
.nosave:
|
||||
end if
|
||||
test [Flags],PNG_MODE
|
||||
jz NoPng
|
||||
xor eax,eax
|
||||
mov edi,filters
|
||||
mov ecx,6
|
||||
rep stosd
|
||||
mov edi,png_image
|
||||
mov esi,output
|
||||
;//
|
||||
mov [outp],edi
|
||||
;//
|
||||
call PngFilter
|
||||
call FiltStats
|
||||
mov [outfile.size],edi
|
||||
mov ebx,[outp];png_image
|
||||
if SYS eq win
|
||||
exit:
|
||||
Msg 12
|
||||
invoke CreateFile,outfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
|
||||
mov [hnd],eax
|
||||
invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
|
||||
invoke CloseHandle, [hnd]
|
||||
call RunViewer
|
||||
and [arc_base],0
|
||||
and [Flags],STAY_MODE
|
||||
|
||||
quit:
|
||||
QueryFile
|
||||
test eax,eax
|
||||
jnz again
|
||||
invoke ExitProcess,0
|
||||
else
|
||||
exit:
|
||||
mov [outfile.out],ebx
|
||||
test [Flags],TAR_MODE
|
||||
jz .notar
|
||||
Msg 37
|
||||
mcall 58,outfile
|
||||
call StartPad
|
||||
.notar:
|
||||
Msg 12
|
||||
call RunViewer
|
||||
and [arc_base],0
|
||||
and [Flags],STAY_MODE
|
||||
quit:
|
||||
test [Flags],STAY_MODE
|
||||
jnz red
|
||||
mcall -1
|
||||
end if
|
||||
|
||||
NoPng:
|
||||
test [Flags],TAR_MODE
|
||||
if SYS eq win
|
||||
jz quit
|
||||
else
|
||||
jz still
|
||||
end if
|
||||
mov ecx,dumpf_len
|
||||
mov esi,dumpfile
|
||||
mov edi,filename
|
||||
rep movsb
|
||||
call OpenFile
|
||||
test ebx,ebx
|
||||
jz again.sizebadq
|
||||
call TarParse
|
||||
mov ecx,[FileNum]
|
||||
call TarFindN
|
||||
cmp [outfile.size],0
|
||||
jz again.sizebadq
|
||||
mov ebx,esi
|
||||
jmp exit
|
||||
|
||||
if ~ SYS eq win
|
||||
draw_window:
|
||||
mcall 12,1
|
||||
mov ebx,15
|
||||
mov ecx,ebx
|
||||
mov edx,0x0e26830
|
||||
mov edi,edx
|
||||
mcall 0,,,,0x1f2a870
|
||||
mcall 8,,,1+1 shl 30
|
||||
mcall 4,<6,5>,0x10d0d0d0,msgs+5,1
|
||||
mcall ,<5,5>,0x10202020
|
||||
ret
|
||||
end if
|
||||
|
||||
include 'data.inc'
|
||||
|
||||
if SYS eq win
|
||||
section '.idata' import data readable writeable
|
||||
|
||||
library kernel,'KERNEL32.DLL',\
|
||||
comdlg,'COMDLG32.DLL',\
|
||||
user,'USER32.DLL'
|
||||
|
||||
import kernel,\
|
||||
CreateFile,'CreateFileA',\
|
||||
GetFileSize,'GetFileSize',\
|
||||
ReadFile,'ReadFile',\
|
||||
WriteFile,'WriteFile',\
|
||||
SetFilePointer,'SetFilePointer',\
|
||||
CloseHandle,'CloseHandle',\
|
||||
GetStdHandle,'GetStdHandle',\
|
||||
WriteConsole,'WriteConsoleA',\
|
||||
ReadConsole,'ReadConsoleA',\
|
||||
CreateProcess,'CreateProcessA',\
|
||||
WritePrivateProfileString,'WritePrivateProfileStringA',\
|
||||
ExitProcess,'ExitProcess'
|
||||
|
||||
import comdlg,\
|
||||
GetOpenFileName,'GetOpenFileNameA'
|
||||
|
||||
import user,\
|
||||
wsprintf,'wsprintfA',\
|
||||
SendMessage,'SendMessageA',\
|
||||
FindWindowEx,'FindWindowExA',\
|
||||
WaitForInputIdle,'WaitForInputIdle'
|
||||
|
||||
|
||||
section '.reloc' fixups data readable discardable
|
||||
end if
|
||||
|
||||
if ~ SYS in <meos,win>
|
||||
error "Please specify SYS: meos OR win"
|
||||
end if
|
||||
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
@RCHER FOR MENUET v1.0 July 14, 2005
|
||||
Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
|
||||
Deflate unpacker
|
||||
|
||||
Vivat assembler et MENUETOS!
|
||||
I tender thanks to everyone who spends his time in feasible effortsfor that
|
||||
little OS evolution. Now in my own rating the Mario79's distro named Kolibri4
|
||||
takes 1th place. It is always pleasant to use modern software. Go on!
|
||||
|
||||
@RCHER is intended to view & unpack data compressed by Deflate method
|
||||
(including both static and dynamic Huffman). This method (although it isn't the
|
||||
best already) is used by such file formats as ZIP (modern versions: PKZIP for
|
||||
MS-DOS can create archives using other, less effective compression methods,
|
||||
which @RCHER doesn't support), GZIP, JAR, OpenOffice files, SFX ZIP executables
|
||||
and some others. I couldn't prevent myself to include support of PNG images
|
||||
(they use the similar compression) and TAR and TAR+GZIP archives.
|
||||
|
||||
When the program is started, a little button carrying a @ symbol appears in the
|
||||
left top corner of screen. Clicking this button opens a SYSXTREE dialog to
|
||||
select a file being unpacked. Doubleclick closes the application. @RCHER
|
||||
outputs its information messages to Debug Board. If an archive contains more
|
||||
than one file, the 1st is by default unpacked into /HD/1/OUT.TXT (you may
|
||||
change the DUMPFILE constant in @RCHER.ASM) and is opened through TINYPAD
|
||||
or - if it's a PNG image - in the built-in viewer.
|
||||
|
||||
These are unpacking flags that may exist in a commandline before an archive
|
||||
filename:
|
||||
|
||||
s - do not close the program after unpacking;
|
||||
n - decompress the K-th archive file, where K is the following dword in
|
||||
commandline;
|
||||
N - decompress the K-th archive file, where K is ASCII number from the
|
||||
following 6 bytes of commandline;
|
||||
R - "raw" Deflate data, without descriptors and headers;
|
||||
q - begin file parsing from offset of K, where K is following dword in
|
||||
commandline;
|
||||
Q - begin file parsing from offset of K, where K is ASCII number from the
|
||||
following 6 bytes of commandline.
|
||||
|
||||
Commandline example:
|
||||
|
||||
cmd_string:
|
||||
db 'sN000037q'
|
||||
dd 1465
|
||||
db '/hd/1/png.zip',0
|
||||
|
||||
It means to open the 34th (counting from 0) file of archive /hd/1/png.zip
|
||||
and do not terminate. Archive will be parsed starting at offset 1465.
|
||||
|
||||
|
||||
To-Do list:
|
||||
|
||||
1. Support for interlaced PNG, alpha-channels, gamma-correction, background,
|
||||
Significant bits and a lot of cool parts of that format.
|
||||
2. Output of archive content through IPC or into a built-in window like SYSTREE
|
||||
(as we are going to decide with the respected colleagues).
|
||||
3. Searching of archive files by name and wildcards!
|
||||
4. Unpacking into a file specified.
|
||||
5. Means on saving memory space (now @RCHER gorges 8 Mb!): moving RAM areas,
|
||||
blocked file output. To do the last thing it is necessary to test carefully
|
||||
the reliability of harddisk I/O, directory creation and file deletion. These
|
||||
kernel capabilities aren't still documented.
|
||||
6. Archive contents integration into SYSXTREE & MFAR filemanagers. We have to
|
||||
unify the calling format (like a structure in the sysfunc 58).
|
||||
7. Add comments to source.
|
||||
8. Correct bugs to be found
|
||||
|
||||
Special thanks to:
|
||||
|
||||
Explanation of algorythm of Deflate format decoder with decoding samples
|
||||
(evm.narod.ru)
|
||||
RFC 1951 DEFLATE Compressed Data Format Specification version 1.3
|
||||
ZIP File Format Specification version 4.5 by PKWARE Inc.
|
||||
"An Explanation of the Deflate Algorithm" by Antaeus Feldspar
|
||||
RFC 1952 GZIP file format specification version 4.3
|
||||
TAR Format. Information from File Format List 2.0 by Max Maischein.
|
||||
RFC 1950 ZLIB Compressed Data Format Specification version 3.3
|
||||
PNG (Portable Network Graphics) Specification version 1.0
|
||||
Michael Dipperstein's Huffman Code Page
|
||||
|
||||
I expect your remarks and suggestions on the @RCHER's topic, "Coding" section
|
||||
at meos.sysbin.com forum.
|
||||
|
||||
See you later!
|
||||
|
||||
|
||||
****************************************
|
||||
****************************************
|
||||
|
||||
@RCHER ДЛЯ MENUET v1.0 14 июля 2005 г.
|
||||
Написана на чистом ассемблере Ивушкиным Андреем (Willow)
|
||||
|
||||
Deflate распаковщик
|
||||
|
||||
Vivat assembler et MenuetOS!
|
||||
Выражаю искреннюю благодарность всем тем, кто не жалея своего времени,
|
||||
делает посильный вклад в развитие этой маленькой ОС. Сейчас в моем собственном
|
||||
рейтинге 1-е место занимает дистрибутив Mario79 Kolibri4. Всегда приятно
|
||||
пользоваться современным ПО. Так держать!
|
||||
|
||||
@RCHER предназначен для просмотра и распаковки данных, сжатых с помощью метода
|
||||
Deflate (включая статический и динамический Хаффман). Данным методом (хотя он
|
||||
уже не претендует на звание наилучшего) пользуются форматы файлов ZIP
|
||||
(современные версии: PKZIP для MS-DOS может создавать архивы с другими, менее
|
||||
эффективными методами сжатия, которые @RCHER не поддерживает), GZIP, JAR,
|
||||
файлы OpenOffice, SFX-ZIP приложения и ряд других. Я не мог удержаться и не
|
||||
сделать поддержку изображений в формате PNG (использующих родственный метод
|
||||
сжатия) и архивов TAR и TAR+GZIP.
|
||||
|
||||
При запуске программы в левом верхнем углу экрана появляется маленькая кнопка
|
||||
со значком @. При нажатии на нее открывается окно выбора файла (SYSXTREE) для
|
||||
распаковки. Двойной щелчок закрывает приложение. Информационные сообщения
|
||||
@RCHER выводит на доску отладки. Если архив содержит несколько файлов, по
|
||||
умолчанию первый из них распаковывается на /HD/1/OUT.TXT (поменяйте при
|
||||
необходимости константу DUMPFILE в @RCHER.ASM) и открывается через TINYPAD
|
||||
или - в случае картинки PNG - в окне встроенного просмотрщика.
|
||||
|
||||
В командной строке перед именем архива могут в произвольном порядке указываться
|
||||
флаги распаковки:
|
||||
|
||||
s - не закрывать программу после распаковки;
|
||||
n - распаковать K-й файл архива, где K - следующий dword в командной строке;
|
||||
N - распаковать K-й файл архива, где K - ASCII число из следующих 6 байт
|
||||
командной строки;
|
||||
R - "сырые" Deflate-данные, без описателей и заголовков;
|
||||
q - просмотр файла начать со смещения K, где K - следующий dword в командной
|
||||
строке;
|
||||
Q - просмотр файла начать со смещения K, где K - ASCII число из следующих 6
|
||||
байт командной строки.
|
||||
|
||||
Пример командной строки:
|
||||
|
||||
cmd_string:
|
||||
db 'sN000037q'
|
||||
dd 1465
|
||||
db '/hd/1/png.zip',0
|
||||
|
||||
Это означает, что следует открыть 34-й (считая от 0) файл архива /hd/1/png.zip
|
||||
и не завершать работу. Просмотр архива начнется со смещения 1465.
|
||||
|
||||
|
||||
Что еще нужно сделать:
|
||||
|
||||
1. Поддержка чересстрочных (interlaced) PNG, а также альфа-каналов, гаммы,
|
||||
фона, Significant bits и кучи других примочек этого формата.
|
||||
2. Вывод содержимого архивов через IPC или во встроенном окне наподобие SYSTREE
|
||||
(это как решим с уважаемыми коллегами).
|
||||
3. Поиск файлов в архиве по имени и даже маске!
|
||||
4. Распаковка в указанный файл.
|
||||
5. Мероприятия по экономии памяти (сейчас @RCHER жрет 8 Мб!): перемещение
|
||||
участков памяти, блочный вывод в файл. Для последнего необходимо тщательно
|
||||
протестировать надежность воода-вывода на ЖД, создания каталогов и удаления
|
||||
файлов. Пока эти возможности ядра не документированы.
|
||||
6. Интеграция архивных каталогов в файловые менеджеры SYSXTREE, MFAR.
|
||||
Потребуется унифицировать формат вызова (наподобие структуры в 58 функции).
|
||||
7. Откомментировать код.
|
||||
8. Исправить баги, которые, несомненно, найдутся ;-)
|
||||
|
||||
Особые благодарности:
|
||||
|
||||
Описание алгоритма декодера формата Deflate на примерах декодирования
|
||||
(evm.narod.ru)
|
||||
RFC 1951 DEFLATE Compressed Data Format Specification version 1.3
|
||||
ZIP File Format Specification version 4.5 by PKWARE Inc.
|
||||
"An Explanation of the Deflate Algorithm" by Antaeus Feldspar
|
||||
RFC 1952 GZIP file format specification version 4.3
|
||||
TAR Format. Information from File Format List 2.0 by Max Maischein.
|
||||
RFC 1950 ZLIB Compressed Data Format Specification version 3.3
|
||||
PNG (Portable Network Graphics) Specification version 1.0
|
||||
Michael Dipperstein's Huffman Code Page
|
||||
|
||||
Жду ваших замечаний и предложений на одноименной ветке раздела "Кодинг" форума
|
||||
meos.sysbin.com
|
||||
|
||||
До новых встреч!
|
||||
@@ -0,0 +1,440 @@
|
||||
; @RCHER macros and messages
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
|
||||
macro stop
|
||||
{
|
||||
if SYS eq win & NO_STOPS eq 0
|
||||
int3
|
||||
end if
|
||||
}
|
||||
|
||||
macro wait
|
||||
{
|
||||
if ~ SYS eq win
|
||||
local .nodrw,.ex
|
||||
pusha
|
||||
mcall 10
|
||||
cmp eax,1
|
||||
jne .nodrw
|
||||
call draw_window
|
||||
.nodrw:
|
||||
mcall 17
|
||||
.ex:
|
||||
popa
|
||||
end if
|
||||
}
|
||||
|
||||
macro rbits dest,cnt
|
||||
{
|
||||
if ~ cnt eq
|
||||
mov ecx,cnt
|
||||
end if
|
||||
if dest eq 0
|
||||
xor eax,eax
|
||||
else
|
||||
mov eax,dest
|
||||
end if
|
||||
call read_bits
|
||||
}
|
||||
|
||||
|
||||
macro rep_err cond_ok, result, msg
|
||||
{
|
||||
local .m
|
||||
j#cond_ok .m
|
||||
if ~ msg eq
|
||||
Msg msg
|
||||
end if
|
||||
mov edx,result
|
||||
jmp .err
|
||||
.m:
|
||||
}
|
||||
|
||||
macro memcpy_esi dest, count,_add
|
||||
{
|
||||
push esi
|
||||
if ~ _add eq
|
||||
add esi,_add
|
||||
end if
|
||||
mov edi,dest
|
||||
mov ecx,count
|
||||
rep movsb
|
||||
pop esi
|
||||
}
|
||||
|
||||
DebugPrint:
|
||||
; in: edx-asciiz string ptr
|
||||
pusha
|
||||
if SYS eq win
|
||||
mov ecx,255
|
||||
xor eax,eax
|
||||
mov edi,edx
|
||||
repne scasb
|
||||
sub edi,edx
|
||||
dec edi
|
||||
invoke WriteConsole,[cons],edx,edi,cparam1,NULL
|
||||
else
|
||||
call debug_outstr
|
||||
end if
|
||||
popa
|
||||
ret
|
||||
|
||||
macro DebugPrintDec
|
||||
{
|
||||
if SYS eq win
|
||||
call int2str
|
||||
mov edx,os_work
|
||||
call DebugPrint
|
||||
else
|
||||
call debug_outdec
|
||||
end if
|
||||
}
|
||||
|
||||
macro Newline
|
||||
{
|
||||
if SYS eq win
|
||||
pusha
|
||||
invoke WriteConsole,[cons],cr_lf,2,cparam1,NULL
|
||||
popa
|
||||
else
|
||||
newline
|
||||
end if
|
||||
}
|
||||
|
||||
Msgcall:
|
||||
; edx - msg number
|
||||
pusha
|
||||
movzx edx,word[strs+edx*2]
|
||||
add edx,msgs
|
||||
call DebugPrint
|
||||
popa
|
||||
ret
|
||||
|
||||
macro Msg num
|
||||
{
|
||||
if ~ num eq edx
|
||||
mov edx,num
|
||||
end if
|
||||
call Msgcall
|
||||
}
|
||||
|
||||
MSG_COUNT=0
|
||||
macro str_table [str]
|
||||
{
|
||||
forward
|
||||
local label
|
||||
dw label-msgs
|
||||
common
|
||||
msgs:
|
||||
forward
|
||||
label db str,0
|
||||
MSG_COUNT=MSG_COUNT+1
|
||||
}
|
||||
|
||||
|
||||
|
||||
strs:
|
||||
if language eq ru
|
||||
str_table \
|
||||
<'*** @RCHER - Deflate Unpacker ***',13,10>,\ ;0
|
||||
<'*** Copyright Wiland Inc., 2005 ***',13,10>,\ ;1
|
||||
'Файлов в архиве: ',\ ;2
|
||||
<'End of Directory достигнут',13,10>,\ ;3
|
||||
'Нет файла с таким номером',\ ;4
|
||||
<'FindByNumber ОК',13,10>,\ ;5
|
||||
<'Неверный ID блока Хаффмана',13,10>,\ ;6
|
||||
<'Ошибка в кодах Хаффмана!',13,10>,\ ;7
|
||||
<13,10,'Расчет таблицы CRC32',13,10>,\ ;8
|
||||
'.',\ ;9
|
||||
'Adler32',\ ;10
|
||||
'CRC32',\ ;11
|
||||
<'Завершено.',13,10>,\ ;12
|
||||
<'Файл имеет нулевую длину, распаковка отменена.',13,10>,\ ;13
|
||||
<'Странная длина файла-источника. Ошибка в имени? Отмена.',13,10>,\ ;14
|
||||
<'Не GZIP архив',13,10>,\ ;15
|
||||
<'Слишком большой размер выходного файла',13,10>,\ ;16
|
||||
<"Ошибка при распаковке.",13,10>,\ ; 17
|
||||
<'Не рисунок PNG',13,10>,\ ; 18
|
||||
<13,10,'*д'>,\ ;19
|
||||
<13,10,'*с'>,\ ;20
|
||||
'Неожиданный конец блоков IDAT',\ ;21
|
||||
'Дефильтрация:',\ ;22
|
||||
'Фильтры: None ',\ ;23
|
||||
' Sub ',\ ;24
|
||||
' Up ',\ ;25
|
||||
' Avg ',\ ;26
|
||||
' Paeth ',\ ;27
|
||||
' Ошибок: ',\ ;28
|
||||
<'Чересстрочный PNG',13,10>,\ ;29
|
||||
<'Блок без сжатия',13,10>,\ ;30
|
||||
<'Тип цвета не поддерживается',13,10>,\ ;31
|
||||
<'Введите пароль для зашифрованного файла:',13,10>,\ ;32
|
||||
<'Поиск файла...',13,10>,\ ;33
|
||||
'Не модуль SFX',\ ;34
|
||||
' неверна! ',\ ;35
|
||||
' OK: ',\ ;36
|
||||
<'Запись OUT.TXT',13,10>,\ ;37
|
||||
' ',\ ;38
|
||||
<'Подготовка изображения...',13,10>,\ ;39
|
||||
<'Укажите "R" для обработки сырых данных. Отмена.',13,10>,\ ;40
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' <- неизвестный метод сжатия',\ ;50
|
||||
' <- зашифрован',\ ;51
|
||||
<'Не ZIP архив',13,10> ; 52
|
||||
else
|
||||
str_table \
|
||||
<'*** @RCHER - Deflate Unpacker ***',13,10>,\ ;0
|
||||
<'*** Copyright Wiland Inc., 2005 ***',13,10>,\ ;1
|
||||
'Files in archive: ',\ ;2
|
||||
<'End of Directory reached',13,10>,\ ;3
|
||||
'No file has this number',\ ;4
|
||||
<'FindByNumber succeded',13,10>,\ ;5
|
||||
<'Invalid Huffman block ID',13,10>,\ ;6
|
||||
<'Error while getting Huffman codes!',13,10>,\ ;7
|
||||
<13,10,'Rebuilding CRC32 table',13,10>,\ ;8
|
||||
'.',\ ;9
|
||||
'Adler32',\ ;10
|
||||
'CRC32',\ ;11
|
||||
<'Job finished.',13,10>,\ ;12
|
||||
<'File of zero length, unpacking aborted.',13,10>,\ ;13
|
||||
<'Source file has strange length, may be missing? Abort.',13,10>,\ ;14
|
||||
<'Not a GZIP archive',13,10>,\ ;15
|
||||
<'Destination file is too large for now',13,10>,\ ;16
|
||||
<"Can't unpack content.",13,10>,\ ; 17
|
||||
<'Not a PNG image',13,10>,\ ; 18
|
||||
<13,10,'*d'>,\ ;19
|
||||
<13,10,'*s'>,\ ;20
|
||||
'Unexpected end of IDAT chunks',\ ;21
|
||||
'Unfiltering:',\ ;22
|
||||
'Filters: None ',\ ;23
|
||||
' Sub ',\ ;24
|
||||
' Up ',\ ;25
|
||||
' Avg ',\ ;26
|
||||
' Paeth ',\ ;27
|
||||
' Invalid ',\ ;28
|
||||
<'Interlaced PNG',13,10>,\ ;29
|
||||
<'Stored block',13,10>,\ ;30
|
||||
<'Color type not supported',13,10>,\ ;31
|
||||
<'Enter password for encrypted file:',13,10>,\ ;32
|
||||
<'Searching for file...',13,10>,\ ;33
|
||||
'Not a SFX module',\ ;34
|
||||
' error! ',\ ;35
|
||||
' OK: ',\ ;36
|
||||
<'Creating OUT.TXT',13,10>,\ ;37
|
||||
' ',\ ;38
|
||||
<'Preparing bitmap...',13,10>,\ ;39
|
||||
<'Specify "R" to force raw data. Abort.',13,10>,\ ;40
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' ',\ ;
|
||||
' <- unknown compression method',\ ;50
|
||||
' <- encrypted',\ ;51
|
||||
<'Not a ZIP archive',13,10> ; 52
|
||||
end if
|
||||
|
||||
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
|
||||
;
|
||||
; 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
|
||||
xor eax,eax
|
||||
mov ecx,200
|
||||
rep stosb
|
||||
|
||||
;mov [get_loops],0
|
||||
mov [dlg_pid_get],0
|
||||
|
||||
; Get my PID in dec format 4 bytes
|
||||
mcall 9,os_work,-1
|
||||
|
||||
; convert eax bin to param dec
|
||||
mov eax,dword [os_work+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
|
||||
|
||||
; write 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
|
||||
|
||||
mcall 40,1000111b
|
||||
;
|
||||
; STEP 3 run SYSTEM XTREE with parameters
|
||||
;
|
||||
|
||||
mcall 58,run_fileinfo
|
||||
|
||||
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
|
||||
mcall 9,os_work,-1
|
||||
mov ebp,eax
|
||||
|
||||
loox:
|
||||
mcall 9,os_work,ebp
|
||||
mov eax,[DLGPID]
|
||||
cmp dword[os_work+30],eax ;IF Dialog find
|
||||
je dlg_is_work ;jmp to dlg_is_work
|
||||
dec ebp
|
||||
jnz loox
|
||||
|
||||
jmp erroff
|
||||
|
||||
dlg_is_work:
|
||||
cmp word[os_work+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:
|
||||
mcall 2 ; 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 os_work ; 0x10000
|
||||
;run_filepath
|
||||
db '/RD/1/SYSXTREE',0
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm @rcher.asm @rcher
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm @rcher.asm @rcher
|
||||
@pause
|
||||
@@ -0,0 +1,158 @@
|
||||
; @RCHER data area
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
|
||||
if SYS eq win
|
||||
dumpfile:
|
||||
db 'D:\Ivushkin\projects\zip\output.dmp',0
|
||||
dumpf_len=$-dumpfile
|
||||
end if
|
||||
outfile:
|
||||
if SYS eq win
|
||||
db 'D:\Ivushkin\projects\zip\output.raw',0
|
||||
end if
|
||||
dd 1
|
||||
dd 0
|
||||
.size dd 0
|
||||
.out dd output
|
||||
dd os_work
|
||||
if ~SYS eq win
|
||||
dumpfile:
|
||||
db DUMPFILE,0
|
||||
dumpf_len=$-dumpfile
|
||||
end if
|
||||
Finfo:
|
||||
dd 0
|
||||
.block dd 0
|
||||
.count dd BUFSIZE*2
|
||||
.ptr dd BUFPTR
|
||||
dd os_work
|
||||
|
||||
filename:
|
||||
if SYS eq win
|
||||
db 'png\absolut0.png',0
|
||||
;db 'fasm-1.54.tgz',0
|
||||
;include 'testsu~1.inc'
|
||||
; db 'pngsuite\pngsuite.tar.gz',0 ; OK
|
||||
; db 'pngsuite\basn4a08.png',0 ; OK
|
||||
; db 'goldhill.png',0 ; beeping
|
||||
; db 'arl_logo.png',0 ; wrong out
|
||||
; db 'tech.png',0 ; wrong out
|
||||
; db 'png\lena0000.png',0
|
||||
; db 'arcs\'
|
||||
; db 'NTOSKRNL.gz'
|
||||
; db 'msg_enc.zip'
|
||||
;db 'msgplain.zip'
|
||||
; db 'c_866.gz'
|
||||
; db 'zalman_2.png' ;OK
|
||||
; db 'arcs\headerbar.png',0 ;OK
|
||||
; db 'fonts1.png' ;OK
|
||||
; db 'fonts.png' ;
|
||||
; db 'skin.png' ;OK
|
||||
; db 'JavaPowered8.png'; OK
|
||||
; db 'opr008S8.png'
|
||||
; db 'goldhill.png'
|
||||
; db 'k3b.png',0
|
||||
; db 'image0051.png'
|
||||
; db 'window-elements.png',0
|
||||
; db 'WWW.zip',0
|
||||
; db 'png.zip',0
|
||||
; db 'zlib09.zip',0
|
||||
|
||||
else
|
||||
if ~ FNAME eq
|
||||
db FNAME
|
||||
end if
|
||||
; db '/hd/1/zip/png.zip',0
|
||||
; db '/hd/1/zip/files/opossum.png'
|
||||
; db '/rd/1/www.zip',0
|
||||
; db '/hd/1/zip/test2.zip',0
|
||||
end if
|
||||
db 0
|
||||
rb 256-($-filename)
|
||||
I_END:
|
||||
|
||||
if SYS eq win
|
||||
cr_lf db 0xa,0xd
|
||||
hnd dd ?
|
||||
cons dd ?
|
||||
cons_in dd ?
|
||||
cparam1 dd ?
|
||||
cparam2 dd ?
|
||||
end if
|
||||
|
||||
DKeys rd 3
|
||||
Dheader rb 12
|
||||
Dpassword rb PASSW_LEN
|
||||
|
||||
png_bpp dd ?
|
||||
sline_len dd ?
|
||||
IDATcount dd ?
|
||||
IDATsize dd ?
|
||||
PNG_info:
|
||||
.Width dd ?
|
||||
.Height dd ?
|
||||
.Bit_depth db ?
|
||||
.Color_type db ?
|
||||
.Compression_method db ?
|
||||
.Filter_method db ?
|
||||
.Interlace_method db ?
|
||||
.Palette rb 3*256
|
||||
gpbf dw ?
|
||||
file_count dd ?
|
||||
filters rd 6
|
||||
arc_base dd ?
|
||||
outp dd ?
|
||||
unp_size dd ?
|
||||
CRC_check dd ?
|
||||
CRC32 dd ?
|
||||
CRC32table rd 256
|
||||
Adler32 dd ?
|
||||
child dd ?
|
||||
clientPID dd ?
|
||||
|
||||
filesize dd ?
|
||||
bits db ?
|
||||
cur_byte dd ?
|
||||
lastblk db ?
|
||||
Flags dd ?
|
||||
tblCount dw ?
|
||||
tblLen dw ?
|
||||
hclen db ?
|
||||
max_len dw ?
|
||||
|
||||
bl_count rb BITS
|
||||
|
||||
next_code rw BITS
|
||||
tmp_clit:
|
||||
rw 20
|
||||
calph:
|
||||
rw 20
|
||||
sorted_clit rw 20
|
||||
|
||||
seql_c db ?
|
||||
seql rb BITS
|
||||
|
||||
seqd_c db ?
|
||||
seqd rb BITS
|
||||
|
||||
hlit dw ?
|
||||
Literal rw 286
|
||||
Lit_c rw 286
|
||||
|
||||
hdist db ?
|
||||
Distance rw 32
|
||||
Dist_c rw 32
|
||||
|
||||
|
||||
area:
|
||||
rb INBUF
|
||||
|
||||
os_work rb 4*1024
|
||||
|
||||
output:
|
||||
rb OUTBUF
|
||||
|
||||
png_image:
|
||||
if SYS eq win
|
||||
rb OUTBUF
|
||||
end if
|
||||
@@ -0,0 +1,131 @@
|
||||
macro debug_print str
|
||||
{
|
||||
local ..string, ..label
|
||||
|
||||
jmp ..label
|
||||
..string db str,0
|
||||
..label:
|
||||
|
||||
pushf
|
||||
pushad
|
||||
mov edx,..string
|
||||
call debug_outstr
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
dps fix debug_print
|
||||
|
||||
macro debug_print_dec arg
|
||||
{
|
||||
pushf
|
||||
pushad
|
||||
if ~arg eq eax
|
||||
mov eax,arg
|
||||
end if
|
||||
call debug_outdec
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
dpd fix debug_print_dec
|
||||
|
||||
;---------------------------------
|
||||
debug_outdec: ;(eax - num, edi-str)
|
||||
push 10 ;2
|
||||
pop ecx ;1
|
||||
push -'0' ;2
|
||||
.l0:
|
||||
xor edx,edx ;2
|
||||
div ecx ;2
|
||||
push edx ;1
|
||||
test eax,eax ;2
|
||||
jnz .l0 ;2
|
||||
.l1:
|
||||
pop eax ;1
|
||||
add al,'0' ;2
|
||||
call debug_outchar ; stosb
|
||||
jnz .l1 ;2
|
||||
ret ;1
|
||||
;---------------------------------
|
||||
|
||||
debug_outchar: ; al - char
|
||||
pushf
|
||||
pushad
|
||||
mov cl,al
|
||||
mov eax,63
|
||||
mov ebx,1
|
||||
int 0x40
|
||||
popad
|
||||
popf
|
||||
ret
|
||||
|
||||
debug_outstr:
|
||||
mov eax,63
|
||||
mov ebx,1
|
||||
@@:
|
||||
mov cl,[edx]
|
||||
test cl,cl
|
||||
jz @f
|
||||
int 40h
|
||||
inc edx
|
||||
jmp @b
|
||||
@@:
|
||||
ret
|
||||
|
||||
|
||||
macro newline
|
||||
{
|
||||
dps <13,10>
|
||||
}
|
||||
|
||||
macro print message
|
||||
{
|
||||
dps message
|
||||
newline
|
||||
}
|
||||
|
||||
macro pregs
|
||||
{
|
||||
dps "EAX: "
|
||||
dpd eax
|
||||
dps " EBX: "
|
||||
dpd ebx
|
||||
newline
|
||||
dps "ECX: "
|
||||
dpd ecx
|
||||
dps " EDX: "
|
||||
dpd edx
|
||||
newline
|
||||
}
|
||||
|
||||
macro debug_print_hex arg
|
||||
{
|
||||
pushf
|
||||
pushad
|
||||
if ~arg eq eax
|
||||
mov eax, arg
|
||||
end if
|
||||
call debug_outhex
|
||||
popad
|
||||
popf
|
||||
}
|
||||
dph fix debug_print_hex
|
||||
|
||||
debug_outhex:
|
||||
; eax - number
|
||||
mov edx, 8
|
||||
.new_char:
|
||||
rol eax, 4
|
||||
movzx ecx, al
|
||||
and cl, 0x0f
|
||||
mov cl, [__hexdigits + ecx]
|
||||
pushad
|
||||
mcall 63, 1
|
||||
popad
|
||||
dec edx
|
||||
jnz .new_char
|
||||
ret
|
||||
|
||||
__hexdigits:
|
||||
db '0123456789ABCDEF'
|
||||
@@ -0,0 +1,615 @@
|
||||
; @RCHER main algorythm
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
|
||||
macro get_a _type,_size,c1,c2,c3,c4,c5
|
||||
{
|
||||
get_#_type:
|
||||
local .no,.no0,.ex
|
||||
push edx
|
||||
and [Flags],not 1
|
||||
if _type eq Len
|
||||
cmp eax,c4
|
||||
jne .no
|
||||
mov eax,c5
|
||||
jmp .ex
|
||||
.no:
|
||||
end if
|
||||
sub eax,c1
|
||||
ja .no0
|
||||
add eax,c2
|
||||
jmp .ex
|
||||
.no0:
|
||||
add eax,c3
|
||||
push eax
|
||||
mov ecx,eax
|
||||
shr ecx,_size
|
||||
xor eax,eax
|
||||
call read_bits
|
||||
pop edx
|
||||
and edx,1 shl _size-1
|
||||
shl edx,cl
|
||||
movzx ecx,[tblH#_type+ecx*2]
|
||||
add edx,ecx
|
||||
add eax,edx
|
||||
.ex:
|
||||
or [Flags],1
|
||||
pop edx
|
||||
ret
|
||||
}
|
||||
; *************************
|
||||
|
||||
Deflate:
|
||||
mov edi,[outp]
|
||||
.init:
|
||||
mov [bits],8
|
||||
lodsb
|
||||
call setcurb
|
||||
.blkbegin:
|
||||
and [lastblk],0
|
||||
and [Flags],not 1
|
||||
rbits 0,1
|
||||
test eax,eax
|
||||
je .nolast
|
||||
mov [lastblk],1
|
||||
.nolast:
|
||||
rbits 0,2
|
||||
cmp eax,10b
|
||||
je .DynHuff
|
||||
cmp eax,01b
|
||||
je .static
|
||||
test eax,eax
|
||||
jnz .errorID
|
||||
Msg 30
|
||||
movzx ecx,[bits]
|
||||
call read_bits
|
||||
movzx ecx,word[esi-1]
|
||||
add esi,3
|
||||
rep movsb
|
||||
jmp .check_last
|
||||
.errorID:
|
||||
Msg 6
|
||||
ret
|
||||
; Static Huffman
|
||||
.static:
|
||||
if SHOW_METH eq 1
|
||||
Msg 20
|
||||
end if
|
||||
mov edi,[outp]
|
||||
or [Flags],1
|
||||
.next:
|
||||
rbits 0,7
|
||||
; stop
|
||||
cmp eax,0x17
|
||||
ja .no7
|
||||
add eax,256
|
||||
cmp eax,256
|
||||
jne .noend
|
||||
.check_last:
|
||||
mov [outp],edi
|
||||
cmp [lastblk],1
|
||||
je .ex
|
||||
jmp .blkbegin
|
||||
.noend:
|
||||
call get_Len
|
||||
mov ebx,eax
|
||||
rbits 0,5
|
||||
call get_Dist
|
||||
neg eax
|
||||
push esi
|
||||
lea esi,[edi+eax]
|
||||
mov ecx,ebx
|
||||
rep movsb
|
||||
pop esi
|
||||
jmp .next
|
||||
.no7:
|
||||
rbits eax,1
|
||||
cmp eax,0xc8
|
||||
jb .no9
|
||||
rbits eax,1
|
||||
sub eax,0xd0
|
||||
jmp .no81
|
||||
.no9:
|
||||
cmp eax,0xc0
|
||||
jb .no81
|
||||
add eax,0x58
|
||||
jmp .noend
|
||||
.no81:
|
||||
sub eax,0x30
|
||||
stosb
|
||||
jmp .next
|
||||
.ex:
|
||||
ret
|
||||
; ************* dynamic Huffman ************
|
||||
|
||||
.DynHuff:
|
||||
; dps '##'
|
||||
if SHOW_METH eq 1
|
||||
Msg 19
|
||||
end if
|
||||
pusha
|
||||
xor eax,eax
|
||||
mov ecx,(area-bl_count) / 4
|
||||
mov edi,bl_count
|
||||
rep stosd
|
||||
popa
|
||||
|
||||
; max_len=0
|
||||
and [max_len],0
|
||||
rbits 0,5
|
||||
; hlit-257
|
||||
add eax,257
|
||||
mov [hlit],ax
|
||||
rbits 0,5
|
||||
; hdist-1
|
||||
inc eax
|
||||
mov [hdist],al
|
||||
rbits 0,4
|
||||
; hclen-4
|
||||
add eax,4
|
||||
mov [hclen],al
|
||||
mov ecx,eax
|
||||
push edi
|
||||
mov edi,tmp_clit
|
||||
; read code lengths for code lengths
|
||||
.alphloop:
|
||||
push ecx
|
||||
rbits 0,3
|
||||
stosb
|
||||
pop ecx
|
||||
loop .alphloop
|
||||
; sort code lengths for code lengths
|
||||
push esi
|
||||
movzx ecx,[hclen]
|
||||
xor eax,eax
|
||||
mov edi,tmp_clit
|
||||
mov esi,tblSort
|
||||
.sortloop:
|
||||
lodsb
|
||||
movzx bx,byte[edi]
|
||||
mov [sorted_clit+eax*2],bx
|
||||
inc edi
|
||||
loop .sortloop
|
||||
pop esi edi
|
||||
.generate:
|
||||
mov ecx,19
|
||||
mov ebx,calph
|
||||
mov edx,seql
|
||||
mov eax,sorted_clit
|
||||
call Huffc
|
||||
and [tblCount],0
|
||||
or [Flags],1
|
||||
mov edi,Lit_c
|
||||
mov ebp,sorted_clit
|
||||
.again:
|
||||
cmp edi,output+OUTBUF
|
||||
jb ._ok
|
||||
Msg 16
|
||||
jmp .ex
|
||||
._ok:
|
||||
mov edx,seql
|
||||
mov ebx,calph
|
||||
call get_code
|
||||
call ExpLen
|
||||
cmp [hlit],ax
|
||||
ja .again
|
||||
if SHOW_CHARS eq 1
|
||||
mov edi,Lit_c
|
||||
call Show_codes
|
||||
end if
|
||||
mov edi,Dist_c
|
||||
and [tblCount],0
|
||||
.again2:
|
||||
mov ebx,calph
|
||||
|
||||
call get_code
|
||||
call ExpLen
|
||||
cmp [hdist],al
|
||||
ja .again2
|
||||
movzx ecx,[hlit]
|
||||
mov ebx,Literal
|
||||
mov edx,seql
|
||||
mov eax,Lit_c
|
||||
call Huffc
|
||||
movzx ecx,[hdist]
|
||||
mov ebx,Distance
|
||||
mov edx,seqd
|
||||
mov eax,Dist_c
|
||||
call Huffc
|
||||
|
||||
push [hlit]
|
||||
pop [tblLen]
|
||||
mov ebp,Lit_c
|
||||
mov edx,seql
|
||||
mov ebx,Literal
|
||||
mov edi,[outp]
|
||||
and [tblCount],0
|
||||
.again3: ; <------------
|
||||
call get_code
|
||||
cmp eax,256
|
||||
je .check_last
|
||||
ja .dist
|
||||
stosb
|
||||
jmp .again3
|
||||
.dist:
|
||||
call get_Len
|
||||
push eax ebx edx ebp
|
||||
mov ecx,32
|
||||
mov ebp,Dist_c
|
||||
mov edx,seqd
|
||||
mov ebx,Distance
|
||||
mov [tblLen],32
|
||||
call get_code
|
||||
call get_Dist
|
||||
push [hlit]
|
||||
pop [tblLen]
|
||||
neg eax
|
||||
pop ebp edx ebx ecx
|
||||
push esi
|
||||
lea esi,[edi+eax]
|
||||
rep movsb
|
||||
pop esi
|
||||
jmp .again3
|
||||
|
||||
; ******************************************
|
||||
Huffc:
|
||||
; EBX - dest array, ECX - length, EDX - br_seq dest, EAX - source array
|
||||
push esi edi eax ecx
|
||||
mov edi,bl_count
|
||||
xor eax,eax
|
||||
mov ecx,BITS
|
||||
rep stosw
|
||||
pop ecx
|
||||
mov esi,[esp]
|
||||
mov [tblLen],cx
|
||||
mov [max_len],ax
|
||||
; Count the number of codes for each code length
|
||||
.cnt_loop:
|
||||
lodsw
|
||||
cmp [max_len],ax
|
||||
jae .skip
|
||||
mov [max_len],ax
|
||||
.skip:
|
||||
inc byte[bl_count+eax]
|
||||
loop .cnt_loop
|
||||
movzx ecx,[max_len]
|
||||
xor eax,eax
|
||||
and [bl_count],al
|
||||
xor esi,esi ; edx - bits
|
||||
mov edi,next_code+2
|
||||
push ebx
|
||||
; Find the numerical value of the smallest code for each code length
|
||||
.nc_loop:
|
||||
movzx bx,byte[bl_count+esi]
|
||||
add ax,bx
|
||||
shl ax,1
|
||||
stosw
|
||||
inc esi
|
||||
loop .nc_loop
|
||||
pop ebx
|
||||
; clear table
|
||||
movzx ecx,[tblLen]
|
||||
xor eax,eax
|
||||
dec eax
|
||||
mov edi,ebx
|
||||
rep stosw
|
||||
inc eax
|
||||
movzx ecx,[tblLen]
|
||||
mov esi,[esp]
|
||||
mov edi,ebx
|
||||
; Assign numerical values to all codes
|
||||
.loop3:
|
||||
lodsw
|
||||
test eax,eax
|
||||
jz .lp
|
||||
push [next_code+eax*2]
|
||||
pop word[edi]
|
||||
inc [next_code+eax*2]
|
||||
.lp:
|
||||
add edi,2
|
||||
loop .loop3
|
||||
; Clear all codes
|
||||
xor eax,eax
|
||||
mov edi,edx
|
||||
movzx ecx,[max_len]
|
||||
mov [edi-1],al
|
||||
; Prepare read bit sequences
|
||||
.rebiloop:
|
||||
inc eax
|
||||
cmp [bl_count+eax],0
|
||||
jz .sk
|
||||
stosb
|
||||
inc byte[edx-1]
|
||||
.sk:
|
||||
loop .rebiloop
|
||||
movzx ecx,byte[edx-1]
|
||||
dec ecx
|
||||
jecxz .noreb2
|
||||
.reb2loop:
|
||||
mov al,[edx+ecx-1]
|
||||
sub [edx+ecx],al
|
||||
loop .reb2loop
|
||||
.noreb2:
|
||||
pop eax edi esi
|
||||
ret
|
||||
|
||||
; ******************************************
|
||||
|
||||
; get Codes of variable sizes
|
||||
get_code:
|
||||
; EDX - br_seq, EBX - source table, EBP - codelength table
|
||||
push edx edi
|
||||
xor eax,eax
|
||||
movzx ecx,byte[edx-1]
|
||||
mov [codel],ax
|
||||
.rb3:
|
||||
push ecx
|
||||
movzx ecx,byte[edx]
|
||||
add [codel],cx
|
||||
call read_bits
|
||||
movzx ecx,[tblLen]
|
||||
inc ecx
|
||||
mov edi,ebx
|
||||
.scas:
|
||||
repne scasw
|
||||
jecxz .notfound
|
||||
push edi ecx
|
||||
sub edi,ebx
|
||||
sub edi,2
|
||||
mov cx,[codel]
|
||||
cmp cx,[ds:ebp+edi]
|
||||
jne .notfound2
|
||||
mov eax,edi
|
||||
shr eax,1
|
||||
add esp,12
|
||||
.pp:
|
||||
pop edi edx
|
||||
ret
|
||||
.notfound2:
|
||||
pop ecx
|
||||
pop edi
|
||||
jmp .scas
|
||||
.notfound:
|
||||
pop ecx
|
||||
inc edx
|
||||
loop .rb3
|
||||
Msg 7
|
||||
jmp .pp
|
||||
|
||||
codel dw ?
|
||||
; ******************************************
|
||||
ExpLen:
|
||||
cmp eax,16
|
||||
jae .noliteral
|
||||
inc [tblCount]
|
||||
stosw
|
||||
jmp .nomatch
|
||||
.noliteral:
|
||||
and [Flags],not 1
|
||||
mov ebx,3
|
||||
cmp eax,17
|
||||
jae .code1718
|
||||
mov ecx,2
|
||||
xor eax,eax
|
||||
call read_bits
|
||||
lea ecx,[eax+ebx]
|
||||
mov ax,[edi-2]
|
||||
.cc:
|
||||
add [tblCount],cx
|
||||
rep stosw
|
||||
or [Flags],1
|
||||
jmp .nomatch
|
||||
.code1718:
|
||||
jne .code18
|
||||
mov ecx,3
|
||||
.cc2:
|
||||
xor eax,eax
|
||||
call read_bits
|
||||
lea ecx,[eax+ebx]
|
||||
xor eax,eax
|
||||
jmp .cc
|
||||
.code18:
|
||||
mov ebx,11
|
||||
mov ecx,7
|
||||
jmp .cc2
|
||||
.nomatch:
|
||||
mov ax,[tblCount]
|
||||
ret
|
||||
get_a Len,2,256+8,10,3,285,258
|
||||
get_a Dist,1,3,4,1
|
||||
|
||||
|
||||
; ******************************************
|
||||
read_bits: ; eax-dest; ecx-count
|
||||
push edx ecx
|
||||
.shift:
|
||||
if RBLOCK eq 4
|
||||
ror [cur_byte],1
|
||||
else
|
||||
ror byte[cur_byte],1
|
||||
end if
|
||||
pushf
|
||||
test [Flags],1
|
||||
je .noh1
|
||||
popf
|
||||
rcl eax,1
|
||||
jmp .dec
|
||||
.noh1:
|
||||
popf
|
||||
rcr eax,1
|
||||
.dec:
|
||||
dec [bits]
|
||||
jnz .loop1
|
||||
.push:
|
||||
push eax
|
||||
mov eax,[esi]
|
||||
call setcurb
|
||||
pop eax
|
||||
if RBLOCK eq 1
|
||||
inc esi
|
||||
inc [IDATcount]
|
||||
else
|
||||
inc esi
|
||||
inc [IDATcount]
|
||||
end if
|
||||
cmp esi,area+INBUF-BSIZE
|
||||
jbe .ok
|
||||
pusha
|
||||
if SHOW_RBLOCK eq 1
|
||||
Msg 9
|
||||
end if
|
||||
mov eax,0
|
||||
mov ebx,1
|
||||
call FileSeek
|
||||
mov [esp+4],esi
|
||||
popa
|
||||
.ok:
|
||||
test [Flags],PNG_MODE
|
||||
jz .idatok
|
||||
mov edx,[IDATcount]
|
||||
cmp edx,[IDATsize]
|
||||
jbe .idatok
|
||||
pusha
|
||||
lodsd
|
||||
call PngParse.nxt_sec
|
||||
mov [IDATcount],1
|
||||
mov [esp+4],esi
|
||||
mov [esp+20],edx
|
||||
popa
|
||||
cmp edx,21
|
||||
jne .idatok
|
||||
mov eax,256
|
||||
pop ecx
|
||||
jmp .exx
|
||||
.idatok:
|
||||
|
||||
mov [bits],8
|
||||
.loop1:
|
||||
loop .shift2
|
||||
jmp .popc
|
||||
.shift2:
|
||||
jmp .shift
|
||||
.popc:
|
||||
pop ecx
|
||||
test [Flags],1
|
||||
jne .exx
|
||||
.noh2:
|
||||
rol eax,cl
|
||||
.exx:
|
||||
pop edx
|
||||
ret
|
||||
|
||||
if SHOW_CHARS eq 1
|
||||
Show_codes:
|
||||
pusha
|
||||
movzx ecx,[tblLen]
|
||||
mov ecx,256
|
||||
xor eax,eax
|
||||
.lp2:
|
||||
mov [braces+1],al
|
||||
push eax ecx
|
||||
invoke StrFormat,eax,strbuf,20
|
||||
invoke WriteConsole,[cons],strbuf,16,param1,NULL
|
||||
invoke WriteConsole,[cons],braces,6,param1,NULL
|
||||
mov eax,[esp+4]
|
||||
movzx eax,word[edi+eax*2]
|
||||
test eax,eax
|
||||
jz .skip
|
||||
invoke WriteConsole,[cons],exist,6,param1,NULL
|
||||
.skip:
|
||||
invoke WriteConsole,[cons],braces+6,2,param1,NULL
|
||||
pop ecx eax
|
||||
inc eax
|
||||
loop .lp
|
||||
jmp .ex
|
||||
.lp:
|
||||
jmp .lp2
|
||||
.ex:
|
||||
popa
|
||||
ret
|
||||
|
||||
cons dd ?
|
||||
param1 dd ?
|
||||
braces db '( ) = ',0xa, 0xd
|
||||
strbuf rb 20
|
||||
exist db 'exists'
|
||||
end if
|
||||
|
||||
makeCRC:
|
||||
pusha
|
||||
Msg 8
|
||||
mov edi,CRC32table
|
||||
add edi,255*4
|
||||
std
|
||||
mov ecx,255
|
||||
mov ebx,0xedb88320
|
||||
.m1:
|
||||
mov eax,ecx
|
||||
push ecx
|
||||
mov ecx,8
|
||||
.m2:
|
||||
shr eax,1
|
||||
jnc .m3
|
||||
xor eax,ebx
|
||||
.m3:
|
||||
loop .m2
|
||||
pop ecx
|
||||
stosd
|
||||
loop .m1
|
||||
popa
|
||||
cld
|
||||
ret
|
||||
|
||||
UCRC:
|
||||
; in: esi - data to calculate CRC
|
||||
; ecx - its length
|
||||
; [CRC32] - previous CRC32
|
||||
; out: [CRC32]- partial CRC32 (no pre- & post-conditioning!)
|
||||
pusha
|
||||
cmp dword[CRC32table+4],0x77073096
|
||||
je .tbl_rdy
|
||||
call makeCRC
|
||||
.tbl_rdy:
|
||||
mov eax,[CRC32]
|
||||
not eax
|
||||
.m1:
|
||||
movzx ebx,al
|
||||
shr eax,8
|
||||
xor bl,[esi]
|
||||
xor eax,[CRC32table+ebx*4]
|
||||
inc esi
|
||||
loop .m1
|
||||
not eax
|
||||
mov [CRC32],eax
|
||||
popa
|
||||
ret
|
||||
|
||||
UAdler:
|
||||
; in: esi - data to calculate CRC
|
||||
; ecx - its length
|
||||
; [Adler32] - previous Adler32
|
||||
; out: [Adler32]- partial Adler32
|
||||
pusha
|
||||
mov ebp,65521
|
||||
movzx ebx,word[Adler32] ; s1-ebx
|
||||
movzx edi,word[Adler32+2] ; s2-edi
|
||||
.m1:
|
||||
movzx eax,byte[esi]
|
||||
add eax,ebx
|
||||
xor edx,edx
|
||||
div ebp
|
||||
mov ebx,edx
|
||||
lea eax,[edi+ebx]
|
||||
xor edx,edx
|
||||
div ebp
|
||||
mov edi,edx
|
||||
inc esi
|
||||
loop .m1
|
||||
shl edi,16
|
||||
add edi,ebx
|
||||
mov [Adler32],edi
|
||||
popa
|
||||
ret
|
||||
|
||||
tblSort db 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15
|
||||
tblHLen dw 7,11,19,35,67,131
|
||||
tblHDist dw 3,5,9,17,33,65,129,257,513,1025,2049,4097,8193,16385
|
||||
@@ -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
|
||||
@@ -0,0 +1,896 @@
|
||||
; @RCHER parser and filter routines
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
|
||||
fhs_local equ 0x04034b50
|
||||
fhs_central equ 0x02014b50
|
||||
fhs_end equ 0x06054b50
|
||||
fhs_enc equ 0x08074b50
|
||||
|
||||
SkipASCIIZ:
|
||||
xor eax,eax
|
||||
mov ecx,255
|
||||
mov edi,esi
|
||||
repne scasb
|
||||
mov esi,edi
|
||||
ret
|
||||
|
||||
PrintFilename:
|
||||
pusha
|
||||
mov esi,edx
|
||||
mov edi,os_work
|
||||
mov edx,edi
|
||||
rep movsb
|
||||
mov dword[edi],0x00a0d
|
||||
call DebugPrint
|
||||
; mcall 10
|
||||
; mcall 2
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; Parse routines:
|
||||
; out: edx= 0 if all ok, 1 - central dir, 2-EOD
|
||||
; 50 - encrypted
|
||||
; 51 - not deflated
|
||||
; 52 - invalid format
|
||||
; 53 - dir skipped
|
||||
; 1 - encrypted
|
||||
|
||||
; ****************************************************
|
||||
ZipParse:
|
||||
|
||||
call ResetFile
|
||||
.nxt:
|
||||
call ZipCrawl
|
||||
|
||||
cmp edx,3
|
||||
je .ex
|
||||
cmp edx,1
|
||||
je .skipinc
|
||||
if IGNORE_DIRS eq 1
|
||||
cmp edx,53
|
||||
jne .skipinc
|
||||
end if
|
||||
inc [file_count]
|
||||
.skipinc:
|
||||
cmp edx,52
|
||||
je .er1
|
||||
cmp edx,50
|
||||
jne .seek
|
||||
.er1:
|
||||
Msg edx
|
||||
ret
|
||||
.seek:
|
||||
add eax,ecx
|
||||
mov ebx,1
|
||||
call FileSeek
|
||||
jmp .nxt
|
||||
.ex:
|
||||
Msg 2
|
||||
mov eax,[file_count]
|
||||
if ~ SYS eq win
|
||||
dpd eax
|
||||
else
|
||||
pusha
|
||||
call int2str
|
||||
mov edx,os_work
|
||||
call DebugPrint
|
||||
popa
|
||||
end if
|
||||
Newline
|
||||
ret
|
||||
|
||||
ZipFindN:
|
||||
; ecx - file #
|
||||
Msg 33
|
||||
cmp ecx,[file_count]
|
||||
jae .err
|
||||
push ecx
|
||||
call ResetFile
|
||||
.nxt:
|
||||
call ZipCrawl
|
||||
cmp edx,51
|
||||
je .ok2
|
||||
.noenc:
|
||||
test edx,edx
|
||||
jnz .err
|
||||
.ok2:
|
||||
add eax,ecx
|
||||
cmp dword[esp],0
|
||||
jz .ok
|
||||
dec dword[esp]
|
||||
mov ebx,1
|
||||
call FileSeek
|
||||
jmp .nxt
|
||||
.err:
|
||||
mov edx,4
|
||||
jmp .ex
|
||||
.ok:
|
||||
pop ecx
|
||||
sub eax,[esi+18]
|
||||
add esi,eax
|
||||
mov edx,5
|
||||
.ex:
|
||||
push edx
|
||||
Msg edx
|
||||
pop edx
|
||||
ret
|
||||
|
||||
ZipCrawl:
|
||||
mov edx,52
|
||||
cmp dword[esi],fhs_central
|
||||
jne .noc
|
||||
mov eax,46
|
||||
movzx ecx,word[esi+28]
|
||||
add eax,ecx
|
||||
movzx ecx,word[esi+30]
|
||||
add eax,ecx
|
||||
movzx ecx,word[esi+32]
|
||||
mov edx,1
|
||||
ret
|
||||
.noc:
|
||||
cmp dword[esi],fhs_end
|
||||
jne .noe
|
||||
.edx3:
|
||||
Msg 3
|
||||
mov edx,3
|
||||
ret
|
||||
.noe:
|
||||
cmp dword[esi],fhs_local
|
||||
je .loc
|
||||
cmp dword[esi],fhs_enc
|
||||
jne .err
|
||||
mov eax,16
|
||||
xor ecx,ecx
|
||||
mov edx,1
|
||||
ret
|
||||
.loc:
|
||||
push word[esi+6]
|
||||
pop [gpbf]
|
||||
push dword[esi+14]
|
||||
pop [CRC_check]
|
||||
push dword[esi+22]
|
||||
pop [unp_size]
|
||||
movzx ecx,word[esi+26]
|
||||
mov eax,30
|
||||
lea edx,[esi+eax]
|
||||
add eax,ecx
|
||||
if IGNORE_DIRS eq 1
|
||||
cmp byte[edx+ecx-1],'/'
|
||||
je .skipdp
|
||||
end if
|
||||
call PrintFilename
|
||||
.skipdp:
|
||||
movzx ecx,word[esi+28]
|
||||
add eax,[esi+18]
|
||||
test [gpbf],1
|
||||
jz .no_enc
|
||||
or [Flags],DECRYPT_MODE ; encrypted
|
||||
mov edx,51
|
||||
jmp .err
|
||||
.no_enc:
|
||||
test word[esi+8],7
|
||||
rep_err z,50
|
||||
.ok:
|
||||
xor edx,edx
|
||||
.err:
|
||||
ret
|
||||
|
||||
; ***********************************************
|
||||
GzipParse:
|
||||
ID1ID2 equ 0x8b1f
|
||||
FTEXT equ 1b
|
||||
FHCRC equ 10b
|
||||
FEXTRA equ 100b
|
||||
FNAME equ 1000b
|
||||
FCOMMENT equ 10000b
|
||||
mov eax,7
|
||||
mov ebx,2
|
||||
call FileSeek
|
||||
push dword[esi]
|
||||
pop [CRC_check]
|
||||
push dword[esi+4]
|
||||
pop [unp_size]
|
||||
call ResetFile
|
||||
xor edx,edx
|
||||
cmp word[esi],ID1ID2
|
||||
rep_err e, 52, 15
|
||||
cmp byte[esi+2],8
|
||||
rep_err e, 52, 50
|
||||
mov bl,[esi+3] ; bl - FLG
|
||||
add esi,10 ; esi->extra
|
||||
test bl,FEXTRA
|
||||
jz .noextr
|
||||
movzx eax,word[esi]
|
||||
lea esi,[esi+eax+2] ; esi->FNAME
|
||||
.noextr:
|
||||
test bl,FNAME
|
||||
jz .nofname
|
||||
mov edx,esi
|
||||
call DebugPrint
|
||||
call SkipASCIIZ
|
||||
cmp dword[esi-5],'.tar'
|
||||
jne .nofname
|
||||
or [Flags],TAR_MODE
|
||||
.nofname: ; esi->FCOMMENT
|
||||
test bl,FCOMMENT
|
||||
jz .nocomm
|
||||
call SkipASCIIZ
|
||||
.nocomm: ; esi->HCRC
|
||||
test bl,FHCRC
|
||||
jz .noCRC16
|
||||
add esi,2
|
||||
.noCRC16:
|
||||
cmp [unp_size],OUTBUF
|
||||
jb .sizeok2
|
||||
Msg 16
|
||||
mov edx,15
|
||||
ret
|
||||
.sizeok2:
|
||||
xor edx,edx
|
||||
.err:
|
||||
ret
|
||||
|
||||
PngParse:
|
||||
ID1 equ 0x474e5089
|
||||
ID2 equ 0x0a1a0a0d
|
||||
FDICT equ 100000b
|
||||
InitIDAT equ 2
|
||||
mov [IDATcount],InitIDAT
|
||||
call ResetFile
|
||||
cmp dword[esi],ID1
|
||||
rep_err e, 52, 18
|
||||
cmp dword[esi+4],ID2
|
||||
rep_err e, 52, 18
|
||||
add esi,8
|
||||
cmp dword[esi+4],'IHDR'
|
||||
rep_err e,52, 18
|
||||
or [Flags],PNG_MODE
|
||||
memcpy_esi PNG_info,13,8
|
||||
mov eax,[PNG_info.Width]
|
||||
bswap eax
|
||||
mov [PNG_info.Width],eax
|
||||
mov eax,[PNG_info.Height]
|
||||
bswap eax
|
||||
mov [PNG_info.Height],eax
|
||||
add esi,25
|
||||
cmp byte[esi-5],0
|
||||
rep_err e,52,29
|
||||
.nxt_sec:
|
||||
lodsd
|
||||
bswap eax ; eax - section size
|
||||
push eax
|
||||
lodsd
|
||||
mov edi,Png_ch
|
||||
mov ecx,(E_ch-Png_ch) / 4
|
||||
repne scasd
|
||||
pop eax
|
||||
mov ebx,[esi-4]
|
||||
mov edx,os_work
|
||||
mov [edx],ebx
|
||||
mov dword[edx+4],0x0a0d
|
||||
.dp:
|
||||
sub edi,Png_ch
|
||||
shr edi,2 ; edi- chunk #
|
||||
if SHOW_PNG_SEC eq 1
|
||||
call DebugPrint
|
||||
end if
|
||||
cmp edi,1
|
||||
jne .noend
|
||||
mov edx,21
|
||||
jmp .err
|
||||
.noend:
|
||||
cmp edi,2
|
||||
jne .noplte
|
||||
memcpy_esi PNG_info.Palette,eax
|
||||
jmp .noidat
|
||||
.noplte:
|
||||
cmp edi,3
|
||||
jne .noidat
|
||||
mov [IDATsize],eax
|
||||
cmp [IDATcount],InitIDAT
|
||||
jne .ex
|
||||
mov [bits],8
|
||||
if RBLOCK eq 4
|
||||
lodsd
|
||||
else
|
||||
lodsb
|
||||
end if
|
||||
call setcurb
|
||||
rbits 0,16
|
||||
test ah,FDICT
|
||||
jz .ex
|
||||
rbits 0,32
|
||||
add [IDATcount],4
|
||||
jmp .ex
|
||||
.noidat:
|
||||
add eax,4
|
||||
mov ebx,1
|
||||
call FileSeek
|
||||
jmp .nxt_sec
|
||||
.ex:
|
||||
xor edx,edx
|
||||
.err:
|
||||
ret
|
||||
|
||||
Png_ch:
|
||||
dd 'IEND','PLTE','IDAT','????'
|
||||
E_ch:
|
||||
|
||||
ZipDecrypt:
|
||||
push edi
|
||||
mov ecx,3
|
||||
mov edi,Dheader
|
||||
rep movsd
|
||||
pop edi
|
||||
call QueryPwd
|
||||
jecxz .ex
|
||||
push esi
|
||||
mov [DKeys], 305419896
|
||||
mov [DKeys+4],591751049
|
||||
mov [DKeys+8],878082192
|
||||
xor eax,eax
|
||||
mov esi,Dpassword
|
||||
.enc_init:
|
||||
lodsb
|
||||
call UKeys
|
||||
loop .enc_init
|
||||
mov ecx,12
|
||||
mov esi,Dheader
|
||||
.dec_header:
|
||||
call decrypt_byte
|
||||
xor al,[esi]
|
||||
call UKeys
|
||||
mov [esi],al
|
||||
inc esi
|
||||
loop .dec_header
|
||||
mov eax,[CRC_check]
|
||||
pop esi
|
||||
.ex:
|
||||
ret
|
||||
|
||||
QueryPwd:
|
||||
; out: ecx - passwd len
|
||||
if SYS eq win
|
||||
Msg 32
|
||||
invoke ReadConsole,[cons_in],Dpassword,PASSW_LEN,cparam1,NULL
|
||||
test eax,eax
|
||||
jnz .inp_ok
|
||||
xor ecx,ecx
|
||||
jmp .ex
|
||||
.inp_ok:
|
||||
mov ecx,[cparam1]
|
||||
cmp ecx,PASSW_LEN
|
||||
je .ex
|
||||
sub ecx,2
|
||||
else
|
||||
end if
|
||||
.ex:
|
||||
ret
|
||||
|
||||
UKeys:
|
||||
; in: al - char
|
||||
pusha
|
||||
mov edi,134775813
|
||||
mov ebx,DKeys
|
||||
mov esi,os_work
|
||||
mov byte[esi],al
|
||||
mov ecx,1
|
||||
push dword[ebx]
|
||||
pop [CRC32]
|
||||
call UCRC
|
||||
push [CRC32]
|
||||
pop dword[ebx]
|
||||
mov eax,[ebx]
|
||||
and eax,0xff
|
||||
add eax,[ebx+4]
|
||||
mul edi
|
||||
inc eax
|
||||
mov [ebx+4],eax
|
||||
shr eax,24
|
||||
mov byte[esi],al
|
||||
push dword[ebx+8]
|
||||
pop [CRC32]
|
||||
call UCRC
|
||||
push [CRC32]
|
||||
pop dword[ebx+8]
|
||||
popa
|
||||
ret
|
||||
|
||||
decrypt_byte:
|
||||
; out: al
|
||||
push ebx edx
|
||||
movzx ebx,word[DKeys+8]
|
||||
or ebx,2
|
||||
mov eax,ebx
|
||||
xor eax,1
|
||||
mul ebx
|
||||
shr eax,8
|
||||
pop edx ebx
|
||||
ret
|
||||
|
||||
setcurb:
|
||||
; in: eax
|
||||
test [Flags],DECRYPT_MODE
|
||||
jz .noenc
|
||||
push eax
|
||||
call decrypt_byte
|
||||
xor al,byte[esp]
|
||||
add esp,4
|
||||
call UKeys
|
||||
.noenc:
|
||||
mov [cur_byte],eax
|
||||
ret
|
||||
|
||||
TarParse:
|
||||
call ResetFile
|
||||
.nxt:
|
||||
call TarCrawl
|
||||
; wait
|
||||
cmp edx,3
|
||||
je ZipParse.ex
|
||||
if IGNORE_DIRS eq 1
|
||||
cmp edx,53
|
||||
jne .skipinc
|
||||
end if
|
||||
inc [file_count]
|
||||
.skipinc:
|
||||
add eax,ecx
|
||||
mov ebx,1
|
||||
call FileSeek
|
||||
jmp .nxt
|
||||
|
||||
TarFindN:
|
||||
; in: ecx - file number
|
||||
; ecx - file #
|
||||
Msg 33
|
||||
cmp ecx,[file_count]
|
||||
jae .err
|
||||
push ecx
|
||||
call ResetFile
|
||||
.nxt:
|
||||
call TarCrawl
|
||||
if IGNORE_DIRS eq 1
|
||||
cmp edx,53
|
||||
je .seek
|
||||
end if
|
||||
test edx,edx
|
||||
jnz .err
|
||||
cmp dword[esp],0
|
||||
jz .ok
|
||||
dec dword[esp]
|
||||
.seek:
|
||||
add eax,ecx
|
||||
mov ebx,1
|
||||
call FileSeek
|
||||
jmp .nxt
|
||||
.err:
|
||||
mov edx,4
|
||||
jmp .ex
|
||||
.ok:
|
||||
pop ecx
|
||||
add esi,eax
|
||||
mov edx,5
|
||||
.ex:
|
||||
Msg edx
|
||||
ret
|
||||
|
||||
TarCrawl:
|
||||
cmp byte[esi],0
|
||||
jz ZipCrawl.edx3
|
||||
push esi
|
||||
mov ecx,11
|
||||
add esi,0x7c
|
||||
call Octal_str
|
||||
mov esi,[esp]
|
||||
mov [outfile.size],eax
|
||||
call SkipASCIIZ
|
||||
if IGNORE_DIRS eq 1
|
||||
cmp byte[esi-2],'/'
|
||||
je .skipdp
|
||||
end if
|
||||
mov edx,[esp]
|
||||
lea ecx,[esi-1]
|
||||
sub ecx,edx
|
||||
call PrintFilename
|
||||
.skipdp:
|
||||
mov ecx,[outfile.size]
|
||||
jecxz .zerolen
|
||||
shr ecx,9
|
||||
inc ecx
|
||||
shl ecx,9
|
||||
.zerolen:
|
||||
mov eax,512
|
||||
pop esi
|
||||
jmp ZipCrawl.ok
|
||||
|
||||
Octal_str:
|
||||
; in: esi - ASCIIZ octal string
|
||||
; ecx - its length
|
||||
; out: eax - value
|
||||
push esi ebx ecx
|
||||
xor ebx,ebx
|
||||
xor eax,eax
|
||||
.jec:
|
||||
jecxz .zero
|
||||
cmp byte[esi+ecx-1],' '
|
||||
jne .lp
|
||||
dec ecx
|
||||
jmp .jec
|
||||
.lp:
|
||||
lodsb
|
||||
shl ebx,3
|
||||
cmp eax,' '
|
||||
je .space
|
||||
lea ebx,[ebx+eax-'0']
|
||||
.space:
|
||||
loop .lp
|
||||
mov eax,ebx
|
||||
.zero:
|
||||
pop ecx ebx esi
|
||||
ret
|
||||
|
||||
TRAILING_BUF equ 2048
|
||||
SfxParse:
|
||||
call ResetFile
|
||||
cmp word[esi],'MZ'
|
||||
rep_err e, 34
|
||||
mov eax,TRAILING_BUF
|
||||
mov ecx,eax
|
||||
mov ebx,2
|
||||
call FileSeek
|
||||
mov edi,esi
|
||||
mov al,'P'
|
||||
.lp:
|
||||
repne scasb
|
||||
cmp dword[edi-1],fhs_end
|
||||
je .end_found
|
||||
jecxz .err
|
||||
jmp .lp
|
||||
.end_found:
|
||||
dec edi
|
||||
mov esi,edi
|
||||
mov eax,[edi+12]
|
||||
neg eax
|
||||
mov ebx,1
|
||||
call FileSeek
|
||||
push dword[esi+42]
|
||||
pop [arc_base]
|
||||
.err:
|
||||
ret
|
||||
|
||||
; Created: May 31, 2005
|
||||
FiltCall:
|
||||
dd PngFilter.nofilt,Filt_sub,Filt_up,Filt_av,Filt_paeth,PngFilter.nofilt
|
||||
PngFilter:
|
||||
; esi - filtered uncompressed image data
|
||||
; edi - destination
|
||||
mov cl,[PNG_info.Color_type]
|
||||
mov eax,1
|
||||
cmp cl,3
|
||||
je .palette
|
||||
test cl,2
|
||||
jz .notriple
|
||||
add eax,2
|
||||
.notriple:
|
||||
test cl,4
|
||||
jz .calc_bpp
|
||||
inc eax
|
||||
.calc_bpp:
|
||||
mul [PNG_info.Bit_depth]
|
||||
.palette:
|
||||
mov ecx,eax ; in bits
|
||||
shr eax,3 ; in bytes
|
||||
test eax,eax
|
||||
jnz .noz
|
||||
inc eax
|
||||
.noz:
|
||||
mov [png_bpp],eax
|
||||
mov eax,[PNG_info.Width]
|
||||
mov ebp,eax
|
||||
imul ecx
|
||||
shr eax,3
|
||||
test eax,eax
|
||||
jnz .noz2
|
||||
inc eax
|
||||
.noz2:
|
||||
mov [sline_len],eax ; scanline length
|
||||
push edi
|
||||
and [Flags],not 1
|
||||
mov ecx,[PNG_info.Height]
|
||||
.scanline:
|
||||
; Msg 9,1
|
||||
push ecx
|
||||
lodsb
|
||||
movzx eax,al
|
||||
cmp eax,5
|
||||
jb .f_ok
|
||||
mov eax,5
|
||||
.f_ok:
|
||||
inc dword[filters+eax*4]
|
||||
jmp dword[FiltCall+eax*4]
|
||||
.nofilt:
|
||||
mov dl,[PNG_info.Color_type]
|
||||
cmp dl,3
|
||||
jne .nopalette
|
||||
lodsb
|
||||
mov [cur_byte],eax
|
||||
mov [bits],8
|
||||
mov ecx,ebp
|
||||
.pixel:
|
||||
push ecx
|
||||
movzx ecx,[PNG_info.Bit_depth]
|
||||
call rb_png
|
||||
push esi
|
||||
lea esi,[eax+eax*2]
|
||||
add esi,PNG_info.Palette
|
||||
call PngStore
|
||||
pop esi
|
||||
pop ecx
|
||||
loop .pixel
|
||||
cmp [bits],8
|
||||
jne .lp
|
||||
dec esi
|
||||
.lp:
|
||||
pop ecx
|
||||
loop .sl
|
||||
jmp .sl2
|
||||
.sl:
|
||||
;//
|
||||
MV equ 1
|
||||
; mov eax,ecx
|
||||
; and eax,1 shl MOVE_SLINE_LEV-1
|
||||
; jnz .scanline
|
||||
;stop
|
||||
if MV eq 0
|
||||
push ecx
|
||||
mov ecx,edi
|
||||
sub ecx,esi
|
||||
sub [outp],esi
|
||||
mov edi,output
|
||||
add [outp],edi
|
||||
rep movsb
|
||||
mov esi,output
|
||||
pop ecx
|
||||
pop eax
|
||||
push [outp]
|
||||
end if
|
||||
;;//
|
||||
jmp .scanline
|
||||
.sl2:
|
||||
;//
|
||||
; call MoveScanline
|
||||
sub edi,[outp]
|
||||
;//
|
||||
; sub edi,[esp]
|
||||
pop eax
|
||||
ret
|
||||
|
||||
.nopalette:
|
||||
test dl,2
|
||||
jz .notriple1
|
||||
.__:
|
||||
mov ecx,[PNG_info.Width]
|
||||
.RGBcp:
|
||||
call PngStore
|
||||
add esi,[png_bpp]
|
||||
loop .RGBcp
|
||||
jmp .lp
|
||||
.notriple1:
|
||||
test dl,dl
|
||||
jz .gray
|
||||
cmp dl,4
|
||||
jne .__
|
||||
; Msg 31
|
||||
; ud2
|
||||
.gray:
|
||||
; stop
|
||||
push ecx
|
||||
mov ecx,[PNG_info.Width]
|
||||
mov [bits],8
|
||||
lodsb
|
||||
mov [cur_byte],eax
|
||||
.gray2:
|
||||
push ecx
|
||||
movzx ecx,[PNG_info.Bit_depth]
|
||||
push ecx
|
||||
call rb_png
|
||||
pop ecx
|
||||
cmp ecx,8
|
||||
jbe .lo
|
||||
add esi,2
|
||||
shr eax,8
|
||||
jmp .stsb
|
||||
.lo:
|
||||
neg ecx
|
||||
add ecx,8
|
||||
shl eax,cl
|
||||
.stsb:
|
||||
mov ecx,3
|
||||
rep stosb
|
||||
pop ecx
|
||||
loop .gray2
|
||||
dec esi
|
||||
pop ecx
|
||||
jmp .lp
|
||||
|
||||
Filt_sub:
|
||||
; dps '-'
|
||||
mov ecx,[sline_len]
|
||||
sub ecx,[png_bpp]
|
||||
push esi edi
|
||||
mov edi,esi
|
||||
add edi,[png_bpp]
|
||||
.scan: ; esi - previous, edi - current
|
||||
lodsb
|
||||
add [edi],al
|
||||
inc edi
|
||||
loop .scan
|
||||
|
||||
pop edi esi
|
||||
; dps '-'
|
||||
jmp PngFilter.nofilt
|
||||
|
||||
Filt_up:
|
||||
cmp ecx,[PNG_info.Height]
|
||||
je PngFilter.nofilt
|
||||
push esi edi
|
||||
mov ecx,[sline_len]
|
||||
mov edi,esi
|
||||
sub esi,ecx
|
||||
dec esi
|
||||
jmp Filt_sub.scan
|
||||
|
||||
Filt_av:
|
||||
pusha
|
||||
mov ecx,[sline_len]
|
||||
mov ebp,[PNG_info.Height]
|
||||
mov edx,[png_bpp] ; edx-raw
|
||||
neg edx
|
||||
mov ebx,ecx
|
||||
sub ebx,[png_bpp]
|
||||
mov edi,esi
|
||||
sub esi,ecx
|
||||
dec esi ; esi-prior
|
||||
.lpavg:
|
||||
xor eax,eax
|
||||
cmp [esp+24h],ebp
|
||||
je .1stl
|
||||
movzx eax,byte[esi]
|
||||
.1stl:
|
||||
cmp ecx,ebx
|
||||
ja .leftbad
|
||||
push ecx
|
||||
movzx ecx,byte[edi+edx]
|
||||
add eax,ecx
|
||||
pop ecx
|
||||
.leftbad:
|
||||
shr eax,1
|
||||
add [edi],al
|
||||
inc esi
|
||||
inc edi
|
||||
loop .lpavg
|
||||
popa
|
||||
jmp PngFilter.nofilt
|
||||
|
||||
Filt_paeth:
|
||||
pusha
|
||||
mov ecx,[sline_len]
|
||||
mov edx,[png_bpp]
|
||||
neg edx
|
||||
lea ebp,[ecx+edx] ; left edge
|
||||
mov edi,esi
|
||||
sub esi,ecx
|
||||
dec esi
|
||||
.lpaeth:
|
||||
push ecx
|
||||
movzx eax,byte[edi+edx]
|
||||
movzx ebx,byte[esi]
|
||||
movzx ecx,byte[esi+edx]
|
||||
push eax
|
||||
mov eax,[esp+28h]
|
||||
cmp eax,[PNG_info.Height] ; 1st line
|
||||
jne .no1stlineok
|
||||
xor ebx,ebx
|
||||
xor ecx,ecx
|
||||
.no1stlineok:
|
||||
pop eax
|
||||
cmp [esp],ebp ; ecx
|
||||
jbe .leftok ; x-bpp>=0
|
||||
xor eax,eax
|
||||
xor ecx,ecx
|
||||
.leftok:
|
||||
pusha ; eax-28, ebx-16, ecx-24
|
||||
lea edx,[eax+ebx]
|
||||
sub edx,ecx ; p=edx
|
||||
sub eax,edx ; pa := abs(p - a)
|
||||
jge .eaxp
|
||||
neg eax
|
||||
.eaxp:
|
||||
sub ebx,edx ; pb := abs(p - b)
|
||||
jge .ebxp
|
||||
neg ebx
|
||||
.ebxp:
|
||||
sub ecx,edx ; pc := abs(p - c)
|
||||
jge .ecxp
|
||||
neg ecx
|
||||
.ecxp:
|
||||
cmp eax,ebx
|
||||
ja .noa
|
||||
cmp eax,ecx
|
||||
jbe .ex ; pa-min
|
||||
.noa:
|
||||
cmp ebx,ecx
|
||||
ja .nob
|
||||
mov eax,[esp+16]
|
||||
jmp .ex2
|
||||
.nob:
|
||||
mov eax,[esp+24]
|
||||
.ex2:
|
||||
mov [esp+28],eax
|
||||
.ex:
|
||||
popa
|
||||
add [edi],al
|
||||
inc esi
|
||||
inc edi
|
||||
pop ecx
|
||||
loop .lpaeth
|
||||
popa
|
||||
jmp PngFilter.nofilt
|
||||
|
||||
rb_png: ; eax-dest; ecx-count
|
||||
push ecx
|
||||
xor eax,eax
|
||||
.shift:
|
||||
rol byte[cur_byte],1
|
||||
rcl eax,1
|
||||
.dec:
|
||||
dec [bits]
|
||||
jnz .loop1
|
||||
.push:
|
||||
push dword[esi]
|
||||
pop [cur_byte]
|
||||
mov [bits],8
|
||||
inc esi
|
||||
.loop1:
|
||||
loop .shift
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
PngStore:
|
||||
push esi
|
||||
cmp [PNG_info.Bit_depth],8
|
||||
jbe .lo
|
||||
add esi,3
|
||||
.lo:
|
||||
if ~ SYS eq win
|
||||
mov esi,[esi]
|
||||
bswap esi
|
||||
shr esi,8
|
||||
mov [edi],esi
|
||||
add edi,3
|
||||
else
|
||||
movsw
|
||||
movsb
|
||||
end if
|
||||
pop esi
|
||||
ret
|
||||
|
||||
FiltStats:
|
||||
pusha
|
||||
xor ebx,ebx
|
||||
mov edx,23
|
||||
mov ecx,6
|
||||
.lp:
|
||||
push ecx edx
|
||||
Msg edx
|
||||
mov eax,[filters+ebx*4]
|
||||
DebugPrintDec
|
||||
pop edx ecx
|
||||
inc edx
|
||||
inc ebx
|
||||
loop .lp
|
||||
Newline
|
||||
popa
|
||||
ret
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
; @RCHER system-dependent and other stuff
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
|
||||
OpenFile:
|
||||
mov [outp],output
|
||||
mov esi,area
|
||||
and [Finfo.block],0
|
||||
if SYS eq win
|
||||
invoke CreateFile, filename, GENERIC_READ, FILE_SHARE_READ, NULL, \
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL
|
||||
inc eax
|
||||
test eax,eax
|
||||
jz .ex
|
||||
dec eax
|
||||
mov [hnd],eax
|
||||
invoke GetFileSize,eax,NULL
|
||||
.ex:
|
||||
mov ebx,eax
|
||||
mov [filesize],eax
|
||||
else
|
||||
mcall 58,Finfo
|
||||
mov [filesize],ebx
|
||||
end if
|
||||
ret
|
||||
|
||||
ResetFile:
|
||||
and [file_count],0
|
||||
mov eax,[arc_base]
|
||||
xor ebx,ebx
|
||||
mov esi,area
|
||||
call FileSeek
|
||||
ret
|
||||
|
||||
|
||||
FileSeek:
|
||||
; eax - offset
|
||||
; esi - current pointer (in memory!)
|
||||
; ebx - translation method: 0 - beginning, 1 - current, 2 - end
|
||||
push eax ecx edx
|
||||
mov edx,[Finfo.block]
|
||||
imul edx,BSIZE
|
||||
sub esi,BUFPTR
|
||||
add esi,edx
|
||||
cmp ebx,1
|
||||
je .cur
|
||||
jb .begin
|
||||
mov esi,[filesize]
|
||||
not eax
|
||||
.cur:
|
||||
add eax,esi
|
||||
.begin:
|
||||
mov ecx,BSIZE
|
||||
xor edx,edx
|
||||
div ecx
|
||||
lea esi,[BUFPTR+edx]
|
||||
mov [Finfo.block],eax
|
||||
if SYS eq win
|
||||
mul ecx
|
||||
invoke SetFilePointer,[hnd],eax,NULL,FILE_BEGIN
|
||||
invoke ReadFile,[hnd],area,INBUF, os_work, NULL
|
||||
; add [byte_count],area
|
||||
else
|
||||
; pregs
|
||||
; wait
|
||||
mov [Finfo.count],BUFSIZE*2
|
||||
mcall 58,Finfo
|
||||
; mov [byte_count],area+INBUF
|
||||
end if
|
||||
pop edx ecx eax
|
||||
ret
|
||||
|
||||
macro QueryFile
|
||||
{
|
||||
local ex
|
||||
if SYS eq win
|
||||
invoke GetOpenFileName,ofstruc
|
||||
else
|
||||
opendialog draw_window,QFok,QFcanc,filename
|
||||
QFok:
|
||||
xor eax,eax
|
||||
jmp ex
|
||||
ret
|
||||
QFcanc:
|
||||
mov eax,1
|
||||
end if
|
||||
ex:
|
||||
}
|
||||
|
||||
RunViewer:
|
||||
test [Flags],PNG_MODE
|
||||
jz .ex
|
||||
if SYS eq win
|
||||
mov eax,[PNG_info.Width]
|
||||
call int2str
|
||||
invoke WritePrivateProfileString,ini_sec,ini_rwidth,os_work,ini_file
|
||||
mov eax,[PNG_info.Height]
|
||||
call int2str
|
||||
invoke WritePrivateProfileString,ini_sec,ini_rheight,os_work,ini_file
|
||||
invoke CreateProcess,NULL,iview_cmd,NULL,NULL,TRUE,\
|
||||
NORMAL_PRIORITY_CLASS,NULL,NULL,suinfo,pinfo
|
||||
invoke WaitForInputIdle,dword[pinfo],0xFFFFFFFF
|
||||
invoke FindWindowEx, NULL,NULL,NULL,rawwnd_txt
|
||||
invoke FindWindowEx, eax,NULL,NULL,ok_txt
|
||||
invoke SendMessage,eax,BM_CLICK,NULL,NULL
|
||||
else
|
||||
test [Flags],THREAD_YES
|
||||
jnz .ex
|
||||
mcall 51,1,thread,MEMORY
|
||||
mov [child],eax
|
||||
end if
|
||||
.ex:
|
||||
ret
|
||||
|
||||
if SYS eq win
|
||||
int2str:
|
||||
; in: eax - number
|
||||
; out: formatted string -> os_work
|
||||
invoke wsprintf,os_work,fmt_str,eax
|
||||
add esp,12
|
||||
ret
|
||||
|
||||
rawwnd_txt db 'Set RAW open parameters',0
|
||||
ok_txt db 'OK',0
|
||||
ini_sec db 'RAW',0
|
||||
ini_rwidth db 'RWidth',0
|
||||
ini_rheight db 'RHeight',0
|
||||
ini_file db "C:\Program Files\IrfanView\i_view32.ini",0
|
||||
fmt_str db "%d",0
|
||||
iview_cmd db '"C:\Program Files\IrfanView\i_view32.exe"'
|
||||
db ' "D:\Ivushkin\projects\zip\output.raw"',0
|
||||
filt_str:
|
||||
db 'Pictures (*.png)',0,'*.png',0
|
||||
db 'Archives (*.zip;*.*gz)',0,'*.zip;*.*gz',0
|
||||
db 'All files (*.*)',0,'*.*',0,0
|
||||
|
||||
suinfo STARTUPINFO
|
||||
pinfo PROCESS_INFORMATION
|
||||
cpstruc:
|
||||
ofstruc:
|
||||
dd ofstruc_end-ofstruc
|
||||
dd NULL
|
||||
dd NULL
|
||||
dd filt_str
|
||||
dd NULL
|
||||
dd NULL
|
||||
dd 0
|
||||
dd filename
|
||||
dd 256
|
||||
dd NULL
|
||||
dd 0
|
||||
dd NULL
|
||||
dd NULL
|
||||
dd NULL
|
||||
dw NULL
|
||||
dw NULL
|
||||
dd NULL
|
||||
dd NULL
|
||||
dd NULL
|
||||
dd NULL
|
||||
dd NULL
|
||||
dd NULL
|
||||
dd NULL
|
||||
ofstruc_end:
|
||||
|
||||
else
|
||||
mov ebx,-1
|
||||
mov ecx,ebx
|
||||
mov edx,[PNG_info.Width]
|
||||
add edx,10
|
||||
mov esi,[PNG_info.Width]
|
||||
add esi,30
|
||||
mcall 67
|
||||
mcall 7,outfile,[outfile.size],10 shl 16+15
|
||||
.ex:
|
||||
ret
|
||||
|
||||
MIN_WIDTH equ 300
|
||||
thread:
|
||||
.red:
|
||||
mcall 12,1
|
||||
mov ebx,[PNG_info.Width]
|
||||
cmp ebx,MIN_WIDTH
|
||||
jae .more
|
||||
mov ebx,MIN_WIDTH
|
||||
.more:
|
||||
add ebx,20
|
||||
mov ecx,[PNG_info.Height]
|
||||
add ecx,30
|
||||
mcall 0,,,0x3808080
|
||||
mcall 4,<5,7>,0x10f0f0f0,filename,255
|
||||
mov ecx,[PNG_info.Width]
|
||||
shl ecx,16
|
||||
add ecx,[PNG_info.Height]
|
||||
mcall 7,png_image,,10 shl 16+25
|
||||
mcall 12,2
|
||||
.still:
|
||||
mcall 10
|
||||
cmp eax,1
|
||||
je .red
|
||||
cmp eax,2
|
||||
jne .nokey
|
||||
mcall 2
|
||||
cmp ah,27 ; Esc - close
|
||||
je .close
|
||||
jmp .still
|
||||
.nokey:
|
||||
cmp eax,3
|
||||
jne .still
|
||||
.close:
|
||||
and [child],0
|
||||
mcall -1
|
||||
|
||||
KillViewer:
|
||||
pusha
|
||||
mov edi,[child]
|
||||
test edi,edi
|
||||
jz .noth
|
||||
mcall 9,os_work,-1
|
||||
mov ecx,eax
|
||||
.fchild:
|
||||
push ecx
|
||||
mcall 9,os_work
|
||||
cmp edi,[ebx+30]
|
||||
jne .lp
|
||||
mov ecx,[esp]
|
||||
mcall 18,2
|
||||
pop ecx
|
||||
jmp .noth
|
||||
.lp:
|
||||
pop ecx
|
||||
loop .fchild
|
||||
.noth:
|
||||
popa
|
||||
ret
|
||||
|
||||
macro CmdLine
|
||||
{
|
||||
mov esi,PARAM_PTR
|
||||
.parse:
|
||||
lodsb
|
||||
|
||||
test al,al
|
||||
jnz .noend
|
||||
or [Flags],STAY_MODE
|
||||
jmp red
|
||||
.noend:
|
||||
cmp al,' '
|
||||
je .stay
|
||||
cmp al,'/'
|
||||
jne .yespar
|
||||
mov ecx,255
|
||||
dec esi
|
||||
mov edi,filename
|
||||
xor al,al
|
||||
rep stosb
|
||||
mov ecx,255
|
||||
mov edi,filename
|
||||
rep movsb
|
||||
jmp again
|
||||
.yespar:
|
||||
cmp al,'N'
|
||||
jne .nonum
|
||||
call get_6ASCII_num
|
||||
.fnum:
|
||||
mov [FileNum],eax
|
||||
jmp .parse
|
||||
.nonum:
|
||||
cmp al,'n'
|
||||
jne .nonum2
|
||||
lodsd
|
||||
jmp .fnum
|
||||
.nonum2:
|
||||
cmp al,'s'
|
||||
jne .nostay
|
||||
.stay:
|
||||
or [Flags],STAY_MODE
|
||||
jmp .parse
|
||||
.nostay:
|
||||
cmp al,'i'
|
||||
jne .noclPID
|
||||
lodsd
|
||||
mov [clientPID],eax
|
||||
or [Flags],IPC_MODE
|
||||
jmp .parse
|
||||
.noclPID:
|
||||
cmp al,'R'
|
||||
jne .noraw
|
||||
or [Flags],RAW_MODE
|
||||
jmp .parse
|
||||
.noraw:
|
||||
cmp al,'q'
|
||||
jne .noofs
|
||||
lodsd
|
||||
.fofs:
|
||||
mov [arc_base],eax
|
||||
jmp .parse
|
||||
.noofs:
|
||||
cmp al,'Q'
|
||||
jne .noofs2
|
||||
call get_6ASCII_num
|
||||
jmp .fofs
|
||||
.noofs2:
|
||||
jmp .parse
|
||||
|
||||
get_6ASCII_num:
|
||||
; in: esi - str ptr, out: eax - num
|
||||
xor edx,edx
|
||||
mov ebx,10
|
||||
mov ecx,6
|
||||
.lp:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al,'0'
|
||||
imul edx,ebx
|
||||
add edx,eax
|
||||
loop .lp
|
||||
mov eax,edx
|
||||
ret
|
||||
}
|
||||
|
||||
StartPad:
|
||||
mcall 19,editorcmd,dumpfile
|
||||
ret
|
||||
|
||||
editorcmd db 'TINYPAD '
|
||||
end if
|
||||
@@ -0,0 +1,442 @@
|
||||
;
|
||||
; ARP Status Monitor
|
||||
;
|
||||
; Compile with FASM for Menuet
|
||||
;
|
||||
; This program displays the ARP table, and it's settings
|
||||
|
||||
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
|
||||
dd 0x00000000 ; reserved=no extended header
|
||||
include 'lang.inc'
|
||||
include 'macros.inc'
|
||||
|
||||
START: ; start of execution
|
||||
call draw_window ; at first, draw the window
|
||||
|
||||
still:
|
||||
mov eax,23 ; wait here for event
|
||||
mov ebx,200 ; Time out after 2s
|
||||
int 0x40
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
jz red
|
||||
cmp eax,2 ; key in buffer ?
|
||||
jz key
|
||||
cmp eax,3 ; button in buffer ?
|
||||
jz button
|
||||
|
||||
; read the stack status data, and write it to the screen buffer
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 200
|
||||
int 0x40
|
||||
|
||||
push eax
|
||||
mov ebx, text + 24
|
||||
call printhex
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 201
|
||||
int 0x40
|
||||
|
||||
mov ebx, text + 64
|
||||
call printhex
|
||||
|
||||
|
||||
; Fill the table with blanks
|
||||
mov edx, text + 160
|
||||
doBlank:
|
||||
mov esi, blank
|
||||
mov edi, edx
|
||||
mov ecx, 40
|
||||
rep movsb
|
||||
add edx, 40
|
||||
|
||||
cmp edx, text + 560
|
||||
jne doBlank
|
||||
|
||||
pop ecx ; The number of entries
|
||||
|
||||
mov ebx, text+ 160 +1 ; the position for the first IP address line
|
||||
|
||||
xor edx, edx ; edx is index into the ARP table
|
||||
|
||||
cmp ecx, 10
|
||||
jle show_entries
|
||||
mov ecx, 10
|
||||
|
||||
|
||||
; The following code is not very efficient; Sorry about that.
|
||||
; ARPSTAT is a debugging tool, so I didn't want to put much effort in
|
||||
show_entries:
|
||||
; Ecx now holds the number of entries to populate.
|
||||
; Ebx holds the place to put the data
|
||||
; edx is a counter
|
||||
cmp ecx, 0
|
||||
je red
|
||||
|
||||
push ecx
|
||||
push edx
|
||||
push ebx
|
||||
|
||||
|
||||
; select the arp table entry (in edx)
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 202
|
||||
int 0x40
|
||||
|
||||
; Read the IP address
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 203
|
||||
int 0x40
|
||||
|
||||
; IP in eax. Get the address to put it back
|
||||
pop ebx
|
||||
push ebx
|
||||
|
||||
call writeDecimal ; Extract 1 byte from eax, store it in string
|
||||
add ebx, 4
|
||||
shr eax, 8
|
||||
call writeDecimal ; Extract 1 byte from eax, store it in string
|
||||
add ebx, 4
|
||||
shr eax, 8
|
||||
call writeDecimal ; Extract 1 byte from eax, store it in string
|
||||
add ebx, 4
|
||||
shr eax, 8
|
||||
call writeDecimal ; Extract 1 byte from eax, store it in string
|
||||
|
||||
add ebx, 4
|
||||
|
||||
; Now display the 6 byte MAC
|
||||
push ebx
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 204
|
||||
int 0x40
|
||||
pop ebx
|
||||
|
||||
mov ecx, eax
|
||||
|
||||
shr eax, 4
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 12
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 8
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 20
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 16
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 28
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 24
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
|
||||
push ebx
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 205
|
||||
int 0x40
|
||||
pop ebx
|
||||
|
||||
mov ecx, eax
|
||||
|
||||
shr eax, 4
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 12
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 8
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
|
||||
; Now display the stat field
|
||||
inc ebx
|
||||
inc ebx
|
||||
push ebx
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 206
|
||||
int 0x40
|
||||
pop ebx
|
||||
|
||||
mov ecx, eax
|
||||
|
||||
shr eax, 4
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 12
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 8
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
|
||||
; Now display the TTL field (this is intel word format)
|
||||
inc ebx
|
||||
inc ebx
|
||||
push ebx
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 207
|
||||
int 0x40
|
||||
pop ebx
|
||||
|
||||
mov ecx, eax
|
||||
|
||||
shr eax, 12
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 8
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 4
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
|
||||
|
||||
pop ebx
|
||||
add ebx, 40
|
||||
pop edx
|
||||
inc edx
|
||||
pop ecx
|
||||
dec ecx
|
||||
jmp show_entries
|
||||
|
||||
red: ; redraw
|
||||
call draw_window
|
||||
jmp still
|
||||
|
||||
key: ; Keys are not valid at this part of the
|
||||
mov eax,2 ; loop. Just read it and ignore
|
||||
int 0x40
|
||||
jmp still
|
||||
|
||||
button: ; button
|
||||
mov eax,17 ; get id
|
||||
int 0x40
|
||||
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jnz still
|
||||
|
||||
mov eax,0xffffffff ; close this program
|
||||
int 0x40
|
||||
|
||||
jmp still
|
||||
|
||||
|
||||
|
||||
writeDecimal:
|
||||
pusha
|
||||
and eax, 0xff
|
||||
mov ecx, eax
|
||||
mov dl, 100
|
||||
div dl
|
||||
mov cl, ah
|
||||
add al, '0'
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
mov dl, 10
|
||||
div dl
|
||||
mov cl, ah
|
||||
add al, '0'
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov al, ah
|
||||
add al, '0'
|
||||
mov [ebx], al
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* 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+280 ; [x start] *65536 + [x size]
|
||||
mov ecx,100*65536+270 ; [y start] *65536 + [y size]
|
||||
mov edx,0x03224466 ; color of work area RRGGBB
|
||||
mov esi,0x00334455 ; color of grab bar RRGGBB,8->color gl
|
||||
mov edi,0x00ddeeff ; 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,0x00ffffff ; color of text RRGGBB
|
||||
mov edx,labelt ; pointer to text beginning
|
||||
mov esi,labellen-labelt ; text length
|
||||
int 0x40
|
||||
|
||||
; Re-draw the screen text
|
||||
cld
|
||||
mov ebx,25*65536+35 ; draw info text with function 4
|
||||
mov ecx,0xffffff
|
||||
mov edx,text
|
||||
mov esi,40
|
||||
newline:
|
||||
mov eax,4
|
||||
int 0x40
|
||||
add ebx,16
|
||||
add edx,40
|
||||
cmp [edx],byte 'x'
|
||||
jnz newline
|
||||
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,2 ; 2, end of draw
|
||||
int 0x40
|
||||
|
||||
ret
|
||||
|
||||
; Taken from PS.ASM
|
||||
printhex:
|
||||
; number in eax
|
||||
; print to ebx
|
||||
; xlat from hextable
|
||||
pusha
|
||||
mov esi, ebx
|
||||
add esi, 8
|
||||
mov ebx, hextable
|
||||
mov ecx, 8
|
||||
phex_loop:
|
||||
mov edx, eax
|
||||
and eax, 15
|
||||
xlatb
|
||||
mov [esi], al
|
||||
mov eax, edx
|
||||
shr eax, 4
|
||||
dec esi
|
||||
loop phex_loop
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
text:
|
||||
db ' Number of ARP entries: xxxxxxxx '
|
||||
db ' Maximum # of entries : xxxxxxxx '
|
||||
db ' '
|
||||
db ' IP Address MAC Stat TTL '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db 'x <- END MARKER, DONT DELETE '
|
||||
|
||||
|
||||
blank:
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
|
||||
|
||||
labelt:
|
||||
db 'ARP Table ( First 10 Entries )'
|
||||
labellen:
|
||||
|
||||
hextable db '0123456789ABCDEF'
|
||||
|
||||
|
||||
I_END:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm arpstat.asm arpstat
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm arpstat.asm arpstat
|
||||
@pause
|
||||
@@ -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
|
||||
@@ -0,0 +1,157 @@
|
||||
;
|
||||
; BCD CLOCK
|
||||
;
|
||||
; Compile with FASM for Menuet
|
||||
;
|
||||
;
|
||||
|
||||
use32
|
||||
|
||||
org 0x0
|
||||
|
||||
db 'MENUET01'
|
||||
dd 0x01
|
||||
dd START
|
||||
dd I_END
|
||||
dd 0x100000
|
||||
dd 0x7fff0
|
||||
dd 0x0 , 0x0
|
||||
|
||||
include "lang.inc"
|
||||
include "macros.inc"
|
||||
|
||||
|
||||
START:
|
||||
|
||||
call drawwindow
|
||||
|
||||
still:
|
||||
|
||||
|
||||
mov eax,23 ; wait for timeout
|
||||
mov ebx,50
|
||||
int 0x40
|
||||
|
||||
cmp eax,1 ; redraw ?
|
||||
je red
|
||||
|
||||
cmp eax,3 ; button in buffer ?
|
||||
je button
|
||||
|
||||
call drawclock
|
||||
|
||||
jmp still
|
||||
|
||||
red: ; redraw
|
||||
call drawwindow
|
||||
jmp still
|
||||
|
||||
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
|
||||
|
||||
drawclock:
|
||||
|
||||
mov eax,3 ; get time
|
||||
int 0x40
|
||||
bswap eax
|
||||
shr eax,8
|
||||
mov edi,dg1
|
||||
mov ecx,6
|
||||
dgtomem:
|
||||
push eax
|
||||
and al,15
|
||||
mov [edi],al
|
||||
inc edi
|
||||
pop eax
|
||||
shr eax,4
|
||||
loop dgtomem
|
||||
mov ebx,74*65536+10
|
||||
mov edi,dg1
|
||||
digitlp:
|
||||
mov ecx,30*65536+10
|
||||
xor esi,esi
|
||||
plotlp:
|
||||
xor edx,edx
|
||||
test byte[edi],8
|
||||
je nobit
|
||||
mov edx,0x00ff0000
|
||||
nobit:
|
||||
mov eax,13 ; plot 8,4,2,1
|
||||
int 0x40
|
||||
add ecx,12*65536
|
||||
shl byte[edi],1
|
||||
inc esi
|
||||
cmp esi,4
|
||||
jne plotlp
|
||||
shr byte[edi],4
|
||||
mov edx,0x00880040
|
||||
mov eax,13 ; draw digit box
|
||||
int 0x40
|
||||
pusha
|
||||
mov edx,ebx
|
||||
and edx,0xffff0000
|
||||
shr ecx,16
|
||||
or edx,ecx
|
||||
add edx,3*65536+2
|
||||
mov ebx,0x00010100
|
||||
mov ecx,[edi]
|
||||
mov esi,0x00ffffff
|
||||
mov eax,47 ; display decimal
|
||||
int 0x40
|
||||
popa
|
||||
sub ebx,12*65536
|
||||
inc edi
|
||||
cmp edi,dg1+6
|
||||
jne digitlp
|
||||
ret
|
||||
|
||||
|
||||
drawwindow:
|
||||
|
||||
|
||||
mov eax,12
|
||||
mov ebx,1 ; start redraw
|
||||
int 0x40
|
||||
|
||||
mov eax,0 ; window
|
||||
mov ebx,100*65536+100
|
||||
mov ecx,100*65536+100
|
||||
mov edx,0x83400088
|
||||
mov esi,0x805080d0
|
||||
mov edi,0x000000ff
|
||||
int 0x40
|
||||
|
||||
call drawclock
|
||||
|
||||
mov eax,4 ; text
|
||||
mov ebx,8*65536+8
|
||||
mov ecx,0x10ddeeff
|
||||
mov edx,title
|
||||
mov esi,title-titlend
|
||||
int 0x40
|
||||
|
||||
|
||||
mov eax,12
|
||||
mov ebx,2 ; end redraw
|
||||
int 0x40
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
title:
|
||||
db 'BCD Clock'
|
||||
titlend:
|
||||
|
||||
dg1: db ?
|
||||
|
||||
I_END:
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm bcdclk.asm bcdclk
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm bcdclk.asm bcdclk
|
||||
@pause
|
||||
@@ -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
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,691 @@
|
||||
; BGIFONT.INC v1.0 beta
|
||||
;
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
;
|
||||
; Created: December 16, 2004
|
||||
;
|
||||
; Last changed: February 2, 2005
|
||||
;
|
||||
; Compile with FASM
|
||||
|
||||
; BGI constants
|
||||
BGI_NODRAW equ 0x10000
|
||||
BGI_ITALIC equ 0x20000
|
||||
BGI_BOLD equ 0x40000
|
||||
BGI_HALEFT equ 0x0
|
||||
BGI_HARIGHT equ 0x1000
|
||||
BGI_HACENTER equ 0x2000
|
||||
BGI_VABOTTOM equ 0x0
|
||||
BGI_VATOP equ 0x4000
|
||||
BGI_VACENTER equ 0x8000
|
||||
|
||||
BGI_FREE equ 0x80000000
|
||||
BGI_HAMASK equ 0x3000
|
||||
BGI_VAMASK equ 0xc000
|
||||
|
||||
; Freetext structure
|
||||
struc BGIfree FontName,XY,Angle,ScaleX,ScaleY,StrPtr,StrLen,Color,Align
|
||||
{
|
||||
dd FontName ;0
|
||||
dd XY ;4
|
||||
dd Angle ;8
|
||||
dd ScaleX ;12
|
||||
dd ScaleY ;16
|
||||
dd StrPtr ;20
|
||||
dd StrLen ;24
|
||||
dd Color ;28
|
||||
dd Align ;32
|
||||
}
|
||||
|
||||
; font options structure
|
||||
struc BGIrec FontName,CharsCount,FirstChar,UpperMargin,LowerMargin,\
|
||||
Widths,FirstData,EOF,font_data
|
||||
{
|
||||
.FontName dd ? ; 0
|
||||
.CharsCount db ? ; 4
|
||||
.FirstChar db ? ; 5
|
||||
.UpperMargin db ? ; 6
|
||||
.LowerMargin db ? ; 7
|
||||
.Widths dd ? ; 8
|
||||
.FirstData dd ? ; 12
|
||||
.EOF dd ? ; 16
|
||||
.font_data dd ? ; 20 follows (Offsets)
|
||||
}
|
||||
|
||||
macro BGIfont_GetID
|
||||
{
|
||||
call _BGIfont_GetID
|
||||
}
|
||||
|
||||
macro BGIfont_Prepare
|
||||
{
|
||||
call _BGIfont_Prepare
|
||||
}
|
||||
|
||||
macro BGIfont_Freetext
|
||||
{
|
||||
call _BGIfont_Freetext
|
||||
}
|
||||
|
||||
macro BGIfont_Outtext
|
||||
{
|
||||
call _BGIfont_Outtext
|
||||
}
|
||||
|
||||
macro _FI name,_size
|
||||
{
|
||||
db name
|
||||
if BGI_LEVEL eq KERNEL
|
||||
dw _size
|
||||
end if
|
||||
}
|
||||
|
||||
BGIfont_names:
|
||||
_FI 'LCOM',11485 ;7
|
||||
_FI 'EURO',8117 ;5
|
||||
_FI 'GOTH',13816 ;6
|
||||
_FI 'LITT',3596 ;8
|
||||
_FI 'TRIP',11932 ;14
|
||||
_FI 'SCRI',8490 ;11
|
||||
_FI 'SMAL',4162 ;13
|
||||
_FI 'TSCR',12134 ;15
|
||||
_FI 'SANS',8453 ;10
|
||||
_FI 'SIMP',9522 ;12
|
||||
BGIfont_names_end:
|
||||
|
||||
macro BGIfont_Init
|
||||
{
|
||||
; in: ecx - number of fonts to load;
|
||||
; esi-> _FI structure
|
||||
; edi-> where to load
|
||||
push edi
|
||||
if BGI_LEVEL eq KERNEL
|
||||
mov edi,0x40000
|
||||
end if
|
||||
.nfont:
|
||||
mov edx,[esi]
|
||||
if BGI_LEVEL eq KERNEL
|
||||
movzx ebx,word[esi+4]
|
||||
mov [BGIfont_Prepare.okflag],'N'
|
||||
end if
|
||||
call _BGIfont_Prepare
|
||||
if ~ BGI_LEVEL eq KERNEL
|
||||
add esi,4
|
||||
else
|
||||
push esi
|
||||
test eax,eax
|
||||
jz .fail
|
||||
mov [BGIfont_Prepare.okflag],'*'
|
||||
.fail:
|
||||
mov esi,BGIfont_Prepare.font
|
||||
call boot_log
|
||||
pop esi
|
||||
add esi,6
|
||||
end if
|
||||
loop .nfont
|
||||
dph2 _BGI_BOLD,300,550
|
||||
; movzx edi,byte[0x40000]
|
||||
pop edi
|
||||
}
|
||||
|
||||
BGIfont_get2head:
|
||||
shr ecx,28 ; font #
|
||||
sub ecx,4
|
||||
jb .exit2 ; invalid #
|
||||
mov edi,[BGIfont_Ptr]
|
||||
inc edi
|
||||
cmp cl,[edi-1]
|
||||
jae .exit2 ; # too large
|
||||
jecxz .ex
|
||||
.fnext:
|
||||
mov edi,[edi+16]
|
||||
loop .fnext
|
||||
jmp .ex
|
||||
.exit2:
|
||||
xor edi,edi
|
||||
.ex:
|
||||
ret
|
||||
|
||||
BGIfont_GetName:
|
||||
; in: ecx-fontID;
|
||||
; out: edx-font name.
|
||||
call BGIfont_get2head
|
||||
xor edx,edx
|
||||
test edi,edi
|
||||
jz .ex
|
||||
mov edx,[edi]
|
||||
.ex:
|
||||
ret
|
||||
|
||||
macro dps2 _str
|
||||
{
|
||||
if ~ BGI_LEVEL eq KERNEL
|
||||
if LOAD_MSG eq 1
|
||||
dps _str
|
||||
end if
|
||||
else
|
||||
pusha
|
||||
mov esi,BGIfont_Prepare.okflag
|
||||
mov byte[esi], _str
|
||||
call boot_log
|
||||
popa
|
||||
end if
|
||||
}
|
||||
|
||||
macro dph2 num,x,y
|
||||
{
|
||||
if BGI_LEVEL eq KERNEL
|
||||
pusha
|
||||
mov eax,0x00080100
|
||||
mov ebx,num
|
||||
mov ecx,x shl 16+y
|
||||
mov edx,0xFF0000
|
||||
call display_number
|
||||
popa
|
||||
end if
|
||||
}
|
||||
|
||||
_BGIfont_GetID:
|
||||
; in: edx-font name;
|
||||
; out: eax-fontID, edi->BGIrec
|
||||
push ecx edi
|
||||
mov edi,[BGIfont_Ptr]
|
||||
movzx ecx,byte[edi] ; ecx-font count
|
||||
mov eax,ecx
|
||||
inc edi ; edi->FontName
|
||||
jecxz .ex
|
||||
.fnext:
|
||||
cmp edx,[edi]
|
||||
jne .floop
|
||||
sub eax,ecx
|
||||
add eax,4
|
||||
shl eax,28
|
||||
jmp .ex
|
||||
.floop:
|
||||
mov edi,[edi+16]
|
||||
loop .fnext
|
||||
.num0:
|
||||
xor eax,eax
|
||||
.ex:
|
||||
pop edi ecx
|
||||
ret
|
||||
|
||||
_BGIfont_Prepare:
|
||||
; in: edx-font name, edi->pointer to load fonts (fonts_count)
|
||||
; out: eax-ID of new font loaded; eax=0 error
|
||||
cmp [BGIfont_Ptr],0
|
||||
jne .already
|
||||
mov [BGIfont_Ptr],edi
|
||||
.already:
|
||||
pusha
|
||||
mov edi,[BGIfont_Ptr]
|
||||
movzx ecx,byte[edi] ; ecx-font count
|
||||
mov eax,ecx
|
||||
inc edi ; edi->FontName
|
||||
jecxz .fload
|
||||
.fnext:
|
||||
cmp edx,[edi]
|
||||
jne .loop
|
||||
sub eax,ecx
|
||||
inc eax
|
||||
jmp .cr_id
|
||||
.loop:
|
||||
mov edi,[edi+16]
|
||||
loop .fnext
|
||||
.fload:
|
||||
mov dword[.font],edx ; filename
|
||||
mov esi,edi ; esi->FontName
|
||||
mov [.dest],edi ; ptr to load font
|
||||
if ~ BGI_LEVEL eq KERNEL
|
||||
mov [.fsize],1
|
||||
mov eax,58
|
||||
mov ebx,.fontinfo
|
||||
int 0x40
|
||||
test eax,eax
|
||||
jnz .fail
|
||||
dps2 '1'
|
||||
shr ebx,9
|
||||
inc ebx
|
||||
mov [.fsize],ebx
|
||||
mov ebx,.fontinfo
|
||||
mov eax,58
|
||||
int 0x40 ; ebx - file size
|
||||
else
|
||||
push edi esi edx
|
||||
mov eax,.font
|
||||
xor ebx,ebx
|
||||
mov esi,12
|
||||
mov ecx,ebx
|
||||
mov edx,edi
|
||||
call fileread
|
||||
pop edx esi edi
|
||||
mov ebp,edi
|
||||
add ebp,ebx
|
||||
cmp ebp,0x50000
|
||||
ja .fail
|
||||
end if
|
||||
cmp dword[edi],0x08084b50 ; 'PK',8,8
|
||||
jne .fail
|
||||
dps2 '2'
|
||||
inc edi
|
||||
mov eax,26 ; #EOF
|
||||
mov ecx,253
|
||||
cld
|
||||
repne scasb ; skip Copyright
|
||||
test ecx,ecx
|
||||
jz .fail
|
||||
dps2 '3'
|
||||
cmp edx,[edi+2] ; FontName
|
||||
jne .fail
|
||||
dps2 '4'
|
||||
movzx ecx,word[edi] ; HeaderSize
|
||||
sub ebx,ecx ; Filesize-Headersize
|
||||
movzx eax,word[edi+6] ; FontSize
|
||||
cmp eax,ebx
|
||||
jb .fail ; file truncated
|
||||
add ecx,[.dest]
|
||||
dps2 '5'
|
||||
cmp byte[ecx],'+' ; ParPrefix
|
||||
jne .fail
|
||||
; font is valid, let's fill parameter table
|
||||
dps2 '>'
|
||||
mov [esi],edx ; FontName
|
||||
mov edx,eax
|
||||
add eax,ecx
|
||||
mov [esi+16],eax ; Font EOF
|
||||
movzx eax,word[ecx+5]
|
||||
add eax,ecx
|
||||
mov [esi+12],eax
|
||||
lea edi,[esi+4] ; edi->CharsCount
|
||||
lea esi,[ecx+1] ; esi->ParPrefix+1
|
||||
xor eax,eax
|
||||
lodsw
|
||||
stosb ; CharsCount
|
||||
inc esi
|
||||
movsb ; FirstChar
|
||||
add esi,3
|
||||
lodsw
|
||||
stosb ; UpperMargin
|
||||
movsb ; LowerMargin
|
||||
add esi,5 ; esi->offsets
|
||||
mov eax,[esi]
|
||||
push edi ; edi->Widths
|
||||
; prepare moving data
|
||||
add edi,12 ; edi->offsets
|
||||
lea ecx,[edx-16]
|
||||
rep movsb
|
||||
pop edi ; edi->Widths
|
||||
mov [edi+8],esi ; EOF
|
||||
; mov eax,[edi]
|
||||
movzx ecx,byte[edi-4] ; CharsCount
|
||||
lea eax,[edi+12+ecx*2] ; eax->widths
|
||||
stosd ; edi->FirstData
|
||||
add eax,ecx
|
||||
stosd ; edi->EOF
|
||||
mov eax,[esp] ; eax->fonts_count
|
||||
inc byte[eax] ; increase font counter
|
||||
movzx eax,byte[eax]
|
||||
.cr_id:
|
||||
add eax,0x3 ; create unique ID
|
||||
shl eax,28 ; to easy use in color(ecx)
|
||||
jmp .exit
|
||||
.fail:
|
||||
xor eax,eax
|
||||
.exit:
|
||||
mov [esp+28],eax
|
||||
popa
|
||||
ret
|
||||
|
||||
if ~ BGI_LEVEL eq KERNEL
|
||||
.fontinfo:
|
||||
dd 0
|
||||
dd 0
|
||||
.fsize dd 0
|
||||
.dest dd 0
|
||||
dd 0x10000
|
||||
db BGIFONT_PATH
|
||||
.font db 'FONT.CHR',0
|
||||
else
|
||||
.dest dd 0
|
||||
.font db 'FONT CHR'
|
||||
.okflag db ' ',0
|
||||
end if
|
||||
|
||||
BGIfont_Coo:
|
||||
; y->word[txt.y1], x->word[txt.x1]
|
||||
fild [txt.y1] ;y
|
||||
fmul st0,st0; y*y
|
||||
fild [txt.x1] ;x
|
||||
fmul st0,st0; x*x
|
||||
faddp ; x*x+y*y
|
||||
fsqrt ; sqrt, angle
|
||||
fild [txt.y1];y
|
||||
fabs
|
||||
fild [txt.x1] ; x
|
||||
fabs
|
||||
fpatan ; arctg(y/x)
|
||||
.skip:
|
||||
cmp [txt.x1],0
|
||||
jge .xplus
|
||||
fchs
|
||||
fadd st0,st3
|
||||
.xplus:
|
||||
cmp [txt.y1],0
|
||||
jge .yplus
|
||||
fchs
|
||||
.yplus:
|
||||
fadd st0,st2
|
||||
fsincos
|
||||
fmul st0,st2
|
||||
fiadd [txt.x0]
|
||||
fistp [txt.x1] ; x=r*cos a
|
||||
fmulp ; y=r*sin a,angle
|
||||
fiadd [txt.y0]
|
||||
fistp [txt.y1]
|
||||
ret
|
||||
|
||||
_BGIfont_Freetext:
|
||||
; in: ebx-BGIfree structure
|
||||
; out: eax-new drawing coords
|
||||
mov edx,[ebx]
|
||||
call _BGIfont_GetID
|
||||
test eax,eax
|
||||
jnz .fexists
|
||||
ret
|
||||
.fexists:
|
||||
pusha
|
||||
fninit
|
||||
fldpi
|
||||
fld [pi180]
|
||||
fimul dword[ebx+8]
|
||||
fst [BGIangle]
|
||||
mov esi,[ebx+28]
|
||||
and esi,0xffffff
|
||||
add esi,eax
|
||||
mov eax,[ebx+32]
|
||||
and [deform],0
|
||||
test eax,BGI_ITALIC
|
||||
jz .norm
|
||||
mov [deform],0.4
|
||||
.norm:
|
||||
mov ebp,eax
|
||||
or ebp,BGI_FREE
|
||||
mov eax,[ebx+12]
|
||||
mov [Xscale],eax
|
||||
mov eax,[ebx+16]
|
||||
mov [Yscale],eax
|
||||
mov ecx,[ebx+20]
|
||||
mov edx,ebp
|
||||
and edx,BGI_FREE+BGI_VAMASK+BGI_HAMASK
|
||||
add edx,[ebx+24]
|
||||
mov eax,[ebx+4]
|
||||
mov ebx,esi
|
||||
add ebx,0x6000000
|
||||
mov [esp+4],edx
|
||||
mov [esp+20],ecx
|
||||
jmp txt
|
||||
|
||||
pi180 dd 0.017453
|
||||
|
||||
_BGIfont_Outtext:
|
||||
; in: ebx-[x][y], ecx-color, edx-string, esi-length
|
||||
pusha
|
||||
mov ebp,esi
|
||||
if ~ BGI_LEVEL eq KERNEL
|
||||
mov eax,ebx
|
||||
mov ebx,ecx
|
||||
mov ecx,edx
|
||||
mov edx,esi
|
||||
end if
|
||||
; in: eax-[x][y], ebx-color, ecx-string, edx-length
|
||||
txt:
|
||||
if ~ BGI_LEVEL eq KERNEL
|
||||
if BGI_WINDOW_CLIP eq 1
|
||||
pusha
|
||||
mov eax,9
|
||||
mov ebx,BGI_PRC_INFO
|
||||
mov ecx,-1
|
||||
int 0x40
|
||||
popa
|
||||
end if
|
||||
end if
|
||||
mov [.y0],ax
|
||||
shr eax,16
|
||||
mov [.x0],ax
|
||||
mov ecx,ebx ; color
|
||||
and ebx,0xfffffff
|
||||
mov [.color],ebx
|
||||
call BGIfont_get2head
|
||||
test edi,edi
|
||||
jz .exit
|
||||
mov ecx,[esp+4]; str length
|
||||
mov esi,[esp+20]; str ptr
|
||||
movzx eax,byte[edi+5]
|
||||
push ecx
|
||||
and ecx,0xff
|
||||
jnz .lenok
|
||||
add esp,4
|
||||
jmp .ex2
|
||||
.lenok:
|
||||
pusha
|
||||
push dword[txt.y0]
|
||||
and dword[txt.y0],0
|
||||
xor edx,edx
|
||||
mov ebx,[edi+8]
|
||||
.next:
|
||||
call txt.BGIfont_GetChar
|
||||
movzx eax,byte[ebx+eax]
|
||||
add edx,eax
|
||||
loop .next
|
||||
mov ecx,edx ; ecx - x size
|
||||
movzx dx,byte[edi+6]
|
||||
mov ebx,[esp+36]
|
||||
and ebx,BGI_HAMASK
|
||||
cmp ebx,BGI_HARIGHT
|
||||
je .nova
|
||||
ja .subv
|
||||
xor ecx,ecx
|
||||
jmp .nova
|
||||
.subv:
|
||||
shr cx,1
|
||||
.nova:
|
||||
mov ebx,[esp+36]
|
||||
and ebx,BGI_VAMASK
|
||||
cmp ebx,BGI_VATOP
|
||||
je .def
|
||||
ja .subh
|
||||
xor edx,edx
|
||||
jmp .def
|
||||
.subh:
|
||||
shr dx,1
|
||||
.def:
|
||||
call txt.BGIfont_Deform
|
||||
pop dword[txt.y0]
|
||||
popa
|
||||
pop ebx
|
||||
mov ax,[txt.y1]
|
||||
sub [txt.y0],ax
|
||||
mov ax,[txt.x1]
|
||||
sub [txt.x0],ax
|
||||
xor eax,eax
|
||||
cld
|
||||
.mloop:
|
||||
push [.y0]
|
||||
pop [.y]
|
||||
push [.x0]
|
||||
pop [.x]
|
||||
call .BGIfont_GetChar
|
||||
push esi
|
||||
lea esi,[edi+20] ; offset
|
||||
movzx edx,word[esi+eax*2] ; ofs1
|
||||
add edx,[edi+12]
|
||||
inc eax
|
||||
cmp al,[edi+4]
|
||||
je .eof
|
||||
movzx eax,word[esi+eax*2]; ofs2
|
||||
add eax,[edi+12]
|
||||
jmp .prc_vec
|
||||
.eof:
|
||||
mov eax,[edi+16] ; ofs2=eof
|
||||
.prc_vec: ; edx-vec cmd ifs, eax-cmd limit
|
||||
mov [.vec_end],eax
|
||||
push ecx
|
||||
.vec_loop:
|
||||
mov ax,word[edx]
|
||||
push edx
|
||||
mov ecx,eax
|
||||
and eax,0x8080 ; op
|
||||
and ecx,0x7f ; xx
|
||||
mov edx,[edx+1]
|
||||
and edx,0x7f ; yy
|
||||
cmp edx,63
|
||||
jbe .positive
|
||||
sub edx,128 ; yy-=128
|
||||
.positive:
|
||||
cmp ecx,63
|
||||
jbe .positive2
|
||||
sub ecx,128 ; xx-=128
|
||||
.positive2:
|
||||
call .BGIfont_Deform
|
||||
cmp eax,0x8080
|
||||
jne .noline
|
||||
test ebp,BGI_NODRAW
|
||||
jnz .noline
|
||||
; draw vector
|
||||
if ~ BGI_LEVEL eq KERNEL
|
||||
push eax
|
||||
mov ebx,dword[.x1]
|
||||
mov ecx,dword[.y1]
|
||||
if BGI_WINDOW_CLIP eq 1
|
||||
movzx eax,[.x]
|
||||
cmp eax,dword[BGI_PRC_INFO+42]
|
||||
ja .nobold
|
||||
movzx eax,[.y]
|
||||
cmp eax,dword[BGI_PRC_INFO+46]
|
||||
ja .nobold
|
||||
xor eax,eax
|
||||
cmp ax,bx
|
||||
jg .nobold
|
||||
cmp ax,cx
|
||||
jg .nobold
|
||||
end if
|
||||
mov edx,[.color]
|
||||
mov eax,38
|
||||
int 0x40
|
||||
test ebp,BGI_BOLD
|
||||
jz .nobold
|
||||
test ebp,BGI_FREE
|
||||
jnz .free5
|
||||
.free5:
|
||||
add ebx,1 shl 16+1
|
||||
int 0x40
|
||||
.nobold:
|
||||
pop eax
|
||||
else
|
||||
pusha
|
||||
mov eax,dword[.x1]
|
||||
mov ebx,dword[.y1]
|
||||
mov ecx,[.color]
|
||||
; call syscall_drawline
|
||||
test dword[esp+8],BGI_BOLD
|
||||
jz .nobold
|
||||
add eax,1 shl 16+1
|
||||
; call syscall_drawline
|
||||
.nobold:
|
||||
popa
|
||||
end if
|
||||
.noline:
|
||||
pop edx
|
||||
test eax,eax
|
||||
je .eovecs ; op=0
|
||||
push [.y1]
|
||||
pop [.y]
|
||||
push [.x1]
|
||||
pop [.x]
|
||||
add edx,2
|
||||
cmp edx,[.vec_end]
|
||||
jb .vec_loop
|
||||
.eovecs:
|
||||
pop ecx esi
|
||||
push [.y]
|
||||
pop [.y0]
|
||||
push [.x]
|
||||
pop [.x0]
|
||||
loop .mloop1
|
||||
jmp .exit
|
||||
.mloop1:
|
||||
jmp .mloop
|
||||
.exit:
|
||||
mov eax,dword[.y0]
|
||||
mov [esp+28],eax
|
||||
.ex2:
|
||||
popa
|
||||
ret
|
||||
|
||||
.BGIfont_Deform:
|
||||
test ebp,BGI_FREE
|
||||
jnz .free0
|
||||
movzx ebx,byte[.color+3] ;ebx=scale
|
||||
imul ecx,ebx
|
||||
add ecx,2
|
||||
shr ecx,2
|
||||
imul edx,ebx
|
||||
add edx,2
|
||||
shr edx,2
|
||||
neg edx
|
||||
mov [.x1],cx
|
||||
mov [.y1],dx
|
||||
jmp .add
|
||||
.free0:
|
||||
mov [.x1],cx
|
||||
mov [.y1],dx
|
||||
fild [.y1]
|
||||
fld st0
|
||||
fmul [Yscale]
|
||||
fchs
|
||||
fistp [.y1]
|
||||
fmul [deform]
|
||||
fiadd [.x1]
|
||||
fmul [Xscale]
|
||||
fistp [.x1]
|
||||
cmp [BGIangle],0
|
||||
je .add
|
||||
call BGIfont_Coo
|
||||
jmp .eax
|
||||
.add:
|
||||
mov cx,[.x0]
|
||||
add [.x1],cx
|
||||
mov cx,[.y0]
|
||||
add [.y1],cx
|
||||
.eax:
|
||||
ret
|
||||
|
||||
.BGIfont_GetChar:
|
||||
; in: esi -> string; edi -> BGIrec
|
||||
; out: esi -> next char; al - char obtained
|
||||
lodsb ; al - char from str
|
||||
sub al,[edi+5]
|
||||
jb .out
|
||||
cmp al,[edi+4]
|
||||
jb .in
|
||||
.out:
|
||||
xor al,al ; al - 1st symbol available
|
||||
.in:
|
||||
ret
|
||||
|
||||
.y0 dw ?
|
||||
.x0 dw ?
|
||||
|
||||
.x1 dw ?
|
||||
.x dw ?
|
||||
.y1 dw ?
|
||||
.y dw ?
|
||||
|
||||
.color dd ?
|
||||
.vec_end dd ?
|
||||
BGIfont_Ptr dd 0
|
||||
width dd ?
|
||||
deform dd ?
|
||||
BGIangle dd ?
|
||||
Xscale dd ?
|
||||
Yscale dd ?
|
||||
@@ -0,0 +1,444 @@
|
||||
; BGI Font Test
|
||||
;
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
;
|
||||
; Created: December 20, 2004
|
||||
;
|
||||
; Last changed: February 2, 2005
|
||||
;
|
||||
|
||||
BGIFONT_PATH equ '/RD/1/'
|
||||
_X equ 340
|
||||
_Y equ 240
|
||||
|
||||
BGI_WINDOW_CLIP equ 1
|
||||
BGI_PRC_INFO equ pinfo
|
||||
|
||||
macro ListFonts
|
||||
{
|
||||
mov eax,lf_head
|
||||
call PixelPrint
|
||||
mov ebx,20 shl 16+60
|
||||
mov ecx,(BGIfont_names_end-BGIfont_names)/4
|
||||
mov esi,BGIfont_names
|
||||
.l1:
|
||||
pusha
|
||||
pusha
|
||||
mcall 4,,0x10777fac,esi,4
|
||||
popa
|
||||
mov edx,[esi]
|
||||
BGIfont_GetID
|
||||
mov dword[_BGIfont_Prepare.font],edx
|
||||
mov ecx,eax
|
||||
add ebx,140 shl 16
|
||||
mov edx,ebx
|
||||
mcall 47,0x80100,,,0x10ffffff
|
||||
jecxz .nofont
|
||||
lea ebx,[edx+80 shl 16+12]
|
||||
mov edx,_BGIfont_Prepare.dest+8
|
||||
mov esi,BGIfont_Coo-1
|
||||
sub esi,edx
|
||||
add ecx,0x3b800b8
|
||||
BGIfont_Outtext
|
||||
sub ebx,155 shl 16+12
|
||||
mcall 4,,0x1000f000,load_ok,load_fail-load_ok
|
||||
jmp .pop
|
||||
.nofont:
|
||||
lea ebx,[edx-80 shl 16]
|
||||
mcall 4,,0x10f00010,load_fail,font_msg-load_fail
|
||||
.pop:
|
||||
popa
|
||||
add esi,4
|
||||
add ebx,39
|
||||
loop .l2
|
||||
jmp .ex
|
||||
.l2:
|
||||
jmp .l1
|
||||
.ex:
|
||||
}
|
||||
use32
|
||||
org 0x0
|
||||
|
||||
db 'MENUET01'
|
||||
dd 0x01
|
||||
dd START
|
||||
dd I_END
|
||||
dd 0x100000
|
||||
dd 0x0cfff0
|
||||
dd 0x0
|
||||
not1strun dd 0x0
|
||||
|
||||
include 'lang.inc'
|
||||
include 'macros.inc'
|
||||
;include 'debug.inc'
|
||||
include 'bgifont.inc'
|
||||
lang equ en;ru;en
|
||||
|
||||
START:
|
||||
mov [help],0
|
||||
mov ecx,(BGIfont_names_end-BGIfont_names)/4
|
||||
mov esi,BGIfont_names
|
||||
mov edi,I_END
|
||||
BGIfont_Init
|
||||
reset:
|
||||
mov esi,[BGIfont_Ptr]
|
||||
inc esi
|
||||
mov edi,freeconst
|
||||
movsd
|
||||
mov esi,freeconst
|
||||
mov edi,freetest
|
||||
mov ecx,36
|
||||
rep movsb
|
||||
red:
|
||||
mov eax,[freetest]
|
||||
mov dword[title+19],eax
|
||||
call draw_window
|
||||
cmp [not1strun],0
|
||||
jnz still
|
||||
mcall 5,300
|
||||
not [not1strun]
|
||||
inc [help]
|
||||
jmp red
|
||||
still:
|
||||
|
||||
mov eax,10
|
||||
int 0x40
|
||||
|
||||
cmp eax,1
|
||||
je red
|
||||
cmp eax,2
|
||||
je key
|
||||
cmp eax,3
|
||||
je button
|
||||
|
||||
jmp still
|
||||
|
||||
button:
|
||||
mov eax,17
|
||||
int 0x40
|
||||
cmp ah,1
|
||||
jnz noclose
|
||||
close:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
int 0x40
|
||||
noclose:
|
||||
jmp still
|
||||
|
||||
key:
|
||||
mov eax,2
|
||||
int 0x40
|
||||
shr eax,8
|
||||
cmp al,27 ; esc - close
|
||||
je close
|
||||
cmp al,32 ; Space - help
|
||||
jne .noh
|
||||
inc [help]
|
||||
cmp [help],3
|
||||
jne red
|
||||
and [help],0
|
||||
jmp red
|
||||
.noh:
|
||||
cmp [help],2
|
||||
jne still
|
||||
cmp al,50
|
||||
jb .noff
|
||||
cmp al,57
|
||||
ja .noff
|
||||
sub al,46
|
||||
.gn:
|
||||
movzx ecx,al
|
||||
shl ecx,28
|
||||
call BGIfont_GetName
|
||||
mov [freetest],edx
|
||||
jmp red
|
||||
.noff:
|
||||
mov ecx,4
|
||||
mov edi,Fkeys
|
||||
.fkey:
|
||||
cmp al,[edi]
|
||||
je .fndkey
|
||||
inc edi
|
||||
loop .fkey
|
||||
jmp .notfnd
|
||||
.fndkey:
|
||||
lea eax,[edi-Fkeys+0xc]
|
||||
jmp .gn
|
||||
.notfnd:
|
||||
cmp al,114 ; r - reset
|
||||
je reset
|
||||
cmp al,176
|
||||
jne .nol ; left
|
||||
sub dword[freetest+8],5
|
||||
jmp red
|
||||
.nol:
|
||||
cmp al,179
|
||||
jne .nor ; right
|
||||
add dword[freetest+8],5
|
||||
jmp red
|
||||
.nor:
|
||||
cmp al,105 ; i -italic
|
||||
jne .noi
|
||||
xor dword[freetest+32],BGI_ITALIC
|
||||
jmp red
|
||||
.noi:
|
||||
cmp al,98 ; b -bold
|
||||
jne .nob
|
||||
xor dword[freetest+32],BGI_BOLD
|
||||
jmp red
|
||||
.nob:
|
||||
mov ecx,2
|
||||
mov esi,ali
|
||||
.ol2:
|
||||
cmp al,[esi]
|
||||
jne .othl2
|
||||
mov ax,[freetest+32]
|
||||
add ax,[esi+3]
|
||||
mov bx,ax
|
||||
mov dx,[esi+1]
|
||||
and bx,dx
|
||||
cmp bx,dx
|
||||
jne .ok
|
||||
not dx
|
||||
and ax,dx
|
||||
.ok:
|
||||
mov [freetest+32],ax
|
||||
jmp red
|
||||
.othl2:
|
||||
add esi,5
|
||||
loop .ol2
|
||||
.other:
|
||||
mov esi,delt
|
||||
mov ecx,4
|
||||
.ol:
|
||||
cmp al,[esi]
|
||||
jne .othl
|
||||
fld dword[esi+1]
|
||||
movzx eax,byte[esi+5]
|
||||
fadd dword[freetest+eax]
|
||||
fstp dword[freetest+eax]
|
||||
jmp red
|
||||
.othl:
|
||||
add esi,6
|
||||
loop .ol
|
||||
jmp still
|
||||
|
||||
draw_window:
|
||||
mov eax,12
|
||||
mov ebx,1
|
||||
int 0x40
|
||||
|
||||
xor eax,eax
|
||||
mov ebx,10*65536+_X*2
|
||||
mov ecx,100*65536+_Y*2
|
||||
mov edx,0x03261212
|
||||
mov esi,0x805080d0
|
||||
mov edi,0x005080d0
|
||||
int 0x40
|
||||
|
||||
mov eax,4
|
||||
mov ebx,8*65536+8
|
||||
mov ecx,0x10ddeeff
|
||||
mov edx,title
|
||||
mov esi,title_end-title
|
||||
cmp [help],2
|
||||
je .int
|
||||
sub esi,12
|
||||
.int:
|
||||
int 0x40
|
||||
|
||||
cmp [help],0
|
||||
jnz .help
|
||||
cmp byte[I_END],0
|
||||
jnz .fontsok
|
||||
mov eax,font_msg
|
||||
call PixelPrint
|
||||
.fontsok:
|
||||
ListFonts
|
||||
jmp .eod
|
||||
.help:
|
||||
cmp [help],1
|
||||
jne .nohelp
|
||||
mov eax,helptxt
|
||||
cmp byte[I_END],0
|
||||
jnz .fontsok2
|
||||
mov word[eax+2],_X-80
|
||||
call PixelPrint
|
||||
jmp .eod
|
||||
.fontsok2:
|
||||
mov word[eax+2],_X
|
||||
call Print
|
||||
jmp .eod
|
||||
.nohelp:
|
||||
mov edi,cross
|
||||
mov eax,38
|
||||
mov edx,0x4b331a
|
||||
mov ebx,[edi]
|
||||
mov ecx,[edi+4]
|
||||
int 0x40
|
||||
mov ebx,[edi+8]
|
||||
mov ecx,[edi+12]
|
||||
int 0x40
|
||||
mov ebx,freetest
|
||||
BGIfont_Freetext
|
||||
.eod:
|
||||
mov eax,12
|
||||
mov ebx,2
|
||||
int 0x40
|
||||
ret
|
||||
|
||||
Print: ; eax-pointer to _txt struc
|
||||
pusha
|
||||
mov ebx,[eax]
|
||||
movzx ecx,byte[eax+12]
|
||||
lea edx,[eax+13]
|
||||
mov edi,eax
|
||||
.nextstr:
|
||||
mov esi,[edx]
|
||||
add edx,4
|
||||
push ecx
|
||||
mov ecx,[edi+8]
|
||||
BGIfont_Outtext
|
||||
add ebx,[edi+4]
|
||||
pop ecx
|
||||
and esi,0xfff
|
||||
add edx,esi
|
||||
loop .nextstr
|
||||
popa
|
||||
ret
|
||||
|
||||
PixelPrint: ; eax-pointer to _txt struc, but used differently
|
||||
pusha
|
||||
mov ebp,eax
|
||||
mov ebx,[ebp]
|
||||
movzx ecx,byte[ebp+12]
|
||||
mov eax,4
|
||||
lea edx,[ebp+17]
|
||||
.l:
|
||||
mov esi,[edx-4]
|
||||
and esi,0xfff
|
||||
push ecx
|
||||
mov ecx,[ebp+8]
|
||||
int 0x40
|
||||
pop ecx
|
||||
lea edx,[esi+edx+4]
|
||||
add ebx,[ebp+4]
|
||||
loop .l
|
||||
popa
|
||||
ret
|
||||
|
||||
macro _txt _xy,_vert,_color,_opt,[_str]
|
||||
{
|
||||
common
|
||||
_counter=0
|
||||
forward
|
||||
_counter=_counter+1
|
||||
common
|
||||
dd _xy ; 0
|
||||
dd _vert ; 4
|
||||
dd _color ; 8
|
||||
db _counter ;_str_count ; 12
|
||||
forward
|
||||
local .str_beg,.str_end
|
||||
dd (.str_end-.str_beg) or _opt ; 13
|
||||
.str_beg:
|
||||
db _str ;17
|
||||
.str_end:
|
||||
}
|
||||
|
||||
title db 'BGIFONT.INC demo - FONT font'
|
||||
title_end:
|
||||
_M equ 30
|
||||
cross dd _M shl 16+_X*2-_M,_Y shl 16+_Y,_X shl 16+_X,_M shl 16+_Y*2-_M
|
||||
helptxt:
|
||||
if lang eq ru
|
||||
_txt _X shl 16+60,40,0x434ba010,BGI_HACENTER,\
|
||||
"ГОРЯЧИЕ КЛАВИШИ:",\
|
||||
"Пробел - шрифты/этот текст/демка;",\
|
||||
"<-> стрелки - вращение строки;",\
|
||||
"V - выравнивание по вертикали;",\
|
||||
"H - выравнивание по горизонтали;",\
|
||||
"[,] - масштаб по оси X;",\
|
||||
"A,Z - масштаб по оси Y;",\
|
||||
"B,I - полужирный шрифт и курсив;",\
|
||||
"R - сброс параметров шрифта;",\
|
||||
"F1..F12 - выбор шрифта;",\
|
||||
"Esc - закрыть прогу :-("
|
||||
alpha:
|
||||
db "Вот пример текста!"
|
||||
lf_head:
|
||||
_txt 10 shl 16+30,85 shl 16,0x6e00f7,0,"Имя шрифта","Статус","ID",\
|
||||
"Путь к файлу"
|
||||
load_ok:
|
||||
db "загружен"
|
||||
load_fail:
|
||||
db "не найден"
|
||||
font_msg:
|
||||
_txt (_X+20) shl 16+180,25,0x10ff0000,0,\
|
||||
"К сожалению, не найдено ни одного",\
|
||||
"векторного шрифта *.CHR. Возможно,",\
|
||||
"вам следует исправить константу",\
|
||||
"BGIFONT_PATH в начале файла BGITEST.ASM",\
|
||||
"и перекомпилировать его :-("
|
||||
else
|
||||
_txt _X shl 16+60,40,0x434ba010, BGI_HACENTER,\
|
||||
"HOT KEYS:",\
|
||||
"Space - font list/this message/demo;",\
|
||||
"<-> arrows - rotate text string;",\
|
||||
"V - toggle vertical alignment;",\
|
||||
"H - toggle horizontal alignment;",\
|
||||
"[,] - scale on X axis;",\
|
||||
"A,Z - scale on Y axis;",\
|
||||
"B,I - toggle bold & italic mode;",\
|
||||
"R - reset font options;",\
|
||||
"F1..F12 - select font;",\
|
||||
"Esc - close demo :-("
|
||||
alpha:
|
||||
db 'This is a Sample text!'
|
||||
; db 'ABCDEFGHIGKLMNOPQRSTUVWXWZ'
|
||||
lf_head:
|
||||
_txt 10 shl 16+30,85 shl 16,0x6e00f7,0,"Font name","Status","ID",\
|
||||
"Filename"
|
||||
load_ok:
|
||||
db "loaded"
|
||||
load_fail:
|
||||
db "not found"
|
||||
font_msg:
|
||||
_txt (_X+20) shl 16+180,25,0x10ff0000,0,\
|
||||
"Sorry, no vector font *.CHR found.",\
|
||||
"Maybe you should correct BGIFONT_PATH",\
|
||||
"constant at the beginning of file",\
|
||||
"BGITEST.ASM and recompile it :-("
|
||||
end if
|
||||
|
||||
macro Deltas _key,_scale,_ofs
|
||||
{
|
||||
db _key
|
||||
dd _scale
|
||||
db _ofs
|
||||
}
|
||||
|
||||
delt:
|
||||
Deltas 91, -0.15,12
|
||||
Deltas 93, 0.15,12
|
||||
Deltas 97, 0.15,16
|
||||
Deltas 122,-0.15,16
|
||||
Fkeys db 48,49,68,255
|
||||
|
||||
macro Aligns _key,_mask,_add
|
||||
{
|
||||
db _key
|
||||
dw _mask,_add
|
||||
}
|
||||
ali:
|
||||
Aligns 118,BGI_VAMASK,BGI_VATOP
|
||||
Aligns 104,BGI_HAMASK,BGI_HARIGHT
|
||||
freeconst BGIfree 'FONT',_X shl 16+_Y,0, 1.0, 1.0, alpha,\
|
||||
lf_head-alpha,0xb800e7,\
|
||||
BGI_VACENTER or BGI_HACENTER
|
||||
freetest BGIfree ?,?,?,?,?,?,?,?,?
|
||||
help db ?
|
||||
pinfo:
|
||||
times 1024 db ?
|
||||
rb 10000 ; reserve, unless process info will corrupt our fonts (why?)
|
||||
I_END:
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm bgitest.asm bgitest
|
||||
@pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm bgitest.asm bgitest
|
||||
@pause
|
||||
@@ -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
|
||||
@@ -0,0 +1,140 @@
|
||||
BGIFONT.INC v1.0 beta
|
||||
|
||||
Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
|
||||
At present Menuet operation system has poor means to draw charaters. Its
|
||||
distro contains 2 raster fonts (CHAR.MT & CHAR2.MT files). The kernel supports
|
||||
them internally. That is Jarek Pelczar who makes certain efforts to develop
|
||||
scalable TTF-like fonts but huge Menuet C Library does not become widespread
|
||||
inside our assembly-written OS. Bulgarian MenuetOS team also tries to include
|
||||
third scalable font into the kernel, though, as far as I know, its characters
|
||||
are still under design and are incomplete. Therefore Bulgarian developing is
|
||||
not valuable for ordinary users. It is obvious that scalable fonts will help
|
||||
to develop such products as browsers and word processors where character
|
||||
formatting is of great importance.
|
||||
Let me introduce for public domain an include file BGIFONT.INC to process
|
||||
vector fonts (*.CHR) worked out by famous Borland Corporation to use in Turbo
|
||||
Pascal, Turbo C and Borland C++ compilers under MS-DOS. Sorry, I still fail to
|
||||
add BGI font support into kernel - deeper knowledge on memory allocation and
|
||||
system calls needed. I hope that Menuet system programmers will be glad to help
|
||||
me. Module compiling within kernel is supposed using constant BGI_LEVEL equ
|
||||
KERNEL. By means of conditional compiling it will be possible to use the module
|
||||
at both kernel and application levels. Following is concerned using the include
|
||||
file while programming an application.
|
||||
|
||||
BGI fonts may reside in any folder on HD or RD. They are searched using value
|
||||
of constant BGI_PATH. If constant BGI_WINDOW_CLIP is equal to 1, module routines
|
||||
perform window bounds check to avoid artifacts while drawing. Use this if you
|
||||
aren't sure that strings are fit in window. All BGIFONT.INC routines are
|
||||
declared as macros, that is they are used without "call". To load 11 fonts into
|
||||
application's memory a contiguous free space up to 120 kb is needed. When
|
||||
loading, font data relocation is performed to save memory. Let us see a chart:
|
||||
|
||||
| Font | | BGIrec | | Font | | BGIrec | | Font | | BGIrec |
|
||||
| counter | | structure| | data | | structure| | data | | structure| ...
|
||||
| (1 byte)| | | | | |
|
||||
| ------------->------ -------------->----- ----------
|
||||
- referenced by [BGIfont_Ptr]
|
||||
|
||||
BGIrec structure fields have following meaning:
|
||||
|
||||
+00 dword .FontName font name (4 characters)
|
||||
+04 byte .CharsCount amount of font characters
|
||||
+05 byte .FirstChar code of the first character present
|
||||
+06 byte .UpperMargin high bound of characters
|
||||
+07 byte .LowerMargin low bound of characters
|
||||
+08 dword .Widths offset to width array
|
||||
+12 dword .FirstData offset to vector table
|
||||
+16 dword .EOF pointer to the following BGIrec
|
||||
+20 dword .font_data here font data begin
|
||||
|
||||
Font loading and verification are carried out by BGIfont_Prepare procedure.
|
||||
|
||||
BGIfont_Prepare
|
||||
in: EDX - font name (4 characters) to be loaded. It must to be the same as
|
||||
the font filename (without extension)
|
||||
EDI - address to where font have to be loaded. Used only for the
|
||||
first time. Then you may find this value in [BGIfont_Ptr]
|
||||
out: EAX=0, if an error occured, otherwise EAX is identifier (ID) of the
|
||||
loaded font. Later it is possible to get font ID with BGIfont_GetID
|
||||
function.
|
||||
|
||||
For the simultaneous loading of few fonts you may use BGIfont_Init routine.
|
||||
|
||||
BGIfont_Init
|
||||
in: ESI - pointer to array of font names (for example db 'TRIPSIMPEURO')
|
||||
ECX is amount of fonts to load
|
||||
EDI - see BGIfont_Prepare
|
||||
out: nothing.
|
||||
|
||||
To load 10 standard fonts the module defines an array BGIfont_names (see in
|
||||
BGITEST for usage demonstration).
|
||||
|
||||
For compatibility and subsequent kernel introduction, the module offers 2
|
||||
routines for drawing vector characters. One of them uses registers (like sysfunc
|
||||
4), another uses a structure.
|
||||
|
||||
BGIfont_Outtext
|
||||
in: EAX - "pivot point" of a string [x] shl 16+[y]
|
||||
ECX - text color and font size 0xXYRRGGBB,
|
||||
where X - vector font ID(4..F),
|
||||
Y - size of caracters divided by 4, e.g. 0x1 - 1/4 of
|
||||
ordinary size, 0xC - triple size.
|
||||
EDX - pointer to the string
|
||||
ESI - string length + formatting flags (see below). BGI_ITALIC and
|
||||
BGI_NODRAW flags are ignored.
|
||||
out: EAX - coords at the end of the string drawn [x] shl 16+[y].
|
||||
|
||||
As you can see, BGIfont_Outtext is similar to the 4th system function,
|
||||
but provides an extended management of drawing symbols.
|
||||
|
||||
The most complete use of vector fonts is provided by BGIfont_Freetext routine.
|
||||
Parameters are passed in a BGIfree structure.
|
||||
|
||||
BGIfree structure fields have following meaning:
|
||||
|
||||
+00 dword font name (4 characters)
|
||||
+04 dword "pivot point" of a string [x] shl 16+[y]
|
||||
+08 dword turn angle (clockwise, 0 is horizontal)
|
||||
+12 dword X scale (floating point value!)
|
||||
+16 dword Y scale (floating point value!)
|
||||
+20 dword pointer to the string
|
||||
+24 dword string length WITHOUT formatting flags
|
||||
+28 dword text color 0x00RRGGBB
|
||||
+32 dword formatting flags
|
||||
|
||||
The module defines following formatting flags:
|
||||
BGI_NODRAW - do not draw
|
||||
BGI_ITALIC - italic
|
||||
BGI_BOLD - bold
|
||||
BGI_HALEFT - left alignment
|
||||
BGI_HARIGHT - right alignment
|
||||
BGI_HACENTER - center alignment
|
||||
BGI_VABOTTOM - bottom alignment
|
||||
BGI_VATOP - top alignment
|
||||
BGI_VACENTER - middle vertical alignment
|
||||
|
||||
Combination of flags can be performed by addition or the OR operation.
|
||||
|
||||
BGIfont_Freetext
|
||||
in: EBX - pointer to BGIfree structure
|
||||
out: EAX coords at the end of the string drawn [x] shl 16+[y].
|
||||
|
||||
BGIfont_GetID routine returns font ID by its name.
|
||||
|
||||
BGIfont_GetID
|
||||
in: EDX - font name (4 characters)
|
||||
out: EAX - ID of the font
|
||||
EDI - pointer on font's BGIrec structure.
|
||||
|
||||
Using functions of BGIFONT.INC module is demonstrated by BGITEST app.
|
||||
|
||||
Todo list:
|
||||
1. An insidious bug sometimes shows up while loading multiple fonts (as in
|
||||
BGITEST), that corrupts some characters. It disappears when font loading
|
||||
order is changed... :-(
|
||||
2. To correct a hardly reproduceable bug when moving along the font list.
|
||||
3. To perfect drawing of bold fonts.
|
||||
4. To add number drawing routines.
|
||||
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
BGIFONT.INC v1.0 beta for MenuetOS
|
||||
Модуль для работы с векторными шрифтами формата BGI
|
||||
|
||||
Написан на чистом ассемблере Ивушкиным Андреем aka Willow
|
||||
|
||||
В настоящее время операционная система Menuet обладает скудными средствами
|
||||
отображения символов. В дистрибутиве имеются 2 растровых шрифта (файлы CHAR.MT и
|
||||
CHAR2.MT). Работа с ними жестко зашита в ядре. Определенные усилия по внедрению
|
||||
масштабируемых шрифтов TTF-подобного формата предпринимает Jarek Pelczar, однако
|
||||
громоздкая MenuetOS C Library не получила до сих пор большой популярности в
|
||||
ассемблерной ОС. Болгарской командой Menuet делались попытки встроить в ядро
|
||||
третий масштабируемый шрифт, но, насколько мне известно, его символы находятся в
|
||||
стадии дизайна. Таким образом, разработка болгар пока не представляет ценности
|
||||
для рядовых пользователей. Очевидно, что масштабируемые шрифты помогут
|
||||
разработке таких важных категорий программных продуктов, как браузеры и
|
||||
текстовые процессоры, где большую роль играет форматирование символов.
|
||||
Представляю в общественное пользование включаемый файл BGIFONT.INC для работы с
|
||||
векторными шрифтами *.CHR, разработанные знаменитой фирмой Borland для
|
||||
использования в компиляторах Turbo Pascal, Turbo C и Borland C++ еще в среде MS-
|
||||
DOS. К сожалению, пока что мне не удается обеспечить поддержку BGI-шрифтов на
|
||||
уровне ядра - нужно глубже изучать нюансы распределения памяти и вызова
|
||||
системных функций. Я надеюсь, что системщики Menuet с готовностью мне помогут.
|
||||
Компиляция модуля в составе ядра предполагается с использованием константы
|
||||
BGI_LEVEL equ KERNEL. Благодаря условной компиляции модуль можно будет
|
||||
использовать с незначительными изменениями на уровне как ядра, так и приложения.
|
||||
Нижеизложенное касается работы модуля на уровне приложения.
|
||||
|
||||
BGI-шрифты могут располагаться в любом каталоге HD или RD. Их поиск
|
||||
осуществляется по значению константы BGI_PATH. Если константа BGI_WINDOW_CLIP
|
||||
установлена в 1, процедурами модуля в процессе вывода векторов шрифта
|
||||
осуществляется проверка выхода за границы окна, чтобы избежать артефактов.
|
||||
Используйте это, если вы не уверены, что надписи будут помещаться в окне. В
|
||||
этом случае необходимо дополнительно определить константу BGI_PRC_INFO - адрес
|
||||
в памяти (1024 байта), куда приложение может получать информацию о своем окне
|
||||
через 9-ю системную функцию. Все процедуры модуля BGIFONT.INC объявлены как
|
||||
макросы, т.е. вызываются без call. Для загрузки 11 шрифтов в адресное
|
||||
пространство приложения необходим непрерывный участок размером около 120 кб.
|
||||
При загрузке осуществляется перемещение данных с целью экономии памяти. Схема
|
||||
размещения шрифтов:
|
||||
|
||||
| Счетчик | | Структура| |Данные| |Структура| | Данные| |Структура|
|
||||
| шрифтов | | BGIrec | |шрифта| | BGIrec | | шрифта| | BGIrec | ...
|
||||
| (1 байт)| | | | | |
|
||||
| ------------->------ -------------->----- ----------
|
||||
- сюда ссылается [BGIfont_Ptr]
|
||||
|
||||
Поля структуры BGIrec имеют следующее назначение:
|
||||
|
||||
+00 dword .FontName четырехбуквенное имя шрифта
|
||||
+04 byte .CharsCount количество символов в шрифте
|
||||
+05 byte .FirstChar код первого реализованного символа
|
||||
+06 byte .UpperMargin верхняя граница символа
|
||||
+07 byte .LowerMargin нижняя граница символа
|
||||
+08 dword .Widths смещение массива ширин символов
|
||||
+12 dword .FirstData смещение таблицы векторов
|
||||
+16 dword .EOF указатель на следующий BGIrec
|
||||
+20 dword .font_data здесь начинаются данные шрифта
|
||||
|
||||
Собственно загрузку и верификацию шрифта осуществляет процедура
|
||||
BGIfont_Prepare.
|
||||
|
||||
BGIfont_Prepare
|
||||
вход: EDX - четырехбуквенное имя шрифта, подлежащего загрузке. Должно
|
||||
совпадать с именем файла шрифта (без расширения)
|
||||
EDI - адрес участка памяти, куда следует поместить данные шрифта.
|
||||
Используется только при загрузке первого шрифта. Это значение
|
||||
заносится в [BGIfont_Ptr]
|
||||
выход: EAX=0, если произошла ошибка, иначе в EAX - идентификатор (ID)
|
||||
загруженного шрифта. Впоследствии ID можно получить функциями
|
||||
BGIfont_GetID и BGIfont_GetName.
|
||||
|
||||
Для единовременной загрузки нескольких шрифтов можно использовать процедуру
|
||||
BGIfont_Init.
|
||||
|
||||
BGIfont_Init
|
||||
вход: ESI - указатель на список имен шрифтов (например db 'TRIPSIMPEURO')
|
||||
ECX - количество шрифтов для загрузки
|
||||
EDI - см. BGIfont_Prepare
|
||||
выход: ничего.
|
||||
|
||||
Для загрузки 10 стандартных шрифтов в модуле определен массив BGIfont_names
|
||||
(использование см. в BGITEST).
|
||||
|
||||
В целях совместимости и последующего внедрения в ядро модуль предлагает 2
|
||||
процедуры для вывода символов векторными шрифтами. Одна из них использует
|
||||
регистры (подобно 4-й системной функции), другая - структуру.
|
||||
|
||||
BGIfont_Outtext
|
||||
вход: EAX - "точка отсчета" при выводе строки [x] shl 16+[y]
|
||||
ECX - цвет текста и размер шрифта 0xXYRRGGBB,
|
||||
где X - ID векторного шрифта (4..F),
|
||||
Y - величина символов/4, например 0x1 - 1/4 обычного размера,
|
||||
0xC - тройной размер.
|
||||
EDX - указатель на строку
|
||||
ESI - длина строки + флаги форматирования (см. ниже). Флаги
|
||||
BGI_ITALIC и BGI_NODRAW игнорируются.
|
||||
выход: EAX - координаты конца надписи [x] shl 16+[y].
|
||||
|
||||
Как видим, BGIfont_Outtext по своим параметрам схожа с 4-й системной функцией,
|
||||
но допускает расширенное управление выводом символов.
|
||||
|
||||
Наиболее полное использование векторных шрифтов обеспечивает функция
|
||||
BGIfont_Freetext. Параметры вывода строки передаются в структуре BGIfree.
|
||||
|
||||
Поля структуры BGIfree имеют следующее назначение:
|
||||
|
||||
+00 dword четырехбуквенное имя шрифта
|
||||
+04 dword "точка отсчета" при выводе строки [x] shl 16+[y]
|
||||
+08 dword угол поворота (0 - горизонталь, отсчет по часовой стрелке)
|
||||
+12 dword масштаб по оси X (значение с плавающей точкой!)
|
||||
+16 dword масштаб по оси Y (значение с плавающей точкой!)
|
||||
+20 dword указатель на строку
|
||||
+24 dword длина строки БЕЗ флагов форматирования
|
||||
+28 dword цвет текста 0x00RRGGBB
|
||||
+32 dword флаги форматирования
|
||||
|
||||
Модуль определяет следующие флаги форматирования:
|
||||
BGI_NODRAW - не рисовать символы
|
||||
BGI_ITALIC - курсив
|
||||
BGI_BOLD - полужирный шрифт
|
||||
BGI_HALEFT - выровнять по левому краю
|
||||
BGI_HARIGHT - выровнять по правому краю
|
||||
BGI_HACENTER - выровнять по центру
|
||||
BGI_VABOTTOM - выровнять по нижнему краю
|
||||
BGI_VATOP - выровнять по верхнему краю
|
||||
BGI_VACENTER - выровнять по середине
|
||||
|
||||
Комбинация флагов образуется их сложением или операцией OR.
|
||||
|
||||
BGIfont_Freetext
|
||||
вход: EBX - указатель на структуру BGIfree
|
||||
выход: EAX - координаты конца надписи [x] shl 16+[y].
|
||||
|
||||
Функция BGIfont_GetID возвращает ID шрифта по заданному имени.
|
||||
|
||||
BGIfont_GetID
|
||||
вход: EDX - четырехбуквенное имя шрифта
|
||||
выход: EAX - ID шрифта
|
||||
EDI - указатель на BGIrec шрифта.
|
||||
|
||||
Использование функций модуля BGIFONT.INC демонстрирует программа BGITEST.
|
||||
|
||||
Что еще нужно сделать:
|
||||
1. При множественной загрузке шрифтов (как в BGITEST) иногда проявляется
|
||||
коварный баг, портящий несколько символов. При изменении порядка загрузки
|
||||
шрифтов он исчезает... :-(
|
||||
2. Исправить трудовоспроизводимый баг при движении по списку шрифтов.
|
||||
3. Усовершенствовать прорисовку полужирных шрифтов.
|
||||
4. Добавить функции вывода чисел.
|
||||
Loaded 100 of 667 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user