Page 1 of 2 12 LastLast
Results 1 to 40 of 41

Thread: Lets make a Sega Genesis Emulator

  1. #1

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    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:
    1. Option Explicit
    2.  
    3. Public CPU_Paused As Boolean
    4. Public CPU_Running As Boolean
    5. Public Instruction(256) As Long 'Dont know how many instructions yet so keep it 256 for now
    6. Public Cycles(256) As Long
    7.  
    8. Public Opcode As Long
    9. Public PC As Long
    10. Public Tick_Count As Long
    11.  
    12.  
    13. Public Function ReadMemory(ByVal Address As Long) As Long
    14.     ReadMemory = 0
    15. End Function
    16.  
    17.  
    18. Public Sub Execute_68000()
    19.     If CPU_Paused = True Then
    20.         Do Until CPU_Paused = False And CPU_Running = True
    21.             DoEvents
    22.         Loop
    23.     End If
    24.  
    25.     Opcode = ReadMemory(PC)  ' Fetch Next Operation
    26.     PC = PC + 1
    27.     Tick_Count = Tick_Count + Cycles(Opcode)
    28.    
    29.     Select Case Instruction(Opcode)
    30.  
    31.     End Select
    32.    
    33.     DoEvents
    34. End Sub

    vb.net Code:
    1. Option Explicit On
    2. Option Strict On
    3.  
    4. Public Module mod68000
    5.  
    6.     Public CPU_Paused As Boolean
    7.     Public CPU_Running As Boolean
    8.     Public Instruction(256) As Integer 'Dont know how many instructions yet so keep it 256 for now
    9.     Public Cycles(256) As Integer ''Dont know how many instructions yet so keep it 256 for now
    10.  
    11.     Public Opcode As Integer
    12.     Public PC As Integer
    13.     Public Tick_Count As Integer
    14.  
    15.  
    16.     Public Function ReadMemory(ByVal Address As Integer) As Integer
    17.         Return 0
    18.     End Function
    19.  
    20.  
    21.     Public Sub Execute_68000()
    22.         If CPU_Paused = True Then
    23.             Do Until CPU_Paused = False And CPU_Running = True
    24.                 Application.DoEvents()
    25.             Loop
    26.         End If
    27.  
    28.         Opcode = ReadMemory(PC)  ' Fetch Next Operation
    29.         PC = PC + 1
    30.         Tick_Count = Tick_Count + Cycles(Opcode)
    31.  
    32.         Select Case Instruction(Opcode)
    33.  
    34.         End Select
    35.  
    36.         Application.DoEvents()
    37.     End Sub
    38.  
    39. 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

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Lets make a Sega Genesis Emulator

    Does one need to understand every detail of how a processor works to emulate it or are there things one can pass on when dealing with emulation ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    The only thing you will need to know about the processor are the Opcodes and Address Modes. Once you understand what each instruction does, then you can code it. Shortly today when I have time, I'm gonna go about them

  4. #4

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Wow after investigating 2 open source emulators written in C, one being a famous one called DGen, I noticed they both had nearly identical code with the 68k, only it was a lot more complex and not written like a simple NES emulator at all. It literally is working with binary numbers for the instruction set. But I don't want to just guess that it really is. I want to know. So were going to have to dig deeper. A simple google search of Sega Genesis Documentation led me to this page http://www.genny4ever.net/index.php?page=docs#md. So I'm gonna read up on the docs and quite possibly dig for more open source emulators to get a general idea on the 68k processor. The more we learn about it, the more we should be able to emulate it. Once we have a foundation to work with, then we can jump into things such as loading a game from file, reading and writing from memory, the PPU, APU, etc.

    Plus this PDF doc should help as well http://www.freescale.com/files/archi.../M68000PRM.pdf

  5. #5

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    After reading that PDF, I gathered more information than anything. So what I'm gonna do is list the instructions. Then later we will logically program the instructions one by one as long as the instruction is associated with the CPU the Genesis uses. Bare in mind not all the instructions go with every M68000 processor as there are multiple versions of the M68000 family such as the MC68010, MC68020, MC68030, MC68040, as well as a CPU32 version. Each have similar instructions but have additional instructions the other processors don't have. What I want to know exactly is which processor does the model 1, 2, and 3 of the Sega Genesis uses, so I'm not wasting time coding on instructions that will never compute. For now I'm gonna list what I believe to be nearly all the instructions the entire M68000 family uses. So here is a list I gathered so far from that PDF found here: http://www.freescale.com/files/archi.../M68000PRM.pdf

    1. ABCD - Add Decimal with Extend
    2. ADD - Add
    3. ADDA - Add Address
    4. ADDI - Add Immediate
    5. ADDQ - Add Quick
    6. ADDX - Add Extended
    7. AND - And Logical
    8. ANDI - And Immediate
    9. ANDI to CCR - CCR AND Immediate
    10. ASL - Arithmetic Left Shift
    11. ASR - Arithmetic Right Shift
    12. Bcc - Branch Conditionally
    13. BCHG - Test a Bit and Change
    14. BCLR - Test a Bit and Clear
    15. BFCHG - Test Bit Field and Change
    16. BFCLR - Test Bit Field and Clear
    17. BFEXTS - Extract Bit Field Signed
    18. BFEXTU - Extract Bit Field Unsigned
    19. BFFFO - Find First One in Bit Field
    20. BFINS - Insert Bit Field
    21. BFSET - Test Bit Field and Set
    22. BFTST - Test Bit Field
    23. BKPT - Breakpoint
    24. BRA - Branch Always
    25. BSET - Test Bit and Set
    26. BSR - Branch to Subroutine
    27. BTST - Test a Bit
    28. CALLM - Call Module
    29. CAS - Compare and Swap with Operand
    30. CAS2 - Compare and Swap with Operand
    31. CHK - Check Register Against Bounds
    32. CHK2 - Check Register Against Bounds
    33. CLR - Clear an Operand
    34. CMP - Compare
    35. CMPA - Compare Address
    36. CMPI - Compare Immediate
    37. CMPM - Compare Memory
    38. CMP2 - Compare Register Against Bounds
    39. cpBcc - Branch on Coprocessor Condition
    40. cpDBcc - Test Coprocessor Condition Decrement and Branch
    41. cpGEN - Coprocessor General Function
    42. cpScc - Set on Coprocessor Condition
    43. cpTRAPcc - Trap on Coprocessor Condition
    44. DBcc - Test Condition, Decrement, and Branch
    45. DIVS - Signed Divide
    46. DIVSL - Signed Divide
    47. DIVU - Unsigned Divide
    48. DIVUL - Unsigned Divide
    49. EOR - Exclusive Or Logical
    50. EORI - Exclusive Or Immediate
    51. EORI to CCR - Exclusive Or Immediate to Condition Code
    52. EXG - Exchange Registers
    53. EXT - Sign Extend
    54. EXTB - Sign Extend
    55. ILLEGAL - Take Illegal Instruction Trap
    56. JMP - Jump
    57. JSR - Jump to Subroutine
    58. LEA - Load Effective Address
    59. LINK - Link and Allocate
    60. LSL - Logical Shift Left
    61. LSR - Logical Shift Right
    62. MOVE - Move Data from Source to Destination
    63. MOVEA - Move Address
    64. MOVE from CCR - Move From Condition Code Register
    65. MOVE to CCR - Move to Condition Code Register
    66. MOVE from SR - Move From Status Register
    67. MOVE16 - Move 16 Byte Block
    68. MOVEM - Move Multiple Registers
    69. MOVEP - Move Peripheral Data
    70. MOVEQ - Move Quick
    71. MULS - Signed Multiply
    72. MULU - Unsigned Multiply
    73. NBCD - Negate Decimal with Extend
    74. NEG - Negate
    75. NEGX - Negate With Extend
    76. NOP - No Operation
    77. NOT - Logical Complement
    78. OR - Inclusive Or Logical
    79. ORI - Inclusive Or (Immediate)
    80. ORI to CCR - Inclusive Or Immediate to Condition Codes
    81. PACK - Pack
    82. PEA - Push Effective Address
    83. ROL - Rotate (Without Extend) Left
    84. ROR - Rotate (Without Extend) Right
    85. ROXL - Rotate (With Extend) Left
    86. ROXR - Rotate (With Extend) Right
    87. RTD - Return and Deallocate
    88. RTM - Return From Module
    89. RTR - Return and Restore Condition Codes
    90. RTS - Return from Subroutine
    91. SBCD - Subtract Decimal with Extend
    92. Scc - Set According to Condition
    93. SUB - Subtract
    94. SUBA - Subtract Address
    95. SUBI - Subtract Immediate
    96. SUBQ - Subtract Quick
    97. SUBX - Subtract with Extend
    98. SWAP - Swap Register Halves
    99. TAS - Test and Set an Operand
    100. TRAP - Trap
    101. TRAPcc - Trap on Condition
    102. TRAPV - Trap on Overflow
    103. TST - Test an Operand
    104. UNLK - Unlink
    105. UNPK - Unpack BCD

    Directly Supported Floating Point Instructions:
    ----------------------------------
    FABS - Floating-Point Absolute Value
    FADD - Floating-Point Add
    FBcc - Floating-Point Branch Conditionally
    FCMP - Floating-Point Compare
    FDBcc - Floating-Point Test Condition, Decrement, and Branch
    FDIV - Floating-Point Divide
    FMOVE - Move Floating-Point Data Register
    FMOVE - Move Floating-Point System Control Register
    FMOVEM - Move Multiple Floating-Point System Data Register
    FMOVEM - Move Multiple Floating-Point Control Data Register
    FMUL - Floating-Point Multiply
    FNEG - Floating-Point Negate
    FNOP - No Operation
    FRESTORE* - Restore Internal Floating-Point State*
    FSAVE* - Save Internal Floating-Point State*
    FScc - Set According to Floating-Point Condition
    FSORT - Floating-Point Square Root
    FSUB - Floating-Point Subtract
    FSGLDIV - Floating-Point Single-Precision Divide
    FSFLMUL - Floating-Point Single-Precision Multiply
    FTRAPcc - Trap on Floating-Point Condition
    FTST - Test Floating-Point Operand

    Indirectly Supported Floating Point Instructions:
    -------------------------------------------------
    FACOS - Floating-Point Arc Cosine
    FASIN - Floating-Point Arc Sine
    FATAN - Floating-Point Arc Tangent
    FATANH - Floating-Point Hyperbolic Arc Tangent
    FCOS - Floating-Point Cosine
    FCOSH - Floating-Point Hyperbolic Cosine
    FETOX - Floating-Point e^x
    FETOXM1 - Floating-Point e^x– 1
    FGETEXP - Floating-Point Get Exponent
    FGETMAN - Floating-Point Get Mantissa
    FINT - Floating-Point Integer Part
    FINTRZ - Floating-Point Integer Part, Round-to- Zero
    FLOG10 - Floating-Point Log10
    FLOG2 - Floating-Point Log2
    FLOGN - Floating-Point Loge
    FLOGNP1 - Floating-Point Log e^(x + 1)
    FMOD - Floating-Point Modulo Remainder
    FMOVECR - Floating-Point Move Constant ROM
    FREM - Floating-Point IEEE Remainder
    FSCALE - Floating-Point Scale Exponent
    FSIN - Floating-Point Sine
    FSINCOS - Floating-Point Simultaneous Sine and Cosine
    FSINH - Floating-Point Hyperbolic Sine
    FTAN - Floating-Point Tangent
    FTANH - Floating-Point Hyperbolic Tangent
    FTENTOX - Floating-Point 10^x
    FTWOTOX - Floating-Point 2^x

  6. #6
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Lets make a Sega Genesis Emulator

    I'm intrigued. What kinda timeline are you expecting for this. I mean how long would a project like this take to complete ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  7. #7

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Honestly since I never made a Sega Emulator before I dont know. But Im passionate about emulation and very curious of the results since noone had the guts to even attempt it in VB. I have both the model 1 and 2 Sega Genesis at my house. So I am gonna take them apart to see what M68000 processor they use. Once I am satisfied, I can eliminate most of the instructions that wont be used.

  8. #8

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    I'm going to have to compare these to the 2 C++ version of the Sega Genesis emulator I currently have and do some research but at least I have a foundation for the M68000 processor's Opcodes source code to work with...in C#

    http://sega360.codeplex.com/SourceCo...anipulation.cs

    I'm also gonna need a CCR (Condition Code Register) for the opcodes as well, which are these:

    X - Extend: Set to the value of the C-bit for arithmetic operations; otherwise not affected or set to a specified result.

    N - Negative: Set if the most significant bit of the result is set; otherwise clear.

    Z - Zero: Set if the result equals zero; otherwise clear.

    V - Overflow: Set if an arithmetic overflow occurs implying that the result cannot be represented in the operand size; otherwise clear.

    C - Carry: Set if a carry out of the most significant bit of the operand occurs for an addition, or if a borrow occurs in a subtraction; otherwise clear.

  9. #9

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Alrighty I'm back people. I took apart my Sega Genesis Model 1 and ran into a surprise. The Model 1 version I have has a 68 Pin Quad Pack Motorola MC68HC000FN8 Chip as you can see in these photos:




    However I saw photos of another Genesis Model 1 that uses a 64 pin Motorola MC68000P8:


    Don't exactly know the difference between them. Maybe it had something to do with the expansion port for the Sega CD, I honestly don't know. Matter of fact I found a good site showing the other chip sets Sega used: http://console5.com/wiki/68000

    Bottom line is that I'm gonna assume that the Sega Genesis uses an MC68000 and nothing more. So with that said we are gonna eliminate the unused operands as of right now. So I'm gonna cycle through the PDF document I shown earlier and make a check list.

    [EDIT] Its interesting to see that there were 3 different versions of the Sega Genesis Model 1. I have the latest version with the motherboard labeled PC BD M5 USA VA7. You can see it in the pic just under the heat sink. And here are the others: http://console5.com/wiki/Genesis

  10. #10

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Ok so I weeded out the opcode instructions that the Sega Genesis doesn't have. All these instructions are part of the 68000 family according to the PDF. And the floating point instructions are NOT part of the MC68000. In fact the directly supported floating point instructions are only supported in the MC6888X and MC68040, and the indirectly supported floating point instructions are only supported in the MC6888X and MC68040FPSW. With X being I'm guessing version number. Bottom line is they arent supported at all in the Sega Genesis, hence, wont be calculated in the emulator. So now here is the new list of instructions I gathered up:

    1. ABCD - Add Decimal with Extend
    2. ADD - Add
    3. ADDA - Add Address
    4. ADDI - Add Immediate
    5. ADDQ - Add Quick
    6. ADDX - Add Extended
    7. AND - And Logical
    8. ANDI - And Immediate
    9. ANDI to CCR - CCR AND Immediate
    10. ASL - Arithmetic Left Shift
    11. ASR - Arithmetic Right Shift
    12. Bcc - Branch Conditionally
    13. BCHG - Test a Bit and Change
    14. BCLR - Test a Bit and Clear
    15. BRA - Branch Always
    16. BSET - Test Bit and Set
    17. BSR - Branch to Subroutine
    18. BTST - Test a Bit
    19. CHK - Check Register Against Bounds
    20. CLR - Clear an Operand
    21. CMP - Compare
    22. CMPA - Compare Address
    23. CMPI - Compare Immediate
    24. CMPM - Compare Memory
    25. DBcc - Test Condition, Decrement, and Branch
    26. DIVS - Signed Divide
    27. DIVSL - Signed Divide
    28. DIVU - Unsigned Divide
    29. DIVUL - Unsigned Divide
    30. EOR - Exclusive Or Logical
    31. EORI - Exclusive Or Immediate
    32. EORI to CCR - Exclusive Or Immediate to Condition Code
    33. EXG - Exchange Registers
    34. EXT - Sign Extend
    35. EXTB - Sign Extend
    36. ILLEGAL - Take Illegal Instruction Trap
    37. JMP - Jump
    38. JSR - Jump to Subroutine
    39. LEA - Load Effective Address
    40. LINK - Link and Allocate
    41. LSL - Logical Shift Left
    42. LSR - Logical Shift Right
    43. MOVE - Move Data from Source to Destination
    44. MOVEA - Move Address
    45. MOVE to CCR - Move to Condition Code Register
    46. MOVE from SR - Move From Status Register
    47. MOVEM - Move Multiple Registers
    48. MOVEP - Move Peripheral Data
    49. MOVEQ - Move Quick
    50. MULS - Signed Multiply
    51. MULU - Unsigned Multiply
    52. NBCD - Negate Decimal with Extend
    53. NEG - Negate
    54. NEGX - Negate With Extend
    55. NOP - No Operation
    56. NOT - Logical Complement
    57. OR - Inclusive Or Logical
    58. ORI - Inclusive Or (Immediate)
    59. ORI to CCR - Inclusive Or Immediate to Condition Codes
    60. PEA - Push Effective Address
    61. ROL - Rotate (Without Extend) Left
    62. ROR - Rotate (Without Extend) Right
    63. ROXL - Rotate (With Extend) Left
    64. ROXR - Rotate (With Extend) Right
    65. RTR - Return and Restore Condition Codes
    66. RTS - Return from Subroutine
    67. SBCD - Subtract Decimal with Extend
    68. Scc - Set According to Condition
    69. SUB - Subtract
    70. SUBA - Subtract Address
    71. SUBI - Subtract Immediate
    72. SUBQ - Subtract Quick
    73. SUBX - Subtract with Extend
    74. SWAP - Swap Register Halves
    75. TAS - Test and Set an Operand
    76. TRAP - Trap
    77. TRAPV - Trap on Overflow
    78. TST - Test an Operand
    79. UNLK - Unlink

    We narrowed it down to just 79 opcode instructions. You must bare in mind I'm taking all the information I'm gathering online and from other emulators with a grain of salt. If I see consistancy with any information, I'm gonna say its safe to assume its correct. Due to the fact that the PDF is the official Motorola 68000 chip documentation, I think I did a pretty good job. And just to see if I am truely right when I did narrow it down, there are a list of opcodes on another site which is here: http://emu-docs.org/CPU%2068k/68000inst.txt

  11. #11
    Addicted Member omundodogabriel's Avatar
    Join Date
    May 2013
    Posts
    177

    Re: Lets make a Sega Genesis Emulator

    I made a very simple ui in vb.net today, and writted the code to read the rom header.

    I found the "secret" sega document here:
    http://emu-docs.org/Genesis/sega2f.htm

    I also managed to download de generator source code (an old sega genesis emulator for linux/dos). Maybe we can use something from the sources.

    generator-0.15.zip

    The interesting thing is that there is a vb.net sdk for windows phone, maybe we can even port the emulator for windows phone when mature.

    This weekend I'll see if I look at the CPU.

  12. #12
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Lets make a Sega Genesis Emulator

    Quote Originally Posted by omundodogabriel View Post
    I found the "secret" sega document here:
    http://emu-docs.org/Genesis/sega2f.htm
    Wow, I barely understood anything in that doc. It would probably take a year of consistent research and study for that doc to actually make sense to me.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  13. #13

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Nah its no different than how the Nintendo emulator was. Emulate the Opcode instructions, Read/Write from the Memory map only in this case its 32 bit so there are 16777215 addresses (or FFFFFF, see table)



    and last but not least emulate the video and sound hardware. Its not rocket science. It just takes mad common sense skills

    [EDIT] To Omundodogabriel: I found a good link that shows source code to the opcode instructions along with the CCR registers to each of them just to serve as a basis http://sega360.codeplex.com/SourceCo...anipulation.cs

  14. #14

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Since in the other emulators im not exactly seeing the ABCD instruction (probably because it was sort of embeded into the ADD instruction itself I'm assuming...at least in one of the emulators) we are going to skip that and focus on ADD. So according to the Motorola 68000 PDF documentation:

    Code:
    ADD
    (M68000 Family)
    
    Operation: Source + Destination→Destination
    
    Assembler: ADD < ea > ,Dn
    
    Syntax: ADD Dn, < ea >
    
    Attributes: Size = (Byte, Word, Long)
    Description: Adds the source operand to the destination operand using binary addition and stores the result in the destination location. The size of the operation may be specified as byte, word, or long. The mode of the instruction indicates which operand is the source and which is the destination, as well as the operand size.
    
    Condition Codes:
    X — Set the same as the carry bit.
    N — Set if the result is negative; cleared otherwise.
    Z — Set if the result is zero; cleared otherwise.
    V — Set if an overflow is generated; cleared otherwise.
    C — Set if a carry is generated; cleared otherwise.
    
    Instruction Format:
    X *
    N *
    Z *
    V *
    C *
    
    |15|14|13|12|11|10|09|08|07|06|05|04|03||02|01|00|
    | 1 | 1 | 0| 1 |REGISTER|OPMODE| MODE | REGISTER |
    There are also multiple data types used for ADD such as Byte (8 bit), Short (16 Bit), as well as Integer (32 bit). 64 bit instructions are not supported. And according to one emulators I examined, there are 2 different versions of each. One version having condition code registers updated and the other not having condition code registers updated. For example, here is the C# version:

    C# Code:
    1. #region Add Helper Functions
    2.         private sbyte Add(sbyte a, sbyte b, bool updateConditions, bool useX)
    3.         {
    4.             int result = useX ? (int)a + (int)b + (this.X ? 1 : 0) : (int)a + (int)b;
    5.  
    6.             if (updateConditions)
    7.             {
    8.                 this.C = this.X = (result & 0x100) > 0;
    9.                 this.V = result > sbyte.MaxValue || result < sbyte.MinValue;
    10.                 this.N = result < 0;
    11.                 if (!useX) { this.Z = result == 0; }
    12.             }
    13.  
    14.             return (sbyte)result;
    15.         }
    16.  
    17.         private short Add(short a, short b, bool updateConditions, bool useX)
    18.         {
    19.             int result = useX ? (int)a + (int)b + (this.X ? 1 : 0) : (int)a + (int)b;
    20.  
    21.             if (updateConditions)
    22.             {
    23.                 this.C = this.X = (result & 0x10000) > 0;
    24.                 this.V = result > short.MaxValue || result < short.MinValue;
    25.                 this.N = result < 0;
    26.                 if (!useX) { this.Z = result == 0; }
    27.             }
    28.  
    29.             return (short)result;
    30.         }
    31.  
    32.         private int Add(int a, int b, bool updateConditions, bool useX)
    33.         {
    34.             long result = useX ? (long)a + (long)b + (this.X ? 1 : 0) : (long)a + (long)b;
    35.  
    36.             if (updateConditions)
    37.             {
    38.                 this.C = this.X = (result & 0x100000000) > 0;
    39.                 this.V = result > int.MaxValue || result < int.MinValue;
    40.                 this.N = result < 0;
    41.                 if (!useX) { this.Z = result == 0; }
    42.             }
    43.  
    44.             return (int)result;
    45.         }
    46.         #endregion Add Helper Functions

    The C++ version unfortunately had waaaay too many versions of ADD and I believe was overkill and complex for no reason IMO. I think the main difference was the Program Counter (PC) and thats about it but I will need to examine the code more closely. So this will be the primary focus before we translate it to VB.

  15. #15
    Addicted Member omundodogabriel's Avatar
    Join Date
    May 2013
    Posts
    177

    Re: Lets make a Sega Genesis Emulator

    I found a simple and good doc about 68k opcodes: http://goldencrystal.free.fr/M68kOpcodes.pdf

    NOTE: The hex values of each opcode are represented in binary.

    All 68k instructions with descriptions can be found here: http://68k.hax.com/


    I wrote the Memory Read/Write functions and CPU Reset.
    VBnet Code:
    1. Module MMU
    2.     Public Memory(&HFFFFFF) As Byte '16 MB Ram
    3. #Region "Read Memory"
    4.     Public Function ReadMemory8(Address As Integer) As Byte 'B
    5.         Return Memory(Address)
    6.     End Function
    7.     Public Function ReadMemory16(Address As Integer) As Integer 'W
    8.         Return Memory(Address + 1) + _
    9.             (Memory(Address) * &H100)
    10.     End Function
    11.     Public Function ReadMemory32(Address As Integer) As Long 'L
    12.         Return Memory(Address + 3) + _
    13.             (Memory(Address + 2) * &H100) + _
    14.             (Memory(Address + 1) * &H10000) + _
    15.             (Memory(Address) * &H1000000)
    16.     End Function
    17. #End Region
    18.  
    19. #Region "Write Memory"
    20.     Public Sub WriteMemory8(Address As Integer, Value As Byte) 'B
    21.         Memory(Address) = Value
    22.     End Sub
    23.     Public Sub WriteMemory16(Address As Integer, Value As Integer) 'W
    24.         Memory(Address) = ((Value And &HFF00) / &H100) And &HFF
    25.         Memory(Address + 1) = (Value And &HFF) And &HFF
    26.     End Sub
    27.     Public Sub WriteMemory32(Address As Integer, Value As Long) 'L
    28.         Memory(Address) = ((Value And &HFF000000) / &H1000000) And &HFF
    29.         Memory(Address + 1) = ((Value And &HFF0000) / &H10000) And &HFF
    30.         Memory(Address + 2) = ((Value And &HFF00) / &H100) And &HFF
    31.         Memory(Address + 3) = (Value And &HFF) And &HFF
    32.     End Sub
    33. #End Region
    34. End Module

    CPU Reset

    VBnet Code:
    1. Module M68k
    2.     Dim PC As Long
    3.     Dim Regs(15) As Long '32-bit D0-D7 and A0-A7 Regs
    4.     Public Sub M68k_Reset()
    5.         'Reset Program Counter
    6.         PC = ReadMemory32(&H4)
    7.  
    8.         'Clear Registers
    9.         For i As Integer = 0 To 15
    10.             Regs(i) = 0
    11.         Next
    12.  
    13.         MsgBox("Reset to $" & Hex(PC))
    14.     End Sub
    15. End Module


    The next step is start writing the opcodes.
    Last edited by omundodogabriel; Aug 2nd, 2013 at 03:25 PM.

  16. #16

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Ive been away for awhile since Ive been playing a lot of World of Warcraft lately. Rather than talk about one opcode at a time which would be slow and sluggish, Im doing the whole 68000 module. Once its complete in both VB6 and VB.Net you will be able to upload the game ROM and see the opcodes in action. Just no video or sound yet. Thatll be the next step.

  17. #17
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    Joined the forum just for this project after seeing your NES emulator thread leading here. I'm olaf, the programmer of olafnes and Zega Alpha (two emulators written in VB6). I'd like to hop on this Genesis project.

  18. #18
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    Here's the current page for Zega Alpha. It's a continuation of vbSMS, a Sega Master System emulator that I spruced up.

    http://www.nothackers.com/zegaalpha/

  19. #19
    Addicted Member omundodogabriel's Avatar
    Join Date
    May 2013
    Posts
    177

    Re: Lets make a Sega Genesis Emulator

    Welcome olaf! I saw your emulator olafnes some time ago, I was helping with jacob nes emulator, and researching more about basicnes when I found olafnes page on sourceforge. The basicnes 6502 emulation code was bad written, and had a lot of timing issues, wrong flags and messy code. I rewrote most of the code, based on virtuanes sources and docs from nesdev. Is a lot better now, just need some minor fixes. The wrong timing cause some strange glitches, like the map on battletoads intro, maniac mansion not scrolling correctly...

    I VDP is similar to sega master system, then I think we can use the code vdp master system with some minor modifications.
    Jacob, how it's going with the 68k CPU emulation? Need some help?

  20. #20
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Lets make a Sega Genesis Emulator

    Hey, this could be awesome!! I'd love to help. I've been wanting to make a Genesis emulator. I've got experience writing emulators. Mostly in C, but I did create a VB6 8086 PC emulator too. It's posted here: http://www.vbforums.com/showthread.p...6-PC-emulator! and the C version (way way better) is here http://sourceforge.net/projects/fake86

    I've also written a completely working NES emulator in both C and FreeBASIC, as well as an Apple II emulator. I wrote all of the code in each of them, including the CPU stuff from scratch. So, I've emulated an 80186 (it has a few more instructions than the 8086) and a 6502. I can definitely help out. Here's a screenshot of my NES emu in action playing Mega Man 2:




    Now let's do this, bitches! I really want to see a working Genesis emu in VB. Would be ridiculous! So where are we with this right now? Are you still on the m68k code? If you're stuck, I can help if you provide the current code.
    Last edited by miker00lz; Aug 12th, 2013 at 10:15 AM.

  21. #21
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    Quote Originally Posted by omundodogabriel View Post
    Welcome olaf! I saw your emulator olafnes some time ago, I was helping with jacob nes emulator, and researching more about basicnes when I found olafnes page on sourceforge. The basicnes 6502 emulation code was bad written, and had a lot of timing issues, wrong flags and messy code. I rewrote most of the code, based on virtuanes sources and docs from nesdev. Is a lot better now, just need some minor fixes. The wrong timing cause some strange glitches, like the map on battletoads intro, maniac mansion not scrolling correctly...

    I VDP is similar to sega master system, then I think we can use the code vdp master system with some minor modifications.
    Jacob, how it's going with the 68k CPU emulation? Need some help?
    I'd love to see the fixes done to the source code if it's still around. I've been meaning to rework the emulator as I now have a lot more experience with that sort of thing after Zega Alpha. I've really gotten down and dirty with the Master System and Game Gear stuff in recent years, so I can carry that back to my NES project now. Zega Alpha also has the better Game Gear's VDP thanks to Parasyte (ROM hacker, discoverer of the Metroid code) and benryves (programmer of the Cogwheel emulator). I've never looked too much into the technical aspects of the Genesis VDP, but it's probable that the Game Gear's architecture is relatively closer to it. The increased color palette, sprite zooming, and so forth.

    Most of my experience prior to working on emulators was application development. Much of what I added to the emulators I based my work off of was full screen, Game Genie, save states, movies, rewinding, PC controller support, memory editors, and so on. However I did fix things like timing issues, added support for peripherals, mappers, and things like that.

    Might I suggest if we're welcome to work on the project to keep a shared FTP with the files on it or something? Perhaps also chatting on IRC as a group? I'd be more than happy to make some room on nothackers.com for the project.

  22. #22
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Lets make a Sega Genesis Emulator

    I second an IRC channel. Great idea. It would definitely be the best way to work in realtime. Everything else is too slow, and it would take forever. I run an IRCd that could be used. Might be better than a full-blown public server for a project like this.

  23. #23
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    After doing some research on the Sega Genesis, I've found...

    - The Sega Master System's Z80 processor is used as a co-processor for the Sega Genesis. So you're welcome to gut that out of Zega Alpha. This Z80 core comes from vbSpec, the Sinclair ZX Spectrum emulator written in VB6. This as well as the VDP and everything else is available to you guys from me.

    - Wikipedia says that the Genesis VDP is actually derived from the Master System/Game Gear VDP. It's actually between them in number of possible colors and stuff, so I imagine they are very very close.

    - The Texas Instruments SN76489 PSG sound chip is also used from the Master System. I don't have the FM chip also used programmed into my emulator (as only a few games supported it, mostly imports), but MEKA and Genesis emulators are open source so it'd be possible to bring that chip over too. In fact, if I can get a hold of vbt, I may be able to coax him into implementing that. He ported the PSG sound chip in from SMS Plus! for Saturn to VB6 for me.

    Anyway, just figured I'd flesh out some more details that are obviously of major use. We could recode stuff as needed. Zega Alpha's source is available here. As far as I know my emulator passes the ZEXALL test ROM as well (an emulator tool to test how accurate your Z80 and VDP emulators are).
    Last edited by notolaf; Aug 14th, 2013 at 04:28 PM.

  24. #24

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Hey guys, sorry about the long wait. I've been having some personal issues lately with my job, my gf (and her birthday), and other things. So I took a little break from VBForums and programming in general until I can get my life back in order. But I'm back now. Yes I will probably need some help and would love for you guys to join in on the project. I think with all of us as a team (including my awesome DirectX programming skills) we can add some "Blast Processing" in VB.

  25. #25
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    Sounds bueno.

  26. #26
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Lets make a Sega Genesis Emulator

    Quote Originally Posted by Jacob Roman View Post
    Hey guys, sorry about the long wait. I've been having some personal issues lately with my job, my gf (and her birthday), and other things.
    Oh please, I know you got hooked on WoW
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  27. #27
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    So are there some skeleton modules we can look at? I'd like to start pitching in during my spare time if possible.

  28. #28

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Quote Originally Posted by notolaf View Post
    So are there some skeleton modules we can look at? I'd like to start pitching in during my spare time if possible.
    See post #24 for details. It was that...and WoW

    I havent programmed or did anything at that time. Had too many things going on which put a lot of stress on me. But I'm back now. So now I can slowely but surely get a skeleton going.

  29. #29
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    Alright, keep us posted.

  30. #30
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Lets make a Sega Genesis Emulator

    The basic structure is pretty much still like a NES emulator I think. Just to play around with the idea, I used somebody's 68000 core in C and created a ROM loader for it, and started emulation with some debug output. I ran Sonic 1, and it runs code. It starts communicating with the VDP registers which sit at $C00000. So, if we started there and then began emulating the VDP's features I'm pretty sure we could at least get a Sonic title screen showing. Of course, we still need to make a 68000 core for VB first.

    What I have here seems like it's waiting for some interrupts or the correct status flags from the VDP.
    Last edited by miker00lz; Aug 19th, 2013 at 05:47 PM.

  31. #31
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    http://cgfm2.emuviews.com/txt/genvdp.txt

    Notes on the Genesis VDP written by Charles MacDonald. I've chatted with him on many occasions and he's extremely knowledgeable about the Sega consoles and others. He's written SMS Plus, Genesis Plus, and TGEmu. To backup further what I was saying earlier about the VDP probably being based on the Master System and Game Gear's VDP (straight from his document):

    Code:
    ----------------------------------------------------------------------------
     1.) Overview
     ----------------------------------------------------------------------------
    
     The Genesis VDP is derived from the Master System VDP, which in turn
     was derived from the Texas Instruments TMS9918. As a result, the VDP is
     programmed much like it's earlier counterparts.
    
     Interestingly enough, none of the Sega produced VDP's are similar to the
     later VDP models made by Yamaha, which were also based upon the TMS9918.
    
     ----------------------------------------------------------------------------
     2.) Display Modes
     ----------------------------------------------------------------------------
    
     To clarify naming conventions, here is a list of display modes used by
     the various video chips mentioned:
    
     Mode 0 - TMS9918 specific
     Mode 1 - TMS9918 specific
     Mode 2 - TMS9918 specific
     Mode 3 - TMS9918 specific
     Mode 4 - SMS mode
     Mode 5 - Genesis mode
    
     Supported mode list:
    
     TMS9918    - Modes 0, 1, 2, 3
     SMS        - Modes 0, 1, 2, 3, 4
     Genesis    - Modes 4, 5 (possibly 0 and others as well)
    
     If anybody has some information about how the Game Gear would fit into
     this list, let me know. I assume it's identical to the SMS, but I don't
     know about the TMS9918 compatability. (if any)
    I'm sure there's other documentation around but I just felt like following up before I head to bed. So, the source code to my Master System/Game Gear emulator should actually be a pretty big help in the VDP area as well as sound and the Z80 co-processor.

  32. #32
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    Also, Gens/GS is the most recently updated and the most accurate open source Genesis emulator these days AFAIK.

    http://segaretro.org/Gens/GS

  33. #33
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Lets make a Sega Genesis Emulator

    I would hate to see this project die! Any updates?

  34. #34
    New Member notolaf's Avatar
    Join Date
    Aug 2013
    Posts
    10

    Re: Lets make a Sega Genesis Emulator

    Quote Originally Posted by miker00lz View Post
    I would hate to see this project die! Any updates?
    This. Please updates. [:

  35. #35
    Lively Member
    Join Date
    Jun 2016
    Posts
    106

    Re: Lets make a Sega Genesis Emulator

    hi, please updates.
    how i am can load (parsing) the Genesis game .rom file to a VB 6.0 picturebox and display images?
    thanks.

  36. #36
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Lets make a Sega Genesis Emulator

    Quote Originally Posted by xman2000 View Post
    hi, please updates.
    how i am can load (parsing) the Genesis game .rom file to a VB 6.0 picturebox and display images?
    thanks.
    With lots of research and difficulty.

    You need to emulate all of the CPU instructions, the graphics chip, memory subsystem, etc.

    I wouldn't use a picturebox. They're slow. You should have a bitmap buffer and blit it using the DirectDraw API for any kind of speed.

    If you don't know how emulators work, don't start with the Genesis/Megadrive. Start with CHIP-8 or Space Invaders.
    Last edited by miker00lz; Sep 7th, 2021 at 11:32 AM.

  37. #37

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Quote Originally Posted by xman2000 View Post
    hi, please updates.
    how i am can load (parsing) the Genesis game .rom file to a VB 6.0 picturebox and display images?
    thanks.
    Yeah you have to emulate every single instruction from the 68000 chip, as well as address modes, what each of the registers do in the memory itself when it comes to reading and writing (which links with the instructions in the CPU) as well as the PPU. You can take a look at my vb6 Nintendo Emulator in my signature below my post to see what I mean. The only difference is that you are literally tackling 16 bits instead of 8 as well as a lot more instructions and OP codes. I've been super busy with life to get around to it, but if you do some research and look up other open source emulators, you should have no difficulty mimicing this 16 bits worth of blast processing. If you need help, I can guide you in the right places.

    Quote Originally Posted by miker00lz View Post
    With lots of research and difficulty.
    You need to emulate all of the CPU instructions, the graphics chip, memory subsystem, etc.
    I wouldn't use a picturebox. They're slow. You should have a bitmap buffer and blit it using the DirectDraw API for any kind of speed.
    If you don't know how emulators work, don't start with the Genesis/Megadrive. Start with CHIP-8 or Space Invaders.
    Yuck DirectDraw. Noone uses DirectX7 no more. Stick with DirectX8, lock up the memory buffer to write in, write in the memory, and unlock it.

    One day I would like to tackle on a Phillips CD-I emulator in VB6. Now that would take some raw talent [EDIT] And I just may have a shot o.O https://github.com/cdifan/cdichips

  38. #38
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Lets make a Sega Genesis Emulator

    Quote Originally Posted by Jacob Roman View Post
    Yuck DirectDraw. Noone uses DirectX7 no more. Stick with DirectX8, lock up the memory buffer to write in, write in the memory, and unlock it.
    Agreed. I think that's actually what I did in my VB emulators. It's been so long I can't even remember.

  39. #39
    Lively Member
    Join Date
    Jun 2016
    Posts
    106

    Re: Lets make a Sega Genesis Emulator

    thank yours Miker00lz and Jacob Roman !
    very good tips to start with emulators.
    if i am if I knew how to do, if i am if I knew another programming language i would translate Emulators in GITHUB from C#, C++ and others to VB6.0.
    then I would study the code to create my own emulators.

    I wish is to be able to add more features to emulators and games and be able to work on the .ROM files of the games and not have to create emulators

  40. #40

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,333

    Re: Lets make a Sega Genesis Emulator

    Well it shouldnt be too hard to translate to VB6. Besides little syntax differences, youll only need to remove the semicolons. But anywho, use our Nintendo Emulators we wrote in our signatures using VB6 such as this http://www.vbforums.com/showthread.p...31#post4358131

    I rewrote it years later in C++, and in doing so, I found a lot of flaws I never noticed when I did it in VB6. So its actually a better version, and the code is more organized. More readable than my VB6 counterpart. Youll find that in my github here: https://github.com/RomanEntertainmen...C/NES-Emulator

    Also, if you think thats hard, try actually making a Nintendo game o.O https://www.vbforums.com/showthread....etting-Started

    Once you get used to HOW the NES is emulated. You can now gradually jump up to doing the Genesis. The best place to find docs on emulating the Sega Genesis besides Google and open source emulators is Zophars Domain: https://www.zophar.net/documents/genesis.html

    Always begin your code at the CPU when writing an emulator. Then Reading and Writing registers of memory, which will go hand in hand with each CPU instruction. Usually each function will pertain to certain registers or within a number of registers as well as mirrors. Assuming you completed this task, you then write code that loads the rom that the CPU can read. Make sure you have a suitable way to print out the outcomes of your CPU as it executes, such as the shift registers, hex code, instruction executions, etc. If everything seems to be in working order, you can then jump to working out the PPU, which can be a daunting task since you will have no idea where to begin. This is when your research skills will come into play. Assuming it semi works, since you will not always one shot it, then it should be time to work on the sound, which should be a lot easier than the graphics. Generally youll have whatever info in the sound registers go through whatever sound api you are using such as DirectSound which is part of DirectX. The last step is testing out multiple games to find what is compatable or what has flaws. That is when you tinker your code until every flaw is flushed out.

    [EDIT] Just found out that the Sega Genesis uses 2 CPUs. The Motorola 68000 and the Z80, where the Z80 was originally found in the Sega Master System. So you gotta have 2 CPUs working together simultaneously.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width