First3D.EXE. Help please!!!
category: general [glöplog]
Hi ! Help me pelase ! This is my first opengl program (in fasm). But something is wrong ! Proc LoadImage returns "0". So texturemaping doesn't works :( Also some problems with perspective (it doesn't works to :( ) Please HELP !
Full source at http://www.tylerdurden.nm.ru/3d.zip
----------- --------------- --------------- --------------
format PE GUI 4.0
entry start
include '%fasminc%\win32a.inc'
include 'opengl_const.inc'
include 'ext.inc'
start:
xor ebx,ebx
invoke GetModuleHandle,ebx
mov [hInstance],eax
invoke LoadIcon,eax,1
mov [wc.hIcon],eax
mov [wc.hCursor],eax
mov [wc.lpfnWndProc],WindowProc
mov eax,[hInstance]
mov [wc.hInstance],eax
mov [wc.lpszClassName],szClass
invoke RegisterClass,wc
invoke CreateWindowEx,ebx,szClass,szTitle,WS_VISIBLE+WS_POPUP+WS_CLIPSIBLINGS+WS_CLIPCHILDREN,ebx,ebx,[screenWidth],[screenHeight],ebx,ebx,[hInstance],ebx
mov [hInstance],eax
msg_loop:
invoke InvalidateRect,[hInstance],ebx,ebx
invoke TranslateMessage,msg
invoke DispatchMessage,msg
invoke GetMessage,msg,ebx,ebx,ebx
test eax,eax
jz end_loop
jmp msg_loop
end_loop:
invoke ExitProcess,[msg.wParam]
proc WindowProc,hwnd,wmsg,wparam,lparam
enter
push ebx esi edi
cmp [wmsg],WM_CREATE
jz .wmcreate
cmp [wmsg],WM_SIZE
jz .wmsize
cmp [wmsg],WM_PAINT
jz .wmpaint
cmp [wmsg],WM_KEYDOWN
jz .wmkeydown
cmp [wmsg],WM_DESTROY
jz .wmdestroy
.defwndproc:
invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
jmp .finish
.wmcreate:
;fullscreen
mov [dmScreenSettings.dmSize],sizeof.DEVMODE
push [screenWidth]
pop [dmScreenSettings.dmPelsWidth]
push [screenHeight]
pop [dmScreenSettings.dmPelsHeight]
mov [dmScreenSettings.dmBitsPerPel],screenBPP
mov [dmScreenSettings.dmDisplayFrequency],screenFreq
mov [dmScreenSettings.dmFields],DM_BITSPERPEL+DM_PELSWIDTH+DM_PELSHEIGHT+DM_DISPLAYFREQUENCY
invoke ChangeDisplaySettings,dmScreenSettings,CDS_FULLSCREEN
;cursor hide
invoke ShowCursor,ebx
;init opengl
invoke GetDC,[hwnd]
mov [hdc],eax
mov [pfd.nSize],sizeof.PIXELFORMATDESCRIPTOR
mov [pfd.nVersion],1
mov [pfd.dwFlags],PFD_SUPPORT_OPENGL+PFD_DOUBLEBUFFER+PFD_DRAW_TO_WINDOW
mov [pfd.dwLayerMask],PFD_MAIN_PLANE
mov [pfd.iPixelType],PFD_TYPE_RGBA
mov [pfd.cColorBits],screenBPP
mov [pfd.cDepthBits],16
invoke ChoosePixelFormat,[hdc],pfd
invoke SetPixelFormat,[hdc],eax,pfd
invoke wglCreateContext,[hdc]
mov [hrc],eax
invoke wglMakeCurrent,[hdc],[hrc]
invoke GetClientRect,[hwnd],rc
invoke glViewport,ebx,ebx,[rc.right],[rc.bottom]
;z-buffer
invoke glClearDepth,ebx
invoke glDepthFunc,GL_GEQUAL
invoke glEnable,GL_DEPTH_TEST
;blending - works strange :(
;invoke glColor4f,1.0f,1.0f,1.0f,0.5f
;invoke glBlendFunc,GL_SRC_ALPHA,GL_ONE
;invoke glEnable,GL_BLEND
;perspective
invoke glHint,GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST
;lighting
invoke glShadeModel,GL_SMOOTH
invoke glLightfv,GL_LIGHT0,GL_AMBIENT,LightAmbient
invoke glLightfv,GL_LIGHT0,GL_POSITION,LightSourcePosition
invoke glEnable,GL_LIGHT0
invoke glEnable,GL_NORMALIZE
invoke glEnable,GL_LIGHTING
;fog
invoke glFogi,GL_FOG_MODE,GL_LINEAR
invoke glFogfv,GL_FOG_COLOR,fogColor
invoke glFogf,GL_FOG_DENSITY,0.1f
invoke glHint,GL_FOG_HINT,GL_DONT_CARE
invoke glFogf,GL_FOG_START,0.6f
invoke glFogf,GL_FOG_END,0.0f
invoke glEnable,GL_FOG
;texture - no works !
invoke glGenTextures,1,texture
invoke LoadImage,[hInstance],texture_back,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION
test eax,eax
jnz .loadOK
invoke MessageBox,HWND_DESKTOP,er,er,MB_OK
.loadOK:
mov [hBack],eax
invoke GetObject,[hBack],sizeof.BITMAP,infoBack
invoke glBindTexture,GL_TEXTURE_2D,[texture]
invoke glTexImage2D,GL_TEXTURE_2D,0,3,[infoBack.bmWidth],[infoBack.bmHeight],0,GL_BGR_EXT,GL_UNSIGNED_BYTE,infoBack.bmBits
invoke glTexParameteri,GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
invoke glTexParameteri,GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
invoke glEnable,GL_TEXTURE_2D
;lists
invoke glNewList,cube,GL_COMPILE
invoke glBegin,GL_QUADS
invoke glBindTexture,GL_TEXTURE_2D,[texture]
invoke glNormal3f,ebx,ebx,0.5f
invoke glTexCoord2f,0.0f,0.0f
invoke glVertex3f,-0.4f,-0.4f,-0.4f
invoke glTexCoord2f,0.0f,1.0f
invoke glVertex3f,-0.4f,0.4f,-0.4f
invoke glTexCoord2f,1.0f,1.0f
invoke glVertex3f,0.4f,0.4f,-0.4f
invoke glTexCoord2f,1.0f,0.0f
invoke glVertex3f,0.4f,-0.4f,-0.4f
invoke glNormal3f,ebx,ebx,-0.5f
invoke glVertex3f,-0.4f,-0.4f,0.4f
invoke glVertex3f,-0.4f,0.4f,0.4f
invoke glVertex3f,0.4f,0.4f,0.4f
invoke glVertex3f,0.4f,-0.4f,0.4f
invoke glNormal3f,0.5f,ebx,ebx
invoke glVertex3f,-0.4f,-0.4f,-0.4f
invoke glVertex3f,-0.4f,0.4f,-0.4f
invoke glVertex3f,-0.4f,0.4f,0.4f
invoke glVertex3f,-0.4f,-0.4f,0.4f
invoke glNormal3f,-0.5f,ebx,ebx
invoke glVertex3f,0.4f,0.4f,0.4f
invoke glVertex3f,0.4f,0.4f,-0.4f
invoke glVertex3f,0.4f,-0.4f,-0.4f
invoke glVertex3f,0.4f,-0.4f,0.4f
invoke glNormal3f,ebx,-0.5f,ebx
invoke glVertex3f,-0.4f,0.4f,0.4f
invoke glVertex3f,-0.4f,0.4f,-0.4f
invoke glVertex3f,0.4f,0.4f,-0.4f
invoke glVertex3f,0.4f,0.4f,0.4f
invoke glNormal3f,ebx,0.5f,ebx
invoke glVertex3f,-0.4f,-0.4f,0.4f
invoke glVertex3f,-0.4f,-0.4f,-0.4f
invoke glVertex3f,0.4f,-0.4f,-0.4f
invoke glVertex3f,0.4f,-0.4f,0.4f
invoke glEnd
invoke glEndList
xor eax,eax
jmp .finish
.wmsize:
mov eax,[lparam]
mov ebx,eax
and eax,0ffffh
shr ebx,16
mov [screenWidth],eax
mov [screenHeight],ebx
cmp [screenHeight],0
jnz .nz
inc [screenHeight]
.nz:
invoke glViewport,0,0,[screenWidth],[screenHeight]
invoke glMatrixMode,GL_PROJECTION
invoke glLoadIdentity
fild [screenWidth]
fild [screenHeight]
fdivp st1,st0
fstp [ratio]
;DOESN'T WORKS !!! ;invoke gluPerspective,const_45d1,const_45d0,dword [ratio],dword [ratio+4],const_01d1,const_01d0,const_100d1,const_100d0
invoke glMatrixMode,GL_MODELVIEW
invoke glLoadIdentity
jmp .finish
.wmpaint:
;clear
invoke glClear,GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
invoke glClearColor,0.5f,0.5f,0.5f,1.0f
;rotate
invoke glRotatef,[theta],0.2f,0.3f,0.1f
;cube
invoke glCallList,cube
;draw buffer
invoke SwapBuffers,[hdc]
xor eax,eax
jmp .finish
.wmkeydown:
cmp [wparam],VK_ESCAPE
jnz .defwndproc
.wmdestroy:
;exit
invoke wglMakeCurrent,ebx,ebx
invoke wglDeleteContext,[hrc]
invoke ReleaseDC,[hwnd],[hdc]
invoke PostQuitMessage,ebx
xor eax,eax
.finish:
pop edi esi ebx
return
data import
include 'imports.inc'
end data
data resource
include 'resources.inc'
end data
const_100d0 equ 1079574528
const_100d1 equ ebx
const_01d0 equ 1069128089
const_01d1 equ -1717986918
const_45d0 equ 40468000h
const_45d1 equ ebx
screenBPP=32
screenFreq=85
screenWidth dd 1024
screenHeight dd 768
theta GLfloat 0.5f
fogColor GLfloat 0.5f,0.5f,0.5f,1.0f
LightAmbient GLfloat 0.5f,0.5f,0.5f,0.1f
LightSourcePosition GLfloat 0.0f,0.0f,-2.0f,1.0f
szTitle db 'Tyler Durden 3D',0
szClass db 't3d',0
er db 'Error loading texture',0
cube GLuint 1.0f,1.0f,0.0f
dmScreenSettings DEVMODE
pfd PIXELFORMATDESCRIPTOR
msg MSG
wc WNDCLASS
rc RECT
infoBack BITMAP
hInstance dd ?
hBack dd ?
ratio dq ?
texture GLuint ?
hdc dd ?
hrc dd ?
------------ --------------- --------------- -------------
the end.
Full source at http://www.tylerdurden.nm.ru/3d.zip
----------- --------------- --------------- --------------
format PE GUI 4.0
entry start
include '%fasminc%\win32a.inc'
include 'opengl_const.inc'
include 'ext.inc'
start:
xor ebx,ebx
invoke GetModuleHandle,ebx
mov [hInstance],eax
invoke LoadIcon,eax,1
mov [wc.hIcon],eax
mov [wc.hCursor],eax
mov [wc.lpfnWndProc],WindowProc
mov eax,[hInstance]
mov [wc.hInstance],eax
mov [wc.lpszClassName],szClass
invoke RegisterClass,wc
invoke CreateWindowEx,ebx,szClass,szTitle,WS_VISIBLE+WS_POPUP+WS_CLIPSIBLINGS+WS_CLIPCHILDREN,ebx,ebx,[screenWidth],[screenHeight],ebx,ebx,[hInstance],ebx
mov [hInstance],eax
msg_loop:
invoke InvalidateRect,[hInstance],ebx,ebx
invoke TranslateMessage,msg
invoke DispatchMessage,msg
invoke GetMessage,msg,ebx,ebx,ebx
test eax,eax
jz end_loop
jmp msg_loop
end_loop:
invoke ExitProcess,[msg.wParam]
proc WindowProc,hwnd,wmsg,wparam,lparam
enter
push ebx esi edi
cmp [wmsg],WM_CREATE
jz .wmcreate
cmp [wmsg],WM_SIZE
jz .wmsize
cmp [wmsg],WM_PAINT
jz .wmpaint
cmp [wmsg],WM_KEYDOWN
jz .wmkeydown
cmp [wmsg],WM_DESTROY
jz .wmdestroy
.defwndproc:
invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
jmp .finish
.wmcreate:
;fullscreen
mov [dmScreenSettings.dmSize],sizeof.DEVMODE
push [screenWidth]
pop [dmScreenSettings.dmPelsWidth]
push [screenHeight]
pop [dmScreenSettings.dmPelsHeight]
mov [dmScreenSettings.dmBitsPerPel],screenBPP
mov [dmScreenSettings.dmDisplayFrequency],screenFreq
mov [dmScreenSettings.dmFields],DM_BITSPERPEL+DM_PELSWIDTH+DM_PELSHEIGHT+DM_DISPLAYFREQUENCY
invoke ChangeDisplaySettings,dmScreenSettings,CDS_FULLSCREEN
;cursor hide
invoke ShowCursor,ebx
;init opengl
invoke GetDC,[hwnd]
mov [hdc],eax
mov [pfd.nSize],sizeof.PIXELFORMATDESCRIPTOR
mov [pfd.nVersion],1
mov [pfd.dwFlags],PFD_SUPPORT_OPENGL+PFD_DOUBLEBUFFER+PFD_DRAW_TO_WINDOW
mov [pfd.dwLayerMask],PFD_MAIN_PLANE
mov [pfd.iPixelType],PFD_TYPE_RGBA
mov [pfd.cColorBits],screenBPP
mov [pfd.cDepthBits],16
invoke ChoosePixelFormat,[hdc],pfd
invoke SetPixelFormat,[hdc],eax,pfd
invoke wglCreateContext,[hdc]
mov [hrc],eax
invoke wglMakeCurrent,[hdc],[hrc]
invoke GetClientRect,[hwnd],rc
invoke glViewport,ebx,ebx,[rc.right],[rc.bottom]
;z-buffer
invoke glClearDepth,ebx
invoke glDepthFunc,GL_GEQUAL
invoke glEnable,GL_DEPTH_TEST
;blending - works strange :(
;invoke glColor4f,1.0f,1.0f,1.0f,0.5f
;invoke glBlendFunc,GL_SRC_ALPHA,GL_ONE
;invoke glEnable,GL_BLEND
;perspective
invoke glHint,GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST
;lighting
invoke glShadeModel,GL_SMOOTH
invoke glLightfv,GL_LIGHT0,GL_AMBIENT,LightAmbient
invoke glLightfv,GL_LIGHT0,GL_POSITION,LightSourcePosition
invoke glEnable,GL_LIGHT0
invoke glEnable,GL_NORMALIZE
invoke glEnable,GL_LIGHTING
;fog
invoke glFogi,GL_FOG_MODE,GL_LINEAR
invoke glFogfv,GL_FOG_COLOR,fogColor
invoke glFogf,GL_FOG_DENSITY,0.1f
invoke glHint,GL_FOG_HINT,GL_DONT_CARE
invoke glFogf,GL_FOG_START,0.6f
invoke glFogf,GL_FOG_END,0.0f
invoke glEnable,GL_FOG
;texture - no works !
invoke glGenTextures,1,texture
invoke LoadImage,[hInstance],texture_back,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION
test eax,eax
jnz .loadOK
invoke MessageBox,HWND_DESKTOP,er,er,MB_OK
.loadOK:
mov [hBack],eax
invoke GetObject,[hBack],sizeof.BITMAP,infoBack
invoke glBindTexture,GL_TEXTURE_2D,[texture]
invoke glTexImage2D,GL_TEXTURE_2D,0,3,[infoBack.bmWidth],[infoBack.bmHeight],0,GL_BGR_EXT,GL_UNSIGNED_BYTE,infoBack.bmBits
invoke glTexParameteri,GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
invoke glTexParameteri,GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
invoke glEnable,GL_TEXTURE_2D
;lists
invoke glNewList,cube,GL_COMPILE
invoke glBegin,GL_QUADS
invoke glBindTexture,GL_TEXTURE_2D,[texture]
invoke glNormal3f,ebx,ebx,0.5f
invoke glTexCoord2f,0.0f,0.0f
invoke glVertex3f,-0.4f,-0.4f,-0.4f
invoke glTexCoord2f,0.0f,1.0f
invoke glVertex3f,-0.4f,0.4f,-0.4f
invoke glTexCoord2f,1.0f,1.0f
invoke glVertex3f,0.4f,0.4f,-0.4f
invoke glTexCoord2f,1.0f,0.0f
invoke glVertex3f,0.4f,-0.4f,-0.4f
invoke glNormal3f,ebx,ebx,-0.5f
invoke glVertex3f,-0.4f,-0.4f,0.4f
invoke glVertex3f,-0.4f,0.4f,0.4f
invoke glVertex3f,0.4f,0.4f,0.4f
invoke glVertex3f,0.4f,-0.4f,0.4f
invoke glNormal3f,0.5f,ebx,ebx
invoke glVertex3f,-0.4f,-0.4f,-0.4f
invoke glVertex3f,-0.4f,0.4f,-0.4f
invoke glVertex3f,-0.4f,0.4f,0.4f
invoke glVertex3f,-0.4f,-0.4f,0.4f
invoke glNormal3f,-0.5f,ebx,ebx
invoke glVertex3f,0.4f,0.4f,0.4f
invoke glVertex3f,0.4f,0.4f,-0.4f
invoke glVertex3f,0.4f,-0.4f,-0.4f
invoke glVertex3f,0.4f,-0.4f,0.4f
invoke glNormal3f,ebx,-0.5f,ebx
invoke glVertex3f,-0.4f,0.4f,0.4f
invoke glVertex3f,-0.4f,0.4f,-0.4f
invoke glVertex3f,0.4f,0.4f,-0.4f
invoke glVertex3f,0.4f,0.4f,0.4f
invoke glNormal3f,ebx,0.5f,ebx
invoke glVertex3f,-0.4f,-0.4f,0.4f
invoke glVertex3f,-0.4f,-0.4f,-0.4f
invoke glVertex3f,0.4f,-0.4f,-0.4f
invoke glVertex3f,0.4f,-0.4f,0.4f
invoke glEnd
invoke glEndList
xor eax,eax
jmp .finish
.wmsize:
mov eax,[lparam]
mov ebx,eax
and eax,0ffffh
shr ebx,16
mov [screenWidth],eax
mov [screenHeight],ebx
cmp [screenHeight],0
jnz .nz
inc [screenHeight]
.nz:
invoke glViewport,0,0,[screenWidth],[screenHeight]
invoke glMatrixMode,GL_PROJECTION
invoke glLoadIdentity
fild [screenWidth]
fild [screenHeight]
fdivp st1,st0
fstp [ratio]
;DOESN'T WORKS !!! ;invoke gluPerspective,const_45d1,const_45d0,dword [ratio],dword [ratio+4],const_01d1,const_01d0,const_100d1,const_100d0
invoke glMatrixMode,GL_MODELVIEW
invoke glLoadIdentity
jmp .finish
.wmpaint:
;clear
invoke glClear,GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
invoke glClearColor,0.5f,0.5f,0.5f,1.0f
;rotate
invoke glRotatef,[theta],0.2f,0.3f,0.1f
;cube
invoke glCallList,cube
;draw buffer
invoke SwapBuffers,[hdc]
xor eax,eax
jmp .finish
.wmkeydown:
cmp [wparam],VK_ESCAPE
jnz .defwndproc
.wmdestroy:
;exit
invoke wglMakeCurrent,ebx,ebx
invoke wglDeleteContext,[hrc]
invoke ReleaseDC,[hwnd],[hdc]
invoke PostQuitMessage,ebx
xor eax,eax
.finish:
pop edi esi ebx
return
data import
include 'imports.inc'
end data
data resource
include 'resources.inc'
end data
const_100d0 equ 1079574528
const_100d1 equ ebx
const_01d0 equ 1069128089
const_01d1 equ -1717986918
const_45d0 equ 40468000h
const_45d1 equ ebx
screenBPP=32
screenFreq=85
screenWidth dd 1024
screenHeight dd 768
theta GLfloat 0.5f
fogColor GLfloat 0.5f,0.5f,0.5f,1.0f
LightAmbient GLfloat 0.5f,0.5f,0.5f,0.1f
LightSourcePosition GLfloat 0.0f,0.0f,-2.0f,1.0f
szTitle db 'Tyler Durden 3D',0
szClass db 't3d',0
er db 'Error loading texture',0
cube GLuint 1.0f,1.0f,0.0f
dmScreenSettings DEVMODE
pfd PIXELFORMATDESCRIPTOR
msg MSG
wc WNDCLASS
rc RECT
infoBack BITMAP
hInstance dd ?
hBack dd ?
ratio dq ?
texture GLuint ?
hdc dd ?
hrc dd ?
------------ --------------- --------------- -------------
the end.
#coders forum at scene.org may be a better place for this.
but still, i doubt anyone wants to wade through this...
but still, i doubt anyone wants to wade through this...
the first rule ... just kidding :)
you missed a semi colon.
tyler, are you going to compete in the worlds uggliest code competition ?
This just a test... Thank you for your help
Pantaloon: Damn, you just said it before I did :)
I just think he's polish :)
C'mon men ! I'm just tryin' to study OpenGL. Why nobody can help me ?! This is not an intro ! :) Do you really think I'm tryin' to impress demoscene with foged cube ? :))) This is just my first attempt to write opengl code...
if you wan't help i suggest you write your program in a way that makes them easy to debug. about the code above i must say that a novice student probably writes his code in a more readable fashion.
it could perhaps help to have a few linebreaks between sections, and even some tabs would certainly help. if you do that i'm quite sure your problems will be solved without any interaction from someone else.
it could perhaps help to have a few linebreaks between sections, and even some tabs would certainly help. if you do that i'm quite sure your problems will be solved without any interaction from someone else.
And to re-iterate what deemage said, Pouet.net is not the most appropriate place to ask for a code related question.
Yeah. Why the HELL are you putting assembly to use like THIS? Like Jar commented on IRC earlier, some people should just be precluded from assembly. You can write this kind of a crap in a few lines of C, easier to maintain, easier to extend and just as fast. And easier for us to optically debug (even though a few simple things like Pantaloon said would already help).
If you're trying to learn OpenGL, you're doing it in a darn inefficient way.
When will people STOP thinking that it's cool to write mediocre assembly, putting it to use when they shouldn't :)
If you're trying to learn OpenGL, you're doing it in a darn inefficient way.
When will people STOP thinking that it's cool to write mediocre assembly, putting it to use when they shouldn't :)
quoting from http://skal.planet-d.net/coding/vademecum.html
Rule #2: Optimize on purpose
or: "are you sure you need an ASM version of XOpenDisplay() ??"
Rule #2: Optimize on purpose
or: "are you sure you need an ASM version of XOpenDisplay() ??"
Pouet.net is not the most appropriate place to ask for a code related question.
Yah, asking demosceners code questions is a bad idea.
Yah, asking demosceners code questions is a bad idea.
i won't read the whole thing (which is actually not the whole thing since "loadimage" has an undefined parameter "texture_back", so it is quite hard to tell fromt this what's the problem :)
anyway:
0) loadimage is windows api, not opengl
1) why use loadimage at all? opengl does not need fucking windows DIB bitmaps...
2) tabs suxx, but empty lines would help...
3) when i learned opengl some months ago, my first try was four lines and two quads; only the second try was metaballs :) - so maybe even you should start with something simpler...
4) wtf is fasm? :)
5) this is not the right forum for this thing
anyway:
0) loadimage is windows api, not opengl
1) why use loadimage at all? opengl does not need fucking windows DIB bitmaps...
2) tabs suxx, but empty lines would help...
3) when i learned opengl some months ago, my first try was four lines and two quads; only the second try was metaballs :) - so maybe even you should start with something simpler...
4) wtf is fasm? :)
5) this is not the right forum for this thing
Quote:
o__0Yah, asking demosceners code questions is a bad idea.
hum... ever heard of cfxweb, flipcode, openGl's forum, .... ? These sites are code related, not pouet. In that, Tyler is wasting his ( and the other's ) time asking that here while he could get an answer way faster on the appropriate websites.
blala: fasm (, or "flat assembler") is a quite nice assembler.
http://fasm.sf.net
coding opengl in asm is kind of a waste, unless ofcourse you for some reason are more comfortable with asm than c/c++/whatever. I'm not going to udge that. However, pouet is not a code-forum. As poi² said, try flipcode or something instead.
http://fasm.sf.net
coding opengl in asm is kind of a waste, unless ofcourse you for some reason are more comfortable with asm than c/c++/whatever. I'm not going to udge that. However, pouet is not a code-forum. As poi² said, try flipcode or something instead.
asm and opengl is good when you want a 4k for example... but that can mostly be crunched in with C as well, so why bother? (for fun of course :)
Fasm is great! I was using Nasm but I learned about Fasm after visiting the links section Tyler's site. It's just nice to have a simple environment to compile and run instead of needing to mess up with batch files to do that. I started writting asm in a notepad or the editor of MSDOS on PC, wondering always why, since I started coding with an assembler that comes with an editor in CPC and C64.
Something else that came into my mind (while some people talking about the mess of code or that they don't like tabs :)
I just wondered why on CPC (Z80) it was standard to code like this:
ORG &1000
LD A,0:CALL &BC0E
DI:LD HL,&C9FB:LD (&38),HL
LD HL,&C000:LD DE,&C001:LD BC,16000:LDIR
inc h:inc h:ld a,(hl)
inc l:add a,(hl)
inc l:add a,(hl)
dec h:dec l:add a,(hl)
srl a:srl a
dec h:ld (hl),a
..and what people think about such kind of writting code.
I mean. There is always some : to allow a second command to be near the previous at some lines.
Antitec was coding this way, huge programms, lines that were repeated or lines that are doing a specific work were messed with each other instead being one bellow the other. In such an organized manner.
Someone can see it and think it's a bad code because some people are even writting this way in other machines:
MOV AX,13h
INT 10h
but we are coding
MOV AX,13h: INT 10h
because we have in just one line that this thing goes to 320*200 and we prefer on CPC to have opcodes messed together. It's like watching little paragraphs of code and we know that this paragraph as a whole is doing this thing..
Even great coders on CPC code like this and the common assemblers (Maxam, DAMS) support the symbol : for such things. But Turbo assembler on CPC (which is inspired and look very alike to TASS from C64 btw :), even if my favoritest assembler, don't give this option. Instead it automatically inserts TABs..
On the C64, nobody codes asm in the CPC way. On the PC nobody codes asm in the CPC way. I think it's only a virus of CPC and wondered if I can find such an editor to put the symbol : and have many opcodes in one line. There is a nice reason to put stuff like this (paragraphs of lines doing one work, you can find it easier. Or as Antitec/Dirty Minds who hates the PC asm way, says, if the code of his latest Diskmag Ovation6 was not written in the CPC way, but one line for each opcode, then hell!!! He would need to scroll 40 pages to go to the previous routine (Hmm,. both Maxam and Dams are annoying when it's about scrolling to find a previous routine. Was that perhaps the reason? I say not only..). If you see his code and the big "paragraphs" of opcodes, you will understand why it's more convenient that we code in CPC way. And I would like to find a PC assembler to allow such writting. How else can I manage big projects in asm?)
Just wondered. Preety weird that this kind of writting has dominated the CPC scene, but I don't see it anywhere else..
As for Tyler's question, I'd like to help but I don't have any idea. I only coded a bit of OpenGL with VC++ and I don't prefer asm for such stuff personally. Using APIs from assembly? It's scary for me when it's damn easy to do with VC++. Posting the code was funny however :)
Something else that came into my mind (while some people talking about the mess of code or that they don't like tabs :)
I just wondered why on CPC (Z80) it was standard to code like this:
ORG &1000
LD A,0:CALL &BC0E
DI:LD HL,&C9FB:LD (&38),HL
LD HL,&C000:LD DE,&C001:LD BC,16000:LDIR
inc h:inc h:ld a,(hl)
inc l:add a,(hl)
inc l:add a,(hl)
dec h:dec l:add a,(hl)
srl a:srl a
dec h:ld (hl),a
..and what people think about such kind of writting code.
I mean. There is always some : to allow a second command to be near the previous at some lines.
Antitec was coding this way, huge programms, lines that were repeated or lines that are doing a specific work were messed with each other instead being one bellow the other. In such an organized manner.
Someone can see it and think it's a bad code because some people are even writting this way in other machines:
MOV AX,13h
INT 10h
but we are coding
MOV AX,13h: INT 10h
because we have in just one line that this thing goes to 320*200 and we prefer on CPC to have opcodes messed together. It's like watching little paragraphs of code and we know that this paragraph as a whole is doing this thing..
Even great coders on CPC code like this and the common assemblers (Maxam, DAMS) support the symbol : for such things. But Turbo assembler on CPC (which is inspired and look very alike to TASS from C64 btw :), even if my favoritest assembler, don't give this option. Instead it automatically inserts TABs..
On the C64, nobody codes asm in the CPC way. On the PC nobody codes asm in the CPC way. I think it's only a virus of CPC and wondered if I can find such an editor to put the symbol : and have many opcodes in one line. There is a nice reason to put stuff like this (paragraphs of lines doing one work, you can find it easier. Or as Antitec/Dirty Minds who hates the PC asm way, says, if the code of his latest Diskmag Ovation6 was not written in the CPC way, but one line for each opcode, then hell!!! He would need to scroll 40 pages to go to the previous routine (Hmm,. both Maxam and Dams are annoying when it's about scrolling to find a previous routine. Was that perhaps the reason? I say not only..). If you see his code and the big "paragraphs" of opcodes, you will understand why it's more convenient that we code in CPC way. And I would like to find a PC assembler to allow such writting. How else can I manage big projects in asm?)
Just wondered. Preety weird that this kind of writting has dominated the CPC scene, but I don't see it anywhere else..
As for Tyler's question, I'd like to help but I don't have any idea. I only coded a bit of OpenGL with VC++ and I don't prefer asm for such stuff personally. Using APIs from assembly? It's scary for me when it's damn easy to do with VC++. Posting the code was funny however :)
I tried to overpass the size of Tyler's first post, sorry :)
don't worry, the content value was around the same (= zilch)
but that can mostly be crunched in with C as well, so why bother?
blah. you know that what you are saying is not the truth :)
anyway, using api-s in asm is quite simple. in fact sometimes it seems even simpler than in c (and surely simpler than using those ugly oop-style api-s in c++ :)
but maybe this is not the best way to _learn_ an api...
optimus: write a simple preprocessor which inserts linebreaks instead of those : signs, and pipe the source through it before compiling :)
blah. you know that what you are saying is not the truth :)
anyway, using api-s in asm is quite simple. in fact sometimes it seems even simpler than in c (and surely simpler than using those ugly oop-style api-s in c++ :)
but maybe this is not the best way to _learn_ an api...
optimus: write a simple preprocessor which inserts linebreaks instead of those : signs, and pipe the source through it before compiling :)
>optimus: write a simple preprocessor which inserts linebreaks instead of those : signs, and pipe the source through it before compiling :)
Easy enough! How did I missed this idea???
Easy enough! How did I missed this idea???
blala: note that i said "mostly"
gargaj: "mostly" because most people write their intros in c. that's not a good enough reason to be crap :)