Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 108 → Rev 109

/programs/media/ac97wav/trunk/ac97.inc
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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/ac97wav/trunk/ac97wav.asm
0,0 → 1,1084
;---------------------------------------------------------------------
;
; MenuetOS AC97 WAV Player
;
; 0.03 November 10, 2004 doesn't halt if file not found
; 0.04 November 11, 2004 better positioning (with mouse)
; 0.05 November 14, 2004 internals clean up
; fixed cutting sound at the edges
; 0.06 November 17, 2004 fixed many bugs
; 0.07 Nov 20, 2004 deactivates text box when 'play' pressed
; stops playing before closing a window
; 0.08 Nov 24, 2004 added support for 8bit and mono modes
; +variable rate for some chipsets
;
; Use [flat assembler 1.56] to compile.
;
;---------------------------------------------------------------------
 
use32 ; turn on 32 bit mode
org 0x0 ; the program is placed at 0 offset
 
db 'MENUET01' ; 8-byte identifier of MenuetOS application
dd 0x01 ; header version (always 1)
dd START ; address of the beginning of the code
dd IMAGE_END ; size of the program's image
dd MEMORY_END ; how much memory does it need
dd STACK_P ; a pointer to the top of the stack
dd textbox_string
; dd 0x0 ; address of buffer for parameters (not used)
dd 0x0 ; reserved
 
;---------------------------------------------------------------------
 
include "lang.inc"
include "macros.inc" ; standart macros & constants
include "meosfunc.inc" ; MenuetOS API functions names
include "debug.inc" ; printing to debug board
include "constant.inc" ; BIT?? constants
include "ac97.inc" ; AC'97 constants
include "pci.inc" ; PCI interface
include "codec.inc" ; functions for configuring codec
include "frontend.inc" ; main window
 
;---------------------------------------------------------------------
 
; Uncomment these strings if you don't want to receive debug messages:
 
; macro dps str {} ; dps prints a string without CRLF
; macro dpd num {} ; prints unsigned decimal number
; macro pregs {} ; outputs EAX, EBX, ECX, EDX
; macro newline {} ; CRLF
; macro print str {} ; output a string with CRLF
; macro dph arg {} ; print hex number
 
;---------------------------------------------------------------------
 
;macro device id, addr { dd id, addr }
macro devices [id, str]
{
common
label supported_devices dword
forward
local string
dd id
dd string
forward
string db str
db 0
}
 
 
devices \
(ICH_DID shl 16) + INTEL_VID, "ICH" ,\
(ICH0_DID shl 16) + INTEL_VID, "ICH0" ,\
(ICH2_DID shl 16) + INTEL_VID, "ICH2" ,\
(ICH3_DID shl 16) + INTEL_VID, "ICH2" ,\
(ICH4_DID shl 16) + INTEL_VID, "ICH4" ,\
(ICH5_DID shl 16) + INTEL_VID, "ICH5" ,\
(MX440_DID shl 16) + INTEL_VID, "440MX" ,\
(SI7012_DID shl 16) + SIS_VID, "SI7012" ,\
(NFORCE_DID shl 16) + NVIDIA_VID, "NForce" ,\
(NFORCE2_DID shl 16) + NVIDIA_VID, "NForce2",\
(AMD8111_DID shl 16) + AMD_VID, "AMD8111",\
(AMD768_DID shl 16) + AMD_VID, "AMD768"
dd 0
 
 
;---------------------------------------------------------------------
;--- MAIN PROGRAM --------------------------------------------------
;---------------------------------------------------------------------
 
START:
 
; Print PCI version (for example, 2.16)
; mcall MF_PCI, 0
; mov bl, al
; movzx eax, ah
; dps "PCI version: "
; dpd eax
; movzx eax, bl
; dpd eax
; newline
 
; Check PCI access mechanism (must be 1 or 2)
mcall MF_PCI, 2
dec al
cmp al, 1
jna @f
print "Error: cannot access PCI bus."
jmp exit
; dps "PCI returned "
; movzx eax, al
; dpd eax
; newline
@@:
 
 
; Get last bus & then check all buses & devices
mcall MF_PCI, 1
mov [lastbus], al
 
; looking for a compatible device
mov [bus], -1
.next_bus:
inc [bus]
 
mov al, [lastbus]
cmp al, [bus]
jb .device_not_found
 
mov [devfn], 0
.next_devfn:
 
mov cl, 0
call pciRegRead32
 
mov edi, supported_devices
@@:
mov ebx, [edi]
test ebx, ebx
jz @f
cmp eax, ebx
jnz .skip
add edi, 4
mov [device_id], eax
mov edx, [edi]
call debug_outstr
jmp proceed
.skip:
add edi, 8
jmp @b
@@:
 
inc [devfn]
cmp [devfn], 255
jb .next_devfn
 
jmp .next_bus
 
 
.device_not_found:
print "Could not find Intel AC'97 compatible codec!"
print "1) Check if it's enabled in BIOS."
print "2) Check if your device is included in the device list."
jmp exit
 
 
proceed:
print " integrated AC97 audio codec detected."
mov eax, [device_id]
cmp eax, (ICH4_DID shl 16) + INTEL_VID
je .newich
cmp eax, (ICH5_DID shl 16) + INTEL_VID
jne .nonewich
.newich:
mov [AC97ICH4], 1
.nonewich:
 
cmp eax, (SI7012_DID shl 16) + SIS_VID
jne @f
mov [SI7012], 1
@@:
 
;---------------------------------------------------------------------
 
; Get NAMBAR register base port address & save it
mov cl, NAMBAR_REG
call pciRegRead16
 
and eax, 0xFFFE
mov [NAMBAR], ax
test eax, eax
jnz .mixer_base_ok
 
print "Error: Intel ICH based AC97 audio codec disabled in BIOS!"
jmp exit
 
.mixer_base_ok:
dps "NAMBAR: "
dph eax
 
; Get NABMBAR & save it
mov cl, NABMBAR_REG
call pciRegRead16
and eax, 0xFFC0
mov [NABMBAR], ax
test eax, eax
jnz .bm_base_ok
 
print "Error: Intel ICH based AC97 audio codec disabled in BIOS!"
jmp exit
 
.bm_base_ok:
dps " NABMBAR: "
dph eax
newline
 
;---------------------------------------------------------------------
 
; Get IRQ (not used)
mov cl, IRQ_REG
call pciRegRead8
mov [AC97IRQ], al
 
; Get Interrupt pin (not used)
mov cl, INT_REG
call pciRegRead8
mov [AC97INT], al
 
; AC97ICH4 should work then...
cmp [AC97ICH4], 1
jne .skip_ich4_init
 
mov cl, ICH4_CFG_REG ; 0x41
call pciRegRead8
or al, 0x1
mov dl, al
call pciRegWrite8
 
mov cl, 0x54
call pciRegRead16
and eax, 0xFFFF
dps "Power Control & Status: "
dph eax
newline
.skip_ich4_init:
 
;---------------------------------------------------------------------
 
mov cl, PCI_CMD_REG
call pciRegRead16 ; read PCI command register
mov dx, ax
or dx, IO_ENA+BM_ENA+BIT10 ; enable IO and bus master + disable
; interrupts
call pciRegWrite16
 
;---------------------------------------------------------------------
 
print "Enabling access to ports..."
 
movzx ecx, [NAMBAR]
mov edx, ecx
add edx, NAM_SIZE
mcall MF_PORTS, PRT_RESERVE
test eax, eax
jz @f
print "Error: couldn't enable access to ports"
jmp exit
@@:
 
movzx ecx, [NABMBAR]
mov edx, ecx
add edx, NABM_SIZE
mcall MF_PORTS, PRT_RESERVE
test eax, eax
jz @f
print "Error: couldn't enable access to ports"
jmp exit
@@:
 
;---------------------------------------------------------------------
 
; setup the Codec
mov eax, 48000
call codecConfig ; unmute codec, set rates.
test eax, eax
jnz @f
print "Error: cannot initialize AC97 device."
jmp fpexit
@@:
 
print "Congrutalations! Your device has been initialized properly!"
call print_info
 
;---------------------------------------------------------------------
 
; register reset the DMA engine.
mov edx, PO_CR_REG ; PCM out control register
mov al, RR ; reset
call NABMBAR_write_byte
;start fix for MM (1)
mcall MF_INTERNAL_SERVICES,ALLOC_PHYS_MEM,120*1024
test eax,eax
jz no_phys_buffers ;not enough memory
mov [phys_wav_buffer1],eax
add eax,60*1024
mov [phys_wav_buffer2],eax
mcall MF_INTERNAL_SERVICES,ALLOC_PHYS_MEM,32*8
test eax,eax
jnz @f
mcall MF_INTERNAL_SERVICES,FREE_PHYS_MEM,[phys_wav_buffer1]
jmp no_phys_buffers
@@:
mov [phys_bdl_buffer],eax
;end fix for MM (1)
 
; create Buffer Descriptors List
call prepare_BDL
 
; open player's window
mcall MF_THREAD, THR_CREATE, thread, thread_stack
 
; wait for command
.new_check:
cmp [status], ST_PLAY
jne @f
call play
@@:
cmp [status], ST_STOP
jne @f
call stop
@@:
cmp [status], ST_EXIT
je stopexit
 
mcall MF_DELAY, 10
jmp .new_check
 
stopexit:
call stop
 
fpexit:
 
; free ports
movzx ecx, [NAMBAR]
mov edx, ecx
add edx, NAM_SIZE
mcall MF_PORTS, PRT_FREE
 
movzx ecx, [NABMBAR]
mov edx, ecx
add edx, NABM_SIZE
mcall MF_PORTS, PRT_FREE
 
;---------------------------------------------------------------------
;start fix for MM (2)
mcall MF_INTERNAL_SERVICES,FREE_PHYS_MEM,[phys_bdl_buffer]
mcall MF_INTERNAL_SERVICES,FREE_PHYS_MEM,[phys_wav_buffer1]
;end fix for MM (2)
exit:
mcall MF_EXIT
no_phys_buffers:
print "allocation of physical buffers failed"
jmp exit
 
;---------------------------------------------------------------------
;--- FUNCTIONS -----------------------------------------------------
;---------------------------------------------------------------------
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; prepare_BDL - initializes BUFFER DESCRIPTORS LIST
prepare_BDL:
mov ecx, 32 / 2 ; make 32 entries in BDL
mov edi, BDL_BUFFER
; call get_my_address
mov ebx, 30*1024
cmp [SI7012], 1
jne @f
add ebx, ebx
@@:
; set buf. desc. 0 to start of data file in memory
push eax
; add eax, WAV_BUFFER1
;start fix for MM (6)
mov eax,[phys_wav_buffer1]
;end fix for MM (6)
stosd
; set length to 60k samples. 1 sample is 16 bit or 2 bytes.
mov eax, ebx ;60*1024 ; number of samples
or eax, BUP
stosd
 
mov eax, [esp]
; add eax, WAV_BUFFER2
;start fix for MM (7)
mov eax,[phys_wav_buffer2]
;end fix for MM (7)
stosd
mov eax, ebx ;60*1024
or eax, BUP
stosd
 
pop eax
loop @b
 
; tell the DMA engine where to find our list of Buffer Descriptors.
; eax = base addr!
;start fix for MM (3)
;copy to physical memory
mcall MF_INTERNAL_SERVICES,SET_PHYS_BUFFER,[phys_bdl_buffer],BDL_BUFFER,32*8
;physical address of bdl
mov eax,[phys_bdl_buffer]
;end fix for MM (3)
mov edx, PO_BDBAR_REG
; add eax, BDL_BUFFER
call NABMBAR_write_dword
 
ret
 
 
;---------------------------------------------------------------------
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; stop - stops current music
;; in: nothing
;; out: nothing
stop:
; print "STOP!"
push eax edx
 
mcall MF_DELAY, 10
mov edx, PO_CR_REG
mov al, 0
call NABMBAR_write_byte
cmp [status], ST_STOP
jne .exit
mov [status], ST_DONE
.exit:
 
pop edx eax
ret
 
;---------------------------------------------------------------------
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; play - plays wav file!
;; in: nothing
;; out: nothing (but sound :) !corrupts registers!
play:
; at first, reset file
mov [fileinfo.first_block], 0
mcall MF_SYSTREE, fileinfo ; load a block, returns error code in eax
; and size of the file in ebx
test eax, eax ; 0 - successful
jz @f
print "AC97: File not found!"
mov [status], ST_STOP
jmp .exit
@@:
shr ebx, 9 ; size_of_file / 512 = number_of_blocks
mov [file_size], ebx
 
 
mov al, [LOAD_BUFFER+32] ; bytes per sample
dec al
jz @f
cmp al, 3
je @f
sub al, [LOAD_BUFFER+22] ; channels
add al, 2
@@:
mov [wav_mode], al
 
pusha
movzx ebx,word [LOAD_BUFFER+24]
mov eax,48000
xor edx,edx
div ebx
mov [difference_of_frequency],al
; dph eax
mov ecx,edx
imul eax,ecx,10
xor edx,edx
div ebx
mov ecx,edx
imul ecx,10
push eax
mov eax,ecx
xor edx,edx
div ebx
; dph eax
cmp eax,5
jl .temp_15
pop eax
; dph eax
 
inc eax
jmp .temp_16
.temp_15:
pop eax
.temp_16:
mov [difference_of_frequency_1],al
; dph eax
xor edx,edx
movzx ebx,[difference_of_frequency]
imul ebx,10
add bl,[difference_of_frequency_1]
mov [difference_of_frequency_2],bl
; dph ebx
popa
 
movzx eax, word [LOAD_BUFFER+24]
;dps "Freq: "
;dpd eax
;newline
call set_sample_rate
 
 
; change the last_valid_index to the (current_index-1)
; the LVI register tells the DMA engine where to stop playing
call updateLVI
 
; if current index is odd, load buffer 1 then 0, jump to tuneLoop
; if it is even, buffers 0 then 1; tuneLoop1
call getCurrentIndex
and eax, BIT0
 
mov esi, eax
push eax
call update_next_buffer
pop eax
xor eax, 1
call update_next_buffer
 
; start playing!
mov edx, PO_CR_REG
mov al, RPBM
call NABMBAR_write_byte
 
jmp [jumpto+esi*4]
 
 
.tuneLoop:
; wait while the current_index is even
@@:
; dps "a"
mcall MF_DELAY, 7
call getCurrentIndex
test al, BIT0
jz @b ; loop if not ready yet
; print "fa"
 
call updateLVI
 
mov eax, 0
call update_next_buffer
test al, al
jnz .exit_wait
 
cmp [status], ST_PLAY
jne .exit
 
test [volume], 0x10000000 ; test volume_changed bit
je @f
mov al, byte [volume]
call setVolume
and [volume], 0x0FFFFFFF ; clear vloume_changed bit
@@:
 
.tuneLoop1:
@@:
; dps "b"
mcall MF_DELAY, 7
call getCurrentIndex
test al, BIT0
jnz @b ; loop if not ready yet
; print "fb"
 
cmp [status], ST_PLAY
jne .exit
 
call updateLVI
 
mov eax, 1
call update_next_buffer
test al, al
jnz .exit_wait
 
jmp .tuneLoop
.exit_wait:
mcall MF_DELAY, 30 ; a little pause - let the player finish
.exit:
ret
attempts db 0
 
buffers dd WAV_BUFFER1, WAV_BUFFER2
jumpto dd play.tuneLoop, play.tuneLoop1
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; update_first_buffer - load a chunk into the first buffer, increments offset
;; in: eax = number - 0 or 1
;; out: error code, 0 - successful
update_next_buffer:
push esi edi
 
movzx edx, byte [wav_mode]
mov ecx, [blocks + edx * 4]
mov [fileinfo.blocks], ecx
 
mov esi, LOAD_BUFFER
mov edi, [buffers+eax*4]
push eax ;save buffer index
start_attempts:
mcall MF_SYSTREE, fileinfo
test eax, eax
jz @f
cmp [attempts],100
je @f
inc [attempts]
jmp start_attempts
dpd eax
newline
dpd [fileinfo.first_block]
newline
@@:
; print " loaded!"
 
push eax ebx edx
mov eax,ecx
xor edx,edx
imul eax,10
movzx ebx,[difference_of_frequency_2]
 
div ebx
mov ecx,eax
 
; mov ebx,10
; mov eax,edx
; xor edx,edx
; div ebx
; cmp edx,5
; jb temp_12_7
; inc ecx
; temp_12_7:
cmp edx,0
je temp_12_7
inc ecx
temp_12_7:
 
pop edx ebx
mov eax,[esp+4] ;restore buffer index
add [fileinfo.first_block], ecx ; +60Kb
call [convert + edx * 4]
;start fix for MM (4)
mov eax,[esp+4] ;restore buffer index
test eax,not 1
jz .ok
print "buffer index out of range"
dpd eax
jmp .ret
.ok:
push ebp
mov ebp,[phys_wav_buffer1+eax*4]
mov edi,[buffers+eax*4]
mcall MF_INTERNAL_SERVICES,SET_PHYS_BUFFER,ebp,edi,60*1024
pop ebp
.ret:
pop eax
add esp,4 ;pop buffer index
;end fix for MM (4)
 
pop edi esi
ret
 
c8mono:
mov [type_of_conversion],1
jmp for_all_type
 
c8mono_1:
lodsb
call c8mono_2
push ax
shl eax,16
pop ax
push eax
mov al,[esi]
call c8mono_2
push ax
shl eax,16
pop ax
mov ebx,eax
pop eax
jmp for_all_type_1
 
c8mono_2:
sub al, 0x80
cbw
imul ax, 255
ret
 
c8stereo:
mov [type_of_conversion],2
jmp for_all_type
 
c8stereo_1:
lodsb
call c8stereo_2
shl eax,16
lodsb
call c8stereo_2
push eax
mov al,[esi]
call c8stereo_2
shl eax,16
mov al,[esi+1]
call c8stereo_2
mov ebx,eax
pop eax
jmp for_all_type_1
 
c8stereo_2:
sub al, 0x80
cbw
imul ax, 255
ret
 
c16mono:
mov [type_of_conversion],3
jmp for_all_type
 
c16mono_1:
lodsw
push ax
shl eax,16
pop ax
mov bx,[esi]
shl ebx,16
mov bx,[esi]
jmp for_all_type_1
 
c16stereo:
for_all_type:
xor edx,edx
mov eax, 15*1024*10
movzx ebx,[difference_of_frequency_2]
xor edx,edx
div ebx
mov ecx,eax
 
; mov ebx,10
; mov eax,edx
; xor edx,edx
; div ebx
; cmp edx,5
; jb temp_12_6
; inc ecx
; temp_12_6:
cmp edx,0
je temp_12_6
inc ecx
temp_12_6:
 
c16stereo_1:
mov [znak],0
 
cmp [type_of_conversion],1
je c8mono_1
cmp [type_of_conversion],2
je c8stereo_1
cmp [type_of_conversion],3
je c16mono_1
lodsd
 
mov ebx,[esi]
for_all_type_1:
cmp eax,ebx
jne c16stereo_2
inc [znak]
c16stereo_2:
push eax
push ecx
sub eax,ebx
push eax
shl eax,16
movzx ebx,[difference_of_frequency]
inc ebx
xor edx,edx
div ebx
shr eax,16
mov ecx,eax
pop eax
xor ax,ax
xor edx,edx
div ebx
shl eax,16
mov cx,ax
mov ebx,ecx
pop ecx
pop eax
mov dl,[difference_of_frequency]
inc dl
@@:
temp_12:
cmp [difference_of_frequency_1],0
je temp_12_3
cmp [difference_of_frequency_1],5
jne temp_12_4
cmp [difference_of_frequency_4],2
jne temp_12_3
jmp temp_12_5
temp_12_4:
cmp [difference_of_frequency_4],10
jne temp_12_3
 
temp_12_5:
 
cmp [znak],0
jne temp_12_5_1
sub eax,ebx
jmp temp_12_5_2
temp_12_5_1:
add eax,ebx
temp_12_5_2:
 
 
stosd
inc [schetchik]
mov [difference_of_frequency_4],0
temp_12_3:
cmp [znak],0
jne temp_13
sub eax,ebx
jmp temp_14
temp_13:
add eax,ebx
 
temp_14:
cld
dec dl
jz temp_14_1
stosd
inc [schetchik]
inc [difference_of_frequency_4]
jmp temp_12
temp_14_1:
dec ecx
cmp ecx,0
; jnz c16stereo_1
jg c16stereo_1
newline
dph [schetchik]
temp_14_2:
cmp [schetchik],15360
jge temp_14_3
stosd
inc [schetchik]
jmp temp_14_2
 
temp_14_3:
newline
dph [schetchik]
cmp [schetchik],15360
je temp_14_4
; mov [edi-4],dword 0
sub edi,4
; sub esi,4
temp_14_4:
mov [schetchik],0
ret
 
 
difference_of_frequency db 0
difference_of_frequency_1 db 0
difference_of_frequency_2 db 0
difference_of_frequency_4 db 0
schetchik dd 0
znak db 0
type_of_conversion db 0
 
convert dd c8mono, c8stereo, c16mono, c16stereo
blocks dd 30, 60, 60, 120
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; get_my_address - get base address of the program in physical memory
;; in: nothing
;; out: eax = address
;start fix for MM (8)
;function shouldn't used.
;get_my_address:
; pushad
; mcall MF_PROCINFO, procinfo, PN_MYSELF
; popad
; mov eax, [procinfo.memory_start]
;ret
;end fix for MM (8)
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set the last valid index to something other than we're currently playing
;; so that we never end
;;
;; this routine just sets the last valid index to 1 less than the index
;; that we're currently playing, thus keeping it in and endless loop
;; input: none
;; output: none
updateLVI:
push eax
call getCurrentIndex
; dps "index "
; dpd eax
; newline
dec al
and al, INDEX_MASK
call setLastValidIndex
pop eax
ret
 
;---------------------------------------------------------------------
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; returns AL = current index value
getCurrentIndex:
push edx
mov edx, PO_CIV_REG
call NABMBAR_read_byte
pop edx
ret
 
;---------------------------------------------------------------------
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; input AL = index # to stop on
setLastValidIndex:
push edx
mov edx, PO_LVI_REG
call NABMBAR_write_byte
pop edx
ret
 
;---------------------------------------------------------------------
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; print_info - outputs debug information
;; in: nothing
;; out: nothing
print_info:
dps "BUS: "
movzx eax, [bus]
dph eax
 
dps " DEVFN: "
movzx eax, [devfn]
dph eax
 
dps " IRQ: "
movzx eax, [AC97IRQ]
dpd eax
newline
 
 
dps "CODEC_POWER_CTRL: "
mov edx, CODEC_POWER_CTRL_REG
call NAMBAR_read_word
dph eax
dps " (bits 0-3 should be set)"
newline
 
mov edx, 0x28
call NAMBAR_read_word
dph eax
dps " - supported features"
newline
mov edx, 0x2A
call NAMBAR_read_word
dph eax
dps " - config"
newline
mov edx, 0x2C
call NAMBAR_read_word
dph eax
dps " - PCM rate"
 
newline
ret
 
 
;---------------------------------------------------------------------
;--- DATA OF PROGRAM -----------------------------------------------
;---------------------------------------------------------------------
volume dd 15
 
fileinfo:
.mode dd 0 ; READ
.first_block dd 0
.blocks dd 120 ; 120 Kb
.dest dd LOAD_BUFFER ;file_data
.work dd work_area
; db "/HD/1/WINDOWS/MEDIA/WICEB7~1.WAV",0
;sz textbox_string, "/hd/1/testmuz/menuet11.wav",0
sz textbox_string, " ",0
; rb 256
;---------------------------------------------------------------------
 
IMAGE_END: ; end of program's image
rb 100-textbox_string.size
; textbox_string.size
 
;---------------------------------------------------------------------
 
device_id dd ? ; (device_id << 16) + vendor_id
lastbus db ? ; pci coordinates
bus db ?
devfn db ?
 
AC97ICH4 db ? ; Intel ICH4 codec flag
SI7012 db ? ; SiS SI7012 codec flag
NAMBAR dw ? ; Audio Mixers Registers (base)
NABMBAR dw ? ; Bus Master Registers (base)
 
AC97IRQ db ? ; Interrupt request
AC97INT db ? ; Interrupt pin
 
wav_mode db ? ; bits per sample & channels
 
;---------------------------------------------------------------------
 
ST_DONE = 0x0 ; for interacting with player's window
ST_PLAY = 0x1
ST_EXIT = 0x2
ST_STOP = 0x4
 
status db ?
 
;---------------------------------------------------------------------
phys_bdl_buffer rd 1
phys_wav_buffer1 rd 1
phys_wav_buffer2 rd 1
align 32
 
 
; Buffer Descriptors List
; ___________________________
; | physical address | dword
; |_________________________|
; | attr | length | dword max. length = 65535 samples
; |_________________________|
 
BDL_BUFFER:
rb 32*8 ; 32 descriptors, 8 bytes each
 
 
;---------------------------------------------------------------------
 
file_data:
 
WAV_BUFFER1:
rb 60 * 1024 ; 60 Kb
 
WAV_BUFFER2:
rb 60 * 1024
 
LOAD_BUFFER:
rb 60 * 1024
 
;---------------------------------------------------------------------
 
procinfo process_information
 
work_area:
rb 0x10000
 
;---------------------------------------------------------------------
 
rb 0x800
thread_stack:
 
rb 0x1000 ; for stack
STACK_P:
 
MEMORY_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/ac97wav/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm ac97wav.asm ac97wav
@pause
/programs/media/ac97wav/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm ac97wav.asm ac97wav
@pause
/programs/media/ac97wav/trunk/codec.inc
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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/ac97wav/trunk/constant.inc
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
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/ac97wav/trunk/debug.inc
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'
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/ac97wav/trunk/frontend.inc
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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/ac97wav/trunk/includes.inc
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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/ac97wav/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/ac97wav/trunk/meosfunc.inc
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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/ac97wav/trunk/pci.inc
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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/bmpview/trunk/bmpview.asm
0,0 → 1,694
;
; BMP VIEWER
; modified by Ivan Poddubny
;
; Compile with FASM for Menuet
;
 
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x300000 ; memory for app
dd 0xfff0 ; esp
dd I_Param , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
include 'macros.inc'
 
 
START: ; start of execution
 
cmp dword [I_Param],0
je noparam
 
cmp dword [I_Param],'BOOT'
jne noboot
call load_image
call set_as_background
mov eax,15
mov ebx,4
mov ecx,2
int 0x40
mov eax,15
mov ebx,3
int 0x40
 
or eax,-1
int 0x40
noboot:
 
mov edi,name_string
mov al,0
mov ecx,70
rep stosb
 
mov ecx,50
mov edi,I_Param
repne scasb
sub edi,I_Param
mov ecx,edi
 
mov esi,I_Param
mov edi,name_string
cld
rep movsb
call load_image
 
noparam:
 
call draw_window ; at first, draw the window
 
still:
 
mov eax,10 ; wait here for event
int 0x40
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
 
jmp still
 
red: ; redraw
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne noclose
mov eax,-1 ; close this program
int 0x40
noclose:
 
cmp ah,2
jne no_file_name
call read_string
jmp still
no_file_name:
 
cmp ah,3
jne no_load_image
call load_image
call draw_window
jmp still
no_load_image:
 
cmp ah,4
jne no_setasbackground
call set_as_background
jmp still
no_setasbackground:
 
cmp ah,5
jne no_tiled
mov eax,15
mov ebx,4
mov ecx,1
int 0x40
mov eax,15
mov ebx,3
int 0x40
jmp still
no_tiled:
 
cmp ah,6
jne no_stretch
mov eax,15
mov ebx,4
mov ecx,2
int 0x40
mov eax,15
mov ebx,3
int 0x40
jmp still
no_stretch:
 
 
jmp still
 
type dd 0x0
i_pos dd 0x0
x_size dd 0x1
y_size dd 0x1
bpp dd 0x24
 
temp dd 999
 
fileinfoblock:
 
dd 0 ; 0 = read
dd 0 ; first 512 block
dd 1 ; number of blocks to read
dd 0x10000+1024 ; read to
dd 35 ; 17000 byte work area
name_string:
db '/HARDDISK/FIRST/MENUET/PICS/NEW.BMP',0
times 100 db 0
 
 
read_header:
 
pusha
 
mov edi,0x10000
mov ecx,100
mov eax,0
cld
rep stosb
 
mov [fileinfoblock+ 8],dword 1
mov [fileinfoblock+12],dword 0x10000
 
push dword [name_string-4]
mov [name_string-4],dword 0x20000
mov eax,58
mov ebx,fileinfoblock
int 0x40
pop dword [name_string-4]
 
movzx eax,word [0x10000+0]
mov [type],eax
mov eax,[0x10000+10]
mov [i_pos],eax
mov eax,[0x10000+18]
mov [x_size],eax
mov eax,[0x10000+22]
mov [y_size],eax
movzx eax,word [0x10000+28]
mov [bpp],eax
 
popa
ret
 
 
draw_picture_info:
 
pusha
 
mov eax,13
mov ebx,380*65536+6*5
mov ecx,65*65536+40
mov edx,0xffffff
int 0x40
 
mov eax,47
mov ebx,5*65536
mov ecx,[x_size]
mov edx,380*65536+65
mov esi,0x224466
int 0x40
 
mov ecx,[y_size]
add edx,10
int 0x40
 
mov ecx,[bpp]
add edx,20
int 0x40
 
popa
ret
 
 
 
load_image:
 
pusha
 
call read_header
 
cmp word [type],'BM'
je ok_image
 
cmp [bpp],24
je ok_image
 
mov eax,13 ; not found !
mov ebx,150*65536+50
mov ecx,100*65536+50
mov edx,0xff0000
int 0x40
 
mov eax,5
mov ebx,100
int 0x40
 
jmp retimage
 
ok_image:
 
call draw_picture_info
 
mov [fileinfoblock+8],dword 0x100000/512
mov eax,0x80000
sub eax,[i_pos]
mov [fileinfoblock+12],eax
push dword [name_string-4]
mov [name_string-4],dword 0x20000
mov eax,58
mov ebx,fileinfoblock
int 0x40
pop dword [name_string-4]
 
mov eax,[x_size]
imul eax,3
 
mov [x_delta],eax
 
mov ebx,[y_size]
dec ebx
imul eax,ebx
add eax,0x80000
 
mov esi,eax
mov edi,0x180000
newln:
push esi
push edi
mov ecx,[x_delta]
cld
rep movsb
pop edi
pop esi
 
sub esi,[x_delta];640*3
add edi,[x_delta];640*3
cmp esi,0x80000
jge newln
 
retimage:
 
popa
 
ret
 
x_delta dd 0x1
 
 
draw_image:
 
pusha
 
; mov eax,7 ; draw with putimage
; mov ebx,0x180000
; mov ecx,200*65536+160
; mov edx,14*65536+28
; int 0x40
; mov eax,5
; mov ebx,200
; int 0x40
 
mov ebx,0 ; show the image as 320x240 picture
mov ecx,0
 
times 6 db 0x90
 
newpix:
 
push ebx
push ecx
 
mov eax,[esp]
imul eax,[y_size]
 
mov ebx,240
xor edx,edx
div ebx
 
imul eax,3
imul eax,[x_size]
 
mov esi,eax
 
mov eax,[esp+4]
imul eax,[x_size]
 
mov ebx,320
xor edx,edx
div ebx
 
imul eax,3
 
add esi,eax
mov edx,[0x180000+esi]
 
 
and edx,0xffffff
 
pop ecx
pop ebx
 
add ebx,20
add ecx,40
mov eax,1
int 0x40
add ebx,-20
add ecx,-40
 
inc ebx
cmp ebx,320
jb newpix
 
xor ebx,ebx
 
inc ecx
cmp ecx,240
jb newpix
 
popa
 
ret
 
set_as_background:
 
pusha
 
mov esi,0x180000
new_smooth:
xor eax,eax
xor ebx,ebx
mov al,[esi]
mov bl,[esi+3]
add eax,ebx
mov bl,[esi+6]
add eax,ebx
mov bl,[esi+9]
add eax,ebx
shr eax,2
and eax,0xff
inc esi
cmp esi,0x180000+640*480*3
jbe new_smooth
 
 
mov eax,15
mov ebx,1
mov ecx,[x_size]
mov edx,[y_size]
int 0x40
 
mov eax,15
mov ebx,5
mov ecx,0x180000
mov edx,0
mov esi,640*480*3
int 0x40
 
mov eax,15
mov ebx,3
int 0x40
 
 
popa
 
ret
 
ya dd 300
addr dd name_string
case_sens db 0
 
 
read_string:
pusha
 
mov edi,[addr]
mov eax,[addr]
mov eax,[eax-4]
mov [temp],eax
 
add edi,eax
 
call print_strings
 
f11:
mov eax,10
int 0x40
cmp eax,2
jne read_done
int 0x40
shr eax,8
 
cmp eax,13
je read_done
 
cmp eax,192
jne noclear
 
xor eax,eax
mov [temp],eax
mov edi,[addr]
mov [edi-4],eax
mov ecx,49
cld
rep stosb
mov edi,[addr]
call print_strings
jmp f11
 
noclear:
 
cmp eax,8
jnz nobsl
cmp [temp],0
jz f11
dec [temp]
mov edi,[addr]
add edi,[temp]
mov [edi],byte 0
 
mov eax,[addr]
dec dword [eax-4]
 
call print_strings
jmp f11
 
nobsl:
cmp [temp],50
jae read_done
 
cmp eax,dword 31
jbe f11
cmp [case_sens],1
je keyok
cmp eax,dword 95
jb keyok
add eax,-32
keyok:
mov edi,[addr]
add edi,[temp]
mov [edi],al
 
inc [temp]
 
mov eax,[addr]
inc dword [eax-4]
call print_strings
cmp [temp],50
jbe f11
 
read_done:
mov ecx,50
sub ecx,[temp]
mov edi,[addr]
add edi,[temp]
xor eax,eax
cld
rep stosb
 
mov [temp],999
 
call print_strings
 
popa
ret
 
print_strings:
pusha
mov eax,13
mov ebx,80*65536+6*45
mov ecx,[ya]
shl ecx,16
add ecx,12
mov edx,0xffffff
int 0x40
 
mov edx,[addr]
mov esi,[edx-4]
mov eax,4
mov ebx,80*65536+2
add ebx,[ya]
mov ecx,0
int 0x40
 
cmp [temp],50
ja @f
 
mov eax,[ya]
mov ebx,eax
shl eax,16
add eax,ebx
add eax,10
mov ecx,eax
 
mov eax,[temp]
imul eax,eax,6
add eax,80
mov ebx,eax
shl eax,16
add ebx,eax
 
mov eax,38
mov edx,0
int 0x40
@@:
 
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,20*65536+444 ; [x start] *65536 + [x size]
mov ecx,10*65536+333 ; [y start] *65536 + [y size]
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl
mov esi,0x808899ff ; color of grab bar RRGGBB,8->color gl
mov edi,0x008899ff ; 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,0x10ddeeff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
mov eax,8
mov ebx,20*65536+52
mov ecx,295*65536+16
mov edx,2
mov esi,0x306090
int 0x40
 
add ebx,336*65536+20
add ecx,5*65536
mov edx,3
int 0x40
 
sub ecx,20*65536
mov edx,4
int 0x40
 
sub ecx,40*65536
inc edx
int 0x40
 
add ecx,20*65536
inc edx
int 0x40
 
mov ebx,346*65536+45
mov edx,info+1
mov esi,15
newinfo:
mov ecx,[tcolor]
cmp [edx-1],byte 'w'
jne nowhite
mov ecx,[btcolor]
nowhite:
mov eax,4
int 0x40
add ebx,10
add edx,16
cmp [edx-1],byte 'x'
jne newinfo
 
mov ebx,20*65536+300 ; draw info text with function 4
mov ecx,[btcolor]
mov edx,text
mov esi,70
newline:
mov eax,4
int 0x40
add ebx,10
add edx,esi
cmp [edx],byte 'x'
jne newline
 
call print_strings
 
call draw_image
 
call draw_picture_info
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
; DATA AREA
 
tcolor dd 0x000000
btcolor dd 0x224466+0x808080
 
 
text:
db ' FILE: '
db 'x'
 
info:
db ' IMAGE INFO '
db ' '
db ' X: '
db ' Y: '
db ' '
db ' BPP: '
db ' '
db ' '
db ' 16M COLOURS '
db ' 640x480 max '
times 10 db ' '
db 'w TILED '
db ' '
db 'w STRETCH '
db ' '
db 'w SET AS BGR '
db ' '
db 'w LOAD '
db 'x'
 
 
labelt: db 'BMP VIEWER'
labellen:
 
