-
Jun 1st, 2013, 07:26 PM
#41
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by Niya
I have a question Jacob....Why do you use QueryPerformanceCounter ? What's its function ? MSDN says returns a count of a high resolution counter. What does that mean in layman's terms ?
Because its a high resolution timer. Practically the highest resolution timer out there. And can be used for real time related things such as game physics, locking framerates, getting FPS, timing things, anything to do with time, etc. You could alternatively use the timeGetTime API. But its not as a high resolution. But a good alternative if you feel QueryPerformanceCounter is overkill. Its a matter of preference.
-
Jun 1st, 2013, 07:46 PM
#42
Re: Nintendo Emulator v0.65 (VB6)
Ah, I think I get it. I suppose for something like an emulator, that kind of precision is necessary. I made simple game-like engines in the past without it so I guess its not that big a deal in such a scenario.
-
Jun 1st, 2013, 10:26 PM
#43
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by omundodogabriel
I managed to add DirectX to vb.net, and ported all sound emulation code to use with the new DirectSound. However, in runtime, vb show the error NullReferenceException. What I am doing wrong?
Edit: Already discovered the problem, I forgot to call the function DirectSound_Initialize
Now is giving a ArgumentException error on Sound_Process_Through_Mixer function ....
Edit 2: FIXED! It's working perfectly now! NES vb.net emulator now with sound! The source with working sound engine is attached! OMG, i can ever hear bricks breaking now!
Code:
Option Explicit On
Imports Microsoft.DirectX
Imports Microsoft.DirectX.DirectSound
Module DSound
'Public DX As DirectX9
'Public DirectSound_Enum As Enum
Private Sound_Device As New Device
Public Sound_Buffer As SecondaryBuffer
Private Sound_Buffer_Description As New DirectSound.BufferDescription()
Public Sound_Buffer_Wave_Format As New WaveFormat()
Public Const MAX_VOLUME As Long = 100
Public Buffer_Length As Long, Half_Buffer_Length As Long
Public Buffer_Size As Long
Public Sound_Data() As Byte
Public Sub DirectSound_Initialize()
'DX = New DirectSound
'DirectSound_Enum = DX.GetDSEnum
'DirectSound = DX.DirectSoundCreate(DirectSound_Enum.GetGuid(1))
With Sound_Buffer_Wave_Format
.FormatTag = WaveFormatTag.Pcm
.Channels = 1 '1 = Mono 2 = Stereo. The NES is Mono
.BitsPerSample = 16
.SamplesPerSecond = 44100 '22050
.BlockAlign = (.BitsPerSample * .Channels) / 8
.AverageBytesPerSecond = ((.BitsPerSample / 8) * .Channels) * .SamplesPerSecond
Buffer_Size = .AverageBytesPerSecond '* 5
ReDim Sound_Data(Buffer_Size)
Half_Buffer_Length = .AverageBytesPerSecond / 2 '/ 15
Half_Buffer_Length = Half_Buffer_Length + (Half_Buffer_Length Mod .BlockAlign)
End With
Buffer_Length = Half_Buffer_Length * 2
Sound_Device.SetCooperativeLevel(Form1.Handle, CooperativeLevel.Normal)
With Sound_Buffer_Description
.Format = Sound_Buffer_Wave_Format
.BufferBytes = Buffer_Length
'DSBCAPS_STICKYFOCUS - means it will keep playing even if our application does not have focus
.Flags = BufferDescriptionFlags.ControlPositionNotify Or _
BufferDescriptionFlags.StickyFocus Or _
BufferDescriptionFlags.ControlFrequency Or _
BufferDescriptionFlags.ControlPan Or _
BufferDescriptionFlags.ControlVolume
End With
Sound_Buffer = New SecondaryBuffer(Sound_Buffer_Description, Sound_Device)
'DirectSound.CreateSoundBuffer(Sound_Buffer_Description)
Sound_Channel_Clear_Buffer()
Set_Sound_Volume(Sound_Buffer, 100)
Play_Sound_Loop(Sound_Buffer)
'Sound_Buffer.Play(0, DirectSound.BufferPlayFlags.Looping)
End Sub
Public Sub Play_Sound(ByVal Sound_Buffer As SecondaryBuffer)
Sound_Buffer.SetCurrentPosition(0)
Sound_Buffer.Play(0, BufferPlayFlags.Default)
End Sub
Public Sub Play_Sound_Once(ByVal Sound_Buffer As SecondaryBuffer)
Sound_Buffer.Play(0, BufferPlayFlags.Default)
End Sub
Public Sub Play_Sound_Loop(ByVal Sound_Buffer As SecondaryBuffer)
Sound_Buffer.Play(0, BufferPlayFlags.Looping)
End Sub
Public Sub Pause_Sound(ByVal Sound_Buffer As SecondaryBuffer)
Sound_Buffer.Stop()
End Sub
Public Sub Set_Sound_Volume(ByVal Buffer As SecondaryBuffer, ByVal Volume As Long)
If Volume >= MAX_VOLUME Then Volume = MAX_VOLUME
If Volume <= 0 Then Volume = 0
Buffer.Volume = ((Volume / MAX_VOLUME) * 10000) + -10000
End Sub
Here is the code with sound
Attachment 100711
I oughta check this out. The bricks actually making the breaking sound? No way!
[EDIT] Yea no bricks breaking on my end. Its just a thump which I believe comes from the triangle or rectangle channel. The brick breaking noise is suppose to sound like the bricks are crumbling. You get that satisfying feeling with the thump combined with the crackling noise, knowing you broke the bricks.
Also you forgot to shut off the sound when you close out of it. It persists after you exit the program. I get on average 55 fps on my computer at least. I'll try to work with the sound more so. I'm browsing through virtuanes's source code on the apu to get ideas. It probably has something to do with the IRQ implementation over in register $4017 which I did not put in. But thats just a wild guess. Wont know for sure till then.
Last edited by Jacob Roman; Jun 1st, 2013 at 10:40 PM.
-
Jun 2nd, 2013, 11:54 AM
#44
Re: Nintendo Emulator v0.65 (VB6)
Already solved the speed problem. The code "Play_Sound_Loop (Sound_Buffer)" on 6502.vb play the sound buffer, but the buffer is already being played trough the Sound_Process_Through_Mixer function. I deleted that line of code, and speed is back to 200 fps
As for the breaking bricks sound, I was pretty sure I heard the first time, now also do not hear anymore ...
Edit: In fact, I can only hear the breaking blocks in a rom hack of Super Mario Bros . I don't know why, since the only difference is some graphic changes. I am attaching the rom hack.
Acid Bros (SMB1 Hack).zip
Last edited by omundodogabriel; Jun 2nd, 2013 at 12:46 PM.
-
Jun 3rd, 2013, 03:01 PM
#45
Re: Nintendo Emulator v0.65 (VB6)
The mapper MMC5 is already working, at least for Castlevania 3. Still has some problems regarding the name tables, but I believe that it shouldn't be difficult to solve.
The mappers MMC5 is one of the most complex to emulate.
-
Jun 3rd, 2013, 03:49 PM
#46
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by omundodogabriel
Already solved the speed problem. The code "Play_Sound_Loop (Sound_Buffer)" on 6502.vb play the sound buffer, but the buffer is already being played trough the Sound_Process_Through_Mixer function. I deleted that line of code, and speed is back to 200 fps
As for the breaking bricks sound, I was pretty sure I heard the first time, now also do not hear anymore ...
Edit: In fact, I can only hear the breaking blocks in a rom hack of Super Mario Bros . I don't know why, since the only difference is some graphic changes. I am attaching the rom hack.
Acid Bros (SMB1 Hack).zip
That is very strange. I hear bricks breaking on the vb.net version, but not the vb6 version. I'm gonna have to take a look at your code to see what you have done differently.
-
Jun 3rd, 2013, 06:02 PM
#47
Re: Nintendo Emulator v0.65 (VB6)
Actually, I just did the conversion of your code to directx 9, I have not changed anything but the buffer size. The block breaking noise on Mario hack works on both vb.net and vb6 versions here, but not on the original game... It's really is very weird.
Already fixed all the problems related to Castlevania 3, was just the IRQ that was not working. Now Castlevania 3 is perfect. I will test other MMC5 games.
Edit: Castlevania 3 still have some Mirroring problems...
Last edited by omundodogabriel; Jun 3rd, 2013 at 06:25 PM.
-
Jun 7th, 2013, 01:46 PM
#48
Re: Nintendo Emulator v0.65 (VB6)
I'm putting the progress I've made so far in the code if Jacob wants to improve and fix the current problems. I'll take a break for now, I have other projects I want to work, but soon I will work on it again.
Main changes:
- Added Mappers 1, 2, 3, 4, 5
- Improved Menus, need a english translation
- Added controls
- Fixed some PPU issues
- Some settings
ToDo:
- Faster Blit function (maybe with DirectX?), FullScreen is too slow
- Mapeable Keyboard keys and USB Joystick support
- Fix some sprite priority issues (on foreground or background), Simpsons the space ship is behind the stars and the moon!
- Fix some Noise channel problems and add DMC channel
- Add translations support
Source Here:
NES.net_rev2_src.zip
I'm wanting to make a snes emulator for vb, after fix the issues with this emulator of course. Jacob, you will help me?
-
Jul 21st, 2013, 07:43 AM
#49
Lively Member
Re: Nintendo Emulator v0.65 (VB6)
Pretty nice job! just played the mario! brought back memories!
-
Jul 21st, 2013, 10:41 AM
#50
Re: Nintendo Emulator v0.65 (VB6)
Thanks. It was a royal pain to put together and took a lot of research. Was pretty cool for both of us emulator developers to work on it.
-
Jul 21st, 2013, 04:36 PM
#51
Lively Member
Re: Nintendo Emulator v0.65 (VB6)
Sega genesis is your next step! I'm sure you can handle it!
Although I don't think something like that is even possible in VB6. even if it is, it's going to be a pain in (You know where!!) but maybe .Net can handle it.
-
Jul 22nd, 2013, 01:28 AM
#52
Re: Nintendo Emulator v0.65 (VB6)
If it were me, I would export all the heavy lifting to C++ libraries. You really cannot touch C++ for creating super fast algorithms. Some of the best emulators make use of assembly. ZSNES, which is considered to be one of the greatest SNES emulators ever made was written in pure assembly. If you're emulating hardware like that used for an advanced system like the Sega Genesis you really want speed. Neither VB6 nor VB.Net can natively provide such astonishing speed. Then again, we are in 2013 so the sheer speed of processors today may render that point moot.
-
Jul 22nd, 2013, 06:10 AM
#53
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by kivisoft@
Sega genesis is your next step! I'm sure you can handle it!
Although I don't think something like that is even possible in VB6. even if it is, it's going to be a pain in (You know where!!) but maybe .Net can handle it.
Ugh dont get me started on .Net. Well end up turning this thread into another VS war and I'm pretty sure Niyas in agreement we don't want that again. omundodogabriel has already ported it to VB.Net only he found it to be extremely slow compared to VB6. You can find out yourself has he has it available for download in one of the posts in this thread. If you read up eventually youll find it. Gotta hit the sack again because Im never this up early. I just woke up from a sound sleep in the middle of the crack of dawn and I'm not a morning person!
I was thinking about making a Genesis version. Its already been done in Gameboy in VB6 only the comments are in Japanese. Hell I even got documentation on Playstation as well.
-
Jul 22nd, 2013, 06:43 AM
#54
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by Jacob Roman
Ugh dont get me started on .Net. Well end up turning this thread into another VS war and I'm pretty sure Niyas in agreement we don't want that again.
Well this kind of thing is your domain. I'm not gonna argue you on something I know little about. I've never written an emulator or even anything close so I'd be more than willing to defer to you on this. If VB6 is better than VB.Net for this then I'm not gonna even try and debate that. You'd know better than I do.
-
Jul 22nd, 2013, 05:00 PM
#55
Lively Member
Re: Nintendo Emulator v0.65 (VB6)
I agree the whole argument on Which one is better (VB6 or VB.NET) is just stupid. Every language has it's capabilities and it's limitations, I always laughed at those who say "C++" is good for anything, I have no C++ skills but that is just crap. which is why knowing multiple languages is useful, you can pick the one that is right for the job. And about VB6, as I Always said "It gets the job done FAST" and that's it (maybe I should put that in my sig!). There is currently two versions of this Emu (VB6 and .NET) now ask yourself which one took more time? definitely VB.NET but that doesn't necessarily means that VB6 is better.
-
Jul 22nd, 2013, 08:20 PM
#56
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by Jacob Roman
Its already been done in Gameboy in VB6 only the comments are in Japanese.
Well, it shouldn't be too hard to translate it into English! You wouldn't even need the Japanese comments. I am sure a master such as yourself can tell what is happening just by looking at the code?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jul 22nd, 2013, 11:30 PM
#57
Re: Nintendo Emulator v0.65 (VB6)
I honestly dont know how I'm gonna simulate Blast Processing if I do the Genesis. Genesis does what Nintendont
-
Jul 22nd, 2013, 11:58 PM
#58
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by Jacob Roman
I honestly dont know how I'm gonna simulate Blast Processing if I do the Genesis. Genesis does what Nintendont
Whoa...I had to look up that term. Seems there is some controversy behind it because it was overhyped so as to become an effective marketing gimmick. But technically, it seems simple enough. Something about using DMA to do bit block transfers, not that I really know anything about that.
-
Jul 23rd, 2013, 12:35 AM
#59
Re: Nintendo Emulator v0.65 (VB6)
-
Jul 23rd, 2013, 12:40 AM
#60
Re: Nintendo Emulator v0.65 (VB6)
lol....aggressive marketing.
-
Jul 23rd, 2013, 12:46 AM
#61
Re: Nintendo Emulator v0.65 (VB6)
If I do make a Sega Genesis Emulator I am definitely adding this sub:
vb Code:
Public Sub Blast_Processing 'Do Blast Processing here!!! End Sub
-
Jul 23rd, 2013, 01:38 AM
#62
Re: Nintendo Emulator v0.65 (VB6)
Might be more like this:-
vbnet Code:
Public Class BlastProcessor Public Sub Blast(ByVal src As IntPtr, ByVal dest As IntPtr, ByVal cb As Integer) 'Blast processing code!!!! End Sub End Class
-
Jul 23rd, 2013, 03:09 PM
#63
Re: Nintendo Emulator v0.65 (VB6)
-
Jul 23rd, 2013, 03:37 PM
#64
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by Jacob Roman
Do you think you're up to the challenge ?....I wish I had massive amounts of time to spend on non-profitable ventures. I would really love to spend my days learning about these things in depth.
-
Jul 23rd, 2013, 03:45 PM
#65
Lively Member
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by Niya
Do you think you're up to the challenge ?....I wish I had massive amounts of time to spend on non-profitable ventures. I would really love to spend my days learning about these things in depth.
Really?! sounds like a true pain! it's like reading a note in chines!
-
Jul 23rd, 2013, 07:24 PM
#66
Re: Nintendo Emulator v0.65 (VB6)
The NES emulator uses the 6502 CPU with 56 opcodes and 13 address modes. Any start in designing any emulator starts with the CPU. So if I do the Sega Genesis I would have to simulate the 68000 CPU. Its gonna be tough but very possible.
-
Jul 24th, 2013, 12:10 AM
#67
Re: Nintendo Emulator v0.65 (VB6)
I've always found it quite cute that processors and emulate other processors. There is a beautiful symmetry about that.
-
Jul 26th, 2013, 07:05 PM
#68
Re: Nintendo Emulator v0.65 (VB6)
A sega genesis emulator? It would be amazing to play the Sega classics like Sonic 3 on an emulator made in vb6! It would be the first emulator of a 16-bit system in vb. The CPU will be very hard to do, but after this, emulate the apu and ppu should be easy! If you want I am willing to help in this project.
As for the Gameboy emulator, there is a very good Gameboy Color emulator for vb6 in english with sound called BasicBoy, and code is avaible!, it's worth a look:
http://www.zophar.net/gb/basicboy.html
If anyone is interested, here is the latest version of Nes.net. I probably will not touch it again.
NES.net_rev3.zip
-Gabriel.
-
Jul 26th, 2013, 09:15 PM
#69
Re: Nintendo Emulator v0.65 (VB6)
Yeah sure lets do it and make history. Blast Processing on VB6 =D
-
Jul 28th, 2013, 06:46 PM
#70
Re: Nintendo Emulator v0.65 (VB6)
Originally Posted by Jacob Roman
Yeah sure lets do it and make history. Blast Processing on VB6 =D
Well, I tried to find documents about sega genesis emulation (68k CPU and VPU), and found very little. The best I got so far was reading the Rom Header . You've managed to find good simple emulators and good documents that we can rely?
-
Jul 31st, 2013, 10:12 PM
#71
Re: Nintendo Emulator v0.65 (VB6)
I created a thread on it in the games and graphics section. All the info you need will be there and lots more to come
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|