Discuss Scratch

CoolCode16
Scratcher
19 posts

Sega Master System/GameGear emulator assistance - VDP

https://scratch.mit.edu/projects/889057250

This is my first time making an emulator aside from chip-8. And while things have been pretty straightforward so far, I started having trouble when implementing the VDP:
The most important part of the VDP to implement first is the Line Counter (Vcnt), since most if not all ROMS get stuck in a loop waiting for it to return a certain value. But knowing what value it's currently on is a bit difficult, since the only thing in the emulator that represents elapsed time is the number of CPU cycled emulated. And most places that specify how many cycles correspond to 1 line seem to give slightly different values. They say 227.5, but when I did some math I ended up with a number closed to 204. And also what about cycles per pixel? cycles per frame? I remember someone said something about a half-line at the end of each frame at one point.
PS. I'm not going to snoop around in @Aart1256's code either. Not that I can read it anyway, that's half the reason I made my own.

Last edited by CoolCode16 (Dec. 16, 2025 02:01:21)

CoolCode16
Scratcher
19 posts

Sega Master System/GameGear emulator assistance - VDP

CoolCode16 wrote:

https://scratch.mit.edu/projects/889057250

This is my first time making an emulator aside from chip-8. And while things have been pretty straightforward so far, I started having trouble when implementing the VDP:
The most important part of the VDP to implement first is the Line Counter (Vcnt), since most if not all ROMS get stuck in a loop waiting for it to return a certain value. But knowing what value it's currently on is a bit difficult, since the only thing in the emulator that represents elapsed time is the number of CPU cycled emulated. And most places that specify how many cycles correspond to 1 line seem to give slightly different values. They say 227.5, but when I did some math I ended up with a number closed to 204. And also what about cycles per pixel? cycles per frame? I remember someone said something about a half-line at the end of each frame at one point.
PS. I'm not going to snoop around in @Aart1256's code either. Not that I can read it anyway, that's half the reason I made my own.

I've just figured out most of the Vcnt and VDP timing stuff (I found https://www.smspower.org/forums/8161-SMSDisplayTiming), though I'm still not sure if I should calculate the Vcnt value or store the values in a list/table.

Now, I need to fugure out what's causing the CPU to loop forever when starting a ROM instead of trying to run it without displaying anything.

Powered by DjangoBB