6502js icon indicating copy to clipboard operation
6502js copied to clipboard

Display a character on screen

Open bonnefoi opened this issue 5 years ago • 4 comments

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

bonnefoi avatar Aug 25 '19 19:08 bonnefoi

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

BigEd avatar Dec 21 '19 14:12 BigEd

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

pmanolak avatar Aug 11 '20 07:08 pmanolak

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

BigEd avatar Aug 11 '20 07:08 BigEd

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

}`

ts-soft avatar Jul 15 '21 17:07 ts-soft