C47 - missing LINE function

This area is for discussion about these families of custom high-end Scientific Calculator applications for SwissMicros devices.
User avatar
rudi
Posts: 413
Joined: Wed Nov 03, 2021 9:03 am
Location: Denmark
Contact:

Re: C47 - missing LINE function

Post by rudi »

Walter wrote:
Wed Mar 22, 2023 8:25 am
rudi wrote:
Wed Mar 22, 2023 8:02 am
dlachieze wrote:
Wed Mar 22, 2023 7:27 am
Look at the GRAMOD variable in the WP43 Reference Manual. I’ve not tested it but it should do what you need.
Thanks - found it on p94 in the WP43! Just what I was looking for.
...
I was under the impression, that WP43 was a subset of C47 and all WP43 functions are contained in C47 but not nesecary the other way arround?
Sorry, wrong impression. WP43 was the root, but C47 & Co deviated based on a different concept of its UI, now for some years. Think of Darwin.

BTW, you won't execute a variable, will you? ;)
Thanks for clarifying Walter, RCL 'GRMOD' worked on my C43 ;-)
But not on my Windows Free42, so I guess it is not a DM42 register as well. I'll figure something else out.
/Rudi

DM-42 (s/n 06999), HP-42S, HP-35s, HP-11c, HP-32SII (ex HP-41CV, ex HP-75C, ex HP-48G + a lot, really lot of a accessories)
Denmark
dlachieze
Posts: 613
Joined: Thu May 04, 2017 12:20 pm
Location: France

Re: C47 - missing LINE function

Post by dlachieze »

On the HP-42S, Free42 and DM42 the graphic mode is controlled by the flags 34 and 35.
DM42: 00425 - DM41X: β00066 - WP43: 00042
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

Re: C47 - missing LINE function

Post by Walter »

For sake of historic completeness: Compatibility to HP-42 was (and had to be) given up for various reasons many moons ago. Meanwhile, also Free42 has evolved away from the original. So HP-42S is clearly the forefather and reference for more than one community development but not more anymore.
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
User avatar
Jaymos
Posts: 1633
Joined: Sun Nov 04, 2018 7:03 pm
Location: Cape Town

Re: C47 - missing LINE function

Post by Jaymos »

rudi wrote:
Wed Mar 22, 2023 5:35 am
Jaymos wrote:
Tue Mar 21, 2023 8:14 pm
pauli wrote:
Tue Mar 21, 2023 7:32 am
If someone volunteered to implement more, I'm sure they'd be considered for inclusion.
Otherwise, they'll have to wait for one of the team to build up sufficient motivation to design and implement them.
True. In addition:

There is no spec for commands to draw. The closest to a spec was this list I dreamt up at some point. A good start would be a spec of how this is to be done, and not a haphazard addition of commands like LINE and CIRCLE or what not.

Consider this and either replace it or enhance it.

viewtopic.php?f=2&t=2216&p=25356&hilit=Graphics#p25356
I would be happy to provide some C snippets, containing code that renders a LINE, RECT and ELLIPSE.
I also assume, that in the source to C43, there is some sort of fast setpixel function?

All three functions should take two 2D integer points as parameters, p0 and p1.
LINE will draw a line between p0 and p1.
RECT will draw a rectangle, where p0 and p1 are diagonally opposite corners (no requirements to which is left/right/upper/lower, the code detects this)
ELLIPSE will draw an ellipse with bounding rect p0 and p1, same specs as for RECT.
For all three functions, p0 and p1 are allowed to lie outside the screen rect and will be clipped automatically. Thus allowing for drawing figures, that only partially lies on the screen.

Another thing, I am writing a program, that uses AGRAPH to draw objects on the screen and they may sometimes partially overlap.
It would be convenient, if it was possible to set the raster-operation, ROP, for AGRAPH. Could be inspired from MS BitBlt function. To allow overlapping, the MERGECOPY ROP would be needed.
SRCCOPY : (default) copies pixels
MERGECOPY : merges pixels (OR)

Any additions to the set of commands need to go through scrutiny in terms of name choice, parameter usage, parameter sequence, etc. If originating here; scrutiny on a thread like this one would be ok. After that, internal discussion on Gitlab will continue.

Having said that, to me, my take on the commands could take the form:

LINE from (Z,T) to (X,Y)

RECT with corners (Z,T) and (X,Y) are ok. These two internal commands exist already and only wrappers are needed. This does not allow for a rectangle on an incline. Maybe register A = the angle offset anti-clockwise.

ELLIPSE bounded by a rectangle seems to be limited as the ellipse should have an inclination. Maybe like RECT, with additional parameter A = angle of the bounding rectangle. So the ellipse has the same spec as a rectangle.

POLY can have the same spec as ELLIPSE, with an additional parameter B = number of points (codes) (note the points fit inside the rectangle). So a equilateral 10x3 triangle would be POLY (0,0) (10,10) 0 3 and a 10x10 square would be POLY (0,0) (10,10) 0 4

ELLIPSE may be a bit long - depending on the exact pixel length, it might not fix into a softkey. COMPLEX currently is the longest one and does fit in marginally. If it does not fit, 2nd choice might be ELLIPS which should fit.


