[Atsoft-commit] CVS: dcgen/main cpu68k.c,1.1.1.1,1.2 generator.c,1.8,1.9 ta_text.c,1.2,1.3 ui-kos.c,
Brought to you by:
atani
|
From: Mike D. <at...@us...> - 2002-02-10 22:41:09
|
Update of /cvsroot/atsoft/dcgen/main
In directory usw-pr-cvs1:/tmp/cvs-serv30551/main
Modified Files:
cpu68k.c generator.c ta_text.c ui-kos.c
Log Message:
This is the preliminary pvr_* API upgrade. There are known issues with
this new port. Most notably is that palettes now work again but the colors
are totally wrong (again?) and when using non-paletted txrs the screen
shifts left by about 40 pixels or so... DP is looking into fixing this in
KOS soon.
Index: cpu68k.c
===================================================================
RCS file: /cvsroot/atsoft/dcgen/main/cpu68k.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** cpu68k.c 18 Jan 2002 02:42:47 -0000 1.1.1.1
--- cpu68k.c 10 Feb 2002 22:41:06 -0000 1.2
***************
*** 179,187 ****
void cpu68k_printipc(t_ipc * ipc)
{
! printf("IPC @ 0x%p\n", ipc);
! printf(" opcode: %04X, uses %X set %X\n", ipc->opcode, ipc->used,
! ipc->set);
! printf(" src = %08X\n", ipc->src);
! printf(" dst = %08X\n", ipc->dst);
}
--- 179,187 ----
void cpu68k_printipc(t_ipc * ipc)
{
! LOG_VERBOSE(("IPC @ 0x%p\n", ipc));
! LOG_VERBOSE((" opcode: %04X, uses %X set %X\n", ipc->opcode, ipc->used,
! ipc->set));
! LOG_VERBOSE((" src = %08X\n", ipc->src));
! LOG_VERBOSE((" dst = %08X\n", ipc->dst));
}
***************
*** 344,348 ****
instrs++;
if (instrs > size) {
! if (size > 10000)
ui_err("Something has gone seriously wrong @ %08X", pc);
size += 16;
--- 344,348 ----
instrs++;
if (instrs > size) {
! if (size > 100000)
ui_err("Something has gone seriously wrong @ %08X", pc);
size += 16;
***************
*** 400,411 ****
int i;
! printf("in cpu68k_reset [top]\n");
! printf("in cpu68k_reset [clear ram]\n");
memset(cpu68k_ram, 0, 0x10000);
! printf("in cpu68k_reset [set initial pc]\n");
regs68k.pc = fetchlong(4);
regs68k.regs[15] = fetchlong(0);
! printf("in cpu68k_reset PC: %08x REG[15]: %08x\n", regs68k.pc, regs68k.regs[15]);
regs68k.sr.sr_int = 0;
regs68k.sr.sr_struct.s = 1; /* Supervisor mode */
--- 400,411 ----
int i;
! LOG_VERBOSE(("in cpu68k_reset [top]\n"));
! LOG_VERBOSE(("in cpu68k_reset [clear ram]\n"));
memset(cpu68k_ram, 0, 0x10000);
! LOG_VERBOSE(("in cpu68k_reset [set initial pc]\n"));
regs68k.pc = fetchlong(4);
regs68k.regs[15] = fetchlong(0);
! LOG_VERBOSE(("in cpu68k_reset PC: %08x REG[15]: %08x\n", regs68k.pc, regs68k.regs[15]));
regs68k.sr.sr_int = 0;
regs68k.sr.sr_struct.s = 1; /* Supervisor mode */
***************
*** 414,418 ****
cpu68k_frames = 0; /* Number of frames */
! printf("in cpu68k_reset [clean ipclist]\n");
for (i = 0; i < LEN_IPCLISTTABLE; i++) {
if (ipclist[i]) {
--- 414,418 ----
cpu68k_frames = 0; /* Number of frames */
! LOG_VERBOSE(("in cpu68k_reset [clean ipclist]\n"));
for (i = 0; i < LEN_IPCLISTTABLE; i++) {
if (ipclist[i]) {
***************
*** 421,425 ****
}
}
! printf("in cpu68k_reset [end]\n");
}
--- 421,425 ----
}
}
! LOG_VERBOSE(("in cpu68k_reset [end]\n"));
}
Index: generator.c
===================================================================
RCS file: /cvsroot/atsoft/dcgen/main/generator.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** generator.c 6 Feb 2002 07:11:20 -0000 1.8
--- generator.c 10 Feb 2002 22:41:06 -0000 1.9
***************
*** 42,53 ****
void gen_setupcartinfo(void);
- static char thing[] = ("\n\nIt's the year 2000 is there anyone out there?\n"
- "\nIf you're from another planet put your hand in the "
- "air, say yeah!\n\n");
-
/*** Program entry point ***/
extern uint8 romdisk_boot[];
int main(int argc, char *argv[])
{
--- 42,55 ----
void gen_setupcartinfo(void);
/*** Program entry point ***/
extern uint8 romdisk_boot[];
+ pvr_init_params_t params =
+ {
+ {PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0, },
+ 512*1024
+ };
+
int main(int argc, char *argv[])
{
***************
*** 62,70 ****
return 1;
}
! kos_init_all(IRQ_ENABLE|THD_ENABLE|TA_ENABLE, romdisk_boot);
! #ifdef PAL_DREAMCAST
! vid_init(DM_640x480_PAL_IL, PM_RGB565);
! ta_init_defaults();
! #endif
init_ta_text();
--- 64,73 ----
return 1;
}
! kos_init_all(IRQ_ENABLE|THD_ENABLE, romdisk_boot);
! pvr_init(¶ms);
! //#ifdef PAL_DREAMCAST
! // vid_init(DM_640x480_PAL_IL, PM_RGB565);
! // ta_init_defaults();
! //#endif
init_ta_text();
***************
*** 121,127 ****
void update_progress(const uint8 *romname, uint32 total, uint32 current, uint8 *info, int abortable )
{
! ta_begin_render();
pvr_dummy_poly(TA_OPAQUE);
! ta_commit_eol();
draw_poly_strf(40.0f, 224.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "%s %s", info, romname);
draw_poly_strf(40.0f, 250.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "%u/%u", current, total);
--- 124,133 ----
void update_progress(const uint8 *romname, uint32 total, uint32 current, uint8 *info, int abortable )
{
! pvr_wait_ready();
! pvr_scene_begin();
! pvr_list_begin(PVR_LIST_OP_POLY);
pvr_dummy_poly(TA_OPAQUE);
! pvr_list_finish();
! pvr_list_begin(PVR_LIST_TR_POLY);
draw_poly_strf(40.0f, 224.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "%s %s", info, romname);
draw_poly_strf(40.0f, 250.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "%u/%u", current, total);
***************
*** 130,135 ****
draw_poly_strf(40.0f, 400.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "PRESS B TO CANCEL LOADING");
}
! ta_commit_eol();
! ta_finish_frame();
}
--- 136,141 ----
draw_poly_strf(40.0f, 400.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "PRESS B TO CANCEL LOADING");
}
! pvr_list_finish();
! pvr_scene_finish();
}
***************
*** 149,153 ****
/* Check extension is not wrong */
extension = filename + strlen(filename) - 3;
! if (!strcasecmp(extension, "smd"))
{
LOG_VERBOSE(("attempting to recognize as SMD file\n"));
--- 155,159 ----
/* Check extension is not wrong */
extension = filename + strlen(filename) - 3;
! if (!stricmp(extension, "smd"))
{
LOG_VERBOSE(("attempting to recognize as SMD file\n"));
***************
*** 155,159 ****
}
! if ((file = fs_open(filename, O_RDONLY)) == -1) {
ui_err("unable to open file.\n");
return ("Unable to open file.");
--- 161,166 ----
}
! if ((file = fs_open(filename, O_RDONLY)) == -1)
! {
ui_err("unable to open file.\n");
return ("Unable to open file.");
***************
*** 173,183 ****
/* is this icky? */
if ((p = strrchr(filename, '/')) == NULL &&
! (p = strrchr(filename, '\\')) == NULL) {
snprintf(gen_leafname, sizeof(gen_leafname), "%s", filename);
! } else {
snprintf(gen_leafname, sizeof(gen_leafname), "%s", p + 1);
}
! if ((p = strrchr(gen_leafname, '.')) != NULL) {
! if ((!strcasecmp(p, ".smd")) || (!strcasecmp(p, ".bin")))
*p = '\0';
}
--- 180,194 ----
/* is this icky? */
if ((p = strrchr(filename, '/')) == NULL &&
! (p = strrchr(filename, '\\')) == NULL)
! {
snprintf(gen_leafname, sizeof(gen_leafname), "%s", filename);
! }
! else
! {
snprintf(gen_leafname, sizeof(gen_leafname), "%s", p + 1);
}
! if ((p = strrchr(gen_leafname, '.')) != NULL)
! {
! if ((!stricmp(p, ".smd")) || (!stricmp(p, ".bin")))
*p = '\0';
}
***************
*** 185,189 ****
snprintf(gen_leafname, sizeof(gen_leafname), "rom");
! cpu68k_rom = &genesis_rom;
gen_freerom = 0;
memset(cpu68k_rom, 0, cpu68k_romlen);
--- 196,200 ----
snprintf(gen_leafname, sizeof(gen_leafname), "rom");
! cpu68k_rom = (uint8 *)&genesis_rom;
gen_freerom = 0;
memset(cpu68k_rom, 0, cpu68k_romlen);
***************
*** 194,198 ****
if(imagetype == 2)
fs_seek(file, 512, SEEK_SET);
! do {
update_progress(gen_leafname, cpu68k_romlen, cpu68k_romlen-bytesleft, "Now Loading:", 1);
if ((bytes = fs_read(file, buffer, 0x4000)) <= 0)
--- 205,210 ----
if(imagetype == 2)
fs_seek(file, 512, SEEK_SET);
! do
! {
update_progress(gen_leafname, cpu68k_romlen, cpu68k_romlen-bytesleft, "Now Loading:", 1);
if ((bytes = fs_read(file, buffer, 0x4000)) <= 0)
***************
*** 210,214 ****
/* convert to standard BIN file format */
! switch (imagetype) {
case 1: /* BIN */
break;
--- 222,227 ----
/* convert to standard BIN file format */
! switch (imagetype)
! {
case 1: /* BIN */
break;
***************
*** 242,246 ****
gen_setupcartinfo();
! if (gen_autodetect) {
vdp_pal = (!gen_cartinfo.flag_usa && !gen_cartinfo.flag_japan &&
gen_cartinfo.flag_europe) ? 1 : 0;
--- 255,260 ----
gen_setupcartinfo();
! if (gen_autodetect)
! {
vdp_pal = (!gen_cartinfo.flag_usa && !gen_cartinfo.flag_japan &&
gen_cartinfo.flag_europe) ? 1 : 0;
***************
*** 252,258 ****
while(!ui_check_cond(CONT_START))
{
! ta_begin_render();
pvr_dummy_poly(TA_OPAQUE);
! ta_commit_eol();
draw_poly_strf(40.0f, 200.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "Loaded:");
draw_poly_strf(40.0f, 224.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "DOMESTIC: %s", gen_cartinfo.name_domestic);
--- 266,275 ----
while(!ui_check_cond(CONT_START))
{
! pvr_wait_ready();
! pvr_scene_begin();
! pvr_list_begin(PVR_LIST_OP_POLY);
pvr_dummy_poly(TA_OPAQUE);
! pvr_list_finish();
! pvr_list_begin(PVR_LIST_TR_POLY);
draw_poly_strf(40.0f, 200.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "Loaded:");
draw_poly_strf(40.0f, 224.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "DOMESTIC: %s", gen_cartinfo.name_domestic);
***************
*** 265,270 ****
}
draw_poly_strf(40.0f, 400.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "PRESS START");
! ta_commit_eol();
! ta_finish_frame();
}
gen_quit = 0;
--- 282,287 ----
}
draw_poly_strf(40.0f, 400.0f, 100.0f, 1.0f, 1.0f, 1.0f, 1.0f, "PRESS START");
! pvr_list_finish();
! pvr_scene_finish();
}
gen_quit = 0;
***************
*** 283,291 ****
gen_nicetext(gen_cartinfo.name_domestic, (char *)(cpu68k_rom + 0x120), 48);
gen_nicetext(gen_cartinfo.name_overseas, (char *)(cpu68k_rom + 0x150), 48);
! if (cpu68k_rom[0x180] == 'G' && cpu68k_rom[0x181] == 'M') {
gen_cartinfo.prodtype = pt_game;
! } else if (cpu68k_rom[0x180] == 'A' && cpu68k_rom[0x181] == 'I') {
gen_cartinfo.prodtype = pt_education;
! } else {
gen_cartinfo.prodtype = pt_unknown;
}
--- 300,313 ----
gen_nicetext(gen_cartinfo.name_domestic, (char *)(cpu68k_rom + 0x120), 48);
gen_nicetext(gen_cartinfo.name_overseas, (char *)(cpu68k_rom + 0x150), 48);
! if (cpu68k_rom[0x180] == 'G' && cpu68k_rom[0x181] == 'M')
! {
gen_cartinfo.prodtype = pt_game;
! }
! else if (cpu68k_rom[0x180] == 'A' && cpu68k_rom[0x181] == 'I')
! {
gen_cartinfo.prodtype = pt_education;
! }
! else
! {
gen_cartinfo.prodtype = pt_unknown;
}
***************
*** 294,298 ****
cpu68k_romlen - 0x200);
gen_nicetext(gen_cartinfo.memo, (char *)(cpu68k_rom + 0x1C8), 28);
! for (i = 0x1f0; i < 0x1ff; i++) {
if (cpu68k_rom[i] == 'J')
gen_cartinfo.flag_japan = 1;
--- 316,321 ----
cpu68k_romlen - 0x200);
gen_nicetext(gen_cartinfo.memo, (char *)(cpu68k_rom + 0x1C8), 28);
! for (i = 0x1f0; i < 0x1ff; i++)
! {
if (cpu68k_rom[i] == 'J')
gen_cartinfo.flag_japan = 1;
***************
*** 302,312 ****
gen_cartinfo.flag_europe = 1;
}
! if (cpu68k_rom[0x1f0] >= '1' && cpu68k_rom[0x1f0] <= '9') {
gen_cartinfo.hardware = cpu68k_rom[0x1f0] - '0';
! } else if (cpu68k_rom[0x1f0] >= 'A' && cpu68k_rom[0x1f0] <= 'F') {
gen_cartinfo.hardware = cpu68k_rom[0x1f0] - 'A' + 10;
}
p = gen_cartinfo.country;
! for (i = 0x1f0; i < 0x200; i++) {
if (cpu68k_rom[i] != 0 && cpu68k_rom[i] != 32)
*p++ = cpu68k_rom[i];
--- 325,339 ----
gen_cartinfo.flag_europe = 1;
}
! if (cpu68k_rom[0x1f0] >= '1' && cpu68k_rom[0x1f0] <= '9')
! {
gen_cartinfo.hardware = cpu68k_rom[0x1f0] - '0';
! }
! else if (cpu68k_rom[0x1f0] >= 'A' && cpu68k_rom[0x1f0] <= 'F')
! {
gen_cartinfo.hardware = cpu68k_rom[0x1f0] - 'A' + 10;
}
p = gen_cartinfo.country;
! for (i = 0x1f0; i < 0x200; i++)
! {
if (cpu68k_rom[i] != 0 && cpu68k_rom[i] != 32)
*p++ = cpu68k_rom[i];
***************
*** 325,331 ****
flag = 0; /* set if within word, e.g. make lowercase */
i = size; /* maximum number of chars in input */
! while ((c = *in++) && --i > 0) {
! if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z') {
! if (!flag) {
/* make uppercase */
flag = 1;
--- 352,361 ----
flag = 0; /* set if within word, e.g. make lowercase */
i = size; /* maximum number of chars in input */
! while ((c = *in++) && --i > 0)
! {
! if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
! {
! if (!flag)
! {
/* make uppercase */
flag = 1;
***************
*** 334,338 ****
else
*out++ = c;
! } else {
/* make lowercase */
if (isupper(c))
--- 364,370 ----
else
*out++ = c;
! }
! else
! {
/* make lowercase */
if (isupper(c))
***************
*** 341,349 ****
*out++ = c;
}
! } else if (c == ' ') {
if (flag)
*out++ = c;
flag = 0;
! } else if (isprint(c) && c != '\t') {
flag = 0;
*out++ = c;
--- 373,385 ----
*out++ = c;
}
! }
! else if (c == ' ')
! {
if (flag)
*out++ = c;
flag = 0;
! }
! else if (isprint(c) && c != '\t')
! {
flag = 0;
*out++ = c;
***************
*** 361,370 ****
uint16 checksum = 0;
! if (length & 1) {
length &= ~1;
LOG_CRITICAL(("checksum routines given odd length (%d)", length));
}
! for (; length; length -= 2, start += 2) {
checksum += start[0] << 8;
checksum += start[1];
--- 397,408 ----
uint16 checksum = 0;
! if (length & 1)
! {
length &= ~1;
LOG_CRITICAL(("checksum routines given odd length (%d)", length));
}
! for (; length; length -= 2, start += 2)
! {
checksum += start[0] << 8;
checksum += start[1];
***************
*** 372,373 ****
--- 410,412 ----
return checksum;
}
+
Index: ta_text.c
===================================================================
RCS file: /cvsroot/atsoft/dcgen/main/ta_text.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ta_text.c 24 Jan 2002 04:30:21 -0000 1.2
--- ta_text.c 10 Feb 2002 22:41:06 -0000 1.3
***************
*** 7,11 ****
*/
! uint32 ta_text_txr = 0;
void init_ta_text()
--- 7,13 ----
*/
! pvr_ptr_t ta_text_txr = 0;
! pvr_poly_hdr_t font_header;
! pvr_poly_hdr_t color_header;
void init_ta_text()
***************
*** 13,18 ****
uint16 *txr;
uint32 x, y;
! ta_text_txr = ta_txr_allocate(256*256*2);
txr = ta_txr_map(ta_text_txr);
for(y = 0; y < 8; y++)
--- 15,22 ----
uint16 *txr;
uint32 x, y;
+ pvr_poly_cxt_t tmp;
+ pvr_poly_cxt_t tmp2;
! ta_text_txr = pvr_mem_malloc(256*256*2);
txr = ta_txr_map(ta_text_txr);
for(y = 0; y < 8; y++)
***************
*** 28,36 ****
txr += 23*256;
}
}
/* Draw one font character (12x24); assumes polygon header already sent */
void draw_poly_char(float x1, float y1, float z1, float a, float r, float g, float b, int c) {
! vertex_ot_t vert;
int ix = (c % 16) * 16;
int iy = (c / 16) * 24;
--- 32,44 ----
txr += 23*256;
}
+ pvr_poly_cxt_txr(&tmp, PVR_LIST_TR_POLY, PVR_TXRFMT_ARGB1555|PVR_TXRFMT_NONTWIDDLED, 256, 256, ta_text_txr, PVR_FILTER_NONE);
+ pvr_poly_compile(&font_header, &tmp);
+ pvr_poly_cxt_col(&tmp2, PVR_LIST_TR_POLY);
+ pvr_poly_compile(&color_header, &tmp2);
}
/* Draw one font character (12x24); assumes polygon header already sent */
void draw_poly_char(float x1, float y1, float z1, float a, float r, float g, float b, int c) {
! pvr_vertex_t vert;
int ix = (c % 16) * 16;
int iy = (c / 16) * 24;
***************
*** 40,44 ****
float v2 = (iy+24) * 1.0f / 256.0f;
! vert.flags = TA_VERTEX_NORMAL;
vert.x = x1;
vert.y = y1 + 24.0f;
--- 48,52 ----
float v2 = (iy+24) * 1.0f / 256.0f;
! vert.flags = PVR_CMD_VERTEX;
vert.x = x1;
vert.y = y1 + 24.0f;
***************
*** 46,56 ****
vert.u = u1;
vert.v = v2;
! vert.dummy1 = vert.dummy2 = 0;
! vert.a = a;
! vert.r = r;
! vert.g = g;
! vert.b = b;
! vert.oa = vert.or = vert.og = vert.ob = 0.0f;
! ta_commit_vertex(&vert, sizeof(vert));
vert.x = x1;
--- 54,60 ----
vert.u = u1;
vert.v = v2;
! vert.argb = PVR_PACK_COLOR(a,r,g,b);
! vert.oargb = 0;
! pvr_prim(&vert, sizeof(vert));
vert.x = x1;
***************
*** 58,62 ****
vert.u = u1;
vert.v = v1;
! ta_commit_vertex(&vert, sizeof(vert));
vert.x = x1 + 12.0f;
--- 62,66 ----
vert.u = u1;
vert.v = v1;
! pvr_prim(&vert, sizeof(vert));
vert.x = x1 + 12.0f;
***************
*** 64,68 ****
vert.u = u2;
vert.v = v2;
! ta_commit_vertex(&vert, sizeof(vert));
vert.flags = TA_VERTEX_EOL;
--- 68,72 ----
vert.u = u2;
vert.v = v2;
! pvr_prim(&vert, sizeof(vert));
vert.flags = TA_VERTEX_EOL;
***************
*** 71,75 ****
vert.u = u2;
vert.v = v1;
! ta_commit_vertex(&vert, sizeof(vert));
}
--- 75,79 ----
vert.u = u2;
vert.v = v1;
! pvr_prim(&vert, sizeof(vert));
}
***************
*** 81,85 ****
va_list args;
char *s;
- poly_hdr_t poly;
va_start(args, fmt);
--- 85,88 ----
***************
*** 87,92 ****
va_end(args);
! ta_poly_hdr_txr(&poly, TA_TRANSLUCENT, TA_ARGB4444, 256, 256, ta_text_txr, TA_NO_FILTER);
! ta_commit_poly_hdr(&poly);
s = strbuf;
while (*s) {
--- 90,94 ----
va_end(args);
! pvr_prim(&font_header, sizeof(font_header));
s = strbuf;
while (*s) {
***************
*** 103,129 ****
float a1, float r1, float g1, float b1,
float a2, float r2, float g2, float b2) {
! poly_hdr_t poly;
! vertex_oc_t vert;
! ta_poly_hdr_col(&poly, TA_TRANSLUCENT);
! ta_commit_poly_hdr(&poly);
! vert.flags = TA_VERTEX_NORMAL;
vert.x = x1; vert.y = y2; vert.z = z;
! vert.a = (a1+a2)/2; vert.r = (r1+r2/2); vert.g = (g1+g2)/2; vert.b = (b1+b2)/2;
! ta_commit_vertex(&vert, sizeof(vert));
vert.y = y1;
! vert.a = a1; vert.r = r1; vert.g = g1; vert.b = b1;
! ta_commit_vertex(&vert, sizeof(vert));
vert.x = x2; vert.y = y2;
! vert.a = a2; vert.r = r2; vert.g = g2; vert.b = b2;
! ta_commit_vertex(&vert, sizeof(vert));
! vert.flags = TA_VERTEX_EOL;
vert.y = y1;
! vert.a = (a1+a2)/2; vert.r = (r1+r2/2); vert.g = (g1+g2)/2; vert.b = (b1+b2)/2;
! ta_commit_vertex(&vert, sizeof(vert));
}
--- 105,129 ----
float a1, float r1, float g1, float b1,
float a2, float r2, float g2, float b2) {
! pvr_vertex_t vert;
! pvr_prim(&color_header, sizeof(color_header));
! vert.flags = PVR_CMD_VERTEX;
vert.x = x1; vert.y = y2; vert.z = z;
! vert.argb = PVR_PACK_COLOR((a1+a2)/2, (r1+r2/2), (g1+g2)/2, (b1+b2)/2);
! pvr_prim(&vert, sizeof(vert));
vert.y = y1;
! vert.argb = PVR_PACK_COLOR(a1, r1, g1, b1);
! pvr_prim(&vert, sizeof(vert));
vert.x = x2; vert.y = y2;
! vert.argb = PVR_PACK_COLOR(a2, r2, g2, b2);
! pvr_prim(&vert, sizeof(vert));
! vert.flags = PVR_CMD_VERTEX_EOL;
vert.y = y1;
! vert.argb = PVR_PACK_COLOR((a1+a2)/2, (r1+r2/2), (g1+g2)/2, (b1+b2)/2);
! pvr_prim(&vert, sizeof(vert));
}
Index: ui-kos.c
===================================================================
RCS file: /cvsroot/atsoft/dcgen/main/ui-kos.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ui-kos.c 6 Feb 2002 07:11:20 -0000 1.3
--- ui-kos.c 10 Feb 2002 22:41:06 -0000 1.4
***************
*** 25,36 ****
char *ui_initload = NULL;
uint8 ui_vdpsimple = 0;
! uint32 txr_base;
! uint16 *txr_ptr;
! uint32 txr_base_ex;
! uint16 *txr_ptr_ex;
uint32 old_pal_fmt;
uint8 screen[512*512];
uint16 screen_ex[512*512];
!
#define PAL_FMT_RGB565 1
#define PAL_BANK_SHIFT (25)
--- 25,35 ----
char *ui_initload = NULL;
uint8 ui_vdpsimple = 0;
! pvr_ptr_t txr_base;
! pvr_ptr_t txr_base_ex;
uint32 old_pal_fmt;
uint8 screen[512*512];
uint16 screen_ex[512*512];
! pvr_poly_hdr_t screen_poly;
! pvr_poly_hdr_t screen_poly_pal;
#define PAL_FMT_RGB565 1
#define PAL_BANK_SHIFT (25)
***************
*** 91,105 ****
int ui_init(int argc, char *argv[])
{
! txr_base = ta_txr_allocate(512*512);
! txr_ptr = ta_txr_map(txr_base);
!
! txr_base_ex = ta_txr_allocate(512*512*2);
! txr_ptr_ex = ta_txr_map(txr_base_ex);
//old_pal_fmt = *(volatile uint32 *)0xa05f8108;
//*(volatile uint32 *)0xa05f8108 = PAL_FMT_RGB565;
! *(volatile unsigned int *)(0xa05f80e4) = 320/32; //stride
!
ui_initjoysticks();
return 0;
--- 90,111 ----
int ui_init(int argc, char *argv[])
{
! pvr_poly_cxt_t tmp;
! pvr_poly_cxt_t pal_tmp;
! txr_base = (pvr_ptr_t)pvr_mem_malloc(512*512);
! txr_base_ex = (pvr_ptr_t)pvr_mem_malloc(512*512*2);
//old_pal_fmt = *(volatile uint32 *)0xa05f8108;
//*(volatile uint32 *)0xa05f8108 = PAL_FMT_RGB565;
! PVR_SET(PVR_TEXTURE_MODULO, 10);
!
! pvr_poly_cxt_txr(&pal_tmp, PVR_LIST_TR_POLY, PVR_TXRFMT_PAL8BPP, 512, 512, txr_base, TA_BILINEAR_FILTER);
! #ifdef USE_TWIDDLED_TXR
! pvr_poly_cxt_txr(&tmp, PVR_LIST_TR_POLY, PVR_TXRFMT_RGB565, 512, 512, txr_base_ex, TA_BILINEAR_FILTER);
! #else
! pvr_poly_cxt_txr(&tmp, PVR_LIST_TR_POLY, PVR_TXRFMT_RGB565|PVR_TXRFMT_NONTWIDDLED, 512, 512, txr_base_ex, TA_BILINEAR_FILTER);
! #endif
! pvr_poly_compile(&screen_poly, &tmp);
! pvr_poly_compile(&screen_poly_pal, &pal_tmp);
ui_initjoysticks();
return 0;
***************
*** 108,111 ****
--- 114,119 ----
void ui_final()
{
+ pvr_mem_free(txr_base);
+ pvr_mem_free(txr_base_ex);
//*(volatile uint32 *)0xa05f8108 = old_pal_fmt;
}
***************
*** 199,220 ****
}
! void __inline palette_update(int flag)
{
int i;
! uint8 *p;
uint8 r, g, b;
for(i = 0; i < 64; i++)
{
! //if(flag || vdp_cramf[i])
! //{
! p = (uint8 *)vdp_cram + (i << 1);
! b = (p[0] & 0x0E);
! r = (p[1] & 0x0E);
! g = ((p[1] & 0xE0) >> 4);
! pals[i] = (r << 11) | (g << 6) | (b << 1);
! pals[i + 64] = (r << 10) | (g << 5) | (b) | 0x510;
! pals[i + 128] = (r << 10) | (g << 5) | (b);
! //vdp_cramf[i] = 0;
! //}
}
if(ui_rendermode != PALETTED_TXR) return;
--- 207,223 ----
}
! void __inline palette_update()
{
int i;
! uint8 *p = (uint8 *)vdp_cram;
uint8 r, g, b;
for(i = 0; i < 64; i++)
{
! b = (*p++ & 0x0E);
! r = (*p & 0x0E);
! g = ((*p++ & 0xE0) >> 4);
! pals[i] = (r << 11) | (g << 6) | (b << 1);
! pals[i + 64] = (r << 10) | (g << 5) | (b) | 0x510;
! pals[i + 128] = (r << 10) | (g << 5) | (b);
}
if(ui_rendermode != PALETTED_TXR) return;
***************
*** 270,274 ****
}
-
void ui_line(int line)
{
--- 273,276 ----
***************
*** 292,302 ****
vdp_renderline(line, p, 0);
}
! //palette_update(0);
}
void ui_endfield(void)
{
! poly_hdr_t poly;
! vertex_ot_t vert;
uint32 y_size = 240;
uint32 x_size = 320;
--- 294,303 ----
vdp_renderline(line, p, 0);
}
! palette_update();
}
void ui_endfield(void)
{
! pvr_vertex_t vert;
uint32 y_size = 240;
uint32 x_size = 320;
***************
*** 304,308 ****
uint32 u_max = (vdp_reg[12] & 1) ? 320 : 256;
! palette_update(1);
if(ui_vdpsimple)
--- 305,309 ----
uint32 u_max = (vdp_reg[12] & 1) ? 320 : 256;
! palette_update();
if(ui_vdpsimple)
***************
*** 333,359 ****
if(ui_rendermode == PALETTED_TXR)
{
- /*
- int x, y;
- for(y = 0; y < 512; y+=2)
- {
- for(x = 0; x < 512; x++)
- {
- txr_ptr[TWIDOUT(y/2, x) + (x+y)*512] =
- screen[(y*512)+x] | (screen[((y+1)*512)+x]<<8);
- }
- }
- */
txr_twiddle_copy_general(&screen[0], txr_base, 512, 512, 8);
- //txr_twiddle_copy(&screen[0], 512, 512, txr_base, 512, 512, 0);
- ta_poly_hdr_txr(&poly, TA_TRANSLUCENT, TA_PAL8BPP, 512, 512, txr_base, TA_BILINEAR_FILTER);
- poly.flags4 &= ~PAL_BANK_MASK;
- poly.flags4 |= 0 << PAL_BANK_SHIFT;
}
else
{
- uint32 x_offs = 0;
uint32 y_offs = 0;
#ifdef USE_64_BIT_TXR_XFER
! unsigned short *dst = (unsigned short *)txr_ptr_ex;
unsigned char *src = &screen[0];
--- 334,344 ----
if(ui_rendermode == PALETTED_TXR)
{
txr_twiddle_copy_general(&screen[0], txr_base, 512, 512, 8);
}
else
{
uint32 y_offs = 0;
#ifdef USE_64_BIT_TXR_XFER
! unsigned short *dst = (unsigned short *)txr_base_ex;
unsigned char *src = &screen[0];
***************
*** 365,368 ****
--- 350,354 ----
}
#else
+ uint32 x_offs = 0;
for(y_offs = 0; y_offs < vdp_vislines; y_offs++)
{
***************
*** 373,392 ****
}
#ifdef USE_TWIDDLED_TXR
! ta_poly_hdr_txr(&poly, TA_TRANSLUCENT, TA_RGB565_TWID, 512, 512, txr_base_ex, TA_BILINEAR_FILTER);
! txr_twiddle_copy(&screen_ex[0], 512, 512, txr_base_ex, 512, 512, pals[0]);
#else
! memcpy4(txr_ptr_ex, &screen_ex[0], 512*512*2);
#endif // USE_TWIDDLED_TXR
#endif // USE_64_BIT_TXR_XFER
- ta_poly_hdr_txr(&poly, TA_TRANSLUCENT, TA_RGB565, 512, 512, txr_base_ex, TA_BILINEAR_FILTER);
}
! ta_begin_render();
pvr_dummy_poly(TA_OPAQUE);
! ta_commit_eol();
pvr_dummy_poly(TA_TRANSLUCENT);
! ta_commit_poly_hdr(&poly);
! vert.flags = TA_VERTEX_NORMAL;
! vert.a = vert.r = vert.g = vert.b = 1.0f;
! vert.oa = vert.or = vert.og = vert.ob = 0.0f;
vert.z = 256.0f;
vert.x = x;
--- 359,386 ----
}
#ifdef USE_TWIDDLED_TXR
! pvr_txr_load_twiddle(&screen_ex[0], txr_base_ex, 512, 512);
#else
! memcpy4(txr_base_ex, &screen_ex[0], 512*512*2);
#endif // USE_TWIDDLED_TXR
#endif // USE_64_BIT_TXR_XFER
}
! pvr_wait_ready();
! pvr_scene_begin();
! pvr_list_begin(PVR_LIST_OP_POLY);
pvr_dummy_poly(TA_OPAQUE);
! pvr_list_finish();
! pvr_list_begin(PVR_LIST_TR_POLY);
pvr_dummy_poly(TA_TRANSLUCENT);
! if(ui_rendermode == PALETTED_TXR)
! {
! pvr_prim(&screen_poly_pal, sizeof(screen_poly_pal));
! }
! else
! {
! pvr_prim(&screen_poly, sizeof(screen_poly));
! }
! vert.flags = PVR_CMD_VERTEX;
! vert.argb = PVR_PACK_COLOR(1,1,1,1);
! vert.oargb = PVR_PACK_COLOR(0,0,0,0);
vert.z = 256.0f;
vert.x = x;
***************
*** 394,442 ****
vert.u = 0;
vert.v = vdp_vislines/512.0f;
! ta_commit_vertex(&vert, sizeof(vert));
vert.x = x;
vert.y = y;
vert.u = 0;
vert.v = 0;
! ta_commit_vertex(&vert, sizeof(vert));
vert.x = x + x_size;
vert.y = y + y_size;
vert.u = u_max/512.0f;
vert.v = vdp_vislines/512.0f;
! ta_commit_vertex(&vert, sizeof(vert));
vert.x = x + x_size;
vert.y = y;
vert.u = u_max/512.0f;
vert.v = 0;
! ta_commit_vertex(&vert, sizeof(vert));
! ta_commit_eol();
! ta_finish_frame();
}
/*** logging functions ***/
! /* logging is done this way because this was the best I could come up with
! whilst battling with macros that can only take fixed numbers of arguments */
! #define LOG_FUNC(name,level,txt) void ui_log_ ## name ## (const char *text, ...) \
! { \
! va_list ap; \
! char msg[512]; \
! if (gen_loglevel >= level) { \
! va_start(ap, text); \
! vsprintf((char *)msg, text, ap); \
! va_end(ap); \
! printf("%s (%05X) %s\n", txt, cpu68k_clocks, msg); \
! } \
}
! LOG_FUNC(debug3, 7, "DEBG ");
! LOG_FUNC(debug2, 6, "DEBG ");
! LOG_FUNC(debug1, 5, "DEBG ");
! LOG_FUNC(user, 4, "USER ");
! LOG_FUNC(verbose, 3, "---- ");
! LOG_FUNC(normal, 2, "---- ");
! LOG_FUNC(critical, 1, "CRIT ");
! LOG_FUNC(request, 0, "---- ");
/*** ui_err - log error message and quit ***/
--- 388,509 ----
vert.u = 0;
vert.v = vdp_vislines/512.0f;
! pvr_prim(&vert, sizeof(vert));
vert.x = x;
vert.y = y;
vert.u = 0;
vert.v = 0;
! pvr_prim(&vert, sizeof(vert));
vert.x = x + x_size;
vert.y = y + y_size;
vert.u = u_max/512.0f;
vert.v = vdp_vislines/512.0f;
! pvr_prim(&vert, sizeof(vert));
! vert.flags = PVR_CMD_VERTEX_EOL;
vert.x = x + x_size;
vert.y = y;
vert.u = u_max/512.0f;
vert.v = 0;
! pvr_prim(&vert, sizeof(vert));
! pvr_list_finish();
! pvr_scene_finish();
}
+
/*** logging functions ***/
+ void ui_log_debug3(const char *text, ...)
+ {
+ va_list ap;
+ char msg[512];
+ if (gen_loglevel >= 7) {
+ va_start(ap, text);
+ vsprintf((char *)msg, text, ap);
+ va_end(ap);
+ printf("DEBG (%05X) %s\n", cpu68k_clocks, msg);
+ }
+ }
! void ui_log_debug2(const char *text, ...)
! {
! va_list ap;
! char msg[512];
! if (gen_loglevel >= 6) {
! va_start(ap, text);
! vsprintf((char *)msg, text, ap);
! va_end(ap);
! printf("DEBG (%05X) %s\n", cpu68k_clocks, msg);
! }
! }
! void ui_log_debug1(const char *text, ...)
! {
! va_list ap;
! char msg[512];
! if (gen_loglevel >= 5) {
! va_start(ap, text);
! vsprintf((char *)msg, text, ap);
! va_end(ap);
! printf("DEBG (%05X) %s\n", cpu68k_clocks, msg);
! }
}
! void ui_log_user(const char *text, ...)
! {
! va_list ap;
! char msg[512];
! if (gen_loglevel >= 4) {
! va_start(ap, text);
! vsprintf((char *)msg, text, ap);
! va_end(ap);
! printf("USER (%05X) %s\n", cpu68k_clocks, msg);
! }
! }
!
! void ui_log_verbose(const char *text, ...)
! {
! va_list ap;
! char msg[512];
! if (gen_loglevel >= 3) {
! va_start(ap, text);
! vsprintf((char *)msg, text, ap);
! va_end(ap);
! printf("---- (%05X) %s\n", cpu68k_clocks, msg);
! }
! }
!
! void ui_log_normal(const char *text, ...)
! {
! va_list ap;
! char msg[512];
! if (gen_loglevel >= 2) {
! va_start(ap, text);
! vsprintf((char *)msg, text, ap);
! va_end(ap);
! printf("---- (%05X) %s\n", cpu68k_clocks, msg);
! }
! }
!
! void ui_log_critical(const char *text, ...)
! {
! va_list ap;
! char msg[512];
! if (gen_loglevel >= 1) {
! va_start(ap, text);
! vsprintf((char *)msg, text, ap);
! va_end(ap);
! printf("CRIT (%05X) %s\n", cpu68k_clocks, msg);
! }
! }
!
! void ui_log_request(const char *text, ...)
! {
! va_list ap;
! char msg[512];
! if (gen_loglevel) {
! va_start(ap, text);
! vsprintf((char *)msg, text, ap);
! va_end(ap);
! printf("---- (%05X) %s\n", cpu68k_clocks, msg);
! }
! }
/*** ui_err - log error message and quit ***/
|