element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
At The Core Design Challenge
  • Challenges & Projects
  • Design Challenges
  • At The Core Design Challenge
  • More
  • Cancel
At The Core Design Challenge
Blog ATCDC: Digimorf, Day 35, The project SEGA SG-1000 Emulator on PSoC62S4 Pioneer kit - part 8
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join At The Core Design Challenge to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Digimorf
  • Date Created: 3 Apr 2023 7:58 PM Date Created
  • Views 703 views
  • Likes 10 likes
  • Comments 5 comments
  • ram
  • infineon
  • element14
  • PSoC 62S4 pioneer kit
  • modustoolbox
  • challenge
Related
Recommended

ATCDC: Digimorf, Day 35, The project SEGA SG-1000 Emulator on PSoC62S4 Pioneer kit - part 8

Digimorf
Digimorf
3 Apr 2023
ATCDC: Digimorf, Day 35, The project SEGA SG-1000 Emulator on PSoC62S4 Pioneer kit - part 8

Have you ever seen the movie "Apollo 13"? It's one of my favorite movies.

There are many sequences that I like, and many moments of my life match them perfectly. This is the time of the sequence where Ken Mattingly spends hours in a simulator putting together the procedures for starting up the cold, dead command module in time to bring the astronauts safely back to Earth.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image
 

Why I am talking about this sequence? Currently, I really feel like him here but instead of Amps, I am trying to find out KBs. Joy

So, I am formatting the memory layout for both cores, and this is really challenging because the emulator really needs a double video buffer for rendering the game screen, then the emulated VDP needs 16KB in order to make the virtual console work, and 2KB mirrored for the Z80  used as system RAM. Moreover, there are variables and arrays here ad there in the emulator program. 

I knew I would have gone crazy here.       

To make matters worse, the CM4 and CM0+ need to share SRAM where the double buffer lives, because the CM4 renders into the back buffer, while the CM0+ streams the front buffer to the video. at the end of a frame, if there is s new one in the back buffer they are swapped, and so on.

The mechanism works, but what it's difficult to fit is the whole emulator, so some smart optimization is needed... I won't give up until the last day of the challenge Sunglasses                    

  • Sign in to reply

Top Comments

  • dang74
    dang74 over 2 years ago +1
    Cool project. At one point I wanted to design an FPGA based emulator for Coleco Vision. From what I understand the architecture between SG-1000 and Coleco Vision are very similar.
  • Digimorf
    Digimorf over 2 years ago

    Another problem is that the buffer used for rendering graphics into is in a shared memory portion, so if the DMA is accessing the SRAM for streaming the pixels, if the other core accesses at the same time for rendering graphics, even if in another portion of memory, the DMA is affected by some traffic, and the resulting scanline is deformed at video.

    I think I already reached the limits of this board concerning emulation of retro consoles. But, there is still the hope to make something payable Sweat smile

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Digimorf
    Digimorf over 2 years ago in reply to dang74

    Thanks, you are right, but Coleco Vision has more features that makes it a cool machine Blush

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dang74
    dang74 over 2 years ago

    Cool project.  At one point I wanted to design an FPGA based emulator for Coleco Vision.  From what I understand the architecture between SG-1000 and Coleco Vision are very similar.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Digimorf
    Digimorf over 2 years ago

    Maybe, and I am not saying it too loud, I have a solution.

    In order to fit everything needed by the emulator to run, I need 8KB more than offered by the PSoc6. This is because, for a fluid video playing, a double video frame buffer is needed. While the VGA video driver is showing the front buffer, the emulator is rendering the next frame in the back buffer.     

    Unfortunately, the video resolution generated by the VDP TMS9918 is 256*192 pixels wide. That means 49152 bytes or 98304 bytes for a double frame buffer. Moreover, the VDP has 16KB of VRAM, used to store graphic tiles, sprites, etc. Uh, don't forget the machine RAM used by the Z80 CPU, which is 2KB. 

    The total so far is 116,736 bytes. The maximum offered by this PSoC6 is 128Kb, and it should work, but unfortunately, it doesn't.

    Mumble, mumble...

    If I use one frame buffer only, the emulator must render the graphics while the VGA driver is not showing the active area of the video, so let's say the blank area. So (525 - (192 * 2)) = 141 scanlines of time.

    It could work, but the emulator needs to perform other tasks also, like rendering audio, accessing the ROM, etc. I could go for this solution, but...

    Mumble, mumble...

    image

    What if instead of rendering a whole frame at a time, I render half frame at a time?  I could use the double buffer technique but applied it to half of a buffer. So while the VGA driver is showing the first half of the frame, the emulator renders the second half, and so on...

    I will try it, wish me luck!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Digimorf
    Digimorf over 2 years ago

    My new nickname will be Byteskaven Sweat smile

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube