News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Torture Her

Started by NightWare, January 08, 2009, 01:59:46 AM

Previous topic - Next topic

NightWare

hi,

under this horrible perpective, it's just a small app to help people starting with 2D gfx stuff, it shows you how to proceed to have your own set of gfx functions (yep, why being dependant, or loosing your time with gdi/gdi+ when you can do everything by yourself...). but of course, everything depends of your needs.

the purpose of the app is to test your own algos. but it's also to torture this well known canadian sasquach by any gfx way... there is 4 little examples, and there is also some empty slot for your creativity.

keys:
ESC = quit
B = activate/disactivate blur
D = activate/disactivate double buffer
F = activate/disactivate full screen
L = activate/disactivate frame limit
S = activate/disactivate stats
U = activate/disactivate fusion with the previous screen

have fun !

ps : it's supposed to be a funny stuff, so if you want to post an effect, just don't go to far in the torture...
ps2 : no, i have nothing against canadians, i just needed a picture with a dominance of red components for one of the effect... but you can perfectly cange the picture with another one, anyway it's not a good quality picture, coz i've reduced the number of colors/size to be able to post it (coz bmp).
ps3 : for thoses not interested by gfx stuff, but by nice algos, look at EnlargeScreenArea function, it will show you how to resize (here enlarge) a screen without the need of div or even mul instructions.
ps4 : oh yes, mmx (maybe sse) needed


[attachment deleted by admin]

Mark Jones

Poor celebrity... :toothy

Neat, the effects work as expected, however ESC does not close the window for me. In XP pro SP3 it can only be ended from the task manager. (No second dialog is displayed, and OllyDbg isn't letting me debug the call to DialogBoxParam because of multiple threads.)

Tinkering [heavily] with the code, this hack works:

...
case WM_KEYDOWN ; keypress?
mov ecx,WParam ; yes, which key?
...
.elseif ecx==VK_Q ; q (new emergency exit)
mov [Flag_Main_Process],-1
.endif


300+ FPS when unlimited, nice. :bg

Is "Fusion" is supposed to allow two simultaneous effects? I'm only seeing one. I'll keep looking.

Originally I was going to create a RadASM project for this, but then started changing things like a madman. Sorry about that. :green

Finally, a worthy Christmas present! Thanks. Now lets see if we can make some interesting effects. Any chance we could get a few more bitmaps, say some select political figures? :wink
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

NightWare

Quote from: Mark Jones on January 09, 2009, 01:08:37 AM
ESC does not close the window for me. In XP pro SP3 it can only be ended from the task manager. (No second dialog is displayed, and OllyDbg isn't letting me debug the call to DialogBoxParam because of multiple threads.)

Tinkering [heavily] with the code, this hack works:

...
case WM_KEYDOWN ; keypress?
mov ecx,WParam ; yes, which key?
...
.elseif ecx==VK_Q ; q (new emergency exit)
mov [Flag_Main_Process],-1
.endif

thanks for the info  :U

Quote from: Mark Jones on January 09, 2009, 01:08:37 AM
Is "Fusion" is supposed to allow two simultaneous effects? I'm only seeing one. I'll keep looking.
no, just a fusion with the previous screen displayed (if dbuffer is active).  but fusion of the efects is a nice idea :P

Quote from: Mark Jones on January 09, 2009, 01:08:37 AM
Any chance we could get a few more bitmaps, say some select political figures? :wink
another good idea... shoes it's not enough... especially when they don't touch the target...  :lol

Mark Jones

Careful, my "fix" actually orphans a thread, whoops. :red
Instead, this seems to work:


...
case WM_KEYDOWN ; keypress?
mov ecx,WParam ; yes, which key?
...
.elseif ecx==VK_Q ; q (new emergency exit)
jmp End_Everything ; <--- added this
.endif
...
;
; And here the exit...
;
End_Everything: ; <---- added this
invoke KillTimer,Pointer_Window,1
; invoke SetThreadPriority,Pointer_Main_Process,THREAD_PRIORITY_NORMAL
invoke TerminateThread,Pointer_Main_Process,0
invoke DestroyMenu,Pointer_Main_Menu
invoke DeleteDC,Pointer_DC_Screen
; invoke SetCursorPos,OS_Screen_Width_Half,OS_Screen_Height_Half
; invoke ShowCursor,TRUE
...
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

NightWare

here a version that allow you to add your own bmps (8 bmp max). you simply have to increase Number_Of_Victims in constant section, define the corresponding filename in str_BmpxxFileName.
and specify the bmp used in init section of the effects (the line before call UpdateCurrentVictim)
all bmps have their own backup and work screen. i've only made few tests but it seams it work... just save your work (if any) and overwrite the old files with those in the new zip.

concerning the problem with the dialog box, try to remove the TortureHer.exe.manifest file, it may be the problem... AGAIN...

concerning effects fusion, i must abandon the idea, coz it introduce a priority concept. plus, i will probably post more advanced effects later (rotation, sin waves, etc...), and those effects don't follow the copy/paste logic...


[attachment deleted by admin]

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

NightWare

#6
Turn Her  :P

EDIT : new version of Effect04, it's the same code, but here i take care of the alignment/memory usage, so noticeable speedup... (37 fps before, 67 fps now, in fullscreen/no limits)
note : it's also possible to really speedup the code with simd instructions, or calc only the displacements of the first half part of the screen and "deduce" the displacement of the second part. but i will not post those codes, coz i want something understandable for everybody...  :bg

oh, here another speedup, replace the EnlargeScreenArea function, with this one (yep, no need to re-read the same source pixel...) :
ALIGN 16
;
; elargir un écran source, dans un écran destination (ils doivent être différents...)
; note : ici, ne fonctionne qu'en élargissant
;
; Syntax :
; mov esi,{OFFSET d'une structure Screen_Area (le tampon de l'écran originel)}
; mov edi,{OFFSET d'une structure Screen_Area (le tampon de l'écran final)}
; call EnlargeScreenArea
;
; Return :
; rien
;
EnlargeScreenArea PROC
pushad

