Tuesday, January 24, 2017

Chip-8 for the RCA Studio II ?

Hi folks,

I know i have not much posted on this blog, that's because i'm trying to finish my OdySim project but from tme to time, i'm trying to hack or mod something for the Studio II or clones. The last mod i've attempted was a "pause" switch and connecting an Atari 2600 joystick in parallel to keypad A. The pause switch works but i haven't fully tested it to see how long it can "pause" without any kind of bugs.

As for the joystick, well it works...BUT..(yeah a big but) by connecting it in parallel to the keypad A of my Studio II, now it's the keypad who doesn't work. That mod too needs to be checked. But orget those for the moment and concentrate on the subject: Chip-8 for the Studio II !! (and Euro clones also).

I had this idea in my head for a long time, something like 12 years now and seems i wasn't the only person who had this idea (later on). The Studio II is based on a series of 1802 CPU's computers (FRED, Elf, Cosmac VIP, etc...) which all of them have many features in commun with the Studio II. If you look at the ELF or VIP computers (just to name these two), both have a interpreter that people could use which is called: Chip-8.

There's a freaking slew of Chip-8 emulators out there (PC, MAC OS, Android, Java...and so on) and even for many game systems like: Sega Master System, Colecovision, Atari Lynx, Game Boy...etc!! but none for the Studio II..so the big question is ...WHY ??!??

The interpreter (or BIOS) that's built-in the Studio II is very similar, in fact uses many Chip-8 references but it is NOT a Chip-8 interpreter which resides in any Studio II or clones. This interpreter is machine language/Chip-8 mix into one especially for the Studio II. There's a "Programming Cartridge" (aka PROM cart) that Aresco published back then that you could program in machine language on any Studio II..cool but then again, why no Chip-8 interpreter ?

If the Studio II is very similar to Chip-8, then why not make a suited Chip-8 interpreter for the Studio II ?? Let's take the VIP as example. the VIP has a ML interpreter that is 512 bytes (1/2K) and is at memory adress 8000, so you need to load the chip-8 interpreter at adress 0000 and Chip-8 games starts at 0200. Simple enough.

So you need a "monitor" (the VIP BIOS) interpreter and the Chip-8 so Chip-8 game can work. Let's say we use the VIP monitor at adress 0000 to 01FF and the Chip-8 interpreter at adress 0200 to 03FF which makes 1024 bytes (or 1K) of codes taken as each interpreters are 512 bytes. So games would starts at 0400 to ... WAIT!!

You need to know that the last 352 bytes are reserved for stack/variables  (from 0EA0 to 0EFF, which equals 96 bytes) and video RAM (from 0F00 to 0FFF, which equals 256 bytes) so games would resides from 0400 to 0E9F (which makes 2720 bytes available).

I tried yesturday a Chip-8 program i've made called "Hello World!) which is a BMP viewer program which looks like this (with Fish 'n Chip emulator - sorry for the small picture, it is 64x32 pixels wide):

 The result was for a first try not too shabby as i saw the Earth image in half and the words were inverted (flipped) with many garbled sprites on screen as i used only the Studio II BIOS+original Chip-8 interpreter (ELF or VIP) with the code of the "Hello World" program. It didn't worked like a charm but at least it's a step in the right direction. Oh and i've put this "bundled" code on a RCA Studio II Multi-Cart available from 'FliP" of Atari Age forums.

Since i'm NO programmer (OK.... I know BASIC and LUA - big Whoop!), is there someone who knows ML/Chip-8 languages for the CDP1802 and could do a Chip-8 intreperter made for the Studio II ? That would be SSOOO AWESOME!!

Because this would extend the game library of the Studio II not to 30 or 40 games but more than 200!! Yup, i'm not joking as i cataloged more than 200 Chip-8 games which this list contains NO alternate versions or program/demos. I have so far 109 Chip-8 games in ".c8" format and i'm missing about 125 Chip-8 games which are still either not typed and saved in c8 format or missing the listing. I will post my list very soon with all the Chip-8 games i've collected so far.

