88 lines
1.1 KiB
NASM
88 lines
1.1 KiB
NASM
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
|
|
|
;; Jumps to a routine via a table. Index goes in A register.
|
|
jumpwithtable:
|
|
tay
|
|
|
|
;; Set up pointer to jump table
|
|
pla
|
|
sta z:zscratch0
|
|
pla
|
|
sta z:zscratch1
|
|
|
|
tya
|
|
asl
|
|
tay
|
|
iny
|
|
|
|
lda (zscratch0),y
|
|
sta z:zscratch2
|
|
iny
|
|
lda (zscratch0),y
|
|
sta z:zscratch3
|
|
|
|
jmp (zscratch2)
|
|
|
|
printbyte:
|
|
inx
|
|
jsr printnyb
|
|
.repeat 4
|
|
lsr
|
|
.endrep
|
|
dex
|
|
jsr printnyb
|
|
rts
|
|
|
|
printnyb:
|
|
pha
|
|
and #$0f
|
|
cmp #$0a
|
|
bcc @number ;if nybble<$A then print a number, else letter
|
|
sec
|
|
sbc #$09 ;letters start at $01, so sub away 9
|
|
jmp @done
|
|
@number:
|
|
clc
|
|
adc #$30 ;print a number, starting at $30
|
|
@done:
|
|
sta VMBASE,x
|
|
pla
|
|
rts
|
|
|
|
;; Put string pointer into zscratch1+2
|
|
;; X position into X, y pos into Y
|
|
printstr:
|
|
lda scrlinelo,y
|
|
sta z:zscratch2
|
|
lda scrlinehi,y
|
|
sta z:zscratch3
|
|
|
|
txa
|
|
clc
|
|
adc z:zscratch2
|
|
sta z:zscratch2
|
|
lda z:zscratch3
|
|
adc #0
|
|
sta z:zscratch3
|
|
|
|
ldy #$00
|
|
@loop:
|
|
lda (zscratch0),y
|
|
beq @done
|
|
sta (zscratch2),y
|
|
iny
|
|
inx
|
|
jmp @loop
|
|
@done:
|
|
rts
|
|
|
|
keydown:
|
|
lda #$ff
|
|
sta DDRA
|
|
lda #$00
|
|
sta DDRB
|
|
stx PRA
|
|
tya
|
|
and PRB
|
|
rts
|
|
|