Skip to main content
gamedev.net
🔒 Locked

emulator help

Started by ErUs 7 replies 600+ views
Original Post
ErUs
ErUs
I am trying to emulate the gameboy ( original brick-shape one ). My Questions is: When should the (PC) screen be updated / how do i know when the screen buffer is ready to be drawn to the actual screen?
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
doynax
doynax
You'll have to count CPU cycles and keep track of the emulated video "beam's" position on the LCD in relation to the CPU clock, otherwise you won't be able to handle raster effects properly. The easiest method is probably to run the CPU and render to the back buffer in synchronization, scanline-per-scanline. And then you can just flip it all to screen when the emulated video chip reaches the vertical blanking period, in 60 Hz or so IIRC.

A more exact method is to track any display IO writes from the CPU and this together with the current CPU cycle to the display emulator. Thus the display can draw all pixels between the previous write and the new one. Horiziontal blanking interrupts complicates this a little though.
ErUs
ErUs
ok, thanks m8.
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
Homers Pal
Homers Pal
can I ask why? There are several excellent GB emulators available already.
ErUs
ErUs
because i want to expand my knowledge of both OOP programming and how computer systems work. ( and its geeky-good fun ( and maybe makes me looks good ( u know... with the ladies :P ) ) )
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
Homers Pal
Homers Pal
hmmm it won't...make you look good with the ladies :)

but as for learning GB, I'm prety sure some of the old emulators may be opensource, and were mostly written in C.

Sounds like a fun if not entierly productive project...enjoy
ErUs
ErUs
im still having trouble figuring this out :(

im told cpu clock speed is 4.194304MHz ( 4194304 hz ? )
and hsync is 9198 KHz ( 9198000 hz ? :S )
vync is 59.73 Hz

do these figuers seem correct?
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
doynax
doynax
The h-sync looks *way* to high. But I suspect that it's supposed to be 9198 Hz, not 9198 KHz.
9198 Hz h-blank / 59.73 Hz v-blank ~= 144 scanlines + 10 lines of vblank.4.194304 MHz CPU freq / 9198 Hz h-blank ~= 456 cycles per scanline.
ErUs
ErUs
thanks alot mate, i knew something was wrong
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.