Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define bcall(x) rst 28h \ .dw x
- .db $BB,$6D
- .org $9D95
- ld hl,teststr
- ld bc,teststr_end-teststr
- call sendBytes
- ld hl,str_success
- jr c,$+5
- ld hl,str_fail
- bcall(450Ah)
- bcall(452Eh)
- ret
- str_success:
- .db "Send success!",0
- str_fail:
- .db "Send failed :(",0
- teststr:
- .db "This is a test."
- teststr_end:
- ;==============================================
- ;==============================================
- ;==============================================
- sendBytes:
- ;Input:
- ; HL points to the bytes to send
- ; BC is the number of bytes to send
- ;Output:
- ; BC is the number of bytes remaning to be sent
- ; HL points to the bytes to be sent
- ; c is set upon success
- ; nc if failure
- push hl
- push bc
- ld a,c
- call sendByte
- pop bc
- push bc
- ld a,b
- call c,sendByte
- jp nc,sendBytes_fail
- or a
- .db $C2
- sendBytes_loop
- push hl
- push bc
- ld a,(hl)
- call sendByte
- sendBytes_fail:
- pop bc
- pop hl
- ret nc
- cpi
- jp pe,sendBytes_loop
- scf
- ret
- sendByte:
- ; c is set upon success
- ; nc if failure
- di
- ld e,a
- ld bc,$5503 ;Bit counter in b, bit mask in c
- ld a,%00000010
- out (0),a ;Indicate we are ready to send
- _:
- in a,(4)
- and 8
- jr z,_sendByte_ret
- in a,(0) ;Loop is 59 T-states maximum
- and c
- jr nz,-_
- out (0),a
- _:
- rrc e
- ccf
- rla
- sla b
- ccf
- rla
- out (0),a
- ex (sp),hl
- ex (sp),hl
- nop
- jr nz,-_
- ;need 37cc
- push hl
- pop hl
- scf
- sbc a,a
- inc a
- nop
- _sendByte_ret
- out (0),a
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement