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

Store Byte with Bitmap display #47

Closed
PedroAugustoRamalhoDuarte opened this issue Sep 17, 2019 · 4 comments
Closed

Store Byte with Bitmap display #47

PedroAugustoRamalhoDuarte opened this issue Sep 17, 2019 · 4 comments

Comments

@PedroAugustoRamalhoDuarte

I found an problem working accessing bytes to color bitmap display:

.data
init:		.word	0x10040000
.text
main:
	lw	t0, init 	# Heap adress
	li	t1, 0x00ff0000	# Red point to t1
	sw	t1, 0(t0)	# Paint the first dot with red
	addi	t0, t0, 4	# Jump 4 bytes
	
	li	t2, 0xff	
	sb	t2, 2(t0)	# Paint the second dot with red

In this code i am trying to color two points with red. For the first dot, i use SW and works fine, but when i try to use SB to the second dot, in the display appears that the point is Blue.
Display Config:
configdisplay
Result:
display
The memory is right:
mem

@TheThirdOne
Copy link
Owner

I'm not considering this a bug because the behavior is the same in MARS and the help isn't quite specific enough to say that lb is a valid way of setting memory for the tool.

The issue is that the pixels are updated by memory updates, but only expect them to be from word sized updates. The relevant code is

private void updateColorForAddress(MemoryAccessNotice notice) {
int address = notice.getAddress();
int value = notice.getValue();
int offset = (address - baseAddress) / Memory.WORD_LENGTH_BYTES;
try {
theGrid.setElement(offset / theGrid.getColumns(), offset % theGrid.getColumns(), value);
} catch (IndexOutOfBoundsException e) {
// If address is out of range for display, do nothing.
}
}

Getting this to work with lb and lh would just be a matter of updating that function to use the lower bits of the address to shift the value.

@PedroAugustoRamalhoDuarte PedroAugustoRamalhoDuarte changed the title Bug Store Byte with Bitmap display Store Byte with Bitmap display Sep 17, 2019
TheThirdOne added a commit that referenced this issue Sep 17, 2019
Addresses #47. I thought about using a bit mask to do this instead, but I think
most potential contributors wouldn't be comfortable with that. Instead I reference
memory which is technical debt as I plan to remove all such references at some
point.
@TheThirdOne
Copy link
Owner

I ended up implementing this in a slightly different way than I explained. The shifting based solution would zero out the non written areas which I don't think is what most users would expect. Masking out only the bytes would work, but used too much bit twiddling for my liking.

I decided to just access the relevant word from memory and send that to the display.

An updated build can be found at https://github.com/TheThirdOne/rars/releases/tag/continuous. Please confirm that it works as you would expect now.

@PedroAugustoRamalhoDuarte
Copy link
Author

Works fine, thanks!! I have test with sh and sb and the result is correct!!

@TheThirdOne
Copy link
Owner

Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants