Author Topic: asm library  (Read 4611 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
asm library
« on: April 07, 2018, 12:23:23 PM »
hello,

here is another fine library, called ASM.
of course, it is 32Bit thing.
 
if you do not like it then have your say here!
I will then ends my contributions, in favour of you.

Peter

I offer here some demos.

1.
Code: OxygenBasic
  1. include "asm.inc"
  2. Window 640,480,1
  3.  
  4. sys x, y, z
  5. float a, v
  6.  
  7. ! timeBeginPeriod Lib "winmm.dll" (long uPeriod) As Long
  8. ! timeEndPeriod   Lib "winmm.dll" (long uPeriod  As Long
  9.  
  10. LoadImage "gfx/jump.bmp",8
  11. LoadImage "gfx/grass.bmp",1
  12. LoadImage "gfx/himmel.bmp",1
  13.  
  14. While Key(27)=0
  15. ScaleImage 3,0,0,640,480,0
  16. ScaleImage 1,200+*50,270+x+cos(a)*80,150,118,z
  17. ScaleImage 2,0,415,640,64,0
  18. Color 255,255,255
  19. Text 120,8,16,"timeBeginPeriod Demo"
  20. a +=.1
  21. if a>=360 then a=-a
  22. x = atan(sin(a),cos(a))
  23. v +=.2
  24. if v >=1
  25.    v=0  
  26.    z +=1
  27.    if z=8 then z=0
  28. end if
  29. Flip
  30. timeBeginPeriod (1)
  31. Wait 32
  32. timeEndPeriod (1)
  33. Wend
  34. WinEnd
  35.  

2.
Code: OxygenBasic
  1. include "asm.inc"
  2. window 640,480,1
  3. SetFrames 60
  4.  
  5. CreateImage 320,240
  6. p1 = LoadImage("gfx/p1.bmp",1)
  7. p4 = LoadImage("gfx/p4.bmp",1)
  8. p3 = LoadImage("gfx/p3.bmp",1)
  9. p5 = LoadImage("gfx/metal.bmp",1)
  10.  
  11. float a
  12.  
  13. while KeyDown(27)=0
  14. UseImage (on)
  15. cls 0,255,0
  16. RotateImage p4,128,88,2,-a
  17. DrawImageRect 0,0,800,600,0,0
  18. Image p5,0,0
  19. DrawImageRect 320,0,800,600,0,0
  20. Image p5,0,0
  21. DrawImageRect 0,240,800,600,0,0
  22. cls 255,255,0
  23. DrawImageRect 320,240,800,600,0,0
  24. RotateImage p1,128,88,2,-a
  25. DrawImageRect 320,240,800,600,0,0
  26. UseImage (off)
  27. RotateImage p3,288,208,2,a
  28. Flip()
  29. a +=4.5
  30. if a>=360 then a=-a
  31. wend
  32. winEnd
  33.  

3.
Code: OxygenBasic
  1. include "asm.inc"
  2. Window 640,400,1
  3. SetFrames 60
  4.  
  5. LoadImage "gfx/pic.bmp",1
  6. LoadImage "gfx/bee.bmp",6
  7.  
  8. single x, y, v
  9. int w=ScreenW, z
  10.  
  11. while KeyDown(27)=0
  12. Image 1,0,0
  13. Color 0,0,200
  14. Text 120,0,20,"CONSTRAIN EXAMPLE"
  15. y = 200+100*sin(rad(x))
  16. v +=.2
  17. if v>=1  
  18.    v=0
  19.    z +=1: if z=6 then z=0
  20. end if  
  21. ScaleImage 2,x,y,64,64,z
  22. if Constrain(x, 0, w) >0
  23.    x +=2
  24. else
  25.    x=0
  26. end if  
  27. Flip
  28. Wait 20
  29. Wend
  30. WinEnd
  31.  

4.
Code: OxygenBasic
  1. include "asm.inc"
  2. window 800,600,1
  3.  
  4. int e=70, s=273
  5. Color 255,255,255
  6. Cls 0,0,200
  7. for a=0 to e
  8. for v=0 to s
  9.     PutPixel 60+2*(v+a+1), 60+2*(a+119-((-cos(a/e*2*pi-pi*2)*.25)*(-sin(v/s*8*pi-pi*8)*.25)*80)),0xffffff
  10. next
  11. next
  12. Text 328,8,12,"INTEL CARPET"
  13. WaitKey
  14. WinEnd
  15.  

5.
Code: OxygenBasic
  1. include "asm.inc"
  2. window 640,480,1
  3. SetFrames (100)
  4.  
  5. LoadImage("gfx/bk1.bmp",1)
  6. LoadImage("gfx/bk3.bmp",1)
  7. LoadImage("gfx/bk4.bmp",1)
  8.  
  9. sys yg=32,yb=96,yc=160
  10.  
  11. while KeyDown(VK_ESCAPE)=0
  12. for i=0 to 240
  13.     Color i+15,0,0
  14.     Line 0,i,640,i
  15.     Color 255-i,0,0
  16.     Line 0,i+240,640,i+240
  17. Next
  18. Color 255,255,255
  19. Text( 156,230,36,"CROSSBARS" )
  20. BlendImage 1,0,yc,640,32,180
  21. BlendImage 2,0,yg,640,32,180
  22. BlendImage 3,0,yb,640,32,180
  23. yg -=1
  24. yb +=1
  25. yc -=1
  26. if yg <=-64 then yg=480
  27. if yb >=480 then yb=-64
  28. if yc <=-64 then yc=480
  29. Flip()
  30. wend
  31. WinEnd
  32.  

6.
Code: OxygenBasic
  1. include "asm.inc"
  2. window 1024,768,1
  3. setframes 60
  4.  
  5. sys x,y
  6. float a,i
  7. CenterMousePos()
  8.  
  9. while Key(27)=0
  10. cls 0,0,0
  11. for i=0 to 360 step .1
  12.     x = sin(i+a)*50 - cos(i-a)*i
  13.     y = cos(i+a)*50 + sin(i-a)*i
  14.     color mod(i,128)+127,mod(i,64)+127,mod(i,32)+127  
  15.     FillCircle x+xMouse()-50,y+yMouse()-50, sin(i)*10
  16.  next  
  17. a +=.03
  18. if a >=360 then a=-a
  19. Flip()
  20. wend
  21. winEnd
  22.  
« Last Edit: April 07, 2018, 09:13:47 PM by o2admin »

JRS

  • Guest
Re: asm library
« Reply #1 on: April 07, 2018, 12:32:05 PM »
Thanks Peter!

Please don't be so sensitive this time and stick around. ALL your contributions are appreciated. Charles wouln't include them in the O2 distribution if they weren't.

I'm working on converting your asm.inc to a Script BASIC / DLLC option.

jack

  • Guest
Re: asm library
« Reply #2 on: April 07, 2018, 06:26:20 PM »
thank you Peter :)
may I suggest that you enclose source code in code tags ?
that way
Code: [Select]
8) won't look like 8)
« Last Edit: April 07, 2018, 07:02:34 PM by jack »

