diff --git a/nes/eznes.h b/nes/eznes.h index eb2f9e5..42d32f9 100644 --- a/nes/eznes.h +++ b/nes/eznes.h @@ -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 1) { for(i=n-1;i>0;i--) { @@ -338,7 +337,7 @@ s16 handle_monster(s16 val) { return val; } -void handle_weapon(s16 val) { +void handle_weapon(u8 val) { weapon = val; snprintf(status_msg, sizeof(status_msg), "You equip a %d-level weapon.", weapon); durability = 14; /* reset durability to max limit */ @@ -366,7 +365,7 @@ s16 game() { s16 score = -208; /* score storage */ s16 item, room_sum; /* true item value */ s16 last_room = 0, last_room_clr = 0; /* last room markers */ - char ch; + u8 ch; deck_idx = 0; /* reset the deck index */ /* Prefill the deck */ for(i=0;i<13;i++) deck[i] = deck[i+13] = i+1; @@ -457,8 +456,8 @@ s16 game() { engaged++; /* increase the amount of engaged cards */ can_run = 0; /* Cannot run once engaged */ - item = room[(int)ch]; /* get the item from the room */ - room[(int)ch] = 0; /* mark the room slot as empty */ + item = room[ch]; /* get the item from the room */ + room[ch] = 0; /* mark the room slot as empty */ /* Note: We do NOT put the item back in deck. It is consumed. */ if(item < 14) { /* monster */