I_END:
I_Param:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/bmpview/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm bmpview.asm bmpview
@pause
/programs/media/bmpview/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm bmpview.asm bmpview
@pause
/programs/media/bmpview/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/cdp/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm cdp.asm cdp
@pause
/programs/media/cdp/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm cdp.asm cdp
@pause
/programs/media/cdp/trunk/cdp.asm
0,0 → 1,1332
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Audio CD player; code by Dmitry Yushko - dma@bn.by ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
include "lang.inc"
include "macros.inc"
 
FALSE equ 0
TRUE equ 1
 
ESC_KEY equ 27
LEFT_KEY equ 176
RIGHT_KEY equ 179
 
NORMAL_PLAY equ 0
REPEAT_TRACK equ 1
REPEAT_DISK equ 2
SHUFFLE_DISK equ 3
 
COLOR_FUNC_BUTS equ 0x00dddddd
 
use32
 
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x2000 ; required amount of memory
dd 0x2000 ; esp = 0x7fff0
dd 0x0, 0x0 ; reserved=no extended header
 
START:
call chk_cdrom ; start of execution
call read_cd
call draw_window ; at first, draw the window
still:
 
mov eax,23
mov ebx,10 ; wait here for event
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
 
call draw_info
cmp [curr_trk],0
je @f
call current_trk_time
@@:
jmp still
 
red: ; redraw
call draw_window
 
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
 
;====== hotkeys:
cmp ah,0x61
jb @f
cmp ah,0x7a
ja @f
and ah,11011111b
@@:
 
cmp ah,'P' ;PLAY
jne no_key_play
call play_acd
jmp still
no_key_play:
 
cmp ah,'S' ;STOP
jne no_key_stop
mov [if_paused],FALSE
call stop_playing
jmp still
no_key_stop:
 
cmp ah,'N' ;NEXT
jne no_key_next
call play_next_trk
jmp still
no_key_next:
 
cmp ah,'B' ;BACK
jne no_key_back
call play_back_trk
jmp still
no_key_back:
 
cmp ah,'F' ;FORWARD
jne no_key_fwd
call fast_forward
jmp still
no_key_fwd:
 
cmp ah,'R' ;REWIND
jne no_key_rewind
call fast_rewind
jmp still
no_key_rewind:
 
cmp ah,'M' ;MODE
jne no_key_mode
call change_mode
jmp still
no_key_mode:
 
 
cmp ah,'L' ;READ PLAYLIST
jne no_key_list
mov [if_paused],FALSE
mov [curr_trk],0
call stop_playing
call chk_cdrom
call read_cd
jmp still
no_key_list:
 
cmp ah,50 ;F1 key
jz itsahelpkey
 
cmp ah,'H' ;HELP
jne no_key_help
itsahelpkey:
cmp [flag],4
je still
cmp [flag],1
jne was_it_ok_false
mov [was_it_ok],TRUE
jmp flag4_done
was_it_ok_false:
mov [was_it_ok],FALSE
flag4_done:
mov [flag],4
mov [help_screen],1
call draw_window
jmp still
no_key_help:
 
 
cmp ah,ESC_KEY
jne no_esc_key
cmp [flag],4
jne still
cmp [was_it_ok],FALSE
jne was_it_ok_true
mov [flag],0
jmp end_esc_key
was_it_ok_true:
mov [flag],1
end_esc_key:
call draw_window
no_esc_key:
 
cmp ah,LEFT_KEY
jne no_left_key
cmp [flag],4
jne still
cmp [help_screen],1
jz still
dec [help_screen]
call draw_window
no_left_key:
 
cmp ah,RIGHT_KEY
jne no_right_key
cmp [flag],4
jne still
cmp [help_screen],3
jz still
inc [help_screen]
call draw_window
no_right_key:
 
 
jmp still
 
 
button: ; button
mov eax,17
int 0x40
 
cmp ah,1 ; button id=1 ?
jnz no_but_close
mov eax,24
mov ebx,3
int 0x40
mov eax,0xffffffff ; close this program
int 0x40
no_but_close:
 
cmp ah,2
jne no_but_play
call play_acd
jmp still
no_but_play:
 
cmp ah,3
jne no_but_stop
mov [if_paused],FALSE
call stop_playing
jmp still
no_but_stop:
 
cmp ah,4
jne no_but_reread
mov [curr_trk],0
call chk_cdrom
call read_cd
mov [if_paused],FALSE
call stop_playing
jmp still
no_but_reread:
 
cmp ah,5
jne no_but_next
call play_next_trk
jmp still
no_but_next:
 
cmp ah,6
jne no_but_back
call play_back_trk
jmp still
no_but_back:
 
cmp ah,7
jne no_but_mode
call change_mode
jmp still
no_but_mode:
 
cmp ah,8
jne no_but_frew
call fast_rewind
jmp still
no_but_frew:
 
cmp ah,9
jne no_but_ffwd
call fast_forward
jmp still
no_but_ffwd:
 
cmp ah,10
jb no_but_track
cmp ah,40
ja no_but_track
call read_cd
cmp [flag],1
jne no_but_track
mov cl,ah
sub cl,10
mov [curr_trk],cl
mov cl,[max_trk]
mov [shuftab],cl
call stop_playing
call renew_shuftab
call play_n_track
call rem_time_trk
jmp still
no_but_track:
 
jmp still
 
 
change_mode:
cmp [mode],3
jne inc_mode
mov [mode],0
jmp end_but_mode
inc_mode:
inc [mode]
end_but_mode:
call draw_info
ret
 
play_next_trk:
cmp [curr_trk],0
je @play_next_trk
cmp [if_paused],TRUE
je @play_next_trk
cmp [mode],NORMAL_PLAY
jne play_next_mode1
xor eax,eax
mov al,[curr_trk]
cmp [max_trk],al
je @play_next_trk
inc [curr_trk]
cmp [if_stopped],TRUE
je @play_next_trk
call play_n_track
jmp @play_next_trk
play_next_mode1:
cmp [mode],REPEAT_TRACK
jne play_next_mode2
cmp [if_stopped],TRUE
je @play_next_trk
call play_n_track
jmp @play_next_trk
play_next_mode2:
cmp [mode],REPEAT_DISK
jne play_next_mode3
xor eax,eax
mov al,[curr_trk]
cmp [max_trk],al
jne play_next_mode2_go
mov [curr_trk],1
cmp [if_stopped],TRUE
je @play_next_trk
call play_n_track
jmp @play_next_trk
play_next_mode2_go:
inc [curr_trk]
cmp [if_stopped],TRUE
je @play_next_trk
call play_n_track
jmp @play_next_trk
play_next_mode3:
cmp [mode],SHUFFLE_DISK
jne @play_next_trk
call shuffle_track
@play_next_trk:
ret
 
play_back_trk:
cmp [curr_trk],0
je @play_back_trk
cmp [if_paused],TRUE
je @play_back_trk
cmp [mode],NORMAL_PLAY
jne play_back_mode1
xor eax,eax
mov al,[curr_trk]
cmp al,1
je @play_back_trk
dec [curr_trk]
cmp [if_stopped],TRUE
je @play_next_trk
call play_n_track
jmp @play_back_trk
play_back_mode1:
cmp [mode],REPEAT_TRACK
jne play_back_mode2
cmp [if_stopped],TRUE
je @play_next_trk
call play_n_track
jmp @play_back_trk
play_back_mode2:
cmp [mode],REPEAT_DISK
jne play_back_mode3
xor eax,eax
mov al,[curr_trk]
cmp al,1
jne play_back_mode2_go
mov al,[max_trk]
mov [curr_trk],al
cmp [if_stopped],TRUE
je @play_next_trk
call play_n_track
jmp @play_back_trk
play_back_mode2_go:
dec [curr_trk]
cmp [if_stopped],TRUE
je @play_next_trk
call play_n_track
jmp @play_back_trk
play_back_mode3: ;(shuffle)
; call shuffle_track
@play_back_trk:
ret
 
 
current_trk_time:
cmp [if_stopped],TRUE
je menshe
call get_uptime
mov ebx,[stimtrk]
sub eax,ebx
; eax now is seconds from track start * 100
xor edx,edx
mov ecx,100
div ecx
mov [curr_trk_pg_time],eax
mov ebx,[curr_trk_length]
; add eax,1 ;{inc curr time on 1 sec)
cmp eax,ebx
jb menshe
call stop_playing
cmp [mode],SHUFFLE_DISK
jne @f
call shuffle_track
@@:
cmp [mode],REPEAT_TRACK
je @@mode_repeat_1
mov al,[max_trk]
cmp [curr_trk],al
jb @@next_trk_ok
cmp [mode],REPEAT_DISK
jne menshe
mov [curr_trk],0
@@next_trk_ok:
inc [curr_trk]
@@mode_repeat_1:
call play_n_track
menshe:
ret
 
 
rem_time_trk:
call get_uptime
mov [stimtrk],eax
ret
 
fast_forward:
cmp [if_stopped],TRUE
je end_ffwd
mov eax,[curr_trk_pg_time]
add eax,5
cmp eax,[curr_trk_length]
jae end_ffwd
cmp [stimtrk],500
jbe end_ffwd
sub [stimtrk],500
call current_trk_time
call play_from_x_time
end_ffwd:
ret
 
fast_rewind:
cmp [if_stopped],TRUE
je end_frew
cmp [curr_trk_pg_time],5
jbe end_frew
add [stimtrk],500
call current_trk_time
call play_from_x_time
end_frew:
ret
 
renew_shuftab:
mov ecx,40
@rn:
mov [shuftab+ecx],cl
loop @rn
mov cl,[max_trk]
mov [shuftab],cl
ret
 
 
shuffle_track:
call get_uptime
ror eax,16
cmp eax,0
je shuffle_track
xor ecx,ecx
mov cl,[shuftab]
cmp ecx,1
je @enddsk
xor edx,edx
div ecx
cmp edx,0
je shuffle_track
xor ecx,ecx
mov cl,[max_trk]
@main_loop:
xor eax,eax
mov al,[shuftab+ecx]
cmp al,0
je @f
dec edx
cmp edx,0
jne @f
mov cl,[shuftab]
dec cl
mov [shuftab],cl
mov [shuftab+eax],0
mov [curr_trk],al
call play_n_track
jmp @endofshuffle
@@:
loop @main_loop
jmp @endofshuffle
@enddsk:
call stop_playing
@endofshuffle:
 
ret
 
 
 
 
play_from_x_time:
xor ecx,ecx
mov cl,[curr_trk]
shl cl,3
add cl,1
add ecx,cdp
mov ebx,[ecx]
mov ecx,ebx
and ecx,0x00ffffff
 
mov eax,[curr_trk_pg_time]
xor edx,edx
mov ebx,60
div ebx
add cl,al ;mins
add dl,ch
xor eax,eax
mov al,dl
xor edx,edx
div ebx
add cl,al ;real min
mov ch,dl ;real sec
 
mov eax,24
mov ebx,1
int 0x40
ret
 
play_n_track:
mov [if_paused],FALSE
mov [if_stopped],FALSE
mov [curr_trk_pg_time],0
call draw_window
; mov eax,26
; mov ebx,9
; int 0x40
call get_uptime
mov [stimtrk],eax
xor ebx,ebx
xor ecx,ecx
mov cl,[curr_trk]
inc cl
shl cl,3
add cl,1
add ecx,cdp
mov ebx,[ecx]
and ecx,0x00ffffff
mov ecx,ebx
;get_minutes:
and ecx,0x000000ff
mov eax,ecx
imul eax,60
;get_seconds:
mov ecx,ebx
and ecx,0x0000ff00
shr ecx,8
add eax,ecx
;eax now is next pos in secs
mov [next_pos_sec],eax
;eax now is current pos in secs
xor ebx,ebx
xor ecx,ecx
mov cl,[curr_trk]
shl cl,3
add cl,1
add ecx,cdp
mov ebx,[ecx]
and ecx,0x00ffffff
mov ecx,ebx
;get_minutes:
and ecx,0x000000ff
mov eax,ecx
imul eax,60
;get_seconds:
mov ecx,ebx
and ecx,0x0000ff00
shr ecx,8
add eax,ecx
;eax now is current pos in secs
mov ecx,[next_pos_sec]
sub ecx,eax
;eax now is length of trk in sec
mov [curr_trk_length],ecx
;now play that!
mov ecx,ebx
mov eax,24
mov ebx,1
int 0x40
ret
 
 
play_acd:
call chk_cdrom
call read_cd
call draw_window
call renew_shuftab
mov cl,[curr_trk]
cmp cl,0
jnz play_acd_trk_ok
mov cl,[max_trk]
mov [shuftab],cl
mov [curr_trk],1
jmp playing_no_pause
play_acd_trk_ok:
; start_chk_on_pause:
cmp [if_paused],TRUE
jne pause_playing
mov [if_stopped],FALSE
mov [if_paused],FALSE
call current_trk_time
mov eax,[curr_trk_pg_time]
mov ebx,[paused_time]
sub eax,ebx
imul eax,100
add [stimtrk],eax
call current_trk_time
call play_from_x_time
call draw_window
jmp end_play_acd
pause_playing:
cmp [curr_trk_pg_time],0
je playing_no_pause
mov eax,[curr_trk_pg_time]
mov [paused_time],eax
mov [if_paused],TRUE
call stop_playing
call draw_window
jmp end_play_acd
playing_no_pause:
mov [if_paused],FALSE
call rem_time_trk
call play_n_track
call draw_window
end_play_acd:
ret
 
stop_playing:
mov eax, 24
mov ebx,3
int 0x40
mov cl,[max_trk]
mov [shuftab],cl
mov [if_stopped],TRUE
cmp [if_paused],TRUE
je end_stop_playing
mov [curr_trk_pg_time],0
end_stop_playing:
call draw_window
ret
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
draw_info:
;bar->
mov eax,13
mov ebx, 10 shl 16 + 41
mov ecx,120 shl 16 + 9
mov edx,0x00ffffff
int 0x40
mov ebx, 96 shl 16 + 11
int 0x40
mov ebx, 185 shl 16 + 11
int 0x40
mov ebx, 200 shl 16 + 11
int 0x40
mov ebx, 150 shl 16 + 11
int 0x40
mov ebx, 165 shl 16 + 11
int 0x40
;bar<-
 
mov eax,4
mov ebx,10 shl 16 +120
mov ecx,0x00111111
cmp [mode],NORMAL_PLAY
jne info_mode_1
mov edx,mode_normal
jmp info_mode_end
info_mode_1:
cmp [mode],REPEAT_TRACK
jne info_mode_2
mov edx,mode_repeat_1
jmp info_mode_end
info_mode_2:
cmp [mode],REPEAT_DISK
jne info_mode_3
mov edx,mode_repeat_all
jmp info_mode_end
info_mode_3:
cmp [mode],SHUFFLE_DISK
jne info_mode_end
mov edx,mode_shuffle
; mov ecx,0x00aaaaaa
; mov cl,[max_trk]
; mov [shuftab],cl
jmp info_mode_end
info_mode_end:
mov esi,7
int 0x40
 
;num info ->
mov eax,47
xor ebx,ebx
mov bl,0
mov bh,0
or ebx,0x20000 ;X0000 - number of digits to draw
xor ecx,ecx
mov cl, [curr_trk] ;number to draw
mov edx,96 shl 16 + 120
mov esi,0x111111
int 0x40
mov eax,[curr_trk_pg_time]
xor edx,edx
mov ecx,60
div ecx
push edx
mov ecx,eax
mov eax,47
mov edx,150 shl 16 + 120
int 0x40
pop ecx
mov edx,165 shl 16 + 120
int 0x40
mov eax,[curr_trk_length]
xor edx,edx
mov ecx,60
div ecx
push edx
mov ecx,eax
mov eax,47
mov edx,185 shl 16 + 120
int 0x40
pop ecx
mov edx,200 shl 16 + 120
int 0x40
;num info <-
ret
 
 
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, 50*65536+219 ; [x start] *65536 + [x size]
mov ecx,100*65536+168 ; [y start] *65536 + [y size]
mov edx,0x03ffffff ; color of work area RRGGBB
mov esi,0x8099bbff ; color of grab bar RRGGBB,8->color glide
mov edi,0x0099bbee ; 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,0xf000ffff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
mov eax,13 ;bar
mov ebx,8 shl 16 + 204
mov ecx,28 shl 16 + 84
mov edx,0x000fe6f5
int 0x40
 
;info ->
mov eax,4
mov ebx,63 shl 16 + 120
mov ecx,0x00111111
mov edx,playing_trk_info
mov esi,6
int 0x40
mov ebx,120 shl 16 + 120
mov edx,playing_time_info
; mov esi,5
dec esi
int 0x40
mov ebx,178 shl 16 + 120
mov edx,slash
mov esi,1
int 0x40
mov ebx,196 shl 16 + 120
mov edx,column
; mov esi,1
int 0x40
mov ebx,161 shl 16 + 120
mov edx,column
; mov esi,1
int 0x40
;info <-
 
; button MODE
mov eax,8
mov ebx,12*65536+20
mov ecx,135*65536+20
mov edx,7
mov esi,COLOR_FUNC_BUTS
int 0x40
; text
mov eax,4
mov ebx,19*65536+142
mov ecx,0xf00f73f5;ffff0f
mov edx,but_mode_lab
mov esi,1
int 0x40
 
; button BACK
mov eax,8
mov ebx,37*65536+20
mov ecx,135*65536+20
mov edx,6
mov esi,COLOR_FUNC_BUTS
int 0x40
mov [coord_x],51
mov [coord_y],141
call draw_left_triangle
mov [coord_x],44
call draw_vertical_line
 
; button NEXT
mov eax,8
mov ebx,62*65536+20
mov ecx,135*65536+20
mov edx,5
mov esi,COLOR_FUNC_BUTS
int 0x40
mov [coord_x],68
mov [coord_y],141
call draw_right_triangle
mov [coord_x],74
call draw_vertical_line
 
; button REWIND
mov eax,8
mov ebx,87*65536+20
mov ecx,135*65536+20
mov edx,8
mov esi,COLOR_FUNC_BUTS
int 0x40
mov [coord_x],102
mov [coord_y],141
call draw_left_triangle
mov [coord_x],97
call draw_left_triangle
 
; button STOP
mov eax,8
mov ebx,112*65536+20
mov ecx,135*65536+20
mov edx,3
mov esi,COLOR_FUNC_BUTS
int 0x40
mov [coord_x],118
mov [coord_y],142
call draw_square
 
 
; button PLAY
mov eax,8
mov ebx,137*65536+20
mov ecx,135*65536+20
mov edx,2
mov esi,COLOR_FUNC_BUTS
int 0x40
cmp [if_stopped],TRUE
je playing_paused
cmp [if_paused],TRUE
je playing_paused
mov [coord_x],144
mov [coord_y],141
call draw_vertical_line
mov [coord_x],149
call draw_vertical_line
jmp end_draw_play
playing_paused:
mov [coord_x],144
mov [coord_y],141
call draw_right_triangle
end_draw_play:
 
 
; button FORWARD
mov eax,8
mov ebx,162*65536+20
mov ecx,135*65536+20
mov edx,9
mov esi,COLOR_FUNC_BUTS
int 0x40
mov [coord_x],167
mov [coord_y],141
call draw_right_triangle
mov [coord_x],172
call draw_right_triangle
 
; button RE-READ PLAYLIST
mov eax,8
mov ebx,187*65536+20
mov ecx,135*65536+20
mov edx,4
mov esi,COLOR_FUNC_BUTS
int 0x40
mov [coord_x],192
mov [coord_y],140
call draw_vert_list_line
dec [coord_y]
call draw_hor_list_line
mov [coord_y], 151
call draw_hor_list_line
mov [coord_x],202
mov [coord_y],140
call draw_vert_list_line
mov [coord_x],195
mov [coord_y], 142
call draw_str_list_line
mov [coord_y],145
call draw_str_list_line
mov [coord_y],148
call draw_str_list_line
 
cmp [flag],1
jne flag2
;Draw tracs buttons
xor eax,eax
xor ebx,ebx
mov ecx,10
mov al,[cdp+3]
mov [max_trk],al
xor edi,edi
mov di,ax
mov [posx],12
mov [posy],32
mov [tracs],1
draw_tracs_buttons:
mov eax,8
xor ebx,ebx
mov bl,[posx]
shl ebx,16
add ebx,15
xor ecx,ecx
mov cl,[posy]
shl ecx,16
add ecx,15
xor edx,edx
mov dx,[tracs]
add edx,10
mov esi,0xaaaaaa
add esi,edi
int 0x40
;---draw tracs numbers
mov eax,47
xor ebx,ebx
mov bl,0
or ebx,0x20000 ;number of digits to draw
xor ecx,ecx
mov cx, [tracs] ;number to draw
xor edx,edx
mov dl,[posx]
add dl,3
shl edx,16
add dl,[posy]
add dl,5
mov esi,0xffffff
int 0x40
;---
mov al,[posx]
add al,20
mov [posx],al
xor eax,eax
mov ax,[tracs]
mov bl,10
div bl
cmp ah,0
jnz no_new_str
mov al,[posxstart]
mov [posx], al
mov al,[posy]
add al,20
mov [posy],al
no_new_str:
inc [tracs]
cmp [tracs],41
je flag2
dec edi
cmp edi,0
jnz draw_tracs_buttons
 
flag2:
cmp [flag],2
jne flag3
mov eax,4
mov ebx, 20 shl 16 +67
mov ecx,0xf0ffff00
mov edx,define_cdrom
mov esi,define_cdrom_len-define_cdrom
int 0x40
flag3:
cmp [flag],3
jne flag4
mov eax,4
mov ebx, 47 shl 16 +67
mov ecx,0xf0ffff00
mov edx,no_cda
mov esi,no_cda_len-no_cda
int 0x40
flag4:
cmp [flag],4
jne flag5
;help screen
cmp [help_screen],1
jnz @hs2
mov edx,help1
jmp @ehs
@hs2:
cmp [help_screen],2
jnz @hs3
mov edx,help2
jmp @ehs
@hs3:
mov edx,help3
@ehs:
xor edi,edi
mov ebx,25*65536+30
new_line:
mov eax,4
mov ecx,0x111111
mov esi,31
int 0x40
noline:
add ebx,10
add edx,31
inc edi
cmp [edx],byte 'x'
jnz new_line
flag5:
call draw_info
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
draw_right_triangle:
mov ebx,[coord_x]
mov ecx,[coord_y]
mov edx,0x00111111
mov esi,5
mov eax,9
start_draw_pixel:
push ebx
cmp eax,5
jb y_menshe_5
mov esi,10
sub esi,eax
jmp draw_pixel
y_menshe_5:
mov esi,eax
draw_pixel:
dec esi
inc ebx
push eax
mov eax,1
int 0x40
pop eax
cmp esi,0
jne draw_pixel
pop ebx
dec eax
inc ecx
cmp eax,0
jne start_draw_pixel
ret
 
draw_square:
mov ebx,[coord_x]
mov ecx,[coord_y]
mov edx,0x00111111
mov eax,7
q_start_draw_pixel:
push ebx
mov esi,7
q_draw_pixel:
dec esi
inc ebx
push eax
mov eax,1
int 0x40
pop eax
cmp esi,0
jne q_draw_pixel
pop ebx
dec eax
inc ecx
cmp eax,0
jne q_start_draw_pixel
ret
 
draw_left_triangle:
mov ebx,[coord_x]
mov ecx,[coord_y]
mov edx,0x00111111
mov esi,5
mov eax,9
l_start_draw_pixel:
push ebx
cmp eax,5
jb l_y_menshe_5
mov esi,10
sub esi,eax
jmp l_draw_pixel
l_y_menshe_5:
mov esi,eax
l_draw_pixel:
dec esi
dec ebx
push eax
mov eax,1
int 0x40
pop eax
cmp esi,0
jne l_draw_pixel
pop ebx
dec eax
inc ecx
cmp eax,0
jne l_start_draw_pixel
ret
 
draw_vertical_line:
mov eax,2
mov ebx,[coord_x]
mov edx,0x00111111
@@draw_2_line:
mov ecx,[coord_y]
dec ecx
mov esi,9
start_draw_vline:
inc ecx
push eax
mov eax,1
int 0x40
pop eax
dec esi
cmp esi,0
jne start_draw_vline
dec eax
inc ebx
cmp eax,0
jne @@draw_2_line
ret
 
draw_vert_list_line:
mov eax,1
mov ebx,[coord_x]
mov edx,0x00111111
mov ecx,[coord_y]
dec ecx
mov esi,11
vlstart_draw_vline:
inc ecx
int 0x40
dec esi
cmp esi,0
jne vlstart_draw_vline
dec eax
inc ebx
ret
 
draw_hor_list_line:
mov eax,1
mov ebx,[coord_x]
mov edx,0x00111111
mov ecx,[coord_y]
dec ebx
mov esi,11
hlstart_draw_vline:
inc ebx
int 0x40
dec esi
cmp esi,0
jne hlstart_draw_vline
dec eax
inc ebx
ret
 
draw_str_list_line:
mov eax,1
mov ebx,[coord_x]
mov edx,0x00111111
mov ecx,[coord_y]
dec ebx
mov esi,5
slstart_draw_vline:
inc ebx
int 0x40
dec esi
cmp esi,0
jne slstart_draw_vline
dec eax
inc ebx
ret
 
 
chk_cdrom:
mov eax,24
mov ebx,1
int 0x40
cmp eax,0
je chk_cdrom_ok
mov [flag],2
call draw_window
jmp chk_cdrom_end
chk_cdrom_ok:
mov [flag],0
chk_cdrom_end:
ret
 
read_cd:
mov [if_stopped],TRUE
push ax
cmp [flag],2
je read_cd_end
mov al,101
mov [cdp+3],al
mov eax,24
mov ebx,2
mov ecx, cdp
mov edx,321
int 0x40
mov [flag],1
mov al,100
cmp [cdp+3],al
jb read_cd_end
mov [flag],3
call draw_window
read_cd_end:
pop ax
ret
 
get_uptime:
push ebx
mov eax,26
mov ebx,9
int 0x40
pop ebx
ret
 
; DATA AREA
 
paused_time dd 0
if_paused db FALSE
coord_x dd 0
coord_y dd 0
flag db 0
tracs dw 1
posx db 12
posy db 32
posxstart db 12
curr_trk db 0
max_trk db 0
stimtrk dd 0
help_screen db 0
next_pos_sec dd 0
curr_trk_length dd 0
curr_trk_pg_time dd 0
was_it_ok db FALSE
if_stopped db FALSE
mode db NORMAL_PLAY
 
shuftab db 00,01,02,03,04,05,06,07,08,09
db 10,11,12,13,14,15,16,17,18,19
db 20,21,22,23,24,25,26,27,28,29
db 30,31,32,33,34,35,36,37,38,39
db 40
 
but_mode_lab: db 'M'
 
playing_time_info: db 'Time '
slash db '/'
column db ':'
mode_normal db 'Normal '
mode_repeat_1 db 'Rep trk'
mode_repeat_all db 'Rep all'
mode_shuffle db 'Shuffle'
playing_trk_info: db 'Track '
 
define_cdrom: db 'Please, define your CD-ROM'
define_cdrom_len:
 
no_cda: db 'Audio CD not found'
no_cda_len:
 
labelt:
db 'CD player'
labellen:
 
help1: db 'HotKeys: '
db 'H - this screen (Help) '
db 'P - Play/Pause current track '
db 'S - Stop playing '
db 'L - re-read playList '
db 'N - play Next track '
db 'B - play previous track (Back) '
db ' next ->'
db 'x'
help2: db 'HotKeys: '
db 'F - fast Forward track '
db 'R - fast Rewind track '
db 'M - change Mode '
db ' '
db ' '
db ' '
db '<- prev next ->'
db 'x'
help3: db 'About: '
db 'Audio CD Player ver 1.1beta-2 '
db 'All questions, wishes and '
db 'advices please send to: '
db ' E-mail: dma@bn.by '
db ' FidoNet: 2:450/258.75 '
db ' '
db '<- prev '
db 'x'
cdp:
 
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/cdp/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/cdplay/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm cdplay.asm cdplay
@pause
/programs/media/cdplay/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm cdplay.asm cdplay
@pause
/programs/media/cdplay/trunk/cdplay.asm
0,0 → 1,482
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; CD PLAYER - Compile with fasm
;
 
use32
 
org 0x0
db 'MENUET00' ; 8 byte id
dd 38 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x1000 ; reguired amount of memory
dd 0x1000
dd 0x00000000 ; reserved=no extended header
 
include 'lang.inc'
include 'macros.inc'
 
START:
 
call draw_window
 
still:
 
mov eax,10
int 0x40
 
cmp eax,1
jz red
cmp eax,2
jz key
cmp eax,3
jz button
jmp still
 
red:
call draw_window
jmp still
 
key:
mov eax,2
int 0x40
jmp still
 
button:
mov eax,17
int 0x40
 
cmp ah,byte 41
jnz nostop
call stop
jmp still
nostop:
 
cmp ah,byte 42
jnz nogetinfo
call getinfo
jmp still
nogetinfo:
 
pusha
 
cmp ah,100
jnz err
 
jmp noerr
 
err:
 
xor ecx,ecx
mov cl,ah
shl ecx,3
add ecx,cdinfo
add ecx,1
xor ebx,ebx
mov ebx,[ecx]
and ebx,0x00ffffff
mov ecx,ebx
 
mov ebx,1
mov eax,24
int 0x40
 
cmp eax,0
je noerr
 
error:
 
mov eax,13
mov ebx,10*65536+215
mov ecx,115*65536+13
mov edx,0x0088aacc
int 0x40
 
mov eax,dword 0x00000004 ; write text
mov ebx,12*65536+117
mov ecx,[tcolor]
mov edx,infotext2
mov esi,itl2-infotext2
int 0x40
 
mov eax,5
mov ebx,200
int 0x40
 
noerr:
 
popa
 
shr eax,8
and eax,255
mov ebx,0
mov ecx,10
 
cmp eax,100
jnz noend
mov eax,-1
int 0x40
noend:
 
newc:
 
cmp eax,ecx
jb dri
inc ebx
sub eax,ecx
 
jmp newc
 
 
dri:
 
mov ecx,48
add ebx,ecx
mov [infotext+0],bl
add eax,ecx
mov [infotext+1],al
call drawinfo
jmp still
 
 
getinfo:
 
mov eax,24 ; get info
mov ebx,1
mov ecx,0x010100
int 0x40
 
cmp eax,0
jnz gierror
 
mov eax,13
mov ebx,10*65536+215
mov ecx,115*65536+13
mov edx,0x0088aacc
int 0x40
mov eax,dword 0x00000004 ; write text
mov ebx,12*65536+117
mov ecx,dword 0x00ffffff ; 8b window nro - RR GG BB color
mov edx,infotext3 ; pointer to text beginning
mov esi,itl3-infotext3 ; text length
int 0x40
 
mov eax,5
mov ebx,100*10
int 0x40
 
mov eax,24 ; get info
mov ebx,2
mov ecx,cdinfo
mov edx,256
int 0x40
 
cmp eax,0
jz gi1
 
gierror:
 
mov eax,13
mov ebx,10*65536+215
mov ecx,115*65536+13
mov edx,0x0088aacc
int 0x40
 
mov eax,dword 0x00000004 ; write text
mov ebx,12*65536+117
mov ecx,dword 0x00ffffff ; 8b window nro - RR GG BB color
mov edx,infotext2 ; pointer to text beginning
mov esi,itl2-infotext2 ; text length
int 0x40
 
mov eax,5
mov ebx,200
int 0x40
 
gi1:
 
call drawinfo
ret
 
 
 
stop:
 
mov eax,24 ; get info
mov ebx,3
int 0x40
 
ret
 
 
 
; info bar
 
 
drawinfo:
 
 
; end
 
xor eax,eax
xor ebx,ebx
mov ecx,10
mov al,[cdinfo+3]
cld
 
newco:
 
cmp eax,ecx
jb noco
 
add ebx,1
sub eax,ecx
jmp newco
 
noco:
 
add al,48
mov [infotext+32],al
 
add bl,48
mov [infotext+31],bl
 
 
; start
 
xor eax,eax
xor ebx,ebx
mov al,[cdinfo+2]
cld
 
newco2:
 
cmp eax,ecx
jb noco2
 
add ebx,1
sub eax,ecx
jmp newco2
 
noco2:
 
add al,48
mov [infotext+17],al
 
add bl,48
mov [infotext+16],bl
 
mov eax,13
mov ebx,10*65536+219
mov ecx,115*65536+13
mov edx,[col]
sub edx,0x101010
int 0x40
 
mov eax,4 ; write text
mov ebx,12*65536+117
mov ecx,dword 0x00ffffff ; 8b window nro - RR GG BB color
mov edx,infotext ; pointer to text beginning
mov esi,itl-infotext ; text length
int 0x40
 
ret
 
 
draw_window:
 
pusha
 
mov eax,12 ; tell os about redraw
mov ebx,1
int 0x40
 
mov eax,0 ; define and draw window
mov ebx,170*65536+240
mov ecx,40*65536+135
mov edx,0x00b6aaff
mov esi,0x80b9aaff; bbee - 0x202020
mov edi,0x00b9aaff ;bbee
mov edx,[col]
add edx,0x00000000
mov esi,[col]
add esi,0x80000000
mov edi,[col]
int 0x40
 
mov eax,4 ; write text
mov ebx,8*65536+8
mov ecx,[tcolor]
mov edx,labelt
mov esi,labellen-labelt
int 0x40
 
mov eax,8 ; CLOSE BUTTON
mov ebx,(240-18)*65536+10
mov ecx,6 *65536+10
mov edx,100
mov esi,[col]
sub esi,0x302010
int 0x40
 
 
; first row
 
mov eax,8 ; button
mov edx,1 ; button number
mov ebx,9*65536+21 ; button start x & size
mov ecx,30*65536+13 ; button start y & size
mov esi,[bcolor] ; button color
newbutton1:
pusha
int 0x40
popa
 
pusha
mov eax,dword 0x00000004
and ebx,65535*65536
shr ecx,16
add ebx,ecx
add ebx,6*65536+3
mov ecx,[tcolor]
shl edx,1
add edx,nro-2
mov esi,2
int 0x40
popa
 
add ebx,22*65536
inc edx
cmp edx,11
jnz newbutton1
 
; second row
 
mov eax,8 ; button
mov edx,11 ; button number
mov ebx,9*65536+21 ; button start x & size
mov ecx,50*65536+13 ; button start y & size
mov esi,[bcolor] ; button color
newbutton2:
pusha
int 0x40
popa
 
pusha
mov eax,dword 0x00000004
and ebx,65535*65536
shr ecx,16
add ebx,ecx
add ebx,6*65536+3
mov ecx,[tcolor]
shl edx,1
add edx,nro2-2-20
mov esi,2
int 0x40
popa
 
 
add ebx,22*65536
inc edx
cmp edx,21
jnz newbutton2
 
; third row
 
mov eax,8 ; button
mov edx,21 ; button number
mov ebx,9*65536+21 ; button start x & size
mov ecx,70*65536+13 ; button start y & size
mov esi,[bcolor] ; button color
newbutton3:
pusha
int 0x40
popa
 
pusha
mov eax,dword 0x00000004
and ebx,65535*65536
shr ecx,16
add ebx,ecx
add ebx,6*65536+3
mov ecx,[tcolor]
shl edx,1
add edx,nro3-2-40
mov esi,2
int 0x40
popa
 
add ebx,22*65536
inc edx
cmp edx,31
jnz newbutton3
 
 
; fourth row
 
mov eax,8 ; button
mov edx,41 ; button number
mov ebx,9*65536+109 ; button start x & size
mov ecx,90*65536+13 ; button start y & size
mov esi,0x00aabbcc ; button color
newbutton4:
pusha
int 0x40
popa
 
pusha
mov eax,4
and ebx,65535*65536
shr ecx,16
add ebx,ecx
add ebx,9*65536+3
mov ecx,[tcolor]
sub edx,41
shl edx,4
add edx,text
mov esi,16
int 0x40
popa
 
add ebx,110*65536
inc edx
cmp edx,43
jnz newbutton4
 
call drawinfo
 
mov eax,12 ; tell os about redraw end
mov ebx,2
int 0x40
 
popa
ret
 
 
 
 
; DATA AREA
 
