Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/scrom.asm
2 views
1
;;============================================================================
2
;;
3
;; SSSS tt lll lll
4
;; SS SS tt ll ll
5
;; SS tttttt eeee ll ll aaaa
6
;; SSSS tt ee ee ll ll aa
7
;; SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8
;; SS SS tt ee ll ll aa aa
9
;; SSSS ttt eeeee llll llll aaaaa
10
;;
11
;; Copyright (c) 1995-2012 by Bradford W. Mott, Stephen Anthony
12
;; and the Stella Team
13
;;
14
;; See the file "License.txt" for information on usage and redistribution of
15
;; this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
;;
17
;; $Id: scrom.asm,v 1.3 2005-06-16 01:11:29 stephena Exp $
18
;;============================================================================
19
;;
20
;; This file contains a "dummy" Supercharger BIOS for Stella. It is based
21
;; on routines developed by Eckhard Stolberg.
22
;;
23
;;============================================================================
24
25
processor 6502
26
27
VSYNC equ $00
28
VBLANK equ $01
29
WSYNC equ $02
30
COLUPF equ $08
31
COLUBK equ $09
32
CTRLPF equ $0a
33
PF0 equ $0d
34
PF1 equ $0e
35
PF2 equ $0f
36
RESP0 equ $10
37
RESP1 equ $11
38
AUDC0 equ $15
39
AUDF0 equ $17
40
AUDV0 equ $19
41
AUDV1 equ $1a
42
GRP0 equ $1b
43
GRP1 equ $1c
44
ENAM0 equ $1d
45
ENAM1 equ $1e
46
ENABL equ $1f
47
HMP0 equ $20
48
HMP1 equ $21
49
HMOVE equ $2a
50
51
;;
52
;; Entry point for multi-load reading
53
;;
54
org $F800
55
56
LDA $FA ; Grab the load number and store it in $80 where the
57
STA $80 ; emulator will grab it when it does the loading
58
JMP clrp7 ; Go clear page 7 of RAM bank 1 like the real SC
59
60
;;
61
;; Entry point for initial load (invoked when the system is reset)
62
;;
63
org $F80A
64
65
start SEI
66
CLD
67
68
;;
69
;; Clear page zero routine for initial load (e.g., RAM and TIA registers)
70
;;
71
LDY #$00
72
LDX #$00
73
ilclr STY $00,X
74
INX
75
BNE ilclr
76
77
JMP load
78
79
;;
80
;; Clear page 7 of RAM bank 1 (used for stars in the real SC)
81
;;
82
clrp7 LDX #$00
83
LDA $F006,X
84
LDA $FFF8
85
LDX #$00
86
mlclr3 LDA $F000
87
NOP
88
LDA $F700,X
89
DEX
90
BNE mlclr3
91
JMP load
92
93
;;
94
;; NOTE: The emulator does the actual reading of the new load when the
95
;; next instruction is accessed. The emulator expects the load number to
96
;; to be stored in location $80. As a side-effect the emulator sets $80
97
;; to contain the bank selection byte from the load's header and sets
98
;; $FE and $FF to contain the starting address from the load's header.
99
;;
100
load org $F850
101
102
;;
103
;; Copy code into page zero to do the bank switching
104
;;
105
LDX #$03
106
copy LDY code,X
107
STY $FA,X
108
DEX
109
BPL copy
110
111
;;
112
;; Clear some of the 2600's RAM and TIA registers like the real SC BIOS does
113
;;
114
LDY #$00
115
LDX #$28
116
mlclr1 STY $04,X
117
DEX
118
BPL mlclr1
119
120
LDX #$1C
121
mlclr2 STY $81,X
122
DEX
123
BPL mlclr2
124
125
;;
126
;; Display the "emulated" Supercharger loading progress bar
127
;;
128
;; Check if we should skip the loading progress bar
129
;; Note that the following code seems to never do a jump
130
;; However, the comparison value can be patched outside this code
131
;;
132
LDA #$FF
133
CMP #$00 ; patch this value to $FF outside ROM to do a jump
134
BNE startbars
135
JMP skipbars
136
137
;; Otherwise we display them
138
startbars:
139
LDA #$00
140
STA GRP0
141
STA GRP1
142
STA ENAM0
143
STA ENAM1
144
STA ENABL
145
STA AUDV0
146
STA AUDV1
147
STA COLUPF
148
STA VBLANK
149
150
LDA #$10
151
STA HMP1
152
STA WSYNC
153
LDX #$07
154
DEX
155
pos DEX
156
BNE pos
157
LDA #$00
158
STA HMP0
159
STA RESP0
160
STA RESP1
161
STA WSYNC
162
STA HMOVE
163
164
LDA #%00000101
165
STA CTRLPF
166
LDA #$FF
167
STA PF0
168
STA PF1
169
STA PF2
170
STA $84
171
STA $85
172
LDA #$F0
173
STA $83
174
LDA #$74
175
STA COLUBK
176
LDA #$0C
177
STA AUDC0
178
LDA #$1F
179
STA AUDF0
180
STA $82
181
LDA #$07
182
STA AUDV0
183
a1
184
LDX #$08
185
LDY #$00
186
a2
187
STA WSYNC
188
DEY
189
BNE a2
190
STA WSYNC
191
STA WSYNC
192
LDA #$02
193
STA WSYNC
194
STA VSYNC
195
STA WSYNC
196
STA WSYNC
197
STA WSYNC
198
LDA #$00
199
STA VSYNC
200
DEX
201
BPL a2
202
ASL $83
203
ROR $84
204
ROL $85
205
LDA $83
206
STA PF0
207
LDA $84
208
STA PF1
209
LDA $85
210
STA PF2
211
LDX $82
212
DEX
213
STX $82
214
STX AUDF0
215
CPX #$0A
216
BNE a1
217
218
LDA #%00000010
219
STA VBLANK
220
221
LDX #$1C
222
LDY #$00
223
STY AUDV0
224
STY COLUBK
225
clear:
226
STY $81,x
227
DEX
228
BPL clear
229
skipbars:
230
231
;;
232
;; Setup value to be stored in the bank switching control register
233
;;
234
LDX $80
235
CMP $F000,X
236
237
;;
238
;; Initialize A, X, Y, and SP registers
239
;;
240
LDA #$9a ;; This is patched outside the ROM to a random value
241
LDX #$FF
242
LDY #$00
243
TXS
244
245
;;
246
;; Execute the code to do bank switch and start running cartridge code
247
;;
248
JMP $FA
249
250
code dc.b $cd, $f8, $ff ;; CMP $fff8
251
dc.b $4c ;; JMP $????
252
253
254