Changes

Jump to: navigation, search

6502 Emulator Example Code

1,227 bytes added, 11:02, 4 March 2020
Fill the Bitmapped Display
[[Category:6502]][[Category:Assembly Language]][[Category:SPO600]]This is a collection of simple examples of [[6502]] code which will run in the [[6502 Emulator]]. To use this code, copy and paste one of these programs into the text box of the [http://6502.cdot.systems emulator].
 
'''This code is Copyright ©2020 Seneca College of Applied Arts and Technology. Each of these programs is free software; you can redistribute them and/or modify them under the terms of the [https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html|GNU General Public License] as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.'''
== Fill the Bitmapped Display ==
ldy #$00 ; index
lda #$07 ; colour code
loop: sta ($10),y ; store colour
iny ; increment index
bne loop ; branch until overflowpage done
inc $11 ; increment hi high byte of pointer
lda $11 ; load page number as colour
cpx $11 ; compare with max value
bne loop ; continue if not done
rts brk ; done - returnto debugger
== Place a Message on the Character Display ==
 
=== Without using the ROM routines ===
define SCREEN $f000
bne char
con edone: brk
text:
dcb "6","5","0","2",32,"w","a","s",32,"h","e","r","e",".",00
 
=== Using the ROM routines ===
 
; ROM routines
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
jsr SCINIT
ldy #$00
char: lda text,y
beq done
jsr CHROUT
iny
bne char
done: brk
text:
dcb "6","5","0","2",32,"w","a","s",32,"h","e","r","e",".",00
== Type on the Screen ==
; let the user type on the first page of character screen
; has blinking cursor!
; does not use ROM routines
; backspace works (non-destructive), arrows/ENTER don't
dcb 32,"k","e","y",32,"c","l","e","a","r","s"
dcb 00
 
== Additional Examples ==
 
Additional examples, as well as the source code for the emulator's ROM routines, are in a repository at https://github.com/ctyler/6502js-code

Navigation menu