Add loader.s
This commit is contained in:
parent
0734b19746
commit
1ebf191797
1 changed files with 112 additions and 0 deletions
112
wip-duuqnd/loader.s
Normal file
112
wip-duuqnd/loader.s
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
|
CLKMASK = %00000010
|
||||||
|
CTRL2 = $DC00
|
||||||
|
|
||||||
|
coldstart:
|
||||||
|
lda #$0
|
||||||
|
sta $400
|
||||||
|
waitstart:
|
||||||
|
lda $dc01
|
||||||
|
and #$01
|
||||||
|
bne waitstart
|
||||||
|
lda #$00
|
||||||
|
sta $d020
|
||||||
|
teststart:
|
||||||
|
jsr check_for_load_start
|
||||||
|
jmp $c000
|
||||||
|
beq teststart
|
||||||
|
bcs @error
|
||||||
|
jmp $c000
|
||||||
|
@error:
|
||||||
|
lda #0
|
||||||
|
sta $0400
|
||||||
|
rts
|
||||||
|
|
||||||
|
check_for_load_start:
|
||||||
|
lda #CLKMASK
|
||||||
|
bit CTRL2
|
||||||
|
bne start
|
||||||
|
lda #$00
|
||||||
|
rts
|
||||||
|
start:
|
||||||
|
sei
|
||||||
|
ldx #$02
|
||||||
|
stx $d020
|
||||||
|
ldy #$00
|
||||||
|
jmp new_byte
|
||||||
|
|
||||||
|
wait_for_bit_start:
|
||||||
|
lda #CLKMASK
|
||||||
|
@loop:
|
||||||
|
bit CTRL2
|
||||||
|
beq @loop
|
||||||
|
|
||||||
|
lda #CLKMASK
|
||||||
|
bit CTRL2
|
||||||
|
beq error
|
||||||
|
lda CTRL2
|
||||||
|
|
||||||
|
lsr
|
||||||
|
ror BYTE
|
||||||
|
bcc wait_for_bit_end
|
||||||
|
txa ; get the zero flag from X
|
||||||
|
beq @normal
|
||||||
|
dex
|
||||||
|
lda BYTE
|
||||||
|
sta LEN,x
|
||||||
|
txa
|
||||||
|
bne @notdone
|
||||||
|
;; Computing stop address
|
||||||
|
clc
|
||||||
|
lda LEN
|
||||||
|
adc z:progdest
|
||||||
|
sta stop
|
||||||
|
lda LEN+1
|
||||||
|
adc z:progdest+1
|
||||||
|
sta stop+1
|
||||||
|
jmp @notdone
|
||||||
|
@normal:
|
||||||
|
;; Byte finished, storing
|
||||||
|
lda BYTE
|
||||||
|
sta (progdest), y
|
||||||
|
inc z:progdest
|
||||||
|
bne @noinchi
|
||||||
|
inc z:progdest+1
|
||||||
|
@noinchi:
|
||||||
|
;; Comparing progdest against stop address
|
||||||
|
lda z:progdest
|
||||||
|
cmp stop
|
||||||
|
bne @notdone
|
||||||
|
lda z:progdest+1
|
||||||
|
cmp stop+1
|
||||||
|
bne @notdone
|
||||||
|
jmp done
|
||||||
|
@notdone:
|
||||||
|
new_byte:
|
||||||
|
lda #%10000000
|
||||||
|
sta BYTE
|
||||||
|
wait_for_bit_end:
|
||||||
|
lda #CLKMASK
|
||||||
|
@loop:
|
||||||
|
bit CTRL2
|
||||||
|
bne @loop
|
||||||
|
jmp wait_for_bit_start
|
||||||
|
|
||||||
|
done:
|
||||||
|
lda #$01
|
||||||
|
cli
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
|
||||||
|
error:
|
||||||
|
;; TODO
|
||||||
|
cli
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
BYTE = $400
|
||||||
|
LEN = $402
|
||||||
|
progdest = $fe
|
||||||
|
stop: .word $0000
|
||||||
|
loaded: .byte 0
|
Loading…
Add table
Reference in a new issue