Not bad
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
#define ResX 256
#define ResY 192
int main(void) {
// required data
static int pixel[ResX*ResY];
static BITMAPINFO bmi = {sizeof(BITMAPINFOHEADER),ResX,ResY,1,32};
// window creation
HWND hWnd = CreateWindowExA(0,"edit",0,WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,0,0);
HDC hDC = GetDC(hWnd);
ShowCursor(FALSE);
// main loop
for (MSG msg; msg.message != WM_KEYDOWN; PeekMessage(&msg,0,0,0,PM_REMOVE)) {
// screen blitting
int ScreenX = GetSystemMetrics(SM_CXSCREEN);
int ScreenY = GetSystemMetrics(SM_CYSCREEN);
StretchDIBits(hDC,0,0,ScreenX,ScreenY,0,0,ResX,ResY,pixel,&bmi,0,SRCCOPY);
SwapBuffers(hDC);
// pixel pushing
int t = GetTickCount();
for (int i = 0; i < ResX*ResY; i++) pixel[i] = i + t;
}
ExitProcess(0);
return 0;
}
float invSqrt(float x)
{
float xhalf = 0.5f*x;
union
{
float x;
int i;
} u;
u.x = x;
u.i = 0x5f3759df - (u.i >> 1);
/* The next line can be repeated any number of times to increase accuracy */
u.x = u.x * (1.5f - xhalf * u.x * u.x);
return u.x;
}
// Quakes version
float Q_rsqrt( float number )
{
int i;
float x2, y;
const float threehalfs = 1.5f;
x2 = number * 0.5f;
y = number;
i = *( int* )&y; // evil floating point bit level hacking
i = 0x5F3759DF - ( i >> 1 ); // what the f***?
y = *( float* )&i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}
// Lomonts version
float InvSqrt( float x )
{
float xhalf = 0.5f*x;
int i = *( int* )&x; // get bits for floating value
i = 0x5F375A86 - ( i >> 1 ); // gives initial guess y0
x = *( float* )&i; // convert bits back to float
x = x*(1.5f - xhalf*x*x ); // Newton step, repeating increases accuracy
return x;
}
rsqrt:
_asm {
rsqrtps xmm0, xmmword ptr [ rcx ] ;
movaps xmmword ptr [ rcx ], xmm0 ;
ret ;
}
sqrthw:
_asm {
rsqrtps xmm0, xmmword ptr [ rcx ] ;
rcpps xmm0, xmm0 ;
movaps xmmword ptr [ rcx ], xmm0 ;
ret ;
}
float fastsqrt( float n )
{
int i = *( int* )&n;
i -= 1 << 23;
i >>= 1;
i += 1 << 29;
return *( float* )&i;
}
float sqrtNewRapf( float x )
{
float y = sqrtf( x ); // Get approx
// y = ( y*y + x ) / ( 2*y ); // Newton-Raphson as many times as needed
return ( y*y + x ) / ( 2*y );
}
OneAsIntShr1 dd 4 dup ( 0x1FC00000 ) ; OneAsInt >> 1
fastsqrt:
_asm {
movdqa xmm0, xmmword ptr [ rcx ] ;
psrld xmm0, 1 ;
paddd xmm0, xmmword ptr [ OneAsIntShr1 ] ;
movdqa xmmword ptr [ rcx ], xmm0 ;
ret ;
}
OneAsIntShr1 dd 4 dup ( 0x1FC00000 ) ; OneAsInt >> 1
fastsqrt:
_asm {
movdqa xmm0, xmmword ptr [ rcx ] ;
psrld xmm0, 1 ;
paddd xmm0, xmmword ptr [ OneAsIntShr1 ] ;
; Newton Raphson
movaps xmm1, xmm0 ; Place y ( our guess ) into xmm1 for doubling
addps xmm1, xmm1 ; double y
mulps xmm0, xmm0 ; square y
addps xmm0, xmmword ptr [ rcx ] ; add original x
rcpps xmm1, xmm1 ; Divide by our 2y
mulps xmm0, xmm1 ;
movaps xmmword ptr [ rcx ], xmm0 ; Store result
ret ;
}
_inline float neg( float f )
{
return AsFloat( AsInt( f ) ^ 0x80000000 );
}
fneg:
_asm {
pcmpeqd xmm1, xmm1 ; Get 0x80000000, -0.0 int xmm1
pslld xmm1, 31 ;
; loop here down as necessary ;
movdqa xmm0, xmmword ptr [ rcx ] ;
pxor xmm0, xmm1 ;
movdqa xmmword ptr [ rcx ], xmm0 ;
ret ;
}
const unsigned int OneAsInt = 0x3F800000; // 1.0f as int
const float ScaleUp = float( 0x00800000 ); // 8388608.0, 2^23
const float ScaleDown = 1.0f / ScaleUp;
float Log2( float x )
{
return float ( AsInt( x )-OneAsInt )*ScaleDown;
}
OneAsInt dd 4 dup ( 0x3F800000 ) ; 1.0 bit pattern as int
ScaleDown dd 4 dup ( 0x34000000 ) ; 4 copies of 1.0 / ScaleUp
Log2f:
asm {
movdqa xmm0, xmmword ptr [ rcx ] ;
psubd xmm0, xmmword ptr [ OneAsInt ] ;
cvtdq2ps xmm0, xmm0 ; cast to singles
mulps xmm0, xmmword ptr [ ScaleDown ] ;
movdqa xmmword ptr [ rcx ], xmm0 ;
ret ;
}
float Exp2( float x )
{
return AsFloat( int( x*ScaleUp ) + OneAsInt );
}
OneAsInt dd 4 dup ( 0x3F800000 ) ; 1.0 bit pattern as int
Pow2f:
_asm {
movdqa xmm0, xmmword ptr [ rcx ] ;
movaps xmm1, xmmword ptr [ rdx ] ;
psubd xmm0, xmmword ptr [ OneAsInt ] ;
cvtdq2ps xmm0, xmm0 ;
mulps xmm0, xmm1 ;
cvtps2dq xmm0, xmm0 ;
paddd xmm0, xmmword ptr [ OneAsInt ] ;
movaps xmmword ptr [ rcx ], xmm0 ;
ret ;
}
#include <math.h>
#include <time.h>
#include <stdio.h>
static volatile float f2 = 0.0f;
float fmod1_fast( const float f )
{
const int iBits = *( reinterpret_cast< const int* >( &f ) );
// extract exponent
const int iExponent = ( ( iBits & 0x7F800000 ) - 0x3F800000 ) >> 23;
if( iExponent > 23 )
{
return 0.0f;
}
if( iExponent < 0 )
{
return f;
}
const int iSignificand = iBits & 0x007FFFFF;
if( iSignificand == 0 )
{
return 0.0f;
}
// find the most significant bit of the significand - this can be done by binary search
/*
0111 1111 1111 1111 1111 1111
0111 1111 1111 0000 0000 0000
7 F F 0 0 0
0111 1100 0000 1111 1100 0000
7 C 0 F C 0
0110 0011 1000 1110 0011 1000
A 3 8 E 3 8
0001 0010 0100 1001 0010 0100
1 2 4 9 2 4
0100 1001 0010 0100 1001 0010
4 9 2 4 9 2
*/
int iMSB = ( iSignificand & 0x007FF000 ) ? 11 : 0;
iMSB += ( iSignificand & 0x007C0FC0 ) ? 6 : 0;
iMSB += ( iSignificand & 0x00A38E38 ) ? 3 : 0;
iMSB += ( iSignificand & 0x00124924 ) ? 2 : 0;
iMSB += ( iSignificand & 0x00492492 ) ? 1 : 0;
iMSB = 23 - iMSB;
const int iNewBits = ( ( iSignificand << ( iMSB + iExponent ) ) & 0x007FFFFF ) | ( 0x3F800000 - ( ( ( iMSB ) - iExponent ) << 23 ) );
const float fPreMod = *reinterpret_cast< const float* >( &iNewBits );
const float fMod = ( ( iBits & 0x80000000 ) ? ( 1.0f - fPreMod ) : fPreMod ) - static_cast< float > ( 1 << ( iExponent ) );
const int iNewNewBits = *reinterpret_cast< const int* >( &fMod );
const int iNewNewNewBits = iNewNewBits - ( ( iExponent << 23 ) & 0x3F800000 );
const float fMaybeSignFlippedMod = *reinterpret_cast< const float* >( &iNewNewNewBits );
return ( fMaybeSignFlippedMod > 0.0f ) ? fMaybeSignFlippedMod : ( 1.0f - -fMaybeSignFlippedMod );
}

