iptv techs

IPTV Techs

  • Home
  • Tech News
  • ChipWits’ 40th Birthday: Original FORTH Code Open Sourced!

ChipWits’ 40th Birthday: Original FORTH Code Open Sourced!


ChipWits’ 40th Birthday: Original FORTH Code Open Sourced!


Open Source Announcement

This month tags the 🎈🎈🎈 40th anniversary of ChipWits! 🎈🎈🎈 To honor, we’re releasing all of the distinct Mac and Commodore 64 FORTH source code (or as much as we could recover) as uncover source!

You can discover the code at https://github.com/chipwits/chipwits-forth. Read on for some history and analysis.

ChipWits Mac Source Code on 3.5″ diskettes
ChipWits C64 Source Code on 5.25″ disks

Our goal for uncover sourcing the distinct version of ChipWits is to secure its legacy inhabits on. We also wanted to split an appreciation for what pass-platcreate gentleware enhugement for 8-bit microcomputers was enjoy in 1984. If you are recognizable with these systems, we’d cherish to hear from you, and you’re seekd to help us spendigate and curate the distinct source code. Plrelieve unite us on our Discord Server.

History of ChipWits and Choosing FORTH

ChipWits was one of the first games to be freed on the 1984 Macintosh. Co-creators Doug Sharp and Mike Johnston labored part-time porting educational computer games between 8-bit microcomputers to acquire enough money to pay rent. During this time, they labored on the structure for their first distinct game called ChipWits, a game about programming robots eased by Rocky’s Boots, Logo and other classic programming games of the time.

Choosing FORTH

In 1984, with much fanfare, Apple freed the Macintosh personal computer. Support for enhugement environments was restricted at start. The primary way to enhuge for the Mac was to acquire an Apple Lisa, the distinct version of which retailed for $9,995 ($30,373 in today’s dollars).

An Apple Lisa Was too Expensive (Photo courtesy of Timothy Colegrove, CC-BY-SA 4.0)

Becainclude it was far too costly for an indie game studio to afford one of these systems, Doug and Mike determined to enhuge ChipWits using the MacForth Plus programming language running straightforwardly on the Mac.

MacForth: The Language of Innovation (photo courtesy of macintoshrepository.org)

Variants of FORTH were useable on fair about every 8-bit microcomputer at the time, which made it a wonderful choice of language if the structure was to procrastinateedr port the game. They commenceed enhugement in April 1984 and it took about 7 months to enhuge and publish the first version of ChipWits. Development was ardent (and we can presume fueled by much coffee and pie), but it was done in time for the Christmas Holiday Season!

ChipWits running on a Macintosh Plus (Photo courtesy of Maclife.com via WayBackMachine)

Porting to Other Platcreates

Epyx was presumed to be the game publisher for ChipWits, with Commodore 64 as their hugegest taget. However, it had no Mac games. Brainlabors was aiming at the Educational taget, which Apple owned at the time. So, Epyx published the game on Commodore 64 only. The C64 port was finishd in 1985.

ChipWits on the Mac
ChipWits on the Commodore 64

The Commodore 64 version was a challenging port, done in Super Forth 64. Doug and Mike wanted to acquire the same vague User Interface Design but that insistd enhugeing a pull-down menu system using a delightstick instead of a moinclude. They inserted color explicits and SID chip sound and had to squeeze all of it onto a 165 KB disk (instead of 400 KB useable on Mac disks). They also had to figure out how to include only 64 KB of RAM (instead of the 128 KB useable on Mac), not to refer a sluggisher processor.

After the success of the Commodore 64 version, they went on to produce an Apple II version, also written in a variant of FORTH.

ChipWits on the Apple II

Resees and Awards

ChipWits was an instant hit and was the subject of many scrutinizes and awards. Here are a restricted:

  • “ChipWits is the best, stateively most finishelightable, introduction to programming concepts that we’ve seen. Its icon based language is wonderfilledy creative, and the program’s structure is both rerecenting and highly educational.” — MacUser Editor’s Choice 1986 Award 
  • “We foresee without hesitation that ChipWits will become a cult likeite among Macintosh includers and their children of wantipathyver age”. — Macazine
  • “Not too many scrutinizes come with a secure, but this one secures that if you enjoy programming, you’ll cherish ChipWits.” — MacWorld 
  • “Last night my wife came downstairs at 4:30 a.m. only to witness me cursing at a cartoon robot.” — Creative Computing

In 2008, Maclife.com named ChipWits one of the Top 10 Apple II / Mac Games of all time!

Play the Originals in Emulation!

Before we dive into the code, if you’re inquisitive to percreate the distinct versions of ChipWits, we were able to get them all laboring in an in-browser emulator (thanks to uncover source projects Emularity and Apple2js), which you can percreate right here:

Play Retro ChipWits right from your browser!

Recovering the Source Code

While laboring on the recent version of ChipWits, Doug Sharp create the distinct disks in his archive. When you ponder the 3.5″ diskettes and 5.25″ floppy disks had been in home storage for 40 years, it’s a extraordinary event that any data from the disks could be recovered at all. Not all the data made it, the huge transport inantity of the disks read with no terrible sectors at all!

