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 *.lst
*.note *.note
./build/* ./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 ;; More documentation on the Joystick port can be found here: https://www.c64-wiki.com/wiki/Joystick
progdest = $fe progdest = $fe
CLKMASK = %00000010 CLKMASK = %00000010
CTRL1 = $DC01 CTRL1 = $DC01
.org $80d setup_loader:
coldstart: ;; Draw an at sign on screen to show that program has loaded ;; Bank out character ROM, I/O in
lda #$0 lda #%00000100
sta $400 ora $01
sta $01
lda #$00
sta progdest sta progdest
lda #$c0 lda #$c0
sta progdest+1 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 rts
check_for_load_start: maybe_download_userprog:
;; Bank out character ROM, I/O in
lda #%00000100
ora $01
sta $01
lda #CLKMASK lda #CLKMASK
bit CTRL1 bit CTRL1
bne start bne download_userprog
lda #$00 lda #$00
rts rts
start:
download_userprog:
.scope userprog_downloader
sei sei
lda #$00
sta progdest
lda #$c0
sta progdest+1
;; change border color for debugging purposes ;; change border color for debugging purposes
ldx #$02 ldx #$02 ; X needed for more than that debug color
stx $d020 stx $d020
ldy #$00 ldy #$00
jmp new_byte jmp new_byte
@ -70,6 +70,9 @@ wait_for_bit_start:
bit CTRL1 bit CTRL1
beq @loop beq @loop
lda #$06
sta $d020
lda #CLKMASK lda #CLKMASK
bit CTRL1 bit CTRL1
beq error beq error
@ -122,7 +125,7 @@ wait_for_bit_end:
bit CTRL1 bit CTRL1
bne @loop bne @loop
;; Debug show the clock is low ;; Debug show the clock is low
lda #$00 lda #$02
sta $d020 sta $d020
jmp wait_for_bit_start jmp wait_for_bit_start
@ -137,9 +140,11 @@ error:
;; TODO ;; TODO
cli cli
sec sec
jmp $c000
rts rts
BYTE = $400 BYTE = $400
LEN = $402 LEN = $402
stop: .word $0000 stop: .word $0000
loaded: .byte 0 loaded: .byte 0
.endscope

View file

@ -1,14 +1,26 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
.scope mainsetup .scope mainsetup
USERPROG = $C000 ;; USERPROG = $C000
.repeat 4, I ;; .repeat 4, I
ldy #$00 ;; ldy #$00
: ;; :
lda batch_userprog+(I*256),Y ;; lda batch_userprog+(I*256),Y
sta USERPROG+(I*256),Y ;; sta USERPROG+(I*256),Y
dey ;; dey
bne :- ;; bne :-
.endrep ;; .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 .endscope
.scope mainloop .scope mainloop
@ -23,6 +35,7 @@ ml:
and $01 and $01
sta $01 sta $01
;;jsr maybe_download_userprog
jsr USERPROG jsr USERPROG
;; Bank out character ROM, I/O in ;; Bank out character ROM, I/O in

View file

@ -12,13 +12,16 @@
.include "STARTUP.s" .include "STARTUP.s"
;.include "dubbel_buffer/raster_irqs.s" ;.include "dubbel_buffer/raster_irqs.s"
.include "mainloop.s"
.include "loader.s"
;.include "routines/arithmatic/mult_test.s" ;.include "routines/arithmatic/mult_test.s"
;.include "routines/arithmatic/div_test.s" ;.include "routines/arithmatic/div_test.s"
;.include "routines/circle/circle_test.s" ;.include "routines/circle/circle_test.s"
;.include "routines/circle/circle_test_size.s" ;.include "routines/circle/circle_test_size.s"
;.include "routines/circle/circle_test_position.s" ;.include "routines/circle/circle_test_position.s"
;.include "routines/line/line_test.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/text/char_draw_test.s"
;.include "routines/pixel/pixel_test.s" ;.include "routines/pixel/pixel_test.s"
;.include "routines/memory/memcpy_test.s" ;.include "routines/memory/memcpy_test.s"
@ -39,7 +42,7 @@ JMP exit
.include "routines/arithmatic/mult.s" .include "routines/arithmatic/mult.s"
.include "routines/arithmatic/div.s" .include "routines/arithmatic/div.s"
batch_userprog: ;batch_userprog:
.incbin "userprog.bin", 0, 1024 ;.incbin "userprog.bin", 0, 1024
.include "END.s" .include "END.s"