liberis
|
00001 /* 00002 liberis -- A set of libraries for controlling the NEC PC-FX 00003 00004 Copyright (C) 2011 Alex Marshall "trap15" <trap15@raidenii.net> 00005 00006 # This code is licensed to you under the terms of the MIT license; 00007 # see file LICENSE or http://www.opensource.org/licenses/mit-license.php 00008 */ 00009 00014 #ifndef _LIBERIS_KING_H_ 00015 #define _LIBERIS_KING_H_ 00016 00017 #include <eris/types.h> 00018 00027 #define KING_CODE(off, type, rot, bg, nop) \ 00028 (((off & 7) << 0) | ((type & 3) << 3) | ((rot & 1) << 5) | \ 00029 ((bg & 3) << 6) | ((nop & 1) << 8)) 00030 00033 typedef enum { 00034 KING_CODE_BG0_CG_0 = KING_CODE(0, 0, 0, 0, 0), 00035 KING_CODE_BG0_CG_1 = KING_CODE(1, 0, 0, 0, 0), 00036 KING_CODE_BG0_CG_2 = KING_CODE(2, 0, 0, 0, 0), 00037 KING_CODE_BG0_CG_3 = KING_CODE(3, 0, 0, 0, 0), 00038 KING_CODE_BG0_CG_4 = KING_CODE(4, 0, 0, 0, 0), 00039 KING_CODE_BG0_CG_5 = KING_CODE(5, 0, 0, 0, 0), 00040 KING_CODE_BG0_CG_6 = KING_CODE(6, 0, 0, 0, 0), 00041 KING_CODE_BG0_CG_7 = KING_CODE(7, 0, 0, 0, 0), 00042 KING_CODE_BG0_BATCG_0 = KING_CODE(0, 1, 0, 0, 0), 00043 KING_CODE_BG0_BATCG_1 = KING_CODE(1, 1, 0, 0, 0), 00044 KING_CODE_BG0_BATCG_2 = KING_CODE(2, 1, 0, 0, 0), 00045 KING_CODE_BG0_BATCG_3 = KING_CODE(3, 1, 0, 0, 0), 00046 KING_CODE_BG0_BATCG_4 = KING_CODE(4, 1, 0, 0, 0), 00047 KING_CODE_BG0_BATCG_5 = KING_CODE(5, 1, 0, 0, 0), 00048 KING_CODE_BG0_BATCG_6 = KING_CODE(6, 1, 0, 0, 0), 00049 KING_CODE_BG0_BATCG_7 = KING_CODE(7, 1, 0, 0, 0), 00050 KING_CODE_BG0_BAT_0 = KING_CODE(0, 2, 0, 0, 0), 00051 KING_CODE_BG0_BAT_1 = KING_CODE(1, 2, 0, 0, 0), 00052 KING_CODE_BG0_BAT_2 = KING_CODE(2, 2, 0, 0, 0), 00053 KING_CODE_BG0_BAT_3 = KING_CODE(3, 2, 0, 0, 0), 00054 KING_CODE_BG0_BAT_4 = KING_CODE(4, 2, 0, 0, 0), 00055 KING_CODE_BG0_BAT_5 = KING_CODE(5, 2, 0, 0, 0), 00056 KING_CODE_BG0_BAT_6 = KING_CODE(6, 2, 0, 0, 0), 00057 KING_CODE_BG0_BAT_7 = KING_CODE(7, 2, 0, 0, 0), 00058 KING_CODE_BG1_CG_0 = KING_CODE(0, 0, 0, 1, 0), 00059 KING_CODE_BG1_CG_1 = KING_CODE(1, 0, 0, 1, 0), 00060 KING_CODE_BG1_CG_2 = KING_CODE(2, 0, 0, 1, 0), 00061 KING_CODE_BG1_CG_3 = KING_CODE(3, 0, 0, 1, 0), 00062 KING_CODE_BG1_CG_4 = KING_CODE(4, 0, 0, 1, 0), 00063 KING_CODE_BG1_CG_5 = KING_CODE(5, 0, 0, 1, 0), 00064 KING_CODE_BG1_CG_6 = KING_CODE(6, 0, 0, 1, 0), 00065 KING_CODE_BG1_CG_7 = KING_CODE(7, 0, 0, 1, 0), 00066 KING_CODE_BG1_BATCG_0 = KING_CODE(0, 1, 0, 1, 0), 00067 KING_CODE_BG1_BATCG_1 = KING_CODE(1, 1, 0, 1, 0), 00068 KING_CODE_BG1_BATCG_2 = KING_CODE(2, 1, 0, 1, 0), 00069 KING_CODE_BG1_BATCG_3 = KING_CODE(3, 1, 0, 1, 0), 00070 KING_CODE_BG1_BATCG_4 = KING_CODE(4, 1, 0, 1, 0), 00071 KING_CODE_BG1_BATCG_5 = KING_CODE(5, 1, 0, 1, 0), 00072 KING_CODE_BG1_BATCG_6 = KING_CODE(6, 1, 0, 1, 0), 00073 KING_CODE_BG1_BATCG_7 = KING_CODE(7, 1, 0, 1, 0), 00074 KING_CODE_BG1_BAT_0 = KING_CODE(0, 2, 0, 1, 0), 00075 KING_CODE_BG1_BAT_1 = KING_CODE(1, 2, 0, 1, 0), 00076 KING_CODE_BG1_BAT_2 = KING_CODE(2, 2, 0, 1, 0), 00077 KING_CODE_BG1_BAT_3 = KING_CODE(3, 2, 0, 1, 0), 00078 KING_CODE_BG1_BAT_4 = KING_CODE(4, 2, 0, 1, 0), 00079 KING_CODE_BG1_BAT_5 = KING_CODE(5, 2, 0, 1, 0), 00080 KING_CODE_BG1_BAT_6 = KING_CODE(6, 2, 0, 1, 0), 00081 KING_CODE_BG1_BAT_7 = KING_CODE(7, 2, 0, 1, 0), 00082 KING_CODE_BG2_CG_0 = KING_CODE(0, 0, 0, 2, 0), 00083 KING_CODE_BG2_CG_1 = KING_CODE(1, 0, 0, 2, 0), 00084 KING_CODE_BG2_CG_2 = KING_CODE(2, 0, 0, 2, 0), 00085 KING_CODE_BG2_CG_3 = KING_CODE(3, 0, 0, 2, 0), 00086 KING_CODE_BG2_CG_4 = KING_CODE(4, 0, 0, 2, 0), 00087 KING_CODE_BG2_CG_5 = KING_CODE(5, 0, 0, 2, 0), 00088 KING_CODE_BG2_CG_6 = KING_CODE(6, 0, 0, 2, 0), 00089 KING_CODE_BG2_CG_7 = KING_CODE(7, 0, 0, 2, 0), 00090 KING_CODE_BG2_BATCG_0 = KING_CODE(0, 1, 0, 2, 0), 00091 KING_CODE_BG2_BATCG_1 = KING_CODE(1, 1, 0, 2, 0), 00092 KING_CODE_BG2_BATCG_2 = KING_CODE(2, 1, 0, 2, 0), 00093 KING_CODE_BG2_BATCG_3 = KING_CODE(3, 1, 0, 2, 0), 00094 KING_CODE_BG2_BATCG_4 = KING_CODE(4, 1, 0, 2, 0), 00095 KING_CODE_BG2_BATCG_5 = KING_CODE(5, 1, 0, 2, 0), 00096 KING_CODE_BG2_BATCG_6 = KING_CODE(6, 1, 0, 2, 0), 00097 KING_CODE_BG2_BATCG_7 = KING_CODE(7, 1, 0, 2, 0), 00098 KING_CODE_BG2_BAT_0 = KING_CODE(0, 2, 0, 2, 0), 00099 KING_CODE_BG2_BAT_1 = KING_CODE(1, 2, 0, 2, 0), 00100 KING_CODE_BG2_BAT_2 = KING_CODE(2, 2, 0, 2, 0), 00101 KING_CODE_BG2_BAT_3 = KING_CODE(3, 2, 0, 2, 0), 00102 KING_CODE_BG2_BAT_4 = KING_CODE(4, 2, 0, 2, 0), 00103 KING_CODE_BG2_BAT_5 = KING_CODE(5, 2, 0, 2, 0), 00104 KING_CODE_BG2_BAT_6 = KING_CODE(6, 2, 0, 2, 0), 00105 KING_CODE_BG2_BAT_7 = KING_CODE(7, 2, 0, 2, 0), 00106 KING_CODE_BG3_CG_0 = KING_CODE(0, 0, 0, 3, 0), 00107 KING_CODE_BG3_CG_1 = KING_CODE(1, 0, 0, 3, 0), 00108 KING_CODE_BG3_CG_2 = KING_CODE(2, 0, 0, 3, 0), 00109 KING_CODE_BG3_CG_3 = KING_CODE(3, 0, 0, 3, 0), 00110 KING_CODE_BG3_CG_4 = KING_CODE(4, 0, 0, 3, 0), 00111 KING_CODE_BG3_CG_5 = KING_CODE(5, 0, 0, 3, 0), 00112 KING_CODE_BG3_CG_6 = KING_CODE(6, 0, 0, 3, 0), 00113 KING_CODE_BG3_CG_7 = KING_CODE(7, 0, 0, 3, 0), 00114 KING_CODE_BG3_BATCG_0 = KING_CODE(0, 1, 0, 3, 0), 00115 KING_CODE_BG3_BATCG_1 = KING_CODE(1, 1, 0, 3, 0), 00116 KING_CODE_BG3_BATCG_2 = KING_CODE(2, 1, 0, 3, 0), 00117 KING_CODE_BG3_BATCG_3 = KING_CODE(3, 1, 0, 3, 0), 00118 KING_CODE_BG3_BATCG_4 = KING_CODE(4, 1, 0, 3, 0), 00119 KING_CODE_BG3_BATCG_5 = KING_CODE(5, 1, 0, 3, 0), 00120 KING_CODE_BG3_BATCG_6 = KING_CODE(6, 1, 0, 3, 0), 00121 KING_CODE_BG3_BATCG_7 = KING_CODE(7, 1, 0, 3, 0), 00122 KING_CODE_BG3_BAT_0 = KING_CODE(0, 2, 0, 3, 0), 00123 KING_CODE_BG3_BAT_1 = KING_CODE(1, 2, 0, 3, 0), 00124 KING_CODE_BG3_BAT_2 = KING_CODE(2, 2, 0, 3, 0), 00125 KING_CODE_BG3_BAT_3 = KING_CODE(3, 2, 0, 3, 0), 00126 KING_CODE_BG3_BAT_4 = KING_CODE(4, 2, 0, 3, 0), 00127 KING_CODE_BG3_BAT_5 = KING_CODE(5, 2, 0, 3, 0), 00128 KING_CODE_BG3_BAT_6 = KING_CODE(6, 2, 0, 3, 0), 00129 KING_CODE_BG3_BAT_7 = KING_CODE(7, 2, 0, 3, 0), 00130 KING_CODE_ROTATE = KING_CODE(0, 0, 1, 0, 0), 00131 KING_CODE_NOP = KING_CODE(0, 0, 0, 0, 1), 00132 } king_opcode; 00133 00136 typedef enum { 00137 KING_BGMODE_4_PAL = 0x1, 00138 KING_BGMODE_16_PAL = 0x2, 00139 KING_BGMODE_256_PAL = 0x3, 00140 KING_BGMODE_64K = 0x4, 00141 KING_BGMODE_16M = 0x5, 00142 KING_BGMODE_BAT = 0x8, 00143 KING_BGMODE_64K_BAT_EXTDOT = 0xE, 00145 KING_BGMODE_16M_BAT_EXTDOT = 0xF, 00147 } king_bgmode; 00148 00151 typedef enum { 00152 KING_BGPRIO_HIDE = 0, 00153 KING_BGPRIO_0 = 1, 00154 KING_BGPRIO_1 = 2, 00155 KING_BGPRIO_2 = 3, 00156 KING_BGPRIO_3 = 4, 00157 } king_bgprio; 00158 00161 typedef enum { 00162 KING_BGSIZE_8 = 3, 00163 KING_BGSIZE_16 = 4, 00164 KING_BGSIZE_32 = 5, 00165 KING_BGSIZE_64 = 6, 00166 KING_BGSIZE_128 = 7, 00167 KING_BGSIZE_256 = 8, 00168 KING_BGSIZE_512 = 9, 00169 KING_BGSIZE_1024 = 10, 00170 } king_bgsize; 00171 00174 typedef enum { 00175 KING_BG0 = 0, 00176 KING_BG0SUB = 1, 00177 KING_BG1 = 2, 00178 KING_BG2 = 3, 00179 KING_BG3 = 4, 00180 } king_bg; 00181 00184 void eris_king_init(void); 00190 void eris_king_set_kram_read(u32 addr, int incr); 00196 void eris_king_set_kram_write(u32 addr, int incr); 00201 u16 eris_king_kram_read(void); 00206 void eris_king_kram_write(u16 data); 00214 void eris_king_set_kram_pages(u8 scsi, u8 bg, u8 rainbow, u8 adpcm); 00222 void eris_king_set_bg_mode(king_bgmode bg0, king_bgmode bg1, king_bgmode bg2, 00223 king_bgmode bg3); 00232 void eris_king_set_bg_prio(king_bgprio bg0, king_bgprio bg1, king_bgprio bg2, 00233 king_bgprio bg3, int bgrot); 00242 void eris_king_set_bg_size(king_bg bg, king_bgsize h, king_bgsize w, 00243 king_bgsize sub_h, king_bgsize sub_w); 00250 void eris_king_set_bat_cg_addr(king_bg bg, u32 bat, u32 cg); 00257 void eris_king_set_scroll(king_bg bg, s16 x, s16 y); 00264 void eris_king_write_microprogram(u16* data, u8 addr, u8 len); 00271 void eris_king_fill_microprogram(u16 data, u8 addr, u8 len); 00274 void eris_king_enable_microprogram(void); 00277 void eris_king_disable_microprogram(void); 00278 00279 #endif 00280