Fabrizio-Caruso / CROSS-LIB

CROSS LIB - A universal 8-bit library and some games built with it
311 stars 30 forks source link

Use raster interrupts for C64 #3

Closed matozoid closed 6 years ago

matozoid commented 6 years ago

Saw this video: https://www.youtube.com/watch?v=VVXqgPCUQCM and thought refreshing the screen somewhere outside the displayable area would stop the flickering.

Thanks for making new 8-bit stuff :-)

Fabrizio-Caruso commented 6 years ago

Hi! Thanks for following my project! I do not understand the issue. What is flickering for you that should not be flickering? The green slowdown power-up is supposed to flicker. The enemies are redefined characters and move in a grid. Their jerky movement is the expected behavior (in the current implementation at least for the moment).

REMARK: The game is written in C and very time sensitive code is impossible in C.

Buffering all writes to screen and waiting for a rasterline would probably make the code much more complicated and it could have a huge performance impact. If the graphics quality improves significantly and it can be done without touching the non-hardware specific code, I may consider this feature in the future.

Fabrizio-Caruso commented 6 years ago

If I try to do something like while(VIC.rasterline>40){} cputc(image->_imageData);

i.e., wait for a low value of the rasterline before writing onto video memory, I do not see any improvement and the game is significantly slowed-down.

matozoid commented 6 years ago

Okay, with flickering I mean that every time a monster moves it disappears for a splits second. So instead of moving from a to b, it seems to disappear from a and reappear on b.

With a raster interrupt I mean putting your code in an interrupt handler that fires on a specific rasterline. It's what most games do to hide screen updates.

If this can't be done from C then this issue can be closed, I guess :-)

Fabrizio-Caruso commented 6 years ago

This cannot be done reasonably in C because it would require handling interrupts in C, which is (close to) impossible. Some cross-compilers provide some tools but discourage to use them (e.g., CC65) to do anything time-critical. I am not writing a C64 version of the game. If you look at the code, you'll see that all versions share the same code except very few bits about input, sound and graphics (and even this is shared among many targets).

My project is about a universal 8 bit game (i.e., it has to be coded in a way that a single Makefile can generate binaries for nearly all 8 bit computers from the same code). The game should be fun and very playable. Eye-candy is not the highest priority but I DO plan to improve it. In the future I may use sprites instead of simple characters (I have already implemented a prototype).

Fabrizio-Caruso commented 6 years ago

So, what you ask is not impossible but extremely hard in C. It would require lots of Assembly and therefore it would not be in the scope of a universal project. (I have used small fragments of Z80 Assembly for sound in Amstrad CPC and graphics in VG-5000 because I had not much choice). I will close the issue BUT I will try to do my best to improve graphics because that is where my little game is a bit weak. (I am actually doing it right now). Thanks a lot for following my project!

matozoid commented 6 years ago

And thank you for considering this :-)