RetroDevDaemon / pc88-c

Standalone C-based framework for making games for the PC-8801 series of Japanese personal computers. (WIP)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PC88-C (0.1.5)

Overview

A very minimal framework for PC88 development using C.
src/pc88-c.h has all the good stuff.
Check out the src/lib/ folder for the detailed code. Everything should be laid bare.

For source code for the Linux port of xdisk2 check here:
https://github.com/bferguson3/xdisk3

Consider joining the RetroDev Discord to discuss, ask questions, and contribute:
https://discord.gg/Js3uUrc

To-Dos

-OPNA FM
-Joystick
-Saving files to disk
-Kanji ROM, nado (in -asm examples)
-Fix CRTC code
-Finalize M88 player

Documentation

Doxygen (0.1.3):
https://bferguson3.github.io/pc88-c/
(Tutorial, of out of date):
Manual part 1, overview: https://barelyconsciousgames.blogspot.com/2021/02/pc-88-c-framework-for-nec-pc8801.html
Manual part 2, basic drawing: https://barelyconsciousgames.blogspot.com/2021/02/pc88-c-frame-for-nec-pc-8801-part-2.html

What's new

0.1.5

  • Fixed ClearAttributeRam() not clearing all attributes
  • Added CLS() to clear text only
  • Clarified certain functions
  • Bugfixes for OPN channel 1-3 playback
  • Inter-VRAM copy functions (limited use)
  • Note: M88 player is using inaccurate tempo! (non-IRQ based)
  • Note: Check examples/rpj4 for use of new functions

0.1.4

  • Added CRT controls with SetMonitor() [bugged - careful!]
  • Added limited channel A,B,C M88 support
  • Added DrawImage_V2() and DrawTransparentImage_V2() methods
  • Changed Enable_ALU() and Disable_ALU() to require FASTMEM param
  • Various tweaks and fixes

Important: requires SDCC to be on the path

If you have SDCC 4.1.0 and Python3, you should be able to build without issue.
(Note the newest build of SDCC is not yet supported. Please use 4.1.0)
Recommended emulators:
M88x5 - Cycle accurate, excellent for debugging, slow (get from Illusion City, below)
XM8 - SDL2, fast, no debugging (http://retropc.net/pi/xm8/index.html)
Illusion City, huge tools list, recent M88 builds: https://illusioncity.net/nec-pc-88-series-emulators-tools-lists/
quasi88 - SDL1, builds on pretty much any nix (https://github.com/waitingmoon/quasi88/tree/master)
quasi88 - SDL2, for OSx (https://github.com/barbeque/quasi88-port)
When starting quasi88, use -debug to enable the Monitor option in the menu.
PC-8801 mkII FR BIOS (my own, content (C) NEC, right click + save) (http://barelyconsciousgames.com/pc8801mkiifr_bios.zip)

Brief overview:

Python dependencies for tools:

$ python3 -m pip install --upgrade Pillow
$ pip (or pip3) install numpy
$ pip (or pip3) install intelhex

Makefile - Creates app.d88 for use in an emulator.
Usage: make PROJECT=examples/1bitsprite USEDSEC=0x2f
Creates app.d88 in root of '1bitsprite' project and overrides the value of the initial number of sectors to copy in from the autoloader to 2Fh.
You can also do make IPL to recompile src/ipl.z80 and src/disk.z80.

ipl.bin is the autoloader.
In some ways it takes place of crt0. For me, src/crt0.c instead sets up the PC88-C environment. Notably, the putchr/print functions are probably quite clumsy since I haven't written them for a system before.
Important byte locations in IPL.BIN:
0x2F : Number of sectors loaded by autoloader (bytes / 256, default: 0x5F)
0x34-0x35 : Stack pointer location (Default: 00 01 (=$0100))
0x38-0x39 : Code start location (Default: 00 10 (=$1000))
(SDCC data is set to 0x0100~).
PC-8x usually has the stack on page 0 (0x0000 to 0x00ff).
The stack pointer is initially set in IPL.BIN to 0x0100.
disk.z80 is a disk I/O driver under 256 bytes.(!!)

maked88.py is a special tool (replaces D88SAVER.EXE) to make/add the files to
a 2D PC-88 disk image.
0 0 1 must be the IPL, 0 0 2 must be the the file to load into RAM.
I tried to make it as easy as possible to adjust memory addresses and load options.

The disk will auto boot!

A hello world minimal main.c looks like:

#include "pc88-c.h"

void main() { 
    print("Hello World!\x00");
    while(1) { }
}



A large amount of information is in pc88-c.h

On Pi4/00

Use the sdcc-compile-guide.txt to compile SDCC for your Pi.
If properly made/installed, the normal make command should work :)

Revision history

0.1.3

  • Added limited VGM player and YM conversion tool
  • Various tweaks and fixes

0.1.2

  • Added Disk BASIC support to the d88 tool, and static makefile.
    Example: $ make -f Makefile.n88 PROJECT=examples/helloworld-static
    Then, write the disk using xdisk, and on the PC88:
bload"2:main.bin
def usr1=&he123
a=usr1(0)

Where main.bin is the output file existing on disk drive 2,
and $e123 is the resultant address of _main(), taken from out/main.map.
Ensure that code, data and stack locations are properly set! Double check the makefile.

  • Refactored SSG player properly.

0.1.1
-Added minimal SSG support for MUCOM88 compiled files!
CURRENT SUPPORT:
Channels D, E, F (SSG) on octaves 2 through 6
Supported MML:

Tone and rest control (a-g, ., r, >, <)
o, t, v, [, ], P, w, #

Octave, tempo, volume, repeat, SSG mixer control, noise frequency, flag byte.
(Technically @ is supported but does nothing.)
To use the player, simply include the compiled song anywhere in code
and use the LoadSong() function to load the song data into predefined structs, then
PlaySong() every vertical blank to play it.

-Some small bugfixes and optimizations.

0.1.0
-Added clock-irq example
-Added bin2c.py (converts binary to .h)
-Added xbas.c
xbas.c should compile on pretty much any nix.
It allows you to transfer BASIC programs to PC-88 over USB-Serial.
Stay tuned for disk writing, ROM extraction, etc.!

0.0.14b
-Fixed SetCursorPos (wasn't updating ROWPOINTER)
-Added VERY BASIC math routines
-Added CMDFLAGS to the make for your own build flags.
e.g. make PROJECT=examples/hachinoid USEDSEC=0x49 CMDFLAGS=--cyclomatic
-Moved stack pointer back to 0x100 (doubled stack size)

0.0.14
-Fixed EraseVRAMArea - deleted old code fragments
-Still WIP Hachinoid example
-Added BEEP support
0.0.13b
-Added IPL target to makefile (make IPL). No longer requires ASW, compiles with SDCC.
-Updated png288.py. If you append -rle, /rle etc. it will RLE-encode the file with the following schema:

0x80 [X] [Y] : Duplicate [X] by [Y] times.
All other bytes : Copy through

-Added getsjis.py. Scans and prints a file for N88-BASIC kana.
-Added Sprite, XYPos structs to lib header
-WIP: Arkanoid clone example
0.0.12
-Made a real Makefile and removed the .bat/.sh files.
0.0.11
-Fixed maked88.py. Was not copying in the last byte of the file causing build issues.
-Various tweaks and fixes

About

Standalone C-based framework for making games for the PC-8801 series of Japanese personal computers. (WIP)


Languages

Language:C 75.2%Language:Python 20.3%Language:BASIC 1.3%Language:C++ 1.0%Language:Makefile 0.9%Language:Assembly 0.6%Language:Batchfile 0.3%Language:Shell 0.3%