the old-new win32 port
[picodrive.git] / platform / win32 / GenaDrive / Emu.cpp
1 \r
2 #include "app.h"\r
3 \r
4 unsigned short *EmuScreen=NULL;\r
5 int EmuWidth=320,EmuHeight=224;\r
6 RECT EmuScreenRect = { 0, 0, 320, 224 };\r
7 int PicoPadAdd = 0;\r
8 \r
9 static int EmuScan(unsigned int num);\r
10 unsigned char *PicoDraw2FB = NULL;\r
11 \r
12 int EmuInit()\r
13 {\r
14   int len=0;\r
15 \r
16   PicoInit();\r
17 \r
18   // Allocate screen:\r
19   EmuWidth=320; EmuHeight=224;\r
20   len=EmuWidth*EmuHeight; len<<=1;\r
21   EmuScreen=(unsigned short *)malloc(len); if (EmuScreen==NULL) return 1;\r
22   PicoDraw2FB=(unsigned char *)malloc((8+320)*(8+224+8)*2);\r
23   memset(EmuScreen,0,len);\r
24 \r
25   PicoDrawSetColorFormat(1);\r
26   PicoScanBegin=EmuScan;\r
27 \r
28   return 0;\r
29 }\r
30 \r
31 void EmuExit()\r
32 {\r
33   //RomFree();\r
34   free(EmuScreen); EmuScreen=NULL; // Deallocate screen\r
35   free(PicoDraw2FB);\r
36   EmuWidth=EmuHeight=0;\r
37 \r
38   PicoExit();\r
39 }\r
40 \r
41 // Megadrive scanline callback:\r
42 static int EmuScan(unsigned int num)\r
43 {\r
44   DrawLineDest=EmuScreen+(num<<8)+(num<<6);\r
45   \r
46   return 0;\r
47 }\r
48 \r
49 int EmuFrame()\r
50 {\r
51   char map[12]={0,1,2,3,8,9,10,4,11,12,13,14};  // Joypads, format is UDLR BCAS ZYXM\r
52   int a=0,input=0;\r
53  \r
54   // Set Megadrive buttons:\r
55   for (a=0;a<12;a++)\r
56   {\r
57     int m=map[a];\r
58     if (m>=0) if (Inp.button[m]>30) input|=1<<a;\r
59   }\r
60 \r
61   PicoPad[0]=input;\r
62   PicoPad[0]|=PicoPadAdd;\r
63 \r
64   PsndOut=(short *)DSoundNext;\r
65   PicoFrame();\r
66   PsndOut=NULL;\r
67 \r
68   return 0;\r
69 }\r
70 \r
71 \r
72 void mp3_update(int *buffer, int length, int stereo)\r
73 {\r
74 }\r
75 \r
76 void mp3_start_play(FILE *f, int pos)\r
77 {\r
78 }\r
79 \r
80 int mp3_get_bitrate(FILE *f, int size)\r
81 {\r
82   return -1;\r
83 }\r
84 \r