Add "main loop" to host program, which executes user program

This commit is contained in:
John Lorentzson 2025-07-24 15:29:55 +02:00
parent 677b6a2f56
commit c076aa2055

45
host/mainloop.s Normal file
View file

@ -0,0 +1,45 @@
;;; -*- 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
.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 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