Skip to content

Commit

Permalink
Add an option to the ROM menu to load a program from SDcard
Browse files Browse the repository at this point in the history
  • Loading branch information
zeldin committed Oct 1, 2022
1 parent a9c4ddf commit 3dbb331
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 1 deletion.
1 change: 1 addition & 0 deletions rom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ OBJS = $(OBJDIR)/entry.o
OBJS += $(OBJDIR)/player.o
OBJS += $(OBJDIR)/stream.o
OBJS += $(OBJDIR)/fileselector.o
OBJS += $(OBJDIR)/loader.o
OBJS += $(OBJDIR)/fileindexer.o
OBJS += $(OBJDIR)/index.o
OBJS += $(OBJDIR)/screen.o
Expand Down
11 changes: 10 additions & 1 deletion rom/source/entry.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

.import deselectmmc64, selectmmc64, stopcmd

.import fileselector, movie_player
.import fileselector, movie_player, loader


.zeropage
Expand Down Expand Up @@ -97,6 +97,9 @@ start:
scrcode "Press 1 for movie player@"
jsr nextrow
jsr printtext
scrcode "Press 2 to load program from SDcard@"
jsr nextrow
jsr printtext
scrcode "Press Q to quit into BASIC@"
jsr nextrow
lda isc128
Expand All @@ -120,12 +123,18 @@ wait_here:
bcc go128
lsr
lsr
bcc @sdload
lsr
lsr
lsr
bcc exit_to_basic
jmp wait_here

@sdload:
jsr fileselector
jsr loader
jmp start

@next_movie:
lda #0
sta $d020
Expand Down
133 changes: 133 additions & 0 deletions rom/source/loader.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

.macpack cbm

.export loader

.import initstream, getstreamdata

.importzp vreg

vartab = $2d
ndx = $c6
keyd = $277

loader:
ldx #0
stx $df04
stx $df05
stx $df06
lda #$40
sta $df09
stx $df0a
stx $df0b
inx
jsr initstream
lda #0
jsr getstreamdata
beq @no_data

lda #<vreg
sta $df02
lda #>vreg
sta $df03
lda #<2
sta $df07
lda #>2
sta $df08
lda #$91
sta $df01
jsr waitdma

lda vreg
sta $df02
lda vreg+1
sta $df03
lda #$fe
sta $df07
dex
stx $df08
lda #$81
sta $df01

sei
ldx #$ff
txs
cld
lda #$37
sta $01
lda #$2f
sta $00
lda #$0b
sta $d011
ldx #@stub_size-1
@copy_stub:
lda @stub,x
sta $102,x
dex
bpl @copy_stub
ldx #3
@copy_kbd:
lda kbd_data,x
sta keyd,x
dex
bpl @copy_kbd
lda #0
ldx #$37
ldy #%10100011
jmp $102

@no_data:
rts

@stub:
sty $de11
stx $01
tax
tay
jsr $ff84
jsr $ff87
jsr $ff8a
jsr $ff81
jsr $e453
jsr $e3bf
jsr $e422
lda #'r'
sta keyd
lda #'u'
sta keyd+1
lda #'n'
sta keyd+2
lda #$d
sta keyd+3
lda #4
sta ndx
sei
lda #$34
sta $01
sta $ff00
lda #$37
sta $01
lda $df02
sta vartab
lda $df03
sta vartab+1
cli
jmp $e39d

@stub_size = *-@stub


@feh:
inc $d020
jmp @feh


waitdma:
inc $d024
lda $df00
bpl waitdma
rts

kbd_data:
.byte "rub",$d

0 comments on commit 3dbb331

Please sign in to comment.