--- uae/src/hardfile.c 2018/04/24 16:38:39 1.1 +++ uae/src/hardfile.c 2018/04/24 16:39:03 1.1.1.2 @@ -13,10 +13,12 @@ #include "options.h" #include "memory.h" #include "custom.h" +#include "readcpu.h" #include "newcpu.h" #include "disk.h" #include "xwin.h" #include "autoconf.h" +#include "execlib.h" static int opencount = 0; static int uaedevfd; @@ -26,7 +28,7 @@ static ULONG hardfile_init(void) { ULONG tmp1, devicenode, bootnode; int have36 = 1; - ULONG retval = regs.d[0]; + ULONG retval = m68k_dreg(regs, 0); filesys_init(); @@ -35,12 +37,12 @@ static ULONG hardfile_init(void) static ULONG hardfile_open(void) { - CPTR tmp1 = regs.a[1]; /* IOReq */ + CPTR tmp1 = m68k_areg(regs, 1); /* IOReq */ /* Check unit number */ - if (regs.d[0] == 0) { + if (m68k_dreg(regs, 0) == 0) { opencount++; - put_word (regs.a[6]+32, get_word (regs.a[6]+32) + 1); + put_word (m68k_areg(regs, 6)+32, get_word (m68k_areg(regs, 6)+32) + 1); put_long (tmp1+24, 0); /* io_Unit */ put_byte (tmp1+31, 0); /* io_Error */ put_byte (tmp1+8, 7); /* ln_type = NT_REPLYMSG */ @@ -55,9 +57,9 @@ static ULONG hardfile_open(void) static ULONG hardfile_close(void) { opencount--; - put_word (regs.a[6]+32, get_word (regs.a[6]+32) - 1); + put_word (m68k_areg(regs, 6)+32, get_word (m68k_areg(regs, 6)+32) - 1); - return regs.d[0]; + return 0; } static ULONG hardfile_expunge(void) @@ -68,14 +70,14 @@ static ULONG hardfile_expunge(void) static ULONG hardfile_beginio(void) { ULONG tmp1, tmp2, dataptr, offset; - ULONG retval = regs.d[0]; + ULONG retval = m68k_dreg(regs, 0); - tmp1 = regs.a[1]; - put_byte (tmp1+8, 5); /* set ln_type to NT_MESSAGE */ + tmp1 = m68k_areg(regs, 1); + put_byte (tmp1+8, NT_MESSAGE); put_byte (tmp1+31, 0); /* no error yet */ tmp2 = get_word (tmp1+28); /* io_Command */ switch (tmp2) { - case 2: /* Read */ + case CMD_READ: dataptr = get_long (tmp1 + 40); if (dataptr & 1) goto bad_command; @@ -100,7 +102,7 @@ static ULONG hardfile_beginio(void) } break; - case 3: /* Write */ + case CMD_WRITE: case 11: /* Format */ dataptr = get_long (tmp1 + 40); if (dataptr & 1) @@ -138,8 +140,8 @@ static ULONG hardfile_beginio(void) break; /* Some commands that just do nothing and return zero */ - case 4: /* Update */ - case 5: /* Clear */ + case CMD_UPDATE: + case CMD_CLEAR: case 9: /* Motor */ case 10: /* Seek */ case 12: /* Remove */ @@ -160,7 +162,7 @@ static ULONG hardfile_beginio(void) } if ((get_byte (tmp1+30) & 1) == 0) { /* Not IOF_QUICK -- need to ReplyMsg */ - regs.a[1] = tmp1; + m68k_areg(regs, 1) = tmp1; CallLib (get_long(4), -378); } return retval; @@ -175,7 +177,7 @@ void hardfile_install(void) { ULONG functable, datatable, inittable; ULONG initcode, openfunc, closefunc, expungefunc; - ULONG nullfunc, beginiofunc, abortiofunc; + ULONG beginiofunc, abortiofunc; uaedevfd = open ("hardfile", O_RDWR | O_BINARY); @@ -200,11 +202,6 @@ void hardfile_install(void) expungefunc = here(); calltrap(deftrap(hardfile_expunge)); dw(RTS); - /* Null */ - nullfunc = here(); - dw(0x7000); /* return 0; */ - dw(RTS); - /* BeginIO */ beginiofunc = here(); calltrap(deftrap(hardfile_beginio)); dw(RTS); @@ -218,10 +215,10 @@ void hardfile_install(void) dl(openfunc); /* Open */ dl(closefunc); /* Close */ dl(expungefunc); /* Expunge */ - dl(nullfunc); /* Null */ + dl(EXPANSION_nullfunc); /* Null */ dl(beginiofunc); /* BeginIO */ dl(abortiofunc); /* AbortIO */ - dl(0xFFFFFFFF); /* end of table */ + dl(0xFFFFFFFFul); /* end of table */ /* DataTable */ datatable = here();