Previous 15994 Revisions Next

r1995 Sunday 16th March, 2008 at 05:57:10 UTC by Robbbert
[Z80BIN] Fixed a bug with return values.
[src/mess/devices]z80bin.c z80bin.h
[src/mess/drivers]mbee.c super80.c

src/mess/devices/z80bin.c
r1994r1995
77
88   NOTE: INIT_FAIL == 1, INIT_PASS == 0, EOF == 0xffffffff
99
10   The return_code consists of start_addr | end_addr | exec_addr | status.
11   Status: 0 = good data, 1 = corrupted quickload file.
10   Return status: 0 = good data, 1 = corrupted quickload file.
1211
1312*********************************************************************/
1413
r1994r1995
1716#include "z80bin.h"
1817#include "snapquik.h"
1918
20UINT64 z80bin_load_file( running_machine *machine, mess_image *image, const char *file_type )
19
20int z80bin_load_file( running_machine *machine, mess_image *image, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr )
2121{
2222   int ch;
2323   UINT16 args[3];
2424   UINT16 i=0, j, size;
25   UINT64 start_addr, exec_addr, end_addr;   /* need to be this size for return at end */
2625   UINT8 data;
2726   char * pgmname;
2827   pgmname = (char *) malloc(256);
r1994r1995
5453      return INIT_FAIL;
5554   }
5655
57   exec_addr   = LITTLE_ENDIANIZE_INT16(args[0]);
58   start_addr   = LITTLE_ENDIANIZE_INT16(args[1]);
59   end_addr   = LITTLE_ENDIANIZE_INT16(args[2]);
56   exec_addr[0]   = LITTLE_ENDIANIZE_INT16(args[0]);
57   start_addr[0]   = LITTLE_ENDIANIZE_INT16(args[1]);
58   end_addr[0]   = LITTLE_ENDIANIZE_INT16(args[2]);
6059
61   size = (end_addr - start_addr + 1) & 0xffff;
60   size = (end_addr[0] - start_addr[0] + 1) & 0xffff;
6261
63   popmessage("%s\nsize=%04X : start=%04X : end=%04X : exec=%04X",pgmname,size,(int)start_addr,(int)end_addr,(int)exec_addr);
62   popmessage("%s\nsize=%04X : start=%04X : end=%04X : exec=%04X",pgmname,size,start_addr[0],end_addr[0],exec_addr[0]);
6463
6564   for (i = 0; i < size; i++)
6665   {
67      j = (start_addr + i) & 0xffff;
66      j = (start_addr[0] + i) & 0xffff;
6867      if (image_fread(image, &data, 1) != 1)
6968      {
7069         ui_popup_time(10,"QUICKLOAD: %s\nUnexpected EOF while writing byte to %04X",pgmname,j);
r1994r1995
7675
7776   free(pgmname);
7877
79   return (start_addr << 48) | (end_addr << 32) | (exec_addr << 16);
78   return INIT_PASS;
8079}
8180
81
8282static QUICKLOAD_LOAD( z80bin )
8383{
84   UINT16 exec_addr;
85   UINT64 return_info = z80bin_load_file( machine, image, file_type );   /* load file */
86   if (return_info == INIT_FAIL) return INIT_FAIL;         /* failure */
87   exec_addr = (return_info & 0xffff0000) >> 16;         /* get program run address */
84   UINT16 exec_addr, start_addr, end_addr;
85
86   if (z80bin_load_file( machine, image, file_type, &exec_addr, &start_addr, &end_addr ) == INIT_FAIL)
87      return INIT_FAIL;
88
8889   if (exec_addr == 0xffff) return INIT_PASS;         /* non-executable data file */
8990   cpunum_set_reg(0, REG_PC, exec_addr);            /* start program */
9091   return INIT_PASS;
9192}
9293
9394
94
9595void z80bin_quickload_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
9696{
9797   /* quickload */
src/mess/devices/z80bin.h
r1994r1995
1616
1717void z80bin_quickload_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
1818
19UINT64 z80bin_load_file( running_machine *machine, mess_image *image, const char *file_type );
19int z80bin_load_file( running_machine *machine, mess_image *image, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr );
2020
2121
2222#endif /* Z80BIN_H */
src/mess/drivers/mbee.c
r1994r1995
435435static QUICKLOAD_LOAD( mbee )
436436{
437437   UINT8 sw = readinputportbytag("CONFIG") & 1;         /* reading the dipswitch: 1 = autorun */
438   UINT16 exec_addr;
439   UINT64 return_info = z80bin_load_file( machine, image, file_type );   /* load file */
438   UINT16 exec_addr, start_addr, end_addr;
440439
441   if (return_info == INIT_FAIL) return INIT_FAIL;         /* failure */
440   if (z80bin_load_file( machine, image, file_type, &exec_addr, &start_addr, &end_addr ) == INIT_FAIL)
441      return INIT_FAIL;
442442
443   exec_addr = (return_info & 0xffff0000) >> 16;         /* get program run address */
444
445443   if (exec_addr == 0xffff) return INIT_PASS;         /* data file */
446444
447445   program_write_word_16le(0xa6,exec_addr);         /* fix the EXEC command */
src/mess/drivers/super80.c
r1994r1995
981981static QUICKLOAD_LOAD( super80 )
982982{
983983   UINT8 sw = readinputportbytag("CONFIG") & 1;            /* reading the dipswitch: 1 = autorun */
984   UINT16 exec_addr;
985   UINT64 return_info = z80bin_load_file( machine, image, file_type );   /* load file */
984   UINT16 exec_addr, start_addr, end_addr;
986985
987   if (return_info == INIT_FAIL) return INIT_FAIL;         /* failure */
986   if (z80bin_load_file( machine, image, file_type, &exec_addr, &start_addr, &end_addr ) == INIT_FAIL)
987      return INIT_FAIL;
988988
989   exec_addr = (return_info & 0xffff0000) >> 16;         /* get program run address */
990
991989   if ((exec_addr != 0xffff) && (sw))
992990      cpunum_set_reg(0, REG_PC, exec_addr);
993991

Previous 15994 Revisions Next


© 1998-2018 The MESS Team