diff --git a/editor/editor.lisp b/editor/editor.lisp index 21fbebb..3d8a5b1 100644 --- a/editor/editor.lisp +++ b/editor/editor.lisp @@ -753,7 +753,12 @@ Additionally ensures correct line numbers on the way, as a bonus." (clear-screen) (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 () + (when *refresh-asm-functions-p* + (usc:usc-init)) (let* ((src (buffer-string (current-buffer *editor*))) (bytes (handler-case @@ -777,7 +782,8 @@ Additionally ensures correct line numbers on the way, as a bonus." :element-type '(unsigned-byte 8) :if-exists :supersede) (dolist (byte bytes) - (write-byte byte output))))))) + (write-byte byte output))) + (usc::send-data-to-c64 (coerce bytes 'vector)))))) diff --git a/host/src/STARTUP.s b/host/src/STARTUP.s index bc9ebc8..60fb38f 100755 --- a/host/src/STARTUP.s +++ b/host/src/STARTUP.s @@ -70,14 +70,10 @@ ;; Disable maskeble interups (not all) SEI ;; Disable BASIC ROM mohahaha + ;; https://www.c64-wiki.com/wiki/Bank_Switching LDA #%11111110 AND $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 ;;https://codebase64.org/doku.php?id=base:nmi_lock_without_kernal diff --git a/host/src/loader.s b/host/src/loader.s index 2aa5360..2fb8035 100644 --- a/host/src/loader.s +++ b/host/src/loader.s @@ -20,7 +20,7 @@ ;; More documentation on the Joystick port can be found here: https://www.c64-wiki.com/wiki/Joystick - progdest = $fe + progdest = $fd CLKMASK = %00000010 CTRL1 = $DC01 @@ -55,8 +55,10 @@ download_userprog: lda #$00 sta progdest + sta progdest_backup lda #$c0 sta progdest+1 + sta progdest_backup+1 ;; change border color for debugging purposes ldx #$02 ; X needed for more than that debug color @@ -86,6 +88,7 @@ wait_for_bit_start: dex lda BYTE sta LEN,x + sta $4010,x txa bne @notdone ;; Computing stop address @@ -101,9 +104,12 @@ wait_for_bit_start: ;; Byte finished, storing lda BYTE sta (progdest), y + inc progdest_backup inc z:progdest bne @noinchi + inc progdest_backup+1 inc z:progdest+1 + @noinchi: ;; Comparing progdest against stop address lda z:progdest @@ -131,20 +137,26 @@ wait_for_bit_end: jmp wait_for_bit_start done: - lda #$01 + lda #CLKMASK +@loop: + bit CTRL1 + bne @loop cli clc + lda #$01 rts error: ;; TODO cli sec + lda #$07 + sta $d020 jmp $c000 rts -BYTE = $400 -LEN = $402 +BYTE: .byte 0 +LEN: .word $0000 stop: .word $0000 -loaded: .byte 0 +progdest_backup = $4094 .endscope diff --git a/host/src/mainloop.s b/host/src/mainloop.s index 61f670a..6612125 100644 --- a/host/src/mainloop.s +++ b/host/src/mainloop.s @@ -11,31 +11,46 @@ ;; .endrep @waitstart: ;; Wait until joystick 2 has been pulled down to start the program + dec $d020 lda $dc00 and #$02 bne @waitstart jsr setup_loader - inc $d020 + + pha @trying: - dec $d020 + pla + tax + inx + stx $d020 + txa + pha + jsr maybe_download_userprog beq @trying .endscope + lda #$0d + sta $d020 + .scope mainloop ml: USERPROG = $C000 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 - lda #%11111011 - and $01 + ;; Bank out character ROM, I/O in + lda #%00000100 + ora $01 sta $01 - ;;jsr maybe_download_userprog + jsr maybe_download_userprog + beq @nochange + ldx #$00 + stx FRAMECOUNT + inx + sta FIRSTTIME +@nochange: jsr USERPROG ;; Bank out character ROM, I/O in @@ -47,6 +62,8 @@ ml: cpy #$66 beq @framewait inc FRAMECOUNT + lda #$00 + sta FIRSTTIME jmp ml .endscope @@ -55,4 +72,23 @@ ml: rts .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 +FIRSTTIME: .byte 1 diff --git a/host/src/routines/memory/clear_screen.s b/host/src/routines/memory/clear_screen.s index e55edb8..2fad099 100644 --- a/host/src/routines/memory/clear_screen.s +++ b/host/src/routines/memory/clear_screen.s @@ -2,7 +2,7 @@ ;; Sets memory in 'A'-registry to all addresses from 'A_start' until 'A_start' + 'length' ;; Modifies A, X and A_start -.proc clear_screen +.proc clear_screen ; user-procedure .include "mem.inc" VIC_bank = $4000 length_ = $1f40 diff --git a/user-side-compiler/populate-asm-functions.lisp b/user-side-compiler/populate-asm-functions.lisp index 83d9dae..bade850 100644 --- a/user-side-compiler/populate-asm-functions.lisp +++ b/user-side-compiler/populate-asm-functions.lisp @@ -68,8 +68,8 @@ (parse-asm-declaration main-text) (list name address declaration))))) -(defparameter *program-listing-filepath* #P"../host/build/program.lst") -(defparameter *program-build-filepath* #P"../host/build.sh") +(defparameter *program-listing-filepath* #P"../host/build/host.lst") +(defparameter *program-build-filepath* #P"../host/Makefile") (defun check-for-asm-build-script () (do ((path *program-build-filepath*)) @@ -90,7 +90,9 @@ (progn (uiop:chdir (make-pathname :defaults script-path :name nil :type nil)) - (uiop:run-program (namestring + (uiop:run-program "make -" + #+(or) + (namestring (make-pathname :defaults script-path :directory '(:relative "."))))) (uiop:chdir current-dir))))