col dd 0x7777aa
tcolor dd 0xffffff
bcolor dd 0xaabbcc
labelt: db 'CD PLAYER'
labellen:
infotext: db '01 First Track: xx Last Track: xx '
itl:
infotext2: db 'DEFINE CD ROM BASE WITH SETUP '
itl2:
infotext3: db 'READING PLAYLIST - (10 secs) '
itl3:
nro: db '01020304050607080910'
nro2: db '11121314151617181920'
nro3: db '21222324252627282930'
text: db ' STOP READ PLAYLIST '
 
cdinfo:
 
I_END:
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/cdplay/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/gifview/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm gifview.asm gifview
@pause
/programs/media/gifview/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm gifview.asm gifview
@pause
/programs/media/gifview/trunk/debug.inc
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'
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/gifview/trunk/gif_lite.inc
0,0 → 1,328
; GIF LITE v2.0 by Willow
; Written in pure assembler by Ivushkin Andrey aka Willow
;
; This include file will contain functions to handle GIF image format
;
; Created: August 15, 2004
; Last changed: September 9, 2004
 
; Change COLOR_ORDER in your program
; if colors are displayed improperly
 
if ~ (COLOR_ORDER in <MENUETOS,OTHER>)
; This message may not appear under MenuetOS, so watch...
display 'Please define COLOR_ORDER: MENUETOS or OTHER',13,10
end if
 
; virtual structure, used internally
 
struc GIF_list
{
.NextImg rd 1
.Left rw 1
.Top rw 1
.Width rw 1
.Height rw 1
}
 
struc GIF_info
{
.Left rw 1
.Top rw 1
.Width rw 1
.Height rw 1
}
 
_null fix 0x1000
 
; ****************************************
; FUNCTION GetGIFinfo - retrieve Nth image info
; ****************************************
; in:
; esi - pointer to image list header
; ecx - image_index (0...img_count-1)
; edi - pointer to GIF_info structure to be filled
 
; out:
; eax - pointer to RAW data, or 0, if error
 
GetGIFinfo:
push esi ecx edi
xor eax,eax
jecxz .eloop
.lp:
mov esi,[esi]
test esi,esi
jz .error
loop .lp
.eloop:
add esi,4
movsd
movsd
mov eax,esi
.error:
pop edi ecx esi
ret
 
; ****************************************
; FUNCTION ReadGIF - unpacks GIF image
; ****************************************
; in:
; esi - pointer to GIF file in memory
; edi - pointer to output image list
; eax - pointer to work area (MIN 16 KB!)
 
; out:
; eax - 0, all OK;
; eax - 1, invalid signature;
; eax >=8, unsupported image attributes
;
; ecx - number of images
 
