Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/StewBC/Time-Pilot
Browse files Browse the repository at this point in the history
  • Loading branch information
StewBC committed Aug 15, 2024
2 parents 2ad2b96 + dc6d988 commit 42263ee
Show file tree
Hide file tree
Showing 105 changed files with 38,015 additions and 0 deletions.
59 changes: 59 additions & 0 deletions TimePilot-Mac68k/BasiliskII_prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
disk //wsl.localhost/Ubuntu/home/swessels/develop/personal/github/Time-Pilot/TimePilot-Mac68k/BootImage/MacintoshHD.dsk
disk //wsl.localhost/Ubuntu/home/swessels/develop/personal/github/Time-Pilot/TimePilot-Mac68k/build/Time.Pilot.dsk
rom C:\Users\swessels\Games\Mac68k\BasilikII\roms\F1A6F343 - Centris 650.ROM
displaycolordepth 0
extfs
seriala COM1
serialb COM2
udptunnel false
udpport 6066
bootdrive 0
bootdriver 0
ramsize 8388608
frameskip 6
modelid 5
cpu 3
fpu false
nocdrom false
nosound false
noclipconversion false
nogui false
jit false
jitfpu true
jitdebug false
jitcachesize 8192
jitlazyflush true
jitinline true
keyboardtype 5
keycodes false
mousewheelmode 1
mousewheellines 3
hotkey 0
scale_nearest false
scale_integer false
yearofs 0
dayofs 0
mag_rate 0
swap_opt_cmd true
ignoresegv true
sound_buffer 0
name_encoding 0
delay 0
init_grab false
keycodes false
mousewheelmode 1
mousewheellines 3
idlewait true
enableextfs true
debugextfs false
extdrives CDEFGHIJKLMNOPQRSTUVWXYZ
pollmedia true
etherpermanentaddress true
ethermulticastmode 0
routerenabled false
ftp_port_list 21
portfile0 //wsl.localhost/Ubuntu/home/swessels/temp/B2TEMP0.OUT
portfile1 //wsl.localhost/Ubuntu/home/swessels/temp/B2TEMP1.OUT
sdlrender software
sdl_vsync false
reservewindowskey false
Binary file added TimePilot-Mac68k/BasiliskII_xpram.dat
Binary file not shown.
Binary file added TimePilot-Mac68k/BootImage/MacintoshHD.dsk
Binary file not shown.
66 changes: 66 additions & 0 deletions TimePilot-Mac68k/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This is how to make this go:
# In the path replace /home/swessels/develop/external/github/ with the appropriate prefix
# Manual:
# mkdir build
# cd build
# cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/swessels/develop/external/github/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake -DARGS_CREATOR=SWTP
# SWTP is Stefan Wessels Time Pilot so this is whatever unique ID of choice and matches the resource bundle

#
# Using VS Code:
# Settings, Extensions, Cmake Tools, Cmake: Configure Args (and add both)
# -DCMAKE_TOOLCHAIN_FILE=/home/swessels/develop/external/github/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake
# -DARGS_CREATOR=SWTP
# Generator:
# Unix Makefiles

cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0091 NEW)

# This include specifies the project and version.
project("Time.Pilot" VERSION "1.0" LANGUAGES C)
message(STATUS "${PROJECT_NAME} version ${PROJECT_VERSION}")

# This does not set the creator code as I expexted. I found I had to manually edit the file:
# build/CMakeFiles/Time.Pilot_APPL.dir/build.make and look for -t APPL -c ???? and
# change the ???? to SWTP (Or whatever owner/creator ID you choose in the resource file)
set(ARGS_CREATOR "SWTP")

# Files needed to create executable.
add_application(
"${PROJECT_NAME}"
src/ai.c
src/audio.c
src/collide.c
src/data.c
src/draw.c
src/erase.c
src/game.c
src/globals.c
src/input.c
src/mac.c
src/main.c
src/print.c
src/screen.c
src/sprite.c
src/text.c
src/things.c
src/ui.c
src/update.c
src/audio.r
src/timepilot.r
src/tpr.r
)

# Set a dependency for timepilot.r on tpr.r
set_source_files_properties(
${CMAKE_BINARY_DIR}/timepilot.r.rsrc.bin
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tpr.r
)

set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_OPTIONS -ffunction-sections)
if(CMAKE_SYSTEM_NAME MATCHES Retro68)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-strip-macsbug")
else()
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-Wl,-gc-sections")
endif()
126 changes: 126 additions & 0 deletions TimePilot-Mac68k/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Time Pilot in C for the 68K Mac
I think you need color - I play on my Centris 650 or in the Basilisk II emulator. Even thouh vMac looks like a target, that just crashes.

