Luc Pauwels

Line + Pix

Olivier Hoche

Machine language graphics programs, for HP28S (version 2BB) only.

WARNING:
Permission is granted to any HP28S owner to make use of these programs for non-commercial purposes. The author of this program cannot, in any case, be held responsible for any direct or indirect damages of any kind that could occur from misuse of these programs or of any data provided with - and including - their codes.

I was surprised not to find any program of that kind on this server nor anywhere else, although it's quite a basic function, to "modern" standards at least. So here is my version of it (based on Bresenham algorithm), just in case anyone in this world is still using his dear ol'28 and desperately looking for this. It has never been really optimised, and I'm no professional programmer, but it still works a few tens times faster than any RPL program, and it handles several options as well. I have to admit, though, that it could possibly be a little faster, and surely somewhat smaller.

  Syntax: 4:      #X
          3:      #Y
          2:     #dX
          1:     #dY  
      Top left pixel is (#0,#0), bottom right is (#88,#1F).
The drawing mode is set through user flags 1 and 2: Stated in executable form, for those who don't want to *think* about it:
   GON  << 1 CF 2 CF >>
   GOFF << 1 SF 2 CF >>
   GXOR << 2 SF >>
will do the work for you.

An interesting feature of this program is that it can't crash. The worst it can do is looping endlessly if you try to draw a line with the main coordinate decreasing down to a binary integer ending with #80000h. Apart from that, it works all right. Only the least significant five nibbles of the values given are used, and it does accept "negative" binary integers, although your HP doesn't.

  Example:
        4:      # 88h
        3:      # 1Fh
        2:   # FFF78h
        1:   # FFFE1h
        LINE
    will draw a line from the bottom right to the top left points of the screen.
    If you want it to keep on screen, run << # 18A85h SYSEVAL >> (which you can
    call SEMF, since it's just the counterpart to CLMF) just before LINE.
You will notice that no 4 DROPN has been added at the end, so that all values stay untouched on the stack. If it bothers you, just add "76C20" at the beginning of the code, and "80311 1B670 09F20" at the end.
LINE (CHK:"557B", CRC:#7D99) 
 
       "69C20 E3200 8F180 5020A F0100 10110
        21031 04083 40000 8D514 31301 69142
        8B270 F8857 10417 41431 30169 1428B
        2A0F8 85685 81031 1C8BE E1854 85510
        B1041 10121 12009 81E0A 11CD7 C711B
        E3174 14313 01691 42101 17414 31301
        69142 10086 4B011 01211 20110 11B86
        680EA 6500C AC010 21FF0 10C15 3009A
        860A1 10C01 1A876 B08B6 27680 08B29
        6864C 11111 20101 76601 11120 10167
        00755 01108 7680E 46500 CC100 D98B3 
        12111 86780 CC650 0E410 11131 1CE26
        60011 CC6C3 618F8 F8B05 01421 64808
        C1103 48800 08B6A 71113 4F100 08B6B
        681C8 1C118 C6C6C 6CA34 048FF C2134
        31341 109EA 11340 A1001 32CA1 30A82
        11180 871B0 80890 68008 08928 08605
        0A061 52076 00150 00186 1C113 50E0A
        1370E 06B8C 1370E 06018 70800 E0E01
        B8E0E 0601"
By the way, here is PIX, from the same family as the one above, and from which the latter actually derives. The syntax is just as simple: #X, #Y, PIX. Options are strictly the same. It's much faster than the original PIXEL function, and allows consistent use with the LINE one, so it could not be completely useless...
PIX (CHK:"9C3C", CRC:#93D2)
 
       "69C20 70100 8F180 50AF0 14313 01691
        42101 17414 31301 69142 10020 1BF01
        0C156 00A34 88000 8B6A7 11134 F1000
        8B6B6 81C81 C118C 6C6C6 CA340 48FFC
        21343 13411 09EA1 1340A 10013 2CA13
        0A821 11808 71B08 08906 80080 89280
        86050 A0615 20751 01500 8F8B0 50142
        16480 8C861 C1135 0E0A1 370E0 6B8C1
        370E0 60187 0800E 0E01B 8E0E0 601" 
For a DROP2 at the end of run-time, add "76C20" at the beginning and "44670 09F20" at the end.

I'd like to say "Enjoy!", but to whom? It looks like HP28ists are a bit of an extinct race now...

                Olivier Hoche.
                (S-mail:
                   3 rue du Marchis,
                   27120 Pacy-sur-Eure,
                   France)