ReadGIF:
push esi edi
mov [.table_ptr],eax
mov [.cur_info],edi
xor eax,eax
mov [.globalColor],eax
mov [.img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne .er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc .nextblock
mov [.globalColor],esi
call .Gif_skipmap
.nextblock:
cmp byte[edi],0x21
jne .noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne .no_gc
add edi,7
jmp .nextblock
.no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne .no_comm
inc edi
.block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz .block_skip
inc edi
jmp .nextblock
.no_comm:
cmp byte[edi],0xff ; Application Ext
jne .nextblock
add edi,13
jmp .block_skip
.noextblock:
cmp byte[edi],0x2c ; image beginning
jne .er
inc [.img_count]
inc edi
mov esi,[.cur_info]
add esi,4
xchg esi,edi
movsd
movsd
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc .uselocal
push [.globalColor]
mov edi,esi
jmp .setPal
.uselocal:
call .Gif_skipmap
push esi
.setPal:
movzx ecx,byte[edi]
inc ecx
mov [.codesize],ecx
dec ecx
pop [.Palette]
lea esi,[edi+1]
mov edi,[.table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [.block_ofs],eax
mov [.bit_count],8
mov eax,1
shl eax,cl
mov [.CC],eax
inc eax
mov [.EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
.filltable:
stosd
inc eax
loop .filltable
pop edi
mov [.img_start],edi
.reinit:
mov edx,[.EOI]
inc edx
push [.codesize]
pop [.compsize]
call .Gif_get_sym
cmp eax,[.CC]
je .reinit
call .Gif_output
.cycle:
movzx ebx,ax
call .Gif_get_sym
cmp eax,edx
jae .notintable
cmp eax,[.CC]
je .reinit
cmp eax,[.EOI]
je .end
call .Gif_output
.add:
push eax
mov eax,[.table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae .cycle
inc edx
bsr ebx,edx
cmp ebx,[.compsize]
jne .noinc
inc [.compsize]
.noinc:
jmp .cycle
.notintable:
push eax
mov eax,ebx
call .Gif_output
push ebx
movzx eax,bx
call .Gif_output
pop ebx eax
jmp .add
.er:
pop edi
jmp .ex
.end:
mov eax,[.cur_info]
mov [eax],edi
mov [.cur_info],edi
add esi,2
xchg esi,edi
.nxt:
cmp byte[edi],0
jnz .continue
inc edi
jmp .nxt
.continue:
cmp byte[edi],0x3b
jne .nextblock
xor eax,eax
stosd
mov ecx,[.img_count]
.ex:
pop edi esi
ret
 
.Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
.Gif_get_sym:
mov ecx,[.compsize]
push ecx
xor eax,eax
.shift:
ror byte[esi],1
rcr eax,1
dec [.bit_count]
jnz .loop1
inc esi
cmp esi,[.block_ofs]
jb .noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz .nextbl
mov eax,[.EOI]
sub esi,2
add esp,8
jmp .exx
.nextbl:
add eax,esi
mov [.block_ofs],eax
pop eax
.noblock:
mov [.bit_count],8
.loop1:
loop .shift
pop ecx
rol eax,cl
.exx:
xor ecx,ecx
ret
 
.Gif_output:
push esi eax edx
mov edx,[.table_ptr]
.next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz .next
shl ebx,16
mov bx,[esp]
.loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[.Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop .loop2
pop edx eax esi
ret
 
.globalColor rd 1
.img_count rd 1
.cur_info rd 1 ; image table pointer
.img_start rd 1
.codesize rd 1
.compsize rd 1
.bit_count rd 1
.CC rd 1
.EOI rd 1
.Palette rd 1
.block_ofs rd 1
.table_ptr rd 1
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/gifview/trunk/gifview.asm
0,0 → 1,314
; GIF VIEWER FOR MENUET v1.0
; Written in pure assembler by Ivushkin Andrey aka Willow
;
; Uses GIF_LITE 2.0
;
; Created: August 31, 2004
; Last changed: September 9, 2004
;
; COMPILE WITH FASM
 
WND_COLOR equ 0x02aabbcc
; input line dimensions
INP_X equ 10 shl 16+680
INP_Y equ 25 shl 16+16
INP_XY equ 15 shl 16+30
 
use32
 
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x300000
dd 0x27fff0
dd filename ;0x0
dd 0x0
 
include 'lang.inc'
include 'macros.inc' ; decrease code size (optional)
;include '/hd/1/meos/debug.inc'
include 'debug.inc'
COLOR_ORDER equ MENUETOS
 
DELAY equ 20 ; animation speed
 
;include '/hd/1/gif/gif_lite.inc'
include 'gif_lite.inc'
 
START:
cmp [filename],byte 0
jne openfile2
; jmp openfile2
openfile:
and [entered],0
xor eax,eax
mov [imgcount],eax
mov esi,fn_input
mov edi,filename
mov ecx,[inp_pos]
rep movsb
mov byte[edi],al
openfile2:
mov eax,58
mov ebx,file_info
int 0x40
cmp eax,6
je temp
test eax,eax
jnz ok2
temp:
cmp ebx,64
jbe ok2
 
and [entered],0
xor eax,eax
mov [imgcount],eax
mov esi,filename
mov edi,fn_input
mov ecx,256 ;[filename_len]
rep movsb
 
mov edi,fn_input
mov ecx,50
xor eax,eax
repne scasb
sub edi,fn_input
dec edi
mov [inp_pos],edi
inc [inp_pos]
 
; test eax,eax
; jnz .ok2
; cmp ebx,64
; jbe .ok2
mov esi,workarea
mov edi,Image
mov eax,hashtable
call ReadGIF
test eax,eax
jz .ok
xor ecx,ecx
.ok:
mov [imgcount],ecx
ok2:
and dword[img_index],0
 
red:
 
call draw_window
 
still:
mov ebx,DELAY
mov eax,23
int 0x40
 
cmp eax,1
je red
cmp eax,2
je key
cmp eax,3
je button
mov eax,[imgcount]
cmp eax,1
je still
inc [img_index]
cmp eax,[img_index]
jne redsub
and [img_index],0
redsub:
mov ecx,[img_index]
call draw_subimage
jmp still
 
key:
mov eax,2
int 0x40
cmp ah,13
je is_input
jmp still
 
button:
mov eax,17
int 0x40
 
cmp ah,1
jne noclose
_close:
or eax,-1
int 0x40
 
noclose:
is_input: ; simple input line with backspace feature
inc [entered] ; sorry - no cursor
wait_input:
call draw_input
mov eax,10
int 0x40
cmp eax,2
jne still
mov edi,[inp_pos]
mov eax,2
int 0x40
shr eax,8
cmp eax,27
je still
cmp eax,13
je openfile
cmp eax,8
je backsp
mov [fn_input+edi],al
inc [inp_pos]
jmp wait_input
backsp:
test edi,edi
jz wait_input
dec [inp_pos]
jmp wait_input
jmp still
 
;****************************************
;******* DRAW CONTENTS OF INPUT LINE ****
;****************************************
draw_input:
push edi
cmp [entered],0
jne highlight
mov esi,WND_COLOR
jmp di_draw
highlight:
mov esi,0xe0e0e0
di_draw:
mov eax,8
mov ebx,INP_X
mov ecx,INP_Y
mov edx,2
int 0x40
mov eax,4
mov ecx,0x00107a30 ; èà¨äâ 1 ¨ 梥â ( 0xF0RRGGBB )
mov ebx,INP_XY
mov edx,fn_input
mov esi,[inp_pos]
int 0x40
pop edi
ret
 
; *********************************************
; ******* Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ *******
; *********************************************
 
draw_window:
 
mov eax,12
mov ebx,1
int 0x40
 
mov eax,0
mov ebx,50*65536+700
mov ecx,50*65536+500
mov edx,WND_COLOR
mov esi,0x805080d0
mov edi,0x005080d0
int 0x40
 
 
mov eax,4
mov ebx,8*65536+8
mov ecx,0x10ddeeff
mov edx,zagolovok
mov esi,zag_konets-zagolovok
int 0x40
 
mov eax,8
mov ebx,(700-19)*65536+12
mov ecx,5*65536+12
mov edx,1
mov esi,0x6688dd
int 0x40
 
call draw_input
 
xor ecx,ecx
call draw_subimage
cmp [imgcount],1
je .enddraw
 
mov ecx,[img_index]
call draw_subimage
.enddraw:
mov eax,12
mov ebx,2
int 0x40
ret
 
draw_subimage:
cmp [imgcount],0
jz .enddraw
mov esi,Image
mov edi,gif_inf
call GetGIFinfo
test eax,eax
jz .enddraw
movzx ebx,[gif_inf.Width]
shl ebx,16
movzx ecx,[gif_inf.Height]
add ecx,ebx
mov ebx,eax
movzx eax,[gif_inf.Top]
movzx edx,[gif_inf.Left]
shl edx,16
add edx,eax
add edx,10 shl 16 +45
mov eax,7
int 0x40
.enddraw:
ret
 
; ‡¤¥áì ­ å®¤ïâáï ¤ ­­ë¥ ¯à®£à ¬¬ë:
 
; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¤¢ãï§ëç­ë© - § ¤ ©â¥ ï§ëª ¢ macros.inc
 
zagolovok: ; áâப  § £®«®¢ª 
if lang eq ru
db 'Ž‘ŒŽ’ GIF'
else
db 'GIF VIEWER'
end if
zag_konets: ; ¨ ¥ñ ª®­¥æ
 
inp_pos dd inp_end-fn_input
fn_input:
; db '/hd/1/gif/smileys/sm100000.gif'
db '/rd/1/meos.gif'
; db '/hd/1/1/tex256.gif',0
; db '/rd/1/tex256.gif'
inp_end:
rb 256-(inp_end-fn_input)
 
file_info:
dd 0
dd 0
dd 0x100000/512;0x200000
dd workarea
dd Image;0x100000
I_END: ; ª®­¥æ ¯à®£à ¬¬ë
filename:
; db '/hd/1/gif/smileys/sm112000.gif',0
; db '/hd/1/gif/test.gif',0
; db '/hd/1/gif/explode1.gif',0
; db '/hd/1/gif/tapeta.gif',0
; db '/hd/1/gif/meos.gif',0
rb 256
;filename_len dd 0
entered rd 1
 
imgcount rd 1
img_index rd 1
gif_inf GIF_info
 
hashtable rd 4096
workarea rb 0x100000
 
Image:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/gifview/trunk/macros.inc
0,0 → 1,265
; 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
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/iconedit/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm iconedit.asm iconedit
@pause
/programs/media/iconedit/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm iconedit.asm iconedit
@pause
/programs/media/iconedit/trunk/iconedit.asm
0,0 → 1,983
;
; Modified from original icon editor
;
; Compile with FASM for Menuet
;
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x100000 ; memory for app
dd 0x7fff0 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
include 'macros.inc'
 
window_x_size equ 346
window_y_size equ 312
 
START: ; start of execution
 
call draw_window ; at first, draw the window
call get_screen_size ; get screen x and y size
 
check_mouse:
 
call draw_mouse ; are we editing the icon
call check_colour ; are we selecting a colour
 
still:
 
mov eax,23 ; wait here for event
mov ebx,1 ; for 1ms
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 check_mouse ; start loop again
 
red: ; redraw
call draw_window ; draw our window
jmp check_mouse ; start the loop again
key:
 
mov eax,2 ; get a key
int 0x40 ; do it
shr eax,8 ; move it to al
cmp byte [editstate],0 ; are we in edit mode
je check_mouse ; if not start loop again
cmp al,8 ; is it a backspace
jne no_bksp ; if no jump over backspace code
cmp byte [editpos],0 ; is it the first character
je no_del_last ; if yes jump over backspace code
dec byte [editpos] ; decrement our position
xor ebx,ebx ; clear pointer
mov bl,byte [editpos] ; get our position
add ebx,icon ; add our offset
mov byte [ebx],0 ; delete character
no_del_last:
call draw_filename ; update filename
jmp check_mouse ; start loop again
no_bksp:
cmp al,13 ; is it the enter key
jne no_enter ; no then jump over enter code
mov byte [editstate],0 ; get out of edit mode
call draw_filename ; update filename
jmp check_mouse ; start loop again
no_enter:
cmp al,31 ; are we below character 31
jbe no_lit ; then must be illegal
cmp al,97 ; are we below character 97
jb capital ; then must be ok
sub eax,32 ; else subtract 32 from it to make it legal
capital:
xor ebx,ebx ; clear our pointer
mov bl,byte [editpos] ; get our position
add ebx,icon ; add our offset
mov byte [ebx],al ; move our character into buffer
inc byte [editpos] ; increment our edit position
cmp byte [editpos],12 ; are we at our last position
jne no_null_state ; no then jump over last position code
mov byte [editstate],0 ; get out of edit mode
no_null_state:
call draw_filename ; update filename
no_lit:
jmp check_mouse ; start loop again
 
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne button_3
mov eax,-1 ; close this program
int 0x40
button_3:
cmp ah,3 ; was it button 3 - FILENAME
jne button_4 ; no then try button 4
cld ;
mov byte [editstate],1 ; enter edit mode
mov edi,icon ; point to our buffer
mov eax,0x20202020 ; file reg with 4 spaces
mov ecx,3 ; going to write it 3 times
rep stosd ; repeat giving 12 spaces
mov byte [editpos],0 ; zero our edit position
call draw_filename ; update filename
jmp check_mouse ; start loop again
button_4:
cmp ah,4 ; was it button 4 - LOAD
jne button_5 ; no then try button 5
mov byte [editstate],0 ; dont want to be in edit mode
call draw_filename ; update filename
call load_file ; load the file
call draw_icon ; update icon screen
call draw_graph ; update edit screen
jmp check_mouse ; start loop again
button_5:
cmp ah,5 ; was it button 5 - SAVE
jne button_6 ; no then try button 6
mov byte [editstate],0 ; dont want to be in edit mode
call draw_filename ; update filename
call save_file ; save the file
jmp check_mouse ; start loop again
button_6:
cmp ah,6 ; was it button 6 - CLEAR ICON
jne button_7 ; no then try button 7
mov byte [editstate],0 ; dont want to be in edit mode
call draw_filename ; update filename
call clear_graph_icon ; clear the icon and edit screens
button_7:
cmp ah,7 ; was it button 7 - FLIP ICON
jne button_8 ; no then try button 8
call flip_icon ; flip
button_8:
cmp ah,8 ; was it button 8 - MIRROR ICON
jne button_9 ; no then try button 9
call flip_diag ; flip L/R and U/D
call flip_icon ; cheated now have to flip it
button_9:
cmp ah,9 ; was it button 9 - FLIP L/R and U/D
jne button_10 ; no then try button 10
call flip_diag ; flip L/R and U/D
call draw_icon ; update icon
call draw_graph ; update graph
button_10:
cmp ah,10 ; was it button 9 - SET AS BGR
jne check_mouse ; no then exit
call set_background ; set as background
 
jmp check_mouse ; start loop again
 
; *********************************************
; ******* 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+window_x_size ; [x start] *65536 + [x size]
mov ecx,100*65536+window_y_size ; [y start] *65536 + [y size]
mov edx,0x03ffffff ; color of work area 0x00RRGGBB
mov esi,0x807799bb ; color of grab bar 0x00RRGGBB
mov edi,0x007799bb ; color of frames 0x00RRGGBB
int 0x40
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,7*65536+7 ; [x start] *65536 + [y start]
mov ecx,0xddeeff ; color of text 0x00RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,11 ; text length
int 0x40
; DRAW BUTTON BAR
mov eax,13 ; function 13 : draw bar
mov ebx,5*65536+window_x_size-9 ; [x start] *65536 + [x size]
mov ecx,(window_y_size-20)*65536+16 ; [y start] *65536 + [y size]
mov edx,0x7799bb ; colour 0x00RRGGBB
int 0x40
; DEFINE BUTTON 3 : FILENAME
mov eax,8 ; function 8 : define button
mov ebx,5*65536+62 ; [x start] *65536 + [x size]
mov ecx,(window_y_size-19)*65536+14 ; [y start] *65536 + [y size]
mov edx,3 ; button id number
mov esi,0x7799bb ; button color 0x00RRGGBB
int 0x40
; BUTTON 3 TEXT
mov eax,4 ; function 4 : write text to window
mov ebx,13*65536+window_y_size-15 ; [x start] *65536 + [y start]
mov ecx,0xddeeff ; text color 0x00RRGGBB
mov edx,button_text_3 ; pointer to text beginning
mov esi,8 ; text length
int 0x40
 
call draw_filename ; update filename
 
; DEFINE BUTTON 4 : LOAD
mov eax,8 ; function 8 : define button
mov ebx,(window_x_size-87)*65536+38 ; [x start] *65536 + [x size]
mov ecx,(window_y_size-19)*65536+14 ; [y start] *65536 + [y size]
mov edx,4 ; button id number
mov esi,0x7799bb ; button color 0x00RRGGBB
int 0x40
; DEFINE BUTTON 5 : SAVE
mov ebx,(window_x_size-43)*65536+38 ; [x start] *65536 + [x size]
mov edx,5 ; button id number
int 0x40
; DEFINE BUTTON 6 : CLEAR ICON
mov ebx,268*65536+72 ; [x start] *65536 + [x size]
mov ecx,65*65536+14 ; [y start] *65536 + [y size]
mov edx,6 ; button id number
int 0x40
; DEFINE BUTTON 7 : FLIP VERTICAL
mov ecx,85*65536+14 ; [y start] *65536 + [y size]
mov edx,7 ; button id number
int 0x40
; DEFINE BUTTON 8 : FLIP HORIZONTAL
mov ecx,105*65536+14 ; [y start] *65536 + [y size]
mov edx,8 ; button id number
int 0x40
; DEFINE BUTTON 9 : SET AS BACKGROUND
mov ecx,125*65536+14 ; [y start] *65536 + [y size]
mov edx,9 ; button id number
int 0x40
; DEFINE BUTTON 10 : SET AS BACKGROUND
mov ecx,145*65536+14 ; [y start] *65536 + [y size]
mov edx,10 ; button id number
int 0x40
; BUTTON 4 TEXT
mov eax,4 ; function 4 : write text to window
mov ebx,267*65536+window_y_size-15 ; [x start] *65536 + [y start]
mov ecx,0xddeeff ; text color 0x00RRGGBB
mov edx,button_text_4 ; pointer to text beginning
mov esi,4 ; text length
int 0x40
; BUTTON 5 TEXT
mov ebx,311*65536+window_y_size-15 ; [x start] *65536 + [y start]
mov edx,button_text_5 ; pointer to text beginning
int 0x40
; BUTTON 6 TEXT
mov ebx,275*65536+69 ; [x start] *65536 + [y start]
mov edx,button_text_6 ; pointer to text beginning
mov esi,10 ; text length
int 0x40
; BUTTON 7 TEXT
mov ebx,275*65536+89 ; [x start] *65536 + [y start]
mov edx,button_text_7 ; pointer to text beginning
int 0x40
; BUTTON 8 TEXT
mov ebx,275*65536+109 ; [x start] *65536 + [y start]
mov edx,button_text_8 ; pointer to text beginning
int 0x40
; BUTTON 9 TEXT
mov ebx,275*65536+129 ; [x start] *65536 + [y start]
mov edx,button_text_9 ; pointer to text beginning
int 0x40
; BUTTON 10 TEXT
mov ebx,275*65536+149 ; [x start] *65536 + [y start]
mov edx,button_text_10 ; pointer to text beginning
int 0x40
; DRAW GRAPH BACKGROUND
mov eax,13 ; function 13 : draw bar
mov ebx,6*65536+257 ; [x start] *65536 + [x size]
mov ecx,26*65536+257 ; [y start] *65536 + [y size]
mov edx,0x7799bb ; colour 0x00RRGGBB
int 0x40
; DRAW ICON BACKGROUND
mov ebx,268*65536+34 ; [x start] *65536 + [x size]
mov ecx,26*65536+34 ; [y start] *65536 + [y size]
int 0x40
; DRAW PALETTE BACKGROUND
mov ebx,268*65536+34 ; [x start] *65536 + [x size]
mov ecx,217*65536+33 ; [y start] *65536 + [y size]
int 0x40
; DRAW PALETTE BACKGROUND
mov ebx,268*65536+33 ; [x start] *65536 + [x size]
mov ecx,250*65536+33 ; [y start] *65536 + [y size]
int 0x40
; DRAW PALETTE BACKGROUND
mov ebx,301*65536+33 ; [x start] *65536 + [x size]
mov ecx,249*65536+34 ; [y start] *65536 + [y size]
int 0x40
; DRAW GREYSCALE BACKGROUND
mov ebx,307*65536+34 ; [x start] *65536 + [x size]
mov ecx,210*65536+34 ; [y start] *65536 + [y size]
int 0x40
; DRAW SELECTED COLOUR BACKGROUND
mov ebx,268*65536+73 ; [x start] *65536 + [x size]
mov ecx,171*65536+34 ; [y start] *65536 + [y size]
int 0x40
; DRAW WHITE TO START
mov ebx,269*65536+71 ; [x start] *65536 + [x size]
mov ecx,172*65536+32 ; [y start] *65536 + [y size]
mov edx,0xffffff ; colour 0x00RRGGBB
int 0x40
; DRAW PALETTE RED + GREEN SECTION
xor edi,edi ; clear column loop count
next_r_g_outer:
xor esi,esi ; clear line loop count
next_r_g_inner:
mov eax,1 ; function 1 : putpixel
mov ebx,edi ; get column count
shr ebx,3 ; divide by 8
add ebx,269 ; add our x offset
mov ecx,esi ; get our line count
shr ecx,3 ; divide by 8
add ecx,218 ; add our y offset
mov edx,255 ; maximum red
sub edx,edi ; minus column count
shl edx,8 ; into position 0x0000RR00
add edx,255 ; maximum green
sub edx,esi ; minus line count
shl edx,8 ; into position 0x00RRGG00
int 0x40
add esi,5 ; colour in steps of 5 to keep small
cmp esi,255 ; have we done a line
jne next_r_g_inner ; nop then do next pixel
add edi,5 ; colour in steps of 5 to keep small
cmp edi,255 ; have we done all columns
jne next_r_g_outer ; no then start the next one
 
; DRAW PALETTE GREEN + BLUE SECTION
mov edi,0 ; as above
next_g_b_outer:
mov esi,0
next_g_b_inner:
mov eax,1
mov ebx,edi
shr ebx,3
add ebx,269
mov ecx,esi
shr ecx,3
add ecx,250
mov edx,255
sub edx,edi
shl edx,16
add edx,esi
int 0x40
add esi,5
cmp esi,255
jne next_g_b_inner
add edi,5
cmp edi,255
jne next_g_b_outer
 
; DRAW PALETTE BLUE + RED SECTION
mov edi,0 ; as above
next_b_r_outer:
mov esi,0
next_b_r_inner:
mov eax,1
mov ebx,edi
shr ebx,3
add ebx,301
mov ecx,esi
shr ecx,3
add ecx,250
mov edx,edi
shl edx,8
add edx,esi
int 0x40
add esi,5
cmp esi,255
jne next_b_r_inner
add edi,5
cmp edi,255
jne next_b_r_outer
 
; DRAW GREYSCALE
mov edi,0
next_b_w_outer:
mov esi,0
next_b_w_inner:
mov eax,1
mov ebx,edi
shr ebx,3
add ebx,308
mov ecx,esi
shr ecx,3
add ecx,211
mov edx,esi
shl edx,8
add edx,esi
shl edx,8
add edx,esi
int 0x40
add esi,5
cmp esi,255
jne next_b_w_inner
add edi,5
cmp edi,255
jne next_b_w_outer
 
cmp [first_run],0 ; is it the first window draw
jne dont_load ; no then dont reload the file
call load_file ; load initial file
mov [first_run],1 ; first window draw done
dont_load:
call draw_icon ; draw icon area
call draw_graph ; draw edit area
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret ; return
 
; *********************************************
; ******* SET BACKGROUND ********
; *********************************************
set_background:
 
mov ecx,image+3600 ; point to our decode buffer
mov edx,image+54+32*32*3-96 ; point to last line of bmp
 
mov edi,0 ; zero line count
decode_line:
mov esi,0 ; zero column count
decode_column:
mov ebx,[edx] ; get our data
mov [ecx],ebx ; store our data
add ecx,4 ; add 4 bytes to pointer as using double word
add edx,4 ; add 4 bytes to pointer
inc esi ; increment column count
cmp esi,24 ; have we done all columns
jne decode_column ; no then do some more
sub edx,192 ; move back 2 lines of bmp data
inc edi ; increment line count
cmp edi,33 ; have we done all lines
jne decode_line ; no then do another one
 
mov eax,15 ; background
mov ebx,1 ; set background size
mov ecx,32 ; x size
mov edx,32 ; y size
int 0x40 ; do it
mov ebx,5 ; blockmove image to os bgr memory
mov ecx,image+3600 ; point to image
mov edx,0 ; start of bgr memory
mov esi,32*32*3 ; byte count
int 0x40 ; do it
mov ebx,4 ; type of background draw
mov ecx,1 ; tile
int 0x40 ; do it
mov ebx,3 ; draw background
int 0x40 ; do it
 
ret ; return
 
; *********************************************
; ******* GET SCREEN X and Y SIZE ********
; *********************************************
get_screen_size:
 
mov eax,14 ; function 14 : get screen max
int 0x40 ; returns eax : 0xXXXXYYYY
push eax ; save reg
and eax,0x0000ffff ; split out y size
add eax,1 ; add 1 to remove zero base
mov [y_size],eax ; store for later
pop eax ; restore reg
shr eax,16 ; move x size down the reg
add eax,1 ; add 1 to remove zero base
mov [x_size],eax ; store for later
 
ret
 
; *********************************************
; ******* LOAD FILE ********
; *********************************************
load_file:
 
mov eax,6 ; function 6 : load file
mov ebx,icon ; point to the name
mov ecx,0 ; reserved
mov edx,200000 ; reserved
mov esi,image ; point to image buffer
int 0x40 ; do it
 
ret ; return
 
; *********************************************
; ******* SAVE FILE ********
; *********************************************
save_file:
 
mov eax,33 ; function 33 : save file
mov ebx,icon ; point to name
mov ecx,image ; point to our data
mov edx,54+32*32*3 ; how much data to transfer
xor esi,esi ; 0 - create a new file
int 0x40 ; do it
 
ret ; return
 
; *********************************************
; ******* DRAW FILENAME TO SCREEN ********
; *********************************************
draw_filename:
; DRAW COLOUR BACKGROUND
pusha ; save all registers on stack
mov eax,13 ; function 13 : draw bar
mov ebx,73*65536+81 ; [x start] *65536 + [x size]
mov ecx,(window_y_size-19)*65536+15 ; [y start] *65536 + [y size]
mov edx,0x557799 ; colour 0x00RRGGBB
int 0x40
 
mov eax,4 ; function 4 : write text to window
mov ebx,78*65536+(window_y_size-15) ; [y start] *65536 + [y size]
xor ecx,ecx ; colour 0x00RRGGBB = black
mov edx,icon ; point to text
mov esi,12 ; number of characters to write
cmp byte [editstate],1 ; are we in edit mode
jne no_active_1 ; no then jump over change colour
mov ecx,0x00112299 ; else change colour
no_active_1:
int 0x40 ; do it
popa ; return all registers to original
ret ; return
 
; *********************************************
; ******* DRAW ICON FROM LOADED FILE ********
; *********************************************
draw_icon:
 
mov ecx,27 ; y start position
mov eax,image+51+32*32*3 ; point to our bmp data
mov edi,0 ; line count
line:
mov esi,0 ; column count
mov ebx,269+31 ; x start position
pixel:
mov edx,[eax] ; colour 0x00RRGGBB from image data
push eax ; save our position
mov eax,1 ; function 1 : put pixel
int 0x40 ; do it
pop eax ; restore our position
sub eax,3 ; point to next pixel colour
dec ebx ; move our x position
inc esi ; increment our column count
cmp esi,32 ; have we done all columns
jne pixel ; no then do next pixel
inc ecx ; move our y position
inc edi ; increment line count
cmp edi,32 ; have we done all lines
jne line ; no then do next line
 
ret ; return
 
; *********************************************
; ******* DRAW GRAPH FROM LOADED FILE *******
; *********************************************
draw_graph:
 
mov edi,0 ; line count
mov eax,image+51+32*32*3 ; point to our bmp data
next_lin:
mov ecx,edi ; use our line count for position
shl ecx,3 ; multiply by eight
add ecx,27 ; add y start position
shl ecx,16 ; move into top eight bytes [y start]
add ecx,7 ; add box height [y size]
mov esi,32 ; column count
next_bo:
mov ebx,esi ; use our column count for position
shl ebx,3 ; multiply by eight
add ebx,-1 ; add a correction
shl ebx,16 ; and move into top eight bytes [x start]
add ebx,7 ; add box width [x size]
mov edx,[eax] ; point to bmp data
push eax ; save our position
mov eax,13 ; function 13 : draw bar
int 0x40 ; do it
pop eax ; restore our position
sub eax,3 ; point to next pixel colour
dec esi ; increment column count
cmp esi,0 ; have we done all columns
jne next_bo ; no then do the next column
inc edi ; increment line count
cmp edi,32 ; have we done all lines
jne next_lin ; no then do the next line
 
ret ; return
 
; *********************************************
; ******* CLEAR GRAPH and ICON AREA ********
; *********************************************
clear_graph_icon:
 
; CLEAR IMAGE DATA
mov edi,image+54 ; point to our data
mov eax,0x00000000 ; data to write
mov ecx,(32*32*3)/4 ; how much data
rep stosd ; repeat until all data transfered
call draw_icon ; draw a blank icon
call draw_graph ; draw a blank graph
 
ret ; return
 
; *********************************************
; ******* FLIP ICON TOP to BOTTOM ********
; *********************************************
flip_icon:
 
mov ecx,image+54 ; point at first line
mov edx,image+54+32*32*3+96 ; point 1 line past end
 
mov edi,0 ; zero line count
lines:
mov esi,0 ; zero column count
sub edx,192 ; move back 2 lines
columns:
mov eax,[ecx] ; get bytes
mov ebx,[edx] ; get bytes
mov [ecx],ebx ; swap bytes
mov [edx],eax ; swap bytes
add ecx,4 ; move pointer
add edx,4 ; move pointer
inc esi ; increment column count
cmp esi,24 ; have we done all columns
jne columns ; no then do next column
inc edi ; increment line count
cmp edi,16 ; have we done all lines
jne lines ; no then do next line
call draw_icon ; update icon
call draw_graph ; update graph
 
ret ; return
 
; *********************************************
; ******* FLIP ICON DIAGONAL ********
; *********************************************
flip_diag:
 
mov ecx,image+54 ; point line 1 first bytes
mov edx,image+3600 ; point to buffer
xor esi,esi ; zero byte count
 
pusha ; save all registers
copy_out:
mov eax,[ecx] ; get bytes
mov [edx],eax ; copy bytes
add ecx,4 ; move pointer
add edx,4 ; move pointer
inc esi ; increment byte count
cmp esi,24*32 ; have we done all bytes
jne copy_out ; no then do the next
popa ; restore all registers
 
mov edx,image+3600+32*32*3-3 ; point to last bytes
copy_in:
mov eax,[edx] ; get bytes
mov [ecx],eax ; copy to image first bytes
add ecx,3 ; move pointer 3 bytes
sub edx,3 ; move pointer 3 bytes
inc esi ; increment byte count
cmp esi,32*32 ; have we done all bytes
jne copy_in ; no then do next
 
ret ; return
 
; *********************************************
; ******* DRAW MOUSE ON GRAPH / ICON ********
; *********************************************
draw_mouse:
 
mov eax,37 ; function 37
mov ebx,2 ; sub function 2 : check for mouse button
int 0x40 ; do it
cmp eax,0 ; was a button pressed
je exit_mouse ; no then jump to exit
cmp eax,1 ; left hand button
je colour_mouse ; we are using selected colour
mov [draw_colour],0x000000 ; else draw with black
jmp blank ; jmp over colour select
colour_mouse:
mov eax,[sel_colour] ; get our selected colour
mov [draw_colour],eax ; save our selected colour
blank:
mov eax,37 ; function 37
mov ebx,1 ; sub function 1 : get mouse position
int 0x40 ; do it
push eax ; save our x/y position for later
and eax,0x0000ffff ; y is in lower bytes
add eax,1 ; add 1 because we are zero based
mov [my_pos],eax ; save y position
pop eax ; restore our x/y position
shr eax,16 ; shift x into lower bytes
add eax,1 ; add 1 because we are zero based
mov [mx_pos],eax ; save x position
cmp [mx_pos],7 ; check we are within x/y limits
jle exit_mouse
cmp [mx_pos],263
jge exit_mouse
cmp [my_pos],27
jle exit_mouse
cmp [my_pos],283
jge exit_mouse
mov eax,[mx_pos] ; calculate nearest square and save
sub eax,7 ; subtract 7 graph zero offset
shr eax,3 ; divide by 8 (box size) loose remainder
mov [icon_x],eax ; save for use later in icon
shl eax,3 ; multiply by 8 to get box position
add eax,7 ; add 7 graph zero offset
mov [gx_pos],eax ; save graph x position
mov eax,[my_pos] ; repeat for y
sub eax,27 ;
shr eax,3 ;
mov [icon_y],eax ;
shl eax,3 ;
add eax,27 ;
mov [gy_pos],eax ;
mov eax,13 ; function 13 : draw bar
mov ebx,[gx_pos] ; load graph x position
shl ebx,16 ; shift into high bytes
add ebx,7 ; add box size
mov ecx,[gy_pos] ; repeat for y
shl ecx,16 ;
add ecx,7 ;
mov edx,[draw_colour] ; give it a colour
int 0x40 ; do it
mov eax,1 ; function 1 : put pixel
mov ebx,[icon_x] ; icon x from above
add ebx,269 ; add icon x offset
mov ecx,[icon_y] ; icon y from above
add ecx,27 ; add icon y offset
mov edx,[draw_colour] ; give it a colour
int 0x40 ; do it
mov ecx,image+54 ; point to our data
mov ebx,31 ; 32 lines in image zero based
sub ebx,[icon_y] ; get the correct line
mov eax,96 ; 96 or 3 bytes per colour * 32 columns
mul ebx ; multiply by 96 result in eax
add ecx,eax ; add to our position
mov ebx,[icon_x] ; get the correct column
mov eax,3 ; 3 bytes per colour
mul ebx ; multiply by 3 result in eax
add ecx,eax ; add to our position
mov ebx,[draw_colour] ; get our colour
mov [ecx],bl ; move blue into image data
mov [ecx+1],bh ; move green into image data
shr ebx,16 ; shift red down
mov [ecx+2],bl ; move red into image data
exit_mouse:
 
ret ; return
 
; *********************************************
; ******* GET COLOUR TO DRAW WITH ********
; *********************************************
check_colour:
 
mov eax,37 ; function 37
mov ebx,2 ; sub function 2 : check for mouse button
int 0x40 ; do it
cmp eax,0 ; was a button pressed
je exit_draw ; no then jump to exit
mov eax,37 ; function 37
mov ebx,1 ; sub function 1 : get mouse position
int 0x40 ; do it
push eax ; save our x/y position for later
and eax,0x0000ffff ; y is in lower bytes
add eax,1 ; add 1 because we are zero based
mov [my_pos],eax ; save y position
pop eax ; restore our x/y position
shr eax,16 ; shift x into lower bytes
add eax,1 ; add 1 because we are zero based
mov [mx_pos],eax ; save x position
cmp [mx_pos],270 ; check we are within x/y limits
jl check_rb
cmp [mx_pos],301
jg check_rb
cmp [my_pos],219
jl check_rb
cmp [my_pos],250
jg check_rb
 
call decode_mouse
 
mov edi,0
next_sel_rg_outer:
mov esi,0
next_sel_rg_inner:
mov eax,1
mov ebx,edi
shr ebx,3
add ebx,308
mov ecx,esi
shr ecx,3
add ecx,211
mov edx,[sel_colour]
add edx,esi
int 0x40
add esi,5
cmp esi,255
jne next_sel_rg_inner
add edi,5
cmp edi,255
jne next_sel_rg_outer
 
 
check_rb:
 
cmp [mx_pos],270 ; check we are within x/y limits
jl check_bg
cmp [mx_pos],301
jg check_bg
cmp [my_pos],251
jle check_bg
cmp [my_pos],282
jg check_bg
 
call decode_mouse
 
mov edi,0
next_sel_rb_outer:
mov esi,0
next_sel_rb_inner:
mov ebx,edi
shr ebx,3
add ebx,308
mov ecx,esi
shr ecx,3
add ecx,211
mov edx,[sel_colour]
mov eax,esi
shl eax,8
add edx,eax
mov eax,1
int 0x40
add esi,5
cmp esi,255
jne next_sel_rb_inner
add edi,5
cmp edi,255
jne next_sel_rb_outer
 
 
check_bg:
 
cmp [mx_pos],301 ; check we are within x/y limits
jl get_colour
cmp [mx_pos],333
jg get_colour
cmp [my_pos],251
jl get_colour
cmp [my_pos],282
jg get_colour
 
call decode_mouse
 
mov edi,0
next_sel_bg_outer:
mov esi,0
next_sel_bg_inner:
mov ebx,edi
shr ebx,3
add ebx,308
mov ecx,esi
shr ecx,3
add ecx,211
mov edx,[sel_colour]
mov eax,esi
shl eax,16
add edx,eax
mov eax,1
int 0x40
add esi,5
cmp esi,255
jne next_sel_bg_inner
add edi,5
cmp edi,255
jne next_sel_bg_outer
 
get_colour:
 
cmp [mx_pos],309 ; check we are within x/y limits
jl exit_draw
cmp [mx_pos],340
jg exit_draw
cmp [my_pos],212
jl exit_draw
cmp [my_pos],243
jg exit_draw
 
call decode_mouse
 
mov eax,13
mov ebx,269*65536+71
mov ecx,172*65536+32
mov edx,[sel_colour]
int 0x40
 
mov eax,[sel_colour]
mov [draw_colour],eax
 
mov eax,47
xor ebx,ebx
mov ebx,6
shl ebx,16
mov bh,1
mov ecx,[sel_colour]
mov edx,273*65536+176
mov esi,0x000000
int 0x40
 
exit_draw:
 
ret
 
; *********************************************
; ******* DECODE MOUSE POSITION GET PIX *****
; *********************************************
 
decode_mouse:
 
mov eax,37
xor ebx,ebx
int 0x40
mov ebx,eax
mov ecx,eax
and ebx,0xffff0000
shr ebx,16
and ecx,0x0000ffff
mov eax,[x_size]
imul ecx,eax
add ebx,ecx
mov eax,35
dec ebx
int 0x40
 
mov [sel_colour],eax
 
ret
 
; *********************************************
; ******* DATA AREA *****
; *********************************************
 
mx_pos dd 0x0
my_pos dd 0x0
 
gx_pos dd 0x0
gy_pos dd 0x0
 
icon_x dd 0x0
icon_y dd 0x0
 
x_size dd 0x0
y_size dd 0x0
 
sel_colour dd 0x00ffffff
draw_colour dd 0x00ffffff
 
button_text_3 db 'FILENAME'
button_text_4 db 'LOAD'
button_text_5 db 'SAVE'
button_text_6 db 'CLEAR ICON'
button_text_7 db 'FLIP VERT '
button_text_8 db 'FLIP HORIZ'
button_text_9 db 'FLIP DIAG '
button_text_10 db 'SET AS BGR'
 
labelt: db 'ICON EDITOR'
 
icon: db 'WRITE.BMP '
 
editpos db 0
editstate db 0
 
first_run db 0
 
image:
 
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/iconedit/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/jpegview/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm jpegview.asm jpegview
@pause
/programs/media/jpegview/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm jpegview.asm jpegview
@pause
/programs/media/jpegview/trunk/filelib.asm
0,0 → 1,151
file_handler:
.position=0
.size=4
.bufer_block=8
.operation=12
.first_block=16
.n_blocks=20
.bufer=24
.work_area=28
.name=32
.st_size=32+128
 
open: ;esi=name_string
;retorna eax
pushad
push dword [work_area]
mov ecx,512 ;bufer
call malloc
push edi
mov ecx,file_handler.st_size
call mallocz
pop dword[edi+file_handler.bufer]
pop dword[edi+file_handler.work_area]
mov [esp+28],edi
mov ecx,100
add edi,file_handler.name
call movedata
mov edi,[esp+28]
mov byte[edi+file_handler.n_blocks],1
mov eax,58
lea ebx,[edi+file_handler.operation]
push edi
int 0x40
pop edi
test eax,eax
jnz close.b
mov [edi+file_handler.size],ebx
clc
popad
ret
 
close:
pushad
.b:
mov eax,[esp+28]
mov edi,[eax+file_handler.bufer]
call free
mov edi,eax
call free
popad
xor eax,eax
ret
 
 
read: ;(f,bufer,nbytes) eax,edi,ecx ncr
;retorna bytes leidos en ecx
pushad
mov edx,[eax+file_handler.size]
sub edx,[eax+file_handler.position]
cmp edx,ecx
jnc .nb_ok
mov ecx,edx
mov [esp+24],edx
.nb_ok:
jecxz .final
mov byte[eax+file_handler.operation],0
test dword[eax+file_handler.position],511
jz .l1
call .bufer
.l1:
mov edx,ecx
shr edx,9
jz .l2
mov [eax+file_handler.n_blocks],edx
mov edx,[eax+file_handler.position]
shr edx,9
mov [eax+file_handler.first_block],edx
xchg edi,[eax+file_handler.bufer]
pushad
lea ebx,[eax+file_handler.operation]
mov eax,58
int 40h
cmp eax,0ffffff00h
jnc .error
popad
xchg edi,[eax+file_handler.bufer]
mov edx,ecx
and edx,0fffffe00h
add [eax+file_handler.position],edx
add edi,edx
.l2:
and ecx,511
jz .final
call .bufer
.final:
popad
ret
 
.bufer:
pushad
mov ebx,[eax+file_handler.position]
shr ebx,9
cmp ebx,[eax+file_handler.bufer_block]
je .l3
mov [eax+file_handler.first_block],ebx
mov [eax+file_handler.bufer_block],ebx
mov dword[eax+file_handler.n_blocks],1
lea ebx,[eax+file_handler.operation]
mov eax,58
int 40h
cmp eax,0ffffff00h
jnc .error
.l3:
mov eax,[esp+28]
mov edx,[eax+file_handler.position]
mov esi,[eax+file_handler.bufer]
and edx,511
add esi,edx
neg edx
add edx,512
cmp ecx,edx
jc .l4
mov ecx,edx
.l4:
add [eax+file_handler.position],ecx
sub [esp+24],ecx
pop edi
call movedata
push edi
popad
ret
.error:
popad
popad
xor ecx,ecx
stc
ret
 
 
ftell: mov edx,[eax+file_handler.position]
ret
lseek: ;eax=file edx=pos
mov [eax+file_handler.position],edx
ret
skip: ;eax=file edx=bytes to skip
add [eax+file_handler.position],edx
ret
 
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/jpegview/trunk/jpegdat.asm
0,0 → 1,22
modes:
dd mcu100,color100,8,8 ;monocromo
dd mcu111,color111,8,8
dd mcu211,color211,16,8
dd mcu411,color411,16,16
 
zigzag:
db 0,0, 4+1,0, 32,1, 64,1, 36,2, 8+1,0, 12+1,0, 40,4
db 68,2, 96,1, 128,1, 100,2, 72,4, 44,8, 16+1,0, 20+1,0
db 48,16, 76,8, 104,4, 132,2, 160,1, 192,1, 164,2, 136,4
db 108,8, 80,16, 52,32, 24+1,0, 28+1,0, 56,64, 84,32, 112,16
db 140,8, 168,4, 196,2, 224,1, 228,2, 200,4, 172,8, 144,16
db 116,32, 88,64, 60,128, 92,128, 120,64, 148,32, 176,16, 204,8
db 232,4, 236,8, 208,16, 180,32, 152,64, 124,128, 156,128, 184,64
db 212,32, 240,16, 244,32, 216,64, 188,128, 220,128, 248,64, 252,128
 
k:
dd 1.41421,1.84776,1.08239,-2.6131
k2:
dd 0.3535534,0.49039264,0.46193953,0.415734806
dd 0.3535534,0.277785116,0.191341716,0.0975451609
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/jpegview/trunk/jpeglib.asm
0,0 → 1,1179
;405 412 586
;
;
bufer_size=1024*16+2
fichero=4
mcu_ptr=8
color_ptr=12
estado=16
color_c=17
nbits=color_c
idct=20
tmp_bits=24
actable=28
matriz_limit=32
sourcebits=36
sourcebits_index=40
sourcebits_limit=44
qt_ptrs=48
ht_dc_ptrs=64
ht_ac_ptrs=80
matrices=96
tmp_bufer=100
x_org=104
y_org=108
x_mcu=112
y_mcu=116
x_size=120
y_size=124
x_org2=128
y_org2=132
x_mcu2=136
y_mcu2=140
x_size2=144
y_size2=148
q_ptr=152
dc=164
position=204
draw_ptr=208
struct_size=212
 
jpeg_info: ;fichero en eax
;retorna ebp
xor ebp,ebp
pushad
mov ebp,esp
mov ecx,6
sub esp,ecx
mov edi,esp
call read
pop dx
cmp dx,0d8ffh
je .l1
mov esp,ebp
popad
ret
.l1: push eax
mov ecx,struct_size
call mallocz
mov [edi],ebp
mov ebp,edi
pop dword [ebp+fichero]
pop ax
pop cx
jmp .l3
.l2: mov ebx,[ebp+tmp_bufer]
add ebx,[ebx-4]
mov cx,[ebx-2]
mov ax,[ebx-4]
.l3: push .l2
xchg cl,ch
add cx,2
cmp ch,3
jnc .l4
cmp al,0ffh
jne eoi
cmp ah,0dbh
je dqt
cmp ah,0c4h
je dht
cmp ah,0c0h
je sof0
cmp ah,0dah
je sos
cmp ah,0c2h
je eoi
cmp ah,0c9h
je eoi
cmp ah,0d9h
je eoi
.l4: lea edx,[ecx-4]
xor ecx,ecx
mov eax,[ebp+fichero]
call skip
mov ecx,4
call READ
cmp ecx,[edi-4]
jne eoi
ret
 
eoi:
mov esp,[ebp]
call jpeg_close
popad
xor ebp,ebp
ret
 
jpeg_close:
test ebp,ebp
jz .l2
pushad
mov eax,[ebp+fichero]
call close
mov edi,[ebp+sourcebits]
call free
lea esi,[ebp+qt_ptrs]
mov ecx,14
.l1: mov edi,[esi]
add esi,4
call free
loop .l1
mov edi,ebp
call free
popad
.l2: ret
 
dqt: call READ
mov esi,edi
lea eax,[edi+ecx]
push eax
.l1: xor eax,eax
lodsb
cmp al,4
jnc eoi
lea ebx,[ebp+qt_ptrs+eax*4]
test dword [ebx],-1
jnz eoi
mov ecx,64
xor eax,eax
sub esp,128
mov edi,esp
.l2: lodsb
stosw
loop .l2
mov ecx,256
call malloc
mov [ebx],edi
mov eax,esi
mov esi,esp
pushad
mov ebp,zigzag
fninit
mov cl,64
xor eax,eax
.l3: fild word[esi]
mov al,[ebp]
and al,-2
add ebp,2
add esi,2
mov ebx,eax
and ebx,28
fmul dword [ebx+k2]
mov ebx,eax
shr ebx,3
and ebx,4+8+16
fmul dword [ebx+k2]
fstp dword [edi+eax]
dec cl
jnz .l3
popad
mov esi,eax
add esp,128
mov eax,[esp]
sub eax,esi
jc eoi
cmp eax,4
ja .l1
jne eoi
pop eax
ret
 
sof0: call READ
cmp byte [edi],8
jne eoi ;precision
mov ax,[edi+1]
xchg al,ah
mov [ebp+y_size],ax
mov ax,[edi+3]
xchg al,ah
mov [ebp+x_size],ax
mov al,[edi+5] ;ncomponentes
mov cl,al
mov [ebp+color_c],al
mov edx,modes
dec al
jz .l1
dec al
dec al
jnz eoi
mov al,[edi+10]
mov ah,[edi+13]
cmp ax,1111h
jne eoi
mov al,[edi+7]
add edx,16
cmp al,11h
je .l1
add edx,16
cmp al,21h
je .l1
add edx,16
cmp al,22h
jne eoi
.l1: lea ebx,[ebp+q_ptr]
lea esi,[ebp+qt_ptrs]
mov [ebp+mcu_ptr],edx
.l2: movzx eax,byte [edi+8]
add edi,3
cmp al,4
jnc eoi
lea eax,[eax*4+esi]
mov [ebx],eax
add ebx,16
dec cl
jnz .l2
ret
 
READ: mov eax,[ebp+fichero]
mov edi,[ebp+tmp_bufer]
movzx ecx,cx
call mresize
mov [ebp+tmp_bufer],edi
jmp read
 
dht: call READ
mov esi,edi
lea eax,[edi+ecx]
push eax
.l1: lodsb
mov edi,esi
mov ebx,3+16
and bl,al
cmp bl,al
jne eoi
shr bl,2
and al,3
or bl,al
lea ebx,[ebp+ht_dc_ptrs+ebx*4]
test dword [ebx],-1
jnz eoi
mov cl,15
mov al,[edi]
.l2: inc edi ;calcular numero de codigos
add al,[edi]
jc eoi
dec cl
jnz .l2
movzx ecx,al
lea ecx,[ecx*4+2]
call malloc
mov [ebx],edi
call arbol_hf
mov eax,[esp]
sub eax,ebx
jc eoi
mov esi,ebx
cmp eax,4
ja .l1
jne eoi
pop eax
ret
 
arbol_hf: ;esi=ht edi=memoria para el arbol
;retorna en ebx el final de ht
;codigos: bits 0-3=nbits del siguiente numero
; bits 4-7=numero de zeros
; bits 8-14=longitud de este codigo o error si =127
; bit 15=codigo/puntero
push ebp
lea ebx,[edi-2]
add ebx,[ebx-2]
mov word [ebx],-1 ;codigo de error si encontrado
push ebx
push esi
lea ebx,[esi+16]
mov ebp,esp
xor ecx,ecx
push edi
push ecx
add edi,2
mov dx,1
add dh,[esi]
jz .l3
jmp .l2
.l1: push edi
push ecx
add edi,2
.l2: inc cl
cmp cl,dl
jc .l1
mov al,[ebx]
inc ebx
mov ah,128 ;marca de codigo
or ah,dl
cmp edi,[ebp+4]
jnc .l5
stosw
cmp esp,ebp
jnc .l5
pop ecx
pop esi
lea eax,[edi-2]
sub eax,esi
mov [esi],ax
dec dh
jnz .l2 ;ncodigos
mov esi,[ebp]
.l3: inc esi
inc dl
cmp dl,17
jnc .l4
add dh,[esi]
jz .l3
mov [ebp],esi
jmp .l2
.l4: lea esp,[ebp+8]
pop ebp
ret
.l5: mov ebp,[ebp+8]
jmp eoi
 
sos: sub ecx,4 ;a continuacion vienen los datos de la imagen
call READ
mov eax,[ebp+fichero]
call ftell
mov [ebp+position],edx
mov esi,edi
lea edi,[ebp+q_ptr]
lodsb ;numero de componentes
sub [ebp+color_c],al
jnz eoi
mov dh,al
.l1: mov ebx,[edi]
mov eax,[ebx]
stosd
lodsw
mov cl,ah
and eax,0f00h
and ecx,0f0h
shr eax,6
shr ecx,2
lea ebx,[ebp+ht_ac_ptrs+eax]
mov eax,[ebx]
lea ebx,[ebp+ht_dc_ptrs+ecx]
mov ecx,[ebx]
test eax,eax
jz eoi
test ecx,ecx
jz eoi
stosd
mov eax,ecx
stosd
add edi,4
dec dh
jnz .l1
mov edx,[ebp+mcu_ptr]
cmp edx,modes
jne .l2
lea esi,[ebp+q_ptr]
lea edi,[ebp+q_ptr+32]
movsd
movsd
movsd
.l2:
mov esi,edx
push dword [esi]
pop dword [ebp+mcu_ptr]
push dword [esi+4]
pop dword[ebp+color_ptr]
push dword [esi+12]
pop dword [ebp+y_mcu]
push dword [esi+8]
pop dword [ebp+x_mcu]
mov ecx,64*18
call malloc
mov [ebp+matrices],edi
mov ecx,bufer_size
call malloc
mov [ebp+sourcebits],edi
mov esp,[ebp]
mov [esp+8],ebp
popad
ret
 
jpeg_display:
test ebp,ebp
jnz .inicio
ret
.inicio:
pushad
mov [ebp],esp
mov eax,[ebp+fichero]
mov edx,[ebp+position]
call lseek
mov edi,[ebp+sourcebits]
add edi,bufer_size
mov [ebp+sourcebits_index],edi
sub edi,2
mov [ebp+sourcebits_limit],edi
mov edi,[ebp+matrices]
mov [ebp+matriz_limit],edi
xor eax,eax
mov [esp+8],eax
mov [ebp+estado],eax
mov [ebp+tmp_bits],eax
mov [ebp+dc],eax
mov [ebp+dc+16],eax
mov [ebp+dc+32],eax
 
mov eax,[ebp+y_mcu]
mov ecx,[ebp+y_org]
sub ecx,eax
mov [ebp+y_org2],ecx
mov [ebp+y_mcu2],eax
push dword [ebp+y_size]
pop dword [ebp+y_size2]
.l3: push dword [ebp+x_org]
pop dword [ebp+x_org2]
push dword [ebp+x_mcu]
pop dword [ebp+x_mcu2]
push dword [ebp+x_size]
pop dword [ebp+x_size2]
mov eax,[ebp+y_mcu2]
add [ebp+y_org2],eax
sub [ebp+y_size2],eax
jnc .l4
add eax,[ebp+y_size2]
jnz .cont
mov [esp+8],ebp
popad
ret
.cont:
mov dword [ebp+y_size2],0
mov [ebp+y_mcu2],eax
.l4:
mov eax,[ebp+x_mcu2]
sub [ebp+x_size2],eax
jnc .l5
add eax,[ebp+x_size2]
jz .l3
mov dword [ebp+x_size2],0
mov [ebp+x_mcu2],eax
call dword [ebp+mcu_ptr]
mov eax,[ebp+x_mcu]
mov ecx,[ebp+x_mcu2]
mov edx,[ebp+y_mcu2]
call recortar
jmp .l6
.l5:
call dword [ebp+mcu_ptr]
mov ecx,[ebp+x_mcu2]
mov edx,[ebp+y_mcu2]
.l6:
mov eax,[ebp+x_org2]
mov ebx,[ebp+y_org2]
call dword [ebp+draw_ptr]
add [ebp+x_org2],ecx
mov ax,[ebp+estado]
test al,15
jz .l4
cmp ah,8
jnc .l4
xor edx,edx
mov [ebp+tmp_bits],edx
mov [ebp+dc],edx
mov [ebp+dc+16],edx
mov [ebp+dc+32],edx
add dword [ebp+sourcebits_index],2
and word [ebp+estado],0c0h
test al,32
jz .l4
jmp .l3
 
color100:
push edi
.l1: lodsw
mov dl,ah
mov ah,al
stosw
mov ah,dl
stosb
mov al,dl
stosb
stosw
dec cl
jnz .l1
pop edi
ret
 
color111:
push edi
.l1: lodsw
mov bx,[esi+62]
mov dx,[esi+126]
xchg ah,bh
xchg ah,dl
xchg ah,bl
stosw
mov ax,bx
stosw
mov ax,dx
stosw
dec cl
jnz .l1
pop edi
mov ecx,64*3
jmp ybr_bgr
 
color411:
push ebp
push edi
lea ebp,[esi+ecx*8]
.l1: push ecx
mov ax,[esi]
mov cx,[ebp]
mov dx,[ebp+64]
add ebp,2
xchg ch,dl
mov bx,ax
mov ah,cl
mov bl,ch
mov [edi],ax
mov [edi+2],bx
mov [edi+4],cx
mov ax,[esi+8]
mov bh,ah
mov ah,cl
mov [edi+48],ax
mov [edi+48+2],bx
mov [edi+48+4],cx
mov ax,[esi+2]
mov bx,ax
mov ah,dl
mov bl,dh
mov [edi+6],ax
mov [edi+2+6],bx
mov [edi+4+6],dx
mov ax,[esi+8+2]
mov bh,ah
mov ah,dl
mov [edi+48+6],ax
mov [edi+48+2+6],bx
mov [edi+48+4+6],dx
pop ecx
add edi,12
dec ecx
add esi,4
test cl,1
jnz .l1
add esi,64-8
test cl,2
jnz .l1
sub esi,128-16
add edi,48
test cl,15
jnz .l1
add esi,64
test cl,cl
jnz .l1
pop edi
pop ebp
mov ecx,64*4*3
jmp ybr_bgr
 
color211:
push ebp
push edi
lea ebp,[esi+ecx*4]
.l1: push ecx
mov ax,[esi]
mov cx,[ebp]
mov dx,[ebp+64]
add ebp,2
xchg ch,dl
mov bx,ax
mov ah,cl
mov bl,ch
mov [edi],ax
mov [edi+2],bx
mov [edi+4],cx
mov ax,[esi+2]
mov bx,ax
mov ah,dl
mov bl,dh
mov [edi+6],ax
mov [edi+2+6],bx
mov [edi+4+6],dx
pop ecx
add edi,12
dec cl
add esi,4
test cl,1
jnz .l1
add esi,64-8
test cl,2
jnz .l1
sub esi,128-8
test cl,cl
jnz .l1
pop edi
pop ebp
mov ecx,64*3*2
jmp ybr_bgr
 
 
mcu411: lea ebx,[ebp+q_ptr]
call hufdecode
lea ebx,[ebp+q_ptr]
call hufdecode
mcu211: lea ebx,[ebp+q_ptr]
call hufdecode
mcu111: lea ebx,[ebp+q_ptr]
call hufdecode
lea ebx,[ebp+q_ptr+16]
call hufdecode
mcu100: lea ebx,[ebp+q_ptr+32]
call hufdecode
mov esi,[ebp+matrices]
mov dword [ebp+matriz_limit],esi
mov ecx,32
lea edi,[esi+64*6]
jmp dword [ebp+color_ptr]
 
cargar_bits: ;edx=bits,cl=nbits,
;bp=data struct
;cr: cl,edx,eax,si
;ncr bx,bp,di,ch
 
mov esi,[ebp+sourcebits_index]
cmp esi,[ebp+sourcebits_limit]
jnc .l6
movzx eax,byte [esi]
inc esi
add cl,8
cmp al,-1
je .l2
mov ah,al
lodsb
add cl,8
cmp al,-1
je .l2
.l1: ror eax,cl
or edx,eax
mov [ebp+sourcebits_index],esi
ret
.l2: lodsb
test al,al
jnz .l3
mov al,-1
call .l1
cmp cl,16
jc cargar_bits
ret
.l3: sub esi,2
sub cl,8
sub al,0d0h
cmp al,8
jc .l4
sub al,9
mov al,63
jz .l4
mov al,127
.l4: inc al
or [ebp+estado],al
movzx eax,ah
jmp .l1
.l5: mov [ebp+sourcebits_limit],edi
mov word [edi],0d9ffh
popad
jmp cargar_bits
.l6: ;read file
pushad
mov ecx,bufer_size-2
mov edx,[ebp+sourcebits_limit]
mov edi,[ebp+sourcebits]
mov ax,[edx]
sub edx,edi
stosw
sub esi,edx
mov [ebp+sourcebits_index],esi
cmp edx,ecx
jne .l5
mov eax,[ebp+fichero]
call read
lea ecx,[edi+ecx-2]
mov [ebp+sourcebits_limit],ecx
popad
jmp cargar_bits
 
 
hufdecode: ;si->dctable [bp+20]->actable di->outbufer edx->bits cl->bits en edx
 
 
;[bp+24]->sourcebits
;[bp+22]=outbufer+128
;[bx] q ptr para aa&n
;[bx+2] a ptr
;[bx+4] d ptr
;[bx+8] dc componente
fninit
push dword [ebx]
mov cl,[ebp+nbits]
mov edx,[ebp+tmp_bits]
cmp cl,16
jnc .l1
call cargar_bits
.l1: mov eax,[ebx+4]
mov esi,[ebx+8]
mov [ebp+actable],eax
movzx eax,word [esi]
add esi,2
.l2: add edx,edx
jnc .l3
add esi,eax
.l3: lodsw
test ax,ax
jns .l2
;codigo encontrado
and ax,7f0fh
mov edi,[ebp+matriz_limit] ;arrays
sub cl,ah
jns .l4
fldz
.error:
xor ecx,ecx
or byte [ebp+estado],32
jmp .l12
.l4: cmp cl,al
jnc .l5
push eax
call cargar_bits
pop eax
.l5: sub cl,al
mov ch,cl
mov cl,al
mov eax,edx
shl edx,cl
sar eax,17
xor ax,8000h
xor cl,15
sar ax,cl
mov cl,ch
mov ch,2
add ax,8000h ;incrementar si negativo
adc ax,8000h
add [ebx+12],ax
fild word [ebx+12]
push ecx
mov ecx,64
xor eax,eax
add [ebp+matriz_limit],ecx
rep stosd
pop ecx
sub edi,64*4
mov ebx,[esp]
fmul dword [ebx]
.l6: cmp cl,16
jnc .l7
call cargar_bits
.l7: mov esi,[ebp+actable]
movzx eax,word[esi]
add esi,2
.l8: add edx,edx
jnc .l9
add esi,eax
.l9: lodsw
test ax,ax
jns .l8
;codigo encontrado
and ah,127
xor ebx,ebx
sub cl,ah
js .error
or bl,al
jz .l12
and al,0f0h
shr al,3
add ch,al
js .error
and bl,0fh
jz .l11
cmp cl,bl
jnc .l10
call cargar_bits
.l10: sub cl,bl
xchg bl,cl
mov eax,edx
shl edx,cl
sar eax,17
xor cl,15
xor ax,8000h
sar ax,cl
add ax,8000h ;incrementar si negativo
adc ax,8000h
mov cl,bl
mov bl,ch
mov [ebp+tmp_bits],ax
mov ax,[ebx+zigzag]
mov ebx,[esp]
fild word [ebp+tmp_bits]
or [ebp+idct],ax
and eax,11111100b
fmul dword [ebx+eax]
fstp dword [edi+eax]
.l11: add ch,2
jns .l6
.l12: mov [ebp+nbits],cl
mov [ebp+tmp_bits],edx
xor ebx,ebx
add esp,4
xchg ebx,[ebp+idct]
cmp ch,2
je idctf1
fstp dword [edi]
test bh,0feh
jnz idctf3
idctf2a: test bh,1
mov esi,edi
jz .l1
test bl,1
jnz idctf3
push idctf2b
jmp idctf3b
.l1: call idctf3a
mov cl,4
call limit
mov eax,[edi-8]
mov edx,[edi-4]
mov cl,7
.l2: mov [edi],eax
mov [edi+4],edx
add edi,8
dec cl
jnz .l2
ret
 
idctf1: fistp word[edi+64]
mov ax,128
add ax,[edi+64]
jz .l2
test ah,ah
jz .l1
mov al,-1
js .l2
.l1: mov ah,al
stosw
stosw
mov eax,[edi-4]
mov ecx,15
rep stosd
.l2: ret
 
idctf3: mov bl,8
mov esi,edi
.l1: rcr bh,1
jc .l3
mov eax,[esi]
test eax,eax
jz .l4
mov cl,7
.l2: add esi,32
mov [esi],eax
dec cl
jnz .l2
sub esi,32*7-4
dec bl
jnz .l1
jmp .l5
.l3: call idctf3b
.l4: add esi,4
dec bl
jnz .l1
.l5: mov esi,edi
mov cl,8
.l6: call idctf3a
add esi,32
add edi,16
dec cl
jnz .l6
sub edi,128
mov esi,edi
mov cl,32
limit: mov dx,[esi]
mov bx,[esi+2]
add esi,4
add dx,128
add bx,128
test dh,dh
mov ax,dx
jz .l1
mov al,0
js .l1
mov al,-1
.l1: test bh,bh
mov ah,bl
jz .l2
mov ah,0
js .l2
mov ah,-1
.l2: stosw
dec cl
jnz limit
ret
 
idctf2b:
mov dl,8
.l1: fld dword[esi]
add esi,32
mov ax,128
fistp word [edi]
add ax,[edi]
test ah,ah
jz .l2
mov al,0
js .l2
mov al,-1
.l2: mov ah,al
stosw
stosw
stosw
stosw
dec dl
jnz .l1
ret
 
idctf3a: ;si(d float),di(w int) ncr
fld dword[esi+1*4] ;f1 ;t21=f1+f7
fld st0
fld dword[esi+7*4] ;f7
fadd st2,st0
fsubp st1,st0 ;t22=f1-f7
fld dword[esi+5*4]
fld st0 ;f5 ;t23=f5+f3
fld dword[esi+3*4] ;f3
fadd st2,st0
fsubp st1,st0 ;t20=f5-f3
fld st0
fadd st0,st3 ;t25=(t20+t22)*k2
fmul dword[k+4] ;k2 ;t25,t20,t23,t22,t21
fld st4 ;t7=t21+t23
fadd st0,st3 ;t7,t25,t20,t23,t22,t21
fld dword[k+12] ;k4 ;t6=k4*t20+t25-t7
fmulp st3,st0
fsub st2,st0
fld st1
faddp st3,st0 ;t7,t25,t6,t23,t22,t21
fld st5 ;t5=(t21-t23)*k1-t6
fsub st0,st4
fmul dword[k] ;k1
fsub st0,st3
fstp st6 ;t7,t25,t6,t23,t22,t5
fstp st3 ;t25,t6,t7,t22,t5
fxch st3
fmul dword[k+8] ;k3 ;t4=k3*t22-t25+t5
fadd st0,st4 ;t22*k3+t5,t6,t7,t25,t5
fsubrp st3,st0 ;t6,t7,t4,t5
fld dword[esi] ;f0 ;t10=f0+f4
fst st5 ;f0,t4,t5,t6,t7,f0
fld dword[esi+4*4] ;f4
fsub st6,st0 ;t11=f0-f4
faddp st1,st0
fld st0 ;t10,t10,t6,t7,t4,t5,t11
fld dword[esi+2*4] ;f2 ;t13=f2+f6
fadd dword[esi+6*4] ;f6 ;t13,t10,t10,t6,t7,t4,t5,t11
fadd st2,st0 ;t13,t10,t0,t6,t7,t4,t5,t11 ;t0=t10+t13
fsubp st1,st0 ;t3,t0,t6,t7,t4,t5,t11 ;t3=t10-t13
fld st0 ;p3=t3-t4
fsub st0,st5
fistp word [edi+3*2] ;p3
fadd st0,st4 ;p4=t3+t4
fld dword[esi+2*4] ;f2
fstp st5
fistp word [edi+4*2] ;p4 ;t0,t6,t7,f2,t5,t11
fld st0 ;p0=t0+t7
fsub st0,st3
fistp word [edi+7*2] ;p7
fadd st0,st2 ;p7=t0-t7
fistp word [edi] ;p0 ;t6,t7,f2,t5,t11
fld st2 ;f2 ;f2,t6,t7,f2,t5,t11 ;t12=(f2-f6)*k1-t13
fld dword[esi+6*4] ;f6
fadd st4,st0 ;f6,f2,t6,t7,t13,t5,t11
fsubp st1,st0
fmul dword[k] ;k1
fsub st0,st3
fst st3 ;t12,t6,t7,t12,t5,t11
fadd st0,st5 ;t1=t11+t12
fst st2 ;t1,t6,t1,t12,t5,t11
fadd st0,st1 ;p1=t1+t6
fistp word [edi+2] ;p1 ;t6,t1,t12,t5,t11
fsubp st1,st0 ;p6=t1-t6
fistp word [edi+6*2] ;p6 ;t12,t5,t11
fsubp st2,st0 ;t2=t11-t12 ;t5,t2
fld st0
fadd st0,st2 ;p2=t2+t5
fistp word [edi+2*2] ;p2
fsubp st1,st0 ;p5=t2-t5 ;t5,t2
fistp word [edi+5*2]
ret ;p5
 
 
 
 
idctf3b: ;si ncr
fld dword[esi+1*32]
fld st0 ;f1 ;t21=f1+f7
fld dword[esi+7*32]
fadd st2,st0 ;f7
fsubp st1,st0 ;t22=f1-f7
fld dword[esi+5*32]
fld st0 ;f5 ;t23=f5+f3
fld dword[esi+3*32] ;f3
fadd st2,st0
fsubp st1,st0
fld st0 ;t20=f5-f3
fadd st0,st3 ;t25=(t20+t22)*k2
fmul dword[k+4] ;k2 ;t25,t20,t23,t22,t21
fld st4 ;t7=t21+t23
fadd st0,st3 ;t7,t25,t20,t23,t22,t21
fld dword[k+12] ;k4 ;t6=k4*t20+t25-t7
fmulp st3,st0
fsub st2,st0
fld st1
faddp st3,st0 ;t7,t25,t6,t23,t22,t21
fld st5 ;t5=(t21-t23)*k1-t6
fsub st0,st4
fmul dword[k] ;k1
fsub st0,st3
fstp st6 ;t7,t25,t6,t23,t22,t5
fstp st3
fxch st3 ;t25,t6,t7,t22,t5
fmul dword[k+8] ;k3 ;t4=k3*t22-t25+t5
fadd st0,st4 ;t22*k3+t5,t6,t7,t25,t5
fsubrp st3,st0 ;t6,t7,t4,t5
fld dword[esi] ;f0 ;t10=f0+f4
fst st5 ;f0,t4,t5,t6,t7,f0
fld dword[esi+4*32] ;f4
fsub st6,st0 ;t11=f0-f4
faddp st1,st0
fld st0 ;t10,t10,t6,t7,t4,t5,t11
fld dword[esi+2*32] ;f2 ;t13=f2+f6
fadd dword[esi+6*32] ;f6 ;t13,t10,t10,t6,t7,t4,t5,t11
fadd st2,st0 ;t13,t10,t0,t6,t7,t4,t5,t11 ;t0=t10+t13
fsubp st1,st0 ;t3,t0,t6,t7,t4,t5,t11 ;t3=t10-t13
fld st0 ;p3=t3-t4
fsub st0,st5
fstp dword[esi+3*32] ;p3
fadd st0,st4 ;p4=t3+t4
fld dword[esi+2*32] ;f2
fstp st5
fstp dword[esi+4*32] ;p4 ;t0,t6,t7,f2,t5,t11
fld st0
fsub st0,st3 ;p0=t0+t7
fstp dword[esi+7*32] ;p7
fadd st0,st2 ;p7=t0-t7
fstp dword[esi] ;p0 ;t6,t7,f2,t5,t11
fld st2 ;f2 ;f2,t6,t7,f2,t5,t11 ;t12=(f2-f6)*k1-t13
fld dword[esi+6*32] ;f6
fadd st4,st0 ;f6,f2,t6,t7,t13,t5,t11
fsubp st1,st0
fmul dword[k] ;k1
fsub st0,st3
fst st3 ;t12,t6,t7,t12,t5,t11
fadd st0,st5 ;t1=t11+t12
fst st2 ;t1,t6,t1,t12,t5,t11
fadd st0,st1 ;p1=t1+t6
fstp dword[esi+1*32] ;p1 ;t6,t1,t12,t5,t11
fsubp st1,st0 ;p6=t1-t6
fstp dword[esi+6*32] ;p6 ;t12,t5,t11
fsubp st2,st0
fld st0 ;t2=t11-t12 ;t5,t2
fadd st0,st2 ;p2=t2+t5
fstp dword[esi+2*32] ;p2
fsubp st1,st0 ;p5=t2-t5 ;t5,t2
fstp dword[esi+5*32]
ret ;p5
 
ybr_bgr: ;edi=bmp ecx=n_BYTES
;retorna edi+=ecx
pushad
mov esi,edi
add edi,ecx
push edi
mov edi,[colortabla]
.l1: lodsw
movzx ebx,ah
movzx ebp,al
movzx eax,al
movzx ecx,byte[esi]
lea ebx,[ebx*4+edi+1024]
lea ecx,[ecx*4+edi]
add eax,[ebx] ;cb ;solo se usan 16 bits
mov edx,[ebx+2] ;pero el codigo de 32 bits es mas rapido
mov ebx,[ecx] ;cr
add eax,[ecx+2]
add ebx,ebp ;b
add edx,ebp ;r
test ah,ah
jz .l2
mov al,0
js .l2
mov al,-1
.l2: test dh,dh
jz .l3
mov dl,0
js .l3
mov dl,-1
.l3: test bh,bh
mov dh,al
jz .l4
mov bl,0
js .l4
mov bl,-1
.l4: mov [esi-2],dx
mov [esi],bl
inc esi
cmp esi,[esp]
jc .l1
pop edi
popad
ret
 
recortar: ;edi=bufer eax=ancho en pixels (ecx,edx)tama¤o deseado
pushad
dec edx
jz .l2
lea ebx,[ecx*3]
lea eax,[eax*3]
lea esi,[edi+eax]
add edi,ebx
sub eax,ebx
.l1: mov ecx,ebx
call movedata
add esi,eax
dec edx
jnz .l1
.l2: popad
ret
 
;R = Y + 1.402 *(Cr-128)
;G = Y - 0.34414*(Cb-128) - 0.71414*(Cr-128)
;B = Y + 1.772 *(Cb-128)
 
colortabla: dd 0
 
colorprecalc: ;prepara la tabla para convertir ycb a rgb
mov ecx,1024*2
call malloc
mov [colortabla],edi
fninit
fld dword [.k+4]
fld dword [.k]
mov dl,0
call .l1
fld dword [.k+12]
fld dword[.k+8]
.l1: mov cx,-128
.l2: mov [edi],ecx
inc ecx
fild word[edi]
fld st0
fmul st0,st2
fistp word[edi]
fmul st0,st2
fistp word[edi+2]
add edi,4
inc dl
jnz .l2
ret
 
.k: dd 1.402,-0.71414,-0.34414,+1.772
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/jpegview/trunk/jpegview.asm
0,0 → 1,638
; IMGVIEW.ASM
;
; This program displays jpeg images. The window can be resized.
;
; Version 0.0 END OF 2003
; Octavio Vega
; Version 0.1 7th March 2004
; Mike Hibbett ( very small part! )
; Version 0.11 7th April 2004
; Ville Turjanmaa ( 'set_as_bgr' function )
; Version 0.12 29th May 2004
; Ivan Poddubny (correct "set_as_bgr"+parameters+boot+...)
; Version 0.12 30 de mayo 2004
; Octavio Vega
; bugs correction and slideshow
; version 0.13 3 de junio 2004
; Octavio Vega
; unos retoques
; version 0.14 10th August 2004
; Mike Hibbett Added setting default colours
;
memsize=20000h
org 0
PARAMS = memsize - 1024
 
use32
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd memsize ; memory for app
dd memsize - 1024 ; esp
dd PARAMS , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
stack_size=4096 + 1024
 
 
START: ; start of execution
 
cmp [PARAMS], byte 0
jne check_parameters
 
; Calculate the 'free' memory available
; to the application, and create the malloc block from it
.l1:
mov ecx,memsize-fin-stack_size
mov edi,fin
call add_mem
 
; Get some memory
mov ecx,16384
call malloc
mov [work_area],edi
call colorprecalc ;inicializa tablas usadas para pasar de ybr a bgr
call draw_window
call read_string.rs_done
 
still:
push still
mov ebx,100 ;1 second
mov eax,23 ; wait here for event
int 0x40
cmp eax,1 ; redraw request ?
je draw_window
cmp eax,2 ; key in buffer ?
je read_string
cmp eax,3 ; button in buffer ?
je button
jmp display_next
 
button: ; BUTTON
mov eax,17
int 0x40
cmp ah,3
je set_as_bgr2
cmp ah,2
je slideshow
cmp ah,1 ; CLOSE PROGRAM
jne close_program.exit
close_program:
mov eax,-1
int 0x40
.exit:
ret
 
; Put a 'chunk' of the image on the window
put_image:
pushad
 
lea ebp,[edx+eax+7]
cmp [winxs],bp
jc .l1
lea ebp,[ecx+ebx+20+2+17]
cmp [winys],bp
jc .l1
 
add eax,5 ; offset for boarder
add ebx,20 ; offset for title bar
push ax ; pox
push bx ; pos
push cx ; size
push dx ; size
pop ecx
pop edx
mov ebx,edi
mov eax,7
 
int 40h ; Put image function
.l1:
popad
ret
 
 
 
;******************************************************************************
 
check_parameters:
cmp [PARAMS], dword "BOOT" ; received BOOT parameter -> goto handler
je boot_set_background
 
mov edi, name_string ; clear string with file name
mov al, 0
mov ecx, 100
rep stosb
 
mov ecx, 100 ; calculate length of parameter string
mov edi, PARAMS
repne scasb
sub edi, PARAMS
mov ecx, edi
 
mov esi, PARAMS ; copy parameters to file name
mov edi, name_string
cld
rep movsb
 
jmp START.l1 ; return to beggining of the progra
 
;******************************************************************************
 
 
set_default_colours:
 
pusha
 
mov eax,6 ; load default color map
mov ebx,defcol
mov ecx,0
mov edx,-1
mov esi,0x10000
int 0x40
 
mov eax,48 ; set default color map
mov ebx,2
mov ecx,0x10000
mov edx,10*4
int 0x40
 
popa
ret
 
defcol db 'DEFAULT.DTP'
 
 
boot_set_background:
call set_default_colours
 
mov ecx,memsize-fin-stack_size ; size
mov edi,fin ; pointer
call add_mem ; mark memory from fin to 0x100000-1024 as free
; Get some memory
mov ecx,16384 ; get 16 Kb of memory
call malloc ; returns pointer in edi
mov [work_area],edi ; save it
call colorprecalc ; calculate colors
mov esi,name_string
call open
test eax,eax
jz close_program
call jpeg_info
mov dword [jpeg_st],ebp
call set_as_bgr2 ; set wallpaper
jmp close_program ; close the program right now
 
;******************************************************************************
;******************************************************************************
 
set_as_bgr2:
mov ebp,dword[jpeg_st]
test ebp,ebp
jz .end
 
mov dword [ebp+draw_ptr],put_chunk_to_bgr
call jpeg_display
mov eax, 15
mov ebx, 1
mov ecx, [ebp + x_size]
mov edx, [ebp + y_size]
int 0x40
 
; Stretch the image to fit
mov eax, 15
mov ebx, 4
mov ecx, 2
int 0x40
 
mov eax, 15
mov ebx, 3
int 0x40
 
 
.end:
ret
 
;******************************************************************************
 
put_chunk_to_bgr:
pushad
 
mov [x_pointer], edi
mov esi, ecx
imul esi, 3
mov [x_numofbytes], esi
mov ecx, [ebp + x_size]
imul ecx, ebx
add ecx, eax
imul ecx, 3
mov [x_offset], ecx
mov [x_counter], edx
mov eax, [ebp + x_size]
imul eax, 3
mov [x_numofb2], eax
.new_string:
mov eax, 15
mov ebx, 5
mov ecx, [x_pointer]
mov edx, [x_offset]
mov esi, [x_numofbytes]
int 0x40
mov eax, [x_numofbytes]
add [x_pointer], eax
mov eax, [x_numofb2]
add [x_offset], eax
dec [x_counter]
jnz .new_string
 
popad
ret
 
;******************************************************************************
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
mov eax,12
mov ebx,1
int 0x40
 
; Draw the window to the appropriate size - it may have
; been resized by the user
mov eax, 0
cmp [winxs], ax
jne dw_001
 
; Give the screen some inital defaults
mov ax, 400
mov [winxs], ax
mov ax, 300
mov [winys], ax
mov ax, 100
mov [winxo], ax
mov [winyo], ax
jmp dw_002
 
dw_001:
mov eax, 9
mov ebx, memsize - 1024
mov ecx, -1
int 0x40
mov eax, [ebx + 34]
mov [winxo], ax
mov eax, [ebx + 38]
mov [winyo], ax
mov eax, [ebx + 42]
mov [winxs], ax
mov eax, [ebx + 46]
mov [winys], ax
 
dw_002:
mov bx, [winxo]
shl ebx, 16
mov bx, [winxs]
 
mov cx, [winyo]
shl ecx, 16
mov cx, [winys]
 
 
mov eax,0 ; DRAW WINDOW
mov edx,[wcolor]
add edx,0x02000000
mov esi,0x80557799
mov edi,0x00557799
int 0x40
 
mov eax,4 ; WINDOW LABEL
mov ebx,8*65536+8
mov ecx,0x00ffffff
mov edx,labelt
mov esi,labellen-labelt
int 0x40
 
 
mov eax,8 ; CLOSE BUTTON
 
mov bx, [winxs]
sub bx, 19
shl ebx, 16
add ebx, 12
 
mov ecx,5*65536+12
mov edx,1
mov esi,0x557799
int 0x40
 
; draw status bar
mov eax, 13
movzx ebx, word [winxs]
sub ebx, 5
add ebx, 4*65536
mov cx, [winys]
sub ecx, 19
shl ecx, 16
add ecx, 3
mov edx, 0x00557799
int 0x40
 
mov eax,8 ; BUTTON 2: filename
mov ebx,4*65536+55
mov cx, [winys]
sub cx, 16
shl ecx, 16
add ecx, 12
mov esi, 0x00557799
mov edx,2
int 0x40
 
mov eax,4 ; Button text
movzx ebx, word [winys]
sub ebx, 13
add ebx, 6*65536
mov ecx,0x00ffffff
mov edx,setname
mov esi,setnamelen-setname
int 0x40
 
 
mov eax,8 ; BUTTON 3: set as background
mov bx, [winxs]
sub bx, 60
shl ebx, 16
mov bx,55
mov cx, [winys]
sub cx, 16
shl ecx, 16
add ecx, 12
mov esi, 0x00557799
mov edx,3
int 0x40
 
mov eax,4 ; Button text
movzx ebx, word [winxs]
sub ebx, 60
shl ebx,16
mov bx, word [winys]
sub bx,13
mov ecx,0x00ffffff
mov edx,setbgr
mov esi,setbgrlen-setbgr
int 0x40
call print_strings
call load_image
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
 
; Read in the image file name.
read_string:
movzx edi,byte[name_string.cursor]
add edi,name_string
mov eax,2
int 0x40 ; Get the key value
shr eax,8
cmp eax,13 ; Return key ends input
je .rs_done
cmp eax,8
jnz .nobsl
cmp edi,name_string
je .exit
dec edi
mov [edi],byte 0;'_'
dec byte[name_string.cursor]
jmp print_strings
.exit: ret
.nobsl:
cmp eax,31
jbe .exit
cmp eax,97
jb .keyok
sub eax,32
.keyok:
mov ah,0
stosw
cmp edi,name_string.end
jnc print_strings
inc byte[name_string.cursor]
jmp print_strings
.rs_done:
call print_strings
mov esi,name_string
call open
test eax,eax
jz .exit
call jpeg_info
test ebp,ebp
jz close
xchg [jpeg_st],ebp
call jpeg_close
 
load_image:
 
mov eax,13 ; clear picture area
movzx ebx, word [winxs]
sub ebx, 7
add ebx, 4 * 65536
movzx ecx, word [winys]
sub ecx, 39
add ecx, 20 * 65536
 
mov edx,0
int 0x40
mov ebp,[jpeg_st]
test ebp,ebp
jz .exit
mov dword [ebp+draw_ptr],put_image
jmp jpeg_display
.exit: ret
 
print_strings:
pusha
mov eax,13 ; clear text area
movzx ebx, word [winxs]
sub ebx, 64+58
add ebx, 60*65536
mov cx, [winys]
sub cx, 16
shl ecx, 16
add ecx, 12
mov edx,0xffffff
int 0x40
 
mov eax,4 ;
movzx ebx, word [winys]
sub ebx, 14
add ebx, 60*65536
mov ecx,0x000000
mov edx,name_string
mov esi,60
int 0x40
popa
ret
 
slideshow:
test dword[file_dir],-1
jnz .exit
test dword[jpeg_st],-1
jz .exit
mov esi,name_string
movzx ecx,byte[name_string.cursor]
.l1:
cmp byte[esi+ecx],'/'
je .l2
loop .l1
.exit:
ret
.l2:
mov byte[esi+ecx],0
call open
mov byte[esi+ecx],'/'
test eax,eax
jz .exit
 
mov dword[eax+file_handler.size],-1 ;directory size is always 0
mov [file_dir],eax
inc cl
mov [name_string.cursor],cl
 
display_next:
mov eax,[file_dir]
test eax,eax
jnz .l1
ret
.l1:
mov ecx,32
sub esp,ecx
mov edi,esp
call read
cmp ecx,32
jnc .l11
.l10:
add esp,32
mov eax,dword[file_dir]
mov dword[file_dir],0
jmp close
.l11:
mov esi,esp
movzx edi,byte[name_string.cursor]
add edi,name_string
lodsb
cmp al,0
je .l10
cmp al,229
jne .l0
add esp,32
jmp display_next
.l0:
stosb
mov cl,7
.l2:
lodsb
cmp al,32
jna .l3
stosb
loop .l2
.l3:
lea esi,[esp+8]
mov al,'.'
stosb
mov cl,3
.l4:
lodsb
cmp al,32
jna .l5
stosb
loop .l4
.l5:
mov al,0
stosb
cmp edi,name_string.end
jc .l5
add esp,32
call print_strings
mov esi,name_string
call open
test eax,eax
jz display_next
call jpeg_info
test ebp,ebp
jnz .l6
call close
jmp display_next
.l6:
mov dword[ebp+draw_ptr],put_image
push ebp
xchg [jpeg_st],ebp
call jpeg_close
pop ebp
jmp jpeg_display
 
 
 
include 'filelib.asm'
include 'memlib.asm'
include 'jpeglib.asm'
 
 
; DATA AREA
 
wcolor dd 0x000000
labelt db 'Jpegview v0.14'
labellen:
setname db 'SLIDESHOW'
setnamelen:
 
setbgr db ' BGR '
setbgrlen:
 
x_pointer dd 0
x_offset dd 0
x_numofbytes dd 0
x_numofb2 dd 0
x_counter dd 0
winxo: dw 0
winyo: dw 0
winxs: dw 0
winys: dw 0
jpeg_st: dd 0
file_dir: dd 0
work_area: dd 0
tcolor dd 0x000000
btcolor dd 0x224466+0x808080
name_string: db '/rd/1/jpegview.jpg',0
 
rb 100
.end:
.cursor: db 19
.cursor2: db 0
 
align 4
 
rgb16: db 0,4,8,13,17,21,25,29,34,38,42,46,50,55,59,63
rgb4: db 0,21,42,63
 
include 'jpegdat.asm'
 
align 4
 
iniciomemoria:
dd -(iniciomemoria+4),-(iniciomemoria+4),(iniciomemoria+4),.l1,0
.l1 dd 0
 
fin:
I_END:
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/jpegview/trunk/memlib.asm
0,0 → 1,210
 
movedata:
push eax
xor eax,eax
sub eax,edi
and eax,3
xchg ecx,eax
sub eax,ecx
jle .l1
rep movsb
mov ecx,eax
shr ecx,2
rep movsd
and eax,3
.l1: add ecx,eax
rep movsb
pop eax
ret
 
mallocz:
call malloc
pushad
add ecx,3
xor eax,eax
shr ecx,2
rep stosd
popad
ret
 
mresize1: popad
xor edi,edi
stc
mresize2: ret
mresize: ; puntero en di ncr retorna nuevo puntero en di
test edi,edi
jz malloc
cmp ecx,[edi-4]
je mresize2
call free
malloc:
mov edi,ecx
jecxz mresize2
pushad
mov esi,iniciomemoria+4
lea ebx,[ecx+3]
and ebx,-4 ;redondeo a 4
.l1: mov edi,esi
add esi,[esi]
jc mresize1
lodsd
cmp eax,ebx
jc .l1
cmp esi,[iniciomemoria+8]
jc .l2
jne mresize1
lea edx,[ebx+esi+4]
cmp edx,[iniciomemoria+12]
jnc mresize1
mov [iniciomemoria+8],edx
.l2: pop dword [esi-4]
push esi
sub eax,ebx
je .l3
sub eax,4
mov [esi+ebx],eax
jz .l3
;fragmentar
add ebx,4
add [edi],ebx
mov eax,[esi]
sub eax,ebx
mov [esi+ebx],eax
popad
ret
.l3: lodsd
add eax,4
add [edi],eax
popad
ret
 
realloc: test edi,edi
jz malloc
jecxz free
pushad
pop esi
mov eax,[edi-4]
call malloc
push edi
cmp ecx,eax
jc .l1
mov ecx,eax
.l1: push esi
call movedata
pop edi
call free
popad
.l2: ret
free: ;puntero en di
;no se comprueban los punteros
;retorna di=0 , ncr
test edi,edi
jz realloc.l2
pushad
pop edi
mov ebp,[edi-4]
dec ebp
and ebp,-4 ;redondeo a 4,dx=dx-4
xor edx,edx
push edx
mov edx,iniciomemoria+4
mov esi,edx
;buscar puntero libre anterior
.l1: mov ebx,esi
lodsd
add esi,eax
cmp esi,edi
jc .l1
;enlazar
mov ecx,esi
sub ecx,edi
sub eax,ecx
sub ecx,4
mov [ebx],eax
;fusionar con el anterior
cmp eax,[ebx-4]
jne .l2
cmp ebx,edx
je .l2 ;no fusionar con el primero
mov edi,ebx
add eax,4
add ecx,eax
add ebp,eax
.l2: mov ebx,ebp ;fusionar con bloques de tama¤o 0
.l3: add ebx,4
test dword [edi+ebx],-1
jz .l3
cmp ebx,ecx
jne .l4
;fusionar con el siguiente
add ebx,[esi-4]
add ecx,[esi]
add ebx,4
add ecx,4
cmp esi,[edx+4]
jne .l4
mov [edx+4],edi
.l4: mov [edi-4],ebx
mov [edi],ecx
popad
ret
 
add_mem: ;edi,ecx ;el ultimo bloque libre debe ser >8 bytes para poder fragmentarlo
cmp ecx,64
jc .l1
add ecx,edi
add edi,3
and edi,-4
and ecx,-4
mov eax,ecx
sub ecx,edi ;redondeo
xchg eax,[iniciomemoria+12]
cmp edi,eax
jna .l1
lea esi,[edi+4]
mov edx,esi
xchg esi,[iniciomemoria+8]
neg edx
mov [edi],edx
mov [edi+4],edx
lea edx,[edi-4]
sub edi,esi
mov [esi],edi
sub eax,4
sub eax,esi
mov [esi-4],eax
add esi,eax
sub edx,esi
mov [esi],edx
.l1: ret
 
check_mem: ;busqueda de errores en la memoria
;retorna edx nbloques o 0 si error,ecx memoria libre
;ncr: ebp,ebx,eax
mov edi,iniciomemoria
mov esi,edi
xor edx,edx
mov ecx,[edi]
neg ecx ;el primer bloque no cuenta
.l1: add ecx,[edi]
add edi,4
add edi,[edi]
.l2: inc edx
add esi,[esi]
jc .l4
add esi,7
jc .l3
and esi,-4
cmp esi,edi
jc .l2
je .l1
jmp .l4
.l3: test edi,edi
jnz .l4
add ecx,[iniciomemoria+12]
ret
.l4: xor edx,edx
stc
ret
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/midiplay/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm midiplay.asm midiplay
@pause
/programs/media/midiplay/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm midiplay.asm midiplay
@pause
/programs/media/midiplay/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/midiplay/trunk/midiplay.asm
0,0 → 1,255
;
; Ok, this is the sceleton that MENUET 0.01 understands.
; Do not change the header bits for now. Compile with nasm.
;
 
include 'lang.inc'
include 'macros.inc'
 
use32
 
org 0x0
db 'MENUET00' ; 8 byte id
dd 38 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x1000 ; reguired amount of memory
dd 0x1000
dd 0x00000000 ; reserved=no extended header
 
 
 
START:
 
call draw_window
 
still:
 
mov eax,10 ; redraw ?
int 0x40
 
cmp eax,1
jz red
cmp eax,3
jz button
jmp still
 
red:
call draw_window
jmp still
 
button:
mov eax,17
int 0x40
 
cmp al,byte 0
jnz still
 
cmp ah,1
jnz noexit
 
mov eax,0xffffffff
int 0x40
 
noexit:
 
cmp ah,2
jz note1
 
mov eax,20 ; reset midi device
mov ebx,1
mov ecx,0
int 0x40
 
cmp eax,0
jz noe1
 
call printerror
 
noe1:
 
jmp still
 
note1:
 
mov eax,50
 
nn:
 
mov ebx,100
call noteout
pusha
mov eax,5
mov ebx,8
int 0x40
popa
mov ebx,0
; call noteout
 
add eax,3
 
mov ebx,100
call noteout
pusha
mov eax,5
mov ebx,8
int 0x40
popa
mov ebx,0
; call noteout
 
add eax,4
 
inc eax
cmp eax,90
jbe nn
 
jmp still
 
 
draw_window:
 
pusha
 
mov eax,12 ; tell os about redraw
mov ebx,1
int 0x40
 
mov eax,0 ; define and draw window
mov ebx,20*65536+250
mov ecx,20*65536+120
mov edx,0x02ffffff
mov esi,0x805070d0;88ccee
mov edi,0x005070d0;88ccee
int 0x40
 
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw
mov ebx,(250-19)*65536+12 ; [x start] *65536 + [x size]
mov ecx,5*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,0x5577cc ; button color RRGGBB
int 0x40
 
 
mov eax,4 ; 4 = write text
mov ebx,8*65536+8
mov ecx,dword 0x00ffffff ; 8b window nro - RR GG BB color
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
mov eax,8
mov ebx,10*65536+200 ; button start x & size
mov ecx,40 *65536+17 ; button start y & size
mov edx,2 ; button number
mov esi,0x4060b0 ; button color
int 0x40
 
mov eax,8
mov ebx,10*65536+200 ; button start x & size
mov ecx,60 *65536+17 ; button start y & size
mov edx,3 ; button number
mov esi,0x4060b0 ; button color
int 0x40
 
mov eax,dword 4
mov ebx,25*65536+45
mov ecx,dword 0xffffff
mov edx,buttont
mov esi,buttontlen-buttont
int 0x40
 
mov eax,dword 4
mov ebx,25*65536+65
mov ecx,dword 0xffffff
mov edx,buttont2
mov esi,buttontlen2-buttont2
int 0x40
 
mov eax,12 ; tell os about redraw end
mov ebx,2
int 0x40
 
popa
ret
 
 
noteout:
 
pusha
 
push ebx
push eax
 
mov eax,20
mov ebx,2
mov ecx,0x9f
int 0x40
mov eax,20
mov ebx,2
pop ecx
int 0x40
mov eax,20
mov ebx,2
pop ecx
int 0x40
 
cmp eax,0
jz noe2
 
call printerror
 
noe2:
 
popa
ret
 
printerror:
 
mov eax,dword 4
mov ebx,15*65536+85
mov ecx,0x000000
mov edx,error1
mov esi,errorlen1-error1
int 0x40
 
mov eax,dword 4
mov ebx,15*65536+95
mov ecx,0x000000
mov edx,error2
mov esi,errorlen2-error2
int 0x40
 
ret
 
 
; DATA AREA
 
 
labelt:
db 'MIDI TEST'
labellen:
 
buttont:
db 'PLAY A FEW NOTES'
buttontlen:
buttont2:
db 'RESET MIDI DEVICE'
buttontlen2:
 
error1:
db 'NO BASE DEFINED FOR MPU-401'
errorlen1:
 
error2:
db 'USE SETUP AND RESET MIDI DEVICE.'
errorlen2:
 
base db 0x0
 
 
I_END:
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/mixer/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm mixer.asm mixer
@pause
/programs/media/mixer/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm mixer.asm mixer
@pause
/programs/media/mixer/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/mixer/trunk/mixer.asm
0,0 → 1,491
 
;
; MIXER
;
; Compile with FASM
;
 
use32
 
org 0x0
db 'MENUET00' ; 8 byte id
dd 38 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x1000 ; reguired amount of memory
dd 0x1000
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,10 ; wait here for event
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
 
jmp still
 
red: ; redraw
call draw_window
 
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
 
jmp still
 
button: ; button
mov eax,17
int 0x40
 
cmp ah,1 ; button id=1 ?
jnz noclose
mov eax,-1 ; close this program
int 0x40
noclose:
 
cmp ah,101
jnz nochange
mov al,byte [usecard]
cld
inc al
and al,3
cmp al,0
jnz nozer
mov al,1
nozer:
mov byte [usecard],al
 
call drawusedcard
 
nochange:
 
cmp byte [usecard],byte 1
jz usesb16
 
cmp byte [usecard],byte 2
jnz nousesb16II
jmp usesb16II
nousesb16II:
 
cmp byte [usecard],byte 3
jnz nousewss
jmp usewss
nousewss:
 
 
 
; SOUND BLASTER 16
 
 
usesb16:
 
 
cld
 
mov al,20
cmp ah,al
jge nomain
 
mov ecx,0
cmp ah,12
jnz nomain12
mov ecx,3*16+3
nomain12:
cmp ah,13
jnz nomain13
mov ecx,7*16+7
nomain13:
cmp ah,14
jnz nomain14
mov ecx,11*16+11
nomain14:
cmp ah,15
jnz nomain15
mov ecx,15*16+15
nomain15:
 
mov eax,25
mov ebx,1
int 0x40
 
jmp still
 
nomain:
 
mov al,30
cmp ah,al
jge nocd
 
mov ecx,0
 
cmp ah,22
jnz nocd12
mov ecx,3*16+3
nocd12:
cmp ah,23
jnz nocd13
mov ecx,7*16+7
nocd13:
cmp ah,24
jnz nocd14
mov ecx,11*16+11
nocd14:
cmp ah,25
jnz nocd15
mov ecx,15*16+15
nocd15:
 
mov eax,25
mov ebx,2
int 0x40
 
jmp still
 
nocd:
 
 
jmp still
 
 
 
 
; SOUND BLASTER 16 II
 
usesb16II:
 
cld
 
mov al,20
cmp ah,al
jge IIwnomain
 
mov ecx,0
cmp ah,12
jnz IIwnomain12
mov ecx,50
IIwnomain12:
cmp ah,13
jnz IIwnomain13
mov ecx,150
IIwnomain13:
cmp ah,14
jnz IIwnomain14
mov ecx,200
IIwnomain14:
cmp ah,15
jnz IIwnomain15
mov ecx,255
IIwnomain15:
 
mov eax,28
mov ebx,1
int 0x40
 
jmp still
 
IIwnomain:
 
mov al,30
cmp ah,al
jge IIwnocd
 
mov ecx,0
 
cmp ah,22
jnz IIwnocd12
mov ecx,50
IIwnocd12:
cmp ah,23
jnz IIwnocd13
mov ecx,150
IIwnocd13:
cmp ah,24
jnz IIwnocd14
mov ecx,200
IIwnocd14:
cmp ah,25
jnz IIwnocd15
mov ecx,255
IIwnocd15:
 
mov eax,28
mov ebx,2
int 0x40
 
jmp still
 
IIwnocd:
 
 
jmp still
 
 
 
 
 
 
 
 
 
; WINDOWS SOUND SYSTEM
 
usewss:
 
cld
 
mov al,20
cmp ah,al
jge wnomain
 
mov ecx,255
cmp ah,12
jnz wnomain12
mov ecx,200
wnomain12:
cmp ah,13
jnz wnomain13
mov ecx,150
wnomain13:
cmp ah,14
jnz wnomain14
mov ecx,70
wnomain14:
cmp ah,15
jnz wnomain15
mov ecx,0
wnomain15:
 
mov eax,27
mov ebx,1
int 0x40
 
jmp still
 
wnomain:
 
mov al,30
cmp ah,al
jge wnocd
 
mov ecx,255
 
cmp ah,22
jnz wnocd12
mov ecx,200
wnocd12:
cmp ah,23
jnz wnocd13
mov ecx,150
wnocd13:
cmp ah,24
jnz wnocd14
mov ecx,70
wnocd14:
cmp ah,25
jnz wnocd15
mov ecx,0
wnocd15:
 
mov eax,27
mov ebx,2
int 0x40
 
jmp still
 
wnocd:
 
 
jmp still
 
 
 
 
; *********************************************
; ******* 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+195 ; [x start] *65536 + [x size]
mov ecx,100*65536+140 ; [y start] *65536 + [y size]
mov edx,[wcolor] ; color of work area RRGGBB
mov esi,0x8099bbff ; color of grab bar RRGGBB,8->color glide
mov edi,0x0099bbee ; 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
 
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw button
mov ebx,(195-19)*65536+12 ; [x start] *65536 + [x size]
mov ecx,5*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,0x22aacc ; button color RRGGBB
; int 0x40
 
mov edx,16 ; button id
mov ebx,10*65536
 
newbut:
 
push edx
push ebx
 
mov esi,[bcolor]
 
mov eax,8 ; function 8 : define and draw button
mov bx,22 ; [x start] *65536 + [x size]
mov ecx,35*65536+8 ; [y start] *65536 + [y size]
dec edx
int 0x40
mov eax,8 ; function 8 : define and draw button
mov bx,22 ; [x start] *65536 + [x size]
mov ecx,45*65536+8 ; [y start] *65536 + [y size]
dec edx
int 0x40
mov eax,8 ; function 8 : define and draw button
mov bx,22 ; [x start] *65536 + [x size]
mov ecx,55*65536+8 ; [y start] *65536 + [y size]
dec edx
int 0x40
mov eax,8 ; function 8 : define and draw button
mov bx,22 ; [x start] *65536 + [x size]
mov ecx,65*65536+8 ; [y start] *65536 + [y size]
dec edx
int 0x40
mov eax,8 ; function 8 : define and draw button
mov bx,22 ; [x start] *65536 + [x size]
mov ecx,75*65536+8 ; [y start] *65536 + [y size]
dec edx
int 0x40
 
pop ebx
pop edx
 
add ebx,30*65536
add edx,10
 
cmp edx,16+6*10
jz butdone
 
jmp newbut
 
butdone:
 
 
mov eax,4 ; function 4 : write text to window
mov ebx,10*65536+104 ; [x start] *65536 + [y start]
mov ecx,0x00ffffff ; color of text RRGGBB
mov edx,text ; pointer to text beginning
mov esi,29
int 0x40
 
mov eax,8 ; function 8 : define and draw button
mov ebx,(5)*65536+185 ; [x start] *65536 + [x size]
mov ecx,120*65536+14 ; [y start] *65536 + [y size]
mov edx,101 ; button id
mov esi,[bcolor] ; button color RRGGBB
int 0x40
 
call drawusedcard
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
drawusedcard:
 
pusha
 
mov eax,13
mov ebx,14*65536+160
mov ecx,123*65536+10
mov edx,[bcolor]
int 0x40
 
mov eax,[usecard]
mov edx,c3
 
cmp al,1
jnz nosbc
mov edx,c1
nosbc:
cmp al,2
jnz nosbcII
mov edx,c2
nosbcII:
cmp al,3
jnz nowssc
mov edx,c3
nowssc:
 
mov eax,4
mov ebx,14*65536+123
mov ecx,0x00ffffff
mov esi,30
int 0x40
 
popa
 
ret
 
 
 
; DATA AREA
 
bcolor dd 0x5577c8
 
wcolor dd 0x03000000
 
 
text:
db 'MAIN CD WAVE MPU4 AUX1 AUX2'
 
c1 db 'SOUND BLASTER 16 - MIXER I '
c2 db 'SOUND BLASTER 16 - MIXER II '
c3 db 'WINDOWS SOUND SYSTEM '
 
 
usecard dd 0x1
 
labelt:
db 'MIXER'
labellen:
 
I_END:
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/mp3s/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm mp3s.asm mp3s
@pause
/programs/media/mp3s/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm mp3s.asm mp3s
@pause
/programs/media/mp3s/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/mp3s/trunk/mp3s.asm
0,0 → 1,791
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Tiny MP3 Shoutcast Server v0.1 (vt) ;
; ;
; Compile with FASM for Menuet ;
; ;
; Listening to port 8008 ;
; Connect with eg: 192.168.1.22:8008 ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
version equ '0.3'
 
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; program start
dd I_END ; program image size
dd 0x80000 ; memory usage
dd 0x20000 ; stack
dd 0,0
 
include 'lang.inc'
include 'macros.inc'
 
; 0x0+ program image
; 0x1ffff stack
; 0x20000 work area for file read
; 0x40000+ file send buffer ( 100 kb )
 
 
START: ; start of execution
 
mov [status],0
call clear_input
call draw_window ; at first, draw the window
 
still:
 
mov eax,23 ; wait here for event
mov ebx,2
int 0x40
 
call check_events
 
call check_connection_status
 
cmp [status],4
je start_transmission
 
jmp still
 
 
check_events:
 
cmp eax,1 ; redraw request ?
jz red
cmp eax,2 ; key in buffer ?
jz key
cmp eax,3 ; button in buffer ?
jz button
 
ret
 
red: ; redraw
call draw_window
ret
 
key:
mov eax,2 ; Just read it and ignore
int 0x40
ret
 
button: ; button
 
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; close
jne no_close
mov eax,-1
int 0x40
no_close:
 
cmp ah,2 ; button id=2 ?
jnz tst3
; open socket
mov eax,53
mov ebx,5
mov ecx,8008 ; local port # - http
mov edx,0 ; no remote port specified
mov esi,0 ; no remote ip specified
mov edi,0 ; PASSIVE open
int 0x40
mov [socket], eax
mov [posy],1
mov [posx],0
mov [read_on],1
call check_for_incoming_data
call draw_window
ret
tst3:
 
cmp ah,4
je close_socket
cmp ah,6
je close_socket
jmp no_socket_close
close_socket:
mov edx,eax
; Close socket
mov eax, 53
mov ebx, 8
mov ecx, [socket]
int 0x40
mov esp,0x1fff0
cmp dh,6
je read_string
jmp still
no_socket_close:
 
cmp ah,9
jne no_bps_add
add [bps],8*1000
call draw_window
ret
no_bps_add:
 
cmp ah,8
jne no_bps_sub
sub [bps],8*1000
call draw_window
ret
no_bps_sub:
 
 
ret
 
 
clear_input:
 
mov edi,input_text
mov eax,0
mov ecx,60*40
cld
rep stosb
 
ret
 
 
read_string:
 
mov [addr],dword filename
mov [ya],dword 95
 
mov edi,[addr]
mov eax,32
mov ecx,30
cld
rep stosb
 
call print_text
 
mov edi,[addr]
 
f11:
mov eax,10
int 0x40
cmp eax,2
jne read_done
mov eax,2
int 0x40
shr eax,8
cmp eax,13
je read_done
cmp eax,8
jnz nobsl
cmp edi,[addr]
jz f11
sub edi,1
mov [edi],byte 32
call print_text
jmp f11
nobsl:
cmp eax,dword 31
jbe f11
cmp eax,dword 95
jb keyok
sub eax,32
keyok:
mov [edi],al
 
call print_text
 
add edi,1
mov esi,[addr]
add esi,30
cmp esi,edi
jnz f11
 
read_done:
 
mov ecx,40
mov eax,0
cld
rep movsb
 
call print_text
 
jmp still
 
 
print_text:
 
pusha
 
mov eax,13
mov ebx,56*65536+30*6
mov ecx,[ya]
shl ecx,16
mov cx,8
mov edx,0xffffff
int 0x40
 
mov eax,4
mov edx,[addr]
mov ebx,56*65536
add ebx,[ya]
mov ecx,0x000000
mov esi,30
int 0x40
 
popa
ret
 
 
wait_for dd 0x0
 
transmission_start dd 0x0
sentbytes dd 0x0
 
start_transmission:
 
call clear_input
 
mov eax,5
mov ebx,50
int 0x40
 
call check_for_incoming_data
call draw_window
 
call send_header
 
mov [fileinfo+4],dword 0 ; start from beginning
mov [read_to],0x40000
mov [playpos],0x40000
 
mov ecx,1024 / 512
 
new_buffer:
 
mov eax,[read_to]
mov ebx,1
call read_file
 
loop new_buffer
 
 
newpart:
 
call check_connection_status
call draw_window
 
mov eax,26
mov ebx,9
int 0x40
mov [transmission_start],eax
mov [sentbytes],0
 
newblock:
 
mov eax,[read_to]
mov ebx,2
call read_file
 
wait_more:
 
mov eax,26
mov ebx,9
int 0x40
 
cmp eax,[wait_for]
jge nomw
 
mov eax,5
mov ebx,1
int 0x40
 
jmp wait_more
 
nomw:
 
add eax,2
mov [wait_for],eax
 
mov eax,11
int 0x40
call check_events
 
mov eax,53
mov ebx,255
mov ecx,103
int 0x40
 
cmp eax,0
jne wait_more
 
; write to socket
mov eax,53
mov ebx,7
mov ecx,[socket]
mov edx,[playadd]
mov esi,[playpos]
int 0x40
 
add [sentbytes],edx
 
mov esi,[playpos]
add esi,[playadd]
mov edi,0x40000
mov ecx,110000 / 4
cld
rep movsd
 
mov eax,[playadd]
sub [read_to],eax
 
call check_for_incoming_data
call show_progress
call check_rate
 
mov eax, 53
mov ebx, 6
mov ecx, [socket]
int 0x40
cmp eax,4
jne end_stream
 
cmp [read_to],0x40000
jge newblock
 
end_stream:
 
; Close socket
 
mov eax, 53
mov ebx, 8
mov ecx, [socket]
int 0x40
 
mov eax,5
mov ebx,5
int 0x40
 
; Open socket
 
mov eax,53
mov ebx,5
mov ecx,8008 ; local port # - http
mov edx,0 ; no remote port specified
mov esi,0 ; no remote ip specified
mov edi,0 ; PASSIVE open
int 0x40
mov [socket], eax
mov [posy],1
mov [posx],0
mov [read_on],0
 
call draw_window
 
jmp still
 
 
check_rate:
 
pusha
 
mov eax,[bps]
xor edx,edx
mov ebx,8*100
div ebx
shl eax,1
mov [playadd],eax
 
mov eax,26
mov ebx,9
int 0x40
 
sub eax,[transmission_start]
shr eax,1
 
imul eax,[playadd]
 
mov edx,0x00dd00
 
cmp [sentbytes],eax
jge sendok
 
sub eax,20000
cmp [sentbytes],eax ; a long buffer underrun correction
jge no_buffer_overrun ; actually leads to overrun
mov [sentbytes],eax
no_buffer_overrun:
 
add [playadd],150
mov edx,0xdd0000
 
sendok:
 
mov eax,13
mov ebx,320*65536+10
mov ecx,105*65536+10
int 0x40
 
mov eax,47
mov ebx,4*65536
mov ecx,[playadd]
mov edx,322*65536+106
mov esi,0x000000
; int 0x40
 
popa
 
ret
 
 
show_progress:
 
pusha
 
mov eax,13
mov ebx,236*65536+10*6
mov ecx,107*65536+8
mov edx,0xffffff
int 0x40
 
mov ecx,[fileinfo+4]
imul ecx,512
 
mov eax,47 ; file read
mov ebx,9*65536
mov edx,236*65536+107
mov esi,0x000000
int 0x40
 
popa
ret
 
 
playpos dd 0x100000
playadd dd 256000 / 8 / 100
 
 
send_header:
 
pusha
 
mov [playpos],0x40000
 
mov esi,fileinfo+5*4
mov edi,transname
mov ecx,30
cld
rep movsb
 
mov eax, 53
mov ebx, 7
mov ecx, [socket]
mov edx, headere-headers
mov esi, headers
int 0x40
 
popa
ret
 
 
read_file:
 
cmp [read_to],0x40000+2000
jg cache_ok
mov [read_on],1
cache_ok:
 
cmp [read_to],0x40000+95500
jg no_read_1
 
mov [fileinfo+12],eax
mov [fileinfo+8],ebx
 
mov eax,58
mov ebx,fileinfo
int 0x40
 
cmp eax,0
jne no_read_1
 
mov eax,[fileinfo+8]
add [fileinfo+4],eax
 
add [read_to],512*2
 
ret
 
no_read_1:
 
mov [read_on],0
 
ret
 
 
 
check_for_incoming_data:
 
pusha
 
mov eax, 53
mov ebx, 2
mov ecx, [socket]
int 0x40
 
cmp eax,0
je _ret_now
 
new_data:
 
mov eax, 53
mov ebx, 2
mov ecx, [socket]
int 0x40
 
cmp eax,0
je _ret
 
mov eax,53
mov ebx,3
mov ecx,[socket]
int 0x40
 
cmp bl,10
jne no_lf
inc [posy]
mov [posx],0
jmp new_data
no_lf:
 
cmp bl,20
jb new_data
 
inc [posx]
cmp [posx],60
jbe xok
inc [posy]
mov [posx],0
xok:
 
cmp [posy],12
jbe yok
mov [posy],1
yok:
 
mov eax,[posy]
imul eax,60
add eax,[posx]
 
mov [input_text+eax],bl
 
jmp new_data
 
_ret:
 
; call draw_window
 
_ret_now:
 
popa
ret
 
 
 
check_connection_status:
 
pusha
 
mov eax, 53
mov ebx, 6
mov ecx, [socket]
int 0x40
 
cmp eax,[status]
je .ccs_ret
mov [status],eax
add eax,48
mov [text+20],al
call draw_window
.ccs_ret:
 
popa
ret
 
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
pusha
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
mov eax,0 ; Draw Window
mov ebx,50*65536+410
mov ecx,100*65536+141
mov edx,0x03ffffff
mov esi,0x00405080
mov edi,0x00405080
int 0x40
 
mov eax,4 ; Window label
mov ebx,8*65536+8
mov ecx,0x10ffffff
mov edx,wls
mov esi,wle-wls
int 0x40
 
mov eax,8 ; Start server
mov ebx,(25)*65536+21
mov ecx,57*65536+10
mov edx,2
mov esi,0x409040
int 0x40 ; Stop server
mov eax,8
mov ebx,(25)*65536+21
mov ecx,69*65536+10
mov edx,4
mov esi,0x904040
int 0x40
 
mov esi,0x3366d0
 
mov eax,8 ; Enter filename
mov ebx,(25)*65536+21
mov ecx,93*65536+10
mov edx,6
int 0x40
mov eax,8 ; Decrease transfer rate
mov ebx,(25)*65536+10
mov ecx,105*65536+10
mov edx,8
int 0x40
mov eax,8 ; Increase transfer rate
mov ebx,(36)*65536+10
mov ecx,105*65536+10
mov edx,9
int 0x40
 
mov ebx,10*65536+35 ; draw info text
mov ecx,0x00000000
mov edx,text
mov esi,40
newline:
mov eax,4
int 0x40
add ebx,12
add edx,40
cmp [edx],byte 'x'
jnz newline
 
mov eax,4 ; Filename
mov ebx,56*65536+95
mov ecx,0x000000
mov edx,filename
mov esi,30
int 0x40
 
mov eax,[bps]
xor edx,edx
mov ebx,1000
div ebx
mov ecx,eax
 
mov eax,47
mov ebx,3*65536
mov edx,58*65536+107
mov esi,0x00000000
int 0x40
 
mov [input_text+0],dword 'RECE'
mov [input_text+4],dword 'IVED'
mov [input_text+8],dword ': '
 
mov ebx,230*65536+35 ; draw info text
mov ecx,0x00000000
mov edx,input_text
mov esi,28
mov edi,7
newline2:
mov eax,4
int 0x40
add ebx,10
add edx,60
dec edi
jnz newline2
 
mov eax,38
mov ebx,210*65536+210
mov ecx,22*65536+136
mov edx,0x6699cc ; 002288
int 0x40
 
mov eax,38
mov ebx,211*65536+211
mov ecx,22*65536+136
mov edx,0x336699 ; 002288
int 0x40
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
popa
 
ret
 
 
 
; DATA AREA
 
text:
db ' TCB status: 0 '
db ' '
db ' Activate - port 8008 '
db ' Stop server '
db ' '
db ' > '
db ' < > Kbps '
db 'x'; <- END MARKER, DONT DELETE
 
headers:
 
db 'ICY 200 OK',13,10
db 'icy-notice1:This stream requires Winamp or xmms',13,10
db 'icy-url:http://www.menuetos.org',13,10
db 'icy-pub: 1',13,10
db 'icy-name: Menuet Mp3 Shoutcast Radio ',version,' - '
transname:
db ' ',13,10,13,10
 
headere:
 
wls: db 'MP3 shoutcast server ',version
wle:
 
socket dd 0
status dd 0
 
posy dd 1
posx dd 0
 
read_on db 1
read_to dd 0
 
addr dd 0
ya dd 0
 
bps dd 128*1000
 
fileinfo: dd 0,0,0,0,0x20000
filename: db '/RD/1/MENUET.MP3',0
times 50 db 0
 
input_text:
 
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/mv/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm mv.asm mv
@pause
/programs/media/mv/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm mv.asm mv
@pause
/programs/media/mv/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/mv/trunk/mv.asm
0,0 → 1,996
; Picture browser by lisovin@26.ru
; Modified by Ivan Poddubny - v.0.3
; Compile with FASM for Menuet
 
;******************************************************************************
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 temp_area , 0x0 ; I_Param , I_Icon
include 'lang.inc'
include 'macros.inc'
;******************************************************************************
 
tmp_param dd 0
 
START: ; start of execution
 
; check for parameters
cmp dword [temp_area],'BOOT'
jne .no_boot
call load_image
call convert
call background
or eax,-1
int 0x40
.no_boot:
 
cmp byte [temp_area],0
jz .no_param
mov edi,string ; clear string
mov ecx,43*3 ; length of a string
xor eax,eax ; symbol <0>
cld
rep stosb
 
mov edi,temp_area ; look for <0> in temp_area
mov ecx,43*3+1 ; strlen
repne scasb
add edi,-temp_area ; get length of the string
dec edi
 
mov ecx,edi
mov esi,temp_area
mov edi,string
rep movsb ; copy string from temp_area to "string" (filename)
 
call draw_window
mov [tmp_param],0xdeadbeef
.no_param:
 
 
mov ecx,-1 ; get information about me
call getappinfo
 
mov edx,[process_info+30] ; ⥯¥àì ¢ edx ­ è ¨¤¥­â¨ä¨ª â®à
mov ecx,eax
 
@@:
call getappinfo
cmp edx,[process_info+30]
je @f ; ¥á«¨ ­ è PID ᮢ¯ « á PID à áᬠâਢ ¥¬®£® ¯à®æ¥áá , ¬ë ­ è«¨ ᥡï
dec ecx ; ¨­ ç¥ ᬮâਬ á«¥¤ãî騩 ¯à®æ¥áá
jne @b ; ¢®§¢à é ¥¬áï, ¥á«¨ ­¥ ¢á¥ ¯à®æ¥ááë à áᬮâ७ë
@@:
 
; ⥯¥àì ¢ ecx ­®¬¥à ¯à®æ¥áá 
mov [process],ecx
 
cmp [tmp_param],0xdeadbeef
jne @f
jmp kopen
@@:
 
call draw_window
 
still:
 
mov eax,10 ; wait here for event
int 0x40
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
 
jmp still
 
red:
bt [status],2
jnc @f
mov eax,18
mov ebx,3
mov ecx,[process]
int 0x40
btr [status],2
jmp still
@@:
call draw_window
jmp still
 
key: ; key
int 0x40
cmp ah,6
je kfile
cmp ah,15
je kopen
cmp ah,9
je kinfo
cmp ah,2
je kbgrd
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 nofile
kfile:
bt dword [status],0
jc still
bts dword [status],0
mov eax,51
mov ebx,1
mov ecx,thread1
mov edx,0x29fff0
int 0x40
jmp still
nofile:
cmp ah,3
jne noopen
 
kopen:
mov ecx,-1
call getappinfo
mov ebx,dword [I_END+42]
mov ecx,dword [I_END+46]
add ebx,10*65536-15
add ecx,50*65536-55
mov edx,0xffffff
mov eax,13
int 0x40
 
call load_image
 
open1:
cmp word [I_END],word 'BM'
jne still
call convert
call drawimage
jmp still
noopen:
 
cmp ah,4
jne noinfo
kinfo:
bt dword [status],1
jc still
bts dword [status],1
mov eax,51
mov ebx,1
mov ecx,thread2
mov edx,0x2afff0
int 0x40
jmp still
noinfo:
 
; “‘’€Ž‚ˆ’œ ”Ž
cmp ah,5
jne still
kbgrd:
bt dword [status],3
jc still
bts dword [status],3
mov eax,51
mov ebx,1
mov ecx,thread3
mov edx,0x2bfff0
int 0x40
jmp still
;call background
 
getappinfo:
mov eax,9
mov ebx,I_END
int 0x40
ret
 
 
load_image:
mov dword [fileinfo+8],1 ; how many blocks to read (1)
mov eax,58
mov ebx,fileinfo
int 0x40
cmp [I_END+2],dword 512 ; à §¬¥à ä ©«  (file size)
jbe open1
mov eax,[I_END+2]
shr eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
inc eax
 
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
ret
 
 
drawimage:
cmp word [I_END],word 'BM'
jne nodrawimage
mov eax,7
mov ebx,[soi]
mov ecx,[I_END+18]
shl ecx,16
add ecx,[I_END+22]
mov edx,10*65536+50
int 0x40
nodrawimage:
ret
 
; “‘’€Ž‚ˆ’œ ”Ž
background:
cmp word [I_END],word 'BM'
jne @f
mov eax,15
mov ebx,1
mov ecx,[I_END+18] ; è¨à¨­ 
mov edx,[I_END+22] ; ¢ëá®â 
int 0x40
 
mov esi, ecx
imul esi, edx
imul esi, 3
mov ebx,5
mov ecx,[soi]
xor edx,edx
;;; mov esi, ;640*480*3
int 0x40
 
dec ebx ;tile/stretch
mov ecx,dword [bgrmode]
int 0x40
 
dec ebx
int 0x40
@@:
ret
 
convert:
movzx eax,word [I_END+28]
mul dword [I_END+18]
mov ebx,32
div ebx
test edx,edx
je noaddword
inc eax
noaddword:
mov [dwps],eax ;dwps-doublewords per string
shl eax,2
mov [bps],eax ;bps-bytes per string
 
cmp dword [I_END+34],0
jne yespicsize ;if picture size is defined
mul dword [I_END+22]
mov dword [I_END+34],eax
 
yespicsize:
mov eax,I_END
push eax
add eax, [I_END+2];file size
inc eax
mov [soi],eax ;soi-start of image area for drawing
pop eax
add eax, [I_END+10]
mov [sop],eax ;sop-start of picture in file
add eax, [I_END+34]
mov [eop],eax ;eop-end of picture in file
mov eax, [I_END+18]
mov ebx,3
mul ebx ;3x pixels in eax
 
mov edi,[soi] ;initializing
mov esi,[eop]
sub esi,[bps]
 
 
nextstring:
push edi
cmp word [I_END+28],24
jne convertno32
 
mov ecx,[dwps]
cld
rep movsd
convert1:
pop edi
sub esi,[bps]
sub esi,[bps]
cmp esi,[sop]
jb nomorestring
add edi,eax
jmp nextstring
 
nomorestring:
ret
 
convertno32:
mov ebx,I_END
add ebx, [I_END+14]
add ebx,14 ;start of color table
push esi
add esi,[bps]
mov [eos],esi
pop esi
nextelem:
push eax
movzx eax,byte [esi]
cmp word [I_END+28],4
je convert4bpp
cmp word [I_END+28],1
je convert1bpp
call converttable
convert2:
pop eax
inc esi
cmp esi,[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, [eax]
mov dword [edi],edx
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
xor eax,eax ; function 0 : define and draw window
mov ebx,350 ; [x start] *65536 + [x size]
mov ecx,400 ; [y start] *65536 + [y size]
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl
int 0x40
 
mov eax,8
mov ebx,10*65536+46
mov ecx,25*65536+20
mov edx,2
mov esi,0x780078
newbutton:
int 0x40
add ebx,48*65536
inc edx
cmp edx,6
jb newbutton
 
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x10ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelt ; pointer to text beginning
mov esi,12 ; text length
int 0x40
 
mov ebx,14*65536+32
mov edx,buttext
mov esi,26
int 0x40
 
call drawimage
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
; DATA AREA
 
labelt:
db 'MeView v.0.3'
 
lsz buttext,\
en, ' FILE OPEN INFO BGRD',\
ru, ' ”€‰‹ Ž’Š ˆ”Ž ”Ž '
 
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
 
thread1: ; start of thread1
 
call draw_window1
 
still1:
 
mov eax,10 ; wait here for event
int 0x40
 
cmp eax,1 ; redraw request ?
je thread1
cmp eax,2 ; key in buffer ?
je key1
cmp eax,3 ; button in buffer ?
je button1
 
jmp still1
 
key1: ; key
int 0x40
cmp ah,179
jne noright
mov eax,[pos]
cmp eax,41
ja still1
inc eax
mov [pos],eax
call drawstring
jmp still1
noright:
cmp ah,176
jne noleft
mov eax,[pos]
test eax,eax
je still1
dec eax
mov [pos],eax
call drawstring
jmp still1
noleft:
cmp ah,182 ;del
jne nodelet
call shiftback
call drawstring
jmp still1
nodelet:
cmp ah,8 ;zaboy
jne noback
mov eax,[pos]
test eax,eax
je still1
dec eax
mov [pos],eax
call shiftback
call drawstring
jmp still1
noback:
cmp ah,13
jne noenter
enter1:
mov al,byte ' '
mov edi,string
mov ecx,43
cld
repne scasb
dec edi
mov byte [edi],0
jmp close1
noenter:
cmp ah,27
jne noesc
jmp enter1
noesc:
cmp dword [pos],42
jae still1
 
mov edi,string
add edi,42
mov esi,edi
dec esi
mov ecx,42
sub ecx,[pos]
std
rep movsb
 
shr eax,8
mov esi,string
add esi,[pos]
mov byte [esi],al
inc dword [pos]
call drawstring
 
jmp still1
 
button1: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne noclose1
jmp enter1
close1:
bts dword [status],2
btr dword [status],0
mov eax,-1 ; close this program
int 0x40
noclose1:
cmp ah,2
jne nosetcur
mov eax,37
mov ebx,1
int 0x40
shr eax,16
sub eax,21
xor edx,edx
mov ebx,6
div ebx
mov [pos],eax
call drawstring
jmp still1
nosetcur:
jmp still1
 
 
shiftback:
mov edi,string
add edi,[pos]
mov esi,edi
inc esi
mov ecx,43
sub ecx,[pos]
cld
rep movsb
ret
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window1:
 
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window
mov ebx,100*65536+300 ; [x start] *65536 + [x size]
mov ecx,100*65536+80 ; [y start] *65536 + [y size]
mov edx,0x03780078 ; color of work area RRGGBB,8->color gl
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,0x10ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelt1 ; pointer to text beginning
mov esi,4 ; text length
int 0x40
 
call drawstring
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
drawstring:
pusha
mov eax,8 ;invisible button
mov ebx,21*65536+258
mov ecx,40*65536+15
mov edx,0x40000002
int 0x40
 
mov eax,13 ;bar
mov edx,0xe0e0e0
int 0x40
push eax ;cursor
mov eax,6*65536
mul dword [pos]
add eax,21*65536+6
mov ebx,eax
pop eax
mov edx,0x6a73d0
int 0x40
mov eax,4 ;path
mov ebx,21*65536+44
xor ecx,ecx
mov edx,string
mov esi,43
int 0x40
 
 
popa
ret
 
; DATA AREA
 
lsz labelt1,\
en, 'File',\
ru, '” ©«'
 
pos: dd 6
fileinfo:
dd 0
dd 0
dd 1 ;number of blocks of 512 bytes
dd I_END
dd temp_area
string:
; db '/HARDDISK/FIRST/1/DICK.BMP '
db '/hd/1/menuet/pics/new.bmp '
db ' '
db ' '
 
thread2: ; start of info thread
 
call draw_window2
 
still2:
 
mov eax,10 ; wait here for event
int 0x40
 
cmp eax,1 ; redraw request ?
je thread2
cmp eax,2 ; key in buffer ?
je close2
cmp eax,3 ; button in buffer ?
je button2
 
jmp still2
 
button2: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne noclose2
close2:
btr dword [status],1
bts dword [status],2
mov eax,-1 ; close this program
int 0x40
noclose2:
 
jmp still2
 
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window2:
 
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window
mov ebx,100*65536+330 ; [x start] *65536 + [x size]
mov ecx,100*65536+90 ; [y start] *65536 + [y size]
mov edx,0x03780078 ; color of work area RRGGBB,8->color gl
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,0x10ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelt2 ; pointer to text beginning
mov esi,labelt2.size ; text length
int 0x40
 
mov ebx,10*65536+30
mov edx,string
mov esi,43
int 0x40
mov edx,fitext
mov esi,14
add ebx,70*65536+10
followstring:
int 0x40
add ebx,10
add edx,esi
cmp ebx,80*65536+70
jbe followstring
mov eax,47
mov edx,200*65536+40
mov esi,ecx
mov ecx, [I_END+2]
call digitcorrect
int 0x40
add edx,10
mov ecx, [I_END+18]
call digitcorrect
int 0x40
add edx,10
mov ecx, [I_END+22]
call digitcorrect
int 0x40
add edx,10
movzx ecx,word [I_END+28]
call digitcorrect
int 0x40
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
digitcorrect:
xor ebx,ebx
mov bh,6
cmp ecx,99999
ja c_end
dec bh
cmp ecx,9999
ja c_end
dec bh
cmp ecx,999
ja c_end
dec bh
cmp ecx,99
ja c_end
dec bh
cmp ecx,9
ja c_end
dec bh
c_end:
bswap ebx
ret
 
 
; DATA AREA
 
lsz labelt2,\
en, 'File info',\
ru, 'ˆ­ä®à¬ æ¨ï ® ä ©«¥'
 
lsz fitext,\
en, 'FILE SIZE ',\
en, 'X SIZE ',\
en, 'Y SIZE ',\
en, 'BITS PER PIXEL',\
\
ru, ' §¬¥à ä ©«  ',\
ru, '˜¨à¨­  ',\
ru, '‚ëá®â  ',\
ru, '¨â ­  ¯¨ªá¥« '
 
thread3: ; start of bgrd thread
 
call draw_window3
 
still3:
 
mov eax,10 ; wait here for event
int 0x40
 
cmp eax,1 ; redraw request ?
je thread3
cmp eax,2 ; key in buffer ?
je key3
cmp eax,3 ; button in buffer ?
je button3
 
jmp still3
 
key3:
int 0x40
cmp ah,27
je close3
cmp ah,13
je kok
cmp ah,178 ;up
jne nofup
cmp dword [bgrmode],1
je fdn
fup:
dec dword [bgrmode]
jmp flagcont
nofup:
cmp ah,177 ;down
jne still3
cmp dword [bgrmode],2
je fup
fdn:
inc dword [bgrmode]
jmp flagcont
 
 
button3: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne noclose3
close3:
btr dword [status],3
bts dword [status],2
mov eax,-1 ; close this program
int 0x40
noclose3:
cmp ah,4
jne nook
kok:
call background
jmp close3
nook:
cmp ah,2
jb still3
cmp ah,3
ja still3
dec ah
mov byte [bgrmode],ah
flagcont:
call drawflags
jmp still3
 
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window3:
 
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window
mov ebx,100*65536+200 ; [x start] *65536 + [x size]
mov ecx,100*65536+100 ; [y start] *65536 + [y size]
mov edx,0x03780078 ; color of work area RRGGBB,8->color gl
int 0x40
 
mov eax,8
mov ebx,70*65536+40
mov ecx,70*65536+20
mov edx,4
mov esi,0xac0000
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,0x10ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelt3 ; pointer to text beginning
mov esi,14 ; text length
int 0x40
add ebx,38*65536+20
mov ecx,0xddeeff
mov edx, bgrdtext
mov esi, bgrdtext.size
int 0x40
add ebx,40*65536+15
mov edx, tiled
mov esi, tiled.size
int 0x40
add ebx,15
mov edx, stretch
mov esi, stretch.size ;7
int 0x40
add ebx,18
mov edx, ok_btn
mov esi, ok_btn.size ;2
int 0x40
 
call drawflags
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
drawflags:
mov eax,8
mov ebx,70*65536+10
mov ecx,40*65536+10
mov edx,2
mov esi,0xe0e0e0
int 0x40
add ecx,15*65536
inc edx
int 0x40
mov eax,4
mov ebx,73*65536+42
xor ecx,ecx
mov edx,vflag
mov esi,1
cmp dword [bgrmode],1
je nodownflag
add ebx,15
nodownflag:
int 0x40
ret
 
 
; DATA AREA
vflag: db 'x'
bgrmode: dd 1
 
lsz labelt3,\
en, 'Background set',\
ru, "“áâ ­®¢ª  ä®­ "
 
lsz bgrdtext,\
en, 'SET AS BACKGROUND:',\
ru, '’¨¯ ®¡®¥¢:'
 
lsz tiled,\
en, 'TILED',\
ru, '§ ¬®áâ¨âì'
 
lsz stretch,\
en, 'STRETCH',\
ru, 'à áâï­ãâì'
 
lsz ok_btn,\
en, 'Ok',\
ru, 'Ok'
 
 
 
IM_END:
temp_area:
rb 0x10000
I_END:
process_info:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/sb/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm sb.asm sb
@pause
/programs/media/sb/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm sb.asm sb
@pause
/programs/media/sb/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/sb/trunk/sb.asm
0,0 → 1,1010
;
; SOUND BLASTER
;
; Compile with FASM for Menuet
;
 
include 'lang.inc'
include 'macros.inc'
 
use32
 
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01
dd START ; program start
dd I_END ; program image size
dd 0x80000 ; required amount of memory
dd 0xfff0 ; stack position
dd 0,0
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
vol_data dd 0x40000
playposition dd 0x20000
next_tic dd 0x0
onoff dd 0x0
pause_between_songs dd 100
delay dd 100
repeat_song db 0
mono_stereo dd 1
 
 
; 0x10000 data from hd
; 0x20000 play position for sb
; 0x40000 volume indicator data
 
 
START: ; start of execution
 
call draw_window ; at first, draw the window
 
mov eax,26
mov ebx,9
int 0x40
mov [next_tic],eax
 
still:
 
mov [delay],145
cmp [mono_stereo],2
jne no_stereo
mov [delay],73
no_stereo:
 
mov eax,55
mov ebx,2
mov ecx,0
mov edx,[mono_stereo]
int 0x40
 
mov eax,23 ; wait here for event
mov ebx,1
int 0x40
 
cmp eax,0
jne do_task
 
still2:
 
cmp [onoff],0
je still
 
mov eax,26
mov ebx,9
int 0x40
mov ebx,[next_tic]
cmp eax,ebx
jge play_wave_block
 
mov edi,[next_tic]
sub edi,eax
mov eax,[delay]
sub eax,edi
mov edi,eax
call draw_volume
 
jmp still
 
do_task:
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
 
cmp eax,16+4
jne no_irman
mov eax,42
mov ebx,4
int 0x40
dec [ir_count]
cmp bl,140
jne no_first
mov [ir_count],3
no_first:
cmp [ir_count],0
jne no_irman
call give_wav
cmp bl,215
je play
mov ah,4
;; cmp bl,55
;; je rev
mov ah,3
;;; cmp bl,183
;;; je rev
cmp bl,127
jne no_block_dec
add [block],65536/512*10
no_block_dec:
cmp bl,191
jne no_block_inc
sub [block],65536/512*10
no_block_inc:
jmp still
no_irman:
 
jmp still
 
play_wave_block:
 
mov eax,55 ; load wave
mov ebx,0
mov ecx,[playposition]
int 0x40
 
mov eax,55 ; play wave
mov ebx,1
int 0x40
 
mov eax,26
mov ebx,9
int 0x40
add eax,[delay]
mov [next_tic],eax
 
call draw_wave
call read_wav
 
jmp still
 
red: ; redraw
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still2
 
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,6
jne no_ir
call enable_ir
jmp still
no_ir:
 
cmp ah,7
jne no_file_name
call read_string
jmp still
no_file_name:
 
cmp ah,2 ; button id=2
jne noplay
play:
mov eax,[onoff]
not eax
and eax,1
mov [onoff],eax
mov [playposition],0x20000
mov [block],2
call read_header
call read_wav
; mov [next_tic],0
jmp still
 
noplay:
 
cmp ah,3
jb no_rev
cmp ah,4
jg no_rev
sub ah,3
shr eax,8
imul eax,4000
sub eax,2000
add [block],eax
cmp [block],0x0f000000
jb block_ok
mov [block],2
block_ok:
call display_progress
jmp still2
no_rev:
 
cmp ah,5 ; repeat song ?
jne no_repeat
mov al,[repeat_song]
inc al
and eax,1
mov [repeat_song],al
shl eax,2
mov eax,[repeat_text+eax]
mov [text+40*5+31],eax
call draw_window
jmp still
repeat_text: db 'OFF ON '
no_repeat:
 
 
cmp ah,1
jne noclose
cmp [infrared_enabled],1
jne no_dis
mov eax,45
mov ebx,1
mov ecx,4
int 0x40
mov eax,46
mov ebx,1
mov ecx,0x3f0
mov edx,0x3ff
int 0x40
no_dis:
mov eax,-1 ; close this program
int 0x40
noclose:
 
jmp still2
 
 
give_wav:
 
pusha
 
mov eax,55
mov ebx,0
mov ecx,0x20000
int 0x40
 
popa
ret
 
ir_count db 0x0
 
 
drop_rate dd 100
 
draw_volume:
 
; edi = tic to show
 
ret
 
pusha
 
add edi,[vol_data]
 
mov eax,[drop_rate]
cmp eax,2
jb no_drop
sub eax,2
no_drop:
mov [drop_rate],eax
 
movzx eax,byte [edi]
cmp eax,[drop_rate]
jge drop_ok
mov eax,[drop_rate]
mov [edi],al
jmp fixed_drop
drop_ok:
mov [drop_rate],eax
fixed_drop:
 
mov eax,13
mov ebx,320*65536+20
mov ecx,50*65536+1
movzx edx,byte [edi]
shr edx,1
mov esi,128
sub esi,edx
add ecx,esi
mov edx,0x00ff00
int 0x40
 
mov eax,13
mov ebx,320*65536+20
movzx edx,byte [edi]
shr edx,1
mov ecx,edx
add ecx,(50+128)*65536+1
shl edx,16
sub ecx,edx
mov edx,0xff0000
int 0x40
 
popa
 
ret
 
 
read_header:
 
pusha
 
mov dword [file_info+4],0 ; block to read
mov dword [file_info+8],1 ; blocks to read
mov dword [file_info+12],0x10000+1024 ; return data pointer
mov dword [file_info+16],0x60000 ; work area for os
 
mov eax,58
mov ebx,file_info
int 0x40
 
movzx eax,byte [0x10000+1024+12+10]
mov [channels],eax
movzx eax,byte [0x10000+1024+12+20]
mov [bytes_per_sample],eax
 
cmp [0x10000+1024],dword 'RIFF'
jne unknownformat
cmp [0x10000+1024+8],dword 'WAVE'
jne unknownformat
 
mov [addb],128
cmp [channels],1
je addb_ok
mov [addb],256
addb_ok:
cmp [bytes_per_sample],1
je addb_ok2
mov [addb],256
addb_ok2:
 
mov [bmul],256
cmp [addb],256
je bmok
mov [bmul],512
bmok:
 
cmp [bytes_per_sample],4
jne no16s
mov [addb],512 ;mono_stereo
mov ecx,[mono_stereo]
shr ecx,1
shr [addb],cl
mov [bmul],128 ;mono_stereo
shl [bmul],cl
no16s:
 
popa
 
ret
 
unknownformat:
 
mov [onoff],0
 
call display_progress
 
mov eax,13
mov ebx,190*65536+10
mov ecx,104*65536+10
mov edx,0xff0000
int 0x40
pusha
 
mov eax,5
mov ebx,[pause_between_songs]
int 0x40
 
popa
mov eax,13
mov edx,0x000000
int 0x40
 
popa
 
ret
 
 
 
channels dd 0x0 ; 1=mono, 2 stereo
bytes_per_sample dd 0x0 ; 1=8 2=2*8/16 4=16
 
buffer dd 0x20000
 
block dd 0x2
addb dd 256 ; 128 = mono 8 bit , 256 = stereo 8 bit/16 bit mono
bmul dd 0x0 ; 512 = mono 8 bit , 256 = stereo 8 bit/16 bit mono
 
file_size dd 100
 
current_play dd wavfile+40*0
 
 
read_wav:
 
pusha
 
new_file:
 
mov edx,[block]
 
newread:
 
mov dword [file_info+4],edx ; block to read
mov dword [file_info+8],1 ; blocks to read
mov dword [file_info+12],0x10000+1024 ; return data pointer
mov dword [file_info+16],0x60000 ; work area for os
 
mov eax,58
mov ebx,file_info
int 0x40
 
 
pusha
mov eax,11
int 0x40
cmp eax,1
jne no_wd
call draw_window
no_wd:
popa
 
pusha
mov eax,38
mov ebx,1*65536+128
mov ecx,71*65536+71
add ebx,25*65536+25
mov edx,0x555555
; int 0x40
mov eax,38
mov ebx,[esp+32-12]
and ebx,65536/512 -1
or ebx,1*65536
add ebx,25*65536+25
mov ecx,71*65536+71
mov edx,0x999999
; int 0x40
popa
 
cmp eax,0
je conp
 
movzx eax,byte [repeat_song]
inc eax
and eax,1
imul eax,40
mov [current_play],wavfile
play_ok:
 
mov [onoff],1
mov [playposition],0x20000
mov [block],20
 
mov eax,5
mov ebx,[pause_between_songs]
add ebx,[delay]
int 0x40
 
call read_header
 
cmp [onoff],0
je noplay2
cmp [repeat_song],0
je noplay2
 
call display_progress
 
jmp new_file
 
noplay2:
 
mov [onoff],0
mov [block],2
call display_progress
 
popa
ret
conp:
 
mov [file_size],ebx
 
mov esi,0x10000+1024 ; 8 bit stereo & 16 bit mono
mov edi,edx
sub edi,[block]
imul edi,[bmul]
add edi,[buffer]
mov ecx,512
 
movedata:
 
mov al,[esi+1]
 
cmp [bytes_per_sample],4 ; for 16 bit stereo
jne no_16_stereo
mov al,[esi+1]
add al,128
no_16_stereo:
 
cmp [bytes_per_sample],1 ; for 16 bit mono
je no_16_mono
cmp [channels],2
je no_16_mono
mov al,[esi+1]
add al,128
no_16_mono:
 
mov [edi],al
mov eax,[bytes_per_sample]
cmp [mono_stereo],1
je bps1
mov eax,[bytes_per_sample]
push ecx
mov ecx,[mono_stereo]
dec ecx
shr eax,cl
pop ecx
bps1:
add esi,eax ; 2;[bytes_per_sample] ; / mono_stereo
add edi,1
loop movedata
 
add edx,1
mov ecx,[block]
add ecx,[addb]
cmp edx,ecx
jbe newread
 
mov ecx,[addb]
add [block],ecx
 
call display_progress
 
rewr:
 
popa
 
call set_vol_data
 
ret
 
 
set_vol_data:
 
; ret
 
pusha
 
mov eax,65536
xor edx,edx
mov ebx,[delay]
div ebx
push eax
 
mov esi,[playposition]
mov edi,[vol_data]
mov ecx,[delay]
 
svd:
 
mov eax,0
mov edx,100
svd3:
movzx ebx,byte [esi]
cmp ebx,128
jge svd2
mov ebx,0
svd2:
sub ebx,128
shl ebx,1
 
cmp ebx,ebp
jbe svd4
mov edx,ebx
svd4:
 
inc esi
inc eax
cmp eax,[esp]
jb svd3
 
mov [edi],dl
inc edi
loop svd
 
pop eax
popa
 
ret
 
 
addr dd 0x0
ya dd 0x0
 
 
read_string:
 
mov [onoff],0
 
mov [addr],wavfile
mov [ya],30
 
mov edi,[addr]
mov al,'_'
mov ecx,32
rep stosb
 
call print_text
 
mov edi,[addr]
 
f11:
mov eax,10
int 0x40
cmp eax,2
jne read_done
mov eax,2
int 0x40
shr eax,8
cmp eax,13
je read_done
cmp eax,8
jnz nobsl
cmp edi,[addr]
jz f11
sub edi,1
mov [edi],byte '_'
call print_text
jmp f11
nobsl:
cmp eax,dword 31
jbe f11
cmp eax,dword 95
jb keyok
sub eax,32
keyok:
mov [edi],al
 
call print_text
 
add edi,1
mov esi,[addr]
add esi,32
cmp esi,edi
jnz f11
 
read_done:
 
mov ecx,[addr]
add ecx,38
sub ecx,edi
mov eax,0
cld
rep stosb
 
call print_text
 
ret
 
 
print_text:
 
display_progress:
 
pusha
 
mov eax,13 ; gray progress bar
mov ebx,25*65536+215
mov ecx,61*65536+8
mov edx,[border]
int 0x40
 
cmp [onoff],1
je yes_playing
mov [block],0
mov [file_size],100*512
yes_playing:
mov eax,[block] ; yellow progress bar
imul eax,214
xor edx,edx
mov ebx,[file_size]
shr ebx,9
or ebx,1
div ebx
mov ebx,eax
and ebx,0xff
mov eax,13
add ebx,25*65536
mov ecx,61*65536+1
mov edx,[drawp]
newbar:
int 0x40
add edx,0x101010
add ecx,1*65536
cmp ecx,65*65536
jb newbar
newbar2:
int 0x40
sub edx,0x101010
add ecx,1*65536
cmp ecx,69*65536
jb newbar2
 
 
mov eax,[block]
imul eax,214-30
xor edx,edx
mov ebx,[file_size]
shr ebx,9
or ebx,1
div ebx
mov ebx,eax
shl ebx,16
add ebx,25*65536+30
mov ecx,61*65536+9
mov edx,0xeeeeff
mov eax,13
mov edi,5
newb:
; int 0x40
add ebx,1*65536-2
add ecx,1*65536-2
sub edx,0x332211;3366aa
dec edi
jnz newb
 
 
noyellow:
 
mov esi,[current_play]
mov edi,now_playing
mov ecx,40
cld
rep movsb
 
mov eax,13
mov ebx,42*65536+33*6
mov ecx,114*65536+11
mov edx,0x000000
int 0x40
 
mov eax,4
mov ebx,42*65536+117
mov ecx,[textc]
mov edx,now_playing
mov esi,38
int 0x40
 
popa
 
ret
 
 
shape_window:
 
ret
 
pusha
 
mov eax,50
mov ebx,0
mov ecx,shape_reference
int 0x40
 
mov eax,50
mov ebx,1
mov ecx,4
int 0x40
 
popa
 
ret
 
 
shape_reference:
 
times 1 db 1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0
times 9 db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
 
infrared_enabled db 0x0
 
 
enable_ir:
 
pusha
 
mov eax,46
mov ebx,0
mov ecx,0x3f0
mov edx,0x3ff
int 0x40
 
mov eax,45
mov ebx,0
mov ecx,4
int 0x40
 
mov eax,40
mov ebx,10000b shl 16 + 111b
int 0x40
 
mov [infrared_enabled],1
 
popa
 
ret
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
pusha
 
inc [next_tic]
 
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+320 ; [x start] *65536 + [x size]
mov ecx,100*65536+140 ; [y start] *65536 + [y size]
mov edx,[bgr]
add edx,0x03000000 ; color of work area RRGGBB,8->color gl
mov esi,0x808844ee
mov edi,0x008844ee ; 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,0x10ffffff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
mov eax,8 ; START/STOP - id 2
mov ebx,24*65536+77
mov ecx,80*65536+16
mov edx,2
mov esi,[border]
int 0x40
 
inc edx ; << / >> - id 3 , 4
add ebx,86*65536-57
mov eax,8
int 0x40
inc edx
add ebx,24*65536
mov eax,8
int 0x40
 
mov eax,8 ; REPEAT
add ebx,29*65536+54
inc edx
int 0x40
 
mov eax,8 ; enable infrared
add ebx,98*65536-33
add ecx,10*65536+10
inc edx
int 0x40
 
pusha
mov eax,8
mov ebx,25*65536+9
mov ecx,115*65536+9
inc edx
int 0x40
popa
 
mov eax,4
shr ecx,16
mov bx,cx
add ebx,2*65536+4
mov ecx,0xffffff
mov edx,infrared_text
mov esi,10
int 0x40
add ebx,11
add edx,10
mov eax,4
int 0x40
 
mov ebx,25*65536+35 ; draw info text with function 4
mov ecx,[textc]
mov edx,text
mov esi,40
newline:
mov eax,4
int 0x40
add ebx,10
add edx,40
cmp [edx],byte 'x'
jne newline
 
call display_progress
 
call draw_wave
 
mov eax,12
mov ebx,2
int 0x40
 
popa
ret
 
 
 
 
draw_wave:
 
; ret
 
pusha
 
mov eax,13
mov ebx,260*65536+43
mov ecx,42*65536+32
mov edx,[border]
int 0x40
 
mov esi,[playposition]
mov ebx,260
npix:
mov eax,1
inc ebx
movzx ecx,byte [esi]
shr ecx,3
add ecx,42
mov edx,[drawc];0x2255aa
int 0x40
 
add esi,2
 
cmp ebx,300
jbe npix
 
popa
 
ret
 
 
; DATA AREA
 
infrared_text: db 'IRMAN INFRAR '
 
 
textc dd 0xffffff
bgr dd 0x00000000
drawc dd 0x2255aa
drawp dd 0x8011aa
border dd 0x5577aa
 
text:
db 'Define SB, HD & partition with setup '
db 'If clipping change "delay" in source '
db ' '
db ' '
db ' '
db ' START/STOP << >> REPEAT:OFF '
db 'x <- END MARKER, DONT DELETE '
now_playing:
db ' '
db 'xx '
 
file_info:
 
dd 0 ; read
dd 0
dd 0
dd 0
dd 0
 
wavfile:
db '/HD/1/MENUET/MUSIC/FILE7.WAV',0
db ' '
 
 
labelt:
db ' WAVE PLAYER : 8b Mono - 16b Stereo'
labellen:
 
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/scrshot/trunk/ascl.inc
0,0 → 1,933
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 savefile file_name,file_save_area,file_temp_area,fsize
{
local save,fileinfo,string ;,counter00
jmp save
;counter00 dd 0
fileinfo:
dd 1
dd 0
dd fsize ;counter00
dd file_save_area
dd file_temp_area
string:
db file_name,0
save:
;xor edi,edi
; sub edi,file_save_area ; calculate dump size
; mov edx,edi
;mov [counter00],edi
; mov dword [fileinfo+8],1 ; how many blocks to write (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
words2reg ebx,arg1,arg3
words2reg ecx,arg2,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 putlabel 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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/scrshot/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm scrshot.asm scrshot
@pause
/programs/media/scrshot/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm scrshot.asm scrshot
@pause
/programs/media/scrshot/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/scrshot/trunk/readme.txt
0,0 → 1,26
 
ScrShoot v.0.1b - Ôîòîãðàô ýêðàíà (ScreenShooter)
Àëãîðèòì çàïèñè áìï-ôàéëà âçÿò èç VSCREEN2, îäíàêî,
ýòà ïðîãðàììà íèêàê íå ïðèòåíäóåò íà îòíîøåíèå ê íåé, êàê ê ñåðü¸çíîé ïðîãðàììå.
Êîãäà-òî äàâíî ÿ óæå ïûòàëñÿ ïåðåäåëàòü vscreen, ÷òîáû ìîæíî áûëî èçìåíÿòü èìÿ
ñîõðàíÿåìîãî ôàéëà, îäíàêî îí íå ïîëó÷èë ðàñïðîñòðîíåíèÿ (èççà êðèâîñòè êîäà íàâåðíîå :)).
ScrShoot - ìàëåíüêàÿ ïðîãðàììêà (êîòîðàÿ çàíèìàåò äîñòàòî÷íî ÌÍÎÃÎ îïåðàòèâû), êîòîðàÿ
ïðè íàæàòèè íà êëàâèøó PrintScreen ñîõðàíÿåò ñíèìîê ýêðàíà, àâòîìàòè÷åñêè èçìåíÿåò èìÿ ôàéëà,
÷òî ïîçâîëÿåò äåëàòü äî 99 ñíèìêîâ. Ïðîãðàììà íå èìååò GUI, ïîýòîìó äàþ "êðàòêîå îïèñàíèå"
 
- [Print Screen] - ñîõðàíèòü ñíèìîê ýêðàíà íà '/hd/1/SCREEN##.BMP', ãäå ## - íîìåð ñíèìêà.
- ëåâûé [Alt] + [Print Screen] - ñîõðàíèòü ñíèìîê ýêðàíà íà '/rd/1/SCREEN##.BMP',
ãäå ## - íîìåð ñíèìêà.
- [Scroll Lock] - âûõîä èç ïðîãðàììû.
 
Èçâåñòíî ÷òî:
- âî âðåìÿ íàæàòèÿ êëàâèø ScrShoot äîëæåí áûòü àêòèâíûì (êòî íå ïîíÿë - ù¸ëêàåò íà êíîïå
[SCRSHOOT] íà ïàíåëè.)
- îäíî èçîáðàæåíèå çàïèñûâàåòñÿ íà ÆÄ äî 3õ ñåêóíä äëÿ 800õ600 è äî 5 ñåê.
äëÿ 1024õ768, òî åñòü åñëè âåì íàäî ñäåëàòü êó÷ó ñêðèíîâ
íàæèìàéòå íà ïðèíò ñêðèí íå ÷àùå 1 ðàçà â 3-5 ñåêóíä.
- ðàçðåøåíèå ýêðàíà íå äîëæíî ïðåâûøàòü 1024õ768, òàê êàê òîãäà çàïèñü áìïøíèêà çàéì¸ò
öåëóþ âå÷íîñòü, è ïàìÿòè áóäåò æðàòü ìíîãîâàòî. (íó ÿ êîíå÷íî êðàñêè ñãóñòèë, íî ýòî
âñ¸ æå òàê)
 
Ñèëüíûõ ãëþêîâ ÿ íå çàìåòèë, íî åñëè ÷òî - archangel{at}mail.kz
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/scrshot/trunk/scrshot.asm
0,0 → 1,232
;===[includes]===;
include 'lang.inc'
include 'ascl.inc'
include 'macros.inc'
;===[header and etc.]===;
meos_app_start
;===[code:]===;
code
;---------------------------------------
;====== we want keyborad events ========
mov eax,40
mov ebx,00000000000000000000000000000010b
int 0x40
 
;====== wanna use keyboard scan codes ==
mov eax,66
mov ebx,1
mov ecx,1
int 0x40
 
;=======GET SCREEN SIZE=================
 
mov eax,14 ; get screen size
int 0x40
push eax
and eax,0x0000ffff
inc eax
mov [size_y],eax
pop eax
shr eax,16
inc eax
mov [size_x],eax
 
mov eax,[size_x]
shr eax,2
mov [cmp_ecx],eax
 
mov eax,[size_x]
xor edx,edx
mov ebx,3
mul ebx
mov [add_esi],eax
 
mov eax,[size_y]
shr eax,2
mov [cmp_edx],eax
 
mov eax,[size_y]
imul eax,[size_x]
imul eax,3
mov [i_size],eax
 
;=======================================
 
still:
mov eax,10
int 0x40
cmp eax,2
je key
jmp still
 
key:
mov eax,2
int 0x40
cmp ah,55 ;===print screen to hdd
je print_screen_hdd
cmp ah,84 ;===alt+prnt.screen = print screen to fdd
je print_screen_fdd
cmp ah,70 ;===lets make exit - scroll lock
je close_now
jmp still
 
close_now:
close
;==================================
;===save file to hdd===============
print_screen_hdd:
mov [savetofdd],0
call change_fname
call save_screen
jmp still
;===save file to fdd===============
print_screen_fdd:
mov [savetofdd],1
call change_fname
call save_screen
jmp still
;===change our file name ==========
change_fname:
cmp [bmp_name+7],'9'
jne addfname
cmp [bmp_name+6],'9'
je leavenow ;if name is > than 'screen99.bmp' then we do not change name
mov [bmp_name+7],'0'
add [bmp_name+6],0x1
jmp leavenow
addfname:
add [bmp_name+7],0x1
leavenow:
ret
;==================================
 
;============SAVE SCREEN===========
read_pixel:
pushad
 
mov esi,eax
mov eax,[size_x]
mul ebx
add eax,esi
 
xchg eax,ebx
mov eax,35
int 0x40
mov [esp+28],eax
 
popad
ret
 
save_screen:
 
pusha
 
; 1) READ SCREEN
mov edi,bmp_file_area+0x36 ;0x10036
 
mov eax,[size_y]
dec eax
mov [temp_y],eax
 
ynew:
 
xor eax,eax
mov [temp_x],eax
 
xnew:
 
mov eax,[temp_x]
mov ebx,[temp_y]
call read_pixel
 
mov [edi],eax
add edi,3
 
inc [temp_x]
 
mov eax,[size_x]
cmp [temp_x],eax
jb xnew
 
dec [temp_y]
 
cmp [temp_y],0
jge ynew
 
; 2) BMP HEADER
 
mov [bmp_file_area],word 'BM' ; bmp signature
mov eax,[i_size]
mov [bmp_file_area+34],eax ; image size
mov ebx,0x36
mov [bmp_file_area+10],ebx ; headers size
add eax,ebx
mov [bmp_file_area+2],eax ; file size
mov [bmp_file_area+14],dword 0x28
mov eax,[size_x]
mov [bmp_file_area+18],eax ; x size
mov eax,[size_y]
mov [bmp_file_area+22],eax ; y size
mov [bmp_file_area+26],word 1
mov [bmp_file_area+28],word 0x18 ; bpp = 24 = 0x18
 
; 3) SAVE FILE
cmp [savetofdd],1
je save_to_fdd
mov eax,56
mov ebx,bmp_name
mov edx,bmp_file_area
mov ecx,[i_size]
add ecx,0x36
mov esi,path
int 0x40
popa
ret
 
save_to_fdd:
mov eax,33;
mov ebx,bmp_name
mov ecx,bmp_file_area
mov edx,[i_size]
add edx,0x36
mov esi,0
int 0x40
popa
ret
 
 
;=======================================
 
;---------------------------------------
;===[DATA]===;
data
;---------------------------------------
bmp_name db 'SCREEN00BMP'
path db 0
 
i_size dd 0x1
 
m_x dd 100
m_y dd 100
 
cmp_ecx dd 0
add_esi dd 0
cmp_edx dd 0
 
savetofdd db 0
 
;===[uninitialised data]===;
udata
;---------------------------------------
 
temp_x dd ?
temp_y dd ?
 
size_x dd ?
size_y dd ?
 
bmp_file_area:
rb 0x250000
 
;the happy end
meos_app_end
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/vscreen/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm vscreen.asm vscreen
@pause
/programs/media/vscreen/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm vscreen.asm vscreen
@pause
/programs/media/vscreen/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a { ; 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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/vscreen/trunk/vscreen.asm
0,0 → 1,417
;
; VIRTUAL SCREEN 2
; based on the original VSCREEN
;
; Compile with FASM for Menuet
;'
 
use32
 
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x600000 ; required amount of memory
dd 0xfff0
dd 0,0
 
scr equ 0x20000
 
include 'lang.inc'
include 'macros.inc'
 
START: ; start of execution
 
mov eax,14 ; get screen size
int 0x40
push eax
and eax,0x0000ffff
inc eax
mov [size_y],eax
pop eax
shr eax,16
inc eax
mov [size_x],eax
 
mov eax,[size_x]
shr eax,2
mov [cmp_ecx],eax
 
mov eax,[size_x]
xor edx,edx
mov ebx,3
mul ebx
mov [add_esi],eax
 
mov eax,[size_y]
shr eax,2
mov [cmp_edx],eax
 
mov eax,[size_y]
imul eax,[size_x]
imul eax,3
mov [i_size],eax
 
red:
call draw_window ; at first, draw the window
 
still:
 
call draw_screen
 
mov eax,23 ; wait here for event with timeout
mov ebx,[delay]
int 0x40
 
dec eax ; redraw request ?
jz red
dec eax ; key in buffer ?
jz key
dec eax ; button in buffer ?
jz button
 
jmp still
 
key: ; key
mov eax,2
int 0x40 ; just read it and ignore
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jnz noclose
exit:
or eax,-1 ; close this program
int 0x40
noclose:
 
cmp ah,2
jnz still
 
mov eax,51
xor ebx,ebx
inc ebx
mov ecx,thread_start
mov edx,0xe000
int 0x40
 
jmp exit
 
thread_start:
mov eax,5 ; wait for termination (1 sec.)
mov ebx,100
int 0x40
 
call save_screen
jmp exit ; exit thread
 
save_screen:
 
pusha
 
; mov eax,5
; mov ebx,500
; int 0x40
 
; xor ebx,ebx
; mov edi,0x10036 ;0x10000
; mov esi,edi ;0x10000
; add esi,[i_size]
 
; ss1:
 
; mov eax,35
; int 0x40
 
; inc ebx
 
; mov [edi],eax
; add edi,3
 
; cmp edi,esi
; jb ss1
 
; 1) READ SCREEN
mov edi,0x10036
 
mov eax,[size_y]
dec eax
mov [temp_y],eax
 
ynew:
 
xor eax,eax
mov [temp_x],eax
 
xnew:
 
mov eax,[temp_x]
mov ebx,[temp_y]
call read_pixel
 
mov [edi],eax
add edi,3
 
inc [temp_x]
 
mov eax,[size_x]
cmp [temp_x],eax
jb xnew
 
dec [temp_y]
 
cmp [temp_y],0
jge ynew
 
; 2) BMP HEADER
 
mov [0x10000],word 'BM' ; bmp signature
mov eax,[i_size]
mov [0x10000+34],eax ; image size
mov ebx,0x36
mov [0x10000+10],ebx ; headers size
add eax,ebx
mov [0x10000+2],eax ; file size
mov [0x10000+14],dword 0x28
mov eax,[size_x]
mov [0x10000+18],eax ; x size
mov eax,[size_y]
mov [0x10000+22],eax ; y size
mov [0x10000+26],word 1
mov [0x10000+28],word 0x18 ; bpp = 24 = 0x18
 
; 3) SAVE FILE
 
mov eax,56
mov ebx,filename
mov edx,0x10000
mov ecx,[i_size]
add ecx,0x36
mov esi,path
int 0x40
 
popa
ret
 
filename db 'SCREEN BMP'
path db 0
 
read_pixel:
pushad
 
mov esi,eax
mov eax,[size_x]
mul ebx
add eax,esi
 
xchg eax,ebx
mov eax,35
int 0x40
mov [esp+28],eax
 
popad
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
xor eax,eax ; function 0 : define and draw window
movzx ebx,word [size_x]
shr ebx,2
add ebx,100*65536+40
 
movzx ecx,word [size_y]
shr ecx,2
add ecx,100*65536+75
 
mov edx,0x027777dd ;82 ; color of work area RRGGBB
mov esi,0x807777dd ; color of grab bar RRGGBB,8->color gl
mov edi,0x007777dd ; 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,0x10ffffff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw button
mov ebx,[size_x]
shr ebx,2
add ebx,40-19
shl ebx,16
mov bx,12 ; [x start] *65536 + [x size]
mov ecx,5*65536+12 ; [y start] *65536 + [y size]
xor edx,edx ; button id
inc edx
mov esi,0x7777dd ; button color RRGGBB
int 0x40
 
; save image
mov ebx,20*65536
mov bx,word [size_x]
shr bx,2
mov cx,word [size_y]
shr cx,2
add cx,49
shl ecx,16
mov cx,12
mov edx,2
mov esi,0x4f4f9f
int 0x40
 
shr ecx,16
mov ebx,25*65536
mov bx,cx
add bx,3
mov eax,4
mov ecx,0xffffff
mov edx,savetext
mov esi,24 ;22
int 0x40
 
call draw_screen
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
draw_screen:
 
pusha
 
mov edi,scr
 
xor ecx,ecx
xor edx,edx
 
xor esi,esi
 
ds1:
 
mov eax,35
mov ebx,esi
int 0x40
stosd
dec edi
 
add esi,4
inc ecx
cmp ecx,[cmp_ecx] ; 800/4
jb ds1
 
add esi,[add_esi] ; 800*3
xor ecx,ecx
inc edx
cmp edx,[cmp_edx] ; 600/4
jb ds1
 
mov eax,7
mov ebx,scr
mov ecx,200*65536+160
mov ecx,[size_x]
shr ecx,2
shl ecx,16
mov cx,word [size_y]
shr cx,2
mov edx,20*65536+35
int 0x40
 
popa
 
ret
 
draw_magnify:
 
pusha
 
mov [m_x],dword 0x0
mov [m_y],dword 0x0
 
xor ecx,ecx
xor edx,edx
 
dm1:
 
push edx
mov eax,edx
mul [size_x]
pop edx
add eax,ecx
 
mov ebx,eax
mov eax,35
int 0x40
 
pusha
mov ebx,ecx
mov ecx,edx
shl ebx,3
add ebx,20
shl ebx,16
mov bx,8
shl ecx,3
add ecx,35
shl ecx,16
mov cx,8
 
mov edx,eax
mov eax,13
int 0x40
popa
 
inc ecx
cmp ecx,40
jnz dm1
xor ecx,ecx
inc edx
cmp edx,32
jnz dm1
 
popa
ret
 
; DATA AREA
 
i_size dd 0x1
 
m_x dd 100
m_y dd 100
 
cmp_ecx dd 0
add_esi dd 0
cmp_edx dd 0
 
delay dd 100
 
labelt:
db 'VIRTUAL SCREEN 2'
labellen:
 
savetext db 'SAVE AS /HD/1/SCREEN.BMP '
 
I_END:
 
temp_x dd ?
temp_y dd ?
 
size_x dd ?
size_y dd ?
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/xpaint/trunk/ascgl.inc
0,0 → 1,1385
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Graphics
; Libary
;
; Ver 0.18 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 LoadImage
;0.02 SetBmp
;0.03 Bmptoimg, Setimg ~01.03.2004
;0.04 Bug deleted, copyimg ~03.05.2004
;0.05 fullimg, collimg ~05.05.2004
;0.06 getimg ~09.05.2004
;0.07 convbmp ~13.05.2004
;0.08 fps ~14.05.2004
;0.09 drawfbox ~03.06.2004
;0.10 all macros optimized by Halyavin A., add at ~07.06.2004
;0.11 many macros optimized by Halyavin A., add at ~30.08.2004
;0.12 bmptoimg ~07.09.2004
;0.13 imgtoimg ~08.09.2004
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
;0.15 giftoimg, giftoani ~10.09.2004
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
 
aframetoimg_use_count=0
macro aframetoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aframetoimg_use_count=aframetoimg_use_count+1
if aframetoimg_use_count = 1
 
jmp end_aframetoimg_proc
 
acolor dd 0
aframetoimg_proc:
;getout coord
mov [acolor],ebp
 
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aframetoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aframetoimg_proc
}
 
frametoimg_use_count=0
macro frametoimg img, x, y, canvas
{
local loo,loo2
frametoimg_use_count=frametoimg_use_count+1
if frametoimg_use_count = 1
 
jmp end_frametoimg_proc
 
frametoimg_proc:
;getout coord
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
 
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_frametoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call frametoimg_proc
}
 
 
aimgtoimg_use_count=0
macro aimgtoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aimgtoimg_use_count=aimgtoimg_use_count+1
if aimgtoimg_use_count = 1
 
jmp end_aimgtoimg_proc
 
acolor dd 0
aimgtoimg_proc:
;getout coord
mov [acolor],ebp
 
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
 
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aimgtoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aimgtoimg_proc
}
 
 
 
 
imgtoimg_use_count=0
macro imgtoimg img, x, y, canvas
{
local loo,loo2
imgtoimg_use_count=imgtoimg_use_count+1
if imgtoimg_use_count = 1
 
jmp end_imgtoimg_proc
imgtoimg_proc:
;getout coord
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_imgtoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call imgtoimg_proc
}
 
 
;DrawBox
macro drawfbox x,y,xs,ys,color
{
words2reg ebx,x,xs ;x*65536+xs
words2reg ecx,y,ys ;y*65536+ys
mov edx,color
mov eax,13
int 0x40
}
 
