Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. Where Russian peasants come from...

Where Russian peasants come from...

Scheduled Pinned Locked Moved The Lounge
questioncomgraphicsalgorithms
16 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CodeWraith
    wrote on last edited by
    #1

    The stork brings them, but that's not the interesting part. I want to see 3D graphics on an 8 bit computer, at least once I get around to build the graphics card. It's going to have a TMS9981 graphics chip, a RISC graphics processor and a DMA based DGP (Decelerated Graphics Port). Anyway, I'm going to need some math routines for, let's say, 32 bit fixed point math. Will 24 bits for the whole numbers will be enough, but maybe just 8 bits for the fractions are not. We shall see. Anyway, I intend to use the Russian Peasant Multiplication[^] algorithm. It's based on multiplying and dividing by 2 (also known as shifting) and addition. That should be easy to implement. But what is the algorithm for division called? I'm going to need that as well.

    I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

    F Mike HankeyM Richard Andrew x64R L G 5 Replies Last reply
    0
    • C CodeWraith

      The stork brings them, but that's not the interesting part. I want to see 3D graphics on an 8 bit computer, at least once I get around to build the graphics card. It's going to have a TMS9981 graphics chip, a RISC graphics processor and a DMA based DGP (Decelerated Graphics Port). Anyway, I'm going to need some math routines for, let's say, 32 bit fixed point math. Will 24 bits for the whole numbers will be enough, but maybe just 8 bits for the fractions are not. We shall see. Anyway, I intend to use the Russian Peasant Multiplication[^] algorithm. It's based on multiplying and dividing by 2 (also known as shifting) and addition. That should be easy to implement. But what is the algorithm for division called? I'm going to need that as well.

      I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

      F Offline
      F Offline
      Fueled By Decaff
      wrote on last edited by
      #2

      It sounds like you are looking for binary division. Does this help? Binary Division - Rules, Steps to Solve, Examples[^]

      C 1 Reply Last reply
      0
      • C CodeWraith

        The stork brings them, but that's not the interesting part. I want to see 3D graphics on an 8 bit computer, at least once I get around to build the graphics card. It's going to have a TMS9981 graphics chip, a RISC graphics processor and a DMA based DGP (Decelerated Graphics Port). Anyway, I'm going to need some math routines for, let's say, 32 bit fixed point math. Will 24 bits for the whole numbers will be enough, but maybe just 8 bits for the fractions are not. We shall see. Anyway, I intend to use the Russian Peasant Multiplication[^] algorithm. It's based on multiplying and dividing by 2 (also known as shifting) and addition. That should be easy to implement. But what is the algorithm for division called? I'm going to need that as well.

        I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

        Mike HankeyM Offline
        Mike HankeyM Offline
        Mike Hankey
        wrote on last edited by
        #3

        and I'm struggling with keypad and 7-segment display on my Z80 I'm building.

        The less you need, the more you have. Even a blind squirrel gets a nut...occasionally. JaxCoder.com

        C 1 Reply Last reply
        0
        • C CodeWraith

          The stork brings them, but that's not the interesting part. I want to see 3D graphics on an 8 bit computer, at least once I get around to build the graphics card. It's going to have a TMS9981 graphics chip, a RISC graphics processor and a DMA based DGP (Decelerated Graphics Port). Anyway, I'm going to need some math routines for, let's say, 32 bit fixed point math. Will 24 bits for the whole numbers will be enough, but maybe just 8 bits for the fractions are not. We shall see. Anyway, I intend to use the Russian Peasant Multiplication[^] algorithm. It's based on multiplying and dividing by 2 (also known as shifting) and addition. That should be easy to implement. But what is the algorithm for division called? I'm going to need that as well.

          I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          That sounds like the video chip that was used in the TI-99/4A home computer.

          The difficult we do right away... ...the impossible takes slightly longer.

          C 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            That sounds like the video chip that was used in the TI-99/4A home computer.

            The difficult we do right away... ...the impossible takes slightly longer.

            C Offline
            C Offline
            CodeWraith
            wrote on last edited by
            #5

            Exactly. Oldschool graphics chips suitable for 8 bit computers are hard to get.

            I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

            1 Reply Last reply
            0
            • Mike HankeyM Mike Hankey

              and I'm struggling with keypad and 7-segment display on my Z80 I'm building.

              The less you need, the more you have. Even a blind squirrel gets a nut...occasionally. JaxCoder.com

              C Offline
              C Offline
              CodeWraith
              wrote on last edited by
              #6

              What's the problem?

              I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

              Mike HankeyM 1 Reply Last reply
              0
              • F Fueled By Decaff

                It sounds like you are looking for binary division. Does this help? Binary Division - Rules, Steps to Solve, Examples[^]

                C Offline
                C Offline
                CodeWraith
                wrote on last edited by
                #7

                Certainly does. At least I now have all bases covered. But before I write the first code, I'm going to check the runtime behavior of the algorithms to pick the best choice. No time to waste on an old 8 bit CPU.

                I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                F 1 Reply Last reply
                0
                • C CodeWraith

                  What's the problem?

                  I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                  Mike HankeyM Offline
                  Mike HankeyM Offline
                  Mike Hankey
                  wrote on last edited by
                  #8

                  Keypad works fine(24 key), display works fine (7-segment 4 address, 2 data). On reset I set display buffer to: FFFF FF I then go into my main loop looking for keyboard input and when Data Available bit from keypad goes low I process the input and if it's a 0-F I put in address buffer if it's > 16 it's a function key and I process it as such. For some reason on reset the system thinks that the data available bit is low and so I end up with display of; 0FFF FF. I've put the scope on the DA pin and on reset it does not go low so not sure exactly what's going on. Not sure where to go from here as far as debugging. For now Ive got it set up just to accept keypad input and put key input into 1st buffer position and if any function key pressed put 4444 44 into display buffer which it does just fine.

                  The less you need, the more you have. Even a blind squirrel gets a nut...occasionally. JaxCoder.com

                  C 1 Reply Last reply
                  0
                  • C CodeWraith

                    The stork brings them, but that's not the interesting part. I want to see 3D graphics on an 8 bit computer, at least once I get around to build the graphics card. It's going to have a TMS9981 graphics chip, a RISC graphics processor and a DMA based DGP (Decelerated Graphics Port). Anyway, I'm going to need some math routines for, let's say, 32 bit fixed point math. Will 24 bits for the whole numbers will be enough, but maybe just 8 bits for the fractions are not. We shall see. Anyway, I intend to use the Russian Peasant Multiplication[^] algorithm. It's based on multiplying and dividing by 2 (also known as shifting) and addition. That should be easy to implement. But what is the algorithm for division called? I'm going to need that as well.

                    I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    Restoring Division, usually. There are other options, but they make more sense in hardware than in software. By the way take a look at Quarter Square Multiplication, it costs a bunch of ROM but it's a lot faster than bit-by-bit multiplication. Usually I wouldn't recommend it, but for 3D stuff you may need the speed.

                    1 Reply Last reply
                    0
                    • Mike HankeyM Mike Hankey

                      Keypad works fine(24 key), display works fine (7-segment 4 address, 2 data). On reset I set display buffer to: FFFF FF I then go into my main loop looking for keyboard input and when Data Available bit from keypad goes low I process the input and if it's a 0-F I put in address buffer if it's > 16 it's a function key and I process it as such. For some reason on reset the system thinks that the data available bit is low and so I end up with display of; 0FFF FF. I've put the scope on the DA pin and on reset it does not go low so not sure exactly what's going on. Not sure where to go from here as far as debugging. For now Ive got it set up just to accept keypad input and put key input into 1st buffer position and if any function key pressed put 4444 44 into display buffer which it does just fine.

                      The less you need, the more you have. Even a blind squirrel gets a nut...occasionally. JaxCoder.com

                      C Offline
                      C Offline
                      CodeWraith
                      wrote on last edited by
                      #10

                      Put in a delay loop before entering the main loop and processing any inputs. It's just an idea, but your code may be faster than the I/O chip after a reset. Give it a little more time to get going.

                      I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                      Mike HankeyM 2 Replies Last reply
                      0
                      • C CodeWraith

                        Certainly does. At least I now have all bases covered. But before I write the first code, I'm going to check the runtime behavior of the algorithms to pick the best choice. No time to waste on an old 8 bit CPU.

                        I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                        F Offline
                        F Offline
                        Fueled By Decaff
                        wrote on last edited by
                        #11

                        It is always going to be a slow(ish) operation in software, that is why they brought out co-processors and eventually implemented it on the CPU. Just remember when you multiply/divide the decimal point will move and you will need to normalise the result. You might also look into doing binary square roots: Methods of computing square roots - Wikipedia[^] I have never used this myself, but there is code there, so that should help you assess the speed of it.

                        1 Reply Last reply
                        0
                        • C CodeWraith

                          Put in a delay loop before entering the main loop and processing any inputs. It's just an idea, but your code may be faster than the I/O chip after a reset. Give it a little more time to get going.

                          I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                          Mike HankeyM Offline
                          Mike HankeyM Offline
                          Mike Hankey
                          wrote on last edited by
                          #12

                          Thanks I'll try that today, was working on honey-do list yesterday.

                          The less you need, the more you have. Even a blind squirrel gets a nut...occasionally. JaxCoder.com

                          1 Reply Last reply
                          0
                          • C CodeWraith

                            Put in a delay loop before entering the main loop and processing any inputs. It's just an idea, but your code may be faster than the I/O chip after a reset. Give it a little more time to get going.

                            I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                            Mike HankeyM Offline
                            Mike HankeyM Offline
                            Mike Hankey
                            wrote on last edited by
                            #13

                            Turns out I needed to RTFM a little better. I am using a 8255 (PIO) to talk to the keypad and display and was trying to use Mode 1 on Port A without doing the appropriate handshacking. So I put it in straight input mode 0 and it works like a charm. Thanks for your feedback.

                            The less you need, the more you have. Even a blind squirrel gets a nut...occasionally. JaxCoder.com

                            C 1 Reply Last reply
                            0
                            • C CodeWraith

                              The stork brings them, but that's not the interesting part. I want to see 3D graphics on an 8 bit computer, at least once I get around to build the graphics card. It's going to have a TMS9981 graphics chip, a RISC graphics processor and a DMA based DGP (Decelerated Graphics Port). Anyway, I'm going to need some math routines for, let's say, 32 bit fixed point math. Will 24 bits for the whole numbers will be enough, but maybe just 8 bits for the fractions are not. We shall see. Anyway, I intend to use the Russian Peasant Multiplication[^] algorithm. It's based on multiplying and dividing by 2 (also known as shifting) and addition. That should be easy to implement. But what is the algorithm for division called? I'm going to need that as well.

                              I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                              G Offline
                              G Offline
                              Gary R Wheeler
                              wrote on last edited by
                              #14

                              CodeWraith wrote:

                              I want to see 3D graphics on an 8 bit computer

                              A very long time ago, at a university not too far away... When I was in college I did an independent study course as one of my electives. My project was to implement Binary Space Partitioning[^] as a method for doing 3D hidden-surface removal graphics. The computer was a Z-80 running CP/M, and the display was 256x256 with 8 colors per pixel. The code was written in PL/I-80[^] from Digital Research. The program was so large it was written as a bunch of overlays and took a couple of disk swaps (8" floppies) to render an image. As far as I know I was the first implementor of the BSP algorithm after the original authors. Another claim to fame is that this was the same algorithm used in the 1st version of DOOM. This happened almost 40 years ago, in 1982-1983.

                              Software Zen: delete this;

                              1 Reply Last reply
                              0
                              • Mike HankeyM Mike Hankey

                                Turns out I needed to RTFM a little better. I am using a 8255 (PIO) to talk to the keypad and display and was trying to use Mode 1 on Port A without doing the appropriate handshacking. So I put it in straight input mode 0 and it works like a charm. Thanks for your feedback.

                                The less you need, the more you have. Even a blind squirrel gets a nut...occasionally. JaxCoder.com

                                C Offline
                                C Offline
                                CodeWraith
                                wrote on last edited by
                                #15

                                People who used the as IDE controller ran into similar problems. That's why I plan to skip all I/O devices and will try to access the registers of the IDE devices directly, as memory mapped I/O devices themselves.

                                I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                                Mike HankeyM 1 Reply Last reply
                                0
                                • C CodeWraith

                                  People who used the as IDE controller ran into similar problems. That's why I plan to skip all I/O devices and will try to access the registers of the IDE devices directly, as memory mapped I/O devices themselves.

                                  I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

                                  Mike HankeyM Offline
                                  Mike HankeyM Offline
                                  Mike Hankey
                                  wrote on last edited by
                                  #16

                                  I'm beginning to learn the same thing.

                                  The less you need, the more you have. Even a blind squirrel gets a nut...occasionally. JaxCoder.com

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups