Why does GetScreenMen and DisplayScreenMen use loops? This seems to work just as well in your demo program:
Code: Select all
#define GetScreenMem( ScreenMem ) ArrayInit(ScreenMem, 0, 800); GetDisplayNormal(0, TEXTLINE_1, 800, ScreenMem);
#define DisplayScreenMem( ScreenMem ) SetDisplayNormal(0, TEXTLINE_1, 800, ScreenMem);
I'm not sure if the memory structure is the same but that should only affect some of your file functions.
(I do just now realize that GetScreenMem() was never used in your demo program...)
You could use a structure like this instead:
Code: Select all
struct screen_mem{
byte buffer[];
unsigned long display_add;
unsigned long buffer_add;
and then do
Code: Select all
#define DrawScreenMem(ScreenMem, FunctionName, args) { \
SetDisplayDisplay( ScreenMem.buffer_add ); \
FunctionName(args); \
SetDisplayDisplay( ScreenMem.display_add ); \
}
(Does the "args" part work btw, shouldn't it be "..."?)
Use a init function to set display_add and buffer_add.
DisplayScreenMem is done by syscall and all parameters are therefore contained in a struct. I have noticed though that it appears that syscall doesn't check if the members of the struct is in the correct type. I could make SysRandom() use a struct which contained a unsigned word instead of a signed, automatically casting the variable.
I have absolutely no idea, but I could imagine that it might not check the amount of members. Or rather, I hope it does not. (I haven't yet to test it.)
Consider the SetDisplayNormal struct:
Code: Select all
__IOMWBIArgs_def struct
Result sbyte
ModuleID dword
Offset word
Buffer byte[]
__IOMWBIArgs_def ends
ModuleID and Offset are constant for this function. What if we could merge this with our earlier ScreenMem structure?
Code: Select all
struct ScreenMem{
byte Result;
long ModuleID;
int Offset;
byte Buffer[];
unsigned long display_add;
unsigned long buffer_add;
};
This is surely pure speculation but if it doesn't perform a check on the amount of members (and therefore doesn't reject our struct) it should never notice our two extra members and thus work exactly like we would expect. However we don't need to copy the buffer into the other struct and we keep everything nicely contained so it is easy to use multiple buffers.