Add working emulator preview build method
This commit is contained in:
parent
edde967aac
commit
0505b4cfef
4 changed files with 52 additions and 18 deletions
|
@ -753,7 +753,7 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
|||
(clear-screen)
|
||||
(redisplay-view (current-view *editor*)))
|
||||
|
||||
(defparameter *refresh-asm-functions-p* nil
|
||||
(defparameter *refresh-asm-functions-p* #+swank t #-swank nil
|
||||
"If non-NIL, reload asm function addresses from listing before every compile.")
|
||||
|
||||
(defun com-compile-buffer ()
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
BINARY := host.prg
|
||||
HOST_BINARY := host.prg
|
||||
PREVIEW_BINARY := preview.prg
|
||||
|
||||
BUILD_DIR := ./build
|
||||
SRC_DIR := ./src
|
||||
|
||||
HOST_PRG := $(BUILD_DIR)/$(HOST_BINARY)
|
||||
PREVIEW_PRG := $(BUILD_DIR)/$(PREVIEW_BINARY)
|
||||
|
||||
SRCS := $(shell find $(SRC_DIR) -name '*.s' -or -name '*.inc')
|
||||
TOPLEVEL := source.s
|
||||
|
||||
|
@ -10,11 +14,13 @@ CL := cl65
|
|||
|
||||
CLFLAGS := -u __EXEHDR__ -t c64 -C c64-asm.cfg -l $(BUILD_DIR)/host.lst -Ln $(BUILD_DIR)/host.lbl
|
||||
|
||||
$(BUILD_DIR)/$(BINARY): $(SRCS)
|
||||
$(HOST_PRG): $(SRCS)
|
||||
mkdir -p $(BUILD_DIR)
|
||||
$(CL) -o $@ $(CLFLAGS) $(SRC_DIR)/$(TOPLEVEL)
|
||||
|
||||
all: $(BUILD_DIR)/$(BINARY)
|
||||
$(PREVIEW_PRG): $(SRCS) userprog.bin
|
||||
$(CL) -o $@ --asm-define EMULATOR_PREVIEW $(CLFLAGS) $(SRC_DIR)/$(TOPLEVEL)
|
||||
|
||||
preview: userprog.bin $(SRCS)
|
||||
$(CL) -o $@ -D EMULATOR_PREVIEW $(CLFLAGS) $(SRC_DIR)/$(TOPLEVEL)
|
||||
all: $(HOST_PRG)
|
||||
|
||||
preview: $(PREVIEW_PRG)
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
;;; -*- 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
|
||||
.ifdef EMULATOR_PREVIEW
|
||||
USERPROG = $C000
|
||||
.repeat 4, I
|
||||
ldy #$00
|
||||
:
|
||||
lda batch_userprog+(I*256),Y
|
||||
sta USERPROG+(I*256),Y
|
||||
dey
|
||||
bne :-
|
||||
.endrep
|
||||
.endif
|
||||
|
||||
.ifndef EMULATOR_PREVIEW
|
||||
@waitstart: ;; Wait until joystick 2 has been pulled down to start the program
|
||||
dec $d020
|
||||
lda $dc00
|
||||
|
@ -29,12 +32,19 @@
|
|||
|
||||
jsr maybe_download_userprog
|
||||
beq @trying
|
||||
.endif
|
||||
.endscope
|
||||
|
||||
lda #$0d
|
||||
sta $d020
|
||||
|
||||
.scope mainloop
|
||||
|
||||
ldx #$00
|
||||
stx FRAMECOUNT
|
||||
inx
|
||||
sta FIRSTTIME
|
||||
|
||||
ml:
|
||||
USERPROG = $C000
|
||||
RASTER = $D012
|
||||
|
@ -44,6 +54,7 @@ ml:
|
|||
ora $01
|
||||
sta $01
|
||||
|
||||
.ifndef EMULATOR_PREVIEW
|
||||
jsr maybe_download_userprog
|
||||
beq @nochange
|
||||
ldx #$00
|
||||
|
@ -51,6 +62,7 @@ ml:
|
|||
inx
|
||||
sta FIRSTTIME
|
||||
@nochange:
|
||||
.endif
|
||||
jsr USERPROG
|
||||
|
||||
;; Bank out character ROM, I/O in
|
||||
|
|
|
@ -221,12 +221,15 @@
|
|||
(format t "Finished, wrote compiled program to \"~A\".~%"
|
||||
output-filepath))))
|
||||
|
||||
(defun send-data-to-c64 (data)
|
||||
(defparameter *c64-tty* "/dev/ttyACM0")
|
||||
|
||||
(defun %send-data-to-c64 (data)
|
||||
(declare (type vector data))
|
||||
(with-open-file (stream "/dev/ttyACM0"
|
||||
(with-open-file (stream *c64-tty*
|
||||
:direction :io
|
||||
:element-type '(unsigned-byte 8)
|
||||
:if-exists :overwrite)
|
||||
:if-exists :overwrite
|
||||
:if-does-not-exist :error)
|
||||
(sleep 2.5)
|
||||
(let ((index 0)
|
||||
(length (length data)))
|
||||
|
@ -245,6 +248,19 @@
|
|||
(force-output stream)
|
||||
(format t "~D~%" index)))))
|
||||
|
||||
(defun send-data-to-c64 (data)
|
||||
(declare (type vector data))
|
||||
(handler-bind
|
||||
((file-error
|
||||
(lambda (c)
|
||||
(when (equalp (namestring (file-error-pathname c))
|
||||
(namestring *c64-tty*))
|
||||
(warn "Failed to open C64 transfer TTY.")
|
||||
(abort c)))))
|
||||
(restart-case
|
||||
(%send-data-to-c64 data)
|
||||
(abort ()))))
|
||||
|
||||
(defun compile-and-send-to-c64 (string)
|
||||
(let ((bytes (compile-string-to-bytes string :print-ir-p t)))
|
||||
(send-data-to-c64 (coerce bytes 'vector))))
|
||||
|
|
Loading…
Add table
Reference in a new issue