Created
June 1, 2022 15:12
-
-
Save lpproj/d12834d8d6d40f3c44e4f373e8a4413f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
patch against AHASEL98 1.00 (http://offgao.net/program/ahasel98.html) | |
to build with LSI-C86 3.30c or OpenWatcom C/C++ (wcl) | |
diff --git a/AHASEL98.C b/AHASEL98.C | |
index 9e1af56..c99e1a0 100644 | |
--- a/AHASEL98.C | |
+++ b/AHASEL98.C | |
@@ -5,10 +5,34 @@ | |
V1.00 2022/06/01 by OffGao | |
******************************/ | |
+/* | |
+20220601 addendum (lpproj) | |
+to build with LSI-C 3.30c eval: | |
+ lcc ahasel98.c -lintlib | |
+ | |
+to build with OpenWatcom C/C++: | |
+ wcl -zq -bcl=dos -s -Fr -zk0 ahasel98.c | |
+*/ | |
#include <stdio.h> | |
-#include <pc98.h> | |
+#include <dos.h> | |
+#include <stdlib.h> | |
+#include <string.h> | |
+#include <conio.h> | |
+#ifdef LSI_C | |
+# include <machine.h> /* inp[w], outp[w] */ | |
+#endif | |
+#ifndef __TURBOC__ | |
+# define inport(p) inpw(p) | |
+# define inportb(p) inp(p) | |
+# define outport(p,v) outpw(p,v) | |
+# define outportb(p,v) outp(p,v) | |
+#endif | |
+ | |
+#ifdef USE_PC98LIB | |
+# include <pc98.h> | |
+#endif | |
typedef unsigned char Uint8; | |
typedef unsigned int Uint16; | |
@@ -18,18 +42,18 @@ typedef int Int16; | |
typedef long Int32; | |
-//グローバル定義 | |
-//------------------------------- | |
+/* グローバル定義 */ | |
+/* ------------------------------- */ | |
-//MODE -> IOポート | |
+/* MODE -> IOポート */ | |
const Uint16 romport[]={ | |
- 0x186e,0x386e //AHA-1030 series, 0:18xx 1:38xx | |
+ 0x186e,0x386e /* AHA-1030 series, 0:18xx 1:38xx */ | |
}; | |
-//IRQ -> INT | |
+/* IRQ -> INT */ | |
const Uint8 irq2int[]={255,255,255,0,255,1,2,255,255,3,41,42,5,6,255}; | |
-//PnP info TEMPLATE | |
+/* PnP info TEMPLATE */ | |
const Uint8 pnptemp1[]={0x0a,0x10,0x10}; | |
const Uint8 pnptemp2[]={ | |
0x82,0x1a,0x00, | |
@@ -56,7 +80,7 @@ const Uint8 pnptemp5[]={ | |
0x79}; | |
- | |
+#ifdef USE_PC98LIB | |
void cursor(Uint8 enable){ | |
if(enable){ | |
pc98crt(0x11); | |
@@ -87,12 +111,19 @@ Uint8 iskey(){ | |
#define locate(x,y) gotoxy((x)+1,(y)+1) | |
#define cls clrscr | |
+#else | |
+static void cls(void) | |
+{ | |
+ printf("\x1b[2J"); | |
+ fflush(stdout); | |
+} | |
+#endif /* USE_PC98LIB */ | |
/* | |
void memcpy(Uint8* to, Uint8* from, Uint16 size){ | |
for(;size>0;from++,to++,size--)*to=*from; | |
} | |
*/ | |
-//EEPROM Access WAIT | |
+/* EEPROM Access WAIT */ | |
/*--------------------------- | |
ct : wait count (ct*0.6us) | |
----------------------------*/ | |
@@ -105,7 +136,7 @@ void romwait(Uint16 ct){ | |
} | |
} | |
-//EEPROMリセット | |
+/* EEPROMリセット */ | |
/*--------------------------- | |
pa : IO port Mode | |
----------------------------*/ | |
@@ -118,7 +149,7 @@ void rominit(Uint8 pa){ | |
} | |
} | |
-//EEPROM IOSET | |
+/* EEPROM IOSET */ | |
/*--------------------------- | |
pa : IO port Mode | |
d : data | |
@@ -132,7 +163,7 @@ void romset(Uint8 pa, Uint8 d){ | |
} | |
} | |
-//EEPROM IOGET | |
+/* EEPROM IOGET */ | |
/*--------------------------- | |
pa : IO port Mode | |
return : data | |
@@ -146,7 +177,7 @@ Uint8 romget(Uint8 pa){ | |
return 0; | |
} | |
-//EEPROMアクセス基本OUT | |
+/* EEPROMアクセス基本OUT */ | |
/*--------------------------- | |
a : io address | |
b : data bit | |
@@ -165,7 +196,7 @@ void romoutp(Uint8 a, Uint8 b){ | |
} | |
} | |
-//EEPROMアクセス基本IN | |
+/* EEPROMアクセス基本IN */ | |
/*--------------------------- | |
a : io address | |
-------- | |
@@ -181,7 +212,7 @@ Uint8 rominp(Uint8 a){ | |
} | |
-//EEPROM複数Bit送信 | |
+/* EEPROM複数Bit送信 */ | |
/*---------------------------- | |
pa : IO port Mode | |
ct : bit count | |
@@ -194,7 +225,7 @@ void romoutc(Uint8 pa, Uint8 ct, Uint16 d){ | |
} | |
} | |
-//EEPROM複数Bit受信 | |
+/* EEPROM複数Bit受信 */ | |
/*---------------------------- | |
pa : IO port Mode | |
ct : bit count | |
@@ -212,7 +243,7 @@ Uint8 rominc(Uint8 pa, Uint8 ct){ | |
return r; | |
} | |
-//EEPROM Busy WAIT | |
+/* EEPROM Busy WAIT */ | |
/*--------------------------- | |
pa : IO port Mode | |
-------- | |
@@ -226,7 +257,9 @@ Uint8 rombusywait(Uint8 pa){ | |
romset(pa,0x84); | |
for(a=0;a<10000;a++){ | |
romwait(1); | |
- //printf("%02X ",inportb(0x186e)); | |
+#if 0 | |
+ printf("%02X ",inportb(0x186e)); | |
+#endif | |
if(romget(pa)&0x8)a=32767; | |
} | |
romset(pa,0x00); | |
@@ -234,7 +267,7 @@ Uint8 rombusywait(Uint8 pa){ | |
} | |
-//EEPROMリード | |
+/* EEPROMリード */ | |
/*---------------------------- | |
pa : IO port Mode | |
ra : ROM Address | |
@@ -245,7 +278,7 @@ Uint8 romread(Uint8 pa, Uint16 ra){ | |
register Uint8 r=0; | |
rominit(pa); | |
- //READ:110 | |
+ /* READ:110 */ | |
romoutc(pa,3,6); | |
romoutc(pa,9,ra); | |
r = rominc(pa,8); | |
@@ -253,7 +286,7 @@ Uint8 romread(Uint8 pa, Uint16 ra){ | |
return r; | |
} | |
-//EEPROMライト | |
+/* EEPROMライト */ | |
/*---------------------------- | |
pa : IO port Address | |
ra : ROM Address | |
@@ -264,22 +297,22 @@ void romwrite(Uint8 pa, Uint16 ra, Uint8 d){ | |
rominit(pa); | |
- //ERASE & WEITE ENABLE:100 11xxxxxxx | |
+ /* ERASE & WEITE ENABLE:100 11xxxxxxx */ | |
romoutc(pa,3,4); | |
romoutc(pa,9,0x1ff); | |
- //ERASE 111 addr | |
+ /* ERASE 111 addr */ | |
romoutc(pa,3,7); | |
romoutc(pa,9,ra); | |
rombusywait(pa); | |
- //WRITE 101 addr data | |
+ /* WRITE 101 addr data */ | |
romoutc(pa,3,5); | |
romoutc(pa,9,ra); | |
romoutc(pa,8,d); | |
rombusywait(pa); | |
- //ERASE & WEITE DISABLE:100 00xxxxxxx | |
+ /* ERASE & WEITE DISABLE:100 00xxxxxxx */ | |
romoutc(pa,3,4); | |
romoutc(pa,9,0x0); | |
@@ -309,10 +342,10 @@ void main(void){ | |
for(a=0;a<256;a++){ | |
bf[a]=romread(board,a); | |
if(a>0 && bf[a-1]==0x31 && bf[a]==0x00){ | |
- pnp=1; //PnP ON | |
+ pnp=1; /* PnP ON */ | |
} | |
if(a>1 && bf[a-2]=='N' && bf[a-1]=='E' && bf[a]=='C'){ | |
- nec=1; //PC-9801-100 | |
+ nec=1; /* PC-9801-100 */ | |
} | |
} | |
@@ -332,7 +365,7 @@ void main(void){ | |
if(irq>13){ | |
printf("IRQ:%d???",irq); | |
}else if(irq2int[irq]==255){ | |
- printf("IRQ:%d(INT:??)",irq); | |
+ printf("IRQ:%d(INT:?""?)",irq); /* to avoid trigraph `??)' */ | |
}else{ | |
printf("IRQ:%d(INT:%d)",irq,irq2int[irq]); | |
} | |
@@ -346,21 +379,21 @@ void main(void){ | |
printf("%02X ", bf[a]); | |
} | |
- //MODE | |
+ /* MODE */ | |
printf("\n1:BOARD SELECT 2:EASY SETUP 3:ADVACED SETUP 9:WRITE DATA 0:END\n"); | |
printf("CMD >");scanf("%x",&a);fflush(stdin); | |
switch(a){ | |
- case 0://END | |
+ case 0: /* END */ | |
exit(0); | |
- case 1://BOARD SELECT | |
+ case 1: /* BOARD SELECT */ | |
break; | |
- case 3://ADVANCED SETUP | |
+ case 3: /* ADVANCED SETUP */ | |
printf("NEC Board? Adaptec Board? [1:PC-9801-100 0:AHA-1030x] >"); | |
scanf("%d",&a);fflush(stdin); | |
if(a>=0x1)a=0x1; | |
nec=a; | |
- case 2://EASY SETUP | |
+ case 2: /* EASY SETUP */ | |
printf("Enable PnP? [1:YES 0:NO] >"); | |
scanf("%d",&a);fflush(stdin); | |
if(a>=0x1)a=0x1; | |
@@ -377,7 +410,7 @@ void main(void){ | |
scanf("%d",&a);fflush(stdin); | |
if(a!=1)break; | |
printf("Writing..."); | |
- //Let's CREATE PnPInfo | |
+ /* Let's CREATE PnPInfo */ | |
#define COPY(x) {memcpy(bf+c,x,sizeof(x));c+=sizeof(x);} | |
c=9; | |
COPY(pnptemp1); | |
@@ -411,7 +444,7 @@ void main(void){ | |
if((c&0xf)==0)printf("%02X\b\b",c); | |
} | |
break; | |
- case 9://WRITE DATA | |
+ case 9: /* WRITE DATA */ | |
printf("ADDRESS [00-FF] >");scanf("%x",&a);fflush(stdin); | |
if(a>0xff)a=0xff; | |
printf("DAT [00-FF] >");scanf("%x",&b);fflush(stdin); | |
@@ -423,7 +456,7 @@ void main(void){ | |
} | |
a=3; | |
break; | |
- case 8://TEST | |
+ case 8: /* TEST */ | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment