Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite InitLinkMovementBuffer:: #1

Open
vulcandth opened this issue Aug 19, 2022 · 0 comments
Open

Rewrite InitLinkMovementBuffer:: #1

vulcandth opened this issue Aug 19, 2022 · 0 comments
Labels
Link Movement Branch Issues with Link Movement

Comments

@vulcandth
Copy link
Owner

InitLinkMovementBuffer::
ld a, [rSVBK]
push af
ld a, BANK(wLinkMovementSendRingBuffer)
ld [rSVBK], a
ld de, wLinkMovementSendRingBuffer
ld hl, wLinkMovementSendTailPointer
ld a, d
ld [hli], a
ld a, e
ld [hli], a
push de
pop hl
inc hl
ld d, h
ld e, l
ld hl, wLinkMovementSendHeadPointer
ld a, d
ld [hli], a
ld a, e
ld [hl], a
ld de, wLinkMovementReceivedRingBuffer
ld hl, wLinkMovementReceivedTailPointer
ld a, d
ld [hli], a
ld a, e
ld [hli], a
push de
pop hl
inc hl
ld d, h
ld e, l
ld hl, wLinkMovementReceivedHeadPointer
ld a, d
ld [hli], a
ld a, e
ld [hl], a
pop af
ld [rSVBK], a
ret

Lets rewrite this to:

InitLinkMovementBuffer::
	ld a, [rSVBK]
	push af
	ld a, BANK(wLinkMovementSendRingBuffer)
	ld [rSVBK], a

	ld hl, wLinkMovementSendTailPointer
	ld de, wLinkMovementSendRingBuffer
	ld a, d
	ld [hli], a
	ld a, e
	ld [hli], a
	
	; wLinkMovementSendHeadPointer
	inc de ; wLinkMovementReceiveRingBuffer + 1
	ld a, d
	ld [hli], a
	ld a, e
	ld [hl], a

	ld hl, wLinkMovementReceiveTailPointer
	ld de, wLinkMovementReceiveRingBuffer
	ld a, d
	ld [hli], a
	ld a, e
	ld [hli], a

	; wLinkMovementSendReceivePointer
	inc de ; wLinkMovementReceiveRingBuffer + 1
	ld a, d
	ld [hli], a
	ld a, e
	ld [hl], a

	pop af
	ld [rSVBK], a
	ret
@vulcandth vulcandth added the Link Movement Branch Issues with Link Movement label Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Link Movement Branch Issues with Link Movement
Projects
None yet
Development

No branches or pull requests

1 participant