WM sound generating question - Windows Mobile Software Development

Hi people!
I'm working on an emulator for WM platform. 95% of job is finished fine but I have a problem which I don't know how to solve.
Namely, I need to convert a small fragment of x86 code into ARM equivalent.
here it is:
Code:
__asm in al,61;
__asm and al,0xFC;
__asm mov BYTE PTR speaker,al;
and this one:
Code:
__asm mov al,BYTE PTR port
__asm shl al,1
__asm and al,2
__asm or al,BYTE PTR speaker
__asm out 0x61,al
This code is working with PC's 8253 timer chip and its 61h port. As the result we get sounds from beeper.
It is not a secret that WM devices don't have beeper
Does anybody know how to get sound from WM device which would emulate PC's beeper? I know that this question is not easy one but I hope that someone could help me.
A big thanks in advance.

You may have to do it from a much higher level by calling PlaySound() with a .wav resource of the sound you want.
http://msdn.microsoft.com/en-us/library/aa909766.aspx
I dont think you can get to the underlying hardware that easily.
By fiddling with the sound chip registers, it was possible to alter the frequency of the PC beep. Using PlaySound() this is not possible, you would need a separate wav file for each note.

Thank you, stephj for your answer
As you know, much higher level means, much slower execution A bad thing for emulation. Yes, I knew for this function but I hope that somebody could suggest something more faster.
I've tried with google to find anything about this topic and I found some articles from PocketPC (and even before) era but nothing more concrete. According to that articles, it is possible to emulate beeper on PPC but I couldn't find any code which talks about that.

I suggest that you go ask over at stack overflow, and I'm sure that you'll get your question answered in no time

It isn't a problem to ask but it is a big problem to get a good answer .
Not so many ppl understand low-level programming at all.
I still can't understand why PPC/WM programming is so poorly covered if we know that this platform exists for a very long time. It is almost impossible to find some article how to implement ARM mc in your programs.

Goshx said:
It isn't a problem to ask but it is a big problem to get a good answer .
Not so many ppl understand low-level programming at all.
I still can't understand why PPC/WM programming is so poorly covered if we know that this platform exists for a very long time. It is almost impossible to find some article how to implement ARM mc in your programs.
Click to expand...
Click to collapse
stack overflow contains the best of programmers
and I know, I wish I can learn low level programming some time in the future, stupid .Net and Java made everything so simple and stupid lol

Have a read of this: -
http://blogs.msdn.com/b/medmedia/archive/2007/01/03/windows-ce-audio-driver-samples.aspx
Your attention is drawn to the following sentence in the second paragraph.
That upper-edge is hardware independent, and all the hardware dependent code goes into the driver.
Click to expand...
Click to collapse
There are that many different audio chipsets in WM devices, that only the sound driver knows how it really works and where it actually lives. It presents a standard interface to WM above it. If you did manage to find the port/memory addresses that map to the sound chip in your device, and managed to write some code that could force a sound out of it, it probably would not work on anything else.

thank you, stephj
I'm analyzing now some emulators to check how this problem is solved there. In any case, it is impossible to produce beep sound writing a value into registers which don't exist on WM platform
Unfortunately, a small piece of x86 code should be translated into a large C code with APIs.

Related

Today plugins

