※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

「VDPアクセス例」の編集履歴(バックアップ)一覧はこちら

VDPアクセス例」の最新版変更点

追加された行は青色になります。

削除された行は赤色になります。

 既に作成したinp(),outp()I/O関数を用いてVDPを直接扱う。
 
 VDPを直接設定し画面モードを切り替える場合は、BIOSと異なりレジスタの操作と画面初期化
 などを必要とする。
 
 新たに作成した関数はVDPレジスタアクセス、メモリーアドレス設定、フォント再設定の
 三つの関数のみ。
 
 VRAMへのアクセス方法は初めにアドレス(VMemadr)をセットし、後はI/Oダイレクト(outp/inp)に連続してリードライトする。
 
 SCREEN8へ切り替えはVDPモードレジスタの設定だけでなく、CLS処理など
 画面の初期化を行なう必要がある。
 
 SCREEN8からテキストモードSCREEN0へ復帰する際は、9938/9958のフォントデータを
 再セットアップする必要がある。
 以下のサンプルコードは英数字のみ。
 
 
 サンプル例はSCREEN0(WIDTH40)から、SCREEN8にモード切替え後、再びSCREEN0(40)へ戻る
 
 サンプルソースコード。
 vdpexample.c
  //ALPHABET FONT
  const unsigned char f[96][8]={ 
   {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
   {0x20,0x20,0x20,0x20,0x0,0x0,0x20,0x0},
   {0x50,0x50,0x50,0x0,0x0,0x0,0x0,0x0},
   {0x50,0x50,0xF8,0x50,0xF8,0x50,0x50,0x0},
   {0x20,0x78,0xA0,0x70,0x28,0xF0,0x20,0x0},
   {0xC0,0xC8,0x10,0x20,0x40,0x98,0x18,0x0},
   {0x40,0xA0,0x40,0xA8,0x90,0x98,0x60,0x0},
   {0x10,0x20,0x40,0x0,0x0,0x0,0x0,0x0},
   {0x10,0x20,0x40,0x40,0x40,0x20,0x10,0x0},
   {0x40,0x20,0x10,0x10,0x10,0x20,0x40,0x0},
   {0x20,0xA8,0x70,0x20,0x70,0xA8,0x20,0x0},
   {0x0,0x20,0x20,0xF8,0x20,0x20,0x0,0x0},
   {0x0,0x0,0x0,0x0,0x0,0x20,0x20,0x40},
   {0x0,0x0,0x0,0x78,0x0,0x0,0x0,0x0},
   {0x0,0x0,0x0,0x0,0x0,0x60,0x60,0x0},
   {0x0,0x0,0x8,0x10,0x20,0x40,0x80,0x0},
   {0x70,0x88,0x98,0xA8,0xC8,0x88,0x70,0x0},
   {0x20,0x60,0xA0,0x20,0x20,0x20,0xF8,0x0},
   {0x70,0x88,0x8,0x10,0x60,0x80,0xF8,0x0},
   {0x70,0x88,0x8,0x30,0x8,0x88,0x70,0x0},
   {0x10,0x30,0x50,0x90,0xF8,0x10,0x10,0x0},
   {0xF8,0x80,0xE0,0x10,0x8,0x10,0xE0,0x0},
   {0x30,0x40,0x80,0xF0,0x88,0x88,0x70,0x0},
   {0xF8,0x88,0x10,0x20,0x20,0x20,0x20,0x0},
   {0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x0},
   {0x70,0x88,0x88,0x78,0x8,0x10,0x60,0x0},
   {0x0,0x0,0x20,0x0,0x0,0x20,0x0,0x0},
   {0x0,0x0,0x20,0x0,0x0,0x20,0x20,0x40},
   {0x18,0x30,0x60,0xC0,0x60,0x30,0x18,0x0},
   {0x0,0x0,0xF8,0x0,0xF8,0x0,0x0,0x0},
   {0xC0,0x60,0x30,0x18,0x30,0x60,0xC0,0x0},
   {0x70,0x88,0x8,0x10,0x20,0x0,0x20,0x0},
   {0x70,0x88,0x8,0x68,0xA8,0xA8,0x70,0x0},
   {0x20,0x50,0x88,0x88,0xF8,0x88,0x88,0x0},
   {0xF0,0x48,0x48,0x70,0x48,0x48,0xF0,0x0},
   {0x30,0x48,0x80,0x80,0x80,0x48,0x30,0x0},
   {0xE0,0x50,0x48,0x48,0x48,0x50,0xE0,0x0},
   {0xF8,0x80,0x80,0xF0,0x80,0x80,0xF8,0x0},
   {0xF8,0x80,0x80,0xF0,0x80,0x80,0x80,0x0},
   {0x70,0x88,0x80,0xB8,0x88,0x88,0x70,0x0},
   {0x88,0x88,0x88,0xF8,0x88,0x88,0x88,0x0},
   {0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x0},
   {0x38,0x10,0x10,0x10,0x90,0x90,0x60,0x0},
   {0x88,0x90,0xA0,0xC0,0xA0,0x90,0x88,0x0},
   {0x80,0x80,0x80,0x80,0x80,0x80,0xF8,0x0},
   {0x88,0xD8,0xA8,0xA8,0x88,0x88,0x88,0x0},
   {0x88,0xC8,0xC8,0xA8,0x98,0x98,0x88,0x0},
   {0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0},
   {0xF0,0x88,0x88,0xF0,0x80,0x80,0x80,0x0},
   {0x70,0x88,0x88,0x88,0xA8,0x90,0x68,0x0},
   {0xF0,0x88,0x88,0xF0,0xA0,0x90,0x88,0x0},
   {0x70,0x88,0x80,0x70,0x8,0x88,0x70,0x0},
   {0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0x0},
   {0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x0},
   {0x88,0x88,0x88,0x88,0x50,0x50,0x20,0x0},
   {0x88,0x88,0x88,0xA8,0xA8,0xD8,0x88,0x0},
   {0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x0},
   {0x88,0x88,0x88,0x70,0x20,0x20,0x20,0x0},
   {0xF8,0x8,0x10,0x20,0x40,0x80,0xF8,0x0},
   {0x70,0x40,0x40,0x40,0x40,0x40,0x70,0x0},
   {0x88,0x50,0x20,0x70,0x20,0x70,0x20,0x0},
   {0x70,0x10,0x10,0x10,0x10,0x10,0x70,0x0},
   {0x20,0x50,0x88,0x0,0x0,0x0,0x0,0x0},
   {0x0,0x0,0x0,0x0,0x0,0x0,0xF8,0x0},
   {0x40,0x20,0x10,0x0,0x0,0x0,0x0,0x0},
   {0x0,0x0,0x70,0x8,0x78,0x88,0x78,0x0},
   {0x80,0x80,0xB0,0xC8,0x88,0xC8,0xB0,0x0},
   {0x0,0x0,0x70,0x88,0x80,0x88,0x70,0x0},
   {0x8,0x8,0x68,0x98,0x88,0x98,0x68,0x0},
   {0x0,0x0,0x70,0x88,0xF8,0x80,0x70,0x0},
   {0x10,0x28,0x20,0xF8,0x20,0x20,0x20,0x0},
   {0x0,0x0,0x68,0x98,0x98,0x68,0x8,0x70},
   {0x80,0x80,0xF0,0x88,0x88,0x88,0x88,0x0},
   {0x20,0x0,0x60,0x20,0x20,0x20,0x70,0x0},
   {0x10,0x0,0x30,0x10,0x10,0x10,0x90,0x60},
   {0x40,0x40,0x48,0x50,0x60,0x50,0x48,0x0},
   {0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x0},
   {0x0,0x0,0xD0,0xA8,0xA8,0xA8,0xA8,0x0},
   {0x0,0x0,0xB0,0xC8,0x88,0x88,0x88,0x0},
   {0x0,0x0,0x70,0x88,0x88,0x88,0x70,0x0},
   {0x0,0x0,0xB0,0xC8,0xC8,0xB0,0x80,0x80},
   {0x0,0x0,0x68,0x98,0x98,0x68,0x8,0x8},
   {0x0,0x0,0xB0,0xC8,0x80,0x80,0x80,0x0},
   {0x0,0x0,0x78,0x80,0xF0,0x8,0xF0,0x0},
   {0x40,0x40,0xF0,0x40,0x40,0x48,0x30,0x0},
   {0x0,0x0,0x90,0x90,0x90,0x90,0x68,0x0},
   {0x0,0x0,0x88,0x88,0x88,0x50,0x20,0x0},
   {0x0,0x0,0x88,0xA8,0xA8,0xA8,0x50,0x0},
   {0x0,0x0,0x88,0x50,0x20,0x50,0x88,0x0},
   {0x0,0x0,0x88,0x88,0x98,0x68,0x8,0x70},
   {0x0,0x0,0xF8,0x10,0x20,0x40,0xF8,0x0},
   {0x18,0x20,0x20,0x40,0x20,0x20,0x18,0x0},
   {0x20,0x20,0x20,0x0,0x20,0x20,0x20,0x0},
   {0xC0,0x20,0x20,0x10,0x20,0x20,0xC0,0x0},
   {0x40,0xA8,0x10,0x0,0x0,0x0,0x0,0x0},
   {0,0,0,0,0,0,0,0}
  };
  
  extern unsigned char inp(unsigned char);
  extern outp(unsigned char,unsigned char);
  
  void VRegister(unsigned char reg, unsigned char data);
  void VMemadr(long addr, char rw);
  void Fontset(void);
  
  void main(void){
  	long i;
  	int j; 
  
  	//SCREEN8
  	VRegister(0,0xE);
  	VRegister(1,0x60);
  
  	//VDP DISPSCAN BASE ADDRESS(PATTERN NAME TABLE)
  	VRegister(2,0x1F);
  
  	//SPRITE OFF
  	VRegister(8,0xA);
  
  	//SET ADDRESS,WRITE MODE
  	VMemadr(0,1);
  
  	//WRITE VMEM(I/O DIRECT)
  	for(j=0; j<0xd3ff; j++){
  		outp(0x98,0);
  	}
  
  	//WAIT
  	for(i=0; i<300000; i++);
  
  	//RETURN SCREEN0(40)
  	VRegister(0,0);
  	VRegister(1,0x70);
  
  	//VDP DISPSCAN BASE ADDRESS
  	VRegister(2,0x0);
  
  	//SCREEN0(40) FONT RECOVER
  	Fontset();
  }
  
  //function(Register number, Data)
  void VRegister(unsigned char reg, unsigned char data){
  	outp(0x99,data);
  	outp(0x99,reg+0x80);
  }
  
  //function(VMem Address, 0-Read/1-Write)
  void VMemadr(long addr,char rw){
  	unsigned char low,mid,hi;
  
  	low=addr & 0xff;
  	mid=(addr >> 8) & 0x3f;
  	hi=(addr >>14) & 0x7;
  
  	//HI ADDR
  	outp(0x99,hi);
  	//R#14
  	outp(0x99,0x8e);
  
  	//LOW ADDR
  	outp(0x99,low);
  	//MID ADDR
  	if (rw) {
  		//WRITE
  		outp(0x99,mid+0x40);
  	}else{
  		//READ
  		outp(0x99,mid);
  	}
  }
  
  void Fontset(){
  	int i;
  	int j;
+ 
+ 	//CLEAR VFONT ALLOCATION
+ 	VMemadr(0x800,1);
+ 	for(i=0x800; i<0x1100; i++){
+ 		outp(0x98,0);
+ 	}
  
  	//SET VFONT ADDRESS
  	//(PATTERN GENERATOR TABLE,SCREEN0/WIDTH40)
  	VMemadr(0x900,1);
  
  	//WRITE FONT(ALPHABET ONLY)
  	for(i=0; i<96; i++){
  		for(j=0; j<8; j++){
  		outp(0x98,f[i][j]);
  		}
  	}
  }
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。