pandora: fix readme and pxml version
[picodrive.git] / pico / pico / pico.c
... / ...
CommitLineData
1/*
2 * PicoDrive
3 * (C) notaz, 2008
4 * (C) irixxxx, 2024
5 *
6 * This work is licensed under the terms of MAME license.
7 * See COPYING file in the top-level directory.
8 */
9#include "../pico_int.h"
10
11// x: 0x03c - 0x19d
12// y: 0x1fc - 0x2f7
13// 0x2f8 - 0x3f3
14picohw_state PicoPicohw;
15
16
17
18PICO_INTERNAL void PicoReratePico(void)
19{
20 PicoPicoPCMRerate();
21 PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer + PicoPicohw.fifo_bytes;
22}
23
24static void PicoLinePico(void)
25{
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));
29}
30
31static void PicoResetPico(void)
32{
33 PicoPicoPCMResetN(1);
34 PicoPicoPCMStartN(1);
35 PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer;
36 PicoPicohw.fifo_bytes = 0;
37 PicoPicohw.r12 = 0;
38
39 PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
40
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 }
53}
54
55PICO_INTERNAL void PicoInitPico(void)
56{
57 elprintf(EL_STATUS, "Pico startup");
58 PicoLineHook = PicoLinePico;
59 PicoResetHook = PicoResetPico;
60
61 PicoIn.AHW = PAHW_PICO;
62 memset(&PicoPicohw, 0, sizeof(PicoPicohw));
63 PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
64}