Screen display issue CPUEmulator

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Screen display issue CPUEmulator

whycatscantfly
Idk if it's an actual bug, but I found this forum when googling and this seems like the right place to put it

Whenever I set any pixels on the CPUEmulator screen to black, every 5th pixel is white instead of black
I noticed this when making my Fill.asm for project 4, and I know that it's not my code because when looking at the screen memory map, it's all -1 (1111111111111111), and other projects that I've made have the same issue. I'm running Windows 11, redownloaded the tools from the website, and have the latest version of java installed
Reply | Threaded
Open this post in threaded view
|

Re: Screen display issue CPUEmulator

WBahn
Administrator
First time that I've heard of anything like this. Reinstalled the N2T tools would have been my first suggestion, but you've already done that.

Go ahead and upload your ASM file and I will take a look at it, just to confirm that it is not the culprit if nothing else.
Reply | Threaded
Open this post in threaded view
|

Re: Screen display issue CPUEmulator

whycatscantfly
This post was updated on .
Sorry for my bad commenting, I didn't expect anyone but me to read this lol
Here's my fill.asm

NOD NOTE: File removed -- no longer needed.
Reply | Threaded
Open this post in threaded view
|

Re: Screen display issue CPUEmulator

WBahn
Administrator
Your program works just fine on my machine, so there is something wrong with your installation. I have no idea what. Do you have access to a different machine that you can install the tools on using the same files and see if it works on that machine?
Reply | Threaded
Open this post in threaded view
|

Re: Screen display issue CPUEmulator

dolomiti7
In reply to this post by whycatscantfly
This issue is linked to an incompatibility between the scaling of Windows, Java and the way the official tools are handling the screen output. I assume your Windows is set to 125% zoom factor. This leads to a problem in how the pixels of the screen output are scaled and effectively each 4 pixels from the nand2tetris screen output are mapped to 5 physical pixels on your screen. Therefore every 5th pixel on your screen appears blank. It is important to note that this is just an annoying issue how the screen is presented on your computer, but not a bug in the sense of the emulator.

There are a few ways to fix this:
- Install JDK version 8 in parallel and use it for the nand2tetris tools (this version was still ignoring Windows zoom settings).
or
- set your screen to 100% zoom rate
or
- edit the batch file that starts the tools and add the parameter -Dsun.java2d.uiScale=1.0 to the java call
  (start javaw -Dsun.java2d.uiScale=1.0 -classpath...)
Example for the CPU Emulator:
CPUEmulator.bat
Reply | Threaded
Open this post in threaded view
|

Re: Screen display issue CPUEmulator

whycatscantfly
I was just trying things out
my brother actually did this course last year and so I was trying to send his files over to see, and I was very confused when the same tools didn't work on my computer
I tried changing the .bat file and your solution works perfectly! (the window is a little small, but there's nothing I can do about that)

Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: Screen display issue CPUEmulator

WBahn
Administrator
Glad you got it fixed and so thankful to dolomiti7 for diagnosing the issue and offering a solution.
Reply | Threaded
Open this post in threaded view
|

Re: Screen display issue CPUEmulator

dolomiti7
In reply to this post by whycatscantfly
If you run into this problem and have a very high resolution (like a 4k screen), a scale factor of 1.0 may be hard to read on the screen. You can also change the scale factor to 2.0 in the batch file in such a case:

-Dsun.java2d.uiScale=2.0