Some unfinished fixing of program uploading

This commit is contained in:
John Lorentzson 2025-07-24 23:51:03 +02:00
parent 32615cd6c9
commit d605e299f5
4 changed files with 60 additions and 38 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
*.lst
*.note
./build/*
*.lbl

View file

@ -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

View file

@ -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

View file

@ -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"