Quote from: spathi on March 25, 2014
I have been relearning 6502 assembly after 35 years. How much harder is x86?
;---rigid body.bb------------------------------------------------------------------------\
;
; rigid body
;
;
; by Tetra
;
;----------------------------------------------------------------------------------------/
AppTitle "Rigid Body Test 1.0"
SeedRnd( MilliSecs() )
;=======================================================================================|
; LOAD MODELS --|
;__Variables______________________________________
;
Type TSquare
Field x#
Field y#
Field a#
Field dx#
Field dy#
Field da#
Field odx#
Field ody#
Field oda#
Field mass#
Field velocity#
Field acceleration#
Field torque#
Field force#
Field time#
Field timePassed#
Field points#[8]
Field collided[4]
End Type
;
;------------------------------------------------
Function Load_Objects()
Local Square.TSquare
Square.TSquare = New TSquare
Square\x# = 512.0
Square\y# = 284.0
Square\a# = 20.0
Square\dx# = 0.0
Square\dy# = 0.0
Square\da# = 0.0
Square\odx# = 0.0
Square\ody# = 0.0
Square\oda# = 0.0
Square\mass# = 1.0
Square\time = MilliSecs()
End Function
;\---------------------------------------------------------------------------------------/
;=======================================================================================|
; DRAW SQUARES --|
;__Variables_____________________________________
;
;
;------------------------------------------------
Function DrawSquare()
Local Square.TSquare = First TSquare
Color 255,255,255
For i = 0 To 4 Step 2
Line Square\x# + Square\points[i],Square\y# + Square\points[i+1], Square\x# + Square\points[i+2],Square\y# + Square\points[i+3]
Next
Line Square\x# + Square\points[6],Square\y# + Square\points[7], Square\x# + Square\points[0],Square\y# + Square\points[1]
End Function
;----------------------------------------------------------------------------------------/
;=======================================================================================|
; GET ANGLE --|
;__Variables_____________________________________
;
;
; Get the angle between two vectors
;
; 0
; |
; -90 ==X== 90
; |
; 180
;------------------------------------------------
Function getAngle#( x1#,y1#, x2#,y2#, ox# = 0,oy# = 0 )
Local tvAx# = x1# - ox#
Local tvAY# = y1# - oy#
Local tvBx# = x2# - ox#
Local tvBY# = y2# - oy#
Local d# = ATan2#( tvAy#, tvAx# )
Local tvCx# = Cos#( d# ) * tvBx# + Sin#( d# ) * tvBy#
Local tvCy# = -Sin#( d# ) * tvBx# + Cos#( d# ) * tvBy#
Local newAngle# = ATan2#( tvCy#, tvCx# )
If ( newAngle# > 0.0 )
newAngle# = -(180.0 - newAngle#)
Else
newAngle# = -(-180.0 - newAngle#)
EndIf
Return newAngle#
End Function
;----------------------------------------------------------------------------------------/
;=======================================================================================|
; ANIMATE SQUARES --|
;__Variables_____________________________________
;
; g / 1s so 1pixel = 9.807 meters
Const Gravity# = 9.807 / 1000.0
;
;------------------------------------------------
Function AnimateSquare()
Local Square.TSquare = First TSquare
Local newX# = Square\x# + Square\dx#
Local newY# = Square\y# + Square\dy#
Local newA# = Square\a# + Square\da#
Local newVA# ;= Square\da#
Local bottom = 600
Local top = 100
Local leftb = 100
Local rightb = 900
Square\points[0] = 50.0 * Sin#( newA# - 45.0 )
Square\points[1] = 50.0 * Cos#( newA# - 45.0 )
Square\points[2] = 50.0 * Sin#( newA# + 45.0 )
Square\points[3] = 50.0 * Cos#( newA# + 45.0 )
Square\points[4] = 50.0 * Sin#( newA# + 135.0 )
Square\points[5] = 50.0 * Cos#( newA# + 135.0 )
Square\points[6] = 50.0 * Sin#( newA# - 135.0 )
Square\points[7] = 50.0 * Cos#( newA# - 135.0 )
;Color 0,255,0
;Line Square\x#,Square\y#, Square\x#+Square\vx#*10,Square\y#+Square\vy#*10
Local distance#, newAVel#, tempAVel#, tempXVel#, tempYVel#, impactX#, impactY#
Local reverseY = 0
Local reverseX = 0
Local Ejection#
Local angle#
tempXVel# = Square\dx#
tempYVel# = Square\dy#
Square\timePassed# = ( Float( MilliSecs() ) - Square\time# )
Square\time# = MilliSecs()
For i = 0 To 3
impactX# = Square\points[(i*2)]
impactY# = Square\points[(i*2)+1]
; this is a hack to make sure the box stays where it should do
; if it travelled as hyper speed it would fail ;)
; also the direction of the force wont simply reverse
If ( impactY# + newY# > bottom )
Ejection# = ( (impactY# + newY#) - bottom )
newY# = newY# - Ejection#
reverseY = 1
ElseIf ( impactY# + newY# < top )
Ejection# = ( top - (impactY# + newY#) )
newY# = newY# + Ejection#
reverseY = -1
EndIf
If ( impactX# + newX# >= rightb )
Ejection# = ( (impactX# + newX#) - rightb )
newX# = newX# - Ejection#
reverseX = 1
ElseIf ( impactX# + newX# < leftb )
Ejection# = ( leftb - (impactX# + newX#) )
newX# = newX# + Ejection#
reverseX = -1
EndIf
If ( reverseX <> 0 )Or( reverseY <> 0 )
;
; Force = Mass * Acceleration
; Acceleration is the rate of change in velocity over time a = v/t
;
Square\velocity# = VectorLength#( Square\dx# - Square\odx#, Square\dy# - Square\ody# )
Square\acceleration# = Square\velocity# / ( Square\timePassed# / 1000.0 )
Square\force# = Square\mass# * Square\acceleration#
;
; Angle between the direction vector and point of impact vector
;
angle# = -getAngle( impactX#,impactY#, Square\dx#, Square\dy# )
;
; torque = distance to center * Force * sin( angle )
;
distance# = VectorLength#( impactX#, impactY# )
Square\torque# = Square\force# * distance# * Sin( angle# )
;
; Convert torque to angular velocity
;
newVA# = newVA# + ( Square\torque# * 360.0 )
EndIf
Next
If reverseY = 1
tempYVel# = -Abs(Square\dy#) * 0.5
ElseIf reverseY = -1
tempYVel# = Abs(Square\dy#) * 0.5
EndIf
If reverseX = 1
tempXVel# = -Abs(Square\dx#) * 0.5
ElseIf reverseX = -1
tempXVel# = Abs(Square\dx#) * 0.5
EndIf
Square\x# = newX#
Square\y# = newY#
Square\a# = newA#
Square\odx# = Square\dx#
Square\ody# = Square\dy#
Square\dx# = tempXVel#
Square\dy# = tempYVel#
Square\da# = newVA#; * Float(Square\timePassed)
Square\dy# = Square\dy# + ( Gravity# * Square\timePassed# )
Color 128,128,128
Line leftb,bottom ,rightb,bottom
Line leftb,top ,rightb,top
Line leftb,top ,leftb,bottom
Line rightb,top ,rightb,bottom
End Function
;----------------------------------------------------------------------------------------/
;=======================================================================================|
; VECTOR LENGTH --|
;__Variables_____________________________________
;
;
;------------------------------------------------
Function VectorLength#( x#,y# )
Return Sqr#( x# * x# + y# * y# )
End Function
;----------------------------------------------------------------------------------------/
;=======================================================================================|
; READ INPUT --|
;__Variables_____________________________________
;
Global EXIT_PROGRAM = False
Global click = False
;
;------------------------------------------------
Function Read_Input()
If KeyDown(1) Then EXIT_PROGRAM = True
Local Square.TSquare = First TSquare
If MouseDown(1)
If Not click
Square\x# = 512
Square\y# = 384
Square\dx# = Rand(-100,100) / 10.0
Square\dy# = Rand(-100,100) / 10.0
Square\da# = Rand(-100,100) / 100.0
Square\a# = Rand(0,3600) / 10.0
click = True
EndIf
Else
click = False
EndIf
If MouseDown(2)
Square\x# = MouseX()
Square\y# = MouseY()
Square\dx# = MouseXSpeed()/4.0
Square\dy# = MouseYSpeed()/4.0
Square\da# = 0.0
EndIf
End Function
;----------------------------------------------------------------------------------------/
;=======================================================================================|
; INITIALIZE --|
;__Variables_____________________________________
;
Const GFX_WIDTH = 1024
Const GFX_HEIGHT = 768
Global timer
;
;------------------------------------------------
Function Initialize()
Graphics GFX_WIDTH, GFX_HEIGHT, 32, 2
timer = CreateTimer( 60 )
Load_Objects()
SetBuffer( BackBuffer() )
End Function
;----------------------------------------------------------------------------------------/
;=======================================================================================|
; MAIN --|
;__Variables_____________________________________
;
;
;------------------------------------------------
Function Main()
AnimateSquare()
DrawSquare()
Color 255,255,255
Text 10,10,"Right Click to randomize, Hold Left Click, drag then release to throw"
Local Square.TSquare = First TSquare
Text 10,30, "A Velocity: "+Square\da#
Text 10,50, "X Velocity: "+Square\dx#
Text 10,70, "Y Velocity: "+Square\dy#
End Function
;----------------------------------------------------------------------------------------/
;=======================================================================================|
; MAIN PROGRAM --|
;__Variables_____________________________________
;
;
;------------------------------------------------
Initialize()
While Not EXIT_PROGRAM
Read_Input()
Main()
Flip
Cls
WaitTimer( timer )
Wend
;----------------------------------------------------------------------------------------/
;=======================================================================================|
;-------------------------------------------------------------------------------- END --|
End
;--------------------------------------------------------------------------------------/
format binary as 'exe'
macro tinycall proc,[arg]
{
common
if ~ arg eq
reverse
pushd arg
common
end if
call dword [ebx + proc]
}
VK_ESCAPE = (0x0000001B)
SRCCOPY = (0x00CC0020)
WS_POPUP = (0x80000000)
WS_VISIBLE = (0x10000000)
WS_MAXIMIZE = (0x01000000)
PM_REMOVE = (0x00000001)
WM_KEYDOWN = (0x00000100)
WM_KEYUP = (0x00000101)
SM_CXSCREEN = (0x00000000)
SM_CYSCREEN = (0x00000001)
RESX equ 256
RESY equ 192
ImageBase = 0x00400000
SizeOfHdr = 0x0088 ; 0x94
SizeOfCode = 0x00600080 ; 0x00040004 ; 0x00010000 + 196608 ; (196608 = 4*(RESX)*(RESY))
;GetSystemMetrics dd 0xB9DAA600
use32
root: dec ebp
pop edx
jmp jump
dd 'PE' ; .Signature
dw 0x014C ; .Machine
dw 0x0000 ; .NumberOfSections
LoadLibrary dd 0xE9826FC6 ; .TimeDateStamp
GetWindowRect dd 0xF9AC1F38 ; .PointerToSymbolTable
ShowCursor dd 0x19A434A8 ; .NumberOfSymbols
dw 0x0010 ; .SizeOfOptionalHeader
dw 0x010F ; .Characteristics (no relocations, executable, 32 bit)
Op_Hdr:
dd 0x0000010B ; .Magic .MajorLinkerVersion .MinorLinkerVersion
PeekMessage dd 0xEA1682FE ; .SizeOfCode
StretchDIBits dd 0x4ED54D5C ; .SizeOfInitializedData
ExitProcess dd 0x38A66AE8 ; .SizeOfUninitializedData
dd root ; .AddressOfEntryPoint
CreateWindowEx dd 0xF8820ECC ; .BaseOfCode
dd 'edit' ; .BaseOfData
dd ImageBase ; .ImageBase
dd 0x00000004 ; .SectionAlignment
dd 0x00000004 ; .FileAlignment
GetDC dd 0xA4D450D1 ; .MajorOperatingSystemVersion
wave dd 0x3DC90FDB ; .MinorOperatingSystemVersion .MajorImageVersion
dw 0x0004 ; .MajorSubsystemVersion
jump: push 0x30
pop ecx
push edx
jmp kern
dd SizeOfCode ; .SizeOfImage
dd SizeOfHdr ; .SizeOfHeaders
libname: dd 'gdi3' ; .CheckSum
dw 0x0002 ; .Subsystem
dw 0x0000 ; .DllCharacteristics
SizeStackClear = 0x24
NumStackValues = 0x0F
BitMapInfo = 0x68
PtrStack = (PackedStack-libname)+3
PackedStack:
db 0x08, 0x34 ; <- &edit
db 0x0A, 0x40 ; <- &edit+ImageBase
db 0x13, 0x91 ; <- window style WS_POPUP|WS_MAXIMIZE|WS_VISIBLE
db 0x60, 0x20 ; <- LOWORD(SRCCOPY);
db 0x4D, 0x01 ; <- StretchDIBits->nSrcWidth = RESX
db 0x68, 0x28 ; <- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
db 0x56, 0x41 ; <- 41 here is compressed 00410000 == &pixel[0]
db 0x50, 0xC0 ; <- StretchDIBits->nSrcHeight = RESY
db 0x62, 0xCC ; <- HIWORD(SRCCOPY);
db 0x6D, 0x01 ; <- bmi.bmiHeader.biWidth = RESX;
dd 0x00000000 ; .NumberOfRvaAndSizes
db 0x76, 0x20 ; <- bmi.bmiHeader.biBitCount = 32;
db 0x70, 0xC0 ; <- bmi.bmiHeader.biHeight = RESY;
db 0x74, 0x01 ; <- bmi.bmiHeader.biPlanes = 1;
kern: mov eax, [fs : ecx] ; 64 8B 01
mov eax, [eax+0x0C] ; 8B 40 0C
mov eax, [eax+0x1C] ; 8B 40 1C
base: mov edx, [eax+0x20] ; 8B 50 20
mov ebp, [eax+0x08] ; 8B 68 08
cmp [edx+0x18], ch ; 38 6A 18
mov eax, [eax] ; 8B 00
jnz base ; 75 F3
mov esi, ImageBase+libname ; BE 5C 00 40 00
jmp libs ;
hash: mov ecx, [edx+0x18] ; 8B 4A 18 ; ecx = Num Exports
redo: jecxz done ; E3 2E ; ecx = 0 No More Exports
dec ecx ; 49 ; ecx = Num Exports Decreased
mov esi, [edx+0x20] ; 8B 72 20 ; edi = RVA Exports Asciiz
add esi, ebp ; 01 EE ; edi = RVA -> VA
mov esi, [esi+ecx*0x04] ; 8B 34 8E ; esi = RVA Export Asciiz Index
add esi, ebp ; 01 EE ; esi = RVA -> VA
mov ebx, 0x00000000 ; BB 00 00 00 00 ; .PointerToLinenumbers
calc: lodsb ; AC ; al = Char Export Asciiz
rol ebx, 0x06 ; C1 C3 06 ; ebx = Hash Preparation
xor bl, al ; 30 C3 ; ebx = Hash Complete
test al, al ; 84 C0 ; al = 0 Only For End of Asciiz
jnz calc ; 75 F6 ; If Not Zero Keep Hashing
cmp ebx, [edi] ; 3B 1F ; Check Hash Against Input
jnz redo ; 75 E3 ; If Not Equal Hash Next Function
mov ebx, [edx+0x24] ; 8B 5A 24 ; edi = RVA Function Ordinal
add ebx, ebp ; 01 EB ; edi = RVA -> VA
movzx ecx, word [ebx+ecx*0x02] ; 0F B7 0C 4B ;
mov ebx, [edx+0x1C] ; 8B 5A 1C ; edi = Function RVAS List
add ebx, ebp ; 01 EB ; edi = RVA -> VA
add ebp, [ebx+ecx*0x04] ; 03 2C 8B ; eax = Function RVA
mov [edi], ebp ; 89 2F
jmp done
libs: or byte [esi+0x04], cl
mov ebx, esi
mov bl, ch
scan: push 0x13 ;
pop ecx ; LoadLibrary trashes ecx
func: pusha
lea edi, [ebx+ecx*0x04]
mov eax, [ebp+0x3C] ; 8B 45 3C ; eax = RVA NT Header
mov edx, [ebp+eax+0x78] ; 8B 54 05 78 ; edx = RVA Data Directory
add edx, ebp ; 01 EA ; edx = RVA -> VA
jmp hash
done: popa ; 61 ; Restore Registers
loop func ; E2 EB
push esi ; 56
tinycall LoadLibrary ;, esi ; FF 53 0C
dec esi ; 4E
mov dword [esi], 'user' ; C7 06 75 73 65 72
xchg ebp, eax ; 95
or ebp, ebp ; 09 ED
jnz scan ; 75 DE
start: push SizeStackClear ; 0x24
pop ecx
push ebp
loop $-1
lea esi, [esi + PtrStack]
mov cl, NumStackValues
lodsw
movzx edx, al
mov [esp+edx], ah
loop $-8
lea ebp, [esp+BitMapInfo]
mov [esp+0x58], ebp
tinycall ShowCursor
tinycall CreateWindowEx
mov edx, esp
tinycall GetWindowRect, eax, edx, eax
tinycall GetDC
push eax
RESX equ 256
RESY equ 192
ResX equ ebp+0x1C
ResY equ ebp+0x20
Size equ ebp+0x1F
Pixel equ ebp+0x24
msg equ edi
pump: ;xor ecx, ecx
mov ebp, esp
tinycall PeekMessage, msg, ecx, ecx, ecx, PM_REMOVE
tinycall StretchDIBits
mov esp, ebp
mov eax, [ResX]
cmp eax, [msg + 4]
jnz main
tinycall ExitProcess
x = 0x0A
y = 0x0A
HalfResX = 0x54
HalfResY = 0x56
time = 0x78
SixtyFour = 0x3A
Sixteen = 0x18
NinetySix = 0x56
;ebx image pointer
;ebp frame pointer
;esi const pointer
;edx temp pointer
;edi pixel pointer
;ecx loop counter
main: fld dword [ebx+time]
fadd dword [ebx+wave]
fstp dword [ebx+time]
mov edi, [Pixel]
mov ecx, [Size]
draw: dec ecx
jz pump
finit
push 0x0A
pop dword [edi]
lea esi, [ebx+0x18] ;0x0010
lea edx, [ebx+0x2C] ;0x00000000
;float dirx = (float)(x+x-ResX);
;float diry = fabs((float)(y+y-ResY));
;float dirz = (float)ResX;
mov byte [edx], cl ;
fild word [edx] ;
fisub word [ebx+0x54] ; ResX/2
mov byte [edx], ch ;
fild word [edx] ;
fisub word [ebx+0x56] ; ResY/2
fabs ;
fild word [ResX] ;
;float norm = 1.0f/sqrt(dirx*dirx + diry*diry + dirz*dirz);
fld st2
fmul st0, st0
fld st2
fmul st0, st0
fld st2
fmul st0, st0
faddp st1, st0
faddp st1, st0
fsqrt
fld1
fdivrp st1, st0
;dirx *= norm;
;diry *= norm;
;dirz *= norm;
fmul st3, st0
fmul st2, st0
fmulp st1, st0
;float posx = sin(time*wave)*0x40;
;float posy = cos(time*wave)*0x10-0x20;
;float posz = 0x60;
fld dword [ebx+time]
fsincos
fimul word [ebx+0x3A] ; 0x0040
fxch
fimul word [esi]
fisub word [esi]
fisub word [esi]
fild word [ResX] ; 0x0080
cast: ;do {
;dist = fabs(posy + 0x10*sin(posx*wave)*sin(posz*wave));
fld st0
fmul dword [ebx+wave]
fsin
fld st3
fmul dword [ebx+wave]
fsin
fmulp st1, st0
fimul dword [edi]
fadd st0, st2
fabs
fist dword [ebx]
;posx += dist*dirx;
;posy += dist*diry;
;posz += dist*dirz;
fld st6
fmul st0, st1
faddp st4, st0
fld st5
fmul st0, st1
faddp st3, st0
fld st4
fmulp st1, st0
faddp st1, st0
;} while ((int)posz < 0x0200 && (int)dist>1);
cmp dword [ebx], 0x00000004
jbe colr
fist dword [ebx]
cmp dword [ebx], 0x00000800
jb cast
colr:
;int b = (int)fabs(posy*0x100/posz)<<2;
;int r = ((int)posx^(int)posz)&0x10;
;r = (int)(r*0x100/posz);
fild dword [ResX]
fdivrp st1, st0
fmulp st1, st0
fimul dword [edi]
fabs
fistp dword [edi]
mov eax, [edi]
stosb
stosb
stosb
scasb
jmp draw
db 0
rem this is a string input
print "Hello my name is yabasic"
input "What is your name?" Name$
print "Hello " + Name$ + " nice to meet you"
rem this is a numeric input
print "So " + Name$ + " can you answer this question for me"
print "I have 3 apples and I share 1 of my apples with you"
input "How many apples do I have left?" NumApples
if (NumApples = 2) then
print "Correct " + Name$ + " I have exactly 2 apples left."
elsif (NumApples < 2) then
print "No " + Name$ + " I have 2 apples left."
elsif (NumApples > 2) then
print "No " + Name$ + " I have 2 apples left."
else
print "No " + Name$ + " I have 2 apples left."
endif
+---+
| |
+---+---+---+
| | X | |
+---+---+---+
| |
+---+
+---+
| X |
+---+---+---+
| | | |
+---+---+---+
| |
+---+
Page created in 0.275 seconds with 15 queries.