LittleBigForum Archive
LittleBigForum
LittleBigPlanet 3
Levels

8-bit CPU with 256 bytes of RAM (Lodestar microcomputer)

Archive: 20 posts
2015-03-07 14:32:00 / Author: Ayneh
Over the last couple of months I've developed an 8-bit CPU and 256-byte RAM chip. Together I believe they represent the fastest and most versatile computer made in LBP to date. I call this system the Lodestar.

http://i.imgur.com/iOpsaVv.jpg

A Lodestar system drawing a bunny. Why? Because bunnies.

1 INTRODUCTION
1.1 SPECIFICATION
1.2 DESIGN AND INTERFACE
1.3 INSTRUCTION SET
2 PROGRAMMING
2.1 YOUR FIRST PROGRAM
2.2 ADDITION
2.3 MULTIPLICATION
2.4 INPUT AND OUTPUT
2.5 GRAPHICS
2.6 SOUND
3 WHERE TO GET IT

1 INTRODUCTION

The Lodestar is an 8-bit microcomputer that supports arithmetic, logic, conditional jumps, a stack, subroutines, serial I/O and interrupts. It can also generate music.

The most challenging part of developing the CPU were signal timing issues. To make the best use of each frame the system runs unclocked at 30 Hz, resulting in speeds of around 3 instructions per second.

One of the problems with past computers in LBP is how poorly documented they were by their authors. With this post I hope to provide a comprehensive guide to the system.

1.1 SPECIFICATION

- Accumulator architecture
- 256 bytes of memory
- 2 addressing modes
- Serial I/O ports
- 3 bars of thermo

Internally the system is split into 2 chips: the CPU and RAM. Together they use 4000 components total.

http://i.imgur.com/eBHmNTj.jpg

These chips are mounted on a board above the switch assembly.

1.2 DESIGN AND INTERFACE

The Lodestar's front panel has 20 lights and 12 flip switches. Since I'm a fan of vintage computers the front panel is inspired by machines like the PDP-8 and Altair 8800.

http://i.imgur.com/N2rwbME.jpg

There are 4 control switches: RUN starts and stops a program, EXA examines a memory address, DEP deposits a value into memory, DAT toggles display of the accumulator or data bus.

The address lights show the current memory address. The data lights show either the contents of memory or the accumulator depending on the position of the DAT switch. The status lights indicate the internal state of the machine, such as overflow and I/O port activity.

On the right side of the machine are the serial input and output ports.

1.3 INSTRUCTION SET

The Lodestar instruction set features 36 documented instructions.

http://fs1.directupload.net/images/150419/4beky8gk.png

There are two addressing modes for the LDA, STA, ADD, SUB and bitwise instructions: immediate and absolute. This is determined by the 1th bit of the instruction as demonstrated below.

http://fs1.directupload.net/images/150419/8q92abea.png

These addressing modes allow the use of variables in programs.

2 PROGRAMMING

A Lodestar program is a series of instructions. When you flip the RUN switch the program will begin executing from the current memory address.

Programs are entered byte by byte. To input a byte into memory:


1. Set input switches to desired address and examine
2. Set input switches to desired value and deposit

To input the value 44 at address 08 for instance you would first examine 08 and then deposit 44.

What follows is a tutorial that introduces the instruction set through 6 programs. All the programs begin from address 0.

2.1 YOUR FIRST PROGRAM

A program can be as simple as a single instruction.

http://fs2.directupload.net/images/150419/orqdp4nm.png

This program uses the jump instruction to jump to itself, creating an infinite loop.

2.2 ADDITION

Performing arithmetic is just as simple.

http://fs2.directupload.net/images/150419/whjqdvgg.png

This program loads 5 into the accumulator, then adds 3 to it.

As the name implies the accumulator accumulates the result of all operations. To see the result of this program displayed on the data lights flip the DAT switch up.

2.3 MULTIPLICATION

There's no multiply instruction. Instead, repeated addition can be used.

http://fs2.directupload.net/images/150419/t53dixve.png

This program performs 5 x 4. There are two variables used: x and i. The variable x is initially set to zero and accumulates the result with each iteration of the loop. The variable i is decremented once per iteration and acts as a counter, when it reaches zero the program halts.

2.4 INPUT AND OUTPUT

