Changes

Jump to: navigation, search

6502 Emulator

1,421 bytes added, 00:32, 31 January 2020
Peripherals and Memory Map
== Peripherals and Memory Map ==
The entire 64K address space is available and is populated with RAM except for peripheralsand a small ROM area.
There are four peripherals available:
* a 32x32 pixel bitmapped display at '''$0200-$05ff''', with one byte per pixel. The lowest four bits of each byte select one of 16 colours.
* an 80x25 character display at '''$f000-$7cff''', with one byte per pixel. Printable ASCII characters will be displayed. If the high-order bit is set, the character will be shown in <span style="background: black; color: white;">&nbsp;reverse video&nbsp;</span>.
* a read-only ROM chip is present at '''$fe00-$ffff'''; see below for details.
The Reset button clears the zero page, bitmap display, and character display, and resets the stack pointer (SP=$ff), program counter (PC=$0600), status register (P=$30), and the general purpose registers (A=X=Y=$00).
For more details, press the Notes button in the emulator.
 
== ROM Routines ==
These routines are defined in ROM:
* SCINIT $ff81 - Initialize and clear the character display
* CHRIN $ffcf - Input one character from keyboard (returns A)
* CHROUT $ffdw - Outputs one character (A) to the screen at the current cursor position. Screen will wrap/scroll appropriately. Printable characters and cursor codes ($80/$81/$82/$83 for up/right/left/down) as well as RETURN ($0d) are accepted. Printable ASCII codes with the high bit set will be printed in reverse video.
* SCREEN $ffed - Returns the character screen size in the X and Y registers.
* PLOT $fff0 - gets (CARRY=1) or sets (CARRY=0) the cursor position
 
If C=0: X,Y registers set the cursor position
Y:X is returned as a pointer to the current screen position
If C=1: X,Y registers return the current cursor position
A contains the character at the current cursor location
 
To use the ROM routines, these define directives may be pasted into your code:
 
define SCINIT $ff81 ; initialize/clear screen
define CHRIN $ffcf ; input character from keyboard
define CHROUT $ffd2 ; output character to screen
define SCREEN $ffed ; get screen size
define PLOT $fff0 ; get/set cursor coordinates
 
You can then access the routines by name using the <code>JSR</code> instruction:
 
jsr CHROUT
== Example Code ==
See the [[6502 Emulator Example Code]] page.

Navigation menu