Making a 1-bit game engine

ftech

New Tinkerer
Mar 31, 2025
12
16
3
A few months ago, while learning C to make applications for my Mac SE, I was challenged by my son to make a cool game that would work on those old 68k compact Macs.
I took the challenge but without knowing what sort of game I would make. Therefore, I started by understanding the concept of sprites; how to animate them, how to move them around. Then, I tried to understand collisions, then I realized that the my code would require a lot of optimizations in order to run correctly on a 68000 Mac. Therefore, from solving one problem to another and still having no clue about what my game would be, I ended up building a game engine which I called ClassicSprite and which I am releasing under a GPL v3 free software license.

It is still a work in progress and I still don't know the best way to publish the code, but I wanted to share a quick demo of a dummy game (an intro and 2 levels) I made with it. I worked very hard on speed optimizations. When launching, the engine pre-calculates as much data as it can to help improve performances (especially movement curves). Although the video shows it running on an SE/30 (my SE is not operational at the moment), the speed is the same on the SE.

So far the engine can handle:
- Sprite animations through sprite-sheets (loaded in the rsrc file)
- Sprite movements with built in easing curves (linear, sine, bounce, elastic...)
- Sprite Z position (automatically calculated for RPG levels)
- Forces (currently only gravitation)
- Collisions
- Events with callbacks for movements, animations and collisions
- Tiles to build the background
- Levels
- Visual helpers to help debug show collision areas
- A profiler showing FPS and memory state

In the future I plan to implement:
- Moving tiles
- Background scrolling
- Using the alternate screen when available (to optimize speed for background scrolling)
- Mouse drag and drop
- More forces (magnetic field)
- Audio

[Update] The code is now available at https://gitlab.com/ftech31/classicsprite

 
Last edited:

ftech

New Tinkerer
Mar 31, 2025
12
16
3
Thanks @JDW ! I will see how to publish the source code. It is a bit messy at the moment. I have a folder for the actual source files next to a THINK C 5 project and a CodeWarrior Pro 5 project in their own folders. This way, I keep making sure that the engine works from System 6 all the way up to MacOS 9 on PPC. I have also successfully tested this demo on A/UX 3! :)
 
  • Like
  • Wow
Reactions: Eric's Edge and JDW

eric

Administrator
Staff member
Sep 2, 2021
1,114
1,846
113
MN
bluescsi.com
Fun to see more new games come out for the classic mac!

Looks like you're pretty familiar (modern?) game dev? What were your biggest challenges working in classic mac/toolbox/etc?
 
  • Like
Reactions: JDW

ftech

New Tinkerer
Mar 31, 2025
12
16
3
I am a graphics designer and I like to play with my old Macs to make drawings and animations. I am new to game design and I discover the joy of making sprites as well as pixel art in general. I have worked as a software developer 20 years ago so I have some knowledge in this area. However, I am new to the Macintosh Toolbox and I discover how fun it is! :)

The most challenging thing was to find documentation. I found this forum (and some of your posts @eric) while searching for code examples. That helped me getting started. I also got myself the Inside Macintosh books. The next challenge was to optimize the logic so that it has the right balance between memory consumption (caching data) and speed. I made sure that any floating point operation is made before the game starts. I also try to do as less CopyBits as possible. I know there are ways to optimize the code even more (like with the alternate screen hack) but I still have to learn those things.

By the way @eric are there any guidelines out there about code syntax and code publishing? I would like to make this project a collaborative effort if anyone is interested.
 
  • Like
Reactions: JDW

eric

Administrator
Staff member
Sep 2, 2021
1,114
1,846
113
MN
bluescsi.com
Ya it's hard to find code examples. Old usenet posts and MacTech are great resources too. AI can sometimes help explanations but sometimes tries to use too new of API's.

Biggest part is understanding the lingo - they talked differently back then about systems and when we read it 30-40 years later the meanings behind common abbreviations, slang, references is lost.

I use Amend/AmendHub for sharing. Github is fine too but line endings/encoding/etc.
 

Mu0n

