+// M68000 breakpoints initialisations
+void m68k_brk_init(void)
+{
+ brkNbr = 0;
+ brkInfo = NULL;
+}
+
+
+// Reset the M68000 breakpoints structures
+void m68k_brk_reset(void)
+{
+ // Reset the breakpoints
+ free(brkInfo);
+ brkInfo = NULL;
+ brkNbr = 0;
+}
+
+
+// Delete a M68000 breakpoint (starting from 1)
+void m68k_brk_del(unsigned int NumBrk)
+{
+ // Remove the breakpoint
+ memset((void *)(brkInfo + (NumBrk - 1)), 0, sizeof(S_BrkInfo));
+}
+
+
+// Add a M68000 breakpoint
+// return true if breakpoint has been added, and false if breakpoint already exists
+unsigned int m68k_brk_add(void *PtrInfo)
+{
+ S_BrkInfo *Ptr = NULL;
+
+ // Check if breakpoint already exists
+ for (size_t i = 0; i < brkNbr; i++)
+ {
+ if (brkInfo[i].Used)
+ {
+ if (brkInfo[i].Adr == ((S_BrkInfo *)PtrInfo)->Adr)
+ {
+ return false;
+ }
+ }
+ }
+
+ // Look for an available breakpoint
+ for (size_t i = 0; i < brkNbr, Ptr; i++)
+ {
+ if (!brkInfo[i].Used)
+ {
+ Ptr = &brkInfo[i];
+ }
+ }
+
+ // Add a breakpoint
+ if (!Ptr)
+ {
+ brkInfo = (S_BrkInfo *)realloc(brkInfo, (++brkNbr * sizeof(S_BrkInfo)));
+ Ptr = &brkInfo[brkNbr - 1];
+ }
+
+ // Transfert the breakpoint information and init the activities
+ memcpy((void *)Ptr, PtrInfo, sizeof(S_BrkInfo));
+ Ptr->HitCounts = 0;
+ return (Ptr->Active = Ptr->Used = true);
+}
+
+
+// Check if breakpoint has been reached
+unsigned int m68k_brk_check(unsigned int adr)
+{
+ // Check if BPM has been reached
+ if ((adr == bpmAddress1) && bpmActive)
+ {
+ bpmHitCounts++;
+ return true;
+ }
+ else
+ {
+ // Check user breakpoints
+ for (size_t i = 0; i < brkNbr; i++)
+ {
+ if (brkInfo[i].Used && brkInfo[i].Active)
+ {
+ if (brkInfo[i].Adr == adr)
+ {
+ brkInfo[i].HitCounts++;
+ return true;
+ }
+ }
+ }
+ }
+
+ // No breakpoint found
+ return false;
+}
+
+
+// Disable the M68000 breakpoints
+void m68k_brk_disable(void)
+{
+ // reset active for the breakpoints
+ for (size_t i = 0; i < brkNbr; i++)
+ {
+ brkInfo[i].Active = 0;
+ }
+}
+
+
+// Reset the M68000 breakpoints
+void m68k_brk_hitcounts_reset(void)
+{
+ // reset hit counts for the breakpoints
+ for (size_t i = 0; i < brkNbr; i++)
+ {
+ brkInfo[i].HitCounts = 0;
+ }
+}
+
+
+// Close the M68000 breakpoints structures
+void m68k_brk_close(void)
+{
+ free(brkInfo);
+}
+
+
+// Read 1 byte from address
+// Check if address reaches a breakpoint