NeoGeo: support for consolidated C ROMs, new progress bar.

This commit is contained in:
sorgelig
2019-07-27 21:52:52 +08:00
parent c645788823
commit 0818fd837a
5 changed files with 147 additions and 111 deletions

View File

@@ -160,6 +160,10 @@ unsigned char charfont[256][8] =
{ 0x7F,0x41,0x41,0x41,0x41,0x41,0x7F,0x00 }, // 140 [0x8C] empty square
{ 0x1C,0x1C,0x3E,0x7F,0x00,0x2A,0x49,0x00 }, // 141 [0x8D] speaker
{ 0x7F,0x61,0x61,0x61,0x61,0x61,0x7F,0x00 }, // 142 [0x8E] fill 1
{ 0x7F,0x71,0x71,0x71,0x71,0x71,0x7F,0x00 }, // 143 [0x8F] fill 2
{ 0x7F,0x79,0x79,0x79,0x79,0x79,0x7F,0x00 }, // 144 [0x90] fill 3
{ 0x7F,0x7D,0x7D,0x7D,0x7D,0x7D,0x7F,0x00 }, // 145 [0x91] fill 4
};
static unsigned char tempfont[2048];

View File

@@ -1576,15 +1576,9 @@ void HandleUI(void)
printf("File selected: %s\n", SelectedPath);
if (fs_Options & SCANO_NEOGEO)
{
if (!neogeo_romset_tx(SelectedPath))
{
OsdSetTitle("Message", 0);
OsdEnable(0); // do not disable keyboard
menu_timer = GetTimer(2000);
menustate = MENU_INFO;
} else {
menustate = MENU_NONE1;
}
menustate = MENU_NONE1;
HandleUI();
neogeo_romset_tx(SelectedPath);
}
else
{

View File

@@ -1,79 +1,103 @@
// Moves bytes around so that the fix graphics are stored in a way that
// takes advantage of the SDRAM 16-bit bus
// Part of Neogeo_MiSTer
// (C) 2019 Sean 'furrtek' Gonsalves
#include "graphics.h"
#include "../../spi.h"
void spr_convert(uint8_t* buf_in, uint8_t* buf_out, unsigned int size)
{
/*
In C ROMs, a word provides two bitplanes for an 8-pixel wide line
They're used in pairs to provide 32 bits at once (all four bitplanes)
For one sprite tile, bytes are used like this: ([...] represents one 8-pixel wide line)
Even ROM Odd ROM
[ 40 41 ][ 00 01 ] [ 42 43 ][ 02 03 ]
[ 44 45 ][ 04 05 ] [ 46 47 ][ 06 07 ]
[ 48 49 ][ 08 09 ] [ 4A 4B ][ 0A 0B ]
[ 4C 4D ][ 0C 0D ] [ 4E 4F ][ 0E 0F ]
[ 50 51 ][ 10 11 ] [ 52 53 ][ 12 13 ]
... ...
The data read for a given tile line (16 pixels) is always the same, only the rendering order of the pixels can change
To take advantage of the SDRAM burst read feature, the data can be loaded so that all 16 pixels of a tile
line can be read sequentially: () are 16-bit words, [] is the 4-word burst read
[(40 41) (00 01) (42 43) (02 03)]
[(44 45) (04 05) (46 47) (06 07)]...
Word interleaving is done on the FPGA side to mix the two C ROMs data (even/odd)
In: FEDCBA9876 54321 0
Out: FEDCBA9876 15432 0
*/
for (unsigned int i = 0; i < size; i++)
buf_out[i] = buf_in[(i & 0xFFC0) | (i & 1) | ((i >> 1) & 0x1E) | (((i & 2) ^ 2) << 4)];
/*
0 <- 20
1 <- 21
2 <- 00
3 <- 01
4 <- 22
5 <- 23
6 <- 02
7 <- 03
...
00 -> 02
01 -> 03
02 -> 06
03 -> 07
...
*/
}
void fix_convert(uint8_t* buf_in, uint8_t* buf_out, unsigned int size)
{
/*
In S ROMs, a byte provides two pixels
For one fix tile, bytes are used like this: ([...] represents a pair of pixels)
[10][18][00][08]
[11][19][01][09]
[12][1A][02][0A]
[13][1B][03][0B]
[14][1C][04][0C]
[15][1D][05][0D]
[16][1E][06][0E]
[17][1F][07][0F]
The data read for a given tile line (8 pixels) is always the same
To take advantage of the SDRAM burst read feature, the data can be loaded so that all 8 pixels of a tile
line can be read sequentially: () are 16-bit words, [] is the 2-word burst read
[(10 18) (00 08)]
[(11 19) (01 09)]...
In: FEDCBA9876543210
Out: FEDCBA9876510432
*/
for (unsigned int i = 0; i < size; i++)
buf_out[i] = buf_in[(i & 0xFFE0) | ((i >> 2) & 7) | ((i & 1) << 3) | (((i & 2) << 3) ^ 0x10)];
}
// Moves bytes around so that the fix graphics are stored in a way that
// takes advantage of the SDRAM 16-bit bus
// Part of Neogeo_MiSTer
// (C) 2019 Sean 'furrtek' Gonsalves
#include "graphics.h"
void spr_convert(uint8_t* buf_in, uint8_t* buf_out, unsigned int size)
{
/*
In C ROMs, a word provides two bitplanes for an 8-pixel wide line
They're used in pairs to provide 32 bits at once (all four bitplanes)
For one sprite tile, bytes are used like this: ([...] represents one 8-pixel wide line)
Even ROM Odd ROM
[ 40 41 ][ 00 01 ] [ 42 43 ][ 02 03 ]
[ 44 45 ][ 04 05 ] [ 46 47 ][ 06 07 ]
[ 48 49 ][ 08 09 ] [ 4A 4B ][ 0A 0B ]
[ 4C 4D ][ 0C 0D ] [ 4E 4F ][ 0E 0F ]
[ 50 51 ][ 10 11 ] [ 52 53 ][ 12 13 ]
... ...
The data read for a given tile line (16 pixels) is always the same, only the rendering order of the pixels can change
To take advantage of the SDRAM burst read feature, the data can be loaded so that all 16 pixels of a tile
line can be read sequentially: () are 16-bit words, [] is the 4-word burst read
[(40 41) (00 01) (42 43) (02 03)]
[(44 45) (04 05) (46 47) (06 07)]...
Word interleaving is done on the FPGA side to mix the two C ROMs data (even/odd)
In: FEDCBA9876 54321 0
Out: FEDCBA9876 15432 0
*/
for (unsigned int i = 0; i < size; i++)
buf_out[i] = buf_in[(i & 0xFFC0) | (i & 1) | ((i >> 1) & 0x1E) | (((i & 2) ^ 2) << 4)];
/*
0 <- 20
1 <- 21
2 <- 00
3 <- 01
4 <- 22
5 <- 23
6 <- 02
7 <- 03
...
00 -> 02
01 -> 03
02 -> 06
03 -> 07
...
*/
}
void spr_convert_dbl(uint8_t* buf_in, uint8_t* buf_out, unsigned int size)
{
/*
In C ROMs, a word provides two bitplanes for an 8-pixel wide line
They're used in pairs to provide 32 bits at once (all four bitplanes)
For one sprite tile, bytes are used like this: ([...] represents one 8-pixel wide line)
ROM
[ 42 43 ][ 02 03 ][ 40 41 ][ 00 01 ]
[ 46 47 ][ 06 07 ][ 44 45 ][ 04 05 ]
[ 4A 4B ][ 0A 0B ][ 48 49 ][ 08 09 ]
[ 4E 4F ][ 0E 0F ][ 4C 4D ][ 0C 0D ]
[ 52 53 ][ 12 13 ][ 50 51 ][ 10 11 ]
... ...
The data read for a given tile line (16 pixels) is always the same, only the rendering order of the pixels can change
To take advantage of the SDRAM burst read feature, the data can be loaded so that all 16 pixels of a tile
line can be read sequentially: () are 16-bit words, [] is the 4-word burst read
[(40 41) (00 01) (42 43) (02 03)]
[(44 45) (04 05) (46 47) (06 07)]...
This is consolidated version of C ROM with both parts in one.
*/
for (unsigned int i = 0; i < size; i++)
buf_out[i] = buf_in[(i & 0xFF80) | ((i ^ 2) & 3) | ((i >> 1) & 0x3C) | (((i & 4) ^ 4) << 4)];
}
void fix_convert(uint8_t* buf_in, uint8_t* buf_out, unsigned int size)
{
/*
In S ROMs, a byte provides two pixels
For one fix tile, bytes are used like this: ([...] represents a pair of pixels)
[10][18][00][08]
[11][19][01][09]
[12][1A][02][0A]
[13][1B][03][0B]
[14][1C][04][0C]
[15][1D][05][0D]
[16][1E][06][0E]
[17][1F][07][0F]
The data read for a given tile line (8 pixels) is always the same
To take advantage of the SDRAM burst read feature, the data can be loaded so that all 8 pixels of a tile
line can be read sequentially: () are 16-bit words, [] is the 2-word burst read
[(10 18) (00 08)]
[(11 19) (01 09)]...
In: FEDCBA9876543210
Out: FEDCBA9876510432
*/
for (unsigned int i = 0; i < size; i++)
buf_out[i] = buf_in[(i & 0xFFE0) | ((i >> 2) & 7) | ((i & 1) << 3) | (((i & 2) << 3) ^ 0x10)];
}

View File

@@ -1,4 +1,5 @@
#include "../../file_io.h"
void spr_convert(uint8_t* buf_in, uint8_t* buf_out, unsigned int size);
void fix_convert(uint8_t* buf_in, uint8_t* buf_out, unsigned int size);
#include "../../file_io.h"
void spr_convert(uint8_t* buf_in, uint8_t* buf_out, unsigned int size);
void spr_convert_dbl(uint8_t* buf_in, uint8_t* buf_out, unsigned int size);
void fix_convert(uint8_t* buf_in, uint8_t* buf_out, unsigned int size);

View File

@@ -10,26 +10,30 @@
#include "../../sxmlc.h"
#include "../../user_io.h"
#include "../../osd.h"
#include "../../menu.h"
bool checked_ok;
void neogeo_osd_progress(const char* name, unsigned int progress) {
char progress_buf[30 + 1];
static char pchar[] = { 0x20, 0x8C, 0x8E, 0x8F, 0x90, 0x91, 0x7F };
static void neogeo_osd_progress(const char* name, unsigned int progress)
{
static char progress_buf[64];
memset(progress_buf, ' ', sizeof(progress_buf));
// OSD width - width of white bar on the left - max width of file name = 32 - 2 - 11 - 1 = 18
progress = (progress * 18) >> 8;
if (progress >= 18) progress = 18;
progress = (progress * 126) >> 8;
if (progress >= 126) progress = 126;
// ##############################
// NNNNNNNNNNN-PPPPPPPPPPPPPPPPPP
memset(progress_buf, ' ', 30);
memcpy(progress_buf, name, strlen(name));
for (unsigned int i = 0; i < progress; i++)
progress_buf[12 + i] = 0x7f;
progress_buf[30] = 0;
char c = pchar[progress % 7];
progress /= 7;
OsdWrite(OsdGetSize() - 2);
OsdWrite(OsdGetSize() - 1, progress_buf, 0);
strcpy(progress_buf, name);
char *buf = progress_buf + strlen(progress_buf);
*buf++ = ' ';
for (unsigned int i = 0; i < progress; i++) buf[1 + i] = (i < (progress-1)) ? 0x7F : c;
buf[19] = 0;
Info(progress_buf);
}
int neogeo_file_tx(const char* romset, const char* name, unsigned char neo_file_type, unsigned char index, unsigned long offset, unsigned long size)
@@ -59,7 +63,7 @@ int neogeo_file_tx(const char* romset, const char* name, unsigned char neo_file_
printf("Loading %s (offset %lu, size %lu, type %u) with index 0x%02X\n", name, offset, bytes2send, neo_file_type, index);
// Put pairs of bitplanes in the correct order for the core
if (neo_file_type == NEO_FILE_SPR) index ^= 1;
if (neo_file_type == NEO_FILE_SPR && index != 15) index ^= 1;
// set index byte
user_io_set_index(index);
@@ -69,6 +73,8 @@ int neogeo_file_tx(const char* romset, const char* name, unsigned char neo_file_
spi8(0xff);
DisableFpga();
int progress = -1;
while (bytes2send)
{
uint16_t chunk = (bytes2send > sizeof(buf)) ? sizeof(buf) : bytes2send;
@@ -87,7 +93,10 @@ int neogeo_file_tx(const char* romset, const char* name, unsigned char neo_file_
if (neo_file_type == NEO_FILE_FIX)
fix_convert(buf, buf_out, sizeof(buf_out));
else if (neo_file_type == NEO_FILE_SPR)
spr_convert(buf, buf_out, sizeof(buf_out));
{
if(index == 15) spr_convert_dbl(buf, buf_out, sizeof(buf_out));
else spr_convert(buf, buf_out, sizeof(buf_out));
}
clock_gettime(CLOCK_REALTIME, &ts1); // DEBUG PROFILING
spi_write(buf_out, chunk, 1);
@@ -102,8 +111,12 @@ int neogeo_file_tx(const char* romset, const char* name, unsigned char neo_file_
}
DisableFpga();
neogeo_osd_progress(name, 256 - ((bytes2send << 8) / size));
int new_progress = 256 - ((((uint64_t)bytes2send) << 8)/size);
if (progress != new_progress)
{
progress = new_progress;
neogeo_osd_progress(name, progress);
}
bytes2send -= chunk;
}
@@ -243,7 +256,7 @@ static int xml_check_files(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, c
else {
printf("Missing %s\n", full_path);
sprintf(full_path, "Missing %s !", node->attributes[i].value);
OsdWrite(OsdGetSize() - 1, full_path, 0);
Info(full_path);
return false;
}
}