2019-05-07 15:26:52 -04:00
|
|
|
#include "jumptable.inc"
|
|
|
|
.org 0x9000
|
|
|
|
|
2019-05-08 16:03:54 -04:00
|
|
|
call JUMP_SDCINITALIZE
|
|
|
|
or a
|
2019-05-07 17:28:07 -04:00
|
|
|
jp nz, .error
|
|
|
|
|
|
|
|
; Alright, normally we should configure block size and all, but this is
|
|
|
|
; too exciting and we'll play it dirty: we'll read just enough bytes
|
|
|
|
; to fetch our "Hello World!" and print it and we'll leave the SD card
|
|
|
|
; hanging. Yeah, I know, not very polite.
|
|
|
|
|
|
|
|
|
|
|
|
out (5), a
|
|
|
|
ld hl, sCmd
|
|
|
|
call JUMP_PRINTSTR
|
|
|
|
ld a, 0b01010001 ; CMD17
|
|
|
|
ld hl, 0 ; read single block at addr 0
|
|
|
|
ld de, 0
|
|
|
|
call JUMP_SDCCMD
|
|
|
|
cp 0
|
|
|
|
jr nz, .error
|
|
|
|
|
|
|
|
ld hl, sCmd
|
|
|
|
call JUMP_PRINTSTR
|
|
|
|
; Command sent, no error, now let's wait for our data response.
|
|
|
|
ld b, 20
|
2019-05-08 16:03:54 -04:00
|
|
|
.loop1:
|
2019-05-07 17:28:07 -04:00
|
|
|
call JUMP_SDCWAITRESP
|
|
|
|
; 0xfe is the expected data token for CMD17
|
|
|
|
cp 0xfe
|
2019-05-08 16:03:54 -04:00
|
|
|
jr z, .loop1end
|
2019-05-07 17:28:07 -04:00
|
|
|
cp 0xff
|
|
|
|
jr nz, .error
|
2019-05-08 16:03:54 -04:00
|
|
|
djnz .loop1
|
2019-05-07 17:28:07 -04:00
|
|
|
jr .error
|
|
|
|
|
2019-05-08 16:03:54 -04:00
|
|
|
.loop1end:
|
2019-05-07 17:28:07 -04:00
|
|
|
ld hl, sGettingData
|
|
|
|
call JUMP_PRINTSTR
|
|
|
|
; Data packets follow immediately
|
|
|
|
ld b, 12 ; size of "Hello World!"
|
|
|
|
ld hl, sDest ; sDest has null chars, we'll be alright
|
|
|
|
; printing it.
|
|
|
|
.loop2:
|
|
|
|
call JUMP_SDCWAITRESP
|
|
|
|
ld (hl), a
|
|
|
|
inc hl
|
|
|
|
djnz .loop2
|
|
|
|
out (6), a
|
|
|
|
ld hl, sDest
|
|
|
|
call JUMP_PRINTSTR
|
2019-05-07 16:20:28 -04:00
|
|
|
ret
|
|
|
|
.error:
|
2019-05-07 17:28:07 -04:00
|
|
|
call JUMP_PRINTHEX
|
2019-05-07 16:20:28 -04:00
|
|
|
ld hl, sErr
|
|
|
|
call JUMP_PRINTSTR
|
2019-05-07 15:26:52 -04:00
|
|
|
ret
|
2019-05-07 16:20:28 -04:00
|
|
|
|
2019-05-07 17:28:07 -04:00
|
|
|
sCmd:
|
|
|
|
.db "CMD", 0xa, 0xd, 0
|
|
|
|
sGettingData:
|
|
|
|
.db "Data", 0xa, 0xd, 0
|
2019-05-07 16:20:28 -04:00
|
|
|
sOk:
|
|
|
|
.db "Ok", 0xa, 0xd, 0
|
|
|
|
sErr:
|
|
|
|
.db "Err", 0xa, 0xd, 0
|
2019-05-07 17:28:07 -04:00
|
|
|
|
|
|
|
sDest:
|
|
|
|
.fill 0x10
|