Skip to content

Commit 404983f

Browse files
committed
Added option to disable 8-sprite per line limit in NES
1 parent 34d5efe commit 404983f

File tree

7 files changed

+47
-17
lines changed

7 files changed

+47
-17
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Retro-Go is composed of a launcher and several emulators.
2020
- Fastforward
2121
- Customizable launcher
2222
- PNG cover art
23+
- And more!
2324

2425
# Screenshot
2526
![Preview](https://raw.githubusercontent.com/ducalex/retro-go/master/assets/screenshot.jpg)

components/odroid/odroid_overlay.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void odroid_overlay_draw_dialog(char *header, odroid_dialog_choice_t *options, i
165165
uint16_t fg, bg, color;
166166
for (int i = 0; i < options_count; i++)
167167
{
168-
color = options[i].enabled ? box_text_color : C_GRAY;
168+
color = options[i].enabled == 1 ? box_text_color : C_GRAY;
169169
fg = (i == sel) ? box_color : color;
170170
bg = (i == sel) ? color : box_color;
171171
odroid_overlay_draw_text(x, y + i * ODROID_FONT_HEIGHT, width * ODROID_FONT_WIDTH, rows[i], fg, bg);
@@ -251,6 +251,11 @@ int odroid_overlay_dialog(char *header, odroid_dialog_choice_t *options, int opt
251251
}
252252
if (sel_old != sel)
253253
{
254+
int dir = sel - sel_old;
255+
while (options[sel].enabled == -1 && sel_old != sel)
256+
{
257+
sel = (sel + dir) % options_count;
258+
}
254259
odroid_overlay_draw_dialog(header, options, options_count, sel);
255260
sel_old = sel;
256261
}

components/odroid/odroid_overlay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct odroid_dialog_choice {
2929
int id;
3030
char label[32];
3131
char value[16];
32-
bool enabled;
32+
int8_t enabled;
3333
bool (*update_cb)(odroid_dialog_choice_t *, odroid_dialog_event_t);
3434
};
3535

nesemu-go/components/nofrendo/nes/nes_ppu.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ void ppu_displaysprites(bool display)
6363
ppu.drawsprites = display;
6464
}
6565

66+
void ppu_limitsprites(bool limit)
67+
{
68+
ppu.limitsprites = limit;
69+
}
70+
6671
void ppu_setcontext(ppu_t *src_ppu)
6772
{
6873
int nametab[4];
@@ -136,6 +141,7 @@ ppu_t *ppu_create(void)
136141
temp->vromswitch = NULL;
137142
temp->vram_present = false;
138143
temp->drawsprites = true;
144+
temp->limitsprites = true;
139145

140146
ppu_setnpal(temp, 0); // Set default palette
141147

@@ -875,7 +881,7 @@ static void IRAM_ATTR ppu_renderoam(uint8 *vidbuf, int scanline)
875881
ppu_setstrike(strike_pixel);
876882

877883
/* maximum of 8 sprites per scanline */
878-
if (++spritecount == PPU_MAXSPRITE)
884+
if (++spritecount == PPU_MAXSPRITE && ppu.limitsprites)
879885
{
880886
ppu.stat |= PPU_STATF_MAXSPRITE;
881887
break;

nesemu-go/components/nofrendo/nes/nes_ppu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ typedef struct ppu_s
115115

116116
bool vram_present;
117117
bool drawsprites;
118+
bool limitsprites;
118119
} ppu_t;
119120

120121
typedef struct
@@ -165,6 +166,7 @@ extern void ppu_setnpal(ppu_t *src_ppu, int n);
165166
extern void ppu_dumppattern(bitmap_t *bmp, int table_num, int x_loc, int y_loc, int col);
166167
extern void ppu_dumpoam(bitmap_t *bmp, int x_loc, int y_loc);
167168
extern void ppu_displaysprites(bool display);
169+
extern void ppu_limitsprites(bool limit);
168170

169171
#endif /* _NES_PPU_H_ */
170172

nesemu-go/main/main.c

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#define PIXEL_MASK 0x3F
2020

21+
#define NVS_KEY_LIMIT_SPRITES "limitspr"
22+
2123
static char* romPath;
2224
static char* romData;
2325
static size_t romSize;
@@ -123,6 +125,7 @@ void osd_loadstate()
123125
LoadState();
124126
}
125127

128+
ppu_limitsprites(odroid_settings_int32_get(NVS_KEY_LIMIT_SPRITES, 1));
126129
ppu_setnpal(nes_getcontextptr()->ppu, odroid_settings_Palette_get());
127130
}
128131

@@ -199,17 +202,31 @@ void IRAM_ATTR osd_blitscreen(bitmap_t *bmp)
199202
}
200203