Recently i was thinking about creating an app which would show me my remaining calltime with one of polish prepaid services. I imagine it would work like that:
1. receiving a specific text message with my account balance from my operator the app would capture it and store the value
2. after each call being made operator sends sms with call cost. this should be deducted from previously stored value. etc etc.
3. value should be displayed somewhere, like on today plugin...
seems simple, but theres a catch;] i can't code for WM5. i just got myself delphi 2006 today and i see it has limited CF support so i can create applicatons... but am i able to create Dlls? also i don't have clue about creating dll's at all, especialy those for WM5. is it even possible with .net? is there any chance for me?
i know, i know, i shoud start to use c++ long time ago, but i'm affraid it' might be a bit to late for me;]
ps. is there anything like WM5 sdk, any guide kit for programmers, specs of any kind? where to look for it? thanks for any help. please note, i'd like to become one of you guys, i could even be of some value;]
heard somewhere that today plugins
cant be written in .net
here is a link to the subject of today plugins
http://forum.xda-developers.com:80/showthread.php?t=234162&highlight=codeguru
thanks, gonna try it in a minute.
(today unbelievable happened - my wizards battery got empty )
interesting. i'll consider switching to c++. as far as i understand it's not normal C, its some kind of mobile oriented c? but no connection with .net? how does it work?
Ok.
C++ is an extension of C to include object oriented programming. The language is not specific for mobile devices, so any book / article on the subject will do for starters.
I taught my self C++ after learning Pascal (Delphi is for Pascal right?) in school and it was quite easy because the languages have similar structure.
Your second stop is to learn WIN32 programming. I don't know how Delphi deals with APIs and function exports (that's what you need for DLLs).
Basically WM programming is very similar to desktop windows programming, except for a few miner difference (like all APIs using only Unicode).
You can download a free development tool called eVC 4 from MS. It looks exactly like Visual Studio 6 if you have any experience with that.
Unfortunately system DLLs like plugins can not be written using .NET but if you search MSDN (I really don't remember the link), there is an article on how to use a basic C++ DLL for the plugin and delegate all the real functionality to a .NET DLL.
Good luck.
yes, delphi is much like pascal
i know it's not that hard if you mean the structure. i just don't know how to start. in fact i got myself evc yesterday, after what you say i'll take good lok at it as soon as i prepare some room on my HD.
Delphi does well with windows api - as far as i can tell, i played with theese a bit so it shouldn't be hard to catch up when starting with c++. other thing is i never did dll, although i know how it works in general, i also used other peoples dll's in my programs. will do i hope. also, Rudegar provided us with good tutorial/example on today dlls, so i hope i'll be able to expand it. the only thing, i'm a bit anxious. you say evc is good for starters? ok, going to give it a try.
what a week, four days, four new RAD environments already
delphi is object pascal which is an extention of pascal like c++ is of c
c programs should compile without any problems in c++
Hi,
I saw a way to develop today plugins in .net : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppcgen/html/TodayScrn.asp?_r=1
I did not try and I guess it will slow down the device as .net is not very fast, but you can try...
Good luck

Run exe in WM

Hi!
is it somehow possible to run exe file, that is for desktop windows, on WM6.1?
I was installing some software, and was unable to run keygen, until I reached my PC.
I'm using WM 6.1 on HTC HD.
Thanks
Perhaps you should describe what is keygen?
Keygen is some small executable file, that usually display graphical form and generates some numeric (or another) data on the output.
philous said:
is it somehow possible to run exe file, that is for desktop windows, on WM6.1? Thanks
Click to expand...
Click to collapse
Long story short: no. You can't just drop an application compiled for Win32 to WinMo and launch it. Even for .NET-stuff the loader-stub-thingamagic (can you tell I've got near to zero .NET-programming experience :-?) that passes the code to the runtime is for a different processor architechture. (and AFAIK XScale/ARM and x86 don't really match)
I guess it could be done with some really weird conditional PE-header wizardy (winmo uses the same kind of portable executable as win32, right?).
But more to the point, I thought discussing warez-related stuff on these boards wasn't ok
I'm sure someone with far more experience in WinMo-development will come along and correct me any minute
shisux said:
Long story short: no. You can't just drop an application compiled for Win32 to WinMo and launch it. Even for .NET-stuff the loader-stub-thingamagic (can you tell I've got near to zero .NET-programming experience :-?) that passes the code to the runtime is for a different processor architechture. (and AFAIK XScale/ARM and x86 don't really match)
I guess it could be done with some really weird conditional PE-header wizardy (winmo uses the same kind of portable executable as win32, right?).
But more to the point, I thought discussing warez-related stuff on these boards wasn't ok
I'm sure someone with far more experience in WinMo-development will come along and correct me any minute
Click to expand...
Click to collapse
well, yeah, I also didn't think that it's possible because of different processor architectures, but maybe somebody heard something about that..
Miracles happens
We are not discussing warez stuff, the question thesis is different.

Language of choice

Just curious..What is everyone's programming language of choice when developing apps for WinMo?
Ive been working (lightly) on a VB program, which is ok, but i feel it isnt as efficient as others might be, and i know efficiency and size is a big issue on mobile devices (obviously)
Depends:
A simple program or one that can be done just using the stuff in the standard system DLLs then I will go for the pain of coding it in WIN32 C++. The resulting application runs like the wind, and can be distributed as a single executable file, no CAB, no installation projects, etc etc.
If I need any web or fancy data functionality, then it is .NET, because it is not worth the hassle of getting all this to work from levels lower down.
Having had lots of previous coding experience in C/C++ then C# is the natural choice, but as far as .NET is concerned, the actual language you code in is irrelevant. It compiles down to IL anyway and the CPU 'JIT' compiles this into its own code before it runs. Hence the performance hit when the program starts and runs.
In .NET, in essence, all you are doing anyway, is creating .NET objects, setting their properties and calling their methods, in order to get them to do what your application requires. A simplistic view, I know, but that's is all there is to it!
The language that you use to do this doesn't really matter, it is just personal preference.
I guess i assumed one language had more efficantcy than another. Like im working with VB atm, and i know it simplifies alot of things to make it easier to use, not sure if it includes all that extra code in the final build or not tho.
I would like to get more pratice with C++ and i have yet to use C# so dono whats different about that.
I would like to eventually start making programs that utilize the .net code and get my programs talking though data on the phone, but im not that advanced yet.
currently im still trying to wrap my head about making a program with a local database. The program im working on currently doesn't store any data, but i would like to to. I would also like (if i get ambitious) to have that program possibly talk to a PC (parent) program and sync with it. But that i think is a ways off.
Also, do the Mobile SDK's look different? The program im working on i started in the 5 SDK, but (obviously) doesnt have Finger friendly IU tools. I haven't looked at the 6/6.5 SDK yet (as id have to start over again i think). Does it have more finger friendly options?
In .NET CF, the finger-friendlinnes and kinetic scrolling and this all isn't available for all controls. Most of them (the classic ones) are, but if you try using scrolling for whole form, it won't work, only scrollbar will. (Probably with some playing with physicsengine and marshalling you might be able to get it working here, too).
In C++, there are numerous examples of this gestures etc directly in SDK, also many other stuff is there.
See, the main difference here is that .NET is fully equipped with stuff to get everything done fast, easy way.
In C++, you must first make this way yourself .
i am using the .net 3.5 framework tho.. Unless you mean C++ vs C#. I thought .net was an expansion on a current language, and not a language on it self (meaning i cant choose to program in .net, its an option to VB, C++ or C#)
I did toy with it, and it appears as tho your right, the forums are the same. IE drop down/combo boxes are not finger friendly. Guess id have to turn it to a button and another form with large radio button options.
C# vs C++ main difference is that C++ is compiled to native code right on first time, which makes it very fast. C# is compiled to MSIL, which is NOT native code yet. When you run c# app, the code is being Just-In-Time (JIT) compiled to native code, which makes it "longer" to load and "slower" to run (usually that makes about 20% of speeddown on classic PCs with very optimalized C++ same code - it probably already is lower, this is a bit older result of testing).
C# has those nice features that it can't get out of its memory etc, the JIT is almost unhackable, so you can't write viruses in it etc.
As far as the SDKs are concerned, there are slight differences from one version to the next but they can be quite difficult to spot.
They can become issues, when code written to run on one platform is run on one several generations away. I have a program that was written in C++ WM2003. Works under all versions of WM until 6.5.3, when the About Dialog box fails to close if the (X) button is pressed. Turns out another value has to be added to the dialogbox flags field to get it to behave properly.
This has been a feature of SDK's from WM 5.0 onwards, but the WM2003 SDK is unaware of it. You have to add it manually to the shell code created by the SDK,
Progress I suppose. The full article is here:
http://forum.xda-developers.com/showthread.php?t=635063
Treo 700xw Verizon Spanish language
Hello fellow .... I'm new to this forum
I have a Treo 700wx and I live in Mexico ...
My Treo is Verizon's company and is currently with the version 1.22 ...
My problem is that it is in English and I need to change the language in Spanish ...
Thank you for your support both the need
Greetings
stephj said:
As far as the SDKs are concerned, there are slight differences from one version to the next but they can be quite difficult to spot.
They can become issues, when code written to run on one platform is run on one several generations away. I have a program that was written in C++ WM2003. Works under all versions of WM until 6.5.3, when the About Dialog box fails to close if the (X) button is pressed. Turns out another value has to be added to the dialogbox flags field to get it to behave properly.
This has been a feature of SDK's from WM 5.0 onwards, but the WM2003 SDK is unaware of it. You have to add it manually to the shell code created by the SDK,
Progress I suppose. The full article is here:
http://forum.xda-developers.com/showthread.php?t=635063
Click to expand...
Click to collapse
I noticed something else odd. When i run the app on my pone, the resolution is off. Now everything looks ok, i just mean that when i run it on my phone, theirs alot of "white dead space" at the bottom. I can only guess this is due to the SDK's catered to phones with smaller screen resolutions (ie Touch Pro) with buttons.. Is their a way for me to switch the resolution to ultilize the full Touch Pro 2 screen size (480x320 i think)?
Funny you should mention that. I replied to a similar post a short while ago. I'm not going to type it all in again, it's here.
http://forum.xda-developers.com/showthread.php?t=637417

Thoughts on Unlocking custom GPU programs...

Hey,
Currently I've been working on a game for the Windows Phone but a couple things have really irritated me during porting, one of which is they don't allow custom GPU programs...which is very stupid considering there basiceffect class is completely useless.
The Windows Phone has some awesome hardware and it sucks that its being restricted by the dev team.
So right now I'm looking at microsoft.xna.framework.graphics in reflector(the GAC version not the reference version). The effect class itself is NOT marked as security critical, but the constructor is(because it requires compiled GPU bytecode to be passed down), so the logical why would be to load it via the contentmanager, but the damn thing spits out("You are unable to compile custom effects for winphone7).
My question is does anyone know where that error is actually located?
It looks like XNA is using a custom content importer to import some kind of template called "BasicEffectReader" , and "BuiltInEffectReader" . I don't know if I'm allowed to post reflected code on here, but if you open up BasicEffectReader.cs youll find that it creates a "cloned effect" from the BuiltInEffectReader.
My other questions are, is the bytecode for Windows Phone 7 different from the 360/Windows(I'd assume so), and if so is XNA actually compiling bytecode on the fly, is it using a template for basiceffect?
If it is requires its own bytecode, what kind of methods do you guys think would be feasible to be able to create custom effects? The graphics card on the phone should follow the DX9 specs, unless its a 9.5 hybrid like the 360.
EDIT3:
Alright it looks like if you compile it on another platform, strip out the contentmanager stuff at the start of the file, it will load(passes all the header checks) but it fails because UnsafeNativeMethods.Effect.GetGlobal(graphicsDevice).CreateEffect(pEffectCode, ((uint) effectCode.Length) - num2, graphicsDevice.pComPtr, out effect_desc); returns a invalid handle...
Very surprised they don't let you use custom GPU shader programs.
Yeah I know :/ anyway I kind of got a custom program loaded, but I'm not sure about the OpCodes, so I don't know how to customize it yet.
_effect = new Effect(device, Code);
static byte[] Code = new byte[] {
0xcf, 11, 240, 0xbc, 12, 0, 0, 0, 0, 0, 0, 0, 1, 9, 0xff, 0xfe,
0x62, 0x61, 0x73, 0x69
};
Click to expand...
Click to collapse
First Int(4 bytes) are the XNA header magic number,
Next Int(4bytes) byte offset to the code(from start of the buffer).
(Offset 12) - 1, 9, 0xff, 0xfe - FX Magic Number dx9 i believe.
Next 4 bytes are the IDENTIFIER for the effect. basi <-- basiceffect, skin <-- skinable effect etc.
Click to expand...
Click to collapse
Also what version of Direct3D is the phone running? Is it a 10/11 hybrid? cause in XNAFrameworkCore.dll it references D3D11CreateDeviceAndSwapChain and it also references CreateDXGIFactory1
Has anyone got PInvoke to work? The only way to get access to the HLSL compiler for the phone is through non-exposed API's in XnaFrameworkCore.dll.
When it creates the effect it looks for the unique four byte effect iden to create the shader internally(D3D_Effect_CreateHandle in XnaFrameworkCore.dll). So to get access to the HLSL compiler and compile our own effects it looks like we have to call some of the non-exported API's from the DLL. Which shouldn't be a problem if someone has found out how to get PInvoke to work( Not the COM dll hack but actually calling PInvoke. ).
EDIT
For anyone thats interested here are the different ID's(remember the hex is actually in reverse order):
.text:1003DF68 mov eax, [ebp+var_4]
.text:1003DF6B cmp eax, 69727073h
.text:1003DF70 jz loc_1003E086
.text:1003DF76 cmp eax, 69736162h
.text:1003DF7B jz loc_1003E05F
.text:1003DF81 cmp eax, 6C617564h
.text:1003DF86 jz loc_1003E038
.text:1003DF8C cmp eax, 6D766E65h
.text:1003DF91 jz short loc_1003E009
.text:1003DF93 cmp eax, 6E696B73h
.text:1003DF98 jz short loc_1003DFD7
.text:1003DF9A cmp eax, 74736574h
.text:1003DF9F jnz loc_1003E0B5
Click to expand...
Click to collapse
crozzbreed23 said:
Has anyone got PInvoke to work? The only way to get access to the HLSL compiler for the phone is through non-exposed API's in XnaFrameworkCore.dll.
Click to expand...
Click to collapse
A number of us have tried to do it, but have failed. The correct path is probably '\Windows\X.dll.' I haven't tried that yet. It's probably worth mentioning that even if you do get it working, Microsoft has sworn to reject any app that uses PInvoke.
I know the app would be rejected, I only want to build a portfolio project that I can take with me to a job interview.
Even though a lot of the HLSL code is in XnaFrameworkCore.dll, there is a d3dcompiler dll(which is compiled against D3D10). I know this is probably something that has been answered before, but is there a method for opening up the WM ARM dll's in IDA?
My thinking is this, we can launch executables but to get access to the OS dll's we have to build valid OS libraries. I wanted to try the COM dll method, but I don't have the phone yet and the emulator obviously won't load COM dll's.
If we can get as far as calling LoadLibrary than we can call:
D3D11CreateDeviceAndSwapChain
and
CreateFactory1
Click to expand...
Click to collapse
Than ASSUMING D3DCompiler.dll works(its not referenced in the XNAFrameworkCore except for loading in the HLSL sig), we can load custom GPU programs(that are HLSL based not effect based which is just fine...) as well as exposing more of the Direct3D API.
The only reason why I want all the graphics API's is so I don't have to create a portfolio project with baked lightmaps with bumpmapping built in. Its such a shame that the GPU on the phone is going to waste because they designed a very restrictive effect interface :/.
Its a pain but it has been but there are lots of reason why they are doing that. for one when the chassis requirements where released the minimum requirement is that the gpu had to do opengl. xna is built for direct x and hence the problem, some stuff had to be ported to opengl for it to work properly, the problem wiht this is that the new chips now have directx gpus with them, and i am not sure but i believe none of the wp7 phones that have been released has any of the directx acceleration. Becuase of this and compatibility with the later phones (atleast up to next year) some stuff had to go, custom shaders for one. But i believe if you work close with microsoft they actually give you the the ability to create custom shader. I have not played much with xna for windows phone, just on xbox so i am not to sure what i can do and not do. But your post was enlightening and i will go back to it after i finish my few apps.
Yeah your right. I just read up that they are using the ADRENO 200 GPU(http://developer.qualcomm.com/dev/gpu/processors), which supports opengl es, and "Direct3D Mobile" whatever that means. But that still doesn't explain why they didn't allow custom GPU programs because everything is still being compiled down to bytecode. If the GPU can do per-pixel lighting it is more than capable of bump mapping that reacts to lighting which is why I really want to see if I can maybe extend one of the .net effect classes, but I still haven't figured out if that would mess with any of the internal core functions.
But as I did with the XNA 360 code, I got access to the UnsafeNativeMethod classes inside the framework dll that expose all the native interfaces to the core. So basically I just skip passed all the XNA init code. The only thing that creates a problem with on the phone is that they use a "messaging service" to communicate with the framework, they build a byte[] array in the .NET code and pass it to the framework which parses it and does whatever it needs to do. On the phone, pointers aren't allowed, but I might just be able to use reflection to get the messaging code.
Also I thought of something, sense the GPU supports OpenGL ES and I know that someone has been able to create a window(the FS example on Chris's site), I wonder if we create a COM dll and link against the OpenGL ES library that we can just use OpenGL rather than the "non finished" d3d api? I would try that myself but I'm not going to be able to get the phone for a couple weeks and I havent found a way to get COM dll's to work in the emulator :/
Yeah your right. I just read up that they are using the ADRENO 200 GPU(http://developer.qualcomm.com/dev/gpu/processors), which supports opengl es, and "Direct3D Mobile" whatever that means. But that still doesn't explain why they didn't allow custom GPU programs because everything is still being compiled down to bytecode. If the GPU can do per-pixel lighting it is more than capable of bump mapping that reacts to lighting which is why I really want to see if I can maybe extend one of the .net effect classes, but I still haven't figured out if that would mess with any of the internal core functions.
But as I did with the XNA 360 code, I got access to the UnsafeNativeMethod classes inside the framework dll that expose all the native interfaces to the core. So basically I just skip passed all the XNA init code. The only thing that creates a problem with on the phone is that they use a "messaging service" to communicate with the framework, they build a byte[] array in the .NET code and pass it to the framework which parses it and does whatever it needs to do. On the phone, pointers aren't allowed, but I might just be able to use reflection to get the messaging code.
Also I thought of something, sense the GPU supports OpenGL ES and I know that someone has been able to create a window(the FS example on Chris's site), I wonder if we create a COM dll and link against the OpenGL ES library that we can just use OpenGL rather than the "non finished" d3d api? I would try that myself but I'm not going to be able to get the phone for a couple weeks and I havent found a way to get COM dll's to work in the emulator :/
You can pretty much give up on that one, the COM dlls for the phone are ARM assembly, but the emulator runs on x86. Not likely to work.

[Q] Develop Apps for Windows Mobile

I want to develop simple apps for Windows Mobile. I read that I can use:
---Compact Framemork. (I downloaded Sharp Develop, it is free. It also exist a program from Resco that speedup the development with C.F.)
--- C or C++ or C# (I don't know if WinMo understand these...)
---Visual Basic (is difficult and Visual Studio isn't free, but I found another program that allows to develop more simple)
---Mortscript (I think is the most simple)
---Which is the best and the most simple language?
---Where can I read or download tutorials?
---I can not develop simple apps with images and sounds yet.
Please Help!
I want to develop
-a lock screen
-an app that turn on and turn off the leds of my device
-an app that change registry values (without softreset the device)
-an app that can copy, cut and delete files
-a Soft Imput Panel (a virtual keyboard)
I haven't done windows mobile development in quite some time, so things may have changed a bit. But to help you out better, it would be good to know what version of windows you intend to develop for (I assume Windows Phone 7?) as well as any specific devices you may want to concentrate on, and what experience you already have with coding.
MortScript is probably a good starting point, though if you want to get some real functionality going, you should look at C#.net CF. Take a look at this MSDN resource: LINK. It should be good for getting started.
I think that for modifying the registry, working with LEDs, and for the software keyboard you may need to use C++ ... though I can be mistaken. I'm not sure how Microsoft has worked out libraries and privileges in WP7.
Cyclonezephyrxz7 said:
I haven't done windows mobile development in quite some time, so things may have changed a bit. But to help you out better, it would be good to know what version of windows you intend to develop for (I assume Windows Phone 7?) as well as any specific devices you may want to concentrate on, and what experience you already have with coding.
MortScript is probably a good starting point, though if you want to get some real functionality going, you should look at C#.net CF. Take a look at this MSDN resource: LINK. It should be good for getting started.
I think that for modifying the registry, working with LEDs, and for the software keyboard you may need to use C++ ... though I can be mistaken. I'm not sure how Microsoft has worked out libraries and privileges in WP7.
Click to expand...
Click to collapse
Thanks CycloneZephyrxz7.
I want to develop for Windows Mobile 6.X for devices with WVGA resolution.
But with Mortscript I can do less things? Because I can only write scripts.
Do you know how is written a simple app like "ClearTemp"?
I wait other replies from Devolpers and people that used these languages...

Categories

Resources