flat assembler
Message board for the users of flat assembler.

Index > Windows > Hilfe bei Sound , wer kann helfen !!

Author
Thread Post new topic Reply to topic
Harald2026



Joined: 13 Apr 2026
Posts: 4
Harald2026 23 Apr 2026, 07:45
Hallo, wie kann ich eine Info bekommen wenn der Sound zu ende ist ??
Wie kann man die Lautstärke regeln ??




format PE64 GUI 5.0 ;;https://board.flatassembler.net/
entry start

include 'win64a.inc'
include 'Myclude\ddraw64.inc'
section '.text' code readable executable

start:

sub rsp,8*5

and [DDraw],0
and [DDSPrimary],0
and [DDSBack],0

invoke GetModuleHandle,NULL
mov [hinstance],rax
mov [wc.hInstance],rax

invoke LoadIcon,[wc.hInstance],IDI_HARALD; ;IDI_APPLICATION
mov [wc.hIcon],rax
invoke LoadCursor,NULL,IDC_ARROW
mov [wc.hCursor],rax
invoke RegisterClassEx,wc
test rax,rax
jz startup_error

invoke CreateFileA, MeinBildSTR, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL
mov [hFile], rax
invoke GetFileSize, [hFile], NULL
mov [fileSize], rax ; assume high-dword zero
invoke VirtualAlloc,NULL, [fileSize], MEM_COMMIT or MEM_RESERVE, PAGE_READWRITE
mov [pBuffer], rax
invoke ReadFile, [hFile], [pBuffer], [fileSize], addr bytesRead, 0
invoke CloseHandle, [hFile]

invoke CreateWindowEx,\
0,_class,_title,WS_POPUP+WS_VISIBLE+SS_BITMAP,0,0,FensterdefX,FensterdefY,NULL,NULL,[hinstance], NULL
test rax,rax
jz startup_error ;dialogitem 'STATIC',IDR_LOGO,-1,4,4,248,20,WS_VISIBLE+SS_BITMAP
mov [hwnd],rax


invoke DirectDrawCreate,NULL,DDraw,NULL
test rax,rax
jnz ddraw_error

cominvk DDraw,SetCooperativeLevel,\
[hwnd],DDSCL_EXCLUSIVE+DDSCL_FULLSCREEN
test rax,rax
jnz ddraw_error

cominvk DDraw,SetDisplayMode,\
FensterdefX,FensterdefY,FensterdefBytePixel
test rax,rax
jnz ddraw_error

mov [ddsd.dwSize],sizeof.DDSURFACEDESC
mov [ddsd.dwFlags],DDSD_CAPS+DDSD_BACKBUFFERCOUNT
mov [ddsd.ddsCaps.dwCaps],DDSCAPS_PRIMARYSURFACE+DDSCAPS_FLIP+DDSCAPS_COMPLEX
mov [ddsd.dwBackBufferCount],1
cominvk DDraw,CreateSurface,\
ddsd,DDSPrimary,NULL
or eax,eax
jnz ddraw_error

mov [ddscaps.dwCaps],DDSCAPS_BACKBUFFER
cominvk DDSPrimary,GetAttachedSurface,\
ddscaps,DDSBack
or eax,eax
jnz ddraw_error
;**************************************
refresh:

cominvk DDSPrimary,IsLost
test rax,rax
jz paint
cmp eax,DDERR_SURFACELOST
jne end_loop
cominvk DDSPrimary,Restore

paint:

mov [ddscaps.dwCaps],DDSCAPS_BACKBUFFER
cominvk DDSPrimary,GetAttachedSurface,\
ddscaps,DDSBack
or eax,eax
jnz ddraw_error

mov [ddsd.dwSize],sizeof.DDSURFACEDESC
mov [ddsd.dwFlags],0
cominvk DDSBack,Lock,NULL,ddsd,DDLOCK_SURFACEMEMORYPTR+DDLOCK_WAIT,NULL

test rax,rax
jnz main_loop
mov rdi,[ddsd.lpSurface]
mov r10d,[ddsd.lPitch]
MOV [PaintGraf],RDI
xor edx,edx
PUSH RAX
PUSH RBX
PUSH RCX
PUSH RDI
PUSH RSI
;************************************************************************

Call MeinProgramm
POP RSI
POP RDI
POP RCX
POP RBX
POP RAX
xor edx,edx
;*************************************************************************

mov [refresh_needed],0
cominvk DDSBack,Unlock,NULL
cominvk DDSPrimary,Flip,0,0

main_loop:

invoke PeekMessage,msg,NULL,0,0,PM_NOREMOVE
or eax,eax
jz no_message
invoke GetMessage,msg,NULL,0,0
cmp eax,1
jb end_loop
jne no_message
invoke TranslateMessage,msg
invoke DispatchMessage,msg
cmp [refresh_needed],0
jne refresh
jmp main_loop
no_message:
invoke WaitMessage
jmp main_loop

ddraw_error:
invoke wsprintf,buffer,_ddraw_error,rax
invoke MessageBox,[hwnd],buffer,_error,MB_OK+MB_ICONERROR
invoke DestroyWindow,[hwnd]
invoke PostQuitMessage,2
jmp main_loop

startup_error:
invoke MessageBox,[hwnd],_startup_error,_error,MB_OK+MB_ICONERROR
invoke ExitProcess,1

end_loop:
cominvk DDraw,RestoreDisplayMode

cmp [DDSBack],0
je back_surface_released
cominvk DDSPrimary,DeleteAttachedSurface,0,DDSBack
back_surface_released:
cmp [DDSPrimary],0
je primary_surface_released
cominvk DDSPrimary,Release
primary_surface_released:
cmp [DDraw],0
je ddraw_released
cominvk DDraw,Release
ddraw_released:

