Author Topic: z80-like portable computer for <$30! (If you build one)  (Read 59860 times)

0 Members and 3 Guests are viewing this topic.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: z80-like portable computer for <$30! (If you build one)
« Reply #15 on: June 26, 2013, 12:58:29 pm »
So, I was thinking about interpreters, and I think I have a good solution to the problem at hand:

There will be an interpreted language, with an editor. The language will be tokenized, and there will be relatively few commands, since I want to use 1 byte tokens only. This means anything that goes into a string must be one of these tokens. However, whenever possible the tokens will follow the ASCII character set. The other implication of this is the relatively few commands it allows. Because of this, there will be function support. One of the tokens defines a function, another calls it.

Since the primary interface will be a keyboard, most of the tokens are designed with this in mind. For example, C style logical operations. Another important note: Unless people complain loud enough, I plan to make the internal number system hexadecimal, with only a print function converting it back to decimal. (This is made very easy by the DA command, which encodes a hex number to a decimal number.)

I'm not sure whether it matters enough for it to support 2-byte numbers by default. 1-byte numbers would be much faster, and rarely do people actually NEED more than 255 for a particular number internally. (except maybe for health and such)

In any case, there would only be 158 available commands, assuming all characters available to type on the keyboard except tab (Which I'm using for an instruction catalog pop-up window) are available as individual tokens for use in variables or  strings. (actually a few more, since the math commands are on there)

Speaking of variables, a variable can be many types, and all the letters, numbers, and many symbols are valid for variable names. Since commands are tokenized, there is no worry that a variable will be confused with a command in the program itself.

Here's how entry will work. You start typing, and a window pops up with all possible commands that could match your input. You either keep typing, or select the command from the list. For example.

Type p
___________
|p (Variable)|             (Does not list other variables. You must type the vars exactly)
|pass         |
|print(        |
|_________ |

Pressing TAB would result in a list with no variable mentions, but containing all commands. Like TI's catalog, but just a small pop-up window. Think like mimas, for those who have used it.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: z80-like portable computer for <$30! (If you build one)
« Reply #16 on: June 26, 2013, 03:56:08 pm »
What about tokenizing a string that you type? Or doesn't it have enough ram for that?
If you like my work: why not give me an internet?








Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: z80-like portable computer for <$30! (If you build one)
« Reply #17 on: June 26, 2013, 03:56:52 pm »
Well, I was just thinking of ways to make it easy to program. This is essentially tokenizing the string you type, but doing it one command at a time.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: z80-like portable computer for <$30! (If you build one)
« Reply #18 on: June 26, 2013, 03:57:17 pm »
Ah! very well. That will save ram too.
If you like my work: why not give me an internet?








Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: z80-like portable computer for <$30! (If you build one)
« Reply #19 on: June 26, 2013, 03:58:44 pm »
Yeah. Also, I forgot to mention, I'm planning on having an interactive shell prompt as well, like python or Lua. It won't be the primary interface for running programs, but it will run identically to running a program, and you can drop to it from within one.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: z80-like portable computer for <$30! (If you build one)
« Reply #20 on: June 26, 2013, 05:15:12 pm »
Might build this, when I have time and money.
I'm not a nerd but I pretend:

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: z80-like portable computer for <$30! (If you build one)
« Reply #21 on: June 26, 2013, 06:34:10 pm »
One thing that would be nice is if you guys built your own Z80-like computer, you tried to make each of your own use the same hardware as much as possible. Who knows? Maybe that could make it easier to test an OS or something and eventually make such project viable for a commercial release. Of course, if anyone ever released such computer he would need to check patent stuff in respective countries, to ensure that everything used in the machine won't violate them or any other copyrights.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: z80-like portable computer for <$30! (If you build one)
« Reply #22 on: June 26, 2013, 06:47:18 pm »
That would be ideal. I'll be careful to make sure that the pins I use won't get in the way in the future, so they wouldn't need to be changed to accomodate additions to the circuits.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: z80-like portable computer for <$30! (If you build one)
« Reply #23 on: June 26, 2013, 10:58:24 pm »
Some commands I think you should have are:
For math:
+,-,*,/,^,log2,sqrt() and maybe some trig functions
Some bit operations such as arbitrary shifts/rotates and bit-logic

For Graphics:
Line, Circle, Sprite, Rectangle, lcd refresh

For Input/Output:
getkey, Text()

And a few commands for creating and editing files.

That should make for a light language and still powerful. As well, there should be an easy way  to incorporate assembly for users that want to be very precise with what there program does.

If the math can return information such as the c,z, and sign flags (maybe store this in a system var), that would also be very useful. If users needed, say, 32-bit math precision, this would help.

Good luck!

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: z80-like portable computer for <$30! (If you build one)
« Reply #24 on: June 26, 2013, 11:01:27 pm »
All good suggestions, yes. Although, I don't think I'd have a built-in sqrt function since there's no plan to support decimal numbers at all.

I haven't exactly started writing it yet :P maybe I'll change my mind.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: z80-like portable computer for <$30! (If you build one)
« Reply #25 on: June 27, 2013, 03:47:30 am »
Ah yeah and also make sure that the hardware you'll use isn't rumored to be discontinued anytime soon. I know that old processors are still made, but you still have to be careful in case. :P

As for lack of decimal support, I think that 2 bytes numbers might be a good idea if memory doesn't become a big issue, since this would make it incredibly hard to create some kinds of games. For example, in RPGs, there are many stats that can go beyond 255 and damage calculation (defense, elemental weaknesses, magic power, etc) would be a major hassle. I wonder if there is a tutorial online explaining how this was done on older consoles? Even the 1987 Final Fantasy has numbers over 255.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: z80-like portable computer for <$30! (If you build one)
« Reply #26 on: June 27, 2013, 07:54:43 am »
If someone mass-produced 'em I might actually buy one ^^

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: z80-like portable computer for <$30! (If you build one)
« Reply #27 on: June 27, 2013, 12:40:19 pm »
I was trying to build a small single board computer out of a z80 too, but it became a huge mess of wires. Wireing up data and address busses is a huge pain and when it doesn't work correctly you'd have to check every connection. With a cpu like the ez8 there is ram and rom inside, so no messy wires here. I think I'm gonna get something similar: an mcu that can run code ram or a cpu with built in rom and ram.
If you like my work: why not give me an internet?








Offline zigzagjoe

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 8
  • Rating: +1/-0
    • View Profile
Re: z80-like portable computer for <$30! (If you build one)
« Reply #28 on: June 27, 2013, 05:45:53 pm »
Honestly, if you are going to make a design from scratch, you may as well use a more current design - the ez8 does not make that cut, being just as elderly as the z80. By the way, the only similarity between the z80 and the z8 is assembly mnemonic.... you will not be able to use existing code without a rewrite.

By the way, putting two independent CPUs will just increase the headaches involved in general purpose programming, rather like what happened to the sega saturn. Worse, these are microcontrollers, effectively independent systems by themselves - they will not be able to share a bus seeing as it's fully internal, and synchronization would be a nightmare. Unless one is going to be a dedicated co-processor handling IO, display, or other such things, it will be largely wasted as it would be incredibly cumbersome to use.

Since you won't be able to use any existing code anyways, you may as well go for an ARM chip, such as the LPC1114. 50mhz, 32-bit ARM Cortex-M0 with 4kb of SRAM and 32kb of flash. The SRAM and flash is unfortunately small, but it is still an order of magnitude more powerful then what you've suggested, never mind cheaper at less than 3$ per. Plus, it comes in a nice DIP package and has vastly more toolchain support - gcc.

Grab this 240x320 2.4" Color LCD - 15$. 3.3v-tolerant and has a built in ILI9340 controller again, requiring an 8 bit interface and 4 control lines (CS, WR, RD, RS).

Use an 8x8 key matrix: use the 8 pin data bus that is also connected to the LCD for input, and hook up a 74HC165 Shift-in register - 3 pins, CLK-out, LD-out, Ser-in to read it out. You may be able to find an existing keyboard module you could use, or just design a PCB. Alternatively, you could use PS/2 as you suggested.

2 more pins for a bit-banged USB interface - the ARM is easily fast enough to manage USB low speed, it should be able to manage full speed as well. SD card interface would occupy another 4 pins - MOSI, MISO, CLK, and CS; one of the SPI interfaces. Could use an I2C eeprom or flash instead of a SD card. Probably makes more sense: less overhead, by far.

Unfortunately, it seems that it would be difficult to use NXP's ISP interface in-situ, but the uC may be able to reprogram itself via a bootloader. If you could bake enough USB into the bootloader, programming could become quite simple. ASM programs will be incredibly difficult, however; 4kb of SRAM would be enough for some programs and overhead, but it's nowhere near enough for a complete binary program. An interpreted language would be possible, but honestly rather depressing. a Forth clone could be decent, though - not too much overhead in the interpreter.

Though, discussing a language now; doesn't that strike you as counting eggs before they hatch? You need to have working hardware before you can do much else, and it will not be as simple as buying all the parts and wiring them together - you will need hardware to program the uCs, as well as toolchains, debugging facilities (meter and logic analyzer), passives for LCD and uC(s). It's a great feeling to get it all together but it's a lot of work before you have something working. If you've got the background for it, by all means go for it, but if not I'd recommend playing with standalone microcontrollers first.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: z80-like portable computer for <$30! (If you build one)
« Reply #29 on: June 27, 2013, 05:53:04 pm »
Wow, that's one heck of a first post. Welcome to Omnimaga zigzagjoe! What brings you here? You should head over and <a href=http://www.omnimaga.org/index.php?board=10.0>introduce yourself</a>. The main reasons for will choosing this processor (and a low res b&w display) is it's similarity to the Z80, (which powers many of the TI calculators we all know and love) and low cost. Maybe an ez80 would be an option, but I'm unsure how that would affect cost.
« Last Edit: June 27, 2013, 05:54:19 pm by Art_of_camelot »