Human68k CUI emulator with sound.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

v68iocscall.c 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <sys/sysinfo.h>
  5. #include "v68.h"
  6. #include "v68iocscall.h"
  7. #include "musashi/m68k.h"
  8. #include "musashi/m68kcpu.h"
  9. #include "sjis.h"
  10. #define IOCS_CALL_B_KEYINP 0x00
  11. #define IOCS_CALL_B_KEYSNS 0x01
  12. #define IOCS_CALL_B_SFTSNS 0x02
  13. #define IOCS_CALL_KEY_INIT 0x03
  14. #define IOCS_CALL_BITSNS 0x04
  15. #define IOCS_CALL_SKEYSET 0x05
  16. #define IOCS_CALL_LEDCTRL 0x06
  17. #define IOCS_CALL_LEDSET 0x07
  18. #define IOCS_CALL_KEYDLY 0x08
  19. #define IOCS_CALL_KEYREP 0x09
  20. #define IOCS_CALL_TVCTRL 0x0c
  21. #define IOCS_CALL_LEDMOD 0x0d
  22. #define IOCS_CALL_TGUSEMD 0x0e
  23. #define IOCS_CALL_DEFCHR 0x0f
  24. #define IOCS_CALL_CRTMOD 0x10
  25. #define IOCS_CALL_CONTRAST 0x11
  26. #define IOCS_CALL_HSVTORGB 0x12
  27. #define IOCS_CALL_TPALET 0x13
  28. #define IOCS_CALL_TPALET2 0x14
  29. #define IOCS_CALL_TCOLOR 0x15
  30. #define IOCS_CALL_FNTADR 0x16
  31. #define IOCS_CALL_VRAMGET 0x17
  32. #define IOCS_CALL_VRAMPUT 0x18
  33. #define IOCS_CALL_FNTGET 0x19
  34. #define IOCS_CALL_TEXTGET 0x1a
  35. #define IOCS_CALL_TEXTPUT 0x1b
  36. #define IOCS_CALL_CLIPPUT 0x1c
  37. #define IOCS_CALL_SCROLL 0x1d
  38. #define IOCS_CALL_B_CURON 0x1e
  39. #define IOCS_CALL_B_CUROFF 0x1f
  40. #define IOCS_CALL_B_PUTC 0x20
  41. #define IOCS_CALL_B_PRINT 0x21
  42. #define IOCS_CALL_B_COLOR 0x22
  43. #define IOCS_CALL_B_LOCATE 0x23
  44. #define IOCS_CALL_B_DOWN_S 0x24
  45. #define IOCS_CALL_B_UP_S 0x25
  46. #define IOCS_CALL_B_UP 0x26
  47. #define IOCS_CALL_B_DOWN 0x27
  48. #define IOCS_CALL_B_RIGHT 0x28
  49. #define IOCS_CALL_B_LEFT 0x29
  50. #define IOCS_CALL_B_CLR_ST 0x2a
  51. #define IOCS_CALL_B_ERA_ST 0x2b
  52. #define IOCS_CALL_B_INS 0x2c
  53. #define IOCS_CALL_B_DEL 0x2d
  54. #define IOCS_CALL_B_CONSOL 0x2e
  55. #define IOCS_CALL_B_PUTMES 0x2f
  56. #define IOCS_CALL_SET232C 0x30
  57. #define IOCS_CALL_LOF232C 0x31
  58. #define IOCS_CALL_INP232C 0x32
  59. #define IOCS_CALL_ISNS232C 0x33
  60. #define IOCS_CALL_OSNS232C 0x34
  61. #define IOCS_CALL_OUT232C 0x35
  62. #define IOCS_CALL_SETFNTADR 0x38
  63. #define IOCS_CALL_JOYGET 0x3b
  64. #define IOCS_CALL_INIT_PRN 0x3c
  65. #define IOCS_CALL_SNSPRN 0x3d
  66. #define IOCS_CALL_OUTLPT 0x3e
  67. #define IOCS_CALL_OUTPRN 0x3f
  68. #define IOCS_CALL_B_SEEK 0x40
  69. #define IOCS_CALL_B_VERIFY 0x41
  70. #define IOCS_CALL_B_READDI 0x42
  71. #define IOCS_CALL_B_DSKINI 0x43
  72. #define IOCS_CALL_B_DRVSNS 0x44
  73. #define IOCS_CALL_B_WRITE 0x45
  74. #define IOCS_CALL_B_READ 0x46
  75. #define IOCS_CALL_B_RECALI 0x47
  76. #define IOCS_CALL_B_ASSIGN 0x48
  77. #define IOCS_CALL_B_WRITED 0x49
  78. #define IOCS_CALL_B_READID 0x4a
  79. #define IOCS_CALL_B_BADFMT 0x4b
  80. #define IOCS_CALL_B_READDL 0x4c
  81. #define IOCS_CALL_B_FORMAT 0x4d
  82. #define IOCS_CALL_B_DRVCHK 0x4e
  83. #define IOCS_CALL_B_EJECT 0x4f
  84. #define IOCS_CALL_DATEBCD 0x50
  85. #define IOCS_CALL_DATESET 0x51
  86. #define IOCS_CALL_TIMEBCD 0x52
  87. #define IOCS_CALL_TIMESET 0x53
  88. #define IOCS_CALL_DATEGET 0x54
  89. #define IOCS_CALL_DATEBIN 0x55
  90. #define IOCS_CALL_TIMEGET 0x56
  91. #define IOCS_CALL_TIMEBIN 0x57
  92. #define IOCS_CALL_DATECNV 0x58
  93. #define IOCS_CALL_TIMECNV 0x59
  94. #define IOCS_CALL_DATEASC 0x5a
  95. #define IOCS_CALL_TIMEASC 0x5b
  96. #define IOCS_CALL_DAYASC 0x5c
  97. #define IOCS_CALL_ALARMMOD 0x5d
  98. #define IOCS_CALL_ALARMSET 0x5e
  99. #define IOCS_CALL_ALARMGET 0x5f
  100. #define IOCS_CALL_ADPCMOUT 0x60
  101. #define IOCS_CALL_ADPCMINP 0x61
  102. #define IOCS_CALL_ADPCMAOT 0x62
  103. #define IOCS_CALL_ADPCMAIN 0x63
  104. #define IOCS_CALL_ADPCMLOT 0x64
  105. #define IOCS_CALL_ADPCMLIN 0x65
  106. #define IOCS_CALL_ADPCMSNS 0x66
  107. #define IOCS_CALL_ADPCMMOD 0x67
  108. #define IOCS_CALL_OPMSET 0x68
  109. #define IOCS_CALL_OPMSNS 0x69
  110. #define IOCS_CALL_OPMINTST 0x6a
  111. #define IOCS_CALL_TIMERDST 0x6b
  112. #define IOCS_CALL_VDISPST 0x6c
  113. #define IOCS_CALL_CRTCRAS 0x6d
  114. #define IOCS_CALL_HSYNCST 0x6e
  115. #define IOCS_CALL_PRNINTST 0x6f
  116. #define IOCS_CALL_MS_INIT 0x70
  117. #define IOCS_CALL_MS_CURON 0x71
  118. #define IOCS_CALL_MS_CUROF 0x72
  119. #define IOCS_CALL_MS_STAT 0x73
  120. #define IOCS_CALL_MS_GETDT 0x74
  121. #define IOCS_CALL_MS_CURGT 0x75
  122. #define IOCS_CALL_MS_CURST 0x76
  123. #define IOCS_CALL_MS_LIMIT 0x77
  124. #define IOCS_CALL_MS_OFFTM 0x78
  125. #define IOCS_CALL_MS_ONTM 0x79
  126. #define IOCS_CALL_MS_PATST 0x7a
  127. #define IOCS_CALL_MS_SEL 0x7b
  128. #define IOCS_CALL_MS_SEL2 0x7c
  129. #define IOCS_CALL_SKEY_MOD 0x7d
  130. #define IOCS_CALL_DENSNS 0x7e
  131. #define IOCS_CALL_ONTIME 0x7f
  132. #define IOCS_CALL_B_INTVCS 0x80
  133. #define IOCS_CALL_B_SUPER 0x81
  134. #define IOCS_CALL_B_BPEEK 0x82
  135. #define IOCS_CALL_B_WPEEK 0x83
  136. #define IOCS_CALL_B_LPEEK 0x84
  137. #define IOCS_CALL_B_MEMSTR 0x85
  138. #define IOCS_CALL_B_BPOKE 0x86
  139. #define IOCS_CALL_B_WPOKE 0x87
  140. #define IOCS_CALL_B_LPOKE 0x88
  141. #define IOCS_CALL_B_MEMSET 0x89
  142. #define IOCS_CALL_DMAMOVE 0x8a
  143. #define IOCS_CALL_DMAMOV_A 0x8b
  144. #define IOCS_CALL_DMAMOV_L 0x8c
  145. #define IOCS_CALL_DMAMODE 0x8d
  146. #define IOCS_CALL_BOOTINF 0x8e
  147. #define IOCS_CALL_ROMVER 0x8f
  148. #define IOCS_CALL_G_CLR_ON 0x90
  149. #define IOCS_CALL_GPALET 0x94
  150. #define IOCS_CALL_SFTJIS 0xa0
  151. #define IOCS_CALL_JISSFT 0xa1
  152. #define IOCS_CALL_AKCONV 0xa2
  153. #define IOCS_CALL_RMACNV 0xa3
  154. #define IOCS_CALL_DAKJOB 0xa4
  155. #define IOCS_CALL_HANJOB 0xa5
  156. #define IOCS_CALL_SYS_STAT 0xac
  157. #define IOCS_CALL_B_CONMOD 0xad
  158. #define IOCS_CALL_OS_CURON 0xae
  159. #define IOCS_CALL_OS_CUROF 0xaf
  160. #define IOCS_CALL_DRAWMODE 0xb0
  161. #define IOCS_CALL_APAGE 0xb1
  162. #define IOCS_CALL_VPAGE 0xb2
  163. #define IOCS_CALL_HOME 0xb3
  164. #define IOCS_CALL_WINDOW 0xb4
  165. #define IOCS_CALL_WIPE 0xb5
  166. #define IOCS_CALL_PSET 0xb6
  167. #define IOCS_CALL_POINT 0xb7
  168. #define IOCS_CALL_LINE 0xb8
  169. #define IOCS_CALL_BOX 0xb9
  170. #define IOCS_CALL_FILL 0xba
  171. #define IOCS_CALL_CIRCLE 0xbb
  172. #define IOCS_CALL_PAINT 0xbc
  173. #define IOCS_CALL_SYMBOL 0xbd
  174. #define IOCS_CALL_GETGRM 0xbe
  175. #define IOCS_CALL_PUTGRM 0xbf
  176. #define IOCS_CALL_SP_INIT 0xc0
  177. #define IOCS_CALL_SP_ON 0xc1
  178. #define IOCS_CALL_SP_OFF 0xc2
  179. #define IOCS_CALL_SP_CGCLR 0xc3
  180. #define IOCS_CALL_SP_DEFCG 0xc4
  181. #define IOCS_CALL_SP_GTPCG 0xc5
  182. #define IOCS_CALL_SP_REGST 0xc6
  183. #define IOCS_CALL_SP_REGGT 0xc7
  184. #define IOCS_CALL_BGSCRLST 0xc8
  185. #define IOCS_CALL_BGSCRLGT 0xc9
  186. #define IOCS_CALL_BGCTRLST 0xca
  187. #define IOCS_CALL_BGCTRLGT 0xcb
  188. #define IOCS_CALL_BGTEXTCL 0xcc
  189. #define IOCS_CALL_BGTEXTST 0xcd
  190. #define IOCS_CALL_BGTEXTGT 0xce
  191. #define IOCS_CALL_SPALET 0xcf
  192. #define IOCS_CALL_TXXLINE 0xd3
  193. #define IOCS_CALL_TXYLINE 0xd4
  194. #define IOCS_CALL_TXLINE 0xd5
  195. #define IOCS_CALL_TXBOX 0xd6
  196. #define IOCS_CALL_TXFILL 0xd7
  197. #define IOCS_CALL_TXREV 0xd8
  198. #define IOCS_CALL_OPMDRV 0xf0
  199. #define IOCS_CALL_RSDRV 0xf1
  200. #define IOCS_CALL_A_JOYGET 0xf2
  201. #define IOCS_CALL_MUSICDRV 0xf3
  202. #define IOCS_CALL_SCSIDRV 0xf5
  203. #define IOCS_CALL_ABORTRST 0xfd
  204. #define IOCS_CALL_IPLERR 0xfe
  205. #define IOCS_CALL_ABORTJOB 0xff
  206. static const char *iocs_call_names[256] = {
  207. /* 0x00 */ "_B_KEYINP",
  208. /* 0x01 */ "_B_KEYSNS",
  209. /* 0x02 */ "_B_SFTSNS",
  210. /* 0x03 */ "_KEY_INIT",
  211. /* 0x04 */ "_BITSNS",
  212. /* 0x05 */ "_SKEYSET",
  213. /* 0x06 */ "_LEDCTRL",
  214. /* 0x07 */ "_LEDSET",
  215. /* 0x08 */ "_KEYDLY",
  216. /* 0x09 */ "_KEYREP",
  217. /* 0x0a */ "?",
  218. /* 0x0b */ "?",
  219. /* 0x0c */ "_TVCTRL",
  220. /* 0x0d */ "_LEDMOD",
  221. /* 0x0e */ "_TGUSEMD",
  222. /* 0x0f */ "_DEFCHR",
  223. /* 0x10 */ "_CRTMOD",
  224. /* 0x11 */ "_CONTRAST",
  225. /* 0x12 */ "_HSVTORGB",
  226. /* 0x13 */ "_TPALET",
  227. /* 0x14 */ "_TPALET2",
  228. /* 0x15 */ "_TCOLOR",
  229. /* 0x16 */ "_FNTADR",
  230. /* 0x17 */ "_VRAMGET",
  231. /* 0x18 */ "_VRAMPUT",
  232. /* 0x19 */ "_FNTGET",
  233. /* 0x1a */ "_TEXTGET",
  234. /* 0x1b */ "_TEXTPUT",
  235. /* 0x1c */ "_CLIPPUT",
  236. /* 0x1d */ "_SCROLL",
  237. /* 0x1e */ "_B_CURON",
  238. /* 0x1f */ "_B_CUROFF",
  239. /* 0x20 */ "_B_PUTC",
  240. /* 0x21 */ "_B_PRINT",
  241. /* 0x22 */ "_B_COLOR",
  242. /* 0x23 */ "_B_LOCATE",
  243. /* 0x24 */ "_B_DOWN_S",
  244. /* 0x25 */ "_B_UP_S",
  245. /* 0x26 */ "_B_UP",
  246. /* 0x27 */ "_B_DOWN",
  247. /* 0x28 */ "_B_RIGHT",
  248. /* 0x29 */ "_B_LEFT",
  249. /* 0x2a */ "_B_CLR_ST",
  250. /* 0x2b */ "_B_ERA_ST",
  251. /* 0x2c */ "_B_INS",
  252. /* 0x2d */ "_B_DEL",
  253. /* 0x2e */ "_B_CONSOL",
  254. /* 0x2f */ "_B_PUTMES",
  255. /* 0x30 */ "_SET232C",
  256. /* 0x31 */ "_LOF232C",
  257. /* 0x32 */ "_INP232C",
  258. /* 0x33 */ "_ISNS232C",
  259. /* 0x34 */ "_OSNS232C",
  260. /* 0x35 */ "_OUT232C",
  261. /* 0x36 */ "?",
  262. /* 0x37 */ "?",
  263. /* 0x38 */ "_SETFNTADR",
  264. /* 0x39 */ "?",
  265. /* 0x3a */ "?",
  266. /* 0x3b */ "_JOYGET",
  267. /* 0x3c */ "_INIT_PRN",
  268. /* 0x3d */ "_SNSPRN",
  269. /* 0x3e */ "_OUTLPT",
  270. /* 0x3f */ "_OUTPRN",
  271. /* 0x40 */ "_B_SEEK",
  272. /* 0x41 */ "_B_VERIFY",
  273. /* 0x42 */ "_B_READDI",
  274. /* 0x43 */ "_B_DSKINI",
  275. /* 0x44 */ "_B_DRVSNS",
  276. /* 0x45 */ "_B_WRITE",
  277. /* 0x46 */ "_B_READ",
  278. /* 0x47 */ "_B_RECALI",
  279. /* 0x48 */ "_B_ASSIGN",
  280. /* 0x49 */ "_B_WRITED",
  281. /* 0x4a */ "_B_READID",
  282. /* 0x4b */ "_B_BADFMT",
  283. /* 0x4c */ "_B_READDL",
  284. /* 0x4d */ "_B_FORMAT",
  285. /* 0x4e */ "_B_DRVCHK",
  286. /* 0x4f */ "_B_EJECT",
  287. /* 0x50 */ "_DATEBCD",
  288. /* 0x51 */ "_DATESET",
  289. /* 0x52 */ "_TIMEBCD",
  290. /* 0x53 */ "_TIMESET",
  291. /* 0x54 */ "_DATEGET",
  292. /* 0x55 */ "_DATEBIN",
  293. /* 0x56 */ "_TIMEGET",
  294. /* 0x57 */ "_TIMEBIN",
  295. /* 0x58 */ "_DATECNV",
  296. /* 0x59 */ "_TIMECNV",
  297. /* 0x5a */ "_DATEASC",
  298. /* 0x5b */ "_TIMEASC",
  299. /* 0x5c */ "_DAYASC",
  300. /* 0x5d */ "_ALARMMOD",
  301. /* 0x5e */ "_ALARMSET",
  302. /* 0x5f */ "_ALARMGET",
  303. /* 0x60 */ "_ADPCMOUT",
  304. /* 0x61 */ "_ADPCMINP",
  305. /* 0x62 */ "_ADPCMAOT",
  306. /* 0x63 */ "_ADPCMAIN",
  307. /* 0x64 */ "_ADPCMLOT",
  308. /* 0x65 */ "_ADPCMLIN",
  309. /* 0x66 */ "_ADPCMSNS",
  310. /* 0x67 */ "_ADPCMMOD",
  311. /* 0x68 */ "_OPMSET",
  312. /* 0x69 */ "_OPMSNS",
  313. /* 0x6a */ "_OPMINTST",
  314. /* 0x6b */ "_TIMERDST",
  315. /* 0x6c */ "_VDISPST",
  316. /* 0x6d */ "_CRTCRAS",
  317. /* 0x6e */ "_HSYNCST",
  318. /* 0x6f */ "_PRNINTST",
  319. /* 0x70 */ "_MS_INIT",
  320. /* 0x71 */ "_MS_CURON",
  321. /* 0x72 */ "_MS_CUROF",
  322. /* 0x73 */ "_MS_STAT",
  323. /* 0x74 */ "_MS_GETDT",
  324. /* 0x75 */ "_MS_CURGT",
  325. /* 0x76 */ "_MS_CURST",
  326. /* 0x77 */ "_MS_LIMIT",
  327. /* 0x78 */ "_MS_OFFTM",
  328. /* 0x79 */ "_MS_ONTM",
  329. /* 0x7a */ "_MS_PATST",
  330. /* 0x7b */ "_MS_SEL",
  331. /* 0x7c */ "_MS_SEL2",
  332. /* 0x7d */ "_SKEY_MOD",
  333. /* 0x7e */ "_DENSNS",
  334. /* 0x7f */ "_ONTIME",
  335. /* 0x80 */ "_B_INTVCS",
  336. /* 0x81 */ "_B_SUPER",
  337. /* 0x82 */ "_B_BPEEK",
  338. /* 0x83 */ "_B_WPEEK",
  339. /* 0x84 */ "_B_LPEEK",
  340. /* 0x85 */ "_B_MEMSTR",
  341. /* 0x86 */ "_B_BPOKE",
  342. /* 0x87 */ "_B_WPOKE",
  343. /* 0x88 */ "_B_LPOKE",
  344. /* 0x89 */ "_B_MEMSET",
  345. /* 0x8a */ "_DMAMOVE",
  346. /* 0x8b */ "_DMAMOV_A",
  347. /* 0x8c */ "_DMAMOV_L",
  348. /* 0x8d */ "_DMAMODE",
  349. /* 0x8e */ "_BOOTINF",
  350. /* 0x8f */ "_ROMVER",
  351. /* 0x90 */ "_G_CLR_ON",
  352. /* 0x91 */ "?",
  353. /* 0x92 */ "?",
  354. /* 0x93 */ "?",
  355. /* 0x94 */ "_GPALET",
  356. /* 0x95 */ "?",
  357. /* 0x96 */ "?",
  358. /* 0x97 */ "?",
  359. /* 0x98 */ "?",
  360. /* 0x99 */ "?",
  361. /* 0x9a */ "?",
  362. /* 0x9b */ "?",
  363. /* 0x9c */ "?",
  364. /* 0x9d */ "?",
  365. /* 0x9e */ "?",
  366. /* 0x9f */ "?",
  367. /* 0xa0 */ "_SFTJIS",
  368. /* 0xa1 */ "_JISSFT",
  369. /* 0xa2 */ "_AKCONV",
  370. /* 0xa3 */ "_RMACNV",
  371. /* 0xa4 */ "_DAKJOB",
  372. /* 0xa5 */ "_HANJOB",
  373. /* 0xa6 */ "?",
  374. /* 0xa7 */ "?",
  375. /* 0xa8 */ "?",
  376. /* 0xa9 */ "?",
  377. /* 0xaa */ "?",
  378. /* 0xab */ "?",
  379. /* 0xac */ "_SYS_STAT",
  380. /* 0xad */ "_B_CONMOD",
  381. /* 0xae */ "_OS_CURON",
  382. /* 0xaf */ "_OS_CUROF",
  383. /* 0xb0 */ "_DRAWMODE",
  384. /* 0xb1 */ "_APAGE",
  385. /* 0xb2 */ "_VPAGE",
  386. /* 0xb3 */ "_HOME",
  387. /* 0xb4 */ "_WINDOW",
  388. /* 0xb5 */ "_WIPE",
  389. /* 0xb6 */ "_PSET",
  390. /* 0xb7 */ "_POINT",
  391. /* 0xb8 */ "_LINE",
  392. /* 0xb9 */ "_BOX",
  393. /* 0xba */ "_FILL",
  394. /* 0xbb */ "_CIRCLE",
  395. /* 0xbc */ "_PAINT",
  396. /* 0xbd */ "_SYMBOL",
  397. /* 0xbe */ "_GETGRM",
  398. /* 0xbf */ "_PUTGRM",
  399. /* 0xc0 */ "_SP_INIT",
  400. /* 0xc1 */ "_SP_ON",
  401. /* 0xc2 */ "_SP_OFF",
  402. /* 0xc3 */ "_SP_CGCLR",
  403. /* 0xc4 */ "_SP_DEFCG",
  404. /* 0xc5 */ "_SP_GTPCG",
  405. /* 0xc6 */ "_SP_REGST",
  406. /* 0xc7 */ "_SP_REGGT",
  407. /* 0xc8 */ "_BGSCRLST",
  408. /* 0xc9 */ "_BGSCRLGT",
  409. /* 0xca */ "_BGCTRLST",
  410. /* 0xcb */ "_BGCTRLGT",
  411. /* 0xcc */ "_BGTEXTCL",
  412. /* 0xcd */ "_BGTEXTST",
  413. /* 0xce */ "_BGTEXTGT",
  414. /* 0xcf */ "_SPALET",
  415. /* 0xd0 */ "?",
  416. /* 0xd1 */ "?",
  417. /* 0xd2 */ "?",
  418. /* 0xd3 */ "_TXXLINE",
  419. /* 0xd4 */ "_TXYLINE",
  420. /* 0xd5 */ "_TXLINE",
  421. /* 0xd6 */ "_TXBOX",
  422. /* 0xd7 */ "_TXFILL",
  423. /* 0xd8 */ "_TXREV",
  424. /* 0xd9 */ "?",
  425. /* 0xda */ "?",
  426. /* 0xdb */ "?",
  427. /* 0xdc */ "?",
  428. /* 0xdd */ "?",
  429. /* 0xde */ "?",
  430. /* 0xdf */ "?",
  431. /* 0xe0 */ "?",
  432. /* 0xe1 */ "?",
  433. /* 0xe2 */ "?",
  434. /* 0xe3 */ "?",
  435. /* 0xe4 */ "?",
  436. /* 0xe5 */ "?",
  437. /* 0xe6 */ "?",
  438. /* 0xe7 */ "?",
  439. /* 0xe8 */ "?",
  440. /* 0xe9 */ "?",
  441. /* 0xea */ "?",
  442. /* 0xeb */ "?",
  443. /* 0xec */ "?",
  444. /* 0xed */ "?",
  445. /* 0xee */ "?",
  446. /* 0xef */ "?",
  447. /* 0xf0 */ "_OPMDRV",
  448. /* 0xf1 */ "_RSDRV",
  449. /* 0xf2 */ "_A_JOYGET",
  450. /* 0xf3 */ "_MUSICDRV",
  451. /* 0xf4 */ "?",
  452. /* 0xf5 */ "_SCSIDRV",
  453. /* 0xf6 */ "?",
  454. /* 0xf7 */ "?",
  455. /* 0xf8 */ "?",
  456. /* 0xf9 */ "?",
  457. /* 0xfa */ "?",
  458. /* 0xfb */ "?",
  459. /* 0xfc */ "?",
  460. /* 0xfd */ "_ABORTRST",
  461. /* 0xfe */ "_IPLERR",
  462. /* 0xff */ "_ABORTJOB",
  463. };
  464. void v68_iocs_init() {
  465. }
  466. int v68_iocs_call(uint16_t instr) {
  467. uint8_t call = instr & 0xff;
  468. uint32_t call_addr = m68k_read_memory_32(0x400 + call * 4);
  469. if(v68.log_calls)
  470. printf("v68_iocs_call call=0x%02x %s call_addr=0x%08x\n", instr, iocs_call_names[call], call_addr);
  471. if(call_addr < 0xff0000) {/* Only implement calls that aren't overridden */
  472. uint16_t sr = m68k_get_reg(0, M68K_REG_SR);
  473. uint32_t sp = m68k_get_reg(0, M68K_REG_SP);
  474. verbose2("v68_iocs_call call_addr=0x%08x implemented sp=0x%08x\n", call_addr, sp);
  475. sp -= 4;
  476. m68k_set_reg(M68K_REG_SR, sr | 0x2000);
  477. uint32_t pc = m68k_get_reg(0, M68K_REG_PC);
  478. m68k_write_memory_32(sp, pc);
  479. m68k_set_reg(M68K_REG_SP, sp);
  480. m68k_set_reg(M68K_REG_PC, call_addr);
  481. return 0;
  482. }
  483. switch(call) {
  484. case IOCS_CALL_B_PUTC: {
  485. uint16_t chr = m68k_get_reg(0, M68K_REG_D0);
  486. uint8_t chrbuf[2] = { chr >> 8, chr };
  487. sjis_print_utf8(chrbuf[0] ? chrbuf : chrbuf+1, chrbuf[0] ? 2 : 1);
  488. m68k_set_reg(M68K_REG_D0, 0x00100010);
  489. }
  490. break;
  491. case IOCS_CALL_ONTIME: {
  492. struct sysinfo si;
  493. sysinfo(&si);
  494. m68k_set_reg(M68K_REG_D0, (si.uptime % (24 * 60 * 60)) * 100);
  495. m68k_set_reg(M68K_REG_D1, si.uptime / (24 * 60 * 60));
  496. }
  497. break;
  498. case IOCS_CALL_B_MEMSTR: {
  499. uint32_t num_bytes = m68k_get_reg(0, M68K_REG_D1);
  500. uint32_t src = m68k_get_reg(0, M68K_REG_A1);
  501. uint32_t dst = m68k_get_reg(0, M68K_REG_A2);
  502. if(src + num_bytes >= v68.ram_size || dst + num_bytes >= v68.ram_size) {
  503. // Out of bounds, fool
  504. m68k_set_reg(M68K_REG_A1, 0);
  505. m68k_set_reg(M68K_REG_A2, 0);
  506. } else {
  507. memcpy(&v68.ram[dst], &v68.ram[src], num_bytes);
  508. m68k_set_reg(M68K_REG_A1, src + num_bytes);
  509. m68k_set_reg(M68K_REG_A2, 0);
  510. }
  511. }
  512. break;
  513. case IOCS_CALL_ADPCMOUT: {
  514. verbose1("_ADPCMOUT\n");
  515. m68k_write_memory_8(0x00E840C5, 0x32); // Channel 3, OCR
  516. m68k_write_memory_8(0x00E840C0, 0xff); // Channel 3, CSR
  517. m68k_write_memory_32(0x00E840CC, m68k_get_reg(0, M68K_REG_A1)); // Channel 3, MAR
  518. m68k_write_memory_16(0x00E840CA, m68k_get_reg(0, M68K_REG_D2)); // Channel 3, MTC
  519. m68k_write_memory_8(0x00E840C7, 0x88); // Channel 3, CCR
  520. m68k_write_memory_8(0xe9a005, 0x08); // Write to UPD8255
  521. m68k_write_memory_8(0xE92001, 0x02); // OKI ADPCM: play start
  522. }
  523. break;
  524. case IOCS_CALL_ADPCMINP: {
  525. verbose1("_ADPCMINP\n");
  526. }
  527. break;
  528. case IOCS_CALL_ADPCMAOT: {
  529. verbose1("_ADPCMAOT\n");
  530. }
  531. break;
  532. case IOCS_CALL_ADPCMAIN: {
  533. verbose1("_ADPCMAIN\n");
  534. }
  535. break;
  536. case IOCS_CALL_ADPCMLOT: {
  537. verbose1("_ADPCMLOT\n");
  538. }
  539. break;
  540. case IOCS_CALL_ADPCMLIN: {
  541. verbose1("_ADPCMLIN\n");
  542. }
  543. break;
  544. case IOCS_CALL_ADPCMSNS: {
  545. verbose1("_ADPCMSNS\n");
  546. }
  547. break;
  548. case IOCS_CALL_ADPCMMOD: {
  549. verbose1("_ADPCMMOD\n");
  550. }
  551. break;
  552. default:
  553. logcall("Unimplemented V68 IOCS CALL %04x %s\n", instr, iocs_call_names[call]);
  554. }
  555. return 0;
  556. }