Skip to content

Instantly share code, notes, and snippets.

.include "macros.s"
NEWVIDEO = $c029
BORDERCOLOR = $e0c034
.org $800
main:
scanLineInterruptHandler:
.i8 ; Interrupt firmware calls us in 8-bit native mode so make sure assembler knows that
.a8
lda $e0c032 ; Clear scanline interrupt source
and #%11011111
sta $e0c032
clc
rtl
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
import sys,os,fileinput
def main(argv):
for line in fileinput.input():
bytes = line.lstrip(".byte ").rstrip('\n').split(',')
print(".byte ", end="")
; Display test string
lda #0
sta PARAM1_L
lda #$40 ; Actually address 0, but high bits must be 01
sta PARAM1_H
lda #<testString
sta PARAM2_L
lda #>testString
sta PARAM2_H
lda #0
ldx #$fc
CALL16 graphicsVramWriteByte,$0800
ldx #$84
CALL16 graphicsVramWriteByte,$0801
ldx #$84
CALL16 graphicsVramWriteByte,$0802
ldx #$84
CALL16 graphicsVramWriteByte,$0803
ldx #$fc
CALL16 graphicsVramWriteByte,$0804
.macro CALL16 subroutine,param16
lda #<param16
sta PARAM1_L
lda #>param16
sta PARAM1_H
jsr subroutine
.endmacro
ldx #$fc
CALL16 graphicsVramWriteByte,$0800
;;;;;;;;;;;;;;;;;;;;;;;
; graphicsVramWriteByte
; PARAM1 : Destination VRAM address in F18A, high 2 bits must be 01
; X : Byte to write
;
; Write a single byte to F18A's VRAM
;
graphicsVramWriteByte:
SAVE_AX
;;;;;;;;;;;;;;;;;;;;;;;
; graphicsModeText
;
; Begins text rendering mode
;
graphicsModeText:
SAVE_AX
F18AREGW $80,%00000000 ; Set M3 to 0 (dumb, but necessary)
F18AREGW $81,%01010000 ; Select Text mode (with M1,M2)
;;;;;;;;;;;;;;;;;;;;;;;
; graphicsVramWriteBlock
; PARAM1 : Destination VRAM address in F18A, high 2 bits must be 01
; PARAM2 : Source address in main RAM, must be page-aligned
; PARAM3 : Number of bytes to copy
;
; Write data to F18A's VRAM
;
; Trashes PARAM2
;
; Write to an F18A register. High 5 bits of regNum must be 10000
.macro F18AREGW regNum,dataByte
lda #dataByte
sta F18AREG1
lda #regNum
sta F18AREG1
.endmacro