• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Z80エミュレーターを搭載した作品群


Commit MetaInfo

Revisiónfec9c66e3bf425bc974f8e1360ed91dfae6490e3 (tree)
Tiempo2019-04-07 12:43:08
AutorKatsumi <kmorimatsu@sour...>
CommiterKatsumi

Log Message

CP/KM ver 0.6

Cambiar Resumen

Diferencia incremental

--- a/cpkmweb/cpm.html
+++ b/cpkmweb/cpm.html
@@ -9,7 +9,7 @@
99 -->
1010 <head>
1111 <meta charset="UTF-8" />
12- <title>CP/KM web v0.5</title>
12+ <title>CP/KM web v0.6</title>
1313 <link rel="stylesheet" type="text/css" href="./style.css" />
1414 <!-- HTML5 functions -->
1515 <script type="text/javascript" src="./get.js"></script>
--- a/cpkmweb/display.js
+++ b/cpkmweb/display.js
@@ -142,9 +142,10 @@ display.writeChar=function(ascii){
142142 this.cursor=parseInt(this.cursor/80)*80+80;
143143 break;
144144 case 0x0b: // ^K
145- for(var i=this.cursor;i<parseInt(this.cursor/80)*80+80;i++){
145+ /*for(var i=this.cursor;i<parseInt(this.cursor/80)*80+80;i++){
146146 this.write(i,0x20);
147- }
147+ }*/
148+ if (80<=this.cursor) this.cursor-=80;
148149 break;
149150 case 0x0d: // ^M (CR)
150151 this.cursor=parseInt(this.cursor/80)*80+80;
@@ -160,6 +161,15 @@ display.writeChar=function(ascii){
160161 case 0x1a: // ^Z
161162 this.cls();
162163 break;
164+ case 0x1c: // ^\
165+ this.cursor++;
166+ break;
167+ case 0x1d: // ^]
168+ if (0<this.cursor) this.cursor--;
169+ break;
170+ case 0x1e: // ^^
171+ this.cursor=0;
172+ break;
163173 default:
164174 this.write(this.cursor,ascii);
165175 this.cursor++;
--- a/cpkmweb/z80.js
+++ b/cpkmweb/z80.js
@@ -1,8 +1,9 @@
1-/*********************************
2-* CP/KM web written by Katsumi *
3-* This script is released *
4-* under the LGPL v2.1. *
5-*********************************/
1+/**********************************
2+* Z80 emulator written by Katsumi *
3+* ver 0.80 *
4+* This script is released *
5+* under the LGPL v2.1. *
6+**********************************/
67
78 /*
89 Public methods:
@@ -10,7 +11,7 @@
1011 z80.setSpeed(clk);
1112 z80.getMicroSec();
1213 z80.exec(msec);
13- z80.interrupt();
14+ z80.interrupt(code);
1415 z80.nmr();
1516
1617 Required outside methods:
@@ -24,6 +25,7 @@
2425 z80=new Object();
2526 z80.breakPoint=-1;
2627 z80.step=0;
28+z80.m1=false;
2729 z80.reset=function(){
2830 // 8 bit registers
2931 this.z80IM=0;
@@ -72,11 +74,13 @@ z80.reset=function(){
7274 this.irq=0;
7375 this.nrq=0;
7476 };
75-z80.interrupt=function(){
77+z80.intCode=0xff;
78+z80.interrupt=function(code){
7679 if (!this.flagIFF1) return;
7780 this.loadIFF1(0);
7881 this.loadIFF2(0);
7982 this.irq=1;
83+ this.intCode=code;
8084 };
8185 z80.nmr=function(){
8286 this.loadIFF1(0);
@@ -94,11 +98,22 @@ z80.doInt=function(){
9498 this.loadPC(0x0066);
9599 } else {
96100 // Mascable interrupt
97- if (this.regIM!=1) {
98- alert("Mode "+this.regIM+" interrupt is not supported.");
99- return;
101+ switch (this.regIM) {
102+ case 0:
103+ this.codeVector[this.intCode]();
104+ return;
105+ case 2:
106+ var addr=(this.regI<<8)|this.intCode;
107+ this.loadSP(this.regSP-2);
108+ memory.write(this.regSP,this.regPC&0xFF);
109+ memory.write(this.regSP+1,this.regPC>>8);
110+ this.loadPC(memory.read(addr)|(memory.read(addr+1)<<8));
111+ return;
112+ case 1:
113+ default:
114+ this.codeFF();
115+ return;
100116 }
101- this.codeFF();
102117 }
103118 };
104119 z80.speed=2000; // Default: 2 MHz
@@ -113,25 +128,32 @@ z80.events=function(){
113128 // The events function will be called every msec.
114129 // Override this function if required to use.
115130 }
131+
116132 z80.clk=0;
117-z80.setT4= function(){ this.clk+=4; }
118-z80.setT5= function(){ this.clk+=5; }
119-z80.setT6= function(){ this.clk+=6; }
120-z80.setT7= function(){ this.clk+=7; }
121-z80.setT8= function(){ this.clk+=8; }
122-z80.setT9= function(){ this.clk+=9; }
123-z80.setT10=function(){ this.clk+=10; }
124-z80.setT11=function(){ this.clk+=11; }
125-z80.setT12=function(){ this.clk+=12; }
126-z80.setT13=function(){ this.clk+=13; }
127-z80.setT14=function(){ this.clk+=14; }
128-z80.setT15=function(){ this.clk+=15; }
129-z80.setT16=function(){ this.clk+=16; }
130-z80.setT17=function(){ this.clk+=17; }
131-z80.setT19=function(){ this.clk+=19; }
132-z80.setT20=function(){ this.clk+=20; }
133-z80.setT21=function(){ this.clk+=21; }
134-z80.setT23=function(){ this.clk+=23; }
133+z80.setT4= function(){ this.clk+=4; }
134+z80.setT4_5= function(){ this.clk+=4; }
135+z80.setT4_7= function(){ this.clk+=4; }
136+z80.setT5= function(){ this.clk+=5; }
137+z80.setT6= function(){ this.clk+=6; }
138+z80.setT6_5= function(){ this.clk+=6; }
139+z80.setT7= function(){ this.clk+=7; }
140+z80.setT8= function(){ this.clk+=8; }
141+z80.setT9= function(){ this.clk+=9; }
142+z80.setT10= function(){ this.clk+=10; }
143+z80.setT10_11=function(){ this.clk+=10; }
144+z80.setT11= function(){ this.clk+=11; }
145+z80.setT11_10=function(){ this.clk+=11; }
146+z80.setT12= function(){ this.clk+=12; }
147+z80.setT13= function(){ this.clk+=13; }
148+z80.setT14= function(){ this.clk+=14; }
149+z80.setT15= function(){ this.clk+=15; }
150+z80.setT16= function(){ this.clk+=16; }
151+z80.setT17= function(){ this.clk+=17; }
152+z80.setT19= function(){ this.clk+=19; }
153+z80.setT19_18=function(){ this.clk+=19; }
154+z80.setT20= function(){ this.clk+=20; }
155+z80.setT21= function(){ this.clk+=21; }
156+z80.setT23= function(){ this.clk+=23; }
135157
136158 z80.loadA=function(x){
137159 this.regA=x&0xff;
@@ -179,7 +201,7 @@ z80.loadI=function(x){
179201 this.regI=x&0xff;
180202 };
181203 z80.loadR=function(x){
182- this.regR=x&0xff;
204+ this.regR=x&0x7f;
183205 };
184206 z80.loadIXh=function(x){
185207 this.regIXh=x&0xff;
@@ -303,19 +325,19 @@ z80.code02=function(){
303325 z80.code03=function(){
304326 //INC BC
305327 //Note that 16-bit increment routine does not change flags.
306- this.setT6();
328+ this.setT6_5();
307329 this.loadBC(this.regBC+1);
308330 };
309331 z80.code04=function(){
310332 //INC B
311- this.setT4();
333+ this.setT4_5();
312334 var i8=this.regB+1;
313335 this.loadB(i8);
314336 this.flag8inc(i8);
315337 };
316338 z80.code05=function(){
317339 //DEC B
318- this.setT4();
340+ this.setT4_5();
319341 var i8=this.regB-1;
320342 this.loadB(i8);
321343 this.flag8dec(i8);
@@ -355,7 +377,7 @@ z80.code08=function(){
355377 };
356378 z80.code09=function(){
357379 //ADD HL,BC
358- this.setT11();
380+ this.setT11_10();
359381 this.z80ADD16(this.regBC);
360382 };
361383 z80.code0A=function(){
@@ -365,19 +387,19 @@ z80.code0A=function(){
365387 };
366388 z80.code0B=function(){
367389 //DEC BC
368- this.setT6();
390+ this.setT6_5();
369391 this.loadBC(this.regBC-1);
370392 };
371393 z80.code0C=function(){
372394 //INC C
373- this.setT4();
395+ this.setT4_5();
374396 var i8=this.regC+1;
375397 this.loadC(i8);
376398 this.flag8inc(i8);
377399 };
378400 z80.code0D=function(){
379401 //DEC C
380- this.setT4();
402+ this.setT4_5();
381403 var i8=this.regC-1;
382404 this.loadC(i8);
383405 this.flag8dec(i8);
@@ -434,19 +456,19 @@ z80.code12=function(){
434456 };
435457 z80.code13=function(){
436458 //INC DE
437- this.setT6();
459+ this.setT6_5();
438460 this.loadDE(this.regDE+1);
439461 };
440462 z80.code14=function(){
441463 //INC D
442- this.setT4();
464+ this.setT4_5();
443465 var i8=this.regD+1;
444466 this.loadD(i8);
445467 this.flag8inc(i8);
446468 };
447469 z80.code15=function(){
448470 //DEC D
449- this.setT4();
471+ this.setT4_5();
450472 var i8=this.regD-1;
451473 this.loadD(i8);
452474 this.flag8dec(i8);
@@ -482,7 +504,7 @@ z80.code18=function(){
482504 };
483505 z80.code19=function(){
484506 //ADD HL,DE
485- this.setT11();
507+ this.setT11_10();
486508 this.z80ADD16(this.regDE);
487509 };
488510 z80.code1A=function(){
@@ -492,19 +514,19 @@ z80.code1A=function(){
492514 };
493515 z80.code1B=function(){
494516 //DEC DE
495- this.setT6();
517+ this.setT6_5();
496518 this.loadDE(this.regDE-1);
497519 };
498520 z80.code1C=function(){
499521 //INC E
500- this.setT4();
522+ this.setT4_5();
501523 var i8=this.regE+1;
502524 this.loadE(i8);
503525 this.flag8inc(i8);
504526 };
505527 z80.code1D=function(){
506528 //DEC E
507- this.setT4();
529+ this.setT4_5();
508530 var i8=this.regE-1;
509531 this.loadE(i8);
510532 this.flag8dec(i8);
@@ -560,19 +582,19 @@ z80.code22=function(){
560582 };
561583 z80.code23=function(){
562584 //INC HL
563- this.setT6();
585+ this.setT6_5();
564586 this.loadHL(this.regHL+1);
565587 };
566588 z80.code24=function(){
567589 //INC H
568- this.setT4();
590+ this.setT4_5();
569591 var i8=this.regH+1;
570592 this.loadH(i8);
571593 this.flag8inc(i8);
572594 };
573595 z80.code25=function(){
574596 //DEC H
575- this.setT4();
597+ this.setT4_5();
576598 var i8=this.regH-1;
577599 this.loadH(i8);
578600 this.flag8dec(i8);
@@ -736,7 +758,7 @@ z80.code28=function(){
736758 };
737759 z80.code29=function(){
738760 //ADD HL,HL
739- this.setT11();
761+ this.setT11_10();
740762 this.z80ADD16(this.regHL);
741763 };
742764 z80.code2A=function(){
@@ -750,19 +772,19 @@ z80.code2A=function(){
750772 };
751773 z80.code2B=function(){
752774 //DEC HL
753- this.setT6();
775+ this.setT6_5();
754776 this.loadHL(this.regHL-1);
755777 };
756778 z80.code2C=function(){
757779 //INC L
758- this.setT4();
780+ this.setT4_5();
759781 var i8=this.regL+1;
760782 this.loadL(i8);
761783 this.flag8inc(i8);
762784 };
763785 z80.code2D=function(){
764786 //DEC L
765- this.setT4();
787+ this.setT4_5();
766788 var i8=this.regL-1;
767789 this.loadL(i8);
768790 this.flag8dec(i8);
@@ -815,19 +837,19 @@ z80.code32=function(){
815837 };
816838 z80.code33=function(){
817839 //INC SP
818- this.setT6();
840+ this.setT6_5();
819841 this.loadSP(this.regSP+1);
820842 };
821843 z80.code34=function(){
822844 //INC (HL)
823- this.setT11();
845+ this.setT11_10();
824846 var i8=memory.read(this.regHL)+1;
825847 memory.write(this.regHL,i8);
826848 this.flag8inc(i8);
827849 };
828850 z80.code35=function(){
829851 //DEC (HL)
830- this.setT11();
852+ this.setT11_10();
831853 var i8=memory.read(this.regHL)-1;
832854 memory.write(this.regHL,i8);
833855 this.flag8dec(i8);
@@ -864,7 +886,7 @@ z80.code38=function(){
864886 };
865887 z80.code39=function(){
866888 //ADD HL,SP
867- this.setT11();
889+ this.setT11_10();
868890 this.z80ADD16(this.regSP);
869891 };
870892 z80.code3A=function(){
@@ -877,19 +899,19 @@ z80.code3A=function(){
877899 };
878900 z80.code3B=function(){
879901 //DEC SP
880- this.setT6();
902+ this.setT6_5();
881903 this.loadSP(this.regSP-1);
882904 };
883905 z80.code3C=function(){
884906 //INC A
885- this.setT4();
907+ this.setT4_5();
886908 var i8=this.regA+1;
887909 this.loadA(i8);
888910 this.flag8inc(i8);
889911 };
890912 z80.code3D=function(){
891913 //DEC A
892- this.setT4();
914+ this.setT4_5();
893915 var i8=this.regA-1;
894916 this.loadA(i8);
895917 this.flag8dec(i8);
@@ -921,32 +943,32 @@ C is set if CY was 0 before operation; reset otherwise
921943 };
922944 z80.code40=function(){
923945 //LD B,B
924- this.setT4();
946+ this.setT4_5();
925947 this.loadB(this.regB);
926948 };
927949 z80.code41=function(){
928950 //LD B,C
929- this.setT4();
951+ this.setT4_5();
930952 this.loadB(this.regC);
931953 };
932954 z80.code42=function(){
933955 //LD B,D
934- this.setT4();
956+ this.setT4_5();
935957 this.loadB(this.regD);
936958 };
937959 z80.code43=function(){
938960 //LD B,E
939- this.setT4();
961+ this.setT4_5();
940962 this.loadB(this.regE);
941963 };
942964 z80.code44=function(){
943965 //LD B,H
944- this.setT4();
966+ this.setT4_5();
945967 this.loadB(this.regH);
946968 };
947969 z80.code45=function(){
948970 //LD B,L
949- this.setT4();
971+ this.setT4_5();
950972 this.loadB(this.regL);
951973 };
952974 z80.code46=function(){
@@ -956,37 +978,37 @@ z80.code46=function(){
956978 };
957979 z80.code47=function(){
958980 //LD B,A
959- this.setT4();
981+ this.setT4_5();
960982 this.loadB(this.regA);
961983 };
962984 z80.code48=function(){
963985 //LD C,B
964- this.setT4();
986+ this.setT4_5();
965987 this.loadC(this.regB);
966988 };
967989 z80.code49=function(){
968990 //LD C,C
969- this.setT4();
991+ this.setT4_5();
970992 this.loadC(this.regC);
971993 };
972994 z80.code4A=function(){
973995 //LD C,D
974- this.setT4();
996+ this.setT4_5();
975997 this.loadC(this.regD);
976998 };
977999 z80.code4B=function(){
9781000 //LD C,E
979- this.setT4();
1001+ this.setT4_5();
9801002 this.loadC(this.regE);
9811003 };
9821004 z80.code4C=function(){
9831005 //LD C,H
984- this.setT4();
1006+ this.setT4_5();
9851007 this.loadC(this.regH);
9861008 };
9871009 z80.code4D=function(){
9881010 //LD C,L
989- this.setT4();
1011+ this.setT4_5();
9901012 this.loadC(this.regL);
9911013 };
9921014 z80.code4E=function(){
@@ -996,37 +1018,37 @@ z80.code4E=function(){
9961018 };
9971019 z80.code4F=function(){
9981020 //LD C,A
999- this.setT4();
1021+ this.setT4_5();
10001022 this.loadC(this.regA);
10011023 };
10021024 z80.code50=function(){
10031025 //LD D,B
1004- this.setT4();
1026+ this.setT4_5();
10051027 this.loadD(this.regB);
10061028 };
10071029 z80.code51=function(){
10081030 //LD D,C
1009- this.setT4();
1031+ this.setT4_5();
10101032 this.loadD(this.regC);
10111033 };
10121034 z80.code52=function(){
10131035 //LD D,D
1014- this.setT4();
1036+ this.setT4_5();
10151037 this.loadD(this.regD);
10161038 };
10171039 z80.code53=function(){
10181040 //LD D,E
1019- this.setT4();
1041+ this.setT4_5();
10201042 this.loadD(this.regE);
10211043 };
10221044 z80.code54=function(){
10231045 //LD D,H
1024- this.setT4();
1046+ this.setT4_5();
10251047 this.loadD(this.regH);
10261048 };
10271049 z80.code55=function(){
10281050 //LD D,L
1029- this.setT4();
1051+ this.setT4_5();
10301052 this.loadD(this.regL);
10311053 };
10321054 z80.code56=function(){
@@ -1036,37 +1058,37 @@ z80.code56=function(){
10361058 };
10371059 z80.code57=function(){
10381060 //LD D,A
1039- this.setT4();
1061+ this.setT4_5();
10401062 this.loadD(this.regA);
10411063 };
10421064 z80.code58=function(){
10431065 //LD E,B
1044- this.setT4();
1066+ this.setT4_5();
10451067 this.loadE(this.regB);
10461068 };
10471069 z80.code59=function(){
10481070 //LD E,C
1049- this.setT4();
1071+ this.setT4_5();
10501072 this.loadE(this.regC);
10511073 };
10521074 z80.code5A=function(){
10531075 //LD E,D
1054- this.setT4();
1076+ this.setT4_5();
10551077 this.loadE(this.regD);
10561078 };
10571079 z80.code5B=function(){
10581080 //LD E,E
1059- this.setT4();
1081+ this.setT4_5();
10601082 this.loadE(this.regE);
10611083 };
10621084 z80.code5C=function(){
10631085 //LD E,H
1064- this.setT4();
1086+ this.setT4_5();
10651087 this.loadE(this.regH);
10661088 };
10671089 z80.code5D=function(){
10681090 //LD E,L
1069- this.setT4();
1091+ this.setT4_5();
10701092 this.loadE(this.regL);
10711093 };
10721094 z80.code5E=function(){
@@ -1076,37 +1098,37 @@ z80.code5E=function(){
10761098 };
10771099 z80.code5F=function(){
10781100 //LD E,A
1079- this.setT4();
1101+ this.setT4_5();
10801102 this.loadE(this.regA);
10811103 };
10821104 z80.code60=function(){
10831105 //LD H,B
1084- this.setT4();
1106+ this.setT4_5();
10851107 this.loadH(this.regB);
10861108 };
10871109 z80.code61=function(){
10881110 //LD H,C
1089- this.setT4();
1111+ this.setT4_5();
10901112 this.loadH(this.regC);
10911113 };
10921114 z80.code62=function(){
10931115 //LD H,D
1094- this.setT4();
1116+ this.setT4_5();
10951117 this.loadH(this.regD);
10961118 };
10971119 z80.code63=function(){
10981120 //LD H,E
1099- this.setT4();
1121+ this.setT4_5();
11001122 this.loadH(this.regE);
11011123 };
11021124 z80.code64=function(){
11031125 //LD H,H
1104- this.setT4();
1126+ this.setT4_5();
11051127 this.loadH(this.regH);
11061128 };
11071129 z80.code65=function(){
11081130 //LD H,L
1109- this.setT4();
1131+ this.setT4_5();
11101132 this.loadH(this.regL);
11111133 };
11121134 z80.code66=function(){
@@ -1116,37 +1138,37 @@ z80.code66=function(){
11161138 };
11171139 z80.code67=function(){
11181140 //LD H,A
1119- this.setT4();
1141+ this.setT4_5();
11201142 this.loadH(this.regA);
11211143 };
11221144 z80.code68=function(){
11231145 //LD L,B
1124- this.setT4();
1146+ this.setT4_5();
11251147 this.loadL(this.regB);
11261148 };
11271149 z80.code69=function(){
11281150 //LD L,C
1129- this.setT4();
1151+ this.setT4_5();
11301152 this.loadL(this.regC);
11311153 };
11321154 z80.code6A=function(){
11331155 //LD L,D
1134- this.setT4();
1156+ this.setT4_5();
11351157 this.loadL(this.regD);
11361158 };
11371159 z80.code6B=function(){
11381160 //LD L,E
1139- this.setT4();
1161+ this.setT4_5();
11401162 this.loadL(this.regE);
11411163 };
11421164 z80.code6C=function(){
11431165 //LD L,H
1144- this.setT4();
1166+ this.setT4_5();
11451167 this.loadL(this.regH);
11461168 };
11471169 z80.code6D=function(){
11481170 //LD L,L
1149- this.setT4();
1171+ this.setT4_5();
11501172 this.loadL(this.regL);
11511173 };
11521174 z80.code6E=function(){
@@ -1156,7 +1178,7 @@ z80.code6E=function(){
11561178 };
11571179 z80.code6F=function(){
11581180 //LD L,A
1159- this.setT4();
1181+ this.setT4_5();
11601182 this.loadL(this.regA);
11611183 };
11621184 z80.code70=function(){
@@ -1191,7 +1213,7 @@ z80.code75=function(){
11911213 };
11921214 z80.code76=function(){
11931215 //HALT
1194- this.setT4();
1216+ this.setT4_7();
11951217 this.loadPC(this.regPC-1);
11961218 };
11971219 z80.code77=function(){
@@ -1201,32 +1223,32 @@ z80.code77=function(){
12011223 };
12021224 z80.code78=function(){
12031225 //LD A,B
1204- this.setT4();
1226+ this.setT4_5();
12051227 this.loadA(this.regB);
12061228 };
12071229 z80.code79=function(){
12081230 //LD A,C
1209- this.setT4();
1231+ this.setT4_5();
12101232 this.loadA(this.regC);
12111233 };
12121234 z80.code7A=function(){
12131235 //LD A,D
1214- this.setT4();
1236+ this.setT4_5();
12151237 this.loadA(this.regD);
12161238 };
12171239 z80.code7B=function(){
12181240 //LD A,E
1219- this.setT4();
1241+ this.setT4_5();
12201242 this.loadA(this.regE);
12211243 };
12221244 z80.code7C=function(){
12231245 //LD A,H
1224- this.setT4();
1246+ this.setT4_5();
12251247 this.loadA(this.regH);
12261248 };
12271249 z80.code7D=function(){
12281250 //LD A,L
1229- this.setT4();
1251+ this.setT4_5();
12301252 this.loadA(this.regL);
12311253 };
12321254 z80.code7E=function(){
@@ -1236,7 +1258,7 @@ z80.code7E=function(){
12361258 };
12371259 z80.code7F=function(){
12381260 //LD A,A
1239- this.setT4();
1261+ this.setT4_5();
12401262 this.loadA(this.regA);
12411263 };
12421264 z80.code80=function(){
@@ -1598,7 +1620,7 @@ z80.codeC4=function(){
15981620 var i8=this.getCode();
15991621 var i16=this.getCode();
16001622 if (this.flagZ){
1601- this.setT10();
1623+ this.setT10_11();
16021624 } else {
16031625 this.setT17();
16041626 this.loadSP(this.regSP-2);
@@ -1667,7 +1689,7 @@ z80.codeCC=function(){
16671689 memory.write(this.regSP+1,this.regPC>>8);
16681690 this.loadPC((i16<<8)|i8);
16691691 } else {
1670- this.setT10();
1692+ this.setT10_11();
16711693 }
16721694 };
16731695 z80.codeCD=function(){
@@ -1722,7 +1744,7 @@ z80.codeD2=function(){
17221744 };
17231745 z80.codeD3=function(){
17241746 //OUT (n),A
1725- this.setT11();
1747+ this.setT11_10();
17261748 io.write(this.getCode(),this.regA,this.regA);
17271749 };
17281750 z80.codeD4=function(){
@@ -1730,7 +1752,7 @@ z80.codeD4=function(){
17301752 var i8=this.getCode();
17311753 var i16=this.getCode();
17321754 if (this.flagC){
1733- this.setT10();
1755+ this.setT10_11();
17341756 } else {
17351757 this.setT17();
17361758 this.loadSP(this.regSP-2);
@@ -1794,7 +1816,7 @@ z80.codeDA=function(){
17941816 };
17951817 z80.codeDB=function(){
17961818 //IN A,n
1797- this.setT11();
1819+ this.setT11_10();
17981820 this.loadA(io.read(this.getCode(), this.regA));
17991821 };
18001822 z80.codeDC=function(){
@@ -1808,7 +1830,7 @@ z80.codeDC=function(){
18081830 memory.write(this.regSP+1,this.regPC>>8);
18091831 this.loadPC((i16<<8)|i8);
18101832 } else {
1811- this.setT10();
1833+ this.setT10_11();
18121834 }
18131835 };
18141836 z80.codeDE=function(){
@@ -1853,7 +1875,7 @@ z80.codeE2=function(){
18531875 };
18541876 z80.codeE3=function(){
18551877 //EX (SP),HL
1856- this.setT19();
1878+ this.setT19_18();
18571879 var i16=memory.read(this.regSP+1)<<8;
18581880 i16|=memory.read(this.regSP);
18591881 memory.write(this.regSP,this.regL);
@@ -1865,7 +1887,7 @@ z80.codeE4=function(){
18651887 var i8=this.getCode();
18661888 var i16=this.getCode();
18671889 if (this.flagP){
1868- this.setT10();
1890+ this.setT10_11();
18691891 } else {
18701892 this.setT17();
18711893 this.loadSP(this.regSP-2);
@@ -1909,7 +1931,7 @@ z80.codeE8=function(){
19091931 };
19101932 z80.codeE9=function(){
19111933 //JP (HL)
1912- this.setT4();
1934+ this.setT4_5();
19131935 this.loadPC(this.regHL);
19141936 };
19151937 z80.codeEA=function(){
@@ -1937,7 +1959,7 @@ z80.codeEC=function(){
19371959 memory.write(this.regSP+1,this.regPC>>8);
19381960 this.loadPC((i16<<8)|i8);
19391961 } else {
1940- this.setT10();
1962+ this.setT10_11();
19411963 }
19421964 };
19431965 z80.codeEE=function(){
@@ -1992,7 +2014,7 @@ z80.codeF4=function(){
19922014 var i8=this.getCode();
19932015 var i16=this.getCode();
19942016 if (this.flagS){
1995- this.setT10();
2017+ this.setT10_11();
19962018 } else {
19972019 this.setT17();
19982020 this.loadSP(this.regSP-2);
@@ -2036,7 +2058,7 @@ z80.codeF8=function(){
20362058 };
20372059 z80.codeF9=function(){
20382060 //LD SP,HL
2039- this.setT6();
2061+ this.setT6_5();
20402062 this.loadSP(this.regHL);
20412063 };
20422064 z80.codeFA=function(){
@@ -2063,7 +2085,7 @@ z80.codeFC=function(){
20632085 memory.write(this.regSP+1,this.regPC>>8);
20642086 this.loadPC((i16<<8)|i8);
20652087 } else {
2066- this.setT10();
2088+ this.setT10_11();
20672089 }
20682090 };
20692091 z80.codeFE=function(){
@@ -5001,7 +5023,7 @@ for (i=16;i<256;i++) {
50015023 eval("z80.codeFDCBVector["+i+"]=function(i16){ z80.codeFDCB"+i.toString(16).toUpperCase()+"(i16); };");
50025024 }
50035025 z80.exec=function(msec){
5004- var i;
5026+ var i,code;
50055027 for (i=msec;0<i;i--) {
50065028 while (this.clk<this.speed || this.step) {
50075029 if (this.regPC==this.breakPoint) {
@@ -5009,43 +5031,56 @@ z80.exec=function(msec){
50095031 this.step=1;
50105032 return;
50115033 }
5012- this.codeVector[this.getCode()]();
5034+ this.m1=true;
5035+ code=this.getCode();
5036+ this.m1=false;
5037+ this.codeVector[code]();
50135038 if (this.irq) this.doInt();
50145039 if (this.step) return;
5040+ // Increment R register here
5041+ this.loadR(this.regR+1);
50155042 }
50165043 this.clk-=this.speed;
50175044 this.events();
50185045 }
50195046 };
50205047 z80.codeCB=function(){
5048+ // Increment R register here
5049+ this.loadR(this.regR+1);
50215050 try {
50225051 this.codeCBVector[this.getCode()]();
50235052 } catch(e) {
5024- alert(e);
5053+ console.log(e);
50255054 this.codeVOID();
50265055 }
50275056 };
50285057 z80.codeDD=function(){
5058+ // Increment R register here
5059+ this.loadR(this.regR+1);
50295060 try {
50305061 this.codeDDVector[this.getCode()]();
50315062 } catch(e) {
5032- alert(e);
5063+ console.log(e);
50335064 this.codeVOID();
50345065 }
50355066 };
50365067 z80.codeED=function(){
5068+ // Increment R register here
5069+ this.loadR(this.regR+1);
50375070 try {
50385071 this.codeEDVector[this.getCode()]();
50395072 } catch(e) {
5040- alert(e);
5073+ console.log(e);
50415074 this.codeVOID();
50425075 }
50435076 };
50445077 z80.codeFD=function(){
5078+ // Increment R register here
5079+ this.loadR(this.regR+1);
50455080 try {
50465081 this.codeFDVector[this.getCode()]();
50475082 } catch(e) {
5048- alert(e);
5083+ console.log(e);
50495084 this.codeVOID();
50505085 }
50515086 };
@@ -5054,7 +5089,7 @@ z80.codeDDCB=function(){
50545089 try {
50555090 this.codeDDCBVector[this.getCode()](i16);
50565091 } catch(e) {
5057- alert(e);
5092+ console.log(e);
50585093 this.codeVOID();
50595094 }
50605095 };
@@ -5063,7 +5098,7 @@ z80.codeFDCB=function(){
50635098 try {
50645099 this.codeFDCBVector[this.getCode()](i16);
50655100 } catch(e) {
5066- alert(e);
5101+ console.log(e);
50675102 this.codeVOID();
50685103 }
50695104 };
--- a/cpkmweb/z80functions.js
+++ b/cpkmweb/z80functions.js
@@ -1,8 +1,9 @@
1-/*********************************
2-* CP/KM web written by Katsumi *
3-* This script is released *
4-* under the LGPL v2.1. *
5-*********************************/
1+/**********************************
2+* Z80 emulator written by Katsumi *
3+* ver 0.80 *
4+* This script is released *
5+* under the LGPL v2.1. *
6+**********************************/
67
78 /*
89 Additional methods used for emulating Z80 CPU