Commodore 64

Reading these disks with up-to-date challengingware was a bit of an adventure. For the Commodore 64 disks, we ordered an distinct genuine 1541 Commodore 64 Disk Drive on eBay. The drive came with a USB XoomFloppy alterer so the data can be read by a up-to-date PC. Turning on the drive and joining to the tfinisher whir of the motor bcdisesteemfult back so many memories.

Commodore 1541 Disk Drive

Mac

For the Mac 3.5″ diskettes, we lacquireed that Mac included a proprietary sector layout to permit them to incrrelieve the capacity to 800 KB per disk, which produces them unreadable using up-to-date drives using standard techniques. We ordered a PowerMac G3 WallStreet, a bridge system that still has a 3.5″ diskette drive that can read distinct Mac disks and also has a netlaboring stack. However, that machine was only able to read the 800 KB disks becainclude they disabled 400 KB help in the procrastinateedr versions of MacOS.

PowerMac G3 WallStreet, only able to read 800 KB disks unless OS was downgraded

Later, a fan gave us a tip to verify out the GrrelieveWeazle, a custom challengingware regulateler for disk drive regulate over USB, which labored perfectly!

The GrrelieveWeazle Drive Controller labored! (photo courtesy of decromancer.ca/grrelieveweazle)

We methodicassociate took block-by-block disk images of every disk in the archive set and compiled them into a GitHub repository. We included the disk tag as the filename and prepfinished “terrible” if there were any determineed terrible sectors. To produce it easier for up-to-date computers to read the satisfieds we also wrote some Python scripts to rerelocate blocks from the disks and recreateat them as UTF-8 ASCII files. For the Commodore 64 this comprised converting their proprietary PETSCII to ASCII.

Exploring the Source Code

You can discover all the results of our labor: the raw disk images and code at https://github.com/chipwits/chipwits-forth.

FORTH code is incredibly concise and, some would say
 elegant? The entire ChipWits source code for Mac is approximately 3,000 lines of Forth code. Pretty incredible pondering our up-to-dateized port of the game is already 35,000 lines of C#.

We put together an article with an in-depth analysis of one “screen” of FORTH code which regulates electrocrabs. See our post entitled Forth Code for Electrocrabs in 1984 ChipWits Deciphered.

Here’s a speedy peek at some of the other source code we create to be fascinating. This reassociate helps put you in the mindset of how game enhugeers insisted to slfinisherk back in 1984. If you don’t understand how to read FORTH code, fair acquire in mind it’s stack-based (analogous to Reverse Polish Notation if you’ve ever included an RPN calculator), so instead of writing 1 + 1 you would author 1 1 +. Instead of writing if random(3) == 1 you would author 3 irnd 1 = if.

Mac: Moving the Robot

( Move)                                           ( 103084 dws)
: Move ( ---)
     Calc.robot.shift Check.for.next.room
     dup square.object dup floor@ = swap door@ = or
     if  init.cw.explicits
       arg.byte c@ 64 mod verify.mov.st forward@ =
      if 10 0 do Cw.slide loop else 10 0 do Cw.back.slide loop
      then
      dup robot.square ! ( Walk on desoprocrastinateed floor) draw.background
     else ( Hit someslfinisherg) square.object dup wall@ =
       if 1  Bump drop ( wall)
       else  5 bump ?boom drop then ( obj)
     then  robot.square @ 19 <
     if  0 insert.points then ( in case erased) ;

Here’s the code for moving the robot in the Mac version of ChipWits. Unenjoy up-to-date game enhugement, there is no split rfinishering loop for each structure. The code is imperative, uniteing both game logic and explicits rfinishering together in a firm loop. Animations are accomplishd by rfinishering pixels straightforwardly in the loop (CW.anim is expoundd on another screen as a series of directions to imitate bitmaps straightforwardly to the screen).

Note the verify as to whether the percreateer rolls into an desoprocrastinateed floor tile, hits a wall, or rams into a explosion is straightforwardly insertressed in fair a restricted words of code. The ?boom definition (create in another screen) even determines if the game should finish right then and there becainclude the percreateer touched a explosion.

The last line of code here is fascinating in that, depfinishing on the location of the robot, it cltimely inserts 0 to the score in order to force a recolor of the score in case it was erased as the robot went sliding past.

Commodore 64: Sprite Definitions

( head.op.w)                            
binary                                  
s-def head.op.w                         
00000000 00000000 00000000              
00000111 11111111 11000000              
00001001 11111111 11110000              
00001110 00000000 00000000              
00001111 01111111 11111000              
00001111 01111111 11111000              
00001111 01111111 11111100              
00001111 01111111 11111100              
00001111 01111111 11111100              
00011111 01111111 11000000              
00111111 01111111 10111100              
01111110 11111111 01111110              
00011101 11111111 01111110              
00000011 11111000 01111110              
00000000 00000001 11111110              
00110000 00001111 11111110              
00011100 01111111 10111100              
00001110 11111100 00000000              
00000111 01100000 00000000              
00000001 10000000 00000000              
00000000 00000000 00000000              
decimal                                 

