6502js
6502js copied to clipboard
Display a character on screen
I've not found a way to display a simple character on screen. Could add this functionality ?
You can use the WDM opcode to output a character to the debug text box - not quite what you're asking for perhaps. Try for example
LDA #$01
STA $0200
LDA #65
WDM 0
LDA #66
WDM 0
LDA #$05
STA $0201
I tried that but got a syntax error:
Indexing labels.. Found 0 labels. Assembling code ... **Syntax error line 4: WDM 0**
this occurs only when run the app locally but into the https://skilldrick.github.io/easy6502
Sounds like your local copy is out of date:
git pull
might fix that. If not, try
git status
and paste its output.
Looking at the source code, the author simply draws a small rectangle with a color at an indexed position in the small black window. At this point there isn't an attempt to draw a specific character, only a block of pixels of the specified color.
See line #198 in the assembler.js file.
`function updatePixel(addr) {
ctx.fillStyle = palette[memory.get(addr) & 0x0f]; // masks off any value in the second byte of the value in the screen location then sets the palette index 0 to 15 remains
var y = Math.floor((addr - 0x200) / 32); // index of row for the block
var x = (addr - 0x200) % 32; // index of column for the block
ctx.fillRect(x * pixelSize, y * pixelSize, pixelSize, pixelSize); // puts a rectangle of 32x32 pixels at the correct location, color was already set in the ctx.fillStyle() routine
}`