|
-
Jul 29th, 2013, 01:17 AM
#1
Lets make a Sega Genesis Emulator
I know I posted a topic about a Sega Genesis emulator before, but havent got a single response about anything on it. Almost as must as Nightwalkers useful post. Heck noone chills in the Games and Graphics area no more like the good ol days of VBForums. Anyways I'm going really off topic here. Lets freaking make a Sega Genesis emulator shall we. Yes this will be a very humerous learning experience in the way I'm typing this.
Ah the language of choice. Well I would love to do C++ but then noone would want to even touch it. At least in VBForums. I would love to make history pulling it off using VB6, which to some people is a dead language but continues to be widely used. Literally, worldwide. But I dont feel like making a thread on debating which language is better. So how bout we try both VB6 and VB.Net as 2 separate programs and see how far we get. Shall we? At least then we can compare in performance. Afterall, who would love to see "Blast Processing" in VB?!! Probably mostly none of you all because youre too busy posting questions on Winsock and SQL programing, and chilling in the VB.Net, VB6 and Chit Chat areas
For those who dont know or remember, there was a huge game console war back in the late 80s and early 90s between Nintendo and Sega. Nintendo had the NES which was an 8 bit system, and Sega had the Genesis which was 16 bit. It was always about bits. Noone really knew what bits meant. I mean what are bits anyways? As long as the graphics and games looked good, thats all that it really meant. Nintendo had really great titles and so did Sega. And this competition led to better games. Then the Super Nintendo came out in 1991 which was also 16 bit. It had better graphics and sound, and was in steady competition with Sega. However the Sega genesis, although its graphics were shallow in comparison due to the lack of colors, had a faster processer than the Super NES. This is when Sega had a huge ad campaign attacking Nintendo with the phrase "Blast Processing." And it worked in some aspects! Along with the phrase Genesis does what Nintendon't.
Whoh I got really off topic. Lets build the emulator. Ok to build the emulator it all starts with the processor. The Sega Genesis uses a Motorola 68000. The chip consist of 64 pins. However the number of opcodes according to my research is not known per say just yet due to the number of combinations. But the closest I've come is this document:
http://emu-docs.org/CPU%2068k/68000inst.txt
A lot of the instructions looks as though it borrowed from the 6502 family. However if you really wanna get complicated, heres a binary version of it:
http://emudocs.org/CPU%2068k/68000obj.txt
I know I'm getting way ahead of myself here but thats where it starts. And I have source code to implement for the instructions thankfully...just not in VB yet. So lets begin coding. We are going to need a basic emulation loop going before we put in the CPU. Now bare in mind, this is just a foundation to work with. It doesnt work on its own yet. So create a new project and add a module:
vb Code:
Option Explicit
Public CPU_Paused As Boolean
Public CPU_Running As Boolean
Public Instruction(256) As Long 'Dont know how many instructions yet so keep it 256 for now
Public Cycles(256) As Long
Public Opcode As Long
Public PC As Long
Public Tick_Count As Long
Public Function ReadMemory(ByVal Address As Long) As Long
ReadMemory = 0
End Function
Public Sub Execute_68000()
If CPU_Paused = True Then
Do Until CPU_Paused = False And CPU_Running = True
DoEvents
Loop
End If
Opcode = ReadMemory(PC) ' Fetch Next Operation
PC = PC + 1
Tick_Count = Tick_Count + Cycles(Opcode)
Select Case Instruction(Opcode)
End Select
DoEvents
End Sub
vb.net Code:
Option Explicit On
Option Strict On
Public Module mod68000
Public CPU_Paused As Boolean
Public CPU_Running As Boolean
Public Instruction(256) As Integer 'Dont know how many instructions yet so keep it 256 for now
Public Cycles(256) As Integer ''Dont know how many instructions yet so keep it 256 for now
Public Opcode As Integer
Public PC As Integer
Public Tick_Count As Integer
Public Function ReadMemory(ByVal Address As Integer) As Integer
Return 0
End Function
Public Sub Execute_68000()
If CPU_Paused = True Then
Do Until CPU_Paused = False And CPU_Running = True
Application.DoEvents()
Loop
End If
Opcode = ReadMemory(PC) ' Fetch Next Operation
PC = PC + 1
Tick_Count = Tick_Count + Cycles(Opcode)
Select Case Instruction(Opcode)
End Select
Application.DoEvents()
End Sub
End Module
Thats all for now. Tomorrow we will actually start building the CPU from scratch one opcode at a time. And there are a lot! Have a good one
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
|