Libgodc:为世嘉梦幻主机编写Go程序
Libgodc: Write Go Programs for Sega Dreamcast

原始链接: https://github.com/drpaneas/libgodc

## Go for Dreamcast: godc 概要 **godc** 将 Go 编程语言带到 Sega Dreamcast,无需操作系统,直接在主机的有限硬件(16MB RAM,单核 SH-4 CPU)上运行。它提供了一个定制的 Go 运行时,包括垃圾回收、协程和通道。 要开始,您需要 Go 1.25.3+、make 和 git,然后安装单独的 **godc** CLI 工具进行设置和构建。项目使用 `godc init` 初始化,使用 `godc build` 构建,并使用 `godc run` 直接在 Dreamcast 上运行。 在真机上的性能测量显示,Go 核心功能的运行速度出乎意料地快。提供各种示例,从简单的“Hello World”程序到 Breakout 克隆,展示了图形、输入、并发和 VMU 交互。 该项目是开源的,采用 BSD 3-Clause 许可证。开发者可以获取完整的文档和快速入门指南。

## 在世嘉梦幻主机上使用 Go:Libgodc 开发者 drpaneas 创建了 “libgodc”,一个 Go 运行时,使开发者能够为世嘉梦幻主机编写程序,包括游戏。考虑到该主机的硬件限制——16MB 内存,200MHz 单核 CPU,以及没有操作系统,这非常了不起。 该项目使用 `gccgo` 将 Go 代码编译为适用于梦幻主机,保留了协程、通道和垃圾回收等特性。Drpaneas 提供了三个游戏示例(Pong、Breakout、平台跳跃游戏),以及输入和音频支持,并与 KallistiOS 自制 SDK 集成。 该项目文档完善,因其全面的 readme 和“书籍式”文档而备受赞誉,能够预见并解答许多潜在问题。GitHub 仓库、文档和视频教程等资源可通过提供的链接获取。
相关文章

原文

libgodc

Pong Breakout Platformer

Replaces the standard Go runtime with one designed for the Dreamcast's constraints: memory 16MB RAM, CPU single-core SH-4, no operating system. Provides garbage collection, goroutines, channels, and the core runtime functions.

Prerequisites: Go 1.25.3+, make, and git must be installed.

go install github.com/drpaneas/godc@latest
godc setup
godc doctor # to check (optional)

Note: The godc CLI tool is a separate project that handles toolchain setup and builds.

Create and run a project:

mkdir myproject && cd myproject
godc init
# write you main.go and other *.go files
godc build
godc run

See the Quick Start Guide for your first program.

📚 Full Documentation

Measured on real hardware (SH-4 @ 200MHz):

Operation Time
Gosched yield ~120 ns
Allocation ~186 ns
Buffered channel ~1.8 μs
Context switch ~6.4 μs
Unbuffered channel ~13 μs
Goroutine spawn ~31 μs
GC pause 72 μs - 6 ms

The examples/ directory contains working programs:

  • hello — Minimal program (debug output)
  • hello_screen — Hello World on screen using BIOS font
  • blue_screen — Minimal graphics
  • input — Controller input
  • goroutines — Concurrent bouncing balls
  • channels — Producer/consumer pattern
  • timer — Frame-rate independent animation
  • bfont — BIOS font rendering
  • filesystem — Directory browser
  • vmu — VMU LCD and buzzer
  • brkout — Breakout clone (GPL v2, port of Jim Ursetto's original)
  • pong — Pong clone with 1P/2P mode, particle effects, and AI

BSD 3-Clause License. See LICENSE for details.

联系我们 contact @ memedata.com