flat assembler
Message board for the users of flat assembler.

Index > Windows > Tetris game, first approach

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Now your game could be qualified as a "Spyware" because it successfully disclosed the color of my desktop. Very Happy
Post 23 Jan 2012, 14:21
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
JohnFound wrote:
Now your game could be qualified as a "Spyware" because it successfully disclosed the color of my desktop. Very Happy


Very Happy


Ha ha, yes, but an stupid spyware because it disclosed the color of my desktop too...

Well, counter clock wise rotation was easy, so I did it alredy... it should works now in that way. Regarding background color, now it is COLOR_CAPTIONTEXT... yes it is configurable too, but i do not want to use a function to do it... who in the world would configure its COLOR_CAPTIONTEXT to a color distinct of black? Anyway it is only for fun, so...

Regards


Description:
Download
Filename: TetrisWF1.zip
Filesize: 3.84 KB
Downloaded: 54 Time(s)

Post 23 Jan 2012, 15:03
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Why not to use simple color like $000000?
Post 23 Jan 2012, 15:21
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
Well, what i do is:

start:
invoke GetModuleHandle, NULL
mov [wc.hInstance], eax
mov [wc.lpfnWndProc], WndProc
mov [wc.lpszClassName], NombreClase
mov [wc.hbrBackground], cdColFondo
stdcall WinMain, [wc.hInstance], NULL, NULL, SW_SHOWNORMAL
invoke ExitProcess, [wMsg.wParam]

Surely it must be many ways to set the background color apart of this one... using a black rectangle in the whole window, but this is needed to do everytime... surely there must be another easier way... the easiest method i thought was that...

Regards
Post 23 Jan 2012, 15:46
View user's profile Send private message Visit poster's website Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
This program looks for the file WFTetris.txt in the same folder that it is, if it does not find it, create it (hidden) with initial data for storing user, level and score. Next time the program runs (and the file already exists) open it and sort (bubble) descending its data according to the score field and dump this data to the file.

Regards


Description:
Download
Filename: TET.zip
Filesize: 22.95 KB
Downloaded: 48 Time(s)

Post 25 Jan 2012, 16:49
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
BTW, the latest published version of the game, crashed on $401932 (rep movsd) - you are trying to write to the address $401fe8, but it seems to be read only.
Post 26 Jan 2012, 07:46
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
Ok, thank you. I have also seen something wrong... I will revise it...

Regards
Post 26 Jan 2012, 08:25
View user's profile Send private message Visit poster's website Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
There were an error in BubbleSort method that I've just fixed... I hope. The last procedure is this:

Code:
proc BubleSort uses ecx esi edi
    ;  Propósito: Ordena el búfer de marcadores según los marcadores, de mayor a menor
    ;  Entrada  : Ninguna
    ;  Salida   : Ninguna
    ;  Destruye : EAX
    mov      esi, 0
    mov      cl, cdNumRScore-1
    @bs_BucleExt:
      mov      ch, cl
      mov      edi, esi
      add      edi, stFilScoreLen  ;13
      @bs_BucleInt:
        mov      eax, [vmDatosPlay+esi+9]   ; Comparamos marcadores
        cmp      eax, [vmDatosPlay+edi+9]
        jge      @bs_Next1
          stdcall  Swap
        @bs_Next1:
        add      edi, stFilScoreLen  ;13
        dec      ch
      jnz      @bs_BucleInt
      add      esi, stFilScoreLen  ;13
      dec      cl
    jnz      @bs_BucleExt
    ret
endp    


Regards


Description:
Download
Filename: TET.zip
Filesize: 5.76 KB
Downloaded: 49 Time(s)

Post 26 Jan 2012, 09:49
View user's profile Send private message Visit poster's website Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
Maybe it would be good for a dynamic background for score reports...


Description:
Download
Filename: StarsWF1.zip
Filesize: 1.25 KB
Downloaded: 32 Time(s)

Post 27 Jan 2012, 09:54
View user's profile Send private message Visit poster's website Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
This new 3d starfield version writes down the score text content. It works rather well, i think, but not completely. It has no flickering, but if another window overlap it, some funny things occurs (logical, by other hand). I have to review also the code in order it can paint wider names. In other hand, i suspect that rd variables can interactuate with system organization memory, perhaps is it better use rd variables not at the end of the code?... I should prove it... or perhaps using memory reservations...

Thank you.


Description:
Filesize: 7.3 KB
Viewed: 2165 Time(s)

3dStarfield.png


Description:
Download
Filename: StarsWF4.zip
Filesize: 2.08 KB
Downloaded: 37 Time(s)

