Compare commits

..

24 commits

Author SHA1 Message Date
31242dd7d9 Merge branch 'main' into integration 2025-07-25 13:07:30 +02:00
69b29fc77c Replace host/build.sh with a Makefile 2025-07-25 12:54:39 +02:00
981b989ad1 Delete a new.labels.lables (what's this? why's this here?) 2025-07-25 12:52:46 +02:00
e7c316bb6b Add *.labels to .gitignore 2025-07-25 12:52:28 +02:00
e4d5fd6f5a Remove another label file 2025-07-25 12:51:40 +02:00
96cf505934 Delete label file (should not be under version control) 2025-07-25 12:50:40 +02:00
90ca5d6836 Move host source code into "src" directory 2025-07-25 12:50:26 +02:00
d3b48e99f4 Add some more to .gitignore 2025-07-25 12:35:22 +02:00
8ea1a2530a Remove duplicate entry in .gitignore 2025-07-25 12:33:43 +02:00
77d30af636 Add IFDEF for "emulator preview" with userprog baked into host 2025-07-25 12:32:53 +02:00
a48937fe3c Move lookup tables into separate file 2025-07-25 12:32:29 +02:00
d605e299f5 Some unfinished fixing of program uploading 2025-07-24 23:51:03 +02:00
32615cd6c9 Move loader to host 2025-07-24 19:58:53 +02:00
c076aa2055 Add "main loop" to host program, which executes user program 2025-07-24 15:29:55 +02:00
677b6a2f56 Rename "file.prg" to "host.prg" 2025-07-24 15:29:34 +02:00
2206b1f864 Correct paths to host program listing and build script in USC 2025-07-24 15:29:08 +02:00
ec867b25d3 Correct ARGVEC and VARVEC offsets in code generator 2025-07-24 15:28:55 +02:00
a32dea0a11 Include batch compiler user program into host program 2025-07-24 15:28:44 +02:00
36c8d52388 Add origin address to host program 2025-07-24 15:28:29 +02:00
bf2e6f8035 Move public.inc to host 2025-07-24 13:22:09 +02:00
c0dc98a2c9 Move wip-hugo stuff into "host" (to be sorted) 2025-07-24 13:20:29 +02:00
e00474bc98 Move user-side compiler into repo root 2025-07-24 12:34:53 +02:00
a206de1007 Move editor into repo root 2025-07-24 12:34:21 +02:00
4dfde387e4 Remove Dicander's code, as it is unused by the larger system 2025-07-24 12:27:53 +02:00
124 changed files with 329 additions and 2037 deletions

8
.gitignore vendored
View file

