Skip to content

Commit

Permalink
Fix for 0x00 byte
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoflite committed Jan 10, 2019
1 parent 7008123 commit c71b398
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.PHONY: all
.PHONY: all clean

all:
make -C driver
make -C example disk

clean:
make clean -C driver
make clean -C example
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ This is an implementation of a reliable 2400b serial driver for the userport of
Based on George Hug's 'Towards 2400' article in the Transactor Magazine volume 9 issue 3.
(https://archive.org/details/transactor-magazines-v9-i03)

I used this fix to get around the 0x0d problem when a 0 byte is received.
(https://modelrail.otenko.com/electronics/commodore-64-fixing-rs-232-serial-limitations)

Cheers,
Johan
16 changes: 15 additions & 1 deletion driver/c64-up2400.s
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ GET:
jsr CHKIN
jsr rshavedata
beq GET_NO_DATA
jsr BASIN
jsr OURBASIN
ldx #$00
sta (ptr1,x)
jsr CLRCH
Expand All @@ -160,6 +160,19 @@ GET_NO_DATA:
ldx #>SER_ERR_NO_DATA
rts

;----------------------------------------------------------------------------
; OURBASIN: This is a minimised call to get the character from the buffer.
; The Kernal code does not allow zero bytes (0x00)... this does.
;

OURBASIN:
jsr $F14E
bcc @exit
jmp $F1B4
@exit
clc
rts

;----------------------------------------------------------------------------
; PUT: Output character in A.
; Must return an error code in a/x.
Expand All @@ -185,6 +198,7 @@ STATUS:
lda #<SER_ERR_OK
tax
rts

;----------------------------------------------------------------------------
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
; specific data in ptr1, and the ioctl code in A.
Expand Down

2 comments on commit c71b398

@greg-king5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is simpler: Use the Kernal function GETIN instead of BASIN.

Those functions were designed to support Microsoft's Micro BASIC. BASIN (called CHRIN also) is used by BASIC's INPUT statement. GETIN is used by the GET statement.

@nanoflite
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll try it out.

Please # to comment.