Compare commits

..

No commits in common. "17560c4b78008c9d3a4517c4ea5b5d0625a43cfa" and "5c41b4866426722c96b689927cf84fad4dc7ff52" have entirely different histories.

2 changed files with 27 additions and 34 deletions

View file

@ -1,13 +1,13 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;; This program reads a data stream from the joystick port and saves it in memory. ;;This program reads a data stream from the joystick port and saves it in memory.
;; The datastream format is as sutch: ;;The datastream format is as sutch:
;; ;;
;; ############################################ ;;############################################
;; 16-bit byte-length (big endian) | data ;; 16-bit byte-length (big endian) | data
;; ############################################ ;;############################################
;; The data comes from CTRL1 bit 0 and the clock is at bit 1 ;; The data comes from CTRL2 bit 0 and the clock is at bit 1
;; The stream starts when the clock is pulled high, after that comes a ;; The stream starts when the clock is pulled high, after that comes a
;; 16-bit big endian number that matches the byte-lenght of the data that will get sent. ;; 16-bit big endian number that matches the byte-lenght of the data that will get sent.
@ -21,44 +21,41 @@
;; More documentation on the Joystick port can be found here: https://www.c64-wiki.com/wiki/Joystick ;; More documentation on the Joystick port can be found here: https://www.c64-wiki.com/wiki/Joystick
progdest = $fe
CLKMASK = %00000010 CLKMASK = %00000010
CTRL1 = $DC01 CTRL2 = $DC00
.org $80d .org $80d
coldstart: ;; Draw an at sign on screen to show that program has loaded coldstart: ;; Draw a dollar sign on screen to show that program has loaded
lda #$0 lda #$0
sta $400 sta $400
sta progdest waitstart: ;; Wait until joystick 1 has been pulled forwards to start this program
lda #$c0 lda $dc01
sta progdest+1 and #$01
waitstart: ;; Wait until joystick 2 has been pulled down to start the program
lda $dc00
and #$02
bne waitstart bne waitstart
;; Change border colour for debugging ;; Change boarder colour for debuging
lda #$03 lda #$00
sta $d020 sta $d020
teststart: teststart:
jsr check_for_load_start ; Check if start_bit is correct jsr check_for_load_start ; Check if start_bit is correct
bcs @error ; The routine sets carry in the event of an error bcs @error ; Idk why C=1 ask john
beq teststart beq teststart
@doneforever:
jmp $c000 ; starts the program? jmp $c000 ; starts the program?
jmp $c000
@error: @error:
lda #1 lda #1
sta $0400 ;lets store 1 att this address for debuging purposes
rts rts
check_for_load_start: check_for_load_start:
lda #CLKMASK lda #CLKMASK
bit CTRL1 bit CTRL2
bne start bne start ; branch if Z ==0 <--> CTRL2 and CLKMASK ==0 <---> CTRL2 bit 2 == 0
lda #$00 lda #$00
rts rts
start: start:
sei sei
;; change border color for debugging purposes ;; change boarder collor for debuging purposes
ldx #$02 ldx #$02
stx $d020 stx $d020
ldy #$00 ldy #$00
@ -67,13 +64,13 @@ start:
wait_for_bit_start: wait_for_bit_start:
lda #CLKMASK lda #CLKMASK
@loop: @loop:
bit CTRL1 bit CTRL2
beq @loop beq @loop
lda #CLKMASK lda #CLKMASK
bit CTRL1 bit CTRL2
beq error beq error
lda CTRL1 lda CTRL2
lsr lsr
ror BYTE ror BYTE
@ -112,19 +109,15 @@ wait_for_bit_start:
jmp done jmp done
@notdone: @notdone:
new_byte: new_byte:
;; BYTE is the byte being read from the stream. The bits are shifted from the left ;; BYTE is the byte beaing read from the stream. The bits are shifted from the left
;; When we shift out this 1 in BYTE below we save the BYTE to memory. ;; When we shift out this 1 in BYTE bellow we save the BYTE to memory.
lda #%10000000 lda #%10000000
sta BYTE sta BYTE
wait_for_bit_end: wait_for_bit_end:
lda #CLKMASK lda #CLKMASK
@loop: @loop:
bit CTRL1 bit CTRL2
bne @loop bne @loop
;; Debug show the clock is low
lda #$00
sta $d020
jmp wait_for_bit_start jmp wait_for_bit_start
done: done:
@ -141,5 +134,6 @@ error:
BYTE = $400 BYTE = $400
LEN = $402 LEN = $402
progdest = $fe
stop: .word $0000 stop: .word $0000
loaded: .byte 0 loaded: .byte 0

View file

@ -222,7 +222,6 @@
output-filepath)))) output-filepath))))
(defun send-data-to-c64 (data) (defun send-data-to-c64 (data)
(declare (type vector data))
(with-open-file (stream "/dev/ttyACM0" (with-open-file (stream "/dev/ttyACM0"
:direction :io :direction :io
:element-type '(unsigned-byte 8) :element-type '(unsigned-byte 8)