GBDKライブラリドキュメント
GBDK libraries documentation |
||
---|---|---|
前
Prev |
次
Next |
GBの記憶に直接アクセスする主要な2つの方法があります。
外部ものとしてアドレスを宣言しとリンク時にそれを定義することに第2がよるところで、私が推薦する1番目は鋳物を使用しています。
両方は、例によって最も例証されます。
あなたがSND_STATに8fhを書くことにより音をつけたいと仮定します(FF26h)。
キャストを使用するコードは
There are two main ways of accessing the memory of the GB directly.The first which I recommend is using casting, where the second is by declaring an address as external and defining it at link time.Both are best illustrated by example.Suppose that you want to turn on sound by writing 8fh to SND_STAT (FF26h).The code using casts is
#define SND_STAT (UBYTE *)0xFF26U void sound_on(void) { *SND_STAT = 0x8FU; } 一方、遅いリンクを使用するコードは
while the code using late linking is
extern UBYTE snd_stat; void sound_on(void) { snd_stat = 0x8FU; }ここでsnd_statは、 リンカ引数 に-gsnd_stat=0xff26を加えることによってリンク時に定義されます。
where snd_stat is defined at link time by adding -gsnd_stat=0xff26 to the linker arguments.
最もcomonlyに使用されたハードウェアレジスタは、遅いリンク方法を使用して、 hardware.h にあらかじめ定義されます。 このコード
The most comonly used hardware registers are pre-defined in hardware.h using the late linking method.This code
#include <hardware.h> void sound_on(void) { NR52_REG = 0x8fU; /* 'NR52_REG' maps to '_reg_0x26' or SND_STAT */ }他の2例として同じを達成します。
achieves the same as the other two examples.
前
Prev |
ホーム
Home |
次
Next |
その他
Other |
割り込み
Interrupts |