Added JSR and RET functions to CMDFIFO (Voodoo2/Banshee/Voodoo3).

This commit is contained in:
Volker Ruppert 2024-09-08 20:52:40 +02:00
parent 79c820e7b1
commit f5e3dd9dce
2 changed files with 27 additions and 5 deletions

View File

@ -1509,7 +1509,9 @@ struct _cmdfifo_info
Bit32u depth; /* current depth */
Bit32u depth_needed; /* depth needed for command */
Bit32u holes; /* number of holes */
Bit32u retAddr;
bool cmd_ready;
bool jsr;
};

View File

@ -2936,11 +2936,13 @@ Bit32u cmdfifo_r(cmdfifo_info *f)
data = *(Bit32u*)(&v->fbi.ram[f->rdptr & v->fbi.mask]);
f->rdptr += 4;
if (f->rdptr >= f->end) {
BX_INFO(("CMDFIFO RdPtr rollover"));
f->rdptr = f->base;
if (!f->jsr) {
if (f->rdptr >= f->end) {
BX_INFO(("CMDFIFO RdPtr rollover"));
f->rdptr = f->base;
}
f->depth--;
}
f->depth--;
return data;
}
@ -2961,6 +2963,24 @@ void cmdfifo_process(cmdfifo_info *f)
switch (code) {
case 0: // NOP
break;
case 1: // JSR
if (f->jsr) {
BX_ERROR(("cmdfifo_process(): JSR: already inside of subroutine"));
} else {
f->jsr = true;
f->retAddr = f->rdptr;
f->rdptr = (command >> 4) & 0xfffffc;
}
break;
case 2: // RET
if (!f->jsr) {
BX_ERROR(("cmdfifo_process(): RET: not inside of subroutine"));
} else {
f->rdptr = f->retAddr;
f->retAddr = 0;
f->jsr = false;
}
break;
case 3: // JMP
f->rdptr = (command >> 4) & 0xfffffc;
if (f->count_holes) {
@ -3209,7 +3229,7 @@ void cmdfifo_process(cmdfifo_info *f)
BX_ERROR(("CMDFIFO: unsupported packet type %d", type));
}
f->depth_needed = cmdfifo_calc_depth_needed(f);
if (f->depth < f->depth_needed) {
if (!f->jsr && f->depth < f->depth_needed) {
f->cmd_ready = 0;
}
}