JRS

  • Guest
Re: asm library
« Reply #3 on: April 07, 2018, 06:37:42 PM »
Besides the code enclosure feature you're able to disable smiley's in the Attachments and other options section of your message editor.

JRS

  • Guest
Re: asm library
« Reply #4 on: April 07, 2018, 08:10:07 PM »
Peter,

How close is your sw.inc (Simple Windows) include to your new asm.inc include file?

Peter

  • Guest
Re: asm library
« Reply #5 on: April 08, 2018, 02:47:49 AM »
Hi John,

the sw.inc is outdated, is not stable and erroneous.
do not use it !

the asm.inc is a new project, much stabler, more functions and  good for games and ohter applications.

will permanently at it worked, untill the doctor comes.

by the way, thanks for the tips  you gave me.

Peter

 


Peter

  • Guest
Re: asm library
« Reply #6 on: April 08, 2018, 03:21:32 AM »
Hello,

asm library updated.
please, use only this library.

own api's demo
Code: [Select]
include "asm.inc"
window 640,480,1

LoadImage "gfx/greentoy.bmp",1

! GetDC  Lib "user32.dll" (sys hdc) as sys
! BitBlt Lib "gdi32.dll"  (sys hdc,xscr,yscr,width,height,dsthdc,xdst,ydest,rob)
! StretchBlt Lib "gdi32.dll" (sys DstHdc,xDst,yDst,wDst,hDst,ScrHdc,xScr,yScr,wScr,hScr,rop) as sys
! SetStretchBltMode Lib "gdi32.dll" (sys hdc,mode) as sys