This version was derived from the Windows code which in turn was derived from my original Apple IIgs 65816 code. I cleaned up the code a little, since I couldn't afford the sloppiness that I was allowed in Windows. This version sorts the sprites by layer only (vs in Y and then overlapping sprites by layer for the IIgs). The collision routine thus had to change a little as well. Otherwise, this is pretty much the Windows version.

## Prerequisites and Dev Environment
* The code builds using the Retro68 compiler, with the Universal headers.
* To build the art, ffmpeg needs to be installed, and the pipeline is in Python with its own set of requirements. The python script (probably the best thing of the whole project) is in misc/resman.py. See the top of that file for modules needed, also for sample usage.

I developed using WSL (Windows subsystem for Linux) and there are paths checked in, which refer to, for example, Basilisk II, on my Windows side. So, yes, I developed on Linux and from VS Code launched the emulator on Windows, to mount a disk on Linux. It all works great!

## Audio
The audio works quite well, but there are issues with the code. I could not get the callback system to see the parameters I am passing so I found a much less efficient way to do what I need to do (still using async play and the callbacks). I wish I understood what I am not understanding.

## Graphics
The game uses a clever way to draw sprites that don't require a mask. The sprites are encoded as horizontal lines, with a code for draw, skip, etc. All sprites are software drawn to a back buffer and the back buffer is sent to the screen at (hopefully) 60 FPS. At 320x200 this worked but it was agonizingly slow (like 2 FPS) at 640x480. The game now uses dirty rectangles and runs at 320x200 but will stretch by 2x if 640x480 mode is selected. It runs slow, but almost passable like this. Not bad for all "C" code. The sprites and dirty rect code comes from "Tricks of the Mac Game Programming Gurus". That was an invaluable resource for getting this done.

## Code Switches
There's a define to enable replay recording (see RECORD_REPLAY in globals.h). When defined, the game starts at Stage 2 and the playing is recorded to a buffer. When you die or kill the boss, the replay is saved (replayXXX.bin) and played back and the next play will record again. This is useful for capturing the demo attract sequence. The saved files are numbered so the highest numbered save is the last one played. There is, however, an issue with this Mac version where it is somehow not repeatable. I'll have to think how that came about. Quite possibly the Audio.

## Game Input and Keyboard
```
Hold space to fire (I didn't like tapping the key)
Rotate left right with the [ and ] keys (or where they would have been if you have say a French keyboard) - or steer with cursor keys or WASD
P pauses
1 or Space starts a 1P game
2 starts a 2P game
ESC or command-q quits the game or app if in the ui
- and + (or =) will switch the game display between 320x240 and 640x480.
```

At 640x480 the game is too slow on my Centris 650.

Pressing the J key will supposedly scan for the next usable joystick, but I don't know if there were even any Mac joysticks? If there were, I don't support them. For now, this is a keyboard only game and pressing J will have no effect.

## VS Code
These files are in the .vscode folder, inside the TimePilot-Mac68k folder.
c_cpp_properties.json:
```
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/swessels/develop/external/github/Retro68-build/toolchain/universal/CIncludes/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4,
"enableConfigurationSquiggles": true
}
```
`/home/swessels/develop/external/github/Retro68-build/toolchain/universal/CIncludes/` is where I have Retro68 installed.

launch.json:
```
{
"version": "0.2.0",
"configurations": [
{
"name": "Basilisk II",
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceFolder}",
"program": "/mnt/c/Users/swessels/Games/Mac68k/BasiliskII/BasiliskII.exe",
"args": [],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Mini vMac",
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceFolder}",
"program": "/bin/sh",
"args": ["vMac.sh"],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
```
`/mnt/c/Users/swessels/Games/Mac68k/BasiliskII/BasiliskII.exe` Basilisk II on my Windows machine.

tasks.json:
```
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build and Run",
"type": "shell",
"command": "cd build;make -j",
"args": [],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true
},
"problemMatcher": [
"$gcc"
]
}
]
}
```
I use Unix Makefiles with cmake. Pretty standard CMakeLists.txt for Retro68.

## Thank you
1) [Retro68](https://github.com/autc04/Retro68)
2) [Tricks of the Mac Game Programming Gurus](https://vintageapple.org/macprogramming/pdf/Tricks_Of_The_Mac_Game_Programming__Gurus_1995.pdf)
3) https://dev.os9.ca/ - I don't know who owns this site, but it's great! Inside Macintosh was another indispensable resource, even though it's for Pascal and sometimes a bit confusing (to me). There's almost no quicker way to find something than a Google search with say `SndPlay site:https://dev.os9.ca/techpubs/mac/`

