-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpcengine.inc
626 lines (496 loc) · 14 KB
/
pcengine.inc
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
; ***************************************************************************
; ***************************************************************************
;
; pcengine.inc
;
; Definitions for PC Engine hardware and System Card variables/functions.
;
; Distributed under the Boost Software License, Version 1.0.
; (See accompanying file LICENSE_1_0.txt or copy at
; http://www.boost.org/LICENSE_1_0.txt)
;
; ***************************************************************************
; ***************************************************************************
; ***************************************************************************
;
; HuC6270 - Video Display Controller
;
VDC_SR = $0000 ; Status Register
VDC_AR = $0000 ; Address Register
VDC_DL = $0002 ; Data (Read/Write) Low
VDC_DH = $0003 ; Data (Read/Write) High
SGX_SR = $0010 ; Status Register
SGX_AR = $0010 ; Address Register
SGX_DL = $0012 ; Data (Read/Write) Low
SGX_DH = $0013 ; Data (Read/Write) High
VDC_MAWR = 0 ; Memory Address Write
VDC_MARR = 1 ; Memory Address Read
VDC_VWR = 2 ; VRAM Data Write
VDC_VRR = 2 ; VRAM Data Read
VDC_CR = 5 ; Control
VDC_RCR = 6 ; Raster Counter Register
VDC_BXR = 7 ; BGX Scroll
VDC_BYR = 8 ; BGY Scroll
VDC_MWR = 9 ; Memory Access Width
VDC_HSR = 10 ; Horizontal Sync
VDC_HDR = 11 ; Horizontal Display
VDC_VPR = 12 ; Vertical Sync
VDC_VDW = 13 ; Vertical Display
VDC_VCR = 14 ; Vertical Display End Position
VDC_DCR = 15 ; Block Transfer Control
VDC_SOUR = 16 ; Block Transfer Source
VDC_DESR = 17 ; Block Transfer Destination
VDC_LENR = 18 ; Block Transfer Length
VDC_DVSSR = 19 ; VRAM-SATB Block Transfer Source
; ***************************************************************************
;
; HuC6202 - Video Priority Controller (SGX-only)
;
VPC_CR = $0008
VPC_CRL = $0008
VPC_CRH = $0009
VPC_WIN1 = $000A
VPC_WIN1L = $000A
VPC_WIN1H = $000B
VPC_WIN2 = $000C
VPC_WIN2L = $000C
VPC_WIN2H = $000D
VPC_VDC_REDIR = $000E
; ***************************************************************************
;
; HuC6260 - Video Color Encoder
;
; Palette Data is 0000000gggrrrbbb
;
VCE_CR = $0400 ; Control Register
VCE_CTA = $0402 ; Color Table Address
VCE_CTW = $0404 ; Color Table Data Write
VCE_CTR = $0404 ; Color Table Data Read
; ***************************************************************************
;
; HuC6280 - Programmable Sound Generator
;
PSG_R0 = $0800 ; Channel Select
PSG_R1 = $0801 ; Main Amplitude Level
PSG_R2 = $0802 ; Frequency Low
PSG_R3 = $0803 ; Frequency High
PSG_R4 = $0804 ; Control & Channel Amplitude
PSG_R5 = $0805 ; L/R Amplitude Level
PSG_R6 = $0806 ; Waveform
PSG_R7 = $0807 ; Noise
PSG_R8 = $0808 ; LFO Frequency
PSG_R9 = $0809 ; LFO Control
PSG_AR = $0800 ; Channel Select
PSG_MAL = $0801 ; Main Amplitude Level
PSG_FL = $0802 ; Frequency Low
PSG_FH = $0803 ; Frequency High
PSG_CR = $0804 ; Control & Channel Amplitude
PSG_LRAL = $0805 ; L/R Amplitude Level
PSG_WF = $0806 ; Waveform
PSG_NZ = $0807 ; Noise
PSG_LFO_FRQ = $0808 ; LFO Frequency
PSG_LFO_CR = $0809 ; LFO Control
; ***************************************************************************
;
; HuC6280 - Timer
;
TIMER_DR = $0C00 ; Timer Data
TIMER_CR = $0C01 ; Timer Control
; ***************************************************************************
;
; HuC6280 - I/O Port
;
IO_PORT = $1000
JOY_L = $80
JOY_D = $40
JOY_R = $20
JOY_U = $10
JOY_RUN = $08
JOY_SEL = $04
JOY_B2 = $02
JOY_B1 = $01
PORT_CLR = $02
PORT_SEL = $01
; ***************************************************************************
;
; HuC6280 - Interrupt Control
;
IRQ_MSK = $1402 ; Interrupt Disable
IRQ_REQ = $1403 ; Interrupt Request
IRQ_ACK = $1403 ; Interrupt Acknowledge
; ***************************************************************************
;
; CDROM/ADPCM hardware registers.
;
IFU_SCSI_CTRL = $1800 ; -W : SCSI control signals out.
IFU_SCSI_FLGS = $1800 ; R- : SCSI control signals in.
IFU_SCSI_DATA = $1801 ; RW : SCSI data bus.
IFU_SCSI_ACK = $1802
IFU_IRQ_CTL = $1802
IFU_IRQ_FLG = $1803 ; flags reporting CD/ADPCM info.
IFU_HW_RESET = $1804
IFU_SCSI_AUTO = $1808 ; RO - SCSI auto-handshake read.
IFU_ADPCM_LSB = $1808
IFU_ADPCM_MSB = $1809
IFU_ADPCM_DAT = $180A
IFU_ADPCM_DMA = $180B
IFU_ADPCM_FLG = $180C
IFU_ADPCM_CTL = $180D
IFU_ADPCM_SPD = $180E
IFU_AUDIO_FADE = $180F
IFU_BRAM_LOCK = $1803
IFU_BRAM_UNLOCK = $1807
; IFU interrupt bits in IFU_IRQ_CTL/IFU_IRQ_FLG
IFU_INT_HALF = $04 ; ADPCM < 50% remaining.
IFU_INT_STOP = $08 ; ADPCM finished.
IFU_INT_SUB = $10
IFU_INT_MSG_IN = $20 ; SCSI MIN phase.
IFU_INT_DAT_IN = $40 ; SCSI DIN phase.
; ADPCM control bits in IFU_ADPCM_CTL
ADPCM_WR_CLK = $01
ADPCM_SET_WR = $02
ADPCM_RD_CLK = $04
ADPCM_SET_RD = $08
ADPCM_SET_SZ = $10
ADPCM_PLAY = $20
ADPCM_INCR = $40
ADPCM_RESET = $80
; ADPCM status bits in IFU_ADPCM_FLG
ADPCM_AD_END = $01
ADPCM_WR_BSY = $04
ADPCM_AD_BSY = $08
ADPCM_RD_BSY = $80
; ***************************************************************************
;
; Arcade Card
;
ACD_DAT0 = $1A00 ; 2
ACD_ADR0 = $1A02 ; 2
ACD_OFF0 = $1A05 ; 2
ACD_INC0 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I3L = $1A37 ; 1
ACD_I3H = $1A38 ; 1
ACD_SHIFTREG = $1AE0 ; 4 bytes
ACD_ASL_CNT = $1AE4 ; positive = shift left
ACD_ROL_CNT = $1AE5 ; positive = shift left
ACD_VERL = $1AFD
ACD_VERH = $1AFE
ACD_FLAG = $1AFF
ACD_ID = $51 ; if ac_identflag = AC_IDENT, then AC in use
; ***************************************************************************
;
; System Card's Zero Page Variables.
;
zpg_psg_top = $20E6
time_sw = $20E6 ; psg irq mutex (NZ == already running)
main_sw = $20E7 ; psg driver mode ($80 == disable)
psg_si = $20E8 ;
psg_si_l = $20E8 ;
psg_si_h = $20E9 ;
psg_r0 = $20EA ;
psg_r0_l = $20EA ;
psg_r0_h = $20EB ;
zpg_sys_top = $20EC
__bp = $20EC ; base pointer
__si = $20EE ; source address
__di = $20F0 ; destination address
cdi_b = $20F2 ; ???
vdc_crl = $20F3 ; shadow of VDC control register (lo-byte)
vdc_crh = $20F4 ; shadow of VDC control register (hi-byte)
irq_vec = $20F5 ; interrupt vector control mask
vdc_sr = $20F6 ; shadow of VDC status register
vdc_reg = $20F7 ; shadow of VDC register index
__ax = $20F8
__al = $20F8
__ah = $20F9
__bx = $20FA
__bl = $20FA
__bh = $20FB
__cx = $20FC
__cl = $20FC
__ch = $20FD
__dx = $20FE
__dl = $20FE
__dh = $20FF
; ***************************************************************************
;
; System Card's Main RAM Variables.
;
irq2_hook = $2200 ; 2 officially called irq2_jmp
irq1_hook = $2202 ; 2 officially called irq_jmp
timer_hook = $2204 ; 2 officially called tim_jmp
nmi_hook = $2206 ; 2 officially called nmi_jmp
vsync_hook = $2208 ; 2 officially called sync_jmp
hsync_hook = $220A ; 2 officially called rcr_jmp
bg_x1 = $220C ; 2 officially called bgx1
bg_x2 = $220E ; 2
bg_y1 = $2210 ; 2
bg_y2 = $2212 ; 2
satb_addr = $2214 ; 2 officially called sat_adr
sprptr = $2216 ; 1
spryl = $2217 ; 1
spryh = $2218 ; 1
sprxl = $2219 ; 1
sprxh = $221A ; 1
sprnl = $221B ; 1
sprnh = $221C ; 1
spral = $221D ; 1
sprah = $221E ; 1
color_cmd = $221F ; 1
bgc_ptr = $2220 ; 2
bgc_len = $2222 ; 1
sprc_ptr = $2223 ; 2
sprc_len = $2225 ; 1
joyena = $2227 ; 1
joynow = $2228 ; 5 officially called joy
joytrg = $222D ; 5
joyold = $2232 ; 5
irq_cnt = $2241 ; 1
vdc_mwr = $2242 ; 1 officially called mwr_m
vdc_dcr = $2243 ; 1 officially called dcr_m
rndseed = $2249 ; 1
rndl = $2249 ; 1
rndh = $224A ; 1
rndm = $224B ; 1
; ...
tnomin = $226A ; 1
tnomax = $226B ; 1
outmin = $226C ; 1
outsec = $226D ; 1
outfrm = $226E ; 1
vdtin_flg = $2272 ; 1
recbase0_h = $2274 ; 1
recbase0_m = $2275 ; 1
recbase0_l = $2276 ; 1
recbase1_h = $2277 ; 1
recbase1_m = $2278 ; 1
recbase1_l = $2279 ; 1
;??? = $227A ; 1
scsists = $227B ; 1
suberrc = $227C ; 1
;??? = $227D ; 1
subcode = $227E ; 1
colortia = $2286 ; 8
;? = $228E ; ?
;mprsav = $22B5 ; 8 backups of MPR when BIOS needs major bank swapping.
ramend = $22D0 ; 1
psg_work_top = $22D0
psg_reg = $22ED ; 1 shadow for selected PSG register, like vdc_reg
; ...
graph_work_top = $2616
key_work_top = $2646
user_work_top = $267C
; ***************************************************************************
;
; System Card's Function Vectors
;
cd_boot = $E000
cd_reset = $E003
cd_base = $E006
cd_read = $E009
cd_seek = $E00C
cd_exec = $E00F
cd_play = $E012
cd_search = $E015
cd_pause = $E018
cd_stat = $E01B
cd_subq = $E01E
cd_dinfo = $E021
cd_contnts = $E024
cd_subrd = $E027
cd_pcmrd = $E02A
cd_fade = $E02D
ad_reset = $E030
ad_trans = $E033
ad_read = $E036
ad_write = $E039
ad_play = $E03C
ad_cplay = $E03F
ad_stop = $E042
ad_stat = $E045
bm_format = $E048
bm_free = $E04B
bm_read = $E04E
bm_write = $E051
bm_delete = $E054
bm_files = $E057
ex_getver = $E05A
ex_setvec = $E05D
ex_getfnt = $E060
ex_joysns = $E063
ex_joyrep = $E066
ex_scrsiz = $E069
ex_dotmod = $E06C
ex_scrmod = $E06F
ex_imode = $E072
ex_vmode = $E075
ex_hmode = $E078
ex_vsync = $E07B
ex_rcron = $E07E
ex_rcroff = $E081
ex_irqon = $E084
ex_irqoff = $E087
ex_bgon = $E08A
ex_bgoff = $E08D
ex_spron = $E090
ex_sproff = $E093
ex_dspon = $E096
ex_dspoff = $E099
ex_dmamod = $E09C
ex_sprdma = $E09F
ex_satclr = $E0A2
ex_sprput = $E0A5
ex_setrcr = $E0A8
ex_setred = $E0AB
ex_setwrt = $E0AE
ex_setdma = $E0B1
ex_binbcd = $E0B4
ex_bcdbin = $E0B7
ex_rnd = $E0BA
ma_mul8u = $E0BD
ma_mul8s = $E0C0
ma_mul16u = $E0C3
ma_div16s = $E0C6
ma_div16u = $E0C9
ma_sqrt = $E0CC
ma_sin = $E0CF
ma_cos = $E0D2
ma_atni = $E0D5
psg_bios = $E0D8
grp_bios = $E0DB
ex_memopen = $E0DE
psg_driver = $E0E1
ex_colorcmd = $E0E4
max_mapping = $FFF5
; ***************************************************************************
;
; System Card's PSG BIOS call functions.
;
PSG_ON = 0
PSG_OFF = 1
PSG_INIT = 2
PSG_BANK = 3
PSG_TRACK = 4
PSG_WAVE = 5
PSG_ENV = 6
PSG_FM = 7
PSG_PE = 8
PSG_PC = 9
PSG_TEMPO = 10
PSG_PLAY = 11
PSG_MSTAT = 12
PSG_SSTAT = 13
PSG_MSTOP = 14
PSG_SSTOP = 15
PSG_ASTOP = 16
PSG_MVOFF = 17
PSG_CONT = 18
PSG_FDOUT = 19
PSG_DCNT = 20
; ***************************************************************************
;
; Standard Display Timings.
;
; VDC constants for VRAM access speed.
VDC_MWR_1CYCLE = $0000
VDC_MWR_2CYCLE = $000A
; VDC constants for 240 & 256 wide display (Set VDC_MWR_1CYCLE).
VCE_CR_5MHz = $00 ; 43 chr (actually 42.8) -> 342 pixel slots.
VDC_HSR_224 = $0402 ; HDS HSW
VDC_HDR_224 = $061B ; HDE HDW
VDC_HSR_240 = $0302 ; HDS HSW
VDC_HDR_240 = $051D ; HDE HDW
VDC_HSR_256 = $0202 ; HDS HSW
VDC_HDR_256 = $041F ; HDE HDW
; VDC constants for 320 & 336 wide display (Set VDC_MWR_1CYCLE).
VCE_CR_7MHz = $01 ; 57 chr (actually 57.0) -> 456 pixel slots.
VDC_HSR_320 = $0503 ; HDS HSW
VDC_HDR_320 = $0627 ; HDE HDW
VDC_HSR_336 = $0403 ; HDS HSW
VDC_HDR_336 = $0529 ; HDE HDW
VDC_HSR_344 = $0403 ; HDS HSW
VDC_HDR_344 = $042A ; HDE HDW
VDC_HSR_352 = $0303 ; HDS HSW
VDC_HDR_352 = $042B ; HDE HDW
; VDC constants for 480 & 512 wide display (Set VDC_MWR_2CYCLE).
VCE_CR_10MHz = $02 ; 86 chr (actually 85.5) -> 684 pixel slots.
VDC_HSR_480 = $0D05 ; HDS HSW
VDC_HDR_480 = $053B ; HDE HDW
VDC_HSR_512 = $0B05 ; HDS HSW
VDC_HDR_512 = $033F ; HDE HDW
; VDC constants for 200, 224 & 240 high display.
;
; N.B. 2 lines higher on the screen than the System Card.
VDC_VPR_200 = $2102
VDC_VDW_200 = $00C7
VDC_VCR_200 = $0016 ; bios $00E2
VDC_VPR_208 = $1E02
VDC_VDW_208 = $00CF
VDC_VCR_208 = $0013 ; bios $00EE
VDC_VPR_224 = $1502
VDC_VDW_224 = $00DF
VDC_VCR_224 = $000B ; bios $00EE
VDC_VPR_240 = $0D02
VDC_VDW_240 = $00EF
VDC_VCR_240 = $0003 ; bios $00F6
; VDC constants for different BAT screen sizes.
VDC_MWR_32x32 = $0000
VDC_MWR_32x64 = $0040
VDC_MWR_64x32 = $0010
VDC_MWR_64x64 = $0050
VDC_MWR_128x32 = $0020
VDC_MWR_128x64 = $0060