Thank you. Yes, I just realised that I’d read that function parameters are passed directly via the ARM registers. Whilst I think this means in theory there could be more than four parameters allowing that to happen puts heavy restrictions on coding practice.
I can pack my co-ords. But I just thought it good to create a separate function setState(bool state)
which sets a static variable so that the line/rectangle/box plotting functions can then be called without the fifth parameter. This bool flag is for a draw/undraw state and applies to to all plotting functions.
By the way, is my state variable best defined as a static? I’m not up on C at all, so I’m not sure. I’ve also got two look-up tables for bitwise manipulations because this was a quicker method in Javascript than doing it from scratch.
Can you please tell me if I’ve used the most appropriate way to define my constants and variables? I have also created the buffer - 504 bytes for the LCD display - in C so that I can pass it to Javascript through initBuffer()
.
namespace nokialcd {
static const uint8_t FILL_X[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
static const uint8_t FILL_B[9] = {0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, 0xff};
static Buffer bytearray = NULL;
static bool state = true;
//%
Buffer initBuffer() {
bytearray = mkBuffer(NULL,504);
return bytearray;
}
//%
void setState(bool s) {
state = s;
}
...and then the main pixel/line/screen-scroll functions...
}
Also I used to have a table of [0,84,168…] to multiply by 84 but I discovered, with run-time tests, that in C it’s actually quicker to do int r = (y >>3) * 84
than it is to do int r = YMUL[y >>3]
. That’s interesting.