cff531af |
1 | /* |
2 | * PicoDrive |
3 | * (C) notaz, 2008 |
f1b425e3 |
4 | * (C) irixxxx, 2024 |
cff531af |
5 | * |
6 | * This work is licensed under the terms of MAME license. |
7 | * See COPYING file in the top-level directory. |
8 | */ |
efcba75f |
9 | #include "../pico_int.h" |
9037e45d |
10 | |
406c96c5 |
11 | // x: 0x03c - 0x19d |
12 | // y: 0x1fc - 0x2f7 |
13 | // 0x2f8 - 0x3f3 |
d49b10c2 |
14 | picohw_state PicoPicohw; |
15 | |
d49b10c2 |
16 | |
fa22af4c |
17 | |
ed367a3f |
18 | PICO_INTERNAL void PicoReratePico(void) |
19 | { |
f1b425e3 |
20 | PicoPicoPCMRerate(); |
fa4e0531 |
21 | PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer + PicoPicohw.fifo_bytes; |
ed367a3f |
22 | } |
23 | |
b0677887 |
24 | static void PicoLinePico(void) |
d49b10c2 |
25 | { |
f1b425e3 |
26 | // update sound so that irq for FIFO refill is generated |
27 | if ((PicoPicohw.fifo_bytes | !PicoPicoPCMBusyN()) && (Pico.m.scanline & 7) == 7) |
28 | PsndDoPCM(cycles_68k_to_z80(SekCyclesDone() - Pico.t.m68c_frame_start)); |
d49b10c2 |
29 | } |
406c96c5 |
30 | |
ef4eb506 |
31 | static void PicoResetPico(void) |
32 | { |
f1b425e3 |
33 | PicoPicoPCMResetN(1); |
34 | PicoPicoPCMStartN(1); |
ef4eb506 |
35 | PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer; |
f1b425e3 |
36 | PicoPicohw.fifo_bytes = 0; |
37 | PicoPicohw.r12 = 0; |
38 | |
c87e36d7 |
39 | PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000; |
40 | |
f1b425e3 |
41 | PicoPicoPCMIrqEn(0); |
42 | PicoPicoPCMFilter(0); |
43 | PicoPicoPCMGain(8); |
44 | |
45 | // map version register |
46 | PicoDetectRegion(); |
47 | switch (Pico.m.hardware >> 6) { |
48 | case 0: PicoPicohw.r1 = 0x40; break; // JP NTSC |
49 | case 1: PicoPicohw.r1 = 0x00; break; // JP PAL |
50 | case 2: PicoPicohw.r1 = 0x60; break; // US |
51 | case 3: PicoPicohw.r1 = 0x20; break; // EU |
52 | } |
ef4eb506 |
53 | } |
54 | |
2aa27095 |
55 | PICO_INTERNAL void PicoInitPico(void) |
9037e45d |
56 | { |
45f2f245 |
57 | elprintf(EL_STATUS, "Pico startup"); |
ef4eb506 |
58 | PicoLineHook = PicoLinePico; |
59 | PicoResetHook = PicoResetPico; |
d49b10c2 |
60 | |
93f9619e |
61 | PicoIn.AHW = PAHW_PICO; |
d49b10c2 |
62 | memset(&PicoPicohw, 0, sizeof(PicoPicohw)); |
15cc45c0 |
63 | PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000; |
9037e45d |
64 | } |