7 comments:

  1. Replies
    1. Hey Ianoid!

      Thanks very much but marcel has made a Chip8 interpreter which can play some games for now he's the one to cheer! =)

      Delete
  2. Interesting idea; I won't promise that I'll manage but I will have a look

    ReplyDelete
  3. Have a very preliminary / limited first version running. I still have the chip8 SW at 0x200 next step is moving that to 0x400. All I did so far is I added one byte at the start of the VIP chip 8 to be able to load the right screen value. I also copied the VIP interrupt routine. Just wondering how you were planning to replace the Studio ROM? is there an option for that? or should we put the chip8 interpreter itself starting at 0x400?

    Can I email you directly?

    ReplyDelete
  4. Hi Again, sorry got some 'bad' news. I'm afraid I got stuck on the following: chip8 SW on the VIP and Elfs is running in RAM, Studio II would run the chip8 SW from ROM. This is a bit of an issue as most chip8 SW will use the same 'area' for storing data. For example I got David's breakout game working but the scoring stayed on '0' as the score is stored on address 0x516 (originally 0x316 but with the Studio offset that I build in 0x200 higher). I expect most games will suffer from this. Of course we could adapt all chip8 SW to use Studio RAM but that might defeat the purpose a bit.....

    ReplyDelete
  5. Ok, I decided to finish a first version anyway even if most chip8 SW will not run automatically. I also did some changes in a few games some will be simple others just too much work.

    You can find the Studio II chip 8 version including 3 games here: https://dl.dropboxusercontent.com/u/3880958/studio-chip8.zip

    If you want to run it in Emma 02 I suggest to use this beta:
    win 64 bit: https://dl.dropboxusercontent.com/u/3880958/Emma%2002/Emma_02_x64_setup_v1.24.23.exe
    win 32 bit: https://dl.dropboxusercontent.com/u/3880958/Emma%2002/Emma_02_setup_v1.24.23.exe

    I can make builds for XP or OS X, drop me an email if needed.

    To run the chip 8 make sure to select the chip8.bin file as main ROM (or load the chip8 configuration).

    I can't guarantee this is bug free so drop me a message if you do find anything strange. I will probably try to convert some more chip 8 SW....

    Cheers, Marcel.

    ReplyDelete
    Replies
    1. Hi Marcel!

      Been quite a while since the last time we wrote to each other, how you've been doing ?

      Yes i did just read all the comments a few moments ago, and sorry for the late reply but

      each week-ends i have my kids so i'm pretty much offline when i'm with them.

      You can email me directly at: slydc@yahoo.ca (which is posted on the RCA Studio II blog -

      on the right just before the "about me" with the Dingbot picture).

      Oh and i've just seen the post of FliP on Atari Age that he tested your chip8.bin with the

      game Breakout and it works! I am so much impressed! This is amazing!

      This is quite a step to be able to play Chip8 games on the Studio II and this is your

      first attemp...totally incredible! You're the main man, Marcel! =)

      I saw that your chip8 ROM is 1K (1024 bytes) which has to be from 0x000 to 0x3FF,

      so this leaves 0x400 to 0x7FF for game space and also from 0xA00 to 0xFFF for extra

      game space (the Soundic Victory is using that space for the Blackjack game and i think

      it's using RAM for color from 0XB00 to 0xB3F) as the Studio II (or clones) is using from

      0x800 to 0x9FF for RAM & Video RAM and this we can't touch.

      So on 4K memory (RAM and/or ROM), the first 1K is the Chip8 and minus 512 bytes for

      RAM/Video RAM, that leaves 2,5K for game space. FliP multicart can handle 4K as each

      "slots" on his multicart are 4K each (Flip has put he Studio Ii interpreter from 000 to 3FF

      on each 4K slots and any games from 400 to 7FF).

      I think that you should leave any chip8 game to start at 0x400 (1024 bytes) and if bigger

      than 1024 bytes, the the rest from 0xA00 to 0xFFF (1536 bytes).

      What do you think ? LMK at my email address (slydc@yahoo.ca)

      TTYS! =)

      P.S.: We can't replace the Studio II interpreter ROM as the CS2 pins for both internal ROMS aren't connected to the cartridge port, so the only way to bypass would be to put a switch between both CS2 and R2 (10K resistor) to disable the Studio II interpreter, which is an easy mod to do.

      Delete