Post 30 Jan 2012, 17:19
View user's profile Send private message Visit poster's website Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
Some changes has been made:

1) This time, black background forever, does not depends on Windows Configurations
2) 3d Double buffering starfield
3) About info added to system menu
4) Fixed bug on the score report on length name
5) Now, there's no problem on overlapping windows

Changes that are needed to apply:
1) I believe Windows memory allocation overlaps rd variables, may be the best solution be to reserving memory...

BTW, anyone interested?


Description:
Download
Filename: StarsWF5.zip
Filesize: 2.37 KB
Downloaded: 37 Time(s)

Post 31 Jan 2012, 17:21
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1419
Location: Toronto, Canada
AsmGuru62
"...Windows memory allocation overlaps rd variables..."

Can you explain that in detail?
What do you mean by this?
Post 31 Jan 2012, 17:49
View user's profile Send private message Send e-mail Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
Well, i'm not sure, it is only a suspect. When I define no initialized variables with "rd" (reserve double word) it does not get place in the final executable, so, when you execute it, Windows allocate memory for it, but for the executable size, where rd variable do not be, so, it can use unused memory by the rd variables. But, because Windows is a multitasking system, if it has to allocate memory for other application, it could take the memory where rd variables are. In a monotasking system like DOS it works well because all the memory available is assigned to the application.

Well, I'm not sure if this works as it, only I guess it, in any case nothing will go wrong if i take all this rd variables into a reservation memory. I begin to worry if, even so, keeps on failing, it would be the code who were wrong. It is possible that, for any change, any pointer changes to anywhere in the memory that it has not to.

I need to do some proves... and look for information... that's all
Post 01 Feb 2012, 08:40
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17716
Location: In your JS exploiting you and your system
revolution
avcaballero wrote:
But, because Windows is a multitasking system, if it has to allocate memory for other application, it could take the memory where rd variables are.
This will never happen.

Don't worry about it, the OS won't screw with your memory allocations.
Post 01 Feb 2012, 09:30
View user's profile Send private message Visit poster's website Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
Sad These are bad news, revolution, because it means that somewhere in my code exists a bug Wink...

Anyway I will revise the code... and probably will use reserving memory

Regards
Post 01 Feb 2012, 09:46
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1419
Location: Toronto, Canada
AsmGuru62
@avcaballero:
It depends where you use that RD directive.

If this is used in a 'data' section, then memory reserved by RD is included into EXE file and NOT allocated by Windows. Also, this memory initialized to zeroes -- at least that is what I can see in debugger.

If the RD is used in a local variable declaration, then this memory is also NOT allocated by Windows with any allocation techniques - it is instead allocated on stack by FASM itself, when it builds the EXE file.

Something is interesting going on here... as you said -- most likely a bug.
Post 01 Feb 2012, 14:38
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17716
Location: In your JS exploiting you and your system
revolution
AsmGuru62 wrote:
If this is used in a 'data' section, then memory reserved by RD is included into EXE file and NOT allocated by Windows.
It goes slightly deeper than that. If you include non-initialised data at the end of a section then it won't appear in the exe file, but is allocated at program start-up by the Windows loader.
Post 01 Feb 2012, 14:46
View user's profile Send private message Visit poster's website Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
Well, as i can see, when define non-initialized variables (see Test01.asm, 2048 bytes exe resulting) they are not added to executable; but when I initialized them, they are added (see Test02.asm, 6144 bytes exe resulting). What I do not understand yet is how can Windows know that has to reserve memory also for non-initialized variables... I suppose that it could look inside the program and check if in it something point outside the program... but... if I do want to point outside my program to anything else...

Well, I don't know... I need to study it a bit.

Regards


Description:
Download
Filename: Test.zip
Filesize: 3.82 KB
Downloaded: 37 Time(s)

Post 01 Feb 2012, 15:46
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17716
Location: In your JS exploiting you and your system
revolution
avcaballero wrote:
What I do not understand yet is how can Windows know that has to reserve memory also for non-initialized variables...
The PE format structures for each section support two fields for size: Size-on-disk and size-in-memory.
Post 01 Feb 2012, 15:48
View user's profile Send private message Visit poster's website Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 192
Location: Madrid - Spain
avcaballero
Well, just another version where everything have been joined, hence we have tetris game, and the hall of fame, with the gamers' figures over a 3d starfield background.

Still remains bugs to be fixed:

* sometimes hungs up
* a bit of flickering in main window
* revise the code

Regards


Description:
Download
Filename: TetrisWF2.zip
Filesize: 5.44 KB
Downloaded: 40 Time(s)


_________________
Siempre aprendiendo
Post 03 Feb 2012, 08:02
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.