add documentation

This commit is contained in:
hugova 2025-07-11 16:34:12 +02:00
parent 74f589b98d
commit 877f5f5955

View file

@ -1,37 +1,61 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;This program reads a data stream from the joystick port and saves it in memory.
;;The datastream format is as sutch:
;;
;;############################################
;; 16-bit byte-length (big endian) | data
;;############################################
;; 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
;; 16-bit big endian number that matches the byte-lenght of the data that will get sent.
;; When the hole stream has ended the clock is pulled low until the next stream!
;; The data is then stored in ram with the first byte in progdest and the last in progdest + byte-length
;; At the end the program run the code stored at progdest with a jmp!
;; More documentation on the Joystick port can be found here: https://www.c64-wiki.com/wiki/Joystick
CLKMASK = %00000010
CTRL2 = $DC00
.org $80d
coldstart:
coldstart: ;; Draw a dollar sign on screen to show that program has loaded
lda #$0
sta $400
waitstart:
waitstart: ;; Wait until joystick 1 has been pulled forwards to start this program
lda $dc01
and #$01
bne waitstart
;; Change boarder colour for debuging
lda #$00
sta $d020
teststart:
jsr check_for_load_start
bcs @error
jsr check_for_load_start ; Check if start_bit is correct
bcs @error ; Idk why C=1 ask john
beq teststart
jmp $c000
jmp $c000 ; starts the program?
jmp $c000
@error:
lda #1
sta $0400
sta $0400 ;lets store 1 att this address for debuging purposes
rts
check_for_load_start:
lda #CLKMASK
bit CTRL2
bne start
bne start ; branch if Z ==0 <--> CTRL2 and CLKMASK ==0 <---> CTRL2 bit 2 == 0
lda #$00
rts
start:
sei
;; change boarder collor for debuging purposes
ldx #$02
stx $d020
ldy #$00
@ -85,6 +109,8 @@ wait_for_bit_start:
jmp done
@notdone:
new_byte:
;; BYTE is the byte beaing read from the stream. The bits are shifted from the left
;; When we shift out this 1 in BYTE bellow we save the BYTE to memory.
lda #%10000000
sta BYTE
wait_for_bit_end: