From d605e299f5f0b225e4355f072a6eb96200524e4d Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Thu, 24 Jul 2025 23:51:03 +0200 Subject: [PATCH] Some unfinished fixing of program uploading --- .gitignore | 1 + host/loader.s | 57 +++++++++++++++++++++++++++---------------------- host/mainloop.s | 31 +++++++++++++++++++-------- host/source.s | 9 +++++--- 4 files changed, 60 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 9f406fc..d292bd7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ *.lst *.note ./build/* +*.lbl \ No newline at end of file diff --git a/host/loader.s b/host/loader.s index d1a16c3..2aa5360 100644 --- a/host/loader.s +++ b/host/loader.s @@ -20,46 +20,46 @@ ;; More documentation on the Joystick port can be found here: https://www.c64-wiki.com/wiki/Joystick - progdest = $fe CLKMASK = %00000010 CTRL1 = $DC01 - .org $80d -coldstart: ;; Draw an at sign on screen to show that program has loaded - lda #$0 - sta $400 +setup_loader: + ;; Bank out character ROM, I/O in + lda #%00000100 + ora $01 + sta $01 + + lda #$00 sta progdest lda #$c0 sta progdest+1 -waitstart: ;; Wait until joystick 2 has been pulled down to start the program - lda $dc00 - and #$02 - bne waitstart - - ;; Change border colour for debugging - lda #$03 - sta $d020 -teststart: - jsr check_for_load_start ; Check if start_bit is correct - bcs @error ; The routine sets carry in the event of an error - beq teststart -@doneforever: - jmp $c000 ; starts the program? -@error: - lda #1 rts -check_for_load_start: +maybe_download_userprog: + ;; Bank out character ROM, I/O in + lda #%00000100 + ora $01 + sta $01 + lda #CLKMASK bit CTRL1 - bne start + bne download_userprog + lda #$00 rts -start: + +download_userprog: +.scope userprog_downloader sei + + lda #$00 + sta progdest + lda #$c0 + sta progdest+1 + ;; change border color for debugging purposes - ldx #$02 + ldx #$02 ; X needed for more than that debug color stx $d020 ldy #$00 jmp new_byte @@ -70,6 +70,9 @@ wait_for_bit_start: bit CTRL1 beq @loop + lda #$06 + sta $d020 + lda #CLKMASK bit CTRL1 beq error @@ -122,7 +125,7 @@ wait_for_bit_end: bit CTRL1 bne @loop ;; Debug show the clock is low - lda #$00 + lda #$02 sta $d020 jmp wait_for_bit_start @@ -137,9 +140,11 @@ error: ;; TODO cli sec + jmp $c000 rts BYTE = $400 LEN = $402 stop: .word $0000 loaded: .byte 0 +.endscope diff --git a/host/mainloop.s b/host/mainloop.s index 65854b1..61f670a 100644 --- a/host/mainloop.s +++ b/host/mainloop.s @@ -1,14 +1,26 @@ ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- .scope mainsetup - USERPROG = $C000 - .repeat 4, I - ldy #$00 -: - lda batch_userprog+(I*256),Y - sta USERPROG+(I*256),Y - dey - bne :- - .endrep +;; USERPROG = $C000 +;; .repeat 4, I +;; ldy #$00 +;; : +;; lda batch_userprog+(I*256),Y +;; sta USERPROG+(I*256),Y +;; dey +;; bne :- +;; .endrep + +@waitstart: ;; Wait until joystick 2 has been pulled down to start the program + lda $dc00 + and #$02 + bne @waitstart + + jsr setup_loader + inc $d020 +@trying: + dec $d020 + jsr maybe_download_userprog + beq @trying .endscope .scope mainloop @@ -23,6 +35,7 @@ ml: and $01 sta $01 + ;;jsr maybe_download_userprog jsr USERPROG ;; Bank out character ROM, I/O in diff --git a/host/source.s b/host/source.s index d545d0b..30a16b4 100644 --- a/host/source.s +++ b/host/source.s @@ -12,13 +12,16 @@ .include "STARTUP.s" ;.include "dubbel_buffer/raster_irqs.s" +.include "mainloop.s" +.include "loader.s" + ;.include "routines/arithmatic/mult_test.s" ;.include "routines/arithmatic/div_test.s" ;.include "routines/circle/circle_test.s" ;.include "routines/circle/circle_test_size.s" ;.include "routines/circle/circle_test_position.s" ;.include "routines/line/line_test.s" -.include "routines/line/line_test_extensive.s" +;.include "routines/line/line_test_extensive.s" ;.include "routines/text/char_draw_test.s" ;.include "routines/pixel/pixel_test.s" ;.include "routines/memory/memcpy_test.s" @@ -39,7 +42,7 @@ JMP exit .include "routines/arithmatic/mult.s" .include "routines/arithmatic/div.s" -batch_userprog: -.incbin "userprog.bin", 0, 1024 +;batch_userprog: +;.incbin "userprog.bin", 0, 1024 .include "END.s"