syncing 2.3.0

parent bfe77db8
......@@ -133,7 +133,7 @@ EXTRA_DIST = \
uae_SOURCES = \
main.c newcpu.c memory.c rommgr.c custom.c serial.c dongle.c cia.c \
blitter.c autoconf.c traps.c ersatz.c keybuf.c expansion.c \
diskutil.c zfile.c cfgfile.c picasso96.c inputdevice.c \
diskutil.c zfile.c zfile_archive.c cfgfile.c picasso96.c inputdevice.c \
gfxutil.c audio.c sinctable.c drawing.c consolehook.c \
native2amiga.c disk.c crc32.c savestate.c arcadia.c cdtv.c cd32_fmv.c \
uaeexe.c uaelib.c uaeresource.c fdi2raw.c hotkeys.c amax.c \
......
......@@ -79,17 +79,17 @@ am_uae_OBJECTS = main.$(OBJEXT) newcpu.$(OBJEXT) memory.$(OBJEXT) \
dongle.$(OBJEXT) cia.$(OBJEXT) blitter.$(OBJEXT) \
autoconf.$(OBJEXT) traps.$(OBJEXT) ersatz.$(OBJEXT) \
keybuf.$(OBJEXT) expansion.$(OBJEXT) diskutil.$(OBJEXT) \
zfile.$(OBJEXT) cfgfile.$(OBJEXT) picasso96.$(OBJEXT) \
inputdevice.$(OBJEXT) gfxutil.$(OBJEXT) audio.$(OBJEXT) \
sinctable.$(OBJEXT) drawing.$(OBJEXT) consolehook.$(OBJEXT) \
native2amiga.$(OBJEXT) disk.$(OBJEXT) crc32.$(OBJEXT) \
savestate.$(OBJEXT) arcadia.$(OBJEXT) cdtv.$(OBJEXT) \
cd32_fmv.$(OBJEXT) uaeexe.$(OBJEXT) uaelib.$(OBJEXT) \
uaeresource.$(OBJEXT) fdi2raw.$(OBJEXT) hotkeys.$(OBJEXT) \
amax.$(OBJEXT) ar.$(OBJEXT) driveclick.$(OBJEXT) \
enforcer.$(OBJEXT) misc.$(OBJEXT) a2065.$(OBJEXT) \
gayle.$(OBJEXT) ncr_scsi.$(OBJEXT) missing.$(OBJEXT) \
readcpu.$(OBJEXT)
zfile.$(OBJEXT) zfile_archive.$(OBJEXT) cfgfile.$(OBJEXT) \
picasso96.$(OBJEXT) inputdevice.$(OBJEXT) gfxutil.$(OBJEXT) \
audio.$(OBJEXT) sinctable.$(OBJEXT) drawing.$(OBJEXT) \
consolehook.$(OBJEXT) native2amiga.$(OBJEXT) disk.$(OBJEXT) \
crc32.$(OBJEXT) savestate.$(OBJEXT) arcadia.$(OBJEXT) \
cdtv.$(OBJEXT) cd32_fmv.$(OBJEXT) uaeexe.$(OBJEXT) \
uaelib.$(OBJEXT) uaeresource.$(OBJEXT) fdi2raw.$(OBJEXT) \
hotkeys.$(OBJEXT) amax.$(OBJEXT) ar.$(OBJEXT) \
driveclick.$(OBJEXT) enforcer.$(OBJEXT) misc.$(OBJEXT) \
a2065.$(OBJEXT) gayle.$(OBJEXT) ncr_scsi.$(OBJEXT) \
missing.$(OBJEXT) readcpu.$(OBJEXT)
uae_OBJECTS = $(am_uae_OBJECTS)
SCRIPTS = $(dist_noinst_SCRIPTS)
DEFAULT_INCLUDES = -I.@am__isrc@
......@@ -412,7 +412,7 @@ EXTRA_DIST = \
uae_SOURCES = \
main.c newcpu.c memory.c rommgr.c custom.c serial.c dongle.c cia.c \
blitter.c autoconf.c traps.c ersatz.c keybuf.c expansion.c \
diskutil.c zfile.c cfgfile.c picasso96.c inputdevice.c \
diskutil.c zfile.c zfile_archive.c cfgfile.c picasso96.c inputdevice.c \
gfxutil.c audio.c sinctable.c drawing.c consolehook.c \
native2amiga.c disk.c crc32.c savestate.c arcadia.c cdtv.c cd32_fmv.c \
uaeexe.c uaelib.c uaeresource.c fdi2raw.c hotkeys.c amax.c \
......@@ -660,6 +660,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uaeresource.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writelog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zfile_archive.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
......
......@@ -23,6 +23,7 @@
#include "threaddep/thread.h"
#include "akiko.h"
#include "gui.h"
#include "crc32.h"
#include "sleep.h"
#include "custom.h"
#include "newcpu.h"
......@@ -370,7 +371,7 @@ static uae_u32 akiko_c2p_read (int offset)
#define CH_ERR_ABNORMALSEEK 0xf0 // %11110000
#define CH_ERR_NODISK 0xf8 // %11111000
static int framecounter, subcodecounter;
static int subcodecounter;
#define MAX_SUBCODEBUFFER 20
static volatile int subcodebufferoffset, subcodebufferoffsetw;
......@@ -398,7 +399,7 @@ static struct cd_toc_head cdrom_toc_cd_buffer;
static uae_u8 qcode_buf[SUBQ_SIZE];
static int qcode_valid;
static int cdrom_disk, cdrom_paused, cdrom_playing;
static int cdrom_disk, cdrom_paused, cdrom_playing, cdrom_audiostatus;
static int cdrom_command_active;
static int cdrom_command_length;
static int cdrom_checksum_error, cdrom_unknown_command;
......@@ -455,6 +456,7 @@ static void cdaudiostop_do (void)
static void cdaudiostop (void)
{
cdrom_audiostatus = 0;
cdrom_audiotimeout = 0;
cdrom_paused = 0;
cdrom_playing = 0;
......@@ -499,6 +501,25 @@ static void subfunc (uae_u8 *data, int cnt)
uae_sem_post (&sub_sem);
}
static int statusfunc (int status)
{
if (status == -1)
return 0;
if (status == -2)
return 150;
if (cdrom_audiostatus != status) {
if (status == AUDIO_STATUS_IN_PROGRESS) {
cdrom_playing = 1;
cdrom_audiotimeout = 1;
}
if (cdrom_playing && status != AUDIO_STATUS_IN_PROGRESS && status != AUDIO_STATUS_PAUSED) {
cdrom_audiotimeout = -1;
}
}
cdrom_audiostatus = status;
return 0;
}
static void cdaudioplay_do (void)
{
uae_u32 startlsn = read_comm_pipe_u32_blocking (&requests);
......@@ -508,7 +529,7 @@ static void cdaudioplay_do (void)
if (unitnum < 0)
return;
sys_command_cd_pause (unitnum, 0);
sys_command_cd_play2 (unitnum, startlsn, endlsn, scan, subfunc);
sys_command_cd_play2 (unitnum, startlsn, endlsn, scan, statusfunc, subfunc);
}
static bool isaudiotrack (int startlsn)
......@@ -583,9 +604,7 @@ static int cd_qcode (uae_u8 *d)
buf[2] = 0x80;
if (!qcode_valid)
return 0;
if (cdrom_playing) // fake it!
as = AUDIO_STATUS_IN_PROGRESS;
if (as != AUDIO_STATUS_IN_PROGRESS && as != AUDIO_STATUS_PAUSED && as != AUDIO_STATUS_PLAY_COMPLETE && as != AUDIO_STATUS_NO_STATUS) /* audio status ok? */
if (cdrom_audiostatus != AUDIO_STATUS_IN_PROGRESS && cdrom_audiostatus != AUDIO_STATUS_PAUSED)
return 0;
s = buf + 4;
last_play_pos = msf2lsn (fromlongbcd (s + 7));
......@@ -875,11 +894,11 @@ static int cdrom_command_multi (void)
seekpos, msf2lsn (seekpos), endpos, msf2lsn (endpos), scan);
#endif
cdrom_playing = 1;
cdrom_result_buffer[1] |= CDS_PLAYING;
if (!cd_play_audio (seekpos, endpos, 0)) {
// play didn't start, report it in next status packet
cdrom_audiotimeout = -3;
}
cdrom_result_buffer[1] |= CDS_PLAYING;
} else {
#if AKIKO_DEBUG_IO_CMD
write_log ("SEEKTO %06X\n",seekpos);
......@@ -892,10 +911,15 @@ static int cdrom_command_multi (void)
return 2;
}
static int cdrom_playend_notify (int err)
static int cdrom_playend_notify (int status)
{
cdrom_result_buffer[0] = 4;
cdrom_result_buffer[1] = err ? 0x80 : 0x00;
if (status < 0)
cdrom_result_buffer[1] = 0x80; // error
else if (status == 0)
cdrom_result_buffer[1] = 0x08; // play started
else
cdrom_result_buffer[1] = 0x00; // play ended
return 2;
}
......@@ -1089,6 +1113,10 @@ static void akiko_handler (void)
get_cdrom_toc ();
return;
}
if (cdrom_audiotimeout == 1) { // play start
cdrom_start_return_data (cdrom_playend_notify (0));
cdrom_audiotimeout = 0;
}
if (cdrom_audiotimeout == -1) { // play finished (or disk end)
if (cdrom_playing) {
cdaudiostop ();
......@@ -1097,12 +1125,13 @@ static void akiko_handler (void)
cdrom_audiotimeout = 0;
}
}
if (cdrom_audiotimeout == -2 && qcode_buf[1] != AUDIO_STATUS_IN_PROGRESS) {
cdrom_start_return_data (cdrom_playend_notify (0));
if (cdrom_audiotimeout == -2) { // play end notification
cdrom_start_return_data (cdrom_playend_notify (1));
cdrom_audiotimeout = 0;
}
if (cdrom_audiotimeout == -3) {
cdrom_start_return_data (cdrom_playend_notify (1));
// play didn't start notification (illegal address)
if (cdrom_audiotimeout == -3) { // return error status
cdrom_start_return_data (cdrom_playend_notify (-1));
cdrom_audiotimeout = 0;
}
......@@ -1132,6 +1161,7 @@ void AKIKO_hsync_handler (void)
if (!currprefs.cs_cd32cd || !akiko_inited)
return;
static float framecounter;
framecounter--;
if (framecounter <= 0) {
if (cdrom_seek_delay <= 0) {
......@@ -1139,12 +1169,12 @@ void AKIKO_hsync_handler (void)
} else {
cdrom_seek_delay--;
}
framecounter = 1000000 / (63 * 75 * cdrom_speed);
framecounter += (float)maxvpos * vblank_hz / (75.0 * cdrom_speed);
}
subcodecounter--;
if (subcodecounter <= 0) {
if ((cdrom_flags & CDFLAG_SUBCODE) && subcodebufferoffset != subcodebufferoffsetw) {
if ((cdrom_flags & CDFLAG_SUBCODE) && cdrom_playing && subcodebufferoffset != subcodebufferoffsetw) {
uae_sem_wait (&sub_sem);
if (subcodebufferinuse[subcodebufferoffset]) {
if (cdrom_subcodeoffset >= 128)
......@@ -1164,7 +1194,7 @@ void AKIKO_hsync_handler (void)
}
uae_sem_post (&sub_sem);
}
subcodecounter = 1000000 / (70 * 75 * cdrom_speed);
subcodecounter = maxvpos * vblank_hz / (75 * cdrom_speed) - 5;
}
if (frame2counter > 0)
......@@ -1172,12 +1202,6 @@ void AKIKO_hsync_handler (void)
if (mediacheckcounter > 0)
mediacheckcounter--;
if (cdrom_audiotimeout > 0) {
cdrom_audiotimeout--;
if (cdrom_audiotimeout == 0)
cdrom_audiotimeout = -1;
}
akiko_internal ();
akiko_handler ();
}
......@@ -1222,16 +1246,6 @@ static void *akiko_thread (void *null)
if (unitnum >= 0 && sys_command_cd_qcode (unitnum, qcode_buf)) {
uae_u8 as = qcode_buf[1];
qcode_valid = 1;
if (as == AUDIO_STATUS_IN_PROGRESS) {
frame2counter /= 4;
if (cdrom_audiotimeout == 0) {
int lsn = msf2lsn (fromlongbcd (qcode_buf + 4 + 7));
// make sure audio play really ends because not all drives report position accurately
if ((lsn >= cdrom_toc_cd_buffer.lastaddress - 3 * 75 || lsn >= last_play_end - 3 * 75)) {
cdrom_audiotimeout = 3 * 312;
}
}
}
}
}
......
......@@ -394,19 +394,19 @@ bool get_header(struct zfile *fp, LzHeader *hdr)
if (zfile_fread(data + I_HEADER_CHECKSUM,
sizeof(char), header_size - 1, fp) < header_size - 1) {
fatal_error(L"Invalid header (LHarc file ?)");
fatal_error("Invalid header (LHarc file ?)");
return FALSE; /* finish */
}
setup_get(data + I_HEADER_LEVEL);
hdr->header_level = get_byte ();
if (hdr->header_level != 2 &&
zfile_fread(data + header_size, sizeof(char), 2, fp) < 2) {
fatal_error(L"Invalid header (LHarc file ?)");
fatal_error("Invalid header (LHarc file ?)");
return FALSE; /* finish */
}
if (hdr->header_level >= 3) {
fatal_error(L"Unknown level header");
fatal_error("Unknown level header");
return FALSE;
}
......@@ -427,7 +427,7 @@ bool get_header(struct zfile *fp, LzHeader *hdr)
if ((hdr->header_level = get_byte ()) != 2) {
if (calc_sum(data + I_METHOD, header_size) != checksum)
warning(L"Checksum error (LHarc file?)", L"");
warning("Checksum error (LHarc file?)", "");
name_length = get_byte ();
for (i = 0; i < name_length; i++)
hdr->name[i] = (char) get_byte ();
......@@ -450,7 +450,7 @@ bool get_header(struct zfile *fp, LzHeader *hdr)
hdr->extend_type = EXTEND_GENERIC;
hdr->has_crc = FALSE;
} else {
fatal_error(L"Unkonwn header (lha file?)");
fatal_error("Unkonwn header (lha file?)");
return FALSE;
}
} else {
......@@ -500,7 +500,7 @@ bool get_header(struct zfile *fp, LzHeader *hdr)
if (hdr->header_level != 2 &&
((data + LZHEADER_STRAGE - get_ptr < header_size) ||
zfile_fread(get_ptr, sizeof(char), header_size, fp) < header_size)) {
fatal_error(L"Invalid header (LHa file ?)");
fatal_error("Invalid header (LHa file ?)");
return FALSE;
}
switch (get_byte ()) {
......
......@@ -37,7 +37,7 @@ void lha_make_table(short nchar, unsigned char bitlen[], short tablebits, unsign
total += weight[i] * count[i];
}
if ((total & 0xffff) != 0)
error(L"make_table()", L"Bad table (5)\n");
error("make_table()", "Bad table (5)\n");
/* shift data for make table. */
m = 16 - tablebits;
......
......@@ -163,7 +163,7 @@ char *xxrealloc(char *old, int size)
{
char *p = (char *) xrealloc(char, old, size);
if (!p)
fatal_error(L"Not enough memory");
fatal_error("Not enough memory");
return p;
}
......
......@@ -667,7 +667,7 @@ struct zfile *archive_access_lzx (struct znode *zn)
unpsize -= decrunch_length;
crc_calc (pdest, decrunch_length);
} else {
write_log (L"LZX corrupt compressed data %s\n", zn->name);
write_log ("LZX corrupt compressed data %s\n", zn->name);
goto end;
}
}
......@@ -812,7 +812,7 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file)
else
abort = 0; /* continue */
//write_log (L"unp=%6d mrg=%6d pack=%6d off=%6d %s\n", unpack_size, merge_size, pack_size, zn->offset, zai.name);
//write_log ("unp=%6d mrg=%6d pack=%6d off=%6d %s\n", unpack_size, merge_size, pack_size, zn->offset, zai.name);
}
......
......@@ -403,8 +403,8 @@ struct zfile *unwarp(struct zfile *zf)
if (!iswrp (buf))
break;
if (!nf) {
nf = zfile_fopen_empty (zf, L"zipped.wrp", 1760 * 512);
tmpf = zfile_fopen_empty (zf, L"tmp", outsize2);
nf = zfile_fopen_empty (zf, "zipped.wrp", 1760 * 512);
tmpf = zfile_fopen_empty (zf, "tmp", outsize2);
}
track = (buf[10] << 8) | buf[11];
algo = buf[19];
......@@ -447,19 +447,19 @@ struct zfile *unwarp(struct zfile *zf)
}
break;
default:
write_log (L"WRP unknown compression method %d, track=%d,size=%d\n", algo, track, side);
write_log ("WRP unknown compression method %d, track=%d,size=%d\n", algo, track, side);
goto end;
break;
}
if (err) {
write_log (L"WRP corrupt data, track=%d,side=%d,err=%d\n", track, side, err);
write_log ("WRP corrupt data, track=%d,side=%d,err=%d\n", track, side, err);
} else {
uae_u16 crc2;
int os = zfile_ftell (tmpf);
data = zfile_getdata (tmpf, 0, os);
crc2 = wrpcrc16 (wrpcrc16table, data, os);
if (crc != crc2)
write_log (L"WRP crc error %04x<>%04x, track=%d,side=%d\n", crc, crc2, track, side);
write_log ("WRP crc error %04x<>%04x, track=%d,side=%d\n", crc, crc2, track, side);
xfree (data);
}
if (dstpos >= 0) {
......
......@@ -26,7 +26,7 @@ static int scsiemu[MAX_TOTAL_SCSI_DEVICES];
struct device_functions *device_func[MAX_TOTAL_SCSI_DEVICES];
static int openlist[MAX_TOTAL_SCSI_DEVICES];
static int waspaused[MAX_TOTAL_SCSI_DEVICES], wasslow[MAX_TOTAL_SCSI_DEVICES];
static int waspaused[MAX_TOTAL_SCSI_DEVICES];
static int delayed[MAX_TOTAL_SCSI_DEVICES];
/* convert minutes, seconds and frames -> logical sector number */
......@@ -469,7 +469,6 @@ static void check_changes (int unitnum)
struct device_info di;
device_func[unitnum]->info (unitnum, &di, 0);
wasopen[unitnum] = di.open;
wasslow[unitnum] = di.slow_unit;
if (wasopen[unitnum]) {
device_func[unitnum]->closedev (unitnum);
if (currprefs.scsi) {
......@@ -495,7 +494,7 @@ static void check_changes (int unitnum)
write_log ("CD: delayed insert '%s'\n", currprefs.cdslots[unitnum].name[0] ? currprefs.cdslots[unitnum].name : "<EMPTY>");
device_func_init (0);
if (wasopen[unitnum]) {
if (!device_func[unitnum]->opendev (unitnum, currprefs.cdslots[unitnum].name, wasslow[unitnum])) {
if (!device_func[unitnum]->opendev (unitnum, currprefs.cdslots[unitnum].name, 0)) {
write_log ("-> device open failed\n");
}
}
......@@ -622,18 +621,18 @@ int sys_command_cd_play (int unitnum, int startlsn, int endlsn, int scan)
return do_scsi (unitnum, cmd, sizeof cmd) ? 0 : 1;
}
//startlsn = adjustplaypos (unitnum, startlsn);
return device_func[unitnum]->play (unitnum, startlsn, endlsn, scan, NULL);
return device_func[unitnum]->play (unitnum, startlsn, endlsn, scan, NULL, NULL);
}
/* play CD audio with subchannels */
int sys_command_cd_play2 (int unitnum, int startlsn, int endlsn, int scan, play_subchannel_callback subfunc)
int sys_command_cd_play2 (int unitnum, int startlsn, int endlsn, int scan, play_status_callback statusfunc, play_subchannel_callback subfunc)
{
if (failunit (unitnum))
return 0;
if (device_func[unitnum]->play == NULL)
return sys_command_cd_play (unitnum, startlsn, endlsn, scan);
//startlsn = adjustplaypos (unitnum, startlsn);
return device_func[unitnum]->play (unitnum, startlsn, endlsn, scan, subfunc);
return device_func[unitnum]->play (unitnum, startlsn, endlsn, scan, statusfunc, subfunc);
}
/* set CD audio volume */
......@@ -1370,7 +1369,7 @@ static int scsi_emulate (int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len,
goto errreq;
start = toc->toc[toc->first_track_offset + start].paddress;
}
sys_command_cd_play2 (unitnum, start, end, scan, NULL);
sys_command_cd_play (unitnum, start, end, scan);
scsi_len = 0;
}
break;
......@@ -1390,7 +1389,7 @@ static int scsi_emulate (int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len,
goto errreq;
int start = toc->toc[toc->first_track_offset + strack - 1].paddress;
int end = etrack == toc->last_track ? toc->lastaddress : toc->toc[toc->first_track_offset + etrack - 1 + 1].paddress;
if (!sys_command_cd_play2 (unitnum, start, end, 0, NULL))
if (!sys_command_cd_play (unitnum, start, end, 0))
goto notdatatrack;
scsi_len = 0;
}
......@@ -1411,7 +1410,7 @@ static int scsi_emulate (int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len,
if (end > di.toc.lastaddress)
end = di.toc.lastaddress;
if (len > 0) {
if (!sys_command_cd_play2 (unitnum, start, start + len, 0, NULL))
if (!sys_command_cd_play (unitnum, start, start + len, 0))
goto notdatatrack;
}
scsi_len = 0;
......@@ -1434,7 +1433,7 @@ static int scsi_emulate (int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len,
if (start > end)
goto errreq;
if (start < end)
if (!sys_command_cd_play2 (unitnum, start, end, 0, NULL))
if (!sys_command_cd_play (unitnum, start, end, 0))
goto notdatatrack;
scsi_len = 0;
}
......@@ -1459,7 +1458,7 @@ static int scsi_emulate (int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len,
int end = start + len;
if (end > di.toc.lastaddress)
end = di.toc.lastaddress;
if (!sys_command_cd_play2 (unitnum, start, end, 0, NULL))
if (!sys_command_cd_play (unitnum, start, end, 0))
goto notdatatrack;
}
scsi_len = 0;
......@@ -1483,7 +1482,7 @@ static int scsi_emulate (int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len,
if (start > end)
goto errreq;
if (start < end) {
if (!sys_command_cd_play2 (unitnum, start, end, 0, NULL))
if (!sys_command_cd_play (unitnum, start, end, 0))
goto notdatatrack;
}
}
......
......@@ -78,9 +78,9 @@ static volatile uae_u32 dmac_acr;
static volatile int dmac_wtc;
static volatile int dmac_dma;
static volatile int activate_stch, cdrom_command_done, play_state, play_statewait;
static volatile int activate_stch, cdrom_command_done;
static volatile int cdrom_sector, cdrom_sectors, cdrom_length, cdrom_offset;
static volatile int cd_playing, cd_paused, cd_motor, cd_media, cd_error, cd_finished, cd_isready;
static volatile int cd_playing, cd_paused, cd_motor, cd_media, cd_error, cd_finished, cd_isready, cd_audio_finished;
static uae_u32 last_play_pos, last_play_end;
static volatile int cdtv_hsync, dma_finished, cdtv_sectorsize;
......@@ -142,28 +142,10 @@ static int get_toc (void)
return 1;
}
static void finished_cdplay (void)
{
cd_audio_status = AUDIO_STATUS_PLAY_COMPLETE;
cd_playing = 0;
cd_finished = 1;
cd_paused = 0;
do_stch ();
}
static int get_qcode (void)
{
if (!sys_command_cd_qcode (unitnum, cdrom_qcode))
return 0;
if (cd_playing) {
if (cdrom_qcode[1] == AUDIO_STATUS_IN_PROGRESS) {
int end = msf2lsn (fromlongbcd (cdrom_qcode + 4 + 7));
if (end >= play_end - 75)
finished_cdplay ();
} else if (cdrom_qcode[1] == AUDIO_STATUS_PLAY_COMPLETE) {
finished_cdplay ();
}
}
cdrom_qcode[1] = cd_audio_status;
return 1;
}
......@@ -187,6 +169,7 @@ static void cdaudiostop (void)
cd_playing = 0;
cd_paused = 0;
cd_motor = 0;
cd_audio_finished = 0;
write_comm_pipe_u32 (&requests, 0x0104, 1);
}
......@@ -285,7 +268,24 @@ static void subfunc (uae_u8 *data, int cnt)
subcodebufferoffsetw = offset;
uae_sem_post (&sub_sem);
}
static int statusfunc (int status)
{
if (status == -1)
return 500;
if (status == -2)
return 75;
if (cd_audio_status != status) {
if (status == AUDIO_STATUS_PLAY_COMPLETE || status == AUDIO_STATUS_PLAY_ERROR) {
cd_audio_finished = 1;
} else {
if (status == AUDIO_STATUS_IN_PROGRESS)
cd_playing = 1;
activate_stch = 1;
}
}
cd_audio_status = status;
return 0;
}
static void do_play (void)
{
......@@ -294,15 +294,21 @@ static void do_play (void)
uae_u32 scan = read_comm_pipe_u32_blocking (&requests);
subreset ();
sys_command_cd_pause (unitnum, 0);
cd_audio_status = AUDIO_STATUS_PLAY_ERROR;
sys_command_cd_volume (unitnum, (cd_volume_stored << 5) | (cd_volume_stored >> 5), (cd_volume_stored << 5) | (cd_volume_stored >> 5));
if (sys_command_cd_play2 (unitnum, start, end, 0, subfunc)) {
cd_audio_status = AUDIO_STATUS_IN_PROGRESS;
cd_playing = 1;
} else {
cd_error = 1;
}
sys_command_cd_play2 (unitnum, start, end, 0, statusfunc, subfunc);
}
static void startplay (void)
{
subreset ();
write_comm_pipe_u32 (&requests, 0x0110, 0);
write_comm_pipe_u32 (&requests, play_start, 0);
write_comm_pipe_u32 (&requests, play_end, 0);
write_comm_pipe_u32 (&requests, 0, 1);
if (!cd_motor) {
cd_motor = 1;
activate_stch = 1;
}
}
static int play_cdtrack (uae_u8 *p)
......@@ -342,11 +348,11 @@ static int play_cdtrack (uae_u8 *p)
play_start = start;
last_play_pos = start;
last_play_end = end;
#ifdef CDTV_DEBUG
#ifdef CDTV_DEBUG_CMD
write_log ("PLAY CD AUDIO from %d-%d, %06X (%d) to %06X (%d)\n",
track_start, track_end, start, start, end, end);
#endif
play_state = 1;
startplay ();
return 0;
}
......@@ -366,11 +372,10 @@ static int play_cd (uae_u8 *p)
cd_playing = 0;
cd_paused = 0;
cd_motor = 0;
cd_audio_status = AUDIO_STATUS_PLAY_COMPLETE;
sys_command_cd_pause (unitnum, 0);
sys_command_cd_stop (unitnum);
cd_isready = 50;
write_comm_pipe_u32 (&requests, 0x0104, 1);
cd_audio_status = AUDIO_STATUS_NO_STATUS;
cd_error = 1;
activate_stch = 1;
return 0;
}
if (p[0] != 0x09) { /* msf */
......@@ -388,7 +393,7 @@ static int play_cd (uae_u8 *p)
write_log ("PLAY CD AUDIO from %06X (%d) to %06X (%d)\n",
lsn2msf (start), start, lsn2msf (end), end);
#endif
play_state = 1;
startplay ();
return 0;
}
......@@ -512,9 +517,10 @@ static void cdrom_command_thread (uae_u8 b)
{
case 0x01: /* seek */
if (cdrom_command_cnt_in == 7) {
uae_msleep (500);
cdrom_command_accepted (0, s, &cdrom_command_cnt_in);
cd_finished = 1;
uae_msleep (500);
activate_stch = 1;
}
break;
case 0x02: /* read */
......@@ -799,8 +805,7 @@ static void init_play (int start, int end)
write_log ("PLAY CD AUDIO from %06X (%d) to %06X (%d)\n",
lsn2msf (start), start, lsn2msf (end), end);
#endif
play_state = 1;
subreset ();
startplay ();
}
bool cdtv_front_panel (int button)
......@@ -1168,7 +1173,17 @@ void CDTV_hsync_handler (void)
sten = 0;
}
if (cd_audio_finished) {
cd_audio_finished = 0;
cd_playing = 0;
cd_finished = 1;
cd_paused = 0;
//cd_error = 1;
activate_stch = 1;
}
static int subchannelcounter;
int cntmax = maxvpos * vblank_hz / 75 - 6;
if (subchannelcounter > 0)
subchannelcounter--;
if (subchannelcounter <= 0) {
......@@ -1193,7 +1208,7 @@ void CDTV_hsync_handler (void)
tp_check_interrupts ();
}
uae_sem_post (&sub_sem);
subchannelcounter = 200;
subchannelcounter = cntmax;
}
}
if (!scor && !cd_playing) {
......@@ -1201,35 +1216,14 @@ void CDTV_hsync_handler (void)
scor = 1;
tp_check_interrupts ();
scor = 0;
subchannelcounter = 200;
subchannelcounter = cntmax;
}
}
if (cdtv_hsync < 200 && cdtv_hsync >= 0)
if (cdtv_hsync < cntmax && cdtv_hsync >= 0)
return;
cdtv_hsync = 0;
if (play_state == 1) {
play_state = 2;
cd_playing = 1;
cd_motor = 1;
activate_stch = 1;
play_statewait = 2;
} else if (play_statewait > 0) {
play_statewait--;
} else if (play_state == 2) {
write_comm_pipe_u32 (&requests, 0x0110, 0);
write_comm_pipe_u32 (&requests, play_start, 0);
write_comm_pipe_u32 (&requests, play_end, 0);
write_comm_pipe_u32 (&requests, 0, 1);
play_state = 0;
}
if (cd_isready > 0) {
cd_isready--;
if (!cd_isready)
do_stch ();
}
if (dmac_dma || dma_finished)
cd_led |= LED_CD_ACTIVE;
else
......@@ -1884,7 +1878,7 @@ uae_u8 *save_cdtv (int *len)
(cd_motor ? 8 : 0) | (cd_error ? 16 : 0) | (cd_finished ? 32 : 0) | (cdrom_command_done ? 64 : 0) |
(activate_stch ? 128 : 0) | (sten ? 256 : 0) | (stch ? 512 : 0) | (frontpanel ? 1024 : 0));
save_u8 (cd_isready);
save_u8 (play_state);
save_u8 (0);
save_u16 (cd_volume_stored);
if (cd_playing)
get_qcode ();
......@@ -1939,7 +1933,7 @@ uae_u8 *restore_cdtv (uae_u8 *src)
stch = (v & 512) ? 1 : 0;
frontpanel = (v & 1024) ? 1 : 0;
cd_isready = restore_u8 ();
play_state = restore_u8 ();
restore_u8 ();
cd_volume_stored = restore_u16 ();
last_play_pos = restore_u32 ();
last_play_end = restore_u32 ();
......
......@@ -1954,14 +1954,12 @@ STATIC_INLINE void do_color_changes (line_draw_func worker_border, line_draw_fun
(*worker_border) (lastpos, nextpos_in_range);
lastpos = nextpos_in_range;
}
if (i != dip_for_drawing->last_color_change) {
if (regno >= 0x1000) {
pfield_expand_dp_bplconx (regno, value);
} else {
} else if (regno >= 0) {
color_reg_set (&colors_for_drawing, regno, value);
colors_for_drawing.acolors[regno] = getxcolor (value);
}
}
if (lastpos >= endpos)
break;
}
......
......@@ -42,6 +42,7 @@ extern int action_replay_load (void);
extern void action_replay_memory_reset (void);
extern void action_replay_init (int);
extern void action_replay_cleanup (void);
//extern void action_replay_map_banks (void);
extern void REGPARAM3 chipmem_lput_actionreplay23 (uaecptr addr, uae_u32 l) REGPARAM;
extern void REGPARAM3 chipmem_wput_actionreplay23 (uaecptr addr, uae_u32 w) REGPARAM;
extern void REGPARAM3 chipmem_bput_actionreplay1 (uaecptr addr, uae_u32 b) REGPARAM;
......
......@@ -80,7 +80,6 @@ struct device_info {
TCHAR productid[18];
TCHAR revision[6];
TCHAR *backend;
int slow_unit;
struct cd_toc_head toc;
};
......@@ -110,10 +109,11 @@ typedef uae_u8* (*execscsicmd_in_func) (int, uae_u8*, int, int*);
typedef int (*execscsicmd_direct_func) (int, struct amigascsi*);
typedef void (*play_subchannel_callback) (uae_u8*, int);
typedef int (*play_status_callback) (int);
typedef int (*pause_func) (int, int);
typedef int (*stop_func) (int);
typedef int (*play_func) (int, int, int, int, play_subchannel_callback);
typedef int (*play_func) (int, int, int, int, play_status_callback, play_subchannel_callback);
typedef uae_u32 (*volume_func) (int, uae_u16, uae_u16);
typedef int (*qcode_func) (int, uae_u8*, int);
typedef int (*toc_func) (int, struct cd_toc_head*);
......@@ -160,7 +160,7 @@ extern struct device_info *sys_command_info (int unitnum, struct device_info *di
extern int sys_command_cd_pause (int unitnum, int paused);
extern void sys_command_cd_stop (int unitnum);
extern int sys_command_cd_play (int unitnum, int startlsn, int endlsn, int);
extern int sys_command_cd_play2 (int unitnum, int startlsn, int endlsn, int scan, play_subchannel_callback subfunc);
extern int sys_command_cd_play2 (int unitnum, int startlsn, int endlsn, int scan, play_status_callback statusfunc, play_subchannel_callback subfunc);
extern uae_u32 sys_command_cd_volume (int unitnum, uae_u16 volume_left, uae_u16 volume_right);
extern int sys_command_cd_qcode (int unitnum, uae_u8*);
extern int sys_command_cd_toc (int unitnum, struct cd_toc_head*);
......
......@@ -52,28 +52,28 @@ struct romlist {
struct romdata *rd;
};
extern struct romdata *getromdatabypath (TCHAR *path);
extern struct romdata *getromdatabypath (const TCHAR *path);
extern struct romdata *getromdatabycrc (uae_u32 crc32);
extern struct romdata *getromdatabydata (uae_u8 *rom, int size);
extern struct romdata *getromdatabyid (int id);
extern struct romdata *getromdatabyidgroup (int id, int group, int subitem);
//extern struct romdata *getromdatabyzfile (struct zfile *f);
extern struct romlist **getarcadiaroms (void);
extern struct romdata *getarcadiarombyname (TCHAR *name);
extern struct romlist **getromlistbyident (int ver, int rev, int subver, int subrev, TCHAR *model, int all);
extern void getromname (struct romdata*, TCHAR*);
extern struct romdata *getarcadiarombyname (const TCHAR *name);
extern struct romlist **getromlistbyident (int ver, int rev, int subver, int subrev, const TCHAR *model, int all);
extern void getromname (const struct romdata*, TCHAR*);
//extern struct romdata *getromdatabyname (const TCHAR*);
extern struct romlist *getromlistbyids (int *ids);
extern void romwarning(int *ids);
extern struct romlist *getromlistbyromdata (struct romdata *rd);
extern void romlist_add (TCHAR *path, struct romdata *rd);
extern TCHAR *romlist_get (struct romdata *rd);
extern struct romlist *getromlistbyids (const int *ids);
extern void romwarning(const int *ids);
extern struct romlist *getromlistbyromdata (const struct romdata *rd);
extern void romlist_add (const TCHAR *path, struct romdata *rd);
extern TCHAR *romlist_get (const struct romdata *rd);
extern void romlist_clear (void);
extern struct zfile *read_rom (struct romdata **rd);
extern struct zfile *read_rom_name (const TCHAR *filename);
extern int load_keyring (struct uae_prefs *p, TCHAR *path);
extern uae_u8 *target_load_keyfile (struct uae_prefs *p, TCHAR *path, int *size, TCHAR *name);
extern int load_keyring (struct uae_prefs *p, const TCHAR *path);
extern uae_u8 *target_load_keyfile (struct uae_prefs *p, const TCHAR *path, int *size, TCHAR *name);
extern void free_keyring (void);
extern int get_keyring (void);
extern void kickstart_fix_checksum (uae_u8 *mem, int size);
......@@ -83,7 +83,8 @@ extern int decode_rom (uae_u8 *mem, int size, int mode, int real_size);
extern struct zfile *rom_fopen (const TCHAR *name, const TCHAR *mode, int mask);
extern struct zfile *read_rom_name_guess (const TCHAR *filename);
extern void addkeydir (const TCHAR *path);
extern void addkeyfile (const TCHAR *path);
extern int romlist_count (void);
extern struct romlist *romlist_getit (void);
extern int configure_rom (struct uae_prefs *p, int *rom, int msg);
extern int configure_rom (struct uae_prefs *p, const int *rom, int msg);
......@@ -20,8 +20,8 @@ extern uae_u32 restore_u32_func (uae_u8 **);
extern uae_u16 restore_u16_func (uae_u8 **);
extern uae_u8 restore_u8_func (uae_u8 **);
extern void save_string_func (uae_u8 **, const char *);
extern char *restore_string_func (const uae_u8 **);
extern void save_string_func (uae_u8 **, const TCHAR*);
extern TCHAR *restore_string_func (uae_u8 **);
#define save_u64(x) save_u64_func (&dst, (x))
#define save_u32(x) save_u32_func (&dst, (x))
......@@ -151,9 +151,9 @@ extern uae_u8 *save_action_replay (int *, uae_u8 *);
extern uae_u8 *restore_hrtmon (uae_u8 *);
extern uae_u8 *save_hrtmon (int *, uae_u8 *);
extern void savestate_initsave (const char *filename, int docompress, int nodialogs);
extern int save_state (const char *filename, const char *description);
extern void restore_state (const char *filename);
extern void savestate_initsave (const TCHAR *filename, int docompress, int nodialogs);
extern int save_state (const TCHAR *filename, const TCHAR *description);
extern void restore_state (const TCHAR *filename);
extern void savestate_restore_finish (void);
extern void custom_save_state (void);
......@@ -167,7 +167,7 @@ extern void custom_prepare_savestate (void);
#define STATE_DOREWIND 32
extern int savestate_state;
extern char savestate_fname[MAX_DPATH];
extern TCHAR savestate_fname[MAX_DPATH];
extern struct zfile *savestate_file;
extern void savestate_quick (int slot, int save);
......
......@@ -425,4 +425,5 @@ extern void xfree (const void*);
#define true 1
#define false 0
#define _vsntprintf vsnprintf
#define max(a,b) ((a) > (b) ? (a) : (b))
#endif
......@@ -424,7 +424,7 @@ uae_u32 emulib_target_getcpurate (uae_u32 v, uae_u32 *low)
*/
return 0;
}
/*
int isfat (uae_u8 *p)
{
int i, b;
......@@ -454,7 +454,7 @@ int isfat (uae_u8 *p)
return 0;
return 1;
}
*/
void setmouseactivexy (int x, int y, int dir)
{
/* int diff = 8;
......
/*
/*
* UAE - The Un*x Amiga Emulator
*
* Call Amiga Exec functions outside the main UAE thread.
......
......@@ -8,6 +8,7 @@
#define MOVEC_DEBUG 0
#define MMUOP_DEBUG 2
#define DEBUG_CD32CDTVIO 0
#include "sysconfig.h"
#include "sysdeps.h"
......@@ -2675,8 +2676,7 @@ STATIC_INLINE int do_specialties (int cycles)
//static uae_u32 pcs[1000];
//#define DEBUG_CD32CDTVIO
#ifdef DEBUG_CD32CDTVIO
#if DEBUG_CD32CDTVIO
static uae_u32 cd32nextpc, cd32request;
......@@ -2768,7 +2768,7 @@ static void m68k_run_1 (void)
count_instr (opcode);
#ifdef DEBUG_CD32CDTVIO
#if DEBUG_CD32CDTVIO
out_cd32io (m68k_getpc ());
#endif
......@@ -2815,7 +2815,7 @@ static void m68k_run_1_ce (void)
ipl_fetch ();
for (;;) {
uae_u32 opcode = r->ir;
#ifdef DEBUG_CD32CDTVIO
#if DEBUG_CD32CDTVIO
out_cd32io (m68k_getpc ());
#endif
(*cpufunctbl[opcode])(opcode);
......@@ -2947,7 +2947,7 @@ static void opcodedebug (uae_u32 pc, uae_u16 opcode)
if (!fault) {
TCHAR buf[100];
write_log ("mmufixup=%d %04x %04x\n", mmufixup[0].reg, regs.wb3_status, regs.mmu_ssw);
m68k_disasm_2 (buf, 100, addr, NULL, 1, NULL, NULL, 0);
m68k_disasm_2 (buf, sizeof buf / sizeof (TCHAR), addr, NULL, 1, NULL, NULL, 0);
write_log ("%s\n", buf);
m68k_dumpstate (stdout, NULL);
}
......@@ -3050,7 +3050,7 @@ static void m68k_run_2p (void)
uae_u32 opcode;
uae_u32 pc = m68k_getpc ();
#ifdef DEBUG_CD32CDTVIO
#if DEBUG_CD32CDTVIO
out_cd32io (m68k_getpc ());
#endif
......
......@@ -27,6 +27,7 @@
* accesses which may be rather slow.
*
* TODO:
* - add panning capability
* - we want to add a manual switch to override SetSwitch for hardware banging
* programs started from a Picasso workbench.
*/
......@@ -47,7 +48,7 @@
int have_done_picasso = 0; /* For the JIT compiler */
int picasso_is_special = PIC_WRITE; /* ditto */
int picasso_is_special_read = PIC_READ; /* ditto */
# endif
#endif
#ifdef PICASSO96
......@@ -139,8 +140,7 @@ static void DumpLibResolutionStructure (uaecptr amigalibresptr)
{
int i;
uaecptr amigamodeinfoptr;
struct LibResolution *uaememptr = (struct LibResolution *)
get_mem_bank (amigalibresptr).xlateaddr (amigalibresptr);
struct LibResolution *uaememptr = (struct LibResolution *) get_mem_bank (amigalibresptr).xlateaddr (amigalibresptr);
return;
......@@ -255,8 +255,8 @@ STATIC_INLINE uae_u8 GetBytesPerPixel (uae_u32 RGBfmt)
/*
* Amiga <-> native structure conversion functions
*/
static int CopyRenderInfoStructureA2U (uaecptr amigamemptr,
struct RenderInfo *ri)
static int CopyRenderInfoStructureA2U (uaecptr amigamemptr, struct RenderInfo *ri)
{
uaecptr memp = get_long (amigamemptr + PSSO_RenderInfo_Memory);
......@@ -271,8 +271,7 @@ static int CopyRenderInfoStructureA2U (uaecptr amigamemptr,
return 0;
}
static int CopyPatternStructureA2U (uaecptr amigamemptr,
struct Pattern *pattern)
static int CopyPatternStructureA2U (uaecptr amigamemptr, struct Pattern *pattern)
{
uaecptr memp = get_long (amigamemptr + PSSO_Pattern_Memory);
......@@ -290,8 +289,7 @@ static int CopyPatternStructureA2U (uaecptr amigamemptr,
return 0;
}
static void CopyColorIndexMappingA2U (uaecptr amigamemptr,
struct ColorIndexMapping *cim)
static void CopyColorIndexMappingA2U (uaecptr amigamemptr, struct ColorIndexMapping *cim)
{
int i;
cim->ColorMask = get_long (amigamemptr);
......@@ -309,8 +307,7 @@ static int CopyBitMapStructureA2U (uaecptr amigamemptr, struct BitMap *bm)
bm->Depth = get_byte (amigamemptr + PSSO_BitMap_Depth);
if (bm->Depth > 8) {
write_log ("P96: WARNING - Can't handle %d-bit deep bitmap\n",
bm->Depth);
write_log ("P96: WARNING - Can't handle %d-bit deep bitmap\n", bm->Depth);
return 0;
}
......@@ -334,8 +331,7 @@ static int CopyBitMapStructureA2U (uaecptr amigamemptr, struct BitMap *bm)
return 1;
}
static int CopyTemplateStructureA2U (uaecptr amigamemptr,
struct Template *tmpl)
static int CopyTemplateStructureA2U (uaecptr amigamemptr, struct Template *tmpl)
{
uaecptr memp = get_long (amigamemptr + PSSO_Template_Memory);
......@@ -352,10 +348,9 @@ static int CopyTemplateStructureA2U (uaecptr amigamemptr,
return 0;
}
static void CopyLibResolutionStructureU2A (struct LibResolution *libres,
uaecptr amigamemptr)
static void CopyLibResolutionStructureU2A (struct LibResolution *libres, uaecptr amigamemptr)
{
uae_u8 *uaememptr = 0;
char *uaememptr = 0;
int i;
/* I know that amigamemptr is inside my gfxmem chunk, so I can just do the xlate() */
......@@ -424,8 +419,7 @@ static void do_fillrect (uae_u8 *src, int x, int y, int width, int height,
{
uae_u8 *dst;
P96TRACE (("P96: do_fillrect (src:%08x x:%d y:%d w:%d h%d pen:%08x)\n",
src, x, y, width, height, pen));
P96TRACE (("P96: do_fillrect (src:%08x x:%d y:%d w:%d h%d pen:%08x)\n", src, x, y, width, height, pen));
/* Clipping. */
x -= picasso96_state.XOffset;
......@@ -621,8 +615,7 @@ static void do_blit (struct RenderInfo *ri, int Bpp, int srcx, int srcy,
* Invert a rectangle on the screen.
*/
static void do_invertrect (struct RenderInfo *ri, int Bpp, int x, int y,
int width, int height)
static void do_invertrect (struct RenderInfo *ri, int Bpp, int x, int y, int width, int height)
{
#if 0
/* Clipping. */
......@@ -781,8 +774,7 @@ void picasso_refresh (int call_setpalette)
height = picasso96_state.Height;
}
do_blit (&ri, picasso96_state.BytesPerPixel, 0, 0, 0, 0, width,
height, BLIT_SRC, 0);
do_blit (&ri, picasso96_state.BytesPerPixel, 0, 0, 0, 0, width, height, BLIT_SRC, 0);
} else
write_log ("P96: ERROR - picasso_refresh() can't refresh!\n");
}
......@@ -812,7 +804,7 @@ STATIC_INLINE void do_blitrect_frame_buffer (struct RenderInfo *ri,
}
if (mask == 0xFF || Bpp > 1) {
if( opcode == BLIT_SRC ) {
if (opcode == BLIT_SRC) {
/* handle normal case efficiently */
if (ri->Memory == dstri->Memory && dsty == srcy) {
unsigned long i;
......@@ -838,10 +830,10 @@ STATIC_INLINE void do_blitrect_frame_buffer (struct RenderInfo *ri,
unsigned int y;
for (y = 0; y < height; y++) {
uae_u32 *bound = (uae_u32 *)(src + total_width - 4);
int bound = src + total_width - 4;
//copy now the longs
for (src2_32 = (uae_u32*)src, dst2_32 = (uae_u32*)dst; src2_32 < bound; src2_32++, dst2_32++ ) {
switch ((uae_u8) opcode) {
for (src2_32 = src, dst2_32 = dst; src2_32 < bound; src2_32++, dst2_32++) {
switch (opcode) {
case BLIT_FALSE:
*dst2_32 = 0;
break;
......@@ -1200,7 +1192,7 @@ uae_u32 picasso_SetSwitch (void)
* whenever it is ready to change the screen state. */
picasso_requested_on = !!flag;
#ifdef JIT
flush_icache (0, 5); /* Changing the screen mode might make gfx memory
flush_icache(0, 5); /* Changing the screen mode might make gfx memory
directly accessible, or no longer thus accessible */
#endif
......@@ -1480,7 +1472,7 @@ uae_u32 picasso_InvertRect (void)
unsigned long Y = (uae_u16)m68k_dreg (regs, 1);
unsigned long Width = (uae_u16)m68k_dreg (regs, 2);
unsigned long Height = (uae_u16)m68k_dreg (regs, 3);
uae_u8 mask = (uae_u8) m68k_dreg (regs, 4);
uae_u8 mask = (uae_u8)m68k_dreg (regs, 4);
int Bpp = GetBytesPerPixel (m68k_dreg (regs, 7));
uae_u32 xorval;
unsigned int lines;
......@@ -1563,7 +1555,7 @@ STATIC_INLINE void do_fillrect_frame_buffer (struct RenderInfo *ri, int X, int Y
memcpy (dst, src, Width * Bpp);
} else {
for (lines = 0; lines < (Height - 1); lines++, dst += ri->BytesPerRow)
memset( dst, Pen, Width );
memset (dst, Pen, Width);
}
}
......@@ -1588,7 +1580,7 @@ uae_u32 picasso_FillRect (void)
uae_u32 Width = (uae_u16)m68k_dreg (regs, 2);
uae_u32 Height = (uae_u16)m68k_dreg (regs, 3);
uae_u32 Pen = m68k_dreg (regs, 4);
uae_u8 Mask = (uae_u8) m68k_dreg (regs, 5);
uae_u8 Mask = (uae_u8)m68k_dreg (regs, 5);
RGBFTYPE RGBFormat = m68k_dreg (regs, 7);
uae_u8 *src;
......@@ -1625,7 +1617,7 @@ uae_u32 picasso_FillRect (void)
if (Width == 1) {
for (i = 0; i < Height; i++) {
if( Bpp == 4 )
if (Bpp == 4)
gfxmem_lput (addr + (i * picasso96_state.BytesPerRow), Pen);
else if (Bpp == 2)
gfxmem_wput (addr + (i * picasso96_state.BytesPerRow), Pen);
......@@ -1639,7 +1631,7 @@ uae_u32 picasso_FillRect (void)
else if (Bpp == 2)
gfxmem_wput (addr + (i*Bpp), Pen);
else
gfxmem_bput( addr + (i*Bpp), Pen );
gfxmem_bput (addr + (i*Bpp), Pen);
}
}
return 1;
......@@ -1691,7 +1683,7 @@ uae_u32 picasso_FillRect (void)
}
}
if (renderinfo_is_current_screen (&ri))
do_blit (&ri, Bpp, X, Y, X, Y, Width, Height, BLIT_SRC, 0);
do_blit( &ri, Bpp, X, Y, X, Y, Width, Height, BLIT_SRC, 0);
result = 1;
}
}
......@@ -1703,25 +1695,25 @@ uae_u32 picasso_FillRect (void)
/*
* BlitRect() is a generic (any chunky pixel format) rectangle copier
* NOTE: If dstri is NULL, then we're only dealing with one RenderInfo area, and called from picasso_BlitRect()
*
* OpCodes:
* 0 = FALSE: dst = 0
* 1 = NOR: dst = ~(src | dst)
* 2 = ONLYDST: dst = dst & ~src
* 3 = NOTSRC: dst = ~src
* 4 = ONLYSRC: dst = src & ~dst
* 5 = NOTDST: dst = ~dst
* 6 = EOR: dst = src^dst
* 7 = NAND: dst = ~(src & dst)
* 8 = AND: dst = (src & dst)
* 9 = NEOR: dst = ~(src ^ dst)
*10 = DST: dst = dst
*11 = NOTONLYSRC: dst = ~src | dst
*12 = SRC: dst = src
*13 = NOTONLYDST: dst = ~dst | src
*14 = OR: dst = src | dst
*15 = TRUE: dst = 0xFF
*/
*
* OpCodes:
* 0 = FALSE: dst = 0
* 1 = NOR: dst = ~(src | dst)
* 2 = ONLYDST: dst = dst & ~src
* 3 = NOTSRC: dst = ~src
* 4 = ONLYSRC: dst = src & ~dst
* 5 = NOTDST: dst = ~dst
* 6 = EOR: dst = src^dst
* 7 = NAND: dst = ~(src & dst)
* 8 = AND: dst = (src & dst)
* 9 = NEOR: dst = ~(src ^ dst)
* 10 = DST: dst = dst
* 11 = NOTONLYSRC: dst = ~src | dst
* 12 = SRC: dst = src
* 13 = NOTONLYDST: dst = ~dst | src
* 14 = OR: dst = src | dst
* 15 = TRUE: dst = 0xFF
*/
struct blitdata
{
struct RenderInfo ri_struct;
......@@ -1807,7 +1799,7 @@ STATIC_INLINE int BlitRect (uaecptr ri, uaecptr dstri,
blitrectdata.ri = &blitrectdata.ri_struct;
if (dstri) {
CopyRenderInfoStructureA2U( dstri, &blitrectdata.dstri_struct );
CopyRenderInfoStructureA2U (dstri, &blitrectdata.dstri_struct);
blitrectdata.dstri = &blitrectdata.dstri_struct;
} else
blitrectdata.dstri = NULL;
......@@ -2012,10 +2004,10 @@ uae_u32 picasso_BlitPattern (void)
pattern.DrawMode &= 0x03;
if (Mask != 0xFF) {
if( Bpp > 1 )
if (Bpp > 1)
Mask = 0xFF;
if( pattern.DrawMode == COMP)
if (pattern.DrawMode == COMP)
write_log ("WARNING - BlitPattern() has unhandled mask 0x%x with COMP DrawMode. Using fall-back routine.\n", Mask);
else
result = 1;
......@@ -2103,7 +2095,7 @@ uae_u32 picasso_BlitPattern (void)
/* If we need to update a second-buffer (extra_mem is set), then do it only if visible! */
if (picasso_vidinfo.extra_mem && renderinfo_is_current_screen (&ri))
do_blit (&ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0);
do_blit( &ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0);
result = 1;
}
......@@ -2195,9 +2187,9 @@ uae_u32 picasso_BlitTemplate (void)
bitoffset = tmp.XOffset % 8;
# if defined( P96TRACING_ENABLED ) && ( P96TRACING_LEVEL > 0 )
DumpTemplate (&tmp, W, H);
# endif
#if defined (P96TRACING_ENABLED) && (P96TRACING_LEVEL > 0)
DumpTemplate(&tmp, W, H);
#endif
tmpl_base = tmp.Memory + tmp.XOffset / 8;
......@@ -2786,7 +2778,7 @@ static void REGPARAM2 gfxmem_wput (uaecptr addr, uae_u32 w)
addr -= gfxmem_start;
addr &= gfxmem_mask;
m = (uae_u16 *) (gfxmemory + addr);
do_put_mem_word (m, (uae_u16)w);
do_put_mem_word (m, (uae_u16) w);
/* write the word to our displayable memory */
write_gfx_word (addr, (uae_u16) w);
......
/*
/*
* UAE - The Un*x Amiga Emulator
*
* ROM file management
......@@ -30,7 +30,7 @@ int romlist_count (void)
return romlist_cnt;
}
TCHAR *romlist_get (struct romdata *rd)
TCHAR *romlist_get (const struct romdata *rd)
{
int i;
......@@ -43,7 +43,7 @@ TCHAR *romlist_get (struct romdata *rd)
return 0;
}
static struct romlist *romlist_getrl (struct romdata *rd)
static struct romlist *romlist_getrl (const struct romdata *rd)
{
int i;
......@@ -57,7 +57,7 @@ static struct romlist *romlist_getrl (struct romdata *rd)
}
static void romlist_cleanup (void);
void romlist_add (TCHAR *path, struct romdata *rd)
void romlist_add (const TCHAR *path, struct romdata *rd)
{
struct romlist *rl2;
......@@ -73,7 +73,7 @@ void romlist_add (TCHAR *path, struct romdata *rd)
}
struct romdata *getromdatabypath (TCHAR *path)
struct romdata *getromdatabypath (const TCHAR *path)
{
int i;
for (i = 0; i < romlist_cnt; i++) {
......@@ -88,7 +88,7 @@ struct romdata *getromdatabypath (TCHAR *path)
return NULL;
}
#define NEXT_ROM_ID 73
#define NEXT_ROM_ID 74
static struct romheader romheaders[] = {
{ "Freezer Cartridges", 1 },
......@@ -106,6 +106,8 @@ static struct romdata roms[] = {
0x869ae1b1, 0x801bbab3,0x2e3d3738,0x6dd1636d,0x4f1d6fa7,0xe21d5874 },
{ "Cloanto Amiga Forever 2006 ROM key", 0, 0, 0, 0, 0, 750, 48, 0, 1, ROMTYPE_KEY, 0, 0, NULL,
0xb01c4b56, 0xbba8e5cd,0x118b8d92,0xafed5693,0x5eeb9770,0x2a662d8f },
{ "Cloanto Amiga Forever 2010 ROM key", 0, 0, 0, 0, 0, 1544, 73, 0, 1, ROMTYPE_KEY, 0, 0, NULL,
0x8c4dd05c, 0x05034f62,0x0b5bb7b2,0x86954ea9,0x164fdb90,0xfb2897a4 },
{ "KS ROM v1.0 (A1000)(NTSC)", 1, 0, 1, 0, "A1000\0", 262144, 1, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
0x299790ff, 0x00C15406,0xBEB4B8AB,0x1A16AA66,0xC05860E1,0xA7C1AD79 },
......@@ -135,8 +137,8 @@ static struct romdata roms[] = {
0x43b0df7b, 0x02843C42,0x53BBD29A,0xBA535B0A,0xA3BD9A85,0x034ECDE4 },
{ "KS ROM v2.04 (A3000)", 2, 4, 37, 175, "A3000\0", 524288, 71, 3, 0, ROMTYPE_KICK, 0, 0, NULL,
0x234a7233, 0xd82ebb59,0xafc53540,0xddf2d718,0x7ecf239b,0x7ea91590 },
ALTROMPN(71, 1, 1, 262144, ROMTYPE_EVEN, "390629-03", 0x7db1332b,0x48f14b31,0x279da675,0x7848df6f,0xeb531881,0x8f8f576c)
ALTROMPN(71, 1, 2, 262144, ROMTYPE_ODD , "390630-03", 0xa245dbdf,0x83bab8e9,0x5d378b55,0xb0c6ae65,0x61385a96,0xf638598f)
ALTROMPN(71, 1, 1, 262144, ROMTYPE_EVEN, "390629-03", 0xa245dbdf,0x83bab8e9,0x5d378b55,0xb0c6ae65,0x61385a96,0xf638598f)
ALTROMPN(71, 1, 2, 262144, ROMTYPE_ODD , "390630-03", 0x7db1332b,0x48f14b31,0x279da675,0x7848df6f,0xeb531881,0x8f8f576c)
{ "KS ROM v3.0 (A1200)", 3, 0, 39, 106, "A1200\0", 524288, 11, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
0x6c9b07d2, 0x70033828,0x182FFFC7,0xED106E53,0x73A8B89D,0xDA76FAA5 },
......@@ -377,7 +379,7 @@ static void romlist_cleanup (void)
}
}
struct romlist **getromlistbyident (int ver, int rev, int subver, int subrev, TCHAR *model, int all)
struct romlist **getromlistbyident (int ver, int rev, int subver, int subrev, const TCHAR *model, int all)
{
int i, j, ok, out, max;
struct romdata *rd;
......@@ -457,7 +459,7 @@ struct romlist **getromlistbyident (int ver, int rev, int subver, int subrev, TC
return rdout;
}
struct romdata *getarcadiarombyname (TCHAR *name)
struct romdata *getarcadiarombyname (const TCHAR *name)
{
int i;
for (i = 0; roms[i].name; i++) {
......@@ -465,7 +467,7 @@ struct romdata *getarcadiarombyname (TCHAR *name)
TCHAR *p = roms[i].name;
p = p + _tcslen (p) + 1;
if (_tcslen (name) >= _tcslen (p) + 4) {
TCHAR *p2 = name + _tcslen (name) - _tcslen (p) - 4;
const TCHAR *p2 = name + _tcslen (name) - _tcslen (p) - 4;
if (!memcmp (p, p2, _tcslen (p)) && !memcmp (p2 + _tcslen (p2) - 4, ".zip", 4))
return &roms[i];
}
......@@ -516,7 +518,7 @@ static int kickstart_checksum_do (uae_u8 *mem, int size)
return cksum == 0xffffffff;
}
#define ROM_KEY_NUM 3
#define ROM_KEY_NUM 4
struct rom_key {
uae_u8 *key;
int size;
......@@ -554,7 +556,7 @@ static void addkey (uae_u8 *key, int size, const TCHAR *name)
write_log ("ROM KEY '%s' %d bytes loaded\n", name, size);
}
static void addkeyfile (const TCHAR *path)
void addkeyfile (const TCHAR *path)
{
struct zfile *f;
int keysize;
......@@ -602,12 +604,12 @@ int get_keyring (void)
return num;
}
int load_keyring (struct uae_prefs *p, TCHAR *path)
int load_keyring (struct uae_prefs *p, const TCHAR *path)
{
uae_u8 *keybuf;
int keysize;
TCHAR tmp[MAX_PATH], *d;
int keyids[] = { 0, 48, -1 };
int keyids[] = { 0, 48, 73, -1 };
int cnt, i;
free_keyring ();
......@@ -683,10 +685,10 @@ void free_keyring (void)
int i;
for (i = 0; i < ROM_KEY_NUM; i++)
xfree (keyring[i].key);
memset(keyring, 0, sizeof (struct rom_key) * ROM_KEY_NUM);
memset (keyring, 0, sizeof (struct rom_key) * ROM_KEY_NUM);
}
struct romdata *getromdatabyname (TCHAR *name)
struct romdata *getromdatabyname (const TCHAR *name)
{
TCHAR tmp[MAX_PATH];
int i = 0;
......@@ -742,7 +744,7 @@ struct romdata *getromdatabycrc (uae_u32 crc32)
return 0;
}
static int cmpsha1 (uae_u8 *s1, struct romdata *rd)
static int cmpsha1 (const uae_u8 *s1, const struct romdata *rd)
{
int i;
......@@ -756,7 +758,7 @@ static int cmpsha1 (uae_u8 *s1, struct romdata *rd)
return 0;
}
static struct romdata *checkromdata (uae_u8 *sha1, int size, uae_u32 mask)
static struct romdata *checkromdata (const uae_u8 *sha1, int size, uae_u32 mask)
{
int i = 0;
while (roms[i].name) {
......@@ -914,7 +916,7 @@ struct romdata *getromdatabyzfile (struct zfile *f)
return rd;
}
void getromname (struct romdata *rd, TCHAR *name)
void getromname (const struct romdata *rd, TCHAR *name)
{
name[0] = 0;
if (!rd)
......@@ -930,7 +932,7 @@ void getromname (struct romdata *rd, TCHAR *name)
_stprintf (name + _tcslen (name), " [%s]", rd->partnumber);
}
struct romlist *getromlistbyromdata (struct romdata *rd)
struct romlist *getromlistbyromdata (const struct romdata *rd)
{
int ids[2];
......@@ -939,7 +941,7 @@ struct romlist *getromlistbyromdata (struct romdata *rd)
return getromlistbyids(ids);
}
struct romlist *getromlistbyids (int *ids)
struct romlist *getromlistbyids (const int *ids)
{
struct romdata *rd;
int i, j;
......@@ -958,7 +960,7 @@ struct romlist *getromlistbyids (int *ids)
return NULL;
}
void romwarning (int *ids)
void romwarning (const int *ids)
{
int i, exp;
TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
......@@ -1029,7 +1031,7 @@ static void mergecd32 (uae_u8 *dst, uae_u8 *src, int size)
#endif
}
static void descramble (struct romdata *rd, uae_u8 *data, int size, int odd)
static void descramble (const struct romdata *rd, uae_u8 *data, int size, int odd)
{
int flags = rd->type;
......@@ -1037,7 +1039,7 @@ static void descramble (struct romdata *rd, uae_u8 *data, int size, int odd)
descramble_nordicpro (data, size, odd);
}
static int read_rom_file (uae_u8 *buf, struct romdata *rd)
static int read_rom_file (uae_u8 *buf, const struct romdata *rd)
{
struct zfile *zf;
struct romlist *rl = romlist_getrl (rd);
......@@ -1300,7 +1302,7 @@ int kickstart_checksum (uae_u8 *mem, int size)
return 1;
}
int configure_rom (struct uae_prefs *p, int *rom, int msg)
int configure_rom (struct uae_prefs *p, const int *rom, int msg)
{
struct romdata *rd;
TCHAR *path = 0;
......
......@@ -199,7 +199,7 @@ uae_u8 restore_u8_func (uae_u8 **dstp)
*dstp = dst + 1;
return v;
}
TCHAR *restore_string_func (const uae_u8 **dstp)
TCHAR *restore_string_func (uae_u8 **dstp)
{
int len;
uae_u8 v;
......@@ -219,7 +219,7 @@ TCHAR *restore_string_func (const uae_u8 **dstp)
#ifdef SAVESTATE
/* read and write IFF-style hunks */
static void save_chunk (struct zfile *f, uae_u8 *chunk, size_t len, const TCHAR *name, int compress)
static void save_chunk (struct zfile *f, uae_u8 *chunk, size_t len, TCHAR *name, int compress)
{
uae_u8 tmp[8], *dst;
uae_u8 zero[4]= { 0, 0, 0, 0 };
......@@ -287,7 +287,7 @@ static uae_u8 *restore_chunk (struct zfile *f, TCHAR *name, size_t *len, size_t
uae_u8 tmp[6], dummy[4], *mem;
const uae_u8 *src;
uae_u32 flags;
size_t len2;
int len2;
*totallen = 0;
/* chunk name */
......@@ -846,12 +846,12 @@ int save_state (const TCHAR *filename, const TCHAR *description)
xfree (dst);
#endif
#ifdef CDTV
dst = save_dmac (&len);
save_chunk (f, dst, len, "DMAC", 0);
xfree (dst);
dst = save_cdtv (&len);
save_chunk (f, dst, len, "CDTV", 0);
xfree (dst);
dst = save_dmac (&len);
save_chunk (f, dst, len, "DMAC", 0);
xfree (dst);
#endif
#ifdef ACTION_REPLAY
......@@ -888,7 +888,7 @@ int save_state (const TCHAR *filename, const TCHAR *description)
}
#endif
#ifdef CD32
for (i = 0; i < 10; i++) {
for (i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
dst = save_cd (i, &len);
if (dst) {
_stprintf (name, "CDU%d", i);
......
......@@ -800,7 +800,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
{
int start = io_offset;
int end = io_length + start;
if (!sys_command_cd_play2 (dev->di.unitnum, start, end, 0, NULL))
if (!sys_command_cd_play (dev->di.unitnum, start, end, 0))
io_error = IOERR_BADADDRESS;
}
break;
......@@ -808,7 +808,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
{
int start = msf2lsn (io_offset);
int end = msf2lsn (io_length) + start;
if (!sys_command_cd_play2 (dev->di.unitnum, start, end, 0, NULL))
if (!sys_command_cd_play (dev->di.unitnum, start, end, 0))
io_error = IOERR_BADADDRESS;
}
break;
......@@ -819,7 +819,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
if (sys_command_cd_toc (dev->di.unitnum, &toc)) {
for (i = toc.first_track_offset; i < toc.last_track_offset; i++) {
if (i == io_offset && i + io_length <= toc.last_track_offset) {
ok = sys_command_cd_play2 (dev->di.unitnum, toc.toc[i].address, toc.toc[i + io_length].address, 0, NULL);
ok = sys_command_cd_play (dev->di.unitnum, toc.toc[i].address, toc.toc[i + io_length].address, 0);
break;
}
}
......
......@@ -445,7 +445,7 @@ configure:4344: $? = 0
configure:4344: result: yes
configure:4350: checking for _doprnt
configure:4350: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccg6gkCX.o: In function `main':
/tmp/cca25XDN.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:67: undefined reference to `_doprnt'
collect2: ld returned 1 exit status
configure:4350: $? = 1
......@@ -533,7 +533,7 @@ configure:4364: $? = 0
configure:4364: result: yes
configure:4364: checking for strcmpi
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccyGlF54.o: In function `main':
/tmp/ccfgVok2.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `strcmpi'
collect2: ld returned 1 exit status
configure:4364: $? = 1
......@@ -613,7 +613,7 @@ configure: failed program was:
configure:4364: result: no
configure:4364: checking for stricmp
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/cct8UV89.o: In function `main':
/tmp/ccY0iee7.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `stricmp'
collect2: ld returned 1 exit status
configure:4364: $? = 1
......
......@@ -1551,7 +1551,7 @@ int zfile_zopen (const TCHAR *name, zfile_callback zc, void *user)
TCHAR path[MAX_DPATH];
manglefilename (path, name);
l = zfile_fopen_2 (path, L"rb", ZFD_NORMAL);
l = zfile_fopen_2 (path, "rb", ZFD_NORMAL);
if (!l)
return 0;
ztype = iszip (l);
......@@ -1632,7 +1632,7 @@ static struct zfile *zfile_fopen_internet (const TCHAR *name, const TCHAR *mode,
if (!hi) {
hi = InternetOpen (WINUAEAPPNAME, INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, NULL, NULL, 0);
if (hi == NULL) {
write_log (L"InternetOpen() failed, %d\n", GetLastError ());
write_log ("InternetOpen() failed, %d\n", GetLastError ());
return NULL;
}
}
......@@ -1641,7 +1641,7 @@ static struct zfile *zfile_fopen_internet (const TCHAR *name, const TCHAR *mode,
DWORD err = GetLastError ();
if (err == ERROR_INTERNET_EXTENDED_ERROR)
InternetGetLastResponseInfo (&ierr, tmp, &outbuf);
write_log (L"InternetOpenUrl(%s) failed %d (%d,%s)\n", name, err, ierr, tmp);
write_log ("InternetOpenUrl(%s) failed %d (%d,%s)\n", name, err, ierr, tmp);
goto end;
}
......@@ -1651,11 +1651,11 @@ static struct zfile *zfile_fopen_internet (const TCHAR *name, const TCHAR *mode,
DWORD size = sizeof statuscode;
if (!HttpQueryInfo (i, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &statuscode, &size, &hindex)) {
DWORD err = GetLastError ();
write_log (L"HttpQueryInfo(%s) failed %d\n", name, err);
write_log ("HttpQueryInfo(%s) failed %d\n", name, err);
goto end;
}
if (statuscode != 200) {
write_log (L"HttpQueryInfo(%s)=%d\n", name, statuscode);
write_log ("HttpQueryInfo(%s)=%d\n", name, statuscode);
goto end;
}
}
......@@ -1672,7 +1672,7 @@ static struct zfile *zfile_fopen_internet (const TCHAR *name, const TCHAR *mode,
DWORD err = GetLastError ();
if (err == ERROR_INTERNET_EXTENDED_ERROR)
InternetGetLastResponseInfo (&ierr, tmp, &outbuf);
write_log (L"InternetReadFile(%s) failed %d (%d,%s)\n", name, err, ierr, tmp);
write_log ("InternetReadFile(%s) failed %d (%d,%s)\n", name, err, ierr, tmp);
break;
}
if (didread == 0)
......@@ -1751,9 +1751,9 @@ static struct zfile *zfile_fopenx2 (const TCHAR *name, const TCHAR *mode, int ma
static struct zfile *zfile_fopenx (const TCHAR *name, const TCHAR *mode, int mask, int index)
{
struct zfile *zf;
//write_log (L"zfile_fopen('%s','%s',%08x,%d)\n", name, mode, mask, index);
//write_log ("zfile_fopen('%s','%s',%08x,%d)\n", name, mode, mask, index);
zf = zfile_fopenx2 (name, mode, mask, index);
//write_log (L"=%p\n", zf);
//write_log ("=%p\n", zf);
return zf;
}
......@@ -2700,6 +2700,37 @@ struct znode *zvolume_adddir_abs (struct zvolume *zv, struct zarchive_info *zai)
return znode_adddir (zn2, p, zai);
}
struct znode *zvolume_addfile_abs (struct zvolume *zv, struct zarchive_info *zai)
{
struct znode *zn, *zn2;
int i;
TCHAR *path = my_strdup (zai->name);
TCHAR *p, *p2;
zn2 = &zv->root;
p = p2 = path;
for (i = 0; path[i]; i++) {
if (path[i] == '/' || path[i] == '\\') {
path[i] = 0;
zn2 = znode_adddir (zn2, p, zai);
path[i] = FSDB_DIR_SEPARATOR;
p = p2 = &path[i + 1];
}
}
if (p2) {
zn = znode_alloc_child (zn2, p2);
zn->size = zai->size;
zn->type = ZNODE_FILE;
zn->mtime = zai->t;
if (zai->comment)
zn->comment = my_strdup (zai->comment);
zn->flags = zai->flags;
addvolumesize (zn->volume, zai->size);
}
xfree (path);
return zn;
}
void zfile_fclose_archive (struct zvolume *zv)
{
struct znode *zn;
......@@ -2737,6 +2768,17 @@ void zfile_fclose_archive (struct zvolume *zv)
xfree (zv);
}
struct zdirectory {
TCHAR *parentpath;
struct znode *first;
struct znode *n;
bool doclose;
struct zvolume *zv;
int cnt;
int offset;
TCHAR **filenames;
};
#ifdef _CONSOLE
static TCHAR *zerror;
#define WRITE_LOG_BUF_SIZE 4096
......
......@@ -17,10 +17,10 @@
#include "options.h"
#include "zfile.h"
#include "archivers/zip/unzip.h"
#include "archivers/dms/pfile.h"
#include "crc32.h"
#include "zarchive.h"
#include "disk.h"
#include "fsdb.h"
#include <zlib.h>
......@@ -42,8 +42,8 @@ static time_t fromdostime (uae_u32 dd)
tm.tm_mon = ((dd >> 21) & 0x0f) - 1;
tm.tm_mday = (dd >> 16) & 0x1f;
t = mktime (&tm);
_tzset ();
t -= _timezone;
tzset ();
t -= timezone;
return t;
}
......@@ -56,18 +56,18 @@ static struct zvolume *getzvolume (struct znode *parent, struct zfile *zf, unsig
case ArchiveFormatZIP:
zv = archive_directory_zip (zf);
break;
case ArchiveFormat7Zip:
zv = archive_directory_7z (zf);
break;
case ArchiveFormatRAR:
zv = archive_directory_rar (zf);
break;
case ArchiveFormatLHA:
zv = archive_directory_lha (zf);
break;
case ArchiveFormatLZX:
zv = archive_directory_lzx (zf);
break;
// case ArchiveFormat7Zip:
// zv = archive_directory_7z (zf);
// break;
// case ArchiveFormatRAR:
// zv = archive_directory_rar (zf);
// break;
// case ArchiveFormatLHA:
// zv = archive_directory_lha (zf);
// break;
// case ArchiveFormatLZX:
// zv = archive_directory_lzx (zf);
// break;
case ArchiveFormatPLAIN:
zv = archive_directory_plain (zf);
break;
......@@ -84,8 +84,8 @@ static struct zvolume *getzvolume (struct znode *parent, struct zfile *zf, unsig
zv = archive_directory_fat (zf);
break;
}
if (!zv)
zv = archive_directory_arcacc (zf, id);
// if (!zv)
// zv = archive_directory_arcacc (zf, id);
return zv;
}
......@@ -251,7 +251,7 @@ struct zvolume *archive_directory_tar (struct zfile *z)
struct zvolume *zv;
struct znode *zn;
_tzset ();
tzset ();
zv = zvolume_alloc (z, ArchiveFormatTAR, NULL, NULL);
for (;;) {
uae_u8 block[512];
......@@ -280,15 +280,15 @@ struct zvolume *archive_directory_tar (struct zfile *z)
if (ustar && (block[256] != 0 && block[256] != '0'))
valid = 0;
size = _strtoui64 ((char*)block + 124, NULL, 8);
size = strtoul ((char*)block + 124, NULL, 8);
if (valid) {
memset (&zai, 0, sizeof zai);
zai.name = au (name);
zai.name = my_strdup (name);
zai.size = size;
zai.t = _strtoui64 ((char*)block + 136, NULL, 8);
zai.t += _timezone;
if (_daylight)
zai.t = strtoul ((char*)block + 136, NULL, 8);
zai.t += timezone;
if (daylight)
zai.t -= 1 * 60 * 60;
if (zai.name[_tcslen (zai.name) - 1] == '/') {
zn = zvolume_adddir_abs (zv, &zai);
......@@ -307,14 +307,7 @@ struct zvolume *archive_directory_tar (struct zfile *z)
struct zfile *archive_access_tar (struct znode *zn)
{
#if 0
struct zfile *zf = zfile_fopen_empty (zn->volume->archive, zn->fullname, zn->size);
zfile_fseek (zn->volume->archive, zn->offset, SEEK_SET);
zfile_fwrite (zf->data, zn->size, 1, zn->volume->archive);
return zf;
#else
return zfile_fopen_parent (zn->volume->archive, zn->fullname, zn->offset, zn->size);
#endif
}
/* ZIP */
......@@ -347,7 +340,7 @@ struct zvolume *archive_directory_zip (struct zfile *z)
err = unzGetCurrentFileInfo (uz, &file_info, filename_inzip2, sizeof (filename_inzip2), NULL, 0, NULL, 0);
if (err != UNZ_OK)
return 0;
filename_inzip = au (filename_inzip2);
filename_inzip = my_strdup (filename_inzip2);
dd = file_info.dosDate;
t = fromdostime (dd);
memset (&zai, 0, sizeof zai);
......@@ -447,7 +440,7 @@ error:
return NULL;
}
static struct zfile *archive_access_zip (struct znode *zn, int flags)
struct zfile *archive_access_zip (struct znode *zn, int flags)
{
return archive_do_zip (zn, NULL, flags);
}
......@@ -480,52 +473,6 @@ struct aaFileInArchiveInfo {
char path[FileInArchiveInfoStringSize];
};
typedef HRESULT (__stdcall *aaReadCallback)(int StreamID, uae_u64 offset, uae_u32 count, void* buf, uae_u32 *processedSize);
typedef HRESULT (__stdcall *aaWriteCallback)(int StreamID, uae_u64 offset, uae_u32 count, const void *buf, uae_u32 *processedSize);
typedef aaHandle (__stdcall *aapOpenArchive)(aaReadCallback function, int StreamID, uae_u64 FileSize, int ArchiveType, int *result, TCHAR *password);
typedef int (__stdcall *aapGetFileCount)(aaHandle ArchiveHandle);
typedef int (__stdcall *aapGetFileInfo)(aaHandle ArchiveHandle, int FileNum, struct aaFileInArchiveInfo *FileInfo);
typedef int (__stdcall *aapExtract)(aaHandle ArchiveHandle, int FileNum, int StreamID, aaWriteCallback WriteFunc, uae_u64 *written);
typedef int (__stdcall *aapCloseArchive)(aaHandle ArchiveHandle);
static aapOpenArchive aaOpenArchive;
static aapGetFileCount aaGetFileCount;
static aapGetFileInfo aaGetFileInfo;
static aapExtract aaExtract;
static aapCloseArchive aaCloseArchive;
#ifdef _WIN32
static HMODULE arcacc_mod;
static void arcacc_free (void)
{
if (arcacc_mod)
FreeLibrary (arcacc_mod);
arcacc_mod = NULL;
}
static int arcacc_init (struct zfile *zf)
{
if (arcacc_mod)
return 1;
arcacc_mod = WIN32_LoadLibrary (L"archiveaccess.dll");
if (!arcacc_mod) {
write_log (L"failed to open archiveaccess.dll ('%s')\n", zfile_getname (zf));
return 0;
}
aaOpenArchive = (aapOpenArchive) GetProcAddress (arcacc_mod, "aaOpenArchive");
aaGetFileCount = (aapGetFileCount) GetProcAddress (arcacc_mod, "aaGetFileCount");
aaGetFileInfo = (aapGetFileInfo) GetProcAddress (arcacc_mod, "aaGetFileInfo");
aaExtract = (aapExtract) GetProcAddress (arcacc_mod, "aaExtract");
aaCloseArchive = (aapCloseArchive) GetProcAddress (arcacc_mod, "aaCloseArchive");
if (!aaOpenArchive || !aaGetFileCount || !aaGetFileInfo || !aaExtract || !aaCloseArchive) {
write_log (L"Missing functions in archiveaccess.dll. Old version?\n");
arcacc_free ();
return 0;
}
return 1;
}
#endif
#define ARCACC_STACKSIZE 10
static struct zfile *arcacc_stack[ARCACC_STACKSIZE];
......@@ -595,7 +542,7 @@ struct zvolume *archive_directory_arcacc (struct zfile *z, unsigned int id)
if (fi.IsDir)
continue;
name = au (fi.path);
name = my_strdup (fi.path);
memset (&zai, 0, sizeof zai);
zai.name = name;
zai.flags = -1;
......@@ -700,7 +647,7 @@ struct zvolume *archive_directory_plain (struct zfile *z)
char *an = ua (zai.name);
char *data = xmalloc (char, 1 + strlen (an) + 1 + 1 + 1);
sprintf (data, "\"%s\"\n", an);
zn = addfile (zv, z, L"s/startup-sequence", (uae_u8*)data, strlen (data));
zn = addfile (zv, z, "s/startup-sequence", (uae_u8*)data, strlen (data));
xfree (data);
xfree (an);
}
......@@ -733,14 +680,14 @@ struct zvolume *archive_directory_plain (struct zfile *z)
}
return zv;
}
static struct zfile *archive_access_plain (struct znode *zn)
struct zfile *archive_access_plain (struct znode *zn)
{
struct zfile *z;
if (zn->offset) {
struct zfile *zf;
z = zfile_fopen_empty (zn->volume->archive, zn->fullname, zn->size);
zf = zfile_fopen2 (zfile_getname (zn->volume->archive), L"rb", zn->volume->archive->zfdmask & ~ZFD_ADF, zn->offset - 1);
zf = zfile_fopen2 (zfile_getname (zn->volume->archive), "rb", zn->volume->archive->zfdmask & ~ZFD_ADF, zn->offset - 1);
if (zf) {
zfile_fread (z->data, zn->size, 1, zf);
zfile_fclose (zf);
......@@ -792,7 +739,7 @@ static TCHAR *getBSTR (uae_u8 *bstr)
for (i = 0; i < n; i++)
buf[i] = *bstr++;
buf[i] = 0;
return au (buf);
return my_strdup (buf);
}
static uae_u32 gl (struct adfhandle *adf, int off)
......@@ -925,7 +872,7 @@ static void recursesfs (struct znode *zn, int root, TCHAR *name, int sfs2)
memset (&zai, 0, sizeof zai);
zai.flags = glx (p + 8) ^ 0x0f;
s = p + (sfs2 ? 27 : 25);
fname = au ((char*)s);
fname = my_strdup ((char*)s);
i = 0;
while (*s) {
s++;
......@@ -934,7 +881,7 @@ static void recursesfs (struct znode *zn, int root, TCHAR *name, int sfs2)
s++;
i++;
if (*s)
zai.comment = au ((char*)s);
zai.comment = my_strdup ((char*)s);
while (*s) {
s++;
i++;
......@@ -1184,7 +1131,7 @@ static int sfsfindblock (struct adfhandle *adf, int btree, int theblock, struct
}
static struct zfile *archive_access_adf (struct znode *zn)
struct zfile *archive_access_adf (struct znode *zn)
{
struct zfile *z = NULL;
int root, ffs;
......@@ -1260,7 +1207,7 @@ static struct zfile *archive_access_adf (struct znode *zn)
for (i = 0; i < sfsblockcnt; i++)
bsize += sfsblocks[i].length * adf->blocksize;
if (bsize < size)
write_log (L"SFS extracting error, %s size mismatch %d<%d\n", z->name, bsize, size);
write_log ("SFS extracting error, %s size mismatch %d<%d\n", z->name, bsize, size);
dst = z->data;
block = zn->offset;
......@@ -1310,7 +1257,7 @@ static TCHAR *tochar (uae_u8 *s, int len)
}
tmp[j] = 0;
}
return au (tmp);
return my_strdup (tmp);
}
struct zvolume *archive_directory_rdb (struct zfile *z)
......@@ -1363,15 +1310,15 @@ struct zvolume *archive_directory_rdb (struct zfile *z)
dos = tochar (buf + 192, 4);
if (!memcmp (dos, L"DOS", 3))
if (!memcmp (dos, "DOS", 3))
rootblock = ((size / blocksize) - 1 + 2) / 2;
else
rootblock = 0;
devname = getBSTR (buf + 36);
_stprintf (tmp, L"%s.hdf", devname);
_stprintf (tmp, "%s.hdf", devname);
memset (&zai, 0, sizeof zai);
_stprintf (comment, L"FS=%s LO=%d HI=%d HEADS=%d SPT=%d RES=%d BLOCK=%d ROOT=%d",
_stprintf (comment, "FS=%s LO=%d HI=%d HEADS=%d SPT=%d RES=%d BLOCK=%d ROOT=%d",
dos, lowcyl, highcyl, surf, spt, reserved, blocksize, rootblock);
zai.comment = comment;
xfree (dos);
......@@ -1386,7 +1333,7 @@ struct zvolume *archive_directory_rdb (struct zfile *z)
zfile_fseek (z, 0, SEEK_SET);
p = buf;
zfile_fread (buf, 1, 512, z);
zai.name = L"rdb_dump.dat";
zai.name = "rdb_dump.dat";
bs = rl (p + 16);
zai.size = rl (p + 140) * bs;
zai.comment = NULL;
......@@ -1397,7 +1344,7 @@ struct zvolume *archive_directory_rdb (struct zfile *z)
return zv;
}
static struct zfile *archive_access_rdb (struct znode *zn)
struct zfile *archive_access_rdb (struct znode *zn)
{
struct zfile *z = zn->volume->archive;
struct zfile *zf;
......@@ -1600,7 +1547,7 @@ static void fatdirectory (struct zfile *z, struct zvolume *zv, TCHAR *name, int
}
fatname[cnt] = 0;
fname = au ((char*)fatname);
fname = my_strdup ((char*)fatname);
name2[0] = 0;
if (name[0]) {
TCHAR sep[] = { FSDB_DIR_SEPARATOR, 0 };
......@@ -1657,12 +1604,12 @@ struct zvolume *archive_directory_fat (struct zfile *z)
dataregion = rootdir + rootentries * 32 / 512;
zv = zvolume_alloc (z, ArchiveFormatFAT, NULL, NULL);
fatdirectory (z, zv, L"", rootdir, rootentries, sectorspercluster, reserved, dataregion, fatbits);
fatdirectory (z, zv, "", rootdir, rootentries, sectorspercluster, reserved, dataregion, fatbits);
zv->method = ArchiveFormatFAT;
return zv;
}
static struct zfile *archive_access_fat (struct znode *zn)
struct zfile *archive_access_fat (struct znode *zn)
{
uae_u8 buf[512] = { 0 };
int fatbits = 12;
......@@ -1714,12 +1661,12 @@ void archive_access_close (void *handle, unsigned int id)
case ArchiveFormatZIP:
archive_close_zip (handle);
break;
case ArchiveFormat7Zip:
archive_close_7z (handle);
break;
case ArchiveFormatRAR:
archive_close_rar (handle);
break;
// case ArchiveFormat7Zip:
// archive_close_7z (handle);
// break;
// case ArchiveFormatRAR:
// archive_close_rar (handle);
// break;
case ArchiveFormatLHA:
break;
case ArchiveFormatADF:
......@@ -1731,9 +1678,9 @@ void archive_access_close (void *handle, unsigned int id)
}
}
static struct zfile *archive_access_dir (struct znode *zn)
struct zfile *archive_access_dir (struct znode *zn)
{
return zfile_fopen (zn->fullname, L"rb", 0);
return zfile_fopen (zn->fullname, "rb", 0);
}
......@@ -1742,7 +1689,7 @@ struct zfile *archive_unpackzfile (struct zfile *zf)
struct zfile *zout = NULL;
if (!zf->archiveparent)
return NULL;
unpack_log (L"delayed unpack '%s'\n", zf->name);
unpack_log ("delayed unpack '%s'\n", zf->name);
zf->datasize = zf->size;
switch (zf->archiveid)
{
......@@ -1765,18 +1712,18 @@ struct zfile *archive_getzfile (struct znode *zn, unsigned int id, int flags)
case ArchiveFormatZIP:
zf = archive_access_zip (zn, flags);
break;
case ArchiveFormat7Zip:
zf = archive_access_7z (zn);
break;
case ArchiveFormatRAR:
zf = archive_access_rar (zn);
break;
case ArchiveFormatLHA:
zf = archive_access_lha (zn);
break;
case ArchiveFormatLZX:
zf = archive_access_lzx (zn);
break;
// case ArchiveFormat7Zip:
// zf = archive_access_7z (zn);
// break;
// case ArchiveFormatRAR:
// zf = archive_access_rar (zn);
// break;
// case ArchiveFormatLHA:
// zf = archive_access_lha (zn);
// break;
// case ArchiveFormatLZX:
// zf = archive_access_lzx (zn);
// break;
case ArchiveFormatPLAIN:
zf = archive_access_plain (zn);
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment