-
-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Suggested by @Kyrio on Discord:
I think we can make the page flipping explanation a little clearer. Tonc shows you this snippet but doesn't define most of the symbols used.
u16 *vid_flip() { // toggle the write_buffer's page vid_page= (u16*)((u32)vid_page ^ VID_FLIP); REG_DISPCNT ^= DCNT_PAGE; // update control register return vid_page; }The easy part is the register update, although Cearn doesn't waste time explaining that you can just xor the contents of
DISPCNT
with the offset of the page bit, and you get a nice toggle.Now for the "hard" part. You are told that
vid_page
is your write buffer pointer, but we should probably mention that while it is declared by libtonc, you have to initialize it yourself (e.g. tovid_mem
). I suppose it'd be more obvious if the following example usedvid_page
, but it doesn't.More importantly,
VID_FLIP
is never defined. It's not a libtonc symbol and without further details, it's hard to tell what this line is actually doing. I think we can safely replace it withVRAM_PAGE_SIZE
, and point out that the XOR lets you add or remove the page size offset.What do you think?