True. Will be good if we can capture the disks complete I guess, then we can generate everything possible for emulation like you say.
I think the 7 C1 bytes are always available at the end of each sector, but not sure whether the C2 data is always read into the C2 buffer unless the Micro finds a C1 error it can't correct?
I managed to get libdragon to compile with the interrupt 1 stuff added, but it's not triggering yet because I need to set the correct enable bit as well.
Having to use Ubunutu on a VM is still a pain, but much faster on the new i5 PC.
Even it's basic file manager is not always intuitive. lol
I'll let you know if I get the interrupt working.
OzOnE
Still struggling with the interrupt stuff, but it's slowly making more sense...
Page 351 onwards of the PDF shows how the ints are masked etc...
http://datasheets.chipdb.org/NEC/Vr-Series/Vr43xx/U10504EJ7V0UMJ1.pdf
It also says that there is no direct "Status Register" on the R4300, but it is accessed via the control part instead (COP0) using mfc0 / mtc0 etc.
Libdragon normally only enables interrupt level 3, so only includes the two software ints, and int0 (RCP)...
/* Interrupt pending bits */
#define CAUSE_IP8 0x00008000 /* External level 8 pending - COMPARE */
#define CAUSE_IP7 0x00004000 /* External level 7 pending - INT4 (GIO debug on U64 Board) */
#define CAUSE_IP6 0x00002000 /* External level 6 pending - INT3 (GIO debug on U64 Board) */
#define CAUSE_IP5 0x00001000 /* External level 5 pending - INT2 (PIF) */
#define CAUSE_IP4 0x00000800 /* External level 4 pending - INT1 (Exp / Cart / 64DD) */
#define CAUSE_IP3 0x00000400 /* External level 3 pending - INT0 (RCP) */
#define CAUSE_SW2 0x00000200 /* Software level 2 pending */
#define CAUSE_SW1 0x00000100 /* Software level 1 pending */
Libdragon enables int level 3 in the init_interrupts() routine in interrupt.c directly with asm...
asm("\tmfc0 $8,$12\n\tori $8,0x801\n\tmtc0 $8,$12\n\tnop":::"$8");
ie...
mfc0 $8,$12 // Move Status Reg ($12) from COP0 to reg $8
ori $8,0x401 // OR Immediate value 0x401 (set int level 3, and enable global ints.)
mtc0 $8,$12 // Move back to SR in COP0.
nop
I tried hooking up the new int routine in the 64ddtest code and modifying inthandler.S in Libdragon like in post #25.
I also changed the above asm to write 0x801 instead (to enable ints up to level 4), re-compiled Libdragon...
make clean
make all
make tools install
make install
...re-compiled 64ddtest (checksum does change, so Libdragon must have compiled OK), but 64ddtest now just freezes on the N64.
I tried changing the asm line back to 0x401 as well, but it's still not working?
I might have messed something else up, because it shows a blank screen even if I don't enable int1?
The tricky part with the N64 is remembering which block the ints are coming from (CPU or RCP), and how it all links together.
This is quite helpful though...
http://level42.ca/projects/ultra64/Documentation/man/pro-man/pro07/index7.7.html
I think I'll have a break for a while and try to debug this problem in a few hours.
OzOnE.
P.S. As an interesting side note, the above link shows that interrupts 3 and 4 on the R4300 (CAUSE_IP6 and CAUSE_IP7) are used by the U64 Dev board to talk to the SGI Indy and debug the code.
Hmmm, I wonder if any commercial game carts still have debug handlers in there?
OK, so it's when I set the Status reg to 0x801 to enable int1 that makes it freeze.
I think the int is triggering the routine OK, but I'm not clearing the int on the 64DD afterwards, so it gets stuck in a loop.
(The int from the 64DD shouldn't affect the RCP regs directly since it goes directly to the R4300.)
Ahhh, seems setting the Status reg bits (COP0) is just a mask for the ints.
I should have been setting bits 10 AND 11 to allow hardware ints 0 and 1 (RCP and 64DD / Expansion).
Looks like Libdragon does only using int0 so it can use the basic RCP stuff, but it doesn't appear to enable any of the other ints (normally).
So, the test program is running again, but now it's freezing at the "Resetting 64DD..." message. Hmmm.
I think we're getting somewhere though. Better to have something on screen rather than nothing.
OzOnE.
Right, I spent many hours trying to get interrupts working properly, but it just freezes whenever I leave the code in inthandler.S in Libdragon.
It freezes even if I'm not enabling int1, so the int handler must be seeing bit 11 of the Status reg set (int1 flag) whenever the 64DD triggers an int?...
notcount:
// check for cart/expansion INT1
// and $30,k1,0x800
// beqz $30,notexpint
// nop
// call int1 / expansion int handler
// jal __EXP_handler
// nop
// j endint
// nop
Anywho, long story short, I got it to read the disk ID by polling instead.
https://mega.co.nz/#!SlxyjT5A!ezsW6RhJBYXrnzkDhkr91kINfWCvXmAbBftJqebhmm4
You have to press the A button to read the ID atm, but I wanted to post the code as soon as it worked.
It also sometimes needs a second button press to read a valid ID, so some timing / flags issues to sort out.
Basically, you need to do the BM Reset and Start BM stuff just after do the Read Seek.
This gets the Buffer Manager on the drive ready to receive the sector data from the Micro.
We should soon be able to read full blocks of data from the disk, then work out how to write it back to SD card.
@Luigiblood - please ignore the interrupt routine for now, it's not being used.
I also commented out the extra parts in inthandler.S in my Libdragon sources anyway, so I'm not using 64DD ints atm.
OzOnE.