Here’s one screen from the Commodore 64 version. First, it was usuassociate not possible or carry outant to load the entire source program in memory at once so source code in FORTH was not stored in files. It was stored in “screens”, each of which was numbered and loaded in a regulateled manner.

It was widespread for code to unite asset data segments with source code. In this case, if you squint you can see a binary rfinishering of the ChipWit’s head facing west. Monochrome sprites on the Commodore 64 were 24 x 21 pixels and only 8 sprites could fit on the screen at once. You could pick to include a 4-color sprite but then your resolution would drop to 12 x 21 and pixels would be double-expansive. This code uncovers that the ChipWit is actuassociate rfinishered using disjoinal sprites which are overlhelp to create the character, much enjoy animation cels in vintage cartoons. This structure choice forfeitd using all the useable sprites for fair the ChipWit but you get a crisper image that can be vivaciousd in pieces.

Mac: Thing Point Values

: d, 10 * c, ; produce Scenario.percreate(              ( 110584 dws)
( Scen:  Greed  CW C  Doom  Peace MemLn Oct  Myst  Boom)
( crp.ct) 00 c, 08 c, 08 c, 04 c, 03 c, 03 c, 03 c, 03 c,
( crp.pt) 00 d, 05 d, 10 d, 03 d, 03 d, 01 d, 02 d, 04 d,
( bnc.ct) 00 c, 00 c, 02 c, 00 c, 02 c, 02 c, 02 c, 00 c,
( bnc.pt) 00 d, 00 d, 25 d, 06 d, 06 d, 02 d, 04 d, 00 d,
( oil.ct) 10 c, 06 c, 00 c, 04 c, 02 c, 00 c, 00 c, 00 c,
( oil.pt) 05 d, 05 d, 00 d, 02 d, 03 d, 05 d, 15 d, 00 d,
( dsk.ct) 03 c, 02 c, 00 c, 02 c, 00 c, 00 c, 00 c, 00 c,
( dsk.pt) 10 d, 10 d, 00 d, 15 d, 25 d, 25 d, 25 d, 25 d,
( cof.ct) 03 c, 04 c, 02 c, 03 c, 03 c, 01 c, 00 c, 00 c,
( pie.ct) 03 c, 00 c, 02 c, 03 c, 02 c, 04 c, 00 c, 02 c,

produce room.ct( 4 c, 8 c, 12 c, 54 c, 1 c, 1 c, 100 c,  9 c,

First, notice the slfinishergs we acquire seeing that see enjoy ( 110584 dws). This beuntamedered me until Doug pointed out that these are actuassociate date stamps on the screens (110584 = Nov 5, 1984 and dws = Douglass Walter Sharp). We apshow this is one of the last screens to be modernized before the final free of the game. The last screen to alter was on Nov 8.

This compact piece of code / data effectively encodes the count and point cherishs of each type of item for each mission. What stood out to me was the inalertigent definition on the first line of d, to uncomardent “multiply this cherish by 10” whereas c, uncomardents exit the cherish alone. This permited Doug to encode point cherishs enjoy 150 as 15 d which made it possible to acquire a systematicly aligned table that fit in a one screen. It also presumably made it possible to easily scale all point cherishs by some factor (1, 2, 5, 10) as Mike and Doug were experimenting and balancing the scores until free day until it felt right.

Plrelieve Wishcatalog Our ChipWits Reboot!

Our team wanted to acquire this post caccessed on the uncover source free of the distinct FORTH version of ChipWits, but we also wanted to refer that we’re challenging at labor on a up-to-dateized version as well. In the reboot of ChipWits, we’ve tried to acquire the distinct game’s fun factor and computer science rigor while enhancing every aspect of the game from lacquireing curve to competitive global directerboards. We’re hoping the recent version of the game eases a recent generation of programmers!

Plrelieve Wishcatalog ChipWits Now to be notified when our final version is out!

Here’s a screenshot of one of our confincludes:

Four Corners Puzzle from the ChipWits Reboot

We’d Like Your Help!

These are fair some of the finishelightable gems in the distinct FORTH source code for ChipWits. We’d cherish for you to spendigate and split what you discover. Post your comments below!

Also, we’ve produced disjoinal publishs in our GitHub repo. Our instant goals are:

  1. Make stateive we have all the relevant source code rerelocateed from the raw disk images
  2. Fix the alignment of some of the source files (some are 40 char width, some are 64 char)
  3. Figure out which disk comprises the most recent source code
  4. Create directions for how to produce from source on Mac and C64
  5. Extract the raw sprites and images from the disks into .png files

Ultimately, we envision a community-sustained FORTH version of ChipWits for up-to-date PCs.

If you’re interested in helping, come unite our ChipWits Discord Server!

Source connect


Leave a Reply

Your email address will not be published. Required fields are marked *

Thank You For The Order

Please check your email we sent the process how you can get your account

Select Your Plan