Recent Posts

Pages: [1] 2 3 ... 10
1
Game Development / Re: Function Pointers In Game Logic
« Last post by Caché GB on Today at 08:48:50 PM »
Thanks felipe for the info.

Once again thanks to HSE and Siekmanski. Jump Tables are definitely the goto.

I see that hierarchical complexity can quickly be implemented and for deep nesting, it is possible to have
predetermined or calculated code paths (tree transversal) for rapidly dealing with course and effect. As
daydreamer pointed out "loads array of STATE for 100's of ... and use jump table".

Thanks daydreamer.

Awesome! Welcome to the JUNGLE, Table.

Code: [Select]

.data

szEntityZero   db "I am Entity Zero", 0
szEntityOne    db "I am Entity One", 0
    etc.

g_pBehaviour   dd offset Behaviour00, offset Behaviour00Routine00,  offset Behaviour00Routine01,  offset Behaviour00Routine02
               dd offset Behaviour01, offset Behaviour01Routine00,  offset Behaviour01Routine01,  offset Behaviour01Routine02
               dd offset Behaviour02, offset Behaviour02Routine00,  offset Behaviour02Routine01,  offset Behaviour02Routine02
               dd offset Behaviour03, offset Behaviour03Routine00,  offset Behaviour03Routine01,  offset Behaviour03Routine02
               dd offset Behaviour04, offset Behaviour04Routine00,  offset Behaviour04Routine01,  offset Behaviour04Routine02
               dd offset Behaviour05, offset Behaviour05Routine00,  offset Behaviour05Routine01,  offset Behaviour05Routine02

GameEntity     ENTITY  NumEntities dup (<>)

.code

 ;===========================================>

          ...
          lea  esi, GameEntity
       assume  esi:ptr ENTITY

          mov [esi].ENTITY.MyName, offset szEntityZero
          add  esi, sizeof(ENTITY)
          mov [esi].ENTITY.MyName, offset szEntityOne
          add  esi, sizeof(ENTITY)
             
          etc.

          mov  i, 0
       .while (i < NumEntities)

          invoke  RAND32, 6              ;; RNG by NaN (May 5, 2001)
            imul  eax, 4
             mov  edx, eax
             mAm [esi].ENTITY.BehaviourPtr, [g_pBehaviour+eax*4]
   
          invoke  RAND32, 3
             add  eax, 1
             add  eax, edx
             mAm [esi].ENTITY.RoutinePtr, [g_pBehaviour+eax*4]

             add  esi, sizeof(ENTITY)
             inc  i
        .endw
       assume  esi:
          ...
 ;===========================================>
          ...
         lea  esi, GameEntity
      assume  esi:ptr ENTITY
          mov  i, 0
       .while (i < NumEntities)         
            push  esi
            call [esi].ENTITY.BehaviourPtr
             add  esi, sizeof(ENTITY)
             inc  i
        .endw
       assume  esi:nothing
          ...

;===========================================>

Behaviour00 PROC  Who:PTR ENTITY

          mov  edx, Who
       assume  edx:ptr ENTITY
       invoke  MessageBoxA, null, CSTR("Acting out Behaviour 0"),  [edx].ENTITY.MyName, MB_OK   

          mov  edx, Who
         call [edx].ENTITY.RoutinePtr
       assume  edx:nothing
          ret

Behaviour00 ENDP

    Behaviour00Routine00 PROC
       invoke  MessageBoxA, null, CSTR("while doing 0s Routine 0"),  [edx].ENTITY.MyName, MB_OK
          ret
    Behaviour00Routine00 ENDP

    Behaviour00Routine01 PROC
       invoke  MessageBoxA, null, CSTR("while doing 0s Routine 1"),  [edx].ENTITY.MyName, MB_OK
          ret
    Behaviour00Routine01 ENDP

    Behaviour00Routine02 PROC
       invoke  MessageBoxA, null, CSTR("while doing 0s Routine 2"),  [edx].ENTITY.MyName, MB_OK
          ret
    Behaviour00Routine02 ENDP

  etc.

;==================================================================>

2
Game Development / Re: Function Pointers In Game Logic
« Last post by daydreamer on Today at 08:24:08 PM »
I think for finite state machine,its great to have a jumptable,just make a loop that loads array of State for 100's of enemies and use jumptable
also useful for the right image for 2d sprite for enemies/player character,depending on direction it points at and moves,action like fire a gun,jump,nonaction idle I seen in some games,the PC falls asleep after certain milliseconds inaction
3
The Workshop / Re: About fpu
« Last post by jj2007 on Today at 07:51:14 PM »
What is LUTS?
4
The Laboratory / Re: Hardware Enumerator [pre-release]
« Last post by AW on Today at 07:46:45 PM »
It is all right then, but this sort of bugs are very easily debugged when we have the source.
It is also easy without source, but nobody will do it to help you.  :biggrin:
So, it is all in your hands. :t
5
The Workshop / Re: About fpu
« Last post by daydreamer on Today at 07:10:40 PM »
the fpu is easy to use for sine,cosine etc,compared to know advanced math to code taylor series in SSE,but best is to use fpu initializing LUTS and 1/x of most common divisions in innerloop and SIMD in innerloop for speed,especially if you choose to use MMX/SSE2 integer instructions,you need to use fixed point math with most common divisions,exchanged with mul with their reciprocals,because it lacks division opcodes
and if you use RCPPS/MULPS combination,RCP might lack the precision you need,but a stored reciprocal precalculated with fpu fix this when its just a constant
you also avoid getting "division by zero" with this
6
GoAsm / Re: GetDIBits instruction
« Last post by Yuri on Today at 07:09:47 PM »
Code: [Select]
invoke WriteFile, [hFile], addr bmfHeader, sizeof BITMAPFILEHEADER, \
                    addr dwBytesWritten, 0
invoke WriteFile, [hFile], addr bi, sizeof BITMAPINFOHEADER, \
                    addr dwBytesWritten, 0
invoke WriteFile, [hFile], addr bitmap, [dwBmpSize], addr dwBytesWritten, 0
7
UASM Assembler Development / Re: Symbol not defined
« Last post by habran on Today at 05:34:27 PM »
Keep up good job :t
Are you using the modified exe or normal one?
Try to switch them.
8
UASM Assembler Development / Re: Symbol not defined
« Last post by Biterider on Today at 04:52:17 PM »
Hi
Short update: I created a small project of 8 files, where one includes the next. Since I could not trigger the described problem, I went back to a more complex project and found that the line number correct but not the filename.
Maybe that helps a bit  ;)
I will try different things with the test case.

Biterider
9
The Laboratory / Re: Hardware Enumerator [pre-release]
« Last post by Raistlin on Today at 03:19:23 PM »
Thanks FORTRANS - I will definitely PM you some test pieces.

@AW:
Quote
If I were you I would publish the source code of the .dll
Nothing in there is secret. No need to hide it and use a compressor on top to hide more

Currently the dll is part of a larger project, sponsored by the university and thus subject to ethics clearance.
I would need to request permission to publish the source. Perhaps end of the year.
- that's after the small bug is dealt with and I'am sure it runs stable. :t
10
The Workshop / Re: Old Intel manuals
« Last post by hutch-- on Today at 01:19:27 PM »
> You have to admit that MS-DOS "calling convention" was more like a fastcall

What goes around, comes around but Interrupts at the time was closely related to an unreliable means of contraception.  :P
Pages: [1] 2 3 ... 10