201204

202-
static bool more_settings_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event)
205+
bool sprite_limit_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event)
206+
{
207+
int val = odroid_settings_int32_get(NVS_KEY_LIMIT_SPRITES, 1);
208+
209+
if (event == ODROID_DIALOG_PREV || event == ODROID_DIALOG_NEXT) {
210+
val = val ? 0 : 1;
211+
odroid_settings_int32_set(NVS_KEY_LIMIT_SPRITES, val);
212+
ppu_limitsprites(val);
213+
}
214+
215+
strcpy(option->value, val ? "On " : "Off");
216+
217+
return event == ODROID_DIALOG_ENTER;
218+
}
219+
220+
static bool advanced_settings_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event)
203221
{
204222
if (event == ODROID_DIALOG_ENTER) {
205-
odroid_dialog_choice_t choices[] = {
206-
{1, "APU FC IRQ", "Auto", 1, NULL},
207-
{2, "Region", "NTSC", 1, NULL},
208-
{2, "Sprite Limit", "On", 1, NULL}, // PPU_MAXSPRITE
209-
{3, "", "", 1, NULL},
210-
{0, "Reset all", "", 1, NULL},
223+
odroid_dialog_choice_t options[] = {
224+
{1, "Region", "NTSC", 1, NULL},
225+
{2, "Sprite limit", "On ", 1, &sprite_limit_cb},
226+
// {4, "", "", 1, NULL},
227+
//{0, "Reset all", "", 1, NULL},
211228
};
212-
odroid_overlay_dialog("Compatibility", choices, 5, 0);
229+
odroid_overlay_dialog("Advanced", options, sizeof(options) / sizeof(options[0]), 0);
213230
}
214231
return false;
215232
}
@@ -264,11 +281,10 @@ void osd_getinput(void)
264281
else if (joystick.values[ODROID_INPUT_VOLUME]) {
265282
odroid_dialog_choice_t options[] = {
266283
{100, "Palette", "Default", 1, &palette_update_cb},
267-
// {100, "", "", 0, NULL},
268-
// {100, "APU FC IRQ", "Auto", 1, NULL},
269-
// {200, "More settings...", "", 1, &more_settings_cb},
284+
{101, "", "", -1, NULL},
285+
{101, "More...", "", 1, &advanced_settings_cb},
270286
};
271-
odroid_overlay_game_settings_menu(options, 1);
287+
odroid_overlay_game_settings_menu(options, sizeof(options) / sizeof(options[0]));
272288
}
273289

274290
// A

retro-go/main/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void retro_loop()
222222
odroid_dialog_choice_t choices[] = {
223223
{0, "Date", COMPILEDATE, 1, NULL},
224224
{0, "Commit", GITREV, 1, NULL},
225-
{0, "", "", 0, NULL},
225+
{0, "", "", -1, NULL},
226226
{1, "Reboot to firmware", "", 1, NULL},
227227
{0, "Close", "", 1, NULL},
228228
};
@@ -237,7 +237,7 @@ void retro_loop()
237237
else if (joystick.values[ODROID_INPUT_VOLUME]) {
238238
last_key = ODROID_INPUT_VOLUME;
239239
odroid_dialog_choice_t choices[] = {
240-
{0, "---", "", 0, NULL},
240+
{0, "---", "", -1, NULL},
241241
{0, "Color theme", "1/10", 1, &color_shift_cb},
242242
{0, "Font size", "Small", 1, &font_size_cb},
243243
{0, "Show cover", "Yes", 1, &show_cover_cb},

0 commit comments

Comments
 (0)