Try using OG ActiveGS as base for KEGS.

This commit is contained in:
James Sanford 2012-08-10 18:05:53 -07:00
parent f9f4a21ef5
commit 8a164513ec
82 changed files with 33324 additions and 30281 deletions

File diff suppressed because it is too large Load Diff

2958
jni/16inst_s.h Normal file

File diff suppressed because it is too large Load Diff

274
jni/16size_s.h Normal file
View File

@ -0,0 +1,274 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
#ifdef INCLUDE_RCSID_S
.stringz "@(#)$KmKId: size_tab.h,v 1.13 2002-11-19 03:10:38-05 kadickey Exp $"
#else
.word inst00_16 /*1*/ /* brk */
.word inst01_16 /*1*/ /* ORA (Dloc,X) */
.word inst02_16 /*1*/ /* COP */
.word inst03_16 /*1*/ /* ORA Disp8,S */
.word inst04_16 /*1*/ /* TSB Dloc */
.word inst05_16 /*1*/ /* ORA Dloc */
.word inst06_16 /*1*/ /* ASL Dloc */
.word inst07_16 /*1*/ /* ORA [Dloc] */
.word inst08_16 /*0*/ /* PHP */
.word inst09_16 /*4*/ /* ORA #imm */
.word inst0a_16 /*0*/ /* ASL a */
.word inst0b_16 /*0*/ /* PHD */
.word inst0c_16 /*2*/ /* TSB abs */
.word inst0d_16 /*2*/ /* ORA abs */
.word inst0e_16 /*2*/ /* ASL abs */
.word inst0f_16 /*3*/ /* ORA long */
.word inst10_16 /*1*/ /* BPL disp8 */
.word inst11_16 /*1*/ /* ORA (),y */
.word inst12_16 /*1*/ /* ORA () */
.word inst13_16 /*1*/ /* ORA (disp8,s),y */
.word inst14_16 /*1*/ /* TRB Dloc */
.word inst15_16 /*1*/ /* ORA Dloc,x */
.word inst16_16 /*1*/ /* ASL Dloc,x */
.word inst17_16 /*1*/ /* ORA [],y */
.word inst18_16 /*0*/ /* clc */
.word inst19_16 /*2*/ /* ORA abs,y */
.word inst1a_16 /*0*/ /* INC a */
.word inst1b_16 /*0*/ /* TCS */
.word inst1c_16 /*2*/ /* TRB Abs */
.word inst1d_16 /*2*/ /* ORA Abs,X */
.word inst1e_16 /*2*/ /* ASL abs,x */
.word inst1f_16 /*3*/ /* ORA Long,x */
.word inst20_16 /*2*/ /* JSR abs */
.word inst21_16 /*1*/ /* AND (Dloc,X) */
.word inst22_16 /*3*/ /* JSL Abslong */
.word inst23_16 /*1*/ /* AND Disp8,S */
.word inst24_16 /*1*/ /* BIT Dloc */
.word inst25_16 /*1*/ /* AND Dloc */
.word inst26_16 /*1*/ /* ROL Dloc */
.word inst27_16 /*1*/ /* AND [Dloc] */
.word inst28_16 /*0*/ /* PLP */
.word inst29_16 /*4*/ /* AND #imm */
.word inst2a_16 /*0*/ /* ROL a */
.word inst2b_16 /*0*/ /* PLD */
.word inst2c_16 /*2*/ /* BIT abs */
.word inst2d_16 /*2*/ /* AND abs */
.word inst2e_16 /*2*/ /* ROL abs */
.word inst2f_16 /*3*/ /* AND long */
.word inst30_16 /*1*/ /* BMI disp8 */
.word inst31_16 /*1*/ /* AND (),y */
.word inst32_16 /*1*/ /* AND () */
.word inst33_16 /*1*/ /* AND (disp8,s),y */
.word inst34_16 /*1*/ /* BIT Dloc,X */
.word inst35_16 /*1*/ /* AND Dloc,x */
.word inst36_16 /*1*/ /* ROL Dloc,x */
.word inst37_16 /*1*/ /* AND [],y */
.word inst38_16 /*0*/ /* SEC */
.word inst39_16 /*2*/ /* AND abs,y */
.word inst3a_16 /*0*/ /* DEC a */
.word inst3b_16 /*0*/ /* TSC */
.word inst3c_16 /*2*/ /* BIT Abs,X */
.word inst3d_16 /*2*/ /* AND Abs,X */
.word inst3e_16 /*2*/ /* ROL abs,x */
.word inst3f_16 /*3*/ /* AND Long,x */
.word inst40_16 /*0*/ /* RTI */
.word inst41_16 /*1*/ /* EOR (Dloc,X) */
.word inst42_16 /*1*/ /* WDM */
.word inst43_16 /*1*/ /* EOR Disp8,S */
.word inst44_16 /*2*/ /* MVP I,J */
.word inst45_16 /*1*/ /* EOR Dloc */
.word inst46_16 /*1*/ /* LSR Dloc */
.word inst47_16 /*1*/ /* EOR [Dloc] */
.word inst48_16 /*0*/ /* PHA */
.word inst49_16 /*4*/ /* EOR #imm */
.word inst4a_16 /*0*/ /* LSR a */
.word inst4b_16 /*0*/ /* PHK */
.word inst4c_16 /*2*/ /* JMP abs */
.word inst4d_16 /*2*/ /* EOR abs */
.word inst4e_16 /*2*/ /* LSR abs */
.word inst4f_16 /*3*/ /* EOR long */
.word inst50_16 /*1*/ /* BVC disp8 */
.word inst51_16 /*1*/ /* EOR (),y */
.word inst52_16 /*1*/ /* EOR () */
.word inst53_16 /*1*/ /* EOR (disp8,s),y */
.word inst54_16 /*2*/ /* MVN I,J */
.word inst55_16 /*1*/ /* EOR Dloc,x */
.word inst56_16 /*1*/ /* LSR Dloc,x */
.word inst57_16 /*1*/ /* EOR [],y */
.word inst58_16 /*0*/ /* CLI */
.word inst59_16 /*2*/ /* EOR abs,y */
.word inst5a_16 /*0*/ /* PHY */
.word inst5b_16 /*0*/ /* TCD */
.word inst5c_16 /*3*/ /* JMP Long */
.word inst5d_16 /*2*/ /* EOR Abs,X */
.word inst5e_16 /*2*/ /* LSR abs,x */
.word inst5f_16 /*3*/ /* EOR Long,x */
.word inst60_16 /*0*/ /* RTS */
.word inst61_16 /*1*/ /* ADC (Dloc,X) */
.word inst62_16 /*2*/ /* PER DISP16 */
.word inst63_16 /*1*/ /* ADC Disp8,S */
.word inst64_16 /*1*/ /* STZ Dloc */
.word inst65_16 /*1*/ /* ADC Dloc */
.word inst66_16 /*1*/ /* ROR Dloc */
.word inst67_16 /*1*/ /* ADC [Dloc] */
.word inst68_16 /*0*/ /* PLA */
.word inst69_16 /*4*/ /* ADC #imm */
.word inst6a_16 /*0*/ /* ROR a */
.word inst6b_16 /*0*/ /* RTL */
.word inst6c_16 /*2*/ /* JMP (abs) */
.word inst6d_16 /*2*/ /* ADC abs */
.word inst6e_16 /*2*/ /* ROR abs */
.word inst6f_16 /*3*/ /* ADC long */
.word inst70_16 /*1*/ /* BVS disp8 */
.word inst71_16 /*1*/ /* ADC (),y */
.word inst72_16 /*1*/ /* ADC () */
.word inst73_16 /*1*/ /* ADC (disp8,s),y */
.word inst74_16 /*1*/ /* STZ Dloc,X */
.word inst75_16 /*1*/ /* ADC Dloc,x */
.word inst76_16 /*1*/ /* ROR Dloc,x */
.word inst77_16 /*1*/ /* ADC [],y */
.word inst78_16 /*0*/ /* SEI */
.word inst79_16 /*2*/ /* ADC abs,y */
.word inst7a_16 /*0*/ /* PLY */
.word inst7b_16 /*0*/ /* TDC */
.word inst7c_16 /*2*/ /* JMP (abs,x) */
.word inst7d_16 /*2*/ /* ADC Abs,X */
.word inst7e_16 /*2*/ /* ROR abs,x */
.word inst7f_16 /*3*/ /* ADC Long,x */
.word inst80_16 /*1*/ /* BRA Disp8 */
.word inst81_16 /*1*/ /* STA (Dloc,X) */
.word inst82_16 /*2*/ /* BRL DISP16 */
.word inst83_16 /*1*/ /* STA Disp8,S */
.word inst84_16 /*1*/ /* STY Dloc */
.word inst85_16 /*1*/ /* STA Dloc */
.word inst86_16 /*1*/ /* STX Dloc */
.word inst87_16 /*1*/ /* STA [Dloc] */
.word inst88_16 /*0*/ /* DEY */
.word inst89_16 /*4*/ /* BIT #imm */
.word inst8a_16 /*0*/ /* TXA */
.word inst8b_16 /*0*/ /* PHB */
.word inst8c_16 /*2*/ /* STY abs */
.word inst8d_16 /*2*/ /* STA abs */
.word inst8e_16 /*2*/ /* STX abs */
.word inst8f_16 /*3*/ /* STA long */
.word inst90_16 /*1*/ /* BCC disp8 */
.word inst91_16 /*1*/ /* STA (),y */
.word inst92_16 /*1*/ /* STA () */
.word inst93_16 /*1*/ /* STA (disp8,s),y */
.word inst94_16 /*1*/ /* STY Dloc,X */
.word inst95_16 /*1*/ /* STA Dloc,x */
.word inst96_16 /*1*/ /* STX Dloc,y */
.word inst97_16 /*1*/ /* STA [],y */
.word inst98_16 /*0*/ /* TYA */
.word inst99_16 /*2*/ /* STA abs,y */
.word inst9a_16 /*0*/ /* TXS */
.word inst9b_16 /*0*/ /* TXY */
.word inst9c_16 /*2*/ /* STX abs */
.word inst9d_16 /*2*/ /* STA Abs,X */
.word inst9e_16 /*2*/ /* STZ abs,x */
.word inst9f_16 /*3*/ /* STA Long,x */
.word insta0_16 /*5*/ /* LDY #imm */
.word insta1_16 /*1*/ /* LDA (Dloc,X) */
.word insta2_16 /*5*/ /* LDX #imm */
.word insta3_16 /*1*/ /* LDA Disp8,S */
.word insta4_16 /*1*/ /* LDY Dloc */
.word insta5_16 /*1*/ /* LDA Dloc */
.word insta6_16 /*1*/ /* LDX Dloc */
.word insta7_16 /*1*/ /* LDA [Dloc] */
.word insta8_16 /*0*/ /* TAY */
.word insta9_16 /*4*/ /* LDA #imm */
.word instaa_16 /*0*/ /* TAX */
.word instab_16 /*0*/ /* PLB */
.word instac_16 /*2*/ /* LDY abs */
.word instad_16 /*2*/ /* LDA abs */
.word instae_16 /*2*/ /* LDX abs */
.word instaf_16 /*3*/ /* LDA long */
.word instb0_16 /*1*/ /* BCS disp8 */
.word instb1_16 /*1*/ /* LDA (),y */
.word instb2_16 /*1*/ /* LDA () */
.word instb3_16 /*1*/ /* LDA (disp8,s),y */
.word instb4_16 /*1*/ /* LDY Dloc,X */
.word instb5_16 /*1*/ /* LDA Dloc,x */
.word instb6_16 /*1*/ /* LDX Dloc,y */
.word instb7_16 /*1*/ /* LDA [],y */
.word instb8_16 /*0*/ /* CLV */
.word instb9_16 /*2*/ /* LDA abs,y */
.word instba_16 /*0*/ /* TSX */
.word instbb_16 /*0*/ /* TYX */
.word instbc_16 /*2*/ /* LDY abs,x */
.word instbd_16 /*2*/ /* LDA Abs,X */
.word instbe_16 /*2*/ /* LDX abs,y */
.word instbf_16 /*3*/ /* LDA Long,x */
.word instc0_16 /*5*/ /* CPY #Imm */
.word instc1_16 /*1*/ /* CMP (Dloc,X) */
.word instc2_16 /*1*/ /* REP #8bit */
.word instc3_16 /*1*/ /* CMP Disp8,S */
.word instc4_16 /*1*/ /* CPY Dloc */
.word instc5_16 /*1*/ /* CMP Dloc */
.word instc6_16 /*1*/ /* DEC Dloc */
.word instc7_16 /*1*/ /* CMP [Dloc] */
.word instc8_16 /*0*/ /* INY */
.word instc9_16 /*4*/ /* CMP #imm */
.word instca_16 /*0*/ /* DEX */
.word instcb_16 /*0*/ /* WAI */
.word instcc_16 /*2*/ /* CPY abs */
.word instcd_16 /*2*/ /* CMP abs */
.word instce_16 /*2*/ /* DEC abs */
.word instcf_16 /*3*/ /* CMP long */
.word instd0_16 /*1*/ /* BNE disp8 */
.word instd1_16 /*1*/ /* CMP (),y */
.word instd2_16 /*1*/ /* CMP () */
.word instd3_16 /*1*/ /* CMP (disp8,s),y */
.word instd4_16 /*1*/ /* PEI Dloc */
.word instd5_16 /*1*/ /* CMP Dloc,x */
.word instd6_16 /*1*/ /* DEC Dloc,x */
.word instd7_16 /*1*/ /* CMP [],y */
.word instd8_16 /*0*/ /* CLD */
.word instd9_16 /*2*/ /* CMP abs,y */
.word instda_16 /*0*/ /* PHX */
.word instdb_16 /*0*/ /* STP */
.word instdc_16 /*2*/ /* JML (Abs) */
.word instdd_16 /*2*/ /* CMP Abs,X */
.word instde_16 /*2*/ /* DEC abs,x */
.word instdf_16 /*3*/ /* CMP Long,x */
.word inste0_16 /*5*/ /* CPX #Imm */
.word inste1_16 /*1*/ /* SBC (Dloc,X) */
.word inste2_16 /*1*/ /* SEP #8bit */
.word inste3_16 /*1*/ /* SBC Disp8,S */
.word inste4_16 /*1*/ /* CPX Dloc */
.word inste5_16 /*1*/ /* SBC Dloc */
.word inste6_16 /*1*/ /* INC Dloc */
.word inste7_16 /*1*/ /* SBC [Dloc] */
.word inste8_16 /*0*/ /* INX */
.word inste9_16 /*4*/ /* SBC #imm */
.word instea_16 /*0*/ /* NOP */
.word insteb_16 /*0*/ /* XBA */
.word instec_16 /*2*/ /* CPX abs */
.word insted_16 /*2*/ /* SBC abs */
.word instee_16 /*2*/ /* INC abs */
.word instef_16 /*3*/ /* SBC long */
.word instf0_16 /*1*/ /* BEQ disp8 */
.word instf1_16 /*1*/ /* SBC (),y */
.word instf2_16 /*1*/ /* SBC () */
.word instf3_16 /*1*/ /* SBC (disp8,s),y */
.word instf4_16 /*2*/ /* PEA Imm */
.word instf5_16 /*1*/ /* SBC Dloc,x */
.word instf6_16 /*1*/ /* INC Dloc,x */
.word instf7_16 /*1*/ /* SBC [],y */
.word instf8_16 /*0*/ /* SED */
.word instf9_16 /*2*/ /* SBC abs,y */
.word instfa_16 /*0*/ /* PLX */
.word instfb_16 /*0*/ /* XCE */
.word instfc_16 /*2*/ /* JSR (Abs,x) */
.word instfd_16 /*2*/ /* SBC Abs,X */
.word instfe_16 /*2*/ /* INC abs,x */
.word instff_16 /*3*/ /* SBC Long,x */
.block 4*16
#endif

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

2958
jni/8inst_s.h Normal file

File diff suppressed because it is too large Load Diff

274
jni/8size_s.h Normal file
View File

@ -0,0 +1,274 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
#ifdef INCLUDE_RCSID_S
.stringz "@(#)$KmKId: size_tab.h,v 1.13 2002-11-19 03:10:38-05 kadickey Exp $"
#else
.word inst00_8 /*1*/ /* brk */
.word inst01_8 /*1*/ /* ORA (Dloc,X) */
.word inst02_8 /*1*/ /* COP */
.word inst03_8 /*1*/ /* ORA Disp8,S */
.word inst04_8 /*1*/ /* TSB Dloc */
.word inst05_8 /*1*/ /* ORA Dloc */
.word inst06_8 /*1*/ /* ASL Dloc */
.word inst07_8 /*1*/ /* ORA [Dloc] */
.word inst08_8 /*0*/ /* PHP */
.word inst09_8 /*4*/ /* ORA #imm */
.word inst0a_8 /*0*/ /* ASL a */
.word inst0b_8 /*0*/ /* PHD */
.word inst0c_8 /*2*/ /* TSB abs */
.word inst0d_8 /*2*/ /* ORA abs */
.word inst0e_8 /*2*/ /* ASL abs */
.word inst0f_8 /*3*/ /* ORA long */
.word inst10_8 /*1*/ /* BPL disp8 */
.word inst11_8 /*1*/ /* ORA (),y */
.word inst12_8 /*1*/ /* ORA () */
.word inst13_8 /*1*/ /* ORA (disp8,s),y */
.word inst14_8 /*1*/ /* TRB Dloc */
.word inst15_8 /*1*/ /* ORA Dloc,x */
.word inst16_8 /*1*/ /* ASL Dloc,x */
.word inst17_8 /*1*/ /* ORA [],y */
.word inst18_8 /*0*/ /* clc */
.word inst19_8 /*2*/ /* ORA abs,y */
.word inst1a_8 /*0*/ /* INC a */
.word inst1b_8 /*0*/ /* TCS */
.word inst1c_8 /*2*/ /* TRB Abs */
.word inst1d_8 /*2*/ /* ORA Abs,X */
.word inst1e_8 /*2*/ /* ASL abs,x */
.word inst1f_8 /*3*/ /* ORA Long,x */
.word inst20_8 /*2*/ /* JSR abs */
.word inst21_8 /*1*/ /* AND (Dloc,X) */
.word inst22_8 /*3*/ /* JSL Abslong */
.word inst23_8 /*1*/ /* AND Disp8,S */
.word inst24_8 /*1*/ /* BIT Dloc */
.word inst25_8 /*1*/ /* AND Dloc */
.word inst26_8 /*1*/ /* ROL Dloc */
.word inst27_8 /*1*/ /* AND [Dloc] */
.word inst28_8 /*0*/ /* PLP */
.word inst29_8 /*4*/ /* AND #imm */
.word inst2a_8 /*0*/ /* ROL a */
.word inst2b_8 /*0*/ /* PLD */
.word inst2c_8 /*2*/ /* BIT abs */
.word inst2d_8 /*2*/ /* AND abs */
.word inst2e_8 /*2*/ /* ROL abs */
.word inst2f_8 /*3*/ /* AND long */
.word inst30_8 /*1*/ /* BMI disp8 */
.word inst31_8 /*1*/ /* AND (),y */
.word inst32_8 /*1*/ /* AND () */
.word inst33_8 /*1*/ /* AND (disp8,s),y */
.word inst34_8 /*1*/ /* BIT Dloc,X */
.word inst35_8 /*1*/ /* AND Dloc,x */
.word inst36_8 /*1*/ /* ROL Dloc,x */
.word inst37_8 /*1*/ /* AND [],y */
.word inst38_8 /*0*/ /* SEC */
.word inst39_8 /*2*/ /* AND abs,y */
.word inst3a_8 /*0*/ /* DEC a */
.word inst3b_8 /*0*/ /* TSC */
.word inst3c_8 /*2*/ /* BIT Abs,X */
.word inst3d_8 /*2*/ /* AND Abs,X */
.word inst3e_8 /*2*/ /* ROL abs,x */
.word inst3f_8 /*3*/ /* AND Long,x */
.word inst40_8 /*0*/ /* RTI */
.word inst41_8 /*1*/ /* EOR (Dloc,X) */
.word inst42_8 /*1*/ /* WDM */
.word inst43_8 /*1*/ /* EOR Disp8,S */
.word inst44_8 /*2*/ /* MVP I,J */
.word inst45_8 /*1*/ /* EOR Dloc */
.word inst46_8 /*1*/ /* LSR Dloc */
.word inst47_8 /*1*/ /* EOR [Dloc] */
.word inst48_8 /*0*/ /* PHA */
.word inst49_8 /*4*/ /* EOR #imm */
.word inst4a_8 /*0*/ /* LSR a */
.word inst4b_8 /*0*/ /* PHK */
.word inst4c_8 /*2*/ /* JMP abs */
.word inst4d_8 /*2*/ /* EOR abs */
.word inst4e_8 /*2*/ /* LSR abs */
.word inst4f_8 /*3*/ /* EOR long */
.word inst50_8 /*1*/ /* BVC disp8 */
.word inst51_8 /*1*/ /* EOR (),y */
.word inst52_8 /*1*/ /* EOR () */
.word inst53_8 /*1*/ /* EOR (disp8,s),y */
.word inst54_8 /*2*/ /* MVN I,J */
.word inst55_8 /*1*/ /* EOR Dloc,x */
.word inst56_8 /*1*/ /* LSR Dloc,x */
.word inst57_8 /*1*/ /* EOR [],y */
.word inst58_8 /*0*/ /* CLI */
.word inst59_8 /*2*/ /* EOR abs,y */
.word inst5a_8 /*0*/ /* PHY */
.word inst5b_8 /*0*/ /* TCD */
.word inst5c_8 /*3*/ /* JMP Long */
.word inst5d_8 /*2*/ /* EOR Abs,X */
.word inst5e_8 /*2*/ /* LSR abs,x */
.word inst5f_8 /*3*/ /* EOR Long,x */
.word inst60_8 /*0*/ /* RTS */
.word inst61_8 /*1*/ /* ADC (Dloc,X) */
.word inst62_8 /*2*/ /* PER DISP16 */
.word inst63_8 /*1*/ /* ADC Disp8,S */
.word inst64_8 /*1*/ /* STZ Dloc */
.word inst65_8 /*1*/ /* ADC Dloc */
.word inst66_8 /*1*/ /* ROR Dloc */
.word inst67_8 /*1*/ /* ADC [Dloc] */
.word inst68_8 /*0*/ /* PLA */
.word inst69_8 /*4*/ /* ADC #imm */
.word inst6a_8 /*0*/ /* ROR a */
.word inst6b_8 /*0*/ /* RTL */
.word inst6c_8 /*2*/ /* JMP (abs) */
.word inst6d_8 /*2*/ /* ADC abs */
.word inst6e_8 /*2*/ /* ROR abs */
.word inst6f_8 /*3*/ /* ADC long */
.word inst70_8 /*1*/ /* BVS disp8 */
.word inst71_8 /*1*/ /* ADC (),y */
.word inst72_8 /*1*/ /* ADC () */
.word inst73_8 /*1*/ /* ADC (disp8,s),y */
.word inst74_8 /*1*/ /* STZ Dloc,X */
.word inst75_8 /*1*/ /* ADC Dloc,x */
.word inst76_8 /*1*/ /* ROR Dloc,x */
.word inst77_8 /*1*/ /* ADC [],y */
.word inst78_8 /*0*/ /* SEI */
.word inst79_8 /*2*/ /* ADC abs,y */
.word inst7a_8 /*0*/ /* PLY */
.word inst7b_8 /*0*/ /* TDC */
.word inst7c_8 /*2*/ /* JMP (abs,x) */
.word inst7d_8 /*2*/ /* ADC Abs,X */
.word inst7e_8 /*2*/ /* ROR abs,x */
.word inst7f_8 /*3*/ /* ADC Long,x */
.word inst80_8 /*1*/ /* BRA Disp8 */
.word inst81_8 /*1*/ /* STA (Dloc,X) */
.word inst82_8 /*2*/ /* BRL DISP16 */
.word inst83_8 /*1*/ /* STA Disp8,S */
.word inst84_8 /*1*/ /* STY Dloc */
.word inst85_8 /*1*/ /* STA Dloc */
.word inst86_8 /*1*/ /* STX Dloc */
.word inst87_8 /*1*/ /* STA [Dloc] */
.word inst88_8 /*0*/ /* DEY */
.word inst89_8 /*4*/ /* BIT #imm */
.word inst8a_8 /*0*/ /* TXA */
.word inst8b_8 /*0*/ /* PHB */
.word inst8c_8 /*2*/ /* STY abs */
.word inst8d_8 /*2*/ /* STA abs */
.word inst8e_8 /*2*/ /* STX abs */
.word inst8f_8 /*3*/ /* STA long */
.word inst90_8 /*1*/ /* BCC disp8 */
.word inst91_8 /*1*/ /* STA (),y */
.word inst92_8 /*1*/ /* STA () */
.word inst93_8 /*1*/ /* STA (disp8,s),y */
.word inst94_8 /*1*/ /* STY Dloc,X */
.word inst95_8 /*1*/ /* STA Dloc,x */
.word inst96_8 /*1*/ /* STX Dloc,y */
.word inst97_8 /*1*/ /* STA [],y */
.word inst98_8 /*0*/ /* TYA */
.word inst99_8 /*2*/ /* STA abs,y */
.word inst9a_8 /*0*/ /* TXS */
.word inst9b_8 /*0*/ /* TXY */
.word inst9c_8 /*2*/ /* STX abs */
.word inst9d_8 /*2*/ /* STA Abs,X */
.word inst9e_8 /*2*/ /* STZ abs,x */
.word inst9f_8 /*3*/ /* STA Long,x */
.word insta0_8 /*5*/ /* LDY #imm */
.word insta1_8 /*1*/ /* LDA (Dloc,X) */
.word insta2_8 /*5*/ /* LDX #imm */
.word insta3_8 /*1*/ /* LDA Disp8,S */
.word insta4_8 /*1*/ /* LDY Dloc */
.word insta5_8 /*1*/ /* LDA Dloc */
.word insta6_8 /*1*/ /* LDX Dloc */
.word insta7_8 /*1*/ /* LDA [Dloc] */
.word insta8_8 /*0*/ /* TAY */
.word insta9_8 /*4*/ /* LDA #imm */
.word instaa_8 /*0*/ /* TAX */
.word instab_8 /*0*/ /* PLB */
.word instac_8 /*2*/ /* LDY abs */
.word instad_8 /*2*/ /* LDA abs */
.word instae_8 /*2*/ /* LDX abs */
.word instaf_8 /*3*/ /* LDA long */
.word instb0_8 /*1*/ /* BCS disp8 */
.word instb1_8 /*1*/ /* LDA (),y */
.word instb2_8 /*1*/ /* LDA () */
.word instb3_8 /*1*/ /* LDA (disp8,s),y */
.word instb4_8 /*1*/ /* LDY Dloc,X */
.word instb5_8 /*1*/ /* LDA Dloc,x */
.word instb6_8 /*1*/ /* LDX Dloc,y */
.word instb7_8 /*1*/ /* LDA [],y */
.word instb8_8 /*0*/ /* CLV */
.word instb9_8 /*2*/ /* LDA abs,y */
.word instba_8 /*0*/ /* TSX */
.word instbb_8 /*0*/ /* TYX */
.word instbc_8 /*2*/ /* LDY abs,x */
.word instbd_8 /*2*/ /* LDA Abs,X */
.word instbe_8 /*2*/ /* LDX abs,y */
.word instbf_8 /*3*/ /* LDA Long,x */
.word instc0_8 /*5*/ /* CPY #Imm */
.word instc1_8 /*1*/ /* CMP (Dloc,X) */
.word instc2_8 /*1*/ /* REP #8bit */
.word instc3_8 /*1*/ /* CMP Disp8,S */
.word instc4_8 /*1*/ /* CPY Dloc */
.word instc5_8 /*1*/ /* CMP Dloc */
.word instc6_8 /*1*/ /* DEC Dloc */
.word instc7_8 /*1*/ /* CMP [Dloc] */
.word instc8_8 /*0*/ /* INY */
.word instc9_8 /*4*/ /* CMP #imm */
.word instca_8 /*0*/ /* DEX */
.word instcb_8 /*0*/ /* WAI */
.word instcc_8 /*2*/ /* CPY abs */
.word instcd_8 /*2*/ /* CMP abs */
.word instce_8 /*2*/ /* DEC abs */
.word instcf_8 /*3*/ /* CMP long */
.word instd0_8 /*1*/ /* BNE disp8 */
.word instd1_8 /*1*/ /* CMP (),y */
.word instd2_8 /*1*/ /* CMP () */
.word instd3_8 /*1*/ /* CMP (disp8,s),y */
.word instd4_8 /*1*/ /* PEI Dloc */
.word instd5_8 /*1*/ /* CMP Dloc,x */
.word instd6_8 /*1*/ /* DEC Dloc,x */
.word instd7_8 /*1*/ /* CMP [],y */
.word instd8_8 /*0*/ /* CLD */
.word instd9_8 /*2*/ /* CMP abs,y */
.word instda_8 /*0*/ /* PHX */
.word instdb_8 /*0*/ /* STP */
.word instdc_8 /*2*/ /* JML (Abs) */
.word instdd_8 /*2*/ /* CMP Abs,X */
.word instde_8 /*2*/ /* DEC abs,x */
.word instdf_8 /*3*/ /* CMP Long,x */
.word inste0_8 /*5*/ /* CPX #Imm */
.word inste1_8 /*1*/ /* SBC (Dloc,X) */
.word inste2_8 /*1*/ /* SEP #8bit */
.word inste3_8 /*1*/ /* SBC Disp8,S */
.word inste4_8 /*1*/ /* CPX Dloc */
.word inste5_8 /*1*/ /* SBC Dloc */
.word inste6_8 /*1*/ /* INC Dloc */
.word inste7_8 /*1*/ /* SBC [Dloc] */
.word inste8_8 /*0*/ /* INX */
.word inste9_8 /*4*/ /* SBC #imm */
.word instea_8 /*0*/ /* NOP */
.word insteb_8 /*0*/ /* XBA */
.word instec_8 /*2*/ /* CPX abs */
.word insted_8 /*2*/ /* SBC abs */
.word instee_8 /*2*/ /* INC abs */
.word instef_8 /*3*/ /* SBC long */
.word instf0_8 /*1*/ /* BEQ disp8 */
.word instf1_8 /*1*/ /* SBC (),y */
.word instf2_8 /*1*/ /* SBC () */
.word instf3_8 /*1*/ /* SBC (disp8,s),y */
.word instf4_8 /*2*/ /* PEA Imm */
.word instf5_8 /*1*/ /* SBC Dloc,x */
.word instf6_8 /*1*/ /* INC Dloc,x */
.word instf7_8 /*1*/ /* SBC [],y */
.word instf8_8 /*0*/ /* SED */
.word instf9_8 /*2*/ /* SBC abs,y */
.word instfa_8 /*0*/ /* PLX */
.word instfb_8 /*0*/ /* XCE */
.word instfc_8 /*2*/ /* JSR (Abs,x) */
.word instfd_8 /*2*/ /* SBC Abs,X */
.word instfe_8 /*2*/ /* INC abs,x */
.word instff_8 /*3*/ /* SBC Long,x */
.block 4*16
#endif

View File

@ -4,8 +4,8 @@ include $(CLEAR_VARS)
LOCAL_CFLAGS := -DNDEBUG -DKEGS_LITTLE_ENDIAN -O2 -I.
LOCAL_MODULE := kegs
LOCAL_SRC_FILES := adb.c clock.c config.c dis.c engine_c.c scc.c iwm.c \
joystick_driver.c moremem.c paddles.c sim65816.c smartport.c \
LOCAL_SRC_FILES := adb.c clock.c config_generic.c config_kegs.c dis.c engine_c.c scc.c iwm.c \
joystick_dummy.c moremem.c paddles.c sim65816.c smartport.c \
sound.c sound_driver.c video.c scc_socket_driver.c scc_windriver.c \
scc_macdriver.c android_driver.c android_sound_driver.c
LOCAL_LDLIBS := -lm -llog -ljnigraphics -lOpenSLES

View File

@ -1,280 +0,0 @@
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

View File

@ -1,239 +0,0 @@
KEGS's Apple //gs IWM emulation routines.
The IWM code does 5.25" and 3.5" reads & writes, and updates the Unix disk
image on writes. It is also nearly cycle-accurate--Let me know if you
have a program which can detect it's not a real Apple II. There are
a few 5.25" features missing (No 1/4 or 1/2 tracks, no support for Unix nibble
images, limited disk switching), but what's there is pretty accurate.
The low-level code support 1/4 and 1/2 tracks--it's the arm movement
and image-handling routines which don't. And lack of Unix nibble images
are also due to lack of higher-level routines to make those features work.
How my disk emulation works: The routines have a nibblized image of each
track of each drive (two 5.25" and two 3.5" drives are supported) in memory.
The nibble images are declared as arrays, but it could be made to use
more dynamic memory allocation.
Each track's data format is a series of two-byte pairs. The first byte
of the pair is the number of bits in this disk byte, and the second byte
is the value. So a size of 8 is normal. A size of 10 means that there
are 2 sync bits written before this byte on the disk. So for 5.25" disk
accesses, 40 cycles need to pass in the simulator before providing a
valid nibble. Partial nibbles are correctly formed if a read happens
too early (this actually makes things slower, but is required if you
want to make nibble copiers work). Similarly, writing to the disk
watches timing carefully to write out the correct number of bits per
disk byte. These routines will definitely test out your emulator's cycle
counting ability.
If a long delay occurs between a read (or a write) the routines skips
the correct number of bits to return the correctly formed disk byte.
After a long delay, for efficiency, I always return a full disk byte,
instead of a partial one, even if the timing would put it in the middle
of a disk byte.
The arm stepping is really lame. I will clean it up soon.
Smartport support is sufficient to claim that there are no smartport
devices. This is necessary since the ROM tries to see if there are
smartport devices at power-on.
I tested my 5.25" drive routines on EDD, which could correctly measure
drive speed and other disk factors. I also nibble-copied some disks,
which also worked fine. I tested the 3.5" routines using Copy II+,
which successfully nibble-copied several disks.
Code description:
Most code is in iwm.c, with some defines in iwm.h, and some stuff in
iwm_35_525.h.
Code only supports DOS3.3 ordered 5.25" images now, and ProDOS-ordered 3.5"
images. Well, the code supports ProDOS-order 5.25" also, but has no
mechanism to tell it an image is prodos-order yet. :-)
Iwm state is encoded in the Iwm structure.
drive525[2]: Disk structure for each 5.25" disk
drive35[2]: Disk structure for each 3.5" disk
smarport[32]: Disk structure for each "smartport" device emulated
via slot 7 (this code not included)
motor_on: True if IWM motor_on signal (c0e9) is asserted. Some
drive is on.
motor_off: True if motor has been turned off in software, but the
1 second timeout has not expired yet.
motor_on35: True if 3.5" motor is on (controlled differently than
5.25" c0e9).
motor_off_vbl_count: VBL count to turn motor off.
head35, step_direction35: 3.5" controls, useless.
iwm_phase[4]: Has '1' for each 5.25" phase that is on.
iwm_mode: IWM mode register.
drive_select: 0 = drive 1, 1 = drive 2.
q6, q7: IWM q6, q7 registers.
enable2: Smartport /ENABLE2 asserted.
reset: Smartport /RESET asserted.
previous_write_val: Partial write value.
previous_write_bits: How many bits are valid in previous_write_val.
Each disk (3.5" and 5.25") is encoded in the Disk struct:
fd: Unix file descriptor. If < 0, no disk.
name_ptr: Unix file name for this disk.
image_start: offset from beginning of file for this partition.
image_size: size of this partition.
smartport: 1 if this is a smartport image, 0 if it is 5.25" or 3.5"
disk_525: 1 if this is a 5.25" image, 0 if it is 3.5"
drive: 0 = drive 1, 1 = drive 2.
cur_qtr_track: Current qtr track. So track 1 == qtr_track 4.
For 3.5", cur_qtr_track encodes the side also, so track 3
side 1 would be qtr_track 7.
prodos_order: True if Unix image is ProDOS order.
vol_num: DOS3.3 volume number to use. Always 254.
write_prot: True if disk is write protected.
write_through_to_unix: True if writes should be passed through to
the unix image. If this is false, you can write
to the image in memory, but it won't get reflected
into the Unix file. If you create a non-DOS3.3
or ProDOS format image, it automatically sets this
false.
disk_dirty: Some track has dirty data that need to be flushed.
just_ejected: Ejection flag.
dcycs_last_read: Cycle count of last disk data register access.
last_phase: Phase number last accessed.
nib_pos: Nibble offset ptr--points to a byte.
num_tracks: Number of tracks: 140 for 5.25" and 160 for 3.5"
track[MAX_TRACKS]: nibble image of all possible tracks.
Each track is represented by the Track structure:
track_dirty: Contains data that needs to be written back to
the Unix image file.
overflow_size: Count of overflow bits, used in writing.
track_len: Number of nibbles on this track.
dsk: Handy pointer to parent Disk structure.
nib_area[]: ptr to memory containing pairs of [size,data],
encoding disk data bytes.
pad1: If the structure is 32 bytes long, some array
indexing is done better by my compiler.
Externally callable routines:
iwm_init(): Init various data structures at simulation start.
iwm_reset(): Called at Apple //gs reset time.
iwm_vbl_update(): Called every VBL (60 Hz) period. Used to turn motor
off, and flush out dirty data.
g_vbl_count is the count of VBL ticks (so it counts
at 60 times a second).
iwm_read_c0ec(double dcycs): Optimized routine to handle reading $C0EC
faster. Exactly the same as read_iwm(0xc, dcycs);
read_iwm(loc, dcycs):
Read from 0xc0e0 + loc. Loc is between 0x0 and 0xf.
Dcycs is an artifact from my simulator. Dcycs is a
double holding the number of Apple //gs cycles since the
emulator started. Dcycs always counts at 1.024MHz. If
you are running at 2.5MHz, it increments by 0.4 every
"cycle". This is a very convenient timing strategy. It
also allows emulating the delay caused by synchronizing
the fast part of a real Apple //gs with slow memory,
which means my emulator knows that reading softswitches
takes longer than reading fast memory.
write_iwm(int loc, int val, double dcycs):
Write to 0xc0e0 + loc. Just like read_iwm, but write "val" into
loc.
Tricky routines:
IWM_READ_ROUT(): called by read_iwm() if q6,q7 = 0,0.
This is actually in the file iwm_35_525.h. This is so I
write the basic code once for 5.25" and 3.5" disk reads,
but then include the file with some macros set to create
the correct function optimized for 5.25" or 3.5"
accesses. The function for 5.25" is called
iwm_read_data_525, and iwm_read_data_35 for 3.5".
Returns next disk byte.
Takes three arguments: ptr to the Disk structure for
the active drive, fast_disk_emul, and dcycs. dcycs is
so that it can see how many cycles have passed since
the last read (stored in dsk->dcycs_last_read).
16.0 dcycs need to pass for an 8 bit nibble for 3.5"
accesses, and 32.0 dcycs for an 8 bit nibble for 5.25".
Fast_disk_emul == 1 says don't mess around with accuracy,
and always return the next fully-formed nibble.
There is a lot of complexity in this routine. All IWM
routines must skip over nibbles (stored as byte pairs in
dsk->nib_area[]) which have a size of 0 (special padding
trick, described later). It then determines how much
time has passed, and so how many bits are valid.
If too many bits have gone by (11 cycs is almost 3 5.25"
bit times, which is about the nibble valid time in
the Apple //gs IWM hardware latch), it tries to skip
to the correct position.
Handles IWM latch mode for 3.5" or 5.25" accesses. If a
partial read is indicated, it ensures that the high bit
is clear by shifting the nibble to the right
appropriately. Again, nib_area[] is an array of bytes,
which are treated as pairs. Byte 0 = size, byte 1 =
disk nibble.
IWM_WRITE_ROUT(): called by write_iwm() if q6,q7 = 1,1.
Similar to above. Handles async and sync mode writes.
Handles partial writes. Handles the ROM writing
0xff, 0x3f, 0xcf, 0xf3, 0xfc to be four 10-bit nibbles.
Routine disk_nib_out(dsk, val, bits_read) does the
actual work of merging the bits into the track image.
disk_nib_out(): called by IWM_WRITE_ROUTE() and iwm_nibblize_track_*().
Writes byte into nib_area[]. If size > 10, makes it 10.
If high order bit not set, it sets it (makes certain routines
in EDD happy).
overflow_size:
Writing to the disk creates some problems. I need to
maintain 2 things at all times on the track:
1) Constant number of bits for the entire track.
2) know where each synchronized byte starts on
the track.
If the track was just stored as raw bits, then correctly
simulating a delay of 300*4 cycles is tough, since it has to
be done by reading through all 300 bits on the track,
so that we keep in sync with where bytes really start.
But if you just store the bytes themselves, then sync
bytes look like every other byte. And if you now add
the size field, you have a situation where a track could
gain or lose bits when rewritten. Here's the case:
Assume the track contains: 10,ff 10,ff 10,ff 10,ff.
(That is 4 self-sync disk bytes of 10 bits each).
If we rewrite that area of the track with 'D5 AA 96 FF',
where each byte is 8 bits, we would have:
8,D5 8,AA, 8,96, 8,FF.
Looks OK, but we just lost 8 bits! The original 4 nibbles
were using 40 bits of space on the disk. Our new 4 nibbles
are using 32 bits. 8 bits are lost.
Solution: log these missing bits via overflow_size.
When writing, if overflow_size gets > 8, force out a 0,0
nibble. So sync bytes get written as:
10,FF 10,FF 10,FF 10,FF 0,0 10,FF 10,FF 10,FF 10,FF, 0,0.
So when they get re-written with 8,xx, we don't lose any
bytes on the disk.
Unfortunately, it doesn't quite work that easily, and bits
can still be lost when sync fields are partially overwritten.
This happens when all the 0,0's end up in a place on the
track where few overwrites occur, but other sync bytes
are being turned into 8,xx. So overflow_size goes negative,
saying we've got too much on the track.
The code prints an error when it gains more than 64 bits.
If someone can come up with a better scheme, I'd love to
hear it. A partial solution would be to have a routine
re-space the track to spread the needed 0,0's around
a little better when overflow_size gets too negative.
In iwm_nibblize_track_35(), the comments with hex numbers correspond
to the ROM 01 addresses which I disassembled to determine the checksum
algorithm. The code is not well written--it's basically hand-translated
65816 assembly code. I'll clean it up someday.
Much of the code is not well-optimized. I'll get to that someday, but
the speed has been adequate for me so far.

View File

@ -1,96 +0,0 @@
KEGS Internals
--------------
The INTERNALS* files describe the internal structure of KEGS and how
it works. It is meant to be useful to those who would attempt to
port KEGS to non-Unix platforms, or just want to know how KEGS works.
Documentation files:
--------------------
INTERNALS.overview: Provides overview of KEGS's file structure
KEGS SOURCE FILES:
-----------------
adb.c: ADB emulation routines. This includes keyboard, mouse, and
joystick.
adb.h: Defines for ADB routines.
clock.c: Clock, BRAM, and some timing routines.
compile_time.c: Trick file to put the time you compiled in g_compile_time[].
defc.h: Global defines included by all .c files. Useful trick
to avoid complex multi-level include problems.
defs.h: Global defines included by all .s files (assembly language).
defcomm.h: Global defines included by all files (must be assembly and
C safe, such as #defines).
defs_instr.h: C and assembly definitions for various addressing modes
and for some repeated instructions (like LDA, STA, etc).
dis.c: Disassembler and debugger interface. The debugger interface
is similar to the Apple // monitor, but has many
more commands.
disas.h: Tables for disassembling 65816 instructions. Not very
efficient, but it works.
engine_c.c: C main instruction dispatch loop.
engine_s.s: Assembly main instruction dispatch loop.
instable.h: Instruction table. It is C and assembly-safe through
the make_inst script. make_inst turns instable.h into
8inst_c and 16inst_c, which are both valid C code.
iwm.c: IWM routines for 5.25" and 3.5" disks. See INTERNALS.iwm
iwm.h: IWM defines
iwm_35_525.h: File for reading and writing a disk byte, which is included
in iwm.c twice, once for 5.25" and again for 3.5".
Forcing out compile-time constants this way makes it
faster.
moremem.c: Awful name--this file contains the page table change
routines (fixup_*) and io_read() and io_write() to
emulate all $C000 I/O accesses.
op_routs.h: More macros for 65816 emulation.
protos.h: Prototypes for all C functions. Auto-generated through
the "cproto" program (not included).
protos_xdriver.h: Prototypes for functions in xdriver.c.
scc.c: Serial chip emulation.
scc_driver.h: Unix-specific socket routines, stubbed out if you're not
on Linux or HP-UX.
scc.h: Defines for scc.c.
sim65816.c: main() is here along with many other housekeeping
functions, such as events, and interrupts.
The main loop of KEGS is run_prog().
size_tab.h: Used by assembly for a jump table (make_size script
turns it into 8size_s and 16size_s) and by both C and
assembly to get the size of instructions.
smartport.c: Smartport emulation, emulates s7dx devices.
sound.c: Sound emulation. Builds sound samples, but does not
send sound to output device.
sound.h: Header file for sound.c.
sound_driver.c: Sound driver routines. Takes samples generated by sound.c
and sends them to the correct output device. Supports
HP Alib, HP /dev/audio, and Linux /dev/dsp currently.
superhires.h: "macro" routine used by video.c so that I could write
one generic superhires routine, but then include it
multiple times to get optimized 320 vs 640 mode routines.
video.c: Display routines. Builds 8 bit video buffers in a
device independent way. Functions here know nothing
about X windows.
xdriver.c: X windows driver routines. Takes buffers from video.c
and sends them on to X windows. Get keypresses from
X and sends them to adb.c.
Porting Advice:
--------------
To a non-unix platform, disabling scc emulation would be a good start.
Just make sure you get the dummy stub routines in scc_driver.h.
If you don't have gettimeofday(), clock.c will need to modified with
whatever timer facilities are available. A high-resolution clock works
best, but even a low-resolution clock will work.
Modify sound_driver.c to get it to compile, if necessary. Always run with
"-audio 0" to turn audio off. No routines in sound_driver.c will get
called if you run with -audio 0.
Replace xdriver.c with new routines for whatever platform you are porting to.
See INTERNALS.xdriver for more information.

View File

@ -1,148 +0,0 @@
xdriver.c contains the routines for interfacing to X windows. The rest
of KEGS interacts with X windows only through xdriver.c routines.
Externally called routines are:
show_xcolor_array(): Debug routine, it does not need to do anything.
dev_video_init(): Called at startup, it should open up the
window and do other initialization.
update_physical_colormap(): Updates the X windows palette with the colors
from xcolor_a2vid_array[], which is maintained by
other xdriver routines.
update_status_line(): Call to update the internal array of chars
representing the status lines at the bottom of
the window. Does not draw the chars to the screen.
xdriver_end(): Shutdown routine
check_input_events(): Called up to 60 times a second (see video_update() in
video.c) to handle any X window events and get
keypresses.
On a mouse press, call update_mouse() with the
new x, y coordinates, and the status of the mouse
button.
If g_warp_pointer is set, constrain mouse within
the window.
On keypress, calls handle_keysym().
handle_keysym(): Takes X keysym, and converts to the appropriate
a2code using the a2_key_to_xsym[] lookup table.
The a2codes are the Apple // ADB keycodes.
Special work is done to handle shift and control
properly since Apple only has one keycode for both
shift and control keys. Then call
adb_physical_key_update() with the a2 keycode and
is_up = 1 if keyup, 0 = if key down.
In addition, this routine handles all the Function
keys doing special actions, which should be easy to
port.
x_refresh_ximage(): Redraws the window using the a2_line_* arrays.
Described in more detail below.
update_color_array(): Interface to the color map. Sets color[col_num]
of the internal colormap array to a2_color.
a2_color is the 12 bit apple color of the form:
(red << 8) + (green << 4) + (blue).
There are 16 palettes of 16 colors each, managed as
one 256-color colormap. See discussion of
g_a2vid_palette below.
x_auto_repeat_on(): The X routines turn off key repeat when the cursor
enters the graphics window automatically, and turn
it back on when the cursor leaves. But if the
debugger gets control due to a breakpoint, keyrepeat
would be left off. So the debugger calls this
routine to make sure key repeat is back on.
redraw_status_lines(): Draw the status lines from the g_status_buf[][] array
to the graphics window.
Externally referenced data:
g_use_shmem: Set by main() to enable/disable MIT-SHM for X.
Also used by sound routines to auto-turn-off sound
if not using MIT-SHM.
Bytes representing screen data:
byte *data_text[2]: Array of bytes for the lores and text pages 1 and 2.
Just 400*640 bytes.
byte *data_hires[2]: Array of bytes for the hires pages 1 and 2.
byte *data_superhires: Array of bytes for superhires screen.
byte *data_border_sides: Array of bytes representing the border sides.
Basically just A2_WINDOW_HEIGHT*EFF_BORDER_WIDTH bytes.
byte *data_border_special: Top and bottom border bytes.
(X_A2_WINDOW_HEIGHT - A2_WINDOW_HEIGHT + 2*8) *
(X_A2_WINDOW_WIDTH) bytes.
Handles used for X windows drawing:
XImage *ximage_hires[2]: Opaque handle to XImage object for hires page 1 and
page 2.
XImage *ximage_text[2]: Text pages 1 and 2.
XImage *ximage_superhires: Superhires graphics XImage
XImage *ximage_border_special: Top and bottom border XImage.
XImage *ximage_border_sides: Left and right sides (only one copy, it is
drawn at two different locations to be both sides).
Basic operation of xdriver:
--------------------------
X windows can push arrays of bytes to the screen through structures
called XImages. An XImage is a structure describing an offscreen bitmap.
For efficiency of page flipping, KEGS maintains separate bitmaps for the
two lores/text screens, the two hires screens, and the superhires screen.
It also maintains bitmaps for the border. For MIT-SHM to work, X
requires a unique XImage for each bitmap, and the bitmap must be allocated
within xdriver.c since it must be obtained through an shmat() call.
The X code also has non-MIT-SHM code which allocates the data_* buffers
just through malloc().
All bitmaps are 8-bits of Pseudo-color. The color arrays are managed
through the update_color_array() and update_physical_colormap() routines.
KEGS manages all 256 colors in the colormap as 16 palettes of 16 colors.
One of the palettes is reserved for the 16 lores colors, and is
indicated by the variable g_a2vid_palette. It defaults to 0xe.
Update_color_array() is called to update superhires colormap entries.
Update_color_array must not update colors corresponding to g_a2vid_palette.
Update_physical_colormap() pushes the color array managed by
update_color_array() to the screen, but first forces the lores colors into
the g_a2vid_palette palette. g_installed_full_superhires_colormap is
always false in KEGS for now. video.c calls update_color_array and changes
g_a2vid_palette. No xdriver routines gets notified when g_a2vid_palette
changes, so update_physical_colormap must handle the case where
g_a2vid_palette might have changed since it was last called.
x_redraw_ximage():
Routines in video.c are free to draw into the corresponding data_*
arrays to change any byte at any time. video.c manages remembering
which lines need to be redrawn and which parts of the screen are in
which video mode via the a2_line_* arrays.
KEGS divides the video screen up into 25 groups, corresponding to each
text line. Each of these groups consists of 16 sublines. 25*8 = 400 lines.
(video.c has already doubled the vertical resolution in all video modes).
KEGS can allow any group to be from any of the five screens it manages:
The two text/lores pages, the two hires pages, and the superhires screen.
For each group, KEGS keeps track of what part of it needs to be redrawn.
g_a2_screen_buffer_changed has a bit set for each group which has changed
since the last call to x_redraw_ximage(). The rightmost bit (bit 0)
corresponds to group 0. If g_a2_screen_buffer_changed == 0, no groups
need to be redrawn. x_redraw_ximage clears out g_a2_screen_buffer_changed
after drawing the screen.
For each group, a2_line_left_edge[] and a2_line_right_edge give the pixel
offsets of what should be redrawn. a2_line_xim[] gives the ximage handle
of what needs to be redrawn. KEGS always redraws 8 verticals of a group.
g_full_refresh_needed also has one bit set in it for each group, which
indicates overriding the a2_line_*_edge functions and redraw from 0 to
640 pixels of each group that needs to be redrawn. x_redraw_ximage()
interprets this information now using a simple algorithm: Skip over
groups which have not changed (using g_a2_screen_buffer_changed).
Save the ximage of this group, the left pixel and the right pixel.
Continue with the next group if it has changed. Widen the pixel region
and keep sucking up new groups to the same ximage. At group 25, or
when the ximage changes, call x_refresh_lines to redraw this large
rectangle from this ximage. x_refresh_lines() knows the ximage
corresponding to the border for the last group has to be handled
specially since the border group is not 640*400 pixels like the others.
Other porting info:
a2_key_to_xsym[][3] contains the mapping function from X keysyms to
a2 keycodes. The first element is the a2 keycode, the second element
is the unshifted X keysym, and the third element is the shifted keysym.
A port must make the conversion to a2 keycodes, and provide up and
down events.

View File

@ -1,64 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>2mg</string>
<string>2MG</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>2mg.icns</string>
<key>CFBundleTypeName</key>
<string>Apple II 2MG Disk Image</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>a2mg</string>
</array>
<key>CFBundleTypeRole</key>
<string>None</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>kegs</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>525.icns</string>
<key>CFBundleTypeName</key>
<string>KEGS Configuration File</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>kegs</string>
</array>
<key>CFBundleTypeRole</key>
<string>None</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>KEGSMAC</string>
<key>CFBundleName</key>
<string>KEGSMAC</string>
<key>CFBundleIconFile</key>
<string>kegsicon.icns</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>KEGS</string>
<key>CFBundleVersion</key>
<string>0.91</string>
<key>CFBundleShortVersionString</key>
<string>KEGSMAC version 0.91</string>
<key>CFBundleGetInfoString</key>
<string>KEGSMAC v0.91, Copyright 2004 Kent Dickey, http://kegs.sourceforge.net</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright 2004 Kent Dickey</string>
</dict>
</plist>

View File

@ -1,124 +0,0 @@
# $Id: release_makefile_base,v 1.15 2003/11/21 20:00:42 kentd Exp kentd $
OBJECTS1 = adb.o clock.o config.o dis.o engine_c.o scc.o iwm.o \
joystick_driver.o moremem.o paddles.o sim65816.o smartport.o \
sound.o sound_driver.o video.o scc_socket_driver.o scc_windriver.o \
scc_macdriver.o
include vars
.SUFFIXES: .dep .proto
AS = $(CC)
XLIBS = -L/usr/X11R6/lib
PERL = perl
all: $(TARGET)
specials: 8inst_s 16inst_s 8size 16size 8inst_c 16inst_c size_c size_s
specials_clean:
rm -f 8inst_s 16inst_s 8size 16size 8inst_c 16inst_c size_c size_s
# Mac builds:
kegsmac: $(OBJECTS) compile_time.o
$(CC) $(CCOPTS) $(LDOPTS) -arch ppc $(OBJECTS) compile_time.o $(LDFLAGS) -o kegsmac $(EXTRA_LIBS) -prebind -framework Carbon -framework Quicktime
mkdir -p ../KEGSMAC.app/Contents/Resources/English.lproj/main.nib
mkdir -p ../KEGSMAC.app/Contents/MacOS
mv kegsmac ../KEGSMAC.app/Contents/MacOS/KEGSMAC
echo "APPL????" > ../KEGSMAC.app/Contents/PkgInfo
cp -f Info.plist ../KEGSMAC.app/Contents/
cp -f info.nib ../KEGSMAC.app/Contents/Resources/English.lproj/main.nib
cp -f classes.nib ../KEGSMAC.app/Contents/Resources/English.lproj/main.nib
cp -f objects.xib ../KEGSMAC.app/Contents/Resources/English.lproj/main.nib
cp -f kegsicon.icns ../KEGSMAC.app/Contents/Resources/
cp -f 525.icns ../KEGSMAC.app/Contents/Resources/
cp -f 2mg.icns ../KEGSMAC.app/Contents/Resources/
touch '../KEGSMAC.app/Icon?'
# Linux for X builds:
xkegs: $(OBJECTS) compile_time.o
$(CC) $(CCOPTS) $(LDOPTS) $(OBJECTS) compile_time.o $(LDFLAGS) -o $(NAME)$(SUFFIX) $(XLIBS) $(EXTRA_LIBS) -lX11
mv xkegs ..
# Cygwin for X builds:
kegs.exe: $(OBJECTS) compile_time.o
$(CC) $(CCOPTS) $(LDOPTS) $(OBJECTS) compile_time.o $(LDFLAGS) -o $(NAME)$(SUFFIX) $(XLIBS) $(EXTRA_LIBS) -lXext -lX11 -lm
mv kegs.exe ..
# Mingw32 (native windows) builds:
kegswin.exe: $(OBJECTS) compile_time.o
$(CC) $(CCOPTS) $(LDOPTS) $(OBJECTS) compile_time.o $(LDFLAGS) -o $(NAME)$(SUFFIX) $(EXTRA_LIBS) -lwinmm -lgdi32 -ldsound -lcomctl32 -lws2_32
mv $(NAME)$(SUFFIX) ..
8inst_c.h: instable.h
$(PERL) make_inst c 8 instable.h > 8inst_c.h
16inst_c.h: instable.h
$(PERL) make_inst c 16 instable.h > 16inst_c.h
size_c.h: size_tab.h
$(PERL) make_size c size_tab.h > size_c.h
engine_c.o: 8inst_c.h 16inst_c.h size_c.h
8inst_s.h: instable.h
$(PERL) make_inst s 8 instable.h > 8inst_s.h
16inst_s.h: instable.h
$(PERL) make_inst s 16 instable.h > 16inst_s.h
size_s.h: size_tab.h
$(PERL) make_size s size_tab.h > size_s.h
8size_s.h: size_tab.h
$(PERL) make_size 8 size_tab.h > 8size_s.h
16size_s.h: size_tab.h
$(PERL) make_size 16 size_tab.h > 16size_s.h
engine_s.o: 8inst_s.h 16inst_s.h 8size_s.h 16size_s.h size_s.h
.s.o:
$(AS) -c $(OPTS) -I. $*.s
.c.o:
$(CC) $(CCOPTS) $(XOPTS) -c $(OPTS) -I. $*.c
partls: partls.c
cc $(CCOPTS) $(XOPTS) $(OPTS) -o partls partls.c
to_pro: prodos.h prodos_protos.h to_pro.c
cc $(CCOPTS) $(XOPTS) $(OPTS) -o to_pro to_pro.c
compile_time.o: $(OBJECTS)
# dependency stuff
adb.o: adb.c adb.h defc.h defcomm.h iwm.h protos.h
engine_c.o: engine_c.c defc.h defcomm.h iwm.h protos.h protos_engine_c.h size_c.h op_routs.h defs_instr.h 8inst_c.h 16inst_c.h
clock.o: clock.c defc.h defcomm.h iwm.h protos.h
compile_time.o: compile_time.c
config.o: config.c defc.h defcomm.h iwm.h protos.h config.h
dis.o: dis.c defc.h defcomm.h iwm.h protos.h disas.h
scc.o: scc.c defc.h defcomm.h iwm.h protos.h scc.h
scc_socket_driver.o: scc_socket_driver.c defc.h defcomm.h iwm.h protos.h scc.h
scc_windriver.o: scc_windriver.c defc.h defcomm.h iwm.h protos.h scc.h
scc_macdriver.o: scc_macdriver.c defc.h defcomm.h iwm.h protos.h scc.h
iwm.o: iwm.c defc.h defcomm.h iwm.h protos.h iwm_35_525.h
joystick_driver.o: joystick_driver.c defc.h defcomm.h iwm.h protos.h
moremem.o: moremem.c defc.h defcomm.h iwm.h protos.h
paddles.o: paddles.c defc.h defcomm.h iwm.h protos.h
sim65816.o: sim65816.c defc.h defcomm.h iwm.h protos.h
smartport.o: smartport.c defc.h defcomm.h iwm.h protos.h
sound.o: sound.c defc.h defcomm.h iwm.h protos.h sound.h
sound_driver.o: sound_driver.c defc.h defcomm.h iwm.h protos.h sound.h
video.o: video.c defc.h defcomm.h iwm.h protos.h superhires.h kegsfont.h
macdriver.o: macdriver.c defc.h defcomm.h iwm.h protos.h protos_macdriver.h
macsnd_driver.o: macsnd_driver.c defc.h defcomm.h iwm.h protos.h sound.h
windriver.o: windriver.c defc.h defcomm.h iwm.h protos.h protos_windriver.h winresource.h
win32snd_driver.o: win32snd_driver.c defc.h defcomm.h iwm.h protos.h sound.h

View File

@ -1,123 +0,0 @@
# $Id: README.a2.compatibility,v 1.2 2004/10/18 18:17:21 kentd Exp $
Flobynoid: Must disable Fast Disk Emul (hit F7 to toggle it off) since
game's loader relies on the sector order on the disk (reads 8
sectors from the start without checking headers, assumes every other
physical sector is skipped due to decode delays).
Bard's Tale II GS: Doesn't recognize any save disk as a ProDOS disk.
It's detecting a "ProDOS" disk by checking for a string on block
0 at offset 0x15e. GSOS on system 6 has moved the string to 0x162,
so disks inited under GSOS will be detected as "Not a PRODOS disk".
Just make a copy of the Bard's Tale disk image to another file and
then mount that new image and remove all the files using the Finder.
Then rename the volume and you have a working save disk.
Robotron 2084:
Robot Battle:
These cracks use a "Fastloader" which is buggy.
It tries to JMP $F3D4 and expects to hit an RTS soon.
But on a IIgs it will access some illegal memory causing a code
yellow. You can just ignore the code yellow.
Beyond Castle Wolfenstein: Make sure your disk is writeable (not compressed!)
Breakout: Has trouble loading from the cracked copy.
From the BASIC prompt, do: "CALL -151" then "C083 N C083" then
"BLOAD INTBASIC" then run breakout. Then it runs fine.
Burgertime: This is a bad crack. Loader starts the game by writing
the game entry point into $0036/$0037, and then executing a BRK
instruction. The BRK handler on an old Apple II will try to write
out a message by calling through $0036/$0037, and this will start
the game. But on a IIgs, the ROM sets the $0036/$0037 vectors
back to the default, and so we crash into the monitor instead.
Here's a memory fix and a disk-image fix: From the crack screen,
press Shift-F6 (or middle mouse button) and in the KEGS debugger
window enter: "1d0a:ea 6c 36 0" and then "g". You can make
this fix to the disk image using a sector editor and change
Track $1E sector $09 offset $0A from "60 78 A9 03" to "EA 6C 36 00"
and write it back.
Caverns of Callisto: Requires old C600 ROM in slot 6 (Slot 6==Your Card).
Championship Loderunner: Requires disk to be writeable or else it starts
the level and then jumps immediately back to the title page.
Jeopardy: Disk must be writeable or else it displays "DISK ERROR" and
then crashes into the monitor.
Drol: Needs slot 6 set to "Your Card" from the IIgs control panel
(Ctrl-Cmd-ESC, then choose "Slots").
I found Drol hard, so here are some cheats. First, the standard cheat
for Drol is to have infinite lives, this cheat is to edit the disk
image:
Track $0B, Sector $0A, byte $22 to EA EA
Track $11, Sector $0A, byte $10 to EA EA
Track $17, Sector $09, byte $B2 to EA EA
I didn't create those cheats, I got it from textfiles.com.
My cheats are for the monsters to never kill you--just run right
through them.
While playing Drol, press Shift-F6 (or middle mouse button) to
enter the KEGS debugger, and then:
0/f28:18 18 # Monsters' missiles won't kill you
0/e05:90 0c # Monsters won't kill you
Continue emulation by type "g" and then enter.
Other things, like the bird, axes, swords still kill you.
To easily solve the third screen, move your man to the far right
side on the top level, so that you are directly above the woman
on the bottom row. Fly into the air "A" and then get to the KEGS
debugger, and type:
0/c:4
and then continue with "g". Now press "Z" and you will go all
the way down and land on the woman and end the level. It's
useful to have made the two above patches so that touching monsters
won't kill you.
Two more patches that only apply to level 3, and so most be made
in memory each time you enter level 3:
6cf3:18 18 18 # Axes won't kill you
6f70:38 38 # Swords/arrows won't kill you
The bird and the guy you can't kill will still kill you. These
cheats were enough to make the game easily playable.
In the game, your death is indicated by setting location $001E to
$FF. Setting breakpoints there can let you find other cheats.
Moon Patrol: Crashes into the monitor after completing checkpoint E.
To fix the Moon Patrol/Dung beetles version, from within KEGS:
BLOAD MOON PATROL
CALL -151
1E15:EA
919G
and it will work fine.
If you have the booting version that just has Moon Patrol on it,
then from any point after the crack screen is shown, enter the
KEGS debugger (Shift-F6 or middle moust button) and then enter:
0/1e15:ea
g
and then it will play fine.
The bug is that the code executes an instruction with opcode $02,
which is a NOP on 6502, but is a COP instruction to 65816. The
COP instruction acts like BRK and will crash. The patch just
makes it a real NOP.
Microbe: Crashes upon booting.
Code at $599E tries to pull a return address off of a location
beneath the stack pointer and jump to it, but it doesn't add 1
correctly so it jumps to $5917 when it meant to jump to $5918.
On a IIgs, this causes a BRK to be executed and the game to crash.
This can be patched in memory in two places:
0/599e:ba ca 9a 7d 00 01 48 98 7d 01 01 9d 01 01 60
0/6f1d:ba ca 9a 7d 00 01 48 98 7d 01 01 9d 01 01 60
The original byte sequence for both locations is:
00/599e: ba TSX
00/599f: 7d ff 00 ADC $00ff,X
00/59a2: 85 94 STA $94
00/59a4: 98 TYA
00/59a5: 7d 00 01 ADC $0100,X
00/59a8: 85 95 STA $95
00/59aa: 6c 94 00 JMP ($0094)
You can also patch the code onto the disk image. I found
the $599E version on Track $05, Sector $06, Byte $9E.
I found the $6F1D version on the image at Track $0C, Sector $00,
at byte $1D.

View File

@ -1,118 +0,0 @@
# $Id: README.compile,v 1.20 2004/10/18 04:05:14 kentd Exp $
General build instructions:
--------------------------
You need to build with a make utility. I've only tested GNU make.
There's a default Makefile, which should work for nearly any environment.
The Makefile includes a file called "vars" which defines the platform-
dependent variables. You need to make vars point to the appropriate
file for your machine.
This makes my maintenance of the diverse platforms a bit easier.
WIN32 build instructions:
------------------------
See the file README.win32 for build instructions and other information
for Microsoft Windows.
Mac OS X build instructions (the default):
------------------------------------------
KEGS is easy to compile. Just cd to the src directory and type "make".
KEGS requires perl to be in your path (or just edit the vars file to give
the full path to wherever you installed perl). Perl version 4 or 5 is
fine.
After the "make" has finished, it will create the application KEGSMAC.
To run, see README.mac.
X86 Linux build instructions:
----------------------------
Use the vars_x86linux file with:
rm vars; ln -s vars_x86linux vars
make
The resulting executable is called "xkegs".
The build scripts assume perl is in your path. If it is somewhere else,
you need to edit the "PERL = perl" line in the vars file and make it point
to the correct place.
For audio, KEGS needs access to /dev/dsp. If the permissions do not allow
KEGS to access /dev/dsp, it can fail with a cryptic error message. As root,
just do: "chmod 666 /dev/dsp".
PowerPC Linux build instructions:
----------------------------
Use the vars_linuxppc vars file by:
rm vars; ln -s vars_linuxppc vars
make
The build scripts assume perl is in your path. If it is somewhere else,
you need to edit the "PERL = perl" line in the vars file and make it point
to the correct place.
Audio is currently disabled by default, but you can try turning it on
by runnning "xkegs -audio 1". It sounds horrible to me, but sounds do
come out.
Solaris SPARC build instructions:
--------------------------------
Use the vars_solaris vars file by:
rm vars; ln -s vars_solaris vars
make
The build scripts assume perl is in your path. If it is somewhere else,
you need to edit the "PERL = perl" line in the vars file and make it point
to the correct place.
Audio is currently disabled by default, but you can try turning it on
by runnning "xkegs -audio 1".
Solaris x86 build instructions:
--------------------------------
Use the vars_x86solaris vars file by:
rm vars; ln -s vars_x86solaris vars
make
The build scripts assume perl is in your path. If it is somewhere else,
you need to edit the "PERL = perl" line in the vars file and make it point
to the correct place.
Audio is currently disabled by default, but you can try turning it on
by runnning "xkegs -audio 1".
HP-UX assembly-emulation instructions:
-------------------------------------
Use the vars_hp vars file by:
rm vars; ln -s vars_hp vars
Edit the Makefile, and remove "engine_c.o" from the "OBJECTS1=" line at
the top. Then just type "make".
This version is quite out of date and most likely does not compile any more.
Other platform "C" build instructions:
-------------------------------------
If you are porting to an X-windows and Unix-based machine, it should be
easy. Start with vars_x86linux if you are a little-endian machine, or
vars_linuxppc if you are big endian. Don't define -DKEGS_LITTLE_ENDIAN
unless your processor is little-endian (x86, Alpha). Mac, Sun, MIPS,
HP, Motorola, and IBM are big-endian.

File diff suppressed because it is too large Load Diff

View File

@ -1,252 +0,0 @@
[ This info provided by Mike Thomas <phoenyx@texas.net> ]
[ Updated 10/30/2003 by Kent: This file mentions editing "kegs.conf" to ]
[ mount images--this is now replaced by the built-in Configuration Panel. ]
Setup and configuration for x86 Linux:
--------------------------------------
KEGS is very easy to setup on your Linux box, but not foolproof. First
you will need to decide where it will live. When doing this you will
have to take into consideration any users of your machine. It really
doesn't matter where it goes but it should have it's own directory and
any supplied sub-directories should be there. You may decide to use the
/usr/local path where most systems recommend you install applications.
Again, this is entirely up to you. On my system I have a separate
partition for KEGS and all the miscellaneous files I've accumulated for
it. This makes it easy for me to reinstall the system should the need
arise. Since I fool around with a large variety of software and OS's
this happens more often than it would for normal users.
Once you have put the files into the proper place you will need to
compile it. You should not need to be 'root' to do this part. The file
README.compile explains the steps required for this. Basically all you
should need to do is set the vars link to point to the file
vars_x86linux. You will want to check the file and make sure it is
accurate for your system. On my Redhat 6.0 system the default compile
setup works fine. I use the pentium GCC compiler instead of the
supplied EGCS since it seems to build better binaries. I do not
recommend using optimization levels higher than 2. Once you have
successfully built the binaries you will need to copy them to the KEGS
directory. At a minimum copy the file kegs and to_pro.
Ok, now that you have the binaries you're almost ready. You will need a
copy of the IIgs rom placed in the KEGS directory. It should be named
ROM. You will also need some disk images. This is the hardest part.
You will need to create an HD image to work with. Kent mentions an easy
way in his readme. From the shell type this:
echo "testfile" > testfile
to_pro -16384 testfile
If you're using bash try this:
echo "testfile" > testfile
./to_pro -16384 testfile
This should create a 16 megabyte HD image. This image will NOT be properly
formatted to boot a system. The block zero is not properly setup. There is no
easy way to fix this with the current KEGS/Linux system. There seems to be a
problem formating HD files for Prodos using KEGS. The system will easily erase
them but this doesn't help you. One solution is to make the primary boot drive
use a disk partition. This is more involved and will be explained later.
Another solution is to have access to the utility Block.Warden or some other
P8 block utility. What you need to do is copy the boot blocks (blocks 0 and 1)
from any bootable disk to the HD image. With that done you can now install
GS/OS.
Make sure you set the proper file permissions on files needed by KEGS. You
will not be able to properly use it while logged on as root. KEGS uses the
file permissions to test if it should write the image to disk or the memory
image. As root, KEGS will never write the image since it thinks root
always has execute privilege. The main files which you will need read/write
access to are bram.data.1 and disk_conf. I suggest you have read access to all
the other files in the directory.
Once you've got all the proper permissions set, log onto the system with your
normal account. Start up X and a shell and cd to the KEGS directory. Assuming
you have the disk images for GS/OS edit your disk_conf file so it looks
similar to this:
# boot from install disk
s7d1 = /usr/local/fst/gsos1
# our HD image
# you should rename POOF1 file created with to_pro
# I use *.hdv to be compatible with other utilities
s7d2 = /usr/local/fst/boot.hdv
# other GSOS images
s7d3 = /usr/local/fst/gsos2
...
If you include all the GSOS images this way you will have a simple setup.
Execute KEGS. For now go with the simplest command line possible. Since the
newer versions support auto detect on video resolutions this should be the
command kegs by itself. Hopefully you will boot into the emulator. If so,
install GSOS and you're ready to go.
Sound
-----
Kent says sound doesn't work under Linux. This is partially true and much
depends on the sound system you have installed. I have been successful with
sound on both Soundblaster and Soundpro systems. For long compositions the
sound may break up but it is functional for games and system sounds.
System Video Setup
------------------
This is rather personal and based upon system hardware so I'll just give you my
thoughts and setup info on this. My normal X system is configured
@ 1152x864 15bpp due to constraints in the X server for my video system. I
have custom configured it to boot into this mode and then I change to 800x600
by using the CTRL+ALT+(keypad)PLUS sequence when I use KEGS. This makes the
system much easier to read.
KEGS and disk partitions
------------------------
Kent mentions using partitions in his readme file but doesn't go into much
details. I suspect this is mostly for accessing CD-roms. But it also works
well for HFS and Prodos formatted partitions also. Linux can also handle HFS
partitions but not Prodos. To accomplish this you will need some free space on
your hard disk to create the partitions. You should not attempt this unless you
know what you are doing. You have been warned!
This task is not easy, nor is it supported by Kent. This was done and tested
on my own system so I know it works. You will need the HFS support utilities
for Linux. These are available on several Linux software sites. The primary
need for these utilities is to change an ext2fs partition to an HFS partition.
You can also use them to format the HFS volumes and copy files to and from
the partition. Newer versions of the Linux kernel support HFS file systems but
you will still need the utilities to create the original volume.
You must decide how you want to divide this partition. You can use it all for
HFS or you can create Prodos volumes and HFS volumes. There are pros and cons
for using Prodos partitions instead of files. The pros, it is a little faster
than using an HD file. It is a real Prodos partition, formatted by KEGS. The
cons, It must be backed up by using software on the emulator. You can't just
copy the HD file to another drive.
You must weigh these pros and cons and decide for yourself. Of course you
are not limited to using partitions. I have a mix of partitions and files
which works quite well. I like the P8 partitions for holding my boot system
and applications. I back them up with GSHK to an HFS volume which I can then
transfer to another drive if I need even more security.
If you decide to use the whole partition for HFS then all you need to do is
run the HFS utilities and setup the HFS volume. Read the documentation which
comes with the utility package and follow it faithfully.
If you want to use P8 and HFS partitions you have some more work to do. If
you have never worked with low level partitions or are worried about destroying
your HD then you should probably forget this. For this to work you will have
to change the partition table on your HD. This can and most likely will ruin
any data you already have on there. I can not state this enough. Back up any
important data on the hard drive! It is possible to change the partitions in
Linux and not destroy the system. I have done this on mine but I also used
the last defined partition to make the changes and designed the system for
change should it be necessary.
For those of you who know how to handle this, take the partition you have
decided to use for KEGS and divide it into at least one 32 meg partition.
More is better but you will have to use the emulator to back up any drives
setup this way since Linux can't access a Prodos partition (yet). I have setup
4 32 meg P8 partitions and several smaller HFS partitions of about 96 megs.
The reason I use smaller HFS partitions is because HFS isn't real efficient
with larger drives, but that's another story. The reason for the separate
HFS partitions is so Linux can mount the HFS volumes like any other file system.
I find this works quite easily for accessing files instead of using the HFS
utilities. Just my opinion though. For P8 utilities you will still need to
use the HFS utility and configure the drive as an HFS volume. This lets KEGS
read the partition when it loads the partition the first time. KEGS doesn't
like the Linux file system.
Ok, everybody got their partitions defined? You want to use the HFS tools
and setup all the partitions (P8 and HFS) as HFS volumes. Next you will have
to setup the HFS partitions. No, I'm not repeating myself. This is not the same
thing as the low level partitions. HFS volumes have their own partition table.
For our purposes the table will only hold one partition on each whole volume.
The utility will give you the block count when you setup the partitions,
write it down so you don't forget. After you have the volume partition setup
you can format the drive. Yeah I know you made a Prodos partition but it
doesn't hurt anything and KEGS will be able to read the partition when it
boots up.
Well, I think I covered everything needed to set them up. Now you will need to
edit the /etc/fstab file. Make sure there are no references to the original
partition. If you want to access the HFS volumes you will need to add them to
this file. You will also need to make sure that your Linux can understand the
HFS format. Most newer kernels will as long as you've compiled it into the
kernel or set it up as a module. KEGS doesn't need these entries to access
the volumes, they are just here for your convenience. In fact, if you don't
need Linux access I suggest you either leave them out or set them up as
NOAUTO and mount them only when needed. Unmount them when finished to avoid
any potential problems also. Do not give Linux access to any P8 partitions.
For one thing it can't recognize them and most likely will give you problems
when you boot the system. For safety's sake the only partition I have listed
in my /etc/fstab is a volume called transfer. You must set the filetype to HFS
so Linux doesn't complain about the partitions if you mount them.
Ok, all partitions are defined, the /etc/fstab is setup correct, now you need
to change the permissions on the device files associated with the partitions.
This allows you to access the files as a normal user. (Thanks Kent, guess I
got too involved and forgot it should be treated like the CD). You will need
to reboot to ensure the system sees the new partitions and has the correct
/dev/hd?# device files. If you setup the partitions with fdisk you should know
the correct hd info to select the files. For the sake of example let's assume
the device is HDB and the partitions numbers are 1,2,3. From the shell,
cd /dev
chmod 666 /dev/hdb1
chmod 666 /dev/hdb2
chmod 666 /dev/hdb3
After you start KEGS you can format the Prodos partitions. If you use the
method mentioned earlier for installing GS/OS you will want to quit the
installer and run the advanced disk utilities on the utilities disk, then
quit back to the installer program or reboot.
Now I know this all sounds like a lot of trouble but (IMHO) it's worth it. For
one thing, KEGS will format a Prodos partition without problems (unlike an HD
file image) which makes a great boot system. And with GS/OS 6.01 you can access
large HFS volumes for storage and GS applications. You can also download from
the net to the HFS volume (if it's mounted) and avoid the trouble of copying
files to an image with to_pro. Not to mention the fact that the newest GNO
works with HFS drives.
One more note, if you use HFS you will need to patch the HFS fst. There is a
one byte bug which mis-calculates HFS block sizes and WILL trash your HFS
drive. The patch is at several places on the net or ask someone in one of
the comp.sys.apple2 news groups.
Miscellanea
-----------
To ease access to the KEGS binary, make an executable script which contains
any command line parms you need. Then put this script somewhere in the path
so you can execute it from any shell. Depending on the desktop you use you
may want to setup links for editing the disk_conf file also. With GNO/ME you
can launch KEGS without the shell but I don't recommend this since you won't
know what happened when it dies. With KDE you can set up the launcher to use
a shell, this is much better but until you have your setup stable you will
want to use a regular terminal so you can keep track of what's going on. Like
GNO/ME, the KDE shell will close as soon as KEGS quits with an error.
Thanks
------
I hope this info helps you enjoy KEGS. Many thanks to Kent for creating this
fine emulator and for putting up with me bugging him with 'bug' reports. Many
of these weren't actually bugs but were my own fault due to lack of knowledge
about *nix systems. But Kent was prompt in fixing the ones which truly were
bugs. Thanks to him I can now play my favorite game, Questron 2 (gs version)
which requires a player disk in slot 5. I know no other emulator which can
actually play this game.
Mike Thomas

View File

@ -1,41 +0,0 @@
MAC OS X port of KEGS (KEGSMAC): http://kegs.sourceforge.net
-------------------------------------------------------------
There is a different port of KEGS to Mac OS X called KEGS-OSX.
You can get it from http://casags.net/.
This port is not leveraged from KEGS-OSX (which is based on SDL).
This is a Mac OS X Carbon port. It will not work on Mac OS 9.
Everything pretty much works, but 8-bit color doesn't work. Make sure your
Mac is set to Thousands or Millions of colors.
Usage:
-----
Like most other KEGS versions, KEGSMAC is usually run from a Terminal
window. Just type "./KEGSMAC.app/Contents/MacOS/KEGSMAC" in the directory
you installed/compiled it in. You need to have a ROM file (named
ROM, ROM.01, or ROM.03) and a config.kegs in the same directory or in your
home directory (read the README--these files are searched for in various
places).
KEGSMAC can also be run from the Finder, but if you do this, there
will be no debug window at all. This is not well tested, yet.
To quit, either click the window close box, or select Quit from the menu.
You can also middle-click (if you have a 3-button mouse) or
Shift-F6 to get the debugger in the terminal window, and then type "q".
Compile directions
------------------
In order to compile,
1) cd into the src/ directory
2) copy vars_mac to vars
3) run make
You can contact me at kadickey@alumni.princeton.edu

View File

@ -1,52 +0,0 @@
WIN32 port of KEGS (KEGSWIN)
----------------------------
There is a different port of KEGS by Chea Chee Keong (akilgard) called
KEGS32. You can get it from http://www.geocities.com/akilgard/kegs32.
This port is leveraged from KEGS32, but mostly a rewrite (perhaps for
the worse). I am grateful for Chea for doing the windows port since I
did not know any Windows programming.
This port is alpha quality. Don't expect much.
This is a bare-bones Win32 port. It was compiled with Mingw2.0,
which you can download at: http://www.mingw.org/. I also had
previously installed cygwin at http://www.cygwin.com/. Installing
these two beasts is a bit of a pain, so I'll eventually write up
directions (I hope).
Sound works, the mouse works, and a joystick might work (ported
from KEGS32). The user-interface is just like every other KEGS
version (i.e., bad), so you can just read the standard README file.
Only tested on a 32-bit graphics display, although I think 16-bit and
24-bit will work. 8-bit definitely does not work. There are many
other bugs I just haven't had time to list yet.
Usage:
-----
Like most other KEGS versions, KEGSWIN must be run from a terminal
window (command.com is fine). Just type "KEGSWIN" in the directory
you installed/compiled it in. You need to have a ROM file (named
ROM, ROM.01, or ROM.03) and a kegs_conf in the same directory (or
read the README--these files are searched for in various places).
To quit, either click the close box, or force quit the application.
You can also middle-click (if you have a 3-button mouse) or
Shift-F6 to get the debugger in the terminal window, and then type "q".
Compile directions
------------------
In order to compile,
1) cd into the src/ directory
2) rm vars
3) ln -s vars_win32 vars
3) ./make_win
You can contact me at kadickey@alumni.princeton.edu

3748
jni/adb.c

File diff suppressed because it is too large Load Diff

View File

@ -132,7 +132,9 @@ const int a2_key_to_ascii[][4] = {
{ 0x67, 0x800b, 0x1067, -1 }, /* F11 */
{ 0x68, -1, -1, -1 },
{ 0x69, 0x800d, 0x1069, -1 }, /* F13 */
// { 0x69, 0x800d, 0x1069, -1 }, /* F13 */
// OG remap F13 to reset
{ 0x69, 0x800c, 0x1069, -1 }, /* F13 */
{ 0x6a, -1, -1, -1 },
{ 0x6b, 0x800e, 0x106b, -1 }, /* F14 */
{ 0x6c, -1, -1, -1 },

View File

@ -459,3 +459,19 @@ check_input_events()
}
} while(event_item != NULL && keep_going);
}
// OG
void x_release_kimage(Kimage* kimage_ptr)
{
if (kimage_ptr->dev_handle == (void*)-1)
{
free(kimage_ptr->data_ptr);
kimage_ptr->data_ptr = NULL;
}
}
// OG Addding ratio
int x_calc_ratio(float x,float y)
{
return 1;
}

4
jni/classes.nib generated
View File

@ -1,4 +0,0 @@
{
IBClasses = ();
IBVersion = 1;
}

View File

@ -1,382 +1,396 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
const char rcsid_clock_c[] = "@(#)$KmKId: clock.c,v 1.31 2004-10-19 17:32:07-04 kentd Exp $";
#include "defc.h"
#include <time.h>
#ifdef _WIN32
# include <windows.h>
# include <mmsystem.h>
#else
# include <sys/time.h>
#endif
extern int Verbose;
extern int g_vbl_count;
extern int g_rom_version;
extern int g_config_kegs_update_needed;
#define CLK_IDLE 1
#define CLK_TIME 2
#define CLK_INTERNAL 3
#define CLK_BRAM1 4
#define CLK_BRAM2 5
int g_clk_mode = CLK_IDLE;
int g_clk_read = 0;
int g_clk_reg1 = 0;
extern int g_c033_data;
extern int g_c034_val;
byte g_bram[2][256];
byte *g_bram_ptr = &(g_bram[0][0]);
word32 g_clk_cur_time = 0xa0000000;
int g_clk_next_vbl_update = 0;
double
get_dtime()
{
#ifndef _WIN32
struct timeval tp1;
double dsec;
double dusec;
#endif
double dtime;
/* Routine used to return actual system time as a double */
/* No routine cares about the absolute value, only deltas--maybe */
/* take advantage of that in future to increase usec accuracy */
#ifdef _WIN32
dtime = timeGetTime() / 1000.0;
#else
# ifdef SOLARIS
gettimeofday(&tp1, (void *)0);
# else
gettimeofday(&tp1, (struct timezone *)0);
# endif
dsec = (double)tp1.tv_sec;
dusec = (double)tp1.tv_usec;
dtime = dsec + (dusec / (1000.0 * 1000.0));
#endif
return dtime;
}
int
micro_sleep(double dtime)
{
#ifndef _WIN32
struct timeval Timer;
int ret;
#endif
if(dtime <= 0.0) {
return 0;
}
if(dtime >= 1.0) {
halt_printf("micro_sleep called with %f!!\n", dtime);
return -1;
}
#if 0
printf("usleep: %f\n", dtime);
#endif
#ifdef _WIN32
Sleep(dtime * 1000);
#else
Timer.tv_sec = 0;
Timer.tv_usec = (dtime * 1000000.0);
if( (ret = select(0, 0, 0, 0, &Timer)) < 0) {
fprintf(stderr, "micro_sleep (select) ret: %d, errno: %d\n",
ret, errno);
return -1;
}
#endif
return 0;
}
void
clk_bram_zero()
{
int i, j;
/* zero out all bram */
for(i = 0; i < 2; i++) {
for(j = 0; j < 256; j++) {
g_bram[i][j] = 0;
}
}
g_bram_ptr = &(g_bram[0][0]);
}
void
clk_bram_set(int bram_num, int offset, int val)
{
g_bram[bram_num][offset] = val;
}
void
clk_setup_bram_version()
{
if(g_rom_version < 3) {
g_bram_ptr = (&g_bram[0][0]); // ROM 01
} else {
g_bram_ptr = (&g_bram[1][0]); // ROM 03
}
}
void
clk_write_bram(FILE *fconf)
{
int i, j, k;
for(i = 0; i < 2; i++) {
fprintf(fconf, "\n");
for(j = 0; j < 256; j += 16) {
fprintf(fconf, "bram%d[%02x] =", 2*i + 1, j);
for(k = 0; k < 16; k++) {
fprintf(fconf, " %02x", g_bram[i][j+k]);
}
fprintf(fconf, "\n");
}
}
}
void
update_cur_time()
{
struct tm *tm_ptr;
time_t cur_time;
unsigned int secs, secs2;
cur_time = time(0);
/* Figure out the timezone (effectively) by diffing two times. */
/* this is probably not right for a few hours around daylight savings*/
/* time transition */
secs2 = mktime(gmtime(&cur_time));
tm_ptr = localtime(&cur_time);
secs = mktime(tm_ptr);
#ifdef MAC
/* Mac OS X's mktime function modifies the tm_ptr passed in for */
/* the CDT timezone and breaks this algorithm. So on a Mac, we */
/* will use the tm_ptr->gmtoff member to correct the time */
secs = secs + tm_ptr->tm_gmtoff;
#else
secs = (unsigned int)cur_time - (secs2 - secs);
if(tm_ptr->tm_isdst) {
/* adjust for daylight savings time */
secs += 3600;
}
#endif
/* add in secs to make date based on Apple Jan 1, 1904 instead of */
/* Unix's Jan 1, 1970 */
/* So add in 66 years and 17 leap year days (1904 is a leap year) */
secs += ((66*365) + 17) * (24*3600);
g_clk_cur_time = secs;
clk_printf("Update g_clk_cur_time to %08x\n", g_clk_cur_time);
g_clk_next_vbl_update = g_vbl_count + 5;
}
/* clock_update called by sim65816 every VBL */
void
clock_update()
{
/* Nothing to do */
}
void
clock_update_if_needed()
{
int diff;
diff = g_clk_next_vbl_update - g_vbl_count;
if(diff < 0 || diff > 60) {
/* Been a while, re-read the clock */
update_cur_time();
}
}
void
clock_write_c034(word32 val)
{
g_c034_val = val & 0x7f;
if((val & 0x80) != 0) {
if((val & 0x20) == 0) {
printf("c034 write not last = 1\n");
/* set_halt(1); */
}
do_clock_data();
}
}
void
do_clock_data()
{
word32 mask;
int read;
int op;
clk_printf("In do_clock_data, g_clk_mode: %02x\n", g_clk_mode);
read = g_c034_val & 0x40;
switch(g_clk_mode) {
case CLK_IDLE:
g_clk_read = (g_c033_data >> 7) & 1;
g_clk_reg1 = (g_c033_data >> 2) & 3;
op = (g_c033_data >> 4) & 7;
if(!read) {
/* write */
switch(op) {
case 0x0: /* Read/write seconds register */
g_clk_mode = CLK_TIME;
clock_update_if_needed();
break;
case 0x3: /* internal registers */
g_clk_mode = CLK_INTERNAL;
if(g_clk_reg1 & 0x2) {
/* extend BRAM read */
g_clk_mode = CLK_BRAM2;
g_clk_reg1 = (g_c033_data & 7) << 5;
}
break;
case 0x2: /* read/write ram 0x10-0x13 */
g_clk_mode = CLK_BRAM1;
g_clk_reg1 += 0x10;
break;
case 0x4: /* read/write ram 0x00-0x0f */
case 0x5: case 0x6: case 0x7:
g_clk_mode = CLK_BRAM1;
g_clk_reg1 = (g_c033_data >> 2) & 0xf;
break;
default:
halt_printf("Bad c033_data in CLK_IDLE: %02x\n",
g_c033_data);
}
} else {
printf("clk read from IDLE mode!\n");
/* set_halt(1); */
g_clk_mode = CLK_IDLE;
}
break;
case CLK_BRAM2:
if(!read) {
/* get more bits of bram addr */
if((g_c033_data & 0x83) == 0x00) {
/* more address bits */
g_clk_reg1 |= ((g_c033_data >> 2) & 0x1f);
g_clk_mode = CLK_BRAM1;
} else {
halt_printf("CLK_BRAM2: c033_data: %02x!\n",
g_c033_data);
g_clk_mode = CLK_IDLE;
}
} else {
halt_printf("CLK_BRAM2: clock read!\n");
g_clk_mode = CLK_IDLE;
}
break;
case CLK_BRAM1:
/* access battery ram addr g_clk_reg1 */
if(read) {
if(g_clk_read) {
/* Yup, read */
g_c033_data = g_bram_ptr[g_clk_reg1];
clk_printf("Reading BRAM loc %02x: %02x\n",
g_clk_reg1, g_c033_data);
} else {
halt_printf("CLK_BRAM1: said wr, now read\n");
}
} else {
if(g_clk_read) {
halt_printf("CLK_BRAM1: said rd, now write\n");
} else {
/* Yup, write */
clk_printf("Writing BRAM loc %02x with %02x\n",
g_clk_reg1, g_c033_data);
g_bram_ptr[g_clk_reg1] = g_c033_data;
g_config_kegs_update_needed = 1;
}
}
g_clk_mode = CLK_IDLE;
break;
case CLK_TIME:
if(read) {
if(g_clk_read == 0) {
halt_printf("Reading time, but in set mode!\n");
}
g_c033_data = (g_clk_cur_time >> (g_clk_reg1 * 8)) &
0xff;
clk_printf("Returning time byte %d: %02x\n",
g_clk_reg1, g_c033_data);
} else {
/* Write */
if(g_clk_read) {
halt_printf("Write time, but in read mode!\n");
}
clk_printf("Writing TIME loc %d with %02x\n",
g_clk_reg1, g_c033_data);
mask = 0xff << (8 * g_clk_reg1);
g_clk_cur_time = (g_clk_cur_time & (~mask)) |
((g_c033_data & 0xff) << (8 * g_clk_reg1));
}
g_clk_mode = CLK_IDLE;
break;
case CLK_INTERNAL:
if(read) {
printf("Attempting to read internal reg %02x!\n",
g_clk_reg1);
} else {
switch(g_clk_reg1) {
case 0x0: /* test register */
if(g_c033_data & 0xc0) {
printf("Writing test reg: %02x!\n",
g_c033_data);
/* set_halt(1); */
}
break;
case 0x1: /* write protect reg */
clk_printf("Writing clk wr_protect: %02x\n",
g_c033_data);
if(g_c033_data & 0x80) {
printf("Stop, wr clk wr_prot: %02x\n",
g_c033_data);
/* set_halt(1); */
}
break;
default:
halt_printf("Writing int reg: %02x with %02x\n",
g_clk_reg1, g_c033_data);
}
}
g_clk_mode = CLK_IDLE;
break;
default:
halt_printf("clk mode: %d unknown!\n", g_clk_mode);
g_clk_mode = CLK_IDLE;
break;
}
}
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
const char rcsid_clock_c[] = "@(#)$KmKId: clock.c,v 1.31 2004-10-19 17:32:07-04 kentd Exp $";
#include "defc.h"
#include <time.h>
#ifdef _WIN32
# include <windows.h>
# include <mmsystem.h>
#else
# include <sys/time.h>
#endif
extern int Verbose;
extern word32 g_vbl_count; // OG change int to word32
extern int g_rom_version;
extern int g_config_kegs_update_needed;
#define CLK_IDLE 1
#define CLK_TIME 2
#define CLK_INTERNAL 3
#define CLK_BRAM1 4
#define CLK_BRAM2 5
int g_clk_mode = CLK_IDLE;
int g_clk_read = 0;
int g_clk_reg1 = 0;
extern int g_c033_data;
extern int g_c034_val;
byte g_bram[2][256];
byte *g_bram_ptr = &(g_bram[0][0]);
word32 g_clk_cur_time = 0xa0000000;
int g_clk_next_vbl_update = 0;
double
get_dtime()
{
#ifndef _WIN32
struct timeval tp1;
double dsec;
double dusec;
#endif
double dtime;
/* Routine used to return actual system time as a double */
/* No routine cares about the absolute value, only deltas--maybe */
/* take advantage of that in future to increase usec accuracy */
#ifdef _WIN32
dtime = timeGetTime() / 1000.0;
#else
# ifdef SOLARIS
gettimeofday(&tp1, (void *)0);
# else
gettimeofday(&tp1, (struct timezone *)0);
# endif
dsec = (double)tp1.tv_sec;
dusec = (double)tp1.tv_usec;
dtime = dsec + (dusec / (1000.0 * 1000.0));
#endif
return dtime;
}
int
micro_sleep(double dtime)
{
#ifndef _WIN32
struct timeval Timer;
int ret;
#endif
if(dtime <= 0.0) {
return 0;
}
if(dtime >= 1.0) {
halt_printf("micro_sleep called with %f!!\n", dtime);
return -1;
}
#if 0
printf("usleep: %f\n", dtime);
#endif
#ifdef _WIN32
Sleep((DWORD)(dtime * 1000));
#else
Timer.tv_sec = 0;
Timer.tv_usec = (dtime * 1000000.0);
if( (ret = select(0, 0, 0, 0, &Timer)) < 0) {
fprintf(stderr, "micro_sleep (select) ret: %d, errno: %d\n",
ret, errno);
return -1;
}
#endif
return 0;
}
void
clk_bram_zero()
{
int i, j;
/* zero out all bram */
for(i = 0; i < 2; i++) {
for(j = 0; j < 256; j++) {
g_bram[i][j] = 0;
}
}
g_bram_ptr = &(g_bram[0][0]);
}
void
clk_bram_set(int bram_num, int offset, int val)
{
g_bram[bram_num][offset] = val;
}
extern void x_clk_setup_bram_version();
void
clk_setup_bram_version()
{
x_clk_setup_bram_version();
}
void
clk_write_bram(FILE *fconf)
{
int i, j, k;
for(i = 0; i < 2; i++) {
fprintf(fconf, "\n");
for(j = 0; j < 256; j += 16) {
fprintf(fconf, "bram%d[%02x] =", 2*i + 1, j);
for(k = 0; k < 16; k++) {
fprintf(fconf, " %02x", g_bram[i][j+k]);
}
fprintf(fconf, "\n");
}
}
}
void
update_cur_time()
{
struct tm *tm_ptr;
time_t cur_time;
unsigned int secs, secs2;
#ifdef UNDER_CE // OG Not supported on WIndows CE
/*
SYSTEMTIME stime;
FILETIME ftime;
GetLocalTime(&stime);
SystemTimeToFileTime(&stime,&ftime);
cur_time = ftime.dwLowDateTime;
*/
cur_time = time(0);
secs=0;
secs2=0;
#else
cur_time = time(0);
/* Figure out the timezone (effectively) by diffing two times. */
/* this is probably not right for a few hours around daylight savings*/
/* time transition */
secs2 = (unsigned int)mktime(gmtime(&cur_time));
tm_ptr = localtime(&cur_time);
secs = (unsigned int)mktime(tm_ptr);
#ifdef MAC
/* Mac OS X's mktime function modifies the tm_ptr passed in for */
/* the CDT timezone and breaks this algorithm. So on a Mac, we */
/* will use the tm_ptr->gmtoff member to correct the time */
secs = secs + tm_ptr->tm_gmtoff;
#else
secs = (unsigned int)cur_time - (secs2 - secs);
if(tm_ptr->tm_isdst) {
/* adjust for daylight savings time */
secs += 3600;
}
#endif
#endif
/* add in secs to make date based on Apple Jan 1, 1904 instead of */
/* Unix's Jan 1, 1970 */
/* So add in 66 years and 17 leap year days (1904 is a leap year) */
secs += ((66*365) + 17) * (24*3600);
g_clk_cur_time = secs;
clk_printf("Update g_clk_cur_time to %08x\n", g_clk_cur_time);
g_clk_next_vbl_update = g_vbl_count + 5;
}
/* clock_update called by sim65816 every VBL */
void
clock_update()
{
/* Nothing to do */
}
void
clock_update_if_needed()
{
int diff;
diff = g_clk_next_vbl_update - g_vbl_count;
if(diff < 0 || diff > 60) {
/* Been a while, re-read the clock */
update_cur_time();
}
}
void
clock_write_c034(word32 val)
{
g_c034_val = val & 0x7f;
if((val & 0x80) != 0) {
if((val & 0x20) == 0) {
printf("c034 write not last = 1\n");
/* set_halt(1); */
}
do_clock_data();
}
}
void
do_clock_data()
{
word32 mask;
int read;
int op;
clk_printf("In do_clock_data, g_clk_mode: %02x\n", g_clk_mode);
read = g_c034_val & 0x40;
switch(g_clk_mode) {
case CLK_IDLE:
g_clk_read = (g_c033_data >> 7) & 1;
g_clk_reg1 = (g_c033_data >> 2) & 3;
op = (g_c033_data >> 4) & 7;
if(!read) {
/* write */
switch(op) {
case 0x0: /* Read/write seconds register */
g_clk_mode = CLK_TIME;
clock_update_if_needed();
break;
case 0x3: /* internal registers */
g_clk_mode = CLK_INTERNAL;
if(g_clk_reg1 & 0x2) {
/* extend BRAM read */
g_clk_mode = CLK_BRAM2;
g_clk_reg1 = (g_c033_data & 7) << 5;
}
break;
case 0x2: /* read/write ram 0x10-0x13 */
g_clk_mode = CLK_BRAM1;
g_clk_reg1 += 0x10;
break;
case 0x4: /* read/write ram 0x00-0x0f */
case 0x5: case 0x6: case 0x7:
g_clk_mode = CLK_BRAM1;
g_clk_reg1 = (g_c033_data >> 2) & 0xf;
break;
default:
halt_printf("Bad c033_data in CLK_IDLE: %02x\n",
g_c033_data);
}
} else {
printf("clk read from IDLE mode!\n");
/* set_halt(1); */
g_clk_mode = CLK_IDLE;
}
break;
case CLK_BRAM2:
if(!read) {
/* get more bits of bram addr */
if((g_c033_data & 0x83) == 0x00) {
/* more address bits */
g_clk_reg1 |= ((g_c033_data >> 2) & 0x1f);
g_clk_mode = CLK_BRAM1;
} else {
halt_printf("CLK_BRAM2: c033_data: %02x!\n",
g_c033_data);
g_clk_mode = CLK_IDLE;
}
} else {
halt_printf("CLK_BRAM2: clock read!\n");
g_clk_mode = CLK_IDLE;
}
break;
case CLK_BRAM1:
/* access battery ram addr g_clk_reg1 */
if(read) {
if(g_clk_read) {
/* Yup, read */
g_c033_data = g_bram_ptr[g_clk_reg1];
clk_printf("Reading BRAM loc %02x: %02x\n",
g_clk_reg1, g_c033_data);
} else {
halt_printf("CLK_BRAM1: said wr, now read\n");
}
} else {
if(g_clk_read) {
halt_printf("CLK_BRAM1: said rd, now write\n");
} else {
/* Yup, write */
clk_printf("Writing BRAM loc %02x with %02x\n",
g_clk_reg1, g_c033_data);
g_bram_ptr[g_clk_reg1] = g_c033_data;
g_config_kegs_update_needed = 1;
}
}
g_clk_mode = CLK_IDLE;
break;
case CLK_TIME:
if(read) {
if(g_clk_read == 0) {
halt_printf("Reading time, but in set mode!\n");
}
g_c033_data = (g_clk_cur_time >> (g_clk_reg1 * 8)) &
0xff;
clk_printf("Returning time byte %d: %02x\n",
g_clk_reg1, g_c033_data);
} else {
/* Write */
if(g_clk_read) {
halt_printf("Write time, but in read mode!\n");
}
clk_printf("Writing TIME loc %d with %02x\n",
g_clk_reg1, g_c033_data);
mask = 0xff << (8 * g_clk_reg1);
g_clk_cur_time = (g_clk_cur_time & (~mask)) |
((g_c033_data & 0xff) << (8 * g_clk_reg1));
}
g_clk_mode = CLK_IDLE;
break;
case CLK_INTERNAL:
if(read) {
printf("Attempting to read internal reg %02x!\n",
g_clk_reg1);
} else {
switch(g_clk_reg1) {
case 0x0: /* test register */
if(g_c033_data & 0xc0) {
printf("Writing test reg: %02x!\n",
g_c033_data);
/* set_halt(1); */
}
break;
case 0x1: /* write protect reg */
clk_printf("Writing clk wr_protect: %02x\n",
g_c033_data);
if(g_c033_data & 0x80) {
printf("Stop, wr clk wr_prot: %02x\n",
g_c033_data);
/* set_halt(1); */
}
break;
default:
halt_printf("Writing int reg: %02x with %02x\n",
g_clk_reg1, g_c033_data);
}
}
g_clk_mode = CLK_IDLE;
break;
default:
halt_printf("clk mode: %d unknown!\n", g_clk_mode);
g_clk_mode = CLK_IDLE;
break;
}
}

678
jni/config_generic.c Normal file
View File

@ -0,0 +1,678 @@
#include "defc.h"
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
extern int g_rom_version;
extern word32 g_mem_size_base;
extern byte *g_rom_fc_ff_ptr;
extern byte *g_rom_cards_ptr;
extern word32 g_mem_size_exp;
extern Iwm iwm;
extern int Verbose;
extern int g_track_bytes_35[];
extern int g_track_nibs_35[];
extern int g_c031_disk35;
// was in config.cpp
int g_config_control_panel = 0;
int g_config_kegs_update_needed = 0;
int g_highest_smartport_unit = -1;
word32 g_cfg_vbl_count = 0;
int g_user_page2_shadow = 1;
int g_save_cur_a2_stat = 0;
byte g_rom_c600_rom01_diffs[256] = {
0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0xe2, 0x00,
0xd0, 0x50, 0x0f, 0x77, 0x5b, 0xb9, 0xc3, 0xb1,
0xb1, 0xf8, 0xcb, 0x4e, 0xb8, 0x60, 0xc7, 0x2e,
0xfc, 0xe0, 0xbf, 0x1f, 0x66, 0x37, 0x4a, 0x70,
0x55, 0x2c, 0x3c, 0xfc, 0xc2, 0xa5, 0x08, 0x29,
0xac, 0x21, 0xcc, 0x09, 0x55, 0x03, 0x17, 0x35,
0x4e, 0xe2, 0x0c, 0xe9, 0x3f, 0x9d, 0xc2, 0x06,
0x18, 0x88, 0x0d, 0x58, 0x57, 0x6d, 0x83, 0x8c,
0x22, 0xd3, 0x4f, 0x0a, 0xe5, 0xb7, 0x9f, 0x7d,
0x2c, 0x3e, 0xae, 0x7f, 0x24, 0x78, 0xfd, 0xd0,
0xb5, 0xd6, 0xe5, 0x26, 0x85, 0x3d, 0x8d, 0xc9,
0x79, 0x0c, 0x75, 0xec, 0x98, 0xcc, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00,
0x00, 0x00, 0x00, 0x39, 0x00, 0x35, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00,
0x6c, 0x44, 0xce, 0x4c, 0x01, 0x08, 0x00, 0x00
};
extern void x_config_load_roms();
extern void x_config_load_additional_roms();
void
config_load_roms()
{
int more_than_8mb;
int changed_rom;
int i;
// OG load roms
x_config_load_roms();
memset(&g_rom_cards_ptr[0], 0, 256*16);
/* initialize c600 rom to be diffs from the real ROM, to build-in */
/* Apple II compatibility without distributing ROMs */
for(i = 0; i < 256; i++) {
g_rom_cards_ptr[0x600 + i] = g_rom_fc_ff_ptr[0x3c600 + i] ^
g_rom_c600_rom01_diffs[i];
}
if(g_rom_version >= 3) {
/* some patches */
g_rom_cards_ptr[0x61b] ^= 0x40;
g_rom_cards_ptr[0x61c] ^= 0x33;
g_rom_cards_ptr[0x632] ^= 0xc0;
g_rom_cards_ptr[0x633] ^= 0x33;
}
x_config_load_additional_roms();
more_than_8mb = (g_mem_size_exp > 0x800000);
/* Only do the patch if users wants more than 8MB of expansion mem */
changed_rom = 0;
if(g_rom_version == 1) {
/* make some patches to ROM 01 */
#if 0
/* 1: Patch ROM selftest to not do speed test */
printf("Patching out speed test failures from ROM 01\n");
g_rom_fc_ff_ptr[0x3785a] = 0x18;
changed_rom = 1;
#endif
#if 0
/* 2: Patch ROM selftests not to do tests 2,4 */
/* 0 = skip, 1 = do it, test 1 is bit 0 of LSByte */
g_rom_fc_ff_ptr[0x371e9] = 0xf5;
g_rom_fc_ff_ptr[0x371ea] = 0xff;
changed_rom = 1;
#endif
if(more_than_8mb) {
/* Geoff Weiss patch to use up to 14MB of RAM */
g_rom_fc_ff_ptr[0x30302] = 0xdf;
g_rom_fc_ff_ptr[0x30314] = 0xdf;
g_rom_fc_ff_ptr[0x3031c] = 0x00;
changed_rom = 1;
}
/* Patch ROM selftest to not do ROM cksum if any changes*/
if(changed_rom) {
g_rom_fc_ff_ptr[0x37a06] = 0x18;
g_rom_fc_ff_ptr[0x37a07] = 0x18;
}
} else if(g_rom_version == 3) {
/* patch ROM 03 */
printf("Patching ROM 03 smartport bug\n");
/* 1: Patch Smartport code to fix a stupid bug */
/* that causes it to write the IWM status reg into c036, */
/* which is the system speed reg...it's "safe" since */
/* IWM status reg bit 4 must be 0 (7MHz)..., otherwise */
/* it might have turned on shadowing in all banks! */
g_rom_fc_ff_ptr[0x357c9] = 0x00;
changed_rom = 1;
#if 0
/* patch ROM 03 to not to speed test */
/* skip fast speed test */
g_rom_fc_ff_ptr[0x36ad7] = 0x18;
g_rom_fc_ff_ptr[0x36ad8] = 0x18;
changed_rom = 1;
#endif
#if 0
/* skip slow speed test */
g_rom_fc_ff_ptr[0x36ae7] = 0x18;
g_rom_fc_ff_ptr[0x36ae8] = 0x6b;
changed_rom = 1;
#endif
#if 0
/* 4: Patch ROM 03 selftests not to do tests 1-4 */
g_rom_fc_ff_ptr[0x364a9] = 0xf0;
g_rom_fc_ff_ptr[0x364aa] = 0xff;
changed_rom = 1;
#endif
/* ROM tests are in ff/6403-642x, where 6403 = addr of */
/* test 1, etc. */
if(more_than_8mb) {
/* Geoff Weiss patch to use up to 14MB of RAM */
g_rom_fc_ff_ptr[0x30b] = 0xdf;
g_rom_fc_ff_ptr[0x31d] = 0xdf;
g_rom_fc_ff_ptr[0x325] = 0x00;
changed_rom = 1;
}
if(changed_rom) {
/* patch ROM 03 selftest to not do ROM cksum */
g_rom_fc_ff_ptr[0x36cb0] = 0x18;
g_rom_fc_ff_ptr[0x36cb1] = 0x18;
}
}
}
Disk *
cfg_get_dsk_from_slot_drive(int slot, int drive)
{
Disk *dsk;
int max_drive;
/* Get dsk */
max_drive = 2;
switch(slot) {
case 5:
dsk = &(iwm.drive35[drive]);
break;
case 6:
dsk = &(iwm.drive525[drive]);
break;
default:
max_drive = MAX_C7_DISKS;
dsk = &(iwm.smartport[drive]);
}
if(drive >= max_drive) {
dsk -= drive; /* move back to drive 0 effectively */
}
return dsk;
}
void
insert_disk(int slot, int drive, const char *name, int ejected, int force_size,
const char *partition_name, int part_num)
{
byte buf_2img[512];
Disk *dsk;
char *name_ptr;
char *part_ptr;
int size;
#ifndef ACTIVEGS
char *uncomp_ptr, *system_str;
int system_len;
#endif
int part_len;
int cmp_o, cmp_p, cmp_dot;
int cmp_b, cmp_i, cmp_n;
int can_write;
int len;
int nibs;
int unix_pos;
int name_len;
int image_identified;
int exp_size;
int save_track;
int ret;
int tmp;
int i;
g_config_kegs_update_needed = 1;
if((slot < 5) || (slot > 7)) {
fatal_printf("Invalid slot for insertiing disk: %d\n", slot);
return;
}
if(drive < 0 || ((slot == 7) && (drive >= MAX_C7_DISKS)) ||
((slot < 7) && (drive > 1))) {
fatal_printf("Invalid drive for inserting disk: %d\n", drive);
return;
}
dsk = cfg_get_dsk_from_slot_drive(slot, drive);
// OG Do not insert same disk at same place
if (( dsk->name_ptr && name) && !strcmp(dsk->name_ptr,name)) return ;
#if 0
printf("Inserting disk %s (%s or %d) in slot %d, drive: %d\n", name,
partition_name, part_num, slot, drive);
#endif
dsk->just_ejected = 0;
dsk->force_size = force_size;
if(dsk->fd >= 0) {
eject_disk(dsk);
}
// OG check for valid name first
if (!name) return ;
/* Before opening, make sure no other mounted disk has this name */
/* If so, unmount it */
if(!ejected) {
for(i = 0; i < 2; i++) {
eject_named_disk(&iwm.drive525[i], name,partition_name);
eject_named_disk(&iwm.drive35[i], name, partition_name);
}
for(i = 0; i < MAX_C7_DISKS; i++) {
eject_named_disk(&iwm.smartport[i],name,partition_name);
}
}
if(dsk->name_ptr != 0) {
/* free old name_ptr */
free(dsk->name_ptr);
}
name_len = strlen(name);
name_ptr = (char *)malloc(name_len + 1);
strncpy(name_ptr, name, name_len + 1);
dsk->name_ptr = name_ptr;
dsk->partition_name = 0;
if(partition_name != 0) {
part_len = strlen(partition_name) + 1;
part_ptr = (char *)malloc(part_len);
strncpy(part_ptr, partition_name, part_len);
dsk->partition_name = part_ptr;
}
dsk->partition_num = part_num;
iwm_printf("Opening up disk image named: %s\n", name_ptr);
if(ejected) {
/* just get out of here */
dsk->fd = -1;
return;
}
dsk->fd = -1;
can_write = 1;
//OG discard .GZ support
#ifndef ACTIVEGS
if((name_len > 3) && (strcmp(&name_ptr[name_len - 3], ".gz") == 0)) {
/* it's gzip'ed, try to gunzip it, then unlink the */
/* uncompressed file */
can_write = 0;
uncomp_ptr = (char *)malloc(name_len + 1);
strncpy(uncomp_ptr, name_ptr, name_len + 1);
uncomp_ptr[name_len - 3] = 0;
system_len = 2*name_len + 100;
system_str = (char *)malloc(system_len + 1);
snprintf(system_str, system_len,
"set -o noclobber;gunzip -c %c%s%c > %c%s%c",
0x22, name_ptr, 0x22,
0x22, uncomp_ptr, 0x22);
/* 0x22 are " to allow spaces in filenames */
printf("I am uncompressing %s into %s for mounting\n",
name_ptr, uncomp_ptr);
ret = system(system_str);
if(ret == 0) {
/* successfully ran */
dsk->fd = open(uncomp_ptr, O_RDONLY | O_BINARY, 0x1b6);
iwm_printf("Opening .gz file %s is fd: %d\n",
uncomp_ptr, dsk->fd);
/* and, unlink the temporary file */
(void)unlink(uncomp_ptr);
}
free(system_str);
free(uncomp_ptr);
/* Reduce name_len by 3 so that subsequent compares for .po */
/* look at the correct chars */
name_len -= 3;
}
#endif // OG
if(dsk->fd < 0 && can_write) {
dsk->fd = open(name_ptr, O_RDWR | O_BINARY, 0x1b6);
}
if(dsk->fd < 0 && can_write) {
printf("Trying to open %s read-only, errno: %d\n", name_ptr,
errno);
dsk->fd = open(name_ptr, O_RDONLY | O_BINARY, 0x1b6);
can_write = 0;
}
iwm_printf("open returned: %d\n", dsk->fd);
if(dsk->fd < 0) {
fatal_printf("Disk image %s does not exist!\n", name_ptr);
return;
}
if(can_write != 0) {
dsk->write_prot = 0;
dsk->write_through_to_unix = 1;
} else {
dsk->write_prot = 1;
dsk->write_through_to_unix = 0;
}
save_track = dsk->cur_qtr_track; /* save arm position */
dsk->image_type = DSK_TYPE_PRODOS;
dsk->image_start = 0;
/* See if it is in 2IMG format */
ret = read(dsk->fd, (char *)&buf_2img[0], 512);
size = force_size;
if(size <= 0) {
size = cfg_get_fd_size(dsk->fd) ;
}
/* Try to guess that there is a Mac Binary header of 128 bytes */
/* See if image size & 0xfff = 0x080 which indicates extra 128 bytes */
if((size & 0xfff) == 0x080) {
printf("Assuming Mac Binary header on %s\n", dsk->name_ptr);
dsk->image_start += 0x80;
}
image_identified = 0;
if(buf_2img[0] == '2' && buf_2img[1] == 'I' && buf_2img[2] == 'M' &&
buf_2img[3] == 'G') {
// OG Put back Gilles Tschopp hack to deal with corrupted 2IMG files
size -= 64;
size = size & -0x1000;
/* It's a 2IMG disk */
printf("Image named %s is in 2IMG format\n", dsk->name_ptr);
image_identified = 1;
if(buf_2img[12] == 0) {
printf("2IMG is in DOS 3.3 sector order\n");
dsk->image_type = DSK_TYPE_DOS33;
}
if(buf_2img[19] & 0x80) {
/* disk is locked */
printf("2IMG is write protected\n");
dsk->write_prot = 1;
dsk->write_through_to_unix = 0;
}
if((buf_2img[17] & 1) && (dsk->image_type == DSK_TYPE_DOS33)) {
dsk->vol_num = buf_2img[16];
printf("Setting DOS 3.3 vol num to %d\n", dsk->vol_num);
}
// OG do not overwrite when 2mg size = 0
int size2img = (buf_2img[31] << 24) + (buf_2img[30] << 16) + (buf_2img[29] << 8) + buf_2img[28];
if (size2img) size = size2img;
else printf(".2MG has corrupted size - fixed.\n");
unix_pos = (buf_2img[27] << 24) + (buf_2img[26] << 16) +
(buf_2img[25] << 8) + buf_2img[24];
// Some 2IMG archives have the size byte reversed
if(size == 0x800c00) {
// Byte reversed 0x0c8000
size = 0x0c8000;
}
dsk->image_start = unix_pos;
dsk->image_size = size;
}
exp_size = 800*1024;
if(dsk->disk_525) {
exp_size = 140*1024;
}
if(!image_identified) {
/* See if it might be the Mac diskcopy format */
tmp = (buf_2img[0x40] << 24) + (buf_2img[0x41] << 16) +
(buf_2img[0x42] << 8) + buf_2img[0x43];
if((size >= (exp_size + 0x54)) && (tmp == exp_size)) {
/* It's diskcopy since data size field matches */
printf("Image named %s is in Mac diskcopy format\n",
dsk->name_ptr);
image_identified = 1;
dsk->image_start += 0x54;
dsk->image_size = exp_size;
dsk->image_type = DSK_TYPE_PRODOS; /* ProDOS */
}
}
if(!image_identified) {
/* Assume raw image */
dsk->image_size = size;
dsk->image_type = DSK_TYPE_PRODOS;
if(dsk->disk_525) {
dsk->image_type = DSK_TYPE_DOS33;
if(name_len >= 4) {
cmp_o = dsk->name_ptr[name_len-1];
cmp_p = dsk->name_ptr[name_len-2];
cmp_dot = dsk->name_ptr[name_len-3];
if(cmp_dot == '.' &&
(cmp_p == 'p' || cmp_p == 'P') &&
(cmp_o == 'o' || cmp_o == 'O')) {
dsk->image_type = DSK_TYPE_PRODOS;
}
cmp_b = dsk->name_ptr[name_len-1];
cmp_i = dsk->name_ptr[name_len-2];
cmp_n = dsk->name_ptr[name_len-3];
cmp_dot = dsk->name_ptr[name_len-4];
if(cmp_dot == '.' &&
(cmp_n == 'n' || cmp_n == 'N') &&
(cmp_i == 'i' || cmp_i == 'I') &&
(cmp_b == 'b' || cmp_b == 'B')) {
dsk->image_type = DSK_TYPE_NIB;
dsk->write_prot = 0; // OG : Remove WriteProtect on .nib
dsk->write_through_to_unix = 0;
}
}
}
}
dsk->disk_dirty = 0;
dsk->nib_pos = 0;
dsk->trks = 0;
if(dsk->smartport) {
g_highest_smartport_unit = MAX(dsk->drive,
g_highest_smartport_unit);
// OG Disabled partition support
#ifndef ACTIVEGS
if(partition_name != 0 || part_num >= 0) {
ret = cfg_partition_find_by_name_or_num(dsk->fd,
partition_name, part_num, dsk);
printf("partition %s (num %d) mounted, wr_prot: %d\n",
partition_name, part_num, dsk->write_prot);
if(ret < 0) {
close(dsk->fd);
dsk->fd = -1;
return;
}
}
#endif
iwm_printf("adding smartport device[%d], size:%08x, "
"img_sz:%08x\n", dsk->drive, dsk->trks[0].unix_len,
dsk->image_size);
} else if(dsk->disk_525) {
unix_pos = dsk->image_start;
size = dsk->image_size;
disk_set_num_tracks(dsk, 4*35);
len = 0x1000;
nibs = NIB_LEN_525;
if(dsk->image_type == DSK_TYPE_NIB) {
len = dsk->image_size / 35;;
nibs = len;
}
if(size != 35*len) {
fatal_printf("Disk 5.25 error: size is %d, not 140K. "
"Will try to mount anyway\n", size, 35*len);
}
for(i = 0; i < 35; i++) {
iwm_move_to_track(dsk, 4*i);
disk_unix_to_nib(dsk, 4*i, unix_pos, len, nibs);
unix_pos += len;
}
} else {
/* disk_35 */
unix_pos = dsk->image_start;
size = dsk->image_size;
if(size != 800*1024) {
fatal_printf("Disk 3.5 error: size is %d, not 800K. "
"Will try to mount anyway\n", size);
}
disk_set_num_tracks(dsk, 2*80);
for(i = 0; i < 2*80; i++) {
iwm_move_to_track(dsk, i);
len = g_track_bytes_35[i >> 5];
nibs = g_track_nibs_35[i >> 5];
iwm_printf("Trk: %d.%d = unix: %08x, %04x, %04x\n",
i>>1, i & 1, unix_pos, len, nibs);
disk_unix_to_nib(dsk, i, unix_pos, len, nibs);
unix_pos += len;
iwm_printf(" trk_len:%05x\n", dsk->trks[i].track_len);
}
}
iwm_move_to_track(dsk, save_track);
// OG send info back to the container
#ifdef ACTIVEGS
{
extern void prepareDriveInfo(Disk* dsk,int slot, int drive);
prepareDriveInfo(dsk,slot,drive);
}
#endif
}
void
eject_named_disk(Disk *dsk, const char *name, const char *partition_name)
{
if(dsk->fd < 0) {
return;
}
/* If name matches, eject the disk! */
if(!strcmp(dsk->name_ptr, name)) {
/* It matches, eject it */
if((partition_name != 0) && (dsk->partition_name != 0)) {
/* If both have partitions, and they differ, then */
/* don't eject. Otherwise, eject */
if(strcmp(dsk->partition_name, partition_name) != 0) {
/* Don't eject */
return;
}
}
eject_disk(dsk);
}
}
void
eject_disk_by_num(int slot, int drive)
{
Disk *dsk;
dsk = cfg_get_dsk_from_slot_drive(slot, drive);
eject_disk(dsk);
}
void
eject_disk(Disk *dsk)
{
int motor_on;
int i;
if(dsk->fd < 0) {
return;
}
g_config_kegs_update_needed = 1;
motor_on = iwm.motor_on;
if(g_c031_disk35 & 0x40) {
motor_on = iwm.motor_on35;
}
if(motor_on) {
halt_printf("Try eject dsk:%s, but motor_on!\n", dsk->name_ptr);
}
iwm_flush_disk_to_unix(dsk);
printf("Ejecting disk: %s\n", dsk->name_ptr);
/* Free all memory, close file */
/* free the tracks first */
if(dsk->trks != 0) {
for(i = 0; i < dsk->num_tracks; i++) {
if(dsk->trks[i].nib_area) {
free(dsk->trks[i].nib_area);
}
dsk->trks[i].nib_area = 0;
dsk->trks[i].track_len = 0;
}
free(dsk->trks);
}
dsk->num_tracks = 0;
dsk->trks = 0;
/* close file, clean up dsk struct */
close(dsk->fd);
dsk->image_start = 0;
dsk->image_size = 0;
dsk->nib_pos = 0;
dsk->disk_dirty = 0;
dsk->write_through_to_unix = 0;
dsk->write_prot = 1;
dsk->fd = -1;
dsk->just_ejected = 1;
/* Leave name_ptr valid */ // OG WHY?
// OG Free memory allocated for the disk name
if (dsk->name_ptr)
{
free(dsk->name_ptr);
dsk->name_ptr = NULL;
}
}
int
cfg_get_fd_size(int fd)
{
struct stat stat_buf;
int ret;
ret = fstat(fd, &stat_buf);
if(ret != 0) {
fprintf(stderr,"fstat returned %d on fd %d, errno: %d\n",
ret, fd, errno);
stat_buf.st_size = 0;
}
return stat_buf.st_size;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,315 +1,367 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
#ifdef INCLUDE_RCSID_C
const char rcsid_defc_h[] = "@(#)$KmKId: defc.h,v 1.100 2004-11-09 02:02:07-05 kentd Exp $";
#endif
#include "defcomm.h"
#define STRUCT(a) typedef struct _ ## a a; struct _ ## a
typedef unsigned char byte;
typedef unsigned short word16;
typedef unsigned int word32;
#if _MSC_VER
typedef unsigned __int64 word64;
#else
typedef unsigned long long word64;
#endif
void U_STACK_TRACE();
/* 28MHz crystal, plus every 65th 1MHz cycle is stretched 140ns */
#define CYCS_28_MHZ (28636360)
#define DCYCS_28_MHZ (1.0*CYCS_28_MHZ)
#define CYCS_3_5_MHZ (CYCS_28_MHZ/8)
#define DCYCS_1_MHZ ((DCYCS_28_MHZ/28.0)*(65.0*7/(65.0*7+1.0)))
#define CYCS_1_MHZ ((int)DCYCS_1_MHZ)
/* #define DCYCS_IN_16MS_RAW (DCYCS_1_MHZ / 60.0) */
#define DCYCS_IN_16MS_RAW (262.0 * 65.0)
/* Use precisely 17030 instead of forcing 60 Hz since this is the number of */
/* 1MHz cycles per screen */
#define DCYCS_IN_16MS ((double)((int)DCYCS_IN_16MS_RAW))
#define DRECIP_DCYCS_IN_16MS (1.0 / (DCYCS_IN_16MS))
#ifdef KEGS_LITTLE_ENDIAN
# define BIGEND(a) ((((a) >> 24) & 0xff) + \
(((a) >> 8) & 0xff00) + \
(((a) << 8) & 0xff0000) + \
(((a) << 24) & 0xff000000))
# define GET_BE_WORD16(a) ((((a) >> 8) & 0xff) + (((a) << 8) & 0xff00))
# define GET_BE_WORD32(a) (BIGEND(a))
#else
# define BIGEND(a) (a)
# define GET_BE_WORD16(a) (a)
# define GET_BE_WORD32(a) (a)
#endif
#define MAXNUM_HEX_PER_LINE 32
#ifdef __NeXT__
# include <libc.h>
#endif
#ifndef _WIN32
# include <unistd.h>
# include <sys/ioctl.h>
# include <sys/wait.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#ifdef HPUX
# include <machine/inline.h> /* for GET_ITIMER */
#endif
#ifdef SOLARIS
# include <sys/filio.h>
#endif
#ifndef O_BINARY
/* work around some Windows junk */
# define O_BINARY 0
#endif
STRUCT(Pc_log) {
double dcycs;
word32 dbank_kpc;
word32 instr;
word32 psr_acc;
word32 xreg_yreg;
word32 stack_direct;
word32 pad;
};
STRUCT(Data_log) {
double dcycs;
word32 addr;
word32 val;
word32 size;
};
STRUCT(Event) {
double dcycs;
int type;
Event *next;
};
STRUCT(Fplus) {
double plus_1;
double plus_2;
double plus_3;
double plus_x_minus_1;
};
STRUCT(Engine_reg) {
double fcycles;
word32 kpc;
word32 acc;
word32 xreg;
word32 yreg;
word32 stack;
word32 dbank;
word32 direct;
word32 psr;
Fplus *fplus_ptr;
};
STRUCT(Kimage) {
void *dev_handle;
void *dev_handle2;
byte *data_ptr;
int width_req;
int width_act;
int height;
int depth;
int mdepth;
int aux_info;
};
typedef byte *Pg_info;
STRUCT(Page_info) {
Pg_info rd_wr;
};
STRUCT(Cfg_menu) {
const char *str;
void *ptr;
const char *name_str;
void *defptr;
int cfgtype;
};
STRUCT(Cfg_dirent) {
char *name;
int is_dir;
int size;
int image_start;
int part_num;
};
STRUCT(Cfg_listhdr) {
Cfg_dirent *direntptr;
int max;
int last;
int invalid;
int curent;
int topent;
int num_to_show;
};
STRUCT(Emustate_intlist) {
const char *str;
int *iptr;
};
STRUCT(Emustate_dbllist) {
const char *str;
double *dptr;
};
STRUCT(Emustate_word32list) {
const char *str;
word32 *wptr;
};
#ifdef __LP64__
# define PTR2WORD(a) ((unsigned long)(a))
#else
# define PTR2WORD(a) ((unsigned int)(a))
#endif
#define ALTZP (g_c068_statereg & 0x80)
/* #define PAGE2 (g_c068_statereg & 0x40) */
#define RAMRD (g_c068_statereg & 0x20)
#define RAMWRT (g_c068_statereg & 0x10)
#define RDROM (g_c068_statereg & 0x08)
#define LCBANK2 (g_c068_statereg & 0x04)
#define ROMB (g_c068_statereg & 0x02)
#define INTCX (g_c068_statereg & 0x01)
#define C041_EN_25SEC_INTS 0x10
#define C041_EN_VBL_INTS 0x08
#define C041_EN_SWITCH_INTS 0x04
#define C041_EN_MOVE_INTS 0x02
#define C041_EN_MOUSE 0x01
/* WARNING: SCC1 and SCC0 interrupts must be in this order for scc.c */
/* This order matches the SCC hardware */
#define IRQ_PENDING_SCC1_ZEROCNT 0x00001
#define IRQ_PENDING_SCC1_TX 0x00002
#define IRQ_PENDING_SCC1_RX 0x00004
#define IRQ_PENDING_SCC0_ZEROCNT 0x00008
#define IRQ_PENDING_SCC0_TX 0x00010
#define IRQ_PENDING_SCC0_RX 0x00020
#define IRQ_PENDING_C023_SCAN 0x00100
#define IRQ_PENDING_C023_1SEC 0x00200
#define IRQ_PENDING_C046_25SEC 0x00400
#define IRQ_PENDING_C046_VBL 0x00800
#define IRQ_PENDING_ADB_KBD_SRQ 0x01000
#define IRQ_PENDING_ADB_DATA 0x02000
#define IRQ_PENDING_ADB_MOUSE 0x04000
#define IRQ_PENDING_DOC 0x08000
#define EXTRU(val, pos, len) \
( ( (len) >= (pos) + 1) ? ((val) >> (31-(pos))) : \
(((val) >> (31-(pos)) ) & ( (1<<(len) ) - 1) ) )
#define DEP1(val, pos, old_val) \
(((old_val) & ~(1 << (31 - (pos))) ) | \
( ((val) & 1) << (31 - (pos))) )
#define set_halt(val) \
if(val) { set_halt_act(val); }
#define clear_halt() \
clr_halt_act()
#define GET_PAGE_INFO_RD(page) \
(page_info_rd_wr[page].rd_wr)
#define GET_PAGE_INFO_WR(page) \
(page_info_rd_wr[0x10000 + PAGE_INFO_PAD_SIZE + (page)].rd_wr)
#define SET_PAGE_INFO_RD(page,val) \
;page_info_rd_wr[page].rd_wr = (Pg_info)val;
#define SET_PAGE_INFO_WR(page,val) \
;page_info_rd_wr[0x10000 + PAGE_INFO_PAD_SIZE + (page)].rd_wr = \
(Pg_info)val;
#define VERBOSE_DISK 0x001
#define VERBOSE_IRQ 0x002
#define VERBOSE_CLK 0x004
#define VERBOSE_SHADOW 0x008
#define VERBOSE_IWM 0x010
#define VERBOSE_DOC 0x020
#define VERBOSE_ADB 0x040
#define VERBOSE_SCC 0x080
#define VERBOSE_TEST 0x100
#define VERBOSE_VIDEO 0x200
#define VERBOSE_MAC 0x400
#ifdef NO_VERB
# define DO_VERBOSE 0
#else
# define DO_VERBOSE 1
#endif
#define disk_printf if(DO_VERBOSE && (Verbose & VERBOSE_DISK)) printf
#define irq_printf if(DO_VERBOSE && (Verbose & VERBOSE_IRQ)) printf
#define clk_printf if(DO_VERBOSE && (Verbose & VERBOSE_CLK)) printf
#define shadow_printf if(DO_VERBOSE && (Verbose & VERBOSE_SHADOW)) printf
#define iwm_printf if(DO_VERBOSE && (Verbose & VERBOSE_IWM)) printf
#define doc_printf if(DO_VERBOSE && (Verbose & VERBOSE_DOC)) printf
#define adb_printf if(DO_VERBOSE && (Verbose & VERBOSE_ADB)) printf
#define scc_printf if(DO_VERBOSE && (Verbose & VERBOSE_SCC)) printf
#define test_printf if(DO_VERBOSE && (Verbose & VERBOSE_TEST)) printf
#define vid_printf if(DO_VERBOSE && (Verbose & VERBOSE_VIDEO)) printf
#define mac_printf if(DO_VERBOSE && (Verbose & VERBOSE_MAC)) printf
#define HALT_ON_SCAN_INT 0x001
#define HALT_ON_IRQ 0x002
#define HALT_ON_SHADOW_REG 0x004
#define HALT_ON_C70D_WRITES 0x008
#define HALT_ON(a, msg) \
if(Halt_on & a) { \
halt_printf(msg); \
}
#ifndef MIN
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
# define MAX(a,b) (((a) < (b)) ? (b) : (a))
#endif
#define GET_ITIMER(dest) dest = get_itimer();
#include "iwm.h"
#include "protos.h"
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
#ifdef INCLUDE_RCSID_C
const char rcsid_defc_h[] = "@(#)$KmKId: defc.h,v 1.100 2004-11-09 02:02:07-05 kentd Exp $";
#endif
#include "defcomm.h"
// OG redirect printf to console
#ifdef ACTIVEGS
#include <stdio.h>
extern "C" int outputInfo(const char* format,...);
extern "C" int fOutputInfo(FILE*,const char* format,...);
#define printf outputInfo
#define fprintf fOutputInfo
#endif
#define STRUCT(a) typedef struct _ ## a a; struct _ ## a
typedef unsigned char byte;
typedef unsigned short word16;
typedef unsigned int word32;
#if _MSC_VER
typedef unsigned __int64 word64;
#else
typedef unsigned long long word64;
#endif
void U_STACK_TRACE();
/* 28MHz crystal, plus every 65th 1MHz cycle is stretched 140ns */
#define CYCS_28_MHZ (28636360)
#define DCYCS_28_MHZ (1.0*CYCS_28_MHZ)
#define CYCS_3_5_MHZ (CYCS_28_MHZ/8)
#define DCYCS_1_MHZ ((DCYCS_28_MHZ/28.0)*(65.0*7/(65.0*7+1.0)))
#define CYCS_1_MHZ ((int)DCYCS_1_MHZ)
/* #define DCYCS_IN_16MS_RAW (DCYCS_1_MHZ / 60.0) */
#define DCYCS_IN_16MS_RAW (262.0 * 65.0)
/* Use precisely 17030 instead of forcing 60 Hz since this is the number of */
/* 1MHz cycles per screen */
#define DCYCS_IN_16MS ((double)((int)DCYCS_IN_16MS_RAW))
#define DRECIP_DCYCS_IN_16MS (1.0 / (DCYCS_IN_16MS))
#ifdef KEGS_LITTLE_ENDIAN
# define BIGEND(a) ((((a) >> 24) & 0xff) + \
(((a) >> 8) & 0xff00) + \
(((a) << 8) & 0xff0000) + \
(((a) << 24) & 0xff000000))
# define GET_BE_WORD16(a) ((((a) >> 8) & 0xff) + (((a) << 8) & 0xff00))
# define GET_BE_WORD32(a) (BIGEND(a))
#else
# define BIGEND(a) (a)
# define GET_BE_WORD16(a) (a)
# define GET_BE_WORD32(a) (a)
#endif
#define MAXNUM_HEX_PER_LINE 32
#ifdef __NeXT__
# include <libc.h>
#endif
#if !defined( _WIN32) && !defined(UNDER_CE) // OG
# include <unistd.h>
# include <sys/ioctl.h>
# include <sys/wait.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#ifndef UNDER_CE // OG CE SPecific
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
// OG Adding support for open
#ifdef WIN32
#include <io.h>
#endif
#else
extern int errno;
extern int open(const char* name,int,...);
extern int read(int,char*,int);
extern int close(int);
extern int write( int fd, const void *buffer, unsigned int count );
extern int lseek(int,int,int);
struct stat { int st_size; };
extern int stat(const char* name, struct stat*);
extern int fstat(int, struct stat*);
#define O_RDWR 1
#define O_BINARY 2
#define O_RDONLY 4
#define O_WRONLY 8
#define O_CREAT 16
#define O_TRUNC 32
#define EAGAIN 11
#define EINTR 4
#endif
#ifdef HPUX
# include <machine/inline.h> /* for GET_ITIMER */
#endif
#ifdef SOLARIS
# include <sys/filio.h>
#endif
#ifndef O_BINARY
/* work around some Windows junk */
# define O_BINARY 0
#endif
STRUCT(Pc_log) {
double dcycs;
word32 dbank_kpc;
word32 instr;
word32 psr_acc;
word32 xreg_yreg;
word32 stack_direct;
word32 pad;
};
STRUCT(Data_log) {
double dcycs;
word32 addr;
word32 val;
word32 size;
};
STRUCT(Event) {
double dcycs;
int type;
Event *next;
};
STRUCT(Fplus) {
double plus_1;
double plus_2;
double plus_3;
double plus_x_minus_1;
};
STRUCT(Engine_reg) {
double fcycles;
word32 kpc;
word32 acc;
word32 xreg;
word32 yreg;
word32 stack;
word32 dbank;
word32 direct;
word32 psr;
Fplus *fplus_ptr;
};
STRUCT(Kimage) {
void *dev_handle;
void *dev_handle2;
byte *data_ptr;
int width_req;
int width_act;
int height;
int depth;
int mdepth;
int aux_info;
};
typedef byte *Pg_info;
STRUCT(Page_info) {
Pg_info rd_wr;
};
STRUCT(Cfg_menu) {
const char *str;
void *ptr;
const char *name_str;
void *defptr;
int cfgtype;
};
STRUCT(Cfg_dirent) {
char *name;
int is_dir;
int size;
int image_start;
int part_num;
};
STRUCT(Cfg_listhdr) {
Cfg_dirent *direntptr;
int max;
int last;
int invalid;
int curent;
int topent;
int num_to_show;
};
STRUCT(Emustate_intlist) {
const char *str;
int *iptr;
};
STRUCT(Emustate_dbllist) {
const char *str;
double *dptr;
};
STRUCT(Emustate_word32list) {
const char *str;
word32 *wptr;
};
#ifdef __LP64__
# define PTR2WORD(a) ((unsigned long)(a))
#else
# define PTR2WORD(a) ((unsigned int)(a))
#endif
#define ALTZP (g_c068_statereg & 0x80)
/* #define PAGE2 (g_c068_statereg & 0x40) */
#define RAMRD (g_c068_statereg & 0x20)
#define RAMWRT (g_c068_statereg & 0x10)
#define RDROM (g_c068_statereg & 0x08)
#define LCBANK2 (g_c068_statereg & 0x04)
#define ROMB (g_c068_statereg & 0x02)
#define INTCX (g_c068_statereg & 0x01)
#define C041_EN_25SEC_INTS 0x10
#define C041_EN_VBL_INTS 0x08
#define C041_EN_SWITCH_INTS 0x04
#define C041_EN_MOVE_INTS 0x02
#define C041_EN_MOUSE 0x01
/* WARNING: SCC1 and SCC0 interrupts must be in this order for scc.c */
/* This order matches the SCC hardware */
#define IRQ_PENDING_SCC1_ZEROCNT 0x00001
#define IRQ_PENDING_SCC1_TX 0x00002
#define IRQ_PENDING_SCC1_RX 0x00004
#define IRQ_PENDING_SCC0_ZEROCNT 0x00008
#define IRQ_PENDING_SCC0_TX 0x00010
#define IRQ_PENDING_SCC0_RX 0x00020
#define IRQ_PENDING_C023_SCAN 0x00100
#define IRQ_PENDING_C023_1SEC 0x00200
#define IRQ_PENDING_C046_25SEC 0x00400
#define IRQ_PENDING_C046_VBL 0x00800
#define IRQ_PENDING_ADB_KBD_SRQ 0x01000
#define IRQ_PENDING_ADB_DATA 0x02000
#define IRQ_PENDING_ADB_MOUSE 0x04000
#define IRQ_PENDING_DOC 0x08000
#define EXTRU(val, pos, len) \
( ( (len) >= (pos) + 1) ? ((val) >> (31-(pos))) : \
(((val) >> (31-(pos)) ) & ( (1<<(len) ) - 1) ) )
#define DEP1(val, pos, old_val) \
(((old_val) & ~(1 << (31 - (pos))) ) | \
( ((val) & 1) << (31 - (pos))) )
#define set_halt(val) \
if(val) { set_halt_act(val); }
#define clear_halt() \
clr_halt_act()
#define GET_PAGE_INFO_RD(page) \
(page_info_rd_wr[page].rd_wr)
#define GET_PAGE_INFO_WR(page) \
(page_info_rd_wr[0x10000 + PAGE_INFO_PAD_SIZE + (page)].rd_wr)
#define SET_PAGE_INFO_RD(page,val) \
;page_info_rd_wr[page].rd_wr = (Pg_info)val;
#define SET_PAGE_INFO_WR(page,val) \
;page_info_rd_wr[0x10000 + PAGE_INFO_PAD_SIZE + (page)].rd_wr = \
(Pg_info)val;
#define VERBOSE_DISK 0x001
#define VERBOSE_IRQ 0x002
#define VERBOSE_CLK 0x004
#define VERBOSE_SHADOW 0x008
#define VERBOSE_IWM 0x010
#define VERBOSE_DOC 0x020
#define VERBOSE_ADB 0x040
#define VERBOSE_SCC 0x080
#define VERBOSE_TEST 0x100
#define VERBOSE_VIDEO 0x200
#define VERBOSE_MAC 0x400
#ifdef NO_VERB
# define DO_VERBOSE 0
#else
# define DO_VERBOSE 1
#endif
#define disk_printf if(DO_VERBOSE && (Verbose & VERBOSE_DISK)) printf
#define irq_printf if(DO_VERBOSE && (Verbose & VERBOSE_IRQ)) printf
#define clk_printf if(DO_VERBOSE && (Verbose & VERBOSE_CLK)) printf
#define shadow_printf if(DO_VERBOSE && (Verbose & VERBOSE_SHADOW)) printf
#define iwm_printf if(DO_VERBOSE && (Verbose & VERBOSE_IWM)) printf
#define doc_printf if(DO_VERBOSE && (Verbose & VERBOSE_DOC)) printf
#define adb_printf if(DO_VERBOSE && (Verbose & VERBOSE_ADB)) printf
#define scc_printf if(DO_VERBOSE && (Verbose & VERBOSE_SCC)) printf
#define test_printf if(DO_VERBOSE && (Verbose & VERBOSE_TEST)) printf
#define vid_printf if(DO_VERBOSE && (Verbose & VERBOSE_VIDEO)) printf
#define mac_printf if(DO_VERBOSE && (Verbose & VERBOSE_MAC)) printf
#define HALT_ON_SCAN_INT 0x001
#define HALT_ON_IRQ 0x002
#define HALT_ON_SHADOW_REG 0x004
#define HALT_ON_C70D_WRITES 0x008
#define HALT_ON(a, msg) \
if(Halt_on & a) { \
halt_printf(msg); \
}
#ifndef MIN
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
# define MAX(a,b) (((a) < (b)) ? (b) : (a))
#endif
#define GET_ITIMER(dest) dest = get_itimer();
#include "iwm.h"
#include "protos.h"
// OG Added define for joystick
#define JOYSTICK_TYPE_KEYPAD 0
#define JOYSTICK_TYPE_MOUSE 1
#define JOYSTICK_TYPE_NATIVE_1 2
#define JOYSTICK_TYPE_NATIVE_2 3
#define JOYSTICK_TYPE_NONE 4 // OG Added Joystick None
#define NB_JOYSTICK_TYPE 5

View File

@ -1,170 +1,175 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
#ifdef INCLUDE_RCSID_C
const char rcsdif_defcomm_h[] = "@(#)$KmKId: defcomm.h,v 1.94 2004-10-13 21:53:44-04 kentd Exp $";
#endif
#if 0
# define CHECK_BREAKPOINTS
#endif
#define SHIFT_PER_CHANGE 3
#define CHANGE_SHIFT (5 + SHIFT_PER_CHANGE)
#define SLOW_MEM_CH_SIZE (0x10000 >> CHANGE_SHIFT)
#define MAXNUM_HEX_PER_LINE 32
/* Different Joystick defines */
#define JOYSTICK_MOUSE 1
#define JOYSTICK_LINUX 2
#define JOYSTICK_KEYPAD 3
#define JOYSTICK_WIN32_1 4
#define JOYSTICK_WIN32_2 5
#define HALT_EVENT 0x10
#define MAX_BREAK_POINTS 0x20
#define MAX_BP_INDEX 0x100
#define MAX_BP_PER_INDEX 3 /* 4 word32s total = 16 bytes */
#define SIZE_BREAKPT_ENTRY_BITS 4 /* 16 bytes = 4 bits */
/* Warning--next defines used by asm! */
#define PAGE_INFO_PAD_SIZE 0x800
#define PAGE_INFO_WR_OFFSET 0x10000+PAGE_INFO_PAD_SIZE
#define BANK_IO_BIT 31
#define BANK_SHADOW_BIT 30
#define BANK_SHADOW2_BIT 29
#define BANK_IO2_BIT 28
#define BANK_BREAK_BIT 27
#define BANK_BREAK (1 << (31 - BANK_BREAK_BIT))
#define BANK_IO2_TMP (1 << (31 - BANK_IO2_BIT))
#define BANK_IO_TMP (1 << (31 - BANK_IO_BIT))
#define BANK_SHADOW (1 << (31 - BANK_SHADOW_BIT))
#define BANK_SHADOW2 (1 << (31 - BANK_SHADOW2_BIT))
#define SET_BANK_IO \
(&g_dummy_memory1_ptr[BANK_IO_TMP | BANK_IO2_TMP])
#define BANK_BAD_MEM (&g_dummy_memory1_ptr[0xff])
#define ENGINE_FCYCLES 0x00
#define ENGINE_REG_KPC 0x08
#define ENGINE_REG_ACC 0x0c
#define ENGINE_REG_XREG 0x10
#define ENGINE_REG_YREG 0x14
#define ENGINE_REG_STACK 0x18
#define ENGINE_REG_DBANK 0x1c
#define ENGINE_REG_DIRECT 0x20
#define ENGINE_REG_PSR 0x24
#define ENGINE_FPLUS_PTR 0x28
#define LOG_PC_DCYCS 0x00
#define LOG_PC_DBANK_KPC 0x08
#define LOG_PC_INSTR 0x0c
#define LOG_PC_PSR_ACC 0x10
#define LOG_PC_XREG_YREG 0x14
#define LOG_PC_STACK_DIRECT 0x18
#define LOG_PC_PAD 0x1c
#define LOG_PC_SIZE 0x20
#define FPLUS_PLUS_1 0x00
#define FPLUS_PLUS_2 0x08
#define FPLUS_PLUS_3 0x10
#define FPLUS_PLUS_X_M1 0x18
#define RET_BREAK 0x1
#define RET_COP 0x2
#define RET_WDM 0x3
#define RET_MVP 0x4
#define RET_MVN 0x5
#define RET_WAI 0x6
#define RET_STP 0x7
#define RET_ADD_DEC_8 0x8
#define RET_ADD_DEC_16 0x9
#define RET_C700 0xa
#define RET_C70A 0xb
#define RET_C70D 0xc
#define RET_IRQ 0xd
#define MODE_BORDER 0
#define MODE_TEXT 1
#define MODE_GR 2
#define MODE_HGR 3
#define MODE_SUPER_HIRES 4
#define BIT_ALL_STAT_TEXT 0
#define BIT_ALL_STAT_VID80 1
#define BIT_ALL_STAT_ST80 2
#define BIT_ALL_STAT_COLOR_C021 3
#define BIT_ALL_STAT_MIX_T_GR 4
#define BIT_ALL_STAT_DIS_COLOR_DHIRES 5 /* special val, c029 */
#define BIT_ALL_STAT_PAGE2 6 /* special val, statereg */
#define BIT_ALL_STAT_SUPER_HIRES 7 /* special, c029 */
#define BIT_ALL_STAT_HIRES 8
#define BIT_ALL_STAT_ANNUNC3 9
#define BIT_ALL_STAT_BG_COLOR 10 /* 4 bits */
#define BIT_ALL_STAT_TEXT_COLOR 14 /* 4 bits */
/* Text must be just above */
/* bg to match c022 reg */
#define BIT_ALL_STAT_ALTCHARSET 18
#define BIT_ALL_STAT_FLASH_STATE 19
#define BIT_ALL_STAT_A2VID_PALETTE 20 /* 4 bits */
#define ALL_STAT_SUPER_HIRES (1 << (BIT_ALL_STAT_SUPER_HIRES))
#define ALL_STAT_TEXT (1 << (BIT_ALL_STAT_TEXT))
#define ALL_STAT_VID80 (1 << (BIT_ALL_STAT_VID80))
#define ALL_STAT_PAGE2 (1 << (BIT_ALL_STAT_PAGE2))
#define ALL_STAT_ST80 (1 << (BIT_ALL_STAT_ST80))
#define ALL_STAT_COLOR_C021 (1 << (BIT_ALL_STAT_COLOR_C021))
#define ALL_STAT_DIS_COLOR_DHIRES (1 << (BIT_ALL_STAT_DIS_COLOR_DHIRES))
#define ALL_STAT_MIX_T_GR (1 << (BIT_ALL_STAT_MIX_T_GR))
#define ALL_STAT_HIRES (1 << (BIT_ALL_STAT_HIRES))
#define ALL_STAT_ANNUNC3 (1 << (BIT_ALL_STAT_ANNUNC3))
#define ALL_STAT_TEXT_COLOR (0xf << (BIT_ALL_STAT_TEXT_COLOR))
#define ALL_STAT_BG_COLOR (0xf << (BIT_ALL_STAT_BG_COLOR))
#define ALL_STAT_ALTCHARSET (1 << (BIT_ALL_STAT_ALTCHARSET))
#define ALL_STAT_FLASH_STATE (1 << (BIT_ALL_STAT_FLASH_STATE))
#define ALL_STAT_A2VID_PALETTE (0xf << (BIT_ALL_STAT_A2VID_PALETTE))
#define BORDER_WIDTH 32
#define EFF_BORDER_WIDTH (BORDER_WIDTH + (640-560))
/* BASE_MARGIN_BOTTOM+MARGIN_TOP must equal 62. There are 262 scan lines */
/* at 60Hz (15.7KHz line rate) and so we just make 62 border lines */
#define BASE_MARGIN_TOP 32
#define BASE_MARGIN_BOTTOM 30
#define BASE_MARGIN_LEFT BORDER_WIDTH
#define BASE_MARGIN_RIGHT BORDER_WIDTH
#define A2_WINDOW_WIDTH 640
#define A2_WINDOW_HEIGHT 400
#define X_A2_WINDOW_WIDTH (A2_WINDOW_WIDTH + BASE_MARGIN_LEFT + \
BASE_MARGIN_RIGHT)
#define X_A2_WINDOW_HEIGHT (A2_WINDOW_HEIGHT + BASE_MARGIN_TOP + \
BASE_MARGIN_BOTTOM)
#define MAX_STATUS_LINES 7
#define STATUS_LINE_LENGTH 88
#define BASE_WINDOW_WIDTH (X_A2_WINDOW_WIDTH)
#define A2_BORDER_COLOR_NUM 0xfe
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
#ifdef INCLUDE_RCSID_C
const char rcsdif_defcomm_h[] = "@(#)$KmKId: defcomm.h,v 1.94 2004-10-13 21:53:44-04 kentd Exp $";
#endif
#if 0
# define CHECK_BREAKPOINTS
#endif
#define SHIFT_PER_CHANGE 3
#define CHANGE_SHIFT (5 + SHIFT_PER_CHANGE)
#define SLOW_MEM_CH_SIZE (0x10000 >> CHANGE_SHIFT)
#define MAXNUM_HEX_PER_LINE 32
/* Different Joystick defines */
#define JOYSTICK_MOUSE 1
#define JOYSTICK_LINUX 2
#define JOYSTICK_KEYPAD 3
#define JOYSTICK_WIN32_1 4
#define JOYSTICK_WIN32_2 5
#define HALT_EVENT 0x10
#define HALT_WANTTOQUIT 0x20 // OG : added WANTTOQUIT event
#define HALT_WANTTOBRK 0x40 // OG : added WANTTOBRK event
#define MAX_BREAK_POINTS 0x20
#define MAX_BP_INDEX 0x100
#define MAX_BP_PER_INDEX 3 /* 4 word32s total = 16 bytes */
#define SIZE_BREAKPT_ENTRY_BITS 4 /* 16 bytes = 4 bits */
/* Warning--next defines used by asm! */
#define PAGE_INFO_PAD_SIZE 0x800
#define PAGE_INFO_WR_OFFSET 0x10000+PAGE_INFO_PAD_SIZE
#define BANK_IO_BIT 31
#define BANK_SHADOW_BIT 30
#define BANK_SHADOW2_BIT 29
#define BANK_IO2_BIT 28
#define BANK_BREAK_BIT 27
#define BANK_BREAK (1 << (31 - BANK_BREAK_BIT))
#define BANK_IO2_TMP (1 << (31 - BANK_IO2_BIT))
#define BANK_IO_TMP (1 << (31 - BANK_IO_BIT))
#define BANK_SHADOW (1 << (31 - BANK_SHADOW_BIT))
#define BANK_SHADOW2 (1 << (31 - BANK_SHADOW2_BIT))
#define SET_BANK_IO \
(&g_dummy_memory1_ptr[BANK_IO_TMP | BANK_IO2_TMP])
#define BANK_BAD_MEM (&g_dummy_memory1_ptr[0xff])
#define ENGINE_FCYCLES 0x00
#define ENGINE_REG_KPC 0x08
#define ENGINE_REG_ACC 0x0c
#define ENGINE_REG_XREG 0x10
#define ENGINE_REG_YREG 0x14
#define ENGINE_REG_STACK 0x18
#define ENGINE_REG_DBANK 0x1c
#define ENGINE_REG_DIRECT 0x20
#define ENGINE_REG_PSR 0x24
#define ENGINE_FPLUS_PTR 0x28
#define LOG_PC_DCYCS 0x00
#define LOG_PC_DBANK_KPC 0x08
#define LOG_PC_INSTR 0x0c
#define LOG_PC_PSR_ACC 0x10
#define LOG_PC_XREG_YREG 0x14
#define LOG_PC_STACK_DIRECT 0x18
#define LOG_PC_PAD 0x1c
#define LOG_PC_SIZE 0x20
#define FPLUS_PLUS_1 0x00
#define FPLUS_PLUS_2 0x08
#define FPLUS_PLUS_3 0x10
#define FPLUS_PLUS_X_M1 0x18
#define RET_BREAK 0x1
#define RET_COP 0x2
#define RET_WDM 0x3
#define RET_MVP 0x4
#define RET_MVN 0x5
#define RET_WAI 0x6
#define RET_STP 0x7
#define RET_ADD_DEC_8 0x8
#define RET_ADD_DEC_16 0x9
#define RET_C700 0xa
#define RET_C70A 0xb
#define RET_C70D 0xc
#define RET_IRQ 0xd
#define MODE_BORDER 0
#define MODE_TEXT 1
#define MODE_GR 2
#define MODE_HGR 3
#define MODE_SUPER_HIRES 4
#define BIT_ALL_STAT_TEXT 0
#define BIT_ALL_STAT_VID80 1
#define BIT_ALL_STAT_ST80 2
#define BIT_ALL_STAT_COLOR_C021 3
#define BIT_ALL_STAT_MIX_T_GR 4
#define BIT_ALL_STAT_DIS_COLOR_DHIRES 5 /* special val, c029 */
#define BIT_ALL_STAT_PAGE2 6 /* special val, statereg */
#define BIT_ALL_STAT_SUPER_HIRES 7 /* special, c029 */
#define BIT_ALL_STAT_HIRES 8
#define BIT_ALL_STAT_ANNUNC3 9
#define BIT_ALL_STAT_BG_COLOR 10 /* 4 bits */
#define BIT_ALL_STAT_TEXT_COLOR 14 /* 4 bits */
/* Text must be just above */
/* bg to match c022 reg */
#define BIT_ALL_STAT_ALTCHARSET 18
#define BIT_ALL_STAT_FLASH_STATE 19
#define BIT_ALL_STAT_A2VID_PALETTE 20 /* 4 bits */
#define ALL_STAT_SUPER_HIRES (1 << (BIT_ALL_STAT_SUPER_HIRES))
#define ALL_STAT_TEXT (1 << (BIT_ALL_STAT_TEXT))
#define ALL_STAT_VID80 (1 << (BIT_ALL_STAT_VID80))
#define ALL_STAT_PAGE2 (1 << (BIT_ALL_STAT_PAGE2))
#define ALL_STAT_ST80 (1 << (BIT_ALL_STAT_ST80))
#define ALL_STAT_COLOR_C021 (1 << (BIT_ALL_STAT_COLOR_C021))
#define ALL_STAT_DIS_COLOR_DHIRES (1 << (BIT_ALL_STAT_DIS_COLOR_DHIRES))
#define ALL_STAT_MIX_T_GR (1 << (BIT_ALL_STAT_MIX_T_GR))
#define ALL_STAT_HIRES (1 << (BIT_ALL_STAT_HIRES))
#define ALL_STAT_ANNUNC3 (1 << (BIT_ALL_STAT_ANNUNC3))
#define ALL_STAT_TEXT_COLOR (0xf << (BIT_ALL_STAT_TEXT_COLOR))
#define ALL_STAT_BG_COLOR (0xf << (BIT_ALL_STAT_BG_COLOR))
#define ALL_STAT_ALTCHARSET (1 << (BIT_ALL_STAT_ALTCHARSET))
#define ALL_STAT_FLASH_STATE (1 << (BIT_ALL_STAT_FLASH_STATE))
#define ALL_STAT_A2VID_PALETTE (0xf << (BIT_ALL_STAT_A2VID_PALETTE))
#define BORDER_WIDTH 32
//#define EFF_BORDER_WIDTH (BORDER_WIDTH + (640-560))
// OG Eff_border_widht == border side in A2 mode
#define EFF_BORDER_WIDTH (BORDER_WIDTH + (640-560)/2)
/* BASE_MARGIN_BOTTOM+MARGIN_TOP must equal 62. There are 262 scan lines */
/* at 60Hz (15.7KHz line rate) and so we just make 62 border lines */
#define BASE_MARGIN_TOP 32
#define BASE_MARGIN_BOTTOM 30
#define BASE_MARGIN_LEFT BORDER_WIDTH
#define BASE_MARGIN_RIGHT BORDER_WIDTH
#define A2_WINDOW_WIDTH 640
#define A2_WINDOW_HEIGHT 400
#define X_A2_WINDOW_WIDTH (A2_WINDOW_WIDTH + BASE_MARGIN_LEFT + \
BASE_MARGIN_RIGHT)
#define X_A2_WINDOW_HEIGHT (A2_WINDOW_HEIGHT + BASE_MARGIN_TOP + \
BASE_MARGIN_BOTTOM)
#define MAX_STATUS_LINES 7
#define STATUS_LINE_LENGTH 88
#define BASE_WINDOW_WIDTH (X_A2_WINDOW_WIDTH)
#define A2_BORDER_COLOR_NUM 0xfe

230
jni/dirent-win32.h Normal file
View File

@ -0,0 +1,230 @@
/*****************************************************************************
* dirent.h - dirent API for Microsoft Visual Studio
*
* Copyright (C) 2006 Toni Ronkko
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* ``Software''), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Dec 15, 2009, John Cunningham
* Added rewinddir member function
*
* Jan 18, 2008, Toni Ronkko
* Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
* between multi-byte and unicode representations. This makes the
* code simpler and also allows the code to be compiled under MingW. Thanks
* to Azriel Fasten for the suggestion.
*
* Mar 4, 2007, Toni Ronkko
* Bug fix: due to the strncpy_s() function this file only compiled in
* Visual Studio 2005. Using the new string functions only when the
* compiler version allows.
*
* Nov 2, 2006, Toni Ronkko
* Major update: removed support for Watcom C, MS-DOS and Turbo C to
* simplify the file, updated the code to compile cleanly on Visual
* Studio 2005 with both unicode and multi-byte character strings,
* removed rewinddir() as it had a bug.
*
* Aug 20, 2006, Toni Ronkko
* Removed all remarks about MSVC 1.0, which is antiqued now. Simplified
* comments by removing SGML tags.
*
* May 14 2002, Toni Ronkko
* Embedded the function definitions directly to the header so that no
* source modules need to be included in the Visual Studio project. Removed
* all the dependencies to other projects so that this very header can be
* used independently.
*
* May 28 1998, Toni Ronkko
* First version.
*****************************************************************************/
#ifndef DIRENT_H
#define DIRENT_H
#include <windows.h>
#include <string.h>
#include <assert.h>
typedef struct dirent
{
char d_name[MAX_PATH + 1]; /* current dir entry (multi-byte char string) */
WIN32_FIND_DATAA data; /* file attributes */
} dirent;
typedef struct DIR
{
dirent current; /* Current directory entry */
int cached; /* Indicates un-processed entry in memory */
HANDLE search_handle; /* File search handle */
char patt[MAX_PATH + 3]; /* search pattern (3 = pattern + "\\*\0") */
} DIR;
/* Forward declarations */
static DIR *opendir (const char *dirname);
static struct dirent *readdir (DIR *dirp);
static int closedir (DIR *dirp);
static void rewinddir(DIR* dirp);
/* Use the new safe string functions introduced in Visual Studio 2005 */
#if defined(_MSC_VER) && _MSC_VER >= 1400
# define STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
#else
# define STRNCPY(dest,src,size) strncpy((dest),(src),(size))
#endif
/*****************************************************************************
* Open directory stream DIRNAME for read and return a pointer to the
* internal working area that is used to retrieve individual directory
* entries.
*/
static DIR *opendir(const char *dirname)
{
DIR *dirp;
assert (dirname != NULL);
assert (strlen (dirname) < MAX_PATH);
/* construct new DIR structure */
dirp = (DIR*) malloc (sizeof (struct DIR));
if (dirp != NULL) {
char *p;
/* take directory name... */
STRNCPY (dirp->patt, dirname, sizeof(dirp->patt));
dirp->patt[MAX_PATH] = '\0';
/* ... and append search pattern to it */
p = strchr (dirp->patt, '\0');
if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') {
*p++ = '\\';
}
*p++ = '*';
*p = '\0';
/* open stream and retrieve first file */
dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data);
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
/* invalid search pattern? */
free (dirp);
return NULL;
}
/* there is an un-processed directory entry in memory now */
dirp->cached = 1;
}
return dirp;
}
/*****************************************************************************
* Read a directory entry, and return a pointer to a dirent structure
* containing the name of the entry in d_name field. Individual directory
* entries returned by this very function include regular files,
* sub-directories, pseudo-directories "." and "..", but also volume labels,
* hidden files and system files may be returned.
*/
static struct dirent *readdir(DIR *dirp)
{
assert (dirp != NULL);
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
/* directory stream was opened/rewound incorrectly or ended normally */
return NULL;
}
/* get next directory entry */
if (dirp->cached != 0) {
/* a valid directory entry already in memory */
dirp->cached = 0;
} else {
/* read next directory entry from disk */
if (FindNextFileA (dirp->search_handle, &dirp->current.data) == FALSE) {
/* the very last file has been processed or an error occured */
FindClose (dirp->search_handle);
dirp->search_handle = INVALID_HANDLE_VALUE;
return NULL;
}
}
/* copy as a multibyte character string */
STRNCPY ( dirp->current.d_name,
dirp->current.data.cFileName,
sizeof(dirp->current.d_name) );
dirp->current.d_name[MAX_PATH] = '\0';
return &dirp->current;
}
/*****************************************************************************
* Close directory stream opened by opendir() function. Close of the
* directory stream invalidates the DIR structure as well as any previously
* read directory entry.
*/
static int closedir(DIR *dirp)
{
assert (dirp != NULL);
/* release search handle */
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
FindClose (dirp->search_handle);
dirp->search_handle = INVALID_HANDLE_VALUE;
}
/* release directory handle */
free (dirp);
return 0;
}
/*****************************************************************************
* Resets the position of the directory stream to which dirp refers to the
* beginning of the directory. It also causes the directory stream to refer
* to the current state of the corresponding directory, as a call to opendir()
* would have done. If dirp does not refer to a directory stream, the effect
* is undefined.
*/
static void rewinddir(DIR* dirp)
{
/* release search handle */
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
FindClose (dirp->search_handle);
dirp->search_handle = INVALID_HANDLE_VALUE;
}
/* open new search handle and retrieve first file */
dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data);
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
/* invalid search pattern? */
free (dirp);
return;
}
/* there is an un-processed directory entry in memory now */
dirp->cached = 1;
}
#endif /*DIRENT_H*/

2388
jni/dis.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

19
jni/info.nib generated
View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>152 85 356 240 0 0 1280 832 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>69 252 182 44 0 0 1280 832 </string>
</dict>
<key>IBFramework Version</key>
<string>291.0</string>
<key>IBSystem Version</key>
<string>6R73</string>
<key>targetFramework</key>
<string>IBCarbonFramework</string>
</dict>
</plist>

4726
jni/iwm.c

File diff suppressed because it is too large Load Diff

View File

@ -312,7 +312,7 @@ IWM_WRITE_ROUT (Disk *dsk, word32 val, int fast_disk_emul, double dcycs)
bits_read, val, prev_val, prev_bits);
}
sdiff = dcycs - dcycs_last_read;
sdiff = (int)( dcycs - dcycs_last_read );
if(sdiff < (dcycs_this_nib) || (sdiff > (2*dcycs_this_nib)) ) {
dsk->dcycs_last_read = dcycs;
} else {

52
jni/joystick_dummy.c Normal file
View File

@ -0,0 +1,52 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
const char rcsid_joystick_driver_c[] = "@(#)$KmKId: joystick_driver.c,v 1.12 2004-10-17 21:28:48-04 kentd Exp $";
#include "defc.h"
#ifndef _MSC_VER // OG Unknown MSFT header
#include <sys/time.h>
#endif
extern int g_joystick_native_type1; /* in paddles.c */
extern int g_joystick_native_type2; /* in paddles.c */
extern int g_joystick_native_type; /* in paddles.c */
extern int g_paddle_buttons;
extern int g_paddle_val[];
void
joystick_init()
{
g_joystick_native_type1 = -1;
g_joystick_native_type2 = -1;
g_joystick_native_type = -1;
}
void
joystick_update(double dcycs)
{
int i;
for(i = 0; i < 4; i++) {
g_paddle_val[i] = 32767;
}
g_paddle_buttons = 0xc;
}
void
joystick_update_buttons()
{
}
// OG
void joystick_shut()
{
}

125
jni/joystick_linux.c Normal file
View File

@ -0,0 +1,125 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
const char rcsid_joystick_driver_c[] = "@(#)$KmKId: joystick_driver.c,v 1.12 2004-10-17 21:28:48-04 kentd Exp $";
#include "defc.h"
#include <sys/time.h>
# include <linux/joystick.h>
extern int g_joystick_native_type1; /* in paddles.c */
extern int g_joystick_native_type2; /* in paddles.c */
extern int g_joystick_native_type; /* in paddles.c */
extern int g_paddle_buttons;
extern int g_paddle_val[];
const char *g_joystick_dev = "/dev/js0"; /* default joystick dev file */
#define MAX_JOY_NAME 128
int g_joystick_native_fd = -1;
int g_joystick_num_axes = 0;
int g_joystick_num_buttons = 0;
void
joystick_init()
{
char joy_name[MAX_JOY_NAME];
int version;
int fd;
int i;
fd = open(g_joystick_dev, O_RDONLY | O_NONBLOCK);
if(fd < 0) {
printf("Unable to open joystick dev file: %s, errno: %d\n",
g_joystick_dev, errno);
printf("Defaulting to mouse joystick\n");
return;
}
strcpy(&joy_name[0], "Unknown Joystick");
version = 0x800;
ioctl(fd, JSIOCGNAME(MAX_JOY_NAME), &joy_name[0]);
ioctl(fd, JSIOCGAXES, &g_joystick_num_axes);
ioctl(fd, JSIOCGBUTTONS, &g_joystick_num_buttons);
ioctl(fd, JSIOCGVERSION, &version);
printf("Detected joystick: %s [%d axes, %d buttons vers: %08x]\n",
joy_name, g_joystick_num_axes, g_joystick_num_buttons,
version);
g_joystick_native_type1 = 1;
g_joystick_native_type2 = -1;
g_joystick_native_fd = fd;
for(i = 0; i < 4; i++) {
g_paddle_val[i] = 32767;
}
g_paddle_buttons = 0xc;
joystick_update(0.0);
}
/* joystick_update_linux() called from paddles.c. Update g_paddle_val[] */
/* and g_paddle_buttons with current information */
void
joystick_update(double dcycs)
{
struct js_event js; /* the linux joystick event record */
int mask;
int val;
int num;
int type;
int ret;
int len;
int i;
/* suck up to 20 events, then give up */
len = sizeof(struct js_event);
for(i = 0; i < 20; i++) {
ret = read(g_joystick_native_fd, &js, len);
if(ret != len) {
/* just get out */
break;
}
type = js.type & ~JS_EVENT_INIT;
val = js.value;
num = js.number & 3; /* clamp to 0-3 */
switch(type) {
case JS_EVENT_BUTTON:
mask = 1 << num;
if(val) {
val = mask;
}
g_paddle_buttons = (g_paddle_buttons & ~mask) | val;
break;
case JS_EVENT_AXIS:
/* val is -32767 to +32767 */
g_paddle_val[num] = val;
break;
}
}
if(i > 0) {
paddle_update_trigger_dcycs(dcycs);
}
}
void
joystick_update_buttons()
{
}
// OG
void joystick_shut()
{
}

View File

@ -11,18 +11,9 @@
const char rcsid_joystick_driver_c[] = "@(#)$KmKId: joystick_driver.c,v 1.12 2004-10-17 21:28:48-04 kentd Exp $";
#include "defc.h"
#include <sys/time.h>
#ifndef __ANDROID__
#ifdef __linux__
# include <linux/joystick.h>
#endif
#endif
#ifdef _WIN32
# include <windows.h>
# include <mmsystem.h>
#endif
extern int g_joystick_native_type1; /* in paddles.c */
extern int g_joystick_native_type2; /* in paddles.c */
@ -30,113 +21,16 @@ extern int g_joystick_native_type; /* in paddles.c */
extern int g_paddle_buttons;
extern int g_paddle_val[];
const char *g_joystick_dev = "/dev/js0"; /* default joystick dev file */
/*
const char *g_joystick_dev = "/dev/js0"; // default joystick dev file
#define MAX_JOY_NAME 128
int g_joystick_native_fd = -1;
int g_joystick_num_axes = 0;
int g_joystick_num_buttons = 0;
*/
#ifndef __ANDROID__
#ifdef __linux__
# define JOYSTICK_DEFINED
void
joystick_init()
{
char joy_name[MAX_JOY_NAME];
int version;
int fd;
int i;
fd = open(g_joystick_dev, O_RDONLY | O_NONBLOCK);
if(fd < 0) {
printf("Unable to open joystick dev file: %s, errno: %d\n",
g_joystick_dev, errno);
printf("Defaulting to mouse joystick\n");
return;
}
strcpy(&joy_name[0], "Unknown Joystick");
version = 0x800;
ioctl(fd, JSIOCGNAME(MAX_JOY_NAME), &joy_name[0]);
ioctl(fd, JSIOCGAXES, &g_joystick_num_axes);
ioctl(fd, JSIOCGBUTTONS, &g_joystick_num_buttons);
ioctl(fd, JSIOCGVERSION, &version);
printf("Detected joystick: %s [%d axes, %d buttons vers: %08x]\n",
joy_name, g_joystick_num_axes, g_joystick_num_buttons,
version);
g_joystick_native_type1 = 1;
g_joystick_native_type2 = -1;
g_joystick_native_fd = fd;
for(i = 0; i < 4; i++) {
g_paddle_val[i] = 32767;
}
g_paddle_buttons = 0xc;
joystick_update(0.0);
}
/* joystick_update_linux() called from paddles.c. Update g_paddle_val[] */
/* and g_paddle_buttons with current information */
void
joystick_update(double dcycs)
{
struct js_event js; /* the linux joystick event record */
int mask;
int val;
int num;
int type;
int ret;
int len;
int i;
/* suck up to 20 events, then give up */
len = sizeof(struct js_event);
for(i = 0; i < 20; i++) {
ret = read(g_joystick_native_fd, &js, len);
if(ret != len) {
/* just get out */
break;
}
type = js.type & ~JS_EVENT_INIT;
val = js.value;
num = js.number & 3; /* clamp to 0-3 */
switch(type) {
case JS_EVENT_BUTTON:
mask = 1 << num;
if(val) {
val = mask;
}
g_paddle_buttons = (g_paddle_buttons & ~mask) | val;
break;
case JS_EVENT_AXIS:
/* val is -32767 to +32767 */
g_paddle_val[num] = val;
break;
}
}
if(i > 0) {
paddle_update_trigger_dcycs(dcycs);
}
}
void
joystick_update_buttons()
{
}
#endif /* LINUX */
#endif
#ifdef _WIN32
# define JOYSTICK_DEFINED
void
joystick_init()
void joystick_init()
{
JOYINFO info;
JOYCAPS joycap;
@ -234,31 +128,8 @@ joystick_update_buttons()
}
}
}
#endif
#ifndef JOYSTICK_DEFINED
/* stubs for the routines */
void
joystick_init()
{
g_joystick_native_type1 = -1;
g_joystick_native_type2 = -1;
g_joystick_native_type = -1;
}
void
joystick_update(double dcycs)
{
int i;
for(i = 0; i < 4; i++) {
g_paddle_val[i] = 32767;
}
g_paddle_buttons = 0xc;
}
void
joystick_update_buttons()
// OG
void joystick_shut()
{
}
#endif

Binary file not shown.

File diff suppressed because it is too large Load Diff

501
jni/macdriver_generic.c Normal file
View File

@ -0,0 +1,501 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002-2004 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
const char rcsid_macdriver_c[] = "@(#)$KmKId: macdriver.c,v 1.24 2004-11-14 10:23:29-05 kentd Exp $";
#ifdef ACTIVEIPHONE
#include <CoreGraphics/CGContext.h>
#include <CoreGraphics/CGBitmapContext.h>
#include <CoreFoundation/CFURL.h>
#else
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <Carbon/Carbon.h>
#define ENABLEQD
#endif
#include "defc.h"
#include "protos_macdriver.h"
word32 g_mac_shift_control_state = 0;
int macUsingCoreGraphics=0;
// Coregraphics context
CGContextRef offscreenContext = NULL;
char * bitmapData=NULL;
int bitmapByteCount;
int bitmapBytesPerRow;
#ifdef ENABLEQD
WindowRef g_main_window;
CGrafPtr mac_window_port;
#endif
extern Kimage g_mainwin_kimage;
int g_use_shmem = 0;
extern int Verbose;
extern int g_video_act_width;
extern int g_video_act_height;
extern int g_video_act_margin_left;
extern int g_video_act_margin_right;
extern int g_video_act_margin_top;
extern int g_video_act_margin_bottom;
extern int g_screen_depth;
extern int g_force_depth;
int g_screen_mdepth = 0;
extern int g_send_sound_to_file;
//extern int g_quit_sim_now; // OG Not need anymore
extern int g_config_control_panel;
int g_auto_repeat_on = -1;
int g_x_shift_control_state = 0;
extern int Max_color_size;
extern word32 g_palette_8to1624[256];
extern word32 g_a2palette_8to1624[256];
int g_alt_left_up = 1;
int g_alt_right_up = 1;
extern word32 g_full_refresh_needed;
extern int g_border_sides_refresh_needed;
extern int g_border_special_refresh_needed;
extern int g_status_refresh_needed;
extern int g_lores_colors[];
extern int g_a2vid_palette;
extern int g_installed_full_superhires_colormap;
extern int g_screen_redraw_skip_amt;
extern word32 g_a2_screen_buffer_changed;
int g_upd_count = 0;
void
update_window(void)
{
// OG Not needed
/*
SetPortWindowPort(g_main_window);
PenNormal();
*/
g_full_refresh_needed = -1;
g_a2_screen_buffer_changed = -1;
g_status_refresh_needed = 1;
g_border_sides_refresh_needed = 1;
g_border_special_refresh_needed = 1;
g_upd_count++;
if(g_upd_count > 250) {
g_upd_count = 0;
}
}
void
mac_update_modifiers(word32 state)
{
#ifndef ACTIVEIPHONE
word32 state_xor;
int is_up;
state = state & (
cmdKey | controlKey |
shiftKey | alphaLock | optionKey
);
state_xor = g_mac_shift_control_state ^ state;
is_up = 0;
if(state_xor & controlKey) {
is_up = ((state & controlKey) == 0);
adb_physical_key_update(0x36, is_up);
}
if(state_xor & alphaLock) {
is_up = ((state & alphaLock) == 0);
adb_physical_key_update(0x39, is_up);
}
if(state_xor & shiftKey) {
is_up = ((state & shiftKey) == 0);
adb_physical_key_update(0x38, is_up);
}
if(state_xor & cmdKey) {
is_up = ((state & cmdKey) == 0);
adb_physical_key_update(0x37, is_up);
}
if(state_xor & optionKey) {
is_up = ((state & optionKey) == 0);
adb_physical_key_update(0x3a, is_up);
}
#endif
g_mac_shift_control_state = state;
}
void
x_update_color(int col_num, int red, int green, int blue, word32 rgb)
{
}
void
x_update_physical_colormap()
{
}
void
show_xcolor_array()
{
int i;
for(i = 0; i < 256; i++) {
printf("%02x: %08x\n", i, g_palette_8to1624[i]);
}
}
void
x_get_kimage(Kimage *kimage_ptr)
{
#ifdef ENABLEQD
PixMapHandle pixmap_handle;
GWorldPtr world;
Rect world_rect;
OSStatus err;
#endif
word32 *wptr;
byte *ptr;
int row_bytes;
int width;
int height;
int depth, mdepth;
int size;
width = kimage_ptr->width_req;
height = kimage_ptr->height;
depth = kimage_ptr->depth;
mdepth = kimage_ptr->mdepth;
size = 0;
if(depth == g_screen_depth)
{
if (!macUsingCoreGraphics)
{
#ifdef ENABLEQD
SetRect(&world_rect, 0, 0, width, height);
err = NewGWorld( &world, 0, &world_rect, NULL, NULL, 0);
pixmap_handle = GetGWorldPixMap(world);
err = LockPixels(pixmap_handle);
ptr = (byte *)GetPixBaseAddr(pixmap_handle);
row_bytes = ((*pixmap_handle)->rowBytes & 0x3fff);
kimage_ptr->width_act = row_bytes / (mdepth >> 3);
mac_printf("Got depth: %d, bitmap_ptr: %p, width: %d\n", depth, ptr, kimage_ptr->width_act);
mac_printf("pixmap->base: %08x, rowbytes: %08x, pixType:%08x\n",(int)(*pixmap_handle)->baseAddr,(*pixmap_handle)->rowBytes,(*pixmap_handle)->pixelType);
wptr = (word32 *)(*pixmap_handle);
mac_printf("wptr: %p=%08x %08x %08x %08x %08x %08x %08x %08x\n",wptr,wptr[0], wptr[1], wptr[2], wptr[3],wptr[4], wptr[5], wptr[6], wptr[7]);
kimage_ptr->dev_handle = pixmap_handle;
kimage_ptr->data_ptr = ptr;
#endif
}
else
{
kimage_ptr->width_act = width ;
size = height* kimage_ptr->width_act * mdepth >> 3;
ptr = (byte *)malloc(size);
if(ptr == 0) {
mac_printf("malloc for data fail, mdepth:%d\n", mdepth);
exit(2);
}
kimage_ptr->data_ptr = ptr;
kimage_ptr->dev_handle = (void *)-1;
}
}
else {
/* allocate buffers for video.c to draw into */
kimage_ptr->width_act = width ;
size = height* kimage_ptr->width_act * mdepth >> 3 ;
ptr = (byte *)malloc(size);
if(ptr == 0) {
mac_printf("malloc for data fail, mdepth:%d\n", mdepth);
exit(2);
}
kimage_ptr->data_ptr = ptr;
kimage_ptr->dev_handle = (void *)-1;
}
mac_printf("kim: %p, dev:%p data: %p, size: %08x\n", kimage_ptr,
kimage_ptr->dev_handle, kimage_ptr->data_ptr, size);
}
#ifdef ENABLEQD
PixMapHandle pixmap_backbuffer=NULL;
GWorldPtr backbuffer=NULL;
#endif
void
dev_video_init()
{
int lores_col;
int i;
printf("Preparing graphics system\n");
// OG Create backbuffer
if (!macUsingCoreGraphics)
{
#ifdef ENABLEQD
Rect r;
SetRect(&r, 0, 0, 704, 462);
QDErr err = NewGWorld( &backbuffer, 0, &r, NULL, NULL, 0);
pixmap_backbuffer = GetGWorldPixMap(backbuffer);
#endif
}
else
{
CGColorSpaceRef colorSpace;
int pixelsWide = 704;
int pixelsHigh = 462;
bitmapBytesPerRow = (pixelsWide * 4);// 1
bitmapByteCount = (bitmapBytesPerRow * pixelsHigh);
colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);// 2
bitmapData = (char*)malloc( bitmapByteCount );// 3
if (bitmapData == NULL)
{
fprintf (stderr, "Memory not allocated!");
return ;
}
offscreenContext = CGBitmapContextCreate (bitmapData,// 4
pixelsWide,
pixelsHigh,
8, // bits per component
bitmapBytesPerRow,
colorSpace,
kCGImageAlphaNoneSkipLast);
if (offscreenContext== NULL)
{
free (bitmapData);// 5
fprintf (stderr, "Context not created!");
return ;
}
CGContextSetRGBFillColor (offscreenContext, 1, 0.5, 0.5, 1);
CGContextFillRect (offscreenContext, CGRectMake (0,0, 704, 462 ));
CGColorSpaceRelease( colorSpace );// 6
}
video_get_kimages();
if(g_screen_depth != 8) {
// Get g_mainwin_kimage
video_get_kimage(&g_mainwin_kimage, 0, g_screen_depth,
g_screen_mdepth);
}
for(i = 0; i < 256; i++) {
lores_col = g_lores_colors[i & 0xf];
video_update_color_raw(i, lores_col);
g_a2palette_8to1624[i] = g_palette_8to1624[i];
}
g_installed_full_superhires_colormap = 1;
fflush(stdout);
}
void
x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
int width, int height)
{
if (!macUsingCoreGraphics)
{
#ifdef ENABLEQD
PixMapHandle pixmap_handle;
Rect src_rect, dest_rect;
CGrafPtr window_port;
pixmap_handle = (PixMapHandle)kimage_ptr->dev_handle;
SetRect(&src_rect, srcx, srcy, srcx + width, srcy + height);
SetRect(&dest_rect, destx, desty, destx + width, desty + height);
#ifndef ACTIVEGSPLUGIN
SetPortWindowPort(g_main_window);
window_port = GetWindowPort(g_main_window);
CopyBits( (BitMap *)(*pixmap_handle),
GetPortBitMapForCopyBits(window_port), &src_rect, &dest_rect,
srcCopy, NULL);
#else // !ACTIVEGSPLUGIN
// OG Write to the back buffer instead of the display window
window_port = mac_window_port ;
SetGWorld(backbuffer,NULL);
CopyBits( (BitMap *)(*pixmap_handle),
GetPortBitMapForCopyBits(backbuffer), &src_rect, &dest_rect,
srcCopy, NULL);
#endif // ACTIVEGSPLUGIN
#endif
}
else
{
int wd = kimage_ptr->width_act * kimage_ptr->mdepth>>3;
int w = width *4;
char* ptrdest = bitmapData + bitmapBytesPerRow*desty + destx*4;
char* srcdest = (char*)kimage_ptr->data_ptr + wd*srcy + srcx*4;
for(int i=0;i<height;i+=1)
{
memcpy(ptrdest,srcdest,w);
ptrdest += bitmapBytesPerRow;
srcdest += wd;
}
}
}
void
x_auto_repeat_on(int must)
{
}
void
x_auto_repeat_off(int must)
{
}
void
x_hide_pointer(int do_hide)
{
#ifdef ENABLEQD
if(do_hide) {
HideCursor();
} else {
ShowCursor();
}
#endif
}
void
update_main_window_size()
{
#ifdef ENABLEQD
Rect win_rect;
int width, height;
int left, excess_height;
int top, bottom;
GetPortBounds(GetWindowPort(g_main_window), &win_rect);
width = win_rect.right - win_rect.left;
height = win_rect.bottom - win_rect.top;
g_video_act_width = width;
g_video_act_height = height;
left = MAX(0, (width - A2_WINDOW_WIDTH) / 2);
left = MIN(left, BASE_MARGIN_LEFT);
g_video_act_margin_left = left;
g_video_act_margin_right = left;
excess_height = (height - A2_WINDOW_HEIGHT) / 2;
bottom = MAX(0, excess_height / 2); // No less than 0
bottom = MIN(BASE_MARGIN_BOTTOM, bottom); // No more than 30
g_video_act_margin_bottom = bottom;
excess_height -= bottom;
top = MAX(0, excess_height);
top = MIN(BASE_MARGIN_TOP, top);
g_video_act_margin_top = top;
#endif
}
// OG Adding release
void x_release_kimage(Kimage* kimage_ptr)
{
if (kimage_ptr->dev_handle == (void*)-1)
{
free(kimage_ptr->data_ptr);
kimage_ptr->data_ptr = NULL;
}
else
{
if (!macUsingCoreGraphics)
{
#ifdef ENABLEQD
UnlockPixels((PixMapHandle)kimage_ptr->dev_handle);
kimage_ptr->dev_handle = NULL;
DisposeGWorld((GWorldPtr)kimage_ptr->dev_handle2);
kimage_ptr->dev_handle2 = NULL;
#endif
}
}
}
// OG Addding ratio
int x_calc_ratio(float&x,float&y)
{
return 1;
}

834
jni/macdriver_kegs.c Normal file
View File

@ -0,0 +1,834 @@
#include "defc.h"
#include "protos_macdriver.h"
pascal OSStatus quit_event_handler(EventHandlerCallRef call_ref, EventRef event, void *ignore);
pascal OSStatus my_cmd_handler(EventHandlerCallRef handlerRef, EventRef event, void *userdata);
pascal OSStatus my_win_handler(EventHandlerCallRef handlerRef, EventRef event, void *userdata);
pascal OSStatus dummy_event_handler(EventHandlerCallRef call_ref, EventRef in_event, void *ignore);
int g_quit_seen = 0;
#define MAX_STATUS_LINES 7
#define X_LINE_LENGTH 88
#define MAX_MAC_ARGS 128
int g_mac_argc = 0;
char *g_mac_argv[MAX_MAC_ARGS];
extern char g_argv0_path[];
extern char *g_status_ptrs[MAX_STATUS_LINES];
extern const char g_kegs_version_str[];
extern int g_warp_pointer;
extern WindowRef g_main_window;
WindowRef g_main_window_saved;
EventHandlerUPP g_quit_handler_UPP;
EventHandlerUPP g_dummy_event_handler_UPP;
RgnHandle g_event_rgnhandle = 0;
FMFontFamily g_status_font_family;
extern word32 g_red_mask;
extern word32 g_green_mask;
extern word32 g_blue_mask;
extern int g_red_left_shift;
extern int g_green_left_shift;
extern int g_blue_left_shift;
extern int g_red_right_shift;
extern int g_green_right_shift;
extern int g_blue_right_shift;
int g_ignore_next_click = 0;
int g_mainwin_active = 0;
int g_mac_mouse_x = 0;
int g_mac_mouse_y = 0;
extern int g_video_act_width;
extern int g_video_act_height;
extern int g_video_act_margin_left;
extern int g_video_act_margin_right;
extern int g_video_act_margin_top;
extern int g_video_act_margin_bottom;
extern int g_screen_depth;
extern int g_force_depth;
extern int g_screen_mdepth;
Ptr g_mac_fullscreen_state = 0;
Rect g_main_window_saved_rect;
extern char *g_fatal_log_strs[];
extern int g_fatal_log;
int
x_show_alert(int is_fatal, const char *str)
{
DialogRef alert;
DialogItemIndex out_item_hit;
CFStringRef cfstrref, cfstrref2;
CFStringRef okstrref;
AlertStdCFStringAlertParamRec alert_param;
OSStatus osstat;
char *bufptr, *buf2ptr;
int sum, len;
int i;
/* The dialog eats all events--including key-up events */
/* Call adb_all_keys_up() to prevent annoying key-repeat problems */
/* for instance, a key-down causes a dialog to appear--and the */
/* eats the key-up event...then as soon as the dialog goes, adb.c */
/* auto-repeat will repeat the key, and the dialog re-appears...*/
adb_all_keys_up();
sum = 20;
for(i = 0; i < g_fatal_log; i++) {
sum += strlen(g_fatal_log_strs[i]);
}
bufptr = (char*)malloc(sum);
buf2ptr = bufptr;
for(i = 0; i < g_fatal_log; i++) {
len = strlen(g_fatal_log_strs[i]);
len = MIN(len, sum);
len = MAX(len, 0);
memcpy(bufptr, g_fatal_log_strs[i], MIN(len, sum));
bufptr += len;
bufptr[0] = 0;
sum = sum - len;
}
cfstrref = CFStringCreateWithCString(NULL, buf2ptr,
kCFStringEncodingMacRoman);
printf("buf2ptr: :%s:\n", buf2ptr);
osstat = GetStandardAlertDefaultParams(&alert_param,
kStdCFStringAlertVersionOne);
if(str) {
// Provide an extra option--create a file
cfstrref2 = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
CFSTR("Create ~/Library/KEGS/%s"), str);
alert_param.otherText = cfstrref2;
}
okstrref = CFSTR("Click OK to continue");
if(is_fatal) {
okstrref = CFSTR("Clock OK to exit KEGS");
}
CreateStandardAlert(kAlertStopAlert, cfstrref, okstrref,
&alert_param, &alert);
out_item_hit = -1;
RunStandardAlert(alert, NULL, &out_item_hit);
printf("out_item_hit: %d\n", out_item_hit);
free(buf2ptr);
clear_fatal_logs(); /* free the fatal_log string memory */
return (out_item_hit >= 3);
}
pascal OSStatus
quit_event_handler(EventHandlerCallRef call_ref, EventRef event, void *ignore)
{
OSStatus err;
err = CallNextEventHandler(call_ref, event);
if(err == noErr) {
g_quit_seen = 1;
}
return err;
}
void
show_simple_alert(char *str1, char *str2, char *str3, int num)
{
char buf[256];
g_fatal_log_strs[0] = kegs_malloc_str(str1);
g_fatal_log_strs[1] = kegs_malloc_str(str2);
g_fatal_log_strs[2] = kegs_malloc_str(str3);
g_fatal_log = 3;
if(num != 0) {
snprintf(buf, 250, ": %d", num);
g_fatal_log_strs[g_fatal_log++] = kegs_malloc_str(buf);
}
x_show_alert(0, 0);
}
void
x_dialog_create_kegs_conf(const char *str)
{
char *path;
char tmp_buf[512];
int ret;
ret = x_show_alert(1, str);
if(ret) {
// Create empty file
path = "~/Library/KEGS";
snprintf(tmp_buf, 500, "mkdir -p %s", path);
system(tmp_buf);
snprintf(tmp_buf, 500, "touch %s/%s", path, str);
system(tmp_buf);
}
}
pascal OSStatus
my_cmd_handler( EventHandlerCallRef handlerRef, EventRef event, void *userdata)
{
OSStatus osresult;
HICommand command;
word32 command_id;
osresult = eventNotHandledErr;
GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL,
sizeof(HICommand), NULL, &command);
command_id = (word32)command.commandID;
switch(command_id) {
case 'Kbep':
SysBeep(10);
osresult = noErr;
break;
case 'abou':
show_simple_alert("KEGSMAC v", (char *)g_kegs_version_str,
", Copyright 2004 Kent Dickey\n"
"Latest version at http://kegs.sourceforge.net/\n", 0);
osresult = noErr;
break;
case 'KCFG':
#ifdef ACTIVEGS
#else
cfg_toggle_config_panel();
#endif
osresult = noErr;
break;
case 'quit':
break;
case 'swin':
/* not sure what this is, but Panther sends it */
break;
default:
printf("commandID %08x unknown\n", command_id);
SysBeep(90);
break;
}
return osresult;
}
pascal OSStatus
my_win_handler(EventHandlerCallRef handlerRef, EventRef event, void *userdata)
{
OSStatus os_result;
UInt32 event_kind;
os_result = eventNotHandledErr;
// SysBeep(1);
event_kind = GetEventKind(event);
// show_alert("win handler", event_kind);
if(event_kind == kEventWindowDrawContent)
{
update_window();
} if(event_kind == kEventWindowClose) {
// OG Use HALT_WANTTOQUIT pardigme
//g_quit_sim_now = 1;
set_halt_act(HALT_WANTTOQUIT);
#ifndef ACTIVEGS
g_quit_seen = 1;
my_exit(0);
#endif
} else {
//show_event(GetEventClass(event), event_kind, 0);
update_window();
}
return os_result;
}
pascal OSStatus
dummy_event_handler(EventHandlerCallRef call_ref, EventRef in_event,
void *ignore)
{
OSStatus err;
EventHandlerRef installed_handler;
EventTypeSpec event_spec = { kEventClassApplication, kEventAppQuit };
// From http://developer.apple.com/qa/qa2001/qa1061.html
// Trick to move main event queue to use ReceiveNextEvent in an event
// handler called by RunApplicationEventLoop
err = InstallApplicationEventHandler(g_quit_handler_UPP, 1, &event_spec,
NULL, &installed_handler);
kegsmain(g_mac_argc, g_mac_argv);
return noErr;
}
void
check_input_events()
{
OSStatus err;
EventTargetRef target;
EventRef event;
UInt32 event_class, event_kind;
byte mac_keycode;
UInt32 keycode;
UInt32 modifiers;
Point mouse_point, mouse_delta_point;
WindowRef window_ref;
int button, button_state;
EventMouseButton mouse_button;
int handled;
int mouse_events;
int is_up;
int in_win;
int ignore;
if(g_quit_seen) {
exit(0);
}
SetPortWindowPort(g_main_window);
mouse_events = 0;
target = GetEventDispatcherTarget();
while(1) {
err = ReceiveNextEvent(0, NULL, kEventDurationNoWait,
true, &event);
if(err == eventLoopTimedOutErr) {
break;
}
if(err != noErr) {
printf("ReceiveNextEvent err: %d\n", (int)err);
break;
}
event_class = GetEventClass(event);
event_kind = GetEventKind(event);
handled = 0;
switch(event_class) {
case kEventClassKeyboard:
handled = 1;
keycode = 0;
modifiers = 0;
GetEventParameter(event, kEventParamKeyMacCharCodes,
typeChar, NULL, sizeof(byte), NULL,
&mac_keycode);
GetEventParameter(event, kEventParamKeyCode,
typeUInt32, NULL, sizeof(UInt32), NULL,
&keycode);
GetEventParameter(event, kEventParamKeyModifiers,
typeUInt32, NULL, sizeof(UInt32), NULL,
&modifiers);
mac_update_modifiers((word32)modifiers);
// Key up/down event
is_up = -1;
switch(event_kind) {
case kEventRawKeyDown:
is_up = 0;
//printf("key down: %02x, %08x\n",
// (int)mac_keycode, (int)keycode);
break;
case kEventRawKeyUp:
is_up = 1;
//printf("key up: %02x, %08x\n",
// (int)mac_keycode, (int)keycode);
break;
case kEventRawKeyModifiersChanged:
is_up = -1;
//printf("key xxx: %08x\n", (int)modifiers);
break;
}
if(is_up >= 0) {
adb_physical_key_update((int)keycode, is_up);
}
break;
case kEventClassMouse:
handled = 2;
mouse_events++;
GetEventParameter(event, kEventParamMouseLocation,
typeQDPoint, NULL, sizeof(Point), NULL,
&mouse_point);
GetWindowRegion(g_main_window, kWindowContentRgn,
g_event_rgnhandle);
in_win = PtInRgn(mouse_point, g_event_rgnhandle);
// in_win = 1 if it was in the contect region of window
err = GetEventParameter(event, kEventParamMouseDelta,
typeQDPoint, NULL, sizeof(Point), NULL,
&mouse_delta_point);
button = 0;
button_state = -1;
switch(event_kind) {
case kEventMouseDown:
button_state = 7;
handled = 3;
break;
case kEventMouseUp:
button_state = 0;
handled = 3;
break;
}
if(button_state >= 0) {
GetEventParameter(event, kEventParamMouseButton,
typeMouseButton, NULL,
sizeof(EventMouseButton), NULL,
&mouse_button);
button = mouse_button;
if(button > 1) {
button = 4 - button;
button = 1 << button;
}
ignore = (button_state != 0) &&
(!in_win || g_ignore_next_click);
ignore = ignore || !g_mainwin_active;
if(ignore) {
// Outside of A2 window, ignore clicks
button = 0;
}
if(button_state == 0) {
g_ignore_next_click = 0;
}
}
GlobalToLocal(&mouse_point);
if(g_warp_pointer) {
if(err == 0) {
g_mac_mouse_x += mouse_delta_point.h;
g_mac_mouse_y += mouse_delta_point.v;
}
mac_warp_mouse();
} else {
g_mac_mouse_x = mouse_point.h -
g_video_act_margin_left;
g_mac_mouse_y = mouse_point.v -
g_video_act_margin_top;
}
#if 0
printf("Mouse %d at: %d,%d button:%d, button_st:%d\n",
mouse_events, g_mac_mouse_x, g_mac_mouse_y,
button, button_state);
printf("Mouse deltas: err:%d, %d,%d\n", (int)err,
mouse_delta_point.h, mouse_delta_point.v);
#endif
update_mouse(g_mac_mouse_x, g_mac_mouse_y,
button_state, button & 7);
if(g_warp_pointer) {
g_mac_mouse_x = A2_WINDOW_WIDTH/2;
g_mac_mouse_y = A2_WINDOW_HEIGHT/2;
update_mouse(g_mac_mouse_x, g_mac_mouse_y,0,-1);
}
break;
case kEventClassApplication:
switch(event_kind) {
case kEventAppActivated:
handled = 1;
g_mainwin_active = 1;
window_ref = 0;
GetEventParameter(event, kEventParamWindowRef,
typeWindowRef, NULL, sizeof(WindowRef),
NULL, &window_ref);
if(window_ref == g_main_window) {
g_ignore_next_click = 1;
}
break;
case kEventAppDeactivated:
handled = 1;
g_mainwin_active = 0;
g_ignore_next_click = 1;
break;
}
break;
}
// show_event(event_class, event_kind, handled);
if(handled != 1) {
(void)SendEventToEventTarget(event, target);
}
ReleaseEvent(event);
}
return;
}
void
temp_run_application_event_loop(void)
{
OSStatus err;
EventRef dummy_event;
EventHandlerRef install_handler;
EventTypeSpec event_spec = { 'KWIN', 'KWIN' };
// Create UPP for dummy_event_handler and for quit_event_handler
err = noErr;
dummy_event = 0;
g_dummy_event_handler_UPP = NewEventHandlerUPP(dummy_event_handler);
g_quit_handler_UPP = NewEventHandlerUPP(quit_event_handler);
if((g_dummy_event_handler_UPP == 0) || (g_quit_handler_UPP == 0)) {
err = memFullErr;
}
if(err == noErr) {
err = InstallApplicationEventHandler(g_dummy_event_handler_UPP,
1, &event_spec, 0, &install_handler);
if(err == noErr) {
err = MacCreateEvent(NULL, 'KWIN', 'KWIN',
GetCurrentEventTime(), kEventAttributeNone,
&dummy_event);
if(err == noErr) {
err = PostEventToQueue(GetMainEventQueue(),
dummy_event, kEventPriorityHigh);
}
if(err == noErr) {
RunApplicationEventLoop();
}
(void)RemoveEventHandler(install_handler);
}
}
if(dummy_event != NULL) {
ReleaseEvent(dummy_event);
}
}
int
#ifdef ACTIVEGS
macmain
#else
main
#endif
(int argc, char* argv[])
{
ProcessSerialNumber my_psn;
IBNibRef nibRef;
EventHandlerUPP handlerUPP;
EventTypeSpec cmd_event[3];
GDHandle g_gdhandle ;
Rect win_rect;
OSStatus err;
char *argptr;
int slash_cnt;
int i;
#ifndef ACTIVEGS
/* Prepare argv0 */
slash_cnt = 0;
argptr = argv[0];
for(i = strlen(argptr); i >= 0; i--) {
if(argptr[i] == '/') {
slash_cnt++;
if(slash_cnt == 3) {
strncpy(&(g_argv0_path[0]), argptr, i);
g_argv0_path[i] = 0;
}
}
}
printf("g_argv0_path is %s\n", g_argv0_path);
g_mac_argv[0] = argv[0];
g_mac_argc = 1;
i = 1;
while((i < argc) && (g_mac_argc < MAX_MAC_ARGS)) {
if(!strncmp(argv[i], "-psn", 4)) {
/* skip this argument */
} else {
g_mac_argv[g_mac_argc++] = argv[i];
}
i++;
}
#endif
InitCursor();
g_event_rgnhandle = NewRgn();
g_status_font_family = FMGetFontFamilyFromName("\pCourier");
SetRect(&win_rect, 0, 0, X_A2_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT
// OG Remove status line from ActiveGS window
#ifndef ACTIVEGS
+ MAX_STATUS_LINES*16 + 8
#endif
);
OffsetRect(&win_rect, 64, 50);
// Create a Nib reference passing the name of the nib file
// CreateNibReference only searches into the application bundle.
err = CreateNibReference(CFSTR("main"), &nibRef);
require_noerr( err, CantGetNibRef );
// Once the nib reference is created, set the menu bar.
err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
require_noerr( err, CantSetMenuBar );
#ifndef ACTIVEGS
err = CreateNewWindow(kDocumentWindowClass,
kWindowStandardDocumentAttributes |
kWindowStandardHandlerAttribute,
&win_rect, &g_main_window);
err = SetWindowTitleWithCFString(g_main_window, CFSTR("KEGSMAC"));
#else
err = CreateNewWindow(kDocumentWindowClass,
(kWindowCloseBoxAttribute /*| kWindowFullZoomAttribute */| kWindowCollapseBoxAttribute /*| kWindowResizableAttribute*/) /*kWindowStandardDocumentAttributes*/ |
kWindowStandardHandlerAttribute,
&win_rect, &g_main_window);
extern CFStringRef activeGSversionSTR;
err = SetWindowTitleWithCFString(g_main_window, activeGSversionSTR);
#endif
//printf("CreateNewWindow ret: %d, g_main_window: %p\n", (int)err, g_main_window);
// We don't need the nib reference anymore.
DisposeNibReference(nibRef);
SysBeep(120);
handlerUPP = NewEventHandlerUPP( my_cmd_handler );
cmd_event[0].eventClass = kEventClassCommand;
cmd_event[0].eventKind = kEventProcessCommand;
InstallWindowEventHandler(g_main_window, handlerUPP, 1, &cmd_event[0],
(void *)g_main_window, NULL);
handlerUPP = NewEventHandlerUPP(my_win_handler);
cmd_event[0].eventClass = kEventClassWindow;
cmd_event[0].eventKind = kEventWindowDrawContent;
cmd_event[1].eventClass = kEventClassWindow;
cmd_event[1].eventKind = kEventWindowUpdate;
cmd_event[2].eventClass = kEventClassWindow;
cmd_event[2].eventKind = kEventWindowClose;
err = InstallWindowEventHandler(g_main_window, handlerUPP, 3,
&cmd_event[0], (void *)g_main_window, NULL);
require_noerr(err, CantCreateWindow);
// Get screen depth
g_gdhandle = GetGDevice();
g_screen_mdepth = (**((**g_gdhandle).gdPMap)).pixelSize;
g_screen_depth = g_screen_mdepth;
if(g_screen_depth > 16) {
/* 32-bit display */
g_red_mask = 0xff;
g_green_mask = 0xff;
g_blue_mask = 0xff;
/*
if (macUsingCoreGraphics)
{
g_red_left_shift = 0;
g_green_left_shift = 8;
g_blue_left_shift = 16;
}
else
*/
{
g_red_left_shift = 16;
g_green_left_shift = 8;
g_blue_left_shift = 0;
}
g_red_right_shift = 0;
g_green_right_shift = 0;
g_blue_right_shift = 0;
} else if(g_screen_depth > 8) {
/* 16-bit display */
g_red_mask = 0x1f;
g_green_mask = 0x1f;
g_blue_mask = 0x1f;
g_red_left_shift = 10;
g_green_left_shift = 5;
g_blue_left_shift = 0;
g_red_right_shift = 3;
g_green_right_shift = 3;
g_blue_right_shift = 3;
}
// show_alert("About to show window", (int)g_main_window);
update_main_window_size();
update_window();
// The window was created hidden so show it.
ShowWindow( g_main_window );
BringToFront( g_main_window );
update_window();
// Make us pop to the front a different way
err = GetCurrentProcess(&my_psn);
if(err == noErr) {
(void)SetFrontProcess(&my_psn);
}
// Call the event loop
temp_run_application_event_loop();
CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
show_simple_alert("ending", "", "error code", err);
return err;
}
void
xdriver_end()
{
printf("xdriver_end\n");
if(g_fatal_log >= 0) {
x_show_alert(1, 0);
}
}
void
x_redraw_status_lines()
{
// OG Disable status line
#ifndef ACTIVEGS
Rect rect;
Pattern white_pattern;
char tmp_buf[256];
char *buf;
int len;
int line;
int height;
int margin;
SetPortWindowPort(g_main_window);
PenNormal();
height = 16;
margin = 0;
TextFont(g_status_font_family);
TextFace(normal);
TextSize(12);
SetRect(&rect, 0, X_A2_WINDOW_HEIGHT + margin, X_A2_WINDOW_WIDTH,
X_A2_WINDOW_HEIGHT + margin + MAX_STATUS_LINES*height);
GetQDGlobalsWhite(&white_pattern);
FillRect(&rect, &white_pattern);
for(line = 0; line < MAX_STATUS_LINES; line++) {
buf = g_status_ptrs[line];
if(buf == 0) {
/* skip it */
continue;
}
MoveTo(10, X_A2_WINDOW_HEIGHT + height*line + margin + height);
len = MIN(250, strlen(buf));
strncpy(&tmp_buf[1], buf, len);
tmp_buf[0] = len;
DrawString((const unsigned char*)&tmp_buf[0]);
}
#endif
}
void
x_full_screen(int do_full)
{
#if 0
WindowRef new_window;
short width, height;
OSErr ret;
width = 640;
height = 480;
if(do_full && (g_mac_fullscreen_state == 0)) {
g_main_window_saved = g_main_window;
GetWindowBounds(g_main_window, kWindowContentRgn,
&g_main_window_saved_rect);
ret = BeginFullScreen(&g_mac_fullscreen_state, 0,
&width, &height, &new_window, 0, 0);
printf("Ret beginfullscreen: %d\n", (int)ret);
printf("New width: %d, new height: %d\n", width, height);
if(ret == noErr) {
g_main_window = new_window;
} else {
g_mac_fullscreen_state = 0;
}
} else if(!do_full && (g_mac_fullscreen_state != 0)) {
ret = EndFullScreen(g_mac_fullscreen_state, 0);
printf("ret endfullscreen: %d\n", (int)ret);
g_main_window = g_main_window_saved;
g_mac_fullscreen_state = 0;
//InitCursor();
SetWindowBounds(g_main_window, kWindowContentRgn,
&g_main_window_saved_rect);
}
update_main_window_size();
ShowWindow(g_main_window);
BringToFront(g_main_window);
update_window();
#endif
}
void
x_push_done()
{
CGrafPtr window_port;
SetPortWindowPort(g_main_window);
window_port = GetWindowPort(g_main_window);
QDFlushPortBuffer(window_port, 0);
}
void
mac_warp_mouse()
{
#ifndef ACTIVEGS
Rect port_rect;
Point win_origin_pt;
CGPoint cgpoint;
CGDisplayErr cg_err;
GetPortBounds(GetWindowPort(g_main_window), &port_rect);
SetPt(&win_origin_pt, port_rect.left, port_rect.top);
LocalToGlobal(&win_origin_pt);
cgpoint = CGPointMake( (float)(win_origin_pt.h + X_A2_WINDOW_WIDTH/2),
(float)(win_origin_pt.v + X_A2_WINDOW_HEIGHT/2));
cg_err = CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
#endif
}

View File

@ -11,9 +11,17 @@
const char rcsid_macsnd_driver_c[] = "@(#)$KmKId: macsnd_driver.c,v 1.4 2003-10-17 15:57:40-04 kentd Exp $";
#include "defc.h"
#include "sound.h"
#ifdef ACTIVEIPHONE
void child_sound_init_mac() {}
void macsnd_init(word32 *shmaddr) {}
int mac_send_audio(byte *ptr, int in_size) {}
#else
#include <Carbon/Carbon.h>
#include "sound.h"
#include <unistd.h>
#define MACSND_REBUF_SIZE (64*1024)
@ -32,6 +40,7 @@ extern word32 *g_sound_shm_addr;
extern int g_sound_size;
SndChannelPtr g_snd_channel_ptr;
ExtSoundHeader g_snd_hdr;
SndCommand g_snd_cmd;
@ -58,7 +67,7 @@ mac_snd_callback(SndChannelPtr snd_chan_ptr, SndCommand *in_sndcmd)
g_macsnd_playing = 1;
g_snd_hdr.numFrames = samps;
g_snd_hdr.loopEnd = samps;
g_snd_hdr.samplePtr = (byte *)g_macsnd_rebuf_cur;
g_snd_hdr.samplePtr = (char *)g_macsnd_rebuf_cur; // OG Cast from byte* to ,char*
g_snd_cmd.cmd = bufferCmd;
g_snd_cmd.param1 = 0;
@ -152,3 +161,4 @@ macsnd_init(word32 *shmaddr)
mac_printf("macsnd_init called\n");
child_sound_loop(-1, -1, shmaddr);
}
#endif

View File

@ -1,31 +0,0 @@
#!/usr/local/bin/perl -w
# $KmKId: make_inst,v 1.5 2002-11-07 08:18:16-08 kadickey Exp $
$is_c = shift;
$repl = shift;
$count = 0;
while(<>) {
$line = $_;
if(/^inst(..)_SYM(.*)$/) {
if($is_c eq "c") {
if($count > 0) {
printf("\tbreak;\n");
}
print "case 0x$1: $2\n";
$count++;
} else {
print "\t.align\t8\n";
print "inst" . "$1" . "_$repl" . "$2\n";
}
} elsif(/^(.*)_SYM(.*)$/) {
print "$1" . "_$repl" . "$2\n";
} else {
print $line;
}
}
# if(/^inst(..)_SYM (.*)$/) {
# print "OPCODE($1) /* $2 */\n";
# } else if(/^(

View File

@ -1,30 +0,0 @@
#!/usr/local/bin/perl -w
# $KmKId: make_size,v 1.3 2002-11-07 08:18:16-08 kadickey Exp $
$repl = shift;
while(<>) {
$line = $_;
if(/\.word inst(..)_SYM\+(.)(.*)$/) {
if($repl eq "c") {
print "\t0x$2, /* $1 */ $3\n";
} elsif($repl eq "s") {
print "\t.byte 0x$2, /* $1 */ $3\n";
} else {
print "\t.word\tinst$1" . "_$repl" . "\t/*$2*/ $3\n";
}
} elsif (/\.block.*$/) {
if($repl eq "c") {
print "\n";
} elsif($repl eq "s") {
print "\n";
} else {
print $line;
}
} else {
print $line;
}
}
# if(/^inst(..)_SYM (.*)$/) {
# print "OPCODE($1) /* $2 */\n";
# } else if(/^(

View File

@ -1,4 +0,0 @@
#!/bin/sh
export PATH="/mingw/bin:${PATH}"
make

View File

@ -12,7 +12,7 @@ const char rcsid_moremem_c[] = "@(#)$KmKId: moremem.c,v 1.251 2004-11-19 01:55:5
#include "defc.h"
extern char g_kegs_version_str[];
extern const char* g_kegs_version_str;
extern byte *g_memory_ptr;
extern byte *g_dummy_memory1_ptr;
@ -45,6 +45,8 @@ int g_paddle_buttons = 0;
int g_irq_pending = 0;
int g_c023_val = 0;
//int g_delayed_c023_val = 0; // OG Added delayed c023
int g_c029_val_some = 0x41;
int g_c02b_val = 0x08;
int g_c02d_int_crom = 0;
@ -129,6 +131,109 @@ Emustate_word32list g_emustate_word32list[] = {
halt_printf("UNIMP WRITE to addr %08x, val: %04x\n", loc, val); \
return;
//#ifdef _WINDOWS
// OG Added Transwarp ROM
#define TRANSWARP
int transwarp_low_val = 0;
#ifdef _WIN32
__declspec(align(256))
#endif
unsigned char transwarpcode[][32]
#ifndef _WIN32
__attribute__ ((aligned(256)))
#endif
={
{
/*0xBCFF00*/ 'T','W','G','S',0,0,0,0,0,0,0,0,0,0,0,0,
/*0xBCFF10*/ 0x5C,0x40,0xFF,0xBC, // JMP GetMaxSpeed
/*0xBCFF14*/ 0x5C,0x60,0xFF,0xBC, // JMP GetNumISpeed
/*0xBCFF18*/ 0x6B,0x00,0x00,0x00, // ???
/*0xBCFF1C*/ 0x6B,0x00,0x00,0x00 // ???
},
{
/*0xBCFF20*/ 0x5C,0x80,0xFF,0xBC, // JMP GetCurSpeed
/*0xBCFF24*/ 0x5C,0xA0,0xFF,0xBC, // JMP SetCurSpeed
/*0xBCFF28*/ 0x5C,0xC0,0xFF,0xBC, // JMP GetCurISpeed
/*0xBCFF2C*/ 0x5C,0xE0,0xFF,0xBC, // JMP SetCurISpeed
/*0xBCFF30*/ 0x6B,0x00,0x00,0x00, // ???
/*0xBCFF34*/ 0x6B,0x00,0x00,0x00, // ???
/*0xBCFF38*/ 0x6B,0x00,0x00,0x00, // ???
/*0xBCFF3C*/ 0x6B,0x00,0x00,0x00 // GetTWConfig
},
{
/* 0xBCFF40*/ // GetMaxSpeed
#define ZIP_SPEED 8000
0xA9, ZIP_SPEED & 0xFF, (ZIP_SPEED >> 8) &0xFF, // LDA 0x1F40 // Max Speed = 8.0Mhz
0x6B, // RTL
0x00,0x00,0x00,0x00, //4
0x00,0x00,0x00,0x00, //8
0x6B,0x00,0x00,0x00, //C Space Shark calls this address ???
},
{
/* 0xBCFF60*/ //GetNumISpeed
0xA9,0x02,0x00, // LDA 0x0002 // 0=slow, 1=normal, 2=warp
0x6B, // RTL
},
{
/* 0xBCFF80*/ //GetCurSpeed
0xAF, 0x6A, 0xC0, 0x00, // LDA 0xC06A (/6B)
0x6B, // RTL
},
{
/* 0xBCFFA0*/ //SetCurSpeed
0x8F, 0x6A, 0xC0, 0x00, // STA 0xC06A (/6B)
0x6B, // RTL
},
{
/* 0xBCFFC0*/ //GetCurISpeed
0x48, // PHA
0xAF, 0x6C, 0xC0, 0x00, // LDA 0xC06C (/6D)
0xAA, // TAX
0x68, // PLA
0x6B, // RTL
},
{
/* 0xBCFFE0*/ //SetCurISpeed
0x48, // PHA
0x8A, // TXA
0x8F, 0x6C, 0xC0, 0x00, // STA 0xC06C (/6D)
0x68, // PLA
0x6B, // RTL
}
}
;
// OG Added moremem_init()
void moremem_init()
{
g_em_emubyte_cnt = 0;
g_paddle_buttons = 0;
g_irq_pending = 0;
g_c023_val = 0;
g_c029_val_some = 0x41;
g_c02b_val = 0x08;
g_c02d_int_crom = 0;
g_c031_disk35 = 0;
g_c034_val = 0;
g_c035_shadow_reg = 0x08;
g_c036_val_speed = 0x80;
g_c03ef_doc_ptr = 0;
g_c041_val = 0; /* C041_EN_25SEC_INTS, C041_EN_MOVE_INTS */
g_c046_val = 0;
g_c05x_annuncs = 0;
g_c068_statereg = 0;
g_c08x_wrdefram = 0;
g_zipgs_unlock = 0;
g_zipgs_reg_c059 = 0x5f;
g_zipgs_reg_c05a = 0x0f;
g_zipgs_reg_c05b = 0x40;
g_zipgs_reg_c05c = 0x00;
}
void
fixup_brks()
{
@ -670,55 +775,55 @@ fixup_rdrom()
void
set_statereg(double dcycs, int val)
{
int xor;
int _xor; // OG renamed xor to _xor
xor = val ^ g_c068_statereg;
_xor = val ^ g_c068_statereg;
g_c068_statereg = val;
if(xor == 0) {
if(_xor == 0) {
return;
}
if(xor & 0x80) {
if(_xor & 0x80) {
/* altzp */
fixup_altzp();
}
if(xor & 0x40) {
if(_xor & 0x40) {
/* page2 */
g_cur_a2_stat = (g_cur_a2_stat & ~ALL_STAT_PAGE2) |
(val & ALL_STAT_PAGE2);
fixup_page2(dcycs);
}
if(xor & 0x20) {
if(_xor & 0x20) {
/* RAMRD */
fixup_ramrd();
}
if(xor & 0x10) {
if(_xor & 0x10) {
/* RAMWRT */
fixup_ramwrt();
}
if(xor & 0x08) {
if(_xor & 0x08) {
/* RDROM */
fixup_rdrom();
}
if(xor & 0x04) {
if(_xor & 0x04) {
/* LCBANK2 */
fixup_lcbank2();
}
if(xor & 0x02) {
if(_xor & 0x02) {
/* ROMBANK */
halt_printf("Just set rombank = %d\n", ROMB);
}
if(xor & 0x01) {
if(_xor & 0x01) {
fixup_intcx();
}
if(xor) {
if(_xor) {
fixup_brks();
}
}
@ -888,42 +993,42 @@ fixup_shadow_iolc()
void
update_shadow_reg(int val)
{
int xor;
int _xor;
if(g_c035_shadow_reg == val) {
return;
}
xor = g_c035_shadow_reg ^ val;
_xor = g_c035_shadow_reg ^ val;
g_c035_shadow_reg = val;
if(xor & 8) {
if(_xor & 8) {
fixup_shadow_hires1();
fixup_shadow_hires2();
fixup_shadow_shr();
xor = xor & (~0x16);
_xor = _xor & (~0x16);
}
if(xor & 0x10) {
if(_xor & 0x10) {
fixup_shadow_hires1();
fixup_shadow_hires2();
xor = xor & (~0x6);
_xor = _xor & (~0x6);
}
if(xor & 2) {
if(_xor & 2) {
fixup_shadow_hires1();
}
if(xor & 4) {
if(_xor & 4) {
fixup_shadow_hires2();
}
if(xor & 1) {
if(_xor & 1) {
fixup_shadow_txt1();
}
if((xor & 0x20) && ((g_rom_version >= 3) || g_user_page2_shadow)) {
if((_xor & 0x20) && ((g_rom_version >= 3) || g_user_page2_shadow)) {
fixup_shadow_txt2();
}
if(xor & 0x40) {
if(_xor & 0x40) {
fixup_shadow_iolc();
}
if(xor) {
if(_xor) {
fixup_brks();
}
}
@ -1014,6 +1119,10 @@ setup_pageinfo()
fixup_shadow_shr();
fixup_shadow_iolc();
fixup_brks();
#ifdef TRANSWARP // OG adding Transwarp code
SET_PAGE_INFO_RD(0xBCFF,transwarpcode);
#endif
}
void
@ -1151,7 +1260,14 @@ io_read(word32 loc, double *cyc_ptr)
case 0x22: /* 0xc022 */
return (g_cur_a2_stat >> BIT_ALL_STAT_BG_COLOR) & 0xff;
case 0x23: /* 0xc023 */
return g_c023_val;
/*
{
extern Engine_reg engine;
// printf("c023=%X (%X)\n",g_c023_val,engine.kpc);
if (engine.kpc==0xB7D84) __asm int 3;
}
*/
return g_c023_val;
case 0x24: /* 0xc024 */
return mouse_read_c024(dcycs);
case 0x25: /* 0xc025 */
@ -1398,9 +1514,31 @@ io_read(word32 loc, double *cyc_ptr)
case 0x69: /* 0xc069 */
/* Reserved reg, return 0 */
return 0;
// OG Transwarp Read Interface
#ifdef TRANSWARP
case 0x6a: /* 0xc06a */
{
extern double g_zip_pmhz;
return (int)(g_zip_pmhz*1000)&0xFF;
}
case 0x6b: /* 0xc06b */
{
extern double g_zip_pmhz;
return (((int)(g_zip_pmhz*1000))>>8)&0xFF;
}
case 0x6c: /* 0xc06c */
{
extern double g_zip_pmhz;
if (g_zip_pmhz==1.0) return 0; // slow
else if (g_zip_pmhz>=2.6) return 2; // warp
else return 1; // zip
}
#else
case 0x6a: /* 0xc06a */
case 0x6b: /* 0xc06b */
case 0x6c: /* 0xc06c */
#endif
case 0x6d: /* 0xc06d */
case 0x6e: /* 0xc06e */
case 0x6f: /* 0xc06f */
@ -1670,9 +1808,11 @@ io_write(word32 loc, int val, double *cyc_ptr)
}
tmp = (g_c023_val & 0x70) | (val & 0x0f);
if((tmp & 0x22) == 0x22) {
//printf("adding scanline irq\n");
add_irq(IRQ_PENDING_C023_SCAN);
}
if(!(tmp & 2)) {
//printf("remove scanline irq\n");
remove_irq(IRQ_PENDING_C023_SCAN);
}
if((tmp & 0x44) == 0x44) {
@ -1686,6 +1826,8 @@ io_write(word32 loc, int val, double *cyc_ptr)
IRQ_PENDING_C023_1SEC)) {
tmp |= 0x80;
}
//printf("old c023: %X new: %X\n",g_c023_val,tmp);
g_c023_val = tmp;
return;
case 0x24: /* 0xc024 */
@ -1763,16 +1905,39 @@ io_write(word32 loc, int val, double *cyc_ptr)
/* clear 1 sec int */
remove_irq(IRQ_PENDING_C023_1SEC);
tmp &= 0xbf;
//printf("c032 (1s) old: %X new: %X\n",g_c023_val,tmp & 0xbf);
g_c023_val = tmp;
}
if( (val & 0x20) == 0 && !(tmp & 0x20) )
{
irq_printf("no scan int irq to clear\n");
}
else
if(((val & 0x20) == 0) && (tmp & 0x20)) {
/* clear scan line int */
remove_irq(IRQ_PENDING_C023_SCAN);
#if 0
// OG delayed write C023 (wait end of line before clearing value)
{
extern word32 kpc;
printf("(%X) delayed clearing scanline irq old: %X new: %X\n",kpc,g_c023_val,tmp & 0xdf);
// add_event_entry(dcycs+ (DCYCS_IN_16MS/262.0)/2, 8 /*EV_DELAY_WRITE_C023*/ );
g_delayed_c023_val = 1;
}
#else
//printf("clearing g_c023_val\n");
g_c023_val = tmp & 0xdf;
check_for_new_scan_int(dcycs);
#endif
}
if(g_irq_pending & (IRQ_PENDING_C023_1SEC |
IRQ_PENDING_C023_SCAN)) {
irq_printf("c032 pending: %X\n",g_c023_val);
g_c023_val |= 0x80;
}
if((val & 0x9f) != 0x9f) {
@ -2032,9 +2197,53 @@ io_write(word32 loc, int val, double *cyc_ptr)
case 0x69: /* 0xc069 */
/* just ignore, someone writing c068 with m=0 */
return;
#ifdef TRANSWARP
// OG writeTranswarp pseudo-register
case 0x6a: /* 0xc06a */
transwarp_low_val = val;
return ;
case 0x6b: /* 0xc06b */
val = (val<<8) + transwarp_low_val;
if ((val==2600) || (val==0x0028)) // Bug for demo ...
{
printf("Disabling Transwarp!\n");
g_zipgs_reg_c05b |= 0x10; // disable
set_halt(HALT_EVENT);
}
else if (val==8000)
{
printf("Enabling Transwarp!\n");
g_zipgs_reg_c05b &= ~0x10; // enable
set_halt(HALT_EVENT);
}
else
printf("unknown twgs speed:%d\n",val);
return;
case 0x6c: /* 0xc06c */
if (val==0)
; // set slow ?
else if (val==1)
{
// disable zip
g_zipgs_reg_c05b |= 0x10; // disable
set_halt(HALT_EVENT);
}
else if (val==2)
{
// enable zip
g_zipgs_reg_c05b &= ~0x10; // enable
set_halt(HALT_EVENT);
}
else
printf("unknown twgs index:%d\n",val);
return ;
#else
case 0x6a: /* 0xc06a */
case 0x6b: /* 0xc06b */
case 0x6c: /* 0xc06c */
#endif
case 0x6d: /* 0xc06d */
case 0x6e: /* 0xc06e */
case 0x6f: /* 0xc06f */

View File

@ -1,169 +0,0 @@
<?xml version="1.0" standalone="yes"?>
<object class="NSIBObjectData">
<string name="targetFramework">IBCarbonFramework</string>
<object name="rootObject" class="NSCustomObject" id="1">
<string name="customClass">NSApplication</string>
</object>
<array count="18" name="allObjects">
<object class="IBCarbonMenu" id="29">
<string name="title">main</string>
<array count="3" name="items">
<object class="IBCarbonMenuItem" id="185">
<string name="title">KEGSMAC</string>
<object name="submenu" class="IBCarbonMenu" id="184">
<string name="title">KEGSMAC</string>
<array count="3" name="items">
<object class="IBCarbonMenuItem" id="187">
<string name="title">About KEGSMAC</string>
<int name="keyEquivalentModifier">0</int>
<ostype name="command">abou</ostype>
</object>
<object class="IBCarbonMenuItem" id="199">
<boolean name="separator">TRUE</boolean>
</object>
<object class="IBCarbonMenuItem" id="198">
<string name="title">Quit</string>
<int name="keyEquivalentModifier">0</int>
<ostype name="command">quit</ostype>
</object>
</array>
<string name="name">_NSAppleMenu</string>
</object>
</object>
<object class="IBCarbonMenuItem" id="127">
<string name="title">File</string>
<object name="submenu" class="IBCarbonMenu" id="131">
<string name="title">File</string>
<array count="1" name="items">
<object class="IBCarbonMenuItem" id="200">
<string name="title">Configuration F4</string>
<int name="keyEquivalentModifier">0</int>
<ostype name="command">KCFG</ostype>
<string name="helpTagText">Enter KEGS Configuration Panel</string>
</object>
</array>
</object>
</object>
<object class="IBCarbonMenuItem" id="192">
<string name="title">Window</string>
<object name="submenu" class="IBCarbonMenu" id="195">
<string name="title">Window</string>
<array count="6" name="items">
<object class="IBCarbonMenuItem" id="197">
<string name="title">Zoom Window</string>
<ostype name="command">zoom</ostype>
</object>
<object class="IBCarbonMenuItem" id="190">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Minimize Window</string>
<int name="keyEquivalentModifier">0</int>
<ostype name="command">mini</ostype>
</object>
<object class="IBCarbonMenuItem" id="191">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Minimize All Windows</string>
<int name="keyEquivalentModifier">0</int>
<ostype name="command">mina</ostype>
</object>
<object class="IBCarbonMenuItem" id="194">
<boolean name="separator">TRUE</boolean>
</object>
<object class="IBCarbonMenuItem" id="196">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Bring All to Front</string>
<ostype name="command">bfrt</ostype>
</object>
<object class="IBCarbonMenuItem" id="193">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Arrange in Front</string>
<int name="keyEquivalentModifier">1572864</int>
<ostype name="command">frnt</ostype>
</object>
</array>
<string name="name">_NSWindowsMenu</string>
</object>
</object>
</array>
<string name="name">_NSMainMenu</string>
</object>
<reference idRef="127"/>
<reference idRef="131"/>
<object class="IBCarbonMenuItem" id="153">
<string name="title">Window</string>
<object name="submenu" class="IBCarbonMenu">
<string name="title">Window</string>
<array count="5" name="items">
<object class="IBCarbonMenuItem">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Minimize Window</string>
<string name="keyEquivalent">m</string>
<ostype name="command">mini</ostype>
</object>
<object class="IBCarbonMenuItem">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Minimize All Windows</string>
<string name="keyEquivalent">m</string>
<int name="keyEquivalentModifier">1572864</int>
<ostype name="command">mini</ostype>
</object>
<object class="IBCarbonMenuItem">
<boolean name="separator">TRUE</boolean>
</object>
<object class="IBCarbonMenuItem">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Bring All to Front</string>
<ostype name="command">frnt</ostype>
</object>
<object class="IBCarbonMenuItem">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Bring in Front</string>
<int name="keyEquivalentModifier">1572864</int>
<ostype name="command">frnt</ostype>
</object>
</array>
<string name="name">_NSWindowsMenu</string>
</object>
</object>
<reference idRef="184"/>
<reference idRef="185"/>
<reference idRef="187"/>
<reference idRef="190"/>
<reference idRef="191"/>
<reference idRef="192"/>
<reference idRef="193"/>
<reference idRef="194"/>
<reference idRef="195"/>
<reference idRef="196"/>
<reference idRef="197"/>
<reference idRef="198"/>
<reference idRef="199"/>
<reference idRef="200"/>
</array>
<array count="18" name="allParents">
<reference idRef="1"/>
<reference idRef="29"/>
<reference idRef="127"/>
<reference idRef="29"/>
<reference idRef="185"/>
<reference idRef="29"/>
<reference idRef="184"/>
<reference idRef="195"/>
<reference idRef="195"/>
<reference idRef="29"/>
<reference idRef="195"/>
<reference idRef="195"/>
<reference idRef="192"/>
<reference idRef="195"/>
<reference idRef="195"/>
<reference idRef="184"/>
<reference idRef="184"/>
<reference idRef="131"/>
</array>
<dictionary count="2" name="nameTable">
<string>Files Owner</string>
<reference idRef="1"/>
<string>MenuBar</string>
<reference idRef="29"/>
</dictionary>
<unsigned_int name="nextObjectID">201</unsigned_int>
</object>

View File

@ -23,7 +23,7 @@ int g_joystick_scale_factor_y = 0x100;
int g_joystick_trim_amount_x = 0;
int g_joystick_trim_amount_y = 0;
int g_joystick_type = 0; /* 0 = Keypad Joystick */
int g_joystick_type = JOYSTICK_TYPE_NATIVE_1; // OG Trying to set native joystick as default
int g_joystick_native_type1 = -1;
int g_joystick_native_type2 = -1;
int g_joystick_native_type = -1;
@ -37,20 +37,23 @@ double g_paddle_dcycs[4] = { 0.0, 0.0, 0.0, 0.0 };
/* g_paddle_dcycs are the dcycs the paddle goes to 0 */
void
paddle_fixup_joystick_type()
{
/* If g_joystick_type points to an illegal value, change it */
if(g_joystick_type == 2) {
if(g_joystick_type == JOYSTICK_TYPE_NATIVE_1) {
g_joystick_native_type = g_joystick_native_type1;
if(g_joystick_native_type1 < 0) {
g_joystick_type = 0;
g_joystick_type = JOYSTICK_TYPE_KEYPAD;
printf("no joy 1 --- switching to keypad\n");
}
}
if(g_joystick_type == 3) {
if(g_joystick_type == JOYSTICK_TYPE_NATIVE_2) {
g_joystick_native_type = g_joystick_native_type2;
if(g_joystick_native_type2 < 0) {
g_joystick_type = 0;
g_joystick_type = JOYSTICK_TYPE_KEYPAD;
printf("no joy 2 --- switching to keypad\n");
}
}
}
@ -65,10 +68,13 @@ paddle_trigger(double dcycs)
paddle_fixup_joystick_type();
switch(g_joystick_type) {
case 0: /* Keypad Joystick */
case JOYSTICK_TYPE_KEYPAD: /* Keypad Joystick */
paddle_trigger_keypad(dcycs);
break;
case 1: /* Mouse Joystick */
case JOYSTICK_TYPE_MOUSE: /* Mouse Joystick */
paddle_trigger_mouse(dcycs);
break;
case JOYSTICK_TYPE_NONE: /* Mouse Joystick */
paddle_trigger_mouse(dcycs);
break;
default:

0
jni/partls.c Executable file → Normal file
View File

0
jni/prodos.h Executable file → Normal file
View File

0
jni/prodos_protos.h Executable file → Normal file
View File

View File

@ -42,6 +42,7 @@ void do_gen_test(int got_num, int base_seed);
/* engine.s and engine_c.c */
void fixed_memory_ptrs_init();
void fixed_memory_ptrs_shut(); // OG Added shut to smoothly free up allocated memory
word32 get_itimer(void);
word32 get_memory_c(word32 addr, int cycs);
@ -84,6 +85,7 @@ void joystick_update_buttons(void);
/* adb.c */
void adb_init(void);
void adb_shut(); // OG Added adb_shut()
void adb_reset(void);
void adb_log(word32 addr, int val);
void show_adb_log(void);
@ -284,6 +286,7 @@ void scc_socket_do_answer(int port, double dcycs);
void iwm_init_drive(Disk *dsk, int smartport, int drive, int disk_525);
void disk_set_num_tracks(Disk *dsk, int num_tracks);
void iwm_init(void);
void iwm_shut(void); //OG
void iwm_reset(void);
void draw_iwm_status(int line, char *buf);
void iwm_flush_disk_to_unix(Disk *dsk);
@ -324,6 +327,7 @@ void iwm_show_a_track(Trk *trk);
/* moremem.c */
void moremem_init(); // OG Added moremem_init()
void fixup_brks(void);
void fixup_hires_on(void);
void fixup_bank0_2000_4000(void);
@ -382,8 +386,10 @@ void do_reset(void);
void check_engine_asm_defines(void);
byte *memalloc_align(int size, int skip_amt, void **alloc_ptr);
void memory_ptr_init(void);
void memory_ptr_shut(void); // OG Added shut
int kegsmain(int argc, char **argv);
void load_roms_init_memory(void);
void load_roms_shut_memory(void); // OG Added shut
void kegs_expand_path(char *out_ptr, const char *in_ptr, int maxlen);
void setup_kegs_file(char *outname, int maxlen, int ok_if_missing, int can_create_file, const char **name_ptr);
void initialize_events(void);

View File

@ -13,15 +13,11 @@ const char rcsid_protos_mac_h[] = "@(#)$KmKId: protos_macdriver.h,v 1.11 2004-11
/* END_HDR */
/* macdriver.c */
pascal OSStatus quit_event_handler(EventHandlerCallRef call_ref, EventRef event, void *ignore);
void show_simple_alert(char *str1, char *str2, char *str3, int num);
void x_dialog_create_kegs_conf(const char *str);
int x_show_alert(int is_fatal, const char *str);
pascal OSStatus my_cmd_handler(EventHandlerCallRef handlerRef, EventRef event, void *userdata);
void update_window(void);
void show_event(UInt32 event_class, UInt32 event_kind, int handled);
pascal OSStatus my_win_handler(EventHandlerCallRef handlerRef, EventRef event, void *userdata);
pascal OSStatus dummy_event_handler(EventHandlerCallRef call_ref, EventRef in_event, void *ignore);
int x_show_alert(int is_fatal, const char *str);void update_window(void);
void mac_update_modifiers(word32 state);
void mac_warp_mouse(void);
void check_input_events(void);

View File

@ -14,7 +14,7 @@
/* windriver.c */
int win_update_mouse(int x, int y, int button_states, int buttons_valid);
void win_event_mouse(WPARAM wParam, LPARAM lParam);
void win_event_mouse(int umsg,WPARAM wParam, LPARAM lParam);
void win_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags);
void win_event_quit(HWND hwnd);
void win_event_redraw(void);

View File

@ -12,6 +12,10 @@ const char rcsid_scc_c[] = "@(#)$KmKId: scc.c,v 1.44 2004-12-03 17:33:40-05 kent
#include "defc.h"
#ifdef UNDER_CE
#define vsnprintf _vsnprintf
#endif
extern int Verbose;
extern int g_code_yellow;
extern double g_cur_dcycs;
@ -1113,7 +1117,7 @@ scc_add_to_readbufv(int port, double dcycs, const char *fmt, ...)
int i;
va_start(ap, fmt);
bufptr = malloc(4096);
bufptr = (char*)malloc(4096); // OG cast added
bufptr[0] = 0;
ret = vsnprintf(bufptr, 4090, fmt, ap);
len = strlen(bufptr);

View File

@ -23,8 +23,10 @@ const char rcsid_scc_h[] = "@(#)$KmKId: scc.h,v 1.17 2004-12-03 14:03:12-05 kent
#endif
#if defined(HPUX) || defined(__linux__) || defined(SOLARIS) || defined(MAC) || defined(__MACH__) || defined(_WIN32)
#ifndef __ANDROID__
# define SCC_SOCKETS
#endif
#endif
/* my scc port 0 == channel A, port 1 = channel B */

View File

@ -70,7 +70,7 @@ scc_serial_mac_change_params(int port)
scc_ptr = &(scc_stat[port]);
fd = (int)scc_ptr->host_handle;
fd = (intptr_t)scc_ptr->host_handle;
printf("scc_serial_mac_change_parms port: %d, fd: %d\n", port, fd);
if(fd <= 0) {
return;
@ -140,7 +140,7 @@ scc_serial_mac_fill_readbuf(int port, int space_left, double dcycs)
scc_ptr = &(scc_stat[port]);
fd = (int)scc_ptr->host_handle;
fd = (intptr_t)scc_ptr->host_handle;
if(fd <= 0) {
return;
}
@ -170,7 +170,7 @@ scc_serial_mac_empty_writebuf(int port)
scc_ptr = &(scc_stat[port]);
fd = (int)scc_ptr->host_handle;
fd = (intptr_t)scc_ptr->host_handle;
if(fd <= 0) {
return;
}

View File

@ -14,12 +14,17 @@ const char rcsid_scc_socket_driver_c[] = "@(#)$KmKId: scc_socket_driver.c,v 1.11
#include "defc.h"
#include "scc.h"
#ifndef UNDER_CE //OG
#include <signal.h>
#endif
extern Scc scc_stat[2];
extern int g_serial_modem[];
#ifndef _MSC_VER //OG
extern int h_errno;
#else
#define socklen_t int
#endif
int g_wsastartup_called = 0;
/* Usage: scc_socket_init() called to init socket mode */
@ -186,7 +191,7 @@ scc_socket_open_outgoing(int port, double dcycs)
memset(&sa_in, 0, sizeof(sa_in));
sa_in.sin_family = AF_INET;
sa_in.sin_port = htons(23);
hostentptr = gethostbyname(&scc_ptr->modem_cmd_str[0]);
hostentptr = gethostbyname((const char*)&scc_ptr->modem_cmd_str[0]); // OG Added Cast
if(hostentptr == 0) {
#ifdef _WIN32
fatal_printf("Lookup host %s failed\n",
@ -343,8 +348,8 @@ scc_accept_socket(int port, double dcycs)
return; /* just give up */
}
if(scc_ptr->rdwrfd == -1) {
rdwrfd = accept(scc_ptr->sockfd, scc_ptr->host_handle,
&(scc_ptr->host_aux1));
rdwrfd = accept(scc_ptr->sockfd, (sockaddr*)scc_ptr->host_handle,
(socklen_t*)&(scc_ptr->host_aux1));
if(rdwrfd < 0) {
return;
}
@ -439,7 +444,7 @@ scc_socket_fill_readbuf(int port, int space_left, double dcycs)
/* Try reading some bytes */
space_left = MIN(space_left, 256);
ret = recv(rdwrfd, tmp_buf, space_left, 0);
ret = recv(rdwrfd, (char*)tmp_buf, space_left, 0); // OG Added cast
if(ret > 0) {
for(i = 0; i < ret; i++) {
if(tmp_buf[i] == 0) {
@ -731,7 +736,7 @@ scc_socket_empty_writebuf(int port, double dcycs)
}
# ifdef _WIN32
ret = send(rdwrfd, &(scc_ptr->out_buf[rdptr]), len, 0);
ret = send(rdwrfd, (const char*)&(scc_ptr->out_buf[rdptr]), len, 0); // OG Added Cast
# else
/* ignore SIGPIPE around writes to the socket, so we */
/* can catch a closed socket and prepare to accept */
@ -791,7 +796,7 @@ scc_socket_modem_write(int port, int c, double dcycs)
}
modem_mode = scc_ptr->modem_mode;
str = &(scc_ptr->modem_cmd_str[0]);
str = (char*)&(scc_ptr->modem_cmd_str[0]); // OG Added Cast
#if 0
printf("M: %02x\n", c);
@ -855,7 +860,7 @@ scc_socket_do_cmd_str(int port, double dcycs)
scc_ptr = &(scc_stat[port]);
str = &(scc_ptr->modem_cmd_str[0]);
str = (char*)&(scc_ptr->modem_cmd_str[0]); // OG Added cast
printf("Got modem string :%s:=%02x %02x %02x\n", str, str[0], str[1],
str[2]);
@ -1093,7 +1098,7 @@ scc_socket_modem_do_ring(int port, double dcycs)
num_rings = 0;
}
scc_ptr->socket_num_rings = num_rings;
scc_ptr->socket_last_ring_dcycs = dcycs;
scc_ptr->socket_last_ring_dcycs = (int)dcycs;
if(num_rings <= 0) {
/* decide on answering */
if(scc_ptr->modem_s0_val || (g_serial_modem[port]==0)) {

View File

@ -15,6 +15,10 @@ const char rcsid_scc_windriver_c[] = "@(#)$KmKId: scc_windriver.c,v 1.4 2004-11-
#include "defc.h"
#include "scc.h"
#ifdef UNDER_CE
#define vsnprintf _vsnprintf
#endif
extern Scc scc_stat[2];
extern word32 g_c025_val;
@ -23,7 +27,7 @@ int
scc_serial_win_init(int port)
{
COMMTIMEOUTS commtimeouts;
char str_buf[8];
TCHAR str_buf[8];
Scc *scc_ptr;
HANDLE host_handle;
int state;
@ -33,8 +37,11 @@ scc_serial_win_init(int port)
scc_ptr->state = 0; /* mark as failed */
#ifdef UNICODE
wsprintf(&str_buf[0], _T("COM%d"), port+1);
#else
sprintf(&str_buf[0], "COM%d", port+1);
#endif
host_handle = CreateFile(&str_buf[0], GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
@ -79,7 +86,7 @@ scc_serial_win_change_params(int port)
scc_ptr = &(scc_stat[port]);
host_handle = scc_ptr->host_handle;
dcbptr = scc_ptr->host_handle2;
dcbptr = (DCB*)scc_ptr->host_handle2; // OG Added cast
if(host_handle == 0) {
return;
}
@ -157,7 +164,7 @@ scc_serial_win_fill_readbuf(int port, int space_left, double dcycs)
Scc *scc_ptr;
HANDLE host_handle;
DWORD bytes_read;
int i;
DWORD i;
int ret;
scc_ptr = &(scc_stat[port]);

File diff suppressed because it is too large Load Diff

View File

@ -1,274 +1,274 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
#ifdef INCLUDE_RCSID_S
.stringz "@(#)$KmKId: size_tab.h,v 1.13 2002-11-19 03:10:38-05 kadickey Exp $"
#else
0x1, /* 00 */ /* brk */
0x1, /* 01 */ /* ORA (Dloc,X) */
0x1, /* 02 */ /* COP */
0x1, /* 03 */ /* ORA Disp8,S */
0x1, /* 04 */ /* TSB Dloc */
0x1, /* 05 */ /* ORA Dloc */
0x1, /* 06 */ /* ASL Dloc */
0x1, /* 07 */ /* ORA [Dloc] */
0x0, /* 08 */ /* PHP */
0x4, /* 09 */ /* ORA #imm */
0x0, /* 0a */ /* ASL a */
0x0, /* 0b */ /* PHD */
0x2, /* 0c */ /* TSB abs */
0x2, /* 0d */ /* ORA abs */
0x2, /* 0e */ /* ASL abs */
0x3, /* 0f */ /* ORA long */
0x1, /* 10 */ /* BPL disp8 */
0x1, /* 11 */ /* ORA (),y */
0x1, /* 12 */ /* ORA () */
0x1, /* 13 */ /* ORA (disp8,s),y */
0x1, /* 14 */ /* TRB Dloc */
0x1, /* 15 */ /* ORA Dloc,x */
0x1, /* 16 */ /* ASL Dloc,x */
0x1, /* 17 */ /* ORA [],y */
0x0, /* 18 */ /* clc */
0x2, /* 19 */ /* ORA abs,y */
0x0, /* 1a */ /* INC a */
0x0, /* 1b */ /* TCS */
0x2, /* 1c */ /* TRB Abs */
0x2, /* 1d */ /* ORA Abs,X */
0x2, /* 1e */ /* ASL abs,x */
0x3, /* 1f */ /* ORA Long,x */
0x2, /* 20 */ /* JSR abs */
0x1, /* 21 */ /* AND (Dloc,X) */
0x3, /* 22 */ /* JSL Abslong */
0x1, /* 23 */ /* AND Disp8,S */
0x1, /* 24 */ /* BIT Dloc */
0x1, /* 25 */ /* AND Dloc */
0x1, /* 26 */ /* ROL Dloc */
0x1, /* 27 */ /* AND [Dloc] */
0x0, /* 28 */ /* PLP */
0x4, /* 29 */ /* AND #imm */
0x0, /* 2a */ /* ROL a */
0x0, /* 2b */ /* PLD */
0x2, /* 2c */ /* BIT abs */
0x2, /* 2d */ /* AND abs */
0x2, /* 2e */ /* ROL abs */
0x3, /* 2f */ /* AND long */
0x1, /* 30 */ /* BMI disp8 */
0x1, /* 31 */ /* AND (),y */
0x1, /* 32 */ /* AND () */
0x1, /* 33 */ /* AND (disp8,s),y */
0x1, /* 34 */ /* BIT Dloc,X */
0x1, /* 35 */ /* AND Dloc,x */
0x1, /* 36 */ /* ROL Dloc,x */
0x1, /* 37 */ /* AND [],y */
0x0, /* 38 */ /* SEC */
0x2, /* 39 */ /* AND abs,y */
0x0, /* 3a */ /* DEC a */
0x0, /* 3b */ /* TSC */
0x2, /* 3c */ /* BIT Abs,X */
0x2, /* 3d */ /* AND Abs,X */
0x2, /* 3e */ /* ROL abs,x */
0x3, /* 3f */ /* AND Long,x */
0x0, /* 40 */ /* RTI */
0x1, /* 41 */ /* EOR (Dloc,X) */
0x1, /* 42 */ /* WDM */
0x1, /* 43 */ /* EOR Disp8,S */
0x2, /* 44 */ /* MVP I,J */
0x1, /* 45 */ /* EOR Dloc */
0x1, /* 46 */ /* LSR Dloc */
0x1, /* 47 */ /* EOR [Dloc] */
0x0, /* 48 */ /* PHA */
0x4, /* 49 */ /* EOR #imm */
0x0, /* 4a */ /* LSR a */
0x0, /* 4b */ /* PHK */
0x2, /* 4c */ /* JMP abs */
0x2, /* 4d */ /* EOR abs */
0x2, /* 4e */ /* LSR abs */
0x3, /* 4f */ /* EOR long */
0x1, /* 50 */ /* BVC disp8 */
0x1, /* 51 */ /* EOR (),y */
0x1, /* 52 */ /* EOR () */
0x1, /* 53 */ /* EOR (disp8,s),y */
0x2, /* 54 */ /* MVN I,J */
0x1, /* 55 */ /* EOR Dloc,x */
0x1, /* 56 */ /* LSR Dloc,x */
0x1, /* 57 */ /* EOR [],y */
0x0, /* 58 */ /* CLI */
0x2, /* 59 */ /* EOR abs,y */
0x0, /* 5a */ /* PHY */
0x0, /* 5b */ /* TCD */
0x3, /* 5c */ /* JMP Long */
0x2, /* 5d */ /* EOR Abs,X */
0x2, /* 5e */ /* LSR abs,x */
0x3, /* 5f */ /* EOR Long,x */
0x0, /* 60 */ /* RTS */
0x1, /* 61 */ /* ADC (Dloc,X) */
0x2, /* 62 */ /* PER DISP16 */
0x1, /* 63 */ /* ADC Disp8,S */
0x1, /* 64 */ /* STZ Dloc */
0x1, /* 65 */ /* ADC Dloc */
0x1, /* 66 */ /* ROR Dloc */
0x1, /* 67 */ /* ADC [Dloc] */
0x0, /* 68 */ /* PLA */
0x4, /* 69 */ /* ADC #imm */
0x0, /* 6a */ /* ROR a */
0x0, /* 6b */ /* RTL */
0x2, /* 6c */ /* JMP (abs) */
0x2, /* 6d */ /* ADC abs */
0x2, /* 6e */ /* ROR abs */
0x3, /* 6f */ /* ADC long */
0x1, /* 70 */ /* BVS disp8 */
0x1, /* 71 */ /* ADC (),y */
0x1, /* 72 */ /* ADC () */
0x1, /* 73 */ /* ADC (disp8,s),y */
0x1, /* 74 */ /* STZ Dloc,X */
0x1, /* 75 */ /* ADC Dloc,x */
0x1, /* 76 */ /* ROR Dloc,x */
0x1, /* 77 */ /* ADC [],y */
0x0, /* 78 */ /* SEI */
0x2, /* 79 */ /* ADC abs,y */
0x0, /* 7a */ /* PLY */
0x0, /* 7b */ /* TDC */
0x2, /* 7c */ /* JMP (abs,x) */
0x2, /* 7d */ /* ADC Abs,X */
0x2, /* 7e */ /* ROR abs,x */
0x3, /* 7f */ /* ADC Long,x */
0x1, /* 80 */ /* BRA Disp8 */
0x1, /* 81 */ /* STA (Dloc,X) */
0x2, /* 82 */ /* BRL DISP16 */
0x1, /* 83 */ /* STA Disp8,S */
0x1, /* 84 */ /* STY Dloc */
0x1, /* 85 */ /* STA Dloc */
0x1, /* 86 */ /* STX Dloc */
0x1, /* 87 */ /* STA [Dloc] */
0x0, /* 88 */ /* DEY */
0x4, /* 89 */ /* BIT #imm */
0x0, /* 8a */ /* TXA */
0x0, /* 8b */ /* PHB */
0x2, /* 8c */ /* STY abs */
0x2, /* 8d */ /* STA abs */
0x2, /* 8e */ /* STX abs */
0x3, /* 8f */ /* STA long */
0x1, /* 90 */ /* BCC disp8 */
0x1, /* 91 */ /* STA (),y */
0x1, /* 92 */ /* STA () */
0x1, /* 93 */ /* STA (disp8,s),y */
0x1, /* 94 */ /* STY Dloc,X */
0x1, /* 95 */ /* STA Dloc,x */
0x1, /* 96 */ /* STX Dloc,y */
0x1, /* 97 */ /* STA [],y */
0x0, /* 98 */ /* TYA */
0x2, /* 99 */ /* STA abs,y */
0x0, /* 9a */ /* TXS */
0x0, /* 9b */ /* TXY */
0x2, /* 9c */ /* STX abs */
0x2, /* 9d */ /* STA Abs,X */
0x2, /* 9e */ /* STZ abs,x */
0x3, /* 9f */ /* STA Long,x */
0x5, /* a0 */ /* LDY #imm */
0x1, /* a1 */ /* LDA (Dloc,X) */
0x5, /* a2 */ /* LDX #imm */
0x1, /* a3 */ /* LDA Disp8,S */
0x1, /* a4 */ /* LDY Dloc */
0x1, /* a5 */ /* LDA Dloc */
0x1, /* a6 */ /* LDX Dloc */
0x1, /* a7 */ /* LDA [Dloc] */
0x0, /* a8 */ /* TAY */
0x4, /* a9 */ /* LDA #imm */
0x0, /* aa */ /* TAX */
0x0, /* ab */ /* PLB */
0x2, /* ac */ /* LDY abs */
0x2, /* ad */ /* LDA abs */
0x2, /* ae */ /* LDX abs */
0x3, /* af */ /* LDA long */
0x1, /* b0 */ /* BCS disp8 */
0x1, /* b1 */ /* LDA (),y */
0x1, /* b2 */ /* LDA () */
0x1, /* b3 */ /* LDA (disp8,s),y */
0x1, /* b4 */ /* LDY Dloc,X */
0x1, /* b5 */ /* LDA Dloc,x */
0x1, /* b6 */ /* LDX Dloc,y */
0x1, /* b7 */ /* LDA [],y */
0x0, /* b8 */ /* CLV */
0x2, /* b9 */ /* LDA abs,y */
0x0, /* ba */ /* TSX */
0x0, /* bb */ /* TYX */
0x2, /* bc */ /* LDY abs,x */
0x2, /* bd */ /* LDA Abs,X */
0x2, /* be */ /* LDX abs,y */
0x3, /* bf */ /* LDA Long,x */
0x5, /* c0 */ /* CPY #Imm */
0x1, /* c1 */ /* CMP (Dloc,X) */
0x1, /* c2 */ /* REP #8bit */
0x1, /* c3 */ /* CMP Disp8,S */
0x1, /* c4 */ /* CPY Dloc */
0x1, /* c5 */ /* CMP Dloc */
0x1, /* c6 */ /* DEC Dloc */
0x1, /* c7 */ /* CMP [Dloc] */
0x0, /* c8 */ /* INY */
0x4, /* c9 */ /* CMP #imm */
0x0, /* ca */ /* DEX */
0x0, /* cb */ /* WAI */
0x2, /* cc */ /* CPY abs */
0x2, /* cd */ /* CMP abs */
0x2, /* ce */ /* DEC abs */
0x3, /* cf */ /* CMP long */
0x1, /* d0 */ /* BNE disp8 */
0x1, /* d1 */ /* CMP (),y */
0x1, /* d2 */ /* CMP () */
0x1, /* d3 */ /* CMP (disp8,s),y */
0x1, /* d4 */ /* PEI Dloc */
0x1, /* d5 */ /* CMP Dloc,x */
0x1, /* d6 */ /* DEC Dloc,x */
0x1, /* d7 */ /* CMP [],y */
0x0, /* d8 */ /* CLD */
0x2, /* d9 */ /* CMP abs,y */
0x0, /* da */ /* PHX */
0x0, /* db */ /* STP */
0x2, /* dc */ /* JML (Abs) */
0x2, /* dd */ /* CMP Abs,X */
0x2, /* de */ /* DEC abs,x */
0x3, /* df */ /* CMP Long,x */
0x5, /* e0 */ /* CPX #Imm */
0x1, /* e1 */ /* SBC (Dloc,X) */
0x1, /* e2 */ /* SEP #8bit */
0x1, /* e3 */ /* SBC Disp8,S */
0x1, /* e4 */ /* CPX Dloc */
0x1, /* e5 */ /* SBC Dloc */
0x1, /* e6 */ /* INC Dloc */
0x1, /* e7 */ /* SBC [Dloc] */
0x0, /* e8 */ /* INX */
0x4, /* e9 */ /* SBC #imm */
0x0, /* ea */ /* NOP */
0x0, /* eb */ /* XBA */
0x2, /* ec */ /* CPX abs */
0x2, /* ed */ /* SBC abs */
0x2, /* ee */ /* INC abs */
0x3, /* ef */ /* SBC long */
0x1, /* f0 */ /* BEQ disp8 */
0x1, /* f1 */ /* SBC (),y */
0x1, /* f2 */ /* SBC () */
0x1, /* f3 */ /* SBC (disp8,s),y */
0x2, /* f4 */ /* PEA Imm */
0x1, /* f5 */ /* SBC Dloc,x */
0x1, /* f6 */ /* INC Dloc,x */
0x1, /* f7 */ /* SBC [],y */
0x0, /* f8 */ /* SED */
0x2, /* f9 */ /* SBC abs,y */
0x0, /* fa */ /* PLX */
0x0, /* fb */ /* XCE */
0x2, /* fc */ /* JSR (Abs,x) */
0x2, /* fd */ /* SBC Abs,X */
0x2, /* fe */ /* INC abs,x */
0x3, /* ff */ /* SBC Long,x */
#endif
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
#ifdef INCLUDE_RCSID_S
.stringz "@(#)$KmKId: size_tab.h,v 1.13 2002-11-19 03:10:38-05 kadickey Exp $"
#else
0x1, /* 00 */ /* brk */
0x1, /* 01 */ /* ORA (Dloc,X) */
0x1, /* 02 */ /* COP */
0x1, /* 03 */ /* ORA Disp8,S */
0x1, /* 04 */ /* TSB Dloc */
0x1, /* 05 */ /* ORA Dloc */
0x1, /* 06 */ /* ASL Dloc */
0x1, /* 07 */ /* ORA [Dloc] */
0x0, /* 08 */ /* PHP */
0x4, /* 09 */ /* ORA #imm */
0x0, /* 0a */ /* ASL a */
0x0, /* 0b */ /* PHD */
0x2, /* 0c */ /* TSB abs */
0x2, /* 0d */ /* ORA abs */
0x2, /* 0e */ /* ASL abs */
0x3, /* 0f */ /* ORA long */
0x1, /* 10 */ /* BPL disp8 */
0x1, /* 11 */ /* ORA (),y */
0x1, /* 12 */ /* ORA () */
0x1, /* 13 */ /* ORA (disp8,s),y */
0x1, /* 14 */ /* TRB Dloc */
0x1, /* 15 */ /* ORA Dloc,x */
0x1, /* 16 */ /* ASL Dloc,x */
0x1, /* 17 */ /* ORA [],y */
0x0, /* 18 */ /* clc */
0x2, /* 19 */ /* ORA abs,y */
0x0, /* 1a */ /* INC a */
0x0, /* 1b */ /* TCS */
0x2, /* 1c */ /* TRB Abs */
0x2, /* 1d */ /* ORA Abs,X */
0x2, /* 1e */ /* ASL abs,x */
0x3, /* 1f */ /* ORA Long,x */
0x2, /* 20 */ /* JSR abs */
0x1, /* 21 */ /* AND (Dloc,X) */
0x3, /* 22 */ /* JSL Abslong */
0x1, /* 23 */ /* AND Disp8,S */
0x1, /* 24 */ /* BIT Dloc */
0x1, /* 25 */ /* AND Dloc */
0x1, /* 26 */ /* ROL Dloc */
0x1, /* 27 */ /* AND [Dloc] */
0x0, /* 28 */ /* PLP */
0x4, /* 29 */ /* AND #imm */
0x0, /* 2a */ /* ROL a */
0x0, /* 2b */ /* PLD */
0x2, /* 2c */ /* BIT abs */
0x2, /* 2d */ /* AND abs */
0x2, /* 2e */ /* ROL abs */
0x3, /* 2f */ /* AND long */
0x1, /* 30 */ /* BMI disp8 */
0x1, /* 31 */ /* AND (),y */
0x1, /* 32 */ /* AND () */
0x1, /* 33 */ /* AND (disp8,s),y */
0x1, /* 34 */ /* BIT Dloc,X */
0x1, /* 35 */ /* AND Dloc,x */
0x1, /* 36 */ /* ROL Dloc,x */
0x1, /* 37 */ /* AND [],y */
0x0, /* 38 */ /* SEC */
0x2, /* 39 */ /* AND abs,y */
0x0, /* 3a */ /* DEC a */
0x0, /* 3b */ /* TSC */
0x2, /* 3c */ /* BIT Abs,X */
0x2, /* 3d */ /* AND Abs,X */
0x2, /* 3e */ /* ROL abs,x */
0x3, /* 3f */ /* AND Long,x */
0x0, /* 40 */ /* RTI */
0x1, /* 41 */ /* EOR (Dloc,X) */
0x1, /* 42 */ /* WDM */
0x1, /* 43 */ /* EOR Disp8,S */
0x2, /* 44 */ /* MVP I,J */
0x1, /* 45 */ /* EOR Dloc */
0x1, /* 46 */ /* LSR Dloc */
0x1, /* 47 */ /* EOR [Dloc] */
0x0, /* 48 */ /* PHA */
0x4, /* 49 */ /* EOR #imm */
0x0, /* 4a */ /* LSR a */
0x0, /* 4b */ /* PHK */
0x2, /* 4c */ /* JMP abs */
0x2, /* 4d */ /* EOR abs */
0x2, /* 4e */ /* LSR abs */
0x3, /* 4f */ /* EOR long */
0x1, /* 50 */ /* BVC disp8 */
0x1, /* 51 */ /* EOR (),y */
0x1, /* 52 */ /* EOR () */
0x1, /* 53 */ /* EOR (disp8,s),y */
0x2, /* 54 */ /* MVN I,J */
0x1, /* 55 */ /* EOR Dloc,x */
0x1, /* 56 */ /* LSR Dloc,x */
0x1, /* 57 */ /* EOR [],y */
0x0, /* 58 */ /* CLI */
0x2, /* 59 */ /* EOR abs,y */
0x0, /* 5a */ /* PHY */
0x0, /* 5b */ /* TCD */
0x3, /* 5c */ /* JMP Long */
0x2, /* 5d */ /* EOR Abs,X */
0x2, /* 5e */ /* LSR abs,x */
0x3, /* 5f */ /* EOR Long,x */
0x0, /* 60 */ /* RTS */
0x1, /* 61 */ /* ADC (Dloc,X) */
0x2, /* 62 */ /* PER DISP16 */
0x1, /* 63 */ /* ADC Disp8,S */
0x1, /* 64 */ /* STZ Dloc */
0x1, /* 65 */ /* ADC Dloc */
0x1, /* 66 */ /* ROR Dloc */
0x1, /* 67 */ /* ADC [Dloc] */
0x0, /* 68 */ /* PLA */
0x4, /* 69 */ /* ADC #imm */
0x0, /* 6a */ /* ROR a */
0x0, /* 6b */ /* RTL */
0x2, /* 6c */ /* JMP (abs) */
0x2, /* 6d */ /* ADC abs */
0x2, /* 6e */ /* ROR abs */
0x3, /* 6f */ /* ADC long */
0x1, /* 70 */ /* BVS disp8 */
0x1, /* 71 */ /* ADC (),y */
0x1, /* 72 */ /* ADC () */
0x1, /* 73 */ /* ADC (disp8,s),y */
0x1, /* 74 */ /* STZ Dloc,X */
0x1, /* 75 */ /* ADC Dloc,x */
0x1, /* 76 */ /* ROR Dloc,x */
0x1, /* 77 */ /* ADC [],y */
0x0, /* 78 */ /* SEI */
0x2, /* 79 */ /* ADC abs,y */
0x0, /* 7a */ /* PLY */
0x0, /* 7b */ /* TDC */
0x2, /* 7c */ /* JMP (abs,x) */
0x2, /* 7d */ /* ADC Abs,X */
0x2, /* 7e */ /* ROR abs,x */
0x3, /* 7f */ /* ADC Long,x */
0x1, /* 80 */ /* BRA Disp8 */
0x1, /* 81 */ /* STA (Dloc,X) */
0x2, /* 82 */ /* BRL DISP16 */
0x1, /* 83 */ /* STA Disp8,S */
0x1, /* 84 */ /* STY Dloc */
0x1, /* 85 */ /* STA Dloc */
0x1, /* 86 */ /* STX Dloc */
0x1, /* 87 */ /* STA [Dloc] */
0x0, /* 88 */ /* DEY */
0x4, /* 89 */ /* BIT #imm */
0x0, /* 8a */ /* TXA */
0x0, /* 8b */ /* PHB */
0x2, /* 8c */ /* STY abs */
0x2, /* 8d */ /* STA abs */
0x2, /* 8e */ /* STX abs */
0x3, /* 8f */ /* STA long */
0x1, /* 90 */ /* BCC disp8 */
0x1, /* 91 */ /* STA (),y */
0x1, /* 92 */ /* STA () */
0x1, /* 93 */ /* STA (disp8,s),y */
0x1, /* 94 */ /* STY Dloc,X */
0x1, /* 95 */ /* STA Dloc,x */
0x1, /* 96 */ /* STX Dloc,y */
0x1, /* 97 */ /* STA [],y */
0x0, /* 98 */ /* TYA */
0x2, /* 99 */ /* STA abs,y */
0x0, /* 9a */ /* TXS */
0x0, /* 9b */ /* TXY */
0x2, /* 9c */ /* STX abs */
0x2, /* 9d */ /* STA Abs,X */
0x2, /* 9e */ /* STZ abs,x */
0x3, /* 9f */ /* STA Long,x */
0x5, /* a0 */ /* LDY #imm */
0x1, /* a1 */ /* LDA (Dloc,X) */
0x5, /* a2 */ /* LDX #imm */
0x1, /* a3 */ /* LDA Disp8,S */
0x1, /* a4 */ /* LDY Dloc */
0x1, /* a5 */ /* LDA Dloc */
0x1, /* a6 */ /* LDX Dloc */
0x1, /* a7 */ /* LDA [Dloc] */
0x0, /* a8 */ /* TAY */
0x4, /* a9 */ /* LDA #imm */
0x0, /* aa */ /* TAX */
0x0, /* ab */ /* PLB */
0x2, /* ac */ /* LDY abs */
0x2, /* ad */ /* LDA abs */
0x2, /* ae */ /* LDX abs */
0x3, /* af */ /* LDA long */
0x1, /* b0 */ /* BCS disp8 */
0x1, /* b1 */ /* LDA (),y */
0x1, /* b2 */ /* LDA () */
0x1, /* b3 */ /* LDA (disp8,s),y */
0x1, /* b4 */ /* LDY Dloc,X */
0x1, /* b5 */ /* LDA Dloc,x */
0x1, /* b6 */ /* LDX Dloc,y */
0x1, /* b7 */ /* LDA [],y */
0x0, /* b8 */ /* CLV */
0x2, /* b9 */ /* LDA abs,y */
0x0, /* ba */ /* TSX */
0x0, /* bb */ /* TYX */
0x2, /* bc */ /* LDY abs,x */
0x2, /* bd */ /* LDA Abs,X */
0x2, /* be */ /* LDX abs,y */
0x3, /* bf */ /* LDA Long,x */
0x5, /* c0 */ /* CPY #Imm */
0x1, /* c1 */ /* CMP (Dloc,X) */
0x1, /* c2 */ /* REP #8bit */
0x1, /* c3 */ /* CMP Disp8,S */
0x1, /* c4 */ /* CPY Dloc */
0x1, /* c5 */ /* CMP Dloc */
0x1, /* c6 */ /* DEC Dloc */
0x1, /* c7 */ /* CMP [Dloc] */
0x0, /* c8 */ /* INY */
0x4, /* c9 */ /* CMP #imm */
0x0, /* ca */ /* DEX */
0x0, /* cb */ /* WAI */
0x2, /* cc */ /* CPY abs */
0x2, /* cd */ /* CMP abs */
0x2, /* ce */ /* DEC abs */
0x3, /* cf */ /* CMP long */
0x1, /* d0 */ /* BNE disp8 */
0x1, /* d1 */ /* CMP (),y */
0x1, /* d2 */ /* CMP () */
0x1, /* d3 */ /* CMP (disp8,s),y */
0x1, /* d4 */ /* PEI Dloc */
0x1, /* d5 */ /* CMP Dloc,x */
0x1, /* d6 */ /* DEC Dloc,x */
0x1, /* d7 */ /* CMP [],y */
0x0, /* d8 */ /* CLD */
0x2, /* d9 */ /* CMP abs,y */
0x0, /* da */ /* PHX */
0x0, /* db */ /* STP */
0x2, /* dc */ /* JML (Abs) */
0x2, /* dd */ /* CMP Abs,X */
0x2, /* de */ /* DEC abs,x */
0x3, /* df */ /* CMP Long,x */
0x5, /* e0 */ /* CPX #Imm */
0x1, /* e1 */ /* SBC (Dloc,X) */
0x1, /* e2 */ /* SEP #8bit */
0x1, /* e3 */ /* SBC Disp8,S */
0x1, /* e4 */ /* CPX Dloc */
0x1, /* e5 */ /* SBC Dloc */
0x1, /* e6 */ /* INC Dloc */
0x1, /* e7 */ /* SBC [Dloc] */
0x0, /* e8 */ /* INX */
0x4, /* e9 */ /* SBC #imm */
0x0, /* ea */ /* NOP */
0x0, /* eb */ /* XBA */
0x2, /* ec */ /* CPX abs */
0x2, /* ed */ /* SBC abs */
0x2, /* ee */ /* INC abs */
0x3, /* ef */ /* SBC long */
0x1, /* f0 */ /* BEQ disp8 */
0x1, /* f1 */ /* SBC (),y */
0x1, /* f2 */ /* SBC () */
0x1, /* f3 */ /* SBC (disp8,s),y */
0x2, /* f4 */ /* PEA Imm */
0x1, /* f5 */ /* SBC Dloc,x */
0x1, /* f6 */ /* INC Dloc,x */
0x1, /* f7 */ /* SBC [],y */
0x0, /* f8 */ /* SED */
0x2, /* f9 */ /* SBC abs,y */
0x0, /* fa */ /* PLX */
0x0, /* fb */ /* XCE */
0x2, /* fc */ /* JSR (Abs,x) */
0x2, /* fd */ /* SBC Abs,X */
0x2, /* fe */ /* INC abs,x */
0x3, /* ff */ /* SBC Long,x */
#endif

274
jni/size_s.h Normal file
View File

@ -0,0 +1,274 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
#ifdef INCLUDE_RCSID_S
.stringz "@(#)$KmKId: size_tab.h,v 1.13 2002-11-19 03:10:38-05 kadickey Exp $"
#else
.byte 0x1, /* 00 */ /* brk */
.byte 0x1, /* 01 */ /* ORA (Dloc,X) */
.byte 0x1, /* 02 */ /* COP */
.byte 0x1, /* 03 */ /* ORA Disp8,S */
.byte 0x1, /* 04 */ /* TSB Dloc */
.byte 0x1, /* 05 */ /* ORA Dloc */
.byte 0x1, /* 06 */ /* ASL Dloc */
.byte 0x1, /* 07 */ /* ORA [Dloc] */
.byte 0x0, /* 08 */ /* PHP */
.byte 0x4, /* 09 */ /* ORA #imm */
.byte 0x0, /* 0a */ /* ASL a */
.byte 0x0, /* 0b */ /* PHD */
.byte 0x2, /* 0c */ /* TSB abs */
.byte 0x2, /* 0d */ /* ORA abs */
.byte 0x2, /* 0e */ /* ASL abs */
.byte 0x3, /* 0f */ /* ORA long */
.byte 0x1, /* 10 */ /* BPL disp8 */
.byte 0x1, /* 11 */ /* ORA (),y */
.byte 0x1, /* 12 */ /* ORA () */
.byte 0x1, /* 13 */ /* ORA (disp8,s),y */
.byte 0x1, /* 14 */ /* TRB Dloc */
.byte 0x1, /* 15 */ /* ORA Dloc,x */
.byte 0x1, /* 16 */ /* ASL Dloc,x */
.byte 0x1, /* 17 */ /* ORA [],y */
.byte 0x0, /* 18 */ /* clc */
.byte 0x2, /* 19 */ /* ORA abs,y */
.byte 0x0, /* 1a */ /* INC a */
.byte 0x0, /* 1b */ /* TCS */
.byte 0x2, /* 1c */ /* TRB Abs */
.byte 0x2, /* 1d */ /* ORA Abs,X */
.byte 0x2, /* 1e */ /* ASL abs,x */
.byte 0x3, /* 1f */ /* ORA Long,x */
.byte 0x2, /* 20 */ /* JSR abs */
.byte 0x1, /* 21 */ /* AND (Dloc,X) */
.byte 0x3, /* 22 */ /* JSL Abslong */
.byte 0x1, /* 23 */ /* AND Disp8,S */
.byte 0x1, /* 24 */ /* BIT Dloc */
.byte 0x1, /* 25 */ /* AND Dloc */
.byte 0x1, /* 26 */ /* ROL Dloc */
.byte 0x1, /* 27 */ /* AND [Dloc] */
.byte 0x0, /* 28 */ /* PLP */
.byte 0x4, /* 29 */ /* AND #imm */
.byte 0x0, /* 2a */ /* ROL a */
.byte 0x0, /* 2b */ /* PLD */
.byte 0x2, /* 2c */ /* BIT abs */
.byte 0x2, /* 2d */ /* AND abs */
.byte 0x2, /* 2e */ /* ROL abs */
.byte 0x3, /* 2f */ /* AND long */
.byte 0x1, /* 30 */ /* BMI disp8 */
.byte 0x1, /* 31 */ /* AND (),y */
.byte 0x1, /* 32 */ /* AND () */
.byte 0x1, /* 33 */ /* AND (disp8,s),y */
.byte 0x1, /* 34 */ /* BIT Dloc,X */
.byte 0x1, /* 35 */ /* AND Dloc,x */
.byte 0x1, /* 36 */ /* ROL Dloc,x */
.byte 0x1, /* 37 */ /* AND [],y */
.byte 0x0, /* 38 */ /* SEC */
.byte 0x2, /* 39 */ /* AND abs,y */
.byte 0x0, /* 3a */ /* DEC a */
.byte 0x0, /* 3b */ /* TSC */
.byte 0x2, /* 3c */ /* BIT Abs,X */
.byte 0x2, /* 3d */ /* AND Abs,X */
.byte 0x2, /* 3e */ /* ROL abs,x */
.byte 0x3, /* 3f */ /* AND Long,x */
.byte 0x0, /* 40 */ /* RTI */
.byte 0x1, /* 41 */ /* EOR (Dloc,X) */
.byte 0x1, /* 42 */ /* WDM */
.byte 0x1, /* 43 */ /* EOR Disp8,S */
.byte 0x2, /* 44 */ /* MVP I,J */
.byte 0x1, /* 45 */ /* EOR Dloc */
.byte 0x1, /* 46 */ /* LSR Dloc */
.byte 0x1, /* 47 */ /* EOR [Dloc] */
.byte 0x0, /* 48 */ /* PHA */
.byte 0x4, /* 49 */ /* EOR #imm */
.byte 0x0, /* 4a */ /* LSR a */
.byte 0x0, /* 4b */ /* PHK */
.byte 0x2, /* 4c */ /* JMP abs */
.byte 0x2, /* 4d */ /* EOR abs */
.byte 0x2, /* 4e */ /* LSR abs */
.byte 0x3, /* 4f */ /* EOR long */
.byte 0x1, /* 50 */ /* BVC disp8 */
.byte 0x1, /* 51 */ /* EOR (),y */
.byte 0x1, /* 52 */ /* EOR () */
.byte 0x1, /* 53 */ /* EOR (disp8,s),y */
.byte 0x2, /* 54 */ /* MVN I,J */
.byte 0x1, /* 55 */ /* EOR Dloc,x */
.byte 0x1, /* 56 */ /* LSR Dloc,x */
.byte 0x1, /* 57 */ /* EOR [],y */
.byte 0x0, /* 58 */ /* CLI */
.byte 0x2, /* 59 */ /* EOR abs,y */
.byte 0x0, /* 5a */ /* PHY */
.byte 0x0, /* 5b */ /* TCD */
.byte 0x3, /* 5c */ /* JMP Long */
.byte 0x2, /* 5d */ /* EOR Abs,X */
.byte 0x2, /* 5e */ /* LSR abs,x */
.byte 0x3, /* 5f */ /* EOR Long,x */
.byte 0x0, /* 60 */ /* RTS */
.byte 0x1, /* 61 */ /* ADC (Dloc,X) */
.byte 0x2, /* 62 */ /* PER DISP16 */
.byte 0x1, /* 63 */ /* ADC Disp8,S */
.byte 0x1, /* 64 */ /* STZ Dloc */
.byte 0x1, /* 65 */ /* ADC Dloc */
.byte 0x1, /* 66 */ /* ROR Dloc */
.byte 0x1, /* 67 */ /* ADC [Dloc] */
.byte 0x0, /* 68 */ /* PLA */
.byte 0x4, /* 69 */ /* ADC #imm */
.byte 0x0, /* 6a */ /* ROR a */
.byte 0x0, /* 6b */ /* RTL */
.byte 0x2, /* 6c */ /* JMP (abs) */
.byte 0x2, /* 6d */ /* ADC abs */
.byte 0x2, /* 6e */ /* ROR abs */
.byte 0x3, /* 6f */ /* ADC long */
.byte 0x1, /* 70 */ /* BVS disp8 */
.byte 0x1, /* 71 */ /* ADC (),y */
.byte 0x1, /* 72 */ /* ADC () */
.byte 0x1, /* 73 */ /* ADC (disp8,s),y */
.byte 0x1, /* 74 */ /* STZ Dloc,X */
.byte 0x1, /* 75 */ /* ADC Dloc,x */
.byte 0x1, /* 76 */ /* ROR Dloc,x */
.byte 0x1, /* 77 */ /* ADC [],y */
.byte 0x0, /* 78 */ /* SEI */
.byte 0x2, /* 79 */ /* ADC abs,y */
.byte 0x0, /* 7a */ /* PLY */
.byte 0x0, /* 7b */ /* TDC */
.byte 0x2, /* 7c */ /* JMP (abs,x) */
.byte 0x2, /* 7d */ /* ADC Abs,X */
.byte 0x2, /* 7e */ /* ROR abs,x */
.byte 0x3, /* 7f */ /* ADC Long,x */
.byte 0x1, /* 80 */ /* BRA Disp8 */
.byte 0x1, /* 81 */ /* STA (Dloc,X) */
.byte 0x2, /* 82 */ /* BRL DISP16 */
.byte 0x1, /* 83 */ /* STA Disp8,S */
.byte 0x1, /* 84 */ /* STY Dloc */
.byte 0x1, /* 85 */ /* STA Dloc */
.byte 0x1, /* 86 */ /* STX Dloc */
.byte 0x1, /* 87 */ /* STA [Dloc] */
.byte 0x0, /* 88 */ /* DEY */
.byte 0x4, /* 89 */ /* BIT #imm */
.byte 0x0, /* 8a */ /* TXA */
.byte 0x0, /* 8b */ /* PHB */
.byte 0x2, /* 8c */ /* STY abs */
.byte 0x2, /* 8d */ /* STA abs */
.byte 0x2, /* 8e */ /* STX abs */
.byte 0x3, /* 8f */ /* STA long */
.byte 0x1, /* 90 */ /* BCC disp8 */
.byte 0x1, /* 91 */ /* STA (),y */
.byte 0x1, /* 92 */ /* STA () */
.byte 0x1, /* 93 */ /* STA (disp8,s),y */
.byte 0x1, /* 94 */ /* STY Dloc,X */
.byte 0x1, /* 95 */ /* STA Dloc,x */
.byte 0x1, /* 96 */ /* STX Dloc,y */
.byte 0x1, /* 97 */ /* STA [],y */
.byte 0x0, /* 98 */ /* TYA */
.byte 0x2, /* 99 */ /* STA abs,y */
.byte 0x0, /* 9a */ /* TXS */
.byte 0x0, /* 9b */ /* TXY */
.byte 0x2, /* 9c */ /* STX abs */
.byte 0x2, /* 9d */ /* STA Abs,X */
.byte 0x2, /* 9e */ /* STZ abs,x */
.byte 0x3, /* 9f */ /* STA Long,x */
.byte 0x5, /* a0 */ /* LDY #imm */
.byte 0x1, /* a1 */ /* LDA (Dloc,X) */
.byte 0x5, /* a2 */ /* LDX #imm */
.byte 0x1, /* a3 */ /* LDA Disp8,S */
.byte 0x1, /* a4 */ /* LDY Dloc */
.byte 0x1, /* a5 */ /* LDA Dloc */
.byte 0x1, /* a6 */ /* LDX Dloc */
.byte 0x1, /* a7 */ /* LDA [Dloc] */
.byte 0x0, /* a8 */ /* TAY */
.byte 0x4, /* a9 */ /* LDA #imm */
.byte 0x0, /* aa */ /* TAX */
.byte 0x0, /* ab */ /* PLB */
.byte 0x2, /* ac */ /* LDY abs */
.byte 0x2, /* ad */ /* LDA abs */
.byte 0x2, /* ae */ /* LDX abs */
.byte 0x3, /* af */ /* LDA long */
.byte 0x1, /* b0 */ /* BCS disp8 */
.byte 0x1, /* b1 */ /* LDA (),y */
.byte 0x1, /* b2 */ /* LDA () */
.byte 0x1, /* b3 */ /* LDA (disp8,s),y */
.byte 0x1, /* b4 */ /* LDY Dloc,X */
.byte 0x1, /* b5 */ /* LDA Dloc,x */
.byte 0x1, /* b6 */ /* LDX Dloc,y */
.byte 0x1, /* b7 */ /* LDA [],y */
.byte 0x0, /* b8 */ /* CLV */
.byte 0x2, /* b9 */ /* LDA abs,y */
.byte 0x0, /* ba */ /* TSX */
.byte 0x0, /* bb */ /* TYX */
.byte 0x2, /* bc */ /* LDY abs,x */
.byte 0x2, /* bd */ /* LDA Abs,X */
.byte 0x2, /* be */ /* LDX abs,y */
.byte 0x3, /* bf */ /* LDA Long,x */
.byte 0x5, /* c0 */ /* CPY #Imm */
.byte 0x1, /* c1 */ /* CMP (Dloc,X) */
.byte 0x1, /* c2 */ /* REP #8bit */
.byte 0x1, /* c3 */ /* CMP Disp8,S */
.byte 0x1, /* c4 */ /* CPY Dloc */
.byte 0x1, /* c5 */ /* CMP Dloc */
.byte 0x1, /* c6 */ /* DEC Dloc */
.byte 0x1, /* c7 */ /* CMP [Dloc] */
.byte 0x0, /* c8 */ /* INY */
.byte 0x4, /* c9 */ /* CMP #imm */
.byte 0x0, /* ca */ /* DEX */
.byte 0x0, /* cb */ /* WAI */
.byte 0x2, /* cc */ /* CPY abs */
.byte 0x2, /* cd */ /* CMP abs */
.byte 0x2, /* ce */ /* DEC abs */
.byte 0x3, /* cf */ /* CMP long */
.byte 0x1, /* d0 */ /* BNE disp8 */
.byte 0x1, /* d1 */ /* CMP (),y */
.byte 0x1, /* d2 */ /* CMP () */
.byte 0x1, /* d3 */ /* CMP (disp8,s),y */
.byte 0x1, /* d4 */ /* PEI Dloc */
.byte 0x1, /* d5 */ /* CMP Dloc,x */
.byte 0x1, /* d6 */ /* DEC Dloc,x */
.byte 0x1, /* d7 */ /* CMP [],y */
.byte 0x0, /* d8 */ /* CLD */
.byte 0x2, /* d9 */ /* CMP abs,y */
.byte 0x0, /* da */ /* PHX */
.byte 0x0, /* db */ /* STP */
.byte 0x2, /* dc */ /* JML (Abs) */
.byte 0x2, /* dd */ /* CMP Abs,X */
.byte 0x2, /* de */ /* DEC abs,x */
.byte 0x3, /* df */ /* CMP Long,x */
.byte 0x5, /* e0 */ /* CPX #Imm */
.byte 0x1, /* e1 */ /* SBC (Dloc,X) */
.byte 0x1, /* e2 */ /* SEP #8bit */
.byte 0x1, /* e3 */ /* SBC Disp8,S */
.byte 0x1, /* e4 */ /* CPX Dloc */
.byte 0x1, /* e5 */ /* SBC Dloc */
.byte 0x1, /* e6 */ /* INC Dloc */
.byte 0x1, /* e7 */ /* SBC [Dloc] */
.byte 0x0, /* e8 */ /* INX */
.byte 0x4, /* e9 */ /* SBC #imm */
.byte 0x0, /* ea */ /* NOP */
.byte 0x0, /* eb */ /* XBA */
.byte 0x2, /* ec */ /* CPX abs */
.byte 0x2, /* ed */ /* SBC abs */
.byte 0x2, /* ee */ /* INC abs */
.byte 0x3, /* ef */ /* SBC long */
.byte 0x1, /* f0 */ /* BEQ disp8 */
.byte 0x1, /* f1 */ /* SBC (),y */
.byte 0x1, /* f2 */ /* SBC () */
.byte 0x1, /* f3 */ /* SBC (disp8,s),y */
.byte 0x2, /* f4 */ /* PEA Imm */
.byte 0x1, /* f5 */ /* SBC Dloc,x */
.byte 0x1, /* f6 */ /* INC Dloc,x */
.byte 0x1, /* f7 */ /* SBC [],y */
.byte 0x0, /* f8 */ /* SED */
.byte 0x2, /* f9 */ /* SBC abs,y */
.byte 0x0, /* fa */ /* PLX */
.byte 0x0, /* fb */ /* XCE */
.byte 0x2, /* fc */ /* JSR (Abs,x) */
.byte 0x2, /* fd */ /* SBC Abs,X */
.byte 0x2, /* fe */ /* INC abs,x */
.byte 0x3, /* ff */ /* SBC Long,x */
#endif

View File

@ -18,7 +18,7 @@ extern int g_rom_version;
extern int g_io_amt;
extern int g_highest_smartport_unit;
int g_cycs_in_io_read = 0;
word32 g_cycs_in_io_read = 0; // OG Changed int to word32
extern Engine_reg engine;
@ -566,7 +566,7 @@ do_read_c7(int unit_num, word32 buf, int blk)
return 0x27;
}
len = read(fd, &local_buf[0], 0x200);
len = read(fd, (char*)&local_buf[0], 0x200);
if(len != 0x200) {
printf("read returned %08x, errno:%d, blk:%04x, unit: %02x\n",
len, errno, blk, unit_num);

View File

@ -230,6 +230,31 @@ sound_init()
rptr->last_samp_val = 0;
}
// OG sound globals initialization
g_num_c030_fsamps = 0;
g_sound_shm_pos = 0;
g_queued_samps = 0;
g_queued_nonsamps = 0;
doc_sound_ctl = 0;
doc_saved_val = 0;
g_doc_num_osc_en = 1;
g_dcycs_per_doc_update = 1.0;
g_dupd_per_dcyc = 1.0;
g_drecip_osc_en_plus_2 = 1.0 / (double)(1 + 2);
doc_reg_e0 = 0xff;
g_audio_rate = 0;
g_daudio_rate = 0.0;
g_drecip_audio_rate = 0.0;
g_dsamps_per_dcyc = 0.0;
g_dcycs_per_samp = 0.0;
g_fsamps_per_dcyc = 0.0;
g_doc_vol = 2;
g_last_sound_play_dsamp = 0.0;
sound_init_general();
}
@ -287,7 +312,7 @@ sound_init_general()
}
#else
/* windows and mac */
shmaddr = malloc(size);
shmaddr = (word32*)malloc(size);
memset(shmaddr, 0, size);
#endif
@ -346,13 +371,13 @@ sound_init_general()
parent_sound_get_sample_rate(g_pipe2_fd[0]);
#endif
#ifdef MAC
macsnd_init(shmaddr);
macsnd_init(shmaddr);
#endif
#ifdef __ANDROID__
android_snd_init(shmaddr);
#endif
#ifdef _WIN32
win32snd_init(shmaddr);
win32snd_init(shmaddr);
#endif
}
@ -363,7 +388,7 @@ parent_sound_get_sample_rate(int read_fd)
word32 tmp;
int ret;
ret = read(read_fd, &tmp, 4);
ret = read(read_fd, (char*)&tmp, 4);
if(ret != 4) {
printf("parent dying, could not get sample rate from child\n");
printf("ret: %d, fd: %d errno:%d\n", ret, read_fd, errno);
@ -394,7 +419,7 @@ sound_reset(double dcycs)
dsamps = dcycs * g_dsamps_per_dcyc;
for(i = 0; i < 32; i++) {
doc_write_ctl_reg(i, g_doc_regs[i].ctl | 1, dsamps);
doc_reg_e0 = 0xff;
doc_reg_e0 = 0xff; // OG : Don't understand????
if(g_doc_regs[i].has_irq_pending) {
halt_printf("reset: has_irq[%02x] = %d\n", i,
g_doc_regs[i].has_irq_pending);
@ -406,13 +431,19 @@ sound_reset(double dcycs)
}
g_num_osc_interrupting = 0;
// OG No reason to reset the number of active oscillo on reset : this should only be done on startup.
/*
g_doc_num_osc_en = 1;
UPDATE_G_DCYCS_PER_DOC_UPDATE(1);
*/
}
void
sound_shutdown()
{
// OG stop sound and free memory on sound_shutdown
sound_reset(g_cur_dcycs);
#ifdef _WIN32
win32snd_shutdown();
#else
@ -420,6 +451,14 @@ sound_shutdown()
close(g_pipe_fd[1]);
}
#endif
// OG Free up allocated memory
if (g_sound_shm_addr)
{
free(g_sound_shm_addr);
g_sound_shm_addr = NULL;
}
}
@ -814,7 +853,7 @@ sound_play(double dsamps)
if(c030_state) {
/* add in fractional time */
ftmp = (int)(fsampnum + (float)1.0);
ftmp = (float)(int)(fsampnum + 1.0f); //OG added cast
fpercent += (ftmp - fsampnum);
}
@ -1543,7 +1582,10 @@ doc_write_ctl_reg(int osc, int val, double dsamps)
if(old_halt != 0) {
/* start sound */
DOC_LOG("ctl_sound_play", osc, eff_dsamps, val);
sound_play(eff_dsamps);
// OG If the sound_play is executed, it may restart a oscillo we thought was stopped at time,
// hence crashing the start_sound function (cf. game Arrgh!)
//sound_play(eff_dsamps);
g_doc_regs[osc].ctl = val;
start_sound(osc, eff_dsamps, dsamps);
@ -1592,7 +1634,8 @@ doc_recalc_sound_parms(int osc, double eff_dcycs, double dsamps)
res = wave_size & 7;
shifted_size = size << SND_PTR_SHIFT;
cur_start = (rptr->waveptr << (8 + SND_PTR_SHIFT)) & (-shifted_size);
cur_start = (rptr->waveptr << (8 + SND_PTR_SHIFT)) & (-(int)shifted_size); // OG
dtmp1 = dfreq * (DOC_SCAN_RATE * g_drecip_audio_rate);
dacc = (double)(1 << (20 - (17 - sz + res)));
@ -1894,6 +1937,10 @@ doc_write_c03d(int val, double dcycs)
g_doc_num_osc_en = tmp;
UPDATE_G_DCYCS_PER_DOC_UPDATE(tmp);
// OG Update any oscs that were running to take care of the new numbers of oscillo
for(i = 0; i<g_doc_num_osc_en; i++)
doc_recalc_sound_parms(i,0.0,0.0);
/* Stop any oscs that were running but now */
/* are disabled */
for(i = g_doc_num_osc_en; i < 0x20; i++) {

View File

@ -25,8 +25,9 @@ const char rcsid_sound_driver_c[] = "@(#)$KmKId: sound_driver.c,v 1.17 2004-09-2
# include <sys/socket.h>
# include <netinet/in.h>
#endif
#ifndef UNDER_CE
#include <errno.h>
#endif
extern int Verbose;
@ -74,16 +75,16 @@ reliable_buf_write(word32 *shm_addr, int pos, int size)
while(size > 0) {
#ifdef _WIN32
ret = win32_send_audio(ptr, size);
ret = win32_send_audio(ptr, size);
#endif
#ifdef MAC
ret = mac_send_audio(ptr, size);
ret = mac_send_audio(ptr, size);
#endif
#ifdef __ANDROID__
ret = android_send_audio(ptr, size);
ret = android_send_audio(ptr, size);
#endif
#if !defined(_WIN32) && !defined(MAC) && !defined(__ANDROID__)
ret = write(g_audio_socket, ptr, size);
ret = write(g_audio_socket, ptr, size);
#endif
if(ret < 0) {
@ -146,8 +147,8 @@ child_sound_loop(int read_fd, int write_fd, word32 *shm_addr)
return;
#endif
#if defined(__ANDROID__)
child_sound_init_android();
return;
child_sound_init_android();
return;
#endif
tmp = g_audio_rate;
@ -163,7 +164,7 @@ child_sound_loop(int read_fd, int write_fd, word32 *shm_addr)
while(1) {
errno = 0;
ret = read(read_fd, &tmp, 4);
ret = read(read_fd, (char*)&tmp, 4);
if(ret <= 0) {
printf("child dying from ret: %d, errno: %d\n",
ret, errno);

0
jni/to_pro.c Executable file → Normal file
View File

View File

@ -5,6 +5,6 @@ CCOPTS = -O2 -DMAC
SUFFIX =
NAME = kegsmac
XOPTS = -Wall -fpascal-strings -mdynamic-no-pic -arch ppc
XOPTS =
XLIBS =

View File

@ -1,20 +0,0 @@
TARGET = xkegs
OBJECTS = $(OBJECTS1) xdriver.o
CC = gcc
CCOPTS = -O
OPTS = -DNDEBUG
SUFFIX =
NAME = xkegs
LDFLAGS =
LDOPTS = -z
LD = $(CC)
EXTRA_LIBS = -lXext -lX11 -lcl -lc
EXTRA_SPECIALS = Alib.h
AS = cc -Ae
PERL = perl
XOPTS = -DHPUX -I/usr/include/X11R5
XLIBS = -L/usr/lib/X11R5 -L/opt/audio/lib

View File

@ -1,20 +0,0 @@
TARGET = xkegs
OBJECTS = engine_s.o $(OBJECTS1) sound_driver.o xdriver.o
CC = cc -Ae +DA1.1
CCOPTS = -O
OPTS = -DNDEBUG
SUFFIX =
NAME = xkegs
LDFLAGS =
LDOPTS = -z
LD = $(CC)
EXTRA_LIBS = -lXext -lX11 -lcl -lc
EXTRA_SPECIALS = 8inst_s 16inst_s 8size 16size size_s Alib.h
AS = cc -Ae
PERL = perl
XOPTS = -DHPUX -I/usr/include/X11R5
XLIBS = -L/usr/lib/X11R5 -L/opt/audio/lib

View File

@ -1,20 +0,0 @@
TARGET = xkegs
OBJECTS = $(OBJECTS1) xdriver.o
CC = cc
CCOPTS = -O
OPTS = -DNDEBUG
SUFFIX =
NAME = xkegs
LDFLAGS =
LDOPTS =
LD = $(CC)
EXTRA_LIBS = -lXext -lX11 -lc
EXTRA_SPECIALS =
AS = cc
PERL = perl
XOPTS = -I/usr/X11R6/include
XLIBS = -L/usr/X11R6/lib

View File

@ -1,20 +0,0 @@
TARGET = xkegs
OBJECTS = $(OBJECTS1) xdriver.o
CC = cc
CCOPTS = -O
OPTS = -DNDEBUG -DSOLARIS
SUFFIX =
NAME = xkegs
LDFLAGS =
LDOPTS =
LD = $(CC)
EXTRA_LIBS = -lXext -lX11 -lsocket -lnsl
EXTRA_SPECIALS =
AS = cc
PERL = perl
XOPTS = -I/usr/X/include
XLIBS = -L/usr/X/lib

View File

@ -1,10 +0,0 @@
TARGET = kegswin.exe
OBJECTS = $(OBJECTS1) win32snd_driver.o windriver.o
CCOPTS = -O2 -DKEGS_LITTLE_ENDIAN
SUFFIX = ".exe"
NAME = kegswin
XOPTS = -Wall -fomit-frame-pointer -march=pentium
XLIBS =

View File

@ -1,19 +0,0 @@
TARGET = xkegs
OBJECTS = $(OBJECTS1) xdriver.o
CC = cc
CCOPTS = -O2 -Wall -fomit-frame-pointer -march=pentium
OPTS = -DKEGS_LITTLE_ENDIAN
SUFFIX =
NAME = xkegs
LDFLAGS =
LDOPTS =
LD = $(CC)
EXTRA_LIBS = -lXext
EXTRA_SPECIALS =
AS = cc
PERL = perl
XOPTS = -I/usr/X11R6/include

View File

@ -1,20 +0,0 @@
TARGET = xkegs
OBJECTS = $(OBJECTS1) xdriver.o
CC = gcc
CCOPTS = -O
OPTS = -DNDEBUG -DSOLARIS -DKEGS_LITTLE_ENDIAN -DSOLARISSOUND
SUFFIX =
NAME = xkegs
LDFLAGS =
LDOPTS =
LD = $(CC)
EXTRA_LIBS = -lXext -lX11 -lsocket -lnsl
EXTRA_SPECIALS =
AS = cc
PERL = perl
XOPTS = -I/usr/X/include
XLIBS = -L/usr/X/lib

File diff suppressed because it is too large Load Diff

View File

@ -1,109 +0,0 @@
#include <windows.h>
#include "winresource.h"
// $Id: $
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
IDD_DLG_DISKCONF DIALOGEX 0, 0, 268, 182
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Disk Configuration"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,150,161,50,14
PUSHBUTTON "Cancel",IDCANCEL,203,161,50,14
LTEXT "S5D1",IDC_STATIC,19,46,19,8
EDITTEXT IDC_EDIT_S5D1,43,42,156,14,ES_AUTOHSCROLL,
WS_EX_ACCEPTFILES
PUSHBUTTON "Browse",IDC_BTN_S5D1,203,42,50,14
LTEXT "S5D2",IDC_STATIC,19,62,19,8
EDITTEXT IDC_EDIT_S5D2,43,60,155,14,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_BTN_S5D2,203,60,50,14
LTEXT "S6D1",IDC_STATIC,19,80,19,8
EDITTEXT IDC_EDIT_S6D1,43,77,156,14,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_BTN_S6D1,203,77,50,14
LTEXT "S6D2",IDC_STATIC,19,98,19,8
EDITTEXT IDC_EDIT_S6D2,43,95,156,14,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_BTN_S6D2,203,96,50,14
LTEXT "S7D1",IDC_STATIC,19,118,19,8
EDITTEXT IDC_EDIT_S7D1,43,115,155,14,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_BTN_S7D1,203,115,50,14
LTEXT "S7D2",IDC_STATIC,19,137,19,8
EDITTEXT IDC_EDIT_S7D2,43,135,155,14,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_BTN_S7D2,203,135,50,14
GROUPBOX "Disk settings",IDC_STATIC,7,7,254,148
LTEXT "Configure your disk images for each drive. Disk image formats supported\nare *.2MG,*.PO and *.DSK. ",
IDC_STATIC,19,20,234,16
END
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDC_KEGS32 MENU DISCARDABLE
BEGIN
POPUP "&Emulator"
BEGIN
MENUITEM "&Set Disk Configuration\tALT-F1", ID_FILE_DISK
MENUITEM "Send CTRL Open-Apple Reset\tCTRL-ALT-BREAK",
ID_FILE_SENDRESET
MENUITEM "Toggle &Joystick", ID_FILE_JOYSTICK
MENUITEM "Toggle Debug Statistics", ID_FILE_DEBUGSTAT
MENUITEM SEPARATOR
MENUITEM "E&xit\tALT-F4", ID_FILE_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About", ID_HELP_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDR_TOOLBAR BITMAP DISCARDABLE "wintoolbar.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCEL ACCELERATORS DISCARDABLE
BEGIN
VK_F1, ID_FILE_DISK, VIRTKEY, ALT, NOINVERT
VK_F4, ID_FILE_EXIT, VIRTKEY, ALT, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDC_KEGS32 ICON DISCARDABLE "win32.ico"
KEGS32_ICON ICON DISCARDABLE "win32.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUT_DIALOG DIALOG DISCARDABLE 0, 0, 207, 82
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,78,61,50,14
LTEXT "KEGS32: GS Emulator.\nBased on KEGS by Kent Dickey\nWindows Port by Chea Chee Keong\n\nThis software is free for non-commercial use.",
IDC_STATIC,38,7,162,45,NOT WS_GROUP
ICON "KEGS32_ICON",IDC_STATIC,7,7,21,20,0
END

View File

@ -1,215 +1,248 @@
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
const char rcsid_win32snd_driver_c[] = "@(#)$KmKId: win32snd_driver.c,v 1.5 2002-11-19 03:09:59-05 kadickey Exp $";
#include "defc.h"
#include "sound.h"
#ifndef __CYGWIN__
# include <windows.h>
# include <mmsystem.h>
#endif
#include <unistd.h>
extern int Verbose;
extern int g_audio_rate;
unsigned int __stdcall child_sound_loop_win32(void *param);
void check_wave_error(int res, char *str);
#define NUM_WAVE_HEADERS 8
#ifndef __CYGWIN__
HWAVEOUT g_wave_handle;
WAVEHDR g_wavehdr[NUM_WAVE_HEADERS];
#endif
extern int g_audio_enable;
extern word32 *g_sound_shm_addr;
extern int g_preferred_rate;
int g_win32snd_buflen = 0x1000;
void
win32snd_init(word32 *shmaddr)
{
printf("win32snd_init\n");
child_sound_loop(-1, -1, shmaddr);
return;
}
void
win32snd_shutdown()
{
/* hmm */
}
#ifndef __CYGWIN__
void CALLBACK
handle_wav_snd(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, DWORD dwParam1,
DWORD dwParam2)
{
LPWAVEHDR lpwavehdr;
/* Only service "buffer done playing messages */
if(uMsg == WOM_DONE) {
lpwavehdr = (LPWAVEHDR)dwParam1;
if(lpwavehdr->dwFlags == (WHDR_DONE | WHDR_PREPARED)) {
lpwavehdr->dwUser = FALSE;
}
}
return;
}
void
check_wave_error(int res, char *str)
{
char buf[256];
if(res == MMSYSERR_NOERROR) {
return;
}
waveOutGetErrorText(res, &buf[0], sizeof(buf));
printf("%s: %s\n", str, buf);
exit(1);
}
void
child_sound_init_win32()
{
WAVEFORMATEX wavefmt;
WAVEOUTCAPS caps;
byte *bptr;
int bits_per_sample, channels, block_align;
int blen;
int res;
int i;
memset(&wavefmt, 0, sizeof(WAVEFORMATEX));
wavefmt.wFormatTag = WAVE_FORMAT_PCM;
bits_per_sample = 16;
channels = 2;
wavefmt.wBitsPerSample = bits_per_sample;
wavefmt.nChannels = channels;
wavefmt.nSamplesPerSec = g_audio_rate;
block_align = channels * (bits_per_sample / 8);
wavefmt.nBlockAlign = block_align;
wavefmt.nAvgBytesPerSec = block_align * g_audio_rate;
res = waveOutOpen(&g_wave_handle, WAVE_MAPPER, &wavefmt, 0, 0,
WAVE_FORMAT_QUERY);
if(res != MMSYSERR_NOERROR) {
printf("Cannot open audio device\n");
g_audio_enable = 0;
return;
}
res = waveOutOpen(&g_wave_handle, WAVE_MAPPER, &wavefmt,
(DWORD)handle_wav_snd, 0, CALLBACK_FUNCTION | WAVE_ALLOWSYNC);
if(res != MMSYSERR_NOERROR) {
printf("Cannot register audio\n");
g_audio_enable = 0;
return;
}
g_audio_rate = wavefmt.nSamplesPerSec;
blen = (SOUND_SHM_SAMP_SIZE * 4 * 2) / NUM_WAVE_HEADERS;
g_win32snd_buflen = blen;
bptr = malloc(blen * NUM_WAVE_HEADERS);
if(bptr == NULL) {
printf("Unabled to allocate sound buffer\n");
exit(1);
}
for(i = 0; i < NUM_WAVE_HEADERS; i++) {
memset(&g_wavehdr[i], 0, sizeof(WAVEHDR));
g_wavehdr[i].dwUser = FALSE;
g_wavehdr[i].lpData = &(bptr[i*blen]);
g_wavehdr[i].dwBufferLength = blen;
g_wavehdr[i].dwFlags = 0;
g_wavehdr[i].dwLoops = 0;
res = waveOutPrepareHeader(g_wave_handle, &g_wavehdr[i],
sizeof(WAVEHDR));
check_wave_error(res, "waveOutPrepareHeader");
}
res = waveOutGetDevCaps((UINT)g_wave_handle, &caps, sizeof(caps));
check_wave_error(res, "waveOutGetDevCaps");
printf("Using %s\n", caps.szPname);
printf(" Bits per Sample = %d. Channels = %d\n",
wavefmt.wBitsPerSample, wavefmt.nChannels);
printf(" Sampling rate = %d, avg_bytes_per_sec = %d\n",
(int)wavefmt.nSamplesPerSec, (int)wavefmt.nAvgBytesPerSec);
set_audio_rate(g_audio_rate);
}
void
win32_send_audio2(byte *ptr, int size)
{
int found;
int res;
int i;
found = 0;
for(i = 0; i < NUM_WAVE_HEADERS; i++) {
if(g_wavehdr[i].dwUser == FALSE) {
found = 1;
break;
}
}
if(!found) {
/* all audio buffers busy, just get out */
return;
}
memcpy(g_wavehdr[i].lpData, ptr, size);
g_wavehdr[i].dwBufferLength = size;
g_wavehdr[i].dwUser = TRUE;
res = waveOutWrite(g_wave_handle, &g_wavehdr[i], sizeof(g_wavehdr));
check_wave_error(res, "waveOutWrite");
return;
}
int
win32_send_audio(byte *ptr, int in_size)
{
int size;
int tmpsize;
size = in_size;
while(size > 0) {
tmpsize = size;
if(size > g_win32snd_buflen) {
tmpsize = g_win32snd_buflen;
}
win32_send_audio2(ptr, tmpsize);
ptr += tmpsize;
size = size - tmpsize;
}
return in_size;
}
#endif /* __CYGWIN */
/************************************************************************/
/* KEGS: Apple //gs Emulator */
/* Copyright 2002 by Kent Dickey */
/* */
/* This code is covered by the GNU GPL */
/* */
/* The KEGS web page is kegs.sourceforge.net */
/* You may contact the author at: kadickey@alumni.princeton.edu */
/************************************************************************/
const char rcsid_win32snd_driver_c[] = "@(#)$KmKId: win32snd_driver.c,v 1.5 2002-11-19 03:09:59-05 kadickey Exp $";
#include "defc.h"
#include "sound.h"
#ifndef __CYGWIN__
# include <windows.h>
# include <mmsystem.h>
#endif
// OG
//#include <unistd.h>
extern int Verbose;
extern int g_audio_rate;
unsigned int __stdcall child_sound_loop_win32(void *param);
void check_wave_error(int res, char *str);
#define NUM_WAVE_HEADERS 8
#ifndef __CYGWIN__
HWAVEOUT g_wave_handle = NULL; // OG Default value must be set
WAVEHDR g_wavehdr[NUM_WAVE_HEADERS];
#endif
extern int g_audio_enable;
extern word32 *g_sound_shm_addr;
extern int g_preferred_rate;
int g_win32snd_buflen = 0x1000;
void
win32snd_init(word32 *shmaddr)
{
printf("win32snd_init\n");
child_sound_loop(-1, -1, shmaddr);
return;
}
// OG Added global to free the dedicated win32 sound memory
byte *bptr = NULL;
// OG shut win32 sound resources
void
win32snd_shutdown()
{
if (g_wave_handle)
{
MMRESULT res = waveOutReset(g_wave_handle);
if (res!=MMSYSERR_NOERROR )
printf("waveOutReset Failed");
res = waveOutClose(g_wave_handle);
if (res!=MMSYSERR_NOERROR )
printf("waveOutClose Failed");
g_wave_handle=NULL;
}
// OG Free dedicated sound memory
if (bptr)
{
free(bptr);
bptr = NULL;
}
}
#ifndef __CYGWIN__
void CALLBACK
handle_wav_snd(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, DWORD dwParam1,
DWORD dwParam2)
{
LPWAVEHDR lpwavehdr;
/* Only service "buffer done playing messages */
if(uMsg == WOM_DONE) {
lpwavehdr = (LPWAVEHDR)dwParam1;
if(lpwavehdr->dwFlags == (WHDR_DONE | WHDR_PREPARED)) {
lpwavehdr->dwUser = FALSE;
}
}
return;
}
void
check_wave_error(int res, char *str)
{
TCHAR buf[256];
if(res == MMSYSERR_NOERROR) {
return;
}
waveOutGetErrorText(res, &buf[0], sizeof(buf));
printf("%s: %s\n", str, buf);
exit(1);
}
void
child_sound_init_win32()
{
WAVEFORMATEX wavefmt;
WAVEOUTCAPS caps;
// OG Moved as global variable (to rename)
// byte *bptr;
int bits_per_sample, channels, block_align;
int blen;
int res;
int i;
memset(&wavefmt, 0, sizeof(WAVEFORMATEX));
wavefmt.wFormatTag = WAVE_FORMAT_PCM;
#ifndef UNDER_CE
bits_per_sample = 16;
wavefmt.nSamplesPerSec = g_audio_rate;
#else
bits_per_sample = 16;
wavefmt.nSamplesPerSec = 12000;
#endif
channels = 2;
wavefmt.wBitsPerSample = bits_per_sample;
wavefmt.nChannels = channels;
block_align = channels * (bits_per_sample / 8);
wavefmt.nBlockAlign = block_align;
wavefmt.nAvgBytesPerSec = block_align * g_audio_rate;
res = waveOutOpen(&g_wave_handle, WAVE_MAPPER, &wavefmt, 0, 0,
WAVE_FORMAT_QUERY);
if(res != MMSYSERR_NOERROR) {
printf("Cannot open audio device\n");
g_audio_enable = 0;
return;
}
res = waveOutOpen(&g_wave_handle, WAVE_MAPPER, &wavefmt,
(DWORD)handle_wav_snd, 0, CALLBACK_FUNCTION | WAVE_ALLOWSYNC);
if(res != MMSYSERR_NOERROR) {
printf("Cannot register audio\n");
g_audio_enable = 0;
return;
}
g_audio_rate = wavefmt.nSamplesPerSec;
blen = (SOUND_SHM_SAMP_SIZE * 4 * 2) / NUM_WAVE_HEADERS;
g_win32snd_buflen = blen;
bptr = (byte*)malloc(blen * NUM_WAVE_HEADERS); // OG Added cast
if(bptr == NULL) {
printf("Unabled to allocate sound buffer\n");
exit(1);
}
for(i = 0; i < NUM_WAVE_HEADERS; i++) {
memset(&g_wavehdr[i], 0, sizeof(WAVEHDR));
g_wavehdr[i].dwUser = FALSE;
g_wavehdr[i].lpData = (LPSTR)&(bptr[i*blen]); // OG Added cast
g_wavehdr[i].dwBufferLength = blen;
g_wavehdr[i].dwFlags = 0;
g_wavehdr[i].dwLoops = 0;
res = waveOutPrepareHeader(g_wave_handle, &g_wavehdr[i],
sizeof(WAVEHDR));
check_wave_error(res, "waveOutPrepareHeader");
}
res = waveOutGetDevCaps((UINT)g_wave_handle, &caps, sizeof(caps));
check_wave_error(res, "waveOutGetDevCaps");
printf("Using %s\n", caps.szPname);
printf(" Bits per Sample = %d. Channels = %d\n",
wavefmt.wBitsPerSample, wavefmt.nChannels);
printf(" Sampling rate = %d, avg_bytes_per_sec = %d\n",
(int)wavefmt.nSamplesPerSec, (int)wavefmt.nAvgBytesPerSec);
set_audio_rate(g_audio_rate);
}
void
win32_send_audio2(byte *ptr, int size)
{
int found;
int res;
int i;
found = 0;
for(i = 0; i < NUM_WAVE_HEADERS; i++) {
if(g_wavehdr[i].dwUser == FALSE) {
found = 1;
break;
}
}
if(!found) {
/* all audio buffers busy, just get out */
return;
}
memcpy(g_wavehdr[i].lpData, ptr, size);
g_wavehdr[i].dwBufferLength = size;
g_wavehdr[i].dwUser = TRUE;
res = waveOutWrite(g_wave_handle, &g_wavehdr[i], sizeof(g_wavehdr));
check_wave_error(res, "waveOutWrite");
return;
}
int
win32_send_audio(byte *ptr, int in_size)
{
int size;
int tmpsize;
size = in_size;
while(size > 0) {
tmpsize = size;
if(size > g_win32snd_buflen) {
tmpsize = g_win32snd_buflen;
}
win32_send_audio2(ptr, tmpsize);
ptr += tmpsize;
size = size - tmpsize;
}
return in_size;
}
#endif /* __CYGWIN */

162
jni/win_console.c Normal file
View File

@ -0,0 +1,162 @@
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <winsock.h>
//#include <commctrl.h>
#include "defc.h"
#include "protos_windriver.h"
extern void kegsinit(HWND _hwnd);
extern void kegsshut();
extern HWND g_hwnd_main;
extern char *g_status_ptrs[MAX_STATUS_LINES];
int
win_nonblock_read_stdin(int fd, char *bufptr, int len)
{
HANDLE oshandle;
DWORD dwret;
int ret;
errno = EAGAIN;
oshandle = (HANDLE)_get_osfhandle(fd); // get stdin handle
dwret = WaitForSingleObject(oshandle, 1); // wait 1msec for data
ret = -1;
if(dwret == WAIT_OBJECT_0) {
ret = read(fd, bufptr, len);
}
return ret;
}
void
x_dialog_create_kegs_conf(const char *str)
{
}
int
x_show_alert(int is_fatal, const char *str)
{
return 0;
}
int WINAPI WinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
return main(0,0);
}
int
main(int argc, char **argv)
{
// InitCommonControls();
WNDCLASS wndclass;
RECT rect;
int height;
wndclass.style = 0;
wndclass.lpfnWndProc = (WNDPROC)win_event_handler;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = GetModuleHandle(NULL);
wndclass.hIcon = LoadIcon((HINSTANCE)NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // OG Added cast
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "kegswin";
// Register the window
if(!RegisterClass(&wndclass)) {
printf("Registering window failed\n");
exit(1);
}
height = X_A2_WINDOW_HEIGHT + (MAX_STATUS_LINES * 16) + 32;
// g_main_height = height;
HWND hwnd = CreateWindow("kegswin", "KEGSWIN - Apple //gs Emulator",
WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT,
X_A2_WINDOW_WIDTH, height,
NULL, NULL, GetModuleHandle(NULL), NULL);
printf("g_hwnd_main = %p, height = %d\n", hwnd, height);
GetWindowRect(hwnd, &rect);
printf("...rect is: %ld, %ld, %ld, %ld\n", rect.left, rect.top,
rect.right, rect.bottom);
kegsinit(hwnd);
int ret = kegsmain(argc, argv);
UnregisterClass(wndclass.lpszClassName,GetModuleHandle(NULL));
kegsshut();
return ret;
}
void
x_check_input_events()
{
MSG msg;
while(PeekMessage(&msg, g_hwnd_main, 0, 0, PM_NOREMOVE)) {
if(GetMessage(&msg, g_hwnd_main, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
printf("GetMessage returned <= 0\n");
my_exit(2);
}
}
}
void
x_redraw_status_lines()
{
COLORREF oldtextcolor, oldbkcolor;
char *buf;
int line;
int len;
int height;
int margin;
height = 16;
margin = 0;
HDC localdc = GetDC(g_hwnd_main); // OG Use on the fly DC
oldtextcolor = SetTextColor(localdc, 0);
oldbkcolor = SetBkColor(localdc, 0xffffff);
for(line = 0; line < MAX_STATUS_LINES; line++) {
buf = g_status_ptrs[line];
if(buf != 0) {
len = strlen(buf);
TextOut(localdc, 10, X_A2_WINDOW_HEIGHT +
height*line + margin, buf, len);
}
}
SetTextColor(localdc, oldtextcolor);
SetBkColor(localdc, oldbkcolor);
ReleaseDC(g_hwnd_main,localdc);
}
int x_calc_ratio(float& ratiox,float& ratioy)
{
return 0; // not stretched
}

File diff suppressed because it is too large Load Diff