skilldrick / 6502js

A JavaScript 6502 assembler and simulator
GNU General Public License v3.0
483 stars 142 forks source link

Display a character on screen #8

Open bonnefoi opened 5 years ago

bonnefoi commented 5 years ago

I've not found a way to display a simple character on screen. Could add this functionality ?

BigEd commented 4 years ago

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
pmanolak commented 4 years ago

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

BigEd commented 4 years ago

Sounds like your local copy is out of date: git pull might fix that. If not, try git status and paste its output.

ts-soft commented 3 years ago

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

}`