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 -*- ;;; -*- 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 CLKMASK = %00000010
CTRL2 = $DC00 CTRL2 = $DC00
.org $80d .org $80d
coldstart: coldstart: ;; Draw a dollar sign on screen to show that program has loaded
lda #$0 lda #$0
sta $400 sta $400
waitstart: waitstart: ;; Wait until joystick 1 has been pulled forwards to start this program
lda $dc01 lda $dc01
and #$01 and #$01
bne waitstart bne waitstart
;; Change boarder colour for debuging
lda #$00 lda #$00
sta $d020 sta $d020
teststart: teststart:
jsr check_for_load_start jsr check_for_load_start ; Check if start_bit is correct
bcs @error bcs @error ; Idk why C=1 ask john
beq teststart beq teststart
jmp $c000 jmp $c000 ; starts the program?
jmp $c000 jmp $c000
@error: @error:
lda #1 lda #1
sta $0400 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 CTRL2 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 boarder collor for debuging purposes
ldx #$02 ldx #$02
stx $d020 stx $d020
ldy #$00 ldy #$00
@ -85,6 +109,8 @@ wait_for_bit_start:
jmp done jmp done
@notdone: @notdone:
new_byte: 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 lda #%10000000
sta BYTE sta BYTE
wait_for_bit_end: wait_for_bit_end: