;==============================================================================
;	<< 386ASM V2.0 >>  for  FM TOWNS
;==============================================================================
	page		60,132
	name		INT23
	title		INT23 INTERRUPT.
;==============================================================================
;	INT23(^C) 割り込み
;
;	CREATE : 1990.08.30
;	FINISH : 1990.08.30
;
;	< High C からの呼出形式 >
;	extern	void INT23_init(void) ;
;	extern	void INT23_end(void) ;
;
;	< HISTORY >
;	1990.08.30 : CREATE
;
;	<  note   >
;	TABS = 4
;
;	★注意
;		このプログラムを呼ぶプログラムの
;		オブジェクトは、ネイティブの最初に
;		おいて下さい｡(先頭から64K以内に入る
;		ようにするため｡)
;
;	Programed by Y.Hirata ( Nifty-ID : NAB03321 )
;==============================================================================
;
;
;********************************************
;			外部宣言定義
;********************************************
;
			public	INT23_init				; INT23(^C) 割り込み登録
			public	INT23_end				; INT23(^C) 割り込み解除
;
;
;********************************************
;			定数定義
;********************************************
;
DOS_INT		EQU			021h				; MS-DOS Function
;
;
;////////////////////////////////////////////
;			リアル部
;////////////////////////////////////////////
;
rmcode		segment WORD public 'rmcode' use16
			assume	cs:rmcode				;
;
;********************************************
;	INT23 ﾘｱﾙﾊﾝﾄﾞﾗ内での使用データ領域
;********************************************
;
vct_23h		dd		far						; ^C 割り込みﾍﾞｸﾀ
;
;********************************************
;			^C ハンドラ
;********************************************
int23_abort		proc	FAR					;
			iret							;
int23_abort		endp						;
;
;********************************************
;			^C ﾊﾝﾄﾞﾗのｾｯﾄ
;********************************************
int23_setup		proc	FAR					;
			push	es						;
			push	ds						;
			push	dx						;
			push	bx						;
			push	cs						;
			pop		ds						; ds = cs
;
			mov		ax,3523h				;
			int		DOS_INT					;
			mov		WORD ptr cs:vct_23h,bx	;
			mov		WORD ptr cs:vct_23h+2,es	;
;
			mov		dx,offset cs:int23_abort	; ^C ﾊﾝﾄﾞﾗのﾍﾞｸﾀｾｯﾄ
			mov		ax,2523h				;
			int		DOS_INT					;
;
			pop		bx						;
			pop		dx						;
			pop		ds						;
			pop		es						;
			ret								;
int23_setup		endp						;
;
;********************************************
;			^C ﾊﾝﾄﾞﾗのﾘｾｯﾄ
;********************************************
int23_release	proc	FAR					;
			push	ds						;
			push	dx						;
			push	cs						;
			pop		ds						; ds = cs
;
			lds		dx,DWORD ptr cs:vct_23h	;
			mov		ax,2523h				;
			int		DOS_INT					;
;
			pop		dx						;
			pop		ds						;
			ret								;
int23_release	endp						;
;
real_end	label byte						; ﾘｱﾙの最終ｱﾄﾞﾚｽ(ﾘｱﾙｻｲｽﾞ取得用)
;
rmcode		ends							;
;
;
;
;////////////////////////////////////////////
;			ネイティブ部
;////////////////////////////////////////////
;
;********************************************
;	VSYNC ﾈｲﾃｨﾌﾞ処理
;********************************************
;
pmcode		segment DWORD public 'CODE' use32	;
			assume	cs:pmcode,ds:rmcode		;
;
;********************************************
;	INT23(^C) 割り込み登録
;********************************************
INT23_init	proc	NEAR					;
			enter	0,0						;
			push	es						;
			push	ds						;
			push	ecx						;
			push	ebx						;
;
			mov		ax,ds					;
			mov		es,ax					; es = ds
			xor		ebx,ebx					;
			lea		ecx,real_end			;
			mov		ax,0250fh				;
			int		DOS_INT					; ﾈｲﾃｨﾌﾞ->ﾘｱﾙ の ｱﾄﾞﾚｽ変換
;
			mov		ebx,ecx					; ｾｸﾞﾒﾝﾄ
			lea		bx,int23_setup			; ｵﾌｾｯﾄ
			xor		ecx,ecx					; ecx = 0
			mov		ax,0250eh				;
			int		DOS_INT					; ﾘｱﾙﾓｰﾄﾞﾌﾟﾛｼｼﾞｬの呼出
;
			pop		ebx						;
			pop		ecx						;
			pop		ds						;
			pop		es						;
			xor		eax,eax					; return code = 0
			leave							;
			ret								;
INT23_init	endp							;
;
;
;********************************************
;	INT23(^C) 割り込み解除
;********************************************
INT23_end	proc	NEAR					;
			enter	0,0						;
			push	es						;
			push	ds						;
			push	ecx						;
			push	ebx						;
;
			mov		ax,ds					;
			mov		es,ax					; es = ds
			xor		ebx,ebx					;
			lea		ecx,real_end			;
			mov		ax,0250fh				;
			int		DOS_INT					; ﾈｲﾃｨﾌﾞ->ﾘｱﾙ の ｱﾄﾞﾚｽ変換
;
			mov		ebx,ecx					; ｾｸﾞﾒﾝﾄ
			lea		bx,int23_release		; ｵﾌｾｯﾄ
			xor		ecx,ecx					; ecx = 0
			mov		ax,0250eh				;
			int		DOS_INT					; ﾘｱﾙﾓｰﾄﾞﾌﾟﾛｼｼﾞｬの呼出
;
			pop		ebx						;
			pop		ecx						;
			pop		ds						;
			pop		es						;
			xor		eax,eax					; return code = 0
			leave							;
			ret								;
INT23_end	endp							;
;
pmcode		ends							;
;
			end
	
