Offloaded some NES routines to eznes.h
This commit is contained in:
+14
-14
@@ -52,7 +52,7 @@ void ppu_on() {
|
||||
PPU.mask |= 0x1A;
|
||||
}
|
||||
|
||||
int joy_input_wait() {
|
||||
u8 joy_input_wait() {
|
||||
u8 last_joy = 0, joy, pressed;
|
||||
/* wait until the previous key is released */
|
||||
while(joy_read(JOY_1));
|
||||
@@ -88,7 +88,7 @@ void init_palette(u8 bg, u8 c1, u8 c2, u8 c3, u8 c4) {
|
||||
|
||||
/* 4x4 char block colorization method (palette is 0 to 3) */
|
||||
void colorxy(u8 x, u8 y, u8 palette) {
|
||||
unsigned int addr;
|
||||
u16 addr;
|
||||
u8 attr_byte;
|
||||
addr = 0x23C0 + ((y >> 2) << 3) + (x >> 2);
|
||||
attr_byte = palette | (palette << 2) | (palette << 4) | (palette << 6);
|
||||
@@ -100,25 +100,25 @@ void colorxy(u8 x, u8 y, u8 palette) {
|
||||
|
||||
/* Sound section */
|
||||
|
||||
unsigned int get_timer_by_freq(int freq) {
|
||||
return (unsigned int) ((CPU / 16 / freq) - 1);
|
||||
u16 get_timer_by_freq(u16 freq) {
|
||||
return (u16) ((CPU / 16 / freq) - 1);
|
||||
}
|
||||
|
||||
void play_pulse(u8 idx, unsigned int freq, u8 len) {
|
||||
unsigned int tm = get_timer_by_freq(freq);
|
||||
void play_pulse(u8 idx, u16 freq, u8 len) {
|
||||
u16 tm = get_timer_by_freq(freq);
|
||||
if(len > 31) len = 31;
|
||||
if(idx > 1) idx = 0;
|
||||
APU.pulse[idx].period_low = tm & 255;
|
||||
APU.pulse[idx].len_period_high = (tm >> 8) | (len << 3);
|
||||
}
|
||||
|
||||
void play_jingle(unsigned int n1f1,
|
||||
unsigned int n1f2,
|
||||
unsigned int n2f1,
|
||||
unsigned int n2f2,
|
||||
unsigned int n3f1,
|
||||
unsigned int n3f2) {
|
||||
unsigned int i, dl = 2000;
|
||||
void play_jingle(u16 n1f1,
|
||||
u16 n1f2,
|
||||
u16 n2f1,
|
||||
u16 n2f2,
|
||||
u16 n3f1,
|
||||
u16 n3f2) {
|
||||
u16 i, dl = 2000;
|
||||
play_pulse(0, n1f1, 2);
|
||||
play_pulse(1, n1f2, 2);
|
||||
for(i=0;i<dl;++i);
|
||||
@@ -165,7 +165,7 @@ void wait_for_start() {
|
||||
/* randomize until Start is pressed */
|
||||
void wait_for_start_rand() {
|
||||
u8 joy;
|
||||
unsigned int entropy = rand();
|
||||
u16 entropy = rand();
|
||||
while(1) {
|
||||
++entropy;
|
||||
joy = joy_read(JOY_1);
|
||||
|
||||
Reference in New Issue
Block a user