How do I do a "VDU" in C?
Chris Mahoney (1684) 2165 posts |
I’ve just discovered VDU 24, which apparently restricts sprite output to the specified area of the screen. Sounds good, except the only example I can find is in BASIC and the Acorn C/C++ manual virtually doesn’t mention VDU at all. The example is:
How do I do that in C? For that matter, should I? Is there a SWI that does the same thing? I haven’t found anything, but maybe I’m looking in the wrong place… Edit: 5a-686 says that “Many of the VDU calls that are present in RISC OS have been superseded by either the OS_Plot call or other SWIs. Instead of using the VDU call, you should call the relevant SWI.” but unfortunately doesn’t have an exhaustive list and I haven’t been able to find anything equivalent to VDU 24. |
Jeff Doggett (257) 234 posts |
I’m sure that there must be a library call to do this! |
Colin (478) 2433 posts |
No there isn’t a vdu command like there is in basic you have to send a byte at a time with _kernel_oswrch so VDU24 becomes:
edit: I’ve changed the parameters from unsigned ints to signed ints as they are relative to the graphics origin (VDU 29) note the trap that if the value goes off the screen the graphics window isn’t set |
Chris Mahoney (1684) 2165 posts |
Thanks! That works perfectly :) (and would’ve taken me ages to figure out!) |
Rick Murray (539) 13851 posts |
There is also OS_WriteN which can send a pre-prepared block of VDU data in one go. |
Chris Mahoney (1684) 2165 posts |
That sounds like it could be a little more “elegant” so I’ll give it a go too. Thanks! |
Rick Murray (539) 13851 posts |
Using OS_WriteN also has the benefit that if you need to issue multiple similar VDU calls, you can set up the block, poke in the desired values, and then output. For the next iteration, just change the desired values, output again. |
Chris Mahoney (1684) 2165 posts |
I’ve just tested this and it works as expected… and is almost twice as fast as _kernel_oswrch :) |