Referring to the link I gave above and the response from dlachieze, I still find the creative expansion of AGRAPH interesting and I like the flag idea for defining to fill a shape, an arc spec, and other elements.

I think though that standard commands above can co-exist with an expanded AGRAPH.

This is my take on taking the proposed commands from rudi further. Welcome to further comment or change for proposal.

In terms of new snippets offered, there are already existing internal functions plotrect, plotline and plotline2 (in plotstat.c). New snippets will be needed using the existing ones where applicable.
Jaco Mostert
Elec Eng, South Africa
https://47calc.com C47 (s/n 03818 & 06199), WP43 (0015). In box: HP42S, HP32Sii, WP34S&C, HP28C, HP35s, EL-506P, EL-W506, PB700; ex: FX702P, 11C, HP67 & HP85; iOS: 42s Byron, Free42+, WP31S/34S, HCalc.
User avatar
pauli
Posts: 251
Joined: Tue May 02, 2017 10:11 am
Location: Australia

Re: C47 - missing LINE function

Post by pauli »

Could we consider using complex numbers to define the graphical coordinates?
Perhaps also have each axis ranging from zero to one as a real rather than an integer?
User avatar
Jaymos
Posts: 1633
Joined: Sun Nov 04, 2018 7:03 pm
Location: Cape Town

Re: C47 - missing LINE function

Post by Jaymos »

pauli wrote:
Fri Mar 24, 2023 12:39 am
Could we consider using complex numbers to define the graphical coordinates?
Perhaps also have each axis ranging from zero to one as a real rather than an integer?
I have thought of the complex number coords and like it.

But I thought that since there is a setting CPXRES for people who don't want to see a complex number, that forcing complex mode for those might be problematic.

As said, I would like complex numbers to represent the graph area.

Limits 0-1 -- mmm I think when trying to graph shapes with LINE etc, I would prefer the integer boundaries.
Jaco Mostert
Elec Eng, South Africa
https://47calc.com C47 (s/n 03818 & 06199), WP43 (0015). In box: HP42S, HP32Sii, WP34S&C, HP28C, HP35s, EL-506P, EL-W506, PB700; ex: FX702P, 11C, HP67 & HP85; iOS: 42s Byron, Free42+, WP31S/34S, HCalc.
User avatar
rudi
Posts: 413
Joined: Wed Nov 03, 2021 9:03 am
Location: Denmark
Contact:

Re: C47 - missing LINE function

Post by rudi »

Does integers take up less memory than floating points in the C47 And are they faster to handle and do operations on?
Then it might not be beneficial for performance to use floating point complex numbers. And with only one color available, I wouldn’t imagine that antialiasing would be of any use, for example if drawing a line between two decimal coordinates.
At least make complex numbers optional, such that you can draw a line between two points, where either one can be either defined by two integers or a complex number.
/Rudi

DM-42 (s/n 06999), HP-42S, HP-35s, HP-11c, HP-32SII (ex HP-41CV, ex HP-75C, ex HP-48G + a lot, really lot of a accessories)
Denmark
User avatar
Jaymos
Posts: 1633
Joined: Sun Nov 04, 2018 7:03 pm
Location: Cape Town

Re: C47 - missing LINE function

Post by Jaymos »

rudi wrote:
Fri Mar 24, 2023 11:35 am
Does integers take up less memory than floating points in the C47 And are they faster to handle and do operations on?
Then it might not be beneficial for performance to use floating point complex numbers. And with only one color available, I wouldn’t imagine that antialiasing would be of any use, for example if drawing a line between two decimal coordinates.
At least make complex numbers optional, such that you can draw a line between two points, where either one can be either defined by two integers or a complex number.
If only integers were to be used throughout of course it will be a lot faster. However, the system that is implemented currently partly uses the same graphics methods for PLSTAT, SCATR, ASSESS, EQN.DRAW, which require Reals and require the Reals to be stored in a few matrixes. Matrixes store in Real (or Complex) only. This system AND the underlying routines use scaling, a scaling window and are Real only. I have previously played around with short 4-digit Reals to try get around the speed issue - but I would have to go see in Gitlab or otherwise how much difference that made. Can't remember. Internally, once the data is extracted from Reals, I use standard Floats in c to work the graphs along the axes and scaling.

If you mean a non-scaled environment (without scalable axes, i.e. for an integer cartesian plane for screen pixels (integers) only), then integers may work. Do remember that there are however no short-short-integer data type for 2 bytes words only, which you may have in mind. You would have to use short integers which are stored as 64 bit integers or long integers, which come with other overhead. Either way it is not a machine where you can play with double byte words to gain a lot of speed.
Jaco Mostert
Elec Eng, South Africa
https://47calc.com C47 (s/n 03818 & 06199), WP43 (0015). In box: HP42S, HP32Sii, WP34S&C, HP28C, HP35s, EL-506P, EL-W506, PB700; ex: FX702P, 11C, HP67 & HP85; iOS: 42s Byron, Free42+, WP31S/34S, HCalc.
Post Reply