Located on the right side of the Lodestar are both the serial input port and serial output port. These can be used to connect peripherals or to create networks of Lodestar systems.

On receiving a byte via the input port an interrupt is triggered. An interrupt pushes the current memory address to the stack and the CPU jumps to address 0. After an interrupt has been handled a RTI instruction can be used to return the CPU to the prior address.

http://fs2.directupload.net/images/150419/3u6yenl7.png

This is a powerful program that listens to the input port, copying whatever it receives to memory. This means we can hook up a keyboard to the system, so programs can be entered easier and

faster. In fact, all the programs in this tutorial were written using this program and a keyboard.

Although not necessary, this program uses the stack to temporarily store the interrupt. The stack starts at address FF and decrements down. This is a handy way to pass data around without using lots of LDA and STA instructions.

2.5 GRAPHICS

Using the serial output port it's possible to communicate with peripherals such as a monitor.

http://fs2.directupload.net/images/150419/wgkt3ojh.png

This program sends a region of memory to the serial output port, byte by byte. The monitor treats these bytes as pixel coordinates and updates the screen. In this case, the pixel data is 3 bytes long and draws a triangle.

https://i.imgur.com/LKKAIFa.jpg

By combining this program with the program in the previous section it's possible to copy programs and data from one Lodestar system to another.

2.6 SOUND

Lastly, the Lodestar is also capable of generating music. The lowest 4 bits of the accumulator determine the pitch when the SPK instruction is used.

http://fs2.directupload.net/images/150419/bv2yhvin.png

This program plays a spooky song.

3 WHERE TO GET IT

The level, which features a running system, can be found here:

https://lbp.me/v/qvz2ch0

Simply complete the level to collect the Lodestar, monitor and keyboard as shareable prizes.
2015-03-07 14:32:00
Author:
Ayneh
Posts: 152

2015-03-07 15:18:00 / Author: gurren009
That's quite impressive!
2015-03-07 15:18:00
Author:
gurren009
Posts: 617

2015-03-07 17:11:00 / Author: JellyBellyScout
Woah

Hope you end up getting the "awesomesauce" pin for this.
2015-03-07 17:11:00
Author:
JellyBellyScout
Posts: 467

2015-03-07 20:41:00 / Author: dakrrs
Wait...this is LittleBigPlanet right? O_o
2015-03-07 20:41:00
Author:
dakrrs
Posts: 561

2015-03-07 20:47:00 / Author: nerd_dog
yep @dakrrs. I have a few logic friends that have made logical masterpieces like this. but dang this looks like quite the accomplishment! i'll have to queue this because I really wanna see this logic in action. Very impressive indeed!
2015-03-07 20:47:00
Author:
nerd_dog
Posts: 1483

2015-03-07 22:47:00 / Author: THE-73est
Wow, I actually just took a computer architecture class last semester in university (I am in Software Engineering), and learned all about this stuff, and was considering doing something like this myself, but this blows out even what I had in mind. Mind if I ask, are you in computer science, or computer/software engineering fields.

I have queued up the level.
2015-03-07 22:47:00
Author:
THE-73est
Posts: 39

2015-03-08 16:31:00 / Author: Ayneh
It seems while this level is stable on LBP2 it crashes LBP3 on PS3. I've narrowed down the issue to a single chip and hope to publish a fix shortly.
Nah, I'm just a hobbyist.
2015-03-08 16:31:00
Author:
Ayneh
Posts: 152

2015-03-08 16:46:00 / Author: Kid_code
It's not lbp any more. Just. Woah. I can't even believe how much time this would of took.
2015-03-08 16:46:00
Author:
Kid_code
Posts: 90

2015-03-08 23:26:00 / Author: Sound Friction
Holy shit, Ayneh = Mad Scientist
2015-03-08 23:26:00
Author:
Sound Friction
Posts: 437

2015-03-09 10:03:00 / Author: 211Nickey
The game keeps crashing when loading the level, so I'm not able to play it...

mmm good lbp3
2015-03-09 10:03:00
Author:
211Nickey
Posts: 337

2015-03-09 11:17:00 / Author: nerd_dog
I was having the same problem. i'll have to check it out on lbp2

i'll check out the fix to see if it works first though
2015-03-09 11:17:00
Author:
nerd_dog
Posts: 1483