Active Tinkerer
Oct 29, 2021
647
605
93
Quebec
www.youtube.com
Thanks @JDW ! I will see how to publish the source code. It is a bit messy at the moment. I have a folder for the actual source files next to a THINK C 5 project and a CodeWarrior Pro 5 project in their own folders. This way, I keep making sure that the engine works from System 6 all the way up to MacOS 9 on PPC. I have also successfully tested this demo on A/UX 3! :)

Very cool to see more C development for old Macs. I have a long term goal of developing games for my Mac Plus as well and I've taken a long winded path as well, collecting tech demos along the way.

I also went into rabbit holes with sprite animation and background preserving and I agree that it's pretty hard to vanquish in all areas.
For the past year, though, I've made a lot of progress understand MIDI and pairing it with 20 year old code of mine that uses the Sound Driver.

You seem to be on solid ground on the graphical side. I would love to help you with audio and offer whatever I have. Here's a repo that I started this year where I just stashed disjointed code from the last 20 years https://github.com/Mu0n/1bitdreammachine

 
  • Love
Reactions: ftech and JDW

Eric's Edge

Tinkerer
Oct 31, 2021
128
95
28
This is so awesome! I am currently building some tools in C for HyperCard. And look forward to learning more for classic game development.
 
  • Like
Reactions: JDW

ftech

New Tinkerer
Mar 31, 2025
12
16
3
Thanks for your comment @Mu0n ! I really like what you are doing with audio and I believe that your project is as advanced on the audio side as mine on the graphics side. If we mix both projects we could have something pretty nice at the end. I will try to publish my code some time this week. I have used Amend for backuping my work so I guess AmendHub is a nice place to start. I'll keep you updated here.
 

sam256

New Tinkerer
Oct 14, 2025
6
5
3
  • Like
Reactions: ftech and JDW

ftech

New Tinkerer
Mar 31, 2025
12
16
3
Thanks for sharing @sam256. Those are great sources of examples. I believe Continuum implements the alternate screen hack and features a pretty smooth scrolling background. I will definitely check that out!
 

sam256

New Tinkerer
Oct 14, 2025
6
5
3
Yes, it did have very smooth screen scrolling, mostly due to the highly optimized wall drawing algorithms (written in assembly). It actually used a slightly different double buffering scheme depending on whether it was running on "old" hardware (Mac Plus or earlier) or "modern" (SE/30, Mac II). I think CopyBits wasn't available on some of the earlier machines? The relevant code starts around line 1104 in Play.c
 

sam256

New Tinkerer
Oct 14, 2025
6
5
3
Interesting. I don't know why they didn't use it there then. The game originally ran on 128K Macs but then they eventually had to bump the spec to 512K, so maybe even though the game code refers to MAC_PLUS it was vestigial from an older system. Not sure. I didn't focus on that logic that much when I was porting, since it was hardware focused.

In any event, one thing that I think is interesting about that game unlike other pure sprite games from the time is that it was actually redrawing the walls each frame based on their coordinates (not sprites), and doing it fast enough to have smooth scrolling at 20fps.
 

ftech

New Tinkerer
Mar 31, 2025
12
16
3
I have made a repo on Gitlab so you can already play with the code: https://gitlab.com/ftech31/classicsprite
I am not sure I package the project correctly, I am not used to this kind of retro computing repo so any comments are welcome!

Unfortunately there is no documentation yet. This will be a whole project by itself but I plan to do it at some point. You can already check the code of the demo which is all in the main.c file. This file may be a bit messy at this point and I also plan to do some proper demo files when I get the time.

The rest of the code is written in an object oriented fashion and should not be too difficult to decrypt. Most of the rendering happens in `cs-scene.c`. In this file, there is function that checks collisions (cs_scene_check_collision) 60 times per second. This function is pretty big because it is resource intensive and I tried to inline as much as I could in order to avoid wasting time in method calls.

I tried to comment things that are not obvious so it makes the code easier to read.

Any feedback is welcome! :)
 
Last edited:

sam256

New Tinkerer
Oct 14, 2025
6
5
3
Unfortunately there is no documentation yet. This will be a whole project by itself but I plan to do it at some point. You can already check the code of the demo which is all in the main.c file. This file may be a bit messy at this point and I also plan to do some proper demo files when I get the time.
You might want to use an LLM to help with that. Claude Code is surprisingly good at understanding vintage mac code!