Skip to content
4am edited this page Jul 10, 2020 · 11 revisions

The game port libraries are used when connecting an Arduino to the game port connector with this setup:

Apple II, meet Arduino

Arduino Apple Slave


Low Level SPI Port

The connection is made by bit-banging an SPI like protocol between the Apple II and Arduino. The SPI protocol as managed through the SPI Low Level interface. Accessed via:

Compatibility: II

Usage: include "inc/spiport.plh"

Values:

const SPI_SLAVE_READY = '@'
const SPI_SLAVE_ERROR = '!'
const SPI_SLAVE_BUSY  = $FF

Functions:

spiXferByte(outbyte)
spiSend(data)
spiRecv()
spiWriteBuf(buf, len)
spiReadBuf(buf, len)
spiDelay(time)
spiReady()

Source Code: spiport.pla

Sample Source: sdfat.pla


Wiring Library

A wiring style library allows for controlling the I/O pins on the Arduino. Accessed via:

Compatibility: II

Usage: include "inc/spiport.plh"

Values:

//
// Wiring constants for Arduino
//
const PINHIGH   = 1
const PINLOW    = 0
const PINOUTPUT = 1
const PININPUT  = 0
const PINPULLUP = 2
//
// SPI commands to Wiring functions on Arduino
//
const CMDPINMODE  = 3
const CMDDIGREAD  = 4
const CMDDIGWRITE = 5
const CMDANAREAD  = 6
const CMDANAWRITE = 7
//
// SPI commands to serial functions on Arduino
//
const CMDSERMODE  = 8
const CMDSERAVAIL = 9
const CMDSERREAD  = 10
const CMDSERWRITE = 11

SD Card FAT Filesystem Access

If the Arduino has an SD card shield attached, the FAT filesystem can be accessed from the Apple II through the SD Fat Library. Accessed via:

Compatibility: II

Usage: include "inc/sdfat.plh"

Values:

//
// Open flags
//
const O_READ   = $01
const O_WRITE  = $02
const O_APPEND = $04
const O_SYNC   = $08
const O_TRUNC  = $10
const O_AT_END = $20
const O_CREAT  = $40
const O_EXCL   = $80
const MAX_FAT_BUF_SIZE = 512

API:

sdFAT:getDir
sdFAT:setDir
sdFAT:newDir
sdFAT:removeDir
sdFAT:renameFile
sdFAT:removeFile
sdFAT:existsFile
sdFAT:openFirstFile
sdFAT:openNextFile
sdFAT:openFile
sdFAT:closeFile
sdFAT:readFile
sdFAT:writeFile
sdFAT:syncFile
sdFAT:rewindFile
sdFAT:seekFile
sdFAT:seekOffsetFile
sdFAT:posFile
sdFAT:sizeOfFile
sdFAT:truncateFile
sdFAT:isDir
sdFAT:isFile

Source Code: sdfat.pla

Sample Source: fatcat.pla, fatget.pla, fatput.pla, fatreaddsk.pla, fatwritedsk.pla

Clone this wiki locally