Last night's hacking, livecoding now working

This commit is contained in:
John Lorentzson 2025-07-28 11:04:33 +02:00
parent 8616393991
commit edde967aac
6 changed files with 75 additions and 23 deletions

View file

@ -753,7 +753,12 @@ Additionally ensures correct line numbers on the way, as a bonus."
(clear-screen) (clear-screen)
(redisplay-view (current-view *editor*))) (redisplay-view (current-view *editor*)))
(defparameter *refresh-asm-functions-p* nil
"If non-NIL, reload asm function addresses from listing before every compile.")
(defun com-compile-buffer () (defun com-compile-buffer ()
(when *refresh-asm-functions-p*
(usc:usc-init))
(let* ((src (buffer-string (current-buffer *editor*))) (let* ((src (buffer-string (current-buffer *editor*)))
(bytes (bytes
(handler-case (handler-case
@ -777,7 +782,8 @@ Additionally ensures correct line numbers on the way, as a bonus."
:element-type '(unsigned-byte 8) :element-type '(unsigned-byte 8)
:if-exists :supersede) :if-exists :supersede)
(dolist (byte bytes) (dolist (byte bytes)
(write-byte byte output))))))) (write-byte byte output)))
(usc::send-data-to-c64 (coerce bytes 'vector))))))

View file

@ -70,14 +70,10 @@
;; Disable maskeble interups (not all) ;; Disable maskeble interups (not all)
SEI SEI
;; Disable BASIC ROM mohahaha ;; Disable BASIC ROM mohahaha
;; https://www.c64-wiki.com/wiki/Bank_Switching
LDA #%11111110 LDA #%11111110
AND $0001 AND $0001
STA $0001 STA $0001
; https://www.c64-wiki.com/wiki/Bank_Switching
; Disable IO, CHAREN =0
LDA #%11111011
AND $0001
STA $0001
;;Disable non maskable interupts ;;Disable non maskable interupts
;;https://codebase64.org/doku.php?id=base:nmi_lock_without_kernal ;;https://codebase64.org/doku.php?id=base:nmi_lock_without_kernal

View file

@ -20,7 +20,7 @@
;; 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 = $fd
CLKMASK = %00000010 CLKMASK = %00000010
CTRL1 = $DC01 CTRL1 = $DC01
@ -55,8 +55,10 @@ download_userprog:
lda #$00 lda #$00
sta progdest sta progdest
sta progdest_backup
lda #$c0 lda #$c0
sta progdest+1 sta progdest+1
sta progdest_backup+1
;; change border color for debugging purposes ;; change border color for debugging purposes
ldx #$02 ; X needed for more than that debug color ldx #$02 ; X needed for more than that debug color
@ -86,6 +88,7 @@ wait_for_bit_start:
dex dex
lda BYTE lda BYTE
sta LEN,x sta LEN,x
sta $4010,x
txa txa
bne @notdone bne @notdone
;; Computing stop address ;; Computing stop address
@ -101,9 +104,12 @@ wait_for_bit_start:
;; Byte finished, storing ;; Byte finished, storing
lda BYTE lda BYTE
sta (progdest), y sta (progdest), y
inc progdest_backup
inc z:progdest inc z:progdest
bne @noinchi bne @noinchi
inc progdest_backup+1
inc z:progdest+1 inc z:progdest+1
@noinchi: @noinchi:
;; Comparing progdest against stop address ;; Comparing progdest against stop address
lda z:progdest lda z:progdest
@ -131,20 +137,26 @@ wait_for_bit_end:
jmp wait_for_bit_start jmp wait_for_bit_start
done: done:
lda #$01 lda #CLKMASK
@loop:
bit CTRL1
bne @loop
cli cli
clc clc
lda #$01
rts rts
error: error:
;; TODO ;; TODO
cli cli
sec sec
lda #$07
sta $d020
jmp $c000 jmp $c000
rts rts
BYTE = $400 BYTE: .byte 0
LEN = $402 LEN: .word $0000
stop: .word $0000 stop: .word $0000
loaded: .byte 0 progdest_backup = $4094
.endscope .endscope

View file

@ -11,31 +11,46 @@
;; .endrep ;; .endrep
@waitstart: ;; Wait until joystick 2 has been pulled down to start the program @waitstart: ;; Wait until joystick 2 has been pulled down to start the program
dec $d020
lda $dc00 lda $dc00
and #$02 and #$02
bne @waitstart bne @waitstart
jsr setup_loader jsr setup_loader
inc $d020
pha
@trying: @trying:
dec $d020 pla
tax
inx
stx $d020
txa
pha
jsr maybe_download_userprog jsr maybe_download_userprog
beq @trying beq @trying
.endscope .endscope
lda #$0d
sta $d020
.scope mainloop .scope mainloop
ml: ml:
USERPROG = $C000 USERPROG = $C000
RASTER = $D012 RASTER = $D012
;; Currently no code for fetching new programs, since we're testing with
;; batch compiled version of the whole to begin with.
;; Bank in character ROM ;; Bank out character ROM, I/O in
lda #%11111011 lda #%00000100
and $01 ora $01
sta $01 sta $01
;;jsr maybe_download_userprog jsr maybe_download_userprog
beq @nochange
ldx #$00
stx FRAMECOUNT
inx
sta FIRSTTIME
@nochange:
jsr USERPROG jsr USERPROG
;; Bank out character ROM, I/O in ;; Bank out character ROM, I/O in
@ -47,6 +62,8 @@ ml:
cpy #$66 cpy #$66
beq @framewait beq @framewait
inc FRAMECOUNT inc FRAMECOUNT
lda #$00
sta FIRSTTIME
jmp ml jmp ml
.endscope .endscope
@ -55,4 +72,23 @@ ml:
rts rts
.endproc .endproc
.proc first ; user-procedure
lda FIRSTTIME
rts
.endproc
.proc bitand ; user-procedure
lda ARGVEC+0
and ARGVEC+1
rts
.endproc
.proc bitxor ; user-procedure
lda ARGVEC+0
eor ARGVEC+1
rts
.endproc
FRAMECOUNT: .byte 0 FRAMECOUNT: .byte 0
FIRSTTIME: .byte 1

View file

@ -2,7 +2,7 @@
;; Sets memory in 'A'-registry to all addresses from 'A_start' until 'A_start' + 'length' ;; Sets memory in 'A'-registry to all addresses from 'A_start' until 'A_start' + 'length'
;; Modifies A, X and A_start ;; Modifies A, X and A_start
.proc clear_screen .proc clear_screen ; user-procedure
.include "mem.inc" .include "mem.inc"
VIC_bank = $4000 VIC_bank = $4000
length_ = $1f40 length_ = $1f40

View file

@ -68,8 +68,8 @@
(parse-asm-declaration main-text) (parse-asm-declaration main-text)
(list name address declaration))))) (list name address declaration)))))
(defparameter *program-listing-filepath* #P"../host/build/program.lst") (defparameter *program-listing-filepath* #P"../host/build/host.lst")
(defparameter *program-build-filepath* #P"../host/build.sh") (defparameter *program-build-filepath* #P"../host/Makefile")
(defun check-for-asm-build-script () (defun check-for-asm-build-script ()
(do ((path *program-build-filepath*)) (do ((path *program-build-filepath*))
@ -90,7 +90,9 @@
(progn (progn
(uiop:chdir (make-pathname :defaults script-path (uiop:chdir (make-pathname :defaults script-path
:name nil :type nil)) :name nil :type nil))
(uiop:run-program (namestring (uiop:run-program "make -"
#+(or)
(namestring
(make-pathname :defaults script-path (make-pathname :defaults script-path
:directory '(:relative "."))))) :directory '(:relative ".")))))
(uiop:chdir current-dir)))) (uiop:chdir current-dir))))