Kernal Jump Table

A.C. Wright 6502 BIOS
Kernal · BIOS v1.5
The contract
Call the slot, never the implementation. 53 entry points, three bytes each, starting at $A000 and in an order that does not change. jsr $A000 prints a character on this ROM and on the next one. 6502.inc gives every slot its name, so you will write jsr Chrout.
Arguments go in registers. A, X and Y in, A, X, Y or the carry flag out. Nothing is passed on the stack.
The tail of the table. 32 slots from $A09F to $A0FE are reserved. Each is a real jump to a bare RTS, so calling one is harmless now and may do something later. Do not put your own code there.
Console
AddrNameIn / out
$A000ChroutOutput char (dispatched by IO_MODE)
in A = character to output
$A003ChrinInput char from buffer
$A090PrintStrPrint NUL-terminated string (A=lo, Y=hi); clobbers A,Y,STR_PTR
in A = string address low, Y = string address high · out A, Y clobbered; X preserved; clobbers STR_PTR (Chrout preserves it)
$A093PrintCRLFPrint CR+LF
$A096PrintDecU16Print unsigned 16-bit decimal (A=lo, X=hi), no leading zeros
in A = value low, X = value high
$A006WriteBufferWrite byte to input buffer
$A009ReadBufferRead byte from input buffer
$A00CBufferSizeGet buffer count
$A00FSetIOModeSet IO_MODE
in A = mode (bit 0: 0=video, 1=serial)
$A012GetIOModeGet IO_MODE
out A = current IO_MODE
The screen
AddrNameIn / out
$A015InitVideoInitialize TMS9918 (mode registers + character set)
$A018VideoClearClear video screen
$A01BVideoPutCharWrite char at cursor
in A = character to write
$A02AVideoChroutRawOutput char to video (raw, no control-code handling)
in A = character code (0-255)
$A01EVideoSetCursorSet cursor (X=col, Y=row)
in X = column (0-39), Y = row (0-23)
$A021VideoGetCursorGet cursor position
out X = column (0-39), Y = row (0-23)
$A024VideoScrollScroll screen up one line
$A027VideoSetColorSet TMS9918 text color (A=reg7 byte: hi=fg, lo=bg)
in A = color byte (high nibble = fg color, low nibble = bg color)
Sound
AddrNameIn / out
$A02DInitSIDInitialize SID
$A030BeepPlay beep tone
$A033SidPlayNotePlay note (A=voice, X=freqLo, Y=freqHi)
in A = voice (0-2), X = frequency low byte, Y = frequency high byte
$A036SidSilenceSilence all voices
$A039SidSetVolumeSet SID master volume (A=0-15)
in A = volume (0-15); upper nibble of SID_MODE_VOL is cleared (no filter)
Keyboard and sticks
AddrNameIn / out
$A045InitKBInitialize GPIO/VIA keyboard
$A048ReadJoystick1Read joystick 1
out A = joystick bitmask (active-low bits: R-L-D-U-Y-X-B-A)
$A04BReadJoystick2Read joystick 2
out A = joystick bitmask (active-low bits: R-L-D-U-Y-X-B-A)
$A099KBDisableRelease both encoders and settle; ports free for raw read
$A09CKBEnableRe-enable both encoders

Kernal Jump Table

A.C. Wright 6502 BIOS
Kernal · BIOS v1.5
Files
AddrNameIn / out
$A07EFsLoadFileAddrLoad named file to FS_IO_ADDR
in STR_PTR = filename, FS_IO_ADDR = destination address
$A081FsSaveFileAddrSave FS_FILE_SIZE bytes from FS_IO_ADDR to named file
in STR_PTR = filename, FS_IO_ADDR = source address, FS_FILE_SIZE = byte count
$A03CFsLoadFileLoad file from CF
in STR_PTR ($02-$03) points to null-terminated filename · out Carry clear = success, FS_FILE_SIZE = bytes loaded; Carry set = file not found or read error
$A03FFsSaveFileSave file to CF
in STR_PTR ($02-$03) points to null-terminated filename; FS_FILE_SIZE ($034A-$034B) = number of bytes to save · out Carry clear = success, Carry set = error (directory full or write error)
$A042FsDeleteFileDelete file from CF
in STR_PTR ($02-$03) points to null-terminated filename · out Carry clear = success, Carry set = file not found or error
$A084FsFormatDiskZero the current disk's directory sector
out Carry clear = success, Carry set = write error
$A087FsSetDiskSelect current CF disk (A=0-255)
in A = disk number (0-255)
$A08AFsGetDiskGet current CF disk (A=disk)
out A = current disk number
$A08DFsPrintDiskPrint "DISK n" + CRLF via Chrout
The card itself
AddrNameIn / out
$A06CStReadSectorRead CF sector
in CF_LBA ($26-$29) = LBA address, CF_BUF_PTR ($24-$25) = destination pointer · out Carry clear = success, Carry set = error; CF_BUF_PTR advanced by 512 bytes on success
$A06FStWriteSectorWrite CF sector
in CF_LBA ($26-$29) = LBA address, CF_BUF_PTR ($24-$25) = source pointer · out Carry clear = success, Carry set = error; CF_BUF_PTR advanced by 512 bytes on success
$A072StWaitReadyWait CF ready
out Carry clear = ready, Carry set = error or timeout
Serial
AddrNameIn / out
$A04EInitSCInitialize serial 6551
$A051SerialChroutDirect serial output (bypass IO_MODE)
$A054XModemLoadReceive binary via XModem
in XFER_PTR = destination address (set by caller) · out Carry clear = success, XFER_PTR past last byte written; XFER_REMAIN = total bytes received; Carry set = transfer failed
$A057XModemSaveSend binary via XModem
in XFER_PTR = source address, XFER_REMAIN = byte count (set by caller) · out Carry clear = success, Carry set = transfer failed
Clock and lasting memory
AddrNameIn / out
$A05ARtcReadTimeRead RTC time
out A = hours (binary), X = minutes (binary), Y = seconds (binary)
$A05DRtcReadDateRead RTC date
out A = day of month (binary), X = month (binary), Y = year (binary); RTC_BUF_CENT = century (binary)
$A060RtcWriteTimeSet RTC time
in A = hours (binary), X = minutes (binary), Y = seconds (binary)
$A063RtcWriteDateSet RTC date
in A = day of month (binary), X = month (binary), Y = year (binary); RTC_BUF_CENT = century (binary)
$A066RtcReadNVRAMRead NVRAM byte
in X = NVRAM address ($00-$FF) · out A = data byte
$A069RtcWriteNVRAMWrite NVRAM byte
in X = NVRAM address ($00-$FF), A = data byte
The machine
AddrNameIn / out
$A075SysDelayDelay A=cnt_lo, X=cnt_hi centiseconds
in A = count low byte, X = count high byte
$A078KernalInitInitialize all hardware (caller must reset SP; no cli, no splash); rts when done
$A07BKernalVersionGet BIOS version (A=major, X=minor)
out A = major version, X = minor version