@ -2,7 +2,11 @@
*.prg
*.o
*.lst
*.lst
*.note
host/build/*
*.lbl
build/*
*.bin
*.labels
editor/c6le
editor/source-program_*.c6l
user-side-compiler/c6lc

20
host/Makefile Normal file
View file

@ -0,0 +1,20 @@
BINARY := host.prg
BUILD_DIR := ./build
SRC_DIR := ./src
SRCS := $(shell find $(SRC_DIR) -name '*.s' -or -name '*.inc')
TOPLEVEL := source.s
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)
mkdir -p $(BUILD_DIR)
$(CL) -o $@ $(CLFLAGS) $(SRC_DIR)/$(TOPLEVEL)
all: $(BUILD_DIR)/$(BINARY)
preview: userprog.bin $(SRCS)
$(CL) -o $@ -D EMULATOR_PREVIEW $(CLFLAGS) $(SRC_DIR)/$(TOPLEVEL)

5
host/run.sh Executable file
View file

@ -0,0 +1,5 @@
# !/bin/bash
killall x64sc
make \
&& nohup flatpak run net.sf.VICE -windowypos 0 -windowxpos 960 -windowwidth 945 -windowheight 720 -moncommands program.lbl build/file.prg </dev/null &>/dev/null &

View file

@ -1,4 +1,4 @@
# !/bin/bash
./build.sh &&
make &&
./retrodebugger_label_build_tool/rdb_build_label.sh \
&& nohup retrodebugger -b retrodebugger_label_build_tool/new.labels.labels -c64 ./build/file.prg </dev/null &>/dev/null &

2
host/src/END.s Normal file
View file

@ -0,0 +1,2 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
END_OF_PROGRAM:

View file

@ -58,14 +58,17 @@
ORA Screen_RAM_settings
STA Screen_RAM_settings
;; clear the screen
JSR clear_screen
;; Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 length, length + 1, #<$1f40, #>$1f40
LDA #$00
jsr memset
;; Sets the screen color to black and white
Mov_16 A_start, A_start + 1, #<Screen_RAM, #>Screen_RAM
Mov_16 length, length + 1, #<$03E8, #>$03E8
LDA #%11110000
JSR memset
jsr memset
;; Disable maskeble interups (not all)
SEI

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

58
host/src/mainloop.s Normal file
View file

@ -0,0 +1,58 @@
;;; -*- 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
@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
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
sta $01
;;jsr maybe_download_userprog
jsr USERPROG
;; Bank out character ROM, I/O in
lda #%00000100
ora $01
sta $01
@framewait:
ldy RASTER
cpy #$66
beq @framewait
inc FRAMECOUNT
jmp ml
.endscope
.proc time ; user-procedure
lda FRAMECOUNT
rts
.endproc
FRAMECOUNT: .byte 0

View file

@ -21,8 +21,12 @@ loop:
; DEY
; BNE delay_point
JSR clear_screen
;;clear screen
VIC_bank = $4000
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 length, length + 1, #<$1f40, #>$1f40
LDA #$00
jsr memset
;;move circle
INC $AD

View file

@ -30,7 +30,12 @@ loop:
LDA $AD
STA radius
JSR clear_screen
;; clean the screen
VIC_bank = $4000
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 length, length + 1, #<$1f40, #>$1f40
LDA #$00
jsr memset
;; draw the circle
JSR circle

View file

@ -5,24 +5,26 @@
.include "line.inc"
;; Fix line that is too long
LDA #$C8 ;y_max = $C8
CMP Y_pos
BCS do_not_fix_y_pos
LDA Y_pos
CMP #$C8 ;;y_max = $C8
BCC do_not_fix_y_pos
LDA #$C8
STA Y_pos
do_not_fix_y_pos:
LDA Y_end
CMP #$C8 ;;y_max = $C8
BCC do_not_fix_y_end
LDA #$C8
CMP Y_pos ;y_max = $C8
BCS do_not_fix_y_end
STA Y_end
do_not_fix_y_end:
;;dx
SEC
LDA X_end
SBC X_pos
BCS dx_no_underflow;; X_end >= X_pos
EOR #$ff ; Fix bit underflow
ADC #$01
STA dx
;; line_* expect X_pos < X_end and now its not the case.
;; Lets move them around
@ -34,27 +36,28 @@ do_not_fix_y_end:
LDY Y_end
STX Y_end
STY Y_pos
dx_no_underflow:
STA dx
SEC
LDA Y_end
SBC Y_pos
BCS down ;normal Y_pos < Y_end
up:; Y_pos > Y_end
EOR #$ff ; Fix bit underflow
ADC #$01
LDA Y_pos
SBC Y_end
STA dy
BCC down ;normal Y_pos < Y_end
up:; Y_pos > Y_end
STA dy
CMP dx
BCC shallow; dy < dx
steep:
jsr line_up_inv
RTS
shallow: ;dy =< dx
lda dx
jsr line_up
RTS
down:
EOR #$ff ; Fix bit underflow
STA dy
CMP dx
BCC shallow_; dy < dx

View file

@ -67,7 +67,6 @@ end_selfmod:
STA byte_to_paint
;; X = X_end - X_pos
LDX dx
INX ; okay if it overflow to $00 because it will go back to $ff in loop.
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$00, #$00,! ;; Y has always a offset of at least 1 = C + $0000
INY
for_x:

View file

@ -55,7 +55,6 @@ end_selfmod:
INY
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$00, #$00, !
LDX dy
INX
CLC
for_y: ; C =0
LDA byte_to_paint

View file

@ -8,8 +8,6 @@
X_pos_ = $0E
Y_end_ = $0F
X_end_ = $0C
full_angle_test:
LDA #$d2
STA X_pos_
LDA #$62
@ -36,45 +34,23 @@ full_angle_test:
CMP #$ff
bne @loop
jsr clear_screen
full_angle_test_pos_end_swapped:
LDA #$d2
STA X_end_
LDA #$62
STA Y_end_
LDA #$ff
STA X_pos_
LDA #$0
STA Y_pos_
;; Full angle test
@loop:
LDA Y_end_
STA Y_end
LDA X_end_
STA X_end
LDA X_pos_
STA X_pos
LDA Y_pos_
STA Y_pos
jsr line
INC Y_pos_
LDA Y_pos_
CMP #$ff
bne @loop
jsr clear_screen
clear_screen:
;;Lets clear bitmap
VIC_bank = $4000
;;Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 length, length + 1, #<$1f40, #>$1f40
LDA #$00
jsr memset
long_line_test_a:
LDA #$01
LDA #$00
STA X_pos_
LDA #$60
STA Y_pos_
LDA #$ff
STA X_end_
LDA #$00
LDA #$0
STA Y_end_
@loop:
LDA Y_pos_
@ -92,10 +68,15 @@ long_line_test_a:
CMP #$ff
BNE @loop
jsr clear_screen
clear_screen_:
;;Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 length, length + 1, #<$1f40, #>$1f40
LDA #$00
jsr memset
long_line_test_b:
LDA #$01
LDA #$00
STA X_pos_
LDA #$00
STA Y_pos_
@ -118,10 +99,15 @@ long_line_test_b:
CMP #$ff
BNE @loop
jsr clear_screen
clear_screen__:
;;Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 length, length + 1, #<$1f40, #>$1f40
LDA #$00
jsr memset
long_line_test_b_pos_end_swapped:
LDA #$01
LDA #$00
STA X_end_
LDA #$00
STA Y_end_

View file

@ -50,7 +50,6 @@ end_selfmod:
;LDY #$01
INY
LDX dx
INX
for_x:
LDA byte_to_paint
ORA (btp_mem_pos), Y

View file

@ -34,7 +34,7 @@
STA D + 1
;; because C flag is wrong value we let dy_2 be 1 to small
Sub_16 dx_2, dx_2 +1, #$01,#$00
Sub_16 dy_2, dy_2 +1, #$01,#$00
selfmod:
LDA dx_2
@ -52,7 +52,6 @@ end_selfmod:
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$00, #$00,!
CLC
LDX dy
INX
for_y:
LDA byte_to_paint
ORA (btp_mem_pos), Y

View file

@ -1,39 +1,40 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;; Sets memory in 'A'-registry to all addresses from 'A_start' until 'A_start' + 'length'
;; Modifies A, X and A_start
.proc clear_screen
.include "mem.inc"
VIC_bank = $4000
length_ = $1f40
low_length_3 = $C0 + $03 ;; we need one more.
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
LDA #$00
;; big_set sets the memory in $ff chunks.
;; skipp if length >= $ff
LDX #>length_
BNE big_set
JMP small_set
big_set: ;sets $ff of memory
;; Y value do not matter, will go through all anyway!
.repeat $ff
STA (A_start), Y
DEY
.endrepeat
STA (A_start), Y ; dont forget Y =0
big_set_end:
;;set all hole $ff memory chunks!
INC A_start + 1
DEX ;; length +1 --
BEQ small_set
JMP big_set
small_set:
LDX big_set + low_length_3
LDY #$60
STY big_set + low_length_3
LDY #<length_
JSR big_set
STX big_set + low_length_3
RTS
.endproc
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;; Sets memory in 'A'-registry to all addresses from 'A_start' until 'A_start' + 'length'
;; Modifies A, X and A_start
.proc memset
.include "mem.inc"
;; big_set sets the memory in $ff chunks.
;; skipp if length >= $ff
LDX length +1
BNE big_set
JMP small_set
big_set: ;sets $ff of memory
;; Y value do not matter, will go through all anyway!
.repeat $ff
STA (A_start), Y
DEY
.endrepeat
STA (A_start), Y ; dont forget Y =0
big_set_end:
;;set all hole $ff memory chunks!
INC A_start + 1
DEX ;; length +1 --
BEQ small_set
JMP big_set
;;sets the rest of the memory
;; note that this can use code above (smc) or the same method. may implement later.
small_set:
LDY length
small_set_loop:
STA (A_start), Y
DEY
BNE small_set_loop
STA (A_start), Y
RTS
.endproc

View file

@ -0,0 +1,75 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;; Sets memory in 'A'-registry to all addresses from 'A_start' until 'A_start' + 'length'
;; Modifies A, X and A_start
.proc memset
.include "mem.inc"
;; big_set sets the memory in $ff chunks.
;; skipp if length >= $ff
LDX length +1
BNE big_set
JMP small_set
big_set: ;sets $ff of memory
;; Y value do not matter, will go through all anyway!
.repeat $ff
STA (A_start), Y
DEY
.endrepeat
STA (A_start), Y ; dont forget Y =0
big_set_end:
;;set all hole $ff memory chunks!
INC A_start + 1
DEX ;; length +1 --
BEQ small_set
JMP big_set
small_set:
STA data_to_write
LDA length
STA length_copy
;; calculate rts-position
LDX #$00
STX length + 1
;; 3 bytes = STA DEY NOP = seting 1 byte of memory.
;; So we need to calculate: length*3
Mult_16 A, length + 1
; A= length
ADC length_copy
TAY
LDA length + 1
ADC #$00
STA length + 1
;; Now RTS_pointer + Y = length*3 + big_set_label
LDA #<big_set
STA RTS_pointer
LDA #>big_set
ADC length + 1
STA RTS_pointer + 1
;; read data we will change to RTS
STY Y_copy
LDA (RTS_pointer), Y
TAX
;; set RTS in big_set
LDA #$60
STA (RTS_pointer), Y
;; JSR to modified big_set
LDY length_copy
DEY ; because we want to count to Y=0 :)
LDA data_to_write
JSR big_set
;; revert changes
LDY Y_copy
TXA
STA (RTS_pointer), Y
RTS
.endproc

View file

@ -3,6 +3,7 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
.debuginfo + ; Generate debug info
.org $080D
;;Macros
.include "macros/16aritmatic.s"
;;inc files
@ -11,31 +12,43 @@
.include "STARTUP.s"
;.include "dubbel_buffer/raster_irqs.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/text/char_draw_test.s"
.include "routines/pixel/pixel_test.s"
.include "routines/memory/memcpy_test.s"
.include "routines/memory/memset_test.s"
.include "mainloop.s"
.ifndef EMULATOR_PREVIEW
.include "loader.s"
.endif
;.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/text/char_draw_test.s"
;.include "routines/pixel/pixel_test.s"
;.include "routines/memory/memcpy_test.s"
;.include "routines/memory/memset_test.s"
;.include "routines/triangle/triangle_test.s"
exit:
JMP exit
.include "../wip-duuqnd/public.inc"
.include "public.inc"
.include "routines/line/line.s"
.include "routines/circle/circle.s"
.include "routines/triangle/triangle.s"
.include "routines/pixel/pixel_draw.s"
.include "routines/pixel/pixel_calc.s"
.include "routines/text/char_draw.s"
.include "routines/memory/memset.s"
.include "routines/memory/clear_screen.s"
.include "routines/memory/memset_alt.s"
.include "routines/memory/memcpy.s"
.include "routines/arithmatic/mult.s"
.include "routines/arithmatic/div.s"
.include "lookup_tables.s"
.ifdef EMULATOR_PREVIEW
batch_userprog:
.incbin "../userprog.bin"
.endif
.include "END.s"

View file

@ -50,8 +50,8 @@
;; TODO: Handle case of too many arguments (? not realistically needed)
t)
(defparameter +argvec-offset+ #x00)
(defparameter +varvec-offset+ #x08)
(defparameter +argvec-offset+ #xF0)
(defparameter +varvec-offset+ #x20)
(defmacro with-variable-allocations (allocations &body body)
`(let ((*variable-allocations* (make-hash-table)))

View file

@ -68,8 +68,8 @@
(parse-asm-declaration main-text)
(list name address declaration)))))
(defparameter *program-listing-filepath* #P"../../wip-hugo/program.lst")
(defparameter *program-build-filepath* #P"../../wip-hugo/build.sh")
(defparameter *program-listing-filepath* #P"../host/build/program.lst")
(defparameter *program-build-filepath* #P"../host/build.sh")
(defun check-for-asm-build-script ()
(do ((path *program-build-filepath*))

Some files were not shown because too many files have changed in this diff Show more