invoke ExitProcess,[msg.wParam]

proc WindowProc uses rbx rsi rdi, hwnd,wmsg,wparam,lparam

cmp edx,WM_CREATE
je .wmcreate
cmp edx,WM_DESTROY
je .wmdestroy
cmp edx,WM_LBUTTONDOWN
je .wmlbuttondown
cmp edx,WM_RBUTTONDOWN
je .wmrbuttondown
cmp edx,WM_MBUTTONDOWN
Je .wmmbuttondown
cmp edx,WM_MOUSEMOVE
je .mouse
cmp edx,WM_KEYDOWN
je .wmkeydown
cmp edx,WM_ACTIVATE
je .wmactivate

.defwindowproc:
invoke DefWindowProc,rcx,rdx,r8,r9
jmp .finish
.wmcreate:
xor eax,eax
jmp .finish
.wmactivate:
test r8,r8
jz .finish
or [refresh_needed],1
jmp .finish
.wmlbuttondown:
or [refresh_needed],1
MOV [MausTastL],1
jmp .finish
.wmrbuttondown:
or [refresh_needed],1
MOV [MausTastR],1
jmp .finish
.mouse:

MOV rax,r9
and eax,0FFFFh
mov [MouseX],eax
MOV rax,r9
shr eax,16
and eax,0FFFFh
mov [MouseY],eax
or [refresh_needed],1
jmp .finish


.wmmbuttondown:
or [refresh_needed],1
MOV [MausTastM],1
jmp .finish

.wmkeydown:
MOV [MyKeyTaste], r8d
cmp r8d,VK_ESCAPE ;user32.inc
je .wmdestroy
;MOV EAX,[MyKeyTaste]
;cmp rax,VK_RETURN
;JE .MymusikW
or [refresh_needed],1
jmp .finish
;.MymusikW:
;MOV [Brucke],0
;or [refresh_needed],1
;jmp .finish
.wmdestroy:
invoke PostQuitMessage,0 ;https://transcribe.com/de/formats-to-mp3
xor eax,eax
.finish:
ret
endp

Include 'Myclude\MeinProc.inc'
Include 'Myclude\MeinSoundList.inc'
Include 'Myclude\Ausgabe.inc'
Include 'Myclude\RamTest.inc'
Include 'Myclude\Bildlader.inc'


section '.data' data readable writeable

wc WNDCLASSEX sizeof.WNDCLASSEX,0,WindowProc,0,0,NULL,NULL,NULL,NULL,NULL,_class,NULL

_title db 'flat assembler DirectDraw application',0
_class db 'FDDRAW64',0

_error db 'Error',0
_startup_error db 'Startup failed',0
_ddraw_error db 'Direct Draw initialization failed (error code 0x%x).',0

align 16 ; SSE data follows

Include 'Myclude\Var.inc'

section '.bss' readable writeable



hinstance dq ?
hwnd dq ?
msg MSG

cmd_open db 'open Musik\Test6.mp3 type MPEGVideo Alias MP3',0 ;Test6.mp3 = Win
cmd_play db 'play MP3',0 ;Test.mid geht auch
cmd_Play_end db 'play MP3 type MPEGVideo Alias MP3',0
cmd_close db 'close MP3',0 ;Test.wav geht auch
NoText db '',0
XText db 'Ende des Lied',0
ddsd DDSURFACEDESC
ddscaps DDSCAPS

DDraw DirectDraw
DDSPrimary DirectDrawSurface
DDSBack DirectDrawSurface

rect RECT

refresh_needed dd ?
buffer rb 100h
bufferZ rb 1000000h ;16777216 Byte ca 16 MByte

section '.idata' import data readable writeable

library kernel32,'KERNEL32.DLL',\
user32,'USER32.DLL',\
ddraw,'DDRAW.DLL',\
winmm,'WINMM.DLL'

include 'api\kernel32.inc'
include 'api\user32.inc'

import ddraw,\
DirectDrawCreate,'DirectDrawCreate'

import kernel,\
GetModuleHandle,'GetModuleHandleA',\
LoadLibrary,'LoadLibraryA',\
ExitProcess,'ExitProcess'

import winmm,\
mciSendCommand,'mciSendCommandA',\
mciSendString,'mciSendStringA',\
timeEndPeriod,'timeEndPeriod'


section '.rsrc' resource data readable


directory RT_ICON,icons,\
RT_GROUP_ICON,group_icons

IDI_HARALD = 17
resource menus,\
IDM_MENU,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu


resource icons,\ ;auxSetVolume
1,LANG_NEUTRAL,icon_data
resource group_icons,\
IDI_HARALD,LANG_NEUTRAL,main_icon

IDM_MENU = 37

IDM_MENU1 = 100
My_PlayMP3 = 101
IDM_QUITTER = 102

IDM_ABOUT = 300

menu main_menu
menuitem 'Play MP3',My_PlayMP3
menuseparator
menuitem 'Ende',IDM_QUITTER,MFR_END

;menuitem '&A Propos..',IDM_ABOUT,MFR_END

icon main_icon,icon_data,'icons\HARALD01.ico'


MP3Lauf: cmp [Brucke],0
JNE LesAus
IDM_PLAYMP3 = PaintGraf
invoke mciSendString,cmd_close,XText,0,0
invoke mciSendString,cmd_open,NoText,0,0
invoke mciSendString,cmd_play,NoText,0,0
MOV [Brucke],65536
invoke mciSendString,cmd_Play_end,XText,0,0
;invoke mciSendString,cmd_Play_end,XText,timeEndPeriod
Post 23 Apr 2026, 07:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.