From 8ea80d38a547a08979e0e0c462f17b9a548235fa Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Wed, 10 Dec 2008 18:16:30 +0000 Subject: [PATCH] rewrote file interface --- history.txt | 8 +- source/LICENSE | 26 +- source/gen_input.c | 409 +++++------ source/gen_input.h | 22 +- source/gen_io.c | 98 +-- source/gen_io.h | 12 +- source/genesis.c | 210 +++--- source/hvc.h | 183 +++-- source/loadrom.c | 310 ++++---- source/loadrom.h | 32 +- source/macros.h | 27 +- source/membnk.c | 84 +-- source/memz80.c | 44 +- source/ngc/config.c | 19 +- source/ngc/config.h | 2 +- source/ngc/{gui => }/dvd.c | 42 +- source/ngc/dvd.h | 19 + source/ngc/fileio.c | 40 +- source/ngc/fileio_dvd.c | 399 +++++++++++ source/ngc/fileio_dvd.h | 14 + source/ngc/fileio_fat.c | 313 ++++++++ source/ngc/fileio_fat.h | 21 + source/ngc/gcaram.c | 25 +- source/ngc/gcaram.h | 11 +- source/ngc/gui/dvd.h | 29 - source/ngc/gui/filesel.c | 557 ++------------- source/ngc/gui/filesel.h | 35 + source/ngc/gui/font.c | 944 +++++------------------- source/ngc/gui/ggentry.c | 290 ++++---- source/ngc/gui/iso9660.c | 221 ------ source/ngc/gui/iso9660.h | 31 - source/ngc/gui/legal.c | 10 +- source/ngc/gui/menu.c | 1015 +++++++++++++------------- source/ngc/history.c | 92 +-- source/ngc/history.h | 27 +- source/ngc/memfile.c | 691 +++++++++--------- source/ngc/ngc.c | 31 +- source/ngc/ogc_audio.c | 14 +- source/ngc/ogc_input.c | 12 +- source/ngc/ogc_video.c | 280 ++++---- source/ngc/osd.h | 3 +- source/render.c | 404 +++++------ source/state.c | 252 +++---- source/system.c | 288 ++++---- source/system.h | 38 +- source/unzip.c | 1380 ++++++++++++++++++------------------ source/vdp.c | 766 ++++++++++---------- source/vdp.h | 30 +- 48 files changed, 4616 insertions(+), 5194 deletions(-) rename source/ngc/{gui => }/dvd.c (78%) create mode 100644 source/ngc/dvd.h create mode 100644 source/ngc/fileio_dvd.c create mode 100644 source/ngc/fileio_dvd.h create mode 100644 source/ngc/fileio_fat.c create mode 100644 source/ngc/fileio_fat.h delete mode 100644 source/ngc/gui/dvd.h create mode 100644 source/ngc/gui/filesel.h delete mode 100644 source/ngc/gui/iso9660.c delete mode 100644 source/ngc/gui/iso9660.h diff --git a/history.txt b/history.txt index e7d1934..e69c1ef 100644 --- a/history.txt +++ b/history.txt @@ -25,8 +25,9 @@ Genesis Plus for Gamecube - rewrote video engine: improved horizontal scaling (VI+GX), improved rendering speed (direct texture mapping) - removed embedded font, (re)enabled IPL font support: now should works for Qoob users too (thanks to emukiddid) - fixed "Reset" button behavior, now acts more like Genesis Reset button ;-) -- minor bugfixes and menu tweaks -- compiled with libogc 1.7.0 +- patched libfat for faster SDCARD accesses (thanks to svpe) +- various bugfixes and menu tweaks + [NGC only] - added 480p support in menu @@ -34,7 +35,8 @@ Genesis Plus for Gamecube [Wii only] - implemented fast scrolling in menu using Wiimote D-PAD - added "Power" button support -- libogc 1.7.0 features (SDHC support , Wiimote shutdown button support) +- added USB Storage support +- *new* libogc 1.7.0 features: SDHC support, Wiimote shutdown button support diff --git a/source/LICENSE b/source/LICENSE index 60549be..42e70da 100644 --- a/source/LICENSE +++ b/source/LICENSE @@ -1,12 +1,12 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE + + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -225,7 +225,7 @@ impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it diff --git a/source/gen_input.c b/source/gen_input.c index 62fb7c2..633cf21 100644 --- a/source/gen_input.c +++ b/source/gen_input.c @@ -31,57 +31,58 @@ t_input input; *****************************************************************************/ /* H counter values for a 256-pixel wide display (342 pixel max.) */ uint8 hc_256[171] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; /* H counter values for a 320-pixel wide display (442 pixels max.) */ uint8 hc_320[210] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36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F }; static inline void lightgun_reset(int num) { - input.analog[num][0] = bitmap.viewport.w >> 1; - input.analog[num][1] = bitmap.viewport.h >> 1; + input.analog[num][0] = bitmap.viewport.w >> 1; + input.analog[num][1] = bitmap.viewport.h >> 1; } static inline void lightgun_update(int num) { if ((input.analog[num][1] == v_counter + input.y_offset)) - { + { /* HL enabled ? */ if (io_reg[5] & 0x80) { /* External Interrupt ? */ if (reg[11] & 0x08) {irq_status &= 0xff; irq_status |= 0x12;} - /* HVC Latch: - 1) some games does not set HVC latch but instead use bigger X offset - 2) for games using H40 mode, the gun routine scales up the Hcounter value, + /* HVC Latch: + 1) some games does not set HVC latch but instead use bigger X offset + 2) for games using H40 mode, the gun routine scales up the Hcounter value, H-Counter range is approx. 292 pixel clocks */ hc_latch = 0x100; @@ -90,19 +91,19 @@ static inline void lightgun_update(int num) else hc_latch |= hc_256[(input.analog[num][0] / 2 + input.x_offset)%171]; - } - } -} - + } + } +} + /* Sega Menacer specific */ uint32 menacer_read() { /* pins should return 0 by default (fix Body Count when mouse is enabled) */ int retval = 0x00; - if (input.pad[4] & INPUT_B) retval |= 0x01; - if (input.pad[4] & INPUT_A) retval |= 0x02; + if (input.pad[4] & INPUT_B) retval |= 0x01; + if (input.pad[4] & INPUT_A) retval |= 0x02; if (input.pad[4] & INPUT_C) retval |= 0x04; - if (input.pad[4] & INPUT_START) retval |= 0x08; + if (input.pad[4] & INPUT_START) retval |= 0x08; return retval; } @@ -130,8 +131,8 @@ uint32 justifier_read() return retval; default: /* guns disabled */ - return retval; -} + return retval; + } } /***************************************************************************** @@ -148,8 +149,8 @@ struct mega_mouse static inline void mouse_reset() { - mouse.State = 0x60; - mouse.Counter = 0; + mouse.State = 0x60; + mouse.Counter = 0; mouse.Wait = 0; mouse.Port = (input.system[0] == SYSTEM_MOUSE) ? 0 : 4; } @@ -267,19 +268,19 @@ struct pad static inline void gamepad_raz(uint32 i) { - gamepad[i].Counter = 0; - gamepad[i].Delay = 0; + gamepad[i].Counter = 0; + gamepad[i].Delay = 0; } static inline void gamepad_reset(uint32 i) { - gamepad[i].State = 0x40; - if (input.dev[i] == DEVICE_6BUTTON) gamepad_raz(i); + gamepad[i].State = 0x40; + if (input.dev[i] == DEVICE_6BUTTON) gamepad_raz(i); } static inline void gamepad_update(uint32 i) { - if (gamepad[i].Delay++ > 25) gamepad_raz(i); + if (gamepad[i].Delay++ > 25) gamepad_raz(i); } static inline uint32 gamepad_read(uint32 i) @@ -288,10 +289,10 @@ static inline uint32 gamepad_read(uint32 i) int retval = 0x7F; control = (gamepad[i].State & 0x40) >> 6; /* current TH state */ - + if (input.dev[i] == DEVICE_6BUTTON) { - control += (gamepad[i].Counter & 3) << 1; /* TH transitions counter */ + control += (gamepad[i].Counter & 3) << 1; /* TH transitions counter */ } switch (control) @@ -299,7 +300,7 @@ static inline uint32 gamepad_read(uint32 i) case 1: /*** First High ***/ case 3: /*** Second High ***/ case 5: /*** Third High ***/ - + /* TH = 1 : ?1CBRLDU */ if (input.pad[i] & INPUT_C) retval &= ~0x20; if (input.pad[i] & INPUT_B) retval &= ~0x10; @@ -311,7 +312,7 @@ static inline uint32 gamepad_read(uint32 i) case 0: /*** First low ***/ case 2: /*** Second low ***/ - + /* TH = 0 : ?0SA00DU */ if (input.pad[i] & INPUT_A) retval &= ~0x10; if (input.pad[i] & INPUT_START) retval &= ~0x20; @@ -333,7 +334,7 @@ static inline uint32 gamepad_read(uint32 i) TH = 0 : ?0SA1111 D3-0 are forced to '1' */ case 4: /*** Third Low ***/ - + /* TH = 0 : ?0SA0000 D3-0 are forced to '0'*/ if (input.pad[i] & INPUT_A) retval &= ~0x10; if (input.pad[i] & INPUT_START) retval &= ~0x20; @@ -341,7 +342,7 @@ static inline uint32 gamepad_read(uint32 i) break; case 6: /*** Fourth Low ***/ - + /* TH = 0 : ?0SA1111 D3-0 are forced to '1'*/ if (input.pad[i] & INPUT_A) retval &= ~0x10; if (input.pad[i] & INPUT_START) retval &= ~0x20; @@ -349,7 +350,7 @@ static inline uint32 gamepad_read(uint32 i) break; case 7: /*** Fourth High ***/ - + /* TH = 1 : ?1CBMXYZ Extra buttons returned in D3-0*/ if (input.pad[i] & INPUT_X) retval &= ~0x04; if (input.pad[i] & INPUT_Y) retval &= ~0x02; @@ -360,7 +361,7 @@ static inline uint32 gamepad_read(uint32 i) break; default: - break; + break; } /* bit7 is latched */ @@ -371,12 +372,12 @@ static inline void gamepad_write(uint32 i, uint32 data) { if (input.dev[i] == DEVICE_6BUTTON) { - /* TH=0 to TH=1 transition */ - if (!(gamepad[i].State & 0x40) && (data & 0x40)) - { - gamepad[i].Counter++; - gamepad[i].Delay = 0; - } + /* TH=0 to TH=1 transition */ + if (!(gamepad[i].State & 0x40) && (data & 0x40)) + { + gamepad[i].Counter++; + gamepad[i].Delay = 0; + } } gamepad[i].State = data; @@ -396,85 +397,85 @@ struct teamplayer static inline void teamplayer_reset(uint32 port) { - int i; - int index = 0; - int pad_input = 0; + int i; + int index = 0; + int pad_input = 0; - teamplayer[port].State = 0x60; /* TH = 1, TR = 1 */ - teamplayer[port].Counter = 0; + teamplayer[port].State = 0x60; /* TH = 1, TR = 1 */ + teamplayer[port].Counter = 0; - /* this table determines which gamepad input should be returned during acquisition sequence - index = teamplayer read table index: 0=1st read, 1=2nd read, ... - pad_input = gamepad input 0-14: 0=P1_DIR, 1=P1_SABC, 2=P1_MXYZ, 4=P2_DIR, 5=P2_SABC, ... - */ - for (i=0; i<4; i++) - { - if (input.dev[(4*port) + i] == DEVICE_3BUTTON) - { - teamplayer[port].Table[index++] = pad_input; - teamplayer[port].Table[index++] = pad_input + 1; - } - else if (input.dev[(4*port) + i] == DEVICE_6BUTTON) - { - teamplayer[port].Table[index++] = pad_input; - teamplayer[port].Table[index++] = pad_input + 1; - teamplayer[port].Table[index++] = pad_input + 2; - } - pad_input += 4; - } + /* this table determines which gamepad input should be returned during acquisition sequence + index = teamplayer read table index: 0=1st read, 1=2nd read, ... + pad_input = gamepad input 0-14: 0=P1_DIR, 1=P1_SABC, 2=P1_MXYZ, 4=P2_DIR, 5=P2_SABC, ... + */ + for (i=0; i<4; i++) + { + if (input.dev[(4*port) + i] == DEVICE_3BUTTON) + { + teamplayer[port].Table[index++] = pad_input; + teamplayer[port].Table[index++] = pad_input + 1; + } + else if (input.dev[(4*port) + i] == DEVICE_6BUTTON) + { + teamplayer[port].Table[index++] = pad_input; + teamplayer[port].Table[index++] = pad_input + 1; + teamplayer[port].Table[index++] = pad_input + 2; + } + pad_input += 4; + } } /* SEGA teamplayer returns successively: - PAD1 inputs - - PAD2 inputs - - PAD3 inputs - - PAD4 inputs + - PAD2 inputs + - PAD3 inputs + - PAD4 inputs Each PAD inputs is obtained through 2 or 3 sequential reads: 1/ DIR buttons - 2/ START,A,C,B buttons - 3/ MODE, X,Y,Z buttons (6Button only !) + 2/ START,A,C,B buttons + 3/ MODE, X,Y,Z buttons (6Button only !) */ static inline uint32 teamplayer_read_device(uint32 port, uint32 index) { - int retval = 0x7F; - int pad_input = teamplayer[port].Table[index] & 0x03; - int pad_num = (4 * port) + ((teamplayer[port].Table[index] >> 2) & 0x03); - - switch (pad_input) - { - case 0: - /* Directions Buttons */ - if (input.pad[pad_num] & INPUT_UP) retval &= ~0x01; - if (input.pad[pad_num] & INPUT_DOWN) retval &= ~0x02; - if (input.pad[pad_num] & INPUT_LEFT) retval &= ~0x04; - if (input.pad[pad_num] & INPUT_RIGHT) retval &= ~0x08; - break; - - case 1: - /* S,A,C,B Buttons */ - if (input.pad[pad_num] & INPUT_B) retval &= ~0x01; - if (input.pad[pad_num] & INPUT_C) retval &= ~0x02; - if (input.pad[pad_num] & INPUT_A) retval &= ~0x04; - if (input.pad[pad_num] & INPUT_START) retval &= ~0x08; - break; + int retval = 0x7F; + int pad_input = teamplayer[port].Table[index] & 0x03; + int pad_num = (4 * port) + ((teamplayer[port].Table[index] >> 2) & 0x03); - case 2: - /* M,X,Y,Z Buttons (6-Buttons only)*/ - if (input.pad[pad_num] & INPUT_Z) retval &= ~0x01; - if (input.pad[pad_num] & INPUT_Y) retval &= ~0x02; - if (input.pad[pad_num] & INPUT_X) retval &= ~0x04; - if (input.pad[pad_num] & INPUT_MODE) retval &= ~0x08; - break; - } + switch (pad_input) + { + case 0: + /* Directions Buttons */ + if (input.pad[pad_num] & INPUT_UP) retval &= ~0x01; + if (input.pad[pad_num] & INPUT_DOWN) retval &= ~0x02; + if (input.pad[pad_num] & INPUT_LEFT) retval &= ~0x04; + if (input.pad[pad_num] & INPUT_RIGHT) retval &= ~0x08; + break; - return retval; + case 1: + /* S,A,C,B Buttons */ + if (input.pad[pad_num] & INPUT_B) retval &= ~0x01; + if (input.pad[pad_num] & INPUT_C) retval &= ~0x02; + if (input.pad[pad_num] & INPUT_A) retval &= ~0x04; + if (input.pad[pad_num] & INPUT_START) retval &= ~0x08; + break; + + case 2: + /* M,X,Y,Z Buttons (6-Buttons only)*/ + if (input.pad[pad_num] & INPUT_Z) retval &= ~0x01; + if (input.pad[pad_num] & INPUT_Y) retval &= ~0x02; + if (input.pad[pad_num] & INPUT_X) retval &= ~0x04; + if (input.pad[pad_num] & INPUT_MODE) retval &= ~0x08; + break; + } + + return retval; } static inline uint32 teamplayer_read(uint32 port) { - int retval = 0x7F; - int padnum; + int retval = 0x7F; + int padnum; switch (teamplayer[port].Counter) /* acquisition sequence steps */ { @@ -490,7 +491,7 @@ static inline uint32 teamplayer_read(uint32 port) case 3: /* ack request: TH=0, TR handshake */ retval = 0x00; break; - + case 4: case 5: case 6: @@ -498,16 +499,16 @@ static inline uint32 teamplayer_read(uint32 port) padnum = (4 * port) + teamplayer[port].Counter - 4; retval = input.dev[padnum]; break; - + default: /* gamepads inputs acquisition */ retval = teamplayer_read_device(port, teamplayer[port].Counter - 8); break; } - + /* TL must match TR state */ retval &= ~0x10; if (teamplayer[port].State & 0x20) retval |= 0x10; - + return retval; } @@ -517,7 +518,7 @@ static inline void teamplayer_write(uint32 port, uint32 data) teamplayer[port].State = (data & io_reg[port+4]) | (teamplayer[port].State & ~io_reg[port+4]); if (old_state != teamplayer[port].State) teamplayer[port].Counter ++; if ((data&0x60) == 0x60) teamplayer[port].Counter = 0; -} +} /***************************************************************************** * 4WAYPLAY adapter @@ -531,7 +532,7 @@ static inline void wayplay_write(uint32 port, uint32 data) static inline uint32 wayplay_read(uint32 port) { - if (port == 1) return 0x7F; + if (port == 1) return 0x7F; if (input.current >= 4) return 0x70; /* multitap detection (TH2 = 1) */ return gamepad_read(input.current); /* 0x0C = Pad1, 0x1C = Pad2, ... */ } @@ -563,54 +564,54 @@ void gamepad_2_write (uint32 data) uint32 wayplay_1_read (void) { - return wayplay_read(0); + return wayplay_read(0); } uint32 wayplay_2_read (void) { - return wayplay_read(1); + return wayplay_read(1); } void wayplay_1_write (uint32 data) { - wayplay_write(0, data); + wayplay_write(0, data); } void wayplay_2_write (uint32 data) { - wayplay_write(1, data); + wayplay_write(1, data); } uint32 teamplayer_1_read (void) { - return teamplayer_read(0); + return teamplayer_read(0); } uint32 teamplayer_2_read (void) { - return teamplayer_read(1); + return teamplayer_read(1); } void teamplayer_1_write (uint32 data) { - teamplayer_write(0, data); + teamplayer_write(0, data); } void teamplayer_2_write (uint32 data) { - teamplayer_write(1, data); + teamplayer_write(1, data); } uint32 jcart_read(uint32 address) { - return (gamepad_read(5) | ((gamepad_read(6)&0x3f) << 8)); /* fixes Micro Machines 2 (is it correct ?) */ + return (gamepad_read(5) | ((gamepad_read(6)&0x3f) << 8)); /* fixes Micro Machines 2 (is it correct ?) */ } void jcart_write(uint32 address, uint32 data) { - gamepad_write(5, (data&1) << 6); - gamepad_write(6, (data&1) << 6); - return; + gamepad_write(5, (data&1) << 6); + gamepad_write(6, (data&1) << 6); + return; } /***************************************************************************** @@ -619,16 +620,16 @@ void jcart_write(uint32 address, uint32 data) *****************************************************************************/ void input_reset () { - int i,j; - - input.max = 0; + int i,j; + + input.max = 0; input.current = 0; - for (i=0; i 0) count_z80 += z80_execute(current_z80); - } - } - else - { - /* Bus released */ - if (zbusreq && zreset) - { - /* Z80 started */ - /* z80 was OFF during the last 68k cycles */ - /* we burn the appropriate number of z80 cycles */ - z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; - count_z80 = z80_cycles_to_run; - } - } + } + } + else + { + /* Bus released */ + if (zbusreq && zreset) + { + /* Z80 started */ + /* z80 was OFF during the last 68k cycles */ + /* we burn the appropriate number of z80 cycles */ + z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; + count_z80 = z80_cycles_to_run; + } + } - zbusreq = state; - zbusack = 1 ^ (zbusreq & zreset); + zbusreq = state; + zbusack = 1 ^ (zbusreq & zreset); } void gen_reset_w (uint32 state) { - uint32 z80_cycles_to_run; + uint32 z80_cycles_to_run; - if (state) - { - /* stop RESET process */ - if (!zbusreq && !zreset) - { - /* Z80 started */ - /* z80 was OFF during the last 68k cycles */ - /* we burn the appropriate number of z80 cycles */ - z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; - count_z80 = z80_cycles_to_run; - } - } - else - { - /* start RESET process */ - if (!zbusreq && zreset) - { - /* Z80 stopped */ - /* z80 was ON during the last 68k cycles */ - /* we execute the appropriate number of z80 cycles */ - z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; + if (state) + { + /* stop RESET process */ + if (!zbusreq && !zreset) + { + /* Z80 started */ + /* z80 was OFF during the last 68k cycles */ + /* we burn the appropriate number of z80 cycles */ + z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; + count_z80 = z80_cycles_to_run; + } + } + else + { + /* start RESET process */ + if (!zbusreq && zreset) + { + /* Z80 stopped */ + /* z80 was ON during the last 68k cycles */ + /* we execute the appropriate number of z80 cycles */ + z80_cycles_to_run = line_z80 + ((count_m68k - line_m68k)*7)/15; current_z80 = z80_cycles_to_run - count_z80; if (current_z80 > 0) count_z80 += z80_execute(current_z80); - } + } - /* Reset Z80 & YM2612 */ - _YM2612_Reset(); - z80_reset (); - } + /* Reset Z80 & YM2612 */ + _YM2612_Reset(); + z80_reset (); + } - zreset = state; - zbusack = 1 ^ (zbusreq & zreset); + zreset = state; + zbusack = 1 ^ (zbusreq & zreset); } void gen_bank_w (uint32 state) { - zbank = ((zbank >> 1) | ((state & 1) << 23)) & 0xFF8000; + zbank = ((zbank >> 1) | ((state & 1) << 23)) & 0xFF8000; } int z80_irq_callback (int param) { - zirq = 0; - z80_set_irq_line (0, CLEAR_LINE); - return 0xFF; + zirq = 0; + z80_set_irq_line (0, CLEAR_LINE); + return 0xFF; } diff --git a/source/hvc.h b/source/hvc.h index 2f1f449..466167d 100644 --- a/source/hvc.h +++ b/source/hvc.h @@ -125,41 +125,41 @@ /* V counter values for NTSC 192-line display */ uint8 vc_ntsc_192[262] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 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xD8, 0xD9, 0xDA, + 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; /* V counter values for NTSC 224-line display */ uint8 vc_ntsc_224[262] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82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int8 vc_ntsc_224[262] = { /* V counter values for NTSC 240-line display (invalid mode) */ uint8 vc_ntsc_240[262] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0x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86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 @@ -188,20 +188,20 @@ uint8 vc_ntsc_240[262] = { /* V counter values for PAL 192-line display */ uint8 vc_pal_192[313] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x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B, 0xDC, 0xDD, 0xDE, 0xDF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, @@ -213,20 +213,20 @@ uint8 vc_pal_192[313] = { /* V counter values for PAL 224-line display */ uint8 vc_pal_224[313] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5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6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x00, 0x01, 0x02, @@ -238,20 +238,20 @@ uint8 vc_pal_224[313] = { /* V counter values for PAL 240-line display */ uint8 vc_pal_240[313] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91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xB1, 0xB2, + 0xB2, 0xB3, 0xB3, 0xB4, 0xB4, 0xB4, 0xB5, 0xB5, 0xB6, 0xB6, 0xE4, 0xE4, 0xE4, 0xE5, 0xE5, 0xE6, 0xE6, 0xE7, 0xE7, 0xE7, 0xE8, 0xE8, 0xE9, 0xE9, 0xEA, 0xEA, 0xEB, 0xEB, 0xEB, 0xEC, 0xEC, 0xED, 0xED, 0xEE, 0xEE, 0xEE, 0xEF, 0xEF, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF2, 0xF2, 0xF3, 0xF3, 0xF4, 0xF4, @@ -406,7 +406,6 @@ uint8 cycle2hc40[488] = { 0xA1, 0xA2, 0xA2, 0xA3, 0xA3, 0xA4, 0xA4, }; - uint8 *vctab; uint8 *hctab; diff --git a/source/loadrom.c b/source/loadrom.c index 96b76ca..63bdd0a 100644 --- a/source/loadrom.c +++ b/source/loadrom.c @@ -25,48 +25,48 @@ #include "shared.h" /*** ROM Information ***/ -#define ROMCONSOLE 256 -#define ROMCOPYRIGHT 272 -#define ROMDOMESTIC 288 -#define ROMWORLD 336 -#define ROMTYPE 384 -#define ROMPRODUCT 386 -#define ROMCHECKSUM 398 -#define ROMIOSUPPORT 400 -#define ROMROMSTART 416 -#define ROMROMEND 420 -#define ROMRAMINFO 424 -#define ROMRAMSTART 436 -#define ROMRAMEND 440 -#define ROMMODEMINFO 444 -#define ROMMEMO 456 -#define ROMCOUNTRY 496 +#define ROMCONSOLE 256 +#define ROMCOPYRIGHT 272 +#define ROMDOMESTIC 288 +#define ROMWORLD 336 +#define ROMTYPE 384 +#define ROMPRODUCT 386 +#define ROMCHECKSUM 398 +#define ROMIOSUPPORT 400 +#define ROMROMSTART 416 +#define ROMROMEND 420 +#define ROMRAMINFO 424 +#define ROMRAMSTART 436 +#define ROMRAMEND 440 +#define ROMMODEMINFO 444 +#define ROMMEMO 456 +#define ROMCOUNTRY 496 -#define P3BUTTONS 1 -#define P6BUTTONS 2 -#define PKEYBOARD 4 -#define PPRINTER 8 -#define PBALL 16 -#define PFLOPPY 32 -#define PACTIVATOR 64 +#define P3BUTTONS 1 +#define P6BUTTONS 2 +#define PKEYBOARD 4 +#define PPRINTER 8 +#define PBALL 16 +#define PFLOPPY 32 +#define PACTIVATOR 64 #define PTEAMPLAYER 128 #define PMSYSTEMPAD 256 #define PSERIAL 512 -#define PTABLET 1024 -#define PPADDLE 2048 -#define PCDROM 4096 -#define PMOUSE 8192 +#define PTABLET 1024 +#define PPADDLE 2048 +#define PCDROM 4096 +#define PMOUSE 8192 int peripherals; uint16 realchecksum; ROMINFO rominfo; - /*************************************************************************** +/*************************************************************************** * Genesis ROM Manufacturers * * Based on the document provided at * http://www.zophar.net/tech/files/Genesis_ROM_Format.txt - ***************************************************************************/ + **************************************************************************/ COMPANYINFO companyinfo[MAXCOMPANY] = { {"ACLD", "Ballistic"}, {"RSI", "Razorsoft"}, @@ -186,35 +186,35 @@ uint16 GetRealChecksum (uint8 *rom, int length) ****************************************************************************/ int getcompany () { - char *s; - int i; - char company[10]; + char *s; + int i; + char company[10]; - for (i = 3; i < 8; i++) company[i - 3] = rominfo.copyright[i]; - company[5] = 0; + for (i = 3; i < 8; i++) company[i - 3] = rominfo.copyright[i]; + company[5] = 0; - /** OK, first look for a hyphen - * Capcom use T-12 for example - */ - s = strstr (company, "-"); - if (s != NULL) - { - s++; - strcpy (company, s); - } + /** OK, first look for a hyphen + * Capcom use T-12 for example + */ + s = strstr (company, "-"); + if (s != NULL) + { + s++; + strcpy (company, s); + } - /** Strip any trailing spaces **/ - for (i = strlen (company) - 1; i >= 0; i--) + /** Strip any trailing spaces **/ + for (i = strlen (company) - 1; i >= 0; i--) if (company[i] == 32) company[i] = 0; - if (strlen (company) == 0) return MAXCOMPANY - 1; + if (strlen (company) == 0) return MAXCOMPANY - 1; - for (i = 0; i < MAXCOMPANY - 1; i++) - { - if (!(strncmp (company, companyinfo[i].companyid, strlen (company)))) return i; - } + for (i = 0; i < MAXCOMPANY - 1; i++) + { + if (!(strncmp (company, companyinfo[i].companyid, strlen (company)))) return i; + } - return MAXCOMPANY - 1; + return MAXCOMPANY - 1; } @@ -236,11 +236,11 @@ void getrominfo (char *romheader) j=1; for (i=1; i<48; i++) { - if ((rominfo.domestic[j-1] != 32) || (romheader[ROMDOMESTIC + i] != 32)) - { - rominfo.domestic[j] = romheader[ROMDOMESTIC + i]; - j++; - } + if ((rominfo.domestic[j-1] != 32) || (romheader[ROMDOMESTIC + i] != 32)) + { + rominfo.domestic[j] = romheader[ROMDOMESTIC + i]; + j++; + } } rominfo.domestic[j] = 0; @@ -248,11 +248,11 @@ void getrominfo (char *romheader) j=1; for (i=1; i<48; i++) { - if ((rominfo.international[j-1] != 32) || (romheader[ROMWORLD + i] != 32)) - { - rominfo.international[j] = romheader[ROMWORLD + i]; - j++; - } + if ((rominfo.international[j-1] != 32) || (romheader[ROMWORLD + i] != 32)) + { + rominfo.international[j] = romheader[ROMWORLD + i]; + j++; + } } rominfo.international[j] = 0; @@ -277,8 +277,8 @@ void getrominfo (char *romheader) peripherals = 0; for (i = 0; i < 14; i++) - for (j=0; j < 14; j++) - if (rominfo.io_support[i] == peripheralinfo[j].pID[0]) peripherals |= (1 << j); + for (j=0; j < 14; j++) + if (rominfo.io_support[i] == peripheralinfo[j].pID[0]) peripherals |= (1 << j); for (i = 0; i < 8; i++) { @@ -292,63 +292,63 @@ void getrominfo (char *romheader) /* 05/05/2006: new region detection routine (taken from GENS sourcecode) */ void set_region () { - /* country codes used to differentiate region */ - /* 0001 = japan ntsc (1) */ - /* 0010 = japan pal (2) */ - /* 0100 = usa (4) */ - /* 1000 = europe (8) */ + /* country codes used to differentiate region */ + /* 0001 = japan ntsc (1) */ + /* 0010 = japan pal (2) */ + /* 0100 = usa (4) */ + /* 1000 = europe (8) */ - int country = 0; - int i = 0; - char c; + int country = 0; + int i = 0; + char c; - /* reading header to find the country */ - if (!strnicmp(rominfo.country, "eur", 3)) country |= 8; - else if (!strnicmp(rominfo.country, "usa", 3)) country |= 4; - else if (!strnicmp(rominfo.country, "jap", 3)) country |= 1; + /* reading header to find the country */ + if (!strnicmp(rominfo.country, "eur", 3)) country |= 8; + else if (!strnicmp(rominfo.country, "usa", 3)) country |= 4; + else if (!strnicmp(rominfo.country, "jap", 3)) country |= 1; - else for(i = 0; i < 4; i++) - { - c = toupper((int)rominfo.country[i]); - if (c == 'U') country |= 4; - else if (c == 'J') country |= 1; - else if (c == 'E') country |= 8; - else if (c < 16) country |= c; - else if ((c >= '0') && (c <= '9')) country |= c - '0'; - else if ((c >= 'A') && (c <= 'F')) country |= c - 'A' + 10; - } + else for(i = 0; i < 4; i++) + { + c = toupper((int)rominfo.country[i]); + if (c == 'U') country |= 4; + else if (c == 'J') country |= 1; + else if (c == 'E') country |= 8; + else if (c < 16) country |= c; + else if ((c >= '0') && (c <= '9')) country |= c - '0'; + else if ((c >= 'A') && (c <= 'F')) country |= c - 'A' + 10; + } - /* automatic detection */ - /* setting region */ - /* this is used by IO register */ - if (country & 4) region_code = REGION_USA; - else if (country & 1) region_code = REGION_JAPAN_NTSC; - else if (country & 8) region_code = REGION_EUROPE; - else if (country & 2) region_code = REGION_JAPAN_PAL; - else region_code = REGION_USA; + /* automatic detection */ + /* setting region */ + /* this is used by IO register */ + if (country & 4) region_code = REGION_USA; + else if (country & 1) region_code = REGION_JAPAN_NTSC; + else if (country & 8) region_code = REGION_EUROPE; + else if (country & 2) region_code = REGION_JAPAN_PAL; + else region_code = REGION_USA; - /* some games need specific REGION setting */ + /* some games need specific REGION setting */ if (((strstr(rominfo.product,"T-45033") != NULL) && (rominfo.checksum == 0x0F81)) || /* Alisia Dragon (E) */ - (strstr(rominfo.product,"T-69046-50") != NULL)) /* On Dal Jang Goon (Korea) */ - { - /* need PAL settings */ - region_code = REGION_EUROPE; - } - else if ((realchecksum == 0x532e) && (strstr(rominfo.product,"1011-00") != NULL)) - { - /* On Dal Jang Goon (Korea) needs JAP region code */ - region_code = REGION_JAPAN_NTSC; - } + (strstr(rominfo.product,"T-69046-50") != NULL)) /* On Dal Jang Goon (Korea) */ + { + /* need PAL settings */ + region_code = REGION_EUROPE; + } + else if ((realchecksum == 0x532e) && (strstr(rominfo.product,"1011-00") != NULL)) + { + /* On Dal Jang Goon (Korea) needs JAP region code */ + region_code = REGION_JAPAN_NTSC; + } - /* Force region setting */ - if (config.region_detect == 1) region_code = REGION_USA; - else if (config.region_detect == 2) region_code = REGION_EUROPE; - else if (config.region_detect == 3) region_code = REGION_JAPAN_NTSC; - else if (config.region_detect == 4) region_code = REGION_JAPAN_PAL; + /* Force region setting */ + if (config.region_detect == 1) region_code = REGION_USA; + else if (config.region_detect == 2) region_code = REGION_EUROPE; + else if (config.region_detect == 3) region_code = REGION_JAPAN_NTSC; + else if (config.region_detect == 4) region_code = REGION_JAPAN_PAL; - /* set cpu/vdp speed: PAL or NTSC */ - if ((region_code == REGION_EUROPE) || (region_code == REGION_JAPAN_PAL)) vdp_pal = 1; - else vdp_pal = 0; + /* set cpu/vdp speed: PAL or NTSC */ + if ((region_code == REGION_EUROPE) || (region_code == REGION_JAPAN_PAL)) vdp_pal = 1; + else vdp_pal = 0; } /* SMD (interleaved) rom support */ @@ -370,64 +370,64 @@ int load_rom(char *filename) int i, size, offset = 0; #ifdef NGC - size = genromsize; + size = genromsize; #else - uint8 *ptr; - ptr = load_archive(filename, &size); + uint8 *ptr; + ptr = load_archive(filename, &size); if(!ptr) return (0); memcpy(cart_rom, ptr + offset, size); free(ptr); #endif - /* detect interleaved roms (.smd format) */ - if (strncmp((char *)(cart_rom + 0x100),"SEGA", 4) && ((size / 512) & 1)) - { - size -= 512; - offset += 512; + /* detect interleaved roms (.smd format) */ + if (strncmp((char *)(cart_rom + 0x100),"SEGA", 4) && ((size / 512) & 1)) + { + size -= 512; + offset += 512; - for (i = 0; i < (size / 0x4000); i += 1) - { - deinterleave_block (cart_rom + offset + (i * 0x4000)); - } + for (i = 0; i < (size / 0x4000); i += 1) + { + deinterleave_block (cart_rom + offset + (i * 0x4000)); + } - memcpy(cart_rom, cart_rom + offset, size); - } + memcpy(cart_rom, cart_rom + offset, size); + } - /* max. 10 MBytes supported */ - if (size > 0xA00000) size = 0xA00000; - genromsize = size; - - /* clear unused ROM space */ - if (size < 0xA00000) memset (cart_rom + size, 0x00, 0xA00000 - size); + /* max. 10 MBytes supported */ + if (size > 0xA00000) size = 0xA00000; + genromsize = size; + + /* clear unused ROM space */ + if (size < 0xA00000) memset (cart_rom + size, 0x00, 0xA00000 - size); - getrominfo((char *)cart_rom); /* get infos from ROM header */ - set_region(); /* set game region (PAL/NTSC, JAP/USA/EUR) */ + getrominfo((char *)cart_rom); /* get infos from ROM header */ + set_region(); /* set game region (PAL/NTSC, JAP/USA/EUR) */ #ifdef LSB_FIRST - /* Byteswap ROM */ - uint8 temp; - for(i = 0; i < genromsize; i += 2) - { - temp = cart_rom[i]; - cart_rom[i] = cart_rom[i+1]; - cart_rom[i+1] = temp; - } + /* Byteswap ROM */ + uint8 temp; + for(i = 0; i < genromsize; i += 2) + { + temp = cart_rom[i]; + cart_rom[i] = cart_rom[i+1]; + cart_rom[i+1] = temp; + } #endif - /* byteswapped RADICA dumps (from Haze) */ - if (((strstr(rominfo.product,"-K0101") != NULL) && (rominfo.checksum == 0xf424)) || - ((strstr(rominfo.product,"-K0109") != NULL) && (rominfo.checksum == 0x4f10))) - { - uint8 temp; - for(i = 0; i < genromsize; i += 2) - { - temp = cart_rom[i]; - cart_rom[i] = cart_rom[i+1]; - cart_rom[i+1] = temp; - } - } + /* byteswapped RADICA dumps (from Haze) */ + if (((strstr(rominfo.product,"-K0101") != NULL) && (rominfo.checksum == 0xf424)) || + ((strstr(rominfo.product,"-K0109") != NULL) && (rominfo.checksum == 0x4f10))) + { + uint8 temp; + for(i = 0; i < genromsize; i += 2) + { + temp = cart_rom[i]; + cart_rom[i] = cart_rom[i+1]; + cart_rom[i+1] = temp; + } + } - /* console hardware */ + /* console hardware */ if (strstr(rominfo.consoletype, "SEGA PICO") != NULL) system_hw = SYSTEM_PICO; else if (strstr(rominfo.consoletype, "SEGA MEGADRIVE") != NULL) system_hw = SYSTEM_MEGADRIVE; else system_hw = SYSTEM_GENESIS; diff --git a/source/loadrom.h b/source/loadrom.h index edbab9b..ab295a7 100644 --- a/source/loadrom.h +++ b/source/loadrom.h @@ -27,22 +27,22 @@ typedef struct { - char consoletype[18]; /* Genesis or Mega Drive */ - char copyright[18]; /* Copyright message */ - char domestic[50]; /* Domestic name of ROM */ - char international[50]; /* International name of ROM */ - char ROMType[4]; /* Educational or Game */ - char product[14]; /* Product serial number */ - unsigned short checksum; /* Checksum */ - char io_support[18]; /* Actually 16 chars :) */ - unsigned int romstart; - unsigned int romend; - char RAMInfo[14]; - unsigned int ramstart; - unsigned int ramend; - char modem[14]; - char memo[50]; - char country[18]; + char consoletype[18]; /* Genesis or Mega Drive */ + char copyright[18]; /* Copyright message */ + char domestic[50]; /* Domestic name of ROM */ + char international[50]; /* International name of ROM */ + char ROMType[4]; /* Educational or Game */ + char product[14]; /* Product serial number */ + unsigned short checksum; /* Checksum */ + char io_support[18]; /* Actually 16 chars :) */ + unsigned int romstart; /* ROM start address */ + unsigned int romend; /* ROM end address */ + char RAMInfo[14]; /* Backup RAM header */ + unsigned int ramstart; /* RAM start address */ + unsigned int ramend; /* RAM end address */ + char modem[14]; /* Sega Modem support */ + char memo[50]; /* Misc */ + char country[18]; /* Country flag */ } ROMINFO; typedef struct diff --git a/source/macros.h b/source/macros.h index e4d9c6f..7224500 100644 --- a/source/macros.h +++ b/source/macros.h @@ -4,20 +4,23 @@ #ifdef LSB_FIRST #define READ_BYTE(BASE, ADDR) (BASE)[(ADDR)^1] -#define READ_WORD(BASE, ADDR) (((BASE)[ADDR]<<8) | \ - (BASE)[(ADDR)+1]) -#define READ_WORD_LONG(BASE, ADDR) (((BASE)[ADDR]<<24) | \ - ((BASE)[(ADDR)+1]<<16) | \ - ((BASE)[(ADDR)+2]<<8) | \ - (BASE)[(ADDR)+3]) + +#define READ_WORD(BASE, ADDR) (((BASE)[ADDR]<<8) | (BASE)[(ADDR)+1]) + +#define READ_WORD_LONG(BASE, ADDR) (((BASE)[ADDR]<<24) | \ + ((BASE)[(ADDR)+1]<<16) | \ + ((BASE)[(ADDR)+2]<<8) | \ + (BASE)[(ADDR)+3]) #define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[(ADDR)^1] = (VAL)&0xff -#define WRITE_WORD(BASE, ADDR, VAL) (BASE)[ADDR] = ((VAL)>>8) & 0xff; \ - (BASE)[(ADDR)+1] = (VAL)&0xff -#define WRITE_WORD_LONG(BASE, ADDR, VAL) (BASE)[(ADDR] = ((VAL)>>24) & 0xff; \ - (BASE)[(ADDR)+1] = ((VAL)>>16)&0xff; \ - (BASE)[(ADDR)+2] = ((VAL)>>8)&0xff; \ - (BASE)[(ADDR)+3] = (VAL)&0xff + +#define WRITE_WORD(BASE, ADDR, VAL) (BASE)[ADDR] = ((VAL)>>8) & 0xff; \ + (BASE)[(ADDR)+1] = (VAL)&0xff + +#define WRITE_WORD_LONG(BASE, ADDR, VAL) (BASE)[(ADDR] = ((VAL)>>24) & 0xff; \ + (BASE)[(ADDR)+1] = ((VAL)>>16)&0xff; \ + (BASE)[(ADDR)+2] = ((VAL)>>8)&0xff; \ + (BASE)[(ADDR)+3] = (VAL)&0xff #else diff --git a/source/membnk.c b/source/membnk.c index 74f9873..596d673 100644 --- a/source/membnk.c +++ b/source/membnk.c @@ -32,7 +32,7 @@ uint32 zbank_unused_r(uint32 address) #ifdef LOGERROR error("Z80 bank unused read %06X\n", address); #endif - return (address & 1) ? 0x00 : 0xFF; + return (address & 1) ? 0x00 : 0xFF; } void zbank_unused_w(uint32 address, uint32 data) @@ -47,7 +47,7 @@ uint32 zbank_lockup_r(uint32 address) #ifdef LOGERROR error("Z80 bank lockup read %06X\n", address); #endif - gen_running = config.force_dtack; + gen_running = config.force_dtack; return 0xFF; } @@ -56,7 +56,7 @@ void zbank_lockup_w(uint32 address, uint32 data) #ifdef LOGERROR error("Z80 bank lockup write %06X = %02X\n", address, data); #endif - gen_running = config.force_dtack; + gen_running = config.force_dtack; } /* I/O & Control registers */ @@ -64,57 +64,57 @@ uint32 zbank_read_ctrl_io(uint32 address) { switch ((address >> 8) & 0xff) { - case 0x00: /* I/O chip */ + case 0x00: /* I/O chip */ if (address & 0xe0) return zbank_unused_r(address); else return (io_read((address >> 1) & 0x0f)); - case 0x11: /* BUSACK */ + case 0x11: /* BUSACK */ if (address & 1) return zbank_unused_r(address); else return (0xfe | zbusack); - case 0x30: /* TIME */ + case 0x30: /* TIME */ if (cart_hw.time_r) return cart_hw.time_r(address); else return zbank_unused_r(address); - case 0x10: /* MEMORY MODE */ - case 0x12: /* RESET */ - case 0x20: /* MEGA-CD */ - case 0x40: /* TMSS */ - case 0x41: /* BOOTROM */ - case 0x44: /* RADICA */ - case 0x50: /* SVP REGISTERS */ + case 0x10: /* MEMORY MODE */ + case 0x12: /* RESET */ + case 0x20: /* MEGA-CD */ + case 0x40: /* TMSS */ + case 0x41: /* BOOTROM */ + case 0x44: /* RADICA */ + case 0x50: /* SVP REGISTERS */ return zbank_unused_r(address); - default: /* Invalid address */ + default: /* Invalid address */ return zbank_lockup_r(address); } } void zbank_write_ctrl_io(uint32 address, uint32 data) -{ +{ switch ((address >> 8) & 0xff) { - case 0x00: /* I/O chip */ + case 0x00: /* I/O chip */ if ((address & 0xe1) == 0x01) io_write((address >> 1) & 0x0f, data); /* get /LWR only */ else zbank_unused_w(address, data); return; - case 0x11: /* BUSREQ */ + case 0x11: /* BUSREQ */ if (address & 1) zbank_unused_w(address, data); else gen_busreq_w(data & 1); return; - case 0x12: /* RESET */ + case 0x12: /* RESET */ if (address & 1) zbank_unused_w(address, data); else gen_reset_w(data & 1); return; - case 0x30: /* TIME */ + case 0x30: /* TIME */ if (cart_hw.time_w) cart_hw.time_w(address, data); else zbank_unused_w(address, data); return; - case 0x41: /* BOOTROM */ + case 0x41: /* BOOTROM */ if (address & 1) { m68k_memory_map[0].base = (data & 1) ? default_rom : bios_rom; @@ -130,15 +130,15 @@ void zbank_write_ctrl_io(uint32 address, uint32 data) else zbank_unused_w (address, data); return; - case 0x10: /* MEMORY MODE */ - case 0x20: /* MEGA-CD */ - case 0x40: /* TMSS */ - case 0x44: /* RADICA */ + case 0x10: /* MEMORY MODE */ + case 0x20: /* MEGA-CD */ + case 0x40: /* TMSS */ + case 0x44: /* RADICA */ case 0x50: /* SVP REGISTERS */ zbank_unused_w(address, data); return; - default: /* Invalid address */ + default: /* Invalid address */ zbank_lockup_w(address, data); return; } @@ -150,33 +150,33 @@ uint32 zbank_read_vdp(uint32 address) { switch (address & 0xfd) { - case 0x00: /* DATA */ + case 0x00: /* DATA */ return (vdp_data_r() >> 8); - - case 0x01: /* DATA */ + + case 0x01: /* DATA */ return (vdp_data_r() & 0xff); - - case 0x04: /* CTRL */ + + case 0x04: /* CTRL */ return (0xfc | ((vdp_ctrl_r() >> 8) & 3)); - case 0x05: /* CTRL */ + case 0x05: /* CTRL */ return (vdp_ctrl_r() & 0xff); - - case 0x08: /* HVC */ + + case 0x08: /* HVC */ case 0x0c: return (vdp_hvc_r() >> 8); - - case 0x09: /* HVC */ + + case 0x09: /* HVC */ case 0x0d: return (vdp_hvc_r() & 0xff); - - case 0x18: /* Unused */ + + case 0x18: /* Unused */ case 0x19: case 0x1c: case 0x1d: return zbank_unused_r(address); - default: /* Invalid address */ + default: /* Invalid address */ return zbank_lockup_r(address); } } @@ -185,15 +185,15 @@ void zbank_write_vdp(uint32 address, uint32 data) { switch (address & 0xfc) { - case 0x00: /* Data port */ + case 0x00: /* Data port */ vdp_data_w(data << 8 | data); return; - case 0x04: /* Control port */ + case 0x04: /* Control port */ vdp_ctrl_w(data << 8 | data); return; - case 0x10: /* PSG */ + case 0x10: /* PSG */ case 0x14: if (address & 1) psg_write(0, data); else zbank_unused_w(address, data); @@ -207,7 +207,7 @@ void zbank_write_vdp(uint32 address, uint32 data) vdp_test_w(data << 8 | data); return; - default: /* Invalid address */ + default: /* Invalid address */ zbank_lockup_w(address, data); return; } diff --git a/source/memz80.c b/source/memz80.c index 9d95e8d..368f544 100644 --- a/source/memz80.c +++ b/source/memz80.c @@ -24,8 +24,8 @@ #define LOG_PORT 0 /* 1= Log Z80 I/O port accesses */ /* - Handlers for access to unused addresses and those which make the - machine lock up. + Handlers for access to unused addresses and those which make the + machine lock up. */ static inline void z80_unused_w(unsigned int address, unsigned int data) { @@ -39,7 +39,7 @@ static inline unsigned int z80_unused_r(unsigned int address) #ifdef LOGERROR error("Z80 unused read %04X\n", address); #endif - return 0xff; + return 0xff; } static inline void z80_lockup_w(unsigned int address, unsigned int data) @@ -47,7 +47,7 @@ static inline void z80_lockup_w(unsigned int address, unsigned int data) #ifdef LOGERROR error("Z80 lockup write %04X = %02X\n", address, data); #endif - gen_running = config.force_dtack; + gen_running = config.force_dtack; } static inline unsigned int z80_lockup_r(unsigned int address) @@ -55,8 +55,8 @@ static inline unsigned int z80_lockup_r(unsigned int address) #ifdef LOGERROR error("Z80 lockup read %04X\n", address); #endif - gen_running = config.force_dtack; - return 0xff; + gen_running = config.force_dtack; + return 0xff; } /* VDP access @@ -85,34 +85,34 @@ static inline unsigned int z80_vdp_r(unsigned int address) case 0x0d: return (vdp_hvc_r() & 0xff); - case 0x18: /* Unused */ - case 0x19: + case 0x18: /* Unused */ + case 0x19: case 0x1c: - case 0x1d: - return z80_unused_r(address); + case 0x1d: + return z80_unused_r(address); default: /* Invalid address */ - return z80_lockup_r(address); - } + return z80_lockup_r(address); + } } static inline void z80_vdp_w(unsigned int address, unsigned int data) { switch (address & 0xfc) { - case 0x00: /* Data port */ + case 0x00: /* Data port */ vdp_data_w(data << 8 | data); return; - case 0x04: /* Control port */ + case 0x04: /* Control port */ vdp_ctrl_w(data << 8 | data); return; - case 0x10: /* PSG */ + case 0x10: /* PSG */ case 0x14: if (address & 1) psg_write(0, data); else z80_unused_w(address, data); - return; + return; case 0x18: /* Unused */ z80_unused_w(address, data); @@ -122,7 +122,7 @@ static inline void z80_vdp_w(unsigned int address, unsigned int data) vdp_test_w(data << 8 | data); return; - default: /* Invalid address */ + default: /* Invalid address */ z80_lockup_w(address, data); return; } @@ -194,22 +194,22 @@ void cpu_writemem16(unsigned int address, unsigned int data) if (zbank_memory_map[slot].write) (*zbank_memory_map[slot].write)(address, data); else WRITE_BYTE(m68k_memory_map[slot].base, address&0xffff, data); return; + } } } -} /* - Port handlers. Ports are unused when not in Mark III compatability mode. + Port handlers. Ports are unused when not in Mark III compatability mode. - Games that access ports anyway: - - Thunder Force IV reads port $BF in it's interrupt handler. + Games that access ports anyway: + Thunder Force IV reads port $BF in it's interrupt handler. */ unsigned int cpu_readport16(unsigned int port) { #if LOG_PORT error("Z80 read port %04X\n", port); -#endif +#endif return 0xFF; } diff --git a/source/ngc/config.c b/source/ngc/config.c index 25efa65..86f0f74 100644 --- a/source/ngc/config.c +++ b/source/ngc/config.c @@ -12,15 +12,19 @@ void config_save() { - if (!use_FAT) return; + char pathname[MAXPATHLEN]; + + if (!fat_enabled) return; /* first check if directory exist */ - DIR_ITER *dir = diropen("/genplus"); - if (dir == NULL) mkdir("/genplus",S_IRWXU); + sprintf (pathname, DEFAULT_PATH); + DIR_ITER *dir = diropen(pathname); + if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); /* open configuration file */ - FILE *fp = fopen("/genplus/genplus.ini", "wb"); + sprintf (pathname, "%s/config.ini", pathname); + FILE *fp = fopen(pathname, "wb"); if (fp == NULL) return; /* save options */ @@ -31,8 +35,11 @@ void config_save() void config_load() { + char pathname[MAXPATHLEN]; + /* open configuration file */ - FILE *fp = fopen("/genplus/genplus.ini", "rb"); + sprintf (pathname, "%s/genplus.ini", DEFAULT_PATH); + FILE *fp = fopen(pathname, "rb"); if (fp == NULL) return; /* read version */ @@ -42,7 +49,7 @@ void config_load() if (strcmp(version,CONFIG_VERSION)) return; /* read file */ - fp = fopen("/genplus/genplus.ini", "rb"); + fp = fopen(pathname, "rb"); fread(&config, sizeof(config), 1, fp); fclose(fp); } diff --git a/source/ngc/config.h b/source/ngc/config.h index b2f0a42..cd90ef3 100644 --- a/source/ngc/config.h +++ b/source/ngc/config.h @@ -44,7 +44,7 @@ t_config config; extern void config_save(); extern void config_load(); extern void set_config_defaults(void); -extern bool use_FAT; +extern bool fat_enabled; #endif /* _CONFIG_H_ */ diff --git a/source/ngc/gui/dvd.c b/source/ngc/dvd.c similarity index 78% rename from source/ngc/gui/dvd.c rename to source/ngc/dvd.c index 266c94d..bbfbd36 100644 --- a/source/ngc/gui/dvd.c +++ b/source/ngc/dvd.c @@ -1,28 +1,17 @@ /**************************************************************************** * Nintendo Gamecube DVD Reading Library * - * This is NOT a complete DVD library, in that it works for reading - * ISO9660 discs only. + * Low-Level DVD access * - * If you need softmod drivecodes etc, look elsewhere. - * There are known issues with libogc dvd handling, so these work - * outside of it ,if you will. - * - * This is ideal for using with a gc-linux self booting DVD only. - * Go http://www.gc-linux.org for further information and the tools - * for your platform. - * - * To keep libOGC stable, make sure you call DVD_Init before using - * these functions. ***************************************************************************/ #include "shared.h" + #ifdef HW_RVL #include "di/di.h" #endif - #ifndef HW_RVL -static u64 DvdMaxOffset = 0x57057C00; /* 1.4 GB max. */ +static u64 DvdMaxOffset = 0x57057C00; /* 1.4 GB max. by default */ static vu32* const dvd = (u32*)0xCC006000; /* DVD I/O Address base */ static u8 *inquiry=(unsigned char *)0x80000004; /* pointer to drive ID */ #else @@ -32,7 +21,6 @@ static u64 DvdMaxOffset = 0x118244F00LL; /* 4.7 GB max. */ static u8 DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32); /* data buffer for all DVD operations */ - /*************************************************************************** * dvd_read * @@ -85,19 +73,19 @@ u32 dvd_read (void *dst, u32 len, u64 offset) void dvd_motor_off( ) { #ifndef HW_RVL - dvd[0] = 0x2e; - dvd[1] = 0; - dvd[2] = 0xe3000000; - dvd[3] = 0; - dvd[4] = 0; - dvd[5] = 0; - dvd[6] = 0; - dvd[7] = 1; // Do immediate - while (dvd[7] & 1); + dvd[0] = 0x2e; + dvd[1] = 0; + dvd[2] = 0xe3000000; + dvd[3] = 0; + dvd[4] = 0; + dvd[5] = 0; + dvd[6] = 0; + dvd[7] = 1; // Do immediate + while (dvd[7] & 1); - /*** PSO Stops blackscreen at reload ***/ - dvd[0] = 0x14; - dvd[1] = 0; + /*** PSO Stops blackscreen at reload ***/ + dvd[0] = 0x14; + dvd[1] = 0; #else DI_StopMotor(); diff --git a/source/ngc/dvd.h b/source/ngc/dvd.h new file mode 100644 index 0000000..ccf99aa --- /dev/null +++ b/source/ngc/dvd.h @@ -0,0 +1,19 @@ +/**************************************************************************** + * Nintendo Gamecube DVD Reading Library + * + * Low-Level DVD access + * + ***************************************************************************/ + +#ifndef _DVD_H_ +#define _DVD_H_ + +extern u32 dvd_read (void *dst, u32 len, u64 offset); +extern void dvd_motor_off (); + +#ifndef HW_RVL +extern void uselessinquiry (); +extern void dvd_drive_detect(); +#endif + +#endif diff --git a/source/ngc/fileio.c b/source/ngc/fileio.c index d71cc5e..eaa861b 100644 --- a/source/ngc/fileio.c +++ b/source/ngc/fileio.c @@ -9,8 +9,8 @@ #include "dvd.h" #include "font.h" #include "unzip.h" -#include +#include /* * PKWare Zip Header - adopted into zip standard @@ -24,7 +24,7 @@ */ typedef struct { - unsigned int zipid __attribute__ ((__packed__)); // 0x04034b50 + unsigned int zipid __attribute__ ((__packed__)); // 0x04034b50 unsigned short zipversion __attribute__ ((__packed__)); unsigned short zipflags __attribute__ ((__packed__)); unsigned short compressionMethod __attribute__ ((__packed__)); @@ -119,34 +119,34 @@ int UnZipDVD (unsigned char *outbuffer, u64 discoffset, int length) { zs.avail_in = zipchunk; zs.next_in = (Bytef *) & readbuffer[zipoffset]; - + /*** Now inflate until input buffer is exhausted ***/ do - { - zs.avail_out = ZIPCHUNK; - zs.next_out = (Bytef *) & out; - res = inflate (&zs, Z_NO_FLUSH); + { + zs.avail_out = ZIPCHUNK; + zs.next_out = (Bytef *) & out; + res = inflate (&zs, Z_NO_FLUSH); - if (res == Z_MEM_ERROR) - { - inflateEnd (&zs); - return 0; - } + if (res == Z_MEM_ERROR) + { + inflateEnd (&zs); + return 0; + } - have = ZIPCHUNK - zs.avail_out; - if (have) - { + have = ZIPCHUNK - zs.avail_out; + if (have) + { /*** Copy to normal block buffer ***/ - memcpy (&outbuffer[bufferoffset], &out, have); - bufferoffset += have; - } + memcpy (&outbuffer[bufferoffset], &out, have); + bufferoffset += have; + } } while (zs.avail_out == 0); - /*** Readup the next 2k block ***/ + /*** Readup the next 2k block ***/ zipoffset = 0; zipchunk = ZIPCHUNK; - + discoffset += 2048; dvd_read (&readbuffer, 2048, discoffset); } diff --git a/source/ngc/fileio_dvd.c b/source/ngc/fileio_dvd.c new file mode 100644 index 0000000..3edc173 --- /dev/null +++ b/source/ngc/fileio_dvd.c @@ -0,0 +1,399 @@ +/**************************************************************************** + * + * DVD ISO9660/Joliet loading support + * + ***************************************************************************/ +#include "shared.h" +#include "font.h" +#include "fileio_dvd.h" +#include "filesel.h" +#include "fileio.h" +#include "dvd.h" + +#ifdef HW_RVL +#include "di/di.h" +#endif + +/** Minimal ISO Directory Definition **/ +#define RECLEN 0 /* Record length */ +#define EXTENT 6 /* Extent */ +#define FILE_LENGTH 14 /* File length (BIG ENDIAN) */ +#define FILE_FLAGS 25 /* File flags */ +#define FILENAME_LENGTH 32 /* Filename length */ +#define FILENAME 33 /* ASCIIZ filename */ + +/** Minimal Primary Volume Descriptor **/ +#define PVDROOT 0x9c + +/** Static Variables **/ +static u64 rootdir = 0; /* current root directory offset */ +static u64 basedir = 0; /* base directory offset */ +static int rootdirlength = 0; /* current root directory length */ +static int IsJoliet = 0; +static int diroffset = 0; +static char dvdbuffer[2048]; + +/**************************************************************************** + * Primary Volume Descriptor + * + * The PVD should reside between sector 16 and 31. + * This is for single session DVD only. + ****************************************************************************/ +static int getpvd () +{ + int sector = 16; + u32 rootdir32; + + basedir = rootdirlength = 0; + IsJoliet = -1; + + /** Look for Joliet PVD first **/ + while (sector < 32) + { + if (dvd_read (&dvdbuffer, 2048, (u64)(sector << 11))) + { + if (memcmp (&dvdbuffer, "\2CD001\1", 8) == 0) + { + memcpy(&rootdir32, &dvdbuffer[PVDROOT + EXTENT], 4); + basedir = (u64)rootdir32; + memcpy (&rootdirlength, &dvdbuffer[PVDROOT + FILE_LENGTH], 4); + basedir <<= 11; + IsJoliet = 1; + break; + } + } + else return 0; /*** Can't read sector! ***/ + sector++; + } + + if (IsJoliet > 0) return 1; /*** Joliet PVD Found ? ***/ + + /*** Look for standard ISO9660 PVD ***/ + sector = 16; + while (sector < 32) + { + if (dvd_read (&dvdbuffer, 2048, (u64)(sector << 11))) + { + if (memcmp (&dvdbuffer, "\1CD001\1", 8) == 0) + { + memcpy (&rootdir32, &dvdbuffer[PVDROOT + EXTENT], 4); + basedir = (u64)rootdir32; + memcpy (&rootdirlength, &dvdbuffer[PVDROOT + FILE_LENGTH], 4); + IsJoliet = 0; + basedir <<= 11; + break; + } + } + else return 0; /*** Can't read sector! ***/ + sector++; + } + + return (IsJoliet == 0); +} + +/**************************************************************************** + * getentry + * + * Support function to return the next file entry, if any + * Declared static to avoid accidental external entry. + ****************************************************************************/ +static int getentry (int entrycount) +{ + char fname[512]; /* Huge, but experience has determined this */ + char *ptr; + char *filename; + char *filenamelength; + char *rr; + int j; + u32 offset32; + + /* Basic checks */ + if (entrycount >= MAXFILES) return 0; + if (diroffset >= 2048) return 0; + + /** Decode this entry **/ + if (dvdbuffer[diroffset]) /* Record length available */ + { + /* Update offsets into sector buffer */ + ptr = (char *) &dvdbuffer[0]; + ptr += diroffset; + filename = ptr + FILENAME; + filenamelength = ptr + FILENAME_LENGTH; + + /* Check for wrap round - illegal in ISO spec, + * but certain crap writers do it! */ + if ((diroffset + dvdbuffer[diroffset]) > 2048) return 0; + + if (*filenamelength) + { + memset (&fname, 0, 512); + + /*** Do ISO 9660 first ***/ + if (!IsJoliet) strcpy (fname, filename); + else + { + /*** The more tortuous unicode joliet entries ***/ + for (j = 0; j < (*filenamelength >> 1); j++) + { + fname[j] = filename[j * 2 + 1]; + } + + fname[j] = 0; + + if (strlen (fname) >= MAXJOLIET) fname[MAXJOLIET - 1] = 0; + if (strlen (fname) == 0) fname[0] = filename[0]; + } + + if (strlen (fname) == 0) strcpy (fname, "."); + else + { + if (fname[0] == 1) strcpy (fname, ".."); + else + { + /* + * Move *filenamelength to t, + * Only to stop gcc warning for noobs :) + */ + int t = *filenamelength; + fname[t] = 0; + } + } + + /** Rockridge Check **/ + rr = strstr (fname, ";"); + if (rr != NULL) *rr = 0; + + strcpy (filelist[entrycount].filename, fname); + memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4); + filelist[entrycount].offset = (u64)offset32; + memcpy (&filelist[entrycount].length, &dvdbuffer[diroffset + FILE_LENGTH], 4); + memcpy (&filelist[entrycount].flags, &dvdbuffer[diroffset + FILE_FLAGS], 1); + + filelist[entrycount].offset <<= 11; + filelist[entrycount].flags = filelist[entrycount].flags & 2; + filelist[entrycount].filename_offset = 0; + + /*** Prepare for next entry ***/ + diroffset += dvdbuffer[diroffset]; + + return 1; + } + } + return 0; +} + +/*************************************************************************** + * DVD_UpdateRootDir + * + * Update DVD current root directory + ***************************************************************************/ +int DVD_UpdateDir(int go_up) +{ + /* current directory doesn't change */ + if (selection == 0) return 1; + + /* root has no parent directory */ + if (go_up && (basedir == rootdir)) return 0; + + /* by default, update current directory */ + rootdir = filelist[selection].offset; + rootdirlength = filelist[selection].length; + + /* reinit selector (previous value is saved for one level) */ + if (selection == 1) + { + selection = old_selection; + offset = old_offset; + old_selection = 0; + old_offset = 0; + } + else + { + /* save current selector value */ + old_selection = selection; + old_offset = offset; + selection = 0; + offset = 0; + } + + return 1; +} + +/**************************************************************************** + * DVD_ParseDirectory + * + * This function will parse the directory tree. + * It relies on rootdir and rootdirlength being pre-populated by a call to + * getpvd, a previous parse or a menu selection. + * + * The return value is number of files collected, or 0 on failure. + ****************************************************************************/ +int DVD_ParseDirectory () +{ + int pdlength; + u64 pdoffset; + u64 rdoffset; + int len = 0; + int filecount = 0; + + pdoffset = rdoffset = rootdir; + pdlength = rootdirlength; + filecount = 0; + + /** Clear any existing values ***/ + memset (&filelist, 0, sizeof (FILEENTRIES) * MAXFILES); + + /*** Get as many files as possible ***/ + while (len < pdlength) + { + if (dvd_read (&dvdbuffer, 2048, pdoffset) == 0) return 0; + + diroffset = 0; + + while (getentry (filecount)) + { + if (filecount < MAXFILES) filecount++; + } + + len += 2048; + pdoffset = rdoffset + len; + } + return filecount; +} + +/**************************************************************************** + * DVD_LoadFile + * + * This function will load a BIN, SMD or ZIP file from DVD into the ROM buffer. + * The index values indicates the file position in filentry list + * This functions return the actual size of data copied into the buffer + * + ****************************************************************************/ +int DVD_LoadFile (unsigned char *buffer) +{ + /* file size */ + int length = filelist[selection].length; + + if (length > 0) + { + /* Read first data chunk */ + char readbuffer[2048]; + u64 discoffset = filelist[selection].offset; + dvd_read (&readbuffer, 2048, discoffset); + + /* determine file type */ + if (!IsZipFile ((char *) readbuffer)) + { + /* How many 2k blocks to read */ + int blocks = length / 2048; + int readoffset = 0; + int i; + + /* read data chunks */ + for (i = 0; i < blocks; i++) + { + dvd_read(readbuffer, 2048, discoffset); + discoffset += 2048; + memcpy (buffer + readoffset, readbuffer, 2048); + readoffset += 2048; + } + + /* final read */ + i = length % 2048; + if (i) + { + dvd_read (readbuffer, 2048, discoffset); + memcpy (buffer + readoffset, readbuffer, i); + } + + return length; + } + else + { + return UnZipDVD (buffer, discoffset, length); + } + } + + return 0; +} + +/**************************************************************************** + * DVD_Open + * + * Function to load a DVD directory and display to user. + ****************************************************************************/ + +int DVD_Open () +{ + /* reset flags */ + useFAT = 0; + + /* is DVD mounted ? */ + if (!getpvd()) + { + /* mount DVD */ + ShowAction("Mounting DVD ... Wait"); + +#ifdef HW_RVL + u32 val; + DI_GetCoverRegister(&val); + + if(val & 0x1) + { + WaitPrompt("No Disc inserted !"); + return 0; + } + + DI_Mount(); + while(DI_GetStatus() & DVD_INIT); + if (!(DI_GetStatus() & DVD_READY)) + { + char msg[50]; + sprintf(msg, "DI Status Error: 0x%08X\n",DI_GetStatus()); + WaitPrompt(msg); + return 0; + } +#else + DVD_Mount(); +#endif + + haveDVDdir = 0; + if (!getpvd()) + { + WaitPrompt ("Failed to mount DVD"); + return 0; + } + } + + if (haveDVDdir == 0) + { + /* reset root directory */ + rootdir = basedir; + + /* parse root directory */ + ShowAction("Reading Directory ..."); + int max = DVD_ParseDirectory (); + if (max) + { + /* set DVD as default */ + haveDVDdir = 1; + haveFATdir = 0; + + /* reset File selector */ + maxfiles = max; + offset = 0; + selection = 0; + old_offset = 0; + old_selection = 0; + return FileSelector (); + } + else + { + /* no entries found */ + WaitPrompt ("no files found !"); + return 0; + } + } + + return FileSelector (); +} diff --git a/source/ngc/fileio_dvd.h b/source/ngc/fileio_dvd.h new file mode 100644 index 0000000..e37599d --- /dev/null +++ b/source/ngc/fileio_dvd.h @@ -0,0 +1,14 @@ +/**************************************************************************** + * + * DVD ISO9660/Joliet loading support + * + ***************************************************************************/ +#ifndef _FILEIO_DVD_H +#define _FILEIO_DVD_H + +extern int DVD_UpdateDir(int go_up); +extern int DVD_ParseDirectory(); +extern int DVD_LoadFile(unsigned char* buffer); +extern int DVD_Open (); + +#endif diff --git a/source/ngc/fileio_fat.c b/source/ngc/fileio_fat.c new file mode 100644 index 0000000..57f24d8 --- /dev/null +++ b/source/ngc/fileio_fat.c @@ -0,0 +1,313 @@ +/**************************************************************************** + * FAT loading support + * + ***************************************************************************/ +#include "shared.h" +#include "font.h" +#include "fileio_fat.h" +#include "filesel.h" +#include "fileio.h" +#include "history.h" + +/* current FAT directory */ +static char fatdir[256]; + +/* current FAT device */ +static int fat_type = 0; +static int useHistory = 0; + +/*************************************************************************** + * FAT_UpdateDir + * + * Update FAT current root directory + ***************************************************************************/ +int FAT_UpdateDir(int go_up) +{ + int size=0; + char *test; + char temp[1024]; + + /* current directory doesn't change */ + if (strcmp(filelist[selection].filename,".") == 0) return 1; + + /* go up to parent directory */ + if (strcmp(filelist[selection].filename,"..") == 0) + { + /* determine last subdirectory namelength */ + sprintf(temp,"%s",fatdir); + test= strtok(temp,"/"); + while (test != NULL) + { + size = strlen(test); + test = strtok(NULL,"/"); + } + + /* remove last subdirectory name */ + size = strlen(fatdir) - size; + fatdir[size-1] = 0; + + /* restore previous selector state */ + selection = old_selection; + offset = old_offset; + + /* reset old selection */ + old_selection = 0; + old_offset = 0; + } + else if (go_up) + { + /* root has no parent directory */ + return 0; + } + else + { + /* by default, simply append folder name */ + sprintf(fatdir, "%s%s/",fatdir, filelist[selection].filename); + + /* save current selector state */ + old_selection = selection; + old_offset = offset; + + /* reset selection */ + selection = 0; + offset = 0; + } + return 1; +} + +/*************************************************************************** + * FileSortCallback (Marty Disibio) + * + * Quick sort callback to sort file entries with the following order: + * . + * .. + * + * + ***************************************************************************/ +static int FileSortCallback(const void *f1, const void *f2) +{ + /* Special case for implicit directories */ + if(((FILEENTRIES *)f1)->filename[0] == '.' || ((FILEENTRIES *)f2)->filename[0] == '.') + { + if(strcmp(((FILEENTRIES *)f1)->filename, ".") == 0) { return -1; } + if(strcmp(((FILEENTRIES *)f2)->filename, ".") == 0) { return 1; } + if(strcmp(((FILEENTRIES *)f1)->filename, "..") == 0) { return -1; } + if(strcmp(((FILEENTRIES *)f2)->filename, "..") == 0) { return 1; } + } + + /* If one is a file and one is a directory the directory is first. */ + if(((FILEENTRIES *)f1)->flags == 1 && ((FILEENTRIES *)f2)->flags == 0) return -1; + if(((FILEENTRIES *)f1)->flags == 0 && ((FILEENTRIES *)f2)->flags == 1) return 1; + + return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename); +} + +/*************************************************************************** + * FAT_ParseDirectory + * + * List files into one FAT directory + ***************************************************************************/ +int FAT_ParseDirectory() +{ + int nbfiles = 0; + char filename[MAXPATHLEN]; + struct stat filestat; + + /* open directory */ + DIR_ITER *dir = diropen (fatdir); + if (dir == NULL) + { + sprintf(filename, "Error opening %s", fatdir); + WaitPrompt (filename); + return 0; + } + + while ((dirnext(dir, filename, &filestat) == 0) && (nbfiles < MAXFILES)) + { + if (strcmp(filename,".") != 0) + { + memset(&filelist[nbfiles], 0, sizeof (FILEENTRIES)); + sprintf(filelist[nbfiles].filename,"%s",filename); + filelist[nbfiles].length = filestat.st_size; + filelist[nbfiles].flags = (filestat.st_mode & S_IFDIR) ? 1 : 0; + nbfiles++; + } + } + + dirclose(dir); + + /* Sort the file list */ + qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback); + + return nbfiles; +} + +/**************************************************************************** + * FAT_LoadFile + * + * This function will load a BIN, SMD or ZIP file from DVD into the ROM buffer. + * This functions return the actual size of data copied into the buffer + * + ****************************************************************************/ +int FAT_LoadFile (unsigned char *buffer) +{ + /* If loading from history then we need to setup a few more things. */ + if(useHistory) + { + /* Get the parent folder for the file. */ + strncpy(fatdir, history.entries[selection].filepath, MAXJOLIET-1); + fatdir[MAXJOLIET-1] = '\0'; + + /* Get the length of the file. This has to be done + * before calling LoadFile(). */ + char filepath[MAXJOLIET]; + struct stat filestat; + snprintf(filepath, MAXJOLIET-1, "%s%s", history.entries[selection].filepath, history.entries[selection].filename); + filepath[MAXJOLIET-1] = '\0'; + if(stat(filepath, &filestat) == 0) + { + filelist[selection].length = filestat.st_size; + } + } + + /* file size */ + int length = filelist[selection].length; + + if (length > 0) + { + /* Add/move the file to the top of the history. */ + history_add_file(fatdir, filelist[selection].filename); + + /* full filename */ + char fname[MAXPATHLEN]; + sprintf(fname, "%s%s",fatdir,filelist[selection].filename); + + /* open file */ + FILE *sdfile = fopen(fname, "rb"); + if (sdfile == NULL) + { + WaitPrompt ("Unable to open file!"); + haveFATdir = 0; + return 0; + } + + /* Read first data chunk */ + unsigned char temp[2048]; + fread(temp, 1, 2048, sdfile); + fclose(sdfile); + + /* determine file type */ + if (!IsZipFile ((char *) temp)) + { + /* re-open and read file */ + sdfile = fopen(fname, "rb"); + if (sdfile) + { + fread(buffer, 1, length, sdfile); + fclose(sdfile); + return length; + } + } + else + { + /* unzip file */ + return UnZipFAT(buffer, fname); + } + } + + return 0; +} + +/**************************************************************************** + * OpenFAT + * + * Function to load a FAT directory and display to user. + ****************************************************************************/ +int FAT_Open(int type) +{ + int max = 0; + char root[10] = ""; + + /* reset flags */ + useFAT = 1; + useHistory = 0; + + /* FAT header */ +#ifdef HW_RVL + if (type == TYPE_SD) sprintf (root, "sd:"); + else if (type == TYPE_USB) sprintf (root, "usb:"); +#endif + + /* if FAT device type changed, reload filelist */ + if (fat_type != type) + { + haveFATdir = 0; + } + fat_type = type; + + /* update filelist */ + if (haveFATdir == 0) + { + if (type == TYPE_RECENT) + { + /* fetch history list */ + useHistory = 1; + int i; + for(i=0; i < NUM_HISTORY_ENTRIES; i++) + { + if(history.entries[i].filepath[0] > 0) + { + filelist[i].offset = 0; + filelist[i].length = 0; + filelist[i].flags = 0; + filelist[i].filename_offset = 0; + strncpy(filelist[i].filename, history.entries[i].filename, MAXJOLIET-1); + filelist[i].filename[MAXJOLIET-1] = '\0'; + max++; + } + else + { + /* Found the end of the list. */ + break; + } + } + } + else + { + /* reset root directory */ + sprintf (fatdir, "%s%s/roms", root, DEFAULT_PATH); + + /* if directory doesn't exist, use root as default */ + DIR_ITER *dir = diropen(fatdir); + if (dir == NULL) sprintf (fatdir, "%s/", root); + else dirclose(dir); + + /* parse root directory */ + ShowAction("Reading Directory ..."); + max = FAT_ParseDirectory (); + } + + if (max) + { + /* FAT is default */ + haveFATdir = 1; + haveDVDdir = 0; + + /* reset file selection */ + maxfiles = max; + offset = 0; + selection = 0; + old_offset = 0; + old_selection = 0; + return FileSelector (); + } + else + { + /* no entries found */ + WaitPrompt ("no files found !"); + return 0; + } + } + + return FileSelector (); +} diff --git a/source/ngc/fileio_fat.h b/source/ngc/fileio_fat.h new file mode 100644 index 0000000..b4fbc6f --- /dev/null +++ b/source/ngc/fileio_fat.h @@ -0,0 +1,21 @@ +/**************************************************************************** + * + * FAT loading support + * + ***************************************************************************/ +#ifndef _FILEIO_FAT_H +#define _FILEIO_FAT_H + +#define TYPE_RECENT 0 +#define TYPE_SD 1 + +#ifdef HW_RVL +#define TYPE_USB 2 +#endif + +extern int FAT_UpdateDir(int go_up); +extern int FAT_ParseDirectory(void); +extern int FAT_LoadFile(unsigned char* buffer); +extern int FAT_Open (int device); + +#endif diff --git a/source/ngc/gcaram.c b/source/ngc/gcaram.c index 680b8bf..01b8cdf 100644 --- a/source/ngc/gcaram.c +++ b/source/ngc/gcaram.c @@ -9,10 +9,8 @@ #include "shared.h" #define ARAMSTART 0x8000 - - -#define ARAM_READ 1 -#define ARAM_WRITE 0 +#define ARAM_READ 1 +#define ARAM_WRITE 0 /** * StartARAM @@ -20,8 +18,7 @@ * Passing NULL for array list, and 0 items to allocate. * Required so libOGC knows to handle any interrupts etc. */ -void -StartARAM () +void StartARAM () { AR_Init (NULL, 0); } @@ -31,8 +28,7 @@ StartARAM () * * Move data from MAIN memory to ARAM */ -void -ARAMPut (char *src, char *dst, int len) +void ARAMPut (char *src, char *dst, int len) { DCFlushRange (src, len); AR_StartDMA( ARAM_WRITE, (u32)src, (u32)dst, len); @@ -51,16 +47,3 @@ ARAMFetch (char *dst, char *src, int len) AR_StartDMA( ARAM_READ, (u32) dst, (u32) src, len); while (AR_GetDMAStatus()); } - -/** - * ShadowROM - * Copy the rom from cart_rom into ARAM - * NB: libOGC appears to use the first 0x4000 bytes. - * As there's plenty left, all ARAM addresses are 0x8000 based. - * Here, the ROM is simply copied in one swift movement :) - */ -void -ShadowROM () -{ - ARAMPut ((char *)cart_rom, (void *) ARAMSTART, genromsize); -} diff --git a/source/ngc/gcaram.h b/source/ngc/gcaram.h index 277f8b6..72b0b6f 100644 --- a/source/ngc/gcaram.h +++ b/source/ngc/gcaram.h @@ -7,8 +7,11 @@ * Good to know :) */ -extern void StartARAM (); -void ShadowROM (); -void ARAMFetch (char *src, char *dst, int len); -void ARAMPut (char *src, char *dst, int len); +#ifndef _ARAM_H +#define _ARAM_H +extern void StartARAM (); +extern void ARAMFetch (char *src, char *dst, int len); +extern void ARAMPut (char *src, char *dst, int len); + +#endif diff --git a/source/ngc/gui/dvd.h b/source/ngc/gui/dvd.h deleted file mode 100644 index c7728d9..0000000 --- a/source/ngc/gui/dvd.h +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** - * Nintendo Gamecube DVD Reading Library - * - * This is NOT a complete DVD library, in that it works for reading - * ISO9660 discs only. - * - * If you need softmod drivecodes etc, look elsewhere. - * There are known issues with libogc dvd handling, so these work - * outside of it ,if you will. - * - * This is ideal for using with a gc-linux self booting DVD only. - * Go http://www.gc-linux.org for further information and the tools - * for your platform. - * - * To keep libOGC stable, make sure you call DVD_Init before using - * these functions. - ***************************************************************************/ -#ifndef _DVD_H_ -#define _DVD_H_ - -extern u32 dvd_read (void *dst, u32 len, u64 offset); -extern void dvd_motor_off (); - -#ifndef HW_RVL -extern void uselessinquiry (); -extern void dvd_drive_detect(); -#endif - -#endif diff --git a/source/ngc/gui/filesel.c b/source/ngc/gui/filesel.c index aee1c4a..dc5641b 100644 --- a/source/ngc/gui/filesel.c +++ b/source/ngc/gui/filesel.c @@ -11,56 +11,22 @@ * ***************************************************************************/ #include "shared.h" -#include "iso9660.h" #include "font.h" -#include "fileio.h" -#include "history.h" -#include "dvd.h" +#include "fileio_dvd.h" +#include "fileio_fat.h" +#include "filesel.h" -#ifdef HW_RVL -#include -#endif +/* Global Variables */ +int maxfiles = 0; +int offset = 0; +int selection = 0; +int old_selection = 0; +int old_offset = 0; +int useFAT = 0; +int useHistory = 0; +int haveDVDdir = 0; +int haveFATdir = 0; -#define PAGESIZE 12 - -static int maxfiles; -static int offset = 0; -static int selection = 0; -static int old_selection = 0; -static int old_offset = 0; -static char rootFATdir[256]; -static u8 haveDVDdir = 0; -static u8 haveFATdir = 0; -static u8 UseFAT = 0; -static u8 UseHistory = 0; -static int LoadFile (unsigned char *buffer); - -/*************************************************************************** - * FileSortCallback (Marty Disibio) - * - * Quick sort callback to sort file entries with the following order: - * . - * .. - * - * - ***************************************************************************/ -static int FileSortCallback(const void *f1, const void *f2) -{ - /* Special case for implicit directories */ - if(((FILEENTRIES *)f1)->filename[0] == '.' || ((FILEENTRIES *)f2)->filename[0] == '.') - { - if(strcmp(((FILEENTRIES *)f1)->filename, ".") == 0) { return -1; } - if(strcmp(((FILEENTRIES *)f2)->filename, ".") == 0) { return 1; } - if(strcmp(((FILEENTRIES *)f1)->filename, "..") == 0) { return -1; } - if(strcmp(((FILEENTRIES *)f2)->filename, "..") == 0) { return 1; } - } - - /* If one is a file and one is a directory the directory is first. */ - if(((FILEENTRIES *)f1)->flags == 1 && ((FILEENTRIES *)f2)->flags == 0) return -1; - if(((FILEENTRIES *)f1)->flags == 0 && ((FILEENTRIES *)f2)->flags == 1) return 1; - - return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename); -} /*************************************************************************** * ShowFiles @@ -87,137 +53,17 @@ static void ShowFiles (int offset, int selection) SetScreen (); } -/*************************************************************************** - * updateFATdirname - * - * Update ROOT directory while browsing SDCARD - ***************************************************************************/ -static int updateFATdirname() -{ - int size=0; - char *test; - char temp[1024]; - - /* current directory doesn't change */ - if (strcmp(filelist[selection].filename,".") == 0) return 0; - - /* go up to parent directory */ - else if (strcmp(filelist[selection].filename,"..") == 0) - { - /* determine last subdirectory namelength */ - sprintf(temp,"%s",rootFATdir); - test= strtok(temp,"/"); - while (test != NULL) - { - size = strlen(test); - test = strtok(NULL,"/"); - } - - /* remove last subdirectory name */ - size = strlen(rootFATdir) - size; - rootFATdir[size-1] = 0; - } - else - { - sprintf(rootFATdir, "%s%s/",rootFATdir, filelist[selection].filename); - } - - return 1; -} - -/*************************************************************************** - * parseFATdirectory - * - * List files into one SDCARD directory - ***************************************************************************/ -static int parseFATdirectory() -{ - int nbfiles = 0; - char filename[MAXPATHLEN]; - struct stat filestat; - - /* open directory */ - DIR_ITER *dir = diropen (rootFATdir); - if (dir == NULL) - { - sprintf(filename, "Error opening %s", rootFATdir); - WaitPrompt (filename); - return 0; - } - - while (dirnext(dir, filename, &filestat) == 0) - { - if (strcmp(filename,".") != 0) - { - memset(&filelist[nbfiles], 0, sizeof (FILEENTRIES)); - sprintf(filelist[nbfiles].filename,"%s",filename); - filelist[nbfiles].length = filestat.st_size; - filelist[nbfiles].flags = (filestat.st_mode & S_IFDIR) ? 1 : 0; - nbfiles++; - } - } - - dirclose(dir); - - /* Sort the file list */ - qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback); - - return nbfiles; -} - -/**************************************************************************** - * FileSelected - * - * Called when a file is selected by the user inside the FileSelector loop. - ****************************************************************************/ -static int FileSelected() -{ - /* If loading from history then we need to setup a few more things. */ - if(UseHistory) - { - /* Get the parent folder for the file. */ - strncpy(rootFATdir, history.entries[selection].filepath, MAXJOLIET-1); - rootFATdir[MAXJOLIET-1] = '\0'; - - /* Get the length of the file. This has to be done - * before calling LoadFile(). */ - char filepath[MAXJOLIET]; - struct stat filestat; - snprintf(filepath, MAXJOLIET-1, "%s%s", history.entries[selection].filepath, history.entries[selection].filename); - filepath[MAXJOLIET-1] = '\0'; - if(stat(filepath, &filestat) == 0) - { - filelist[selection].length = filestat.st_size; - } - } - - /* Add/move the file to the top of the history. */ - if (UseFAT) history_add_file(rootFATdir, filelist[selection].filename); - - rootdir = filelist[selection].offset; - rootdirlength = filelist[selection].length; - memfile_autosave(); - genromsize = LoadFile(cart_rom); - if (genromsize) - { - reloadrom(); - memfile_autoload(); - return 1; - } - - return 0; -} - /**************************************************************************** * FileSelector * * Let user select a file from the File listing ****************************************************************************/ -static int FileSelector () +int FileSelector() { short p; int redraw = 1; int go_up = 0; + int ret; int i,size; while (1) @@ -297,22 +143,7 @@ static int FileSelector () if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; redraw = 1; } - - /* go up one directory or quit */ - if (p & PAD_BUTTON_B) - { - filelist[selection].filename_offset = 0; - if (UseFAT) - { - if (strcmp(filelist[0].filename,"..") != 0) return 0; - } - else - { - if (basedir == rootdir) return 0; - } - go_up = 1; - } - + /* quit */ if (p & PAD_TRIGGER_Z) { @@ -321,349 +152,45 @@ static int FileSelector () } /* open selected file or directory */ - if ((p & PAD_BUTTON_A) || go_up) + if ((p & PAD_BUTTON_A) || (p & PAD_BUTTON_B)) { filelist[selection].filename_offset = 0; - if (go_up) + go_up = 0; + + if (p & PAD_BUTTON_B) { - /* select item #1 */ - go_up = 0; - selection = UseFAT ? 0 : 1; + /* go up one directory or quit */ + go_up = 1; + selection = useFAT ? 0 : 1; } /*** This is directory ***/ if (filelist[selection].flags) { - /* SDCARD directory handler */ - if (UseFAT) - { - /* update current directory */ - if (updateFATdirname()) - { - /* reinit selector (previous value is saved for one level) */ - if (selection == 0) - { - selection = old_selection; - offset = old_offset; - old_selection = 0; - old_offset = 0; - } - else - { - /* save current selector value */ - old_selection = selection; - old_offset = offset; - selection = 0; - offset = 0; - } - - /* set new entry list */ - maxfiles = parseFATdirectory(); - if (!maxfiles) - { - /* quit */ - WaitPrompt ("No files found !"); - haveFATdir = 0; - return 0; - } - } - } - else /* DVD directory handler */ - { - /* move to a new directory */ - if (selection != 0) - { - /* update current directory */ - rootdir = filelist[selection].offset; - rootdirlength = filelist[selection].length; - - /* reinit selector (previous value is saved for one level) */ - if (selection == 1) - { - selection = old_selection; - offset = old_offset; - old_selection = 0; - old_offset = 0; - } - else - { - /* save current selector value */ - old_selection = selection; - old_offset = offset; - selection = 0; - offset = 0; - } + /* get new directory */ + ret = useFAT ? FAT_UpdateDir(go_up) : DVD_UpdateDir(go_up); - /* get new entry list */ - maxfiles = parseDVDdirectory (); - } - } - } - else /*** This is a file ***/ - { - return FileSelected(); - } - redraw = 1; - } - } -} - -/**************************************************************************** - * OpenDVD - * - * Function to load a DVD directory and display to user. - ****************************************************************************/ -int OpenDVD () -{ - UseFAT = 0; - UseHistory = 0; - - if (!getpvd()) - { - /* mount DVD */ - ShowAction("Mounting DVD ... Wait"); - -#ifndef HW_RVL - DVD_Mount(); -#else - u32 val; - DI_GetCoverRegister(&val); - - if(val & 0x1) - { - WaitPrompt("No Disc inserted !"); - return 0; - } - DI_Mount(); - while(DI_GetStatus() & DVD_INIT); - if (!(DI_GetStatus() & DVD_READY)) - { - char msg[50]; - sprintf(msg, "DI Status Error: 0x%08X\n",DI_GetStatus()); - WaitPrompt(msg); - return 0; - } -#endif - - haveDVDdir = 0; - if (!getpvd()) - { - WaitPrompt ("Failed to mount DVD"); - return 0; - } - } - - if (haveDVDdir == 0) - { - /* don't mess with SD entries */ - haveFATdir = 0; - - /* reinit selector */ - rootdir = basedir; - old_selection = selection = offset = old_offset = 0; - } - - /* Parse root directory and get entries list */ - ShowAction("Reading Directory ..."); - if ((maxfiles = parseDVDdirectory ())) - { - /* Select an entry */ - haveDVDdir = 1; - return FileSelector (); - } - else - { - /* no entries found */ - WaitPrompt ("no files found !"); - haveDVDdir = 0; - return 0; - } -} - -/**************************************************************************** - * OpenFAT - * - * Function to load a FAT directory and display to user. - ****************************************************************************/ -int OpenFAT (char *name) -{ - UseFAT = 1; - UseHistory = 0; - - if (haveFATdir == 0) - { - /* don't mess with DVD entries */ - haveDVDdir = 0; - - /* reinit selector */ - old_selection = selection = offset = old_offset = 0; - - /* Reset SDCARD root directory */ - sprintf (rootFATdir, "%s/genplus/roms/", name); - - /* if directory doesn't exist, use root */ - DIR_ITER *dir = diropen(rootFATdir); - if (dir == NULL) sprintf (rootFATdir, "%s/", name); - else dirclose(dir); - } - - /* Parse root directory and get entries list */ - ShowAction("Reading Directory ..."); - if ((maxfiles = parseFATdirectory ())) - { - /* Select an entry */ - haveFATdir = 1; - return FileSelector (); - } - else - { - /* no entries found */ - WaitPrompt ("no files found !"); - haveFATdir = 0; - return -1; - } -} - -/**************************************************************************** - * OpenHistory - * - * Function to load a recent file from SDCARD (Marty Disibio) - ****************************************************************************/ -int OpenHistory() -{ - int i; - - UseFAT = 1; - UseHistory = 1; - - /* don't mess with other entries */ - haveFATdir = 0; - haveDVDdir = 0; - - /* reinit selector */ - old_selection = selection = offset = old_offset = 0; - - /* Recreate the file listing from the history - * as if all of the roms were in the same directory. */ - ShowAction("Reading Files ..."); - - maxfiles = 0; - for(i=0; i < NUM_HISTORY_ENTRIES; i++) - { - if(history.entries[i].filepath[0] > 0) - { - filelist[i].offset = 0; - filelist[i].length = 0; - filelist[i].flags = 0; - filelist[i].filename_offset = 0; - strncpy(filelist[i].filename, history.entries[i].filename, MAXJOLIET-1); - filelist[i].filename[MAXJOLIET-1] = '\0'; - - maxfiles++; - } - else - { - /* Found the end of the list. */ - break; - } - } - - if(!maxfiles) - { - WaitPrompt ("No recent files"); - return 0; - } - - return FileSelector(); -} - - -/**************************************************************************** - * LoadFile - * - * This function will load a file from DVD or SDCARD, in BIN, SMD or ZIP format. - * The values for offset and length are inherited from rootdir and - * rootdirlength. - * - * The buffer parameter should re-use the initial ROM buffer. - ****************************************************************************/ -static int LoadFile (unsigned char *buffer) -{ - u64 discoffset = 0; - char readbuffer[2048]; - char fname[MAXPATHLEN]; - FILE *sdfile = NULL; - - if (rootdirlength == 0) return 0; - - /* SDCard access */ - if (UseFAT) - { - /* open file */ - sprintf(fname, "%s%s",rootFATdir,filelist[selection].filename); - sdfile = fopen(fname, "rb"); - if (sdfile == NULL) - { - WaitPrompt ("Unable to open file!"); - haveFATdir = 0; - return -1; - } - } - - ShowAction ("Loading ... Wait"); - - /* Read first data chunk */ - if (UseFAT) - { - fread(readbuffer, 1, 2048, sdfile); - } - else - { - discoffset = rootdir; - dvd_read (&readbuffer, 2048, discoffset); - } - - /* determine file type */ - if (!IsZipFile ((char *) readbuffer)) - { - if (UseFAT) - { - /* go back to file start and read file */ - fseek(sdfile, 0, SEEK_SET); - fread(buffer, 1, rootdirlength, sdfile); - fclose(sdfile); - } - else - { - /* How many 2k blocks to read */ - int blocks = rootdirlength / 2048; - int readoffset = 0; - int i; - - /* read data chunks */ - for (i = 0; i < blocks; i++) - { - dvd_read(readbuffer, 2048, discoffset); - discoffset += 2048; - memcpy (buffer + readoffset, readbuffer, 2048); - readoffset += 2048; + /* get new entry list or quit */ + if (ret) maxfiles = useFAT ? FAT_ParseDirectory() : DVD_ParseDirectory(); + else return 0; } - /* final read */ - i = rootdirlength % 2048; - if (i) + /*** This is a file ***/ + else { - dvd_read (readbuffer, 2048, discoffset); - memcpy (buffer + readoffset, readbuffer, i); + /* Load file */ + genromsize = useFAT ? FAT_LoadFile(cart_rom) : DVD_LoadFile(cart_rom); + if (genromsize) + { + memfile_autosave(); + reloadrom(); + memfile_autoload(); + return 1; + } + + return 0; } + redraw = 1; } } - else - { - /* unzip file */ - if (UseFAT) return UnZipFAT(buffer, fname); - else return UnZipDVD (buffer, discoffset, rootdirlength); - } - - return rootdirlength; } diff --git a/source/ngc/gui/filesel.h b/source/ngc/gui/filesel.h new file mode 100644 index 0000000..d32988e --- /dev/null +++ b/source/ngc/gui/filesel.h @@ -0,0 +1,35 @@ +/**************************************************************************** + * ROM Selection Interface + * + ***************************************************************************/ +#ifndef _FILESEL_H +#define _FILESEL_H + +#define MAXJOLIET 256 +#define MAXFILES 1000 +#define PAGESIZE 12 + +typedef struct +{ + u64 offset; + unsigned int length; + char flags; + char filename[MAXJOLIET]; + u16 filename_offset; +}FILEENTRIES; + +FILEENTRIES filelist[MAXFILES]; + +/* Global Variables */ +extern int maxfiles; +extern int offset; +extern int selection; +extern int old_selection; +extern int old_offset; +extern int useFAT; +extern int haveDVDdir; +extern int haveFATdir; + +extern int FileSelector(); + +#endif diff --git a/source/ngc/gui/font.c b/source/ngc/gui/font.c index b9f024e..8710aba 100644 --- a/source/ngc/gui/font.c +++ b/source/ngc/gui/font.c @@ -7,614 +7,7 @@ #include "shared.h" #include "gpback.h" -/*** IPL Font (ripped from original BOOTROM) ***/ -#if 0 -static unsigned char iplfont[]= -{ - 0x59,0x61,0x79,0x30,0x00,0x01,0x01,0x10,0x00,0x00,0x03,0x08,0x00,0x00,0x13,0x94, - 0xfd,0x77,0x7e,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de,0xc3,0xba,0xc0,0x81,0x31,0x5c,0xb2,0x7f, - 0xc9,0xac,0xbd,0xfe,0x39,0xff,0xf2,0x8a,0xd5,0x34,0x2d,0xe4,0x83,0xff,0x7f,0xf4, - 0xff,0x0b,0xff,0xf5,0xaa,0xa2,0x49,0xd1,0x0b,0xe3,0x73,0x7f,0x97,0xf0,0xaa,0x0a, - 0x8d,0xf3,0xe5,0xca,0x3f,0x6f,0xdf,0xfd,0x6e,0xa9,0xb5,0x51,0x13,0x7f,0x47,0x56, - 0xfe,0xb1,0x51,0x54,0xa6,0x0c,0x16,0xef,0x55,0xa9,0xc5,0x52,0x8f,0xcf,0xcd,0xf7, - 0x7d,0x22,0x0a,0x88,0xca,0x4f,0xf2,0xe2,0x80,0x65,0x41,0x6b,0x68,0x5f,0xfd,0x85, - 0xfd,0xca,0x58,0xfe,0xb3,0xfb,0x52,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x03,0x10,0x09,0x10,0x07,0x10,0x15, - 0x20,0x0a,0x30,0x13,0x10,0x0e,0x10,0x0a,0x10,0x06,0x10,0x17,0x10,0x1e,0x10,0x6b, - 0x10,0x00,0x10,0x58,0x10,0x00,0x20,0x12,0x10,0x85,0x50,0x00,0x20,0x00,0x20,0x1f, - 0x40,0x10,0x10,0x88,0x00,0x00,0x10,0x01,0x00,0x3f,0x20,0x01,0x80,0x6f,0x30,0x01, - 0x00,0x7f,0x80,0x9f,0x00,0x2d,0x80,0xcf,0x00,0x60,0x90,0x5f,0x12,0x05,0xc0,0x9f, - 0xb1,0x1d,0xa0,0x5f,0x01,0x3e,0x30,0x01,0x01,0x5f,0x01,0x8f,0x00,0x2f,0x51,0xe7, - 0x01,0xef,0xa2,0x1f,0x10,0xf1,0x00,0x00,0x70,0xcf,0xa2,0xfe,0x83,0x0f,0x01,0x8f, - 0x03,0x3f,0x83,0x6f,0x10,0x5f,0x01,0xef,0xb0,0x8f,0x03,0xaf,0x01,0xb0,0xb0,0x01, - 0x04,0x3f,0x94,0x65,0x04,0x72,0x10,0x00,0xe4,0xaf,0x14,0x2f,0x45,0xcc,0xf4,0x2f, - 0x20,0x01,0x23,0xf3,0x92,0xe0,0x12,0x1d,0x11,0x8d,0x12,0x35,0x20,0xc7,0xf3,0x10, - 0x05,0x54,0x10,0xdb,0x60,0x01,0x05,0x8f,0x10,0x82,0x30,0x01,0x05,0xbf,0x13,0xd2, - 0x12,0xe1,0x03,0xf1,0x30,0x01,0x40,0x01,0x83,0xff,0x01,0xc9,0x06,0x5a,0x86,0x7d, - 0x04,0x5e,0x15,0xb1,0xd6,0x73,0x50,0x01,0x36,0xdc,0x10,0x07,0xd7,0x20,0x80,0x01, - 0x07,0x40,0x42,0xf2,0x03,0x0b,0x23,0x20,0x30,0x90,0x26,0x94,0x10,0x2f,0x20,0x9b, - 0x05,0xa1,0x17,0x25,0x50,0x01,0xc7,0xdf,0x05,0xbf,0x21,0xbb,0x37,0xf9,0x06,0x0b, - 0x31,0x07,0x13,0x71,0x07,0x36,0x18,0x55,0x18,0x2d,0x13,0x4f,0x08,0xd8,0x22,0x0f, - 0x40,0x5f,0x20,0x3d,0x13,0x56,0x10,0x1e,0x61,0x9b,0x12,0x3e,0x2a,0x25,0x97,0x1b, - 0x03,0x0b,0x27,0xc7,0x17,0xff,0x09,0x8d,0x13,0xff,0x07,0xcc,0x13,0x01,0x72,0xef, - 0x00,0xad,0x70,0x01,0x54,0x6e,0x64,0x01,0x04,0x60,0x20,0x01,0x08,0x1d,0x20,0x01, - 0x01,0x50,0x13,0xca,0x3b,0xe2,0x06,0x6f,0x61,0xff,0x0b,0x1a,0x83,0xfb,0x0b,0x3b, - 0x24,0x01,0x8b,0x6b,0x03,0x01,0x62,0x6f,0x1a,0x62,0x00,0x8f,0x35,0xa5,0x9b,0xc4, - 0x43,0xfd,0x43,0x3f,0x03,0xf3,0x17,0x79,0x94,0x2f,0x0c,0x1f,0xc8,0xcf,0x38,0x9f, - 0x0a,0x20,0x56,0x51,0xb5,0xf1,0x08,0xff,0xb9,0x2f,0x08,0xff,0x8c,0xcf,0x09,0x5f, - 0x0a,0xcb,0x0b,0x40,0x09,0xdf,0xab,0xcd,0x09,0x8c,0x16,0xaf,0x9b,0xf0,0x46,0x93, - 0xa4,0xf7,0xcd,0x3f,0xad,0xaf,0x06,0xae,0x9c,0x8a,0x98,0x01,0x20,0x8f,0x0e,0x10, - 0x19,0x83,0x9b,0x6f,0x02,0x3f,0x98,0x61,0x2b,0xd1,0x00,0x2f,0xa8,0x91,0xb3,0x5a, - 0x02,0xcf,0x98,0xc1,0x11,0x4f,0x03,0x2f,0x25,0x59,0x9f,0x9f,0x00,0x2f,0x06,0x7f, - 0x5b,0x9a,0x1c,0xf9,0x19,0x09,0x19,0x09,0xe6,0xaf,0x24,0xcd,0x10,0x09,0x10,0x91, - 0x58,0x9d,0x0e,0x49,0x19,0x8b,0x2d,0x77,0x1d,0x79,0x1b,0x61,0x06,0x4d,0x47,0x6f, - 0x12,0xad,0x2a,0x80,0x19,0x2f,0x18,0xff,0x0f,0x70,0x29,0xa8,0x16,0x23,0x1a,0xe3, - 0x11,0x23,0x25,0x33,0xff,0xa0,0x06,0x4b,0x00,0x2f,0x3e,0x5a,0x0f,0xd4,0x2b,0x6b, - 0x46,0x1d,0x18,0xfd,0x2b,0x0b,0x1b,0x6b,0x36,0x2d,0x6b,0x6b,0x6d,0x3d,0x1b,0xb4, - 0x1e,0xa9,0x9f,0x97,0x1e,0xc5,0x03,0x3f,0x1c,0x28,0x73,0x9d,0x16,0xef,0x17,0xaf, - 0xfb,0x09,0x5b,0x0f,0x1a,0x4f,0x1c,0x37,0x70,0x01,0x1c,0x3e,0x10,0x53,0x1e,0x14, - 0x1e,0x21,0x31,0xc3,0xfe,0xaf,0x50,0x01,0x13,0xfd,0x20,0x0b,0x10,0x01,0x10,0x8f, - 0x07,0x3f,0x30,0x01,0x13,0x0f,0x0e,0x9f,0xc0,0x01,0x12,0x13,0x1b,0x45,0x13,0x3d, - 0xfd,0xaf,0x60,0x2f,0x14,0x2b,0x2b,0xf2,0x6f,0xff,0x04,0xbb,0x7c,0x29,0x23,0xfd, - 0x85,0x0e,0x1c,0x36,0x0b,0xff,0x80,0x8d,0x33,0x2f,0x2f,0xff,0x02,0xcf,0x49,0x4d, - 0x19,0x53,0x21,0x1f,0x19,0x59,0x30,0xb7,0x13,0xf7,0x28,0x31,0x03,0xff,0x70,0x2f, - 0x50,0x37,0x0f,0xef,0x1f,0x0d,0x48,0xff,0x38,0x6f,0x1c,0x6f,0x08,0x6f,0x19,0xef, - 0x16,0x3a,0x69,0x2f,0x08,0x9f,0x1f,0x10,0x5d,0x5c,0x68,0x8f,0x0b,0x2d,0x53,0xcb, - 0x7b,0x6f,0x1d,0x8b,0x00,0x5f,0x1a,0x1f,0x8b,0x9f,0x24,0x2d,0x16,0x4f,0x03,0xcf, - 0x44,0x2f,0x0a,0xdd,0x1e,0x71,0x9f,0xff,0x1c,0xc0,0x0c,0xef,0xbf,0xf3,0xd0,0x0f, - 0xfd,0xb1,0x50,0x4e,0x00,0xe7,0x9a,0x4e,0x27,0x39,0x2e,0xe0,0xac,0xad,0x0f,0xbb, - 0x1a,0x3b,0x10,0xc7,0x3c,0xdf,0x1c,0xf0,0x6c,0xe9,0x9f,0xf9,0x26,0x41,0x5e,0x0f, - 0x15,0xaf,0x1d,0x3e,0x0e,0x20,0x83,0xfd,0x4b,0x0f,0x1e,0xdd,0x0f,0x3f,0x12,0x6d, - 0x12,0x9d,0x74,0xf3,0x0b,0x0f,0x3f,0xb6,0x23,0xcd,0x3b,0x5f,0x10,0x5d,0x04,0x2f, - 0x30,0x2f,0xab,0x9f,0x03,0xff,0x0e,0xff,0x10,0xc1,0x1e,0x3d,0x51,0x7f,0x02,0xcf, - 0x83,0xcf,0x4c,0xef,0x63,0xff,0x64,0x37,0x00,0x2f,0x0f,0xe0,0x19,0xbd,0x99,0xbf, - 0x26,0x75,0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xcf,0x1e,0x24,0x5b,0xaf, - 0x0f,0x6f,0x1f,0x9b,0x52,0x2f,0x2b,0xa2,0x1e,0x13,0x0a,0xaf,0x2f,0x65,0x3a,0xaf, - 0x7b,0xa0,0x13,0xff,0x02,0x7f,0x2c,0xad,0x90,0x2f,0x2f,0x4f,0x19,0xed,0x00,0x8f, - 0x10,0x2d,0x1a,0xa3,0x3f,0x68,0x1e,0x2c,0x13,0xf9,0x0a,0x4f,0x53,0xf7,0x09,0x1b, - 0x10,0x09,0x1c,0xd3,0x1f,0xcf,0x08,0x3c,0x8f,0x9f,0x4d,0x1f,0x70,0x01,0x03,0x9f, - 0x7d,0x1f,0x0e,0xb0,0x43,0xfb,0x0e,0xde,0x13,0xf9,0x8d,0x7f,0x3e,0xdd,0x25,0xaf, - 0x03,0xff,0x00,0x8f,0x43,0xf5,0x23,0xfb,0x4e,0x6f,0x23,0xf3,0x40,0x03,0x0e,0x0f, - 0x6e,0xad,0x02,0x6f,0xe2,0x3f,0x25,0x87,0x02,0x6f,0x16,0xff,0x64,0x4d,0x02,0x9b, - 0x5e,0x0f,0x92,0x9b,0x22,0x6b,0x56,0x6b,0x06,0x6d,0x00,0xaf,0xff,0xde,0x26,0xc5, - 0x12,0x45,0x3f,0x5f,0x26,0x09,0x1f,0x95,0x0a,0x78,0x09,0x8f,0x0d,0x82,0x0c,0x4f, - 0x30,0x01,0x0e,0x51,0x0e,0x21,0x15,0x1a,0x8f,0xf4,0xaf,0xff,0x2e,0xe9,0x0e,0xa2, - 0x1f,0x69,0x7c,0xcc,0x15,0xe3,0x0c,0x6f,0x30,0x01,0x00,0x2f,0x18,0xc5,0x6f,0xff, - 0x3b,0x67,0x01,0xb2,0x20,0x07,0x20,0x0b,0x0f,0xff,0x86,0x83,0x4e,0x7f,0x90,0x01, - 0x0a,0x23,0x17,0x43,0x65,0x63,0x2b,0xad,0x00,0x9f,0x34,0xd3,0x2c,0x10,0x1a,0x5b, - 0x75,0xef,0x37,0x43,0x17,0xa1,0x49,0xe0,0x1b,0x0d,0x1c,0x65,0x20,0x27,0x0f,0xff, - 0x48,0x03,0x4b,0x53,0x1c,0x63,0x30,0x31,0x0c,0xf3,0x12,0x49,0x30,0x58,0x35,0x63, - 0x10,0x2d,0x0a,0xe1,0x19,0x8f,0x10,0x09,0x0f,0xff,0xd0,0x01,0x0f,0xff,0x10,0xa6, - 0x20,0x01,0x2b,0xf2,0x03,0x50,0x72,0x1d,0x4f,0xff,0x1a,0x2f,0x00,0xfd,0x0c,0x00, - 0x22,0x47,0x1f,0xd9,0x05,0x02,0x0f,0xff,0x21,0xa7,0x10,0x01,0x32,0x2b,0x0f,0xff, - 0x53,0xfb,0x14,0x01,0x1e,0x9b,0x0f,0xff,0x80,0x2f,0x1e,0xcb,0x0f,0xff,0xdf,0xff, - 0x05,0xb2,0x33,0xf7,0x1a,0xdf,0x99,0xb0,0x08,0xd1,0x2f,0x63,0x3e,0x29,0x33,0xfb, - 0x1f,0x0f,0x0a,0x7f,0x10,0x1e,0x23,0x97,0x4b,0x3f,0x63,0x67,0x07,0x18,0x10,0x8f, - 0x40,0x5f,0x0f,0xd2,0x1d,0x5d,0x4c,0x4f,0x5a,0x7d,0x0e,0xeb,0x1b,0xc9,0x1c,0x92, - 0x16,0x8e,0xc4,0x49,0x06,0xd2,0x21,0xc3,0x8f,0xeb,0x1c,0xc3,0x07,0x02,0x0f,0xfd, - 0x03,0xfd,0x23,0xfb,0x14,0xaa,0x09,0xad,0x25,0x73,0x87,0x67,0x1c,0x01,0x4f,0xff, - 0x05,0x2b,0x00,0x60,0x20,0x01,0x09,0x1d,0x10,0x8d,0x2c,0x8f,0x00,0x7b,0x20,0x01, - 0xac,0x51,0x0d,0xbe,0x7e,0x90,0x7f,0xfb,0x36,0x21,0x4f,0xff,0x90,0x01,0x04,0x2f, - 0x10,0x2f,0x04,0x2f,0x0b,0xaf,0xa4,0x4e,0x0a,0xbf,0x13,0x79,0x2f,0xff,0x1f,0xa1, - 0x27,0x6f,0x09,0x8d,0x16,0x2b,0x98,0xff,0x0b,0x1a,0x8f,0xf4,0x8f,0xff,0x1f,0xe3, - 0x0a,0x18,0x10,0xbf,0xc0,0xbf,0x0a,0x1f,0x11,0x1e,0x0a,0x9f,0x4f,0x49,0x07,0x16, - 0x6f,0xff,0x49,0x19,0x03,0x17,0xab,0xbd,0x07,0xcb,0x0b,0xf8,0x7c,0x98,0x07,0x77, - 0x29,0xb5,0x69,0xaf,0x02,0xd0,0x8f,0xf8,0x1a,0x57,0x0b,0x6f,0x2f,0xa5,0x10,0x31, - 0x0f,0x5f,0x20,0x01,0x1d,0x2b,0x3a,0xdd,0x8f,0xff,0x17,0xe5,0x2b,0x3f,0x15,0xe4, - 0x18,0x38,0x42,0x54,0x18,0x05,0x0e,0xef,0x1b,0xf1,0x0f,0xff,0x10,0x29,0x18,0xd5, - 0x11,0x2f,0x18,0xdd,0x1c,0x3d,0x10,0x01,0x10,0x09,0x6f,0xff,0x0e,0x4b,0x33,0xf3, - 0x14,0xc2,0x1a,0xb9,0x0b,0xcf,0x0f,0x5f,0x0e,0x95,0x11,0x03,0x0f,0xf4,0x26,0xdd, - 0xc3,0xc5,0x0f,0x04,0x87,0x07,0x6f,0xb3,0x0f,0x32,0x60,0x01,0x0f,0xe0,0x51,0x89, - 0x5f,0xff,0x15,0xdd,0x95,0xdd,0x19,0xc5,0xaa,0xf7,0xc0,0x2f,0xc0,0x2f,0x06,0x0e, - 0x43,0xf5,0x6f,0xff,0x09,0x7f,0x3b,0x29,0x13,0x07,0x3e,0x63,0x1f,0x69,0x1d,0x5d, - 0x0e,0x0f,0x1e,0x5e,0x13,0xfe,0x1d,0x29,0xaf,0xff,0x0a,0x75,0x1f,0xc9,0x13,0x8b, - 0x1f,0xff,0xa5,0x8d,0x0d,0x5b,0x5e,0x1b,0x48,0xcf,0x68,0xcf,0x14,0x1f,0x17,0xfd, - 0x2f,0xcb,0x1e,0xe9,0x0b,0x9e,0x30,0xff,0x1c,0xa8,0x19,0x38,0x0c,0x63,0x25,0x23, - 0x17,0x9d,0x2b,0xa5,0x30,0x5f,0x16,0xe5,0x9b,0x7f,0x2f,0x81,0x0e,0x57,0x2b,0xcf, - 0xcb,0xcf,0x1e,0xb1,0x0b,0x4d,0x00,0x82,0x01,0x35,0x4f,0x2f,0x1f,0x13,0x1b,0xf1, - 0x0f,0x31,0x1c,0x27,0x0f,0x9c,0x5f,0x5f,0x83,0x60,0x06,0xa9,0x13,0x6b,0x8f,0xf6, - 0x14,0xb6,0x0f,0x19,0x4f,0x02,0xba,0x8b,0x11,0x10,0x0e,0x91,0x0e,0xe0,0xac,0xce, - 0x0d,0xc6,0x75,0x4f,0x01,0x21,0xcf,0xf3,0x19,0x2a,0x0a,0x53,0xa0,0x4f,0x0f,0xe2, - 0x19,0x77,0xe0,0x5f,0x07,0x40,0x1d,0x1d,0x79,0x4f,0x32,0x89,0x0f,0xa4,0x20,0x01, - 0x6f,0xff,0x30,0x01,0x0f,0x93,0x1f,0xd7,0x59,0x64,0x9f,0xc6,0x1d,0xf1,0x4e,0x0f, - 0x19,0xac,0x0f,0xe6,0x1a,0x68,0x82,0x7d,0x1a,0x79,0x0c,0x5f,0x00,0xef,0xaf,0xff, - 0x80,0xef,0x7a,0x45,0x7f,0xf1,0xc8,0xbb,0x10,0x0f,0xb8,0x8b,0x67,0xfb,0x27,0xbd, - 0x0a,0x71,0xc0,0x81,0x0a,0xf3,0x0f,0xff,0x18,0xd1,0x29,0x8d,0x1f,0xa1,0x4b,0x05, - 0x2f,0x5b,0x0b,0x11,0x12,0xd3,0x44,0xf6,0x18,0x01,0x15,0x07,0x2b,0x45,0x03,0xf1, - 0x1f,0xff,0x3b,0xff,0x02,0xcf,0xb3,0xc5,0x2c,0x85,0x1c,0xc3,0x0c,0x6e,0x19,0x8f, - 0x3d,0xf3,0x1c,0xdd,0x0f,0xfc,0x5a,0x27,0x30,0x01,0x0d,0xcf,0x41,0x1b,0x16,0x23, - 0x0c,0xb3,0x43,0xf5,0x46,0x19,0x03,0xff,0x19,0x1b,0x1c,0xbe,0x33,0xf9,0x21,0x97, - 0x10,0x8d,0x0c,0xc2,0x10,0x01,0x4d,0x76,0x13,0xa7,0x40,0x01,0xa9,0xd7,0x0a,0x9b, - 0x1d,0xc9,0x8a,0xc7,0x0d,0x81,0xeb,0xfb,0x1f,0x4e,0x20,0x01,0x0f,0xd3,0xec,0x4f, - 0x0c,0xf7,0x10,0xef,0x50,0x01,0xe0,0xef,0x04,0x56,0x09,0x1f,0x1e,0xa5,0x20,0x09, - 0x15,0x80,0x0e,0xf3,0x71,0x7b,0x0f,0x12,0xcb,0x0f,0x2d,0x7d,0x0b,0x5f,0x70,0x01, - 0x6f,0x87,0x40,0x99,0x0f,0x3d,0x43,0xf7,0x30,0x01,0x0f,0xe1,0x1c,0x8b,0x1c,0x5f, - 0x29,0x60,0x0d,0x89,0x5f,0xdc,0x16,0xd5,0xa2,0x1b,0x0f,0xfe,0x19,0x7c,0x7f,0xff, - 0x0f,0xff,0x25,0x49,0x10,0x01,0x31,0x1f,0x01,0x1f,0x70,0x01,0x0f,0xd5,0x14,0x7f, - 0x3d,0x81,0x1a,0x7f,0x1e,0x58,0x1a,0x83,0x0c,0xc0,0x17,0xf5,0x1e,0xab,0x3d,0xad, - 0x18,0x36,0x21,0x21,0x27,0xa5,0x17,0xf9,0x0e,0x79,0x15,0x71,0x19,0x39,0x18,0x03, - 0x1f,0x3d,0x18,0x04,0x1e,0xe9,0x78,0x9e,0x0f,0xc6,0x0d,0xa5,0x10,0xef,0xa0,0xef, - 0x21,0x88,0x00,0xef,0x0e,0xa0,0x1d,0x53,0x88,0x5f,0x29,0x80,0x13,0xff,0x0e,0x9d, - 0x1f,0xd5,0xb5,0x2f,0x0f,0x12,0x0f,0x30,0x9b,0x9f,0x1b,0xac,0x0f,0xa2,0x02,0xf6, - 0xaf,0xff,0x0d,0xb7,0xc0,0x2f,0x03,0x65,0xaa,0x10,0x24,0xdb,0x00,0x2f,0xa6,0xf0, - 0x00,0x9d,0xd7,0x20,0x0a,0xd5,0x1a,0x39,0x56,0x4d,0x3c,0x8d,0x1d,0x88,0x25,0x63, - 0x0e,0x6f,0x20,0x31,0x60,0x2f,0x1e,0x7e,0x4d,0xa8,0x0e,0x9f,0x18,0x19,0x25,0x10, - 0x40,0x5f,0x30,0x5d,0x19,0xab,0x0e,0xcf,0x1d,0x49,0x70,0xbf,0x0e,0xff,0x30,0x01, - 0x43,0xad,0x17,0x83,0x20,0x01,0x2d,0x1b,0x00,0xef,0x1c,0xed,0x1b,0x5f,0x11,0xdf, - 0x1e,0x74,0x19,0x3f,0x15,0xb1,0x0c,0x95,0xd8,0xd5,0xcf,0xf8,0xda,0x7e,0x5c,0x5f, - 0x51,0xc0,0x0a,0x0f,0x8d,0xd5,0x04,0xeb,0x1b,0x99,0x60,0x01,0x1b,0x2f,0x70,0x01, - 0x0e,0xa9,0x20,0x01,0x1b,0x9d,0x1e,0x56,0xb0,0x01,0x0f,0xff,0x20,0x01,0x08,0x84, - 0xab,0xcf,0x40,0x01,0x0f,0x98,0x8b,0x0f,0x6f,0x63,0x0b,0x0f,0x1f,0x48,0x13,0x00, - 0x67,0x1a,0x2b,0x65,0x1f,0x22,0xf1,0x4d,0x70,0x01,0x00,0x2f,0xcf,0xcf,0x1d,0xbf, - 0x1e,0xc3,0x19,0x2f,0x95,0x80,0x1e,0x1f,0x1d,0x3a,0x33,0xf3,0x1e,0x3b,0x2e,0xd5, - 0x62,0x45,0x0e,0xdd,0x23,0xfb,0x1e,0x3b,0x18,0xb7,0x1f,0x7a,0x00,0x2f,0x1e,0x5e, - 0x40,0x2f,0x60,0x2f,0x00,0x2f,0x00,0x2f,0x20,0x5f,0x50,0x5f,0x40,0x5f,0x00,0x8f, - 0x30,0xe9,0x14,0x8f,0x10,0x33,0x1e,0x6f,0x10,0x2b,0x1f,0x17,0x00,0x2f,0x40,0xf1, - 0x70,0x2f,0x40,0x2f,0x00,0x2f,0xd0,0x8f,0x1f,0x8d,0x1d,0xe3,0x10,0x00,0x1e,0xd1, - 0xcf,0x93,0x1e,0x61,0x3f,0x2f,0x1e,0x11,0xab,0x8a,0x00,0x00,0x44,0x01,0x1e,0x9d, - 0x1a,0xa7,0x1e,0xe9,0x0c,0x00,0x4f,0xfe,0x15,0xf1,0xa3,0xff,0x08,0x6f,0x1f,0xcb, - 0x00,0x85,0x08,0x67,0x10,0x8d,0x19,0x50,0x1b,0x0d,0xf1,0xe5,0xb2,0xdf,0x13,0x39, - 0x3f,0xeb,0x1b,0x17,0x7b,0x19,0xac,0xfd,0xd0,0x2f,0x1c,0x2e,0x11,0x01,0x3f,0xaf, - 0x6b,0xc9,0x62,0x2a,0x1d,0xe1,0x20,0x63,0x3d,0xdf,0x20,0x2b,0x4d,0xef,0x23,0xf3, - 0x10,0x01,0x5d,0x61,0x25,0xd7,0x66,0x7d,0x04,0xef,0x22,0xb1,0x27,0x3e,0x12,0xde, - 0x1c,0xc4,0x50,0x10,0x00,0x2f,0x10,0x61,0x70,0x2f,0x00,0x2f,0x00,0x2f,0x10,0x5f, - 0x80,0x5f,0x1d,0x54,0x00,0x8f,0x15,0x71,0x12,0x3f,0x4c,0xad,0x34,0x30,0xcc,0xbe, - 0x80,0x2f,0xc0,0x2f,0x00,0x2f,0x60,0x8f,0x53,0x23,0x43,0xfb,0x9f,0x9f,0x7f,0x6f, - 0x1e,0x07,0x1e,0x6f,0x1e,0x06,0x32,0x41,0x0d,0xa1,0x1e,0x4b,0x39,0x91,0x86,0x0b, - 0x2f,0x41,0x08,0x3f,0x19,0xbd,0x60,0x2f,0x59,0x8d,0x00,0x2f,0x10,0x2d,0x80,0x2f, - 0x19,0xf1,0x00,0x5f,0x20,0x01,0x70,0x2f,0x44,0xff,0x22,0x2d,0x00,0xbe,0x1a,0x6c, - 0x04,0x93,0x3f,0x2d,0x00,0x2f,0x10,0x5d,0x00,0x5f,0x20,0x01,0x00,0x8f,0x9f,0xf8, - 0xcf,0xff,0x0d,0xab,0x21,0xaf,0x4f,0x86,0x1c,0x00,0x07,0x3f,0x39,0x1c,0x5f,0xcd, - 0x5a,0x1f,0x1b,0x67,0x1a,0x1f,0x0a,0x15,0x1b,0xa1,0x1b,0xf1,0x22,0x1e,0x1a,0xa9, - 0x2e,0x87,0x11,0x67,0x0b,0xcf,0x1f,0x43,0x20,0x2f,0x1a,0xd7,0x17,0x0f,0x00,0x2f, - 0x4b,0x6f,0x1e,0xe8,0x30,0x5f,0x1e,0x6b,0x4b,0x6f,0x00,0x5f,0x8b,0x6f,0x1f,0xa5, - 0x27,0xe2,0x20,0x01,0x00,0x8f,0x9f,0xff,0xfe,0xa1,0x0f,0x06,0x40,0x8f,0x6f,0xea, - 0x04,0xc2,0x21,0x4f,0x4b,0x99,0x3f,0x20,0x1c,0x91,0x2f,0xbc,0x0f,0xd3,0x1b,0x99, - 0x40,0x2f,0x1f,0xd3,0x5d,0xd9,0x00,0x2f,0x20,0x2d,0x27,0xc7,0x20,0x5f,0x3c,0xef, - 0x1b,0x45,0x00,0x5f,0x20,0x01,0x23,0x20,0xec,0x9e,0x0f,0xff,0x50,0x01,0x9c,0x31, - 0x00,0x2f,0x67,0xa0,0x20,0x2f,0x00,0x2f,0x00,0x5f,0x00,0x2f,0xd0,0x01,0x0f,0xff, - 0x00,0x2f,0x13,0xf1,0x4e,0x4d,0x14,0x03,0x1f,0x17,0x11,0xd6,0x45,0x5d,0x2b,0x99, - 0x1f,0x1d,0x1b,0xff,0x60,0x01,0xfb,0x3f,0x26,0xdd,0x3d,0x75,0x26,0xe1,0x1d,0x7c, - 0x1a,0xf5,0xef,0x9c,0x17,0x71,0x17,0xd5,0x1d,0xb7,0x1a,0x4f,0x27,0x0d,0x62,0x24, - 0x00,0x2f,0x40,0x2f,0x12,0xab,0x00,0x2f,0x30,0x8f,0x38,0x65,0x1e,0x3f,0x1f,0xdb, - 0x00,0x8f,0x3d,0x6b,0x10,0xb3,0x15,0x49,0x2c,0x67,0x18,0xa1,0x1b,0x41,0x21,0x3f, - 0x00,0xbf,0x11,0x68,0xf0,0xef,0x20,0xe5,0xa0,0x03,0xc0,0x01,0x00,0x2f,0xd0,0x01, - 0x00,0x8f,0x00,0x3f,0x98,0x5f,0x0b,0x9e,0x00,0x2f,0x83,0xff,0x0f,0xfa,0x00,0x2f, - 0x56,0xdb,0x17,0xf9,0x4b,0x10,0x1f,0xf8,0x49,0xee,0x1f,0x65,0xa9,0xc9,0x6d,0x20, - 0x4b,0x3f,0x04,0xef,0x33,0x11,0x1a,0x25,0x45,0x76,0x0c,0x5e,0x1f,0x55,0x13,0x3f, - 0x24,0x85,0x55,0x60,0x00,0x2f,0xa0,0x2f,0x30,0x2f,0x00,0x2f,0x1c,0x29,0xf0,0x2f, - 0x20,0x2f,0x00,0x8f,0x20,0x8f,0x10,0x8f,0x07,0x6a,0x86,0xdf,0x14,0xef,0x0f,0x07, - 0x1c,0x97,0x1f,0x5a,0x60,0xbf,0x00,0xef,0x25,0x13,0x71,0x4f,0x23,0xff,0x01,0x4f, - 0x30,0x2f,0xc0,0x2f,0x00,0x5f,0xf0,0x2f,0x20,0x2f,0x00,0x2f,0x24,0xf1,0xa0,0x5f, - 0x50,0x2f,0x0f,0xfa,0x38,0x71,0x21,0x5c,0x08,0x9f,0x9f,0xff,0x0f,0x91,0xcf,0xf8, - 0x00,0xa3,0x1b,0xd6,0x1c,0xd9,0xb6,0x6f,0x2c,0x95,0x0b,0xd6,0xad,0x81,0x0f,0xdf, - 0x5c,0x95,0xc0,0x5d,0x0a,0x1a,0x9e,0x09,0x0f,0xff,0x20,0x01,0x8f,0xff,0x4d,0xc9, - 0x0f,0xd6,0x1f,0x93,0x6f,0xf6,0x17,0xf1,0x09,0xbe,0x00,0x1f,0x4e,0x15,0x01,0x7f, - 0x4e,0x15,0x9c,0x50,0x01,0x7f,0x6e,0x15,0x01,0x4f,0x7e,0x15,0x0d,0x80,0x2e,0x15, - 0x0d,0xaf,0x4e,0x15,0x0d,0xe0,0x4e,0x15,0x0e,0x10,0x1d,0xab,0x89,0x6f,0x1d,0xe1, - 0x02,0x9f,0x02,0x9f,0x0f,0x0b,0x15,0xef,0x2a,0x11,0x2c,0x62,0x15,0xc4,0x39,0x31, - 0x08,0x2f,0x18,0x2b,0x8a,0x0e,0x1e,0x45,0x14,0xe3,0x10,0x01,0xfe,0x1f,0x3b,0xa3, - 0x1e,0x82,0x1a,0x29,0x19,0xc2,0x19,0xcf,0x0e,0x4d,0x23,0xc3,0x2d,0x01,0x1d,0x61, - 0x0a,0xae,0x1f,0x0d,0xc0,0x2f,0xb0,0x2f,0x03,0x95,0x30,0x5f,0x50,0x5f,0x1e,0xdf, - 0x70,0x2d,0x00,0x5f,0xc0,0x8f,0x1f,0x35,0x4d,0x91,0x00,0x8f,0x1e,0x11,0x10,0xbf, - 0x10,0xbf,0x34,0xe5,0x2b,0x6e,0x00,0xbf,0x1f,0x91,0xa0,0x8f,0x40,0xef,0x20,0xed, - 0x00,0x2f,0x2e,0x20,0x3d,0x1e,0x7d,0x2e,0x1f,0xe5,0x20,0x01,0x4d,0xe5,0x2e,0x43, - 0x11,0x77,0x7f,0x17,0x0f,0xcd,0x50,0xbf,0x1f,0x7a,0x04,0xef,0x25,0x64,0x40,0x2f, - 0x10,0x2f,0x90,0x2f,0x00,0x2f,0x21,0x7f,0x20,0x2f,0x50,0x2f,0x61,0x7f,0x1e,0x55, - 0x00,0x2f,0x31,0x4f,0x20,0x2f,0x10,0x8f,0x51,0x4f,0x00,0x2f,0x20,0x8f,0x5e,0xa1, - 0x2e,0xa9,0x0e,0xff,0x27,0x25,0x0e,0x3f,0x00,0x2f,0x1f,0x95,0x00,0x2f,0x1f,0xf7, - 0x16,0x9b,0x1c,0xb7,0x2c,0xc8,0x19,0x99,0xf6,0xd2,0x19,0xa5,0x3f,0x97,0x42,0x9f, - 0x4d,0xb2,0x0e,0x7f,0x70,0x01,0x2f,0xf9,0x70,0x01,0x0c,0x2f,0x1f,0xf5,0x4e,0x0a, - 0x30,0x2e,0x13,0xfb,0x0f,0x6f,0x23,0xfb,0x47,0x15,0x34,0x25,0x00,0x35,0x24,0x2b, - 0x3a,0xa0,0x43,0x37,0x0c,0xbf,0x30,0x2f,0x00,0x2f,0x2e,0xcc,0xf0,0x5f,0x00,0x2f, - 0x00,0x2f,0x21,0x87,0xc0,0xbf,0x00,0x2f,0x1c,0x01,0x3b,0xc0,0x7b,0xd0,0x9c,0x31, - 0x1a,0x79,0x1f,0xbf,0x21,0xaa,0x15,0xad,0x01,0xdb,0x3b,0x5e,0x17,0x09,0x6a,0xaf, - 0x14,0x23,0x35,0xad,0x00,0x2f,0x00,0x5f,0x2c,0xc1,0x00,0x2f,0x02,0x9f,0x83,0xf9, - 0x0e,0x0f,0x00,0x2f,0x4c,0x2f,0x6d,0xaf,0x14,0x07,0x00,0xef,0x00,0x9f,0xbe,0x89, - 0xaf,0xf4,0x0a,0x7f,0x1e,0xa7,0x09,0xef,0xab,0x9d,0x08,0xcf,0xcb,0x6f,0x17,0xbb, - 0x0b,0x6f,0x1c,0xf9,0x9c,0xaf,0x30,0x01,0x0c,0x90,0xcf,0xff,0x0b,0x6f,0x01,0x4f, - 0x01,0x4f,0x03,0xa7,0x1f,0xcd,0x11,0x4f,0xc1,0x4f,0x0a,0xbf,0x20,0x01,0x8f,0xf4, - 0x09,0x1f,0x01,0xdf,0x0c,0xa9,0x20,0x01,0x0b,0xcf,0x00,0x18,0x0e,0x19,0x29,0xef, - 0x19,0xef,0x1b,0xf5,0x89,0xef,0x0b,0x9f,0xc0,0x2f,0xb0,0x2f,0x0b,0xff,0x30,0x5f, - 0x50,0x5f,0x1a,0x73,0x00,0x2f,0xb0,0x2f,0x68,0xcf,0x20,0x8f,0x00,0x5f,0x2a,0x10, - 0x1f,0xc9,0x4a,0xe3,0x4b,0x6f,0x2d,0x3c,0x2c,0x91,0x09,0x60,0x43,0xf3,0x2f,0x95, - 0x4d,0x92,0xce,0xed,0x79,0x01,0x20,0x5f,0x2d,0x69,0x2a,0xdb,0x0f,0xff,0x1e,0x4b, -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0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff,0x0f,0xff, - 0x0f,0xff,0x0f,0xff,0x00,0x00,0x00,0x20,0x00,0xff,0x18,0x18,0x00,0x1c,0x18,0x00, - 0x02,0x00,0x00,0x15,0x00,0x0b,0x02,0x30,0x00,0x00,0x01,0x10,0x55,0xaa,0xff,0x0c, - 0x06,0x0b,0x12,0x10,0x16,0x13,0x06,0x0a,0x0a,0x0f,0x13,0x07,0x11,0x07,0x17,0x12, - 0x0a,0x11,0x11,0x13,0x12,0x12,0x11,0x11,0x11,0x07,0x07,0x11,0x13,0x11,0x0f,0x14, - 0x12,0x10,0x11,0x11,0x0e,0x0e,0x0b,0x10,0x0e,0x13,0x10,0x12,0x0f,0x12,0x11,0x10, - 0x10,0x10,0x11,0x16,0x11,0x11,0x0f,0x0a,0x17,0x09,0x0d,0x18,0x07,0x0f,0x0f,0x0e, - 0x0f,0x0f,0x0a,0x0f,0x0e,0x07,0x09,0x0e,0x07,0x13,0x0f,0x0a,0x0d,0x0b,0x0e,0x0f, - 0x13,0x0f,0x0e,0x0d,0x0a,0x05,0x0a,0x15,0x18,0x14,0x18,0x06,0x0f,0x0b,0x15,0x0e, - 0x0e,0x0d,0x17,0x18,0x0f,0x18,0x18,0x07,0x07,0x0b,0x0b,0x0f,0x12,0x0e,0x0b,0x13, - 0x18,0x0d,0x11,0x06,0x0f,0x0c,0x17,0x0b,0x0e,0x12,0x0a,0x17,0x18,0x0b,0x12,0x0a, - 0x0b,0x0a,0x0e,0x0e,0x08,0x08,0x07,0x0b,0x0e,0x14,0x14,0x15,0x10,0x12,0x13,0x13, - 0x14,0x10,0x0f,0x06,0x14,0x10,0x11,0x11,0x12,0x10,0x11,0x0f,0x13,0x0e,0x10,0x0e, - 0x0e,0x0e,0x0f,0x10,0x0e,0x00,0x27,0x29,0x00,0x3e,0x18,0x3e,0x0b,0x80,0x09,0x06, - 0x00,0x0b,0x00,0x0f,0x41,0x90,0x42,0xe0,0x42,0xd0,0x09,0x1b,0x02,0xff,0x0f,0xeb, - 0x90,0x00,0xfd,0x00,0xbf,0x09,0x06,0xf8,0x1f,0xfe,0x2e,0x0b,0x40,0x2e,0x6f,0x01, - 0xff,0x03,0xe0,0xf4,0x00,0xbc,0x09,0x3f,0x17,0x18,0x00,0x7d,0x00,0xf8,0x02,0xe0, - 0x16,0x09,0x00,0x0f,0x40,0x07,0xc0,0x18,0x0a,0x1d,0x01,0xa0,0xad,0x06,0x00,0x1f, - 0x80,0x7e,0x00,0xf8,0x1b,0x00,0xbf,0x03,0xfd,0xf9,0x00,0xff,0x80,0x6f,0x0a,0x29, - 0x00,0xbe,0x07,0xfe,0x19,0x2b,0x01,0xff,0x07,0xf9,0xe9,0x5f,0x0a,0x6b,0x02,0xff, - 0x0b,0xf5,0xd0,0x5b,0xf0,0x18,0x06,0x80,0x1f,0xd0,0x7f,0xd0,0x3e,0x3e,0x00,0x2e, - 0x0e,0x0e,0x03,0x0d,0x03,0x38,0x80,0x00,0x40,0x0c,0x0f,0x0b,0xff,0x0b,0xff,0x01, - 0x7d,0x00,0x3c,0x00,0x78,0x15,0xb9,0x2f,0xff,0x03,0xc0,0xff,0x5b,0x95,0x0f,0x40, - 0x0f,0x00,0x5e,0x54,0xff,0xf8,0x2f,0x4b,0x2e,0x0b,0x2f,0x4b,0x1f,0xeb,0x07,0xff, - 0x00,0x6f,0x0b,0x0b,0xc0,0xe4,0x00,0xff,0x40,0x6f,0xc0,0x07,0x3d,0x0b,0x2f,0x6f, - 0x0b,0xfe,0x01,0xa4,0x80,0x7c,0x81,0xf4,0x82,0xe0,0x4b,0x80,0x1f,0x00,0x7d,0x1f, - 0xb8,0x7e,0xe0,0xe0,0x7d,0x00,0x03,0xd0,0x03,0xd0,0x02,0xf1,0x00,0xfb,0x00,0xbf, - 0xdb,0x0f,0x42,0x7c,0x00,0x7c,0xe0,0xb4,0xd0,0xb4,0xf4,0x0f,0x00,0x0e,0x00,0x38, - 0x19,0x03,0xd0,0x07,0x80,0x0b,0x0f,0xf4,0x00,0xb8,0x3c,0x00,0x2d,0x3c,0x0f,0x1f, - 0x04,0x0f,0x2e,0x0f,0x3f,0xdf,0x06,0xff,0x00,0x7f,0x06,0xff,0x2f,0xdf,0x40,0x0b, - 0x80,0x7f,0xc0,0xf9,0x00,0xd0,0xbf,0xc0,0x01,0x1a,0xaa,0x2f,0xff,0x1a,0xaa,0x00, - 0x01,0xf4,0x00,0xfa,0xaa,0xff,0xff,0xfa,0xaa,0x40,0x10,0x0b,0x2a,0xaa,0x7f,0xff, - 0x6a,0xaa,0xaa,0xa8,0xff,0xfc,0xaa,0xa8,0x3f,0x02,0x00,0x07,0x00,0x1f,0x00,0x7e, - 0x01,0xf4,0x07,0xd0,0x2f,0x40,0xbd,0xe0,0x0b,0xe0,0x0f,0xc0,0x2f,0x40,0x2f,0x00, - 0x40,0x02,0xf8,0x00,0xfc,0x00,0xbd,0x00,0x7e,0x3e,0x7f,0xfe,0x3e,0x7e,0x10,0x7e, - 0x00,0x0d,0x0f,0xd0,0x1f,0x80,0x06,0x06,0x00,0x7f,0x01,0xfe,0x02,0xf4,0x02,0xf8, - 0x02,0xf4,0x07,0xf0,0x6f,0xe0,0xff,0x40,0xf4,0x01,0x0f,0x80,0x01,0x15,0xf4,0x01, - 0x5f,0xe0,0xff,0x80,0xff,0xe0,0x07,0x00,0x07,0x2e,0x00,0xb8,0x02,0xf0,0x0b,0xd0, - 0x1f,0xaa,0xfb,0xd0,0xe7,0xd0,0x87,0xd0,0x07,0xab,0xea,0x80,0x2f,0x29,0x15,0x43, - 0x2f,0xff,0x00,0xf0,0x01,0xe0,0x02,0xe0,0x02,0xd0,0x00,0xff,0xf8,0x3c,0x78,0x00, - 0xb4,0x00,0x50,0x04,0x2f,0xeb,0x0b,0xff,0x00,0xbf,0x06,0xe0,0x03,0xe0,0x1b,0xd0, - 0xff,0x80,0xf9,0x06,0x3d,0x00,0xb8,0x01,0xf0,0xc1,0xf0,0x41,0xf0,0x00,0xf0,0x00, - 0xbe,0x00,0x7f,0x00,0x2e,0xbc,0x00,0x1f,0x0f,0x80,0x0b,0xfa,0x02,0xff,0x00,0x1a, - 0xbe,0xf0,0x2f,0xe0,0x1f,0xf8,0xbf,0xff,0xf8,0x2f,0x40,0x40,0x27,0x0b,0x40,0x0b, - 0x80,0x03,0xf4,0x1d,0x11,0x3c,0xf4,0x02,0xf0,0x07,0xd0,0x0f,0x40,0x12,0x2e,0x0f, - 0x04,0x0f,0x1a,0x80,0x01,0x0c,0x01,0x07,0x80,0x07,0x80,0x03,0x40,0x0e,0x45,0x2f, - 0x80,0x05,0x15,0xbd,0x02,0xf4,0x0b,0x80,0x2e,0xd0,0x0d,0x1f,0x80,0x0f,0xd0,0x07, - 0xf4,0x02,0xfe,0x00,0xbd,0x01,0xfc,0x07,0xf4,0xbf,0xd0,0xff,0x40,0xa4,0x04,0x14, - 0x12,0x07,0xf4,0x2f,0xff,0x2f,0xff,0x05,0x55,0xff,0xf8,0xff,0xf8,0x55,0x54,0x05, - 0x00,0x2f,0x90,0x0b,0xfe,0xfc,0x02,0xf8,0xaf,0xf4,0xff,0x90,0x04,0xff,0xff,0xab, - 0xea,0xc0,0x17,0x06,0xaa,0xaa,0xa0,0xff,0xf0,0xaa,0xa0,0x09,0x1b,0x09,0xab,0xf8, - 0x0d,0xe4,0xd0,0x1b,0x0a,0x6f,0x07,0xff,0x1f,0xe5,0xe8,0x0e,0x60,0xb4,0x07,0x3b, - 0x2d,0x00,0x2f,0x19,0x01,0xaf,0x0b,0xff,0x2f,0xd5,0xfe,0x00,0xbf,0x0a,0x02,0xbe, - 0x90,0xaa,0xfd,0xa0,0x00,0x02,0xaa,0x1f,0xff,0x1f,0x90,0x0a,0x1a,0xfa,0x40,0xff, - 0xe0,0x5b,0x09,0x2a,0xaa,0x3f,0xff,0x3f,0x50,0x40,0x0c,0x3e,0x00,0xff,0x00,0x01, - 0x2f,0xa9,0xa9,0x00,0x38,0x0a,0x40,0xa4,0x01,0xf8,0x01,0xf8,0x19,0x14,0xc0,0x0f, - 0x80,0x0f,0x85,0x1f,0xbf,0x1f,0xfe,0x2f,0xd0,0x05,0xa4,0xaf,0xf0,0xbc,0x00,0x2e, - 0x2f,0x3e,0xbf,0x3f,0xe4,0x3f,0x50,0x40,0x00,0xfe,0x40,0xbd,0x09,0x03,0x0b,0x0b, - 0xe0,0xbd,0xf0,0xd0,0x02,0x40,0xd0,0x3f,0xaf,0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0x07,0x55,0x69,0x40,0xc0,0x07,0xea,0x2f,0x40,0x3f,0xab,0x7d,0x06,0x02,0xf0,0x03, - 0xf0,0x1b,0xfe,0x06,0xc0,0xf8,0x6f,0x74,0x01,0xfc,0xef,0x07,0x01,0x15,0x03,0xf0, - 0x0b,0xe0,0x7f,0xe4,0x0b,0x40,0xff,0x40,0x55,0x0c,0x15,0x2f,0x40,0xf4,0x7f,0xbc, - 0x00,0xbc,0x01,0x09,0x0e,0x29,0x0a,0x0c,0x2f,0x06,0x90,0x18,0x0e,0x2a,0x40,0x3f, - 0xc0,0x3f,0x2a,0xbf,0x08,0x0a,0x1f,0x01,0xa0,0x02,0xf0,0x02,0xf0,0x18,0x12,0x90, - 0xff,0x0d,0x03,0x80,0x5b,0xe0,0x18,0x40,0xbf,0xc0,0x0a,0xe4,0x7f,0x80,0x0d,0xaf, - 0x90,0xff,0xe0,0xea,0x09,0x29,0x00,0x90,0x03,0xe0,0x03,0x09,0x40,0x68,0xf8,0x0c, - 0x69,0xbf,0x7d,0x0a,0x40,0x0b,0xd0,0x03,0xa4,0x09,0x1a,0xa4,0x02,0xf4,0x0b,0x40, - 0x07,0x05,0x54,0x1f,0xfe,0x1f,0xa9,0x1e,0x17,0x18,0x00,0x2e,0x00,0x0b,0x80,0x02, - 0x17,0x15,0x54,0x2f,0xfc,0x1a,0xbc,0x00,0x3c,0x15,0x69,0xff,0x0b,0xeb,0x2f,0x82, - 0xe0,0x00,0x11,0x0f,0x02,0x2f,0x0b,0x2f,0x2f,0x2f,0xbe,0x2f,0xfe,0x8b,0x2f,0x80, - 0xf4,0x09,0x2f,0x13,0x3f,0xe0,0x3e,0xf0,0x3e,0xf4,0x3e,0xb8,0x3e,0x7c,0x3e,0x3e, - 0x3e,0x2f,0x3e,0x1f,0x00,0xff,0x01,0xff,0x02,0xfb,0x03,0xeb,0x07,0xcb,0x0b,0x8b, - 0x0f,0x4b,0x5f,0x0b,0x1f,0xf8,0x1f,0xbd,0x1f,0xbe,0x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xfb,0x01,0xbe,0x00,0x81,0xfb,0x40,0xff,0x7f,0xbd,0x01,0xf8,0xf0,0x03,0xe0, - 0x04,0x2f,0x80,0x80,0xff,0x80,0x55,0x40,0x0a,0x1f,0xa9,0x1f,0xfe,0x05,0x54,0x21, - 0x7d,0x07,0xf8,0x1f,0x1a,0xbc,0x2f,0xfc,0x15,0x22,0x55,0x01,0x00,0x0b,0x40,0x1c, - 0x00,0x1c,0x40,0x48,0x19,0x58,0x0a,0x1f,0x0a,0x1e,0xad,0x02,0xfe,0x07,0xe4,0x48, - 0x3f,0x64,0x00,0xb8,0x19,0x18,0x2f,0x40,0x88,0xff,0x80,0x2f,0x80,0x1a,0x1c,0x55, - 0x0b,0xff,0x2f,0xeb,0x1d,0x00,0x04,0x01,0x00,0x6f,0x0b,0x01,0x05,0xfb,0x40,0xfc, - 0x2f,0x06,0x15,0x01,0xff,0x0b,0xfa,0x1f,0x90,0x2f,0x40,0xfd,0x00,0x1c,0x09,0x0f, - 0xd0,0xef,0x02,0x00,0xbf,0x02,0xfa,0x5a,0x1f,0xff,0xfe,0x80,0xbf,0x80,0xfe,0x3f, - 0xfd,0x3f,0xfd,0x12,0x00,0xeb,0x40,0xff,0x0f,0x00,0x15,0x3e,0xff,0x3f,0xfb,0x3f, - 0x40,0x3e,0xbd,0x00,0x11,0xb8,0x0d,0x42,0x6f,0x1f,0xfd,0x1f,0xbd,0xd0,0x05,0x12, - 0x2e,0xff,0x2f,0xef,0x2f,0x42,0x2e,0x02,0x50,0xdb,0xfe,0xff,0xbf,0xf8,0x1f,0x0b, - 0x05,0x1f,0x7f,0x1f,0xfa,0x1f,0xd0,0x7f,0x08,0x15,0x02,0x80,0x00,0xfd,0x1f,0x40, - 0x06,0xfa,0xfd,0x04,0x07,0xeb,0x0c,0x04,0x2e,0x80,0x14,0x07,0xff,0x0f,0xeb,0x74, - 0x18,0x15,0x1a,0xaa,0x55,0xff,0xff,0xaa,0x50,0xff,0xf8,0xaa,0xa4,0x21,0x90,0x01, - 0x3f,0xaf,0x1f,0xff,0x01,0xbc,0xfc,0x00,0xfe,0x40,0x6f,0x02,0xfa,0x2e,0xbf,0x14, - 0x05,0x06,0x1c,0xf8,0x06,0x2f,0xeb,0x80,0x04,0x1f,0xa5,0xd0,0x03,0xfa,0x40,0x40, - 0xf9,0x06,0x07,0xd0,0x01,0x13,0x0b,0xe5,0x07,0xff,0x00,0x6a,0x00,0x00,0x09,0x00, - 0x0b,0xff,0x00,0xbf,0x40,0xef,0x40,0x4f,0x7f,0x02,0x7d,0x14,0x0a,0x0f,0xf8,0x05, - 0xf8,0x3f,0xf4,0x2f,0x90,0x10,0x1f,0xef,0x42,0x80,0x15,0x0d,0x14,0x14,0x2f,0x00, - 0x04,0x7f,0x09,0xfa,0x2f,0xbf,0x2f,0x05,0x0a,0xfa,0x01,0xef,0x02,0x0e,0x16,0x08, - 0xeb,0xbd,0x22,0x01,0xa0,0x02,0xf0,0xff,0x26,0x68,0x02,0xfd,0x03,0xd4,0x03,0x17, - 0x28,0x00,0x38,0x16,0x09,0x40,0x1f,0xe0,0x05,0xf0,0x00,0xb0,0x7b,0x2b,0xe9,0xff, - 0xff,0xf9,0x6f,0x5b,0x03,0xc0,0xd0,0x68,0x28,0x00,0x3d,0x44,0x69,0x01,0xff,0xeb, - 0x1f,0x82,0x40,0x00,0xc0,0x0f,0xf0,0x02,0xf0,0x1f,0xff,0x1f,0xff,0x12,0x7e,0x04, - 0x0f,0xc0,0xe0,0x02,0xf0,0x01,0xf4,0x7c,0x05,0x3e,0x01,0x2f,0x02,0x1f,0x43,0x0f, - 0x83,0x0b,0xc7,0x07,0xcb,0x07,0xfc,0x0b,0xfd,0x0f,0xfe,0x0f,0xee,0x1f,0x9f,0xc0, - 0xc0,0x07,0xe0,0x01,0xf9,0x3f,0x2f,0xf8,0x02,0x7d,0xd1,0x03,0xe2,0x02,0xf7,0xb8, - 0xf0,0x03,0xff,0x2f,0xff,0x0b,0xf8,0x04,0x03,0xc0,0x02,0xc0,0x02,0xd0,0x02,0xd0, - 0x0b,0xc0,0x0e,0x38,0x0f,0x01,0xf8,0x01,0x16,0x6a,0x07,0xff,0x1f,0xea,0x2d,0x00, - 0x04,0xe4,0x00,0xff,0x96,0x2f,0xff,0x01,0xa9,0x10,0xf4,0x05,0x0e,0x00,0x2f,0x0a, - 0xbf,0x1f,0xff,0x05,0xbe,0x00,0xbd,0xd0,0x02,0x40,0x00,0xaa,0x80,0xff,0xd0,0x55, - 0xff,0xd0,0xff,0xd0,0xe0,0x00,0x17,0x34,0x0a,0xaf,0x0f,0xff,0x0a,0xaf,0x00,0x0f, - 0xc0,0x80,0x00,0xea,0x40,0xff,0x80,0xaa,0x40,0x80,0x5f,0x15,0x7d,0x3f,0xff,0x3f, - 0xff,0x54,0xfd,0x09,0x2a,0xbe,0x3f,0xff,0x2a,0xbe,0xa9,0xa8,0x09,0x1e,0xb4,0x1e, - 0x01,0xfe,0x40,0x07,0x3f,0x41,0x2f,0xeb,0x0b,0xff,0xbe,0xbe,0x05,0x00,0xf9,0x1f, - 0x06,0x03,0xdf,0x02,0xff,0x02,0xfe,0xfd,0x4f,0x7d,0x0b,0xbc,0x07,0xf8,0x07,0xf4, - 0x03,0xf4,0x01,0x50,0x03,0x7f,0x00,0xfa,0x02,0xf4,0x0b,0xe0,0x2f,0x80,0x05,0x03, - 0x01,0xfb,0x7f,0xbd,0x2f,0xf8,0x1f,0x01,0xf8,0x07,0xe0,0x1f,0x80,0x15,0x55,0xfc, - 0x54,0x04,0xd0,0x02,0xc0,0x03,0xc0,0x03,0x80,0x03,0xd0,0x02,0xfd,0x00,0x68,0x10, - 0x1d,0x00,0xb0,0x01,0xf0,0x1f,0xe0,0x0a,0x40,0x71,0x0f,0x01,0xe4,0x07,0xff,0xbf, - 0xbf,0xff,0x06,0x94,0xd0,0x07,0x16,0x0b,0x00,0x0e,0x14,0x0f,0x1f,0x04,0x1f,0x1f, - 0xbe,0x0b,0xfd,0x00,0x60,0x40,0x0d,0x3e,0x0f,0x0e,0x03,0x0d,0x03,0x34,0x0e,0x08, - 0x06,0x00,0x1f,0xc0,0x1f,0xc0,0x06,0x18,0x00,0x7e,0x01,0x7f,0x01,0x19,0x60,0x64, - 0x3d,0x28,0x1d,0x0e,0x38,0x06,0xe4,0x0b,0xbc,0x1d,0x90,0x02,0xd0,0x07,0x03,0x01, - 0x00,0x07,0xe0,0x02,0xfa,0x1a,0x00,0xaf,0x04,0x40,0x00,0xa4,0x0a,0x0b,0x0f,0x6f, - 0x01,0xff,0x03,0xf5,0x96,0xaa,0xff,0xff,0xff,0xaa,0xa4,0xa4,0x25,0x07,0xd0,0xbf, - 0x00,0x1a,0x1a,0xaa,0xaa,0x67,0x40,0x1c,0x00,0x2c,0x19,0x17,0x01,0x1c,0x07,0x3c, - 0x0f,0x39,0x0e,0x40,0x0f,0x80,0x5e,0x26,0x90,0x0f,0xf8,0x2f,0xbf,0x38,0x1b,0x20, - 0x02,0x40,0x4b,0x80,0xff,0x09,0x1a,0xa9,0x2f,0xfe,0xa0,0x19,0xf8,0x2e,0xfc,0x7e, - 0xfe,0xfe,0xef,0xea,0x0b,0x80,0x07,0xf6,0x14,0x08,0x0f,0x7e,0x1d,0x1e,0x0b,0xbd, - 0x06,0xf6,0x1e,0x00,0x2d,0x0f,0x00,0x2d,0x00,0x78,0x85,0x00,0x7f,0x81,0xb6,0xd3, - 0x64,0xdb,0x40,0x07,0xff,0x0f,0x90,0x2f,0x00,0x6f,0x00,0x6f,0x40,0xa0,0xbf,0x00, - 0xb8,0x01,0xf4,0x02,0xe0,0x07,0xc0,0x0f,0x0f,0x40,0x0b,0xc0,0x0e,0x0b,0x1f,0x2e, - 0x1e,0x3f,0x40,0x40,0x0b,0x40,0x0b,0xff,0xe0,0x25,0x2f,0xff,0x3f,0x00,0xbd,0xff, - 0x80,0xbf,0x80,0xbe,0x09,0x4e,0x2f,0x80,0x2f,0x80,0x1a,0x19,0x00,0x39,0x19,0x29, - 0x0a,0x0a,0x10,0x15,0x54,0x2f,0xfd,0x16,0x1a,0xaa,0xaa,0xaa,0xa8,0x05,0x55,0x55, - 0x55,0x55,0x54,0xff,0xf8,0xaa,0x21,0x01,0x90,0xeb,0xda,0xe2,0x8a,0xe0,0x0a,0x90, - 0x0a,0x07,0xff,0xaa,0x80,0x0f,0x90,0x07,0xfe,0xe0,0x90,0x7c,0x90,0x00,0xd0,0x01, - 0xf0,0x7d,0x07,0x54,0xef,0x1f,0x43,0x2e,0x01,0x2d,0x50,0x4b,0xfd,0xdf,0xaf,0xfd, - 0x0b,0xf8,0x03,0xf9,0xaf,0xff,0xfe,0xc0,0x32,0xb4,0x01,0xe1,0x03,0xc0,0x0b,0x40, - 0x1e,0xe1,0xe7,0xd1,0xeb,0xe1,0xe7,0xf6,0xd3,0x7f,0xc2,0x87,0x80,0x47,0x80,0x87, - 0x80,0xdb,0x40,0xfe,0x2f,0x40,0x1f,0xfa,0x02,0xff,0xc0,0xc0,0xbf,0x40,0xfd,0x00, - 0x04,0x03,0xe0,0x3d,0x0b,0x00,0x0e,0x1f,0x7f,0x40,0xff,0xff,0xeb,0xff,0x45,0x54, - 0x23,0x02,0xf8,0x0b,0xaa,0x80,0x55,0x72,0x9f,0x1a,0xa8,0xdd,0xaf,0x00,0x01,0x0a, - 0x00,0x1f,0xea,0x06,0xff,0xf8,0x00,0xbd,0xfd,0x05,0xb8,0x01,0xf0,0x03,0xd0,0x0b, - 0x80,0x0f,0x40,0x2e,0x10,0x2d,0x00,0x2e,0x01,0x1f,0x43,0x0b,0xef,0x02,0xfa,0x50, - 0xf8,0x01,0xfd,0x07,0xdf,0xaf,0x4b,0xfe,0x80,0x43,0x04,0x0b,0xd7,0x10,0xf4,0x06, - 0xfc,0x1a,0xa4,0x3c,0x3e,0x2b,0x05,0x00,0x01,0x7f,0x00,0x00,0x00,0xa9,0x00,0xff, - 0x80,0x5b,0xd0,0x0c,0x2d,0x10,0x08,0x40,0x0f,0x80,0x0b,0x68,0x01,0xf8,0x03,0xf0, - 0x06,0x18,0x2d,0x0b,0xfa,0x07,0x40,0x2e,0x06,0x0b,0x15,0x05,0xd0,0x0b,0x06,0xb8, - 0x02,0x15,0x40,0xff,0xf9,0x95,0x6f,0x00,0x02,0x05,0x80,0xb8,0x50,0x0f,0xf8,0x09, - 0x01,0xfe,0x07,0x5e,0x17,0x08,0x00,0x2c,0xb0,0x0e,0x38,0x68,0x03,0x01,0xa4,0x1f, - 0xff,0x3d,0x0b,0x3c,0x03,0x3d,0x07,0x1f,0xbf,0xc0,0x0e,0x01,0x90,0x07,0x06,0xa4, - 0x1f,0xbd,0x3c,0x1e,0x14,0x1e,0x01,0xfd,0x1e,0x07,0xff,0x15,0x05,0x57,0x2f,0xf4, - 0x03,0x1f,0x03,0xf0,0x01,0x1f,0x00,0x0b,0x02,0xf4,0x03,0xe0,0x40,0x3e,0x30,0x2a, - 0x29,0x2e,0x07,0xbf,0x02,0xfe,0x0b,0xe0,0x0f,0x80,0x1f,0x40,0x1f,0x41,0x1f,0x42, - 0xad,0x40,0xbb,0xc0,0xf2,0xc0,0xe0,0x00,0x01,0xf4,0xf4,0x00,0xb8,0x05,0xbd,0x1f, - 0xff,0x0a,0xbe,0x00,0x2e,0x02,0xe0,0x01,0x55,0xa9,0x01,0x1f,0x46,0x07,0xef,0x01, - 0xf9,0x01,0xe0,0xf0,0x91,0xf4,0xff,0xd0,0x6f,0x40,0x0b,0x80,0x03,0x00,0x02,0x3f, - 0x05,0x6f,0x0f,0xff,0x0a,0xab,0x00,0x03,0x0b,0xd0,0x1f,0x80,0x2f,0xf9,0x50,0xff, - 0xf8,0xea,0xa4,0x00,0x14,0x11,0xf9,0x06,0xff,0x0f,0x96,0x1f,0x0f,0xd0,0x07,0xfe, - 0x04,0xff,0xbf,0x2f,0x07,0x80,0x0b,0x02,0x0e,0x0b,0x1d,0x0b,0x1d,0x0f,0x0b,0x0e, - 0x07,0xbf,0xf8,0xe5,0x7d,0x80,0x08,0x40,0x00,0xc0,0x09,0x2d,0x0b,0x00,0x07,0x40, - 0x0b,0x00,0x2d,0x0e,0x1d,0x3f,0x0b,0xe6,0x00,0x00,0x2a,0xaa,0x2a,0xaa,0x80,0x05, - 0x01,0xe0,0x03,0xc0,0x07,0x42,0x0e,0x07,0x2d,0x0f,0x38,0x1d,0x2c,0x0e,0x0e,0x07, - 0xb4,0x04,0x15,0x55,0x7f,0xff,0x6a,0xaf,0x05,0x40,0x05,0x07,0x81,0x02,0x1d,0x0e, - 0x02,0xaa,0x90,0xea,0xf4,0xc0,0x38,0xc0,0x38,0xea,0xf4,0xeb,0xd0,0xc1,0xe0,0xc0, - 0xf4,0x1f,0x1e,0x02,0x00,0x02,0x1a,0xab,0xab,0x00,0xe0,0x00,0xea,0xa8,0xff,0xfd, - 0xfa,0xa9,0xe0,0x03,0x0b,0x90,0x2e,0x00,0x3e,0x21,0xbd,0x02,0xf4,0x0b,0xd0,0x2f, - 0xea,0x05,0x07,0x01,0x34,0x3e,0x2a,0x11,0x0f,0xc3,0x0b,0xe7,0xbf,0x2c,0x81,0xc0, - 0x47,0xc0,0xaf,0x80,0xfe,0x01,0x3d,0xf9,0x0f,0xff,0x0b,0x24,0xfa,0xfc,0xff,0xf4, - 0x15,0x03,0xef,0x1f,0x46,0x1d,0x6f,0x40,0xfb,0xd0,0x91,0xf4,0x00,0x74,0x06,0x0a, - 0xab,0x0f,0x03,0xea,0xa4,0xff,0xf8,0xe5,0x50,0x08,0x2d,0x29,0x14,0x6f,0x00,0x01, - 0x01,0x07,0xe5,0x01,0xf9,0x2f,0xbe,0x90,0x31,0x0b,0x02,0x07,0x80,0xb8,0xf9,0xbd, - 0xbf,0xf4,0x02,0x95,0x6f,0xff,0xf9,0xb8,0x26,0x0b,0x42,0x03,0x81,0xf0,0x2c,0xe0, - 0x38,0x0e,0x00,0x0a,0x0a,0x3c,0x81,0xc0,0x78,0x80,0x37,0x20,0xaa,0xaa,0xaa,0xa9, - 0x4a,0x01,0xa9,0x0b,0xef,0x0a,0x07,0x00,0x5b,0x05,0x10,0x01,0xf8,0x0b,0xfd,0x2f, - 0xd0,0x09,0x4b,0x01,0xbf,0x0b,0xff,0x2f,0xfe,0x1e,0x65,0x01,0x40,0x1b,0x80,0x3f, - 0x80,0x12,0x80,0x02,0x15,0x01,0x50,0x0b,0xfd,0x1e,0x0b,0x2c,0x07,0x2c,0x07,0x40, - 0x09,0x04,0x08,0x2c,0x0e,0x1e,0x0b,0x0b,0x03,0x0c,0x02,0xe0,0x1f,0x14,0x39,0x50, - 0x0b,0xfe,0x1e,0x01,0x00,0x0b,0x40,0x1f,0x0d,0xc0,0x04,0x0b,0x01,0xf8,0x05,0x3f, - 0x00,0x19,0xf4,0x03,0x06,0xf4,0xa0,0x2f,0x01,0x04,0x14,0xff,0x07,0x41,0x02,0x40, - 0x20,0xe0,0xb4,0xff,0xf0,0x6f,0xd0,0x05,0x06,0x7e,0x15,0xc0,0xfc,0x06,0x2e,0x2e, - 0x90,0x0b,0x5f,0xfc,0x10,0x05,0x00,0x00,0xff,0x10,0x07,0x19,0x03,0x1f,0xaf,0x06, - 0xfa,0xc0,0x3d,0x05,0x00,0x14,0x00,0x7d,0xbd,0x00,0xfe,0x2f,0xfe,0x0b,0xfe,0x01, - 0x00,0x2e,0x06,0x1f,0xd0,0x05,0x34,0x80,0x16,0x2d,0x0b,0x0f,0xae,0x02,0xa4,0x06, - 0x03,0x81,0x02,0xd0,0x74,0x00,0x3c,0x2c,0x00,0x74,0x0e,0xe0,0x01,0x00,0x92,0x00, - 0x07,0x02,0xe0,0x07,0xd0,0x0b,0x40,0x2e,0x00,0x7c,0x00,0xf4,0x1a,0xe0,0x7e,0xc0, - 0xfa,0x19,0xbf,0xe2,0xe6,0xc2,0x80,0x0b,0x01,0xae,0x01,0xaf,0x00,0x07,0x2d,0x07, - 0x1f,0xaf,0x01,0x40,0x41,0xf0,0x83,0xd0,0x8b,0x80,0x6e,0x02,0x7d,0x0b,0xb4,0x90, - 0x0b,0x06,0x0f,0x00,0x6f,0x02,0xfe,0x03,0x2f,0x7d,0x00,0xfc,0x01,0xf4,0x02,0xfa, - 0xf8,0x7e,0x1f,0x40,0x0f,0xc0,0x0b,0xd0,0xab,0xe0,0x07,0xfc,0x80,0x03,0x0f,0x25, - 0xbc,0x03,0x3f,0xc0,0x01,0x07,0x1f,0x7d,0xfe,0xfd,0xaf,0x00,0x4f,0x07,0xab,0xf4, - 0x05,0x5f,0xe0,0x01,0xff,0xff,0xf9,0x55,0xf8,0xf8,0x07,0xfe,0x40,0x2f,0x80,0xaf, - 0xe0,0x02,0xa0,0x00,0x6d,0x1f,0xeb,0x1f,0xff,0x1f,0xa9,0x1a,0xfd,0x7d,0x0d,0x33, - 0x40,0x02,0x03,0xc0,0x1f,0x80,0x2e,0x0a,0x58,0xf0,0x81,0x0b,0x43,0x0e,0x07,0x2c, - 0x0e,0x14,0x78,0xd0,0x2e,0x00,0xb8,0xd0,0x06,0x42,0xda,0x0b,0x4a,0x1e,0xaf,0x1a, - 0xaf,0x90,0x40,0x02,0xb8,0xea,0x02,0xa0,0x02,0x7c,0x00,0x64,0x79,0xc1,0xe1,0x43, - 0x01,0xe8,0xd0,0x0b,0xe0,0x1f,0x80,0x0f,0xe0,0x07,0xff,0x02,0x90,0x07,0xd0,0x2f, - 0xc0,0xff,0x40,0xf8,0x02,0xff,0x0b,0xd5,0x0f,0xc0,0x00,0x00,0xff,0xf0,0xfc,0x3e, - 0x02,0x3f,0x56,0xf4,0x0a,0x07,0x23,0x2f,0x14,0xf8,0x7e,0x04,0x02,0xff,0x03,0xf5, - 0xff,0xf8,0x55,0xbc,0x2f,0x40,0xe5,0x07,0xd0,0x0f,0x7d,0x08,0x3e,0xfe,0xaa,0xff, - 0xff,0x55,0x90,0x07,0xf5,0x1b,0x07,0x2e,0x00,0x00,0x17,0xf0,0xff,0xd0,0xf9,0x17, - 0x10,0x00,0x7d,0x2f,0xff,0x03,0x01,0xbf,0x02,0xfd,0x01,0x90,0x80,0x05,0x2a,0xff, - 0x0b,0xe2,0x0b,0x40,0xe0,0x78,0x06,0x00,0x0b,0xd2,0x05,0x50,0x03,0xb9,0x00,0xff, - 0x80,0x2f,0xe0,0x01,0x3e,0x14,0x40,0xbf,0xc0,0xf9,0x12,0x6a,0xff,0xe0,0xd2,0xf8, - 0x40,0xb8,0x00,0x10,0x14,0xc2,0xf4,0x40,0x50,0x16,0x7f,0xff,0xe4,0x01,0x90,0x0b, - 0xfd,0x1f,0xbf,0x2d,0x0b,0x14,0x80,0x42,0xc0,0xff,0x80,0xfe,0x02,0x00,0x80,0xfd, - 0x00,0x28,0xfe,0x07,0x0a,0x6f,0xb8,0x54,0x07,0x7e,0x11,0xa4,0xff,0x40,0x5f,0x05, - 0x81,0x24,0x95,0x04,0x01,0xc0,0x05,0x40,0x05,0x60,0x0c,0x54,0x7e,0xff,0x02,0x3f, - 0x2f,0x80,0x00,0xe4,0x68,0xf0,0x05,0x2f,0x38,0x40,0xf4,0x03,0x06,0x01,0xf8,0x90, - 0x7e,0x06,0x02,0xf8,0x2f,0xf0,0x0e,0x2f,0xff,0x2f,0x00,0xff,0x2f,0xaa,0x2f,0xfd, - 0x00,0xa9,0x03,0x2e,0x29,0xfc,0x00,0xa8,0x12,0x00,0x0c,0x3e,0x0e,0x7e,0x7e,0x0a, - 0xbe,0x1f,0xff,0x0a,0xbe,0xff,0xfe,0x0b,0x02,0xa4,0xa4,0x02,0xf0,0xf0,0x00,0x2f, - 0xd0,0x2f,0xf0,0x2f,0xf8,0x2e,0xbd,0x2e,0x3f,0x2e,0x2f,0x2e,0x0f,0x2e,0x82,0xe0, - 0xd2,0xe0,0xe2,0x07,0xfe,0x0f,0xd0,0x7e,0x7e,0x00,0xbf,0xd0,0x0b,0xe0,0x02,0xbc, - 0xbd,0xff,0x03,0xf4,0x0b,0xd0,0x2f,0x3e,0x00,0x07,0x44,0xc0,0xaf,0xf4,0x02,0xfc, - 0x3f,0x00,0x40,0xd0,0x07,0xf4,0x01,0xfd,0xbe,0x01,0xf8,0x07,0x7e,0xbe,0x00,0x0b, - 0x42,0x1f,0x4b,0xaf,0xf4,0x07,0xf8,0x0f,0xfd,0x2f,0x7e,0x7d,0x2f,0xf8,0xd0,0x02, - 0xf0,0x5f,0x0e,0x05,0xaa,0x2f,0xff,0x15,0xaa,0x40,0xff,0x80,0x55,0x09,0x78,0x15, - 0x13,0x7e,0x7f,0x03,0x6f,0xab,0xfe,0xff,0xe4,0xe0,0x2e,0x02,0xf6,0xe0,0xfe,0xe0, - 0x7f,0xe0,0x2f,0xe0,0x0f,0xe0,0x05,0x50,0x04,0xfa,0x1a,0x02,0xf8,0x07,0xf0,0xaf, - 0xd0,0xfe,0x40,0xa4,0x04,0x06,0xbe,0x01,0xfc,0xaf,0xf4,0xff,0x90,0xa5,0x09,0x02, - 0xbd,0x80,0x04,0x02,0xf8,0x15,0x3f,0xab,0xa9,0x04,0xf8,0x0b,0xe0,0x2f,0x80,0x1d, - 0x80,0xf8,0x08,0x0f,0x9f,0x0b,0xfe,0x07,0xfd,0x02,0xfe,0xc6,0x0a,0x80,0x05,0x0f, - 0xd0,0x0b,0x07,0xe0,0x08,0xc0,0x0b,0xfa,0x02,0xc0,0xfe,0x40,0x94,0x05,0x2f,0x0b, - 0x00,0x05,0x80,0x03,0x90,0x18,0x00,0x34,0x11,0x1a,0x1d,0x01,0xaa,0x09,0x0a,0x00, - 0xbf,0x03,0xfd,0xd0,0x0a,0xf8,0x08,0x40,0x0b,0xf8,0x2f,0xfe,0x78,0x1f,0x40,0x07, - 0x80,0xff,0x09,0x0b,0xe1,0x05,0x19,0x01,0xff,0xc0,0x02,0xe5,0xd0,0xb4,0x00,0x0f, - 0x4a,0x16,0x80,0x3b,0x15,0x18,0xfd,0x17,0xe2,0xf8,0x18,0x17,0xb8,0x1f,0x06,0x00, - 0xaf,0x0a,0x1f,0x00,0x40,0xff,0x10,0x03,0x2f,0x00,0x0f,0x07,0xe0,0x0b,0xc0,0x1f, - 0x40,0xd0,0x02,0x2f,0x55,0xa4,0x6f,0x80,0x6f,0x0b,0xff,0x2f,0x95,0x01,0x3e,0x2f, - 0x3e,0x1a,0x3e,0x00,0xf9,0xf8,0x00,0xbe,0x01,0x00,0x02,0xbf,0x1f,0xff,0x2e,0x41, - 0x08,0x00,0x00,0x5b,0x07,0xff,0xf8,0xfc,0x00,0x00,0xfc,0x00,0x40,0x01,0x1e,0x78, - 0x90,0x00,0x20,0x02,0xfd,0x05,0x01,0x1f,0x40,0x1b,0x06,0xff,0x54,0xbc,0x03,0x05, - 0x05,0xff,0x1f,0xff,0x0e,0x02,0x04,0x02,0x00,0x02,0x06,0x5b,0xf8,0xff,0xfe,0xf8, - 0x1f,0xf0,0x0b,0xe5,0xab,0xff,0x40,0x00,0x05,0x01,0xbf,0x07,0xfa,0x1f,0x80,0x04, - 0x02,0x00,0x00,0xaf,0x07,0xff,0x0f,0x90,0x2f,0x00,0x2e,0x16,0x3f,0xff,0x90,0xbe, - 0xaf,0x00,0x00,0x01,0xbf,0x3e,0x00,0xbf,0x01,0x1f,0xbd,0x02,0x05,0x2e,0x00,0x3d, - 0x50,0x06,0x2a,0x0e,0x2a,0x19,0x40,0xb8,0x00,0x10,0x29,0x1a,0x1a,0x02,0xfe,0x00, - 0x00,0x6f,0x1f,0x40,0x2f,0x40,0xef,0x80,0xff,0xc0,0x2f,0xc0,0x20,0x19,0x6a,0x2e, - 0xff,0x2f,0xd5,0x2f,0x13,0x0b,0x05,0xc0,0x40,0x04,0xa4,0x10,0x05,0x29,0x08,0x1f, - 0xe4,0x2f,0xab,0x1f,0xff,0x01,0xfe,0x40,0xbf,0x40,0x06,0x04,0x3f,0x17,0x1f,0xe4, - 0x2e,0xaf,0x0a,0x01,0x1a,0xbc,0x00,0xfe,0x80,0xaf,0x80,0x34,0x0f,0xff,0x02,0x2f, - 0x5f,0x1f,0xff,0x06,0xfa,0x94,0xe0,0x01,0xf4,0x07,0xfe,0xaf,0x6f,0xfe,0x06,0x80, - 0x0b,0xe4,0x6f,0x00,0x0f,0xbd,0x6e,0x90,0x05,0xa9,0x2e,0x0b,0xea,0x50,0x1e,0x40, - 0x49,0xfe,0x09,0x00,0xf4,0x05,0x4e,0x14,0x43,0x07,0xf9,0x07,0xd0,0x0b,0xd0,0x1f, - 0xc0,0xbf,0x50,0x13,0x1e,0xbf,0x00,0x1b,0xd0,0x0a,0x01,0x7f,0x01,0x18,0x1a,0x00, - 0xbf,0x01,0xff,0x07,0xe5,0xf4,0x0c,0xf4,0x3f,0x0a,0x03,0x03,0xbd,0x0e,0xf4,0x3a, - 0x2e,0x00,0xf4,0x1b,0xe0,0x09,0x7f,0xf5,0x0a,0x07,0xe0,0x04,0x27,0x1f,0x0b,0xe0, - 0x16,0xff,0x36,0x6a,0xe5,0x2f,0x3e,0x00,0xa0,0x40,0x0f,0x80,0x0b,0x00,0xa0,0x00, - 0x0f,0x00,0x80,0x01,0x1f,0x7d,0x0a,0x20,0x07,0x00,0x1f,0x01,0x01,0x6a,0xe5,0xfd, - 0x80,0x00,0x05,0x55,0x2f,0xff,0x1a,0xaa,0x55,0x55,0xff,0xff,0xaa,0xaa,0x6a,0x06, - 0x81,0x2f,0x02,0x2e,0x0b,0x9f,0x40,0xfe,0x80,0xef,0x80,0xcb,0xc0,0x02,0x0a,0xa0, - 0x02,0x1a,0x6d,0x1a,0x2f,0x54,0x07,0x1a,0x00,0xf9,0x40,0xf8,0x01,0x5b,0x2f,0xbf, - 0x2f,0xf4,0x2f,0xe0,0x2f,0x40,0xd0,0x02,0xd0,0x02,0xf9,0x0a,0x04,0xff,0x3d,0x2f, - 0x40,0x08,0x2f,0x1f,0x0d,0x3f,0x00,0x09,0x5a,0x40,0x2f,0x09,0x2f,0x0b,0xfa,0x0b, - 0xc0,0x80,0x08,0x60,0x06,0x1f,0x2f,0x7e,0x1f,0xf8,0x0b,0xfa,0x03,0xff,0x0b,0x9a, - 0x4b,0xc0,0x0c,0x69,0x3f,0x40,0xff,0x40,0xef,0x40,0x05,0x09,0x0f,0xfa,0x07,0x7f, - 0x10,0xea,0x7f,0xef,0x00,0x34,0x00,0x1f,0x00,0x7f,0x0f,0xfd,0x0f,0xf0,0xd0,0x00, - 0x00,0xf0,0x2f,0xfe,0x2f,0x6f,0x2f,0x45,0x07,0xd0,0x90,0x08,0xbe,0xd0,0x80,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 -}; -#endif - -/*** Backdrop ***/ +/* Backdrop */ char backdrop[(640 * 480 * 2) + 32]; /* Backdrop Frame Width (to avoid writing outside of the background frame) */ @@ -635,95 +28,94 @@ static unsigned char fontFont[ 0x40000 ] __attribute__((aligned(32))); /**************************************************************************** * YAY0 Decoding ****************************************************************************/ -/* Yay0 decompression */ void yay0_decode(unsigned char *s, unsigned char *d) { - int i, j, k, p, q, cnt; + int i, j, k, p, q, cnt; - i = *(unsigned long *)(s + 4); // size of decoded data - j = *(unsigned long *)(s + 8); // link table - k = *(unsigned long *)(s + 12); // byte chunks and count modifiers + i = *(unsigned long *)(s + 4); // size of decoded data + j = *(unsigned long *)(s + 8); // link table + k = *(unsigned long *)(s + 12); // byte chunks and count modifiers - q = 0; // current offset in dest buffer - cnt = 0; // mask bit counter - p = 16; // current offset in mask table + q = 0; // current offset in dest buffer + cnt = 0; // mask bit counter + p = 16; // current offset in mask table - unsigned long r22 = 0, r5; - - do - { - // if all bits are done, get next mask - if(cnt == 0) - { - // read word from mask data block - r22 = *(unsigned long *)(s + p); - p += 4; - cnt = 32; // bit counter - } - // if next bit is set, chunk is non-linked - if(r22 & 0x80000000) - { - // get next byte - *(unsigned char *)(d + q) = *(unsigned char *)(s + k); - k++, q++; - } - // do copy, otherwise - else - { - // read 16-bit from link table - int r26 = *(unsigned short *)(s + j); - j += 2; - // 'offset' - int r25 = q - (r26 & 0xfff); - // 'count' - int r30 = r26 >> 12; - if(r30 == 0) - { - // get 'count' modifier - r5 = *(unsigned char *)(s + k); - k++; - r30 = r5 + 18; - } - else r30 += 2; - // do block copy - unsigned char *pt = ((unsigned char*)d) + r25; - int i; - for(i=0; i> 12; + if(r30 == 0) + { + // get 'count' modifier + r5 = *(unsigned char *)(s + k); + k++; + r30 = r5 + 18; + } + else r30 += 2; + // do block copy + unsigned char *pt = ((unsigned char*)d) + r25; + int i; + for(i=0; i>6)&3); - *d++ = ((v>>4)&3); - *d++ = ((v>>2)&3); - *d++ = ((v)&3); - } - } - } + // 8x8 tiles + int x, y; + int t=0; + for (y = 0; y < yres; y += 8) + for (x = 0; x < xres; x += 8) + { + t = !t; + int iy, ix; + for (iy = 0; iy < 8; ++iy, src+=2) + { + unsigned char *d = dst + (y + iy) * xres + x; + for (ix = 0; ix < 2; ++ix) + { + int v = src[ix]; + *d++ = ((v>>6)&3); + *d++ = ((v>>4)&3); + *d++ = ((v>>2)&3); + *d++ = ((v)&3); + } + } + } } int font_offset[256], font_size[256], fheight; @@ -752,10 +144,10 @@ void ipl_set_config(unsigned char c) void init_font(void) { - int i; + int i; /* read font from IPL ROM */ - //memcpy(&fontFont, &iplfont, sizeof(iplfont)); + //memcpy(&fontFont, &iplfont, sizeof(iplfont)); memset(fontFont,0,0x3000); #ifndef HW_RVL ipl_set_config(6); @@ -763,24 +155,24 @@ void init_font(void) __SYS_ReadROM((unsigned char *)&fontFont,0x3000,0x1FCF00); yay0_decode((unsigned char *)&fontFont, (unsigned char *)&fontWork); - FONT_HEADER *fnt = ( FONT_HEADER * )&fontWork; - untile((unsigned char*)&fontFont, (unsigned char*)&fontWork[fnt->offset_tile], fnt->texture_width, fnt->texture_height); + FONT_HEADER *fnt = ( FONT_HEADER * )&fontWork; + untile((unsigned char*)&fontFont, (unsigned char*)&fontWork[fnt->offset_tile], fnt->texture_width, fnt->texture_height); - for (i=0; i<256; ++i) - { - int c = i; + for (i=0; i<256; ++i) + { + int c = i; - if ((c < fnt->first_char) || (c > fnt->last_char)) c = fnt->subst_char; - else c -= fnt->first_char; + if ((c < fnt->first_char) || (c > fnt->last_char)) c = fnt->subst_char; + else c -= fnt->first_char; - font_size[i] = ((unsigned char*)fnt)[fnt->offset_charwidth + c]; + font_size[i] = ((unsigned char*)fnt)[fnt->offset_charwidth + c]; - int r = c / fnt->texture_columns; - c %= fnt->texture_columns; - font_offset[i] = (r * fnt->cell_height) * fnt->texture_width + (c * fnt->cell_width); - } - - fheight = fnt->cell_height; + int r = c / fnt->texture_columns; + c %= fnt->texture_columns; + font_offset[i] = (r * fnt->cell_height) * fnt->texture_width + (c * fnt->cell_width); + } + + fheight = fnt->cell_height; } #define TRANSPARENCY (COLOR_BLACK) @@ -790,105 +182,105 @@ unsigned int blit_lookup_inv[4]={COLOR_WHITE, 0xb584b57b, 0x6d896d77, 0x258e2573 void setfontcolour (int fcolour) { - if (fcolour == COLOR_WHITE) - { - blit_lookup[1] = 0x6d896d77; - blit_lookup[2] = 0xb584b57b; - blit_lookup[3] = COLOR_WHITE; - } - else - { - blit_lookup[1] = fcolour; - blit_lookup[2] = fcolour; - blit_lookup[3] = fcolour; - } + if (fcolour == COLOR_WHITE) + { + blit_lookup[1] = 0x6d896d77; + blit_lookup[2] = 0xb584b57b; + blit_lookup[3] = COLOR_WHITE; + } + else + { + blit_lookup[1] = fcolour; + blit_lookup[2] = fcolour; + blit_lookup[3] = fcolour; + } } void blit_char(int x, int y, unsigned char c, unsigned int *lookup) { - unsigned char *fnt = ((unsigned char*)fontFont) + font_offset[c]; - int ay, ax; - unsigned int llookup; + unsigned char *fnt = ((unsigned char*)fontFont) + font_offset[c]; + int ay, ax; + unsigned int llookup; - for (ay=0; ay> 1); - unsigned long o = xfb[whichfb][p]; + for (ax=0; ax> 1); + unsigned long o = xfb[whichfb][p]; - llookup = lookup[v0]; + llookup = lookup[v0]; - if ((o != TRANSPARENCY) && (v0 == 0) && (lookup[0] == TRANSPARENCY)) - llookup = o; - - if ((ax+x) & 1) - { - o &= ~0x00FFFFFF; - o |= llookup & 0x00FFFFFF; - } - else - { - o &= ~0xFF000000; - o |= llookup & 0xFF000000; - } + if ((o != TRANSPARENCY) && (v0 == 0) && (lookup[0] == TRANSPARENCY)) + llookup = o; - xfb[whichfb][p] = o; - } - - fnt += 512; - } + if ((ax+x) & 1) + { + o &= ~0x00FFFFFF; + o |= llookup & 0x00FFFFFF; + } + else + { + o &= ~0xFF000000; + o |= llookup & 0xFF000000; + } + + xfb[whichfb][p] = o; + } + + fnt += 512; + } } void write_font(int x, int y, char *string) { - int ox = x; - while (*string && (x < (ox + back_framewidth))) - { - blit_char(x, y, *string, blit_lookup); - x += font_size[(u8)*string]; - string++; - } + int ox = x; + while (*string && (x < (ox + back_framewidth))) + { + blit_char(x, y, *string, blit_lookup); + x += font_size[(u8)*string]; + string++; + } } void writex(int x, int y, int sx, int sy, char *string, unsigned int *lookup) { - int ox = x; - while ((*string) && ((x) < (ox + sx))) - { - blit_char(x, y, *string, lookup); - x += font_size[(u8)*string]; - string++; - } - - int ay; - for (ay=0; ayback_framewidth) x=back_framewidth; - x = (640 - x) >> 1; - write_font(x, y, string); + int x, t; + for (x=t=0; tback_framewidth) x=back_framewidth; + x = (640 - x) >> 1; + write_font(x, y, string); } void WriteCentre_HL( int y, char *string) { - int x,t,h; + int x,t,h; for (x=t=0; tback_framewidth) x = back_framewidth; - h = x; - x = (640 - x) >> 1; - writex(x, y, h, fheight, string, blit_lookup_inv); + if (x>back_framewidth) x = back_framewidth; + h = x; + x = (640 - x) >> 1; + writex(x, y, h, fheight, string, blit_lookup_inv); } diff --git a/source/ngc/gui/ggentry.c b/source/ngc/gui/ggentry.c index 5b7b221..d101162 100644 --- a/source/ngc/gui/ggentry.c +++ b/source/ngc/gui/ggentry.c @@ -34,8 +34,8 @@ typedef struct } GGPATCH; /*** Game Genie Codes Array ***/ -unsigned char ggcodes[MAXCODES][10]; /*** Codes are entered as XXXX-XXXX ***/ -int gghpos[MAXCODES]; /*** Edit positions ***/ +unsigned char ggcodes[MAXCODES][10]; /*** Codes are entered as XXXX-XXXX ***/ +int gghpos[MAXCODES]; /*** Edit positions ***/ int ggrow = 0; int editing = 0; char ggvalidchars[] = "ABCDEFGHJKLMNPRSTVWXYZ0123456789*"; @@ -50,53 +50,53 @@ void decode_genie (char *code, int which) int n, i; for (i = 0; i < 8; i++) { - /*** This should only happen if memory is corrupt! ***/ - p = strchr (ggvalidchars, code[i]); - if (p == NULL) - { - ggpatch[which].address = ggpatch[which].data = 0; - return; - } + /*** This should only happen if memory is corrupt! ***/ + p = strchr (ggvalidchars, code[i]); + if (p == NULL) + { + ggpatch[which].address = ggpatch[which].data = 0; + return; + } - n = p - ggvalidchars; + n = p - ggvalidchars; - switch (i) - { - case 0: - ggpatch[which].data |= n << 3; - break; + switch (i) + { + case 0: + ggpatch[which].data |= n << 3; + break; - case 1: - ggpatch[which].data |= n >> 2; - ggpatch[which].address |= (n & 3) << 14; - break; + case 1: + ggpatch[which].data |= n >> 2; + ggpatch[which].address |= (n & 3) << 14; + break; - case 2: - ggpatch[which].address |= n << 9; - break; + case 2: + ggpatch[which].address |= n << 9; + break; - case 3: - ggpatch[which].address |= (n & 0xF) << 20 | (n >> 4) << 8; - break; + case 3: + ggpatch[which].address |= (n & 0xF) << 20 | (n >> 4) << 8; + break; - case 4: - ggpatch[which].data |= (n & 1) << 12; - ggpatch[which].address |= (n >> 1) << 16; - break; + case 4: + ggpatch[which].data |= (n & 1) << 12; + ggpatch[which].address |= (n >> 1) << 16; + break; - case 5: - ggpatch[which].data |= (n & 1) << 15 | (n >> 1) << 8; - break; + case 5: + ggpatch[which].data |= (n & 1) << 15 | (n >> 1) << 8; + break; - case 6: - ggpatch[which].data |= (n >> 3) << 13; - ggpatch[which].address |= (n & 7) << 5; - break; + case 6: + ggpatch[which].data |= (n >> 3) << 13; + ggpatch[which].address |= (n & 7) << 5; + break; - case 7: - ggpatch[which].address |= n; - break; - } + case 7: + ggpatch[which].address |= n; + break; + } } } @@ -112,25 +112,25 @@ void decode_ggcodes () j = 0; for (i = 0; i < 8; i++) { - if (strcmp ((char *)ggcodes[i], "AAAA-AAAA")) - { - /*** Move the code into thiscode ***/ - memcpy (&thiscode, &ggcodes[i], 4); - memcpy (&thiscode[4], &ggcodes[i][5], 4); + if (strcmp ((char *)ggcodes[i], "AAAA-AAAA")) + { + /*** Move the code into thiscode ***/ + memcpy (&thiscode, &ggcodes[i], 4); + memcpy (&thiscode[4], &ggcodes[i][5], 4); - decode_genie (thiscode, j); - j++; - } + decode_genie (thiscode, j); + j++; + } } /*** And now apply the patches ***/ if (j) { - for (i = 0; i < j; i++) - { - if (ggpatch[i].address < 0x400000) - { - /*** Patching ROM space ONLY (Game Genie does NOT have access to other memory areas) ***/ + for (i = 0; i < j; i++) + { + if (ggpatch[i].address < 0x400000) + { + /*** Patching ROM space ONLY (Game Genie does NOT have access to other memory areas) ***/ if (cart_rom) *(uint16 *)(cart_rom + ggpatch[i].address) = ggpatch[i].data & 0xffff; } } @@ -148,8 +148,8 @@ void ClearGGCodes () for (i = 0; i < MAXCODES; i++) { - strcpy ((char *)ggcodes[i], "AAAA-AAAA"); - gghpos[i] = 0; + strcpy ((char *)ggcodes[i], "AAAA-AAAA"); + gghpos[i] = 0; } ggrow = 0; } @@ -169,29 +169,29 @@ void DrawGGCodes () for (i = 0; i < MAXCODES; i++) { - if (i == ggrow) - { - /*** Highlight selected ***/ - WriteCentre_HL (i * fheight + 224, (char *)ggcodes[i]); + if (i == ggrow) + { + /*** Highlight selected ***/ + WriteCentre_HL (i * fheight + 224, (char *)ggcodes[i]); - /*** If editing, highlight the current character ***/ - if (editing) - { - int hpos = 0; + /*** If editing, highlight the current character ***/ + if (editing) + { + int hpos = 0; for (j=0; j> 1); - for (j=0; j> 1); + for (j=0; j 8) gghpos[ggrow] = 0; + if (gghpos[ggrow] < 0) gghpos[ggrow] = 8; + if (gghpos[ggrow] > 8) gghpos[ggrow] = 0; if (p & PAD_BUTTON_A) quit = 1; } @@ -283,49 +283,49 @@ void GGSelectLine () short j; /*** To select a line, just move up or down. - Pressing A will enter edit mode. - Pressing B will exit to caller. ***/ + Pressing A will enter edit mode. + Pressing B will exit to caller. ***/ while (quit == 0) { - if (redraw) - { - DrawGGCodes (); - redraw = 0; - } + if (redraw) + { + DrawGGCodes (); + redraw = 0; + } - j = ogc_input__getMenuButtons(); + j = ogc_input__getMenuButtons(); - if (j & PAD_BUTTON_UP) - { - ggrow--; - redraw = 1; - } + if (j & PAD_BUTTON_UP) + { + ggrow--; + redraw = 1; + } - if (j & PAD_BUTTON_DOWN) - { - ggrow++; - redraw = 1; - } + if (j & PAD_BUTTON_DOWN) + { + ggrow++; + redraw = 1; + } - if (ggrow < 0) ggrow = MAXCODES - 1; - if (ggrow == MAXCODES) ggrow = 0; + if (ggrow < 0) ggrow = MAXCODES - 1; + if (ggrow == MAXCODES) ggrow = 0; - if (j & PAD_BUTTON_B) quit = 1; + if (j & PAD_BUTTON_B) quit = 1; - if (j & PAD_BUTTON_A) - { - GGEditLine (); - redraw = 1; - } + if (j & PAD_BUTTON_A) + { + GGEditLine (); + redraw = 1; + } if (j & PAD_TRIGGER_Z) - { - /* reset code */ + { + /* reset code */ strcpy ((char *)ggcodes[ggrow], "AAAA-AAAA"); gghpos[ggrow] = 0; redraw = 1; - } + } } } diff --git a/source/ngc/gui/iso9660.c b/source/ngc/gui/iso9660.c deleted file mode 100644 index b71a61e..0000000 --- a/source/ngc/gui/iso9660.c +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** - * DVD ISO9660/Joliet Parsing - * - * This is not intended as a complete guide to ISO9660. - * Here I use the bare minimum! - ***************************************************************************/ -#include "shared.h" -#include "dvd.h" -#include "iso9660.h" - -/** Minimal ISO Directory Definition **/ -#define RECLEN 0 /* Record length */ -#define EXTENT 6 /* Extent */ -#define FILE_LENGTH 14 /* File length (BIG ENDIAN) */ -#define FILE_FLAGS 25 /* File flags */ -#define FILENAME_LENGTH 32 /* Filename length */ -#define FILENAME 33 /* ASCIIZ filename */ - -/** Minimal Primary Volume Descriptor **/ -#define PVDROOT 0x9c - -static int IsJoliet = 0; -u64 rootdir = 0; -u64 basedir = 0; -int rootdirlength = 0; - -/** Global file entry table **/ -FILEENTRIES filelist[MAXFILES]; -static char dvdbuffer[2048] ATTRIBUTE_ALIGN (32); - -/**************************************************************************** - * Primary Volume Descriptor - * - * The PVD should reside between sector 16 and 31. - * This is for single session DVD only. - ****************************************************************************/ -int getpvd () -{ - int sector = 16; - u32 rootdir32; - - basedir = rootdirlength = 0; - IsJoliet = -1; - - /** Look for Joliet PVD first **/ - while (sector < 32) - { - if (dvd_read (&dvdbuffer, 2048, (u64)(sector << 11))) - { - if (memcmp (&dvdbuffer, "\2CD001\1", 8) == 0) - { - memcpy(&rootdir32, &dvdbuffer[PVDROOT + EXTENT], 4); - basedir = (u64)rootdir32; - memcpy (&rootdirlength, &dvdbuffer[PVDROOT + FILE_LENGTH], 4); - basedir <<= 11; - IsJoliet = 1; - break; - } - } - else return 0; /*** Can't read sector! ***/ - sector++; - } - - if (IsJoliet > 0) return 1; /*** Joliet PVD Found ? ***/ - - /*** Look for standard ISO9660 PVD ***/ - sector = 16; - while (sector < 32) - { - if (dvd_read (&dvdbuffer, 2048, (u64)(sector << 11))) - { - if (memcmp (&dvdbuffer, "\1CD001\1", 8) == 0) - { - memcpy (&rootdir32, &dvdbuffer[PVDROOT + EXTENT], 4); - basedir = (u64)rootdir32; - memcpy (&rootdirlength, &dvdbuffer[PVDROOT + FILE_LENGTH], 4); - IsJoliet = 0; - basedir <<= 11; - break; - } - } - else return 0; /*** Can't read sector! ***/ - sector++; - } - - return (IsJoliet == 0); -} - -/**************************************************************************** - * getentry - * - * Support function to return the next file entry, if any - * Declared static to avoid accidental external entry. - ****************************************************************************/ -static int diroffset = 0; -static int getentry (int entrycount) -{ - char fname[512]; /* Huge, but experience has determined this */ - char *ptr; - char *filename; - char *filenamelength; - char *rr; - int j; - u32 offset32; - - /* Basic checks */ - if (entrycount >= MAXFILES) return 0; - if (diroffset >= 2048) return 0; - - /** Decode this entry **/ - if (dvdbuffer[diroffset]) /* Record length available */ - { - /* Update offsets into sector buffer */ - ptr = (char *) &dvdbuffer[0]; - ptr += diroffset; - filename = ptr + FILENAME; - filenamelength = ptr + FILENAME_LENGTH; - - /* Check for wrap round - illegal in ISO spec, - * but certain crap writers do it! */ - if ((diroffset + dvdbuffer[diroffset]) > 2048) return 0; - - if (*filenamelength) - { - memset (&fname, 0, 512); - - /*** Do ISO 9660 first ***/ - if (!IsJoliet) strcpy (fname, filename); - else - { - /*** The more tortuous unicode joliet entries ***/ - for (j = 0; j < (*filenamelength >> 1); j++) - { - fname[j] = filename[j * 2 + 1]; - } - - fname[j] = 0; - - if (strlen (fname) >= MAXJOLIET) fname[MAXJOLIET - 1] = 0; - if (strlen (fname) == 0) fname[0] = filename[0]; - } - - if (strlen (fname) == 0) strcpy (fname, "."); - else - { - if (fname[0] == 1) strcpy (fname, ".."); - else - { - /* - * Move *filenamelength to t, - * Only to stop gcc warning for noobs :) - */ - int t = *filenamelength; - fname[t] = 0; - } - } - - /** Rockridge Check **/ - rr = strstr (fname, ";"); - if (rr != NULL) *rr = 0; - - strcpy (filelist[entrycount].filename, fname); - memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4); - filelist[entrycount].offset = (u64)offset32; - memcpy (&filelist[entrycount].length, &dvdbuffer[diroffset + FILE_LENGTH], 4); - memcpy (&filelist[entrycount].flags, &dvdbuffer[diroffset + FILE_FLAGS], 1); - - filelist[entrycount].offset <<= 11; - filelist[entrycount].flags = filelist[entrycount].flags & 2; - filelist[entrycount].filename_offset = 0; - - /*** Prepare for next entry ***/ - diroffset += dvdbuffer[diroffset]; - - return 1; - } - } - return 0; -} - -/**************************************************************************** - * parseDVDdirectory - * - * This function will parse the directory tree. - * It relies on rootdir and rootdirlength being pre-populated by a call to - * getpvd, a previous parse or a menu selection. - * - * The return value is number of files collected, or 0 on failure. - ****************************************************************************/ -int parseDVDdirectory () -{ - int pdlength; - u64 pdoffset; - u64 rdoffset; - int len = 0; - int filecount = 0; - - pdoffset = rdoffset = rootdir; - pdlength = rootdirlength; - filecount = 0; - - /** Clear any existing values ***/ - memset (&filelist, 0, sizeof (FILEENTRIES) * MAXFILES); - - /*** Get as many files as possible ***/ - while (len < pdlength) - { - if (dvd_read (&dvdbuffer, 2048, pdoffset) == 0) return 0; - - diroffset = 0; - - while (getentry (filecount)) - { - if (filecount < MAXFILES) filecount++; - } - - len += 2048; - pdoffset = rdoffset + len; - } - return filecount; -} diff --git a/source/ngc/gui/iso9660.h b/source/ngc/gui/iso9660.h deleted file mode 100644 index ad2d76e..0000000 --- a/source/ngc/gui/iso9660.h +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************** - * - * DVD ISO9660/Joliet Parsing - * - * This is not intended as a complete guide to ISO9660. - * Here I use the bare minimum! - ***************************************************************************/ -#ifndef _ISO9660_H -#define _ISO9660_H - -#define MAXJOLIET 256 -#define MAXFILES 1000 /** Restrict to 1000 files per dir **/ - -typedef struct -{ - u64 offset; - unsigned int length; - char flags; - char filename[MAXJOLIET]; - u16 filename_offset; -} FILEENTRIES; - -extern u64 basedir; -extern u64 rootdir; -extern int rootdirlength; - -extern int getpvd (); -extern int parseDVDdirectory (); -extern FILEENTRIES filelist[MAXFILES]; - -#endif diff --git a/source/ngc/gui/legal.c b/source/ngc/gui/legal.c index fcbc8d7..201a3b5 100644 --- a/source/ngc/gui/legal.c +++ b/source/ngc/gui/legal.c @@ -80,12 +80,12 @@ void legal () dispoffset = (316 * 320) + ((640 - dkpro_WIDTH) >> 2); for (h = 0; h < dkpro_HEIGHT; h++) - { - for (w = 0; w < dkpro_WIDTH >> 1; w++) - xfb[whichfb][dispoffset + w] = dkproraw[p++]; + { + for (w = 0; w < dkpro_WIDTH >> 1; w++) + xfb[whichfb][dispoffset + w] = dkproraw[p++]; - dispoffset += 320; - } + dispoffset += 320; + } free (dkproraw); } diff --git a/source/ngc/gui/menu.c b/source/ngc/gui/menu.c index 3430e0a..549b985 100644 --- a/source/ngc/gui/menu.c +++ b/source/ngc/gui/menu.c @@ -24,7 +24,8 @@ #include "shared.h" #include "dvd.h" #include "font.h" -#include "history.h" +#include "fileio_dvd.h" +#include "fileio_fat.h" #ifdef HW_RVL #include @@ -131,82 +132,82 @@ int domenu (char items[][25], int maxitems, u8 fastmove) extern struct ym2612__ YM2612; void soundmenu () { - int ret; - int quit = 0; - int prevmenu = menu; - int count = 6; - char items[6][25]; + int ret; + int quit = 0; + int prevmenu = menu; + int count = 6; + char items[6][25]; - strcpy (menutitle, "Press B to return"); + strcpy (menutitle, "Press B to return"); - menu = 0; - while (quit == 0) - { - sprintf (items[0], "PSG Volume: %1.2f", config.psg_preamp); - sprintf (items[1], "FM Volume: %1.2f", config.fm_preamp); - sprintf (items[2], "Volume Boost: %dX", config.boost); - sprintf (items[3], "LowPass Filter: %s", config.filter ? " ON":"OFF"); - if (config.hq_fm == 0) sprintf (items[4], "HQ YM2612: OFF"); + menu = 0; + while (quit == 0) + { + sprintf (items[0], "PSG Volume: %1.2f", config.psg_preamp); + sprintf (items[1], "FM Volume: %1.2f", config.fm_preamp); + sprintf (items[2], "Volume Boost: %dX", config.boost); + sprintf (items[3], "LowPass Filter: %s", config.filter ? " ON":"OFF"); + if (config.hq_fm == 0) sprintf (items[4], "HQ YM2612: OFF"); else if ((config.hq_fm == 1) || config.fm_core) sprintf (items[4], "HQ YM2612: LINEAR"); else sprintf (items[4], "HQ YM2612: SINC"); - sprintf (items[5], "FM core: %s", config.fm_core ? "GENS" : "MAME"); + sprintf (items[5], "FM core: %s", config.fm_core ? "GENS" : "MAME"); - ret = domenu (&items[0], count, 1); - switch (ret) - { - case 0: - case -2: - if (ret<0) config.psg_preamp -= 0.01; - else config.psg_preamp += 0.01; - if (config.psg_preamp < 0.0) config.psg_preamp = 5.0; - if (config.psg_preamp > 5.0) config.psg_preamp = 0.0; - break; + ret = domenu (&items[0], count, 1); + switch (ret) + { + case 0: + case -2: + if (ret<0) config.psg_preamp -= 0.01; + else config.psg_preamp += 0.01; + if (config.psg_preamp < 0.0) config.psg_preamp = 5.0; + if (config.psg_preamp > 5.0) config.psg_preamp = 0.0; + break; - case 1: - case -3: - if (ret<0) config.fm_preamp -= 0.01; - else config.fm_preamp += 0.01; - if (config.fm_preamp < 0.0) config.fm_preamp = 5.0; - if (config.fm_preamp > 5.0) config.fm_preamp = 0.0; - break; + case 1: + case -3: + if (ret<0) config.fm_preamp -= 0.01; + else config.fm_preamp += 0.01; + if (config.fm_preamp < 0.0) config.fm_preamp = 5.0; + if (config.fm_preamp > 5.0) config.fm_preamp = 0.0; + break; - case 2: - config.boost ++; - if (config.boost > 4) config.boost = 0; - break; - - case 3: - config.filter ^= 1; - break; + case 2: + config.boost ++; + if (config.boost > 4) config.boost = 0; + break; + + case 3: + config.filter ^= 1; + break; case 4: - config.hq_fm ++; + config.hq_fm ++; if ((config.hq_fm>2)||(config.fm_core && (config.hq_fm>1))) config.hq_fm = 0; if (genromsize) - { - audio_init(48000); - fm_restore(); - } - break; + { + audio_init(48000); + fm_restore(); + } + break; - case 5: - config.fm_core ^= 1; - config.psg_preamp = config.fm_core ? 2.5 : 1.5; - config.fm_preamp = 1.0; - if (genromsize) - { - if (!config.fm_core) memcpy(fm_reg,YM2612.REG,sizeof(fm_reg)); - audio_init(48000); - fm_restore(); - } - break; + case 5: + config.fm_core ^= 1; + config.psg_preamp = config.fm_core ? 2.5 : 1.5; + config.fm_preamp = 1.0; + if (genromsize) + { + if (!config.fm_core) memcpy(fm_reg,YM2612.REG,sizeof(fm_reg)); + audio_init(48000); + fm_restore(); + } + break; case -1: - quit = 1; - break; - } - } - menu = prevmenu; + quit = 1; + break; + } + } + menu = prevmenu; } /**************************************************************************** @@ -215,97 +216,97 @@ void soundmenu () ****************************************************************************/ void miscmenu () { - int ret; - int quit = 0; - int prevmenu = menu; - int count = 6; - char items[6][25]; - strcpy (menutitle, "Press B to return"); - menu = 0; - - while (quit == 0) - { - if (config.region_detect == 0) sprintf (items[0], "Region: AUTO"); - else if (config.region_detect == 1) sprintf (items[0], "Region: USA"); - else if (config.region_detect == 2) sprintf (items[0], "Region: EUR"); - else if (config.region_detect == 3) sprintf (items[0], "Region: JAP"); - sprintf (items[1], "Force DTACK: %s", config.force_dtack ? "Y" : "N"); - if (config.bios_enabled & 1) sprintf (items[2], "Use BIOS: ON"); - else sprintf (items[2], "Use BIOS: OFF"); - sprintf (items[3], "SVP Cycles: %d", SVP_cycles); - if (config.sram_auto == 0) sprintf (items[4], "Auto SRAM: SDCARD"); - else if (config.sram_auto == 1) sprintf (items[4], "Auto SRAM: MCARD A"); - else if (config.sram_auto == 2) sprintf (items[4], "Auto SRAM: MCARD B"); - else sprintf (items[4], "Auto SRAM: OFF"); - if (config.freeze_auto == 0) sprintf (items[5], "Auto FREEZE: SDCARD"); - else if (config.freeze_auto == 1) sprintf (items[5], "Auto FREEZE: MCARD A"); - else if (config.freeze_auto == 2) sprintf (items[5], "Auto FREEZE: MCARD B"); - else sprintf (items[5], "Auto FREEZE: OFF"); + int ret; + int quit = 0; + int prevmenu = menu; + int count = 6; + char items[6][25]; + strcpy (menutitle, "Press B to return"); + menu = 0; + + while (quit == 0) + { + if (config.region_detect == 0) sprintf (items[0], "Region: AUTO"); + else if (config.region_detect == 1) sprintf (items[0], "Region: USA"); + else if (config.region_detect == 2) sprintf (items[0], "Region: EUR"); + else if (config.region_detect == 3) sprintf (items[0], "Region: JAP"); + sprintf (items[1], "Force DTACK: %s", config.force_dtack ? "Y" : "N"); + if (config.bios_enabled & 1) sprintf (items[2], "Use BIOS: ON"); + else sprintf (items[2], "Use BIOS: OFF"); + sprintf (items[3], "SVP Cycles: %d", SVP_cycles); + if (config.sram_auto == 0) sprintf (items[4], "Auto SRAM: SDCARD"); + else if (config.sram_auto == 1) sprintf (items[4], "Auto SRAM: MCARD A"); + else if (config.sram_auto == 2) sprintf (items[4], "Auto SRAM: MCARD B"); + else sprintf (items[4], "Auto SRAM: OFF"); + if (config.freeze_auto == 0) sprintf (items[5], "Auto FREEZE: SDCARD"); + else if (config.freeze_auto == 1) sprintf (items[5], "Auto FREEZE: MCARD A"); + else if (config.freeze_auto == 2) sprintf (items[5], "Auto FREEZE: MCARD B"); + else sprintf (items[5], "Auto FREEZE: OFF"); - ret = domenu (&items[0], count, 1); - switch (ret) - { - case 0: /*** Region Force ***/ - config.region_detect = (config.region_detect + 1) % 4; - if (genromsize) - { - /* force region & cpu mode */ - set_region(); - - /* reinitialize timings */ - system_init (); - audio_init(48000); - fm_restore(); - - /* reinitialize HVC tables */ - vctab = (vdp_pal) ? ((reg[1] & 8) ? vc_pal_240 : vc_pal_224) : vc_ntsc_224; - hctab = (reg[12] & 1) ? cycle2hc40 : cycle2hc32; + ret = domenu (&items[0], count, 1); + switch (ret) + { + case 0: /*** Region Force ***/ + config.region_detect = (config.region_detect + 1) % 4; + if (genromsize) + { + /* force region & cpu mode */ + set_region(); + + /* reinitialize timings */ + system_init (); + audio_init(48000); + fm_restore(); + + /* reinitialize HVC tables */ + vctab = (vdp_pal) ? ((reg[1] & 8) ? vc_pal_240 : vc_pal_224) : vc_ntsc_224; + hctab = (reg[12] & 1) ? cycle2hc40 : cycle2hc32; - /* reinitialize overscan area */ - bitmap.viewport.x = config.overscan ? ((reg[12] & 1) ? 16 : 12) : 0; - bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0; - bitmap.viewport.changed = 1; - } - break; + /* reinitialize overscan area */ + bitmap.viewport.x = config.overscan ? ((reg[12] & 1) ? 16 : 12) : 0; + bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0; + bitmap.viewport.changed = 1; + } + break; - case 1: /*** force DTACK ***/ - config.force_dtack ^= 1; - break; + case 1: /*** force DTACK ***/ + config.force_dtack ^= 1; + break; - case 2: /*** BIOS support ***/ + case 2: /*** BIOS support ***/ config.bios_enabled ^= 1; if (genromsize || (config.bios_enabled == 3)) { - system_init (); - audio_init(48000); + system_init (); + audio_init(48000); system_reset (); - } + } break; - case 3: /*** SVP emulation ***/ - case -5: - if (ret<0) SVP_cycles = SVP_cycles ? (SVP_cycles-1) : 1500; - else SVP_cycles++; - if (SVP_cycles > 1500) SVP_cycles = 0; - break; + case 3: /*** SVP emulation ***/ + case -5: + if (ret<0) SVP_cycles = SVP_cycles ? (SVP_cycles-1) : 1500; + else SVP_cycles++; + if (SVP_cycles > 1500) SVP_cycles = 0; + break; - case 4: /*** SRAM autoload/autosave ***/ - config.sram_auto ++; + case 4: /*** SRAM autoload/autosave ***/ + config.sram_auto ++; if (config.sram_auto > 2) config.sram_auto = -1; break; - case 5: /*** FreezeState autoload/autosave ***/ + case 5: /*** FreezeState autoload/autosave ***/ config.freeze_auto ++; if (config.freeze_auto > 2) config.freeze_auto = -1; break; case -1: - quit = 1; - break; - } - } + quit = 1; + break; + } + } - menu = prevmenu; + menu = prevmenu; } /**************************************************************************** @@ -316,50 +317,50 @@ uint8 old_overscan = 1; void dispmenu () { - int ret; - int quit = 0; - int prevmenu = menu; - int count = config.aspect ? 8 : 10; - char items[10][25]; + int ret; + int quit = 0; + int prevmenu = menu; + int count = config.aspect ? 8 : 10; + char items[10][25]; - strcpy (menutitle, "Press B to return"); - menu = 0; + strcpy (menutitle, "Press B to return"); + menu = 0; - while (quit == 0) - { + while (quit == 0) + { sprintf (items[0], "Aspect: %s", config.aspect ? "ORIGINAL" : "STRETCHED"); - if (config.render == 1) sprintf (items[1], "Render: INTERLACED"); - else if (config.render == 2) sprintf (items[1], "Render: PROGRESSIVE"); - else sprintf (items[1], "Render: ORIGINAL"); - if (config.tv_mode == 0) sprintf (items[2], "TV Mode: 60HZ"); - else if (config.tv_mode == 1) sprintf (items[2], "TV Mode: 50HZ"); - else sprintf (items[2], "TV Mode: 50/60HZ"); + if (config.render == 1) sprintf (items[1], "Render: INTERLACED"); + else if (config.render == 2) sprintf (items[1], "Render: PROGRESSIVE"); + else sprintf (items[1], "Render: ORIGINAL"); + if (config.tv_mode == 0) sprintf (items[2], "TV Mode: 60HZ"); + else if (config.tv_mode == 1) sprintf (items[2], "TV Mode: 50HZ"); + else sprintf (items[2], "TV Mode: 50/60HZ"); sprintf (items[3], "Bilinear Filter: %s", config.bilinear ? " ON" : "OFF"); if (config.ntsc == 1) sprintf (items[4], "NTSC Filter: COMPOSITE"); - else if (config.ntsc == 2) sprintf (items[4], "NTSC Filter: S-VIDEO"); - else if (config.ntsc == 3) sprintf (items[4], "NTSC Filter: RGB"); - else sprintf (items[4], "NTSC Filter: OFF"); - sprintf (items[5], "Borders: %s", config.overscan ? " ON" : "OFF"); - sprintf (items[6], "Center X: %s%02d", config.xshift < 0 ? "-":"+", abs(config.xshift)); - sprintf (items[7], "Center Y: %s%02d", config.yshift < 0 ? "-":"+", abs(config.yshift)); - sprintf (items[8], "Scale X: %s%02d", config.xscale < 0 ? "-":"+", abs(config.xscale)); - sprintf (items[9], "Scale Y: %s%02d", config.yscale < 0 ? "-":"+", abs(config.yscale)); + else if (config.ntsc == 2) sprintf (items[4], "NTSC Filter: S-VIDEO"); + else if (config.ntsc == 3) sprintf (items[4], "NTSC Filter: RGB"); + else sprintf (items[4], "NTSC Filter: OFF"); + sprintf (items[5], "Borders: %s", config.overscan ? " ON" : "OFF"); + sprintf (items[6], "Center X: %s%02d", config.xshift < 0 ? "-":"+", abs(config.xshift)); + sprintf (items[7], "Center Y: %s%02d", config.yshift < 0 ? "-":"+", abs(config.yshift)); + sprintf (items[8], "Scale X: %s%02d", config.xscale < 0 ? "-":"+", abs(config.xscale)); + sprintf (items[9], "Scale Y: %s%02d", config.yscale < 0 ? "-":"+", abs(config.yscale)); - ret = domenu (&items[0], count, 1); + ret = domenu (&items[0], count, 1); - switch (ret) - { - case 0: /*** config.aspect ratio ***/ - config.aspect ^= 1; + switch (ret) + { + case 0: /*** config.aspect ratio ***/ + config.aspect ^= 1; count = config.aspect ? 8 : 10; - break; + break; - case 1: /*** rendering ***/ - config.render = (config.render + 1) % 3; - if (config.render == 2) - { - if (VIDEO_HaveComponentCable()) - { + case 1: /*** rendering ***/ + config.render = (config.render + 1) % 3; + if (config.render == 2) + { + if (VIDEO_HaveComponentCable()) + { /* progressive mode (60hz only) */ config.tv_mode = 0; } @@ -368,65 +369,65 @@ void dispmenu () /* do nothing if component cable is not detected */ config.render = 0; } - } - bitmap.viewport.changed = 1; - break; + } + bitmap.viewport.changed = 1; + break; - case 2: /*** tv mode ***/ - if (config.render == 2) break; /* 60hz progressive only */ - config.tv_mode = (config.tv_mode + 1) % 3; - break; - - case 3: /*** bilinear filtering ***/ - config.bilinear ^= 1; - bitmap.viewport.changed = 1; - break; + case 2: /*** tv mode ***/ + if (config.render == 2) break; /* 60hz progressive only */ + config.tv_mode = (config.tv_mode + 1) % 3; + break; + + case 3: /*** bilinear filtering ***/ + config.bilinear ^= 1; + bitmap.viewport.changed = 1; + break; case 4: /*** NTSC filter ***/ - config.ntsc ++; + config.ntsc ++; if (config.ntsc > 3) config.ntsc = 0; - bitmap.viewport.changed = 1; - break; + bitmap.viewport.changed = 1; + break; case 5: /*** overscan emulation ***/ - config.overscan ^= 1; - bitmap.viewport.x = config.overscan ? ((reg[12] & 1) ? 16 : 12) : 0; - bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0; - bitmap.viewport.changed = 1; - break; + config.overscan ^= 1; + bitmap.viewport.x = config.overscan ? ((reg[12] & 1) ? 16 : 12) : 0; + bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0; + bitmap.viewport.changed = 1; + break; - case 6: /*** Center X ***/ - case -8: - if (ret<0) config.xshift --; - else config.xshift ++; - break; + case 6: /*** Center X ***/ + case -8: + if (ret<0) config.xshift --; + else config.xshift ++; + break; - case 7: /*** Center Y ***/ - case -9: - if (ret<0) config.yshift --; - else config.yshift ++; - break; - - case 8: /*** Scale X ***/ - case -10: - if (config.aspect) break; + case 7: /*** Center Y ***/ + case -9: + if (ret<0) config.yshift --; + else config.yshift ++; + break; + + case 8: /*** Scale X ***/ + case -10: + if (config.aspect) break; if (ret<0) config.xscale --; - else config.xscale ++; - break; + else config.xscale ++; + break; - case 9: /*** Scale Y ***/ - case -11: - if (config.aspect) break; - if (ret<0) config.yscale --; - else config.yscale ++; - break; + case 9: /*** Scale Y ***/ + case -11: + if (config.aspect) break; + if (ret<0) config.yscale --; + else config.yscale ++; + break; - case -1: - quit = 1; - break; - } - } - menu = prevmenu; + case -1: + quit = 1; + break; + } + } + menu = prevmenu; } /**************************************************************************** @@ -435,10 +436,10 @@ void dispmenu () extern int old_system[2]; void ConfigureJoypads () { - int ret, max_players; - int i = 0; + int ret, max_players; + int i = 0; int quit = 0; - int prevmenu = menu; + int prevmenu = menu; char padmenu[8][25]; int player = 0; @@ -446,11 +447,11 @@ void ConfigureJoypads () u32 exp; #endif - strcpy (menutitle, "Press B to return"); + strcpy (menutitle, "Press B to return"); - menu = 0; - while (quit == 0) - { + menu = 0; + while (quit == 0) + { /* update max players */ max_players = 0; if (input.system[0] == SYSTEM_GAMEPAD) @@ -548,9 +549,9 @@ void ConfigureJoypads () ret = domenu (&padmenu[0], 8,0); - switch (ret) - { - case 0: + switch (ret) + { + case 0: if (j_cart) { WaitPrompt("JCART detected !"); @@ -569,9 +570,9 @@ void ConfigureJoypads () io_reset(); old_system[0] = input.system[0]; old_system[1] = input.system[1]; - break; - - case 1: + break; + + case 1: if (j_cart) { WaitPrompt("JCART detected !"); @@ -588,7 +589,7 @@ void ConfigureJoypads () io_reset(); old_system[0] = input.system[0]; old_system[1] = input.system[1]; - break; + break; case 2: config.gun_cursor ^= 1; @@ -704,7 +705,7 @@ void ConfigureJoypads () #endif break; - case 6: + case 6: if (config.input[player].device == 1) break; input.padtype[player] ^= 1; io_reset(); @@ -716,7 +717,7 @@ void ConfigureJoypads () ogc_input__config(config.input[player].port, config.input[player].device, input.padtype[player]); break; - case -1: + case -1: /* remove duplicate assigned inputs */ for (i=0; i<8; i++) { @@ -726,12 +727,12 @@ void ConfigureJoypads () config.input[i].port = i%4; } } - quit = 1; - break; - } - } + quit = 1; + break; + } + } - menu = prevmenu; + menu = prevmenu; } /**************************************************************************** @@ -740,49 +741,49 @@ void ConfigureJoypads () ****************************************************************************/ void optionmenu () { - int ret; - int quit = 0; - int prevmenu = menu; - int count = 5; - char items[5][25] = + int ret; + int quit = 0; + int prevmenu = menu; + int count = 5; + char items[5][25] = { - "Video Options", - "Sound Options", - "System Options", - "Controls Options", - "Game Genie Codes" - }; + "Video Options", + "Sound Options", + "System Options", + "Controls Options", + "Game Genie Codes" + }; - menu = 0; - while (quit == 0) - { - strcpy (menutitle, "Press B to return"); - ret = domenu (&items[0], count, 0); - switch (ret) - { - case 0: - dispmenu(); - break; - case 1: - soundmenu(); - break; - case 2: - miscmenu(); - break; - case 3: - ConfigureJoypads(); - break; - case 4: - GetGGEntries(); - break; - case -1: - quit = 1; - break; - } - } + menu = 0; + while (quit == 0) + { + strcpy (menutitle, "Press B to return"); + ret = domenu (&items[0], count, 0); + switch (ret) + { + case 0: + dispmenu(); + break; + case 1: + soundmenu(); + break; + case 2: + miscmenu(); + break; + case 3: + ConfigureJoypads(); + break; + case 4: + GetGGEntries(); + break; + case -1: + quit = 1; + break; + } + } config_save(); - menu = prevmenu; + menu = prevmenu; } /**************************************************************************** @@ -793,15 +794,15 @@ static u8 device = 0; int loadsavemenu (int which) { - int prevmenu = menu; - int quit = 0; - int ret; - int count = 3; - char items[3][25]; + int prevmenu = menu; + int quit = 0; + int ret; + int count = 3; + char items[3][25]; - strcpy (menutitle, "Press B to return"); + strcpy (menutitle, "Press B to return"); - menu = 2; + menu = 2; if (which == 1) { @@ -814,34 +815,34 @@ int loadsavemenu (int which) sprintf(items[2], "Load SRAM"); } - while (quit == 0) - { + while (quit == 0) + { if (device == 0) sprintf(items[0], "Device: SDCARD"); else if (device == 1) sprintf(items[0], "Device: MCARD A"); else if (device == 2) sprintf(items[0], "Device: MCARD B"); - ret = domenu (&items[0], count, 0); - switch (ret) - { - case -1: - quit = 1; - break; + ret = domenu (&items[0], count, 0); + switch (ret) + { + case -1: + quit = 1; + break; - case 0: + case 0: device = (device + 1)%3; break; - case 1: - case 2: - if (which == 1) quit = ManageState(ret-1,device); - else if (which == 0) quit = ManageSRAM(ret-1,device); - if (quit) return 1; + case 1: + case 2: + if (which == 1) quit = ManageState(ret-1,device); + else if (which == 0) quit = ManageSRAM(ret-1,device); + if (quit) return 1; break; - } - } + } + } - menu = prevmenu; - return 0; + menu = prevmenu; + return 0; } @@ -851,36 +852,37 @@ int loadsavemenu (int which) ****************************************************************************/ int filemenu () { - int prevmenu = menu; - int ret; - int quit = 0; - int count = 2; - char items[2][25] = { - {"SRAM Manager"}, - {"STATE Manager"} - }; + int prevmenu = menu; + int ret; + int quit = 0; + int count = 2; + char items[2][25] = { + {"SRAM Manager"}, + {"STATE Manager"} + }; - menu = 0; + menu = 0; - while (quit == 0) - { - strcpy (menutitle, "Press B to return"); - ret = domenu (&items[0], count, 0); - switch (ret) - { - case -1: /*** Button B ***/ - ret = 0; - quit = 1; - break; - case 0: /*** SRAM Manager ***/ - case 1: /*** SaveState Manager ***/ - if (loadsavemenu(ret)) return 1; - break; - } - } + while (quit == 0) + { + strcpy (menutitle, "Press B to return"); + ret = domenu (&items[0], count, 0); + switch (ret) + { + case -1: /*** Button B ***/ + ret = 0; + quit = 1; + break; - menu = prevmenu; - return 0; + case 0: /*** SRAM Manager ***/ + case 1: /*** SaveState Manager ***/ + if (loadsavemenu(ret)) return 1; + break; + } + } + + menu = prevmenu; + return 0; } @@ -893,60 +895,40 @@ static u8 dvd_on = 0; int loadmenu () { - int prevmenu = menu; + int prevmenu = menu; int ret; - int quit = 0; + int quit = 0; #ifdef HW_RVL int count = 4 + dvd_on; char item[5][25] = { {"Load Recent"}, - {"Load from SD"}, - {"Load from USB"}, + {"Load from SD"}, + {"Load from USB"}, {"Load from DVD"}, {"Stop DVD Motor"} - }; + }; #else int count = 3 + dvd_on; char item[4][25] = { {"Load Recent"}, - {"Load from SD"}, + {"Load from SD"}, {"Load from DVD"}, {"Stop DVD Motor"} - }; + }; #endif - menu = load_menu; - - while (quit == 0) - { - strcpy (menutitle, "Press B to return"); - ret = domenu (&item[0], count, 0); - switch (ret) - { - /*** Button B ***/ + menu = load_menu; + + while (quit == 0) + { + strcpy (menutitle, "Press B to return"); + ret = domenu (&item[0], count, 0); + switch (ret) + { + /*** Button B ***/ case -1: - quit = 1; - break; - - /*** Load Recent ***/ - case 0: - load_menu = menu; - if (OpenHistory()) return 1; - break; - - /*** Load from SD ***/ - case 1: - load_menu = menu; - if (OpenFAT("") > 0) return 1; - break; - -#ifdef HW_RVL - /*** Load from USB ***/ - case 2: - load_menu = menu; - if (OpenFAT("usb:") > 0) return 1; + quit = 1; break; -#endif /*** Load from DVD ***/ #ifdef HW_RVL @@ -954,8 +936,8 @@ int loadmenu () #else case 2: #endif - load_menu = menu; - if (OpenDVD()) + load_menu = menu; + if (DVD_Open()) { dvd_on = 1; return 1; @@ -975,10 +957,17 @@ int loadmenu () #else count = 3 + dvd_on; #endif - menu = load_menu; + menu = load_menu; break; + + /*** Load from FAT device ***/ + default: + load_menu = menu; + if (FAT_Open(ret)) return 1; + break; + } - } + } menu = prevmenu; return 0; @@ -1008,100 +997,100 @@ void showrominfo () max = 14; for (i = 0; i < 14; i++) { - if (peripherals & (1 << i)) - { - sprintf(pName[max-14],"%s", peripheralinfo[i].pName); - max ++; - } + if (peripherals & (1 << i)) + { + sprintf(pName[max-14],"%s", peripheralinfo[i].pName); + max ++; + } } while (quit == 0) { if (redraw) { - ClearScreen (); + ClearScreen (); - ypos = 134; - WriteCentre(ypos, "ROM Header Information"); - ypos += 2*fheight; + ypos = 134; + WriteCentre(ypos, "ROM Header Information"); + ypos += 2*fheight; - for (i=0; i<8; i++) - { - switch (i+j) - { - case 0: - sprintf (msg, "Console type: %s", rominfo.consoletype); - break; - case 1: - sprintf (msg, "Copyright: %s", rominfo.copyright); - break; - case 2: - sprintf (msg, "Company: %s", companyinfo[getcompany ()].company); - break; - case 3: - sprintf (msg, "Game Domestic Name:"); - break; - case 4: - sprintf(msg, " %s",rominfo.domestic); - break; - case 5: - sprintf (msg, "Game International Name:"); - break; - case 6: - sprintf(msg, " %s",rominfo.international); - break; - case 7: - sprintf (msg, "Type - %s : %s", rominfo.ROMType, strcmp (rominfo.ROMType, "AI") ? "Game" : "Educational"); - break; - case 8: - sprintf (msg, "Product - %s", rominfo.product); - break; - case 9: - sprintf (msg, "Checksum - %04x (%04x) (%s)", rominfo.checksum, realchecksum, (rominfo.checksum == realchecksum) ? "Good" : "Bad"); - break; - case 10: - sprintf (msg, "ROM end: $%06X", rominfo.romend); - break; - case 11: - if (svp) sprintf (msg, "SVP Chip detected"); - else if (sram.custom) sprintf (msg, "EEPROM(%dK) - $%06X", ((eeprom.type.size_mask+1)* 8) /1024, (unsigned int)sram.start); - else if (sram.detected) sprintf (msg, "SRAM Start - $%06X", sram.start); - else sprintf (msg, "External RAM undetected"); - - break; - case 12: - if (sram.custom) sprintf (msg, "EEPROM(%dK) - $%06X", ((eeprom.type.size_mask+1)* 8) /1024, (unsigned int)sram.end); - else if (sram.detected) sprintf (msg, "SRAM End - $%06X", sram.end); - else if (sram.on) sprintf (msg, "Default SRAM activated "); - else sprintf (msg, "SRAM is disactivated "); - break; - case 13: - if (region_code == REGION_USA) sprintf (msg, "Region - %s (USA)", rominfo.country); - else if (region_code == REGION_EUROPE) sprintf (msg, "Region - %s (EUR)", rominfo.country); - else if (region_code == REGION_JAPAN_NTSC) sprintf (msg, "Region - %s (JAP)", rominfo.country); - else if (region_code == REGION_JAPAN_PAL) sprintf (msg, "Region - %s (JPAL)", rominfo.country); - break; - default: - sprintf (msg, "Supports - %s", pName[i+j-14]); - break; - } + for (i=0; i<8; i++) + { + switch (i+j) + { + case 0: + sprintf (msg, "Console type: %s", rominfo.consoletype); + break; + case 1: + sprintf (msg, "Copyright: %s", rominfo.copyright); + break; + case 2: + sprintf (msg, "Company: %s", companyinfo[getcompany ()].company); + break; + case 3: + sprintf (msg, "Game Domestic Name:"); + break; + case 4: + sprintf(msg, " %s",rominfo.domestic); + break; + case 5: + sprintf (msg, "Game International Name:"); + break; + case 6: + sprintf(msg, " %s",rominfo.international); + break; + case 7: + sprintf (msg, "Type - %s : %s", rominfo.ROMType, strcmp (rominfo.ROMType, "AI") ? "Game" : "Educational"); + break; + case 8: + sprintf (msg, "Product - %s", rominfo.product); + break; + case 9: + sprintf (msg, "Checksum - %04x (%04x) (%s)", rominfo.checksum, realchecksum, (rominfo.checksum == realchecksum) ? "Good" : "Bad"); + break; + case 10: + sprintf (msg, "ROM end: $%06X", rominfo.romend); + break; + case 11: + if (svp) sprintf (msg, "SVP Chip detected"); + else if (sram.custom) sprintf (msg, "EEPROM(%dK) - $%06X", ((eeprom.type.size_mask+1)* 8) /1024, (unsigned int)sram.start); + else if (sram.detected) sprintf (msg, "SRAM Start - $%06X", sram.start); + else sprintf (msg, "External RAM undetected"); + + break; + case 12: + if (sram.custom) sprintf (msg, "EEPROM(%dK) - $%06X", ((eeprom.type.size_mask+1)* 8) /1024, (unsigned int)sram.end); + else if (sram.detected) sprintf (msg, "SRAM End - $%06X", sram.end); + else if (sram.on) sprintf (msg, "Default SRAM activated "); + else sprintf (msg, "SRAM is disactivated "); + break; + case 13: + if (region_code == REGION_USA) sprintf (msg, "Region - %s (USA)", rominfo.country); + else if (region_code == REGION_EUROPE) sprintf (msg, "Region - %s (EUR)", rominfo.country); + else if (region_code == REGION_JAPAN_NTSC) sprintf (msg, "Region - %s (JAP)", rominfo.country); + else if (region_code == REGION_JAPAN_PAL) sprintf (msg, "Region - %s (JPAL)", rominfo.country); + break; + default: + sprintf (msg, "Supports - %s", pName[i+j-14]); + break; + } - write_font (100, ypos, msg); - ypos += fheight; - } + write_font (100, ypos, msg); + ypos += fheight; + } - ypos += fheight; - WriteCentre (ypos, "Press A to Continue"); - SetScreen (); - } + ypos += fheight; + WriteCentre (ypos, "Press A to Continue"); + SetScreen (); + } - p = ogc_input__getMenuButtons(); - redraw = 0; + p = ogc_input__getMenuButtons(); + redraw = 0; - if ((j<(max-8)) && (p & PAD_BUTTON_DOWN)) {redraw = 1; j++;} - if ((j>0) && (p & PAD_BUTTON_UP)) {redraw = 1; j--;} - if (p & PAD_BUTTON_A) quit = 1; - if (p & PAD_BUTTON_B) quit = 1; + if ((j<(max-8)) && (p & PAD_BUTTON_DOWN)) {redraw = 1; j++;} + if ((j>0) && (p & PAD_BUTTON_UP)) {redraw = 1; j--;} + if (p & PAD_BUTTON_A) quit = 1; + if (p & PAD_BUTTON_B) quit = 1; } } @@ -1111,30 +1100,30 @@ void showrominfo () ****************************************************************************/ void MainMenu () { - menu = 0; - int ret; - int quit = 0; - uint32 crccheck; + menu = 0; + int ret; + int quit = 0; + uint32 crccheck; - int count = 8; - char items[8][25] = - { - {"Play Game"}, - {"Game Infos"}, - {"Hard Reset"}, - {"Load New Game"}, - {"File Management"}, - {"Emulator Options"}, - {"Return to Loader"}, - {"System Reboot"} - }; + int count = 8; + char items[8][25] = + { + {"Play Game"}, + {"Game Infos"}, + {"Hard Reset"}, + {"Load New Game"}, + {"File Management"}, + {"Emulator Options"}, + {"Return to Loader"}, + {"System Reboot"} + }; - /* Switch to menu default rendering mode (60hz or 50hz, but always 480 lines) */ - VIDEO_Configure (vmode); - VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); - VIDEO_Flush(); - VIDEO_WaitVSync(); - VIDEO_WaitVSync(); + /* Switch to menu default rendering mode (60hz or 50hz, but always 480 lines) */ + VIDEO_Configure (vmode); + VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); + VIDEO_Flush(); + VIDEO_WaitVSync(); + VIDEO_WaitVSync(); /* autosave (SRAM only) */ int temp = config.freeze_auto; @@ -1142,45 +1131,45 @@ void MainMenu () memfile_autosave(); config.freeze_auto = temp; - while (quit == 0) - { + while (quit == 0) + { crccheck = crc32 (0, &sram.sram[0], 0x10000); if (genromsize && (crccheck != sram.crc)) strcpy (menutitle, "*** SRAM has been modified ***"); else sprintf(menutitle, "%d FPS", FramesPerSecond); - ret = domenu (&items[0], count, 0); - switch (ret) - { - case -1: /*** Button B ***/ - case 0: /*** Play Game ***/ - if (genromsize) quit = 1; - break; + ret = domenu (&items[0], count, 0); + switch (ret) + { + case -1: /*** Button B ***/ + case 0: /*** Play Game ***/ + if (genromsize) quit = 1; + break; - case 1: /*** ROM Information ***/ - showrominfo (); - break; + case 1: /*** ROM Information ***/ + showrominfo (); + break; - case 2: /*** Emulator Reset ***/ - if (genromsize || (config.bios_enabled == 3)) - { - system_reset (); - quit = 1; - } - break; + case 2: /*** Emulator Reset ***/ + if (genromsize || (config.bios_enabled == 3)) + { + system_reset (); + quit = 1; + } + break; - case 3: /*** Load ROM Menu ***/ - quit = loadmenu(); - break; + case 3: /*** Load ROM Menu ***/ + quit = loadmenu(); + break; - case 4: /*** Memory Manager ***/ - quit = filemenu (); - break; + case 4: /*** Memory Manager ***/ + quit = filemenu (); + break; - case 5: /*** Emulator Options */ - optionmenu (); - break; + case 5: /*** Emulator Options */ + optionmenu (); + break; - case 6: /*** SD/PSO/TP Reload ***/ + case 6: /*** SD/PSO/TP Reload ***/ memfile_autosave(); system_shutdown(); audio_shutdown(); @@ -1193,7 +1182,7 @@ void MainMenu () exit(0); break; - case 7: /*** Return to Wii System Menu ***/ + case 7: /*** Return to Wii System Menu ***/ memfile_autosave(); system_shutdown(); audio_shutdown(); @@ -1202,26 +1191,26 @@ void MainMenu () VIDEO_WaitVSync(); #ifdef HW_RVL DI_Close(); - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); #else - SYS_ResetSystem(SYS_HOTRESET,0,0); + SYS_ResetSystem(SYS_HOTRESET,0,0); #endif - break; - } - } + break; + } + } - /*** Remove any still held buttons ***/ + /*** Remove any still held buttons ***/ while (PAD_ButtonsHeld(0)) PAD_ScanPads(); #ifdef HW_RVL while (WPAD_ButtonsHeld(0)) WPAD_ScanPads(); #endif - /*** Reinitialize GX ***/ + /*** Reinitialize GX ***/ ogc_video__reset(); odd_frame = 1; #ifndef HW_RVL - /*** Stop the DVD from causing clicks while playing ***/ - uselessinquiry (); + /*** Stop the DVD from causing clicks while playing ***/ + uselessinquiry (); #endif } diff --git a/source/ngc/history.c b/source/ngc/history.c index 5a54f32..b240781 100644 --- a/source/ngc/history.c +++ b/source/ngc/history.c @@ -8,22 +8,25 @@ */ #include "shared.h" -#include "font.h" #include "history.h" t_history history; void history_save() { - if (!use_FAT) return; + char pathname[MAXPATHLEN]; + + if (!fat_enabled) return; /* first check if directory exist */ - DIR_ITER *dir = diropen("/genplus"); - if (dir == NULL) mkdir("/genplus",S_IRWXU); + sprintf (pathname, DEFAULT_PATH); + DIR_ITER *dir = diropen(pathname); + if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); /* open file for writing */ - FILE *fp = fopen("/genplus/romhistory.ini", "wb"); + sprintf (pathname, "%s/history.ini", pathname); + FILE *fp = fopen(pathname, "wb"); if (fp == NULL) return; /* save options */ @@ -42,46 +45,49 @@ void history_save() ****************************************************************************/ void history_add_file(char *filepath, char *filename) { - /* Create the new entry for this path. */ - t_history_entry newentry; - strncpy(newentry.filepath, filepath, MAXJOLIET - 1); - strncpy(newentry.filename, filename, MAXJOLIET - 1); - newentry.filepath[MAXJOLIET - 1] = '\0'; - newentry.filename[MAXJOLIET - 1] = '\0'; - - t_history_entry oldentry; /* Old entry is the one being shuffled down a spot. */ - t_history_entry currentry; /* Curr entry is the one that just replaced old path. */ - - /* Initially set curr entry to the new value. */ - memcpy(¤try, &newentry, sizeof(t_history_entry)); + /* Create the new entry for this path. */ + t_history_entry newentry; + strncpy(newentry.filepath, filepath, MAXJOLIET - 1); + strncpy(newentry.filename, filename, MAXJOLIET - 1); + newentry.filepath[MAXJOLIET - 1] = '\0'; + newentry.filename[MAXJOLIET - 1] = '\0'; + + t_history_entry oldentry; /* Old entry is the one being shuffled down a spot. */ + t_history_entry currentry; /* Curr entry is the one that just replaced old path. */ + + /* Initially set curr entry to the new value. */ + memcpy(¤try, &newentry, sizeof(t_history_entry)); - int i; - for(i=0; i < NUM_HISTORY_ENTRIES; i++) - { - /* Save off the next entry. */ - memcpy(&oldentry, &history.entries[i], sizeof(t_history_entry)); - - /* Overwrite with the previous entry. */ - memcpy(&history.entries[i], ¤try, sizeof(t_history_entry)); - - /* Switch the old entry to the curr entry now. */ - memcpy(¤try, &oldentry, sizeof(t_history_entry)); - - /* If the entry in the list at this spot matches - the new entry then do nothing and let this - entry get deleted. */ - if(strcmp(newentry.filepath, currentry.filepath) == 0 && strcmp(newentry.filename, currentry.filename) == 0) - break; - } + int i; + for(i=0; i < NUM_HISTORY_ENTRIES; i++) + { + /* Save off the next entry. */ + memcpy(&oldentry, &history.entries[i], sizeof(t_history_entry)); - /* now save to disk */ - history_save(); + /* Overwrite with the previous entry. */ + memcpy(&history.entries[i], ¤try, sizeof(t_history_entry)); + + /* Switch the old entry to the curr entry now. */ + memcpy(¤try, &oldentry, sizeof(t_history_entry)); + + /* If the entry in the list at this spot matches + the new entry then do nothing and let this + entry get deleted. */ + if(strcmp(newentry.filepath, currentry.filepath) == 0 && strcmp(newentry.filename, currentry.filename) == 0) + break; + } + + /* now save to disk */ + history_save(); } void history_load() { + char pathname[MAXPATHLEN]; + /* open file for reading */ - FILE *fp = fopen("/genplus/romhistory.ini", "rb"); + sprintf (pathname, "%s/history.ini", DEFAULT_PATH); + FILE *fp = fopen(pathname, "rb"); if (fp == NULL) return; /* read file */ @@ -92,11 +98,11 @@ void history_load() void set_history_defaults(void) { - int i; - for(i=0; i < NUM_HISTORY_ENTRIES; i++) - { - memset(&history.entries[i], 0, sizeof(t_history_entry)); - } + int i; + for(i=0; i < NUM_HISTORY_ENTRIES; i++) + { + memset(&history.entries[i], 0, sizeof(t_history_entry)); + } } diff --git a/source/ngc/history.h b/source/ngc/history.h index 62ba94c..4bc275c 100644 --- a/source/ngc/history.h +++ b/source/ngc/history.h @@ -5,20 +5,19 @@ * Created by Martin Disibio on 6/17/08. * */ - #ifndef _HISTORY_H - #define _HISTORY_H - - #include "types.h" - #include "iso9660.h" - - - /**************************************************************************** +#ifndef _HISTORY_H +#define _HISTORY_H + + +#include "types.h" +#include "filesel.h" + +#define NUM_HISTORY_ENTRIES (10) + +/**************************************************************************** * ROM Play History * ****************************************************************************/ - #define NUM_HISTORY_ENTRIES (10) - - typedef struct { char filepath[MAXJOLIET]; @@ -27,14 +26,12 @@ typedef struct typedef struct { - t_history_entry entries[NUM_HISTORY_ENTRIES]; + t_history_entry entries[NUM_HISTORY_ENTRIES]; } t_history; extern t_history history; extern void history_add_file(char *filepath, char *filename); extern void history_load(); extern void set_history_defaults(); - - - #endif +#endif diff --git a/source/ngc/memfile.c b/source/ngc/memfile.c index c547577..6d1aacd 100644 --- a/source/ngc/memfile.c +++ b/source/ngc/memfile.c @@ -6,6 +6,7 @@ #include "shared.h" #include "font.h" #include "saveicon.h" + #ifndef HW_RVL #include "dvd.h" #endif @@ -29,8 +30,8 @@ static card_stat CardStatus; */ static u8 savebuffer[0x26000] ATTRIBUTE_ALIGN (32); -int ManageSRAM (u8 direction, u8 device); -int ManageState (u8 direction, u8 device); +int ManageSRAM(u8 direction, u8 device); +int ManageState(u8 direction, u8 device); /**************************************************************************** * FILE autoload (SRAM/FreezeState or Config File) @@ -39,7 +40,7 @@ int ManageState (u8 direction, u8 device); *****************************************************************************/ void memfile_autoload() { - /* this should be transparent to the user */ + /* this should be transparent to the user */ SILENT = 1; /* SRAM */ @@ -50,7 +51,7 @@ void memfile_autoload() if (config.freeze_auto != -1) ManageState(1,config.freeze_auto); - SILENT = 0; + SILENT = 0; } void memfile_autosave() @@ -85,15 +86,17 @@ static int SD_ManageFile(char *filename, int direction, int filetype) int done = 0; int filesize; - if (!use_FAT) return 0; + if (!fat_enabled) return 0; /* first check if directory exist */ - DIR_ITER *dir = diropen("/genplus/saves"); - if (dir == NULL) mkdir("/genplus/saves",S_IRWXU); + sprintf (pathname, "%s/saves", DEFAULT_PATH); + + DIR_ITER *dir = diropen(pathname); + if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); /* build complete SDCARD filename */ - sprintf (pathname, "/genplus/saves/%s", filename); + sprintf (pathname, "%s/%s", pathname, filename); /* open file */ FILE *fp = fopen(pathname, direction ? "rb" : "wb"); @@ -104,17 +107,17 @@ static int SD_ManageFile(char *filename, int direction, int filetype) return 0; } - switch (direction) - { - case 0: /* SAVING */ + switch (direction) + { + case 0: /* SAVING */ - if (filetype) /* SRAM */ - { - memcpy(savebuffer, sram.sram, 0x10000); - sram.crc = crc32 (0, sram.sram, 0x10000); + if (filetype) /* SRAM */ + { + memcpy(savebuffer, sram.sram, 0x10000); + sram.crc = crc32 (0, sram.sram, 0x10000); filesize = 0x10000; - } - else filesize = state_save(savebuffer); /* STATE */ + } + else filesize = state_save(savebuffer); /* STATE */ /* write buffer */ done = fwrite(savebuffer, 1, filesize, fp); @@ -129,9 +132,9 @@ static int SD_ManageFile(char *filename, int direction, int filetype) sprintf (filename, "Saved %d bytes successfully", done); WaitPrompt (filename); return 1; - - case 1: /* LOADING */ - + + case 1: /* LOADING */ + /* read size */ fseek(fp , 0 , SEEK_END); filesize = ftell (fp); @@ -147,20 +150,20 @@ static int SD_ManageFile(char *filename, int direction, int filetype) } fclose(fp); - if (filetype) /* SRAM */ - { - memcpy(sram.sram, savebuffer, filesize); - sram.crc = crc32 (0, sram.sram, 0x10000); - system_reset (); - } - else state_load(savebuffer); /* STATE */ - - sprintf (filename, "Loaded %d bytes successfully", done); - WaitPrompt (filename); - return 1; - } - - return 0; + if (filetype) /* SRAM */ + { + memcpy(sram.sram, savebuffer, filesize); + sram.crc = crc32 (0, sram.sram, 0x10000); + system_reset (); + } + else state_load(savebuffer); /* STATE */ + + sprintf (filename, "Loaded %d bytes successfully", done); + WaitPrompt (filename); + return 1; + } + + return 0; } /**************************************************************************** @@ -174,21 +177,21 @@ static int SD_ManageFile(char *filename, int direction, int filetype) *****************************************************************************/ int MountTheCard (u8 slot) { - int tries = 0; - int CardError; - *(unsigned long *) (0xcc006800) |= 1 << 13; /*** Disable Encryption ***/ + int tries = 0; + int CardError; + *(unsigned long *) (0xcc006800) |= 1 << 13; /*** Disable Encryption ***/ #ifndef HW_RVL - uselessinquiry (); + uselessinquiry (); #endif while (tries < 10) { VIDEO_WaitVSync (); - CardError = CARD_Mount (slot, SysArea, NULL); /*** Don't need or want a callback ***/ - if (CardError == 0) return 1; - else EXI_ProbeReset (); - tries++; - } - return 0; + CardError = CARD_Mount (slot, SysArea, NULL); /*** Don't need or want a callback ***/ + if (CardError == 0) return 1; + else EXI_ProbeReset (); + tries++; + } + return 0; } /**************************************************************************** @@ -199,13 +202,13 @@ int MountTheCard (u8 slot) ****************************************************************************/ int CardFileExists (char *filename, u8 slot) { - int CardError = CARD_FindFirst (slot, &CardDir, TRUE); - while (CardError != CARD_ERROR_NOFILE) - { - CardError = CARD_FindNext (&CardDir); - if (strcmp ((char *) CardDir.filename, filename) == 0) return 1; - } - return 0; + int CardError = CARD_FindFirst (slot, &CardDir, TRUE); + while (CardError != CARD_ERROR_NOFILE) + { + CardError = CARD_FindNext (&CardDir); + if (strcmp ((char *) CardDir.filename, filename) == 0) return 1; + } + return 0; } /**************************************************************************** @@ -221,185 +224,185 @@ int CardFileExists (char *filename, u8 slot) ****************************************************************************/ int ManageSRAM (u8 direction, u8 device) { - char filename[128]; - char action[80]; - int CardError; - unsigned int SectorSize; - int blocks; - char comment[2][32] = { {"Genesis Plus 1.2a"}, {"SRAM Save"} }; + char filename[128]; + char action[80]; + int CardError; + unsigned int SectorSize; + int blocks; + char comment[2][32] = { {"Genesis Plus 1.2a"}, {"SRAM Save"} }; int outbytes = 0; - int sbo; - unsigned long inzipped,outzipped; + int sbo; + unsigned long inzipped,outzipped; - if (!genromsize) return 0; + if (!genromsize) return 0; - /* clean buffer */ + /* clean buffer */ memset(savebuffer, 0, 0x24000); - if (direction) ShowAction ("Loading SRAM ..."); - else ShowAction ("Saving SRAM ..."); + if (direction) ShowAction ("Loading SRAM ..."); + else ShowAction ("Saving SRAM ..."); - /* First, build a filename */ - sprintf (filename, "MD-%04X.srm", realchecksum); - strcpy (comment[1], filename); + /* First, build a filename */ + sprintf (filename, "MD-%04X.srm", realchecksum); + strcpy (comment[1], filename); + + /* device is SDCARD, let's go */ + if (device == 0) return SD_ManageFile(filename,direction,1); - /* device is SDCARD, let's go */ - if (device == 0) return SD_ManageFile(filename,direction,1); - /* set MCARD slot nr. */ u8 CARDSLOT = device - 1; - /* device is MCARD, we continue */ - if (direction == 0) /*** Saving ***/ - { - /*** Build the output buffer ***/ - memcpy (&savebuffer, &icon, 2048); - memcpy (&savebuffer[2048], &comment[0], 64); + /* device is MCARD, we continue */ + if (direction == 0) /*** Saving ***/ + { + /*** Build the output buffer ***/ + memcpy (&savebuffer, &icon, 2048); + memcpy (&savebuffer[2048], &comment[0], 64); - inzipped = 0x10000; - outzipped = 0x12000; - compress2 ((Bytef *) &savebuffer[2112+sizeof(outzipped)], &outzipped, (Bytef *) &sram.sram, inzipped, 9); - memcpy(&savebuffer[2112], &outzipped, sizeof(outzipped)); - } - - outbytes = 2048 + 64 + outzipped + sizeof(outzipped); + inzipped = 0x10000; + outzipped = 0x12000; + compress2 ((Bytef *) &savebuffer[2112+sizeof(outzipped)], &outzipped, (Bytef *) &sram.sram, inzipped, 9); + memcpy(&savebuffer[2112], &outzipped, sizeof(outzipped)); + } - /*** Initialise the CARD system ***/ - memset (&SysArea, 0, CARD_WORKAREA); - CARD_Init ("GENP", "00"); + outbytes = 2048 + 64 + outzipped + sizeof(outzipped); - /*** Attempt to mount the card ***/ - CardError = MountTheCard (CARDSLOT); + /*** Initialise the CARD system ***/ + memset (&SysArea, 0, CARD_WORKAREA); + CARD_Init ("GENP", "00"); - if (CardError) - { - /*** Retrieve the sector size ***/ - CardError = CARD_GetSectorSize (CARDSLOT, &SectorSize); + /*** Attempt to mount the card ***/ + CardError = MountTheCard (CARDSLOT); - switch (direction) - { - case 0: /*** Saving ***/ - /*** Determine number of blocks on this card ***/ - blocks = (outbytes / SectorSize) * SectorSize; - if (outbytes % SectorSize) blocks += SectorSize; + if (CardError) + { + /*** Retrieve the sector size ***/ + CardError = CARD_GetSectorSize (CARDSLOT, &SectorSize); - /*** Check if a previous save exists ***/ - if (CardFileExists (filename,CARDSLOT)) - { - CardError = CARD_Open (CARDSLOT, filename, &CardFile); - if (CardError) - { - sprintf (action, "Error Open : %d", CardError); - WaitPrompt (action); - CARD_Unmount (CARDSLOT); - return 0; - } + switch (direction) + { + case 0: /*** Saving ***/ + /*** Determine number of blocks on this card ***/ + blocks = (outbytes / SectorSize) * SectorSize; + if (outbytes % SectorSize) blocks += SectorSize; - int size = CardFile.len; - CARD_Close (&CardFile); + /*** Check if a previous save exists ***/ + if (CardFileExists (filename,CARDSLOT)) + { + CardError = CARD_Open (CARDSLOT, filename, &CardFile); + if (CardError) + { + sprintf (action, "Error Open : %d", CardError); + WaitPrompt (action); + CARD_Unmount (CARDSLOT); + return 0; + } - if (size < blocks) - { - /* new size is bigger: check if there is enough space left */ - CardError = CARD_Create (CARDSLOT, "TEMP", blocks-size, &CardFile); - if (CardError) - { - sprintf (action, "Error Update : %d", CardError); - WaitPrompt (action); - CARD_Unmount (CARDSLOT); - return 0; - } - CARD_Close (&CardFile); - CARD_Delete(CARDSLOT, "TEMP"); - } + int size = CardFile.len; + CARD_Close (&CardFile); - /* always delete existing slot */ - CARD_Delete(CARDSLOT, filename); - } - - /*** Create a new slot ***/ - CardError = CARD_Create (CARDSLOT, filename, blocks, &CardFile); - if (CardError) - { - sprintf (action, "Error create : %d %d", CardError, CARDSLOT); - WaitPrompt (action); - CARD_Unmount (CARDSLOT); - return 0; - } + if (size < blocks) + { + /* new size is bigger: check if there is enough space left */ + CardError = CARD_Create (CARDSLOT, "TEMP", blocks-size, &CardFile); + if (CardError) + { + sprintf (action, "Error Update : %d", CardError); + WaitPrompt (action); + CARD_Unmount (CARDSLOT); + return 0; + } + CARD_Close (&CardFile); + CARD_Delete(CARDSLOT, "TEMP"); + } - /*** Continue and save ***/ - CARD_GetStatus (CARDSLOT, CardFile.filenum, &CardStatus); - CardStatus.icon_addr = 0x0; - CardStatus.icon_fmt = 2; - CardStatus.icon_speed = 1; - CardStatus.comment_addr = 2048; - CARD_SetStatus (CARDSLOT, CardFile.filenum, &CardStatus); + /* always delete existing slot */ + CARD_Delete(CARDSLOT, filename); + } - /*** And write the blocks out ***/ - sbo = 0; - while (outbytes > 0) - { - CardError = CARD_Write (&CardFile, &savebuffer[sbo], SectorSize, sbo); - outbytes -= SectorSize; - sbo += SectorSize; - } + /*** Create a new slot ***/ + CardError = CARD_Create (CARDSLOT, filename, blocks, &CardFile); + if (CardError) + { + sprintf (action, "Error create : %d %d", CardError, CARDSLOT); + WaitPrompt (action); + CARD_Unmount (CARDSLOT); + return 0; + } - CARD_Close (&CardFile); - CARD_Unmount (CARDSLOT); - sram.crc = crc32 (0, &sram.sram[0], 0x10000); - sprintf (action, "Saved %d bytes successfully", blocks); - WaitPrompt (action); - return 1; + /*** Continue and save ***/ + CARD_GetStatus (CARDSLOT, CardFile.filenum, &CardStatus); + CardStatus.icon_addr = 0x0; + CardStatus.icon_fmt = 2; + CardStatus.icon_speed = 1; + CardStatus.comment_addr = 2048; + CARD_SetStatus (CARDSLOT, CardFile.filenum, &CardStatus); - default: /*** Loading ***/ - if (!CardFileExists (filename,CARDSLOT)) - { - WaitPrompt ("No SRAM File Found"); - CARD_Unmount (CARDSLOT); - return 0; - } + /*** And write the blocks out ***/ + sbo = 0; + while (outbytes > 0) + { + CardError = CARD_Write (&CardFile, &savebuffer[sbo], SectorSize, sbo); + outbytes -= SectorSize; + sbo += SectorSize; + } - memset (&CardFile, 0, sizeof (CardFile)); - CardError = CARD_Open (CARDSLOT, filename, &CardFile); - if (CardError) - { - sprintf (action, "Error Open : %d", CardError); - WaitPrompt (action); - CARD_Unmount (CARDSLOT); - return 0; - } + CARD_Close (&CardFile); + CARD_Unmount (CARDSLOT); + sram.crc = crc32 (0, &sram.sram[0], 0x10000); + sprintf (action, "Saved %d bytes successfully", blocks); + WaitPrompt (action); + return 1; - blocks = CardFile.len; - if (blocks < SectorSize) blocks = SectorSize; - if (blocks % SectorSize) blocks++; + default: /*** Loading ***/ + if (!CardFileExists (filename,CARDSLOT)) + { + WaitPrompt ("No SRAM File Found"); + CARD_Unmount (CARDSLOT); + return 0; + } - /*** Just read the file back in ***/ - sbo = 0; - int size = blocks; - while (blocks > 0) - { - CARD_Read (&CardFile, &savebuffer[sbo], SectorSize, sbo); - sbo += SectorSize; - blocks -= SectorSize; - } - CARD_Close (&CardFile); - CARD_Unmount (CARDSLOT); + memset (&CardFile, 0, sizeof (CardFile)); + CardError = CARD_Open (CARDSLOT, filename, &CardFile); + if (CardError) + { + sprintf (action, "Error Open : %d", CardError); + WaitPrompt (action); + CARD_Unmount (CARDSLOT); + return 0; + } - /* Copy to SRAM */ - memcpy(&inzipped,&savebuffer[2112],sizeof(inzipped)); - outzipped = 0x10000; - uncompress ((Bytef *) &sram.sram, &outzipped, (Bytef *) &savebuffer[2112+sizeof(inzipped)], inzipped); - sram.crc = crc32 (0, &sram.sram[0], 0x10000); - system_reset (); + blocks = CardFile.len; + if (blocks < SectorSize) blocks = SectorSize; + if (blocks % SectorSize) blocks++; - /*** Inform user ***/ - sprintf (action, "Loaded %d bytes successfully", size); - WaitPrompt (action); - return 1; - } - } - else WaitPrompt ("Unable to mount memory card"); - return 0; /*** Signal failure ***/ + /*** Just read the file back in ***/ + sbo = 0; + int size = blocks; + while (blocks > 0) + { + CARD_Read (&CardFile, &savebuffer[sbo], SectorSize, sbo); + sbo += SectorSize; + blocks -= SectorSize; + } + CARD_Close (&CardFile); + CARD_Unmount (CARDSLOT); + + /* Copy to SRAM */ + memcpy(&inzipped,&savebuffer[2112],sizeof(inzipped)); + outzipped = 0x10000; + uncompress ((Bytef *) &sram.sram, &outzipped, (Bytef *) &savebuffer[2112+sizeof(inzipped)], inzipped); + sram.crc = crc32 (0, &sram.sram[0], 0x10000); + system_reset (); + + /*** Inform user ***/ + sprintf (action, "Loaded %d bytes successfully", size); + WaitPrompt (action); + return 1; + } + } + else WaitPrompt ("Unable to mount memory card"); + return 0; /*** Signal failure ***/ } /**************************************************************************** @@ -412,174 +415,174 @@ int ManageSRAM (u8 direction, u8 device) ****************************************************************************/ int ManageState (u8 direction, u8 device) { - char filename[128]; - char action[80]; - int CardError; - unsigned int SectorSize; - int blocks; - char comment[2][32] = { {"Genesis Plus 1.2a [FRZ]"}, {"Freeze State"} }; - int outbytes = 0; - int sbo; - int state_size = 0; + char filename[128]; + char action[80]; + int CardError; + unsigned int SectorSize; + int blocks; + char comment[2][32] = { {"Genesis Plus 1.2a [FRZ]"}, {"Freeze State"} }; + int outbytes = 0; + int sbo; + int state_size = 0; - if (!genromsize) return 0; + if (!genromsize) return 0; - /* clean buffer */ - memset(savebuffer, 0, 0x24000); + /* clean buffer */ + memset(savebuffer, 0, 0x24000); if (direction) ShowAction ("Loading State ..."); - else ShowAction ("Saving State ..."); + else ShowAction ("Saving State ..."); - /* First, build a filename */ - sprintf (filename, "MD-%04X.gpz", realchecksum); - strcpy (comment[1], filename); + /* First, build a filename */ + sprintf (filename, "MD-%04X.gpz", realchecksum); + strcpy (comment[1], filename); - /* device is SDCARD, let's go */ - if (device == 0) return SD_ManageFile(filename,direction,0); + /* device is SDCARD, let's go */ + if (device == 0) return SD_ManageFile(filename,direction,0); /* set MCARD slot nr. */ u8 CARDSLOT = device - 1; - /* device is MCARD, we continue */ - if (direction == 0) /* Saving */ - { - /* Build the output buffer */ - memcpy (&savebuffer, &icon, 2048); - memcpy (&savebuffer[2048], &comment[0], 64); - state_size = state_save(&savebuffer[2112]); - } + /* device is MCARD, we continue */ + if (direction == 0) /* Saving */ + { + /* Build the output buffer */ + memcpy (&savebuffer, &icon, 2048); + memcpy (&savebuffer[2048], &comment[0], 64); + state_size = state_save(&savebuffer[2112]); + } - outbytes = 2048 + 64 + state_size; + outbytes = 2048 + 64 + state_size; - /*** Initialise the CARD system ***/ - memset (&SysArea, 0, CARD_WORKAREA); - CARD_Init ("GENP", "00"); + /*** Initialise the CARD system ***/ + memset (&SysArea, 0, CARD_WORKAREA); + CARD_Init ("GENP", "00"); - /*** Attempt to mount the card ***/ - CardError = MountTheCard (CARDSLOT); + /*** Attempt to mount the card ***/ + CardError = MountTheCard (CARDSLOT); - if (CardError) - { - /*** Retrieve the sector size ***/ - CardError = CARD_GetSectorSize (CARDSLOT, &SectorSize); + if (CardError) + { + /*** Retrieve the sector size ***/ + CardError = CARD_GetSectorSize (CARDSLOT, &SectorSize); - switch (direction) - { - case 0: /*** Saving ***/ - /*** Determine number of blocks on this card ***/ - blocks = (outbytes / SectorSize) * SectorSize; - if (outbytes % SectorSize) blocks += SectorSize; + switch (direction) + { + case 0: /*** Saving ***/ + /*** Determine number of blocks on this card ***/ + blocks = (outbytes / SectorSize) * SectorSize; + if (outbytes % SectorSize) blocks += SectorSize; - /*** Check if a previous save exists ***/ - if (CardFileExists (filename, CARDSLOT)) - { - CardError = CARD_Open (CARDSLOT, filename, &CardFile); - if (CardError) - { - sprintf (action, "Error Open : %d", CardError); - WaitPrompt (action); - CARD_Unmount (CARDSLOT); - return 0; - } + /*** Check if a previous save exists ***/ + if (CardFileExists (filename, CARDSLOT)) + { + CardError = CARD_Open (CARDSLOT, filename, &CardFile); + if (CardError) + { + sprintf (action, "Error Open : %d", CardError); + WaitPrompt (action); + CARD_Unmount (CARDSLOT); + return 0; + } - int size = CardFile.len; - CARD_Close (&CardFile); + int size = CardFile.len; + CARD_Close (&CardFile); - if (size < blocks) - { - /* new size is bigger: check if there is enough space left */ - CardError = CARD_Create (CARDSLOT, "TEMP", blocks-size, &CardFile); - if (CardError) - { - sprintf (action, "Error Update : %d", CardError); - WaitPrompt (action); - CARD_Unmount (CARDSLOT); - return 0; - } - CARD_Close (&CardFile); - CARD_Delete(CARDSLOT, "TEMP"); - } + if (size < blocks) + { + /* new size is bigger: check if there is enough space left */ + CardError = CARD_Create (CARDSLOT, "TEMP", blocks-size, &CardFile); + if (CardError) + { + sprintf (action, "Error Update : %d", CardError); + WaitPrompt (action); + CARD_Unmount (CARDSLOT); + return 0; + } + CARD_Close (&CardFile); + CARD_Delete(CARDSLOT, "TEMP"); + } - /* always delete existing slot */ - CARD_Delete(CARDSLOT, filename); - } + /* always delete existing slot */ + CARD_Delete(CARDSLOT, filename); + } - /*** Create a new slot ***/ - CardError = CARD_Create (CARDSLOT, filename, blocks, &CardFile); - if (CardError) - { - sprintf (action, "Error create : %d %d", CardError, CARDSLOT); - WaitPrompt (action); - CARD_Unmount (CARDSLOT); - return 0; - } - - /*** Continue and save ***/ - CARD_GetStatus (CARDSLOT, CardFile.filenum, &CardStatus); - CardStatus.icon_addr = 0x0; - CardStatus.icon_fmt = 2; - CardStatus.icon_speed = 1; - CardStatus.comment_addr = 2048; - CARD_SetStatus (CARDSLOT, CardFile.filenum, &CardStatus); + /*** Create a new slot ***/ + CardError = CARD_Create (CARDSLOT, filename, blocks, &CardFile); + if (CardError) + { + sprintf (action, "Error create : %d %d", CardError, CARDSLOT); + WaitPrompt (action); + CARD_Unmount (CARDSLOT); + return 0; + } + + /*** Continue and save ***/ + CARD_GetStatus (CARDSLOT, CardFile.filenum, &CardStatus); + CardStatus.icon_addr = 0x0; + CardStatus.icon_fmt = 2; + CardStatus.icon_speed = 1; + CardStatus.comment_addr = 2048; + CARD_SetStatus (CARDSLOT, CardFile.filenum, &CardStatus); - /*** And write the blocks out ***/ - sbo = 0; - while (outbytes > 0) - { - CardError = CARD_Write (&CardFile, &savebuffer[sbo], SectorSize, sbo); - outbytes -= SectorSize; - sbo += SectorSize; - } + /*** And write the blocks out ***/ + sbo = 0; + while (outbytes > 0) + { + CardError = CARD_Write (&CardFile, &savebuffer[sbo], SectorSize, sbo); + outbytes -= SectorSize; + sbo += SectorSize; + } - CARD_Close (&CardFile); - CARD_Unmount (CARDSLOT); - sprintf (action, "Saved %d bytes successfully", blocks); - WaitPrompt (action); - return 1; + CARD_Close (&CardFile); + CARD_Unmount (CARDSLOT); + sprintf (action, "Saved %d bytes successfully", blocks); + WaitPrompt (action); + return 1; - default: /*** Loading ***/ - if (!CardFileExists (filename, CARDSLOT)) - { - WaitPrompt ("No Savestate Found"); - CARD_Unmount (CARDSLOT); - return 0; - } + default: /*** Loading ***/ + if (!CardFileExists (filename, CARDSLOT)) + { + WaitPrompt ("No Savestate Found"); + CARD_Unmount (CARDSLOT); + return 0; + } - memset (&CardFile, 0, sizeof (CardFile)); - CardError = CARD_Open (CARDSLOT, filename, &CardFile); - if (CardError) - { - sprintf (action, "Error Open : %d", CardError); - WaitPrompt (action); - CARD_Unmount (CARDSLOT); - return 0; - } + memset (&CardFile, 0, sizeof (CardFile)); + CardError = CARD_Open (CARDSLOT, filename, &CardFile); + if (CardError) + { + sprintf (action, "Error Open : %d", CardError); + WaitPrompt (action); + CARD_Unmount (CARDSLOT); + return 0; + } - blocks = CardFile.len; - if (blocks < SectorSize) blocks = SectorSize; - if (blocks % SectorSize) blocks++; + blocks = CardFile.len; + if (blocks < SectorSize) blocks = SectorSize; + if (blocks % SectorSize) blocks++; - /*** Just read the file back in ***/ - sbo = 0; - int size = blocks; - while (blocks > 0) - { - CARD_Read (&CardFile, &savebuffer[sbo], SectorSize, sbo); - sbo += SectorSize; - blocks -= SectorSize; - } - CARD_Close (&CardFile); - CARD_Unmount (CARDSLOT); + /*** Just read the file back in ***/ + sbo = 0; + int size = blocks; + while (blocks > 0) + { + CARD_Read (&CardFile, &savebuffer[sbo], SectorSize, sbo); + sbo += SectorSize; + blocks -= SectorSize; + } + CARD_Close (&CardFile); + CARD_Unmount (CARDSLOT); - /*** Load State ***/ - state_load(&savebuffer[2112]); + /*** Load State ***/ + state_load(&savebuffer[2112]); - /*** Inform user ***/ - sprintf (action, "Loaded %d bytes successfully", size); - WaitPrompt (action); - return 1; - } - } - else WaitPrompt ("Unable to mount memory card"); - return 0; /*** Signal failure ***/ + /*** Inform user ***/ + sprintf (action, "Loaded %d bytes successfully", size); + WaitPrompt (action); + return 1; + } + } + else WaitPrompt ("Unable to mount memory card"); + return 0; /*** Signal failure ***/ } diff --git a/source/ngc/ngc.c b/source/ngc/ngc.c index 860be48..044a448 100644 --- a/source/ngc/ngc.c +++ b/source/ngc/ngc.c @@ -28,6 +28,8 @@ #include #endif +#include + int Shutdown = 0; #ifdef HW_RVL @@ -46,11 +48,14 @@ void Power_Off(void) ***************************************************************************/ static void load_bios() { + char pathname[MAXPATHLEN]; + /* reset BIOS found flag */ config.bios_enabled &= ~2; /* open file */ - FILE *fp = fopen("/genplus/BIOS.bin", "rb"); + sprintf (pathname, "%s/BIOS.bin", DEFAULT_PATH); + FILE *fp = fopen(pathname, "rb"); if (fp == NULL) return; /* read file */ @@ -113,12 +118,12 @@ void reloadrom () ***************************************************************************/ int FramesPerSecond = 0; int frameticker = 0; -bool use_FAT = 0; +bool fat_enabled = 0; int main (int argc, char *argv[]) { #ifdef HW_RVL - /* initialize Wii DVD interface first */ + /* initialize Wii DVD interface first */ DI_Close(); DI_Init(); #endif @@ -127,7 +132,7 @@ int main (int argc, char *argv[]) long long now, prev; int RenderedFrameCount = 0; int FrameCount = 0; - + /* Initialize OGC subsystems */ ogc_video__init(); ogc_input__init(); @@ -147,7 +152,7 @@ int main (int argc, char *argv[]) /* Initialize FAT Interface */ if (fatInitDefault() == true) { - use_FAT = 1; + fat_enabled = 1; } /* Default Config */ @@ -172,11 +177,11 @@ int main (int argc, char *argv[]) legal(); MainMenu(); ConfigRequested = 0; - + /* Initialize Frame timings */ frameticker = 0; prev = gettime(); - + /* Emulation Loop */ while (1) { @@ -202,7 +207,7 @@ int main (int argc, char *argv[]) system_frame(0); RenderedFrameCount++; } - } + } else { /* use VSync */ @@ -223,11 +228,11 @@ int main (int argc, char *argv[]) frameticker--; } - + /* update video & audio */ ogc_video__update(); ogc_audio__update(); - + /* Check rendered frames (FPS) */ FrameCount++; if (FrameCount == vdp_rate) @@ -236,17 +241,17 @@ int main (int argc, char *argv[]) RenderedFrameCount = 0; FrameCount = 0; } - + /* Check for Menu request */ if (ConfigRequested) { /* reset AUDIO */ ogc_audio__reset(); - + /* go to menu */ MainMenu (); ConfigRequested = 0; - + /* reset frame timings */ frameticker = 0; prev = gettime(); diff --git a/source/ngc/ogc_audio.c b/source/ngc/ogc_audio.c index d0b7368..a85d9b2 100644 --- a/source/ngc/ogc_audio.c +++ b/source/ngc/ogc_audio.c @@ -24,7 +24,7 @@ /* global datas */ unsigned char soundbuffer[16][3840] ATTRIBUTE_ALIGN(32); -int mixbuffer = 0; +int mixbuffer = 0; static int playbuffer = 0; static int IsPlaying = 0; @@ -42,14 +42,14 @@ static void AudioSwitchBuffers() IsPlaying = 0; return; } - + u32 dma_len = (vdp_pal) ? 3840 : 3200; /* restart audio DMA with current soundbuffer */ AUDIO_InitDMA((u32) soundbuffer[playbuffer], dma_len); DCFlushRange(soundbuffer[playbuffer], dma_len); AUDIO_StartDMA(); - + /* increment soundbuffers index */ if (playbuffer == mixbuffer) { @@ -65,10 +65,10 @@ static void AudioSwitchBuffers() void ogc_audio__init(void) { - AUDIO_Init (NULL); - AUDIO_SetDSPSampleRate (AI_SAMPLERATE_48KHZ); - AUDIO_RegisterDMACallback (AudioSwitchBuffers); - memset(soundbuffer, 0, 16 * 3840); + AUDIO_Init (NULL); + AUDIO_SetDSPSampleRate (AI_SAMPLERATE_48KHZ); + AUDIO_RegisterDMACallback (AudioSwitchBuffers); + memset(soundbuffer, 0, 16 * 3840); } void ogc_audio__reset(void) diff --git a/source/ngc/ogc_input.c b/source/ngc/ogc_input.c index e13bfa9..b016a0d 100644 --- a/source/ngc/ogc_input.c +++ b/source/ngc/ogc_input.c @@ -77,9 +77,9 @@ static int held_cnt = 0; static u32 wpad_dirmap[3][4] = { - {WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, // WIIMOTE only - {WPAD_BUTTON_UP, WPAD_BUTTON_DOWN, WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT}, // WIIMOTE + NUNCHUK - {WPAD_CLASSIC_BUTTON_UP, WPAD_CLASSIC_BUTTON_DOWN, WPAD_CLASSIC_BUTTON_LEFT, WPAD_CLASSIC_BUTTON_RIGHT} // CLASSIC + {WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, /* WIIMOTE only */ + {WPAD_BUTTON_UP, WPAD_BUTTON_DOWN, WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT}, /* WIIMOTE + NUNCHUK */ + {WPAD_CLASSIC_BUTTON_UP, WPAD_CLASSIC_BUTTON_DOWN, WPAD_CLASSIC_BUTTON_LEFT, WPAD_CLASSIC_BUTTON_RIGHT} /* CLASSIC */ }; /* wiimote/expansion available buttons */ @@ -581,7 +581,7 @@ void ogc_input__init(void) #ifdef HW_RVL WPAD_Init(); - WPAD_SetIdleTimeout(60); + WPAD_SetIdleTimeout(60); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL,640,480); #endif @@ -763,7 +763,7 @@ u16 ogc_input__getMenuButtons(void) s8 y = PAD_StickY(0); if (x > 70) p |= PAD_BUTTON_RIGHT; else if (x < -70) p |= PAD_BUTTON_LEFT; - if (y > 60) p |= PAD_BUTTON_UP; + if (y > 60) p |= PAD_BUTTON_UP; else if (y < -60) p |= PAD_BUTTON_DOWN; #ifdef HW_RVL @@ -853,7 +853,7 @@ u16 ogc_input__getMenuButtons(void) if (q & WPAD_CLASSIC_BUTTON_B) p |= PAD_BUTTON_B; if (q & WPAD_CLASSIC_BUTTON_HOME) p |= PAD_TRIGGER_Z; - #endif +#endif return p; } diff --git a/source/ngc/ogc_video.c b/source/ngc/ogc_video.c index a57f7b3..7563031 100644 --- a/source/ngc/ogc_video.c +++ b/source/ngc/ogc_video.c @@ -35,10 +35,10 @@ sms_ntsc_t sms_ntsc; int gc_pal = 0; /*** VI ***/ -unsigned int *xfb[2]; /*** Double buffered ***/ -int whichfb = 0; /*** External framebuffer index ***/ -GXRModeObj *vmode; /*** Menu video mode ***/ -u8 *texturemem; /*** Texture Data ***/ +unsigned int *xfb[2]; /*** Double buffered ***/ +int whichfb = 0; /*** External framebuffer index ***/ +GXRModeObj *vmode; /*** Menu video mode ***/ +u8 *texturemem; /*** Texture Data ***/ /*** GX ***/ #define TEX_WIDTH 360 * 2 @@ -57,12 +57,12 @@ static u32 vwidth, vheight; /* 288 lines progressive (PAL 50Hz) */ GXRModeObj TV50hz_288p = { - VI_TVMODE_PAL_DS, // viDisplayMode + VI_TVMODE_PAL_DS,// viDisplayMode 640, // fbWidth 286, // efbHeight 286, // xfbHeight - (VI_MAX_WIDTH_PAL - 720)/2, // viXOrigin - (VI_MAX_HEIGHT_PAL/2 - 572/2)/2, // viYOrigin + (VI_MAX_WIDTH_PAL - 720)/2, // viXOrigin + (VI_MAX_HEIGHT_PAL/2 - 572/2)/2,// viYOrigin 720, // viWidth 572, // viHeight VI_XFBMODE_SF, // xFBmode @@ -70,34 +70,34 @@ GXRModeObj TV50hz_288p = GX_FALSE, // aa // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, + { + {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each + {6,6},{6,6},{6,6}, // pix 1 + {6,6},{6,6},{6,6}, // pix 2 + {6,6},{6,6},{6,6} // pix 3 + }, // vertical filter[7], 1/64 units, 6 bits each - { - 0, // line n-1 - 0, // line n-1 - 21, // line n - 22, // line n - 21, // line n - 0, // line n+1 - 0 // line n+1 - } + { + 0, // line n-1 + 0, // line n-1 + 21, // line n + 22, // line n + 21, // line n + 0, // line n+1 + 0 // line n+1 + } }; /* 288 lines interlaced (PAL 50Hz) */ GXRModeObj TV50hz_288i = { - VI_TVMODE_PAL_INT, // viDisplayMode - 640, // fbWidth - 286, // efbHeight - 286, // xfbHeight - (VI_MAX_WIDTH_PAL - 720)/2, // viXOrigin - (VI_MAX_HEIGHT_PAL/2 - 572/2)/2, // viYOrigin + VI_TVMODE_PAL_INT,// viDisplayMode + 640, // fbWidth + 286, // efbHeight + 286, // xfbHeight + (VI_MAX_WIDTH_PAL - 720)/2, // viXOrigin + (VI_MAX_HEIGHT_PAL/2 - 572/2)/2,// viYOrigin 720, // viWidth 572, // viHeight VI_XFBMODE_SF, // xFBmode @@ -105,34 +105,34 @@ GXRModeObj TV50hz_288i = GX_FALSE, // aa // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, + { + {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each + {6,6},{6,6},{6,6}, // pix 1 + {6,6},{6,6},{6,6}, // pix 2 + {6,6},{6,6},{6,6} // pix 3 + }, // vertical filter[7], 1/64 units, 6 bits each - { - 0, // line n-1 - 0, // line n-1 - 21, // line n - 22, // line n - 21, // line n - 0, // line n+1 - 0 // line n+1 - } + { + 0, // line n-1 + 0, // line n-1 + 21, // line n + 22, // line n + 21, // line n + 0, // line n+1 + 0 // line n+1 + } }; /* 576 lines interlaced (PAL 50Hz, scaled) */ GXRModeObj TV50hz_576i = { - VI_TVMODE_PAL_INT, // viDisplayMode + VI_TVMODE_PAL_INT,// viDisplayMode 640, // fbWidth 480, // efbHeight 574, // xfbHeight - (VI_MAX_WIDTH_PAL - 720)/2, // viXOrigin - (VI_MAX_HEIGHT_PAL - 574)/2, // viYOrigin + (VI_MAX_WIDTH_PAL - 720)/2, // viXOrigin + (VI_MAX_HEIGHT_PAL - 574)/2,// viYOrigin 720, // viWidth 574, // viHeight VI_XFBMODE_DF, // xFBmode @@ -140,34 +140,34 @@ GXRModeObj TV50hz_576i = GX_FALSE, // aa // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, + { + {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each + {6,6},{6,6},{6,6}, // pix 1 + {6,6},{6,6},{6,6}, // pix 2 + {6,6},{6,6},{6,6} // pix 3 + }, // vertical filter[7], 1/64 units, 6 bits each - { - 8, // line n-1 - 8, // line n-1 - 10, // line n - 12, // line n - 10, // line n - 8, // line n+1 - 8 // line n+1 - } + { + 8, // line n-1 + 8, // line n-1 + 10, // line n + 12, // line n + 10, // line n + 8, // line n+1 + 8 // line n+1 + } }; /* 240 lines progressive (NTSC or PAL 60Hz) */ GXRModeObj TV60hz_240p = { - VI_TVMODE_EURGB60_DS, // viDisplayMode + VI_TVMODE_EURGB60_DS,// viDisplayMode 640, // fbWidth 240, // efbHeight 240, // xfbHeight - (VI_MAX_WIDTH_NTSC - 720)/2, // viXOrigin - (VI_MAX_HEIGHT_NTSC/2 - 480/2)/2, // viYOrigin + (VI_MAX_WIDTH_NTSC - 720)/2, // viXOrigin + (VI_MAX_HEIGHT_NTSC/2 - 480/2)/2, // viYOrigin 720, // viWidth 480, // viHeight VI_XFBMODE_SF, // xFBmode @@ -175,34 +175,34 @@ GXRModeObj TV60hz_240p = GX_FALSE, // aa // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, + { + {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each + {6,6},{6,6},{6,6}, // pix 1 + {6,6},{6,6},{6,6}, // pix 2 + {6,6},{6,6},{6,6} // pix 3 + }, // vertical filter[7], 1/64 units, 6 bits each - { - 0, // line n-1 - 0, // line n-1 - 21, // line n - 22, // line n - 21, // line n - 0, // line n+1 - 0 // line n+1 - } + { + 0, // line n-1 + 0, // line n-1 + 21, // line n + 22, // line n + 21, // line n + 0, // line n+1 + 0 // line n+1 + } }; /* 240 lines interlaced (NTSC or PAL 60Hz) */ GXRModeObj TV60hz_240i = { - VI_TVMODE_EURGB60_INT, // viDisplayMode + VI_TVMODE_EURGB60_INT,// viDisplayMode 640, // fbWidth 240, // efbHeight 240, // xfbHeight - (VI_MAX_WIDTH_NTSC - 720)/2, // viXOrigin - (VI_MAX_HEIGHT_NTSC/2 - 480/2)/2, // viYOrigin + (VI_MAX_WIDTH_NTSC - 720)/2, // viXOrigin + (VI_MAX_HEIGHT_NTSC/2 - 480/2)/2, // viYOrigin 720, // viWidth 480, // viHeight VI_XFBMODE_SF, // xFBmode @@ -210,34 +210,34 @@ GXRModeObj TV60hz_240i = GX_FALSE, // aa // sample points arranged in increasing Y order - { - {3,2},{9,6},{3,10}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {3,2},{9,6},{3,10}, // pix 1 - {9,2},{3,6},{9,10}, // pix 2 - {9,2},{3,6},{9,10} // pix 3 - }, + { + {3,2},{9,6},{3,10}, // pix 0, 3 sample points, 1/12 units, 4 bits each + {3,2},{9,6},{3,10}, // pix 1 + {9,2},{3,6},{9,10}, // pix 2 + {9,2},{3,6},{9,10} // pix 3 + }, // vertical filter[7], 1/64 units, 6 bits each - { - 0, // line n-1 - 0, // line n-1 - 21, // line n - 22, // line n - 21, // line n - 0, // line n+1 - 0 // line n+1 - } + { + 0, // line n-1 + 0, // line n-1 + 21, // line n + 22, // line n + 21, // line n + 0, // line n+1 + 0 // line n+1 + } }; /* 480 lines interlaced (NTSC or PAL 60Hz) */ GXRModeObj TV60hz_480i = { - VI_TVMODE_EURGB60_INT, // viDisplayMode + VI_TVMODE_EURGB60_INT,// viDisplayMode 640, // fbWidth 480, // efbHeight 480, // xfbHeight - (VI_MAX_WIDTH_NTSC - 720)/2, // viXOrigin - (VI_MAX_HEIGHT_NTSC - 480)/2, // viYOrigin + (VI_MAX_WIDTH_NTSC - 720)/2, // viXOrigin + (VI_MAX_HEIGHT_NTSC - 480)/2, // viYOrigin 720, // viWidth 480, // viHeight VI_XFBMODE_DF, // xFBmode @@ -245,29 +245,29 @@ GXRModeObj TV60hz_480i = GX_FALSE, // aa // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, + { + {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each + {6,6},{6,6},{6,6}, // pix 1 + {6,6},{6,6},{6,6}, // pix 2 + {6,6},{6,6},{6,6} // pix 3 + }, // vertical filter[7], 1/64 units, 6 bits each - { - 8, // line n-1 - 8, // line n-1 - 10, // line n - 12, // line n - 10, // line n - 8, // line n+1 - 8 // line n+1 - } + { + 8, // line n-1 + 8, // line n-1 + 10, // line n + 12, // line n + 10, // line n + 8, // line n+1 + 8 // line n+1 + } }; /* TV Modes table */ GXRModeObj *tvmodes[6] = { - &TV60hz_240p, &TV60hz_240i, &TV60hz_480i, /* 60hz modes */ - &TV50hz_288p, &TV50hz_288i, &TV50hz_576i /* 50Hz modes */ + &TV60hz_240p, &TV60hz_240i, &TV60hz_480i, /* 60hz modes */ + &TV50hz_288p, &TV50hz_288i, &TV50hz_576i /* 50Hz modes */ }; typedef struct tagcamera @@ -279,7 +279,7 @@ typedef struct tagcamera /*** Square Matrix This structure controls the size of the image on the screen. - Think of the output as a -80 x 80 by -60 x 60 graph. + Think of the output as a -80 x 80 by -60 x 60 graph. ***/ static s16 square[] ATTRIBUTE_ALIGN (32) = { @@ -287,10 +287,10 @@ static s16 square[] ATTRIBUTE_ALIGN (32) = * X, Y, Z * Values set are for roughly 4:3 aspect */ - -HASPECT, VASPECT, 0, // 0 - HASPECT, VASPECT, 0, // 1 - HASPECT, -VASPECT, 0, // 2 - -HASPECT, -VASPECT, 0, // 3 + -HASPECT, VASPECT, 0, // 0 + HASPECT, VASPECT, 0, // 1 + HASPECT, -VASPECT, 0, // 2 + -HASPECT, -VASPECT, 0, // 3 }; static camera cam = { @@ -402,23 +402,23 @@ static void gxScale(GXRModeObj *rmode) /* original aspect ratio */ /* the following values have been detected from comparison with a real 50/60hz Mega Drive */ if (config.overscan) - { + { /* borders are emulated */ - xscale = 358 + ((reg[12] & 1)*2) - gc_pal; + xscale = 358 + ((reg[12] & 1)*2) - gc_pal; yscale = vdp_pal + ((gc_pal && !config.render) ? 143 : 120); } else { /* borders are simulated (black) */ - xscale = 325 + ((reg[12] & 1)*2) - gc_pal; + xscale = 325 + ((reg[12] & 1)*2) - gc_pal; yscale = bitmap.viewport.h / 2; - if (vdp_pal && (!gc_pal || config.render)) yscale = yscale * 240 / 288; - else if (!vdp_pal && gc_pal && !config.render) yscale = yscale * 288 / 240; + if (vdp_pal && (!gc_pal || config.render)) yscale = yscale * 240 / 288; + else if (!vdp_pal && gc_pal && !config.render) yscale = yscale * 288 / 240; } xshift = config.xshift; yshift = 2 - vdp_pal + 2*(gc_pal & !config.render) + config.yshift; - } + } else { /* manual aspect ratio (default is fullscreen) */ @@ -440,8 +440,8 @@ static void gxScale(GXRModeObj *rmode) yscale += config.yscale; xshift = config.xshift; - yshift = config.yshift; - } + yshift = config.yshift; + } /* Double resolution modes */ if (config.render) @@ -488,9 +488,9 @@ static void gxScale(GXRModeObj *rmode) /* update GX scaler (Vertex Position Matrix) */ square[6] = square[3] = xscale + xshift; - square[0] = square[9] = -xscale + xshift; + square[0] = square[9] = -xscale + xshift; square[4] = square[1] = yscale + yshift; - square[7] = square[10] = -yscale + yshift; + square[7] = square[10] = -yscale + yshift; DCFlushRange (square, 32); GX_InvVtxCache (); @@ -499,7 +499,7 @@ static void gxScale(GXRModeObj *rmode) /* Reinitialize Video */ void ogc_video__reset() { - Mtx p; + Mtx p; GXRModeObj *rmode; /* 50Hz/60Hz mode */ @@ -522,18 +522,18 @@ void ogc_video__reset() /* Set current TV mode */ if (config.render) rmode = tvmodes[gc_pal*3 + 2]; - else rmode = tvmodes[gc_pal*3 + interlaced]; + else rmode = tvmodes[gc_pal*3 + interlaced]; /* Aspect ratio */ gxScale(rmode); /* Configure VI */ VIDEO_Configure (rmode); - VIDEO_ClearFrameBuffer(rmode, xfb[whichfb], COLOR_BLACK); - VIDEO_Flush(); - VIDEO_WaitVSync(); - if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); - else while (VIDEO_GetNextField()) VIDEO_WaitVSync(); + VIDEO_ClearFrameBuffer(rmode, xfb[whichfb], COLOR_BLACK); + VIDEO_Flush(); + VIDEO_WaitVSync(); + if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); + else while (VIDEO_GetNextField()) VIDEO_WaitVSync(); /* Configure GX */ GX_SetViewport (0.0F, 0.0F, rmode->fbWidth, rmode->efbHeight, 0.0F, 1.0F); @@ -596,7 +596,7 @@ void ogc_video__update() ogc_video__reset(); /* reinitialize texture */ - GX_InitTexObj (&texobj, texturemem, vwidth * 4, vheight * 4, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); + GX_InitTexObj (&texobj, texturemem, vwidth * 4, vheight * 4, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); /* enable/disable bilinear filtering */ if (!config.bilinear) diff --git a/source/ngc/osd.h b/source/ngc/osd.h index 735f3c0..320fe8b 100644 --- a/source/ngc/osd.h +++ b/source/ngc/osd.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include "ogc_input.h" @@ -19,6 +18,8 @@ #include "config.h" #include "history.h" +#define DEFAULT_PATH "/genplus" + #define update_input() ogc_input__update() /* globals */ diff --git a/source/render.c b/source/render.c index aa068a8..9bcadd5 100644 --- a/source/render.c +++ b/source/render.c @@ -63,7 +63,7 @@ static uint32 make_lut_bgobj_ste(uint32 bx, uint32 sx); static __inline__ uint32 READ_LONG(void *address) { if ((uint32)address & 3) - { + { #ifdef LSB_FIRST /* little endian version */ return ( *((uint8 *)address) + (*((uint8 *)address+1) << 8) + @@ -75,14 +75,14 @@ static __inline__ uint32 READ_LONG(void *address) (*((uint8 *)address+1) << 16) + (*((uint8 *)address) << 24) ); #endif /* LSB_FIRST */ - } - else return *(uint32 *)address; + } + else return *(uint32 *)address; } static __inline__ void WRITE_LONG(void *address, uint32 data) { if ((uint32)address & 3) - { + { #ifdef LSB_FIRST *((uint8 *)address) = data; *((uint8 *)address+1) = (data >> 8); @@ -94,9 +94,9 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) *((uint8 *)address+1) = (data >> 16); *((uint8 *)address) = (data >> 24); #endif /* LSB_FIRST */ - return; - } - else *(uint32 *)address = data; + return; + } + else *(uint32 *)address = data; } #endif /* ALIGN_LONG */ @@ -112,26 +112,26 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) N = Pattern Number (11 bits) MSB PCCVHNNN NNNNNNNN LSB PCCVHNNN NNNNNNNN LSB - PATTERN1 PATTERN2 + PATTERN1 PATTERN2 Pattern attributes are read from VRAM as 32bits WORD like this: LIT_ENDIAN: ATTR is MSB PCCVHNNN NNNNNNNN PCCVHNNN NNNNNNNN LSB - PATTERN2 PATTERN1 + PATTERN2 PATTERN1 BIG_ENDIAN: ATTR is MSB PCCVHNNN NNNNNNNN PCCVHNNN NNNNNNNN LSB - PATTERN1 PATTERN2 + PATTERN1 PATTERN2 Each Line Buffer written byte describe one pixel data like this: - msb SPppcccc lsb + msb SPppcccc lsb - with: - S = sprite data indicator (not written here) - P = priority bit (from Pattern Attribute) - p = color palette (from Pattern Attribute) - c = color data (from Pattern Cache) + with: + S = sprite data indicator (not written here) + P = priority bit (from Pattern Attribute) + p = color palette (from Pattern Attribute) + c = color data (from Pattern Cache) A column is 2 patterns wide @@ -141,11 +141,11 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) /* Draw a single 8-pixel column */ /* pattern cache is addressed like this: 00000VHN NNNNNNNN NNYYYXXX - with : Y = pattern row (1-8 lines) - X = pattern column (1-8 pixels) - V = Vertical Flip bit - H = Horizontal Flip bit - N = Pattern Number (1-2048) + with : Y = pattern row (1-8 lines) + X = pattern column (1-8 pixels) + V = Vertical Flip bit + H = Horizontal Flip bit + N = Pattern Number (1-2048) */ #ifdef ALIGN_LONG #ifdef LSB_FIRST @@ -170,7 +170,7 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) #else #define DRAW_COLUMN(ATTR, LINE) \ attr_msb = ATTR >> 16; \ - atex = atex_table[(ATTR_MSB >> 13) & 7]; \ + atex = atex_table[(ATTR_MSB >> 13) & 7]; \ src = (uint32 *)&bg_pattern_cache[(ATTR_MSB & 0x1FFF) << 6 | (LINE)]; \ WRITE_LONG(dst, READ_LONG(src) | atex); \ dst++; \ @@ -202,7 +202,7 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) #else #define DRAW_COLUMN(ATTR, LINE) \ attr_msb = ATTR >> 16; \ - atex = atex_table[(attr_msb >> 13) & 7]; \ + atex = atex_table[(attr_msb >> 13) & 7]; \ src = (uint32 *)&bg_pattern_cache[(attr_msb & 0x1FFF) << 6 | (LINE)]; \ *dst++ = (*src++ | atex); \ *dst++ = (*src++ | atex); \ @@ -217,11 +217,11 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) /* Draw a single 16-pixel column */ /* pattern cache is addressed like this: 00000VHN NNNNNNNN NYYYYXXX - with : Y = pattern row (1-16 lines) - X = pattern column (1-8 pixels) - V = Vertical Flip bit - H = Horizontal Flip bit - N = Pattern Number (1-1024) + with : Y = pattern row (1-16 lines) + X = pattern column (1-8 pixels) + V = Vertical Flip bit + H = Horizontal Flip bit + N = Pattern Number (1-1024) one pattern line is 8 pixels = 8 bytes = 2 * 32 bits */ @@ -252,7 +252,7 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) #else #define DRAW_COLUMN_IM2(ATTR, LINE) \ attr_msb = ATTR >> 16; \ - atex = atex_table[(attr_msb >> 13) & 7]; \ + atex = atex_table[(attr_msb >> 13) & 7]; \ offs = (attr_msb & 0x03FF) << 7 | (attr_msb & 0x1800) << 6 | (LINE); \ if(attr_msb & 0x1000) offs ^= 0x40; \ src = (uint32 *)&bg_pattern_cache[offs]; \ @@ -318,11 +318,11 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) check if non-transparent sprite data has been previously drawn */ #define DRAW_SPRITE_TILE \ - for(i=0; i<8; i++) \ - { \ - if ((lb[i] & 0x80) && (lb[i] & 0x0F) && (src[i] & 0x0F)) status |= 0x20; \ - lb[i] = table[(lb[i] << 8) |(src[i] | palette)]; \ - } + for(i=0; i<8; i++) \ + { \ + if ((lb[i] & 0x80) && (lb[i] & 0x0F) && (src[i] & 0x0F)) status |= 0x20; \ + lb[i] = table[(lb[i] << 8) |(src[i] | palette)]; \ + } /* Pixel creation macros, input is four bits each */ @@ -387,11 +387,11 @@ static uint16 pixel_16[0x100]; static uint16 pixel_16_lut[3][0x200]; /* Line buffers */ -static uint8 tmp_buf[0x400]; /* Temporary buffer */ -static uint8 bg_buf[0x400]; /* Merged background buffer */ -static uint8 nta_buf[0x400]; /* Plane A / Window line buffer */ -static uint8 ntb_buf[0x400]; /* Plane B line buffer */ -static uint8 obj_buf[0x400]; /* Object layer line buffer */ +static uint8 tmp_buf[0x400]; /* Temporary buffer */ +static uint8 bg_buf[0x400]; /* Merged background buffer */ +static uint8 nta_buf[0x400]; /* Plane A / Window line buffer */ +static uint8 ntb_buf[0x400]; /* Plane B line buffer */ +static uint8 obj_buf[0x400]; /* Object layer line buffer */ /* Sprite line buffer data */ static uint32 object_index_count; @@ -401,8 +401,8 @@ static uint32 object_index_count; this is used to convert 3bits RGB values to 5bits (R,B) or 6bits (G) values there is three color modes: normal: RGB range is [0;MAX] - half: RGB range is [0;MAX/2] (shadow mode) - high: RGB range is [MAX/2;MAX] (highlight mode) + half: RGB range is [0;MAX/2] (shadow mode) + high: RGB range is [MAX/2;MAX] (highlight mode) MAX is 31 (R,B) or 63 (G) for 5:6:5 pixels and 7 (R,G,B) for 3:3:3 pixels MAX/2 is rounded to inferior value (15, 31 or 3) @@ -410,59 +410,59 @@ static uint32 object_index_count; the extrapolation is linear and calculated like this: for (i=0; i<8; i++) - { - rgb565_norm[0][i] = round(((double)i * 31.0) / 7.0); - rgb565_norm[1][i] = round(((double)i * 63.0) / 7.0); - - rgb565_half[0][i] = round(((double)i * 31.0) / 7.0 / 2.0); - rgb565_half[1][i] = round(((double)i * 63.0) / 7.0 / 2.0); - - rgb565_high[0][i] = round(((double)i * 31.0) / 7.0 / 2.0 + 15.5); - rgb565_high[1][i] = round(((double)i * 63.0) / 7.0 / 2.0 + 31.5); - } + { + rgb565_norm[0][i] = round(((double)i * 31.0) / 7.0); + rgb565_norm[1][i] = round(((double)i * 63.0) / 7.0); + + rgb565_half[0][i] = round(((double)i * 31.0) / 7.0 / 2.0); + rgb565_half[1][i] = round(((double)i * 63.0) / 7.0 / 2.0); + + rgb565_high[0][i] = round(((double)i * 31.0) / 7.0 / 2.0 + 15.5); + rgb565_high[1][i] = round(((double)i * 63.0) / 7.0 / 2.0 + 31.5); + } */ uint8 rgb565_norm[2][8] = {{0 , 4, 9, 13, 18, 22, 27, 31}, - {0 , 9, 18, 27, 36, 45, 54, 63}}; + {0 , 9, 18, 27, 36, 45, 54, 63}}; uint8 rgb565_half[2][8] = {{0 , 2, 4, 6, 9, 11, 13, 15}, - {0 , 4, 9, 13, 18, 22, 27, 31}}; + {0 , 4, 9, 13, 18, 22, 27, 31}}; uint8 rgb565_high[2][8] = {{15, 17, 19, 21, 24, 26, 28, 31}, - {31, 35, 40, 44, 49, 53, 58, 63}}; + {31, 35, 40, 44, 49, 53, 58, 63}}; void palette_init(void) { - int i; + int i; - for (i = 0; i < 0x200; i += 1) - { - int r, g, b; + for (i = 0; i < 0x200; i += 1) + { + int r, g, b; - r = (i >> 6) & 7; - g = (i >> 3) & 7; - b = (i >> 0) & 7; + r = (i >> 6) & 7; + g = (i >> 3) & 7; + b = (i >> 0) & 7; #ifndef NGC - pixel_8_lut[0][i] = MAKE_PIXEL_8(r>>1,g>>1,b>>1); - pixel_8_lut[1][i] = MAKE_PIXEL_8(r,g,b); - pixel_8_lut[2][i] = MAKE_PIXEL_8((r>>1)|4,(g>>1)|4,(b>>1)|4); + pixel_8_lut[0][i] = MAKE_PIXEL_8(r>>1,g>>1,b>>1); + pixel_8_lut[1][i] = MAKE_PIXEL_8(r,g,b); + pixel_8_lut[2][i] = MAKE_PIXEL_8((r>>1)|4,(g>>1)|4,(b>>1)|4); - pixel_15_lut[0][i] = MAKE_PIXEL_15(r,g,b); - pixel_15_lut[1][i] = MAKE_PIXEL_15(r<<1,g<<1,b<<1); - pixel_15_lut[2][i] = MAKE_PIXEL_15(r|8,g|8,b|8); + pixel_15_lut[0][i] = MAKE_PIXEL_15(r,g,b); + pixel_15_lut[1][i] = MAKE_PIXEL_15(r<<1,g<<1,b<<1); + pixel_15_lut[2][i] = MAKE_PIXEL_15(r|8,g|8,b|8); - pixel_32_lut[0][i] = MAKE_PIXEL_32(r,g,b); - pixel_32_lut[1][i] = MAKE_PIXEL_32(r<<1,g<<1,b<<1); - pixel_32_lut[2][i] = MAKE_PIXEL_32(r|8,g|8,b|8); + pixel_32_lut[0][i] = MAKE_PIXEL_32(r,g,b); + pixel_32_lut[1][i] = MAKE_PIXEL_32(r<<1,g<<1,b<<1); + pixel_32_lut[2][i] = MAKE_PIXEL_32(r|8,g|8,b|8); #endif - /* RGB 565 format: we extrapolate each 3-bit value into a 5-bit (R,B) or 6-bit (G) value - this is needed to correctly cover full color range: [0-31] for R,B or [0-63] for G */ - pixel_16_lut[0][i] = MAKE_PIXEL_16(rgb565_half[0][r],rgb565_half[1][g],rgb565_half[0][b]); - pixel_16_lut[1][i] = MAKE_PIXEL_16(rgb565_norm[0][r],rgb565_norm[1][g],rgb565_norm[0][b]); - pixel_16_lut[2][i] = MAKE_PIXEL_16(rgb565_high[0][r],rgb565_high[1][g],rgb565_high[0][b]); - } + /* RGB 565 format: we extrapolate each 3-bit value into a 5-bit (R,B) or 6-bit (G) value + this is needed to correctly cover full color range: [0-31] for R,B or [0-63] for G */ + pixel_16_lut[0][i] = MAKE_PIXEL_16(rgb565_half[0][r],rgb565_half[1][g],rgb565_half[0][b]); + pixel_16_lut[1][i] = MAKE_PIXEL_16(rgb565_norm[0][r],rgb565_norm[1][g],rgb565_norm[0][b]); + pixel_16_lut[2][i] = MAKE_PIXEL_16(rgb565_high[0][r],rgb565_high[1][g],rgb565_high[0][b]); + } } /*--------------------------------------------------------------------------*/ @@ -471,75 +471,75 @@ void palette_init(void) int render_init (void) { - int bx, ax, i; + int bx, ax, i; - /* Allocate and align pixel look-up tables */ - if (lut_base == NULL) lut_base = malloc ((LUT_MAX * LUT_SIZE) + LUT_SIZE); - lut[0] = (uint8 *) (((uint32) lut_base + LUT_SIZE) & ~(LUT_SIZE - 1)); - for (i = 1; i < LUT_MAX; i += 1) lut[i] = lut[0] + (i * LUT_SIZE); + /* Allocate and align pixel look-up tables */ + if (lut_base == NULL) lut_base = malloc ((LUT_MAX * LUT_SIZE) + LUT_SIZE); + lut[0] = (uint8 *) (((uint32) lut_base + LUT_SIZE) & ~(LUT_SIZE - 1)); + for (i = 1; i < LUT_MAX; i += 1) lut[i] = lut[0] + (i * LUT_SIZE); - /* Make pixel look-up table data */ - for (bx = 0; bx < 0x100; bx += 1) - for (ax = 0; ax < 0x100; ax += 1) - { - uint16 index = (bx << 8) | (ax); - lut[0][index] = make_lut_bg (bx, ax); - lut[1][index] = make_lut_obj (bx, ax); - lut[2][index] = make_lut_bg_ste (bx, ax); - lut[3][index] = make_lut_obj_ste (bx, ax); - lut[4][index] = make_lut_bgobj_ste (bx, ax); - } + /* Make pixel look-up table data */ + for (bx = 0; bx < 0x100; bx += 1) + for (ax = 0; ax < 0x100; ax += 1) + { + uint16 index = (bx << 8) | (ax); + lut[0][index] = make_lut_bg (bx, ax); + lut[1][index] = make_lut_obj (bx, ax); + lut[2][index] = make_lut_bg_ste (bx, ax); + lut[3][index] = make_lut_obj_ste (bx, ax); + lut[4][index] = make_lut_bgobj_ste (bx, ax); + } - /* Make pixel data tables */ - palette_init(); + /* Make pixel data tables */ + palette_init(); - /* Set up color update function */ + /* Set up color update function */ #ifndef NGC - switch(bitmap.depth) - { - case 8: color_update = color_update_8; break; - case 15: color_update = color_update_15; break; - case 16: color_update = color_update_16; break; - case 32: color_update = color_update_32; break; - } + switch(bitmap.depth) + { + case 8: color_update = color_update_8; break; + case 15: color_update = color_update_15; break; + case 16: color_update = color_update_16; break; + case 32: color_update = color_update_32; break; + } #else - color_update = color_update_16; + color_update = color_update_16; #endif - /* Make sprite name look-up table */ - make_name_lut(); + /* Make sprite name look-up table */ + make_name_lut(); - return (1); + return (1); } void make_name_lut(void) { - int col, row; - int vcol, vrow; - int width, height; - int flipx, flipy; - int i, name; + int col, row; + int vcol, vrow; + int width, height; + int flipx, flipy; + int i, name; - memset (name_lut, 0, sizeof (name_lut)); + memset (name_lut, 0, sizeof (name_lut)); - for (i = 0; i < 0x400; i += 1) - { - vcol = col = i & 3; - vrow = row = (i >> 2) & 3; - height = (i >> 4) & 3; - width = (i >> 6) & 3; - flipx = (i >> 8) & 1; - flipy = (i >> 9) & 1; + for (i = 0; i < 0x400; i += 1) + { + vcol = col = i & 3; + vrow = row = (i >> 2) & 3; + height = (i >> 4) & 3; + width = (i >> 6) & 3; + flipx = (i >> 8) & 1; + flipy = (i >> 9) & 1; - if(flipx) vcol = (width - col); - if(flipy) vrow = (height - row); + if(flipx) vcol = (width - col); + if(flipy) vrow = (height - row); - name = vrow + (vcol * (height + 1)); + name = vrow + (vcol * (height + 1)); - if ((row > height) || col > width) name = -1; + if ((row > height) || col > width) name = -1; - name_lut[i] = name; - } + name_lut[i] = name; + } } void render_reset(void) @@ -547,7 +547,7 @@ void render_reset(void) /* Clear display bitmap */ memset(bitmap.data, 0, bitmap.pitch * bitmap.height); - memset(&clip, 0, sizeof(clip)); + memset(&clip, 0, sizeof(clip)); memset(bg_buf, 0, sizeof(bg_buf)); memset(tmp_buf, 0, sizeof(tmp_buf)); memset(nta_buf, 0, sizeof(nta_buf)); @@ -555,7 +555,7 @@ void render_reset(void) memset(obj_buf, 0, sizeof(obj_buf)); #ifndef NGC - memset(&pixel_8, 0, sizeof(pixel_8)); + memset(&pixel_8, 0, sizeof(pixel_8)); memset(&pixel_15, 0, sizeof(pixel_15)); memset(&pixel_32, 0, sizeof(pixel_32)); #endif @@ -580,10 +580,10 @@ static inline void update_bg_pattern_cache(uint32 index) uint8 *dst; uint32 bp; #ifdef LSB_FIRST - uint8 shift_table[8] = {12, 8, 4, 0, 28, 24, 20, 16}; + uint8 shift_table[8] = {12, 8, 4, 0, 28, 24, 20, 16}; #else - uint8 shift_table[8] = {28, 24, 20, 16, 12, 8, 4, 0}; -#endif + uint8 shift_table[8] = {28, 24, 20, 16, 12, 8, 4, 0}; +#endif for(i = 0; i < index; i ++) { @@ -599,11 +599,11 @@ static inline void update_bg_pattern_cache(uint32 index) for(x = 0; x < 8; x ++) { - c = (bp >> shift_table[x]) & 0x0F; - dst[0x00000 | (y << 3) | (x)] = (c); /* hf=0, vf=0: normal */ - dst[0x20000 | (y << 3) | (x ^ 7)] = (c); /* hf=1, vf=0: horizontal flipped */ - dst[0x40000 | ((y ^ 7) << 3) | (x)] = (c); /* hf=0, vf=1: vertical flipped */ - dst[0x60000 | ((y ^ 7) << 3) | (x ^ 7)] = (c); /* hf=1, vf=1: horizontal & vertical flipped */ + c = (bp >> shift_table[x]) & 0x0F; + dst[0x00000 | (y << 3) | (x)] = (c); /* hf=0, vf=0: normal */ + dst[0x20000 | (y << 3) | (x ^ 7)] = (c); /* hf=1, vf=0: horizontal flipped */ + dst[0x40000 | ((y ^ 7) << 3) | (x)] = (c); /* hf=0, vf=1: vertical flipped */ + dst[0x60000 | ((y ^ 7) << 3) | (x ^ 7)] = (c); /* hf=1, vf=1: horizontal & vertical flipped */ } } } @@ -751,7 +751,7 @@ void remap_buffer(uint32 line, uint32 width) else sms_ntsc_blit(&sms_ntsc, ( SMS_NTSC_IN_T const * )pixel_16, tmp_buf+0x20-bitmap.viewport.x, width, line); return; } - + #ifdef NGC /* directly fill the RGB565 texture */ /* one tile is 32 byte = 4x4 pixels */ @@ -764,17 +764,17 @@ void remap_buffer(uint32 line, uint32 width) void *out =((void *)&bitmap.data[(line * bitmap.pitch)]); switch(bitmap.depth) { - case 8: - remap_8(tmp_buf+0x20-bitmap.viewport.x, (uint8 *)out, pixel_8, width); - break; + case 8: + remap_8(tmp_buf+0x20-bitmap.viewport.x, (uint8 *)out, pixel_8, width); + break; case 15: - remap_16(tmp_buf+0x20-bitmap.viewport.x, (uint16 *)out, pixel_15, width); - break; + remap_16(tmp_buf+0x20-bitmap.viewport.x, (uint16 *)out, pixel_15, width); + break; case 16: - remap_16(tmp_buf+0x20-bitmap.viewport.x, (uint16 *)out, pixel_16, width); - break; + remap_16(tmp_buf+0x20-bitmap.viewport.x, (uint16 *)out, pixel_16, width); + break; case 32: - remap_32(tmp_buf+0x20-bitmap.viewport.x, (uint32 *)out, pixel_32, width); + remap_32(tmp_buf+0x20-bitmap.viewport.x, (uint32 *)out, pixel_32, width); break; } #endif @@ -782,16 +782,16 @@ void remap_buffer(uint32 line, uint32 width) void render_line(uint32 line, uint32 overscan) { - uint32 width = bitmap.viewport.w; + uint32 width = bitmap.viewport.w; uint32 x_offset = bitmap.viewport.x; - /* background color (display OFF or borders) */ + /* background color (display OFF or borders) */ if (overscan || !(reg[1] & 0x40)) { width += 2 * x_offset; - memset(&tmp_buf[0x20 - x_offset], 0x40, width); - } - else + memset(&tmp_buf[0x20 - x_offset], 0x40, width); + } + else { uint8 *lb = tmp_buf; @@ -910,17 +910,17 @@ static void render_bg(uint32 line, uint32 width) uint32 y_scroll = (line + (vs[0] & 0x3FF)) & pf_row_mask; #endif - uint32 v_line = (y_scroll & 7) << 3; - uint32 *nt = (uint32 *)&vram[ntbb + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + uint32 v_line = (y_scroll & 7) << 3; + uint32 *nt = (uint32 *)&vram[ntbb + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; if(shift) { - dst = (uint32 *)&buf[0x10 + shift]; + dst = (uint32 *)&buf[0x10 + shift]; atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN(atbuf, v_line); + DRAW_COLUMN(atbuf, v_line); } - dst = (uint32 *)&buf[0x20 + shift]; + dst = (uint32 *)&buf[0x20 + shift]; for(column = 0; column < end; column ++, index ++) { atbuf = nt[index & pf_col_mask]; @@ -991,7 +991,7 @@ static void render_bg(uint32 line, uint32 width) if (w) { v_line = (line & 7) << 3; - nt = (uint32 *)&vram[ntwb | ((line >> 3) << (6 + (reg[12] & 1)))]; + nt = (uint32 *)&vram[ntwb | ((line >> 3) << (6 + (reg[12] & 1)))]; dst = (uint32 *)&buf[0x20 + (start << 4)]; for(column = start; column < end; column ++) { @@ -1029,19 +1029,19 @@ static void render_bg_vs(uint32 line, uint32 width) uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); #endif - uint32 y_scroll, v_line, *nt; + uint32 y_scroll, v_line, *nt; - if(shift) + if(shift) { y_scroll = (line & pf_row_mask); v_line = (y_scroll & 7) << 3; nt = (uint32 *)&vram[ntbb + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; - dst = (uint32 *)&buf[0x10 + shift]; + dst = (uint32 *)&buf[0x10 + shift]; atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN(atbuf, v_line); + DRAW_COLUMN(atbuf, v_line); } - dst = (uint32 *)&buf[0x20 + shift]; + dst = (uint32 *)&buf[0x20 + shift]; for(column = start; column < end; column ++, index ++) { #ifdef LSB_FIRST @@ -1108,7 +1108,7 @@ static void render_bg_vs(uint32 line, uint32 width) y_scroll = (line + (vs[column] & 0x3FF)) & pf_row_mask; #else y_scroll = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; -#endif +#endif v_line = (y_scroll & 7) << 3; nt = (uint32 *)&vram[ntab + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; atbuf = nt[index & pf_col_mask]; @@ -1124,7 +1124,7 @@ static void render_bg_vs(uint32 line, uint32 width) if (w) { v_line = (line & 7) << 3; - nt = (uint32 *)&vram[ntwb | ((line >> 3) << (6 + (reg[12] & 1)))]; + nt = (uint32 *)&vram[ntwb | ((line >> 3) << (6 + (reg[12] & 1)))]; dst = (uint32 *)&buf[0x20 + (start << 4)]; for(column = start; column < end; column ++) { @@ -1164,17 +1164,17 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) uint32 y_scroll = (line + ((vs[0] >> 1) & 0x3FF)) & pf_row_mask; /* IM2 specific */ #endif - uint32 v_line = (((y_scroll & 7) << 1) | odd) << 3; /* IM2 specific */ - uint32 *nt = (uint32 *)&vram[ntbb + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + uint32 v_line = (((y_scroll & 7) << 1) | odd) << 3; /* IM2 specific */ + uint32 *nt = (uint32 *)&vram[ntbb + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; if(shift) { - dst = (uint32 *)&buf[0x10 + shift]; + dst = (uint32 *)&buf[0x10 + shift]; atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN_IM2(atbuf, v_line); /* IM2 specific */ + DRAW_COLUMN_IM2(atbuf, v_line); /* IM2 specific */ } - dst = (uint32 *)&buf[0x20 + shift]; + dst = (uint32 *)&buf[0x20 + shift]; for(column = 0; column < end; column ++, index ++) { atbuf = nt[index & pf_col_mask]; @@ -1215,18 +1215,18 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) y_scroll = (line + ((vs[0] >> 17) & 0x3FF)) & pf_row_mask; /* IM2 specific */ #endif - v_line = (((y_scroll & 7) << 1) | odd) << 3; /* IM2 specific */ - nt = (uint32 *)&vram[ntab + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + v_line = (((y_scroll & 7) << 1) | odd) << 3; /* IM2 specific */ + nt = (uint32 *)&vram[ntab + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; if(shift) { - dst = (uint32 *)&buf[0x10 + shift + (start<<4)]; + dst = (uint32 *)&buf[0x10 + shift + (start<<4)]; - /* Window bug */ - if (start) atbuf = nt[index & pf_col_mask]; + /* Window bug */ + if (start) atbuf = nt[index & pf_col_mask]; else atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN_IM2(atbuf, v_line); /* IM2 specific */ + DRAW_COLUMN_IM2(atbuf, v_line); /* IM2 specific */ } dst = (uint32 *)&buf[0x20 + shift + (start<<4)]; @@ -1245,7 +1245,7 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) if (w) { v_line = ((line & 7) << 1 | odd) << 3; /* IM2 specific */ - nt = (uint32 *)&vram[ntwb | ((line >> 3) << (6 + (reg[12] & 1)))]; + nt = (uint32 *)&vram[ntwb | ((line >> 3) << (6 + (reg[12] & 1)))]; dst = (uint32 *)&buf[0x20 + (start << 4)]; for(column = start; column < end; column ++) { @@ -1612,23 +1612,23 @@ void parse_satb(uint32 line) { ypos = (q[link] >> im2_flag) & 0x1FF; size = q[link + 1] >> 8; - height = sizetab[size & 3]; + height = sizetab[size & 3]; if((line >= ypos) && (line < (ypos + height))) { /* sprite limit (max. 16 or 20 sprites displayed per line) */ - if(object_index_count == limit) + if(object_index_count == limit) { if(vint_pending == 0) status |= 0x40; return; } - // using xpos from internal satb stops sprite x + // using xpos from internal satb stops sprite x // scrolling in bloodlin.bin, // but this seems to go against the test prog - object_info[object_index_count].attr = p[link + 2]; + object_info[object_index_count].attr = p[link + 2]; object_info[object_index_count].xpos = p[link + 3]; - object_info[object_index_count].ypos = ypos; + object_info[object_index_count].ypos = ypos; object_info[object_index_count].size = size; ++object_index_count; } @@ -1668,14 +1668,14 @@ static void render_obj(uint32 line, uint8 *buf, uint8 *table) xpos = object_info[count].xpos & 0x1ff; /* sprite masking */ - if(xpos != 0) sol_flag = 1; - else if(xpos == 0 && sol_flag) return; + if(xpos != 0) sol_flag = 1; + else if(xpos == 0 && sol_flag) return; size = object_info[count].size & 0x0f; - width = sizetab[(size >> 2) & 3]; + width = sizetab[(size >> 2) & 3]; - /* update pixel count (off-screen sprites included) */ - pixelcount += width; + /* update pixel count (off-screen sprites included) */ + pixelcount += width; if(((xpos + width) >= left) && (xpos < right)) { @@ -1695,10 +1695,10 @@ static void render_obj(uint32 line, uint8 *buf, uint8 *table) lb = (uint8 *)&buf[0x20 + (xpos - 0x80)]; - /* number of tiles to draw */ - /* adjusted for sprite limit */ + /* number of tiles to draw */ + /* adjusted for sprite limit */ if (pixelcount > bitmap.viewport.w) width -= (pixelcount - bitmap.viewport.w); - width >>= 3; + width >>= 3; for(column = 0; column < width; column += 1, lb+=8) { @@ -1709,8 +1709,8 @@ static void render_obj(uint32 line, uint8 *buf, uint8 *table) } - /* sprite limit (256 or 320 pixels) */ - if (pixelcount >= bitmap.viewport.w) return; + /* sprite limit (256 or 320 pixels) */ + if (pixelcount >= bitmap.viewport.w) return; } } @@ -1741,20 +1741,20 @@ static void render_obj_im2(uint32 line, uint32 odd, uint8 *buf, uint8 *table) int attr_mask, nt_row; - for(count = 0; count < object_index_count; count += 1) + for(count = 0; count < object_index_count; count += 1) { xpos = object_info[count].xpos & 0x1ff; - /* sprite masking */ - if(xpos != 0) sol_flag = 1; - else if(xpos == 0 && sol_flag) return; + /* sprite masking */ + if(xpos != 0) sol_flag = 1; + else if(xpos == 0 && sol_flag) return; size = object_info[count].size & 0x0f; width = sizetab[(size >> 2) & 3]; - /* update pixel count (off-screen sprites included) */ - pixelcount += width; - + /* update pixel count (off-screen sprites included) */ + pixelcount += width; + if(((xpos + width) >= left) && (xpos < right)) { ypos = object_info[count].ypos; @@ -1773,10 +1773,10 @@ static void render_obj_im2(uint32 line, uint32 odd, uint8 *buf, uint8 *table) lb = (uint8 *)&buf[0x20 + (xpos - 0x80)]; - /* number of tiles to draw */ - /* adjusted for sprite limit */ + /* number of tiles to draw */ + /* adjusted for sprite limit */ if (pixelcount > bitmap.viewport.w) width -= (pixelcount - bitmap.viewport.w); - width >>= 3; + width >>= 3; for(column = 0; column < width; column += 1, lb+=8) { @@ -1788,8 +1788,8 @@ static void render_obj_im2(uint32 line, uint32 odd, uint8 *buf, uint8 *table) } } - /* sprite limit (256 or 320 pixels) */ - if (pixelcount >= bitmap.viewport.w) return; + /* sprite limit (256 or 320 pixels) */ + if (pixelcount >= bitmap.viewport.w) return; } } diff --git a/source/state.c b/source/state.c index fbbb731..fc58890 100644 --- a/source/state.c +++ b/source/state.c @@ -27,163 +27,163 @@ static unsigned int bufferptr; static inline void load_param(void *param, unsigned int size) { - memcpy(param, &state[bufferptr], size); - bufferptr+= size; + memcpy(param, &state[bufferptr], size); + bufferptr+= size; } static inline void save_param(void *param, unsigned int size) { - memcpy(&state[bufferptr], param, size); - bufferptr+= size; + memcpy(&state[bufferptr], param, size); + bufferptr+= size; } void state_load(unsigned char *buffer) { - /* reset buffer pointer */ - bufferptr = 0; + /* reset buffer pointer */ + bufferptr = 0; /* uncompress savestate */ unsigned long inbytes, outbytes; - memcpy(&inbytes, buffer, 4); - outbytes = 0x24000; + memcpy(&inbytes, buffer, 4); + outbytes = 0x24000; uncompress ((Bytef *)state, &outbytes, (Bytef *)(buffer + 4), inbytes); - /* reset system */ - system_reset(); - m68k_memory_map[0].base = default_rom; + /* reset system */ + system_reset(); + m68k_memory_map[0].base = default_rom; - // GENESIS - load_param(work_ram, sizeof(work_ram)); - load_param(zram, sizeof(zram)); - load_param(&zbusreq, sizeof(zbusreq)); - load_param(&zreset, sizeof(zreset)); - load_param(&zbank, sizeof(zbank)); - zbusack = 1 ^(zbusreq & zreset); + // GENESIS + load_param(work_ram, sizeof(work_ram)); + load_param(zram, sizeof(zram)); + load_param(&zbusreq, sizeof(zbusreq)); + load_param(&zreset, sizeof(zreset)); + load_param(&zbank, sizeof(zbank)); + zbusack = 1 ^(zbusreq & zreset); - // IO - load_param(io_reg, sizeof(io_reg)); - - // VDP - uint8 temp_reg[0x20]; - load_param(sat, sizeof(sat)); - load_param(vram, sizeof(vram)); - load_param(cram, sizeof(cram)); - load_param(vsram, sizeof(vsram)); - load_param(temp_reg, sizeof(temp_reg)); - load_param(&addr, sizeof(addr)); - load_param(&addr_latch, sizeof(addr_latch)); - load_param(&code, sizeof(code)); - load_param(&pending, sizeof(pending)); - load_param(&status, sizeof(status)); - load_param(&dmafill, sizeof(dmafill)); - load_param(&hint_pending, sizeof(hint_pending)); - load_param(&vint_pending, sizeof(vint_pending)); - load_param(&irq_status, sizeof(irq_status)); - vdp_restore(temp_reg); + // IO + load_param(io_reg, sizeof(io_reg)); - // FM - load_param(fm_reg,sizeof(fm_reg)); - fm_restore(); + // VDP + uint8 temp_reg[0x20]; + load_param(sat, sizeof(sat)); + load_param(vram, sizeof(vram)); + load_param(cram, sizeof(cram)); + load_param(vsram, sizeof(vsram)); + load_param(temp_reg, sizeof(temp_reg)); + load_param(&addr, sizeof(addr)); + load_param(&addr_latch, sizeof(addr_latch)); + load_param(&code, sizeof(code)); + load_param(&pending, sizeof(pending)); + load_param(&status, sizeof(status)); + load_param(&dmafill, sizeof(dmafill)); + load_param(&hint_pending, sizeof(hint_pending)); + load_param(&vint_pending, sizeof(vint_pending)); + load_param(&irq_status, sizeof(irq_status)); + vdp_restore(temp_reg); - // PSG - load_param(SN76489_GetContextPtr (0),SN76489_GetContextSize ()); + // FM + load_param(fm_reg,sizeof(fm_reg)); + fm_restore(); - // 68000 - uint16 tmp16; - uint32 tmp32; - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D0, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D1, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D2, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D3, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D4, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D5, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D6, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D7, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A0, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A1, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A2, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A3, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A4, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A5, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A6, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A7, tmp32); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_PC, tmp32); - load_param(&tmp16, 2); m68k_set_reg(M68K_REG_SR, tmp16); - load_param(&tmp32, 4); m68k_set_reg(M68K_REG_USP,tmp32); + // PSG + load_param(SN76489_GetContextPtr (0),SN76489_GetContextSize ()); - // Z80 - load_param(&Z80, sizeof(Z80_Regs)); + // 68000 + uint16 tmp16; + uint32 tmp32; + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D0, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D1, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D2, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D3, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D4, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D5, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D6, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_D7, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A0, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A1, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A2, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A3, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A4, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A5, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A6, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_A7, tmp32); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_PC, tmp32); + load_param(&tmp16, 2); m68k_set_reg(M68K_REG_SR, tmp16); + load_param(&tmp32, 4); m68k_set_reg(M68K_REG_USP,tmp32); + + // Z80 + load_param(&Z80, sizeof(Z80_Regs)); } int state_save(unsigned char *buffer) { - /* reset buffer pointer */ - bufferptr = 0; + /* reset buffer pointer */ + bufferptr = 0; - // GENESIS - save_param(work_ram, sizeof(work_ram)); - save_param(zram, sizeof(zram)); - save_param(&zbusreq, sizeof(zbusreq)); - save_param(&zreset, sizeof(zreset)); - save_param(&zbank, sizeof(zbank)); + // GENESIS + save_param(work_ram, sizeof(work_ram)); + save_param(zram, sizeof(zram)); + save_param(&zbusreq, sizeof(zbusreq)); + save_param(&zreset, sizeof(zreset)); + save_param(&zbank, sizeof(zbank)); - // IO - save_param(io_reg, sizeof(io_reg)); - - // VDP - save_param(sat, sizeof(sat)); - save_param(vram, sizeof(vram)); - save_param(cram, sizeof(cram)); - save_param(vsram, sizeof(vsram)); - save_param(reg, sizeof(reg)); - save_param(&addr, sizeof(addr)); - save_param(&addr_latch, sizeof(addr_latch)); - save_param(&code, sizeof(code)); - save_param(&pending, sizeof(pending)); - save_param(&status, sizeof(status)); - save_param(&dmafill, sizeof(dmafill)); - save_param(&hint_pending, sizeof(hint_pending)); - save_param(&vint_pending, sizeof(vint_pending)); - save_param(&irq_status, sizeof(irq_status)); + // IO + save_param(io_reg, sizeof(io_reg)); - // FM - save_param(fm_reg,sizeof(fm_reg)); + // VDP + save_param(sat, sizeof(sat)); + save_param(vram, sizeof(vram)); + save_param(cram, sizeof(cram)); + save_param(vsram, sizeof(vsram)); + save_param(reg, sizeof(reg)); + save_param(&addr, sizeof(addr)); + save_param(&addr_latch, sizeof(addr_latch)); + save_param(&code, sizeof(code)); + save_param(&pending, sizeof(pending)); + save_param(&status, sizeof(status)); + save_param(&dmafill, sizeof(dmafill)); + save_param(&hint_pending, sizeof(hint_pending)); + save_param(&vint_pending, sizeof(vint_pending)); + save_param(&irq_status, sizeof(irq_status)); - // PSG - save_param(SN76489_GetContextPtr (0),SN76489_GetContextSize ()); + // FM + save_param(fm_reg,sizeof(fm_reg)); - // 68000 - uint16 tmp16; - uint32 tmp32; - tmp32 = m68k_get_reg(NULL, M68K_REG_D0); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D1); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D2); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D3); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D4); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D5); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D6); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D7); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A0); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A1); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A2); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A3); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A4); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A5); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A6); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A7); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_PC); save_param(&tmp32, 4); - tmp16 = m68k_get_reg(NULL, M68K_REG_SR); save_param(&tmp16, 2); - tmp32 = m68k_get_reg(NULL, M68K_REG_USP); save_param(&tmp32, 4); + // PSG + save_param(SN76489_GetContextPtr (0),SN76489_GetContextSize ()); - // Z80 - save_param(&Z80, sizeof(Z80_Regs)); + // 68000 + uint16 tmp16; + uint32 tmp32; + tmp32 = m68k_get_reg(NULL, M68K_REG_D0); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_D1); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_D2); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_D3); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_D4); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_D5); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_D6); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_D7); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_A0); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_A1); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_A2); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_A3); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_A4); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_A5); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_A6); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_A7); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(NULL, M68K_REG_PC); save_param(&tmp32, 4); + tmp16 = m68k_get_reg(NULL, M68K_REG_SR); save_param(&tmp16, 2); + tmp32 = m68k_get_reg(NULL, M68K_REG_USP); save_param(&tmp32, 4); - /* compress state file */ - unsigned long inbytes = bufferptr; + // Z80 + save_param(&Z80, sizeof(Z80_Regs)); + + /* compress state file */ + unsigned long inbytes = bufferptr; unsigned long outbytes = 0x26000; compress2 ((Bytef *)(buffer + 4), &outbytes, (Bytef *)state, inbytes, 9); - memcpy(buffer, &outbytes, 4); + memcpy(buffer, &outbytes, 4); - /* return total size */ - return (outbytes + 4); + /* return total size */ + return (outbytes + 4); } diff --git a/source/system.c b/source/system.c index 07568d0..b3e19e6 100644 --- a/source/system.c +++ b/source/system.c @@ -49,13 +49,13 @@ static inline void audio_update (void); ****************************************************************/ void system_init (void) { - /* PAL/NTSC timings */ - vdp_rate = vdp_pal ? 50 : 60; - lines_per_frame = vdp_pal ? 313 : 262; - - gen_init (); - vdp_init (); - render_init (); + /* PAL/NTSC timings */ + vdp_rate = vdp_pal ? 50 : 60; + lines_per_frame = vdp_pal ? 313 : 262; + + gen_init (); + vdp_init (); + render_init (); cart_hw_init(); } @@ -64,30 +64,30 @@ void system_init (void) ****************************************************************/ void system_reset (void) { - aim_m68k = 0; - count_m68k = 0; - line_m68k = 0; - aim_z80 = 0; - count_z80 = 0; - line_z80 = 0; - current_z80 = 0; - odd_frame = 0; - interlaced = 0; + aim_m68k = 0; + count_m68k = 0; + line_m68k = 0; + aim_z80 = 0; + count_z80 = 0; + line_z80 = 0; + current_z80 = 0; + odd_frame = 0; + interlaced = 0; - /* Cart Hardware reset */ - cart_hw_reset(); + /* Cart Hardware reset */ + cart_hw_reset(); - /* Hard reset */ - gen_reset (1); - vdp_reset (); - render_reset (); - io_reset(); - SN76489_Reset(0); + /* Hard reset */ + gen_reset (1); + vdp_reset (); + render_reset (); + io_reset(); + SN76489_Reset(0); - /* Sound buffers reset */ - memset (snd.psg.buffer, 0, SND_SIZE); - memset (snd.fm.buffer[0], 0, SND_SIZE*2); - memset (snd.fm.buffer[1], 0, SND_SIZE*2); + /* Sound buffers reset */ + memset (snd.psg.buffer, 0, SND_SIZE); + memset (snd.fm.buffer[0], 0, SND_SIZE*2); + memset (snd.fm.buffer[1], 0, SND_SIZE*2); } /**************************************************************** @@ -95,9 +95,9 @@ void system_reset (void) ****************************************************************/ void system_shutdown (void) { - gen_shutdown (); - vdp_shutdown (); - render_shutdown (); + gen_shutdown (); + vdp_shutdown (); + render_shutdown (); } /**************************************************************** @@ -105,19 +105,19 @@ void system_shutdown (void) ****************************************************************/ int system_frame (int do_skip) { - if (!gen_running) + if (!gen_running) { update_input(); return 0; - } - - /* reset cycles counts */ - count_m68k = 0; - aim_m68k = 0; - aim_z80 = 0; - count_z80 = 0; - fifo_write_cnt = 0; - fifo_lastwrite = 0; + } + + /* reset cycles counts */ + count_m68k = 0; + aim_m68k = 0; + aim_z80 = 0; + count_z80 = 0; + fifo_write_cnt = 0; + fifo_lastwrite = 0; /* update display settings */ int line; @@ -125,48 +125,48 @@ int system_frame (int do_skip) int vdp_height = bitmap.viewport.h; int end_line = vdp_height + bitmap.viewport.y; int start_line = lines_per_frame - bitmap.viewport.y; - int old_interlaced = interlaced; + int old_interlaced = interlaced; interlaced = (reg[12] & 2) >> 1; - if (old_interlaced != interlaced) + if (old_interlaced != interlaced) { - bitmap.viewport.changed = 2; + bitmap.viewport.changed = 2; im2_flag = ((reg[12] & 6) == 6); - odd_frame = 1; - } + odd_frame = 1; + } odd_frame ^= 1; /* clear VBLANK and DMA flags */ status &= 0xFFF5; - + /* even/odd field flag (interlaced modes only) */ if (odd_frame && interlaced) status |= 0x0010; else status &= 0xFFEF; - /* reload HCounter */ - int h_counter = reg[10]; + /* reload HCounter */ + int h_counter = reg[10]; /* parse sprites for line 0 (done on last line) */ - parse_satb (0x80); + parse_satb (0x80); - /* process frame */ - for (line = 0; line < lines_per_frame; line ++) - { + /* process frame */ + for (line = 0; line < lines_per_frame; line ++) + { /* update VCounter */ - v_counter = line; + v_counter = line; - /* update 6-Buttons or Menacer */ - input_update(); + /* update 6-Buttons or Menacer */ + input_update(); - /* update CPU cycle counters */ + /* update CPU cycle counters */ hint_m68k = count_m68k; line_m68k = aim_m68k; - line_z80 = aim_z80; + line_z80 = aim_z80; aim_z80 += z80cycles_per_line; aim_m68k += m68cycles_per_line; - /* Soft Reset ? */ - if (line == reset) + /* Soft Reset ? */ + if (line == reset) { #ifdef NGC /* wait for RESET button to be released */ @@ -177,14 +177,14 @@ int system_frame (int do_skip) /* active display */ if (line <= vdp_height) - { - /* H Interrupt */ + { + /* H Interrupt */ if(--h_counter < 0) - { - h_counter = reg[10]; - hint_pending = 1; + { + h_counter = reg[10]; + hint_pending = 1; if (reg[0] & 0x10) irq_status = (irq_status & 0xff) | 0x14; - + /* adjust timings to take further decrement in account (see below) */ if ((line != 0) || (h_counter == 0)) aim_m68k += 36; } @@ -198,9 +198,9 @@ int system_frame (int do_skip) /* update DMA timings */ if (dma_length) dma_update(); - /* vertical retrace */ + /* vertical retrace */ if (line == vdp_height) - { + { /* render overscan */ if ((line < end_line) && (!do_skip)) render_line(line, 1); @@ -211,9 +211,9 @@ int system_frame (int do_skip) status |= 0x08; /* Z80 interrupt is 16ms period (one frame) and 64us length (one scanline) */ - zirq = 1; - z80_set_irq_line(0, ASSERT_LINE); - + zirq = 1; + z80_set_irq_line(0, ASSERT_LINE); + /* delay between HINT, VBLANK and VINT (Dracula, OutRunners, VR Troopers) */ m68k_run(line_m68k + 84); if (zreset && !zbusreq) @@ -223,7 +223,7 @@ int system_frame (int do_skip) } else count_z80 = line_z80 + 39; - /* V Interrupt */ + /* V Interrupt */ status |= 0x80; vint_pending = 1; @@ -235,7 +235,7 @@ int system_frame (int do_skip) /* render scanline and parse sprites for line n+1 */ render_line(line, 0); if (line < (vdp_height-1)) parse_satb(0x81 + line); - } + } } else { @@ -253,57 +253,57 @@ int system_frame (int do_skip) } } - /* process line */ - m68k_run(aim_m68k); - if (zreset == 1 && zbusreq == 0) + /* process line */ + m68k_run(aim_m68k); + if (zreset == 1 && zbusreq == 0) { current_z80 = aim_z80 - count_z80; if (current_z80 > 0) count_z80 += z80_execute(current_z80); - } - else count_z80 = aim_z80; - - /* SVP chip */ - if (svp) ssp1601_run(SVP_cycles); - } + } + else count_z80 = aim_z80; + + /* SVP chip */ + if (svp) ssp1601_run(SVP_cycles); + } - audio_update (); - - return gen_running; + audio_update (); + + return gen_running; } /**************************************************************** - * Audio System + * Audio System ****************************************************************/ int audio_init (int rate) { - /* Shutdown first */ + /* Shutdown first */ audio_shutdown(); - /* Clear the sound data context */ - memset (&snd, 0, sizeof (snd)); + /* Clear the sound data context */ + memset (&snd, 0, sizeof (snd)); - /* Make sure the requested sample rate is valid */ - if (!rate || ((rate < 8000) | (rate > 48000))) return (-1); - snd.sample_rate = rate; - - /* Calculate the sound buffer size (for one frame) */ - snd.buffer_size = (rate / vdp_rate); + /* Make sure the requested sample rate is valid */ + if (!rate || ((rate < 8000) | (rate > 48000))) return (-1); + snd.sample_rate = rate; + + /* Calculate the sound buffer size (for one frame) */ + snd.buffer_size = (rate / vdp_rate); #ifdef DOS /* output buffers */ snd.buffer[0] = (int16 *) malloc(SND_SIZE); - snd.buffer[1] = (int16 *) malloc(SND_SIZE); - if (!snd.buffer[0] || !snd.buffer[1]) return (-1); - memset (snd.buffer[0], 0, SND_SIZE); - memset (snd.buffer[1], 0, SND_SIZE); + snd.buffer[1] = (int16 *) malloc(SND_SIZE); + if (!snd.buffer[0] || !snd.buffer[1]) return (-1); + memset (snd.buffer[0], 0, SND_SIZE); + memset (snd.buffer[1], 0, SND_SIZE); #endif /* YM2612 stream buffers */ snd.fm.buffer[0] = (int *)malloc (SND_SIZE*2); - snd.fm.buffer[1] = (int *)malloc (SND_SIZE*2); - if (!snd.fm.buffer[0] || !snd.fm.buffer[1]) return (-1); - memset (snd.fm.buffer[0], 0, SND_SIZE*2); - memset (snd.fm.buffer[1], 0, SND_SIZE*2); + snd.fm.buffer[1] = (int *)malloc (SND_SIZE*2); + if (!snd.fm.buffer[0] || !snd.fm.buffer[1]) return (-1); + memset (snd.fm.buffer[0], 0, SND_SIZE*2); + memset (snd.fm.buffer[1], 0, SND_SIZE*2); /* SRC buffers */ if (config.hq_fm && !config.fm_core) @@ -312,23 +312,23 @@ int audio_init (int rate) if (!snd.fm.src_out) return (-1); } - /* SN76489 stream buffers */ + /* SN76489 stream buffers */ snd.psg.buffer = (int16 *)malloc (SND_SIZE); - if (!snd.psg.buffer) return (-1); - memset (snd.psg.buffer, 0, SND_SIZE); + if (!snd.psg.buffer) return (-1); + memset (snd.psg.buffer, 0, SND_SIZE); - /* Set audio enable flag */ - snd.enabled = 1; + /* Set audio enable flag */ + snd.enabled = 1; - /* Initialize Sound Chips emulation */ - sound_init(rate); + /* Initialize Sound Chips emulation */ + sound_init(rate); - return (0); + return (0); } void audio_shutdown(void) { - /* free sound buffers */ + /* free sound buffers */ if (snd.buffer[0]) free(snd.buffer[0]); if (snd.buffer[1]) free(snd.buffer[1]); if (snd.fm.buffer[0]) free(snd.fm.buffer[0]); @@ -341,7 +341,7 @@ static int ll, rr; static inline void audio_update (void) { - int i; + int i; int l, r; double psg_preamp = config.psg_preamp; double fm_preamp = config.fm_preamp; @@ -349,56 +349,56 @@ static inline void audio_update (void) int filter = config.filter; #ifndef DOS - int16 *sb = (int16 *) soundbuffer[mixbuffer]; + int16 *sb = (int16 *) soundbuffer[mixbuffer]; #endif - /* get remaining samples */ - sound_update(); + /* get remaining samples */ + sound_update(); - /* mix samples */ - for (i = 0; i < snd.buffer_size; i ++) - { - l = r = (int) ((double)snd.psg.buffer[i] * psg_preamp); - l += (int) ((double)snd.fm.buffer[0][i] * fm_preamp); - r += (int) ((double)snd.fm.buffer[1][i] * fm_preamp); - snd.fm.buffer[0][i] = 0; - snd.fm.buffer[1][i] = 0; - snd.psg.buffer[i] = 0; + /* mix samples */ + for (i = 0; i < snd.buffer_size; i ++) + { + l = r = (int) ((double)snd.psg.buffer[i] * psg_preamp); + l += (int) ((double)snd.fm.buffer[0][i] * fm_preamp); + r += (int) ((double)snd.fm.buffer[1][i] * fm_preamp); + snd.fm.buffer[0][i] = 0; + snd.fm.buffer[1][i] = 0; + snd.psg.buffer[i] = 0; /* single-pole low-pass filter (6 dB/octave) */ - if (filter) - { + if (filter) + { l = (ll + l) >> 1; - r = (rr + r) >> 1; + r = (rr + r) >> 1; ll = l; rr = r; } /* boost volume if asked*/ - l = l * boost; - r = r * boost; + l = l * boost; + r = r * boost; - /* clipping */ - if (l > 32767) l = 32767; - else if (l < -32768) l = -32768; - if (r > 32767) r = 32767; - else if (r < -32768) r = -32768; + /* clipping */ + if (l > 32767) l = 32767; + else if (l < -32768) l = -32768; + if (r > 32767) r = 32767; + else if (r < -32768) r = -32768; - /* update sound buffer */ + /* update sound buffer */ #ifdef DOS - snd.buffer[0][i] = l; - snd.buffer[1][i] = r; + snd.buffer[0][i] = l; + snd.buffer[1][i] = r; #elif LSB_FIRST - *sb++ = l; - *sb++ = r; + *sb++ = l; + *sb++ = r; #else *sb++ = r; - *sb++ = l; + *sb++ = l; #endif - } + } #ifndef DOS - mixbuffer++; - mixbuffer &= 0xf; + mixbuffer++; + mixbuffer &= 0xf; #endif } diff --git a/source/system.h b/source/system.h index b90f087..b251d63 100644 --- a/source/system.h +++ b/source/system.h @@ -35,38 +35,38 @@ typedef struct { - uint8 *data; /* Bitmap data */ - int width; /* Bitmap width (32+512+32) */ - int height; /* Bitmap height (256) */ - int depth; /* Color depth (8 bits) */ - int pitch; /* Width of bitmap in bytes */ - int granularity; /* Size of each pixel in bytes */ - int remap; /* 1= Translate pixel data */ + uint8 *data; /* Bitmap data */ + int width; /* Bitmap width (32+512+32) */ + int height; /* Bitmap height (256) */ + int depth; /* Color depth (8 bits) */ + int pitch; /* Width of bitmap in bytes */ + int granularity; /* Size of each pixel in bytes */ + int remap; /* 1= Translate pixel data */ struct { - int x; /* X offset of viewport within bitmap */ - int y; /* Y offset of viewport within bitmap */ - int w; /* Width of viewport */ - int h; /* Height of viewport */ - int ow; /* Previous width of viewport */ - int oh; /* Previous height of viewport */ - int changed; /* 1= Viewport width or height have changed */ + int x; /* X offset of viewport within bitmap */ + int y; /* Y offset of viewport within bitmap */ + int w; /* Width of viewport */ + int h; /* Height of viewport */ + int ow; /* Previous width of viewport */ + int oh; /* Previous height of viewport */ + int changed; /* 1= Viewport width or height have changed */ } viewport; } t_bitmap; typedef struct { - int sample_rate; /* Sample rate (8000-48000) */ - int enabled; /* 1= sound emulation is enabled */ - int buffer_size; /* Size of sound buffer (in bytes) */ - int16 *buffer[2]; /* Signed 16-bit stereo sound data */ + int sample_rate; /* Sample rate (8000-48000) */ + int enabled; /* 1= sound emulation is enabled */ + int buffer_size; /* Size of sound buffer (in bytes) */ + int16 *buffer[2]; /* Signed 16-bit stereo sound data */ struct { int curStage; int lastStage; int *buffer[2]; - float *src_out; /* SRC conversion buffer */ + float *src_out; /* SRC conversion buffer */ } fm; struct { diff --git a/source/unzip.c b/source/unzip.c index cb68299..f9bc46a 100644 --- a/source/unzip.c +++ b/source/unzip.c @@ -12,19 +12,19 @@ #include "unzip.h" #ifdef STDC -# include -# include -# include +#include +#include +#include #endif #ifdef NO_ERRNO_H - extern int errno; +extern int errno; #else -# include +#include #endif #ifndef local -# define local static +#define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ @@ -82,23 +82,23 @@ typedef struct unz_file_info_internal_s when reading and decompress it */ typedef struct { - char *read_buffer; /* internal buffer for compressed data */ - z_stream stream; /* zLib stream structure for inflate */ + char *read_buffer; /* internal buffer for compressed data */ + z_stream stream; /* zLib stream structure for inflate */ - uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ + uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ + uLong stream_initialised; /* flag set if stream structure is initialised*/ - uLong offset_local_extrafield;/* offset of the local extra field */ - uInt size_local_extrafield;/* size of the local extra field */ - uLong pos_local_extrafield; /* position in the local extra field in read*/ + uLong offset_local_extrafield;/* offset of the local extra field */ + uInt size_local_extrafield;/* size of the local extra field */ + uLong pos_local_extrafield; /* position in the local extra field in read*/ - uLong crc32; /* crc32 of all data uncompressed */ - uLong crc32_wait; /* crc32 we must obtain after decompress all */ - uLong rest_read_compressed; /* number of byte to be decompressed */ - uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ - FILE* file; /* io structore of the zipfile */ - uLong compression_method; /* compression method (0==store) */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + uLong crc32; /* crc32 of all data uncompressed */ + uLong crc32_wait; /* crc32 we must obtain after decompress all */ + uLong rest_read_compressed; /* number of byte to be decompressed */ + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + FILE* file; /* io structore of the zipfile */ + uLong compression_method; /* compression method (0==store) */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ } file_in_zip_read_info_s; @@ -106,22 +106,22 @@ typedef struct */ typedef struct { - FILE* file; /* io structore of the zipfile */ - unz_global_info gi; /* public global information */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - uLong num_file; /* number of the current file in the zipfile*/ - uLong pos_in_central_dir; /* pos of the current file in the central dir*/ - uLong current_file_ok; /* flag about the usability of the current file*/ - uLong central_pos; /* position of the beginning of the central dir*/ + FILE* file; /* io structore of the zipfile */ + unz_global_info gi; /* public global information */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + uLong num_file; /* number of the current file in the zipfile*/ + uLong pos_in_central_dir; /* pos of the current file in the central dir*/ + uLong current_file_ok; /* flag about the usability of the current file*/ + uLong central_pos; /* position of the beginning of the central dir*/ - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory with - respect to the starting disk number */ + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory with + respect to the starting disk number */ - unz_file_info cur_file_info; /* public info about the current file in zip*/ - unz_file_info_internal cur_file_info_internal; /* private info about it*/ + unz_file_info cur_file_info; /* public info about the current file in zip*/ + unz_file_info_internal cur_file_info_internal; /* private info about it*/ file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current - file if we are decompressing it */ + file if we are decompressing it */ } unz_s; @@ -133,11 +133,11 @@ typedef struct local int unzlocal_getByte(fin,pi) - FILE *fin; - int *pi; + FILE *fin; + int *pi; { unsigned char c; - int err = fread(&c, 1, 1, fin); + int err = fread(&c, 1, 1, fin); if (err==1) { *pi = (int)c; @@ -157,7 +157,7 @@ local int unzlocal_getByte(fin,pi) Reads a long in LSB order from the given gz_stream. Sets */ local int unzlocal_getShort (fin,pX) - FILE* fin; + FILE* fin; uLong *pX; { uLong x ; @@ -179,7 +179,7 @@ local int unzlocal_getShort (fin,pX) } local int unzlocal_getLong (fin,pX) - FILE* fin; + FILE* fin; uLong *pX; { uLong x ; @@ -211,26 +211,26 @@ local int unzlocal_getLong (fin,pX) /* My own strcmpi / strcasecmp */ local int strcmpcasenosensitive_internal (fileName1,fileName2) - const char* fileName1; - const char* fileName2; + const char* fileName1; + const char* fileName2; { - for (;;) - { - char c1=*(fileName1++); - char c2=*(fileName2++); - if ((c1>='a') && (c1<='z')) - c1 -= 0x20; - if ((c2>='a') && (c2<='z')) - c2 -= 0x20; - if (c1=='\0') - return ((c2=='\0') ? 0 : -1); - if (c2=='\0') - return 1; - if (c1c2) - return 1; - } + for (;;) + { + char c1=*(fileName1++); + char c2=*(fileName2++); + if ((c1>='a') && (c1<='z')) + c1 -= 0x20; + if ((c2>='a') && (c2<='z')) + c2 -= 0x20; + if (c1=='\0') + return ((c2=='\0') ? 0 : -1); + if (c2=='\0') + return 1; + if (c1c2) + return 1; + } } @@ -254,17 +254,17 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2) */ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) - const char* fileName1; - const char* fileName2; - int iCaseSensitivity; + const char* fileName1; + const char* fileName2; + int iCaseSensitivity; { - if (iCaseSensitivity==0) - iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; + if (iCaseSensitivity==0) + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; - if (iCaseSensitivity==1) - return strcmp(fileName1,fileName2); + if (iCaseSensitivity==1) + return strcmp(fileName1,fileName2); - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); } #define BUFREADCOMMENT (0x400) @@ -274,161 +274,161 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit the global comment) */ local uLong unzlocal_SearchCentralDir(fin) - FILE *fin; + FILE *fin; { - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; - - if (fseek(fin,0,SEEK_END) != 0) - return 0; + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (fseek(fin,0,SEEK_END) != 0) + return 0; - uSizeFile = ftell( fin ); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; + uSizeFile = ftell( fin ); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (fseek(fin,uReadPos,SEEK_SET)!=0) - break; + if (fseek(fin,uReadPos,SEEK_SET)!=0) + break; - if (fread(buf,(uInt)uReadSize,1,fin)!=1) - break; + if (fread(buf,(uInt)uReadSize,1,fin)!=1) + break; for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+i; - break; - } + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; } /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer - "zlib/zlib109.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. + "zlib/zlib109.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. Else, the return value is a unzFile Handle, usable with other function - of this unzip package. + of this unzip package. */ extern unzFile ZEXPORT unzOpen (path) - const char *path; + const char *path; { - unz_s us; - unz_s *s; - uLong central_pos,uL; - FILE * fin ; + unz_s us; + unz_s *s; + uLong central_pos,uL; + FILE * fin ; - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - uLong number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + uLong number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ - int err=UNZ_OK; + int err=UNZ_OK; if (unz_copyright[0]!=' ') return NULL; fin=fopen(path,"rb"); - if (fin==NULL) - return NULL; + if (fin==NULL) + return NULL; - central_pos = unzlocal_SearchCentralDir(fin); - if (central_pos==0) - err=UNZ_ERRNO; + central_pos = unzlocal_SearchCentralDir(fin); + if (central_pos==0) + err=UNZ_ERRNO; - if (fseek(fin,central_pos,SEEK_SET)!=0) - err=UNZ_ERRNO; + if (fseek(fin,central_pos,SEEK_SET)!=0) + err=UNZ_ERRNO; - /* the signature, already checked */ - if (unzlocal_getLong(fin,&uL)!=UNZ_OK) - err=UNZ_ERRNO; + /* the signature, already checked */ + if (unzlocal_getLong(fin,&uL)!=UNZ_OK) + err=UNZ_ERRNO; - /* number of this disk */ - if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; + /* number of this disk */ + if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; - /* number of the disk with the start of the central directory */ - if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; + /* number of the disk with the start of the central directory */ + if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; - /* total number of entries in the central dir on this disk */ - if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) - err=UNZ_ERRNO; + /* total number of entries in the central dir on this disk */ + if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) + err=UNZ_ERRNO; - /* total number of entries in the central dir */ - if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) - err=UNZ_ERRNO; + /* total number of entries in the central dir */ + if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) + err=UNZ_ERRNO; - if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=UNZ_BADZIPFILE; + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; - /* size of the central directory */ - if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; + /* size of the central directory */ + if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; - /* offset of start of central directory with respect to the - starting disk number */ - if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; + /* offset of start of central directory with respect to the + starting disk number */ + if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; - /* zipfile comment length */ - if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) - err=UNZ_ERRNO; + /* zipfile comment length */ + if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) + err=UNZ_ERRNO; - if ((central_pospfile_in_zip_read!=NULL) unzCloseCurrentFile(file); - fclose(s->file); - TRYFREE(s); - return UNZ_OK; + fclose(s->file); + TRYFREE(s); + return UNZ_OK; } @@ -459,15 +459,15 @@ extern int ZEXPORT unzClose (file) No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) - unzFile file; - unz_global_info *pglobal_info; + unzFile file; + unz_global_info *pglobal_info; { - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - *pglobal_info=s->gi; - return UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; } @@ -497,11 +497,11 @@ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, unz_file_info_internal *pfile_info_internal, char *szFileName, - uLong fileNameBufferSize, + uLong fileNameBufferSize, void *extraField, - uLong extraFieldBufferSize, + uLong extraFieldBufferSize, char *szComment, - uLong commentBufferSize)); + uLong commentBufferSize)); local int unzlocal_GetCurrentFileInfoInternal (file, pfile_info, @@ -509,162 +509,162 @@ local int unzlocal_GetCurrentFileInfoInternal (file, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - unz_file_info_internal *pfile_info_internal; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; + unzFile file; + unz_file_info *pfile_info; + unz_file_info_internal *pfile_info_internal; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; { - unz_s* s; - unz_file_info file_info; - unz_file_info_internal file_info_internal; - int err=UNZ_OK; - uLong uMagic; - long lSeek=0; + unz_s* s; + unz_file_info file_info; + unz_file_info_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) - err=UNZ_ERRNO; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) + err=UNZ_ERRNO; - /* we check the magic */ - if (err==UNZ_OK) + /* we check the magic */ + if (err==UNZ_OK) { - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x02014b50) - err=UNZ_BADZIPFILE; + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; } - if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; - lSeek+=file_info.size_filename; - if ((err==UNZ_OK) && (szFileName!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_filename0) && (fileNameBufferSize>0)) - if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek -= uSizeRead; - } + if ((file_info.size_filename>0) && (fileNameBufferSize>0)) + if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek -= uSizeRead; + } - - if ((err==UNZ_OK) && (extraField!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_extrafile,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; + lSeek=0; + else + err=UNZ_ERRNO; } - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) - if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek += file_info.size_file_extra - uSizeRead; - } - else - lSeek+=file_info.size_file_extra; + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek += file_info.size_file_extra - uSizeRead; + } + else + lSeek+=file_info.size_file_extra; - - if ((err==UNZ_OK) && (szComment!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_commentfile,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; + lSeek=0; + else + err=UNZ_ERRNO; } - if ((file_info.size_file_comment>0) && (commentBufferSize>0)) - if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek+=file_info.size_file_comment - uSizeRead; - } - else - lSeek+=file_info.size_file_comment; + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek+=file_info.size_file_comment - uSizeRead; + } + else + lSeek+=file_info.size_file_comment; - if ((err==UNZ_OK) && (pfile_info!=NULL)) - *pfile_info=file_info; + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; - if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) - *pfile_info_internal=file_info_internal; + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; - return err; + return err; } @@ -679,19 +679,19 @@ extern int ZEXPORT unzGetCurrentFileInfo (file, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; + unzFile file; + unz_file_info *pfile_info; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; { - return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, - szFileName,fileNameBufferSize, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); + return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); } /* @@ -699,20 +699,20 @@ extern int ZEXPORT unzGetCurrentFileInfo (file, return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToFirstFile (file) - unzFile file; + unzFile file; { - int err=UNZ_OK; - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - s->pos_in_central_dir=s->offset_central_dir; - s->num_file=0; - err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; + int err=UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; } @@ -722,27 +722,27 @@ extern int ZEXPORT unzGoToFirstFile (file) return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzGoToNextFile (file) - unzFile file; + unzFile file; { - unz_s* s; - int err; + unz_s* s; + int err; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - if (s->num_file+1==s->gi.number_entry) - return UNZ_END_OF_LIST_OF_FILE; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; - s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; - s->num_file++; - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; } @@ -755,48 +755,48 @@ extern int ZEXPORT unzGoToNextFile (file) UNZ_END_OF_LIST_OF_FILE if the file is not found */ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) - unzFile file; - const char *szFileName; - int iCaseSensitivity; + unzFile file; + const char *szFileName; + int iCaseSensitivity; { - unz_s* s; - int err; + unz_s* s; + int err; - - uLong num_fileSaved; - uLong pos_in_central_dirSaved; + + uLong num_fileSaved; + uLong pos_in_central_dirSaved; - if (file==NULL) - return UNZ_PARAMERROR; + if (file==NULL) + return UNZ_PARAMERROR; if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; - num_fileSaved = s->num_file; - pos_in_central_dirSaved = s->pos_in_central_dir; + num_fileSaved = s->num_file; + pos_in_central_dirSaved = s->pos_in_central_dir; - err = unzGoToFirstFile(file); + err = unzGoToFirstFile(file); - while (err == UNZ_OK) - { - char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; - unzGetCurrentFileInfo(file,NULL, - szCurrentFileName,sizeof(szCurrentFileName)-1, - NULL,0,NULL,0); - if (unzStringFileNameCompare(szCurrentFileName, - szFileName,iCaseSensitivity)==0) - return UNZ_OK; - err = unzGoToNextFile(file); - } + while (err == UNZ_OK) + { + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; + unzGetCurrentFileInfo(file,NULL, + szCurrentFileName,sizeof(szCurrentFileName)-1, + NULL,0,NULL,0); + if (unzStringFileNameCompare(szCurrentFileName, + szFileName,iCaseSensitivity)==0) + return UNZ_OK; + err = unzGoToNextFile(file); + } - s->num_file = num_fileSaved ; - s->pos_in_central_dir = pos_in_central_dirSaved ; - return err; + s->num_file = num_fileSaved ; + s->pos_in_central_dir = pos_in_central_dirSaved ; + return err; } @@ -808,162 +808,162 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) (filename and size of extra field data) */ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, - poffset_local_extrafield, - psize_local_extrafield) - unz_s* s; - uInt* piSizeVar; - uLong *poffset_local_extrafield; - uInt *psize_local_extrafield; + poffset_local_extrafield, + psize_local_extrafield) + unz_s* s; + uInt* piSizeVar; + uLong *poffset_local_extrafield; + uInt *psize_local_extrafield; { - uLong uMagic,uData,uFlags; - uLong size_filename; - uLong size_extra_field; - int err=UNZ_OK; + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; - *piSizeVar = 0; - *poffset_local_extrafield = 0; - *psize_local_extrafield = 0; + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; - if (fseek(s->file,s->cur_file_info_internal.offset_curfile + - s->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; + if (fseek(s->file,s->cur_file_info_internal.offset_curfile + + s->byte_before_the_zipfile,SEEK_SET)!=0) + return UNZ_ERRNO; - if (err==UNZ_OK) + if (err==UNZ_OK) { if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x04034b50) - err=UNZ_BADZIPFILE; + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; } - if (unzlocal_getShort(s->file,&uData) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; /* - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) - err=UNZ_BADZIPFILE; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) + err=UNZ_BADZIPFILE; */ - if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&uData) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) - err=UNZ_BADZIPFILE; + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ - err=UNZ_ERRNO; + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ + err=UNZ_ERRNO; - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; - if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) - err=UNZ_BADZIPFILE; + if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; - *piSizeVar += (uInt)size_filename; + *piSizeVar += (uInt)size_filename; - if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) - err=UNZ_ERRNO; - *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + - SIZEZIPLOCALHEADER + size_filename; - *psize_local_extrafield = (uInt)size_extra_field; + if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; - *piSizeVar += (uInt)size_extra_field; + *piSizeVar += (uInt)size_extra_field; - return err; + return err; } - + /* Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ extern int ZEXPORT unzOpenCurrentFile (file) - unzFile file; + unzFile file; { - int err=UNZ_OK; - int Store; - uInt iSizeVar; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uLong offset_local_extrafield; /* offset of the local extra field */ - uInt size_local_extrafield; /* size of the local extra field */ + int err=UNZ_OK; + int Store; + uInt iSizeVar; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uLong offset_local_extrafield; /* offset of the local extra field */ + uInt size_local_extrafield; /* size of the local extra field */ - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_PARAMERROR; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; if (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) - return UNZ_BADZIPFILE; + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; - pfile_in_zip_read_info = (file_in_zip_read_info_s*) - ALLOC(sizeof(file_in_zip_read_info_s)); - if (pfile_in_zip_read_info==NULL) - return UNZ_INTERNALERROR; + pfile_in_zip_read_info = (file_in_zip_read_info_s*) + ALLOC(sizeof(file_in_zip_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); - pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; - pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; - pfile_in_zip_read_info->pos_local_extrafield=0; + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; - if (pfile_in_zip_read_info->read_buffer==NULL) - { - TRYFREE(pfile_in_zip_read_info); - return UNZ_INTERNALERROR; - } + if (pfile_in_zip_read_info->read_buffer==NULL) + { + TRYFREE(pfile_in_zip_read_info); + return UNZ_INTERNALERROR; + } - pfile_in_zip_read_info->stream_initialised=0; - - if ((s->cur_file_info.compression_method!=0) && + pfile_in_zip_read_info->stream_initialised=0; + + if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - Store = s->cur_file_info.compression_method==0; + err=UNZ_BADZIPFILE; + Store = s->cur_file_info.compression_method==0; - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; - pfile_in_zip_read_info->crc32=0; - pfile_in_zip_read_info->compression_method = + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; - pfile_in_zip_read_info->file=s->file; - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + pfile_in_zip_read_info->file=s->file; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; pfile_in_zip_read_info->stream.total_out = 0; - if (!Store) - { - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; - pfile_in_zip_read_info->stream.zfree = (free_func)0; - pfile_in_zip_read_info->stream.opaque = (voidpf)0; + if (!Store) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=1; + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and @@ -971,21 +971,21 @@ extern int ZEXPORT unzOpenCurrentFile (file) * In unzip, i don't wait absolutely Z_STREAM_END because I known the * size of both compressed and uncompressed data */ - } - pfile_in_zip_read_info->rest_read_compressed = + } + pfile_in_zip_read_info->rest_read_compressed = s->cur_file_info.compressed_size ; - pfile_in_zip_read_info->rest_read_uncompressed = + pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size ; - - pfile_in_zip_read_info->pos_in_zipfile = + + pfile_in_zip_read_info->pos_in_zipfile = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + - iSizeVar; - - pfile_in_zip_read_info->stream.avail_in = (uInt)0; + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; - s->pfile_in_zip_read = pfile_in_zip_read_info; + s->pfile_in_zip_read = pfile_in_zip_read_info; return UNZ_OK; } @@ -1001,126 +1001,126 @@ extern int ZEXPORT unzOpenCurrentFile (file) (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern int ZEXPORT unzReadCurrentFile (file, buf, len) - unzFile file; - voidp buf; - unsigned len; + unzFile file; + voidp buf; + unsigned len; { - int err=UNZ_OK; - uInt iRead = 0; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + int err=UNZ_OK; + uInt iRead = 0; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; - if ((pfile_in_zip_read_info->read_buffer == NULL)) - return UNZ_END_OF_LIST_OF_FILE; - if (len==0) - return 0; + if ((pfile_in_zip_read_info->read_buffer == NULL)) + return UNZ_END_OF_LIST_OF_FILE; + if (len==0) + return 0; - pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; - pfile_in_zip_read_info->stream.avail_out = (uInt)len; - - if (len>pfile_in_zip_read_info->rest_read_uncompressed) - pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if (len>pfile_in_zip_read_info->rest_read_uncompressed) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; - while (pfile_in_zip_read_info->stream.avail_out>0) - { - if ((pfile_in_zip_read_info->stream.avail_in==0) && + while (pfile_in_zip_read_info->stream.avail_out>0) + { + if ((pfile_in_zip_read_info->stream.avail_in==0) && (pfile_in_zip_read_info->rest_read_compressed>0)) - { - uInt uReadThis = UNZ_BUFSIZE; - if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; - if (uReadThis == 0) - return UNZ_EOF; - if (fseek(pfile_in_zip_read_info->file, + { + uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; + if (uReadThis == 0) + return UNZ_EOF; + if (fseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; - if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, + return UNZ_ERRNO; + if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, pfile_in_zip_read_info->file)!=1) - return UNZ_ERRNO; - pfile_in_zip_read_info->pos_in_zipfile += uReadThis; + return UNZ_ERRNO; + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; - pfile_in_zip_read_info->rest_read_compressed-=uReadThis; - - pfile_in_zip_read_info->stream.next_in = + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + + pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->read_buffer; - pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; - } + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } - if (pfile_in_zip_read_info->compression_method==0) - { - uInt uDoCopy,i ; - if (pfile_in_zip_read_info->stream.avail_out < + if (pfile_in_zip_read_info->compression_method==0) + { + uInt uDoCopy,i ; + if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) - uDoCopy = pfile_in_zip_read_info->stream.avail_out ; - else - uDoCopy = pfile_in_zip_read_info->stream.avail_in ; - - for (i=0;istream.next_out+i) = + uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + else + uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + + for (i=0;istream.next_out+i) = *(pfile_in_zip_read_info->stream.next_in+i); - - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, - pfile_in_zip_read_info->stream.next_out, - uDoCopy); - pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; - pfile_in_zip_read_info->stream.avail_in -= uDoCopy; - pfile_in_zip_read_info->stream.avail_out -= uDoCopy; - pfile_in_zip_read_info->stream.next_out += uDoCopy; - pfile_in_zip_read_info->stream.next_in += uDoCopy; + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, + pfile_in_zip_read_info->stream.next_out, + uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; pfile_in_zip_read_info->stream.total_out += uDoCopy; - iRead += uDoCopy; - } - else - { - uLong uTotalOutBefore,uTotalOutAfter; - const Bytef *bufBefore; - uLong uOutThis; - int flush=Z_SYNC_FLUSH; + iRead += uDoCopy; + } + else + { + uLong uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + uLong uOutThis; + int flush=Z_SYNC_FLUSH; - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; - bufBefore = pfile_in_zip_read_info->stream.next_out; + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; - /* - if ((pfile_in_zip_read_info->rest_read_uncompressed == - pfile_in_zip_read_info->stream.avail_out) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - flush = Z_FINISH; - */ - err=inflate(&pfile_in_zip_read_info->stream,flush); + /* + if ((pfile_in_zip_read_info->rest_read_uncompressed == + pfile_in_zip_read_info->stream.avail_out) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + flush = Z_FINISH; + */ + err=inflate(&pfile_in_zip_read_info->stream,flush); - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; - uOutThis = uTotalOutAfter-uTotalOutBefore; - - pfile_in_zip_read_info->crc32 = + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); - pfile_in_zip_read_info->rest_read_uncompressed -= + pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); - if (err==Z_STREAM_END) - return (iRead==0) ? UNZ_EOF : iRead; - if (err!=Z_OK) - break; - } - } + if (err==Z_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=Z_OK) + break; + } + } - if (err==Z_OK) - return iRead; - return err; + if (err==Z_OK) + return iRead; + return err; } @@ -1128,19 +1128,19 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) Give the current position in uncompressed data */ extern z_off_t ZEXPORT unztell (file) - unzFile file; + unzFile file; { - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; - return (z_off_t)pfile_in_zip_read_info->stream.total_out; + return (z_off_t)pfile_in_zip_read_info->stream.total_out; } @@ -1148,22 +1148,22 @@ extern z_off_t ZEXPORT unztell (file) return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzeof (file) - unzFile file; + unzFile file; { - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - return 1; - else - return 0; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + return 1; + else + return 0; } @@ -1176,51 +1176,51 @@ extern int ZEXPORT unzeof (file) if buf==NULL, it return the size of the local extra field that can be read if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. + buf. the return value is the number of bytes copied in buf, or (if <0) - the error code + the error code */ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) - unzFile file; - voidp buf; - unsigned len; + unzFile file; + voidp buf; + unsigned len; { - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uInt read_now; - uLong size_to_read; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uInt read_now; + uLong size_to_read; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; - size_to_read = (pfile_in_zip_read_info->size_local_extrafield - - pfile_in_zip_read_info->pos_local_extrafield); + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + pfile_in_zip_read_info->pos_local_extrafield); - if (buf==NULL) - return (int)size_to_read; - - if (len>size_to_read) - read_now = (uInt)size_to_read; - else - read_now = (uInt)len ; + if (buf==NULL) + return (int)size_to_read; + + if (len>size_to_read) + read_now = (uInt)size_to_read; + else + read_now = (uInt)len ; - if (read_now==0) - return 0; - - if (fseek(pfile_in_zip_read_info->file, + if (read_now==0) + return 0; + + if (fseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->offset_local_extrafield + - pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) - return UNZ_ERRNO; + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) + return UNZ_ERRNO; - if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) - return UNZ_ERRNO; + if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) + return UNZ_ERRNO; - return (int)read_now; + return (int)read_now; } /* @@ -1228,39 +1228,39 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzCloseCurrentFile (file) - unzFile file; + unzFile file; { - int err=UNZ_OK; + int err=UNZ_OK; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - { - if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) - err=UNZ_CRCERROR; - } + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } - TRYFREE(pfile_in_zip_read_info->read_buffer); - pfile_in_zip_read_info->read_buffer = NULL; - if (pfile_in_zip_read_info->stream_initialised) - inflateEnd(&pfile_in_zip_read_info->stream); + TRYFREE(pfile_in_zip_read_info->read_buffer); + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised) + inflateEnd(&pfile_in_zip_read_info->stream); - pfile_in_zip_read_info->stream_initialised = 0; - TRYFREE(pfile_in_zip_read_info); + pfile_in_zip_read_info->stream_initialised = 0; + TRYFREE(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; - return err; + return err; } @@ -1270,32 +1270,32 @@ extern int ZEXPORT unzCloseCurrentFile (file) return the number of byte copied or an error code <0 */ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) - unzFile file; - char *szComment; - uLong uSizeBuf; + unzFile file; + char *szComment; + uLong uSizeBuf; { /* int err=UNZ_OK; */ - unz_s* s; - uLong uReadThis ; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + uLong uReadThis ; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; - uReadThis = uSizeBuf; - if (uReadThis>s->gi.size_comment) - uReadThis = s->gi.size_comment; + uReadThis = uSizeBuf; + if (uReadThis>s->gi.size_comment) + uReadThis = s->gi.size_comment; - if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) - return UNZ_ERRNO; + if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) + return UNZ_ERRNO; - if (uReadThis>0) + if (uReadThis>0) { *szComment='\0'; - if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) - return UNZ_ERRNO; + if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) + return UNZ_ERRNO; } - if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) - *(szComment+s->gi.size_comment)='\0'; - return (int)uReadThis; + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) + *(szComment+s->gi.size_comment)='\0'; + return (int)uReadThis; } diff --git a/source/vdp.c b/source/vdp.c index 9ed7208..8e82db2 100644 --- a/source/vdp.c +++ b/source/vdp.c @@ -29,52 +29,52 @@ #define UNPACK_CRAM(d) ((((d)&0x1C0)>>5)|((d)&0x038)<<2|(((d)&0x007)<<9)) /* Mark a pattern as dirty */ -#define MARK_BG_DIRTY(addr) \ -{ \ - name = (addr >> 5) & 0x7FF; \ - if(bg_name_dirty[name] == 0) bg_name_list[bg_list_index++] = name; \ - bg_name_dirty[name] |= (1 << ((addr >> 2) & 0x07)); \ +#define MARK_BG_DIRTY(addr) \ +{ \ + name = (addr >> 5) & 0x7FF; \ + if(bg_name_dirty[name] == 0) bg_name_list[bg_list_index++] = name; \ + bg_name_dirty[name] |= (1 << ((addr >> 2) & 0x07)); \ } /* VDP context */ -uint8 sat[0x400]; /* Internal copy of sprite attribute table */ +uint8 sat[0x400]; /* Internal copy of sprite attribute table */ uint8 vram[0x10000]; /* Video RAM (64Kx8) */ -uint8 cram[0x80]; /* On-chip color RAM (64x9) */ +uint8 cram[0x80]; /* On-chip color RAM (64x9) */ uint8 vsram[0x80]; /* On-chip vertical scroll RAM (40x11) */ -uint8 reg[0x20]; /* Internal VDP registers (23x8) */ +uint8 reg[0x20]; /* Internal VDP registers (23x8) */ uint16 addr; /* Address register */ uint16 addr_latch; /* Latched A15, A14 of address */ uint8 code; /* Code register */ -uint8 pending; /* Pending write flag */ -uint16 status; /* VDP status flags */ -uint8 dmafill; /* next VDP Write is DMA Fill */ +uint8 pending; /* Pending write flag */ +uint16 status; /* VDP status flags */ +uint8 dmafill; /* next VDP Write is DMA Fill */ uint8 hint_pending; /* 0= Line interrupt is pending */ uint8 vint_pending; /* 1= Frame interrupt is pending */ -uint16 irq_status; /* Interrupt lines updated */ +uint16 irq_status; /* Interrupt lines updated */ /* Global variables */ -uint16 ntab; /* Name table A base address */ -uint16 ntbb; /* Name table B base address */ -uint16 ntwb; /* Name table W base address */ -uint16 satb; /* Sprite attribute table base address */ -uint16 hscb; /* Horizontal scroll table base address */ -uint8 border; /* Border color index */ -uint8 bg_name_dirty[0x800]; /* 1= This pattern is dirty */ -uint16 bg_name_list[0x800]; /* List of modified pattern indices */ -uint16 bg_list_index; /* # of modified patterns in list */ -uint8 bg_pattern_cache[0x80000];/* Cached and flipped patterns */ -uint8 playfield_shift; /* Width of planes A, B (in bits) */ -uint8 playfield_col_mask; /* Vertical scroll mask */ -uint16 playfield_row_mask; /* Horizontal scroll mask */ -uint32 y_mask; /* Name table Y-index bits mask */ -uint16 hc_latch; /* latched HCounter (INT2) */ -uint16 v_counter; /* VDP scanline counter */ -uint8 im2_flag; /* 1= Interlace mode 2 is being used */ -uint32 dma_length; /* Current DMA remaining bytes */ -int32 fifo_write_cnt; /* VDP writes fifo count */ -uint32 fifo_lastwrite; /* last VDP write cycle */ -uint8 fifo_latency; /* VDP write cycles latency */ -uint8 vdp_pal = 0; /* 1: PAL , 0: NTSC (default) */ +uint16 ntab; /* Name table A base address */ +uint16 ntbb; /* Name table B base address */ +uint16 ntwb; /* Name table W base address */ +uint16 satb; /* Sprite attribute table base address */ +uint16 hscb; /* Horizontal scroll table base address */ +uint8 border; /* Border color index */ +uint8 bg_name_dirty[0x800]; /* 1= This pattern is dirty */ +uint16 bg_name_list[0x800]; /* List of modified pattern indices */ +uint16 bg_list_index; /* # of modified patterns in list */ +uint8 bg_pattern_cache[0x80000]; /* Cached and flipped patterns */ +uint8 playfield_shift; /* Width of planes A, B (in bits) */ +uint8 playfield_col_mask; /* Vertical scroll mask */ +uint16 playfield_row_mask; /* Horizontal scroll mask */ +uint32 y_mask; /* Name table Y-index bits mask */ +uint16 hc_latch; /* latched HCounter (INT2) */ +uint16 v_counter; /* VDP scanline counter */ +uint8 im2_flag; /* 1= Interlace mode 2 is being used */ +uint32 dma_length; /* Current DMA remaining bytes */ +int32 fifo_write_cnt; /* VDP writes fifo count */ +uint32 fifo_lastwrite; /* last VDP write cycle */ +uint8 fifo_latency; /* VDP write cycles latency */ +uint8 vdp_pal = 0; /* 1: PAL , 0: NTSC (default) */ /* Tables that define the playfield layout */ @@ -83,8 +83,8 @@ static const uint8 col_mask_table[] = { 0x0F, 0x1F, 0x0F, 0x3F }; static const uint16 row_mask_table[] = { 0x0FF, 0x1FF, 0x2FF, 0x3FF }; static const uint32 y_mask_table[] = { 0x1FC0, 0x1F80, 0x1FC0, 0x1F00 }; -static uint16 sat_base_mask; /* Base bits of SAT */ -static uint16 sat_addr_mask; /* Index bits of SAT */ +static uint16 sat_base_mask; /* Base bits of SAT */ +static uint16 sat_addr_mask; /* Index bits of SAT */ static uint32 dma_endCycles; /* 68k cycles to DMA end */ static uint8 dma_type; /* Type of DMA */ static double vdp_timings[4][4]; /* DMA timings */ @@ -120,8 +120,8 @@ static inline void vdp_reg_w(unsigned int r, unsigned int d); */ static const uint8 dma_rates[16] = { 8, 9, 83 , 102, /* 68K to VRAM */ - 16, 18, 167, 205, /* 68K to CRAM or VSRAM */ - 15, 17, 166, 204, /* DMA fill */ + 16, 18, 167, 205, /* 68K to CRAM or VSRAM */ + 15, 17, 166, 204, /* DMA fill */ 8, 9, 83 , 102, /* DMA Copy */ }; @@ -133,95 +133,95 @@ static inline void data_write(unsigned int data); /*--------------------------------------------------------------------------*/ void vdp_init(void) { - int i; - - /* reinitialize DMA timings table */ - for (i=0; i<4; i++) - { - vdp_timings[0][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i]); - vdp_timings[1][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i + 4]); - vdp_timings[2][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i + 8]); - vdp_timings[3][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i + 12]); - } + int i; + + /* reinitialize DMA timings table */ + for (i=0; i<4; i++) + { + vdp_timings[0][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i]); + vdp_timings[1][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i + 4]); + vdp_timings[2][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i + 8]); + vdp_timings[3][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i + 12]); + } } void vdp_reset(void) { - memset ((char *) sat, 0, sizeof (sat)); - memset ((char *) vram, 0, sizeof (vram)); - memset ((char *) cram, 0, sizeof (cram)); - memset ((char *) vsram, 0, sizeof (vsram)); - memset ((char *) reg, 0, sizeof (reg)); + memset ((char *) sat, 0, sizeof (sat)); + memset ((char *) vram, 0, sizeof (vram)); + memset ((char *) cram, 0, sizeof (cram)); + memset ((char *) vsram, 0, sizeof (vsram)); + memset ((char *) reg, 0, sizeof (reg)); - addr = 0; - addr_latch = 0; - code = 0; - pending = 0; + addr = 0; + addr_latch = 0; + code = 0; + pending = 0; - status = 0x200; /* fifo empty */ + status = 0x200; /* fifo empty */ status |= vdp_pal; - ntab = 0; - ntbb = 0; - ntwb = 0; - satb = 0; - hscb = 0; + ntab = 0; + ntbb = 0; + ntwb = 0; + satb = 0; + hscb = 0; sat_base_mask = 0xFE00; sat_addr_mask = 0x01FF; border = 0x00; - memset ((char *) bg_name_dirty, 0, sizeof (bg_name_dirty)); - memset ((char *) bg_name_list, 0, sizeof (bg_name_list)); + memset ((char *) bg_name_dirty, 0, sizeof (bg_name_dirty)); + memset ((char *) bg_name_list, 0, sizeof (bg_name_list)); bg_list_index = 0; - memset ((char *) bg_pattern_cache, 0, sizeof (bg_pattern_cache)); + memset ((char *) bg_pattern_cache, 0, sizeof (bg_pattern_cache)); playfield_shift = 6; - playfield_col_mask = 0x0F; + playfield_col_mask = 0x0F; playfield_row_mask = 0x0FF; y_mask = 0x1FC0; - hint_pending = 0; - vint_pending = 0; - irq_status = 0; + hint_pending = 0; + vint_pending = 0; + irq_status = 0; - hc_latch = 0; - v_counter = 0; + hc_latch = 0; + v_counter = 0; - dmafill = 0; - dma_length = 0; - dma_endCycles = 0; + dmafill = 0; + dma_length = 0; + dma_endCycles = 0; - im2_flag = 0; - interlaced = 0; + im2_flag = 0; + interlaced = 0; - fifo_write_cnt = 0; + fifo_write_cnt = 0; - /* reset HVC tables */ - vctab = (vdp_pal) ? vc_pal_224 : vc_ntsc_224; - hctab = cycle2hc32; + /* reset HVC tables */ + vctab = (vdp_pal) ? vc_pal_224 : vc_ntsc_224; + hctab = cycle2hc32; - /* reset display area */ - bitmap.viewport.w = 256; - bitmap.viewport.h = 224; - bitmap.viewport.oh = 256; - bitmap.viewport.ow = 224; - - /* reset border area */ - bitmap.viewport.x = config.overscan ? 12 : 0; - bitmap.viewport.y = config.overscan ? (vdp_pal ? 32 : 8) : 0; + /* reset display area */ + bitmap.viewport.w = 256; + bitmap.viewport.h = 224; + bitmap.viewport.oh = 256; + bitmap.viewport.ow = 224; + + /* reset border area */ + bitmap.viewport.x = config.overscan ? 12 : 0; + bitmap.viewport.y = config.overscan ? (vdp_pal ? 32 : 8) : 0; bitmap.viewport.changed = 1; - /* initialize some registers (normally set by BIOS) */ - if (config.bios_enabled != 3) - { - vdp_reg_w(1 , 0x04); /* Mode 5 enabled */ - vdp_reg_w(10, 0xff); /* HINT disabled */ - vdp_reg_w(12, 0x81); /* H40 mode */ - vdp_reg_w(15, 0x02); /* auto increment */ + /* initialize some registers (normally set by BIOS) */ + if (config.bios_enabled != 3) + { + vdp_reg_w(1 , 0x04); /* Mode 5 enabled */ + vdp_reg_w(10, 0xff); /* HINT disabled */ + vdp_reg_w(12, 0x81); /* H40 mode */ + vdp_reg_w(15, 0x02); /* auto increment */ window_clip(1,0); - } + } /* default latency */ fifo_latency = 27; @@ -232,37 +232,37 @@ void vdp_shutdown(void) void vdp_restore(uint8 *vdp_regs) { - int i; - - for (i=0;i<0x20;i++) + int i; + + for (i=0;i<0x20;i++) { - vdp_reg_w(i, vdp_regs[i]); - } + vdp_reg_w(i, vdp_regs[i]); + } - /* reinitialize HVC tables */ - vctab = (vdp_pal) ? ((reg[1] & 8) ? vc_pal_240 : vc_pal_224) : vc_ntsc_224; - hctab = (reg[12] & 1) ? cycle2hc40 : cycle2hc32; + /* reinitialize HVC tables */ + vctab = (vdp_pal) ? ((reg[1] & 8) ? vc_pal_240 : vc_pal_224) : vc_ntsc_224; + hctab = (reg[12] & 1) ? cycle2hc40 : cycle2hc32; - /* reinitialize overscan area */ - bitmap.viewport.x = config.overscan ? ((reg[12] & 1) ? 16 : 12) : 0; - bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0; - bitmap.viewport.changed = 1; + /* reinitialize overscan area */ + bitmap.viewport.x = config.overscan ? ((reg[12] & 1) ? 16 : 12) : 0; + bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0; + bitmap.viewport.changed = 1; - /* restore VDP timings */ - fifo_latency = (reg[12] & 1) ? 27 : 30; - if ((code & 0x0F) == 0x01) fifo_latency = fifo_latency * 2; - - /* remake cache */ - for (i=0;i<0x800;i++) + /* restore VDP timings */ + fifo_latency = (reg[12] & 1) ? 27 : 30; + if ((code & 0x0F) == 0x01) fifo_latency = fifo_latency * 2; + + /* remake cache */ + for (i=0;i<0x800;i++) { bg_name_list[i]=i; bg_name_dirty[i]=0xFF; } - bg_list_index=0x800; + bg_list_index=0x800; /* reinitialize palette */ - for(i = 0; i < 0x40; i += 1) color_update(i, *(uint16 *)&cram[i << 1]); - color_update(0x00, *(uint16 *)&cram[border << 1]); + for(i = 0; i < 0x40; i += 1) color_update(i, *(uint16 *)&cram[i << 1]); + color_update(0x00, *(uint16 *)&cram[border << 1]); } /*--------------------------------------------------------------------------*/ @@ -272,48 +272,48 @@ void vdp_restore(uint8 *vdp_regs) /* Update DMA timings (this is call on start of DMA and then at the start of each scanline) */ void dma_update() { - int32 left_cycles; - uint32 dma_cycles, dma_bytes; - uint8 index = 0; + int32 left_cycles; + uint32 dma_cycles, dma_bytes; + uint8 index = 0; - /* get the appropriate tranfer rate (bytes/line) for this DMA operation */ - if ((status&8) || !(reg[1] & 0x40)) index = 2; /* VBLANK or Display OFF */ - index += (reg[12] & 1); /* 32 or 40 Horizontal Cells */ + /* get the appropriate tranfer rate (bytes/line) for this DMA operation */ + if ((status&8) || !(reg[1] & 0x40)) index = 2; /* VBLANK or Display OFF */ + index += (reg[12] & 1); /* 32 or 40 Horizontal Cells */ - /* calculate transfer quantity for the remaining 68k cycles */ - left_cycles = aim_m68k - count_m68k; - if (left_cycles < 0) left_cycles = 0; - dma_bytes = (uint32)(((double)left_cycles / vdp_timings[dma_type][index]) + 0.5); + /* calculate transfer quantity for the remaining 68k cycles */ + left_cycles = aim_m68k - count_m68k; + if (left_cycles < 0) left_cycles = 0; + dma_bytes = (uint32)(((double)left_cycles / vdp_timings[dma_type][index]) + 0.5); - /* determinate DMA length in CPU cycles */ - if (dma_length < dma_bytes) - { - /* DMA will be finished during this line */ - dma_cycles = (uint32)(((double)dma_length * vdp_timings[dma_type][index]) + 0.5); - dma_length = 0; - } - else - { - /* DMA can not be finished until next scanline */ - dma_cycles = left_cycles; - dma_length -= dma_bytes; - } + /* determinate DMA length in CPU cycles */ + if (dma_length < dma_bytes) + { + /* DMA will be finished during this line */ + dma_cycles = (uint32)(((double)dma_length * vdp_timings[dma_type][index]) + 0.5); + dma_length = 0; + } + else + { + /* DMA can not be finished until next scanline */ + dma_cycles = left_cycles; + dma_length -= dma_bytes; + } - if (dma_type < 2) - { - /* 68K COPY to V-RAM */ - /* 68K is frozen during DMA operation */ - count_m68k += dma_cycles; - } - else - { - /* VRAM Fill or VRAM Copy */ - /* set DMA end cyles count */ - dma_endCycles = count_m68k + dma_cycles; - - /* set DMA Busy flag */ + if (dma_type < 2) + { + /* 68K COPY to V-RAM */ + /* 68K is frozen during DMA operation */ + count_m68k += dma_cycles; + } + else + { + /* VRAM Fill or VRAM Copy */ + /* set DMA end cyles count */ + dma_endCycles = count_m68k + dma_cycles; + + /* set DMA Busy flag */ status |= 0x0002; - } + } } /* DMA Copy @@ -330,41 +330,41 @@ static inline void dma_copy(void) int source = (reg[22] << 8 | reg[21]) & 0xFFFF; if (!length) length = 0x10000; - dma_type = 3; - dma_length = length; - dma_update(); + dma_type = 3; + dma_length = length; + dma_update(); - /* proceed DMA */ - do - { - vram[addr] = vram[source]; + /* proceed DMA */ + do + { + vram[addr] = vram[source]; MARK_BG_DIRTY(addr); source = (source + 1) & 0xFFFF; - addr += reg[15]; + addr += reg[15]; } while (--length); - /* update length & source address registers */ - reg[19] = length & 0xFF; + /* update length & source address registers */ + reg[19] = length & 0xFF; reg[20] = (length >> 8) & 0xFF; - reg[21] = source & 0xFF; /* not sure */ - reg[22] = (source >> 8) & 0xFF; + reg[21] = source & 0xFF; /* not sure */ + reg[22] = (source >> 8) & 0xFF; } /* 68K Copy to VRAM, VSRAM or CRAM */ static inline void dma_vbus (void) { - uint32 base, source = ((reg[23] & 0x7F) << 17 | reg[22] << 9 | reg[21] << 1) & 0xFFFFFE; - uint32 length = (reg[20] << 8 | reg[19]) & 0xFFFF; + uint32 base, source = ((reg[23] & 0x7F) << 17 | reg[22] << 9 | reg[21] << 1) & 0xFFFFFE; + uint32 length = (reg[20] << 8 | reg[19]) & 0xFFFF; uint32 temp; - if (!length) length = 0x10000; - base = source; + if (!length) length = 0x10000; + base = source; - /* DMA timings */ - dma_type = (code & 0x06) ? 1 : 0; - dma_length = length; - dma_update(); + /* DMA timings */ + dma_type = (code & 0x06) ? 1 : 0; + dma_length = length; + dma_update(); /* DMA source */ if ((source >> 17) == 0x50) @@ -413,8 +413,8 @@ static inline void dma_vbus (void) while (--length); } - /* update length & source address registers */ - reg[19] = length & 0xFF; + /* update length & source address registers */ + reg[19] = length & 0xFF; reg[20] = (length >> 8) & 0xFF; reg[21] = (source >> 1) & 0xFF; reg[22] = (source >> 9) & 0xFF; @@ -425,35 +425,35 @@ static inline void dma_vbus (void) static inline void dma_fill(unsigned int data) { int name; - int length = (reg[20] << 8 | reg[19]) & 0xFFFF; - if (!length) length = 0x10000; + int length = (reg[20] << 8 | reg[19]) & 0xFFFF; + if (!length) length = 0x10000; /* DMA timings */ - dma_type = 2; + dma_type = 2; dma_length = length; dma_update(); /* proceed DMA */ data_write(data); - /* write MSB */ - data = (data >> 8) & 0xff; + /* write MSB */ + data = (data >> 8) & 0xff; - /* detect internal SAT modification */ - if ((addr & sat_base_mask) == satb) - { - do - { - /* update internal SAT (fix Battletech) */ - WRITE_BYTE(sat, (addr & sat_addr_mask)^1, data); - WRITE_BYTE(vram, addr^1, data); - MARK_BG_DIRTY (addr); - addr += reg[15]; - } - while (--length); - } - else - { + /* detect internal SAT modification */ + if ((addr & sat_base_mask) == satb) + { + do + { + /* update internal SAT (fix Battletech) */ + WRITE_BYTE(sat, (addr & sat_addr_mask)^1, data); + WRITE_BYTE(vram, addr^1, data); + MARK_BG_DIRTY (addr); + addr += reg[15]; + } + while (--length); + } + else + { do { WRITE_BYTE(vram, addr^1, data); @@ -461,7 +461,7 @@ static inline void dma_fill(unsigned int data) addr += reg[15]; } while (--length); - } + } /* update length register */ reg[19] = length & 0xFF; @@ -474,19 +474,19 @@ static inline void dma_fill(unsigned int data) /*--------------------------------------------------------------------------*/ static inline void fifo_update() { - if (fifo_write_cnt > 0) - { - /* update FIFO reads */ - uint32 fifo_read = ((count_m68k - fifo_lastwrite) / fifo_latency); - if (fifo_read > 0) - { - fifo_write_cnt -= fifo_read; - if (fifo_write_cnt < 0) fifo_write_cnt = 0; + if (fifo_write_cnt > 0) + { + /* update FIFO reads */ + uint32 fifo_read = ((count_m68k - fifo_lastwrite) / fifo_latency); + if (fifo_read > 0) + { + fifo_write_cnt -= fifo_read; + if (fifo_write_cnt < 0) fifo_write_cnt = 0; - /* update cycle count */ - fifo_lastwrite += fifo_read*fifo_latency; - } - } + /* update cycle count */ + fifo_lastwrite += fifo_read*fifo_latency; + } + } } /*--------------------------------------------------------------------------*/ @@ -494,63 +494,63 @@ static inline void fifo_update() /*--------------------------------------------------------------------------*/ static inline void data_write (unsigned int data) { - switch (code & 0x0F) - { - case 0x01: /* VRAM */ - - /* Byte-swap data if A0 is set */ - if (addr & 1) data = (data >> 8) | (data << 8); + switch (code & 0x0F) + { + case 0x01: /* VRAM */ + + /* Byte-swap data if A0 is set */ + if (addr & 1) data = (data >> 8) | (data << 8); - /* Copy SAT data to the internal SAT */ - if ((addr & sat_base_mask) == satb) - { - *(uint16 *) &sat[addr & sat_addr_mask & 0xFFFE] = data; - } + /* Copy SAT data to the internal SAT */ + if ((addr & sat_base_mask) == satb) + { + *(uint16 *) &sat[addr & sat_addr_mask & 0xFFFE] = data; + } - /* Only write unique data to VRAM */ - if (data != *(uint16 *) &vram[addr & 0xFFFE]) - { - /* Write data to VRAM */ - *(uint16 *) &vram[addr & 0xFFFE] = data; + /* Only write unique data to VRAM */ + if (data != *(uint16 *) &vram[addr & 0xFFFE]) + { + /* Write data to VRAM */ + *(uint16 *) &vram[addr & 0xFFFE] = data; - /* Update the pattern cache */ + /* Update the pattern cache */ int name; - MARK_BG_DIRTY (addr); - } - break; + MARK_BG_DIRTY (addr); + } + break; - case 0x03: /* CRAM */ - { - uint16 *p = (uint16 *) &cram[(addr & 0x7E)]; - data = PACK_CRAM (data & 0x0EEE); - if (data != *p) - { - int index = (addr >> 1) & 0x3F; - *p = data; - color_update (index, *p); - color_update (0x00, *(uint16 *)&cram[border << 1]); - } - break; - } + case 0x03: /* CRAM */ + { + uint16 *p = (uint16 *) &cram[(addr & 0x7E)]; + data = PACK_CRAM (data & 0x0EEE); + if (data != *p) + { + int index = (addr >> 1) & 0x3F; + *p = data; + color_update (index, *p); + color_update (0x00, *(uint16 *)&cram[border << 1]); + } + break; + } - case 0x05: /* VSRAM */ - *(uint16 *) &vsram[(addr & 0x7E)] = data; - break; - } + case 0x05: /* VSRAM */ + *(uint16 *) &vsram[(addr & 0x7E)] = data; + break; + } - /* Increment address register */ - addr += reg[15]; + /* Increment address register */ + addr += reg[15]; } void vdp_ctrl_w(unsigned int data) { - if (pending == 0) + if (pending == 0) { - if ((data & 0xC000) == 0x8000) + if ((data & 0xC000) == 0x8000) { - /* VDP register write */ - uint8 r = (data >> 8) & 0x1F; + /* VDP register write */ + uint8 r = (data >> 8) & 0x1F; uint8 d = data & 0xFF; vdp_reg_w (r, d); } @@ -561,38 +561,38 @@ void vdp_ctrl_w(unsigned int data) } else { - /* Clear pending flag */ - pending = 0; + /* Clear pending flag */ + pending = 0; - /* Update address and code registers */ - addr = ((addr & 0x3FFF) | ((data & 3) << 14)) & 0xFFFF; - code = ((code & 0x03) | ((data >> 2) & 0x3C)) & 0x3F; + /* Update address and code registers */ + addr = ((addr & 0x3FFF) | ((data & 3) << 14)) & 0xFFFF; + code = ((code & 0x03) | ((data >> 2) & 0x3C)) & 0x3F; - /* Save address bits A15 and A14 */ - addr_latch = (addr & 0xC000); + /* Save address bits A15 and A14 */ + addr_latch = (addr & 0xC000); - /* DMA operation */ - if ((code & 0x20) && (reg[1] & 0x10)) - { - switch (reg[23] & 0xC0) - { - case 0x00: /* V bus to VDP DMA */ - case 0x40: /* V bus to VDP DMA */ - dma_vbus(); - break; + /* DMA operation */ + if ((code & 0x20) && (reg[1] & 0x10)) + { + switch (reg[23] & 0xC0) + { + case 0x00: /* V bus to VDP DMA */ + case 0x40: /* V bus to VDP DMA */ + dma_vbus(); + break; - case 0x80: /* VRAM fill */ - dmafill = 1; - break; + case 0x80: /* VRAM fill */ + dmafill = 1; + break; - case 0xC0: /* VRAM copy */ - dma_copy(); - break; - } - } - } + case 0xC0: /* VRAM copy */ + dma_copy(); + break; + } + } + } - /* FIFO emulation: + /* FIFO emulation: --------------- HDISP is 256*10/7 = approx. 366 cycles (same for both modes) this gives: @@ -612,11 +612,11 @@ void vdp_ctrl_w(unsigned int data) */ static inline void vdp_reg_w(unsigned int r, unsigned int d) { - /* Check if Mode 4 (SMS mode) has been activated - According to official doc, VDP registers #11 to #23 can not be written unless bit2 in register #1 is set - Fix Captain Planet & Avengers (Alt version), Bass Master Classic Pro Edition (they incidentally activate Mode 4) - */ - if (!(reg[1] & 4) && (r > 10)) return; + /* Check if Mode 4 (SMS mode) has been activated + According to official doc, VDP registers #11 to #23 can not be written unless bit2 in register #1 is set + Fix Captain Planet & Avengers (Alt version), Bass Master Classic Pro Edition (they incidentally activate Mode 4) + */ + if (!(reg[1] & 4) && (r > 10)) return; switch(r) { @@ -646,15 +646,15 @@ static inline void vdp_reg_w(unsigned int r, unsigned int d) { /* Update the height of the viewport */ bitmap.viewport.h = (d & 8) ? 240 : 224; - if (config.overscan) bitmap.viewport.y = ((vdp_pal ? 288 : 240) - bitmap.viewport.h) / 2; + if (config.overscan) bitmap.viewport.y = ((vdp_pal ? 288 : 240) - bitmap.viewport.h) / 2; bitmap.viewport.changed = 1; - /* update VC table */ - if (vdp_pal) vctab = (d & 8) ? vc_pal_240 : vc_pal_224; + /* update VC table */ + if (vdp_pal) vctab = (d & 8) ? vc_pal_240 : vc_pal_224; } - + /* DISPLAY switched ON/OFF during HBLANK */ - if ((v_counter < bitmap.viewport.h) && ((d&0x40) != (reg[1]&0x40))) + if ((v_counter < bitmap.viewport.h) && ((d&0x40) != (reg[1]&0x40))) { if (count_m68k <= (hint_m68k + 120)) { @@ -687,7 +687,7 @@ static inline void vdp_reg_w(unsigned int r, unsigned int d) satb = (d << 9) & sat_base_mask; break; - case 0x07: /* Border Color index */ + case 0x07: /* Border Color index */ /* Check if the border color has actually changed */ d &= 0x3F; if(border != d) @@ -702,7 +702,7 @@ static inline void vdp_reg_w(unsigned int r, unsigned int d) /* remap current line (see Road Rash I,II,III) */ reg[7] = d; remap_buffer(v_counter,bitmap.viewport.w + 2*bitmap.viewport.x); - } + } } break; @@ -712,11 +712,11 @@ static inline void vdp_reg_w(unsigned int r, unsigned int d) { /* Update the width of the viewport */ bitmap.viewport.w = (d & 1) ? 320 : 256; - if (config.overscan) bitmap.viewport.x = (d & 1) ? 16 : 12; + if (config.overscan) bitmap.viewport.x = (d & 1) ? 16 : 12; bitmap.viewport.changed = 1; - - /* update HC table */ - hctab = (d & 1) ? cycle2hc40 : cycle2hc32; + + /* update HC table */ + hctab = (d & 1) ? cycle2hc40 : cycle2hc32; /* update clipping */ window_clip(d,reg[17]); @@ -726,14 +726,14 @@ static inline void vdp_reg_w(unsigned int r, unsigned int d) if((reg[0x0C] & 8) != (d & 8)) { int i; - + /* The following color update check this value */ reg[0x0C] = d; /* Update colors */ - for (i = 0; i < 0x40; i += 1) color_update (i, *(uint16 *) & cram[i << 1]); - color_update (0x00, *(uint16 *) & cram[border << 1]); - } + for (i = 0; i < 0x40; i += 1) color_update (i, *(uint16 *) & cram[i << 1]); + color_update (0x00, *(uint16 *) & cram[border << 1]); + } /* The following register updates check this value */ reg[0x0C] = d; @@ -763,139 +763,137 @@ static inline void vdp_reg_w(unsigned int r, unsigned int d) reg[r] = d; } - - +/* + * Return VDP status + * + * Bits are + * 0 0:1 ntsc:pal + * 1 DMA Busy + * 2 During HBlank + * 3 During VBlank + * 4 Frame Interlace 0:even 1:odd + * 5 Sprite collision + * 6 Too many sprites per line + * 7 v interrupt occurred + * 8 Write FIFO full + * 9 Write FIFO empty + * 10 - 15 Next word on bus + */ unsigned int vdp_ctrl_r(void) { - /* - * Return vdp status - * - * Bits are - * 0 0:1 ntsc:pal - * 1 DMA Busy - * 2 During HBlank - * 3 During VBlank - * 4 Frame Interlace 0:even 1:odd - * 5 Sprite collision - * 6 Too many sprites per line - * 7 v interrupt occurred - * 8 Write FIFO full - * 9 Write FIFO empty - * 10 - 15 Next word on bus - */ /* update FIFO flags */ fifo_update(); if (fifo_write_cnt < 4) { - status &= 0xFEFF; + status &= 0xFEFF; if (fifo_write_cnt == 0) status |= 0x200; } - else status ^= 0x200; + else status ^= 0x200; - /* update DMA Busy flag */ - if ((status & 2) && !dma_length && (count_m68k >= dma_endCycles)) + /* update DMA Busy flag */ + if ((status & 2) && !dma_length && (count_m68k >= dma_endCycles)) { status &= 0xFFFD; } - unsigned int temp = status; + unsigned int temp = status; - /* display OFF: VBLANK flag is set */ - if (!(reg[1] & 0x40)) temp |= 0x8; + /* display OFF: VBLANK flag is set */ + if (!(reg[1] & 0x40)) temp |= 0x8; - /* HBLANK flag (Sonic 3 and Sonic 2 "VS Modes", Lemmings 2) */ - if ((count_m68k <= (line_m68k + 84)) || (count_m68k > (line_m68k + m68cycles_per_line))) temp |= 0x4; + /* HBLANK flag (Sonic 3 and Sonic 2 "VS Modes", Lemmings 2) */ + if ((count_m68k <= (line_m68k + 84)) || (count_m68k > (line_m68k + m68cycles_per_line))) temp |= 0x4; - /* clear pending flag */ - pending = 0; + /* clear pending flag */ + pending = 0; - /* clear SPR/SCOL flags */ - status &= 0xFF9F; + /* clear SPR/SCOL flags */ + status &= 0xFF9F; - return (temp); + return (temp); } void vdp_data_w(unsigned int data) { - /* Clear pending flag */ - pending = 0; + /* Clear pending flag */ + pending = 0; - if (dmafill) - { - dma_fill(data); - return; - } - - /* update VDP FIFO (during HDISPLAY only) */ - if (!(status&8) && (reg[1]&0x40)) + if (dmafill) { - fifo_update(); - if (fifo_write_cnt == 0) - { + dma_fill(data); + return; + } + + /* update VDP FIFO (during HDISPLAY only) */ + if (!(status&8) && (reg[1]&0x40)) + { + fifo_update(); + if (fifo_write_cnt == 0) + { /* reset cycle counter */ fifo_lastwrite = count_m68k; - - /* FIFO is not empty anymore */ - status &= 0xFDFF; - } - /* increase write counter */ - fifo_write_cnt ++; - - /* is FIFO full ? */ - if (fifo_write_cnt >= 4) - { - status |= 0x100; + /* FIFO is not empty anymore */ + status &= 0xFDFF; + } + + /* increase write counter */ + fifo_write_cnt ++; + + /* is FIFO full ? */ + if (fifo_write_cnt >= 4) + { + status |= 0x100; /* VDP latency (Chaos Engine, Soldiers of Fortune, Double Clutch) */ if (fifo_write_cnt > 4) count_m68k = fifo_lastwrite + fifo_latency; } } - /* write data */ - data_write(data); + /* write data */ + data_write(data); } unsigned int vdp_data_r(void) { - uint16 temp = 0; + uint16 temp = 0; - /* Clear pending flag */ - pending = 0; + /* Clear pending flag */ + pending = 0; - switch (code & 0x0F) + switch (code & 0x0F) { - case 0x00: /* VRAM */ - temp = *(uint16 *) & vram[(addr & 0xFFFE)]; - break; + case 0x00: /* VRAM */ + temp = *(uint16 *) & vram[(addr & 0xFFFE)]; + break; - case 0x08: /* CRAM */ - temp = *(uint16 *) & cram[(addr & 0x7E)]; - temp = UNPACK_CRAM (temp); - break; + case 0x08: /* CRAM */ + temp = *(uint16 *) & cram[(addr & 0x7E)]; + temp = UNPACK_CRAM (temp); + break; - case 0x04: /* VSRAM */ - temp = *(uint16 *) & vsram[(addr & 0x7E)]; - break; - } + case 0x04: /* VSRAM */ + temp = *(uint16 *) & vsram[(addr & 0x7E)]; + break; + } - /* Increment address register */ - addr += reg[15]; + /* Increment address register */ + addr += reg[15]; - /* return data */ - return (temp); + /* return data */ + return (temp); } unsigned int vdp_hvc_r(void) { - uint8 hc = (hc_latch & 0x100) ? (hc_latch & 0xFF) : hctab[count_m68k % m68cycles_per_line]; - uint8 vc = vctab[v_counter]; + uint8 hc = (hc_latch & 0x100) ? (hc_latch & 0xFF) : hctab[count_m68k % m68cycles_per_line]; + uint8 vc = vctab[v_counter]; - /* interlace mode 2 */ - if (im2_flag) vc = (vc << 1) | ((vc >> 7) & 1); + /* interlace mode 2 */ + if (im2_flag) vc = (vc << 1) | ((vc >> 7) & 1); - return ((vc << 8) | hc); + return ((vc << 8) | hc); } @@ -911,8 +909,8 @@ int vdp_int_ack_callback(int int_level) /* VINT triggered ? */ if (irq_status&0x20) - { - vint_pending = 0; + { + vint_pending = 0; status &= ~0x80; /* clear VINT flag */ } else diff --git a/source/vdp.h b/source/vdp.h index 1c9e249..813dd4f 100644 --- a/source/vdp.h +++ b/source/vdp.h @@ -27,8 +27,8 @@ /* VDP context */ extern uint8 sat[0x400]; extern uint8 vram[0x10000]; -extern uint8 cram[0x80]; -extern uint8 vsram[0x80]; +extern uint8 cram[0x80]; +extern uint8 vsram[0x80]; extern uint8 reg[0x20]; extern uint16 addr; extern uint16 addr_latch; @@ -41,20 +41,20 @@ extern uint8 vint_pending; extern uint16 irq_status; /* Global variables */ -extern uint16 ntab; -extern uint16 ntbb; -extern uint16 ntwb; -extern uint16 satb; -extern uint16 hscb; -extern uint8 border; -extern uint8 bg_name_dirty[0x800]; -extern uint16 bg_name_list[0x800]; -extern uint16 bg_list_index; +extern uint16 ntab; +extern uint16 ntbb; +extern uint16 ntwb; +extern uint16 satb; +extern uint16 hscb; +extern uint8 border; +extern uint8 bg_name_dirty[0x800]; +extern uint16 bg_name_list[0x800]; +extern uint16 bg_list_index; extern uint8 bg_pattern_cache[0x80000]; -extern uint8 playfield_shift; -extern uint8 playfield_col_mask; -extern uint16 playfield_row_mask; -extern uint32 y_mask; +extern uint8 playfield_shift; +extern uint8 playfield_col_mask; +extern uint16 playfield_row_mask; +extern uint32 y_mask; extern uint16 hc_latch; extern uint16 v_counter; extern uint8 im2_flag;