From d9e4e76356df348404586a0b9c2b6824400bb72f Mon Sep 17 00:00:00 2001 From: flowenol Date: Sat, 16 Jan 2021 01:13:14 +0100 Subject: [PATCH] Added api routines for read and write --- Makefile | 17 ++++ build.sh | 5 -- .../address_decoder.jed | 0 .../address_decoder.log | 0 .../addressdecoder.eqn | 0 src/apple1serial.xa | 77 +++++++++++++++++-- 6 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 Makefile delete mode 100755 build.sh rename address_decoder.jed => mapping/address_decoder.jed (100%) rename address_decoder.log => mapping/address_decoder.log (100%) rename addressdecoder.eqn => mapping/addressdecoder.eqn (100%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9f63e28 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +TOPTARGETS := all clean + +SUBDIRS := firmware + +$(TOPTARGETS): $(SUBDIRS) +$(SUBDIRS): + $(MAKE) -C $@ $(MAKECMDGOALS) + +.PHONY: $(TOPTARGETS) $(SUBDIRS) + +apple1serial.bin: + xa -W -C -v -O ASCII -S -c src/apple1serial.xa -l apple1serial.label -o apple1serial.bin + +all: apple1serial.bin + +clean: + rm apple1serial.bin apple1serial.label diff --git a/build.sh b/build.sh deleted file mode 100755 index 739a087..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -xa -W -C -v -O ASCII -S -c src/apple1serial.xa -l apple1serial.label -o apple1serial.bin -make -C firmware clean -make -C firmware diff --git a/address_decoder.jed b/mapping/address_decoder.jed similarity index 100% rename from address_decoder.jed rename to mapping/address_decoder.jed diff --git a/address_decoder.log b/mapping/address_decoder.log similarity index 100% rename from address_decoder.log rename to mapping/address_decoder.log diff --git a/addressdecoder.eqn b/mapping/addressdecoder.eqn similarity index 100% rename from addressdecoder.eqn rename to mapping/addressdecoder.eqn diff --git a/src/apple1serial.xa b/src/apple1serial.xa index 47550de..719ecae 100644 --- a/src/apple1serial.xa +++ b/src/apple1serial.xa @@ -1,10 +1,10 @@ ;End address of dump block -#define hex1_l $24 -#define hex1_h $25 +#define hex1_l $34 +#define hex1_h $35 ;Begin address of dump block -#define hex2_l $26 -#define hex2_h $27 +#define hex2_l $36 +#define hex2_h $37 #define last_command $28 #define last_command_none $00 @@ -141,7 +141,7 @@ separator jmp next_chr ;------------------------------------------------------------------------- -; Read procedure +; In-monitor read procedure ;------------------------------------------------------------------------- read @@ -182,7 +182,7 @@ read_next jmp read_byte ;------------------------------------------------------------------------- -; Write procedure +; In-monitor Write procedure ;------------------------------------------------------------------------- write @@ -225,6 +225,71 @@ write_next jsr increment_16bit ;Increment destination address jmp write_byte + +;------------------------------------------------------------------------- +; API read procedure +;------------------------------------------------------------------------- + +api_read + jsr reset_serial + lda serial_read ;Enable read mode + ldy #$00 + ldx #hex2_l + +api_read_byte + lda serial_ready + beq api_read_byte ;No data arrived + lda serial_read ;Read byte + sta (hex2_l),Y ;Store byte under address, this should be hex2_l but macro substitution doesn't work + + lda hex2_l + cmp hex1_l ;Compare lower destination address half with lower end address half + bne api_read_next ;If not equal then increment destination address + + lda hex2_h + cmp hex1_h ;Compare upper destination address half with upper end address half + bne api_read_next ;If not equal then proceed to read next byte + + rts ;Read is completed, return + +api_read_next + jsr increment_16bit ;Increment destination address + jmp api_read_byte + +;------------------------------------------------------------------------- +; API write procedure +;------------------------------------------------------------------------- + +api_write + jsr reset_serial ;Reset serial and give some time to stabilize + ;This is required due to inability to guess what is the current device mode + ;and prevents from polluting the output while setting the write mode + sta serial_write ;Enable write mode +api_write_ready + ldx #hex2_l + ldy #$00 + +api_write_byte + lda serial_ready + beq api_write_byte ;Not yet ready to write data + lda (hex2_l),Y ;Read byte from source address, this should be hex2_l but macro substitution doesn't work + sta serial_write ;Write byte + + lda hex2_l + cmp hex1_l ;Compare lower source address half with lower end address half + bne api_write_next ;If not equal then increment source address + + lda hex2_h + cmp hex1_h ;Compare upper source address half with upper end address half + bne api_write_next ;If not equal then proceed to write next byte + + rts ;Write is completed, return + +api_write_next + jsr increment_16bit ;Increment destination address + jmp api_write_byte + + ;------------------------------------------------------------------------- ; tool routines ;-------------------------------------------------------------------------