Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 41 additions & 16 deletions ac6502/ac6502.cfg
Original file line number Diff line number Diff line change
@@ -1,27 +1,52 @@
# SPDX-FileCopyrightText: 2022-2026 Willis Blackburn
#
# SPDX-License-Identifier: MIT
#
# Linker configuration for VC83 BASIC as an ac6502 cartridge.
#
# Cartridge ROM overlays $C000-$FFFF. The BIOS Kernal jump table at
# $A000 and its implementation at $A100-$B7FF remain accessible, as
# does the character-set ROM at $B800-$BFFF. BASIC runs from ROM and
# uses RAM at $0800-$7FFF for its workspace (buffers, stacks, BSS) and
# the user program / variables / string heap.
#
# Zero page layout (per 6502-BIOS/BIOS.inc):
# $00-$03 System pointers (BIOS)
# $04-$23 Reserved by native BIOS BASIC (unused here)
# $24-$35 System scratch (CF, XFER, XModem, Monitor)
# $3A-$FF Free for user programs -> VC83 BASIC zero page lives here
#
# See https://github.com/acwright/6502 for more info

FEATURES {
STARTADDRESS: default = $0800;
}
SYMBOLS {
__STACKSIZE__: type = weak, value = $0000;
__ZPSTART__: type = weak, value = $003A;
__ZPSIZE__: type = weak, value = $00C6;
__RAM_START__: type = weak, value = $0800;
__HIMEM__: type = weak, value = $8000;
__ROM_START__: type = weak, value = $C000;
}
MEMORY {
ZEROPAGE: file = "", start = $0080, size = $0080;
MAIN: file = %O, start = %S, size = __HIMEM__ - %S, define = yes;
BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __ONCE_RUN__;
ZEROPAGE: file = "", start = __ZPSTART__, size = __ZPSIZE__;
MAIN: file = "", start = __RAM_START__, size = __HIMEM__ - __RAM_START__, define = yes;
# AT28C256 is 32 KB. The chip's lower half ($0000-$3FFF in the file)
# is filled with zeros; the upper half ($4000-$7FFF) carries the
# cartridge ROM that the CPU sees at $C000-$FFFF. PAD is the first
# region written to the output file so the linker emits zeros there.
PAD: file = %O, start = $8000, size = $4000, fill = yes, fillval = $00;
ROM: file = %O, start = __ROM_START__, size = $FFFA - __ROM_START__, fill = yes, fillval = $00;
VECTORS: file = %O, start = $FFFA, size = $0006, fill = yes, fillval = $00;
}
SEGMENTS {
ZEROPAGE: load = ZEROPAGE, type = zp;
STARTUP: load = MAIN, type = ro;
CODE: load = MAIN, type = ro;
VEC: load = MAIN, type = ro, define = yes;
XVEC: load = MAIN, type = ro, define = yes;
FUNC: load = MAIN, type = ro, define = yes;
XFUNC: load = MAIN, type = ro, define = yes;
PARSER: load = MAIN, type = ro;
ONCE: load = MAIN, type = ro, define = yes;
BSS: load = BSS, type = bss, define = yes;
ZEROPAGE: load = ZEROPAGE, type = zp;
STARTUP: load = ROM, type = ro;
CODE: load = ROM, type = ro;
VEC: load = ROM, type = ro, define = yes;
XVEC: load = ROM, type = ro, define = yes;
FUNC: load = ROM, type = ro, define = yes;
XFUNC: load = ROM, type = ro, define = yes;
PARSER: load = ROM, type = ro;
ONCE: load = ROM, type = ro, define = yes;
BSS: load = MAIN, type = bss, define = yes, align = $100;
VECTORS: load = VECTORS, type = ro;
}
94 changes: 87 additions & 7 deletions ac6502/ac6502.inc
Original file line number Diff line number Diff line change
@@ -1,13 +1,93 @@
; SPDX-FileCopyrightText: 2022-2026 Willis Blackburn
;
; SPDX-License-Identifier: MIT
;
; ac6502 target include -- symbolic names for BIOS Kernal routines and
; system variables used by VC83 BASIC. See 6502-BIOS/BIOS.inc for the
; full documentation of the Kernal jump table.
;
; See https://github.com/acwright/6502-BIOS for more info

BAS_LINBUF_SIZE = 240

CH_CTRLC = $03
CH_BEL = $07
CH_BKSP = $08
CH_LF = $0A
CH_CR = $0D
CH_ESC = $1B
CH_SPACE = $20
CH_DEL = $7F

; --- Zero-page system pointers (BIOS) ---
STR_PTR := $02 ; $02-$03 - BIOS string pointer

; --- BIOS Kernal jump table ($A000-$A0FF) ---
Chrout := $A000 ; Output character (routed by IO_MODE)
Chrin := $A003 ; Non-blocking input char (C=1 if available)
WriteBuffer := $A006
ReadBuffer := $A009
BufferSize := $A00C
SetIOMode := $A00F
GetIOMode := $A012
InitVideo := $A015
VideoClear := $A018
VideoPutChar := $A01B
VideoSetCursor := $A01E
VideoGetCursor := $A021
VideoScroll := $A024
VideoSetColor := $A027
VideoChroutRaw := $A02A
InitSID := $A02D
Beep := $A030
SidPlayNote := $A033
SidSilence := $A036
SidSetVolume := $A039
FsLoadFile := $A03C
FsSaveFile := $A03F
FsDeleteFile := $A042
InitKB := $A045
ReadJoystick1 := $A048
ReadJoystick2 := $A04B
InitSC := $A04E
SerialChrout := $A051
XModemLoad := $A054
XModemSave := $A057
RtcReadTime := $A05A
RtcReadDate := $A05D
RtcWriteTime := $A060
RtcWriteDate := $A063
RtcReadNVRAM := $A066
RtcWriteNVRAM := $A069
StReadSector := $A06C
StWriteSector := $A06F
StWaitReady := $A072
SysDelay := $A075
KernalInit := $A078 ; Initialize all hardware; caller resets SP, must CLI after
KernalVersion := $A07B

; --- System RAM variables used here ---
IRQ_PTR := $0300
BRK_PTR := $0302
NMI_PTR := $0304
IO_MODE := $0306
HW_PRESENT := $030D
BOOT_VECTOR := $035B

BAS_LINBUF_SIZE = 240
; Legacy aliases used by earlier ac6502 code.
CHROUT := Chrout
CHRIN := Chrin

CH_CR = $0D ; Carriage return
CH_LF = $0A ; Line feed
CH_SPACE = $20 ; Space
CH_BKSP = $08 ; Backspace
; --- HW_PRESENT bit masks ---
HW_RAM_L = %00000001
HW_RAM_H = %00000010
HW_RTC = %00000100
HW_CF = %00001000
HW_SC = %00010000
HW_GPIO = %00100000
HW_SID = %01000000
HW_VID = %10000000

CHROUT := $A000
CHRIN := $A003
; --- RTC / storage RAM variables used by kernal routines ---
RTC_BUF_CENT := $030B ; Century register for RTC read/write
RAM_BANK_L := $83FF ; Write-only bank latch for low RAM card
Loading
Loading