#49396 - Sephiroth87 - Fri Jul 29, 2005 11:47 am
hi there!
i need to write a function that redraw the main screen 50 times per seconds, and while doing this, store the line being currently redrawn in somewhere, and this value need to be used in real time by another function...
i thought to do that by putting the first on the amr7 cpu, and the second on the arm9 one, but i've no idea on where to start from...
maybye smbdy could help me a little :)
#49397 - Mr Snowflake - Fri Jul 29, 2005 11:56 am
You can't draw 50 frames per second, the hardware won't let you. It'll only display 60fps. You still can write 50fps to the framebuffer, but this won't be to good. And I believe there is a Vblank and an Hblank, so using the Hblank you can keep the currently redrawn line.
In the main memory you can maloc some space for keeping the vars between both cpu's.
#49398 - Sephiroth87 - Fri Jul 29, 2005 12:05 pm
so i can't slow down my prog?
however, if i use the hblank, doens't it stops the execution until is over?
#49399 - Mr Snowflake - Fri Jul 29, 2005 12:41 pm
You can slow it down, but animations would look rather strange, with some frames, being the same as the previous.
AFAIK the hblank is an interupt, so if you use it, it'll hold the execution of the currently executed code and run the hblank control code.
#49411 - Sephiroth87 - Fri Jul 29, 2005 4:02 pm
but i need not to stop the code during the refresh...
the situation is:
i'm trying to write a c64 emu...
it has a refresh rate of 50fps, and a registry that holds the line currently drawn...
so i have to refresh the screen and keep the emulation movin on...
#49416 - tepples - Fri Jul 29, 2005 5:16 pm
Sephiroth87 wrote: |
i'm trying to write a c64 emu...
it has a refresh rate of 50fps |
Commodore 64 units sold in the United States, Canada, Japan, and other NTSC regions have a 60 Hz refresh rate. Get the NTSC version working, and then get the European version working.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#49419 - Mr Snowflake - Fri Jul 29, 2005 5:33 pm
Sephiroth87 wrote: |
i'm trying to write a c64 emu...
|
Where did you find al the nescessary info? I've been searching a lot and didn't find..
#49451 - Sephiroth87 - Fri Jul 29, 2005 8:01 pm
now that you note that, reading again docs, you are right, but, the problem doesn't change a lot in my opinion, i still don't see a solution...
howewer, i've tons of original old books of the c64, "almost" all the info that i need (and google is my second best friend xD)
#49453 - sajiimori - Fri Jul 29, 2005 8:25 pm
Don't worry about making it run full-speed right away. Get it working, then think about timing later.
#49454 - Sephiroth87 - Fri Jul 29, 2005 9:04 pm
sigh, that doesn't help me a lot xD
#49461 - sajiimori - Fri Jul 29, 2005 10:34 pm
I'm just saying that you may be getting ahead of yourself with this stuff about using both CPUs and monitoring scanlines and whatnot. Just switch to bitmap mode and emulate in a plain manner to start, and think about fancy stuff later.
#49465 - Sephiroth87 - Fri Jul 29, 2005 10:55 pm
yeah, it's my intention, but without emulating this interrupt, kernal won't run...
so no emulation...
#49532 - Sephiroth87 - Sat Jul 30, 2005 10:54 pm
i've tried this thing...
first i set up the interrupt handler...
Code: |
void InitInterruptHandler()
{
IME = 0;
IRQ_HANDLER = on_irq;
IE = IRQ_HBLANK;
IF = ~0;
DISP_SR = DISP_HBLANK_IRQ;
IME = 1;
}
|
to the hblank interrupts...
then, i've put this...
Code: |
void on_irq()
{
if(IF & IRQ_HBLANK) {
for(i=0; i<SCREEN_WIDTH*SCREEN_HEIGHT; i++)
{
videoBuffer[i]=color;
line=i/SCREEN_HEIGHT;
}
color++;
VBLANK_INTR_WAIT_FLAGS |= IRQ_HBLANK;
IF |= IRQ_HBLANK;
}
else {
IF = IF;
}
} |
(it's not actually the emu code, just a little try...)
will this works? hblank occours 60 times a second?
#49554 - tepples - Sun Jul 31, 2005 2:30 am
Vblank occurs 60 times a second. Hblank occurs on every scanline.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#49555 - sajiimori - Sun Jul 31, 2005 4:02 am
I suggest emulating the interrupt in software until you get the hang of it. That is, do not use DS interrupts to emulate C64 interrupts.
#49563 - Sephiroth87 - Sun Jul 31, 2005 9:05 am
ok, but i don't see any software way to run 2 routines toghether, cause refreshing the screen must be done while the emulating process is running...
now i don't care of perfect timing and 60fps, but i'd like to see at least the mighty blue interface :P
edit: if i put the code in the vblank interrupt instead of the hblank, wont it works?
#49585 - sajiimori - Sun Jul 31, 2005 6:46 pm
When emulating, things that would be literally simultaneous on real hardware might be sequential on the emulator. You don't literally have to refresh the screen and emulate the CPU at the same time. You could pause CPU emulation after a certain number of cycles (emulated cycles, not DS ones), then run the refresh stuff, then resume the CPU.