removed separate event id

This commit is contained in:
Polprzewodnikowy 2022-01-22 15:56:20 +01:00
parent d1823be902
commit c2ae1e2587
3 changed files with 26 additions and 46 deletions

View File

@ -46,12 +46,12 @@ class SC64:
__DDIPL_ROM_LENGTH = 0x400000
__DEBUG_ID_TEXT = 0x01
__DEBUG_ID_EVENT = 0xFE
__EVENT_ID_FSD_READ = 0
__EVENT_ID_FSD_WRITE = 1
__EVENT_ID_DD_BLOCK = 2
__EVENT_ID_IS_VIEWER = 3
__EVENT_ID_FSD_READ = 0xF0
__EVENT_ID_FSD_WRITE = 0xF1
__EVENT_ID_FSD_LOAD = 0xF2
__EVENT_ID_FSD_STORE = 0xF3
__EVENT_ID_DD_BLOCK = 0xF4
__EVENT_ID_IS_VIEWER = 0xF5
__DD_DRIVE_ID_RETAIL = 3
__DD_DRIVE_ID_DEVELOPMENT = 4
@ -599,20 +599,6 @@ class SC64:
pass
def __debug_process_event(self, event_data: bytes) -> None:
id = int.from_bytes(event_data[0:4], byteorder="big")
data = event_data[4:]
if (id == self.__EVENT_ID_FSD_READ):
self.__debug_process_fsd_read(data)
elif (id == self.__EVENT_ID_FSD_WRITE):
self.__debug_process_fsd_write(data)
elif (id == self.__EVENT_ID_DD_BLOCK):
self.__debug_process_dd_block(data)
elif (id == self.__EVENT_ID_IS_VIEWER):
self.__debug_process_is_viewer(data)
def debug_init(self, fsd_file: str = None, disk_file: str = None, dd_turbo: bool = False) -> None:
if (fsd_file):
self.__fsd_file = open(fsd_file, "rb+")
@ -654,8 +640,14 @@ class SC64:
else:
if (id == self.__DEBUG_ID_TEXT):
print(data.decode(encoding="ascii", errors="backslashreplace"), end="")
elif (id == self.__DEBUG_ID_EVENT):
self.__debug_process_event(data)
elif (id == self.__EVENT_ID_FSD_READ):
self.__debug_process_fsd_read(data)
elif (id == self.__EVENT_ID_FSD_WRITE):
self.__debug_process_fsd_write(data)
elif (id == self.__EVENT_ID_DD_BLOCK):
self.__debug_process_dd_block(data)
elif (id == self.__EVENT_ID_IS_VIEWER):
self.__debug_process_is_viewer(data)
else:
print(f"\033[35mGot unknown id: {id}, length: {length}\033[0m", file=sys.stderr)

View File

@ -66,8 +66,6 @@ static bool tx_word (uint32_t data) {
#define USB_DMA_TOKEN (0x444D4100)
#define USB_ERR_TOKEN (0x45525200)
#define DEBUG_ID_EVENT (0xFE)
enum state {
STATE_IDLE,
@ -84,7 +82,6 @@ struct process {
uint32_t args[2];
bool error;
bool dma_in_progress;
bool queried;
bool event_pending;
bool event_callback_pending;
@ -183,7 +180,6 @@ void process_usb (void) {
p.counter = 0;
p.error = false;
p.dma_in_progress = false;
p.queried = false;
p.state = STATE_ARGS;
} else {
p.cmd = '!';
@ -220,9 +216,9 @@ void process_usb (void) {
break;
case 'Q':
if (!p.queried) {
if (p.counter == 0) {
cfg_query(p.args);
p.queried = true;
p.counter += 1;
}
if (tx_word(p.args[1])) {
p.state = STATE_RESPONSE;
@ -317,18 +313,15 @@ void process_usb (void) {
if ((p.counter == 0) && tx_word(USB_DMA_TOKEN | '@')) {
p.counter += 1;
}
if ((p.counter == 1) && tx_word((DEBUG_ID_EVENT << 24) | (sizeof(p.event.id) + p.event_data_length))) {
if ((p.counter == 1) && tx_word(((p.event.id & 0xFF) << 24) | p.event_data_length)) {
p.counter += 1;
}
if ((p.counter == 2) && tx_word(p.event.id)) {
p.counter += 1;
}
if (p.counter >= 3) {
while (((p.counter - 3) < p.event_data_length) && tx_byte(p.event_data[p.counter - 3])) {
if (p.counter >= 2) {
while (((p.counter - 2) < p.event_data_length) && tx_byte(p.event_data[p.counter - 2])) {
p.counter += 1;
}
}
if ((p.counter == (p.event_data_length + 3)) && tx_word(USB_CMP_TOKEN | 'H')) {
if ((p.counter == (p.event_data_length + 2)) && tx_word(USB_CMP_TOKEN | 'H')) {
if (p.event.callback != NULL) {
p.event_callback_pending = true;
}

View File

@ -6,17 +6,12 @@
typedef enum {
INT_DBG_ID_IS_VIEWER = 0,
INT_DBG_ID_DD_BLOCK = 1,
INT_DBG_ID_FSD_READ = 2,
INT_DBG_ID_FSD_WRITE = 3,
} internal_debug_id_t;
typedef enum {
EVENT_ID_FSD_READ = 0,
EVENT_ID_FSD_WRITE = 1,
EVENT_ID_DD_BLOCK = 2,
EVENT_ID_IS_VIEWER = 3,
EVENT_ID_FSD_READ = 0xF0,
EVENT_ID_FSD_WRITE = 0xF1,
EVENT_ID_FSD_LOAD = 0xF2,
EVENT_ID_FSD_STORE = 0xF3,
EVENT_ID_DD_BLOCK = 0xF4,
EVENT_ID_IS_VIEWER = 0xF5,
} usb_event_id_t;
typedef enum {