News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

"Hello masm32", not a BOT, new member

Started by LordAdef, January 22, 2017, 09:42:24 AM

Previous topic - Next topic

jj2007

Quote from: LordAdef on February 21, 2017, 06:32:54 AMinvoke GetAsyncKeyState, VK_RIGHT
   AND   ax, 8000h
   cmp ax, 32768
   jz Right

invoke GetAsyncKeyState, VK_RIGHT
test ah, ah
js Right


same result ;)

LordAdef

Quoteinvoke GetAsyncKeyState, VK_RIGHT
   AND   ax, 8000h
   cmp ax, 32768
   jz Right

And I thought I was being very clever here, since I pulled this off by myself! Cheers JJ, I updated the code with your suggestion.

I attached the prog updated with the latest suggestions. I also now have a bitmap airplane, check it out!

I took this bitmap code from Iczelion. It´s a first timer here too among a thousand this week.
Just checking: Do I need to keep all of these inside my PAINT loop?

Quote;-------  AIRPLANE -----------------
        invoke CreateCompatibleDC,hdc
        mov    hMemDC,eax
        invoke SelectObject,hMemDC,hBitmap
        invoke GetClientRect,hWnd,addr rect
        invoke BitBlt,hdc, man.x, man.y, rect.right, rect.bottom, hMemDC, 0, 0, SRCPAINT ;SRCCOPY
         invoke DeleteDC,hMemDC
        ;--------------------------------------------------------------------------------------------------------------

hutch--

You can probably get away with putting the open and close GDI resource code in your startup/exit code but keep an eye on the device context count and also check your memory usage after running the app for a while.

avcaballero


LordAdef


hutch--

This one works well, just downloaded and tested it and the left right keys navigate the plane with no lag at all.  :t

LordAdef

Quote from: hutch-- on February 22, 2017, 12:32:44 PM
This one works well, just downloaded and tested it and the left right keys navigate the plane with no lag at all.  :t

Nice Hutch!

Well, today I complete a full month as part of the Masm32 community!
I guess you wont get rid of me any soon  :eusa_naughty:

I made some small little cleaning, and put some animation for my airplane. Attached the exe, just for fun.

Cheers, Alex

jj2007


LordAdef

Hi guys,

I created another actor for the game, a Bomber. While testing the little guy, I could not make it look right. Its body is transparent although the colour background is fine. Just run the exe and see what I mean (What matters is when inside the map, I left it bleed on the left side on purpose) .

The temp code is this one below (it´s just for test):

Quote;-------------- TESTING ONLY! --------------
          mov eax, map.line
           add eax, edi
         Switch eax   
         Case 470               ;this is line
                 mov bomber.y, ebx
         Endsw
           invoke   SetTextColor,hdc,  colBOMBER
           invoke BitBlt, hdc, bomber.x, bomber.y, 36, 35, hMemDCbomber, 0, bomber.frmy, SRCPAINT ;

The file for the Bomber is "Bomber.bmp", 1 bit.

Any hint on how to work this out?
Cheers!

ps: For those who don´t remember River Raid for Atari, I found this link:
https://www.youtube.com/watch?v=kNXQYH-xTK8

What I´m doing is a loose recreation of River Raid, more of a inspiration in fact. As you can see, there are these Bombers in the original game, but they don´t follow the map and run horizontally. I changed that.


ps2: Some small changes: Windows is not resizable anymore, colours are constants

avcaballero

That's nice. I guess that if you fly outside the river you will lose.

LordAdef

Exactly Caballero!

I still need to write the collision detection algorithm. There is where the fun is!

LordAdef

Update on the transparency & bombers:

I managed to make it to work, but it´s a very expensive solution and it´s bloating my exe file... I really need someone to suggest me a cheaper solution, please.

I´m using two bmp: 1 bit one and the other is 4 bits (it doesn´t work with 2 1bits)
I´m using 2 bitblt lines (attached as separate files in the zip):

Quoteinvoke   SetTextColor,hdc,  colBOMBER
           invoke BitBlt, hdc, bomber.x, bomber.y, 36, 35, hMaskDC, 0, bomber.frmy, SRCAND
           invoke BitBlt, hdc, bomber.x, bomber.y, 36, 35, hMemDCbomber, 0, bomber.frmy, SRCPAINT

So, a veeery expensive solution for a small detail.

As a bonus, due to the FANTASTIC Switch/case in MASM I put 5 little guys flying for you.

Quote;-------------- TESTING ONLY! --------------
          mov eax, map.line
           add eax, edi
         Switch eax   
         Case 450, 440, 430, 400, 390            ;this is line. 5 planes at given lines
                 mov bomber.y, ebx
         Endsw

Any help is welcomed
Cheers Alex

ps: asm and Richmasm files included.

jj2007

Quote from: LordAdef on March 01, 2017, 12:56:21 PM
I´m using 2 bitblt lines (attached as separate files in the zip):
...
So, a veeery expensive solution for a small detail.

Hi Alex,

Test this:;xxxxxxxxxxxxxxxxxxxxxxxxx
;   ASCii Raid. game foundation
;xxxxxxxxxxxxxxxxxxxxxxxxx
include \masm32\MasmBasic\MasmBasic.inc
; include \masm32\include\masm32rt.inc
include stuff.inc ;protos, structs, macros
...
      NanoTimer()
      invoke BitBlt, hdc, bomber.x, bomber.y, 36, 35, hMaskDC, 0, bomber.frmy, SRCAND
      invoke BitBlt, hdc, bomber.x, bomber.y, 36, 35, hMemDCbomber, 0, bomber.frmy, SRCPAINT
      Print Str$("%i us ", NanoTimer(us))


The animation will not work properly, but it's just for showing how expensive your solution really is 8)

LordAdef

QuoteThe animation will not work properly, but it's just for showing how expensive your solution really is 8)

Hi JJ,

This is what I´ve got from 2 scenarios:

1st line:
Quoteinvoke BitBlt, hdc, bomber.x, bomber.y, 36, 35, hBomberDC, 0, bomber.frmy, SRCPAINT
2nd line:
Quoteinvoke BitBlt, hdc, bomber.x, bomber.y, 36, 35, hMaskDC, 0, bomber.frmy, SRCAND
invoke BitBlt, hdc, bomber.x, bomber.y, 36, 35, hBomberDC, 0, bomber.frmy, SRCPAINT

Quote5  us 9 us 24 us 10 us 46 us 24 us 21 us 21 us 18 us 38 us 36 us 21 us 23 us 20 us 19 us 19 us 28 us 35 us 23 us 22 us 22 us 22 us 20 us 15 us 27 us 23 us 21 us     Average: 21
23 us 9 us 82 us 7  us 30 us 27 us 26 us 33 us 42 us 29 us 25 us 24 us 21 us 33 us 29 us 25 us 54 us 27 us 23 us 36 us 27 us 24 us 24 us 25 us 24 us 25 us 24 us     Average: 28

Interesting test. And it´s good because I was lacking a way to time my code. I will now be using your macros to time it further.

Apart from any performance issue, I am actually suffering with the extra  2.57kb I´m having to add to my payload (on top of the 1bit 902 bytes for the same actor).

Do you think this is a nice solution then?

Disclaimer:
It´s all you guys´s fault, I´m turning into this miserable programmer crying for every byte added, and every tick lost :dazzled:

I blame you and Hutch!!!  :badgrin:

hutch--

 :biggrin:

> I blame you and Hutch!!!

If in doubt, choose speed over size.
If not in doubt, choose speed over size.
If all else fails, choose speed over size.
Don't care what others do, choose speed over size.

And if none of that works, make it go fast !!!!