-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathharness.asm
89 lines (78 loc) · 1.31 KB
/
harness.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
; harness
#include CONFIGFILE
#include "harness.def"
* = HARNESS
jmp mpeek
jmp spush
jmp spull
jmp stsx
jmp stxs
; these drivers should not change dptr
; poke .a into location indicated by dptr
; okay to clobber x and y
mpoke ldx dptr+1
cpx #>ROMSTART
bcc :+
; no writes to emulated ROM, cheaters
rts
; page unchanged? if so, skip all this nonsense
: cpx curpage
beq :++
; map the high byte maps onto the geoRAM page registers
stx curpage ; cache it
cpx #64
bcs :+
; below $4000, direct mapping
stx $dffe
ldx #0
stx $dfff
ldx dptr
sta $de00,x
rts
; $4000 and up indirect mapping, convert to block and bank
: tay
txa
and #63
sta $dffe
txa
and #192
clc ; carry is still set
rol
rol
rol
sta $dfff
tya
: ldx dptr
sta $de00,x
rts
; load .a with location indicated by dptr
mpeek MPEEK(dptr) ; use inline version
rts
; push .a onto stack (must maintain stack pointer itself)
; allow stack to overflow
spush ldx sptr
ldy #0
sty $dfff
ldy #1
sty $dffe ; select page 1
sty curpage
sta $de00,x
dec sptr
rts
; pull .a from stack (must maintain stack pointer itself)
; allow stack to underflow
spull inc sptr
ldx sptr
ldy #0
sty $dfff
ldy #1
sty $dffe ; select page 1
sty curpage
lda $de00,x
rts
; emulate tsx
stsx ldx sptr
rts
; emulate txs
stxs stx sptr
rts