Jump to content
  • Advertisement
  • entries
    222
  • comments
    606
  • views
    593031

Running BBC BASIC on a home-built computer

Sign in to follow this  
benryves

1791 views



This computer needs a name - I'd welcome any suggestions!

I have built a circuit on another piece of stripboard that will handle memory, clock signal generation and the Z80 itself.

A few posts ago I was wondering about how I'd partition memory. To date I've been using a very simple circuit where the lower 32KB of addressable memory is mapped to ROM and the upper 32KB is mapped to RAM. As my ROM chip is 128KB and I have two 32KB RAM chips, this seems a bit wasteful.

The memory layout I'm now using is quite simple: the upper 32KB is still mapped to RAM. However, only the first 16KB is mapped to ROM, and the three most significant bits of the ROM chip's address lines are connected to a device on the I/O board so that one of its eight 16KB "pages" can be swapped in. The next 16KB will be mapped to RAM, and the most significant bit of the RAM chip's address is connected to the same device on the I/O board so one of its two 16KB "pages" can be swapped in.


For more information, see the Wikipedia article on bank switching. There is a potential problem here; the Z80 uses particular fixed addresses for certain operations. The three most obvious ones are $0000 (jumped to on reset), $0038 (address of maskable interrupt handler) and $0066 (address of non-maskable interrupt handler). As which 16KB bank switched in at power-on is effectively random, the easy way around this problem is to ensure that the first 256 bytes or so of every ROM page has the same code assembled on it. This means that whichever page is swapped in on boot doesn't matter, as the same common boot code is available on each page.

The assembled memory board looks like this:


Click to toggle labels

I have only attached one of the 32KB RAM chips. The wiring was becoming a bit of a nightmare (I think I'll need to solder to the track side of the stripboard to fit in that other RAM chip) so for the moment the system can only access the fixed 32KB RAM. I haven't yet added the device on the I/O board to handle bank switching, so for the moment the ROM is permanently configured to access the first 16KB page by pulling the its three externally controllable address lines low.

That said, this machine does genuinely run BBC BASIC (the last system only ran a mockup with a dummy header at the top of the screen). I've done quite a bit of work on the OS in the emulator and it works pretty well there, and with a minor adjustment to cram it onto a single 16KB page it works well on hardware too.


Click for video (664KB XviD MPEG-4 AVI)

The row of chips along the bottom of the memory board are responsible for generating the clock signals that drive the computer. If this looks needlessly complex, that's because it can run at either 10MHz or 2MHz and generates the E signal for LCD access. The CPU needs to drop to 2MHz when accessing the LCD (the LCD driver can't keep up, otherwise) so I'll probably end up connecting the input for this 2MHz/10MHz switch to the LCD chip enable pins so that normally the system runs at 10MHz but drops to 2MHz when accessing the LCD. Allowing the user to drop to 2MHz to save power is an appealing idea, however...
Sign in to follow this  


10 Comments


Recommended Comments

Looking at that picture brings a tear to my eye. It takes me back to my days with GW Basic (and later Qbasic) alone in my dark room with nothing but the white glow of the text of my Basic code for my Text RPG. Where I began on a path that led me.. here. ahem.

But yeah I am mightily impressed - you built your own computer and OS and language environment for it from scratchish. To me its nothing short of wizardry.

Share this comment


Link to comment
that is some amazing work you are doing there, cant wait to see your finished product, its gonna kick some major booty.

Share this comment


Link to comment
that is some amazing work you are doing there, cant wait to see your finished product, its gonna kick some major booty.

Share this comment


Link to comment
Quote:
Original post by Daerax
Looking at that picture brings a tear to my eye. It takes me back to my days with GW Basic (and later Qbasic) alone in my dark room with nothing but the white glow of the text of my Basic code for my Text RPG. Where I began on a path that led me.. here. ahem.

But yeah I am mightily impressed - you built your own computer and OS and language environment for it from scratchish. To me its nothing short of wizardry.
Most of the hard work on the software side is done by BBC BASIC; all I've had to do is cobble together a few routines to sit between it and the hardware. The choice of BBC BASIC is partially nostalgia, as that was the first proper programming language I learned myself!

Thanks for the comment and kind words! [smile]

Share this comment


Link to comment
I cant wait to see more progress.
I felt cool earlier today when I finally got my pong for my ti 84 somewhat working and now I see this!

You should definately write a tutorial on how to build your own Benryves Machine from start to finish!

Cheers :)

Share this comment


Link to comment
Quote:
Original post by moose517
that is some amazing work you are doing there, cant wait to see your finished product, its gonna kick some major booty.
Cheers, though I wouldn't exactly describe 70s-era computing as "kicking major booty". [wink] (The Z80 was originally released in 1976).
Quote:
Original post by Falling Sky
I cant wait to see more progress.
I felt cool earlier today when I finally got my pong for my ti 84 somewhat working and now I see this!

You should definately write a tutorial on how to build your own Benryves Machine from start to finish!

Cheers :)
I'm glad to hear you've got your pong game working (even if only "somewhat") - getting started with assembly is the hardest part! Hopefully things will be easier from now on. [smile] If you haven't seen it, the Z80 User Manual is a good reference on the workings of the CPU at a hardware and software level. Thomas Scherrer's Z80 page is extremely useful and has some bare-bones Z80 system designs if you wanted to give yourself an idea of how a Z80 computer may be constructed.

I'm not sure that a tutorial on building a computer from parts would really be much fun to read; it really is a case of connecting the dots ("where it says A0, A1, A2 &c on the CPU, connect them to A0, A1, A2 &c on the RAM and ROM chips") with a few bits of glue logic to hold the thing together. If I get this system working well enough I may design a PCB for it that could be much smaller, more robust and easier to solder than the existing system and get that professionally made up, and publish that online for anyone who really wanted to put it together themselves, but the real fun is in designing and building the hardware yourself, not copying someone else's plans.

Share this comment


Link to comment
Christ, last time I read your journal you were programming a calculator or something - when the hell did this start? Just been scrolling down your journal and it seems to have been going on for ages.

Just remember what happened in Terminator. That must have started out something like this.

Share this comment


Link to comment
Quote:
Original post by EasilyConfused
Christ, last time I read your journal you were programming a calculator or something - when the hell did this start?

I see someone hasn't been reading Weekend Reading often or closely enough [smile]

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!