; FPS - Set Frame Per Second Display
fps_show_frequency=40
macro fps x,y,color,delcolor
{
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
local no_out_fps
jmp spdat
savetime dd 0
fps_cntr dd 0
fps dd 0
ttt dd 0
spdat:
get_time:
mov eax,3
int 0x40
cmp eax,[savetime]
jne new_time
inc [fps_cntr]
cmp dword [ttt],0
je out_fps
dec dword [ttt]
jmp no_out_fps
new_time:
mov [savetime],eax
mov ebx,[fps_cntr]
mov [fps],ebx
mov [fps_cntr],0
out_fps:
if ~(delcolor eq )
mov ebx,x*65536+36
mov ecx,y*65536+7
mov edx,delcolor
mov eax,13
int 0x40
end if
mov dword [ttt],fps_show_frequency
mov eax,47
mov ebx,6*65536
; mov bl,0
mov edx,x*65536+y
mov esi,color
mov ecx,[fps]
int 0x40
no_out_fps:
}
 
; COLLIMG - Collusion image's
_1dbounce_count=0;
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
{
local bounce,exit,anot,bc,nbc
mov esi,[img1_off] ;xs1
mov edi,[img2_off] ;ys2
mov eax,x1 ;
mov ebx,x2 ;
call _1dbounce
mov edx,ecx
mov esi,[img1_off+4] ;ys1
mov edi,[img2_off+4] ;ys2
mov eax,y1 ;
mov ebx,y2 ;
call _1dbounce
add edx,ecx
cmp edx,2
je bounce
mov otv,0
jmp exit
_1dbounce_count=_1dbounce_count+1
if _1dbounce_count = 1
_1dbounce:
cmp ebx,eax
jb anot
add eax,esi
cmp eax,ebx
jbe nbc
bc:
mov ecx,1
ret
anot:
add ebx,edi
cmp ebx,eax
ja bc
nbc:
xor ecx,ecx
ret
end if
bounce:
mov otv,1
exit:
}
 
