PC-G850 開発ツール
SHARP PC-G850 シリーズ(PC-G850 / PC-G850S / PC-G850V / PC-G850VS、CPU は Z80)の BASIC と機械語のプログラムを VS Code で作るための拡張機能です。エミュレータでは PC-G815、PC-G813、PC-G802、PC-E200 / E220 の ROM も動きます。
シャープ株式会社とは関係のない、個人が作った非公式のツールです。SHARP はシャープ株式会社の商標です。
English: see below.
| できること |
くわしい説明 |
ASM(Z80、g850asm と同じ文法)と BASIC の色分け、間違いの表示、候補、説明、定義へ移動 |
VS Code 拡張の使い方 |
| エミュレータで実行、デバッグ(ASM と BASIC。Windows) |
F5 で動かす |
z88dk の C(.c)のビルド、実行、デバッグ(C の行で止める、変数と構造体を見る。z88dk は別に入れる。Windows) |
C を VS Code で動かし、デバッグする |
本体の C(.c)の実行(TEXT と RAM ディスクに入れて G で動かす。#include "…" のファイルも。コンパイルの間違いを問題のビューに。IntelliSense 用のヘッダー。Windows) |
本体の C を VS Code で動かす |
本体の内蔵アセンブラ(ASMBL)の書式のソース(行番号付き。色分け、間違いの表示、F5。本体のアセンブラで TEXT から組んで動かすこともできる。Windows) |
本体のアセンブラのソースを扱う |
SDCC の sdasz80 の書式のソース(.s。打っているあいだの間違いの表示、F5 で sdasz80・sdldz80 で組んで動かす、行で止める、テスト。SDCC は別に入れる。Windows) |
SDCC の sdasz80 で書く |
*.g850test.json の自動テスト(Windows) |
テスト |
画面の絵 .lcd とキャラクタ .spr のドットエディタ |
テンプレートとドット絵 |
テンプレート、INCLUDE ファイル(g850.inc、hardware.inc、keycode.inc、screen.inc、sprite.inc、text.inc、screen_part.inc、pad.inc、game.inc、random.inc。PC-E200 / E220 用の e200.inc と *_e200.inc、PC-G815 用の g815.inc と *_g815.inc。e200.inc・g815.inc を INCLUDE すると、その機種の ROM で動く) |
INCLUDE ファイル、ゲームを作る |
| サンプル(講座の例、レシピ集、INCLUDE ファイルのデモ、PC-E200 / E220 と PC-G815 の例、BASIC。テスト付き) |
サンプル |
実機用の BIN と、実機で打つ MON・USER・CALL |
実機へ送る |
ターミナルと AI アシスタントから使うコマンド g850 |
コマンド g850 と AI |
全部の文書はツールの使い方の目次にあります。
必要なもの
| 使う機能 |
必要なもの |
| 編集、間違いの表示、ドットエディタ、テンプレート、「BIN を作成」 |
VS Code 1.95 以降だけ(Windows、Linux、macOS) |
| エミュレータでの実行、デバッグ、テスト |
Windows、.NET 10 のランタイム、PC-G850 エミュレータ(PokeComG850。デバッグ用の関数がある g850core.dll)、自分の本体から吸い出した ROM |
「アセンブル」(.asm) |
g850asm(pc-g850_tools の Assembler) |
| sdasz80 の書式のソースの組み立て |
SDCC(SDCC の sdasz80 で書く)。設定 pcG850.sdas.sdccPath、環境変数 G850_SDCC、PATH、Program Files の SDCC\bin の sdasz80 |
z88dk の C(.c)のビルド |
z88dk(z88dk の C を動かす)。設定 pcG850.c.zccPath か環境変数 G850_ZCC か PATH の zcc |
ROM、エミュレータ、z88dk、SDCC は、この拡張機能に入っていません。
はじめに
- コマンド 「PC-G850: 環境を確認」 で、エミュレータのフォルダを選びます(
g850core.dll と rom フォルダがあるフォルダ。編集だけなら不要)。
- フォルダを右クリック →「PC-G850」→「新しいプログラムを作成」→「BASIC から呼ぶルーチン」など。
F5 で動きます。
| 拡張子 |
扱い |
.asm .s .inc |
PC-G850 アセンブリ(g850asm と同じ文法、同じバイト列。全部の行に行番号があるか ; syntax: builtin と書いたソースは、本体の内蔵アセンブラの書式。.s と、.area などの sdasz80 の書き方のあるソースは、SDCC の sdasz80 の書式) |
.bas |
PC-G850 BASIC |
.c |
z88dk の C か本体の C(設定 pcG850.c.compiler。既定はソースから決める)。F5 で動かす。色分けなどは VS Code の C のもの |
.lcd .pixels .spr |
ドットエディタ |
*.g850test.json |
テスト |
設定
設定は次の 6 つの節に分かれています(この順に並びます)。場所の設定は、説明の頭に要るかどうかが書いてあります。
| 節 |
設定 |
内容 |
| エミュレータの場所 |
pcG850.emulatorPath |
エミュレータのフォルダ。g850core.dll と rom をここから探す。エミュレータで動かすのに要る(インストールしてあるか PATH にあれば空のまま) |
|
pcG850.romPath |
ROM ファイル(任意)。空なら pcG850.emulatorPath の rom から(PC-G850VS.ROM、PC-G850V.ROM、PC-G850S.ROM、PC-G850.ROM、なければ名前の順)。e200.inc・g815.inc を INCLUDE したアセンブリは、この ROM と同じフォルダとエミュレータの rom から、その機種の ROM を探す |
|
pcG850.corePath |
g850core.dll(任意)。空なら pcG850.emulatorPath から |
|
pcG850.serverPath |
デバッグサーバー g850dbg.exe(任意)。空なら拡張に入っているもの |
| 外部ツールの場所(使うときだけ) |
pcG850.asm.assemblerPath |
「アセンブル」で .asm を組む g850asm。空なら PATH から |
|
pcG850.c.zccPath |
z88dk の zcc。空なら環境変数 G850_ZCC、PATH から |
|
pcG850.sdas.sdccPath |
SDCC の bin のフォルダ。空なら環境変数 G850_SDCC、PATH、Program Files の SDCC\bin から |
| BASIC |
pcG850.basic.requireLineNumbers、pcG850.basic.checkMissingTargets |
行番号のない行、ない飛び先を報告する |
| アセンブリ |
pcG850.asm.includeDirectories、pcG850.asm.defines |
g850asm の -I、-D と同じ |
|
pcG850.asm.syntax |
ASM の書式。auto(ソースから決める)、builtin(本体の内蔵アセンブラ)、g850asm、sdas(SDCC の sdasz80) |
|
pcG850.sdas.linkOptions |
sdasz80 の書式のソースで sdldz80 に渡す区域の置き場所(既定は -b _CODE=0x100) |
|
pcG850.asm.assembler |
F5 とテストで組むもの。g850asm(PC で組んで書き込む)か builtin(ソースを TEXT に入れて本体のアセンブラで組む) |
| C |
pcG850.c.compiler |
.c のコンパイラ。auto(ソースから決める)、builtin(本体の C)、z88dk |
|
pcG850.c.options |
zcc に渡すオプション(既定は -clib=g850b、0200h から、-lm) |
| エミュレータ |
pcG850.speed、pcG850.openPanelOnDebug |
エミュレータの速さ(1 = 実機、2 = 2 倍、0 = 最高速)、デバッグでパネルを開く |
|
pcG850.appearance |
パネルの「本体」の表示で描く本体の外観(色と型番)。既定の auto は ROM から決める |
エミュレータのパネルの表示は、既定が「画面だけ」(液晶だけ)で、「本体」に切り替えると本体の絵とキーを出します。
信頼していないフォルダでは、そのフォルダの設定にある実行ファイルの場所(pcG850.emulatorPath、pcG850.romPath、pcG850.corePath、pcG850.serverPath、pcG850.asm.assemblerPath、pcG850.c.zccPath、pcG850.sdas.sdccPath)を使いません。
表示の言語
VS Code の表示言語が日本語なら日本語、それ以外は英語です。
開発
このフォルダで打ちます。
npm install
node node_modules/typescript/bin/tsc -p .
npm run build:server
node --test "out/test/**/*.test.js"
code .
| コマンド |
何をするか |
npm install |
作るのに要る部品を取ってくる(最初の 1 回) |
node node_modules/typescript/bin/tsc -p . |
コンパイルして out/ に出す(npm run compile と同じ) |
npm run build:server |
エミュレータを動かす g850dbg を out/server/ に作る(.NET 10 SDK が要る) |
node --test "out/test/**/*.test.js" |
テストを全部動かす。エミュレータと ROM がないと、それを使うテストは飛ばす |
code . |
このフォルダを VS Code で開く。F5 で開発用の VS Code が起動する |
npm run package |
VSIX を作る |
作りは設計: 拡張の全体、VS Code 拡張、デバッグサーバー、デバッガー、テスト、ビルド、配布にあります。
この拡張機能は、PC-E500 用の pc-e500-devtools を写して、PC-G850 シリーズ(Z80)向けに作り直したものです。
ライセンス
MIT です。エミュレータのコア g850core.dll は GPL-2.0-or-later の別のプログラム(PC-G850 エミュレータ PokeComG850)で、拡張機能には入っていません。デバッグサーバー g850dbg が実行するときに利用者のものを読み込みます。ドットエディタの文字入れの 5 × 7 ドットのフォントは SparkFun Electronics のもの(MIT)で、ThirdPartyNotices.txt に書いてあります。
English
Tools for writing BASIC and machine-code programs for the SHARP PC-G850 series (PC-G850, PC-G850S, PC-G850V, PC-G850VS; CPU Z80) in VS Code. The emulator also runs ROMs of the PC-G815, PC-G813, PC-G802 and PC-E200/E220. This is an unofficial tool made by an individual, not related to Sharp Corporation. SHARP is a trademark of Sharp Corporation.
- Editing: highlighting, errors as you type, completion and hover help for Z80 assembly (
.asm, same syntax and bytes as g850asm) and PC-G850 BASIC (.bas)
- Sources for the machine's built-in assembler (numbered lines, or
; syntax: builtin): the same bytes as the machine makes, and, if you like, assembled by the machine's own assembler from TEXT in the emulator, with its errors shown at their lines
- Running and debugging in the PC-G850 emulator (Windows): breakpoints, stepping, registers, flags, memory, disassembly for assembly; line breakpoints, stepping and variables for BASIC; C (
.c) built with z88dk's zcc (installed apart), with line breakpoints, stepping by lines of C, and variables, arrays and structs; C for the machine's built-in C compiler, put into TEXT (the files it #include "…"s onto the RAM disk) and run with the C menu's G, its compile errors shown at their file and line (run only), with a header for IntelliSense
- Tests (
*.g850test.json) in the Test Explorer
- Dot editors for screen pictures (
.lcd) and sprites (.spr), templates and INCLUDE files (also e200.inc and g815.inc for the PC-E200/E220 and PC-G815: a program that includes one runs on that machine's ROM)
- BIN files for the real machine, and the command
g850 (asm, dis, lint and bin on Windows, Linux and macOS; run and test on Windows)
Requirements: editing needs only VS Code 1.95 or later. Running, debugging and tests need Windows, the .NET 10 runtime, the PC-G850 emulator (PokeComG850, a g850core.dll with the debugger functions) and a ROM dumped from your own machine. Neither the ROM nor the emulator is included.
Run "PC-G850: Check the Setup" first. The user interface is in English unless VS Code is in Japanese. The documents are in Japanese.