diff -drupN apple2-emul-0.7.4/src/Makefile.am apple2-emul-0.7.4-rpm/src/Makefile.am --- apple2-emul-0.7.4/src/Makefile.am Thu Oct 28 05:19:28 1999 +++ apple2-emul-0.7.4-rpm/src/Makefile.am Thu Oct 12 16:49:44 2000 @@ -1,5 +1,5 @@ noinst_HEADERS = apple2.h debug.h disk.h interface.h keys.h misc.h \ - video.h cpu.h glue.h gluepro.h prefs.h + video.h cpu.h glue.h gluepro.h prefs.h audio.h SUFFIXES = .l-cpp -80.o @@ -11,7 +11,7 @@ bin_PROGRAMS = @PROGS@ EXTRA_apple2_SOURCES = debugger.c opcodes.c debug.c joystick.c apple2_SOURCES = cpu.S memory.S display.S glue.S keys.c prefs.c disk.c \ interface.c misc.c font.c svideo.c compact.c cpu-supp.c \ - vidsup.c + vidsup.c audio.c apple2_LDADD = @DEBUGGER_O@ @JOYSTICK_O@ -lvga apple2_DEPENDENCIES = @DEBUGGER_O@ @JOYSTICK_O@ @@ -20,7 +20,7 @@ EXTRA_xapple2_SOURCES = debugger.c opcod xapple2_SOURCES = cpu.S memory.S display.S glue.S keys.c prefs.c \ disk.c interface.c misc.c font.c xvideo.c compact.c \ - cpu-supp.c vidsup.c + cpu-supp.c vidsup.c audio.c xapple2_LDADD = @DEBUGGER_O@ @JOYSTICK_O@ @X_LIBS@ -lX11 -lXext xapple2_DEPENDENCIES = @DEBUGGER_O@ @JOYSTICK_O@ @@ -28,7 +28,7 @@ xapple2_DEPENDENCIES = @DEBUGGER_O@ @JOY EXTRA_xapple2_80col_SOURCES = debugger.c opcodes.c debug.c joystick.c xapple2_80col_SOURCES = cpu.S memory.S glue.S keys.c prefs.c disk.c \ - font.c compact.c cpu-supp.c misc.c interface.c + font.c compact.c cpu-supp.c misc.c interface.c audio.c xapple2_80col_LDADD = @DEBUGGER_O@ @JOYSTICK_O@ \ vidsup-80.o xvideo-80.o display-80.o \ @@ -49,7 +49,7 @@ CLEANFILES = font.c debug.c glue.S font.c : font.txt genfont ./genfont < $< > $@ -glue.S : disk.c misc.c +glue.S : disk.c misc.c audio.c $(srcdir)/genglue $^ > $@ %-80.o: %.c diff -drupN apple2-emul-0.7.4/src/audio.c apple2-emul-0.7.4-rpm/src/audio.c --- apple2-emul-0.7.4/src/audio.c Wed Dec 31 19:00:00 1969 +++ apple2-emul-0.7.4-rpm/src/audio.c Thu Oct 12 17:04:06 2000 @@ -0,0 +1,238 @@ +/* + * Apple // emulator for Linux: C portion of audio + * + * Copyright 2000 Robert Munafo + * + * This software package is subject to the GNU General Public License + * version 2 or later (your choice) as published by the Free Software + * Foundation. + * + * THERE ARE NO WARRANTIES WHATSOEVER. + * + */ + +#include +#include +#include +#include + +#include "audio.h" +#include "cpu.h" +#include "glue.h" +#include "misc.h" +#include "prefs.h" + +/* New sound output method: try to use /dev/audio. */ +int audio_method; + +/* If /dev/audio method is being used, all the following variables are + * used, otherwise they aren't */ + +/* This is the amount of time (in 10ths of a second) of the maximum desired + * amount of silence. There is a tradeoff here: If you make it really short, + * music programs sound wrong because the gaps (rests) get lost. But if + * you make it really long, then the "maximum speed" setting (F9) doesn't + * provide as much speed, because you can only run at maximum speed when + * sound is not being played. I have found after a fair amount of fiddling + * with the setting that the best setting seems to be about 1/2 second. */ +#define MAX_SILENCE_TIME 5L + +#define AUDIO_FREQ_ASK 48000 +long audio_freq; +#define CLOCK_SPEED_6502 1000000L +long audio_incr; +long audio_max_silence; +long audio_flushrate; +#define AUDIO_PULSEBUF 512 +int audio_fd; +long last_audio_cycles; + +char speaker_hi[AUDIO_PULSEBUF+2]; +char speaker_lo[AUDIO_PULSEBUF+2]; +int spkr_state; +long audio_toflush; + +/* This routine is CALLED FROM ASSEMBLY in response to read or write + * accesses to $C030-$C03F, but only if /dev/audio sound output method was + * set at startup. */ +GLUE_C_READ(read_speaker_dev_audio) +{ + long ctr; + long first2; + int len; + char *buf; + + /* Find out how many clock cycles have gone by since the last time + * the speaker was toggled */ + ctr = cpu65_cycles - last_audio_cycles; + /* Convert to our sampling rate */ + ctr /= audio_incr; + + /* Range check, and update last_audio_cycles. Fractions of a sample + * will automatically be counted towards the next sample; this + * ensures the accuracy of pitch for sustained notes. */ + + /* Don't output blocks of silence longer than audio_max_silence */ + if ((ctr > audio_max_silence) || (ctr < -1)) { + /* There was a long delay. Just catch up. */ + ctr = audio_max_silence; + last_audio_cycles = cpu65_cycles - (ctr * audio_incr); + /* because there has been a long delay, the last speaker transition + * hasn't been heard yet. That means we would get a "click" + * at the beginning of the max_silence we're about to write out. + * We avoid this click by toggling the state before doing the write. */ + spkr_state = spkr_state ? 0 : 1; + } else if (ctr < 1) { + /* This is to make sure the following actually generates a sound: + * loop1 lea $C030 ; toggle speaker + * nop + * lea $C030 ; toggle speaker again + * dex + * bcc loop1 + * However, we don't do this if the audio output is already more + * than one full sample ahead of the 6502 -- otherwise, (particularly + * when the /dev/audio sampling rate is very low, we'd get a + * continuous high-pitched tone, which would almost certainly be of + * the wrong frequency. */ + if (ctr == 0) { + ctr = 1; + } + } + + /* Okay, now write the audio bytes corresponding to the amount + * of time that has elapsed */ + + buf = spkr_state ? speaker_hi : speaker_lo; + +#ifdef LAME_O + /* The first two samples after a toggle are special */ + first2 = ctr; + if (first2 > 2) { + first2 = 2; + } + last_audio_cycles += (first2 * audio_incr); + len = first2; + write(audio_fd, buf+AUDIO_PULSEBUF, len); + ctr -= first2; +#endif + + /* Output solid blocks of PULSEBUF size until we're down to less + * then one PULSEBUF */ + while (ctr > AUDIO_PULSEBUF) { + last_audio_cycles += (AUDIO_PULSEBUF * audio_incr); + ctr -= AUDIO_PULSEBUF; + len = AUDIO_PULSEBUF; + write(audio_fd, buf, len); + } + + /* Now output the last bit */ + if (ctr) { + len = ctr; + write(audio_fd, buf, len); + last_audio_cycles += (ctr * audio_incr); + } + + /* See if it's time to flush (synchronize) the audio output */ + audio_toflush += ctr; + if (audio_toflush > audio_flushrate) { + /* ioctl(audio_fd, I_FLUSH); */ + audio_toflush = 0; + } + + /* Now actually toggle the speaker state */ + spkr_state = spkr_state ? 0 : 1; +} + +/* ------------------------------------------------------------------------- + void c_initialize_sound() + ------------------------------------------------------------------------- */ + +void sound_init() +{ + int freq, result; + int i; + + audio_method = 0; + + printf("sound_mode %i\n", sound_mode); + + /* If sound mode is 3(autodetect) or 2 (/dev/audio) we'll try to open /dev/audio */ + if ((sound_mode == 2) || (sound_mode == 3)) { + audio_fd = open("/dev/audio", O_WRONLY, 0); + if (audio_fd == -1) { + /* It failed */ + perror("/dev/audio"); + } else { + /* success */ + audio_method = 2; + + /* Now set up all our variables, etc. */ + + /* First, try to set audio speed. If unsuccessful, we use the standard /dev/audio + * speed which is 8000 Hz (Sun workstations, Sparc, SunOS, Solaris) because almost + * all other /dev/audio implementations emulate the Sun */ + freq = AUDIO_FREQ_ASK; + result = ioctl(audio_fd, SNDCTL_DSP_SPEED, &freq); + if (result == -1) { + perror("SNDCTL_DSP_SPEED"); + audio_freq = 8000L; + } else { + printf("Got speed %i\n", freq); + audio_freq = freq; + } + audio_max_silence = (MAX_SILENCE_TIME * audio_freq) / 10L; + audio_flushrate = audio_freq / 50; + audio_incr = CLOCK_SPEED_6502 / audio_freq; + + /* Set up our buffer used to write to the speaker. */ + for(i=0; i M */ + /* Also called AXS */ #define DoAAX movb A_Reg, %al; \ andb X_Reg, %al; \ FlagNZ \ @@ -629,6 +633,11 @@ 6502 routines and instructions ---------------------------------------------------------------------- */ + /* NOTE: The insturction timings are not perfect. It accounts for + the extra cycle for branches taken, but does not yet account + for the extra cycle for indirect indexing across a page + boundary (anyone want to fix this?) - RPM 20001007 */ + /* ---------------------------------- ADC instructions ---------------------------------- */ @@ -637,6 +646,7 @@ op_ADC_dec: DoADC_d Continue op_ADC_imm: + Cycles($2) GetImm testb $D_Flag, F_Reg # Decimal mode? jnz op_ADC_dec # Yes, jump to decimal version @@ -644,6 +654,7 @@ op_ADC_imm: Continue op_ADC_zpage: + Cycles($3) GetZPage testb $D_Flag, F_Reg # Decimal mode? jnz op_ADC_dec # Yes, jump to decimal version @@ -651,6 +662,7 @@ op_ADC_zpage: Continue op_ADC_zpage_x: + Cycles($4) GetZPage_X testb $D_Flag, F_Reg # Decimal mode? jnz op_ADC_dec # Yes, jump to decimal version @@ -658,6 +670,7 @@ op_ADC_zpage_x: Continue op_ADC_abs: + Cycles($4) GetAbs testb $D_Flag, F_Reg # Decimal mode? jnz op_ADC_dec # Yes, jump to decimal version @@ -665,6 +678,7 @@ op_ADC_abs: Continue op_ADC_abs_x: + Cycles($4) GetAbs_X testb $D_Flag, F_Reg # Decimal mode? jnz op_ADC_dec # Yes, jump to decimal version @@ -672,6 +686,7 @@ op_ADC_abs_x: Continue op_ADC_abs_y: + Cycles($4) GetAbs_Y testb $D_Flag, F_Reg # Decimal mode? jnz op_ADC_dec # Yes, jump to decimal version @@ -679,6 +694,7 @@ op_ADC_abs_y: Continue op_ADC_ind_x: + Cycles($6) GetIndZPage_X testb $D_Flag, F_Reg # Decimal mode? jnz op_ADC_dec # Yes, jump to decimal version @@ -686,6 +702,7 @@ op_ADC_ind_x: Continue op_ADC_ind_y: + Cycles($5) GetIndZPage_Y testb $D_Flag, F_Reg # Decimal mode? jnz op_ADC_dec # Yes, jump to decimal version @@ -697,41 +714,49 @@ op_ADC_ind_y: ---------------------------------- */ op_AND_imm: + Cycles($2) GetImm DoAND Continue op_AND_zpage: + Cycles($3) GetZPage DoAND Continue op_AND_zpage_x: + Cycles($4) GetZPage_X DoAND Continue op_AND_abs: + Cycles($4) GetAbs DoAND Continue op_AND_abs_x: + Cycles($4) GetAbs_X DoAND Continue op_AND_abs_y: + Cycles($4) GetAbs_Y DoAND Continue op_AND_ind_x: + Cycles($6) GetIndZPage_X DoAND Continue op_AND_ind_y: + Cycles($5) GetIndZPage_Y DoAND Continue @@ -741,26 +766,31 @@ op_AND_ind_y: ---------------------------------- */ op_ASL_acc: + Cycles($2) addb A_Reg, A_Reg FlagNZC Continue op_ASL_zpage: + Cycles($5) GetZPage DoASL Continue op_ASL_zpage_x: + Cycles($6) GetZPage_X DoASL Continue op_ASL_abs: + Cycles($6) GetAbs DoASL Continue op_ASL_abs_x: + Cycles($7) GetAbs_X DoASL Continue @@ -770,11 +800,13 @@ op_ASL_abs_x: ---------------------------------- */ op_BCC: + Cycles($2) GetFromPC_B testb $C_Flag, F_Reg jnz op_BCC_not cbw addw %ax, PC_Reg + Cycles($1) op_BCC_not: Continue @@ -783,11 +815,13 @@ op_BCC_not: ---------------------------------- */ op_BCS: + Cycles($2) GetFromPC_B testb $C_Flag, F_Reg jz op_BCS_not cbw addw %ax, PC_Reg + Cycles($1) op_BCS_not: Continue @@ -796,11 +830,13 @@ op_BCS_not: ---------------------------------- */ op_BEQ: + Cycles($2) GetFromPC_B testb $Z_Flag, F_Reg jz op_BEQ_not cbw addw %ax, PC_Reg + Cycles($1) op_BEQ_not: Continue @@ -809,11 +845,13 @@ op_BEQ_not: ---------------------------------- */ op_BIT_zpage: + Cycles($3) GetZPage DoBIT Continue op_BIT_abs: + Cycles($4) GetAbs DoBIT Continue @@ -823,12 +861,14 @@ op_BIT_abs: ---------------------------------- */ op_BMI: + Cycles($2) GetFromPC_B testb F_Reg, F_Reg /* optimized check of N flag, * which happens to be sign bit */ jns op_BMI_not cbw addw %ax, PC_Reg + Cycles($1) op_BMI_not: Continue @@ -837,11 +877,13 @@ op_BMI_not: ---------------------------------- */ op_BNE: + Cycles($2) GetFromPC_B testb $Z_Flag, F_Reg jnz op_BNE_not cbw addw %ax, PC_Reg + Cycles($1) op_BNE_not: Continue @@ -850,12 +892,14 @@ op_BNE_not: ---------------------------------- */ op_BPL: + Cycles($2) GetFromPC_B testb F_Reg, F_Reg /* optimized check of N flag, * which happens to be sign bit */ js op_BPL_not cbw addw %ax, PC_Reg + Cycles($1) op_BPL_not: Continue @@ -865,6 +909,7 @@ op_BPL_not: op_UNK: /* make undefined opcodes fault */ op_BRK: + Cycles($7) incw PC_Reg movw PC_Reg, %ax Push(%ah) @@ -884,11 +929,13 @@ op_BRK: ---------------------------------- */ op_BVC: + Cycles($2) GetFromPC_B testb $V_Flag, F_Reg jnz op_BVC_not cbw addw %ax, PC_Reg + Cycles($1) op_BVC_not: Continue @@ -897,11 +944,13 @@ op_BVC_not: ---------------------------------- */ op_BVS: + Cycles($2) GetFromPC_B testb $V_Flag, F_Reg jz op_BVS_not cbw addw %ax, PC_Reg + Cycles($1) op_BVS_not: Continue @@ -910,6 +959,7 @@ op_BVS_not: ---------------------------------- */ op_CLC: + Cycles($2) andb $~C_Flag, F_Reg Continue @@ -918,6 +968,7 @@ op_CLC: ---------------------------------- */ op_CLD: + Cycles($2) andb $~D_Flag, F_Reg Continue @@ -926,6 +977,7 @@ op_CLD: ---------------------------------- */ op_CLI: + Cycles($2) andb $~I_Flag, F_Reg Continue @@ -934,6 +986,7 @@ op_CLI: ---------------------------------- */ op_CLV: + Cycles($2) andb $~V_Flag, F_Reg Continue @@ -942,41 +995,49 @@ op_CLV: ---------------------------------- */ op_CMP_imm: + Cycles($2) GetImm DoCMP Continue op_CMP_zpage: + Cycles($3) GetZPage DoCMP Continue op_CMP_zpage_x: + Cycles($4) GetZPage_X DoCMP Continue op_CMP_abs: + Cycles($4) GetAbs DoCMP Continue op_CMP_abs_x: + Cycles($4) GetAbs_X DoCMP Continue op_CMP_abs_y: + Cycles($4) GetAbs_Y DoCMP Continue op_CMP_ind_x: + Cycles($6) GetIndZPage_X DoCMP Continue op_CMP_ind_y: + Cycles($5) GetIndZPage_Y DoCMP Continue @@ -986,16 +1047,19 @@ op_CMP_ind_y: ---------------------------------- */ op_CPX_imm: + Cycles($2) GetImm DoCPX Continue op_CPX_zpage: + Cycles($3) GetZPage DoCPX Continue op_CPX_abs: + Cycles($4) GetAbs DoCPX Continue @@ -1005,16 +1069,19 @@ op_CPX_abs: ---------------------------------- */ op_CPY_imm: + Cycles($2) GetImm DoCPY Continue op_CPY_zpage: + Cycles($3) GetZPage DoCPY Continue op_CPY_abs: + Cycles($4) GetAbs DoCPY Continue @@ -1024,21 +1091,25 @@ op_CPY_abs: ---------------------------------- */ op_DEC_zpage: + Cycles($5) GetZPage DoDEC Continue op_DEC_zpage_x: + Cycles($6) GetZPage_X DoDEC Continue op_DEC_abs: + Cycles($6) GetAbs DoDEC Continue op_DEC_abs_x: + Cycles($7) GetAbs_X DoDEC Continue @@ -1048,6 +1119,7 @@ op_DEC_abs_x: ---------------------------------- */ op_DEX: + Cycles($2) decb X_Reg FlagNZ Continue @@ -1057,6 +1129,7 @@ op_DEX: ---------------------------------- */ op_DEY: + Cycles($2) decb Y_Reg FlagNZ Continue @@ -1066,41 +1139,49 @@ op_DEY: ---------------------------------- */ op_EOR_imm: + Cycles($2) GetImm DoEOR Continue op_EOR_zpage: + Cycles($3) GetZPage DoEOR Continue op_EOR_zpage_x: + Cycles($4) GetZPage_X DoEOR Continue op_EOR_abs: + Cycles($4) GetAbs DoEOR Continue op_EOR_abs_x: + Cycles($4) GetAbs_X DoEOR Continue op_EOR_abs_y: + Cycles($4) GetAbs_Y DoEOR Continue op_EOR_ind_x: + Cycles($6) GetIndZPage_X DoEOR Continue op_EOR_ind_y: + Cycles($5) GetIndZPage_Y DoEOR Continue @@ -1110,21 +1191,25 @@ op_EOR_ind_y: ---------------------------------- */ op_INC_zpage: + Cycles($5) GetZPage DoINC Continue op_INC_zpage_x: + Cycles($6) GetZPage_X DoINC Continue op_INC_abs: + Cycles($6) GetAbs DoINC Continue op_INC_abs_x: + Cycles($7) GetAbs_X DoINC Continue @@ -1134,6 +1219,7 @@ op_INC_abs_x: ---------------------------------- */ op_INX: + Cycles($2) incb X_Reg FlagNZ Continue @@ -1143,6 +1229,7 @@ op_INX: ---------------------------------- */ op_INY: + Cycles($2) incb Y_Reg FlagNZ Continue @@ -1152,11 +1239,13 @@ op_INY: ---------------------------------- */ op_JMP_abs: + Cycles($3) GetAbs DoJMP Continue op_JMP_ind: + Cycles($5) xorl %eax, %eax GetFromMem_B(PC_Reg_E) xchgb %al, %ah @@ -1182,6 +1271,7 @@ special_case: /*?*/ ---------------------------------- */ op_JSR: + Cycles($6) GetAbs DoJSR Continue @@ -1191,41 +1281,49 @@ op_JSR: ---------------------------------- */ op_LDA_imm: + Cycles($2) GetImm DoLDA Continue op_LDA_zpage: + Cycles($3) GetZPage DoLDA Continue op_LDA_zpage_x: + Cycles($4) GetZPage_X DoLDA Continue op_LDA_abs: + Cycles($4) GetAbs DoLDA Continue op_LDA_abs_x: + Cycles($4) GetAbs_X DoLDA Continue op_LDA_abs_y: + Cycles($4) GetAbs_Y DoLDA Continue op_LDA_ind_x: + Cycles($6) GetIndZPage_X DoLDA Continue op_LDA_ind_y: + Cycles($5) GetIndZPage_Y DoLDA Continue @@ -1235,26 +1333,31 @@ op_LDA_ind_y: ---------------------------------- */ op_LDX_imm: + Cycles($2) GetImm DoLDX Continue op_LDX_zpage: + Cycles($3) GetZPage DoLDX Continue op_LDX_zpage_y: + Cycles($4) GetZPage_Y DoLDX Continue op_LDX_abs: + Cycles($4) GetAbs DoLDX Continue op_LDX_abs_y: + Cycles($4) GetAbs_Y DoLDX Continue @@ -1264,26 +1367,31 @@ op_LDX_abs_y: ---------------------------------- */ op_LDY_imm: + Cycles($2) GetImm DoLDY Continue op_LDY_zpage: + Cycles($3) GetZPage DoLDY Continue op_LDY_zpage_x: + Cycles($4) GetZPage_X DoLDY Continue op_LDY_abs: + Cycles($4) GetAbs DoLDY Continue op_LDY_abs_x: + Cycles($4) GetAbs_X DoLDY Continue @@ -1293,26 +1401,31 @@ op_LDY_abs_x: ---------------------------------- */ op_LSR_acc: + Cycles($2) shrb $1, A_Reg FlagNZC Continue op_LSR_zpage: + Cycles($5) GetZPage DoLSR Continue op_LSR_zpage_x: + Cycles($6) GetZPage_X DoLSR Continue op_LSR_abs: + Cycles($6) GetAbs DoLSR Continue op_LSR_abs_x: + Cycles($7) GetAbs_X DoLSR Continue @@ -1322,6 +1435,7 @@ op_LSR_abs_x: ---------------------------------- */ op_NOP: + Cycles($2) Continue /* ---------------------------------- @@ -1329,41 +1443,49 @@ op_NOP: ---------------------------------- */ op_ORA_imm: + Cycles($2) GetImm DoORA Continue op_ORA_zpage: + Cycles($3) GetZPage DoORA Continue op_ORA_zpage_x: + Cycles($4) GetZPage_X DoORA Continue op_ORA_abs: + Cycles($4) GetAbs DoORA Continue op_ORA_abs_x: + Cycles($4) GetAbs_X DoORA Continue op_ORA_abs_y: + Cycles($4) GetAbs_Y DoORA Continue op_ORA_ind_x: + Cycles($6) GetIndZPage_X DoORA Continue op_ORA_ind_y: + Cycles($5) GetIndZPage_Y DoORA Continue @@ -1373,6 +1495,7 @@ op_ORA_ind_y: ---------------------------------- */ op_PHA: + Cycles($3) Push(A_Reg) Continue @@ -1381,6 +1504,7 @@ op_PHA: ---------------------------------- */ op_PHP: + Cycles($3) movb F_Reg, %al movb SN(cpu65_flags_encode)(,%eax,1), %al Push(%al) @@ -1391,6 +1515,7 @@ op_PHP: ---------------------------------- */ op_PLA: + Cycles($4) Pop(A_Reg) orb A_Reg, A_Reg FlagNZ @@ -1401,6 +1526,7 @@ op_PLA: ---------------------------------- */ op_PLP: + Cycles($4) xorl %eax, %eax Pop(%al) movb SN(cpu65_flags_decode)(,%eax,1), F_Reg @@ -1411,27 +1537,33 @@ op_PLP: ROL instructions ---------------------------------- */ -op_ROL_acc: bt $C_Flag_Bit, FF_Reg +op_ROL_acc: + Cycles($2) + bt $C_Flag_Bit, FF_Reg adcb A_Reg, A_Reg FlagNZC Continue op_ROL_zpage: + Cycles($5) GetZPage DoROL Continue op_ROL_zpage_x: + Cycles($6) GetZPage_X DoROL Continue op_ROL_abs: + Cycles($6) GetAbs DoROL Continue op_ROL_abs_x: + Cycles($7) GetAbs_X DoROL Continue @@ -1441,6 +1573,7 @@ op_ROL_abs_x: ---------------------------------- */ /* NB: assumes A_Reg = %cl, F_Reg = %ch */ op_ROR_acc: + Cycles($2) rorw $1, %cx /* Roll flags into accum */ adcb F_Reg, F_Reg /* Roll carry into flags */ orb A_Reg, A_Reg @@ -1448,21 +1581,25 @@ op_ROR_acc: Continue op_ROR_zpage: + Cycles($5) GetZPage DoROR Continue op_ROR_zpage_x: + Cycles($6) GetZPage_X DoROR Continue op_ROR_abs: + Cycles($6) GetAbs DoROR Continue op_ROR_abs_x: + Cycles($7) GetAbs_X DoROR Continue @@ -1472,6 +1609,7 @@ op_ROR_abs_x: ---------------------------------- */ op_RTI: + Cycles($6) xorl %eax, %eax Pop(%al) movb SN(cpu65_flags_decode)(,%eax,1), F_Reg @@ -1486,6 +1624,7 @@ op_RTI: ---------------------------------- */ op_RTS: + Cycles($6) Pop(%al) Pop(%ah) incw %ax @@ -1501,6 +1640,7 @@ op_SBC_dec: Continue op_SBC_imm: + Cycles($2) GetImm testb $D_Flag, F_Reg # Decimal mode? jnz op_SBC_dec # Yes, jump to decimal version @@ -1508,6 +1648,7 @@ op_SBC_imm: Continue op_SBC_zpage: + Cycles($3) GetZPage testb $D_Flag, F_Reg # Decimal mode? jnz op_SBC_dec # Yes, jump to decimal version @@ -1515,6 +1656,7 @@ op_SBC_zpage: Continue op_SBC_zpage_x: + Cycles($4) GetZPage_X testb $D_Flag, F_Reg # Decimal mode? jnz op_SBC_dec # Yes, jump to decimal version @@ -1522,6 +1664,7 @@ op_SBC_zpage_x: Continue op_SBC_abs: + Cycles($4) GetAbs testb $D_Flag, F_Reg # Decimal mode? jnz op_SBC_dec # Yes, jump to decimal version @@ -1529,6 +1672,7 @@ op_SBC_abs: Continue op_SBC_abs_x: + Cycles($4) GetAbs_X testb $D_Flag, F_Reg # Decimal mode? jnz op_SBC_dec # Yes, jump to decimal version @@ -1536,6 +1680,7 @@ op_SBC_abs_x: Continue op_SBC_abs_y: + Cycles($4) GetAbs_Y testb $D_Flag, F_Reg # Decimal mode? jnz op_SBC_dec # Yes, jump to decimal version @@ -1543,6 +1688,7 @@ op_SBC_abs_y: Continue op_SBC_ind_x: + Cycles($6) GetIndZPage_X testb $D_Flag, F_Reg # Decimal mode? jnz op_SBC_dec # Yes, jump to decimal version @@ -1550,6 +1696,7 @@ op_SBC_ind_x: Continue op_SBC_ind_y: + Cycles($5) GetIndZPage_Y testb $D_Flag, F_Reg # Decimal mode? jnz op_SBC_dec # Yes, jump to decimal version @@ -1561,6 +1708,7 @@ op_SBC_ind_y: ---------------------------------- */ op_SEC: + Cycles($2) orb $C_Flag, F_Reg Continue @@ -1569,6 +1717,7 @@ op_SEC: ---------------------------------- */ op_SED: + Cycles($2) orb $D_Flag, F_Reg Continue @@ -1577,6 +1726,7 @@ op_SED: ---------------------------------- */ op_SEI: + Cycles($2) orb $I_Flag, F_Reg Continue @@ -1584,42 +1734,49 @@ op_SEI: STA instructions ---------------------------------- */ -op_STA_imm: +op_STA_imm: /* A nonexistent instruction. Why is this here? -RPM */ GetImm DoSTA Continue op_STA_zpage: + Cycles($3) GetZPage DoSTA Continue op_STA_zpage_x: + Cycles($4) GetZPage_X DoSTA Continue op_STA_abs: + Cycles($4) GetAbs DoSTA Continue op_STA_abs_x: + Cycles($5) GetAbs_X DoSTA Continue op_STA_abs_y: + Cycles($5) GetAbs_Y DoSTA Continue op_STA_ind_x: + Cycles($6) GetIndZPage_X DoSTA Continue op_STA_ind_y: + Cycles($6) GetIndZPage_Y DoSTA Continue @@ -1629,16 +1786,19 @@ op_STA_ind_y: ---------------------------------- */ op_STX_zpage: + Cycles($3) GetZPage DoSTX Continue op_STX_zpage_y: + Cycles($4) GetZPage_Y DoSTX Continue op_STX_abs: + Cycles($4) GetAbs DoSTX Continue @@ -1648,16 +1808,19 @@ op_STX_abs: ---------------------------------- */ op_STY_zpage: + Cycles($3) GetZPage DoSTY Continue op_STY_zpage_x: + Cycles($4) GetZPage_X DoSTY Continue op_STY_abs: + Cycles($4) GetAbs DoSTY Continue @@ -1667,6 +1830,7 @@ op_STY_abs: ---------------------------------- */ op_TAX: + Cycles($2) movb A_Reg, X_Reg orb X_Reg, X_Reg FlagNZ @@ -1677,6 +1841,7 @@ op_TAX: ---------------------------------- */ op_TAY: + Cycles($2) movb A_Reg, Y_Reg orb Y_Reg, Y_Reg FlagNZ @@ -1687,6 +1852,7 @@ op_TAY: ---------------------------------- */ op_TSX: + Cycles($2) movb SP_Reg_L, X_Reg orb X_Reg, X_Reg FlagNZ @@ -1697,6 +1863,7 @@ op_TSX: ---------------------------------- */ op_TXA: + Cycles($2) movb X_Reg, A_Reg orb A_Reg, A_Reg FlagNZ @@ -1707,6 +1874,7 @@ op_TXA: ---------------------------------- */ op_TXS: + Cycles($2) movb X_Reg, SP_Reg_L Continue @@ -1715,6 +1883,7 @@ op_TXS: ---------------------------------- */ op_TYA: + Cycles($2) movb Y_Reg, A_Reg orb A_Reg, A_Reg FlagNZ @@ -1734,6 +1903,7 @@ op_TYA: ---------------------------------- */ op_ADC_ind_zpage: # 72 + Cycles($6) GetIndZPage testb $D_Flag, F_Reg # Decimal mode? jnz op_ADC_dec # Yes, jump to decimal version @@ -1748,6 +1918,7 @@ op_ADC_ind_zpage_dec: ---------------------------------- */ op_AND_ind_zpage: # 32 + Cycles($6) GetIndZPage DoAND Continue @@ -1757,11 +1928,13 @@ op_AND_ind_zpage: # 32 ---------------------------------- */ op_BIT_zpage_x: # 34 + Cycles($4) GetIndZPage DoBIT Continue op_BIT_abs_x: # 3C + Cycles($4) GetAbs_X DoBIT Continue @@ -1770,6 +1943,7 @@ op_BIT_abs_x: # 3C * N and V flags, unlike in other addressing modes. */ op_BIT_imm: # 89 + Cycles($2) GetImm GetFromEA_Bh testb %al, A_Reg @@ -1781,6 +1955,7 @@ op_BIT_imm: # 89 ---------------------------------- */ op_BRA: # 80 + Cycles($3) GetFromPC_B cbw addw %ax, PC_Reg @@ -1791,6 +1966,7 @@ op_BRA: # 80 ---------------------------------- */ op_CMP_ind_zpage: # D2 + Cycles($5) GetIndZPage DoCMP Continue @@ -1800,6 +1976,7 @@ op_CMP_ind_zpage: # D2 ---------------------------------- */ op_DEA: # 3A + Cycles($2) decb A_Reg FlagNZ Continue @@ -1809,6 +1986,7 @@ op_DEA: # 3A ---------------------------------- */ op_EOR_ind_zpage: # 52 + Cycles($5) GetIndZPage DoEOR Continue @@ -1818,6 +1996,7 @@ op_EOR_ind_zpage: # 52 ---------------------------------- */ op_INA: # 1A + Cycles($2) incb A_Reg FlagNZ Continue @@ -1827,6 +2006,7 @@ op_INA: # 1A ---------------------------------- */ op_JMP_ind_65c02: # 6C - different from 6502 + Cycles($5) xorl %eax, %eax GetFromMem_B(PC_Reg_E) xchgb %al, %ah @@ -1838,6 +2018,7 @@ op_JMP_ind_65c02: # 6C - different from Continue op_JMP_abs_ind_x: # 7C + Cycles($6) GetFromPC_W movw %ax, EffectiveAddr movzbl X_Reg, %eax @@ -1851,6 +2032,7 @@ op_JMP_abs_ind_x: # 7C ---------------------------------- */ op_LDA_ind_zpage: # B2 + Cycles($5) GetIndZPage DoLDA Continue @@ -1860,6 +2042,7 @@ op_LDA_ind_zpage: # B2 ---------------------------------- */ op_ORA_ind_zpage: # 12 + Cycles($5) GetIndZPage DoORA Continue @@ -1869,6 +2052,7 @@ op_ORA_ind_zpage: # 12 ---------------------------------- */ op_PHX: # DA + Cycles($3) Push(X_Reg) Continue @@ -1877,6 +2061,7 @@ op_PHX: # DA ---------------------------------- */ op_PHY: # 5A + Cycles($3) Push(Y_Reg) Continue @@ -1885,6 +2070,7 @@ op_PHY: # 5A ---------------------------------- */ op_PLX: # FA + Cycles($4) Pop(X_Reg) orb X_Reg, X_Reg FlagNZ @@ -1895,6 +2081,7 @@ op_PLX: # FA ---------------------------------- */ op_PLY: # 7A + Cycles($4) Pop(Y_Reg) orb Y_Reg, Y_Reg FlagNZ @@ -1905,6 +2092,7 @@ op_PLY: # 7A ---------------------------------- */ op_STA_ind_zpage: # 92 + Cycles($5) GetIndZPage DoSTA Continue @@ -1914,6 +2102,7 @@ op_STA_ind_zpage: # 92 ---------------------------------- */ op_SBC_ind_zpage: # F2 + Cycles($5) GetIndZPage testb $D_Flag, F_Reg # Decimal mode? jnz op_SBC_dec # Yes, jump to decimal version @@ -1928,20 +2117,24 @@ op_SBC_ind_zpage_dec: ---------------------------------- */ op_STZ_zpage: # 64 + Cycles($3) GetZPage DoSTZ Continue op_STZ_zpage_x: # 74 + Cycles($4) GetZPage_X Continue op_STZ_abs: # 9C + Cycles($4) GetAbs DoSTZ Continue op_STZ_abs_x: # 9E + Cycles($5) GetAbs_X DoSTZ Continue @@ -1951,11 +2144,13 @@ op_STZ_abs_x: # 9E ---------------------------------- */ op_TRB_abs: # 1C + Cycles($6) GetAbs DoTRB Continue op_TRB_zpage: # 14 + Cycles($5) GetZPage DoTRB Continue @@ -1965,11 +2160,13 @@ op_TRB_zpage: # 14 ---------------------------------- */ op_TSB_abs: # 0C + Cycles($6) GetAbs DoTSB Continue op_TSB_zpage: # 04 + Cycles($5) GetZPage DoTSB Continue @@ -1979,6 +2176,7 @@ op_TSB_zpage: # 04 ??? instruction - 65c02 ---------------------------------- */ op_UNK_65c02: + Cycles($4) Continue #endif /* APPLE_IIE */ @@ -1991,7 +2189,11 @@ op_UNK_65c02: HANG instruction ---------------------------------- */ + /* This is implemented as an infinite loop by decrementing the + * program counter, so that reset will work (as it should). The + * timing of 2 cycles is arbitrary. */ op_HANG: + Cycles($2) decw PC_Reg Continue @@ -2000,6 +2202,7 @@ op_HANG: ---------------------------------- */ op_NOP_2: + Cycles($3) /* %%% Actually takes 2 3 or 4 */ incw PC_Reg Continue @@ -2007,62 +2210,87 @@ op_NOP_2: NOP_3 instruction ---------------------------------- */ + /* The opcodes 0C, 1C, 3C, 5C, 7C, DC and FC actually read + a byte from the address given by the two bytes being skipped + but that byte is not stored anywhere. 0C is absolute, + the rest are absolute indexed XX */ op_NOP_3: + Cycles($4) addw $2, PC_Reg Continue +op_SKW_abs: + Cycles($4) + GetAbs + GetFromEA_Bh + Continue + +op_SKW_abs_x: + Cycles($4) + GetAbs_X + GetFromEA_Bh + Continue + /* ---------------------------------- - AAX instructions + AAX instructions a.k.a. AXS ---------------------------------- */ op_AAX_abs: + Cycles($4) GetAbs DoAAX Continue op_AAX_zpage: + Cycles($3) GetZPage DoAAX Continue op_AAX_zpage_y: + Cycles($4) GetZPage_Y DoAAX Continue op_AAX_ind_x: + Cycles($6) GetIndZPage_X DoAAX Continue op_AAX_ind_y: + Cycles($6) /* a.k.a. AXA indirect Y */ GetIndZPage_Y DoAAX Continue /* ---------------------------------- - AMA instruction + AMA instruction a.k.a. OAL ---------------------------------- */ op_AMA_imm: + Cycles($2) GetImm DoAMA Continue /* ---------------------------------- - ANA instruction + ANA instruction a.k.a. ANC ---------------------------------- */ op_ANA_imm: + Cycles($2) GetImm DoANA Continue /* ---------------------------------- - ANB instruction + ANB instruction a.k.a. ANC ---------------------------------- */ op_ANB_imm: + Cycles($2) GetImm DoANB Continue @@ -2072,60 +2300,69 @@ op_ANB_imm: ---------------------------------- */ op_AXM_imm: + Cycles($2) GetImm DoAXM Continue /* ---------------------------------- - AXS instruction + AXS instruction a.k.a. TAS ---------------------------------- */ op_AXS_abs_y: + Cycles($5) GetAbs_Y DoAXS Continue /* ---------------------------------- - DCP instructions + DCP instructions a.k.a. DCM ---------------------------------- */ op_DCP_zpage: + Cycles($5) GetZPage DoDCP Continue op_DCP_zpage_x: + Cycles($6) GetZPage_X DoDCP Continue op_DCP_abs: + Cycles($6) GetAbs DoDCP Continue op_DCP_abs_x: + Cycles($7) GetAbs_X DoDCP Continue op_DCP_abs_y: + Cycles($7) GetAbs_Y DoDCP Continue op_DCP_ind_x: + Cycles($8) GetIndZPage_X DoDCP Continue op_DCP_ind_y: + Cycles($8) GetIndZPage_Y DoDCP Continue /* ---------------------------------- - ISB instructions + ISB instructions, a.k.a. INS ---------------------------------- */ op_ISB_dec: @@ -2133,6 +2370,7 @@ op_ISB_dec: Continue op_ISB_zpage: + Cycles($5) GetZPage testb $D_Flag, F_Reg # Decimal mode? jnz op_ISB_dec # Yes, jump to decimal version @@ -2140,6 +2378,7 @@ op_ISB_zpage: Continue op_ISB_zpage_x: + Cycles($6) GetZPage_X testb $D_Flag, F_Reg # Decimal mode? jnz op_ISB_dec # Yes, jump to decimal version @@ -2148,6 +2387,7 @@ op_ISB_zpage_x: op_ISB_abs: + Cycles($6) GetAbs testb $D_Flag, F_Reg # Decimal mode? jnz op_ISB_dec # Yes, jump to decimal version @@ -2155,6 +2395,7 @@ op_ISB_abs: Continue op_ISB_abs_x: + Cycles($7) GetAbs_X testb $D_Flag, F_Reg # Decimal mode? jnz op_ISB_dec # Yes, jump to decimal version @@ -2162,6 +2403,7 @@ op_ISB_abs_x: Continue op_ISB_abs_y: + Cycles($7) GetAbs_Y testb $D_Flag, F_Reg # Decimal mode? jnz op_ISB_dec # Yes, jump to decimal version @@ -2169,6 +2411,7 @@ op_ISB_abs_y: Continue op_ISB_ind_x: + Cycles($8) GetIndZPage_X testb $D_Flag, F_Reg # Decimal mode? jnz op_ISB_dec # Yes, jump to decimal version @@ -2176,6 +2419,7 @@ op_ISB_ind_x: Continue op_ISB_ind_y: + Cycles($8) GetIndZPage_Y testb $D_Flag, F_Reg # Decimal mode? jnz op_ISB_dec # Yes, jump to decimal version @@ -2183,40 +2427,47 @@ op_ISB_ind_y: Continue /* ---------------------------------- - LAN instructions + LAN instructions a.k.a. RLA ---------------------------------- */ op_LAN_zpage: + Cycles($5) GetZPage DoLAN Continue op_LAN_zpage_x: + Cycles($6) GetZPage_X DoLAN Continue op_LAN_abs: + Cycles($6) GetAbs DoLAN Continue op_LAN_abs_x: + Cycles($7) GetAbs_X DoLAN Continue op_LAN_abs_y: + Cycles($7) GetAbs_Y DoLAN Continue op_LAN_ind_x: + Cycles($8) GetIndZPage_X DoLAN Continue op_LAN_ind_y: + Cycles($8) GetIndZPage_Y DoLAN Continue @@ -2226,6 +2477,7 @@ op_LAN_ind_y: ---------------------------------- */ op_LAS_abs_y: + Cycles($4) GetAbs_Y DoLAS Continue @@ -2235,76 +2487,89 @@ op_LAS_abs_y: ---------------------------------- */ op_LAX_zpage: + Cycles($3) GetZPage DoLAX Continue op_LAX_zpage_y: + Cycles($4) GetZPage_Y DoLAX Continue op_LAX_abs: + Cycles($4) GetAbs DoLAX Continue op_LAX_abs_y: + Cycles($4) GetAbs_Y DoLAX Continue op_LAX_ind_x: + Cycles($6) GetIndZPage_X DoLAX Continue op_LAX_ind_y: + Cycles($5) GetIndZPage_Y DoLAX Continue /* ---------------------------------- - LOR instructions + LOR instructions, a.k.a. ASO ---------------------------------- */ op_LOR_zpage: + Cycles($5) GetZPage DoLOR Continue op_LOR_zpage_x: + Cycles($6) GetZPage_X DoLOR Continue op_LOR_abs: + Cycles($6) GetAbs DoLOR Continue op_LOR_abs_x: + Cycles($7) GetAbs_X DoLOR Continue op_LOR_abs_y: + Cycles($7) GetAbs_Y DoLOR Continue op_LOR_ind_x: + Cycles($8) GetIndZPage_X DoLOR Continue op_LOR_ind_y: + Cycles($8) GetIndZPage_Y DoLOR Continue /* ---------------------------------- - RAD instructions + RAD instructions a.k.a. RRA ---------------------------------- */ op_RAD_dec: @@ -2312,6 +2577,7 @@ op_RAD_dec: Continue op_RAD_zpage: + Cycles($5) GetZPage testb $D_Flag, F_Reg # Decimal mode? jnz op_RAD_dec # Yes, jump to decimal version @@ -2319,6 +2585,7 @@ op_RAD_zpage: Continue op_RAD_zpage_x: + Cycles($6) GetZPage_X testb $D_Flag, F_Reg # Decimal mode? jnz op_RAD_dec # Yes, jump to decimal version @@ -2326,6 +2593,7 @@ op_RAD_zpage_x: Continue op_RAD_abs: + Cycles($6) GetAbs testb $D_Flag, F_Reg # Decimal mode? jnz op_RAD_dec # Yes, jump to decimal version @@ -2333,6 +2601,7 @@ op_RAD_abs: Continue op_RAD_abs_x: + Cycles($7) GetAbs_X testb $D_Flag, F_Reg # Decimal mode? jnz op_RAD_dec # Yes, jump to decimal version @@ -2340,6 +2609,7 @@ op_RAD_abs_x: Continue op_RAD_abs_y: + Cycles($7) GetAbs_Y testb $D_Flag, F_Reg # Decimal mode? jnz op_RAD_dec # Yes, jump to decimal version @@ -2347,6 +2617,7 @@ op_RAD_abs_y: Continue op_RAD_ind_x: + Cycles($8) GetIndZPage_X testb $D_Flag, F_Reg # Decimal mode? jnz op_RAD_dec # Yes, jump to decimal version @@ -2354,6 +2625,7 @@ op_RAD_ind_x: Continue op_RAD_ind_y: + Cycles($8) GetIndZPage_Y testb $D_Flag, F_Reg # Decimal mode? jnz op_RAD_dec # Yes, jump to decimal version @@ -2361,58 +2633,67 @@ op_RAD_ind_y: Continue /* ---------------------------------- - RAM instruction + RAM instruction a.k.a. ALR ---------------------------------- */ op_RAM_imm: + Cycles($2) GetImm DoRAM Continue /* ---------------------------------- - RBM instruction + RBM instruction a.k.a. ARR ---------------------------------- */ op_RBM_imm: + Cycles($2) GetImm DoRBM Continue /* ---------------------------------- - REO instructions + REO instructions a.k.a. LSE ---------------------------------- */ op_REO_zpage: + Cycles($5) GetZPage DoREO Continue op_REO_zpage_x: + Cycles($6) GetZPage_X DoREO Continue op_REO_abs: + Cycles($6) GetAbs DoREO Continue op_REO_abs_x: + Cycles($7) GetAbs_X DoREO Continue op_REO_abs_y: + Cycles($7) GetAbs_Y DoREO Continue op_REO_ind_x: + Cycles($8) GetIndZPage_X DoREO Continue op_REO_ind_y: + Cycles($8) GetIndZPage_Y DoREO Continue @@ -2422,6 +2703,7 @@ op_REO_ind_y: ---------------------------------- */ op_ZBC_imm: + Cycles($2) GetImm testb $D_Flag, F_Reg # Decimal mode? jnz op_ZBC_dec # Yes, jump to decimal version @@ -2432,37 +2714,41 @@ op_ZBC_dec: Continue /* ---------------------------------- - TEA instruction + TEA instruction a.k.a. AXA absolute Y ---------------------------------- */ op_TEA_abs_y: + Cycles($5) GetAbs_Y DoTEA Continue /* ---------------------------------- - TEX instruction + TEX instruction a.k.a. XAS ---------------------------------- */ op_TEX_abs_y: + Cycles($5) GetAbs_Y DoTEX Continue /* ---------------------------------- - TEY instruction + TEY instruction a.k.a. SAY ---------------------------------- */ op_TEY_abs_x: + Cycles($5) GetAbs_X DoTEY Continue /* ---------------------------------- - XMA instruction + XMA instruction a.k.a. XAA ---------------------------------- */ op_XMA_imm: + Cycles($2) GetImm DoXMA Continue @@ -3089,7 +3375,7 @@ E(cpu65__cmos) #endif /* HAVE_IIE */ E(cpu65__nmos) - .long op_BRK + .long op_BRK /* 00 */ .long op_ORA_ind_x .long op_HANG .long op_LOR_ind_x @@ -3101,11 +3387,11 @@ E(cpu65__nmos) .long op_ORA_imm .long op_ASL_acc .long op_ANA_imm - .long op_NOP_3 + .long op_SKW_abs .long op_ORA_abs .long op_ASL_abs .long op_LOR_abs - .long op_BPL + .long op_BPL /* 10 */ .long op_ORA_ind_y .long op_HANG .long op_LOR_ind_y @@ -3117,11 +3403,11 @@ E(cpu65__nmos) .long op_ORA_abs_y .long op_NOP .long op_LOR_abs_y - .long op_NOP_3 + .long op_SKW_abs_x .long op_ORA_abs_x .long op_ASL_abs_x .long op_LOR_abs_x - .long op_JSR + .long op_JSR /* 20 */ .long op_AND_ind_x .long op_HANG .long op_LAN_ind_x @@ -3137,7 +3423,7 @@ E(cpu65__nmos) .long op_AND_abs .long op_ROL_abs .long op_LAN_abs - .long op_BMI + .long op_BMI /* 30 */ .long op_AND_ind_y .long op_HANG .long op_LAN_ind_y @@ -3149,11 +3435,11 @@ E(cpu65__nmos) .long op_AND_abs_y .long op_NOP .long op_LAN_abs_y - .long op_NOP_3 + .long op_SKW_abs_x .long op_AND_abs_x .long op_ROL_abs_x .long op_LAN_abs_x - .long op_RTI + .long op_RTI /* 40 */ .long op_EOR_ind_x .long op_HANG .long op_REO_ind_x @@ -3169,7 +3455,7 @@ E(cpu65__nmos) .long op_EOR_abs .long op_LSR_abs .long op_REO_abs - .long op_BVC + .long op_BVC /* 50 */ .long op_EOR_ind_y .long op_HANG .long op_REO_ind_y @@ -3181,11 +3467,11 @@ E(cpu65__nmos) .long op_EOR_abs_y .long op_NOP .long op_REO_abs_y - .long op_NOP_3 + .long op_SKW_abs_x .long op_EOR_abs_x .long op_LSR_abs_x .long op_REO_abs_x - .long op_RTS + .long op_RTS /* 60 */ .long op_ADC_ind_x .long op_HANG .long op_RAD_ind_x @@ -3201,7 +3487,7 @@ E(cpu65__nmos) .long op_ADC_abs .long op_ROR_abs .long op_RAD_abs - .long op_BVS + .long op_BVS /* 70 */ .long op_ADC_ind_y .long op_HANG .long op_RAD_ind_y @@ -3213,11 +3499,11 @@ E(cpu65__nmos) .long op_ADC_abs_y .long op_NOP .long op_RAD_abs_y - .long op_NOP_3 + .long op_SKW_abs_x .long op_ADC_abs_x .long op_ROR_abs_x .long op_RAD_abs_x - .long op_NOP_2 + .long op_NOP_2 /* 80 */ .long op_STA_ind_x .long op_NOP_2 .long op_AAX_ind_x @@ -3233,10 +3519,10 @@ E(cpu65__nmos) .long op_STA_abs .long op_STX_abs .long op_AAX_abs - .long op_BCC + .long op_BCC /* 90 */ .long op_STA_ind_y .long op_HANG - .long op_AAX_ind_y + .long op_AAX_ind_y .long op_STY_zpage_x .long op_STA_zpage_x .long op_STX_zpage_y @@ -3249,7 +3535,7 @@ E(cpu65__nmos) .long op_STA_abs_x .long op_TEX_abs_y .long op_TEA_abs_y - .long op_LDY_imm + .long op_LDY_imm /* A0 */ .long op_LDA_ind_x .long op_LDX_imm .long op_LAX_ind_x @@ -3265,7 +3551,7 @@ E(cpu65__nmos) .long op_LDA_abs .long op_LDX_abs .long op_LAX_abs - .long op_BCS + .long op_BCS /* B0 */ .long op_LDA_ind_y .long op_HANG .long op_LAX_ind_y @@ -3281,7 +3567,7 @@ E(cpu65__nmos) .long op_LDA_abs_x .long op_LDX_abs_y .long op_LAX_abs_y - .long op_CPY_imm + .long op_CPY_imm /* C0 */ .long op_CMP_ind_x .long op_NOP_2 .long op_DCP_ind_x @@ -3297,7 +3583,7 @@ E(cpu65__nmos) .long op_CMP_abs .long op_DEC_abs .long op_DCP_abs - .long op_BNE + .long op_BNE /* D0 */ .long op_CMP_ind_y .long op_HANG .long op_DCP_ind_y @@ -3309,11 +3595,11 @@ E(cpu65__nmos) .long op_CMP_abs_y .long op_NOP .long op_DCP_abs_y - .long op_NOP_3 + .long op_SKW_abs_x .long op_CMP_abs_x .long op_DEC_abs_x .long op_DCP_abs_x - .long op_CPX_imm + .long op_CPX_imm /* E0 */ .long op_SBC_ind_x .long op_NOP_2 .long op_ISB_ind_x @@ -3329,7 +3615,7 @@ E(cpu65__nmos) .long op_SBC_abs .long op_INC_abs .long op_ISB_abs - .long op_BEQ + .long op_BEQ /* F0 */ .long op_SBC_ind_y .long op_HANG .long op_ISB_ind_y @@ -3341,8 +3627,8 @@ E(cpu65__nmos) .long op_SBC_abs_y .long op_NOP .long op_ISB_abs_y - .long op_NOP_3 + .long op_SKW_abs_x .long op_SBC_abs_x .long op_INC_abs_x - .long op_ISB_abs_x + .long op_ISB_abs_x /* FF */ diff -drupN apple2-emul-0.7.4/src/memory.S apple2-emul-0.7.4-rpm/src/memory.S --- apple2-emul-0.7.4/src/memory.S Sat Feb 19 00:32:23 2000 +++ apple2-emul-0.7.4-rpm/src/memory.S Thu Oct 12 16:47:47 2000 @@ -56,14 +56,14 @@ Interrupt ReQuests (IRQ) (normally 65 FF = FF65) 0400 - 07FF Basically primary video text page - 0478 - 047F I/O Scratchpad RAM Addresses for Slot 0 - 7 - 04F8 - 04FF - " " - - 0578 - 057F - " " - - 05F8 - 05FF - " " - + 0478 - 047F I/O Scratchpad RAM Addresses for Slot 0 + 04F8 - 04FF - " " - for Slot 1 + 0578 - 057F - " " - 2 + 05F8 - 05FF - " " - . 0678 - 067F - " " - 06F8 - 06FF - " " - - 0778 - 077F - " " - - 07F8 - 07FF - " " - + 0778 - 077F - " " - . + 07F8 - 07FF - " " - for slot 7 ----- These two addresses are pretty strange; the values provided were inconsistent at least on my Apple II 05F8 Holds the slot number of the disk diff -drupN apple2-emul-0.7.4/src/misc.c apple2-emul-0.7.4-rpm/src/misc.c --- apple2-emul-0.7.4/src/misc.c Tue Feb 1 23:38:42 2000 +++ apple2-emul-0.7.4-rpm/src/misc.c Thu Oct 12 16:34:56 2000 @@ -23,6 +23,7 @@ #include #include +#include "audio.h" #include "misc.h" #include "video.h" #include "disk.h" @@ -162,8 +163,8 @@ void c_initialize_tables() { /* done common initialization */ #ifdef APPLE_IIE - /* initialize zero-page, //e specific */ - if (apple_mode == IIE_MODE) { + /* initialize zero-page, IIe specific */ + if (apple_mode == IIE_MODE) { for (i = 0; i < 0x200; i++) { cpu65_vmem[i].r = iie_read_ram_zpage_and_stack; @@ -593,19 +594,6 @@ void c_initialize_apple_ii_memory() apple_ii_64k[1][0xC000] = 0x00; } -/* ------------------------------------------------------------------------- - void c_initialize_sound() - ------------------------------------------------------------------------- */ - -void c_initialize_sound() -{ - int i; - - for (i = 0xC030; i < 0xC040; i++) - cpu65_vmem[i].r = cpu65_vmem[i].w = - (sound_mode && soundAllowed) ? read_speaker_toggle_pc : ram_nop; -} - #ifdef APPLE_IIE /* ------------------------------------------------------------------------- c_initialize_iie_switches @@ -691,21 +679,14 @@ static void reinitialize(void) static void c_initialize_firsttime() { - /* get IO permission for speaker port. */ - if (/*ioperm(0x42, 1, 1) ||*/ ioperm(0x61, 1, 1)) { - perror("ioperm"); - printf("cannot get port access to PC speaker.\n"); - printf("sound will not be used.\n"); - soundAllowed=0; - } else - soundAllowed=1; - /* read in system files and calculate system defaults */ c_load_interface_font(); /* initialize the video system */ video_init(); + sound_init(); /* sound system first-time init */ + /* Enable periodic updates */ signal(SIGVTALRM,c_periodic_update); setitimer(ITIMER_VIRTUAL,&timer_on,0); @@ -734,6 +715,8 @@ int main(int sargc, char *sargv[]) load_settings(); /* user prefs */ c_initialize_firsttime(); /* init svga graphics and vm */ + + cpu65_cycles = 0L; for (;;) { /* execute the emulator */ diff -drupN apple2-emul-0.7.4/src/misc.h apple2-emul-0.7.4-rpm/src/misc.h --- apple2-emul-0.7.4/src/misc.h Tue Feb 1 23:38:53 2000 +++ apple2-emul-0.7.4-rpm/src/misc.h Thu Oct 12 16:36:31 2000 @@ -39,6 +39,8 @@ #define SW_IOUDIS 0xC07E #endif +extern long cpu65_cycles; + extern const struct itimerval timer_on,timer_off; /* Text characters */ diff -drupN apple2-emul-0.7.4/src/prefs.c apple2-emul-0.7.4-rpm/src/prefs.c --- apple2-emul-0.7.4/src/prefs.c Tue Feb 1 23:39:54 2000 +++ apple2-emul-0.7.4-rpm/src/prefs.c Thu Oct 12 17:13:27 2000 @@ -125,7 +125,9 @@ static const struct match_table sound_ta { {"off", 0}, {"pc_speaker", 1}, - {"on", 1}, + {"/dev/audio", 2}, + {"autodetect", 3}, + {"on", 3}, {0, 1}, }; diff -drupN apple2-emul-0.7.4/src/video.h apple2-emul-0.7.4-rpm/src/video.h --- apple2-emul-0.7.4/src/video.h Tue Feb 1 23:40:19 2000 +++ apple2-emul-0.7.4-rpm/src/video.h Thu Oct 12 16:54:31 2000 @@ -127,11 +127,11 @@ void video_sync(int block); #define COLOR_DARK_RED 35 #define COLOR_MEDIUM_RED 36 -#define COLOR_LIGHT_RED 37 /* hgr used */ +#define COLOR_LIGHT_RED 0x90 /* 37 hgr used */ #define COLOR_DARK_GREEN 38 #define COLOR_MEDIUM_GREEN 39 -#define COLOR_LIGHT_GREEN 40 /* hgr used */ +#define COLOR_LIGHT_GREEN 0xc0 /* 40 hgr used */ #define COLOR_DARK_YELLOW 41 #define COLOR_MEDIUM_YELLOW 42 @@ -139,11 +139,11 @@ void video_sync(int block); #define COLOR_DARK_BLUE 44 #define COLOR_MEDIUM_BLUE 45 -#define COLOR_LIGHT_BLUE 46 /* hgr used */ +#define COLOR_LIGHT_BLUE 0x60 /* 46 hgr used */ #define COLOR_DARK_PURPLE 47 #define COLOR_MEDIUM_PURPLE 48 -#define COLOR_LIGHT_PURPLE 49 /* hgr used */ +#define COLOR_LIGHT_PURPLE 0x30 /* 49 hgr used */ #define COLOR_DARK_CYAN 50 #define COLOR_MEDIUM_CYAN 51 diff -drupN apple2-emul-0.7.4/src/xvideo.c apple2-emul-0.7.4-rpm/src/xvideo.c --- apple2-emul-0.7.4/src/xvideo.c Fri Mar 3 00:57:17 2000 +++ apple2-emul-0.7.4-rpm/src/xvideo.c Thu Oct 12 16:52:24 2000 @@ -264,72 +264,59 @@ static void c_initialize_colors() { colors[ COLOR_FLASHING_WHITE].green = (255<<8)|255; colors[ COLOR_FLASHING_WHITE].blue = (255<<8)|255; - colors[0x00].red = 0; colors[0x00].green = 0; - colors[0x00].blue = 0; /* Black */ - colors[0x10].red = 195; colors[0x10].green = 0; - colors[0x10].blue = 48; /* Magenta */ - colors[0x20].red = 0; colors[0x20].green = 0; - colors[0x20].blue = 130; /* Dark Blue */ - colors[0x30].red = 166; colors[0x30].green = 52; - colors[0x30].blue = 170; /* Purple */ - colors[0x40].red = 0; colors[0x40].green = 146; - colors[0x40].blue = 0; /* Dark Green */ - colors[0x50].red = 105; colors[0x50].green = 105; - colors[0x50].blue = 105; /* Dark Grey*/ - colors[0x60].red = 113; colors[0x60].green = 24; - colors[0x60].blue = 255; /* Medium Blue */ - colors[0x70].red = 12; colors[0x70].green = 190; - colors[0x70].blue = 235; /* Light Blue */ - colors[0x80].red = 150; colors[0x80].green = 85; - colors[0x80].blue = 40; /* Brown */ - colors[0x90].red = 255; colors[0xa0].green = 24; - colors[0x90].blue = 44; /* Orange */ - colors[0xa0].red = 150; colors[0xa0].green = 170; - colors[0xa0].blue = 170; /* Light Gray */ - colors[0xb0].red = 255; colors[0xb0].green = 158; - colors[0xb0].blue = 150; /* Pink */ - colors[0xc0].red = 0; colors[0xc0].green = 255; - colors[0xc0].blue = 0; /* Green */ - colors[0xd0].red = 255; colors[0xd0].green = 255; - colors[0xd0].blue = 0; /* Yellow */ - colors[0xe0].red = 130; colors[0xe0].green = 255; - colors[0xe0].blue = 130; /* Aqua */ - colors[0xf0].red = 255; colors[0xf0].green = 255; - colors[0xf0].blue = 255; /* White */ + /* Believe it or not, the old color code was typed out by hand, + * 32 copies of lines like this: + * + * colors[0x90].red = 255; colors[0xa0].green = 24; + * colors[0x90].blue = 44; + * + * Notice the typo in the array index! + */ + +#define SET_C_RGB(i1,i2,r,g,b) \ + colors[i1].red = (r); colors[i2].red = (r); \ + colors[i1].green = (g); colors[i2].green = (g); \ + colors[i1].blue = (b); colors[i2].blue = (b); /* mirror of lores colors optimized for dhires code */ - colors[0x00].red = 0; colors[0x00].green = 0; - colors[0x00].blue = 0; /* Black */ - colors[0x08].red = 195; colors[0x08].green = 0; - colors[0x08].blue = 48; /* Magenta */ - colors[0x01].red = 0; colors[0x01].green = 0; - colors[0x01].blue = 130; /* Dark Blue */ - colors[0x09].red = 166; colors[0x09].green = 52; - colors[0x09].blue = 170; /* Purple */ - colors[0x02].red = 0; colors[0x02].green = 146; - colors[0x02].blue = 0; /* Dark Green */ - colors[0x0a].red = 105; colors[0x0A].green = 105; - colors[0x0a].blue = 105; /* Dark Grey*/ - colors[0x03].red = 113; colors[0x03].green = 24; - colors[0x03].blue = 255; /* Medium Blue */ - colors[0x0b].red = 12; colors[0x0b].green = 190; - colors[0x0b].blue = 235; /* Light Blue */ - colors[0x04].red = 150; colors[0x04].green = 85; - colors[0x04].blue = 40; /* Brown */ - colors[0x0c].red = 255; colors[0x0c].green = 24; - colors[0x0c].blue = 44; /* Orange */ - colors[0x05].red = 150; colors[0x05].green = 170; - colors[0x05].blue = 170; /* Light Gray */ - colors[0x0d].red = 255; colors[0x0d].green = 158; - colors[0x0d].blue = 150; /* Pink */ - colors[0x06].red = 0; colors[0x06].green = 255; - colors[0x06].blue = 0; /* Green */ - colors[0x0e].red = 255; colors[0x0e].green = 255; - colors[0x0e].blue = 0; /* Yellow */ - colors[0x07].red = 130; colors[0x07].green = 255; - colors[0x07].blue = 130; /* Aqua */ - colors[0x0f].red = 255; colors[0x0f].green = 255; - colors[0x0f].blue = 255; /* White */ + +#ifdef USE_ORIGINAL_GUESSED_COLORS + SET_C_RGB(0x00, 0x00, 0, 0, 0) /* Black COLOR=0 */ + SET_C_RGB(0x10, 0x08, 195, 0, 48) /* Magenta COLOR=1 */ + SET_C_RGB(0x20, 0x01, 0, 0, 130) /* Dark Blue COLOR=2 */ + SET_C_RGB(0x30, 0x09, 166, 52, 170) /* Purple COLOR=3 HCOLOR=2 */ + SET_C_RGB(0x40, 0x02, 0, 146, 0) /* Dark Green COLOR=4 */ + SET_C_RGB(0x50, 0x0a, 105, 105, 105) /* Dark Grey COLOR=5 */ + SET_C_RGB(0x60, 0x03, 113, 24, 255) /* Medium Blue COLOR=6 HCOLOR=6 */ + SET_C_RGB(0x70, 0x0b, 12, 190, 235) /* Light Blue COLOR=7 */ + SET_C_RGB(0x80, 0x04, 150, 85, 40) /* Brown COLOR=8 */ + SET_C_RGB(0x90, 0x0c, 255, 24, 44) /* Orange COLOR=9 HCOLOR=5 */ + SET_C_RGB(0xa0, 0x05, 150, 170, 170) /* Light Gray COLOR=10 */ + SET_C_RGB(0xb0, 0x0d, 255, 158, 150) /* Pink COLOR=11 */ + SET_C_RGB(0xc0, 0x06, 0, 255, 0) /* Green COLOR=12 HCOLOR=1 */ + SET_C_RGB(0xd0, 0x0e, 255, 255, 0) /* Yellow COLOR=13 */ + SET_C_RGB(0xe0, 0x07, 130, 255, 130) /* Aqua COLOR=14 */ + SET_C_RGB(0xf0, 0x0f, 255, 255, 255) /* White COLOR=15 */ +#else + /* Not only are they more accurate, but these color values were + * actually calculated from the NTSC spec! */ + SET_C_RGB(0x00, 0x00, 0, 0, 0) /* Black COLOR=0 */ + SET_C_RGB(0x10, 0x08, 227, 30, 96) /* Magenta COLOR=1 */ + SET_C_RGB(0x20, 0x01, 96, 78, 189) /* Dark Blue COLOR=2 */ + SET_C_RGB(0x30, 0x09, 255, 68, 253) /* Purple COLOR=3 HCOLOR=2 */ + SET_C_RGB(0x40, 0x02, 0, 163, 96) /* Dark Green COLOR=4 */ + SET_C_RGB(0x50, 0x0a, 156, 156, 156) /* Dark Grey COLOR=5 */ + SET_C_RGB(0x60, 0x03, 20, 207, 253) /* Medium Blue COLOR=6 HCOLOR=6 */ + SET_C_RGB(0x70, 0x0b, 208, 195, 255) /* Light Blue COLOR=7 */ + SET_C_RGB(0x80, 0x04, 96, 114, 3) /* Brown COLOR=8 */ + SET_C_RGB(0x90, 0x0c, 255, 106, 60) /* Orange COLOR=9 HCOLOR=5 */ + SET_C_RGB(0xa0, 0x05, 156, 156, 156) /* Light Gray COLOR=10 */ + SET_C_RGB(0xb0, 0x0d, 255, 160, 208) /* Pink COLOR=11 */ + SET_C_RGB(0xc0, 0x06, 20, 245, 60) /* Green COLOR=12 HCOLOR=1 */ + SET_C_RGB(0xd0, 0x0e, 208, 221, 141) /* Yellow COLOR=13 */ + SET_C_RGB(0xe0, 0x07, 114, 255, 208) /* Aqua COLOR=14 */ + SET_C_RGB(0xf0, 0x0f, 255, 255, 255) /* White COLOR=15 */ +#endif for (i=0; i<16; i++) { colors[i].red = (colors[i].red<<8) | colors[i].red; @@ -375,6 +362,8 @@ static int keysym_to_scancode(void) { rc = 67; break; case XK_F10: rc = 68; break; + case XK_F12: + rc = 101; break; case XK_Left: rc = 105; break; case XK_Right: