I am using Arduino library for VGA output. It uses framebuffer - two-dimensional array. Everything works well but the framebuffer has "non-standard" order of the pixels which repeats every 4 bytes. Instead of pixel 1,2,3,4... the framebuffer has order 3,4,1,2...
So instead of this: FrameBuffer[width][height] I have to switch width, height and also xor the width coordinate by 2: FrameBuffer[height][width^2]. It works well, but sometimes I forget about it. It is not standard (standard screen has width and height coordinates).
So my question is: is it possible to write a macro (for example) which will replace (during compilation) the line FrameBuffer[width][height] with FrameBuffer[height][width^2]? Or is there any other way?
a macro would require parenthesis instead of the square brackets
You could make the FrameBuffer an instance of a custom class and overload the Subscript / array index operator or operator()(int, int) or write a method and instead of FrameBuffer[x][y] you would write FrameBuffer(x,y)