macro rgbtobgr image
{
local loo
mov eax,[image]
mul dword [image+4]
mov ecx,eax
mov esi,image+8
; add esi,8
loo:
mov al,[esi]
mov bl,[esi+2]
mov [esi],bl
mov [esi+2],al
add esi,3
dec ecx
jnz loo
}
 
 
macro setimg x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
mov cx,[arg3]
shl ecx,16
add cx,[arg3+4]
; wordstoreg ecx,[arg3],[arg3+4]
words2reg edx, x , y ;arg1*65536+arg2
int 0x40
}
 
macro setframe x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
words2reg edx, x , y ;arg1*65536+arg2
add edx,dword [arg3]
mov ecx,dword [arg3+4]
int 0x40
}
 
 
macro getimg imgsrc,x,y,xs,ys,imgdest
{
local cyc
if xs eqtype 0
mov dword [imgdest],xs
else
mov eax,xs
mov dword [imgdest],eax
end if
if ys eqtype 0
mov dword [imgdest+4],ys
else
mov eax,ys
mov dword [imgdest+4],eax
end if
 
mov eax,dword [imgsrc] ;getx size
; lea ecx,[eax+2*eax]
mov ecx,eax
shl ecx,1
add ecx,eax
 
mov ebx,y
mul ebx
add eax,x
mov edx,ecx
lea eax,[eax+2*eax] ;eax=offset on imsrc
; mov ebp,eax
; shl eax,1
; add eax,ebp
 
mov ecx,xs
mov ebx,ys
 
mov edi,8+imgdest
lea esi,[eax+8+imgsrc]
; mov esi,eax
; add esi,8
; add esi,imgsrc
 
cld
cyc:
movsw
movsb
dec ecx
jne cyc
add esi,edx
mov ecx,xs
sub esi,ecx
sub esi,ecx
sub esi,ecx
dec ebx
jne cyc
}
 
