Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e8fd27d
Factor out asm object configs into .inc files to improve cohesion for…
avolkov76 Mar 22, 2025
a89e0ac
gcc warnings -1; -Wno-misleading-indentation for miniz
avolkov76 Mar 23, 2025
6e4e2ba
* diskload2 refactoring, prep for experimental hacks and further work…
avolkov76 Mar 23, 2025
0a0bbe6
DOS refactor phase 0: remove DOS page 3 vectors; not needed.
avolkov76 Mar 24, 2025
381a9e0
makeheader refactor: reusable .mon to .h conversion; sed instead of p…
avolkov76 Mar 24, 2025
2960b72
DOS refactor phase 1: add DOS 3.3 stripped down to RWTS
avolkov76 Mar 24, 2025
8253e57
Simulation address comment correction
avolkov76 Mar 24, 2025
28b2e4e
FIX: correctly handle the checksum edge case in fastload8000/diskload…
avolkov76 Mar 26, 2025
9bf16e3
Merge remote-tracking branch 'origin/fix-1' into dos-hack-1
avolkov76 Mar 27, 2025
13355c3
FIX: .wav files produced on Windows undergo CR LF conversions. Window…
avolkov76 Mar 27, 2025
b235293
Merge remote-tracking branch 'origin/fix-1' into dos-hack-1
avolkov76 Mar 29, 2025
8b80d97
Automatic asm .inc object config conversions to C .h; to be used in c…
avolkov76 Mar 29, 2025
d0a87ef
Missed fastload.inc in asm object config auto-conversion
avolkov76 Mar 30, 2025
c60ae9d
Unhardcode more asm object symbols and locations
avolkov76 Mar 30, 2025
1b50c81
Unhardcode many of the asm object locations in c2t.c, using the #defi…
avolkov76 Mar 30, 2025
ecd118c
Add some sanity checks to detect and alert of simulation-breaking asm…
avolkov76 Mar 30, 2025
fa94ac2
Switch to DOS 3.3 RWTS rip:
avolkov76 Mar 30, 2025
2a640fc
Add missed asm .inc
avolkov76 Mar 30, 2025
5d54cb8
Form sed command pipeline in incheader() in a compatible way
avolkov76 Mar 31, 2025
7ba3520
Fix makeheader to work with BSD sed Also fix Makefile to make the cc6…
majick Mar 31, 2025
71f86ae
Merged makeheader POSIX sed fixes with tweaks (PR2 from majick)
avolkov76 Apr 1, 2025
ea5ab0c
Minimal .gitignore change
majick Apr 1, 2025
58e2307
Merged .gitignore with prior PR4 (from majick) and additional exclusions
avolkov76 Apr 2, 2025
4a43222
Remove non-platform specific built binaries from repo (no way of tell…
avolkov76 Apr 2, 2025
a684e9c
makeheader oops: do not append to c2t.h.[23]; overwrite every time
avolkov76 Apr 2, 2025
e106da6
Auto-detect the Disk II controller (or compatible) slot using the IIe…
avolkov76 Apr 2, 2025
8a2ca3b
BUGFIX: Shift diskload3 inflate data down 1 page because diskload2 sh…
avolkov76 Apr 3, 2025
c920aac
Customizable, table-driven Disk II detection slot scan order;
avolkov76 Apr 3, 2025
3ec3f0d
Factor out a common RWTS call sequence and save some grief (and some …
avolkov76 Apr 5, 2025
ab78cd6
BUGFIX: Misdefined DOS symbol (drive 1 current track table) can cause…
avolkov76 Apr 6, 2025
b304d44
Another misdefined DOS symbol, copy-paste oops; does not currently af…
avolkov76 Apr 6, 2025
c9eea82
FIX: calculate diskload2 object padding size correctly; possibility e…
avolkov76 Apr 9, 2025
3da7974
DOS refactoring, Phase 2: format tracks while writing data at the sam…
avolkov76 Apr 9, 2025
dc5f1cc
FIX: calculate DOS end location correctly in diskload (+1 for checksu…
avolkov76 May 14, 2025
e7e579c
FIX: correct Makefile c2t.h .mon dependency
avolkov76 May 17, 2025
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
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Assembly build artifacts
asm/**
!asm/*.s
!asm/*.inc
!asm/Makefile

# Generated at build time but being kept upstream
# c2t.h
# Ephemeral build artifacts (when makeheader barfs)
c2t.h.[123]

# Linux/BSD/*nix built binaries without platform identifiers
bin/**
# but keep Windows binaries checked-in (at least for now)
# TODO: use releases instead of this?
!bin/*.exe

# Annoying macOS Finder state detritus
.DS_Store

# Visual Studio Code workspace, settings
.vscode

# Installed at build time, not a distributed artifact
cc65*
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

WIN32GCC = /usr/local/local.x86_64/gcc-4.8.0-qt-4.8.4-for-mingw32/win32-gcc/bin/i586-mingw32-gcc
CCWARN = -Wall -Wno-strict-aliasing -Wno-unused-value -Wno-unused-function -Wno-misleading-indentation

all: nix

Expand All @@ -20,30 +21,30 @@ clean: testclean

# nix
bin/c2t: c2t.c c2t.h
$(CC) -Wall -Wno-strict-aliasing -Wno-unused-value -Wno-unused-function -I. -O3 -o bin/c2t c2t.c -lm
$(CC) $(CCWARN) -I. -O3 -o bin/c2t c2t.c -lm

bin/c2t-96h: c2t-96h.c c2t.h
$(CC) -Wall -Wno-strict-aliasing -Wno-unused-value -Wno-unused-function -I. -O3 -o bin/c2t-96h c2t-96h.c -lm
$(CC) $(CCWARN) -I. -O3 -o bin/c2t-96h c2t-96h.c -lm

# macos universal
bin/c2t_x86: c2t.c c2t.h
$(CC) -Wall -Wno-strict-aliasing -Wno-unused-value -Wno-unused-function -I. -O3 -target x86_64-apple-macos10.12 -o $@ c2t.c -lm
$(CC) $(CCWARN) -I. -O3 -target x86_64-apple-macos10.12 -o $@ c2t.c -lm

bin/c2t-96h_x86: c2t-96h.c c2t.h
$(CC) -Wall -Wno-strict-aliasing -Wno-unused-value -Wno-unused-function -I. -O3 -target x86_64-apple-macos10.12 -o $@ c2t-96h.c -lm
$(CC) $(CCWARN) -I. -O3 -target x86_64-apple-macos10.12 -o $@ c2t-96h.c -lm

bin/c2t_arm: c2t.c c2t.h
$(CC) -Wall -Wno-strict-aliasing -Wno-unused-value -Wno-unused-function -I. -O3 -target arm64-apple-macos11 -o $@ c2t.c -lm
$(CC) $(CCWARN) -I. -O3 -target arm64-apple-macos11 -o $@ c2t.c -lm

bin/c2t-96h_arm: c2t-96h.c c2t.h
$(CC) -Wall -Wno-strict-aliasing -Wno-unused-value -Wno-unused-function -I. -O3 -target arm64-apple-macos11 -o $@ c2t-96h.c -lm
$(CC) $(CCWARN) -I. -O3 -target arm64-apple-macos11 -o $@ c2t-96h.c -lm

# windows
bin/c2t.exe: c2t.c c2t.h
$(WIN32GCC) -Wall -Wno-strict-aliasing -Wno-unused-value -Wno-unused-function -I. -O3 -o bin/c2t.exe c2t.c
$(WIN32GCC) $(CCWARN) -I. -O3 -o bin/c2t.exe c2t.c

bin/c2t-96h.exe: c2t-96h.c c2t.h
$(WIN32GCC) -Wall -Wno-strict-aliasing -Wno-unused-value -Wno-unused-function -I. -O3 -o bin/c2t-96h.exe c2t-96h.c
$(WIN32GCC) $(CCWARN) -I. -O3 -o bin/c2t-96h.exe c2t-96h.c

cc65-sources-2.13.3.tar.bz2:
curl -sLO https://github.com/mrdudz/cc65-old/raw/master/cc65-sources-2.13.3.tar.bz2
Expand All @@ -52,7 +53,7 @@ cc65-2.13.3/bin/cl65: cc65-sources-2.13.3.tar.bz2
bunzip2 -c cc65-sources-2.13.3.tar.bz2 | tar xf -
(cd cc65-2.13.3; /usr/bin/sed 's!/usr/local!'${PWD}'/cc65-2.13.3!' <make/gcc.mak >Makefile; make -j4 bins || make bins && make install || true)

c2t.h: c2t.h.0 makeheader mon/dos33.boot1.mon mon/dos33.boot2.mon asm/autoload.s asm/diskload2.s asm/diskload3.s asm/diskload8000.s asm/diskload9600.s asm/fastload8000.s asm/fastload9600.s asm/fastloadcd.s asm/inflate.s cc65-2.13.3/bin/cl65
c2t.h: c2t.h.0 makeheader mon/dos33.rwts.mon asm/*.inc asm/autoload.s asm/diskload2.s asm/diskload3.s asm/diskload8000.s asm/diskload9600.s asm/fastload8000.s asm/fastload9600.s asm/fastloadcd.s asm/inflate.s cc65-2.13.3/bin/cl65
./makeheader

test: bin/c2t-96h bin/c2t-96h.exe tests/test.md
Expand Down
3 changes: 2 additions & 1 deletion asm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CL = cl65
CL_FLAGS = -t none --listing --list-bytes 100

ASRC = $(shell echo *.s)
AINC = $(wildcard *.inc)
AOBJ = $(ASRC:%.s=%.o)
ALST = $(ASRC:%.s=%.lst)
AMON = $(ASRC:%.s=%.mon)
Expand All @@ -12,5 +13,5 @@ all: $(ABIN)
clean:
-rm -f $(ABIN) $(AOBJ) $(ALST) $(AMON)

%: %.s
%: %.s $(AINC)
$(CL) $(CL_FLAGS) $<
47 changes: 47 additions & 0 deletions asm/apple2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
; apple2.inc
; Apple II Monitor entry points, ZP locations, and I/O

; ZP Monitor vars
CH := $24 ; Cursor horizontal position
CV := $25 ; Cursor vertical position
BASL := $28 ; Text base address low
BASH := $29 ; Text base address high
INVFLG := $32 ; Normal/inverse(/flash)
PROMPT := $33 ; Used by GETLN
CSW := $36 ; Character out soft-link
KSW := $38 ; Keyboard in soft-link
ACC := $45 ; Monitor BRK A register save location
XREG := $46 ; Monitor BRK X register save location
YREG := $47 ; Monitor BRK Y register save location
STATUS := $48 ; Monitor BRK MPU status (P) register save location
SPNT := $49 ; Monitor BRK stack pointer (S) register save location

; Page 3 stuff
BRKV := $03F0 ; Break (BRK) vector
SOFTEV := $03F2 ; Vector for warm start
PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1
AMPERV := $03F5 ; Thunk vector for & commands
USRADR := $03F8 ; Thunk vector for Monitor user commands
NMI := $03FB ; NMI handler thunk
IRQLOC := $03FE ; IRQ handler vector

; I/O addresses
IOBASE := $C000 ; base of all I/O
TAPEIN := $C060 ; read tape interface

; Monitor routines
COUT := $FDED ; character out sub
CROUT := $FD8E ; CR out sub
CLREOP := $FC42 ; clear to end of screen
CR := $FC58 ; clear screen
TABV := $FB5B ; move cursor to ch,a
PRBYTE := $FDDA ; print a byte in hex

RESET := $FA62 ; reset Mon routine
PWRUP := $FAA6 ; cold-start reset routine
BELL1 := $FBD9 ; ding
BELL2 := $FBDD ; ding
RDKEY := $FD0C ; read key
READ := $FEFD ; read a block from tape
MON := $FF65 ; Monitor EP with a bell
MONZ := $FF69 ; Monitor EP w/o a bell
4 changes: 4 additions & 0 deletions asm/autoload.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
; autoload.inc
; Autoload bootstrapper object config

autoload_org = $BF00 ; origin, should be $BF00 for now
33 changes: 18 additions & 15 deletions asm/autoload.s
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
;autoload.s

org = $BF00 ; should be $BF00
cout = $FDED ; character out sub
crout = $FD8E ; CR out sub
prbyte = $FDDA
warm = $FF69 ; back to monitor
readblk = $FEFD
.include "apple2.inc"
.include "inflate.inc"
.include "autoload.inc"

cout = COUT ; character out sub
crout = CROUT ; CR out sub
prbyte = PRBYTE ; print byte in hex
warm = MONZ ; back to monitor
readblk = READ ; read a block from tape

pointer = $06
endbas = $80C
;target = $1000
target = $801
chksum = $00
inflate = $BA00
inf_zp = $0
;inf_zp = $0 ; see inflate.inc

start:
.org endbas
Expand All @@ -24,7 +27,7 @@ move1: lda moved,x
bne move1 ; move 256 bytes
jmp load
moved:
.org org
.org autoload_org
load:
lda #<loadm
ldy #>loadm
Expand All @@ -49,21 +52,21 @@ inf:
jsr print

lda inf_src ;src lsb
sta inf_zp+0
sta inflate_zp+0
lda inf_src+1 ;src msb
sta inf_zp+1
sta inflate_zp+1
lda inf_dst ;dst lsb
sta inf_zp+2
sta inflate_zp+2
lda inf_dst+1 ;dst msb
sta inf_zp+3
sta inflate_zp+3

jsr inflate

lda inf_end ;dst end +1 lsb
cmp inf_zp+2
cmp inflate_zp+2
bne error
lda inf_end+1 ;dst end +1 msb
cmp inf_zp+3
cmp inflate_zp+3
bne error
runit:
lda warm_flag ; if warm_flag = 1 warm boot
Expand Down
23 changes: 23 additions & 0 deletions asm/disk2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; disk2.inc
; Disk II controller and drive I/O

; $C080 - C087 are the 4 stepper phases
phase0clr := $C080
phase0set := $C081
phase1clr := $C082
phase1set := $C083
phase2clr := $C084
phase2set := $C085
phase3clr := $C086
phase3set := $C087

motoroff := $C088 ; Turn drive motor off
motoron := $C089 ; Turn drive motor on
drv1sel := $C08A ; Select drive 1
drv2sel := $C08B ; Select drive 2
sequencer := $C08C ; Activate sequencer
rdshifter := $C08C ; Read shifter
wrshifter := $C08D ; Load shifter for write
wrprot := $C08E ; Read write-protected status
rdmode := $C08E ; Set read mode / sequencer to idle
wrreq := $C08F ; Set write mode / load shifter for write
9 changes: 9 additions & 0 deletions asm/diskload1.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; diskload1.inc
; Diskload bootstrapper object config

diskload1_org = $9000 ; origin, should be $9000 for now
diskload1_zp = $00 ; object's ZP usage

;--END-OF-H ; ends C header file

diskload1 = diskload1_org ; Entry point
14 changes: 14 additions & 0 deletions asm/diskload2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; diskload2.inc
; Diskload object config

diskload2_org = $AE00 ; origin; 7 pages
diskload2_data = $1000 ; sector data start

; NB: Currently ends at $A9FF, but diskload3 inflate_data segment ($AB00-ADFF) can
; also be reused. The two buffers are not used at the same time.
nybbdata_org = $9200 ; Nybblized track data
nybbdata_size = $1800 ; 16*1.5=24 pages

;--END-OF-H ; ends C header file

diskload2 = diskload2_org ; Entry point
Loading