hey, i know this is a stupid question to most of your but anyways,
i have a string right
szAttack db "5",0
and i want to add 5 to that string to make the value 10,
and then print the value in the screen that i have set up
well as u can see it jumps to the lable attack and then after the instructions are done it jumps to StartMsg to use a messagebox that has the value, but the value is ":"
i know its in hex but how would i add 5 to the original value 5 to make it ten and so forth, make it in decimal instead of hex?
thanks,
njkt
(sorry for the simple post lol)
i have a string right
szAttack db "5",0
and i want to add 5 to that string to make the value 10,
and then print the value in the screen that i have set up
.if wParam == 50
jmp Attack
StartMsg::
invoke MessageBox,hWin,ADDR szAttack,
ADDR szDisplayName, MB_OK
;--------------------------------------------------------------
Attack::
add szAttack, 5
jmp StartMsg
well as u can see it jumps to the lable attack and then after the instructions are done it jumps to StartMsg to use a messagebox that has the value, but the value is ":"
i know its in hex but how would i add 5 to the original value 5 to make it ten and so forth, make it in decimal instead of hex?
thanks,
njkt
(sorry for the simple post lol)
Your probably better off to store it as a number then convert it when you have to display it...
Number dd 5
szAttack db 16 DUP(0) ; make it big enough to hold the largest possible number DWORD aligned
add Number, Whatever
invoke dwtoa,Number,,OFFSET szAttack
Number dd 5
szAttack db 16 DUP(0) ; make it big enough to hold the largest possible number DWORD aligned
add Number, Whatever
invoke dwtoa,Number,,OFFSET szAttack
ok thanks,
that worked
btw what is dwtoa?
i havent heard of it i dont think
thanks,
njkt
that worked
btw what is dwtoa?
i havent heard of it i dont think
thanks,
njkt
If you are using MASM, then dwtoa is a function in the masm32.lib that converts a dword to a string
there is also wsprintf which is a windows api that can do it...
also sprinft can do floats but it seems to be flawed or i need to change how i call on it...
sprinft there is not lib or includes made for it yet...
also sprinft can do floats but it seems to be flawed or i need to change how i call on it...
sprinft there is not lib or includes made for it yet...
wsprintf is *very* slow, if you're just doing integers use the dwtoa function, it is much faster. If you are sure to have only number 0 through 9, just add 30H to the number and pass the address to the number,it is fastest of all. Another way is to use the following for 0 through 99 it is very fast:
LOCAL szAttack :DWORD
mov eax,Number
aam
add eax,3030H
bswap eax
shr eax,16
mov szAttack,eax
invoke MessageBox,NULL,ADDR szAttack,NULL,MB_OK
hey,
well im not using just 0-9 it will probably be more then 2 digits.
everything works so far,
so im going to get info on buttons since im using prostart i dont know how to move the buttons so ima go look for other methods.
njkt
well im not using just 0-9 it will probably be more then 2 digits.
everything works so far,
so im going to get info on buttons since im using prostart i dont know how to move the buttons so ima go look for other methods.
njkt
Well, if you're doing a game, here are the tic counts for the methods mentioned here:
Based on maximum value for each function
using Pentium 3 for tests
add 30h method = 1 tic
aam method = 20 tics
dwtoa method = 39 tics
wsprintf method = 237 tics (using %d formatting)
wsprintf method = 1028 tics (using %u formatting)
Based on maximum value for each function
using Pentium 3 for tests
add 30h method = 1 tic
aam method = 20 tics
dwtoa method = 39 tics
wsprintf method = 237 tics (using %d formatting)
wsprintf method = 1028 tics (using %u formatting)
hey,
i am making a game,
hey also,
do u have any info on backgrounds?
ive looked at the masm example but its kinda confusing to look at since there arent any tuts with it.
thanks,
njkt
i am making a game,
hey also,
do u have any info on backgrounds?
ive looked at the masm example but its kinda confusing to look at since there arent any tuts with it.
thanks,
njkt
Backgrounds for what? do you mean for your window ? Solid or bitmap ? If you're looking for a background colour for your window you can either set it in the class structure of the window or use something like this in your WindowProc :
; LOCALs that are needed :
LOCAL ps :PAINTSTRUCT
LOCAL hDC :DWORD
LOCAL hRgn :DWORD
LOCAL hBrush :DWORD
LOCAL OldObject :DWORD
.ELSEIF uMsg == WM_PAINT
invoke BeginPaint,hWin,ADDR ps
mov hDC,eax
; Create a brush to be used for painting (this should be done elsewhere)
invoke CreateSolidBrush,0042DE21h
; Save the brush handle to destroy it later
mov hBrush,eax
; Select the brush handle into the DC for painting
invoke SelectObject,hDC,hBrush
; save the object that was previously in the DC
mov OldObject,eax
; Create a region from the parameters passed in the paintstruct
invoke CreateRectRgn, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom
; The region handle must be saved to destroy it later
mov hRgn,eax
invoke PaintRgn, hDC, hRgn
; restore the old object into the DC
invoke SelectObject,hDC,OldObject
; Clean up the GDI
invoke DeleteObject,hRgn
invoke DeleteObject,hBrush
invoke EndPaint,hWin,ADDR ps
mov eax,TRUE
ret
hey,
im looking for bitmap or solid, wats the difference?
i will more than likely use solid
thanks for the color code i will use that as well,
sorry for the asinine questions though.
thanks,
njkt
im looking for bitmap or solid, wats the difference?
i will more than likely use solid
thanks for the color code i will use that as well,
sorry for the asinine questions though.
thanks,
njkt
The quesions are OK. For bitmap I think that there is a tutorial for that, Iczelion # 25 if I remember correctly.
hey,
ok
i will look through those,
i forgot there are more than 24.
thanks,
njkt
ok
i will look through those,
i forgot there are more than 24.
thanks,
njkt
You can download the full set in chm format from this site :
http://www.masmforum.com/website/
Go to tutorials,it's at the bottom. It will give you the option of searching through the tutorials for your subject.
http://www.masmforum.com/website/
Go to tutorials,it's at the bottom. It will give you the option of searching through the tutorials for your subject.
hey,
well i downloaded those tutorials,
i have the bitmap working perfectly,
but im having problems with the buttons,
i cant position them where i want and i havent found any source code except in the tuts but i havent found anything in there that pertains to position or anything.
thanks,
njkt
well i downloaded those tutorials,
i have the bitmap working perfectly,
but im having problems with the buttons,
i cant position them where i want and i havent found any source code except in the tuts but i havent found anything in there that pertains to position or anything.
thanks,
njkt
Well, I would suggest that you use a dialog as main window type application (Tutorial #10). Download RadASM from the following site :
http://radasm.visualassembler.com/
It has a very good dialog editor that will allow you to place the buttons with a visual editor.Be sure to download the help file as well, it will show you how to use the IDE.
http://radasm.visualassembler.com/
It has a very good dialog editor that will allow you to place the buttons with a visual editor.Be sure to download the help file as well, it will show you how to use the IDE.
hey,
well this is wat i wanna do,
i have a game already right,
and so i want to create a gdi for it, with buttons, text, and pictures.
http://www.asmcommunity.net/board/index.php?topic=14533
a dialog box will be able to do all of this right?
thanks,
njkt
well this is wat i wanna do,
i have a game already right,
and so i want to create a gdi for it, with buttons, text, and pictures.
http://www.asmcommunity.net/board/index.php?topic=14533
a dialog box will be able to do all of this right?
thanks,
njkt
You can do anything with a dialog box that you can do with a window. In effect it is simply a window where Windows handles most of the creation and message handling. There are a few minor differences, mostly advantages like using the TAB key to navigate and simple control and background colouring using the WM_CTLCOLORxxx messages. I rarely ever use windows, prefering the ability to quickly edit a dialog in RadASM. If you use the dialog as window, you have all of the features of a window but with the advantage that you can buildit visually. The disadvantage is that it requires a slightly larger resource section and might add 1 or 2 Kb to your program. Using RadASM you can also add bitmaps and icons to your resource section so that they don'thave to be external to your application.
ok thanks,
ive already downloaded RadAsm,
so i'll begin on a dialog app,
hey also, is there anyway i can set up an inputlike field (like in tut 24) that displays a value (ie. life, attack point, money, etc. )
thanks,
njkt
ive already downloaded RadAsm,
so i'll begin on a dialog app,
hey also, is there anyway i can set up an inputlike field (like in tut 24) that displays a value (ie. life, attack point, money, etc. )
thanks,
njkt
The available controls are on the dialog editor toolbox, you would use the Edit Control for that, you can set it to numeric only in the properties window if you want to allow only numbers. You can also use an up/down control set up as a spinbox that will allow the user to use arrows to do it.