gngb-20060309/0000755000175000017500000000000010650127102011350 5ustar josejosegngb-20060309/src/0000755000175000017500000000000010476607762012164 5ustar josejosegngb-20060309/src/cpu.c0000644000175000017500000013762310476606756013135 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "rom.h" #include "cpu.h" #include "memory.h" #include "interrupt.h" #include "serial.h" #include "emu.h" GB_CPU *gbcpu=0; //extern Sint32 gdma_cycle; static Uint8 t8; static Sint8 st8; static Uint16 t16; static Sint16 st16; static Uint32 t32; static Uint8 v; static Uint8 a; // registre #define REG_AF (gbcpu->af) #define REG_BC (gbcpu->bc) #define REG_DE (gbcpu->de) #define REG_HL (gbcpu->hl) #define REG_SP (gbcpu->sp) #define REG_PC (gbcpu->pc) #define AF (gbcpu->af.w) #define BC (gbcpu->bc.w) #define DE (gbcpu->de.w) #define HL (gbcpu->hl.w) #define PC (gbcpu->pc.w) #define SP (gbcpu->sp.w) #define A (gbcpu->af.b.h) #define F (gbcpu->af.b.l) #define B (gbcpu->bc.b.h) #define C (gbcpu->bc.b.l) #define D (gbcpu->de.b.h) #define E (gbcpu->de.b.l) #define H (gbcpu->hl.b.h) #define L (gbcpu->hl.b.l) __inline__ Uint16 get_word(void) { //Uint16 v=((Uint16)(mem_read(PC))); Uint16 v1,v2; mem_read_fast(PC,v1); PC++; //v|=(Uint16)((mem_read(PC)<<8)); mem_read_fast(PC,v2); PC++; return (v1|(v2<<8)); //return v; } __inline__ Uint8 get_byte(void) { //Uint8 t=mem_read(PC); Uint8 t; mem_read_fast(PC,t); PC++; return t; } __inline__ void push_r(REG *r) { //mem_write(--SP,(r)->b.h); //mem_write(--SP,(r)->b.l); SP--; mem_write_fast(SP,(r)->b.h); SP--; mem_write_fast(SP,(r)->b.l); } __inline__ void pop_r(REG *r) { //(r)->b.l=mem_read(SP); mem_read_fast(SP,(r)->b.l); SP++; //(r)->b.h=mem_read(SP); mem_read_fast(SP,(r)->b.h); SP++; } #define GET_BYTE get_byte() #define GET_WORD get_word() #define SUB_CYCLE(c) return (c) //define SUB_CYCLE(c) a=c;break; #define PUSH_R(r) (push_r(&r)) #define POP_R(r) (pop_r(&r)) #define EI (gbcpu->ei_flag=1) #define DI (gbcpu->int_flag=0) #define CP_A_R(v) {t16=A-(v); ((t16&0x0100)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); ((t16&0xff)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); ((((v&0x0f)>((A)&0x0f)))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); SET_FLAG(FLAG_N); } #define RLC_R(r) {t8=((r)&0x80)>>7; (r)=((r)<<1)|t8; ((t8)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} #define RRC_R(r) {t8=((r)&0x01)<<7; (r)=((r)>>1)|t8; ((t8)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} #define RL_R(r) {t8=(IS_SET(FLAG_C)?(1):(0)); (((r)&0x80)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (r)=((r)<<1)|t8; ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH); } #define SLA_R(r) {(((r)&0x80)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (r)<<=1; ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} #define SRA_R(r) {(((r)&0x01)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (r)=((r)&0x80)|((r)>>1); ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} #define SWAP_R(r) {(r)=(((r)&0xf0)>>4)|(((r)&0x0f)<<4); ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH&FLAG_NC);} #define SRL_R(r) {(((r)&0x01)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (r)>>=1; ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} #define BIT_N_R(n,r) {(((r)&(n))?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_H); UNSET_FLAG(FLAG_NN);} void gbcpu_init(void) { gbcpu=(GB_CPU *)malloc(sizeof(GB_CPU)); gbcpu_reset(); } void gbcpu_reset(void) { //if (conf.normal_gb || conf.gb_type==NORMAL_GAMEBOY) { if (conf.gb_type&COLOR_GAMEBOY) { /* FIXME : 0xff => SGB2 */ /*if (conf.gb_type&SUPER_GAMEBOY) gbcpu->af.w=0xffb0; else*/ gbcpu->af.w=0x11b0; } else if (conf.gb_type&NORMAL_GAMEBOY || conf.gb_type&SUPER_GAMEBOY) gbcpu->af.w=0x01B0; gbcpu->bc.w=(Uint16)0x0013; gbcpu->hl.w=(Uint16)0x014d; gbcpu->de.w=(Uint16)0x00d8; gbcpu->sp.w=(Uint16)0xFFFE; gbcpu->pc.w=(Uint16)0x0100; gbcpu->mode=0; gbcpu->state=0; gbcpu->int_flag=0; gbcpu->ei_flag=1; gbcpu->mode=SIMPLE_SPEED; } // GAMEBOY OPERANDE __inline__ Uint8 unknown(void){ printf("unknow opcode"); return 0; } __inline__ Uint8 gbcpu_exec_one(void) { static Uint8 opcode; if (gbcpu->ei_flag==1) { gbcpu->int_flag=1; gbcpu->ei_flag=0; } mem_read_fast(PC,opcode); PC++; switch(opcode) { case 0x0: SUB_CYCLE(4); case 0x1: BC=GET_WORD; SUB_CYCLE(12); case 0x2: mem_write_fast(BC,A); SUB_CYCLE(8); case 0x3: BC++; SUB_CYCLE(8); case 0x4: ((B^0x0f)? UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); B++; ((B) ? UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x5: ((B&0x0f)?UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); B--; ((B)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x6: B=GET_BYTE; SUB_CYCLE(8); case 0x7: ((t8=(A&0x80))?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); UNSET_FLAG(FLAG_NN&FLAG_NZ&FLAG_NH); A=((A<<1)|(t8>>7)); SUB_CYCLE(4); case 0x8: t16=GET_WORD; mem_write_fast(t16,REG_SP.b.l); mem_write_fast(t16+1,REG_SP.b.h); SUB_CYCLE(20); case 0x9: t32=HL+BC; ((t32&0x00010000)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((HL&0x0f)+(BC&0x0f))>0x0f)?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); HL=t32&0xffff; UNSET_FLAG(FLAG_NN); SUB_CYCLE(8); case 0xa: mem_read_fast(BC,A); SUB_CYCLE(8); case 0xb: BC--; SUB_CYCLE(8); case 0xc: ((C^0x0f)? UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); C++; ((C) ? UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0xd: ((C&0x0f)?UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); C--; ((C)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0xe: C=GET_BYTE; SUB_CYCLE(8); case 0xf: ((t8=(A&0x01))?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); UNSET_FLAG(FLAG_NN&FLAG_NZ&FLAG_NH); A=((A>>1)|(t8<<7)); SUB_CYCLE(4); case 0x10: /* FIXME: Stop=>PC++ fix konami2 collection */ PC++; //printf("Stop Instruction at %04x",PC); SUB_CYCLE(4); case 0x11: DE=GET_WORD; SUB_CYCLE(12); case 0x12: mem_write_fast(DE,A); SUB_CYCLE(8); case 0x13: DE++; SUB_CYCLE(8); case 0x14: ((D^0x0f)? UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); D++; ((D) ? UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x15: ((D&0x0f)?UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); D--; ((D)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x16: D=GET_BYTE; SUB_CYCLE(8); case 0x17: t8=((IS_SET(FLAG_C))?1:0); ((A&0x80)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); UNSET_FLAG(FLAG_NN&FLAG_NZ&FLAG_NH); A=(A<<1)|t8; SUB_CYCLE(4); case 0x18: PC=((Sint8)GET_BYTE)+PC; SUB_CYCLE(12); case 0x19: t32=HL+DE; ((t32&0x00010000)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((HL&0x0f)+(DE&0x0f))>0x0f)?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); HL=t32&0xffff; UNSET_FLAG(FLAG_NN); SUB_CYCLE(8); case 0x1a: mem_read_fast(DE,A); SUB_CYCLE(8); case 0x1b: DE--; SUB_CYCLE(8); case 0x1c: ((E^0x0f)? UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); E++; ((E) ? UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x1d: ((E&0x0f)?UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); E--; ((E)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x1e: E=GET_BYTE; SUB_CYCLE(8); case 0x1f: t8=((IS_SET(FLAG_C))?1:0); ((A&0x01)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); UNSET_FLAG(FLAG_NN&FLAG_NZ&FLAG_NH); A=(A>>1)|(t8<<7); SUB_CYCLE(4); case 0x20: if (IS_SET(FLAG_Z)) { PC++; SUB_CYCLE(8); } else { PC=((Sint8)GET_BYTE)+PC; SUB_CYCLE(12); } case 0x21: HL=GET_WORD; SUB_CYCLE(12); case 0x22: mem_write_fast(HL,A); HL++; SUB_CYCLE(8); case 0x23: HL++; SUB_CYCLE(8); case 0x24: ((H^0x0f)? UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); H++; ((H) ? UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x25: ((H&0x0f)?UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); H--; ((H)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x26: H=GET_BYTE; SUB_CYCLE(8); case 0x27: t16=A; if ((t16&0x0f) > 0x09) { if (IS_SET(FLAG_N)) t16-=6; else t16+=06; } if ((t16&0xf0)>0x90) { if (IS_SET(FLAG_N)) t16-=0x60; else t16+=0x60; SET_FLAG(FLAG_C); } else UNSET_FLAG(FLAG_NC); A=t16&0xff; UNSET_FLAG(FLAG_NH); SUB_CYCLE(4); case 0x28: if (IS_SET(FLAG_Z)) { PC=((Sint8)GET_BYTE)+PC; SUB_CYCLE(12); } else { PC++; SUB_CYCLE(8); } case 0x29: t32=HL+HL; ((t32&0x00010000)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((HL&0x0f)+(HL&0x0f))>0x0f)?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); HL=t32&0xffff; UNSET_FLAG(FLAG_NN); SUB_CYCLE(8); case 0x2a: mem_read_fast(HL,A); HL++; SUB_CYCLE(8); case 0x2b: HL--; SUB_CYCLE(8); case 0x2c: ((L^0x0f)? UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); L++; ((L) ? UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x2d: ((L&0x0f)?UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); L--; ((L)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x2e: L=GET_BYTE; SUB_CYCLE(8); case 0x2f: A=(~A); SET_FLAG(FLAG_N|FLAG_H); SUB_CYCLE(4); case 0x30: if (IS_SET(FLAG_C)) { PC++; SUB_CYCLE(8); } else { PC=((Sint8)GET_BYTE)+PC; SUB_CYCLE(12); } case 0x31: SP=GET_WORD; SUB_CYCLE(12); case 0x32: mem_write_fast(HL,A); HL--; SUB_CYCLE(8); case 0x33: SP++; SUB_CYCLE(8); case 0x34: mem_read_fast(HL,t8); ((t8^0x0f)? UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); t8++; ((t8) ? UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); mem_write_fast(HL,t8); SUB_CYCLE(12); case 0x35: mem_read_fast(HL,t8); ((t8&0x0f)?UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); t8--; ((t8)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); mem_write_fast(HL,t8); SUB_CYCLE(12); case 0x36: t8=GET_BYTE; mem_write_fast(HL,t8); SUB_CYCLE(12); case 0x37: SET_FLAG(FLAG_C); UNSET_FLAG(FLAG_NN&FLAG_NH); SUB_CYCLE(4); case 0x38: if (IS_SET(FLAG_C)) { PC=((Sint8)GET_BYTE)+PC; SUB_CYCLE(12); } else { PC++; SUB_CYCLE(8); } case 0x39: t32=HL+SP; ((t32&0x00010000)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((HL&0x0f)+(SP&0x0f))>0x0f)?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); HL=t32&0xffff; UNSET_FLAG(FLAG_NN); SUB_CYCLE(8); case 0x3a: mem_read_fast(HL,A); HL--; SUB_CYCLE(8); case 0x3b: SP--; SUB_CYCLE(8); case 0x3c: ((A^0x0f)? UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); A++; ((A) ? UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x3d: ((A&0x0f)?UNSET_FLAG(FLAG_NH):SET_FLAG(FLAG_H)); A--; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x3e: A=GET_BYTE; SUB_CYCLE(8); case 0x3f: F^=FLAG_C; UNSET_FLAG(FLAG_NN&FLAG_NH); SUB_CYCLE(4); case 0x40: SUB_CYCLE(4); case 0x41: B=C; SUB_CYCLE(4); case 0x42: B=D; SUB_CYCLE(4); case 0x43: B=E; SUB_CYCLE(4); case 0x44: B=H; SUB_CYCLE(4); case 0x45: B=L; SUB_CYCLE(4); case 0x46: mem_read_fast(HL,B); SUB_CYCLE(8); case 0x47: B=A; SUB_CYCLE(4); case 0x48: C=B; SUB_CYCLE(4); case 0x49: SUB_CYCLE(4); case 0x4a: C=D; SUB_CYCLE(4); case 0x4b: C=E; SUB_CYCLE(4); case 0x4c: C=H; SUB_CYCLE(4); case 0x4d: C=L; SUB_CYCLE(4); case 0x4e: mem_read_fast(HL,C); SUB_CYCLE(8); case 0x4f: C=A; SUB_CYCLE(4); case 0x50: D=B; SUB_CYCLE(4); case 0x51: D=C; SUB_CYCLE(4); case 0x52: SUB_CYCLE(4); case 0x53: D=E; SUB_CYCLE(4); case 0x54: D=H; SUB_CYCLE(4); case 0x55: D=L; SUB_CYCLE(4); case 0x56: mem_read_fast(HL,D); SUB_CYCLE(8); case 0x57: D=A; SUB_CYCLE(4); case 0x58: E=B; SUB_CYCLE(4); case 0x59: E=C; SUB_CYCLE(4); case 0x5a: E=D; SUB_CYCLE(4); case 0x5b: SUB_CYCLE(4); case 0x5c: E=H; SUB_CYCLE(4); case 0x5d: E=L; SUB_CYCLE(4); case 0x5e: mem_read_fast(HL,E); SUB_CYCLE(8); case 0x5f: E=A; SUB_CYCLE(4); case 0x60: H=B; SUB_CYCLE(4); case 0x61: H=C; SUB_CYCLE(4); case 0x62: H=D; SUB_CYCLE(4); case 0x63: H=E; SUB_CYCLE(4); case 0x64: SUB_CYCLE(4); case 0x65: H=L; SUB_CYCLE(4); case 0x66: mem_read_fast(HL,H); SUB_CYCLE(8); case 0x67: H=A; SUB_CYCLE(4); case 0x68: L=B; SUB_CYCLE(4); case 0x69: L=C; SUB_CYCLE(4); case 0x6a: L=D; SUB_CYCLE(4); case 0x6b: L=E; SUB_CYCLE(4); case 0x6c: L=H; SUB_CYCLE(4); case 0x6d: SUB_CYCLE(4); case 0x6e: mem_read_fast(HL,L); SUB_CYCLE(8); case 0x6f: L=A; SUB_CYCLE(4); case 0x70: mem_write_fast(HL,B); SUB_CYCLE(8); case 0x71: mem_write_fast(HL,C); SUB_CYCLE(8); case 0x72: mem_write_fast(HL,D); SUB_CYCLE(8); case 0x73: mem_write_fast(HL,E); SUB_CYCLE(8); case 0x74: mem_write_fast(HL,H); SUB_CYCLE(8); case 0x75: mem_write_fast(HL,L); SUB_CYCLE(8); case 0x76: if (gbcpu->int_flag) { gbcpu->state=HALT_STATE; gbcpu->pc.w--; } else { //printf("WARNING Halt with DIn"); } SUB_CYCLE(4); case 0x77: mem_write_fast(HL,A); SUB_CYCLE(8); case 0x78: A=B; SUB_CYCLE(4); case 0x79: A=C; SUB_CYCLE(4); case 0x7a: A=D; SUB_CYCLE(4); case 0x7b: A=E; SUB_CYCLE(4); case 0x7c: A=H; SUB_CYCLE(4); case 0x7d: A=L; SUB_CYCLE(4); case 0x7e: mem_read_fast(HL,A); SUB_CYCLE(8); case 0x7f: SUB_CYCLE(4); case 0x80: st16=A+B; ((st16&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(B&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=st16&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x81: st16=A+C; ((st16&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(C&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=st16&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x82: st16=A+D; ((st16&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(D&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=st16&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x83: st16=A+E; ((st16&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(E&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=st16&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x84: st16=A+H; ((st16&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(H&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=st16&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x85: st16=A+L; ((st16&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(L&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=st16&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x86: mem_read_fast(HL,t8); st16=A+t8; ((st16&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t8&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=st16&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(8); case 0x87: st16=A+A; ((st16&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(A&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=st16&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x88: t16=B+(IS_SET(FLAG_C)?(1):(0)); t32=A+t16; ((t32&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t16&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t32&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x89: t16=C+(IS_SET(FLAG_C)?(1):(0)); t32=A+t16; ((t32&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t16&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t32&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x8a: t16=D+(IS_SET(FLAG_C)?(1):(0)); t32=A+t16; ((t32&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t16&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t32&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x8b: t16=E+(IS_SET(FLAG_C)?(1):(0)); t32=A+t16; ((t32&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t16&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t32&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x8c: t16=H+(IS_SET(FLAG_C)?(1):(0)); t32=A+t16; ((t32&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t16&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t32&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x8d: t16=L+(IS_SET(FLAG_C)?(1):(0)); t32=A+t16; ((t32&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t16&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t32&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x8e: mem_read_fast(HL,t16); t16+=(IS_SET(FLAG_C)?(1):(0)); t32=A+t16; ((t32&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t16&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t32&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(8); case 0x8f: t16=A+(IS_SET(FLAG_C)?(1):(0)); t32=A+t16; ((t32&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t16&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t32&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(4); case 0x90: ((B>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((B&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=B; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x91: ((C>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((C&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=C; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x92: ((D>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((D&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=D; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x93: ((E>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((E&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=E; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x94: ((H>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((H&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=H; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x95: ((L>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((L&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=L; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x96: mem_read_fast(HL,t8); ((t8>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t8&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t8; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(8); case 0x97: ((A>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=A; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x98: t16=B+((IS_SET(FLAG_C))?(1):(0)); ((t16>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t16&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t16; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x99: t16=C+((IS_SET(FLAG_C))?(1):(0)); ((t16>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t16&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t16; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x9a: t16=D+((IS_SET(FLAG_C))?(1):(0)); ((t16>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t16&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t16; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x9b: t16=E+((IS_SET(FLAG_C))?(1):(0)); ((t16>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t16&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t16; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x9c: t16=H+((IS_SET(FLAG_C))?(1):(0)); ((t16>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t16&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t16; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x9d: t16=L+((IS_SET(FLAG_C))?(1):(0)); ((t16>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t16&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t16; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0x9e: mem_read_fast(HL,t16); t16+=((IS_SET(FLAG_C))?(1):(0)); ((t16>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t16&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t16; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(8); case 0x9f: t16=A+((IS_SET(FLAG_C))?(1):(0)); ((t16>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t16&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t16; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(4); case 0xa0: A&=B; if (A) { UNSET_FLAG(FLAG_NZ&FLAG_NN&FLAG_NC); SET_FLAG(FLAG_H); } else { UNSET_FLAG(FLAG_NN&FLAG_NC); SET_FLAG(FLAG_Z|FLAG_H); } SUB_CYCLE(4); case 0xa1: A&=C; if (A) { UNSET_FLAG(FLAG_NZ&FLAG_NN&FLAG_NC); SET_FLAG(FLAG_H); } else { UNSET_FLAG(FLAG_NN&FLAG_NC); SET_FLAG(FLAG_Z|FLAG_H); } SUB_CYCLE(4); case 0xa2: A&=D; if (A) { UNSET_FLAG(FLAG_NZ&FLAG_NN&FLAG_NC); SET_FLAG(FLAG_H); } else { UNSET_FLAG(FLAG_NN&FLAG_NC); SET_FLAG(FLAG_Z|FLAG_H); } SUB_CYCLE(4); case 0xa3: A&=E; if (A) { UNSET_FLAG(FLAG_NZ&FLAG_NN&FLAG_NC); SET_FLAG(FLAG_H); } else { UNSET_FLAG(FLAG_NN&FLAG_NC); SET_FLAG(FLAG_Z|FLAG_H); } SUB_CYCLE(4); case 0xa4: A&=H; if (A) { UNSET_FLAG(FLAG_NZ&FLAG_NN&FLAG_NC); SET_FLAG(FLAG_H); } else { UNSET_FLAG(FLAG_NN&FLAG_NC); SET_FLAG(FLAG_Z|FLAG_H); } SUB_CYCLE(4); case 0xa5: A&=L; if (A) { UNSET_FLAG(FLAG_NZ&FLAG_NN&FLAG_NC); SET_FLAG(FLAG_H); } else { UNSET_FLAG(FLAG_NN&FLAG_NC); SET_FLAG(FLAG_Z|FLAG_H); } SUB_CYCLE(4); case 0xa6: mem_read_fast(HL,t8); A&=t8; if (A) { UNSET_FLAG(FLAG_NZ&FLAG_NN&FLAG_NC); SET_FLAG(FLAG_H); } else { UNSET_FLAG(FLAG_NN&FLAG_NC); SET_FLAG(FLAG_Z|FLAG_H); } SUB_CYCLE(8); case 0xa7: A&=A; if (A) { UNSET_FLAG(FLAG_NZ&FLAG_NN&FLAG_NC); SET_FLAG(FLAG_H); } else { UNSET_FLAG(FLAG_NN&FLAG_NC); SET_FLAG(FLAG_Z|FLAG_H); } SUB_CYCLE(4); case 0xa8: A^=B; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xa9: A^=C; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xaa: A^=D; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xab: A^=E; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xac: A^=H; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xad: A^=L; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xae: mem_read_fast(HL,t8); A^=t8; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(8); case 0xaf: A^=A; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xb0: A|=B; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xb1: A|=C; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xb2: A|=D; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xb3: A|=E; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xb4: A|=H; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xb5: A|=L; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); case 0xb6: mem_read_fast(HL,t8); A|=t8; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(8); case 0xb7: A|=A; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(4); #define CP_A_R(v) {t16=A-(v); ((t16&0x0100)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); ((t16&0xff)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); ((((v&0x0f)>((A)&0x0f)))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); SET_FLAG(FLAG_N); } case 0xb8: CP_A_R(B); SUB_CYCLE(4); case 0xb9: CP_A_R(C); SUB_CYCLE(4); case 0xba: CP_A_R(D); SUB_CYCLE(4); case 0xbb: CP_A_R(E); SUB_CYCLE(4); case 0xbc: CP_A_R(H); SUB_CYCLE(4); case 0xbd: CP_A_R(L); SUB_CYCLE(4); case 0xbe: mem_read_fast(HL,t8); CP_A_R(t8); SUB_CYCLE(8); case 0xbf: CP_A_R(A); SUB_CYCLE(4); case 0xc0: if (IS_SET(FLAG_Z)) SUB_CYCLE(8); else { POP_R(REG_PC); SUB_CYCLE(20); } case 0xc1: POP_R(REG_BC); SUB_CYCLE(12); case 0xc2: if (IS_SET(FLAG_Z)) { PC+=2; SUB_CYCLE(12); } else { PC=GET_WORD; SUB_CYCLE(16); } case 0xc3: PC=GET_WORD; SUB_CYCLE(16); case 0xc4: if (IS_SET(FLAG_Z)) { PC+=2; SUB_CYCLE(12); } else { Uint16 v=GET_WORD; PUSH_R(REG_PC); PC=v; SUB_CYCLE(24); } case 0xc5: PUSH_R(REG_BC); SUB_CYCLE(16); case 0xc6: t8=GET_BYTE; t16=A+t8; ((t16&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t8&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t16&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(8); case 0xc7: PUSH_R(REG_PC); PC=0x0000; SUB_CYCLE(16); case 0xc8: if (IS_SET(FLAG_Z)) { POP_R(REG_PC); SUB_CYCLE(20); }else SUB_CYCLE(8); case 0xc9: POP_R(REG_PC); SUB_CYCLE(16); case 0xca: if (IS_SET(FLAG_Z)) { PC=GET_WORD; SUB_CYCLE(16); } else { PC+=2; SUB_CYCLE(12); } case 0xcb: switch(GET_BYTE) { #define RLC_R(r) {t8=((r)&0x80)>>7; (r)=((r)<<1)|t8; ((t8)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} case 0x0: RLC_R(B); SUB_CYCLE(8); case 0x1: RLC_R(C); SUB_CYCLE(8); case 0x2: RLC_R(D); SUB_CYCLE(8); case 0x3: RLC_R(E); SUB_CYCLE(8); case 0x4: RLC_R(H); SUB_CYCLE(8); case 0x5: RLC_R(L); SUB_CYCLE(8); case 0x6: mem_read_fast(HL,a); RLC_R(a); mem_write_fast(HL,a); SUB_CYCLE(16); case 0x7: RLC_R(A); SUB_CYCLE(8); #define RRC_R(r) {t8=((r)&0x01)<<7; (r)=((r)>>1)|t8; ((t8)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} case 0x8: RRC_R(B); SUB_CYCLE(8); case 0x9: RRC_R(C); SUB_CYCLE(8); case 0xa: RRC_R(D); SUB_CYCLE(8); case 0xb: RRC_R(E); SUB_CYCLE(8); case 0xc: RRC_R(H); SUB_CYCLE(8); case 0xd: RRC_R(L); SUB_CYCLE(8); case 0xe: mem_read_fast(HL,a); RRC_R(a); mem_write_fast(HL,a); SUB_CYCLE(16); case 0xf: RRC_R(A); SUB_CYCLE(8); #define RL_R(r) {t8=(IS_SET(FLAG_C)?(1):(0)); (((r)&0x80)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (r)=((r)<<1)|t8; ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH); } case 0x10: RL_R(B); SUB_CYCLE(8); case 0x11: RL_R(C); SUB_CYCLE(8); case 0x12: RL_R(D); SUB_CYCLE(8); case 0x13: RL_R(E); SUB_CYCLE(8); case 0x14: RL_R(H); SUB_CYCLE(8); case 0x15: RL_R(L); SUB_CYCLE(8); case 0x16: mem_read_fast(HL,a); RL_R(a); mem_write_fast(HL,a); SUB_CYCLE(16); case 0x17: RL_R(A); SUB_CYCLE(8); #define RR_R(r) {t8=(IS_SET(FLAG_C)?(0x80):(0x00)); (((r)&0x01)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (r)=((r)>>1)|t8; ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} case 0x18: RR_R(B); SUB_CYCLE(8); case 0x19: RR_R(C); SUB_CYCLE(8); case 0x1a: RR_R(D); SUB_CYCLE(8); case 0x1b: RR_R(E); SUB_CYCLE(8); case 0x1c: RR_R(H); SUB_CYCLE(8); case 0x1d: RR_R(L); SUB_CYCLE(8); case 0x1e: mem_read_fast(HL,a); RR_R(a); mem_write_fast(HL,a); SUB_CYCLE(16); case 0x1f: RR_R(A); SUB_CYCLE(8); #define SLA_R(r) {(((r)&0x80)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (r)<<=1; ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} case 0x20: SLA_R(B); SUB_CYCLE(8); case 0x21: SLA_R(C); SUB_CYCLE(8); case 0x22: SLA_R(D); SUB_CYCLE(8); case 0x23: SLA_R(E); SUB_CYCLE(8); case 0x24: SLA_R(H); SUB_CYCLE(8); case 0x25: SLA_R(L); SUB_CYCLE(8); case 0x26: mem_read_fast(HL,a); SLA_R(a); mem_write_fast(HL,a); SUB_CYCLE(16); case 0x27: SLA_R(A); SUB_CYCLE(8); #define SRA_R(r) {(((r)&0x01)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (r)=((r)&0x80)|((r)>>1); ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} case 0x28: SRA_R(B); SUB_CYCLE(8); case 0x29: SRA_R(C); SUB_CYCLE(8); case 0x2a: SRA_R(D); SUB_CYCLE(8); case 0x2b: SRA_R(E); SUB_CYCLE(8); case 0x2c: SRA_R(H); SUB_CYCLE(8); case 0x2d: SRA_R(L); SUB_CYCLE(8); case 0x2e: mem_read_fast(HL,a); SRA_R(a); mem_write_fast(HL,a); SUB_CYCLE(16); case 0x2f: SRA_R(A); SUB_CYCLE(8); #define SWAP_R(r) {(r)=(((r)&0xf0)>>4)|(((r)&0x0f)<<4); ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH&FLAG_NC);} case 0x30: SWAP_R(B); SUB_CYCLE(8); case 0x31: SWAP_R(C); SUB_CYCLE(8); case 0x32: SWAP_R(D); SUB_CYCLE(8); case 0x33: SWAP_R(E); SUB_CYCLE(8); case 0x34: SWAP_R(H); SUB_CYCLE(8); case 0x35: SWAP_R(L); SUB_CYCLE(8); case 0x36: mem_read_fast(HL,a); SWAP_R(a); mem_write_fast(HL,a); SUB_CYCLE(16); case 0x37: SWAP_R(A); SUB_CYCLE(8); #define SRL_R(r) {(((r)&0x01)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (r)>>=1; ((r)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN&FLAG_NH);} case 0x38: SRL_R(B); SUB_CYCLE(8); case 0x39: SRL_R(C); SUB_CYCLE(8); case 0x3a: SRL_R(D); SUB_CYCLE(8); case 0x3b: SRL_R(E); SUB_CYCLE(8); case 0x3c: SRL_R(H); SUB_CYCLE(8); case 0x3d: SRL_R(L); SUB_CYCLE(8); case 0x3e: mem_read_fast(HL,a); SRL_R(a); mem_write_fast(HL,a); SUB_CYCLE(16); case 0x3f: SRL_R(A); SUB_CYCLE(8); #define BIT_N_R(n,r) {(((r)&(n))?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_H); UNSET_FLAG(FLAG_NN);} case 0x40: BIT_N_R(0x01,B); SUB_CYCLE(8); case 0x41: BIT_N_R(0x01,C); SUB_CYCLE(8); case 0x42: BIT_N_R(0x01,D); SUB_CYCLE(8); case 0x43: BIT_N_R(0x01,E); SUB_CYCLE(8); case 0x44: BIT_N_R(0x01,H); SUB_CYCLE(8); case 0x45: BIT_N_R(0x01,L); SUB_CYCLE(8); case 0x46: mem_read_fast(HL,a); BIT_N_R(0x01,a); SUB_CYCLE(12); case 0x47: BIT_N_R(0x01,A); SUB_CYCLE(8); case 0x48: BIT_N_R(0x02,B); SUB_CYCLE(8); case 0x49: BIT_N_R(0x02,C); SUB_CYCLE(8); case 0x4a: BIT_N_R(0x02,D); SUB_CYCLE(8); case 0x4b: BIT_N_R(0x02,E); SUB_CYCLE(8); case 0x4c: BIT_N_R(0x02,H); SUB_CYCLE(8); case 0x4d: BIT_N_R(0x02,L); SUB_CYCLE(8); case 0x4e: mem_read_fast(HL,a); BIT_N_R(0x02,a); SUB_CYCLE(12); case 0x4f: BIT_N_R(0x02,A); SUB_CYCLE(8); case 0x50: BIT_N_R(0x04,B); SUB_CYCLE(8); case 0x51: BIT_N_R(0x04,C); SUB_CYCLE(8); case 0x52: BIT_N_R(0x04,D); SUB_CYCLE(8); case 0x53: BIT_N_R(0x04,E); SUB_CYCLE(8); case 0x54: BIT_N_R(0x04,H); SUB_CYCLE(8); case 0x55: BIT_N_R(0x04,L); SUB_CYCLE(8); case 0x56: mem_read_fast(HL,a); BIT_N_R(0x04,a); SUB_CYCLE(12); case 0x57: BIT_N_R(0x04,A); SUB_CYCLE(8); case 0x58: BIT_N_R(0x08,B); SUB_CYCLE(8); case 0x59: BIT_N_R(0x08,C); SUB_CYCLE(8); case 0x5a: BIT_N_R(0x08,D); SUB_CYCLE(8); case 0x5b: BIT_N_R(0x08,E); SUB_CYCLE(8); case 0x5c: BIT_N_R(0x08,H); SUB_CYCLE(8); case 0x5d: BIT_N_R(0x08,L); SUB_CYCLE(8); case 0x5e: mem_read_fast(HL,a); BIT_N_R(0x08,a); SUB_CYCLE(12); case 0x5f: BIT_N_R(0x08,A); SUB_CYCLE(8); case 0x60: BIT_N_R(0x10,B); SUB_CYCLE(8); case 0x61: BIT_N_R(0x10,C); SUB_CYCLE(8); case 0x62: BIT_N_R(0x10,D); SUB_CYCLE(8); case 0x63: BIT_N_R(0x10,E); SUB_CYCLE(8); case 0x64: BIT_N_R(0x10,H); SUB_CYCLE(8); case 0x65: BIT_N_R(0x10,L); SUB_CYCLE(8); case 0x66: mem_read_fast(HL,a); BIT_N_R(0x10,a); SUB_CYCLE(12); case 0x67: BIT_N_R(0x10,A); SUB_CYCLE(8); case 0x68: BIT_N_R(0x20,B); SUB_CYCLE(8); case 0x69: BIT_N_R(0x20,C); SUB_CYCLE(8); case 0x6a: BIT_N_R(0x20,D); SUB_CYCLE(8); case 0x6b: BIT_N_R(0x20,E); SUB_CYCLE(8); case 0x6c: BIT_N_R(0x20,H); SUB_CYCLE(8); case 0x6d: BIT_N_R(0x20,L); SUB_CYCLE(8); case 0x6e: mem_read_fast(HL,a); BIT_N_R(0x20,a); SUB_CYCLE(12); case 0x6f: BIT_N_R(0x20,A); SUB_CYCLE(8); case 0x70: BIT_N_R(0x40,B); SUB_CYCLE(8); case 0x71: BIT_N_R(0x40,C); SUB_CYCLE(8); case 0x72: BIT_N_R(0x40,D); SUB_CYCLE(8); case 0x73: BIT_N_R(0x40,E); SUB_CYCLE(8); case 0x74: BIT_N_R(0x40,H); SUB_CYCLE(8); case 0x75: BIT_N_R(0x40,L); SUB_CYCLE(8); case 0x76: mem_read_fast(HL,a); BIT_N_R(0x40,a); SUB_CYCLE(12); case 0x77: BIT_N_R(0x40,A); SUB_CYCLE(8); case 0x78: BIT_N_R(0x80,B); SUB_CYCLE(8); case 0x79: BIT_N_R(0x80,C); SUB_CYCLE(8); case 0x7a: BIT_N_R(0x80,D); SUB_CYCLE(8); case 0x7b: BIT_N_R(0x80,E); SUB_CYCLE(8); case 0x7c: BIT_N_R(0x80,H); SUB_CYCLE(8); case 0x7d: BIT_N_R(0x80,L); SUB_CYCLE(8); case 0x7e: mem_read_fast(HL,a); BIT_N_R(0x80,a); SUB_CYCLE(12); case 0x7f: BIT_N_R(0x80,A); SUB_CYCLE(8); case 0x80: B&=0xfe; SUB_CYCLE(8); case 0x81: C&=0xfe; SUB_CYCLE(8); case 0x82: D&=0xfe; SUB_CYCLE(8); case 0x83: E&=0xfe; SUB_CYCLE(8); case 0x84: H&=0xfe; SUB_CYCLE(8); case 0x85: L&=0xfe; SUB_CYCLE(8); case 0x86: mem_read_fast(HL,v); v&=0xfe; mem_write_fast(HL,v); SUB_CYCLE(16); case 0x87: A&=0xfe; SUB_CYCLE(8); case 0x88: B&=0xfd; SUB_CYCLE(8); case 0x89: C&=0xfd; SUB_CYCLE(8); case 0x8a: D&=0xfd; SUB_CYCLE(8); case 0x8b: E&=0xfd; SUB_CYCLE(8); case 0x8c: H&=0xfd; SUB_CYCLE(8); case 0x8d: L&=0xfd; SUB_CYCLE(8); case 0x8e: mem_read_fast(HL,v); v&=0xfd; mem_write_fast(HL,v); SUB_CYCLE(16); case 0x8f: A&=0xfd; SUB_CYCLE(8); case 0x90: B&=0xfb; SUB_CYCLE(8); case 0x91: C&=0xfb; SUB_CYCLE(8); case 0x92: D&=0xfb; SUB_CYCLE(8); case 0x93: E&=0xfb; SUB_CYCLE(8); case 0x94: H&=0xfb; SUB_CYCLE(8); case 0x95: L&=0xfb; SUB_CYCLE(8); case 0x96: mem_read_fast(HL,v); v&=0xfb; mem_write_fast(HL,v); SUB_CYCLE(16); case 0x97: A&=0xfb; SUB_CYCLE(8); case 0x98: B&=0xf7; SUB_CYCLE(8); case 0x99: C&=0xf7; SUB_CYCLE(8); case 0x9a: D&=0xf7; SUB_CYCLE(8); case 0x9b: E&=0xf7; SUB_CYCLE(8); case 0x9c: H&=0xf7; SUB_CYCLE(8); case 0x9d: L&=0xf7; SUB_CYCLE(8); case 0x9e: mem_read_fast(HL,v); v&=0xf7; mem_write_fast(HL,v); SUB_CYCLE(16); case 0x9f: A&=0xf7; SUB_CYCLE(8); case 0xa0: B&=0xef; SUB_CYCLE(8); case 0xa1: C&=0xef; SUB_CYCLE(8); case 0xa2: D&=0xef; SUB_CYCLE(8); case 0xa3: E&=0xef; SUB_CYCLE(8); case 0xa4: H&=0xef; SUB_CYCLE(8); case 0xa5: L&=0xef; SUB_CYCLE(8); case 0xa6: mem_read_fast(HL,v); v&=0xef; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xa7: A&=0xef; SUB_CYCLE(8); case 0xa8: B&=0xdf; SUB_CYCLE(8); case 0xa9: C&=0xdf; SUB_CYCLE(8); case 0xaa: D&=0xdf; SUB_CYCLE(8); case 0xab: E&=0xdf; SUB_CYCLE(8); case 0xac: H&=0xdf; SUB_CYCLE(8); case 0xad: L&=0xdf; SUB_CYCLE(8); case 0xae: mem_read_fast(HL,v); v&=0xdf; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xaf: A&=0xdf; SUB_CYCLE(8); case 0xb0: B&=0xbf; SUB_CYCLE(8); case 0xb1: C&=0xbf; SUB_CYCLE(8); case 0xb2: D&=0xbf; SUB_CYCLE(8); case 0xb3: E&=0xbf; SUB_CYCLE(8); case 0xb4: H&=0xbf; SUB_CYCLE(8); case 0xb5: L&=0xbf; SUB_CYCLE(8); case 0xb6: mem_read_fast(HL,v); v&=0xbf; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xb7: A&=0xbf; SUB_CYCLE(8); case 0xb8: B&=0x7f; SUB_CYCLE(8); case 0xb9: C&=0x7f; SUB_CYCLE(8); case 0xba: D&=0x7f; SUB_CYCLE(8); case 0xbb: E&=0x7f; SUB_CYCLE(8); case 0xbc: H&=0x7f; SUB_CYCLE(8); case 0xbd: L&=0x7f; SUB_CYCLE(8); case 0xbe: mem_read_fast(HL,v); v&=0x7f; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xbf: A&=0x7f; SUB_CYCLE(8); case 0xc0: B|=0x01; SUB_CYCLE(8); case 0xc1: C|=0x01; SUB_CYCLE(8); case 0xc2: D|=0x01; SUB_CYCLE(8); case 0xc3: E|=0x01; SUB_CYCLE(8); case 0xc4: H|=0x01; SUB_CYCLE(8); case 0xc5: L|=0x01; SUB_CYCLE(8); case 0xc6: mem_read_fast(HL,v); v|=0x01; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xc7: A|=0x01; SUB_CYCLE(8); case 0xc8: B|=0x02; SUB_CYCLE(8); case 0xc9: C|=0x02; SUB_CYCLE(8); case 0xca: D|=0x02; SUB_CYCLE(8); case 0xcb: E|=0x02; SUB_CYCLE(8); case 0xcc: H|=0x02; SUB_CYCLE(8); case 0xcd: L|=0x02; SUB_CYCLE(8); case 0xce: mem_read_fast(HL,v); v|=0x02; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xcf: A|=0x02; SUB_CYCLE(8); case 0xd0: B|=0x04; SUB_CYCLE(8); case 0xd1: C|=0x04; SUB_CYCLE(8); case 0xd2: D|=0x04; SUB_CYCLE(8); case 0xd3: E|=0x04; SUB_CYCLE(8); case 0xd4: H|=0x04; SUB_CYCLE(8); case 0xd5: L|=0x04; SUB_CYCLE(8); case 0xd6: mem_read_fast(HL,v); v|=0x04; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xd7: A|=0x04; SUB_CYCLE(8); case 0xd8: B|=0x08; SUB_CYCLE(8); case 0xd9: C|=0x08; SUB_CYCLE(8); case 0xda: D|=0x08; SUB_CYCLE(8); case 0xdb: E|=0x08; SUB_CYCLE(8); case 0xdc: H|=0x08; SUB_CYCLE(8); case 0xdd: L|=0x08; SUB_CYCLE(8); case 0xde: mem_read_fast(HL,v); v|=0x08; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xdf: A|=0x08; SUB_CYCLE(8); case 0xe0: B|=0x10; SUB_CYCLE(8); case 0xe1: C|=0x10; SUB_CYCLE(8); case 0xe2: D|=0x10; SUB_CYCLE(8); case 0xe3: E|=0x10; SUB_CYCLE(8); case 0xe4: H|=0x10; SUB_CYCLE(8); case 0xe5: L|=0x10; SUB_CYCLE(8); case 0xe6: mem_read_fast(HL,v); v|=0x10; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xe7: A|=0x10; SUB_CYCLE(8); case 0xe8: B|=0x20; SUB_CYCLE(8); case 0xe9: C|=0x20; SUB_CYCLE(8); case 0xea: D|=0x20; SUB_CYCLE(8); case 0xeb: E|=0x20; SUB_CYCLE(8); case 0xec: H|=0x20; SUB_CYCLE(8); case 0xed: L|=0x20; SUB_CYCLE(8); case 0xee: mem_read_fast(HL,v); v|=0x20; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xef: A|=0x20; SUB_CYCLE(8); case 0xf0: B|=0x40; SUB_CYCLE(8); case 0xf1: C|=0x40; SUB_CYCLE(8); case 0xf2: D|=0x40; SUB_CYCLE(8); case 0xf3: E|=0x40; SUB_CYCLE(8); case 0xf4: H|=0x40; SUB_CYCLE(8); case 0xf5: L|=0x40; SUB_CYCLE(8); case 0xf6: mem_read_fast(HL,v); v|=0x40; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xf7: A|=0x40; SUB_CYCLE(8); case 0xf8: B|=0x80; SUB_CYCLE(8); case 0xf9: C|=0x80; SUB_CYCLE(8); case 0xfa: D|=0x80; SUB_CYCLE(8); case 0xfb: E|=0x80; SUB_CYCLE(8); case 0xfc: H|=0x80; SUB_CYCLE(8); case 0xfd: L|=0x80; SUB_CYCLE(8); case 0xfe: mem_read_fast(HL,v); v|=0x80; mem_write_fast(HL,v); SUB_CYCLE(16); case 0xff: A|=0x80; SUB_CYCLE(8); } case 0xcc: if (IS_SET(FLAG_Z)) { t16=GET_WORD; PUSH_R(REG_PC); PC=t16; SUB_CYCLE(24); } else { PC+=2; SUB_CYCLE(12); } case 0xcd: t16=GET_WORD; PUSH_R(REG_PC); PC=t16; SUB_CYCLE(24); case 0xce: t16=GET_BYTE+(IS_SET(FLAG_C)?(1):(0)); t32=A+t16; ((t32&0x0100) ? SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((A&0X0f)+(t16&0x0f))>0x0f) ? SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); A=t32&0xff; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); UNSET_FLAG(FLAG_NN); SUB_CYCLE(8); case 0xcf: PUSH_R(REG_PC); PC=0x0008; SUB_CYCLE(16); case 0xd0: if (IS_SET(FLAG_C)) SUB_CYCLE(8); else { POP_R(REG_PC); SUB_CYCLE(20); } case 0xd1: POP_R(REG_DE); SUB_CYCLE(12); case 0xd2: if (IS_SET(FLAG_C)) { PC+=2; SUB_CYCLE(12); } else { PC=GET_WORD; SUB_CYCLE(16); } case 0xd3: return unknown(); case 0xd4: if (IS_SET(FLAG_C)) { PC+=2; SUB_CYCLE(12); } else { t16=GET_WORD; PUSH_R(REG_PC); PC=t16; SUB_CYCLE(24); } case 0xd5: PUSH_R(REG_DE); SUB_CYCLE(16); case 0xd6: t8=GET_BYTE; ((t8>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t8&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t8; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(8); case 0xd7: PUSH_R(REG_PC); PC=0x0010; SUB_CYCLE(16); case 0xd8: if (IS_SET(FLAG_C)) { POP_R(REG_PC); SUB_CYCLE(20); }else SUB_CYCLE(8); case 0xd9: POP_R(REG_PC); gbcpu->int_flag=1; SUB_CYCLE(16); case 0xda: if (IS_SET(FLAG_C)) { PC=GET_WORD; SUB_CYCLE(16); }else { PC+=2; SUB_CYCLE(12); } case 0xdb: return unknown(); case 0xdc: if (IS_SET(FLAG_C)) { t16=GET_WORD; PUSH_R(REG_PC); PC=t16; SUB_CYCLE(24); } else { PC+=2; SUB_CYCLE(12); } case 0xdd: return unknown(); case 0xde: t16=GET_BYTE+((IS_SET(FLAG_C))?(1):(0)); ((t16>A)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((t16&0x0f)>(A&0x0f))?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); A-=t16; ((A)?UNSET_FLAG(FLAG_NZ):SET_FLAG(FLAG_Z)); SET_FLAG(FLAG_N); SUB_CYCLE(8); case 0xdf: PUSH_R(REG_PC); PC=0x0018; SUB_CYCLE(16); case 0xe0: mem_write_ff(0xff00+GET_BYTE,A); SUB_CYCLE(12); case 0xe1: POP_R(REG_HL); SUB_CYCLE(12); case 0xe2: mem_write_ff(0xff00+C,A); SUB_CYCLE(8); case 0xe3: return unknown(); case 0xe4: return unknown(); case 0xe5: PUSH_R(REG_HL); SUB_CYCLE(16); case 0xe6: A&=GET_BYTE; if (A) { UNSET_FLAG(FLAG_NZ&FLAG_NN&FLAG_NC); SET_FLAG(FLAG_H); } else { UNSET_FLAG(FLAG_NN&FLAG_NC); SET_FLAG(FLAG_Z|FLAG_H); } SUB_CYCLE(8); case 0xe7: PUSH_R(REG_PC); PC=0x0020; SUB_CYCLE(16); case 0xe8: st8=GET_BYTE; t32=SP+st8; ((t32&0x00010000)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); ((((SP&0x0f)+(st8&0x0f))&0x10)?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH)); SP=t32&0xffff; UNSET_FLAG(FLAG_NN&FLAG_NZ); SUB_CYCLE(16); case 0xe9: PC=HL; SUB_CYCLE(4); case 0xea: t16=GET_WORD; mem_write_fast(t16,A); SUB_CYCLE(16); case 0xeb: return unknown(); case 0xec: return unknown(); case 0xed: return unknown(); case 0xee: A^=GET_BYTE; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(8); case 0xef: PUSH_R(REG_PC); PC=0x0028; SUB_CYCLE(16); case 0xf0: A=mem_read_ff(0xff00+GET_BYTE); SUB_CYCLE(12); case 0xf1: POP_R(REG_AF); SUB_CYCLE(12); case 0xf2: A=mem_read_ff(0xff00+C); SUB_CYCLE(8); case 0xf3: DI; SUB_CYCLE(4); case 0xf4: return unknown(); case 0xf5: PUSH_R(REG_AF); SUB_CYCLE(16); case 0xf6: A|=GET_BYTE; UNSET_FLAG(FLAG_NN&FLAG_NC&FLAG_NH); if (A) UNSET_FLAG(FLAG_NZ); else SET_FLAG(FLAG_Z); SUB_CYCLE(8); case 0xf7: PUSH_R(REG_PC); PC=0x0030; SUB_CYCLE(16); case 0xf8: st8=GET_BYTE; t32=SP+st8; ((t32&0x00010000)?SET_FLAG(FLAG_C):UNSET_FLAG(FLAG_NC)); (((SP&0x0f)+(st8&0x0f))>0x0f) ?SET_FLAG(FLAG_H):UNSET_FLAG(FLAG_NH); HL=t32&0xffff; UNSET_FLAG(FLAG_NN&FLAG_NZ); SUB_CYCLE(12); case 0xf9: SP=HL; SUB_CYCLE(8); case 0xfa: t16=GET_WORD; mem_read_fast(t16,A); SUB_CYCLE(16); case 0xfb: EI; SUB_CYCLE(4); case 0xfc: return unknown(); case 0xfd: return unknown(); case 0xfe: t8=GET_BYTE; CP_A_R(t8); SUB_CYCLE(8); case 0xff: PUSH_R(REG_PC); PC=0x0038; SUB_CYCLE(16); } return 0; } __inline__ void rom_timer_inc(void) { rom_timer->reg[0]=(rom_timer->reg[0]+1)%60; if (!rom_timer->reg[0]) { rom_timer->reg[1]=(rom_timer->reg[1]+1)%60; if (!rom_timer->reg[1]) { rom_timer->reg[2]=(rom_timer->reg[2]+1)%24; if (!rom_timer->reg[2]) { rom_timer->reg[3]++; if (rom_timer->reg[3]) { if (rom_timer->reg[4]&0x01) rom_timer->reg[4]|=0x80; // set carry else rom_timer->reg[4]|=0x01; // set dayh bit } } } } } __inline__ void cpu_run(void) { static Uint32 divid_cycle; int v=0; Uint8 a; do { v=0; /*FIXME: GDMA and interrupt */ if (dma_info.type!=GDMA) { if (INT_FLAG&VBLANK_INT) {v=make_interrupt(VBLANK_INT);} if ((INT_FLAG&LCDC_INT) && (!v)) {v=make_interrupt(LCDC_INT);} if ((INT_FLAG&TIMEOWFL_INT) && (!v)) {v=make_interrupt(TIMEOWFL_INT); } if ((INT_FLAG&SERIAL_INT) && (!v)) {v=make_interrupt(SERIAL_INT); } } //if (v) a+=24; if (dma_info.type==GDMA) { /* FIXME */ dma_info.gdma_cycle-=4; if (dma_info.gdma_cycle<=0) { dma_info.type=NO_DMA; HDMA_CTRL5=0xff; } a=4; } else { /*gblcdc_addcycle(gdma_cycle); }*/ if (gbcpu->state!=HALT_STATE) { a=gbcpu_exec_one(); } else a=4; } //if (v) a+=24; //if (gbcpu->state==HALT_STATE) halt_update(); nb_cycle+=a; divid_cycle+=a; if (divid_cycle>256) { DIVID++; divid_cycle=0; } if (LCDCCONT&0x80) GBLCDC_ADD_CYCLE(a) else { key_cycle+=a; if (key_cycle>=gblcdc->vblank_cycle) { update_key(); key_cycle=0; } } if (TIME_CONTROL&0x04) { gbtimer->cycle+=a; if (gbtimer->cycle>=gbtimer->clk_inc) { gbtimer_update(); gbtimer->cycle-=gbtimer->clk_inc; } } /* FIXME: MBC3 timing */ if (rom_type&TIMER && rom_timer->reg[4]&0x40) { rom_timer->cycle+=a; if (rom_timer->cycle>111) { rom_timer_inc(); rom_timer->cycle=0; } } /* FIXME: serial is experimentale */ if (conf.serial_on) { // if (gbserial_check()) { if (gbserial.ready2read) { printf("Receive data\n"); if (SC&0x80) { /* Transfert is on the way */ if (SC&0x01) { /* Server */ SB=gbserial_read(); set_interrupt(SERIAL_INT); printf("Server read %02x make int\n",SB); SC&=0x7f; serial_cycle_todo=0; } else { /* Client */ printf("Client write %02x make int\n",SB); gbserial_write(SB); SB=gbserial_read(); printf("Client read %02x make int\n",SB); /* TODO: Make interrupt in n cycle */ SC&=0x7f; set_interrupt(SERIAL_INT); serial_cycle_todo=0; } } else { gbserial_read(); gbserial.ready2read=0; } gbserial.wait=0; } if (serial_cycle_todo>0) { serial_cycle_todo-=a; if (serial_cycle_todo<=0) { serial_cycle_todo=0; if (SC&0x80) { SB=0xFF; set_interrupt(SERIAL_INT); } } } } /* End of serial Update */ } while(!conf.gb_done); } #undef REG_AF #undef REG_BC #undef REG_DE #undef REG_HL #undef REG_PC #undef AF #undef BC #undef DE #undef HL #undef PC #undef SP #undef A #undef F #undef B #undef C #undef D #undef E #undef H #undef L gngb-20060309/src/cpu.h0000644000175000017500000000337507703567701013131 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _CPU_H #define _CPU_H #include "global.h" #include #define FLAG_Z 0x80 #define FLAG_N 0x40 #define FLAG_H 0x20 #define FLAG_C 0x10 #define FLAG_NZ 0x7F #define FLAG_NN 0xBF #define FLAG_NH 0xDF #define FLAG_NC 0xEF #define SET_FLAG(f) ((gbcpu->af.b.l)|=(f)) #define UNSET_FLAG(f) ((gbcpu->af.b.l)&=(f)) #define IS_SET(f) ((gbcpu->af.b.l&(f))) #ifdef WORDS_BIGENDIAN typedef union { Uint16 w; struct { Uint8 h,l; }b; }REG; #else typedef union { Uint16 w; struct { Uint8 l,h; }b; }REG; #endif #define SIMPLE_SPEED 0 #define DOUBLE_SPEED 1 #define HALT_STATE 1 #define STOP_STATE 2 typedef struct { REG af; REG bc; REG de; REG hl; REG sp; REG pc; Uint8 int_flag; // IME Uint8 ei_flag; Uint8 mode; Uint8 state; }GB_CPU; extern GB_CPU *gbcpu; void gbcpu_init(void); void gbcpu_reset(void); __inline__ Uint8 gbcpu_exec_one(void); __inline__ void cpu_run(void); #endif gngb-20060309/src/emu.c0000644000175000017500000003600407703537376013123 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #ifdef HAVE_GETOPT_LONG #include #else #include "getopt.h" #endif #include #include #include #include "emu.h" #include "message.h" #include "rom.h" #include "vram.h" #include "serial.h" #include "memory.h" #include "cpu.h" #include "interrupt.h" #include "menu.h" #include "frame_skip.h" #include "sound.h" #include "sgb.h" #include "video_std.h" #include "save.h" #define ABS(a) (((a)>=0)?(a):(-(a))) /* Default mapping for joystick and keyboard */ Uint16 kmap[8]={SDLK_UP,SDLK_DOWN,SDLK_LEFT,SDLK_RIGHT, SDLK_x,SDLK_w,SDLK_RETURN,SDLK_RSHIFT}; Uint8 jmap[8]={1,1,0,0,3,2,0,1}; Sint16 *joy_axis; Uint8 *joy_but; /* Configuration File */ #define UINTEGER8 1 #define UINTEGER16 2 #define UINTEGER32 3 #define STRING 4 struct { char *name; int type; void *var; int size; } config_var[]={{"fullscreen",UINTEGER32,&conf.fs,1}, {"sound",UINTEGER32,&conf.sound,1}, {"show_fps",UINTEGER32,&conf.show_fps,1}, {"autoframeskip",UINTEGER32,&conf.autoframeskip,1}, {"throttle",UINTEGER32,&conf.throttle,1}, {"sleep_idle",UINTEGER32,&conf.sleep_idle,1}, {"rumble",UINTEGER32,&conf.rumble_on,1}, {"gb_type",UINTEGER32,&conf.gb_type,1}, {"delay_int",UINTEGER32,&conf.delay_int,1}, {"glmode",UINTEGER32,&conf.gl,1}, {"yuv",UINTEGER32,&conf.yuv,1}, {"yuv_type",UINTEGER32,&conf.yuv_type,1}, {"resolution_w",UINTEGER32,&conf.res_w,1}, {"resolution_h",UINTEGER32,&conf.res_h,1}, {"sample_rate",UINTEGER32,&conf.sample_rate,1}, {"joy_dev",UINTEGER32,&conf.joy_no,1}, {"map_joy",UINTEGER8,jmap,8}, {"map_key",UINTEGER16,kmap,8}, {"pal_1",UINTEGER32,conf.pal[0],4}, {"pal_2",UINTEGER32,conf.pal[1],4}, {"pal_3",UINTEGER32,conf.pal[2],4}, {"pal_4",UINTEGER32,conf.pal[3],4}, {"pal_5",UINTEGER32,conf.pal[4],4}, {"gdma_cycle",UINTEGER32,&conf.gdma_cycle,1}, {"const_cycle",UINTEGER32,&conf.const_cycle,1}, {"color_filter",UINTEGER32,&conf.color_filter,1}, {"filter",UINTEGER32,&conf.filter,1}, {NULL,0,NULL,0}}; enum { OPT_SAMPLE_RATE=256, OPT_YUV_TYPE, OPT_FILTER }; int option_index = 0; static struct option long_options[] = { {"help",0,NULL,'h'}, {"autoframeskip", 0, NULL, 'a'}, {"no-autoframeskip", 0, &conf.autoframeskip, 0}, {"sleep_idle", 0, &conf.sleep_idle, 1}, {"no-sleep_idle", 0, &conf.sleep_idle, 0}, {"color_filter",0,&conf.color_filter,1}, {"no-color_filter",0,&conf.color_filter,0}, {"rumble",0,NULL,'r'}, {"no-rumble",0,&conf.rumble_on,1}, {"res",1,NULL,'R'}, {"yuv",0,NULL,'Y'}, {"filter",1,NULL,OPT_FILTER}, {"no-yuv",0,&conf.yuv,0}, {"yuv_type",1,NULL,OPT_YUV_TYPE}, {"opengl",0,NULL,'o'}, {"no-opengl",0,&conf.gl,0}, {"fullscreen", 0, NULL, 'f'}, {"no-fullscreen", 0, &conf.fs, 0}, {"fps", 0, &conf.show_fps, 1}, {"no-fps", 0, &conf.show_fps, 0}, {"sound", 0, NULL, 's'}, {"no-sound", 0, &conf.sound, 0}, {"sample_rate",1, NULL, OPT_SAMPLE_RATE}, {"color_gb",0,NULL,'C'}, {"normal_gb",0,NULL,'G'}, {"super_gb",0,NULL,'S'}, {"auto_gb",0,&conf.gb_type,0}, {"constant_cycle",0,NULL,'y'}, {"no-constant_cycle",0,&conf.const_cycle,0}, {"gdma_cycle",0,NULL,'g'}, {"no-gdma_cycle",0,&conf.gdma_cycle,0}, {"joy_dev",1,0,'j'}, {"no-joy",0,&conf.use_joy,0}, {"version",0,NULL,'v'}, {0, 0, 0, 0} }; void print_help(void) { printf("Usage: gngb [OPTION]... FILE\n"); printf("Emulate the GameBoy rom pointed by FILE\n\n"); printf(" -h, --help print this help and exit\n"); printf(" -a, --autoframeskip turn on autoframeskip\n"); printf(" --sleep_idle sleep when idle\n"); printf(" --color_filter turn on the color filter\n"); printf(" -r, --rumble turn on the rumble simulation\n"); printf(" --filter=X Set the filter to apply (only for standard mode)\n"); printf(" 0 = none\n"); printf(" 1 = scanline\n"); printf(" 2 = scanline 50%%\n"); printf(" 3 = smooth\n"); printf(" 4 = pseudo cell shading\n"); printf(" -R, --res=WxH set the resolution to WxH (for YUV and GL mode)\n"); printf(" -Y, --yuv turn YUV mode on\n"); printf(" --yuv_type set the type of the YUV overlay\n"); printf(" 0 = YV12\n"); printf(" 1 = YUY2\n"); printf(" -o, --opengl turn OpenGL mode on (if conpiled in)\n"); printf(" -f, --fullscreen run gngb in fullscreen\n"); printf(" --fps show frame/sec\n"); printf(" -s, --sound turn on sound\n"); printf(" --sample_rate=RATE set the sample rate to RATE\n"); printf(" -C, --color_gb force to color gameboy mode\n"); printf(" -G, --normal_gb force to normal gameboy mode\n"); printf(" -S, --super_gb force to super gameboy mode (experimental)\n"); printf(" --auto_gb turn on automatique detection\n"); printf(" -j, --joy_dev=N use the Nth joystick\n"); printf(" -g, --gdma_cycle cpu stop during gdma transfer (experimental)\n"); printf(" -v, --version printf gngb number version\n"); printf("\n"); printf("Most options can be disabled whith --no-OPTION (Ex: --no-sound turn sound off)\n\n"); exit(0); } void setup_default_conf(void) { int i; conf.autoframeskip=0; conf.throttle=1; conf.sleep_idle=0; conf.sound=0; conf.serial_on=0; conf.use_joy=1; conf.joy_no=0; conf.fs=0; conf.gb_done=0; conf.rumble_on=0; conf.delay_int=0; conf.show_fps=0; conf.gb_type=0; /* deprecated: now allways constant cycle */ conf.const_cycle=0; conf.gdma_cycle=0; conf.color_filter=1; conf.sample_rate=44100; conf.gl=0; conf.filter=0; conf.yuv=0; conf.yuv_type=0; conf.yuv_interline_int=0x2020; // intensité d'une interligne en yuv color ((int&0xff)<<8)|(int&0xff) (unused now) conf.res_w=160*2; conf.res_h=144*2; conf.video_flag=0; conf.show_keycode=0; for (i=0;i<5;i++) { conf.pal[i][0]=0xB8A68D; //0xc618; // ffe6ce conf.pal[i][1]=0x917D5E; //0x8410; // bfad9a conf.pal[i][2]=0x635030; //0x4208; // 7f7367 conf.pal[i][3]=0x211A10; //0x0000; // 3f3933 } /* Movie */ conf.save_movie=0; conf.play_movie=0; } /* Function for read configuration File */ int discard_line(char *buf) { if (buf[0]=='#') return 1; if (buf[0]=='\n') return 1; return 0; } void read_tab(void *tab,int type,char *val,int size) { int i=0; char *v; v=strtok(val,","); while(v!=NULL && i0) { sdl_joy=SDL_JoystickOpen(conf.joy_no); if(sdl_joy) { printf("Name: %s\n", SDL_JoystickName(conf.joy_no)); printf("Number of Axes: %d\n", SDL_JoystickNumAxes(sdl_joy)); printf("Number of Buttons: %d\n", SDL_JoystickNumButtons(sdl_joy)); printf("Number of Balls: %d\n", SDL_JoystickNumBalls(sdl_joy)); joy_axis=(Sint16 *)malloc(sizeof(Sint16)*SDL_JoystickNumAxes(sdl_joy)); joy_but=(Uint8 *)malloc(sizeof(Uint8)*SDL_JoystickNumButtons(sdl_joy)); memset(joy_axis,0,sizeof(Sint16)*SDL_JoystickNumAxes(sdl_joy)); memset(joy_but,0,sizeof(Uint8)*SDL_JoystickNumButtons(sdl_joy)); } else { joy_axis=(Sint16 *)malloc(sizeof(Sint16)*2); joy_but=(Uint8 *)malloc(sizeof(Uint8)*4); memset(joy_axis,0,sizeof(Sint16)*2); memset(joy_but,0,sizeof(Uint8)*4); memset(jmap,0,8); } } else conf.use_joy=0; } if (conf.sound) if (gbsound_init()) conf.sound=0; } void emu_run(void) { } void emu_reset(void) { gblcdc_reset(); gbtimer_reset(); gbcpu_reset(); gbmemory_reset(); //if (conf.sound) gbsound_reset(); } void emu_pause(void) { } void emu_quit(void) { if (rom_type&BATTERY) { save_ram(); if (rom_type&TIMER) save_rom_timer(); } } gngb-20060309/src/emu.h0000644000175000017500000000470507656701673013133 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef EMU_H #define EMU_H #include "global.h" #include #include #include "fileio.h" // GAMEBOY TYPE #define UNKNOW 0x00 #define NORMAL_GAMEBOY 0x01 #define SUPER_GAMEBOY 0x02 #define COLOR_GAMEBOY 0x04 #define COLOR_GAMEBOY_ONLY 0x0c typedef struct { int autoframeskip; /* auto frameskip */ int throttle; int sleep_idle; int fs; /* fullscreen */ int sound; int color_filter; int rumble_on; int serial_on; int gb_done; int joy_no; int use_joy; int gl; int yuv; int yuv_type; int video_flag; int filter; int delay_int; int show_fps; int show_keycode; int res_w,res_h; int yuv_interline_int; int sample_rate; int gb_type; int const_cycle; int gdma_cycle; int save_movie; int play_movie; Sint32 pal[5][4]; }GNGB_CONF; GNGB_CONF conf; SDL_Joystick *sdl_joy; Uint16 key[SDLK_LAST]; extern Sint16 *joy_axis; extern Uint8 *joy_but; #define PAD_UP 0 #define PAD_DOWN 1 #define PAD_LEFT 2 #define PAD_RIGHT 3 #define PAD_A 4 #define PAD_B 5 #define PAD_START 6 #define PAD_SELECT 7 extern Uint8 jmap[8]; extern Uint16 kmap[8]; /* Movie */ typedef struct _pad_save { Uint8 pad; struct _pad_save *next; }PAD_SAVE; typedef struct _gngb_movie { char name[256]; int len; GNGB_FILE *stream; PAD_SAVE *first_pad; PAD_SAVE *last_pad; }GNGB_MOVIE; extern GNGB_MOVIE gngb_movie; void print_help(void); void setup_default_conf(void); void open_conf(void); void check_option(int argc,char *argv[]); void update_key(void); void emu_init(void); void emu_run(void); void emu_reset(void); void emu_pause(void); void emu_quit(void); #endif gngb-20060309/src/rom.c0000644000175000017500000001751207706266035013127 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include #include #ifdef HAVE_DIRENT_H #include #endif #ifdef HAVE_ZLIB_H #include #endif #include #include #include "rom.h" #include "memory.h" #include "emu.h" #include "cpu.h" #include "interrupt.h" #include "vram.h" #include "sound.h" #include "emu.h" #include "fileio.h" #include "save.h" #define FILENAME_LEN 1024 Sint16 rom_type=UNKNOW_TYPE; Uint8 rom_gb_type=UNKNOW; int check_dir(char *dir_name) { #ifdef WIN32 BOOL res; res = CreateDirectory(dir_name,NULL); if(res == 0) { return 0; } else { return 1; } #else DIR *d; if (!(d=opendir(dir_name)) && (errno==ENOENT)) { mkdir(dir_name,0755); return 0; } return 1; #endif } void get_ext_nb(char *r,int n) { sprintf(r,".%03d",n); } void get_bmp_ext_nb(char *r,int n) { sprintf(r,"%03d.bmp",n); } void set_gameboy_type(void) { if (rom_gb_type&COLOR_GAMEBOY) // prefer always CGB conf.gb_type=COLOR_GAMEBOY; else { if (rom_gb_type&SUPER_GAMEBOY && !conf.yuv) // prefer SGB if not CGB conf.gb_type=SUPER_GAMEBOY; else conf.gb_type=NORMAL_GAMEBOY; } } void check_gameboy_type(void) { if (conf.gb_type&COLOR_GAMEBOY && rom_gb_type&NORMAL_GAMEBOY && !(rom_gb_type&COLOR_GAMEBOY)) { printf("WARNING:Normal gb game on Color gb dont work for the moment\n"); printf("Force to normal gb\n"); conf.gb_type&=(~COLOR_GAMEBOY); } } int open_rom(char *filename) { Uint8 gb_memory[32768]; GNGB_FILE * stream; int i; if (rom_page) free_mem_page(rom_page,nb_rom_page); if (ram_page) free_mem_page(ram_page,nb_ram_page); if (vram_page) free_mem_page(vram_page,nb_vram_page); if (wram_page) free_mem_page(wram_page,nb_wram_page); rom_page=ram_page=vram_page=wram_page=NULL; if ((stream=gngb_file_open(filename,"rb",UNKNOW_FILE_TYPE))) { printf("stream %d\n",stream->type); if (stream->type==ZIP_ARCH_FILE_TYPE) { #ifdef HAVE_LIBZ if (zip_file_open_next_rom(stream->stream)<0) return -1; #else fprintf(stderr,"Zip file unsupported\n"); return -1; #endif } printf("Open file %s\n",filename); rom_name=get_name_without_ext(filename); printf("Rom Name %s\n",rom_name); gngb_file_read(gb_memory,sizeof(char),32768,stream); printf("Name : %.15s\n",gb_memory+0x134); if (gb_memory[0x0143]==0x80) { rom_gb_type=COLOR_GAMEBOY|NORMAL_GAMEBOY; printf("Color GameBoy\n"); printf("Normal GameBoy Supported\n"); } else if (gb_memory[0x0143]==0xc0) { rom_gb_type=COLOR_GAMEBOY_ONLY; printf("Color GameBoy\n"); printf("Normal GameBoy Not Supported !! \n"); } else { rom_gb_type=NORMAL_GAMEBOY; printf("Normal GameBoy\n"); } if (gb_memory[0x0146]) { rom_gb_type|=SUPER_GAMEBOY; printf("SGB Supported %02x\n",gb_memory[0x0146]); } //if (conf.normal_gb) gameboy_type=NORMAL_GAMEBOY; if (conf.gb_type==UNKNOW) set_gameboy_type(); else check_gameboy_type(); printf("configuration %02x : ",gb_memory[0x147]); switch(gb_memory[0x147]) { case 0x00: printf("ROM ONLY\n"); rom_type=ROM_ONLY;break; case 0x01: printf("MBC1\n"); rom_type=MBC1;break; case 0x02: printf("MBC1+RAM\n"); rom_type=MBC1|RAM;break; case 0x03: printf("MBC1+RAM+BATTERY\n"); rom_type=MBC1|RAM|BATTERY;break; case 0x05: printf("MBC2\n"); rom_type=MBC2;break; case 0x06: printf("MBC2+BATTERY\n"); rom_type=MBC2|BATTERY;break; case 0x08: printf("ROM+RAM\n"); rom_type=ROM_ONLY|RAM;break; case 0x09: printf("ROM+RAM+BATTERY\n"); rom_type=ROM_ONLY|RAM|BATTERY;break; case 0x0b: case 0x0c: case 0x0d: printf("unknown\n"); rom_type=UNKNOW_TYPE;break; case 0x0f: printf("MBC3+TIMER+BATTERY\n");rom_type=MBC3|TIMER|BATTERY;break; case 0x10: printf("MBC3+TIMER+RAM+BATTERY\n");rom_type=MBC3|TIMER|BATTERY|RAM;break; case 0x11: printf("MBC3\n");rom_type=MBC3;break; case 0x12: printf("MBC3+RAM\n"); rom_type=MBC3|RAM;break; case 0x13: printf("MBC3+RAM+BATTERY\n"); rom_type=MBC3|RAM|BATTERY;break; case 0x19: printf("MBC5\n"); rom_type=MBC5;break; case 0x1a: printf("MBC5+RAM\n"); rom_type=MBC5|RAM;break; case 0x1b: printf("MBC5+RAM+BATTERY\n"); rom_type=MBC5|RAM|BATTERY;break; case 0x1c: printf("MBC5+RUMBLE\n"); rom_type=MBC5|RUMBLE;break; case 0x1d: printf("MBC5+RUMBLE+SRAM\n"); rom_type=MBC5|RUMBLE|SRAM;break; case 0x1e: printf("MBC5+RUMBLE+SRAM+BATTERY\n"); rom_type=MBC5|RUMBLE|SRAM|BATTERY;break; case 0x22: printf("MBC7 (not suported)\n"); rom_type=UNKNOW_TYPE;break; case 0xFF: printf(" Hudson HuC-1\n"); /* FIXME: HUC1=MBC1 */rom_type=MBC1;break; default: printf("unknown %02x \n",gb_memory[0x147]); rom_type=UNKNOW_TYPE;break; } printf("ROM size %d : %u * 16 kbyte \n",gb_memory[0x148],1<cycle=0; rom_timer->reg_sel=0; rom_timer->latch=0; memset(rom_timer->reg,0,sizeof(Uint8)*5); } else rom_timer=NULL; /* RAM */ if ((rom_type&RAM) || (rom_type&SRAM)) { switch(gb_memory[0x149]) { case 0:printf("RAM size %02x : 0 ?????\n",gb_memory[0x149]);nb_ram_page=1;ram_mask=0x00;break; case 1:printf("RAM size %02x : 2 kbyte\n",gb_memory[0x149]);nb_ram_page=1;ram_mask=0x00;break; case 2:printf("RAM size %02x : 8 kbyte\n",gb_memory[0x149]);nb_ram_page=1;ram_mask=0x00;break; case 3:printf("RAM size %02x : 32 kbyte\n",gb_memory[0x149]);nb_ram_page=4;ram_mask=0x03;break; case 4:printf("RAM size %02x : 128 kbyte\n",gb_memory[0x149]);nb_ram_page=16;ram_mask=0x0f;break; } } else { printf("NO RAM\n"); nb_ram_page=1; ram_mask=0x00; } ram_page=alloc_mem_page(nb_ram_page,0x2000); active_ram_page=0; if (rom_type&BATTERY) { load_ram(); if (rom_type&TIMER) load_rom_timer(); } /* VRAM & INTERNAL RAM */ if (conf.gb_type&COLOR_GAMEBOY) { nb_vram_page=2; nb_wram_page=8; } else { nb_vram_page=1; nb_wram_page=2; } vram_page=alloc_mem_page(nb_vram_page,0x2000); active_vram_page=0; wram_page=alloc_mem_page(nb_wram_page,0x1000); active_wram_page=1; switch(gb_memory[0x014a]) { case 0:printf("Country : Japanese \n");break; case 1:printf("Country : Non-Japanese \n");break; } gngb_file_close(stream); if (rom_type!=UNKNOW_TYPE) return 0; else return 1; } return 1; } gngb-20060309/src/rom.h0000644000175000017500000000304707643033301013116 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _ROM_H #define _ROM_H #include "global.h" #include /* rom type definition */ #define UNKNOW_TYPE 0x00 #define ROM_ONLY 0x01 #define MBC1 0x02 #define MBC2 0x04 #define MBC3 0x08 #define MBC5 0x10 #define RAM 0x20 #define BATTERY 0x40 #define TIMER 0x80 #define RUMBLE 0x100 #define SRAM 0x200 #define HUC1 0x400 char *rom_name; extern Sint16 rom_type; // rom_gb_suport extern Uint8 rom_gb_type; typedef struct { Uint16 cycle; Uint8 reg_sel; Uint8 latch; Uint8 reg[5]; Uint8 regl[5]; // register locked }ROM_TIMER; // MBC3 ROM_TIMER *rom_timer; int open_rom(char *filename); #endif gngb-20060309/src/sgb.c0000644000175000017500000003555207715136631013107 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include "memory.h" #include "sgb.h" #include "rom.h" #include "vram.h" #include "emu.h" #define SGB_CMD_END() {sgb.cmd=0xff;sgb.nb_pack=-1;} #define SGB_COLOR(c) ((((c)&0x7C00)>>10)|(((c)&0x3E0)<<1)|(((c)&0x1F)<<11)) Uint8 sgb_tiles[256*32]; Uint8 sgb_map[32*32]; Uint8 sgb_att[32*32]; SDL_Surface *sgb_buf=NULL; extern Uint16 Filter[32768]; Uint16 sgb_border_pal[64]; Uint16 sgb_scpal[512][4]; // 512 pallete of 4 color Uint8 sgb_ATF[45][90]; Uint8 sgb_buffer[4160]; static Uint8 sgb_flag=0; void sgb_init(void) { int i; sgb_buf=SDL_CreateRGBSurface(SDL_HWSURFACE,SGB_WIDTH,SGB_HEIGHT,16, 0xf800,0x7e0,0x1f,0x00); if (sgb_buf==NULL) { fprintf(stderr,"Couldn't set %dx%dx%d video mode: %s\n", SGB_WIDTH,SGB_HEIGHT,16,SDL_GetError()); exit(1); } memset(sgb_pal_map,0,20*18); for(i=0;i<4;i++) { sgb_pal[i][0]=grey[0]; sgb_pal[i][1]=grey[1]; sgb_pal[i][2]=grey[2]; sgb_pal[i][3]=grey[3]; } sgb_mask=0; sgb.player=0; SGB_CMD_END(); } /* SGB Border */ __inline__ void sgb_tiles_pat_transfer(void) { //char type=sgb.pack[1]>>2; Uint8 range=sgb.pack[1]&0x01; Uint8 *src,*dst; // printf("Pack %02x\n",sgb.pack[1]); src=&vram_page[0][0x800]; dst=(!range)?(&sgb_tiles[0]):(&sgb_tiles[0x80*32]); memcpy(dst,src,0x80*32); SGB_CMD_END(); } __inline__ void sgb_tiles_map_transfer(void) { int i; //printf("%02x\n",LCDCCONT); for(i=0;i<32*32;i++) { /* FIXME: dkl2 et conker => 0x1000 */ if (sgb_flag) { sgb_map[i]=vram_page[0][0x1000+i*2]; sgb_att[i]=vram_page[0][0x1000+i*2+1]; } else { sgb_map[i]=vram_page[0][0x800+i*2]; sgb_att[i]=vram_page[0][0x800+i*2+1]; } } /* FIXME: dkl2 et conker => 0x800 */ /* TODO: Fix sgb border color 0 */ if (sgb_flag) for(i=0;i<64;i++) sgb_border_pal[i]=SGB_COLOR((vram_page[0][0x800+i*2+1]<<8)|vram_page[0][0x800+i*2]); else for(i=0;i<64;i++) sgb_border_pal[i]=SGB_COLOR((vram_page[0][0x1000+i*2+1]<<8)|vram_page[0][0x1000+i*2]); sgb_border_pal[0]=0xffff; SGB_CMD_END(); } __inline__ void sgb_draw_one_tile(Uint16 *buf,int x,int y,Uint16 no_tile,Uint8 att,Uint16 pitch) { int sx,sy; char bit0,bit1,bit2,bit3; int c; char xflip=att&0x40; Uint16 *b=&buf[x+y*(pitch>>1)]; pitch=pitch>>1; /* FIXME: comme ca dkl2 et conker ca marche mais dragon quest nan :(*/ if (sgb_flag) { if (no_tile>=128) no_tile=((64+no_tile)%128)+128; else no_tile=(64+no_tile)%128; } no_tile=no_tile|((att&0x03)<<6); if (att&0x80) { // yflip for(sy=7;sy>=0;sy--,b+=pitch) { for(sx=0;sx<8;sx++) { int wbit; if (!xflip) wbit=sx; else wbit=7-sx; bit0=(sgb_tiles[no_tile*32+sy*2]&tab_ms[wbit].mask)>>tab_ms[wbit].shift; bit1=(sgb_tiles[no_tile*32+1+sy*2]&tab_ms[wbit].mask)>>tab_ms[wbit].shift; bit2=(sgb_tiles[no_tile*32+16+sy*2]&tab_ms[wbit].mask)>>tab_ms[wbit].shift; bit3=(sgb_tiles[no_tile*32+16+1+sy*2]&tab_ms[wbit].mask)>>tab_ms[wbit].shift; c=(bit3<<3)|(bit2<<2)|(bit1<<1)|bit0; b[sx]=sgb_border_pal[c|((att&0x0c)<<2)]; } } } else { for(sy=0;sy<8;sy++,b+=pitch) { for(sx=0;sx<8;sx++) { int wbit; if (!xflip) wbit=sx; else wbit=7-sx; bit0=(sgb_tiles[no_tile*32+sy*2]&tab_ms[wbit].mask)>>tab_ms[wbit].shift; bit1=(sgb_tiles[no_tile*32+1+sy*2]&tab_ms[wbit].mask)>>tab_ms[wbit].shift; bit2=(sgb_tiles[no_tile*32+16+sy*2]&tab_ms[wbit].mask)>>tab_ms[wbit].shift; bit3=(sgb_tiles[no_tile*32+16+1+sy*2]&tab_ms[wbit].mask)>>tab_ms[wbit].shift; c=(bit3<<3)|(bit2<<2)|(bit1<<1)|bit0; b[sx]=sgb_border_pal[c|((att&0x0c)<<2)]; } } } } __inline__ void sgb_draw_tiles(void) { int i,j; Uint16 *buf; Uint16 pitch; buf=(Uint16 *)sgb_buf->pixels; pitch=sgb_buf->pitch; for(j=0;j<28;j++) for(i=0;i<32;i++) sgb_draw_one_tile(buf,i*8,j*8,sgb_map[i+j*32],sgb_att[i+j*32],pitch); cur_mode->blit_sgb_mask(); } /* Area Designation Mode Functions */ __inline__ void set_pal_Hline(int line,int pal) { int i; for(i=0;i<20;i++) sgb_pal_map[i][line]=pal; } __inline__ void set_pal_Vline(int line,int pal) { int i; for(i=0;i<18;i++) sgb_pal_map[line][i]=pal; } __inline__ void set_pal_Hline_range(int l1,int l2,int pal) { int i,j; for(j=l1;j<=l2;j++) for(i=0;i<20;i++) sgb_pal_map[i][j]=pal; } __inline__ void set_pal_Vline_range(int l1,int l2,int pal) { int i,j; for(i=l1;i<=l2;i++) for(j=0;j<18;j++) sgb_pal_map[i][j]=pal; } __inline__ void set_pal_inside_block(int x1,int y1,int x2,int y2,int pal) { int x,y; if (x1<0) x1=0; if (x2>=20) x2=20; if (y1<0) y1=0; if (y2>=18) y2=18; for(x=x1+1;x0) set_pal_Hline_range(0,y1-1,pal); if (y2<17) set_pal_Hline_range(y2+1,17,pal); if (x1>0) set_pal_Vline_range(0,x1-1,pal); if (x2<19) set_pal_Vline_range(x2+1,19,pal); } __inline__ void set_pal_on_block(int x1,int y1,int x2,int y2,int pal) { int x,y; if (x1<0) x1=0; if (x2>=20) x2=19; for(x=x1;x<=x2;x++) { if (y1>=0) sgb_pal_map[x][y1]=pal; if (y2<18) sgb_pal_map[x][y2]=pal; } if (y1<0) y1=0; if (y2>=18) y2=17; for(y=y1;y<=y2;y++) { if (x1>=0) sgb_pal_map[x1][y]=pal; if (x2<20) sgb_pal_map[x2][y]=pal; } } __inline__ void sgb_block_mode(void) { static Sint8 nb_dataset; static Uint8 dataset[6]; static Uint8 ds_i; // dataset indice Uint8 p_i; // packet indice if (sgb.nb_pack==-1) { // first call //printf("Block mode\n"); sgb.nb_pack=sgb.pack[0]&0x07; nb_dataset=sgb.pack[1]&0x1f; //printf("nb dataset %02x\n",nb_dataset); p_i=2; ds_i=0; } else p_i=0; while(nb_dataset>0 && p_i>4)&0x03; py=(dataset[1]>>2)&0x03; pz=(dataset[1]&0x03); nb_dataset--; //printf("type %d p %d %d %d line %d %d %d %d\n",dataset[0]&0x07,px,py,pz,SH,SV,EH,EV); ds_i=0; switch(dataset[0]&0x07) { case 0x00:break; case 0x01: set_pal_inside_block(SH,SV,EH,EV,pz); set_pal_on_block(SH,SV,EH,EV,pz); break; case 0x02: set_pal_on_block(SH,SV,EH,EV,py); break; case 0x03: set_pal_inside_block(SH,SV,EH,EV,py); set_pal_on_block(SH,SV,EH,EV,py); break; case 0x04: set_pal_outside_block(SH,SV,EH,EV,px); break; case 0x05: set_pal_inside_block(SH,SV,EH,EV,pz); set_pal_outside_block(SH,SV,EH,EV,px); break; case 0x06: set_pal_outside_block(SH,SV,EH,EV,px); break; case 0x07: set_pal_inside_block(SH,SV,EH,EV,pz); set_pal_on_block(SH,SV,EH,EV,py); set_pal_outside_block(SH,SV,EH,EV,px); break; } } } sgb.nb_pack--; if (sgb.nb_pack==0) SGB_CMD_END(); } __inline__ void sgb_line_mode(void) { int i; static Sint16 nb_dataset; if (sgb.nb_pack==-1) { // first call sgb.nb_pack=sgb.pack[0]&0x07; //printf("%d\n",sgb.nb_pack); //printf("Line mode\n"); nb_dataset=sgb.pack[1]; //printf("nb dataset %d\n",nb_dataset); i=2; } else i=0; while(nb_dataset>0 && i>5);*/ if ((sgb.pack[i]&0x40)) // mode vertical set_pal_Vline(sgb.pack[i]&0x1f,(sgb.pack[i]>>5)&0x03); //set_pal_Vline_range(0,sgb.pack[i]&0x1f,(sgb.pack[i]>>5)&0x03); else // mode horizontal set_pal_Hline(sgb.pack[i]&0x1f,(sgb.pack[i]>>5)&0x03); //set_pal_Hline_range(0,sgb.pack[i]&0x1f,(sgb.pack[i]>>5)&0x03); i++; } sgb.nb_pack--; if (sgb.nb_pack==0) SGB_CMD_END(); } __inline__ void sgb_divide_mode(void) { int line=sgb.pack[2]&0x1f; /*printf("Divide mode\n"); printf(((sgb.pack[1]&0x40)?"Vertical\n":"Horizontal\n")); printf("Line %d\n",sgb.pack[2]); printf("Color %d %d %d \n",(sgb.pack[1]&0x30)>>4,(sgb.pack[1]&0x0c)>>2,sgb.pack[1]&0x03);*/ if (!(sgb.pack[1]&0x40)) { set_pal_Vline(line,(sgb.pack[1]&0x30)>>4); set_pal_Vline_range(0,line-1,(sgb.pack[1]>>2)&0x03); set_pal_Vline_range(line+1,19,(sgb.pack[1]/*>>2*/)&0x03); } else { set_pal_Hline(line,(sgb.pack[1]&0x30)>>4); set_pal_Hline_range(0,line-1,(sgb.pack[1]>>2)&0x03); set_pal_Hline_range(line+1,17,(sgb.pack[1]/*>>2*/)&0x03); } SGB_CMD_END(); } __inline__ void sgb_1chr_mode(void) { static Uint8 mode; static Uint16 nb_dataset; static Uint8 I,J; static int i; if (sgb.nb_pack==-1) { // first call sgb.nb_pack=sgb.pack[0]&0x07; /*printf("1chr mode\n"); printf("Nb packet %d\n",sgb.pack[0]&0x07); printf("X %d Y %d\n",sgb.pack[1]&0x1f,sgb.pack[2]&0x1f); printf("Nb dataset %d\n",sgb.pack[3]); printf("MSB %d\n",sgb.pack[4]); printf("Writing style %d\n",sgb.pack[5]); printf("Data ....\n");*/ I=(sgb.pack[1]&0x1f); J=(sgb.pack[2]&0x1f); nb_dataset=((sgb.pack[4]&0x01)<<8)|sgb.pack[3]; if (nb_dataset>360) nb_dataset=360; mode=sgb.pack[5]&0x01; i=6; } else i=0; while(i=0;t--) { //p=(sgb.pack[i]&(0x03<<(t*2)))>>(t*2); p=(sgb.pack[i]>>(t*2))&0x03; sgb_pal_map[I][J]=p; if (!mode) { I=(I+1)%20; if (!I) J++; } else { J=(J+1)%18; if (!J) I++; } } i++; } sgb.nb_pack--; //printf("packet num %d\n",sgb.nb_pack); if (sgb.nb_pack==0) SGB_CMD_END(); } void set_ATF_nf(int nf,int mode) { int i,j,n; Uint8 *t=sgb_ATF[nf]; /*printf("Set data from ATF \n"); printf("Num file %d\n",nf); printf("Mode %d\n",mode);*/ for(j=0;j<18;j++) { i=0; for(n=0;n<5;n++,t++) { sgb_pal_map[i++][j]=(*t)>>6; sgb_pal_map[i++][j]=((*t)&0x30)>>4; sgb_pal_map[i++][j]=((*t)&0x0c)>>2; sgb_pal_map[i++][j]=((*t)&0x03); } } if (mode) sgb_mask=0; } void sgb_set_ATF(void) { int i; Uint8 *t=&vram_page[0][0x800]; //printf("Set ATF \n"); for(i=0;i<45;i++,t+=90) memcpy(sgb_ATF[i],t,90); set_ATF_nf(0,0); SGB_CMD_END(); } void sgb_set_data_ATF(void) { set_ATF_nf(sgb.pack[1]&0x3f,sgb.pack[1]&0x40); SGB_CMD_END(); } /* Pallete Functions */ __inline__ void sgb_set_scpal_data(void) { int i,j; Uint8 *t=&vram_page[0][0x800]; for(i=0;i<512;i++) for(j=0;j<4;j++,t+=2) sgb_scpal[i][j]=SGB_COLOR((*(t+1)<<8)|(*t)); /* FIXME */ /*n=0; for(i=16;i<32;i++) for(j=0;j<4;j++) sgb_border_pal[n++]=sgb_scpal[i][j]; sgb_draw_tiles();*/ SGB_CMD_END(); } __inline__ void sgb_set_pal_indirect(void) { memcpy(sgb_pal[0],sgb_scpal[((sgb.pack[2]&0x01)<<8)|sgb.pack[1]],2*4); memcpy(sgb_pal[1],sgb_scpal[((sgb.pack[4]&0x01)<<8)|sgb.pack[3]],2*4); memcpy(sgb_pal[2],sgb_scpal[((sgb.pack[6]&0x01)<<8)|sgb.pack[5]],2*4); memcpy(sgb_pal[3],sgb_scpal[((sgb.pack[8]&0x01)<<8)|sgb.pack[7]],2*4); if (sgb.pack[9]) set_ATF_nf(sgb.pack[9]&0x3f,1); SGB_CMD_END(); } __inline__ void sgb_setpal(int p1,int p2) { int i; for(i=0;i<4;i++) sgb_pal[i][0]=SGB_COLOR((sgb.pack[2]<<8)|sgb.pack[1]); sgb_pal[p1][1]=SGB_COLOR((sgb.pack[4]<<8)|sgb.pack[3]); sgb_pal[p1][2]=SGB_COLOR((sgb.pack[6]<<8)|sgb.pack[5]); sgb_pal[p1][3]=SGB_COLOR((sgb.pack[8]<<8)|sgb.pack[7]); sgb_pal[p2][1]=SGB_COLOR((sgb.pack[10]<<8)|sgb.pack[9]); sgb_pal[p2][2]=SGB_COLOR((sgb.pack[12]<<8)|sgb.pack[11]); sgb_pal[p2][3]=SGB_COLOR((sgb.pack[14]<<8)|sgb.pack[13]); SGB_CMD_END(); } /* Misc Function */ __inline__ void sgb_function(void) { switch(sgb.pack[1]) { case 0x01:/*sgb_flag=1;*/break; // Please if you know what do this function (email me) } SGB_CMD_END(); } __inline__ void sgb_window_mask(void) { /* je ne sais pas si c'est ca */ /* apres quelque test: apparement nan :( */ printf("LCDCSTAT: %02x LCDCCONT: %02x SCR: %02x %02x WIN: %02x %02x LY: %02x LYC: %02x\n",LCDCSTAT,LCDCCONT,SCRX,SCRY,WINX,WINY,CURLINE,CMP_LINE); switch(sgb.pack[1]&0x03) { case 0x00:sgb_mask=0;break; case 0x01: // i dint know what it do case 0x02: /*for(i=0;i<4;i++) memset(sgb_pal[i],0,sizeof(Uint16)*4); break;*/ case 0x03: /*for(i=0;i<4;i++) memset(sgb_pal[i],0xffff,sizeof(Uint16)*4); break;*/ sgb_mask=1; break; } SGB_CMD_END(); } void sgb_exec_cmd(void) { if (sgb.cmd==0xff) { int i; /* printf("sgb:%02x nb:%d pack: ",sgb.pack[0]>>3,sgb.pack[0]&0x07); for(i=0;i>3; } // printf("LCDCSTAT: %02x LCDCCONT: %02x SCR: %02x %02x WIN: %02x %02x LY: %02x LYC: %02x\n",LCDCSTAT,LCDCCONT,SCRX,SCRY,WINX,WINY,CURLINE,CMP_LINE); switch(sgb.cmd) { case 0x11: //GB_PAD=(gameboy_type&SUPER_GAMEBOY)?0x30:0xff; //printf("check sgb %02x\n",GB_PAD); if (sgb.pack[1]==0x03) GB_PAD=(conf.gb_type&SUPER_GAMEBOY)?0x30:0xff; else { sgb.player=sgb.pack[1]&0x01; //sgb.player|=0x80; } SGB_CMD_END(); break; //GB_PAD=0xff;break; // SGB Function case 0x0e:sgb_function();break; // SGB Border case 0x13:sgb_tiles_pat_transfer();break; case 0x14: sgb_tiles_map_transfer(); sgb_draw_tiles(); break; // Area using pallete case 0x04:sgb_block_mode();break; case 0x05:sgb_line_mode();break; case 0x06:sgb_divide_mode();break; case 0x07:sgb_1chr_mode();break; // ATF case 0x15:sgb_set_ATF();break; case 0x16:sgb_set_data_ATF();break; // Palette direct case 0x00:sgb_setpal(0,1);break; case 0x01:sgb_setpal(2,3);break; case 0x02:sgb_setpal(0,3);break; case 0x03:sgb_setpal(1,2);break; // Palette indirect case 0x0a:sgb_set_pal_indirect();break; case 0x0b:sgb_set_scpal_data();break; // Misc case 0x17:sgb_window_mask();break; case 0x18: // I dont know what do this function case 0x19: SGB_CMD_END(); break; default: SGB_CMD_END();break; } } gngb-20060309/src/sgb.h0000644000175000017500000000314207643033301013070 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef SGB_H #define SGB_H #include #include #include "global.h" #include "vram.h" #define SGB_WIDTH 256 #define SGB_HEIGHT 224 #define SGB_PACKSIZE 16 /* 128/8=16 */ typedef struct { Uint8 on; /* on!=0 during a transfert */ Uint8 cmd; Sint8 nb_pack; /* nb packet for the cmd */ Uint8 b; Uint8 pack[SGB_PACKSIZE]; Sint16 b_i; /* ieme bit du package */ Uint8 player; }SGB; SGB sgb; Uint16 sgb_pal[4][4]; /* 4 pallete of 4 colour */ Uint8 sgb_pal_map[20][18]; /* Map of Pallete Tiles */ Uint8 sgb_mask; extern SDL_Surface *sgb_buf; #define sgb_init_transfer() { \ sgb.on=1; \ sgb.b_i=-1; \ memset(sgb.pack,0,SGB_PACKSIZE);} void sgb_exec_cmd(void); void sgb_init(void); #endif gngb-20060309/src/interrupt.c0000644000175000017500000003346710347005403014356 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "interrupt.h" #include "frame_skip.h" #include "memory.h" #include "vram.h" #include "cpu.h" #include "emu.h" #include "rom.h" #define DELAY_CYCLE 24 static const Uint16 lcd_cycle_tab[2][5]={{204,456,80,172,80}, /* GB */ {204*2,456*2,80*2,172*2,80*2}}; /* CGB */ Uint32 nb_cycle=0; Uint32 key_cycle=0; Uint8 vram_init_pal=0; Uint32 get_nb_cycle(void) { Uint32 t=nb_cycle; SDL_LockAudio(); nb_cycle=0; SDL_UnlockAudio(); return t; } __inline__ Uint8 make_interrupt(Uint8 n) { if ((INT_ENABLE&n) && (gbcpu->int_flag)) { if (gbcpu->state==HALT_STATE) { gbcpu->state=0; gbcpu->pc.w++; } INT_FLAG&=(~n); gbcpu->int_flag=0; push_stack_word(gbcpu->pc.w); switch(n) { case VBLANK_INT:gbcpu->pc.w=0x0040;break; case LCDC_INT:gbcpu->pc.w=0x0048;break; case TIMEOWFL_INT:gbcpu->pc.w=0x0050;break; case SERIAL_INT:gbcpu->pc.w=0x0058;break; } return 1; } return 0; } void go2double_speed(void) { if (gbcpu->mode==DOUBLE_SPEED) return; gblcdc->mode1cycle=912; gblcdc->mode2cycle=160; gblcdc->vblank_cycle=70224*2; gblcdc->timing=1; gbcpu->mode=DOUBLE_SPEED; } void go2simple_speed(void) { if (gbcpu->mode==SIMPLE_SPEED) return; gblcdc->mode1cycle=456; gblcdc->mode2cycle=80; gblcdc->vblank_cycle=70224; gblcdc->timing=0; gbcpu->mode=SIMPLE_SPEED; } // GB LCD void gblcdc_init(void) { gblcdc=(GBLCDC *)malloc(sizeof(GBLCDC)); gblcdc_reset(); } void gblcdc_reset(void) { int i; gblcdc->vblank_cycle=70224; gblcdc->mode1cycle=456; gblcdc->mode2cycle=80; gblcdc->mode3cycle=170; gblcdc->cycle=gblcdc->mode2cycle; /* FIXME: SGB timing change */ /*if (conf.gb_type==SUPER_GAMEBOY) gblcdc->timing=0; else*/ gblcdc->timing=0; /* TRICK for emulate vic viper laser */ gblcdc->vram_factor=1.0; for(i=0;i<160;i++) gblcdc->vram_pal_line[i]=pal_bck; gblcdc_set_on(); } void gblcdc_set_on(void) { gblcdc->win_curline=0; CURLINE=0x00; LCDCCONT|=0x80; gblcdc->inc_line=0; gblcdc->mode=END_VBLANK_PER; vram_init_pal=1; clear_screen(); reset_frame_skip(); gblcdc->cycle=gblcdc_update(); } Uint16 gblcdc_update(void) // LCDC is on { Uint16 ret=0; Uint8 skip_this_frame; int x; if (!(LCDCCONT&0x80)) return 0; if (gblcdc->inc_line) { CURLINE++; LCDCSTAT&=0xf8; if ((CURLINE && CURLINE==CMP_LINE) || ((CURLINE==0x99 && CMP_LINE==0x00))) LCDCSTAT|=0x04; } if (CURLINE==0x90 && (gblcdc->mode==OAM_PER || gblcdc->mode==BEGIN_OAM_PER)) { if (!conf.delay_int) { gblcdc->mode=VBLANK_PER; set_interrupt(VBLANK_INT); } else gblcdc->mode=LINE_90_BEGIN; } if (CURLINE==0x00 && gblcdc->mode==END_VBLANK_PER) { LCDCSTAT&=0xf8; skip_this_frame=skip_next_frame; if (!skip_this_frame) blit_screen(); skip_next_frame=frame_skip(0); if (1/*!conf.delay_int*/) gblcdc->mode=OAM_PER; else gblcdc->mode=BEGIN_OAM_PER; gblcdc->win_curline=0; } if (CURLINE==0x99 && gblcdc->mode==LINE_99) { CURLINE=0x00; gblcdc->mode=END_VBLANK_PER; } else if (CURLINE==0x99) { gblcdc->mode=LINE_99; } switch(gblcdc->mode) { case HBLANK_PER: // HBLANK if (LCDCSTAT&0x08) set_interrupt(LCDC_INT); if (!skip_next_frame) draw_screen(); ret=lcd_cycle_tab[gblcdc->timing][0]; if (1/*!conf.delay_int*/) gblcdc->mode=OAM_PER; else gblcdc->mode=BEGIN_OAM_PER; if (dma_info.type==HDMA) do_hdma(); gblcdc->inc_line=1; LCDCSTAT&=0xfc; break; case LINE_90_BEGIN: gblcdc->inc_line=0; LCDCSTAT|=0x01; if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); ret=DELAY_CYCLE; gblcdc->mode=LINE_90_END; break; case LINE_90_END: gblcdc->inc_line=1; if (LCDCSTAT&0x10) set_interrupt(LCDC_INT); ret=lcd_cycle_tab[gblcdc->timing][1]-DELAY_CYCLE-8; LCDCSTAT|=0x01; gblcdc->mode=VBLANK_PER; set_interrupt(VBLANK_INT); break; case LINE_99: LCDCSTAT|=0x01; /* FIXME: Line 99 Timing */ ret=lcd_cycle_tab[gblcdc->timing][4]; gblcdc->inc_line=0; break; case END_VBLANK_PER: LCDCSTAT|=0x01; if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); ret=lcd_cycle_tab[gblcdc->timing][1]-lcd_cycle_tab[gblcdc->timing][4]; gblcdc->inc_line=0; break; case VBLANK_PER: // VBLANK /* FIXME => water.gbc */ if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); LCDCSTAT|=0x01; ret=lcd_cycle_tab[gblcdc->timing][1]; gblcdc->inc_line=1; break; case BEGIN_OAM_PER: LCDCSTAT|=0x02; gblcdc->inc_line=0; gblcdc->mode=OAM_PER; ret=DELAY_CYCLE; ret=24; if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); break; case OAM_PER: // OAM LCDCSTAT|=0x02; gblcdc->inc_line=0; /* FIXME: Pinball Deluxe */ if (LCDCSTAT&0x20) set_interrupt(LCDC_INT); if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); ret=lcd_cycle_tab[gblcdc->timing][2]; /*if (conf.delay_int) ret-=DELAY_CYCLE;*/ gblcdc->mode=VRAM_PER; gblcdc->nb_spr=get_nb_spr(); break; case VRAM_PER: // VRAM LCDCSTAT|=0x03; ret=lcd_cycle_tab[gblcdc->timing][3]; gblcdc->mode=HBLANK_PER; /* FIXME */ gblcdc->mode3cycle=ret; gblcdc->vram_factor=160.0/(double)(gblcdc->mode3cycle); if (vram_init_pal) { for(x=0;x<160;x++) gblcdc->vram_pal_line[x]=pal_bck; pal_bck[0]=BGPAL&3; pal_bck[1]=(BGPAL>>2)&3; pal_bck[2]=(BGPAL>>4)&3; pal_bck[3]=(BGPAL>>6)&3; vram_init_pal=0; } break; } return ret; } /* New Implemantation og gblcdc_updtate */ Uint16 gblcdc_update2(void) // LCDC is on { Uint16 ret=0; Uint8 skip_this_frame; int x; if (!(LCDCCONT&0x80)) return 0; if (CURLINE==0x00 && gblcdc->mode==END_VBLANK_PER) { // LCDCSTAT&=0xf8; skip_this_frame=skip_next_frame; if (!skip_this_frame) blit_screen(); skip_next_frame=frame_skip(0); gblcdc->mode=OAM_PER; gblcdc->win_curline=0; } if (gblcdc->mode==LINE_99) { CURLINE=0x00; LCDCSTAT&=0xf8; if (CURLINE==CMP_LINE) LCDCSTAT|=0x04; if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); gblcdc->mode=END_VBLANK_PER; } if (gblcdc->inc_line) { CURLINE++; if (CURLINE==0x90) { if (gbcpu->state==HALT_STATE) { set_interrupt(VBLANK_INT); gblcdc->mode=VBLANK_PER; } else gblcdc->mode=LINE_90_BEGIN; } if (CURLINE==0x99) gblcdc->mode=LINE_99; LCDCSTAT&=0xf8; if (CURLINE==CMP_LINE) LCDCSTAT|=0x04; if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); } switch(gblcdc->mode) { case HBLANK_PER: // HBLANK if (LCDCSTAT&0x08) set_interrupt(LCDC_INT); if (!skip_next_frame) draw_screen(); ret=lcd_cycle_tab[gblcdc->timing][0]; gblcdc->mode=OAM_PER; if (dma_info.type==HDMA) do_hdma(); gblcdc->inc_line=1; LCDCSTAT&=0xfc; break; case LINE_90_BEGIN: gblcdc->inc_line=0; LCDCSTAT|=0x01; //if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); ret=DELAY_CYCLE; gblcdc->mode=LINE_90_END; break; case LINE_90_END: gblcdc->inc_line=1; if (LCDCSTAT&0x10) set_interrupt(LCDC_INT); ret=lcd_cycle_tab[gblcdc->timing][1]-DELAY_CYCLE-8; LCDCSTAT|=0x01; gblcdc->mode=VBLANK_PER; set_interrupt(VBLANK_INT); break; case LINE_99: LCDCSTAT|=0x01; /* FIXME: Line 99 Timing */ ret=lcd_cycle_tab[gblcdc->timing][4]; gblcdc->inc_line=0; break; case END_VBLANK_PER: LCDCSTAT|=0x01; //if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); ret=lcd_cycle_tab[gblcdc->timing][1]-lcd_cycle_tab[gblcdc->timing][4]; gblcdc->inc_line=0; break; case VBLANK_PER: // VBLANK /* FIXME => water.gbc */ //if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); LCDCSTAT|=0x01; ret=lcd_cycle_tab[gblcdc->timing][1]; gblcdc->inc_line=1; break; case BEGIN_OAM_PER: LCDCSTAT|=0x02; gblcdc->inc_line=0; gblcdc->mode=OAM_PER; ret=DELAY_CYCLE; ret=24; //if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); break; case OAM_PER: // OAM LCDCSTAT|=0x02; gblcdc->inc_line=0; /* FIXME: Pinball Deluxe */ if (LCDCSTAT&0x20) set_interrupt(LCDC_INT); //if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); ret=lcd_cycle_tab[gblcdc->timing][2]; /*if (conf.delay_int) ret-=DELAY_CYCLE;*/ gblcdc->mode=VRAM_PER; gblcdc->nb_spr=get_nb_spr(); break; case VRAM_PER: // VRAM LCDCSTAT|=0x03; ret=lcd_cycle_tab[gblcdc->timing][3]; gblcdc->mode=HBLANK_PER; /* FIXME */ gblcdc->mode3cycle=ret; gblcdc->vram_factor=160.0/(double)(gblcdc->mode3cycle); if (vram_init_pal) { for(x=0;x<160;x++) gblcdc->vram_pal_line[x]=pal_bck; pal_bck[0]=BGPAL&3; pal_bck[1]=(BGPAL>>2)&3; pal_bck[2]=(BGPAL>>4)&3; pal_bck[3]=(BGPAL>>6)&3; vram_init_pal=0; } break; } return ret; } /* gblcdc_update2: Try new implementation don't Work for the moment */ void gblcdc_set_on3(void) { gblcdc->win_curline=0; LCDCCONT|=0x80; vram_init_pal=1; clear_screen(); reset_frame_skip(); LCDCSTAT=(LCDCSTAT&0xf8)|0x02; CURLINE=0x00; gblcdc->nb_spr=get_nb_spr(); gblcdc->cycle=lcd_cycle_tab[gblcdc->timing][2]; } Uint16 gblcdc_update3(void) { int x; static Uint8 delay_vblank_int; if (!(LCDCCONT&0x80)) return 0; switch(LCDCSTAT&0x03) { case 0x00: if (CURLINE==0x8F) { /* Go to VBlank Mode */ CURLINE++; LCDCSTAT=(LCDCSTAT&0xf8)|0x01; /* FIXME: Check LYC irq */ /* if (CURLINE==CMP_LINE) LCDCSTAT|=0x04; if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT);*/ if (LCDCSTAT&0x10) set_interrupt(LCDC_INT); if (gbcpu->state&HALT_STATE) { set_interrupt(VBLANK_INT); return lcd_cycle_tab[gblcdc->timing][1]; } delay_vblank_int=1; return DELAY_CYCLE; } else { /* Go to Oam Mode */ LCDCSTAT=(LCDCSTAT&0xf8)|0x02; CURLINE++; gblcdc->nb_spr=get_nb_spr(); if (CURLINE==CMP_LINE) LCDCSTAT|=0x04; if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); if (LCDCSTAT&0x20) set_interrupt(LCDC_INT); return lcd_cycle_tab[gblcdc->timing][2]; } break; case 0x01: if (delay_vblank_int) { delay_vblank_int=0; set_interrupt(VBLANK_INT); return lcd_cycle_tab[gblcdc->timing][1]-DELAY_CYCLE; } if (CURLINE==0x00) { /* Go to Oam Mode */ blit_screen(); LCDCSTAT=(LCDCSTAT&0xf8)|0x02; gblcdc->nb_spr=get_nb_spr(); /* if (CURLINE==CMP_LINE) LCDCSTAT|=0x04; if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT);*/ if (LCDCSTAT&0x20) set_interrupt(LCDC_INT); return lcd_cycle_tab[gblcdc->timing][2]; } if (CURLINE<0x98) { /* Go to VBlank Mode */ CURLINE++; LCDCSTAT=(LCDCSTAT&0xf8)|0x01; /* FIXME: Check LYC irq */ return lcd_cycle_tab[gblcdc->timing][1]; } if (CURLINE==0x98) { CURLINE++; LCDCSTAT=(LCDCSTAT&0xf8)|0x01; return lcd_cycle_tab[gblcdc->timing][4]; } if (CURLINE==0x99) { CURLINE=0x00; LCDCSTAT=(LCDCSTAT&0xf8)|0x01; /* FIXME: Check LYC irq */ if (CURLINE==CMP_LINE) LCDCSTAT|=0x04; if (LCDCSTAT&0x40 && LCDCSTAT&0x04) set_interrupt(LCDC_INT); return (lcd_cycle_tab[gblcdc->timing][1]-lcd_cycle_tab[gblcdc->timing][4]); } break; case 0x02: LCDCSTAT=(LCDCSTAT&0xfc)|0x03; gblcdc->mode3cycle=lcd_cycle_tab[gblcdc->timing][3]; gblcdc->vram_factor=160.0/(double)(gblcdc->mode3cycle); if (vram_init_pal) { for(x=0;x<160;x++) gblcdc->vram_pal_line[x]=pal_bck; pal_bck[0]=BGPAL&3; pal_bck[1]=(BGPAL>>2)&3; pal_bck[2]=(BGPAL>>4)&3; pal_bck[3]=(BGPAL>>6)&3; vram_init_pal=0; } return lcd_cycle_tab[gblcdc->timing][3]; break; case 0x03: draw_screen(); /* Go to HBlank Mode */ LCDCSTAT=(LCDCSTAT&0xfc); if (dma_info.type==HDMA) do_hdma(); if (LCDCSTAT&0x08) set_interrupt(LCDC_INT); return lcd_cycle_tab[gblcdc->timing][0]; break; } } /* FIXME */ void gblcdc_addcycle(Sint32 c) { Uint8 v=0; if (!(LCDCCONT&0x80)) return; while(c>gblcdc->cycle) { if (INT_FLAG&VBLANK_INT) v=make_interrupt(VBLANK_INT); if (INT_FLAG&LCDC_INT && !v) v=make_interrupt(LCDC_INT); if (INT_FLAG&TIMEOWFL_INT && !v) v=make_interrupt(TIMEOWFL_INT); c-=gblcdc->cycle; gblcdc->cycle=gblcdc_update(); } gblcdc->cycle-=c; dma_info.type=NO_DMA; HDMA_CTRL5=0xff; } /* GB TIMER */ void gbtimer_init(void) { gbtimer=(GBTIMER *)malloc(sizeof(GBTIMER)); gbtimer_reset(); } void gbtimer_reset(void) { gbtimer->clk_inc=0; gbtimer->cycle=0; } void gbtimer_update(void) { TIME_COUNTER++; if (TIME_COUNTER==0x00) { TIME_COUNTER=TIME_MOD; set_interrupt(TIMEOWFL_INT); } } __inline__ void halt_update(void) // gbcpu->state=HALT_STATE { if (INT_FLAG&INT_ENABLE) { gbcpu->state=0; gbcpu->pc.w++; } } gngb-20060309/src/interrupt.h0000644000175000017500000000620107656635707014376 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _INTERUPT_H #define _INTERUPT_H #include "global.h" #define HBLANK_PER 0 #define VBLANK_PER 1 #define OAM_PER 2 #define VRAM_PER 3 #define END_VBLANK_PER 4 #define LINE_90_BEGIN 5 #define LINE_90_END 6 #define BEGIN_OAM_PER 7 #define LINE_99 8 #define NO_INT 0 #define VBLANK_INT 0x01 #define LCDC_INT 0x02 #define TIMEOWFL_INT 0x04 #define SERIAL_INT 0x08 extern Uint32 nb_cycle; extern Uint32 key_cycle; #define GBLCDC_ADD_CYCLE(n) { \ gblcdc->cycle-=(n); \ if (gblcdc->cycle<=0) gblcdc->cycle+=(gblcdc_update()); } /*if ((LCDCSTAT&0x03)==0x02) { \ gblcdc->oam_last_p=gblcdc->oam_pixel; \ gblcdc->oam_pixel+=((n)*gblcdc->oam_factor); \ } else if ((LCDCSTAT&0x03)==0x03) gblcdc->vram_pixel+=((n)*gblcdc->vram_factor); \ }*/ typedef struct { Uint8 mode; Uint8 nb_spr; Uint8 inc_line; Sint16 cycle; Uint16 mode1cycle; Uint16 mode2cycle; Uint16 mode3cycle; Uint32 vblank_cycle; Uint8 timing; Uint8 win_curline; /* Gameboy Window Current Line */ double vram_factor; Uint8 *vram_pal_line[160]; }GBLCDC; GBLCDC *gblcdc; Uint8 vram_pal_line_temp[160][4]; extern Uint8 vram_init_pal; #define gb_set_pal_bck(v) { \ int i; \ BGPAL=v;\ if ((LCDCSTAT&0x03)==0x03) { \ Uint8 x=(double)((gblcdc->mode3cycle-gblcdc->cycle))*gblcdc->vram_factor;\ vram_pal_line_temp[x][0]=BGPAL&3; \ vram_pal_line_temp[x][1]=(BGPAL>>2)&3; \ vram_pal_line_temp[x][2]=(BGPAL>>4)&3; \ vram_pal_line_temp[x][3]=(BGPAL>>6)&3; \ for(i=x;i<160;i++) \ gblcdc->vram_pal_line[i]=vram_pal_line_temp[x]; \ vram_init_pal=1; \ } else { \ pal_bck[0]=BGPAL&3;\ pal_bck[1]=(BGPAL>>2)&3;\ pal_bck[2]=(BGPAL>>4)&3;\ pal_bck[3]=(BGPAL>>6)&3;\ } \ } typedef struct { Uint16 clk_inc; Sint32 cycle; }GBTIMER; GBTIMER *gbtimer; void gblcdc_init(void); void gblcdc_reset(void); void gbtimer_init(void); void gbtimer_reset(void); void go2double_speed(void); void go2simple_speed(void); Uint32 get_nb_cycle(void); #define set_interrupt(n) ((INT_FLAG|=(n))) #define unset_interrupt(n) ((INT_FLAG&=(~(n)))) Uint8 make_interrupt(Uint8 n); void gblcdc_set_on(void); void gblcdc_addcycle(Sint32 c); Uint16 gblcdc_update(void); void gbtimer_update(void); void halt_update(void); #endif gngb-20060309/src/fileio.c0000644000175000017500000001603607703530567013602 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include #include #ifdef HAVE_DIRENT_H #include #endif #include #include #include "fileio.h" #ifdef HAVE_LIBZ #include "unzip.h" #include #endif #ifdef HAVE_LIBBZ2 #include #endif char get_type_file(char *filename) { FILE *file_tmp; char str[10]; int i; struct { char *sign; int len; char type; } tab_sign[]={ {"PK\003\004",4,ZIP_ARCH_FILE_TYPE}, {"\037\213",2,GZIP_FILE_TYPE}, {"BZh",3,BZIP_FILE_TYPE}, {NULL,0,UNKNOW_FILE_TYPE}}; if (!(file_tmp=fopen(filename,"rb"))) return UNKNOW_FILE_TYPE; fread(str,1,10,file_tmp); fclose(file_tmp); for(i=0;tab_sign[i].sign;i++) { if (!memcmp(str,tab_sign[i].sign,tab_sign[i].len)) return tab_sign[i].type; } return NORMAL_FILE_TYPE; } GNGB_FILE *gngb_file_open(char *filename,char *mode,char type) { GNGB_FILE *f=(GNGB_FILE *)malloc(sizeof(GNGB_FILE)); if (!f) return NULL; if (type!=UNKNOW_FILE_TYPE) f->type=type; else f->type=get_type_file(filename); switch(f->type) { case GZIP_FILE_TYPE: #ifdef HAVE_LIBZ f->stream=(char *)gzopen(filename,mode); #else fprintf(stderr,"Gzip file unsupported\n"); return NULL; #endif break; case ZIP_ARCH_FILE_TYPE: #ifdef HAVE_LIBZ f->stream=(char *)unzOpen(filename); #else fprintf(stderr,"Zip file unsupported\n"); return NULL; #endif break; case BZIP_FILE_TYPE: #ifdef HAVE_LIBBZ2 f->stream=(char *)BZ2_bzopen(filename,mode); break; #else fprintf(stderr,"Bzip2 file unsupported\n"); return NULL; #endif break; case NORMAL_FILE_TYPE: case GB_ROM_FILE_TYPE: f->stream=(char *)fopen(filename,mode); break; default: return NULL; } if (!f->stream) { free(f); return NULL; } return f; } int gngb_file_close(GNGB_FILE *f) { switch(f->type) { case NORMAL_FILE_TYPE: case GB_ROM_FILE_TYPE:return fclose((FILE *)f->stream); case GZIP_FILE_TYPE: #ifdef HAVE_LIBZ return gzclose((gzFile)f->stream); #else fprintf(stderr,"Gzip file unsupported\n"); return -1; #endif case ZIP_ARCH_FILE_TYPE: #ifdef HAVE_LIBZ unzCloseCurrentFile((unzFile)f->stream); return unzClose((unzFile)f->stream); #else fprintf(stderr,"Zip file unsupported\n"); return -1; #endif case BZIP_FILE_TYPE: #ifdef HAVE_LIBBZ2 BZ2_bzclose((BZFILE *)f->stream); return 0; #else fprintf(stderr,"Bzip2 file unsupported\n"); return -1; #endif break; default:return -1; } } int gngb_file_read(void *ptr, size_t size, size_t nmemb,GNGB_FILE *f) { switch(f->type) { case NORMAL_FILE_TYPE: case GB_ROM_FILE_TYPE:return fread(ptr,size,nmemb,(FILE *)f->stream); case GZIP_FILE_TYPE: #ifdef HAVE_LIBZ return gzread((gzFile)f->stream,ptr,size*nmemb); #else fprintf(stderr,"Gzip file unsupported\n"); return -1; #endif case ZIP_ARCH_FILE_TYPE: #ifdef HAVE_LIBZ return unzReadCurrentFile((unzFile)f->stream,ptr,size*nmemb); #else fprintf(stderr,"Zip file unsupported\n"); return -1; #endif case BZIP_FILE_TYPE: #ifdef HAVE_LIBBZ2 return BZ2_bzread((BZFILE *)f->stream,ptr,size*nmemb); #else fprintf(stderr,"Bzip2 file unsupported\n"); return -1; #endif break; default:return -1; } } int gngb_file_write(const void *ptr, size_t size, size_t nmemb,GNGB_FILE *f) { switch(f->type) { case NORMAL_FILE_TYPE: case GB_ROM_FILE_TYPE: return fwrite(ptr,size,nmemb,(FILE *)(f->stream)); case GZIP_FILE_TYPE: #ifdef HAVE_LIBZ return gzwrite((gzFile)f->stream,ptr,size*nmemb); #else fprintf(stderr,"Gzip file unsupported\n"); return -1; #endif case ZIP_ARCH_FILE_TYPE: #ifdef HAVE_LIBZ fprintf(stderr,"Write for Unzip file unsupported\n"); return -1; #else fprintf(stderr,"Zip file unsupported\n"); return -1; #endif case BZIP_FILE_TYPE: #ifdef HAVE_LIBBZ2 return BZ2_bzwrite((BZFILE *)f->stream,ptr,size*nmemb); #else fprintf(stderr,"Bzip2 file unsupported\n"); return -1; #endif default:return -1; } } int gngb_file_seek(GNGB_FILE *f, long offset, int whence) { switch(f->type) { case NORMAL_FILE_TYPE: case GB_ROM_FILE_TYPE:return fseek((FILE *)f->stream,offset,whence); case BZIP_FILE_TYPE: #ifdef HAVE_LIBBZ2 fprintf(stderr,"fseek for Bzip file: unsuported\n"); return -1; #else fprintf(stderr,"Bzip2 file unsupported\n"); return -1; #endif case GZIP_FILE_TYPE: #ifdef HAVE_LIBZ fprintf(stderr,"fseek for Gzip file: unsuported\n"); return -1; #else fprintf(stderr,"Gzip file unsupported\n"); return -1; #endif case ZIP_ARCH_FILE_TYPE: #ifdef HAVE_LIBZ fprintf(stderr,"fseek for Zip file unsupported\n"); return -1; #else fprintf(stderr,"Zip file unsupported\n"); return -1; #endif default:return -1; } } int gngb_file_eof(GNGB_FILE *f) { switch(f->type) { case NORMAL_FILE_TYPE: case GB_ROM_FILE_TYPE:return feof((FILE *)f->stream); case GZIP_FILE_TYPE: #ifdef HAVE_LIBZ fprintf(stderr,"feof for Gzip file: unsuported\n"); return -1; #else fprintf(stderr,"Gzip file unsupported\n"); return -1; #endif case ZIP_ARCH_FILE_TYPE: #ifdef HAVE_LIBZ fprintf(stderr,"feof for Unzip file unsupported\n"); return -1; #else fprintf(stderr,"Zip file unsupported\n"); return -1; #endif case BZIP_FILE_TYPE: #ifdef HAVE_LIBBZ2 fprintf(stderr,"feof for Bzip file: unsuported\n"); return -1; #else fprintf(stderr,"Bzip2 file unsupported\n"); return -1; #endif default:return -1; } } #ifdef HAVE_LIBZ int zip_file_open_next_rom(unzFile file) { char header[0x200]; unzGoToFirstFile(file); do { unzOpenCurrentFile(file); unzReadCurrentFile(file,header,0x200); unzCloseCurrentFile(file); #ifdef WORD_BIGENDIAN if ((*((unsigned long *)(header+0x104)))==0xCEED6666) { #else if ((*((unsigned long *)(header+0x104)))==0x6666EDCE) { #endif /* Gameboy Roms */ unzOpenCurrentFile(file); return 0; } }while(unzGoToNextFile(file)!=UNZ_END_OF_LIST_OF_FILE); printf("titi\n"); return -1; } #endif gngb-20060309/src/fileio.h0000644000175000017500000000302210347010355013560 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef FILEIO_H #define FILEIO_H #include #include #define UNKNOW_FILE_TYPE (char)(-1) #define ZIP_ARCH_FILE_TYPE (char)(1) #define GZIP_FILE_TYPE (char)(2) #define BZIP_FILE_TYPE (char)(3) #define GB_ROM_FILE_TYPE (char)(4) #define NORMAL_FILE_TYPE (char)(5) typedef struct _gngb_file { char type; char *stream; }GNGB_FILE; GNGB_FILE *gngb_file_open(char *filename,char *mode,char type); int gngb_file_close(GNGB_FILE *f); int gngb_file_read(void *ptr, size_t size, size_t nmemb,GNGB_FILE *f); int gngb_file_write(const void *ptr, size_t size, size_t nmemb,GNGB_FILE *f); int gngb_file_seek(GNGB_FILE *f, long offset, int whence); int gngb_file_eof(GNGB_FILE *f); #endif gngb-20060309/src/sound.c0000644000175000017500000005355307643033301013453 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* TODO : Rewrite the length code for evry channel */ #include #include #include #include "emu.h" #include "sound.h" #include "memory.h" #include "interrupt.h" #include "cpu.h" #define HZ(x) ((double)(131072.0)/(double)(2048-x)) #define HZ_M3(x) ((double)(4194304.0)/(64.0*(double)(2048-x))) // #define LOG_SOUND Sint8 *playbuf; FILE *fsound; /* Sint8 vol_table[]={0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60}; Sint8 snd3_tbl_100[]={-60,-52,-45,-37,-30,-22,-15,-7,7,15,22,30,37,45,52,60}; Sint8 snd3_tbl_50[]={-30,-22,-15,-7,7,15,22,30}; Sint8 snd3_tbl_25[]={-15,-7,7,15}; */ Sint8 vol_table[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; Sint8 snd3_tbl_100[]={-16,-15,-12,-10,-8,-6,-4,-2,2,4,6,8,10,12,14,16}; Sint8 snd3_tbl_50[]={-10,-8,-4,-2,2,4,8,10}; Sint8 snd3_tbl_25[]={-4,-2,2,4}; Uint16 wduty[4][8] = { {0,0,-1,0,0,0,0,0 }, {0,-1,-1,0,0,0,0,0 }, {0,-1,-1,-1,-1,0,0,0 }, {0,0,0,-1,-1,-1,-1,-1 } }; double freq_table[2048]; double freq_table_m3[2048]; long double freq_table_m4[256]; float lastpos=0,curpos=0; Uint32 buf_size; Uint8 m1_len,m1_slen; float wave_duty[]={8,4,2,1.3333}; /* retourne l'entier de l bit, debutant au bit d de v */ // #define BITS(v,d,l) ((v>>(d-l+1))&(l*l-1)) void update_sound_reg(void) { int i; for(i=0xff10;i<=0xFF3F;i++) write_sound_reg(i,himem[i-0xFEA0]); } Uint32 clk; void write_sound_reg(Uint16 add,Uint8 val) { // Uint32 snd_len =(Uint32)((float)get_nb_cycle()*(sample_rate/59.73) // /((gbcpu->mode== DOUBLE_SPEED)?140448.0:70224.0)); // static Uint32 clk; float snd_len; static float samp; clk=get_nb_cycle(); snd_len = ((float)clk*sample_rate/(float)((gbcpu->mode== DOUBLE_SPEED)?8388608.0:4194304.0)); if (snd_len) update_gb_sound(snd_len*2); himem[add-0xfea0]=val; if (add>=0xFF30 && add<=0xFF3F) { // Wave Pattern RAM if (!snd_m3.is_on) snd_m3.wave[add-0xFF30]=val; return; } switch(add) { /*--- GENERAL CONTROL ---*/ case 0xFF24 : // NR50 snd_g.SO1_OutputLevel=val&0x7; snd_g.SO2_OutputLevel=(val&0x70)>>4; snd_g.Vin_SO1=(val&0x8)>>3; snd_g.Vin_SO2=(val&0x80)>>7; return; break; case 0xFF25 : // NR51 snd_g.Sound4_To_SO2=(val&0x80)>>7; snd_g.Sound3_To_SO2=(val&0x40)>>6; snd_g.Sound2_To_SO2=(val&0x20)>>5; snd_g.Sound1_To_SO2=(val&0x10)>>4; snd_g.Sound4_To_SO1=(val&0x8)>>3; snd_g.Sound3_To_SO1=(val&0x4)>>2; snd_g.Sound2_To_SO1=(val&0x2)>>1; snd_g.Sound1_To_SO1=(val&0x1); break; case 0xFF26 : // NR52 snd_g.Sound_On_Off=(val&0x80)>>7; /* le reste est read only (Sound Status bit) */ break; /*--- SOUND MODE 1 ---*/ case 0xFF10 : // NR10 snd_m1.swp_time=(val&0x70)>>4; snd_m1.swp_dir=(val&0x8)>>3; snd_m1.swp_shift=val&0x7; snd_m1.sample_sweep_time=(float)sample_rate*snd_m1.swp_time/128.0; break; case 0xFF11 : // NR11 snd_m1.duty=(val&0xC0)>>6; snd_m1.len=val&0x3F; snd_m1.sample_dut=(float)snd_m1.sample/wave_duty[snd_m1.duty]; snd_m1.sample_len=(64.0-(float)snd_m1.len)*((float)sample_rate/256.0); break; case 0xFF12 : // NR12 snd_m1.env_start=(val&0xF0)>>4; snd_m1.env_dir=(val&0x8)>>3; snd_m1.env_swp=(val&0x7); snd_m1.env_changed=1; snd_m1.sample_env_per_step=(float)snd_m1.env_swp*sample_rate/64.0; break; case 0xFF13 : // NR13 snd_m1.freq_lo=val; snd_m1.freq=((Uint16)(snd_m1.freq_lo))|(((Uint16)(snd_m1.freq_hi))<<8); // update freq //samp=snd_m1.sample; snd_m1.sample=freq_table[snd_m1.freq]; snd_m1.sample_dut=snd_m1.sample/wave_duty[snd_m1.duty]; //snd_m1.cp=snd_m1.cp*snd_m1.sample/samp; break; case 0xFF14 : // NR14 snd_m1.initial=(val&0x80)>>7; snd_m1.mode=(val&0x40)>>6; snd_m1.freq_hi=val&0x7; snd_m1.freq=((Uint16)(snd_m1.freq_lo))|(((Uint16)(snd_m1.freq_hi))<<8); // update freq //samp=snd_m1.sample; snd_m1.sample=freq_table[snd_m1.freq]; snd_m1.sample_dut=(float)snd_m1.sample/wave_duty[snd_m1.duty]; //snd_m1.cp=snd_m1.cp*snd_m1.sample/samp; break; /*--- SOUND MODE 2 ---*/ case 0xFF16 : // NR21 snd_m2.duty=(val&0xC0)>>6; snd_m2.len=val&0x3F; snd_m2.sample_dut=(float)snd_m2.sample/wave_duty[snd_m2.duty]; snd_m2.sample_len=(64.0-(float)snd_m2.len)*((float)sample_rate/256.0); break; case 0xFF17 : // NR22 snd_m2.env_start=(val&0xF0)>>4; snd_m2.env_dir=(val&0x8)>>3; snd_m2.env_swp=(val&0x7); snd_m2.env_changed=1; snd_m2.sample_env_per_step=(float)snd_m2.env_swp*sample_rate/64.0; break; case 0xFF18 : // NR23 snd_m2.freq_lo=val; snd_m2.freq=((Uint16)(snd_m2.freq_lo))|(((Uint16)(snd_m2.freq_hi))<<8); // update freq //samp=snd_m2.sample; snd_m2.sample=freq_table[snd_m2.freq]; //snd_m2.cp=snd_m2.cp*snd_m2.sample/samp; snd_m2.sample_dut=(float)snd_m2.sample/wave_duty[snd_m2.duty]; break; case 0xFF19 : // NR24 snd_m2.initial=(val&0x80)>>7; snd_m2.mode=(val&0x40)>>6; snd_m2.freq_hi=val&0x7; snd_m2.freq=((Uint16)(snd_m2.freq_lo))|(((Uint16)(snd_m2.freq_hi))<<8); // update freq //samp=snd_m2.sample; snd_m2.sample=freq_table[snd_m2.freq]; snd_m2.sample_dut=(float)snd_m2.sample/wave_duty[snd_m2.duty]; //snd_m2.cp=snd_m2.cp*snd_m2.sample/samp; break; /*--- Sound Mode 3 ---*/ case 0xFF1A : // NR30 snd_m3.is_on=(val&0x80)>>7; // printf("[%x]",snd_m3.is_on); // printf("snd3 on:%d\n",snd_m3.is_on); break; case 0xFF1B : // NR31 snd_m3.len=val; // snd_m3.sample_len=(float)sample_rate*(256.0-snd_m3.len)/2.0; snd_m3.sample_len=(float)sample_rate*(256.0-snd_m3.len)*(1.0/256.0); // printf("SNDM3 LEN WRITE %d \n",snd_m3.len); break; case 0xFF1C : // NR32 snd_m3.level=(val&0x60)>>5; // printf("--level%d %x\n", snd_m3.level,val); break; case 0xFF1D : // NR33 snd_m3.freq_lo=val; snd_m3.freq=((Uint16)(snd_m3.freq_lo))|(((Uint16)(snd_m3.freq_hi))<<8); samp=snd_m3.sample; snd_m3.sample=freq_table_m3[snd_m3.freq]/32.0;// *64.0; // printf("sample %f\n",snd_m3.sample); snd_m3.cp=snd_m3.cp* snd_m3.sample/samp; break; case 0xFF1E : // NR34 snd_m3.initial=(val&0x80)>>7; snd_m3.mode=(val&0x40)>>6; snd_m3.freq_hi=val&0x7; snd_m3.freq=((Uint16)(snd_m3.freq_lo))|(((Uint16)(snd_m3.freq_hi))<<8); samp=snd_m3.sample; snd_m3.sample=freq_table_m3[snd_m3.freq]/32.0;// *64.0; // printf("sample %f\n",snd_m3.sample); snd_m3.cp=snd_m3.cp* snd_m3.sample/samp; break; /*--- SOUND MODE 4 ---*/ case 0xFF20 : // NR41 snd_m4.len=val&0x3F; snd_m4.sample_len=(64.0-(float)snd_m4.len)*((float)sample_rate/256.0); break; case 0xFF21 : // NR42 snd_m4.env_start=(val&0xF0)>>4; snd_m4.env_dir=(val&0x8)>>3; snd_m4.env_swp=(val&0x7); snd_m4.env_changed=1; snd_m4.sample_env_per_step=(float)snd_m4.env_swp*sample_rate/64.0; break; case 0xFF22 : // NR43 snd_m4.poly=val; snd_m4.sample=(double)sample_rate*freq_table_m4[val]; // printf("poly %x:%x %x %x %g\n",val,(val&0xF0)>>4,(val&0x8)>>3,val&0x7,snd_m4.sample); snd_m4.poly_changed=1; break; case 0xFF23 : // NR44 snd_m4.initial=(val&0x80)>>7; snd_m4.mode=(val&0x40)>>6; // printf("env mode %x:%d %d\n",val,snd_m4.initial,snd_m4.mode); break; } } Uint8 read_sound_reg(Uint16 add) { if (add>=0xFF30 && add<=0xFF3F) // Wave Pattern RAM return snd_m3.wave[add-0xFF30]; switch(add) { /*--- SOUND MODE 1 ---*/ case 0xFF10 : // NR10 return (snd_m1.swp_time<<4)|(snd_m1.swp_dir<<3)|snd_m1.swp_shift; case 0xFF11 : // NR11 return (snd_m1.duty<<6); case 0xFF12 : // NR12 return (snd_m1.env_start<<4)|(snd_m1.env_dir<<3)|snd_m1.env_swp; case 0xFF13 : // NR13 return snd_m1.freq_lo; case 0xFF14 : // NR14 return snd_m1.mode<<6; /*--- SOUND MODE 2 ---*/ case 0xFF16 : // NR21 return (snd_m2.duty<<6); case 0xFF17 : // NR22 return (snd_m2.env_start<<4)|(snd_m2.env_dir<<3)|snd_m2.env_swp; case 0xFF18 : // NR23 return snd_m2.freq_lo; case 0xFF19 : // NR24 return snd_m2.mode<<6; /*--- SOUND MODE 3 ---*/ case 0xFF1A : // NR30 return snd_m3.is_on<<7; case 0xFF1B : // NR31 return snd_m3.len; case 0xFF1C : // NR32 return snd_m3.level<<5; case 0xFF1D : // NR33 return snd_m3.freq_lo; case 0xFF1E : // NR34 return snd_m3.mode<<6; /*--- SOUND MODE 4 ---*/ case 0xFF20 : // NR41 return snd_m4.len; case 0xFF21 : // NR42 return (snd_m4.env_start<<4)|(snd_m4.env_dir<<3)|snd_m4.env_swp; case 0xFF22 : // NR43 return snd_m4.poly; case 0xFF23 : // NR44 return snd_m4.mode<<6; /*--- GENERAL CONTROL ---*/ case 0xFF24 : // NR50 return (snd_g.Vin_SO2<<7)|(snd_g.SO2_OutputLevel<<4)|(snd_g.Vin_SO1<<3)|snd_g.SO1_OutputLevel; case 0xFF25 : // NR51 return (snd_g.Sound4_To_SO2<<7)| (snd_g.Sound3_To_SO2<<6)| (snd_g.Sound2_To_SO2<<5)| (snd_g.Sound1_To_SO2<<4)| (snd_g.Sound4_To_SO1<<3)| (snd_g.Sound3_To_SO1<<2)| (snd_g.Sound2_To_SO1<<1)| snd_g.Sound1_To_SO1; case 0xFF26 : // NR52 return (snd_g.Sound_On_Off<<7)| (snd_g.Sound4_On_Off<<3)| (snd_g.Sound3_On_Off<<2)| (snd_g.Sound2_On_Off<<1)| snd_g.Sound1_On_Off; } return himem[add-0xfea0]; } void init_freq_table(void) { int i; long double y; for(i=0;i<2048;i++) { freq_table[i]=sample_rate/HZ(i); freq_table_m3[i]=sample_rate/HZ_M3(i); } for(i=0;i<256;i++) { if ((i&0x7)==0) y=(long double)2.0; else y=(long double)1.0/(float)(i&0x7); freq_table_m4[i]=1.0/(4194304.0*(1.0/8.0)*y*(1.0/(long double)(2<<(i>>4)))); } } __inline__ Sint8 update_snd_m1(void) { static int env=0; static char sp=0; static int lp=0; static int ep=0; static int fp=0; static int cur_swp_shift; static int cur_env_step; if (snd_m1.initial) { snd_m1.initial=0; env=snd_m1.env_start; cur_env_step=snd_m1.env_swp; cur_swp_shift=snd_m1.swp_shift; snd_m1.cp=0; // sp=0; lp=0; ep=0; fp=0; } if (snd_m1.env_changed && snd_m1.mode==0) { snd_m1.env_changed=0; env=snd_m1.env_start; cur_env_step=snd_m1.env_swp; cur_swp_shift=snd_m1.swp_shift; snd_m1.cp=0; // sp=0; ep=0; fp=0; } if (snd_m1.mode==1) { // on doit gerer la durée // printf("Mode 1\n"); lp++; if (lp>snd_m1.sample_len) { snd_g.Sound1_On_Off=0;return 0; } } if (snd_m1.swp_time!=0) { // FreqSweep operation fp++; if (fp>snd_m1.sample_sweep_time) { fp=0; //samp=snd_m1.sample; if (snd_m1.swp_dir==1) { snd_m1.freq -= snd_m1.freq>>snd_m1.swp_shift; snd_m1.sample=freq_table[snd_m1.freq]; snd_m1.sample_dut=snd_m1.sample/wave_duty[snd_m1.duty]; } else { snd_m1.freq += snd_m1.freq>>snd_m1.swp_shift; snd_m1.sample=freq_table[snd_m1.freq]; snd_m1.sample_dut=snd_m1.sample/wave_duty[snd_m1.duty]; } //snd_m1.cp=snd_m1.cp*snd_m1.sample/samp; if (snd_m1.freq==0) snd_m1.freq=0; if (snd_m1.freq>=2020) { snd_g.Sound1_On_Off=0;env=0;return 0; } } } if (cur_env_step!=0 ) { if ((env>0 && snd_m1.env_dir==0) || (env<15 && snd_m1.env_dir==1)) { ep++; if ((float)ep>snd_m1.sample_env_per_step) { ep=0; // cur_env_step--; if (snd_m1.env_dir==0) env-=1;//snd_m1.env_per_step; else env+=1;//snd_m1.env_per_step; if (env==0 && snd_m1.env_dir==0) { snd_g.Sound1_On_Off=0;env=0;return 0; } } } } if (env==0) {snd_g.Sound1_On_Off=0;return 0;} // Volume ŕ zero snd_g.Sound1_On_Off=1; /* clipping */ if (env>15) env=15; if (env<0) env=0; /* sp=wduty[snd_m1.duty][((int)(snd_m1.cp/(snd_m1.sample/8.0)))&0x7]; snd_m1.cp+=1; return vol_table[env]&sp; */ /* snd_m1.cp+=1.0; return sin(snd_m1.cp*3.1416*2/(snd_m1.sample))*vol_table[env]*4; */ if (snd_m1.cp+1.0>snd_m1.sample) { sp=1;//1-sp; // printf("- %f\n",snd_m1.cp); snd_m1.cp=(snd_m1.cp+1.0)-snd_m1.sample; } else if (snd_m1.cp+1.0>snd_m1.sample_dut && sp==1) { sp=0;//1-sp; // printf("%f\n",snd_m1.cp); snd_m1.cp+=1.0;// snd_m1.cp-snd_m1.sample_dut; } else snd_m1.cp+=1.0; if (sp) return -vol_table[env]; else return vol_table[env]; } __inline__ Sint8 update_snd_m2(void) { // static float cp=0; static int env=0; static int sp=0; static int lp=0; static int ep=0; static int cur_env_step; if (snd_m2.initial) { snd_m2.initial=0; env=snd_m2.env_start; cur_env_step=snd_m2.env_swp; snd_m2.cp=0; // sp=0; lp=0; ep=0; } if (snd_m2.env_changed && snd_m2.mode==0) { snd_m2.env_changed=0; env=snd_m2.env_start; cur_env_step=snd_m2.env_swp; snd_m2.cp=0; // sp=0; ep=0; } if (snd_m2.mode==1) { // on doit gerer la durée // printf("Mode 1\n"); lp++; if (lp>snd_m2.sample_len) { snd_g.Sound2_On_Off=0;return 0; } } if (cur_env_step!=0) { if ((env>0 && snd_m2.env_dir==0) || (env<15 && snd_m2.env_dir==1)) { ep++; if ((float)ep>snd_m2.sample_env_per_step) { ep=0; // cur_env_step--; if (snd_m2.env_dir==0) env-=1;//snd_m2.env_per_step; else env+=1;//snd_m2.env_per_step; if (env==0 && snd_m2.env_dir==0) { snd_g.Sound2_On_Off=0;env=0;return 0; } } } } if (env==0) {snd_g.Sound2_On_Off=0;return 0;} // Volume ŕ zero snd_g.Sound2_On_Off=1; /* clipping */ if (env>15) env=15; if (env<0) env=0; /* sp=wduty[snd_m2.duty][((int)(snd_m2.cp/(snd_m2.sample/8.0)))&0x7]; snd_m2.cp+=1; return vol_table[env]&sp; */ /* snd_m2.cp+=1.0; return sin(snd_m2.cp*3.1416*2/(snd_m2.sample))*vol_table[env]*4; */ if (snd_m2.cp+1.0>snd_m2.sample) { sp=1;//1-sp; snd_m2.cp=(snd_m2.cp+1.0)-snd_m2.sample; } else if (snd_m2.cp+1.0>snd_m2.sample_dut && sp==1) { sp=0;//1-sp; snd_m2.cp+=1.0; } else snd_m2.cp+=1.0; if (sp) return -vol_table[env]; else return vol_table[env]; } __inline__ Sint8 update_snd_m3(void) { static int lp=0; static int sp=0; static int val=0; if (snd_m3.sample==0) return 0; if (!snd_m3.is_on) { snd_g.Sound3_On_Off=0; sp=0; lp=0; snd_m3.cp=0; return 0; } if (snd_m3.initial) { snd_m3.initial=0; snd_m3.cp=0; sp=0; lp=0; // return 50; } if (snd_m3.mode==1) { // on doit gerer la durée // printf("Mode 1\n"); lp++; if (lp>snd_m3.sample_len) { // snd_m3.is_on=0; snd_g.Sound3_On_Off=0; sp=0; // lp=0; snd_m3.cp=0; return 0; } } snd_g.Sound3_On_Off=1; /* if (snd_m3.cp+1.0>(float)(snd_m3.sample)) { // printf("snd_m3.cp:%d\n",snd_m3.cp); snd_m3.cp=(snd_m3.cp+1.0)-(snd_m3.sample); for (j=0;j<1.0;j+=snd_m3.sample) { sp++; if (sp>=32) sp=0; if (sp&0x1) val=snd_m3.wave[sp>>1]&0xF; else val=(snd_m3.wave[sp>>1]&0xF0)>>4; } // printf("val %x:%x,",val,snd_m3.wave[sp>>1]); } else snd_m3.cp+=1.0; */ sp=(int)(snd_m3.cp/snd_m3.sample)&0x1F; snd_m3.cp+=1.0; if (sp&0x1) val=snd_m3.wave[sp>>1]&0xF; else val=(snd_m3.wave[sp>>1]&0xF0)>>4; // printf("|%02x|",sp>>1); /* val -=8; if (snd_m3.level) val <<= (3 - snd_m3.level); else val=0; return val; */ switch(snd_m3.level) { case 0: // mute return 0; break; case 1: return snd3_tbl_100[val]; case 2: return snd3_tbl_50[val>>1]; break; case 3: return snd3_tbl_25[val>>2]; break; } return 0; } __inline__ Sint8 update_snd_m4(void) { static float cp=0; static int env=0; static int sp=0; static int lp=0; static int ep=0; static int cur_env_step; static Uint32 poly_counter; int vol; float j; /* prohibited code */ if ((snd_m4.poly&0x80)>>4==0xE || (snd_m4.poly&0x80)>>4==0xF) return 0; if (snd_m4.sample==0) return 0; if (snd_m4.initial) { snd_m4.initial=0; env=snd_m4.env_start; cur_env_step=snd_m4.env_swp; cp=0; // sp=0; lp=0; ep=0; } if (snd_m4.env_changed && snd_m4.mode==0) { snd_m4.env_changed=0; env=snd_m4.env_start; cur_env_step=snd_m4.env_swp; cp=0; // sp=0; ep=0; } if (snd_m4.poly_changed) { if (snd_m4.poly&0x8) poly_counter=0x40; else poly_counter=0x4000; snd_m4.poly_changed=0; sp=0; } if (snd_m4.mode==1) { // on doit gerer la durée lp++; if (lp>snd_m4.sample_len) { // env=0; snd_g.Sound4_On_Off=0;return 0; } } if (cur_env_step!=0) { if ((env>0 && snd_m4.env_dir==0) || (env<15 && snd_m4.env_dir==1)) { // printf("%d,",env); ep++; if ((float)ep>snd_m4.sample_env_per_step) { ep=0; // cur_env_step--; if (snd_m4.env_dir==0) env-=1;//snd_m4.env_per_step; else env+=1;//snd_m4.env_per_step; if (env==0 && snd_m4.env_dir==0) { snd_g.Sound4_On_Off=0;env=0;return 0; } } } } if (env==0) {snd_g.Sound4_On_Off=0;return 0;} // Volume ŕ zero snd_g.Sound4_On_Off=1; /* clipping */ if (env>15) env=15; if (env<0) env=0; vol=vol_table[env]; if (snd_m4.sample<0.8) { vol=vol*(snd_m4.sample+0.2); } if (cp+1.0>snd_m4.sample) { if (snd_m4.sample<1.0) { //printf("%f %f %f\n",cp,floor(1.0/snd_m4.sample)*snd_m4.sample,snd_m4.sample); cp=(cp+1.0)-((int)(1.0/snd_m4.sample)*snd_m4.sample); } else cp=(cp+1.0)-snd_m4.sample; //for (j=0;j<1.0;j+=snd_m4.sample) { j=0; do{ sp =(poly_counter&1); if (snd_m4.poly&0x08) poly_counter ^= (((poly_counter&0x1)^((poly_counter&0x2)>>1))<<7); else poly_counter ^= (((poly_counter&0x1)^((poly_counter&0x2)>>1))<<15); poly_counter>>=1; }while(++j<1.0/snd_m4.sample); // printf("%f %f\n",j,1.0/snd_m4.sample); //cp=(cp)-snd_m4.sample; // printf("%f %f %f\n",cp,1.0/snd_m4.sample,snd_m4.sample); } else cp+=1.0; // return rol; if (!sp) return -vol; else return vol; } void update_gb_sound(float snd_len) { int i; Sint8 *pl=playbuf+(int)(lastpos*2); Sint16 p=0,l=0,r=0; SDL_LockAudio(); if ((snd_len+(lastpos*2))>=buf_size) { //printf("ho:%d %d\n",snd_len,(Sint16)(lastpos<<1)); snd_len=buf_size-(lastpos*2); // on borne. } //printf("update gb sound len:%d %d\n",lastpos<<1,snd_len>>1); // return; if (!(NR52&0x80)) { // ALL SOUND ON/OFF SDL_UnlockAudio(); return; } //if (!(NR50&0x80)) return; // SO2 ON/OFF //if (!(NR50&0x08)) return; // SO1 ON/OFF // printf("SO2:%d\n",(NR50&0x70)>>4); // printf("SO1:%d\n",(NR50&0x7)); //printf("Output %d:%d\n",NR51&0x10,NR51&0x01); //printf("yo\n"); //printf("curpos start:%d len:%d\n",curpos,len); for(i=0;i<(snd_len/2) && pl>3; r=r>>3; if (l<-127) l=-127; if (l>127) l=127; if (r<-127) r=-127; if (r>127) r=127; // printf("laspos %d\n",i); /* p+=update_sound_m2(); if (p>127) p=127; else if (p<-127) p=-127; */ *pl++=(Sint8)l; *pl++=(Sint8)r; } curpos+=snd_len/2; if (curpos>buf_size) curpos=0.0; lastpos=curpos; // printf("curpos end:%d\n",curpos); // *(pl-1)=100; SDL_UnlockAudio(); } /* fonction callback */ void update_stream(void *userdata,Uint8 *stream,int snd_len) { /* update tous les buffer dans playbuf*/ if (snd_len-(lastpos*2.0)>0) { // printf("HOHO\n"); update_gb_sound(snd_len-(lastpos*2.0)); // clk=0; } get_nb_cycle(); #ifdef LOG_SOUND fwrite(playbuf,snd_len,1,fsound); #endif memcpy(stream,playbuf,snd_len); memset(playbuf,0,snd_len); lastpos=curpos=0; } int gbsound_init(void) { SDL_AudioSpec desired; #ifdef LOG_SOUND fsound=fopen("./sound.raw","wb"); #endif SDL_InitSubSystem(SDL_INIT_AUDIO); sample_rate=conf.sample_rate; if (sample_rate>22000) sample_per_update=1024; else sample_per_update=512; desired.freq=sample_rate; desired.samples=sample_per_update; desired.format=AUDIO_S8; desired.channels = 2; desired.callback=update_stream; desired.userdata = NULL; if (!SDL_OpenAudio(&desired,NULL)) { //playbuf=(Sint8*)malloc(desired.size+1); if (playbuf) realloc((void*)playbuf,desired.size+1); else playbuf=(Sint8*)malloc(desired.size+1); buf_size=desired.size; memset(playbuf,0,desired.size); printf("Allocating %d for sound\n",desired.size); init_freq_table(); SDL_PauseAudio(0); update_sound_reg(); return 0; } printf("Error while trying to init sound\n"); return 1; } void close_sound(void) { SDL_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); #ifdef LOG_SOUND fclose(fsound); #endif } gngb-20060309/src/sound.h0000644000175000017500000001044607643033301013452 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _SOUND_H #define _SOUND_H #include "global.h" Uint32 sample_rate; Uint8 bit_per_sample; Uint16 sample_per_update; typedef struct SoundM1 { /* NR10 */ Uint8 swp_time; // -OOO---- Uint8 swp_dir; // ----O--- Uint8 swp_shift; // -----OOO /* NR11 */ Uint8 duty; // OO------ Uint8 len; // --OOOOOO -> Write only /* NR12 */ Uint8 env_start; // OOOO---- Uint8 env_dir; // ----O--- Uint8 env_swp; // -----OOO /* NR13 */ Uint8 freq_lo; // OOOOOOOO /* NR14 */ Uint8 initial; // O------- -> Write only Uint8 mode; // -O------ Uint8 freq_hi; // -----OOO -> Write only Uint8 env_changed; Uint16 freq; // freq_lo+(freq_hi<<8) float sample; // Periode en samples float sample_dut; // Wave Duty en samples Uint16 sample_len; // durée en samples float sample_sweep_time; float env_per_step; float sample_env_per_step; float cp; }SoundM1; SoundM1 snd_m1; typedef struct SoundM2 { /* NR21 */ Uint8 duty; // OO------ Uint8 len; // --OOOOOO -> Write only /* NR22 */ Uint8 env_start; // OOOO---- Uint8 env_dir; // ----O--- Uint8 env_swp; // -----OOO /* NR23 */ Uint8 freq_lo; // OOOOOOOO /* NR24 */ Uint8 initial; // O------- -> Write only Uint8 mode; // -O------ Uint8 freq_hi; // -----OOO -> Write only Uint8 env_changed; Uint16 freq; // freq_lo+(freq_hi<<8) float sample; // Periode en samples float sample_dut; // Wave Duty en samples Uint16 sample_len; // durée en samples float env_per_step; float sample_env_per_step; float cp; }SoundM2; SoundM2 snd_m2; typedef struct SoundM3 { /* NR30 */ Uint8 is_on; // O------- /* NR31 */ Uint8 len; // OOOOOOOO /* NR32 */ Uint8 level; // -OO----- /* NR33 */ Uint8 freq_lo; // OOOOOOOO /* NR34 */ Uint8 initial; // O------- -> Write only Uint8 mode; // -O------ Uint8 freq_hi; // -----OOO -> Write only Uint8 wave[16]; // Wave Pattern RAM Uint16 freq; // freq_lo+(freq_hi<<8) float sample; // Periode en samples Uint16 sample_len; // durée en samples float cp; }SoundM3; SoundM3 snd_m3; typedef struct SoundM4 { /* NR41 */ Uint8 len; // --OOOOOO /* NR42 */ Uint8 env_start; // OOOO---- Uint8 env_dir; // ----O--- Uint8 env_swp; // -----OOO /* NR43 */ Uint8 poly; /* NR14 */ Uint8 initial; // O------- -> Write only Uint8 mode; // -O------ Uint8 env_changed; Uint8 poly_changed; double sample; // Periode en samples float freq; Uint16 sample_len; // durée en samples float env_per_step; float sample_env_per_step; }SoundM4; SoundM4 snd_m4; /* Control general */ typedef struct SoundG { /* NR50 */ Uint8 SO1_OutputLevel ; // -----OOO Uint8 Vin_SO1 ; // ----O--- Uint8 SO2_OutputLevel ; // -OOO---- Uint8 Vin_SO2 ; // O------- /* NR51 */ Uint8 Sound1_To_SO1 ; Uint8 Sound2_To_SO1 ; Uint8 Sound3_To_SO1 ; Uint8 Sound4_To_SO1 ; Uint8 Sound1_To_SO2 ; Uint8 Sound2_To_SO2 ; Uint8 Sound3_To_SO2 ; Uint8 Sound4_To_SO2 ; /* NR52 */ Uint8 Sound_On_Off ; Uint8 Sound1_On_Off ; Uint8 Sound2_On_Off ; Uint8 Sound3_On_Off ; Uint8 Sound4_On_Off ; }SoundG; SoundG snd_g; #define LEFT 1 #define RIGHT 2 void update_gb_sound(float len); int gbsound_init(void); void close_sound(void); void write_sound_reg(Uint16 add,Uint8 val); Uint8 read_sound_reg(Uint16 add); void update_sound_reg(void); #endif gngb-20060309/src/global.h0000644000175000017500000000163710437075104013566 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GLOBAL_H #define _GLOBAL_H #include #include #endif gngb-20060309/src/getopt.h0000644000175000017500000001445707643033301013632 0ustar josejose/* Declarations for getopt. Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifndef _GETOPT_H #ifndef __need_getopt # define _GETOPT_H 1 #endif /* If __GNU_LIBRARY__ is not already defined, either we are being used standalone, or this is the first header included in the source file. If we are being used with glibc, we need to include , but that does not exist if we are standalone. So: if __GNU_LIBRARY__ is not defined, include , which will pull in for us if it's from glibc. (Why ctype.h? It's guaranteed to exist and it doesn't flood the namespace with stuff the way some other headers do.) */ #if !defined __GNU_LIBRARY__ # include #endif #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { # if (defined __STDC__ && __STDC__) || defined __cplusplus const char *name; # else char *name; # endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ # define no_argument 0 # define required_argument 1 # define optional_argument 2 #endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. Return the option character from OPTS just read. Return -1 when there are no more options. For unrecognized options, or options missing arguments, `optopt' is set to the option letter, and '?' is returned. The OPTS string is a list of characters which are recognized option letters, optionally followed by colons, specifying that that letter takes an argument, to be placed in `optarg'. If a letter in OPTS is followed by two colons, its argument is optional. This behavior is specific to the GNU `getopt'. The argument `--' causes premature termination of argument scanning, explicitly telling `getopt' that there are no more options. If OPTS begins with `--', then non-option arguments are treated as arguments to the option '\0'. This behavior is specific to the GNU `getopt'. */ #if (defined __STDC__ && __STDC__) || defined __cplusplus # ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int __argc, char *const *__argv, const char *__shortopts); # else /* not __GNU_LIBRARY__ */ extern int getopt (); # endif /* __GNU_LIBRARY__ */ # ifndef __need_getopt extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); extern int getopt_long_only (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only); # endif #else /* not __STDC__ */ extern int getopt (); # ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); # endif #endif /* __STDC__ */ #ifdef __cplusplus } #endif /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt #endif /* getopt.h */ gngb-20060309/src/Makefile.am0000644000175000017500000000067610467673161014225 0ustar josejosebin_PROGRAMS = gngb gngb_SOURCES = cpu.c cpu.h emu.c emu.h frame_skip.c frame_skip.h global.h interrupt.c interrupt.h main.c memory.c memory.h message.c message.h rom.c rom.h serial.c serial.h sgb.c sgb.h sound.c sound.h tiny_font.h vram.c vram.h video_yuy2.c video_yuv.c video_yuv.h video_yv12.c video_std.c video_gl.c video_gl.h video_std.h menu.h menu.c menu_image.h fileio.h fileio.c save.h save.c unzip.c unzip.h EXTRA_DIST = getopt.h gngb-20060309/src/Makefile.in0000644000175000017500000002377010476607762014242 0ustar josejose# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am # Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ CC = @CC@ HAVE_LIB = @HAVE_LIB@ LIB = @LIB@ LTLIB = @LTLIB@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ SDL_CONFIG = @SDL_CONFIG@ VERSION = @VERSION@ bin_PROGRAMS = gngb gngb_SOURCES = cpu.c cpu.h emu.c emu.h frame_skip.c frame_skip.h global.h interrupt.c interrupt.h main.c memory.c memory.h message.c message.h rom.c rom.h serial.c serial.h sgb.c sgb.h sound.c sound.h tiny_font.h vram.c vram.h video_yuy2.c video_yuv.c video_yuv.h video_yv12.c video_std.c video_gl.c video_gl.h video_std.h menu.h menu.c menu_image.h fileio.h fileio.c save.h save.c unzip.c unzip.h EXTRA_DIST = getopt.h mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = PROGRAMS = $(bin_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ gngb_OBJECTS = cpu.o emu.o frame_skip.o interrupt.o main.o memory.o \ message.o rom.o serial.o sgb.o sound.o vram.o video_yuy2.o video_yuv.o \ video_yv12.o video_std.o video_gl.o menu.o fileio.o save.o unzip.o gngb_LDADD = $(LDADD) gngb_DEPENDENCIES = gngb_LDFLAGS = CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best SOURCES = $(gngb_SOURCES) OBJECTS = $(gngb_OBJECTS) all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status mostlyclean-binPROGRAMS: clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) distclean-binPROGRAMS: maintainer-clean-binPROGRAMS: install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) list='$(bin_PROGRAMS)'; for p in $$list; do \ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done .c.o: $(COMPILE) -c $< .s.o: $(COMPILE) -c $< .S.o: $(COMPILE) -c $< mostlyclean-compile: -rm -f *.o core *.core clean-compile: distclean-compile: -rm -f *.tab.c maintainer-clean-compile: gngb: $(gngb_OBJECTS) $(gngb_DEPENDENCIES) @rm -f gngb $(LINK) $(gngb_LDFLAGS) $(gngb_OBJECTS) $(gngb_LDADD) $(LIBS) tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP)) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = src distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done cpu.o: cpu.c rom.h global.h ../config.h cpu.h memory.h interrupt.h \ serial.h emu.h fileio.h emu.o: emu.c ../config.h getopt.h emu.h global.h fileio.h message.h \ rom.h vram.h serial.h memory.h cpu.h interrupt.h menu.h \ frame_skip.h sound.h sgb.h video_std.h save.h fileio.o: fileio.c ../config.h getopt.h fileio.h unzip.h frame_skip.o: frame_skip.c ../config.h getopt.h frame_skip.h message.h \ emu.h global.h fileio.h interrupt.o: interrupt.c interrupt.h global.h ../config.h frame_skip.h \ memory.h vram.h cpu.h emu.h fileio.h rom.h main.o: main.c ../config.h getopt.h global.h emu.h fileio.h memory.h \ cpu.h rom.h vram.h interrupt.h serial.h frame_skip.h sgb.h \ sound.h save.h memory.o: memory.c memory.h global.h ../config.h emu.h fileio.h cpu.h \ rom.h vram.h interrupt.h frame_skip.h sound.h serial.h \ message.h sgb.h menu.o: menu.c ../config.h memory.h global.h emu.h global.h fileio.h \ menu.h message.h vram.h video_std.h rom.h sound.h menu_image.h \ save.h message.o: message.c global.h ../config.h tiny_font.h message.h emu.h \ fileio.h menu.h video_std.h vram.h rom.o: rom.c ../config.h getopt.h rom.h global.h memory.h emu.h fileio.h \ cpu.h interrupt.h vram.h sound.h save.h save.o: save.c emu.h global.h ../config.h fileio.h rom.h memory.h vram.h \ interrupt.h cpu.h serial.o: serial.c ../config.h getopt.h serial.h global.h interrupt.h \ memory.h emu.h fileio.h sgb.o: sgb.c ../config.h memory.h global.h sgb.h vram.h rom.h emu.h \ fileio.h sound.o: sound.c ../config.h emu.h global.h fileio.h sound.h memory.h \ interrupt.h cpu.h unzip.o: unzip.c getopt.h unzip.h video_gl.o: video_gl.c global.h ../config.h memory.h vram.h message.h \ tiny_font.h emu.h fileio.h interrupt.h sgb.h video_std.h \ video_gl.h video_std.o: video_std.c global.h ../config.h memory.h vram.h message.h \ tiny_font.h emu.h fileio.h interrupt.h sgb.h video_std.h menu.h video_yuv.o: video_yuv.c ../config.h cpu.h global.h emu.h fileio.h \ vram.h video_yuv.h memory.h message.h video_yuy2.o: video_yuy2.c ../config.h global.h memory.h video_yuv.h \ vram.h video_std.h sgb.h message.h emu.h fileio.h interrupt.h video_yv12.o: video_yv12.c global.h ../config.h memory.h video_yuv.h \ vram.h video_std.h sgb.h message.h emu.h fileio.h interrupt.h vram.o: vram.c vram.h global.h ../config.h memory.h rom.h interrupt.h \ message.h emu.h fileio.h sgb.h video_std.h menu.h info-am: info: info-am dvi-am: dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am install-exec-am: install-binPROGRAMS install-exec: install-exec-am install-data-am: install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall-binPROGRAMS uninstall: uninstall-am all-am: Makefile $(PROGRAMS) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ mostlyclean-tags mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-binPROGRAMS clean-compile clean-tags clean-generic \ mostlyclean-am clean: clean-am distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ distclean-generic clean-am distclean: distclean-am maintainer-clean-am: maintainer-clean-binPROGRAMS \ maintainer-clean-compile maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am .PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile tags mostlyclean-tags distclean-tags \ clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ check-am installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ all-redirect all-am all installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: gngb-20060309/src/video_std.c0000644000175000017500000005532110346773376014317 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "global.h" #include "memory.h" #include "vram.h" #include "message.h" #include "tiny_font.h" #include "emu.h" #include "interrupt.h" #include "sgb.h" #include "video_std.h" #include "menu.h" static Uint32 std_flag; SDL_Surface *back=NULL; Sint8 rb_tab[2][RB_SIZE]={{0,-2,2,-2,2}, {0,-1,-1,1,1}}; VIDEO_MODE video_std; SDL_Rect clip_rct; Uint8 win_line=0; /* static __inline__ Uint16 color_blend(Uint16 A,Uint16 B,Uint16 C,Uint16 D) { return BLEND2x16_50(BLEND2x16_50(BLEND16_50(D,0,0xf7de),BLEND2x16_50(B,C,0xf7de),0xf7de),A,0xf7de); // return BLEND16_50(BLEND16_50(A,D,0xf7de),BLEND16_50(B,C,0xf7de),0xf7de); } */ //#define FILTER_S2X (random&1?(A==D?A:(B==C?B:A)):A) #define FILTER_S2X (A==D?A:(B==C?B:A)) //#define FILTER_SMTH color_blend(A,B,C,D) #define FILTER_SMTH (BLEND2x16_50(BLEND2x16_50(BLEND16_50(D,0,0xf7de),BLEND2x16_50(B,C,0xf7de),0xf7de),A,0xf7de)); int (*filtered_blit)(SDL_Surface *src,SDL_Rect *srcrect,SDL_Surface *dst,SDL_Rect *dstrect); int blit_std_with_scanline(SDL_Surface *src,SDL_Rect *srcrect,SDL_Surface *dst,SDL_Rect *dstrect) { int i,j; int w=dst->w>>1; int h=dst->h>>1; Uint16* bufs=(Uint16*)src->pixels; Uint16* bufd=(Uint16*)dst->pixels; /* rumble support */ static Uint8 rumble=0; static Uint8 rb_time=0; if (rb_on) { rumble=2-rumble; bufs+=rumble; rb_time++; if (rb_time>8) rb_time=rb_on=0; } for(j=0;jpitch; bufs+=(src->pitch>>1); } return 0; } int blit_std_with_scanline50(SDL_Surface *src,SDL_Rect *srcrect,SDL_Surface *dst,SDL_Rect *dstrect) { int i,j; int w=dst->w>>1; int h=dst->h>>1; Uint16* bufs=(Uint16*)src->pixels+(src->pitch>>1); Uint16* nbufs=(Uint16*)src->pixels; Uint16* bufd=(Uint16*)dst->pixels; Uint16* nbufd=(Uint16*)dst->pixels+(dst->pitch>>1); static Uint8 rumble=0; static Uint8 rb_time=0; if (rb_on) { rumble=2-rumble; bufs+=rumble; rb_time++; if (rb_time>8) rb_time=rb_on=0; } for(j=0;jpitch; nbufd+=dst->pitch; bufs+=(src->pitch>>1); nbufs+=(src->pitch>>1); } return 0; } int blit_std_with_filter_s2x(SDL_Surface *src,SDL_Rect *srcrect,SDL_Surface *dst,SDL_Rect *dstrect){ Uint16* bufs=(Uint16*)src->pixels; Uint16* pbufs=(Uint16*)src->pixels; Uint16* nbufs=(Uint16*)src->pixels+(src->pitch>>1); Uint16* bufd=(Uint16*)dst->pixels; Uint16* nbufd=(Uint16*)dst->pixels+(dst->pitch>>1); int w=dst->w>>1; int h=dst->h>>1; int i,j; Uint16 A,B,C,D; Uint16 col; Uint16 t; static Uint8 rumble=0; static Uint8 rb_time=0; if (rb_on) { rumble=2-rumble; bufs+=rumble; nbufs+=rumble; pbufs+=rumble; rb_time++; if (rb_time>8) rb_time=rb_on=0; } for(i=0;ipitch>>1); nbufs+=(src->pitch>>1); bufd+=(dst->pitch>>1); nbufd+=(dst->pitch>>1); for(j=1;jpitch>>1); nbufs+=(src->pitch>>1); pbufs+=(src->pitch>>1); bufd+=dst->pitch; nbufd+=dst->pitch; } for(i=0;ipixels; Uint16* pbufs=(Uint16*)src->pixels; Uint16* nbufs=(Uint16*)src->pixels+(src->pitch>>1); Uint16* bufd=(Uint16*)dst->pixels; Uint16* nbufd=(Uint16*)dst->pixels+(dst->pitch>>1); int w=dst->w>>1; int h=dst->h>>1; int i,j; Uint16 A,B,C,D; static Uint8 rumble=0; static Uint8 rb_time=0; if (rb_on) { rumble=2-rumble; bufs+=rumble; nbufs+=rumble; pbufs+=rumble; rb_time++; if (rb_time>8) rb_time=rb_on=0; } for(i=0;ipitch>>1); nbufs+=(src->pitch>>1); bufd+=(dst->pitch>>1); nbufd+=(dst->pitch>>1); for(j=1;jpitch>>1); nbufs+=(src->pitch>>1); pbufs+=(src->pitch>>1); bufd+=dst->pitch; nbufd+=dst->pitch; } for(i=0;i=RB_SIZE) { rb_on=0; rb_shift=0; } } scrR.x=0; scrR.y=0; scrR.w=SCREEN_X; scrR.h=SCREEN_Y; dstR.x=rb_tab[0][rb_shift]+scxoff; dstR.y=rb_tab[1][rb_shift]+scyoff; dstR.w=SCREEN_X; dstR.h=SCREEN_Y; filtered_blit(back,&scrR,gb_screen,&dstR); SDL_Flip(gb_screen); /* FIXME: clear_screen */ if ((!(LCDCCONT&0x20) || !(LCDCCONT&0x01)) && (conf.gb_type&NORMAL_GAMEBOY)) clear_screen(); } void blit_screen_sgb_std(void) { if (rb_on) { SDL_SetClipRect(gb_screen,&clip_rct); rb_shift++; if (rb_shift>=RB_SIZE) { rb_on=0; rb_shift=0; SDL_SetClipRect(gb_screen,NULL); } } scrR.x=0; scrR.y=0; scrR.w=SCREEN_X; scrR.h=SCREEN_Y; dstR.x=rb_tab[0][rb_shift]+scxoff; dstR.y=rb_tab[1][rb_shift]+scyoff; dstR.w=SCREEN_X; dstR.h=SCREEN_Y; /* FIXME: sgb support and inverse the blit*/ /* if (conf.gb_type&SUPER_GAMEBOY) SDL_BlitSurface(sgb_buf,NULL,gb_screen,NULL);*/ if (sgb_mask) SDL_FillRect(back,NULL,pal_bck[0]); else SDL_BlitSurface(back,&scrR,gb_screen,&dstR); SDL_Flip(gb_screen); /* FIXME: clear_screen */ if ((!(LCDCCONT&0x20) || !(LCDCCONT&0x01)) && (conf.gb_type&NORMAL_GAMEBOY)) clear_screen(); } void init_video_std(Uint32 flag) { std_flag=flag|SDL_HWSURFACE; if (conf.gb_type&SUPER_GAMEBOY) gb_screen=SDL_SetVideoMode(SGB_WIDTH,SGB_HEIGHT, BIT_PER_PIXEL,std_flag); else { if (conf.filter) { if (conf.filter==5) { gb_screen=SDL_SetVideoMode(SCREEN_X,SCREEN_Y, BIT_PER_PIXEL,std_flag); } else gb_screen=SDL_SetVideoMode(SCREEN_X*2,SCREEN_Y*2, BIT_PER_PIXEL,std_flag); SDL_FillRect(gb_screen,NULL,0); } else gb_screen=SDL_SetVideoMode(SCREEN_X,SCREEN_Y, BIT_PER_PIXEL,std_flag); } switch (conf.filter) { case 1: filtered_blit=blit_std_with_scanline;break; case 2: filtered_blit=blit_std_with_scanline50;break; case 3: filtered_blit=blit_std_with_filter_smooth;break; case 4: filtered_blit=blit_std_with_filter_s2x;break; case 5: filtered_blit=blit_std_with_mblur;break; default: filtered_blit=SDL_BlitSurface;break; } if (gb_screen==NULL) { printf("Couldn't set %dx%dx%d video mode: %s\n", SCREEN_X,SCREEN_Y,BIT_PER_PIXEL,SDL_GetError()); exit(1); } if (conf.gb_type&SUPER_GAMEBOY) { scxoff=48; scyoff=40; video_std.blit=blit_screen_sgb_std; } else { scxoff=0; scyoff=0; video_std.blit=blit_screen_default_std; } clip_rct.x=scxoff; clip_rct.y=scyoff; clip_rct.w=SCREEN_X; clip_rct.h=SCREEN_Y; } void blit_sgb_mask_std(void) { SDL_BlitSurface(sgb_buf,NULL,gb_screen,NULL); } __inline__ void draw_spr_std(Uint16 *buf,GB_SPRITE *sp) { Uint8 *tp; Uint8 nx; Uint8 wbit,c; tp=&vram_page[0][sp->no_tile<<4]; if (!sp->yflip) tp+=((sp->yoff)<<1); else tp+=(sp->sizey-1-sp->yoff)<<1; for(nx=sp->xoff;nx<8;nx++) { if (!sp->xflip) wbit=nx; else wbit=7-nx; c=GET_GB_PIXEL(wbit); if (c) { if (!(sp->priority)) buf[sp->x+nx]=grey[pal_obj[sp->pal][c]]; else if (!back_col[sp->x+nx][CURLINE]) buf[sp->x+nx]=grey[pal_obj[sp->pal][c]]; } } } __inline__ void draw_obj_std(Uint16 *buf) { Sint8 i; for(i=nb_spr-1;i>=0;i--) draw_spr_std(buf,&gb_spr[(Uint8)i]); } __inline__ void draw_back_std(Uint16 *buf) { Uint8 *tb,*tp; int y,x,i; int sx,sy; Uint8 c; Sint16 no_tile; if (LCDCCONT&0x08) tb=&vram_page[0][0x1c00]; else tb=&vram_page[0][0x1800]; y=CURLINE; sy=SCRY+CURLINE; tb+=((sy>>3)<<5)&0x3ff; i=SCRX>>3; no_tile=tb[i&0x1f]; if (!(LCDCCONT&0x10)) no_tile=256+(signed char)no_tile; tp=&vram_page[0][no_tile<<4]; tp+=(sy&0x07)<<1; x=0; for(sx=SCRX&0x07;sx<8;sx++,x++) { c=GET_GB_PIXEL(sx); /* FIXME: VIC VIPER Laser */ buf[x]=grey[gblcdc->vram_pal_line[x][c]]; back_col[x][CURLINE]=c; } i++; for(;x<160;x+=8,i++) { no_tile=tb[i&0x1f]; if (!(LCDCCONT&0x10)) no_tile=256+(signed char)no_tile; tp=&vram_page[0][no_tile<<4]; tp+=(sy&0x07)<<1; for(sx=0;sx<8 && x+sx<160;sx++) { c=GET_GB_PIXEL(sx); /* FIXME: VIC VIPER Laser */ buf[x+sx]=grey[gblcdc->vram_pal_line[x+sx][c]]; back_col[x+sx][CURLINE]=c; } } } Uint8 win_curline=0; __inline__ void draw_win_std(Uint16 *buf) { Uint8 *tb,*tp; Sint16 y,x,i,sx=0; Sint16 no_tile; Uint8 c; if (LCDCCONT&0x40) tb=&vram_page[0][0x1c00]; else tb=&vram_page[0][0x1800]; if (WINX>=166) return; if (CURLINE>=WINY) { /*tb+=(((CURLINE-WINY)>>3)<<5); y=((CURLINE-WINY)&0x07)<<1;*/ tb+=(((gblcdc->win_curline/*-WINY*/)>>3)<<5); y=((gblcdc->win_curline/*-WINY*/)&0x07)<<1; x=(((WINX-7)<0)?0:(WINX-7)); for(i=0;x<160;x+=8,i++) { no_tile=tb[i]; if (!(LCDCCONT&0x10)) no_tile=256+(signed char)no_tile; tp=&vram_page[0][no_tile<<4]; tp+=y; for(sx=0;sx<8 && (x+sx)<160;sx++) { c=GET_GB_PIXEL(sx); /* FIXME: VIC VIPER Laser */ buf[x+sx]=grey[gblcdc->vram_pal_line[x+sx][c]]; back_col[x+sx][CURLINE]=c; } } gblcdc->win_curline++; } } /* CGB drawing functions */ __inline__ void draw_spr_col_std(Uint16 *buf,GB_SPRITE *sp) { Uint8 *tp; Uint8 nx; Uint8 wbit,c; tp=&vram_page[sp->page][sp->no_tile<<4]; if (!sp->yflip) tp+=((sp->yoff)<<1); else tp+=(sp->sizey-1-sp->yoff)<<1; for(nx=sp->xoff;nx<8;nx++) { if (!sp->xflip) wbit=nx; else wbit=7-nx; c=GET_GB_PIXEL(wbit); /* TODO: OPTIMISATION */ /* if (back_col[sp->x+nx][CURLINE]&0x80) { if (c) { if (!(back_col[sp->x+nx][CURLINE]&0x0f)) buf[sp->x+nx]=pal_col_obj[sp->pal_col][c]; } } else { if (!sp->priority) { if (c) buf[sp->x+nx]=pal_col_obj[sp->pal_col][c]; } else { if (!(back_col[sp->x+nx][CURLINE]&0x0f)) buf[sp->x+nx]=pal_col_obj[sp->pal_col][c]; } }*/ if (LCDCCONT&0x01) { if (c) { if (back_col[sp->x+nx][CURLINE]&0x80) { if (!(back_col[sp->x+nx][CURLINE]&0x0f)) buf[sp->x+nx]=pal_col_obj[sp->pal_col][c]; } else if (!sp->priority) buf[sp->x+nx]=pal_col_obj[sp->pal_col][c]; else if (!(back_col[sp->x+nx][CURLINE]&0x0f)) buf[sp->x+nx]=pal_col_obj[sp->pal_col][c]; } } else if (c) buf[sp->x+nx]=pal_col_obj[sp->pal_col][c]; } } __inline__ void draw_obj_col_std(Uint16 *buf) { Sint8 i; for(i=nb_spr-1;i>=0;i--) draw_spr_col_std(buf,&gb_spr[(Uint8)i]); } __inline__ void draw_back_col_std(Uint16 *buf) { Uint8 *tb,*tp,*att_tb; Uint16 y,x,i; Uint16 sx,sy; Uint8 c,p,att,xflip,yflip; Sint16 no_tile; if (LCDCCONT&0x08) {// select Tile Map tb=&vram_page[0][0x1c00]; att_tb=&vram_page[1][0x1c00]; } else { tb=&vram_page[0][0x1800]; att_tb=&vram_page[1][0x1800]; } y=CURLINE; sy=SCRY+CURLINE; tb+=((sy>>3)<<5)&0x3ff; att_tb+=((sy>>3)<<5)&0x3ff; i=SCRX>>3; no_tile=tb[i&0x1f]; att=att_tb[i&0x1f]; yflip = (att & 0x40) ? 1 : 0; xflip = (att & 0x20) ? 1 : 0; p=att&0x07; if (!(LCDCCONT&0x10)) no_tile=256+(signed char)no_tile; tp=&vram_page[(att&0x08)>>3][(no_tile<<4)]; if (!yflip) tp+=((sy&0x07)<<1); else tp+=((7-(sy&0x07))<<1); x=0; for(sx=SCRX&0x07;sx<8;sx++,x++) { int wbit; if (!xflip) wbit=sx; else wbit=7-sx; c=GET_GB_PIXEL(wbit); buf[x]=pal_col_bck[p][c]; back_col[x][CURLINE]=(att&0x80)+c; } i++; for(;x<160;x+=8,i++) { no_tile=tb[i&0x1f]; att=att_tb[i&0x1f]; yflip = (att & 0x40) ? 1 : 0; xflip = (att & 0x20) ? 1 : 0; p=att&0x07; if (!(LCDCCONT&0x10)) no_tile=256+(signed char)no_tile; tp=&vram_page[(att&0x08)>>3][(no_tile<<4)]; if (!yflip) tp+=((sy&0x07)<<1); else tp+=((7-(sy&0x07))<<1); for(sx=0;sx<8;sx++) { int wbit; if (!xflip) wbit=sx; else wbit=7-sx; c=GET_GB_PIXEL(wbit); buf[x+sx]=pal_col_bck[p][c]; back_col[x+sx][CURLINE]=(att&0x80)+c; } } } __inline__ void draw_win_col_std(Uint16 *buf) { Uint8 *tb,*tp,*att_tb; Uint16 y,x,i,sx; Sint16 no_tile; Uint8 c,p,att,xflip,yflip; if (LCDCCONT&0x40) { tb=&vram_page[0][0x1c00]; att_tb=&vram_page[1][0x1c00]; } else { tb=&vram_page[0][0x1800]; att_tb=&vram_page[1][0x1800]; } if (WINX>=166) return; if (CURLINE>=WINY) { /*tb+=(((CURLINE-WINY)>>3)<<5); att_tb+=(((CURLINE-WINY)>>3)<<5); y=((CURLINE-WINY)&0x07);*/ tb+=(((gblcdc->win_curline)>>3)<<5); att_tb+=(((gblcdc->win_curline)>>3)<<5); y=((gblcdc->win_curline)&0x07); x=(((WINX-7)<0)?0:(WINX-7)); for(i=0;x<160;x+=8,i++) { no_tile=tb[i]; att=att_tb[i]; yflip = (att & 0x40) ? 1 : 0; xflip = (att & 0x20) ? 1 : 0; p=att&0x07; if (!(LCDCCONT&0x10)) no_tile=256+(signed char)no_tile; tp=&vram_page[(att&0x08)>>3][(no_tile<<4)]; if (!yflip) tp+=y<<1; else tp+=((7-y)<<1); for(sx=0;sx<8;sx++) { int wbit; if (!xflip) wbit=sx; else wbit=7-sx; c=GET_GB_PIXEL(wbit); buf[x+sx]=pal_col_bck[p][c]; if (!(att&0x80)) back_col[x+sx][CURLINE]=c; else back_col[x+sx][CURLINE]=0x80+c; } } gblcdc->win_curline++; } } /* SGB drawing Functions To Optimize */ __inline__ void draw_back_sgb_std(Uint16 *buf) { Uint8 *tb,*tp; int y,x,i; int sx,sy; Uint8 c; Sint16 no_tile; if (LCDCCONT&0x08) tb=&vram_page[0][0x1c00]; else tb=&vram_page[0][0x1800]; y=CURLINE; sy=SCRY+CURLINE; tb+=((sy>>3)<<5)&0x3ff; i=SCRX>>3; no_tile=tb[i&0x1f]; if (!(LCDCCONT&0x10)) no_tile=256+(signed char)no_tile; tp=&vram_page[0][no_tile<<4]; tp+=(sy&0x07)<<1; x=0; for(sx=SCRX&0x07;sx<8;sx++,x++) { c=GET_GB_PIXEL(sx); //buf[x]=sgb_pal[sgb_pal_map[x/8][CURLINE/8]][pal_bck[c]]; /* FIXME VIC VIPER */ buf[x]=sgb_pal[sgb_pal_map[x/8][CURLINE/8]][gblcdc->vram_pal_line[x+sx][c]]; back_col[x][CURLINE]=c; } i++; for(;x<160;x+=8,i++) { no_tile=tb[i&0x1f]; if (!(LCDCCONT&0x10)) no_tile=256+(signed char)no_tile; tp=&vram_page[0][no_tile<<4]; tp+=(sy&0x07)<<1; for(sx=0;sx<8 && x+sx<160;sx++) { c=GET_GB_PIXEL(sx); //buf[x+sx]=sgb_pal[sgb_pal_map[x/8][CURLINE/8]][pal_bck[c]]; //buf[x+sx]=sgb_pal[sgb_pal_map[x/8][CURLINE/8]][c]; /* FIXME VIC VIPER */ buf[x+sx]=sgb_pal[sgb_pal_map[x/8][CURLINE/8]][gblcdc->vram_pal_line[x+sx][c]]; back_col[x+sx][CURLINE]=c; } } } __inline__ void draw_win_sgb_std(Uint16 *buf) { Uint8 *tb,*tp; Sint16 y,x,i,sx; Sint16 no_tile; Uint8 c; if (LCDCCONT&0x40) tb=&vram_page[0][0x1c00]; else tb=&vram_page[0][0x1800]; if (WINX>=166) return; if (CURLINE>=WINY) { /*tb+=(((CURLINE-WINY)>>3)<<5); y=((CURLINE-WINY)&0x07)<<1;*/ tb+=(((gblcdc->win_curline/*-WINY*/)>>3)<<5); y=((gblcdc->win_curline/*-WINY*/)&0x07)<<1; x=(((WINX-7)<0)?0:(WINX-7)); for(i=0;x<160;x+=8,i++) { no_tile=tb[i]; if (!(LCDCCONT&0x10)) no_tile=256+(signed char)no_tile; tp=&vram_page[0][no_tile<<4]; tp+=y; for(sx=0;sx<8 && x+sx<160;sx++) { c=GET_GB_PIXEL(sx); //buf[x+sx]=pal_bck[c]; //buf[x+sx]=sgb_pal[sgb_pal_map[x/8][CURLINE/8]][pal_bck[c]]; buf[x+sx]=sgb_pal[sgb_pal_map[x/8][CURLINE/8]][gblcdc->vram_pal_line[x+sx][c]]; back_col[x+sx][CURLINE]=c; } } win_curline++; } } __inline__ void draw_spr_sgb_std(Uint16 *buf,GB_SPRITE *sp) { Uint8 *tp; Uint8 nx; Uint8 /*bit0,bit1,*/wbit,c; tp=&vram_page[0][sp->no_tile<<4]; if (!sp->yflip) tp+=((sp->yoff)<<1); else tp+=(sp->sizey-1-sp->yoff)<<1; for(nx=sp->xoff;nx<8;nx++) { if (!sp->xflip) wbit=nx; else wbit=7-nx; c=GET_GB_PIXEL(wbit); if (c) { /* FIXME */ if (!(sp->priority)) buf[sp->x+nx]=sgb_pal[sgb_pal_map[(sp->x+nx)/8][CURLINE/8]][pal_obj[sp->pal][c]]; else if (!back_col[sp->x+nx][CURLINE]) buf[sp->x+nx]=sgb_pal[sgb_pal_map[(sp->x+nx)/8][CURLINE/8]][pal_obj[sp->pal][c]]; /*if (!(sp->priority)) buf[sp->x+nx]=sgb_pal[0][pal_obj[sp->pal][c]]; else if (!back_col[sp->x+nx][CURLINE]) buf[sp->x+nx]=sgb_pal[0][pal_obj[sp->pal][c]];*/ /*if (!(sp->priority)) buf[sp->x+nx]=sgb_pal[sp->pal_col][c]; else if (!back_col[sp->x+nx][CURLINE]) buf[sp->x+nx]=sgb_pal[sp->pal_col][c];*/ } } } __inline__ void draw_obj_sgb_std(Uint16 *buf) { Sint8 i; for(i=nb_spr-1;i>=0;i--) draw_spr_sgb_std(buf,&gb_spr[(Uint8)i]); } void draw_screen_wb_std(void) { Uint16 *buf=(Uint16 *)back->pixels + CURLINE*(back->pitch>>1); if (SDL_MUSTLOCK(back) && SDL_LockSurface(back)<0) printf("can't lock surface\n"); if (LCDCCONT&0x01) draw_back_std(buf); if (LCDCCONT&0x20) draw_win_std(buf); if (LCDCCONT&0x02) draw_obj_std(buf); if (SDL_MUSTLOCK(back)) SDL_UnlockSurface(back); } void draw_screen_col_std(void) { Uint16 *buf=(Uint16 *)back->pixels + CURLINE*(back->pitch>>1); if (SDL_MUSTLOCK(back) && SDL_LockSurface(back)<0) printf("can't lock surface\n"); draw_back_col_std(buf); if (LCDCCONT&0x20) draw_win_col_std(buf); if (LCDCCONT&0x02) draw_obj_col_std(buf); if (SDL_MUSTLOCK(back)) SDL_UnlockSurface(back); } void draw_screen_sgb_std(void) { Uint16 *buf=(Uint16 *)back->pixels + CURLINE*(back->pitch>>1); if (SDL_MUSTLOCK(back) && SDL_LockSurface(back)<0) printf("can't lock surface\n"); if (LCDCCONT&0x01) draw_back_sgb_std(buf); if (LCDCCONT&0x20) draw_win_sgb_std(buf); /* FIXME */ if (LCDCCONT&0x02) draw_obj_sgb_std(buf); if (SDL_MUSTLOCK(back)) SDL_UnlockSurface(back); } void clear_screen_std(void) { if (back && gb_screen) { if (conf.gb_type&COLOR_GAMEBOY) { SDL_FillRect(back,NULL,pal_col_bck[0][0]); //SDL_FillRect(gb_screen,NULL,pal_col_bck[0][0]); } else { SDL_FillRect(back,NULL,grey[0]); //SDL_FillRect(gb_screen,NULL,grey[0]); } } SDL_Flip(gb_screen); } VIDEO_MODE video_std={ init_video_std, NULL, // draw_screen_col_std, // draw_screen_wb_std, // draw_screen_sgb_std, NULL, blit_sgb_mask_std, // NULL, // draw_message_std, // clear_screen_std }; gngb-20060309/src/video_std.h0000644000175000017500000000340207643033301014274 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _VIDEO_STD_H_ #define _VIDEO_STD_H_ #include "vram.h" #define RB_SIZE 5 extern Sint8 rb_tab[2][RB_SIZE]; extern SDL_Surface *back; Uint8 rb_shift; SDL_Rect dstR; SDL_Rect scrR; void draw_screen_sgb_std(void); void draw_screen_wb_std(void); void draw_screen_col_std(void); void clear_screen_std(void); void set_filter(int filter); __inline__ void draw_back_sgb_std(Uint16 *buf); __inline__ void draw_win_sgb_std(Uint16 *buf); __inline__ void draw_spr_sgb_std(Uint16 *buf,GB_SPRITE *sp); __inline__ void draw_obj_sgb_std(Uint16 *buf); __inline__ void draw_back_col_std(Uint16 *buf); __inline__ void draw_win_col_std(Uint16 *buf); __inline__ void draw_spr_col_std(Uint16 *buf,GB_SPRITE *sp); __inline__ void draw_obj_col_std(Uint16 *buf); __inline__ void draw_back_std(Uint16 *buf); __inline__ void draw_win_std(Uint16 *buf); __inline__ void draw_spr_std(Uint16 *buf,GB_SPRITE *sp); __inline__ void draw_obj_std(Uint16 *buf); #endif gngb-20060309/src/tiny_font.h0000644000175000017500000004725307643033301014341 0ustar josejose/* image2c image dump (font_xterm.png) */ static const struct { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ unsigned char pixel_data[8736]; } tiny_font = { 672, 13, 1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\1\1\0\0\0\0\1\1\0\1\1\0\0\0\1" "\0\1\0\0\0\0\1\1\0\0\0\1\1\1\0\0\1\0" "\0\1\1\1\0\0\0\0\0\1\1\1\0\0\0\0\0\1" "\1\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0" "\1\1\0\0\0\0\0\1\1\0\0\0\0\1\1\1\1\0" "\0\1\1\1\1\1\1\0\0\0\0\0\1\1\0\1\1\1" "\1\1\1\0\0\1\1\1\1\0\0\1\1\1\1\1\1\0" "\0\1\1\1\1\0\0\0\1\1\1\1\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0" "\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1\1\1" "\0\0\0\1\1\1\1\0\0\0\1\1\1\1\0\0\1\1" "\1\1\1\0\0\0\1\1\1\1\0\0\1\1\1\1\1\0" "\0\1\1\1\1\1\1\0\1\1\1\1\1\1\0\0\1\1" "\1\1\0\0\1\1\0\0\1\1\0\1\1\1\1\1\1\0" "\0\0\0\0\1\1\0\1\1\0\0\0\1\0\1\1\0\0" "\0\0\0\1\0\0\0\0\1\0\1\1\0\0\1\1\0\0" "\1\1\1\1\0\0\1\1\1\1\1\0\0\0\1\1\1\1" "\0\0\1\1\1\1\1\0\0\0\1\1\1\1\0\0\1\1" "\1\1\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1" "\0\1\1\0\0\1\1\0\1\0\0\0\0\1\0\1\1\0" "\0\1\1\0\1\1\1\1\1\1\0\0\1\1\1\1\0\0" "\1\1\0\0\0\0\0\0\1\1\1\1\0\0\0\0\1\1" "\0\0\0\0\0\0\0\0\0\0\0\1\1\1\0\0\0\0" "\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0" "\1\1\1\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0" "\0\0\0\1\1\0\0\0\0\0\0\0\1\1\0\1\1\0" "\0\0\0\0\0\1\1\1\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\1\1\1\0\0\0\0\1\1\0\0\0\0\1\1" "\1\0\0\0\0\1\1\0\0\1\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\1\1\0" "\1\1\0\0\0\1\0\1\0\0\0\1\1\1\1\0\0\1" "\0\1\0\1\1\0\1\1\0\1\1\0\0\0\0\1\1\1" "\0\0\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\1\1\0\0\1\0\0\1\0\0\0\1\1\1\0\0\0" "\1\1\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0\1" "\1\1\0\1\1\0\0\0\0\0\1\1\0\0\1\1\0\0" "\0\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1" "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\1\1\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0" "\0\1\1\0\0\1\1\0\1\0\0\0\1\1\0\1\1\0" "\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0" "\1\1\0\0\1\1\0\1\1\0\0\0\0\0\1\1\0\0" "\0\0\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\0" "\0\1\1\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1" "\1\0\1\1\0\0\0\0\0\1\1\0\0\1\1\0\1\1" "\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1" "\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0" "\0\1\1\0\0\0\1\1\0\0\0\1\1\0\0\1\1\0" "\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0" "\1\1\0\1\1\0\0\1\1\0\0\0\0\0\1\1\0\0" "\1\1\0\0\0\0\1\1\0\0\0\0\0\0\0\0\1\1" "\0\0\0\1\1\1\1\0\0\0\0\0\0\0\0\0\0\1" "\1\1\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0" "\0\0\0\0\0\1\1\0\1\1\0\0\0\0\0\0\0\0" "\1\1\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0" "\1\1\0\1\1\0\0\0\0\0\0\0\1\1\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1" "\0\0\0\0\0\0\1\1\0\0\1\1\1\1\1\1\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0" "\0\0\0\1\1\0\1\1\0\0\1\1\1\1\1\0\1\0" "\1\1\0\1\0\1\1\1\0\1\0\0\1\1\0\1\1\0" "\0\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0\0\1" "\1\0\0\0\0\1\0\0\1\0\0\0\0\1\1\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\1\1\0\0\1\1\0\0\1\1\0\1" "\0\1\1\0\0\0\1\1\0\0\1\1\0\0\0\0\1\1" "\0\0\0\0\1\1\1\1\0\1\1\0\0\0\0\0\1\1" "\0\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1\1" "\0\1\1\0\0\1\1\0\0\0\1\1\0\0\0\0\0\1" "\1\0\0\0\0\0\1\1\0\0\0\1\1\1\1\1\1\0" "\0\0\1\1\0\0\0\1\1\0\0\1\1\0\1\0\0\0" "\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1" "\1\0\0\0\0\0\1\1\0\0\1\1\0\1\1\0\0\0" "\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0\0\1\1" "\0\0\1\1\0\0\0\1\1\0\0\0\0\0\0\0\1\1" "\0\1\1\0\1\1\0\0\1\1\0\0\0\0\0\1\1\1" "\1\1\1\0\1\1\1\0\1\1\0\1\1\0\0\1\1\0" "\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0" "\1\1\0\1\1\0\0\0\0\0\0\0\1\1\0\0\0\1" "\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1" "\1\0\0\1\0\0\1\0\0\0\1\1\1\1\0\0\0\0" "\0\0\1\1\0\0\1\1\0\0\0\0\0\1\1\0\0\0" "\0\0\0\0\1\1\0\0\1\1\0\0\1\1\0\0\0\0" "\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0" "\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\1\1\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\0" "\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0" "\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0" "\0\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\1\0" "\0\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0\0\1\1" "\1\1\1\0\1\0\1\1\0\0\0\0\0\0\1\1\0\0" "\1\1\0\1\1\0\0\0\1\1\0\0\0\0\0\1\1\0" "\0\0\0\0\0\0\1\1\0\0\0\0\1\1\0\0\0\0" "\0\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0\1\1" "\0\0\1\1\0\0\0\1\1\0\0\0\0\0\0\0\1\1" "\0\0\0\1\1\0\0\0\0\1\1\0\1\1\0\1\1\1" "\1\1\0\0\1\1\0\0\0\0\0\0\0\0\1\1\0\0" "\1\1\0\0\1\1\0\1\1\0\0\1\1\0\0\1\1\1" "\1\0\0\0\1\1\1\1\0\0\0\1\1\0\0\0\0\1" "\1\1\1\1\1\0\0\0\0\1\1\0\0\0\0\0\0\1" "\1\0\1\0\1\1\1\1\0\1\1\0\0\1\1\0\1\1" "\0\0\1\1\0\1\1\0\0\0\0\0\1\1\0\0\1\1" "\0\1\1\0\0\0\0\0\1\1\0\0\0\0\0\1\1\0" "\0\0\0\0\1\1\0\0\1\1\0\0\0\1\1\0\0\0" "\0\0\0\0\1\1\0\1\1\1\1\0\0\0\1\1\0\0" "\0\0\0\1\1\1\1\1\1\0\1\1\1\0\1\1\0\1" "\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1" "\1\0\1\1\0\0\1\1\0\1\1\0\0\0\0\0\0\0" "\1\1\0\0\0\1\1\0\0\1\1\0\0\1\0\0\1\0" "\0\1\1\0\0\1\1\0\0\1\1\1\1\0\0\0\1\1" "\1\1\0\0\0\0\0\1\1\0\0\0\1\1\0\0\0\0" "\0\1\1\0\0\0\0\0\0\0\1\1\0\0\1\0\0\0" "\0\1\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0" "\1\1\1\1\0\0\1\1\1\1\1\0\0\0\1\1\1\1" "\0\0\0\1\1\1\1\1\0\0\1\1\1\1\0\0\0\1" "\1\0\0\0\0\0\1\1\1\0\1\0\1\1\1\1\1\0" "\0\0\1\1\1\0\0\0\0\0\0\0\1\1\0\1\1\0" "\0\1\1\0\0\0\1\1\0\0\0\1\1\0\1\1\0\0" "\1\1\1\1\1\0\0\0\1\1\1\1\0\0\1\1\1\1" "\1\0\0\0\1\1\1\1\1\0\1\1\1\1\1\0\0\0" "\1\1\1\1\0\0\1\1\1\1\1\0\0\1\1\0\0\1" "\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1" "\0\0\1\1\0\1\1\0\0\1\1\0\1\1\1\1\1\1" "\0\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0\0\1" "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0" "\0\0\0\0\0\1\0\1\0\0\0\1\1\1\1\0\0\0" "\0\1\1\0\0\0\0\1\1\1\0\0\0\0\0\0\0\0" "\0\0\0\1\1\0\0\0\0\0\0\0\1\1\0\0\1\1" "\1\1\1\1\0\1\1\1\1\1\1\0\0\0\0\0\0\0" "\0\1\1\1\1\1\1\0\0\0\0\0\0\0\0\0\0\1" "\1\0\0\0\1\1\0\0\1\1\0\0\0\1\1\0\0\0" "\0\0\1\1\1\0\0\0\1\1\1\1\0\0\1\1\0\0" "\1\1\0\1\1\0\0\1\1\0\1\1\1\1\1\0\0\0" "\0\0\1\1\0\0\0\1\1\1\1\0\0\0\1\1\1\1" "\1\0\0\0\1\1\0\0\0\0\0\1\1\0\0\0\1\1" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1" "\0\0\0\1\1\1\0\0\1\0\1\0\1\1\0\1\1\1" "\1\1\1\0\1\1\1\1\1\0\0\1\1\0\0\0\0\0" "\1\1\0\0\1\1\0\1\1\1\1\1\0\0\1\1\1\1" "\1\0\0\1\1\0\1\1\1\0\1\1\1\1\1\1\0\0" "\0\1\1\0\0\0\0\0\0\0\1\1\0\1\1\1\0\0" "\0\0\1\1\0\0\0\0\0\1\1\0\0\1\1\0\1\1" "\1\1\1\1\0\1\1\0\0\1\1\0\1\1\1\1\1\0" "\0\1\1\0\0\1\1\0\1\1\1\1\1\0\0\0\1\1" "\1\1\0\0\0\0\1\1\0\0\0\1\1\0\0\1\1\0" "\0\1\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1" "\0\0\0\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0" "\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1\1" "\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0" "\0\1\1\0\1\1\1\1\0\0\0\1\1\0\0\1\1\0" "\1\1\0\0\1\1\0\0\0\1\1\0\0\0\0\0\0\0" "\1\1\0\1\1\0\1\1\0\0\0\0\1\1\0\0\0\1" "\1\1\1\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1" "\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1" "\0\0\1\1\0\1\1\0\0\1\1\0\0\1\1\0\0\0" "\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0" "\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0" "\0\0\0\0\1\1\0\0\1\1\0\0\0\0\0\0\1\1" "\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0" "\0\0\0\0\0\0\0\0\0\0\1\1\1\1\1\0\0\0" "\1\1\0\1\0\0\1\1\0\0\0\0\1\1\0\1\0\1" "\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0" "\1\1\0\0\1\1\1\1\1\1\0\1\1\1\1\1\1\0" "\0\0\0\0\0\0\0\1\1\1\1\1\1\0\0\0\0\0" "\0\0\0\0\1\1\0\0\0\0\1\1\0\0\1\1\0\0" "\0\1\1\0\0\0\0\1\1\0\0\0\0\0\0\0\0\1" "\1\0\1\1\0\0\1\1\0\0\0\0\0\1\1\0\1\1" "\0\0\1\1\0\0\0\1\1\0\0\0\1\1\0\0\1\1" "\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\1\1\0\0\0\0\1\1\1\1\1\1\0" "\0\0\0\1\1\0\0\0\0\1\1\0\0\0\1\0\1\1" "\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1" "\1\0\0\0\0\0\1\1\0\0\1\1\0\1\1\0\0\0" "\0\0\1\1\0\0\0\0\0\1\1\0\0\1\1\0\1\1" "\0\0\1\1\0\0\0\1\1\0\0\0\0\0\0\0\1\1" "\0\1\1\1\1\0\0\0\1\1\0\0\0\0\0\1\1\0" "\0\1\1\0\1\1\0\1\1\1\0\1\1\0\0\1\1\0" "\1\1\0\0\0\0\0\1\1\0\0\1\1\0\1\1\1\1" "\0\0\0\0\0\0\0\1\1\0\0\0\1\1\0\0\0\1" "\1\0\0\1\1\0\0\1\1\1\1\0\0\1\1\1\1\1" "\1\0\0\1\1\1\1\0\0\0\0\1\1\0\0\0\0\1" "\1\0\0\0\0\0\1\1\0\0\0\0\0\0\0\1\1\0" "\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1\1\1\0" "\1\1\0\0\1\1\0\1\1\0\0\0\0\0\1\1\0\0" "\1\1\0\1\1\1\1\1\1\0\0\1\1\0\0\0\0\1" "\1\0\0\1\1\0\1\1\0\0\1\1\0\0\0\1\1\0" "\0\0\0\0\0\0\1\1\0\1\1\1\1\0\0\0\0\0" "\1\1\0\0\0\1\1\1\1\1\1\0\1\1\0\0\1\1" "\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0" "\0\1\1\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0" "\0\1\1\0\0\0\0\1\1\0\0\1\1\0\1\1\0\0" "\1\1\0\1\1\0\0\1\1\0\0\1\1\1\1\0\0\1" "\1\0\0\1\1\0\0\0\0\1\1\0\0\0\0\1\1\0" "\0\0\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1" "\1\1\1\0\1\0\1\1\0\1\0\0\1\0\1\1\1\0" "\1\1\0\1\1\1\0\0\0\0\0\0\0\0\0\0\1\1" "\0\0\0\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0" "\0\1\1\0\0\0\0\0\1\1\1\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\1\1" "\0\0\1\1\0\0\0\1\1\0\0\0\1\1\0\0\0\0" "\0\0\0\0\0\1\1\0\1\1\1\1\1\1\0\0\0\0" "\0\1\1\0\1\1\0\0\1\1\0\0\0\1\1\0\0\0" "\1\1\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0\0" "\0\0\0\0\0\1\1\1\0\0\0\0\1\1\0\0\0\1" "\1\1\1\1\1\0\0\0\1\1\0\0\0\0\0\0\0\0" "\0\0\1\0\0\0\0\0\0\1\1\0\0\1\1\0\1\1" "\0\0\1\1\0\1\1\0\0\0\0\0\1\1\0\0\1\1" "\0\1\1\0\0\0\0\0\1\1\0\0\0\0\0\1\1\0" "\0\1\1\0\1\1\0\0\1\1\0\0\0\1\1\0\0\0" "\0\0\0\0\1\1\0\1\1\0\1\1\0\0\1\1\0\0" "\0\0\0\1\1\0\0\1\1\0\1\1\0\1\1\1\0\1" "\1\0\0\1\1\0\1\1\0\0\0\0\0\1\1\1\0\1" "\1\0\1\1\0\1\1\0\0\0\0\0\0\1\1\0\0\0" "\1\1\0\0\0\1\1\0\0\1\1\0\0\0\1\1\0\0" "\0\1\1\1\1\1\1\0\0\1\0\0\1\0\0\0\0\1" "\1\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0" "\0\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1" "\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\0" "\0\0\1\1\0\0\1\1\0\1\1\0\0\0\0\0\0\1" "\1\0\0\0\0\0\1\1\1\1\0\0\1\1\0\0\1\1" "\0\0\0\1\1\0\0\0\0\0\0\0\1\1\0\1\1\1" "\1\0\0\0\0\0\1\1\0\0\0\1\1\0\0\1\1\0" "\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0" "\1\1\0\1\1\0\0\1\1\0\1\1\0\0\0\0\0\0" "\0\0\1\1\0\0\0\1\1\0\0\0\0\1\1\0\0\1" "\1\0\0\1\1\1\1\0\0\1\1\1\1\1\1\0\0\1" "\1\1\1\0\0\1\1\0\0\1\1\0\0\1\1\0\0\0" "\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0" "\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0" "\0\0\0\0\0\1\0\1\0\0\0\1\1\1\1\0\0\1" "\1\0\1\0\1\0\1\1\0\1\1\0\0\0\0\0\0\0" "\0\0\0\0\1\1\0\0\0\0\0\1\1\0\0\0\0\1" "\0\0\1\0\0\0\0\1\1\0\0\0\0\0\1\1\1\0" "\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0\1\1\0" "\0\0\0\0\0\1\0\0\1\0\0\0\0\1\1\0\0\0" "\1\1\0\0\0\0\0\1\1\0\0\1\1\0\0\0\0\0" "\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\0" "\1\1\0\0\0\0\1\1\0\0\1\1\0\1\1\0\0\1" "\1\0\0\0\1\1\0\0\0\0\0\1\1\1\0\0\0\0" "\0\1\1\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0" "\0\0\0\1\1\0\0\0\1\0\0\0\1\1\0\1\1\0" "\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0" "\1\1\0\0\1\1\0\1\1\0\0\0\0\0\1\1\0\0" "\0\0\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\0" "\0\1\1\0\0\0\1\1\0\0\1\1\0\1\1\0\0\1" "\1\0\1\1\0\0\0\0\0\1\1\0\0\1\1\0\1\1" "\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\0\0" "\0\1\1\0\1\1\1\0\1\1\0\0\1\1\0\1\1\0" "\0\1\1\0\0\0\1\1\0\0\0\1\1\0\0\1\1\0" "\0\0\1\1\0\0\0\1\1\0\0\1\1\0\1\1\0\0" "\1\1\0\0\0\1\1\0\0\0\1\1\0\0\0\0\0\0" "\1\1\0\0\0\0\0\0\0\0\1\1\0\0\0\0\1\1" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\1\1\0\0\1\1\0\1\1\0\0\1\1" "\0\1\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0" "\0\1\1\0\0\1\1\0\0\0\0\1\1\0\0\0\0\0" "\1\1\0\0\1\1\0\0\0\1\1\0\0\0\0\0\0\0" "\1\1\0\1\1\0\1\1\0\0\0\0\1\1\0\0\0\1" "\1\0\0\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1" "\1\0\1\1\1\1\1\0\0\0\1\1\1\1\1\0\1\1" "\0\0\0\0\0\1\1\0\0\1\1\0\0\1\1\0\1\1" "\0\1\1\0\0\1\1\0\0\1\1\1\1\0\0\1\1\1" "\1\1\1\0\1\1\0\0\1\1\0\0\1\1\1\1\1\0" "\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1" "\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0" "\0\0\0\0\0\0\0\0\0\0\0\1\0\1\0\0\0\0" "\1\1\0\0\0\1\0\0\1\1\1\0\0\1\1\1\0\1" "\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0\1\1" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\1\1\0\0\0\0\0\0\0\0\0\0\0\1\1\1" "\1\0\0\1\1\0\0\0\0\0\0\0\1\1\0\0\0\1" "\1\1\1\1\1\0\1\1\1\1\1\1\0\0\1\1\1\1" "\0\0\0\0\0\0\1\1\0\0\1\1\1\1\0\0\0\1" "\1\1\1\0\0\0\1\1\0\0\0\0\0\1\1\1\1\0" "\0\0\1\1\1\1\0\0\0\1\1\1\1\0\0\0\0\1" "\1\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0" "\1\1\0\0\0\0\0\0\0\1\1\0\0\0\0\1\1\1" "\1\0\0\1\1\0\0\1\1\0\1\1\1\1\1\0\0\0" "\1\1\1\1\0\0\1\1\1\1\1\0\0\1\1\1\1\1" "\1\0\1\1\0\0\0\0\0\0\1\1\1\1\1\0\1\1" "\0\0\1\1\0\1\1\1\1\1\1\0\0\1\1\1\1\0" "\0\1\1\0\0\0\1\0\1\1\1\1\1\1\0\1\1\0" "\0\1\1\0\1\1\0\0\1\1\0\0\1\1\1\1\0\0" "\1\1\0\0\0\0\0\0\1\1\1\1\0\0\1\1\0\0" "\0\1\0\0\1\1\1\1\0\0\0\0\1\1\0\0\0\0" "\1\1\1\1\0\0\0\0\1\1\0\0\0\1\0\0\0\0" "\1\0\1\0\0\0\0\1\0\0\0\1\1\0\0\0\1\1" "\1\1\1\1\0\0\1\1\1\1\0\0\0\0\0\0\1\1" "\0\0\1\1\1\1\0\0\0\0\0\0\0\0\0\1\1\1" "\1\1\1\0\0\0\0\0\0\0\0\0\1\1\1\1\1\0" "\1\1\1\1\1\0\0\0\1\1\1\1\0\0\0\1\1\1" "\1\1\0\0\1\1\1\1\0\0\0\1\1\0\0\0\0\0" "\1\1\1\1\0\0\1\1\0\0\1\1\0\1\1\1\1\1" "\1\0\0\0\0\0\1\1\0\1\1\0\0\1\1\0\1\1" "\1\1\1\1\0\1\1\0\0\1\1\0\1\1\0\0\1\1" "\0\0\1\1\1\1\0\0\1\1\0\0\0\0\0\0\0\0" "\0\1\1\0\1\1\0\0\0\0\0\0\1\1\1\1\0\0" "\0\0\1\1\1\0\0\0\1\1\1\1\1\0\0\0\1\1" "\0\0\0\0\1\0\0\1\0\0\1\1\0\0\1\1\0\0" "\0\0\0\1\1\0\1\1\1\1\1\1\0\0\0\1\1\1" "\0\0\0\0\1\1\0\0\0\0\1\1\1\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0" "\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1" "\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1" "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\1\1\1\1\1\1\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\1\1\0\0\1\1\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\1\1\0\0\1\1\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0" "\0\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\1\1\0\0\1\1\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1\1\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1" "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\1\1\0\0\0\0\0\0\0\0\0\1\1\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1\1\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0" }; gngb-20060309/src/video_yuv.c0000644000175000017500000000332307643033301014322 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "cpu.h" #include "emu.h" #include "vram.h" #include "video_yuv.h" #include "memory.h" #include "message.h" void init_message_yuv(void) { } void init_rgb2yuv_table(void) { Uint32 i; Uint8 y,u,v,r,g,b; for(i=0;i<=65535;i++) { r=((i&0xF800)>>11)<<3; g=((i&0x7E0)>>5)<<2; b=(i&0x1F)<<3; y = (0.257 * r) + (0.504 * g) + (0.098 * b) + 16; u = (0.439 * r) - (0.368 * g) - (0.071 * b) + 128; v =-(0.148 * r) - (0.291 * g) + (0.439 * b) + 128; rgb2yuv[i].y=(y<<8)|y; rgb2yuv[i].u=u; rgb2yuv[i].v=v; #ifndef WORDS_BIGENDIAN rgb2yuv[i].yuy2=(u<<24)|(y<<16)|(v<<8)|y; #else rgb2yuv[i].yuy2=(y<<24)|(v<<16)|(y<<8)|u; #endif } } void reinit_video_yuv(void){ gb_screen=SDL_SetVideoMode(conf.res_w,conf.res_h,BIT_PER_PIXEL,yuv_flag); ov_rect.x=0; ov_rect.y=0; ov_rect.w=conf.res_w; ov_rect.h=conf.res_h; } gngb-20060309/src/video_yuv.h0000644000175000017500000000222607643033301014330 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _VIDEO_YUV_H_ #define _VIDEO_YUV_H_ #include "global.h" SDL_Overlay *overlay; SDL_Rect ov_rect; Uint32 yuv_flag; struct yuv{ Uint16 y; Uint8 u; Uint8 v; Uint32 yuy2; }rgb2yuv[65536]; void init_message_yuv(void); void init_rgb2yuv_table(void); void blit_screen_yuv(void); void reinit_video_yuv(void); #endif gngb-20060309/src/main.c0000644000175000017500000000405007703567734013256 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include #ifdef HAVE_GETOPT_LONG #include #else #include "getopt.h" #endif #include "global.h" #include "emu.h" #include "memory.h" #include "cpu.h" #include "rom.h" #include "vram.h" #include "interrupt.h" #include "serial.h" #include "frame_skip.h" #include "emu.h" #include "sgb.h" //#include "optargs.h" #include "sound.h" #include "save.h" extern SDL_Joystick *sdl_joy; void exit_gngb(void) { if (rom_page) free_mem_page(rom_page,nb_rom_page); if (ram_page) free_mem_page(ram_page,nb_ram_page); if (vram_page) free_mem_page(vram_page,nb_vram_page); if (wram_page) free_mem_page(wram_page,nb_wram_page); if (conf.sound) close_sound(); if (conf.serial_on) gbserial_close(); } int main(int argc,char *argv[]) { setup_default_conf(); open_conf(); check_option(argc,argv); if(optind >= argc) print_help(); if (open_rom(argv[optind])) { fprintf(stderr,"Error while trying to read file %s \n",argv[optind]); exit(1); } emu_init(); cpu_run(); if (rom_type&BATTERY) { save_ram(); if (rom_type&TIMER) save_rom_timer(); } exit_gngb(); return 0; } gngb-20060309/src/menu.c0000644000175000017500000003141710001431753013255 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include "emu.h" #include "menu.h" #include "message.h" #include "vram.h" #include "video_std.h" #include "rom.h" #include "sound.h" #include "message.h" #include "menu_image.h" #include "save.h" #define MAX_ITEM 6 #define MENUX 7 #define MENUY 7 #define SHADOW_IN 0 #define SHADOW_OUT 1 #define SHADOW_ETCHED_IN 2 #define SHADOW_ETCHED_OUT 3 #define SHADOW_NONE 4 int stop_all=0; Uint8 radio_group[256]; SDL_Color buttonpal[]={{255,255,255},{214,214,214},{150,150,150},{0,0,0},{195,195,195}}; SDL_Surface *radio_on,*radio_off,*toggle_on,*toggle_off,*arrow_up,*arrow_down; /* note on action function: if it return 1, the current menu is closed if it's 2, all menu are closed otherwise, it stays open */ int action_save_state(MENU_ITEM *self) { int i=(int)self->user_data; save_state(NULL,i); return 2; } int action_load_state(MENU_ITEM *self) { int i=(int)self->user_data; load_state(NULL,i); return 2; } void menu_draw_state(MENU_ITEM *self,int menu_pos) { int i=(int)self->user_data; SDL_Surface *bmp; SDL_Rect b; b.x=94; b.y=78; b.w=55; b.h=50; bmp=get_surface_of_save_state(i); if(bmp) { SDL_FillRect(back,&b,0); b.x++;b.y++; SDL_BlitSurface(bmp,NULL,back,&b); } } int action_loop_menu(MENU_ITEM *self) { MENU *m=(MENU*)self->user_data; loop_menu(m); return 0; } int toggle_fullscreen(MENU_ITEM *self) { switch_fullscreen(); return 2; } int toggle_filter(MENU_ITEM *self) { if (conf.gb_type&COLOR_GAMEBOY) { conf.color_filter^=1; GenFilter(); update_all_pal(); } return 2; } /* draw a preview of a pal */ void menu_draw_pal(MENU_ITEM *self,int menu_pos) { SDL_Rect b; int i; int pal=(int)self->user_data; b.x=100; b.y=MENUY+menu_pos*hl+3; b.w=22; b.h=7; SDL_FillRect(back,&b,COL32_TO_16(0x000000)); b.w=5; b.h=5; b.y+=1; for(i=0;i<4;i++) { b.x=101+i*5; SDL_FillRect(back,&b,COL32_TO_16(conf.pal[pal][3-i])); } } int action_setpal(MENU_ITEM *self) { int p=(int)self->user_data; gb_set_pal(p); return 2; } int action_reset(MENU_ITEM *self) { emu_reset(); return 2; } int toggle_autofskip(MENU_ITEM *self) { conf.autoframeskip^=1; return 2; } int toggle_sound(MENU_ITEM *self) { conf.sound^=1; if (conf.sound) gbsound_init(); else close_sound(); return 2; } int toggle_sleepidle(MENU_ITEM *self) { conf.sleep_idle^=1; return 2; } int toggle_fps(MENU_ITEM *self) { conf.show_fps^=1; if (!conf.show_fps) unset_info(); else set_info("fps:.."); return 2; } int action_set_filter(MENU_ITEM *self) { int p=(int)self->user_data; set_filter(p); return 2; } MENU save_state_menu={ " Save state ", NULL, 0,0,0,0 }; MENU load_state_menu={ " Load state ", NULL, 0,0,0,0 }; MENU filter_menu={ " Filter ", NULL, 0,0,0,0 }; MENU video_menu={ " Video ", NULL, 0,0,0,0 }; MENU fskip_menu={ " Frame control ", NULL, 0,0,0,0 }; MENU main_menu={ " Main ", NULL, 0,0,0,0 }; MENU *menu_list[]={ &main_menu, &load_state_menu, &save_state_menu, &video_menu, &fskip_menu, NULL }; MENU_ITEM *new_menu_item(char *name,Uint8 type) { MENU_ITEM *t; t=(MENU_ITEM*)malloc(sizeof(MENU_ITEM)); memset(t,0,sizeof(MENU_ITEM)); t->name=strdup(name); t->type=type; t->next=NULL; return t; } void menu_push_back_item(MENU *m,MENU_ITEM *i) { MENU_ITEM *t=m->item; m->size++; m->end=(m->size-1size-1:MAX_ITEM); if (t==NULL) {m->item=i;return;} while(t->next!=NULL) t=t->next; t->next=i; } void draw_v_line(SDL_Surface *s,int x,int y,int l,Uint32 color) { SDL_Rect r; r.x=x; r.y=y; r.w=1; r.h=l; SDL_FillRect(s,&r,color); } void draw_h_line(SDL_Surface *s,int x,int y,int l,Uint32 color) { SDL_Rect r; r.x=x; r.y=y; r.w=l; r.h=1; SDL_FillRect(s,&r,color); } void draw_border(SDL_Surface *s,int type,SDL_Rect *r) { SDL_FillRect(s,r,COL32_TO_16(0xd6d6d6)); switch(type) { case SHADOW_OUT: draw_h_line(s,r->x,r->y,r->w,COL32_TO_16(0xFFFFFF)); draw_h_line(s,r->x+1,r->y+1,r->w-1,COL32_TO_16(0xd6d6d6)); draw_h_line(s,r->x,r->y+r->h,r->w+1,COL32_TO_16(0x000000)); draw_h_line(s,r->x+2,r->y+r->h-1,r->w-2,COL32_TO_16(0x969696)); draw_v_line(s,r->x,r->y,r->h,COL32_TO_16(0xFFFFFF)); draw_v_line(s,r->x+1,r->y+1,r->h-1,COL32_TO_16(0xd6d6d6)); draw_v_line(s,r->x+r->w,r->y,r->h,COL32_TO_16(0x000000)); draw_v_line(s,r->x+r->w-1,r->y+1,r->h-1,COL32_TO_16(0x969696)); break; case SHADOW_ETCHED_IN: draw_h_line(s,r->x,r->y,r->w,COL32_TO_16(0x969696)); draw_h_line(s,r->x+1,r->y+1,r->w-1,COL32_TO_16(0xFFFFFF)); draw_h_line(s,r->x,r->y+r->h-1,r->w-1,COL32_TO_16(0x969696)); draw_h_line(s,r->x,r->y+r->h,r->w,COL32_TO_16(0xFFFFFF)); draw_v_line(s,r->x,r->y,r->h-1,COL32_TO_16(0x969696)); draw_v_line(s,r->x+1,r->y+1,r->h-2,COL32_TO_16(0xFFFFFF)); draw_v_line(s,r->x+r->w-1,r->y+2,r->h-2,COL32_TO_16(0x969696)); draw_v_line(s,r->x+r->w,r->y+1,r->h,COL32_TO_16(0xFFFFFF)); break; default: break; } } void display_menu(MENU *m) { SDL_Rect b; int i; MENU_ITEM *item=m->item; b.x=MENUX-2; b.y=MENUY-2; b.w=wl*21+3; b.h=hl*10+3; draw_border(back,SHADOW_OUT,&b); b.x=MENUX; b.y=MENUY+hl*2-hl/2; b.w=wl*21-2; b.h=hl*8; draw_border(back,SHADOW_ETCHED_IN,&b); if (!item) return; for(i=0;ibegin;i++) item=item->next; draw_message(MENUX,MENUY,m->title); for(i=m->begin;i<=m->end;i++) { if (i==m->id) { b.x=MENUX+3; b.y=MENUY+(i-m->begin+2)*hl; b.w=wl*21-8; b.h=hl; SDL_FillRect(back,&b,COL32_TO_16(0xeaeaea)); if (item->draw_info && item->draw_type==DRAW_WHEN_ACTIVE) item->draw_info(item,i-m->begin+2); } if (item->type==TOGGLE) { b.x=135; b.y=MENUY+(i-m->begin+2)*hl+2; SDL_BlitSurface((item->state?toggle_on:toggle_off),NULL,back,&b); } if (item->type==RADIO) { b.x=135; b.y=MENUY+(i-m->begin+2)*hl+2; SDL_BlitSurface((item->radio==radio_group[item->group]?radio_on:radio_off),NULL,back,&b); } draw_message(MENUX+wl,MENUY+(i-m->begin+2)*hl,item->name); if (item->draw_info && item->draw_type==DRAW_ALWAYS) item->draw_info(item,i-m->begin+2); item=item->next; } if (m->end!=m->size-1) { b.x=75; b.y=MENUY+(MAX_ITEM+1)*hl+hl/2+24; b.w=b.h=9; SDL_BlitSurface(arrow_down,NULL,back,&b); } if (m->begin!=0) { b.x=75; b.y=22; SDL_BlitSurface(arrow_up,NULL,back,&b); } } void init_menu(void){ int i=0; MENU_ITEM *item; char tmpbuf[255]; /* init all the icon */ arrow_down=img2surface(img_arrow_down); arrow_up=img2surface(img_arrow_up); radio_on=img2surface(img_radio_on); radio_off=img2surface(img_radio_off); toggle_on=img2surface(img_toggle_on); toggle_off=img2surface(img_toggle_off); SDL_SetColors(arrow_down,buttonpal,0,5); SDL_SetColors(arrow_up,buttonpal,0,5); SDL_SetColors(radio_off,buttonpal,0,5); SDL_SetColors(radio_on,buttonpal,0,5); SDL_SetColors(toggle_off,buttonpal,0,5); SDL_SetColors(toggle_on,buttonpal,0,5); SDL_SetColorKey(radio_off,SDL_SRCCOLORKEY|SDL_RLEACCEL,5); SDL_SetColorKey(radio_on,SDL_SRCCOLORKEY|SDL_RLEACCEL,5); /* Main Menu creation */ /* load state */ item=new_menu_item("Load state ...",ACTION); item->user_data=(void*)&load_state_menu; item->func=action_loop_menu; menu_push_back_item(&main_menu,item); /*save state */ item=new_menu_item("Save state ...",ACTION); item->user_data=(void*)&save_state_menu; item->func=action_loop_menu; menu_push_back_item(&main_menu,item); /*video */ item=new_menu_item("Video ...",ACTION); item->user_data=(void*)&video_menu; item->func=action_loop_menu; menu_push_back_item(&main_menu,item); /*Framskip&co */ item=new_menu_item("Framskip ...",ACTION); item->user_data=(void*)&fskip_menu; item->func=action_loop_menu; menu_push_back_item(&main_menu,item); item=new_menu_item("Sound",TOGGLE); item->state=conf.sound; item->func=toggle_sound; menu_push_back_item(&main_menu,item); item=new_menu_item("Reset",ACTION); item->func=action_reset; menu_push_back_item(&main_menu,item); /* Load state */ for (i=0;i<8;i++) { snprintf(tmpbuf,254,"Slot %d",i+1); item=new_menu_item(tmpbuf,ACTION); item->func=action_load_state; item->draw_info=menu_draw_state; item->draw_type=DRAW_WHEN_ACTIVE; item->user_data=(void*)i; menu_push_back_item(&load_state_menu,item); } /* Save state */ for (i=0;i<8;i++) { snprintf(tmpbuf,254,"Slot %d",i+1); item=new_menu_item(tmpbuf,ACTION); item->func=action_save_state; item->draw_info=menu_draw_state; item->draw_type=DRAW_WHEN_ACTIVE; item->user_data=(void*)i; menu_push_back_item(&save_state_menu,item); } /* Filter Menu */ item=new_menu_item("None",RADIO); item->group=1; item->radio=0; item->user_data=(void*)0; item->func=action_set_filter; item->draw_type=DRAW_ALWAYS; menu_push_back_item(&filter_menu,item); for (i=1;i<=5;i++) { snprintf(tmpbuf,254,"Filter %d",i); item=new_menu_item(tmpbuf,RADIO); item->group=1; item->radio=i; item->user_data=(void*)i; item->func=action_set_filter; item->draw_type=DRAW_ALWAYS; menu_push_back_item(&filter_menu,item); } /* video menu */ item=new_menu_item("Fullscreen",TOGGLE); item->state=conf.fs; item->func=toggle_fullscreen; menu_push_back_item(&video_menu,item); if (conf.gb_type&COLOR_GAMEBOY) { item=new_menu_item("Color filter",TOGGLE); item->state=conf.color_filter; item->func=toggle_filter; menu_push_back_item(&video_menu,item); } else if (conf.gb_type&NORMAL_GAMEBOY) { for (i=0;i<5;i++) { snprintf(tmpbuf,254,"Palette %d",i+1); item=new_menu_item(tmpbuf,RADIO); item->group=0; item->radio=i; item->user_data=(void*)i; item->func=action_setpal; item->draw_type=DRAW_ALWAYS; item->draw_info=menu_draw_pal; menu_push_back_item(&video_menu,item); } } item=new_menu_item("Filter ...",ACTION); item->user_data=(void*)&filter_menu; item->func=action_loop_menu; menu_push_back_item(&video_menu,item); /* frameskip menu */ item=new_menu_item("Auto frameskip",TOGGLE); item->state=conf.autoframeskip; item->func=toggle_autofskip; menu_push_back_item(&fskip_menu,item); item=new_menu_item("Sleep idle",TOGGLE); item->state=conf.sleep_idle; item->func=toggle_sleepidle; menu_push_back_item(&fskip_menu,item); item=new_menu_item("Show FPS",TOGGLE); item->state=conf.show_fps; item->func=toggle_fps; menu_push_back_item(&fskip_menu,item); } void loop_menu(MENU *m) { SDL_Event event; static int init=1; int done=0,i; MENU_ITEM *item; stop_all=0; if (init) { init_menu(); init=0; } current_menu=m; SDL_SetColorKey(fontbuf,SDL_SRCCOLORKEY|SDL_RLEACCEL,0); while(!done && !stop_all) { blit_screen(); SDL_WaitEvent(&event); switch (event.type) { #if defined(SDL_YUV) || defined(SDL_GL) case SDL_VIDEORESIZE: if (conf.yuv || conf.gl) { conf.res_w=event.resize.w; conf.res_h=event.resize.h; reinit_vram(); blit_screen(); } break; #endif case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_ESCAPE: done=1; break; case SDLK_UP: if (m->id>0) m->id--; if (m->idbegin) { m->begin--; m->end--; } break; case SDLK_DOWN: if (m->idsize-1) m->id++; if (m->id>m->end) { m->end++; m->begin++; } break; case SDLK_RETURN: item=m->item; for(i=0;iid;i++) item=item->next; if (item->type==TOGGLE) item->state^=1; if (item->type==RADIO) radio_group[item->group]=item->radio; if (item->func) { done=item->func(item); if (done==2) stop_all=1; current_menu=m; /* if func call loop_menu, current_menu is trashed */ } break; default: break; } } } current_menu=NULL; } gngb-20060309/src/menu.h0000644000175000017500000000303407643033301013261 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _MENU_H_ #define _MENU_H_ #include #include typedef struct MENU_ITEM{ char *name; int (*func)(struct MENU_ITEM *self); void (*draw_info)(struct MENU_ITEM *self,int menu_pos); Uint8 type; void *user_data; Uint8 state; /* on/off */ Uint8 group; /* for radio_button */ Uint8 radio; /* the radio_buuton place in the group */ Uint8 draw_type; struct MENU_ITEM *next; }MENU_ITEM; typedef struct MENU{ char *title; MENU_ITEM *item; int size,begin,end,id; }MENU; #define ACTION 0 #define TOGGLE 1 #define RADIO 2 #define DRAW_ALWAYS 0 #define DRAW_WHEN_ACTIVE 1 extern MENU main_menu; MENU *current_menu; void loop_menu(MENU *m); void display_menu(MENU *m); #endif gngb-20060309/src/save.c0000644000175000017500000004452307643033301013256 0ustar josejose#include "emu.h" #include "fileio.h" #include "rom.h" #include "memory.h" #include "vram.h" #include "interrupt.h" #include "cpu.h" #define FILENAME_LEN 1024 static SDL_Surface *savestate_bmp=NULL; void get_filename_ext(char *f,char *ext) { /* char *a=getenv("HOME");*/ char buf[8]; char *a=getenv("HOME"); if(a==NULL) { buf[0] = '.'; buf[1] = 0; a = buf; } f[0]=0; strcat(f,a); strcat(f,"/.gngb/"); check_dir(f); strcat(f,rom_name); strcat(f,ext); } char *get_name_without_ext(char *name) { char *a; int lg=strlen(name); int l,r,i; l=lg; #ifndef GNGB_WIN32 while(l>0 && name[l-1]!='/') l--; #else while(l>0 && (name[l-1]!='\\')) l--; #endif r=l; while(r<=lg && name[r-1]!='.') r++; a=(char *)malloc(sizeof(char)*(5+(r-l))); i=0; while(lreg[i]); fprintf(stream,"%ld",(long)time(NULL)); fclose(stream); return 0; } int load_rom_timer(void) { char filename[FILENAME_LEN]; FILE *stream; int i; long dt; get_filename_ext(filename,".rt"); if (!(stream=fopen(filename,"rt"))) { fprintf(stderr,"Error while trying to read file %s \n",filename); return 1; } /* FIXME : must adjust the time still last time */ for(i=0;i<5;i++) { int t; fscanf(stream,"%02x",&t); rom_timer->reg[i]=(Uint8)t; } fscanf(stream,"%ld",&dt); { int h,m,s,d,dd; dt=time(NULL)-dt; s=(dt%60); dt/=60; rom_timer->reg[0]+=s; if (rom_timer->reg[0]>=60) { rom_timer->reg[0]-=60; rom_timer->reg[1]++; } m=(dt%60); dt/=60; rom_timer->reg[1]+=m; if (rom_timer->reg[1]>=60) { rom_timer->reg[1]-=60; rom_timer->reg[2]++; } h=(dt%24); dt/=24; rom_timer->reg[2]+=h; if (rom_timer->reg[2]>=24) { rom_timer->reg[2]-=24; rom_timer->reg[3]++; if (!rom_timer->reg[3]) dt++; } d=dt; dd=((rom_timer->reg[5]&0x01)<<9)|rom_timer->reg[4]; dd+=dt; if (dd>=365) { dd=0; rom_timer->reg[5]|=0x80; // set carry } rom_timer->reg[4]=dd&0xff; rom_timer->reg[5]=(rom_timer->reg[5]&0xfe)|((dd&0x100)>>9); } fclose(stream); return 0; } /* State Load/Save */ typedef enum { CPU_SECTION, LCD_SECTION, PAL_SECTION, TIMER_SECTION, DMA_SECTION, RT_SECTION, PAD_MOVIE_SECTION, MAX_SECTION }SECTION_TYPE; // Save & Load function int save_load_cpu_reg(GNGB_FILE * stream,char op); int save_load_cpu_flag(GNGB_FILE * stream,char op); int save_load_lcd_cycles(GNGB_FILE * stream,char op); int save_load_lcd_info(GNGB_FILE * stream,char op); int save_load_pal(GNGB_FILE * stream,char op); int save_load_timer(GNGB_FILE * stream,char op); int save_load_dma(GNGB_FILE * stream,char op); int save_load_rt_reg(GNGB_FILE * stream,char op); int save_load_rt_info(GNGB_FILE * stream,char op); int save_load_pad_movie(GNGB_FILE * stream,char op); int get_pad_movie_section_size(void); struct sub_section { Sint8 id; Sint16 size; int (*get_size)(void); int (*save_load_function)(GNGB_FILE * stream,char op); }; struct sub_section cpu_sub_section[]={ {0,6*2,NULL,save_load_cpu_reg}, {1,4,NULL,save_load_cpu_flag}, {-1,-1,NULL,NULL}}; struct sub_section lcd_sub_section[]={ {0,3*2+4+1,NULL,save_load_lcd_cycles}, {1,3,NULL,save_load_lcd_info}, {-1,-1,NULL,NULL}}; struct sub_section pal_sub_section[]={ {0,4*2*8*4+2*4+4,NULL,save_load_pal}, {-1,-1,NULL,NULL}}; struct sub_section timer_sub_section[]={ {0,4+2,NULL,save_load_timer}, {-1,-1,NULL,NULL}}; struct sub_section dma_sub_section[]={ {0,1+3*2+4,NULL,save_load_dma}, {-1,-1,NULL,NULL}}; struct sub_section rt_sub_section[]={ {0,5,NULL,save_load_rt_reg}, {1,4,NULL,save_load_rt_info}, {-1,-1,NULL,NULL}}; struct sub_section pad_movie_section[]={ {0,-1,get_pad_movie_section_size,save_load_pad_movie}, {-1,-1,NULL,NULL}}; struct section { Sint8 id; struct sub_section *ss; } tab_section[]={ {CPU_SECTION,cpu_sub_section}, {LCD_SECTION,lcd_sub_section}, {PAL_SECTION,pal_sub_section}, {TIMER_SECTION,timer_sub_section}, {DMA_SECTION,dma_sub_section}, {RT_SECTION,rt_sub_section}, {PAD_MOVIE_SECTION,pad_movie_section}, {-1,NULL}}; int save_load_cpu_reg(GNGB_FILE * stream,char op) { if (!op) { // write gngb_file_write(&gbcpu->af.w,sizeof(Uint16),1,stream); gngb_file_write(&gbcpu->bc.w,sizeof(Uint16),1,stream); gngb_file_write(&gbcpu->de.w,sizeof(Uint16),1,stream); gngb_file_write(&gbcpu->hl.w,sizeof(Uint16),1,stream); gngb_file_write(&gbcpu->sp.w,sizeof(Uint16),1,stream); gngb_file_write(&gbcpu->pc.w,sizeof(Uint16),1,stream); } else { // read gngb_file_read(&gbcpu->af.w,sizeof(Uint16),1,stream); gngb_file_read(&gbcpu->bc.w,sizeof(Uint16),1,stream); gngb_file_read(&gbcpu->de.w,sizeof(Uint16),1,stream); gngb_file_read(&gbcpu->hl.w,sizeof(Uint16),1,stream); gngb_file_read(&gbcpu->sp.w,sizeof(Uint16),1,stream); gngb_file_read(&gbcpu->pc.w,sizeof(Uint16),1,stream); } return 0; } int save_load_cpu_flag(GNGB_FILE * stream,char op) { if (!op) { // write gngb_file_write(&gbcpu->int_flag,sizeof(Uint8),1,stream); gngb_file_write(&gbcpu->ei_flag,sizeof(Uint8),1,stream); gngb_file_write(&gbcpu->state,sizeof(Uint8),1,stream); gngb_file_write(&gbcpu->mode,sizeof(Uint8),1,stream); } else { // read gngb_file_read(&gbcpu->int_flag,sizeof(Uint8),1,stream); gngb_file_read(&gbcpu->ei_flag,sizeof(Uint8),1,stream); gngb_file_read(&gbcpu->state,sizeof(Uint8),1,stream); gngb_file_read(&gbcpu->mode,sizeof(Uint8),1,stream); } return 0; } int save_load_lcd_cycles(GNGB_FILE * stream,char op) { if (!op) { // write gngb_file_write(&gblcdc->cycle,sizeof(Sint16),1,stream); gngb_file_write(&gblcdc->mode1cycle,sizeof(Uint16),1,stream); gngb_file_write(&gblcdc->mode2cycle,sizeof(Uint16),1,stream); gngb_file_write(&gblcdc->vblank_cycle,sizeof(Uint32),1,stream); gngb_file_write(&gblcdc->timing,sizeof(Uint8),1,stream); } else { // read gngb_file_read(&gblcdc->cycle,sizeof(Sint16),1,stream); gngb_file_read(&gblcdc->mode1cycle,sizeof(Uint16),1,stream); gngb_file_read(&gblcdc->mode2cycle,sizeof(Uint16),1,stream); gngb_file_read(&gblcdc->vblank_cycle,sizeof(Uint32),1,stream); gngb_file_read(&gblcdc->timing,sizeof(Uint8),1,stream); } return 0; } int save_load_lcd_info(GNGB_FILE * stream,char op) { if (!op) { // write gngb_file_write(&gblcdc->mode,sizeof(Uint8),1,stream); gngb_file_write(&gblcdc->nb_spr,sizeof(Uint8),1,stream); gngb_file_write(&gblcdc->inc_line,sizeof(Uint8),1,stream); } else { // read gngb_file_read(&gblcdc->mode,sizeof(Uint8),1,stream); gngb_file_read(&gblcdc->nb_spr,sizeof(Uint8),1,stream); gngb_file_read(&gblcdc->inc_line,sizeof(Uint8),1,stream); } return 0; } int save_load_pal(GNGB_FILE * stream,char op) { if (!op) { // write gngb_file_write(pal_col_bck_gb,sizeof(Uint16),8*4,stream); gngb_file_write(pal_col_obj_gb,sizeof(Uint16),8*4,stream); gngb_file_write(pal_col_bck,sizeof(Uint16),8*4,stream); gngb_file_write(pal_col_obj,sizeof(Uint16),8*4,stream); gngb_file_write(pal_bck,sizeof(Uint8),4,stream); gngb_file_write(pal_obj,sizeof(Uint8),2*4,stream); } else { // read gngb_file_read(pal_col_bck_gb,sizeof(Uint16),8*4,stream); gngb_file_read(pal_col_obj_gb,sizeof(Uint16),8*4,stream); gngb_file_read(pal_col_bck,sizeof(Uint16),8*4,stream); gngb_file_read(pal_col_obj,sizeof(Uint16),8*4,stream); gngb_file_read(pal_bck,sizeof(Uint8),4,stream); gngb_file_read(pal_obj,sizeof(Uint8),2*4,stream); } return 0; } int save_load_timer(GNGB_FILE * stream,char op) { if (!op) { // write gngb_file_write(&gbtimer->clk_inc,sizeof(Uint16),1,stream); gngb_file_write(&gbtimer->cycle,sizeof(Uint32),1,stream); } else { // read gngb_file_read(&gbtimer->clk_inc,sizeof(Uint16),1,stream); gngb_file_read(&gbtimer->cycle,sizeof(Uint32),1,stream); } return 0; } int save_load_dma(GNGB_FILE * stream,char op) { if (!op) { // write gngb_file_write(&dma_info.type,sizeof(Uint8),1,stream); gngb_file_write(&dma_info.src,sizeof(Uint16),1,stream); gngb_file_write(&dma_info.dest,sizeof(Uint16),1,stream); gngb_file_write(&dma_info.lg,sizeof(Uint16),1,stream); gngb_file_write(&dma_info.gdma_cycle,sizeof(Uint32),1,stream); } else { // read gngb_file_read(&dma_info.type,sizeof(Uint8),1,stream); gngb_file_read(&dma_info.src,sizeof(Uint16),1,stream); gngb_file_read(&dma_info.dest,sizeof(Uint16),1,stream); gngb_file_read(&dma_info.lg,sizeof(Uint16),1,stream); gngb_file_read(&dma_info.gdma_cycle,sizeof(Uint32),1,stream); } return 0; } int save_load_rt_reg(GNGB_FILE * stream,char op) { int t; if (!op) { // write for(t=0;t<5;t++) gngb_file_write(&rom_timer->reg[t],sizeof(Uint8),1,stream); } else { // read for(t=0;t<5;t++) gngb_file_read(&rom_timer->reg[t],sizeof(Uint8),1,stream); } return 0; } int save_load_rt_info(GNGB_FILE * stream,char op) { if (!op) { // write gngb_file_write(&rom_timer->cycle,sizeof(Uint16),1,stream); gngb_file_write(&rom_timer->reg_sel,sizeof(Uint8),1,stream); gngb_file_write(&rom_timer->latch,sizeof(Uint8),1,stream); } else { // read gngb_file_read(&rom_timer->cycle,sizeof(Uint16),1,stream); gngb_file_read(&rom_timer->reg_sel,sizeof(Uint8),1,stream); gngb_file_read(&rom_timer->latch,sizeof(Uint8),1,stream); } return 0; } int save_load_pad_movie(GNGB_FILE * stream,char op) { if (!op) { /* Write */ PAD_SAVE *p=gngb_movie.first_pad; gngb_file_write(&key_cycle,sizeof(Uint32),1,gngb_movie.stream); gngb_file_write(&gngb_movie.len,sizeof(Uint32),1,gngb_movie.stream); while(p) { gngb_file_write(&p->pad,sizeof(Uint8),1,gngb_movie.stream); p=p->next; } } else { /* Read */ int i; Uint32 len; Uint8 pad; gngb_movie.len=0; gngb_file_read(&key_cycle,sizeof(Uint32),1,gngb_movie.stream); gngb_file_read(&len,sizeof(Uint32),1,gngb_movie.stream); for(i=0;iss[m].id!=-1;m++); //while(gngb_file_tell(stream)0) { gngb_file_read(&t,sizeof(Uint8),1,stream); if (tss[t].save_load_function(stream,1); else break; printf("Size %d\n",size); size-=(s->ss[t].size+1); } printf("Size %d\n",size); //if (gngb_file_tell(stream)!=end) return -1; // if ((Sint16)size<0) return -1; return 0; } int save_section(GNGB_FILE * stream,struct section *s) { Uint16 size=0; int i; for(i=0;s->ss[i].id!=-1;i++,size++) { if (s->ss[i].size!=-1) size+=s->ss[i].size; else size+=s->ss[i].get_size(); } gngb_file_write(&s->id,sizeof(Sint8),1,stream); gngb_file_write(&size,sizeof(Uint16),1,stream); for(i=0;s->ss[i].id!=-1;i++/*,size++*/) { gngb_file_write(&s->ss[i].id,sizeof(Uint8),1,stream); s->ss[i].save_load_function(stream,0); } return 0; } SDL_Surface* get_surface_of_save_state(int n) { char filename[FILENAME_LEN]; char t[8]; if (savestate_bmp!=NULL) SDL_FreeSurface(savestate_bmp); get_bmp_ext_nb(t,n); get_filename_ext(filename,t); savestate_bmp=SDL_LoadBMP(filename); return savestate_bmp; } void save_state_file(GNGB_FILE * stream) { int i; /* We write all the bank and the active page */ for(i=0;i=MAX_SECTION) || (load_section(stream,&tab_section[section_id],size)<0)) { printf("Unknow Section %d\n",section_id); // gngb_file_seek(stream,last,SEEK_SET); return 1; } } printf("Fin\n"); key_cycle=0; return 0; } int load_state(char *name,int n) { GNGB_FILE * stream; int i; char filename[FILENAME_LEN]; char t[5]; Uint8 section_id; Uint16 size; long end,last,begin; if (!name) { get_ext_nb(t,n); get_filename_ext(filename,t); if (!(stream=gngb_file_open(filename,"rb",UNKNOW_FILE_TYPE))) { fprintf(stderr,"Error while trying to read file %s \n",filename); return -1; } } else { if (!(stream=gngb_file_open(name,"rb",UNKNOW_FILE_TYPE))) { fprintf(stderr,"Error while trying to read file %s \n",name); return -1; } } if (load_state_file(stream)) { gngb_file_close(stream); // load_state(-1); fprintf(stderr,"Error while reading file %s \n",filename); return -1; } gngb_file_close(stream); if (conf.sound) update_sound_reg(); return 0; } /* Movie Loas/Save */ /* Movie */ GNGB_MOVIE gngb_movie={NULL,0,NULL}; void begin_save_movie(void) { conf.save_movie=1; get_filename_ext(gngb_movie.name,".mv"); gngb_movie.stream=gngb_file_open(gngb_movie.name,"wb",NORMAL_FILE_TYPE); gngb_movie.len=0; gngb_movie.first_pad=gngb_movie.last_pad=NULL; save_state_file(gngb_movie.stream); } void end_save_movie(void) { PAD_SAVE *p=gngb_movie.first_pad; conf.save_movie=0; save_section(gngb_movie.stream,&tab_section[PAD_MOVIE_SECTION]); gngb_file_close(gngb_movie.stream); } void play_movie(void) { int i,len; Uint8 pad; conf.play_movie=1; get_filename_ext(gngb_movie.name,".mv"); gngb_movie.stream=gngb_file_open(gngb_movie.name,"rb",UNKNOW_FILE_TYPE); gngb_movie.first_pad=gngb_movie.last_pad=NULL; gngb_movie.len=0; load_state_file(gngb_movie.stream); gngb_movie.last_pad=gngb_movie.first_pad; } Uint8 movie_get_next_pad(void) { Uint8 pad; pad=gngb_movie.last_pad->pad; gngb_movie.last_pad=gngb_movie.last_pad->next; if (!gngb_movie.last_pad) conf.play_movie=0; return pad; } void movie_add_pad(Uint8 pad) { PAD_SAVE *p=(PAD_SAVE *)malloc(sizeof(PAD_SAVE)); gngb_movie.len++; p->pad=pad; p->next=NULL; if (!gngb_movie.first_pad) { gngb_movie.first_pad=gngb_movie.last_pad=p; } else { gngb_movie.last_pad->next=p; gngb_movie.last_pad=p; } } /* Config Load/Save */ static Uint8 read_int8(void *data); static Uint8 write_int8(void *date); static Uint8 read_int16(void *data); static Uint8 write_int16(void *data); static Uint8 read_int32(void *data); static Uint8 write_int32(void *data); gngb-20060309/src/save.h0000644000175000017500000000065110001431753013250 0ustar josejose#ifndef SAVE_H #define SAVE_H char *get_name_without_ext(char*); int save_ram(void); int load_ram(void); int save_rom_timer(void); int load_rom_timer(void); SDL_Surface* get_surface_of_save_state(int n); int save_state(char *name,int n); int load_state(char *name,int n); void begin_save_movie(void); void end_save_movie(void); void play_movie(void); void movie_add_pad(Uint8 pad); Uint8 movie_get_next_pad(void); #endif gngb-20060309/src/unzip.c0000644000175000017500000010340107643033301013454 0ustar josejose/* unzip.c -- IO on .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Read unzip.h for more info */ #include #include #include #include "zlib.h" #include "unzip.h" #ifdef STDC # include # include # include #endif #ifdef NO_ERRNO_H extern int errno; #else # include #endif #ifndef local # define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ #if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ !defined(CASESENSITIVITYDEFAULT_NO) #define CASESENSITIVITYDEFAULT_NO #endif #ifndef UNZ_BUFSIZE #define UNZ_BUFSIZE (16384) #endif #ifndef UNZ_MAXFILENAMEINZIP #define UNZ_MAXFILENAMEINZIP (256) #endif #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif #ifndef TRYFREE # define TRYFREE(p) {if (p) free(p);} #endif #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif #ifndef SEEK_SET #define SEEK_SET 0 #endif const char unz_copyright[] = " unzip 0.15 Copyright 1998 Gilles Vollant "; /* unz_file_info_interntal contain internal info about a file in zipfile*/ typedef struct unz_file_info_internal_s { uLong offset_curfile;/* relative offset of local header 4 bytes */ } unz_file_info_internal; /* file_in_zip_read_info_s contain internal information about a file in zipfile, when reading and decompress it */ typedef struct { 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 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)*/ } file_in_zip_read_info_s; /* unz_s contain internal information about the zipfile */ 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*/ 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*/ file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current file if we are decompressing it */ } unz_s; /* =========================================================================== Read a byte from a gz_stream; update next_in and avail_in. Return EOF for end of file. IN assertion: the stream s has been sucessfully opened for reading. */ local int unzlocal_getByte(fin,pi) FILE *fin; int *pi; { unsigned char c; int err = fread(&c, 1, 1, fin); if (err==1) { *pi = (int)c; return UNZ_OK; } else { if (ferror(fin)) return UNZ_ERRNO; else return UNZ_EOF; } } /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ local int unzlocal_getShort (fin,pX) FILE* fin; uLong *pX; { uLong x ; int i; int err; err = unzlocal_getByte(fin,&i); x = (uLong)i; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } local int unzlocal_getLong (fin,pX) FILE* fin; uLong *pX; { uLong x ; int i; int err; err = unzlocal_getByte(fin,&i); x = (uLong)i; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<16; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<24; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } /* My own strcmpi / strcasecmp */ local int strcmpcasenosensitive_internal (fileName1,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; } } #ifdef CASESENSITIVITYDEFAULT_NO #define CASESENSITIVITYDEFAULTVALUE 2 #else #define CASESENSITIVITYDEFAULTVALUE 1 #endif #ifndef STRCMPCASENOSENTIVEFUNCTION #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal #endif /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) const char* fileName1; const char* fileName2; int iCaseSensitivity; { if (iCaseSensitivity==0) iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; if (iCaseSensitivity==1) return strcmp(fileName1,fileName2); return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); } #define BUFREADCOMMENT (0x400) /* Locate the Central directory of a zipfile (at the end, just before the global comment) */ local uLong unzlocal_SearchCentralDir(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; uSizeFile = ftell( fin ); if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; 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)) ? (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); if (fseek(fin,uReadPos,SEEK_SET)!=0) 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 (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. Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ extern unzFile ZEXPORT unzOpen (path) const char *path; { 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) */ int err=UNZ_OK; if (unz_copyright[0]!=' ') return NULL; fin=fopen(path,"rb"); if (fin==NULL) return NULL; central_pos = unzlocal_SearchCentralDir(fin); if (central_pos==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; /* 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; /* 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; 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; /* 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; if ((central_pospfile_in_zip_read!=NULL) unzCloseCurrentFile(file); fclose(s->file); TRYFREE(s); return UNZ_OK; } /* Write info about the ZipFile in the *pglobal_info structure. 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; { unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; *pglobal_info=s->gi; return UNZ_OK; } /* Translate date/time from Dos format to tm_unz (readable more easilty) */ local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) uLong ulDosDate; tm_unz* ptm; { uLong uDate; uDate = (uLong)(ulDosDate>>16); ptm->tm_mday = (uInt)(uDate&0x1f) ; ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; } /* Get Info about the current file in the zipfile, with internal only info */ local int unzlocal_GetCurrentFileInfoInternal OF((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)); local int unzlocal_GetCurrentFileInfoInternal (file, pfile_info, pfile_info_internal, 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; { 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; /* 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_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.flag) != 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; 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.compressed_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_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.disk_num_start) != 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_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 ((err==UNZ_OK) && (extraField!=NULL)) { uLong uSizeRead ; if (file_info.size_file_extrafile,lSeek,SEEK_CUR)==0) 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 ((err==UNZ_OK) && (szComment!=NULL)) { uLong uSizeRead ; if (file_info.size_file_commentfile,lSeek,SEEK_CUR)==0) 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 ((err==UNZ_OK) && (pfile_info!=NULL)) *pfile_info=file_info; if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) *pfile_info_internal=file_info_internal; return err; } /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetCurrentFileInfo (file, pfile_info, 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; { return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, szFileName,fileNameBufferSize, extraField,extraFieldBufferSize, szComment,commentBufferSize); } /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToFirstFile (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; } /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzGoToNextFile (file) unzFile file; { 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; 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; } /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzipStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current 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; { unz_s* s; int err; uLong num_fileSaved; uLong pos_in_central_dirSaved; 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; num_fileSaved = s->num_file; pos_in_central_dirSaved = s->pos_in_central_dir; 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); } s->num_file = num_fileSaved ; s->pos_in_central_dir = pos_in_central_dirSaved ; return err; } /* Read the local header of the current zipfile Check the coherency of the local header and info in the end of central directory about this file store in *piSizeVar the size of extra info in local header (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; { 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; 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 (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x04034b50) err=UNZ_BADZIPFILE; } 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; */ 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 ((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) /* 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 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; *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; *piSizeVar += (uInt)size_extra_field; 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; { 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 (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); 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->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; } 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; 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->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; 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 * return Z_STREAM_END. * 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 = s->cur_file_info.compressed_size ; pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size ; 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; s->pfile_in_zip_read = pfile_in_zip_read_info; return UNZ_OK; } /* Read bytes from the current file. buf contain buffer where data must be copied len the size of buf. return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern int ZEXPORT unzReadCurrentFile (file, buf, 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; 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->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.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) && (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, 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, pfile_in_zip_read_info->file)!=1) 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 = (Bytef*)pfile_in_zip_read_info->read_buffer; 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 < 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) = *(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->stream.total_out += uDoCopy; 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; /* 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 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); if (err==Z_STREAM_END) return (iRead==0) ? UNZ_EOF : iRead; if (err!=Z_OK) break; } } if (err==Z_OK) return iRead; return err; } /* Give the current position in uncompressed data */ extern z_off_t ZEXPORT unztell (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; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; return (z_off_t)pfile_in_zip_read_info->stream.total_out; } /* return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzeof (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; 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; } /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) 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. the return value is the number of bytes copied in buf, or (if <0) the error code */ extern int ZEXPORT unzGetLocalExtrafield (file,buf,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; 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; 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 (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; if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) return UNZ_ERRNO; return (int)read_now; } /* Close the file in zip opened with unzipOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzCloseCurrentFile (file) unzFile file; { 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; 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) { 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); pfile_in_zip_read_info->stream_initialised = 0; TRYFREE(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; return err; } /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ extern int ZEXPORT unzGetGlobalComment (file, szComment, 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; 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 (uReadThis>0) { *szComment='\0'; 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; } gngb-20060309/src/unzip.h0000644000175000017500000002331207643033301013463 0ustar josejose/* unzip.h -- IO for uncompress .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Copyright (C) 1998 Gilles Vollant This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g WinZip, InfoZip tools and compatible. Encryption and multi volume ZipFile (span) are not supported. Old compressions used by old PKZip 1.x are not supported THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE CAN CHANGE IN FUTURE VERSION !! I WAIT FEEDBACK at mail info@winimage.com Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution Condition of use and distribution are the same than zlib : This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* for more info about .ZIP format, see ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip PkWare has also a specification at : ftp://ftp.pkware.com/probdesc.zip */ #ifndef _unz_H #define _unz_H #ifdef __cplusplus extern "C" { #endif #ifndef _ZLIB_H #include "zlib.h" #endif #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ typedef struct TagunzFile__ { int unused; } unzFile__; typedef unzFile__ *unzFile; #else typedef voidp unzFile; #endif #define UNZ_OK (0) #define UNZ_END_OF_LIST_OF_FILE (-100) #define UNZ_ERRNO (Z_ERRNO) #define UNZ_EOF (0) #define UNZ_PARAMERROR (-102) #define UNZ_BADZIPFILE (-103) #define UNZ_INTERNALERROR (-104) #define UNZ_CRCERROR (-105) /* tm_unz contain date/time info */ typedef struct tm_unz_s { uInt tm_sec; /* seconds after the minute - [0,59] */ uInt tm_min; /* minutes after the hour - [0,59] */ uInt tm_hour; /* hours since midnight - [0,23] */ uInt tm_mday; /* day of the month - [1,31] */ uInt tm_mon; /* months since January - [0,11] */ uInt tm_year; /* years - [1980..2044] */ } tm_unz; /* unz_global_info structure contain global data about the ZIPfile These data comes from the end of central dir */ typedef struct unz_global_info_s { uLong number_entry; /* total number of entries in the central dir on this disk */ uLong size_comment; /* size of the global comment of the zipfile */ } unz_global_info; /* unz_file_info contain information about a file in the zipfile */ typedef struct unz_file_info_s { uLong version; /* version made by 2 bytes */ uLong version_needed; /* version needed to extract 2 bytes */ uLong flag; /* general purpose bit flag 2 bytes */ uLong compression_method; /* compression method 2 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ uLong crc; /* crc-32 4 bytes */ uLong compressed_size; /* compressed size 4 bytes */ uLong uncompressed_size; /* uncompressed size 4 bytes */ uLong size_filename; /* filename length 2 bytes */ uLong size_file_extra; /* extra field length 2 bytes */ uLong size_file_comment; /* file comment length 2 bytes */ uLong disk_num_start; /* disk number start 2 bytes */ uLong internal_fa; /* internal file attributes 2 bytes */ uLong external_fa; /* external file attributes 4 bytes */ tm_unz tmu_date; } unz_file_info; extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, const char* fileName2, int iCaseSensitivity)); /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */ extern unzFile ZEXPORT unzOpen OF((const char *path)); /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer "zlib/zlib111.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. */ extern int ZEXPORT unzClose OF((unzFile file)); /* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzOpenCurrentFile (see later), these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, unz_global_info *pglobal_info)); /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalComment OF((unzFile file, char *szComment, uLong uSizeBuf)); /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ /***************************************************************************/ /* Unzip package allow you browse the directory of the zipfile */ extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToNextFile OF((unzFile file)); /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzLocateFile OF((unzFile file, const char *szFileName, int iCaseSensitivity)); /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); /* Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain somes info about the current file if szFileName!=NULL, the filemane string will be copied in szFileName (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField (extraFieldBufferSize is the size of the buffer). This is the Central-header version of the extra field if szComment!=NULL, the comment string of the file will be copied in szComment (commentBufferSize is the size of the buffer) */ /***************************************************************************/ /* for reading the content of the current zipfile, you can open it, read data from it, and close it (you can close it before reading all the file) */ extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); /* Open for reading data the current file in the zipfile. If there is no error, the return value is UNZ_OK. */ extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); /* Close the file in zip opened with unzOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzReadCurrentFile OF((unzFile file, voidp buf, unsigned len)); /* Read bytes from the current file (opened by unzOpenCurrentFile) buf contain buffer where data must be copied len the size of buf. return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern z_off_t ZEXPORT unztell OF((unzFile file)); /* Give the current position in uncompressed data */ extern int ZEXPORT unzeof OF((unzFile file)); /* return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, voidp buf, unsigned len)); /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of bytes copied in buf, or (if <0) the error code */ #ifdef __cplusplus } #endif #endif /* _unz_H */ gngb-20060309/src/vram.c0000644000175000017500000001623207656635750013305 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "vram.h" #include "memory.h" #include "rom.h" #include "interrupt.h" #include "message.h" #include "emu.h" #include "sgb.h" #include "video_std.h" #include "menu.h" #include SDL_Surface *gb_screen=NULL; Uint16 grey[4]; Uint8 pal_bck[4]={0,3,3,3}; Uint8 pal_obj[2][4]={{3,3,3,3},{3,3,3,3}}; Uint16 pal_col_bck_gb[8][4]; Uint16 pal_col_obj_gb[8][4]; Uint16 pal_col_bck[8][4]; Uint16 pal_col_obj[8][4]; Uint16 Filter[32768]; Uint8 back_col[170][170]; Uint8 nb_spr; struct mask_shift tab_ms[8]={ { 0x80,7 }, { 0x40,6 }, { 0x20,5 }, { 0x10,4 }, { 0x08,3 }, { 0x04,2 }, { 0x02,1 }, { 0x01,0 }}; /* Video Mode */ extern VIDEO_MODE video_yuy2; extern VIDEO_MODE video_yv12; extern VIDEO_MODE video_std; extern VIDEO_MODE video_gl; VIDEO_MODE *cur_mode; SDL_Surface *back_save; static SDL_Surface *bmp=NULL; void (*draw_screen)(void); /* take from VGBC (not VGB) */ int GetValue(int min,int max,int v) { return min+(float)(max-min)*(2.0*(v/31.0)-(v/31.0)*(v/31.0)); } void save_gb_screen(void) { SDL_BlitSurface(back,NULL,back_save,NULL); } SDL_Surface *get_mini_screenshot(void) { int i,j; static int div=3; Uint16 *bufd; Uint16 *bufs1; Uint16 *bufs2; Uint16 *bufs3; Uint16 c1,c2,c3; if (!bmp) bmp=SDL_CreateRGBSurface(SDL_SWSURFACE,SCREEN_X/div,SCREEN_Y/div,BIT_PER_PIXEL, 0xf800,0x7e0,0x1f,0x00); bufd=(Uint16*)bmp->pixels; if (!back_save) return NULL; bufs1=(Uint16*)back_save->pixels; bufs2=(Uint16*)back_save->pixels+(back_save->pitch>>1); bufs3=(Uint16*)back_save->pixels+back_save->pitch; for (j=0;jpitch>>1); bufs1+=(back_save->pitch>>1)*div; bufs2+=(back_save->pitch>>1)*div; bufs3+=(back_save->pitch>>1)*div; } return bmp; } void GenFilter(void) { Uint16 r,g,b; Uint16 nr,ng,nb; for (r=0;r<32;r++) { for (g=0;g<32;g++) { for (b=0;b<32;b++) { if (conf.color_filter) { nr=GetValue(GetValue(4,14,g),GetValue(24,29,g),r)-4; ng=GetValue(GetValue(4+GetValue(0,5,r),14+GetValue(0,3,r),b), GetValue(24+GetValue(0,3,r),29+GetValue(0,1,r),b),g)-4; nb=GetValue(GetValue(4+GetValue(0,5,r),14+GetValue(0,3,r),g), GetValue(24+GetValue(0,3,r),29+GetValue(0,1,r),g),b)-4; } else { ng=g; nb=b; nr=r; } Filter[(b<<10)|(g<<5)|r]=(nr<<11)|(ng<<6)|nb; } } } } void update_all_pal(void) { Uint8 p,c; for(p=0;p<8;p++) for(c=0;c<4;c++) { pal_col_bck[p][c]=Filter[pal_col_bck_gb[p][c]&0x7FFF]; pal_col_obj[p][c]=Filter[pal_col_obj_gb[p][c]&0x7FFF]; } } void gb_set_pal(int i) { grey[0]=COL32_TO_16(conf.pal[i][0]); //0xc618; // ffe6ce grey[1]=COL32_TO_16(conf.pal[i][1]); //0x8410; // bfad9a grey[2]=COL32_TO_16(conf.pal[i][2]); //0x4208; // 7f7367 grey[3]=COL32_TO_16(conf.pal[i][3]); //0x0000; // 3f3933 } void init_pallete(void) { gb_set_pal(0); GenFilter(); } /* Reinit the screen after a resize event (For YUV & GL)*/ void reinit_vram(void) { if (cur_mode->reinit) cur_mode->reinit(); } void init_vram(Uint32 flag) { char *mousedrv=getenv("SDL_NOMOUSE"); if (SDL_Init(SDL_INIT_JOYSTICK|SDL_INIT_VIDEO)<0) { printf("Couldn't initialize SDL: %s\n",SDL_GetError()); exit(1); } atexit(SDL_Quit); /* Define the video mode to use */ if (conf.yuv && conf.yuv_type==0) cur_mode=&video_yv12; else if (conf.yuv && conf.yuv_type==1) cur_mode=&video_yuy2; #ifdef SDL_GL else if (conf.gl) cur_mode=&video_gl; #endif else cur_mode=&video_std; SDL_WM_SetCaption("Gngb",NULL); if (mousedrv==NULL) SDL_ShowCursor(0); init_message(); conf.video_flag=flag; cur_mode->init(flag); back=SDL_CreateRGBSurface(SDL_SWSURFACE,SCREEN_X,SCREEN_Y+1,BIT_PER_PIXEL, 0xf800,0x7e0,0x1f,0x00); back_save=SDL_CreateRGBSurface(SDL_SWSURFACE,SCREEN_X,SCREEN_Y,BIT_PER_PIXEL, 0xf800,0x7e0,0x1f,0x00); if (back==NULL) { printf("Couldn't allocate %dx%dx%d SDL_Surface: %s\n", SCREEN_X,SCREEN_Y,BIT_PER_PIXEL,SDL_GetError()); exit(1); } init_pallete(); /* if (conf.gb_type&COLOR_GAMEBOY) draw_screen=cur_mode->draw_col; else if (conf.gb_type&SUPER_GAMEBOY) draw_screen=cur_mode->draw_sgb; else draw_screen=cur_mode->draw_wb; */ if (conf.gb_type&COLOR_GAMEBOY) draw_screen=draw_screen_col_std; else if (conf.gb_type&SUPER_GAMEBOY) draw_screen=draw_screen_sgb_std; else draw_screen=draw_screen_wb_std; //blit_screen=cur_mode->blit; } void blit_screen(void) { update_key(); update_message(); cur_mode->blit(); } void switch_fullscreen(void) { SDL_WM_ToggleFullScreen(gb_screen); conf.fs^=1; } __inline__ Uint8 get_nb_spr(void) { Uint8 *sp=oam_space; Sint16 no_tile,x,y,att; Uint8 sizey; Uint8 i,yoff,xoff; if (!(LCDCCONT&0x02)) return 0; sizey=(LCDCCONT&0x04)?16:8; nb_spr=0; for(i=0;i<40;i++) { y=*sp; x=*(sp+1); no_tile=*(sp+2); att=*(sp+3); sp+=4; y-=16; yoff=CURLINE-y; if ((CURLINE>=y) && (yoff=0 && */((x-8)<160))) { if (x<8) xoff=8-x; else xoff = 0; gb_spr[nb_spr].sizey=sizey; gb_spr[nb_spr].x=x-8; gb_spr[nb_spr].y=y; gb_spr[nb_spr].xoff=xoff; gb_spr[nb_spr].yoff=yoff; gb_spr[nb_spr].xflip=(att&0x20)>>5; gb_spr[nb_spr].yflip=(att&0x40)>>6; gb_spr[nb_spr].pal_col=(att&0x07); if (att&0x10) gb_spr[nb_spr].pal=1; else gb_spr[nb_spr].pal=0; gb_spr[nb_spr].page=(att&0x08)>>3; gb_spr[nb_spr].priority=(att&0x80); if (sizey==16) gb_spr[nb_spr].no_tile=no_tile&0xfe; else gb_spr[nb_spr].no_tile=no_tile; nb_spr++; /* Pas plus de 10 sinon la pause de eur_zld deconne */ if (nb_spr>10) { nb_spr=10; return nb_spr; } } } return nb_spr; } __inline__ void clear_screen(void) { Uint8 i,j; // if (cur_mode->clear_scr) cur_mode->clear_scr(); if (current_menu!=NULL) return; clear_screen_std(); for(i=0;i<170;i++) for(j=0;j<170;j++) back_col[i][j]=0x00; } gngb-20060309/src/vram.h0000644000175000017500000000614107656635774013316 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _VRAM_H #define _VRAM_H #include "global.h" #include #define SCREEN_X 160 #define SCREEN_Y 144 #define BIT_PER_PIXEL 16 #define GET_GB_PIXEL(bit) (((((*tp)&tab_ms[(bit)].mask)>>tab_ms[(bit)].shift))|((((*(tp+1))&tab_ms[(bit)].mask)>>tab_ms[(bit)].shift)<<1)) #define COL32_TO_16(col) ((((col&0xff0000)>>19)<<11)|(((col&0xFF00)>>10)<<5)|((col&0xFF)>>3)) /* blend a single 16 bit pixel at 50% */ #define BLEND16_50(d, s, mask) \ ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff))) /* blend two 16 bit pixels at 50% */ #define BLEND2x16_50(d, s, mask) \ (((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \ + (s & d & (~(mask | mask << 16)))) typedef struct { void (*init)(Uint32 flag); void (*reinit)(void); // void (*draw_col)(void); // void (*draw_wb)(void); // void (*draw_sgb)(void); void (*blit)(void); void (*blit_sgb_mask)(void); // void (*set_pal)(int i); // void (*draw_mes)(int x,int y,char *mes); // void (*clear_scr)(void); }VIDEO_MODE; extern Uint8 back_col[170][170]; struct mask_shift { unsigned char mask; unsigned char shift; }; extern struct mask_shift tab_ms[8]; extern Uint32 video_flag; int scxoff,scyoff; /* shift of the screen */ extern Uint16 grey[4]; extern Uint8 pal_bck[4]; extern Uint8 pal_obj[2][4]; extern Uint16 pal_col_bck_gb[8][4]; // 0BBBBBGGGGGRRRRR extern Uint16 pal_col_obj_gb[8][4]; extern Uint16 pal_col_bck[8][4]; // RRRRRGGGGG1BBBBB avec filtre extern Uint16 pal_col_obj[8][4]; extern Uint16 Filter[32768]; extern SDL_Surface *gb_screen; extern SDL_Surface *back_save; extern VIDEO_MODE *cur_mode; typedef struct { Sint16 x,y; Uint8 xoff,yoff; Uint8 sizey; Uint8 xflip,yflip; Uint8 page,pal_col; Uint16 no_tile; Uint8 pal; Uint8 priority; }GB_SPRITE; GB_SPRITE gb_spr[40]; extern Uint8 nb_spr; Uint8 rb_on; extern void (*draw_screen)(void); SDL_Surface *get_mini_screenshot(void); void save_gb_screen(void); void init_vram(Uint32 flag); void switch_fullscreen(void); void blit_screen(void); void clear_screen(void); void gb_set_pal(int i); __inline__ Uint8 get_nb_spr(void); void reinit_vram(void); void GenFilter(void); void update_all_pal(void); #endif gngb-20060309/src/serial.c0000644000175000017500000001445607710775716013623 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #ifdef HAVE_UNISTD_H #include #endif #ifndef WIN32 #include #include #include #else #include #endif #ifdef HAVE_SYS_TIME_H #include #else #include #endif #include #include #include #include #include "serial.h" #include "interrupt.h" #include "memory.h" #include "emu.h" #define TCPPORT 15781 #ifndef WIN32 #define SOCKET int #endif SDL_Thread *thread; int thread_fun(void *data); SOCKET dest_socket=-1; SOCKET listen_socket=-1; void gngb_closesocket(SOCKET s){ #ifdef WIN32 closesocket(s); #else close(s); #endif } void gbserial_close(void) { if (dest_socket>0) gngb_closesocket(dest_socket); SDL_KillThread(thread); } void gbserial_signal_recv(int signum) { fd_set rfds; struct timeval tv; int retval; tv.tv_sec = 0; tv.tv_usec = 0; FD_ZERO(&rfds); FD_SET(dest_socket, &rfds); retval = select(dest_socket+1, &rfds, NULL, NULL,&tv); if (retval) { gbserial.ready2read=1; printf("Something to read\n"); // read(dest_socket,&gbserial.b,1); return; } gbserial.ready2read=0; return; } void gbserial_init(int server_side,char *servername) { SOCKET s,n; struct sockaddr_in saddr; struct hostent *host; int len; int flags; #ifdef WIN32 int e; WORD ver; WSADATA wsaData; ver = MAKEWORD(2,2); e = WSAStartup(ver,&wsaData); if(e!=0) { fprintf(stderr,"Error while trying to initiialize socket system\n"); exit(1); } #endif serial_cycle_todo=0; gblisten=0; if ((s=socket(AF_INET,SOCK_STREAM,0))<0) { fprintf(stderr,"Error while trying to initilialize socket\n"); exit(1); } len=sizeof(struct sockaddr_in); if (server_side) { memset(&saddr,0,len); saddr.sin_family=AF_INET; saddr.sin_port=htons(TCPPORT); /*n=INADDR_ANY; memcpy(&saddr.sin_addr,&n,sizeof(n));*/ saddr.sin_addr.s_addr=INADDR_ANY; if (bind(s,(struct sockaddr *)&saddr,len)<0) { fprintf(stderr,"Error while trying to bind\n"); gngb_closesocket(s); exit(1); } if (listen(s,1)<0) { fprintf(stderr,"Error while listen on port %i\n",TCPPORT); gngb_closesocket(s); exit(1); } if ((n=accept(s,(struct sockaddr *)&saddr,&len))<0) { gngb_closesocket(s); exit(1); } dest_socket=n; } else { /* client side */ if ((host=gethostbyname(servername))==NULL) { fprintf(stderr,"Error unknown host %s.\n",servername); gngb_closesocket(s); exit(1); } memset(&saddr,0,len); saddr.sin_family=AF_INET; saddr.sin_port=htons(TCPPORT); memcpy(&saddr.sin_addr,host->h_addr_list[0],host->h_length); if (connect(s,(struct sockaddr *)&saddr,len)<0) { gngb_closesocket(s); exit(1); } dest_socket=s; printf("Connection established\n"); } /*#ifndef WIN32 fcntl(dest_socket,F_SETFL,O_NONBLOCK); #else ioctlsocket(dest_socket,FIONBIO,&len); #endif */ // thread=SDL_CreateThread(thread_fun,NULL); gbserial.cycle_todo=0; gbserial.byte_wait=0; gbserial.check=0; gbserial.wait=0; fcntl(dest_socket, F_SETOWN, (int) getpid()); flags = fcntl(dest_socket, F_GETFL); flags |= O_NONBLOCK|O_ASYNC; fcntl(dest_socket,F_SETFL,flags); if ((signal(SIGIO,gbserial_signal_recv))==SIG_ERR) { printf("Heu ya une erreur\n"); } gbserial.ready2read=0; } void gbserial_send(Uint8 b) { #ifndef WIN32 Uint16 d; Uint8 n; /* We send the byte */ write(dest_socket,&b,sizeof(Uint8)); /* Read The return data */ // n=read(dest_socket,&d,sizeof(Uint16)); #else char c[2]; int e; c[0] = b; e = send(dest_socket,c,1,0); #endif } Sint8 gbserial_receive(void) { #ifndef WIN32 Sint8 b; static Uint8 c[1000]; if ((b=read(dest_socket,c,1000))<=0) return -1; else SB=c; return 1; #else char c[1000]; int e; e = recv(dest_socket,c,1000,0); if(e>0) { return c[e-1]; } else { return -1; } #endif } Uint8 gbserial_check2(void) { #ifndef WIN32 Uint8 b; Uint8 c; // printf("Check\n"); SB=0xFF; if ((b=read(dest_socket,&c,1))<=0) return 0; // printf("Check Ok %02x\n",c); if (c!=0xFF) set_interrupt(SERIAL_INT); SB=c; return 1; #else Uint8 c; int e; SB=0xFF; if ((e = recv(dest_socket,&c,1,0))<=0) return 0; SB=c; return 1; #endif } Uint8 gbserial_wait_data(void) { Uint8 b; Uint8 c; if ((b=read(dest_socket,&c,1))<=0) return 0; write(dest_socket,SB,1); set_interrupt(SERIAL_INT); SB=c; return 1; } int thread_fun(void *data) { Sint8 n; while(!conf.gb_done) { if (!gbserial.byte_wait && (n=gbserial_receive())>=0) { gbserial.b=n; gbserial.byte_wait=1; /*if (!(SC&0x01)) send_byte(SB); SB=(Uint8)n; SC&=0x7f; set_interrupt(SERIAL_INT);*/ } } return 0; } /* New GbSerial */ /* gbserial_check: Return 1 if data can be read */ char gbserial_check(void) { fd_set rfds; struct timeval tv; int retval; tv.tv_sec = 0; tv.tv_usec = 0; FD_ZERO(&rfds); FD_SET(dest_socket, &rfds); retval = select(dest_socket+1, &rfds, NULL, NULL,&tv); if (retval) return 1; return 0; } /* Gbserial_read: Read a byte on the serial This is a block function */ Uint8 gbserial_read(void) { Uint8 b; gbserial.ready2read=0; if ((read(dest_socket,&b,2))<=0) return 0xFF; return b; } /* Gbserial_write: Write a byte on the serial c: Command b: data */ void gbserial_write(Uint8 b) { write(dest_socket,&b,1); } gngb-20060309/src/serial.h0000644000175000017500000000240507661211556013607 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef SERIAL_H #define SERIAL_H #include "global.h" struct { Sint16 cycle_todo; Uint16 p; Uint8 b; Uint8 byte_wait; Uint8 check; Uint8 wait; Uint8 ready2read; }gbserial; Sint16 serial_cycle_todo; Sint8 gblisten; void gbserial_init(int server_side,char *servername); void gbserial_close(void); void gbserial_send(Uint8 b); Sint8 gbserial_receive(void); char gbserial_check(void); Uint8 gbserial_wait_data(void); #endif gngb-20060309/src/video_gl.c0000644000175000017500000001130107644604141014103 0ustar josejose#ifdef SDL_GL #include #include #include "global.h" #include "memory.h" #include "vram.h" #include "message.h" #include "tiny_font.h" #include "emu.h" #include "interrupt.h" #include "sgb.h" #include "video_std.h" #include "video_gl.h" #include #include static Uint32 gl_flag; #define FONTBUF_GL_W 128 #define FONTBUF_GL_H 128 GLubyte *gl_buf; int fontgl_texid; extern Uint16 sensor_x,sensor_y; void sgb_init_gl(void) { sgb_tex.bmp=(Uint8 *)malloc(256*256*2); glGenTextures(1,&sgb_tex.id); glBindTexture(GL_TEXTURE_2D,sgb_tex.id); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB5,256,256,0, GL_RGB,GL_UNSIGNED_BYTE,NULL); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); } void reinit_video_gl(void) { gb_screen=SDL_SetVideoMode(conf.res_w,conf.res_h,BIT_PER_PIXEL,gl_flag); glViewport(0,0,conf.res_w,conf.res_h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (conf.gb_type&SUPER_GAMEBOY) glOrtho(0.0,(GLfloat)SGB_WIDTH,(GLfloat)SGB_HEIGHT,0.0,-1.0,1.0); else glOrtho(0.0,(GLfloat)SCREEN_X,(GLfloat)SCREEN_Y,0.0,-1.0,1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); return; } void init_video_gl(Uint32 flag) { gl_flag=SDL_HWSURFACE|flag|SDL_RESIZABLE; gb_screen=SDL_SetVideoMode(conf.res_w,conf.res_h,BIT_PER_PIXEL,gl_flag); if (gb_screen==NULL) { printf("Couldn't set %dx%dx%d video mode: %s\n", SCREEN_X,SCREEN_Y,BIT_PER_PIXEL,SDL_GetError()); exit(1); } glViewport(0,0,conf.res_w,conf.res_h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (conf.gb_type&SUPER_GAMEBOY) glOrtho(0.0,(GLfloat)SGB_WIDTH,(GLfloat)SGB_HEIGHT,0.0,-1.0,1.0); else glOrtho(0.0,(GLfloat)SCREEN_X,(GLfloat)SCREEN_Y,0.0,-200.0,200.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // gl_tex.bmp=(Uint8 *)malloc(256*256*2); glEnable(GL_TEXTURE_2D); glGenTextures(1,&gl_tex.id); glBindTexture(GL_TEXTURE_2D,gl_tex.id); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB5,256,256,0, GL_RGB,GL_UNSIGNED_BYTE,NULL); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); if (conf.gb_type&SUPER_GAMEBOY) { scxoff=48; scyoff=40; sgb_init_gl(); } else { scxoff=0; scyoff=0; } //init_message_gl(); } static void update_gldisp(void) { static GLfloat tu=SCREEN_X/256.0,tv=SCREEN_Y/256.0; glClearColor( 0.0, 0.0, 0.0, 1.0 ); glClear( GL_COLOR_BUFFER_BIT); glEnable(GL_TEXTURE_2D); if (rb_on) { rb_shift++; if (rb_shift>=RB_SIZE) { rb_on=0; rb_shift=0; } } if (conf.gb_type&SUPER_GAMEBOY) { glBindTexture(GL_TEXTURE_2D,sgb_tex.id); glBegin(GL_QUADS); glTexCoord2f(0.0,0.0); glVertex2i(0,0); glTexCoord2f(1.0,0.0); glVertex2i(SGB_WIDTH,0); glTexCoord2f(1.0,SGB_HEIGHT/256.0); glVertex2i(SGB_WIDTH,SGB_HEIGHT); glTexCoord2f(0.0,SGB_HEIGHT/256.0); glVertex2i(0,SGB_HEIGHT); glEnd(); } glBindTexture(GL_TEXTURE_2D,gl_tex.id); if (!sgb_mask) glTexSubImage2D(GL_TEXTURE_2D,0,0,0,SCREEN_X,SCREEN_Y, GL_RGB,GL_UNSIGNED_SHORT_5_6_5,back->pixels); else glTexSubImage2D(GL_TEXTURE_2D,0,0,0,SCREEN_X,SCREEN_Y, GL_RGB,GL_UNSIGNED_SHORT_5_6_5,NULL); glBegin(GL_QUADS); glTexCoord2f(rb_tab[0][rb_shift]/256.0,rb_tab[1][rb_shift]/256.0); glVertex2i(scxoff,scyoff); glTexCoord2f(tu+rb_tab[0][rb_shift]/256.0,rb_tab[1][rb_shift]/256.0); glVertex2i(SCREEN_X+scxoff,scyoff); glTexCoord2f(tu+rb_tab[0][rb_shift]/256.0,tv+rb_tab[1][rb_shift]/256.0); glVertex2i(SCREEN_X+scxoff,SCREEN_Y+scyoff); glTexCoord2f(rb_tab[0][rb_shift]/256.0,tv+rb_tab[1][rb_shift]/256.0); glVertex2i(scxoff,SCREEN_Y+scyoff); glEnd(); glDisable(GL_TEXTURE_2D); SDL_GL_SwapBuffers(); if ((!(LCDCCONT&0x20) || !(LCDCCONT&0x01)) && (conf.gb_type&NORMAL_GAMEBOY)) clear_screen(); } void blit_screen_gl(void) { update_gldisp(); if ((!(LCDCCONT&0x20) || !(LCDCCONT&0x01)) && (conf.gb_type&NORMAL_GAMEBOY)) clear_screen(); } void blit_sgb_mask_gl(void) { glBindTexture(GL_TEXTURE_2D,sgb_tex.id); glTexSubImage2D(GL_TEXTURE_2D,0,0,0,SGB_WIDTH,SGB_HEIGHT, GL_RGB,GL_UNSIGNED_SHORT_5_6_5,sgb_buf->pixels); } VIDEO_MODE video_gl={ init_video_gl, reinit_video_gl, // draw_screen_col_gl, // draw_screen_wb_gl, //draw_screen_sgb_gl, blit_screen_gl, blit_sgb_mask_gl //NULL, //draw_message_gl, //NULL }; #endif gngb-20060309/src/video_gl.h0000644000175000017500000000032107643033301014101 0ustar josejose#ifndef _VIDEO_GL_H_ #define _VIDEO_GL_H_ #ifdef SDL_GL #include typedef struct GLTEX { GLubyte *bmp; GLuint id; }GLTEX; GLTEX gl_tex; GLTEX sgb_tex; void sgb_init_gl(void); #endif #endif gngb-20060309/src/menu_image.h0000644000175000017500000000556307643033301014434 0ustar josejose/* image2c image dump (toggle_on.png) */ static const struct { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ unsigned char pixel_data[10*10]; } img_toggle_on = { 10, 10, 1, { 2,2,2,2,2,2,2,2,2,2, 2,3,3,3,3,3,3,3,3,0, 2,3,1,1,1,1,1,1,1,0, 2,3,1,1,1,1,1,1,1,0, 2,3,1,1,1,1,1,1,1,0, 2,3,1,1,1,1,1,1,1,0, 2,3,1,1,1,1,1,1,1,0, 2,3,1,1,1,1,1,1,1,0, 2,3,1,1,1,1,1,1,1,0, 2,0,0,0,0,0,0,0,0,0 } }; /* image2c image dump (toggle_off.png) */ static const struct { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ unsigned char pixel_data[10*10]; } img_toggle_off = { 10, 10, 1, { 0,0,0,0,0,0,0,0,0,3, 0,1,1,1,1,1,1,1,1,3, 0,1,1,1,1,1,1,1,2,3, 0,1,1,1,1,1,1,1,2,3, 0,1,1,1,1,1,1,1,2,3, 0,1,1,1,1,1,1,1,2,3, 0,1,1,1,1,1,1,1,2,3, 0,1,1,1,1,1,1,1,2,3, 0,1,2,2,2,2,2,2,2,3, 3,3,3,3,3,3,3,3,3,3 } }; /* image2c image dump (radio_on.png) */ static const struct { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ unsigned char pixel_data[11*11]; } img_radio_on = { 11, 11, 1, { 5,5,5,5,5,2,5,5,5,5,5, 5,5,5,5,2,2,2,5,5,5,5, 5,5,5,2,2,3,2,2,5,5,5, 5,5,2,2,3,1,3,2,2,5,5, 5,2,2,3,1,1,1,3,2,2,5, 2,2,3,1,1,1,1,1,3,2,2, 5,0,0,4,1,1,1,4,0,0,5, 5,5,0,0,4,1,4,0,0,5,5, 5,5,5,0,0,4,0,0,5,5,5, 5,5,5,5,0,0,0,5,5,5,5, 5,5,5,5,5,0,5,5,5,5,5 } }; /* image2c image dump (radio_off.png) */ static const struct { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ unsigned char pixel_data[11*11]; } img_radio_off = { 11, 11, 1, { 5,5,5,5,5,0,5,5,5,5,5, 5,5,5,5,0,0,0,5,5,5,5, 5,5,5,0,0,1,0,0,5,5,5, 5,5,0,0,1,1,1,0,0,5,5, 5,0,0,1,1,1,1,1,0,0,5, 0,0,1,1,1,1,1,1,1,0,0, 5,3,2,2,1,1,1,2,2,3,5, 5,5,3,2,2,1,2,2,3,5,5, 5,5,5,3,2,2,2,3,5,5,5, 5,5,5,5,3,2,3,5,5,5,5, 5,5,5,5,5,3,5,5,5,5,5 } }; /* image2c image dump (arrow_down.png) */ static const struct { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ unsigned char pixel_data[9*9]; } img_arrow_down = { 9, 9, 1, { 1,1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,0,2, 0,1,1,1,1,1,1,2,3, 0,1,1,1,1,1,1,2,3, 1,0,1,1,1,1,2,3,1, 1,1,0,1,1,2,3,1,1, 1,1,1,0,1,3,1,1,1, 1,1,1,1,0,1,1,1,1, 1,1,1,1,1,1,1,1,1 } }; static struct { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ unsigned char pixel_data[9*9]; } img_arrow_up = { 9, 9, 1, { 1,1,1,1,1,1,1,1,1, 1,1,1,1,0,1,1,1,1, 1,1,1,0,1,3,1,1,1, 1,1,0,1,1,2,3,1,1, 1,0,1,1,1,1,2,3,1, 0,1,1,1,1,1,1,2,3, 0,1,2,2,2,2,2,2,3, 1,3,3,3,3,3,3,3,2, 1,1,1,1,1,1,1,1,1 } }; gngb-20060309/src/message.c0000644000175000017500000000646507643033301013747 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include "global.h" #include "tiny_font.h" #include "message.h" #include "emu.h" #include "menu.h" #include "video_std.h" SDL_Surface *fontbuf=NULL; //int wl,hl,xm,ym; static int tempo_mes; #define BUF_ALPHA 240 char mes_buf[50]; char info_buf[50]; //extern SDL_Surface *gb_screen; int mx_off,my_off; int info=0; SDL_Color fontpal[]={{214,214,214},{0,0,0}}; //void (*draw_message)(int x,int y,char *mes); static __inline__ void draw_char(SDL_Surface *dest,int x,int y,unsigned char c) { static SDL_Rect font_rect,dest_rect; int indice=c-32; if (c<32 || c>127) return; font_rect.x=indice*wl; font_rect.y=0; font_rect.w=wl; font_rect.h=hl; dest_rect.x=x; dest_rect.y=y; dest_rect.w=wl; dest_rect.h=hl; SDL_BlitSurface(fontbuf,&font_rect,dest,&dest_rect); } void draw_message(int x,int y,char *mes) { int i; for(i=0;i int wl,hl,xm,ym; //extern void (*draw_message)(int x,int y,char *mes); extern SDL_Surface *fontbuf; #define RED_MASK(b) (b==4?0xFF000000:(b==3?0xFF0000:0)) #define GREEN_MASK(b) (b==4?0xFF0000:(b==3?0xFF00:0)) #define BLUE_MASK(b) (b==4?0xFF00:(b==3?0xFF:0)) #define ALPHA_MASK(b) (b==4?0xFF:0) #define img2surface(__a__) SDL_CreateRGBSurfaceFrom((void*)__a__.pixel_data,\ __a__.width,\ __a__.height,\ __a__.bytes_per_pixel*8,\ __a__.width*__a__.bytes_per_pixel,\ RED_MASK(__a__.bytes_per_pixel),\ GREEN_MASK(__a__.bytes_per_pixel),\ BLUE_MASK(__a__.bytes_per_pixel),\ ALPHA_MASK(__a__.bytes_per_pixel)) void init_message(void); void set_message(const char *format,...); void set_info(const char *format,...); void unset_info(void); void update_message(void); void draw_message(int x,int y,char *mes); void restore_message_pal(void); #endif gngb-20060309/src/frame_skip.c0000644000175000017500000000523110437075151014435 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_TIME_H #include #else #include #endif #include #include #include "frame_skip.h" #include "message.h" #include "emu.h" #ifndef uclock_t #define uclock_t Uint32 #endif #define TICKS_PER_SEC 1000000UL #define CPU_FPS 59.7 #define MAX_FRAMESKIP 20 static char init_frame_skip=1; char skip_next_frame=0; #ifdef HAVE_GETTIMEOFDAY static struct timeval init_tv = {0,0}; #endif void reset_frame_skip(void) { #ifdef HAVE_GETTIMEOFDAY init_tv.tv_usec = 0; init_tv.tv_sec = 0; #endif skip_next_frame=0; init_frame_skip=1; } uclock_t get_ticks(void) { #ifdef HAVE_GETTIMEOFDAY struct timeval tv; gettimeofday(&tv, 0); if (init_tv.tv_sec == 0) init_tv = tv; return (tv.tv_sec - init_tv.tv_sec) * TICKS_PER_SEC + tv.tv_usec - init_tv.tv_usec; #else return SDL_GetTicks()*1000; #endif } int frame_skip(int init) { static int f2skip; static uclock_t F=(uclock_t)((double)TICKS_PER_SEC/CPU_FPS); static uclock_t sec=0; static uclock_t rfd; static uclock_t target; static int nbFrame=0; static int skpFrm=0; if (init_frame_skip) { init_frame_skip=0; target=get_ticks(); nbFrame=0; sec=0; return 0; } target+=F; if (f2skip>0) { f2skip--; skpFrm++; return 1; } else skpFrm=0; rfd=get_ticks(); if (conf.autoframeskip) { if (rfdMAX_FRAMESKIP) f2skip=MAX_FRAMESKIP; } } nbFrame++; if (get_ticks()-sec>=TICKS_PER_SEC) { if (conf.show_fps) { set_info("fps:%d",nbFrame); } nbFrame=0; sec=get_ticks(); } return 0; } gngb-20060309/src/frame_skip.h0000644000175000017500000000173107643033301014437 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _FRAME_SKIP_H #define _FRAME_SKIP_H extern char skip_next_frame; void reset_frame_skip(void); int frame_skip(int init); #endif gngb-20060309/src/video_yv12.c0000644000175000017500000000770307656636050014324 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "global.h" #include "memory.h" #include "video_yuv.h" #include "vram.h" #include "video_std.h" #include "sgb.h" #include "message.h" #include "emu.h" #include "interrupt.h" void init_video_yv12(Uint32 flag) { yuv_flag=SDL_HWSURFACE|flag|SDL_RESIZABLE; /* YUV mode are resizable */ /* we need this because YUV may not support down scale */ if (conf.gb_type&SUPER_GAMEBOY) { if (conf.res_wpixels[0]; Uint8 *bufu=(Uint8*)overlay->pixels[1]; Uint8 *bufv=(Uint8*)overlay->pixels[2]; Uint16 *nbufy=(Uint16*)overlay->pixels[0]+(overlay->pitches[0]>>1); Uint16 *t=back->pixels; if (conf.gb_type&SUPER_GAMEBOY) { bufy+=overlay->pitches[0]*40+48; nbufy+=overlay->pitches[0]*40+48; bufu+=overlay->pitches[1]*40+48; bufv+=overlay->pitches[2]*40+48; } if (rb_on) { rumble=2-rumble; t+=rumble; rb_time++; if (rb_time>8) rb_time=rb_on=0; } for(j=0;jpitches[0]; bufy+=overlay->pitches[0]; bufu+=overlay->pitches[1]; bufv+=overlay->pitches[2]; t=&t[i]; } SDL_DisplayYUVOverlay(overlay,&ov_rect); if ((!(LCDCCONT&0x20) || !(LCDCCONT&0x01)) && (conf.gb_type&NORMAL_GAMEBOY)) clear_screen(); } void blit_sgb_mask_yv12(void) { int i,j; Uint16 *bufy=(Uint16*)overlay->pixels[0]; Uint8 *bufu=(Uint8*)overlay->pixels[1]; Uint8 *bufv=(Uint8*)overlay->pixels[2]; Uint16 *nbufy=(Uint16*)overlay->pixels[0]+(overlay->pitches[0]>>1); Uint16 *t=sgb_buf->pixels; for(j=0;jpitches[0]; bufy+=overlay->pitches[0]; bufu+=overlay->pitches[1]; bufv+=overlay->pitches[2]; t=&t[i]; } } VIDEO_MODE video_yv12={ init_video_yv12, reinit_video_yuv, // draw_screen_col_yv12, // draw_screen_wb_yv12, // NULL, blit_screen_yv12, blit_sgb_mask_yv12 // set_pal_yv12, //draw_message_yv12, //NULL }; gngb-20060309/src/video_yuy2.c0000644000175000017500000000646607656636024014441 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "global.h" #include "memory.h" #include "video_yuv.h" #include "vram.h" #include "video_std.h" #include "sgb.h" #include "message.h" #include "emu.h" #include "interrupt.h" void init_video_yuy2(Uint32 flag) { yuv_flag=SDL_HWSURFACE|flag|SDL_RESIZABLE; /* YUV mode are resizable */ /* we need this because YUV may not support down scale */ if (conf.gb_type&SUPER_GAMEBOY) { if (conf.res_wpixels[0]; Uint16 *t=back->pixels; static Uint8 rumble=0; static Uint8 rb_time=0; // printf("%d\n",back->pitch>>1); if (conf.gb_type&SUPER_GAMEBOY) { buf+=(overlay->pitches[0]>>2)*40+48; } if (rb_on) { rumble=2-rumble; t+=rumble; rb_time++; if (rb_time>8) rb_time=rb_on=0; } if (conf.gb_type&SUPER_GAMEBOY) { for(j=0;jpitches[0]>>2; t+=back->pitch>>1; } } else { for(i=0;ipixels[0]; Uint16 *t=sgb_buf->pixels; for(i=0;i #include #include #include "memory.h" #include "emu.h" #include "cpu.h" #include "rom.h" #include "vram.h" #include "interrupt.h" #include "frame_skip.h" #include "sound.h" #include "serial.h" #include "message.h" #include "sgb.h" static Uint8 gb_pad; Uint8 rom_mask; Uint16 nb_rom_page; Uint16 nb_ram_page; Uint16 nb_vram_page; Uint16 nb_wram_page; Uint16 active_rom_page=0; Uint16 active_ram_page=0; Uint16 active_vram_page=0; Uint16 active_wram_page=0; Uint8 **rom_page=NULL; Uint8 **ram_page=NULL; Uint8 **vram_page=NULL; Uint8 **wram_page=NULL; Uint8 oam_space[0xa0]; Uint8 himem[0x160]; Uint8 ram_enable=0; Uint8 mbc1_mem_mode=MBC1_16_8_MEM_MODE; Uint8 mbc1_line=0; Uint8 mbc5_lower=0; Uint8 mbc5_upper=0; Uint8 mbc7_lower=0; Uint8 mbc7_upper=0; Uint16 sensor_x=0x7ff,sensor_y=0x7ff; Uint8 ram_mask; MEM_READ_ENTRY mem_read_tab[0x10]; MEM_WRITE_ENTRY mem_write_tab[0x10]; Sint16 joy_x_min=0;joy_x_max=0;joy_y_min=0;joy_y_max=0; void (*select_rom_page)(Uint16 adr,Uint8 v); void (*select_ram_page)(Uint16 adr,Uint8 v); Uint8 IOMem[256]= {0xCF, 0x00, 0x7E, 0xFF, 0xAD, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x80, 0xBF, 0xF0, 0xFF, 0xBF, 0xFF, 0x3F, 0x00, 0xFF, 0xBF, 0x7F, 0xFF, 0x9F, 0xFF, 0xBF, 0xFF, 0xFF, 0x00, 0x00, 0xBF, 0x77, 0xF3, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFE, 0x0E, 0x7F, 0x00, 0xFF, 0x58, 0xDF, 0x00, 0xEC, 0x00, 0xBF, 0x0c, 0xED, 0x03, 0xF7, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x7E, 0xFF, 0xFE, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xC1, 0x20, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; DMA_INFO dma_info; /* Ram Info: Because some roms use Ram Space to communicate Ram can't always be in direct access */ Uint8 ram_can_direct_access=1; Uint8 (*mem_read_a000_bfff)(Uint16 adr)=NULL; void (*mem_write_a000_bfff)(Uint16 adr,Uint8 v)=NULL; /* Read Function */ Uint8 mbc7_read_a000_bfff(Uint16 adr); Uint8 timer_read_a000_bfff(Uint16 adr); Uint8 mem_read_a000_bfff_default(Uint16 adr); Uint8 mem_read_f000_ffff_default(Uint16 adr); /* Write Function */ void mem_write_0000_1fff_default(Uint16 adr,Uint8 v); void mem_write_2000_3fff_default(Uint16 adr,Uint8 v); void mem_write_4000_5fff_default(Uint16 adr,Uint8 v); void mem_write_6000_7fff_default(Uint16 adr,Uint8 v); void mem_write_a000_bfff_default(Uint16 adr,Uint8 v); void mem_write_f000_ffff_default(Uint16 adr,Uint8 v); void mbc1_write_4000_5fff(Uint16 adr,Uint8 v); void mbc1_write_6000_7fff(Uint16 adr,Uint8 v); void rumble_write_4000_5fff(Uint16 adr,Uint8 v); void timer_write_4000_5fff(Uint16 adr,Uint8 v); void timer_write_6000_7fff(Uint16 adr,Uint8 v); void timer_write_a000_bfff(Uint16 adr,Uint8 v); void mbc7_write_a000_bfff(Uint16 adr,Uint8 v); /* Fast Mem Function */ __inline__ void set_mem_read_direct_access(Uint8 mem_area,Uint8 *buf) { mem_read_tab[mem_area].type=MEM_DIRECT_ACCESS; mem_read_tab[mem_area].b=buf; } __inline__ void set_mem_write_direct_access(Uint8 mem_area,Uint8 *buf) { mem_write_tab[mem_area].type=MEM_DIRECT_ACCESS; mem_write_tab[mem_area].b=buf; } __inline__ void set_mem_read_fun_access(Uint8 mem_area,Uint8 (*fun)(Uint16 adr)) { mem_read_tab[mem_area].type=MEM_FUN_ACCESS; mem_read_tab[mem_area].f=fun; } __inline__ void set_mem_write_fun_access(Uint8 mem_area,void (*fun)(Uint16 adr,Uint8 v)) { mem_write_tab[mem_area].type=MEM_FUN_ACCESS; mem_write_tab[mem_area].f=fun; } __inline__ void set_active_rom_page(Uint16 page) { Uint8 i; active_rom_page=page&rom_mask; for(i=0;i<4;i++) { set_mem_read_direct_access(i,&rom_page[0][i*0x1000]); set_mem_read_direct_access(i+4,&rom_page[active_rom_page][i*0x1000]); } } __inline__ void set_active_vram_page(Uint16 page) { Uint8 i; active_vram_page=page&0x01; for(i=0;i<2;i++) { set_mem_read_direct_access(i+8,&vram_page[active_vram_page][i*0x1000]); set_mem_write_direct_access(i+8,&vram_page[active_vram_page][i*0x1000]); } } __inline__ void set_active_ram_page(Uint16 page) { Uint8 i; active_ram_page=page&ram_mask; if (ram_can_direct_access) { for(i=0;i<2;i++) { set_mem_read_direct_access(i+0x0A,&ram_page[active_ram_page][i*0x1000]); set_mem_write_direct_access(i+0x0A,&ram_page[active_ram_page][i*0x1000]); } } } __inline__ void set_active_wram_page(Uint16 page) { int i; active_wram_page=page&0x07; if (!active_wram_page) active_wram_page=1; set_mem_read_direct_access(0x0C,&wram_page[0][0]); set_mem_read_direct_access(0x0D,&wram_page[active_wram_page][0]); set_mem_read_direct_access(0x0E,&wram_page[0][0]); set_mem_write_direct_access(0x0C,&wram_page[0][0]); set_mem_write_direct_access(0x0D,&wram_page[active_wram_page][0]); set_mem_write_direct_access(0x0E,&wram_page[0][0]); } __inline__ void disable_ram(void) { Uint8 i; for(i=0;i<2;i++) { set_mem_read_fun_access(i+0x0A,mem_read_a000_bfff); set_mem_write_fun_access(i+0x0A,mem_write_a000_bfff); } ram_enable=0; } __inline__ void enable_ram(void) { set_active_ram_page(active_ram_page); ram_enable=1; } void select_default(Uint16 adr,Uint8 v) { // do nothing } void mbc1_select_page(Uint16 adr,Uint8 v) { Uint8 bank=v&rom_mask; if (bank<1) bank=1; set_active_rom_page(bank); } void mbc2_select_page(Uint16 adr,Uint8 v) { Uint8 bank; if (adr==0x2100) { bank=v&rom_mask; if (bank<1) bank=1; set_active_rom_page(bank); } } void mbc3_select_page(Uint16 adr,Uint8 v) { Uint8 bank=v&rom_mask; if (bank<1) bank=1; set_active_rom_page(bank); } void mbc5_select_page(Uint16 adr,Uint8 v) { Uint16 bank; if (adr>=0x2000 && adr<0x3000) mbc5_lower=v; if (adr>=0x3000 && adr<0x4000 && nb_rom_page>=256) { mbc5_upper=v&0x01; } bank=mbc5_lower+((mbc5_upper)?256:0); set_active_rom_page(bank); } void gbmemory_init(void) { //gbmemory_reset(); memset(key,0,256); memset(oam_space,0,0xa0); memcpy(&himem[0x60],IOMem,0xff); DIVID=0x00; TIME_MOD=0x00; TIME_CONTROL=0x00; TIME_COUNTER=0x00; NR10=0x80; NR11=0xbf; NR12=0xf3; NR14=0xbf; NR21=0x3f; NR21=0x00; NR24=0xbf; NR30=0x7f; NR31=0xff; NR32=0x9f; NR33=0xbf; NR41=0xff; NR42=0x00; NR43=0x00; NR44=0xbf; NR50=0x77; NR51=0xf3; /* FIXME: SGB value != */ NR52=0xf1; CMP_LINE=0x00; INT_ENABLE=0x00; dma_info.type=NO_DMA; if (rom_type&MBC1) select_rom_page=mbc1_select_page; else if (rom_type&MBC2) select_rom_page=mbc2_select_page; else if (rom_type&MBC3) select_rom_page=mbc3_select_page; else if (rom_type&MBC5) select_rom_page=mbc5_select_page; else select_rom_page=select_default; gbmemory_reset(); } void gbmemory_reset(void) { int i; memset(key,0,256); memset(oam_space,0,0xa0); memcpy(&himem[0x60],IOMem,0xff); DIVID=0x00; TIME_MOD=0x00; TIME_CONTROL=0x00; TIME_COUNTER=0x00; NR10=0x80; NR11=0xbf; NR12=0xf3; NR14=0xbf; NR21=0x3f; NR21=0x00; NR24=0xbf; NR30=0x7f; NR31=0xff; NR32=0x9f; NR33=0xbf; NR41=0xff; NR42=0x00; NR43=0x00; NR44=0xbf; NR50=0x77; NR51=0xf3; /* FIXME: SGB value != */ NR52=0xf1; /*for(i=0xFF30;i<0xFF3f;i++) { mem_write_ff(i,(i%8)); }*/ LCDCCONT=0x91; CURLINE=0x00; CMP_LINE=0x00; INT_ENABLE=0x00; INT_FLAG=0x00; WRAM_BANK=0x00; VRAM_BANK=0x00; dma_info.type=NO_DMA; active_rom_page=1; active_ram_page=0; active_vram_page=0; active_wram_page=1; ram_enable=0; /* FAST MEM SYSTEM */ /* ROM */ set_mem_write_fun_access(0x00,mem_write_0000_1fff_default); set_mem_write_fun_access(0x01,mem_write_0000_1fff_default); set_mem_write_fun_access(0x02,mem_write_2000_3fff_default); set_mem_write_fun_access(0x03,mem_write_2000_3fff_default); set_mem_write_fun_access(0x04,mem_write_4000_5fff_default); set_mem_write_fun_access(0x05,mem_write_4000_5fff_default); set_mem_write_fun_access(0x06,mem_write_6000_7fff_default); set_mem_write_fun_access(0x07,mem_write_6000_7fff_default); if (rom_type&MBC1) select_rom_page=mbc1_select_page; else if (rom_type&MBC2) select_rom_page=mbc2_select_page; else if (rom_type&MBC3) select_rom_page=mbc3_select_page; else if (rom_type&MBC5) select_rom_page=mbc5_select_page; else select_rom_page=select_default; set_mem_write_fun_access(0x02,select_rom_page); set_mem_write_fun_access(0x03,select_rom_page); for(i=0;i<4;i++) { set_mem_read_direct_access(i,&rom_page[0][i*0x1000]); set_mem_read_direct_access(i+4,&rom_page[active_rom_page][i*0x1000]); } if (rom_type&MBC1) { set_mem_write_fun_access(0x04,mbc1_write_4000_5fff); set_mem_write_fun_access(0x05,mbc1_write_4000_5fff); set_mem_write_fun_access(0x06,mbc1_write_6000_7fff); set_mem_write_fun_access(0x07,mbc1_write_6000_7fff); } if (rom_type&RUMBLE) { set_mem_write_fun_access(0x04,rumble_write_4000_5fff); set_mem_write_fun_access(0x05,rumble_write_4000_5fff); } if (rom_type&TIMER) { set_mem_write_fun_access(0x04,timer_write_4000_5fff); set_mem_write_fun_access(0x05,timer_write_4000_5fff); set_mem_write_fun_access(0x06,timer_write_6000_7fff); set_mem_write_fun_access(0x07,timer_write_6000_7fff); } /* VRAM */ for(i=0;i<2;i++) { set_mem_read_direct_access(i+8,&vram_page[0][i*0x1000]); set_mem_write_direct_access(i+8,&vram_page[0][i*0x1000]); } /* RAM */ if (rom_type&TIMER) { ram_can_direct_access=0; mem_write_a000_bfff=timer_write_a000_bfff; mem_read_a000_bfff=timer_read_a000_bfff; for(i=0;i<2;i++) { set_mem_read_fun_access(i+0x0A,mem_read_a000_bfff); set_mem_write_fun_access(i+0x0A,mem_write_a000_bfff); } } else { ram_can_direct_access=1; mem_read_a000_bfff=mem_read_a000_bfff_default; mem_write_a000_bfff=mem_write_a000_bfff_default; for(i=0;i<2;i++) { set_mem_read_direct_access(i+0x0A,&ram_page[0][i*0x1000]); set_mem_write_direct_access(i+0x0A,&ram_page[0][i*0x1000]); } } /* WRAM */ set_mem_read_direct_access(0x0C,&wram_page[0][0]); set_mem_read_direct_access(0x0D,&wram_page[active_wram_page][0]); set_mem_read_direct_access(0x0E,&wram_page[0][0]); set_mem_write_direct_access(0x0C,&wram_page[0][0]); set_mem_write_direct_access(0x0D,&wram_page[active_wram_page][0]); set_mem_write_direct_access(0x0E,&wram_page[0][0]); /* OAM HIMEM */ set_mem_read_fun_access(0x0f,mem_read_f000_ffff_default); set_mem_write_fun_access(0x0f,mem_write_f000_ffff_default); } void push_stack_word(Uint16 v) { Uint8 h=((v&0xff00)>>8); Uint8 l=(v&0x00ff); --gbcpu->sp.w; mem_write_fast(gbcpu->sp.w,h); --gbcpu->sp.w; mem_write_fast(gbcpu->sp.w,l); } Uint8 **alloc_mem_page(Uint16 nb_page,Uint32 size) { Uint8 **page; int i; page=(Uint8 **)malloc(sizeof(Uint8 *)*nb_page); for(i=0;i>8; HDMA_CTRL2=(dma_info.src&0xf0); HDMA_CTRL3=(dma_info.dest&0xff00)>>8; HDMA_CTRL4=(dma_info.dest&0xf0); HDMA_CTRL5--; dma_info.lg-=16; if (HDMA_CTRL5==0xff) dma_info.type=NO_DMA; } __inline__ void do_gdma(void) { int i; Uint8 t; Uint8 bk; Uint8 *d=&vram_page[active_vram_page][dma_info.dest&0x1fff]; for(i=0;i>8; HDMA_CTRL2=(dma_info.src&0xf0); HDMA_CTRL3=(dma_info.dest&0xff00)>>8; HDMA_CTRL4=(dma_info.dest&0xf0); if (!conf.gdma_cycle) { HDMA_CTRL5=0xff; dma_info.type=NO_DMA; } else dma_info.type=GDMA; } __inline__ void hdma_request(Uint8 v) { /* FIXME : control are necesary ( i think ) */ //if (LCDCCONT&0x80) { if (dma_info.type==HDMA) { int i; Uint8 t; for(i=0;i>4))<<4; dma_info.dest=((((HDMA_CTRL3&31)|0x80)<<4)|(HDMA_CTRL4>>4))<<4; dma_info.lg=((v&0x7f)+1)<<4; HDMA_CTRL5=v&0x7f; dma_info.type=HDMA; if ((LCDCSTAT&0x03)==0x00) do_hdma(); /*} else { dma_info.v=v; dma_info.src=(HDMA_CTRL1<<8)|(HDMA_CTRL2&0xf0); dma_info.dest=(HDMA_CTRL3<<8)|(HDMA_CTRL4&0xf0)|0x8000; dma_info.lg=((v&0x7f)+1)<<4; HDMA_CTRL5=0xff; dma_info.type=NO_DMA; do_gdma(); }*/ } __inline__ void gdma_request(Uint8 v) { dma_info.src=((HDMA_CTRL1<<4)|(HDMA_CTRL2>>4))<<4; dma_info.dest=((((HDMA_CTRL3&31)|0x80)<<4)|(HDMA_CTRL4>>4))<<4; dma_info.lg=((v&0x7f)+1)<<4; /* FIXME: gdma: how many cycle take GDMA ? */ dma_info.gdma_cycle=((((gbcpu->mode==DOUBLE_SPEED)?110:220)+((v&0x7f)*7.63))*0.000001)* (((gbcpu->mode==DOUBLE_SPEED)?4194304*2:4194304)); /* TGB: */ dma_info.gdma_cycle=456*2+((v&0x7f)+1)*32*(gbcpu->mode==DOUBLE_SPEED?2:1); /* FIXME: gdma: control are necesary ( i think ) */ do_gdma(); } __inline__ void do_dma(Uint8 v) { Uint16 a=v<<8; Uint8 bank; int i; DMA=v; if (a>=0xfea0 && a<0xffff) memcpy(oam_space,&himem[a-0xfea0],0xa0); if (a>=0xe000 && a<0xfe00) a-=0x2000; // echo mem bank=(a&0xf000)>>12; switch(bank) { case 0x00: case 0x01: case 0x02: case 0x03:memcpy(oam_space,&rom_page[0][a],0xa0);return; case 0x04: case 0x05: case 0x06: case 0x07:memcpy(oam_space,&rom_page[active_rom_page][a-0x4000],0xa0);return; case 0x08: case 0x09:memcpy(oam_space,&vram_page[active_vram_page][a-0x8000],0xa0);return; case 0x0a: case 0x0b:memcpy(oam_space,&ram_page[active_ram_page][a-0xa000],0xa0);return; case 0x0c:memcpy(oam_space,&wram_page[0][a-0xc000],0xa0);return; case 0x0d:memcpy(oam_space,&wram_page[active_wram_page][a-0xd000],0xa0);return; default: for(i=0;i<0xa0;i++) oam_space[i]=mem_read(a+i); break; } } /* READ FUNCTIONS */ __inline__ Uint8 mem_read_ff(Uint16 adr) { if (adr==0xff00) { Uint8 t=0xff; /*if (sgb.check) { sgb.check=0; return GB_PAD; }*/ // if (GB_PAD==0x30) //printf("read GB_PAD %02x\n",GB_PAD); /* FIXME */ /* if (GB_PAD==0x03) { printf("determine type\n"); return (gameboy_type==SUPER_GAMEBOY)?0x3f:0xff; }*/ //printf("%d %02x\n",sgb.b_i,GB_PAD); /*if (GB_PAD==0x30) return 0xff; if (GB_PAD==0x10) GB_PAD=((~(gb_pad&0x0f))&0xdf); else if (GB_PAD==0x20) GB_PAD=((~(gb_pad>>4))&0xef); return GB_PAD;*/ // if (GB_PAD==0xff) return ((conf.gb_type&SUPER_GAMEBOY)?0x3f:0xff); switch(GB_PAD&0x30) { case 0x00: case 0xff:t=0xff;break; case 0x10:t=((~(gb_pad&0x0f)))|0x10; break; case 0x20:t=((~(gb_pad>>4)))|0x20; break; case 0x30:t=(((!sgb.player)?(~0x00):(~0x01)));break; } /*if (GB_PAD==0x10) GB_PAD=((~(gb_pad&0x0f)))|0x10; else if (GB_PAD==0x20) GB_PAD=((~(gb_pad>>4)))|0x20; return GB_PAD;*/ //if (sgb.player&0x80) { if (conf.gb_type&SUPER_GAMEBOY) t/*GB_PAD*/&=0x3f; /* sgb.player&=(~0x80); }*/ return t; //GB_PAD=t; //return GB_PAD; } /* if (adr==0xff01 && conf.serial_on) { Sint8 a=gbserial_check(); if (a>=0) SB=a; else SB=0xff; return SB; } else return SB;*/ if (conf.gb_type&COLOR_GAMEBOY) { if (adr==0xff4d) { if (gbcpu->mode==DOUBLE_SPEED) return CPU_SPEED|0x80; else return 0x00; } if (adr==0xff69) { if (BGPAL_SPE&0x01) return pal_col_bck_gb[(BGPAL_SPE&0x38)>>3][(BGPAL_SPE&0x06)>>1]>>8; else return pal_col_bck_gb[(BGPAL_SPE&0x38)>>3][(BGPAL_SPE&0x06)>>1]&0xff; } if (adr==0xff6b) { if (OBJPAL_SPE&0x01) return pal_col_obj_gb[(OBJPAL_SPE&0x38)>>3][(OBJPAL_SPE&0x06)>>1]>>8; else return pal_col_obj_gb[(OBJPAL_SPE&0x38)>>3][(OBJPAL_SPE&0x06)>>1]&0xff; } } if (adr>=0xff10 && adr<=0xff3f && conf.sound) return read_sound_reg(adr); return himem[adr-0xfea0]; } Uint8 mem_read_a000_bfff_default(Uint16 adr) { if (!ram_enable) return 0xff; return ram_page[active_ram_page][adr-0xa000]; } Uint8 mem_read_f000_ffff_default(Uint16 adr) { if (adr>=0xff00) return mem_read_ff(adr); if (adr>=0xfe00 && adr<0xfea0) return oam_space[adr-0xfe00]; if (adr>=0xfea0 && adr<0xff00) return himem[adr-0xfea0]; return 0xff; } Uint8 timer_read_a000_bfff(Uint16 adr) { /* FIXME: Timer and ram enable ???? */ if (!ram_enable) return 0xFF; if (rom_timer->reg_sel&0x08) return rom_timer->regl[rom_timer->reg_sel&0x07]; return ram_page[active_ram_page][adr-0xa000]; } Uint8 mem_read_default(Uint16 adr) { Uint8 bank; if (adr>=0xfe00 && adr<0xfea0) return oam_space[adr-0xfe00]; if (adr>=0xfea0 && adr<0xff00) return himem[adr-0xfea0]; if (adr>=0xff00) return mem_read_ff(adr); if (adr>=0xe000 && adr<0xfe00) adr-=0x2000; // echo mem bank=(adr&0xf000)>>12; switch(bank) { case 0x00: case 0x01: case 0x02: case 0x03:return rom_page[0][adr]; case 0x04: case 0x05: case 0x06: case 0x07:return rom_page[active_rom_page][adr-0x4000]; case 0x08: case 0x09:return vram_page[active_vram_page][adr-0x8000]; case 0x0a: case 0x0b: if (!ram_enable) return 0xff; if (rom_type&TIMER && rom_timer->reg_sel&0x08) return rom_timer->regl[rom_timer->reg_sel&0x07]; return ram_page[active_ram_page][adr-0xa000]; case 0x0c:return wram_page[0][adr-0xc000]; case 0x0d:return wram_page[active_wram_page][adr-0xd000]; } return 0xFF; } __inline__ void update_gb_pad(void) { gb_pad=0; if (!conf.play_movie) { if (conf.use_joy) { if ((joy_but[jmap[PAD_START]]) || (key[kmap[PAD_START]])) gb_pad|=0x08; /* Start */ if ((joy_but[jmap[PAD_SELECT]]) || (key[kmap[PAD_SELECT]])) gb_pad|=0x04; /* Select */ if ((joy_but[jmap[PAD_A]]) || (key[kmap[PAD_A]])) gb_pad|=0x01; /* A */ if ((joy_but[jmap[PAD_B]]) || (key[kmap[PAD_B]])) gb_pad|=0x02; /* B */ /*if ((joy_axis[jmap[PAD_LEFT]]<-10000) || (key[kmap[PAD_LEFT]])) gb_pad|=0x20; if ((joy_axis[jmap[PAD_RIGHT]]>10000) || (key[kmap[PAD_RIGHT]])) gb_pad|=0x10; if ((joy_axis[jmap[PAD_UP]]<-10000) || (key[kmap[PAD_UP]])) gb_pad|=0x40; if ((joy_axis[jmap[PAD_DOWN]]>10000) || (key[kmap[PAD_DOWN]])) gb_pad|=0x80;*/ Sint16 joy_x_pos=joy_axis[jmap[PAD_LEFT]]; Sint16 joy_y_pos=joy_axis[jmap[PAD_UP]]; if (joy_x_pos>joy_x_max) joy_x_max=joy_x_pos; if (joy_x_posjoy_y_max) joy_y_max=joy_y_pos; if (joy_y_pos(joy_x_mid+joy_x_qua)) || (key[kmap[PAD_RIGHT]])) gb_pad|=0x10; if ((joy_y_pos<(joy_y_mid-joy_y_qua)) || (key[kmap[PAD_UP]])) gb_pad|=0x40; if ((joy_y_pos>(joy_y_mid+joy_y_qua)) || (key[kmap[PAD_DOWN]])) gb_pad|=0x80; } else { // if (!joy_but) { if (key[kmap[PAD_START]]) gb_pad|=0x08; /* Start */ if (key[kmap[PAD_SELECT]]) gb_pad|=0x04; /* Select */ if (key[kmap[PAD_A]]) gb_pad|=0x01; /* A */ if (key[kmap[PAD_B]]) gb_pad|=0x02; /* B */ // } else { // if ((joy_but[jmap[PAD_START]]) || (key[kmap[PAD_START]])) gb_pad|=0x08; /* Start */ // if ((joy_but[jmap[PAD_SELECT]]) || (key[kmap[PAD_SELECT]])) gb_pad|=0x04; /* Select */ // if ((joy_but[jmap[PAD_A]]) || (key[kmap[PAD_A]])) gb_pad|=0x01; /* A */ // if ((joy_but[jmap[PAD_B]]) || (key[kmap[PAD_B]])) gb_pad|=0x02; /* B */ // } // if (!joy_axis) { if (key[kmap[PAD_LEFT]]) gb_pad|=0x20; if (key[kmap[PAD_RIGHT]]) gb_pad|=0x10; if (key[kmap[PAD_UP]]) gb_pad|=0x40; if (key[kmap[PAD_DOWN]]) gb_pad|=0x80; //} else { //if ((joy_axis[jmap[PAD_LEFT]]<-1000) || (key[kmap[PAD_LEFT]])) gb_pad|=0x20; //if ((joy_axis[jmap[PAD_RIGHT]]>1000) || (key[kmap[PAD_RIGHT]])) gb_pad|=0x10; //if ((joy_axis[jmap[PAD_UP]]<-1000) || (key[kmap[PAD_UP]])) gb_pad|=0x40; //if ((joy_axis[jmap[PAD_DOWN]]>1000) || (key[kmap[PAD_DOWN]])) gb_pad|=0x80; //} } if (conf.save_movie) movie_add_pad(gb_pad); } else { gb_pad=movie_get_next_pad(); } } extern Uint8 win_line; __inline__ void write2lcdccont(Uint8 v) { if ((LCDCCONT&0x80) && (!(v&0x80))) { // LCDC go to off gblcdc->mode=HBLANK_PER; LCDCSTAT=(LCDCSTAT&0xfc); CURLINE=0; gblcdc->cycle=0; dma_info.type=NO_DMA; HDMA_CTRL5=0xff; clear_screen(); reset_frame_skip(); } if ((!(LCDCCONT&0x80)) && (v&0x80)) { // LCDC go to on gblcdc_set_on(); } LCDCCONT=v; } __inline__ void mem_write_ff(Uint16 adr,Uint8 v) { Uint16 a; Uint8 c,p; if (conf.gb_type&COLOR_GAMEBOY) { if (adr==0xff4d) { if (v&0x80 || v&0x01) { go2double_speed(); /* FIXME: */ get_nb_cycle(); } CPU_SPEED=(v&0xfe); return; } if (adr==0xff4f) { set_active_vram_page(v); VRAM_BANK=active_vram_page; return; } if (adr==0xff55) { // HDMA & GDMA if (v&0x80) hdma_request(v); else gdma_request(v); return; } if (adr==0xff68) { BGPAL_SPE=v&0xbf; if (BGPAL_SPE&0x01) BGPAL_DATA=pal_col_bck_gb[(BGPAL_SPE>>3)&0x07][(BGPAL_SPE>>1)&0x03]>>8; else BGPAL_DATA=pal_col_bck_gb[(BGPAL_SPE>>3)&0x07][(BGPAL_SPE>>1)&0x03]&0xff; return; } if (adr==0xff69) { c=(BGPAL_SPE>>1)&0x03; p=(BGPAL_SPE>>3)&0x07; if (BGPAL_SPE&0x01) pal_col_bck_gb[p][c]=(pal_col_bck_gb[p][c]&0x00ff)|(v<<8); else pal_col_bck_gb[p][c]=(pal_col_bck_gb[p][c]&0xff00)|v; pal_col_bck[p][c]=Filter[pal_col_bck_gb[p][c]&0x7FFF]; if (BGPAL_SPE&0x80) { a=BGPAL_SPE&0x3f; a++; BGPAL_SPE=(a&0x3f)|0x80; } BGPAL_DATA=v; return; } if (adr==0xff6a) { OBJPAL_SPE=v&0xbf; if (OBJPAL_SPE&0x01) OBJPAL_DATA=pal_col_obj_gb[(OBJPAL_SPE>>3)&0x07][(OBJPAL_SPE>>1)&0x03]>>8; else OBJPAL_DATA=pal_col_obj_gb[(OBJPAL_SPE>>3)&0x07][(OBJPAL_SPE>>1)&0x03]&0xff; return; } if (adr==0xff6b) { c=(OBJPAL_SPE>>1)&0x03; p=(OBJPAL_SPE>>3)&0x07; if (OBJPAL_SPE&0x01) pal_col_obj_gb[p][c]=(pal_col_obj_gb[p][c]&0x00ff)|(v<<8); else pal_col_obj_gb[p][c]=(pal_col_obj_gb[p][c]&0xff00)|v; pal_col_obj[p][c]=Filter[pal_col_obj_gb[p][c]&0x7FFF]; if (OBJPAL_SPE&0x80) { a=OBJPAL_SPE&0x3f; a++; OBJPAL_SPE=(a&0x3f)|0x80; } OBJPAL_DATA=v; return; } if (adr==0xff70) { set_active_wram_page(v); WRAM_BANK=active_wram_page; return; } } // end COLOR_GAMEBOY // Update sound if necessary if (adr>=0xff10 && adr<=0xff3f && conf.sound) { write_sound_reg(adr,v); return; } switch(adr) { case 0xff00: if (sgb.on) { // sgb transfert switch(v) { case 0x00:sgb_init_transfer();return; case 0x10:sgb.b=1;break; case 0x20:sgb.b=0;break; case 0x30: if (sgb.b_i==-1) {sgb.b_i=0;return;} if (sgb.b_i==128 /*&& sgb.b==0*/) { sgb_exec_cmd(); sgb.on=0; return; } sgb.pack[sgb.b_i/8]=(sgb.pack[sgb.b_i/8]>>1)|(sgb.b<<(8-sgb.b%8)); sgb.b_i++; } } else { if (v==0x00) { if (conf.gb_type&SUPER_GAMEBOY) sgb_init_transfer(); return; } if (v==0x30 ) GB_PAD=0xff; else GB_PAD=v; update_gb_pad(); } break; /* EXPERIMENTAL */ case 0xff01: SB=v; break; case 0xff02: /* SC=v&0x81; if ((v&0x80)&&(v&0x01)) serial_cycle_todo=512; break;*/ if (!conf.serial_on) { if ((v&0x81)==0x81) { SB=0xff; SC=v&0x7f; set_interrupt(SERIAL_INT); } } else { /* Start Tranfer ? */ // printf("Write %02x\n",v); if ((v&0x80)==0x80) { if ((v&0x01)==0x01) { /* Internal Clock */ gbserial_write(SB); printf("Server write %02x\n",SB); serial_cycle_todo=4096; //serial_cycle_todo=4096/2; //serial_cycle_todo=1024; } else { gbserial.wait=1; // gbserial_send(SB); /* External Clock */ //gbserial.check=1; //serial_cycle_todo=4096; // gbserial_send(SB); } SC=(v&0x81); } else { //SB=0xff; //gbserial.check=0; } /*if ((v&0x81)==0x81) { gbserial_send(SB); serial_cycle_todo=4096; } */ SC=(v&0x81); } /* if (conf.serial_on) { if ((v&0x81)==0x81) { gbserial_send(SB); //serial_cycle_todo=4096*2; } } SB=0xff; SC=v&0x7f;*/ break; case 0xff0f: unset_interrupt(((INT_FLAG)^(v&0x1f))^(v&0x1f)); if (v&0x1f) set_interrupt(v&0x1f); break; case 0xffff: INT_ENABLE=v&0x1f; break; case 0xff04:DIVID=0;break; case 0xff05: TIME_COUNTER=v; /* FIXME */ gbtimer->cycle=0; break; case 0xff06: TIME_MOD=v; break; case 0xff07: if (v&4) { switch(v&3) { case 0: gbtimer->clk_inc=1024;break; case 1: gbtimer->clk_inc=16;break; case 2: gbtimer->clk_inc=64;break; case 3: gbtimer->clk_inc=256;break; } } else gbtimer->clk_inc=0; gbtimer->cycle=gbtimer->clk_inc; /* FIXME */ /*if (!(TIME_CONTROL&0x04)) gbtimer->cycle+=gbtimer->clk_inc; else gbtimer->cycle=gbtimer->clk_inc;*/ // if ((v&0x04) && !(TIME_CONTROL&0x04)) gbtimer->cycle=0; TIME_CONTROL=v; break; case 0xff40: write2lcdccont(v); break; case 0xff41: /* Emulate Normal Gameboy Bug (fix Legend Of Zerd) */ if (!(conf.gb_type&COLOR_GAMEBOY)) { //if (!(LCDCSTAT&0x03) || (LCDCSTAT&0x03)==0x01) set_interrupt(LCDC_INT); if (!(LCDCSTAT&0x02)) /* FIXME: Stat write bug */ set_interrupt(LCDC_INT); //if ((v&0x20) && (!(LCDCSTAT&0x20)) && (LCDCSTAT&0x02)) set_interrupt(LCDC_INT); LCDCSTAT=(LCDCSTAT&0x07)|(v&0x78); if (CURLINE<0x91 && CURLINE==CMP_LINE) { LCDCSTAT|=0x04; if (LCDCSTAT&0x40 && LCDCCONT&0x80) set_interrupt(LCDC_INT); } } else { /*FIXME: LCDCSTAT write */ LCDCSTAT=(LCDCSTAT&0x07)|(v&0x78); if (CURLINE<0x91 && CURLINE==CMP_LINE) { LCDCSTAT|=0x04; if (LCDCSTAT&0x40 && LCDCCONT&0x80) set_interrupt(LCDC_INT); } } break; case 0xff44: CURLINE=0; if (LCDCCONT&0x80) gblcdc_set_on(); break; case 0xff45:CMP_LINE=v; /* FIXME */ if (CURLINE==CMP_LINE) LCDCSTAT|=0x04; else LCDCSTAT&=~0x04; if (LCDCCONT&0x80 && LCDCSTAT&0x40 && LCDCSTAT&0x04 && (LCDCSTAT&0x02)==0x02) set_interrupt(LCDC_INT); break; case 0xff46: // DMA do_dma(v); break; case 0xff47: gb_set_pal_bck(v); break; case 0xff48: OBJ0PAL=v; pal_obj[0][0]=OBJ0PAL&3; pal_obj[0][1]=(OBJ0PAL>>2)&3; pal_obj[0][2]=(OBJ0PAL>>4)&3; pal_obj[0][3]=(OBJ0PAL>>6)&3; break; case 0xff49: OBJ1PAL=v; pal_obj[1][0]=OBJ1PAL&3; pal_obj[1][1]=(OBJ1PAL>>2)&3; pal_obj[1][2]=(OBJ1PAL>>4)&3; pal_obj[1][3]=(OBJ1PAL>>6)&3; break; case 0xff4d:CPU_SPEED=0x80;break; default: himem[adr-0xfea0]=v; break; } } /* Mbc1 */ void mbc1_write_4000_5fff(Uint16 adr,Uint8 v) { if (mbc1_mem_mode==MBC1_16_8_MEM_MODE) mbc1_line=v&0x03; else set_active_ram_page(v); } void mbc1_write_6000_7fff(Uint16 adr,Uint8 v) { if (!v) mbc1_mem_mode=MBC1_16_8_MEM_MODE; else if (v==1) mbc1_mem_mode=MBC1_4_32_MEM_MODE; } /* Rumble */ void rumble_write_4000_5fff(Uint16 adr,Uint8 v) { /* FIXME: Rumble write v&0x08 we must active ram Page ????? */ set_active_ram_page(v); if (conf.rumble_on && v&0x08) rb_on=1; } /* Timer */ __inline__ void rom_timer_lock(void) { memcpy(rom_timer->regl,rom_timer->reg,sizeof(Uint8)*5); } __inline__ void rom_timer_write(Uint8 v) { if (!(rom_timer->reg_sel&0x08)) return; switch(rom_timer->reg_sel&0x07) { case 0x00:rom_timer->reg[0]=(v%60);break; // seconds case 0x01:rom_timer->reg[1]=(v%60);break; // minutes case 0x02:rom_timer->reg[2]=(v%24);break; // hours case 0x03:rom_timer->reg[3]=v;break; // dayl case 0x04:rom_timer->reg[4]=v;break; // dayh,start|stop,day carry } } void timer_write_a000_bfff(Uint16 adr,Uint8 v) { /* FIXME: timer write and ram enable ????? */ if (!ram_enable) return; if (rom_timer->reg_sel&0x08) { rom_timer_write(v); return; } ram_page[active_ram_page][adr-0xa000]=v; } void timer_write_4000_5fff(Uint16 adr,Uint8 v) { rom_timer->reg_sel=v&0x0f; } void timer_write_6000_7fff(Uint16 adr,Uint8 v) { if (!rom_timer->latch && v) rom_timer_lock(); rom_timer->latch=v; } /* Write Function Default */ void mem_write_0000_1fff_default(Uint16 adr,Uint8 v) { if ((v&0x0f)==0x0a) enable_ram(); else disable_ram(); } void mem_write_2000_3fff_default(Uint16 adr,Uint8 v) { select_rom_page(adr,v); } void mem_write_4000_5fff_default(Uint16 adr,Uint8 v) { set_active_ram_page(v); } void mem_write_6000_7fff_default(Uint16 adr,Uint8 v) { //printf("WARNING: Write %02x at %04x\n",v,adr); } void mem_write_a000_bfff_default(Uint16 adr,Uint8 v) { if (!ram_enable) return; ram_page[active_ram_page][adr-0xa000]=v; } /*void mem_write_c000_dfff_default(Uint16 adr,Uint8 v) { Uint8 bk; bk=(adr&0xf000)>>12; switch(bk) { case 0xc:wram_page[0][adr-0xc000]=v;return; case 0xd:wram_page[active_wram_page][adr-0xd000]=v;return; } } void mem_write_e000_efff_default(Uint16 adr,Uint8 v) { wram_page[0][adr-0xe000]=v; }*/ void mem_write_f000_ffff_default(Uint16 adr,Uint8 v) { if (adr>=0xff00) { mem_write_ff(adr,v); return; } if (adr>=0xfe00 && adr<0xfea0) { oam_space[adr-0xfe00]=v; return; } if (adr>=0xfea0 && adr<0xff00) { himem[adr-0xfea0]=v; return; } wram_page[active_wram_page][adr-0xf000]=v; } /*void mem_write_0000_7fff(Uint16 adr,Uint8 v) { Uint8 bk; bk=(adr&0xf000)>>12; switch(bk) { case 0: case 1: if ((v&0x0f)==0x0a) enable_ram(); else disable_ram(); return; case 2: case 3:select_rom_page(adr,v);return; case 4: case 5: if (rom_type&MBC1) { if (mbc1_mem_mode==MBC1_16_8_MEM_MODE) mbc1_line=v&0x03; else set_active_ram_page(v); return; } else set_active_ram_page(v); if (rom_type&RUMBLE && conf.rumble_on && v&0x08) rb_on=1; if (rom_type&TIMER) rom_timer->reg_sel=v&0x0f; return; case 6: case 7: if (rom_type&MBC1) { if (!v) mbc1_mem_mode=MBC1_16_8_MEM_MODE; else if (v==1) mbc1_mem_mode=MBC1_4_32_MEM_MODE; return; } if (rom_type&TIMER) { if (!rom_timer->latch && v) rom_timer_lock(); rom_timer->latch=v; } return; default: printf("Warning: Write 0000 7fff bank %02x\n",bk);break; } }*/ void mem_write_default(Uint16 adr,Uint8 v) { Uint8 bk; if (adr>=0xfe00 && adr<0xfea0) { oam_space[adr-0xfe00]=v; return; } if (adr>=0xfea0 && adr<0xff00) { himem[adr-0xfea0]=v; return; } if (adr>=0xff00) { mem_write_ff(adr,v); return; } if (adr>=0xe000 && adr<0xfe00) adr-=0x2000; // echo mem bk=(adr&0xf000)>>12; switch(bk) { case 0: case 1: if ((v&0x0f)==0x0a) enable_ram(); else disable_ram(); return; //ram_enable=((v&0x0f)==0x0a)?(1):(0);return; case 2: case 3:select_rom_page(adr,v);return; case 4: case 5: if (rom_type&MBC1) { if (mbc1_mem_mode==MBC1_16_8_MEM_MODE) mbc1_line=v&0x03; else set_active_ram_page(v); return; } else set_active_ram_page(v); if (rom_type&RUMBLE && conf.rumble_on && v&0x08) rb_on=1; if (rom_type&TIMER) { rom_timer->reg_sel=v&0x0f; // printf("select %02x \n",rom_timer->reg_sel); } return; case 6: case 7: if (rom_type&MBC1) { if (!v) mbc1_mem_mode=MBC1_16_8_MEM_MODE; else if (v==1) mbc1_mem_mode=MBC1_4_32_MEM_MODE; return; } if (rom_type&TIMER) { if (!rom_timer->latch && v) rom_timer_lock(); rom_timer->latch=v; } return; case 8: case 9:vram_page[active_vram_page][adr-0x8000]=v;return; case 0xa: case 0xb: if (!ram_enable) return; if (rom_type&TIMER && rom_timer->reg_sel&0x08) { rom_timer_write(v); return; } ram_page[active_ram_page][adr-0xa000]=v; return; case 0xc:wram_page[0][adr-0xc000]=v;return; case 0xd:wram_page[active_wram_page][adr-0xd000]=v;return; } } gngb-20060309/src/memory.h0000644000175000017500000001145007643033301013626 0ustar josejose/* gngb, a game boy color emulator * Copyright (C) 2001 Peponas Thomas & Peponas Mathieu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _MEMORY_H #define _MEMORY_H #include "global.h" #include /* mbc1 mem mode type */ #define MBC1_16_8_MEM_MODE 0 #define MBC1_4_32_MEM_MODE 1 extern Uint8 rom_mask; extern Uint16 nb_rom_page; extern Uint16 nb_ram_page; extern Uint16 nb_vram_page; extern Uint16 nb_wram_page; extern Uint16 active_rom_page; extern Uint16 active_ram_page; extern Uint16 active_vram_page; extern Uint16 active_wram_page; extern Uint8 **rom_page; // 0000 - 4000 bank #0 4000 - 8000 bank #n extern Uint8 **ram_page; // a000 - c000 extern Uint8 **vram_page; // 8000 - a000 extern Uint8 **wram_page; // c000 - fe00 extern Uint8 oam_space[0xa0]; // fe00 - fea0 extern Uint8 himem[0x160]; // fea0 - ffff extern Uint8 mbc1_mem_mode; extern Uint8 mbc1_line; extern Uint8 mbc5_lower; extern Uint8 mbc5_upper; extern Uint8 ram_mask; // REGISTER #define GB_PAD (himem[0x60]) #define SB (himem[0x61]) #define SC (himem[0x62]) #define DIVID (himem[0x64]) #define TIME_COUNTER (himem[0x65]) #define TIME_MOD (himem[0x66]) #define TIME_CONTROL (himem[0x67]) #define INT_FLAG (himem[0x6f]) #define INT_ENABLE (himem[0x15f]) #define LCDCCONT (himem[0xa0]) #define LCDCSTAT (himem[0xa1]) #define CURLINE (himem[0xa4]) #define CMP_LINE (himem[0xa5]) #define SCRX (himem[0xa3]) #define SCRY (himem[0xa2]) #define WINX (himem[0xab]) #define WINY (himem[0xaa]) #define DMA (himem[0xa6]) #define BGPAL (himem[0xa7]) #define OBJ0PAL (himem[0xa8]) #define OBJ1PAL (himem[0xa9]) #define NR10 (himem[0x70]) #define NR11 (himem[0x71]) #define NR12 (himem[0x72]) #define NR13 (himem[0x73]) #define NR14 (himem[0x74]) #define NR21 (himem[0x76]) #define NR22 (himem[0x77]) #define NR23 (himem[0x78]) #define NR24 (himem[0x79]) #define NR30 (himem[0x7a]) #define NR31 (himem[0x7b]) #define NR32 (himem[0x7c]) #define NR33 (himem[0x7d]) #define NR34 (himem[0x7e]) #define NR41 (himem[0x80]) #define NR42 (himem[0x81]) #define NR43 (himem[0x82]) #define NR44 (himem[0x83]) #define NR50 (himem[0x84]) #define NR51 (himem[0x85]) #define NR52 (himem[0x86]) // COLOR GAMEBOY #define CPU_SPEED (himem[0xad]) #define VRAM_BANK (himem[0xaf]) #define HDMA_CTRL1 (himem[0xb1]) #define HDMA_CTRL2 (himem[0xb2]) #define HDMA_CTRL3 (himem[0xb3]) #define HDMA_CTRL4 (himem[0xb4]) #define HDMA_CTRL5 (himem[0xb5]) #define IR_PORT (himem[0xb6]) #define BGPAL_SPE (himem[0xc8]) #define BGPAL_DATA (himem[0xc9]) #define OBJPAL_SPE (himem[0xca]) #define OBJPAL_DATA (himem[0xcb]) #define WRAM_BANK (himem[0xd0]) Uint8 **alloc_mem_page(Uint16 nb_page,Uint32 size); void free_mem_page(Uint8 **page,Uint16 nb_page); void gbmemory_init(void); void gbmemory_reset(void); /* Mem Read/Write */ #define MEM_DIRECT_ACCESS 1 #define MEM_FUN_ACCESS 2 typedef struct { Uint32 type; Uint8 *b; Uint8 (*f)(Uint16 adr); }MEM_READ_ENTRY; extern MEM_READ_ENTRY mem_read_tab[0x10]; typedef struct { Uint32 type; Uint8 *b; void (*f)(Uint16 adr,Uint8 v); }MEM_WRITE_ENTRY; extern MEM_WRITE_ENTRY mem_write_tab[0x10]; Uint8 mem_read_default(Uint16 adr); void mem_write_default(Uint16 adr,Uint8 v); Uint8 mem_read_ff(Uint16 adr); void mem_write_ff(Uint16 adr,Uint8 v); #define mem_write mem_write_default #define mem_read mem_read_default /* To use this macro you don't have to use autoincrementation in argument */ #define mem_read_fast(a,v) {\ if (mem_read_tab[((a)>>12)&0xff].type!=MEM_DIRECT_ACCESS) {\ (v)=mem_read_tab[((a)>>12)&0xff].f((a));\ } else {\ (v)=mem_read_tab[((a)>>12)&0xff].b[(a)&0xfff];\ }\ } #define mem_write_fast(a,v) {\ if (mem_write_tab[((a)>>12)&0xff].type!=MEM_DIRECT_ACCESS) {\ mem_write_tab[((a)>>12)&0xff].f((a),(v));\ } else {\ mem_write_tab[((a)>>12)&0xff].b[(a)&0xfff]=(v);\ }\ } void push_stack_word(Uint16 v); /* DMA Function */ void do_gdma(void); void do_hdma(void); #define NO_DMA 0 #define SPRITE_DMA 1 #define HDMA 2 #define GDMA 3 typedef struct { Sint32 gdma_cycle; Uint16 src,dest; Uint16 lg; Uint8 type; }DMA_INFO; extern DMA_INFO dma_info; #endif gngb-20060309/NEWS0000644000175000017500000000000007643033275012054 0ustar josejosegngb-20060309/TODO0000644000175000017500000000116507677620203012062 0ustar josejose/* Build */ - gcc 3.3 /* Emu */ Improve compatibility Optimisation Add serial support Add Mbc3 support Add sgb support Fix some interrupt bug Fix gdma cycle Fix gb pad /* ROM BUG TO FIX */ Pinball Deluxe/Fantasy : freeze (Problem avec int LCDCSTAT&0x20) regler avec pas de hblank line 0x89 (verifier) Mickey Racing deconne Magical Drop : freeze (Must use option -g to fix) Addams Family : Freeze (must use option -d to fix) Star Heritage : Freeze when use Start Button Dragon Ball (SGB Pad) Powerpuff Girl : - Line 0 clignote si l'option -g est active Altered Space Maybe set always -d and -g option (other games work) gngb-20060309/aclocal.m40000644000175000017500000011205010476607745013235 0ustar josejosednl aclocal.m4 generated automatically by aclocal 1.4-p6 dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. # lib-prefix.m4 serial 4 (gettext-0.14.2) dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't dnl require excessive bracketing. ifdef([AC_HELP_STRING], [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed dnl to access previously installed libraries. The basic assumption is that dnl a user will want packages to use other packages he previously installed dnl with the same --prefix option. dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate dnl libraries, but is otherwise very convenient. AC_DEFUN([AC_LIB_PREFIX], [ AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib-prefix], [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib --without-lib-prefix don't search for libraries in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/lib" fi fi ]) if test $use_additional = yes; then dnl Potentially add $additional_includedir to $CPPFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's already present in $CPPFLAGS, dnl 3. if it's /usr/local/include and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= for x in $CPPFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $CPPFLAGS. CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" fi fi fi fi dnl Potentially add $additional_libdir to $LDFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's already present in $LDFLAGS, dnl 3. if it's /usr/local/lib and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/lib"; then haveit= for x in $LDFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_libdir" = "X/usr/local/lib"; then if test -n "$GCC"; then case $host_os in linux*) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LDFLAGS. LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" fi fi fi fi fi ]) dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, dnl acl_final_exec_prefix, containing the values to which $prefix and dnl $exec_prefix will expand at the end of the configure script. AC_DEFUN([AC_LIB_PREPARE_PREFIX], [ dnl Unfortunately, prefix and exec_prefix get only finally determined dnl at the end of configure. if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" ]) dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the dnl variables prefix and exec_prefix bound to the values they will have dnl at the end of the configure script. AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], [ acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" $1 exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" ]) # lib-link.m4 serial 6 (gettext-0.14.3) dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_PREREQ(2.50) dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and dnl augments the CPPFLAGS variable. AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" ac_cv_lib[]Name[]_cppflags="$INC[]NAME" ]) LIB[]NAME="$ac_cv_lib[]Name[]_libs" LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" INC[]NAME="$ac_cv_lib[]Name[]_cppflags" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the dnl results of this search when this library appears as a dependency. HAVE_LIB[]NAME=yes undefine([Name]) undefine([NAME]) ]) dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) dnl searches for libname and the libraries corresponding to explicit and dnl implicit dependencies, together with the specified include files and dnl the ability to compile and link the specified testcode. If found, it dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. AC_LIB_LINKFLAGS_BODY([$1], [$2]) dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, dnl because if the user has installed lib[]Name and not disabled its use dnl via --without-lib[]Name-prefix, he wants to use it. ac_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ ac_save_LIBS="$LIBS" LIBS="$LIBS $LIB[]NAME" AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) LIBS="$ac_save_LIBS" ]) if test "$ac_cv_lib[]Name" = yes; then HAVE_LIB[]NAME=yes AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) AC_MSG_CHECKING([how to link with lib[]$1]) AC_MSG_RESULT([$LIB[]NAME]) else HAVE_LIB[]NAME=no dnl If $LIB[]NAME didn't lead to a usable library, we don't need dnl $INC[]NAME either. CPPFLAGS="$ac_save_CPPFLAGS" LIB[]NAME= LTLIB[]NAME= fi AC_SUBST([HAVE_LIB]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) undefine([Name]) undefine([NAME]) ]) dnl Determine the platform dependent parameters needed to use rpath: dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, dnl hardcode_direct, hardcode_minus_L. AC_DEFUN([AC_LIB_RPATH], [ dnl Tell automake >= 1.10 to complain if config.rpath is missing. m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done ]) wl="$acl_cv_wl" libext="$acl_cv_libext" shlibext="$acl_cv_shlibext" hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" hardcode_direct="$acl_cv_hardcode_direct" hardcode_minus_L="$acl_cv_hardcode_minus_L" dnl Determine whether the user wants rpath handling at all. AC_ARG_ENABLE(rpath, [ --disable-rpath do not hardcode runtime library paths], :, enable_rpath=yes) ]) dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib$1-prefix], [ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib --without-lib$1-prefix don't search for lib$1 in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/lib" fi fi ]) dnl Search the library and its dependencies in $additional_libdir and dnl $LDFLAGS. Using breadth-first-seach. LIB[]NAME= LTLIB[]NAME= INC[]NAME= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='$1 $2' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" else dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined dnl that this library doesn't exist. So just drop it. : fi else dnl Search the library lib$name in $additional_libdir and $LDFLAGS dnl and the already constructed $LIBNAME/$LTLIBNAME. found_dir= found_la= found_so= found_a= if test $use_additional = yes; then if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then found_dir="$additional_libdir" found_so="$additional_libdir/lib$name.$shlibext" if test -f "$additional_libdir/lib$name.la"; then found_la="$additional_libdir/lib$name.la" fi else if test -f "$additional_libdir/lib$name.$libext"; then found_dir="$additional_libdir" found_a="$additional_libdir/lib$name.$libext" if test -f "$additional_libdir/lib$name.la"; then found_la="$additional_libdir/lib$name.la" fi fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then found_dir="$dir" found_so="$dir/lib$name.$shlibext" if test -f "$dir/lib$name.la"; then found_la="$dir/lib$name.la" fi else if test -f "$dir/lib$name.$libext"; then found_dir="$dir" found_a="$dir/lib$name.$libext" if test -f "$dir/lib$name.la"; then found_la="$dir/lib$name.la" fi fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then dnl Found the library. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then dnl Linking with a shared library. We attempt to hardcode its dnl directory into the executable's runpath, unless it's the dnl standard /usr/lib. if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then dnl No hardcoding is needed. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl Use an explicit option to hardcode DIR into the resulting dnl binary. dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi dnl The hardcoding into $LIBNAME is system dependent. if test "$hardcode_direct" = yes; then dnl Using DIR/libNAME.so during linking hardcodes DIR into the dnl resulting binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then dnl Use an explicit option to hardcode DIR into the resulting dnl binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else dnl Rely on "-L$found_dir". dnl But don't add it if it's already contained in the LDFLAGS dnl or the already constructed $LIBNAME haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" fi if test "$hardcode_minus_L" != no; then dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH dnl here, because this doesn't fit in flags passed to the dnl compiler. So give up. No hardcoding. This affects only dnl very old systems. dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then dnl Linking with a static library. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" else dnl We shouldn't come here, but anyway it's good to have a dnl fallback. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" fi fi dnl Assume the include files are nearby. additional_includedir= case "$found_dir" in */lib | */lib/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then dnl Potentially add $additional_includedir to $INCNAME. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's /usr/local/include and we are using GCC on Linux, dnl 3. if it's already present in $CPPFLAGS or the already dnl constructed $INCNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INC[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $INCNAME. INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" fi fi fi fi fi dnl Look for dependencies. if test -n "$found_la"; then dnl Read the .la file. It defines the variables dnl dlname, library_names, old_library, dependency_libs, current, dnl age, revision, installed, dlopen, dlpreopen, libdir. save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" dnl We use only dependency_libs. for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's /usr/local/lib and we are using GCC on Linux, dnl 3. if it's already present in $LDFLAGS or the already dnl constructed $LIBNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/lib"; then haveit= if test "X$additional_libdir" = "X/usr/local/lib"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LIBNAME. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LTLIBNAME. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) dnl Handle this in the next round. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) dnl Handle this in the next round. Throw away the .la's dnl directory; it is already contained in a preceding -L dnl option. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) dnl Most likely an immediate library name. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" ;; esac done fi else dnl Didn't find the library; assume it is in the system directories dnl known to the linker and runtime loader. (All the system dnl directories known to the linker should also be known to the dnl runtime loader, otherwise the system is severely misconfigured.) LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user must dnl pass all path elements in one option. We can arrange that for a dnl single library, but not when more than one $LIBNAMEs are used. alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" done dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" else dnl The -rpath options are cumulative. for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then dnl When using libtool, the option that works for both libraries and dnl executables is -R. The -R options are cumulative. for found_dir in $ltrpathdirs; do LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" done fi ]) dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, dnl unless already present in VAR. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes dnl contains two or three consecutive elements that belong together. AC_DEFUN([AC_LIB_APPENDTOVAR], [ for element in [$2]; do haveit= for x in $[$1]; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then [$1]="${[$1]}${[$1]:+ }$element" fi done ]) # lib-ld.m4 serial 3 (gettext-0.13) dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Subroutines of libtool.m4, dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision dnl with libtool.m4. dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. AC_DEFUN([AC_LIB_PROG_LD_GNU], [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, [# I'd rather use --version here, but apparently some GNU ld's only accept -v. case `$LD -v 2>&1 conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by GCC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]* | [A-Za-z]:[\\/]*)] [re_direlt='/[^/][^/]*/\.\./'] # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(acl_cv_path_LD, [if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi]) LD="$acl_cv_path_LD" if test -n "$LD"; then AC_MSG_RESULT($LD) else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) AC_LIB_PROG_LD_GNU ]) # Like AC_CONFIG_HEADER, but automatically create stamp file. AC_DEFUN([AM_CONFIG_HEADER], [AC_PREREQ([2.12]) AC_CONFIG_HEADER([$1]) dnl When config.status generates a header, we must update the stamp-h file. dnl This file resides in the same directory as the config header dnl that is generated. We must strip everything past the first ":", dnl and everything past the last "/". AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, <>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, <>; do case " <<$>>CONFIG_HEADERS " in *" <<$>>am_file "*<<)>> echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx ;; esac am_indx=`expr "<<$>>am_indx" + 1` done<<>>dnl>>) changequote([,]))]) # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. # But this isn't really a big deal. # serial 1 dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) AC_DEFUN([AM_INIT_AUTOMAKE], [AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) VERSION=[$2] AC_SUBST(VERSION) dnl test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi ifelse([$3],, AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) AC_REQUIRE([AM_SANITY_CHECK]) AC_REQUIRE([AC_ARG_PROGRAM]) dnl FIXME This is truly gross. missing_dir=`cd $ac_aux_dir && pwd` AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir) AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir) AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_REQUIRE([AC_PROG_MAKE_SET])]) # Copyright 2002 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"]) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION so it can be traced. # This function is AC_REQUIREd by AC_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.4-p6])]) # # Check to make sure that the build environment is sane. # AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "[$]*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "[$]*" != "X $srcdir/configure conftestfile" \ && test "[$]*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "[$]2" = conftestfile ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi rm -f conftest* AC_MSG_RESULT(yes)]) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. AC_DEFUN([AM_MISSING_PROG], [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if ($2 --version) < /dev/null > /dev/null 2>&1; then $1=$2 AC_MSG_RESULT(found) else $1="$3/missing $2" AC_MSG_RESULT(missing) fi AC_SUBST($1)]) # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_SUBST($1_TRUE) AC_SUBST($1_FALSE) if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi]) gngb-20060309/README0000644000175000017500000000475607643033275012263 0ustar josejoseDescription : ------------- Gngb is Color GameBoy(tm) for linux emulator wrinten in C using the SDL. It emulate most of the GB and GBC roms. Prerequisites : --------------- You need a recent version of SDL (I use SDL-1.2.2). The 1.0 serie don't work, sorry. Installation : -------------- ./configure make make install if you want to compile with a debuger ./configure --with-debuger make make install Usage : ------ gngb [OPTION]... FILE Emulate the GameBoy rom pointed by FILE -h, --help print this help and exit -a, --autoframeskip turn on autoframeskip --sleep_idle sleep when idle --color_filter turn on the color filter -r, --rumble turn on the rumble simulation --filter=X Set the filter to apply (only for standard mode) 0 = none 1 = scanline 2 = scanline 50% 3 = smooth 4 = pseudo cell shading -R, --res=WxH set the resolution to WxH (for YUV and GL mode) -Y, --yuv turn YUV mode on --yuv_type set the type of the YUV overlay 0 = YV12 1 = YUY2 -o, --opengl turn OpenGL mode on (if conpiled in) -f, --fullscreen run gngb in fullscreen --fps show frame/sec -s, --sound turn on sound --sample_rate=RATE set the sample rate to RATE -C, --color_gb force to color gameboy mode -G, --normal_gb force to normal gameboy mode -S, --super_gb force to super gameboy mode (experimental) --auto_gb turn on automatique detection -j, --joy=N use the Nth joystick -g, --gdma_cycle cpu stop during gdma transfer (experimental) Most options can be disabled whith --no-OPTION (Ex: --no-sound turn sound off) Keybinding : ------------ Enter : Start Right Shift : Select W : B X : A TAB : Open menu F9 : fullscreen on/off F10 : show fps F11 : reset F12 : show keysym code KeyPad 1-5: Change palette Palette must be define in your gngbrc file (see sample_gngbrc) KeyPad 6 : Toggle color filter Configuration : --------------- In the file $HOME/.gngb/gngbrc a sample file is provide : sample_gngbrc gngb-20060309/configure0000755000175000017500000057214410476607747013324 0ustar josejose#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local ac_config_libobj_dir=. cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : ${ac_max_here_lines=38} # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_unique_file="src/cpu.c" # Factoring default headers for most tests. ac_includes_default="\ #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #endif" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT SDL_CONFIG CPP EGREP LIBOBJS NATIVE_GETOPT_LONG_TRUE NATIVE_GETOPT_LONG_FALSE LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi (cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 { (exit 1); exit 1; }; } srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] _ACEOF cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --infodir=DIR info documentation [PREFIX/info] --mandir=DIR man documentation [PREFIX/man] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-gl enable opengl support --enable-big-endian Force Big Endian Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d $ac_dir || continue ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. if test -f $ac_srcdir/configure.gnu; then echo $SHELL $ac_srcdir/configure.gnu --help=recursive elif test -f $ac_srcdir/configure; then echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || test -f $ac_srcdir/configure.in; then echo $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi cd "$ac_popdir" done fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit 0 fi exec 5>config.log cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" # Get rid of the leading space. ac_sep=" " ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Be sure not to use single quotes in there, as some shells, # such as our DU 5.0 friend, will then `close' the trap. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------- ## ## Output files. ## ## ------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo sed "/^$/d" confdefs.h | sort echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; *) . ./$cache_file;; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" ac_config_commands="$ac_config_commands default-1" am__api_version="1.4" ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f $ac_dir/shtool; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL=$ac_install_sh fi fi echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo "$as_me:$LINENO: checking whether build environment is sane" >&5 echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "$*" != "X $srcdir/configure conftestfile" \ && test "$*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&5 echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&2;} { (exit 1); exit 1; }; } fi test "$2" = conftestfile ) then # Ok. : else { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! Check your system clock" >&5 echo "$as_me: error: newly created file is older than distributed files! Check your system clock" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest* echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 test "$program_prefix" != NONE && program_transform_name="s,^,$program_prefix,;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s,\$,$program_suffix,;$program_transform_name" # Double any \ or $. echo might interpret backslashes. # By default was `s,x,x', remove it if useless. cat <<\_ACEOF >conftest.sed s/[\\$]/&&/g;s/;s,x,x,$// _ACEOF program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm conftest.sed echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF all: @echo 'ac_maketemp="$(MAKE)"' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 SET_MAKE= else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi PACKAGE=gngb VERSION=20060309 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } fi cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF missing_dir=`cd $ac_aux_dir && pwd` echo "$as_me:$LINENO: checking for working aclocal-${am__api_version}" >&5 echo $ECHO_N "checking for working aclocal-${am__api_version}... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (aclocal-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then ACLOCAL=aclocal-${am__api_version} echo "$as_me:$LINENO: result: found" >&5 echo "${ECHO_T}found" >&6 else ACLOCAL="$missing_dir/missing aclocal-${am__api_version}" echo "$as_me:$LINENO: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi echo "$as_me:$LINENO: checking for working autoconf" >&5 echo $ECHO_N "checking for working autoconf... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoconf --version) < /dev/null > /dev/null 2>&1; then AUTOCONF=autoconf echo "$as_me:$LINENO: result: found" >&5 echo "${ECHO_T}found" >&6 else AUTOCONF="$missing_dir/missing autoconf" echo "$as_me:$LINENO: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi echo "$as_me:$LINENO: checking for working automake-${am__api_version}" >&5 echo $ECHO_N "checking for working automake-${am__api_version}... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (automake-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then AUTOMAKE=automake-${am__api_version} echo "$as_me:$LINENO: result: found" >&5 echo "${ECHO_T}found" >&6 else AUTOMAKE="$missing_dir/missing automake-${am__api_version}" echo "$as_me:$LINENO: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi echo "$as_me:$LINENO: checking for working autoheader" >&5 echo $ECHO_N "checking for working autoheader... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoheader --version) < /dev/null > /dev/null 2>&1; then AUTOHEADER=autoheader echo "$as_me:$LINENO: result: found" >&5 echo "${ECHO_T}found" >&6 else AUTOHEADER="$missing_dir/missing autoheader" echo "$as_me:$LINENO: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi echo "$as_me:$LINENO: checking for working makeinfo" >&5 echo $ECHO_N "checking for working makeinfo... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (makeinfo --version) < /dev/null > /dev/null 2>&1; then MAKEINFO=makeinfo echo "$as_me:$LINENO: result: found" >&5 echo "${ECHO_T}found" >&6 else MAKEINFO="$missing_dir/missing makeinfo" echo "$as_me:$LINENO: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu MY_CFLAGS="$CFLAGS" OUTPUT="Makefile src/Makefile" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. # Be careful to initialize this variable, since it used to be cached. # Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. ac_cv_exeext= # b.out is created by i960 compilers. for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; conftest.$ac_ext ) # This is the source file. ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool, # but it would be cool to find out if it's true. Does anybody # maintain Libtool? --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std1 is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std1. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX 10.20 and later -Ae # HP-UX older versions -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_stdc=$ac_arg break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext done rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC fi case "x$ac_cv_prog_cc_stdc" in x|xno) echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >conftest.$ac_ext <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ '' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration #include int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 continue fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 if test "${ac_cv_c_bigendian+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # See if sys/param.h defines the BYTE_ORDER macro. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN bogus endian macros #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_bigendian=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_bigendian=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # It does not; compile a test program. if test "$cross_compiling" = yes; then # try to guess the endianness by grepping values into an object file ac_cv_c_bigendian=unknown cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () { _ascii (); _ebcdic (); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long l; char c[sizeof (long)]; } u; u.l = 1; exit (u.c[sizeof (long) - 1] == 1); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_bigendian=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_bigendian=yes fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 echo "${ECHO_T}$ac_cv_c_bigendian" >&6 case $ac_cv_c_bigendian in yes) cat >>confdefs.h <<\_ACEOF #define WORDS_BIGENDIAN 1 _ACEOF ;; no) ;; *) { { echo "$as_me:$LINENO: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&5 echo "$as_me: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} { (exit 1); exit 1; }; } ;; esac echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5 echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6 if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char pthread_create (); int main () { pthread_create (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_pthread_pthread_create=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_pthread_pthread_create=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5 echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6 if test $ac_cv_lib_pthread_pthread_create = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF LIBS="-lpthread $LIBS" else { { echo "$as_me:$LINENO: error: SDL library needs pthread Library" >&5 echo "$as_me: error: SDL library needs pthread Library" >&2;} { (exit 1); exit 1; }; } fi # Extract the first word of "sdl-config", so it can be a program name with args. set dummy sdl-config; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_SDL_CONFIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$SDL_CONFIG"; then ac_cv_prog_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_SDL_CONFIG="yes" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done test -z "$ac_cv_prog_SDL_CONFIG" && ac_cv_prog_SDL_CONFIG="no" fi fi SDL_CONFIG=$ac_cv_prog_SDL_CONFIG if test -n "$SDL_CONFIG"; then echo "$as_me:$LINENO: result: $SDL_CONFIG" >&5 echo "${ECHO_T}$SDL_CONFIG" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test "$SDL_CONFIG" = yes ; then CFLAGS="$CFLAGS -DSDL_YUV `sdl-config --cflags`"; LIBS="$LIBS `sdl-config --libs`"; echo "$as_me:$LINENO: checking for SDL_Init in -lSDL" >&5 echo $ECHO_N "checking for SDL_Init in -lSDL... $ECHO_C" >&6 if test "${ac_cv_lib_SDL_SDL_Init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lSDL $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char SDL_Init (); int main () { SDL_Init (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_SDL_SDL_Init=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_SDL_SDL_Init=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_SDL_SDL_Init" >&5 echo "${ECHO_T}$ac_cv_lib_SDL_SDL_Init" >&6 if test $ac_cv_lib_SDL_SDL_Init = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBSDL 1 _ACEOF LIBS="-lSDL $LIBS" else { { echo "$as_me:$LINENO: error: can't find SDL on your system" >&5 echo "$as_me: error: can't find SDL on your system" >&2;} { (exit 1); exit 1; }; } fi else { { echo "$as_me:$LINENO: error: can't find sdl-config on your system" >&5 echo "$as_me: error: can't find sdl-config on your system" >&2;} { (exit 1); exit 1; }; }; fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_opendir=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_opendir="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_opendir" = no; then for ac_lib in dir; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_opendir="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6 if test "$ac_cv_search_opendir" != no; then test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" fi else echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_opendir=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_opendir="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_opendir" = no; then for ac_lib in x; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_opendir="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6 if test "$ac_cv_search_opendir" != no; then test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6 if test "${ac_cv_prog_egrep+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | (grep -E '(a|b)') >/dev/null 2>&1 then ac_cv_prog_egrep='grep -E' else ac_cv_prog_egrep='egrep' fi fi echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 echo "${ECHO_T}$ac_cv_prog_egrep" >&6 EGREP=$ac_cv_prog_egrep echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in fcntl.h sys/time.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset x; /* SunOS 4.1.1 cc rejects this. */ char const *const *ccp; char **p; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; ccp = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++ccp; p = (char**) ccp; ccp = (char const *const *) p; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; } #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6 if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const _ACEOF fi echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6 if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 _ACEOF fi for ac_func in vprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF echo "$as_me:$LINENO: checking for _doprnt" >&5 echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6 if test "${ac_cv_func__doprnt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define _doprnt to an innocuous variant, in case declares _doprnt. For example, HP-UX 11i declares gettimeofday. */ #define _doprnt innocuous__doprnt /* System header to define __stub macros and hopefully few prototypes, which can conflict with char _doprnt (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef _doprnt /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char _doprnt (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub__doprnt) || defined (__stub____doprnt) choke me #else char (*f) () = _doprnt; #endif #ifdef __cplusplus } #endif int main () { return f != _doprnt; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func__doprnt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func__doprnt=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 echo "${ECHO_T}$ac_cv_func__doprnt" >&6 if test $ac_cv_func__doprnt = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DOPRNT 1 _ACEOF fi fi done for ac_func in gettimeofday sleep mkdir socket strtol do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in getopt_long do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF else case $LIBOBJS in "getopt.$ac_objext" | \ *" getopt.$ac_objext" | \ "getopt.$ac_objext "* | \ *" getopt.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt.$ac_objext" ;; esac case $LIBOBJS in "getopt1.$ac_objext" | \ *" getopt1.$ac_objext" | \ "getopt1.$ac_objext "* | \ *" getopt1.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt1.$ac_objext" ;; esac fi done #Compress Roms if test "${ac_cv_header_bzlib_h+set}" = set; then echo "$as_me:$LINENO: checking for bzlib.h" >&5 echo $ECHO_N "checking for bzlib.h... $ECHO_C" >&6 if test "${ac_cv_header_bzlib_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_bzlib_h" >&5 echo "${ECHO_T}$ac_cv_header_bzlib_h" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking bzlib.h usability" >&5 echo $ECHO_N "checking bzlib.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking bzlib.h presence" >&5 echo $ECHO_N "checking bzlib.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: bzlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: bzlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: bzlib.h: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: bzlib.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: bzlib.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: bzlib.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: bzlib.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: bzlib.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: bzlib.h: see the Autoconf documentation" >&5 echo "$as_me: WARNING: bzlib.h: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: bzlib.h: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: bzlib.h: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: bzlib.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: bzlib.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: bzlib.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: bzlib.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for bzlib.h" >&5 echo $ECHO_N "checking for bzlib.h... $ECHO_C" >&6 if test "${ac_cv_header_bzlib_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_bzlib_h=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_bzlib_h" >&5 echo "${ECHO_T}$ac_cv_header_bzlib_h" >&6 fi if test $ac_cv_header_bzlib_h = yes; then echo "$as_me:$LINENO: checking for BZ2_bzopen in -lbz2" >&5 echo $ECHO_N "checking for BZ2_bzopen in -lbz2... $ECHO_C" >&6 if test "${ac_cv_lib_bz2_BZ2_bzopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbz2 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char BZ2_bzopen (); int main () { BZ2_bzopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_bz2_BZ2_bzopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_bz2_BZ2_bzopen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_bz2_BZ2_bzopen" >&5 echo "${ECHO_T}$ac_cv_lib_bz2_BZ2_bzopen" >&6 if test $ac_cv_lib_bz2_BZ2_bzopen = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBBZ2 1 _ACEOF LIBS="-lbz2 $LIBS" else { { echo "$as_me:$LINENO: error: can't find bzlil on your system" >&5 echo "$as_me: error: can't find bzlil on your system" >&2;} { (exit 1); exit 1; }; } fi fi if test "${ac_cv_header_zlib_h+set}" = set; then echo "$as_me:$LINENO: checking for zlib.h" >&5 echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 if test "${ac_cv_header_zlib_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking zlib.h usability" >&5 echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking zlib.h presence" >&5 echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for zlib.h" >&5 echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 if test "${ac_cv_header_zlib_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_zlib_h=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 fi if test $ac_cv_header_zlib_h = yes; then echo "$as_me:$LINENO: checking for gzopen in -lz" >&5 echo $ECHO_N "checking for gzopen in -lz... $ECHO_C" >&6 if test "${ac_cv_lib_z_gzopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gzopen (); int main () { gzopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_z_gzopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_z_gzopen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzopen" >&5 echo "${ECHO_T}$ac_cv_lib_z_gzopen" >&6 if test $ac_cv_lib_z_gzopen = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBZ 1 _ACEOF LIBS="-lz $LIBS" else { { echo "$as_me:$LINENO: error: can't find zlib on your system" >&5 echo "$as_me: error: can't find zlib on your system" >&2;} { (exit 1); exit 1; }; } fi fi #Opengl Mode # Check whether --enable-gl or --disable-gl was given. if test "${enable_gl+set}" = set; then enableval="$enable_gl" enablegl=$enableval else enablegl=yes fi; if test "$enablegl" = yes ; then if test "${ac_cv_header_GL_gl_h+set}" = set; then echo "$as_me:$LINENO: checking for GL/gl.h" >&5 echo $ECHO_N "checking for GL/gl.h... $ECHO_C" >&6 if test "${ac_cv_header_GL_gl_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_GL_gl_h" >&5 echo "${ECHO_T}$ac_cv_header_GL_gl_h" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking GL/gl.h usability" >&5 echo $ECHO_N "checking GL/gl.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking GL/gl.h presence" >&5 echo $ECHO_N "checking GL/gl.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: GL/gl.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: GL/gl.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: GL/gl.h: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: GL/gl.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: GL/gl.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: GL/gl.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: GL/gl.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: GL/gl.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: GL/gl.h: see the Autoconf documentation" >&5 echo "$as_me: WARNING: GL/gl.h: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: GL/gl.h: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: GL/gl.h: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: GL/gl.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: GL/gl.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: GL/gl.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: GL/gl.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for GL/gl.h" >&5 echo $ECHO_N "checking for GL/gl.h... $ECHO_C" >&6 if test "${ac_cv_header_GL_gl_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_GL_gl_h=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_GL_gl_h" >&5 echo "${ECHO_T}$ac_cv_header_GL_gl_h" >&6 fi if test $ac_cv_header_GL_gl_h = yes; then : else enablegl=no fi echo "$as_me:$LINENO: checking for glBegin in -lGL" >&5 echo $ECHO_N "checking for glBegin in -lGL... $ECHO_C" >&6 if test "${ac_cv_lib_GL_glBegin+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lGL $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char glBegin (); int main () { glBegin (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_GL_glBegin=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_GL_glBegin=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_GL_glBegin" >&5 echo "${ECHO_T}$ac_cv_lib_GL_glBegin" >&6 if test $ac_cv_lib_GL_glBegin = yes; then LIBS="$LIBS -lGL"; CFLAGS="$CFLAGS -DSDL_GL "; else enablegl=no fi fi if test "$GETOPT_LONG" = yes; then NATIVE_GETOPT_LONG_TRUE= NATIVE_GETOPT_LONG_FALSE='#' else NATIVE_GETOPT_LONG_TRUE='#' NATIVE_GETOPT_LONG_FALSE= fi # Check whether --enable-big_endian or --disable-big_endian was given. if test "${enable_big_endian+set}" = set; then enableval="$enable_big_endian" enablebig_endian=$enableval else enablebig_endian=no fi; if test "$enablebig_endian" = yes ; then CFLAGS="$CFLAGS -DWORDS_BIGENDIAN "; fi case `uname -m` in *686) arch_info=i686 ;; *i586) arch_info=i586 ;; *i486) arch_info=i486 ;; *i386) arch_info=i386 ;; *sun4u) arch_info=sun4u ;; *) arch_info=no ;; esac echo "$as_me:$LINENO: result: Architeture: $arch_info" >&5 echo "${ECHO_T}Architeture: $arch_info" >&6 sys_info=`uname -s` echo "$as_me:$LINENO: result: System: $sys_info" >&5 echo "${ECHO_T}System: $sys_info" >&6 case $arch_info in i686|i586|i486|i386) OPT="-O3 -Wno-unused -funroll-loops -fstrength-reduce \ -ffast-math -falign-functions=2 -falign-jumps=2 \ -falign-loops=2 -fomit-frame-pointer -Wall " ;; sun4u) OPT="-O3 -Wno-unused -funroll-loops -fstrength-reduce \ -ffast-math -falign-functions=4 -falign-jumps=4 \ -falign-loops=4 -fomit-frame-pointer -Wall " ;; no) OPT="-O3 -Wall " ;; esac case $sys_info in SunOS) LDOPT="-lnsl -lsocket -lresolv" ;; esac CFLAGS="$CFLAGS $OPT" LIBS="$LIBS $LDOPT" ac_config_files="$ac_config_files Makefile src/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. { (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | sed ' t clear : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ : end' >>confcache if diff $cache_file confcache >/dev/null 2>&1; then :; else if test -w $cache_file; then test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_i=`echo "$ac_i" | sed 's/\$U\././;s/\.o$//;s/\.obj$//'` # 2. Add them. ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH exec 6>&1 # Open the log real soon, to keep \$[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. Logging --version etc. is OK. exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF This file was extended by $as_me, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ _CSEOF echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 echo >&5 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS fi cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir INSTALL="$INSTALL" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` ac_shift=: ;; -*) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; *) # This is not an option, so the user has probably given explicit # arguments. ac_option=$1 ac_need_defaults=false;; esac case $ac_option in # Handling of the options. _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:$LINENO: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # INIT-COMMANDS section. # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason to put it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./confstat$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "\$CONFIG_FILES"; then # Protect against being on the right side of a sed subst in config.status. sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@DEFS@,$DEFS,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@LIBS@,$LIBS,;t t s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t s,@PACKAGE@,$PACKAGE,;t t s,@VERSION@,$VERSION,;t t s,@ACLOCAL@,$ACLOCAL,;t t s,@AUTOCONF@,$AUTOCONF,;t t s,@AUTOMAKE@,$AUTOMAKE,;t t s,@AUTOHEADER@,$AUTOHEADER,;t t s,@MAKEINFO@,$MAKEINFO,;t t s,@SET_MAKE@,$SET_MAKE,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@SDL_CONFIG@,$SDL_CONFIG,;t t s,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@NATIVE_GETOPT_LONG_TRUE@,$NATIVE_GETOPT_LONG_TRUE,;t t s,@NATIVE_GETOPT_LONG_FALSE@,$NATIVE_GETOPT_LONG_FALSE,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi if test ! -s $tmp/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_lines` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi fi # test -n "$CONFIG_FILES" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then configure_input= else configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo "$f";; *) # Relative if test -f "$f"; then # Build tree echo "$f" elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } if test x"$ac_file" != x-; then { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@abs_srcdir@,$ac_abs_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t s,@builddir@,$ac_builddir,;t t s,@abs_builddir@,$ac_abs_builddir,;t t s,@top_builddir@,$ac_top_builddir,;t t s,@abs_top_builddir@,$ac_abs_top_builddir,;t t s,@INSTALL@,$ac_INSTALL,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out rm -f $tmp/stdin if test x"$ac_file" != x-; then mv $tmp/out $ac_file else cat $tmp/out rm -f $tmp/out fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # # CONFIG_HEADER section. # # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='[ ].*$,\1#\2' ac_dC=' ' ac_dD=',;t' # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='$,\1#\2define\3' ac_uC=' ' ac_uD=',;t' for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } # Do quote $f, to prevent DOS paths from being IFS'd. echo "$f";; *) # Relative if test -f "$f"; then # Build tree echo "$f" elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } # Remove the trailing spaces. sed 's/[ ]*$//' $ac_file_inputs >$tmp/in _ACEOF # Transform confdefs.h into two sed scripts, `conftest.defines' and # `conftest.undefs', that substitutes the proper values into # config.h.in to produce config.h. The first handles `#define' # templates, and the second `#undef' templates. # And first: Protect against being on the right side of a sed subst in # config.status. Protect against being in an unquoted here document # in config.status. rm -f conftest.defines conftest.undefs # Using a here document instead of a string reduces the quoting nightmare. # Putting comments in sed scripts is not portable. # # `end' is used to avoid that the second main sed command (meant for # 0-ary CPP macros) applies to n-ary macro definitions. # See the Autoconf documentation for `clear'. cat >confdef2sed.sed <<\_ACEOF s/[\\&,]/\\&/g s,[\\$`],\\&,g t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp t end s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp : end _ACEOF # If some macros were called several times there might be several times # the same #defines, which is useless. Nevertheless, we may not want to # sort them, since we want the *last* AC-DEFINE to be honored. uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >>conftest.undefs <<\_ACEOF s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, _ACEOF # Break up conftest.defines because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS echo ' :' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.defines >/dev/null do # Write a limited-size here document to $tmp/defines.sed. echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#define' lines. echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/defines.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines echo ' fi # grep' >>$CONFIG_STATUS echo >>$CONFIG_STATUS # Break up conftest.undefs because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.undefs >/dev/null do # Write a limited-size here document to $tmp/undefs.sed. echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#undef' echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/undefs.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail rm -f conftest.undefs mv conftest.tail conftest.undefs done rm -f conftest.undefs cat >>$CONFIG_STATUS <<\_ACEOF # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then echo "/* Generated by configure. */" >$tmp/config.h else echo "/* $ac_file. Generated by configure. */" >$tmp/config.h fi cat $tmp/in >>$tmp/config.h rm -f $tmp/in if test x"$ac_file" != x-; then if diff $ac_file $tmp/config.h >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } rm -f $ac_file mv $tmp/config.h $ac_file fi else cat $tmp/config.h rm -f $tmp/config.h fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # # CONFIG_COMMANDS section. # for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue ac_dest=`echo "$ac_file" | sed 's,:.*,,'` ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_dir=`(dirname "$ac_dest") 2>/dev/null || $as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_dest" : 'X\(//\)[^/]' \| \ X"$ac_dest" : 'X\(//\)$' \| \ X"$ac_dest" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_dest" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 echo "$as_me: executing $ac_dest commands" >&6;} case $ac_dest in default-1 ) test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h ;; esac done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi gngb-20060309/configure.in0000644000175000017500000000651210476607742013710 0ustar josejosednl Process this file with autoconf to produce a configure script. AC_INIT(src/cpu.c) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(gngb,20060309) dnl Setup for automake AC_LANG_C MY_CFLAGS="$CFLAGS" OUTPUT="Makefile src/Makefile" dnl Checks for programs. AC_PROG_CC AC_C_BIGENDIAN dnl Checks for libraries. AC_CHECK_LIB(pthread, pthread_create,,AC_MSG_ERROR(SDL library needs pthread Library)) AC_CHECK_PROG(SDL_CONFIG, sdl-config, yes,no) if test "$SDL_CONFIG" = yes ; then CFLAGS="$CFLAGS -DSDL_YUV `sdl-config --cflags`"; LIBS="$LIBS `sdl-config --libs`"; AC_CHECK_LIB(SDL, SDL_Init,,AC_MSG_ERROR(can't find SDL on your system)) else AC_MSG_ERROR(can't find sdl-config on your system); fi dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h ) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_HEADER_TIME dnl Checks for library functions. dnl AC_SUBST(LIBOBJS) AC_FUNC_VPRINTF AC_CHECK_FUNCS(gettimeofday sleep mkdir socket strtol) dnl AC_CHECK_FUNCS(getopt_long ,[GETOPT_LONG=yes , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"]]) dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"]) AC_CHECK_FUNCS(getopt_long , , [ AC_LIBOBJ(getopt) AC_LIBOBJ(getopt1) ]) #Compress Roms dnl AC_ARG_ENABLE(compress_roms,[ --disable-compress-roms disable compress roms support], [enablecompress_roms=$enableval], [enablecompress_roms=yes]) dnl if test "$enablecompress_roms" = yes; then AC_CHECK_HEADER(bzlib.h,AC_CHECK_LIB(bz2, BZ2_bzopen,,AC_MSG_ERROR(can't find bzlil on your system))) AC_CHECK_HEADER(zlib.h,AC_CHECK_LIB(z, gzopen,,AC_MSG_ERROR(can't find zlib on your system))) dnl UNZIP_SRC="unzip.c unzip.h" dnl LIBOBJS="$LIBOBJS unzip.o" dnl AC_LIBOBJ([unzip]) dnl else dnl UNZIP_SRC="" dnl fi dnl AC_SUBST(UNZIP_SRC) #Opengl Mode AC_ARG_ENABLE(gl,[ --enable-gl enable opengl support], [enablegl=$enableval], [enablegl=yes]) if test "$enablegl" = yes ; then AC_CHECK_HEADER(GL/gl.h,,enablegl=no) AC_CHECK_LIB(GL, glBegin, [LIBS="$LIBS -lGL"; CFLAGS="$CFLAGS -DSDL_GL ";] ,enablegl=no) fi AM_CONDITIONAL(NATIVE_GETOPT_LONG, test "$GETOPT_LONG" = yes) dnl Force Big Endian AC_ARG_ENABLE(big_endian,[ --enable-big-endian Force Big Endian], [enablebig_endian=$enableval], [enablebig_endian=no]) if test "$enablebig_endian" = yes ; then CFLAGS="$CFLAGS -DWORDS_BIGENDIAN "; fi dnl Arch case `uname -m` in *686) arch_info=i686 ;; *i586) arch_info=i586 ;; *i486) arch_info=i486 ;; *i386) arch_info=i386 ;; *sun4u) arch_info=sun4u ;; *) arch_info=no ;; esac AC_MSG_RESULT(Architeture: $arch_info) dnl System sys_info=`uname -s` AC_MSG_RESULT(System: $sys_info) case $arch_info in i686|i586|i486|i386) OPT="-O3 -Wno-unused -funroll-loops -fstrength-reduce \ -ffast-math -falign-functions=2 -falign-jumps=2 \ -falign-loops=2 -fomit-frame-pointer -Wall " ;; sun4u) OPT="-O3 -Wno-unused -funroll-loops -fstrength-reduce \ -ffast-math -falign-functions=4 -falign-jumps=4 \ -falign-loops=4 -fomit-frame-pointer -Wall " ;; no) OPT="-O3 -Wall " ;; esac case $sys_info in SunOS) LDOPT="-lnsl -lsocket -lresolv" ;; esac CFLAGS="$CFLAGS $OPT" LIBS="$LIBS $LDOPT" AC_OUTPUT(Makefile src/Makefile ) gngb-20060309/config.guess0000755000175000017500000012546610233377522013720 0ustar josejose#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. timestamp='2005-04-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; amd64:OpenBSD:*:*) echo x86_64-unknown-openbsd${UNAME_RELEASE} exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; cats:OpenBSD:*:*) echo arm-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; luna88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; macppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mips64-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit 0 ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit 0 ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit 0 ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit 0 ;; *:OS400:*:*) echo powerpc-ibm-os400 exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit 0 ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7 && exit 0 ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c \ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then # avoid double evaluation of $set_cc_for_build test -n "$CC_FOR_BUILD" || eval $set_cc_for_build if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; x86:Interix*:[34]*) echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' exit 0 ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; amd64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit 0 ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit 0 ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit 0 ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit 0 ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit 0 ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in *86) UNAME_PROCESSOR=i686 ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit 0 ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit 0 ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms && exit 0 ;; I*) echo ia64-dec-vms && exit 0 ;; V*) echo vax-dec-vms && exit 0 ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: gngb-20060309/install-sh0000755000175000017500000001273607643033275013404 0ustar josejose#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 gngb-20060309/config.sub0000755000175000017500000007547010233377522013362 0ustar josejose#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. timestamp='2005-04-22' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | msp430 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | msp430-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16c) basic_machine=cr16c-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: gngb-20060309/missing0000755000175000017500000001421307643033275012767 0ustar josejose#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997 Free Software Foundation, Inc. # Franc,ois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing - GNU libit 0.0" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; makeinfo) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 gngb-20060309/mkinstalldirs0000755000175000017500000000132207643033275014173 0ustar josejose#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here gngb-20060309/gngb.10000644000175000017500000001005707703537465012400 0ustar josejose.TH GNGB 1 .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH GNGB gngb \- emulate various Nintendo Game Boy handheld systems .SH SYNOPSIS .B gngb .I [-h] | [options] .SH "DESCRIPTION" .B gngb is an emulator program that attempts to be various forms of Nintendo Game Boy hardware. It can run the various homebrew games and demos for the system as well as images of commercially-released games. .PP This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. .SH OPTIONS The program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options are included below. .TP .B \-h, \-\-help print help and exit .TP .B \-a, \-\-autoframeskip turn on autoframeskip. This is useful if the emulator is running too slow. It will cause the emulator to drop frames every now and then to maintain a realtime emulation. .TP .B \-\-sleep_idle sleep when idle. This will cause the program to sleep when it has idle cycles instead of busy looping. However, this can degrade emulation performance under some circumstances. .TP .B \-\-color_filter turn on the color filter. .TP .B \-r, \-\-rumble turn on the rumble simulation. This will cause the emulated screen to shake when a rumble effect is caused by the running program. .TP .B \-\-filter=X Set the filter to apply. These only work when using standard (not YUV or GL) video output. 0 = none 1 = scanline 2 = scanline 50% 3 = smooth 4 = pseudo cell shading .TP .B \-R, \-\-res=WxH set the screen resolution to WxH (for YUV and GL mode only). .TP .B \-Y, \-\-yuv turn YUV mode on. This utilizes the hardware YUV colorspace conversion and scaling features if your video card supports it. Most video cards with Xv support can use this feature for excellent performance. .TP .B \-\-yuv_type set the type of the YUV overlay: 0 = YV12 1 = YUY2 .TP .B \-o, \-\-opengl turn OpenGL mode on. This will render the gameboy screen as an OpenGL 3D texture, which on some cards may perform much better than the YUV or X11 output. This requires a 3D card with GLX support. .TP .B \-f, \-\-fullscreen run gngb in fullscreen. Fullscreen can be toggled during use with F9. .TP .B \-\-fps Show frames per second counter in the upper left corner of screen. May be toggled through the emulator's menu. .TP .B \-s, \-\-sound Enable sound. .TP .B \-\-sample_rate=RATE Set the sound output sample rate to RATE. (typically a multiple of 11025 Hz) .TP .B \-\-auto_gb Automatically detect the system to emulate based on the cartridge image that is selected. This should work in most cases. If it fails, you can use one of the [ .B \-C, \-\-color_gb | .B \-G, \-\-normal_gb | .B \-S, \-\-super_gb ] options to force emulation of a Color, Normal, or Super Game Boy. .TP .B \-j, \-\-joy_dev=N The default joystick is /dev/js0. By setting N here, /dev/jsN will be used in its place. .TP .B \-g, \-\-gdma_cycle This experimental option will halt the CPU during certain DMA operations. Leave it off unless you are working around problems in a certain program. .TP .B \-v, \-\-version Show version of program. .PP Most options can be disabled whith --no-OPTION (Ex: --no-sound turn sound off) .PP .SH "DEFAULT BINDINGS" These are the default keys in the emulator. These, along with the joystick buttons, may be changed through a custom gngbrc(5) file. .br Enter : Start .br Right Shift : Select .br W : B .br X : A .br TAB : Open menu .P F9 : fullscreen on/off .br F10 : show fps .br F11 : reset .br F12 : show keysym code .P KeyPad 1-5: Change palette .RS Palette must be define in your gngbrc file (see sample_gngbrc) .RE KeyPad 6 : Toggle color filter .SH "SEE ALSO" There is some good info in the README included in the doc directory. The gngbrc file is documented in manual section 5. .SH AUTHOR This manual page was written by RCU , for the Debian GNU/Linux system (but may be used by others). gngb-20060309/Makefile.am0000644000175000017500000000044607706265413013430 0ustar josejoseman_MANS = gngb.1 EXTRA_DIST = $(man_MANS) sample_gngbrc config_win32.h README.WIN32 debian/changelog debian/conffiles.ex debian/copyright debian/docs debian/rules debian/compat debian/control debian/dirs debian/gngb.manpages debian/watch debian/README.Debian debian/README.debian SUBDIRS=src gngb-20060309/Makefile.in0000644000175000017500000003024710476607761013447 0ustar josejose# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am # Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ CC = @CC@ HAVE_LIB = @HAVE_LIB@ LIB = @LIB@ LTLIB = @LTLIB@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ SDL_CONFIG = @SDL_CONFIG@ VERSION = @VERSION@ man_MANS = gngb.1 EXTRA_DIST = $(man_MANS) sample_gngbrc config_win32.h README.WIN32 debian/changelog debian/conffiles.ex debian/copyright debian/docs debian/rules debian/compat debian/control debian/dirs debian/gngb.manpages debian/watch debian/README.Debian debian/README.debian SUBDIRS = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = man1dir = $(mandir)/man1 MANS = $(man_MANS) NROFF = nroff DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ Makefile.am Makefile.in NEWS TODO aclocal.m4 config.guess config.h.in \ config.sub configure configure.in install-sh missing mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) config.h: stamp-h @if test ! -f $@; then \ rm -f stamp-h; \ $(MAKE) stamp-h; \ else :; fi stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES= CONFIG_HEADERS=config.h \ $(SHELL) ./config.status @echo timestamp > stamp-h 2> /dev/null $(srcdir)/config.h.in: $(srcdir)/stamp-h.in @if test ! -f $@; then \ rm -f $(srcdir)/stamp-h.in; \ $(MAKE) $(srcdir)/stamp-h.in; \ else :; fi $(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOHEADER) @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null mostlyclean-hdr: clean-hdr: distclean-hdr: -rm -f config.h maintainer-clean-hdr: install-man1: $(mkinstalldirs) $(DESTDIR)$(man1dir) @list='$(man1_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ done uninstall-man1: @list='$(man1_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ rm -f $(DESTDIR)$(man1dir)/$$inst; \ done install-man: $(MANS) @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-man1 uninstall-man: @$(NORMAL_UNINSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-man1 # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. @SET_MAKE@ all-recursive install-data-recursive install-exec-recursive \ installdirs-recursive install-recursive uninstall-recursive \ check-recursive installcheck-recursive info-recursive dvi-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ dot_seen=no; \ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ rev="$$subdir $$rev"; \ test "$$subdir" != "." || dot_seen=yes; \ done; \ test "$$dot_seen" = "no" && rev=". $$rev"; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP)) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist -rm -rf $(distdir) GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz mkdir $(distdir)/=build mkdir $(distdir)/=inst dc_install_base=`cd $(distdir)/=inst && pwd`; \ cd $(distdir)/=build \ && ../configure --srcdir=.. --prefix=$$dc_install_base \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) dist -rm -rf $(distdir) @banner="$(distdir).tar.gz is ready for distribution"; \ dashes=`echo "$$banner" | sed s/./=/g`; \ echo "$$dashes"; \ echo "$$banner"; \ echo "$$dashes" dist: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) dist-all: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) distdir: $(DISTFILES) -rm -rf $(distdir) mkdir $(distdir) -chmod 777 $(distdir) $(mkinstalldirs) $(distdir)/debian @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done for subdir in $(SUBDIRS); do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ chmod 777 $(distdir)/$$subdir; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ || exit 1; \ fi; \ done info-am: info: info-recursive dvi-am: dvi: dvi-recursive check-am: all-am check: check-recursive installcheck-am: installcheck: installcheck-recursive all-recursive-am: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive install-exec-am: install-exec: install-exec-recursive install-data-am: install-man install-data: install-data-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-recursive uninstall-am: uninstall-man uninstall: uninstall-recursive all-am: Makefile $(MANS) config.h all-redirect: all-recursive-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: installdirs-recursive installdirs-am: $(mkinstalldirs) $(DESTDIR)$(mandir)/man1 mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic mostlyclean: mostlyclean-recursive clean-am: clean-hdr clean-tags clean-generic mostlyclean-am clean: clean-recursive distclean-am: distclean-hdr distclean-tags distclean-generic clean-am distclean: distclean-recursive -rm -f config.status maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-recursive -rm -f config.status .PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ install-man1 uninstall-man1 install-man uninstall-man \ install-data-recursive uninstall-data-recursive install-exec-recursive \ uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ all-recursive check-recursive installcheck-recursive info-recursive \ dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ install-exec-am install-exec install-data-am install-data install-am \ install uninstall-am uninstall all-redirect all-am all installdirs-am \ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: gngb-20060309/README.WIN320000644000175000017500000000022707643033275013051 0ustar josejosebefore trying to compil this under windows, you must rename config_win32.h to config.h and add the current dir to the headers search path (ie: -I. ) gngb-20060309/config_win32.h0000644000175000017500000000017207706265771014037 0ustar josejose#ifndef _CONFIG_H_ #define _CONFIG_H_ #include /* #define SDL_GL */ #define SDL_YUV #define WIN32 1 #endif gngb-20060309/config.h.in0000644000175000017500000000623010347032770013405 0ustar josejose/* config.h.in. Generated from configure.in by autoheader. */ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `getopt_long' function. */ #undef HAVE_GETOPT_LONG /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `bz2' library (-lbz2). */ #undef HAVE_LIBBZ2 /* Define to 1 if you have the `pthread' library (-lpthread). */ #undef HAVE_LIBPTHREAD /* Define to 1 if you have the `SDL' library (-lSDL). */ #undef HAVE_LIBSDL /* Define to 1 if you have the `z' library (-lz). */ #undef HAVE_LIBZ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the `sleep' function. */ #undef HAVE_SLEEP /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN /* Define to empty if `const' does not conform to ANSI C. */ #undef const gngb-20060309/stamp-h.in0000644000175000017500000000001210476607761013266 0ustar josejosetimestamp gngb-20060309/AUTHORS0000644000175000017500000000012607643033275012436 0ustar josejosePeponas Thomas "Frogus" tpeponas@altern.org Peponas Mathieu "Pepone" pepone@altern.orggngb-20060309/sample_gngbrc0000644000175000017500000000256107643033275014121 0ustar josejose# GNGB Sample resource file # Play in fullscreen? fullscreen 0 # Have sound? sound 1 # Shown FPS show_fps 0 # Rumble On ? rumble 1 # filter mode (only for standard mode without sgb) # 0 NONE # 1 SCANLINE # 2 SCANLINE 50% # 3 smooth # 4 pseudo cell shading filter 0 # GL Mode ? glmode 0 gl_size_w 320 gl_size_h 240 # gameboy type # 0 AUTOMATIC # 1 NORMAL GAMEBOY # 2 SUPER GAMEBOY # 4 COLOR GAMEBOY gb_type 0 # autoframeskip control throttle 1 autoframeskip 1 sleep_idle 0 # Interrupt Delay dely_int 0 # Emulate Gdma Cycle ( experimentale ) # Some game like MagicalDrop work better with this options gdma_cycle 0 # Use constant cycle for lcd (try it for Parodius) const_cycle 0 # Joystick number device nb_joy 0 # Joystick configuration # order : AXE_UP,AXE_DOWN,AXE_LEFT,AXE_RIGHT,A,B,START,SELECT map_joy 1,1,0,0,3,2,0,1 # Key configuration # order : AXE_UP,AXE_DOWN,AXE_LEFT,AXE_RIGHT,A,B,START,SELECT # please see SDL_keysym.h for key definition # or push F12 during game and the keysym code of # the key you press will be printed # (you can do the same for the joystick) map_key 273,274,276,275,120,119,13,303 # Normal GB palette (bright to dark) pal_1 0xB8A68D,0x917D5E,0x635030,0x211A10 pal_2 0x79b752,0x507a37,0x324c22,0x0a0f06 pal_3 0x85d1f1,0x5d92b2,0x406483,0x283e5c pal_4 0xFEFEFE,0xA0A0A0,0x606060,0x101010 pal_5 0xebc3b8,0xc07b76,0xa34949,0x632b2b gngb-20060309/INSTALL0000644000175000017500000001722707643033275012431 0ustar josejoseBasic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. gngb-20060309/ChangeLog0000644000175000017500000001012610476607723013144 0ustar josejose WHAT'S NEW ? * Memory.c: Add uspport for Joy Analogique: Thanks to "XWolf" * Clean code (cpu.c suprression des inline) * Compiler: Fix -maligne => faligne Warnings * Now zlib and bzlib recquir 20060117 * Fix gcc4.0 bug. * Julien Delange make a patch to fix build problem on some architecture 20030809 * Add Support for Bzip2 File * Fix a stupid mistake for zip file (on little endian plateform now it work) * Fix ggc 3.3 bug (Ryan Underwood) * Add a man page (Ryan Underwood) * Add buils script for debian package (Ryan Underwood) * Add an configure option --disable-compress-roms 20030509 * Abandon du debuger * Opem Zip File for Roms: zlib now mandatory * comfigure.in: wall -> Wall for unknow system 200302220 (Not Released) * Do not use macro GNGB_BIG_ENDIAN * Use zlib if we can for roms 2002.. * Clean few code * Fix window current_line (only increment when window is on) (Fix PGAEuropean PowerPuff Girl) * Implement a fast read write system (speed increase) * Add a minimal menu system (TAB to open it) (Most switchable option are accessible within it) * SaveState save also a little screenshot * SGB support for YUV modes * Add some filter (--filter=X) such as scanline etc. * Fix sgb border color 0 * Fix Stop Instruction (PC++ => fix konami2 collection) * Add getopt_long support for all platform * Fix a graphic bug with fbdev * Add the possibility to toggle sound on/off during play 20020114 * replace all inline by __inline__ * use #include instead of #include * Better precision in sound playing (digit in PerfectDark sound better) * Add support for getopt_long (ex: --sound) * Add SDL_OVERLAY_YUY2 support (use option yuv_type 1 ) * YUV with normal gameboy now have same color that non-YUV mode * color_filter option added (SDLK_KP6 during game to switch) * Opengl mode now resizable (as YUV) * New option -R WxH : set the resolution for both yuv and opengl (don't use -O anymore) * Fix some problem with the show_fps option * Configure: Fix check sdl-config,gtk-config,glib-config * Configure: now correctly configure endianess on sun4u platform * Debuger: Add a vram window info * Improve FrameSkip code (should be more accurate) * show_fps work even if autoframeskip is off * sleep_idle support added to the new frameskip code 20011212 * Try a new frameskip code * Add YUV Mode Resizable (option -Y) * Clean up Some Code * Fix Segmentation Fault when can't init sound * Fix getenv segfault on some plateform * Fix bit 0x01 when go 2 double speed (demokart work) * Fix LCD int when write to LCDSTAT register (Legend of Zerd Work) 20010813 * Fix interrupt bug (stop halt when make_int and not when set_int) * Add -g option: try to emulate gdma cycle * New Load/Save state (old save don't work) * Add option -y (emulate with constante cycle in lcd emulation) * Try to emulate VicViper Laser in parodius (option -y for better emulation) * Write the begining of a debuger with ncurses * Add ./configure script * Fix divid mode in Sgb support 20010618 * Try to implement sgb window mask * Fix GB_PAD read/write with SGB (PokeJaune and BOMBERMAN works) * Fix RETI instruction (Magical Drop,Megaman5 works) * Add a configuration file (see gngbrc) * Fix an interrupt bug (oracle of season works) * Implement gdma cycle (Magical drop works better but not perfectly) 20010502 * Add MBC3-TIMER card support (i must test it) * Now message info are draw on the screen * Add some SGB features (maybe there is bug with save/load state) 20010318 * Fix EI instruction -> doesn't take effect imediately (bubble91 work) * Fix vblank interrupt -> doesn't take effect imediately :) (addams family work) * toggle fullscreen by F9 * add save/load state (but still experimantale) : shift F(1-8) for save F(1-8) for load * add a opengl mode: -o or -O WxH 20010305 * Fix a gb_pad bug, when pad is off return 0xff ( BOMBERMAN work) * Fix a bug interrupt, update interrupt when write to CMPLINE (Mickey racing work) 20010219 * Length conter of sound mode 3 wasn't working * Timer cycle speed is the same for GB and GBC * "Simulation" of the Rumble, -r for enable it (The screen will shake) gngb-20060309/COPYING0000644000175000017500000004311007643033275012421 0ustar josejose 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 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any 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 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this 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 themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering 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 void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot 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 may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes 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 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 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 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 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 free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.