gbadev-org / tonc

GBA Programming Tutorial (Community Edition)
https://gbadev.net/tonc
Other
48 stars 22 forks source link

Change the text to use the VBL interrupt from the start #112

Open AntonioND opened 3 months ago

AntonioND commented 3 months ago

vid_vsync() is a really bad hack that shouldn't be used in any serious project. However, Tonc uses that function all the time up to chapter 16. Hardware interrupts.

This is done because Cearn wanted to explain things step by step and not use anything that hadn't been explained, but it's very unlikely that anyone will reach chapter 16 after learning how to do graphics, input, etc, especially if the chapter name is "Hardware interrupts", which sounds boring.

I think teaching people from the start to use:

irq_init(NULL);
irq_add(II_VBLANK, NULL);

and:

VBlankIntrWait();

Is reasonable, and they can keep using them even if they never reach chapter 16.

Personally, when I started with NDS development, I used interrupts from the start without understanding them at all, and I only started to understand them months after starting. It was fine. I just knew that the "wait for VBL interrupt" function waited for the next frame.

Opinions?

GValiente commented 3 months ago

I would add a very small warning/intro about interrupts before using them, but yeah, vid_vsync() sucks xD

AntonioND commented 2 months ago

I've done something similar with memcpy() when used to copy data to VRAM: https://github.com/gbadev-org/libtonc-examples/commit/89d84ea899a2d1fa113708f5c26bb49a9c54ab5b

That way people won't copy broken code.

We will also need to update the examples to not use vid_flip().