macro copyimg img2_off,img1_off
{
mov eax,dword [img1_off]
mov ebx,dword [img1_off+4]
mul ebx
lea ecx,[eax+2*eax]
lea esi,[img1_off+8]
lea edi,[img2_off+8]
cld
rep movsb
}
 
macro fullimg img_off,xs,ys,color
{
local cop
mov eax,xs
mov ebx,ys
mov dword [img_off],eax
mov dword [img_off+4],ebx
mul ebx
lea ebp,[eax+2*eax]
mov esi,color
if color eqtype 0
mov ecx,color/65536
else
mov ecx,esi
shr ecx,16
end if
xor edi,edi
cop:
mov word [img_off+8+edi],si
add edi,2
mov byte [img_off+8+edi],cl
inc edi
cmp edi,ebp
jne cop
}
 
 
 
; number of frame in ecx
; callculatin offset of raw data
 
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame
{
local loo,setpic
mov ebp,num_of_frame ;ecx
mov esi,offset_of_animation;Image
loo:
cmp ebp,0
je setpic
movzx eax,word [esi+4]
movzx ebx,word [esi+6]
mul ebx ;dword [esi+4]
mov ebx,3
mul ebx
add eax,8
add esi,eax
dec ebp
jmp loo
setpic:
mov dword offset_of_frame,esi
}
 
 
; BMPTOIMG -Convert BMP format TO IMG format
; (SYNTAX) BMPTOIMG BMP_source_offset,IMG_dest_ofset
; (SAMPLE) View BMPLS.ASM sample.
; ( NOTE ) This is macros is not brake bmp structure! Tested in 32,8,4 bits
 
 
bmptoimg_data_area_count=0
macro bmptoimg bmp_load_area,img_dest_area
{
local fileinfo,string,end_bmp,nodix
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
;local qwe,bmpfn
 
; convert:
movzx eax,word [bmp_load_area+28]
mul dword [bmp_load_area+18]
add eax,31
shr eax,5
mov dword [bmptoimg_data_area_dwps],eax ;dwps-doublewords per string
shl eax,2
mov dword [bmptoimg_data_area_bps],eax ;bps-bytes per string
 
cmp dword [bmp_load_area+34],0
jne yespicsize ;if picture size is defined
mul dword [bmp_load_area+22]
mov dword [bmp_load_area+34],eax
 
yespicsize:
mov ebp,img_dest_area+8
 
mov eax,bmp_load_area
mov ebx,eax
add ebx, [bmp_load_area+2];file size
inc ebx
mov dword [bmptoimg_soi],ebx ;soi-start of image area for drawing
 
add eax, [bmp_load_area+10]
mov dword [bmptoimg_data_area_sop],eax ;sop-start of picture in file
add eax, [bmp_load_area+34]
mov dword [bmptoimg_data_area_eop],eax ;eop-end of picture in file
mov eax, [bmp_load_area+18]
lea eax,[eax+2*eax] ;3x pixels in eax
 
mov edi,dword [bmptoimg_soi] ;initializing
mov esi,dword [bmptoimg_data_area_eop]
sub esi,dword [bmptoimg_data_area_bps]
 
 
nextstring:
push edi
push ebp
cmp word [bmp_load_area+28],24
jne convertno32
 
mov edi,ebp
mov ecx,[bmptoimg_data_area_dwps]
cld
rep movsd
 
convert1:
pop ebp
pop edi
sub esi,dword [bmptoimg_data_area_bps]
sub esi,dword [bmptoimg_data_area_bps]
cmp esi,dword [bmptoimg_data_area_sop]
jb end_bmp
add edi,eax
add ebp,eax
jmp nextstring
 
convertno32:
mov ebx,bmp_load_area
add ebx, [bmp_load_area+14]
add ebx,14 ;start of color table
push esi
add esi,dword [bmptoimg_data_area_bps]
mov dword [bmptoimg_data_area_eos],esi
pop esi
nextelem:
push eax
movzx eax,byte [esi]
cmp word [bmp_load_area+28],4
je convert4bpp
cmp word [bmp_load_area+28],1
je convert1bpp
call converttable
 
convert2:
pop eax
inc esi
cmp esi,dword [bmptoimg_data_area_eos]
jae convert1
add edi,3
 
add ebp,3
 
jmp nextelem
 
convert4bpp:
shl ax,4
shr al,4
push ax
movzx eax,ah
call converttable
add edi,3
 
add ebp,3
 
pop ax
movzx eax,al
call converttable
jmp convert2
 
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
push edx
call converttable
pop edx
dec edx
js convert2
add edi,3
 
add ebp,3
 
jmp nextbit
 
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
; mov dword [edi],edx
mov [ebp],edx
ret
 
bmptoimg_data_area_count=bmptoimg_data_area_count+1
if bmptoimg_data_area_count = 1
; DATA AREA
bmptoimg_soi dd 0
bmptoimg_data_area_bps dd 0
bmptoimg_data_area_dwps dd 0
bmptoimg_data_area_sop dd 0
bmptoimg_data_area_eop dd 0
bmptoimg_data_area_eos dd 0
end if
 
end_bmp:
mov eax,dword [bmp_load_area+18]
mov ebx,dword [bmp_load_area+22]
mov dword [img_dest_area],eax
mov dword [img_dest_area+4],ebx
}
 
; For convert RGB to BGR
COLOR_ORDER equ MENUETOS
 
macro giftoani gifsrc,imgsrc,num_of_frames
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null equ 0x1000 ; 0x1000
 
; jmp sss
; if defined gif_hash_offset
; else
; hasharea:
; times 4096 dd 0 ;4096
; end if
;sss:
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
push ecx
pop dword num_of_frames
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
movsd
movsd
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
cmp byte[edi],0x3b ;read next frame
jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
 
 
macro giftoimg gifsrc,imgsrc
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null equ 0x1000 ; 0x1000
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
; movsd
; movsd
 
mov bp,word[esi+4]
movzx ebx,bp
mov [edi],ebx
 
mov bp,word[esi+6]
movzx ebx,bp
mov [edi+4],ebx
 
add edi,8
add esi,8
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
; cmp byte[edi],0x3b ;read next frame
; jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/xpaint/trunk/ascgml.inc
0,0 → 1,49
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; GaMe
; Libary
;
; Ver 0.03 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 correct
;0.02 control ~14.05.2004
;0.03 all macros optimized by halyavin, add at ~07.06.2004
 
 
; corectiryemoe,corectnoe,step
macro correct arg1,arg2,arg3
{
local plus,minus,equal
mov eax,arg2
cmp arg1,eax
je equal
mov eax,arg3
ja minus
plus:
add arg1,eax
jmp equal
minus:
sub arg1,eax
equal:
}
 