w = ScreenW
h = ScreenH
hwnd = GetHwnd()
bHdc = GetBufferDC()
hdc  = GetDC(hwnd)

Image 1,0,0
WinText "AN EASY DEMO"
while KeyDown(27)=0
DoEvents()   'important!
StretchBlt(hdc,0,0,w,h,bHdc,0,0,imageW(1),imageH(1),0xCC0020)
Wait 10
wend
WinEnd()
some particles
Code: [Select]
include "asm.inc"
window 800,400,1
ShowMouse (off)
CenterMousePos()

single particle0[1000]
single particle1[1000]
single particle2[1000]
single particle3[1000]
single particle4[1000]
single particle5[1000]
single degree1[360]
single degree2[360]
int max=1000

for i=0 to 359
    degree1[i]=sin(i)
    degree2[i]=cos(i)
next
for i=0 to max-1
    particle4[i]=0
next

while KeyDown(VK_ESCAPE)=0
Color 200,200,200
FillCircle xMouse()-36,yMouse()-32,20
FillCircle xMouse()+18,yMouse()-32,20
color 255,100,50
FillCircle xMouse()-20,yMouse()-32,40
Color 0,220,0
DrawPoint xMouse()-10,yMouse()-22,4
DrawPoint xMouse()+04,yMouse()-22,4
for k=1 to 7
spawni=Rand(1,max)-1
if particle4[spawni] = 0
   particle0[spawni] = xMouse()
   particle1[spawni] = yMouse()-5
   particle2[spawni] = degree1[Rand(1,359)]/2
   particle3[spawni] = degree2[Rand(1,359)]/2
   particle4[spawni] = Rand(100,249)
   particle5[spawni] = particle4[spawni]/5
end if
next

for i=0 to max-1
if particle4[i] >0
   particle0[i] = particle0[i] + particle2[i]
   particle1[i] = particle1[i] + particle3[i]
   particle3[i] = particle3[i] + Rand(1,10)/100
   particle4[i] = particle4[i]-1
   if particle1[i] >399
      particle3[i] = -particle3[i]*(Rand(1,10)/20)
   end if
end if
next

for i=0 to max-1
Color 0,0,0
if particle4[i] > 0 then
if particle4[i]< particle5[i]
   Color 128,128,128
end if
if particle4[i]> (particle5[i])
   color 255,255,255
end if
if particle4[i]> (particle5[i]*2)
   Color 196,196,196
end if
if particle4[i]> (particle5[i]*3)
   Color 96,96,96
end if
if particle4[i]> (particle5[i]*4)
   color 82,82,82
end if
fillcircle particle0[i],particle1[i],6
end if
next
Color 255,255,255
text 260,16,16,"PARTICLE APE"
Flip()
Wait (10)
Cls 5,20,255
wend
WinEnd
mutation
Code: [Select]
include "asm.inc"
window 640,480,1
SetFrames (60)

Sub Draw(single x,y)
    sx = x-40
    sy = y-40
    fillcircle sx, sy, 80
End Sub

single i,a

while key(27)=0
cls 128,128,28
for i=1 to 6.4 step .1
    x = sin(i) * 100 + 200
    y = cos(i) * 100 + 200
    Color mod(i*70,255),mod(i*60,255),mod(i*50,255)
    Draw( x+100+sin(a*i)*70,y+20+cos(a*i)*50 )
next
a +=.01
if a >=360 then a =-a
Color 255,255,255
Text 220,8,14,"WHAT IS THAT!"
Flip()
wend
winEnd
Fun game
Code: [Select]
click on all stars.
is only a joke.

include "asm.inc"
window 640,480,1
SetFrames 60

sys x,y,a,zx,zy,co,w
sys Area [300]
sys xBang[32]
sys yBang[32]
sys zBang[32]

LoadTile ("gfx/stars32.bmp",16,2) 'returns 1
LoadImage("gfx/spark18.bmp",18)   'returns 1
LoadImage("gfx/space.bmp",1)      'returns 2

