ewrogers/sgdk-skills

sgdk-math

Choose and verify SGDK fixed-point math for movement, angles, aiming, interpolation, distance checks and perspective effects.

ソースを見る

使い方

  1. インストールコマンドをコピーし、自分の環境へ導入する前にソースを確認します。
  2. 必要なツール、認証情報、対応環境を原文で確認します。
  3. 入力と成果物を指定し、出力を資料と照合します。
npx skills add https://github.com/ewrogers/sgdk-skills --skill sgdk-math

開始前の確認

  • 導入にはモデル契約、API枠、ファイルへのアクセス許可は含まれません。
  • スター数や導入数は活動の指標であり、独立した品質・安全性試験ではありません。
リポジトリの原文

見出し、例、コード、表、リンク、参照画像を含む原文を表示しています。

SGDK Math

Choose the coordinate range, smallest useful fraction and largest intermediate before choosing a type. A wider storage type does not automatically mean a more accurate or safer multiply/divide implementation.

Choose the right reference

conversions, rounding, overflow and multiply/divide limits.

diagonal movement, squared distances, interpolation and bounded tables.

  • Math Lab: a runnable perspective starfield and

orbit/figure-eight/spiral formations, with controls and a playtest checklist.

Use ewrogers/sgdk:latest and check its inc/maths.h, inc/types.h and src/maths.c before using an unfamiliar helper. These references were checked against SGDK 2.11. In particular, current F16_sin/F16_cos take degrees; deprecated sinFix16 uses a different angle convention.

Make the calculation safe

Keep world positions separate from screen coordinates. Prefer fix32 or integer world positions when a level exceeds fix16's range. Use small fix16 offsets and velocities where they fit. Convert at explicit boundaries; do not cast between fixed-point formats as though their scales were identical.

Widen before subtracting or multiplying. Establish a valid divisor and bound the quotient before division. Avoid signed overflow, shifting negative signed values in your own C and assuming that a wrapped result will be useful. SGDK's helpers have implementation-specific limits too; follow the reference rather than replacing them with floating point or an untested fast-math trick.

For a new effect, test known points, negative inputs, near-zero divisors, maximum supported coordinates and a full angle cycle. Compare with an independent higher-precision oracle within a stated tolerance. Execute the actual target SDK routines when host arithmetic cannot establish their behavior.

Keep repeated work small

Cache a shared sine or reciprocal table when the memory tradeoff is worthwhile. Bound the angle/depth index before looking it up. Prefer squared-distance tests to square roots when only a threshold matters. Do not replace an exact hit test with SGDK's approximate distance without allowing for its error.

Use a consistent simulation clock and cache input once per display frame. Separate simulation coordinates from rendering so a PAL display or a missed frame does not silently change the units of velocity. Measure optimized ROMs; a successful build or smooth host animation does not establish a 68000 budget.

タスクに関連する項目

同じリポジトリから

関連する Skills

すべての Skills
ewrogers
コミュニティ

sgdk-ai

Implement enemy behavior in SGDK games with patrol/chase/attack states, sight cones, target selection, bounded pathfinding and staggered updates. Use when enemies see through walls, get stuck, switch targets erratically, return stale paths or cause frame spikes while searching.

導入数
1
GitHub Stars
0
更新日
10月20日
ewrogers
コミュニティ

sgdk-assets

Prepare, import and troubleshoot Mega Drive graphics, palettes, spritesheets, tiles, maps, fonts and audio resources with SGDK ResComp in Docker. Use for .res files, palette or tile budgets, broken imports, sprite cutting and asset pipeline changes.

導入数
1
GitHub Stars
0
更新日
10月20日
ewrogers
コミュニティ

sgdk-best-practices

Write or review SGDK C for defined arithmetic, clear module boundaries, resource lifetimes, safe queued transfers and interrupt sharing. Use for implementation quality and project code organization, rather than toolchain setup, game design or performance profiling alone.

導入数
1
GitHub Stars
0
更新日
10月20日
ewrogers
コミュニティ

sgdk-cartridge

Plan and implement large SGDK cartridges with Sega/SSF bank switching, FAR resources, pinned shared code and audio, and safe SRAM access. Use when a ROM exceeds the linear address window, stage assets live in separate banks, a FAR pointer becomes invalid, or saving interferes with banked content.

導入数
1
GitHub Stars
0
更新日
10月20日