macro control min,max,arg
{
local gr,low,norm
mov eax,max
cmp arg,eax
jg gr
mov eax,min
cmp arg,eax
jnl norm
gr:
low:
mov arg,eax
norm:
}
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/xpaint/trunk/ascl.inc
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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/xpaint/trunk/ascml.inc
0,0 → 1,93
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Massive operation
; Libary
;
; Ver 0.1 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 readmas,compmas,findmas
 
macro readmas masoff,obroff
{
local loo
mov edi,masoff
add edi,8
mov ebp,[masoff] ;elements
mov edx,[masoff+4] ;elemsize
mov eax,0 ;count
loo:
pushad
call obroff
popad
add edi,edx
inc eax
cmp eax,ebp
jne loo
}
 
macro compmas masoff1,masoff2,obroff
{
local loo,loo2
mov esi,masoff2
add esi,8
mov ecx,[masoff2]
mov ebx,[masoff2+4]
mov eax,0
 
loo2:
push eax
 
mov edi,masoff1
add edi,8
mov ebp,[masoff1] ;elements1
mov edx,[masoff1+4] ;elemsize1
mov eax,0 ;count
loo:
pushad
call obroff
popad
add edi,edx
inc eax
cmp eax,ebp
jne loo
 
add esi,ebx
pop eax
inc eax
cmp eax,ecx
jne loo2
}
 
 
macro findmas masoff,obroff
{
local loo,looend,lend
mov edi,masoff
add edi,8
mov ebp,[masoff] ;elements
mov edx,[masoff+4] ;elemsize
mov eax,0 ;count
loo:
pushad
mov eax,0
call obroff
cmp eax,1
je looend
popad
add edi,edx
inc eax
cmp eax,ebp
jne loo
stc
jmp lend
looend:
popad
clc
lend:
}
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/xpaint/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm xpaint.asm xpaint
@pause
/programs/media/xpaint/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm xpaint.asm xpaint
@pause
/programs/media/xpaint/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a { ; 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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/media/xpaint/trunk/xpaint.asm
0,0 → 1,1706
;
; Show Mini Sample by Pavlushin Evgeni for ASCL
; www.waptap@mail.ru
;
 
;bits brushes(right mouse button)!
;resize pucture(cross buttons)!
;Open BMP MIA MHI grafic files!
;Save as MIA MHI(zip from MHC -70% size)!
;Support full files 800*600
;Open and save dialogs is work!
 
; 27Ver Gif load support
; 28Ver Dialogs is work
 
;******************************************************************************
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd IM_END ; size of image
dd I_END ; memory for app
dd I_END ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
;******************************************************************************
include 'lang.inc'
include 'macros.inc'
include 'ascl.inc'
include 'ascgl.inc'
 
hashtable equ MHC_END
ifile equ MHC_END+65536*8 ;4
ofile equ (MHC_END+65536*8)+2000000 ;1000000
 
gif_hash_offset = ofile
 
START: ; start of execution
mov eax,40
mov ebx,0100111b
int 0x40
 
; clear picture color White
mov ecx,1024*768*3
mov eax,0xffffffff
mov edi,image_area
cld
rep stosb
 
call draw_window
call setbrush
 
rstill:
mov eax,37
mov ebx,1
int 0x40
mov ebx,eax
shr eax,16 ;x
and ebx,0xffff ;y
sub eax,5+6
sub ebx,22+30+6
 
cmp eax,640 ;for detect out of screen
ja still
cmp ebx,480
ja still
mov [xt],ebx
mov [yt],eax
 
still:
mov eax,40
mov ebx,0100111b
int 0x40
 
wtevent red,key,button
 
mov ebx,2
mov eax,37
int 0x40
cmp eax,1
je tescor ;if left button not pressed!
cmp eax,2
je cbr ;if right button pressed!
jmp rstill
; jmp still
 
cbr:
cmp dword [brush],9 ;9 brush matrix
jnae nocr
mov [brush],-1 ;0
nocr:
inc [brush]
call setbrush
jmp still
 
;Set brush
setbrush:
mov eax,[brush]
mov ebx,4*32
mul ebx
 
mov ecx,4*32
mov esi,brushtable
add esi,eax
mov edi,matrix
cld
rep movsb
 
delay 10
ret
 
tescor:
mov eax,37
mov ebx,1
int 0x40
mov ebx,eax
shr eax,16 ;x
and ebx,0xffff ;y
 
sub eax,5+6
sub ebx,22+30+6
 
push eax
push ebx
 
mov ecx,eax ;[yt]
mov edx,ebx ;[xt]
 
mov eax,[xt]
mov ebx,[yt]
pop [xt]
pop [yt]
 
call line
 
; mov [yt],eax
; mov [xt],ebx
call out_image
 
jmp still
 
red:
call draw_window
jmp still
 
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 noclose
mov eax,-1 ; close this program
int 0x40
noclose:
cmp ah,10
jb no_palbut
cmp ah,10+32;64
ja no_palbut
mov ecx,0
mov cl,ah
sub cl,10
shl ecx,2
mov ebx,[colortable+ecx]
mov [color],ebx
 
;Update color boxes
drawfbox 20,32,20,15,[backcolor]
drawfbox 12,28,20,15,[color]
 
jmp still
no_palbut:
 
cmp ah,6
jne no_left
 
mov esi,0
mov edi,0
mov ebp,[img_ysize]
x_pls:
mov ecx,0
mov edx,[img_xsize]
x_pl:
mov al,[image_area+edi+ecx]
mov [image_area+esi+ecx],al
mov al,[image_area+edi+ecx+1]
mov [image_area+esi+ecx+1],al
mov al,[image_area+edi+ecx+2]
mov [image_area+esi+ecx+2],al
add ecx,3
dec edx
jnz x_pl
add edi,[img_xsize]
add edi,[img_xsize]
add edi,[img_xsize]
add esi,[img_xsize]
add esi,[img_xsize]
add esi,[img_xsize]
sub esi,3
dec ebp
jns x_pls
 
dec [img_xsize]
jmp red
no_left:
 
 
cmp ah,7
jne no_right
 
mov eax,[img_xsize]
mul [img_ysize]
mov ebx,3
mul ebx
mov edi,eax
 
mov eax,[img_xsize]
inc eax
mul [img_ysize]
mov ebx,3
mul ebx
mov esi,eax
 
; mov esi,0
; mov edi,0
mov ebp,[img_ysize]
x_mns:
mov ecx,[img_xsize] ;0
add ecx,[img_xsize]
add ecx,[img_xsize]
mov edx,[img_xsize]
x_mn:
mov al,[image_area+edi+ecx]
mov [image_area+esi+ecx],al
mov al,[image_area+edi+ecx+1]
mov [image_area+esi+ecx+1],al
mov al,[image_area+edi+ecx+2]
mov [image_area+esi+ecx+2],al
sub ecx,3
dec edx
jnz x_mn
mov dword [image_area+esi+ecx+0],0xffffffff
sub edi,[img_xsize]
sub edi,[img_xsize]
sub edi,[img_xsize]
sub esi,[img_xsize]
sub esi,[img_xsize]
sub esi,[img_xsize]
sub esi,3
dec ebp
jns x_mns
 
inc [img_xsize]
jmp red
no_right:
 
cmp ah,8
jne no_up
dec [img_ysize]
jmp red
no_up:
 
cmp ah,9
jne no_down
inc [img_ysize]
jmp red
no_down:
 
;SAVE MIA
cmp ah,80
jne no_save
savedialog draw_window, mia_is_save, still, string
mia_is_save:
mov dword [fileinfo],1 ;write
mov eax,[img_xsize]
mul [img_ysize]
mov edx,eax
add edx,eax
add edx,eax
add edx,8
cmp edx,1024*768*3+20000
ja still
mov dword [fileinfo+12],image ;from read
mov dword [fileinfo+8],edx ;1
mov eax,58
mov ebx,fileinfo
int 0x40
; puttxt 20,4,string,40,cl_White
jmp still
no_save:
 
;OPEN MIA
cmp ah,81
jne no_open
opendialog draw_window, mia_is_open, still, string
mia_is_open:
mov dword [fileinfo],0 ;read
mov dword [fileinfo+12],image ;from read
mov dword [fileinfo+8],1
mov eax,58
mov ebx,fileinfo
int 0x40
mov eax,ebx
shr eax,9
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
; puttxt 20,4,string,40,cl_White
jmp red
no_open:
 
cmp ah,82
jne no_save_mhc
 
 
savedialog draw_window, mhi_is_save, still, string
mhi_is_save:
call fill_filebufs
mov eax,[img_xsize]
mul [img_ysize]
mov edx,eax
add edx,eax
add edx,eax
add edx,8
mov ecx,edx
mov esi,image
mov edi,ifile
cld
rep movsb
mov eax,edx
call compress
cmp edx,1024*768*3+20000
ja still
mov dword [fileinfo],1 ;write
mov dword [fileinfo+12],ofile ;from read
mov dword [fileinfo+8],edx ;1
mov eax,58
mov ebx,fileinfo
int 0x40
; puttxt 20,4,string,40,cl_White
jmp still
 
no_save_mhc:
 
;OPEN MHI
cmp ah,83
jne no_open_mhc
 
opendialog draw_window, mhi_is_open, still, string
mhi_is_open:
 
call fill_filebufs
 
mov dword [fileinfo],0 ;read
mov dword [fileinfo+12],ofile ;ofile for decompress
mov dword [fileinfo+8],1
mov eax,58
mov ebx,fileinfo
int 0x40
push ebx ;push file size
mov eax,ebx
shr eax,9
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
 
; puttxt 20,4,string,40,cl_White
; delay 100
pop eax ;pop file size
call decompress
 
mov ecx,edx
mov esi,ifile ;image
mov edi,image ;ifile
cld
rep movsb
 
jmp red
no_open_mhc:
 
cmp ah,84
jne no_save_bmp
jmp still
no_save_bmp:
 
cmp ah,85
jne no_open_bmp
 
opendialog draw_window, bmp_is_open, still, string
 
bmp_is_open:
mov dword [fileinfo],0 ;read
mov dword [fileinfo+12],MHC_END ;from read
 
mov dword [fileinfo+8],1
mov eax,58
mov ebx,fileinfo
int 0x40
mov eax,[MHC_END+2]
shr eax,9
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
 
; puttxt 20,4,string,40,cl_White
bmptoimg MHC_END,image
 
jmp red
 
no_open_bmp:
 
 
cmp ah,86
jne no_save_gif
jmp still
no_save_gif:
 
cmp ah,87
jne no_open_gif
 
opendialog draw_window, gif_is_open, still, string
 
gif_is_open:
mov dword [fileinfo],0 ;read
mov dword [fileinfo+12],MHC_END ;from read
 
mov dword [fileinfo+8],1
mov eax,58
mov ebx,fileinfo
int 0x40
mov eax,[MHC_END+2]
shr eax,9
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
 
puttxt 20,4,string,40,cl_White
giftoimg MHC_END,image
 
jmp red
 
no_open_gif:
 
 
 
cmp ah,100
jne nor1
 
mov eax,[img_xsize]
mul [img_ysize]
mov edx,eax
add edx,eax
add edx,eax
mov esi,image+8
norx:
mov al,byte [esi+2]
and al,01b ;10000000b
cmp al,0
jna xe
; mov al,255
mov byte [esi],0;255
mov byte [esi+1],0;0
mov byte [esi+2],255;0
jmp xa
xe:
mov byte [esi],255
mov byte [esi+1],255
mov byte [esi+2],255
xa:
add esi,3
cmp esi,edx
jnae norx
jmp red
nor1:
 
jmp still
 
fileinfo:
dd 0
dd 0
dd 1
dd MHC_END
dd out_image_area ;16384
string:
times 256 db 0
;times 256 db 0
;times 256 db 0
 
;filename db "IMAGE MIA"
;mhcfilename db "IMAGE MHI"
 
soi dd 0
pxs dd 0
pys dd 0
 
out_image:
mov eax,[prcinfo.x_size]
sub eax,21
cmp eax,[img_xsize] ;640
jna no_x
mov eax,[img_xsize] ;640
no_x:
mov [pxs],eax
mov eax,[prcinfo.y_size]
sub eax,68
cmp eax,[img_ysize] ;480
jna no_y
mov eax,[img_ysize] ;480
no_y:
mov [pys],eax
 
mov eax,[pxs]
cmp eax,[img_xsize] ;640
jne trans
mov eax,[pys]
cmp eax,[img_ysize] ;480
jne trans
 
mov eax,7
mov ebx,image_area
mov ecx,[pxs] ;640
shl ecx,16
add ecx,[pys] ;480
mov edx,(5+6)*65536+(22+6+30) ;+30 Reserve for buttons
int 0x40
ret
 
trans:
mov ebp,[pys]; 180
mov esi,image_area
mov edi,out_image_area
loox:
mov ecx,[pxs] ;200*3
add ecx,[pxs]
add ecx,[pxs]
cld
rep movsb
mov eax,[img_xsize] ;640
sub eax,[pxs]
add esi,eax
add esi,eax
add esi,eax
 
dec ebp
jnz loox
 
mov eax,7
mov ebx,out_image_area
mov ecx,[pxs]
shl ecx,16
add ecx,[pys]
 
mov edx,(5+6)*65536+(22+6+30) ;+30 Reserve for buttons
int 0x40
ret
 
 
;set put to massive
puti:
mov eax,edx
mov ebx,ecx
 
setput:
pushad
cmp eax,[img_xsize] ;640
jae nosetput
cmp ebx,[img_ysize] ;480
jae nosetput
mov edi,ebx
mov ebx,3 ;x*3
mul ebx
mov esi,eax
mov eax,[img_xsize] ;640*3 ;Y*640*3
add eax,[img_xsize]
add eax,[img_xsize]
mov ebx,edi
mul ebx
add eax,esi
 
mov ebp,[img_xsize]
shl ebp,4
add ebp,16
mov esi,ebp
add esi,ebp
add esi,ebp
 
sub eax,esi ;(16+640*16)*3
 
mov esi,0
mlix:
push eax
 
mov edi,[matrix+esi*4]
mloo:
shr edi,1
jnc nosp
; cmp eax,640*480*3 ;for detect out of screen
; jae nosp
push eax
mov eax,[img_xsize]
mul [img_ysize]
mov ebx,eax
add ebx,eax
add ebx,eax
pop eax
cmp eax,ebx
jae nosp
 
mov ebx,[color]
mov byte [image_area+eax],bl ;0x00ff
shr ebx,8
mov byte [image_area+eax+1],bl ;0x33
shr ebx,8
mov byte [image_area+eax+2],bl ;0x33
nosp:
add eax,3
cmp edi,0
jne mloo
 
pop eax
add eax,[img_xsize] ;640*3
add eax,[img_xsize]
add eax,[img_xsize]
inc esi
cmp esi,32
jnae mlix
 
nosetput:
popad
ret
 
matrix:
times 32 dd 0
 
brushtable:
;standart put
times 12 dd 0
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
times 12 dd 0
 
;put size 2
times 12 dd 0
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000011000000000000000b
dd 00000000000000011000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
times 12 dd 0
 
;put size 3
times 12 dd 0
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000111000000000000000b
dd 00000000000000111000000000000000b
dd 00000000000000111000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
times 12 dd 0
 
;put size 4
times 12 dd 0
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000111000000000000000b
dd 00000000000001111100000000000000b
dd 00000000000001111100000000000000b
dd 00000000000001111100000000000000b
dd 00000000000000111000000000000000b
dd 00000000000000000000000000000000b
times 12 dd 0
 
 
;put slash ld-ru
times 12 dd 0
dd 00000000000000000000000000000000b
dd 00000000000000000010000000000000b
dd 00000000000000000100000000000000b
dd 00000000000000001000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000100000000000000000b
dd 00000000000001000000000000000000b
dd 00000000000010000000000000000000b
times 12 dd 0
 
;put slash lu-rd
times 12 dd 0
dd 00000000000000000000000000000000b
dd 00000000000010000000000000000000b
dd 00000000000001000000000000000000b
dd 00000000000000100000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000001000000000000000b
dd 00000000000000000100000000000000b
dd 00000000000000000010000000000000b
times 12 dd 0
 
;pricel
times 8 dd 0
dd 00000000000000000000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000011111110000000000000b
dd 00000000000010010010000000000000b
dd 00000000000010000010000000000000b
dd 00000000111111010111111000000000b
dd 00000000000010000010000000000000b
dd 00000000000010010010000000000000b
dd 00000000000011111110000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000010000000000000000b
times 8 dd 0
 
;krest
times 12 dd 0
dd 00000000000000000000000000000000b
dd 00000000000010000010000000000000b
dd 00000000000001000100000000000000b
dd 00000000000000101000000000000000b
dd 00000000000000010000000000000000b
dd 00000000000000101000000000000000b
dd 00000000000001000100000000000000b
dd 00000000000010000010000000000000b
times 12 dd 0
 
;krest
times 12 dd 0
dd 00000000000000000000000000000000b
dd 00000000000010000010000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000000000000000000000000b
dd 00000000000010000010000000000000b
times 12 dd 0
 
 
;smile
times 8 dd 0
dd 00000111110000000000000b
dd 00011000001100000000000b
dd 00100000000010000000000b
dd 01000000000001000000000b
dd 01000000000001000000000b
dd 10001100011000100000000b
dd 10001100011000100000000b
dd 10000000000000100000000b
dd 10000000000000100000000b
dd 10010000000100100000000b
dd 01001000001001000000000b
dd 01000111110001000000000b
dd 00100000000010000000000b
dd 00011000001100000000000b
dd 00000111110000000000000b
dd 00000000000000000000000000000000b
times 8 dd 0
 
;round
dd 00000000000111111111100000000000b
dd 00000000011000000000011000000000b
dd 00000001100000000000000110000000b
dd 00000010000000000000000001000000b
dd 00000100000000000000000000100000b
dd 00001000000000000000000000010000b
dd 00010000000000000000000000001000b
dd 00100000000000000000000000000100b
dd 00100000000000000000000000000100b
dd 01000000000000000000000000000010b
dd 01000000000000000000000000000010b
dd 10000000000000000000000000000001b
dd 10000000000000000000000000000001b
dd 10000000000000000000000000000001b
dd 10000000000000000000000000000001b
dd 10000000000000000000000000000001b
dd 10000000000000000000000000000001b
dd 10000000000000000000000000000001b
dd 10000000000000000000000000000001b
dd 10000000000000000000000000000001b
dd 10000000000000000000000000000001b
dd 01000000000000000000000000000010b
dd 01000000000000000000000000000010b
dd 00100000000000000000000000000100b
dd 00100000000000000000000000000100b
dd 00010000000000000000000000001000b
dd 00001000000000000000000000010000b
dd 00000100000000000000000000100000b
dd 00000010000000000000000001000000b
dd 00000001100000000000000110000000b
dd 00000000011000000000011000000000b
dd 00000000000111111111100000000000b
 
 
;Draw line procedure
line:
jmp n
previous_X dw -1
previous_Y dw -1
X_increment dw -1
Y_increment dw -1
n:
push ax
push bx
push cx
push dx
pop cx ;yed
pop dx ;xed
pop [previous_Y]
pop [previous_X]
 
mov ax,cx
sub ax,[previous_X]
jns dx_pos
neg ax
mov [X_increment],1
jmp dx_neg
dx_pos: mov [X_increment],-1
dx_neg: mov bx,dx
sub bx,[previous_Y]
jns dy_pos
neg bx
mov [Y_increment],1
jmp dy_neg
dy_pos: mov [Y_increment],-1
dy_neg: shl ax,1
shl bx,1
pusha
call puti
popa
cmp ax,bx
jna dx_le_dy
mov di,ax
shr di,1
neg di
add di,bx
cycle:
cmp cx,[previous_X]
je exit_bres
cmp di,0
jl fractlt0
add dx,[Y_increment]
sub di,ax
fractlt0:
add cx,[X_increment]
add di,bx
pusha
call puti
popa
jmp cycle
dx_le_dy:
mov di,bx
shr di,1
neg di
add di,ax
cycle2:
cmp dx,[previous_Y]
je exit_bres
cmp di,0
jl fractlt02
add cx,[X_increment]
sub di,bx
fractlt02:
add dx,[Y_increment]
add di,ax
pusha
call puti
popa
jmp cycle2
exit_bres:
ret
 
 
draw_window:
startwd
window 40,40,(586+8),(380+24),window_Skinned+0x00ffffff
label 12,8,'2D EXAMPLE: ASCL XPAINT',cl_White+font_Big
 
; Get proc info
mov eax,9
mov ebx,prcinfo
mov ecx,-1
int 0x40
 
mov eax,[prcinfo.x_size]
mov ebp,[prcinfo.y_size]
sub eax,5+4
sub ebp,22+4
 
drawfbox 5,22,eax,ebp,0x00e0f0f4
; call out_image
 
; draw resize buttons
mov eax,8
mov ebx,(341)*65536+9
mov ecx,(22+6+6)*65536+6
mov edx,6 ;start with 6
mov esi,0x00aaaaaa
int 0x40
inc edx
add ebx,15*65536
int 0x40
mov ebx,(340+10)*65536+6
mov ecx,(22+6-2)*65536+8
inc edx
mov esi,0x00aaaaaa
int 0x40
inc edx
add ecx,14*65536
int 0x40
 
;Draw now and back color
drawfbox 20,32,20,15,[backcolor]
drawfbox 12,28,20,15,[color]
 
 
;Draw buttons color set
mov eax,8
mov ebx,(40+6)*65536+8
mov ecx,(22+6)*65536+8
mov edx,10 ;start with 10
mov edi,0
nextbut:
mov esi,dword [colorbuttable+edi*4]
int 0x40
add ecx,(10)*65536
inc edx
inc edi
mov esi,dword [colorbuttable+edi*4]
int 0x40
sub ecx,(10)*65536
add ebx,(10)*65536
inc edx
inc edi
cmp edi,32 ;64 buttons, 2 string of 32 buttons
jnae nextbut
 
;Save as not ziped image button
mov eax,8
mov ebx,(365+6)*65536+50
mov ecx,(22+6)*65536+8
mov edx,80 ;ID
mov esi,cl_Grey
int 0x40
 
label (365+7),(22+7),"SAVE MIA",cl_White
 
;Open not zipped image button
mov eax,8
mov ebx,(365+6)*65536+50
mov ecx,(36+6)*65536+8
mov edx,81 ;ID
mov esi,cl_Grey
int 0x40
 
label (365+7),(36+7),"OPEN MIA",cl_White
 
;Save as MHC ziped image button
mov eax,8
mov ebx,(420+6)*65536+50
mov ecx,(22+6)*65536+8
mov edx,82 ;ID
mov esi,cl_Grey
int 0x40
 
label (420+7),(22+7),"SAVE MHI",cl_White
 
;Open MHC zipped image button
mov eax,8
mov ebx,(420+6)*65536+50
mov ecx,(36+6)*65536+8
mov edx,83 ;ID
mov esi,cl_Grey
int 0x40
 
label (420+7),(36+7),"OPEN MHI",cl_White
 
;Save as Bitmap image button
mov eax,8
mov ebx,(475+6)*65536+50
mov ecx,(22+6)*65536+8
mov edx,84 ;ID
mov esi,cl_Grey
int 0x40
 
label (475+7),(22+7),"SAVE NOT",cl_White
 
;Open Bitmap image button
mov eax,8
mov ebx,(475+6)*65536+50
mov ecx,(36+6)*65536+8
mov edx,85 ;ID
mov esi,cl_Grey
int 0x40
 
label (475+7),(36+7),"OPEN BMP",cl_White
 
;Save as GIF image button
mov eax,8
mov ebx,(530+6)*65536+50
mov ecx,(22+6)*65536+8
mov edx,86 ;ID
mov esi,cl_Grey
int 0x40
 
label (530+7),(22+7),"SAVE NOT",cl_White
 
;Open GIF image button
mov eax,8
mov ebx,(530+6)*65536+50
mov ecx,(36+6)*65536+8
mov edx,87 ;ID
mov esi,cl_Grey
int 0x40
 
label (530+7),(36+7),"OPEN GIF",cl_White
 
;Draw filter buttons
mov eax,8
mov ebx,(590+6)*65536+6
mov ecx,(22+6)*65536+6
mov edx,100 ;start with 100
mov edi,0
nextfbut:
mov esi,0x00aa0000
int 0x40
add ecx,(8)*65536
inc edx
inc edi
mov esi,0x0000aa00
int 0x40
add ecx,(8)*65536
inc edx
inc edi
mov esi,0x000000aa
int 0x40
sub ecx,(8*2)*65536
add ebx,(8)*65536
inc edx
inc edi
cmp edi,8*3 ;24 buttons, 3 string of 8 buttons
jnae nextfbut
 
 
endwd
call out_image
ret
 
 
; Get from MHC Archiver by Nikita Lesnikov
; ======== compression/decompression engine ========
 
compress: ; File compression
 
compress_filefound:
 
jmp lzp_compress ; compress with order-2 LZP
compress_dumpdata:
 
ret
 
decompress: ; File decompression
 
decompress_filefound:
 
cmp byte [ofile],0 ; Invalid method!
jz right_method
mov edx,0 ;0 size
ret
 
right_method:
 
jmp lzp_decompress
decompress_dumpdata:
 
ret
 
fill_filebufs: ; Fill filebufs with garbage to simplify matching
pusha
cld
mov eax,0xF7D9A03F ; <- "magic number" :) just garbage...
mov ecx,2000000/2 ;4
mov edi,ifile
rep stosd
popa
ret
 
; ==== algorithms section ====
 
; Method 0: LZP compression algorithm
 
lzp_compress: ; EDX - how much bytes to dump
 
cld ; clear direction flag
 
mov esi,ifile ; init pointers
mov edi,ofile
 
push eax ; write header: ID0+4bfilesize => total 5 bytes
xor eax,eax
stosb
pop eax
stosd
 
pusha ; fill hash table
mov eax,ifile
mov edi,hashtable
mov ecx,65536*2 ;*1
rep stosd
popa
 
add eax,esi ; calculate endpointer
mov dword [endpointer],eax
 
movsw ; copy three bytes
movsb
 
mov dword [controlp],edi
inc edi
 
mov byte [controld],0
mov byte [controlb],0
 
c_loop:
cmp dword [endpointer],esi ; check end of file
ja c_loop_ok
jmp finish_c_loop
c_loop_ok:
 
call chash
call compare
jz two_match_c
 
lodsb
mov byte [literal],al
call chash
call compare
jz lit_match_c
 
mov al,0
call putbit
mov al,byte [literal]
stosb
movsb
jmp end_c_loop
 
lit_match_c:
mov al,1
call putbit
mov al,0
call putbit
mov al,byte [literal]
stosb
jmp encode_match
 
two_match_c:
mov al,1
call putbit
call putbit
 
encode_match:
call incpos
call compare
jz one_c
mov al,0
call putbit
jmp end_c_loop
one_c:
 
call incpos
mov al,1
call putbit
 
call compare
jnz ec1
call incpos
call compare
jnz ec2
call incpos
call compare
jnz ec3
call incpos
mov al,1
call putbit
call putbit
call compare
jnz ec4
call incpos
call compare
jnz ec5
call incpos
call compare
jnz ec6
call incpos
call compare
jnz ec7
call incpos
call compare
jnz ec8
call incpos
call compare
jnz ec9
call incpos
call compare
jnz ec10
call incpos
 
mov al,1
call putbit
call putbit
call putbit
xor ecx,ecx
 
match_loop_c:
cmp esi,dword [endpointer]
jae out_match_loop_c
call compare
jnz out_match_loop_c
inc ecx
call incpos
jmp match_loop_c
out_match_loop_c:
 
mov al,0xFF
out_lg:
cmp ecx,255
jb out_lg_out
stosb
sub ecx,255
jmp out_lg
out_lg_out:
mov al,cl
stosb
jmp end_c_loop
 
ec10:
mov al,1
call putbit
call putbit
mov al,0
call putbit
jmp end_c_loop
 
ec9:
mov al,1
call putbit
mov al,0
call putbit
mov al,1
call putbit
jmp end_c_loop
 
ec8:
mov al,1
call putbit
mov al,0
call putbit
call putbit
jmp end_c_loop
 
ec7:
mov al,0
call putbit
mov al,1
call putbit
call putbit
jmp end_c_loop
 
ec6:
mov al,0
call putbit
mov al,1
call putbit
mov al,0
call putbit
jmp end_c_loop
 
ec5:
mov al,0
call putbit
call putbit
mov al,1
call putbit
jmp end_c_loop
 
ec4:
mov al,0
call putbit
call putbit
call putbit
jmp end_c_loop
 
ec3:
mov al,1
call putbit
mov al,0
call putbit
jmp end_c_loop
 
ec2:
mov al,0
call putbit
mov al,1
call putbit
jmp end_c_loop
 
ec1:
mov al,0
call putbit
call putbit
 
end_c_loop:
jmp c_loop
 
finish_c_loop:
 
mov eax,dword [controlp] ; store last tagbyte
mov bl,byte [controld]
mov [eax], byte bl
 
sub edi,ofile ; calculate dump size
mov edx,edi
 
jmp compress_dumpdata
 
; LZP decompression algorithm
 
lzp_decompress: ; EDX - how much bytes to dump
 
cld
 
mov edi,ifile
mov esi,ofile+1
 
pusha ; fill hash table
mov eax,ifile
mov edi,hashtable
mov ecx,65536*2 ;*1
rep stosd
popa
 
lodsd
 
mov ebx,edi
add ebx,eax
mov dword [endpointer],ebx
 
movsw
movsb
 
lodsb
mov byte [controld],al
mov byte [controlb],0
 
d_loop:
cmp dword [endpointer],edi
ja d_loop_ok
jmp finish_d_loop
d_loop_ok:
 
call getbit
cmp al,0
jnz match_d
call dhash
movsb
call dhash
movsb
jmp end_d_loop
 
match_d:
 
call getbit
cmp al,0
jnz no_literal_before_match
call dhash
movsb
no_literal_before_match:
 
call dhash
mov ecx,1
call copymatch
 
call getbit
cmp al,0
jz end_d_loop
mov ecx,1
call copymatch
call getbit
cmp al,0
jz dc2
mov ecx,2
call copymatch
call getbit
cmp al,0
jz end_d_loop
mov ecx,1
call copymatch
call getbit
cmp al,0
jz dc4
mov ecx,4
call copymatch
call getbit
cmp al,0
jz dc5
call getbit
cmp al,0
jz dc6
mov ecx,3
call copymatch
 
do:
lodsb
xor ecx,ecx
mov cl,al
call copymatch
cmp al,0xFF
jnz end_do
jmp do
end_do:
jmp end_d_loop
 
dc6:
mov ecx,2
call copymatch
jmp end_d_loop
 
dc5:
call getbit
cmp al,0
jz ndc5
mov ecx,1
call copymatch
ndc5:
jmp end_d_loop
 
dc4:
call getbit
cmp al,0
jz ndc4
call getbit
mov ecx,3
cmp al,1
jz ndcc4
dec ecx
ndcc4:
call copymatch
jmp end_d_loop
ndc4:
call getbit
cmp al,0
jz ndccc4
mov ecx,1
call copymatch
ndccc4:
jmp end_d_loop
 
dc2:
call getbit
cmp al,0
jz ndc2
mov ecx,1
call copymatch
ndc2:
 
end_d_loop:
jmp d_loop
finish_d_loop:
 
mov edx, dword [ofile+1]
 
jmp decompress_dumpdata
 
; LZP subroutines
 
putbit: ; bit -> byte tag, AL holds bit for output
pusha
mov cl,byte [controlb]
shl al,cl
mov bl,byte [controld]
or bl,al
mov byte [controld],bl
inc cl
cmp cl,8
jnz just_increment
mov byte [controlb],0
mov byte [controld],0
push edi
mov edi, dword [controlp]
mov al,bl
stosb
pop edi
mov dword [controlp],edi
popa
inc edi
ret
just_increment:
mov byte [controlb],cl
popa
ret
 
getbit: ; tag byte -> bit, AL holds input
push ecx
mov al,byte [controld]
mov cl,byte [controlb]
shr al,cl
and al,1
inc cl
cmp cl,8
jnz just_increment_d
mov byte [controlb],0
push eax
lodsb
mov byte [controld],al
pop eax
pop ecx
ret
just_increment_d:
mov byte [controlb],cl
pop ecx
ret
 
chash: ; calculate hash -> mp -> fill position
pusha
xor eax,eax
mov al, byte [esi-1]
mov ah, byte [esi-2]
shl eax,2
add eax,hashtable
mov edx,dword [eax]
mov dword [mp],edx
mov dword [eax],esi
popa
ret
 
dhash: ; calculate hash -> mp -> fill position
pusha
xor eax,eax
mov al, byte [edi-1]
mov ah, byte [edi-2]
shl eax,2
add eax,hashtable
mov edx,dword [eax]
mov dword [mp],edx
mov dword [eax],edi
popa
ret
 
copymatch: ; ECX bytes from [mp] to [rp]
push esi
mov esi,dword [mp]
rep movsb
mov dword [mp],esi
pop esi
ret
 
compare: ; compare [mp] with [cpos]
push edi
push esi
mov edi,dword [mp]
cmpsb
pop esi
pop edi
ret
 
incpos:
inc dword [mp]
inc esi
ret
 
 
; LZP algorithm data
 
endpointer dd 0
controlp dd 0
controlb db 0
controld db 0
mp dd 0
literal db 0
 
; the end... - Nikita Lesnikov (nlo_one)
 
 
 
; DATA AREA
newline dd 0
xt dd 100
yt dd 100
counter dd 0
tsoi dd 0
view dd 0
brush dd 0
 
color dd 0x00000000
backcolor dd 0xffffff
 
colortable:
dd 0x00000000 ;black
dd 0x00FFFFFF ;white
dd 0x00808080 ;dark-gray
dd 0x00C0C0C0 ;gray
dd 0x00000080 ;dark-blue
dd 0x000000ff ;blue
dd 0x00400080 ;dark-violet
dd 0x008000ff ;violet
dd 0x00800080 ;dark-pink
dd 0x00ff00ff ;pink
dd 0x00800040 ;
dd 0x00ff0080 ;
dd 0x00800000 ;brown
dd 0x00ff0000 ;red
dd 0x00802000 ;
dd 0x00ff4000 ;dark-orange
dd 0x00804000 ;
dd 0x00ff8000 ;orange
dd 0x00804000 ;
dd 0x00ff8000 ;orange
dd 0x00808000 ;oliva
dd 0x00ffff00 ;yellow
dd 0x00608000 ;
dd 0x00C0ff00 ;
dd 0x00408000 ;green
dd 0x0080ff00 ;lime
dd 0x00008000 ;
dd 0x0000ff00 ;
dd 0x00008040 ;dark-salat
dd 0x0000ff80 ;salat
dd 0x00008080 ;dark-water
dd 0x0000ffff ;water
 
colorbuttable:
dd 0x001e1e1e ;black
dd 0x00dedede ;white
dd 0x00808080 ;dark-gray
dd 0x00C0C0C0 ;gray
dd 0x001e1e80 ;dark-blue
dd 0x001e1ede ;blue
dd 0x00401e80 ;dark-violet
dd 0x00801ede ;violet
dd 0x00801e80 ;dark-pink
dd 0x00de1ede ;pink
dd 0x00801e40 ;
dd 0x00de1e80 ;
dd 0x00801e1e ;brown
dd 0x00de1e1e ;red
dd 0x0080201e ;
dd 0x00de401e ;dark-orange
dd 0x0080401e ;
dd 0x00de801e ;orange
dd 0x0080401e ;
dd 0x00de801e ;orange
dd 0x0080801e ;oliva
dd 0x00dede1e ;yellow
dd 0x0060801e ;
dd 0x00C0de1e ;
dd 0x0040801e ;green
dd 0x0080de1e ;lime
dd 0x001e801e ;
dd 0x001ede1e ;
dd 0x001e8040 ;dark-salat
dd 0x001ede80 ;salat
dd 0x00008080 ;dark-water
dd 0x0000dede ;water
 
 
 
prcinfo process_information
 
;IM_END:
image:
img_xsize dd 200
img_ysize dd 180
IM_END:
image_area:
;rb 1024*768*3
 
out_image_area = image_area+(1024*768*3)
;rb 640*480*3
 
MHC_END = image_area+(1024*768*3)*2
I_END = MHC_END+6000000 ;6 megs for work mhc algorythm
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property