LoadWav("gfx/magic.wav")          'returns 1
LoadWav("gfx/laugh.wav")          'returns 2

for y=1 to 14
for x=1 to 19
    z = y*20+x
    a = Rnd(11)
    if a=1
       Area[z]=1
       co +=1
    end if
next
next

Sub ShowArea()
for y=0 to 14
for x=0 to 19
    z = y*20+x
    if Area[z]=1 then DrawTile(1,x*32,y*32,zx,zy)
next
next
zx +=1
if zx=16
   zx=0
   zy +=1
   if zy=2 then zy=0
end if
End Sub

Sub Buffer(sys bx,by)
for c=0 to 31
    if yBang[c] = 0
       yBang[c] = by
       xBang[c] = bx
       Return 0
    end if
next
End Sub

Sub Mouse()
mx = trunc(xMouse()/32)
my = trunc(yMouse()/32)
z = my*20+mx
if MouseButton()=1 and Area[z]=1
   Buffer mx*32,my*32
   Area[z]=0
   co -=1
   Playwav 1
end if
End Sub

Sub Bang()
for x=0 to 31
if yBang[x] >0
for b=0 to 3
    ScaleImage 1,xBang[x]-16,yBang[x]-16,64,64,zBang[x]
next
zBang[x] +=1
if zBang[x] = 18
   zBang[x] = 0
   yBang[x] = 0
   xBang[x] = 0
end if
end if
next
End Sub

while KeyDown(VK_ESCAPE)=0
Image 2,0,0
ShowArea()
Mouse()
Bang()
Color 254,197,32
Text(8,8,24,"STARS " & co)
if co=0
   Color 255,255,255
   Text 200,200,24,"YOU HAVE WON"
   Text 200,230,26,"PRESS ESCAPE"
   if w=0 
      PlayWav 2
      w=1
   end if     
end if
Flip()
wend
WinEnd
« Last Edit: April 08, 2018, 09:13:24 AM by Peter »

Peter

  • Guest
Re: asm library
« Reply #7 on: April 08, 2018, 03:39:51 AM »
can someone tell me how to disable the face icons.

Peter

Charles Pegge

  • Guest
Re: asm library
« Reply #8 on: April 08, 2018, 04:47:50 AM »
Hi Peter,

Put your code between code and /code with square brackets

I've done it for you. :)

chrisc

  • Guest
Re: asm library
« Reply #9 on: April 08, 2018, 07:17:37 AM »
Thanxx a lot Peter

maybe could you please convert the asm.dll to 64bit? as i'm interested in 64bits graphics

JRS

  • Guest
Re: asm library
« Reply #10 on: April 08, 2018, 09:25:42 AM »
Peter,

How about renaming your asm.inc to pgl.inc (Peter's Graphic Library)?

JRS

  • Guest
Re: asm library
« Reply #11 on: April 08, 2018, 01:54:41 PM »
Peter,

Can I use your library to create a canvas in something else other than a dialog window?

Peter

  • Guest
Re: asm library
« Reply #12 on: April 08, 2018, 02:27:06 PM »
Hi John,

if you like to use the library then do it.

Peter

Mike Lobanovsky

  • Guest
Re: asm library
« Reply #13 on: April 08, 2018, 04:25:48 PM »
John,

Peter's window ... is not a dialog but rather a general purpose (a.k.a. frame) window.

Using WinAPI like in his first demo, you can draw on any canvas, even in the console window, but most of his "keywords" (cls, color, fillcircle, etc.) will work only in his own window ... .

Arnold

  • Guest
Re: asm library
« Reply #14 on: April 08, 2018, 10:46:31 PM »
Hi Peter,

I used OxygenBasicProgress of 29/03/2018 to run your demos. They work quite well, only the particles demo will give an error message in line 38/39:
index expression complexity [..]. This can be solved quite easily:

'   particle2[spawni] = degree1[Rand(1,359)]/2
'   particle3[spawni] = degree2[Rand(1,359)]/2
   int r=Rand(1,359) : particle2[spawni] = degree1[r]/2
        r=Rand(1,359) : particle3[spawni] = degree2[r]/2

Are you still using an older installation? The latest release is much more powerful.

Roland