This was a lot of fun. I really wanted to make a 68K Mac game - I just wasn't expecting to do it now but once I saw Retro68, I couldn't stop myself!

Thank you
Stefan Wessels
14 August 2024
Binary file added TimePilot-Mac68k/audio/big_explosion.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/bomb.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/bossl0.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/bossl1.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/bossl2.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/bossl3.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/coindrop.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/enemy_explode.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/enemy_shoot.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/extra_life.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/game_start.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/highscore.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/next_level.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/pickup.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/player_shoot.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/rocket_fly.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/rocket_launch.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/timewarp.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/wapon_explode.wav
Binary file not shown.
Binary file added TimePilot-Mac68k/audio/wave_start.wav
Binary file not shown.
28 changes: 28 additions & 0 deletions TimePilot-Mac68k/misc/audio.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file describes the audio files and how they are to be converted
# for usei in Time Pilot on the 68K Mac

# The format is Name [loops]:[Hz]:[chanels]:[resID]
# defaults are loops 0, Hz 22050, chanels 2 (stereo vs 1 = mono), resID 128
# looping sounds are set to loop the entire sound - but this isn't implemented in my game code
# using a resID sets the counter to that value, and all subsequent files will count from that ID

audio/big_explosion.wav
audio/bomb.wav
audio/bossl0.wav
audio/bossl1.wav
audio/bossl2.wav
audio/bossl3.wav
audio/coindrop.wav
audio/enemy_explode.wav
audio/enemy_shoot.wav
audio/extra_life.wav
audio/game_start.wav
audio/highscore.wav
audio/next_level.wav
audio/pickup.wav
audio/player_shoot.wav
audio/rocket_fly.wav
audio/rocket_launch.wav
audio/timewarp.wav
audio/wapon_explode.wav
audio/wave_start.wav
54 changes: 54 additions & 0 deletions TimePilot-Mac68k/misc/convert.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

# python misc/resman.py -v -f -r 160 -i misc/convert.txt -p misc/palette.txt -o src/tpsprs.r -c src/tpsprsd.h

# Optional parameters:
# 0 - output_name
# 1 - background_color
# 2 - frame_width
# 3 - frame_height
# 4 - fixed_width
# 5 - offset_x
# 6 - offset_y
# 7 - pad_x
# 8 - pad_y
# 9 - scale

# Put the font first for resource number reasons
# adjust the -128 so this works: -r's 160 + -128 = 32 (space)
# the first font character is a space (?ID_LETTER_32)
png/font.png LETTER_%c(-128)::8:8:1:1:1:1:1:1

# The rest of the sprites follow
png/astro0.png
png/astro1.png
png/astro2.png
png/bomb.png ::2
png/boomerang.png ::8
png/cloud0.png
png/cloud1.png
png/cloud2.png
png/expl_bmrng.png ::4
png/expl_large.png ::4
png/expl_sblt.png ::4
png/expl_small.png ::4
png/expl_wepns.png ::4
png/l0enemy.png ::16
png/l1enemy.png ::16
png/l2enemy.png ::9
png/l3enemy.png ::16
png/l4enemy.png ::4
png/l0boss.png ::8
png/l1boss.png ::8
png/l2boss.png ::8
png/l3boss.png ::8
png/l4boss.png ::2
png/l1bomber.png ::8
png/number.png ::6
png/parachute.png ::4
png/player.png ::32
png/progress.png
png/rocket.png ::16
png/sbullet.png ::8
png/stage.png
png/timepilot.png
png/tpsmall.png
27 changes: 27 additions & 0 deletions TimePilot-Mac68k/misc/palette.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file contains the palette info for Time Pilot Apple Mack68k
# Each entry below is the image color followed by the
# palette index the game uses to render that color.

000000 0 # Black
F0F0F0 1 # White
F00000 2 # Red
00C0F0 3 # Cyan
C000C0 4 # Magenta
00C000 5 # Green
0050F0 6 # Blue
F0F000 7 # Yellow
F08000 8 # Orange
808080 9 # Gray (clouds)
800000 10 # Dark Red
608000 11 # Olive Green
0000A0 11 # Dark Blue (L4 Boss)
B0B000 12 # Dark Yellow
123400 13 # Prop 0 (sky or prop)
432100 14 # prop 1 (prop or sky)
000060 15 # SKY0
005060 16 # SKY1
006050 17 # SKY2
500050 18 # SKY3
# 000000 19 # SKY4 Repeat of Black so don't put in the palette

FFFFFF 255 # Font maps to all FF
Loading

0 comments on commit 42263ee

Please sign in to comment.