2015-03-09 12:02:00 / Author: dragonicfire
Holy crap, I am definitely queuing this up to try out. Awesome work!
2015-03-09 12:02:00
Author:
dragonicfire
Posts: 85

2015-03-10 15:59:00 / Author: Ayneh
quote)Zitat von nerd_dog im Beitrag #11
I was having the same problem. i'll have to check it out on lbp2

i'll check out the fix to see if it works first though

I've republished the level with an update. It won't crash LBP3 now.

Sorry to you both and anyone else who had their console crash before.

I had to move the contents of the CPU to a piece of material and make the inputs wireless to stop the crashes. My guess is LBP3 can't resolve the internal state of the chip somehow.
2015-03-10 15:59:00
Author:
Ayneh
Posts: 152

2015-03-10 19:33:00 / Author: Fox
That is just fantastic! How long did it take you to program this?
2015-03-10 19:33:00
Author:
Fox
Posts: 211

2015-03-10 20:34:00 / Author: dakrrs
Was about to put this in my queue until I saw this comment. Now I'm afraid.

COMMENTS

Zupaton

"Possibly wasn't created with this in mind but the level crashed my ps3 in lbp3 2 times in a row, obviously the second after a clean restart"
2015-03-10 20:34:00
Author:
dakrrs
Posts: 561

2015-03-10 21:18:00 / Author: samuasp
I think I may need your help with programing a card game called the eye of judgement haha part way through it got the feild logic setup done just need to work on the cards and creatures plus a system to give and take mana from both players during turns and summoning creatures BTW is this level published would love to check it out
2015-03-10 21:18:00
Author:
samuasp
Posts: 73

2015-03-11 16:44:00 / Author: Ayneh
The first level backup for the CPU was made on 2015/1/19, so about 2 months.

The RAM chip was made last year along with the switches, so I already had a bunch of stuff to work with.

That has been fixed with an update. The level won't crash LBP3 now.

Have you written about your level anywhere on here? If you have all the mechanics you have in mind written up I can help out.

And yeah, it's published here: https://lbp.me/v/qvz2ch0
2015-03-11 16:44:00
Author:
Ayneh
Posts: 152

2015-03-12 19:03:00 / Author: samuasp
Yeah there is a post on here somewhere I recently published a showcase showing how it works sort of thinghttp://lbp.me/v/qv0e7ew the logic is need to try and sort is a round based thing using selectors to switch between player 1 and 2, at the start of each players turn they gain two mana. Check this youtube video out from the original game as this will give you an oversight on the complexity and size of this project plus what kind of logic setups are needed https://youtu.be/ni3UvCJUXXE
2015-03-12 19:03:00
Author:
samuasp
Posts: 73

2015-03-14 10:37:00 / Author: Ayneh
Link me to your thread so we can talk about stuff there.

You're right in that you'd likely control the flow of the game with selectors. After reading this the flow of the game appears relatively simple: http://db.gamefaqs.com/console/ps3/file/eye_of_judgement.txt

What I imagine is an adder/subtractor circuit that takes 2 cards (from 2 sets of 7 card slots) and performs some operation on them. Which cards are fed into the circuit is determined by the grid and whether the current player's mana is above 0.

A lot of the attributes the cards have, like being poisoned, their cardinal direction, etc, I would discard initially since it introduces a lot of complexity.
2015-03-14 10:37:00
Author:
Ayneh
Posts: 152

2015-03-14 11:39:00 / Author: samuasp
The eye of judgement i have most of the feild logic setup as i think i mentioned before i have been working on a few of the spell cards and have a basic chip for the cards which indicates health.attack power their ability to counter attack if they can gain any health from beijg placed on a correct feild and if they lose health from being placed on the wromg feild ect gonna have a quick look at a mana system now just send me a message on psn - blockbuster95 (sorry for the lack of grammer in this post typing it on my phone)
2015-03-14 11:39:00
Author:
samuasp
Posts: 73
LittleBigForum Archive Statistics
Posts: 37945 • Threads: 4847 • Members: 3878  • Archive-Date: 2019-04-15

Datenschutz

Aus dem Archiv wurden alle persönlichen Daten wie Name, Anschrift, Email etc. - aber auch sämtliche Inhalte wie z.B. persönliche Nachrichten - entfernt.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.