mov eax,(Screen_Area PTR [esi]).Screen_Height
mov ecx,(Screen_Area PTR [esi]).Screen_Width_x4
mov esi,(Screen_Area PTR [esi]).Pointer
mov ebx,(Screen_Area PTR [edi]).Screen_Height
mov edx,(Screen_Area PTR [edi]).Screen_Width_x4
mov edi,(Screen_Area PTR [edi]).Pointer
mov ebp,ebx
neg ebp
mov _Lines_Counter_,ebx
mov _Lines_TestValue_,ebp

; boucle hauteur
Label01: push eax ;; empiler source._Hauteur_Ecran_
push ebx ;; empiler destination._Hauteur_Ecran_
push esi ;; empiler source._Pointeur_ (qui devient le debut de ligne)

mov ebx,edx ;; copier destination._Largeur_Ecran_X4_ dans ebx
add edi,edx ;; ajouter destination._Largeur_Ecran_X4_ à edi
neg ebx ;; inverser ebx (qui devient la valeur test, pour la largeur)
mov eax,DWORD PTR [esi] ;; lire le pixel en esi (le premier pixel de la ligne)
mov ebp,ebx ;; copier ebx dans ebp (qui devient le pas de progression)
; boucle largeur
Label02: add ebx,ecx ;; ajouter source._Largeur_Ecran_X4_ à la valeur test
js Label03 ;; si c'est signé, aller Label03
sub ebx,edx ;; sinon, soustraire destination._Largeur_Ecran_X4_ à ebx, pour retransformer ebx en valeur test
mov eax,DWORD PTR [esi] ;; lire le nouveau pixel source en esi, à utiliser
add esi,DWORD ;; ajouter un dword à esi, pour passer au pixel source suivant
Label03: mov DWORD PTR [edi+ebp],eax ;; écrire le pixel en edi+ebp
; fin boucle largeur
add ebp,DWORD ;; ajouter un dword à ebp, pour passer au pixel destination suivant
jnz Label02 ;; tant qu'ebp est different de zéro, retourner Label02

pop esi ;; restaurer le début de ligne
pop ebx ;; restaurer destination._Hauteur_Ecran_
pop eax ;; restaurer source._Hauteur_Ecran_

add _Lines_TestValue_,eax
js Label04
add esi,ecx
sub _Lines_TestValue_,ebx

Label04: dec _Lines_Counter_
jnz Label01

popad
ret
EnlargeScreenArea ENDP

[attachment deleted by admin]

NightWare

a long time you haven't gone in a tunnel of horror ? you wanna scary yourself a bit ?  :toothy here we go... zoom her :


[attachment deleted by admin]

NightWare

Question : is it possible to join TURN and ZOOM effects at reasonnable speed ?

Answer : Yes, of course, you can naturally use both algos together. BUT there is another possibility, by using one of the properties of sine/cosine, here the example (in fact it's effect 04 + only 2 instructions placed in the approriate location  :wink), TURN HER AND ZOOM HER

[attachment deleted by admin]

dedndave

very cool nightware

the esc worked for me - xp mce2005 sp2
she needs to be shaken and burned at the same time   :P

UtillMasm

Esc not work for Vista Ultimate with SP1.